@marver-design/marver 0.26.1 → 0.27.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/CHANGELOG.md +104 -0
- package/README.md +8 -3
- package/dist/{anchor-check-l-ny3UzH.mjs → anchor-check-ChdDqL5z.mjs} +1 -1
- package/dist/{bake-C-awKgLA.mjs → bake-DM_uWgAA.mjs} +1 -1
- package/dist/{boards-DYG22tOe.mjs → boards-DlTcpF47.mjs} +1 -1
- package/dist/{build-BDRiO_mP.mjs → build-DZnFysGU.mjs} +4 -4
- package/dist/cli.mjs +28 -16
- package/dist/{comments-BqXua-XL.mjs → comments-DxOkCSNE.mjs} +4 -4
- package/dist/{daemon-DL6Fwq6D.mjs → daemon-BSA0lV8d.mjs} +8 -6
- package/dist/detect-C0wpaePX.mjs +125 -0
- package/dist/dev-eQJhWsqg.mjs +1273 -0
- package/dist/dev-lock-C_FC70Mu.mjs +65 -0
- package/dist/exclusive-B1RtpeeP.mjs +150 -0
- package/dist/{init-D8DtrK_F.mjs → init-COD0x48i.mjs} +5 -3
- package/dist/{link-BNzLvdhI.mjs → link-DDXZVGtv.mjs} +20 -8
- package/dist/ls-D7O1G505.mjs +38 -0
- package/dist/{marks-DyWMv_Z1.mjs → marks-CWM3WJjc.mjs} +1 -1
- package/dist/perf-BWzQwZqj.mjs +369 -0
- package/dist/perf-BoDSkbEb.mjs +429 -0
- package/dist/{perf-jam-BU3TVrZu.mjs → perf-jam-D55U3FZK.mjs} +5 -2
- package/dist/{plugin-DkGmZs_r.mjs → plugin-C-E7omsh.mjs} +394 -55
- package/dist/{poster-BdtSKMDm.mjs → poster-Bx83ZYVK.mjs} +1 -1
- package/dist/{profile-WU9qcbIo.mjs → profile-Bh5Y5zpW.mjs} +1 -1
- package/dist/{publish-bakes-9RzRToXV.mjs → publish-bakes-aljgm45S.mjs} +2 -2
- package/dist/{queue-29ok5_eZ.mjs → queue-CAM_vNmX.mjs} +1 -1
- package/dist/recover-t9Pno3u9.mjs +66 -0
- package/dist/{share--oFJ1bCI.mjs → share-W5H3BNvP.mjs} +1 -1
- package/dist/{shot-XQV7HC9A.mjs → shot-DoHLl6ig.mjs} +1 -1
- package/dist/{shot-DQeR_Pfn.mjs → shot-LFhC-WYD.mjs} +9 -3
- package/dist/slots-DCDo3N0x.mjs +471 -0
- package/dist/{sync-DKk-yT1V.mjs → sync-BQVlHZpx.mjs} +4 -3
- package/dist/{work-F5u-twpJ.mjs → work-Bp1p39kq.mjs} +4 -2
- package/dist/{work-VvX_JIgl.mjs → work-BroFwnup.mjs} +4 -2
- package/docs/boards-and-folders.md +3 -1
- package/docs/jam-session.md +55 -1
- package/docs/performance.md +262 -0
- package/package.json +2 -2
- package/src/client/content/index.tsx +3 -0
- package/src/client/content/video.tsx +6 -2
- package/src/client/frame-host/bridge.js +22 -6
- package/src/client/frame-host/main.tsx +17 -5
- package/src/client/shell/App.tsx +180 -25
- package/src/client/shell/BoardList.tsx +5 -5
- package/src/client/shell/Comments.tsx +3 -2
- package/src/client/shell/JamSurface.tsx +4 -2
- package/src/client/shell/LockedApp.tsx +5 -5
- package/src/client/shell/Play.tsx +16 -8
- package/src/client/shell/Toolbar.tsx +12 -1
- package/src/client/shell/api.ts +206 -0
- package/src/client/shell/canvas/Canvas.tsx +30 -3
- package/src/client/shell/canvas/FrameNode.tsx +12 -3
- package/src/client/shell/canvas/admission.ts +8 -1
- package/src/client/shell/canvas/camera-broadcast.ts +15 -5
- package/src/client/shell/canvas/ctl.ts +2 -0
- package/src/client/shell/canvas/frame-registry.ts +28 -2
- package/src/client/shell/canvas/sleep.ts +4 -1
- package/src/client/shell/comments-store.ts +12 -4
- package/src/client/shell/goto.ts +22 -10
- package/src/client/shell/jam-capture.ts +22 -8
- package/src/client/shell/jam-keys.ts +4 -0
- package/src/client/shell/jam-panel.tsx +3 -0
- package/src/client/shell/jam-queue.ts +3 -3
- package/src/client/shell/jam-session.tsx +14 -8
- package/src/client/shell/jam-voice.ts +7 -5
- package/src/client/shell/legacy-links.ts +2 -2
- package/src/client/shell/main.tsx +4 -0
- package/src/client/shell/notes.ts +8 -1
- package/src/client/shell/perf.ts +69 -58
- package/src/client/shell/recorder-core.ts +183 -0
- package/src/client/shell/recorder.ts +565 -0
- package/src/client/shell/store.ts +254 -98
- package/src/client/shell/styles.css +26 -1
- package/templates/AGENTS-embedded.md +22 -4
- package/templates/AGENTS-studio.md +22 -4
- package/templates/demo/dark.tsx +1 -1
- package/templates/demo/welcome.tsx +1 -1
- package/templates/instructions/welcome.md +6 -3
- package/dist/config-Cf7EjAMf.mjs +0 -292
- package/dist/dev-Bw_qYWWq.mjs +0 -755
- package/dist/dev-lock-DWSpa6nj.mjs +0 -179
- package/dist/perf-C75MZ73h.mjs +0 -167
- package/dist/perf-DPbLGhhO.mjs +0 -49
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { capture, t as findChrome } from "./shot-
|
|
1
|
+
import { capture, t as findChrome } from "./shot-LFhC-WYD.mjs";
|
|
2
2
|
import { constants, copyFileSync, existsSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, sep } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as slideSize } from "./cli.mjs";
|
|
2
|
-
import { planShot, t as findChrome } from "./shot-
|
|
3
|
-
import { ASK_MAX, bakeBatch } from "./bake-
|
|
2
|
+
import { planShot, t as findChrome } from "./shot-LFhC-WYD.mjs";
|
|
3
|
+
import { ASK_MAX, bakeBatch } from "./bake-DM_uWgAA.mjs";
|
|
4
4
|
import { MIME } from "./serve-C8rVheYk.mjs";
|
|
5
5
|
import { copyFileSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as createExclusive, r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
|
|
2
2
|
import { r as replay } from "./events-CLH4ijKP.mjs";
|
|
3
3
|
import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
|
|
4
4
|
import { a as deviceId, r as owned } from "./ledger-D54iROST.mjs";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { d as recoverTarget, h as workspaceId, r as legacyEntry, u as recoverEntries } from "./slots-DCDo3N0x.mjs";
|
|
3
|
+
import { DevStartError, dev } from "./dev-eQJhWsqg.mjs";
|
|
4
|
+
//#region src/cli/recover.ts
|
|
5
|
+
/**
|
|
6
|
+
* `marver dev --recover` (spec 28 A1.6). A Jam capture the page could not send waits in that browser's
|
|
7
|
+
* storage, at that page's address and under that workspace key, and goes out the next time a canvas
|
|
8
|
+
* opens there. When the canvas moved (0.27 moved every canvas to a slot; a later start can land on
|
|
9
|
+
* another slot), this starts it again on exactly an earlier address: its port, the address it bound,
|
|
10
|
+
* and the workspace key that run used - never another one. Alone it lists them: the project's recorded
|
|
11
|
+
* addresses, newest first, then the one 0.26 gave the folder.
|
|
12
|
+
*/
|
|
13
|
+
const MONTHS = [
|
|
14
|
+
"Jan",
|
|
15
|
+
"Feb",
|
|
16
|
+
"Mar",
|
|
17
|
+
"Apr",
|
|
18
|
+
"May",
|
|
19
|
+
"Jun",
|
|
20
|
+
"Jul",
|
|
21
|
+
"Aug",
|
|
22
|
+
"Sep",
|
|
23
|
+
"Oct",
|
|
24
|
+
"Nov",
|
|
25
|
+
"Dec"
|
|
26
|
+
];
|
|
27
|
+
const when = (t) => {
|
|
28
|
+
const d = new Date(t);
|
|
29
|
+
return `${d.getDate()} ${MONTHS[d.getMonth()]} ${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
|
|
30
|
+
};
|
|
31
|
+
/** The list `--recover` prints (tests read `^\s+(\d+)\s+(http://localhost:\d+/)`). */
|
|
32
|
+
function formatEntries(root, entries) {
|
|
33
|
+
const own = workspaceId(root);
|
|
34
|
+
const width = Math.max(...entries.map((e) => e.url.length));
|
|
35
|
+
return [
|
|
36
|
+
"addresses this canvas ran on, newest first:",
|
|
37
|
+
...entries.map((e, i) => ` ${String(i + 1).padStart(2)} ${e.url.padEnd(width)} ${e.legacy ? "the address 0.26 gave it" : `bound ${e.bind} ${e.from ? when(e.from) : "?"} - ${e.until ? when(e.until) : "?"}`}${e.ws !== own ? " (another workspace key)" : ""}`),
|
|
38
|
+
`start on one: npx ${NAME} dev --recover <n> - then open its link in the browser that made the capture`
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
/** `--recover` alone (cac hands over `true`), `--recover <n>` (a number or its string), or `--recover --port <p>`. */
|
|
42
|
+
async function recoverCommand(root, which, port, with_ = {}) {
|
|
43
|
+
const listOnly = which === true || which === "";
|
|
44
|
+
if (!listOnly && port !== void 0) throw new DevStartError("give --recover <n>, or --recover --port <p> - not both");
|
|
45
|
+
if (port !== void 0) {
|
|
46
|
+
await dev(root, {
|
|
47
|
+
...with_,
|
|
48
|
+
recover: recoverTarget(legacyEntry(root, port))
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const entries = recoverEntries(root);
|
|
53
|
+
if (listOnly) {
|
|
54
|
+
console.log(`\n${formatEntries(root, entries).map((l) => ` ${l}`).join("\n")}\n`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const n = Number(which);
|
|
58
|
+
const entry = Number.isInteger(n) && n >= 1 ? entries[n - 1] : void 0;
|
|
59
|
+
if (!entry) throw new DevStartError(`no address ${String(which)} - npx ${NAME} dev --recover lists them`);
|
|
60
|
+
await dev(root, {
|
|
61
|
+
...with_,
|
|
62
|
+
recover: recoverTarget(entry)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { recoverCommand };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
2
|
import { M as resolveAccess } from "./auth-Dix8wrXV.mjs";
|
|
3
|
-
import { i as loadCollab } from "./sync-
|
|
3
|
+
import { i as loadCollab } from "./sync-BQVlHZpx.mjs";
|
|
4
4
|
//#region src/cli/share.ts
|
|
5
5
|
/**
|
|
6
6
|
* `marver share <action>` - the roster from the terminal (01-sharing §9).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { i as readDevInfo } from "./work-
|
|
2
|
+
import { i as readDevInfo } from "./work-Bp1p39kq.mjs";
|
|
3
3
|
import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { randomBytes } from "node:crypto";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ROUTE, o as slideSize } from "./cli.mjs";
|
|
2
|
-
import { t as logJam } from "./perf-jam-
|
|
2
|
+
import { t as logJam } from "./perf-jam-D55U3FZK.mjs";
|
|
3
3
|
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { randomBytes } from "node:crypto";
|
|
@@ -43,12 +43,18 @@ const PROFILE_PREFIXES = ["mv-shot-", "mv-browser-"];
|
|
|
43
43
|
function containerFlags(platform, uid) {
|
|
44
44
|
return platform === "linux" && uid === 0 ? ["--no-sandbox", "--disable-dev-shm-usage"] : [];
|
|
45
45
|
}
|
|
46
|
+
const FOREGROUND = [
|
|
47
|
+
"--disable-backgrounding-occluded-windows",
|
|
48
|
+
"--disable-renderer-backgrounding",
|
|
49
|
+
"--disable-background-timer-throttling"
|
|
50
|
+
];
|
|
46
51
|
const FLAGS = [
|
|
47
52
|
...process.env.MV_CHROME_HEADED ? [] : ["--headless=new"],
|
|
48
53
|
"--hide-scrollbars",
|
|
49
54
|
"--no-first-run",
|
|
50
55
|
"--no-default-browser-check",
|
|
51
56
|
"--disable-extensions",
|
|
57
|
+
...FOREGROUND,
|
|
52
58
|
...containerFlags(process.platform, process.getuid?.()),
|
|
53
59
|
...process.env.MV_CHROME_FLAGS?.split(" ").filter(Boolean) ?? []
|
|
54
60
|
];
|
|
@@ -494,8 +500,8 @@ async function shootFrame(opts) {
|
|
|
494
500
|
};
|
|
495
501
|
const plan = planShot(frame, viewports, size);
|
|
496
502
|
if (frame.kind !== "html") try {
|
|
497
|
-
const { scanAssetRefs } = await import("./build-
|
|
498
|
-
const { ensurePoster } = await import("./poster-
|
|
503
|
+
const { scanAssetRefs } = await import("./build-DZnFysGU.mjs");
|
|
504
|
+
const { ensurePoster } = await import("./poster-Bx83ZYVK.mjs");
|
|
499
505
|
const refs = scanAssetRefs(readFileSync(join(root, frame.file), "utf8"), frame.file);
|
|
500
506
|
for (const r of refs) if (r.endsWith(".poster.png")) await ensurePoster(join(root, "design", "assets"), r.slice(0, -11));
|
|
501
507
|
} catch {}
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { a as readJson, i as portInUse, o as takeExclusive, r as pidRuns, t as asHolder } from "./exclusive-B1RtpeeP.mjs";
|
|
3
|
+
import { chmodSync, existsSync, mkdirSync, readdirSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
//#region src/server/workspace.ts
|
|
8
|
+
/**
|
|
9
|
+
* A project's one identity on this Mac (spec 28 A1.6): the first 16 hex of sha256 over its REAL path,
|
|
10
|
+
* so a root reached through a symlink is the same project. CONFIG.workspace, the capture upload's
|
|
11
|
+
* check, the slot file, the preference file and the app's partition all read it.
|
|
12
|
+
*
|
|
13
|
+
* A run holds two values (A1.13 #6): the canonical identity, which picks the project's preference
|
|
14
|
+
* file, and the effective workspace - this run's documents, API, captures and registry record. They
|
|
15
|
+
* differ only in a `--recover` run, which serves under the workspace key an earlier address used.
|
|
16
|
+
*
|
|
17
|
+
* The CLI already hands `dev()` the root's real path (cli/index.ts), so for every canvas started with
|
|
18
|
+
* `npx marver dev` this equals 0.26's key: unsent captures keep their key, and only the origin moves.
|
|
19
|
+
*/
|
|
20
|
+
const key = (s) => createHash("sha256").update(s).digest("hex").slice(0, 16);
|
|
21
|
+
/** realpath, or the path itself when it cannot be resolved (never throws at boot). */
|
|
22
|
+
const realRoot = (root) => {
|
|
23
|
+
try {
|
|
24
|
+
return realpathSync(root);
|
|
25
|
+
} catch {
|
|
26
|
+
return root;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/** The project's canonical identity. */
|
|
30
|
+
const workspaceId = (root) => key(realRoot(root));
|
|
31
|
+
/** 0.26's key, for `--recover` alone: sha256 of the root exactly as it was given (0.26 hashed the
|
|
32
|
+
* given root in plugin.ts and api.ts alike). Equals `workspaceId` for every CLI start. */
|
|
33
|
+
const legacyWorkspace = (root) => key(root);
|
|
34
|
+
const runIdentity = (root, recoverWs) => {
|
|
35
|
+
const real = realRoot(root);
|
|
36
|
+
const id = key(real);
|
|
37
|
+
return {
|
|
38
|
+
root: real,
|
|
39
|
+
id,
|
|
40
|
+
ws: recoverWs ?? id
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const marverHome = () => process.env.MARVER_HOME || join(homedir(), ".marver");
|
|
44
|
+
/** The port before slot 1 - slot n listens on base + n (localhost:4805-4824). MARVER_SLOT_BASE moves
|
|
45
|
+
* the range for the test suite alone: the port check sees every program on this Mac, so a suite on
|
|
46
|
+
* 4805+ would take the slot of a canvas someone is using. */
|
|
47
|
+
function slotBase() {
|
|
48
|
+
const b = Number(process.env.MARVER_SLOT_BASE);
|
|
49
|
+
return process.env.MARVER_SLOT_BASE && Number.isInteger(b) && b >= 1024 && b <= 65515 ? b : 4804;
|
|
50
|
+
}
|
|
51
|
+
const slotPort = (n) => slotBase() + n;
|
|
52
|
+
const slotOfPort = (port) => {
|
|
53
|
+
const n = port - slotBase();
|
|
54
|
+
return n >= 1 && n <= 20 ? n : null;
|
|
55
|
+
};
|
|
56
|
+
/** `~/x` for a path under the home directory - how paths are shown. */
|
|
57
|
+
const tilde = (p) => {
|
|
58
|
+
const h = homedir();
|
|
59
|
+
return p === h ? "~" : p.startsWith(h + "/") ? `~${p.slice(h.length)}` : p;
|
|
60
|
+
};
|
|
61
|
+
const runningDir = () => join(marverHome(), "running");
|
|
62
|
+
const preferDir = () => join(marverHome(), "prefer");
|
|
63
|
+
/** A registry folder, made for writing: mode 700. The home itself is made 700 only when missing (it holds
|
|
64
|
+
* canvases/ and models/ too, and an existing one is never changed). */
|
|
65
|
+
function made(d) {
|
|
66
|
+
mkdirSync(marverHome(), {
|
|
67
|
+
recursive: true,
|
|
68
|
+
mode: 448
|
|
69
|
+
});
|
|
70
|
+
mkdirSync(d, {
|
|
71
|
+
recursive: true,
|
|
72
|
+
mode: 448
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
chmodSync(d, 448);
|
|
76
|
+
} catch {}
|
|
77
|
+
return d;
|
|
78
|
+
}
|
|
79
|
+
const slotFileOf = (n) => join(runningDir(), `slot-${n}.json`);
|
|
80
|
+
const portFileOf = (port) => join(runningDir(), `port-${port}.json`);
|
|
81
|
+
/** Write `file` whole: a private temp file renamed over it. */
|
|
82
|
+
function writeWhole(file, body) {
|
|
83
|
+
const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
84
|
+
writeFileSync(tmp, body, { mode: 384 });
|
|
85
|
+
try {
|
|
86
|
+
renameSync(tmp, file);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
try {
|
|
89
|
+
unlinkSync(tmp);
|
|
90
|
+
} catch {}
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** A record read back, or null when the file names no canvas. Lenient on what a later version adds. */
|
|
95
|
+
function asRecord(v) {
|
|
96
|
+
const h = asHolder(v);
|
|
97
|
+
const r = v;
|
|
98
|
+
if (!h || !r || typeof r.port !== "number" || typeof r.url !== "string") return null;
|
|
99
|
+
return {
|
|
100
|
+
v: 1,
|
|
101
|
+
state: r.state === "ready" || r.state === "closing" ? r.state : "starting",
|
|
102
|
+
pid: h.pid,
|
|
103
|
+
instance: h.instance,
|
|
104
|
+
slot: typeof r.slot === "number" ? r.slot : null,
|
|
105
|
+
port: r.port,
|
|
106
|
+
origin: typeof r.origin === "string" ? r.origin : null,
|
|
107
|
+
url: r.url,
|
|
108
|
+
root: typeof r.root === "string" ? r.root : "",
|
|
109
|
+
name: typeof r.name === "string" ? r.name : "",
|
|
110
|
+
version: typeof r.version === "string" ? r.version : "",
|
|
111
|
+
features: Array.isArray(r.features) ? r.features.filter((f) => typeof f === "string") : [],
|
|
112
|
+
ws: typeof r.ws === "string" ? r.ws : "",
|
|
113
|
+
startedAt: typeof r.startedAt === "number" ? r.startedAt : h.at,
|
|
114
|
+
key: typeof r.key === "string" ? r.key : ""
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Take one candidate: the file, then - holding it - the port check. */
|
|
118
|
+
async function take(i, slot, port) {
|
|
119
|
+
const file = slot ? slotFileOf(slot) : portFileOf(port);
|
|
120
|
+
made(runningDir());
|
|
121
|
+
const key = randomBytes(32);
|
|
122
|
+
const rec = {
|
|
123
|
+
v: 1,
|
|
124
|
+
state: "starting",
|
|
125
|
+
pid: process.pid,
|
|
126
|
+
instance: i.instance,
|
|
127
|
+
slot,
|
|
128
|
+
port,
|
|
129
|
+
origin: null,
|
|
130
|
+
url: `http://localhost:${port}/`,
|
|
131
|
+
root: i.root,
|
|
132
|
+
name: i.name,
|
|
133
|
+
version: i.version,
|
|
134
|
+
features: [],
|
|
135
|
+
ws: i.ws,
|
|
136
|
+
startedAt: Date.now(),
|
|
137
|
+
key: key.toString("base64url")
|
|
138
|
+
};
|
|
139
|
+
const r = await takeExclusive(file, {
|
|
140
|
+
pid: rec.pid,
|
|
141
|
+
instance: rec.instance,
|
|
142
|
+
at: rec.startedAt
|
|
143
|
+
}, JSON.stringify(rec, null, 2) + "\n", { reclaimWaitMs: i.reclaimWaitMs });
|
|
144
|
+
if (!r.ok) return r.why === "held" ? {
|
|
145
|
+
ok: false,
|
|
146
|
+
why: "held",
|
|
147
|
+
holder: asRecord(readJson(file)),
|
|
148
|
+
file
|
|
149
|
+
} : {
|
|
150
|
+
ok: false,
|
|
151
|
+
why: r.why,
|
|
152
|
+
file
|
|
153
|
+
};
|
|
154
|
+
i.onHold?.(r.release);
|
|
155
|
+
if (await (i.inUse ?? portInUse)(port)) {
|
|
156
|
+
r.release();
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
why: "busy",
|
|
160
|
+
file
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
let now = rec;
|
|
164
|
+
const rewrite = (next) => {
|
|
165
|
+
if (asHolder(readJson(file))?.instance !== rec.instance) return;
|
|
166
|
+
writeWhole(file, JSON.stringify(next, null, 2) + "\n");
|
|
167
|
+
now = next;
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
claim: {
|
|
172
|
+
slot,
|
|
173
|
+
port,
|
|
174
|
+
file,
|
|
175
|
+
instance: rec.instance,
|
|
176
|
+
key,
|
|
177
|
+
url: rec.url,
|
|
178
|
+
release: r.release,
|
|
179
|
+
ready(origin) {
|
|
180
|
+
if (now.state !== "closing") rewrite({
|
|
181
|
+
...now,
|
|
182
|
+
state: "ready",
|
|
183
|
+
origin
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
closing() {
|
|
187
|
+
if (now.state !== "closing") rewrite({
|
|
188
|
+
...now,
|
|
189
|
+
state: "closing"
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const canvasOf = (rec) => rec ? `"${rec.name || "?"}" (${tilde(rec.root) || "?"})` : "another canvas";
|
|
196
|
+
const stuckLine = (n) => `slot ${n} is stuck: delete ${tilde(slotFileOf(n))}.reclaim if no canvas is starting`;
|
|
197
|
+
const unreadableLine = (file, n) => `${tilde(file)} is unreadable - ${n ? `slot ${n}` : "that port"} skipped (delete it if no canvas runs there)`;
|
|
198
|
+
/** A slot, any slot: the project's preferred one first, then 1..20. */
|
|
199
|
+
async function anySlot(i, notes) {
|
|
200
|
+
const preferred = readPrefer(i.id)?.slot ?? null;
|
|
201
|
+
const order = [...preferred ? [preferred] : [], ...Array.from({ length: 20 }, (_, k) => k + 1).filter((n) => n !== preferred)];
|
|
202
|
+
for (const n of order) {
|
|
203
|
+
const t = await take(i, n, slotPort(n));
|
|
204
|
+
if (t.ok) return {
|
|
205
|
+
ok: true,
|
|
206
|
+
claim: t.claim,
|
|
207
|
+
notes
|
|
208
|
+
};
|
|
209
|
+
if (t.why === "busy") notes.push(`port ${slotPort(n)} is used by another program - slot ${n} skipped`);
|
|
210
|
+
else if (t.why === "stuck") notes.push(stuckLine(n));
|
|
211
|
+
else if (t.why === "unreadable") notes.push(unreadableLine(t.file, n));
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
ok: false,
|
|
215
|
+
message: [
|
|
216
|
+
`all 20 slots are taken:`,
|
|
217
|
+
...formatRunning(readRunning()).map((l) => ` ${l}`),
|
|
218
|
+
...notes,
|
|
219
|
+
"stop one (Ctrl-C in its terminal), or start this one with --port <n>"
|
|
220
|
+
].join("\n ")
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** Where this canvas listens: a slot, a port of its own, or --recover's exact one - held as a file before
|
|
224
|
+
* anything binds. */
|
|
225
|
+
async function place(i) {
|
|
226
|
+
if (i.recover) {
|
|
227
|
+
const port = i.recover.port;
|
|
228
|
+
const n = slotOfPort(port);
|
|
229
|
+
const t = await take(i, n, port);
|
|
230
|
+
if (t.ok) return {
|
|
231
|
+
ok: true,
|
|
232
|
+
claim: t.claim,
|
|
233
|
+
notes: []
|
|
234
|
+
};
|
|
235
|
+
const never = "--recover never takes another address";
|
|
236
|
+
return {
|
|
237
|
+
ok: false,
|
|
238
|
+
message: t.why === "held" && t.holder?.state === "closing" ? `port ${port} is held by ${canvasOf(t.holder)}, which is closing - ${never}; run it again once it has stopped` : t.why === "held" ? `port ${port} is held by ${canvasOf(t.holder)} - ${never}; stop it (Ctrl-C in its terminal) and run it again` : t.why === "busy" ? `port ${port} is in use - ${never}; stop what holds it and run it again` : t.why === "stuck" && n ? `${stuckLine(n)} - ${never}` : `${unreadableLine(t.file, n)} - ${never}`
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (i.explicit) {
|
|
242
|
+
const { port, from } = i.explicit;
|
|
243
|
+
const n = slotOfPort(port);
|
|
244
|
+
if (n) {
|
|
245
|
+
const t = await take(i, n, port);
|
|
246
|
+
if (t.ok) return {
|
|
247
|
+
ok: true,
|
|
248
|
+
claim: t.claim,
|
|
249
|
+
notes: []
|
|
250
|
+
};
|
|
251
|
+
const instead = from === "config" ? "or remove `port` from design/config.ts" : "or start without --port";
|
|
252
|
+
return {
|
|
253
|
+
ok: false,
|
|
254
|
+
message: t.why === "held" && t.holder?.state === "closing" ? `port ${port} is slot ${n}, and ${canvasOf(t.holder)} holds it while it closes - start again once it has stopped, ${instead}` : t.why === "held" ? `port ${port} is slot ${n}, and ${canvasOf(t.holder)} holds it - stop it first (Ctrl-C in its terminal), ${instead}` : t.why === "busy" ? `port ${port} (slot ${n}) is in use by another program - stop it, ${instead}` : t.why === "stuck" ? stuckLine(n) : unreadableLine(t.file, n)
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const t = await take(i, null, port);
|
|
258
|
+
if (t.ok) return {
|
|
259
|
+
ok: true,
|
|
260
|
+
claim: t.claim,
|
|
261
|
+
notes: []
|
|
262
|
+
};
|
|
263
|
+
const placed = await anySlot(i, t.why === "stuck" ? [`${tilde(t.file)}.reclaim is left from a start that crashed: delete it if no canvas is starting`] : t.why === "unreadable" ? [unreadableLine(t.file, null)] : []);
|
|
264
|
+
return placed.ok ? {
|
|
265
|
+
...placed,
|
|
266
|
+
fellBackFrom: port
|
|
267
|
+
} : placed;
|
|
268
|
+
}
|
|
269
|
+
return anySlot(i, []);
|
|
270
|
+
}
|
|
271
|
+
/** The address a listening server actually bound - `[::1]` or `127.0.0.1`, wildcards mapped to
|
|
272
|
+
* loopback - or null before it listens. */
|
|
273
|
+
const originOf = (a) => {
|
|
274
|
+
if (!a || typeof a === "string") return null;
|
|
275
|
+
return `http://${a.family === "IPv6" ? a.address === "::" ? "[::1]" : `[${a.address}]` : a.address === "0.0.0.0" ? "127.0.0.1" : a.address}:${a.port}`;
|
|
276
|
+
};
|
|
277
|
+
/** 0.26's per-project port in [5200,5399], verbatim - kept only so --recover can offer the address a
|
|
278
|
+
* canvas had before 0.27. Hashes the root exactly as given, as 0.26 did. */
|
|
279
|
+
const legacyPort = (root) => {
|
|
280
|
+
let h = 0;
|
|
281
|
+
for (let i = 0; i < root.length; i++) h = Math.imul(h, 31) + root.charCodeAt(i) | 0;
|
|
282
|
+
return 5200 + Math.abs(h) % 200;
|
|
283
|
+
};
|
|
284
|
+
/** What every `marver dev` since 0.24 writes in design/.local as it starts and keeps once it stops: the sidebar
|
|
285
|
+
* marks (changes.json, seen.json - the dev server their only writer, at every start), the Jam queue, the reload
|
|
286
|
+
* log. No other command writes them, and dev.lock and dev.json go when a canvas stops. Not the daily update check
|
|
287
|
+
* (update-check.json): a start sets it off and does not wait for it, so it lands when it lands - after a failed
|
|
288
|
+
* start has taken back its traces, or while another start reads them - and says nothing of a canvas that ran. */
|
|
289
|
+
const DEV_TRACES = [
|
|
290
|
+
"changes.json",
|
|
291
|
+
"seen.json",
|
|
292
|
+
"jam-jobs.json",
|
|
293
|
+
join("perf", "reloads.jsonl")
|
|
294
|
+
];
|
|
295
|
+
/** Did a `marver dev` run in this folder before? Read once a start holds the folder's lock, before it writes any of
|
|
296
|
+
* them: with none, a project with no preference file is new, not one 0.26 served - and its first start has nothing
|
|
297
|
+
* to say about 0.26. */
|
|
298
|
+
const ranDevBefore = (root) => DEV_TRACES.some((f) => existsSync(join(root, "design", ".local", f)));
|
|
299
|
+
/** A start that found none of them and never served (a sandbox, a port just taken) takes back those it wrote - the
|
|
300
|
+
* marks (with their deps.json) and the rest - so the folder still reads as one no canvas ran in. */
|
|
301
|
+
const forgetDevTraces = (root) => {
|
|
302
|
+
for (const f of [...DEV_TRACES, "deps.json"]) try {
|
|
303
|
+
rmSync(join(root, "design", ".local", f), { force: true });
|
|
304
|
+
} catch {}
|
|
305
|
+
};
|
|
306
|
+
const HISTORY = 5;
|
|
307
|
+
const preferFileOf = (id) => /^[0-9a-f]{16}$/.test(id) ? join(preferDir(), `${id}.json`) : null;
|
|
308
|
+
const sameAddress = (a, b) => a.url === b.url && a.bind === b.bind && a.ws === b.ws;
|
|
309
|
+
/** The project's preference: undefined when it has none (its first 0.27 run), null when the file is there
|
|
310
|
+
* but unreadable (not a first run; the next write replaces it). */
|
|
311
|
+
function readPrefer(id) {
|
|
312
|
+
const file = preferFileOf(id);
|
|
313
|
+
if (!file) return null;
|
|
314
|
+
const raw = readJson(file);
|
|
315
|
+
if (raw === void 0) return void 0;
|
|
316
|
+
if (!raw || raw.v !== 1 || !(raw.slot === null || Number.isInteger(raw.slot) && raw.slot >= 1 && raw.slot <= 20) || !Array.isArray(raw.history)) return null;
|
|
317
|
+
const history = raw.history.filter((a) => !!a && typeof a.url === "string" && typeof a.bind === "string" && typeof a.ws === "string").map((a) => ({
|
|
318
|
+
url: a.url,
|
|
319
|
+
bind: a.bind,
|
|
320
|
+
ws: a.ws,
|
|
321
|
+
from: Number(a.from) || 0,
|
|
322
|
+
until: Number(a.until) || 0
|
|
323
|
+
}));
|
|
324
|
+
return {
|
|
325
|
+
v: 1,
|
|
326
|
+
slot: raw.slot ?? null,
|
|
327
|
+
history
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/** Record this run's address, after ready: a new entry only when url, bind or ws differ from the newest
|
|
331
|
+
* (so recovery never loses the one it needs); an address it ran on before moves to the front, keeping its
|
|
332
|
+
* first start - five distinct addresses at most. Says whether this is the project's first 0.27 run, and
|
|
333
|
+
* the address it ran on last. */
|
|
334
|
+
function notePrefer(id, run, now = Date.now()) {
|
|
335
|
+
const file = preferFileOf(id);
|
|
336
|
+
if (!file) throw new Error(`not a workspace id: ${id}`);
|
|
337
|
+
const cur = readPrefer(id);
|
|
338
|
+
const previous = cur?.history[0] ? { ...cur.history[0] } : null;
|
|
339
|
+
const before = cur?.history.find((a) => sameAddress(a, run));
|
|
340
|
+
const history = [{
|
|
341
|
+
url: run.url,
|
|
342
|
+
bind: run.bind,
|
|
343
|
+
ws: run.ws,
|
|
344
|
+
from: before?.from ?? now,
|
|
345
|
+
until: now
|
|
346
|
+
}, ...(cur?.history ?? []).filter((a) => !sameAddress(a, run))];
|
|
347
|
+
made(preferDir());
|
|
348
|
+
writeWhole(file, JSON.stringify({
|
|
349
|
+
v: 1,
|
|
350
|
+
slot: run.slot ?? cur?.slot ?? null,
|
|
351
|
+
history: history.slice(0, HISTORY)
|
|
352
|
+
}, null, 2) + "\n");
|
|
353
|
+
return {
|
|
354
|
+
first: cur === void 0,
|
|
355
|
+
previous
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/** This run stopped: its entry's `until` (best effort, synchronous - it runs on exit and on signals). */
|
|
359
|
+
function stopPrefer(id, run, now = Date.now()) {
|
|
360
|
+
try {
|
|
361
|
+
const file = preferFileOf(id);
|
|
362
|
+
const cur = readPrefer(id);
|
|
363
|
+
if (!file || !cur || !cur.history[0] || !sameAddress(cur.history[0], run)) return;
|
|
364
|
+
cur.history[0].until = now;
|
|
365
|
+
writeWhole(file, JSON.stringify(cur, null, 2) + "\n");
|
|
366
|
+
} catch {}
|
|
367
|
+
}
|
|
368
|
+
/** The address 0.26 gave this folder: its hash port, `localhost`, and its key. */
|
|
369
|
+
const legacyEntry = (root, port = legacyPort(root)) => ({
|
|
370
|
+
url: `http://localhost:${port}/`,
|
|
371
|
+
bind: `http://localhost:${port}`,
|
|
372
|
+
ws: legacyWorkspace(root),
|
|
373
|
+
legacy: true
|
|
374
|
+
});
|
|
375
|
+
/** The addresses this project ran on, newest first, then the one 0.26 gave it - always last, because the
|
|
376
|
+
* first 0.27 run has written history by the time anyone acts on its hint (A1.13 #6). */
|
|
377
|
+
function recoverEntries(root) {
|
|
378
|
+
const history = readPrefer(workspaceId(root))?.history ?? [];
|
|
379
|
+
const legacy = legacyEntry(root);
|
|
380
|
+
return history.some((h) => h.url === legacy.url && h.ws === legacy.ws) ? history : [...history, legacy];
|
|
381
|
+
}
|
|
382
|
+
/** What a start says about where this canvas ran before (A1.6) - nothing, when nothing a person could have open
|
|
383
|
+
* there has moved:
|
|
384
|
+
* - its first 0.27 start on a slot, only when a `marver dev` ran in this folder before: a new project has no 0.26
|
|
385
|
+
* address to name;
|
|
386
|
+
* - another link than last time (its slot taken, a port of its own given up): where it was, who runs there now
|
|
387
|
+
* when a canvas does, and how to run there again. A tab still open there keeps its unsaved edits until this
|
|
388
|
+
* canvas answers there, and a Jam capture left unsent waits there too. The link alone counts: the address a run
|
|
389
|
+
* bound (`[::1]` or `127.0.0.1`) is what the Mac app loads, and a browser at the link reaches either. */
|
|
390
|
+
function startedWhere(b) {
|
|
391
|
+
if (b.first) {
|
|
392
|
+
if (!b.ranBefore || !b.run.slot) return [];
|
|
393
|
+
const old = legacyPort(b.root);
|
|
394
|
+
return [`ports are now fixed slots: this canvas is at ${b.run.url}`, ...old !== b.port ? [`0.26 served this canvas at http://localhost:${old}/ - if a Jam capture was left unsent there, \`npx ${NAME} dev --recover\` gets it back`] : []];
|
|
395
|
+
}
|
|
396
|
+
const p = b.previous;
|
|
397
|
+
if (!p || p.url === b.run.url) return [];
|
|
398
|
+
const holder = readRunning().find((r) => r.url === p.url && r.pid !== process.pid && r.state !== "closing");
|
|
399
|
+
const who = holder ? `"${holder.name || "?"}"` : null;
|
|
400
|
+
const n = recoverEntries(b.root).findIndex((e) => e.url === p.url && e.bind === p.bind && e.ws === p.ws) + 1;
|
|
401
|
+
return [
|
|
402
|
+
`last run was at ${p.url}${who ? ` - ${who} runs there now` : ""}`,
|
|
403
|
+
"a tab still open there keeps its unsaved edits until this canvas runs there again (a Jam capture left unsent there waits too):",
|
|
404
|
+
`stop ${who ? `${who} and ` : ""}this canvas, then \`npx ${NAME} dev --recover${n ? ` ${n}` : ""}\``
|
|
405
|
+
];
|
|
406
|
+
}
|
|
407
|
+
function recoverTarget(e) {
|
|
408
|
+
const b = new URL(e.bind);
|
|
409
|
+
const port = Number(b.port);
|
|
410
|
+
const host = b.hostname === "localhost" ? void 0 : b.hostname.replace(/^\[(.*)\]$/, "$1");
|
|
411
|
+
return {
|
|
412
|
+
port,
|
|
413
|
+
...host ? { host } : {},
|
|
414
|
+
ws: e.ws,
|
|
415
|
+
url: e.url,
|
|
416
|
+
bind: e.bind
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
/** The canvases running on this Mac: every slot and port file whose pid runs, slots by number, then
|
|
420
|
+
* ports. Reads only - a Mac with no registry has none. */
|
|
421
|
+
function readRunning() {
|
|
422
|
+
let names;
|
|
423
|
+
try {
|
|
424
|
+
names = readdirSync(runningDir());
|
|
425
|
+
} catch {
|
|
426
|
+
return [];
|
|
427
|
+
}
|
|
428
|
+
const out = [];
|
|
429
|
+
for (const name of names) {
|
|
430
|
+
if (!/^(slot-\d+|port-\d+)\.json$/.test(name)) continue;
|
|
431
|
+
const file = join(runningDir(), name);
|
|
432
|
+
const rec = asRecord(readJson(file));
|
|
433
|
+
if (!rec || !pidRuns(rec.pid)) continue;
|
|
434
|
+
const { key: _key, instance: _instance, ...pub } = rec;
|
|
435
|
+
out.push({
|
|
436
|
+
...pub,
|
|
437
|
+
file
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return out.sort((a, b) => (a.slot === null ? 1 : 0) - (b.slot === null ? 1 : 0) || (a.slot ?? a.port) - (b.slot ?? b.port));
|
|
441
|
+
}
|
|
442
|
+
const uptime = (ms) => {
|
|
443
|
+
const s = Math.max(0, Math.floor(ms / 1e3)), m = Math.floor(s / 60), h = Math.floor(m / 60), d = Math.floor(h / 24);
|
|
444
|
+
return d ? `${d}d ${h % 24}h` : h ? `${h}h ${m % 60}m` : m ? `${m}m` : `${s}s`;
|
|
445
|
+
};
|
|
446
|
+
/** The list as `marver ls` prints it: slot, link, name, version, state, uptime, then the folder - last, its length
|
|
447
|
+
* its own, so the columns before it stay on the line. A canvas that is closing is listed, `closing`: it still holds
|
|
448
|
+
* its slot and its folder, so a start there is refused until it has gone, and the list says why. */
|
|
449
|
+
function formatRunning(list, now = Date.now()) {
|
|
450
|
+
const rows = [[
|
|
451
|
+
"slot",
|
|
452
|
+
"link",
|
|
453
|
+
"name",
|
|
454
|
+
"version",
|
|
455
|
+
"state",
|
|
456
|
+
"up",
|
|
457
|
+
"folder"
|
|
458
|
+
], ...list.map((r) => [
|
|
459
|
+
r.slot === null ? "-" : String(r.slot),
|
|
460
|
+
r.url,
|
|
461
|
+
r.name,
|
|
462
|
+
r.version,
|
|
463
|
+
r.state,
|
|
464
|
+
uptime(now - r.startedAt),
|
|
465
|
+
tilde(r.root)
|
|
466
|
+
])];
|
|
467
|
+
const widths = rows[0].map((_, c) => Math.max(...rows.map((r) => r[c].length)));
|
|
468
|
+
return rows.map((r) => r.map((cell, c) => c === 0 ? cell.padStart(widths[c]) : cell.padEnd(widths[c])).join(" ").trimEnd());
|
|
469
|
+
}
|
|
470
|
+
//#endregion
|
|
471
|
+
export { notePrefer as a, ranDevBefore as c, recoverTarget as d, startedWhere as f, workspaceId as h, marverHome as i, readRunning as l, runIdentity as m, formatRunning as n, originOf as o, stopPrefer as p, legacyEntry as r, place as s, forgetDevTraces as t, recoverEntries as u };
|
|
@@ -2,10 +2,10 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
|
2
2
|
import { n as diffEvents } from "./events-CLH4ijKP.mjs";
|
|
3
3
|
import { a as readLog, i as listBoards, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
4
4
|
import { t as CLI_TOKEN_CHARS } from "./auth-Dix8wrXV.mjs";
|
|
5
|
+
import { i as marverHome } from "./slots-DCDo3N0x.mjs";
|
|
5
6
|
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, unlinkSync, writeSync } from "node:fs";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
import { createHash, randomBytes } from "node:crypto";
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
9
|
//#region src/server/sync.ts
|
|
10
10
|
/**
|
|
11
11
|
* Dev ↔ published comment sync - one merge rule, run from the dev side.
|
|
@@ -43,13 +43,14 @@ var sync_exports = /* @__PURE__ */ __exportAll({
|
|
|
43
43
|
*
|
|
44
44
|
* So the file moved out of reach instead. Under the user's home, keyed by the
|
|
45
45
|
* absolute path of the project it belongs to, one file per canvas per machine.
|
|
46
|
-
* Nothing serves that directory, so there is no path to guard.
|
|
46
|
+
* Nothing serves that directory, so there is no path to guard. (MARVER_HOME moves
|
|
47
|
+
* it with the registry: the test suite's, so no test writes the owner's.)
|
|
47
48
|
*
|
|
48
49
|
* The old location is still read once, moved, and removed - a credential left
|
|
49
50
|
* behind in a repo is exactly the thing being fixed.
|
|
50
51
|
*/
|
|
51
52
|
const legacyCollabFile = (root) => join(root, "design", ".local", "collab.json");
|
|
52
|
-
const collabDir = () => join(
|
|
53
|
+
const collabDir = () => join(marverHome(), "canvases");
|
|
53
54
|
const collabFile = (root) => {
|
|
54
55
|
let canonical = root;
|
|
55
56
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { s as listBoardFiles } from "./boards-CGg6piKF.mjs";
|
|
3
|
-
import { r as pidRuns } from "./
|
|
3
|
+
import { r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
|
|
4
4
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
@@ -128,13 +128,15 @@ function removeDevInfo(root, instance = written.get(root)) {
|
|
|
128
128
|
if (written.get(root) === instance) written.delete(root);
|
|
129
129
|
} catch {}
|
|
130
130
|
}
|
|
131
|
+
/** The running server's dev.json: its port and token, and its pid (a file from before 0.26 has none). */
|
|
131
132
|
function readDevInfo(root) {
|
|
132
133
|
try {
|
|
133
134
|
const v = JSON.parse(readFileSync(infoPath(root), "utf8"));
|
|
134
135
|
if (v?.pid !== void 0 && !pidRuns(v.pid)) return null;
|
|
135
136
|
return typeof v?.port === "number" && typeof v?.token === "string" ? {
|
|
136
137
|
port: v.port,
|
|
137
|
-
token: v.token
|
|
138
|
+
token: v.token,
|
|
139
|
+
...typeof v.pid === "number" ? { pid: v.pid } : {}
|
|
138
140
|
} : null;
|
|
139
141
|
} catch {
|
|
140
142
|
return null;
|