source: trip-planner-front/node_modules/webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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