@marver-design/marver 0.30.0 → 0.31.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 +74 -0
- package/README.md +11 -7
- package/dist/{anchor-check-c52IDkiQ.mjs → anchor-check-B92s9tVv.mjs} +1 -1
- package/dist/{board-tree-BXR8dw4b.mjs → board-tree-DGj0HhEE.mjs} +6 -2
- package/dist/{boards-EH2onUXM.mjs → boards-Cim1GTKc.mjs} +32 -2
- package/dist/{boards-BeWtjGUM.mjs → boards-OlAhZ87x.mjs} +7 -7
- package/dist/{build-C3mUtjEn.mjs → build-BNssmbqd.mjs} +14 -17
- package/dist/{capture-DEtM4qm5.mjs → capture-HaS-1or8.mjs} +1 -1
- package/dist/cli.mjs +38 -20
- package/dist/{collab-BEAcXrBb.mjs → collab-D2NcrOB8.mjs} +53 -14
- package/dist/comment-actions-Bxf9Ld4g.mjs +351 -0
- package/dist/{comments-XNhMmSSu.mjs → comments-BakJQwaf.mjs} +85 -10
- package/dist/config-B0YcFtqS.mjs +510 -0
- package/dist/{context-BUnFiyA3.mjs → context-Cj2TcC0H.mjs} +3 -3
- package/dist/{daemon-B0Wi1OQ3.mjs → daemon-MxoEQajX.mjs} +223 -26
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-5dlxoW28.mjs → dev-BBZe_brH.mjs} +23 -16
- package/dist/devices-uJZ2inMq.mjs +155 -0
- package/dist/{events-CLH4ijKP.mjs → events-Dieo1482.mjs} +49 -4
- package/dist/{init-CYlFaRzG.mjs → init-BgusplYn.mjs} +40 -10
- package/dist/{jam-Cj5gBvwD.mjs → jam-CkuLL8A8.mjs} +1 -1
- package/dist/{link-BFFRgrMt.mjs → link-Cmt9Xy4X.mjs} +54 -7
- package/dist/{logo-CXY-1yrn.mjs → logo-C9s7-Cy9.mjs} +89 -66
- package/dist/{ls-NqmePKOf.mjs → ls-DGVIW-Io.mjs} +1 -1
- package/dist/{manifest-DPZ3WNg_.mjs → manifest-CK8Qh4Nq.mjs} +255 -13
- package/dist/{marks-BnNANic9.mjs → marks-C8oX8kbE.mjs} +3 -3
- package/dist/{marks-DBp3h1Mc.mjs → marks-Dt-5JXCp.mjs} +18 -5
- package/dist/{marver-id-gate-vBLb_Icb.mjs → marver-id-gate-BAeuMeaU.mjs} +11 -7
- package/dist/md-B9_13Q0R.mjs +105 -0
- package/dist/notes-CRAX4wgk.mjs +148 -0
- package/dist/own-C8Mq0Hnf.mjs +128 -0
- package/dist/pdf-0m721FFn.mjs +117 -0
- package/dist/pdf-CZENT6t3.mjs +2299 -0
- package/dist/{perf-BCxAo0IS.mjs → perf-BB0XNt1M.mjs} +1 -1
- package/dist/{perf-6MOTHxay.mjs → perf-CIMijND6.mjs} +5 -5
- package/dist/{plugin-CXRoMA8g.mjs → plugin-CL8_wL7a.mjs} +519 -112
- package/dist/{poster-CYmCa00B.mjs → poster-B7uSjlEP.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-C_2ZtHou.mjs → publish-bakes-BjgDNeyS.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-XD8iXJOj.mjs → recover-ByuFQOF9.mjs} +2 -2
- package/dist/{serve-DQv3Ti6X.mjs → serve-kcF6-H8V.mjs} +4 -4
- package/dist/{session-VDJfXEEm.mjs → session-DBF-nQvq.mjs} +29 -3
- package/dist/{share-Bu_kuOKL.mjs → share-CS2mg27O.mjs} +1 -1
- package/dist/{shot-CRRGgxru.mjs → shot-BqwkdtKn.mjs} +4 -4
- package/dist/{shot-DBWN8hPP.mjs → shot-D2TQGo2V.mjs} +1 -1
- package/dist/show-B1u3DiJw.mjs +101 -0
- package/dist/{sizes-wjXDev3b.mjs → sizes-BckcL4Zz.mjs} +1 -1
- package/dist/{slots-Dn4Onb0V.mjs → slots-BOcfIqxy.mjs} +15 -3
- package/dist/{summary-Y8MY1Wuc.mjs → summary-cPmRDGpX.mjs} +1 -1
- package/dist/{sync-CMozOwZ0.mjs → sync-BNWwh8OF.mjs} +205 -7
- package/dist/{work-BYWD_1Zf.mjs → work-DRdzXPvg.mjs} +3 -3
- package/dist/{work-DJxH7cCX.mjs → work-Nv-n2_Un.mjs} +1 -1
- package/docs/app.md +49 -0
- package/docs/boards-and-folders.md +37 -6
- package/docs/jam-session.md +5 -0
- package/docs/live-jam.md +9 -0
- package/docs/pdf.md +108 -0
- package/docs/performance.md +2 -1
- package/docs/publish.md +9 -9
- package/docs/sharing.md +11 -0
- package/docs/slides.md +9 -0
- package/package.json +3 -1
- package/src/client/content/index.tsx +4 -2
- package/src/client/frame-host/main.tsx +3 -0
- package/src/client/shell/App.tsx +71 -24
- package/src/client/shell/BoardList.tsx +16 -7
- package/src/client/shell/Comments.tsx +77 -16
- package/src/client/shell/Play.tsx +24 -22
- package/src/client/shell/Toolbar.tsx +4 -3
- package/src/client/shell/app-bridge.ts +32 -5
- package/src/client/shell/canvas/Canvas.tsx +30 -8
- package/src/client/shell/canvas/FrameNode.tsx +3 -1
- package/src/client/shell/canvas/ctl.ts +16 -0
- package/src/client/shell/commands.ts +20 -0
- package/src/client/shell/comments-store.ts +81 -2
- package/src/client/shell/devices.tsx +42 -0
- package/src/client/shell/goto.ts +56 -9
- package/src/client/shell/icons.tsx +11 -4
- package/src/client/shell/jam-lines.ts +5 -3
- package/src/client/shell/jam-panel.tsx +17 -5
- package/src/client/shell/marks-ui.tsx +54 -0
- package/src/client/shell/notes.ts +21 -0
- package/src/client/shell/pdf-export.tsx +154 -0
- package/src/client/shell/pdf-notes.ts +20 -0
- package/src/client/shell/recorder.ts +3 -2
- package/src/client/shell/show.ts +250 -0
- package/src/client/shell/store.ts +79 -48
- package/src/client/shell/styles.css +43 -0
- package/src/shared/app-api.ts +49 -4
- package/src/shared/auto-place.ts +32 -0
- package/src/shared/board-tree.ts +3 -0
- package/src/shared/board-types.ts +6 -2
- package/src/shared/deep-link.ts +212 -0
- package/src/shared/devices.ts +89 -0
- package/src/shared/events.ts +48 -5
- package/src/shared/export-plan.ts +98 -0
- package/templates/AGENTS-embedded.md +76 -12
- package/templates/AGENTS-studio.md +76 -12
- package/templates/instructions/boards.md +6 -5
- package/templates/instructions/configure.md +32 -2
- package/templates/instructions/iterate.md +8 -0
- package/templates/instructions/jam.md +9 -0
- package/templates/instructions/publish.md +14 -4
- package/templates/instructions/review.md +4 -0
- package/templates/instructions/slides.md +67 -1
- package/templates/instructions/welcome.md +9 -5
- package/templates/playbooks/publish-canvas/PLAYBOOK.md +1 -1
- package/dist/config-BezZTiov.mjs +0 -182
|
@@ -2,51 +2,9 @@ import { a as ROUTE } from "./cli.mjs";
|
|
|
2
2
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readSync, realpathSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, resolve, sep } from "node:path";
|
|
4
4
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
5
|
-
//#region src/
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
* local canvas (`x-mv-nonce`) and checks the answer before the document commits; only the canvas
|
|
9
|
-
* holding the slot file's key can sign it, so the privileges the app grants belong to that exact
|
|
10
|
-
* document. The proof rides the very response the app commits - the check and the load can never
|
|
11
|
-
* reach different listeners.
|
|
12
|
-
*
|
|
13
|
-
* Pinned exactly, so the app (A2.3 `proof.ts`) computes the same: the key is the slot file's 32 bytes
|
|
14
|
-
* (base64url there), HMAC-SHA256 over UTF-8 `doc|<nonce>|<port>` (port in decimal), base64url without
|
|
15
|
-
* padding. Requests from the app itself carry `app|<port>` the same way, and the logo the app fetches
|
|
16
|
-
* (`GET /__mv/logo`, spec 28 A2.4) `logo|<nonce>|<port>`: a listener that took the port after the tab was
|
|
17
|
-
* verified can never hand it a logo. The live stream (`GET /__mv/app/live`, A4.6 #6) is proved both ways: the
|
|
18
|
-
* request carries `x-mv-app` (`appProof`, checked by `appProofOk`), the answer `live|<nonce>|<port>` - a
|
|
19
|
-
* listener that took the port after a canvas stopped can never put words into a notice.
|
|
20
|
-
*/
|
|
21
|
-
/** 16-64 base64url characters - anything else is not a nonce, and is ignored. */
|
|
22
|
-
const NONCE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
23
|
-
const sign$1 = (key, msg) => createHmac("sha256", key).update(msg, "utf8").digest("base64url");
|
|
24
|
-
const docProof = (key, nonce, port) => sign$1(key, `doc|${nonce}|${port}`);
|
|
25
|
-
const appProof = (key, port) => sign$1(key, `app|${port}`);
|
|
26
|
-
const logoProof = (key, nonce, port) => sign$1(key, `logo|${nonce}|${port}`);
|
|
27
|
-
const liveProof = (key, nonce, port) => sign$1(key, `live|${nonce}|${port}`);
|
|
28
|
-
const PROOFS = {
|
|
29
|
-
doc: docProof,
|
|
30
|
-
logo: logoProof,
|
|
31
|
-
live: liveProof
|
|
32
|
-
};
|
|
33
|
-
/** The two headers for a request carrying a well-formed `x-mv-nonce`, else null: over the shell's document
|
|
34
|
-
* (`doc`), the logo (`logo`) or the live stream (`live`). */
|
|
35
|
-
function proofHeaders(p, nonce, kind = "doc") {
|
|
36
|
-
if (!p || typeof nonce !== "string" || !NONCE.test(nonce)) return null;
|
|
37
|
-
return {
|
|
38
|
-
"x-mv-instance": p.instance,
|
|
39
|
-
"x-mv-proof": PROOFS[kind](p.key, nonce, p.port)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/** Is this `x-mv-app` header the app's own, `appProof(key, port)`? Compared in constant time over equal lengths;
|
|
43
|
-
* anything but one string is no. The HMAC is never relaxed: no cookie, no token stands in for it (A4.6 #6). */
|
|
44
|
-
function appProofOk(p, header) {
|
|
45
|
-
if (typeof header !== "string") return false;
|
|
46
|
-
const got = Buffer.from(header);
|
|
47
|
-
const want = Buffer.from(appProof(p.key, p.port));
|
|
48
|
-
return got.length === want.length && timingSafeEqual(got, want);
|
|
49
|
-
}
|
|
5
|
+
//#region src/shared/logo-sniff.ts
|
|
6
|
+
/** The most a logo may weigh, on either side: a file past it is never read whole, a fetch past it is aborted. */
|
|
7
|
+
const LOGO_MAX = 262144;
|
|
50
8
|
/** The type each sniffed logo is served with. */
|
|
51
9
|
const LOGO_MIME = {
|
|
52
10
|
png: "image/png",
|
|
@@ -130,6 +88,52 @@ function doctypeEnd(s, i) {
|
|
|
130
88
|
return -1;
|
|
131
89
|
}
|
|
132
90
|
//#endregion
|
|
91
|
+
//#region src/server/proof.ts
|
|
92
|
+
/**
|
|
93
|
+
* The document proof (spec 28 A1.4). The Mac app puts a fresh nonce on every main-frame request to a
|
|
94
|
+
* local canvas (`x-mv-nonce`) and checks the answer before the document commits; only the canvas
|
|
95
|
+
* holding the slot file's key can sign it, so the privileges the app grants belong to that exact
|
|
96
|
+
* document. The proof rides the very response the app commits - the check and the load can never
|
|
97
|
+
* reach different listeners.
|
|
98
|
+
*
|
|
99
|
+
* Pinned exactly, so the app (A2.3 `proof.ts`) computes the same: the key is the slot file's 32 bytes
|
|
100
|
+
* (base64url there), HMAC-SHA256 over UTF-8 `doc|<nonce>|<port>` (port in decimal), base64url without
|
|
101
|
+
* padding. Requests from the app itself carry `app|<port>` the same way, and the logo the app fetches
|
|
102
|
+
* (`GET /__mv/logo`, spec 28 A2.4) `logo|<nonce>|<port>`: a listener that took the port after the tab was
|
|
103
|
+
* verified can never hand it a logo. The live stream (`GET /__mv/app/live`, A4.6 #6) is proved both ways: the
|
|
104
|
+
* request carries `x-mv-app` (`appProof`, checked by `appProofOk`), the answer `live|<nonce>|<port>` - a
|
|
105
|
+
* listener that took the port after a canvas stopped can never put words into a notice.
|
|
106
|
+
*/
|
|
107
|
+
/** 16-64 base64url characters - anything else is not a nonce, and is ignored. */
|
|
108
|
+
const NONCE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
109
|
+
const sign$1 = (key, msg) => createHmac("sha256", key).update(msg, "utf8").digest("base64url");
|
|
110
|
+
const docProof = (key, nonce, port) => sign$1(key, `doc|${nonce}|${port}`);
|
|
111
|
+
const appProof = (key, port) => sign$1(key, `app|${port}`);
|
|
112
|
+
const logoProof = (key, nonce, port) => sign$1(key, `logo|${nonce}|${port}`);
|
|
113
|
+
const liveProof = (key, nonce, port) => sign$1(key, `live|${nonce}|${port}`);
|
|
114
|
+
const PROOFS = {
|
|
115
|
+
doc: docProof,
|
|
116
|
+
logo: logoProof,
|
|
117
|
+
live: liveProof
|
|
118
|
+
};
|
|
119
|
+
/** The two headers for a request carrying a well-formed `x-mv-nonce`, else null: over the shell's document
|
|
120
|
+
* (`doc`), the logo (`logo`) or the live stream (`live`). */
|
|
121
|
+
function proofHeaders(p, nonce, kind = "doc") {
|
|
122
|
+
if (!p || typeof nonce !== "string" || !NONCE.test(nonce)) return null;
|
|
123
|
+
return {
|
|
124
|
+
"x-mv-instance": p.instance,
|
|
125
|
+
"x-mv-proof": PROOFS[kind](p.key, nonce, p.port)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Is this `x-mv-app` header the app's own, `appProof(key, port)`? Compared in constant time over equal lengths;
|
|
129
|
+
* anything but one string is no. The HMAC is never relaxed: no cookie, no token stands in for it (A4.6 #6). */
|
|
130
|
+
function appProofOk(p, header) {
|
|
131
|
+
if (typeof header !== "string") return false;
|
|
132
|
+
const got = Buffer.from(header);
|
|
133
|
+
const want = Buffer.from(appProof(p.key, p.port));
|
|
134
|
+
return got.length === want.length && timingSafeEqual(got, want);
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
133
137
|
//#region src/server/logo.ts
|
|
134
138
|
const LOGO_LADDER = [
|
|
135
139
|
"design/logo.svg",
|
|
@@ -140,28 +144,52 @@ const LOGO_LADDER = [
|
|
|
140
144
|
"public/favicon.png",
|
|
141
145
|
"public/favicon.ico"
|
|
142
146
|
];
|
|
143
|
-
/** The first candidate that passes every check, read whole; null when none does.
|
|
144
|
-
*
|
|
145
|
-
|
|
147
|
+
/** The first candidate that passes every check, read whole; null when none does. The config's own come first, in
|
|
148
|
+
* the order given (`canvasIdentity`: config `logo`, then `share.logo` - a bare string is a `share.logo`), then the
|
|
149
|
+
* ladder. `warn` hears why one the config names was ignored (the ladder's own entries are tried quietly: most repos
|
|
150
|
+
* have none of them). */
|
|
151
|
+
function findLogo(root, own, warn) {
|
|
146
152
|
let realRoot;
|
|
147
153
|
try {
|
|
148
154
|
realRoot = realpathSync(root);
|
|
149
155
|
} catch {
|
|
150
156
|
return null;
|
|
151
157
|
}
|
|
152
|
-
const
|
|
153
|
-
|
|
158
|
+
const named = (typeof own === "string" || own === void 0 ? [{
|
|
159
|
+
key: "share.logo",
|
|
160
|
+
path: own
|
|
161
|
+
}] : own).filter((o) => typeof o.path === "string" && o.path !== "");
|
|
162
|
+
const keyOf = /* @__PURE__ */ new Map();
|
|
163
|
+
for (const o of named) if (!keyOf.has(o.path)) keyOf.set(o.path, o.key);
|
|
164
|
+
for (const cand of /* @__PURE__ */ new Set([...named.map((o) => o.path), ...LOGO_LADDER])) {
|
|
154
165
|
const r = readLogo(realRoot, resolve(realRoot, cand));
|
|
155
166
|
if (typeof r !== "string") return {
|
|
156
167
|
...r,
|
|
157
168
|
from: cand
|
|
158
169
|
};
|
|
159
|
-
|
|
170
|
+
const key = keyOf.get(cand);
|
|
171
|
+
if (key) warn?.(`${key} ${cand} is ignored: ${r}`);
|
|
160
172
|
}
|
|
161
173
|
return null;
|
|
162
174
|
}
|
|
163
175
|
/** One candidate: its bytes and type, or why it does not count. */
|
|
164
176
|
function readLogo(realRoot, file) {
|
|
177
|
+
const r = readInside(realRoot, file, LOGO_MAX, /\.(svg|png|ico)$/i, "not .svg, .png or .ico", "over 256 KB");
|
|
178
|
+
if (typeof r === "string") return r;
|
|
179
|
+
const type = sniffLogo(r);
|
|
180
|
+
return type ? {
|
|
181
|
+
type,
|
|
182
|
+
bytes: r
|
|
183
|
+
} : "not an image (PNG, ICO or SVG)";
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A file inside the repo, read whole - or why not: a regular file by `lstat` (never a symlink, even one inside the
|
|
187
|
+
* repo), its extension `ext`, at most `max` bytes, its real path inside the repo's real path (a symlinked folder on the
|
|
188
|
+
* way out is caught here), and read as checked: no symlink swapped in since (O_NOFOLLOW), the same file (device and
|
|
189
|
+
* inode), never more than one byte past the limit whatever it grew to meanwhile. The logo's checks (spec 28 A2.9), and
|
|
190
|
+
* a device's own icon's (spec 31 F.1).
|
|
191
|
+
*/
|
|
192
|
+
function readInside(realRoot, file, max, ext, badExt, tooBig) {
|
|
165
193
|
let st;
|
|
166
194
|
try {
|
|
167
195
|
st = lstatSync(file);
|
|
@@ -170,8 +198,8 @@ function readLogo(realRoot, file) {
|
|
|
170
198
|
}
|
|
171
199
|
if (st.isSymbolicLink()) return "a symlink";
|
|
172
200
|
if (!st.isFile()) return "not a file";
|
|
173
|
-
if (
|
|
174
|
-
if (st.size >
|
|
201
|
+
if (!ext.test(file)) return badExt;
|
|
202
|
+
if (st.size > max) return tooBig;
|
|
175
203
|
let real;
|
|
176
204
|
try {
|
|
177
205
|
real = realpathSync(file);
|
|
@@ -188,16 +216,11 @@ function readLogo(realRoot, file) {
|
|
|
188
216
|
try {
|
|
189
217
|
const f = fstatSync(fd);
|
|
190
218
|
if (!f.isFile() || f.ino !== st.ino || f.dev !== st.dev) return "changed while it was read";
|
|
191
|
-
const buf = Buffer.alloc(
|
|
219
|
+
const buf = Buffer.alloc(max + 1);
|
|
192
220
|
let n = 0;
|
|
193
221
|
for (let k = 1; k > 0 && n < buf.length; n += k) k = readSync(fd, buf, n, buf.length - n, null);
|
|
194
|
-
if (n >
|
|
195
|
-
|
|
196
|
-
const type = sniffLogo(bytes);
|
|
197
|
-
return type ? {
|
|
198
|
-
type,
|
|
199
|
-
bytes
|
|
200
|
-
} : "not an image (PNG, ICO or SVG)";
|
|
222
|
+
if (n > max) return tooBig;
|
|
223
|
+
return Buffer.from(buf.subarray(0, n));
|
|
201
224
|
} catch {
|
|
202
225
|
return "unreadable";
|
|
203
226
|
} finally {
|
|
@@ -206,8 +229,8 @@ function readLogo(realRoot, file) {
|
|
|
206
229
|
}
|
|
207
230
|
/** `marver build`: the logo into `<outDir>/__mv/logo.<type>` (an `.ico` as `logo.ico`), by its bytes - never a copy
|
|
208
231
|
* that follows a link. Its published path, or undefined when the repo has none. */
|
|
209
|
-
function publishLogo(root,
|
|
210
|
-
const logo = findLogo(root,
|
|
232
|
+
function publishLogo(root, own, outDir, warn) {
|
|
233
|
+
const logo = findLogo(root, own, warn);
|
|
211
234
|
if (!logo) return void 0;
|
|
212
235
|
const dir = join(outDir, ROUTE.slice(1));
|
|
213
236
|
mkdirSync(dir, { recursive: true });
|
|
@@ -258,7 +281,7 @@ function matches(header, tag) {
|
|
|
258
281
|
* SVG opened as a page is a picture. A request carrying a well-formed `x-mv-nonce` gets the logo proof
|
|
259
282
|
* (`x-mv-instance`, `x-mv-proof` over `logo|<nonce>|<port>`), on a 200 and a 304 alike. 404 when the repo has none.
|
|
260
283
|
*/
|
|
261
|
-
function logoRoute(root,
|
|
284
|
+
function logoRoute(root, own, proof) {
|
|
262
285
|
const warned = /* @__PURE__ */ new Set();
|
|
263
286
|
const warn = (m) => {
|
|
264
287
|
if (warned.has(m)) return;
|
|
@@ -278,7 +301,7 @@ function logoRoute(root, shareLogo, proof) {
|
|
|
278
301
|
res.setHeader("allow", "GET, HEAD");
|
|
279
302
|
return res.end();
|
|
280
303
|
}
|
|
281
|
-
const logo = findLogo(root,
|
|
304
|
+
const logo = findLogo(root, own(), warn);
|
|
282
305
|
if (!logo) {
|
|
283
306
|
res.statusCode = 404;
|
|
284
307
|
res.setHeader("cache-control", "no-store");
|
|
@@ -302,4 +325,4 @@ function logoRoute(root, shareLogo, proof) {
|
|
|
302
325
|
};
|
|
303
326
|
}
|
|
304
327
|
//#endregion
|
|
305
|
-
export {
|
|
328
|
+
export { publishLogo as a, proofHeaders as c, logoRoute as i, logoIconLink as n, readInside as o, logoIcons as r, appProofOk as s, findLogo as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { l as readRunning, n as formatRunning } from "./slots-
|
|
2
|
+
import { l as readRunning, n as formatRunning } from "./slots-BOcfIqxy.mjs";
|
|
3
3
|
//#region src/cli/ls.ts
|
|
4
4
|
/**
|
|
5
5
|
* `marver ls` (spec 28 A1.5): the canvases running on this Mac, read from the registry
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { i as PKG, n as CONTENT_WIDTH } from "./cli.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, a as buildTree, b as DECISIONS, f as isBoardName, g as readTitle, h as readDescription, o as flatten, s as folderEntries } from "./board-tree-
|
|
3
|
+
import { h as readRegistry, l as listBoardFiles, o as checkBoardsDir, r as boardFields, s as checkRealDirs, x as hash } from "./boards-Cim1GTKc.mjs";
|
|
4
|
+
import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, a as buildTree, b as DECISIONS, f as isBoardName, g as readTitle, h as readDescription, o as flatten, s as folderEntries } from "./board-tree-DGj0HhEE.mjs";
|
|
5
5
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { join, relative, sep } from "node:path";
|
|
7
7
|
import { randomBytes } from "node:crypto";
|
|
@@ -789,6 +789,7 @@ var manifest_exports = /* @__PURE__ */ __exportAll({
|
|
|
789
789
|
statusBoards: () => statusBoards,
|
|
790
790
|
tagPattern: () => tagPattern,
|
|
791
791
|
toFrameId: () => toFrameId,
|
|
792
|
+
unescapeJs: () => unescapeJs,
|
|
792
793
|
writeManifest: () => writeManifest
|
|
793
794
|
});
|
|
794
795
|
const FRAME_EXT = /\.(tsx|jsx|html)$/;
|
|
@@ -810,19 +811,230 @@ function readNote(abs) {
|
|
|
810
811
|
return;
|
|
811
812
|
}
|
|
812
813
|
}
|
|
813
|
-
/**
|
|
814
|
-
|
|
814
|
+
/** A JS string literal's escapes, read: a backslash before a quote, a backtick or a backslash; \n \t \r; \xHH,
|
|
815
|
+
* \uHHHH, \u{H...}; any other escaped character is itself (\$ is $). */
|
|
816
|
+
function unescapeJs(s) {
|
|
817
|
+
return s.replace(/\\(u\{([0-9a-fA-F]{1,6})\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|[\s\S])/g, (_m, e, cp, u, x) => {
|
|
818
|
+
const hex = cp ?? u ?? x;
|
|
819
|
+
if (hex) {
|
|
820
|
+
const n = parseInt(hex, 16);
|
|
821
|
+
return n <= 1114111 ? String.fromCodePoint(n) : "";
|
|
822
|
+
}
|
|
823
|
+
return e === "n" ? "\n" : e === "t" ? " " : e === "r" ? "\r" : e === "b" ? "\b" : e === "f" ? "\f" : e === "v" ? "\v" : e === "0" ? "\0" : e === "\n" ? "" : e;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/** Can a `/` here start a regex literal? After a value it divides: a literal, a name (a keyword after `.` is a
|
|
827
|
+
* property's name: `values.in / 2`), `]`, `}`, a postfix `++`/`--` (`count++ / 2`), a `)` - unless that `)` closes
|
|
828
|
+
* an `if`/`while`/`for`/`with` condition (`if (ready) /'/.test(t)`). After an operator or a keyword it starts one. */
|
|
829
|
+
const REGEX_AFTER_WORD = /* @__PURE__ */ new Set([
|
|
830
|
+
"return",
|
|
831
|
+
"typeof",
|
|
832
|
+
"instanceof",
|
|
833
|
+
"in",
|
|
834
|
+
"of",
|
|
835
|
+
"new",
|
|
836
|
+
"delete",
|
|
837
|
+
"void",
|
|
838
|
+
"throw",
|
|
839
|
+
"case",
|
|
840
|
+
"do",
|
|
841
|
+
"else",
|
|
842
|
+
"yield",
|
|
843
|
+
"await"
|
|
844
|
+
]);
|
|
845
|
+
const CONTROL = /* @__PURE__ */ new Set([
|
|
846
|
+
"if",
|
|
847
|
+
"while",
|
|
848
|
+
"for",
|
|
849
|
+
"with"
|
|
850
|
+
]);
|
|
851
|
+
const regexCan = (prev) => !prev || prev.k === "punct" && (prev.v === ")" ? !!prev.ctrl : ![
|
|
852
|
+
"]",
|
|
853
|
+
"}",
|
|
854
|
+
"++",
|
|
855
|
+
"--"
|
|
856
|
+
].includes(prev.v)) || prev.k === "word" && !prev.prop && REGEX_AFTER_WORD.has(prev.v);
|
|
857
|
+
/**
|
|
858
|
+
* The JS tokens from `i` to the `}` that closes an already-open `{` (spec 31 H.1, review rounds 1-3): strings, template
|
|
859
|
+
* literals (their `${...}` holes tokenized as code of their own), regex literals and comments are read whole, so a
|
|
860
|
+
* brace, a quote or a slash inside one is text. `emit` hears each token at this object's own level (depth 0) and the
|
|
861
|
+
* `}` that ends it; the index of that `}`, or -1 when the code never closes or a literal is unterminated.
|
|
862
|
+
*/
|
|
863
|
+
function tokens(src, i, emit) {
|
|
864
|
+
let depth = 0;
|
|
865
|
+
let prev;
|
|
866
|
+
/** each open `(`: whether it opens a control statement's condition */
|
|
867
|
+
const parens = [];
|
|
868
|
+
const out = (t) => {
|
|
869
|
+
prev = t;
|
|
870
|
+
if (emit) emit(t, depth);
|
|
871
|
+
};
|
|
872
|
+
while (i < src.length) {
|
|
873
|
+
const ch = src[i];
|
|
874
|
+
if (/\s/.test(ch)) {
|
|
875
|
+
i++;
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
if (ch === "/" && src[i + 1] === "/") {
|
|
879
|
+
const nl = src.indexOf("\n", i);
|
|
880
|
+
i = nl < 0 ? src.length : nl;
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
if (ch === "/" && src[i + 1] === "*") {
|
|
884
|
+
const e = src.indexOf("*/", i + 2);
|
|
885
|
+
if (e < 0) return -1;
|
|
886
|
+
i = e + 2;
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
if (ch === "'" || ch === "\"") {
|
|
890
|
+
let j = i + 1;
|
|
891
|
+
for (; j < src.length && src[j] !== ch; j++) {
|
|
892
|
+
if (src[j] === "\n") return -1;
|
|
893
|
+
if (src[j] === "\\") j++;
|
|
894
|
+
}
|
|
895
|
+
if (j >= src.length) return -1;
|
|
896
|
+
out({
|
|
897
|
+
k: "str",
|
|
898
|
+
raw: src.slice(i + 1, j)
|
|
899
|
+
});
|
|
900
|
+
i = j + 1;
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
if (ch === "`") {
|
|
904
|
+
let j = i + 1, holes = false;
|
|
905
|
+
for (; j < src.length && src[j] !== "`"; j++) if (src[j] === "\\") j++;
|
|
906
|
+
else if (src[j] === "$" && src[j + 1] === "{") {
|
|
907
|
+
holes = true;
|
|
908
|
+
j = tokens(src, j + 2);
|
|
909
|
+
if (j < 0) return -1;
|
|
910
|
+
}
|
|
911
|
+
if (j >= src.length) return -1;
|
|
912
|
+
out({
|
|
913
|
+
k: "tpl",
|
|
914
|
+
raw: src.slice(i + 1, j),
|
|
915
|
+
holes
|
|
916
|
+
});
|
|
917
|
+
i = j + 1;
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
if (ch === "/" && regexCan(prev)) {
|
|
921
|
+
let j = i + 1, cls = false;
|
|
922
|
+
for (; j < src.length; j++) {
|
|
923
|
+
const c = src[j];
|
|
924
|
+
if (c === "\n") return -1;
|
|
925
|
+
if (c === "\\") {
|
|
926
|
+
j++;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (cls) {
|
|
930
|
+
if (c === "]") cls = false;
|
|
931
|
+
} else if (c === "[") cls = true;
|
|
932
|
+
else if (c === "/") break;
|
|
933
|
+
}
|
|
934
|
+
if (j >= src.length) return -1;
|
|
935
|
+
j++;
|
|
936
|
+
while (j < src.length && /[A-Za-z]/.test(src[j])) j++;
|
|
937
|
+
out({ k: "re" });
|
|
938
|
+
i = j;
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
const w = /^(?:[\p{ID_Start}_$][\p{ID_Continue}$\u200c\u200d]*|\d[\w.]*)/u.exec(src.slice(i, i + 256));
|
|
942
|
+
if (w) {
|
|
943
|
+
out({
|
|
944
|
+
k: "word",
|
|
945
|
+
v: w[0],
|
|
946
|
+
prop: prev?.k === "punct" && (prev.v === "." || prev.v === "?.")
|
|
947
|
+
});
|
|
948
|
+
i += w[0].length;
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (ch === "}" && depth === 0) {
|
|
952
|
+
if (emit) emit({
|
|
953
|
+
k: "punct",
|
|
954
|
+
v: "}"
|
|
955
|
+
}, 0);
|
|
956
|
+
return i;
|
|
957
|
+
}
|
|
958
|
+
if (ch === "(") {
|
|
959
|
+
parens.push(prev?.k === "word" && !prev.prop && CONTROL.has(prev.v));
|
|
960
|
+
out({
|
|
961
|
+
k: "punct",
|
|
962
|
+
v: ch
|
|
963
|
+
});
|
|
964
|
+
depth++;
|
|
965
|
+
i++;
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (ch === "{" || ch === "[") {
|
|
969
|
+
out({
|
|
970
|
+
k: "punct",
|
|
971
|
+
v: ch
|
|
972
|
+
});
|
|
973
|
+
depth++;
|
|
974
|
+
i++;
|
|
975
|
+
continue;
|
|
976
|
+
}
|
|
977
|
+
if (ch === ")") {
|
|
978
|
+
depth--;
|
|
979
|
+
out({
|
|
980
|
+
k: "punct",
|
|
981
|
+
v: ch,
|
|
982
|
+
ctrl: parens.pop() === true
|
|
983
|
+
});
|
|
984
|
+
i++;
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
if (ch === "}" || ch === "]") {
|
|
988
|
+
depth--;
|
|
989
|
+
out({
|
|
990
|
+
k: "punct",
|
|
991
|
+
v: ch
|
|
992
|
+
});
|
|
993
|
+
i++;
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
const op = /^(?:\+\+|--|\?\.(?!\d)|=>|\.\.\.)/.exec(src.slice(i, i + 3));
|
|
997
|
+
if (op) {
|
|
998
|
+
out({
|
|
999
|
+
k: "punct",
|
|
1000
|
+
v: op[0]
|
|
1001
|
+
});
|
|
1002
|
+
i += op[0].length;
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
out({
|
|
1006
|
+
k: "punct",
|
|
1007
|
+
v: ch
|
|
1008
|
+
});
|
|
1009
|
+
i++;
|
|
1010
|
+
}
|
|
1011
|
+
return -1;
|
|
1012
|
+
}
|
|
1013
|
+
/** The lenient reading, for a meta the tokenizer cannot follow: r31's - the body to its first `}`, each key's literal
|
|
1014
|
+
* found where a property starts - with its quotes read escape-aware (spec 31 H.1). Never worse than r31 was. */
|
|
1015
|
+
function lenientMeta(src) {
|
|
815
1016
|
const m = /export\s+const\s+meta\s*=\s*\{([\s\S]*?)\}/.exec(src);
|
|
816
1017
|
if (!m) return {};
|
|
817
1018
|
const body = m[1];
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
1019
|
+
const strings = /* @__PURE__ */ new Map();
|
|
1020
|
+
for (const key of [
|
|
1021
|
+
"title",
|
|
1022
|
+
"viewport",
|
|
1023
|
+
"theme",
|
|
1024
|
+
"of",
|
|
1025
|
+
"variant",
|
|
1026
|
+
"intent",
|
|
1027
|
+
"description"
|
|
1028
|
+
]) {
|
|
1029
|
+
const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(?:'((?:[^'\\\\\\n]|\\\\.)*)'|"((?:[^"\\\\\\n]|\\\\.)*)"|\`((?:[^\`\\\\\\n]|\\\\.)*)\`)\\s*(?=[,}\\n]|$)`).exec(body);
|
|
1030
|
+
if (r && !(r[3] !== void 0 && /(^|[^\\])(\\\\)*\$\{/.test(r[3]))) strings.set(key, unescapeJs(r[1] ?? r[2] ?? r[3]));
|
|
1031
|
+
}
|
|
1032
|
+
const b = /(?:^|[{,])\s*slide\s*:\s*(true|false)\b/.exec(body);
|
|
1033
|
+
return metaOf(strings, new Map(b ? [["slide", b[1] === "true"]] : []));
|
|
1034
|
+
}
|
|
1035
|
+
/** The meta from its literal properties. */
|
|
1036
|
+
function metaOf(strings, bools) {
|
|
1037
|
+
const pick = (key) => strings.get(key);
|
|
826
1038
|
const out = {};
|
|
827
1039
|
const title = pick("title");
|
|
828
1040
|
if (title) out.title = title;
|
|
@@ -836,12 +1048,42 @@ function extractMeta(src) {
|
|
|
836
1048
|
if (variant) out.variant = variant;
|
|
837
1049
|
const intent = pick("intent");
|
|
838
1050
|
if (intent) out.intent = intent;
|
|
839
|
-
const slide =
|
|
1051
|
+
const slide = bools.get("slide");
|
|
840
1052
|
if (slide !== void 0) out.slide = slide;
|
|
841
1053
|
const description = readDescription(pick("description"));
|
|
842
1054
|
if (description) out.description = description;
|
|
843
1055
|
return out;
|
|
844
1056
|
}
|
|
1057
|
+
/** Extract `export const meta = {...}` with literal string values only. Anything else is silently omitted.
|
|
1058
|
+
* Only the object's own top-level properties count, each value a lone literal: `title: "Draft" + phase` is computed,
|
|
1059
|
+
* a template with a `${...}` too, and words inside a string (`"... slide: true ..."`) are only words. */
|
|
1060
|
+
function extractMeta(src) {
|
|
1061
|
+
const m = /export\s+const\s+meta\s*=\s*\{/.exec(src);
|
|
1062
|
+
if (!m) return {};
|
|
1063
|
+
const props = [[]];
|
|
1064
|
+
if (tokens(src, m.index + m[0].length, (t, depth) => {
|
|
1065
|
+
if (depth > 0) {
|
|
1066
|
+
props[props.length - 1].push({
|
|
1067
|
+
k: "punct",
|
|
1068
|
+
v: "nested"
|
|
1069
|
+
});
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (t.k === "punct" && t.v === ",") props.push([]);
|
|
1073
|
+
else if (!(t.k === "punct" && t.v === "}")) props[props.length - 1].push(t);
|
|
1074
|
+
}) < 0) return lenientMeta(src);
|
|
1075
|
+
const strings = /* @__PURE__ */ new Map();
|
|
1076
|
+
const bools = /* @__PURE__ */ new Map();
|
|
1077
|
+
for (const p of props) {
|
|
1078
|
+
if (p.length !== 3 || p[1].k !== "punct" || p[1].v !== ":") continue;
|
|
1079
|
+
const [k, , v] = p;
|
|
1080
|
+
const key = k.k === "word" ? k.v : k.k === "str" ? unescapeJs(k.raw) : null;
|
|
1081
|
+
if (key === null) continue;
|
|
1082
|
+
if (v.k === "str" || v.k === "tpl" && !v.holes) strings.set(key, unescapeJs(v.raw));
|
|
1083
|
+
else if (v.k === "word" && (v.v === "true" || v.v === "false")) bools.set(key, v.v === "true");
|
|
1084
|
+
}
|
|
1085
|
+
return metaOf(strings, bools);
|
|
1086
|
+
}
|
|
845
1087
|
/** Content-frame detection: LEXICAL by convention - the frame file itself imports
|
|
846
1088
|
* PKG/content (an import specifier scan, so "<Diagram" inside a string in a UI frame can
|
|
847
1089
|
* never misbadge it; barrels/re-exports are not detected - meta.intent is the taught path
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { l as framesOn } from "./board-tree-
|
|
4
|
-
import { a as noteFileFor } from "./manifest-
|
|
2
|
+
import { l as listBoardFiles, o as checkBoardsDir, s as checkRealDirs, x as hash } from "./boards-Cim1GTKc.mjs";
|
|
3
|
+
import { l as framesOn } from "./board-tree-DGj0HhEE.mjs";
|
|
4
|
+
import { a as noteFileFor } from "./manifest-CK8Qh4Nq.mjs";
|
|
5
5
|
import { t as imports } from "./imports-WBSnnHLb.mjs";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { dirname, join, relative, sep } from "node:path";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { m as readMembership } from "./boards-Cim1GTKc.mjs";
|
|
2
|
+
import { s as scanFrames } from "./manifest-CK8Qh4Nq.mjs";
|
|
3
|
+
import { a as replay, t as asks } from "./events-Dieo1482.mjs";
|
|
3
4
|
import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
|
|
4
|
-
import { l as isNew, s as projectMarks } from "./marks-
|
|
5
|
-
import { answers } from "./queue-
|
|
5
|
+
import { l as isNew, s as projectMarks } from "./marks-C8oX8kbE.mjs";
|
|
6
|
+
import { answers } from "./queue-BLLfdlDw.mjs";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
//#region src/cli/marks.ts
|
|
8
9
|
/**
|
|
@@ -30,6 +31,11 @@ function marksCommand(root, opts) {
|
|
|
30
31
|
}];
|
|
31
32
|
})).sort((a, b) => Number(b.asks) - Number(a.asks));
|
|
32
33
|
const fresh = m ? manifest.frames.map((f) => f.id).filter((id) => isNew(m, id)) : [];
|
|
34
|
+
const openFrames = listBoards(dir).flatMap((b) => replay(readLog(dir, b)).filter((t) => !t.resolved).map((t) => t.frame));
|
|
35
|
+
const perBoard = readMembership(root, manifest.frames.map((f) => f.id)).boards.map((b) => ({
|
|
36
|
+
board: b.name,
|
|
37
|
+
open: openFrames.filter((f) => !!f && b.frames.includes(f)).length
|
|
38
|
+
})).filter((b) => b.open > 0);
|
|
33
39
|
const { answered, earlier } = answers(root);
|
|
34
40
|
const said = (a) => ({
|
|
35
41
|
frame: a.frame,
|
|
@@ -43,7 +49,11 @@ function marksCommand(root, opts) {
|
|
|
43
49
|
waiting,
|
|
44
50
|
answered: answered.map(said),
|
|
45
51
|
earlier: earlier.map(said),
|
|
46
|
-
new: fresh
|
|
52
|
+
new: fresh,
|
|
53
|
+
open: {
|
|
54
|
+
total: openFrames.length,
|
|
55
|
+
boards: perBoard
|
|
56
|
+
}
|
|
47
57
|
}, null, 2));
|
|
48
58
|
return;
|
|
49
59
|
}
|
|
@@ -60,6 +70,9 @@ function marksCommand(root, opts) {
|
|
|
60
70
|
else if (earlier.length) console.log(`${pad("earlier, maybe handled", 21)}${earlier.length} from before 0.26 - \`--all\` lists them`);
|
|
61
71
|
const shown = fresh.slice(0, 6).join(", ") + (fresh.length > 6 ? `, ... (+${fresh.length - 6})` : "");
|
|
62
72
|
console.log(`${pad(fresh.length ? `new (${fresh.length})` : "new", 21)}${fresh.length ? shown : "nothing"}`);
|
|
73
|
+
const per = perBoard.map((b) => `${b.board} ${b.open}`).join(", ");
|
|
74
|
+
console.log(`${pad(`open (${openFrames.length})`, 21)}${openFrames.length ? per || "on no board" : "nothing"}`);
|
|
75
|
+
if (openFrames.length > 10) console.log(`${pad("", 21)}more than 10 open: ask the human whether to resolve them (\`comments resolve --all --board <b> --dry-run\` counts) - never on your own`);
|
|
63
76
|
}
|
|
64
77
|
//#endregion
|
|
65
78
|
export { marksCommand };
|