@lwrjs/loader 0.19.1 → 0.19.3

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.
@@ -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.19.1 */
7
+ /* LWR Error Shim v0.19.3 */
8
8
  !function(){"use strict";const o=globalThis;if(!(o.LWR&&o.LWR.define)){const r=new Error("The LWR application failed to bootstrap");if(!o.LWR||!o.LWR.onError)throw r;o.LWR.onError(r)}}();
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Legacy Module Loader Shim v0.19.1 */
7
+ /* LWR Legacy Module Loader Shim v0.19.3 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -210,7 +210,7 @@
210
210
  // Parse configuration
211
211
  this.global = global;
212
212
  this.config = global.LWR ;
213
- this.loaderModule = 'lwr/loaderLegacy/v/0_19_1';
213
+ this.loaderModule = 'lwr/loaderLegacy/v/0_19_3';
214
214
 
215
215
  // Set up error handler
216
216
  this.errorHandler = this.config.onError ;
@@ -360,7 +360,7 @@
360
360
  const exporter = (exports) => {
361
361
  Object.assign(exports, { logOperationStart, logOperationEnd });
362
362
  };
363
- define('lwr/profiler/v/0_19_1', ['exports'], exporter, {});
363
+ define('lwr/profiler/v/0_19_3', ['exports'], exporter, {});
364
364
  }
365
365
 
366
366
  // Set up the application globals, import map, root custom element...
@@ -447,14 +447,14 @@
447
447
  // The loader module is ALWAYS required
448
448
  const GLOBAL = globalThis ;
449
449
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
450
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_19_1') < 0) {
451
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_19_1');
450
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_19_3') < 0) {
451
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_19_3');
452
452
  }
453
453
  new LoaderShim(GLOBAL);
454
454
 
455
455
  })();
456
456
 
457
- LWR.define('lwr/loaderLegacy/v/0_19_1', ['exports'], (function (exports) { 'use strict';
457
+ LWR.define('lwr/loaderLegacy/v/0_19_3', ['exports'], (function (exports) { 'use strict';
458
458
 
459
459
  const templateRegex = /\{([0-9]+)\}/g;
460
460
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -584,6 +584,11 @@ LWR.define('lwr/loaderLegacy/v/0_19_1', ['exports'], (function (exports) { 'use
584
584
  level: 0,
585
585
  message: 'Cannot import a blob URL',
586
586
  });
587
+ const NO_IMPORT_LOADER = Object.freeze({
588
+ code: 3024,
589
+ level: 0,
590
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
591
+ });
587
592
 
588
593
  /* importMap errors */
