@lwrjs/shared-utils 0.17.2-alpha.20 → 0.17.2-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
@@ -21,7 +21,9 @@ __export(exports, {
21
21
  getFeatureFlags: () => getFeatureFlags,
22
22
  getTraceHeaders: () => getTraceHeaders,
23
23
  isLambdaEnv: () => isLambdaEnv,
24
+ isLocalAuthEnabled: () => isLocalAuthEnabled,
24
25
  isLocalDev: () => isLocalDev,
26
+ isLocalPreview: () => isLocalPreview,
25
27
  parseRequestDepth: () => parseRequestDepth
26
28
  });
27
29
  if (getFeatureFlags().REEVALUATE_MODULES && !getFeatureFlags().LEGACY_LOADER) {
@@ -61,6 +63,12 @@ function isLambdaEnv() {
61
63
  function isLocalDev() {
62
64
  return process.env.MRT_HMR === "true";
63
65
  }
66
+ function isLocalPreview() {
67
+ return process.env.LOCAL_PREVIEW_MODE === "true";
68
+ }
69
+ function isLocalAuthEnabled() {
70
+ return process.env.AUTH_TOKEN !== void 0;
71
+ }
64
72
  function buildEnvironmentContext(runtimeParams) {
65
73
  const basePath = runtimeParams.basePath;
66
74
  const locale = runtimeParams.locale;
@@ -166,7 +166,6 @@ function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
166
166
  }
167
167
  });
168
168
  return {
169
- ...viewMetadata,
170
169
  customElements: customElements.filter((ce) => !nestedIslands || hasHydrationDirective(ce.props)),
171
170
  assetReferences
172
171
  };
@@ -27,7 +27,7 @@ __export(exports, {
27
27
  launch: () => launch
28
28
  });
29
29
  var import_os = __toModule(require("os"));
30
- async function launch(port, https) {
30
+ async function launch(port, https, path) {
31
31
  const {exec} = await Promise.resolve().then(() => __toModule(require("child_process")));
32
32
  let cmd = "open";
33
33
  if (process.platform == "win32") {
@@ -39,5 +39,9 @@ async function launch(port, https) {
39
39
  cmd = "xdg-open";
40
40
  }
41
41
  }
42
- exec(`${cmd} ${https ? "https" : "http"}://localhost:${port}`);
42
+ const finalPath = path ? path.startsWith("/") ? path : `/${path}` : "";
43
+ const protocol = https ? "https" : "http";
44
+ const url = `${protocol}://localhost:${port}${finalPath}/`;
45
+ exec(`${cmd} ${url}`);
46
+ return url;
43
47
  }
package/build/es/env.d.ts CHANGED
@@ -12,6 +12,18 @@ export declare function isLambdaEnv(): boolean;
12
12
  * @returns true if running in localdev mode
13
13
  */
14
14
  export declare function isLocalDev(): boolean;
15
+ /**
16
+ * This function is used to determine if lwr is running in the context of local preview.
17
+ *
18
+ * @returns true if running in preview mode
19
+ */
20
+ export declare function isLocalPreview(): boolean;
21
+ /**
22
+ * This function is used to determine if lwr is running with an authenticated context locally
23
+ *
24
+ * @returns true if local dev/preview authentication is enabled
25
+ */
26
+ export declare function isLocalAuthEnabled(): boolean;
15
27
  /**
16
28
  * Create a serializable context for user-land exposed environment variables
17
29
  */
package/build/es/env.js CHANGED
@@ -72,6 +72,22 @@ export function isLocalDev() {
72
72
  // TODO still need to formalize environment variable names
73
73
  return process.env.MRT_HMR === 'true';
74
74
  }
75
+ /**
76
+ * This function is used to determine if lwr is running in the context of local preview.
77
+ *
78
+ * @returns true if running in preview mode
79
+ */
80
+ export function isLocalPreview() {
81
+ return process.env.LOCAL_PREVIEW_MODE === 'true';
82
+ }
83
+ /**
84
+ * This function is used to determine if lwr is running with an authenticated context locally
85
+ *
86
+ * @returns true if local dev/preview authentication is enabled
87
+ */
88
+ export function isLocalAuthEnabled() {
89
+ return process.env.AUTH_TOKEN !== undefined;
90
+ }
75
91
  /**
76
92
  * Create a serializable context for user-land exposed environment variables
77
93
  */
@@ -1,11 +1,11 @@
1
- import type { NormalizedLwrGlobalConfig, RenderedViewMetadata } from '@lwrjs/types';
1
+ import type { HtmlMetadata, NormalizedLwrGlobalConfig, RenderedViewMetadata } from '@lwrjs/types';
2
2
  export declare function isRelative(url: string): boolean;
3
3
  export declare function isSelfUrl(url: string): boolean;
4
4
  /**
5
5
  * Pull the custom elements and img tags out of an HTML string, to use as metadata
6
6
  * @param htmlSource - An HTML string to parse
7
7
  */
8
- export declare function extractMetadataFromHtml(htmlSource: string, viewMetadata: RenderedViewMetadata, appConfig: NormalizedLwrGlobalConfig): RenderedViewMetadata;
8
+ export declare function extractMetadataFromHtml(htmlSource: string, viewMetadata: RenderedViewMetadata, appConfig: NormalizedLwrGlobalConfig): HtmlMetadata;
9
9
  export declare const HYDRATE_DIRECTIVE = "lwr:hydrate";
10
10
  export declare const HYDRATE_LOAD_VALUE = "load";
11
11
  export declare const HYDRATE_CLIENT_VALUE = "client-only";
@@ -165,7 +165,6 @@ export function extractMetadataFromHtml(htmlSource, viewMetadata, appConfig) {
165
165
  },
166
166
  });
