@lwrjs/loader 0.6.0-alpha.1 → 0.6.0-alpha.2
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-loader-shim-legacy.bundle.js +12 -9
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +2 -25
- package/build/assets/prod/lwr-loader-shim-legacy.js +4 -4
- package/build/assets/prod/lwr-loader-shim.bundle.js +14 -9
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +2 -25
- package/build/assets/prod/lwr-loader-shim.js +4 -4
- package/build/bundle/prod/lwr/esmLoader/esmLoader.js +1 -1
- package/build/cjs/index.cjs +12 -13
- package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +23 -14
- package/build/cjs/modules/lwr/esmLoader/importResolver.cjs +4 -5
- package/build/cjs/modules/lwr/esmLoader/importResolverLegacy.cjs +5 -6
- package/build/cjs/modules/lwr/loader/constants/constants.cjs +3 -3
- package/build/cjs/modules/lwr/loader/errors/messages.cjs +8 -8
- package/build/cjs/modules/lwr/loader/errors/reportError.cjs +8 -8
- package/build/cjs/modules/lwr/loader/errors/utils.cjs +3 -3
- package/build/cjs/modules/lwr/loader/hooks/moduleInvalidation.cjs +10 -10
- package/build/cjs/modules/lwr/loader/hooks/resolveAndLoadHook.cjs +19 -19
- package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +9 -9
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +30 -27
- package/build/cjs/modules/lwr/loader/moduleRegistry/scriptLoad.cjs +8 -8
- package/build/cjs/modules/lwr/loader/utils/dom.cjs +3 -3
- package/build/cjs/modules/lwr/loader/utils/url.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/constants/constants.cjs +3 -3
- package/build/cjs/modules/lwr/loaderLegacy/errors/messages.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/errors/reportError.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/errors/utils.cjs +3 -3
- package/build/cjs/modules/lwr/loaderLegacy/hooks/moduleInvalidation.cjs +10 -10
- package/build/cjs/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.cjs +19 -19
- package/build/cjs/modules/lwr/loaderLegacy/importMap/dom.cjs +9 -9
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMap.cjs +9 -9
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/importMap/utils.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/importResolver/importResolver.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +28 -25
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.cjs +8 -8
- package/build/cjs/modules/lwr/loaderLegacy/utils/dom.cjs +3 -3
- package/build/cjs/modules/lwr/loaderLegacy/utils/url.cjs +8 -8
- package/build/modules/lwr/esmLoader/esmLoader.js +17 -7
- package/build/modules/lwr/loader/loader.js +10 -5
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +8 -5
- package/package.json +6 -6
|
@@ -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.6.0-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.6.0-alpha.2 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
// Parse configuration
|
|
76
76
|
this.global = global;
|
|
77
77
|
this.config = global.LWR;
|
|
78
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_6_0-
|
|
78
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_6_0-alpha_2';
|
|
79
79
|
// Set up the temporary LWR.define function and customInit hook
|
|
80
80
|
const tempDefine = this.tempDefine.bind(this);
|
|
81
81
|
global.LWR.define = tempDefine;
|
|
@@ -214,14 +214,14 @@
|
|
|
214
214
|
// The loader module is ALWAYS required
|
|
215
215
|
const GLOBAL = globalThis;
|
|
216
216
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
217
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_6_0-
|
|
218
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_6_0-
|
|
217
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_6_0-alpha_2') < 0) {
|
|
218
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_6_0-alpha_2');
|
|
219
219
|
}
|
|
220
220
|
new LoaderShim(GLOBAL);
|
|
221
221
|
|
|
222
222
|
}());
|
|
223
223
|
|
|
224
|
-
LWR.define('lwr/loaderLegacy/v/0_6_0-
|
|
224
|
+
LWR.define('lwr/loaderLegacy/v/0_6_0-alpha_2', ['exports'], function (exports) { 'use strict';
|
|
225
225
|
|
|
226
226
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
227
227
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -692,15 +692,14 @@ LWR.define('lwr/loaderLegacy/v/0_6_0-alpha_1', ['exports'], function (exports) {
|
|
|
692
692
|
}
|
|
693
693
|
if (this.resolver) {
|
|
694
694
|
resolved = this.resolver.resolve(resolvedOrPlain, parentUrl);
|
|
695
|
-
// return the plain id
|
|
695
|
+
// return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
|
|
696
696
|
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
697
697
|
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
698
698
|
const record = this.moduleRegistry.get(resolved);
|
|
699
|
-
if (!record || record.
|
|
699
|
+
if (!record || !record.aliases.has(resolvedOrPlain)) {
|
|
700
700
|
return resolvedOrPlain;
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
-
// return resolved;
|
|
704
703
|
}
|
|
705
704
|
else {
|
|
706
705
|
resolved = resolvedOrPlain;
|
|
@@ -830,6 +829,10 @@ LWR.define('lwr/loaderLegacy/v/0_6_0-alpha_1', ['exports'], function (exports) {
|
|
|
830
829
|
getModuleRecord(resolvedId, id) {
|
|
831
830
|
let moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
832
831
|
if (moduleRecord) {
|
|
832
|
+
// Make sure the original id is in the alias set
|
|
833
|
+
if (!moduleRecord.aliases.has(id)) {
|
|
834
|
+
moduleRecord.aliases.add(id);
|
|
835
|
+
}
|
|
833
836
|
return moduleRecord;
|
|
834
837
|
}
|
|
835
838
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
@@ -849,7 +852,7 @@ LWR.define('lwr/loaderLegacy/v/0_6_0-alpha_1', ['exports'], function (exports) {
|
|
|
849
852
|
});
|
|
850
853
|
moduleRecord = {
|
|
851
854
|
id: resolvedId,
|
|
852
|
-
|
|
855
|
+
aliases: new Set([id]),
|
|
853
856
|
module: Object.create(null),
|
|
854
857
|
dependencyRecords,
|
|
855
858
|
instantiation,
|
|
@@ -4,28 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.6.0-alpha.
|
|
8
|
-
!function(){"use strict";function e(e,t,r,o){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:r,onBootstrapError:o},e)}}const t="function"==typeof setTimeout,r="undefined"!=typeof console;const o=globalThis;o.LWR.requiredModules=o.LWR.requiredModules||[],o.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_6_0-alpha_1")<0&&o.LWR.requiredModules.push("lwr/loaderLegacy/v/0_6_0-alpha_1"),new class{constructor(r){this.defineCache={},this.orderedDefs=[],this.global=r,this.config=r.LWR,this.loaderModule="lwr/loaderLegacy/v/0_6_0-alpha_1";const o=this.tempDefine.bind(this);r.LWR.define=o,this.bootReady=this.config.autoBoot,t&&(this.watchdogTimerId=this.startWatchdogTimer());try{e(Object.freeze(this.config),this.postCustomInit.bind(this),o,e=>{this.errorHandler=e})}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every(e=>this.orderedDefs.includes(e));return this.bootReady&&e}tempDefine(...e){const r=e[0];this.defineCache[r]=e,this.orderedDefs.push(r),this.canInit()&&(t&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s,i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})},t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],this.config.baseUrl,this.config.preloadModules);this.mountApp(e)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>{e()})})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,importMappings:o,endpoints:n}),this.orderedDefs.forEach(t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])});const{disableInitDefer:i}=this.config;e.registerImportMappings(o).then(()=>{if(!i)return this.waitForDOMContentLoaded()}).then(()=>e.load(t)).catch(e=>{this.enterErrorState(new Error(`Application ${r} could not be loaded: ${e}`))})}enterErrorState(e){this.errorHandler?this.errorHandler(e):r&&console.error("An error occurred during LWR bootstrap. "+e.message,e.stack)}startWatchdogTimer(){return setTimeout(()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))},3e5)}}(o)}(),LWR.define("lwr/loaderLegacy/v/0_6_0-alpha_1",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,(e,r)=>t[r])}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"}),MODULE_ALREADY_LOADED=Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"}),FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e=void 0;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}
|
|
9
|
-
/**
|
|
10
|
-
* Check if a string is a URL based on Common Internet Scheme Syntax
|
|
11
|
-
* https://www.ietf.org/rfc/rfc1738.txt
|
|
12
|
-
*
|
|
13
|
-
* URL Format:
|
|
14
|
-
* <scheme>:<scheme-specific-part>
|
|
15
|
-
* Common Internet Scheme Syntax:
|
|
16
|
-
* The scheme specific part starts with a double slash('//')
|
|
17
|
-
*
|
|
18
|
-
* A valid URL has a colon that is followed by a double slash.
|
|
19
|
-
*
|
|
20
|
-
* @param url - the url that is being checked
|
|
21
|
-
* @returns boolean
|
|
22
|
-
*
|
|
23
|
-
* @example Valid URLs
|
|
24
|
-
* 'https://salesforce.com'
|
|
25
|
-
* 'http://localhost:3000'
|
|
26
|
-
*
|
|
27
|
-
* @example Invalid URLs
|
|
28
|
-
* 'salesforce.com'
|
|
29
|
-
* 'localhost:3000'
|
|
30
|
-
* '@salesforce/label/type:namespace:name'
|
|
31
|
-
*/function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.charset="utf-8",t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",()=>{r(new LoaderError(FAIL_LOAD,[e]))}),o.addEventListener("load",()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()}),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error});const MODULE_LOAD_TIMEOUT_TIMER=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then(async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,""+response.status]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}).finally(()=>{})}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise((r,o)=>{const s=setTimeout(()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))},MODULE_LOAD_TIMEOUT_TIMER);t.then(e=>{r(e)}).catch(()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))}).finally(()=>{clearTimeout(s)})}):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",e=>{lastWindowError=e.error}),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.baseUrl=e}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){if(o=this.resolver.resolve(t,r),this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){const e=this.moduleRegistry.get(o);if(!e||e.originalId!==t)return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+="?importer="+encodeURIComponent(t)),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach(([e,t])=>{this.checkModuleSignature(e,t)})}registerExternalModules(e){const t=[];if(e.map(e=>{if(this.namedDefineRegistry.has(e))t.push(e);else{let t,r;const o=new Promise((o,s)=>{t=o,r=setTimeout(()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))},MODULE_LOAD_TIMEOUT_TIMER)}).finally(()=>{clearTimeout(r)}),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r?evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t}):hasConsole&&console.warn(`stale module detected ${e}, current sig:${o}, new sig:${t}`)}}setImportResolver(e){this.resolver=e}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r;const o=this.getModuleDef(e,t),s=o.then(e=>{const t=e.dependencies.map(e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)}).filter(e=>void 0!==e);return Promise.all(t)});return r={id:e,originalId:t,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=await Promise.all(s.map(async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}));if(e.evaluated)return e.module;let a=o(...i);void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),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;return Promise.resolve().then(async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1}).then(t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)}).then(()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return o}).catch(e=>{throw e})}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){return e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length?r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e):r+e.slice(o.length)}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e))return r+encodeURIComponent(e)}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&t||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter(e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps(o=>{r=r.then(()=>getImportMapFromScript(o)).then(e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}}).then(r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t))},"")}return r}class Loader{constructor(e){if(e&&(e=e.replace(/\/?$/,"/")),e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);this.baseUrl=e,this.registry=new ModuleRegistry(e),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry)})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.6.0-alpha.2 */
|
|
8
|
+
!function(){"use strict";function e(e,t,r,o){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:r,onBootstrapError:o},e)}}const t="function"==typeof setTimeout,r="undefined"!=typeof console;const o=globalThis;o.LWR.requiredModules=o.LWR.requiredModules||[],o.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_6_0-alpha_2")<0&&o.LWR.requiredModules.push("lwr/loaderLegacy/v/0_6_0-alpha_2"),new class{constructor(r){this.defineCache={},this.orderedDefs=[],this.global=r,this.config=r.LWR,this.loaderModule="lwr/loaderLegacy/v/0_6_0-alpha_2";const o=this.tempDefine.bind(this);r.LWR.define=o,this.bootReady=this.config.autoBoot,t&&(this.watchdogTimerId=this.startWatchdogTimer());try{e(Object.freeze(this.config),this.postCustomInit.bind(this),o,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const r=e[0];this.defineCache[r]=e,this.orderedDefs.push(r),this.canInit()&&(t&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s,i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],this.config.baseUrl,this.config.preloadModules);this.mountApp(e)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,importMappings:o,endpoints:n}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:i}=this.config;e.registerImportMappings(o).then((()=>{if(!i)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r} could not be loaded: ${e}`))}))}enterErrorState(e){this.errorHandler?this.errorHandler(e):r&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),3e5)}}(o)}(),LWR.define("lwr/loaderLegacy/v/0_6_0-alpha_2",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"}),MODULE_ALREADY_LOADED=Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"}),FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.charset="utf-8",t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0})).finally((()=>{}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.baseUrl=e}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){if(o=this.resolver.resolve(t,r),this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){const e=this.moduleRegistry.get(o);if(!e||!e.aliases.has(t))return t}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){const t=[];if(e.map((e=>{if(this.namedDefineRegistry.has(e))t.push(e);else{let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}})),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r?evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t}):hasConsole&&console.warn(`stale module detected ${e}, current sig:${o}, new sig:${t}`)}}setImportResolver(e){this.resolver=e}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r.aliases.has(t)||r.aliases.add(t),r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=e.dependencies.map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)}));return r={id:e,aliases:new Set([t]),module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])})));if(e.evaluated)return e.module;let a=o(...i);void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),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;return Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return o})).catch((e=>{throw e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){return e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length?r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e):r+e.slice(o.length)}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e))return r+encodeURIComponent(e)}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&t||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){if(e&&(e=e.replace(/\/?$/,"/")),e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);this.baseUrl=e,this.registry=new ModuleRegistry(e),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry)})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.6.0-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.6.0-alpha.2 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
// Parse configuration
|
|
76
76
|
this.global = global;
|
|
77
77
|
this.config = global.LWR;
|
|
78
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_6_0-
|
|
78
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_6_0-alpha_2';
|
|
79
79
|
// Set up the temporary LWR.define function and customInit hook
|
|
80
80
|
const tempDefine = this.tempDefine.bind(this);
|
|
81
81
|
global.LWR.define = tempDefine;
|
|
@@ -214,8 +214,8 @@
|
|
|
214
214
|
// The loader module is ALWAYS required
|
|
215
215
|
const GLOBAL = globalThis;
|
|
216
216
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
217
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_6_0-
|
|
218
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_6_0-
|
|
217
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_6_0-alpha_2') < 0) {
|
|
218
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_6_0-alpha_2');
|
|
219
219
|
}
|
|
220
220
|
new LoaderShim(GLOBAL);
|
|
221
221
|
|
|
@@ -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.6.0-alpha.
|
|
7
|
+
/* LWR Module Loader Shim v0.6.0-alpha.2 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
// Parse configuration
|
|
75
75
|
this.global = global;
|
|
76
76
|
this.config = global.LWR;
|
|
77
|
-
this.loaderModule = 'lwr/loader/v/0_6_0-
|
|
77
|
+
this.loaderModule = 'lwr/loader/v/0_6_0-alpha_2';
|
|
78
78
|
// Set up the temporary LWR.define function and customInit hook
|
|
79
79
|
const tempDefine = this.tempDefine.bind(this);
|
|
80
80
|
global.LWR.define = tempDefine;
|
|
@@ -218,14 +218,14 @@
|
|
|
218
218
|
// The loader module is ALWAYS required
|
|
219
219
|
const GLOBAL = globalThis;
|
|
220
220
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
221
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_6_0-
|
|
222
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_6_0-
|
|
221
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_6_0-alpha_2') < 0) {
|
|
222
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_6_0-alpha_2');
|
|
223
223
|
}
|
|
224
224
|
new LoaderShim(GLOBAL);
|
|
225
225
|
|
|
226
226
|
}());
|
|
227
227
|
|
|
228
|
-
LWR.define('lwr/loader/v/0_6_0-
|
|
228
|
+
LWR.define('lwr/loader/v/0_6_0-alpha_2', ['exports'], function (exports) { 'use strict';
|
|
229
229
|
|
|
230
230
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
231
231
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -908,10 +908,11 @@ LWR.define('lwr/loader/v/0_6_0-alpha_1', ['exports'], function (exports) { 'use
|
|
|
908
908
|
}
|
|
909
909
|
const resolvedUrl = this.resolver.resolveLocal(resolvedOrPlain);
|
|
910
910
|
if (resolvedUrl) {
|
|
911
|
-
// return the plain id
|
|
912
|
-
if (this.namedDefineRegistry.has(resolvedOrPlain)
|
|
911
|
+
// return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
|
|
912
|
+
if (this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
913
|
+
this.namedDefineRegistry.get(resolvedOrPlain).defined) {
|
|
913
914
|
const record = this.moduleRegistry.get(resolvedUrl);
|
|
914
|
-
if (!record || record.
|
|
915
|
+
if (!record || !record.aliases.has(resolvedOrPlain)) {
|
|
915
916
|
return resolvedOrPlain;
|
|
916
917
|
}
|
|
917
918
|
}
|
|
@@ -1012,6 +1013,10 @@ LWR.define('lwr/loader/v/0_6_0-alpha_1', ['exports'], function (exports) { 'use
|
|
|
1012
1013
|
getModuleRecord(resolvedId, id) {
|
|
1013
1014
|
let moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
1014
1015
|
if (moduleRecord) {
|
|
1016
|
+
// Make sure the original id is in the alias set
|
|
1017
|
+
if (!moduleRecord.aliases.has(id)) {
|
|
1018
|
+
moduleRecord.aliases.add(id);
|
|
1019
|
+
}
|
|
1015
1020
|
return moduleRecord;
|
|
1016
1021
|
}
|
|
1017
1022
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
@@ -1031,7 +1036,7 @@ LWR.define('lwr/loader/v/0_6_0-alpha_1', ['exports'], function (exports) { 'use
|
|
|
1031
1036
|
});
|
|
1032
1037
|
moduleRecord = {
|
|
1033
1038
|
id: resolvedId,
|
|
1034
|
-
|
|
1039
|
+
aliases: new Set([id]),
|
|
1035
1040
|
module: Object.create(null),
|
|
1036
1041
|
dependencyRecords,
|
|
1037
1042
|
instantiation,
|
|
@@ -4,28 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.6.0-alpha.
|
|
8
|
-
!function(){"use strict";function e(e,t,r,o){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:r,onBootstrapError:o},e)}}const t="function"==typeof setTimeout,r="undefined"!=typeof console;const o=globalThis;o.LWR.requiredModules=o.LWR.requiredModules||[],o.LWR.requiredModules.indexOf("lwr/loader/v/0_6_0-alpha_1")<0&&o.LWR.requiredModules.push("lwr/loader/v/0_6_0-alpha_1"),new class{constructor(r){this.defineCache={},this.orderedDefs=[],this.global=r,this.config=r.LWR,this.loaderModule="lwr/loader/v/0_6_0-alpha_1";const o=this.tempDefine.bind(this);r.LWR.define=o,this.bootReady=this.config.autoBoot,t&&(this.watchdogTimerId=this.startWatchdogTimer());try{e(Object.freeze(this.config),this.postCustomInit.bind(this),o,e=>{this.errorHandler=e})}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every(e=>this.orderedDefs.includes(e));return this.bootReady&&e}tempDefine(...e){const r=e[0];this.defineCache[r]=e,this.orderedDefs.push(r),this.canInit()&&(t&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl},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 n={};t[2].call(null,n);const{Loader:i}=n,s=new i(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.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>{e()})})}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,endpoints:n,imports:i,index:s}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,endpoints:n,imports:i||{},index:s||{}}),this.orderedDefs.forEach(t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])});const{disableInitDefer:a}=this.config;e.registerImportMappings({imports:i,index:s},[t,r]).then(()=>{if(!a)return this.waitForDOMContentLoaded()}).then(()=>e.load(t)).catch(e=>{this.enterErrorState(new Error(`Application ${r} could not be loaded: ${e}`))})}enterErrorState(e){this.errorHandler?this.errorHandler(e):r&&console.error("An error occurred during LWR bootstrap. "+e.message,e.stack)}startWatchdogTimer(){return setTimeout(()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))},3e5)}}(o)}(),LWR.define("lwr/loader/v/0_6_0-alpha_1",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,(e,r)=>t[r])}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"}),MODULE_ALREADY_LOADED=Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"}),FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e=void 0;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}
|
|
9
|
-
/**
|
|
10
|
-
* Check if a string is a URL based on Common Internet Scheme Syntax
|
|
11
|
-
* https://www.ietf.org/rfc/rfc1738.txt
|
|
12
|
-
*
|
|
13
|
-
* URL Format:
|
|
14
|
-
* <scheme>:<scheme-specific-part>
|
|
15
|
-
* Common Internet Scheme Syntax:
|
|
16
|
-
* The scheme specific part starts with a double slash('//')
|
|
17
|
-
*
|
|
18
|
-
* A valid URL has a colon that is followed by a double slash.
|
|
19
|
-
*
|
|
20
|
-
* @param url - the url that is being checked
|
|
21
|
-
* @returns boolean
|
|
22
|
-
*
|
|
23
|
-
* @example Valid URLs
|
|
24
|
-
* 'https://salesforce.com'
|
|
25
|
-
* 'http://localhost:3000'
|
|
26
|
-
*
|
|
27
|
-
* @example Invalid URLs
|
|
28
|
-
* 'salesforce.com'
|
|
29
|
-
* 'localhost:3000'
|
|
30
|
-
* '@salesforce/label/type:namespace:name'
|
|
31
|
-
*/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 n=o.slice(0,o.lastIndexOf("/")+1)+e,i=[];let s=-1;for(let e=0;e<n.length;e++)-1!==s?"/"===n[e]&&(i.push(n.slice(s,e+1)),s=-1):"."===n[e]?"."!==n[e+1]||"/"!==n[e+2]&&e+2!==n.length?"/"===n[e+1]||e+1===n.length?e+=1:s=e:(i.pop(),e+=2):s=e;return-1!==s&&i.push(n.slice(s)),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.charset="utf-8",t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",()=>{r(new LoaderError(FAIL_LOAD,[e]))}),o.addEventListener("load",()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()}),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error});class ImportMetadataResolver{constructor(e,t){this.importURICache=new Map,this.pendingURICache=new Map,this.loadMappingHooks=[],this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return"?"+Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,n]of Object.entries(e.imports))n.forEach(e=>{const n=r[e],i=this.importURICache.get(e);if(i){const t=n||o,r=i.identity||i.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,n,t.includes(e))})}getURI(e){return this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;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 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 n=t[o],i=await n(e,{knownModules:r});if(i||void 0===i)return i}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());return globalThis.fetch(t).then(t=>{if(!t.ok)throw 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:n}=t;for(let t=0;t<e.length;t++){const i=e[t];try{if(null!==i({name:r,oldUrl:o,newUrl:n}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then(async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,""+response.status]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}).finally(()=>{})}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise((r,o)=>{const n=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(n)})}):t}hasDocument&&globalThis.addEventListener("error",e=>{lastWindowError=e.error}),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this))}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,n=e;const i=this.resolveHook;if(i){for(let e=0;e<i.length;e++){const t=(0,i[e])(n,{parentUrl:r});let s;if((t||null===t)&&(s=isResponseAPromise(t)?await t:t),null!==s){if("string"==typeof s){if(resolveIfNotPlainOrUrl(s,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);n=s;continue}if(o=s&&s.url&&(resolveIfNotPlainOrUrl(s.url,r)||s.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(n!==e){if(!o&&this.namedDefineRegistry.has(n))return n;e=n}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const n=this.resolver.resolveLocal(t);if(n){if(this.namedDefineRegistry.has(t)){const e=this.moduleRegistry.get(n);if(!e||e.originalId!==t)return t}return n}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 n={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(n),this.namedDefineRegistry.set(e,n),this.lastDefine=n}registerExternalModules(e){const t=[];if(e.map(e=>{if(this.namedDefineRegistry.has(e))t.push(e);else{let t,r;const o=new Promise((o,n)=>{t=o,r=setTimeout(()=>{n(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))},MODULE_LOAD_TIMEOUT_TIMER)}).finally(()=>{clearTimeout(r)}),n={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,n)}}),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}getImportMetadataResolver(){return this.resolver}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r;const o=this.getModuleDef(e,t),n=o.then(e=>{const t=e.dependencies.map(e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)}).filter(e=>void 0!==e);return Promise.all(t)});return r={id:e,originalId:t,module:Object.create(null),dependencyRecords:n,instantiation:o,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:n}=await e.instantiation,i={},s=await Promise.all(n.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=o(...s);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}),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 n=this.resolver.getBaseUrl();return Promise.resolve().then(async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,n),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||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return o}).catch(e=>{throw e})}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o?evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r}):hasConsole&&console.warn(`stale module detected ${e}, current URL:${t}, new URL:${r}`)}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;if(!r)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t})),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry)})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,n=t;"function"==typeof n&&(o=t,n=[]),invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,o)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
7
|
+
/* LWR Module Loader Shim v0.6.0-alpha.2 */
|
|
8
|
+
!function(){"use strict";function e(e,t,r,o){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:r,onBootstrapError:o},e)}}const t="function"==typeof setTimeout,r="undefined"!=typeof console;const o=globalThis;o.LWR.requiredModules=o.LWR.requiredModules||[],o.LWR.requiredModules.indexOf("lwr/loader/v/0_6_0-alpha_2")<0&&o.LWR.requiredModules.push("lwr/loader/v/0_6_0-alpha_2"),new class{constructor(r){this.defineCache={},this.orderedDefs=[],this.global=r,this.config=r.LWR,this.loaderModule="lwr/loader/v/0_6_0-alpha_2";const o=this.tempDefine.bind(this);r.LWR.define=o,this.bootReady=this.config.autoBoot,t&&(this.watchdogTimerId=this.startWatchdogTimer());try{e(Object.freeze(this.config),this.postCustomInit.bind(this),o,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const r=e[0];this.defineCache[r]=e,this.orderedDefs.push(r),this.canInit()&&(t&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl},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 n={};t[2].call(null,n);const{Loader:s}=n,i=new s(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})})),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,endpoints:n,imports:s,index:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,endpoints:n,imports:s||{},index:i||{}}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings({imports:s,index:i},[t,r]).then((()=>{if(!a)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r} could not be loaded: ${e}`))}))}enterErrorState(e){this.errorHandler?this.errorHandler(e):r&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),3e5)}}(o)}(),LWR.define("lwr/loader/v/0_6_0-alpha_2",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"}),MODULE_ALREADY_LOADED=Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"}),FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const n=o.slice(0,o.lastIndexOf("/")+1)+e,s=[];let i=-1;for(let e=0;e<n.length;e++)-1!==i?"/"===n[e]&&(s.push(n.slice(i,e+1)),i=-1):"."===n[e]?"."!==n[e+1]||"/"!==n[e+2]&&e+2!==n.length?"/"===n[e+1]||e+1===n.length?e+=1:i=e:(s.pop(),e+=2):i=e;return-1!==i&&s.push(n.slice(i)),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.charset="utf-8",t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));class ImportMetadataResolver{constructor(e,t){this.importURICache=new Map,this.pendingURICache=new Map,this.loadMappingHooks=[],this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,n]of Object.entries(e.imports))n.forEach((e=>{const n=r[e],s=this.importURICache.get(e);if(s){const t=n||o,r=s.identity||s.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,n,t.includes(e))}))}getURI(e){return this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;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 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 n=t[o],s=await n(e,{knownModules:r});if(s||void 0===s)return s}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());return globalThis.fetch(t).then((t=>{if(!t.ok)throw 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:n}=t;for(let t=0;t<e.length;t++){const s=e[t];try{if(null!==s({name:r,oldUrl:o,newUrl:n}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=3e5;let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(code)}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0})).finally((()=>{}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const n=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(n)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error})),!hasSetTimeout&&hasConsole&&console.warn("setTimeout API is not available, watchdog timer on load hook will not be set");class ModuleRegistry{constructor(e){this.namedDefineRegistry=new Map,this.moduleRegistry=new Map,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this))}async load(e,t){const r=await this.resolve(e,t),o=this.getModuleRecord(r,e);return o.evaluated?o.module:(o.evaluationPromise||(o.evaluationPromise=this.topLevelEvaluation(o)),o.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,n=e;const s=this.resolveHook;if(s){for(let e=0;e<s.length;e++){const t=(0,s[e])(n,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);n=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(n!==e){if(!o&&this.namedDefineRegistry.has(n))return n;e=n}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const n=this.resolver.resolveLocal(t);if(n){if(this.namedDefineRegistry.has(t)&&this.namedDefineRegistry.get(t).defined){const e=this.moduleRegistry.get(n);if(!e||!e.aliases.has(t))return t}return n}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 n={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(n),this.namedDefineRegistry.set(e,n),this.lastDefine=n}registerExternalModules(e){const t=[];if(e.map((e=>{if(this.namedDefineRegistry.has(e))t.push(e);else{let t,r;const o=new Promise(((o,n)=>{t=o,r=setTimeout((()=>{n(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),n={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,n)}})),t.length)throw new LoaderError(MODULE_ALREADY_LOADED,[t.join(", ")])}getImportMetadataResolver(){return this.resolver}getModuleRecord(e,t){let r=this.moduleRegistry.get(e);if(r)return r.aliases.has(t)||r.aliases.add(t),r;const o=this.getModuleDef(e,t),n=o.then((e=>{const t=e.dependencies.map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)}));return r={id:e,aliases:new Set([t]),module:Object.create(null),dependencyRecords:n,instantiation:o,evaluated:!1,evaluationPromise:null},this.moduleRegistry.set(e,r),r}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:n}=await e.instantiation,s={},i=await Promise.all(n.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=o(...i);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}),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 n=this.resolver.getBaseUrl();return Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,n),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||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return o})).catch((e=>{throw e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o?evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r}):hasConsole&&console.warn(`stale module detected ${e}, current URL:${t}, new URL:${r}`)}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;if(!r)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t})),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry)})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,n=t;"function"==typeof n&&(o=t,n=[]),invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,o)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.6.0-alpha.
|
|
7
|
+
/* LWR Module Loader Shim v0.6.0-alpha.2 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
// Parse configuration
|
|
75
75
|
this.global = global;
|
|
76
76
|
this.config = global.LWR;
|
|
77
|
-
this.loaderModule = 'lwr/loader/v/0_6_0-
|
|
77
|
+
this.loaderModule = 'lwr/loader/v/0_6_0-alpha_2';
|
|
78
78
|
// Set up the temporary LWR.define function and customInit hook
|
|
79
79
|
const tempDefine = this.tempDefine.bind(this);
|
|
80
80
|
global.LWR.define = tempDefine;
|
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
// The loader module is ALWAYS required
|
|
219
219
|
const GLOBAL = globalThis;
|
|
220
220
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
221
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_6_0-
|
|
222
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_6_0-
|
|
221
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_6_0-alpha_2') < 0) {
|
|
222
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_6_0-alpha_2');
|
|
223
223
|
}
|
|
224
224
|
new LoaderShim(GLOBAL);
|
|
225
225
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
class t{constructor(t){if(this.importURICache=new Map,t&&t.imports)for(const[r,e]of Object.entries(t.imports))if(r&&e){(Array.isArray(e)?e:[]).forEach((t=>{this.importURICache.set(t,r)}))}}resolve(t){return this.importURICache.get(t)}}class r{constructor(t){this.importURICache=t&&t.imports?t:{imports:{}}}legacyResolve(t){return this.importURICache.imports[t]}}let e,o,i;function n(n){e=n;const{imports:s,index:c,importMappings:p}=n;o=new t({imports:s,index:c}),i=new r(p)}function s(t,r){const n=function(t,r){let n;if(!o||!i)throw new Error("The ESM Loader was not initialized");if(n=o.resolve(t),n)return n;if(n=i.legacyResolve(t),n)return n;if(n=t,n.indexOf("://")<0&&!n.startsWith("/")){const{endpoints:o}=e;o&&o.uris&&o.uris.module&&(n=o.uris.module+encodeURIComponent(t),r&&(n+=`?importer=${encodeURIComponent(r)}`))}return n}(t,r);return import(n)}export{n as init,s as load};
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/loader/src/index.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
default: () =>
|
|
27
|
+
default: () => AmdLoaderShimService
|
|
28
28
|
});
|
|
29
29
|
var import_path = __toModule(require("path"));
|
|
30
30
|
var import_fs = __toModule(require("fs"));
|
|
31
31
|
var import_package = __toModule(require("@lwrjs/loader/package"));
|
|
32
32
|
var AmdLoaderShimService = class {
|
|
33
|
-
constructor({dir = "assets"}, context) {
|
|
33
|
+
constructor({ dir = "assets" }, context) {
|
|
34
34
|
this.name = "loader-shim-resource";
|
|
35
35
|
this.filenames = [
|
|
36
36
|
"lwr-loader-shim.js",
|
|
@@ -45,7 +45,7 @@ var AmdLoaderShimService = class {
|
|
|
45
45
|
this.version = context.runtimeEnvironment.lwrVersion;
|
|
46
46
|
}
|
|
47
47
|
async getResource(resource, environment) {
|
|
48
|
-
const {specifier, version = this.version} = resource;
|
|
48
|
+
const { specifier, version = this.version } = resource;
|
|
49
49
|
if (!this.filenames.includes(specifier) || version !== this.version) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -56,11 +56,10 @@ var AmdLoaderShimService = class {
|
|
|
56
56
|
specifier,
|
|
57
57
|
type: "application/javascript",
|
|
58
58
|
stream: import_fs.default.createReadStream(absFilepath),
|
|
59
|
-
src: this.context.resourceRegistry.resolveResourceUri({specifier, version}, environment)
|
|
59
|
+
src: this.context.resourceRegistry.resolveResourceUri({ specifier, version }, environment)
|
|
60
60
|
};
|
|
61
61
|
} else {
|
|
62
62
|
return void 0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
var src_default = AmdLoaderShimService;
|
|
@@ -1,44 +1,52 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/loader/src/modules/lwr/esmLoader/esmLoader.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
+
init: () => init,
|
|
27
28
|
load: () => load
|
|
28
29
|
});
|
|
29
30
|
var import_importResolver = __toModule(require("./importResolver"));
|
|
30
31
|
var import_importResolverLegacy = __toModule(require("./importResolverLegacy"));
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
var esmLoaderConfig;
|
|
33
|
+
var resolver;
|
|
34
|
+
var resolverLegacy;
|
|
35
|
+
function init(config) {
|
|
36
|
+
esmLoaderConfig = config;
|
|
37
|
+
const { imports, index, importMappings } = config;
|
|
38
|
+
resolver = new import_importResolver.default({ imports, index });
|
|
39
|
+
resolverLegacy = new import_importResolverLegacy.default(importMappings);
|
|
40
|
+
}
|
|
36
41
|
function load(specifier, importer) {
|
|
37
42
|
const uri = resolveUrl(specifier, importer);
|
|
38
|
-
return
|
|
43
|
+
return import(uri);
|
|
39
44
|
}
|
|
40
45
|
function resolveUrl(specifier, importer) {
|
|
41
46
|
let uri;
|
|
47
|
+
if (!resolver || !resolverLegacy) {
|
|
48
|
+
throw new Error("The ESM Loader was not initialized");
|
|
49
|
+
}
|
|
42
50
|
uri = resolver.resolve(specifier);
|
|
43
51
|
if (uri) {
|
|
44
52
|
return uri;
|
|
@@ -49,6 +57,7 @@ function resolveUrl(specifier, importer) {
|
|
|
49
57
|
}
|
|
50
58
|
uri = specifier;
|
|
51
59
|
if (uri.indexOf("://") < 0 && !uri.startsWith("/")) {
|
|
60
|
+
const { endpoints } = esmLoaderConfig;
|
|
52
61
|
if (endpoints && endpoints.uris && endpoints.uris.module) {
|
|
53
62
|
uri = endpoints.uris.module + encodeURIComponent(specifier);
|
|
54
63
|
if (importer) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
3
|
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
4
5
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
// packages/@lwrjs/loader/src/modules/lwr/esmLoader/importResolver.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
|
-
default: () =>
|
|
11
|
+
default: () => ImportResolver
|
|
12
12
|
});
|
|
13
13
|
var ImportResolver = class {
|
|
14
14
|
constructor(importMetada) {
|
|
@@ -28,4 +28,3 @@ var ImportResolver = class {
|
|
|
28
28
|
return this.importURICache.get(specifier);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
var importResolver_default = ImportResolver;
|