589
594
  const BAD_IMPORT_MAP = Object.freeze({
@@ -2118,6 +2123,12 @@ LWR.define('lwr/loaderLegacy/v/0_19_1', ['exports'], (function (exports) { 'use
2118
2123
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
2119
2124
  }
2120
2125
 
2126
+ // Throw an error if the specifier is "lwr/loaderLegacy" and the importer is defined
2127
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
2128
+ if (id === 'lwr/loaderLegacy' && importer !== undefined) {
2129
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
2130
+ }
2131
+
2121
2132
  // Throw an error if the specifier is a blob URL
2122
2133
  if (id.startsWith('blob:')) {
2123
2134
  throw new LoaderError(NO_BLOB_IMPORT);
@@ -4,9 +4,9 @@
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.19.1 */
8
- !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function i(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=i(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:i,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:i,metadata:d,specifierIndex:l});else if(s){const e=n(r,i,l),t=a(i,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(s){const e=n(r,l,d),t=i(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:i,customInit:n}=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")}(i,n),n){n({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_19_1",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:i}=s;if(!i)throw new Error("Expected Loader class to be defined");const n=new i(r);return o&&o.length&&n.registerExternalModules(o),n.define(e,["exports"],(e=>{Object.assign(e,{define:n.define.bind(n),load:n.load.bind(n),services:n.services,clearRegistry:n.clearRegistry.bind(n)})}),t[3]),n}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_19_1",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:i,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:i||{},importMappings:o,endpoints:n,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{initDeferDOM:a}=this.config;e.registerImportMappings(o).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():a?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_19_1")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_19_1"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_19_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"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),NO_IMPORT_LWC=Object.freeze({code:3022,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3023,level:0,message:"Cannot import a blob URL"}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;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,i=[];let n=-1;for(let e=0;e<s.length;e++)-1!==n?"/"===s[e]&&(i.push(s.slice(n,e+1)),n=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:n=e:(i.pop(),e+=2):n=e;return-1!==n&&i.push(s.slice(n)),t.slice(0,t.length-o.length)+i.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)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
7
+ /* LWR Legacy Module Loader Shim v0.19.3 */
8
+ !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function i(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=i(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:i,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:i,metadata:d,specifierIndex:l});else if(s){const e=n(r,i,l),t=a(i,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(s){const e=n(r,l,d),t=i(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:i,customInit:n}=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")}(i,n),n){n({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_19_3",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:i}=s;if(!i)throw new Error("Expected Loader class to be defined");const n=new i(r);return o&&o.length&&n.registerExternalModules(o),n.define(e,["exports"],(e=>{Object.assign(e,{define:n.define.bind(n),load:n.load.bind(n),services:n.services,clearRegistry:n.clearRegistry.bind(n)})}),t[3]),n}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_19_3",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:i,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:i||{},importMappings:o,endpoints:n,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{initDeferDOM:a}=this.config;e.registerImportMappings(o).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():a?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_19_3")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_19_3"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_19_3",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),NO_IMPORT_LWC=Object.freeze({code:3022,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3023,level:0,message:"Cannot import a blob URL"}),NO_IMPORT_LOADER=Object.freeze({code:3024,level:0,message:'Cannot dynamically import the LWR loader with importer "{0}"'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;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,i=[];let n=-1;for(let e=0;e<s.length;e++)-1!==n?"/"===s[e]&&(i.push(s.slice(n,e+1)),n=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:n=e:(i.pop(),e+=2):n=e;return-1!==n&&i.push(s.slice(n)),t.slice(0,t.length-o.length)+i.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)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
9
9
  /*!
10
10
  * Copyright (C) 2023 salesforce.com, inc.
11
11
  */
12
- const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);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||!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(trusted.createScript(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 i=e[t];try{if(null!==i({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler,this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}clearRegistry(){this.moduleRegistry=new Map}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=await this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.topLevelEvaluation(s)),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const i=this.resolveHook;let n=!0;if(i){for(let e=0;e<i.length;e++){const t=(0,i[e])(s,{parentUrl:r});let n;if((t||null===t)&&(n=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(n))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==n){if("string"==typeof n){if(resolveIfNotPlainOrUrl(n,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=n;continue}if(o=n&&n.url&&(resolveIfNotPlainOrUrl(n.url,r)||n.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){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,n=e?!!e.defaultUri:n,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.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 n&&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 i={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}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}async 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&&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)})),i={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,i),this.storeModuleAlias(t,e),s.then((()=>i))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,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,i={},n=s?await Promise.all(s.map((async e=>{if("exports"===e)return i;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;try{a=o(...n)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(i)&&Object.defineProperty(i,"__useDefault",{value:!0});const l=a||i;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,i=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:i}),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),i=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===i)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(i&&null!==i)return evaluateLoadHookResponse(i,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:i}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:i}),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]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}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(e.length>1&&-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])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}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)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const i in e){const n=resolveIfNotPlainOrUrl(i,r)||i,a=e[i];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[n]=l.uri:targetWarning(i,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 i=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[i]||(o.scopes[i]={}),t,r,i)}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}function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const s=e[o],i=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==r)return;"access"===s||"optionalAccess"===s?(t=r,r=i(r)):"call"!==s&&"optionalCall"!==s||(r=i(((...e)=>r.call(t,...e))),t=void 0)}return r}class Loader{constructor(e){const t=e||{};let r=t.baseUrl,o=t.profiler;if(r&&(r=r.replace(/\/?$/,"/")),r||(r=getBaseUrl()),!r)throw new LoaderError(NO_BASE_URL);this.baseUrl=r,o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:r,profiler:o}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:_optionalChain([e,"optionalAccess",e=>e.appMetadata])})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,i=t,n=o;"function"==typeof i&&(s=t,i=[],n=r),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,s,n||{})}async load(e,t){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);return this.registry.load(e,t)}clearRegistry(){this.registry.clearRegistry()}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)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
12
+ const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);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||!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(trusted.createScript(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 i=e[t];try{if(null!==i({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler,this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}clearRegistry(){this.moduleRegistry=new Map}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=await this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.topLevelEvaluation(s)),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const i=this.resolveHook;let n=!0;if(i){for(let e=0;e<i.length;e++){const t=(0,i[e])(s,{parentUrl:r});let n;if((t||null===t)&&(n=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(n))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==n){if("string"==typeof n){if(resolveIfNotPlainOrUrl(n,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=n;continue}if(o=n&&n.url&&(resolveIfNotPlainOrUrl(n.url,r)||n.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){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,n=e?!!e.defaultUri:n,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.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 n&&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 i={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}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}async 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&&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)})),i={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,i),this.storeModuleAlias(t,e),s.then((()=>i))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,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,i={},n=s?await Promise.all(s.map((async e=>{if("exports"===e)return i;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;try{a=o(...n)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(i)&&Object.defineProperty(i,"__useDefault",{value:!0});const l=a||i;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,i=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:i}),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),i=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===i)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(i&&null!==i)return evaluateLoadHookResponse(i,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:i}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:i}),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]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}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(e.length>1&&-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])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}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)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const i in e){const n=resolveIfNotPlainOrUrl(i,r)||i,a=e[i];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[n]=l.uri:targetWarning(i,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 i=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[i]||(o.scopes[i]={}),t,r,i)}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}function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const s=e[o],i=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==r)return;"access"===s||"optionalAccess"===s?(t=r,r=i(r)):"call"!==s&&"optionalCall"!==s||(r=i(((...e)=>r.call(t,...e))),t=void 0)}return r}class Loader{constructor(e){const t=e||{};let r=t.baseUrl,o=t.profiler;if(r&&(r=r.replace(/\/?$/,"/")),r||(r=getBaseUrl()),!r)throw new LoaderError(NO_BASE_URL);this.baseUrl=r,o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:r,profiler:o}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:_optionalChain([e,"optionalAccess",e=>e.appMetadata])})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,i=t,n=o;"function"==typeof i&&(s=t,i=[],n=r),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,s,n||{})}async load(e,t){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if("lwr/loaderLegacy"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LOADER,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);return this.registry.load(e,t)}clearRegistry(){this.registry.clearRegistry()}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)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(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.19.1 */
7
+ /* LWR Legacy Module Loader Shim v0.19.3 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -210,7 +210,7 @@
210
210
  // Parse configuration
211
211
  this.global = global;
212
212
  this.config = global.LWR ;
213
- this.loaderModule = 'lwr/loaderLegacy/v/0_19_1';
213
+ this.loaderModule = 'lwr/loaderLegacy/v/0_19_3';
214
214
 
215
215
  // Set up error handler
216
216
  this.errorHandler = this.config.onError ;
@@ -360,7 +360,7 @@
360
360
  const exporter = (exports) => {
361
361
  Object.assign(exports, { logOperationStart, logOperationEnd });
362
362
  };
363
- define('lwr/profiler/v/0_19_1', ['exports'], exporter, {});
363
+ define('lwr/profiler/v/0_19_3', ['exports'], exporter, {});
364
364
  }
365
365
 
366
366
  // Set up the application globals, import map, root custom element...
@@ -447,8 +447,8 @@
447
447
  // The loader module is ALWAYS required
448
448
  const GLOBAL = globalThis ;
449
449
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
450
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_19_1') < 0) {
451
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_19_1');
450
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_19_3') < 0) {
451
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_19_3');
452
452
  }
453
453
  new LoaderShim(GLOBAL);
454
454
 
@@ -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.19.1 */
7
+ /* LWR Module Loader Shim v0.19.3 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -213,7 +213,7 @@
213
213
  // Parse configuration
214
214
  this.global = global;
215
215
  this.config = global.LWR ;
216
- this.loaderSpecifier = 'lwr/loader/v/0_19_1';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_19_3';
217
217
 
218
218
  // Set up error handler
219
219
  this.errorHandler = this.config.onError ;
@@ -364,7 +364,7 @@
364
364
  const exporter = (exports) => {
365
365
  Object.assign(exports, { logOperationStart, logOperationEnd });
366
366
  };
367
- define('lwr/profiler/v/0_19_1', ['exports'], exporter);
367
+ define('lwr/profiler/v/0_19_3', ['exports'], exporter);
368
368
  }
369
369
 
370
370
  // Set up the application globals, import map, root custom element...
@@ -456,14 +456,14 @@
456
456
  // The loader module is ALWAYS required
457
457
  const GLOBAL = globalThis ;
458
458
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
459
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_1') < 0) {
460
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_1');
459
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_3') < 0) {
460
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_3');
461
461
  }
462
462
  new LoaderShim(GLOBAL);
463
463
 
464
464
  })();
465
465
 
466
- LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict';
466
+ LWR.define('lwr/loader/v/0_19_3', ['exports'], (function (exports) { 'use strict';
467
467
 
468
468
  const templateRegex = /\{([0-9]+)\}/g;
469
469
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -603,6 +603,11 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
603
603
  level: 0,
604
604
  message: 'Cannot dynamically import "lwc" with importer "{0}"',
605
605
  });
606
+ const NO_IMPORT_LOADER = Object.freeze({
607
+ code: 3024,
608
+ level: 0,
609
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
610
+ });
606
611
  const NO_BLOB_IMPORT = Object.freeze({
607
612
  code: 3024,
608
613
  level: 0,
@@ -1305,6 +1310,7 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1305
1310
 
1306
1311
 
1307
1312
 
1313
+
1308
1314
 
1309
1315
 
1310
1316
  class ModuleRegistry {
@@ -1543,46 +1549,78 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1543
1549
  return this.resolver;
1544
1550
  }
1545
1551
 
1546
- // Returns an existing module record by the resolvedId or aliased id
1547
- getExistingModuleRecord(resolvedId, aliasId) {
1548
- const moduleRecord = this.moduleRegistry.get(resolvedId);
1549
- if (moduleRecord) {
1550
- this.storeModuleAlias(aliasId, resolvedId);
1551
- return moduleRecord;
1552
+ /**
1553
+ * Gets or creates a module record for the given resolved ID and original ID.
1554
+ *
1555
+ * This function handles the complex logic of module resolution and ensures that:
1556
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
1557
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
1558
+ * 3. Alias mappings are maintained for future lookups
1559
+ *
1560
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
1561
+ * @param originalId - The original module specifer that was requested
1562
+ * @returns Promise<ModuleRecord> - The module record for the module
1563
+ */
1564
+ async getModuleRecord(resolvedId, originalId) {
1565
+ // Step 1: Check if we already have a module record for the resolved ID
1566
+ const existingRecord = this.moduleRegistry.get(resolvedId);
1567
+ if (existingRecord) {
1568
+ if (isUrl(resolvedId)) {
1569
+ // Special case: The resolved ID is a URL (likely a bundle URL)
1570
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
1571
+ const moduleDef = await existingRecord.instantiation;
1572
+
1573
+ const reResolvedId = await this.resolve(originalId);
1574
+
1575
+ // If the re-resolved ID is still a URL OR matches the module definition name,
1576
+ // then this is an internally mapped module (e.g., bundle -> specifier)
1577
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
1578
+ // Store the alias mapping and return the existing record
1579
+ this.storeModuleAlias(originalId, reResolvedId);
1580
+ return existingRecord;
1581
+ } else {
1582
+ // The re-resolved ID is now a specifier, check if we have a record for it
1583
+ resolvedId = reResolvedId;
1584
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
1585
+ if (reExistingRecord) {
1586
+ // Found a record for the specifier, store alias and return it
1587
+ this.storeModuleAlias(originalId, reResolvedId);
1588
+ return reExistingRecord;
1589
+ }
1590
+ }
1591
+ } else if (existingRecord) {
1592
+ // Simple case: resolved ID is a specifier and we have a record for it
1593
+ this.storeModuleAlias(originalId, resolvedId);
1594
+ return existingRecord;
1595
+ }
1552
1596
  }
1553
1597
 
1554
- // Check if this is a known alias
1555
- if (resolvedId !== aliasId) {
1556
- const alias = this.aliases.get(aliasId);
1598
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
1599
+ if (resolvedId !== originalId) {
1600
+ const alias = this.aliases.get(originalId);
1557
1601
  if (alias) {
1558
1602
  const aliasedModule = this.moduleRegistry.get(alias);
1559
1603
  if (aliasedModule) {
1604
+ // Found an existing module via alias, return it
1560
1605
  return aliasedModule;
1561
1606
  }
1562
1607
  }
1563
1608
  }
1564
- return moduleRecord;
1565
- }
1566
1609
 
1567
- async getModuleRecord(resolvedId, id) {
1568
- // Look for an existing record
1569
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1570
- if (existingRecord) {
1571
- // return existing
1572
- return existingRecord;
1573
- }
1610
+ // Step 3: No existing record found, create a new module record
1611
+ const instantiation = this.getModuleDef(resolvedId, originalId);
1574
1612
 
1575
- // Create a new Module Record
1576
- const instantiation = this.getModuleDef(resolvedId, id);
1613
+ // Create dependency records for all module dependencies
1577
1614
  const dependencyRecords = instantiation.then((moduleDef) => {
1578
1615
  const dependencies = moduleDef.dependencies || [];
1579
- // get dep and filter out exports
1616
+
1617
+ // Map dependencies to module records, filtering out 'exports' and 'require'
1580
1618
  const filtered = dependencies
1581
1619
  .map((dep) => {
1582
1620
  if (dep === 'exports') {
1583
- return;
1621
+ return; // 'exports' is a special AMD dependency, not a real module
1584
1622
  }
1585
- invariant(dep !== 'require', NO_AMD_REQUIRE);
1623
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
1586
1624
  return this.getModuleDependencyRecord.call(this, dep);
1587
1625
  })
1588
1626
  .filter((depRecord) => depRecord !== undefined) ;
@@ -1590,19 +1628,23 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1590
1628
  return Promise.all(filtered);
1591
1629
  });
1592
1630
 
1631
+ // Create the new module record
1593
1632
  const newModuleRecord = {
1594
- id: resolvedId,
1595
- module: Object.create(null),
1596
- dependencyRecords,
1597
- instantiation,
1598
- evaluated: false,
1599
- evaluationPromise: null,
1633
+ id: resolvedId, // Use resolved ID as the record identifier
1634
+ originalId: originalId, // Keep track of the original requested ID
1635
+ module: Object.create(null), // Empty object for module exports
1636
+ dependencyRecords, // Promise for dependency module records
1637
+ instantiation, // Promise for module definition
1638
+ evaluated: false, // Track if module has been evaluated
1639
+ evaluationPromise: null, // Promise for module evaluation
1600
1640
  };
1601
1641
 
1642
+ // Store the module record and create alias mapping
1602
1643
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1603
- this.storeModuleAlias(id, resolvedId);
1604
-
1605
- // Wait for the dependencies to resolve the return the moduleRecord
1644
+ if (resolvedId !== originalId) {
1645
+ this.storeModuleAlias(originalId, resolvedId);
1646
+ }
1647
+ // Wait for dependencies to resolve before returning the module record
1606
1648
  return dependencyRecords.then(() => newModuleRecord);
1607
1649
  }
1608
1650
 
@@ -1898,7 +1940,6 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1898
1940
 
1899
1941
 
1900
1942
 
1901
-
1902
1943
  addLoaderPlugin(hooks) {
1903
1944
  if (typeof hooks !== 'object') {
1904
1945
  throw new LoaderError(INVALID_HOOK);
@@ -2080,6 +2121,12 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
2080
2121
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
2081
2122
  }
2082
2123
 
2124
+ // Throw an error if the specifier is "lwr/loader" and the importer is defined
2125
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
2126
+ if (id === 'lwr/loader' && importer !== undefined) {
2127
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
2128
+ }
2129
+
2083
2130
  // Throw an error if the specifier is a blob URL
2084
2131
  if (id.startsWith('blob:')) {
2085
2132
  throw new LoaderError(NO_BLOB_IMPORT);
@@ -4,9 +4,9 @@
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.19.1 */
8
- !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_19_1",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:n}=i;if(!n)throw new Error("Expected Loader class to be defined");const s=new n(r);return o&&o.length&&s.registerExternalModules(o),s.define(e,["exports"],(e=>{Object.assign(e,{define:s.define.bind(s),load:s.load.bind(s),services:s.services})})),s}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_19_1",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{initDeferDOM:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():d?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_19_1")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_19_1"),new h(f)}(),LWR.define("lwr/loader/v/0_19_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"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'}),NO_IMPORT_LWC=Object.freeze({code:3023,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3024,level:0,message:"Cannot import a blob URL"});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;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)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e))})).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
7
+ /* LWR Module Loader Shim v0.19.3 */
8
+ !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_19_3",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:n}=i;if(!n)throw new Error("Expected Loader class to be defined");const s=new n(r);return o&&o.length&&s.registerExternalModules(o),s.define(e,["exports"],(e=>{Object.assign(e,{define:s.define.bind(s),load:s.load.bind(s),services:s.services})})),s}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_19_3",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{initDeferDOM:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():d?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_19_3")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_19_3"),new h(f)}(),LWR.define("lwr/loader/v/0_19_3",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'}),NO_IMPORT_LWC=Object.freeze({code:3023,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_IMPORT_LOADER=Object.freeze({code:3024,level:0,message:'Cannot dynamically import the LWR loader with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3024,level:0,message:"Cannot import a blob URL"});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;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)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e))})).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
9
9
  /*!
10
10
  * Copyright (C) 2023 salesforce.com, inc.
11
11
  */
