@lwrjs/view-registry 0.15.0-alpha.41 → 0.15.0-alpha.43

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.
@@ -54,11 +54,7 @@ var LwrViewRegistry = class {
54
54
  this.viewDefinitions = new import_lru_cache.LRUCache({
55
55
  max: parseInt(process.env.VIEW_CACHE_SIZE ?? "500", 10),
56
56
  dispose: (_value, key) => {
57
- if ((0, import_shared_utils.isLambdaEnv)()) {
58
- import_diagnostics.logger.warn(`View evicted from cache ${key}`);
59
- } else {
60
- import_diagnostics.logger.verbose(`View evicted from cache ${key}`);
61
- }
57
+ import_diagnostics.logger.verbose(`View evicted from cache ${key}`);
62
58
  }
63
59
  });
64
60
  observer.onViewSourceChange(({payload}) => this.onViewSourceChange(payload));
@@ -59,8 +59,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
59
59
  moduleRegistry,
60
60
  moduleBundler,
61
61
  resourceRegistry,
62
- viewMetadata,
63
- viewLinkCacheKey
62
+ viewMetadata
64
63
  } = resourceContext;
65
64
  const {format, hmrEnabled, bundle, debug, minify} = runtimeEnvironment;
66
65
  const {customElements, serverData, serverDebug} = viewMetadata;
@@ -154,7 +153,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
154
153
  requiredResources.push(errorShimDef);
155
154
  }
156
155
  let bootstrapModuleGraph;
157
- const bootstrapModuleGraphCacheKey = (0, import_utils.getModuleGraphCacheKey)(bootstrapSpecifier, viewLinkCacheKey);
156
+ const bootstrapModuleGraphCacheKey = (0, import_utils.getModuleGraphCacheKey)(bootstrapSpecifier, runtimeEnvironment, runtimeParams);
158
157
  if (enableModuleGraphsCache && moduleGraphsCache.has(bootstrapModuleGraphCacheKey)) {
159
158
  bootstrapModuleGraph = moduleGraphsCache.get(bootstrapModuleGraphCacheKey);
160
159
  } else {
@@ -191,7 +190,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
191
190
  for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
192
191
  const uri2 = bootstrapModuleGraph.uriMap[staticDep];
193
192
  imports[staticDep] = uri2;
194
- if (services && services.length) {
193
+ if (services?.length) {
195
194
  requiredAmdModules.push(staticDep);
196
195
  }
197
196
  }
@@ -211,12 +210,16 @@ async function getHtmlResources(view, viewParams, resourceContext) {
211
210
  await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
212
211
  const hydrateDirective = (0, import_shared_utils.getHydrateDirective)(props);
213
212
  const isSsrOnly = isSSR && !hydrateDirective;
214
- const moduleGraphCacheKey = (0, import_utils.getModuleGraphCacheKey)(element, viewLinkCacheKey);
213
+ const elementSpecifier = (0, import_shared_utils.kebabCaseToModuleSpecifier)(element);
214
+ const moduleGraphCacheKey = (0, import_utils.getModuleGraphCacheKey)(elementSpecifier, runtimeEnvironment, {
215
+ ...runtimeParams,
216
+ ssr: isSsrOnly
217
+ });
215
218
  let graph;
216
219
  if (enableModuleGraphsCache && moduleGraphsCache.has(moduleGraphCacheKey)) {
217
220
  graph = moduleGraphsCache.get(moduleGraphCacheKey);
218
221
  } else {
219
- graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifier)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, {...runtimeParams, ssr: isSsrOnly}, visitedCache);
222
+ graph = await (0, import_shared_utils.getModuleGraphs)(elementSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, {...runtimeParams, ssr: isSsrOnly}, visitedCache);
220
223
  enableModuleGraphsCache && moduleGraphsCache.set(moduleGraphCacheKey, graph);
221
224
  }
222
225
  customElementsRecords.push({elementName: element, flatGraph: graph});
