@lwrjs/loader 0.22.8 → 0.22.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +123 -13
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim-legacy.js +105 -9
- package/build/assets/prod/lwr-loader-shim.bundle.js +123 -12
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +105 -8
- package/build/bundle/prod/lwr/esmLoader/esmLoader.js +1 -1
- package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +1 -1
- package/build/cjs/modules/lwr/loader/validateLoadSpecifier.cjs +4 -1
- package/build/modules/lwr/esmLoader/esmLoader.js +2 -2
- package/build/modules/lwr/loader/loader.js +18 -4
- package/build/modules/lwr/loader/validateLoadSpecifier.d.ts +2 -1
- package/build/modules/lwr/loader/validateLoadSpecifier.js +11 -2
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +18 -4
- package/build/shim/defineCacheResolver.d.ts +10 -0
- package/build/shim/defineCacheResolver.js +78 -0
- package/build/shim/loader.d.ts +5 -1
- package/build/shim/loader.js +14 -3
- package/build/shim/shim.js +3 -2
- package/build/shim-legacy/loaderLegacy.d.ts +7 -2
- package/build/shim-legacy/loaderLegacy.js +15 -4
- package/build/shim-legacy/shimLegacy.js +2 -2
- package/build/types.d.ts +18 -0
- package/package.json +10 -10
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.22.
|
|
7
|
+
/* LWR Module Loader Shim v0.22.10 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -105,19 +105,114 @@
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Parse AMD define args. Supports define(id, deps, factory).
|
|
110
|
+
*/
|
|
111
|
+
function parseDefine(def) {
|
|
112
|
+
const [, depsOrFactory, factory] = def;
|
|
113
|
+
if (Array.isArray(depsOrFactory) && typeof factory === 'function') {
|
|
114
|
+
return { deps: depsOrFactory, factory };
|
|
115
|
+
}
|
|
116
|
+
if (typeof depsOrFactory === 'function') {
|
|
117
|
+
return { deps: [], factory: depsOrFactory };
|
|
118
|
+
}
|
|
119
|
+
throw new Error('Invalid module definition');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Resolve a loader dependency: 'exports' returns the bag; otherwise look up in cache and instantiate.
|
|
124
|
+
* Loader deps are assumed to be leaf modules (no deps of their own)—no recursive resolution.
|
|
125
|
+
*/
|
|
126
|
+
function resolveDep(dep, exportsObj, cache) {
|
|
127
|
+
if (dep === 'exports') return exportsObj;
|
|
128
|
+
const mod = cache[dep];
|
|
129
|
+
if (!mod) {
|
|
130
|
+
throw new Error(`Dependency "${dep}" not found in defineCache for loader`);
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
return instantiateLeafModule(mod);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
136
|
+
throw new Error(`Loader dependency "${dep}" has invalid definition: ${msg}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Instantiate a leaf module (loader dep). Assumes the module has no dependencies of its own.
|
|
142
|
+
* Supports only deps: [] or ['exports']; any other dep list throws.
|
|
143
|
+
*/
|
|
144
|
+
function instantiateLeafModule(def) {
|
|
145
|
+
const { deps, factory } = parseDefine(def);
|
|
146
|
+
if (deps.length > 1 || (deps.length === 1 && deps[0] !== 'exports')) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Loader dependencies must have no deps or only ['exports']; got [${deps.join(', ')}]`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const exports = {};
|
|
152
|
+
const out = factory(exports);
|
|
153
|
+
return out !== undefined ? out : exports;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Normalize loader definition to canonical (exports, ...deps). Injects 'exports' if missing.
|
|
158
|
+
*/
|
|
159
|
+
function normalizeLoaderDefinition(def) {
|
|
160
|
+
const { deps, factory } = parseDefine(def);
|
|
161
|
+
if (deps.includes('exports')) {
|
|
162
|
+
return { deps, factory };
|
|
163
|
+
}
|
|
164
|
+
const isEmptyDeps = deps.length === 0;
|
|
165
|
+
const normalizedFactory = (exports, ...rest) => {
|
|
166
|
+
const result = isEmptyDeps ? factory(exports) : factory(...rest);
|
|
167
|
+
if (result !== undefined && typeof result === 'object') {
|
|
168
|
+
Object.assign(exports, result);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return { deps: ['exports', ...deps], factory: normalizedFactory };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Resolve the loader's dependencies from defineCache. Throws if definition is invalid or deps cannot be resolved.
|
|
176
|
+
*/
|
|
177
|
+
function resolveLoaderDepsFromDefineCache(
|
|
178
|
+
loaderSpecifier,
|
|
179
|
+
definition,
|
|
180
|
+
defineCache,
|
|
181
|
+
) {
|
|
182
|
+
try {
|
|
183
|
+
const { deps, factory } = normalizeLoaderDefinition(definition);
|
|
184
|
+
const exportsObj = {};
|
|
185
|
+
const args = deps.map((dep) => resolveDep(dep, exportsObj, defineCache)) ;
|
|
186
|
+
return { factory: factory , args, exportsObj };
|
|
187
|
+
} catch (e) {
|
|
188
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
189
|
+
throw new Error(`Expected loader with specifier "${loaderSpecifier}" to be a module. ${msg}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create a loader from a definition. Original API preserved.
|
|
195
|
+
* Optional defineCache for resolving loader deps (when loader has dependencies).
|
|
196
|
+
*/
|
|
108
197
|
function createLoader(
|
|
109
198
|
name,
|
|
110
199
|
definition,
|
|
111
200
|
config,
|
|
112
201
|
externalModules,
|
|
202
|
+
defineCache,
|
|
113
203
|
) {
|
|
114
204
|
if (!definition || typeof definition[2] !== 'function') {
|
|
115
205
|
throw new Error(`Expected loader with specifier "${name}" to be a module`);
|
|
116
206
|
}
|
|
117
207
|
|
|
118
|
-
// Create a Loader instance
|
|
119
208
|
const exports = {};
|
|
120
|
-
|
|
209
|
+
if (defineCache) {
|
|
210
|
+
const { factory, args, exportsObj } = resolveLoaderDepsFromDefineCache(name, definition, defineCache);
|
|
211
|
+
factory(...args);
|
|
212
|
+
Object.assign(exports, exportsObj);
|
|
213
|
+
} else {
|
|
214
|
+
definition[2].call(null, exports);
|
|
215
|
+
}
|
|
121
216
|
const { Loader } = exports;
|
|
122
217
|
if (!Loader) {
|
|
123
218
|
throw new Error('Expected Loader class to be defined');
|
|
@@ -214,7 +309,7 @@
|
|
|
214
309
|
// Parse configuration
|
|
215
310
|
this.global = global;
|
|
216
311
|
this.config = global.LWR ;
|
|
217
|
-
this.loaderSpecifier = 'lwr/loader/v/
|
|
312
|
+
this.loaderSpecifier = 'lwr/loader/v/0_22_10';
|
|
218
313
|
|
|
219
314
|
// Set up error handler
|
|
220
315
|
this.errorHandler = this.config.onError ;
|
|
@@ -322,6 +417,7 @@
|
|
|
322
417
|
this.defineCache[this.loaderSpecifier],
|
|
323
418
|
loaderConfig,
|
|
324
419
|
this.config.preloadModules,
|
|
420
|
+
this.defineCache,
|
|
325
421
|
);
|
|
326
422
|
this.mountApp(loader);
|
|
327
423
|
if (
|
|
@@ -345,6 +441,7 @@
|
|
|
345
441
|
if (document.body) {
|
|
346
442
|
resolve();
|
|
347
443
|
} else {
|
|
444
|
+
/* istanbul ignore next */
|
|
348
445
|
const observer = new MutationObserver(() => {
|
|
349
446
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
350
447
|
if (document.body) {
|
|
@@ -377,7 +474,7 @@
|
|
|
377
474
|
const exporter = (exports) => {
|
|
378
475
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
379
476
|
};
|
|
380
|
-
define('lwr/profiler/v/
|
|
477
|
+
define('lwr/profiler/v/0_22_10', ['exports'], exporter);
|
|
381
478
|
}
|
|
382
479
|
|
|
383
480
|
// Set up the application globals, import map, root custom element...
|
|
@@ -417,7 +514,7 @@
|
|
|
417
514
|
])
|
|
418
515
|
.then(() => {
|
|
419
516
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
420
|
-
if (typeof window === 'undefined' || typeof document === undefined) {
|
|
517
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
421
518
|
return Promise.resolve();
|
|
422
519
|
}
|
|
423
520
|
if (initDeferDOM) {
|
|
@@ -477,14 +574,14 @@
|
|
|
477
574
|
// The loader module is ALWAYS required
|
|
478
575
|
const GLOBAL = globalThis ;
|
|
479
576
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
480
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
481
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
577
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_22_10') < 0) {
|
|
578
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_22_10');
|
|
482
579
|
}
|
|
483
580
|
new LoaderShim(GLOBAL);
|
|
484
581
|
|
|
485
582
|
})();
|
|
486
583
|
|
|
487
|
-
LWR.define('lwr/loader/v/
|
|
584
|
+
LWR.define('lwr/loader/v/0_22_10', ['exports'], (function (exports) { 'use strict';
|
|
488
585
|
|
|
489
586
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
490
587
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -639,7 +736,7 @@ LWR.define('lwr/loader/v/0_22_8', ['exports'], (function (exports) { 'use strict
|
|
|
639
736
|
level: 0,
|
|
640
737
|
message: 'Cannot import a blob URL',
|
|
641
738
|
});
|
|
642
|
-
Object.freeze({
|
|
739
|
+
const NO_IMPORT_TRANSPORT = Object.freeze({
|
|
643
740
|
code: 3025,
|
|
644
741
|
level: 0,
|
|
645
742
|
message: 'Cannot dynamically import "transport" with importer "{0}"',
|
|
@@ -2089,9 +2186,10 @@ LWR.define('lwr/loader/v/0_22_8', ['exports'], (function (exports) { 'use strict
|
|
|
2089
2186
|
|
|
2090
2187
|
|
|
2091
2188
|
|
|
2189
|
+
|
|
2092
2190
|
/**
|
|
2093
2191
|
* Validates that the given module id is not one of the forbidden dynamic import specifiers.
|
|
2094
|
-
* Throws LoaderError for: lwc, the LWR loader, and blob URLs.
|
|
2192
|
+
* Throws LoaderError for: lwc, the LWR loader, transport/webruntime/transport, and blob URLs.
|
|
2095
2193
|
*
|
|
2096
2194
|
* @param id - Module identifier or URL
|
|
2097
2195
|
* @param importer - Versioned specifier of the module importer (for error reporting)
|
|
@@ -2104,7 +2202,7 @@ LWR.define('lwr/loader/v/0_22_8', ['exports'], (function (exports) { 'use strict
|
|
|
2104
2202
|
loaderSpecifier,
|
|
2105
2203
|
errors,
|
|
2106
2204
|
) {
|
|
2107
|
-
const { LoaderError, NO_IMPORT_LWC, NO_IMPORT_LOADER, NO_BLOB_IMPORT } = errors;
|
|
2205
|
+
const { LoaderError, NO_IMPORT_LWC, NO_IMPORT_LOADER, NO_IMPORT_TRANSPORT, NO_BLOB_IMPORT } = errors;
|
|
2108
2206
|
|
|
2109
2207
|
// Throw an error if the specifier is "lwc" or a versioned lwc specifier
|
|
2110
2208
|
// Dynamic import of LWC APIs is not allowed
|
|
@@ -2120,6 +2218,18 @@ LWR.define('lwr/loader/v/0_22_8', ['exports'], (function (exports) { 'use strict
|
|
|
2120
2218
|
throw new LoaderError(NO_IMPORT_LOADER, [_nullishCoalesce(importer, () => ( 'unknown'))]);
|
|
2121
2219
|
}
|
|
2122
2220
|
|
|
2221
|
+
// Throw an error if the specifier is "transport" or "webruntime/transport" (or versioned)
|
|
2222
|
+
// Dynamic import of transport exposes unsandboxed fetch, bypassing LWS
|
|
2223
|
+
// Reference: Hackforce report HF-3393
|
|
2224
|
+
if (
|
|
2225
|
+
id === 'transport' ||
|
|
2226
|
+
id.startsWith('transport/v/') ||
|
|
2227
|
+
id === 'webruntime/transport' ||
|
|
2228
|
+
id.startsWith('webruntime/transport/v/')
|
|
2229
|
+
) {
|
|
2230
|
+
throw new LoaderError(NO_IMPORT_TRANSPORT, [_nullishCoalesce(importer, () => ( 'unknown'))]);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2123
2233
|
// Throw an error if the specifier is a blob URL (case-insensitive check)
|
|
2124
2234
|
if (id.toLowerCase().startsWith('blob:')) {
|
|
2125
2235
|
throw new LoaderError(NO_BLOB_IMPORT);
|
|
@@ -2231,6 +2341,7 @@ LWR.define('lwr/loader/v/0_22_8', ['exports'], (function (exports) { 'use strict
|
|
|
2231
2341
|
LoaderError,
|
|
2232
2342
|
NO_IMPORT_LWC,
|
|
2233
2343
|
NO_IMPORT_LOADER,
|
|
2344
|
+
NO_IMPORT_TRANSPORT,
|
|
2234
2345
|
NO_BLOB_IMPORT,
|
|
2235
2346
|
});
|
|
2236
2347
|
return this.registry.load(id, importer);
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.22.
|
|
8
|
-
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function s(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=s(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:s,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:s,metadata:d,specifierIndex:l});else if(i){const e=n(r,s,l),t=a(s,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=n(r,l,d),t=s(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,i){const{autoBoot:s,customInit:n}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(s,n),n){n({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const p="function"==typeof setTimeout,u="undefined"!=typeof console;class h{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){h.prototype.__init.call(this),h.prototype.__init2.call(this),p&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_22_8",this.errorHandler=this.config.onError,this.initAppHandler=this.config.onInitApp;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(p&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{this.initAppHandler&&this.initAppHandler()}catch(e){console.error(`An error occurred in the onInitApp function. ${e.message}`,e.stack)}try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,flags:this.config.flags,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const i={};t[2].call(null,i);const{Loader:s}=i;if(!s)throw new Error("Expected Loader class to be defined");const n=new s(r);return o&&o.length&&n.registerExternalModules(o),n.define(e,["exports"],(e=>{Object.assign(e,{define:n.define.bind(n),load:n.load.bind(n),services:n.services})})),n}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_22_8",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:s,imports:n,index:a}=this.config,l=n||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:s,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{initDeferDOM:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():d?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):u&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{const e=this.config.requiredModules&&this.config.requiredModules.filter((e=>!this.orderedDefs.includes(e)))||[];this.enterErrorState(new Error(`Failed to load required modules - timed out: ${e.join(", ")}`))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const f=globalThis;f.LWR.requiredModules=f.LWR.requiredModules||[],f.LWR.requiredModules.indexOf("lwr/loader/v/0_22_8")<0&&f.LWR.requiredModules.push("lwr/loader/v/0_22_8"),new h(f)}(),LWR.define("lwr/loader/v/0_22_8",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'}),NO_IMPORT_LWC=Object.freeze({code:3023,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_IMPORT_LOADER=Object.freeze({code:3024,level:0,message:'Cannot dynamically import the LWR loader with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3024,level:0,message:"Cannot import a blob URL"});Object.freeze({code:3025,level:0,message:'Cannot dynamically import "transport" with importer "{0}"'}),Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const i=o.slice(0,o.lastIndexOf("/")+1)+e,s=[];let n=-1;for(let e=0;e<i.length;e++)-1!==n?"/"===i[e]&&(s.push(i.slice(n,e+1)),n=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:n=e:(s.pop(),e+=2):n=e;return-1!==n&&s.push(i.slice(n)),t.slice(0,t.length-o.length)+s.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const i=e[o],s=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==r)return;"access"===i||"optionalAccess"===i?(t=r,r=s(r)):"call"!==i&&"optionalCall"!==i||(r=s(((...e)=>r.call(t,...e))),t=void 0)}return r}class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}__init4(){this.batchSpecifiers=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),ImportMetadataResolver.prototype.__init4.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],s=this.importURICache.get(e);if(s){const t=i||o,r=s.identity||s.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],s=await i(e,{knownModules:r});if(s||void 0===s)return s}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if(!hasSetTimeout||!_optionalChain([this,"access",e=>e.config,"optionalAccess",e=>e.flags,"optionalAccess",e=>e.batchMappings]))return this.fetchNewMappingsInner(e);const t=()=>{const e=this.batchSpecifiers.join(",");return this.batchSpecifiers=[],clearTimeout(this.batchTimer),this.batchTimer=void 0,this.fetchNewMappingsInner(e)};return this.batchPromise&&0!==this.batchSpecifiers.length||(this.batchPromise=new Promise((e=>{this.batchTimer=setTimeout((()=>e(t())),0)}))),this.batchSpecifiers.push(e),this.batchPromise}async fetchNewMappingsInner(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e))})).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const s=e[t];try{if(null!==s({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
7
|
+
/* LWR Module Loader Shim v0.22.10 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,i=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function s(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d,specifierIndex:l});else if(i){const e=s(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(i){const e=s(r,l,d),t=n(r,l),i=a(l,c);o.measure(t,{start:e,detail:i}),o.clearMarks(e),o.clearMeasures(t)}}function c(e){const[,t,r]=e;if(Array.isArray(t)&&"function"==typeof r)return{deps:t,factory:r};if("function"==typeof t)return{deps:[],factory:t};throw new Error("Invalid module definition")}function p(e,t,r){if("exports"===e)return t;const o=r[e];if(!o)throw new Error(`Dependency "${e}" not found in defineCache for loader`);try{return function(e){const{deps:t,factory:r}=c(e);if(t.length>1||1===t.length&&"exports"!==t[0])throw new Error(`Loader dependencies must have no deps or only ['exports']; got [${t.join(", ")}]`);const o={},i=r(o);return void 0!==i?i:o}(o)}catch(t){const r=t instanceof Error?t.message:String(t);throw new Error(`Loader dependency "${e}" has invalid definition: ${r}`)}}function u(e,t,r){try{const{deps:e,factory:o}=function(e){const{deps:t,factory:r}=c(e);if(t.includes("exports"))return{deps:t,factory:r};const o=0===t.length;return{deps:["exports",...t],factory:(e,...t)=>{const i=o?r(e):r(...t);void 0!==i&&"object"==typeof i&&Object.assign(e,i)}}}(t),i={};return{factory:o,args:e.map((e=>p(e,i,r))),exportsObj:i}}catch(t){const r=t instanceof Error?t.message:String(t);throw new Error(`Expected loader with specifier "${e}" to be a module. ${r}`)}}function h(e,t,o,i){const{autoBoot:n,customInit:s}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,s),s){s({initializeApp:t,define:o,onBootstrapError:i,attachDispatcher:r},e)}}const f="function"==typeof setTimeout,g="undefined"!=typeof console;class E{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){E.prototype.__init.call(this),E.prototype.__init2.call(this),f&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderSpecifier="lwr/loader/v/0_22_10",this.errorHandler=this.config.onError,this.initAppHandler=this.config.onInitApp;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),h(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(f&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(f&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{this.initAppHandler&&this.initAppHandler()}catch(e){console.error(`An error occurred in the onInitApp function. ${e.message}`,e.stack)}try{const e={endpoints:this.config.endpoints,baseUrl:this.config.baseUrl,flags:this.config.flags,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o,i){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const n={};if(i){const{factory:r,args:o,exportsObj:s}=u(e,t,i);r(...o),Object.assign(n,s)}else t[2].call(null,n);const{Loader:s}=n;if(!s)throw new Error("Expected Loader class to be defined");const a=new s(r);return o&&o.length&&a.registerExternalModules(o),a.define(e,["exports"],(e=>{Object.assign(e,{define:a.define.bind(a),load:a.load.bind(a),services:a.services})})),a}(this.loaderSpecifier,this.defineCache[this.loaderSpecifier],e,this.config.preloadModules,this.defineCache);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_22_10",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}))}mountApp(e){const{bootstrapModule:t,rootComponent:r,rootComponents:o,serverData:i,endpoints:n,imports:s,index:a}=this.config,l=s||{};this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:o,serverData:i||{},endpoints:n,imports:l,index:a||{},env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderSpecifier&&e.define(...this.defineCache[t])}));const{initDeferDOM:d}=this.config;e.registerImportMappings({imports:l,index:a},[t,r]).then((()=>"undefined"==typeof window||"undefined"==typeof document?Promise.resolve():d?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):g&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{const e=this.config.requiredModules&&this.config.requiredModules.filter((e=>!this.orderedDefs.includes(e)))||[];this.enterErrorState(new Error(`Failed to load required modules - timed out: ${e.join(", ")}`))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const m=globalThis;m.LWR.requiredModules=m.LWR.requiredModules||[],m.LWR.requiredModules.indexOf("lwr/loader/v/0_22_10")<0&&m.LWR.requiredModules.push("lwr/loader/v/0_22_10"),new E(m)}(),LWR.define("lwr/loader/v/0_22_10",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"});Object.freeze({code:3008,level:0,message:"Error loading empty code for {0}"});const UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded:"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),NO_MAPPING_URL=Object.freeze({code:3019,level:0,message:"Mapping endpoint not set"}),BAD_IMPORT_METADATA=Object.freeze({code:3020,level:0,message:"Invalid import metadata: {0} {1}"}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was "{1}"'}),UNRESOLVEABLE_MAPPING_ERROR=Object.freeze({code:3022,level:0,message:'Unexpected undefined URI resolving mapping for "{0}"'}),NO_IMPORT_LWC=Object.freeze({code:3023,level:0,message:'Cannot dynamically import "lwc" with importer "{0}"'}),NO_IMPORT_LOADER=Object.freeze({code:3024,level:0,message:'Cannot dynamically import the LWR loader with importer "{0}"'}),NO_BLOB_IMPORT=Object.freeze({code:3024,level:0,message:"Cannot import a blob URL"}),NO_IMPORT_TRANSPORT=Object.freeze({code:3025,level:0,message:'Cannot dynamically import "transport" with importer "{0}"'});Object.freeze({code:3011,level:0,message:"import map is not valid"});const hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const i=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let s=-1;for(let e=0;e<i.length;e++)-1!==s?"/"===i[e]&&(n.push(i.slice(s,e+1)),s=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:s=e:(n.pop(),e+=2):s=e;return-1!==s&&n.push(i.slice(s)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasProcess&&process.env,hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`,MAPPINGS_FETCH=`${LOADER_PREFIX}mappings.fetch`,MAPPINGS_ERROR=`${LOADER_PREFIX}mappings.error`;function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const i=e[o],n=e[o+1];if(o+=2,("optionalAccess"===i||"optionalCall"===i)&&null==r)return;"access"===i||"optionalAccess"===i?(t=r,r=n(r)):"call"!==i&&"optionalCall"!==i||(r=n(((...e)=>r.call(t,...e))),t=void 0)}return r}class ImportMetadataResolver{__init(){this.importURICache=new Map}__init2(){this.pendingURICache=new Map}__init3(){this.loadMappingHooks=[]}__init4(){this.batchSpecifiers=[]}constructor(e,t){ImportMetadataResolver.prototype.__init.call(this),ImportMetadataResolver.prototype.__init2.call(this),ImportMetadataResolver.prototype.__init3.call(this),ImportMetadataResolver.prototype.__init4.call(this),this.config=e,this.invalidationCallback=t}addLoadMappingHook(e){this.loadMappingHooks.push(e)}getMappingEndpoint(){return this.config.endpoints&&this.config.endpoints.uris?this.config.endpoints.uris.mapping:void 0}getModifiersAsUrlParams(){const e=this.config.endpoints?this.config.endpoints.modifiers:void 0;if(e){return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}`}return""}buildMappingUrl(e){return`${this.getMappingEndpoint()}${encodeURIComponent(e)}${this.getModifiersAsUrlParams()}`}getBaseUrl(){return this.config.baseUrl||""}registerImportMappings(e,t){if(!t||0===t.length){const r=e?JSON.stringify(e):"undefined";throw new LoaderError(BAD_IMPORT_METADATA,[r,t?"[]":"undefined"])}if(!e)throw new LoaderError(BAD_IMPORT_METADATA,["undefined",JSON.stringify(t)]);if(!e.imports||0===Object.keys(e.imports).length)throw new LoaderError(BAD_IMPORT_METADATA,[JSON.stringify(e),JSON.stringify(t)]);const r=e.index||{};for(const[o,i]of Object.entries(e.imports))i.forEach((e=>{const i=r[e],n=this.importURICache.get(e);if(n){const t=i||o,r=n.identity||n.uri;r!==t&&this.invalidationCallback({name:e,oldUrl:r,newUrl:t})}else this.saveImportURIRecord(e,o,i,t.includes(e))}))}getURI(e){return this.importURICache&&this.importURICache.has(e)?resolveUrl(this.importURICache.get(e).uri,this.getBaseUrl()):void 0}resolveLocal(e){const t=this.getURI(e);return t||(isUrl(e)||e.startsWith("/")?e:void 0)}async resolve(e){let t=this.getURI(e);if(t)return t;if(isUrl(e)||e.startsWith("/"))return e;{const r=this.pendingURICache.get(e);if(r)return r;this.config.profiler.logOperationStart({id:MAPPINGS_FETCH,specifier:e});const o=(this.hasMappingHooks()?this.evaluateMappingHooks:this.fetchNewMappings).bind(this)(e).then((r=>{if(!r||!r.imports)throw new LoaderError(UNRESOLVED,[e]);if(this.registerImportMappings(r,[e]),t=this.getURI(e),!t)throw new LoaderError(UNRESOLVED,[e]);return this.config.profiler.logOperationEnd({id:MAPPINGS_FETCH,specifier:e}),t})).finally((()=>{this.pendingURICache.delete(e)}));return this.pendingURICache.set(e,o),o}}hasMappingHooks(){return this.loadMappingHooks.length>0}async evaluateMappingHooks(e){const t=this.loadMappingHooks;if(t.length){const r=Array.from(this.importURICache.keys());for(let o=0;o<t.length;o++){const i=t[o],n=await i(e,{knownModules:r});if(n||void 0===n)return n}}return this.fetchNewMappings(e)}async fetchNewMappings(e){if(!hasSetTimeout||!_optionalChain([this,"access",e=>e.config,"optionalAccess",e=>e.flags,"optionalAccess",e=>e.batchMappings]))return this.fetchNewMappingsInner(e);const t=()=>{const e=this.batchSpecifiers.join(",");return this.batchSpecifiers=[],clearTimeout(this.batchTimer),this.batchTimer=void 0,this.fetchNewMappingsInner(e)};return this.batchPromise&&0!==this.batchSpecifiers.length||(this.batchPromise=new Promise((e=>{this.batchTimer=setTimeout((()=>e(t())),0)}))),this.batchSpecifiers.push(e),this.batchPromise}async fetchNewMappingsInner(e){if("function"!=typeof globalThis.fetch)throw new LoaderError(UNRESOLVED,[e]);const t=resolveUrl(this.buildMappingUrl(e),this.getBaseUrl());if(!t)throw new LoaderError(UNRESOLVEABLE_MAPPING_ERROR,[e]);return globalThis.fetch(t).then((t=>{if(!t.ok)throw this.config.profiler.logOperationStart({id:MAPPINGS_ERROR,specifier:e}),new LoaderError(UNRESOLVED,[e]);return t.json().then((e=>e))})).catch((t=>{throw new LoaderError(UNRESOLVED,[e])}))}saveImportURIRecord(e,t,r,o){r&&t!==r?this.importURICache.set(e,{uri:t,identity:r,isRoot:o}):this.importURICache.set(e,{uri:t,isRoot:o})}}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldUrl:o,newUrl:i}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldUrl:o,newUrl:i}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
11
11
|
*/
|
|
12
|
-
const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[`empty code for ${id}`]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[`"${id}": ${e instanceof Error?e.message:String(e)}`])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[`"${id}": window error ${lastWindowError instanceof Error?lastWindowError.message:String(lastWindowError)}`]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const i=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,i=e;const s=this.resolveHook;if(s){for(let e=0;e<s.length;e++){const t=(0,s[e])(i,{parentUrl:r});let n;if((t||null===t)&&(n=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(n))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==n){if("string"==typeof n){if(resolveIfNotPlainOrUrl(n,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);i=n;continue}if(o=n&&n.url&&(resolveIfNotPlainOrUrl(n.url,r)||n.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(i)||!this.aliases.has(t))return t}}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getImportMetadataResolver(){return this.resolver}async getModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)if(isUrl(e)){const o=await r.instantiation,i=await this.resolve(t);if(isUrl(i)||o.name===i)return this.storeModuleAlias(t,i),r;{e=i;const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,i),r}}else if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}const o=this.getModuleDef(e,t),i=o.then((e=>{const t=(e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),s={id:e,originalId:t,module:Object.create(null),dependencyRecords:i,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,s),e!==t&&this.storeModuleAlias(t,e),i.then((()=>s))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,t=await this.resolve(e))}return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return this.evaluateModule(e,{})}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:i}=await e.instantiation,s={},n=i?await Promise.all(i.map((async e=>{if("exports"===e)return s;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...n)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(s)&&Object.defineProperty(s,"__useDefault",{value:!0});const l=a||s;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const i=this.resolver.getBaseUrl(),s=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:s}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,i),s=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===s)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(s&&null!==s)return evaluateLoadHookResponse(s,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:s}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:s}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o&&evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}function _nullishCoalesce(e,t){return null!=e?e:t()}function validateLoadSpecifier(e,t,r,o){const{LoaderError:i,NO_IMPORT_LWC:s,NO_IMPORT_LOADER:n,NO_BLOB_IMPORT:a}=o;if("lwc"===e||e.startsWith("lwc/v/"))throw new i(s,[_nullishCoalesce(t,(()=>"unknown"))]);if(e===r||e.startsWith(`${r}/v/`))throw new i(n,[_nullishCoalesce(t,(()=>"unknown"))]);if(e.toLowerCase().startsWith("blob:"))throw new i(a)}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o,flags:e.flags||{}})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=r}this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}async load(e,t){return validateLoadSpecifier(e,t,"lwr/loader",{LoaderError:LoaderError,NO_IMPORT_LWC:NO_IMPORT_LWC,NO_IMPORT_LOADER:NO_IMPORT_LOADER,NO_BLOB_IMPORT:NO_BLOB_IMPORT}),this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
12
|
+
const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[`empty code for ${id}`]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[`"${id}": ${e instanceof Error?e.message:String(e)}`])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[`"${id}": window error ${lastWindowError instanceof Error?lastWindowError.message:String(lastWindowError)}`]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const i=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(i)}))})):t}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.profiler=e.profiler,this.resolver=new ImportMetadataResolver(e,this.importMetadataInvalidationCallback.bind(this)),this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),i=await this.getModuleRecord(o,e);return i.evaluated?i.module:(i.evaluationPromise||(i.evaluationPromise=this.topLevelEvaluation(i)),i.evaluationPromise)}async resolve(e,t){const r=this.resolver.getBaseUrl();let o,i=e;const n=this.resolveHook;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(i,{parentUrl:r});let s;if((t||null===t)&&(s=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(s))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==s){if("string"==typeof s){if(resolveIfNotPlainOrUrl(s,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);i=s;continue}if(o=s&&s.url&&(resolveIfNotPlainOrUrl(s.url,r)||s.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(i!==e){if(!o&&this.namedDefineRegistry.has(i))return i;e=i}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;const i=this.resolver.resolveLocal(t);if(i){if(this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(i)||!this.aliases.has(t))return t}}return i}if(this.namedDefineRegistry.has(t))return t;try{o=await this.resolver.resolve(t)}catch(e){}}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r){const o=this.namedDefineRegistry.get(e);if(o&&o.defined)return void(this.lastDefine=o);const i={name:e,dependencies:t,exporter:r,defined:!0};o&&o.external&&o.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,i)=>{t=o,r=setTimeout((()=>{i(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),i={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,i)}}))}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getImportMetadataResolver(){return this.resolver}async getModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)if(isUrl(e)){const o=await r.instantiation,i=await this.resolve(t);if(isUrl(i)||o.name===i)return this.storeModuleAlias(t,i),r;{e=i;const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,i),r}}else if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}const o=this.getModuleDef(e,t),i=o.then((e=>{const t=(e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,originalId:t,module:Object.create(null),dependencyRecords:i,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),e!==t&&this.storeModuleAlias(t,e),i.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,t=await this.resolve(e))}return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return this.evaluateModule(e,{})}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:i}=await e.instantiation,n={},s=i?await Promise.all(i.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...s)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const i=this.resolver.getBaseUrl(),n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,i),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r,loadMapping:o}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t]),o&&this.resolver.addLoadMappingHook(o)}importMetadataInvalidationCallback({name:e,oldUrl:t,newUrl:r}){const o=this.handleStaleModuleHook;o&&evaluateHandleStaleModuleHooks(o,{name:e,oldUrl:t,newUrl:r})}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}function _nullishCoalesce(e,t){return null!=e?e:t()}function validateLoadSpecifier(e,t,r,o){const{LoaderError:i,NO_IMPORT_LWC:n,NO_IMPORT_LOADER:s,NO_IMPORT_TRANSPORT:a,NO_BLOB_IMPORT:l}=o;if("lwc"===e||e.startsWith("lwc/v/"))throw new i(n,[_nullishCoalesce(t,(()=>"unknown"))]);if(e===r||e.startsWith(`${r}/v/`))throw new i(s,[_nullishCoalesce(t,(()=>"unknown"))]);if("transport"===e||e.startsWith("transport/v/")||"webruntime/transport"===e||e.startsWith("webruntime/transport/v/"))throw new i(a,[_nullishCoalesce(t,(()=>"unknown"))]);if(e.toLowerCase().startsWith("blob:"))throw new i(l)}class Loader{constructor(e){let t=e.baseUrl;const r=e.endpoints?e.endpoints.uris.mapping:void 0;let o=e.profiler;if(!r||!e.endpoints)throw new LoaderError(NO_MAPPING_URL);if(e.endpoints.uris.mapping=r.replace(/\/?$/,"/"),t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);if(o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry(Object.freeze({endpoints:e.endpoints,baseUrl:t,profiler:o,flags:e.flags||{}})),e.appMetadata&&!e.appMetadata.appId){const t=e.appMetadata.bootstrapModule.match(/@lwr-bootstrap\/(.+)\/v\/.+/),r=t&&t[1];e.appMetadata.appId=r}this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata})}define(e,t,r){invariant("string"==typeof e,MISSING_NAME);let o=r,i=t;"function"==typeof i&&(o=t,i=[]),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,o)}async load(e,t){return validateLoadSpecifier(e,t,"lwr/loader",{LoaderError:LoaderError,NO_IMPORT_LWC:NO_IMPORT_LWC,NO_IMPORT_LOADER:NO_IMPORT_LOADER,NO_IMPORT_TRANSPORT:NO_IMPORT_TRANSPORT,NO_BLOB_IMPORT:NO_BLOB_IMPORT}),this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e,t){this.registry.getImportMetadataResolver().registerImportMappings(e,t)}registerExternalModules(e){this.registry.registerExternalModules(e)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Module Loader Shim v0.22.
|
|
7
|
+
/* LWR Module Loader Shim v0.22.10 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -105,19 +105,114 @@
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Parse AMD define args. Supports define(id, deps, factory).
|
|
110
|
+
*/
|
|
111
|
+
function parseDefine(def) {
|
|
112
|
+
const [, depsOrFactory, factory] = def;
|
|
113
|
+
if (Array.isArray(depsOrFactory) && typeof factory === 'function') {
|
|
114
|
+
return { deps: depsOrFactory, factory };
|
|
115
|
+
}
|
|
116
|
+
if (typeof depsOrFactory === 'function') {
|
|
117
|
+
return { deps: [], factory: depsOrFactory };
|
|
118
|
+
}
|
|
119
|
+
throw new Error('Invalid module definition');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Resolve a loader dependency: 'exports' returns the bag; otherwise look up in cache and instantiate.
|
|
124
|
+
* Loader deps are assumed to be leaf modules (no deps of their own)—no recursive resolution.
|
|
125
|
+
*/
|
|
126
|
+
function resolveDep(dep, exportsObj, cache) {
|
|
127
|
+
if (dep === 'exports') return exportsObj;
|
|
128
|
+
const mod = cache[dep];
|
|
129
|
+
if (!mod) {
|
|
130
|
+
throw new Error(`Dependency "${dep}" not found in defineCache for loader`);
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
return instantiateLeafModule(mod);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
136
|
+
throw new Error(`Loader dependency "${dep}" has invalid definition: ${msg}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Instantiate a leaf module (loader dep). Assumes the module has no dependencies of its own.
|
|
142
|
+
* Supports only deps: [] or ['exports']; any other dep list throws.
|
|
143
|
+
*/
|
|
144
|
+
function instantiateLeafModule(def) {
|
|
145
|
+
const { deps, factory } = parseDefine(def);
|
|
146
|
+
if (deps.length > 1 || (deps.length === 1 && deps[0] !== 'exports')) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Loader dependencies must have no deps or only ['exports']; got [${deps.join(', ')}]`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const exports = {};
|
|
152
|
+
const out = factory(exports);
|
|
153
|
+
return out !== undefined ? out : exports;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Normalize loader definition to canonical (exports, ...deps). Injects 'exports' if missing.
|
|
158
|
+
*/
|
|
159
|
+
function normalizeLoaderDefinition(def) {
|
|
160
|
+
const { deps, factory } = parseDefine(def);
|
|
161
|
+
if (deps.includes('exports')) {
|
|
162
|
+
return { deps, factory };
|
|
163
|
+
}
|
|
164
|
+
const isEmptyDeps = deps.length === 0;
|
|
165
|
+
const normalizedFactory = (exports, ...rest) => {
|
|
166
|
+
const result = isEmptyDeps ? factory(exports) : factory(...rest);
|
|
167
|
+
if (result !== undefined && typeof result === 'object') {
|
|
168
|
+
Object.assign(exports, result);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return { deps: ['exports', ...deps], factory: normalizedFactory };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Resolve the loader's dependencies from defineCache. Throws if definition is invalid or deps cannot be resolved.
|
|
176
|
+
*/
|
|
177
|
+
function resolveLoaderDepsFromDefineCache(
|
|
178
|
+
loaderSpecifier,
|
|
179
|
+
definition,
|
|
180
|
+
defineCache,
|
|
181
|
+
) {
|
|
182
|
+
try {
|
|
183
|
+
const { deps, factory } = normalizeLoaderDefinition(definition);
|
|
184
|
+
const exportsObj = {};
|
|
185
|
+
const args = deps.map((dep) => resolveDep(dep, exportsObj, defineCache)) ;
|
|
186
|
+
return { factory: factory , args, exportsObj };
|
|
187
|
+
} catch (e) {
|
|
188
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
189
|
+
throw new Error(`Expected loader with specifier "${loaderSpecifier}" to be a module. ${msg}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Create a loader from a definition. Original API preserved.
|
|
195
|
+
* Optional defineCache for resolving loader deps (when loader has dependencies).
|
|
196
|
+
*/
|
|
108
197
|
function createLoader(
|
|
109
198
|
name,
|
|
110
199
|
definition,
|
|
111
200
|
config,
|
|
112
201
|
externalModules,
|
|
202
|
+
defineCache,
|
|
113
203
|
) {
|
|
114
204
|
if (!definition || typeof definition[2] !== 'function') {
|
|
115
205
|
throw new Error(`Expected loader with specifier "${name}" to be a module`);
|
|
116
206
|
}
|
|
117
207
|
|
|
118
|
-
// Create a Loader instance
|
|
119
208
|
const exports = {};
|
|
120
|
-
|
|
209
|
+
if (defineCache) {
|
|
210
|
+
const { factory, args, exportsObj } = resolveLoaderDepsFromDefineCache(name, definition, defineCache);
|
|
211
|
+
factory(...args);
|
|
212
|
+
Object.assign(exports, exportsObj);
|
|
213
|
+
} else {
|
|
214
|
+
definition[2].call(null, exports);
|
|
215
|
+
}
|
|
121
216
|
const { Loader } = exports;
|
|
122
217
|
if (!Loader) {
|
|
123
218
|
throw new Error('Expected Loader class to be defined');
|
|
@@ -214,7 +309,7 @@
|
|
|
214
309
|
// Parse configuration
|
|
215
310
|
this.global = global;
|
|
216
311
|
this.config = global.LWR ;
|
|
217
|
-
this.loaderSpecifier = 'lwr/loader/v/
|
|
312
|
+
this.loaderSpecifier = 'lwr/loader/v/0_22_10';
|
|
218
313
|
|
|
219
314
|
// Set up error handler
|
|
220
315
|
this.errorHandler = this.config.onError ;
|
|
@@ -322,6 +417,7 @@
|
|
|
322
417
|
this.defineCache[this.loaderSpecifier],
|
|
323
418
|
loaderConfig,
|
|
324
419
|
this.config.preloadModules,
|
|
420
|
+
this.defineCache,
|
|
325
421
|
);
|
|
326
422
|
this.mountApp(loader);
|
|
327
423
|
if (
|
|
@@ -345,6 +441,7 @@
|
|
|
345
441
|
if (document.body) {
|
|
346
442
|
resolve();
|
|
347
443
|
} else {
|
|
444
|
+
/* istanbul ignore next */
|
|
348
445
|
const observer = new MutationObserver(() => {
|
|
349
446
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
350
447
|
if (document.body) {
|
|
@@ -377,7 +474,7 @@
|
|
|
377
474
|
const exporter = (exports) => {
|
|
378
475
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
379
476
|
};
|
|
380
|
-
define('lwr/profiler/v/
|
|
477
|
+
define('lwr/profiler/v/0_22_10', ['exports'], exporter);
|
|
381
478
|
}
|
|
382
479
|
|
|
383
480
|
// Set up the application globals, import map, root custom element...
|
|
@@ -417,7 +514,7 @@
|
|
|
417
514
|
])
|
|
418
515
|
.then(() => {
|
|
419
516
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
420
|
-
if (typeof window === 'undefined' || typeof document === undefined) {
|
|
517
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
421
518
|
return Promise.resolve();
|
|
422
519
|
}
|
|
423
520
|
if (initDeferDOM) {
|
|
@@ -477,8 +574,8 @@
|
|
|
477
574
|
// The loader module is ALWAYS required
|
|
478
575
|
const GLOBAL = globalThis ;
|
|
479
576
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
480
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
481
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
577
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_22_10') < 0) {
|
|
578
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_22_10');
|
|
482
579
|
}
|
|
483
580
|
new LoaderShim(GLOBAL);
|
|
484
581
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let i,o=t[0],e=1;for(;e<t.length;){const n=t[e],s=t[e+1];if(e+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(i=o,o=s(o)):"call"!==n&&"optionalCall"!==n||(o=s(((...t)=>o.call(i,...t))),i=void 0)}return o}class i{__init(){this.importURICache=new Map}__init2(){this.modifiers=""}constructor(o){i.prototype.__init.call(this),i.prototype.__init2.call(this),this.normalizeMetadata(o),this.mappingEndpoint=t([o,"optionalAccess",t=>t.importMappings])?void 0:t([o,"optionalAccess",t=>t.endpoints,"optionalAccess",t=>t.uris,"access",t=>t.mapping]),t([o,"optionalAccess",t=>t.endpoints,"optionalAccess",t=>t.modifiers])&&(this.modifiers=Object.entries(o.endpoints.modifiers).reduce(((t,[i,o])=>t+`${i}=${o}&`),"?"))}normalizeMetadata(t){if(t&&t.imports)for(const[i,o]of Object.entries(t.imports))if(i&&o){(Array.isArray(o)?o:[]).forEach((t=>{this.importURICache.set(t,i)}))}}async fetchMappings(t){const i=`${this.mappingEndpoint}${encodeURIComponent(t)}${this.modifiers}`,o=await globalThis.fetch(i);if(o.ok){const t=await o.json();this.normalizeMetadata(t)}}async resolve(t){let i=this.importURICache.get(t);return!i&&this.mappingEndpoint&&(await this.fetchMappings(t),i=this.importURICache.get(t)),i}}class o{constructor(t){this.importURICache=t&&t.imports?t:{imports:{}}}legacyResolve(t){return this.importURICache&&this.importURICache.imports&&this.importURICache.imports[t]}}let e,n,s;function r(t){e=t;const{imports:r,index:a,importMappings:c,endpoints:p}=t;n=new i({imports:r,index:a,endpoints:p,importMappings:c}),s=new o(c)}async function a(t,i){const o=await async function(t,i){if(t.includes("://")||t.startsWith("/"))return t;if(!n||!s)throw new Error("The ESM Loader was not initialized");if(n){const i=await n.resolve(t);if(i)return i}if(s){const i=s.legacyResolve(t);if(i)return i}const{endpoints:o}=e;if(!function(t){let i,o=t[0],e=1;for(;e<t.length;){const n=t[e],s=t[e+1];if(e+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(i=o,o=s(o)):"call"!==n&&"optionalCall"!==n||(o=s(((...t)=>o.call(i,...t))),i=void 0)}return o}([o,"optionalAccess",t=>t.uris,"optionalAccess",t=>t.module]))throw new Error(`Unable to resolve the URL for "${t}"`);let r=o.uris.module+encodeURIComponent(t);i&&(r+=`?importer=${encodeURIComponent(i)}`);o.modifiers&&(r+=Object.entries(o.modifiers).reduce(((t,[i,o])=>t+`${i}=${o}&`),i?"&":"?"));return r}(t,i);return import(o)}export{r as init,a as load};
|
|
1
|
+
function t(t){let i,o=t[0],e=1;for(;e<t.length;){const n=t[e],s=t[e+1];if(e+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(i=o,o=s(o)):"call"!==n&&"optionalCall"!==n||(o=s(((...t)=>o.call(i,...t))),i=void 0)}return o}class i{__init(){this.importURICache=new Map}__init2(){this.modifiers=""}constructor(o){i.prototype.__init.call(this),i.prototype.__init2.call(this),this.normalizeMetadata(o),this.mappingEndpoint=t([o,"optionalAccess",t=>t.importMappings])?void 0:t([o,"optionalAccess",t=>t.endpoints,"optionalAccess",t=>t.uris,"access",t=>t.mapping]),t([o,"optionalAccess",t=>t.endpoints,"optionalAccess",t=>t.modifiers])&&(this.modifiers=Object.entries(o.endpoints.modifiers).reduce(((t,[i,o])=>t+`${i}=${o}&`),"?"))}normalizeMetadata(t){if(t&&t.imports)for(const[i,o]of Object.entries(t.imports))if(i&&o){(Array.isArray(o)?o:[]).forEach((t=>{this.importURICache.set(t,i)}))}}async fetchMappings(t){const i=`${this.mappingEndpoint}${encodeURIComponent(t)}${this.modifiers}`,o=await globalThis.fetch(i);if(o.ok){const t=await o.json();this.normalizeMetadata(t)}}async resolve(t){let i=this.importURICache.get(t);return!i&&this.mappingEndpoint&&(await this.fetchMappings(t),i=this.importURICache.get(t)),i}}class o{constructor(t){this.importURICache=t&&t.imports?t:{imports:{}}}legacyResolve(t){return this.importURICache&&this.importURICache.imports&&this.importURICache.imports[t]}}let e,n,s;function r(t){e=t;const{imports:r,index:a,importMappings:c,endpoints:p}=t;n=new i({imports:r,index:a,endpoints:p,importMappings:c}),s=new o(c)}async function a(t,i){const o=await async function(t,i){if(t.includes("://")||t.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(t))return t;if(!n||!s)throw new Error("The ESM Loader was not initialized");if(n){const i=await n.resolve(t);if(i)return i}if(s){const i=s.legacyResolve(t);if(i)return i}const{endpoints:o}=e;if(!function(t){let i,o=t[0],e=1;for(;e<t.length;){const n=t[e],s=t[e+1];if(e+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(i=o,o=s(o)):"call"!==n&&"optionalCall"!==n||(o=s(((...t)=>o.call(i,...t))),i=void 0)}return o}([o,"optionalAccess",t=>t.uris,"optionalAccess",t=>t.module]))throw new Error(`Unable to resolve the URL for "${t}"`);let r=o.uris.module+encodeURIComponent(t);i&&(r+=`?importer=${encodeURIComponent(i)}`);o.modifiers&&(r+=Object.entries(o.modifiers).reduce(((t,[i,o])=>t+`${i}=${o}&`),i?"&":"?"));return r}(t,i);return import(o)}export{r as init,a as load};
|
|
@@ -43,7 +43,7 @@ async function load(specifier, importer) {
|
|
|
43
43
|
return Promise.resolve().then(() => __toModule(require(uri)));
|
|
44
44
|
}
|
|
45
45
|
async function resolveUrl(specifier, importer) {
|
|
46
|
-
if (specifier.includes("://") || specifier.startsWith("/")) {
|
|
46
|
+
if (specifier.includes("://") || specifier.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(specifier)) {
|
|
47
47
|
return specifier;
|
|
48
48
|
}
|
|
49
49
|
if (!resolver || !resolverLegacy) {
|
|
@@ -11,13 +11,16 @@ __export(exports, {
|
|
|
11
11
|
validateLoadSpecifier: () => validateLoadSpecifier
|
|
12
12
|
});
|
|
13
13
|
function validateLoadSpecifier(id, importer, loaderSpecifier, errors) {
|
|
14
|
-
const {LoaderError, NO_IMPORT_LWC, NO_IMPORT_LOADER, NO_BLOB_IMPORT} = errors;
|
|
14
|
+
const {LoaderError, NO_IMPORT_LWC, NO_IMPORT_LOADER, NO_IMPORT_TRANSPORT, NO_BLOB_IMPORT} = errors;
|
|
15
15
|
if (id === "lwc" || id.startsWith("lwc/v/")) {
|
|
16
16
|
throw new LoaderError(NO_IMPORT_LWC, [importer ?? "unknown"]);
|
|
17
17
|
}
|
|
18
18
|
if (id === loaderSpecifier || id.startsWith(`${loaderSpecifier}/v/`)) {
|
|
19
19
|
throw new LoaderError(NO_IMPORT_LOADER, [importer ?? "unknown"]);
|
|
20
20
|
}
|
|
21
|
+
if (id === "transport" || id.startsWith("transport/v/") || id === "webruntime/transport" || id.startsWith("webruntime/transport/v/")) {
|
|
22
|
+
throw new LoaderError(NO_IMPORT_TRANSPORT, [importer ?? "unknown"]);
|
|
23
|
+
}
|
|
21
24
|
if (id.toLowerCase().startsWith("blob:")) {
|
|
22
25
|
throw new LoaderError(NO_BLOB_IMPORT);
|
|
23
26
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR ESM Module Loader v0.22.
|
|
7
|
+
/* LWR ESM Module Loader v0.22.10 */
|
|
8
8
|
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
9
9
|
|
|
10
10
|
|
|
@@ -109,7 +109,7 @@ async function load(specifier, importer) {
|
|
|
109
109
|
|
|
110
110
|
async function resolveUrl(specifier, importer) {
|
|
111
111
|
// HMR imports complete URIs when swapping out modules
|
|
112
|
-
if (specifier.includes('://') || specifier.startsWith('/')) {
|
|
112
|
+
if (specifier.includes('://') || specifier.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(specifier)) {
|
|
113
113
|
return specifier;
|
|
114
114
|
}
|
|
115
115
|
|