@i14ks/ccv 0.46.0 → 0.47.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/THIRD-PARTY-NOTICES.md +1688 -461
- package/bundle/ccv.mjs +983 -147
- package/package.json +1 -1
- package/web/assets/MarkdownTextEditor-B3B8_rFw.js +60 -0
- package/web/assets/{abnfDiagram-S7VZAUFO-Bqp0keXX.js → abnfDiagram-S7VZAUFO-DJLBYC4E.js} +1 -1
- package/web/assets/{architectureDiagram-YGSQEFNW-QzTjlCie.js → architectureDiagram-YGSQEFNW-CjOULv4y.js} +1 -1
- package/web/assets/{blockDiagram-APKKGZFW-B2FjM_pa.js → blockDiagram-APKKGZFW-BxtAGaqL.js} +1 -1
- package/web/assets/{c4Diagram-KJ2TOQU5-CLtReqpv.js → c4Diagram-KJ2TOQU5-DixwjD35.js} +1 -1
- package/web/assets/{chunk-2Q5K7J3B-LzZPcVjw.js → chunk-2Q5K7J3B-D5RSYb7c.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-Bg9H60kN.js → chunk-5VM5RSS4-Zw9KRmHP.js} +1 -1
- package/web/assets/{chunk-HFQBQIA3-zN88yezm.js → chunk-HFQBQIA3-Dz3Jqjvc.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-puWxpX88.js → chunk-JWPE2WC7-CYC8lXvq.js} +1 -1
- package/web/assets/{chunk-KQLB2F66-LOgYMAbX.js → chunk-KQLB2F66-BpsntY2B.js} +2 -2
- package/web/assets/{chunk-KS47KZWR-DsV1l8GN.js → chunk-KS47KZWR-CIw-CgK1.js} +1 -1
- package/web/assets/{chunk-OY52VR5R-B-3a7aEt.js → chunk-OY52VR5R-DyNxKUIK.js} +1 -1
- package/web/assets/{chunk-TU62E6Q5-BBAw39la.js → chunk-TU62E6Q5-CHgxHE0R.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-CUUNDCi0.js → chunk-XXDRQBXY-CQ0zLLMg.js} +1 -1
- package/web/assets/{classDiagram-v2-L25IHNXF-BFB6qpyQ.js → classDiagram-v2-L25IHNXF-DyN77x6F.js} +1 -1
- package/web/assets/codemirror-Dh-4cMdO.js +1 -0
- package/web/assets/codemirrorImages-BHHbVBQN.js +1 -0
- package/web/assets/{cose-bilkent-JH36ORCC-h5GUpH0i.js → cose-bilkent-JH36ORCC-D1H3X9ot.js} +1 -1
- package/web/assets/{cynefin-EF2NZ3EQ-C0WBM4M-.js → cynefin-EF2NZ3EQ-B4SsJI8I.js} +1 -1
- package/web/assets/{cynefinDiagram-L36ESFBY-ojD4oji5.js → cynefinDiagram-L36ESFBY-D543PDJ4.js} +1 -1
- package/web/assets/{dagre-SPEB5RXH-kOXetVrP.js → dagre-SPEB5RXH-CksMpjx8.js} +1 -1
- package/web/assets/{diagram-3B7GL73J-Be_DXgKj.js → diagram-3B7GL73J-DywKf_aW.js} +1 -1
- package/web/assets/{diagram-DNEMPZML-DOaoUsOv.js → diagram-DNEMPZML-QaEKUl5W.js} +1 -1
- package/web/assets/{diagram-L3MUGCDN-Cxl9h2A1.js → diagram-L3MUGCDN-51y_ny8R.js} +1 -1
- package/web/assets/{diagram-LA4NIPWU-BuY_La_r.js → diagram-LA4NIPWU-Cg_nbBL_.js} +1 -1
- package/web/assets/{diagram-MHCOC4E2-DNHkV7oi.js → diagram-MHCOC4E2-DFHCPZYb.js} +1 -1
- package/web/assets/{diagram-XPFHEONP-DiWHVc5F.js → diagram-XPFHEONP-dBKRRNZa.js} +1 -1
- package/web/assets/{ebnfDiagram-UZSYDL2S-DDc7v0vH.js → ebnfDiagram-UZSYDL2S-BwTgNIAm.js} +1 -1
- package/web/assets/{elk-XV6XMXQE-ChA__87R.js → elk-XV6XMXQE-BR-xb3ob.js} +1 -1
- package/web/assets/{erDiagram-EYBAPDEH-9DkQVmpd.js → erDiagram-EYBAPDEH-BB1wg_fV.js} +1 -1
- package/web/assets/{flowDiagram-MALGAFMO-85oUCDA9.js → flowDiagram-MALGAFMO-CRDw4nX3.js} +1 -1
- package/web/assets/{ganttDiagram-23REXITY-Tzi438Ud.js → ganttDiagram-23REXITY-MYQEYJ-I.js} +1 -1
- package/web/assets/{gitGraphDiagram-STJD7YCW-DRHc1L8Y.js → gitGraphDiagram-STJD7YCW-Dhn0_pRI.js} +1 -1
- package/web/assets/{index-JfTN2Clg.js → index-7ivf0ID5.js} +1 -1
- package/web/assets/index-BJHr8-zK.js +1 -0
- package/web/assets/{index-D_HA9EKR.js → index-BJdwUs7I.js} +1 -1
- package/web/assets/index-BK9FAkRg.js +1 -0
- package/web/assets/index-BLLxsupM.js +13 -0
- package/web/assets/{index-2yPtUEjB.js → index-Bod45-bM.js} +2 -2
- package/web/assets/index-C13EW7hw.js +3 -0
- package/web/assets/index-CE1Pd4z7.js +7 -0
- package/web/assets/{index-D6OVWVvu.js → index-CaL1Ugw4.js} +1 -1
- package/web/assets/index-Cbs1XkJa.js +1 -0
- package/web/assets/index-DIouQVG8.js +1 -0
- package/web/assets/index-DRJgyVu5.js +1 -0
- package/web/assets/index-DaBTH0ea.js +1 -0
- package/web/assets/{index-fZsOIrjz.js → index-DlMbLAnE.js} +4 -4
- package/web/assets/index-DqLAItfN.js +1 -0
- package/web/assets/index-DqxhStF7.js +1 -0
- package/web/assets/index-DtR2v4RD.js +1 -0
- package/web/assets/{index-DdCA2bPh.js → index-DtwnaAnT.js} +2 -2
- package/web/assets/index-PAORgBv5.js +7 -0
- package/web/assets/index-Vcq4gwWv.js +1 -0
- package/web/assets/{index-B1REGe-R.css → index-eIS20v-m.css} +1 -1
- package/web/assets/index-gy3hTMSD.js +167 -0
- package/web/assets/index-v-BrSiuM.js +1 -0
- package/web/assets/{infoDiagram-KBXO4MBG-BffKyROV.js → infoDiagram-KBXO4MBG-By-j1Q2z.js} +1 -1
- package/web/assets/{ishikawaDiagram-M35NCXHK-37_pqbhO.js → ishikawaDiagram-M35NCXHK-Cj7pfKCW.js} +1 -1
- package/web/assets/{journeyDiagram-OPLOXDXO-B9E5pvMQ.js → journeyDiagram-OPLOXDXO-B7acuJLi.js} +1 -1
- package/web/assets/{kanban-definition-BZKZHSQY-hIyBxfyB.js → kanban-definition-BZKZHSQY-B0N1FM8N.js} +1 -1
- package/web/assets/{mermaid.core-ChOxnUYV.js → mermaid.core-Rt-JZroF.js} +5 -5
- package/web/assets/{mindmap-definition-I2QAS2VK-C4Ed0z-u.js → mindmap-definition-I2QAS2VK-Du6Bq1D4.js} +1 -1
- package/web/assets/{pegDiagram-FD4XPPHP-BgKeMkeu.js → pegDiagram-FD4XPPHP-Cx3y_VAW.js} +1 -1
- package/web/assets/{pieDiagram-J4AKIIQI-CBPbO_O4.js → pieDiagram-J4AKIIQI-DrpfcCiI.js} +1 -1
- package/web/assets/{quadrantDiagram-XTYBLID2-CFKGTA0q.js → quadrantDiagram-XTYBLID2-BbJ2d8x8.js} +1 -1
- package/web/assets/{railroadDiagram-MRQ6NCDL-BIwKP6FP.js → railroadDiagram-MRQ6NCDL-C8B9eHMq.js} +1 -1
- package/web/assets/{requirementDiagram-Y7LWUY3S-Big4Ix1i.js → requirementDiagram-Y7LWUY3S--8FcyGsP.js} +1 -1
- package/web/assets/{sankeyDiagram-WGJFYUXA-DCbAXigB.js → sankeyDiagram-WGJFYUXA-CYq-mQmD.js} +1 -1
- package/web/assets/{sequenceDiagram-5NDRBG5M-e3P8Am5E.js → sequenceDiagram-5NDRBG5M-C-Llg4wI.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-DKMlCS9Z.js → sizeCapture-INFHLROL-80lnJyWe.js} +1 -1
- package/web/assets/{stateDiagram-v2-FJ4FJNEA-CYUxk0oE.js → stateDiagram-v2-FJ4FJNEA-QZyfUycB.js} +1 -1
- package/web/assets/{swimlanes-UMQ2AFYF-GucEiYIi.js → swimlanes-UMQ2AFYF-BxT8Ql8H.js} +1 -1
- package/web/assets/swimlanesDiagram-OMPLPG4O-BZDLC88s.js +8 -0
- package/web/assets/{timeline-definition-SEUHKTQE-C-LrsvQ2.js → timeline-definition-SEUHKTQE-DWywP4r0.js} +4 -4
- package/web/assets/{usecaseDiagram-AFA6YXN4-0HNZ_Bga.js → usecaseDiagram-AFA6YXN4-BgmSQD90.js} +1 -1
- package/web/assets/{vennDiagram-NNMJR3RB-CdccvXeO.js → vennDiagram-NNMJR3RB-B9ikZp8F.js} +1 -1
- package/web/assets/{wardleyDiagram-S7YFUSEH-CvfIM8El.js → wardleyDiagram-S7YFUSEH-CptNVfVi.js} +1 -1
- package/web/assets/{xychartDiagram-GGNKY7IX-C6tfXUfl.js → xychartDiagram-GGNKY7IX-DV4TDhUT.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/codemirror-BUfL2BC4.js +0 -1
- package/web/assets/index-BvY8TANJ.js +0 -3
- package/web/assets/index-CK7BxYBP.js +0 -1
- package/web/assets/index-CL1z_ACK.js +0 -13
- package/web/assets/index-COYbUhJ2.js +0 -7
- package/web/assets/index-C_yOXZE5.js +0 -152
- package/web/assets/index-Ce51ELTJ.js +0 -1
- package/web/assets/index-CkWkBjEu.js +0 -1
- package/web/assets/index-Czfs4nks.js +0 -1
- package/web/assets/index-D7B78fBr.js +0 -1
- package/web/assets/index-D8prWI_9.js +0 -1
- package/web/assets/index-DSCMGgTU.js +0 -1
- package/web/assets/index-DnrCohlM.js +0 -1
- package/web/assets/index-Dxj5KidP.js +0 -7
- package/web/assets/index-dg0dwLUZ.js +0 -1
- package/web/assets/index-jon8dFyn.js +0 -1
- package/web/assets/swimlanesDiagram-OMPLPG4O-Bc0BkwRd.js +0 -8
package/bundle/ccv.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// dist/ccv.js
|
|
4
|
-
import { spawn as
|
|
5
|
-
import { readFile as
|
|
6
|
-
import
|
|
4
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
5
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
6
|
+
import path36 from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
|
|
@@ -145,9 +145,9 @@ function envDefaults() {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// ../host/dist/server.js
|
|
148
|
-
import { createServer } from "node:http";
|
|
148
|
+
import { createServer as createServer3 } from "node:http";
|
|
149
149
|
import { createReadStream as createReadStream2, existsSync as existsSync7, statSync as statSync3 } from "node:fs";
|
|
150
|
-
import
|
|
150
|
+
import path35 from "node:path";
|
|
151
151
|
import { homedir as homedir9 } from "node:os";
|
|
152
152
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
153
153
|
import { WebSocketServer } from "ws";
|
|
@@ -461,7 +461,7 @@ async function exists(file) {
|
|
|
461
461
|
return lstat(file).then(() => true, () => false);
|
|
462
462
|
}
|
|
463
463
|
async function isRealEntry(file) {
|
|
464
|
-
return lstat(file).then((
|
|
464
|
+
return lstat(file).then((stat7) => !stat7.isSymbolicLink(), () => false);
|
|
465
465
|
}
|
|
466
466
|
async function candidateConfigDirs() {
|
|
467
467
|
const home = homedir2();
|
|
@@ -786,12 +786,12 @@ function snippet(text, at, length) {
|
|
|
786
786
|
// ../host/dist/workspace-ids.js
|
|
787
787
|
function workspaceIdRemap(paths, sessionsOf) {
|
|
788
788
|
const byLegacy = /* @__PURE__ */ new Map();
|
|
789
|
-
for (const
|
|
790
|
-
const id = workspaceIdFromPath(
|
|
791
|
-
for (const legacy of formerWorkspaceIdsFromPath(
|
|
789
|
+
for (const path37 of paths) {
|
|
790
|
+
const id = workspaceIdFromPath(path37);
|
|
791
|
+
for (const legacy of formerWorkspaceIdsFromPath(path37)) {
|
|
792
792
|
const group = byLegacy.get(legacy) ?? [];
|
|
793
793
|
if (!group.some((target) => target.id === id))
|
|
794
|
-
group.push({ id, path:
|
|
794
|
+
group.push({ id, path: path37 });
|
|
795
795
|
byLegacy.set(legacy, group);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
@@ -966,6 +966,7 @@ var MEDIA_MIME = {
|
|
|
966
966
|
".mov": "video/quicktime",
|
|
967
967
|
".m4v": "video/mp4"
|
|
968
968
|
};
|
|
969
|
+
var MAX_BINARY_WRITE = 20 * 1024 * 1024;
|
|
969
970
|
var SNIFF = 8192;
|
|
970
971
|
var HIDDEN = /* @__PURE__ */ new Set([".git"]);
|
|
971
972
|
var SEARCH_SKIP = /* @__PURE__ */ new Set([...HIDDEN, "node_modules"]);
|
|
@@ -1255,6 +1256,20 @@ var ProjectFiles = class {
|
|
|
1255
1256
|
const saved = await stat3(file);
|
|
1256
1257
|
return { mtime: Math.round(saved.mtimeMs), size: saved.size };
|
|
1257
1258
|
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Записать новый двоичный файл — картинку, вставленную в .md из буфера.
|
|
1261
|
+
* Только создание: существующий файл не трогаем, имя выбирает окно с
|
|
1262
|
+
* отметкой времени, и совпадение значит ошибку, а не повод затереть.
|
|
1263
|
+
*/
|
|
1264
|
+
async writeBinary(relative, bytes) {
|
|
1265
|
+
if (bytes.length > MAX_BINARY_WRITE)
|
|
1266
|
+
throw new Error("\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F (\u0431\u043E\u043B\u044C\u0448\u0435 20 \u041C\u0411)");
|
|
1267
|
+
const target = await this.#resolve(relative);
|
|
1268
|
+
await mkdir2(path7.dirname(target), { recursive: true });
|
|
1269
|
+
await writeFile2(target, bytes, { flag: "wx" });
|
|
1270
|
+
const saved = await stat3(target);
|
|
1271
|
+
return { mtime: Math.round(saved.mtimeMs), size: saved.size };
|
|
1272
|
+
}
|
|
1258
1273
|
async create(relative, kind) {
|
|
1259
1274
|
const target = await this.#resolve(relative);
|
|
1260
1275
|
if (await exists2(target))
|
|
@@ -2303,6 +2318,10 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
2303
2318
|
get claudeSessionId() {
|
|
2304
2319
|
return this.#claudeSessionId;
|
|
2305
2320
|
}
|
|
2321
|
+
/** `id` — временный UUID, а не дисковый id продолженного разговора. */
|
|
2322
|
+
get hasTemporaryId() {
|
|
2323
|
+
return !this.#options.resume || this.#options.fork === true;
|
|
2324
|
+
}
|
|
2306
2325
|
get accountId() {
|
|
2307
2326
|
return this.#options.accountId ?? MAIN_ACCOUNT_ID;
|
|
2308
2327
|
}
|
|
@@ -7074,9 +7093,9 @@ function parsePatch(raw) {
|
|
|
7074
7093
|
body = "";
|
|
7075
7094
|
}
|
|
7076
7095
|
total += body.length;
|
|
7077
|
-
const
|
|
7096
|
+
const path37 = status === "deleted" ? oldPath : newPath || oldPath;
|
|
7078
7097
|
files.push({
|
|
7079
|
-
path:
|
|
7098
|
+
path: path37,
|
|
7080
7099
|
oldPath: status === "renamed" ? oldPath : "",
|
|
7081
7100
|
status,
|
|
7082
7101
|
added: count(body, "+"),
|
|
@@ -7088,10 +7107,10 @@ function parsePatch(raw) {
|
|
|
7088
7107
|
return { files, truncated };
|
|
7089
7108
|
}
|
|
7090
7109
|
function stripPrefix(value) {
|
|
7091
|
-
const
|
|
7092
|
-
if (
|
|
7110
|
+
const path37 = unquote(value.trim());
|
|
7111
|
+
if (path37 === "/dev/null")
|
|
7093
7112
|
return "";
|
|
7094
|
-
return
|
|
7113
|
+
return path37.replace(/^[ab]\//, "");
|
|
7095
7114
|
}
|
|
7096
7115
|
function count(body, mark) {
|
|
7097
7116
|
let n = 0;
|
|
@@ -7409,18 +7428,18 @@ var MemoryFiles = class {
|
|
|
7409
7428
|
const files = [];
|
|
7410
7429
|
for (const entry of await this.#entries()) {
|
|
7411
7430
|
const info = await stat4(entry.path).catch(() => null);
|
|
7412
|
-
const
|
|
7413
|
-
if (!
|
|
7431
|
+
const exists5 = Boolean(info?.isFile());
|
|
7432
|
+
if (!exists5 && !entry.creatable)
|
|
7414
7433
|
continue;
|
|
7415
7434
|
files.push({
|
|
7416
7435
|
id: entry.id,
|
|
7417
7436
|
scope: entry.scope,
|
|
7418
7437
|
label: entry.label,
|
|
7419
7438
|
path: entry.path,
|
|
7420
|
-
exists:
|
|
7421
|
-
size:
|
|
7422
|
-
mtime:
|
|
7423
|
-
deletable: entry.deletable &&
|
|
7439
|
+
exists: exists5,
|
|
7440
|
+
size: exists5 ? info.size : 0,
|
|
7441
|
+
mtime: exists5 ? Math.round(info.mtimeMs) : 0,
|
|
7442
|
+
deletable: entry.deletable && exists5
|
|
7424
7443
|
});
|
|
7425
7444
|
}
|
|
7426
7445
|
return files;
|
|
@@ -8236,19 +8255,761 @@ function isUnder(parent, child) {
|
|
|
8236
8255
|
return c === p || c.startsWith(`${p}${path20.sep}`.toLowerCase()) || c.startsWith(`${p}/`);
|
|
8237
8256
|
}
|
|
8238
8257
|
|
|
8239
|
-
// ../host/dist/
|
|
8240
|
-
import {
|
|
8258
|
+
// ../host/dist/site-proxy.js
|
|
8259
|
+
import { createServer, request as httpRequest } from "node:http";
|
|
8260
|
+
import { request as httpsRequest } from "node:https";
|
|
8261
|
+
import { connect as netConnect } from "node:net";
|
|
8262
|
+
import { connect as tlsConnect } from "node:tls";
|
|
8263
|
+
import { gunzipSync, brotliDecompressSync, inflateSync } from "node:zlib";
|
|
8264
|
+
|
|
8265
|
+
// ../host/dist/site-annotate-script.js
|
|
8266
|
+
var ANNOTATE_SCRIPT_PATH = "/__ccv/annotate.js";
|
|
8267
|
+
var ANNOTATE_SCRIPT = String.raw`(function () {
|
|
8268
|
+
if (window.__ccvAnnotate) return;
|
|
8269
|
+
window.__ccvAnnotate = true;
|
|
8270
|
+
var me = document.currentScript;
|
|
8271
|
+
var origin = (me && me.getAttribute('data-ccv-origin')) || '';
|
|
8272
|
+
var proxyOrigin = location.origin;
|
|
8273
|
+
var parentWin = window.parent;
|
|
8274
|
+
if (!parentWin || parentWin === window) return;
|
|
8275
|
+
|
|
8276
|
+
function realUrl() {
|
|
8277
|
+
var href = location.href;
|
|
8278
|
+
return origin && href.indexOf(proxyOrigin) === 0 ? origin + href.slice(proxyOrigin.length) : href;
|
|
8279
|
+
}
|
|
8280
|
+
function post(message) {
|
|
8281
|
+
message.source = 'ccv-site';
|
|
8282
|
+
try { parentWin.postMessage(message, '*'); } catch (e) {}
|
|
8283
|
+
}
|
|
8284
|
+
|
|
8285
|
+
var pick = false;
|
|
8286
|
+
var box = null;
|
|
8287
|
+
var label = null;
|
|
8288
|
+
var marksLayer = null;
|
|
8289
|
+
var marks = [];
|
|
8290
|
+
|
|
8291
|
+
function ensureUi() {
|
|
8292
|
+
if (box) return;
|
|
8293
|
+
box = document.createElement('div');
|
|
8294
|
+
box.setAttribute('data-ccv-ui', '');
|
|
8295
|
+
box.style.cssText = 'position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #d97757;background:rgba(217,119,87,.12);border-radius:3px;display:none;transition:all .05s linear';
|
|
8296
|
+
label = document.createElement('div');
|
|
8297
|
+
label.setAttribute('data-ccv-ui', '');
|
|
8298
|
+
label.style.cssText = 'position:fixed;pointer-events:none;z-index:2147483647;background:#1f1e1d;color:#faf9f5;font:500 11px/1.4 ui-monospace,Menlo,Consolas,monospace;padding:2px 6px;border-radius:4px;display:none;max-width:60vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis';
|
|
8299
|
+
marksLayer = document.createElement('div');
|
|
8300
|
+
marksLayer.setAttribute('data-ccv-ui', '');
|
|
8301
|
+
marksLayer.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483645';
|
|
8302
|
+
(document.body || document.documentElement).appendChild(marksLayer);
|
|
8303
|
+
(document.body || document.documentElement).appendChild(box);
|
|
8304
|
+
(document.body || document.documentElement).appendChild(label);
|
|
8305
|
+
}
|
|
8306
|
+
|
|
8307
|
+
function isUi(el) {
|
|
8308
|
+
return !!(el && el.closest && el.closest('[data-ccv-ui]'));
|
|
8309
|
+
}
|
|
8310
|
+
|
|
8311
|
+
function cssEscape(value) {
|
|
8312
|
+
if (window.CSS && CSS.escape) return CSS.escape(value);
|
|
8313
|
+
return String(value).replace(/[^a-zA-Z0-9_-]/g, function (c) { return '\\' + c; });
|
|
8314
|
+
}
|
|
8315
|
+
|
|
8316
|
+
function selectorOf(el) {
|
|
8317
|
+
if (!(el instanceof Element)) return '';
|
|
8318
|
+
var parts = [];
|
|
8319
|
+
var node = el;
|
|
8320
|
+
while (node && node.nodeType === 1 && node !== document.documentElement && parts.length < 6) {
|
|
8321
|
+
if (node.id && !/\d{3,}/.test(node.id)) {
|
|
8322
|
+
parts.unshift('#' + cssEscape(node.id));
|
|
8323
|
+
break;
|
|
8324
|
+
}
|
|
8325
|
+
var part = node.tagName.toLowerCase();
|
|
8326
|
+
var classes = Array.prototype.filter.call(node.classList, function (c) {
|
|
8327
|
+
return c.length < 32 && !/^(css|sc|jsx|svelte)-|[0-9a-f]{6,}|:/.test(c);
|
|
8328
|
+
}).slice(0, 2);
|
|
8329
|
+
if (classes.length) part += '.' + classes.map(cssEscape).join('.');
|
|
8330
|
+
var parent = node.parentElement;
|
|
8331
|
+
if (parent) {
|
|
8332
|
+
var same = Array.prototype.filter.call(parent.children, function (c) {
|
|
8333
|
+
return c.tagName === node.tagName;
|
|
8334
|
+
});
|
|
8335
|
+
if (same.length > 1) part += ':nth-of-type(' + (same.indexOf(node) + 1) + ')';
|
|
8336
|
+
}
|
|
8337
|
+
parts.unshift(part);
|
|
8338
|
+
node = parent;
|
|
8339
|
+
}
|
|
8340
|
+
return parts.join(' > ');
|
|
8341
|
+
}
|
|
8342
|
+
|
|
8343
|
+
/** Где элемент в исходниках: dev-сборка React кладёт это в fiber, плагины-инспекторы — в атрибуты. */
|
|
8344
|
+
function sourceOf(el) {
|
|
8345
|
+
var node = el;
|
|
8346
|
+
for (var depth = 0; node && depth < 8; depth++, node = node.parentElement) {
|
|
8347
|
+
var attr = node.getAttribute && (node.getAttribute('data-source') || node.getAttribute('data-inspector-relative-path') || node.getAttribute('data-locatorjs-id'));
|
|
8348
|
+
if (attr) {
|
|
8349
|
+
var line = node.getAttribute('data-inspector-line');
|
|
8350
|
+
return { file: attr + (line ? ':' + line : '') };
|
|
8351
|
+
}
|
|
8352
|
+
for (var key in node) {
|
|
8353
|
+
if (key.indexOf('__reactFiber$') !== 0 && key.indexOf('__reactInternalInstance$') !== 0) continue;
|
|
8354
|
+
var fiber = node[key];
|
|
8355
|
+
for (var hop = 0; fiber && hop < 12; hop++, fiber = fiber.return) {
|
|
8356
|
+
var src = fiber._debugSource;
|
|
8357
|
+
if (src && src.fileName) {
|
|
8358
|
+
var type = fiber.type;
|
|
8359
|
+
var name = type && (type.displayName || type.name);
|
|
8360
|
+
return { file: src.fileName + ':' + src.lineNumber, component: typeof name === 'string' ? name : undefined };
|
|
8361
|
+
}
|
|
8362
|
+
}
|
|
8363
|
+
break;
|
|
8364
|
+
}
|
|
8365
|
+
}
|
|
8366
|
+
return null;
|
|
8367
|
+
}
|
|
8368
|
+
|
|
8369
|
+
function describe(el) {
|
|
8370
|
+
var rect = el.getBoundingClientRect();
|
|
8371
|
+
var text = (el.innerText || el.textContent || '').replace(/\s+/g, ' ').trim();
|
|
8372
|
+
var html = el.outerHTML || '';
|
|
8373
|
+
var style = getComputedStyle(el);
|
|
8374
|
+
return {
|
|
8375
|
+
selector: selectorOf(el),
|
|
8376
|
+
tag: el.tagName.toLowerCase(),
|
|
8377
|
+
id: el.id || undefined,
|
|
8378
|
+
classes: Array.prototype.slice.call(el.classList, 0, 8),
|
|
8379
|
+
text: text.length > 160 ? text.slice(0, 157) + '…' : text,
|
|
8380
|
+
html: html.length > 500 ? html.slice(0, 497) + '…' : html,
|
|
8381
|
+
rect: { x: Math.round(rect.left), y: Math.round(rect.top), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
8382
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
8383
|
+
styles: { color: style.color, background: style.backgroundColor, font: style.fontSize + ' ' + style.fontWeight + ' ' + style.fontFamily.split(',')[0] },
|
|
8384
|
+
source: sourceOf(el) || undefined,
|
|
8385
|
+
url: realUrl()
|
|
8386
|
+
};
|
|
8387
|
+
}
|
|
8388
|
+
|
|
8389
|
+
function show(el) {
|
|
8390
|
+
ensureUi();
|
|
8391
|
+
if (!el || isUi(el)) { box.style.display = 'none'; label.style.display = 'none'; return; }
|
|
8392
|
+
var r = el.getBoundingClientRect();
|
|
8393
|
+
box.style.display = 'block';
|
|
8394
|
+
box.style.left = r.left + 'px'; box.style.top = r.top + 'px';
|
|
8395
|
+
box.style.width = r.width + 'px'; box.style.height = r.height + 'px';
|
|
8396
|
+
var name = el.tagName.toLowerCase() + (el.id ? '#' + el.id : '') + (el.classList.length ? '.' + Array.prototype.slice.call(el.classList, 0, 2).join('.') : '');
|
|
8397
|
+
label.textContent = name + ' ' + Math.round(r.width) + '×' + Math.round(r.height);
|
|
8398
|
+
label.style.display = 'block';
|
|
8399
|
+
label.style.left = Math.max(4, r.left) + 'px';
|
|
8400
|
+
label.style.top = (r.top > 24 ? r.top - 22 : r.bottom + 4) + 'px';
|
|
8401
|
+
}
|
|
8402
|
+
|
|
8403
|
+
function drawMarks() {
|
|
8404
|
+
ensureUi();
|
|
8405
|
+
marksLayer.innerHTML = '';
|
|
8406
|
+
marks.forEach(function (mark) {
|
|
8407
|
+
var el;
|
|
8408
|
+
try { el = document.querySelector(mark.selector); } catch (e) { el = null; }
|
|
8409
|
+
if (!el) return;
|
|
8410
|
+
var r = el.getBoundingClientRect();
|
|
8411
|
+
if (r.bottom < 0 || r.top > innerHeight) return;
|
|
8412
|
+
var dot = document.createElement('div');
|
|
8413
|
+
dot.textContent = String(mark.n);
|
|
8414
|
+
dot.style.cssText = 'position:fixed;min-width:20px;height:20px;padding:0 5px;box-sizing:border-box;border-radius:10px;background:#d97757;color:#fff;font:600 11px/20px system-ui,sans-serif;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.35);left:' + Math.max(2, r.left - 8) + 'px;top:' + Math.max(2, r.top - 8) + 'px';
|
|
8415
|
+
var outline = document.createElement('div');
|
|
8416
|
+
outline.style.cssText = 'position:fixed;border:1.5px dashed rgba(217,119,87,.8);border-radius:3px;left:' + r.left + 'px;top:' + r.top + 'px;width:' + r.width + 'px;height:' + r.height + 'px';
|
|
8417
|
+
marksLayer.appendChild(outline);
|
|
8418
|
+
marksLayer.appendChild(dot);
|
|
8419
|
+
});
|
|
8420
|
+
}
|
|
8421
|
+
|
|
8422
|
+
var raf = 0;
|
|
8423
|
+
function redrawSoon() {
|
|
8424
|
+
if (raf) return;
|
|
8425
|
+
raf = requestAnimationFrame(function () { raf = 0; drawMarks(); });
|
|
8426
|
+
}
|
|
8427
|
+
addEventListener('scroll', redrawSoon, true);
|
|
8428
|
+
addEventListener('resize', redrawSoon);
|
|
8429
|
+
|
|
8430
|
+
document.addEventListener('mousemove', function (e) {
|
|
8431
|
+
if (!pick) return;
|
|
8432
|
+
show(document.elementFromPoint(e.clientX, e.clientY));
|
|
8433
|
+
}, true);
|
|
8434
|
+
|
|
8435
|
+
function swallow(e) {
|
|
8436
|
+
if (!pick || isUi(e.target)) return;
|
|
8437
|
+
e.preventDefault();
|
|
8438
|
+
e.stopPropagation();
|
|
8439
|
+
e.stopImmediatePropagation();
|
|
8440
|
+
}
|
|
8441
|
+
['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'dblclick', 'contextmenu', 'submit'].forEach(function (type) {
|
|
8442
|
+
document.addEventListener(type, swallow, true);
|
|
8443
|
+
});
|
|
8444
|
+
document.addEventListener('click', function (e) {
|
|
8445
|
+
if (!pick || isUi(e.target)) return;
|
|
8446
|
+
swallow(e);
|
|
8447
|
+
var el = document.elementFromPoint(e.clientX, e.clientY);
|
|
8448
|
+
if (!el || isUi(el)) return;
|
|
8449
|
+
post({ type: 'picked', element: describe(el) });
|
|
8450
|
+
}, true);
|
|
8451
|
+
document.addEventListener('keydown', function (e) {
|
|
8452
|
+
if (pick && e.key === 'Escape') { e.preventDefault(); post({ type: 'cancel' }); }
|
|
8453
|
+
}, true);
|
|
8454
|
+
|
|
8455
|
+
addEventListener('message', function (e) {
|
|
8456
|
+
var data = e.data;
|
|
8457
|
+
if (!data || data.source !== 'ccv-app') return;
|
|
8458
|
+
if (data.type === 'mode') {
|
|
8459
|
+
pick = !!data.pick;
|
|
8460
|
+
document.documentElement.style.cursor = pick ? 'crosshair' : '';
|
|
8461
|
+
if (!pick) show(null);
|
|
8462
|
+
} else if (data.type === 'marks') {
|
|
8463
|
+
marks = Array.isArray(data.marks) ? data.marks : [];
|
|
8464
|
+
drawMarks();
|
|
8465
|
+
} else if (data.type === 'flash') {
|
|
8466
|
+
var el;
|
|
8467
|
+
try { el = document.querySelector(data.selector); } catch (err) { el = null; }
|
|
8468
|
+
if (el) { el.scrollIntoView({ block: 'center', behavior: 'smooth' }); setTimeout(function () { show(el); setTimeout(function () { if (!pick) show(null); }, 1200); }, 350); }
|
|
8469
|
+
}
|
|
8470
|
+
});
|
|
8471
|
+
|
|
8472
|
+
var lastUrl = '';
|
|
8473
|
+
function report(type) {
|
|
8474
|
+
var url = realUrl();
|
|
8475
|
+
if (type === 'location' && url === lastUrl) return;
|
|
8476
|
+
lastUrl = url;
|
|
8477
|
+
post({ type: type, url: url, title: document.title });
|
|
8478
|
+
}
|
|
8479
|
+
var push = history.pushState, replace = history.replaceState;
|
|
8480
|
+
history.pushState = function () { var r = push.apply(this, arguments); report('location'); redrawSoon(); return r; };
|
|
8481
|
+
history.replaceState = function () { var r = replace.apply(this, arguments); report('location'); return r; };
|
|
8482
|
+
addEventListener('popstate', function () { report('location'); redrawSoon(); });
|
|
8483
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { report('ready'); });
|
|
8484
|
+
else report('ready');
|
|
8485
|
+
new MutationObserver(function (records) {
|
|
8486
|
+
for (var i = 0; i < records.length; i++) if (!isUi(records[i].target) && records[i].target !== marksLayer) { redrawSoon(); return; }
|
|
8487
|
+
}).observe(document.documentElement, { childList: true, subtree: true });
|
|
8488
|
+
})();`;
|
|
8489
|
+
|
|
8490
|
+
// ../host/dist/site-proxy.js
|
|
8491
|
+
var DROP_RESPONSE = /* @__PURE__ */ new Set([
|
|
8492
|
+
"content-security-policy",
|
|
8493
|
+
"content-security-policy-report-only",
|
|
8494
|
+
"x-frame-options",
|
|
8495
|
+
"cross-origin-opener-policy",
|
|
8496
|
+
"cross-origin-embedder-policy",
|
|
8497
|
+
"cross-origin-resource-policy",
|
|
8498
|
+
"strict-transport-security",
|
|
8499
|
+
"alt-svc"
|
|
8500
|
+
]);
|
|
8501
|
+
var MAX_HTML = 16 * 1024 * 1024;
|
|
8502
|
+
var OriginProxy = class {
|
|
8503
|
+
origin;
|
|
8504
|
+
#target;
|
|
8505
|
+
#server;
|
|
8506
|
+
#proxyOrigin = "";
|
|
8507
|
+
#lastUsed = Date.now();
|
|
8508
|
+
constructor(origin) {
|
|
8509
|
+
this.origin = origin;
|
|
8510
|
+
this.#target = new URL(origin);
|
|
8511
|
+
this.#server = createServer((req, res) => this.#handle(req, res));
|
|
8512
|
+
this.#server.on("upgrade", (req, socket, head) => this.#upgrade(req, socket, head));
|
|
8513
|
+
this.#server.on("clientError", (_error, socket) => socket.destroy());
|
|
8514
|
+
}
|
|
8515
|
+
get proxyOrigin() {
|
|
8516
|
+
return this.#proxyOrigin;
|
|
8517
|
+
}
|
|
8518
|
+
get lastUsed() {
|
|
8519
|
+
return this.#lastUsed;
|
|
8520
|
+
}
|
|
8521
|
+
listen() {
|
|
8522
|
+
return new Promise((resolve, reject) => {
|
|
8523
|
+
this.#server.once("error", reject);
|
|
8524
|
+
this.#server.listen(0, "127.0.0.1", () => {
|
|
8525
|
+
const address = this.#server.address();
|
|
8526
|
+
this.#proxyOrigin = `http://127.0.0.1:${address.port}`;
|
|
8527
|
+
resolve();
|
|
8528
|
+
});
|
|
8529
|
+
});
|
|
8530
|
+
}
|
|
8531
|
+
close() {
|
|
8532
|
+
this.#server.close();
|
|
8533
|
+
this.#server.closeAllConnections?.();
|
|
8534
|
+
}
|
|
8535
|
+
#upstreamHeaders(headers) {
|
|
8536
|
+
const out = { ...headers };
|
|
8537
|
+
out.host = this.#target.host;
|
|
8538
|
+
out["accept-encoding"] = "gzip, deflate, br";
|
|
8539
|
+
for (const key of ["origin", "referer"]) {
|
|
8540
|
+
const value = out[key];
|
|
8541
|
+
if (typeof value === "string")
|
|
8542
|
+
out[key] = value.split(this.#proxyOrigin).join(this.origin);
|
|
8543
|
+
}
|
|
8544
|
+
return out;
|
|
8545
|
+
}
|
|
8546
|
+
#handle(req, res) {
|
|
8547
|
+
this.#lastUsed = Date.now();
|
|
8548
|
+
const url2 = req.url ?? "/";
|
|
8549
|
+
if (url2 === ANNOTATE_SCRIPT_PATH) {
|
|
8550
|
+
res.writeHead(200, {
|
|
8551
|
+
"content-type": "application/javascript; charset=utf-8",
|
|
8552
|
+
"cache-control": "no-store"
|
|
8553
|
+
});
|
|
8554
|
+
res.end(ANNOTATE_SCRIPT);
|
|
8555
|
+
return;
|
|
8556
|
+
}
|
|
8557
|
+
const send = this.#target.protocol === "https:" ? httpsRequest : httpRequest;
|
|
8558
|
+
const upstream = send({
|
|
8559
|
+
protocol: this.#target.protocol,
|
|
8560
|
+
hostname: this.#target.hostname,
|
|
8561
|
+
port: this.#target.port || void 0,
|
|
8562
|
+
method: req.method,
|
|
8563
|
+
path: url2,
|
|
8564
|
+
headers: this.#upstreamHeaders(req.headers)
|
|
8565
|
+
}, (response) => this.#respond(response, res));
|
|
8566
|
+
upstream.on("error", (error) => {
|
|
8567
|
+
if (res.headersSent) {
|
|
8568
|
+
res.destroy();
|
|
8569
|
+
return;
|
|
8570
|
+
}
|
|
8571
|
+
res.writeHead(502, { "content-type": "text/plain; charset=utf-8" });
|
|
8572
|
+
res.end(`Claude Code Visual: \u0441\u0430\u0439\u0442 ${this.origin} \u043D\u0435 \u043E\u0442\u0432\u0435\u0442\u0438\u043B \u2014 ${error.message}`);
|
|
8573
|
+
});
|
|
8574
|
+
req.pipe(upstream);
|
|
8575
|
+
}
|
|
8576
|
+
#respond(response, res) {
|
|
8577
|
+
const headers = {};
|
|
8578
|
+
for (const [key, value] of Object.entries(response.headers)) {
|
|
8579
|
+
if (value === void 0 || DROP_RESPONSE.has(key))
|
|
8580
|
+
continue;
|
|
8581
|
+
headers[key] = value;
|
|
8582
|
+
}
|
|
8583
|
+
const location = response.headers.location;
|
|
8584
|
+
if (location)
|
|
8585
|
+
headers.location = this.#rewriteUrl(location);
|
|
8586
|
+
const cookies = response.headers["set-cookie"];
|
|
8587
|
+
if (cookies)
|
|
8588
|
+
headers["set-cookie"] = cookies.map(relaxCookie);
|
|
8589
|
+
const type = String(response.headers["content-type"] ?? "");
|
|
8590
|
+
const status = response.statusCode ?? 502;
|
|
8591
|
+
if (!type.includes("text/html") || status === 204 || status === 304) {
|
|
8592
|
+
res.writeHead(status, response.statusMessage, headers);
|
|
8593
|
+
response.pipe(res);
|
|
8594
|
+
return;
|
|
8595
|
+
}
|
|
8596
|
+
const chunks = [];
|
|
8597
|
+
let size = 0;
|
|
8598
|
+
let overflow = false;
|
|
8599
|
+
response.on("data", (chunk) => {
|
|
8600
|
+
size += chunk.length;
|
|
8601
|
+
if (size > MAX_HTML)
|
|
8602
|
+
overflow = true;
|
|
8603
|
+
if (!overflow)
|
|
8604
|
+
chunks.push(chunk);
|
|
8605
|
+
});
|
|
8606
|
+
response.on("end", () => {
|
|
8607
|
+
if (overflow) {
|
|
8608
|
+
res.writeHead(502, { "content-type": "text/plain; charset=utf-8" });
|
|
8609
|
+
res.end("Claude Code Visual: \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F \u0434\u043B\u044F \u0440\u0435\u0436\u0438\u043C\u0430 \u043F\u0440\u0430\u0432\u043E\u043A");
|
|
8610
|
+
return;
|
|
8611
|
+
}
|
|
8612
|
+
let html;
|
|
8613
|
+
try {
|
|
8614
|
+
html = decode2(Buffer.concat(chunks), String(response.headers["content-encoding"] ?? ""));
|
|
8615
|
+
} catch {
|
|
8616
|
+
res.writeHead(status, response.statusMessage, headers);
|
|
8617
|
+
res.end(Buffer.concat(chunks));
|
|
8618
|
+
return;
|
|
8619
|
+
}
|
|
8620
|
+
const body = Buffer.from(this.#inject(html), "utf8");
|
|
8621
|
+
delete headers["content-encoding"];
|
|
8622
|
+
delete headers["content-length"];
|
|
8623
|
+
delete headers["transfer-encoding"];
|
|
8624
|
+
delete headers.etag;
|
|
8625
|
+
headers["content-length"] = body.length;
|
|
8626
|
+
headers["cache-control"] = "no-store";
|
|
8627
|
+
res.writeHead(status, response.statusMessage, headers);
|
|
8628
|
+
res.end(body);
|
|
8629
|
+
});
|
|
8630
|
+
response.on("error", () => res.destroy());
|
|
8631
|
+
}
|
|
8632
|
+
/**
|
|
8633
|
+
* Скрипт выбора элементов — первым в `<head>`, и абсолютные ссылки страницы
|
|
8634
|
+
* на свой же origin — на прокси: иначе переход по такой ссылке увёл бы
|
|
8635
|
+
* iframe на настоящий сайт, где скрипта нет.
|
|
8636
|
+
*/
|
|
8637
|
+
#inject(html) {
|
|
8638
|
+
const rewritten = html.split(this.origin + "/").join(this.#proxyOrigin + "/").split(this.origin.replace(/^https?:/, "") + "/").join(this.#proxyOrigin.replace(/^http:/, "") + "/");
|
|
8639
|
+
const tag = `<script src="${ANNOTATE_SCRIPT_PATH}" data-ccv-origin="${this.origin}"></script>`;
|
|
8640
|
+
const head = /<head[^>]*>/i.exec(rewritten);
|
|
8641
|
+
if (head) {
|
|
8642
|
+
const at = head.index + head[0].length;
|
|
8643
|
+
return rewritten.slice(0, at) + tag + rewritten.slice(at);
|
|
8644
|
+
}
|
|
8645
|
+
const htmlTag = /<html[^>]*>/i.exec(rewritten);
|
|
8646
|
+
if (htmlTag) {
|
|
8647
|
+
const at = htmlTag.index + htmlTag[0].length;
|
|
8648
|
+
return rewritten.slice(0, at) + tag + rewritten.slice(at);
|
|
8649
|
+
}
|
|
8650
|
+
return tag + rewritten;
|
|
8651
|
+
}
|
|
8652
|
+
#rewriteUrl(value) {
|
|
8653
|
+
if (value.startsWith(this.origin))
|
|
8654
|
+
return this.#proxyOrigin + value.slice(this.origin.length);
|
|
8655
|
+
return value;
|
|
8656
|
+
}
|
|
8657
|
+
/** Вебсокеты (горячая перезагрузка dev-сервера) — сырым туннелем до сайта. */
|
|
8658
|
+
#upgrade(req, socket, head) {
|
|
8659
|
+
this.#lastUsed = Date.now();
|
|
8660
|
+
const secure = this.#target.protocol === "https:";
|
|
8661
|
+
const port2 = Number(this.#target.port || (secure ? 443 : 80));
|
|
8662
|
+
const upstream = secure ? tlsConnect({ host: this.#target.hostname, port: port2, servername: this.#target.hostname }) : netConnect({ host: this.#target.hostname, port: port2 });
|
|
8663
|
+
upstream.once(secure ? "secureConnect" : "connect", () => {
|
|
8664
|
+
const headers = this.#upstreamHeaders(req.headers);
|
|
8665
|
+
const lines = [`${req.method ?? "GET"} ${req.url ?? "/"} HTTP/1.1`];
|
|
8666
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8667
|
+
if (value === void 0)
|
|
8668
|
+
continue;
|
|
8669
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
8670
|
+
lines.push(`${key}: ${item}`);
|
|
8671
|
+
}
|
|
8672
|
+
upstream.write(lines.join("\r\n") + "\r\n\r\n");
|
|
8673
|
+
if (head.length > 0)
|
|
8674
|
+
upstream.write(head);
|
|
8675
|
+
upstream.pipe(socket);
|
|
8676
|
+
socket.pipe(upstream);
|
|
8677
|
+
});
|
|
8678
|
+
const drop = () => {
|
|
8679
|
+
upstream.destroy();
|
|
8680
|
+
socket.destroy();
|
|
8681
|
+
};
|
|
8682
|
+
upstream.on("error", drop);
|
|
8683
|
+
socket.on("error", drop);
|
|
8684
|
+
}
|
|
8685
|
+
};
|
|
8686
|
+
function decode2(body, encoding) {
|
|
8687
|
+
const kind = encoding.trim().toLowerCase();
|
|
8688
|
+
if (kind === "gzip" || kind === "x-gzip")
|
|
8689
|
+
return gunzipSync(body).toString("utf8");
|
|
8690
|
+
if (kind === "br")
|
|
8691
|
+
return brotliDecompressSync(body).toString("utf8");
|
|
8692
|
+
if (kind === "deflate")
|
|
8693
|
+
return inflateSync(body).toString("utf8");
|
|
8694
|
+
return body.toString("utf8");
|
|
8695
|
+
}
|
|
8696
|
+
function relaxCookie(cookie) {
|
|
8697
|
+
return cookie.split(";").map((part) => part.trim()).filter((part) => !/^(domain|secure|partitioned)(=|$)/i.test(part)).map((part) => /^samesite=none$/i.test(part) ? "SameSite=Lax" : part).join("; ");
|
|
8698
|
+
}
|
|
8699
|
+
function normalizeSiteUrl(raw) {
|
|
8700
|
+
const text = raw.trim();
|
|
8701
|
+
if (!text)
|
|
8702
|
+
throw new Error("\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0441\u0430\u0439\u0442\u0430");
|
|
8703
|
+
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(text) ? text : /^(localhost|127\.|0\.0\.0\.0|\[::1\]|\d+\.\d+\.\d+\.\d+)/i.test(text) ? `http://${text}` : `https://${text}`;
|
|
8704
|
+
const url2 = new URL(withScheme);
|
|
8705
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
8706
|
+
throw new Error("\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u043C\u043E\u0436\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u0434\u0440\u0435\u0441 http:// \u0438\u043B\u0438 https://");
|
|
8707
|
+
}
|
|
8708
|
+
return url2;
|
|
8709
|
+
}
|
|
8710
|
+
var SiteProxies = class {
|
|
8711
|
+
#byOrigin = /* @__PURE__ */ new Map();
|
|
8712
|
+
#idleMs;
|
|
8713
|
+
#sweep = null;
|
|
8714
|
+
constructor(idleMs = 30 * 60 * 1e3) {
|
|
8715
|
+
this.#idleMs = idleMs;
|
|
8716
|
+
}
|
|
8717
|
+
/** Поднять (или взять готовый) прокси и вернуть адрес страницы через него. */
|
|
8718
|
+
async open(raw) {
|
|
8719
|
+
const url2 = normalizeSiteUrl(raw);
|
|
8720
|
+
let proxy = this.#byOrigin.get(url2.origin);
|
|
8721
|
+
if (!proxy) {
|
|
8722
|
+
proxy = new OriginProxy(url2.origin);
|
|
8723
|
+
await proxy.listen();
|
|
8724
|
+
this.#byOrigin.set(url2.origin, proxy);
|
|
8725
|
+
this.#startSweep();
|
|
8726
|
+
}
|
|
8727
|
+
return {
|
|
8728
|
+
url: url2.href,
|
|
8729
|
+
origin: url2.origin,
|
|
8730
|
+
proxyOrigin: proxy.proxyOrigin,
|
|
8731
|
+
proxyUrl: proxy.proxyOrigin + url2.pathname + url2.search + url2.hash
|
|
8732
|
+
};
|
|
8733
|
+
}
|
|
8734
|
+
closeAll() {
|
|
8735
|
+
for (const proxy of this.#byOrigin.values())
|
|
8736
|
+
proxy.close();
|
|
8737
|
+
this.#byOrigin.clear();
|
|
8738
|
+
if (this.#sweep)
|
|
8739
|
+
clearInterval(this.#sweep);
|
|
8740
|
+
this.#sweep = null;
|
|
8741
|
+
}
|
|
8742
|
+
#startSweep() {
|
|
8743
|
+
if (this.#sweep)
|
|
8744
|
+
return;
|
|
8745
|
+
this.#sweep = setInterval(() => {
|
|
8746
|
+
const now = Date.now();
|
|
8747
|
+
for (const [origin, proxy] of this.#byOrigin) {
|
|
8748
|
+
if (now - proxy.lastUsed < this.#idleMs)
|
|
8749
|
+
continue;
|
|
8750
|
+
proxy.close();
|
|
8751
|
+
this.#byOrigin.delete(origin);
|
|
8752
|
+
}
|
|
8753
|
+
if (this.#byOrigin.size === 0 && this.#sweep) {
|
|
8754
|
+
clearInterval(this.#sweep);
|
|
8755
|
+
this.#sweep = null;
|
|
8756
|
+
}
|
|
8757
|
+
}, 60 * 1e3);
|
|
8758
|
+
this.#sweep.unref();
|
|
8759
|
+
}
|
|
8760
|
+
};
|
|
8761
|
+
|
|
8762
|
+
// ../host/dist/video-studio.js
|
|
8763
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
8764
|
+
import { readdir as readdir6, readFile as readFile11, stat as stat5 } from "node:fs/promises";
|
|
8765
|
+
import { createServer as createServer2 } from "node:net";
|
|
8241
8766
|
import path21 from "node:path";
|
|
8767
|
+
var VIDEO_EXT = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov", ".m4v", ".mkv", ".ogv", ".gif"]);
|
|
8768
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "_deps", "vendor", "third_party", ".git", ".next", ".nuxt", ".cache", ".turbo", ".venv", "__pycache__"]);
|
|
8769
|
+
var MAX_DEPTH = 8;
|
|
8770
|
+
var MAX_ENTRIES = 2e4;
|
|
8771
|
+
var MAX_ANIMATION_BYTES = 512 * 1024;
|
|
8772
|
+
var ANIMATION_HINT = /@keyframes|\bgsap\b|anime\(|\.animate\(|<canvas|lottie|three(\.module)?\.js|animation\s*:/i;
|
|
8773
|
+
var REMOTION_DEPS = ["remotion", "@remotion/cli"];
|
|
8774
|
+
var ENTRY_CANDIDATES = [
|
|
8775
|
+
"src/index.ts",
|
|
8776
|
+
"src/index.tsx",
|
|
8777
|
+
"src/index.js",
|
|
8778
|
+
"src/remotion/index.ts",
|
|
8779
|
+
"src/remotion/index.tsx",
|
|
8780
|
+
"remotion/index.ts",
|
|
8781
|
+
"remotion/index.tsx"
|
|
8782
|
+
];
|
|
8783
|
+
function toRelative(root, file) {
|
|
8784
|
+
return path21.relative(root, file).split(path21.sep).join("/");
|
|
8785
|
+
}
|
|
8786
|
+
async function exists3(file) {
|
|
8787
|
+
return stat5(file).then(() => true, () => false);
|
|
8788
|
+
}
|
|
8789
|
+
async function remotionEntry(dir, pkg) {
|
|
8790
|
+
for (const script of Object.values(pkg.scripts ?? {})) {
|
|
8791
|
+
const match = /remotion\s+(?:studio|preview|render)\s+([^\s]+\.(?:tsx?|jsx?))/.exec(script);
|
|
8792
|
+
if (match?.[1] && await exists3(path21.join(dir, match[1])))
|
|
8793
|
+
return match[1].replace(/\\/g, "/");
|
|
8794
|
+
}
|
|
8795
|
+
for (const candidate of ENTRY_CANDIDATES) {
|
|
8796
|
+
if (await exists3(path21.join(dir, candidate)))
|
|
8797
|
+
return candidate;
|
|
8798
|
+
}
|
|
8799
|
+
return null;
|
|
8800
|
+
}
|
|
8801
|
+
async function scanVideoCatalog(root) {
|
|
8802
|
+
const videos = [];
|
|
8803
|
+
const animations = [];
|
|
8804
|
+
const remotion = [];
|
|
8805
|
+
let seen = 0;
|
|
8806
|
+
let truncated = false;
|
|
8807
|
+
async function walk(dir, depth) {
|
|
8808
|
+
if (depth > MAX_DEPTH || truncated)
|
|
8809
|
+
return;
|
|
8810
|
+
let entries;
|
|
8811
|
+
try {
|
|
8812
|
+
entries = await readdir6(dir, { withFileTypes: true });
|
|
8813
|
+
} catch {
|
|
8814
|
+
return;
|
|
8815
|
+
}
|
|
8816
|
+
for (const entry of entries) {
|
|
8817
|
+
if (++seen > MAX_ENTRIES) {
|
|
8818
|
+
truncated = true;
|
|
8819
|
+
return;
|
|
8820
|
+
}
|
|
8821
|
+
const full = path21.join(dir, entry.name);
|
|
8822
|
+
if (entry.isDirectory()) {
|
|
8823
|
+
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
8824
|
+
continue;
|
|
8825
|
+
await walk(full, depth + 1);
|
|
8826
|
+
continue;
|
|
8827
|
+
}
|
|
8828
|
+
if (!entry.isFile())
|
|
8829
|
+
continue;
|
|
8830
|
+
const ext = path21.extname(entry.name).toLowerCase();
|
|
8831
|
+
if (VIDEO_EXT.has(ext)) {
|
|
8832
|
+
const info = await stat5(full).catch(() => null);
|
|
8833
|
+
if (info)
|
|
8834
|
+
videos.push({ path: toRelative(root, full), size: info.size, mtime: Math.round(info.mtimeMs) });
|
|
8835
|
+
} else if (ext === ".html" || ext === ".htm") {
|
|
8836
|
+
const info = await stat5(full).catch(() => null);
|
|
8837
|
+
if (!info || info.size > MAX_ANIMATION_BYTES)
|
|
8838
|
+
continue;
|
|
8839
|
+
const text = await readFile11(full, "utf8").catch(() => "");
|
|
8840
|
+
if (ANIMATION_HINT.test(text)) {
|
|
8841
|
+
animations.push({ path: toRelative(root, full), size: info.size, mtime: Math.round(info.mtimeMs) });
|
|
8842
|
+
}
|
|
8843
|
+
} else if (entry.name === "package.json") {
|
|
8844
|
+
try {
|
|
8845
|
+
const pkg = JSON.parse(await readFile11(full, "utf8"));
|
|
8846
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
8847
|
+
if (!REMOTION_DEPS.some((name) => name in deps))
|
|
8848
|
+
continue;
|
|
8849
|
+
const entryFile = await remotionEntry(dir, pkg);
|
|
8850
|
+
remotion.push({
|
|
8851
|
+
root: toRelative(root, dir) || ".",
|
|
8852
|
+
name: pkg.name ?? path21.basename(dir),
|
|
8853
|
+
entry: entryFile,
|
|
8854
|
+
installed: await exists3(path21.join(dir, "node_modules", "remotion"))
|
|
8855
|
+
});
|
|
8856
|
+
} catch {
|
|
8857
|
+
}
|
|
8858
|
+
}
|
|
8859
|
+
}
|
|
8860
|
+
}
|
|
8861
|
+
await walk(root, 0);
|
|
8862
|
+
videos.sort((a, b) => b.mtime - a.mtime);
|
|
8863
|
+
animations.sort((a, b) => b.mtime - a.mtime);
|
|
8864
|
+
return { videos, animations, remotion, truncated };
|
|
8865
|
+
}
|
|
8866
|
+
function freePort() {
|
|
8867
|
+
return new Promise((resolve, reject) => {
|
|
8868
|
+
const server2 = createServer2();
|
|
8869
|
+
server2.once("error", reject);
|
|
8870
|
+
server2.listen(0, "127.0.0.1", () => {
|
|
8871
|
+
const { port: port2 } = server2.address();
|
|
8872
|
+
server2.close(() => resolve(port2));
|
|
8873
|
+
});
|
|
8874
|
+
});
|
|
8875
|
+
}
|
|
8876
|
+
var READY_TIMEOUT_MS = 3 * 60 * 1e3;
|
|
8877
|
+
var LOG_LINES = 40;
|
|
8878
|
+
var RemotionStudios = class {
|
|
8879
|
+
#studios = /* @__PURE__ */ new Map();
|
|
8880
|
+
#emit;
|
|
8881
|
+
constructor(emit) {
|
|
8882
|
+
this.#emit = emit;
|
|
8883
|
+
}
|
|
8884
|
+
states(workspaceId) {
|
|
8885
|
+
return [...this.#studios.values()].filter((s) => s.workspaceId === workspaceId).map((s) => s.state);
|
|
8886
|
+
}
|
|
8887
|
+
async start(workspaceId, workspacePath, root, entry) {
|
|
8888
|
+
const key = `${workspaceId}\0${root}`;
|
|
8889
|
+
const running2 = this.#studios.get(key);
|
|
8890
|
+
if (running2 && (running2.state.status === "starting" || running2.state.status === "ready")) {
|
|
8891
|
+
this.#emit(running2.state);
|
|
8892
|
+
return;
|
|
8893
|
+
}
|
|
8894
|
+
const dir = path21.resolve(workspacePath, root);
|
|
8895
|
+
const relative = path21.relative(workspacePath, dir);
|
|
8896
|
+
if (relative.startsWith("..") || path21.isAbsolute(relative))
|
|
8897
|
+
throw new Error("\u041F\u0440\u043E\u0435\u043A\u0442 Remotion \u0432\u043D\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u0430");
|
|
8898
|
+
const port2 = await freePort();
|
|
8899
|
+
const args = ["remotion", "studio", ...entry ? [entry] : [], "--port", String(port2)];
|
|
8900
|
+
const studio = {
|
|
8901
|
+
key,
|
|
8902
|
+
workspaceId,
|
|
8903
|
+
root,
|
|
8904
|
+
child: null,
|
|
8905
|
+
log: [],
|
|
8906
|
+
state: { workspaceId, root, status: "starting", url: `http://localhost:${port2}` }
|
|
8907
|
+
};
|
|
8908
|
+
this.#studios.set(key, studio);
|
|
8909
|
+
this.#emit(studio.state);
|
|
8910
|
+
const child = spawn4("npx", args, {
|
|
8911
|
+
cwd: dir,
|
|
8912
|
+
// `BROWSER=none` — Studio не открывает вкладку сама: её покажет окно.
|
|
8913
|
+
env: { ...process.env, BROWSER: "none", FORCE_COLOR: "0" },
|
|
8914
|
+
shell: process.platform === "win32",
|
|
8915
|
+
windowsHide: true
|
|
8916
|
+
});
|
|
8917
|
+
studio.child = child;
|
|
8918
|
+
const onData = (chunk) => {
|
|
8919
|
+
for (const line of chunk.toString("utf8").split(/\r?\n/)) {
|
|
8920
|
+
const clean = line.replace(/\u001b\[[0-9;]*[A-Za-z]/g, "").trimEnd();
|
|
8921
|
+
if (!clean)
|
|
8922
|
+
continue;
|
|
8923
|
+
studio.log.push(clean);
|
|
8924
|
+
if (studio.log.length > LOG_LINES)
|
|
8925
|
+
studio.log.shift();
|
|
8926
|
+
}
|
|
8927
|
+
};
|
|
8928
|
+
child.stdout?.on("data", onData);
|
|
8929
|
+
child.stderr?.on("data", onData);
|
|
8930
|
+
child.on("error", (error) => this.#fail(studio, error.message));
|
|
8931
|
+
child.on("exit", (code) => {
|
|
8932
|
+
studio.child = null;
|
|
8933
|
+
if (studio.state.status === "stopped")
|
|
8934
|
+
return;
|
|
8935
|
+
this.#fail(studio, `Remotion Studio \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0430\u0441\u044C (\u043A\u043E\u0434 ${code ?? "\u2014"})`);
|
|
8936
|
+
});
|
|
8937
|
+
void this.#waitReady(studio, port2);
|
|
8938
|
+
}
|
|
8939
|
+
stop(workspaceId, root) {
|
|
8940
|
+
const studio = this.#studios.get(`${workspaceId}\0${root}`);
|
|
8941
|
+
if (!studio)
|
|
8942
|
+
return;
|
|
8943
|
+
studio.state = { workspaceId, root, status: "stopped" };
|
|
8944
|
+
this.#kill(studio);
|
|
8945
|
+
this.#studios.delete(studio.key);
|
|
8946
|
+
this.#emit(studio.state);
|
|
8947
|
+
}
|
|
8948
|
+
stopAll() {
|
|
8949
|
+
for (const studio of this.#studios.values()) {
|
|
8950
|
+
studio.state = { ...studio.state, status: "stopped" };
|
|
8951
|
+
this.#kill(studio);
|
|
8952
|
+
}
|
|
8953
|
+
this.#studios.clear();
|
|
8954
|
+
}
|
|
8955
|
+
#kill(studio) {
|
|
8956
|
+
const child = studio.child;
|
|
8957
|
+
if (!child?.pid)
|
|
8958
|
+
return;
|
|
8959
|
+
studio.child = null;
|
|
8960
|
+
if (process.platform === "win32") {
|
|
8961
|
+
spawn4("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true }).on("error", () => {
|
|
8962
|
+
});
|
|
8963
|
+
} else {
|
|
8964
|
+
child.kill("SIGTERM");
|
|
8965
|
+
}
|
|
8966
|
+
}
|
|
8967
|
+
#fail(studio, message) {
|
|
8968
|
+
if (studio.state.status === "failed" || studio.state.status === "stopped")
|
|
8969
|
+
return;
|
|
8970
|
+
studio.state = {
|
|
8971
|
+
workspaceId: studio.workspaceId,
|
|
8972
|
+
root: studio.root,
|
|
8973
|
+
status: "failed",
|
|
8974
|
+
message,
|
|
8975
|
+
log: studio.log.slice(-12)
|
|
8976
|
+
};
|
|
8977
|
+
this.#kill(studio);
|
|
8978
|
+
this.#emit(studio.state);
|
|
8979
|
+
}
|
|
8980
|
+
async #waitReady(studio, port2) {
|
|
8981
|
+
const started = Date.now();
|
|
8982
|
+
while (Date.now() - started < READY_TIMEOUT_MS) {
|
|
8983
|
+
if (studio.state.status !== "starting")
|
|
8984
|
+
return;
|
|
8985
|
+
try {
|
|
8986
|
+
const response = await fetch(`http://127.0.0.1:${port2}/`, { signal: AbortSignal.timeout(2e3) });
|
|
8987
|
+
if (response.ok || response.status < 500) {
|
|
8988
|
+
studio.state = { ...studio.state, status: "ready" };
|
|
8989
|
+
this.#emit(studio.state);
|
|
8990
|
+
return;
|
|
8991
|
+
}
|
|
8992
|
+
} catch {
|
|
8993
|
+
}
|
|
8994
|
+
await new Promise((resolve) => setTimeout(resolve, 700));
|
|
8995
|
+
}
|
|
8996
|
+
this.#fail(studio, "Remotion Studio \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0430\u0441\u044C \u0437\u0430 3 \u043C\u0438\u043D\u0443\u0442\u044B");
|
|
8997
|
+
}
|
|
8998
|
+
};
|
|
8999
|
+
|
|
9000
|
+
// ../host/dist/archive.js
|
|
9001
|
+
import { mkdir as mkdir10, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
|
|
9002
|
+
import path22 from "node:path";
|
|
8242
9003
|
var SessionArchive = class {
|
|
8243
9004
|
#archived = /* @__PURE__ */ new Map();
|
|
8244
9005
|
#restored = /* @__PURE__ */ new Map();
|
|
8245
9006
|
#storePath;
|
|
8246
9007
|
constructor(dataDir) {
|
|
8247
|
-
this.#storePath =
|
|
9008
|
+
this.#storePath = path22.join(dataDir, "session-archive.json");
|
|
8248
9009
|
}
|
|
8249
9010
|
async load() {
|
|
8250
9011
|
try {
|
|
8251
|
-
const raw = await
|
|
9012
|
+
const raw = await readFile12(this.#storePath, "utf8");
|
|
8252
9013
|
const parsed = JSON.parse(raw);
|
|
8253
9014
|
this.#archived = new Map(Object.entries(parsed.archived ?? {}).filter(([, r]) => isRecord2(r)));
|
|
8254
9015
|
this.#restored = new Map(Object.entries(parsed.restored ?? {}).filter((entry) => typeof entry[1] === "number"));
|
|
@@ -8356,7 +9117,7 @@ var SessionArchive = class {
|
|
|
8356
9117
|
archived: Object.fromEntries(this.#archived),
|
|
8357
9118
|
restored: Object.fromEntries(this.#restored)
|
|
8358
9119
|
};
|
|
8359
|
-
await mkdir10(
|
|
9120
|
+
await mkdir10(path22.dirname(this.#storePath), { recursive: true });
|
|
8360
9121
|
await writeFile11(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
8361
9122
|
}
|
|
8362
9123
|
};
|
|
@@ -8365,8 +9126,8 @@ function isRecord2(value) {
|
|
|
8365
9126
|
}
|
|
8366
9127
|
|
|
8367
9128
|
// ../host/dist/pins.js
|
|
8368
|
-
import { mkdir as mkdir11, readFile as
|
|
8369
|
-
import
|
|
9129
|
+
import { mkdir as mkdir11, readFile as readFile13, writeFile as writeFile12 } from "node:fs/promises";
|
|
9130
|
+
import path23 from "node:path";
|
|
8370
9131
|
var SessionPins = class {
|
|
8371
9132
|
#pinned = /* @__PURE__ */ new Map();
|
|
8372
9133
|
/**
|
|
@@ -8381,11 +9142,11 @@ var SessionPins = class {
|
|
|
8381
9142
|
#moved = /* @__PURE__ */ new Map();
|
|
8382
9143
|
#storePath;
|
|
8383
9144
|
constructor(dataDir) {
|
|
8384
|
-
this.#storePath =
|
|
9145
|
+
this.#storePath = path23.join(dataDir, "session-pins.json");
|
|
8385
9146
|
}
|
|
8386
9147
|
async load() {
|
|
8387
9148
|
try {
|
|
8388
|
-
const raw = await
|
|
9149
|
+
const raw = await readFile13(this.#storePath, "utf8");
|
|
8389
9150
|
const parsed = JSON.parse(raw);
|
|
8390
9151
|
this.#pinned = new Map(Object.entries(parsed.pinned ?? {}).filter(([, r]) => isRecord3(r)));
|
|
8391
9152
|
this.#moved = new Map(Object.entries(parsed.moved ?? {}).filter(([, to]) => typeof to === "string"));
|
|
@@ -8538,7 +9299,7 @@ var SessionPins = class {
|
|
|
8538
9299
|
pinned: Object.fromEntries(this.#pinned),
|
|
8539
9300
|
...this.#moved.size > 0 ? { moved: Object.fromEntries(this.#moved) } : {}
|
|
8540
9301
|
};
|
|
8541
|
-
await mkdir11(
|
|
9302
|
+
await mkdir11(path23.dirname(this.#storePath), { recursive: true });
|
|
8542
9303
|
await writeFile12(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
8543
9304
|
}
|
|
8544
9305
|
};
|
|
@@ -8547,17 +9308,17 @@ function isRecord3(value) {
|
|
|
8547
9308
|
}
|
|
8548
9309
|
|
|
8549
9310
|
// ../host/dist/order.js
|
|
8550
|
-
import { mkdir as mkdir12, readFile as
|
|
8551
|
-
import
|
|
9311
|
+
import { mkdir as mkdir12, readFile as readFile14, writeFile as writeFile13 } from "node:fs/promises";
|
|
9312
|
+
import path24 from "node:path";
|
|
8552
9313
|
var ListOrderStore = class {
|
|
8553
9314
|
#order = emptyOrder();
|
|
8554
9315
|
#storePath;
|
|
8555
9316
|
constructor(dataDir) {
|
|
8556
|
-
this.#storePath =
|
|
9317
|
+
this.#storePath = path24.join(dataDir, "list-order.json");
|
|
8557
9318
|
}
|
|
8558
9319
|
async load() {
|
|
8559
9320
|
try {
|
|
8560
|
-
const raw = await
|
|
9321
|
+
const raw = await readFile14(this.#storePath, "utf8");
|
|
8561
9322
|
this.#order = sanitize(JSON.parse(raw));
|
|
8562
9323
|
} catch {
|
|
8563
9324
|
this.#order = emptyOrder();
|
|
@@ -8629,7 +9390,7 @@ var ListOrderStore = class {
|
|
|
8629
9390
|
return changed;
|
|
8630
9391
|
}
|
|
8631
9392
|
async #persist() {
|
|
8632
|
-
await mkdir12(
|
|
9393
|
+
await mkdir12(path24.dirname(this.#storePath), { recursive: true });
|
|
8633
9394
|
await writeFile13(this.#storePath, JSON.stringify(this.#order, null, 2), "utf8");
|
|
8634
9395
|
}
|
|
8635
9396
|
};
|
|
@@ -8659,8 +9420,8 @@ function sanitize(value) {
|
|
|
8659
9420
|
}
|
|
8660
9421
|
|
|
8661
9422
|
// ../host/dist/folders.js
|
|
8662
|
-
import { mkdir as mkdir13, readFile as
|
|
8663
|
-
import
|
|
9423
|
+
import { mkdir as mkdir13, readFile as readFile15, writeFile as writeFile14 } from "node:fs/promises";
|
|
9424
|
+
import path25 from "node:path";
|
|
8664
9425
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
8665
9426
|
var COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
8666
9427
|
var Folders = class {
|
|
@@ -8672,11 +9433,11 @@ var Folders = class {
|
|
|
8672
9433
|
#pinnedAssignments = /* @__PURE__ */ new Map();
|
|
8673
9434
|
#storePath;
|
|
8674
9435
|
constructor(dataDir) {
|
|
8675
|
-
this.#storePath =
|
|
9436
|
+
this.#storePath = path25.join(dataDir, "folders.json");
|
|
8676
9437
|
}
|
|
8677
9438
|
async load() {
|
|
8678
9439
|
try {
|
|
8679
|
-
const raw = await
|
|
9440
|
+
const raw = await readFile15(this.#storePath, "utf8");
|
|
8680
9441
|
const parsed = JSON.parse(raw);
|
|
8681
9442
|
this.#workspaceFolders = new Map(Object.entries(parsed.workspaceFolders ?? {}).filter(([, r]) => isWorkspaceFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
8682
9443
|
this.#sessionFolders = new Map(Object.entries(parsed.sessionFolders ?? {}).filter(([, r]) => isSessionFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
@@ -8994,7 +9755,7 @@ var Folders = class {
|
|
|
8994
9755
|
sessionAssignments: Object.fromEntries(this.#sessionAssignments),
|
|
8995
9756
|
pinnedAssignments: Object.fromEntries(this.#pinnedAssignments)
|
|
8996
9757
|
};
|
|
8997
|
-
await mkdir13(
|
|
9758
|
+
await mkdir13(path25.dirname(this.#storePath), { recursive: true });
|
|
8998
9759
|
await writeFile14(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
8999
9760
|
}
|
|
9000
9761
|
};
|
|
@@ -9017,29 +9778,29 @@ function isPinnedFolder(value) {
|
|
|
9017
9778
|
|
|
9018
9779
|
// ../host/dist/project-folders.js
|
|
9019
9780
|
import { existsSync as existsSync6, watch } from "node:fs";
|
|
9020
|
-
import { mkdir as mkdir14, readdir as
|
|
9021
|
-
import
|
|
9781
|
+
import { mkdir as mkdir14, readdir as readdir8, rmdir } from "node:fs/promises";
|
|
9782
|
+
import path27 from "node:path";
|
|
9022
9783
|
|
|
9023
9784
|
// ../host/dist/project-move.js
|
|
9024
9785
|
import { existsSync as existsSync5 } from "node:fs";
|
|
9025
|
-
import { readFile as
|
|
9786
|
+
import { readFile as readFile16, readdir as readdir7, rename as rename2, stat as stat6 } from "node:fs/promises";
|
|
9026
9787
|
import { homedir as homedir6 } from "node:os";
|
|
9027
|
-
import
|
|
9788
|
+
import path26 from "node:path";
|
|
9028
9789
|
var ACTIVE_WINDOW_MS = 2 * 6e4;
|
|
9029
9790
|
function transcriptDirName(cwd) {
|
|
9030
9791
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
9031
9792
|
}
|
|
9032
9793
|
function isInside(parent, child) {
|
|
9033
|
-
const norm = (value) =>
|
|
9794
|
+
const norm = (value) => path26.resolve(value).replace(/[\\/]+$/, "").toLowerCase();
|
|
9034
9795
|
const p = norm(parent);
|
|
9035
9796
|
const c = norm(child);
|
|
9036
|
-
return c === p || c.startsWith(p +
|
|
9797
|
+
return c === p || c.startsWith(p + path26.sep.toLowerCase()) || c.startsWith(`${p}/`);
|
|
9037
9798
|
}
|
|
9038
9799
|
async function externalAgentActivity(dirs, configDirs, now = Date.now()) {
|
|
9039
9800
|
for (const dir of dirs) {
|
|
9040
9801
|
const name = transcriptDirName(dir);
|
|
9041
9802
|
for (const config of configDirs) {
|
|
9042
|
-
const t = await newestMtime(
|
|
9803
|
+
const t = await newestMtime(path26.join(config, "projects", name), 1);
|
|
9043
9804
|
if (t !== null && now - t < ACTIVE_WINDOW_MS)
|
|
9044
9805
|
return "Claude Code";
|
|
9045
9806
|
}
|
|
@@ -9052,13 +9813,13 @@ async function newestMtime(dir, depth) {
|
|
|
9052
9813
|
let newest = null;
|
|
9053
9814
|
let entries;
|
|
9054
9815
|
try {
|
|
9055
|
-
entries = await
|
|
9816
|
+
entries = await readdir7(dir);
|
|
9056
9817
|
} catch {
|
|
9057
9818
|
return null;
|
|
9058
9819
|
}
|
|
9059
9820
|
for (const entry of entries) {
|
|
9060
|
-
const file =
|
|
9061
|
-
const info = await
|
|
9821
|
+
const file = path26.join(dir, entry);
|
|
9822
|
+
const info = await stat6(file).catch(() => null);
|
|
9062
9823
|
if (!info)
|
|
9063
9824
|
continue;
|
|
9064
9825
|
if (info.isDirectory()) {
|
|
@@ -9075,22 +9836,22 @@ async function newestMtime(dir, depth) {
|
|
|
9075
9836
|
return newest;
|
|
9076
9837
|
}
|
|
9077
9838
|
async function codexActive(dirs, now) {
|
|
9078
|
-
const root =
|
|
9839
|
+
const root = path26.join(process.env.CODEX_HOME?.trim() || path26.join(homedir6(), ".codex"), "sessions");
|
|
9079
9840
|
const days = /* @__PURE__ */ new Set();
|
|
9080
9841
|
for (const offset of [0, 1]) {
|
|
9081
9842
|
const d = new Date(now - offset * 864e5);
|
|
9082
|
-
days.add(
|
|
9843
|
+
days.add(path26.join(root, String(d.getFullYear()), String(d.getMonth() + 1).padStart(2, "0"), String(d.getDate()).padStart(2, "0")));
|
|
9083
9844
|
}
|
|
9084
9845
|
for (const day of days) {
|
|
9085
|
-
const files = await
|
|
9846
|
+
const files = await readdir7(day).catch(() => []);
|
|
9086
9847
|
for (const name of files) {
|
|
9087
9848
|
if (!name.endsWith(".jsonl"))
|
|
9088
9849
|
continue;
|
|
9089
|
-
const file =
|
|
9090
|
-
const info = await
|
|
9850
|
+
const file = path26.join(day, name);
|
|
9851
|
+
const info = await stat6(file).catch(() => null);
|
|
9091
9852
|
if (!info || now - info.mtimeMs >= ACTIVE_WINDOW_MS)
|
|
9092
9853
|
continue;
|
|
9093
|
-
const head = (await
|
|
9854
|
+
const head = (await readFile16(file, "utf8").catch(() => "")).slice(0, 4e3);
|
|
9094
9855
|
const text = head.replace(/\\\\/g, "\\").toLowerCase();
|
|
9095
9856
|
if (dirs.some((dir) => text.includes(dir.toLowerCase()) || head.includes(dir.replace(/\\/g, "\\\\")))) {
|
|
9096
9857
|
return true;
|
|
@@ -9113,10 +9874,10 @@ async function moveDirectory(from, to, projects, configDirs) {
|
|
|
9113
9874
|
throw new Error("\u041D\u0435\u043B\u044C\u0437\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u0441\u0442\u0438\u0442\u044C \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0432\u043D\u0443\u0442\u0440\u044C \u0441\u0430\u043C\u043E\u0433\u043E \u0441\u0435\u0431\u044F");
|
|
9114
9875
|
const transcripts = [];
|
|
9115
9876
|
for (const project of projects) {
|
|
9116
|
-
const next =
|
|
9877
|
+
const next = path26.join(to, path26.relative(from, project));
|
|
9117
9878
|
for (const config of configDirs) {
|
|
9118
|
-
const source =
|
|
9119
|
-
const target =
|
|
9879
|
+
const source = path26.join(config, "projects", transcriptDirName(project));
|
|
9880
|
+
const target = path26.join(config, "projects", transcriptDirName(next));
|
|
9120
9881
|
if (!existsSync5(source))
|
|
9121
9882
|
continue;
|
|
9122
9883
|
if (existsSync5(target)) {
|
|
@@ -9167,45 +9928,45 @@ function cleanFolderName(raw) {
|
|
|
9167
9928
|
return name;
|
|
9168
9929
|
}
|
|
9169
9930
|
async function listDiskFolders(root, projectPaths) {
|
|
9170
|
-
const projects = new Set(projectPaths.map((p) =>
|
|
9171
|
-
const entries = await
|
|
9931
|
+
const projects = new Set(projectPaths.map((p) => path27.resolve(p).toLowerCase()));
|
|
9932
|
+
const entries = await readdir8(root, { withFileTypes: true }).catch(() => []);
|
|
9172
9933
|
const names2 = [];
|
|
9173
9934
|
for (const entry of entries) {
|
|
9174
9935
|
if (!entry.isDirectory() || entry.name.startsWith(".") || SKIP.has(entry.name.toLowerCase()))
|
|
9175
9936
|
continue;
|
|
9176
|
-
const dir =
|
|
9177
|
-
if (projects.has(
|
|
9937
|
+
const dir = path27.join(root, entry.name);
|
|
9938
|
+
if (projects.has(path27.resolve(dir).toLowerCase()))
|
|
9178
9939
|
continue;
|
|
9179
|
-
if (existsSync6(
|
|
9940
|
+
if (existsSync6(path27.join(dir, ".git")))
|
|
9180
9941
|
continue;
|
|
9181
9942
|
names2.push(entry.name);
|
|
9182
9943
|
}
|
|
9183
9944
|
return names2.sort((a, b) => a.localeCompare(b));
|
|
9184
9945
|
}
|
|
9185
9946
|
async function listUnopened(dir, projectPaths, limit = 200) {
|
|
9186
|
-
const projects = new Set(projectPaths.map((p) =>
|
|
9187
|
-
const entries = await
|
|
9188
|
-
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".") && !SKIP.has(e.name.toLowerCase())).map((e) => ({ name: e.name, path:
|
|
9947
|
+
const projects = new Set(projectPaths.map((p) => path27.resolve(p).toLowerCase()));
|
|
9948
|
+
const entries = await readdir8(dir, { withFileTypes: true }).catch(() => []);
|
|
9949
|
+
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".") && !SKIP.has(e.name.toLowerCase())).map((e) => ({ name: e.name, path: path27.join(dir, e.name) })).filter((e) => !projects.has(path27.resolve(e.path).toLowerCase())).sort((a, b) => a.name.localeCompare(b.name)).slice(0, limit);
|
|
9189
9950
|
}
|
|
9190
9951
|
function folderOfProject(root, projectPath, folders) {
|
|
9191
|
-
const parent =
|
|
9192
|
-
if (
|
|
9952
|
+
const parent = path27.dirname(path27.resolve(projectPath));
|
|
9953
|
+
if (path27.resolve(path27.dirname(parent)).toLowerCase() !== path27.resolve(root).toLowerCase())
|
|
9193
9954
|
return null;
|
|
9194
|
-
const name =
|
|
9955
|
+
const name = path27.basename(parent);
|
|
9195
9956
|
return folders.has(name) ? folderIdFor(name) : null;
|
|
9196
9957
|
}
|
|
9197
9958
|
async function createDiskFolder(root, rawName) {
|
|
9198
9959
|
const name = cleanFolderName(rawName);
|
|
9199
|
-
const dir =
|
|
9960
|
+
const dir = path27.join(root, name);
|
|
9200
9961
|
if (existsSync6(dir))
|
|
9201
9962
|
throw new Error(`\u0423\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442: ${dir}`);
|
|
9202
9963
|
await mkdir14(dir, { recursive: true });
|
|
9203
9964
|
return name;
|
|
9204
9965
|
}
|
|
9205
9966
|
async function foreignContent(dir, projectPaths) {
|
|
9206
|
-
const projects = new Set(projectPaths.map((p) =>
|
|
9207
|
-
for (const entry of await
|
|
9208
|
-
if (!projects.has(
|
|
9967
|
+
const projects = new Set(projectPaths.map((p) => path27.resolve(p).toLowerCase()));
|
|
9968
|
+
for (const entry of await readdir8(dir).catch(() => [])) {
|
|
9969
|
+
if (!projects.has(path27.resolve(path27.join(dir, entry)).toLowerCase()))
|
|
9209
9970
|
return entry;
|
|
9210
9971
|
}
|
|
9211
9972
|
return null;
|
|
@@ -9231,9 +9992,9 @@ function watchRoot(root, onChange) {
|
|
|
9231
9992
|
}
|
|
9232
9993
|
|
|
9233
9994
|
// ../host/dist/app-settings.js
|
|
9234
|
-
import { mkdir as mkdir15, readFile as
|
|
9995
|
+
import { mkdir as mkdir15, readFile as readFile17, writeFile as writeFile15 } from "node:fs/promises";
|
|
9235
9996
|
import { homedir as homedir7 } from "node:os";
|
|
9236
|
-
import
|
|
9997
|
+
import path28 from "node:path";
|
|
9237
9998
|
var DEFAULT_AUTO_ARCHIVE_AFTER_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
9238
9999
|
var MIN_AUTO_ARCHIVE_AFTER_MS = 60 * 60 * 1e3;
|
|
9239
10000
|
var DEFAULT_AUTO_STOP_AFTER_MS = 10 * 60 * 1e3;
|
|
@@ -9290,11 +10051,11 @@ var AppSettingsStore = class {
|
|
|
9290
10051
|
#settings = { ...DEFAULT_APP_SETTINGS };
|
|
9291
10052
|
#storePath;
|
|
9292
10053
|
constructor(dataDir) {
|
|
9293
|
-
this.#storePath =
|
|
10054
|
+
this.#storePath = path28.join(dataDir, "app-settings.json");
|
|
9294
10055
|
}
|
|
9295
10056
|
async load() {
|
|
9296
10057
|
try {
|
|
9297
|
-
const raw = await
|
|
10058
|
+
const raw = await readFile17(this.#storePath, "utf8");
|
|
9298
10059
|
this.#settings = sanitize2(JSON.parse(raw), DEFAULT_APP_SETTINGS);
|
|
9299
10060
|
} catch {
|
|
9300
10061
|
this.#settings = { ...DEFAULT_APP_SETTINGS };
|
|
@@ -9314,7 +10075,7 @@ var AppSettingsStore = class {
|
|
|
9314
10075
|
async update(patch) {
|
|
9315
10076
|
const next = sanitize2(patch, this.#settings);
|
|
9316
10077
|
this.#settings = next;
|
|
9317
|
-
await mkdir15(
|
|
10078
|
+
await mkdir15(path28.dirname(this.#storePath), { recursive: true });
|
|
9318
10079
|
await writeFile15(this.#storePath, JSON.stringify(next, null, 2), "utf8");
|
|
9319
10080
|
return this.current;
|
|
9320
10081
|
}
|
|
@@ -9390,7 +10151,7 @@ function sanitize2(value, fallback) {
|
|
|
9390
10151
|
return result;
|
|
9391
10152
|
}
|
|
9392
10153
|
function claudeHome() {
|
|
9393
|
-
return
|
|
10154
|
+
return path28.join(homedir7(), ".claude");
|
|
9394
10155
|
}
|
|
9395
10156
|
function writableRoots(mode, cwd, workspacePaths) {
|
|
9396
10157
|
if (mode === "all")
|
|
@@ -9400,7 +10161,7 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
9400
10161
|
return [...roots];
|
|
9401
10162
|
for (const workspace of [cwd, ...workspacePaths]) {
|
|
9402
10163
|
roots.add(workspace);
|
|
9403
|
-
const parent =
|
|
10164
|
+
const parent = path28.dirname(workspace);
|
|
9404
10165
|
if (parent !== workspace)
|
|
9405
10166
|
roots.add(parent);
|
|
9406
10167
|
}
|
|
@@ -9408,19 +10169,19 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
9408
10169
|
}
|
|
9409
10170
|
|
|
9410
10171
|
// ../host/dist/handoff-store.js
|
|
9411
|
-
import { mkdir as mkdir16, readFile as
|
|
9412
|
-
import
|
|
10172
|
+
import { mkdir as mkdir16, readFile as readFile18, readdir as readdir9, rm as rm5, writeFile as writeFile16 } from "node:fs/promises";
|
|
10173
|
+
import path29 from "node:path";
|
|
9413
10174
|
var HandoffStore = class {
|
|
9414
10175
|
#dir;
|
|
9415
10176
|
constructor(dataDir) {
|
|
9416
|
-
this.#dir =
|
|
10177
|
+
this.#dir = path29.join(dataDir, "handoffs");
|
|
9417
10178
|
}
|
|
9418
10179
|
async get(sessionId) {
|
|
9419
10180
|
const file = this.#file(sessionId);
|
|
9420
10181
|
if (!file)
|
|
9421
10182
|
return null;
|
|
9422
10183
|
try {
|
|
9423
|
-
const parsed = JSON.parse(await
|
|
10184
|
+
const parsed = JSON.parse(await readFile18(file, "utf8"));
|
|
9424
10185
|
return typeof parsed.text === "string" ? parsed : null;
|
|
9425
10186
|
} catch {
|
|
9426
10187
|
return null;
|
|
@@ -9441,7 +10202,7 @@ var HandoffStore = class {
|
|
|
9441
10202
|
/** id всех сохранённых хэндоффов. */
|
|
9442
10203
|
async list() {
|
|
9443
10204
|
try {
|
|
9444
|
-
return (await
|
|
10205
|
+
return (await readdir9(this.#dir)).filter((name) => name.endsWith(".json")).map((name) => name.slice(0, -".json".length));
|
|
9445
10206
|
} catch {
|
|
9446
10207
|
return [];
|
|
9447
10208
|
}
|
|
@@ -9450,7 +10211,7 @@ var HandoffStore = class {
|
|
|
9450
10211
|
#file(sessionId) {
|
|
9451
10212
|
if (!/^[\w-]{1,128}$/.test(sessionId))
|
|
9452
10213
|
return null;
|
|
9453
|
-
return
|
|
10214
|
+
return path29.join(this.#dir, `${sessionId}.json`);
|
|
9454
10215
|
}
|
|
9455
10216
|
};
|
|
9456
10217
|
var SAME_WINDOW_MS = 5 * 6e4;
|
|
@@ -9459,11 +10220,11 @@ var LimitStopState = class {
|
|
|
9459
10220
|
#fired = {};
|
|
9460
10221
|
#storePath;
|
|
9461
10222
|
constructor(dataDir) {
|
|
9462
|
-
this.#storePath =
|
|
10223
|
+
this.#storePath = path29.join(dataDir, "limit-stop.json");
|
|
9463
10224
|
}
|
|
9464
10225
|
async load() {
|
|
9465
10226
|
try {
|
|
9466
|
-
const parsed = JSON.parse(await
|
|
10227
|
+
const parsed = JSON.parse(await readFile18(this.#storePath, "utf8"));
|
|
9467
10228
|
this.#fired = {};
|
|
9468
10229
|
const read = (source) => {
|
|
9469
10230
|
const out = {};
|
|
@@ -9507,7 +10268,7 @@ var LimitStopState = class {
|
|
|
9507
10268
|
}
|
|
9508
10269
|
async #mark(account, limit, until) {
|
|
9509
10270
|
this.#fired[account] = { ...this.#fired[account], [limit]: until };
|
|
9510
|
-
await mkdir16(
|
|
10271
|
+
await mkdir16(path29.dirname(this.#storePath), { recursive: true });
|
|
9511
10272
|
const { [MAIN_ACCOUNT_ID]: main = {}, ...others } = this.#fired;
|
|
9512
10273
|
await writeFile16(this.#storePath, JSON.stringify({ ...main, ...others }, null, 2), "utf8");
|
|
9513
10274
|
}
|
|
@@ -9613,9 +10374,9 @@ function capitalize(text) {
|
|
|
9613
10374
|
}
|
|
9614
10375
|
|
|
9615
10376
|
// ../host/dist/plugins.js
|
|
9616
|
-
import { readFile as
|
|
10377
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
9617
10378
|
import { homedir as homedir8 } from "node:os";
|
|
9618
|
-
import
|
|
10379
|
+
import path30 from "node:path";
|
|
9619
10380
|
var TIMEOUT_MS2 = 12e4;
|
|
9620
10381
|
var SAFE_ARG = /^[A-Za-z0-9][A-Za-z0-9._@/-]*$/;
|
|
9621
10382
|
var PluginCli = class {
|
|
@@ -9714,10 +10475,10 @@ async function readCatalog(markets, installed) {
|
|
|
9714
10475
|
return lists.flat().sort((a, b) => a.name.localeCompare(b.name));
|
|
9715
10476
|
}
|
|
9716
10477
|
async function readMarketplace(market, installed) {
|
|
9717
|
-
const root = market.installLocation ||
|
|
10478
|
+
const root = market.installLocation || path30.join(homedir8(), ".claude", "plugins", "marketplaces", market.name);
|
|
9718
10479
|
let manifest;
|
|
9719
10480
|
try {
|
|
9720
|
-
const text = await
|
|
10481
|
+
const text = await readFile19(path30.join(root, ".claude-plugin", "marketplace.json"), "utf8");
|
|
9721
10482
|
manifest = JSON.parse(text);
|
|
9722
10483
|
} catch {
|
|
9723
10484
|
return [];
|
|
@@ -9969,8 +10730,8 @@ function describe6(error) {
|
|
|
9969
10730
|
|
|
9970
10731
|
// ../host/dist/relay-link.js
|
|
9971
10732
|
import { EventEmitter as EventEmitter7 } from "node:events";
|
|
9972
|
-
import { readFile as
|
|
9973
|
-
import
|
|
10733
|
+
import { readFile as readFile20, writeFile as writeFile17, rm as rm6, mkdir as mkdir17 } from "node:fs/promises";
|
|
10734
|
+
import path31 from "node:path";
|
|
9974
10735
|
import { hostname } from "node:os";
|
|
9975
10736
|
import WebSocket from "ws";
|
|
9976
10737
|
|
|
@@ -10025,7 +10786,7 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
10025
10786
|
#log;
|
|
10026
10787
|
constructor(options2) {
|
|
10027
10788
|
super();
|
|
10028
|
-
this.#file =
|
|
10789
|
+
this.#file = path31.join(options2.dataDir, "relay.json");
|
|
10029
10790
|
this.#defaultUrl = options2.defaultUrl.replace(/\/+$/, "");
|
|
10030
10791
|
this.#log = options2.log ?? ((msg) => console.log(`[relay] ${msg}`));
|
|
10031
10792
|
}
|
|
@@ -10106,7 +10867,7 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
10106
10867
|
}
|
|
10107
10868
|
async #read() {
|
|
10108
10869
|
try {
|
|
10109
|
-
const raw = await
|
|
10870
|
+
const raw = await readFile20(this.#file, "utf8");
|
|
10110
10871
|
const parsed = JSON.parse(raw);
|
|
10111
10872
|
if (typeof parsed !== "object" || parsed === null)
|
|
10112
10873
|
return null;
|
|
@@ -10119,7 +10880,7 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
10119
10880
|
}
|
|
10120
10881
|
}
|
|
10121
10882
|
async #write(credentials) {
|
|
10122
|
-
await mkdir17(
|
|
10883
|
+
await mkdir17(path31.dirname(this.#file), { recursive: true });
|
|
10123
10884
|
await writeFile17(this.#file, `${JSON.stringify(credentials, null, 2)}
|
|
10124
10885
|
`, {
|
|
10125
10886
|
encoding: "utf8",
|
|
@@ -10377,7 +11138,7 @@ function humanize(error) {
|
|
|
10377
11138
|
// ../host/dist/terminal.js
|
|
10378
11139
|
import { EventEmitter as EventEmitter8 } from "node:events";
|
|
10379
11140
|
import { access as access2, constants as constants2 } from "node:fs/promises";
|
|
10380
|
-
import
|
|
11141
|
+
import path32 from "node:path";
|
|
10381
11142
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
10382
11143
|
var SCROLLBACK_BYTES = 256 * 1024;
|
|
10383
11144
|
var FLUSH_MS = 12;
|
|
@@ -10547,35 +11308,35 @@ async function defaultShell() {
|
|
|
10547
11308
|
if (pwsh)
|
|
10548
11309
|
return { file: pwsh, args: [], title: "pwsh" };
|
|
10549
11310
|
const system = process.env.SystemRoot ?? "C:\\Windows";
|
|
10550
|
-
const powershell =
|
|
10551
|
-
if (await
|
|
11311
|
+
const powershell = path32.join(system, "System32/WindowsPowerShell/v1.0/powershell.exe");
|
|
11312
|
+
if (await exists4(powershell))
|
|
10552
11313
|
return { file: powershell, args: [], title: "powershell" };
|
|
10553
11314
|
return { file: process.env.COMSPEC ?? "cmd.exe", args: [], title: "cmd" };
|
|
10554
11315
|
}
|
|
10555
11316
|
const shell = process.env.SHELL;
|
|
10556
|
-
if (shell && await
|
|
10557
|
-
return { file: shell, args: [], title:
|
|
10558
|
-
if (await
|
|
11317
|
+
if (shell && await exists4(shell))
|
|
11318
|
+
return { file: shell, args: [], title: path32.basename(shell) };
|
|
11319
|
+
if (await exists4("/bin/bash"))
|
|
10559
11320
|
return { file: "/bin/bash", args: [], title: "bash" };
|
|
10560
11321
|
return { file: "/bin/sh", args: [], title: "sh" };
|
|
10561
11322
|
}
|
|
10562
11323
|
async function findOnPath(name) {
|
|
10563
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
11324
|
+
const dirs = (process.env.PATH ?? "").split(path32.delimiter).filter(Boolean);
|
|
10564
11325
|
for (const dir of dirs) {
|
|
10565
|
-
const candidate =
|
|
10566
|
-
if (await
|
|
11326
|
+
const candidate = path32.join(dir, name);
|
|
11327
|
+
if (await exists4(candidate))
|
|
10567
11328
|
return candidate;
|
|
10568
11329
|
}
|
|
10569
11330
|
return null;
|
|
10570
11331
|
}
|
|
10571
|
-
function
|
|
11332
|
+
function exists4(file) {
|
|
10572
11333
|
return access2(file, constants2.X_OK).then(() => true, () => false);
|
|
10573
11334
|
}
|
|
10574
11335
|
|
|
10575
11336
|
// ../host/dist/mcp-credentials.js
|
|
10576
11337
|
import { createHash } from "node:crypto";
|
|
10577
|
-
import { readFile as
|
|
10578
|
-
import
|
|
11338
|
+
import { readFile as readFile21, rename as rename3, writeFile as writeFile18 } from "node:fs/promises";
|
|
11339
|
+
import path33 from "node:path";
|
|
10579
11340
|
function mcpOAuthKey(name, config) {
|
|
10580
11341
|
if (!config || typeof config !== "object")
|
|
10581
11342
|
return null;
|
|
@@ -10589,7 +11350,7 @@ function mcpOAuthKey(name, config) {
|
|
|
10589
11350
|
async function readMcpCredentialRecords(configDir, name) {
|
|
10590
11351
|
let parsed;
|
|
10591
11352
|
try {
|
|
10592
|
-
parsed = JSON.parse(await
|
|
11353
|
+
parsed = JSON.parse(await readFile21(path33.join(configDir, ".credentials.json"), "utf8"));
|
|
10593
11354
|
} catch {
|
|
10594
11355
|
return null;
|
|
10595
11356
|
}
|
|
@@ -10656,11 +11417,11 @@ function diagnoseSignIn(records, expectedKey) {
|
|
|
10656
11417
|
};
|
|
10657
11418
|
}
|
|
10658
11419
|
function registryPath(configDir) {
|
|
10659
|
-
return
|
|
11420
|
+
return path33.join(configDir, "plugins", "installed_plugins.json");
|
|
10660
11421
|
}
|
|
10661
11422
|
async function readRegistry(configDir) {
|
|
10662
11423
|
try {
|
|
10663
|
-
const raw = JSON.parse(await
|
|
11424
|
+
const raw = JSON.parse(await readFile21(registryPath(configDir), "utf8"));
|
|
10664
11425
|
const plugins = raw.plugins;
|
|
10665
11426
|
if (!plugins || typeof plugins !== "object")
|
|
10666
11427
|
return null;
|
|
@@ -10704,10 +11465,10 @@ async function keepSinglePluginRecord(configDir, id) {
|
|
|
10704
11465
|
}
|
|
10705
11466
|
|
|
10706
11467
|
// ../host/dist/mcp-config.js
|
|
10707
|
-
import { readFile as
|
|
10708
|
-
import
|
|
11468
|
+
import { readFile as readFile22, writeFile as writeFile19, mkdir as mkdir18 } from "node:fs/promises";
|
|
11469
|
+
import path34 from "node:path";
|
|
10709
11470
|
var MCP_FILE = ".mcp.json";
|
|
10710
|
-
var LOCAL_SETTINGS2 =
|
|
11471
|
+
var LOCAL_SETTINGS2 = path34.join(".claude", "settings.local.json");
|
|
10711
11472
|
var queues = /* @__PURE__ */ new Map();
|
|
10712
11473
|
function serialize(cwd, work) {
|
|
10713
11474
|
const previous = queues.get(cwd) ?? Promise.resolve();
|
|
@@ -10716,7 +11477,7 @@ function serialize(cwd, work) {
|
|
|
10716
11477
|
return next;
|
|
10717
11478
|
}
|
|
10718
11479
|
async function readProjectServers(cwd) {
|
|
10719
|
-
const file = await readJson(
|
|
11480
|
+
const file = await readJson(path34.join(cwd, MCP_FILE));
|
|
10720
11481
|
const servers = file?.mcpServers;
|
|
10721
11482
|
if (!servers || typeof servers !== "object")
|
|
10722
11483
|
return {};
|
|
@@ -10724,23 +11485,23 @@ async function readProjectServers(cwd) {
|
|
|
10724
11485
|
}
|
|
10725
11486
|
function addProjectServer(cwd, name, config) {
|
|
10726
11487
|
return serialize(cwd, async () => {
|
|
10727
|
-
const file = await readJson(
|
|
11488
|
+
const file = await readJson(path34.join(cwd, MCP_FILE)) ?? {};
|
|
10728
11489
|
const servers = file.mcpServers ?? {};
|
|
10729
11490
|
servers[name] = config;
|
|
10730
11491
|
file.mcpServers = servers;
|
|
10731
|
-
await writeJson(
|
|
11492
|
+
await writeJson(path34.join(cwd, MCP_FILE), file);
|
|
10732
11493
|
await approve(cwd, name);
|
|
10733
11494
|
});
|
|
10734
11495
|
}
|
|
10735
11496
|
function removeProjectServer(cwd, name) {
|
|
10736
11497
|
return serialize(cwd, async () => {
|
|
10737
|
-
const file = await readJson(
|
|
11498
|
+
const file = await readJson(path34.join(cwd, MCP_FILE));
|
|
10738
11499
|
const servers = file?.mcpServers;
|
|
10739
11500
|
if (!servers || !(name in servers))
|
|
10740
11501
|
return false;
|
|
10741
11502
|
delete servers[name];
|
|
10742
|
-
await writeJson(
|
|
10743
|
-
const settingsPath =
|
|
11503
|
+
await writeJson(path34.join(cwd, MCP_FILE), file);
|
|
11504
|
+
const settingsPath = path34.join(cwd, LOCAL_SETTINGS2);
|
|
10744
11505
|
const settings = await readJson(settingsPath);
|
|
10745
11506
|
const enabled = settings?.enabledMcpjsonServers;
|
|
10746
11507
|
if (settings && Array.isArray(enabled) && enabled.includes(name)) {
|
|
@@ -10751,7 +11512,7 @@ function removeProjectServer(cwd, name) {
|
|
|
10751
11512
|
});
|
|
10752
11513
|
}
|
|
10753
11514
|
async function approve(cwd, name) {
|
|
10754
|
-
const file =
|
|
11515
|
+
const file = path34.join(cwd, LOCAL_SETTINGS2);
|
|
10755
11516
|
const settings = await readJson(file) ?? {};
|
|
10756
11517
|
const enabled = Array.isArray(settings.enabledMcpjsonServers) ? settings.enabledMcpjsonServers : [];
|
|
10757
11518
|
if (!enabled.includes(name))
|
|
@@ -10790,20 +11551,20 @@ function describeConfig(config) {
|
|
|
10790
11551
|
}
|
|
10791
11552
|
async function readJson(file) {
|
|
10792
11553
|
try {
|
|
10793
|
-
const raw = await
|
|
11554
|
+
const raw = await readFile22(file, "utf8");
|
|
10794
11555
|
const parsed = JSON.parse(raw);
|
|
10795
11556
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
10796
11557
|
} catch (error) {
|
|
10797
11558
|
if (error.code === "ENOENT")
|
|
10798
11559
|
return null;
|
|
10799
11560
|
if (error instanceof SyntaxError) {
|
|
10800
|
-
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${
|
|
11561
|
+
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${path34.basename(file)}: ${error.message}`);
|
|
10801
11562
|
}
|
|
10802
11563
|
throw error;
|
|
10803
11564
|
}
|
|
10804
11565
|
}
|
|
10805
11566
|
async function writeJson(file, data) {
|
|
10806
|
-
await mkdir18(
|
|
11567
|
+
await mkdir18(path34.dirname(file), { recursive: true });
|
|
10807
11568
|
await writeFile19(file, `${JSON.stringify(data, null, 2)}
|
|
10808
11569
|
`, "utf8");
|
|
10809
11570
|
}
|
|
@@ -10836,6 +11597,10 @@ var HostServer = class {
|
|
|
10836
11597
|
#folders;
|
|
10837
11598
|
#settings;
|
|
10838
11599
|
#finder;
|
|
11600
|
+
/** Прокси сайтов для правок комментариями — по одному на origin (`site-proxy.ts`). */
|
|
11601
|
+
#siteProxies = new SiteProxies();
|
|
11602
|
+
/** Remotion Studio проектов для раздела «Видео» (`video-studio.ts`). */
|
|
11603
|
+
#studios = new RemotionStudios((state) => this.#broadcast({ type: "video.studio", state }));
|
|
10839
11604
|
#sessions = /* @__PURE__ */ new Map();
|
|
10840
11605
|
/** Идущие OAuth-входы MCP, ключ — сессия и сервер. */
|
|
10841
11606
|
#mcpAuthRuns = /* @__PURE__ */ new Map();
|
|
@@ -10892,6 +11657,13 @@ var HostServer = class {
|
|
|
10892
11657
|
* не останавливает. В памяти: живые сессии рестарт хоста не переживают.
|
|
10893
11658
|
*/
|
|
10894
11659
|
#limitApproved = /* @__PURE__ */ new Map();
|
|
11660
|
+
/**
|
|
11661
|
+
* Закрытые в этом запуске Claude-сессии: временный id живой сессии →
|
|
11662
|
+
* дисковый id её разговора (`null` — разговор так и не начался). Окно
|
|
11663
|
+
* старого клиента может попросить продолжить по временному id, а CLI знает
|
|
11664
|
+
* только дисковый.
|
|
11665
|
+
*/
|
|
11666
|
+
#closedDiskIds = /* @__PURE__ */ new Map();
|
|
10895
11667
|
/** Живые id сессий, у которых сейчас пишется хэндофф у лимита. */
|
|
10896
11668
|
#limitHandoffBusy = /* @__PURE__ */ new Set();
|
|
10897
11669
|
/** Живые id сессий, у которых сейчас пишется ручной хэндофф. */
|
|
@@ -11018,7 +11790,7 @@ var HostServer = class {
|
|
|
11018
11790
|
const status = await new AuthCli(configDir).status().catch(() => null);
|
|
11019
11791
|
if (!status?.loggedIn)
|
|
11020
11792
|
return null;
|
|
11021
|
-
const used = this.#accounts.all.find((a) =>
|
|
11793
|
+
const used = this.#accounts.all.find((a) => path35.resolve(this.#accounts.effectiveDir(a.id)).toLowerCase() === configDir.toLowerCase());
|
|
11022
11794
|
return {
|
|
11023
11795
|
configDir,
|
|
11024
11796
|
email: status.email,
|
|
@@ -11099,7 +11871,7 @@ var HostServer = class {
|
|
|
11099
11871
|
await this.#github.load();
|
|
11100
11872
|
await warmClaudeLauncher();
|
|
11101
11873
|
void this.#finder.warm();
|
|
11102
|
-
const httpServer =
|
|
11874
|
+
const httpServer = createServer3((req, res) => this.#serveHttp(req, res));
|
|
11103
11875
|
const wss = new WebSocketServer({ server: httpServer, path: "/ws" });
|
|
11104
11876
|
wss.on("connection", (socket) => this.#onConnection(socket));
|
|
11105
11877
|
let listening = false;
|
|
@@ -11152,6 +11924,8 @@ var HostServer = class {
|
|
|
11152
11924
|
for (const auth of this.#auths.values())
|
|
11153
11925
|
auth.cancel();
|
|
11154
11926
|
this.#terminals.closeAll();
|
|
11927
|
+
this.#siteProxies.closeAll();
|
|
11928
|
+
this.#studios.stopAll();
|
|
11155
11929
|
this.#rootWatcher?.close();
|
|
11156
11930
|
await this.#relay.close();
|
|
11157
11931
|
await Promise.all([...this.#sessions.values()].map((s) => s.close("host shutdown")));
|
|
@@ -11324,13 +12098,13 @@ var HostServer = class {
|
|
|
11324
12098
|
workspaceFolders: await Promise.all(this.#diskFolders.map(async (name) => {
|
|
11325
12099
|
const id = folderIdFor(name);
|
|
11326
12100
|
const color = this.#folders.diskFolderColor(id);
|
|
11327
|
-
const unopened = await listUnopened(
|
|
12101
|
+
const unopened = await listUnopened(path35.join(this.#projectsRoot(), name), this.#workspaces.allPaths());
|
|
11328
12102
|
return {
|
|
11329
12103
|
id,
|
|
11330
12104
|
name,
|
|
11331
12105
|
...color ? { color } : {},
|
|
11332
12106
|
unopened,
|
|
11333
|
-
path:
|
|
12107
|
+
path: path35.join(this.#projectsRoot(), name)
|
|
11334
12108
|
};
|
|
11335
12109
|
}))
|
|
11336
12110
|
};
|
|
@@ -11399,10 +12173,10 @@ var HostServer = class {
|
|
|
11399
12173
|
const name = folderNameOf(folderId);
|
|
11400
12174
|
if (!name || !this.#diskFolders.includes(name))
|
|
11401
12175
|
throw new Error("\u041F\u0430\u043F\u043A\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u043D\u0430 \u0434\u0438\u0441\u043A\u0435");
|
|
11402
|
-
parent =
|
|
12176
|
+
parent = path35.join(root, name);
|
|
11403
12177
|
}
|
|
11404
|
-
const to =
|
|
11405
|
-
if (
|
|
12178
|
+
const to = path35.join(parent, path35.basename(workspace.path));
|
|
12179
|
+
if (path35.resolve(to).toLowerCase() === path35.resolve(workspace.path).toLowerCase())
|
|
11406
12180
|
return;
|
|
11407
12181
|
await this.#relocate(workspace.path, to);
|
|
11408
12182
|
}
|
|
@@ -11414,7 +12188,7 @@ var HostServer = class {
|
|
|
11414
12188
|
if (name === old)
|
|
11415
12189
|
return;
|
|
11416
12190
|
const root = this.#projectsRoot();
|
|
11417
|
-
await this.#relocate(
|
|
12191
|
+
await this.#relocate(path35.join(root, old), path35.join(root, name));
|
|
11418
12192
|
await this.#folders.renameDiskFolder(folderId, folderIdFor(name), name);
|
|
11419
12193
|
this.#sendFolders();
|
|
11420
12194
|
}
|
|
@@ -11422,13 +12196,13 @@ var HostServer = class {
|
|
|
11422
12196
|
const name = folderNameOf(folderId);
|
|
11423
12197
|
if (!name)
|
|
11424
12198
|
return;
|
|
11425
|
-
const dir =
|
|
12199
|
+
const dir = path35.join(this.#projectsRoot(), name);
|
|
11426
12200
|
const foreign = await foreignContent(dir, this.#workspaces.allPaths());
|
|
11427
12201
|
if (foreign) {
|
|
11428
12202
|
throw new Error(`\u0412 \u043F\u0430\u043F\u043A\u0435 \u0435\u0441\u0442\u044C \xAB${foreign}\xBB, \u044D\u0442\u043E \u043D\u0435 \u043F\u0440\u043E\u0435\u043A\u0442 ccv \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u0442\u043E \u0438 \u0443\u0434\u0430\u043B\u0438\u0442\u0435 \u043F\u0430\u043F\u043A\u0443 \u0441\u043D\u043E\u0432\u0430`);
|
|
11429
12203
|
}
|
|
11430
12204
|
for (const project of this.#workspaces.allPaths().filter((p) => isInside(dir, p))) {
|
|
11431
|
-
await this.#relocate(project,
|
|
12205
|
+
await this.#relocate(project, path35.join(this.#projectsRoot(), path35.basename(project)));
|
|
11432
12206
|
}
|
|
11433
12207
|
await removeEmptyDir(dir);
|
|
11434
12208
|
await this.#folders.forgetDiskFolder(folderId);
|
|
@@ -11534,7 +12308,7 @@ var HostServer = class {
|
|
|
11534
12308
|
await this.#refreshDiskFolders();
|
|
11535
12309
|
if (!name || !this.#diskFolders.includes(name))
|
|
11536
12310
|
throw new Error("\u041F\u0430\u043F\u043A\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u043D\u0430 \u0434\u0438\u0441\u043A\u0435");
|
|
11537
|
-
parent =
|
|
12311
|
+
parent = path35.join(this.#projectsRoot(), name);
|
|
11538
12312
|
}
|
|
11539
12313
|
const { workspace, warnings } = await this.#workspaces.create(parent, frame.name, frame.init);
|
|
11540
12314
|
await this.#refreshDiskFolders();
|
|
@@ -12178,6 +12952,61 @@ var HostServer = class {
|
|
|
12178
12952
|
await this.#sendDir(frame.workspaceId, parentOf(frame.path));
|
|
12179
12953
|
return;
|
|
12180
12954
|
}
|
|
12955
|
+
case "site.open": {
|
|
12956
|
+
try {
|
|
12957
|
+
const opened = await this.#siteProxies.open(frame.url);
|
|
12958
|
+
this.#send(socket, { type: "site.opened", ...opened });
|
|
12959
|
+
} catch (error) {
|
|
12960
|
+
this.#send(socket, {
|
|
12961
|
+
type: "site.failed",
|
|
12962
|
+
url: frame.url,
|
|
12963
|
+
message: error instanceof Error ? error.message : String(error)
|
|
12964
|
+
});
|
|
12965
|
+
}
|
|
12966
|
+
return;
|
|
12967
|
+
}
|
|
12968
|
+
case "video.scan": {
|
|
12969
|
+
const workspace = this.#workspaces.find(frame.workspaceId);
|
|
12970
|
+
if (!workspace)
|
|
12971
|
+
throw new Error(`\u0412\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${frame.workspaceId}`);
|
|
12972
|
+
const catalog = await scanVideoCatalog(workspace.path);
|
|
12973
|
+
this.#send(socket, { type: "video.catalog", workspaceId: workspace.id, ...catalog });
|
|
12974
|
+
for (const state of this.#studios.states(workspace.id)) {
|
|
12975
|
+
this.#send(socket, { type: "video.studio", state });
|
|
12976
|
+
}
|
|
12977
|
+
return;
|
|
12978
|
+
}
|
|
12979
|
+
case "video.studio.start": {
|
|
12980
|
+
const workspace = this.#workspaces.find(frame.workspaceId);
|
|
12981
|
+
if (!workspace)
|
|
12982
|
+
throw new Error(`\u0412\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${frame.workspaceId}`);
|
|
12983
|
+
const project = (await scanVideoCatalog(workspace.path)).remotion.find((r) => r.root === frame.root);
|
|
12984
|
+
if (!project)
|
|
12985
|
+
throw new Error(`\u041F\u0440\u043E\u0435\u043A\u0442 Remotion \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${frame.root}`);
|
|
12986
|
+
await this.#studios.start(workspace.id, workspace.path, project.root, project.entry);
|
|
12987
|
+
return;
|
|
12988
|
+
}
|
|
12989
|
+
case "video.studio.stop":
|
|
12990
|
+
this.#studios.stop(frame.workspaceId, frame.root);
|
|
12991
|
+
return;
|
|
12992
|
+
case "fs.writeBinary": {
|
|
12993
|
+
let saved;
|
|
12994
|
+
try {
|
|
12995
|
+
saved = await this.#files(frame.workspaceId).writeBinary(frame.path, Buffer.from(frame.base64, "base64"));
|
|
12996
|
+
} catch (error) {
|
|
12997
|
+
this.#fsFailed(frame.workspaceId, frame.path, error);
|
|
12998
|
+
return;
|
|
12999
|
+
}
|
|
13000
|
+
this.#broadcast({
|
|
13001
|
+
type: "fs.saved",
|
|
13002
|
+
workspaceId: frame.workspaceId,
|
|
13003
|
+
path: normalize(frame.path),
|
|
13004
|
+
mtime: saved.mtime,
|
|
13005
|
+
size: saved.size
|
|
13006
|
+
});
|
|
13007
|
+
await this.#sendDir(frame.workspaceId, parentOf(frame.path));
|
|
13008
|
+
return;
|
|
13009
|
+
}
|
|
12181
13010
|
case "fs.create":
|
|
12182
13011
|
case "fs.delete":
|
|
12183
13012
|
case "fs.rename": {
|
|
@@ -12785,6 +13614,9 @@ var HostServer = class {
|
|
|
12785
13614
|
return false;
|
|
12786
13615
|
await this.#closeSide(sessionId);
|
|
12787
13616
|
this.#stopMcpAuthFor(sessionId);
|
|
13617
|
+
if (session instanceof ClaudeSession && session.hasTemporaryId) {
|
|
13618
|
+
this.#closedDiskIds.set(sessionId, session.claudeSessionId);
|
|
13619
|
+
}
|
|
12788
13620
|
await session.close(reason);
|
|
12789
13621
|
this.#sessions.delete(sessionId);
|
|
12790
13622
|
this.#limitApproved.delete(sessionId);
|
|
@@ -13127,6 +13959,10 @@ var HostServer = class {
|
|
|
13127
13959
|
const workspace = this.#workspaces.find(frame.workspaceId);
|
|
13128
13960
|
if (!workspace)
|
|
13129
13961
|
throw new Error(`\u0412\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${frame.workspaceId}`);
|
|
13962
|
+
if (frame.resume && this.#closedDiskIds.has(frame.resume)) {
|
|
13963
|
+
const diskId = this.#closedDiskIds.get(frame.resume) ?? void 0;
|
|
13964
|
+
frame = { ...frame, resume: diskId };
|
|
13965
|
+
}
|
|
13130
13966
|
const provider = frame.provider ?? "claude";
|
|
13131
13967
|
if (!frame.resume && !this.#settings.current.enabledProviders.includes(provider)) {
|
|
13132
13968
|
throw new Error(`${PROVIDER_LABEL[provider]} \u0432\u044B\u043A\u043B\u044E\u0447\u0435\u043D \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445`);
|
|
@@ -13781,8 +14617,8 @@ var HostServer = class {
|
|
|
13781
14617
|
return;
|
|
13782
14618
|
}
|
|
13783
14619
|
const url2 = new URL(req.url ?? "/", "http://localhost");
|
|
13784
|
-
const requested =
|
|
13785
|
-
const target = requested.startsWith(webRoot) && existsSync7(requested) && statSync3(requested).isFile() ? requested :
|
|
14620
|
+
const requested = path35.join(webRoot, path35.normalize(url2.pathname));
|
|
14621
|
+
const target = requested.startsWith(webRoot) && existsSync7(requested) && statSync3(requested).isFile() ? requested : path35.join(webRoot, "index.html");
|
|
13786
14622
|
if (!existsSync7(target)) {
|
|
13787
14623
|
res.writeHead(404).end("not found");
|
|
13788
14624
|
return;
|
|
@@ -13808,7 +14644,7 @@ function contentType(file) {
|
|
|
13808
14644
|
".svg": "image/svg+xml",
|
|
13809
14645
|
".woff2": "font/woff2"
|
|
13810
14646
|
};
|
|
13811
|
-
return types[
|
|
14647
|
+
return types[path35.extname(file)] ?? "application/octet-stream";
|
|
13812
14648
|
}
|
|
13813
14649
|
var PROVIDER_LABEL = {
|
|
13814
14650
|
claude: "Claude",
|
|
@@ -13843,8 +14679,8 @@ function antigravitySummary(record, provider = "antigravity") {
|
|
|
13843
14679
|
}
|
|
13844
14680
|
|
|
13845
14681
|
// dist/ccv.js
|
|
13846
|
-
var HERE =
|
|
13847
|
-
var PACKAGE_ROOT =
|
|
14682
|
+
var HERE = path36.dirname(fileURLToPath(import.meta.url));
|
|
14683
|
+
var PACKAGE_ROOT = path36.resolve(HERE, "..");
|
|
13848
14684
|
var USAGE = `ccv \u2014 Claude Code Visual: \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0445\u043E\u0441\u0442 Claude Code \u0441 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043E\u043C \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.
|
|
13849
14685
|
|
|
13850
14686
|
\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435:
|
|
@@ -13911,7 +14747,7 @@ var server = new HostServer({
|
|
|
13911
14747
|
dataDir: defaults.dataDir,
|
|
13912
14748
|
// UI лежит в пакете рядом с бандлом — это и есть разница между установленной
|
|
13913
14749
|
// утилитой и запуском из репозитория, где сборка живёт в `apps/web/dist`.
|
|
13914
|
-
webRoot: process.env.CCV_WEB_ROOT ??
|
|
14750
|
+
webRoot: process.env.CCV_WEB_ROOT ?? path36.join(PACKAGE_ROOT, "web"),
|
|
13915
14751
|
version,
|
|
13916
14752
|
relayUrl: defaults.relayUrl
|
|
13917
14753
|
});
|
|
@@ -13940,7 +14776,7 @@ for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
|
13940
14776
|
}
|
|
13941
14777
|
async function packageVersion() {
|
|
13942
14778
|
try {
|
|
13943
|
-
const text = await
|
|
14779
|
+
const text = await readFile23(path36.join(PACKAGE_ROOT, "package.json"), "utf8");
|
|
13944
14780
|
return JSON.parse(text).version ?? "0.0.0";
|
|
13945
14781
|
} catch {
|
|
13946
14782
|
return "0.0.0";
|
|
@@ -13984,7 +14820,7 @@ function openBrowser(target) {
|
|
|
13984
14820
|
return;
|
|
13985
14821
|
}
|
|
13986
14822
|
const command = process.platform === "win32" ? { file: "cmd", args: ["/c", "start", "", target] } : process.platform === "darwin" ? { file: "open", args: [target] } : { file: "xdg-open", args: [target] };
|
|
13987
|
-
const child =
|
|
14823
|
+
const child = spawn5(command.file, command.args, {
|
|
13988
14824
|
stdio: "ignore",
|
|
13989
14825
|
detached: true,
|
|
13990
14826
|
windowsHide: true
|