@lwrjs/view-registry 0.6.0-alpha.3 → 0.6.0-alpha.7

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.
@@ -98,7 +98,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
98
98
  }
99
99
  }
100
100
  const customElementsRecords = [];
101
- await Promise.all(customElements.map(async ({tagName: element}) => {
101
+ const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
102
+ await Promise.all(flattenedElements.map(async ({tagName: element}) => {
102
103
  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);
103
104
  customElementsRecords.push({elementName: element, flatGraph: graph});
104
105
  const specifier = graph.graphs[0].specifier;
@@ -24,6 +24,7 @@ var __toModule = (module2) => {
24
24
  // packages/@lwrjs/view-registry/src/linkers/utils.ts
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
+ flattenCustomElements: () => flattenCustomElements,
27
28
  getViewBootstrapConfigurationResource: () => getViewBootstrapConfigurationResource,
28
29
  getViewHmrConfigurationResource: () => getViewHmrConfigurationResource
29
30
  });
@@ -97,3 +98,23 @@ function getViewHmrConfigurationResource(view, viewMetadata) {
97
98
  content: configString
98
99
  };
99
100
  }
101
+ function flattenCustomElements(arr) {
102
+ const ret = [];
103
+ const visitedTags = new Set();
104
+ function flatten(arr2) {
105
+ for (const val of arr2) {
106
+ const {tagName, children} = val;
107
+ if (!visitedTags.has(tagName)) {
108
+ ret.push({
109
+ tagName
110
+ });
111
+ visitedTags.add(tagName);
112
+ }
113
+ if (children) {
114
+ flatten(children);
115
+ }
116
+ }
117
+ }
118
+ flatten(arr);
119
+ return ret;
120
+ }
@@ -99,7 +99,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
99
99
  }
100
100
  let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
101
101
  const customElementsRecords = [];
102
- await Promise.all(customElements.map(async ({tagName: element}) => {
102
+ const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements);
103
+ await Promise.all(flattenedElements.map(async ({tagName: element}) => {
103
104
  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);
104
105
  customElementsRecords.push({elementName: element, flatGraph: graph});
105
106
  const specifier = graph.graphs[0].specifier;
@@ -1,7 +1,7 @@
1
1
  import { kebabcaseToCamelcase, 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
- import { getViewBootstrapConfigurationResource, getViewHmrConfigurationResource } from './utils.js';
4
+ import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
5
5
  export async function getHtmlResources(view, viewParams, resourceContext) {
6
6
  const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, } = resourceContext;
7
7
  const { id: appName, bootstrap: { services } = { services: [] } } = view;
@@ -102,7 +102,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
102
102
  }
103
103
  // ------- View related custom element moduleResources
104
104
  const customElementsRecords = [];
105
- await Promise.all(customElements.map(async ({ tagName: element }) => {
105
+ const flattenedElements = flattenCustomElements(customElements);
106
+ await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
106
107
  const graph = await getModuleGraphs(kebabcaseToCamelcase(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
107
108
  // add to the viewRecord
108
109
  customElementsRecords.push({ elementName: element, flatGraph: graph });
@@ -1,5 +1,6 @@
1
- import { ClientBootstrapConfig, RuntimeEnvironment, RuntimeParams, ResourceDefinition, RenderedViewMetadata } from '@lwrjs/types';
1
+ import { ClientBootstrapConfig, RuntimeEnvironment, RuntimeParams, ResourceDefinition, RenderedViewMetadata, CustomElementReference } from '@lwrjs/types';
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
6
  //# sourceMappingURL=utils.d.ts.map
@@ -76,4 +76,24 @@ export function getViewHmrConfigurationResource(view, viewMetadata) {
76
76
  content: configString,
77
77
  };
78
78
  }
79
+ export function flattenCustomElements(arr) {
80
+ const ret = [];
81
+ const visitedTags = new Set();
82
+ function flatten(arr) {
83
+ for (const val of arr) {
84
+ const { tagName, children } = val;
85
+ if (!visitedTags.has(tagName)) {
86
+ ret.push({
87
+ tagName,
88
+ });
89
+ visitedTags.add(tagName);
90
+ }
91
+ if (children) {
92
+ flatten(children);
93
+ }
94
+ }
95
+ }
96
+ flatten(arr);
97
+ return ret;
98
+ }
79
99
  //# sourceMappingURL=utils.js.map
@@ -1,7 +1,7 @@
1
1
  import { kebabcaseToCamelcase, 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
- import { getViewBootstrapConfigurationResource, getViewHmrConfigurationResource } from './utils.js';
4
+ import { flattenCustomElements, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
5
5
  export async function getHtmlResources(view, viewParams, resourceContext) {
6
6
  const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, } = resourceContext;
7
7
  const { id: appName, bootstrap: { services } = { services: [] } } = view;
@@ -103,7 +103,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
103
103
  let importMetadata = await toImportMetadata(bootstrapModuleGraph, { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams);
104
104
  // ------- View related custom element moduleResources
105
105
  const customElementsRecords = [];
106
- await Promise.all(customElements.map(async ({ tagName: element }) => {
106
+ const flattenedElements = flattenCustomElements(customElements);
107
+ await Promise.all(flattenedElements.map(async ({ tagName: element }) => {
107
108
  const graph = await getModuleGraphs(kebabcaseToCamelcase(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
108
109
  // add to the viewRecord
109
110
  customElementsRecords.push({ elementName: element, flatGraph: graph });
@@ -3,6 +3,7 @@ import { generateHtmlTag, generatePageContext, getRouteHandler, isViewResponse,
3
3
  import { resolve } from 'path';
4
4
  export class LwrViewHandler {
5
5
  constructor(context, globalConfig) {
6
+ // TODO convert to using InflightTasks in the shared utils
6
7
  this.inflightRouteHandlerEvalMap = new Map();
7
8
  this.routeHandlerFunctionMap = new Map();
8
9
  this.viewRegistry = context.viewRegistry;
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.0-alpha.3",
8
- "homepage": "https://lwr.dev/",
7
+ "version": "0.6.0-alpha.7",
8
+ "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/salesforce/lwr.git",
@@ -30,15 +30,15 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/app-service": "0.6.0-alpha.3",
34
- "@lwrjs/diagnostics": "0.6.0-alpha.3",
35
- "@lwrjs/shared-utils": "0.6.0-alpha.3"
33
+ "@lwrjs/app-service": "0.6.0-alpha.7",
34
+ "@lwrjs/diagnostics": "0.6.0-alpha.7",
35
+ "@lwrjs/shared-utils": "0.6.0-alpha.7"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.6.0-alpha.3"
38
+ "@lwrjs/types": "0.6.0-alpha.7"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=14.15.4 <17"
42
42
  },
43
- "gitHead": "ee0ad55e8490f58602de24ab861bb4f4cce9404c"
43
+ "gitHead": "dc066450384dc1e27064b46ddd5f24543758a414"
44
44
  }