@lwrjs/loader 0.17.2-alpha.11 → 0.17.2-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +24 -18
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim-legacy.js +23 -17
- package/build/assets/prod/lwr-loader-shim.bundle.js +24 -18
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim.js +23 -17
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +1 -1
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +1 -1
- package/build/shim/shim.d.ts +1 -1
- package/build/shim/shim.js +15 -10
- package/build/shim-legacy/shimLegacy.d.ts +1 -1
- package/build/shim-legacy/shimLegacy.js +15 -10
- package/package.json +7 -7
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Error Shim v0.17.2-alpha.
|
|
7
|
+
/* LWR Error Shim v0.17.2-alpha.14 */
|
|
8
8
|
!function(){"use strict";const o=globalThis;if(!(o.LWR&&o.LWR.define)){const r=new Error("The LWR application failed to bootstrap");if(!o.LWR||!o.LWR.onError)throw r;o.LWR.onError(r)}}();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.17.2-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.17.2-alpha.14 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
id,
|
|
59
59
|
phase: Phase.Start,
|
|
60
60
|
specifier,
|
|
61
|
-
metadata
|
|
61
|
+
metadata,
|
|
62
|
+
specifierIndex
|
|
62
63
|
});
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -85,7 +86,8 @@
|
|
|
85
86
|
id,
|
|
86
87
|
phase: Phase.End,
|
|
87
88
|
specifier,
|
|
88
|
-
metadata
|
|
89
|
+
metadata,
|
|
90
|
+
specifierIndex
|
|
89
91
|
});
|
|
90
92
|
} else if (isPerfSupported) {
|
|
91
93
|
const markName = getMarkName(id, specifier, specifierIndex);
|
|
@@ -208,7 +210,7 @@
|
|
|
208
210
|
// Parse configuration
|
|
209
211
|
this.global = global;
|
|
210
212
|
this.config = global.LWR ;
|
|
211
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-
|
|
213
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-alpha_14';
|
|
212
214
|
|
|
213
215
|
// Set up error handler
|
|
214
216
|
this.errorHandler = this.config.onError ;
|
|
@@ -320,22 +322,26 @@
|
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
|
|
325
|
+
waitForBody() {
|
|
324
326
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
325
327
|
if (typeof document === undefined) {
|
|
326
328
|
return Promise.resolve();
|
|
327
329
|
}
|
|
328
330
|
|
|
329
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
330
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
331
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
332
|
-
return Promise.resolve();
|
|
333
|
-
}
|
|
334
331
|
return new Promise((resolve) => {
|
|
335
332
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
336
|
-
document.
|
|
333
|
+
if (document.body) {
|
|
337
334
|
resolve();
|
|
338
|
-
}
|
|
335
|
+
} else {
|
|
336
|
+
const observer = new MutationObserver(() => {
|
|
337
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
338
|
+
if (document.body) {
|
|
339
|
+
observer.disconnect();
|
|
340
|
+
resolve();
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
observer.observe(document.documentElement, { childList: true });
|
|
344
|
+
}
|
|
339
345
|
});
|
|
340
346
|
}
|
|
341
347
|
|
|
@@ -345,7 +351,7 @@
|
|
|
345
351
|
const exporter = (exports) => {
|
|
346
352
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
347
353
|
};
|
|
348
|
-
define('lwr/profiler/v/0_17_2-
|
|
354
|
+
define('lwr/profiler/v/0_17_2-alpha_14', ['exports'], exporter, {});
|
|
349
355
|
}
|
|
350
356
|
|
|
351
357
|
// Set up the application globals, import map, root custom element...
|
|
@@ -371,7 +377,7 @@
|
|
|
371
377
|
}
|
|
372
378
|
});
|
|
373
379
|
|
|
374
|
-
// by default, app initialization is gated on waiting for
|
|
380
|
+
// by default, app initialization is gated on waiting for body to be available
|
|
375
381
|
const { disableInitDefer } = this.config;
|
|
376
382
|
|
|
377
383
|
// Load the import mappings and application bootstrap module
|
|
@@ -379,7 +385,7 @@
|
|
|
379
385
|
.registerImportMappings(importMappings)
|
|
380
386
|
.then(() => {
|
|
381
387
|
if (!disableInitDefer) {
|
|
382
|
-
return this.
|
|
388
|
+
return this.waitForBody();
|
|
383
389
|
}
|
|
384
390
|
})
|
|
385
391
|
.then(() => loader.load(bootstrapModule))
|
|
@@ -426,14 +432,14 @@
|
|
|
426
432
|
// The loader module is ALWAYS required
|
|
427
433
|
const GLOBAL = globalThis ;
|
|
428
434
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
429
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-
|
|
430
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-
|
|
435
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-alpha_14') < 0) {
|
|
436
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-alpha_14');
|
|
431
437
|
}
|
|
432
438
|
new LoaderShim(GLOBAL);
|
|
433
439
|
|
|
434
440
|
})();
|
|
435
441
|
|
|
436
|
-
LWR.define('lwr/loaderLegacy/v/0_17_2-
|
|
442
|
+
LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_14', ['exports'], (function (exports) { 'use strict';
|
|
437
443
|
|
|
438
444
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
439
445
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.17.2-alpha.
|
|
8
|
-
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_17_2-
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.17.2-alpha.14 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_17_2-alpha_14",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s;if(!n)throw new Error("Expected Loader class to be defined");const i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services,clearRegistry:i.clearRegistry.bind(i)})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return void 0===typeof document?Promise.resolve():new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}createProfilerModule(e){e("lwr/profiler/v/0_17_2-alpha_14",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:n||{},importMappings:o,endpoints:i,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings(o).then((()=>{if(!a)return this.waitForBody()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_17_2-alpha_14")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_17_2-alpha_14"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_17_2-alpha_14",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process,hasProcessEnv=hasProcess&&process.env;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
11
11
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.17.2-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.17.2-alpha.14 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
id,
|
|
59
59
|
phase: Phase.Start,
|
|
60
60
|
specifier,
|
|
61
|
-
metadata
|
|
61
|
+
metadata,
|
|
62
|
+
specifierIndex
|
|
62
63
|
});
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -85,7 +86,8 @@
|
|
|
85
86
|
id,
|
|
86
87
|
phase: Phase.End,
|
|
87
88
|
specifier,
|
|
88
|
-
metadata
|
|
89
|
+
metadata,
|
|
90
|
+
specifierIndex
|
|
89
91
|
});
|
|
90
92
|
} else if (isPerfSupported) {
|
|
91
93
|
const markName = getMarkName(id, specifier, specifierIndex);
|
|
@@ -208,7 +210,7 @@
|
|
|
208
210
|
// Parse configuration
|
|
209
211
|
this.global = global;
|
|
210
212
|
this.config = global.LWR ;
|
|
211
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-
|
|
213
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-alpha_14';
|
|
212
214
|
|
|
213
215
|
// Set up error handler
|
|
214
216
|
this.errorHandler = this.config.onError ;
|
|
@@ -320,22 +322,26 @@
|
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
|
|
325
|
+
waitForBody() {
|
|
324
326
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
325
327
|
if (typeof document === undefined) {
|
|
326
328
|
return Promise.resolve();
|
|
327
329
|
}
|
|
328
330
|
|
|
329
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
330
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
331
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
332
|
-
return Promise.resolve();
|
|
333
|
-
}
|
|
334
331
|
return new Promise((resolve) => {
|
|
335
332
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
336
|
-
document.
|
|
333
|
+
if (document.body) {
|
|
337
334
|
resolve();
|
|
338
|
-
}
|
|
335
|
+
} else {
|
|
336
|
+
const observer = new MutationObserver(() => {
|
|
337
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
338
|
+
if (document.body) {
|
|
339
|
+
observer.disconnect();
|
|
340
|
+
resolve();
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
observer.observe(document.documentElement, { childList: true });
|
|
344
|
+
}
|
|
339
345
|
});
|
|
340
346
|
}
|
|
341
347
|
|
|
@@ -345,7 +351,7 @@
|
|
|
345
351
|
const exporter = (exports) => {
|
|
346
352
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
347
353
|
};
|
|
348
|
-
define('lwr/profiler/v/0_17_2-
|
|
354
|
+
define('lwr/profiler/v/0_17_2-alpha_14', ['exports'], exporter, {});
|
|
349
355
|
}
|
|
350
356
|
|
|
351
357
|
// Set up the application globals, import map, root custom element...
|
|
@@ -371,7 +377,7 @@
|
|
|
371
377
|
}
|
|
372
378
|
});
|
|
373
379
|
|
|
374
|
-
// by default, app initialization is gated on waiting for
|
|
380
|
+
// by default, app initialization is gated on waiting for body to be available
|
|
375
381
|
const { disableInitDefer } = this.config;
|
|
376
382
|
|
|
377
383
|
// Load the import mappings and application bootstrap module
|
|
@@ -379,7 +385,7 @@
|
|
|
379
385
|
.registerImportMappings(importMappings)
|
|
380
386
|
.then(() => {
|
|
381
387
|
if (!disableInitDefer) {
|
|
382
|
-
return this.
|
|
388
|
+
return this.waitForBody();
|
|
383
389
|
}
|
|
384
390
|
})
|
|
385
391
|
.then(() => loader.load(bootstrapModule))
|
|
@@ -426,8 +432,8 @@
|
|
|
426
432
|
// The loader module is ALWAYS required
|
|
427
433
|
const GLOBAL = globalThis ;
|
|
428
434
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
429
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-
|
|
430
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-
|
|
435
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-alpha_14') < 0) {
|
|
436
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-alpha_14');
|
|
431
437
|
}
|
|
432
438
|
new LoaderShim(GLOBAL);
|
|
433
439
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.17.2-alpha.
|
|
7
|
+
/* LWR Module Loader Shim v0.17.2-alpha.14 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
id,
|
|
59
59
|
phase: Phase.Start,
|
|
60
60
|
specifier,
|
|
61
|
-
metadata
|
|
61
|
+
metadata,
|
|
62
|
+
specifierIndex
|
|
62
63
|
});
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -85,7 +86,8 @@
|
|
|
85
86
|
id,
|
|
86
87
|
phase: Phase.End,
|
|
87
88
|
specifier,
|
|
88
|
-
metadata
|
|
89
|
+
metadata,
|
|
90
|
+
specifierIndex
|
|
89
91
|
});
|
|
90
92
|
} else if (isPerfSupported) {
|
|
91
93
|
const markName = getMarkName(id, specifier, specifierIndex);
|
|
@@ -211,7 +213,7 @@
|
|
|
211
213
|
// Parse configuration
|
|
212
214
|
this.global = global;
|
|
213
215
|
this.config = global.LWR ;
|
|
214
|
-
this.loaderSpecifier = 'lwr/loader/v/0_17_2-
|
|
216
|
+
this.loaderSpecifier = 'lwr/loader/v/0_17_2-alpha_14';
|
|
215
217
|
|
|
216
218
|
// Set up error handler
|
|
217
219
|
this.errorHandler = this.config.onError ;
|
|
@@ -324,22 +326,26 @@
|
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
|
|
327
|
-
|
|
329
|
+
waitForBody() {
|
|
328
330
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
329
331
|
if (typeof document === undefined) {
|
|
330
332
|
return Promise.resolve();
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
334
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
335
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
336
|
-
return Promise.resolve();
|
|
337
|
-
}
|
|
338
335
|
return new Promise((resolve) => {
|
|
339
336
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
340
|
-
document.
|
|
337
|
+
if (document.body) {
|
|
341
338
|
resolve();
|
|
342
|
-
}
|
|
339
|
+
} else {
|
|
340
|
+
const observer = new MutationObserver(() => {
|
|
341
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
342
|
+
if (document.body) {
|
|
343
|
+
observer.disconnect();
|
|
344
|
+
resolve();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
observer.observe(document.documentElement, { childList: true });
|
|
348
|
+
}
|
|
343
349
|
});
|
|
344
350
|
}
|
|
345
351
|
|
|
@@ -349,7 +355,7 @@
|
|
|
349
355
|
const exporter = (exports) => {
|
|
350
356
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
351
357
|
};
|
|
352
|
-
define('lwr/profiler/v/0_17_2-
|
|
358
|
+
define('lwr/profiler/v/0_17_2-alpha_14', ['exports'], exporter);
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
// Set up the application globals, import map, root custom element...
|
|
@@ -377,7 +383,7 @@
|
|
|
377
383
|
}
|
|
378
384
|
});
|
|
379
385
|
|
|
380
|
-
// by default, app initialization is gated on waiting for
|
|
386
|
+
// by default, app initialization is gated on waiting for body to be available (via DOMContentLoaded)
|
|
381
387
|
const { disableInitDefer } = this.config;
|
|
382
388
|
|
|
383
389
|
// Load the import mappings and application bootstrap module
|
|
@@ -388,7 +394,7 @@
|
|
|
388
394
|
])
|
|
389
395
|
.then(() => {
|
|
390
396
|
if (!disableInitDefer) {
|
|
391
|
-
return this.
|
|
397
|
+
return this.waitForBody();
|
|
392
398
|
}
|
|
393
399
|
})
|
|
394
400
|
.then(() => loader.load(bootstrapModule))
|
|
@@ -435,14 +441,14 @@
|
|
|
435
441
|
// The loader module is ALWAYS required
|
|
436
442
|
const GLOBAL = globalThis ;
|
|
437
443
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
438
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_17_2-
|
|
439
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_17_2-
|
|
444
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_17_2-alpha_14') < 0) {
|
|
445
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_17_2-alpha_14');
|
|
440
446
|
}
|
|
441
447
|
new LoaderShim(GLOBAL);
|
|
442
448
|
|
|
443
449
|
})();
|
|
444
450
|
|
|
445
|
-
LWR.define('lwr/loader/v/0_17_2-
|
|
451
|
+
LWR.define('lwr/loader/v/0_17_2-alpha_14', ['exports'], (function (exports) { 'use strict';
|
|
446
452
|
|
|
447
453
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
448
454
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.17.2-alpha.
|
|
8
|
-
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const p="function"==typeof setTimeout,u="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),p&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_17_2-alpha_11",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:n}=i;if(!n)throw new Error("Expected Loader class to be defined");const s=new n(r);return o&&o.length&&s.registerExternalModules(o),s.define(e,["exports"],(e=>{Object.assign(e,{define:s.define.bind(s),load:s.load.bind(s),services:s.services})})),s}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_17_2-alpha_11",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{disableInitDefer:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>{if(!d)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):u&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_17_2-alpha_11")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_17_2-alpha_11"),new h(f)}(),LWR.define("lwr/loader/v/0_17_2-alpha_11",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process,hasProcessEnv=hasProcess&&process.env;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const i=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let s=-1;for(let e=0;e<i.length;e++)-1!==s?"/"===i[e]&&(n.push(i.slice(s,e+1)),s=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:s=e:(n.pop(),e+=2):s=e;return-1!==s&&n.push(i.slice(s)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e)).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
7
|
+
/* LWR Module Loader Shim v0.17.2-alpha.14 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const p="function"==typeof setTimeout,u="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),p&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_17_2-alpha_14",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:n}=i;if(!n)throw new Error("Expected Loader class to be defined");const s=new n(r);return o&&o.length&&s.registerExternalModules(o),s.define(e,["exports"],(e=>{Object.assign(e,{define:s.define.bind(s),load:s.load.bind(s),services:s.services})})),s}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return void 0===typeof document?Promise.resolve():new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}createProfilerModule(e){e("lwr/profiler/v/0_17_2-alpha_14",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{disableInitDefer:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>{if(!d)return this.waitForBody()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):u&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_17_2-alpha_14")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_17_2-alpha_14"),new h(f)}(),LWR.define("lwr/loader/v/0_17_2-alpha_14",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process,hasProcessEnv=hasProcess&&process.env;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const i=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let s=-1;for(let e=0;e<i.length;e++)-1!==s?"/"===i[e]&&(n.push(i.slice(s,e+1)),s=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:s=e:(n.pop(),e+=2):s=e;return-1!==s&&n.push(i.slice(s)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e)).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
11
11
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.17.2-alpha.
|
|
7
|
+
/* LWR Module Loader Shim v0.17.2-alpha.14 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
id,
|
|
59
59
|
phase: Phase.Start,
|
|
60
60
|
specifier,
|
|
61
|
-
metadata
|
|
61
|
+
metadata,
|
|
62
|
+
specifierIndex
|
|
62
63
|
});
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -85,7 +86,8 @@
|
|
|
85
86
|
id,
|
|
86
87
|
phase: Phase.End,
|
|
87
88
|
specifier,
|
|
88
|
-
metadata
|
|
89
|
+
metadata,
|
|
90
|
+
specifierIndex
|
|
89
91
|
});
|
|
90
92
|
} else if (isPerfSupported) {
|
|
91
93
|
const markName = getMarkName(id, specifier, specifierIndex);
|
|
@@ -211,7 +213,7 @@
|
|
|
211
213
|
// Parse configuration
|
|
212
214
|
this.global = global;
|
|
213
215
|
this.config = global.LWR ;
|
|
214
|
-
this.loaderSpecifier = 'lwr/loader/v/0_17_2-
|
|
216
|
+
this.loaderSpecifier = 'lwr/loader/v/0_17_2-alpha_14';
|
|
215
217
|
|
|
216
218
|
// Set up error handler
|
|
217
219
|
this.errorHandler = this.config.onError ;
|
|
@@ -324,22 +326,26 @@
|
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
|
|
327
|
-
|
|
329
|
+
waitForBody() {
|
|
328
330
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
329
331
|
if (typeof document === undefined) {
|
|
330
332
|
return Promise.resolve();
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
334
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
335
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
336
|
-
return Promise.resolve();
|
|
337
|
-
}
|
|
338
335
|
return new Promise((resolve) => {
|
|
339
336
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
340
|
-
document.
|
|
337
|
+
if (document.body) {
|
|
341
338
|
resolve();
|
|
342
|
-
}
|
|
339
|
+
} else {
|
|
340
|
+
const observer = new MutationObserver(() => {
|
|
341
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
342
|
+
if (document.body) {
|
|
343
|
+
observer.disconnect();
|
|
344
|
+
resolve();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
observer.observe(document.documentElement, { childList: true });
|
|
348
|
+
}
|
|
343
349
|
});
|
|
344
350
|
}
|
|
345
351
|
|
|
@@ -349,7 +355,7 @@
|
|
|
349
355
|
const exporter = (exports) => {
|
|
350
356
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
351
357
|
};
|
|
352
|
-
define('lwr/profiler/v/0_17_2-
|
|
358
|
+
define('lwr/profiler/v/0_17_2-alpha_14', ['exports'], exporter);
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
// Set up the application globals, import map, root custom element...
|
|
@@ -377,7 +383,7 @@
|
|
|
377
383
|
}
|
|
378
384
|
});
|
|
379
385
|
|
|
380
|
-
// by default, app initialization is gated on waiting for
|
|
386
|
+
// by default, app initialization is gated on waiting for body to be available (via DOMContentLoaded)
|
|
381
387
|
const { disableInitDefer } = this.config;
|
|
382
388
|
|
|
383
389
|
// Load the import mappings and application bootstrap module
|
|
@@ -388,7 +394,7 @@
|
|
|
388
394
|
])
|
|
389
395
|
.then(() => {
|
|
390
396
|
if (!disableInitDefer) {
|
|
391
|
-
return this.
|
|
397
|
+
return this.waitForBody();
|
|
392
398
|
}
|
|
393
399
|
})
|
|
394
400
|
.then(() => loader.load(bootstrapModule))
|
|
@@ -435,8 +441,8 @@
|
|
|
435
441
|
// The loader module is ALWAYS required
|
|
436
442
|
const GLOBAL = globalThis ;
|
|
437
443
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
438
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_17_2-
|
|
439
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_17_2-
|
|
444
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_17_2-alpha_14') < 0) {
|
|
445
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_17_2-alpha_14');
|
|
440
446
|
}
|
|
441
447
|
new LoaderShim(GLOBAL);
|
|
442
448
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR ESM Module Loader v0.17.2-alpha.
|
|
7
|
+
/* LWR ESM Module Loader v0.17.2-alpha.14 */
|
|
8
8
|
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
9
9
|
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader v0.17.2-alpha.
|
|
7
|
+
/* LWR Module Loader v0.17.2-alpha.14 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader v0.17.2-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader v0.17.2-alpha.14 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
package/build/shim/shim.d.ts
CHANGED
package/build/shim/shim.js
CHANGED
|
@@ -115,21 +115,26 @@ export default class LoaderShim {
|
|
|
115
115
|
this.enterErrorState(e);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
waitForBody() {
|
|
119
119
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
120
120
|
if (typeof document === undefined) {
|
|
121
121
|
return Promise.resolve();
|
|
122
122
|
}
|
|
123
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
124
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
125
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
126
|
-
return Promise.resolve();
|
|
127
|
-
}
|
|
128
123
|
return new Promise((resolve) => {
|
|
129
124
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
130
|
-
document.
|
|
125
|
+
if (document.body) {
|
|
131
126
|
resolve();
|
|
132
|
-
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const observer = new MutationObserver(() => {
|
|
130
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
131
|
+
if (document.body) {
|
|
132
|
+
observer.disconnect();
|
|
133
|
+
resolve();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
observer.observe(document.documentElement, { childList: true });
|
|
137
|
+
}
|
|
133
138
|
});
|
|
134
139
|
}
|
|
135
140
|
// Create a module out of the profiler
|
|
@@ -161,7 +166,7 @@ export default class LoaderShim {
|
|
|
161
166
|
loader.define(...this.defineCache[specifier]);
|
|
162
167
|
}
|
|
163
168
|
});
|
|
164
|
-
// by default, app initialization is gated on waiting for
|
|
169
|
+
// by default, app initialization is gated on waiting for body to be available (via DOMContentLoaded)
|
|
165
170
|
const { disableInitDefer } = this.config;
|
|
166
171
|
// Load the import mappings and application bootstrap module
|
|
167
172
|
loader
|
|
@@ -171,7 +176,7 @@ export default class LoaderShim {
|
|
|
171
176
|
])
|
|
172
177
|
.then(() => {
|
|
173
178
|
if (!disableInitDefer) {
|
|
174
|
-
return this.
|
|
179
|
+
return this.waitForBody();
|
|
175
180
|
}
|
|
176
181
|
})
|
|
177
182
|
.then(() => loader.load(bootstrapModule))
|
|
@@ -114,21 +114,26 @@ export default class LoaderShim {
|
|
|
114
114
|
this.enterErrorState(e);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
waitForBody() {
|
|
118
118
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
119
119
|
if (typeof document === undefined) {
|
|
120
120
|
return Promise.resolve();
|
|
121
121
|
}
|
|
122
|
-
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
123
|
-
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
124
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
125
|
-
return Promise.resolve();
|
|
126
|
-
}
|
|
127
122
|
return new Promise((resolve) => {
|
|
128
123
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
129
|
-
document.
|
|
124
|
+
if (document.body) {
|
|
130
125
|
resolve();
|
|
131
|
-
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const observer = new MutationObserver(() => {
|
|
129
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
130
|
+
if (document.body) {
|
|
131
|
+
observer.disconnect();
|
|
132
|
+
resolve();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
observer.observe(document.documentElement, { childList: true });
|
|
136
|
+
}
|
|
132
137
|
});
|
|
133
138
|
}
|
|
134
139
|
// Create a module out of the profiler
|
|
@@ -158,14 +163,14 @@ export default class LoaderShim {
|
|
|
158
163
|
loader.define(...this.defineCache[specifier]);
|
|
159
164
|
}
|
|
160
165
|
});
|
|
161
|
-
// by default, app initialization is gated on waiting for
|
|
166
|
+
// by default, app initialization is gated on waiting for body to be available
|
|
162
167
|
const { disableInitDefer } = this.config;
|
|
163
168
|
// Load the import mappings and application bootstrap module
|
|
164
169
|
loader
|
|
165
170
|
.registerImportMappings(importMappings)
|
|
166
171
|
.then(() => {
|
|
167
172
|
if (!disableInitDefer) {
|
|
168
|
-
return this.
|
|
173
|
+
return this.waitForBody();
|
|
169
174
|
}
|
|
170
175
|
})
|
|
171
176
|
.then(() => loader.load(bootstrapModule))
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.17.2-alpha.
|
|
8
|
+
"version": "0.17.2-alpha.14",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@locker/trusted-types": "0.23.6",
|
|
64
|
-
"@lwrjs/diagnostics": "0.17.2-alpha.
|
|
65
|
-
"@lwrjs/types": "0.17.2-alpha.
|
|
64
|
+
"@lwrjs/diagnostics": "0.17.2-alpha.14",
|
|
65
|
+
"@lwrjs/types": "0.17.2-alpha.14",
|
|
66
66
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
67
67
|
"@rollup/plugin-sucrase": "^5.0.2",
|
|
68
68
|
"@rollup/plugin-terser": "^0.4.4",
|
|
69
69
|
"rollup": "^2.79.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@lwrjs/client-modules": "0.17.2-alpha.
|
|
73
|
-
"@lwrjs/shared-utils": "0.17.2-alpha.
|
|
72
|
+
"@lwrjs/client-modules": "0.17.2-alpha.14",
|
|
73
|
+
"@lwrjs/shared-utils": "0.17.2-alpha.14"
|
|
74
74
|
},
|
|
75
75
|
"lwc": {
|
|
76
76
|
"modules": [
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
]
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
|
-
"node": ">=
|
|
88
|
+
"node": ">=20.0.0"
|
|
89
89
|
},
|
|
90
90
|
"volta": {
|
|
91
91
|
"extends": "../../../package.json"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "a7d6d67f5453787a8b2428bd11546c334af3f77b"
|
|
94
94
|
}
|