1 | // @ts-nocheck
|
---|
2 | /*
|
---|
3 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
4 | Author Tobias Koppers @sokra
|
---|
5 | */
|
---|
6 |
|
---|
7 | "use strict";
|
---|
8 |
|
---|
9 | var $installedChunks$ = undefined;
|
---|
10 | var $loadUpdateChunk$ = undefined;
|
---|
11 | var $moduleCache$ = undefined;
|
---|
12 | var $moduleFactories$ = undefined;
|
---|
13 | var $ensureChunkHandlers$ = undefined;
|
---|
14 | var $hasOwnProperty$ = undefined;
|
---|
15 | var $hmrModuleData$ = undefined;
|
---|
16 | var $hmrDownloadUpdateHandlers$ = undefined;
|
---|
17 | var $hmrInvalidateModuleHandlers$ = undefined;
|
---|
18 | var __webpack_require__ = undefined;
|
---|
19 |
|
---|
20 | module.exports = function () {
|
---|
21 | var currentUpdateChunks;
|
---|
22 | var currentUpdate;
|
---|
23 | var currentUpdateRemovedChunks;
|
---|
24 | var currentUpdateRuntime;
|
---|
25 | function applyHandler(options) {
|
---|
26 | if ($ensureChunkHandlers$) delete $ensureChunkHandlers$.$key$Hmr;
|
---|
27 | currentUpdateChunks = undefined;
|
---|
28 | function getAffectedModuleEffects(updateModuleId) {
|
---|
29 | var outdatedModules = [updateModuleId];
|
---|
30 | var outdatedDependencies = {};
|
---|
31 |
|
---|
32 | var queue = outdatedModules.map(function (id) {
|
---|
33 | return {
|
---|
34 | chain: [id],
|
---|
35 | id: id
|
---|
36 | };
|
---|
37 | });
|
---|
38 | while (queue.length > 0) {
|
---|
39 | var queueItem = queue.pop();
|
---|
40 | var moduleId = queueItem.id;
|
---|
41 | var chain = queueItem.chain;
|
---|
42 | var module = $moduleCache$[moduleId];
|
---|
43 | if (
|
---|
44 | !module ||
|
---|
45 | (module.hot._selfAccepted && !module.hot._selfInvalidated)
|
---|
46 | )
|
---|
47 | continue;
|
---|
48 | if (module.hot._selfDeclined) {
|
---|
49 | return {
|
---|
50 | type: "self-declined",
|
---|
51 | chain: chain,
|
---|
52 | moduleId: moduleId
|
---|
53 | };
|
---|
54 | }
|
---|
55 | if (module.hot._main) {
|
---|
56 | return {
|
---|
57 | type: "unaccepted",
|
---|
58 | chain: chain,
|
---|
59 | moduleId: moduleId
|
---|
60 | };
|
---|
61 | }
|
---|
62 | for (var i = 0; i < module.parents.length; i++) {
|
---|
63 | var parentId = module.parents[i];
|
---|
64 | var parent = $moduleCache$[parentId];
|
---|
65 | if (!parent) continue;
|
---|
66 | if (parent.hot._declinedDependencies[moduleId]) {
|
---|
67 | return {
|
---|
68 | type: "declined",
|
---|
69 | chain: chain.concat([parentId]),
|
---|
70 | moduleId: moduleId,
|
---|
71 | parentId: parentId
|
---|
72 | };
|
---|
73 | }
|
---|
74 | if (outdatedModules.indexOf(parentId) !== -1) continue;
|
---|
75 | if (parent.hot._acceptedDependencies[moduleId]) {
|
---|
76 | if (!outdatedDependencies[parentId])
|
---|
77 | outdatedDependencies[parentId] = [];
|
---|
78 | addAllToSet(outdatedDependencies[parentId], [moduleId]);
|
---|
79 | continue;
|
---|
80 | }
|
---|
81 | delete outdatedDependencies[parentId];
|
---|
82 | outdatedModules.push(parentId);
|
---|
83 | queue.push({
|
---|
84 | chain: chain.concat([parentId]),
|
---|
85 | id: parentId
|
---|
86 | });
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | return {
|
---|
91 | type: "accepted",
|
---|
92 | moduleId: updateModuleId,
|
---|
93 | outdatedModules: outdatedModules,
|
---|
94 | outdatedDependencies: outdatedDependencies
|
---|
95 | };
|
---|
96 | }
|
---|
97 |
|
---|
98 | function addAllToSet(a, b) {
|
---|
99 | for (var i = 0; i < b.length; i++) {
|
---|
100 | var item = b[i];
|
---|
101 | if (a.indexOf(item) === -1) a.push(item);
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | // at begin all updates modules are outdated
|
---|
106 | // the "outdated" status can propagate to parents if they don't accept the children
|
---|
107 | var outdatedDependencies = {};
|
---|
108 | var outdatedModules = [];
|
---|
109 | var appliedUpdate = {};
|
---|
110 |
|
---|
111 | var warnUnexpectedRequire = function warnUnexpectedRequire(module) {
|
---|
112 | console.warn(
|
---|
113 | "[HMR] unexpected require(" + module.id + ") to disposed module"
|
---|
114 | );
|
---|
115 | };
|
---|
116 |
|
---|
117 | for (var moduleId in currentUpdate) {
|
---|
118 | if ($hasOwnProperty$(currentUpdate, moduleId)) {
|
---|
119 | var newModuleFactory = currentUpdate[moduleId];
|
---|
120 | /** @type {TODO} */
|
---|
121 | var result = newModuleFactory
|
---|
122 | ? getAffectedModuleEffects(moduleId)
|
---|
123 | : {
|
---|
124 | type: "disposed",
|
---|
125 | moduleId: moduleId
|
---|
126 | };
|
---|
127 | /** @type {Error|false} */
|
---|
128 | var abortError = false;
|
---|
129 | var doApply = false;
|
---|
130 | var doDispose = false;
|
---|
131 | var chainInfo = "";
|
---|
132 | if (result.chain) {
|
---|
133 | chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
|
---|
134 | }
|
---|
135 | switch (result.type) {
|
---|
136 | case "self-declined":
|
---|
137 | if (options.onDeclined) options.onDeclined(result);
|
---|
138 | if (!options.ignoreDeclined)
|
---|
139 | abortError = new Error(
|
---|
140 | "Aborted because of self decline: " +
|
---|
141 | result.moduleId +
|
---|
142 | chainInfo
|
---|
143 | );
|
---|
144 | break;
|
---|
145 | case "declined":
|
---|
146 | if (options.onDeclined) options.onDeclined(result);
|
---|
147 | if (!options.ignoreDeclined)
|
---|
148 | abortError = new Error(
|
---|
149 | "Aborted because of declined dependency: " +
|
---|
150 | result.moduleId +
|
---|
151 | " in " +
|
---|
152 | result.parentId +
|
---|
153 | chainInfo
|
---|
154 | );
|
---|
155 | break;
|
---|
156 | case "unaccepted":
|
---|
157 | if (options.onUnaccepted) options.onUnaccepted(result);
|
---|
158 | if (!options.ignoreUnaccepted)
|
---|
159 | abortError = new Error(
|
---|
160 | "Aborted because " + moduleId + " is not accepted" + chainInfo
|
---|
161 | );
|
---|
162 | break;
|
---|
163 | case "accepted":
|
---|
164 | if (options.onAccepted) options.onAccepted(result);
|
---|
165 | doApply = true;
|
---|
166 | break;
|
---|
167 | case "disposed":
|
---|
168 | if (options.onDisposed) options.onDisposed(result);
|
---|
169 | doDispose = true;
|
---|
170 | break;
|
---|
171 | default:
|
---|
172 | throw new Error("Unexception type " + result.type);
|
---|
173 | }
|
---|
174 | if (abortError) {
|
---|
175 | return {
|
---|
176 | error: abortError
|
---|
177 | };
|
---|
178 | }
|
---|
179 | if (doApply) {
|
---|
180 | appliedUpdate[moduleId] = newModuleFactory;
|
---|
181 | addAllToSet(outdatedModules, result.outdatedModules);
|
---|
182 | for (moduleId in result.outdatedDependencies) {
|
---|
183 | if ($hasOwnProperty$(result.outdatedDependencies, moduleId)) {
|
---|
184 | if (!outdatedDependencies[moduleId])
|
---|
185 | outdatedDependencies[moduleId] = [];
|
---|
186 | addAllToSet(
|
---|
187 | outdatedDependencies[moduleId],
|
---|
188 | result.outdatedDependencies[moduleId]
|
---|
189 | );
|
---|
190 | }
|
---|
191 | }
|
---|
192 | }
|
---|
193 | if (doDispose) {
|
---|
194 | addAllToSet(outdatedModules, [result.moduleId]);
|
---|
195 | appliedUpdate[moduleId] = warnUnexpectedRequire;
|
---|
196 | }
|
---|
197 | }
|
---|
198 | }
|
---|
199 | currentUpdate = undefined;
|
---|
200 |
|
---|
201 | // Store self accepted outdated modules to require them later by the module system
|
---|
202 | var outdatedSelfAcceptedModules = [];
|
---|
203 | for (var j = 0; j < outdatedModules.length; j++) {
|
---|
204 | var outdatedModuleId = outdatedModules[j];
|
---|
205 | var module = $moduleCache$[outdatedModuleId];
|
---|
206 | if (
|
---|
207 | module &&
|
---|
208 | (module.hot._selfAccepted || module.hot._main) &&
|
---|
209 | // removed self-accepted modules should not be required
|
---|
210 | appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire &&
|
---|
211 | // when called invalidate self-accepting is not possible
|
---|
212 | !module.hot._selfInvalidated
|
---|
213 | ) {
|
---|
214 | outdatedSelfAcceptedModules.push({
|
---|
215 | module: outdatedModuleId,
|
---|
216 | require: module.hot._requireSelf,
|
---|
217 | errorHandler: module.hot._selfAccepted
|
---|
218 | });
|
---|
219 | }
|
---|
220 | }
|
---|
221 |
|
---|
222 | var moduleOutdatedDependencies;
|
---|
223 |
|
---|
224 | return {
|
---|
225 | dispose: function () {
|
---|
226 | currentUpdateRemovedChunks.forEach(function (chunkId) {
|
---|
227 | delete $installedChunks$[chunkId];
|
---|
228 | });
|
---|
229 | currentUpdateRemovedChunks = undefined;
|
---|
230 |
|
---|
231 | var idx;
|
---|
232 | var queue = outdatedModules.slice();
|
---|
233 | while (queue.length > 0) {
|
---|
234 | var moduleId = queue.pop();
|
---|
235 | var module = $moduleCache$[moduleId];
|
---|
236 | if (!module) continue;
|
---|
237 |
|
---|
238 | var data = {};
|
---|
239 |
|
---|
240 | // Call dispose handlers
|
---|
241 | var disposeHandlers = module.hot._disposeHandlers;
|
---|
242 | for (j = 0; j < disposeHandlers.length; j++) {
|
---|
243 | disposeHandlers[j].call(null, data);
|
---|
244 | }
|
---|
245 | $hmrModuleData$[moduleId] = data;
|
---|
246 |
|
---|
247 | // disable module (this disables requires from this module)
|
---|
248 | module.hot.active = false;
|
---|
249 |
|
---|
250 | // remove module from cache
|
---|
251 | delete $moduleCache$[moduleId];
|
---|
252 |
|
---|
253 | // when disposing there is no need to call dispose handler
|
---|
254 | delete outdatedDependencies[moduleId];
|
---|
255 |
|
---|
256 | // remove "parents" references from all children
|
---|
257 | for (j = 0; j < module.children.length; j++) {
|
---|
258 | var child = $moduleCache$[module.children[j]];
|
---|
259 | if (!child) continue;
|
---|
260 | idx = child.parents.indexOf(moduleId);
|
---|
261 | if (idx >= 0) {
|
---|
262 | child.parents.splice(idx, 1);
|
---|
263 | }
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | // remove outdated dependency from module children
|
---|
268 | var dependency;
|
---|
269 | for (var outdatedModuleId in outdatedDependencies) {
|
---|
270 | if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
|
---|
271 | module = $moduleCache$[outdatedModuleId];
|
---|
272 | if (module) {
|
---|
273 | moduleOutdatedDependencies =
|
---|
274 | outdatedDependencies[outdatedModuleId];
|
---|
275 | for (j = 0; j < moduleOutdatedDependencies.length; j++) {
|
---|
276 | dependency = moduleOutdatedDependencies[j];
|
---|
277 | idx = module.children.indexOf(dependency);
|
---|
278 | if (idx >= 0) module.children.splice(idx, 1);
|
---|
279 | }
|
---|
280 | }
|
---|
281 | }
|
---|
282 | }
|
---|
283 | },
|
---|
284 | apply: function (reportError) {
|
---|
285 | // insert new code
|
---|
286 | for (var updateModuleId in appliedUpdate) {
|
---|
287 | if ($hasOwnProperty$(appliedUpdate, updateModuleId)) {
|
---|
288 | $moduleFactories$[updateModuleId] = appliedUpdate[updateModuleId];
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | // run new runtime modules
|
---|
293 | for (var i = 0; i < currentUpdateRuntime.length; i++) {
|
---|
294 | currentUpdateRuntime[i](__webpack_require__);
|
---|
295 | }
|
---|
296 |
|
---|
297 | // call accept handlers
|
---|
298 | for (var outdatedModuleId in outdatedDependencies) {
|
---|
299 | if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
|
---|
300 | var module = $moduleCache$[outdatedModuleId];
|
---|
301 | if (module) {
|
---|
302 | moduleOutdatedDependencies =
|
---|
303 | outdatedDependencies[outdatedModuleId];
|
---|
304 | var callbacks = [];
|
---|
305 | var errorHandlers = [];
|
---|
306 | var dependenciesForCallbacks = [];
|
---|
307 | for (var j = 0; j < moduleOutdatedDependencies.length; j++) {
|
---|
308 | var dependency = moduleOutdatedDependencies[j];
|
---|
309 | var acceptCallback =
|
---|
310 | module.hot._acceptedDependencies[dependency];
|
---|
311 | var errorHandler =
|
---|
312 | module.hot._acceptedErrorHandlers[dependency];
|
---|
313 | if (acceptCallback) {
|
---|
314 | if (callbacks.indexOf(acceptCallback) !== -1) continue;
|
---|
315 | callbacks.push(acceptCallback);
|
---|
316 | errorHandlers.push(errorHandler);
|
---|
317 | dependenciesForCallbacks.push(dependency);
|
---|
318 | }
|
---|
319 | }
|
---|
320 | for (var k = 0; k < callbacks.length; k++) {
|
---|
321 | try {
|
---|
322 | callbacks[k].call(null, moduleOutdatedDependencies);
|
---|
323 | } catch (err) {
|
---|
324 | if (typeof errorHandlers[k] === "function") {
|
---|
325 | try {
|
---|
326 | errorHandlers[k](err, {
|
---|
327 | moduleId: outdatedModuleId,
|
---|
328 | dependencyId: dependenciesForCallbacks[k]
|
---|
329 | });
|
---|
330 | } catch (err2) {
|
---|
331 | if (options.onErrored) {
|
---|
332 | options.onErrored({
|
---|
333 | type: "accept-error-handler-errored",
|
---|
334 | moduleId: outdatedModuleId,
|
---|
335 | dependencyId: dependenciesForCallbacks[k],
|
---|
336 | error: err2,
|
---|
337 | originalError: err
|
---|
338 | });
|
---|
339 | }
|
---|
340 | if (!options.ignoreErrored) {
|
---|
341 | reportError(err2);
|
---|
342 | reportError(err);
|
---|
343 | }
|
---|
344 | }
|
---|
345 | } else {
|
---|
346 | if (options.onErrored) {
|
---|
347 | options.onErrored({
|
---|
348 | type: "accept-errored",
|
---|
349 | moduleId: outdatedModuleId,
|
---|
350 | dependencyId: dependenciesForCallbacks[k],
|
---|
351 | error: err
|
---|
352 | });
|
---|
353 | }
|
---|
354 | if (!options.ignoreErrored) {
|
---|
355 | reportError(err);
|
---|
356 | }
|
---|
357 | }
|
---|
358 | }
|
---|
359 | }
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | // Load self accepted modules
|
---|
365 | for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
|
---|
366 | var item = outdatedSelfAcceptedModules[o];
|
---|
367 | var moduleId = item.module;
|
---|
368 | try {
|
---|
369 | item.require(moduleId);
|
---|
370 | } catch (err) {
|
---|
371 | if (typeof item.errorHandler === "function") {
|
---|
372 | try {
|
---|
373 | item.errorHandler(err, {
|
---|
374 | moduleId: moduleId,
|
---|
375 | module: $moduleCache$[moduleId]
|
---|
376 | });
|
---|
377 | } catch (err1) {
|
---|
378 | if (options.onErrored) {
|
---|
379 | options.onErrored({
|
---|
380 | type: "self-accept-error-handler-errored",
|
---|
381 | moduleId: moduleId,
|
---|
382 | error: err1,
|
---|
383 | originalError: err
|
---|
384 | });
|
---|
385 | }
|
---|
386 | if (!options.ignoreErrored) {
|
---|
387 | reportError(err1);
|
---|
388 | reportError(err);
|
---|
389 | }
|
---|
390 | }
|
---|
391 | } else {
|
---|
392 | if (options.onErrored) {
|
---|
393 | options.onErrored({
|
---|
394 | type: "self-accept-errored",
|
---|
395 | moduleId: moduleId,
|
---|
396 | error: err
|
---|
397 | });
|
---|
398 | }
|
---|
399 | if (!options.ignoreErrored) {
|
---|
400 | reportError(err);
|
---|
401 | }
|
---|
402 | }
|
---|
403 | }
|
---|
404 | }
|
---|
405 |
|
---|
406 | return outdatedModules;
|
---|
407 | }
|
---|
408 | };
|
---|
409 | }
|
---|
410 | $hmrInvalidateModuleHandlers$.$key$ = function (moduleId, applyHandlers) {
|
---|
411 | if (!currentUpdate) {
|
---|
412 | currentUpdate = {};
|
---|
413 | currentUpdateRuntime = [];
|
---|
414 | currentUpdateRemovedChunks = [];
|
---|
415 | applyHandlers.push(applyHandler);
|
---|
416 | }
|
---|
417 | if (!$hasOwnProperty$(currentUpdate, moduleId)) {
|
---|
418 | currentUpdate[moduleId] = $moduleFactories$[moduleId];
|
---|
419 | }
|
---|
420 | };
|
---|
421 | $hmrDownloadUpdateHandlers$.$key$ = function (
|
---|
422 | chunkIds,
|
---|
423 | removedChunks,
|
---|
424 | removedModules,
|
---|
425 | promises,
|
---|
426 | applyHandlers,
|
---|
427 | updatedModulesList
|
---|
428 | ) {
|
---|
429 | applyHandlers.push(applyHandler);
|
---|
430 | currentUpdateChunks = {};
|
---|
431 | currentUpdateRemovedChunks = removedChunks;
|
---|
432 | currentUpdate = removedModules.reduce(function (obj, key) {
|
---|
433 | obj[key] = false;
|
---|
434 | return obj;
|
---|
435 | }, {});
|
---|
436 | currentUpdateRuntime = [];
|
---|
437 | chunkIds.forEach(function (chunkId) {
|
---|
438 | if (
|
---|
439 | $hasOwnProperty$($installedChunks$, chunkId) &&
|
---|
440 | $installedChunks$[chunkId] !== undefined
|
---|
441 | ) {
|
---|
442 | promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
|
---|
443 | currentUpdateChunks[chunkId] = true;
|
---|
444 | } else {
|
---|
445 | currentUpdateChunks[chunkId] = false;
|
---|
446 | }
|
---|
447 | });
|
---|
448 | if ($ensureChunkHandlers$) {
|
---|
449 | $ensureChunkHandlers$.$key$Hmr = function (chunkId, promises) {
|
---|
450 | if (
|
---|
451 | currentUpdateChunks &&
|
---|
452 | $hasOwnProperty$(currentUpdateChunks, chunkId) &&
|
---|
453 | !currentUpdateChunks[chunkId]
|
---|
454 | ) {
|
---|
455 | promises.push($loadUpdateChunk$(chunkId));
|
---|
456 | currentUpdateChunks[chunkId] = true;
|
---|
457 | }
|
---|
458 | };
|
---|
459 | }
|
---|
460 | };
|
---|
461 | };
|
---|