@xbrowser/cli 1.0.0 → 1.0.2
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/README.md +17 -26
- package/dist/{browser-GURRY444.js → browser-GITRHHFO.js} +4 -3
- package/dist/{browser-DSVV4GHS.js → browser-R56O3CW6.js} +3 -3
- package/dist/{browser-53KUFEEM.js → browser-ZJOZB5CR.js} +4 -4
- package/dist/{cdp-driver-MNPR3HZH.js → cdp-driver-BE3FOMRN.js} +324 -58
- package/dist/{cdp-driver-SSXUGXP6.js → cdp-driver-TOPYJIFL.js} +3 -3
- package/dist/chunk-2SVQTI2O.js +2794 -0
- package/dist/{chunk-2MFXKN32.js → chunk-ACFE6PKF.js} +1013 -119
- package/dist/chunk-BBMRDUYQ.js +260 -0
- package/dist/{chunk-E4O5ZU3H.js → chunk-CAFNSGYM.js} +393 -95
- package/dist/{chunk-DTJRVA76.js → chunk-ETCO4SNK.js} +2 -2
- package/dist/{chunk-YKOHDEFV.js → chunk-JPA2ZT2R.js} +69 -36
- package/dist/{chunk-T4J4C2NZ.js → chunk-JPHCY4TC.js} +12 -2
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/{chunk-ITKPSIP7.js → chunk-MDAPTB7C.js} +6 -25
- package/dist/chunk-OZKD3W4X.js +417 -0
- package/dist/{chunk-42RPMJ76.js → chunk-PPG4D2EW.js} +325 -59
- package/dist/{chunk-IDVD44ED.js → chunk-Q4IGYTKR.js} +19 -7
- package/dist/{chunk-2BQZIT3S.js → chunk-QIK2I3VQ.js} +86 -2501
- package/dist/chunk-WJRE55TN.js +83 -0
- package/dist/cli.js +1435 -1077
- package/dist/{convert-EGFYNICZ.js → convert-LB3GJTLR.js} +3 -3
- package/dist/{convert-EKQVHKB4.js → convert-R3XXYKC6.js} +2 -2
- package/dist/{daemon-client-3VM7VU7O.js → daemon-client-DRCUMNHK.js} +25 -74
- package/dist/{daemon-client-YAVQ343A.js → daemon-client-UZZEHHIV.js} +2 -2
- package/dist/daemon-main.js +2200 -1691
- package/dist/{extract-JUOQQX4V.js → extract-2ZFW2MX7.js} +1 -1
- package/dist/{extract-L2IW3IUB.js → extract-BSYBM4MR.js} +1 -1
- package/dist/{filter-HC4RA7JY.js → filter-KCFO4RSV.js} +1 -1
- package/dist/{filter-VID2GGZ7.js → filter-T7DSZ2X7.js} +1 -1
- package/dist/{human-interaction-W753RVJB.js → human-interaction-UKAS5ZXV.js} +2 -2
- package/dist/index.d.ts +165 -108
- package/dist/index.js +2531 -1680
- package/dist/launcher-QUJ4M2VS.js +19 -0
- package/dist/{launcher-KA7J32K5.js → launcher-YARP45UY.js} +1 -1
- package/dist/{network-store-66A2RATI.js → network-store-XGZ25FFC.js} +1 -1
- package/dist/{network-store-BN6QEZ7R.js → network-store-YVDNUREI.js} +1 -1
- package/dist/{parse-action-dsl-T3DYC33D.js → parse-action-dsl-UM333TL2.js} +1 -1
- package/dist/{proxy-WKGUCH2C.js → proxy-LV4BJ5RC.js} +1 -1
- package/dist/session-recorder-RTDGURIJ.js +8 -0
- package/dist/session-recorder-YI7YYM36.js +7 -0
- package/dist/session-replayer-GLTUICSD.js +276 -0
- package/dist/site-knowledge-SYC6VCDB.js +23 -0
- package/package.json +5 -4
- package/dist/screenshot-CWAWMXVA.js +0 -28
- package/dist/session-recorder-MA75PKTQ.js +0 -7
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/daemon/daemon.ts
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import { join, dirname } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { stopDaemon as xcliStopDaemon, isDaemonRunning, getDaemonStatus, killAllDaemon } from "@dyyz1993/xcli-core";
|
|
7
|
+
var CONFIG_DIR = join(homedir(), ".xbrowser");
|
|
8
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
var WORKER_PATH = join(__dirname, "daemon-main.js");
|
|
10
|
+
function getDaemonConfig() {
|
|
11
|
+
return {
|
|
12
|
+
configDir: CONFIG_DIR,
|
|
13
|
+
workerEntryPath: WORKER_PATH,
|
|
14
|
+
basePort: 9224
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function startDaemonProcess(port = 9224) {
|
|
18
|
+
const config = getDaemonConfig();
|
|
19
|
+
if (isDaemonRunning(config)) {
|
|
20
|
+
const status = getDaemonStatus(config);
|
|
21
|
+
if (status.port === port && status.pid) {
|
|
22
|
+
return { pid: status.pid, port: status.port, startedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
23
|
+
}
|
|
24
|
+
await xcliStopDaemon(config);
|
|
25
|
+
}
|
|
26
|
+
const child = spawn("node", [WORKER_PATH], {
|
|
27
|
+
detached: true,
|
|
28
|
+
stdio: "ignore",
|
|
29
|
+
env: {
|
|
30
|
+
...process.env,
|
|
31
|
+
XBROWSER_DAEMON_PORT: String(port)
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
child.unref();
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
let resolved = false;
|
|
37
|
+
const timeout = setTimeout(() => {
|
|
38
|
+
if (!resolved) {
|
|
39
|
+
resolved = true;
|
|
40
|
+
reject(new Error("Daemon start timeout after 15s"));
|
|
41
|
+
}
|
|
42
|
+
}, 15e3);
|
|
43
|
+
const checkInterval = setInterval(() => {
|
|
44
|
+
if (isDaemonRunning(config)) {
|
|
45
|
+
const s = getDaemonStatus(config);
|
|
46
|
+
if (s.port === port && s.pid) {
|
|
47
|
+
resolved = true;
|
|
48
|
+
clearTimeout(timeout);
|
|
49
|
+
clearInterval(checkInterval);
|
|
50
|
+
resolve({ pid: s.pid, port: s.port, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, 200);
|
|
54
|
+
child.on("error", (err) => {
|
|
55
|
+
if (!resolved) {
|
|
56
|
+
resolved = true;
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
clearInterval(checkInterval);
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function getDaemonProcessStatus() {
|
|
65
|
+
const config = getDaemonConfig();
|
|
66
|
+
const running = isDaemonRunning(config);
|
|
67
|
+
if (!running) {
|
|
68
|
+
return { running: false, pid: 0, port: 0, info: null };
|
|
69
|
+
}
|
|
70
|
+
const status = getDaemonStatus(config);
|
|
71
|
+
return {
|
|
72
|
+
running: true,
|
|
73
|
+
pid: status.pid,
|
|
74
|
+
port: status.port,
|
|
75
|
+
info: { pid: status.pid, port: status.port, startedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
getDaemonConfig,
|
|
81
|
+
startDaemonProcess,
|
|
82
|
+
getDaemonProcessStatus
|
|
83
|
+
};
|