@lwrjs/loader 0.9.0-alpha.8 → 0.9.0
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/README.md +3 -3
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +31 -33
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim-legacy.js +21 -20
- package/build/assets/prod/lwr-loader-shim.bundle.js +32 -33
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim.js +21 -20
- package/build/bundle/prod/lwr/esmLoader/esmLoader.js +1 -1
- package/build/cjs/index.cjs +1 -1
- package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +23 -19
- package/build/cjs/modules/lwr/loader/errors/messages.cjs +1 -1
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +3 -7
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +3 -7
- package/build/index.js +1 -1
- package/build/modules/lwr/esmLoader/esmLoader.js +28 -24
- package/build/modules/lwr/loader/__tests__/utils/amd.js +2 -3
- package/build/modules/lwr/loader/loader.js +11 -13
- package/build/modules/lwr/loaderLegacy/__tests__/utils/amd.js +4 -5
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +10 -13
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -330,8 +330,8 @@ globalThis.LWR: {
|
|
|
330
330
|
'c/example/v/1',
|
|
331
331
|
// ...
|
|
332
332
|
]
|
|
333
|
-
// (optional) versioned root application component
|
|
334
|
-
|
|
333
|
+
// (optional) versioned root application component names
|
|
334
|
+
rootComponents: ['c/example/v/1', 'c/nav/v/1']
|
|
335
335
|
}
|
|
336
336
|
```
|
|
337
337
|
|
|
@@ -368,7 +368,7 @@ type CustomInitAPI = {
|
|
|
368
368
|
type ClientBootstrapConfig = {
|
|
369
369
|
autoBoot: boolean;
|
|
370
370
|
bootstrapModule: string;
|
|
371
|
-
|
|
371
|
+
rootComponents?: string[];
|
|
372
372
|
requiredModules: string[];
|
|
373
373
|
preloadModules?: string[];
|
|
374
374
|
customInit?: CustomInitFunction;
|
|
@@ -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.9.0
|
|
7
|
+
/* LWR Error Shim v0.9.0 */
|
|
8
8
|
!function(){"use strict";if(!(globalThis.LWR&&globalThis.LWR.define)){const o=new Error("The LWR application failed to bootstrap");if(!globalThis.LWR||!globalThis.LWR.onError)throw o;globalThis.LWR.onError(o)}}();
|
|
@@ -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.9.0
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.9.0 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -13,23 +13,23 @@
|
|
|
13
13
|
const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
|
|
14
14
|
|
|
15
15
|
var Phase;
|
|
16
|
-
|
|
17
16
|
(function (Phase) {
|
|
18
17
|
Phase[Phase["Start"] = 0] = "Start";
|
|
19
18
|
Phase[Phase["End"] = 1] = "End";
|
|
20
19
|
})(Phase || (Phase = {}));
|
|
21
|
-
|
|
22
20
|
// Attach a custom dispatcher
|
|
23
21
|
let customDispatcher;
|
|
24
22
|
function attachDispatcher(dispatcher) {
|
|
25
23
|
customDispatcher = dispatcher;
|
|
26
|
-
}
|
|
27
|
-
// e.g. JSDom (used in Jest) doesn't implement these
|
|
24
|
+
}
|
|
28
25
|
|
|
26
|
+
// Check if the Performance API is available
|
|
27
|
+
// e.g. JSDom (used in Jest) doesn't implement these
|
|
29
28
|
const perf = globalThis.performance;
|
|
30
|
-
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
31
|
-
// Fallback to the Performance API if there is no custom dispatcher
|
|
29
|
+
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
32
30
|
|
|
31
|
+
// For marking request metrics
|
|
32
|
+
// Fallback to the Performance API if there is no custom dispatcher
|
|
33
33
|
function logOperationStart({
|
|
34
34
|
id,
|
|
35
35
|
specifier
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
} else if (isPerfSupported) {
|
|
44
44
|
perf.mark(id + (specifier ? `.${specifier}` : ''));
|
|
45
45
|
}
|
|
46
|
-
}
|
|
47
|
-
// Fallback to the Performance API if there is no custom dispatcher
|
|
46
|
+
}
|
|
48
47
|
|
|
48
|
+
// For measuring duration metrics
|
|
49
|
+
// Fallback to the Performance API if there is no custom dispatcher
|
|
49
50
|
/* istanbul ignore next */
|
|
50
|
-
|
|
51
51
|
function logOperationEnd({
|
|
52
52
|
id,
|
|
53
53
|
specifier
|
|
@@ -62,9 +62,10 @@
|
|
|
62
62
|
const suffix = specifier ? `.${specifier}` : '';
|
|
63
63
|
const markName = id + suffix;
|
|
64
64
|
const measureName = `${id}.duration${suffix}`;
|
|
65
|
-
perf.measure(measureName, markName);
|
|
66
|
-
// Even if they get deleted, existing PerformanceObservers preserve copies of the entries
|
|
65
|
+
perf.measure(measureName, markName);
|
|
67
66
|
|
|
67
|
+
// Clear the created mark and measure to avoid filling the performance entry buffer
|
|
68
|
+
// Even if they get deleted, existing PerformanceObservers preserve copies of the entries
|
|
68
69
|
perf.clearMarks(markName);
|
|
69
70
|
perf.clearMeasures(measureName);
|
|
70
71
|
}
|
|
@@ -142,7 +143,7 @@
|
|
|
142
143
|
// Parse configuration
|
|
143
144
|
this.global = global;
|
|
144
145
|
this.config = global.LWR;
|
|
145
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_9_0
|
|
146
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_9_0';
|
|
146
147
|
// Set up error handler
|
|
147
148
|
this.errorHandler = this.config.onError;
|
|
148
149
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -150,6 +151,7 @@
|
|
|
150
151
|
global.LWR.define = tempDefine;
|
|
151
152
|
this.bootReady = this.config.autoBoot;
|
|
152
153
|
try {
|
|
154
|
+
this.createProfilerModule(this.config);
|
|
153
155
|
customInit(Object.freeze(this.config), this.postCustomInit.bind(this), tempDefine, (e) => {
|
|
154
156
|
// customInit handlers can overwrite
|
|
155
157
|
// the error handler with onBootstrapError
|
|
@@ -204,7 +206,7 @@
|
|
|
204
206
|
const loaderConfig = {
|
|
205
207
|
baseUrl: this.config.baseUrl,
|
|
206
208
|
profiler: { logOperationStart, logOperationEnd },
|
|
207
|
-
// TODO: can be removed following https://github.com/salesforce/lwr/issues/1087
|
|
209
|
+
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
208
210
|
appMetadata: {
|
|
209
211
|
appId: this.config.appId,
|
|
210
212
|
bootstrapModule: this.config.bootstrapModule,
|
|
@@ -213,7 +215,6 @@
|
|
|
213
215
|
},
|
|
214
216
|
};
|
|
215
217
|
const loader = createLoader(this.loaderModule, this.defineCache[this.loaderModule], loaderConfig, this.config.preloadModules);
|
|
216
|
-
this.createProfilerModule(loader);
|
|
217
218
|
this.mountApp(loader);
|
|
218
219
|
}
|
|
219
220
|
catch (e) {
|
|
@@ -239,11 +240,11 @@
|
|
|
239
240
|
}
|
|
240
241
|
// Create a module out of the profiler
|
|
241
242
|
// Note: The profiler is also available as a module through lwc module resolution (see package.json)
|
|
242
|
-
createProfilerModule(
|
|
243
|
+
createProfilerModule(globalLWR) {
|
|
243
244
|
const exporter = (exports) => {
|
|
244
245
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
245
246
|
};
|
|
246
|
-
|
|
247
|
+
globalLWR.define('lwr/profiler/v/0_9_0', ['exports'], exporter, {});
|
|
247
248
|
}
|
|
248
249
|
// Set up the application globals, import map, root custom element...
|
|
249
250
|
mountApp(loader) {
|
|
@@ -275,7 +276,7 @@
|
|
|
275
276
|
})
|
|
276
277
|
.then(() => loader.load(bootstrapModule))
|
|
277
278
|
.catch((reason) => {
|
|
278
|
-
this.enterErrorState(new Error(`Application ${rootComponent} could not be loaded: ${reason}`));
|
|
279
|
+
this.enterErrorState(new Error(`Application ${rootComponent || bootstrapModule} could not be loaded: ${reason}`));
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
// Trigger bootstrap error state, and call error handler if registered
|
|
@@ -303,14 +304,14 @@
|
|
|
303
304
|
// The loader module is ALWAYS required
|
|
304
305
|
const GLOBAL = globalThis;
|
|
305
306
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_9_0
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_9_0
|
|
307
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_9_0') < 0) {
|
|
308
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_9_0');
|
|
308
309
|
}
|
|
309
310
|
new LoaderShim(GLOBAL);
|
|
310
311
|
|
|
311
312
|
}());
|
|
312
313
|
|
|
313
|
-
LWR.define('lwr/loaderLegacy/v/0_9_0
|
|
314
|
+
LWR.define('lwr/loaderLegacy/v/0_9_0', ['exports'], function (exports) { 'use strict';
|
|
314
315
|
|
|
315
316
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
316
317
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -709,6 +710,7 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
709
710
|
|
|
710
711
|
// Bootstrap / shim
|
|
711
712
|
|
|
713
|
+
// Loader: modules
|
|
712
714
|
const LOADER_PREFIX = 'lwr.loader.';
|
|
713
715
|
const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
|
|
714
716
|
const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
|
|
@@ -855,12 +857,8 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
855
857
|
* @param modules - list of module identifiers
|
|
856
858
|
*/
|
|
857
859
|
registerExternalModules(modules) {
|
|
858
|
-
const alreadyRegistered = [];
|
|
859
860
|
modules.map((id) => {
|
|
860
|
-
if (this.namedDefineRegistry.has(id)) {
|
|
861
|
-
alreadyRegistered.push(id);
|
|
862
|
-
}
|
|
863
|
-
else {
|
|
861
|
+
if (!this.namedDefineRegistry.has(id)) {
|
|
864
862
|
let resolveExternal;
|
|
865
863
|
let timer;
|
|
866
864
|
const moduleDefPromise = new Promise((resolve, reject) => {
|
|
@@ -884,11 +882,11 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
884
882
|
};
|
|
885
883
|
this.namedDefineRegistry.set(id, moduleDef);
|
|
886
884
|
}
|
|
885
|
+
else if (process.env.NODE_ENV !== 'production' && hasConsole) {
|
|
886
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
887
|
+
console.warn(MODULE_ALREADY_LOADED.message, id);
|
|
888
|
+
}
|
|
887
889
|
});
|
|
888
|
-
// throw error for modules that were already registered
|
|
889
|
-
if (alreadyRegistered.length) {
|
|
890
|
-
throw new LoaderError(MODULE_ALREADY_LOADED, [alreadyRegistered.join(', ')]);
|
|
891
|
-
}
|
|
892
890
|
}
|
|
893
891
|
checkModuleSignature(name, signature) {
|
|
894
892
|
const moduleDef = this.namedDefineRegistry.get(name);
|
|
@@ -1062,7 +1060,7 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
1062
1060
|
moduleDefault = { default: moduleDefault };
|
|
1063
1061
|
// __defaultInterop is ONLY used to support backwards compatibility
|
|
1064
1062
|
// of importing default exports the "wrong" way (when not using named exports).
|
|
1065
|
-
// See https://github.com/salesforce/lwr/pull/816
|
|
1063
|
+
// See https://github.com/salesforce-experience-platform-emu/lwr/pull/816
|
|
1066
1064
|
Object.defineProperty(moduleDefault, '__defaultInterop', { value: true });
|
|
1067
1065
|
}
|
|
1068
1066
|
// if no return value, then we are using the exports object
|
|
@@ -1274,7 +1272,7 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
1274
1272
|
// When a specifier's URI cannot be resolved via the imports, fallback to "default".
|
|
1275
1273
|
// -> https://rfcs.lwc.dev/rfcs/lwr/0000-import-metadata#json-schema
|
|
1276
1274
|
// However, if `id` is already a fully resolved url,
|
|
1277
|
-
// we cannot prepend the defaultUri -> https://github.com/salesforce/lwr/issues/378.
|
|
1275
|
+
// we cannot prepend the defaultUri -> https://github.com/salesforce-experience-platform-emu/lwr/issues/378.
|
|
1278
1276
|
// In this case we do not apply any package mappings and allow the caller (resolveImportMapEntry) to handle it.
|
|
1279
1277
|
if (!isUrl(id)) {
|
|
1280
1278
|
return defaultUri + encodeURIComponent(id);
|
|
@@ -1441,7 +1439,7 @@ LWR.define('lwr/loaderLegacy/v/0_9_0-alpha_8', ['exports'], function (exports) {
|
|
|
1441
1439
|
};
|
|
1442
1440
|
}
|
|
1443
1441
|
this.registry = new ModuleRegistry({ baseUrl, profiler });
|
|
1444
|
-
// TODO: https://github.com/salesforce/lwr/issues/1087
|
|
1442
|
+
// TODO: https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
1445
1443
|
this.services = Object.freeze({
|
|
1446
1444
|
addLoaderPlugin: this.registry.addLoaderPlugin.bind(this.registry),
|
|
1447
1445
|
handleStaleModule: this.registry.registerHandleStaleModuleHook.bind(this.registry),
|
|
@@ -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 Legacy Module Loader Shim v0.9.0
|
|
8
|
-
!function(){"use strict";var e;let t;function r(e){t=e}!function(e){e[e.Start=0]="Start",e[e.End=1]="End"}(e||(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({id:r,specifier:n}){t?t({id:r,phase:e.Start,specifier:n}):s&&o.mark(r+(n?`.${n}`:""))}function i({id:r,specifier:n}){if(t)t({id:r,phase:e.End,specifier:n});else if(s){const e=n?`.${n}`:"",t=r+e,s=`${r}.duration${e}`;o.measure(s,t),o.clearMarks(t),o.clearMeasures(s)}}function a(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 l="function"==typeof setTimeout,d="undefined"!=typeof console;const c=globalThis;c.LWR.requiredModules=c.LWR.requiredModules||[],c.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_9_0-alpha_8")<0&&c.LWR.requiredModules.push("lwr/loaderLegacy/v/0_9_0-alpha_8"),new class{constructor(e){this.defineCache={},this.orderedDefs=[],l&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_9_0-alpha_8",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{a(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){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()&&(l&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:n,logOperationEnd:i},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,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})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.createProfilerModule(t),this.mountApp(t)}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.define("lwr/profiler/v/0_9_0-alpha_8",["exports"],(e=>{Object.assign(e,{logOperationStart:n,logOperationEnd:i})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,ssrProps:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,ssrProps:n,importMappings:o,endpoints:i}),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.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r} could not be loaded: ${e}`))}))}enterErrorState(e){n({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):d&&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"))}),3e5)}}(c)}(),LWR.define("lwr/loaderLegacy/v/0_9_0-alpha_8",["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"}),MODULE_ALREADY_LOADED=Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"}),FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),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;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=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.aliases=new Map,this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){if(o=this.resolver.resolve(t,r),this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){const t=[];if(e.map((e=>{if(this.namedDefineRegistry.has(e))t.push(e);else{let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}})),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=e.dependencies.map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),n}storeModuleAlias(e,t){if(e!==t)if(this.aliases.has(e)){if(hasConsole){const r=this.aliases.get(e);r!==t&&console.warn(`Alias update attempt: ${e}=>${r}, ${t}`)}}else this.aliases.set(e,t)}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])})));if(e.evaluated)return e.module;let a=o(...i);void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){return e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length?r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e):r+e.slice(o.length)}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e))return r+encodeURIComponent(e)}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&t||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.9.0 */
|
|
8
|
+
!function(){"use strict";var e;let t;function r(e){t=e}!function(e){e[e.Start=0]="Start",e[e.End=1]="End"}(e||(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({id:r,specifier:n}){t?t({id:r,phase:e.Start,specifier:n}):s&&o.mark(r+(n?`.${n}`:""))}function i({id:r,specifier:n}){if(t)t({id:r,phase:e.End,specifier:n});else if(s){const e=n?`.${n}`:"",t=r+e,s=`${r}.duration${e}`;o.measure(s,t),o.clearMarks(t),o.clearMeasures(s)}}function a(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 l="function"==typeof setTimeout,d="undefined"!=typeof console;const c=globalThis;c.LWR.requiredModules=c.LWR.requiredModules||[],c.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_9_0")<0&&c.LWR.requiredModules.push("lwr/loaderLegacy/v/0_9_0"),new class{constructor(e){this.defineCache={},this.orderedDefs=[],l&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_9_0",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(this.config),a(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){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()&&(l&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:n,logOperationEnd:i},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,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})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}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.define("lwr/profiler/v/0_9_0",["exports"],(e=>{Object.assign(e,{logOperationStart:n,logOperationEnd:i})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,ssrProps:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,ssrProps:n,importMappings:o,endpoints:i}),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.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){n({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):d&&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"))}),3e5)}}(c)}(),LWR.define("lwr/loaderLegacy/v/0_9_0",["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'}),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;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=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.aliases=new Map,this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){if(o=this.resolver.resolve(t,r),this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=e.dependencies.map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),n}storeModuleAlias(e,t){if(e!==t)if(this.aliases.has(e)){if(hasConsole){const r=this.aliases.get(e);r!==t&&console.warn(`Alias update attempt: ${e}=>${r}, ${t}`)}}else this.aliases.set(e,t)}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])})));if(e.evaluated)return e.module;let a=o(...i);void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){return e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length?r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e):r+e.slice(o.length)}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e))return r+encodeURIComponent(e)}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&t||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
@@ -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.9.0
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.9.0 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -13,23 +13,23 @@
|
|
|
13
13
|
const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
|
|
14
14
|
|
|
15
15
|
var Phase;
|
|
16
|
-
|
|
17
16
|
(function (Phase) {
|
|
18
17
|
Phase[Phase["Start"] = 0] = "Start";
|
|
19
18
|
Phase[Phase["End"] = 1] = "End";
|
|
20
19
|
})(Phase || (Phase = {}));
|
|
21
|
-
|
|
22
20
|
// Attach a custom dispatcher
|
|
23
21
|
let customDispatcher;
|
|
24
22
|
function attachDispatcher(dispatcher) {
|
|
25
23
|
customDispatcher = dispatcher;
|
|
26
|
-
}
|
|
27
|
-
// e.g. JSDom (used in Jest) doesn't implement these
|
|
24
|
+
}
|
|
28
25
|
|
|
26
|
+
// Check if the Performance API is available
|
|
27
|
+
// e.g. JSDom (used in Jest) doesn't implement these
|
|
29
28
|
const perf = globalThis.performance;
|
|
30
|
-
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
31
|
-
// Fallback to the Performance API if there is no custom dispatcher
|
|
29
|
+
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
32
30
|
|
|
31
|
+
// For marking request metrics
|
|
32
|
+
// Fallback to the Performance API if there is no custom dispatcher
|
|
33
33
|
function logOperationStart({
|
|
34
34
|
id,
|
|
35
35
|
specifier
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
} else if (isPerfSupported) {
|
|
44
44
|
perf.mark(id + (specifier ? `.${specifier}` : ''));
|
|
45
45
|
}
|
|
46
|
-
}
|
|
47
|
-
// Fallback to the Performance API if there is no custom dispatcher
|
|
46
|
+
}
|
|
48
47
|
|
|
48
|
+
// For measuring duration metrics
|
|
49
|
+
// Fallback to the Performance API if there is no custom dispatcher
|
|
49
50
|
/* istanbul ignore next */
|
|
50
|
-
|
|
51
51
|
function logOperationEnd({
|
|
52
52
|
id,
|
|
53
53
|
specifier
|
|
@@ -62,9 +62,10 @@
|
|
|
62
62
|
const suffix = specifier ? `.${specifier}` : '';
|
|
63
63
|
const markName = id + suffix;
|
|
64
64
|
const measureName = `${id}.duration${suffix}`;
|
|
65
|
-
perf.measure(measureName, markName);
|
|
66
|
-
// Even if they get deleted, existing PerformanceObservers preserve copies of the entries
|
|
65
|
+
perf.measure(measureName, markName);
|
|
67
66
|
|
|
67
|
+
// Clear the created mark and measure to avoid filling the performance entry buffer
|
|
68
|
+
// Even if they get deleted, existing PerformanceObservers preserve copies of the entries
|
|
68
69
|
perf.clearMarks(markName);
|
|
69
70
|
perf.clearMeasures(measureName);
|
|
70
71
|
}
|
|
@@ -142,7 +143,7 @@
|
|
|
142
143
|
// Parse configuration
|
|
143
144
|
this.global = global;
|
|
144
145
|
this.config = global.LWR;
|
|
145
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_9_0
|
|
146
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_9_0';
|
|
146
147
|
// Set up error handler
|
|
147
148
|
this.errorHandler = this.config.onError;
|
|
148
149
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -150,6 +151,7 @@
|
|
|
150
151
|
global.LWR.define = tempDefine;
|
|
151
152
|
this.bootReady = this.config.autoBoot;
|
|
152
153
|
try {
|
|
154
|
+
this.createProfilerModule(this.config);
|
|
153
155
|
customInit(Object.freeze(this.config), this.postCustomInit.bind(this), tempDefine, (e) => {
|
|
154
156
|
// customInit handlers can overwrite
|
|
155
157
|
// the error handler with onBootstrapError
|
|
@@ -204,7 +206,7 @@
|
|
|
204
206
|
const loaderConfig = {
|
|
205
207
|
baseUrl: this.config.baseUrl,
|
|
206
208
|
profiler: { logOperationStart, logOperationEnd },
|
|
207
|
-
// TODO: can be removed following https://github.com/salesforce/lwr/issues/1087
|
|
209
|
+
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
208
210
|
appMetadata: {
|
|
209
211
|
appId: this.config.appId,
|
|
210
212
|
bootstrapModule: this.config.bootstrapModule,
|
|
@@ -213,7 +215,6 @@
|
|
|
213
215
|
},
|
|
214
216
|
};
|
|
215
217
|
const loader = createLoader(this.loaderModule, this.defineCache[this.loaderModule], loaderConfig, this.config.preloadModules);
|
|
216
|
-
this.createProfilerModule(loader);
|
|
217
218
|
this.mountApp(loader);
|
|
218
219
|
}
|
|
219
220
|
catch (e) {
|
|
@@ -239,11 +240,11 @@
|
|
|
239
240
|
}
|
|
240
241
|
// Create a module out of the profiler
|
|
241
242
|
// Note: The profiler is also available as a module through lwc module resolution (see package.json)
|
|
242
|
-
createProfilerModule(
|
|
243
|
+
createProfilerModule(globalLWR) {
|
|
243
244
|
const exporter = (exports) => {
|
|
244
245
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
245
246
|
};
|
|
246
|
-
|
|
247
|
+
globalLWR.define('lwr/profiler/v/0_9_0', ['exports'], exporter, {});
|
|
247
248
|
}
|
|
248
249
|
// Set up the application globals, import map, root custom element...
|
|
249
250
|
mountApp(loader) {
|
|
@@ -275,7 +276,7 @@
|
|
|
275
276
|
})
|
|
276
277
|
.then(() => loader.load(bootstrapModule))
|
|
277
278
|
.catch((reason) => {
|
|
278
|
-
this.enterErrorState(new Error(`Application ${rootComponent} could not be loaded: ${reason}`));
|
|
279
|
+
this.enterErrorState(new Error(`Application ${rootComponent || bootstrapModule} could not be loaded: ${reason}`));
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
// Trigger bootstrap error state, and call error handler if registered
|
|
@@ -303,8 +304,8 @@
|
|
|
303
304
|
// The loader module is ALWAYS required
|
|
304
305
|
const GLOBAL = globalThis;
|
|
305
306
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_9_0
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_9_0
|
|
307
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_9_0') < 0) {
|
|
308
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_9_0');
|
|
308
309
|
}
|
|
309
310
|
new LoaderShim(GLOBAL);
|
|
310
311
|
|