Buckets:
tahamajs/Other_Lessons / AP /TA_1 /AP-ECE-UT.github.io /node_modules /webpack /hot /lazy-compilation-web.js
| /* global __resourceQuery */ | |
| ; | |
| if (typeof EventSource !== "function") { | |
| throw new Error( | |
| "Environment doesn't support lazy compilation (requires EventSource)" | |
| ); | |
| } | |
| var urlBase = decodeURIComponent(__resourceQuery.slice(1)); | |
| /** @type {EventSource | undefined} */ | |
| var activeEventSource; | |
| var activeKeys = new Map(); | |
| var errorHandlers = new Set(); | |
| var updateEventSource = function updateEventSource() { | |
| if (activeEventSource) activeEventSource.close(); | |
| if (activeKeys.size) { | |
| activeEventSource = new EventSource( | |
| urlBase + Array.from(activeKeys.keys()).join("@") | |
| ); | |
| /** | |
| * @this {EventSource} | |
| * @param {Event & { message?: string, filename?: string, lineno?: number, colno?: number, error?: Error }} event event | |
| */ | |
| activeEventSource.onerror = function (event) { | |
| errorHandlers.forEach(function (onError) { | |
| onError( | |
| new Error( | |
| "Problem communicating active modules to the server: " + | |
| event.message + | |
| " " + | |
| event.filename + | |
| ":" + | |
| event.lineno + | |
| ":" + | |
| event.colno + | |
| " " + | |
| event.error | |
| ) | |
| ); | |
| }); | |
| }; | |
| } else { | |
| activeEventSource = undefined; | |
| } | |
| }; | |
| /** | |
| * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options | |
| * @returns {() => void} function to destroy response | |
| */ | |
| exports.keepAlive = function (options) { | |
| var data = options.data; | |
| var onError = options.onError; | |
| var active = options.active; | |
| var module = options.module; | |
| errorHandlers.add(onError); | |
| var value = activeKeys.get(data) || 0; | |
| activeKeys.set(data, value + 1); | |
| if (value === 0) { | |
| updateEventSource(); | |
| } | |
| if (!active && !module.hot) { | |
| console.log( | |
| "Hot Module Replacement is not enabled. Waiting for process restart..." | |
| ); | |
| } | |
| return function () { | |
| errorHandlers.delete(onError); | |
| setTimeout(function () { | |
| var value = activeKeys.get(data); | |
| if (value === 1) { | |
| activeKeys.delete(data); | |
| updateEventSource(); | |
| } else { | |
| activeKeys.set(data, value - 1); | |
| } | |
| }, 1000); | |
| }; | |
| }; | |
Xet Storage Details
- Size:
- 2.05 kB
- Xet hash:
- 7008bf3bb9d22612874b067911117b85d82a0a71eb15131b24f16c4c71129ca0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.