@lwrjs/shared-utils 0.13.0-alpha.20 → 0.13.0-alpha.22

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.
package/build/cjs/env.cjs CHANGED
@@ -24,7 +24,9 @@ function getFeatureFlags() {
24
24
  SSR_WITH_CSR_FALLBACK: process.env.SSR_WITH_CSR_FALLBACK !== void 0 && process.env.SSR_WITH_CSR_FALLBACK.toLowerCase() === "true" ? true : false,
25
25
  EXPERIMENTAL_UNVERSIONED_ALIASES: process.env.EXPERIMENTAL_UNVERSIONED_ALIASES !== void 0 && process.env.EXPERIMENTAL_UNVERSIONED_ALIASES.toLowerCase() === "true" ? true : false,
26
26
  LWR_TRACING: process.env.LWR_TRACING !== void 0 && process.env.LWR_TRACING.toLowerCase() !== "off" ? process.env.LWR_TRACING : false,
27
- ENABLE_NONCE: process.env.ENABLE_NONCE !== void 0 && process.env.ENABLE_NONCE.toLowerCase() === "true" ? true : false
27
+ ENABLE_NONCE: process.env.ENABLE_NONCE !== void 0 && process.env.ENABLE_NONCE.toLowerCase() === "true" ? true : false,
28
+ DISABLE_LOADER_CACHE: process.env.DISABLE_LOADER_CACHE !== void 0 && process.env.DISABLE_LOADER_CACHE.toLowerCase() === "true" ? true : false,
29
+ MAX_VIEW_CACHE_TTL: process.env.MAX_VIEW_CACHE_TTL
28
30
  };
29
31
  }
30
32
  function isLambdaEnv() {
@@ -66,14 +66,21 @@ async function serializeModuleToJson(code = "", {
66
66
  function replaceStringFromLocation(src, {startOffset, endOffset}, replaceValue) {
67
67
  return src.substr(0, startOffset) + replaceValue + src.substr(endOffset, src.length);
68
68
  }
69
- function shortestTtl(newTtl, oldTtl) {
69
+ function shortestTtl(newTtl, oldTtl, maxTtl) {
70
70
  if (newTtl === void 0 && oldTtl === void 0)
71
71
  return void 0;
72
72
  const newSeconds = typeof newTtl === "string" ? (0, import_ms.default)(newTtl) / 1e3 : newTtl;
73
73
  const oldSeconds = typeof oldTtl === "string" ? (0, import_ms.default)(oldTtl) / 1e3 : oldTtl;
74
- if (newSeconds === void 0)
75
- return oldSeconds;
76
- if (oldSeconds === void 0)
77
- return newSeconds;
78
- return newSeconds < oldSeconds ? newSeconds : oldSeconds;
74
+ const maxSeconds = typeof maxTtl === "string" ? (0, import_ms.default)(maxTtl) / 1e3 : maxTtl;
75
+ let shortest = void 0;
76
+ if (newSeconds !== void 0 && (shortest === void 0 || newSeconds < shortest)) {
77
+ shortest = newSeconds;
78
+ }
79
+ if (oldSeconds !== void 0 && (shortest === void 0 || oldSeconds < shortest)) {
80
+ shortest = oldSeconds;
81
+ }
82
+ if (maxSeconds !== void 0 && (shortest === void 0 || maxSeconds < shortest)) {
83
+ shortest = maxSeconds;
84
+ }
85
+ return shortest;
79
86
  }
package/build/es/env.js CHANGED
@@ -31,6 +31,11 @@ export function getFeatureFlags() {
31
31
  ENABLE_NONCE: process.env.ENABLE_NONCE !== undefined && process.env.ENABLE_NONCE.toLowerCase() === 'true'
32
32
  ? true
33
33
  : false,
34
+ DISABLE_LOADER_CACHE: process.env.DISABLE_LOADER_CACHE !== undefined &&
35
+ process.env.DISABLE_LOADER_CACHE.toLowerCase() === 'true'
36
+ ? true
37
+ : false,
38
+ MAX_VIEW_CACHE_TTL: process.env.MAX_VIEW_CACHE_TTL,
34
39
  };
35
40
  }
36
41
  /**
@@ -25,5 +25,5 @@ export declare function replaceStringFromLocation(src: string, { startOffset, en
25
25
  * @param oldTtl - the current shortest TTL (if it exists)
26
26
  * @returns - the shorter of the two TTLs IN SECONDS, undefined if both TTLs are missing
27
27
  */
28
- export declare function shortestTtl(newTtl?: string | number, oldTtl?: string | number): number | undefined;
28
+ export declare function shortestTtl(newTtl?: string | number, oldTtl?: string | number, maxTtl?: string | number): number | undefined;
29
29
  //# sourceMappingURL=serialize.d.ts.map
@@ -49,15 +49,22 @@ export function replaceStringFromLocation(src, { startOffset, endOffset }, repla
49
49
  * @param oldTtl - the current shortest TTL (if it exists)
50
50
  * @returns - the shorter of the two TTLs IN SECONDS, undefined if both TTLs are missing
51
51
  */
52
- export function shortestTtl(newTtl, oldTtl) {
52
+ export function shortestTtl(newTtl, oldTtl, maxTtl) {
53
53
  if (newTtl === undefined && oldTtl === undefined)
54
54
  return undefined;
55
55
  const newSeconds = typeof newTtl === 'string' ? ms(newTtl) / 1000 : newTtl;
56
56
  const oldSeconds = typeof oldTtl === 'string' ? ms(oldTtl) / 1000 : oldTtl;
57
- if (newSeconds === undefined)
58
- return oldSeconds;
59
- if (oldSeconds === undefined)
60
- return newSeconds;
61
- return newSeconds < oldSeconds ? newSeconds : oldSeconds;
57
+ const maxSeconds = typeof maxTtl === 'string' ? ms(maxTtl) / 1000 : maxTtl;
58
+ let shortest = undefined;
59
+ if (newSeconds !== undefined && (shortest === undefined || newSeconds < shortest)) {
60
+ shortest = newSeconds;
61
+ }
62
+ if (oldSeconds !== undefined && (shortest === undefined || oldSeconds < shortest)) {
63
+ shortest = oldSeconds;
64
+ }
65
+ if (maxSeconds !== undefined && (shortest === undefined || maxSeconds < shortest)) {
66
+ shortest = maxSeconds;
67
+ }
68
+ return shortest;
62
69
  }
63
70
  //# sourceMappingURL=serialize.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.0-alpha.20",
7
+ "version": "0.13.0-alpha.22",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.13.0-alpha.20",
40
+ "@lwrjs/diagnostics": "0.13.0-alpha.22",
41
41
  "es-module-lexer": "^1.5.3",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
@@ -50,12 +50,12 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.13.0-alpha.20",
53
+ "@lwrjs/types": "0.13.0-alpha.22",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=18.0.0"
59
59
  },
60
- "gitHead": "2165594f2871f4f20a4083394e4372e67d1fa1b5"
60
+ "gitHead": "a5af2e1674c93c9c0d4c250edba8f11302f33b70"
61
61
  }