@lwrjs/view-registry 0.15.0-alpha.34 → 0.15.0-alpha.36

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.
@@ -318,14 +318,14 @@ var LwrViewRegistry = class {
318
318
  metadata: renderedViewMetadata,
319
319
  compiledView: {immutable = true}
320
320
  } = renderedView;
321
- const {linkedMetadata, stringBuilder} = await (0, import_instrumentation.getTracer)().trace({
321
+ const {linkedMetadata, stringBuilder} = (0, import_instrumentation.getTracer)().trace({
322
322
  name: import_instrumentation.ViewSpan.ParseView,
323
323
  attributes: {
324
324
  view: view.id,
325
325
  ssr: view.bootstrap?.ssr === true
326
326
  }
327
- }, async () => {
328
- const linkedMetadata2 = skipMetadataCollection ? renderedViewMetadata : await (0, import_shared_utils.extractMetadataFromHtml)(renderedViewContent, renderedViewMetadata, this.globalConfig);
327
+ }, () => {
328
+ const linkedMetadata2 = skipMetadataCollection ? renderedViewMetadata : (0, import_shared_utils.extractMetadataFromHtml)(renderedViewContent, renderedViewMetadata, this.globalConfig);
329
329
  const stringBuilder2 = (0, import_shared_utils.createStringBuilder)(renderedViewContent);
330
330
  return {linkedMetadata: linkedMetadata2, stringBuilder: stringBuilder2};
331
331
  });
@@ -46,6 +46,7 @@ var import_path = __toModule(require("path"));
46
46
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
47
47
  var import_identity = __toModule(require("@lwrjs/app-service/identity"));
48
48
  var import_crypto = __toModule(require("crypto"));
49
+ var import_minimatch = __toModule(require("minimatch"));
49
50
  function generateExternalStyle(src) {
50
51
  return `<link rel="stylesheet" href="${src}">`;
51
52
  }
@@ -305,14 +306,24 @@ function addExternalScriptNonce(def, nonce) {
305
306
  }
306
307
  function generateLinkHeaders(assets, patterns) {
307
308
  const assetConfig = {};
308
- for (let i = 0; i < patterns.length; i++) {
309
- const pattern = patterns[i].match;
310
- assets.forEach((asset) => {
311
- const path = (asset.override?.uri || asset.url).split("?")[0];
312
- if (typeof pattern === "string" && path.endsWith(pattern) || typeof pattern === "object" && pattern.some((match) => path.endsWith(match))) {
313
- assetConfig[path] = patterns[i].attributes;
309
+ for (const assetRef of assets) {
310
+ const path = (assetRef.override?.uri || assetRef.url).split("?")[0];
311
+ let matched = null;
312
+ for (const pattern of patterns) {
313
+ const {match} = pattern;
314
+ const matchPatterns = Array.isArray(match) ? match : [match];
315
+ for (const filePattern of matchPatterns) {
316
+ if ((0, import_minimatch.minimatch)(path, filePattern)) {
317
+ matched = pattern.attributes;
318
+ break;
319
+ }
314
320
  }
315
- });
321
+ if (matched)
322
+ break;
323
+ }
324
+ if (matched) {
325
+ assetConfig[path] = matched;
326
+ }
316
327
  }
317
328
  return Object.keys(assetConfig).reduce((linkHeader, path) => {
318
329
  linkHeader = `${linkHeader ? linkHeader + ", " : ""}<${path}>`;
package/build/es/index.js CHANGED
@@ -342,16 +342,16 @@ export class LwrViewRegistry {
342
342
  const runtimeEnvironment = { ...runtimeEnv, immutableAssets: freezeAssets };
343
343
  // normalize/extract metadata
344
344
  const { renderedView: renderedViewContent, metadata: renderedViewMetadata, compiledView: { immutable = true }, } = renderedView;
345
- const { linkedMetadata, stringBuilder } = await getTracer().trace({
345
+ const { linkedMetadata, stringBuilder } = getTracer().trace({
346
346
  name: ViewSpan.ParseView,
347
347
  attributes: {
348
348
  view: view.id,
349
349
  ssr: view.bootstrap?.ssr === true,
350
350
  },
351
- }, async () => {
351
+ }, () => {
352
352
  const linkedMetadata = skipMetadataCollection
353
353
  ? renderedViewMetadata
354
- : await extractMetadataFromHtml(renderedViewContent, renderedViewMetadata, this.globalConfig);
354
+ : extractMetadataFromHtml(renderedViewContent, renderedViewMetadata, this.globalConfig);
355
355
  const stringBuilder = createStringBuilder(renderedViewContent);
356
356
  return { linkedMetadata, stringBuilder };
357
357
  });
package/build/es/utils.js CHANGED
@@ -2,6 +2,7 @@ import { basename, extname } from 'path';
2
2
  import { explodeSpecifier, getMappingUriPrefix, getSpecifier, getClientBootstrapConfigurationUri, mimeLookup, DEFAULT_TITLE, streamToString, getFeatureFlags, getCacheKeyFromJson, } from '@lwrjs/shared-utils';
3
3
  import { AppResourceEnum, getAppSpecifier, ResourceIdentityTypes, } from '@lwrjs/app-service/identity';
4
4
  import crypto from 'crypto';
5
+ import { minimatch } from 'minimatch';
5
6
  function generateExternalStyle(src) {
6
7
  return `<link rel="stylesheet" href="${src}">`;
7
8
  }
@@ -291,16 +292,24 @@ export function addExternalScriptNonce(def, nonce) {
291
292
  export function generateLinkHeaders(assets, patterns) {
292
293
  // store each Path's config in this config
293
294
  const assetConfig = {};
294
- // Iterate through the patterns to filter the file paths and populate assetConfig
295
- for (let i = 0; i < patterns.length; i++) {
296
- const pattern = patterns[i].match;
297
- assets.forEach((asset) => {
298
- const path = (asset.override?.uri || asset.url).split('?')[0];
299
- if ((typeof pattern === 'string' && path.endsWith(pattern)) ||
300
- (typeof pattern === 'object' && pattern.some((match) => path.endsWith(match)))) {
301
- assetConfig[path] = patterns[i].attributes;
295
+ for (const assetRef of assets) {
296
+ const path = (assetRef.override?.uri || assetRef.url).split('?')[0];
297
+ let matched = null;
298
+ for (const pattern of patterns) {
299
+ const { match } = pattern;
300
+ const matchPatterns = Array.isArray(match) ? match : [match];
301
+ for (const filePattern of matchPatterns) {
302
+ if (minimatch(path, filePattern)) {
303
+ matched = pattern.attributes;
304
+ break;
305
+ }
302
306
  }
303
- });
307
+ if (matched)
308
+ break;
309
+ }
310
+ if (matched) {
311
+ assetConfig[path] = matched;
312
+ }
304
313
  }
305
314
  // Use the assetConfig to construct the Link Header
306
315
  return Object.keys(assetConfig).reduce((linkHeader, path) => {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.15.0-alpha.34",
7
+ "version": "0.15.0-alpha.36",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,14 +33,15 @@
33
33
  "build": "tsc -b"
34
34
  },
35
35
  "dependencies": {
36
- "@lwrjs/app-service": "0.15.0-alpha.34",
37
- "@lwrjs/diagnostics": "0.15.0-alpha.34",
38
- "@lwrjs/instrumentation": "0.15.0-alpha.34",
39
- "@lwrjs/shared-utils": "0.15.0-alpha.34",
40
- "lru-cache": "^10.4.3"
36
+ "@lwrjs/app-service": "0.15.0-alpha.36",
37
+ "@lwrjs/diagnostics": "0.15.0-alpha.36",
38
+ "@lwrjs/instrumentation": "0.15.0-alpha.36",
39
+ "@lwrjs/shared-utils": "0.15.0-alpha.36",
40
+ "lru-cache": "^10.4.3",
41
+ "minimatch": "^10.0.1"
41
42
  },
42
43
  "devDependencies": {
43
- "@lwrjs/types": "0.15.0-alpha.34"
44
+ "@lwrjs/types": "0.15.0-alpha.36"
44
45
  },
45
46
  "engines": {
46
47
  "node": ">=18.0.0"
@@ -48,5 +49,5 @@
48
49
  "volta": {
49
50
  "extends": "../../../package.json"
50
51
  },
51
- "gitHead": "6b9d8e0b50272e646d177e4bda3eec2b2a253fbb"
52
+ "gitHead": "325f5a8d06e1af07795f108e32c8300c06e62aa3"
52
53
  }