@lwrjs/loader 0.20.4 → 0.20.6

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.20.4 */
7
+ /* LWR Error Shim v0.20.6 */
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.20.4 */
7
+ /* LWR Legacy Module Loader Shim v0.20.6 */
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_20_4';
213
+ this.loaderModule = 'lwr/loaderLegacy/v/0_20_6';
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_20_4', ['exports'], exporter, {});
363
+ define('lwr/profiler/v/0_20_6', ['exports'], exporter, {});
364
364
  }
365
365
 
366
366
  // Set up the application globals, import map, root custom element...
@@ -430,7 +430,15 @@
430
430
  startWatchdogTimer() {
431
431
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
432
432
  return setTimeout(() => {
433
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
433
+ const requiredModulesMissing =
434
+ (this.config.requiredModules &&
435
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
436
+ [];
437
+ this.enterErrorState(
438
+ new Error(
439
+ `Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`,
440
+ ),
441
+ );
434
442
  }, REQUIRED_MODULES_TIMEOUT);
435
443
  }
436
444
 
@@ -447,14 +455,14 @@
447
455
  // The loader module is ALWAYS required
448
456
  const GLOBAL = globalThis ;
449
457
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
450
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_4') < 0) {
451
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_4');
458
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_6') < 0) {
459
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_6');
452
460
  }
453
461
  new LoaderShim(GLOBAL);
454
462
 
455
463
  })();
456
464
 
