@lwrjs/view-registry 0.11.0-alpha.9 → 0.11.1
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/index.cjs +6 -2
- package/build/cjs/linkers/legacy_view_bootstrap.cjs +2 -1
- package/build/cjs/linkers/link-lwr-resources.cjs +10 -2
- package/build/cjs/linkers/preload-utils.cjs +2 -1
- package/build/cjs/linkers/utils.cjs +6 -1
- package/build/cjs/linkers/view_bootstrap.cjs +2 -1
- package/build/cjs/utils.cjs +2 -1
- package/build/es/index.js +6 -2
- package/build/es/linkers/legacy_view_bootstrap.js +2 -1
- package/build/es/linkers/link-lwr-resources.js +12 -4
- package/build/es/linkers/preload-utils.js +2 -1
- package/build/es/linkers/utils.d.ts +1 -1
- package/build/es/linkers/utils.js +10 -4
- package/build/es/linkers/view_bootstrap.js +2 -1
- package/build/es/utils.js +1 -0
- package/package.json +7 -7
package/build/cjs/index.cjs
CHANGED
|
@@ -181,7 +181,7 @@ var LwrViewRegistry = class {
|
|
|
181
181
|
}
|
|
182
182
|
const pendingViewDefCacheKey = viewDefCacheKey + viewParamKey;
|
|
183
183
|
const viewDefinition = await this.pendingViewDefinitions.execute(pendingViewDefCacheKey, () => (0, import_instrumentation.getTracer)().trace({
|
|
184
|
-
name: import_instrumentation.ViewSpan.
|
|
184
|
+
name: import_instrumentation.ViewSpan.RenderView,
|
|
185
185
|
attributes: {
|
|
186
186
|
view: view.id,
|
|
187
187
|
ssr: view.bootstrap?.ssr === true
|
|
@@ -243,6 +243,10 @@ var LwrViewRegistry = class {
|
|
|
243
243
|
serverData: {
|
|
244
244
|
...renderedContent.metadata.serverData,
|
|
245
245
|
...renderedLayout.metadata.serverData
|
|
246
|
+
},
|
|
247
|
+
serverDebug: {
|
|
248
|
+
...renderedContent.metadata.serverDebug,
|
|
249
|
+
...renderedLayout.metadata.serverDebug
|
|
246
250
|
}
|
|
247
251
|
}
|
|
248
252
|
}, {
|
|
@@ -291,7 +295,7 @@ var LwrViewRegistry = class {
|
|
|
291
295
|
metadata: renderedViewMetadata,
|
|
292
296
|
compiledView: {immutable = true}
|
|
293
297
|
} = renderedView;
|
|
294
|
-
const linkedMetadata = skipMetadataCollection ? renderedViewMetadata : await (0, import_shared_utils.extractMetadataFromHtml)(renderedViewContent, renderedViewMetadata);
|
|
298
|
+
const linkedMetadata = skipMetadataCollection ? renderedViewMetadata : await (0, import_shared_utils.extractMetadataFromHtml)(renderedViewContent, renderedViewMetadata, this.globalConfig);
|
|
295
299
|
const mergedViewContext = {
|
|
296
300
|
...viewContext,
|
|
297
301
|
runtimeEnvironment,
|
|
@@ -26,6 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
getHtmlResources: () => getHtmlResources
|
|
28
28
|
});
|
|
29
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
29
30
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
30
31
|
var import_identity = __toModule(require("@lwrjs/app-service/identity"));
|
|
31
32
|
var import_utils = __toModule(require("../utils.cjs"));
|
|
@@ -142,7 +143,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
142
143
|
if (uri2) {
|
|
143
144
|
imports[dynamicDep] = uri2;
|
|
144
145
|
} else {
|
|
145
|
-
|
|
146
|
+
import_diagnostics.logger.warn("Skipping unknown dynamic import " + dynamicDep);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -26,12 +26,20 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
linkLwrResources: () => linkLwrResources
|
|
28
28
|
});
|
|
29
|
+
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
29
30
|
var import_view_bootstrap = __toModule(require("./view_bootstrap.cjs"));
|
|
30
31
|
var import_legacy_view_bootstrap = __toModule(require("./legacy_view_bootstrap.cjs"));
|
|
31
32
|
async function linkLwrResources(source, view, viewParams, cxt) {
|
|
32
33
|
const {lwrResourcesId, ...resourceContext} = cxt;
|
|
33
|
-
const LEGACY_LOADER = resourceContext.runtimeEnvironment
|
|
34
|
-
const {partial, viewRecord} =
|
|
34
|
+
const LEGACY_LOADER = !!resourceContext.runtimeEnvironment.featureFlags.LEGACY_LOADER;
|
|
35
|
+
const {partial, viewRecord} = await (0, import_instrumentation.getTracer)().trace({
|
|
36
|
+
name: import_instrumentation.ViewSpan.Generate,
|
|
37
|
+
attributes: {
|
|
38
|
+
legacyLoader: LEGACY_LOADER
|
|
39
|
+
}
|
|
40
|
+
}, () => {
|
|
41
|
+
return LEGACY_LOADER ? (0, import_legacy_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext) : (0, import_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext);
|
|
42
|
+
});
|
|
35
43
|
return {
|
|
36
44
|
renderedView: source.replace(lwrResourcesId, partial),
|
|
37
45
|
viewRecord
|
|
@@ -27,6 +27,7 @@ __export(exports, {
|
|
|
27
27
|
getPreloadModulesMeta: () => getPreloadModulesMeta,
|
|
28
28
|
setPreloadModulesMeta: () => setPreloadModulesMeta
|
|
29
29
|
});
|
|
30
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
30
31
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
31
32
|
function setPreloadModulesMeta(specifier, uri, groups, preloads) {
|
|
32
33
|
const [removedVersion, version] = specifier.split("/v/");
|
|
@@ -54,7 +55,7 @@ async function getPreloadModulesMeta(specifier, viewPreloads, bundleConfig, modu
|
|
|
54
55
|
return exclude.includes(specifier2);
|
|
55
56
|
};
|
|
56
57
|
if (isExternal(specifier)) {
|
|
57
|
-
|
|
58
|
+
import_diagnostics.logger.warn(`"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`);
|
|
58
59
|
} else {
|
|
59
60
|
const versionedModuleId = await (0, import_shared_utils.getVersionedModuleId)(specifier, moduleRegistry, runtimeParams);
|
|
60
61
|
const versionedModuleSpecifier = (0, import_shared_utils.getSpecifier)({
|
|
@@ -45,6 +45,11 @@ function getViewBootstrapConfigurationResource(viewInfo, config, runtimeEnvironm
|
|
|
45
45
|
},
|
|
46
46
|
...debug && {modifiers: {debug: "true"}}
|
|
47
47
|
};
|
|
48
|
+
const environment = {
|
|
49
|
+
NODE_ENV: runtimeEnvironment.serverMode,
|
|
50
|
+
SSR: false,
|
|
51
|
+
...(0, import_shared_utils.buildEnvironmentContext)(runtimeParams)
|
|
52
|
+
};
|
|
48
53
|
const configString = [
|
|
49
54
|
"/* This script is generated */",
|
|
50
55
|
"/* Client Bootstrap configuration */",
|
|
@@ -53,7 +58,7 @@ function getViewBootstrapConfigurationResource(viewInfo, config, runtimeEnvironm
|
|
|
53
58
|
...config,
|
|
54
59
|
endpoints
|
|
55
60
|
})});`,
|
|
56
|
-
`globalThis.process = { env:
|
|
61
|
+
`globalThis.process = { env: ${JSON.stringify(environment)} };`,
|
|
57
62
|
`globalThis.lwcRuntimeFlags = { ENABLE_MIXED_SHADOW_MODE: ${viewInfo.mixedMode} };`,
|
|
58
63
|
debug && debugMessage && `console.warn(${JSON.stringify(debugMessage)});`
|
|
59
64
|
].filter(Boolean).join("\n");
|
|
@@ -26,6 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
getHtmlResources: () => getHtmlResources
|
|
28
28
|
});
|
|
29
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
29
30
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
30
31
|
var import_identity = __toModule(require("@lwrjs/app-service/identity"));
|
|
31
32
|
var import_utils = __toModule(require("../utils.cjs"));
|
|
@@ -133,7 +134,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
133
134
|
if (uri2) {
|
|
134
135
|
imports[dynamicDep] = uri2;
|
|
135
136
|
} else {
|
|
136
|
-
|
|
137
|
+
import_diagnostics.logger.warn("Skipping unknown dynamic import " + dynamicDep);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
}
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -94,7 +94,8 @@ function normalizeRenderedResult({
|
|
|
94
94
|
metadata: {
|
|
95
95
|
customElements: metadata ? metadata.customElements : [],
|
|
96
96
|
assetReferences: metadata ? metadata.assetReferences : [],
|
|
97
|
-
serverData: metadata ? metadata.serverData : {}
|
|
97
|
+
serverData: metadata ? metadata.serverData : {},
|
|
98
|
+
serverDebug: metadata ? metadata.serverDebug : {}
|
|
98
99
|
},
|
|
99
100
|
options: {
|
|
100
101
|
skipMetadataCollection: options ? options.skipMetadataCollection : false
|
package/build/es/index.js
CHANGED
|
@@ -181,7 +181,7 @@ export class LwrViewRegistry {
|
|
|
181
181
|
}
|
|
182
182
|
const pendingViewDefCacheKey = viewDefCacheKey + viewParamKey;
|
|
183
183
|
const viewDefinition = await this.pendingViewDefinitions.execute(pendingViewDefCacheKey, () => getTracer().trace({
|
|
184
|
-
name: ViewSpan.
|
|
184
|
+
name: ViewSpan.RenderView,
|
|
185
185
|
attributes: {
|
|
186
186
|
view: view.id,
|
|
187
187
|
ssr: view.bootstrap?.ssr === true,
|
|
@@ -253,6 +253,10 @@ export class LwrViewRegistry {
|
|
|
253
253
|
...renderedContent.metadata.serverData,
|
|
254
254
|
...renderedLayout.metadata.serverData,
|
|
255
255
|
},
|
|
256
|
+
serverDebug: {
|
|
257
|
+
...renderedContent.metadata.serverDebug,
|
|
258
|
+
...renderedLayout.metadata.serverDebug,
|
|
259
|
+
},
|
|
256
260
|
},
|
|
257
261
|
},
|
|
258
262
|
// Render Content now contains a layout
|
|
@@ -305,7 +309,7 @@ export class LwrViewRegistry {
|
|
|
305
309
|
const { renderedView: renderedViewContent, metadata: renderedViewMetadata, compiledView: { immutable = true }, } = renderedView;
|
|
306
310
|
const linkedMetadata = skipMetadataCollection
|
|
307
311
|
? renderedViewMetadata
|
|
308
|
-
: await extractMetadataFromHtml(renderedViewContent, renderedViewMetadata);
|
|
312
|
+
: await extractMetadataFromHtml(renderedViewContent, renderedViewMetadata, this.globalConfig);
|
|
309
313
|
const mergedViewContext = {
|
|
310
314
|
...viewContext,
|
|
311
315
|
runtimeEnvironment,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
2
|
+
import { kebabCaseToModuleSpecifier, getModuleGraphs, GraphDepth, getModuleUriPrefix, explodeSpecifier, isBundler, getHydrateDirective, } from '@lwrjs/shared-utils';
|
|
2
3
|
import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
|
|
3
4
|
import { generateHtmlTag, getModuleResourceByUri } from '../utils.js';
|
|
4
5
|
import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { ViewSpan, getTracer } from '@lwrjs/instrumentation';
|
|
1
2
|
import { getHtmlResources } from './view_bootstrap.js';
|
|
2
3
|
import { getHtmlResources as getLegacyHtmlResource } from './legacy_view_bootstrap.js';
|
|
3
4
|
export async function linkLwrResources(source, view, viewParams, cxt) {
|
|
4
5
|
const { lwrResourcesId, ...resourceContext } = cxt;
|
|
5
|
-
const LEGACY_LOADER = resourceContext.runtimeEnvironment
|
|
6
|
-
const { partial, viewRecord } =
|
|
7
|
-
|
|
8
|
-
:
|
|
6
|
+
const LEGACY_LOADER = !!resourceContext.runtimeEnvironment.featureFlags.LEGACY_LOADER;
|
|
7
|
+
const { partial, viewRecord } = await getTracer().trace({
|
|
8
|
+
name: ViewSpan.Generate,
|
|
9
|
+
attributes: {
|
|
10
|
+
legacyLoader: LEGACY_LOADER,
|
|
11
|
+
},
|
|
12
|
+
}, () => {
|
|
13
|
+
return LEGACY_LOADER
|
|
14
|
+
? getLegacyHtmlResource(view, viewParams, resourceContext)
|
|
15
|
+
: getHtmlResources(view, viewParams, resourceContext);
|
|
16
|
+
});
|
|
9
17
|
// Finally replace the token with the real resources
|
|
10
18
|
return {
|
|
11
19
|
renderedView: source.replace(lwrResourcesId, partial),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
2
|
+
import { explodeSpecifier, getGroupName, getVersionedModuleId, normalizeVersionToUri, VERSION_NOT_PROVIDED, getSpecifier, isGroupie, } from '@lwrjs/shared-utils';
|
|
2
3
|
/**
|
|
3
4
|
* keeps track of preloadModules metadata
|
|
4
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClientBootstrapConfig, RuntimeEnvironment, RuntimeParams, ResourceDefinition, RenderedViewMetadata, CustomElementReference, View, ViewInfo } from '@lwrjs/types';
|
|
2
|
-
export declare function getViewBootstrapConfigurationResource(viewInfo: ViewInfo, config: ClientBootstrapConfig, runtimeEnvironment: RuntimeEnvironment, runtimeParams
|
|
2
|
+
export declare function getViewBootstrapConfigurationResource(viewInfo: ViewInfo, config: ClientBootstrapConfig, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams, debugMessage?: string): ResourceDefinition;
|
|
3
3
|
export declare function getViewHmrConfigurationResource(view: View, viewMetadata: RenderedViewMetadata): ResourceDefinition;
|
|
4
4
|
export declare function flattenCustomElements(arr: CustomElementReference[], isSSR?: boolean): CustomElementReference[];
|
|
5
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMappingUriPrefix, getModuleUriPrefix, getClientBootstrapConfigurationUri, hashContent, } from '@lwrjs/shared-utils';
|
|
1
|
+
import { buildEnvironmentContext, getMappingUriPrefix, getModuleUriPrefix, getClientBootstrapConfigurationUri, hashContent, } from '@lwrjs/shared-utils';
|
|
2
2
|
const CONTENT_TYPE = 'application/javascript';
|
|
3
3
|
export function getViewBootstrapConfigurationResource(viewInfo, config, runtimeEnvironment, runtimeParams, debugMessage) {
|
|
4
4
|
const { compat, debug, hmrEnabled, apiVersion, format } = runtimeEnvironment;
|
|
@@ -17,6 +17,14 @@ export function getViewBootstrapConfigurationResource(viewInfo, config, runtimeE
|
|
|
17
17
|
},
|
|
18
18
|
...(debug && { modifiers: { debug: 'true' } }),
|
|
19
19
|
};
|
|
20
|
+
const environment = {
|
|
21
|
+
// TODO: W-12639529 change NODE_ENV after addressing downstream customers
|
|
22
|
+
NODE_ENV: runtimeEnvironment.serverMode,
|
|
23
|
+
// Note: SSR is always false because this script is executed on the client
|
|
24
|
+
SSR: false,
|
|
25
|
+
// Used by `lwr/environment`
|
|
26
|
+
...buildEnvironmentContext(runtimeParams),
|
|
27
|
+
};
|
|
20
28
|
const configString = [
|
|
21
29
|
'/* This script is generated */',
|
|
22
30
|
'/* Client Bootstrap configuration */',
|
|
@@ -25,9 +33,7 @@ export function getViewBootstrapConfigurationResource(viewInfo, config, runtimeE
|
|
|
25
33
|
...config,
|
|
26
34
|
endpoints,
|
|
27
35
|
})});`,
|
|
28
|
-
|
|
29
|
-
// Note: SSR is always false because this script is executed on the client
|
|
30
|
-
`globalThis.process = { env: { NODE_ENV: "${runtimeEnvironment.serverMode}", SSR: false } };`,
|
|
36
|
+
`globalThis.process = { env: ${JSON.stringify(environment)} };`,
|
|
31
37
|
`globalThis.lwcRuntimeFlags = { ENABLE_MIXED_SHADOW_MODE: ${viewInfo.mixedMode} };`,
|
|
32
38
|
debug && debugMessage && `console.warn(${JSON.stringify(debugMessage)});`,
|
|
33
39
|
]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
2
|
+
import { kebabCaseToModuleSpecifier, toImportMetadata, getModuleGraphs, getMappingUriPrefix, GraphDepth, explodeSpecifier, isBundler, getHydrateDirective, } from '@lwrjs/shared-utils';
|
|
2
3
|
import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
|
|
3
4
|
import { generateHtmlTag, getModuleResourceByUri } from '../utils.js';
|
|
4
5
|
import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
|
package/build/es/utils.js
CHANGED
|
@@ -59,6 +59,7 @@ export function normalizeRenderedResult({ renderedView, metadata, options, }) {
|
|
|
59
59
|
customElements: metadata ? metadata.customElements : [],
|
|
60
60
|
assetReferences: metadata ? metadata.assetReferences : [],
|
|
61
61
|
serverData: metadata ? metadata.serverData : {},
|
|
62
|
+
serverDebug: metadata ? metadata.serverDebug : {},
|
|
62
63
|
},
|
|
63
64
|
options: {
|
|
64
65
|
skipMetadataCollection: options ? options.skipMetadataCollection : false,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.1",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lwrjs/app-service": "0.11.
|
|
34
|
-
"@lwrjs/diagnostics": "0.11.
|
|
35
|
-
"@lwrjs/instrumentation": "0.11.
|
|
36
|
-
"@lwrjs/shared-utils": "0.11.
|
|
33
|
+
"@lwrjs/app-service": "0.11.1",
|
|
34
|
+
"@lwrjs/diagnostics": "0.11.1",
|
|
35
|
+
"@lwrjs/instrumentation": "0.11.1",
|
|
36
|
+
"@lwrjs/shared-utils": "0.11.1",
|
|
37
37
|
"lru-cache": "^10.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@lwrjs/types": "0.11.
|
|
40
|
+
"@lwrjs/types": "0.11.1"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=16.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b7c40fdcd86635dd4e368c0a2e91c5d3374c0fcf"
|
|
46
46
|
}
|