@lwrjs/shared-utils 0.6.0-alpha.7 → 0.6.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/html-meta.cjs +1 -1
- package/build/cjs/index.cjs +0 -1
- package/build/cjs/mappings.cjs +15 -7
- package/build/cjs/urls.cjs +9 -3
- package/build/es/html-meta.js +2 -1
- package/build/es/index.d.ts +0 -1
- package/build/es/index.js +0 -1
- package/build/es/mappings.js +23 -8
- package/build/es/urls.d.ts +1 -1
- package/build/es/urls.js +9 -2
- package/package.json +4 -4
- package/build/cjs/metrics.cjs +0 -15
- package/build/es/metrics.d.ts +0 -5
- package/build/es/metrics.js +0 -6
package/build/cjs/html-meta.cjs
CHANGED
|
@@ -67,7 +67,7 @@ async function extractMetadataFromHtml(htmlSource) {
|
|
|
67
67
|
ceRefStack.push(ceRef);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
if (tagName === "img" && sourceCodeLocation.attrs) {
|
|
70
|
+
if ((tagName === "img" || tagName === "script") && sourceCodeLocation.attrs) {
|
|
71
71
|
if (sourceCodeLocation.attrs.src) {
|
|
72
72
|
assetReferences.push(parseAssetLocation(htmlSource, tagName, sourceCodeLocation.attrs.src));
|
|
73
73
|
}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -31,6 +31,5 @@ __exportStar(exports, __toModule(require("./typescript.cjs")));
|
|
|
31
31
|
__exportStar(exports, __toModule(require("./import-metadata.cjs")));
|
|
32
32
|
__exportStar(exports, __toModule(require("./graph.cjs")));
|
|
33
33
|
__exportStar(exports, __toModule(require("./mappings.cjs")));
|
|
34
|
-
__exportStar(exports, __toModule(require("./metrics.cjs")));
|
|
35
34
|
__exportStar(exports, __toModule(require("./urls.cjs")));
|
|
36
35
|
__exportStar(exports, __toModule(require("./env.cjs")));
|
package/build/cjs/mappings.cjs
CHANGED
|
@@ -38,7 +38,10 @@ async function getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeP
|
|
|
38
38
|
for (const moduleId of moduleIds) {
|
|
39
39
|
const specifier = (0, import_identity.getSpecifier)(moduleId);
|
|
40
40
|
if (!visitedCache.has(specifier)) {
|
|
41
|
-
const depth = {
|
|
41
|
+
const depth = {
|
|
42
|
+
static: runtimeEnvironment.format === "esm" ? import_graph.GraphDepth.NONE : import_graph.GraphDepth.ALL,
|
|
43
|
+
dynamic: runtimeEnvironment.format === "esm" ? 1 : 0
|
|
44
|
+
};
|
|
42
45
|
const moduleGraph = await (0, import_graph.getModuleGraphs)(specifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, runtimeEnvironment.bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams, visitedCache);
|
|
43
46
|
importMetadata = await toImportMetadata(moduleGraph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
44
47
|
}
|
|
@@ -57,15 +60,20 @@ async function toImportMetadata(moduleGraph, existingImportMetadata = {imports:
|
|
|
57
60
|
}
|
|
58
61
|
const rootMetadata = await normalizeImportMetadata(specifier, uri, definition, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
59
62
|
let importMetadata = mergeImportMetadata(existingImportMetadata, rootMetadata);
|
|
60
|
-
const depSpecifiers = moduleGraph.graphs[0].static;
|
|
63
|
+
const depSpecifiers = runtimeEnvironment.format === "esm" ? moduleGraph.graphs[0].dynamicRefs : moduleGraph.graphs[0].static;
|
|
61
64
|
for (const depSpecifier of depSpecifiers) {
|
|
62
65
|
const depUri = moduleGraph.uriMap[depSpecifier];
|
|
63
66
|
const depDef = moduleGraph.linkedDefinitions[depSpecifier];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const depMissing = !depUri || !depDef;
|
|
68
|
+
if (depMissing && runtimeEnvironment.format !== "esm") {
|
|
69
|
+
if (!depUri) {
|
|
70
|
+
throw new Error("URI was not included in the graph for dependent: " + depSpecifier);
|
|
71
|
+
}
|
|
72
|
+
if (!depDef) {
|
|
73
|
+
throw new Error("Linked dependent module definition was not included in the graph: " + depSpecifier);
|
|
74
|
+
}
|
|
75
|
+
} else if (depMissing) {
|
|
76
|
+
continue;
|
|
69
77
|
}
|
|
70
78
|
if (!importMetadata.imports[depUri]) {
|
|
71
79
|
const depMetadata = await normalizeImportMetadata((0, import_identity.getSpecifier)(depDef), depUri, depDef, moduleRegistry, runtimeEnvironment, runtimeParams);
|
package/build/cjs/urls.cjs
CHANGED
|
@@ -32,10 +32,12 @@ __export(exports, {
|
|
|
32
32
|
});
|
|
33
33
|
var import_path_to_regexp = __toModule(require("path-to-regexp"));
|
|
34
34
|
var CONFIG_SUFFIX = "/config.js";
|
|
35
|
-
|
|
35
|
+
var SIGNATURE_SIGIL = "s";
|
|
36
|
+
function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
|
|
36
37
|
const encodeUrl = encodeURIComponent(routeInfo.url);
|
|
37
38
|
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
38
|
-
|
|
39
|
+
const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : "";
|
|
40
|
+
return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
|
|
39
41
|
}
|
|
40
42
|
function getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
41
43
|
const {apiVersion, format} = runtimeEnvironment;
|
|
@@ -64,7 +66,11 @@ function getClientBootstrapConfigurationRoutes() {
|
|
|
64
66
|
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
65
67
|
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
66
68
|
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
67
|
-
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}
|
|
69
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
70
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
71
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
72
|
+
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
73
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`
|
|
68
74
|
];
|
|
69
75
|
}
|
|
70
76
|
function extractRequestParams(parameterizedRoute, resolvedUrl, existingParams) {
|
package/build/es/html-meta.js
CHANGED
|
@@ -46,7 +46,8 @@ export async function extractMetadataFromHtml(htmlSource) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
// <img src="asset-url"/>
|
|
49
|
-
|
|
49
|
+
// <script type="text/javascript" src="asset-url"></script>
|
|
50
|
+
if ((tagName === 'img' || tagName === 'script') && sourceCodeLocation.attrs) {
|
|
50
51
|
if (sourceCodeLocation.attrs.src) {
|
|
51
52
|
assetReferences.push(parseAssetLocation(htmlSource, tagName, sourceCodeLocation.attrs.src));
|
|
52
53
|
}
|
package/build/es/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './typescript.js';
|
|
|
10
10
|
export * from './import-metadata.js';
|
|
11
11
|
export * from './graph.js';
|
|
12
12
|
export * from './mappings.js';
|
|
13
|
-
export * from './metrics.js';
|
|
14
13
|
export * from './urls.js';
|
|
15
14
|
export * from './env.js';
|
|
16
15
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export * from './typescript.js';
|
|
|
10
10
|
export * from './import-metadata.js';
|
|
11
11
|
export * from './graph.js';
|
|
12
12
|
export * from './mappings.js';
|
|
13
|
-
export * from './metrics.js';
|
|
14
13
|
export * from './urls.js';
|
|
15
14
|
export * from './env.js';
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
package/build/es/mappings.js
CHANGED
|
@@ -13,8 +13,12 @@ export async function getImportMetadataMappings(moduleIds, runtimeEnvironment, r
|
|
|
13
13
|
const specifier = getSpecifier(moduleId);
|
|
14
14
|
// Check if we have already visited
|
|
15
15
|
if (!visitedCache.has(specifier)) {
|
|
16
|
-
// Traversal of the Module Graph is done to get all the
|
|
17
|
-
|
|
16
|
+
// Traversal of the Module Graph is done to get all the URLs for discoverable dependencies.
|
|
17
|
+
// AMD gathers static imports while ESM gathers dynamic imports
|
|
18
|
+
const depth = {
|
|
19
|
+
static: runtimeEnvironment.format === 'esm' ? GraphDepth.NONE : GraphDepth.ALL,
|
|
20
|
+
dynamic: runtimeEnvironment.format === 'esm' ? 1 : 0,
|
|
21
|
+
};
|
|
18
22
|
// eslint-disable-next-line no-await-in-loop
|
|
19
23
|
const moduleGraph = await getModuleGraphs(specifier,
|
|
20
24
|
// include uris and linked definitions
|
|
@@ -52,16 +56,27 @@ export async function toImportMetadata(moduleGraph, existingImportMetadata = { i
|
|
|
52
56
|
// Merge in the existing metadata with imports for the root specifier
|
|
53
57
|
const rootMetadata = await normalizeImportMetadata(specifier, uri, definition, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
54
58
|
let importMetadata = mergeImportMetadata(existingImportMetadata, rootMetadata);
|
|
55
|
-
// root module dependencies
|
|
56
|
-
|
|
59
|
+
// root module dependencies:
|
|
60
|
+
// - static for AMD; dynamic dependencies require a new mapping request
|
|
61
|
+
// - dynamic for ESM; static dependencies are imported via fully qualified URLs
|
|
62
|
+
const depSpecifiers = runtimeEnvironment.format === 'esm'
|
|
63
|
+
? moduleGraph.graphs[0].dynamicRefs
|
|
64
|
+
: moduleGraph.graphs[0].static;
|
|
57
65
|
for (const depSpecifier of depSpecifiers) {
|
|
58
66
|
const depUri = moduleGraph.uriMap[depSpecifier];
|
|
59
67
|
const depDef = moduleGraph.linkedDefinitions[depSpecifier];
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
const depMissing = !depUri || !depDef;
|
|
69
|
+
if (depMissing && runtimeEnvironment.format !== 'esm') {
|
|
70
|
+
if (!depUri) {
|
|
71
|
+
throw new Error('URI was not included in the graph for dependent: ' + depSpecifier);
|
|
72
|
+
}
|
|
73
|
+
if (!depDef) {
|
|
74
|
+
throw new Error('Linked dependent module definition was not included in the graph: ' + depSpecifier);
|
|
75
|
+
}
|
|
62
76
|
}
|
|
63
|
-
if (
|
|
64
|
-
|
|
77
|
+
else if (depMissing) {
|
|
78
|
+
// Ignore variable dynamic imports
|
|
79
|
+
continue;
|
|
65
80
|
}
|
|
66
81
|
if (!importMetadata.imports[depUri]) {
|
|
67
82
|
// eslint-disable-next-line no-await-in-loop
|
package/build/es/urls.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
|
|
|
2
2
|
export declare function getClientBootstrapConfigurationUri(routeInfo: {
|
|
3
3
|
id: string;
|
|
4
4
|
url: string;
|
|
5
|
-
}, runtimeEnvironment: Required<Pick<RuntimeEnvironment, 'apiVersion' | 'format'>>, runtimeParams?: RuntimeParams): string;
|
|
5
|
+
}, runtimeEnvironment: Required<Pick<RuntimeEnvironment, 'apiVersion' | 'format'>>, runtimeParams?: RuntimeParams, signature?: string): string;
|
|
6
6
|
export declare function getClientBootstrapConfigurationUriPrefix(routeInfo: {
|
|
7
7
|
id: string;
|
|
8
8
|
}, runtimeEnvironment: Required<Pick<RuntimeEnvironment, 'apiVersion' | 'format'>>, runtimeParams?: RuntimeParams): string;
|
package/build/es/urls.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { pathToRegexp } from 'path-to-regexp';
|
|
2
2
|
const CONFIG_SUFFIX = '/config.js';
|
|
3
|
-
|
|
3
|
+
const SIGNATURE_SIGIL = 's';
|
|
4
|
+
export function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
|
|
4
5
|
const encodeUrl = encodeURIComponent(routeInfo.url);
|
|
5
6
|
const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
|
|
6
|
-
|
|
7
|
+
const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : '';
|
|
8
|
+
return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
|
|
7
9
|
}
|
|
8
10
|
export function getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams) {
|
|
9
11
|
const { apiVersion, format } = runtimeEnvironment;
|
|
@@ -42,6 +44,11 @@ export function getClientBootstrapConfigurationRoutes() {
|
|
|
42
44
|
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
43
45
|
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
44
46
|
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath${CONFIG_SUFFIX}`,
|
|
47
|
+
// with signature
|
|
48
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
49
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
50
|
+
`/:apiVersion/application/:format/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
51
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId/configuration/ci/:encodedViewPath/s/:signature${CONFIG_SUFFIX}`,
|
|
45
52
|
];
|
|
46
53
|
}
|
|
47
54
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.0
|
|
7
|
+
"version": "0.6.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"slugify": "^1.4.5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@lwrjs/diagnostics": "0.6.0
|
|
47
|
-
"@lwrjs/types": "0.6.0
|
|
46
|
+
"@lwrjs/diagnostics": "0.6.0",
|
|
47
|
+
"@lwrjs/types": "0.6.0",
|
|
48
48
|
"@types/mime-types": "2.1.1",
|
|
49
49
|
"@types/path-to-regexp": "^1.7.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=14.15.4 <17"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "31769655f0155ad7e54cf37bccdf72d0baaf44ab"
|
|
55
55
|
}
|
package/build/cjs/metrics.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
for (var name in all)
|
|
5
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// packages/@lwrjs/shared-utils/src/metrics.ts
|
|
9
|
-
__markAsModule(exports);
|
|
10
|
-
__export(exports, {
|
|
11
|
-
ON_APP_INIT: () => ON_APP_INIT,
|
|
12
|
-
ON_APP_LOAD: () => ON_APP_LOAD
|
|
13
|
-
});
|
|
14
|
-
var ON_APP_LOAD = "lwr-bootstrap-on-app-load";
|
|
15
|
-
var ON_APP_INIT = "lwr-bootstrap-on-app-init";
|
package/build/es/metrics.d.ts
DELETED
package/build/es/metrics.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Measure the point just before the app is requested
|
|
2
|
-
const ON_APP_LOAD = 'lwr-bootstrap-on-app-load';
|
|
3
|
-
// Measure the point where the app has been defined via customElements.define
|
|
4
|
-
const ON_APP_INIT = 'lwr-bootstrap-on-app-init';
|
|
5
|
-
export { ON_APP_LOAD, ON_APP_INIT };
|
|
6
|
-
//# sourceMappingURL=metrics.js.map
|