@lwrjs/view-registry 0.17.6 → 0.17.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.
@@ -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
  }
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.7",
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.7",
37
+ "@lwrjs/config": "0.17.7",
38
+ "@lwrjs/diagnostics": "0.17.7",
39
+ "@lwrjs/instrumentation": "0.17.7",
40
+ "@lwrjs/shared-utils": "0.17.7",
41
41
  "lru-cache": "^10.4.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@lwrjs/types": "0.17.6"
44
+ "@lwrjs/types": "0.17.7"
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": "5084f815d7f7f9ac0b9e72f0250f7e9364bd9e54"
53
53
  }