@shing.wong/sure-wasm-helper 0.1.3 → 0.1.4
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/dist/packager.d.ts +4 -1
- package/dist/packager.js +13 -2
- package/package.json +1 -1
package/dist/packager.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface PackageOptions {
|
|
|
17
17
|
assets?: PackageAsset[] | Record<string, string>;
|
|
18
18
|
/** Arguments used when the binary starts with no CLI arguments. */
|
|
19
19
|
noArgsArgs?: string | string[];
|
|
20
|
+
/** Browser-opener port when noArgsArgs omits --port. */
|
|
21
|
+
defaultUiPort?: number;
|
|
20
22
|
/** Modules esbuild must leave as runtime `require()` calls. */
|
|
21
23
|
external?: string[];
|
|
22
24
|
envCore?: string;
|
|
@@ -41,6 +43,7 @@ export interface PackagePlan {
|
|
|
41
43
|
envUi: string;
|
|
42
44
|
envLaunch: string;
|
|
43
45
|
noArgsArgs: string[] | null;
|
|
46
|
+
defaultUiPort: number;
|
|
44
47
|
buildDate: string;
|
|
45
48
|
}
|
|
46
49
|
export interface PackageResult {
|
|
@@ -64,6 +67,6 @@ export declare function parsePackageCli(argv: string[]): PackageOptions;
|
|
|
64
67
|
/** CLI entry point. Returns an exit code; never calls process.exit. */
|
|
65
68
|
export declare function runSurePackCli(argv?: string[]): Promise<number>;
|
|
66
69
|
/** Exported for the packaged binary's own `--version` diagnostics. */
|
|
67
|
-
export declare const packagerVersion = "0.1.
|
|
70
|
+
export declare const packagerVersion = "0.1.4";
|
|
68
71
|
/** Exported for callers that need the default executable suffix. */
|
|
69
72
|
export declare function defaultExecutableName(app: string, platform?: NodeJS.Platform): string;
|
package/dist/packager.js
CHANGED
|
@@ -105,6 +105,7 @@ export function resolvePackagePlan(options) {
|
|
|
105
105
|
envUi: options.envUi ?? "SURE_APP_UI_DIR",
|
|
106
106
|
envLaunch: options.envLaunch ?? "SURE_APP_LAUNCH_ARGS",
|
|
107
107
|
noArgsArgs,
|
|
108
|
+
defaultUiPort: options.defaultUiPort ?? 8788,
|
|
108
109
|
buildDate: new Date().toISOString(),
|
|
109
110
|
};
|
|
110
111
|
}
|
|
@@ -255,7 +256,7 @@ if (require("node:sea").isSea()) {
|
|
|
255
256
|
process.argv = [process.argv[0], process.argv[1], ...rewritten];
|
|
256
257
|
if (!rewritten.includes("--no-open")) {
|
|
257
258
|
setTimeout(() => {
|
|
258
|
-
const url = "http://127.0.0.1:" + (rewritten.includes("--port") ? rewritten[rewritten.indexOf("--port") + 1] :
|
|
259
|
+
const url = "http://127.0.0.1:" + (rewritten.includes("--port") ? rewritten[rewritten.indexOf("--port") + 1] : String(CONFIG.defaultUiPort)) + "/";
|
|
259
260
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
260
261
|
const argv = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
261
262
|
try {
|
|
@@ -442,6 +443,15 @@ export function parsePackageCli(argv) {
|
|
|
442
443
|
external.push(takeValue(argv, index, flag));
|
|
443
444
|
index += 1;
|
|
444
445
|
break;
|
|
446
|
+
case "--default-ui-port": {
|
|
447
|
+
const port = Number(takeValue(argv, index, flag));
|
|
448
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
449
|
+
fail("--default-ui-port must be 1-65535");
|
|
450
|
+
}
|
|
451
|
+
options.defaultUiPort = port;
|
|
452
|
+
index += 1;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
445
455
|
default:
|
|
446
456
|
fail(`unknown argument '${flag}'`);
|
|
447
457
|
}
|
|
@@ -460,6 +470,7 @@ export function parsePackageCli(argv) {
|
|
|
460
470
|
}
|
|
461
471
|
const USAGE = `usage: sure-pack --app <name> --entry <file> --ui-dir <dir> --out <file>
|
|
462
472
|
[--core <wasm>] [--asset name=path]... [--external <module>]...
|
|
473
|
+
[--default-ui-port <n>]
|
|
463
474
|
[--no-args-args "serve --ui"]
|
|
464
475
|
[--env-core NAME] [--env-build NAME] [--env-ui NAME] [--env-launch NAME]
|
|
465
476
|
[--config sure-pack.json]`;
|
|
@@ -483,7 +494,7 @@ export async function runSurePackCli(argv = process.argv.slice(2)) {
|
|
|
483
494
|
}
|
|
484
495
|
}
|
|
485
496
|
/** Exported for the packaged binary's own `--version` diagnostics. */
|
|
486
|
-
export const packagerVersion = "0.1.
|
|
497
|
+
export const packagerVersion = "0.1.4";
|
|
487
498
|
/** Exported for callers that need the default executable suffix. */
|
|
488
499
|
export function defaultExecutableName(app, platform = process.platform) {
|
|
489
500
|
return `${basename(app)}${platform === "win32" ? ".exe" : ""}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shing.wong/sure-wasm-helper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Generic WASM reactor host, loopback UI/WebSocket host, WASI socket adapter, SEA packager, self-updater and cold-start bench",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|