@xbrowser/cli 0.15.1 → 0.16.0
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/cli.js +122 -141
- package/dist/daemon-main.js +20 -47
- package/dist/index.js +120 -139
- package/package.json +2 -2
package/dist/daemon-main.js
CHANGED
|
@@ -24,13 +24,13 @@ import {
|
|
|
24
24
|
} from "./chunk-F3ZWFCJJ.js";
|
|
25
25
|
|
|
26
26
|
// src/daemon/daemon-main.ts
|
|
27
|
-
import { writeFileSync as
|
|
27
|
+
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync5, appendFileSync } from "fs";
|
|
28
28
|
import { join as join6 } from "path";
|
|
29
29
|
import { homedir as homedir6 } from "os";
|
|
30
30
|
import { startHttpServer } from "@dyyz1993/xcli-core";
|
|
31
31
|
|
|
32
32
|
// src/daemon/rpc-handlers.ts
|
|
33
|
-
import { writeFileSync as
|
|
33
|
+
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync4 } from "fs";
|
|
34
34
|
import { join as join5 } from "path";
|
|
35
35
|
import { homedir as homedir5 } from "os";
|
|
36
36
|
import {
|
|
@@ -45,7 +45,8 @@ import {
|
|
|
45
45
|
isCommandResult,
|
|
46
46
|
configureArchiveStore,
|
|
47
47
|
appendCommandToArchive,
|
|
48
|
-
checkGuard
|
|
48
|
+
checkGuard,
|
|
49
|
+
PluginStorage
|
|
49
50
|
} from "@dyyz1993/xcli-core";
|
|
50
51
|
|
|
51
52
|
// src/utils/positional-params.ts
|
|
@@ -5633,7 +5634,7 @@ import { join as join2 } from "path";
|
|
|
5633
5634
|
import { execSync as execSync6 } from "child_process";
|
|
5634
5635
|
var SHARED_PLUGIN_DEPENDENCIES = {
|
|
5635
5636
|
"zod": "^3.24.0",
|
|
5636
|
-
"@dyyz1993/xcli-core": "^0.
|
|
5637
|
+
"@dyyz1993/xcli-core": "^0.12.1"
|
|
5637
5638
|
};
|
|
5638
5639
|
function ensurePluginDependencies(pluginsDir) {
|
|
5639
5640
|
const zodPath = join2(pluginsDir, "node_modules", "zod");
|
|
@@ -6217,45 +6218,13 @@ async function loadHooks() {
|
|
|
6217
6218
|
// src/executor.ts
|
|
6218
6219
|
import { homedir as homedir3 } from "os";
|
|
6219
6220
|
import { join as join3 } from "path";
|
|
6220
|
-
import { existsSync as existsSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync5, mkdirSync as mkdirSync3 } from "fs";
|
|
6221
6221
|
var NAVIGATION_COMMANDS = /* @__PURE__ */ new Set(["goto", "back", "forward", "refresh"]);
|
|
6222
6222
|
var snapshotHintShown = /* @__PURE__ */ new WeakSet();
|
|
6223
6223
|
var STORAGE_DIR = join3(homedir3(), ".xbrowser", "storage");
|
|
6224
6224
|
var storageCache = /* @__PURE__ */ new Map();
|
|
6225
6225
|
function getPluginStorage(pluginName) {
|
|
6226
6226
|
if (!storageCache.has(pluginName)) {
|
|
6227
|
-
|
|
6228
|
-
let data = {};
|
|
6229
|
-
const load3 = () => {
|
|
6230
|
-
if (existsSync6(filePath)) {
|
|
6231
|
-
try {
|
|
6232
|
-
data = JSON.parse(readFileSync10(filePath, "utf-8"));
|
|
6233
|
-
} catch {
|
|
6234
|
-
data = {};
|
|
6235
|
-
}
|
|
6236
|
-
}
|
|
6237
|
-
};
|
|
6238
|
-
const save = () => {
|
|
6239
|
-
mkdirSync3(STORAGE_DIR, { recursive: true });
|
|
6240
|
-
writeFileSync5(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
6241
|
-
};
|
|
6242
|
-
load3();
|
|
6243
|
-
storageCache.set(pluginName, {
|
|
6244
|
-
get: async (key) => data[key] ?? null,
|
|
6245
|
-
set: async (key, value) => {
|
|
6246
|
-
data[key] = value;
|
|
6247
|
-
save();
|
|
6248
|
-
},
|
|
6249
|
-
delete: async (key) => {
|
|
6250
|
-
delete data[key];
|
|
6251
|
-
save();
|
|
6252
|
-
},
|
|
6253
|
-
clear: async () => {
|
|
6254
|
-
data = {};
|
|
6255
|
-
save();
|
|
6256
|
-
},
|
|
6257
|
-
keys: async () => Object.keys(data)
|
|
6258
|
-
});
|
|
6227
|
+
storageCache.set(pluginName, new PluginStorage(pluginName, STORAGE_DIR));
|
|
6259
6228
|
}
|
|
6260
6229
|
return storageCache.get(pluginName);
|
|
6261
6230
|
}
|
|
@@ -6352,6 +6321,10 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
6352
6321
|
session = await createSession(sessionName, params.url, {
|
|
6353
6322
|
cdpEndpoint: extraOpts?.cdpEndpoint
|
|
6354
6323
|
});
|
|
6324
|
+
} else if (command.scope === "browser") {
|
|
6325
|
+
session = await createSession(sessionName, void 0, {
|
|
6326
|
+
cdpEndpoint: extraOpts?.cdpEndpoint
|
|
6327
|
+
});
|
|
6355
6328
|
} else if (command.scope !== "project") {
|
|
6356
6329
|
return errorResult(
|
|
6357
6330
|
`Session '${sessionName}' not found. Run "xbrowser session open <url>" first.`
|
|
@@ -6960,7 +6933,7 @@ async function replayEntry(entry, options = {}) {
|
|
|
6960
6933
|
}
|
|
6961
6934
|
|
|
6962
6935
|
// src/daemon/feedback-store.ts
|
|
6963
|
-
import { readFileSync as
|
|
6936
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync5, mkdirSync as mkdirSync3 } from "fs";
|
|
6964
6937
|
import { join as join4 } from "path";
|
|
6965
6938
|
import { homedir as homedir4 } from "os";
|
|
6966
6939
|
var FEEDBACK_FILE = join4(homedir4(), ".xbrowser", "feedback.json");
|
|
@@ -6971,7 +6944,7 @@ var FeedbackStore = class {
|
|
|
6971
6944
|
}
|
|
6972
6945
|
load() {
|
|
6973
6946
|
try {
|
|
6974
|
-
const data =
|
|
6947
|
+
const data = readFileSync10(FEEDBACK_FILE, "utf8");
|
|
6975
6948
|
this.entries = JSON.parse(data);
|
|
6976
6949
|
} catch {
|
|
6977
6950
|
this.entries = [];
|
|
@@ -6979,8 +6952,8 @@ var FeedbackStore = class {
|
|
|
6979
6952
|
}
|
|
6980
6953
|
save() {
|
|
6981
6954
|
try {
|
|
6982
|
-
|
|
6983
|
-
|
|
6955
|
+
mkdirSync3(join4(homedir4(), ".xbrowser"), { recursive: true });
|
|
6956
|
+
writeFileSync5(FEEDBACK_FILE, JSON.stringify(this.entries, null, 2));
|
|
6984
6957
|
} catch {
|
|
6985
6958
|
}
|
|
6986
6959
|
}
|
|
@@ -7651,9 +7624,9 @@ function createRPCHandler() {
|
|
|
7651
7624
|
try {
|
|
7652
7625
|
const events = await sess.page.evaluate(() => window.__xb_evts || []);
|
|
7653
7626
|
const recordingsDir = join5(CONFIG_DIR, "recordings");
|
|
7654
|
-
|
|
7627
|
+
mkdirSync4(recordingsDir, { recursive: true });
|
|
7655
7628
|
const outPath = params.path || join5(recordingsDir, `recording-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.json`);
|
|
7656
|
-
|
|
7629
|
+
writeFileSync6(outPath, JSON.stringify({
|
|
7657
7630
|
startUrl: sess.page.url(),
|
|
7658
7631
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7659
7632
|
events
|
|
@@ -8706,10 +8679,10 @@ var WSServer = class extends EventEmitter {
|
|
|
8706
8679
|
}
|
|
8707
8680
|
case "file_download": {
|
|
8708
8681
|
try {
|
|
8709
|
-
const { readFileSync:
|
|
8682
|
+
const { readFileSync: readFileSync12 } = await import("fs");
|
|
8710
8683
|
const { resolve: resolve9, basename } = await import("path");
|
|
8711
8684
|
const targetPath = resolve9(msg.path);
|
|
8712
|
-
const data =
|
|
8685
|
+
const data = readFileSync12(targetPath);
|
|
8713
8686
|
const base64 = data.toString("base64");
|
|
8714
8687
|
const ext = targetPath.split(".").pop()?.toLowerCase() || "";
|
|
8715
8688
|
const mimeMap = {
|
|
@@ -10008,8 +9981,8 @@ async function main() {
|
|
|
10008
9981
|
rpcHandler.setPreviewWS(previewWS);
|
|
10009
9982
|
previewWS.on("screencast-started", (sid) => log(`Preview screencast started: ${sid}`));
|
|
10010
9983
|
previewWS.on("screencast-stopped", (sid) => log(`Preview screencast stopped: ${sid}`));
|
|
10011
|
-
|
|
10012
|
-
|
|
9984
|
+
mkdirSync5(CONFIG_DIR2, { recursive: true });
|
|
9985
|
+
writeFileSync7(join6(CONFIG_DIR2, "daemon.json"), JSON.stringify({
|
|
10013
9986
|
port: daemonPort,
|
|
10014
9987
|
pid: process.pid,
|
|
10015
9988
|
startedAt: Date.now()
|