@orkestrel/sea 0.0.8 → 0.0.9
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.
|
@@ -581,13 +581,14 @@ export declare const MACHO_MAGIC_64 = 4277009103;
|
|
|
581
581
|
* A best-effort launch for bundled local-UI apps: dispatches by
|
|
582
582
|
* `process.platform` (`win32` -> `rundll32 url.dll,FileProtocolHandler`,
|
|
583
583
|
* `darwin` -> `open`, else -> `xdg-open`), each invoked with an argv array
|
|
584
|
-
* (never a shell) so the URL cannot be
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
584
|
+
* through `@orkestrel/process`'s `detach` (never a shell) so the URL cannot be
|
|
585
|
+
* interpreted as a flag or injected into a command line. `detach` spawns the
|
|
586
|
+
* child detached, with its stdio discarded and unreferenced, so the opener
|
|
587
|
+
* outlives the host app and never keeps it alive, and it swallows the async
|
|
588
|
+
* host fault an absent opener binary raises. Only `http:` and `https:` URLs
|
|
589
|
+
* are accepted — any other scheme (including a string that merely looks like a
|
|
590
|
+
* CLI flag, e.g. `'-e ...'`) fails to parse as an http(s) URL and is rejected
|
|
591
|
+
* before anything is spawned.
|
|
591
592
|
*
|
|
592
593
|
* @param url - Absolute http or https URL to open
|
|
593
594
|
* @throws SEAError with code `'BROWSER'` when `url` is not a parseable absolute URL
|
|
@@ -581,13 +581,14 @@ export declare const MACHO_MAGIC_64 = 4277009103;
|
|
|
581
581
|
* A best-effort launch for bundled local-UI apps: dispatches by
|
|
582
582
|
* `process.platform` (`win32` -> `rundll32 url.dll,FileProtocolHandler`,
|
|
583
583
|
* `darwin` -> `open`, else -> `xdg-open`), each invoked with an argv array
|
|
584
|
-
* (never a shell) so the URL cannot be
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
584
|
+
* through `@orkestrel/process`'s `detach` (never a shell) so the URL cannot be
|
|
585
|
+
* interpreted as a flag or injected into a command line. `detach` spawns the
|
|
586
|
+
* child detached, with its stdio discarded and unreferenced, so the opener
|
|
587
|
+
* outlives the host app and never keeps it alive, and it swallows the async
|
|
588
|
+
* host fault an absent opener binary raises. Only `http:` and `https:` URLs
|
|
589
|
+
* are accepted — any other scheme (including a string that merely looks like a
|
|
590
|
+
* CLI flag, e.g. `'-e ...'`) fails to parse as an http(s) URL and is rejected
|
|
591
|
+
* before anything is spawned.
|
|
591
592
|
*
|
|
592
593
|
* @param url - Absolute http or https URL to open
|
|
593
594
|
* @throws SEAError with code `'BROWSER'` when `url` is not a parseable absolute URL
|
package/dist/src/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appendFileSync, chmodSync, closeSync, copyFileSync, existsSync, fstatSync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
2
2
|
import { brotliCompressSync, constants } from "node:zlib";
|
|
3
3
|
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { detach, runSync } from "@orkestrel/process/server";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { Emitter } from "@orkestrel/emitter";
|
|
7
7
|
import { getAssetKeys, getRawAsset, isSea } from "node:sea";
|
|
@@ -312,33 +312,21 @@ function runShell(command, options) {
|
|
|
312
312
|
const [cmd, ...args] = command;
|
|
313
313
|
if (cmd === void 0) throw new SEAError("STATE", "Command array must not be empty");
|
|
314
314
|
if (options?.signal?.aborted === true) throw new SEAError("ABORT", "Shell command aborted", { command: redactCommand(command) });
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
});
|
|
331
|
-
} catch (thrown) {
|
|
332
|
-
if (!(thrown instanceof Error)) throw thrown;
|
|
333
|
-
const redacted = redactCommand(command);
|
|
334
|
-
if (("code" in thrown && typeof thrown.code === "string" ? thrown.code : void 0) === "ETIMEDOUT") throw new SEAError("TIMEOUT", "Shell command timed out", {
|
|
335
|
-
command: redacted,
|
|
336
|
-
timeout: options?.timeout
|
|
337
|
-
});
|
|
338
|
-
const stdout = "stdout" in thrown && Buffer.isBuffer(thrown.stdout) ? thrown.stdout : Buffer.alloc(0);
|
|
339
|
-
const stderr = "stderr" in thrown && Buffer.isBuffer(thrown.stderr) ? thrown.stderr : Buffer.alloc(0);
|
|
340
|
-
throw new ShellError("Command failed: " + redacted.join(" "), stdout, stderr);
|
|
341
|
-
}
|
|
315
|
+
const result = runSync({
|
|
316
|
+
file: cmd,
|
|
317
|
+
arguments: args,
|
|
318
|
+
...options?.env !== void 0 ? { environment: options.env } : {}
|
|
319
|
+
}, {
|
|
320
|
+
...options?.cwd !== void 0 ? { workspace: options.cwd } : {},
|
|
321
|
+
...options?.timeout !== void 0 ? { timeout: options.timeout } : {},
|
|
322
|
+
strict: false
|
|
323
|
+
});
|
|
324
|
+
if (result.expired) throw new SEAError("TIMEOUT", "Shell command timed out", {
|
|
325
|
+
command: redactCommand(command),
|
|
326
|
+
timeout: options?.timeout
|
|
327
|
+
});
|
|
328
|
+
if (result.failed) throw new ShellError("Command failed: " + redactCommand(command).join(" "), Buffer.from(result.stdout, "utf-8"), Buffer.from(result.stderr, "utf-8"));
|
|
329
|
+
return Buffer.from(result.stdout, "utf-8");
|
|
342
330
|
}
|
|
343
331
|
/**
|
|
344
332
|
* Compute a size comparison between original and compressed byte counts.
|
|
@@ -968,13 +956,14 @@ function patchSentinelFuse(executable, fuse) {
|
|
|
968
956
|
* A best-effort launch for bundled local-UI apps: dispatches by
|
|
969
957
|
* `process.platform` (`win32` -> `rundll32 url.dll,FileProtocolHandler`,
|
|
970
958
|
* `darwin` -> `open`, else -> `xdg-open`), each invoked with an argv array
|
|
971
|
-
* (never a shell) so the URL cannot be
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
959
|
+
* through `@orkestrel/process`'s `detach` (never a shell) so the URL cannot be
|
|
960
|
+
* interpreted as a flag or injected into a command line. `detach` spawns the
|
|
961
|
+
* child detached, with its stdio discarded and unreferenced, so the opener
|
|
962
|
+
* outlives the host app and never keeps it alive, and it swallows the async
|
|
963
|
+
* host fault an absent opener binary raises. Only `http:` and `https:` URLs
|
|
964
|
+
* are accepted — any other scheme (including a string that merely looks like a
|
|
965
|
+
* CLI flag, e.g. `'-e ...'`) fails to parse as an http(s) URL and is rejected
|
|
966
|
+
* before anything is spawned.
|
|
978
967
|
*
|
|
979
968
|
* @param url - Absolute http or https URL to open
|
|
980
969
|
* @throws SEAError with code `'BROWSER'` when `url` is not a parseable absolute URL
|
|
@@ -996,18 +985,17 @@ function openBrowser(url) {
|
|
|
996
985
|
url,
|
|
997
986
|
protocol: parsed.protocol
|
|
998
987
|
});
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
child.unref();
|
|
988
|
+
const command = process.platform === "win32" ? {
|
|
989
|
+
file: "rundll32",
|
|
990
|
+
arguments: ["url.dll,FileProtocolHandler", parsed.href]
|
|
991
|
+
} : process.platform === "darwin" ? {
|
|
992
|
+
file: "open",
|
|
993
|
+
arguments: [parsed.href]
|
|
994
|
+
} : {
|
|
995
|
+
file: "xdg-open",
|
|
996
|
+
arguments: [parsed.href]
|
|
997
|
+
};
|
|
998
|
+
detach(command);
|
|
1011
999
|
}
|
|
1012
1000
|
//#endregion
|
|
1013
1001
|
//#region src/server/injectors/Injector.ts
|