@lwrjs/view-registry 0.17.6 → 0.17.8

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.
@@ -90,7 +90,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
90
90
  }
91
91
  } = view;
92
92
  const defRegistry = bundle ? moduleBundler : moduleRegistry;
93
- const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 0};
93
+ const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: (0, import_shared_utils.isMrtBundle)() ? 50 : 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 0};
94
94
  if (isAMD) {
95
95
  depth.includeId = includeIdFactory(bundleConfig);
96
96
  }
@@ -181,7 +181,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
181
181
  const uri2 = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
182
182
  if (uri2) {
183
183
  const integrity2 = (0, import_utils2.getBundleIntegrity)(bootstrapModuleGraph, depSpecifier);
184
- (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, integrity2, groups, viewPreloads);
184
+ const depDef = bootstrapModuleGraph.linkedDefinitions[depSpecifier];
185
+ (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, integrity2, groups, viewPreloads, depDef?.bundleRecord?.includedModules);
185
186
  }
186
187
  }
187
188
  if ((0, import_shared_utils.isBundler)(defRegistry)) {
@@ -192,22 +193,25 @@ async function getHtmlResources(view, viewParams, resourceContext) {
192
193
  if (isAMD) {
193
194
  requiredAmdModules.push(versionedSpecifier);
194
195
  imports[versionedSpecifier] = uri;
195
- for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
196
- const uri2 = bootstrapModuleGraph.uriMap[staticDep];
197
- imports[staticDep] = uri2;
198
- if (services?.length) {
199
- requiredAmdModules.push(staticDep);
196
+ const levels = (0, import_shared_utils.isMrtBundle)() ? bootstrapModuleGraph.graphs.length : 1;
197
+ for (let i = 0; i < levels; i++) {
198
+ for (const staticDep of bootstrapModuleGraph.graphs[i].static) {
199
+ const uri2 = bootstrapModuleGraph.uriMap[staticDep];
200
+ imports[staticDep] = uri2;
201
+ if (services?.length && i === 0) {
202
+ requiredAmdModules.push(staticDep);
203
+ }
200
204
  }
201
- }
202
- for (const dynamicDep of bootstrapModuleGraph.graphs[0].dynamicRefs) {
203
- const uri2 = bootstrapModuleGraph.uriMap[dynamicDep];
204
- if (uri2) {
205
- imports[dynamicDep] = uri2;
206
- } else {
207
- import_diagnostics.logger.warn({
208
- label: `view-registry`,
209
- message: `Skipping unknown dynamic import: ${dynamicDep}`
210
- });
205
+ for (const dynamicDep of bootstrapModuleGraph.graphs[i].dynamicRefs) {
206
+ const uri2 = bootstrapModuleGraph.uriMap[dynamicDep];
207
+ if (uri2) {
208
+ imports[dynamicDep] = uri2;
209
+ } else {
210
+ import_diagnostics.logger.warn({
211
+ label: `view-registry`,
212
+ message: `Skipping unknown dynamic import: ${dynamicDep}`
213
+ });
214
+ }
211
215
  }
212
216
  }
213
217
  }
@@ -240,20 +244,24 @@ async function getHtmlResources(view, viewParams, resourceContext) {
240
244
  const depUri = getPreloadUri(depSpecifier, graph.uriMap);
241
245
  if (depUri) {
242
246
  const integrity2 = (0, import_utils2.getBundleIntegrity)(graph, depSpecifier);
243
- (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, depUri, integrity2, groups, viewPreloads);
247
+ const depDef = graph.linkedDefinitions[depSpecifier];
248
+ (0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, depUri, integrity2, groups, viewPreloads, depDef?.bundleRecord?.includedModules);
244
249
  }
245
250
  }
246
251
  }
247
252
  rootComponents.push(specifier);
248
253
  imports[specifier] = uri;
249
254
  if (isAMD) {
250
- for (const staticDep of graph.graphs[0].static) {
251
- const uri2 = graph.uriMap[staticDep];
252
- imports[staticDep] = uri2;
253
- }
254
- for (const dynamicDep of graph.graphs[0].dynamicRefs) {
255
- const uri2 = graph.uriMap[dynamicDep];
256
- imports[dynamicDep] = uri2;
255
+ const levels = (0, import_shared_utils.isMrtBundle)() ? graph.graphs.length : 1;
256
+ for (let i = 0; i < levels; i++) {
257
+ for (const staticDep of graph.graphs[i].static) {
258
+ const uri2 = graph.uriMap[staticDep];
259
+ imports[staticDep] = uri2;
260
+ }
261
+ for (const dynamicDep of graph.graphs[i].dynamicRefs) {
262
+ const uri2 = graph.uriMap[dynamicDep];
263
+ imports[dynamicDep] = uri2;
264
+ }
257
265
  }
258
266
  }
259
267
  }
@@ -302,28 +302,31 @@ function addExternalScriptNonce(def, nonce) {
302
302
  def.nonce = nonce;
303
303
  }
304
304
  }
305
+ function findAndApplyMatchingPattern(matchPatterns, path, pattern, assetRef, assetConfig) {
306
+ for (const filePattern of matchPatterns) {
307
+ const regex = new RegExp(filePattern);
308
+ if (regex.test(path)) {
309
+ if (pattern.dependent) {
310
+ assetConfig[pattern.dependent.value] = pattern.dependent.attributes;
311
+ }
312
+ assetConfig[path] = pattern.attributes || {};
313
+ if (assetRef.integrity) {
314
+ assetConfig[path].integrity = assetRef.integrity;
315
+ }
316
+ return true;
317
+ }
318
+ }
319
+ return false;
320
+ }
305
321
  function generateLinkHeaders(assets, patterns) {
306
322
  const assetConfig = {};
307
323
  for (const assetRef of assets) {
308
324
  const path = assetRef.override?.uri || assetRef.url;
309
- let matched = null;
310
325
  for (const pattern of patterns) {
311
326
  const {match} = pattern;
312
327
  const matchPatterns = Array.isArray(match) ? match : [match];
313
- for (const filePattern of matchPatterns) {
314
- const regex = new RegExp(filePattern);
315
- if (regex.test(path)) {
316
- matched = pattern.attributes || {};
317
- break;
318
- }
319
- }
320
- if (matched)
328
+ if (findAndApplyMatchingPattern(matchPatterns, path, pattern, assetRef, assetConfig)) {
321
329
  break;
322
- }
323
- if (matched) {
324
- assetConfig[path] = matched;
325
- if (assetRef.integrity) {
326
- assetConfig[path].integrity = assetRef.integrity;
327
330
  }
328
331
  }
329
332
  }
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import { kebabCaseToModuleSpecifier, getModuleGraphs, GraphDepth, getModuleUriPrefix, explodeSpecifier, isBundler, getHydrateDirective, isGroupie, isExternalSpecifier, isLocalDev, isLambdaEnv, } from '@lwrjs/shared-utils';
2
+ import { kebabCaseToModuleSpecifier, getModuleGraphs, GraphDepth, getModuleUriPrefix, explodeSpecifier, isBundler, getHydrateDirective, isGroupie, isExternalSpecifier, isLocalDev, isLambdaEnv, isMrtBundle, } from '@lwrjs/shared-utils';
3
3
  import { AppResourceEnum, getAppSpecifier } from '@lwrjs/app-service/identity';
4
4
  import { addExternalScriptNonce, generateHtmlTag, getModuleResource, getModuleResourceByUri, getViewNonce, getModuleGraphCacheKey, } from '../utils.js';
5
5
  import { flattenCustomElements, getBundleIntegrity, getViewBootstrapConfigurationResource, getViewHmrConfigurationResource, } from './utils.js';
@@ -64,7 +64,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
64
64
  }, } = view;
65
65
  const defRegistry = bundle ? moduleBundler : moduleRegistry;
66
66
  const depth = isAMD
67
- ? { static: GraphDepth.ALL, dynamic: 1 }
67
+ ? { static: GraphDepth.ALL, dynamic: isMrtBundle() ? 50 : 1 }
68
68
  : { static: GraphDepth.NONE, dynamic: 0 };
69
69
  if (isAMD) {
70
70
  depth.includeId = includeIdFactory(bundleConfig);
@@ -202,7 +202,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
202
202
  const uri = getPreloadUri(depSpecifier, bootstrapModuleGraph.uriMap);
203
203
  if (uri) {
204
204
  const integrity = getBundleIntegrity(bootstrapModuleGraph, depSpecifier);
205
- setPreloadModulesMeta(depSpecifier, uri, integrity, groups, viewPreloads);
205
+ const depDef = bootstrapModuleGraph.linkedDefinitions[depSpecifier];
206
+ setPreloadModulesMeta(depSpecifier, uri, integrity, groups, viewPreloads, depDef?.bundleRecord?.includedModules);
206
207
  }
207
208
  }
208
209
  // PRELOAD configured preloadModules as preloaded script resources
@@ -217,27 +218,30 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
217
218
  requiredAmdModules.push(versionedSpecifier);
218
219
  // AMD ADD bootstrap module uri addressability
219
220
  imports[versionedSpecifier] = uri;
220
- // PRELOAD bootstrap module static deps as link resource
221
- for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
222
- const uri = bootstrapModuleGraph.uriMap[staticDep];
223
- // AMD ADD static module dep uri addressability
224
- imports[staticDep] = uri;
225
- // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
226
- if (services?.length) {
227
- requiredAmdModules.push(staticDep);
228
- }
229
- }
230
- // AMD Add import mappings for known dynamic imports
231
- for (const dynamicDep of bootstrapModuleGraph.graphs[0].dynamicRefs) {
232
- const uri = bootstrapModuleGraph.uriMap[dynamicDep];
233
- if (uri) {
234
- imports[dynamicDep] = uri;
221
+ const levels = isMrtBundle() ? bootstrapModuleGraph.graphs.length : 1;
222
+ for (let i = 0; i < levels; i++) {
223
+ // PRELOAD bootstrap module static deps as link resource
224
+ for (const staticDep of bootstrapModuleGraph.graphs[i].static) {
225
+ const uri = bootstrapModuleGraph.uriMap[staticDep];
226
+ // AMD ADD static module dep uri addressability
227
+ imports[staticDep] = uri;
228
+ // ADD bootstrap module static deps to requiredAmdModules if services, otherwise preloadModules
229
+ if (services?.length && i === 0) {
230
+ requiredAmdModules.push(staticDep);
231
+ }
235
232
  }
236
- else {
237
- logger.warn({
238
- label: `view-registry`,
239
- message: `Skipping unknown dynamic import: ${dynamicDep}`,
240
- });
233
+ // AMD Add import mappings for known dynamic imports
234
+ for (const dynamicDep of bootstrapModuleGraph.graphs[i].dynamicRefs) {
235
+ const uri = bootstrapModuleGraph.uriMap[dynamicDep];
236
+ if (uri) {
237
+ imports[dynamicDep] = uri;
238
+ }
239
+ else {
240
+ logger.warn({
241
+ label: `view-registry`,
242
+ message: `Skipping unknown dynamic import: ${dynamicDep}`,
243
+ });
244
+ }
241
245
  }
242
246
  }
243
247
  }
@@ -276,7 +280,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
276
280
  const depUri = getPreloadUri(depSpecifier, graph.uriMap);
277
281
  if (depUri) {
278
282
  const integrity = getBundleIntegrity(graph, depSpecifier);
279
- setPreloadModulesMeta(depSpecifier, depUri, integrity, groups, viewPreloads);
283
+ const depDef = graph.linkedDefinitions[depSpecifier];
284
+ setPreloadModulesMeta(depSpecifier, depUri, integrity, groups, viewPreloads, depDef?.bundleRecord?.includedModules);
280
285
  }
281
286
  }
282
287
  }
@@ -284,15 +289,18 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
284
289
  rootComponents.push(specifier);
285
290
  imports[specifier] = uri;
286
291
  if (isAMD) {
287
- for (const staticDep of graph.graphs[0].static) {
288
- const uri = graph.uriMap[staticDep];
289
- // AMD ADD static module dep uri addressability
290
- imports[staticDep] = uri;
291
- }
292
- // AMD ADD dynamic imports module dep uri addressability
293
- for (const dynamicDep of graph.graphs[0].dynamicRefs) {
294
- const uri = graph.uriMap[dynamicDep];
295
- imports[dynamicDep] = uri;
292
+ const levels = isMrtBundle() ? graph.graphs.length : 1;
293
+ for (let i = 0; i < levels; i++) {
294
+ for (const staticDep of graph.graphs[i].static) {
295
+ const uri = graph.uriMap[staticDep];
296
+ // AMD ADD static module dep uri addressability
297
+ imports[staticDep] = uri;
298
+ }
299
+ // AMD ADD dynamic imports module dep uri addressability
300
+ for (const dynamicDep of graph.graphs[i].dynamicRefs) {
301
+ const uri = graph.uriMap[dynamicDep];
302
+ imports[dynamicDep] = uri;
303
+ }
296
304
  }
297
305
  }
298
306
  }
package/build/es/utils.js CHANGED
@@ -288,30 +288,33 @@ export function addExternalScriptNonce(def, nonce) {
288
288
  def.nonce = nonce;
289
289
  }
290
290
  }
