@marver-design/marver 0.27.0 → 0.28.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 +195 -0
- package/README.md +9 -4
- package/dist/{anchor-check-ChdDqL5z.mjs → anchor-check-PHUOFj1N.mjs} +1 -1
- package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
- package/dist/{board-tree-DRioF94d.mjs → board-tree-BXR8dw4b.mjs} +3 -1
- package/dist/{boards-DlTcpF47.mjs → boards-BeWtjGUM.mjs} +50 -5
- package/dist/boards-EH2onUXM.mjs +995 -0
- package/dist/{build-DZnFysGU.mjs → build-BsAyLMT1.mjs} +9 -22
- package/dist/{capture-vadKjuCo.mjs → capture-DdZ6xgoz.mjs} +92 -30
- package/dist/cli.mjs +56 -21
- package/dist/{collab-Dxg2trOK.mjs → collab-BEAcXrBb.mjs} +1 -1
- package/dist/{comments-DxOkCSNE.mjs → comments-CrBHPEQl.mjs} +4 -4
- package/dist/config-BezZTiov.mjs +182 -0
- package/dist/conn-BMiHS42T.mjs +222 -0
- package/dist/connectors-MR9d-EBP.mjs +290 -0
- package/dist/{context-HQ4Giw58.mjs → context-BUnFiyA3.mjs} +3 -3
- package/dist/{daemon-BSA0lV8d.mjs → daemon-C5dg2R-V.mjs} +2188 -183
- package/dist/{dev-eQJhWsqg.mjs → dev-D7YS7iT2.mjs} +25 -14
- package/dist/{init-COD0x48i.mjs → init-WE5lQkQL.mjs} +8 -3
- package/dist/jam-Cj5gBvwD.mjs +373 -0
- package/dist/{link-DDXZVGtv.mjs → link-BFFRgrMt.mjs} +4 -4
- package/dist/listener-DdLEM79A.mjs +80 -0
- package/dist/{ls-D7O1G505.mjs → ls-BZ5TAtd5.mjs} +1 -1
- package/dist/{manifest-Nl3KSVOk.mjs → manifest-DPZ3WNg_.mjs} +2 -2
- package/dist/{marks-CWM3WJjc.mjs → marks-Dyn6tmjp.mjs} +3 -3
- package/dist/{marks-CKgzucHZ.mjs → marks-Kmdab_5w.mjs} +3 -3
- package/dist/{marver-id-gate-BjF6v4bT.mjs → marver-id-gate-D-R0hSt_.mjs} +1 -1
- package/dist/perf-Cn5LiRaY.mjs +1319 -0
- package/dist/perf-jam-QxD_UnzN.mjs +635 -0
- package/dist/permit-DDa6wqOs.mjs +187 -0
- package/dist/plugin-C_0yb-Fq.mjs +5089 -0
- package/dist/{poster-Bx83ZYVK.mjs → poster-DHi6I1fO.mjs} +1 -1
- package/dist/{profile-Bh5Y5zpW.mjs → profile-jIS6BcAs.mjs} +1 -1
- package/dist/{publish-bakes-aljgm45S.mjs → publish-bakes-r4PEZuPl.mjs} +3 -3
- package/dist/{queue-CAM_vNmX.mjs → queue-c-6aTHEz.mjs} +164 -25
- package/dist/{recover-t9Pno3u9.mjs → recover-nrLEVLyJ.mjs} +2 -2
- package/dist/{serve-C8rVheYk.mjs → serve-Dp3nHstu.mjs} +3 -3
- package/dist/{session-BAaJsK5c.mjs → session-DyVE7cCk.mjs} +1 -1
- package/dist/{share-W5H3BNvP.mjs → share-Ce4tP7ji.mjs} +1 -1
- package/dist/{shot-LFhC-WYD.mjs → shot-BrRtqaiS.mjs} +34 -8
- package/dist/{shot-DoHLl6ig.mjs → shot-DBWN8hPP.mjs} +1 -1
- package/dist/sizes-wjXDev3b.mjs +139 -0
- package/dist/{slots-DCDo3N0x.mjs → slots-CFNnegCc.mjs} +8 -1
- package/dist/speech-worker.mjs +23 -3
- package/dist/{sync-BQVlHZpx.mjs → sync-CQdGARJ9.mjs} +1 -1
- package/dist/transport-C5FnY9ni.mjs +203 -0
- package/dist/{work-BroFwnup.mjs → work-BYWD_1Zf.mjs} +3 -3
- package/dist/{work-Bp1p39kq.mjs → work-DJxH7cCX.mjs} +1 -1
- package/docs/jam-session.md +42 -16
- package/docs/live-jam.md +92 -10
- package/docs/performance.md +197 -35
- package/package.json +1 -1
- package/src/client/content/video.tsx +10 -2
- package/src/client/shell/App.tsx +10 -3
- package/src/client/shell/Comments.tsx +5 -3
- package/src/client/shell/ContextMenu.tsx +5 -3
- package/src/client/shell/JamSurface.tsx +56 -21
- package/src/client/shell/LockedApp.tsx +3 -0
- package/src/client/shell/Play.tsx +4 -2
- package/src/client/shell/Tip.tsx +3 -1
- package/src/client/shell/api.ts +47 -20
- package/src/client/shell/app-bridge.ts +254 -0
- package/src/client/shell/app-perf.ts +92 -0
- package/src/client/shell/canvas/Canvas.tsx +115 -22
- package/src/client/shell/canvas/FrameNode.tsx +10 -6
- package/src/client/shell/canvas/admission.ts +23 -8
- package/src/client/shell/canvas/ctl.ts +6 -0
- package/src/client/shell/canvas/sleep.ts +57 -17
- package/src/client/shell/canvas/updates.ts +2 -1
- package/src/client/shell/icons.tsx +1 -0
- package/src/client/shell/inset.ts +44 -0
- package/src/client/shell/jam-capture.ts +113 -33
- package/src/client/shell/jam-keys.ts +40 -9
- package/src/client/shell/jam-lane.tsx +14 -5
- package/src/client/shell/jam-lines.ts +66 -9
- package/src/client/shell/jam-panel.tsx +61 -6
- package/src/client/shell/jam-queue.ts +50 -8
- package/src/client/shell/jam-session.tsx +53 -4
- package/src/client/shell/jam-surface-parts.tsx +6 -3
- package/src/client/shell/jam-ui.tsx +6 -1
- package/src/client/shell/jam-voice-wait.ts +21 -0
- package/src/client/shell/jam-voice.ts +62 -15
- package/src/client/shell/main.tsx +14 -1
- package/src/client/shell/marks-ui.tsx +5 -3
- package/src/client/shell/marver-app.ts +21 -0
- package/src/client/shell/perf-run-probe.ts +34 -0
- package/src/client/shell/perf-run.ts +70 -0
- package/src/client/shell/perf.ts +11 -0
- package/src/client/shell/recorder.ts +45 -3
- package/src/client/shell/store.ts +52 -24
- package/src/client/shell/styles.css +65 -17
- package/src/client/shell/tidy.ts +3 -2
- package/src/client/shell/unsaved.ts +81 -0
- package/src/client/shell/whiteout-probes.ts +141 -0
- package/src/shared/app-api.ts +205 -0
- package/src/shared/app-perf.ts +308 -0
- package/src/shared/approval.ts +20 -0
- package/src/shared/events.ts +1 -1
- package/src/shared/logo-sniff.ts +86 -0
- package/src/shared/machine.ts +132 -0
- package/src/shared/perf-run.ts +177 -0
- package/templates/AGENTS-embedded.md +31 -1
- package/templates/AGENTS-studio.md +31 -1
- package/templates/instructions/boards.md +10 -2
- package/templates/instructions/jam.md +90 -0
- package/dist/bake-DM_uWgAA.mjs +0 -786
- package/dist/boards-CGg6piKF.mjs +0 -342
- package/dist/perf-BWzQwZqj.mjs +0 -369
- package/dist/perf-BoDSkbEb.mjs +0 -429
- package/dist/perf-jam-D55U3FZK.mjs +0 -242
- package/dist/plugin-C-E7omsh.mjs +0 -2762
package/dist/perf-BWzQwZqj.mjs
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { a as checkRealDirs } from "./boards-CGg6piKF.mjs";
|
|
3
|
-
import { appendFileSync, chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { basename, join } from "node:path";
|
|
5
|
-
//#region src/server/perf.ts
|
|
6
|
-
/**
|
|
7
|
-
* The perf logs, one JSON line per event in design/.local/perf/ - local, never committed, the owner's alone (the
|
|
8
|
-
* directory 700, every file in it 600). `npx marver perf` reads them back.
|
|
9
|
-
* - reloads.jsonl, the reload log (spec 26 Part 1): the server's view (an edit and the frames it reached, a full
|
|
10
|
-
* reload sent or dropped) and the page's (each document that actually booted, and how long it took);
|
|
11
|
-
* - page.jsonl, the recorder's page half (spec 28 A1.7): what each board load did, from the page - its request and
|
|
12
|
-
* commit, each frame's outcome, every move and why, quiet, the last move and settled - plus gestures and
|
|
13
|
-
* errors. Each record is rebuilt from its kind's allowlist; `npx marver perf --loads` reads them back.
|
|
14
|
-
*/
|
|
15
|
-
var perf_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
-
CUT_REASONS: () => CUT_REASONS,
|
|
17
|
-
DROP_REASONS: () => DROP_REASONS,
|
|
18
|
-
GESTURES: () => GESTURES,
|
|
19
|
-
LOAD_CAUSES: () => LOAD_CAUSES,
|
|
20
|
-
OUTCOMES: () => OUTCOMES,
|
|
21
|
-
PAGE_BODY_MAX: () => PAGE_BODY_MAX,
|
|
22
|
-
PAGE_KINDS: () => PAGE_KINDS,
|
|
23
|
-
SOURCES: () => SOURCES,
|
|
24
|
-
cleanPageRecord: () => cleanPageRecord,
|
|
25
|
-
logPage: () => logPage,
|
|
26
|
-
logReload: () => logReload,
|
|
27
|
-
pageLog: () => pageLog,
|
|
28
|
-
perfDir: () => perfDir,
|
|
29
|
-
readPage: () => readPage,
|
|
30
|
-
readReloads: () => readReloads,
|
|
31
|
-
reloadLog: () => reloadLog,
|
|
32
|
-
tidyPerfDir: () => tidyPerfDir
|
|
33
|
-
});
|
|
34
|
-
const MAX = 2e6;
|
|
35
|
-
/** page.jsonl's: one load of a 120-frame board writes ~140 KB (two thirds of it moves), so 2 MB held about fourteen
|
|
36
|
-
* such loads - hours, not the 14 days the lines may stay. 8 MB holds four times as many. */
|
|
37
|
-
const PAGE_MAX = 8e6;
|
|
38
|
-
const maxOf = (file) => basename(file) === "page.jsonl" ? PAGE_MAX : MAX;
|
|
39
|
-
const KEEP_MS = 12096e5;
|
|
40
|
-
/** The logs whose lines age out and whose size is held at start (spec 28 A1.7, A1.13): every one with a `ts` per line. */
|
|
41
|
-
const AGED = [
|
|
42
|
-
"reloads.jsonl",
|
|
43
|
-
"page.jsonl",
|
|
44
|
-
"runs.jsonl",
|
|
45
|
-
"jam.jsonl"
|
|
46
|
-
];
|
|
47
|
-
const perfDir = (root) => join(root, "design", ".local", "perf");
|
|
48
|
-
const reloadLog = (root) => join(perfDir(root), "reloads.jsonl");
|
|
49
|
-
const pageLog = (root) => join(perfDir(root), "page.jsonl");
|
|
50
|
-
/** design/, design/.local and its perf/ must be real directories inside the project: a log is never written through a link. */
|
|
51
|
-
const unsafe = (root) => checkRealDirs(root, [
|
|
52
|
-
[join(root, "design"), "design"],
|
|
53
|
-
[join(root, "design", ".local"), "design/.local"],
|
|
54
|
-
[perfDir(root), "design/.local/perf"]
|
|
55
|
-
]);
|
|
56
|
-
/** One append to a perf log: the directory 700 and the file 600 from their creation, never through a link, the
|
|
57
|
-
* oldest half gone past its cap (maxOf). Throws - callers swallow. */
|
|
58
|
-
function appendLog(root, file, text) {
|
|
59
|
-
const why = unsafe(root);
|
|
60
|
-
if (why) throw new Error(why);
|
|
61
|
-
mkdirSync(join(root, "design", ".local"), { recursive: true });
|
|
62
|
-
mkdirSync(perfDir(root), {
|
|
63
|
-
recursive: true,
|
|
64
|
-
mode: 448
|
|
65
|
-
});
|
|
66
|
-
if (existsSync(file)) {
|
|
67
|
-
if (!lstatSync(file).isFile()) throw new Error("not a regular file");
|
|
68
|
-
if (statSync(file).size > maxOf(file)) {
|
|
69
|
-
const lines = readFileSync(file, "utf8").split("\n");
|
|
70
|
-
writeFileSync(file, lines.slice(Math.floor(lines.length / 2)).join("\n"));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
appendFileSync(file, text, { mode: 384 });
|
|
74
|
-
}
|
|
75
|
-
function logReload(root, entry) {
|
|
76
|
-
try {
|
|
77
|
-
appendLog(root, reloadLog(root), JSON.stringify({
|
|
78
|
-
ts: Date.now(),
|
|
79
|
-
...entry
|
|
80
|
-
}) + "\n");
|
|
81
|
-
} catch {}
|
|
82
|
-
}
|
|
83
|
-
const readLines = (file, since) => {
|
|
84
|
-
try {
|
|
85
|
-
return readFileSync(file, "utf8").split("\n").flatMap((l) => {
|
|
86
|
-
try {
|
|
87
|
-
const e = JSON.parse(l);
|
|
88
|
-
return typeof e?.ts === "number" && e.ts >= since ? [e] : [];
|
|
89
|
-
} catch {
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
} catch {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const readReloads = (root, since = 0) => readLines(reloadLog(root), since);
|
|
98
|
-
/** The page's records from `since` (epoch ms): malformed lines skipped. */
|
|
99
|
-
const readPage = (root, since = 0) => readLines(pageLog(root), since);
|
|
100
|
-
/** What one request may carry. */
|
|
101
|
-
const PAGE_BODY_MAX = 524288;
|
|
102
|
-
const PAGE_KINDS = [
|
|
103
|
-
"load",
|
|
104
|
-
"commit",
|
|
105
|
-
"visible",
|
|
106
|
-
"frame",
|
|
107
|
-
"move",
|
|
108
|
-
"quiet",
|
|
109
|
-
"settled",
|
|
110
|
-
"cut",
|
|
111
|
-
"gesture",
|
|
112
|
-
"error",
|
|
113
|
-
"dropped"
|
|
114
|
-
];
|
|
115
|
-
const LOAD_CAUSES = [
|
|
116
|
-
"boot",
|
|
117
|
-
"switch",
|
|
118
|
-
"disk-reload"
|
|
119
|
-
];
|
|
120
|
-
const CUT_REASONS = [
|
|
121
|
-
"switch",
|
|
122
|
-
"reload",
|
|
123
|
-
"hidden",
|
|
124
|
-
"timeout",
|
|
125
|
-
"superseded",
|
|
126
|
-
"error",
|
|
127
|
-
"edited",
|
|
128
|
-
"unsaved"
|
|
129
|
-
];
|
|
130
|
-
const OUTCOMES = [
|
|
131
|
-
"settled",
|
|
132
|
-
"ready",
|
|
133
|
-
"missing",
|
|
134
|
-
"error",
|
|
135
|
-
"never-ready",
|
|
136
|
-
"cut"
|
|
137
|
-
];
|
|
138
|
-
const GESTURES = [
|
|
139
|
-
"pan",
|
|
140
|
-
"zoom",
|
|
141
|
-
"layout"
|
|
142
|
-
];
|
|
143
|
-
const SOURCES = [
|
|
144
|
-
"shell",
|
|
145
|
-
"frame",
|
|
146
|
-
"stage"
|
|
147
|
-
];
|
|
148
|
-
/** why records were dropped, when it is not the queue's bound or a failed send: errors past a load's 50 */
|
|
149
|
-
const DROP_REASONS = ["errors"];
|
|
150
|
-
const ID = /^[0-9a-f]{12}$/;
|
|
151
|
-
const WS = /^[0-9a-f]{16}$/;
|
|
152
|
-
const CAUSE = /^[a-z][a-z0-9:+-]{0,63}$/;
|
|
153
|
-
const BOARD = /^(?:~unplaced|[a-z0-9][a-z0-9-]{0,63})$/;
|
|
154
|
-
const str = (v, n = 200) => typeof v === "string" && v ? v.slice(0, n) : void 0;
|
|
155
|
-
const id = (v) => typeof v === "string" && ID.test(v) ? v : void 0;
|
|
156
|
-
const count = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 && v < 1e7 ? v : void 0;
|
|
157
|
-
const ms = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 1e9 ? Math.round(v) : void 0;
|
|
158
|
-
const tenth = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 1e7 ? Math.round(v * 10) / 10 : void 0;
|
|
159
|
-
const delta = (v) => typeof v === "number" && Number.isFinite(v) && Math.abs(v) < 1e7 ? Math.round(v) : void 0;
|
|
160
|
-
const flag = (v) => v === true ? true : void 0;
|
|
161
|
-
const oneOf = (v, set) => typeof v === "string" && set.includes(v) ? v : void 0;
|
|
162
|
-
const obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
163
|
-
const prune = (o) => Object.fromEntries(Object.entries(o).filter(([, x]) => x !== void 0));
|
|
164
|
-
const cause = (v) => typeof v === "string" && CAUSE.test(v) ? v : void 0;
|
|
165
|
-
/** Each kind's fields, rebuilt from what the page sent - anything else is left out; null = the record is dropped. */
|
|
166
|
-
const BODY = {
|
|
167
|
-
load: (r) => {
|
|
168
|
-
const board = typeof r.board === "string" && BOARD.test(r.board) ? r.board : void 0, c = oneOf(r.cause, LOAD_CAUSES), request = id(r.request);
|
|
169
|
-
return board && c && request ? {
|
|
170
|
-
board,
|
|
171
|
-
cause: c,
|
|
172
|
-
request,
|
|
173
|
-
sinceNav: ms(r.sinceNav)
|
|
174
|
-
} : null;
|
|
175
|
-
},
|
|
176
|
-
commit: (r) => {
|
|
177
|
-
const k = obj(r.byKind);
|
|
178
|
-
return {
|
|
179
|
-
request: id(r.request),
|
|
180
|
-
ms: ms(r.ms),
|
|
181
|
-
frames: count(r.frames),
|
|
182
|
-
byKind: prune({
|
|
183
|
-
hifi: count(k.hifi),
|
|
184
|
-
content: count(k.content),
|
|
185
|
-
html: count(k.html),
|
|
186
|
-
image: count(k.image)
|
|
187
|
-
}),
|
|
188
|
-
measuring: count(r.measuring),
|
|
189
|
-
savedHeights: count(r.savedHeights),
|
|
190
|
-
late: flag(r.late)
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
visible: (r) => ({
|
|
194
|
-
nodes: count(r.nodes),
|
|
195
|
-
ms: ms(r.ms),
|
|
196
|
-
assumed: flag(r.assumed)
|
|
197
|
-
}),
|
|
198
|
-
frame: (r) => {
|
|
199
|
-
const node = str(r.node), outcome = oneOf(r.outcome, OUTCOMES);
|
|
200
|
-
return node && outcome ? {
|
|
201
|
-
node,
|
|
202
|
-
frame: str(r.frame),
|
|
203
|
-
gen: str(r.gen, 32),
|
|
204
|
-
boot: str(r.boot, 32),
|
|
205
|
-
admitted: ms(r.admitted),
|
|
206
|
-
ready: ms(r.ready),
|
|
207
|
-
firstMeasure: ms(r.firstMeasure),
|
|
208
|
-
settled: ms(r.settled),
|
|
209
|
-
outcome,
|
|
210
|
-
kept: flag(r.kept)
|
|
211
|
-
} : null;
|
|
212
|
-
},
|
|
213
|
-
move: (r) => {
|
|
214
|
-
const node = str(r.node), c = cause(r.cause);
|
|
215
|
-
return node && c ? {
|
|
216
|
-
node,
|
|
217
|
-
dx: delta(r.dx),
|
|
218
|
-
dy: delta(r.dy),
|
|
219
|
-
dw: delta(r.dw),
|
|
220
|
-
dh: delta(r.dh),
|
|
221
|
-
cause: c,
|
|
222
|
-
late: flag(r.late)
|
|
223
|
-
} : null;
|
|
224
|
-
},
|
|
225
|
-
quiet: (r) => ms(r.ms) === void 0 ? null : { ms: ms(r.ms) },
|
|
226
|
-
settled: (r) => {
|
|
227
|
-
if (ms(r.ms) === void 0) return null;
|
|
228
|
-
const w = obj(r.weight);
|
|
229
|
-
return {
|
|
230
|
-
ms: ms(r.ms),
|
|
231
|
-
moves: count(r.moves),
|
|
232
|
-
distance: count(r.distance),
|
|
233
|
-
lastMove: ms(r.lastMove),
|
|
234
|
-
causes: Object.fromEntries(Object.entries(obj(r.causes)).slice(0, 32).flatMap(([k, n]) => cause(k) && count(n) !== void 0 ? [[k, n]] : [])),
|
|
235
|
-
visibleReadyMs: ms(r.visibleReadyMs),
|
|
236
|
-
allReadyMs: ms(r.allReadyMs),
|
|
237
|
-
missing: count(r.missing),
|
|
238
|
-
neverReady: count(r.neverReady),
|
|
239
|
-
errors: count(r.errors),
|
|
240
|
-
weight: prune({
|
|
241
|
-
domNodes: count(w.domNodes),
|
|
242
|
-
iframes: count(w.iframes),
|
|
243
|
-
awake: count(w.awake),
|
|
244
|
-
asleep: count(w.asleep),
|
|
245
|
-
heapMB: tenth(w.heapMB)
|
|
246
|
-
})
|
|
247
|
-
};
|
|
248
|
-
},
|
|
249
|
-
cut: (r) => {
|
|
250
|
-
const reason = oneOf(r.reason, CUT_REASONS);
|
|
251
|
-
return reason ? {
|
|
252
|
-
reason,
|
|
253
|
-
request: id(r.request),
|
|
254
|
-
ms: ms(r.ms),
|
|
255
|
-
lastMove: ms(r.lastMove),
|
|
256
|
-
frames: count(r.frames),
|
|
257
|
-
ready: count(r.ready)
|
|
258
|
-
} : null;
|
|
259
|
-
},
|
|
260
|
-
gesture: (r) => {
|
|
261
|
-
const type = oneOf(r.type, GESTURES);
|
|
262
|
-
return type ? {
|
|
263
|
-
type,
|
|
264
|
-
ms: ms(r.ms),
|
|
265
|
-
frames: count(r.frames),
|
|
266
|
-
p50: tenth(r.p50),
|
|
267
|
-
p95: tenth(r.p95),
|
|
268
|
-
max: tenth(r.max),
|
|
269
|
-
over17ms: count(r.over17ms),
|
|
270
|
-
over33ms: count(r.over33ms),
|
|
271
|
-
longFrames: count(r.longFrames)
|
|
272
|
-
} : null;
|
|
273
|
-
},
|
|
274
|
-
error: (r) => {
|
|
275
|
-
const source = oneOf(r.source, SOURCES), message = str(r.message);
|
|
276
|
-
const stack = Array.isArray(r.stack) ? r.stack.slice(0, 3).map((l) => str(l)).filter((l) => !!l) : [];
|
|
277
|
-
return source && message ? {
|
|
278
|
-
source,
|
|
279
|
-
frame: str(r.frame),
|
|
280
|
-
component: str(r.component),
|
|
281
|
-
message,
|
|
282
|
-
stack: stack.length ? stack : void 0,
|
|
283
|
-
late: flag(r.late)
|
|
284
|
-
} : null;
|
|
285
|
-
},
|
|
286
|
-
dropped: (r) => count(r.n) === void 0 ? null : {
|
|
287
|
-
n: count(r.n),
|
|
288
|
-
reason: oneOf(r.reason, DROP_REASONS)
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
/** A page record rebuilt from the envelope and its kind's allowlist, or null. Strings are cut to 200 characters. */
|
|
292
|
-
function cleanPageRecord(raw, now = Date.now()) {
|
|
293
|
-
const r = obj(raw);
|
|
294
|
-
if (r.v !== 1) return null;
|
|
295
|
-
const kind = oneOf(r.kind, PAGE_KINDS);
|
|
296
|
-
const ws = typeof r.ws === "string" && WS.test(r.ws) ? r.ws : void 0;
|
|
297
|
-
const page = id(r.page), load = r.load === "-" ? "-" : id(r.load), seq = count(r.seq);
|
|
298
|
-
if (!kind || !ws || !page || !load || seq === void 0) return null;
|
|
299
|
-
const body = BODY[kind](r);
|
|
300
|
-
if (!body) return null;
|
|
301
|
-
return {
|
|
302
|
-
v: 1,
|
|
303
|
-
ws,
|
|
304
|
-
page,
|
|
305
|
-
load,
|
|
306
|
-
seq,
|
|
307
|
-
ts: typeof r.ts === "number" && Number.isFinite(r.ts) && Math.abs(r.ts - now) < 864e5 ? Math.round(r.ts) : now,
|
|
308
|
-
kind,
|
|
309
|
-
...prune(body)
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
/** The page's records into design/.local/perf/page.jsonl - best effort; how many were kept. */
|
|
313
|
-
function logPage(root, raws) {
|
|
314
|
-
const now = Date.now();
|
|
315
|
-
const lines = raws.slice(0, 5e3).flatMap((x) => {
|
|
316
|
-
const c = cleanPageRecord(x, now);
|
|
317
|
-
return c ? [JSON.stringify(c)] : [];
|
|
318
|
-
});
|
|
319
|
-
if (!lines.length) return 0;
|
|
320
|
-
try {
|
|
321
|
-
appendLog(root, pageLog(root), lines.join("\n") + "\n");
|
|
322
|
-
} catch {
|
|
323
|
-
return 0;
|
|
324
|
-
}
|
|
325
|
-
return lines.length;
|
|
326
|
-
}
|
|
327
|
-
/** At start (spec 28 A1.7): design/.local/perf/ is the owner's alone - the directory 700 and every file in it 600,
|
|
328
|
-
* those earlier versions created without modes included - and the logs whose lines age out lose the ones older than
|
|
329
|
-
* 14 days and, still past their cap (2 MB; page.jsonl 8 MB), their oldest half. Synchronous, before the server
|
|
330
|
-
* listens: no append of this process interleaves. Best effort; a link is never followed. */
|
|
331
|
-
function tidyPerfDir(root, now = Date.now()) {
|
|
332
|
-
try {
|
|
333
|
-
if (unsafe(root)) return;
|
|
334
|
-
const dir = perfDir(root);
|
|
335
|
-
let st;
|
|
336
|
-
try {
|
|
337
|
-
st = lstatSync(dir);
|
|
338
|
-
} catch {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
if (!st.isDirectory()) return;
|
|
342
|
-
chmodSync(dir, 448);
|
|
343
|
-
for (const name of readdirSync(dir)) {
|
|
344
|
-
const f = join(dir, name);
|
|
345
|
-
try {
|
|
346
|
-
if (!lstatSync(f).isFile()) continue;
|
|
347
|
-
chmodSync(f, 384);
|
|
348
|
-
if (!AGED.includes(name)) continue;
|
|
349
|
-
const text = readFileSync(f, "utf8");
|
|
350
|
-
let lines = text.split("\n").filter((l) => {
|
|
351
|
-
try {
|
|
352
|
-
const e = JSON.parse(l);
|
|
353
|
-
return typeof e?.ts === "number" && e.ts >= now - KEEP_MS;
|
|
354
|
-
} catch {
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
if (Buffer.byteLength(lines.join("\n")) > maxOf(name)) lines = lines.slice(Math.floor(lines.length / 2));
|
|
359
|
-
const next = lines.length ? lines.join("\n") + "\n" : "";
|
|
360
|
-
if (next === text) continue;
|
|
361
|
-
const tmp = `${f}.${process.pid}.tmp`;
|
|
362
|
-
writeFileSync(tmp, next, { mode: 384 });
|
|
363
|
-
renameSync(tmp, f);
|
|
364
|
-
} catch {}
|
|
365
|
-
}
|
|
366
|
-
} catch {}
|
|
367
|
-
}
|
|
368
|
-
//#endregion
|
|
369
|
-
export { readPage as a, perf_exports as i, logPage as n, readReloads as o, logReload as r, tidyPerfDir as s, PAGE_BODY_MAX as t };
|