@lwrjs/shared-utils 0.24.2 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bundle.cjs +24 -20
- package/build/cjs/compiler.cjs +22 -25
- package/build/cjs/cookie.cjs +27 -11
- package/build/cjs/env.cjs +40 -12
- package/build/cjs/fs.cjs +50 -40
- package/build/cjs/graph.cjs +78 -38
- package/build/cjs/headers.cjs +17 -4
- package/build/cjs/html-meta.cjs +56 -38
- package/build/cjs/identity.cjs +34 -23
- package/build/cjs/import-metadata.cjs +25 -25
- package/build/cjs/index.cjs +33 -35
- package/build/cjs/interchangeable-modules.cjs +46 -33
- package/build/cjs/launch.cjs +24 -17
- package/build/cjs/link.cjs +23 -16
- package/build/cjs/localization.cjs +24 -17
- package/build/cjs/lwr-app-observer.cjs +15 -18
- package/build/cjs/mappings.cjs +76 -37
- package/build/cjs/mrt-utils.cjs +15 -18
- package/build/cjs/object.cjs +24 -8
- package/build/cjs/serialize.cjs +53 -37
- package/build/cjs/tasks.cjs +33 -5
- package/build/cjs/urls.cjs +34 -22
- package/package.json +4 -4
package/build/cjs/bundle.cjs
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/shared-utils/src/bundle.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var bundle_exports = {};
|
|
22
|
+
__export(bundle_exports, {
|
|
27
23
|
createAmdAlias: () => createAmdAlias,
|
|
28
24
|
createBundleSigner: () => createBundleSigner,
|
|
29
25
|
getGroupName: () => getGroupName,
|
|
30
26
|
isGroupie: () => isGroupie,
|
|
31
27
|
signBundle: () => signBundle
|
|
32
28
|
});
|
|
33
|
-
|
|
29
|
+
module.exports = __toCommonJS(bundle_exports);
|
|
30
|
+
var import_identity = require("./identity.cjs");
|
|
34
31
|
function getGroupName(rawSpecifier, groupsConfig) {
|
|
35
32
|
for (const [groupName, groupies] of Object.entries(groupsConfig)) {
|
|
36
33
|
if (groupies.indexOf(rawSpecifier) >= 0) {
|
|
@@ -53,14 +50,21 @@ function createAmdAlias(aliasSpecifier, originalSpecifier) {
|
|
|
53
50
|
const builder = [];
|
|
54
51
|
builder.push(`LWR.define('${aliasSpecifier}',['exports','${originalSpecifier}'],function(e,m){`);
|
|
55
52
|
builder.push(`e.default=m&&'object'==typeof m&&'default'in m?m.default:m;`);
|
|
56
|
-
builder.push(
|
|
53
|
+
builder.push(
|
|
54
|
+
`Object.keys(m).forEach(function(n){'default'===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return m[n]}})});`
|
|
55
|
+
);
|
|
57
56
|
builder.push("});");
|
|
58
57
|
return builder.join("");
|
|
59
58
|
}
|
|
60
59
|
function createBundleSigner(moduleBundler) {
|
|
61
60
|
return {
|
|
62
61
|
getBundleSignature: async (moduleId, runtimeEnvironment, runtimeParams, exclude) => {
|
|
63
|
-
const def = await moduleBundler.getModuleBundle(
|
|
62
|
+
const def = await moduleBundler.getModuleBundle(
|
|
63
|
+
moduleId,
|
|
64
|
+
runtimeEnvironment,
|
|
65
|
+
runtimeParams,
|
|
66
|
+
exclude ? { exclude } : void 0
|
|
67
|
+
);
|
|
64
68
|
return signBundle(def);
|
|
65
69
|
}
|
|
66
70
|
};
|
package/build/cjs/compiler.cjs
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/shared-utils/src/compiler.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var compiler_exports = {};
|
|
22
|
+
__export(compiler_exports, {
|
|
27
23
|
AMD_DEFINE: () => AMD_DEFINE,
|
|
28
24
|
convertToAmd: () => convertToAmd
|
|
29
25
|
});
|
|
30
|
-
|
|
26
|
+
module.exports = __toCommonJS(compiler_exports);
|
|
27
|
+
var import_rollup = require("rollup");
|
|
31
28
|
var AMD_DEFINE = "LWR.define";
|
|
32
29
|
var AMD_ROLLUP_PLUGIN = function(rootId, source) {
|
|
33
30
|
return {
|
|
@@ -40,21 +37,21 @@ var AMD_ROLLUP_PLUGIN = function(rootId, source) {
|
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
39
|
};
|
|
43
|
-
async function convertToAmd(source, {id}, forceNamedExports = true) {
|
|
40
|
+
async function convertToAmd(source, { id }, forceNamedExports = true) {
|
|
44
41
|
const bundler = await (0, import_rollup.rollup)({
|
|
45
42
|
input: id,
|
|
46
43
|
plugins: [AMD_ROLLUP_PLUGIN(id, source)],
|
|
47
44
|
onwarn(warning, warn) {
|
|
48
|
-
if (warning.code === "UNRESOLVED_IMPORT")
|
|
49
|
-
return;
|
|
45
|
+
if (warning.code === "UNRESOLVED_IMPORT") return;
|
|
50
46
|
warn(warning);
|
|
51
47
|
}
|
|
52
48
|
});
|
|
53
|
-
const {output} = await bundler.generate({
|
|
54
|
-
amd: {id, define: AMD_DEFINE},
|
|
49
|
+
const { output } = await bundler.generate({
|
|
50
|
+
amd: { id, define: AMD_DEFINE },
|
|
55
51
|
exports: forceNamedExports ? "named" : "auto",
|
|
52
|
+
// 'auto' is rollup default
|
|
56
53
|
format: "amd"
|
|
57
54
|
});
|
|
58
|
-
const {code} = output[0];
|
|
59
|
-
return {code, map: null};
|
|
55
|
+
const { code } = output[0];
|
|
56
|
+
return { code, map: null };
|
|
60
57
|
}
|
package/build/cjs/cookie.cjs
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
6
|
var __export = (target, all) => {
|
|
4
7
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
9
|
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
7
19
|
|
|
8
20
|
// packages/@lwrjs/shared-utils/src/cookie.ts
|
|
9
|
-
|
|
10
|
-
__export(
|
|
21
|
+
var cookie_exports = {};
|
|
22
|
+
__export(cookie_exports, {
|
|
11
23
|
cookieStringToObject: () => cookieStringToObject
|
|
12
24
|
});
|
|
25
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
13
26
|
function cookieStringToObject(cookieString) {
|
|
14
|
-
return cookieString.split(";").reduce(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
return cookieString.split(";").reduce(
|
|
28
|
+
(cookies, cookie) => {
|
|
29
|
+
const [name, value] = cookie.trim().split("=");
|
|
30
|
+
if (name && value) {
|
|
31
|
+
cookies[name] = decodeURIComponent(value);
|
|
32
|
+
}
|
|
33
|
+
return cookies;
|
|
34
|
+
},
|
|
35
|
+
{}
|
|
36
|
+
);
|
|
21
37
|
}
|
package/build/cjs/env.cjs
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
6
|
var __export = (target, all) => {
|
|
4
7
|
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
9
|
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
7
19
|
|
|
8
20
|
// packages/@lwrjs/shared-utils/src/env.ts
|
|
9
|
-
|
|
10
|
-
__export(
|
|
21
|
+
var env_exports = {};
|
|
22
|
+
__export(env_exports, {
|
|
11
23
|
B3_PARENT_ID: () => B3_PARENT_ID,
|
|
12
24
|
B3_SAMPLED: () => B3_SAMPLED,
|
|
13
25
|
B3_SPAN_ID: () => B3_SPAN_ID,
|
|
@@ -27,27 +39,47 @@ __export(exports, {
|
|
|
27
39
|
isMrtBundle: () => isMrtBundle,
|
|
28
40
|
parseRequestDepth: () => parseRequestDepth
|
|
29
41
|
});
|
|
42
|
+
module.exports = __toCommonJS(env_exports);
|
|
30
43
|
if (getFeatureFlags().REEVALUATE_MODULES && !getFeatureFlags().LEGACY_LOADER) {
|
|
31
44
|
throw new Error("REEVALUATE_MODULES is only supported with LEGACY_LOADER");
|
|
32
45
|
}
|
|
33
46
|
function getFeatureFlags() {
|
|
34
47
|
return {
|
|
48
|
+
// Should we load load the assets from the lambda on MRT
|
|
35
49
|
ASSETS_ON_LAMBDA: parseBooleanFlag("ASSETS_ON_LAMBDA"),
|
|
50
|
+
// Number of BundleDefinition and BundleCode instances held in memory
|
|
36
51
|
BUNDLE_CACHE_SIZE: parseStringFlag("BUNDLE_CACHE_SIZE"),
|
|
37
52
|
ENABLE_NONCE: parseBooleanFlag("ENABLE_NONCE"),
|
|
53
|
+
// AMD Module Bundles include un-versioned aliases
|
|
38
54
|
EXPERIMENTAL_UNVERSIONED_ALIASES: parseBooleanFlag("EXPERIMENTAL_UNVERSIONED_ALIASES"),
|
|
55
|
+
// DEFAULT LEGACY_LOADER = false;
|
|
39
56
|
LEGACY_LOADER: parseBooleanFlag("LEGACY_LOADER"),
|
|
57
|
+
// Enable metrics log level 'off', 'default' or 'verbose'
|
|
40
58
|
LWR_TRACING: parseTracingFlag(),
|
|
59
|
+
// Turn off distributed tracing (B3 headers, traceparent meta tag, MRT span exporting)
|
|
60
|
+
// Legacy flag - kept for backward compatibility but no longer controls B3 headers
|
|
41
61
|
DISABLE_B3_TRACING: parseBooleanFlag("DISABLE_B3_TRACING"),
|
|
62
|
+
// Control x-b3-* distributed tracing headers specifically for MRT sites
|
|
42
63
|
MRT_B3_TRACING: parseBooleanFlag("MRT_B3_TRACING"),
|
|
64
|
+
// Max size of ViewDefinition time to live
|
|
43
65
|
MAX_VIEW_CACHE_TTL: parseStringFlag("MAX_VIEW_CACHE_TTL"),
|
|
66
|
+
// Forces SSR to re-evaluate modules for every page render. By default, modules are evaluated only once.
|
|
44
67
|
REEVALUATE_MODULES: parseBooleanFlag("REEVALUATE_MODULES"),
|
|
68
|
+
// Use the LWC SSR compiler and v2 SSR API
|
|
45
69
|
SSR_COMPILER_ENABLED: parseBooleanFlag("SSR_COMPILER_ENABLED"),
|
|
70
|
+
// Create a new SSR Loader on every request
|
|
46
71
|
SSR_LOADER_PER_REQUEST: parseBooleanFlag("SSR_LOADER_PER_REQUEST"),
|
|
72
|
+
// Max number of ViewDefinitions help in memory
|
|
47
73
|
VIEW_CACHE_SIZE: parseStringFlag("VIEW_CACHE_SIZE"),
|
|
74
|
+
// Allows setting/overriding headers for non-immutable assets.
|
|
75
|
+
// Expected format is `<header_key_1>: <header_value_1>, header_value_2>; <header_key_2>: <header_value_2>`
|
|
76
|
+
// E.g., assetHeadersString Cloudflare-CDN-Cache-Control: max-age=2813308004; Cache-Tag: ABC123;
|
|
48
77
|
EXPERIMENTAL_ASSET_HEADERS: parseStringFlag("EXPERIMENTAL_ASSET_HEADERS"),
|
|
78
|
+
// Sets the timeout for SSR on lambda in ms
|
|
49
79
|
SSR_TIMEOUT: parseStringFlag("SSR_TIMEOUT"),
|
|
80
|
+
// Pushes the includedModules of each root component bundle into clientBootstrapConfig.preloadModules
|
|
50
81
|
PRELOAD_INCLUDED_MODULES: parseBooleanFlag("PRELOAD_INCLUDED_MODULES"),
|
|
82
|
+
// Enable data provider metrics
|
|
51
83
|
DATA_PROVIDER_METRICS: parseBooleanFlag("DATA_PROVIDER_METRICS")
|
|
52
84
|
};
|
|
53
85
|
}
|
|
@@ -136,19 +168,15 @@ function parseRequestDepth(headers = {}, query = {}) {
|
|
|
136
168
|
}
|
|
137
169
|
function getTraceHeaders(runtimeParams, span) {
|
|
138
170
|
const headers = {};
|
|
139
|
-
if (runtimeParams.trueClientIP)
|
|
140
|
-
|
|
141
|
-
if (runtimeParams.correlationID)
|
|
142
|
-
headers[CORRELATION_ID] = runtimeParams.correlationID;
|
|
171
|
+
if (runtimeParams.trueClientIP) headers[TRUE_CLIENT_IP] = runtimeParams.trueClientIP;
|
|
172
|
+
if (runtimeParams.correlationID) headers[CORRELATION_ID] = runtimeParams.correlationID;
|
|
143
173
|
if (shouldEnableB3Headers()) {
|
|
144
174
|
if (span?.traceId) {
|
|
145
175
|
headers[B3_TRACE_ID] = span.traceId;
|
|
146
176
|
headers[B3_SAMPLED] = parseTracingFlag() ? "1" : "0";
|
|
147
177
|
}
|
|
148
|
-
if (span?.spanId)
|
|
149
|
-
|
|
150
|
-
if (span?.parentSpanId)
|
|
151
|
-
headers[B3_PARENT_ID] = span.parentSpanId;
|
|
178
|
+
if (span?.spanId) headers[B3_SPAN_ID] = span.spanId;
|
|
179
|
+
if (span?.parentSpanId) headers[B3_PARENT_ID] = span.parentSpanId;
|
|
152
180
|
}
|
|
153
181
|
return headers;
|
|
154
182
|
}
|
package/build/cjs/fs.cjs
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
18
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/shared-utils/src/fs.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var fs_exports = {};
|
|
32
|
+
__export(fs_exports, {
|
|
27
33
|
PROTOCOL_FILE: () => PROTOCOL_FILE,
|
|
28
34
|
PROTOCOL_HTTP: () => PROTOCOL_HTTP,
|
|
29
35
|
PROTOCOL_HTTPS: () => PROTOCOL_HTTPS,
|
|
@@ -46,17 +52,18 @@ __export(exports, {
|
|
|
46
52
|
stringToStream: () => stringToStream,
|
|
47
53
|
toForwardSlash: () => toForwardSlash
|
|
48
54
|
});
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
55
|
+
module.exports = __toCommonJS(fs_exports);
|
|
56
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
57
|
+
var import_path = __toESM(require("path"), 1);
|
|
58
|
+
var import_url = __toESM(require("url"), 1);
|
|
59
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
60
|
+
var import_identity = require("./identity.cjs");
|
|
61
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
62
|
+
var import_mime_types = require("mime-types");
|
|
63
|
+
var import_stream = require("stream");
|
|
64
|
+
var import_diagnostics2 = require("@lwrjs/diagnostics");
|
|
58
65
|
var fileCount = 0;
|
|
59
|
-
var files = new Map();
|
|
66
|
+
var files = /* @__PURE__ */ new Map();
|
|
60
67
|
var PROTOCOL_HTTP = "http://";
|
|
61
68
|
var PROTOCOL_HTTPS = "https://";
|
|
62
69
|
var PROTOCOL_FILE = "file://";
|
|
@@ -165,13 +172,16 @@ function isLocalPath(filePath) {
|
|
|
165
172
|
return false;
|
|
166
173
|
}
|
|
167
174
|
var RESOURCE_DIR_REGEX = /\$(\w+)|^\$(\w+)/g;
|
|
168
|
-
function normalizeResourcePath(rawPath, {rootDir, assets, contentDir, layoutsDir}, allowUnresolvedAlias) {
|
|
169
|
-
const assetsMap = assets.reduce(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, layoutsDir }, allowUnresolvedAlias) {
|
|
176
|
+
const assetsMap = assets.reduce(
|
|
177
|
+
(map, asset) => {
|
|
178
|
+
if (asset.alias) {
|
|
179
|
+
map[asset.alias] = asset.dir || asset.file;
|
|
180
|
+
}
|
|
181
|
+
return map;
|
|
182
|
+
},
|
|
183
|
+
{ rootDir, contentDir, layoutsDir }
|
|
184
|
+
);
|
|
175
185
|
return rawPath.replace(RESOURCE_DIR_REGEX, function(fullMatch, m1, m2) {
|
|
176
186
|
const alias = assetsMap[m1] || assetsMap[m2];
|
|
177
187
|
if (!alias && !allowUnresolvedAlias) {
|
|
@@ -187,10 +197,8 @@ function joinUrlPath(...segments) {
|
|
|
187
197
|
const parts = segments.filter((s) => s !== "");
|
|
188
198
|
return parts.map((seg, i) => {
|
|
189
199
|
let s = toForwardSlash(seg);
|
|
190
|
-
if (i > 0 && !s.startsWith("/"))
|
|
191
|
-
|
|
192
|
-
if (i < parts.length - 1)
|
|
193
|
-
s = s.replace(/\/$/, "");
|
|
200
|
+
if (i > 0 && !s.startsWith("/")) s = `/${s}`;
|
|
201
|
+
if (i < parts.length - 1) s = s.replace(/\/$/, "");
|
|
194
202
|
return s;
|
|
195
203
|
}).join("");
|
|
196
204
|
}
|
|
@@ -198,16 +206,16 @@ function logMetrics(filePath) {
|
|
|
198
206
|
if (import_diagnostics2.logger.isDebugEnabled()) {
|
|
199
207
|
let count = files.get(filePath) || 0;
|
|
200
208
|
if (++count % 100 === 0) {
|
|
201
|
-
import_diagnostics2.logger.debug({label: `logMetrics`, message: `[${count}] Repeat Read ${filePath}`});
|
|
209
|
+
import_diagnostics2.logger.debug({ label: `logMetrics`, message: `[${count}] Repeat Read ${filePath}` });
|
|
202
210
|
}
|
|
203
211
|
files.set(filePath, count);
|
|
204
212
|
if (++fileCount % 1e3 === 0) {
|
|
205
|
-
import_diagnostics2.logger.debug({label: `logMetrics`, message: `Open file count [${fileCount}]`});
|
|
213
|
+
import_diagnostics2.logger.debug({ label: `logMetrics`, message: `Open file count [${fileCount}]` });
|
|
206
214
|
}
|
|
207
215
|
}
|
|
208
216
|
}
|
|
209
217
|
function normalizeAssetSpecifier(assetId, assetPathMap, resourcePaths, basePath) {
|
|
210
|
-
const {specifier, importer, type} = assetId;
|
|
218
|
+
const { specifier, importer, type } = assetId;
|
|
211
219
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
212
220
|
if (!importer) {
|
|
213
221
|
throw Error(`Unable to resolve relative import "${specifier}" without an importer.`);
|
|
@@ -262,6 +270,8 @@ function stringToStream(str) {
|
|
|
262
270
|
return readable;
|
|
263
271
|
}
|
|
264
272
|
function filterProtocolEntries(record, protocol) {
|
|
265
|
-
const filteredEntries = Object.entries(record).filter(
|
|
273
|
+
const filteredEntries = Object.entries(record).filter(
|
|
274
|
+
([_key, value]) => !value || !value.startsWith(protocol)
|
|
275
|
+
);
|
|
266
276
|
return Object.fromEntries(filteredEntries);
|
|
267
277
|
}
|
package/build/cjs/graph.cjs
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/shared-utils/src/graph.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var graph_exports = {};
|
|
22
|
+
__export(graph_exports, {
|
|
27
23
|
GraphDepth: () => GraphDepth,
|
|
28
24
|
getModuleGraphs: () => getModuleGraphs,
|
|
29
25
|
isBundler: () => isBundler
|
|
30
26
|
});
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
(
|
|
27
|
+
module.exports = __toCommonJS(graph_exports);
|
|
28
|
+
var import_identity = require("./identity.cjs");
|
|
29
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
30
|
+
var import_import_metadata = require("./import-metadata.cjs");
|
|
31
|
+
var GraphDepth = /* @__PURE__ */ ((GraphDepth2) => {
|
|
36
32
|
GraphDepth2["ALL"] = "all";
|
|
37
33
|
GraphDepth2["DIRECT"] = "direct";
|
|
38
34
|
GraphDepth2["NONE"] = "none";
|
|
39
|
-
|
|
35
|
+
return GraphDepth2;
|
|
36
|
+
})(GraphDepth || {});
|
|
40
37
|
function isBundler(registry) {
|
|
41
38
|
return registry.getModuleBundle !== void 0;
|
|
42
39
|
}
|
|
43
40
|
async function traverse(module2, depth, flattened, graphIdx, visited, defRegistry, runtimeEnvironment, runtimeParams) {
|
|
44
|
-
const {includeId: includeIdHook} = depth;
|
|
41
|
+
const { includeId: includeIdHook } = depth;
|
|
45
42
|
const versionedSpecifier = (0, import_identity.getSpecifier)(module2);
|
|
46
|
-
const {imports = [], dynamicImports = []} = (0, import_identity.isBundleDefinition)(module2) ? module2.bundleRecord : module2.moduleRecord;
|
|
43
|
+
const { imports = [], dynamicImports = [] } = (0, import_identity.isBundleDefinition)(module2) ? module2.bundleRecord : module2.moduleRecord;
|
|
47
44
|
const staticImports = imports.map((imp) => (0, import_identity.getSpecifier)(imp));
|
|
48
45
|
const dynamic = dynamicImports.map((imp) => (0, import_identity.getSpecifier)(imp));
|
|
49
46
|
if (!visited.has(versionedSpecifier)) {
|
|
50
|
-
visited.set(versionedSpecifier, {static: staticImports, dynamic});
|
|
47
|
+
visited.set(versionedSpecifier, { static: staticImports, dynamic });
|
|
51
48
|
}
|
|
52
49
|
if (!flattened[graphIdx]) {
|
|
53
50
|
flattened.push({
|
|
@@ -56,7 +53,7 @@ async function traverse(module2, depth, flattened, graphIdx, visited, defRegistr
|
|
|
56
53
|
dynamicRefs: dynamic
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
|
-
if (depth.static !==
|
|
56
|
+
if (depth.static !== "none" /* NONE */) {
|
|
60
57
|
for (const imp of imports) {
|
|
61
58
|
const impSpecifier = (0, import_identity.getSpecifier)(imp);
|
|
62
59
|
const shouldIncludeModule = includeIdHook ? includeIdHook(imp) : true;
|
|
@@ -64,12 +61,27 @@ async function traverse(module2, depth, flattened, graphIdx, visited, defRegistr
|
|
|
64
61
|
if (!flattened[graphIdx].static.includes(impSpecifier)) {
|
|
65
62
|
flattened[graphIdx].static.push(impSpecifier);
|
|
66
63
|
}
|
|
67
|
-
if (depth.static ===
|
|
64
|
+
if (depth.static === "all" /* ALL */) {
|
|
68
65
|
if (visited.has(impSpecifier)) {
|
|
69
66
|
await flatten(impSpecifier, flattened, graphIdx, visited);
|
|
70
67
|
} else {
|
|
71
|
-
const moduleDef = isBundler(defRegistry) ?
|
|
72
|
-
|
|
68
|
+
const moduleDef = isBundler(defRegistry) ? (
|
|
69
|
+
// eslint-disable-next-line no-await-in-loop
|
|
70
|
+
await defRegistry.getModuleBundle(imp, runtimeEnvironment, runtimeParams)
|
|
71
|
+
) : (
|
|
72
|
+
// eslint-disable-next-line no-await-in-loop
|
|
73
|
+
await defRegistry.getModule(imp, runtimeParams)
|
|
74
|
+
);
|
|
75
|
+
await traverse(
|
|
76
|
+
moduleDef,
|
|
77
|
+
depth,
|
|
78
|
+
flattened,
|
|
79
|
+
graphIdx,
|
|
80
|
+
visited,
|
|
81
|
+
defRegistry,
|
|
82
|
+
runtimeEnvironment,
|
|
83
|
+
runtimeParams
|
|
84
|
+
);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
}
|
|
@@ -85,8 +97,23 @@ async function traverse(module2, depth, flattened, graphIdx, visited, defRegistr
|
|
|
85
97
|
if (visited.has(impSpecifier)) {
|
|
86
98
|
await flatten(impSpecifier, flattened, graphIdx + 1, visited);
|
|
87
99
|
} else {
|
|
88
|
-
const moduleDef = isBundler(defRegistry) ?
|
|
89
|
-
|
|
100
|
+
const moduleDef = isBundler(defRegistry) ? (
|
|
101
|
+
// eslint-disable-next-line no-await-in-loop
|
|
102
|
+
await defRegistry.getModuleBundle(imp, runtimeEnvironment, runtimeParams)
|
|
103
|
+
) : (
|
|
104
|
+
// eslint-disable-next-line no-await-in-loop
|
|
105
|
+
await defRegistry.getModule(imp, runtimeParams)
|
|
106
|
+
);
|
|
107
|
+
await traverse(
|
|
108
|
+
moduleDef,
|
|
109
|
+
depth,
|
|
110
|
+
flattened,
|
|
111
|
+
graphIdx + 1,
|
|
112
|
+
visited,
|
|
113
|
+
defRegistry,
|
|
114
|
+
runtimeEnvironment,
|
|
115
|
+
runtimeParams
|
|
116
|
+
);
|
|
90
117
|
}
|
|
91
118
|
}
|
|
92
119
|
}
|
|
@@ -104,19 +131,22 @@ async function flatten(versionedSpecifier, flattened, idx, visited) {
|
|
|
104
131
|
}
|
|
105
132
|
}
|
|
106
133
|
async function getModuleGraphs(specifier, options, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, visited) {
|
|
107
|
-
const acc = visited || new Map();
|
|
134
|
+
const acc = visited || /* @__PURE__ */ new Map();
|
|
108
135
|
const versionedModuleId = await (0, import_identity.getVersionedModuleId)(specifier, moduleRegistry, runtimeParams);
|
|
109
136
|
const depth = options.depth || {
|
|
110
|
-
static:
|
|
137
|
+
static: "direct" /* DIRECT */,
|
|
111
138
|
dynamic: 1
|
|
112
139
|
};
|
|
113
140
|
const moduleDef = isBundler(defRegistry) ? await defRegistry.getModuleBundle(versionedModuleId, runtimeEnvironment, runtimeParams) : await defRegistry.getModule(versionedModuleId, runtimeParams);
|
|
114
141
|
if (!moduleDef) {
|
|
115
|
-
throw new import_diagnostics.LwrUnresolvableError(
|
|
142
|
+
throw new import_diagnostics.LwrUnresolvableError(
|
|
143
|
+
import_diagnostics.descriptions.UNRESOLVABLE.MODULE_ENTRY(versionedModuleId.specifier),
|
|
144
|
+
"module"
|
|
145
|
+
);
|
|
116
146
|
}
|
|
117
147
|
const flattened = [];
|
|
118
148
|
await traverse(moduleDef, depth, flattened, 0, acc, defRegistry, runtimeEnvironment, runtimeParams);
|
|
119
|
-
let extraFlat = new Set();
|
|
149
|
+
let extraFlat = /* @__PURE__ */ new Set();
|
|
120
150
|
if (options.includeUris || options.includeLinkedDefinitions) {
|
|
121
151
|
const allDeps = flattened.reduce((all, node) => {
|
|
122
152
|
all.push(node.specifier, ...node.static, ...node.dynamicRefs);
|
|
@@ -135,8 +165,18 @@ async function getModuleGraphs(specifier, options, moduleRegistry, defRegistry,
|
|
|
135
165
|
const linkedDefinitions = {};
|
|
136
166
|
if (options.includeLinkedDefinitions) {
|
|
137
167
|
for (const visitedSpecifier of extraFlat.keys()) {
|
|
138
|
-
const versionedModuleId2 = await (0, import_identity.getVersionedModuleId)(
|
|
139
|
-
|
|
168
|
+
const versionedModuleId2 = await (0, import_identity.getVersionedModuleId)(
|
|
169
|
+
visitedSpecifier,
|
|
170
|
+
moduleRegistry,
|
|
171
|
+
runtimeParams
|
|
172
|
+
);
|
|
173
|
+
const module2 = isBundler(defRegistry) ? (
|
|
174
|
+
// eslint-disable-next-line no-await-in-loop
|
|
175
|
+
await defRegistry.getModuleBundle(versionedModuleId2, runtimeEnvironment, runtimeParams)
|
|
176
|
+
) : (
|
|
177
|
+
// eslint-disable-next-line no-await-in-loop
|
|
178
|
+
await defRegistry.getLinkedModule(versionedModuleId2, runtimeEnvironment, runtimeParams)
|
|
179
|
+
);
|
|
140
180
|
linkedDefinitions[visitedSpecifier] = module2;
|
|
141
181
|
}
|
|
142
182
|
}
|