@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,179 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { linkSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { randomBytes, randomUUID } from "node:crypto";
|
|
5
|
-
import { createServer } from "node:net";
|
|
6
|
-
//#region src/server/dev-lock.ts
|
|
7
|
-
/**
|
|
8
|
-
* One canvas per folder (#19, spec 27 Part 7). `marver dev` takes design/.local/dev.lock before it
|
|
9
|
-
* starts the server, so a second `marver dev` in the same folder says where the first one runs
|
|
10
|
-
* instead of taking over dev.json (which the CLI - `work`, `shot`, `comments new --on` - reads to
|
|
11
|
-
* find the canvas).
|
|
12
|
-
*
|
|
13
|
-
* The rules, none of which guess a holder dead from time or from an unanswered request:
|
|
14
|
-
* - no lock: create it exclusively. Done.
|
|
15
|
-
* - a lock whose pid runs: a canvas runs here (a slow or paused one too) - stop with its link.
|
|
16
|
-
* - a lock whose pid is dead: reclaim it while holding dev.lock.reclaim (also exclusive): read it
|
|
17
|
-
* again, still the same dead holder -> replace it. A reclaim lock already there means another
|
|
18
|
-
* start is reclaiming: wait a second and start over once; still there -> fail closed.
|
|
19
|
-
* - a 0.25 server writes no lock and no pid: dev.json without a lock is decided by binding its port.
|
|
20
|
-
*
|
|
21
|
-
* Both files are created by linking a fully written temp file into place, so a reader never sees
|
|
22
|
-
* an empty or half-written lock - `link` fails if the name exists, which is the exclusive create.
|
|
23
|
-
*/
|
|
24
|
-
var dev_lock_exports = /* @__PURE__ */ __exportAll({
|
|
25
|
-
RECLAIM_STUCK: () => RECLAIM_STUCK,
|
|
26
|
-
createExclusive: () => createExclusive,
|
|
27
|
-
pidRuns: () => pidRuns,
|
|
28
|
-
portInUse: () => portInUse,
|
|
29
|
-
releaseDevLock: () => releaseDevLock,
|
|
30
|
-
takeDevLock: () => takeDevLock
|
|
31
|
-
});
|
|
32
|
-
const localDir = (root) => join(root, "design", ".local");
|
|
33
|
-
const lockPath = (root) => join(localDir(root), "dev.lock");
|
|
34
|
-
const reclaimPath = (root) => `${lockPath(root)}.reclaim`;
|
|
35
|
-
const infoPath = (root) => join(localDir(root), "dev.json");
|
|
36
|
-
/** Is this pid a running process? EPERM means it runs under another user - still running. A
|
|
37
|
-
* process paused with SIGSTOP runs too, as far as this is concerned. */
|
|
38
|
-
function pidRuns(pid) {
|
|
39
|
-
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
|
|
40
|
-
try {
|
|
41
|
-
process.kill(pid, 0);
|
|
42
|
-
return true;
|
|
43
|
-
} catch (err) {
|
|
44
|
-
return err.code === "EPERM";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/** Create `file` holding `body`, failing with EEXIST if it is there - atomically, content included. */
|
|
48
|
-
function createExclusive(file, body) {
|
|
49
|
-
const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
50
|
-
writeFileSync(tmp, body, { mode: 384 });
|
|
51
|
-
try {
|
|
52
|
-
linkSync(tmp, file);
|
|
53
|
-
} finally {
|
|
54
|
-
try {
|
|
55
|
-
unlinkSync(tmp);
|
|
56
|
-
} catch {}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const readJson = (file) => {
|
|
60
|
-
try {
|
|
61
|
-
return JSON.parse(readFileSync(file, "utf8"));
|
|
62
|
-
} catch (err) {
|
|
63
|
-
return err.code === "ENOENT" ? void 0 : null;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const asHolder = (v) => {
|
|
67
|
-
const h = v;
|
|
68
|
-
return h && typeof h.pid === "number" && typeof h.instance === "string" ? {
|
|
69
|
-
pid: h.pid,
|
|
70
|
-
instance: h.instance,
|
|
71
|
-
at: Number(h.at) || 0
|
|
72
|
-
} : null;
|
|
73
|
-
};
|
|
74
|
-
/** Is anything listening on `port` on this machine? Vite binds ::1 for `localhost`, an older or
|
|
75
|
-
* configured one 127.0.0.1 - a port is in use if either refuses the bind. */
|
|
76
|
-
async function portInUse(port) {
|
|
77
|
-
const bind = (host) => new Promise((res) => {
|
|
78
|
-
const s = createServer();
|
|
79
|
-
s.once("error", (err) => res(err.code === "EADDRINUSE" || err.code === "EACCES"));
|
|
80
|
-
s.once("listening", () => s.close(() => res(false)));
|
|
81
|
-
s.listen(port, host);
|
|
82
|
-
});
|
|
83
|
-
return await bind("127.0.0.1") || await bind("::1");
|
|
84
|
-
}
|
|
85
|
-
const runsHere = (root) => {
|
|
86
|
-
const port = readJson(infoPath(root))?.port;
|
|
87
|
-
return typeof port === "number" ? `a canvas already runs here: http://localhost:${port} - open it, or stop it first` : "a canvas already runs here - open it, or stop it first";
|
|
88
|
-
};
|
|
89
|
-
const RECLAIM_STUCK = "a canvas is starting here, or a start crashed: delete design/.local/dev.lock.reclaim if no canvas runs";
|
|
90
|
-
/** Take the folder's canvas lock. On success the caller owns dev.lock until `release()` (which
|
|
91
|
-
* removes it only while it still names this instance). */
|
|
92
|
-
async function takeDevLock(root, opts = {}) {
|
|
93
|
-
mkdirSync(localDir(root), { recursive: true });
|
|
94
|
-
const me = {
|
|
95
|
-
pid: opts.pid ?? process.pid,
|
|
96
|
-
instance: randomUUID(),
|
|
97
|
-
at: Date.now()
|
|
98
|
-
};
|
|
99
|
-
const body = JSON.stringify(me);
|
|
100
|
-
const release = () => releaseDevLock(root, me.instance);
|
|
101
|
-
const won = async () => {
|
|
102
|
-
const info = readJson(infoPath(root));
|
|
103
|
-
if (info && info.instance !== me.instance) {
|
|
104
|
-
if (typeof info.pid === "number" ? pidRuns(info.pid) : typeof info.port === "number" ? await portInUse(info.port) : false) {
|
|
105
|
-
release();
|
|
106
|
-
return {
|
|
107
|
-
ok: false,
|
|
108
|
-
message: `${runsHere(root)}${typeof info.pid === "number" ? "" : " (or delete design/.local/dev.json if it is not)"}`
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
ok: true,
|
|
114
|
-
instance: me.instance,
|
|
115
|
-
release
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
for (let round = 0; round < 2; round++) {
|
|
119
|
-
try {
|
|
120
|
-
createExclusive(lockPath(root), body);
|
|
121
|
-
return await won();
|
|
122
|
-
} catch (err) {
|
|
123
|
-
if (err.code !== "EEXIST") throw err;
|
|
124
|
-
}
|
|
125
|
-
const raw = readJson(lockPath(root));
|
|
126
|
-
if (raw === void 0) continue;
|
|
127
|
-
const holder = asHolder(raw);
|
|
128
|
-
if (!holder) return {
|
|
129
|
-
ok: false,
|
|
130
|
-
message: "design/.local/dev.lock is unreadable: delete it if no canvas runs"
|
|
131
|
-
};
|
|
132
|
-
if (pidRuns(holder.pid)) return {
|
|
133
|
-
ok: false,
|
|
134
|
-
message: runsHere(root)
|
|
135
|
-
};
|
|
136
|
-
try {
|
|
137
|
-
createExclusive(reclaimPath(root), body);
|
|
138
|
-
} catch (err) {
|
|
139
|
-
if (err.code !== "EEXIST") throw err;
|
|
140
|
-
if (round === 0) {
|
|
141
|
-
await new Promise((r) => setTimeout(r, opts.reclaimWaitMs ?? 1e3));
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
ok: false,
|
|
146
|
-
message: RECLAIM_STUCK
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
const again = asHolder(readJson(lockPath(root)));
|
|
151
|
-
if (again && again.pid === holder.pid && again.instance === holder.instance) {
|
|
152
|
-
unlinkSync(lockPath(root));
|
|
153
|
-
try {
|
|
154
|
-
createExclusive(lockPath(root), body);
|
|
155
|
-
return await won();
|
|
156
|
-
} catch (err) {
|
|
157
|
-
if (err.code !== "EEXIST") throw err;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
} finally {
|
|
161
|
-
try {
|
|
162
|
-
unlinkSync(reclaimPath(root));
|
|
163
|
-
} catch {}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const last = asHolder(readJson(lockPath(root)));
|
|
167
|
-
return {
|
|
168
|
-
ok: false,
|
|
169
|
-
message: last && pidRuns(last.pid) ? runsHere(root) : RECLAIM_STUCK
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/** Remove dev.lock if it still names `instance` - a lock some other start took over stays. */
|
|
173
|
-
function releaseDevLock(root, instance) {
|
|
174
|
-
try {
|
|
175
|
-
if (asHolder(readJson(lockPath(root)))?.instance === instance) unlinkSync(lockPath(root));
|
|
176
|
-
} catch {}
|
|
177
|
-
}
|
|
178
|
-
//#endregion
|
|
179
|
-
export { dev_lock_exports as n, pidRuns as r, createExclusive as t };
|
package/dist/perf-C75MZ73h.mjs
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { r as readReloads } from "./perf-DPbLGhhO.mjs";
|
|
2
|
-
import { r as readJam } from "./perf-jam-BU3TVrZu.mjs";
|
|
3
|
-
//#region src/cli/perf.ts
|
|
4
|
-
/**
|
|
5
|
-
* `marver perf` (spec 26 Part 1): the reload log read back - per edited file, the frames it reached
|
|
6
|
-
* and how; every page-wide reload (sent or dropped) and every time the canvas page itself booted,
|
|
7
|
-
* with what came just before; the slowest frames to settle. Reads design/.local/perf/reloads.jsonl.
|
|
8
|
-
*/
|
|
9
|
-
function perfCommand(root, opts) {
|
|
10
|
-
if (opts.jam) return jamPerf(root, opts);
|
|
11
|
-
const minutes = Number(opts.minutes) > 0 ? Number(opts.minutes) : 60;
|
|
12
|
-
const log = readReloads(root, Date.now() - minutes * 6e4);
|
|
13
|
-
const files = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const e of log) if (e.kind === "update") {
|
|
15
|
-
const f = files.get(e.file ?? "(no file)") ?? {
|
|
16
|
-
edits: 0,
|
|
17
|
-
reload: /* @__PURE__ */ new Set(),
|
|
18
|
-
inPlace: /* @__PURE__ */ new Set()
|
|
19
|
-
};
|
|
20
|
-
f.edits++;
|
|
21
|
-
for (const id of e.reload ?? []) f.reload.add(id);
|
|
22
|
-
for (const id of e.inPlace ?? []) f.inPlace.add(id);
|
|
23
|
-
files.set(e.file ?? "(no file)", f);
|
|
24
|
-
}
|
|
25
|
-
const reloads = log.filter((e) => e.kind === "full-reload");
|
|
26
|
-
const boots = log.flatMap((e, i) => e.kind === "shell-boot" ? [{
|
|
27
|
-
ts: e.ts,
|
|
28
|
-
before: log.slice(Math.max(0, i - 3), i).filter((x) => x.kind !== "ready" && x.kind !== "settled")
|
|
29
|
-
}] : []);
|
|
30
|
-
const slow = log.filter((e) => e.kind === "settled" && typeof e.ms === "number").sort((a, b) => b.ms - a.ms).slice(0, 5);
|
|
31
|
-
const booted = log.filter((e) => e.kind === "ready");
|
|
32
|
-
const by = (c) => booted.filter((e) => e.cause === c).length;
|
|
33
|
-
const reloaded = by("job");
|
|
34
|
-
if (opts.json) {
|
|
35
|
-
console.log(JSON.stringify({
|
|
36
|
-
minutes,
|
|
37
|
-
files: Object.fromEntries([...files].map(([k, v]) => [k, {
|
|
38
|
-
edits: v.edits,
|
|
39
|
-
reached: [...v.reload],
|
|
40
|
-
inPlace: [...v.inPlace]
|
|
41
|
-
}])),
|
|
42
|
-
documents: {
|
|
43
|
-
afterEdit: reloaded,
|
|
44
|
-
byHand: by("manual"),
|
|
45
|
-
retried: by("retry"),
|
|
46
|
-
self: by("self"),
|
|
47
|
-
first: by("first")
|
|
48
|
-
},
|
|
49
|
-
reloads,
|
|
50
|
-
boots,
|
|
51
|
-
slow
|
|
52
|
-
}, null, 2));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const t = (ts) => new Date(ts).toLocaleTimeString();
|
|
56
|
-
console.log(`last ${minutes} min - design/.local/perf/reloads.jsonl`);
|
|
57
|
-
console.log(`\nedits (${files.size} files)`);
|
|
58
|
-
for (const [file, f] of [...files].sort((a, b) => b[1].edits - a[1].edits)) console.log(` ${file} ${f.edits}x reached ${f.reload.size} frame${f.reload.size === 1 ? "" : "s"}${f.inPlace.size ? `, ${f.inPlace.size} updated in place` : ""}`);
|
|
59
|
-
console.log(`\nframe documents booted: ${reloaded} after an edit (a frame off screen reloads when it comes into view), ${by("first")} first loads, ${by("manual")} by hand, ${by("retry")} watchdog retries, ${by("self")} reloaded themselves`);
|
|
60
|
-
console.log(`\npage-wide reloads: ${reloads.filter((r) => r.passed).length} sent (dependency rebuilds), ${reloads.filter((r) => !r.passed).length} dropped`);
|
|
61
|
-
for (const r of reloads) console.log(` ${t(r.ts)} ${r.passed ? "sent " : "dropped"} ${r.triggeredBy ?? "no file named"}`);
|
|
62
|
-
console.log(`\ncanvas page loads: ${boots.length}`);
|
|
63
|
-
for (const b of boots) console.log(` ${t(b.ts)}${b.before.length ? ` after: ${b.before.map((x) => x.kind + (x.file ? ` ${x.file}` : "")).join(", ")}` : ""}`);
|
|
64
|
-
if (slow.length) {
|
|
65
|
-
console.log("\nslowest to settle");
|
|
66
|
-
for (const s of slow) console.log(` ${s.frame} ${s.ms} ms`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/** Count, median, p90 and max of a list of ms. */
|
|
70
|
-
function spread(xs) {
|
|
71
|
-
if (!xs.length) return { n: 0 };
|
|
72
|
-
const v = [...xs].sort((a, b) => a - b);
|
|
73
|
-
const at = (q) => v[Math.min(v.length - 1, Math.ceil(q * v.length) - 1)];
|
|
74
|
-
return {
|
|
75
|
-
n: v.length,
|
|
76
|
-
median: at(.5),
|
|
77
|
-
p90: at(.9),
|
|
78
|
-
max: v[v.length - 1]
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/** `marver perf --jam`: each step of a capture and its run - count, median, p90, max - the runs by outcome, and the
|
|
82
|
-
* last problems, from design/.local/perf/jam.jsonl (numbers and codes only). */
|
|
83
|
-
function jamSummary(events) {
|
|
84
|
-
const of = (kind) => events.filter((e) => e.kind === kind);
|
|
85
|
-
const nums = (xs) => xs.filter((x) => typeof x === "number");
|
|
86
|
-
const caps = of("capture"), runs = of("run").filter((r) => !r.redelivered), shots = of("shot"), words = of("words");
|
|
87
|
-
const steps = {
|
|
88
|
-
"capture: E to sealed": spread(nums(caps.map((c) => c.sealMs))),
|
|
89
|
-
"capture: last words": spread(nums(caps.map((c) => c.wordsWaitMs))),
|
|
90
|
-
"capture: a picture": spread(nums(caps.flatMap((c) => c.pictures?.ms ?? []))),
|
|
91
|
-
"upload": spread(nums(of("upload").map((u) => u.ms))),
|
|
92
|
-
"naming": spread(nums(of("name").map((n) => n.ms))),
|
|
93
|
-
"words: wait": spread(nums(words.map((w) => w.waitMs))),
|
|
94
|
-
"words: transcription": spread(nums(words.map((w) => w.decodeMs))),
|
|
95
|
-
"words: model load": spread(nums(words.map((w) => w.modelLoadMs))),
|
|
96
|
-
"run: queued": spread(nums(runs.flatMap((r) => (r.members ?? []).map((m) => m.waitMs)))),
|
|
97
|
-
"run: pictures before": spread(nums(runs.map((r) => r.beforeMs))),
|
|
98
|
-
"run: agent": spread(nums(runs.flatMap((r) => r.agentMs ?? []))),
|
|
99
|
-
"run: pictures after": spread(nums(runs.map((r) => r.afterMs))),
|
|
100
|
-
"run: delivery": spread(nums(of("run").map((r) => r.deliverMs))),
|
|
101
|
-
"shot": spread(nums(shots.map((s) => s.ms)))
|
|
102
|
-
};
|
|
103
|
-
const outcomes = {};
|
|
104
|
-
for (const r of runs) for (const m of r.members ?? []) outcomes[m.outcome ?? "unknown"] = (outcomes[m.outcome ?? "unknown"] ?? 0) + 1;
|
|
105
|
-
return {
|
|
106
|
-
steps,
|
|
107
|
-
outcomes,
|
|
108
|
-
problems: [
|
|
109
|
-
...of("run").filter((r) => r.failure).map((r) => ({
|
|
110
|
-
ts: r.ts,
|
|
111
|
-
what: `run ${String(r.batch).slice(0, 8)} ${r.redelivered ? "could not post its replies" : `failed: ${r.failure}`}`
|
|
112
|
-
})),
|
|
113
|
-
...shots.filter((s) => s.outcome && s.outcome !== "ok").map((s) => ({
|
|
114
|
-
ts: s.ts,
|
|
115
|
-
what: `shot ${s.frame ?? "?"}: ${s.outcome}${s.recaptures ? ` after ${s.recaptures} retakes` : ""}`
|
|
116
|
-
})),
|
|
117
|
-
...caps.filter((c) => c.pictures?.late || c.pictures?.failed).map((c) => ({
|
|
118
|
-
ts: c.ts,
|
|
119
|
-
what: `capture ${c.capture}: ${c.pictures.late ?? 0} picture(s) too late, ${c.pictures.failed ?? 0} failed`
|
|
120
|
-
})),
|
|
121
|
-
...of("name").filter((n) => !n.ok).map((n) => ({
|
|
122
|
-
ts: n.ts,
|
|
123
|
-
what: `naming ${n.capture} gave no name`
|
|
124
|
-
})),
|
|
125
|
-
...of("dropped").map((d) => ({
|
|
126
|
-
ts: d.ts,
|
|
127
|
-
what: `${d.count} event(s) dropped (the log was busy)`
|
|
128
|
-
}))
|
|
129
|
-
].sort((a, b) => b.ts - a.ts).slice(0, 10),
|
|
130
|
-
retakes: shots.reduce((n, s) => n + (s.recaptures ?? 0), 0)
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function jamPerf(root, opts) {
|
|
134
|
-
const minutes = Number(opts.minutes) > 0 ? Number(opts.minutes) : 1440;
|
|
135
|
-
const since = Date.now() - minutes * 6e4;
|
|
136
|
-
const { events, first } = readJam(root, since);
|
|
137
|
-
const sum = jamSummary(events);
|
|
138
|
-
const partial = first !== void 0 && first > since;
|
|
139
|
-
if (opts.json) {
|
|
140
|
-
console.log(JSON.stringify({
|
|
141
|
-
minutes,
|
|
142
|
-
...partial ? { startsAt: first } : {},
|
|
143
|
-
...sum
|
|
144
|
-
}, null, 2));
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const span = minutes >= 120 ? `${Math.round(minutes / 60)} h` : `${minutes} min`;
|
|
148
|
-
console.log(`Jam timings, last ${span} - design/.local/perf/jam.jsonl${partial ? ` (the log starts ${new Date(first).toLocaleString()})` : ""}`);
|
|
149
|
-
if (!events.length) {
|
|
150
|
-
console.log("\nnothing yet - captures, runs and shots log here as they happen");
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
console.log("");
|
|
154
|
-
const pad = (s, n) => s + " ".repeat(Math.max(1, n - s.length));
|
|
155
|
-
console.log(` ${pad("step", 24)}${pad("count", 7)}${pad("median", 9)}${pad("p90", 9)}max`);
|
|
156
|
-
const f = (v) => v === void 0 ? "-" : v >= 1e4 ? `${(v / 1e3).toFixed(0)} s` : v >= 1e3 ? `${(v / 1e3).toFixed(1)} s` : `${v} ms`;
|
|
157
|
-
for (const [name, x] of Object.entries(sum.steps)) if (x.n) console.log(` ${pad(name, 24)}${pad(String(x.n), 7)}${pad(f(x.median), 9)}${pad(f(x.p90), 9)}${f(x.max)}`);
|
|
158
|
-
const out = Object.entries(sum.outcomes);
|
|
159
|
-
if (out.length) console.log(`\nruns by outcome: ${out.map(([k, n]) => `${n} ${k}`).join(", ")}`);
|
|
160
|
-
if (sum.retakes) console.log(`pictures taken again (a stale surface): ${sum.retakes}`);
|
|
161
|
-
if (sum.problems.length) {
|
|
162
|
-
console.log("\nlately");
|
|
163
|
-
for (const p of sum.problems) console.log(` ${new Date(p.ts).toLocaleTimeString()} ${p.what}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
//#endregion
|
|
167
|
-
export { perfCommand };
|
package/dist/perf-DPbLGhhO.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { a as checkRealDirs } from "./boards-CGg6piKF.mjs";
|
|
3
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
//#region src/server/perf.ts
|
|
6
|
-
/**
|
|
7
|
-
* The reload log (spec 26 Part 1): one JSON line per event in design/.local/perf/reloads.jsonl -
|
|
8
|
-
* the server's view (an edit and the frames it reached, a full reload sent or dropped) and the
|
|
9
|
-
* page's (each document that actually booted, and how long it took). Local, never committed.
|
|
10
|
-
* `npx marver perf` reads it back.
|
|
11
|
-
*/
|
|
12
|
-
var perf_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
-
logReload: () => logReload,
|
|
14
|
-
readReloads: () => readReloads,
|
|
15
|
-
reloadLog: () => reloadLog
|
|
16
|
-
});
|
|
17
|
-
const MAX = 2e6;
|
|
18
|
-
const reloadLog = (root) => join(root, "design", ".local", "perf", "reloads.jsonl");
|
|
19
|
-
function logReload(root, entry) {
|
|
20
|
-
try {
|
|
21
|
-
if (checkRealDirs(root, [[join(root, "design"), "design"], [join(root, "design", ".local"), "design/.local"]])) return;
|
|
22
|
-
const file = reloadLog(root);
|
|
23
|
-
mkdirSync(join(file, ".."), { recursive: true });
|
|
24
|
-
if (existsSync(file) && statSync(file).size > MAX) {
|
|
25
|
-
const lines = readFileSync(file, "utf8").split("\n");
|
|
26
|
-
writeFileSync(file, lines.slice(Math.floor(lines.length / 2)).join("\n"));
|
|
27
|
-
}
|
|
28
|
-
appendFileSync(file, JSON.stringify({
|
|
29
|
-
ts: Date.now(),
|
|
30
|
-
...entry
|
|
31
|
-
}) + "\n");
|
|
32
|
-
} catch {}
|
|
33
|
-
}
|
|
34
|
-
function readReloads(root, since = 0) {
|
|
35
|
-
try {
|
|
36
|
-
return readFileSync(reloadLog(root), "utf8").split("\n").flatMap((l) => {
|
|
37
|
-
try {
|
|
38
|
-
const e = JSON.parse(l);
|
|
39
|
-
return typeof e?.ts === "number" && e.ts >= since ? [e] : [];
|
|
40
|
-
} catch {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
} catch {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { perf_exports as n, readReloads as r, logReload as t };
|