@@ -52,8 +52,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
52
52
  moduleRegistry,
53
53
  moduleBundler,
54
54
  resourceRegistry,
55
- viewMetadata,
56
- viewLinkCacheKey
55
+ viewMetadata
57
56
  } = resourceContext;
58
57
  const {format, hmrEnabled, bundle, debug, minify} = runtimeEnvironment;
59
58
  const {customElements, serverData, serverDebug} = viewMetadata;
@@ -135,7 +134,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
135
134
  requiredResources.push(errorShimDef);
136
135
  }
137
136
  let bootstrapModuleGraph;
138
- const bootstrapModuleGraphCacheKey = (0, import_utils3.getModuleGraphCacheKey)(bootstrapSpecifier, viewLinkCacheKey);
137
+ const bootstrapModuleGraphCacheKey = (0, import_utils3.getModuleGraphCacheKey)(bootstrapSpecifier, runtimeEnvironment, runtimeParams);
139
138
  if (enableModuleGraphsCache && moduleGraphsCache.has(bootstrapModuleGraphCacheKey)) {
140
139
  bootstrapModuleGraph = moduleGraphsCache.get(bootstrapModuleGraphCacheKey);
141
140
  } else {
@@ -172,7 +171,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
172
171
  for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
173
172
  const uri2 = bootstrapModuleGraph.uriMap[staticDep];
174
173
  imports[staticDep] = uri2;
175
- if (services && services.length) {
174
+ if (services?.length) {
176
175
  requiredAmdModules.push(staticDep);
177
176
  }
178
177
  }
@@ -193,12 +192,16 @@ async function getHtmlResources(view, viewParams, resourceContext) {
193
192
  for (const {tagName: element, props} of flattenedElements) {
194
193
  const hydrateDirective = (0, import_shared_utils.getHydrateDirective)(props);
195
194
  const isSsrOnly = isSSR && !hydrateDirective;
196
- const moduleGraphCacheKey = (0, import_utils3.getModuleGraphCacheKey)(element, viewLinkCacheKey);
195
+ const elementSpecifier = (0, import_shared_utils.kebabCaseToModuleSpecifier)(element);
196
+ const moduleGraphCacheKey = (0, import_utils3.getModuleGraphCacheKey)(elementSpecifier, runtimeEnvironment, {
197
+ ...runtimeParams,
198
+ ssr: isSsrOnly
199
+ });
197
200
  let graph;
198
201
  if (enableModuleGraphsCache && moduleGraphsCache.has(moduleGraphCacheKey)) {
199
202
  graph = moduleGraphsCache.get(moduleGraphCacheKey);
200
203
  } else {
201
- graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifier)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, {...runtimeParams, ssr: isSsrOnly}, visitedCache);
204
+ graph = await (0, import_shared_utils.getModuleGraphs)(elementSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, {...runtimeParams, ssr: isSsrOnly}, visitedCache);
202
205
  enableModuleGraphsCache && moduleGraphsCache.set(moduleGraphCacheKey, graph);
203
206
  }
204
207
  customElementsRecords.push({elementName: element, flatGraph: graph});
@@ -349,6 +349,15 @@ function getViewDefCacheKey(view, runtimeEnvironment, freezeAssets, runtimeParam
349
349
  nonceEnabled: (0, import_shared_utils.getFeatureFlags)().ENABLE_NONCE
350
350
  });
351
351
  }
