@lwrjs/view-registry 0.6.5 → 0.7.0-alpha.10
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/LICENSE +10 -0
- package/build/cjs/linkers/legacy_view_bootstrap.cjs +14 -3
- package/build/cjs/linkers/link-lwr-resources.cjs +2 -2
- package/build/cjs/linkers/utils.cjs +7 -5
- package/build/cjs/linkers/view_bootstrap.cjs +14 -3
- package/build/cjs/utils.cjs +2 -0
- package/build/es/linkers/legacy_view_bootstrap.js +20 -5
- package/build/es/linkers/link-lwr-resources.js +4 -4
- package/build/es/linkers/utils.d.ts +1 -1
- package/build/es/linkers/utils.js +8 -5
- package/build/es/linkers/view_bootstrap.js +20 -5
- package/build/es/utils.js +3 -0
- package/package.json +7 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -56,6 +56,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
56
56
|
const visitedCache = new Map();
|
|
57
57
|
const imports = {};
|
|
58
58
|
const rootComponents = [];
|
|
59
|
+
const rootProperties = {};
|
|
59
60
|
const requiredAmdModules = [];
|
|
60
61
|
const preloadAmdModules = [];
|
|
61
62
|
if (isAMD) {
|
|
@@ -65,6 +66,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
65
66
|
throw Error("Failed to find definition of resource: " + shimBundle);
|
|
66
67
|
}
|
|
67
68
|
requiredResources.push(def);
|
|
69
|
+
const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
|
|
70
|
+
if (!errorShimDef) {
|
|
71
|
+
throw Error("Failed to find definition of resource: lwr-error-shim.js");
|
|
72
|
+
}
|
|
73
|
+
requiredResources.push(errorShimDef);
|
|
68
74
|
if (!bundle) {
|
|
69
75
|
requiredResources.push(await (0, import_utils.getModuleResource)({
|
|
70
76
|
specifier: "lwr/loaderLegacy",
|
|
@@ -97,16 +103,20 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
}
|
|
106
|
+
const isSSR = view.bootstrap?.experimentalSSR;
|
|
100
107
|
const customElementsRecords = [];
|
|
101
|
-
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
|
|
102
|
-
await Promise.all(flattenedElements.map(async ({tagName: element}) => {
|
|
103
|
-
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.
|
|
108
|
+
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
|
|
109
|
+
await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
|
|
110
|
+
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifer)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
104
111
|
customElementsRecords.push({elementName: element, flatGraph: graph});
|
|
105
112
|
const specifier = graph.graphs[0].specifier;
|
|
106
113
|
const uri2 = graph.uriMap[specifier];
|
|
107
114
|
moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
|
|
108
115
|
rootComponents.push(specifier);
|
|
109
116
|
imports[specifier] = uri2;
|
|
117
|
+
if (isSSR && props) {
|
|
118
|
+
rootProperties[specifier] = props;
|
|
119
|
+
}
|
|
110
120
|
if (isAMD) {
|
|
111
121
|
preloadAmdModules.push(specifier);
|
|
112
122
|
for (const staticDep of graph.graphs[0].static) {
|
|
@@ -132,6 +142,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
132
142
|
default: (0, import_shared_utils.getModuleUriPrefix)(runtimeEnvironment, runtimeParams)
|
|
133
143
|
},
|
|
134
144
|
rootComponents,
|
|
145
|
+
rootProperties: isSSR ? rootProperties : void 0,
|
|
135
146
|
...isAMD && {requiredModules: requiredAmdModules},
|
|
136
147
|
...isAMD && {preloadModules: preloadAmdModules}
|
|
137
148
|
}, runtimeEnvironment, runtimeParams));
|
|
@@ -31,9 +31,9 @@ var import_legacy_view_bootstrap = __toModule(require("./legacy_view_bootstrap.c
|
|
|
31
31
|
async function linkLwrResources(source, view, viewParams, cxt) {
|
|
32
32
|
const {lwrResourcesId, ...resourceContext} = cxt;
|
|
33
33
|
const {
|
|
34
|
-
|
|
34
|
+
featureFlags: {LEGACY_LOADER}
|
|
35
35
|
} = resourceContext.runtimeEnvironment;
|
|
36
|
-
const {partial, viewRecord} =
|
|
36
|
+
const {partial, viewRecord} = LEGACY_LOADER ? await (0, import_legacy_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext) : await (0, import_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext);
|
|
37
37
|
return {
|
|
38
38
|
renderedView: source.replace(lwrResourcesId, partial),
|
|
39
39
|
viewRecord
|
|
@@ -98,16 +98,18 @@ function getViewHmrConfigurationResource(view, viewMetadata) {
|
|
|
98
98
|
content: configString
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function flattenCustomElements(arr) {
|
|
101
|
+
function flattenCustomElements(arr, isSSR = false) {
|
|
102
102
|
const ret = [];
|
|
103
103
|
const visitedTags = new Set();
|
|
104
104
|
function flatten(arr2) {
|
|
105
105
|
for (const val of arr2) {
|
|
106
|
-
const {tagName, children} = val;
|
|
106
|
+
const {tagName, children, props} = val;
|
|
107
107
|
if (!visitedTags.has(tagName)) {
|
|
108
|
-
|
|
109
|
-
tagName
|
|
110
|
-
}
|
|
108
|
+
if (isSSR) {
|
|
109
|
+
ret.push({tagName, props});
|
|
110
|
+
} else {
|
|
111
|
+
ret.push({tagName});
|
|
112
|
+
}
|
|
111
113
|
visitedTags.add(tagName);
|
|
112
114
|
}
|
|
113
115
|
if (children) {
|
|
@@ -56,6 +56,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
56
56
|
const visitedCache = new Map();
|
|
57
57
|
const imports = {};
|
|
58
58
|
const rootComponents = [];
|
|
59
|
+
const rootProperties = {};
|
|
59
60
|
const requiredAmdModules = [];
|
|
60
61
|
const preloadAmdModules = [];
|
|
61
62
|
if (isAMD) {
|
|
@@ -65,6 +66,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
65
66
|
throw Error("Failed to find definition of resource: " + shimBundle);
|
|
66
67
|
}
|
|
67
68
|
requiredResources.push(def);
|
|
69
|
+
const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
|
|
70
|
+
if (!errorShimDef) {
|
|
71
|
+
throw Error("Failed to find definition of resource: lwr-error-shim.js");
|
|
72
|
+
}
|
|
73
|
+
requiredResources.push(errorShimDef);
|
|
68
74
|
if (!bundle) {
|
|
69
75
|
requiredResources.push(await (0, import_utils.getModuleResource)({
|
|
70
76
|
specifier: "lwr/loader",
|
|
@@ -98,16 +104,20 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
107
|
+
const isSSR = view.bootstrap?.experimentalSSR;
|
|
101
108
|
const customElementsRecords = [];
|
|
102
|
-
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
|
|
103
|
-
await Promise.all(flattenedElements.map(async ({tagName: element}) => {
|
|
104
|
-
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.
|
|
109
|
+
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
|
|
110
|
+
await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
|
|
111
|
+
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifer)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
105
112
|
customElementsRecords.push({elementName: element, flatGraph: graph});
|
|
106
113
|
const specifier = graph.graphs[0].specifier;
|
|
107
114
|
const uri2 = graph.uriMap[specifier];
|
|
108
115
|
moduleResources.push((0, import_utils.getModuleResourceByUri)(uri2, runtimeEnvironment, true));
|
|
109
116
|
rootComponents.push(specifier);
|
|
110
117
|
imports[specifier] = uri2;
|
|
118
|
+
if (isSSR && props) {
|
|
119
|
+
rootProperties[specifier] = props;
|
|
120
|
+
}
|
|
111
121
|
if (isAMD) {
|
|
112
122
|
preloadAmdModules.push(specifier);
|
|
113
123
|
for (const staticDep of graph.graphs[0].static) {
|
|
@@ -132,6 +142,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
132
142
|
imports: importMetadata?.imports,
|
|
133
143
|
index: importMetadata?.index,
|
|
134
144
|
rootComponents,
|
|
145
|
+
rootProperties: isSSR ? rootProperties : void 0,
|
|
135
146
|
...isAMD && {requiredModules: requiredAmdModules},
|
|
136
147
|
...isAMD && {preloadModules: preloadAmdModules}
|
|
137
148
|
}, runtimeEnvironment, runtimeParams));
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -205,10 +205,12 @@ async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEnvironme
|
|
|
205
205
|
resources.push({type, src: asset.override?.uri});
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
+
const importMetadata = !runtimeEnvironment.featureFlags?.LEGACY_LOADER && viewRecord.importMetadata;
|
|
208
209
|
viewRecord.resources?.forEach((resource) => {
|
|
209
210
|
resources.push({type: resource.type, src: resource.src});
|
|
210
211
|
});
|
|
211
212
|
const body = {
|
|
213
|
+
...importMetadata,
|
|
212
214
|
modules,
|
|
213
215
|
preloadModules,
|
|
214
216
|
endpoints,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kebabCaseToModuleSpecifer, getModuleGraphs, GraphDepth, getModuleUriPrefix, } from '@lwrjs/shared-utils';
|
|
2
2
|
import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
|
|
3
3
|
import { generateHtmlTag, getModuleResource, getModuleResourceByUri } from '../utils.js';
|
|
4
4
|
import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
|
|
@@ -35,13 +35,15 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
35
35
|
const imports = {};
|
|
36
36
|
// Collection of root view component specifiers
|
|
37
37
|
const rootComponents = [];
|
|
38
|
+
// Collection of root view component properties, used for SSR hydration
|
|
39
|
+
const rootProperties = {};
|
|
38
40
|
// Collection of modules specifiers that MUST be loaded in the view
|
|
39
41
|
const requiredAmdModules = [];
|
|
40
42
|
// Collection of modules that will be loaded in the view
|
|
41
43
|
const preloadAmdModules = [];
|
|
42
44
|
// ------ AMD Required module resources
|
|
43
45
|
if (isAMD) {
|
|
44
|
-
// Keep
|
|
46
|
+
// Keep shim format in sync with view_bootstrap.ts
|
|
45
47
|
const shimBundle = !bundle
|
|
46
48
|
? 'lwr-loader-shim-legacy.js'
|
|
47
49
|
: debug || minify === false
|
|
@@ -52,6 +54,13 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
52
54
|
throw Error('Failed to find definition of resource: ' + shimBundle);
|
|
53
55
|
}
|
|
54
56
|
requiredResources.push(def);
|
|
57
|
+
// Always inline the error shim script after the shim
|
|
58
|
+
const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
|
|
59
|
+
if (!errorShimDef) {
|
|
60
|
+
throw Error('Failed to find definition of resource: lwr-error-shim.js');
|
|
61
|
+
}
|
|
62
|
+
requiredResources.push(errorShimDef);
|
|
63
|
+
// Add loader, if not already bundled with the shim
|
|
55
64
|
if (!bundle) {
|
|
56
65
|
// needed because we're resolving against fully-linked modules
|
|
57
66
|
requiredResources.push(await getModuleResource({
|
|
@@ -101,10 +110,11 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
// ------- View related custom element moduleResources
|
|
113
|
+
const isSSR = view.bootstrap?.experimentalSSR;
|
|
104
114
|
const customElementsRecords = [];
|
|
105
|
-
const flattenedElements = flattenCustomElements(customElements);
|
|
106
|
-
await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
|
|
107
|
-
const graph = await getModuleGraphs(
|
|
115
|
+
const flattenedElements = flattenCustomElements(customElements, isSSR);
|
|
116
|
+
await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
|
|
117
|
+
const graph = await getModuleGraphs(kebabCaseToModuleSpecifer(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
108
118
|
// add to the viewRecord
|
|
109
119
|
customElementsRecords.push({ elementName: element, flatGraph: graph });
|
|
110
120
|
// PRELOAD custom element static deps as link resource
|
|
@@ -114,6 +124,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
114
124
|
// ADD register custom elements as a uri addressable rootComponents
|
|
115
125
|
rootComponents.push(specifier);
|
|
116
126
|
imports[specifier] = uri;
|
|
127
|
+
// ADD properties for each rootComponent if SSR is on
|
|
128
|
+
if (isSSR && props) {
|
|
129
|
+
rootProperties[specifier] = props;
|
|
130
|
+
}
|
|
117
131
|
if (isAMD) {
|
|
118
132
|
preloadAmdModules.push(specifier);
|
|
119
133
|
for (const staticDep of graph.graphs[0].static) {
|
|
@@ -142,6 +156,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
142
156
|
default: getModuleUriPrefix(runtimeEnvironment, runtimeParams),
|
|
143
157
|
},
|
|
144
158
|
rootComponents,
|
|
159
|
+
rootProperties: isSSR ? rootProperties : undefined,
|
|
145
160
|
...(isAMD && { requiredModules: requiredAmdModules }),
|
|
146
161
|
...(isAMD && { preloadModules: preloadAmdModules }),
|
|
147
162
|
}, runtimeEnvironment, runtimeParams));
|
|
@@ -2,10 +2,10 @@ import { getHtmlResources } from './view_bootstrap.js';
|
|
|
2
2
|
import { getHtmlResources as getLegacyHtmlResource } from './legacy_view_bootstrap.js';
|
|
3
3
|
export async function linkLwrResources(source, view, viewParams, cxt) {
|
|
4
4
|
const { lwrResourcesId, ...resourceContext } = cxt;
|
|
5
|
-
const {
|
|
6
|
-
const { partial, viewRecord } =
|
|
7
|
-
? await
|
|
8
|
-
: await
|
|
5
|
+
const { featureFlags: { LEGACY_LOADER }, } = resourceContext.runtimeEnvironment;
|
|
6
|
+
const { partial, viewRecord } = LEGACY_LOADER
|
|
7
|
+
? await getLegacyHtmlResource(view, viewParams, resourceContext)
|
|
8
|
+
: await getHtmlResources(view, viewParams, resourceContext);
|
|
9
9
|
// Finally replace the token with the real resources
|
|
10
10
|
return {
|
|
11
11
|
renderedView: source.replace(lwrResourcesId, partial),
|
|
@@ -2,5 +2,5 @@ import { ClientBootstrapConfig, RuntimeEnvironment, RuntimeParams, ResourceDefin
|
|
|
2
2
|
import { View, ViewInfo } from '@lwrjs/types';
|
|
3
3
|
export declare function getViewBootstrapConfigurationResource(viewInfo: ViewInfo, config: ClientBootstrapConfig, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams): ResourceDefinition;
|
|
4
4
|
export declare function getViewHmrConfigurationResource(view: View, viewMetadata: RenderedViewMetadata): ResourceDefinition;
|
|
5
|
-
export declare function flattenCustomElements(arr: CustomElementReference[]): CustomElementReference[];
|
|
5
|
+
export declare function flattenCustomElements(arr: CustomElementReference[], isSSR?: boolean): CustomElementReference[];
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -76,16 +76,19 @@ export function getViewHmrConfigurationResource(view, viewMetadata) {
|
|
|
76
76
|
content: configString,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
export function flattenCustomElements(arr) {
|
|
79
|
+
export function flattenCustomElements(arr, isSSR = false) {
|
|
80
80
|
const ret = [];
|
|
81
81
|
const visitedTags = new Set();
|
|
82
82
|
function flatten(arr) {
|
|
83
83
|
for (const val of arr) {
|
|
84
|
-
const { tagName, children } = val;
|
|
84
|
+
const { tagName, children, props } = val;
|
|
85
85
|
if (!visitedTags.has(tagName)) {
|
|
86
|
-
|
|
87
|
-
tagName,
|
|
88
|
-
}
|
|
86
|
+
if (isSSR) {
|
|
87
|
+
ret.push({ tagName, props });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
ret.push({ tagName });
|
|
91
|
+
}
|
|
89
92
|
visitedTags.add(tagName);
|
|
90
93
|
}
|
|
91
94
|
if (children) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kebabCaseToModuleSpecifer, toImportMetadata, getModuleGraphs, getMappingUriPrefix, GraphDepth, } from '@lwrjs/shared-utils';
|
|
2
2
|
import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
|
|
3
3
|
import { generateHtmlTag, getModuleResource, getModuleResourceByUri } from '../utils.js';
|
|
4
4
|
import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
|
|
@@ -35,13 +35,15 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
35
35
|
const imports = {};
|
|
36
36
|
// Collection of root view component specifiers
|
|
37
37
|
const rootComponents = [];
|
|
38
|
+
// Collection of root view component properties, used for SSR hydration
|
|
39
|
+
const rootProperties = {};
|
|
38
40
|
// Collection of modules specifiers that MUST be loaded in the view
|
|
39
41
|
const requiredAmdModules = [];
|
|
40
42
|
// Collection of modules that will be loaded in the view
|
|
41
43
|
const preloadAmdModules = [];
|
|
42
44
|
// ------ AMD Required module resources
|
|
43
45
|
if (isAMD) {
|
|
44
|
-
// Keep
|
|
46
|
+
// Keep shim format in sync with legacy_view_bootstrap.ts
|
|
45
47
|
const shimBundle = !bundle
|
|
46
48
|
? 'lwr-loader-shim.js'
|
|
47
49
|
: debug || minify === false
|
|
@@ -52,6 +54,13 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
52
54
|
throw Error('Failed to find definition of resource: ' + shimBundle);
|
|
53
55
|
}
|
|
54
56
|
requiredResources.push(def);
|
|
57
|
+
// Always inline the error shim script after the shim
|
|
58
|
+
const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
|
|
59
|
+
if (!errorShimDef) {
|
|
60
|
+
throw Error('Failed to find definition of resource: lwr-error-shim.js');
|
|
61
|
+
}
|
|
62
|
+
requiredResources.push(errorShimDef);
|
|
63
|
+
// Add loader, if not already bundled with the shim
|
|
55
64
|
if (!bundle) {
|
|
56
65
|
// needed because we're resolving against fully-linked modules
|
|
57
66
|
requiredResources.push(await getModuleResource({
|
|
@@ -101,10 +110,11 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
101
110
|
}
|
|
102
111
|
let importMetadata = await toImportMetadata(bootstrapModuleGraph, { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
103
112
|
// ------- View related custom element moduleResources
|
|
113
|
+
const isSSR = view.bootstrap?.experimentalSSR;
|
|
104
114
|
const customElementsRecords = [];
|
|
105
|
-
const flattenedElements = flattenCustomElements(customElements);
|
|
106
|
-
await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
|
|
107
|
-
const graph = await getModuleGraphs(
|
|
115
|
+
const flattenedElements = flattenCustomElements(customElements, isSSR);
|
|
116
|
+
await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
|
|
117
|
+
const graph = await getModuleGraphs(kebabCaseToModuleSpecifer(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
108
118
|
// add to the viewRecord
|
|
109
119
|
customElementsRecords.push({ elementName: element, flatGraph: graph });
|
|
110
120
|
// PRELOAD custom element static deps as link resource
|
|
@@ -114,6 +124,10 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
114
124
|
// ADD register custom elements as a uri addressable rootComponents
|
|
115
125
|
rootComponents.push(specifier);
|
|
116
126
|
imports[specifier] = uri;
|
|
127
|
+
// ADD properties for each rootComponent if SSR is on
|
|
128
|
+
if (isSSR && props) {
|
|
129
|
+
rootProperties[specifier] = props;
|
|
130
|
+
}
|
|
117
131
|
if (isAMD) {
|
|
118
132
|
preloadAmdModules.push(specifier);
|
|
119
133
|
for (const staticDep of graph.graphs[0].static) {
|
|
@@ -141,6 +155,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
141
155
|
imports: importMetadata?.imports,
|
|
142
156
|
index: importMetadata?.index,
|
|
143
157
|
rootComponents,
|
|
158
|
+
rootProperties: isSSR ? rootProperties : undefined,
|
|
144
159
|
...(isAMD && { requiredModules: requiredAmdModules }),
|
|
145
160
|
...(isAMD && { preloadModules: preloadAmdModules }),
|
|
146
161
|
}, runtimeEnvironment, runtimeParams));
|
package/build/es/utils.js
CHANGED
|
@@ -187,10 +187,13 @@ export async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEn
|
|
|
187
187
|
resources.push({ type, src: asset.override?.uri });
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
|
+
// Import Metadata
|
|
191
|
+
const importMetadata = !runtimeEnvironment.featureFlags?.LEGACY_LOADER && viewRecord.importMetadata;
|
|
190
192
|
viewRecord.resources?.forEach((resource) => {
|
|
191
193
|
resources.push({ type: resource.type, src: resource.src });
|
|
192
194
|
});
|
|
193
195
|
const body = {
|
|
196
|
+
...importMetadata,
|
|
194
197
|
modules,
|
|
195
198
|
preloadModules,
|
|
196
199
|
endpoints,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.7.0-alpha.10",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,14 +30,15 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lwrjs/app-service": "0.
|
|
34
|
-
"@lwrjs/diagnostics": "0.
|
|
35
|
-
"@lwrjs/shared-utils": "0.
|
|
33
|
+
"@lwrjs/app-service": "0.7.0-alpha.10",
|
|
34
|
+
"@lwrjs/diagnostics": "0.7.0-alpha.10",
|
|
35
|
+
"@lwrjs/shared-utils": "0.7.0-alpha.10"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lwrjs/types": "0.
|
|
38
|
+
"@lwrjs/types": "0.7.0-alpha.10"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=14.15.4 <17"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "83c1e65e2169094cb55ac2c37e5aef16d3a9aa4a"
|
|
43
44
|
}
|