@lwrjs/loader 0.11.0-alpha.6 → 0.11.0-alpha.7

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,6 +4,6 @@
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.11.0-alpha.6 */
7
+ /* LWR Error Shim v0.11.0-alpha.7 */
8
8
  !function(){"use strict";if(!(globalThis.LWR&&globalThis.LWR.define)){const o=new Error("The LWR application failed to bootstrap");if(!globalThis.LWR||!globalThis.LWR.onError)throw o;globalThis.LWR.onError(o)}}();
9
9
  //# sourceMappingURL=lwr-error-shim.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 Shim v0.11.0-alpha.6 */
7
+ /* LWR Legacy Module Loader Shim v0.11.0-alpha.7 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -207,7 +207,7 @@
207
207
  // Parse configuration
208
208
  this.global = global;
209
209
  this.config = global.LWR ;
210
- this.loaderModule = 'lwr/loaderLegacy/v/0_11_0-alpha_6';
210
+ this.loaderModule = 'lwr/loaderLegacy/v/0_11_0-alpha_7';
211
211
 
212
212
  // Set up error handler
213
213
  this.errorHandler = this.config.onError;
@@ -327,7 +327,7 @@
327
327
  const exporter = (exports) => {
328
328
  Object.assign(exports, { logOperationStart, logOperationEnd });
329
329
  };
330
- globalLWR.define('lwr/profiler/v/0_11_0-alpha_6', ['exports'], exporter, {});
330
+ globalLWR.define('lwr/profiler/v/0_11_0-alpha_7', ['exports'], exporter, {});
331
331
  }
332
332
 
333
333
  // Set up the application globals, import map, root custom element...
@@ -398,15 +398,15 @@
398
398
  // The loader module is ALWAYS required
399
399
  const GLOBAL = globalThis ;
400
400
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
401
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_11_0-alpha_6') < 0) {
402
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_11_0-alpha_6');
401
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_11_0-alpha_7') < 0) {
402
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_11_0-alpha_7');
403
403
  }
404
404
  new LoaderShim(GLOBAL);
405
405
 
406
406
  })();
407
407
  //# sourceMappingURL=lwr-loader-shim-legacy.js.map
408
408
 
409
- LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'use strict';
409
+ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_7', ['exports'], (function (exports) { 'use strict';
410
410
 
411
411
  const templateRegex = /\{([0-9]+)\}/g;
412
412
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -824,7 +824,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
824
824
 
825
825
  async function evaluateLoadHookResponse(response, id) {
826
826
  return Promise.resolve().then(async () => {
827
- if (!response.status) {
827
+ if (!response || !response.status) {
828
828
  throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
829
829
  }
830
830
  if (response.status !== 200) {
@@ -851,6 +851,10 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
851
851
  // TODO eval source maps for debugging
852
852
  eval(trusted.createScript(code));
853
853
  } catch (e) {
854
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
855
+ // eslint-disable-next-line lwr/no-unguarded-apis
856
+ console.error(e);
857
+ }
854
858
  throw new LoaderError(FAIL_LOAD, [id]);
855
859
  }
856
860
 
@@ -918,6 +922,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
918
922
  // Loader: modules
919
923
  const LOADER_PREFIX = 'lwr.loader.';
920
924
  const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
925
+ const MODULE_DYNAMIC_LOAD = `${LOADER_PREFIX}moduleRegistry.dynamicLoad`;
921
926
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
922
927
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
923
928
 
@@ -972,6 +977,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
972
977
 
973
978
 
974
979
 
980
+
975
981
 
976
982
 
977
983
  class ModuleRegistry {
@@ -983,8 +989,14 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
983
989
  }
984
990
 
985
991
  async load(id, importer) {
992
+ const metadata = importer ? { importer } : {};
993
+ this.profiler.logOperationStart({
994
+ id: MODULE_DYNAMIC_LOAD,
995
+ specifier: id,
996
+ metadata,
997
+ });
986
998
  const resolvedId = await this.resolve(id, importer);
987
- const moduleRecord = this.getModuleRecord(resolvedId, id);
999
+ const moduleRecord = await this.getModuleRecord(resolvedId, id);
988
1000
  if (moduleRecord.evaluated) {
989
1001
  return moduleRecord.module;
990
1002
  } else {
@@ -1061,6 +1073,8 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1061
1073
  // return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
1062
1074
  if (
1063
1075
  this.namedDefineRegistry.has(resolvedOrPlain) &&
1076
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1077
+ // @ts-ignore has check right above
1064
1078
  this.namedDefineRegistry.get(resolvedOrPlain).defined
1065
1079
  ) {
1066
1080
  const record = this.moduleRegistry.get(resolved);
@@ -1114,7 +1128,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1114
1128
  defined: true,
1115
1129
  };
1116
1130
  if (mod && mod.external) {
1117
- // if module is "external", resolve the external promise to notify any dependees
1131
+ // if module is "external", resolve the external promise to notify any dependencies
1118
1132
  mod.external.resolveExternal(moduleDef);
1119
1133
  }
1120
1134
 
@@ -1242,7 +1256,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1242
1256
  return moduleRecord;
1243
1257
  }
1244
1258
 
1245
- getModuleRecord(resolvedId, id) {
1259
+ async getModuleRecord(resolvedId, id) {
1246
1260
  // Look for an existing record
1247
1261
  const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1248
1262
  if (existingRecord) {
@@ -1253,7 +1267,7 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1253
1267
  // Create a new Module Record
1254
1268
  const instantiation = this.getModuleDef(resolvedId, id);
1255
1269
  const dependencyRecords = instantiation.then((moduleDef) => {
1256
- const dependencies = moduleDef.dependencies;
1270
+ const dependencies = (moduleDef && moduleDef.dependencies) || [];
1257
1271
  // get dep and filter out exports
1258
1272
  const filtered = dependencies
1259
1273
  .map((dep) => {
@@ -1278,7 +1292,9 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1278
1292
  };
1279
1293
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1280
1294
  this.storeModuleAlias(id, resolvedId);
1281
- return newModuleRecord;
1295
+
1296
+ // Wait for the dependencies to resolve the return the moduleRecord
1297
+ return dependencyRecords.then(() => newModuleRecord);
1282
1298
  }
1283
1299
 
1284
1300
  storeModuleAlias(aliasId, resolvedId) {
@@ -1289,8 +1305,10 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1289
1305
  // Warn the user if they were not aliasing to the resolvedId
1290
1306
  const currentResolvedId = this.aliases.get(aliasId);
1291
1307
  if (currentResolvedId !== resolvedId) {
1292
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1293
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1308
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
1309
+ // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1310
+ console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1311
+ }
1294
1312
  }
1295
1313
  }
1296
1314
  }
@@ -1339,37 +1357,39 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1339
1357
  const { exporter, dependencies } = await moduleRecord.instantiation;
1340
1358
  // The exports object automatically gets filled in by the exporter evaluation
1341
1359
  const exports = {};
1342
- const depsMapped = await Promise.all(
1343
- dependencies.map(async (dep) => {
1344
- if (dep === 'exports') {
1345
- return exports;
1346
- }
1347
- const resolvedDepId = await this.resolve(dep);
1348
-
1349
- const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1350
- if (!moduleRecord) {
1351
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1352
- }
1353
-
1354
- const module = moduleRecord.module;
1355
-
1356
- /**
1357
- * Circular dependencies are handled properly when named exports are used,
1358
- * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1359
- *
1360
- * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1361
- */
1362
- if (!moduleRecord.evaluated) {
1363
- return this.getCircularDependencyWrapper(module);
1364
- }
1365
-
1366
- if (module) {
1367
- return module.__defaultInterop ? module.default : module;
1368
- }
1369
-
1370
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1371
- }),
1372
- );
1360
+ const depsMapped = dependencies
1361
+ ? await Promise.all(
1362
+ dependencies.map(async (dep) => {
1363
+ if (dep === 'exports') {
1364
+ return exports;
1365
+ }
1366
+ const resolvedDepId = await this.resolve(dep);
1367
+
1368
+ const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1369
+ if (!moduleRecord) {
1370
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1371
+ }
1372
+
1373
+ const module = moduleRecord.module;
1374
+
1375
+ /**
1376
+ * Circular dependencies are handled properly when named exports are used,
1377
+ * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1378
+ *
1379
+ * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1380
+ */
1381
+ if (!moduleRecord.evaluated) {
1382
+ return this.getCircularDependencyWrapper(module);
1383
+ }
1384
+
1385
+ if (module) {
1386
+ return module.__defaultInterop ? module.default : module;
1387
+ }
1388
+
1389
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1390
+ }),
1391
+ )
1392
+ : [];
1373
1393
 
