@lwrjs/shared-utils 0.12.0-alpha.2 → 0.12.0-alpha.20

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
@@ -8,8 +8,11 @@ var __export = (target, all) => {
8
8
  // packages/@lwrjs/shared-utils/src/env.ts
9
9
  __markAsModule(exports);
10
10
  __export(exports, {
11
+ REQUEST_DEPTH_HEADER: () => REQUEST_DEPTH_HEADER,
12
+ REQUEST_DEPTH_KEY: () => REQUEST_DEPTH_KEY,
11
13
  buildEnvironmentContext: () => buildEnvironmentContext,
12
- getFeatureFlags: () => getFeatureFlags
14
+ getFeatureFlags: () => getFeatureFlags,
15
+ parseRequestDepthHeader: () => parseRequestDepthHeader
13
16
  });
14
17
  function getFeatureFlags() {
15
18
  return {
@@ -19,7 +22,7 @@ function getFeatureFlags() {
19
22
  SSR_STATIC_BUNDLES: process.env.SSR_STATIC_BUNDLES !== void 0 && process.env.SSR_STATIC_BUNDLES.toLowerCase() === "true" ? true : false,
20
23
  SSR_WITH_CSR_FALLBACK: process.env.SSR_WITH_CSR_FALLBACK !== void 0 && process.env.SSR_WITH_CSR_FALLBACK.toLowerCase() === "true" ? true : false,
21
24
  EXPERIMENTAL_UNVERSIONED_ALIASES: process.env.EXPERIMENTAL_UNVERSIONED_ALIASES !== void 0 && process.env.EXPERIMENTAL_UNVERSIONED_ALIASES.toLowerCase() === "true" ? true : false,
22
- LWR_TRACING: process.env.LWR_TRACING !== void 0 && process.env.LWR_TRACING.toLowerCase() !== "off" ? true : false
25
+ LWR_TRACING: process.env.LWR_TRACING !== void 0 && process.env.LWR_TRACING.toLowerCase() !== "off" ? process.env.LWR_TRACING : false
23
26
  };
24
27
  }
25
28
  function buildEnvironmentContext(runtimeParams) {
@@ -34,3 +37,27 @@ function buildEnvironmentContext(runtimeParams) {
34
37
  uiBasePath
35
38
  };
36
39
  }
40
+ var REQUEST_DEPTH_HEADER = "X-SFDC-Request-Depth";
41
+ var REQUEST_DEPTH_KEY = REQUEST_DEPTH_HEADER.toLowerCase();
42
+ function parseRequestDepthHeader(headers = {}) {
43
+ let maxDepth = 0;
44
+ const value = headers && headers[REQUEST_DEPTH_KEY];
45
+ if (value) {
46
+ if (Array.isArray(value)) {
47
+ for (const depth of value) {
48
+ if (typeof depth === "string") {
49
+ const depthValue = parseInt(depth, 10);
50
+ if (!isNaN(depthValue) && depthValue > maxDepth) {
51
+ maxDepth = depthValue;
52
+ }
53
+ }
54
+ }
55
+ } else if (typeof value === "string") {
56
+ const depth = parseInt(value, 10);
57
+ if (!isNaN(depth) && depth > maxDepth) {
58
+ maxDepth = depth;
59
+ }
60
+ }
61
+ }
62
+ return maxDepth;
63
+ }
@@ -80,6 +80,7 @@ var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
80
80
  services: [],
81
81
  configAsSrc: false,
82
82
  ssr: false,
83
+ preloadData: false,
83
84
  mixedMode: false,
84
85
  module: void 0,
85
86
  preloadModules: []
@@ -113,19 +113,11 @@ function getViewUri(routePath, basePath, locale, i18n) {
113
113
  url = import_path.default.join(url, `/${locale}`);
114
114
  }
115
115
  url = import_path.default.join(url, routePath);
116
- if (i18n.uriPattern === "query-param" && locale !== i18n.defaultLocale) {
117
- url = addQueryParamToAbsoluteURI(url, "locale", locale);
118
- }
119
116
  return url;
120
117
  }
121
118
  function isURL(uri) {
122
119
  return /^https?:\/\//i.test(uri);
123
120
  }
124
- function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
125
- const url = new URL(absoluteURI, "http://example.com");
126
- url.searchParams.set(paramName, paramValue);
127
- return url.pathname + url.search;
128
- }
129
121
  function sortedQueryParamString(query) {
130
122
  if (!query) {
131
123
  return "";
package/build/es/env.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import type { EnvironmentContext, FeatureFlags, RuntimeParams } from '@lwrjs/types';
1
+ import type { EnvironmentContext, FeatureFlags, Headers, RuntimeParams } from '@lwrjs/types';
2
2
  export declare function getFeatureFlags(): FeatureFlags;
3
3
  /**
4
4
  * Create a serializable context for the lwr/environment variable
5
5
  */
6
6
  export declare function buildEnvironmentContext(runtimeParams: RuntimeParams): EnvironmentContext;
7
+ export declare const REQUEST_DEPTH_HEADER = "X-SFDC-Request-Depth";
8
+ export declare const REQUEST_DEPTH_KEY: string;
9
+ export declare function parseRequestDepthHeader(headers?: Headers): number;
7
10
  //# sourceMappingURL=env.d.ts.map
package/build/es/env.js CHANGED
@@ -10,7 +10,7 @@ export function getFeatureFlags() {
10
10
  LEGACY_LOADER: process.env.LEGACY_LOADER !== undefined && process.env.LEGACY_LOADER.toLowerCase() === 'true'
11
11
  ? true
12
12
  : false,
13
- // Should we use a js worker for SSR, sand-boxing = false (use locker for ssr sand-boxing)
13
+ // Set true to use worker_threads for SSR sandboxes
14
14
  SSR_SANDBOX_WORKER: process.env.SSR_SANDBOX_WORKER !== undefined &&
15
15
  process.env.SSR_SANDBOX_WORKER.toLowerCase() === 'true'
16
16
  ? true
@@ -31,7 +31,7 @@ export function getFeatureFlags() {
31
31
  ? true
32
32
  : false,
33
33
  LWR_TRACING: process.env.LWR_TRACING !== undefined && process.env.LWR_TRACING.toLowerCase() !== 'off'
34
- ? true
34
+ ? process.env.LWR_TRACING
35
35
  : false,
36
36
  };
37
37
  }
@@ -54,4 +54,29 @@ export function buildEnvironmentContext(runtimeParams) {
54
54
  uiBasePath,
55
55
  };
56
56
  }
57
+ export const REQUEST_DEPTH_HEADER = 'X-SFDC-Request-Depth';
58
+ export const REQUEST_DEPTH_KEY = REQUEST_DEPTH_HEADER.toLowerCase();
59
+ export function parseRequestDepthHeader(headers = {}) {
60
+ let maxDepth = 0;
61
+ const value = headers && headers[REQUEST_DEPTH_KEY];
62
+ if (value) {
63
+ if (Array.isArray(value)) {
64
+ for (const depth of value) {
65
+ if (typeof depth === 'string') {
66
+ const depthValue = parseInt(depth, 10);
67
+ if (!isNaN(depthValue) && depthValue > maxDepth) {
68
+ maxDepth = depthValue;
69
+ }
70
+ }
71
+ }
72
+ }
73
+ else if (typeof value === 'string') {
74
+ const depth = parseInt(value, 10);
75
+ if (!isNaN(depth) && depth > maxDepth) {
76
+ maxDepth = depth;
77
+ }
78
+ }
79
+ }
80
+ return maxDepth;
81
+ }
57
82
  //# sourceMappingURL=env.js.map
@@ -22,6 +22,7 @@ export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
22
22
  services: [],
23
23
  configAsSrc: false,
24
24
  ssr: false,
25
+ preloadData: false,
25
26
  mixedMode: false,
26
27
  module: undefined,
27
28
  preloadModules: [],
package/build/es/urls.js CHANGED
@@ -106,9 +106,6 @@ export function getViewUri(routePath, basePath, locale, i18n) {
106
106
  url = path.join(url, `/${locale}`);
107
107
  }
108
108
  url = path.join(url, routePath);
109
- if (i18n.uriPattern === 'query-param' && locale !== i18n.defaultLocale) {
110
- url = addQueryParamToAbsoluteURI(url, 'locale', locale);
111
- }
112
109
  return url;
113
110
  }
