@lwrjs/shared-utils 0.12.0-alpha.0 → 0.12.0-alpha.10

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
@@ -15,11 +15,11 @@ function getFeatureFlags() {
15
15
  return {
16
16
  ASSETS_ON_LAMBDA: process.env.ASSETS_ON_LAMBDA !== void 0 && process.env.ASSETS_ON_LAMBDA.toLowerCase() === "true" ? true : false,
17
17
  LEGACY_LOADER: process.env.LEGACY_LOADER !== void 0 && process.env.LEGACY_LOADER.toLowerCase() === "true" ? true : false,
18
- SSR_SANDBOX_WORKER: process.env.SSR_SANDBOX_WORKER !== void 0 && process.env.SSR_SANDBOX_WORKER.toLowerCase() === "true" ? true : false,
18
+ SSR_SANDBOX_VM: process.env.SSR_SANDBOX_VM !== void 0 && process.env.SSR_SANDBOX_VM.toLowerCase() === "true" ? true : false,
19
19
  SSR_STATIC_BUNDLES: process.env.SSR_STATIC_BUNDLES !== void 0 && process.env.SSR_STATIC_BUNDLES.toLowerCase() === "true" ? true : false,
20
20
  SSR_WITH_CSR_FALLBACK: process.env.SSR_WITH_CSR_FALLBACK !== void 0 && process.env.SSR_WITH_CSR_FALLBACK.toLowerCase() === "true" ? true : false,
21
21
  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
22
+ LWR_TRACING: process.env.LWR_TRACING !== void 0 && process.env.LWR_TRACING.toLowerCase() !== "off" ? process.env.LWR_TRACING : false
23
23
  };
24
24
  }
25
25
  function buildEnvironmentContext(runtimeParams) {
@@ -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: []
@@ -39,7 +39,8 @@ var import_path = __toModule(require("path"));
39
39
  var CONFIG_SUFFIX = "/config.js";
40
40
  var SIGNATURE_SIGIL = "s";
41
41
  function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
42
- const encodeUrl = `-${encodeURIComponent(routeInfo.url)}-`;
42
+ const url = routeInfo.url + sortedQueryParamString(routeInfo.query);
43
+ const encodeUrl = `-${encodeURIComponent(url)}-`;
43
44
  const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
44
45
  const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : "";
45
46
  return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
@@ -112,16 +113,19 @@ function getViewUri(routePath, basePath, locale, i18n) {
112
113
  url = import_path.default.join(url, `/${locale}`);
113
114
  }
114
115
  url = import_path.default.join(url, routePath);
115
- if (i18n.uriPattern === "query-param" && locale !== i18n.defaultLocale) {
116
- url = addQueryParamToAbsoluteURI(url, "locale", locale);
117
- }
118
116
  return url;
119
117
  }
120
118
  function isURL(uri) {
121
119
  return /^https?:\/\//i.test(uri);
122
120
  }