1374
1394
  // W-10029836 - In the case where we could be instantiating multiple graphs at the same time lets make sure the module have not already been evaluated
1375
1395
  if (moduleRecord.evaluated) {
@@ -1532,7 +1552,12 @@ LWR.define('lwr/loaderLegacy/v/0_11_0-alpha_6', ['exports'], (function (exports)
1532
1552
  return moduleDef;
1533
1553
  })
1534
1554
  .catch((e) => {
1535
- this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1555
+ // Create module error marks for all errors caused by the loader
1556
+ // Note: these marks do not include errors caused by invalid server responses or loader hooks
1557
+ if (!(e instanceof LoaderError)) {
1558
+ this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1559
+ }
1560
+
1536
1561
  throw e;
1537
1562
  });
1538
1563
  }
@@ -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.11.0-alpha.6 */
8
- !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_11_0-alpha_6",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(this.config),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s,i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e.define("lwr/profiler/v/0_11_0-alpha_6",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:n,importMappings:o,endpoints:i}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings(o).then((()=>{if(!a)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){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)}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_11_0-alpha_6")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_11_0-alpha_6"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_11_0-alpha_6",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4,SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes;
7
+ /* LWR Legacy Module Loader Shim v0.11.0-alpha.7 */
8
+ !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_11_0-alpha_7",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(this.config),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s,i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e.define("lwr/profiler/v/0_11_0-alpha_7",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:n,importMappings:o,endpoints:i}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings(o).then((()=>{if(!a)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){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)}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_11_0-alpha_7")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_11_0-alpha_7"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_11_0-alpha_7",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4,SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes;
9
9
  /*!
10
10
  * Copyright (C) 2023 salesforce.com, inc.
11
- */function createTrustedTypesPolicy(e,t){return trustedTypes.createPolicy(e,t)}function createFallbackPolicy(e,t){return t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createTrustedTypesPolicy:createFallbackPolicy,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.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 n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;let i=!0;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(i))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,i=e?!!e.defaultUri:i,this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return i&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init(){this.namedDefineRegistry=new Map}__init2(){this.moduleRegistry=new Map}__init3(){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}getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=e.dependencies.map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),n}storeModuleAlias(e,t){if(e!==t)if(this.aliases.has(e)){if(hasConsole){const r=this.aliases.get(e);r!==t&&console.warn(`Alias update attempt: ${e}=>${r}, ${t}`)}}else this.aliases.set(e,t)}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])})));if(e.evaluated)return e.module;let a;try{a=o(...i)}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 s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){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 n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l.uri:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
11
+ */function createTrustedTypesPolicy(e,t){return trustedTypes.createPolicy(e,t)}function createFallbackPolicy(e,t){return t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createTrustedTypesPolicy:createFallbackPolicy,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 n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}moduleRegistry.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}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 n=this.resolveHook;let i=!0;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(i))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,i=e?!!e.defaultUri:i,this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return i&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init(){this.namedDefineRegistry=new Map}__init2(){this.moduleRegistry=new Map}__init3(){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)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),s.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)?hasConsole&&this.aliases.get(e):this.aliases.set(e,t))}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=s?await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...i)}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 s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw 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}=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}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){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 n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l.uri:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
12
12
  //# sourceMappingURL=lwr-loader-shim-legacy.bundle.min.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 Shim v0.11.0-alpha.6 */
7
+ /* LWR Legacy Module Loader Shim v0.11.0-alpha.7 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -207,7 +207,7 @@
207
207
  // Parse configuration
208
208
  this.global = global;
209
209
  this.config = global.LWR ;
210
- this.loaderModule = 'lwr/loaderLegacy/v/0_11_0-alpha_6';
210
+ this.loaderModule = 'lwr/loaderLegacy/v/0_11_0-alpha_7';
211
211
 
212
212
  // Set up error handler
213
213
  this.errorHandler = this.config.onError;
@@ -327,7 +327,7 @@
327
327
  const exporter = (exports) => {
328
328
  Object.assign(exports, { logOperationStart, logOperationEnd });
329
329
  };
330
- globalLWR.define('lwr/profiler/v/0_11_0-alpha_6', ['exports'], exporter, {});
330
+ globalLWR.define('lwr/profiler/v/0_11_0-alpha_7', ['exports'], exporter, {});
331
331
  }
332
332
 
333
333
  // Set up the application globals, import map, root custom element...
@@ -398,8 +398,8 @@
398
398
  // The loader module is ALWAYS required
399
399
  const GLOBAL = globalThis ;
400
400
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
401
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_11_0-alpha_6') < 0) {
402
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_11_0-alpha_6');
401
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_11_0-alpha_7') < 0) {
402
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_11_0-alpha_7');
403
403
  }
404
404
  new LoaderShim(GLOBAL);
405
405
 
@@ -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.11.0-alpha.6 */
7
+ /* LWR Module Loader Shim v0.11.0-alpha.7 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -205,7 +205,7 @@
205
205
  // Parse configuration
206
206
  this.global = global;
207
207
  this.config = global.LWR ;
208
- this.loaderSpecifier = 'lwr/loader/v/0_11_0-alpha_6';
208
+ this.loaderSpecifier = 'lwr/loader/v/0_11_0-alpha_7';
209
209
 
210
210
  // Set up error handler
211
211
  this.errorHandler = this.config.onError;
@@ -325,7 +325,7 @@
325
325
  const exporter = (exports) => {
326
326
  Object.assign(exports, { logOperationStart, logOperationEnd });
327
327
  };
328
- globalLWR.define('lwr/profiler/v/0_11_0-alpha_6', ['exports'], exporter);
328
+ globalLWR.define('lwr/profiler/v/0_11_0-alpha_7', ['exports'], exporter);
329
329
  }
330
330
 
331
331
  // Set up the application globals, import map, root custom element...
@@ -397,15 +397,15 @@
397
397
  // The loader module is ALWAYS required
398
398
  const GLOBAL = globalThis ;
399
399
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
400
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_11_0-alpha_6') < 0) {
401
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_11_0-alpha_6');
400
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_11_0-alpha_7') < 0) {
401
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_11_0-alpha_7');
402
402
  }
403
403
  new LoaderShim(GLOBAL);
404
404
 
405
405
  })();
406
406
  //# sourceMappingURL=lwr-loader-shim.js.map
407
407
 
408
- LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'use strict';
408
+ LWR.define('lwr/loader/v/0_11_0-alpha_7', ['exports'], (function (exports) { 'use strict';
409
409
 
410
410
  const templateRegex = /\{([0-9]+)\}/g;
411
411
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -731,6 +731,7 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
731
731
  // Loader: modules
732
732
  const LOADER_PREFIX = 'lwr.loader.';
733
733
  const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
734
+ const MODULE_DYNAMIC_LOAD = `${LOADER_PREFIX}moduleRegistry.dynamicLoad`;
734
735
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
735
736
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
736
737
 
@@ -1091,7 +1092,7 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1091
1092
 
1092
1093
  async function evaluateLoadHookResponse(response, id) {
1093
1094
  return Promise.resolve().then(async () => {
1094
- if (!response.status) {
1095
+ if (!response || !response.status) {
1095
1096
  throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
1096
1097
  }
1097
1098
  if (response.status !== 200) {
@@ -1118,6 +1119,10 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1118
1119
  // TODO eval source maps for debugging
1119
1120
  eval(trusted.createScript(code));
1120
1121
  } catch (e) {
1122
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
1123
+ // eslint-disable-next-line lwr/no-unguarded-apis
1124
+ console.error(e);
1125
+ }
1121
1126
  throw new LoaderError(FAIL_LOAD, [id]);
1122
1127
  }
1123
1128
 
@@ -1198,7 +1203,6 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1198
1203
 
1199
1204
 
1200
1205
 
1201
-
1202
1206
 
1203
1207
 
1204
1208
  class ModuleRegistry {
@@ -1213,8 +1217,14 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1213
1217
  }
1214
1218
 
1215
1219
  async load(id, importer) {
1220
+ const metadata = importer ? { importer } : {};
1221
+ this.profiler.logOperationStart({
1222
+ id: MODULE_DYNAMIC_LOAD,
1223
+ specifier: id,
1224
+ metadata,
1225
+ });
1216
1226
  const resolvedId = await this.resolve(id, importer);
1217
- const moduleRecord = this.getModuleRecord(resolvedId, id);
1227
+ const moduleRecord = await this.getModuleRecord(resolvedId, id);
1218
1228
  if (moduleRecord.evaluated) {
1219
1229
  return moduleRecord.module;
1220
1230
  } else {
@@ -1288,6 +1298,8 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1288
1298
  // return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
1289
1299
  if (
1290
1300
  this.namedDefineRegistry.has(resolvedOrPlain) &&
1301
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1302
+ // @ts-ignore has check right above
1291
1303
  this.namedDefineRegistry.get(resolvedOrPlain).defined
1292
1304
  ) {
1293
1305
  const record = this.moduleRegistry.get(resolvedUrl);
@@ -1428,7 +1440,7 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1428
1440
  return moduleRecord;
1429
1441
  }
1430
1442
 
1431
- getModuleRecord(resolvedId, id) {
1443
+ async getModuleRecord(resolvedId, id) {
1432
1444
  // Look for an existing record
1433
1445
  const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1434
1446
  if (existingRecord) {
@@ -1439,7 +1451,7 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1439
1451
  // Create a new Module Record
1440
1452
  const instantiation = this.getModuleDef(resolvedId, id);
1441
1453
  const dependencyRecords = instantiation.then((moduleDef) => {
1442
- const dependencies = moduleDef.dependencies;
1454
+ const dependencies = moduleDef.dependencies || [];
1443
1455
  // get dep and filter out exports
1444
1456
  const filtered = dependencies
1445
1457
  .map((dep) => {
@@ -1465,7 +1477,9 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1465
1477
 
1466
1478
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1467
1479
  this.storeModuleAlias(id, resolvedId);
1468
- return newModuleRecord;
1480
+
1481
+ // Wait for the dependencies to resolve the return the moduleRecord
1482
+ return dependencyRecords.then(() => newModuleRecord);
1469
1483
  }
1470
1484
 
1471
1485
  storeModuleAlias(aliasId, resolvedId) {
@@ -1477,7 +1491,10 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1477
1491
  const currentResolvedId = this.aliases.get(aliasId);
1478
1492
  if (currentResolvedId !== resolvedId) {
1479
1493
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1480
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1494
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
1495
+ // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1496
+ console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1497
+ }
1481
1498
  }
1482
1499
  }
1483
1500
  }
@@ -1526,37 +1543,39 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1526
1543
  const { exporter, dependencies } = await moduleRecord.instantiation;
1527
1544
  // The exports object automatically gets filled in by the exporter evaluation
1528
1545
  const exports = {};
1529
- const depsMapped = await Promise.all(
1530
- dependencies.map(async (dep) => {
1531
- if (dep === 'exports') {
1532
- return exports;
1533
- }
1534
- const resolvedDepId = await this.resolve(dep);
1535
-
1536
- const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1537
- if (!moduleRecord) {
1538
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1539
- }
1540
-
1541
- const module = moduleRecord.module;
1542
-
1543
- /**
1544
- * Circular dependencies are handled properly when named exports are used,
1545
- * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1546
- *
1547
- * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1548
- */
1549
- if (!moduleRecord.evaluated) {
1550
- return this.getCircularDependencyWrapper(module);
1551
- }
1552
-
1553
- if (module) {
1554
- return module.__defaultInterop ? module.default : module;
1555
- }
1556
-
1557
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1558
- }),
1559
- );
1546
+ const depsMapped = dependencies
1547
+ ? await Promise.all(
1548
+ dependencies.map(async (dep) => {
1549
+ if (dep === 'exports') {
1550
+ return exports;
1551
+ }
1552
+ const resolvedDepId = await this.resolve(dep);
1553
+
1554
+ const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1555
+ if (!moduleRecord) {
1556
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1557
+ }
1558
+
1559
+ const module = moduleRecord.module;
1560
+
1561
+ /**
1562
+ * Circular dependencies are handled properly when named exports are used,
1563
+ * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1564
+ *
1565
+ * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1566
+ */
1567
+ if (!moduleRecord.evaluated) {
1568
+ return this.getCircularDependencyWrapper(module);
1569
+ }
1570
+
1571
+ if (module) {
1572
+ return module.__defaultInterop ? module.default : module;
1573
+ }
1574
+
1575
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1576
+ }),
1577
+ )
1578
+ : [];
1560
1579
 
1561
1580
  // W-10029836 - In the case where we could be instantiating multiple graphs at the same time lets make sure the module have not already been evaluated
1562
1581
  if (moduleRecord.evaluated) {
@@ -1718,7 +1737,12 @@ LWR.define('lwr/loader/v/0_11_0-alpha_6', ['exports'], (function (exports) { 'us
1718
1737
  return moduleDef;
1719
1738
  })
1720
1739
  .catch((e) => {
1721
- this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1740
+ // Create module error marks for all errors caused by the loader
1741
+ // Note: these marks do not include errors caused by invalid server responses or loader hooks
1742
+ if (!(e instanceof LoaderError)) {
1743
+ this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1744
+ }
1745
+
1722
1746
  throw e;
1723
1747
  });
1724
1748
  }