114
111
  /**
@@ -117,14 +114,6 @@ export function getViewUri(routePath, basePath, locale, i18n) {
117
114
  export function isURL(uri) {
118
115
  return /^https?:\/\//i.test(uri);
119
116
  }
120
- function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
121
- // Use a dummy domain for parsing
122
- const url = new URL(absoluteURI, 'http://example.com');
123
- // Add the query parameter
124
- url.searchParams.set(paramName, paramValue);
125
- // Get the modified URI with the query parameter
126
- return url.pathname + url.search;
127
- }
128
117
  function sortedQueryParamString(query) {
129
118
  if (!query) {
130
119
  return '';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.2",
7
+ "version": "0.12.0-alpha.20",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,10 +37,10 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.12.0-alpha.2",
40
+ "@lwrjs/diagnostics": "0.12.0-alpha.20",
41
41
  "es-module-lexer": "^1.3.0",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
- "magic-string": "^0.30.0",
43
+ "magic-string": "^0.30.7",
44
44
  "mime-types": "^2.1.33",
45
45
  "ms": "^2.1.3",
46
46
  "parse5-sax-parser": "^6.0.1",
@@ -50,12 +50,12 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.12.0-alpha.2",
53
+ "@lwrjs/types": "0.12.0-alpha.20",
54
54
  "@types/mime-types": "2.1.1",
55
55
  "@types/path-to-regexp": "^1.7.0"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=18.0.0"
59
59
  },
60
- "gitHead": "586a2aa659882483af9249dc3db7fe07bc842a25"
60
+ "gitHead": "ae1793e34eaf4e9b97996d7aea9031908b23a13a"
61
61
  }