352
- function getModuleGraphCacheKey(specifier, viewLinkCacheKey) {
353
- return specifier + viewLinkCacheKey;
352
+ function getModuleGraphCacheKey(specifier, runtimeEnvironment, runtimeParams) {
353
+ const updatedParams = {
354
+ ...runtimeParams
355
+ };
356
+ delete updatedParams.url;
357
+ delete updatedParams.query;
358
+ return (0, import_shared_utils.getCacheKeyFromJson)({
359
+ specifier,
360
+ updatedParams,
361
+ runtimeEnvironment
362
+ });
354
363
  }
package/build/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { InflightTasks, createStringBuilder, extractMetadataFromHtml, getCacheKeyFromJson, getFeatureFlags, getSpecifier, isLambdaEnv, isLocalDev, normalizeResourcePath, shortestTtl, isRelative, } from '@lwrjs/shared-utils';
1
+ import { InflightTasks, createStringBuilder, extractMetadataFromHtml, getCacheKeyFromJson, getFeatureFlags, getSpecifier, isLocalDev, normalizeResourcePath, shortestTtl, isRelative, } from '@lwrjs/shared-utils';
2
2
  import { getTracer, ViewSpan } from '@lwrjs/instrumentation';
3
3
  import { generateViewNonce, getViewNonce, normalizeRenderOptions, normalizeRenderedResult, reduceSourceAssetReferences, getViewDefCacheKey, } from './utils.js';
4
4
  import { linkLwrResources } from './linkers/link-lwr-resources.js';
@@ -33,12 +33,8 @@ export class LwrViewRegistry {
33
33
  this.viewDefinitions = new LRUCache({
34
34
  max: parseInt(process.env.VIEW_CACHE_SIZE ?? '500', 10),
35
35
  dispose: (_value, key) => {
36
- if (isLambdaEnv()) {
37
- logger.warn(`View evicted from cache ${key}`);
38
- }
39
- else {
40
- logger.verbose(`View evicted from cache ${key}`);
41
- }
36
+ // We expect the view to get evicted quite often in LWR@MRT so we are not warning of eviction here.
37
+ logger.verbose(`View evicted from cache ${key}`);
42
38
  },
43
39
  });
44
40
  // Observers for cached entries external dependencies -- view templates, modules, and assets
@@ -31,7 +31,7 @@ const moduleGraphsCache = new LRUCache({
31
31
  });
32
32
  const isRunningLocalDev = isLocalDev();
33
33
  export async function getHtmlResources(view, viewParams, resourceContext) {
34
- const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, viewLinkCacheKey, } = resourceContext;
34
+ const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, } = resourceContext;
35
35
  const { format, hmrEnabled, bundle, debug, minify } = runtimeEnvironment;
36
36
  const { customElements, serverData, serverDebug } = viewMetadata;
37
37
  const isAMD = format === 'amd';
@@ -168,7 +168,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
168
168
  // Reasoning: This is to avoid unnecessary HTTP 302's during initial application module fetching.
169
169
  // Scope: ESM currently only exposes immutable URI references, optimize for AMD formats
170
170
  let bootstrapModuleGraph;
171
- const bootstrapModuleGraphCacheKey = getModuleGraphCacheKey(bootstrapSpecifier, viewLinkCacheKey);
171
+ // Just determine the cache key based on the inputs to the getModuleGraphs
172
+ const bootstrapModuleGraphCacheKey = getModuleGraphCacheKey(bootstrapSpecifier, runtimeEnvironment, runtimeParams);
172
173
  if (enableModuleGraphsCache && moduleGraphsCache.has(bootstrapModuleGraphCacheKey)) {
173
174
  bootstrapModuleGraph = moduleGraphsCache.get(bootstrapModuleGraphCacheKey);
174
175
  }
@@ -217,7 +218,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
217
218
  // AMD ADD static module dep uri addressability
218
219
  imports[staticDep] = uri;
219
220
  // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
220
- if (services && services.length) {
221
+ if (services?.length) {
221
222
  requiredAmdModules.push(staticDep);
222
223
  }
223
224
  }
@@ -240,13 +241,17 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
240
241
  await Promise.all(flattenedElements.map(async ({ tagName: element, props }) => {
241
242
  const hydrateDirective = getHydrateDirective(props);
242
243
  const isSsrOnly = isSSR && !hydrateDirective;
243
- const moduleGraphCacheKey = getModuleGraphCacheKey(element, viewLinkCacheKey);
244
+ const elementSpecifier = kebabCaseToModuleSpecifier(element);
245
+ const moduleGraphCacheKey = getModuleGraphCacheKey(elementSpecifier, runtimeEnvironment, {
246
+ ...runtimeParams,
247
+ ssr: isSsrOnly,
248
+ });
244
249
  let graph;
245
250
  if (enableModuleGraphsCache && moduleGraphsCache.has(moduleGraphCacheKey)) {
246
251
  graph = moduleGraphsCache.get(moduleGraphCacheKey);
247
252
  }
248
253
  else {
249
- graph = await getModuleGraphs(kebabCaseToModuleSpecifier(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, defRegistry, runtimeEnvironment, { ...runtimeParams, ssr: isSsrOnly }, visitedCache);
254
+ graph = await getModuleGraphs(elementSpecifier, { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, defRegistry, runtimeEnvironment, { ...runtimeParams, ssr: isSsrOnly }, visitedCache);
250
255
  enableModuleGraphsCache && moduleGraphsCache.set(moduleGraphCacheKey, graph);
251
256
  }
252
257
  // add to the viewRecord
@@ -21,7 +21,7 @@ const moduleGraphsCache = new LRUCache({
21
21
  });
22
22
  const isRunningLocalDev = isLocalDev();
23
23
  export async function getHtmlResources(view, viewParams, resourceContext) {
24
- const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, viewLinkCacheKey, } = resourceContext;
24
+ const { runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler, resourceRegistry, viewMetadata, } = resourceContext;
25
25
  const { format, hmrEnabled, bundle, debug, minify } = runtimeEnvironment;
26
26
  const { customElements, serverData, serverDebug } = viewMetadata;
27
27
  const defRegistry = bundle ? moduleBundler : moduleRegistry;
@@ -136,7 +136,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
136
136
  // Traversal of the Bootstrap Module Graph is done to get all the URLS for discoverable static dependencies.
137
137
  // Reasoning: This is to avoid unnecessary HTTP 302's during initial application module fetching.
138
138
  let bootstrapModuleGraph;
139
- const bootstrapModuleGraphCacheKey = getModuleGraphCacheKey(bootstrapSpecifier, viewLinkCacheKey);
139
+ // Just determine the cache key based on the inputs to the getModuleGraphs
140
+ const bootstrapModuleGraphCacheKey = getModuleGraphCacheKey(bootstrapSpecifier, runtimeEnvironment, runtimeParams);
140
141
  if (enableModuleGraphsCache && moduleGraphsCache.has(bootstrapModuleGraphCacheKey)) {
141
142
  bootstrapModuleGraph = moduleGraphsCache.get(bootstrapModuleGraphCacheKey);
142
143
  }
@@ -185,7 +186,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
185
186
  // ADD static module dep uri addressability
186
187
  imports[staticDep] = uri;
187
188
  // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
188
- if (services && services.length) {
189
+ if (services?.length) {
189
190
  requiredAmdModules.push(staticDep);
190
191
  }
191
192
  }
@@ -209,14 +210,18 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
209
210
  for (const { tagName: element, props } of flattenedElements) {
210
211
  const hydrateDirective = getHydrateDirective(props);
211
212
  const isSsrOnly = isSSR && !hydrateDirective;
212
- const moduleGraphCacheKey = getModuleGraphCacheKey(element, viewLinkCacheKey);
213
+ const elementSpecifier = kebabCaseToModuleSpecifier(element);
214
+ const moduleGraphCacheKey = getModuleGraphCacheKey(elementSpecifier, runtimeEnvironment, {
215
+ ...runtimeParams,
216
+ ssr: isSsrOnly,
217
+ });
213
218
  let graph;
214
219
  if (enableModuleGraphsCache && moduleGraphsCache.has(moduleGraphCacheKey)) {
215
220
  graph = moduleGraphsCache.get(moduleGraphCacheKey);
216
221
  }
217
222
  else {
218
223
  // eslint-disable-next-line no-await-in-loop
219
- graph = await getModuleGraphs(kebabCaseToModuleSpecifier(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, defRegistry, runtimeEnvironment, { ...runtimeParams, ssr: isSsrOnly }, visitedCache);
224
+ graph = await getModuleGraphs(elementSpecifier, { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, defRegistry, runtimeEnvironment, { ...runtimeParams, ssr: isSsrOnly }, visitedCache);
220
225
  enableModuleGraphsCache && moduleGraphsCache.set(moduleGraphCacheKey, graph);
221
226
  }
222
227
  // add to the viewRecord
@@ -25,5 +25,5 @@ export declare function generateViewNonce(viewParams: ViewParams): void;
25
25
  export declare function addExternalScriptNonce(def: ResourceDefinition, nonce?: string): void;
26
26
  export declare function generateLinkHeaders(assets: RenderedAssetReference[], patterns: Record<string, any>[]): string;
27
27
  export declare function getViewDefCacheKey(view: View, runtimeEnvironment: RuntimeEnvironment, freezeAssets: boolean, runtimeParams?: RuntimeParams): string;
28
- export declare function getModuleGraphCacheKey(specifier: string, viewLinkCacheKey: string): string;
28
+ export declare function getModuleGraphCacheKey(specifier: string, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): string;
29
29
  //# sourceMappingURL=utils.d.ts.map
package/build/es/utils.js CHANGED
@@ -340,7 +340,17 @@ export function getViewDefCacheKey(view, runtimeEnvironment, freezeAssets, runti
340
340
  nonceEnabled: getFeatureFlags().ENABLE_NONCE,
341
341
  });
342
342
  }
343
- export function getModuleGraphCacheKey(specifier, viewLinkCacheKey) {
344
- return specifier + viewLinkCacheKey;
343
+ export function getModuleGraphCacheKey(specifier, runtimeEnvironment, runtimeParams) {
344
+ const updatedParams = {
345
+ ...runtimeParams,
346
+ };
347
+ // Remove the URL and query from the runtimeParams
348
+ delete updatedParams.url;
349
+ delete updatedParams.query;
350
+ return getCacheKeyFromJson({
351
+ specifier,
352
+ updatedParams,
353
+ runtimeEnvironment,
354
+ });
345
355
  }
346
356
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.15.0-alpha.41",
7
+ "version": "0.15.0-alpha.43",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,14 +33,14 @@
33
33
  "build": "tsc -b"
34
34
  },
35
35
  "dependencies": {
36
- "@lwrjs/app-service": "0.15.0-alpha.41",
37
- "@lwrjs/diagnostics": "0.15.0-alpha.41",
38
- "@lwrjs/instrumentation": "0.15.0-alpha.41",
39
- "@lwrjs/shared-utils": "0.15.0-alpha.41",
36
+ "@lwrjs/app-service": "0.15.0-alpha.43",
37
+ "@lwrjs/diagnostics": "0.15.0-alpha.43",
38
+ "@lwrjs/instrumentation": "0.15.0-alpha.43",
39
+ "@lwrjs/shared-utils": "0.15.0-alpha.43",
40
40
  "lru-cache": "^10.4.3"
41
41
  },
42
42
  "devDependencies": {
43
- "@lwrjs/types": "0.15.0-alpha.41"
43
+ "@lwrjs/types": "0.15.0-alpha.43"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18.0.0"
@@ -48,5 +48,5 @@
48
48
  "volta": {
49
49
  "extends": "../../../package.json"
50
50
  },
51
- "gitHead": "26a304d3a5f92daf1d3eff3d9c937eccf1372fd3"
51
+ "gitHead": "e11d6addc63842c0c0299c57cb920137a90045c4"
52
52
  }