@lwrjs/loader 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +6 -6
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +2 -2
- package/build/assets/prod/lwr-loader-shim-legacy.js +5 -5
- package/build/assets/prod/lwr-loader-shim.bundle.js +56 -8
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +6 -5
- package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +21 -0
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +50 -3
- package/build/modules/lwr/loader/moduleRegistry/importMetadataResolver.d.ts +4 -0
- package/build/modules/lwr/loader/moduleRegistry/importMetadataResolver.js +24 -0
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +1 -1
- package/build/shim/shim.js +1 -0
- package/build/types.d.ts +3 -0
- package/package.json +6 -6
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Error Shim v0.20.
|
|
7
|
+
/* LWR Error Shim v0.20.1 */
|
|
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.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.20.1 */
|
|
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/
|
|
213
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_20_1';
|
|
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/
|
|
363
|
+
define('lwr/profiler/v/0_20_1', ['exports'], exporter, {});
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
// Set up the application globals, import map, root custom element...
|
|
@@ -447,14 +447,14 @@
|
|
|
447
447
|
// The loader module is ALWAYS required
|
|
448
448
|
const GLOBAL = globalThis ;
|
|
449
449
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
450
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
451
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
450
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_1') < 0) {
|
|
451
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_1');
|
|
452
452
|
}
|
|
453
453
|
new LoaderShim(GLOBAL);
|
|
454
454
|
|
|
455
455
|
})();
|
|
456
456
|
|
|
457
|
-
LWR.define('lwr/loaderLegacy/v/
|
|
457
|
+
LWR.define('lwr/loaderLegacy/v/0_20_1', ['exports'], (function (exports) { 'use strict';
|
|
458
458
|
|
|
459
459
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
460
460
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -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 Legacy Module Loader Shim v0.20.
|
|
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/
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.20.1 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function i(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=i(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:i,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:i,metadata:d,specifierIndex:l});else if(s){const e=n(r,i,l),t=a(i,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(s){const e=n(r,l,d),t=i(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:i,customInit:n}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(i,n),n){n({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_20_1",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:i}=s;if(!i)throw new Error("Expected Loader class to be defined");const n=new i(r);return o&&o.length&&n.registerExternalModules(o),n.define(e,["exports"],(e=>{Object.assign(e,{define:n.define.bind(n),load:n.load.bind(n),services:n.services,clearRegistry:n.clearRegistry.bind(n)})}),t[3]),n}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_20_1",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:i,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:i||{},importMappings:o,endpoints:n,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{initDeferDOM:a}=this.config;e.registerImportMappings(o).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():a?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_20_1")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_20_1"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_20_1",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"});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
|
*/
|
|
@@ -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.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.20.1 */
|
|
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/
|
|
213
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_20_1';
|
|
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/
|
|
363
|
+
define('lwr/profiler/v/0_20_1', ['exports'], exporter, {});
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
// Set up the application globals, import map, root custom element...
|
|
@@ -447,8 +447,8 @@
|
|
|
447
447
|
// The loader module is ALWAYS required
|
|
448
448
|
const GLOBAL = globalThis ;
|
|
449
449
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
450
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
451
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
450
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_20_1') < 0) {
|
|
451
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_20_1');
|
|
452
452
|
}
|
|
453
453
|
new LoaderShim(GLOBAL);
|
|
454
454
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.20.
|
|
7
|
+
/* LWR Module Loader Shim v0.20.1 */
|
|
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/
|
|
216
|
+
this.loaderSpecifier = 'lwr/loader/v/0_20_1';
|
|
217
217
|
|
|
218
218
|
// Set up error handler
|
|
219
219
|
this.errorHandler = this.config.onError ;
|
|
@@ -295,6 +295,7 @@
|
|
|
295
295
|
const loaderConfig = {
|
|
296
296
|
endpoints: this.config.endpoints,
|
|
297
297
|
baseUrl: this.config.baseUrl,
|
|
298
|
+
flags: this.config.flags,
|
|
298
299
|
profiler: { logOperationStart, logOperationEnd },
|
|
299
300
|
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
300
301
|
appMetadata: {
|
|
@@ -364,7 +365,7 @@
|
|
|
364
365
|
const exporter = (exports) => {
|
|
365
366
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
366
367
|
};
|
|
367
|
-
define('lwr/profiler/v/
|
|
368
|
+
define('lwr/profiler/v/0_20_1', ['exports'], exporter);
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
// Set up the application globals, import map, root custom element...
|
|
@@ -456,14 +457,14 @@
|
|
|
456
457
|
// The loader module is ALWAYS required
|
|
457
458
|
const GLOBAL = globalThis ;
|
|
458
459
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
459
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
460
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
460
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_1') < 0) {
|
|
461
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_1');
|
|
461
462
|
}
|
|
462
463
|
new LoaderShim(GLOBAL);
|
|
463
464
|
|
|
464
465
|
})();
|
|
465
466
|
|
|
466
|
-
LWR.define('lwr/loader/v/
|
|
467
|
+
LWR.define('lwr/loader/v/0_20_1', ['exports'], (function (exports) { 'use strict';
|
|
467
468
|
|
|
468
469
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
469
470
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -826,6 +827,16 @@ LWR.define('lwr/loader/v/0_20_0', ['exports'], (function (exports) { 'use strict
|
|
|
826
827
|
const MAPPINGS_FETCH = `${LOADER_PREFIX}mappings.fetch`;
|
|
827
828
|
const MAPPINGS_ERROR = `${LOADER_PREFIX}mappings.error`;
|
|
828
829
|
|
|
830
|
+
function _optionalChain(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; }
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
829
840
|
/* spec based import map resolver */
|
|
830
841
|
class ImportMetadataResolver {
|
|
831
842
|
// Default to empty mappings
|
|
@@ -835,7 +846,13 @@ LWR.define('lwr/loader/v/0_20_0', ['exports'], (function (exports) { 'use strict
|
|
|
835
846
|
|
|
836
847
|
__init3() {this.loadMappingHooks = [];}
|
|
837
848
|
|
|
838
|
-
|
|
849
|
+
// mapping request batching
|
|
850
|
+
__init4() {this.batchSpecifiers = [];}
|
|
851
|
+
|
|
852
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
constructor(config, invalidationCallback) {ImportMetadataResolver.prototype.__init.call(this);ImportMetadataResolver.prototype.__init2.call(this);ImportMetadataResolver.prototype.__init3.call(this);ImportMetadataResolver.prototype.__init4.call(this);
|
|
839
856
|
this.config = config;
|
|
840
857
|
this.invalidationCallback = invalidationCallback;
|
|
841
858
|
}
|
|
@@ -1008,6 +1025,30 @@ LWR.define('lwr/loader/v/0_20_0', ['exports'], (function (exports) { 'use strict
|
|
|
1008
1025
|
}
|
|
1009
1026
|
|
|
1010
1027
|
async fetchNewMappings(specifier) {
|
|
1028
|
+
if (!hasSetTimeout || !_optionalChain([this, 'access', _ => _.config, 'optionalAccess', _2 => _2.flags, 'optionalAccess', _3 => _3.batchMappings])) {
|
|
1029
|
+
return this.fetchNewMappingsInner(specifier);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const batch = () => {
|
|
1033
|
+
const specifiers = this.batchSpecifiers.join(',');
|
|
1034
|
+
this.batchSpecifiers = []; // clear pending mapping requests
|
|
1035
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
1036
|
+
clearTimeout(this.batchTimer); // cancel the batch timer
|
|
1037
|
+
this.batchTimer = undefined;
|
|
1038
|
+
return this.fetchNewMappingsInner(specifiers);
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
if (!this.batchPromise || this.batchSpecifiers.length === 0) {
|
|
1042
|
+
this.batchPromise = new Promise((resolve) => {
|
|
1043
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
1044
|
+
this.batchTimer = setTimeout(() => resolve(batch()), 0);
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
this.batchSpecifiers.push(specifier);
|
|
1048
|
+
return this.batchPromise;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
async fetchNewMappingsInner(specifier) {
|
|
1011
1052
|
if (typeof globalThis.fetch !== 'function') {
|
|
1012
1053
|
throw new LoaderError(UNRESOLVED, [specifier]);
|
|
1013
1054
|
}
|
|
@@ -2070,7 +2111,14 @@ LWR.define('lwr/loader/v/0_20_0', ['exports'], (function (exports) { 'use strict
|
|
|
2070
2111
|
};
|
|
2071
2112
|
}
|
|
2072
2113
|
|
|
2073
|
-
this.registry = new ModuleRegistry(
|
|
2114
|
+
this.registry = new ModuleRegistry(
|
|
2115
|
+
Object.freeze({
|
|
2116
|
+
endpoints: config.endpoints,
|
|
2117
|
+
baseUrl,
|
|
2118
|
+
profiler,
|
|
2119
|
+
flags: config.flags || {},
|
|
2120
|
+
}),
|
|
2121
|
+
);
|
|
2074
2122
|
|
|
2075
2123
|
// TODO: W-10539691 - temp workaround for LWR-Java -- remove once appId is implemented there
|
|
2076
2124
|
if (config.appMetadata && !config.appMetadata.appId) {
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.20.
|
|
8
|
-
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const 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_0",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,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:n}=i;if(!n)throw new Error("Expected Loader class to be defined");const s=new n(r);return o&&o.length&&s.registerExternalModules(o),s.define(e,["exports"],(e=>{Object.assign(e,{define:s.define.bind(s),load:s.load.bind(s),services:s.services})})),s}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_20_0",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{initDeferDOM:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():d?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):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_0")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_20_0"),new h(f)}(),LWR.define("lwr/loader/v/0_20_0",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"});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,n=[];let s=-1;for(let e=0;e<i.length;e++)-1!==s?"/"===i[e]&&(n.push(i.slice(s,e+1)),s=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:s=e:(n.pop(),e+=2):s=e;return-1!==s&&n.push(i.slice(s)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e))})).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
7
|
+
/* LWR Module Loader Shim v0.20.1 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function 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_1",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(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_1",["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_1")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_20_1"),new h(f)}(),LWR.define("lwr/loader/v/0_20_1",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"});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
|
*/
|
|
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 i=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,i=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(i,{parentUrl:r});let s;if((t||null===t)&&(s=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(s))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==s){if("string"==typeof s){if(resolveIfNotPlainOrUrl(s,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);i=s;continue}if(o=s&&s.url&&(resolveIfNotPlainOrUrl(s.url,r)||s.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(i)||!this.aliases.has(t))return t}}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getImportMetadataResolver(){return this.resolver}async getModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)if(isUrl(e)){const o=await r.instantiation,i=await this.resolve(t);if(isUrl(i)||o.name===i)return this.storeModuleAlias(t,i),r;{e=i;const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,i),r}}else if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}const o=this.getModuleDef(e,t),i=o.then((e=>{const t=(e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,originalId:t,module:Object.create(null),dependencyRecords:i,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),e!==t&&this.storeModuleAlias(t,e),i.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,t=await this.resolve(e))}return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:i}=await e.instantiation,n={},s=i?await Promise.all(i.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...s)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const i=this.resolver.getBaseUrl(),n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,i),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o&&evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=r}this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}async load(e,t){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if("lwr/loader"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LOADER,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
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 i=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,i=e;const s=this.resolveHook;if(s){for(let e=0;e<s.length;e++){const t=(0,s[e])(i,{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);i=n;continue}if(o=n&&n.url&&(resolveIfNotPlainOrUrl(n.url,r)||n.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(i)||!this.aliases.has(t))return t}}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getImportMetadataResolver(){return this.resolver}async getModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)if(isUrl(e)){const o=await r.instantiation,i=await this.resolve(t);if(isUrl(i)||o.name===i)return this.storeModuleAlias(t,i),r;{e=i;const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,i),r}}else if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}const o=this.getModuleDef(e,t),i=o.then((e=>{const t=(e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),s={id:e,originalId:t,module:Object.create(null),dependencyRecords:i,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,s),e!==t&&this.storeModuleAlias(t,e),i.then((()=>s))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,t=await this.resolve(e))}return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:i}=await e.instantiation,s={},n=i?await Promise.all(i.map((async e=>{if("exports"===e)return s;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(s)&&Object.defineProperty(s,"__useDefault",{value:!0});const l=a||s;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const i=this.resolver.getBaseUrl(),s=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:s}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,i),s=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===s)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(s&&null!==s)return evaluateLoadHookResponse(s,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:s}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:s}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o&&evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o,flags:e.flags||{}})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=r}this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}async load(e,t){if("lwc"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LWC,[t]);if("lwr/loader"===e&&void 0!==t)throw new LoaderError(NO_IMPORT_LOADER,[t]);if(e.startsWith("blob:"))throw new LoaderError(NO_BLOB_IMPORT);return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.20.
|
|
7
|
+
/* LWR Module Loader Shim v0.20.1 */
|
|
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/
|
|
216
|
+
this.loaderSpecifier = 'lwr/loader/v/0_20_1';
|
|
217
217
|
|
|
218
218
|
// Set up error handler
|
|
219
219
|
this.errorHandler = this.config.onError ;
|
|
@@ -295,6 +295,7 @@
|
|
|
295
295
|
const loaderConfig = {
|
|
296
296
|
endpoints: this.config.endpoints,
|
|
297
297
|
baseUrl: this.config.baseUrl,
|
|
298
|
+
flags: this.config.flags,
|
|
298
299
|
profiler: { logOperationStart, logOperationEnd },
|
|
299
300
|
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
300
301
|
appMetadata: {
|
|
@@ -364,7 +365,7 @@
|
|
|
364
365
|
const exporter = (exports) => {
|
|
365
366
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
366
367
|
};
|
|
367
|
-
define('lwr/profiler/v/
|
|
368
|
+
define('lwr/profiler/v/0_20_1', ['exports'], exporter);
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
// Set up the application globals, import map, root custom element...
|
|
@@ -456,8 +457,8 @@
|
|
|
456
457
|
// The loader module is ALWAYS required
|
|
457
458
|
const GLOBAL = globalThis ;
|
|
458
459
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
459
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
460
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
460
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_20_1') < 0) {
|
|
461
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_20_1');
|
|
461
462
|
}
|
|
462
463
|
new LoaderShim(GLOBAL);
|
|
463
464
|
|
|
@@ -29,11 +29,13 @@ __export(exports, {
|
|
|
29
29
|
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
30
|
var import_url = __toModule(require("../utils/url.cjs"));
|
|
31
31
|
var import_metrics = __toModule(require("lwr/metrics"));
|
|
32
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
32
33
|
var ImportMetadataResolver = class {
|
|
33
34
|
constructor(config, invalidationCallback) {
|
|
34
35
|
this.importURICache = new Map();
|
|
35
36
|
this.pendingURICache = new Map();
|
|
36
37
|
this.loadMappingHooks = [];
|
|
38
|
+
this.batchSpecifiers = [];
|
|
37
39
|
this.config = config;
|
|
38
40
|
this.invalidationCallback = invalidationCallback;
|
|
39
41
|
}
|
|
@@ -157,6 +159,25 @@ var ImportMetadataResolver = class {
|
|
|
157
159
|
return this.fetchNewMappings(specifier);
|
|
158
160
|
}
|
|
159
161
|
async fetchNewMappings(specifier) {
|
|
162
|
+
if (!import_dom.hasSetTimeout || !this.config?.flags?.batchMappings) {
|
|
163
|
+
return this.fetchNewMappingsInner(specifier);
|
|
164
|
+
}
|
|
165
|
+
const batch = () => {
|
|
166
|
+
const specifiers = this.batchSpecifiers.join(",");
|
|
167
|
+
this.batchSpecifiers = [];
|
|
168
|
+
clearTimeout(this.batchTimer);
|
|
169
|
+
this.batchTimer = void 0;
|
|
170
|
+
return this.fetchNewMappingsInner(specifiers);
|
|
171
|
+
};
|
|
172
|
+
if (!this.batchPromise || this.batchSpecifiers.length === 0) {
|
|
173
|
+
this.batchPromise = new Promise((resolve) => {
|
|
174
|
+
this.batchTimer = setTimeout(() => resolve(batch()), 0);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
this.batchSpecifiers.push(specifier);
|
|
178
|
+
return this.batchPromise;
|
|
179
|
+
}
|
|
180
|
+
async fetchNewMappingsInner(specifier) {
|
|
160
181
|
if (typeof globalThis.fetch !== "function") {
|
|
161
182
|
throw new import_messages.LoaderError(import_messages.UNRESOLVED, [specifier]);
|
|
162
183
|
}
|
|
@@ -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.
|
|
7
|
+
/* LWR ESM Module Loader v0.20.1 */
|
|
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.
|
|
7
|
+
/* LWR Module Loader v0.20.1 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
|
@@ -366,6 +366,16 @@ const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
|
|
|
366
366
|
const MAPPINGS_FETCH = `${LOADER_PREFIX}mappings.fetch`;
|
|
367
367
|
const MAPPINGS_ERROR = `${LOADER_PREFIX}mappings.error`;
|
|
368
368
|
|
|
369
|
+
function _optionalChain(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; }
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
369
379
|
/* spec based import map resolver */
|
|
370
380
|
class ImportMetadataResolver {
|
|
371
381
|
// Default to empty mappings
|
|
@@ -375,7 +385,13 @@ class ImportMetadataResolver {
|
|
|
375
385
|
|
|
376
386
|
__init3() {this.loadMappingHooks = [];}
|
|
377
387
|
|
|
378
|
-
|
|
388
|
+
// mapping request batching
|
|
389
|
+
__init4() {this.batchSpecifiers = [];}
|
|
390
|
+
|
|
391
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
constructor(config, invalidationCallback) {ImportMetadataResolver.prototype.__init.call(this);ImportMetadataResolver.prototype.__init2.call(this);ImportMetadataResolver.prototype.__init3.call(this);ImportMetadataResolver.prototype.__init4.call(this);
|
|
379
395
|
this.config = config;
|
|
380
396
|
this.invalidationCallback = invalidationCallback;
|
|
381
397
|
}
|
|
@@ -548,6 +564,30 @@ class ImportMetadataResolver {
|
|
|
548
564
|
}
|
|
549
565
|
|
|
550
566
|
async fetchNewMappings(specifier) {
|
|
567
|
+
if (!hasSetTimeout || !_optionalChain([this, 'access', _ => _.config, 'optionalAccess', _2 => _2.flags, 'optionalAccess', _3 => _3.batchMappings])) {
|
|
568
|
+
return this.fetchNewMappingsInner(specifier);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const batch = () => {
|
|
572
|
+
const specifiers = this.batchSpecifiers.join(',');
|
|
573
|
+
this.batchSpecifiers = []; // clear pending mapping requests
|
|
574
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
575
|
+
clearTimeout(this.batchTimer); // cancel the batch timer
|
|
576
|
+
this.batchTimer = undefined;
|
|
577
|
+
return this.fetchNewMappingsInner(specifiers);
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
if (!this.batchPromise || this.batchSpecifiers.length === 0) {
|
|
581
|
+
this.batchPromise = new Promise((resolve) => {
|
|
582
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
583
|
+
this.batchTimer = setTimeout(() => resolve(batch()), 0);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
this.batchSpecifiers.push(specifier);
|
|
587
|
+
return this.batchPromise;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
async fetchNewMappingsInner(specifier) {
|
|
551
591
|
if (typeof globalThis.fetch !== 'function') {
|
|
552
592
|
throw new LoaderError(UNRESOLVED, [specifier]);
|
|
553
593
|
}
|
|
@@ -1611,7 +1651,14 @@ class Loader {
|
|
|
1611
1651
|
};
|
|
1612
1652
|
}
|
|
1613
1653
|
|
|
1614
|
-
this.registry = new ModuleRegistry(
|
|
1654
|
+
this.registry = new ModuleRegistry(
|
|
1655
|
+
Object.freeze({
|
|
1656
|
+
endpoints: config.endpoints,
|
|
1657
|
+
baseUrl,
|
|
1658
|
+
profiler,
|
|
1659
|
+
flags: config.flags || {},
|
|
1660
|
+
}),
|
|
1661
|
+
);
|
|
1615
1662
|
|
|
1616
1663
|
// TODO: W-10539691 - temp workaround for LWR-Java -- remove once appId is implemented there
|
|
1617
1664
|
if (config.appMetadata && !config.appMetadata.appId) {
|
|
@@ -11,6 +11,9 @@ export declare class ImportMetadataResolver {
|
|
|
11
11
|
private config;
|
|
12
12
|
private invalidationCallback;
|
|
13
13
|
private loadMappingHooks;
|
|
14
|
+
private batchSpecifiers;
|
|
15
|
+
private batchPromise;
|
|
16
|
+
private batchTimer;
|
|
14
17
|
constructor(config: LoaderConfig, invalidationCallback: Function);
|
|
15
18
|
addLoadMappingHook(hook: LoadMappingHook): void;
|
|
16
19
|
getMappingEndpoint(): string | undefined;
|
|
@@ -39,6 +42,7 @@ export declare class ImportMetadataResolver {
|
|
|
39
42
|
*/
|
|
40
43
|
private evaluateMappingHooks;
|
|
41
44
|
private fetchNewMappings;
|
|
45
|
+
private fetchNewMappingsInner;
|
|
42
46
|
private saveImportURIRecord;
|
|
43
47
|
}
|
|
44
48
|
//# sourceMappingURL=importMetadataResolver.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LoaderError, BAD_IMPORT_METADATA, UNRESOLVED, UNRESOLVEABLE_MAPPING_ERROR, } from '../errors/messages.js';
|
|
2
2
|
import { isUrl, resolveUrl } from '../utils/url.js';
|
|
3
3
|
import { MAPPINGS_ERROR, MAPPINGS_FETCH } from 'lwr/metrics';
|
|
4
|
+
import { hasSetTimeout } from '../utils/dom.js';
|
|
4
5
|
/* spec based import map resolver */
|
|
5
6
|
export class ImportMetadataResolver {
|
|
6
7
|
constructor(config, invalidationCallback) {
|
|
@@ -8,6 +9,8 @@ export class ImportMetadataResolver {
|
|
|
8
9
|
this.importURICache = new Map();
|
|
9
10
|
this.pendingURICache = new Map();
|
|
10
11
|
this.loadMappingHooks = [];
|
|
12
|
+
// mapping request batching
|
|
13
|
+
this.batchSpecifiers = [];
|
|
11
14
|
this.config = config;
|
|
12
15
|
this.invalidationCallback = invalidationCallback;
|
|
13
16
|
}
|
|
@@ -168,6 +171,27 @@ export class ImportMetadataResolver {
|
|
|
168
171
|
return this.fetchNewMappings(specifier);
|
|
169
172
|
}
|
|
170
173
|
async fetchNewMappings(specifier) {
|
|
174
|
+
if (!hasSetTimeout || !this.config?.flags?.batchMappings) {
|
|
175
|
+
return this.fetchNewMappingsInner(specifier);
|
|
176
|
+
}
|
|
177
|
+
const batch = () => {
|
|
178
|
+
const specifiers = this.batchSpecifiers.join(',');
|
|
179
|
+
this.batchSpecifiers = []; // clear pending mapping requests
|
|
180
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
181
|
+
clearTimeout(this.batchTimer); // cancel the batch timer
|
|
182
|
+
this.batchTimer = undefined;
|
|
183
|
+
return this.fetchNewMappingsInner(specifiers);
|
|
184
|
+
};
|
|
185
|
+
if (!this.batchPromise || this.batchSpecifiers.length === 0) {
|
|
186
|
+
this.batchPromise = new Promise((resolve) => {
|
|
187
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
188
|
+
this.batchTimer = setTimeout(() => resolve(batch()), 0);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
this.batchSpecifiers.push(specifier);
|
|
192
|
+
return this.batchPromise;
|
|
193
|
+
}
|
|
194
|
+
async fetchNewMappingsInner(specifier) {
|
|
171
195
|
if (typeof globalThis.fetch !== 'function') {
|
|
172
196
|
throw new LoaderError(UNRESOLVED, [specifier]);
|
|
173
197
|
}
|
|
@@ -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.
|
|
7
|
+
/* LWR Legacy Module Loader v0.20.1 */
|
|
8
8
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function templateString(template, args) {
|
package/build/shim/shim.js
CHANGED
|
@@ -91,6 +91,7 @@ export default class LoaderShim {
|
|
|
91
91
|
const loaderConfig = {
|
|
92
92
|
endpoints: this.config.endpoints,
|
|
93
93
|
baseUrl: this.config.baseUrl,
|
|
94
|
+
flags: this.config.flags,
|
|
94
95
|
profiler: { logOperationStart, logOperationEnd },
|
|
95
96
|
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
96
97
|
appMetadata: {
|
package/build/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.20.
|
|
8
|
+
"version": "0.20.1",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@locker/trusted-types": "0.25.3",
|
|
64
|
-
"@lwrjs/diagnostics": "0.20.
|
|
65
|
-
"@lwrjs/types": "0.20.
|
|
64
|
+
"@lwrjs/diagnostics": "0.20.1",
|
|
65
|
+
"@lwrjs/types": "0.20.1",
|
|
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.
|
|
73
|
-
"@lwrjs/shared-utils": "0.20.
|
|
72
|
+
"@lwrjs/client-modules": "0.20.1",
|
|
73
|
+
"@lwrjs/shared-utils": "0.20.1"
|
|
74
74
|
},
|
|
75
75
|
"lwc": {
|
|
76
76
|
"modules": [
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"volta": {
|
|
91
91
|
"extends": "../../../package.json"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "0621a79cb4f645af3500d6ba81ad561cf98ae944"
|
|
94
94
|
}
|