12
- const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);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||!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(trusted.createScript(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}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.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),!this.isValidResolveResponse(s))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(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)){const e=this.namedDefineRegistry.get(t);if(e.external||e.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){e.map((e=>{if(!this.namedDefineRegistry.has(e)){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)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}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}async 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),i.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,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=i?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;try{a=o(...s)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}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||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||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})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)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){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);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)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
12
+ const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);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||!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(trusted.createScript(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}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.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),!this.isValidResolveResponse(s))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(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)){const e=this.namedDefineRegistry.get(t);if(e.external||e.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){e.map((e=>{if(!this.namedDefineRegistry.has(e)){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)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getImportMetadataResolver(){return this.resolver}async getModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)if(isUrl(e)){const o=await r.instantiation,i=await this.resolve(t);if(isUrl(i)||o.name===i)return this.storeModuleAlias(t,i),r;{e=i;const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,i),r}}else 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}}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,originalId:t,module:Object.create(null),dependencyRecords:i,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),e!==t&&this.storeModuleAlias(t,e),i.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,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=i?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;try{a=o(...s)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}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||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||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})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)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){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if("lwr/loader"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LOADER,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);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)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(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.19.1 */
7
+ /* LWR Module Loader Shim v0.19.3 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -213,7 +213,7 @@
213
213
  // Parse configuration
214
214
  this.global = global;
215
215
  this.config = global.LWR ;
216
- this.loaderSpecifier = 'lwr/loader/v/0_19_1';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_19_3';
217
217
 
218
218
  // Set up error handler
219
219
  this.errorHandler = this.config.onError ;
@@ -364,7 +364,7 @@
364
364
  const exporter = (exports) => {
365
365
  Object.assign(exports, { logOperationStart, logOperationEnd });
366
366
  };
367
- define('lwr/profiler/v/0_19_1', ['exports'], exporter);
367
+ define('lwr/profiler/v/0_19_3', ['exports'], exporter);
368
368
  }
369
369
 
370
370
  // Set up the application globals, import map, root custom element...
@@ -456,8 +456,8 @@
456
456
  // The loader module is ALWAYS required
457
457
  const GLOBAL = globalThis ;
458
458
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
459
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_1') < 0) {
460
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_1');
459
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_3') < 0) {
460
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_3');
461
461
  }
462
462
  new LoaderShim(GLOBAL);
463
463
 
@@ -43,6 +43,7 @@ __export(exports, {
43
43
  NO_AMD_REQUIRE: () => NO_AMD_REQUIRE,
44
44
  NO_BASE_URL: () => NO_BASE_URL,
45
45
  NO_BLOB_IMPORT: () => NO_BLOB_IMPORT,
46
+ NO_IMPORT_LOADER: () => NO_IMPORT_LOADER,
46
47
  NO_IMPORT_LWC: () => NO_IMPORT_LWC,
47
48
  NO_MAPPING_URL: () => NO_MAPPING_URL,
48
49
  STALE_HOOK_ERROR: () => STALE_HOOK_ERROR,
@@ -171,6 +172,11 @@ var NO_IMPORT_LWC = Object.freeze({
171
172
  level: 0,
172
173
  message: 'Cannot dynamically import "lwc" with importer "{0}"'
173
174
  });
175
+ var NO_IMPORT_LOADER = Object.freeze({
176
+ code: 3024,
177
+ level: 0,
178
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"'
179
+ });
174
180
  var NO_BLOB_IMPORT = Object.freeze({
175
181
  code: 3024,
176
182
  level: 0,
@@ -208,14 +208,30 @@ var ModuleRegistry = class {
208
208
  getImportMetadataResolver() {
209
209
  return this.resolver;
210
210
  }
211
- getExistingModuleRecord(resolvedId, aliasId) {
212
- const moduleRecord = this.moduleRegistry.get(resolvedId);
213
- if (moduleRecord) {
214
- this.storeModuleAlias(aliasId, resolvedId);
215
- return moduleRecord;
216
- }
217
- if (resolvedId !== aliasId) {
218
- const alias = this.aliases.get(aliasId);
211
+ async getModuleRecord(resolvedId, originalId) {
212
+ const existingRecord = this.moduleRegistry.get(resolvedId);
213
+ if (existingRecord) {
214
+ if ((0, import_url.isUrl)(resolvedId)) {
215
+ const moduleDef = await existingRecord.instantiation;
216
+ const reResolvedId = await this.resolve(originalId);
217
+ if ((0, import_url.isUrl)(reResolvedId) || moduleDef.name === reResolvedId) {
218
+ this.storeModuleAlias(originalId, reResolvedId);
219
+ return existingRecord;
220
+ } else {
221
+ resolvedId = reResolvedId;
222
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
223
+ if (reExistingRecord) {
224
+ this.storeModuleAlias(originalId, reResolvedId);
225
+ return reExistingRecord;
226
+ }
227
+ }
228
+ } else if (existingRecord) {
229
+ this.storeModuleAlias(originalId, resolvedId);
230
+ return existingRecord;
231
+ }
232
+ }
233
+ if (resolvedId !== originalId) {
234
+ const alias = this.aliases.get(originalId);
219
235
  if (alias) {
220
236
  const aliasedModule = this.moduleRegistry.get(alias);
221
237
  if (aliasedModule) {
@@ -223,14 +239,7 @@ var ModuleRegistry = class {
223
239
  }
224
240
  }
225
241
  }
226
- return moduleRecord;
227
- }
228
- async getModuleRecord(resolvedId, id) {
229
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
230
- if (existingRecord) {
231
- return existingRecord;
232
- }
233
- const instantiation = this.getModuleDef(resolvedId, id);
242
+ const instantiation = this.getModuleDef(resolvedId, originalId);
234
243
  const dependencyRecords = instantiation.then((moduleDef) => {
235
244
  const dependencies = moduleDef.dependencies || [];
236
245
  const filtered = dependencies.map((dep) => {
@@ -244,6 +253,7 @@ var ModuleRegistry = class {
244
253
  });
245
254
  const newModuleRecord = {
246
255
  id: resolvedId,
256
+ originalId,
247
257
  module: Object.create(null),
248
258
  dependencyRecords,
249
259
  instantiation,
@@ -251,7 +261,9 @@ var ModuleRegistry = class {
251
261
  evaluationPromise: null
252
262
  };
253
263
  this.moduleRegistry.set(resolvedId, newModuleRecord);
254
- this.storeModuleAlias(id, resolvedId);
264
+ if (resolvedId !== originalId) {
265
+ this.storeModuleAlias(originalId, resolvedId);
266
+ }
255
267
  return dependencyRecords.then(() => newModuleRecord);
256
268
  }
257
269
  storeModuleAlias(aliasId, resolvedId) {
@@ -42,6 +42,7 @@ __export(exports, {
42
42
  NO_AMD_REQUIRE: () => NO_AMD_REQUIRE,
43
43
  NO_BASE_URL: () => NO_BASE_URL,
44
44
  NO_BLOB_IMPORT: () => NO_BLOB_IMPORT,
45
+ NO_IMPORT_LOADER: () => NO_IMPORT_LOADER,
45
46
  NO_IMPORT_LWC: () => NO_IMPORT_LWC,
46
47
  STALE_HOOK_ERROR: () => STALE_HOOK_ERROR,
47
48
  UNRESOLVED: () => UNRESOLVED,
@@ -158,6 +159,11 @@ var NO_BLOB_IMPORT = Object.freeze({
158
159
  level: 0,
159
160
  message: "Cannot import a blob URL"
160
161
  });
162
+ var NO_IMPORT_LOADER = Object.freeze({
163
+ code: 3024,
164
+ level: 0,
165
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"'
166
+ });
161
167
  var BAD_IMPORT_MAP = Object.freeze({
162
168
  code: 3011,
163
169
  level: 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 ESM Module Loader v0.19.1 */
7
+ /* LWR ESM Module Loader v0.19.3 */
8
8
  function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
9
9
 
10
10
 
@@ -28,8 +28,9 @@ declare const BAD_IMPORT_METADATA: ErrorInfo;
28
28
  declare const EXPORTER_ERROR: ErrorInfo;
29
29
  declare const UNRESOLVEABLE_MAPPING_ERROR: ErrorInfo;
30
30
  declare const NO_IMPORT_LWC: ErrorInfo;
31
+ declare const NO_IMPORT_LOADER: ErrorInfo;
31
32
  declare const NO_BLOB_IMPORT: ErrorInfo;
32
33
  declare const BAD_IMPORT_MAP: ErrorInfo;
33
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, NO_MAPPING_URL, BAD_IMPORT_MAP, BAD_IMPORT_METADATA, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, UNRESOLVEABLE_MAPPING_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, };
34
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, NO_MAPPING_URL, BAD_IMPORT_MAP, BAD_IMPORT_METADATA, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, UNRESOLVEABLE_MAPPING_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
34
35
  export { invariant, LoaderError };
