@marver-design/marver 0.30.1 → 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 +58 -0
- package/README.md +11 -7
- package/dist/{anchor-check-Bv4o-R2T.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-zWGXSzly.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-CChgWJNq.mjs → daemon-MxoEQajX.mjs} +222 -23
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-DOgIITpT.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-CFWBcAba.mjs → plugin-CL8_wL7a.mjs} +460 -83
- package/dist/{poster-DPPpQiva.mjs → poster-B7uSjlEP.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-_Zx8crP3.mjs → publish-bakes-BjgDNeyS.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-mDUVsnPd.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-d4h_hJi9.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/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/show.ts +250 -0
- package/src/client/shell/store.ts +23 -38
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as avatarSourceFor, n as attachAvatar, p as provisionFromMarverId } from "./auth-Dix8wrXV.mjs";
|
|
2
|
+
import { n as logoIconLink } from "./logo-C9s7-Cy9.mjs";
|
|
2
3
|
import { TransactionStore, browserBinding, verifyAssertion } from "./marver-id-CVCoaMGI.mjs";
|
|
3
|
-
import { t as poweredByUrl } from "./serve-
|
|
4
|
+
import { t as poweredByUrl } from "./serve-kcF6-H8V.mjs";
|
|
4
5
|
import { randomBytes } from "node:crypto";
|
|
5
6
|
import { isIP } from "node:net";
|
|
6
7
|
import { lookup } from "node:dns/promises";
|
|
@@ -324,7 +325,7 @@ function safeHash(raw) {
|
|
|
324
325
|
if (!/^#\/[\w\-./~%!$&'()*+,;=:@?[\]]*$/.test(value)) return null;
|
|
325
326
|
return value;
|
|
326
327
|
}
|
|
327
|
-
function marverIdHandler(dir, issuer, canvasName, branding = true, ceilings = {}) {
|
|
328
|
+
function marverIdHandler(dir, issuer, canvasName, branding = true, ceilings = {}, logo) {
|
|
328
329
|
const transactions = new TransactionStore();
|
|
329
330
|
const pinned = (process.env.MARVER_PUBLIC_ORIGIN ?? "").trim().replace(/\/$/, "");
|
|
330
331
|
let publicOrigin;
|
|
@@ -370,7 +371,7 @@ function marverIdHandler(dir, issuer, canvasName, branding = true, ceilings = {}
|
|
|
370
371
|
res.setHeader("referrer-policy", "no-referrer");
|
|
371
372
|
res.setHeader("content-security-policy", "frame-ancestors 'none'");
|
|
372
373
|
res.setHeader("x-frame-options", "DENY");
|
|
373
|
-
res.end(finishPage(canvasName, new URL(origin).host, `${issuer}/switch?origin=${encodeURIComponent(origin)}`, branding));
|
|
374
|
+
res.end(finishPage(canvasName, new URL(origin).host, `${issuer}/switch?origin=${encodeURIComponent(origin)}`, branding, logo));
|
|
374
375
|
return true;
|
|
375
376
|
}
|
|
376
377
|
if (req.method === "POST" && url.pathname === "/__mv/id/callback") {
|
|
@@ -422,7 +423,7 @@ function marverIdHandler(dir, issuer, canvasName, branding = true, ceilings = {}
|
|
|
422
423
|
const { shareState, provisionVerdict } = await import("./auth-Dix8wrXV.mjs").then((n) => n.R);
|
|
423
424
|
const share = shareState(dir);
|
|
424
425
|
if (!(share ? provisionVerdict(share, result.identity.email) === "blocked" : false)) {
|
|
425
|
-
const { signCanvasJws } = await import("./summary-
|
|
426
|
+
const { signCanvasJws } = await import("./summary-cPmRDGpX.mjs");
|
|
426
427
|
const now = Math.floor(Date.now() / 1e3);
|
|
427
428
|
request = signCanvasJws(dir, {
|
|
428
429
|
aud: origin,
|
|
@@ -506,15 +507,17 @@ const esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g,
|
|
|
506
507
|
* still wearing the footer an operator had explicitly turned off. A setting that
|
|
507
508
|
* holds almost everywhere is a setting you cannot rely on.
|
|
508
509
|
*/
|
|
509
|
-
function finishPage(canvasName, host, switchUrl, branding = true) {
|
|
510
|
+
function finishPage(canvasName, host, switchUrl, branding = true, logo) {
|
|
510
511
|
const name = esc(canvasName || "this canvas");
|
|
511
512
|
const where = esc(host);
|
|
513
|
+
const icon = logoIconLink(logo);
|
|
514
|
+
const mark = icon ? `<img src="${esc(logo)}" alt="" width="24" height="24" />` : MARK_LG;
|
|
512
515
|
return `<!doctype html>
|
|
513
516
|
<html lang="en"><head><meta charset="utf-8" />
|
|
514
517
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
515
518
|
<meta name="robots" content="noindex" />
|
|
516
519
|
<title>Signing in - ${name}</title>
|
|
517
|
-
<link rel
|
|
520
|
+
${icon || "<link rel=\"icon\" href=\"/__mv/favicon/favicon.ico\" sizes=\"48x48\" />"}
|
|
518
521
|
<style>
|
|
519
522
|
/* The gate's own tokens. This page is the last thing somebody sees before the
|
|
520
523
|
canvas opens - or the only thing, if they are refused - so it belongs to
|
|
@@ -534,6 +537,7 @@ function finishPage(canvasName, host, switchUrl, branding = true) {
|
|
|
534
537
|
display: flex; flex-direction: column; gap: 14px }
|
|
535
538
|
header { display: flex; align-items: center; gap: 9px }
|
|
536
539
|
header svg { color: #0088ff; flex: none }
|
|
540
|
+
header img { flex: none; border-radius: 6px; object-fit: contain }
|
|
537
541
|
h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em }
|
|
538
542
|
/* Pulled up against the address below it: the state line introduces that
|
|
539
543
|
chip rather than floating between it and the canvas name. */
|
|
@@ -595,7 +599,7 @@ function finishPage(canvasName, host, switchUrl, branding = true) {
|
|
|
595
599
|
<body>
|
|
596
600
|
<div class="wait" id="wait" role="status" aria-label="Signing you in" hidden></div>
|
|
597
601
|
<div class="card" id="card" hidden>
|
|
598
|
-
<header>${
|
|
602
|
+
<header>${mark}<h1 id="t">${name}</h1></header>
|
|
599
603
|
<p class="state" id="s"></p>
|
|
600
604
|
<div class="chip">${where}</div>
|
|
601
605
|
<p class="lead" id="m"></p>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Marked } from "marked";
|
|
2
|
+
//#region src/client/content/md.ts
|
|
3
|
+
/**
|
|
4
|
+
* Markdown rendering for the Md block.
|
|
5
|
+
* Raw HTML is inert (escaped, never parsed). Links and images have SEPARATE
|
|
6
|
+
* policies: links may be goto:/http(s)/mailto (external ones open a new tab,
|
|
7
|
+
* never navigate the iframe); images are local-only - design/assets/ paths.
|
|
8
|
+
*/
|
|
9
|
+
const escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
10
|
+
/** Prose text: markup escaped, but an entity the author wrote (`©`, `A`) keeps its
|
|
11
|
+
* meaning - marked's own rule; a raw `<` is still never a tag. */
|
|
12
|
+
const escapeText = (s) => s.replace(/&(?!#?\w+;)|[<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
13
|
+
const FAMILY_RE = new RegExp(`^:(${Object.keys({
|
|
14
|
+
blue: {
|
|
15
|
+
light: "#0088FF",
|
|
16
|
+
dark: "#3B9DFF"
|
|
17
|
+
},
|
|
18
|
+
orange: {
|
|
19
|
+
light: "#F5820A",
|
|
20
|
+
dark: "#FF9F33"
|
|
21
|
+
},
|
|
22
|
+
purple: {
|
|
23
|
+
light: "#B32BC8",
|
|
24
|
+
dark: "#D34FE8"
|
|
25
|
+
},
|
|
26
|
+
green: {
|
|
27
|
+
light: "#1FA34A",
|
|
28
|
+
dark: "#34C759"
|
|
29
|
+
},
|
|
30
|
+
red: {
|
|
31
|
+
light: "#E5342B",
|
|
32
|
+
dark: "#FF453A"
|
|
33
|
+
},
|
|
34
|
+
gray: {
|
|
35
|
+
light: "#8B95A3",
|
|
36
|
+
dark: "#7D8794"
|
|
37
|
+
}
|
|
38
|
+
}).join("|")})\\[([^\\]\\n]+)\\]`);
|
|
39
|
+
/** Relative design/assets/ path -> served URL; null for anything else (fail closed).
|
|
40
|
+
* Decodes BEFORE validating (a %2e%2e must not sneak past the ".." check) and
|
|
41
|
+
* re-encodes per segment, so the validated path is the path the browser requests. */
|
|
42
|
+
function assetUrl(src) {
|
|
43
|
+
let p = String(src ?? "").trim();
|
|
44
|
+
try {
|
|
45
|
+
p = decodeURIComponent(p);
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (p.includes("%")) return null;
|
|
50
|
+
if (!p || p.includes("://") || p.includes(":") || p.startsWith("/") || p.startsWith("\\") || p.includes("\\")) return null;
|
|
51
|
+
if (p.split("/").some((seg) => seg === ".." || seg === "." || seg === "")) return null;
|
|
52
|
+
return `/design/assets/${p.split("/").map(encodeURIComponent).join("/")}`;
|
|
53
|
+
}
|
|
54
|
+
const marked = new Marked({
|
|
55
|
+
gfm: true,
|
|
56
|
+
renderer: {
|
|
57
|
+
html(token) {
|
|
58
|
+
return escapeHtml(String(token.text ?? "").replace(/<!--(?:-?>|[\s\S]*?(?:-->|$))/g, ""));
|
|
59
|
+
},
|
|
60
|
+
text(token) {
|
|
61
|
+
if (token.tokens) return this.parser.parseInline(token.tokens);
|
|
62
|
+
return escapeText(String(token.text ?? ""));
|
|
63
|
+
},
|
|
64
|
+
link(token) {
|
|
65
|
+
const href = String(token.href ?? "");
|
|
66
|
+
const inner = this.parser.parseInline(token.tokens ?? []);
|
|
67
|
+
if (href.startsWith("goto:")) {
|
|
68
|
+
const target = href.slice(5);
|
|
69
|
+
return `<a href="#" data-goto="${escapeHtml(target)}">${inner}</a>`;
|
|
70
|
+
}
|
|
71
|
+
if (/^https?:\/\//i.test(href) || /^mailto:/i.test(href)) return `<a href="${escapeHtml(href)}" target="_blank" rel="noopener noreferrer">${inner}</a>`;
|
|
72
|
+
return inner;
|
|
73
|
+
},
|
|
74
|
+
image(token) {
|
|
75
|
+
const url = assetUrl(String(token.href ?? ""));
|
|
76
|
+
const alt = escapeHtml(String(token.text ?? ""));
|
|
77
|
+
if (!url) return `<span class="mv-md-noimg">[image unavailable: ${alt || "external images are not allowed"}]</span>`;
|
|
78
|
+
return `<img src="${escapeHtml(url)}" alt="${alt}" loading="lazy" />`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
marked.use({ extensions: [{
|
|
83
|
+
name: "mvcolor",
|
|
84
|
+
level: "inline",
|
|
85
|
+
start(src) {
|
|
86
|
+
return src.match(/:(?:blue|orange|purple|green|red|gray)\[/)?.index;
|
|
87
|
+
},
|
|
88
|
+
tokenizer(src) {
|
|
89
|
+
const m = FAMILY_RE.exec(src);
|
|
90
|
+
if (m) return {
|
|
91
|
+
type: "mvcolor",
|
|
92
|
+
raw: m[0],
|
|
93
|
+
family: m[1],
|
|
94
|
+
tokens: this.lexer.inlineTokens(m[2])
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
renderer(token) {
|
|
98
|
+
return `<span class="mv-c-${token.family}">${this.parser.parseInline(token.tokens)}</span>`;
|
|
99
|
+
}
|
|
100
|
+
}] });
|
|
101
|
+
function renderMarkdown(src) {
|
|
102
|
+
return marked.parse(src, { async: false });
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { renderMarkdown };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
/** The width tidy reserves in front of a node: its own note, and the scene note when this node
|
|
3
|
+
* hosts it - one column, so the wider of the two, never the sum. */
|
|
4
|
+
function noteReserve(frameNote, sceneNote) {
|
|
5
|
+
const w = Math.max(frameNote ? 260 : 0, sceneNote ? 380 : 0);
|
|
6
|
+
return w ? w + 24 : 0;
|
|
7
|
+
}
|
|
8
|
+
/** The node that shows a scene's note: the scene's first node on the board in reading order -
|
|
9
|
+
* smallest y, then x, then original index (the deck rule), missing nodes skipped. Null when the
|
|
10
|
+
* scene has no node here. */
|
|
11
|
+
function sceneNoteHost(nodes, sceneOf, scene) {
|
|
12
|
+
let best = null;
|
|
13
|
+
nodes.forEach((n, i) => {
|
|
14
|
+
if (n.missing || sceneOf(n.frame) !== scene) return;
|
|
15
|
+
if (!best || n.y < best.y || n.y === best.y && (n.x < best.x || n.x === best.x && i < best.i)) best = {
|
|
16
|
+
key: n.key,
|
|
17
|
+
x: n.x,
|
|
18
|
+
y: n.y,
|
|
19
|
+
i
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return best ? best.key : null;
|
|
23
|
+
}
|
|
24
|
+
/** The measured extent of a node's note column: world px from the node's top to the bottom of
|
|
25
|
+
* its last sticky (0 = no column, or not rendered yet). A note's height is its content's, known
|
|
26
|
+
* only once it is drawn - so, like a content frame's height, it is measured, transient (never
|
|
27
|
+
* serialized, a reload remeasures), and fed back to the layout when it lands. */
|
|
28
|
+
const noteHeights = /* @__PURE__ */ new Map();
|
|
29
|
+
const noteHeight = (key) => noteHeights.get(key) ?? 0;
|
|
30
|
+
/** True when a note has no room: another node stands inside the space in front of a noted node
|
|
31
|
+
* (its own note, or the scene's note it hosts) - beside its card, or below it where a note taller
|
|
32
|
+
* than its frame runs on. Room is the layout's job, never the author's - a board the shell
|
|
33
|
+
* composes re-applies its layout when this is true, so a note file can land on a saved board and
|
|
34
|
+
* the frames make way. An obstacle is another node's card, or its own note column (two columns
|
|
35
|
+
* running into each other cramp too) - the two rectangles, never their bounding box: the empty
|
|
36
|
+
* canvas under a card beside a long column is free. Missing nodes (a deleted frame's card, still
|
|
37
|
+
* drawn full size) block room but never host a note. `noteH` is the measured column extent. */
|
|
38
|
+
function notesCramped(nodes, manifest, noteH = noteHeight) {
|
|
39
|
+
if (!manifest) return false;
|
|
40
|
+
const entry = (id) => manifest.frames.find((f) => f.id === id);
|
|
41
|
+
const live = nodes.filter((n) => !n.missing);
|
|
42
|
+
const hosts = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const s of manifest.scenes) {
|
|
44
|
+
if (!s.note) continue;
|
|
45
|
+
const h = sceneNoteHost(live, (id) => entry(id)?.scene, s.name);
|
|
46
|
+
if (h) hosts.add(h);
|
|
47
|
+
}
|
|
48
|
+
const hit = (a, b) => a.x0 < b.x1 && a.x1 > b.x0 && a.y0 < b.y1 && a.y1 > b.y0;
|
|
49
|
+
const card = (n) => ({
|
|
50
|
+
x0: n.x,
|
|
51
|
+
x1: n.x + n.w,
|
|
52
|
+
y0: n.y,
|
|
53
|
+
y1: n.y + n.h + 28
|
|
54
|
+
});
|
|
55
|
+
const room = (n) => {
|
|
56
|
+
const r = n.missing ? 0 : noteReserve(!!entry(n.frame)?.note, hosts.has(n.key));
|
|
57
|
+
return r ? {
|
|
58
|
+
x0: n.x - r,
|
|
59
|
+
x1: n.x,
|
|
60
|
+
y0: n.y,
|
|
61
|
+
y1: n.y + Math.max(n.h + 28, noteH(n.key))
|
|
62
|
+
} : null;
|
|
63
|
+
};
|
|
64
|
+
return live.some((n) => {
|
|
65
|
+
const mine = room(n);
|
|
66
|
+
if (!mine) return false;
|
|
67
|
+
return nodes.some((o) => {
|
|
68
|
+
if (o === n) return false;
|
|
69
|
+
const theirs = room(o);
|
|
70
|
+
return hit(mine, card(o)) || !!theirs && hit(mine, theirs);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** What tidy sees of a board's nodes (spec 18): each with its scene, variant run, header-inclusive height, the note
|
|
75
|
+
* width to reserve in front (the frame's note, and the scene's on every member - tidy keeps the scene reserve on the
|
|
76
|
+
* first node it places) and its column's measured height. One rule for the canvas (store.ts tidyInput) and the deck
|
|
77
|
+
* PDF's plan (pdf.ts), which lays a board out as the canvas does when it opens it. */
|
|
78
|
+
function tidyNodes(nodes, manifest, noteH = noteHeight) {
|
|
79
|
+
const entryOf = (id) => manifest?.frames.find((f) => f.id === id);
|
|
80
|
+
const sceneNote = (scene) => !!manifest?.scenes.find((s) => s.name === scene)?.note;
|
|
81
|
+
return nodes.map((n) => {
|
|
82
|
+
const f = entryOf(n.frame);
|
|
83
|
+
const scene = f?.scene ?? "";
|
|
84
|
+
return {
|
|
85
|
+
key: n.key,
|
|
86
|
+
frame: n.frame,
|
|
87
|
+
scene,
|
|
88
|
+
group: f?.variantGroup,
|
|
89
|
+
variant: f?.variant,
|
|
90
|
+
w: n.w,
|
|
91
|
+
h: n.h + 28,
|
|
92
|
+
noteW: noteReserve(!!f?.note, false),
|
|
93
|
+
sceneNoteW: noteReserve(false, sceneNote(scene)),
|
|
94
|
+
noteH: noteH(n.key)
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** The viewer's choice is kept per canvas (spec 28 A1.6): the shell names the key at boot (store.ts),
|
|
99
|
+
* so this module stays importable without the plugin's virtual modules (test/notes.test.ts). */
|
|
100
|
+
let STORAGE = "mv-notes";
|
|
101
|
+
const load = () => {
|
|
102
|
+
try {
|
|
103
|
+
const raw = JSON.parse(localStorage.getItem(STORAGE) ?? "null");
|
|
104
|
+
if (raw && typeof raw === "object") return {
|
|
105
|
+
all: raw.all !== false,
|
|
106
|
+
hidden: Array.isArray(raw.hidden) ? raw.hidden.filter((x) => typeof x === "string") : []
|
|
107
|
+
};
|
|
108
|
+
} catch {}
|
|
109
|
+
return {
|
|
110
|
+
all: true,
|
|
111
|
+
hidden: []
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const save = (s) => {
|
|
115
|
+
try {
|
|
116
|
+
localStorage.setItem(STORAGE, JSON.stringify(s));
|
|
117
|
+
} catch {}
|
|
118
|
+
};
|
|
119
|
+
create((set, get) => ({
|
|
120
|
+
...load(),
|
|
121
|
+
toggle(ids) {
|
|
122
|
+
const { all, hidden } = get();
|
|
123
|
+
const next = !all || ids.some((id) => hidden.includes(id)) ? {
|
|
124
|
+
all: true,
|
|
125
|
+
hidden: all ? hidden.filter((id) => !ids.includes(id)) : [...new Set([...allIds(), ...hidden].filter((id) => !ids.includes(id)))]
|
|
126
|
+
} : {
|
|
127
|
+
all,
|
|
128
|
+
hidden: [.../* @__PURE__ */ new Set([...hidden, ...ids])]
|
|
129
|
+
};
|
|
130
|
+
set(next);
|
|
131
|
+
save(next);
|
|
132
|
+
},
|
|
133
|
+
toggleAll(anyVisible) {
|
|
134
|
+
const next = anyVisible ? {
|
|
135
|
+
all: false,
|
|
136
|
+
hidden: get().hidden
|
|
137
|
+
} : {
|
|
138
|
+
all: true,
|
|
139
|
+
hidden: []
|
|
140
|
+
};
|
|
141
|
+
set(next);
|
|
142
|
+
save(next);
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
/** Every note id currently on the canvas - read from the DOM, the one place that knows. */
|
|
146
|
+
const allIds = () => typeof document === "undefined" ? [] : [...document.querySelectorAll("[data-note]")].map((el) => el.getAttribute("data-note"));
|
|
147
|
+
//#endregion
|
|
148
|
+
export { notesCramped, tidyNodes };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
|
|
2
|
+
import { n as localProfile } from "./profile-cdmSer1k.mjs";
|
|
3
|
+
import { r as owned } from "./ledger-D54iROST.mjs";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
//#region src/server/own.ts
|
|
8
|
+
/**
|
|
9
|
+
* Who owns a message on this machine (spec 31 C.2) - the local provenance that decides who may edit or delete
|
|
10
|
+
* one in `marver dev`. Kept OUTSIDE the shared log, in `design/.local/own.json` (gitignored, watch-ignored,
|
|
11
|
+
* never synced), so no new field ever reaches a published server: there the original message's author email
|
|
12
|
+
* decides, as it always has (collab.ts validateEvents).
|
|
13
|
+
*
|
|
14
|
+
* The dev server records the comment id of every create and reply it writes for the local human - the page's
|
|
15
|
+
* gated POST (api.ts), and the Jam steps that write the owner's own words (a capture's comment, a More work
|
|
16
|
+
* reply). Never an agent's message, never one that arrived by sync.
|
|
17
|
+
*
|
|
18
|
+
* Migration, once, on the first 0.31 start: every create or reply the Jam ledger records as written here by the
|
|
19
|
+
* owner (jam/ledger.ts - local provenance older than any connect or profile change), plus every create or reply
|
|
20
|
+
* with no agent provenance whose author email is the local profile's - or, with no profile email, whose author has
|
|
21
|
+
* none. From then on the file decides, so connecting an account or changing the profile never moves ownership.
|
|
22
|
+
*
|
|
23
|
+
* Shape: `{ "v": 1, "migrated": true, "boards": { "<board>": ["<comment id>", ...] } }`, written atomically.
|
|
24
|
+
*/
|
|
25
|
+
const fileOf = (root) => join(root, "design", ".local", "own.json");
|
|
26
|
+
const commentsOf = (root) => join(root, "design", "comments");
|
|
27
|
+
/** One parsed copy per root, keyed by the file's mtime and size - a check per edit costs a stat. */
|
|
28
|
+
const cache = /* @__PURE__ */ new Map();
|
|
29
|
+
function read(root) {
|
|
30
|
+
const f = fileOf(root);
|
|
31
|
+
if (!existsSync(f)) return null;
|
|
32
|
+
try {
|
|
33
|
+
const v = JSON.parse(readFileSync(f, "utf8"));
|
|
34
|
+
if (!v || typeof v !== "object" || Array.isArray(v) || typeof v.boards !== "object" || !v.boards || Array.isArray(v.boards)) return null;
|
|
35
|
+
const boards = Object.create(null);
|
|
36
|
+
for (const [b, ids] of Object.entries(v.boards)) if (Array.isArray(ids)) boards[b] = ids.filter((x) => typeof x === "string" && !!x);
|
|
37
|
+
return {
|
|
38
|
+
v: 1,
|
|
39
|
+
migrated: v.migrated === true,
|
|
40
|
+
boards
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function write(root, own) {
|
|
47
|
+
const f = fileOf(root);
|
|
48
|
+
mkdirSync(join(root, "design", ".local"), { recursive: true });
|
|
49
|
+
const tmp = `${f}.${randomBytes(4).toString("hex")}.tmp`;
|
|
50
|
+
writeFileSync(tmp, JSON.stringify(own) + "\n", { mode: 384 });
|
|
51
|
+
renameSync(tmp, f);
|
|
52
|
+
cache.delete(root);
|
|
53
|
+
}
|
|
54
|
+
/** The first 0.31 start's migration (idempotent: a file that says `migrated` is left as it is). */
|
|
55
|
+
function migrateOwnership(root) {
|
|
56
|
+
const have = read(root);
|
|
57
|
+
if (have?.migrated) return;
|
|
58
|
+
const boards = Object.assign(Object.create(null), have?.boards ?? {});
|
|
59
|
+
const ledger = owned(root);
|
|
60
|
+
const me = localProfile(root).email.toLowerCase();
|
|
61
|
+
for (const board of listBoards(commentsOf(root))) {
|
|
62
|
+
const ids = new Set(Object.hasOwn(boards, board) ? boards[board] : []);
|
|
63
|
+
for (const e of readLog(commentsOf(root), board)) {
|
|
64
|
+
if (e.type !== "create" && e.type !== "reply" || !e.commentId || e.agent || e.agentMeta) continue;
|
|
65
|
+
const theirs = (e.author?.email ?? "").toLowerCase();
|
|
66
|
+
if (ledger.has(`${board}\t${e.id}`) || (me ? theirs === me : !theirs && !e.author?.id)) ids.add(e.commentId);
|
|
67
|
+
}
|
|
68
|
+
if (ids.size) boards[board] = [...ids];
|
|
69
|
+
}
|
|
70
|
+
write(root, {
|
|
71
|
+
v: 1,
|
|
72
|
+
migrated: true,
|
|
73
|
+
boards
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function sets(root) {
|
|
77
|
+
const f = fileOf(root);
|
|
78
|
+
let key = "";
|
|
79
|
+
try {
|
|
80
|
+
const st = statSync(f);
|
|
81
|
+
key = `${st.mtimeMs}:${st.size}`;
|
|
82
|
+
} catch {}
|
|
83
|
+
const hit = cache.get(root);
|
|
84
|
+
if (hit && hit.key === key && key) return hit.sets;
|
|
85
|
+
if (!key || !read(root)?.migrated) migrateOwnership(root);
|
|
86
|
+
const own = read(root) ?? {
|
|
87
|
+
v: 1,
|
|
88
|
+
migrated: true,
|
|
89
|
+
boards: Object.create(null)
|
|
90
|
+
};
|
|
91
|
+
const out = new Map(Object.entries(own.boards).map(([b, ids]) => [b, new Set(ids)]));
|
|
92
|
+
try {
|
|
93
|
+
const st = statSync(f);
|
|
94
|
+
cache.set(root, {
|
|
95
|
+
key: `${st.mtimeMs}:${st.size}`,
|
|
96
|
+
own,
|
|
97
|
+
sets: out
|
|
98
|
+
});
|
|
99
|
+
} catch {}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/** Record messages written here for the local human (create or reply comment ids on `board`). */
|
|
103
|
+
function recordOwn(root, board, ids) {
|
|
104
|
+
const fresh = ids.filter((x) => typeof x === "string" && !!x);
|
|
105
|
+
if (!board || !fresh.length) return;
|
|
106
|
+
sets(root);
|
|
107
|
+
const own = read(root) ?? {
|
|
108
|
+
v: 1,
|
|
109
|
+
migrated: true,
|
|
110
|
+
boards: Object.create(null)
|
|
111
|
+
};
|
|
112
|
+
const list = new Set(Object.hasOwn(own.boards, board) ? own.boards[board] : []);
|
|
113
|
+
const before = list.size;
|
|
114
|
+
for (const id of fresh) list.add(id);
|
|
115
|
+
if (list.size === before) return;
|
|
116
|
+
own.boards[board] = [...list];
|
|
117
|
+
write(root, own);
|
|
118
|
+
}
|
|
119
|
+
/** Is this message (a create or reply comment id on `board`) the local human's? */
|
|
120
|
+
function ownsMessage(root, board, commentId) {
|
|
121
|
+
return !!commentId && !!sets(root).get(board)?.has(commentId);
|
|
122
|
+
}
|
|
123
|
+
/** Every message this machine's human owns, per board - what the shell asks (`GET comment-ownership`). */
|
|
124
|
+
function ownership(root) {
|
|
125
|
+
return Object.fromEntries([...sets(root)].map(([b, ids]) => [b, [...ids]]));
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { migrateOwnership, ownership, ownsMessage, recordOwn };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { i as readDevInfo } from "./work-Nv-n2_Un.mjs";
|
|
3
|
+
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { randomBytes } from "node:crypto";
|
|
6
|
+
//#region src/cli/pdf.ts
|
|
7
|
+
/**
|
|
8
|
+
* `marver pdf <board>` - a board's deck as a PDF (spec 31 Part A), made by the running `marver dev` (it owns the frames
|
|
9
|
+
* and the browser) and written to `design/exports/<board>.pdf` (`--notes`: `<board>-notes.pdf`, the handout).
|
|
10
|
+
*
|
|
11
|
+
* The job runs in the dev server; this command starts it, shows its progress, cancels it on Ctrl-C, then fetches the
|
|
12
|
+
* finished file and writes it whole. What it prints is the report: pages, size, time, and every slide that was skipped,
|
|
13
|
+
* clipped, unsettled, patched, rasterised, changed while printing or failed.
|
|
14
|
+
*/
|
|
15
|
+
const mb = (n) => n >= 1e6 ? `${(n / 2 ** 20).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1024))} KB`;
|
|
16
|
+
/** The report as lines a person reads: the file, then each kind of slide that needs a look. */
|
|
17
|
+
function reportLines(r, out) {
|
|
18
|
+
const lines = [`${out} - ${r.pages} page${r.pages === 1 ? "" : "s"}, ${mb(r.bytes)}, ${(r.ms / 1e3).toFixed(1)} s`];
|
|
19
|
+
const of = (pred, say) => r.slides.filter(pred).map(say);
|
|
20
|
+
const group = (label, items) => {
|
|
21
|
+
if (items.length) lines.push(` ${label}: ${items.join(", ")}`);
|
|
22
|
+
};
|
|
23
|
+
group("skipped", r.skipped.map((s) => `${s.frame} (${s.why})`));
|
|
24
|
+
group("failed", of((s) => s.status === "failed", (s) => `${s.frame} (${s.error ?? "failed"})`));
|
|
25
|
+
group("patched", of((s) => s.status === "patched", (s) => `${s.frame} (${[...new Set(s.patches ?? [])].join("; ")})`));
|
|
26
|
+
group("raster", of((s) => s.status === "raster", (s) => `${s.frame} (${s.raster ?? "raster"})`));
|
|
27
|
+
group("unsettled", of((s) => !!s.unsettled, (s) => s.frame));
|
|
28
|
+
group("clipped", of((s) => !!s.clipped, (s) => s.frame));
|
|
29
|
+
group("spilled", of((s) => !!s.spilled, (s) => s.frame));
|
|
30
|
+
group("changed while printing", of((s) => !!s.changed, (s) => s.frame));
|
|
31
|
+
const differs = of((s) => !!s.printDiffers, (s) => s.frame);
|
|
32
|
+
group("printed differently from the screen (kept: --vector)", differs);
|
|
33
|
+
if (!r.notes) lines.push(r.certified === "print" ? " every page print-certified (rasterised and compared with the screen)" : differs.length ? " not print-certified: the pages above differ in print" : " screen-certified only (no PDF rasteriser here)");
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
async function pdfCommand(root, board, opts) {
|
|
37
|
+
const usage = `${NAME} pdf <board> [--theme <name>] [--notes] [--paper letter|a4] [--out <file>] [--raster|--vector] [--keep-going] [--json]`;
|
|
38
|
+
if (!board) throw new Error(`name the board: ${usage}`);
|
|
39
|
+
if (opts.raster && opts.vector) throw new Error("--raster or --vector, not both");
|
|
40
|
+
if (opts.paper !== void 0 && opts.paper !== "letter" && opts.paper !== "a4") throw new Error("--paper is letter or a4");
|
|
41
|
+
if (opts.paper && !opts.notes) throw new Error("--paper is for the handout (--notes): a deck page is its slide's own size");
|
|
42
|
+
const info = readDevInfo(root);
|
|
43
|
+
if (!info) throw new Error(`\`${NAME} dev\` is not running in this repo (design/.local/dev.json not found) - start it first.`);
|
|
44
|
+
const base = `http://localhost:${info.port}/__mv/api/pdf`;
|
|
45
|
+
const headers = {
|
|
46
|
+
"x-mv-work": info.token,
|
|
47
|
+
"content-type": "application/json"
|
|
48
|
+
};
|
|
49
|
+
const ask = {
|
|
50
|
+
board,
|
|
51
|
+
...opts.theme ? { theme: opts.theme } : {},
|
|
52
|
+
...opts.notes ? { notes: true } : {},
|
|
53
|
+
...opts.paper ? { paper: opts.paper } : {},
|
|
54
|
+
...opts.raster ? { mode: "raster" } : opts.vector ? { mode: "vector" } : {},
|
|
55
|
+
...opts.keepGoing ? { keepGoing: true } : {}
|
|
56
|
+
};
|
|
57
|
+
const call = async (url, init) => {
|
|
58
|
+
try {
|
|
59
|
+
return await fetch(url, init);
|
|
60
|
+
} catch {
|
|
61
|
+
throw new Error(`could not reach \`${NAME} dev\` on port ${info.port} - is it still running?`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const started = await call(base, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers,
|
|
67
|
+
body: JSON.stringify(ask)
|
|
68
|
+
});
|
|
69
|
+
const s0 = await started.json().catch(() => ({}));
|
|
70
|
+
if (!started.ok || !s0.job) throw new Error(s0.error ? `${s0.error}${started.status === 409 && s0.job ? ` (job ${s0.job})` : ""}` : `the PDF could not start (${started.status})`);
|
|
71
|
+
const job = s0.job;
|
|
72
|
+
const onInt = () => {
|
|
73
|
+
fetch(`${base}/${job}`, {
|
|
74
|
+
method: "DELETE",
|
|
75
|
+
headers
|
|
76
|
+
}).finally(() => process.exit(130));
|
|
77
|
+
};
|
|
78
|
+
process.once("SIGINT", onInt);
|
|
79
|
+
const tty = process.stderr.isTTY && !opts.json;
|
|
80
|
+
let status = {};
|
|
81
|
+
try {
|
|
82
|
+
for (;;) {
|
|
83
|
+
const r = await call(`${base}/${job}`, { headers });
|
|
84
|
+
status = await r.json().catch(() => ({}));
|
|
85
|
+
if (!r.ok) throw new Error(status.error ?? `lost the job (${r.status})`);
|
|
86
|
+
if (tty) process.stderr.write(`\r ${status.phase === "merging" ? "merging" : status.phase === "handout" ? "printing the handout" : `page ${status.page ?? 0} of ${status.pages ?? "?"}`} `);
|
|
87
|
+
if (status.state !== "running") break;
|
|
88
|
+
await new Promise((res) => setTimeout(res, 400));
|
|
89
|
+
}
|
|
90
|
+
} finally {
|
|
91
|
+
process.removeListener("SIGINT", onInt);
|
|
92
|
+
if (tty) process.stderr.write("\r\x1B[K");
|
|
93
|
+
}
|
|
94
|
+
if (status.state !== "done" || !status.report) throw new Error(`the PDF ${status.state ?? "failed"}${status.error ? ` - ${status.error}` : ""}`);
|
|
95
|
+
const file = await call(`${base}/${job}/file`, { headers });
|
|
96
|
+
if (!file.ok) throw new Error((await file.json().catch(() => ({}))).error ?? `could not fetch the PDF (${file.status})`);
|
|
97
|
+
const bytes = Buffer.from(await file.arrayBuffer());
|
|
98
|
+
const out = opts.out ? isAbsolute(opts.out) ? opts.out : resolve(process.cwd(), opts.out) : join(root, "design", "exports", status.filename ?? `${board}.pdf`);
|
|
99
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
100
|
+
const tmp = `${out}.${randomBytes(6).toString("hex")}.tmp`;
|
|
101
|
+
writeFileSync(tmp, bytes);
|
|
102
|
+
try {
|
|
103
|
+
renameSync(tmp, out);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
rmSync(tmp, { force: true });
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
const shown = relative(process.cwd(), out).startsWith("..") ? out : relative(process.cwd(), out) || out;
|
|
109
|
+
if (opts.json) console.log(JSON.stringify({
|
|
110
|
+
file: out,
|
|
111
|
+
...status.report
|
|
112
|
+
}, null, 2));
|
|
113
|
+
else for (const l of reportLines(status.report, shown)) console.log(l);
|
|
114
|
+
return status.report.slides.some((s) => s.status === "failed") ? 1 : 0;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { pdfCommand };
|