123
- function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
124
- const url = new URL(absoluteURI, "http://example.com");
125
- url.searchParams.set(paramName, paramValue);
126
- return url.pathname + url.search;
121
+ function sortedQueryParamString(query) {
122
+ if (!query) {
123
+ return "";
124
+ }
125
+ const keys = Object.keys(query);
126
+ if (!keys || keys.length === 0) {
127
+ return "";
128
+ }
129
+ const sortedKeys = keys.sort();
130
+ return "?" + sortedKeys.map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`).join("&");
127
131
  }
package/build/es/env.js CHANGED
@@ -10,9 +10,8 @@ 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)
14
- SSR_SANDBOX_WORKER: process.env.SSR_SANDBOX_WORKER !== undefined &&
15
- process.env.SSR_SANDBOX_WORKER.toLowerCase() === 'true'
13
+ // Set true to use NODE:VM for SSR sandboxes
14
+ SSR_SANDBOX_VM: process.env.SSR_SANDBOX_VM !== undefined && process.env.SSR_SANDBOX_VM.toLowerCase() === 'true'
16
15
  ? true
17
16
  : false,
18
17
  // SSR should concatenate bundles, default = false
@@ -31,7 +30,7 @@ export function getFeatureFlags() {
31
30
  ? true
32
31
  : false,
33
32
  LWR_TRACING: process.env.LWR_TRACING !== undefined && process.env.LWR_TRACING.toLowerCase() !== 'off'
34
- ? true
33
+ ? process.env.LWR_TRACING
35
34
  : false,
36
35
  };
37
36
  }
@@ -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: [],
@@ -1,7 +1,8 @@
1
- import type { I18NConfig, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
1
+ import type { I18NConfig, RuntimeEnvironment, RuntimeParams, ViewRequestQs } from '@lwrjs/types';
2
2
  export declare function getClientBootstrapConfigurationUri(routeInfo: {
3
3
  id: string;
4
4
  url: string;
5
+ query?: ViewRequestQs;
5
6
  }, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): string;
6
7
  export declare function decodeViewPath(encodedViewPath: string): string;
7
8
  export declare function getClientBootstrapConfigurationUriPrefix(routeInfo: {
package/build/es/urls.js CHANGED
@@ -5,7 +5,8 @@ const SIGNATURE_SIGIL = 's';
5
5
  export function getClientBootstrapConfigurationUri(routeInfo, runtimeEnvironment, runtimeParams, signature) {
6
6
  // Add extra dashes around encoded path so when saved as static file leading and
7
7
  // trailing slashes are preserved as file path.
8
- const encodeUrl = `-${encodeURIComponent(routeInfo.url)}-`;
8
+ const url = routeInfo.url + sortedQueryParamString(routeInfo.query);
9
+ const encodeUrl = `-${encodeURIComponent(url)}-`;
9
10
  const configUrlPrefix = getClientBootstrapConfigurationUriPrefix(routeInfo, runtimeEnvironment, runtimeParams);
10
11
  const signatureSegment = signature ? `/${SIGNATURE_SIGIL}/${signature}` : '';
11
12
  return `${configUrlPrefix}/${encodeUrl}${signatureSegment}${CONFIG_SUFFIX}`;
@@ -105,9 +106,6 @@ export function getViewUri(routePath, basePath, locale, i18n) {
105
106
  url = path.join(url, `/${locale}`);
106
107
  }
107
108
  url = path.join(url, routePath);
108
- if (i18n.uriPattern === 'query-param' && locale !== i18n.defaultLocale) {
109
- url = addQueryParamToAbsoluteURI(url, 'locale', locale);
110
- }
111
109
  return url;
112
110
  }
113
111
  /**
@@ -116,12 +114,18 @@ export function getViewUri(routePath, basePath, locale, i18n) {
116
114
  export function isURL(uri) {
117
115
  return /^https?:\/\//i.test(uri);
118
116
  }
119
- function addQueryParamToAbsoluteURI(absoluteURI, paramName, paramValue) {
120
- // Use a dummy domain for parsing
121
- const url = new URL(absoluteURI, 'http://example.com');
122
- // Add the query parameter
123
- url.searchParams.set(paramName, paramValue);
124
- // Get the modified URI with the query parameter
125
- return url.pathname + url.search;
117
+ function sortedQueryParamString(query) {
118
+ if (!query) {
119
+ return '';
120
+ }
121
+ const keys = Object.keys(query);
122
+ if (!keys || keys.length === 0) {
123
+ return '';
124
+ }
125
+ const sortedKeys = keys.sort();
126
+ return ('?' +
127
+ sortedKeys
128
+ .map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
129
+ .join('&'));
126
130
  }
127
131
  //# sourceMappingURL=urls.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.0",
7
+ "version": "0.12.0-alpha.10",
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.12.0-alpha.0",
40
+ "@lwrjs/diagnostics": "0.12.0-alpha.10",
41
41
  "es-module-lexer": "^1.3.0",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.0",
@@ -45,17 +45,17 @@
45
45
  "ms": "^2.1.3",
46
46
  "parse5-sax-parser": "^6.0.1",
47
47
  "path-to-regexp": "^6.2.0",
48
- "resolve": "^1.22.1",
48
+ "resolve": "^1.22.8",
49
49
  "rollup": "^2.78.0",
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.12.0-alpha.0",
53
+ "@lwrjs/types": "0.12.0-alpha.10",
54
54
  "@types/mime-types": "2.1.1",
55
55
  "@types/path-to-regexp": "^1.7.0"
56
56
  },
57
57
  "engines": {
58
- "node": ">=16.0.0"
58
+ "node": ">=18.0.0"
59
59
  },
60
- "gitHead": "e79862bc238ededc3cf61f0d2c7d8120d1105a6b"
60
+ "gitHead": "36759959f624aa40d371dc9ee698dd472813f19c"
61
61
  }