@farm.js/desktop 0.1.0-beta.6 → 0.1.0-beta.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/electrobun/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/electrobun/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,+DAA+D;AAC/D,eAAO,MAAM,YAAY,QAAmE,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYzD;;AAgDD,wBAiCG"}
|
package/dist/electrobun/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { mkdir, readFile, readdir, rename, rm } from "node:fs/promises";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { defineDesktopShell, } from "@farm.js/core/desktop";
|
|
7
|
+
import { stopProcessTree } from "./process-tree.js";
|
|
7
8
|
import { createElectrobunConfig, createElectrobunMain, ICONSET_IMAGE } from "./templates.js";
|
|
8
9
|
export { createElectrobunConfig, createElectrobunMain } from "./templates.js";
|
|
9
10
|
const isWindows = process.platform === "win32";
|
|
@@ -25,7 +26,8 @@ export function resolveElectrobunCli(root) {
|
|
|
25
26
|
}
|
|
26
27
|
function runElectrobun(context, args, env) {
|
|
27
28
|
// Its own process group on macOS and Linux, so stopping also reaches the app that
|
|
28
|
-
// `electrobun dev` launches, which outlives the CLI wrapper otherwise.
|
|
29
|
+
// `electrobun dev` launches, which outlives the CLI wrapper otherwise. Windows stops the
|
|
30
|
+
// process tree instead.
|
|
29
31
|
return spawn(process.execPath, [resolveElectrobunCli(context.root), ...args], {
|
|
30
32
|
cwd: context.shellDir,
|
|
31
33
|
env: env ?? process.env,
|
|
@@ -39,19 +41,6 @@ function waitForExit(child) {
|
|
|
39
41
|
child.once("exit", (code, signal) => resolve(code ?? (signal ? 1 : 0)));
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
|
-
function stopProcessTree(child, signal) {
|
|
43
|
-
if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined)
|
|
44
|
-
return;
|
|
45
|
-
try {
|
|
46
|
-
if (isWindows)
|
|
47
|
-
child.kill(signal);
|
|
48
|
-
else
|
|
49
|
-
process.kill(-child.pid, signal);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
// Already gone.
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
44
|
/** Move Electrobun's build and artifact folders into Farm's dist directory. */
|
|
56
45
|
async function collectArtifacts(shellDir, distDir) {
|
|
57
46
|
await rm(distDir, { recursive: true, force: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Stop the Electrobun CLI and the app it launched. On macOS and Linux the CLI leads its own
|
|
4
|
+
* process group, so the signal reaches the whole group. Windows has neither process groups nor
|
|
5
|
+
* signals for another process, and kill() would end only the CLI, so taskkill ends the tree.
|
|
6
|
+
*/
|
|
7
|
+
export declare function stopProcessTree(child: ChildProcess, signal: NodeJS.Signals, platform?: NodeJS.Platform): void;
|
|
8
|
+
//# sourceMappingURL=process-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-tree.d.ts","sourceRoot":"","sources":["../../src/electrobun/process-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,IAAI,CAeN"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Stop the Electrobun CLI and the app it launched. On macOS and Linux the CLI leads its own
|
|
4
|
+
* process group, so the signal reaches the whole group. Windows has neither process groups nor
|
|
5
|
+
* signals for another process, and kill() would end only the CLI, so taskkill ends the tree.
|
|
6
|
+
*/
|
|
7
|
+
export function stopProcessTree(child, signal, platform = process.platform) {
|
|
8
|
+
if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
if (platform !== "win32") {
|
|
12
|
+
process.kill(-child.pid, signal);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const result = spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
16
|
+
stdio: "ignore",
|
|
17
|
+
windowsHide: true,
|
|
18
|
+
});
|
|
19
|
+
if (result.error || result.status !== 0)
|
|
20
|
+
child.kill(signal);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Already gone.
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm.js/desktop",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.7",
|
|
4
4
|
"description": "Desktop shells for Farm.js apps (farm dev --desktop, farm build --desktop). Ships the Electrobun shell.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"desktop",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"typescript": "^5.3.3",
|
|
36
36
|
"vite": "8.3.4",
|
|
37
37
|
"vitest": "5.0.5",
|
|
38
|
-
"@farm.js/core": "0.1.
|
|
38
|
+
"@farm.js/core": "0.1.67"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"electrobun": "^2.0.5",
|
|
42
|
-
"@farm.js/core": "0.1.
|
|
42
|
+
"@farm.js/core": "0.1.67"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"electrobun": {
|