35
36
  //# sourceMappingURL=messages.d.ts.map
@@ -120,6 +120,11 @@ const NO_IMPORT_LWC = Object.freeze({
120
120
  level: 0,
121
121
  message: 'Cannot dynamically import "lwc" with importer "{0}"',
122
122
  });
123
+ const NO_IMPORT_LOADER = Object.freeze({
124
+ code: 3024,
125
+ level: 0,
126
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
127
+ });
123
128
  const NO_BLOB_IMPORT = Object.freeze({
124
129
  code: 3024,
125
130
  level: 0,
@@ -132,7 +137,7 @@ const BAD_IMPORT_MAP = Object.freeze({
132
137
  message: 'import map is not valid',
133
138
  });
134
139
  /* Errors */
135
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, NO_MAPPING_URL, BAD_IMPORT_MAP, BAD_IMPORT_METADATA, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, UNRESOLVEABLE_MAPPING_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, };
140
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, NO_MAPPING_URL, BAD_IMPORT_MAP, BAD_IMPORT_METADATA, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, UNRESOLVEABLE_MAPPING_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
136
141
  /* API */
137
142
  export { invariant, LoaderError };
138
143
  //# sourceMappingURL=messages.js.map
@@ -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.19.1 */
7
+ /* LWR Module Loader v0.19.3 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -143,6 +143,11 @@ const NO_IMPORT_LWC = Object.freeze({
143
143
  level: 0,
144
144
  message: 'Cannot dynamically import "lwc" with importer "{0}"',
145
145
  });
146
+ const NO_IMPORT_LOADER = Object.freeze({
147
+ code: 3024,
148
+ level: 0,
149
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
150
+ });
146
151
  const NO_BLOB_IMPORT = Object.freeze({
147
152
  code: 3024,
148
153
  level: 0,
@@ -845,6 +850,7 @@ async function evaluateLoadHook(
845
850
 
846
851
 
847
852
 
853
+
848
854
 
849
855
 
850
856
  class ModuleRegistry {
@@ -1084,46 +1090,78 @@ class ModuleRegistry {
1084
1090
  return this.resolver;
1085
1091
  }
1086
1092
 
1087
- // Returns an existing module record by the resolvedId or aliased id
1088
- getExistingModuleRecord(resolvedId, aliasId) {
1089
- const moduleRecord = this.moduleRegistry.get(resolvedId);
1090
- if (moduleRecord) {
1091
- this.storeModuleAlias(aliasId, resolvedId);
1092
- return moduleRecord;
1093
+ /**
1094
+ * Gets or creates a module record for the given resolved ID and original ID.
1095
+ *
1096
+ * This function handles the complex logic of module resolution and ensures that:
1097
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
1098
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
1099
+ * 3. Alias mappings are maintained for future lookups
1100
+ *
1101
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
1102
+ * @param originalId - The original module specifer that was requested
1103
+ * @returns Promise<ModuleRecord> - The module record for the module
1104
+ */
1105
+ async getModuleRecord(resolvedId, originalId) {
1106
+ // Step 1: Check if we already have a module record for the resolved ID
1107
+ const existingRecord = this.moduleRegistry.get(resolvedId);
1108
+ if (existingRecord) {
1109
+ if (isUrl(resolvedId)) {
1110
+ // Special case: The resolved ID is a URL (likely a bundle URL)
1111
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
1112
+ const moduleDef = await existingRecord.instantiation;
1113
+
1114
+ const reResolvedId = await this.resolve(originalId);
1115
+
1116
+ // If the re-resolved ID is still a URL OR matches the module definition name,
1117
+ // then this is an internally mapped module (e.g., bundle -> specifier)
1118
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
1119
+ // Store the alias mapping and return the existing record
1120
+ this.storeModuleAlias(originalId, reResolvedId);
1121
+ return existingRecord;
1122
+ } else {
1123
+ // The re-resolved ID is now a specifier, check if we have a record for it
1124
+ resolvedId = reResolvedId;
1125
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
1126
+ if (reExistingRecord) {
1127
+ // Found a record for the specifier, store alias and return it
1128
+ this.storeModuleAlias(originalId, reResolvedId);
1129
+ return reExistingRecord;
1130
+ }
1131
+ }
1132
+ } else if (existingRecord) {
1133
+ // Simple case: resolved ID is a specifier and we have a record for it
1134
+ this.storeModuleAlias(originalId, resolvedId);
1135
+ return existingRecord;
1136
+ }
1093
1137
  }
1094
1138
 
1095
- // Check if this is a known alias
1096
- if (resolvedId !== aliasId) {
1097
- const alias = this.aliases.get(aliasId);
1139
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
1140
+ if (resolvedId !== originalId) {
1141
+ const alias = this.aliases.get(originalId);
1098
1142
  if (alias) {
1099
1143
  const aliasedModule = this.moduleRegistry.get(alias);
1100
1144
  if (aliasedModule) {
1145
+ // Found an existing module via alias, return it
1101
1146
  return aliasedModule;
1102
1147
  }
1103
1148
  }
1104
1149
  }
1105
- return moduleRecord;
1106
- }
1107
1150
 
1108
- async getModuleRecord(resolvedId, id) {
1109
- // Look for an existing record
1110
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1111
- if (existingRecord) {
1112
- // return existing
1113
- return existingRecord;
1114
- }
1151
+ // Step 3: No existing record found, create a new module record
1152
+ const instantiation = this.getModuleDef(resolvedId, originalId);
1115
1153
 
1116
- // Create a new Module Record
1117
- const instantiation = this.getModuleDef(resolvedId, id);
1154
+ // Create dependency records for all module dependencies
1118
1155
  const dependencyRecords = instantiation.then((moduleDef) => {
1119
1156
  const dependencies = moduleDef.dependencies || [];
1120
- // get dep and filter out exports
1157
+
1158
+ // Map dependencies to module records, filtering out 'exports' and 'require'
1121
1159
  const filtered = dependencies
1122
1160
  .map((dep) => {
1123
1161
  if (dep === 'exports') {
1124
- return;
1162
+ return; // 'exports' is a special AMD dependency, not a real module
1125
1163
  }
1126
- invariant(dep !== 'require', NO_AMD_REQUIRE);
1164
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
1127
1165
  return this.getModuleDependencyRecord.call(this, dep);
1128
1166
  })
1129
1167
  .filter((depRecord) => depRecord !== undefined) ;
@@ -1131,19 +1169,23 @@ class ModuleRegistry {
1131
1169
  return Promise.all(filtered);
1132
1170
  });
1133
1171
 
1172
+ // Create the new module record
1134
1173
  const newModuleRecord = {
1135
- id: resolvedId,
1136
- module: Object.create(null),
1137
- dependencyRecords,
1138
- instantiation,
1139
- evaluated: false,
1140
- evaluationPromise: null,
1174
+ id: resolvedId, // Use resolved ID as the record identifier
1175
+ originalId: originalId, // Keep track of the original requested ID
1176
+ module: Object.create(null), // Empty object for module exports
1177
+ dependencyRecords, // Promise for dependency module records
1178
+ instantiation, // Promise for module definition
1179
+ evaluated: false, // Track if module has been evaluated
1180
+ evaluationPromise: null, // Promise for module evaluation
1141
1181
  };
1142
1182
 
1183
+ // Store the module record and create alias mapping
1143
1184
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1144
- this.storeModuleAlias(id, resolvedId);
1145
-
1146
- // Wait for the dependencies to resolve the return the moduleRecord
1185
+ if (resolvedId !== originalId) {
1186
+ this.storeModuleAlias(originalId, resolvedId);
1187
+ }
1188
+ // Wait for dependencies to resolve before returning the module record
1147
1189
  return dependencyRecords.then(() => newModuleRecord);
1148
1190
  }
1149
1191
 
@@ -1439,7 +1481,6 @@ class ModuleRegistry {
1439
1481
 
1440
1482
 
1441
1483
 
1442
-
1443
1484
  addLoaderPlugin(hooks) {
1444
1485
  if (typeof hooks !== 'object') {
1445
1486
  throw new LoaderError(INVALID_HOOK);
@@ -1621,6 +1662,12 @@ class Loader {
1621
1662
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
1622
1663
  }
1623
1664
 
1665
+ // Throw an error if the specifier is "lwr/loader" and the importer is defined
1666
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
1667
+ if (id === 'lwr/loader' && importer !== undefined) {
1668
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
1669
+ }
1670
+
1624
1671
  // Throw an error if the specifier is a blob URL
1625
1672
  if (id.startsWith('blob:')) {
1626
1673
  throw new LoaderError(NO_BLOB_IMPORT);
@@ -26,7 +26,18 @@ export declare class ModuleRegistry {
26
26
  aliases: Map<string, string>;
27
27
  private lastDefine;
28
28
  getImportMetadataResolver(): ImportMetadataResolver;
29
- private getExistingModuleRecord;
29
+ /**
30
+ * Gets or creates a module record for the given resolved ID and original ID.
31
+ *
32
+ * This function handles the complex logic of module resolution and ensures that:
33
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
34
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
35
+ * 3. Alias mappings are maintained for future lookups
36
+ *
37
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
38
+ * @param originalId - The original module specifer that was requested
39
+ * @returns Promise<ModuleRecord> - The module record for the module
40
+ */
30
41
  private getModuleRecord;
31
42
  private storeModuleAlias;
32
43
  private getModuleDependencyRecord;
@@ -39,7 +50,6 @@ export declare class ModuleRegistry {
39
50
  private getModuleDef;
40
51
  private resolveHook?;
41
52
  private loadHook?;
42
- private loadMappingHooks?;
43
53
  addLoaderPlugin(hooks: LoaderHooks): void;
44
54
  private importMetadataInvalidationCallback;
45
55
  private handleStaleModuleHook?;
@@ -214,59 +214,95 @@ export class ModuleRegistry {
214
214
  getImportMetadataResolver() {
215
215
  return this.resolver;
216
216
  }
217
- // Returns an existing module record by the resolvedId or aliased id
218
- getExistingModuleRecord(resolvedId, aliasId) {
219
- const moduleRecord = this.moduleRegistry.get(resolvedId);
220
- if (moduleRecord) {
221
- this.storeModuleAlias(aliasId, resolvedId);
222
- return moduleRecord;
223
- }
224
- // Check if this is a known alias
225
- if (resolvedId !== aliasId) {
226
- const alias = this.aliases.get(aliasId);
217
+ /**
218
+ * Gets or creates a module record for the given resolved ID and original ID.
219
+ *
220
+ * This function handles the complex logic of module resolution and ensures that:
221
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
222
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
223
+ * 3. Alias mappings are maintained for future lookups
224
+ *
225
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
226
+ * @param originalId - The original module specifer that was requested
227
+ * @returns Promise<ModuleRecord> - The module record for the module
228
+ */
229
+ async getModuleRecord(resolvedId, originalId) {
230
+ // Step 1: Check if we already have a module record for the resolved ID
231
+ const existingRecord = this.moduleRegistry.get(resolvedId);
232
+ if (existingRecord) {
233
+ if (isUrl(resolvedId)) {
234
+ // Special case: The resolved ID is a URL (likely a bundle URL)
235
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
236
+ const moduleDef = await existingRecord.instantiation;
237
+ const reResolvedId = await this.resolve(originalId);
238
+ // If the re-resolved ID is still a URL OR matches the module definition name,
239
+ // then this is an internally mapped module (e.g., bundle -> specifier)
240
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
241
+ // Store the alias mapping and return the existing record
242
+ this.storeModuleAlias(originalId, reResolvedId);
243
+ return existingRecord;
244
+ }
245
+ else {
246
+ // The re-resolved ID is now a specifier, check if we have a record for it
247
+ resolvedId = reResolvedId;
248
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
249
+ if (reExistingRecord) {
250
+ // Found a record for the specifier, store alias and return it
251
+ this.storeModuleAlias(originalId, reResolvedId);
252
+ return reExistingRecord;
253
+ }
254
+ }
255
+ }
256
+ else if (existingRecord) {
257
+ // Simple case: resolved ID is a specifier and we have a record for it
258
+ this.storeModuleAlias(originalId, resolvedId);
259
+ return existingRecord;
260
+ }
261
+ }
262
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
263
+ if (resolvedId !== originalId) {
264
+ const alias = this.aliases.get(originalId);
227
265
  if (alias) {
228
266
  const aliasedModule = this.moduleRegistry.get(alias);
229
267
  if (aliasedModule) {
268
+ // Found an existing module via alias, return it
230
269
  return aliasedModule;
231
270
  }
232
271
  }
233
272
  }
234
- return moduleRecord;
235
- }
236
- async getModuleRecord(resolvedId, id) {
237
- // Look for an existing record
238
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
239
- if (existingRecord) {
240
- // return existing
241
- return existingRecord;
242
- }
243
- // Create a new Module Record
244
- const instantiation = this.getModuleDef(resolvedId, id);
273
+ // Step 3: No existing record found, create a new module record
274
+ const instantiation = this.getModuleDef(resolvedId, originalId);
275
+ // Create dependency records for all module dependencies
245
276
  const dependencyRecords = instantiation.then((moduleDef) => {
246
277
  const dependencies = moduleDef.dependencies || [];
247
- // get dep and filter out exports
278
+ // Map dependencies to module records, filtering out 'exports' and 'require'
248
279
  const filtered = dependencies
249
280
  .map((dep) => {
250
281
  if (dep === 'exports') {
251
- return;
282
+ return; // 'exports' is a special AMD dependency, not a real module
252
283
  }
253
- invariant(dep !== 'require', NO_AMD_REQUIRE);
284
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
254
285
  return this.getModuleDependencyRecord.call(this, dep);
255
286
  })
256
287
  .filter((depRecord) => depRecord !== undefined);
257
288
  return Promise.all(filtered);
258
289
  });
290
+ // Create the new module record
259
291
  const newModuleRecord = {
260
292
  id: resolvedId,
293
+ originalId: originalId,
261
294
  module: Object.create(null),
262
295
  dependencyRecords,
263
296
  instantiation,
264
297
  evaluated: false,
265
- evaluationPromise: null,
298
+ evaluationPromise: null, // Promise for module evaluation
266
299
  };
300
+ // Store the module record and create alias mapping
267
301
  this.moduleRegistry.set(resolvedId, newModuleRecord);
268
- this.storeModuleAlias(id, resolvedId);
269
- // Wait for the dependencies to resolve the return the moduleRecord
302
+ if (resolvedId !== originalId) {
303
+ this.storeModuleAlias(originalId, resolvedId);
304
+ }
305
+ // Wait for dependencies to resolve before returning the module record
270
306
  return dependencyRecords.then(() => newModuleRecord);
271
307
  }
272
308
  storeModuleAlias(aliasId, resolvedId) {
@@ -26,7 +26,8 @@ declare const FAIL_HOOK_LOAD: ErrorInfo;
26
26
  declare const EXPORTER_ERROR: ErrorInfo;
27
27
  declare const NO_IMPORT_LWC: ErrorInfo;
28
28
  declare const NO_BLOB_IMPORT: ErrorInfo;
29
+ declare const NO_IMPORT_LOADER: ErrorInfo;
29
30
  declare const BAD_IMPORT_MAP: ErrorInfo;
30
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, };
31
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
31
32
  export { invariant, LoaderError };
32
33
  //# sourceMappingURL=messages.d.ts.map
@@ -110,6 +110,11 @@ const NO_BLOB_IMPORT = Object.freeze({
110
110
  level: 0,
111
111
  message: 'Cannot import a blob URL',
112
112
  });
113
+ const NO_IMPORT_LOADER = Object.freeze({
114
+ code: 3024,
115
+ level: 0,
116
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
117
+ });
113
118
  /* importMap errors */
114
119
  const BAD_IMPORT_MAP = Object.freeze({
115
120
  code: 3011,
@@ -117,7 +122,7 @@ const BAD_IMPORT_MAP = Object.freeze({
117
122
  message: 'import map is not valid',
118
123
  });
119
124
  /* Errors */
120
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, };
125
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
121
126
  /* API */
122
127
  export { invariant, LoaderError };
123
128
  //# sourceMappingURL=messages.js.map
@@ -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.19.1 */
7
+ /* LWR Legacy Module Loader v0.19.3 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -133,6 +133,11 @@ const NO_BLOB_IMPORT = Object.freeze({
133
133
  level: 0,
134
134
  message: 'Cannot import a blob URL',
135
135
  });
136
+ const NO_IMPORT_LOADER = Object.freeze({
137
+ code: 3024,
138
+ level: 0,
139
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
140
+ });
136
141
 
137
142
  /* importMap errors */
138
143
  const BAD_IMPORT_MAP = Object.freeze({
@@ -1668,6 +1673,12 @@ class Loader {
1668
1673
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
1669
1674
  }
1670
1675
 
1676
+ // Throw an error if the specifier is "lwr/loaderLegacy" and the importer is defined
1677
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
1678
+ if (id === 'lwr/loaderLegacy' && importer !== undefined) {
1679
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
1680
+ }
1681
+
1671
1682
  // Throw an error if the specifier is a blob URL
1672
1683
  if (id.startsWith('blob:')) {
1673
1684
  throw new LoaderError(NO_BLOB_IMPORT);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.19.1",
8
+ "version": "0.19.3",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -61,16 +61,16 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@locker/trusted-types": "0.24.6",
64
- "@lwrjs/diagnostics": "0.19.1",
65
- "@lwrjs/types": "0.19.1",
64
+ "@lwrjs/diagnostics": "0.19.3",
65
+ "@lwrjs/types": "0.19.3",
66
66
  "@rollup/plugin-node-resolve": "^15.2.3",
67
67
  "@rollup/plugin-sucrase": "^5.0.2",
68
68
  "@rollup/plugin-terser": "^0.4.4",
69
69
  "rollup": "^2.79.2"
70
70
  },
71
71
  "dependencies": {
72
- "@lwrjs/client-modules": "0.19.1",
73
- "@lwrjs/shared-utils": "0.19.1"
72
+ "@lwrjs/client-modules": "0.19.3",
73
+ "@lwrjs/shared-utils": "0.19.3"
74
74
  },
75
75
  "lwc": {
76
76
  "modules": [
@@ -90,5 +90,5 @@
90
90
  "volta": {
91
91
  "extends": "../../../package.json"
92
92
  },
93
- "gitHead": "04c6989df90465662f58f61e3d6c482c086a7c44"
93
+ "gitHead": "2470689217830c5d706cf984830d6e62edf4d012"
94
94
  }