@lwrjs/loader 0.12.0-alpha.9 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +168 -133
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim-legacy.js +6 -5
- package/build/assets/prod/lwr-loader-shim.bundle.js +167 -134
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +6 -5
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +88 -68
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +88 -68
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +161 -129
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +162 -128
- package/package.json +7 -7
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Error Shim v0.12.
|
|
7
|
+
/* LWR Error Shim v0.12.1 */
|
|
8
8
|
!function(){"use strict";if(!(globalThis.LWR&&globalThis.LWR.define)){const o=new Error("The LWR application failed to bootstrap");if(!globalThis.LWR||!globalThis.LWR.onError)throw o;globalThis.LWR.onError(o)}}();
|
|
@@ -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.12.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.12.1 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
// Parse configuration
|
|
208
208
|
this.global = global;
|
|
209
209
|
this.config = global.LWR ;
|
|
210
|
-
this.loaderModule = 'lwr/loaderLegacy/v/
|
|
210
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_12_1';
|
|
211
211
|
|
|
212
212
|
// Set up error handler
|
|
213
213
|
this.errorHandler = this.config.onError;
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
const exporter = (exports) => {
|
|
328
328
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
329
329
|
};
|
|
330
|
-
globalLWR.define('lwr/profiler/v/
|
|
330
|
+
globalLWR.define('lwr/profiler/v/0_12_1', ['exports'], exporter, {});
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
// Set up the application globals, import map, root custom element...
|
|
@@ -343,6 +343,7 @@
|
|
|
343
343
|
serverData,
|
|
344
344
|
importMappings,
|
|
345
345
|
endpoints,
|
|
346
|
+
env: this.global.LWR.env,
|
|
346
347
|
});
|
|
347
348
|
|
|
348
349
|
// Redefine all modules in the temporary cache
|
|
@@ -398,14 +399,14 @@
|
|
|
398
399
|
// The loader module is ALWAYS required
|
|
399
400
|
const GLOBAL = globalThis ;
|
|
400
401
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
401
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
402
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
402
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_12_1') < 0) {
|
|
403
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_12_1');
|
|
403
404
|
}
|
|
404
405
|
new LoaderShim(GLOBAL);
|
|
405
406
|
|
|
406
407
|
})();
|
|
407
408
|
|
|
408
|
-
LWR.define('lwr/loaderLegacy/v/
|
|
409
|
+
LWR.define('lwr/loaderLegacy/v/0_12_1', ['exports'], (function (exports) { 'use strict';
|
|
409
410
|
|
|
410
411
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
411
412
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -779,7 +780,7 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
779
780
|
// swallow
|
|
780
781
|
}
|
|
781
782
|
const trusted = createPolicy('trusted', policyOptions);
|
|
782
|
-
/*! version: 0.21.
|
|
783
|
+
/*! version: 0.21.4 */
|
|
783
784
|
|
|
784
785
|
/* global console,process */
|
|
785
786
|
|
|
@@ -974,32 +975,19 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
974
975
|
|
|
975
976
|
|
|
976
977
|
|
|
978
|
+
|
|
979
|
+
|
|
977
980
|
|
|
978
981
|
|
|
979
982
|
|
|
980
983
|
class ModuleRegistry {
|
|
981
984
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
985
|
-
__init() {this.namedDefineRegistry = new Map();}
|
|
986
|
-
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
987
|
-
__init2() {this.moduleRegistry = new Map();}
|
|
988
|
-
// Aliases of modules in the registry
|
|
989
|
-
__init3() {this.aliases = new Map();}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
985
|
|
|
995
986
|
constructor(config) {ModuleRegistry.prototype.__init.call(this);ModuleRegistry.prototype.__init2.call(this);ModuleRegistry.prototype.__init3.call(this);
|
|
996
987
|
this.baseUrl = config.baseUrl || '';
|
|
997
988
|
this.profiler = config.profiler;
|
|
998
989
|
}
|
|
999
990
|
|
|
1000
|
-
/**
|
|
1001
|
-
* Module import
|
|
1002
|
-
*/
|
|
1003
991
|
async load(id, importer) {
|
|
1004
992
|
const metadata = importer ? { importer } : {};
|
|
1005
993
|
this.profiler.logOperationStart({
|
|
@@ -1008,21 +996,17 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1008
996
|
metadata,
|
|
1009
997
|
});
|
|
1010
998
|
const resolvedId = await this.resolve(id, importer);
|
|
1011
|
-
const moduleRecord = this.getModuleRecord(resolvedId, id);
|
|
1012
|
-
|
|
999
|
+
const moduleRecord = await this.getModuleRecord(resolvedId, id);
|
|
1013
1000
|
if (moduleRecord.evaluated) {
|
|
1014
1001
|
return moduleRecord.module;
|
|
1015
1002
|
} else {
|
|
1016
1003
|
if (!moduleRecord.evaluationPromise) {
|
|
1017
|
-
moduleRecord.evaluationPromise = this.
|
|
1004
|
+
moduleRecord.evaluationPromise = this.topLevelEvaluation(moduleRecord);
|
|
1018
1005
|
}
|
|
1019
1006
|
return moduleRecord.evaluationPromise;
|
|
1020
1007
|
}
|
|
1021
1008
|
}
|
|
1022
1009
|
|
|
1023
|
-
/**
|
|
1024
|
-
* Resolve id for a module
|
|
1025
|
-
*/
|
|
1026
1010
|
async resolve(id, importer) {
|
|
1027
1011
|
const parentUrl = this.baseUrl; // only support baseUrl for now
|
|
1028
1012
|
|
|
@@ -1039,7 +1023,7 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1039
1023
|
// eslint-disable-next-line no-await-in-loop
|
|
1040
1024
|
result = isResponseAPromise(response) ? await response : response;
|
|
1041
1025
|
}
|
|
1042
|
-
if (!isValidResolveResponse(result)) {
|
|
1026
|
+
if (!this.isValidResolveResponse(result)) {
|
|
1043
1027
|
throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
|
|
1044
1028
|
}
|
|
1045
1029
|
|
|
@@ -1120,9 +1104,6 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1120
1104
|
return this.moduleRegistry.has(id);
|
|
1121
1105
|
}
|
|
1122
1106
|
|
|
1123
|
-
/**
|
|
1124
|
-
* Module entry point LWR.define()
|
|
1125
|
-
*/
|
|
1126
1107
|
define(
|
|
1127
1108
|
name,
|
|
1128
1109
|
dependencies,
|
|
@@ -1237,10 +1218,24 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1237
1218
|
}
|
|
1238
1219
|
}
|
|
1239
1220
|
|
|
1221
|
+
|
|
1240
1222
|
setImportResolver(resolver) {
|
|
1241
1223
|
this.resolver = resolver;
|
|
1242
1224
|
}
|
|
1243
1225
|
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
1229
|
+
__init() {this.namedDefineRegistry = new Map();}
|
|
1230
|
+
|
|
1231
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
1232
|
+
__init2() {this.moduleRegistry = new Map();}
|
|
1233
|
+
|
|
1234
|
+
// Aliases of modules in the registry
|
|
1235
|
+
__init3() {this.aliases = new Map();}
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1244
1239
|
// Returns an existing module record by the resolvedId or aliased id
|
|
1245
1240
|
getExistingModuleRecord(resolvedId, aliasId) {
|
|
1246
1241
|
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
@@ -1262,8 +1257,7 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1262
1257
|
return moduleRecord;
|
|
1263
1258
|
}
|
|
1264
1259
|
|
|
1265
|
-
|
|
1266
|
-
getModuleRecord(resolvedId, id) {
|
|
1260
|
+
async getModuleRecord(resolvedId, id) {
|
|
1267
1261
|
// Look for an existing record
|
|
1268
1262
|
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
1269
1263
|
if (existingRecord) {
|
|
@@ -1271,17 +1265,37 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1271
1265
|
return existingRecord;
|
|
1272
1266
|
}
|
|
1273
1267
|
|
|
1268
|
+
// Create a new Module Record
|
|
1269
|
+
const instantiation = this.getModuleDef(resolvedId, id);
|
|
1270
|
+
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
1271
|
+
const dependencies = (moduleDef && moduleDef.dependencies) || [];
|
|
1272
|
+
// get dep and filter out exports
|
|
1273
|
+
const filtered = dependencies
|
|
1274
|
+
.map((dep) => {
|
|
1275
|
+
if (dep === 'exports') {
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
invariant(dep !== 'require', NO_AMD_REQUIRE);
|
|
1279
|
+
return this.getModuleDependencyRecord.call(this, dep);
|
|
1280
|
+
})
|
|
1281
|
+
.filter((depRecord) => depRecord !== undefined) ;
|
|
1282
|
+
|
|
1283
|
+
return Promise.all(filtered);
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1274
1286
|
const newModuleRecord = {
|
|
1275
1287
|
id: resolvedId,
|
|
1276
1288
|
module: Object.create(null),
|
|
1277
|
-
|
|
1289
|
+
dependencyRecords,
|
|
1290
|
+
instantiation,
|
|
1278
1291
|
evaluated: false,
|
|
1279
1292
|
evaluationPromise: null,
|
|
1280
1293
|
};
|
|
1281
1294
|
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
1282
1295
|
this.storeModuleAlias(id, resolvedId);
|
|
1283
1296
|
|
|
1284
|
-
return
|
|
1297
|
+
// Wait for the dependencies to resolve the return the moduleRecord
|
|
1298
|
+
return dependencyRecords.then(() => newModuleRecord);
|
|
1285
1299
|
}
|
|
1286
1300
|
|
|
1287
1301
|
storeModuleAlias(aliasId, resolvedId) {
|
|
@@ -1301,85 +1315,96 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1301
1315
|
}
|
|
1302
1316
|
}
|
|
1303
1317
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
async evaluateDependencies(
|
|
1308
|
-
dependencies,
|
|
1309
|
-
evaluationMap,
|
|
1310
|
-
) {
|
|
1311
|
-
const exports = {};
|
|
1312
|
-
const promiseArray = [];
|
|
1313
|
-
if (dependencies) {
|
|
1314
|
-
for (const dep of dependencies) {
|
|
1315
|
-
if (dep === 'exports') {
|
|
1316
|
-
promiseArray.push(Promise.resolve(exports));
|
|
1317
|
-
} else {
|
|
1318
|
-
invariant(dep !== 'require', NO_AMD_REQUIRE);
|
|
1319
|
-
promiseArray.push(this.evaluateDependent(dep, evaluationMap));
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
return Promise.all(promiseArray).then((results) => {
|
|
1325
|
-
const depsMapped = results.filter((result) => result !== undefined);
|
|
1326
|
-
return { depsMapped, exports };
|
|
1327
|
-
});
|
|
1318
|
+
async getModuleDependencyRecord(dependency) {
|
|
1319
|
+
const resolvedDepId = await this.resolve(dependency);
|
|
1320
|
+
return this.getModuleRecord(resolvedDepId, dependency);
|
|
1328
1321
|
}
|
|
1329
1322
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
const handleReturn = (module) => {
|
|
1336
|
-
if (module) {
|
|
1337
|
-
return module.__defaultInterop ? module.default : module;
|
|
1338
|
-
}
|
|
1339
|
-
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1340
|
-
};
|
|
1323
|
+
// execute the "top-level code" (the code outside of functions) of a module
|
|
1324
|
+
async topLevelEvaluation(moduleRecord) {
|
|
1325
|
+
await this.instantiateAll(moduleRecord, {});
|
|
1326
|
+
return this.evaluateModule(moduleRecord, {});
|
|
1327
|
+
}
|
|
1341
1328
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1329
|
+
// Returns a promise when a module and all of it's dependencies have finished instantiation
|
|
1330
|
+
async instantiateAll(
|
|
1331
|
+
moduleRecord,
|
|
1332
|
+
instantiatedMap,
|
|
1333
|
+
) {
|
|
1334
|
+
if (!instantiatedMap[moduleRecord.id]) {
|
|
1335
|
+
instantiatedMap[moduleRecord.id] = true;
|
|
1336
|
+
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
1337
|
+
if (dependencyModuleRecords) {
|
|
1338
|
+
for (let i = 0; i < dependencyModuleRecords.length; i++) {
|
|
1339
|
+
const depRecord = dependencyModuleRecords[i];
|
|
1340
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1341
|
+
await this.instantiateAll(depRecord, instantiatedMap);
|
|
1342
|
+
}
|
|
1356
1343
|
}
|
|
1357
|
-
return depModuleRecord.evaluationPromise.then((module) => {
|
|
1358
|
-
return handleReturn(module);
|
|
1359
|
-
});
|
|
1360
|
-
} else {
|
|
1361
|
-
// Otherwise return a dummy circular module wrapper
|
|
1362
|
-
module = getCircularDependencyWrapper(module);
|
|
1363
1344
|
}
|
|
1364
|
-
return handleReturn(module);
|
|
1365
1345
|
}
|
|
1366
1346
|
|
|
1367
1347
|
async evaluateModule(
|
|
1368
1348
|
moduleRecord,
|
|
1369
1349
|
evaluationMap,
|
|
1370
1350
|
) {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1351
|
+
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
1352
|
+
if (dependencyModuleRecords.length > 0) {
|
|
1353
|
+
evaluationMap[moduleRecord.id] = true;
|
|
1354
|
+
// evaluate dependencies first
|
|
1355
|
+
await this.evaluateModuleDependencies(dependencyModuleRecords, evaluationMap);
|
|
1356
|
+
}
|
|
1374
1357
|
|
|
1375
|
-
// Wait for load to finish
|
|
1376
1358
|
const { exporter, dependencies } = await moduleRecord.instantiation;
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1359
|
+
// The exports object automatically gets filled in by the exporter evaluation
|
|
1360
|
+
const exports = {};
|
|
1361
|
+
const depsMapped = dependencies
|
|
1362
|
+
? await Promise.all(
|
|
1363
|
+
dependencies.map(async (dep) => {
|
|
1364
|
+
if (dep === 'exports') {
|
|
1365
|
+
return exports;
|
|
1366
|
+
}
|
|
1367
|
+
const resolvedDepId = await this.resolve(dep);
|
|
1368
|
+
|
|
1369
|
+
const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
|
|
1370
|
+
if (!moduleRecord) {
|
|
1371
|
+
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
const module = moduleRecord.module;
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Circular dependencies are handled properly when named exports are used,
|
|
1378
|
+
* however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
|
|
1379
|
+
*
|
|
1380
|
+
* The workaround below applies for circular dependencies (!moduleRecord.evaluated)
|
|
1381
|
+
*/
|
|
1382
|
+
if (!moduleRecord.evaluated) {
|
|
1383
|
+
return this.getCircularDependencyWrapper(module);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
if (module) {
|
|
1387
|
+
return module.__defaultInterop ? module.default : module;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1391
|
+
}),
|
|
1392
|
+
)
|
|
1393
|
+
: [];
|
|
1394
|
+
|
|
1395
|
+
// W-10029836 - In the case where we could be instantiating multiple graphs at the same time lets make sure the module have not already been evaluated
|
|
1396
|
+
if (moduleRecord.evaluated) {
|
|
1397
|
+
return moduleRecord.module;
|
|
1398
|
+
}
|
|
1380
1399
|
|
|
1381
1400
|
// evaluates the module function
|
|
1382
|
-
let moduleDefault
|
|
1401
|
+
let moduleDefault;
|
|
1402
|
+
try {
|
|
1403
|
+
moduleDefault = exporter(...depsMapped);
|
|
1404
|
+
} catch (e) {
|
|
1405
|
+
throw new LoaderError(EXPORTER_ERROR, [moduleRecord.id, e.message || e]);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1383
1408
|
// value is returned from exporter, then we are not using named exports
|
|
1384
1409
|
if (moduleDefault !== undefined) {
|
|
1385
1410
|
moduleDefault = { default: moduleDefault };
|
|
@@ -1391,7 +1416,7 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1391
1416
|
// if no return value, then we are using the exports object
|
|
1392
1417
|
else {
|
|
1393
1418
|
// handle only default export with Rollup forced named exports
|
|
1394
|
-
if (isNamedExportDefaultOnly(exports)) {
|
|
1419
|
+
if (this.isNamedExportDefaultOnly(exports)) {
|
|
1395
1420
|
Object.defineProperty(exports, '__useDefault', { value: true });
|
|
1396
1421
|
}
|
|
1397
1422
|
}
|
|
@@ -1423,17 +1448,42 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1423
1448
|
Object.defineProperty(moduleRecord.module, '__esModule', { value: true });
|
|
1424
1449
|
}
|
|
1425
1450
|
|
|
1426
|
-
Object.freeze(moduleRecord.module);
|
|
1427
1451
|
moduleRecord.evaluated = true;
|
|
1428
|
-
moduleRecord.
|
|
1452
|
+
Object.freeze(moduleRecord.module);
|
|
1429
1453
|
return moduleRecord.module;
|
|
1430
1454
|
}
|
|
1431
1455
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1456
|
+
// Determines if named exports module has only default export
|
|
1457
|
+
isNamedExportDefaultOnly(exports) {
|
|
1458
|
+
return (
|
|
1459
|
+
exports !== undefined &&
|
|
1460
|
+
Object.getOwnPropertyNames(exports).length === 2 &&
|
|
1461
|
+
Object.prototype.hasOwnProperty.call(exports, 'default') &&
|
|
1462
|
+
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// Wrap the dependency in a function that can be called and detected by __circular__ property.
|
|
1467
|
+
// The LWC engine checks for __circular__ to detect circular dependencies.
|
|
1468
|
+
getCircularDependencyWrapper(module) {
|
|
1469
|
+
const tmp = () => {
|
|
1470
|
+
return module.__useDefault || module.__defaultInterop ? module.default : module;
|
|
1471
|
+
};
|
|
1472
|
+
tmp.__circular__ = true;
|
|
1473
|
+
return tmp;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
async evaluateModuleDependencies(
|
|
1477
|
+
dependencyModuleRecords,
|
|
1478
|
+
evaluationMap,
|
|
1479
|
+
) {
|
|
1480
|
+
for (let i = 0; i < dependencyModuleRecords.length; i++) {
|
|
1481
|
+
const depRecord = dependencyModuleRecords[i];
|
|
1482
|
+
if (!depRecord.evaluated && !evaluationMap[depRecord.id]) {
|
|
1483
|
+
evaluationMap[depRecord.id] = true;
|
|
1484
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1485
|
+
await this.evaluateModule(depRecord, evaluationMap);
|
|
1486
|
+
}
|
|
1437
1487
|
}
|
|
1438
1488
|
}
|
|
1439
1489
|
|
|
@@ -1445,8 +1495,8 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1445
1495
|
const moduleName = !isUrl(resolvedId)
|
|
1446
1496
|
? resolvedId
|
|
1447
1497
|
: originalId !== resolvedId
|
|
1448
|
-
|
|
1449
|
-
|
|
1498
|
+
? originalId
|
|
1499
|
+
: undefined;
|
|
1450
1500
|
let moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
1451
1501
|
if (moduleDef && moduleDef.external) {
|
|
1452
1502
|
return moduleDef.external.moduleDefPromise;
|
|
@@ -1513,6 +1563,8 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1513
1563
|
});
|
|
1514
1564
|
}
|
|
1515
1565
|
|
|
1566
|
+
|
|
1567
|
+
|
|
1516
1568
|
addLoaderPlugin(hooks) {
|
|
1517
1569
|
if (typeof hooks !== 'object') {
|
|
1518
1570
|
throw new LoaderError(INVALID_HOOK);
|
|
@@ -1535,6 +1587,7 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1535
1587
|
}
|
|
1536
1588
|
}
|
|
1537
1589
|
|
|
1590
|
+
|
|
1538
1591
|
registerHandleStaleModuleHook(handleStaleModule) {
|
|
1539
1592
|
if (this.handleStaleModuleHook) {
|
|
1540
1593
|
this.handleStaleModuleHook.push(handleStaleModule);
|
|
@@ -1542,30 +1595,12 @@ LWR.define('lwr/loaderLegacy/v/0_12_0-alpha_9', ['exports'], (function (exports)
|
|
|
1542
1595
|
this.handleStaleModuleHook = [handleStaleModule];
|
|
1543
1596
|
}
|
|
1544
1597
|
}
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
function isValidResolveResponse(res) {
|
|
1548
|
-
return res === null || typeof res === 'string' || (res && typeof (res ).url === 'string');
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
// Determines if named exports module has only default export
|
|
1552
|
-
function isNamedExportDefaultOnly(exports) {
|
|
1553
|
-
return (
|
|
1554
|
-
exports !== undefined &&
|
|
1555
|
-
Object.getOwnPropertyNames(exports).length === 2 &&
|
|
1556
|
-
Object.prototype.hasOwnProperty.call(exports, 'default') &&
|
|
1557
|
-
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1558
|
-
);
|
|
1559
|
-
}
|
|
1560
1598
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
};
|
|
1567
|
-
tmp.__circular__ = true;
|
|
1568
|
-
return tmp;
|
|
1599
|
+
isValidResolveResponse(res) {
|
|
1600
|
+
return (
|
|
1601
|
+
res === null || typeof res === 'string' || (res && typeof (res ).url === 'string')
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1569
1604
|
}
|
|
1570
1605
|
|
|
1571
1606
|
// find the longest set of segments from path which are a key in matchObj
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.12.
|
|
8
|
-
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.12.1 */
|
|
8
|
+
!function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_12_1",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(this.config),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&this.initApp()}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},serverData:this.config.serverData,appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s,i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e.define("lwr/profiler/v/0_12_1",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:n,importMappings:o,endpoints:i,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings(o).then((()=>{if(!a)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_12_1")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_12_1"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_12_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"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4,SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes;
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
11
|
-
*/function createTrustedTypesPolicy(e,t){return trustedTypes.createPolicy(e,t)}function createFallbackPolicy(e,t){return t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createTrustedTypesPolicy:createFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}moduleRegistry.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{__init(){this.namedDefineRegistry=new Map}__init2(){this.moduleRegistry=new Map}__init3(){this.aliases=new Map}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.evaluateModule(s,{})),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;let i=!0;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),!isValidResolveResponse(i))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,i=e?!!e.defaultUri:i,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return i&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o={id:e,module:Object.create(null),instantiation:this.getModuleDef(e,t),evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,o),this.storeModuleAlias(t,e),o}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)?hasConsole&&this.aliases.get(e):this.aliases.set(e,t))}async evaluateDependencies(e,t){const r={},o=[];if(e)for(const s of e)"exports"===s?o.push(Promise.resolve(r)):(invariant("require"!==s,NO_AMD_REQUIRE),o.push(this.evaluateDependent(s,t)));return Promise.all(o).then((e=>({depsMapped:e.filter((e=>void 0!==e)),exports:r})))}async evaluateDependent(e,t){const r=await this.resolve(e),o=this.getModuleRecord(r,e);let s=o.module;const n=e=>{if(e)return e.__defaultInterop?e.default:e;throw new LoaderError(FAILED_DEP,[r])};return o.evaluated?n(s):t[o.id]?(s=getCircularDependencyWrapper(s),n(s)):(o.evaluationPromise||(o.evaluationPromise=this.evaluateModule(o,t)),o.evaluationPromise.then((e=>n(e))))}async evaluateModule(e,t){const r={...t};r[e.id]=!0;const{exporter:o,dependencies:s}=await e.instantiation,{depsMapped:n,exports:i}=await this.evaluateDependencies(s,r);let a=this.evaluateModuleCode(o,n,e);void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):isNamedExportDefaultOnly(i)&&Object.defineProperty(i,"__useDefault",{value:!0});const l=a||i;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),Object.freeze(e.module),e.evaluated=!0,e.evaluationPromise=null,e.module}evaluateModuleCode(e,t,r){try{return e(...t)}catch(e){throw new LoaderError(EXPORTER_ERROR,[r.id,e.message||e])}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}}function isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}function isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}function getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(e.length>1&&-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l.uri:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata,serverData:e.serverData||{}})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
11
|
+
*/function createTrustedTypesPolicy(e,t){return trustedTypes.createPolicy(e,t)}function createFallbackPolicy(e,t){return t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createTrustedTypesPolicy:createFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}moduleRegistry.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=await this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.topLevelEvaluation(s)),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;let i=!0;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(i))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,i=e?!!e.defaultUri:i,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return i&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init(){this.namedDefineRegistry=new Map}__init2(){this.moduleRegistry=new Map}__init3(){this.aliases=new Map}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}async getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=(e&&e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),s.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)?hasConsole&&this.aliases.get(e):this.aliases.set(e,t))}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=s?await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...i)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(e.length>1&&-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l.uri:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}class Loader{constructor(e){let t=(e=e||{}).baseUrl,r=e.profiler;if(t&&(t=t.replace(/\/?$/,"/")),t||(t=getBaseUrl()),!t)throw new LoaderError(NO_BASE_URL);this.baseUrl=t,r||(r={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:t,profiler:r}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:e.appMetadata,serverData:e.serverData||{}})}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})}));
|