@jixoai/gh-runner 0.2.5 → 0.2.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.
- package/dist/main.mjs +46 -11
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { mkdir, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
3
5
|
import { createTray } from "opentray";
|
|
4
6
|
import { attachDialog } from "@opentray/ext-dialog";
|
|
5
7
|
import { attachOpener } from "@opentray/ext-opener";
|
|
6
8
|
import { arch, homedir, platform } from "node:os";
|
|
7
|
-
import { dirname, isAbsolute, join } from "node:path";
|
|
8
9
|
import { createWriteStream, existsSync, readFileSync } from "node:fs";
|
|
9
10
|
import { execFile, spawn } from "node:child_process";
|
|
10
11
|
import { promisify } from "node:util";
|
|
11
12
|
import { Readable } from "node:stream";
|
|
12
13
|
import { pipeline } from "node:stream/promises";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
14
|
import { WebviewExt } from "@opentray/ext-webview";
|
|
15
15
|
// src/platform.ts
|
|
16
16
|
const IS_WIN = platform() === "win32";
|
|
@@ -1273,7 +1273,7 @@ var TrayProjection = class {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
1275
|
// src/version.ts
|
|
1276
|
-
const APP_VERSION = "0.2.
|
|
1276
|
+
const APP_VERSION = "0.2.7";
|
|
1277
1277
|
// src/window.ts
|
|
1278
1278
|
const DRAIN_INTERVAL_MS = 150;
|
|
1279
1279
|
const PUSH_DEBOUNCE_MS = 120;
|
|
@@ -1300,6 +1300,8 @@ var UiHost = class {
|
|
|
1300
1300
|
#pushInFlight = false;
|
|
1301
1301
|
#pushPending = false;
|
|
1302
1302
|
#visible = true;
|
|
1303
|
+
/** 隐藏期间 isVisible 慢轮询的分频计数(150ms 滴答 ×7 ≈ 1s)。 */
|
|
1304
|
+
#tick = 0;
|
|
1303
1305
|
constructor(fleet, webviewTray, onOpenDiag, pickPackageFile, pickRunnerDir, openExternal) {
|
|
1304
1306
|
this.fleet = fleet;
|
|
1305
1307
|
this.webviewTray = webviewTray;
|
|
@@ -1309,9 +1311,13 @@ var UiHost = class {
|
|
|
1309
1311
|
this.openExternal = openExternal;
|
|
1310
1312
|
}
|
|
1311
1313
|
async open() {
|
|
1312
|
-
if (this.#window) {
|
|
1314
|
+
if (this.#window) try {
|
|
1313
1315
|
await this.#window.show();
|
|
1314
1316
|
await this.#window.focus();
|
|
1317
|
+
} catch {
|
|
1318
|
+
this.#window = null;
|
|
1319
|
+
}
|
|
1320
|
+
if (this.#window) {
|
|
1315
1321
|
this.#visible = true;
|
|
1316
1322
|
this.#logOffsets.clear();
|
|
1317
1323
|
this.#doPush();
|
|
@@ -1341,15 +1347,20 @@ var UiHost = class {
|
|
|
1341
1347
|
await win.show();
|
|
1342
1348
|
await win.setMinimumSize(720, 520);
|
|
1343
1349
|
win.listen("visibleChange", (event) => {
|
|
1344
|
-
const visible = event.payload.visible
|
|
1345
|
-
this.#visible = visible;
|
|
1350
|
+
const visible = event.payload.visible;
|
|
1351
|
+
this.#visible = typeof visible === "boolean" ? visible : true;
|
|
1346
1352
|
if (visible) {
|
|
1347
1353
|
this.#logOffsets.clear();
|
|
1348
1354
|
this.#doPush();
|
|
1349
1355
|
}
|
|
1350
1356
|
});
|
|
1351
|
-
|
|
1352
|
-
|
|
1357
|
+
win.listen("closed", () => {
|
|
1358
|
+
this.#visible = false;
|
|
1359
|
+
});
|
|
1360
|
+
if (!this.#drainTimer) {
|
|
1361
|
+
this.#drainTimer = setInterval(() => void this.#drain(), DRAIN_INTERVAL_MS);
|
|
1362
|
+
this.#drainTimer.unref?.();
|
|
1363
|
+
}
|
|
1353
1364
|
this.#flush();
|
|
1354
1365
|
}
|
|
1355
1366
|
push(snapshot) {
|
|
@@ -1391,7 +1402,13 @@ var UiHost = class {
|
|
|
1391
1402
|
async #doPush() {
|
|
1392
1403
|
const win = this.#window;
|
|
1393
1404
|
const snap = this.#lastSnapshot;
|
|
1394
|
-
if (!win || !snap || win.connectionDead
|
|
1405
|
+
if (!win || !snap || win.connectionDead) return;
|
|
1406
|
+
if (this.#visible) try {
|
|
1407
|
+
this.#visible = await win.isVisible();
|
|
1408
|
+
} catch {
|
|
1409
|
+
this.#visible = false;
|
|
1410
|
+
}
|
|
1411
|
+
if (!this.#visible) return;
|
|
1395
1412
|
if (this.#pushInFlight) {
|
|
1396
1413
|
this.#pushPending = true;
|
|
1397
1414
|
return;
|
|
@@ -1413,7 +1430,10 @@ var UiHost = class {
|
|
|
1413
1430
|
download: snap.download
|
|
1414
1431
|
};
|
|
1415
1432
|
await this.#evaluate(JSON.stringify(summary));
|
|
1416
|
-
for (const inst of snap.instances)
|
|
1433
|
+
for (const inst of snap.instances) {
|
|
1434
|
+
if (!this.#visible) return;
|
|
1435
|
+
await this.#pushLogDelta(win, inst.id);
|
|
1436
|
+
}
|
|
1417
1437
|
} finally {
|
|
1418
1438
|
this.#pushInFlight = false;
|
|
1419
1439
|
if (this.#pushPending && this.#window) {
|
|
@@ -1448,6 +1468,7 @@ var UiHost = class {
|
|
|
1448
1468
|
if (cur.length > 0) chunks.push(cur);
|
|
1449
1469
|
let offset = total - allLines.length;
|
|
1450
1470
|
for (const lines of chunks) {
|
|
1471
|
+
if (!this.#visible) return;
|
|
1451
1472
|
const msg = {
|
|
1452
1473
|
kind: "log",
|
|
1453
1474
|
seq: ++this.#seq,
|
|
@@ -1477,6 +1498,18 @@ var UiHost = class {
|
|
|
1477
1498
|
async #drain() {
|
|
1478
1499
|
const win = this.#window;
|
|
1479
1500
|
if (!win || win.connectionDead) return;
|
|
1501
|
+
if (!this.#visible) {
|
|
1502
|
+
if (++this.#tick % 7 !== 0) return;
|
|
1503
|
+
try {
|
|
1504
|
+
if (!await win.isVisible()) return;
|
|
1505
|
+
} catch {
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
this.#visible = true;
|
|
1509
|
+
this.#logOffsets.clear();
|
|
1510
|
+
this.#doPush();
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1480
1513
|
let messages;
|
|
1481
1514
|
try {
|
|
1482
1515
|
messages = await win.drainIpcMessages();
|
|
@@ -1560,6 +1593,7 @@ function extendWebview(tray) {
|
|
|
1560
1593
|
}
|
|
1561
1594
|
// src/main.ts
|
|
1562
1595
|
const APP_ID = "com.jixoai.gh-runner";
|
|
1596
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
1563
1597
|
/** 导入本地分发包:系统文件选择框(ext-dialog;darwin NSOpenPanel / win32 对话框)。 */
|
|
1564
1598
|
async function pickPackageFile(tray) {
|
|
1565
1599
|
try {
|
|
@@ -1710,7 +1744,8 @@ async function main() {
|
|
|
1710
1744
|
}, {
|
|
1711
1745
|
appId: APP_ID,
|
|
1712
1746
|
appName: "GH Runner",
|
|
1713
|
-
appIcon: appIcon()
|
|
1747
|
+
appIcon: appIcon(),
|
|
1748
|
+
packageRoot
|
|
1714
1749
|
});
|
|
1715
1750
|
const projection = new TrayProjection(tray, {
|
|
1716
1751
|
openWindow: () => void uiHost.open(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jixoai/gh-runner",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Menu-bar (tray) manager for multiple GitHub Actions self-hosted runners: discover, register from downloaded/imported packages, start/stop, and live job-result analysis. macOS & Windows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|