167
167
  return {
168
- ...viewMetadata,
169
168
  customElements: customElements.filter((ce) => !nestedIslands || hasHydrationDirective(ce.props)),
170
169
  assetReferences,
171
170
  };
@@ -4,5 +4,5 @@
4
4
  * @param port - the port number
5
5
  * @param https - if true, use https
6
6
  */
7
- export declare function launch(port: number, https?: boolean): Promise<void>;
7
+ export declare function launch(port: number, https?: boolean, path?: string): Promise<string>;
8
8
  //# sourceMappingURL=launch.d.ts.map
@@ -5,7 +5,7 @@ import { release } from 'os';
5
5
  * @param port - the port number
6
6
  * @param https - if true, use https
7
7
  */
8
- export async function launch(port, https) {
8
+ export async function launch(port, https, path) {
9
9
  const { exec } = await import('child_process');
10
10
  let cmd = 'open';
11
11
  if (process.platform == 'win32') {
@@ -19,6 +19,11 @@ export async function launch(port, https) {
19
19
  cmd = 'xdg-open';
20
20
  }
21
21
  }
22
- exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
22
+ // Ensure the path begins with '/' if provided
23
+ const finalPath = path ? (path.startsWith('/') ? path : `/${path}`) : '';
24
+ const protocol = https ? 'https' : 'http';
25
+ const url = `${protocol}://localhost:${port}${finalPath}/`;
26
+ exec(`${cmd} ${url}`);
27
+ return url;
23
28
  }
24
29
  //# sourceMappingURL=launch.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.17.2-alpha.20",
7
+ "version": "0.17.2-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.17.2-alpha.20",
40
+ "@lwrjs/diagnostics": "0.17.2-alpha.22",
41
41
  "es-module-lexer": "^1.5.4",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
@@ -50,7 +50,7 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.17.2-alpha.20",
53
+ "@lwrjs/types": "0.17.2-alpha.22",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0",
56
56
  "memfs": "^4.13.0"
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=20.0.0"
60
60
  },
61
- "gitHead": "871213620dec8ff886be421339f1e90e86dbee96"
61
+ "gitHead": "89460a05096fe25860f06a9bea2c5c9a25b9cf05"
62
62
  }