@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,17 +1,181 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
1
|
import { a as ROUTE, i as PKG, r as NAME } from "./cli.mjs";
|
|
3
2
|
import { c as nodeExists, d as readMembership, f as readRegistry, h as hash, i as checkBoardsDir, l as parseBoard, m as withRegistryLock, o as isRegularFile, r as boardFields, s as listBoardFiles, t as AUTHOR_FIELDS, u as pinFrames } from "./boards-CGg6piKF.mjs";
|
|
4
3
|
import { A as settableStatuses, D as readStatusWord, E as readReason, O as readType, T as readCapability, _ as wireKids, a as buildTree, c as folderMap, g as validateWire, h as readTitle, k as resolveType, m as readDescription, n as BOARD_NAME, r as FOLDERS_FILE, t as ALL_SCENES, x as HAS_STATUS } from "./board-tree-DRioF94d.mjs";
|
|
5
4
|
import { c as setSceneTitle, d as annotateBoards, f as planNames, m as readContextFacts, n as isNoteFile, o as rendersDoc, p as planWithStage, r as layoutDocSource, s as scanFrames, t as affectedFrameIds, u as writeManifest } from "./manifest-Nl3KSVOk.mjs";
|
|
6
|
-
import { r as boardsChanged } from "./work-
|
|
7
|
-
import {
|
|
8
|
-
import { n as
|
|
5
|
+
import { r as boardsChanged } from "./work-Bp1p39kq.mjs";
|
|
6
|
+
import { h as workspaceId, o as originOf } from "./slots-DCDo3N0x.mjs";
|
|
7
|
+
import { n as localProfile, t as isConnected } from "./profile-Bh5Y5zpW.mjs";
|
|
8
|
+
import { i as onPath, n as AGENT_NAMES, r as detectAgent, t as AGENT_BIN } from "./agent-BsieQGTD.mjs";
|
|
9
9
|
import { a as observe, n as docRevs, r as initMarks, s as recordChanged, t as docRev } from "./marks-CKgzucHZ.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { n as logPage, r as logReload, s as tidyPerfDir, t as PAGE_BODY_MAX } from "./perf-BWzQwZqj.mjs";
|
|
11
11
|
import { closeSync, copyFileSync, existsSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
12
12
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
|
-
import {
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
15
|
+
//#region src/server/config.ts
|
|
16
|
+
const DEFAULTS = {
|
|
17
|
+
mode: "studio",
|
|
18
|
+
theme: null,
|
|
19
|
+
viewports: {
|
|
20
|
+
mobile: {
|
|
21
|
+
width: 390,
|
|
22
|
+
height: 844
|
|
23
|
+
},
|
|
24
|
+
tablet: {
|
|
25
|
+
width: 768,
|
|
26
|
+
height: 1024
|
|
27
|
+
},
|
|
28
|
+
laptop: {
|
|
29
|
+
width: 1280,
|
|
30
|
+
height: 800
|
|
31
|
+
},
|
|
32
|
+
monitor: {
|
|
33
|
+
width: 1920,
|
|
34
|
+
height: 1080
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
themes: ["light", "dark"],
|
|
38
|
+
port: 5199,
|
|
39
|
+
zoomSpeed: 1,
|
|
40
|
+
share: { branding: true }
|
|
41
|
+
};
|
|
42
|
+
/** Load design/config.ts via native TS import (Node >= 22.18). Missing or broken fields fall back to defaults. */
|
|
43
|
+
async function loadConfig(root) {
|
|
44
|
+
const file = join(root, "design", "config.ts");
|
|
45
|
+
if (!existsSync(file)) return {
|
|
46
|
+
...DEFAULTS,
|
|
47
|
+
...jamFields(void 0)
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const user = (await import(`${pathToFileURL(file).href}?t=${Date.now()}`)).default ?? {};
|
|
51
|
+
return {
|
|
52
|
+
...DEFAULTS,
|
|
53
|
+
...user,
|
|
54
|
+
viewports: validViewports(user.viewports) ?? DEFAULTS.viewports,
|
|
55
|
+
themes: Array.isArray(user.themes) && user.themes.length ? user.themes.map(String) : DEFAULTS.themes,
|
|
56
|
+
port: validPort(user.port) ?? DEFAULTS.port,
|
|
57
|
+
zoomSpeed: validZoom(user.zoomSpeed) ?? DEFAULTS.zoomSpeed,
|
|
58
|
+
description: readDescription(user.description),
|
|
59
|
+
share: {
|
|
60
|
+
branding: user.share?.branding !== false,
|
|
61
|
+
name: typeof user.share?.name === "string" ? user.share.name : void 0,
|
|
62
|
+
logo: typeof user.share?.logo === "string" ? user.share.logo : void 0,
|
|
63
|
+
frontDoor: user.share?.frontDoor !== false && user.share?.front_door !== false,
|
|
64
|
+
notify: user.share?.notify !== false
|
|
65
|
+
},
|
|
66
|
+
...jamFields(user.jam)
|
|
67
|
+
};
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error(`[marver] design/config.ts failed to load, using defaults and leaving Live Jam OFF:\n ${err.message}`);
|
|
70
|
+
return {
|
|
71
|
+
...DEFAULTS,
|
|
72
|
+
jamOff: "unreadable"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const validDim = (n) => typeof n === "number" && Number.isFinite(n) && n >= 1 && n <= 2e4;
|
|
77
|
+
function validPort(n) {
|
|
78
|
+
return typeof n === "number" && Number.isInteger(n) && n > 0 && n < 65536 ? n : null;
|
|
79
|
+
}
|
|
80
|
+
function validZoom(n) {
|
|
81
|
+
return typeof n === "number" && Number.isFinite(n) && n >= .1 && n <= 10 ? n : null;
|
|
82
|
+
}
|
|
83
|
+
/** Six frames at once is what a jam actually feels like - at 3, half of a multi-frame
|
|
84
|
+
* ask sat waiting on the other half while the human watched. */
|
|
85
|
+
const DEFAULT_CONCURRENCY = 6;
|
|
86
|
+
/** A config value, printable in a warning. Never throws - a formatter that can crash inside an
|
|
87
|
+
* error path (JSON.stringify does, on a BigInt) turns a clear message into a mystery. */
|
|
88
|
+
const show = (v) => {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.stringify(v) ?? String(v);
|
|
91
|
+
} catch {
|
|
92
|
+
return String(v);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/** A `{...}` written by hand, not a Date/Map/class instance that merely types as "object". */
|
|
96
|
+
const plainObject = (v) => {
|
|
97
|
+
if (!v || typeof v !== "object") return false;
|
|
98
|
+
const proto = Object.getPrototypeOf(v);
|
|
99
|
+
return proto === Object.prototype || proto === null;
|
|
100
|
+
};
|
|
101
|
+
/** The agent to arm with - or, when the human NAMED one we cannot use, why not (said once,
|
|
102
|
+
* here, because a bad `jam.agent` is a config-file error like any other).
|
|
103
|
+
*
|
|
104
|
+
* A named agent is never quietly swapped for another: running a different tool than the one
|
|
105
|
+
* asked for is worse than not running. Nor is one armed that cannot be spawned - that would
|
|
106
|
+
* claim every @marver mention, fail it, and never retry. */
|
|
107
|
+
function resolveAgent(named) {
|
|
108
|
+
if (named === void 0) return detectAgent() ?? "no-agent";
|
|
109
|
+
if (typeof named !== "string" || !Object.hasOwn(AGENT_BIN, named)) {
|
|
110
|
+
console.warn(`[marver] design/config.ts: jam.agent ${show(named)} is not an agent marver can spawn - Live Jam is off. Use ${AGENT_NAMES}.`);
|
|
111
|
+
return "bad-agent";
|
|
112
|
+
}
|
|
113
|
+
const agent = named;
|
|
114
|
+
if (!onPath(AGENT_BIN[agent])) {
|
|
115
|
+
console.warn(`[marver] design/config.ts names jam.agent "${agent}", but \`${AGENT_BIN[agent]}\` is not on PATH - Live Jam is off until it is installed.`);
|
|
116
|
+
return "bad-agent";
|
|
117
|
+
}
|
|
118
|
+
return agent;
|
|
119
|
+
}
|
|
120
|
+
/** Resolve the jam block. Live Jam is ON by default: an absent or partial `jam` resolves
|
|
121
|
+
* to whatever agent CLI this machine has, so a fresh workspace jams with nothing
|
|
122
|
+
* configured and an old one needs no re-init. `jam: false` is the off switch. */
|
|
123
|
+
function resolveJam(v) {
|
|
124
|
+
if (v === false) return "opted-out";
|
|
125
|
+
const shape = v === void 0 || v === true ? {} : typeof v === "string" ? { agent: v } : plainObject(v) ? v : null;
|
|
126
|
+
if (!shape) {
|
|
127
|
+
console.warn(`[marver] design/config.ts: jam must be false, an agent name, or an options object - got ${show(v)}. Live Jam is off.`);
|
|
128
|
+
return "bad-agent";
|
|
129
|
+
}
|
|
130
|
+
const j = shape;
|
|
131
|
+
const agent = resolveAgent(j.agent);
|
|
132
|
+
if (agent === "no-agent" || agent === "bad-agent") return agent;
|
|
133
|
+
const c = j.concurrency;
|
|
134
|
+
const pick = (key, v, ok, fallback, want) => {
|
|
135
|
+
if (v === void 0) return fallback;
|
|
136
|
+
if (ok(v)) return v;
|
|
137
|
+
console.warn(`[marver] design/config.ts: jam.${key} must be ${want} - got ${show(v)}. Using ${JSON.stringify(fallback)}.`);
|
|
138
|
+
return fallback;
|
|
139
|
+
};
|
|
140
|
+
const bool = (v) => typeof v === "boolean";
|
|
141
|
+
return {
|
|
142
|
+
agent,
|
|
143
|
+
concurrency: typeof c === "number" && Number.isInteger(c) && c >= 1 && c <= 16 ? c : DEFAULT_CONCURRENCY,
|
|
144
|
+
subagents: j.subagents !== false,
|
|
145
|
+
proactive: j.proactive === true,
|
|
146
|
+
chime: pick("chime", j.chime, bool, true, "true or false"),
|
|
147
|
+
capture: pick("capture", j.capture, (v) => v === "confirm" || v === "at-once", "confirm", `'confirm' or 'at-once'`),
|
|
148
|
+
loc: pick("loc", j.loc, bool, true, "true or false"),
|
|
149
|
+
names: pick("names", j.names, bool, true, "true or false")
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** Exactly one of `jam` (armed) or `jamOff` (why not) - so the dev server can speak up about
|
|
153
|
+
* the one off-state nothing has reported yet, and stay quiet about the rest. BOTH keys are
|
|
154
|
+
* always written: these spread over the user's own `jam`, and a raw `jam: false` reaching the
|
|
155
|
+
* server as config would arm the daemon against a truthy object check. */
|
|
156
|
+
function jamFields(v) {
|
|
157
|
+
const r = resolveJam(v);
|
|
158
|
+
return typeof r === "string" ? {
|
|
159
|
+
jam: void 0,
|
|
160
|
+
jamOff: r
|
|
161
|
+
} : {
|
|
162
|
+
jam: r,
|
|
163
|
+
jamOff: void 0
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function validViewports(v) {
|
|
167
|
+
if (!v || typeof v !== "object") return null;
|
|
168
|
+
const out = {};
|
|
169
|
+
for (const [k, val] of Object.entries(v)) {
|
|
170
|
+
const vp = val;
|
|
171
|
+
if (validDim(vp?.width) && validDim(vp?.height)) out[k] = {
|
|
172
|
+
width: Math.round(vp.width),
|
|
173
|
+
height: Math.round(vp.height)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return Object.keys(out).length ? out : null;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
15
179
|
//#region src/shared/frames.ts
|
|
16
180
|
/** A canvas made of content frames alone (Doc, Md, Diagram ship their own styling) needs no theme -
|
|
17
181
|
* only an app frame does (#4). Empty counts as not content-only: the warning still helps there. */
|
|
@@ -363,6 +527,7 @@ function contained(target, base) {
|
|
|
363
527
|
}
|
|
364
528
|
}
|
|
365
529
|
function apiMiddleware(root, opts = {}) {
|
|
530
|
+
const ws = opts.workspace ?? workspaceId(root);
|
|
366
531
|
const devManifest = () => {
|
|
367
532
|
if (opts.manifest) return opts.manifest();
|
|
368
533
|
try {
|
|
@@ -607,7 +772,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
607
772
|
const str = (v) => typeof v === "string" ? v.slice(0, 200) : void 0;
|
|
608
773
|
const num = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
|
|
609
774
|
if (!str(b?.kind)) return json(res, 400, { error: "kind required" });
|
|
610
|
-
(await import("./perf-
|
|
775
|
+
(await import("./perf-BWzQwZqj.mjs").then((n) => n.i)).logReload(root, {
|
|
611
776
|
kind: str(b.kind),
|
|
612
777
|
tab: str(b.tab),
|
|
613
778
|
node: str(b.node),
|
|
@@ -629,9 +794,25 @@ function apiMiddleware(root, opts = {}) {
|
|
|
629
794
|
return json(res, 400, { error: "malformed JSON" });
|
|
630
795
|
}
|
|
631
796
|
if (!b || b.kind !== "capture" && b.kind !== "upload") return json(res, 400, { error: "kind must be capture or upload" });
|
|
632
|
-
(await import("./perf-jam-
|
|
797
|
+
(await import("./perf-jam-D55U3FZK.mjs").then((n) => n.n)).logJam(root, b);
|
|
633
798
|
return json(res, 200, { ok: true });
|
|
634
799
|
}
|
|
800
|
+
if (path === "perf/page" && req.method === "POST") {
|
|
801
|
+
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
802
|
+
const raw = await readBody(req, PAGE_BODY_MAX);
|
|
803
|
+
if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
|
|
804
|
+
let b;
|
|
805
|
+
try {
|
|
806
|
+
b = JSON.parse(raw);
|
|
807
|
+
} catch {
|
|
808
|
+
return json(res, 400, { error: "malformed JSON" });
|
|
809
|
+
}
|
|
810
|
+
if (!Array.isArray(b?.records)) return json(res, 400, { error: "expected { records: [...] }" });
|
|
811
|
+
return json(res, 200, {
|
|
812
|
+
ok: true,
|
|
813
|
+
accepted: logPage(root, b.records)
|
|
814
|
+
});
|
|
815
|
+
}
|
|
635
816
|
if (path === "sizes" && req.method === "GET") {
|
|
636
817
|
const frames = readManifestFrames();
|
|
637
818
|
if (!frames) return json(res, 200, {
|
|
@@ -1023,7 +1204,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1023
1204
|
}
|
|
1024
1205
|
}
|
|
1025
1206
|
if (path === "shot" && req.method === "GET") {
|
|
1026
|
-
const { readDevInfo } = await import("./work-
|
|
1207
|
+
const { readDevInfo } = await import("./work-Bp1p39kq.mjs").then((n) => n.o);
|
|
1027
1208
|
const token = readDevInfo(root)?.token;
|
|
1028
1209
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
1029
1210
|
const frameId = url.searchParams.get("frame") ?? "";
|
|
@@ -1039,7 +1220,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1039
1220
|
};
|
|
1040
1221
|
const asPng = url.searchParams.get("format") === "png";
|
|
1041
1222
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
1042
|
-
const { shootFrame } = await import("./shot-
|
|
1223
|
+
const { shootFrame } = await import("./shot-LFhC-WYD.mjs");
|
|
1043
1224
|
const r = await shootFrame({
|
|
1044
1225
|
root,
|
|
1045
1226
|
viewports: opts.viewports ?? {},
|
|
@@ -1073,7 +1254,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1073
1254
|
return res.end(png);
|
|
1074
1255
|
}
|
|
1075
1256
|
if (path === "shots" && req.method === "POST") {
|
|
1076
|
-
const { readDevInfo } = await import("./work-
|
|
1257
|
+
const { readDevInfo } = await import("./work-Bp1p39kq.mjs").then((n) => n.o);
|
|
1077
1258
|
const token = readDevInfo(root)?.token;
|
|
1078
1259
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
1079
1260
|
const raw = await readBody(req);
|
|
@@ -1090,7 +1271,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1090
1271
|
if (typeof theme !== "string" || !/^[a-z0-9-]+$/i.test(theme)) return json(res, 400, { error: "invalid theme" });
|
|
1091
1272
|
const scale = body.scale === void 0 ? void 0 : body.scale;
|
|
1092
1273
|
if (scale !== void 0 && !(Number.isInteger(scale) && scale >= 1 && scale <= 4)) return json(res, 400, { error: "invalid scale" });
|
|
1093
|
-
const { resolveFrames, shootBatch } = await import("./shot-
|
|
1274
|
+
const { resolveFrames, shootBatch } = await import("./shot-LFhC-WYD.mjs");
|
|
1094
1275
|
const sel = resolveFrames(root, body);
|
|
1095
1276
|
if (!sel.ok) return json(res, sel.status, { error: sel.error });
|
|
1096
1277
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
@@ -1108,7 +1289,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1108
1289
|
}
|
|
1109
1290
|
}
|
|
1110
1291
|
if (path === "anchor" && req.method === "POST") {
|
|
1111
|
-
const { readDevInfo } = await import("./work-
|
|
1292
|
+
const { readDevInfo } = await import("./work-Bp1p39kq.mjs").then((n) => n.o);
|
|
1112
1293
|
const token = readDevInfo(root)?.token;
|
|
1113
1294
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
1114
1295
|
const raw = await readBody(req);
|
|
@@ -1124,7 +1305,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1124
1305
|
if (typeof target === "string") return json(res, 400, { error: target });
|
|
1125
1306
|
const others = Array.isArray(b.others) ? b.others.filter((o) => typeof o?.key === "string").slice(0, 200) : [];
|
|
1126
1307
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
1127
|
-
const { checkAnchor, CheckInputError } = await import("./anchor-check-
|
|
1308
|
+
const { checkAnchor, CheckInputError } = await import("./anchor-check-ChdDqL5z.mjs");
|
|
1128
1309
|
try {
|
|
1129
1310
|
return json(res, 200, await checkAnchor({
|
|
1130
1311
|
root,
|
|
@@ -1152,7 +1333,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1152
1333
|
return json(res, 400, { error: "malformed JSON" });
|
|
1153
1334
|
}
|
|
1154
1335
|
if (!body || typeof body !== "object" || !Array.isArray(body.asks) || !body.asks.length || body.asks.length > 200) return json(res, 400, { error: "asks must list 1-200 frames" });
|
|
1155
|
-
const { bakeBatch, ASK_MAX } = await import("./bake-
|
|
1336
|
+
const { bakeBatch, ASK_MAX } = await import("./bake-DM_uWgAA.mjs");
|
|
1156
1337
|
let manifest = {};
|
|
1157
1338
|
try {
|
|
1158
1339
|
manifest = JSON.parse(readFileSync(join(root, "design", "manifest.json"), "utf8"));
|
|
@@ -1213,11 +1394,19 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1213
1394
|
})
|
|
1214
1395
|
});
|
|
1215
1396
|
}
|
|
1216
|
-
if (path === "poster" && req.method === "
|
|
1397
|
+
if (path === "poster" && req.method === "POST") {
|
|
1217
1398
|
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
|
|
1399
|
+
const raw = await readBody(req, 4096);
|
|
1400
|
+
if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
|
|
1401
|
+
let b;
|
|
1402
|
+
try {
|
|
1403
|
+
b = JSON.parse(raw);
|
|
1404
|
+
} catch {
|
|
1405
|
+
return json(res, 400, { error: "malformed JSON" });
|
|
1406
|
+
}
|
|
1407
|
+
const src = typeof b?.src === "string" ? b.src : "";
|
|
1408
|
+
const { ensurePoster, isLocalClip } = await import("./poster-Bx83ZYVK.mjs");
|
|
1409
|
+
const { isLocalAssetRef } = await import("./build-DZnFysGU.mjs");
|
|
1221
1410
|
if (!isLocalAssetRef(src) || !isLocalClip(src)) return json(res, 400, { error: "src must be a clip under design/assets/" });
|
|
1222
1411
|
const r = await ensurePoster(join(root, "design", "assets"), src);
|
|
1223
1412
|
if (!r.ok) return json(res, r.error.includes("does not exist") ? 404 : 503, { error: r.error });
|
|
@@ -1280,14 +1469,14 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1280
1469
|
return json(res, 405, { error: "method not allowed" });
|
|
1281
1470
|
}
|
|
1282
1471
|
if (path === "work") {
|
|
1283
|
-
const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-
|
|
1472
|
+
const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-Bp1p39kq.mjs").then((n) => n.o);
|
|
1284
1473
|
const tokenOk = () => {
|
|
1285
1474
|
const t = readDevInfo(root)?.token;
|
|
1286
1475
|
return !!t && req.headers["x-mv-work"] === t;
|
|
1287
1476
|
};
|
|
1288
1477
|
if (req.method === "GET") {
|
|
1289
1478
|
if (!ownerGated(req) && !tokenOk()) return json(res, 403, { error: "forbidden" });
|
|
1290
|
-
const { boardsShowing, activityClock } = await import("./work-
|
|
1479
|
+
const { boardsShowing, activityClock } = await import("./work-Bp1p39kq.mjs").then((n) => n.o);
|
|
1291
1480
|
const frames = workActivity.active();
|
|
1292
1481
|
return json(res, 200, {
|
|
1293
1482
|
frames,
|
|
@@ -1382,7 +1571,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1382
1571
|
} catch {
|
|
1383
1572
|
return json(res, 400, { error: "malformed JSON" });
|
|
1384
1573
|
}
|
|
1385
|
-
const { ACTIONS } = await import("./queue-
|
|
1574
|
+
const { ACTIONS } = await import("./queue-CAM_vNmX.mjs");
|
|
1386
1575
|
if (!b || typeof b.id !== "string" || !Number.isInteger(b.rev) || !ACTIONS.includes(b.action) || b.body !== void 0 && typeof b.body !== "string") return json(res, 400, { error: "expected { id, rev, action, body? }" });
|
|
1387
1576
|
if ("kind" in b) return json(res, 400, { error: "a capture has no category" });
|
|
1388
1577
|
const { jamLive } = await import("./live-Cgzsicwi.mjs");
|
|
@@ -1511,8 +1700,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1511
1700
|
} catch {
|
|
1512
1701
|
return json(res, 400, { error: "malformed JSON" });
|
|
1513
1702
|
}
|
|
1514
|
-
|
|
1515
|
-
if (b?.workspace !== void 0 && b.workspace !== createHash("sha256").update(root).digest("hex").slice(0, 16)) return json(res, 409, { error: "this capture was made in another workspace" });
|
|
1703
|
+
if (b?.workspace !== void 0 && b.workspace !== ws) return json(res, 409, { error: "this capture was made in another workspace" });
|
|
1516
1704
|
const { jamLive } = await import("./live-Cgzsicwi.mjs");
|
|
1517
1705
|
if (!jamLive.capture) return json(res, 409, { error: "jam is not running here" });
|
|
1518
1706
|
const r = await jamLive.capture(b?.record);
|
|
@@ -1547,7 +1735,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1547
1735
|
if (!b || typeof b.capture !== "string" || !CAPTURE_ID.test(b.capture) || typeof b.frame !== "string") return json(res, 400, { error: "expected { capture, frame, theme?, viewport? }" });
|
|
1548
1736
|
if (readCapture(root, b.capture)) return json(res, 409, { error: "that capture is sealed" });
|
|
1549
1737
|
const theme = typeof b.theme === "string" && /^[a-z0-9-]+$/i.test(b.theme) ? b.theme : "light";
|
|
1550
|
-
const { shootFrame } = await import("./shot-
|
|
1738
|
+
const { shootFrame } = await import("./shot-LFhC-WYD.mjs");
|
|
1551
1739
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
1552
1740
|
const vp = typeof b.viewport === "string" ? opts.viewports?.[b.viewport] : void 0;
|
|
1553
1741
|
const dim = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
|
|
@@ -1638,7 +1826,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
1638
1826
|
}
|
|
1639
1827
|
}
|
|
1640
1828
|
if (path === "sync" && req.method === "POST") {
|
|
1641
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
1829
|
+
const { loadCollab, syncOnce } = await import("./sync-BQVlHZpx.mjs").then((n) => n.o);
|
|
1642
1830
|
const collab = loadCollab(root);
|
|
1643
1831
|
if (!collab) return json(res, 200, { connected: false });
|
|
1644
1832
|
try {
|
|
@@ -1667,15 +1855,40 @@ function backgroundPush(root) {
|
|
|
1667
1855
|
pushTimer = setTimeout(async () => {
|
|
1668
1856
|
pushTimer = null;
|
|
1669
1857
|
try {
|
|
1670
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
1858
|
+
const { loadCollab, syncOnce } = await import("./sync-BQVlHZpx.mjs").then((n) => n.o);
|
|
1671
1859
|
const collab = loadCollab(root);
|
|
1672
1860
|
if (collab) await syncOnce(root, collab);
|
|
1673
1861
|
} catch {}
|
|
1674
1862
|
}, 1500);
|
|
1675
1863
|
}
|
|
1676
1864
|
//#endregion
|
|
1865
|
+
//#region src/server/proof.ts
|
|
1866
|
+
/**
|
|
1867
|
+
* The document proof (spec 28 A1.4). The Mac app puts a fresh nonce on every main-frame request to a
|
|
1868
|
+
* local canvas (`x-mv-nonce`) and checks the answer before the document commits; only the canvas
|
|
1869
|
+
* holding the slot file's key can sign it, so the privileges the app grants belong to that exact
|
|
1870
|
+
* document. The proof rides the very response the app commits - the check and the load can never
|
|
1871
|
+
* reach different listeners.
|
|
1872
|
+
*
|
|
1873
|
+
* Pinned exactly, so the app (A2.3 `proof.ts`) computes the same: the key is the slot file's 32 bytes
|
|
1874
|
+
* (base64url there), HMAC-SHA256 over UTF-8 `doc|<nonce>|<port>` (port in decimal), base64url without
|
|
1875
|
+
* padding. Requests from the app itself carry `app|<port>` the same way.
|
|
1876
|
+
*/
|
|
1877
|
+
/** 16-64 base64url characters - anything else is not a nonce, and is ignored. */
|
|
1878
|
+
const NONCE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
1879
|
+
const sign$1 = (key, msg) => createHmac("sha256", key).update(msg, "utf8").digest("base64url");
|
|
1880
|
+
const docProof = (key, nonce, port) => sign$1(key, `doc|${nonce}|${port}`);
|
|
1881
|
+
/** The two headers for a request carrying a well-formed `x-mv-nonce`, else null. */
|
|
1882
|
+
function proofHeaders(p, nonce) {
|
|
1883
|
+
if (!p || typeof nonce !== "string" || !NONCE.test(nonce)) return null;
|
|
1884
|
+
return {
|
|
1885
|
+
"x-mv-instance": p.instance,
|
|
1886
|
+
"x-mv-proof": docProof(p.key, nonce, p.port)
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
//#endregion
|
|
1677
1890
|
//#region src/server/routes.ts
|
|
1678
|
-
function routesMiddleware(server, clientDir, stamps) {
|
|
1891
|
+
function routesMiddleware(server, clientDir, stamps, proof) {
|
|
1679
1892
|
const page = (dir) => {
|
|
1680
1893
|
const html = readFileSync(join(clientDir, dir, "index.html"), "utf8");
|
|
1681
1894
|
const entry = "/@fs/" + join(clientDir, dir, "main.tsx").split("\\").join("/");
|
|
@@ -1733,6 +1946,8 @@ function routesMiddleware(server, clientDir, stamps) {
|
|
|
1733
1946
|
if (stamp) html = html.replace("<head>", `<head><meta name="mv-doc" content="${stamp.replace(/[&"<>]/g, (c) => `&#${c.charCodeAt(0)};`)}">`);
|
|
1734
1947
|
res.setHeader("content-type", "text/html");
|
|
1735
1948
|
res.setHeader("cache-control", "no-store");
|
|
1949
|
+
const signed = dir === "shell" && req.method === "GET" ? proofHeaders(proof, req.headers["x-mv-nonce"]) : null;
|
|
1950
|
+
if (signed) for (const [k, v] of Object.entries(signed)) res.setHeader(k, v);
|
|
1736
1951
|
res.end(html);
|
|
1737
1952
|
} catch (err) {
|
|
1738
1953
|
res.statusCode = 500;
|
|
@@ -1741,6 +1956,89 @@ function routesMiddleware(server, clientDir, stamps) {
|
|
|
1741
1956
|
};
|
|
1742
1957
|
}
|
|
1743
1958
|
//#endregion
|
|
1959
|
+
//#region src/server/guard.ts
|
|
1960
|
+
/** A workspace key as marver writes it: 16 hex. A frame's own `ws` query in another shape is the
|
|
1961
|
+
* frame's business, never ours. */
|
|
1962
|
+
const WS_KEY = /^[0-9a-f]{16}$/;
|
|
1963
|
+
/** Marks the workspace refusal, so the page tells it from every other 409 without reading the body. */
|
|
1964
|
+
const ELSEWHERE_HEADER = "x-mv-elsewhere";
|
|
1965
|
+
/** What a frame gets when its URL names another workspace: no script, nothing of this project. The
|
|
1966
|
+
* `mv-elsewhere` meta is how the shell, back on its own canvas, finds the frames to reload, and draws its own
|
|
1967
|
+
* quiet placeholder over them meanwhile (shell/api.ts) - so this page is read on its own: a frame's address
|
|
1968
|
+
* opened in a tab. It wears the frame's own theme (its URL's `theme`; a name with "dark" in it is dark), never
|
|
1969
|
+
* the system's: a light frame stays light on a Mac in dark mode. */
|
|
1970
|
+
function anotherCanvasPage(theme) {
|
|
1971
|
+
const dark = /dark/i.test(theme ?? "");
|
|
1972
|
+
const [bg, ink, dim, code] = dark ? [
|
|
1973
|
+
"#0f1015",
|
|
1974
|
+
"#ececf1",
|
|
1975
|
+
"#a1a1aa",
|
|
1976
|
+
"#1d1e26"
|
|
1977
|
+
] : [
|
|
1978
|
+
"#ffffff",
|
|
1979
|
+
"#18181b",
|
|
1980
|
+
"#52525b",
|
|
1981
|
+
"#f0f0f2"
|
|
1982
|
+
];
|
|
1983
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta name="mv-elsewhere" content="1"><meta name="color-scheme" content="${dark ? "dark" : "light"}"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Another canvas</title><style>html,body{height:100%;margin:0;background:${bg}}body{display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;font:400 13px/1.5 -apple-system,system-ui,sans-serif;color:${dim}}main{max-width:340px}h1{margin:0 0 6px;font-size:15px;font-weight:600;line-height:1.35;color:${ink}}p{margin:0}code{font:500 12px ui-monospace,SFMono-Regular,Menlo,monospace;color:${ink};background:${code};padding:1px 5px;border-radius:5px;white-space:nowrap}</style></head><body><main><h1>This frame's canvas stopped</h1><p>Another project runs on this address now. To bring this frame back, stop that project, run <code>npx marver dev</code> in this frame's own project, then reload.</p></main></body></html>`;
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* The first middleware of every dev server (spec 28 A1.11). A page left open after its canvas
|
|
1987
|
+
* stopped may reach whatever listens on that port later; everything it sends names its workspace,
|
|
1988
|
+
* and this answers before anything of this project is read, written or served:
|
|
1989
|
+
* - `Service-Worker: script` (what the browser sends when it fetches a worker's script): 403 - no
|
|
1990
|
+
* service worker ever runs on a canvas, whatever later takes the port;
|
|
1991
|
+
* - `x-mv-ws` present and not ours: 409 `{ error: 'another workspace' }`;
|
|
1992
|
+
* - a `ws` query not ours (frame and stage URLs, a Jam picture's <img>): the same 409 under
|
|
1993
|
+
* /__mv/api/, else the "another canvas" page - a retained frame reloading its own URL never boots
|
|
1994
|
+
* this project's frame;
|
|
1995
|
+
* - `GET /__mv/api/hello`: `{ ok, ws }` - the stopped page asking "is my canvas back here?".
|
|
1996
|
+
* A request naming no workspace (the CLI, a test, an older page) is served as before.
|
|
1997
|
+
*/
|
|
1998
|
+
function guardMiddleware(workspace) {
|
|
1999
|
+
return (req, res, next) => {
|
|
2000
|
+
if (String(req.headers["service-worker"] ?? "").toLowerCase() === "script") {
|
|
2001
|
+
res.statusCode = 403;
|
|
2002
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
2003
|
+
return res.end("marver canvases run no service workers");
|
|
2004
|
+
}
|
|
2005
|
+
let url;
|
|
2006
|
+
try {
|
|
2007
|
+
url = new URL(req.url ?? "/", "http://x");
|
|
2008
|
+
} catch {
|
|
2009
|
+
return next();
|
|
2010
|
+
}
|
|
2011
|
+
const api = url.pathname.startsWith(`${ROUTE}/api/`);
|
|
2012
|
+
const said = req.headers["x-mv-ws"];
|
|
2013
|
+
if (said !== void 0 && String(said) !== workspace) return elsewhere(res);
|
|
2014
|
+
const q = url.searchParams.get("ws");
|
|
2015
|
+
if (q !== null && WS_KEY.test(q) && q !== workspace) {
|
|
2016
|
+
if (api) return elsewhere(res);
|
|
2017
|
+
res.statusCode = 409;
|
|
2018
|
+
res.setHeader("content-type", "text/html; charset=utf-8");
|
|
2019
|
+
res.setHeader("cache-control", "no-store");
|
|
2020
|
+
res.setHeader(ELSEWHERE_HEADER, "1");
|
|
2021
|
+
return res.end(anotherCanvasPage(url.searchParams.get("theme")));
|
|
2022
|
+
}
|
|
2023
|
+
if (url.pathname === `/__mv/api/hello` && req.method === "GET") {
|
|
2024
|
+
res.setHeader("content-type", "application/json");
|
|
2025
|
+
res.setHeader("cache-control", "no-store");
|
|
2026
|
+
return res.end(JSON.stringify({
|
|
2027
|
+
ok: true,
|
|
2028
|
+
ws: workspace
|
|
2029
|
+
}));
|
|
2030
|
+
}
|
|
2031
|
+
next();
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
function elsewhere(res) {
|
|
2035
|
+
res.statusCode = 409;
|
|
2036
|
+
res.setHeader("content-type", "application/json");
|
|
2037
|
+
res.setHeader("cache-control", "no-store");
|
|
2038
|
+
res.setHeader(ELSEWHERE_HEADER, "1");
|
|
2039
|
+
res.end(JSON.stringify({ error: "another workspace" }));
|
|
2040
|
+
}
|
|
2041
|
+
//#endregion
|
|
1744
2042
|
//#region src/server/update.ts
|
|
1745
2043
|
/**
|
|
1746
2044
|
* Update discovery - dev only, and deliberately boring about privacy: one anonymous
|
|
@@ -1749,10 +2047,6 @@ function routesMiddleware(server, clientDir, stamps) {
|
|
|
1749
2047
|
* firewalled registries degrade to silence. MARVER_NO_UPDATE_CHECK=1 disables it.
|
|
1750
2048
|
* Published bundles never check anything - viewers are not the owner.
|
|
1751
2049
|
*/
|
|
1752
|
-
var update_exports = /* @__PURE__ */ __exportAll({
|
|
1753
|
-
checkUpdate: () => checkUpdate,
|
|
1754
|
-
installedVersion: () => installedVersion
|
|
1755
|
-
});
|
|
1756
2050
|
const TTL = 864e5;
|
|
1757
2051
|
/** Installed version: walk up from this module to the package's own package.json
|
|
1758
2052
|
* (one level from dist/, two from src/server/ - the walk covers both). */
|
|
@@ -1818,6 +2112,9 @@ const VIRTUAL_CONFIG = "virtual:sh-config";
|
|
|
1818
2112
|
const VIRTUAL_DATA = "virtual:sh-data";
|
|
1819
2113
|
function marverPlugin(ctx) {
|
|
1820
2114
|
const { root, clientDir, config } = ctx;
|
|
2115
|
+
const ws = ctx.workspace ?? workspaceId(root);
|
|
2116
|
+
/** a watcher this plugin makes, handed to the start (its error is said, not Node's crash) - as it is, outside one */
|
|
2117
|
+
const guarded = (w) => ctx.startup?.watch?.(w) ?? w;
|
|
1821
2118
|
let project = {
|
|
1822
2119
|
name: config.share.name || basename(root),
|
|
1823
2120
|
description: config.description
|
|
@@ -1825,6 +2122,7 @@ function marverPlugin(ctx) {
|
|
|
1825
2122
|
const projectInfo = () => project;
|
|
1826
2123
|
let manifest = scanFrames(root, projectInfo());
|
|
1827
2124
|
let devServer = null;
|
|
2125
|
+
let served = 0;
|
|
1828
2126
|
const bootId = String(process.hrtime.bigint());
|
|
1829
2127
|
let invRev = 0;
|
|
1830
2128
|
const pendingInv = /* @__PURE__ */ new Set();
|
|
@@ -1880,6 +2178,10 @@ function marverPlugin(ctx) {
|
|
|
1880
2178
|
}, 1e4);
|
|
1881
2179
|
inFlight.set(file, f);
|
|
1882
2180
|
};
|
|
2181
|
+
ctx.startup?.defer(() => {
|
|
2182
|
+
flushInv.cancel();
|
|
2183
|
+
for (const f of inFlight.values()) clearTimeout(f.timer);
|
|
2184
|
+
});
|
|
1883
2185
|
const landed = (file) => {
|
|
1884
2186
|
const owed = late.get(file);
|
|
1885
2187
|
if (owed) {
|
|
@@ -1978,7 +2280,7 @@ function marverPlugin(ctx) {
|
|
|
1978
2280
|
capture: config.jam.capture,
|
|
1979
2281
|
names: config.jam.names && config.jam.agent === "claude"
|
|
1980
2282
|
} : null,
|
|
1981
|
-
workspace:
|
|
2283
|
+
workspace: ws
|
|
1982
2284
|
})}`;
|
|
1983
2285
|
}
|
|
1984
2286
|
if (id === "\0virtual:sh-data") return "export default null";
|
|
@@ -2024,6 +2326,25 @@ function marverPlugin(ctx) {
|
|
|
2024
2326
|
}
|
|
2025
2327
|
},
|
|
2026
2328
|
configureServer(server) {
|
|
2329
|
+
const closers = [];
|
|
2330
|
+
const onClose = (fn) => {
|
|
2331
|
+
closers.push(fn);
|
|
2332
|
+
};
|
|
2333
|
+
const closeAll = () => {
|
|
2334
|
+
for (const fn of closers.splice(0).reverse()) try {
|
|
2335
|
+
fn();
|
|
2336
|
+
} catch {}
|
|
2337
|
+
};
|
|
2338
|
+
const withdraw = ctx.startup?.defer(closeAll, server);
|
|
2339
|
+
server.httpServer?.once("close", () => {
|
|
2340
|
+
withdraw?.();
|
|
2341
|
+
closeAll();
|
|
2342
|
+
});
|
|
2343
|
+
if (served++) {
|
|
2344
|
+
manifest = scanFrames(root, projectInfo());
|
|
2345
|
+
observeLater();
|
|
2346
|
+
}
|
|
2347
|
+
server.middlewares.use(guardMiddleware(ws));
|
|
2027
2348
|
let bakeGen = Date.now();
|
|
2028
2349
|
server.middlewares.use((req, res, next) => {
|
|
2029
2350
|
if (req.url && req.url.includes("/frame-host/registry.ts")) {
|
|
@@ -2047,25 +2368,27 @@ function marverPlugin(ctx) {
|
|
|
2047
2368
|
}));
|
|
2048
2369
|
});
|
|
2049
2370
|
});
|
|
2050
|
-
const listeningOrigin = () =>
|
|
2051
|
-
const a = server.httpServer?.address();
|
|
2052
|
-
if (!a || typeof a === "string") return null;
|
|
2053
|
-
return `http://${a.family === "IPv6" ? a.address === "::" ? "[::1]" : `[${a.address}]` : a.address === "0.0.0.0" ? "127.0.0.1" : a.address}:${a.port}`;
|
|
2054
|
-
};
|
|
2371
|
+
const listeningOrigin = () => originOf(server.httpServer?.address());
|
|
2055
2372
|
initMarks(root, manifest.frames);
|
|
2373
|
+
tidyPerfDir(root);
|
|
2056
2374
|
server.middlewares.use(apiMiddleware(root, {
|
|
2057
2375
|
viewports: config.viewports,
|
|
2058
2376
|
origin: listeningOrigin,
|
|
2059
2377
|
bakeGen: () => bakeGen,
|
|
2060
2378
|
notify: (event) => server.ws.send(event, {}),
|
|
2061
2379
|
manifest: () => manifest,
|
|
2062
|
-
settled
|
|
2380
|
+
settled,
|
|
2381
|
+
workspace: ws
|
|
2063
2382
|
}));
|
|
2064
2383
|
server.middlewares.use(routesMiddleware(server, clientDir, {
|
|
2065
2384
|
doc: (id) => docRev(root, manifest.frames, id),
|
|
2066
2385
|
docs: () => docRevs(root, manifest.frames)
|
|
2067
|
-
}));
|
|
2386
|
+
}, ctx.proof));
|
|
2387
|
+
const before = devServer;
|
|
2068
2388
|
devServer = server;
|
|
2389
|
+
onClose(() => {
|
|
2390
|
+
if (devServer === server) devServer = before;
|
|
2391
|
+
});
|
|
2069
2392
|
guardUpdates(server, root, () => manifest, hooks);
|
|
2070
2393
|
let framesKey = JSON.stringify(manifest.frames);
|
|
2071
2394
|
let scenesKey = JSON.stringify(manifest.scenes);
|
|
@@ -2088,6 +2411,7 @@ function marverPlugin(ctx) {
|
|
|
2088
2411
|
framesKey = key;
|
|
2089
2412
|
scenesKey = sKey;
|
|
2090
2413
|
}, 150);
|
|
2414
|
+
onClose(regen.cancel);
|
|
2091
2415
|
const watched = [join(root, "design", "scenes"), join(root, "design", "components")];
|
|
2092
2416
|
const inScope = (file) => watched.some((w) => file.startsWith(w));
|
|
2093
2417
|
const themeModules = () => {
|
|
@@ -2107,6 +2431,7 @@ function marverPlugin(ctx) {
|
|
|
2107
2431
|
const pushTheme = debounce(() => {
|
|
2108
2432
|
for (const mod of themeModules()) server.reloadModule(mod).catch(() => {});
|
|
2109
2433
|
}, 150);
|
|
2434
|
+
onClose(pushTheme.cancel);
|
|
2110
2435
|
const rescanTheme = () => {
|
|
2111
2436
|
for (const mod of themeModules()) server.moduleGraph.invalidateModule(mod);
|
|
2112
2437
|
pushTheme();
|
|
@@ -2117,11 +2442,19 @@ function marverPlugin(ctx) {
|
|
|
2117
2442
|
bakeGen++;
|
|
2118
2443
|
prune();
|
|
2119
2444
|
};
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2445
|
+
const pruning = /* @__PURE__ */ new Set();
|
|
2446
|
+
const prune = () => {
|
|
2447
|
+
const t = setTimeout(async () => {
|
|
2448
|
+
pruning.delete(t);
|
|
2449
|
+
try {
|
|
2450
|
+
(await import("./bake-DM_uWgAA.mjs")).pruneBakes(root, bakeGen);
|
|
2451
|
+
} catch {}
|
|
2452
|
+
}, 500);
|
|
2453
|
+
pruning.add(t);
|
|
2454
|
+
};
|
|
2455
|
+
onClose(() => {
|
|
2456
|
+
for (const t of pruning) clearTimeout(t);
|
|
2457
|
+
});
|
|
2125
2458
|
prune();
|
|
2126
2459
|
server.watcher.on("add", bumpGen);
|
|
2127
2460
|
server.watcher.on("unlink", bumpGen);
|
|
@@ -2140,6 +2473,7 @@ function marverPlugin(ctx) {
|
|
|
2140
2473
|
});
|
|
2141
2474
|
const contextDir = join(root, "context") + sep;
|
|
2142
2475
|
let statusTimer;
|
|
2476
|
+
onClose(() => clearTimeout(statusTimer));
|
|
2143
2477
|
const restatus = (f) => {
|
|
2144
2478
|
if (!f.startsWith(contextDir) && !(inScope(f) && f.endsWith("_brief.md"))) return;
|
|
2145
2479
|
clearTimeout(statusTimer);
|
|
@@ -2153,6 +2487,7 @@ function marverPlugin(ctx) {
|
|
|
2153
2487
|
server.watcher.on("change", restatus);
|
|
2154
2488
|
server.watcher.on("change", (f) => inScope(f) && (/\.(tsx|jsx)$/.test(f) || f.endsWith("_brief.md") || isNoteFile(f)) && regen());
|
|
2155
2489
|
const marksChanged = debounce(observeLater, 300);
|
|
2490
|
+
onClose(marksChanged.cancel);
|
|
2156
2491
|
for (const ev of [
|
|
2157
2492
|
"add",
|
|
2158
2493
|
"change",
|
|
@@ -2187,7 +2522,7 @@ function marverPlugin(ctx) {
|
|
|
2187
2522
|
}
|
|
2188
2523
|
if (nodeExists(join(boardsDir, `all-scenes.json`))) console.log(`[${NAME}] design/boards/${ALL_SCENES}.json is left over from the All Scenes board, gone since 0.25 - nothing reads it any more; delete it when you like (its threads stay in design/comments/)`);
|
|
2189
2524
|
let listTimer;
|
|
2190
|
-
const watcher = watch(boardsDir, (_event, file) => {
|
|
2525
|
+
const watcher = guarded(watch(boardsDir, (_event, file) => {
|
|
2191
2526
|
if (!file || !file.endsWith(".json") || file === "_sizes.json" || file === `all-scenes.json`) return;
|
|
2192
2527
|
clearTimeout(listTimer);
|
|
2193
2528
|
listTimer = setTimeout(() => {
|
|
@@ -2216,8 +2551,12 @@ function marverPlugin(ctx) {
|
|
|
2216
2551
|
sha256: hash(content)
|
|
2217
2552
|
});
|
|
2218
2553
|
}, 120));
|
|
2554
|
+
}));
|
|
2555
|
+
onClose(() => {
|
|
2556
|
+
watcher.close();
|
|
2557
|
+
clearTimeout(listTimer);
|
|
2558
|
+
for (const t of timers.values()) clearTimeout(t);
|
|
2219
2559
|
});
|
|
2220
|
-
server.httpServer?.once("close", () => watcher.close());
|
|
2221
2560
|
} catch {}
|
|
2222
2561
|
try {
|
|
2223
2562
|
const inbox = join(root, "design", ".local", "shots");
|
|
@@ -2299,7 +2638,7 @@ function marverPlugin(ctx) {
|
|
|
2299
2638
|
});
|
|
2300
2639
|
return;
|
|
2301
2640
|
}
|
|
2302
|
-
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-
|
|
2641
|
+
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-LFhC-WYD.mjs");
|
|
2303
2642
|
if (ways[0] === "frame") {
|
|
2304
2643
|
if (typeof spec.frame !== "string") {
|
|
2305
2644
|
write({
|
|
@@ -2352,16 +2691,16 @@ function marverPlugin(ctx) {
|
|
|
2352
2691
|
}
|
|
2353
2692
|
}, 60);
|
|
2354
2693
|
};
|
|
2355
|
-
const inboxWatcher = watch(inbox, { persistent: false }, (_e, file) => {
|
|
2694
|
+
const inboxWatcher = guarded(watch(inbox, { persistent: false }, (_e, file) => {
|
|
2356
2695
|
if (file) processRequest(file);
|
|
2357
|
-
});
|
|
2696
|
+
}));
|
|
2358
2697
|
const sweep = setInterval(() => {
|
|
2359
2698
|
try {
|
|
2360
2699
|
for (const f of readdirSync(inbox)) processRequest(f);
|
|
2361
2700
|
} catch {}
|
|
2362
2701
|
}, 1e3);
|
|
2363
2702
|
sweep.unref?.();
|
|
2364
|
-
|
|
2703
|
+
onClose(() => {
|
|
2365
2704
|
inboxWatcher.close();
|
|
2366
2705
|
clearInterval(sweep);
|
|
2367
2706
|
});
|
|
@@ -2375,10 +2714,10 @@ function observed(r) {
|
|
|
2375
2714
|
}
|
|
2376
2715
|
function debounce(fn, ms) {
|
|
2377
2716
|
let t;
|
|
2378
|
-
return ((...a) => {
|
|
2717
|
+
return Object.assign(((...a) => {
|
|
2379
2718
|
clearTimeout(t);
|
|
2380
2719
|
t = setTimeout(() => fn(...a), ms);
|
|
2381
|
-
});
|
|
2720
|
+
}), { cancel: () => clearTimeout(t) });
|
|
2382
2721
|
}
|
|
2383
2722
|
/** Extra vite plugin when the host runs Tailwind v4. The host's own @tailwindcss/vite
|
|
2384
2723
|
* wins (version-matched to their tailwindcss); the fallback is marver's bundled copy -
|
|
@@ -2420,4 +2759,4 @@ async function tailwind3Css(root) {
|
|
|
2420
2759
|
return null;
|
|
2421
2760
|
}
|
|
2422
2761
|
//#endregion
|
|
2423
|
-
export { autoWidthOf as a, readSizes as c,
|
|
2762
|
+
export { autoWidthOf as a, readSizes as c, installedVersion as i, loadConfig as l, tailwind3Css as n, keptSizes as o, tailwind4Plugin as r, measuringFrames as s, marverPlugin as t };
|