291
+ function findAndApplyMatchingPattern(matchPatterns, path, pattern, assetRef, assetConfig) {
292
+ for (const filePattern of matchPatterns) {
293
+ const regex = new RegExp(filePattern);
294
+ if (regex.test(path)) {
295
+ if (pattern.dependent) {
296
+ assetConfig[pattern.dependent.value] = pattern.dependent.attributes;
297
+ }
298
+ assetConfig[path] = pattern.attributes || {};
299
+ if (assetRef.integrity) {
300
+ // always add the integrity attribute, if it exists
301
+ assetConfig[path].integrity = assetRef.integrity;
302
+ }
303
+ return true;
304
+ }
305
+ }
306
+ return false;
307
+ }
291
308
  export function generateLinkHeaders(assets, patterns) {
292
309
  // store each Path's config in this config
293
310
  const assetConfig = {};
294
311
  for (const assetRef of assets) {
295
312
  const path = assetRef.override?.uri || assetRef.url;
296
- let matched = null;
297
313
  for (const pattern of patterns) {
298
314
  const { match } = pattern;
299
315
  const matchPatterns = Array.isArray(match) ? match : [match];
300
- for (const filePattern of matchPatterns) {
301
- const regex = new RegExp(filePattern);
302
- if (regex.test(path)) {
303
- matched = pattern.attributes || {};
304
- break;
305
- }
306
- }
307
- if (matched)
316
+ if (findAndApplyMatchingPattern(matchPatterns, path, pattern, assetRef, assetConfig)) {
308
317
  break;
309
- }
310
- if (matched) {
311
- assetConfig[path] = matched;
312
- if (assetRef.integrity) {
313
- // always add the integrity attribute, if it exists
314
- assetConfig[path].integrity = assetRef.integrity;
315
318
  }
316
319
  }
317
320
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.17.6",
7
+ "version": "0.17.8",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,15 +33,15 @@
33
33
  "build": "tsc -b"
34
34
  },
35
35
  "dependencies": {
36
- "@lwrjs/app-service": "0.17.6",
37
- "@lwrjs/config": "0.17.6",
38
- "@lwrjs/diagnostics": "0.17.6",
39
- "@lwrjs/instrumentation": "0.17.6",
40
- "@lwrjs/shared-utils": "0.17.6",
36
+ "@lwrjs/app-service": "0.17.8",
37
+ "@lwrjs/config": "0.17.8",
38
+ "@lwrjs/diagnostics": "0.17.8",
39
+ "@lwrjs/instrumentation": "0.17.8",
40
+ "@lwrjs/shared-utils": "0.17.8",
41
41
  "lru-cache": "^10.4.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@lwrjs/types": "0.17.6"
44
+ "@lwrjs/types": "0.17.8"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=20.0.0"
@@ -49,5 +49,5 @@
49
49
  "volta": {
50
50
  "extends": "../../../package.json"
51
51
  },
52
- "gitHead": "7d557651747a0f08a96deb074c7cd1bb6752488c"
52
+ "gitHead": "a8b449fc6fc78841913b6e36bfbc04e3336541a7"
53
53
  }