@lwrjs/loader 0.13.0-alpha.2 → 0.13.0-alpha.21
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 +2 -2
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +34 -29
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim-legacy.js +21 -16
- package/build/assets/prod/lwr-loader-shim.bundle.js +45 -23
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +27 -12
- package/build/bundle/prod/lwr/esmLoader/esmLoader.js +1 -1
- package/build/cjs/index.cjs +28 -1
- package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +2 -2
- package/build/cjs/modules/lwr/esmLoader/importResolver.cjs +0 -17
- package/build/cjs/modules/lwr/esmLoader/importResolverLegacy.cjs +1 -18
- package/build/cjs/modules/lwr/loader/errors/messages.cjs +7 -1
- package/build/cjs/modules/lwr/loader/errors/reportError.cjs +1 -2
- package/build/cjs/modules/lwr/loader/hooks/moduleInvalidation.cjs +2 -3
- package/build/cjs/modules/lwr/loader/hooks/resolveAndLoadHook.cjs +3 -4
- package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +7 -6
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +8 -10
- package/build/cjs/modules/lwr/loader/moduleRegistry/scriptLoad.cjs +2 -2
- package/build/cjs/modules/lwr/loader/utils/url.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/errors/messages.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/errors/reportError.cjs +1 -2
- package/build/cjs/modules/lwr/loaderLegacy/hooks/moduleInvalidation.cjs +2 -3
- package/build/cjs/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.cjs +3 -4
- package/build/cjs/modules/lwr/loaderLegacy/importMap/dom.cjs +4 -4
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMap.cjs +2 -2
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +1 -2
- package/build/cjs/modules/lwr/loaderLegacy/importMap/utils.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/importResolver/importResolver.cjs +0 -17
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +7 -10
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.cjs +2 -2
- package/build/cjs/modules/lwr/loaderLegacy/utils/url.cjs +1 -1
- package/build/cjs/package.d.cjs +0 -0
- package/build/cjs/types.cjs +5 -0
- package/build/error-shim/index.d.ts +2 -0
- package/build/error-shim/index.js +17 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +28 -1
- package/build/modules/lwr/esmLoader/esmLoader.d.ts +6 -0
- package/build/modules/lwr/esmLoader/esmLoader.js +2 -2
- package/build/modules/lwr/esmLoader/importResolver.d.ts +17 -0
- package/build/modules/lwr/esmLoader/importResolver.js +47 -0
- package/build/modules/lwr/esmLoader/importResolverLegacy.d.ts +16 -0
- package/build/modules/lwr/esmLoader/importResolverLegacy.js +18 -0
- package/build/modules/lwr/loader/constants/constants.d.ts +2 -0
- package/build/modules/lwr/loader/constants/constants.js +2 -0
- package/build/modules/lwr/loader/errors/messages.d.ts +33 -0
- package/build/modules/lwr/loader/errors/messages.js +128 -0
- package/build/modules/lwr/loader/errors/reportError.d.ts +4 -0
- package/build/modules/lwr/loader/errors/reportError.js +9 -0
- package/build/modules/lwr/loader/errors/utils.d.ts +2 -0
- package/build/modules/lwr/loader/errors/utils.js +8 -0
- package/build/modules/lwr/loader/hooks/moduleInvalidation.d.ts +3 -0
- package/build/modules/lwr/loader/hooks/moduleInvalidation.js +19 -0
- package/build/modules/lwr/loader/hooks/resolveAndLoadHook.d.ts +7 -0
- package/build/modules/lwr/loader/hooks/resolveAndLoadHook.js +94 -0
- package/build/modules/lwr/loader/loader.d.ts +53 -0
- package/build/modules/lwr/loader/loader.js +18 -11
- package/build/modules/lwr/loader/moduleRegistry/importMetadataResolver.d.ts +44 -0
- package/build/modules/lwr/loader/moduleRegistry/importMetadataResolver.js +211 -0
- package/build/modules/lwr/loader/moduleRegistry/moduleRegistry.d.ts +47 -0
- package/build/modules/lwr/loader/moduleRegistry/moduleRegistry.js +530 -0
- package/build/modules/lwr/loader/moduleRegistry/scriptLoad.d.ts +3 -0
- package/build/modules/lwr/loader/moduleRegistry/scriptLoad.js +43 -0
- package/build/modules/lwr/loader/utils/dom.d.ts +4 -0
- package/build/modules/lwr/loader/utils/dom.js +6 -0
- package/build/modules/lwr/loader/utils/url.d.ts +28 -0
- package/build/modules/lwr/loader/utils/url.js +128 -0
- package/build/modules/lwr/loaderLegacy/constants/constants.d.ts +2 -0
- package/build/modules/lwr/loaderLegacy/constants/constants.js +2 -0
- package/build/modules/lwr/loaderLegacy/errors/messages.d.ts +30 -0
- package/build/modules/lwr/loaderLegacy/errors/messages.js +113 -0
- package/build/modules/lwr/loaderLegacy/errors/reportError.d.ts +4 -0
- package/build/modules/lwr/loaderLegacy/errors/reportError.js +9 -0
- package/build/modules/lwr/loaderLegacy/errors/utils.d.ts +2 -0
- package/build/modules/lwr/loaderLegacy/errors/utils.js +8 -0
- package/build/modules/lwr/loaderLegacy/hooks/moduleInvalidation.d.ts +3 -0
- package/build/modules/lwr/loaderLegacy/hooks/moduleInvalidation.js +19 -0
- package/build/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.d.ts +7 -0
- package/build/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.js +94 -0
- package/build/modules/lwr/loaderLegacy/importMap/dom.d.ts +10 -0
- package/build/modules/lwr/loaderLegacy/importMap/dom.js +63 -0
- package/build/modules/lwr/loaderLegacy/importMap/importMap.d.ts +22 -0
- package/build/modules/lwr/loaderLegacy/importMap/importMap.js +108 -0
- package/build/modules/lwr/loaderLegacy/importMap/importMapResolver.d.ts +8 -0
- package/build/modules/lwr/loaderLegacy/importMap/importMapResolver.js +11 -0
- package/build/modules/lwr/loaderLegacy/importMap/utils.d.ts +4 -0
- package/build/modules/lwr/loaderLegacy/importMap/utils.js +23 -0
- package/build/modules/lwr/loaderLegacy/importResolver/importResolver.d.ts +6 -0
- package/build/modules/lwr/loaderLegacy/importResolver/importResolver.js +2 -0
- package/build/modules/lwr/loaderLegacy/loaderLegacy.d.ts +57 -0
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +13 -13
- package/build/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.d.ts +53 -0
- package/build/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.js +544 -0
- package/build/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.d.ts +3 -0
- package/build/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.js +43 -0
- package/build/modules/lwr/loaderLegacy/utils/dom.d.ts +4 -0
- package/build/modules/lwr/loaderLegacy/utils/dom.js +6 -0
- package/build/modules/lwr/loaderLegacy/utils/url.d.ts +28 -0
- package/build/modules/lwr/loaderLegacy/utils/url.js +128 -0
- package/build/shim/constants.d.ts +2 -0
- package/build/shim/constants.js +2 -0
- package/build/shim/customInit.d.ts +4 -0
- package/build/shim/customInit.js +29 -0
- package/build/shim/index.d.ts +2 -0
- package/build/shim/index.js +9 -0
- package/build/shim/loader.d.ts +3 -0
- package/build/shim/loader.js +27 -0
- package/build/shim/shim.d.ts +31 -0
- package/build/shim/shim.js +194 -0
- package/build/shim-legacy/index.d.ts +2 -0
- package/build/shim-legacy/index.js +9 -0
- package/build/shim-legacy/loaderLegacy.d.ts +3 -0
- package/build/shim-legacy/loaderLegacy.js +29 -0
- package/build/shim-legacy/shimLegacy.d.ts +31 -0
- package/build/shim-legacy/shimLegacy.js +188 -0
- package/build/types.d.ts +56 -0
- package/build/types.js +2 -0
- package/package.json +9 -10
|
@@ -44,10 +44,11 @@ __export(exports, {
|
|
|
44
44
|
NO_BASE_URL: () => NO_BASE_URL,
|
|
45
45
|
NO_MAPPING_URL: () => NO_MAPPING_URL,
|
|
46
46
|
STALE_HOOK_ERROR: () => STALE_HOOK_ERROR,
|
|
47
|
+
UNRESOLVEABLE_MAPPING_ERROR: () => UNRESOLVEABLE_MAPPING_ERROR,
|
|
47
48
|
UNRESOLVED: () => UNRESOLVED,
|
|
48
49
|
invariant: () => invariant
|
|
49
50
|
});
|
|
50
|
-
var import_utils = __toModule(require("./utils"));
|
|
51
|
+
var import_utils = __toModule(require("./utils.cjs"));
|
|
51
52
|
function generateErrorMessage(errorInfo, args) {
|
|
52
53
|
const message = Array.isArray(args) ? (0, import_utils.templateString)(errorInfo.message, args) : errorInfo.message;
|
|
53
54
|
return `LWR${errorInfo.code}: ${message}`;
|
|
@@ -158,6 +159,11 @@ var EXPORTER_ERROR = Object.freeze({
|
|
|
158
159
|
level: 0,
|
|
159
160
|
message: 'Error evaluating module "{0}", error was "{1}"'
|
|
160
161
|
});
|
|
162
|
+
var UNRESOLVEABLE_MAPPING_ERROR = Object.freeze({
|
|
163
|
+
code: 3022,
|
|
164
|
+
level: 0,
|
|
165
|
+
message: 'Unexpected undefined URI resolving mapping for "{0}"'
|
|
166
|
+
});
|
|
161
167
|
var BAD_IMPORT_MAP = Object.freeze({
|
|
162
168
|
code: 3011,
|
|
163
169
|
level: 0,
|
|
@@ -26,8 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
reportError: () => reportError
|
|
28
28
|
});
|
|
29
|
-
var
|
|
30
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
29
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
31
30
|
function reportError(error) {
|
|
32
31
|
if (import_dom.hasConsole)
|
|
33
32
|
console.error(error);
|
|
@@ -26,9 +26,8 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
evaluateHandleStaleModuleHooks: () => evaluateHandleStaleModuleHooks
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_reportError = __toModule(require("../errors/reportError"));
|
|
31
|
-
var import_types = __toModule(require("@lwrjs/types"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_reportError = __toModule(require("../errors/reportError.cjs"));
|
|
32
31
|
function evaluateHandleStaleModuleHooks(handleStaleModuleHooks, hookArgs) {
|
|
33
32
|
const {name, oldUrl, newUrl} = hookArgs;
|
|
34
33
|
for (let i = 0; i < handleStaleModuleHooks.length; i++) {
|
|
@@ -30,11 +30,10 @@ __export(exports, {
|
|
|
30
30
|
isFetchResponse: () => isFetchResponse,
|
|
31
31
|
isResponseAPromise: () => isResponseAPromise
|
|
32
32
|
});
|
|
33
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
34
|
-
var import_constants = __toModule(require("../constants/constants"));
|
|
35
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
33
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
34
|
+
var import_constants = __toModule(require("../constants/constants.cjs"));
|
|
35
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
36
36
|
var import_trusted_types = __toModule(require("@locker/trusted-types"));
|
|
37
|
-
var import_types = __toModule(require("@lwrjs/types"));
|
|
38
37
|
var lastWindowError;
|
|
39
38
|
if (import_dom.hasDocument) {
|
|
40
39
|
globalThis.addEventListener("error", (evt) => {
|
|
@@ -26,10 +26,8 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ImportMetadataResolver: () => ImportMetadataResolver
|
|
28
28
|
});
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var import_loader = __toModule(require("../loader"));
|
|
32
|
-
var import_url = __toModule(require("../utils/url"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_url = __toModule(require("../utils/url.cjs"));
|
|
33
31
|
var import_metrics = __toModule(require("lwr/metrics"));
|
|
34
32
|
var ImportMetadataResolver = class {
|
|
35
33
|
constructor(config, invalidationCallback) {
|
|
@@ -61,7 +59,7 @@ var ImportMetadataResolver = class {
|
|
|
61
59
|
return `${mappingEndpoint}${specifiers}${modifiers}`;
|
|
62
60
|
}
|
|
63
61
|
getBaseUrl() {
|
|
64
|
-
return this.config.baseUrl;
|
|
62
|
+
return this.config.baseUrl || "";
|
|
65
63
|
}
|
|
66
64
|
registerImportMappings(newImportMetadata, rootSpecifiers) {
|
|
67
65
|
if (!rootSpecifiers || rootSpecifiers.length === 0) {
|
|
@@ -99,7 +97,7 @@ var ImportMetadataResolver = class {
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
getURI(specifier) {
|
|
102
|
-
return this.importURICache.has(specifier) ? (0, import_url.resolveUrl)(this.importURICache.get(specifier).uri, this.getBaseUrl()) : void 0;
|
|
100
|
+
return this.importURICache && this.importURICache.has(specifier) ? (0, import_url.resolveUrl)(this.importURICache.get(specifier).uri, this.getBaseUrl()) : void 0;
|
|
103
101
|
}
|
|
104
102
|
resolveLocal(specifier) {
|
|
105
103
|
const uri = this.getURI(specifier);
|
|
@@ -163,6 +161,9 @@ var ImportMetadataResolver = class {
|
|
|
163
161
|
throw new import_messages.LoaderError(import_messages.UNRESOLVED, [specifier]);
|
|
164
162
|
}
|
|
165
163
|
const uri = (0, import_url.resolveUrl)(this.buildMappingUrl(specifier), this.getBaseUrl());
|
|
164
|
+
if (!uri) {
|
|
165
|
+
throw new import_messages.LoaderError(import_messages.UNRESOLVEABLE_MAPPING_ERROR, [specifier]);
|
|
166
|
+
}
|
|
166
167
|
return globalThis.fetch(uri).then((res) => {
|
|
167
168
|
if (!res.ok) {
|
|
168
169
|
this.config.profiler.logOperationStart({id: import_metrics.MAPPINGS_ERROR, specifier});
|
|
@@ -26,17 +26,15 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ModuleRegistry: () => ModuleRegistry
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_url = __toModule(require("../utils/url"));
|
|
31
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
32
|
-
var import_scriptLoad = __toModule(require("./scriptLoad"));
|
|
33
|
-
var import_importMetadataResolver = __toModule(require("./importMetadataResolver"));
|
|
34
|
-
var import_moduleInvalidation = __toModule(require("../hooks/moduleInvalidation"));
|
|
35
|
-
var import_resolveAndLoadHook = __toModule(require("../hooks/resolveAndLoadHook"));
|
|
36
|
-
var import_types = __toModule(require("@lwrjs/types"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_url = __toModule(require("../utils/url.cjs"));
|
|
31
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
32
|
+
var import_scriptLoad = __toModule(require("./scriptLoad.cjs"));
|
|
33
|
+
var import_importMetadataResolver = __toModule(require("./importMetadataResolver.cjs"));
|
|
34
|
+
var import_moduleInvalidation = __toModule(require("../hooks/moduleInvalidation.cjs"));
|
|
35
|
+
var import_resolveAndLoadHook = __toModule(require("../hooks/resolveAndLoadHook.cjs"));
|
|
37
36
|
var import_metrics = __toModule(require("lwr/metrics"));
|
|
38
|
-
var import_constants = __toModule(require("../constants/constants"));
|
|
39
|
-
var import_loader = __toModule(require("../loader"));
|
|
37
|
+
var import_constants = __toModule(require("../constants/constants.cjs"));
|
|
40
38
|
var ModuleRegistry = class {
|
|
41
39
|
constructor(config) {
|
|
42
40
|
this.namedDefineRegistry = new Map();
|
|
@@ -26,8 +26,8 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
loadModuleDef: () => loadModuleDef
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
31
31
|
function createScript(url) {
|
|
32
32
|
const script = document.createElement("script");
|
|
33
33
|
script.async = true;
|
|
@@ -29,7 +29,7 @@ __export(exports, {
|
|
|
29
29
|
resolveIfNotPlainOrUrl: () => resolveIfNotPlainOrUrl,
|
|
30
30
|
resolveUrl: () => resolveUrl
|
|
31
31
|
});
|
|
32
|
-
var import_dom = __toModule(require("./dom"));
|
|
32
|
+
var import_dom = __toModule(require("./dom.cjs"));
|
|
33
33
|
function getBaseUrl() {
|
|
34
34
|
let baseUrl = void 0;
|
|
35
35
|
if (import_dom.hasDocument) {
|
|
@@ -45,7 +45,7 @@ __export(exports, {
|
|
|
45
45
|
UNRESOLVED: () => UNRESOLVED,
|
|
46
46
|
invariant: () => invariant
|
|
47
47
|
});
|
|
48
|
-
var import_utils = __toModule(require("./utils"));
|
|
48
|
+
var import_utils = __toModule(require("./utils.cjs"));
|
|
49
49
|
function generateErrorMessage(errorInfo, args) {
|
|
50
50
|
const message = Array.isArray(args) ? (0, import_utils.templateString)(errorInfo.message, args) : errorInfo.message;
|
|
51
51
|
return `LWR${errorInfo.code}: ${message}`;
|
|
@@ -26,8 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
reportError: () => reportError
|
|
28
28
|
});
|
|
29
|
-
var
|
|
30
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
29
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
31
30
|
function reportError(error) {
|
|
32
31
|
if (import_dom.hasConsole)
|
|
33
32
|
console.error(error);
|
|
@@ -26,9 +26,8 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
evaluateHandleStaleModuleHooks: () => evaluateHandleStaleModuleHooks
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_reportError = __toModule(require("../errors/reportError"));
|
|
31
|
-
var import_types = __toModule(require("@lwrjs/types"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_reportError = __toModule(require("../errors/reportError.cjs"));
|
|
32
31
|
function evaluateHandleStaleModuleHooks(handleStaleModuleHooks, hookArgs) {
|
|
33
32
|
const {name, oldHash, newHash} = hookArgs;
|
|
34
33
|
for (let i = 0; i < handleStaleModuleHooks.length; i++) {
|
|
@@ -30,11 +30,10 @@ __export(exports, {
|
|
|
30
30
|
isFetchResponse: () => isFetchResponse,
|
|
31
31
|
isResponseAPromise: () => isResponseAPromise
|
|
32
32
|
});
|
|
33
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
34
|
-
var import_constants = __toModule(require("../constants/constants"));
|
|
35
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
33
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
34
|
+
var import_constants = __toModule(require("../constants/constants.cjs"));
|
|
35
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
36
36
|
var import_trusted_types = __toModule(require("@locker/trusted-types"));
|
|
37
|
-
var import_types = __toModule(require("@lwrjs/types"));
|
|
38
37
|
var lastWindowError;
|
|
39
38
|
if (import_dom.hasDocument) {
|
|
40
39
|
globalThis.addEventListener("error", (evt) => {
|
|
@@ -27,10 +27,10 @@ __export(exports, {
|
|
|
27
27
|
IMPORTMAP_SCRIPT_TYPE: () => IMPORTMAP_SCRIPT_TYPE,
|
|
28
28
|
evaluateImportMaps: () => evaluateImportMaps
|
|
29
29
|
});
|
|
30
|
-
var import_importMap = __toModule(require("./importMap"));
|
|
31
|
-
var import_url = __toModule(require("../utils/url"));
|
|
32
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
33
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
+
var import_importMap = __toModule(require("./importMap.cjs"));
|
|
31
|
+
var import_url = __toModule(require("../utils/url.cjs"));
|
|
32
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
33
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
34
34
|
var IMPORTMAP_SCRIPT_TYPE = "lwr-importmap";
|
|
35
35
|
function iterateDocumentImportMaps(callBack, extraSelector) {
|
|
36
36
|
const nodeList = document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]` + extraSelector);
|
|
@@ -27,8 +27,8 @@ __export(exports, {
|
|
|
27
27
|
resolveAndComposeImportMap: () => resolveAndComposeImportMap,
|
|
28
28
|
resolveImportMapEntry: () => resolveImportMapEntry
|
|
29
29
|
});
|
|
30
|
-
var import_url = __toModule(require("../utils/url"));
|
|
31
|
-
var import_utils = __toModule(require("./utils"));
|
|
30
|
+
var import_url = __toModule(require("../utils/url.cjs"));
|
|
31
|
+
var import_utils = __toModule(require("./utils.cjs"));
|
|
32
32
|
function applyPackages(id, packages, defaultUri) {
|
|
33
33
|
const pkgName = (0, import_utils.getMatch)(id, packages);
|
|
34
34
|
if (pkgName) {
|
|
@@ -26,8 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ImportMapResolver: () => ImportMapResolver
|
|
28
28
|
});
|
|
29
|
-
var import_importMap = __toModule(require("./importMap"));
|
|
30
|
-
var import_importResolver = __toModule(require("../importResolver/importResolver"));
|
|
29
|
+
var import_importMap = __toModule(require("./importMap.cjs"));
|
|
31
30
|
var ImportMapResolver = class {
|
|
32
31
|
constructor(importMap) {
|
|
33
32
|
this.importMap = importMap;
|
|
@@ -27,7 +27,7 @@ __export(exports, {
|
|
|
27
27
|
getMatch: () => getMatch,
|
|
28
28
|
targetWarning: () => targetWarning
|
|
29
29
|
});
|
|
30
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
30
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
31
31
|
function getMatch(path, matchObj) {
|
|
32
32
|
if (matchObj[path]) {
|
|
33
33
|
return path;
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
2
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __exportStar = (target, module2, desc) => {
|
|
9
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(module2))
|
|
11
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
12
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
var __toModule = (module2) => {
|
|
17
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
18
|
-
};
|
|
19
3
|
|
|
20
4
|
// packages/@lwrjs/loader/src/modules/lwr/loaderLegacy/importResolver/importResolver.ts
|
|
21
5
|
__markAsModule(exports);
|
|
22
|
-
var import_importMap = __toModule(require("../importMap/importMap"));
|
|
@@ -26,16 +26,13 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ModuleRegistry: () => ModuleRegistry
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_url = __toModule(require("../utils/url"));
|
|
31
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
32
|
-
var import_scriptLoad = __toModule(require("./scriptLoad"));
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var import_moduleInvalidation = __toModule(require("../hooks/moduleInvalidation"));
|
|
37
|
-
var import_constants = __toModule(require("../constants/constants"));
|
|
38
|
-
var import_loaderLegacy = __toModule(require("../loaderLegacy"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_url = __toModule(require("../utils/url.cjs"));
|
|
31
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
32
|
+
var import_scriptLoad = __toModule(require("./scriptLoad.cjs"));
|
|
33
|
+
var import_resolveAndLoadHook = __toModule(require("../hooks/resolveAndLoadHook.cjs"));
|
|
34
|
+
var import_moduleInvalidation = __toModule(require("../hooks/moduleInvalidation.cjs"));
|
|
35
|
+
var import_constants = __toModule(require("../constants/constants.cjs"));
|
|
39
36
|
var import_metrics = __toModule(require("lwr/metrics"));
|
|
40
37
|
var ModuleRegistry = class {
|
|
41
38
|
constructor(config) {
|
|
@@ -26,8 +26,8 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
loadModuleDef: () => loadModuleDef
|
|
28
28
|
});
|
|
29
|
-
var import_messages = __toModule(require("../errors/messages"));
|
|
30
|
-
var import_dom = __toModule(require("../utils/dom"));
|
|
29
|
+
var import_messages = __toModule(require("../errors/messages.cjs"));
|
|
30
|
+
var import_dom = __toModule(require("../utils/dom.cjs"));
|
|
31
31
|
function createScript(url) {
|
|
32
32
|
const script = document.createElement("script");
|
|
33
33
|
script.async = true;
|
|
@@ -29,7 +29,7 @@ __export(exports, {
|
|
|
29
29
|
resolveIfNotPlainOrUrl: () => resolveIfNotPlainOrUrl,
|
|
30
30
|
resolveUrl: () => resolveUrl
|
|
31
31
|
});
|
|
32
|
-
var import_dom = __toModule(require("./dom"));
|
|
32
|
+
var import_dom = __toModule(require("./dom.cjs"));
|
|
33
33
|
function getBaseUrl() {
|
|
34
34
|
let baseUrl = void 0;
|
|
35
35
|
if (import_dom.hasDocument) {
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// If the shim does not initialize, the error shim will:
|
|
2
|
+
// - pass an error into the app-owned globalThis.LWR.onError(), if available
|
|
3
|
+
// - otherwise, throw an error
|
|
4
|
+
// The error shim must be inlined below the shim script, so it can detect if the shim is executing
|
|
5
|
+
const _globalThis = globalThis;
|
|
6
|
+
const shimOK = _globalThis.LWR && _globalThis.LWR.define;
|
|
7
|
+
if (!shimOK) {
|
|
8
|
+
const shimError = new Error('The LWR application failed to bootstrap');
|
|
9
|
+
if (_globalThis.LWR && _globalThis.LWR.onError) {
|
|
10
|
+
_globalThis.LWR.onError(shimError);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
throw shimError;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider, RuntimeEnvironment } from '@lwrjs/types';
|
|
2
|
+
export * from './types.js';
|
|
2
3
|
interface LoaderProviderConfig {
|
|
3
4
|
dir: string;
|
|
4
5
|
}
|
|
@@ -12,5 +13,4 @@ export default class AmdLoaderShimService implements ResourceProvider {
|
|
|
12
13
|
constructor({ dir }: LoaderProviderConfig, context: ProviderContext);
|
|
13
14
|
getResource<T extends ResourceIdentifier, R extends RuntimeEnvironment>(resource: T, environment: R): Promise<ResourceDefinition | undefined>;
|
|
14
15
|
}
|
|
15
|
-
export {};
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { rootPath } from '@lwrjs/loader/package';
|
|
4
|
+
import { createIntegrityHash } from '@lwrjs/shared-utils';
|
|
5
|
+
export * from './types.js';
|
|
4
6
|
export default class AmdLoaderShimService {
|
|
5
7
|
constructor({ dir = 'assets' }, context) {
|
|
6
8
|
this.name = 'loader-shim-resource';
|
|
@@ -28,11 +30,18 @@ export default class AmdLoaderShimService {
|
|
|
28
30
|
// Retrieve the filepath from the build directory
|
|
29
31
|
const absFilepath = path.join(rootPath, 'build', this.directory, 'prod', fileName);
|
|
30
32
|
if (fs.existsSync(absFilepath)) {
|
|
33
|
+
const cachedContent = new CachedContent(absFilepath);
|
|
31
34
|
return {
|
|
32
35
|
specifier,
|
|
33
36
|
type: 'application/javascript',
|
|
34
37
|
inline: specifier === this.errorShimName ? true : false,
|
|
35
|
-
|
|
38
|
+
get content() {
|
|
39
|
+
return cachedContent.getContent();
|
|
40
|
+
},
|
|
41
|
+
get integrity() {
|
|
42
|
+
return cachedContent.getIntegrity();
|
|
43
|
+
},
|
|
44
|
+
version,
|
|
36
45
|
src: await this.context.resourceRegistry.resolveResourceUri({ specifier, version }, environment),
|
|
37
46
|
};
|
|
38
47
|
}
|
|
@@ -41,4 +50,22 @@ export default class AmdLoaderShimService {
|
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
52
|
}
|
|
53
|
+
class CachedContent {
|
|
54
|
+
constructor(absFilepath) {
|
|
55
|
+
this.absFilepath = absFilepath;
|
|
56
|
+
}
|
|
57
|
+
getContent() {
|
|
58
|
+
if (!this._cachedContent) {
|
|
59
|
+
this._cachedContent = fs.readFileSync(this.absFilepath, 'utf-8');
|
|
60
|
+
}
|
|
61
|
+
return this._cachedContent;
|
|
62
|
+
}
|
|
63
|
+
getIntegrity() {
|
|
64
|
+
if (!this._integrity) {
|
|
65
|
+
const content = this.getContent();
|
|
66
|
+
this._integrity = createIntegrityHash(content);
|
|
67
|
+
}
|
|
68
|
+
return this._integrity;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
44
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientBootstrapConfig } from '@lwrjs/types';
|
|
2
|
+
type LoaderConfig = Pick<ClientBootstrapConfig, 'imports' | 'index' | 'importMappings' | 'endpoints'>;
|
|
3
|
+
export declare function init(config: LoaderConfig): void;
|
|
4
|
+
export declare function load(specifier: string, importer?: string): Promise<any>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=esmLoader.d.ts.map
|
|
@@ -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.13.0-alpha.
|
|
7
|
+
/* LWR ESM Module Loader v0.13.0-alpha.21 */
|
|
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
|
|
|
@@ -81,7 +81,7 @@ class ImportResolverLegacy {
|
|
|
81
81
|
* @param specifier - Id of module we are looking for an id for
|
|
82
82
|
*/
|
|
83
83
|
legacyResolve(specifier) {
|
|
84
|
-
return this.importURICache.imports[specifier];
|
|
84
|
+
return this.importURICache && this.importURICache.imports && this.importURICache.imports[specifier];
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ClientBootstrapConfig } from '@lwrjs/types';
|
|
2
|
+
type ImportResolverConfig = Pick<ClientBootstrapConfig, 'imports' | 'index' | 'endpoints' | 'importMappings'>;
|
|
3
|
+
/**
|
|
4
|
+
* Simplified version of the AMD Import Metadata Resolver.
|
|
5
|
+
* Just reads the ImportMetadata at construction time.
|
|
6
|
+
*/
|
|
7
|
+
export default class ImportResolver {
|
|
8
|
+
private importURICache;
|
|
9
|
+
private mappingEndpoint?;
|
|
10
|
+
private modifiers;
|
|
11
|
+
constructor(config: ImportResolverConfig | undefined);
|
|
12
|
+
private normalizeMetadata;
|
|
13
|
+
private fetchMappings;
|
|
14
|
+
resolve(specifier: string): Promise<string | undefined>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=importResolver.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified version of the AMD Import Metadata Resolver.
|
|
3
|
+
* Just reads the ImportMetadata at construction time.
|
|
4
|
+
*/
|
|
5
|
+
export default class ImportResolver {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.importURICache = new Map();
|
|
8
|
+
this.modifiers = '';
|
|
9
|
+
this.normalizeMetadata(config);
|
|
10
|
+
// only fetch mappings if fingerprints is ON
|
|
11
|
+
this.mappingEndpoint = config?.importMappings ? undefined : config?.endpoints?.uris.mapping;
|
|
12
|
+
if (config?.endpoints?.modifiers) {
|
|
13
|
+
// Add URI modifiers to mapping endpoint query
|
|
14
|
+
this.modifiers = Object.entries(config.endpoints.modifiers).reduce((q, [k, v]) => (q += `${k}=${v}&`), '?');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
normalizeMetadata(importMetada) {
|
|
18
|
+
// Normalize the URI cache to optimize retrieval
|
|
19
|
+
if (importMetada && importMetada.imports) {
|
|
20
|
+
for (const [uri, value] of Object.entries(importMetada.imports)) {
|
|
21
|
+
if (uri && value) {
|
|
22
|
+
const specifiers = Array.isArray(value) ? value : [];
|
|
23
|
+
specifiers.forEach((specifier) => {
|
|
24
|
+
this.importURICache.set(specifier, uri);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async fetchMappings(specifier) {
|
|
31
|
+
const mappingUri = `${this.mappingEndpoint}${encodeURIComponent(specifier)}${this.modifiers}`;
|
|
32
|
+
const res = await globalThis.fetch(mappingUri);
|
|
33
|
+
if (res.ok) {
|
|
34
|
+
const mappings = await res.json();
|
|
35
|
+
this.normalizeMetadata(mappings);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async resolve(specifier) {
|
|
39
|
+
let uri = this.importURICache.get(specifier);
|
|
40
|
+
if (!uri && this.mappingEndpoint) {
|
|
41
|
+
await this.fetchMappings(specifier);
|
|
42
|
+
uri = this.importURICache.get(specifier);
|
|
43
|
+
}
|
|
44
|
+
return uri;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=importResolver.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ImportMap } from '../loaderLegacy/importMap/importMap.js';
|
|
2
|
+
/**
|
|
3
|
+
* Simplified version of the AMD Import Metadata Resolver.
|
|
4
|
+
* Just read the legacy ImportMap at construction time.
|
|
5
|
+
*/
|
|
6
|
+
export default class ImportResolverLegacy {
|
|
7
|
+
private importURICache;
|
|
8
|
+
constructor(importMap?: ImportMap);
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the URL for a specifier if it is in the global imports
|
|
11
|
+
* This is using the pre-fingerprints importMappings syntax
|
|
12
|
+
* @param specifier - Id of module we are looking for an id for
|
|
13
|
+
*/
|
|
14
|
+
legacyResolve(specifier: string): string | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=importResolverLegacy.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified version of the AMD Import Metadata Resolver.
|
|
3
|
+
* Just read the legacy ImportMap at construction time.
|
|
4
|
+
*/
|
|
5
|
+
export default class ImportResolverLegacy {
|
|
6
|
+
constructor(importMap) {
|
|
7
|
+
this.importURICache = importMap && importMap.imports ? importMap : { imports: {} };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the URL for a specifier if it is in the global imports
|
|
11
|
+
* This is using the pre-fingerprints importMappings syntax
|
|
12
|
+
* @param specifier - Id of module we are looking for an id for
|
|
13
|
+
*/
|
|
14
|
+
legacyResolve(specifier) {
|
|
15
|
+
return this.importURICache && this.importURICache.imports && this.importURICache.imports[specifier];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=importResolverLegacy.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare class LoaderError extends Error {
|
|
2
|
+
constructor(errorInfo: ErrorInfo, errorArgs?: string[]);
|
|
3
|
+
}
|
|
4
|
+
declare function invariant(condition: boolean, errorInfo: ErrorInfo): void;
|
|
5
|
+
interface ErrorInfo {
|
|
6
|
+
code: number;
|
|
7
|
+
message: string;
|
|
8
|
+
level: number;
|
|
9
|
+
}
|
|
10
|
+
declare const MISSING_NAME: ErrorInfo;
|
|
11
|
+
declare const FAIL_INSTANTIATE: ErrorInfo;
|
|
12
|
+
declare const NO_AMD_REQUIRE: ErrorInfo;
|
|
13
|
+
declare const FAILED_DEP: ErrorInfo;
|
|
14
|
+
declare const INVALID_DEPS: ErrorInfo;
|
|
15
|
+
declare const FAIL_LOAD: ErrorInfo;
|
|
16
|
+
declare const UNRESOLVED: ErrorInfo;
|
|
17
|
+
declare const NO_BASE_URL: ErrorInfo;
|
|
18
|
+
declare const HOOK_ALREADY_SET: ErrorInfo;
|
|
19
|
+
declare const INVALID_HOOK: ErrorInfo;
|
|
20
|
+
declare const INVALID_LOADER_SERVICE_RESPONSE: ErrorInfo;
|
|
21
|
+
declare const MODULE_LOAD_TIMEOUT: ErrorInfo;
|
|
22
|
+
declare const HTTP_FAIL_LOAD: ErrorInfo;
|
|
23
|
+
declare const STALE_HOOK_ERROR: ErrorInfo;
|
|
24
|
+
declare const MODULE_ALREADY_LOADED: ErrorInfo;
|
|
25
|
+
declare const FAIL_HOOK_LOAD: ErrorInfo;
|
|
26
|
+
declare const NO_MAPPING_URL: ErrorInfo;
|
|
27
|
+
declare const BAD_IMPORT_METADATA: ErrorInfo;
|
|
28
|
+
declare const EXPORTER_ERROR: ErrorInfo;
|
|
29
|
+
declare const UNRESOLVEABLE_MAPPING_ERROR: ErrorInfo;
|
|
30
|
+
declare const BAD_IMPORT_MAP: ErrorInfo;
|
|
31
|
+
export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, NO_MAPPING_URL, BAD_IMPORT_MAP, BAD_IMPORT_METADATA, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, UNRESOLVEABLE_MAPPING_ERROR, };
|
|
32
|
+
export { invariant, LoaderError };
|
|
33
|
+
//# sourceMappingURL=messages.d.ts.map
|