@lwrjs/loader 0.8.0-alpha.9 → 0.8.1
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 +54 -19
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim-legacy.js +5 -5
- package/build/assets/prod/lwr-loader-shim.bundle.js +51 -24
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim.js +5 -5
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +35 -15
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +38 -11
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +46 -19
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +49 -14
- package/package.json +6 -6
|
@@ -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.8.
|
|
7
|
+
/* LWR Error Shim v0.8.1 */
|
|
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.8.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.8.1 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
// Parse configuration
|
|
143
143
|
this.global = global;
|
|
144
144
|
this.config = global.LWR;
|
|
145
|
-
this.loaderModule = 'lwr/loaderLegacy/v/
|
|
145
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_8_1';
|
|
146
146
|
// Set up error handler
|
|
147
147
|
this.errorHandler = this.config.onError;
|
|
148
148
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
const exporter = (exports) => {
|
|
244
244
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
245
245
|
};
|
|
246
|
-
loader.define('lwr/profiler/v/
|
|
246
|
+
loader.define('lwr/profiler/v/0_8_1', ['exports'], exporter, {});
|
|
247
247
|
}
|
|
248
248
|
// Set up the application globals, import map, root custom element...
|
|
249
249
|
mountApp(loader) {
|
|
@@ -303,14 +303,14 @@
|
|
|
303
303
|
// The loader module is ALWAYS required
|
|
304
304
|
const GLOBAL = globalThis;
|
|
305
305
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
306
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_8_1') < 0) {
|
|
307
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_8_1');
|
|
308
308
|
}
|
|
309
309
|
new LoaderShim(GLOBAL);
|
|
310
310
|
|
|
311
311
|
}());
|
|
312
312
|
|
|
313
|
-
LWR.define('lwr/loaderLegacy/v/
|
|
313
|
+
LWR.define('lwr/loaderLegacy/v/0_8_1', ['exports'], function (exports) { 'use strict';
|
|
314
314
|
|
|
315
315
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
316
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -716,9 +716,11 @@ LWR.define('lwr/loaderLegacy/v/0_8_0-alpha_9', ['exports'], function (exports) {
|
|
|
716
716
|
constructor(config) {
|
|
717
717
|
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
718
718
|
this.namedDefineRegistry = new Map();
|
|
719
|
-
// The
|
|
719
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
720
720
|
this.moduleRegistry = new Map();
|
|
721
|
-
|
|
721
|
+
// Aliases of modules in the registry
|
|
722
|
+
this.aliases = new Map();
|
|
723
|
+
this.baseUrl = config.baseUrl || '';
|
|
722
724
|
this.profiler = config.profiler;
|
|
723
725
|
}
|
|
724
726
|
async load(id, importer) {
|
|
@@ -789,7 +791,7 @@ LWR.define('lwr/loaderLegacy/v/0_8_0-alpha_9', ['exports'], function (exports) {
|
|
|
789
791
|
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
790
792
|
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
791
793
|
const record = this.moduleRegistry.get(resolved);
|
|
792
|
-
if (!record || !
|
|
794
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
793
795
|
return resolvedOrPlain;
|
|
794
796
|
}
|
|
795
797
|
}
|
|
@@ -920,15 +922,33 @@ LWR.define('lwr/loaderLegacy/v/0_8_0-alpha_9', ['exports'], function (exports) {
|
|
|
920
922
|
setImportResolver(resolver) {
|
|
921
923
|
this.resolver = resolver;
|
|
922
924
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
+
// Returns an existing module record by the resolvedId or aliased id
|
|
926
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
927
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
925
928
|
if (moduleRecord) {
|
|
926
|
-
|
|
927
|
-
if (!moduleRecord.aliases.has(id)) {
|
|
928
|
-
moduleRecord.aliases.add(id);
|
|
929
|
-
}
|
|
929
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
930
930
|
return moduleRecord;
|
|
931
931
|
}
|
|
932
|
+
// Check if this is a known alias
|
|
933
|
+
if (resolvedId !== aliasId) {
|
|
934
|
+
const alias = this.aliases.get(aliasId);
|
|
935
|
+
if (alias) {
|
|
936
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
937
|
+
if (aliasedModule) {
|
|
938
|
+
return aliasedModule;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return moduleRecord;
|
|
943
|
+
}
|
|
944
|
+
getModuleRecord(resolvedId, id) {
|
|
945
|
+
// Look for an existing record
|
|
946
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
947
|
+
if (existingRecord) {
|
|
948
|
+
// return existing
|
|
949
|
+
return existingRecord;
|
|
950
|
+
}
|
|
951
|
+
// Create a new Module Record
|
|
932
952
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
933
953
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
934
954
|
const dependencies = moduleDef.dependencies;
|
|
@@ -944,17 +964,32 @@ LWR.define('lwr/loaderLegacy/v/0_8_0-alpha_9', ['exports'], function (exports) {
|
|
|
944
964
|
.filter((depRecord) => depRecord !== undefined);
|
|
945
965
|
return Promise.all(filtered);
|
|
946
966
|
});
|
|
947
|
-
|
|
967
|
+
const newModuleRecord = {
|
|
948
968
|
id: resolvedId,
|
|
949
|
-
aliases: new Set([id]),
|
|
950
969
|
module: Object.create(null),
|
|
951
970
|
dependencyRecords,
|
|
952
971
|
instantiation,
|
|
953
972
|
evaluated: false,
|
|
954
973
|
evaluationPromise: null,
|
|
955
974
|
};
|
|
956
|
-
this.moduleRegistry.set(resolvedId,
|
|
957
|
-
|
|
975
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
976
|
+
this.storeModuleAlias(id, resolvedId);
|
|
977
|
+
return newModuleRecord;
|
|
978
|
+
}
|
|
979
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
980
|
+
if (aliasId !== resolvedId) {
|
|
981
|
+
if (!this.aliases.has(aliasId)) {
|
|
982
|
+
this.aliases.set(aliasId, resolvedId);
|
|
983
|
+
}
|
|
984
|
+
else if (hasConsole) {
|
|
985
|
+
// Warn the user if they were not aliasing to the resolvedId
|
|
986
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
987
|
+
if (currentResolvedId !== resolvedId) {
|
|
988
|
+
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
989
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
958
993
|
}
|
|
959
994
|
async getModuleDependencyRecord(dependency) {
|
|
960
995
|
const resolvedDepId = await this.resolve(dependency);
|
|
@@ -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.8.
|
|
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_8_0-alpha_9")<0&&c.LWR.requiredModules.push("lwr/loaderLegacy/v/0_8_0-alpha_9"),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_8_0-alpha_9",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_8_0-alpha_9",["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_8_0-alpha_9",["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})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");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.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){const e=this.moduleRegistry.get(o);if(!e||!e.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}):hasConsole&&console.warn(`stale module detected ${e}, current sig:${o}, new sig:${t}`)}}setImportResolver(e){this.resolver=e}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r.aliases.has(t)||r.aliases.add(t),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)}));return r={id:e,aliases:new Set([t]),module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}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.8.1 */
|
|
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_8_1")<0&&c.LWR.requiredModules.push("lwr/loaderLegacy/v/0_8_1"),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_8_1",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_8_1",["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_8_1",["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})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");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}):hasConsole&&console.warn(`stale module detected ${e}, current sig:${o}, new sig:${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.8.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.8.1 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
// Parse configuration
|
|
143
143
|
this.global = global;
|
|
144
144
|
this.config = global.LWR;
|
|
145
|
-
this.loaderModule = 'lwr/loaderLegacy/v/
|
|
145
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_8_1';
|
|
146
146
|
// Set up error handler
|
|
147
147
|
this.errorHandler = this.config.onError;
|
|
148
148
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
const exporter = (exports) => {
|
|
244
244
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
245
245
|
};
|
|
246
|
-
loader.define('lwr/profiler/v/
|
|
246
|
+
loader.define('lwr/profiler/v/0_8_1', ['exports'], exporter, {});
|
|
247
247
|
}
|
|
248
248
|
// Set up the application globals, import map, root custom element...
|
|
249
249
|
mountApp(loader) {
|
|
@@ -303,8 +303,8 @@
|
|
|
303
303
|
// The loader module is ALWAYS required
|
|
304
304
|
const GLOBAL = globalThis;
|
|
305
305
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
306
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_8_1') < 0) {
|
|
307
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_8_1');
|
|
308
308
|
}
|
|
309
309
|
new LoaderShim(GLOBAL);
|
|
310
310
|
|
|
@@ -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.8.
|
|
7
|
+
/* LWR Module Loader Shim v0.8.1 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
// Parse configuration
|
|
141
141
|
this.global = global;
|
|
142
142
|
this.config = global.LWR;
|
|
143
|
-
this.loaderSpecifier = 'lwr/loader/v/
|
|
143
|
+
this.loaderSpecifier = 'lwr/loader/v/0_8_1';
|
|
144
144
|
// Set up error handler
|
|
145
145
|
this.errorHandler = this.config.onError;
|
|
146
146
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
const exporter = (exports) => {
|
|
243
243
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
244
244
|
};
|
|
245
|
-
loader.define('lwr/profiler/v/
|
|
245
|
+
loader.define('lwr/profiler/v/0_8_1', ['exports'], exporter);
|
|
246
246
|
}
|
|
247
247
|
// Set up the application globals, import map, root custom element...
|
|
248
248
|
mountApp(loader) {
|
|
@@ -303,14 +303,14 @@
|
|
|
303
303
|
// The loader module is ALWAYS required
|
|
304
304
|
const GLOBAL = globalThis;
|
|
305
305
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
306
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_8_1') < 0) {
|
|
307
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_8_1');
|
|
308
308
|
}
|
|
309
309
|
new LoaderShim(GLOBAL);
|
|
310
310
|
|
|
311
311
|
}());
|
|
312
312
|
|
|
313
|
-
LWR.define('lwr/loader/v/
|
|
313
|
+
LWR.define('lwr/loader/v/0_8_1', ['exports'], function (exports) { 'use strict';
|
|
314
314
|
|
|
315
315
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
316
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -934,8 +934,10 @@ LWR.define('lwr/loader/v/0_8_0-alpha_9', ['exports'], function (exports) { 'use
|
|
|
934
934
|
constructor(config) {
|
|
935
935
|
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
936
936
|
this.namedDefineRegistry = new Map();
|
|
937
|
-
// The
|
|
937
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
938
938
|
this.moduleRegistry = new Map();
|
|
939
|
+
// Aliases of modules in the registry
|
|
940
|
+
this.aliases = new Map();
|
|
939
941
|
this.profiler = config.profiler;
|
|
940
942
|
this.resolver = new ImportMetadataResolver(config, this.importMetadataInvalidationCallback.bind(this));
|
|
941
943
|
}
|
|
@@ -1007,7 +1009,7 @@ LWR.define('lwr/loader/v/0_8_0-alpha_9', ['exports'], function (exports) { 'use
|
|
|
1007
1009
|
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
1008
1010
|
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
1009
1011
|
const record = this.moduleRegistry.get(resolvedUrl);
|
|
1010
|
-
if (!record || !
|
|
1012
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
1011
1013
|
return resolvedOrPlain;
|
|
1012
1014
|
}
|
|
1013
1015
|
}
|
|
@@ -1106,23 +1108,33 @@ LWR.define('lwr/loader/v/0_8_0-alpha_9', ['exports'], function (exports) { 'use
|
|
|
1106
1108
|
getImportMetadataResolver() {
|
|
1107
1109
|
return this.resolver;
|
|
1108
1110
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
+
// Returns an existing module record by the resolvedId or aliased id
|
|
1112
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
1113
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
1111
1114
|
if (moduleRecord) {
|
|
1112
|
-
|
|
1113
|
-
if (!moduleRecord.aliases.has(id)) {
|
|
1114
|
-
moduleRecord.aliases.add(id);
|
|
1115
|
-
}
|
|
1115
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
1116
1116
|
return moduleRecord;
|
|
1117
1117
|
}
|
|
1118
|
-
//
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1118
|
+
// Check if this is a known alias
|
|
1119
|
+
if (resolvedId !== aliasId) {
|
|
1120
|
+
const alias = this.aliases.get(aliasId);
|
|
1121
|
+
if (alias) {
|
|
1122
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
1123
|
+
if (aliasedModule) {
|
|
1124
|
+
return aliasedModule;
|
|
1125
|
+
}
|
|
1124
1126
|
}
|
|
1125
1127
|
}
|
|
1128
|
+
return moduleRecord;
|
|
1129
|
+
}
|
|
1130
|
+
getModuleRecord(resolvedId, id) {
|
|
1131
|
+
// Look for an existing record
|
|
1132
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
1133
|
+
if (existingRecord) {
|
|
1134
|
+
// return existing
|
|
1135
|
+
return existingRecord;
|
|
1136
|
+
}
|
|
1137
|
+
// Create a new Module Record
|
|
1126
1138
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
1127
1139
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
1128
1140
|
const dependencies = moduleDef.dependencies;
|
|
@@ -1138,17 +1150,32 @@ LWR.define('lwr/loader/v/0_8_0-alpha_9', ['exports'], function (exports) { 'use
|
|
|
1138
1150
|
.filter((depRecord) => depRecord !== undefined);
|
|
1139
1151
|
return Promise.all(filtered);
|
|
1140
1152
|
});
|
|
1141
|
-
|
|
1153
|
+
const newModuleRecord = {
|
|
1142
1154
|
id: resolvedId,
|
|
1143
|
-
aliases: new Set([id]),
|
|
1144
1155
|
module: Object.create(null),
|
|
1145
1156
|
dependencyRecords,
|
|
1146
1157
|
instantiation,
|
|
1147
1158
|
evaluated: false,
|
|
1148
1159
|
evaluationPromise: null,
|
|
1149
1160
|
};
|
|
1150
|
-
this.moduleRegistry.set(resolvedId,
|
|
1151
|
-
|
|
1161
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
1162
|
+
this.storeModuleAlias(id, resolvedId);
|
|
1163
|
+
return newModuleRecord;
|
|
1164
|
+
}
|
|
1165
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
1166
|
+
if (aliasId !== resolvedId) {
|
|
1167
|
+
if (!this.aliases.has(aliasId)) {
|
|
1168
|
+
this.aliases.set(aliasId, resolvedId);
|
|
1169
|
+
}
|
|
1170
|
+
else if (hasConsole) {
|
|
1171
|
+
// Warn the user if they were not aliasing to the resolvedId
|
|
1172
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
1173
|
+
if (currentResolvedId !== resolvedId) {
|
|
1174
|
+
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
1175
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1152
1179
|
}
|
|
1153
1180
|
async getModuleDependencyRecord(dependency) {
|
|
1154
1181
|
const resolvedDepId = await this.resolve(dependency);
|
|
@@ -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 Module Loader Shim v0.8.
|
|
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,i=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}):i&&o.mark(r+(n?`.${n}`:""))}function s({id:r,specifier:n}){if(t)t({id:r,phase:e.End,specifier:n});else if(i){const e=n?`.${n}`:"",t=r+e,i=`${r}.duration${e}`;o.measure(i,t),o.clearMarks(t),o.clearMeasures(i)}}function a(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 l="function"==typeof setTimeout,d="undefined"!=typeof console;const c=globalThis;c.LWR.requiredModules=c.LWR.requiredModules||[],c.LWR.requiredModules.indexOf("lwr/loader/v/0_8_0-alpha_9")<0&&c.LWR.requiredModules.push("lwr/loader/v/0_8_0-alpha_9"),new class{constructor(e){this.defineCache={},this.orderedDefs=[],l&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_8_0-alpha_9",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={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:n,logOperationEnd:s},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,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.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_8_0-alpha_9",["exports"],(e=>{Object.assign(e,{logOperationStart:n,logOperationEnd:s})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,ssrProps:i,endpoints:n,imports:s,index:a}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,ssrProps:i,endpoints:n,imports:s||{},index:a||{}}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{disableInitDefer:l}=this.config;e.registerImportMappings({imports:s,index:a},[t,r]).then((()=>{if(!l)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/loader/v/0_8_0-alpha_9",["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'}),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}"});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;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_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{constructor(e,t){this.importURICache=new Map,this.pendingURICache=new Map,this.loadMappingHooks=[],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.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());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=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 i=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(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this))}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.resolver.getBaseUrl();let o,i=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(i,{parentUrl:r});let s;if((t||null===t)&&(s=isResponseAPromise(t)?await t:t),null!==s){if("string"==typeof s){if(resolveIfNotPlainOrUrl(s,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);i=s;continue}if(o=s&&s.url&&(resolveIfNotPlainOrUrl(s.url,r)||s.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){const e=this.moduleRegistry.get(i);if(!e||!e.aliases.has(t))return t}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}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){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}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,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}})),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}getImportMetadataResolver(){return this.resolver}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r.aliases.has(t)||r.aliases.add(t),r;const o=this.moduleRegistry.keys();for(const e of o){const r=this.moduleRegistry.get(e);if(null==r?void 0:r.aliases.has(t))return r}const i=this.getModuleDef(e,t),n=i.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)}));return r={id:e,aliases:new Set([t]),module:Object.create(null),dependencyRecords:n,instantiation:i,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}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:i}=await e.instantiation,n={},s=await Promise.all(i.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(...s);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 i=this.resolver.getBaseUrl(),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,i),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,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o?evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r}):hasConsole&&console.warn(`stale module detected ${e}, current URL:${t}, new URL:${r}`)}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=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){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}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,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
7
|
+
/* LWR Module Loader Shim v0.8.1 */
|
|
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,i=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}):i&&o.mark(r+(n?`.${n}`:""))}function s({id:r,specifier:n}){if(t)t({id:r,phase:e.End,specifier:n});else if(i){const e=n?`.${n}`:"",t=r+e,i=`${r}.duration${e}`;o.measure(i,t),o.clearMarks(t),o.clearMeasures(i)}}function a(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 l="function"==typeof setTimeout,d="undefined"!=typeof console;const c=globalThis;c.LWR.requiredModules=c.LWR.requiredModules||[],c.LWR.requiredModules.indexOf("lwr/loader/v/0_8_1")<0&&c.LWR.requiredModules.push("lwr/loader/v/0_8_1"),new class{constructor(e){this.defineCache={},this.orderedDefs=[],l&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_8_1",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={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:n,logOperationEnd:s},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,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.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_8_1",["exports"],(e=>{Object.assign(e,{logOperationStart:n,logOperationEnd:s})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,ssrProps:i,endpoints:n,imports:s,index:a}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,ssrProps:i,endpoints:n,imports:s||{},index:a||{}}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{disableInitDefer:l}=this.config;e.registerImportMappings({imports:s,index:a},[t,r]).then((()=>{if(!l)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/loader/v/0_8_1",["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'}),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}"});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;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_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{constructor(e,t){this.importURICache=new Map,this.pendingURICache=new Map,this.loadMappingHooks=[],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.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());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=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 i=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(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.aliases=new Map,this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this))}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.resolver.getBaseUrl();let o,i=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(i,{parentUrl:r});let s;if((t||null===t)&&(s=isResponseAPromise(t)?await t:t),null!==s){if("string"==typeof s){if(resolveIfNotPlainOrUrl(s,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);i=s;continue}if(o=s&&s.url&&(resolveIfNotPlainOrUrl(s.url,r)||s.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){if(!this.moduleRegistry.get(i)||!this.aliases.has(t))return t}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}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){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}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,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}})),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}getImportMetadataResolver(){return this.resolver}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),i=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:i,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:i}=await e.instantiation,n={},s=await Promise.all(i.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(...s);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 i=this.resolver.getBaseUrl(),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,i),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,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o?evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r}):hasConsole&&console.warn(`stale module detected ${e}, current URL:${t}, new URL:${r}`)}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=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){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}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,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}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 Module Loader Shim v0.8.
|
|
7
|
+
/* LWR Module Loader Shim v0.8.1 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
// Parse configuration
|
|
141
141
|
this.global = global;
|
|
142
142
|
this.config = global.LWR;
|
|
143
|
-
this.loaderSpecifier = 'lwr/loader/v/
|
|
143
|
+
this.loaderSpecifier = 'lwr/loader/v/0_8_1';
|
|
144
144
|
// Set up error handler
|
|
145
145
|
this.errorHandler = this.config.onError;
|
|
146
146
|
// Set up the temporary LWR.define function and customInit hook
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
const exporter = (exports) => {
|
|
243
243
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
244
244
|
};
|
|
245
|
-
loader.define('lwr/profiler/v/
|
|
245
|
+
loader.define('lwr/profiler/v/0_8_1', ['exports'], exporter);
|
|
246
246
|
}
|
|
247
247
|
// Set up the application globals, import map, root custom element...
|
|
248
248
|
mountApp(loader) {
|
|
@@ -303,8 +303,8 @@
|
|
|
303
303
|
// The loader module is ALWAYS required
|
|
304
304
|
const GLOBAL = globalThis;
|
|
305
305
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
306
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
307
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
306
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_8_1') < 0) {
|
|
307
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_8_1');
|
|
308
308
|
}
|
|
309
309
|
new LoaderShim(GLOBAL);
|
|
310
310
|
|
|
@@ -39,6 +39,7 @@ var ModuleRegistry = class {
|
|
|
39
39
|
constructor(config) {
|
|
40
40
|
this.namedDefineRegistry = new Map();
|
|
41
41
|
this.moduleRegistry = new Map();
|
|
42
|
+
this.aliases = new Map();
|
|
42
43
|
this.profiler = config.profiler;
|
|
43
44
|
this.resolver = new import_importMetadataResolver.ImportMetadataResolver(config, this.importMetadataInvalidationCallback.bind(this));
|
|
44
45
|
}
|
|
@@ -99,7 +100,7 @@ var ModuleRegistry = class {
|
|
|
99
100
|
if (resolvedUrl) {
|
|
100
101
|
if (this.namedDefineRegistry.has(resolvedOrPlain) && this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
101
102
|
const record = this.moduleRegistry.get(resolvedUrl);
|
|
102
|
-
if (!record || !
|
|
103
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
103
104
|
return resolvedOrPlain;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -183,21 +184,28 @@ var ModuleRegistry = class {
|
|
|
183
184
|
getImportMetadataResolver() {
|
|
184
185
|
return this.resolver;
|
|
185
186
|
}
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
188
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
188
189
|
if (moduleRecord) {
|
|
189
|
-
|
|
190
|
-
moduleRecord.aliases.add(id);
|
|
191
|
-
}
|
|
190
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
192
191
|
return moduleRecord;
|
|
193
192
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
if (resolvedId !== aliasId) {
|
|
194
|
+
const alias = this.aliases.get(aliasId);
|
|
195
|
+
if (alias) {
|
|
196
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
197
|
+
if (aliasedModule) {
|
|
198
|
+
return aliasedModule;
|
|
199
|
+
}
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
return moduleRecord;
|
|
203
|
+
}
|
|
204
|
+
getModuleRecord(resolvedId, id) {
|
|
205
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
206
|
+
if (existingRecord) {
|
|
207
|
+
return existingRecord;
|
|
208
|
+
}
|
|
201
209
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
202
210
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
203
211
|
const dependencies = moduleDef.dependencies;
|
|
@@ -210,17 +218,29 @@ var ModuleRegistry = class {
|
|
|
210
218
|
}).filter((depRecord) => depRecord !== void 0);
|
|
211
219
|
return Promise.all(filtered);
|
|
212
220
|
});
|
|
213
|
-
|
|
221
|
+
const newModuleRecord = {
|
|
214
222
|
id: resolvedId,
|
|
215
|
-
aliases: new Set([id]),
|
|
216
223
|
module: Object.create(null),
|
|
217
224
|
dependencyRecords,
|
|
218
225
|
instantiation,
|
|
219
226
|
evaluated: false,
|
|
220
227
|
evaluationPromise: null
|
|
221
228
|
};
|
|
222
|
-
this.moduleRegistry.set(resolvedId,
|
|
223
|
-
|
|
229
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
230
|
+
this.storeModuleAlias(id, resolvedId);
|
|
231
|
+
return newModuleRecord;
|
|
232
|
+
}
|
|
233
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
234
|
+
if (aliasId !== resolvedId) {
|
|
235
|
+
if (!this.aliases.has(aliasId)) {
|
|
236
|
+
this.aliases.set(aliasId, resolvedId);
|
|
237
|
+
} else if (import_dom.hasConsole) {
|
|
238
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
239
|
+
if (currentResolvedId !== resolvedId) {
|
|
240
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
224
244
|
}
|
|
225
245
|
async getModuleDependencyRecord(dependency) {
|
|
226
246
|
const resolvedDepId = await this.resolve(dependency);
|
|
@@ -38,7 +38,8 @@ var ModuleRegistry = class {
|
|
|
38
38
|
constructor(config) {
|
|
39
39
|
this.namedDefineRegistry = new Map();
|
|
40
40
|
this.moduleRegistry = new Map();
|
|
41
|
-
this.
|
|
41
|
+
this.aliases = new Map();
|
|
42
|
+
this.baseUrl = config.baseUrl || "";
|
|
42
43
|
this.profiler = config.profiler;
|
|
43
44
|
}
|
|
44
45
|
async load(id, importer) {
|
|
@@ -98,7 +99,7 @@ var ModuleRegistry = class {
|
|
|
98
99
|
resolved = this.resolver.resolve(resolvedOrPlain, parentUrl);
|
|
99
100
|
if (this.namedDefineRegistry.has(resolvedOrPlain) && this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
100
101
|
const record = this.moduleRegistry.get(resolved);
|
|
101
|
-
if (!record || !
|
|
102
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
102
103
|
return resolvedOrPlain;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -211,14 +212,28 @@ var ModuleRegistry = class {
|
|
|
211
212
|
setImportResolver(resolver) {
|
|
212
213
|
this.resolver = resolver;
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
216
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
216
217
|
if (moduleRecord) {
|
|
217
|
-
|
|
218
|
-
moduleRecord.aliases.add(id);
|
|
219
|
-
}
|
|
218
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
220
219
|
return moduleRecord;
|
|
221
220
|
}
|
|
221
|
+
if (resolvedId !== aliasId) {
|
|
222
|
+
const alias = this.aliases.get(aliasId);
|
|
223
|
+
if (alias) {
|
|
224
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
225
|
+
if (aliasedModule) {
|
|
226
|
+
return aliasedModule;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return moduleRecord;
|
|
231
|
+
}
|
|
232
|
+
getModuleRecord(resolvedId, id) {
|
|
233
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
234
|
+
if (existingRecord) {
|
|
235
|
+
return existingRecord;
|
|
236
|
+
}
|
|
222
237
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
223
238
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
224
239
|
const dependencies = moduleDef.dependencies;
|
|
@@ -231,17 +246,29 @@ var ModuleRegistry = class {
|
|
|
231
246
|
}).filter((depRecord) => depRecord !== void 0);
|
|
232
247
|
return Promise.all(filtered);
|
|
233
248
|
});
|
|
234
|
-
|
|
249
|
+
const newModuleRecord = {
|
|
235
250
|
id: resolvedId,
|
|
236
|
-
aliases: new Set([id]),
|
|
237
251
|
module: Object.create(null),
|
|
238
252
|
dependencyRecords,
|
|
239
253
|
instantiation,
|
|
240
254
|
evaluated: false,
|
|
241
255
|
evaluationPromise: null
|
|
242
256
|
};
|
|
243
|
-
this.moduleRegistry.set(resolvedId,
|
|
244
|
-
|
|
257
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
258
|
+
this.storeModuleAlias(id, resolvedId);
|
|
259
|
+
return newModuleRecord;
|
|
260
|
+
}
|
|
261
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
262
|
+
if (aliasId !== resolvedId) {
|
|
263
|
+
if (!this.aliases.has(aliasId)) {
|
|
264
|
+
this.aliases.set(aliasId, resolvedId);
|
|
265
|
+
} else if (import_dom.hasConsole) {
|
|
266
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
267
|
+
if (currentResolvedId !== resolvedId) {
|
|
268
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
245
272
|
}
|
|
246
273
|
async getModuleDependencyRecord(dependency) {
|
|
247
274
|
const resolvedDepId = await this.resolve(dependency);
|
|
@@ -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.8.
|
|
7
|
+
/* LWR ESM Module Loader v0.8.1 */
|
|
8
8
|
/**
|
|
9
9
|
* Simplified version of the AMD Import Metadata Resolver.
|
|
10
10
|
* Just reads the ImportMetadata at construction time.
|
|
@@ -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.8.
|
|
7
|
+
/* LWR Module Loader v0.8.1 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
|
@@ -627,8 +627,10 @@ class ModuleRegistry {
|
|
|
627
627
|
constructor(config) {
|
|
628
628
|
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
629
629
|
this.namedDefineRegistry = new Map();
|
|
630
|
-
// The
|
|
630
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
631
631
|
this.moduleRegistry = new Map();
|
|
632
|
+
// Aliases of modules in the registry
|
|
633
|
+
this.aliases = new Map();
|
|
632
634
|
this.profiler = config.profiler;
|
|
633
635
|
this.resolver = new ImportMetadataResolver(config, this.importMetadataInvalidationCallback.bind(this));
|
|
634
636
|
}
|
|
@@ -700,7 +702,7 @@ class ModuleRegistry {
|
|
|
700
702
|
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
701
703
|
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
702
704
|
const record = this.moduleRegistry.get(resolvedUrl);
|
|
703
|
-
if (!record || !
|
|
705
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
704
706
|
return resolvedOrPlain;
|
|
705
707
|
}
|
|
706
708
|
}
|
|
@@ -799,23 +801,33 @@ class ModuleRegistry {
|
|
|
799
801
|
getImportMetadataResolver() {
|
|
800
802
|
return this.resolver;
|
|
801
803
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
+
// Returns an existing module record by the resolvedId or aliased id
|
|
805
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
806
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
804
807
|
if (moduleRecord) {
|
|
805
|
-
|
|
806
|
-
if (!moduleRecord.aliases.has(id)) {
|
|
807
|
-
moduleRecord.aliases.add(id);
|
|
808
|
-
}
|
|
808
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
809
809
|
return moduleRecord;
|
|
810
810
|
}
|
|
811
|
-
//
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
811
|
+
// Check if this is a known alias
|
|
812
|
+
if (resolvedId !== aliasId) {
|
|
813
|
+
const alias = this.aliases.get(aliasId);
|
|
814
|
+
if (alias) {
|
|
815
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
816
|
+
if (aliasedModule) {
|
|
817
|
+
return aliasedModule;
|
|
818
|
+
}
|
|
817
819
|
}
|
|
818
820
|
}
|
|
821
|
+
return moduleRecord;
|
|
822
|
+
}
|
|
823
|
+
getModuleRecord(resolvedId, id) {
|
|
824
|
+
// Look for an existing record
|
|
825
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
826
|
+
if (existingRecord) {
|
|
827
|
+
// return existing
|
|
828
|
+
return existingRecord;
|
|
829
|
+
}
|
|
830
|
+
// Create a new Module Record
|
|
819
831
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
820
832
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
821
833
|
const dependencies = moduleDef.dependencies;
|
|
@@ -831,17 +843,32 @@ class ModuleRegistry {
|
|
|
831
843
|
.filter((depRecord) => depRecord !== undefined);
|
|
832
844
|
return Promise.all(filtered);
|
|
833
845
|
});
|
|
834
|
-
|
|
846
|
+
const newModuleRecord = {
|
|
835
847
|
id: resolvedId,
|
|
836
|
-
aliases: new Set([id]),
|
|
837
848
|
module: Object.create(null),
|
|
838
849
|
dependencyRecords,
|
|
839
850
|
instantiation,
|
|
840
851
|
evaluated: false,
|
|
841
852
|
evaluationPromise: null,
|
|
842
853
|
};
|
|
843
|
-
this.moduleRegistry.set(resolvedId,
|
|
844
|
-
|
|
854
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
855
|
+
this.storeModuleAlias(id, resolvedId);
|
|
856
|
+
return newModuleRecord;
|
|
857
|
+
}
|
|
858
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
859
|
+
if (aliasId !== resolvedId) {
|
|
860
|
+
if (!this.aliases.has(aliasId)) {
|
|
861
|
+
this.aliases.set(aliasId, resolvedId);
|
|
862
|
+
}
|
|
863
|
+
else if (hasConsole) {
|
|
864
|
+
// Warn the user if they were not aliasing to the resolvedId
|
|
865
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
866
|
+
if (currentResolvedId !== resolvedId) {
|
|
867
|
+
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
868
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
845
872
|
}
|
|
846
873
|
async getModuleDependencyRecord(dependency) {
|
|
847
874
|
const resolvedDepId = await this.resolve(dependency);
|
|
@@ -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.8.
|
|
7
|
+
/* LWR Legacy Module Loader v0.8.1 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
|
@@ -409,9 +409,11 @@ class ModuleRegistry {
|
|
|
409
409
|
constructor(config) {
|
|
410
410
|
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
411
411
|
this.namedDefineRegistry = new Map();
|
|
412
|
-
// The
|
|
412
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
413
413
|
this.moduleRegistry = new Map();
|
|
414
|
-
|
|
414
|
+
// Aliases of modules in the registry
|
|
415
|
+
this.aliases = new Map();
|
|
416
|
+
this.baseUrl = config.baseUrl || '';
|
|
415
417
|
this.profiler = config.profiler;
|
|
416
418
|
}
|
|
417
419
|
async load(id, importer) {
|
|
@@ -482,7 +484,7 @@ class ModuleRegistry {
|
|
|
482
484
|
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
483
485
|
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
484
486
|
const record = this.moduleRegistry.get(resolved);
|
|
485
|
-
if (!record || !
|
|
487
|
+
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
486
488
|
return resolvedOrPlain;
|
|
487
489
|
}
|
|
488
490
|
}
|
|
@@ -613,15 +615,33 @@ class ModuleRegistry {
|
|
|
613
615
|
setImportResolver(resolver) {
|
|
614
616
|
this.resolver = resolver;
|
|
615
617
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
+
// Returns an existing module record by the resolvedId or aliased id
|
|
619
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
620
|
+
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
618
621
|
if (moduleRecord) {
|
|
619
|
-
|
|
620
|
-
if (!moduleRecord.aliases.has(id)) {
|
|
621
|
-
moduleRecord.aliases.add(id);
|
|
622
|
-
}
|
|
622
|
+
this.storeModuleAlias(aliasId, resolvedId);
|
|
623
623
|
return moduleRecord;
|
|
624
624
|
}
|
|
625
|
+
// Check if this is a known alias
|
|
626
|
+
if (resolvedId !== aliasId) {
|
|
627
|
+
const alias = this.aliases.get(aliasId);
|
|
628
|
+
if (alias) {
|
|
629
|
+
const aliasedModule = this.moduleRegistry.get(alias);
|
|
630
|
+
if (aliasedModule) {
|
|
631
|
+
return aliasedModule;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return moduleRecord;
|
|
636
|
+
}
|
|
637
|
+
getModuleRecord(resolvedId, id) {
|
|
638
|
+
// Look for an existing record
|
|
639
|
+
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
640
|
+
if (existingRecord) {
|
|
641
|
+
// return existing
|
|
642
|
+
return existingRecord;
|
|
643
|
+
}
|
|
644
|
+
// Create a new Module Record
|
|
625
645
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
626
646
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
627
647
|
const dependencies = moduleDef.dependencies;
|
|
@@ -637,17 +657,32 @@ class ModuleRegistry {
|
|
|
637
657
|
.filter((depRecord) => depRecord !== undefined);
|
|
638
658
|
return Promise.all(filtered);
|
|
639
659
|
});
|
|
640
|
-
|
|
660
|
+
const newModuleRecord = {
|
|
641
661
|
id: resolvedId,
|
|
642
|
-
aliases: new Set([id]),
|
|
643
662
|
module: Object.create(null),
|
|
644
663
|
dependencyRecords,
|
|
645
664
|
instantiation,
|
|
646
665
|
evaluated: false,
|
|
647
666
|
evaluationPromise: null,
|
|
648
667
|
};
|
|
649
|
-
this.moduleRegistry.set(resolvedId,
|
|
650
|
-
|
|
668
|
+
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
669
|
+
this.storeModuleAlias(id, resolvedId);
|
|
670
|
+
return newModuleRecord;
|
|
671
|
+
}
|
|
672
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
673
|
+
if (aliasId !== resolvedId) {
|
|
674
|
+
if (!this.aliases.has(aliasId)) {
|
|
675
|
+
this.aliases.set(aliasId, resolvedId);
|
|
676
|
+
}
|
|
677
|
+
else if (hasConsole) {
|
|
678
|
+
// Warn the user if they were not aliasing to the resolvedId
|
|
679
|
+
const currentResolvedId = this.aliases.get(aliasId);
|
|
680
|
+
if (currentResolvedId !== resolvedId) {
|
|
681
|
+
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
682
|
+
console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
651
686
|
}
|
|
652
687
|
async getModuleDependencyRecord(dependency) {
|
|
653
688
|
const resolvedDepId = await this.resolve(dependency);
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.8.
|
|
8
|
+
"version": "0.8.1",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"build": "yarn build:ts && yarn build:error-shim && yarn build:shim && yarn build:loader && yarn build:shim:bundle && yarn build:shim:bundle:minify"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@lwrjs/compiler": "0.8.
|
|
65
|
-
"@lwrjs/diagnostics": "0.8.
|
|
66
|
-
"@lwrjs/types": "0.8.
|
|
64
|
+
"@lwrjs/compiler": "0.8.1",
|
|
65
|
+
"@lwrjs/diagnostics": "0.8.1",
|
|
66
|
+
"@lwrjs/types": "0.8.1",
|
|
67
67
|
"rollup-plugin-terser": "^7.0.2"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@lwrjs/shared-utils": "0.8.
|
|
70
|
+
"@lwrjs/shared-utils": "0.8.1"
|
|
71
71
|
},
|
|
72
72
|
"lwc": {
|
|
73
73
|
"modules": [
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=14.15.4 <19"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "171c43556c5624849c8ee6b61ef6de5b65630e38"
|
|
88
88
|
}
|