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