@lwrjs/view-registry 0.7.0-alpha.1 → 0.7.0-alpha.12

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.
@@ -102,10 +102,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
102
102
  }
103
103
  }
104
104
  }
105
+ const isSSR = view.bootstrap?.experimentalSSR;
105
106
  const customElementsRecords = [];
106
- const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
107
- await Promise.all(flattenedElements.map(async ({tagName: element}) => {
108
- const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabcaseToCamelcase)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
107
+ const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
108
+ await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
109
+ 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);
109
110
  customElementsRecords.push({elementName: element, flatGraph: graph});
110
111
  const specifier = graph.graphs[0].specifier;
111
112
  const uri2 = graph.uriMap[specifier];
@@ -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
- ret.push({
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) {
@@ -103,10 +103,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
103
103
  }
104
104
  }
105
105
  let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
106
+ const isSSR = view.bootstrap?.experimentalSSR;
106
107
  const customElementsRecords = [];
107
- const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
108
- await Promise.all(flattenedElements.map(async ({tagName: element}) => {
109
- const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabcaseToCamelcase)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
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);
110
111
  customElementsRecords.push({elementName: element, flatGraph: graph});
111
112
  const specifier = graph.graphs[0].specifier;
112
113
  const uri2 = graph.uriMap[specifier];
@@ -45,7 +45,7 @@ var LwrViewHandler = class {
45
45
  return response;
46
46
  }
47
47
  const {view, viewParams, renderOptions} = normalizeViewProperties(viewRequest, response, route, this.globalConfig);
48
- const viewDefinition2 = await this.viewRegistry.getViewDefinition(view, viewParams, runtimeEnvironment, runtimeParams, renderOptions);
48
+ const viewDefinition2 = await this.viewRegistry.getViewDefinition(view, viewParams, runtimeEnvironment, {...runtimeParams, params: viewRequest.params}, renderOptions);
49
49
  return {
50
50
  ...response,
51
51
  body: viewDefinition2.renderedView,
@@ -114,7 +114,7 @@ var LwrViewHandler = class {
114
114
  rootComponent,
115
115
  contentTemplate,
116
116
  layoutTemplate
117
- }, {page, ...properties}, runtimeEnvironment, runtimeParams);
117
+ }, {page, ...properties}, runtimeEnvironment, {...runtimeParams, params: viewRequest.params});
118
118
  return viewDefinition;
119
119
  }
120
120
  async getRouteHandlerResponse(viewRequest, route, runtimeEnvironment, runtimeParams = {}) {
@@ -1,4 +1,4 @@
1
- import { kebabcaseToCamelcase, getModuleGraphs, GraphDepth, getModuleUriPrefix } from '@lwrjs/shared-utils';
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';
@@ -108,10 +108,11 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
108
108
  }
109
109
  }
110
110
  // ------- View related custom element moduleResources
111
+ const isSSR = view.bootstrap?.experimentalSSR;
111
112
  const customElementsRecords = [];
112
- const flattenedElements = flattenCustomElements(customElements);
113
- await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
114
- const graph = await getModuleGraphs(kebabcaseToCamelcase(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
113
+ const flattenedElements = flattenCustomElements(customElements, isSSR);
114
+ await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
115
+ const graph = await getModuleGraphs(kebabCaseToModuleSpecifer(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
115
116
  // add to the viewRecord
116
117
  customElementsRecords.push({ elementName: element, flatGraph: graph });
117
118
  // PRELOAD custom element static deps as link resource
@@ -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
- ret.push({
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 { kebabcaseToCamelcase, toImportMetadata, getModuleGraphs, getMappingUriPrefix, GraphDepth, } from '@lwrjs/shared-utils';
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';
@@ -108,10 +108,11 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
108
108
  }
109
109
  let importMetadata = await toImportMetadata(bootstrapModuleGraph, { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams);
110
110
  // ------- View related custom element moduleResources
111
+ const isSSR = view.bootstrap?.experimentalSSR;
111
112
  const customElementsRecords = [];
112
- const flattenedElements = flattenCustomElements(customElements);
113
- await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
114
- const graph = await getModuleGraphs(kebabcaseToCamelcase(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
113
+ const flattenedElements = flattenCustomElements(customElements, isSSR);
114
+ await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
115
+ const graph = await getModuleGraphs(kebabCaseToModuleSpecifer(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
115
116
  // add to the viewRecord
116
117
  customElementsRecords.push({ elementName: element, flatGraph: graph });
117
118
  // PRELOAD custom element static deps as link resource
@@ -27,7 +27,7 @@ export class LwrViewHandler {
27
27
  }
28
28
  // Process ViewDefinitionResponse
29
29
  const { view, viewParams, renderOptions } = normalizeViewProperties(viewRequest, response, route, this.globalConfig);
30
- const viewDefinition = await this.viewRegistry.getViewDefinition(view, viewParams, runtimeEnvironment, runtimeParams, renderOptions);
30
+ const viewDefinition = await this.viewRegistry.getViewDefinition(view, viewParams, runtimeEnvironment, { ...runtimeParams, params: viewRequest.params }, renderOptions);
31
31
  return {
32
32
  ...response,
33
33
  body: viewDefinition.renderedView,
@@ -127,7 +127,7 @@ export class LwrViewHandler {
127
127
  rootComponent,
128
128
  contentTemplate,
129
129
  layoutTemplate,
130
- }, { page, ...properties }, runtimeEnvironment, runtimeParams);
130
+ }, { page, ...properties }, runtimeEnvironment, { ...runtimeParams, params: viewRequest.params });
131
131
  return viewDefinition;
132
132
  }
133
133
  async getRouteHandlerResponse(
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.7.0-alpha.1",
7
+ "version": "0.7.0-alpha.12",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,15 +30,15 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/app-service": "0.7.0-alpha.1",
34
- "@lwrjs/diagnostics": "0.7.0-alpha.1",
35
- "@lwrjs/shared-utils": "0.7.0-alpha.1"
33
+ "@lwrjs/app-service": "0.7.0-alpha.12",
34
+ "@lwrjs/diagnostics": "0.7.0-alpha.12",
35
+ "@lwrjs/shared-utils": "0.7.0-alpha.12"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.7.0-alpha.1"
38
+ "@lwrjs/types": "0.7.0-alpha.12"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=14.15.4 <17"
42
42
  },
43
- "gitHead": "24245670d6908d37e465f2316f92385df63d22aa"
43
+ "gitHead": "785b8380a821b43b7320783dddaf20d1433216e2"
44
44
  }