@lwrjs/shared-utils 0.24.2 → 0.24.3
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/cjs/bundle.cjs +24 -20
- package/build/cjs/compiler.cjs +22 -25
- package/build/cjs/cookie.cjs +27 -11
- package/build/cjs/env.cjs +40 -12
- package/build/cjs/fs.cjs +50 -40
- package/build/cjs/graph.cjs +78 -38
- package/build/cjs/headers.cjs +17 -4
- package/build/cjs/html-meta.cjs +56 -38
- package/build/cjs/identity.cjs +34 -23
- package/build/cjs/import-metadata.cjs +25 -25
- package/build/cjs/index.cjs +33 -35
- package/build/cjs/interchangeable-modules.cjs +46 -33
- package/build/cjs/launch.cjs +24 -17
- package/build/cjs/link.cjs +23 -16
- package/build/cjs/localization.cjs +24 -17
- package/build/cjs/lwr-app-observer.cjs +15 -18
- package/build/cjs/mappings.cjs +76 -37
- package/build/cjs/mrt-utils.cjs +15 -18
- package/build/cjs/object.cjs +24 -8
- package/build/cjs/serialize.cjs +53 -37
- package/build/cjs/tasks.cjs +33 -5
- package/build/cjs/urls.cjs +34 -22
- package/package.json +4 -4
package/build/cjs/headers.cjs
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
6
|
var __export = (target, all) => {
|
|
4
7
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
9
|
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
7
19
|
|
|
8
20
|
// packages/@lwrjs/shared-utils/src/headers.ts
|
|
9
|
-
|
|
10
|
-
__export(
|
|
21
|
+
var headers_exports = {};
|
|
22
|
+
__export(headers_exports, {
|
|
11
23
|
normalizeHeaders: () => normalizeHeaders
|
|
12
24
|
});
|
|
25
|
+
module.exports = __toCommonJS(headers_exports);
|
|
13
26
|
function normalizeHeaders(headers = {}) {
|
|
14
27
|
return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
15
28
|
}
|
package/build/cjs/html-meta.cjs
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
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
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/shared-utils/src/html-meta.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var html_meta_exports = {};
|
|
32
|
+
__export(html_meta_exports, {
|
|
27
33
|
HYDRATE_CLIENT_VALUE: () => HYDRATE_CLIENT_VALUE,
|
|
28
34
|
HYDRATE_DIRECTIVE: () => HYDRATE_DIRECTIVE,
|
|
29
35
|
HYDRATE_LOAD_VALUE: () => HYDRATE_LOAD_VALUE,
|
|
@@ -36,10 +42,11 @@ __export(exports, {
|
|
|
36
42
|
isRelative: () => isRelative,
|
|
37
43
|
isSelfUrl: () => isSelfUrl
|
|
38
44
|
});
|
|
39
|
-
|
|
40
|
-
var
|
|
45
|
+
module.exports = __toCommonJS(html_meta_exports);
|
|
46
|
+
var parse5 = __toESM(require("parse5"), 1);
|
|
47
|
+
var import_identity = require("./identity.cjs");
|
|
41
48
|
function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
42
|
-
const {startOffset, endOffset} = attrLocation;
|
|
49
|
+
const { startOffset, endOffset } = attrLocation;
|
|
43
50
|
const srcAttr = htmlSource.substring(startOffset, endOffset);
|
|
44
51
|
const split = srcAttr.indexOf("=");
|
|
45
52
|
const keyAttr = srcAttr.substr(0, split);
|
|
@@ -55,13 +62,16 @@ function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
64
|
function parseInlineStyleImages(htmlSource, tagName, attrLocation) {
|
|
58
|
-
const imageAssets = [], urlPattern = /url\((.*?)\)/g, {startOffset, endOffset} = attrLocation, srcAttr = htmlSource.substring(startOffset, endOffset);
|
|
65
|
+
const imageAssets = [], urlPattern = /url\((.*?)\)/g, { startOffset, endOffset } = attrLocation, srcAttr = htmlSource.substring(startOffset, endOffset);
|
|
59
66
|
let srcAttrStart = 0, match;
|
|
60
67
|
while ((match = urlPattern.exec(srcAttr)) !== null) {
|
|
61
68
|
const currentStr = srcAttr.substring(srcAttrStart);
|
|
62
69
|
imageAssets.push({
|
|
70
|
+
// Clean up the URL by trimming quotes and spaces
|
|
63
71
|
url: match[1].trim().replace(/^['"]|['"]$/g, ""),
|
|
72
|
+
// Calculate the starting offset of the matched URL relative to the entire HTML source
|
|
64
73
|
startOffset: startOffset + currentStr.indexOf(match[1]) + srcAttrStart,
|
|
74
|
+
// Calculate the ending offset of the matched URL
|
|
65
75
|
endOffset: startOffset + currentStr.indexOf(match[1]) + match[1].length + srcAttrStart
|
|
66
76
|
});
|
|
67
77
|
srcAttrStart = currentStr.indexOf(match[1]) + match[1].length + srcAttrStart;
|
|
@@ -99,9 +109,9 @@ function traverseHtmlTree(node, visitor) {
|
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
|
|
102
|
-
const {customElements, assetReferences} = viewMetadata;
|
|
112
|
+
const { customElements, assetReferences } = viewMetadata;
|
|
103
113
|
const {
|
|
104
|
-
bundleConfig: {external = {}}
|
|
114
|
+
bundleConfig: { external = {} }
|
|
105
115
|
} = appConfig;
|
|
106
116
|
const externals = Object.keys(external);
|
|
107
117
|
const root = parse5.parse(htmlSource, {
|
|
@@ -110,18 +120,21 @@ function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
|
|
|
110
120
|
});
|
|
111
121
|
let nestedIslands = false;
|
|
112
122
|
let styleStartOffset;
|
|
113
|
-
const openElements = new Set();
|
|
123
|
+
const openElements = /* @__PURE__ */ new Set();
|
|
114
124
|
const ceRefStack = [];
|
|
115
125
|
traverseHtmlTree(root, {
|
|
116
126
|
enter(node) {
|
|
117
|
-
const {nodeName: tagName, attrs, sourceCodeLocation} = node;
|
|
127
|
+
const { nodeName: tagName, attrs, sourceCodeLocation } = node;
|
|
118
128
|
if (sourceCodeLocation && tagName.includes("-") && !openElements.has(tagName) && !externals.includes((0, import_identity.kebabCaseToModuleSpecifier)(tagName))) {
|
|
119
|
-
const {startOffset, endOffset} = sourceCodeLocation;
|
|
120
|
-
const props = attrs.length ? attrs.reduce(
|
|
121
|
-
obj
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
const { startOffset, endOffset } = sourceCodeLocation;
|
|
130
|
+
const props = attrs.length ? attrs.reduce(
|
|
131
|
+
(obj, { name, value }) => {
|
|
132
|
+
obj[(0, import_identity.getPropFromAttrName)(name)] = value === "" ? "true" : value;
|
|
133
|
+
return obj;
|
|
134
|
+
},
|
|
135
|
+
{}
|
|
136
|
+
) : void 0;
|
|
137
|
+
const ceRef = { tagName, location: { startOffset, endOffset }, props };
|
|
125
138
|
openElements.add(tagName);
|
|
126
139
|
if (ceRefStack.length) {
|
|
127
140
|
const last = ceRefStack[ceRefStack.length - 1];
|
|
@@ -145,24 +158,30 @@ function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
|
|
|
145
158
|
styleStartOffset = sourceCodeLocation?.startOffset;
|
|
146
159
|
}
|
|
147
160
|
if (sourceCodeLocation?.attrs?.style) {
|
|
148
|
-
assetReferences.push(
|
|
161
|
+
assetReferences.push(
|
|
162
|
+
...parseInlineStyleImages(htmlSource, tagName, sourceCodeLocation.attrs.style)
|
|
163
|
+
);
|
|
149
164
|
}
|
|
150
165
|
},
|
|
151
166
|
exit(node) {
|
|
152
|
-
const {nodeName: tagName, sourceCodeLocation} = node;
|
|
167
|
+
const { nodeName: tagName, sourceCodeLocation } = node;
|
|
153
168
|
if (openElements.has(tagName)) {
|
|
154
169
|
const ceRef = ceRefStack.pop();
|
|
155
170
|
openElements.delete(tagName);
|
|
156
171
|
if (!ceRef) {
|
|
157
|
-
throw new Error(
|
|
172
|
+
throw new Error(
|
|
173
|
+
`Error extracting metadata: Unmatched custom element close tag for ${tagName}`
|
|
174
|
+
);
|
|
158
175
|
}
|
|
159
176
|
ceRef.location.endOffset = sourceCodeLocation.endOffset;
|
|
160
177
|
}
|
|
161
178
|
if (tagName === "style" && styleStartOffset && sourceCodeLocation?.endOffset) {
|
|
162
|
-
assetReferences.push(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
assetReferences.push(
|
|
180
|
+
...parseInlineStyleImages(htmlSource, "style", {
|
|
181
|
+
startOffset: styleStartOffset,
|
|
182
|
+
endOffset: sourceCodeLocation.endOffset
|
|
183
|
+
})
|
|
184
|
+
);
|
|
166
185
|
styleStartOffset = void 0;
|
|
167
186
|
}
|
|
168
187
|
}
|
|
@@ -180,8 +199,7 @@ var HYDRATION_VALUES = [HYDRATE_LOAD_VALUE, HYDRATE_CLIENT_VALUE, HYDRATE_VISIBL
|
|
|
180
199
|
function getHydrateDirective(props = {}) {
|
|
181
200
|
const rawValue = props[HYDRATE_DIRECTIVE];
|
|
182
201
|
const value = rawValue === "true" ? HYDRATE_LOAD_VALUE : rawValue;
|
|
183
|
-
if (HYDRATION_VALUES.includes(value))
|
|
184
|
-
return value;
|
|
202
|
+
if (HYDRATION_VALUES.includes(value)) return value;
|
|
185
203
|
}
|
|
186
204
|
function isHydrateOnLoad(props = {}) {
|
|
187
205
|
return getHydrateDirective(props) === HYDRATE_LOAD_VALUE;
|
package/build/cjs/identity.cjs
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
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
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/shared-utils/src/identity.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var identity_exports = {};
|
|
32
|
+
__export(identity_exports, {
|
|
27
33
|
ASSETS_CACHE_DIR: () => ASSETS_CACHE_DIR,
|
|
28
34
|
BUNDLE_SIGIL: () => BUNDLE_SIGIL,
|
|
29
35
|
DEFAULT_LOCKER_TRUSTED_CMP: () => DEFAULT_LOCKER_TRUSTED_CMP,
|
|
@@ -60,8 +66,9 @@ __export(exports, {
|
|
|
60
66
|
slugify: () => slugify,
|
|
61
67
|
stringToVariableName: () => stringToVariableName
|
|
62
68
|
});
|
|
63
|
-
|
|
64
|
-
var
|
|
69
|
+
module.exports = __toCommonJS(identity_exports);
|
|
70
|
+
var import_slugify = __toESM(require("slugify"), 1);
|
|
71
|
+
var import_fast_json_stable_stringify = __toESM(require("fast-json-stable-stringify"), 1);
|
|
65
72
|
var VERSION_SIGIL = "v";
|
|
66
73
|
var VERSION_PREFIX = `/${VERSION_SIGIL}/`;
|
|
67
74
|
var LOCALE_SIGIL = "l";
|
|
@@ -102,7 +109,9 @@ function fullyDecodeSpecifier(rawSpecifier) {
|
|
|
102
109
|
}
|
|
103
110
|
decoded = next;
|
|
104
111
|
}
|
|
105
|
-
throw new Error(
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Specifier "${rawSpecifier}" could not be fully decoded within ${MAX_DECODE_ITERATIONS} passes`
|
|
114
|
+
);
|
|
106
115
|
}
|
|
107
116
|
function containsPathTraversal(decodedSpecifier) {
|
|
108
117
|
return decodedSpecifier.split(/[\\/#?]/).some((segment) => segment === "..");
|
|
@@ -134,7 +143,7 @@ function explodeSpecifiers(rawSpecifiers) {
|
|
|
134
143
|
return exploder(rawSpecifier);
|
|
135
144
|
});
|
|
136
145
|
}
|
|
137
|
-
function getSpecifier({specifier, namespace, name = "", version}) {
|
|
146
|
+
function getSpecifier({ specifier, namespace, name = "", version }) {
|
|
138
147
|
if (specifier) {
|
|
139
148
|
const versionMatch = specifier.match(/(.+)\/v\/[a-zA-Z0-9-_.]+$/);
|
|
140
149
|
specifier = versionMatch ? versionMatch[1] : specifier;
|
|
@@ -146,10 +155,10 @@ function getSpecifier({specifier, namespace, name = "", version}) {
|
|
|
146
155
|
async function getVersionedModuleId(rawSpecifier, moduleRegistry, runtimeParams) {
|
|
147
156
|
const moduleId = explodeSpecifier(rawSpecifier);
|
|
148
157
|
if (moduleId.version) {
|
|
149
|
-
return {...moduleId, version: normalizeVersionFromUri(moduleId.version)};
|
|
158
|
+
return { ...moduleId, version: normalizeVersionFromUri(moduleId.version) };
|
|
150
159
|
}
|
|
151
160
|
const moduleEntry = await moduleRegistry.getModuleEntry(moduleId, runtimeParams);
|
|
152
|
-
return {...moduleId, version: moduleEntry.version};
|
|
161
|
+
return { ...moduleId, version: moduleEntry.version };
|
|
153
162
|
}
|
|
154
163
|
function isSpecifier(specifier) {
|
|
155
164
|
return !!specifier && /^@?[\w-.]+(\/[\w-.]+)*$/.test(specifier);
|
|
@@ -167,11 +176,13 @@ function parsePackageSpecifier(specifier) {
|
|
|
167
176
|
return {
|
|
168
177
|
scope,
|
|
169
178
|
packageName: matched[1],
|
|
179
|
+
// @lwrjs/stuff, myapp
|
|
170
180
|
subResource: matched[2] || ""
|
|
171
181
|
};
|
|
172
182
|
}
|
|
173
183
|
return {
|
|
174
184
|
packageName: matched[1],
|
|
185
|
+
// @lwrjs/stuff, myapp
|
|
175
186
|
subResource: matched[2] || ""
|
|
176
187
|
};
|
|
177
188
|
}
|
|
@@ -205,7 +216,7 @@ function slugify(name) {
|
|
|
205
216
|
function getPropFromAttrName(propName) {
|
|
206
217
|
return propName.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
207
218
|
}
|
|
208
|
-
function getModuleUriPrefix({apiVersion, bundle, format, compat, basePath}, {locale, environment} = {}, bundleId) {
|
|
219
|
+
function getModuleUriPrefix({ apiVersion, bundle, format, compat, basePath }, { locale, environment } = {}, bundleId) {
|
|
209
220
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : "";
|
|
210
221
|
const environmentPart = environment ? `/${ENVIRONMENT_SIGIL}/${environment}` : "";
|
|
211
222
|
if (bundle) {
|
|
@@ -214,7 +225,7 @@ function getModuleUriPrefix({apiVersion, bundle, format, compat, basePath}, {loc
|
|
|
214
225
|
return `${basePath}/${apiVersion}/module/${format}/${compat}${localePart}${environmentPart}/mi/`;
|
|
215
226
|
}
|
|
216
227
|
}
|
|
217
|
-
function getMappingUriPrefix({apiVersion, bundle, format, compat, basePath}, {locale, environment} = {}) {
|
|
228
|
+
function getMappingUriPrefix({ apiVersion, bundle, format, compat, basePath }, { locale, environment } = {}) {
|
|
218
229
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : "";
|
|
219
230
|
const environmentPart = environment ? `/${ENVIRONMENT_SIGIL}/${environment}` : "";
|
|
220
231
|
const bundlePart = bundle ? `/${BUNDLE_SIGIL}/0` : "";
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
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);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/shared-utils/src/import-metadata.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var import_metadata_exports = {};
|
|
22
|
+
__export(import_metadata_exports, {
|
|
27
23
|
ModuleNameType: () => ModuleNameType,
|
|
28
24
|
getImportMetadata: () => getImportMetadata
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
var
|
|
26
|
+
module.exports = __toCommonJS(import_metadata_exports);
|
|
27
|
+
var import_es_module_lexer = require("es-module-lexer");
|
|
28
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
32
29
|
var IMPORT_META_REGEX = /^import\.meta(\.\w+)+/;
|
|
33
|
-
var ModuleNameType
|
|
34
|
-
(function(ModuleNameType2) {
|
|
30
|
+
var ModuleNameType = /* @__PURE__ */ ((ModuleNameType2) => {
|
|
35
31
|
ModuleNameType2["string"] = "string";
|
|
36
32
|
ModuleNameType2["unresolved"] = "unresolved";
|
|
37
|
-
|
|
33
|
+
return ModuleNameType2;
|
|
34
|
+
})(ModuleNameType || {});
|
|
38
35
|
async function getImportMetadata(compiledSource) {
|
|
39
36
|
const imports = [];
|
|
40
37
|
const dynamicImports = [];
|
|
@@ -51,12 +48,15 @@ async function getImportMetadata(compiledSource) {
|
|
|
51
48
|
};
|
|
52
49
|
if (isDynamic) {
|
|
53
50
|
const isStringLiteral = moduleSpecifier.startsWith("'") || moduleSpecifier.startsWith('"');
|
|
54
|
-
const moduleNameType = isStringLiteral ?
|
|
51
|
+
const moduleNameType = isStringLiteral ? "string" /* string */ : "unresolved" /* unresolved */;
|
|
55
52
|
moduleSpecifier = isStringLiteral ? moduleSpecifier.slice(1, -1) : moduleSpecifier;
|
|
56
53
|
if (import_diagnostics.logger.isDebugEnabled()) {
|
|
57
54
|
import_diagnostics.logger.debug({
|
|
58
55
|
label: `import-metadata`,
|
|
59
|
-
message: `Import from dynamic import ${compiledSource.slice(
|
|
56
|
+
message: `Import from dynamic import ${compiledSource.slice(
|
|
57
|
+
moduleImportLocation.ss,
|
|
58
|
+
moduleImportLocation.se
|
|
59
|
+
)} -> ${compiledSource.slice(moduleImportLocation.ss, moduleImportLocation.s)}`
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
dynamicImports.push({
|
|
@@ -69,7 +69,7 @@ async function getImportMetadata(compiledSource) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
} else if (isStatic) {
|
|
72
|
-
imports.push({moduleSpecifier, location});
|
|
72
|
+
imports.push({ moduleSpecifier, location });
|
|
73
73
|
} else if (isMeta) {
|
|
74
74
|
const metaMatch = IMPORT_META_REGEX.exec(compiledSource.substring(moduleImportLocation.s));
|
|
75
75
|
if (metaMatch) {
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
11
|
}
|
|
14
|
-
return
|
|
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);
|
|
12
|
+
return to;
|
|
18
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
|
|
20
17
|
// packages/@lwrjs/shared-utils/src/index.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./fs.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./html-meta.cjs"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./identity.cjs"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./interchangeable-modules.cjs"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./link.cjs"), module.exports);
|
|
25
|
+
__reExport(index_exports, require("./object.cjs"), module.exports);
|
|
26
|
+
__reExport(index_exports, require("./serialize.cjs"), module.exports);
|
|
27
|
+
__reExport(index_exports, require("./tasks.cjs"), module.exports);
|
|
28
|
+
__reExport(index_exports, require("./import-metadata.cjs"), module.exports);
|
|
29
|
+
__reExport(index_exports, require("./graph.cjs"), module.exports);
|
|
30
|
+
__reExport(index_exports, require("./mappings.cjs"), module.exports);
|
|
31
|
+
__reExport(index_exports, require("./urls.cjs"), module.exports);
|
|
32
|
+
__reExport(index_exports, require("./env.cjs"), module.exports);
|
|
33
|
+
__reExport(index_exports, require("./lwr-app-observer.cjs"), module.exports);
|
|
34
|
+
__reExport(index_exports, require("./bundle.cjs"), module.exports);
|
|
35
|
+
__reExport(index_exports, require("./localization.cjs"), module.exports);
|
|
36
|
+
__reExport(index_exports, require("./launch.cjs"), module.exports);
|
|
37
|
+
__reExport(index_exports, require("./cookie.cjs"), module.exports);
|
|
38
|
+
__reExport(index_exports, require("./headers.cjs"), module.exports);
|
|
39
|
+
__reExport(index_exports, require("./mrt-utils.cjs"), module.exports);
|
|
@@ -1,37 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
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
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/shared-utils/src/interchangeable-modules.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var interchangeable_modules_exports = {};
|
|
32
|
+
__export(interchangeable_modules_exports, {
|
|
27
33
|
discoverInterchangeableModules: () => discoverInterchangeableModules,
|
|
28
34
|
normalizeInterchangeableModuleConfig: () => normalizeInterchangeableModuleConfig,
|
|
29
35
|
resolveCustomLWCMetadata: () => resolveCustomLWCMetadata
|
|
30
36
|
});
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
37
|
+
module.exports = __toCommonJS(interchangeable_modules_exports);
|
|
38
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
39
|
+
var import_path = __toESM(require("path"), 1);
|
|
40
|
+
var import_resolve = __toESM(require("resolve"), 1);
|
|
41
|
+
var import_fs2 = require("./fs.cjs");
|
|
35
42
|
var CONFIG_FILES = ["package.json", "lwc.config.json", "lwr.config.json"];
|
|
36
43
|
var NoLwcModuleError = class extends Error {
|
|
37
44
|
constructor() {
|
|
@@ -44,10 +51,10 @@ function isNpmModuleRecord(module2) {
|
|
|
44
51
|
}
|
|
45
52
|
function discoverInterchangeableModules(modules, interchangeableModules, visitedModules) {
|
|
46
53
|
if (!interchangeableModules) {
|
|
47
|
-
interchangeableModules = new Map();
|
|
54
|
+
interchangeableModules = /* @__PURE__ */ new Map();
|
|
48
55
|
}
|
|
49
56
|
if (!visitedModules) {
|
|
50
|
-
visitedModules = new Set();
|
|
57
|
+
visitedModules = /* @__PURE__ */ new Set();
|
|
51
58
|
}
|
|
52
59
|
if (modules.length === 0) {
|
|
53
60
|
return interchangeableModules;
|
|
@@ -72,7 +79,10 @@ function discoverInterchangeableModules(modules, interchangeableModules, visited
|
|
|
72
79
|
nestedModules.push(...lwcConfig.modules);
|
|
73
80
|
}
|
|
74
81
|
if (lwcConfig?.interchangeableModules) {
|
|
75
|
-
interchangeableModules = normalizeInterchangeableModuleConfig(
|
|
82
|
+
interchangeableModules = normalizeInterchangeableModuleConfig(
|
|
83
|
+
lwcConfig.interchangeableModules,
|
|
84
|
+
interchangeableModules
|
|
85
|
+
);
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
return discoverInterchangeableModules(nestedModules, interchangeableModules, visitedModules);
|
|
@@ -88,7 +98,7 @@ function resolveCustomLWCMetadata(dir) {
|
|
|
88
98
|
if (!metadata.modules) {
|
|
89
99
|
continue;
|
|
90
100
|
}
|
|
91
|
-
const {interchangeable, interchangeableModules} = metadata;
|
|
101
|
+
const { interchangeable, interchangeableModules } = metadata;
|
|
92
102
|
return {
|
|
93
103
|
interchangeable,
|
|
94
104
|
interchangeableModules
|
|
@@ -98,15 +108,18 @@ function resolveCustomLWCMetadata(dir) {
|
|
|
98
108
|
throw new NoLwcModuleError();
|
|
99
109
|
}
|
|
100
110
|
function normalizeInterchangeableModuleConfig(records, interchangeableModules) {
|
|
101
|
-
return records.reduce(
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
return records.reduce(
|
|
112
|
+
(interchangeableModules2, record) => {
|
|
113
|
+
for (const [target, override] of Object.entries(record.modules)) {
|
|
114
|
+
const contextMap = interchangeableModules2.get(target) || /* @__PURE__ */ new Map();
|
|
115
|
+
if (contextMap.has(record.context)) {
|
|
116
|
+
throw `Multiple implementations found for "${target}" in the "${record.context}" context`;
|
|
117
|
+
}
|
|
118
|
+
contextMap.set(record.context, override);
|
|
119
|
+
interchangeableModules2.set(target, contextMap);
|
|
106
120
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, interchangeableModules || new Map());
|
|
121
|
+
return interchangeableModules2;
|
|
122
|
+
},
|
|
123
|
+
interchangeableModules || /* @__PURE__ */ new Map()
|
|
124
|
+
);
|
|
112
125
|
}
|