457
- LWR.define('lwr/loaderLegacy/v/0_20_4', ['exports'], (function (exports) { 'use strict';
465
+ LWR.define('lwr/loaderLegacy/v/0_20_6', ['exports'], (function (exports) { 'use strict';
458
466
 
459
467
  const templateRegex = /\{([0-9]+)\}/g;
460
468
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -871,7 +879,7 @@ LWR.define('lwr/loaderLegacy/v/0_20_4', ['exports'], (function (exports) { 'use
871
879
  // swallow
872
880
  }
873
881
  const trusted = createPolicy('trusted', policyOptions);
874
- /*! version: 0.25.3 */
882
+ /*! version: 0.26.2 */
875
883
 
876
884
  /* global console,process */
877
885
 
@@ -1021,8 +1029,85 @@ LWR.define('lwr/loaderLegacy/v/0_20_4', ['exports'], (function (exports) { 'use
1021
1029
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
1022
1030
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
1023
1031
 
1024
- /* global process console */
1032
+ 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; }/**
1033
+ * Result of checking whether to yield to the main thread
1034
+ */
1035
+
1036
+ // Track the time of last yield for scheduler batching
1037
+ let timeOfLastYield = 0;
1038
+
1039
+ /**
1040
+ * Yields control to the main thread if enough time has elapsed since the last yield.
1041
+ * This automatically tracks yield timing internally to break up long-running tasks
1042
+ * into batches, improving responsiveness without requiring manual state management.
1043
+ *
1044
+ * @returns Promise that resolves after yielding (if necessary) to the main thread
1045
+ */
1046
+ async function yieldIfNecessary() {
1047
+ const result = checkShouldYield(timeOfLastYield);
1048
+ if (result.shouldYield) {
1049
+ timeOfLastYield = result.timeOfLastYield;
1050
+ await yieldToMainThread();
1051
+ }
1052
+ }
1053
+
1054
+ /**
1055
+ * Checks if the current execution should yield to the main thread based on elapsed time.
1056
+ * Break up long-running tasks into timed batches to improve responsiveness.
1057
+ * Borrowed from https://tinyurl.com/5b4fw7eb
1058
+ *
1059
+ * @param timeOfLastYield - Timestamp of the last yield (from performance.now())
1060
+ * @returns Object containing whether to yield and the updated timestamp
1061
+ */
1062
+ function checkShouldYield(timeOfLastYield) {
1063
+ // eslint-disable-next-line lwr/no-unguarded-apis
1064
+ if (!globalThis.performance || !getSSREnabled()) {
1065
+ return {
1066
+ shouldYield: false,
1067
+ timeOfLastYield
1068
+ };
1069
+ }
1070
+ const TASK_BATCH_DURATION = 50;
1071
+ // eslint-disable-next-line lwr/no-unguarded-apis
1072
+ const now = globalThis.performance.now();
1073
+ if (now - timeOfLastYield > TASK_BATCH_DURATION) {
1074
+ return {
1075
+ shouldYield: true,
1076
+ timeOfLastYield: now
1077
+ };
1078
+ }
1079
+ return {
1080
+ shouldYield: false,
1081
+ timeOfLastYield
1082
+ };
1083
+ }
1084
+
1085
+ /**
1086
+ * Yields control to the main thread during long-running tasks to improve responsiveness.
1087
+ * Uses the scheduler.yield() API if available, otherwise falls back to setTimeout.
1088
+ *
1089
+ * @returns Promise that resolves after yielding to the main thread
1090
+ */
1091
+ async function yieldToMainThread() {
1092
+ const scheduler = globalThis.scheduler;
1093
+ // eslint-disable-next-line lwr/no-unguarded-apis
1094
+ return _optionalChain$1([scheduler, 'optionalAccess', _ => _.yield]) ? scheduler.yield() : new Promise(resolve => setTimeout(resolve, 0));
1095
+ }
1096
+
1097
+ /**
1098
+ * Gets the SSREnabled flag from the global LWR environment
1099
+ *
1100
+ * @returns Whether SSR is enabled
1101
+ */
1102
+ function getSSREnabled() {
1103
+ const globalThisLWR = globalThis;
1104
+ const {
1105
+ SSREnabled
1106
+ } = globalThisLWR.LWR && globalThisLWR.LWR.env || {};
1107
+ return !!SSREnabled;
1108
+ }
1025
1109
 
1110
+ /* global process console */
1026
1111
 
1027
1112
 
1028
1113
 
@@ -1469,6 +1554,8 @@ LWR.define('lwr/loaderLegacy/v/0_20_4', ['exports'], (function (exports) { 'use
1469
1554
  moduleRecord,
1470
1555
  evaluationMap,
1471
1556
  ) {
1557
+ await yieldIfNecessary();
1558
+
1472
1559
  const dependencyModuleRecords = await moduleRecord.dependencyRecords;
1473
1560
  if (dependencyModuleRecords.length > 0) {
1474
1561
  evaluationMap[moduleRecord.id] = true;
@@ -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.20.4 */
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_20_4",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_20_4",["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_20_4")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_20_4"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_20_4",["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}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const 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={}));
7
+ /* LWR Legacy Module Loader Shim v0.20.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 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_20_6",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_20_6",["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((()=>{const e=this.config.requiredModules&&this.config.requiredModules.filter((e=>!this.orderedDefs.includes(e)))||[];this.enterErrorState(new Error(`Failed to load required modules - timed out: ${e.join(", ")}`))}),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_20_6")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_20_6"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_20_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}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const 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,[`empty code for ${id}`]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[`"${id}": ${e instanceof Error?e.message:String(e)}`])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[`"${id}": window error ${lastWindowError instanceof Error?lastWindowError.message:String(lastWindowError)}`]);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 this.evaluateModule(e,{})}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})}));
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,[`empty code for ${id}`]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[`"${id}": ${e instanceof Error?e.message:String(e)}`])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[`"${id}": window error ${lastWindowError instanceof Error?lastWindowError.message:String(lastWindowError)}`]);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`;function _optionalChain$1(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}let timeOfLastYield=0;async function yieldIfNecessary(){const e=checkShouldYield(timeOfLastYield);e.shouldYield&&(timeOfLastYield=e.timeOfLastYield,await yieldToMainThread())}function checkShouldYield(e){if(!globalThis.performance||!getSSREnabled())return{shouldYield:!1,timeOfLastYield:e};const t=globalThis.performance.now();return t-e>50?{shouldYield:!0,timeOfLastYield:t}:{shouldYield:!1,timeOfLastYield:e}}async function yieldToMainThread(){const e=globalThis.scheduler;return _optionalChain$1([e,"optionalAccess",e=>e.yield])?e.yield():new Promise((e=>setTimeout(e,0)))}function getSSREnabled(){const e=globalThis,{SSREnabled:t}=e.LWR&&e.LWR.env||{};return!!t}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 this.evaluateModule(e,{})}async evaluateModule(e,t){await yieldIfNecessary();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.20.4 */
7
+ /* LWR Legacy Module Loader Shim v0.20.6 */
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_20_4';
213
+ this.loaderModule = 'lwr/loaderLegacy/v/0_20_6';
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_20_4', ['exports'], exporter, {});
363
+ define('lwr/profiler/v/0_20_6', ['exports'], exporter, {});
364
364
  }
365
365
 
366
366
  // Set up the application globals, import map, root custom element...
@@ -430,7 +430,15 @@
430
430
  startWatchdogTimer() {
431
431
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
432
432
  return setTimeout(() => {
433
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
433
+ const requiredModulesMissing =
434
+ (this.config.requiredModules &&
435
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
436
+ [];
437
+ this.enterErrorState(
438
+ new Error(
439
+ `Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`,
440
+ ),
441
+ );
434
442
  }, REQUIRED_MODULES_TIMEOUT);
435
443
  }
436
444
 
@@ -447,8 +455,8 @@
447
455
  // The loader module is ALWAYS required
448
456
  const GLOBAL = globalThis ;
449
457
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
450
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_4') < 0) {
451
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_4');
458
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_6') < 0) {
459
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_6');
452
460
  }
453
461
  new LoaderShim(GLOBAL);
454
462
 
@@ -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.20.4 */
7
+ /* LWR Module Loader Shim v0.20.6 */
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_20_4';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_20_6';
217
217
 
218
218
  // Set up error handler
219
219
  this.errorHandler = this.config.onError ;
@@ -365,7 +365,7 @@
365
365
  const exporter = (exports) => {
366
366
  Object.assign(exports, { logOperationStart, logOperationEnd });
367
367
  };
368
- define('lwr/profiler/v/0_20_4', ['exports'], exporter);
368
+ define('lwr/profiler/v/0_20_6', ['exports'], exporter);
369
369
  }
370
370
 
371
371
  // Set up the application globals, import map, root custom element...
@@ -440,7 +440,15 @@
440
440
  startWatchdogTimer() {
441
441
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
442
442
  return setTimeout(() => {
443
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
443
+ const requiredModulesMissing =
444
+ (this.config.requiredModules &&
445
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
446
+ [];
447
+ this.enterErrorState(
448
+ new Error(
449
+ `Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`,
450
+ ),
451
+ );
444
452
  }, REQUIRED_MODULES_TIMEOUT);
445
453
  }
446
454
 
@@ -457,14 +465,14 @@
457
465
  // The loader module is ALWAYS required
458
466
  const GLOBAL = globalThis ;
459
467
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
460
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_4') < 0) {
461
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_4');
468
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_6') < 0) {
469
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_6');
462
470
  }
463
471
  new LoaderShim(GLOBAL);
464
472
 
465
473
  })();
466
474
 
467
- LWR.define('lwr/loader/v/0_20_4', ['exports'], (function (exports) { 'use strict';
475
+ LWR.define('lwr/loader/v/0_20_6', ['exports'], (function (exports) { 'use strict';
468
476
 
469
477
  const templateRegex = /\{([0-9]+)\}/g;
470
478
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1199,7 +1207,7 @@ LWR.define('lwr/loader/v/0_20_4', ['exports'], (function (exports) { 'use strict
1199
1207
  // swallow
1200
1208
  }
1201
1209
  const trusted = createPolicy('trusted', policyOptions);
1202
- /*! version: 0.25.3 */
1210
+ /*! version: 0.26.2 */
1203
1211
 
1204
1212
  /* global console,process */
1205
1213
 
@@ -4,8 +4,8 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Module Loader Shim v0.20.4 */
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 s(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=s(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:s,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:s,metadata:d,specifierIndex:l});else if(i){const e=n(r,s,l),t=a(s,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=n(r,l,d),t=s(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:s,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")}(s,n),n){n({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const p="function"==typeof setTimeout,u="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),p&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_20_4",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,flags:this.config.flags,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:s}=i;if(!s)throw new Error("Expected Loader class to be defined");const n=new s(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})})),n}(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_20_4",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:s,imports:n,index:a}=this.config,l=n||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:s,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):u&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_20_4")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_20_4"),new h(f)}(),LWR.define("lwr/loader/v/0_20_4",["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}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const 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,s=[];let n=-1;for(let e=0;e<i.length;e++)-1!==n?"/"===i[e]&&(s.push(i.slice(n,e+1)),n=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:n=e:(s.pop(),e+=2):n=e;return-1!==n&&s.push(i.slice(n)),t.slice(0,t.length-o.length)+s.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`;function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const i=e[o],s=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==r)return;"access"===i||"optionalAccess"===i?(t=r,r=s(r)):"call"!==i&&"optionalCall"!==i||(r=s(((...e)=>r.call(t,...e))),t=void 0)}return r}class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}__init4(){this.batchSpecifiers=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),ImportMetadataResolver.prototype.__init4.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],s=this.importURICache.get(e);if(s){const t=i||o,r=s.identity||s.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],s=await i(e,{knownModules:r});if(s||void 0===s)return s}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if(!hasSetTimeout||!_optionalChain([this,"access",e=>e.config,"optionalAccess",e=>e.flags,"optionalAccess",e=>e.batchMappings]))return this.fetchNewMappingsInner(e);const t=()=>{const e=this.batchSpecifiers.join(",");return this.batchSpecifiers=[],clearTimeout(this.batchTimer),this.batchTimer=void 0,this.fetchNewMappingsInner(e)};return this.batchPromise&&0!==this.batchSpecifiers.length||(this.batchPromise=new Promise((e=>{this.batchTimer=setTimeout((()=>e(t())),0)}))),this.batchSpecifiers.push(e),this.batchPromise}async fetchNewMappingsInner(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 s=e[t];try{if(null!==s({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.20.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,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function s(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=s(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:s,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:s,metadata:d,specifierIndex:l});else if(i){const e=n(r,s,l),t=a(s,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=n(r,l,d),t=s(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:s,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")}(s,n),n){n({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const p="function"==typeof setTimeout,u="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),p&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_20_6",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,flags:this.config.flags,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:s}=i;if(!s)throw new Error("Expected Loader class to be defined");const n=new s(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})})),n}(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_20_6",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:s,imports:n,index:a}=this.config,l=n||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:s,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):u&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{const e=this.config.requiredModules&&this.config.requiredModules.filter((e=>!this.orderedDefs.includes(e)))||[];this.enterErrorState(new Error(`Failed to load required modules - timed out: ${e.join(", ")}`))}),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_20_6")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_20_6"),new h(f)}(),LWR.define("lwr/loader/v/0_20_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}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const 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,s=[];let n=-1;for(let e=0;e<i.length;e++)-1!==n?"/"===i[e]&&(s.push(i.slice(n,e+1)),n=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:n=e:(s.pop(),e+=2):n=e;return-1!==n&&s.push(i.slice(n)),t.slice(0,t.length-o.length)+s.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`;function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const i=e[o],s=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==r)return;"access"===i||"optionalAccess"===i?(t=r,r=s(r)):"call"!==i&&"optionalCall"!==i||(r=s(((...e)=>r.call(t,...e))),t=void 0)}return r}class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}__init4(){this.batchSpecifiers=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),ImportMetadataResolver.prototype.__init4.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],s=this.importURICache.get(e);if(s){const t=i||o,r=s.identity||s.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],s=await i(e,{knownModules:r});if(s||void 0===s)return s}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if(!hasSetTimeout||!_optionalChain([this,"access",e=>e.config,"optionalAccess",e=>e.flags,"optionalAccess",e=>e.batchMappings]))return this.fetchNewMappingsInner(e);const t=()=>{const e=this.batchSpecifiers.join(",");return this.batchSpecifiers=[],clearTimeout(this.batchTimer),this.batchTimer=void 0,this.fetchNewMappingsInner(e)};return this.batchPromise&&0!==this.batchSpecifiers.length||(this.batchPromise=new Promise((e=>{this.batchTimer=setTimeout((()=>e(t())),0)}))),this.batchSpecifiers.push(e),this.batchPromise}async fetchNewMappingsInner(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 s=e[t];try{if(null!==s({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
9
9
  /*!
10
10
  * Copyright (C) 2023 salesforce.com, inc.
11
11
  */
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Module Loader Shim v0.20.4 */
7
+ /* LWR Module Loader Shim v0.20.6 */
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_20_4';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_20_6';
217
217
 
218
218
  // Set up error handler
219
219
  this.errorHandler = this.config.onError ;
@@ -365,7 +365,7 @@
365
365
  const exporter = (exports) => {
366
366
  Object.assign(exports, { logOperationStart, logOperationEnd });
367
367
  };
368
- define('lwr/profiler/v/0_20_4', ['exports'], exporter);
368
+ define('lwr/profiler/v/0_20_6', ['exports'], exporter);
369
369
  }
370
370
 
371
371
  // Set up the application globals, import map, root custom element...
@@ -440,7 +440,15 @@
440
440
  startWatchdogTimer() {
441
441
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
442
442
  return setTimeout(() => {
443
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
443
+ const requiredModulesMissing =
444
+ (this.config.requiredModules &&
445
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
446
+ [];
447
+ this.enterErrorState(
448
+ new Error(
449
+ `Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`,
450
+ ),
451
+ );
444
452
  }, REQUIRED_MODULES_TIMEOUT);
445
453
  }
446
454
 
@@ -457,8 +465,8 @@
457
465
  // The loader module is ALWAYS required
458
466
  const GLOBAL = globalThis ;
459
467
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
460
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_4') < 0) {
461
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_4');
468
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_6') < 0) {
469
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_6');
462
470
  }
463
471
  new LoaderShim(GLOBAL);
464
472
 
@@ -34,6 +34,7 @@ var import_resolveAndLoadHook = __toModule(require("../hooks/resolveAndLoadHook.
34
34
  var import_moduleInvalidation = __toModule(require("../hooks/moduleInvalidation.cjs"));
35
35
  var import_constants = __toModule(require("../constants/constants.cjs"));
36
36
  var import_metrics = __toModule(require("lwr/metrics"));
37
+ var import_scheduler = __toModule(require("lwr/scheduler"));
37
38
  var ModuleRegistry = class {
38
39
  constructor(config) {
39
40
  this.isAppMounted = false;
@@ -321,6 +322,7 @@ var ModuleRegistry = class {
321
322
  return this.evaluateModule(moduleRecord, {});
322
323
  }
323
324
  async evaluateModule(moduleRecord, evaluationMap) {
325
+ await (0, import_scheduler.yieldIfNecessary)();
324
326
  const dependencyModuleRecords = await moduleRecord.dependencyRecords;
325
327
  if (dependencyModuleRecords.length > 0) {
326
328
  evaluationMap[moduleRecord.id] = true;
@@ -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.20.4 */
7
+ /* LWR ESM Module Loader v0.20.6 */
8
8
  function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
9
9
 
10
10
 
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Module Loader v0.20.4 */
7
+ /* LWR Module Loader v0.20.6 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -738,7 +738,7 @@ try {
738
738
  // swallow
739
739
  }
740
740
  const trusted = createPolicy('trusted', policyOptions);
741
- /*! version: 0.25.3 */
741
+ /*! version: 0.26.2 */
742
742
 
743
743
  /* global console,process */
744
744
 
@@ -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.20.4 */
7
+ /* LWR Legacy Module Loader v0.20.6 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -420,7 +420,7 @@ try {
420
420
  // swallow
421
421
  }
422
422
  const trusted = createPolicy('trusted', policyOptions);
423
- /*! version: 0.25.3 */
423
+ /*! version: 0.26.2 */
424
424
 
425
425
  /* global console,process */
426
426
 
@@ -570,8 +570,85 @@ const MODULE_DYNAMIC_LOAD = `${LOADER_PREFIX}module.dynamicLoad`;
570
570
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
571
571
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
572
572
 
573
- /* global process console */
573
+ 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; }/**
574
+ * Result of checking whether to yield to the main thread
575
+ */
576
+
577
+ // Track the time of last yield for scheduler batching
578
+ let timeOfLastYield = 0;
579
+
580
+ /**
581
+ * Yields control to the main thread if enough time has elapsed since the last yield.
582
+ * This automatically tracks yield timing internally to break up long-running tasks
583
+ * into batches, improving responsiveness without requiring manual state management.
584
+ *
585
+ * @returns Promise that resolves after yielding (if necessary) to the main thread
586
+ */
587
+ async function yieldIfNecessary() {
588
+ const result = checkShouldYield(timeOfLastYield);
589
+ if (result.shouldYield) {
590
+ timeOfLastYield = result.timeOfLastYield;
591
+ await yieldToMainThread();
592
+ }
593
+ }
594
+
595
+ /**
596
+ * Checks if the current execution should yield to the main thread based on elapsed time.
597
+ * Break up long-running tasks into timed batches to improve responsiveness.
598
+ * Borrowed from https://tinyurl.com/5b4fw7eb
599
+ *
600
+ * @param timeOfLastYield - Timestamp of the last yield (from performance.now())
601
+ * @returns Object containing whether to yield and the updated timestamp
602
+ */
603
+ function checkShouldYield(timeOfLastYield) {
604
+ // eslint-disable-next-line lwr/no-unguarded-apis
605
+ if (!globalThis.performance || !getSSREnabled()) {
606
+ return {
607
+ shouldYield: false,
608
+ timeOfLastYield
609
+ };
610
+ }
611
+ const TASK_BATCH_DURATION = 50;
612
+ // eslint-disable-next-line lwr/no-unguarded-apis
613
+ const now = globalThis.performance.now();
614
+ if (now - timeOfLastYield > TASK_BATCH_DURATION) {
615
+ return {
616
+ shouldYield: true,
617
+ timeOfLastYield: now
618
+ };
619
+ }
620
+ return {
621
+ shouldYield: false,
622
+ timeOfLastYield
623
+ };
624
+ }
574
625
 
626
+ /**
627
+ * Yields control to the main thread during long-running tasks to improve responsiveness.
628
+ * Uses the scheduler.yield() API if available, otherwise falls back to setTimeout.
629
+ *
630
+ * @returns Promise that resolves after yielding to the main thread
631
+ */
632
+ async function yieldToMainThread() {
633
+ const scheduler = globalThis.scheduler;
634
+ // eslint-disable-next-line lwr/no-unguarded-apis
635
+ return _optionalChain$1([scheduler, 'optionalAccess', _ => _.yield]) ? scheduler.yield() : new Promise(resolve => setTimeout(resolve, 0));
636
+ }
637
+
638
+ /**
639
+ * Gets the SSREnabled flag from the global LWR environment
640
+ *
641
+ * @returns Whether SSR is enabled
642
+ */
643
+ function getSSREnabled() {
644
+ const globalThisLWR = globalThis;
645
+ const {
646
+ SSREnabled
647
+ } = globalThisLWR.LWR && globalThisLWR.LWR.env || {};
648
+ return !!SSREnabled;
649
+ }
650
+
651
+ /* global process console */
575
652
 
576
653
 
577
654
 
@@ -1019,6 +1096,8 @@ class ModuleRegistry {
1019
1096
  moduleRecord,
1020
1097
  evaluationMap,
1021
1098
  ) {
1099
+ await yieldIfNecessary();
1100
+
1022
1101
  const dependencyModuleRecords = await moduleRecord.dependencyRecords;
1023
1102
  if (dependencyModuleRecords.length > 0) {
1024
1103
  evaluationMap[moduleRecord.id] = true;
@@ -7,6 +7,7 @@ import { evaluateLoadHookResponse, evaluateLoadHook, isResponseAPromise, } from
7
7
  import { evaluateHandleStaleModuleHooks } from '../hooks/moduleInvalidation.js';
8
8
  import { MODULE_LOAD_TIMEOUT_TIMER, MODULE_WARNING } from '../constants/constants.js';
9
9
  import { MODULE_DEFINE, MODULE_ERROR, MODULE_FETCH, MODULE_DYNAMIC_LOAD } from 'lwr/metrics';
10
+ import { yieldIfNecessary } from 'lwr/scheduler';
10
11
  export class ModuleRegistry {
11
12
  constructor(config) {
12
13
  this.isAppMounted = false;
@@ -352,6 +353,7 @@ export class ModuleRegistry {
352
353
  return this.evaluateModule(moduleRecord, {});
353
354
  }
354
355
  async evaluateModule(moduleRecord, evaluationMap) {
356
+ await yieldIfNecessary();
355
357
  const dependencyModuleRecords = await moduleRecord.dependencyRecords;
356
358
  if (dependencyModuleRecords.length > 0) {
357
359
  evaluationMap[moduleRecord.id] = true;
@@ -217,7 +217,10 @@ export default class LoaderShim {
217
217
  startWatchdogTimer() {
218
218
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
219
219
  return setTimeout(() => {
220
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
220
+ const requiredModulesMissing = (this.config.requiredModules &&
221
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
222
+ [];
223
+ this.enterErrorState(new Error(`Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`));
221
224
  }, REQUIRED_MODULES_TIMEOUT);
222
225
  }
223
226
  logWarnings(warnings) {
@@ -210,7 +210,10 @@ export default class LoaderShim {
210
210
  startWatchdogTimer() {
211
211
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
212
212
  return setTimeout(() => {
213
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
213
+ const requiredModulesMissing = (this.config.requiredModules &&
214
+ this.config.requiredModules.filter((element) => !this.orderedDefs.includes(element))) ||
215
+ [];
216
+ this.enterErrorState(new Error(`Failed to load required modules - timed out: ${requiredModulesMissing.join(', ')}`));
214
217
  }, REQUIRED_MODULES_TIMEOUT);
215
218
  }
216
219
  logWarnings(warnings) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.20.4",
8
+ "version": "0.20.6",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -60,17 +60,17 @@
60
60
  "build": "yarn build:ts && yarn build:error-shim && yarn build:shim && yarn build:loader && yarn build:shim:bundle && yarn build:shim:bundle:minify"
61
61
  },
62
62
  "devDependencies": {
63
- "@locker/trusted-types": "0.25.3",
64
- "@lwrjs/diagnostics": "0.20.4",
65
- "@lwrjs/types": "0.20.4",
63
+ "@locker/trusted-types": "0.26.2",
64
+ "@lwrjs/diagnostics": "0.20.6",
65
+ "@lwrjs/types": "0.20.6",
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.20.4",
73
- "@lwrjs/shared-utils": "0.20.4"
72
+ "@lwrjs/client-modules": "0.20.6",
73
+ "@lwrjs/shared-utils": "0.20.6"
74
74
  },
75
75
  "lwc": {
76
76
  "modules": [
@@ -90,5 +90,5 @@
90
90
  "volta": {
91
91
  "extends": "../../../package.json"
92
92
  },
93
- "gitHead": "fe39a477036f96478a75c549439d06bcbee085cc"
93
+ "gitHead": "754d28a0d270ca347d1eb769b34bd62bc1e85119"
94
94
  }