@lwrjs/shared-utils 0.13.0-alpha.5 → 0.13.0-alpha.7

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.
@@ -35,6 +35,7 @@ __export(exports, {
35
35
  LATEST_SIGNATURE: () => LATEST_SIGNATURE,
36
36
  LOCALE_SIGIL: () => LOCALE_SIGIL,
37
37
  VERSION_NOT_PROVIDED: () => VERSION_NOT_PROVIDED,
38
+ VERSION_PREFIX: () => VERSION_PREFIX,
38
39
  VERSION_SIGIL: () => VERSION_SIGIL,
39
40
  explodeSpecifier: () => explodeSpecifier,
40
41
  explodeSpecifiers: () => explodeSpecifiers,
@@ -59,7 +60,8 @@ __export(exports, {
59
60
  });
60
61
  var import_slugify = __toModule(require("slugify"));
61
62
  var import_fast_json_stable_stringify = __toModule(require("fast-json-stable-stringify"));
62
- var VERSION_SIGIL = "/v/";
63
+ var VERSION_SIGIL = "v";
64
+ var VERSION_PREFIX = `/${VERSION_SIGIL}/`;
63
65
  var LOCALE_SIGIL = "l";
64
66
  var ENVIRONMENT_SIGIL = "e";
65
67
  var BUNDLE_SIGIL = "bi";
@@ -122,10 +124,10 @@ function getSpecifier({specifier, namespace, name = "", version}) {
122
124
  if (specifier) {
123
125
  const versionMatch = specifier.match(/(.+)\/v\/[a-zA-Z0-9-_.]+$/);
124
126
  specifier = versionMatch ? versionMatch[1] : specifier;
125
- return version && version !== VERSION_NOT_PROVIDED ? `${specifier}${VERSION_SIGIL}${normalizeVersionToUri(version)}` : specifier;
127
+ return version && version !== VERSION_NOT_PROVIDED ? `${specifier}${VERSION_PREFIX}${normalizeVersionToUri(version)}` : specifier;
126
128
  }
127
129
  const bareSpecifier = namespace ? `${namespace}/${name}` : name;
128
- return version && version !== VERSION_NOT_PROVIDED ? `${bareSpecifier}${VERSION_SIGIL}${normalizeVersionToUri(version)}` : bareSpecifier;
130
+ return version && version !== VERSION_NOT_PROVIDED ? `${bareSpecifier}${VERSION_PREFIX}${normalizeVersionToUri(version)}` : bareSpecifier;
129
131
  }
130
132
  async function getVersionedModuleId(rawSpecifier, moduleRegistry, runtimeParams) {
131
133
  const moduleId = explodeSpecifier(rawSpecifier);
@@ -35,3 +35,4 @@ __exportStar(exports, __toModule(require("./env.cjs")));
35
35
  __exportStar(exports, __toModule(require("./lwr-app-observer.cjs")));
36
36
  __exportStar(exports, __toModule(require("./bundle.cjs")));
37
37
  __exportStar(exports, __toModule(require("./localization.cjs")));
38
+ __exportStar(exports, __toModule(require("./launch.cjs")));
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, {get: all[name], enumerable: true});
11
+ };
12
+ var __exportStar = (target, module2, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && key !== "default")
16
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
+ }
18
+ return target;
19
+ };
20
+ var __toModule = (module2) => {
21
+ return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
+ };
23
+
24
+ // packages/@lwrjs/shared-utils/src/launch.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ launch: () => launch
28
+ });
29
+ var import_os = __toModule(require("os"));
30
+ async function launch(port, https) {
31
+ const {exec} = await Promise.resolve().then(() => __toModule(require("child_process")));
32
+ let cmd = "open";
33
+ if (process.platform == "win32") {
34
+ cmd = "start";
35
+ } else if (process.platform == "linux") {
36
+ if (/microsoft/i.test((0, import_os.release)())) {
37
+ cmd = "cmd.exe /c start";
38
+ } else {
39
+ cmd = "xdg-open";
40
+ }
41
+ }
42
+ exec(`${cmd} ${https ? "https" : "http"}://localhost:${port}`);
43
+ }
@@ -1,6 +1,7 @@
1
1
  import getCacheKeyFromJson from 'fast-json-stable-stringify';
