@lwrjs/shared-utils 0.5.3 → 0.5.7-0.6.0-alpha.2.0
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/env.cjs +3 -3
- package/build/cjs/fs.cjs +13 -11
- package/build/cjs/graph.cjs +11 -11
- package/build/cjs/html-meta.cjs +38 -13
- package/build/cjs/identity.cjs +25 -24
- package/build/cjs/import-metadata.cjs +9 -9
- package/build/cjs/index.cjs +20 -18
- package/build/cjs/interchangeable-modules.cjs +9 -9
- package/build/cjs/link.cjs +32 -0
- package/build/cjs/mappings.cjs +13 -13
- package/build/cjs/metrics.cjs +3 -3
- package/build/cjs/object.cjs +3 -3
- package/build/cjs/serialize.cjs +8 -8
- package/build/cjs/typescript.cjs +11 -11
- package/build/cjs/urls.cjs +83 -0
- package/build/es/fs.d.ts +2 -0
- package/build/es/fs.js +2 -0
- package/build/es/html-meta.js +28 -3
- package/build/es/identity.d.ts +1 -0
- package/build/es/identity.js +2 -1
- package/build/es/index.d.ts +2 -0
- package/build/es/index.js +2 -0
- package/build/es/link.d.ts +3 -0
- package/build/es/link.js +5 -0
- package/build/es/urls.d.ts +35 -0
- package/build/es/urls.js +73 -0
- package/package.json +9 -5
package/build/cjs/env.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
3
|
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
4
5
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
// packages/@lwrjs/shared-utils/src/env.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
11
|
getExperimentalFeatures: () => getExperimentalFeatures
|
|
12
12
|
});
|
package/build/cjs/fs.cjs
CHANGED
|
@@ -1,33 +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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/fs.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
canResolveView: () => canResolveView,
|
|
28
28
|
createFileWatcher: () => createFileWatcher,
|
|
29
29
|
getViewSourceFromFile: () => getViewSourceFromFile,
|
|
30
30
|
hashContent: () => hashContent,
|
|
31
|
+
mimeLookup: () => import_mime_types.lookup,
|
|
31
32
|
normalizeDirectory: () => normalizeDirectory,
|
|
32
33
|
normalizeResourcePath: () => normalizeResourcePath,
|
|
33
34
|
readFile: () => readFile,
|
|
@@ -41,6 +42,7 @@ var import_identity = __toModule(require("./identity.cjs"));
|
|
|
41
42
|
var import_object = __toModule(require("./object.cjs"));
|
|
42
43
|
var import_chokidar = __toModule(require("chokidar"));
|
|
43
44
|
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
45
|
+
var import_mime_types = __toModule(require("mime-types"));
|
|
44
46
|
function hashContent(source) {
|
|
45
47
|
return import_crypto.default.createHash("md5").update(source).digest("hex");
|
|
46
48
|
}
|
|
@@ -68,7 +70,7 @@ function resolveFileExtension(filePath) {
|
|
|
68
70
|
throw new Error(`Unable to find file "${filePath}"`);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
|
-
function createFileWatcher(options = {persistent: true, ignored: "**/node_modules/**"}) {
|
|
73
|
+
function createFileWatcher(options = { persistent: true, ignored: "**/node_modules/**" }) {
|
|
72
74
|
return import_chokidar.default.watch([], options);
|
|
73
75
|
}
|
|
74
76
|
function setupWatcher(onModuleChange) {
|
|
@@ -105,13 +107,13 @@ function normalizeDirectory(dir, rootDir) {
|
|
|
105
107
|
return dir.replace(ROOT_DIR_REGEX, rootDir);
|
|
106
108
|
}
|
|
107
109
|
var RESOURCE_DIR_REGEX = /\$(\w+)|^\$(\w+)/g;
|
|
108
|
-
function normalizeResourcePath(rawPath, {rootDir, assets, contentDir, layoutsDir}, allowUnresolvedAlias) {
|
|
110
|
+
function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, layoutsDir }, allowUnresolvedAlias) {
|
|
109
111
|
const assetsMap = assets.reduce((map, asset) => {
|
|
110
112
|
if (asset.alias) {
|
|
111
113
|
map[asset.alias] = asset.dir || asset.file;
|
|
112
114
|
}
|
|
113
115
|
return map;
|
|
114
|
-
}, {rootDir, contentDir, layoutsDir});
|
|
116
|
+
}, { rootDir, contentDir, layoutsDir });
|
|
115
117
|
return rawPath.replace(RESOURCE_DIR_REGEX, function(fullMatch, m1, m2) {
|
|
116
118
|
const alias = assetsMap[m1] || assetsMap[m2];
|
|
117
119
|
if (!alias && !allowUnresolvedAlias) {
|
package/build/cjs/graph.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/graph.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
GraphDepth: () => GraphDepth,
|
|
28
28
|
getModuleGraphs: () => getModuleGraphs
|
|
@@ -39,13 +39,13 @@ function isBundler(registry) {
|
|
|
39
39
|
return registry.getModuleBundle !== void 0;
|
|
40
40
|
}
|
|
41
41
|
async function traverse(module2, depth, flattened, graphIdx, visited, defRegistry, runtimeEnvironment, runtimeParams) {
|
|
42
|
-
const {includeId: includeIdHook} = depth;
|
|
42
|
+
const { includeId: includeIdHook } = depth;
|
|
43
43
|
const versionedSpecifier = (0, import_identity.getSpecifier)(module2);
|
|
44
|
-
const {imports = [], dynamicImports = []} = (0, import_identity.isBundleDefinition)(module2) ? module2.bundleRecord : module2.moduleRecord;
|
|
44
|
+
const { imports = [], dynamicImports = [] } = (0, import_identity.isBundleDefinition)(module2) ? module2.bundleRecord : module2.moduleRecord;
|
|
45
45
|
const staticImports = imports.map((imp) => (0, import_identity.getSpecifier)(imp));
|
|
46
46
|
const dynamic = dynamicImports.map((imp) => (0, import_identity.getSpecifier)(imp));
|
|
47
47
|
if (!visited.has(versionedSpecifier)) {
|
|
48
|
-
visited.set(versionedSpecifier, {static: staticImports, dynamic});
|
|
48
|
+
visited.set(versionedSpecifier, { static: staticImports, dynamic });
|
|
49
49
|
}
|
|
50
50
|
if (!flattened[graphIdx]) {
|
|
51
51
|
flattened.push({
|
package/build/cjs/html-meta.cjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/html-meta.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
extractMetadataFromHtml: () => extractMetadataFromHtml
|
|
28
28
|
});
|
|
29
29
|
var import_parse5_sax_parser = __toModule(require("parse5-sax-parser"));
|
|
30
30
|
var import_stream = __toModule(require("stream"));
|
|
31
31
|
function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
32
|
-
const {startOffset, endOffset} = attrLocation;
|
|
32
|
+
const { startOffset, endOffset } = attrLocation;
|
|
33
33
|
const srcAttr = htmlSource.substring(startOffset, endOffset);
|
|
34
34
|
const split = srcAttr.indexOf("=");
|
|
35
35
|
const keyAttr = srcAttr.substr(0, split);
|
|
@@ -46,14 +46,26 @@ function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
|
46
46
|
async function extractMetadataFromHtml(htmlSource) {
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
48
48
|
const customElements = [];
|
|
49
|
+
const openElements = new Set();
|
|
49
50
|
const assetReferences = [];
|
|
50
|
-
const parser = new import_parse5_sax_parser.default({sourceCodeLocationInfo: true});
|
|
51
|
+
const parser = new import_parse5_sax_parser.default({ sourceCodeLocationInfo: true });
|
|
52
|
+
const ceRefStack = [];
|
|
51
53
|
parser.on("startTag", ({
|
|
52
54
|
tagName,
|
|
53
55
|
sourceCodeLocation
|
|
54
56
|
}) => {
|
|
55
|
-
if (tagName.includes("-")) {
|
|
56
|
-
|
|
57
|
+
if (tagName.includes("-") && !openElements.has(tagName)) {
|
|
58
|
+
const { startOffset, endOffset } = sourceCodeLocation;
|
|
59
|
+
const ceRef = { tagName, location: { startOffset, endOffset } };
|
|
60
|
+
openElements.add(tagName);
|
|
61
|
+
if (ceRefStack.length) {
|
|
62
|
+
const last = ceRefStack[ceRefStack.length - 1];
|
|
63
|
+
last.children = last.children ? [...last.children, ceRef] : [ceRef];
|
|
64
|
+
ceRefStack.push(ceRef);
|
|
65
|
+
} else {
|
|
66
|
+
customElements.push(ceRef);
|
|
67
|
+
ceRefStack.push(ceRef);
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
if (tagName === "img" && sourceCodeLocation.attrs) {
|
|
59
71
|
if (sourceCodeLocation.attrs.src) {
|
|
@@ -66,8 +78,21 @@ async function extractMetadataFromHtml(htmlSource) {
|
|
|
66
78
|
}
|
|
67
79
|
}
|
|
68
80
|
});
|
|
81
|
+
parser.on("endTag", ({
|
|
82
|
+
tagName,
|
|
83
|
+
sourceCodeLocation
|
|
84
|
+
}) => {
|
|
85
|
+
if (openElements.has(tagName)) {
|
|
86
|
+
const ceRef = ceRefStack.pop();
|
|
87
|
+
openElements.delete(tagName);
|
|
88
|
+
if (!ceRef) {
|
|
89
|
+
throw new Error(`Error extracting metadata: Unmatched custom element close tag for ${tagName}`);
|
|
90
|
+
}
|
|
91
|
+
ceRef.location.endOffset = sourceCodeLocation.endOffset;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
69
94
|
const inputStream = import_stream.Readable.from(htmlSource);
|
|
70
|
-
inputStream.on("end", () => resolve({
|
|
95
|
+
inputStream.on("end", () => resolve({ customElements, assetReferences }));
|
|
71
96
|
inputStream.on("error", (error) => reject(error));
|
|
72
97
|
inputStream.pipe(parser);
|
|
73
98
|
});
|
package/build/cjs/identity.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/identity.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ASSETS_CACHE_DIR: () => ASSETS_CACHE_DIR,
|
|
28
28
|
DEFAULT_LOCKER_TRUSTED_CMP: () => DEFAULT_LOCKER_TRUSTED_CMP,
|
|
@@ -64,7 +64,7 @@ var LATEST_SIGNATURE = "latest";
|
|
|
64
64
|
var DEFAULT_TITLE = "LWR App";
|
|
65
65
|
var IMMUTABLE_ASSET_PREFIX = "/_immutable/";
|
|
66
66
|
var ASSETS_CACHE_DIR = "assetsCache";
|
|
67
|
-
var DEFAULT_LOCKER_TRUSTED_CMP = ["@locker/*", "lwr/*", "@lwrjs/*", "lwc"];
|
|
67
|
+
var DEFAULT_LOCKER_TRUSTED_CMP = ["@locker/*", "lwr/*", "@lwrjs/*", "lwc", "@lwc/*"];
|
|
68
68
|
var DEFAULT_LWR_LOCKER_CONFIG = {
|
|
69
69
|
enabled: false,
|
|
70
70
|
trustedComponents: DEFAULT_LOCKER_TRUSTED_CMP
|
|
@@ -74,7 +74,8 @@ var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
|
74
74
|
syntheticShadow: false,
|
|
75
75
|
workers: {},
|
|
76
76
|
services: [],
|
|
77
|
-
configAsSrc: false
|
|
77
|
+
configAsSrc: false,
|
|
78
|
+
experimentalSSR: false
|
|
78
79
|
};
|
|
79
80
|
function normalizeVersionToUri(version) {
|
|
80
81
|
return version.replace(/\./g, "_");
|
|
@@ -106,7 +107,7 @@ function explodeSpecifiers(rawSpecifiers) {
|
|
|
106
107
|
return exploder(rawSpecifier);
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
|
-
function getSpecifier({specifier, namespace, name = "", version}) {
|
|
110
|
+
function getSpecifier({ specifier, namespace, name = "", version }) {
|
|
110
111
|
if (specifier) {
|
|
111
112
|
const versionMatch = specifier.match(/(.+)\/v\/[a-zA-Z0-9-_.]+$/);
|
|
112
113
|
specifier = versionMatch ? versionMatch[1] : specifier;
|
|
@@ -116,20 +117,20 @@ function getSpecifier({specifier, namespace, name = "", version}) {
|
|
|
116
117
|
return version ? `${bareSpecifier}${VERSION_SIGIL}${normalizeVersionToUri(version)}` : bareSpecifier;
|
|
117
118
|
}
|
|
118
119
|
async function getVersionedSpecifier(rawSpecifier, moduleRegistry) {
|
|
119
|
-
const {specifier, namespace, name, version} = explodeSpecifier(rawSpecifier);
|
|
120
|
+
const { specifier, namespace, name, version } = explodeSpecifier(rawSpecifier);
|
|
120
121
|
if (version) {
|
|
121
122
|
return normalizeVersionToUri(rawSpecifier);
|
|
122
123
|
}
|
|
123
|
-
const moduleEntry = await moduleRegistry.getModuleEntry({specifier});
|
|
124
|
-
return getSpecifier({namespace, name, version: normalizeVersionToUri(moduleEntry.version)});
|
|
124
|
+
const moduleEntry = await moduleRegistry.getModuleEntry({ specifier });
|
|
125
|
+
return getSpecifier({ namespace, name, version: normalizeVersionToUri(moduleEntry.version) });
|
|
125
126
|
}
|
|
126
127
|
async function getVersionedModuleId(rawSpecifier, moduleRegistry) {
|
|
127
|
-
const {specifier, version} = explodeSpecifier(rawSpecifier);
|
|
128
|
+
const { specifier, version } = explodeSpecifier(rawSpecifier);
|
|
128
129
|
if (version) {
|
|
129
|
-
return {specifier, version: normalizeVersionFromUri(version)};
|
|
130
|
+
return { specifier, version: normalizeVersionFromUri(version) };
|
|
130
131
|
}
|
|
131
|
-
const moduleEntry = await moduleRegistry.getModuleEntry({specifier});
|
|
132
|
-
return {specifier, version: moduleEntry.version};
|
|
132
|
+
const moduleEntry = await moduleRegistry.getModuleEntry({ specifier });
|
|
133
|
+
return { specifier, version: moduleEntry.version };
|
|
133
134
|
}
|
|
134
135
|
var RE_SCOPED = /^(@[^/]+\/[^/@]+)(?:\/([^@]+))?(?:@([\s\S]+))?/;
|
|
135
136
|
var RE_NORMAL = /^([^/@]+)(?:\/([^@]+))?(?:@([\s\S]+))?/;
|
|
@@ -179,7 +180,7 @@ function slugify(name) {
|
|
|
179
180
|
lower: true
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
|
-
function getModuleUriPrefix({apiVersion, bundle, format, compat}, {locale, environment} = {}) {
|
|
183
|
+
function getModuleUriPrefix({ apiVersion, bundle, format, compat }, { locale, environment } = {}) {
|
|
183
184
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : "";
|
|
184
185
|
const environmentPart = environment ? `/${ENVIRONMENT_SIGIL}/${environment}` : "";
|
|
185
186
|
if (bundle) {
|
|
@@ -188,7 +189,7 @@ function getModuleUriPrefix({apiVersion, bundle, format, compat}, {locale, envir
|
|
|
188
189
|
return `/${apiVersion}/module/${format}/${compat}${localePart}${environmentPart}/mi/`;
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
function getMappingUriPrefix({apiVersion, bundle, format, compat}, {locale} = {}) {
|
|
192
|
+
function getMappingUriPrefix({ apiVersion, bundle, format, compat }, { locale } = {}) {
|
|
192
193
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : "";
|
|
193
194
|
return `/${apiVersion}/mapping/${format}/${compat}${localePart}/mp/`;
|
|
194
195
|
}
|
|
@@ -200,7 +201,7 @@ function isBundleDefinition(definition) {
|
|
|
200
201
|
return definition.bundleRecord !== void 0;
|
|
201
202
|
}
|
|
202
203
|
function getModuleIdentity(req) {
|
|
203
|
-
const {specifier, signature = LATEST_SIGNATURE} = req.params;
|
|
204
|
+
const { specifier, signature = LATEST_SIGNATURE } = req.params;
|
|
204
205
|
const moduleId = explodeSpecifier(specifier);
|
|
205
206
|
return {
|
|
206
207
|
moduleId,
|
|
@@ -208,14 +209,14 @@ function getModuleIdentity(req) {
|
|
|
208
209
|
};
|
|
209
210
|
}
|
|
210
211
|
function getMappingIdentity(req) {
|
|
211
|
-
const {specifiers} = req.params;
|
|
212
|
+
const { specifiers } = req.params;
|
|
212
213
|
const moduleIds = explodeSpecifiers(specifiers);
|
|
213
214
|
return {
|
|
214
215
|
moduleIds
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
function getResourceIdentity(req) {
|
|
218
|
-
const {specifier, signature = LATEST_SIGNATURE} = req.params;
|
|
219
|
+
const { specifier, signature = LATEST_SIGNATURE } = req.params;
|
|
219
220
|
const resourceId = explodeSpecifier(specifier);
|
|
220
221
|
return {
|
|
221
222
|
resourceId,
|
|
@@ -223,7 +224,7 @@ function getResourceIdentity(req) {
|
|
|
223
224
|
};
|
|
224
225
|
}
|
|
225
226
|
function getAssetIdentity(req) {
|
|
226
|
-
const {signature = LATEST_SIGNATURE, assetType: type} = req.params;
|
|
227
|
+
const { signature = LATEST_SIGNATURE, assetType: type } = req.params;
|
|
227
228
|
const [specifier] = req.originalUrl.split("?");
|
|
228
229
|
return {
|
|
229
230
|
assetId: {
|
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/import-metadata.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ModuleNameType: () => ModuleNameType,
|
|
28
28
|
getImportMetadata: () => getImportMetadata
|
|
@@ -58,7 +58,7 @@ async function getImportMetadata(compiledSource) {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
} else {
|
|
61
|
-
imports.push({moduleSpecifier, location});
|
|
61
|
+
imports.push({ moduleSpecifier, location });
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
return {
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
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
|
|
6
|
-
var
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __exportStar = (target, module2, desc) => {
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __reExport = (target, module2, desc) => {
|
|
9
9
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
10
|
for (let key of __getOwnPropNames(module2))
|
|
11
11
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
12
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
13
|
}
|
|
14
14
|
return target;
|
|
15
15
|
};
|
|
16
16
|
var __toModule = (module2) => {
|
|
17
|
-
return
|
|
17
|
+
return __reExport(__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
18
|
};
|
|
19
19
|
|
|
20
20
|
// packages/@lwrjs/shared-utils/src/index.ts
|
|
21
21
|
__markAsModule(exports);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
__reExport(exports, __toModule(require("./fs.cjs")));
|
|
23
|
+
__reExport(exports, __toModule(require("./html-meta.cjs")));
|
|
24
|
+
__reExport(exports, __toModule(require("./identity.cjs")));
|
|
25
|
+
__reExport(exports, __toModule(require("./interchangeable-modules.cjs")));
|
|
26
|
+
__reExport(exports, __toModule(require("./link.cjs")));
|
|
27
|
+
__reExport(exports, __toModule(require("./object.cjs")));
|
|
28
|
+
__reExport(exports, __toModule(require("./serialize.cjs")));
|
|
29
|
+
__reExport(exports, __toModule(require("./typescript.cjs")));
|
|
30
|
+
__reExport(exports, __toModule(require("./import-metadata.cjs")));
|
|
31
|
+
__reExport(exports, __toModule(require("./graph.cjs")));
|
|
32
|
+
__reExport(exports, __toModule(require("./mappings.cjs")));
|
|
33
|
+
__reExport(exports, __toModule(require("./metrics.cjs")));
|
|
34
|
+
__reExport(exports, __toModule(require("./urls.cjs")));
|
|
35
|
+
__reExport(exports, __toModule(require("./env.cjs")));
|
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/interchangeable-modules.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
discoverInterchangeableModules: () => discoverInterchangeableModules,
|
|
28
28
|
normalizeInterchangeableModuleConfig: () => normalizeInterchangeableModuleConfig,
|
|
@@ -81,7 +81,7 @@ function resolveCustomLWCMetadata(dir) {
|
|
|
81
81
|
if (!metadata.modules) {
|
|
82
82
|
continue;
|
|
83
83
|
}
|
|
84
|
-
const {interchangeable, interchangeableModules} = metadata;
|
|
84
|
+
const { interchangeable, interchangeableModules } = metadata;
|
|
85
85
|
return {
|
|
86
86
|
interchangeable,
|
|
87
87
|
interchangeableModules
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toModule = (module2) => {
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// packages/@lwrjs/shared-utils/src/link.ts
|
|
26
|
+
__export(exports, {
|
|
27
|
+
createStringBuilder: () => createStringBuilder
|
|
28
|
+
});
|
|
29
|
+
var import_magic_string = __toModule(require("magic-string"));
|
|
30
|
+
function createStringBuilder(source) {
|
|
31
|
+
return new import_magic_string.default(source);
|
|
32
|
+
}
|
package/build/cjs/mappings.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/mappings.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
getImportMetadataMappings: () => getImportMetadataMappings,
|
|
28
28
|
toImportMetadata: () => toImportMetadata
|
|
@@ -38,14 +38,14 @@ async function getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeP
|
|
|
38
38
|
for (const moduleId of moduleIds) {
|
|
39
39
|
const specifier = moduleId.specifier;
|
|
40
40
|
if (!visitedCache.has(specifier)) {
|
|
41
|
-
const depth = {static: import_graph.GraphDepth.ALL, dynamic: 0};
|
|
42
|
-
const moduleGraph = await (0, import_graph.getModuleGraphs)(moduleId.specifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, runtimeEnvironment.bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams, visitedCache);
|
|
41
|
+
const depth = { static: import_graph.GraphDepth.ALL, dynamic: 0 };
|
|
42
|
+
const moduleGraph = await (0, import_graph.getModuleGraphs)(moduleId.specifier, { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, runtimeEnvironment.bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams, visitedCache);
|
|
43
43
|
importMetadata = await toImportMetadata(moduleGraph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
return importMetadata;
|
|
47
47
|
}
|
|
48
|
-
async function toImportMetadata(moduleGraph, existingImportMetadata = {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams = {}) {
|
|
48
|
+
async function toImportMetadata(moduleGraph, existingImportMetadata = { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams = {}) {
|
|
49
49
|
const specifier = moduleGraph.graphs[0].specifier;
|
|
50
50
|
const uri = moduleGraph.uriMap[specifier];
|
|
51
51
|
const definition = moduleGraph.linkedDefinitions[specifier];
|
|
@@ -104,13 +104,13 @@ function normalizedIncludedModules(definition) {
|
|
|
104
104
|
}
|
|
105
105
|
async function createIndex(specifiers, moduleRegistry, runtimeEnvironment, runtimeParams) {
|
|
106
106
|
const index = {};
|
|
107
|
-
const moduleRuntimeEnvironment = {...runtimeEnvironment, bundle: false};
|
|
107
|
+
const moduleRuntimeEnvironment = { ...runtimeEnvironment, bundle: false };
|
|
108
108
|
async function getUri(specifier) {
|
|
109
109
|
const moduleId = (0, import_identity.explodeSpecifier)(specifier);
|
|
110
110
|
if (!moduleId.version) {
|
|
111
111
|
throw new Error("Module specifier must include a version: " + specifier);
|
|
112
112
|
}
|
|
113
|
-
index[specifier] = await moduleRegistry.resolveModuleUri({...moduleId, version: moduleId.version}, moduleRuntimeEnvironment, runtimeParams);
|
|
113
|
+
index[specifier] = await moduleRegistry.resolveModuleUri({ ...moduleId, version: moduleId.version }, moduleRuntimeEnvironment, runtimeParams);
|
|
114
114
|
}
|
|
115
115
|
const promises = [];
|
|
116
116
|
for (const specifier of specifiers) {
|
package/build/cjs/metrics.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
3
|
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
4
5
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
// packages/@lwrjs/shared-utils/src/metrics.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
11
|
ON_APP_INIT: () => ON_APP_INIT,
|
|
12
12
|
ON_APP_LOAD: () => ON_APP_LOAD
|
package/build/cjs/object.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
3
|
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
4
5
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
// packages/@lwrjs/shared-utils/src/object.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
11
|
debounce: () => debounce,
|
|
12
12
|
deepFreeze: () => deepFreeze
|
package/build/cjs/serialize.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
3
|
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
4
5
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
// packages/@lwrjs/shared-utils/src/serialize.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
11
|
replaceStringFromLocation: () => replaceStringFromLocation,
|
|
12
12
|
serializeModuleToJson: () => serializeModuleToJson
|
|
@@ -14,7 +14,7 @@ __export(exports, {
|
|
|
14
14
|
async function createJsonModule(moduleId, moduleRegistry, runtimeEnvironment, runtimeParams) {
|
|
15
15
|
const {
|
|
16
16
|
ownHash,
|
|
17
|
-
moduleEntry: {version}
|
|
17
|
+
moduleEntry: { version }
|
|
18
18
|
} = await moduleRegistry.getModule(moduleId, runtimeParams);
|
|
19
19
|
return {
|
|
20
20
|
specifier: moduleId.specifier,
|
|
@@ -30,10 +30,10 @@ async function serializeModuleToJson(code = "", {
|
|
|
30
30
|
version,
|
|
31
31
|
ownHash,
|
|
32
32
|
runtimeEnvironment,
|
|
33
|
-
linkedConfig: {minified},
|
|
34
|
-
moduleRecord: {imports = []}
|
|
33
|
+
linkedConfig: { minified },
|
|
34
|
+
moduleRecord: { imports = [] }
|
|
35
35
|
}, moduleRegistry, runtimeParams) {
|
|
36
|
-
const {format} = runtimeEnvironment;
|
|
36
|
+
const { format } = runtimeEnvironment;
|
|
37
37
|
const dependencies = imports.map((dep) => createJsonModule(dep, moduleRegistry, runtimeEnvironment, runtimeParams));
|
|
38
38
|
return {
|
|
39
39
|
specifier,
|
|
@@ -45,6 +45,6 @@ async function serializeModuleToJson(code = "", {
|
|
|
45
45
|
code
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
function replaceStringFromLocation(src, {startOffset, endOffset}, replaceValue) {
|
|
48
|
+
function replaceStringFromLocation(src, { startOffset, endOffset }, replaceValue) {
|
|
49
49
|
return src.substr(0, startOffset) + replaceValue + src.substr(endOffset, src.length);
|
|
50
50
|
}
|
package/build/cjs/typescript.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
9
10
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
12
|
};
|
|
12
|
-
var
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
13
14
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
15
|
for (let key of __getOwnPropNames(module2))
|
|
15
16
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
18
|
}
|
|
18
19
|
return target;
|
|
19
20
|
};
|
|
20
21
|
var __toModule = (module2) => {
|
|
21
|
-
return
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
// packages/@lwrjs/shared-utils/src/typescript.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
transpileTs: () => transpileTs
|
|
28
28
|
});
|
|
@@ -41,7 +41,7 @@ var ESBUILD_EXTENSION_PLUGIN = function(absFilePath, format) {
|
|
|
41
41
|
return {
|
|
42
42
|
name: "replace-extension-plugin",
|
|
43
43
|
setup(build) {
|
|
44
|
-
build.onResolve({filter: /.*/}, ({path, importer, resolveDir}) => {
|
|
44
|
+
build.onResolve({ filter: /.*/ }, ({ path, importer, resolveDir }) => {
|
|
45
45
|
if (path !== absFilePath) {
|
|
46
46
|
if (path.startsWith(".")) {
|
|
47
47
|
const importeeExt = (0, import_path.extname)(path);
|
|
@@ -50,7 +50,7 @@ var ESBUILD_EXTENSION_PLUGIN = function(absFilePath, format) {
|
|
|
50
50
|
if (!import_fs.default.existsSync(absPath) && ext === ".js") {
|
|
51
51
|
absPath = absPath.replace(".js", ".ts");
|
|
52
52
|
}
|
|
53
|
-
return {path: absPath};
|
|
53
|
+
return { path: absPath };
|
|
54
54
|
} else {
|
|
55
55
|
return {
|
|
56
56
|
external: true
|
|
@@ -61,7 +61,7 @@ var ESBUILD_EXTENSION_PLUGIN = function(absFilePath, format) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
async function transpileTs(tsAbsPath, {rootDir, cacheDir}) {
|
|
64
|
+
async function transpileTs(tsAbsPath, { rootDir, cacheDir }) {
|
|
65
65
|
const format = isCommonJs ? "cjs" : "esm";
|
|
66
66
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
67
67
|
const pathRelativeToRoot = tsAbsPath.replace(new RegExp(`^${rootDir}`), "");
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
__markAsModule(target);
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toModule = (module2) => {
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// packages/@lwrjs/shared-utils/src/urls.ts
|
|
26
|
+
__export(exports, {
|
|
27
|
+
extractRequestParams: () => extractRequestParams,
|
|
28
|
+
getClientBootstrapConfigurationRoutes: () => getClientBootstrapConfigurationRoutes,
|
|
29
|
+
getClientBootstrapConfigurationUri: () => getClientBootstrapConfigurationUri,
|
|
30
|
+
getClientBootstrapConfigurationUriPrefix: () => getClientBootstrapConfigurationUriPrefix,
|
|
31
|
+
removeClientBootstrapConfigurationSuffix: () => removeClientBootstrapConfigurationSuffix
|
|
32
|
+
});
|
|
33
|
+
var import_path_to_regexp = __toModule(require("path-to-regexp"));
|
|
34
|
+
var CONFIG_SUFFIX = "/config.js";
|
|
35
|
+
function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
36
|
+
const encodeUrl = encodeURIComponent(routeInfo.url);
|
|
37
|
+
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
38
|
+
return `${configUrlPrefix}/${encodeUrl}${CONFIG_SUFFIX}`;
|
|
39
|
+
}
|
|
40
|
+
function getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
41
|
+
const { apiVersion, format } = runtimeEnvironment;
|
|
42
|
+
const { id } = routeInfo;
|
|
43
|
+
const locale = runtimeParams?.locale;
|
|
44
|
+
const environment = runtimeParams?.environment;
|
|
45
|
+
if (locale && environment) {
|
|
46
|
+
return `/${apiVersion}/application/${format}/l/${locale}/e/${environment}/ai/${id}/configuration/ci`;
|
|
47
|
+
} else if (locale) {
|
|
48
|
+
return `/${apiVersion}/application/${format}/l/${locale}/ai/${id}/configuration/ci`;
|
|
49
|
+
} else if (environment) {
|
|
50
|
+
return `/${apiVersion}/application/${format}/e/${environment}/ai/${id}/configuration/ci`;
|
|
51
|
+
} else {
|
|
52
|
+
return `/${apiVersion}/application/${format}/ai/${id}/configuration/ci`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function removeClientBootstrapConfigurationSuffix(url) {
|
|
56
|
+
let ret = url;
|
|
57
|
+
if (url.endsWith(CONFIG_SUFFIX)) {
|
|
58
|
+
ret = url.slice(0, -CONFIG_SUFFIX.length);
|
|
59
|
+
}
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
function getClientBootstrapConfigurationRoutes() {
|
|
63
|
+
return [
|
|
64
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
65
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
66
|
+
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
67
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function extractRequestParams(parameterizedRoute, resolvedUrl, existingParams) {
|
|
71
|
+
const keys = [];
|
|
72
|
+
const re = (0, import_path_to_regexp.pathToRegexp)(parameterizedRoute, keys);
|
|
73
|
+
const params = existingParams || {};
|
|
74
|
+
if (keys.length > 0) {
|
|
75
|
+
const result = re.exec(resolvedUrl) || new Array(keys.length);
|
|
76
|
+
for (let i = 0; i < keys.length; i++) {
|
|
77
|
+
const key = keys[i].name;
|
|
78
|
+
const value = result[i + 1];
|
|
79
|
+
params[key] = value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return params;
|
|
83
|
+
}
|
package/build/es/fs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ResourcePaths, Watcher, ViewSource } from '@lwrjs/types';
|
|
3
|
+
import { lookup } from 'mime-types';
|
|
3
4
|
/**
|
|
4
5
|
* Create a hash string for a source
|
|
5
6
|
* @param source
|
|
@@ -39,4 +40,5 @@ export declare function canResolveView(source: string, type: string): boolean;
|
|
|
39
40
|
export declare function getViewSourceFromFile(source: string): ViewSource;
|
|
40
41
|
export declare function normalizeDirectory(dir: string, rootDir: string): string;
|
|
41
42
|
export declare function normalizeResourcePath(rawPath: string, { rootDir, assets, contentDir, layoutsDir }: ResourcePaths, allowUnresolvedAlias?: boolean): string;
|
|
43
|
+
export { lookup as mimeLookup };
|
|
42
44
|
//# sourceMappingURL=fs.d.ts.map
|
package/build/es/fs.js
CHANGED
|
@@ -5,6 +5,7 @@ import { slugify } from './identity.js';
|
|
|
5
5
|
import { debounce } from './object.js';
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
7
|
import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
|
|
8
|
+
import { lookup } from 'mime-types';
|
|
8
9
|
/**
|
|
9
10
|
* Create a hash string for a source
|
|
10
11
|
* @param source
|
|
@@ -135,4 +136,5 @@ export function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, la
|
|
|
135
136
|
return alias;
|
|
136
137
|
});
|
|
137
138
|
}
|
|
139
|
+
export { lookup as mimeLookup };
|
|
138
140
|
//# sourceMappingURL=fs.js.map
|
package/build/es/html-meta.js
CHANGED
|
@@ -24,12 +24,26 @@ function parseAssetLocation(htmlSource, tagName, attrLocation) {
|
|
|
24
24
|
export async function extractMetadataFromHtml(htmlSource) {
|
|
25
25
|
return new Promise((resolve, reject) => {
|
|
26
26
|
const customElements = [];
|
|
27
|
+
const openElements = new Set();
|
|
27
28
|
const assetReferences = [];
|
|
28
29
|
const parser = new SAXParser({ sourceCodeLocationInfo: true }); // TODO: Would we need this in the future?
|
|
30
|
+
const ceRefStack = [];
|
|
29
31
|
parser.on('startTag', ({ tagName, sourceCodeLocation, }) => {
|
|
30
32
|
// custom elements
|
|
31
|
-
if (tagName.includes('-')) {
|
|
32
|
-
|
|
33
|
+
if (tagName.includes('-') && !openElements.has(tagName)) {
|
|
34
|
+
const { startOffset, endOffset } = sourceCodeLocation;
|
|
35
|
+
const ceRef = { tagName, location: { startOffset, endOffset } };
|
|
36
|
+
openElements.add(tagName);
|
|
37
|
+
if (ceRefStack.length) {
|
|
38
|
+
// nested CE
|
|
39
|
+
const last = ceRefStack[ceRefStack.length - 1];
|
|
40
|
+
last.children = last.children ? [...last.children, ceRef] : [ceRef];
|
|
41
|
+
ceRefStack.push(ceRef);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
customElements.push(ceRef);
|
|
45
|
+
ceRefStack.push(ceRef);
|
|
46
|
+
}
|
|
33
47
|
}
|
|
34
48
|
// <img src="asset-url"/>
|
|
35
49
|
if (tagName === 'img' && sourceCodeLocation.attrs) {
|
|
@@ -47,9 +61,20 @@ export async function extractMetadataFromHtml(htmlSource) {
|
|
|
47
61
|
}
|
|
48
62
|
}
|
|
49
63
|
});
|
|
64
|
+
parser.on('endTag', ({ tagName, sourceCodeLocation, }) => {
|
|
65
|
+
if (openElements.has(tagName)) {
|
|
66
|
+
const ceRef = ceRefStack.pop();
|
|
67
|
+
openElements.delete(tagName);
|
|
68
|
+
if (!ceRef) {
|
|
69
|
+
throw new Error(`Error extracting metadata: Unmatched custom element close tag for ${tagName}`);
|
|
70
|
+
}
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
ceRef.location.endOffset = sourceCodeLocation.endOffset;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
50
75
|
const inputStream = Readable.from(htmlSource);
|
|
51
76
|
// dedupe custom element references
|
|
52
|
-
inputStream.on('end', () => resolve({ customElements
|
|
77
|
+
inputStream.on('end', () => resolve({ customElements, assetReferences }));
|
|
53
78
|
inputStream.on('error', (error) => reject(error));
|
|
54
79
|
inputStream.pipe(parser);
|
|
55
80
|
});
|
package/build/es/identity.d.ts
CHANGED
package/build/es/identity.js
CHANGED
|
@@ -8,7 +8,7 @@ export const DEFAULT_TITLE = 'LWR App';
|
|
|
8
8
|
export const IMMUTABLE_ASSET_PREFIX = '/_immutable/';
|
|
9
9
|
export const ASSETS_CACHE_DIR = 'assetsCache';
|
|
10
10
|
// Locker trusted components
|
|
11
|
-
export const DEFAULT_LOCKER_TRUSTED_CMP = ['@locker/*', 'lwr/*', '@lwrjs/*', 'lwc'];
|
|
11
|
+
export const DEFAULT_LOCKER_TRUSTED_CMP = ['@locker/*', 'lwr/*', '@lwrjs/*', 'lwc', '@lwc/*'];
|
|
12
12
|
export const DEFAULT_LWR_LOCKER_CONFIG = {
|
|
13
13
|
enabled: false,
|
|
14
14
|
trustedComponents: DEFAULT_LOCKER_TRUSTED_CMP,
|
|
@@ -19,6 +19,7 @@ export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
|
19
19
|
workers: {},
|
|
20
20
|
services: [],
|
|
21
21
|
configAsSrc: false,
|
|
22
|
+
experimentalSSR: false,
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
25
|
* Turn the dots in a version into underscores
|
package/build/es/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './fs.js';
|
|
|
2
2
|
export * from './html-meta.js';
|
|
3
3
|
export * from './identity.js';
|
|
4
4
|
export * from './interchangeable-modules.js';
|
|
5
|
+
export * from './link.js';
|
|
5
6
|
export * from './object.js';
|
|
6
7
|
export * from './serialize.js';
|
|
7
8
|
export * from './typescript.js';
|
|
@@ -9,5 +10,6 @@ export * from './import-metadata.js';
|
|
|
9
10
|
export * from './graph.js';
|
|
10
11
|
export * from './mappings.js';
|
|
11
12
|
export * from './metrics.js';
|
|
13
|
+
export * from './urls.js';
|
|
12
14
|
export * from './env.js';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './fs.js';
|
|
|
2
2
|
export * from './html-meta.js';
|
|
3
3
|
export * from './identity.js';
|
|
4
4
|
export * from './interchangeable-modules.js';
|
|
5
|
+
export * from './link.js';
|
|
5
6
|
export * from './object.js';
|
|
6
7
|
export * from './serialize.js';
|
|
7
8
|
export * from './typescript.js';
|
|
@@ -9,5 +10,6 @@ export * from './import-metadata.js';
|
|
|
9
10
|
export * from './graph.js';
|
|
10
11
|
export * from './mappings.js';
|
|
11
12
|
export * from './metrics.js';
|
|
13
|
+
export * from './urls.js';
|
|
12
14
|
export * from './env.js';
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/build/es/link.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ModuleFormat, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
|
|
2
|
+
export declare function getClientBootstrapConfigurationUri(routeInfo: {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
}, runtimeEnvironment: Partial<RuntimeEnvironment> & {
|
|
6
|
+
apiVersion: string;
|
|
7
|
+
format: ModuleFormat;
|
|
8
|
+
}, runtimeParams?: RuntimeParams): string;
|
|
9
|
+
export declare function getClientBootstrapConfigurationUriPrefix(routeInfo: {
|
|
10
|
+
id: string;
|
|
11
|
+
}, runtimeEnvironment: Partial<RuntimeEnvironment> & {
|
|
12
|
+
apiVersion: string;
|
|
13
|
+
format: ModuleFormat;
|
|
14
|
+
}, runtimeParams?: RuntimeParams): string;
|
|
15
|
+
/**
|
|
16
|
+
* Remove the suffix from config
|
|
17
|
+
*/
|
|
18
|
+
export declare function removeClientBootstrapConfigurationSuffix(url: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the parameterized client bootstrap app configuration routes
|
|
21
|
+
*/
|
|
22
|
+
export declare function getClientBootstrapConfigurationRoutes(): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Extract param values from a resolved URL based on a parameterized route. Keep existing param values.
|
|
25
|
+
* Uses path-to-regexp to match -> https://www.npmjs.com/package/path-to-regexp
|
|
26
|
+
*
|
|
27
|
+
* extractRequestParams('/:p1/:p2*', '/foo/bar/barz', {e1:'v1'}) => {e1:'v1', p1:'foo', p2:'bar/barz'}
|
|
28
|
+
*
|
|
29
|
+
* @param parameterizedRoute - A Url with parameter tokens
|
|
30
|
+
* @param resolvedUrl - A url with tokens filled in to match against
|
|
31
|
+
* @param existingParams - optional existing request parameters to match against
|
|
32
|
+
* @returns A parameter maps with existing parameters plus token value pairs from route and url
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractRequestParams(parameterizedRoute: string, resolvedUrl: string, existingParams?: Record<string, string>): Record<string, string>;
|
|
35
|
+
//# sourceMappingURL=urls.d.ts.map
|
package/build/es/urls.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { pathToRegexp } from 'path-to-regexp';
|
|
2
|
+
const CONFIG_SUFFIX = '/config.js';
|
|
3
|
+
export function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
4
|
+
const encodeUrl = encodeURIComponent(routeInfo.url);
|
|
5
|
+
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
6
|
+
return `${configUrlPrefix}/${encodeUrl}${CONFIG_SUFFIX}`;
|
|
7
|
+
}
|
|
8
|
+
export function getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
9
|
+
const { apiVersion, format } = runtimeEnvironment;
|
|
10
|
+
const { id } = routeInfo;
|
|
11
|
+
const locale = runtimeParams?.locale;
|
|
12
|
+
const environment = runtimeParams?.environment;
|
|
13
|
+
if (locale && environment) {
|
|
14
|
+
return `/${apiVersion}/application/${format}/l/${locale}/e/${environment}/ai/${id}/configuration/ci`;
|
|
15
|
+
}
|
|
16
|
+
else if (locale) {
|
|
17
|
+
return `/${apiVersion}/application/${format}/l/${locale}/ai/${id}/configuration/ci`;
|
|
18
|
+
}
|
|
19
|
+
else if (environment) {
|
|
20
|
+
return `/${apiVersion}/application/${format}/e/${environment}/ai/${id}/configuration/ci`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return `/${apiVersion}/application/${format}/ai/${id}/configuration/ci`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Remove the suffix from config
|
|
28
|
+
*/
|
|
29
|
+
export function removeClientBootstrapConfigurationSuffix(url) {
|
|
30
|
+
let ret = url;
|
|
31
|
+
if (url.endsWith(CONFIG_SUFFIX)) {
|
|
32
|
+
ret = url.slice(0, -CONFIG_SUFFIX.length);
|
|
33
|
+
}
|
|
34
|
+
return ret;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the parameterized client bootstrap app configuration routes
|
|
38
|
+
*/
|
|
39
|
+
export function getClientBootstrapConfigurationRoutes() {
|
|
40
|
+
return [
|
|
41
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
42
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
43
|
+
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
44
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Extract param values from a resolved URL based on a parameterized route. Keep existing param values.
|
|
49
|
+
* Uses path-to-regexp to match -> https://www.npmjs.com/package/path-to-regexp
|
|
50
|
+
*
|
|
51
|
+
* extractRequestParams('/:p1/:p2*', '/foo/bar/barz', {e1:'v1'}) => {e1:'v1', p1:'foo', p2:'bar/barz'}
|
|
52
|
+
*
|
|
53
|
+
* @param parameterizedRoute - A Url with parameter tokens
|
|
54
|
+
* @param resolvedUrl - A url with tokens filled in to match against
|
|
55
|
+
* @param existingParams - optional existing request parameters to match against
|
|
56
|
+
* @returns A parameter maps with existing parameters plus token value pairs from route and url
|
|
57
|
+
*/
|
|
58
|
+
export function extractRequestParams(parameterizedRoute, resolvedUrl, existingParams) {
|
|
59
|
+
const keys = [];
|
|
60
|
+
const re = pathToRegexp(parameterizedRoute, keys);
|
|
61
|
+
const params = existingParams || {};
|
|
62
|
+
if (keys.length > 0) {
|
|
63
|
+
const result = re.exec(resolvedUrl) || new Array(keys.length);
|
|
64
|
+
for (let i = 0; i < keys.length; i++) {
|
|
65
|
+
const key = keys[i].name;
|
|
66
|
+
// result array if [url, value, value] so add 1 to count to get matching value
|
|
67
|
+
const value = result[i + 1];
|
|
68
|
+
params[key] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return params;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=urls.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.5.
|
|
7
|
+
"version": "0.5.7-0.6.0-alpha.2.0",
|
|
8
8
|
"homepage": "https://lwr.dev/",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -37,15 +37,19 @@
|
|
|
37
37
|
"es-module-lexer": "^0.3.18",
|
|
38
38
|
"esbuild": "^0.8.42",
|
|
39
39
|
"fast-json-stable-stringify": "^2.1.0",
|
|
40
|
+
"magic-string": "^0.25.7",
|
|
41
|
+
"mime-types": "^2.1.33",
|
|
40
42
|
"parse5-sax-parser": "^6.0.1",
|
|
41
43
|
"slugify": "^1.4.5"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@lwrjs/diagnostics": "0.5.
|
|
45
|
-
"@lwrjs/types": "0.5.
|
|
46
|
+
"@lwrjs/diagnostics": "0.5.7-0.6.0-alpha.2.0",
|
|
47
|
+
"@lwrjs/types": "0.5.7-0.6.0-alpha.2.0",
|
|
48
|
+
"@types/mime-types": "2.1.1",
|
|
49
|
+
"@types/path-to-regexp": "^1.7.0"
|
|
46
50
|
},
|
|
47
51
|
"engines": {
|
|
48
|
-
"node": ">=14.15.4 <
|
|
52
|
+
"node": ">=14.15.4 <17"
|
|
49
53
|
},
|
|
50
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "f027dd906e4341bad0085aa21ae82b96743f36aa"
|
|
51
55
|
}
|