@marver-design/marver 0.24.0 → 0.25.1
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 +56 -0
- package/README.md +1 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-DGZnYviN.mjs +135 -0
- package/dist/{bake-ZhXq-X9f.mjs → bake-BpxMZfij.mjs} +45 -6
- package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
- package/dist/boards-CGg6piKF.mjs +342 -0
- package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
- package/dist/{build-ckcinlWH.mjs → build-DKaGhoVN.mjs} +63 -37
- package/dist/cli.mjs +31 -17
- package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
- package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
- package/dist/{comments-Dx1hCVOT.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-BncTXjLB.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-CQv73-jM.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-gv4NS6Fk.mjs → dev-Diqx1Rt8.mjs} +23 -11
- package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
- package/dist/imports-WBSnnHLb.mjs +143 -0
- package/dist/{init--3Moc4J7.mjs → init-DO4DhUt_.mjs} +28 -6
- package/dist/link-C-qUIuKU.mjs +160 -0
- package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
- package/dist/marks-DFuintmJ.mjs +50 -0
- package/dist/marks-koRsbHfe.mjs +397 -0
- package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
- package/dist/perf-CCisg-ny.mjs +49 -0
- package/dist/perf-QJIWtTw1.mjs +68 -0
- package/dist/{plugin-Sa08E7wO.mjs → plugin-dTF5reck.mjs} +425 -207
- package/dist/{poster-B2QPvKOq.mjs → poster-D-zjYpgk.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-BJR3huhu.mjs → publish-bakes-C_9VZ-Mq.mjs} +9 -9
- package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
- package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
- package/dist/{shot-Cw96h5Kk.mjs → shot-CUlmkqFX.mjs} +19 -11
- package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
- package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
- package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
- package/dist/{work-CBUfsOOT.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +62 -21
- package/docs/live-jam.md +10 -5
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +2 -1
- package/src/client/frame-host/inspect.js +195 -84
- package/src/client/frame-host/main.tsx +7 -2
- package/src/client/frame-host/registry.ts +5 -5
- package/src/client/shell/App.tsx +66 -22
- package/src/client/shell/BoardList.tsx +54 -11
- package/src/client/shell/Comments.tsx +79 -34
- package/src/client/shell/ContextMenu.tsx +5 -2
- package/src/client/shell/LockedApp.tsx +45 -12
- package/src/client/shell/Play.tsx +35 -34
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +1 -1
- package/src/client/shell/canvas/FrameNode.tsx +10 -5
- package/src/client/shell/canvas/sleep.ts +23 -4
- package/src/client/shell/canvas/updates.ts +55 -0
- package/src/client/shell/comments-store.ts +48 -19
- package/src/client/shell/goto.ts +11 -14
- package/src/client/shell/hash.ts +12 -5
- package/src/client/shell/icons.tsx +1 -2
- package/src/client/shell/legacy-links.ts +67 -0
- package/src/client/shell/marks-ui.tsx +17 -19
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +312 -92
- package/src/client/shell/styles.css +10 -8
- package/src/client/stage/main.tsx +19 -2
- package/src/shared/anchor.ts +57 -0
- package/src/shared/board-tree.ts +27 -10
- package/src/shared/events.ts +19 -10
- package/src/shared/marks.ts +17 -12
- package/templates/AGENTS-embedded.md +34 -15
- package/templates/AGENTS-studio.md +34 -15
- package/templates/instructions/boards.md +9 -5
- package/templates/instructions/iterate.md +20 -10
- package/templates/instructions/jam.md +13 -4
- package/templates/instructions/publish.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -2
- package/dist/link-vXjxMHTG.mjs +0 -132
- package/dist/manifest-cyG3kbhk.mjs +0 -528
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { a as checkRealDirs, h as hash, i as checkBoardsDir, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
|
|
3
|
+
import { l as framesOn } from "./board-tree-DRioF94d.mjs";
|
|
4
|
+
import { a as noteFileFor } from "./manifest-DnAte_fB.mjs";
|
|
5
|
+
import { t as imports } from "./imports-WBSnnHLb.mjs";
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
8
|
+
import { randomBytes } from "node:crypto";
|
|
9
|
+
//#region src/server/deps.ts
|
|
10
|
+
/**
|
|
11
|
+
* What each frame reads (spec 26): its own file, its `_layout` chain, `design/providers` for a TSX
|
|
12
|
+
* frame, and everything those import - followed statically (imports.ts). The marks use it twice:
|
|
13
|
+
* a shared file that changes lights every frame that reads it, and a boot compares each frame's
|
|
14
|
+
* fingerprint with the last run's, so what changed while `marver dev` was off is seen too.
|
|
15
|
+
*/
|
|
16
|
+
/** frame id -> the repository paths it reads, its own file first. */
|
|
17
|
+
function frameDeps(root, frames) {
|
|
18
|
+
const im = imports(root);
|
|
19
|
+
const providers = ["tsx", "jsx"].map((x) => `design/providers.${x}`).filter(im.isFile);
|
|
20
|
+
const out = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const f of frames) {
|
|
22
|
+
const queue = [f.file];
|
|
23
|
+
if (f.kind === "tsx") {
|
|
24
|
+
const base = f.file.startsWith("design/components/") ? "design/components" : "design/scenes";
|
|
25
|
+
for (let dir = dirname(f.file); dir.length >= base.length; dir = dirname(dir)) {
|
|
26
|
+
for (const x of ["tsx", "jsx"]) if (im.isFile(`${dir}/_layout.${x}`)) queue.push(`${dir}/_layout.${x}`);
|
|
27
|
+
if (dir === base) break;
|
|
28
|
+
}
|
|
29
|
+
queue.push(...providers);
|
|
30
|
+
}
|
|
31
|
+
const reads = /* @__PURE__ */ new Set();
|
|
32
|
+
while (queue.length) {
|
|
33
|
+
const p = queue.shift();
|
|
34
|
+
if (reads.has(p)) continue;
|
|
35
|
+
reads.add(p);
|
|
36
|
+
queue.push(...im.of(p).resolved);
|
|
37
|
+
}
|
|
38
|
+
out.set(f.id, [...reads]);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
const stat = (root, rel) => {
|
|
43
|
+
try {
|
|
44
|
+
const s = statSync(join(root, rel));
|
|
45
|
+
return `${s.size}:${s.mtimeMs}`;
|
|
46
|
+
} catch {
|
|
47
|
+
return "-";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function observed(root, frames, deps = frameDeps(root, frames)) {
|
|
51
|
+
const out = {
|
|
52
|
+
files: {},
|
|
53
|
+
frames: {}
|
|
54
|
+
};
|
|
55
|
+
for (const f of frames) {
|
|
56
|
+
const reads = deps.get(f.id) ?? [f.file];
|
|
57
|
+
for (const p of reads) out.files[p] ??= stat(root, p);
|
|
58
|
+
out.frames[f.id] = {
|
|
59
|
+
reads: hash([...reads].sort().join("\n")).slice(0, 16),
|
|
60
|
+
note: stat(root, noteFileFor(f.file))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** What moved between two looks, per frame: `doc` - added (a new id, a rename too), what it reads
|
|
66
|
+
* changed (a file edited, added, removed or renamed), or app code it imports at `boot` (nothing
|
|
67
|
+
* applied it); `note` - its sticky note, or app code while dev runs (Fast Refresh applies it in place).
|
|
68
|
+
* `only`: compare these files alone (a hot update's own file). */
|
|
69
|
+
function compare(was, now, deps, ids, boot, only) {
|
|
70
|
+
const doc = [], note = [];
|
|
71
|
+
for (const id of ids) {
|
|
72
|
+
const a = was.frames[id], b = now.frames[id];
|
|
73
|
+
if (!b) continue;
|
|
74
|
+
if (!a || !only && a.reads !== b.reads) {
|
|
75
|
+
doc.push(id);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const moved = (deps.get(id) ?? []).filter((p) => (!only || only.has(p)) && was.files[p] !== now.files[p]);
|
|
79
|
+
if (moved.some((p) => boot || !isApp(p))) doc.push(id);
|
|
80
|
+
else if (moved.length || !only && a.note !== b.note) note.push(id);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
doc,
|
|
84
|
+
note
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** App code: outside design/, and code (a component, a helper) - not content like a spec's markdown. */
|
|
88
|
+
const isApp = (rel) => !rel.startsWith("design/") && /\.(tsx?|jsx?|mjs|cjs)$/.test(rel);
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/server/marks.ts
|
|
91
|
+
/**
|
|
92
|
+
* Sidebar marks, the dev server's half (spec 25, made exact by spec 26): which frames changed, and
|
|
93
|
+
* which change you have seen. Local only - `design/.local/` is never committed and never published.
|
|
94
|
+
*
|
|
95
|
+
* Marks count REVISIONS, never clock times. One counter; every recorded change takes the next
|
|
96
|
+
* number. Per frame, `changed` is the last revision that touched it in any way and `doc` the last
|
|
97
|
+
* one that needs a new document to be seen (its file, or anything it reads); a sticky note or an
|
|
98
|
+
* agent's `work done` raises `changed` alone. `seen` is the revision you last acknowledged: a frame
|
|
99
|
+
* is new when changed > seen. An `epoch`, made with the state and kept across restarts, changes on
|
|
100
|
+
* a reset, so an acknowledgement from before it is refused.
|
|
101
|
+
*
|
|
102
|
+
* The clock starts when `marver dev` starts (initMarks): everything on the canvas then counts as
|
|
103
|
+
* seen, and every frame's dependency fingerprint is kept (deps.json), so a later boot sees what
|
|
104
|
+
* changed while dev was off. The dev server is the only writer; the state lives in memory and is
|
|
105
|
+
* written through. `projectMarks` is the read-only view the CLI prints.
|
|
106
|
+
*
|
|
107
|
+
* changes.json { version: 2, epoch, rev, frames: { id: [changed, doc] } }
|
|
108
|
+
* seen.json { version: 2, epoch, frames: { id: rev } }
|
|
109
|
+
* deps.json { version: 3, files: { path: "size:mtime" }, frames: { id: { reads, note } } }
|
|
110
|
+
*/
|
|
111
|
+
var marks_exports = /* @__PURE__ */ __exportAll({
|
|
112
|
+
docRev: () => docRev,
|
|
113
|
+
docRevs: () => docRevs,
|
|
114
|
+
initMarks: () => initMarks,
|
|
115
|
+
markSeen: () => markSeen,
|
|
116
|
+
observe: () => observe,
|
|
117
|
+
projectMarks: () => projectMarks,
|
|
118
|
+
readMarks: () => readMarks,
|
|
119
|
+
recordChanged: () => recordChanged
|
|
120
|
+
});
|
|
121
|
+
const dir = (root) => join(root, "design", ".local");
|
|
122
|
+
/** Writes stay inside the project: a symlinked design/ or .local is refused (as boards.ts refuses). */
|
|
123
|
+
const write = (root, name, data) => {
|
|
124
|
+
if (checkRealDirs(root, [[join(root, "design"), "design"], [dir(root), "design/.local"]])) return;
|
|
125
|
+
mkdirSync(dir(root), { recursive: true });
|
|
126
|
+
const file = join(dir(root), name), tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
127
|
+
writeFileSync(tmp, JSON.stringify(data) + "\n");
|
|
128
|
+
renameSync(tmp, file);
|
|
129
|
+
};
|
|
130
|
+
/** A file's JSON: `undefined` when it does not exist, `null` when it is not valid, and a throw when
|
|
131
|
+
* the disk refuses the read - which is no reason to reset anything. */
|
|
132
|
+
const readJson = (root, name) => {
|
|
133
|
+
let text;
|
|
134
|
+
try {
|
|
135
|
+
text = readFileSync(join(dir(root), name), "utf8");
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (e.code === "ENOENT") return void 0;
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
return JSON.parse(text);
|
|
142
|
+
} catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const rev = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
|
|
147
|
+
const obj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
148
|
+
const newEpoch = () => randomBytes(6).toString("hex");
|
|
149
|
+
const fresh = () => ({
|
|
150
|
+
epoch: newEpoch(),
|
|
151
|
+
rev: 0,
|
|
152
|
+
changed: {},
|
|
153
|
+
doc: {},
|
|
154
|
+
seen: {},
|
|
155
|
+
obs: null
|
|
156
|
+
});
|
|
157
|
+
const states = /* @__PURE__ */ new Map();
|
|
158
|
+
/** Loads the state from disk: the v2 files; a 0.24 state converted (what was new stays new); or a
|
|
159
|
+
* fresh one. `null` = invalid (a reset is due). Never writes. */
|
|
160
|
+
function load(root, frames) {
|
|
161
|
+
const c = readJson(root, "changes.json"), s = readJson(root, "seen.json"), d = readJson(root, "deps.json");
|
|
162
|
+
const obs = obj(d) && d.version === 3 && obj(d.files) && obj(d.frames) && Object.values(d.files).every((v) => typeof v === "string") && Object.values(d.frames).every((v) => obj(v) && typeof v.reads === "string" && typeof v.note === "string") ? d : null;
|
|
163
|
+
if (c === void 0 && s === void 0) return fresh();
|
|
164
|
+
if (obj(s) && s.version === 1) return convert(root, frames, c, s);
|
|
165
|
+
if (!obj(c) || !obj(s) || c.version !== 2 || s.version !== 2 || typeof c.epoch !== "string" || c.epoch !== s.epoch || !rev(c.rev) || !obj(c.frames) || !obj(s.frames)) return null;
|
|
166
|
+
const st = {
|
|
167
|
+
epoch: c.epoch,
|
|
168
|
+
rev: c.rev,
|
|
169
|
+
changed: {},
|
|
170
|
+
doc: {},
|
|
171
|
+
seen: {},
|
|
172
|
+
obs
|
|
173
|
+
};
|
|
174
|
+
for (const [id, v] of Object.entries(c.frames)) {
|
|
175
|
+
if (!Array.isArray(v) || !rev(v[0]) || !rev(v[1]) || v[0] > c.rev || v[1] > v[0]) return null;
|
|
176
|
+
st.changed[id] = v[0];
|
|
177
|
+
st.doc[id] = v[1];
|
|
178
|
+
}
|
|
179
|
+
for (const [id, v] of Object.entries(s.frames)) {
|
|
180
|
+
if (!rev(v) || v > c.rev) return null;
|
|
181
|
+
st.seen[id] = v;
|
|
182
|
+
}
|
|
183
|
+
return st;
|
|
184
|
+
}
|
|
185
|
+
/** 0.24 kept clock stamps (spec 25): a frame new under that rule becomes `changed 1, doc 0` - new,
|
|
186
|
+
* and acknowledged by any look; everything else starts seen. */
|
|
187
|
+
function convert(root, frames, c, s) {
|
|
188
|
+
const st = fresh();
|
|
189
|
+
const num = (o, id) => obj(o) && typeof o[id] === "number" && Number.isFinite(o[id]) ? o[id] : 0;
|
|
190
|
+
const mtime = (rel) => {
|
|
191
|
+
try {
|
|
192
|
+
return statSync(join(root, rel)).mtimeMs;
|
|
193
|
+
} catch {
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const baseline = typeof s.baseline === "number" && Number.isFinite(s.baseline) ? s.baseline : Infinity;
|
|
198
|
+
const done = obj(c) ? c.frames : void 0;
|
|
199
|
+
const strs = (v) => Array.isArray(v) ? new Set(v.filter((x) => typeof x === "string")) : null;
|
|
200
|
+
const ids = strs(s.ids), notes = strs(s.notes);
|
|
201
|
+
for (const f of frames) {
|
|
202
|
+
const changed = Math.max(mtime(f.file), mtime(noteFileFor(f.file)), num(done, f.id));
|
|
203
|
+
const added = !!ids && !ids.has(f.id);
|
|
204
|
+
const noteGone = !!notes?.has(f.id) && !mtime(noteFileFor(f.file));
|
|
205
|
+
if (added || noteGone || changed > Math.max(num(s.frames, f.id), baseline)) {
|
|
206
|
+
st.changed[f.id] = 1;
|
|
207
|
+
st.doc[f.id] = 0;
|
|
208
|
+
st.rev = 1;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return st;
|
|
212
|
+
}
|
|
213
|
+
let warned = false;
|
|
214
|
+
function persist(root, st, deps = false) {
|
|
215
|
+
try {
|
|
216
|
+
persistNow(root, st, deps);
|
|
217
|
+
} catch (e) {
|
|
218
|
+
if (!warned) console.warn(`[marver] sidebar marks could not be saved to design/.local - ${e.message}`);
|
|
219
|
+
warned = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function persistNow(root, st, deps) {
|
|
223
|
+
write(root, "changes.json", {
|
|
224
|
+
version: 2,
|
|
225
|
+
epoch: st.epoch,
|
|
226
|
+
rev: st.rev,
|
|
227
|
+
frames: Object.fromEntries(Object.keys(st.changed).map((id) => [id, [st.changed[id], st.doc[id] ?? 0]]))
|
|
228
|
+
});
|
|
229
|
+
write(root, "seen.json", {
|
|
230
|
+
version: 2,
|
|
231
|
+
epoch: st.epoch,
|
|
232
|
+
frames: st.seen
|
|
233
|
+
});
|
|
234
|
+
if (deps && st.obs) write(root, "deps.json", {
|
|
235
|
+
version: 3,
|
|
236
|
+
files: st.obs.files,
|
|
237
|
+
frames: st.obs.frames
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/** The live state, loaded on first use. A state the disk refuses to read turns marks off for this
|
|
241
|
+
* session (nothing is reset); an invalid one starts over, said once. */
|
|
242
|
+
function state(root, frames) {
|
|
243
|
+
const have = states.get(root);
|
|
244
|
+
if (have) return have === "off" ? null : have;
|
|
245
|
+
let st;
|
|
246
|
+
try {
|
|
247
|
+
st = load(root, frames);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
console.warn(`[marver] marks are off for this session - design/.local could not be read (${e.message})`);
|
|
250
|
+
states.set(root, "off");
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
if (!st) {
|
|
254
|
+
console.warn("[marver] the sidebar marks in design/.local were unreadable - starting over: everything on the canvas counts as seen");
|
|
255
|
+
st = fresh();
|
|
256
|
+
}
|
|
257
|
+
states.set(root, st);
|
|
258
|
+
observe(root, frames, { boot: true });
|
|
259
|
+
return st;
|
|
260
|
+
}
|
|
261
|
+
/** Records a change to these frames: one new revision for the batch. `doc` = it needs a new document
|
|
262
|
+
* to be seen (an edit to the frame or to what it reads); a note or `work done` does not. */
|
|
263
|
+
function recordChanged(root, frames, ids, opts) {
|
|
264
|
+
const st = state(root, frames);
|
|
265
|
+
const known = new Set(frames.map((f) => f.id));
|
|
266
|
+
const hit = [...new Set(ids)].filter((id) => known.has(id));
|
|
267
|
+
if (!st || !hit.length) return null;
|
|
268
|
+
st.rev++;
|
|
269
|
+
for (const id of hit) {
|
|
270
|
+
st.changed[id] = st.rev;
|
|
271
|
+
if (opts.doc) st.doc[id] = st.rev;
|
|
272
|
+
}
|
|
273
|
+
persist(root, st);
|
|
274
|
+
return st.rev;
|
|
275
|
+
}
|
|
276
|
+
/** Looks at the frames as they are on disk now and records what moved since the last look (deps.ts
|
|
277
|
+
* `compare`). The first look of a canvas only remembers. `file`: look at that file alone - a hot
|
|
278
|
+
* update records its own edit, never another one Vite has not processed yet; the next full look
|
|
279
|
+
* sees the rest. Returns the frames it recorded. */
|
|
280
|
+
function observe(root, frames, opts = {}) {
|
|
281
|
+
const st = states.get(root);
|
|
282
|
+
const out = {
|
|
283
|
+
doc: [],
|
|
284
|
+
note: []
|
|
285
|
+
};
|
|
286
|
+
if (!st || st === "off") return out;
|
|
287
|
+
const deps = frameDeps(root, frames);
|
|
288
|
+
const known = new Set(frames.map((f) => f.id));
|
|
289
|
+
const was = st.obs;
|
|
290
|
+
let pruned = false;
|
|
291
|
+
if (opts.file) {
|
|
292
|
+
if (!was) return out;
|
|
293
|
+
const rel = relative(root, opts.file).split(sep).join("/");
|
|
294
|
+
const readers = frames.filter((f) => deps.get(f.id)?.includes(rel));
|
|
295
|
+
const now = observed(root, readers, deps);
|
|
296
|
+
Object.assign(out, compare(was, now, deps, readers.map((f) => f.id), !!opts.boot, /* @__PURE__ */ new Set([rel])));
|
|
297
|
+
was.files[rel] = stat(root, rel);
|
|
298
|
+
for (const f of readers) {
|
|
299
|
+
was.frames[f.id] = {
|
|
300
|
+
reads: now.frames[f.id].reads,
|
|
301
|
+
note: was.frames[f.id]?.note ?? now.frames[f.id].note
|
|
302
|
+
};
|
|
303
|
+
for (const p of deps.get(f.id) ?? []) if (was.files[p] === void 0) was.files[p] = now.files[p];
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
const now = observed(root, frames, deps);
|
|
307
|
+
if (was) Object.assign(out, compare(was, now, deps, frames.map((f) => f.id), !!opts.boot));
|
|
308
|
+
pruned = !was || Object.keys(was.frames).some((id) => !known.has(id));
|
|
309
|
+
st.obs = now;
|
|
310
|
+
}
|
|
311
|
+
for (const m of [
|
|
312
|
+
st.changed,
|
|
313
|
+
st.doc,
|
|
314
|
+
st.seen
|
|
315
|
+
]) for (const id of Object.keys(m)) if (!known.has(id)) {
|
|
316
|
+
delete m[id];
|
|
317
|
+
pruned = true;
|
|
318
|
+
}
|
|
319
|
+
if (out.doc.length || out.note.length) {
|
|
320
|
+
st.rev++;
|
|
321
|
+
for (const id of out.doc) st.changed[id] = st.doc[id] = st.rev;
|
|
322
|
+
for (const id of out.note) st.changed[id] = st.rev;
|
|
323
|
+
}
|
|
324
|
+
if (out.doc.length || out.note.length || pruned || opts.file) persist(root, st, true);
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
/** The clock starts here, when `marver dev` starts - before any page asks. */
|
|
328
|
+
function initMarks(root, frames) {
|
|
329
|
+
states.delete(root);
|
|
330
|
+
try {
|
|
331
|
+
state(root, frames);
|
|
332
|
+
} catch (e) {
|
|
333
|
+
console.warn(`[marver] sidebar marks could not start: ${e.message}`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** You saw these frames at these revisions. Refused (false) from another epoch; never lowers. */
|
|
337
|
+
function markSeen(root, frames, epoch, seen) {
|
|
338
|
+
const st = state(root, frames);
|
|
339
|
+
if (!st || epoch !== st.epoch) return false;
|
|
340
|
+
const known = new Set(frames.map((f) => f.id));
|
|
341
|
+
for (const [id, v] of Object.entries(seen)) if (known.has(id) && rev(v)) st.seen[id] = Math.max(st.seen[id] ?? 0, Math.min(v, st.rev));
|
|
342
|
+
persist(root, st);
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
/** A frame's `doc` revision: the stamp a document of it is served with. */
|
|
346
|
+
function docRev(root, frames, id) {
|
|
347
|
+
const st = state(root, frames);
|
|
348
|
+
return st ? `${st.epoch}:${st.doc[id] ?? 0}` : "";
|
|
349
|
+
}
|
|
350
|
+
function docRevs(root, frames) {
|
|
351
|
+
const st = state(root, frames);
|
|
352
|
+
return st ? {
|
|
353
|
+
epoch: st.epoch,
|
|
354
|
+
doc: { ...st.doc }
|
|
355
|
+
} : null;
|
|
356
|
+
}
|
|
357
|
+
const snapshot = (root, manifest, st) => {
|
|
358
|
+
const all = manifest.frames.map((f) => f.id);
|
|
359
|
+
new Set(all);
|
|
360
|
+
const pick = (m) => Object.fromEntries(all.filter((id) => m[id]).map((id) => [id, m[id]]));
|
|
361
|
+
const boards = {};
|
|
362
|
+
const boardsDir = join(root, "design", "boards");
|
|
363
|
+
if (existsSync(boardsDir) && !checkBoardsDir(root, boardsDir)) {
|
|
364
|
+
for (const b of listBoardFiles(boardsDir).boards) if (b.json) boards[b.name] = framesOn(b.json, all);
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
epoch: st.epoch,
|
|
368
|
+
changed: pick(st.changed),
|
|
369
|
+
doc: pick(st.doc),
|
|
370
|
+
seen: pick(st.seen),
|
|
371
|
+
boards
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
function readMarks(root, manifest) {
|
|
375
|
+
const st = state(root, manifest.frames);
|
|
376
|
+
return st && snapshot(root, manifest, st);
|
|
377
|
+
}
|
|
378
|
+
/** The marks as the next `marver dev` would see them, from the files alone - nothing is written, so
|
|
379
|
+
* looking never starts the clock. `null` before the first `marver dev` on 0.25. */
|
|
380
|
+
function projectMarks(root, manifest) {
|
|
381
|
+
const c = readJson(root, "changes.json"), s = readJson(root, "seen.json");
|
|
382
|
+
if (c === void 0 && s === void 0) return null;
|
|
383
|
+
const st = load(root, manifest.frames);
|
|
384
|
+
if (!st) return null;
|
|
385
|
+
if (st.obs) {
|
|
386
|
+
const deps = frameDeps(root, manifest.frames);
|
|
387
|
+
const { doc, note } = compare(st.obs, observed(root, manifest.frames, deps), deps, manifest.frames.map((f) => f.id), true);
|
|
388
|
+
if (doc.length || note.length) {
|
|
389
|
+
st.rev++;
|
|
390
|
+
for (const id of doc) st.changed[id] = st.doc[id] = st.rev;
|
|
391
|
+
for (const id of note) st.changed[id] = st.rev;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return snapshot(root, manifest, st);
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
export { observe as a, marks_exports as i, docRevs as n, projectMarks as o, initMarks as r, recordChanged as s, docRev as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as avatarSourceFor, n as attachAvatar, p as provisionFromMarverId } from "./auth-DdUKeVKt.mjs";
|
|
2
2
|
import { TransactionStore, browserBinding, verifyAssertion } from "./marver-id-CVCoaMGI.mjs";
|
|
3
|
-
import { t as poweredByUrl } from "./serve-
|
|
3
|
+
import { t as poweredByUrl } from "./serve-wv2QWdxB.mjs";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
5
|
import { isIP } from "node:net";
|
|
6
6
|
import { lookup } from "node:dns/promises";
|
|
@@ -422,7 +422,7 @@ function marverIdHandler(dir, issuer, canvasName, branding = true, ceilings = {}
|
|
|
422
422
|
const { shareState, provisionVerdict } = await import("./auth-DdUKeVKt.mjs").then((n) => n.R);
|
|
423
423
|
const share = shareState(dir);
|
|
424
424
|
if (!(share ? provisionVerdict(share, result.identity.email) === "blocked" : false)) {
|
|
425
|
-
const { signCanvasJws } = await import("./summary-
|
|
425
|
+
const { signCanvasJws } = await import("./summary-CrW88e3q.mjs");
|
|
426
426
|
const now = Math.floor(Date.now() / 1e3);
|
|
427
427
|
request = signCanvasJws(dir, {
|
|
428
428
|
aud: origin,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.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 };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { r as readReloads } from "./perf-CCisg-ny.mjs";
|
|
2
|
+
//#region src/cli/perf.ts
|
|
3
|
+
/**
|
|
4
|
+
* `marver perf` (spec 26 Part 1): the reload log read back - per edited file, the frames it reached
|
|
5
|
+
* and how; every page-wide reload (sent or dropped) and every time the canvas page itself booted,
|
|
6
|
+
* with what came just before; the slowest frames to settle. Reads design/.local/perf/reloads.jsonl.
|
|
7
|
+
*/
|
|
8
|
+
function perfCommand(root, opts) {
|
|
9
|
+
const minutes = Number(opts.minutes) > 0 ? Number(opts.minutes) : 60;
|
|
10
|
+
const log = readReloads(root, Date.now() - minutes * 6e4);
|
|
11
|
+
const files = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const e of log) if (e.kind === "update") {
|
|
13
|
+
const f = files.get(e.file ?? "(no file)") ?? {
|
|
14
|
+
edits: 0,
|
|
15
|
+
reload: /* @__PURE__ */ new Set(),
|
|
16
|
+
inPlace: /* @__PURE__ */ new Set()
|
|
17
|
+
};
|
|
18
|
+
f.edits++;
|
|
19
|
+
for (const id of e.reload ?? []) f.reload.add(id);
|
|
20
|
+
for (const id of e.inPlace ?? []) f.inPlace.add(id);
|
|
21
|
+
files.set(e.file ?? "(no file)", f);
|
|
22
|
+
}
|
|
23
|
+
const reloads = log.filter((e) => e.kind === "full-reload");
|
|
24
|
+
const boots = log.flatMap((e, i) => e.kind === "shell-boot" ? [{
|
|
25
|
+
ts: e.ts,
|
|
26
|
+
before: log.slice(Math.max(0, i - 3), i).filter((x) => x.kind !== "ready" && x.kind !== "settled")
|
|
27
|
+
}] : []);
|
|
28
|
+
const slow = log.filter((e) => e.kind === "settled" && typeof e.ms === "number").sort((a, b) => b.ms - a.ms).slice(0, 5);
|
|
29
|
+
const booted = log.filter((e) => e.kind === "ready");
|
|
30
|
+
const by = (c) => booted.filter((e) => e.cause === c).length;
|
|
31
|
+
const reloaded = by("job");
|
|
32
|
+
if (opts.json) {
|
|
33
|
+
console.log(JSON.stringify({
|
|
34
|
+
minutes,
|
|
35
|
+
files: Object.fromEntries([...files].map(([k, v]) => [k, {
|
|
36
|
+
edits: v.edits,
|
|
37
|
+
reached: [...v.reload],
|
|
38
|
+
inPlace: [...v.inPlace]
|
|
39
|
+
}])),
|
|
40
|
+
documents: {
|
|
41
|
+
afterEdit: reloaded,
|
|
42
|
+
byHand: by("manual"),
|
|
43
|
+
retried: by("retry"),
|
|
44
|
+
self: by("self"),
|
|
45
|
+
first: by("first")
|
|
46
|
+
},
|
|
47
|
+
reloads,
|
|
48
|
+
boots,
|
|
49
|
+
slow
|
|
50
|
+
}, null, 2));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const t = (ts) => new Date(ts).toLocaleTimeString();
|
|
54
|
+
console.log(`last ${minutes} min - design/.local/perf/reloads.jsonl`);
|
|
55
|
+
console.log(`\nedits (${files.size} files)`);
|
|
56
|
+
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` : ""}`);
|
|
57
|
+
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`);
|
|
58
|
+
console.log(`\npage-wide reloads: ${reloads.filter((r) => r.passed).length} sent (dependency rebuilds), ${reloads.filter((r) => !r.passed).length} dropped`);
|
|
59
|
+
for (const r of reloads) console.log(` ${t(r.ts)} ${r.passed ? "sent " : "dropped"} ${r.triggeredBy ?? "no file named"}`);
|
|
60
|
+
console.log(`\ncanvas page loads: ${boots.length}`);
|
|
61
|
+
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(", ")}` : ""}`);
|
|
62
|
+
if (slow.length) {
|
|
63
|
+
console.log("\nslowest to settle");
|
|
64
|
+
for (const s of slow) console.log(` ${s.frame} ${s.ms} ms`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { perfCommand };
|