2
2
  import type { AbstractModuleId, AssetSource, BundleDefinition, ModuleDefinition, NormalizedLwrAppBootstrapConfig, PublicModuleRegistry, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
3
- export declare const VERSION_SIGIL = "/v/";
3
+ export declare const VERSION_SIGIL = "v";
4
+ export declare const VERSION_PREFIX: string;
4
5
  export declare const LOCALE_SIGIL = "l";
5
6
  export declare const ENVIRONMENT_SIGIL = "e";
6
7
  export declare const BUNDLE_SIGIL = "bi";
@@ -1,6 +1,7 @@
1
1
  import slugifyText from 'slugify';
2
2
  import getCacheKeyFromJson from 'fast-json-stable-stringify';
3
- export const VERSION_SIGIL = '/v/';
3
+ export const VERSION_SIGIL = 'v';
4
+ export const VERSION_PREFIX = `/${VERSION_SIGIL}/`;
4
5
  export const LOCALE_SIGIL = 'l';
5
6
  export const ENVIRONMENT_SIGIL = 'e';
6
7
  export const BUNDLE_SIGIL = 'bi';
@@ -99,13 +100,13 @@ export function getSpecifier({ specifier, namespace, name = '', version }) {
99
100
  specifier = versionMatch ? versionMatch[1] : specifier;
100
101
  // If a module has an explicit 'version-not-provided' version this will not be reflected in the specifier
101
102
  return version && version !== VERSION_NOT_PROVIDED
102
- ? `${specifier}${VERSION_SIGIL}${normalizeVersionToUri(version)}`
103
+ ? `${specifier}${VERSION_PREFIX}${normalizeVersionToUri(version)}`
103
104
  : specifier;
104
105
  }
105
106
  const bareSpecifier = namespace ? `${namespace}/${name}` : name;
106
107
  // If a module has an explicit 'version-not-provided' version this will not be reflected in the specifier
107
108
  return version && version !== VERSION_NOT_PROVIDED
108
- ? `${bareSpecifier}${VERSION_SIGIL}${normalizeVersionToUri(version)}`
109
+ ? `${bareSpecifier}${VERSION_PREFIX}${normalizeVersionToUri(version)}`
109
110
  : bareSpecifier;
110
111
  }
111
112
  /**
@@ -14,4 +14,5 @@ export * from './env.js';
14
14
  export * from './lwr-app-observer.js';
15
15
  export * from './bundle.js';
16
16
  export * from './localization.js';
17
+ export * from './launch.js';
17
18
  //# sourceMappingURL=index.d.ts.map
package/build/es/index.js CHANGED
@@ -14,4 +14,5 @@ export * from './env.js';
14
14
  export * from './lwr-app-observer.js';
15
15
  export * from './bundle.js';
16
16
  export * from './localization.js';
17
+ export * from './launch.js';
17
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared utility for launching a localhost browser window at a given port.
3
+ *
4
+ * @param port - the port number
5
+ * @param https - if true, use https
6
+ */
7
+ export declare function launch(port: number, https?: boolean): Promise<void>;
8
+ //# sourceMappingURL=launch.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { release } from 'os';
2
+ /**
3
+ * Shared utility for launching a localhost browser window at a given port.
4
+ *
5
+ * @param port - the port number
6
+ * @param https - if true, use https
7
+ */
8
+ export async function launch(port, https) {
9
+ const { exec } = await import('child_process');
10
+ let cmd = 'open';
11
+ if (process.platform == 'win32') {
12
+ cmd = 'start';
13
+ }
14
+ else if (process.platform == 'linux') {
15
+ if (/microsoft/i.test(release())) {
16
+ cmd = 'cmd.exe /c start';
17
+ }
18
+ else {
19
+ cmd = 'xdg-open';
20
+ }
21
+ }
22
+ exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
23
+ }
24
+ //# sourceMappingURL=launch.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.5",
7
+ "version": "0.13.0-alpha.7",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,8 +37,8 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.13.0-alpha.5",
41
- "es-module-lexer": "^1.3.0",
40
+ "@lwrjs/diagnostics": "0.13.0-alpha.7",
41
+ "es-module-lexer": "^1.5.2",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
44
44
  "mime-types": "^2.1.33",
@@ -50,12 +50,12 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.13.0-alpha.5",
53
+ "@lwrjs/types": "0.13.0-alpha.7",
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": "228fe607cb3f377a11efe53dd800c4f53a4eab66"
60
+ "gitHead": "4b77dea6ac8d473a4113ad7b345b3a37b0b8a3f8"
61
61
  }