source: frontend/node_modules/webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 13.2 KB
RevLine 
[9af201e]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
9var $installedChunks$ = undefined;
10var $loadUpdateChunk$ = undefined;
11var $moduleCache$ = undefined;
12var $moduleFactories$ = undefined;
13var $ensureChunkHandlers$ = undefined;
14var $hasOwnProperty$ = undefined;
15var $hmrModuleData$ = undefined;
16var $hmrDownloadUpdateHandlers$ = undefined;
17var $hmrInvalidateModuleHandlers$ = undefined;
18var __webpack_require__ = undefined;
19
20module.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 var result = newModuleFactory
121 ? getAffectedModuleEffects(moduleId)
122 : {
123 type: "disposed",
124 moduleId: moduleId
125 };
126 /** @type {Error|false} */
127 var abortError = false;
128 var doApply = false;
129 var doDispose = false;
130 var chainInfo = "";
131 if (result.chain) {
132 chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
133 }
134 switch (result.type) {
135 case "self-declined":
136 if (options.onDeclined) options.onDeclined(result);
137 if (!options.ignoreDeclined)
138 abortError = new Error(
139 "Aborted because of self decline: " +
140 result.moduleId +
141 chainInfo
142 );
143 break;
144 case "declined":
145 if (options.onDeclined) options.onDeclined(result);
146 if (!options.ignoreDeclined)
147 abortError = new Error(
148 "Aborted because of declined dependency: " +
149 result.moduleId +
150 " in " +
151 result.parentId +
152 chainInfo
153 );
154 break;
155 case "unaccepted":
156 if (options.onUnaccepted) options.onUnaccepted(result);
157 if (!options.ignoreUnaccepted)
158 abortError = new Error(
159 "Aborted because " + moduleId + " is not accepted" + chainInfo
160 );
161 break;
162 case "accepted":
163 if (options.onAccepted) options.onAccepted(result);
164 doApply = true;
165 break;
166 case "disposed":
167 if (options.onDisposed) options.onDisposed(result);
168 doDispose = true;
169 break;
170 default:
171 throw new Error("Unexception type " + result.type);
172 }
173 if (abortError) {
174 return {
175 error: abortError
176 };
177 }
178 if (doApply) {
179 appliedUpdate[moduleId] = newModuleFactory;
180 addAllToSet(outdatedModules, result.outdatedModules);
181 for (moduleId in result.outdatedDependencies) {
182 if ($hasOwnProperty$(result.outdatedDependencies, moduleId)) {
183 if (!outdatedDependencies[moduleId])
184 outdatedDependencies[moduleId] = [];
185 addAllToSet(
186 outdatedDependencies[moduleId],
187 result.outdatedDependencies[moduleId]
188 );
189 }
190 }
191 }
192 if (doDispose) {
193 addAllToSet(outdatedModules, [result.moduleId]);
194 appliedUpdate[moduleId] = warnUnexpectedRequire;
195 }
196 }
197 }
198 currentUpdate = undefined;
199
200 // Store self accepted outdated modules to require them later by the module system
201 var outdatedSelfAcceptedModules = [];
202 for (var j = 0; j < outdatedModules.length; j++) {
203 var outdatedModuleId = outdatedModules[j];
204 var module = $moduleCache$[outdatedModuleId];
205 if (
206 module &&
207 (module.hot._selfAccepted || module.hot._main) &&
208 // removed self-accepted modules should not be required
209 appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire &&
210 // when called invalidate self-accepting is not possible
211 !module.hot._selfInvalidated
212 ) {
213 outdatedSelfAcceptedModules.push({
214 module: outdatedModuleId,
215 require: module.hot._requireSelf,
216 errorHandler: module.hot._selfAccepted
217 });
218 }
219 }
220
221 var moduleOutdatedDependencies;
222
223 return {
224 dispose: function () {
225 currentUpdateRemovedChunks.forEach(function (chunkId) {
226 delete $installedChunks$[chunkId];
227 });
228 currentUpdateRemovedChunks = undefined;
229
230 var idx;
231 var queue = outdatedModules.slice();
232 while (queue.length > 0) {
233 var moduleId = queue.pop();
234 var module = $moduleCache$[moduleId];
235 if (!module) continue;
236
237 var data = {};
238
239 // Call dispose handlers
240 var disposeHandlers = module.hot._disposeHandlers;
241 for (j = 0; j < disposeHandlers.length; j++) {
242 disposeHandlers[j].call(null, data);
243 }
244 $hmrModuleData$[moduleId] = data;
245
246 // disable module (this disables requires from this module)
247 module.hot.active = false;
248
249 // remove module from cache
250 delete $moduleCache$[moduleId];
251
252 // when disposing there is no need to call dispose handler
253 delete outdatedDependencies[moduleId];
254
255 // remove "parents" references from all children
256 for (j = 0; j < module.children.length; j++) {
257 var child = $moduleCache$[module.children[j]];
258 if (!child) continue;
259 idx = child.parents.indexOf(moduleId);
260 if (idx >= 0) {
261 child.parents.splice(idx, 1);
262 }
263 }
264 }
265
266 // remove outdated dependency from module children
267 var dependency;
268 for (var outdatedModuleId in outdatedDependencies) {
269 if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
270 module = $moduleCache$[outdatedModuleId];
271 if (module) {
272 moduleOutdatedDependencies =
273 outdatedDependencies[outdatedModuleId];
274 for (j = 0; j < moduleOutdatedDependencies.length; j++) {
275 dependency = moduleOutdatedDependencies[j];
276 idx = module.children.indexOf(dependency);
277 if (idx >= 0) module.children.splice(idx, 1);
278 }
279 }
280 }
281 }
282 },
283 apply: function (reportError) {
284 var acceptPromises = [];
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 var result;
322 try {
323 result = callbacks[k].call(null, moduleOutdatedDependencies);
324 } catch (err) {
325 if (typeof errorHandlers[k] === "function") {
326 try {
327 errorHandlers[k](err, {
328 moduleId: outdatedModuleId,
329 dependencyId: dependenciesForCallbacks[k]
330 });
331 } catch (err2) {
332 if (options.onErrored) {
333 options.onErrored({
334 type: "accept-error-handler-errored",
335 moduleId: outdatedModuleId,
336 dependencyId: dependenciesForCallbacks[k],
337 error: err2,
338 originalError: err
339 });
340 }
341 if (!options.ignoreErrored) {
342 reportError(err2);
343 reportError(err);
344 }
345 }
346 } else {
347 if (options.onErrored) {
348 options.onErrored({
349 type: "accept-errored",
350 moduleId: outdatedModuleId,
351 dependencyId: dependenciesForCallbacks[k],
352 error: err
353 });
354 }
355 if (!options.ignoreErrored) {
356 reportError(err);
357 }
358 }
359 }
360 if (result && typeof result.then === "function") {
361 acceptPromises.push(result);
362 }
363 }
364 }
365 }
366 }
367
368 var onAccepted = function () {
369 // Load self accepted modules
370 for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
371 var item = outdatedSelfAcceptedModules[o];
372 var moduleId = item.module;
373 try {
374 item.require(moduleId);
375 } catch (err) {
376 if (typeof item.errorHandler === "function") {
377 try {
378 item.errorHandler(err, {
379 moduleId: moduleId,
380 module: $moduleCache$[moduleId]
381 });
382 } catch (err1) {
383 if (options.onErrored) {
384 options.onErrored({
385 type: "self-accept-error-handler-errored",
386 moduleId: moduleId,
387 error: err1,
388 originalError: err
389 });
390 }
391 if (!options.ignoreErrored) {
392 reportError(err1);
393 reportError(err);
394 }
395 }
396 } else {
397 if (options.onErrored) {
398 options.onErrored({
399 type: "self-accept-errored",
400 moduleId: moduleId,
401 error: err
402 });
403 }
404 if (!options.ignoreErrored) {
405 reportError(err);
406 }
407 }
408 }
409 }
410 };
411
412 return Promise.all(acceptPromises)
413 .then(onAccepted)
414 .then(function () {
415 return outdatedModules;
416 });
417 }
418 };
419 }
420 $hmrInvalidateModuleHandlers$.$key$ = function (moduleId, applyHandlers) {
421 if (!currentUpdate) {
422 currentUpdate = {};
423 currentUpdateRuntime = [];
424 currentUpdateRemovedChunks = [];
425 applyHandlers.push(applyHandler);
426 }
427 if (!$hasOwnProperty$(currentUpdate, moduleId)) {
428 currentUpdate[moduleId] = $moduleFactories$[moduleId];
429 }
430 };
431 $hmrDownloadUpdateHandlers$.$key$ = function (
432 chunkIds,
433 removedChunks,
434 removedModules,
435 promises,
436 applyHandlers,
437 updatedModulesList
438 ) {
439 applyHandlers.push(applyHandler);
440 currentUpdateChunks = {};
441 currentUpdateRemovedChunks = removedChunks;
442 currentUpdate = removedModules.reduce(function (obj, key) {
443 obj[key] = false;
444 return obj;
445 }, {});
446 currentUpdateRuntime = [];
447 chunkIds.forEach(function (chunkId) {
448 if (
449 $hasOwnProperty$($installedChunks$, chunkId) &&
450 $installedChunks$[chunkId] !== undefined
451 ) {
452 promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
453 currentUpdateChunks[chunkId] = true;
454 } else {
455 currentUpdateChunks[chunkId] = false;
456 }
457 });
458 if ($ensureChunkHandlers$) {
459 $ensureChunkHandlers$.$key$Hmr = function (chunkId, promises) {
460 if (
461 currentUpdateChunks &&
462 $hasOwnProperty$(currentUpdateChunks, chunkId) &&
463 !currentUpdateChunks[chunkId]
464 ) {
465 promises.push($loadUpdateChunk$(chunkId));
466 currentUpdateChunks[chunkId] = true;
467 }
468 };
469 }
470 };
471};
Note: See TracBrowser for help on using the repository browser.