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