1////////////////////////////////////////////////////////////////////////// 2// // 3// This is a generated file. You can view the original // 4// source in your browser if your browser supports source maps. // 5// Source maps are supported by all recent versions of Chrome, Safari, // 6// and Firefox, and by Internet Explorer 11. // 7// // 8////////////////////////////////////////////////////////////////////////// 9 10 11Package["core-runtime"].queue("hot-module-replacement",function () {/* Imports */ 12var meteorInstall = Package.modules.meteorInstall; 13var meteorBabelHelpers = Package.modules.meteorBabelHelpers; 14var Meteor = Package.meteor.Meteor; 15var global = Package.meteor.global; 16var meteorEnv = Package.meteor.meteorEnv; 17 18var require = meteorInstall({"node_modules":{"meteor":{"hot-module-replacement":{
18"hot-api.js":function module(require,exports,module){ 19 20///////////////////////////////////////////////////////////////////////////////////////////////////////////// 21// // 22// packages/hot-module-replacement/hot-api.js // 23// // 24///////////////////////////////////////////////////////////////////////////////////////////////////////////// 25 // 26var meteorInstall = Package['modules-runtime'].meteorInstall; 27 28/** 29 * @summary The Hot API used to configure HMR 30 * @memberof module 31 * @name hot 32 */ 33Object.defineProperty(meteorInstall.Module.prototype, "hot", { 34 get: function () { 35 if (!this._hotState) { 36 this._hotState = { 37 // if null, whether it accepts depends on all of the modules that 38 // required it 39 _hotAccepts: null, 40 _disposeHandlers: [], 41 data: null 42 }; 43 } 44 45 var hotState = this._hotState; 46 var module = this; 47 48 return { 49 /** 50 * @summary Accept updates to this module. Also applies to its dependencies, 51 * as long as the other modules that import the dependencies also accept 52 * updates. 53 * @locus Client 54 * @memberOf module.hot 55 * @instance 56 * @name accept 57 */ 58 accept: function () { 59 if (arguments.length > 0) { 60 console.warn('hot.accept does not support any arguments.'); 61 } 62 63 if (hotState._hotAccepts === false) { 64 return; 65 } 66 67 hotState._hotAccepts = true; 68 }, 69 /** 70 * @summary Disable updating this module or its dependencies with HMR. 71 * Hot code push will be used instead. Can not be overridden by calling 72 * module.hot.accept later. 73 * @locus Client 74 * @memberOf module.hot 75 * @instance 76 * @name decline 77 */ 78 decline: function () { 79 if (arguments.length > 0) { 80 throw new Error('hot.decline does not support any arguments.'); 81 } 82 83 hotState._hotAccepts = false; 84 }, 85 /** 86 * @summary Add a call back to clean up the module before replacing it 87 * @locus Client 88 * @memberOf module.hot 89 * @instance 90 * @name dispose 91 * @param {module.hot.DisposeFunction} callback Called before replacing the old module. 92 */ 93 dispose: function (cb) { 94 hotState._disposeHandlers.push(cb); 95 }, 96 /** 97 * @summary Add callbacks to run before and after a module is required 98 * @locus Client 99 * @memberOf module.hot 100 * @instance 101 * @name onRequire 102 * @param {Object} callbacks Can have before and after methods, called before a module is required, 103 * and after it finished being evaluated 104 */ 105 onRequire: function (callbacks) { 106 return module._onRequire(callbacks); 107 }, 108 _canAcceptUpdate: function () { 109 return hotState._hotAccepts; 110 }, 111 /** 112 * @summary Defaults to null. When the module is replaced, 113 * this is set to the object passed to dispose handlers. 114 * @locus Client 115 * @memberOf module.hot 116 * @instance 117 * @name data 118 */ 119 data: hotState.data 120 } 121 }, 122 set: function () { } 123}); 124 125///////////////////////////////////////////////////////////////////////////////////////////////////////////// 126 127},
127"client.js":function module(require,exports,module){ 128 129///////////////////////////////////////////////////////////////////////////////////////////////////////////// 130// // 131// packages/hot-module-replacement/client.js // 132// // 133///////////////////////////////////////////////////////////////////////////////////////////////////////////// 134 // 135// TODO: add an api to Reify to update cached exports for a module 136var ReifyEntry = require('/node_modules/meteor/modules/node_modules/@meteorjs/reify/lib/runtime/entry.js') 137 138var SOURCE_URL_PREFIX = "meteor://\ud83d\udcbbapp"; 139 140var appliedChangeSets = []; 141var removeErrorMessage = null; 142 143var arch = Meteor.isCordova ? "web.cordova" : 144 Meteor.isModern ? "web.browser" : "web.browser.legacy"; 145 146var initialVersions = __meteor_runtime_config__.autoupdate.versions[arch]; 147var lastUpdated = initialVersions.versionHmr; 148var hmrSecret = __meteor_runtime_config__._hmrSecret; 149 150// Cordova doesn't need the hmrSecret, though cordova is also unable to tell 151// if Meteor needs to be restarted to enable HMR; 152var enabled = Meteor.isCordova || !!hmrSecret; 153 154if (!enabled) { 155 console.log('Restart Meteor to enable HMR'); 156} 157 158var imported = Object.create(null); 159var importedBy = Object.create(null); 160 161if (module._onRequire) { 162 module._onRequire({ 163 before: function (importedModule, parentId) { 164 if (parentId === module.id) { 165 // While applying updates we import modules to re-run them. 166 // Don't track those imports since we don't want them to affect 167 // if a future change to the file can be accepted 168 return; 169 } 170 imported[parentId] = imported[parentId] || new Set(); 171 imported[parentId].add(importedModule.id); 172 173 importedBy[importedModule.id] = importedBy[importedModule.id] || new Set(); 174 importedBy[importedModule.id].add(parentId); 175 }, 176 }); 177} 178 179// On web, we can reload the page any time to get the new version. On cordova, 180// we have to wait until Reload._onMigrate is called 181var hotCodePushReady = arch !== 'web.cordova'; 182 183var useHotCodePush = false; 184var forceReload = function () { 185 useHotCodePush = true; 186 // Wait until Reload package has been loaded 187 Meteor.startup(function () { 188 if (hotCodePushReady) { 189 Package['reload'].Reload._reload(); 190 } 191 }); 192}; 193 194// Once an eager update fails, we stop processing future updates since they 195// might depend on the failed update. This gets reset when we re-try applying 196// the changes as non-eager updates. 197var applyEagerUpdates = true; 198 199function handleMessage(message) { 200 if (message.type === 'register-failed') { 201 if (message.reason === 'wrong-app') { 202 console.log('HMR: A different app is running on', Meteor.absoluteUrl()); 203 console.log('HMR: Once you start this app again reload the page to re-enable HMR'); 204 } else if (message.reason === 'wrong-secret') { 205 console.log('HMR: Have the wrong secret, probably because Meteor was restarted'); 206 console.log('HMR: Will enable HMR the next time the page is loaded'); 207 useHotCodePush = true; 208 } else { 209 console.log('HMR: Register failed for unknown reason', message); 210 } 211 return; 212 } else if (message.type === 'app-state') { 213 if (removeErrorMessage) { 214 removeErrorMessage(); 215 } 216 217 if (message.state === 'error' && Package['dev-error-overlay']) { 218 removeErrorMessage = Package['dev-error-overlay'] 219 .DevErrorOverlay 220 .showMessage('Your app is crashing. Here are the latest logs:', message.log.join('\n')); 221 } 222 223 return; 224 } 225 226 if (message.type !== 'changes') { 227 throw new Error('Unknown HMR message type ' + message.type); 228 } 229 230 if (message.eager && !applyEagerUpdates) { 231 return; 232 } else if (!message.eager) { 233 // Now that the build has finished, we will finish handling any updates 234 // that failed while being eagerly applied. Afterwards, we will either 235 // fall back to hot code push, or be in a state where we can start handling 236 // eager updates again 237 applyEagerUpdates = true; 238 } 239 240 var hasUnreloadable = message.changeSets.find(function (changeSet) { 241 return !changeSet.reloadable; 242 }); 243 244 if ( 245 hasUnreloadable || 246 message.changeSets.length === 0 247 ) { 248 if (message.eager) { 249 // This was an attempt to reload before the build finishes 250 // If we can't, we will wait until the build finishes to properly handle it 251 // For now, we will disable eager updates in case future updates depended 252 // on these 253 applyEagerUpdates = false;
254 return; 255 } 256 257 console.log('HMR: Unable to do HMR. Falling back to hot code push.'); 258 // Complete hot code push if we can not do hot module reload 259 return forceReload(); 260 } 261 262 // In case the user changed how a module works with HMR 263 // in one of the earlier change sets, we want to apply each 264 // change set one at a time in order. 265 var succeeded = message.changeSets.filter(function (changeSet) { 266 return !appliedChangeSets.includes(changeSet.id) 267 }).every(function (changeSet) { 268 var applied = applyChangeset(changeSet, message.eager); 269 270 // We don't record if a module is unreplaceable 271 // during an eager update so we can retry and 272 // handle the failure after the build finishes 273 if (applied || !message.eager) { 274 appliedChangeSets.push(changeSet.id); 275 } 276 277 return applied; 278 }); 279 280 if (message.eager) { 281 // If there were any failures, we will stop applying eager updates for now 282 // and wait until after the build finishes to handle the failures 283 applyEagerUpdates = succeeded; 284 return; 285 } 286 287 if (!succeeded) { 288 console.log('HMR: Some changes can not be applied with HMR. Using hot code push.') 289 290 forceReload(); 291 return; 292 } 293 294 if (message.changeSets.length > 0) { 295 lastUpdated = message.changeSets[message.changeSets.length - 1].linkedAt; 296 } 297} 298 299var socket; 300var disconnected = false; 301var pendingMessages = []; 302 303function send(message) { 304 if (socket) { 305 socket.send(JSON.stringify(message)); 306 } else { 307 pendingMessages.push(message); 308 } 309} 310 311function connect() { 312 if (useHotCodePush) { 313 // The page will reload, no reason to 314 // connect and show more logs in the console 315 return; 316 } 317 318 // If we've successfully connected and then was disconnected, we avoid showing 319 // any more connection errors in the console until we've connected again 320 var logDisconnect = !disconnected; 321 var wsUrl = Meteor.absoluteUrl('__meteor__hmr__/websocket'); 322 var protocol = wsUrl.startsWith('https://') ? 'wss://' : 'ws://'; 323 wsUrl = wsUrl.replace(/^.+\/\//, protocol); 324 socket = new WebSocket(wsUrl); 325 326 socket.addEventListener('close', function () { 327 socket = null; 328 329 if (logDisconnect && !useHotCodePush) { 330 console.log('HMR: websocket closed'); 331 } 332 333 disconnected = true; 334 setTimeout(connect, 2000); 335 }); 336 337 socket.addEventListener('open', function () { 338 logDisconnect = true; 339 disconnected = false; 340 341 console.log('HMR: connected'); 342 socket.send(JSON.stringify({ 343 type: 'register', 344 arch: arch, 345 secret: hmrSecret, 346 appId: __meteor_runtime_config__.appId, 347 })); 348 349 var toSend = pendingMessages.slice(); 350 pendingMessages = []; 351 352 toSend.forEach(function (message) { 353 send(message); 354 }); 355 }); 356 357 socket.addEventListener('message', function (event) { 358 handleMessage(JSON.parse(event.data)); 359 }); 360} 361
362if (enabled) { 363 connect(); 364} else { 365 useHotCodePush = true; 366} 367 368function requestChanges() { 369 send({ 370 type: 'request-changes', 371 arch: arch, 372 after: lastUpdated 373 }); 374} 375 376function walkTree(pathParts, tree) { 377 var part = pathParts.shift(); 378 var _module = tree.contents[part]; 379 380 if (!_module) { 381 console.log('HMR: file does not exist', part, pathParts, _module, tree); 382 throw new Error('not-exist'); 383 } 384 385 if (pathParts.length === 0) { 386 return _module; 387 } 388 389 return walkTree(pathParts, _module); 390} 391 392function findFile(moduleId) { 393 return walkTree(moduleId.split('/').slice(1), module._getRoot()); 394} 395 396// btoa with unicode support 397function utoa(data) { 398 return btoa(unescape(encodeURIComponent(data))); 399} 400 401function createInlineSourceMap(map) { 402 return "//# sourceMappingURL=data:application/json;base64," + utoa(JSON.stringify(map)); 403} 404 405function createModuleContent (code, map) { 406 return function () { 407 return eval( 408 // Wrap the function(require,exports,module){...} expression in 409 // parentheses to force it to be parsed as an expression. 410 // The sourceURL is treated as a prefix for the sources array 411 // in the source map 412 "(" + code + ")\n//# sourceURL=" + SOURCE_URL_PREFIX + 413 "\n" + createInlineSourceMap(map) 414 ).apply(this, arguments); 415 } 416} 417 418function replaceFileContent(file, contents) { 419 // TODO: to replace content in packages, we need an eval function that runs 420 // within the package scope, like dynamic imports does. 421 var moduleFunction = createModuleContent(contents.code, contents.map, file.module.id); 422 423 file.contents = moduleFunction; 424} 425 426function checkModuleAcceptsUpdate(moduleId, checked) { 427 checked.add(moduleId); 428 429 if (moduleId === '/' ) { 430 return false; 431 } 432 433 var file = findFile(moduleId); 434 var moduleHot = file.module.hot; 435 var moduleAccepts = moduleHot ? moduleHot._canAcceptUpdate() : false; 436 437 if (moduleAccepts !== null) { 438 return moduleAccepts; 439 } 440 441 var accepts = null; 442 443 // The module did not accept the update. If the update is accepted depends 444 // on if the modules that imported this module accept the update.
445 importedBy[moduleId].forEach(function (depId) { 446 if (depId === '/' && importedBy[moduleId].size > 1) { 447 // This module was eagerly required by Meteor. 448 // Meteor won't know if the module can be updated 449 // but we can check with the other modules that imported it. 450 return; 451 } 452 453 if (checked.has(depId)) { 454 // There is a circular dependency 455 return; 456 } 457 458 var depResult = checkModuleAcceptsUpdate(depId, checked); 459 460 if (accepts !== false) { 461 accepts = depResult; 462 } 463 }); 464 465 return accepts === null ? false : accepts; 466} 467 468function addFiles(addedFiles) { 469 addedFiles.forEach(function (file) { 470 var tree = {}; 471 var segments = file.path.split('/').slice(1); 472 var fileName = segments.pop(); 473 474 var previous = tree; 475 segments.forEach(function (segment) { 476 previous[segment] = previous[segment] || {} 477 previous = previous[segment] 478 }); 479 previous[fileName] = createModuleContent( 480 file.content.code, 481 file.content.map, 482 file.path 483 ); 484 485 meteorInstall(tree, file.meteorInstallOptions); 486 }); 487} 488 489module.constructor.prototype._reset = function (id) { 490 var moduleId = id || this.id; 491 var file = findFile(moduleId); 492 493 var hotState = file.module._hotState; 494 495 var hotData = {}; 496 hotState._disposeHandlers.forEach(function (cb) { 497 cb(hotData); 498 }); 499 500 hotState.data = hotData; 501 hotState._disposeHandlers = []; 502 hotState._hotAccepts = null; 503 504 505 // Clear cached exports 506 // TODO: check how this affects live bindings for ecmascript modules 507 delete file.module.exports; 508 var entry = ReifyEntry.getOrCreate(moduleId); 509 entry.getters = {}; 510 entry.setters = {}; 511 entry.module = null; 512 Object.keys(entry.namespace).forEach(function (key) { 513 if (key !== '__esModule') { 514 delete entry.namespace[key]; 515 } 516 }); 517 518 if (imported[moduleId]) {
519 imported[moduleId].forEach(function (depId) { 520 importedBy[depId].delete(moduleId); 521 }); 522 imported[moduleId] = new Set(); 523 } 524} 525 526module.constructor.prototype._replaceModule = function (id, contents) { 527 var moduleId = id || this.id; 528 var root = this._getRoot(); 529 530 var file; 531 try { 532 file = walkTree(moduleId.split('/').slice(1), root); 533 } catch (e) { 534 if (e.message === 'not-exist') { 535 return null; 536 } 537 538 throw e; 539 } 540 541 if (!file.contents) { 542 // File is a dynamic import that hasn't been loaded 543 return; 544 } 545 546 replaceFileContent(file, contents); 547 548 if (!file.module.exports) { 549 // File hasn't been imported. 550 return; 551 } 552} 553 554function applyChangeset(options) { 555 var changedFiles = options.changedFiles; 556 var addedFiles = options.addedFiles; 557 558 var canApply = true; 559 var toRerun = new Set(); 560 561 changedFiles.forEach(function (changed) { 562 var path = changed.path; 563 var file = findFile(path); 564 565 // Check if the file has been imported. If it hasn't been, 566 // we can assume update to it can be accepted 567 if (file.module.exports) { 568 var checked = new Set(); 569 var accepts = checkModuleAcceptsUpdate(path, checked); 570 571 if (canApply) { 572 canApply = accepts; 573 checked.forEach(function (moduleId) { 574 toRerun.add(moduleId); 575 }); 576 } 577 } 578 }); 579 580 if (!canApply) { 581 return false; 582 } 583 584 changedFiles.forEach(function (changedFile) { 585 module._replaceModule(changedFile.path, changedFile.content); 586 }); 587 588 if (addedFiles.length > 0) { 589 addFiles(addedFiles); 590 } 591 592 toRerun.forEach(function (moduleId) { 593 var file = findFile(moduleId); 594 // clear module caches and hot state 595 file.module._reset(); 596 file.module.loaded = false; 597 }); 598 599 try { 600 toRerun.forEach(function (moduleId) { 601 require(moduleId); 602 }); 603 } catch (error) { 604 console.error('HMR: Error while applying changes:', error); 605 } 606 607 var updateCount = changedFiles.length + addedFiles.length; 608 console.log('HMR: updated ' + updateCount + ' ' + (updateCount === 1 ? 'file' : 'files')); 609 return true; 610} 611 612var nonRefreshableVersion = initialVersions.versionNonRefreshable; 613var replaceableVersion = initialVersions.versionReplaceable; 614 615Meteor.startup(function () { 616 if (!enabled) { 617 return; 618 } 619 620 Package['autoupdate'].Autoupdate._clientVersions.watch(function (doc) { 621 if (doc._id !== arch) { 622 return; 623 } 624 625 if (nonRefreshableVersion !== doc.versionNonRefreshable) { 626 nonRefreshableVersion = doc.versionNonRefreshable; 627 console.log('HMR: Some changes can not be applied with HMR. Using hot code push.') 628 forceReload(); 629 } else if (doc.versionReplaceable !== replaceableVersion) { 630 replaceableVersion = doc.versionReplaceable; 631 632 if (useHotCodePush) { 633 return forceReload(); 634 } 635 636 requestChanges(); 637 } 638 }); 639 640 Package['reload'].Reload._onMigrate(function () { 641 if (useHotCodePush) { 642 return [true]; 643 } 644 645 hotCodePushReady = true; 646 return [false]; 647 }); 648}); 649 650///////////////////////////////////////////////////////////////////////////////////////////////////////////// 651 652}
652}}}},{ 653 "extensions": [ 654 ".js", 655 ".json" 656 ] 657}); 658 659 660/* Exports */ 661return { 662 require: require, 663 eagerModulePaths: [ 664 "/node_modules/meteor/hot-module-replacement/hot-api.js", 665 "/node_modules/meteor/hot-module-replacement/client.js" 666 ] 667}});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.