@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,19 +1,20 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { a as ROUTE, i as PKG, r as NAME } from "./cli.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, _ as validateWire, a as buildTree, c as folderMap, g as readTitle, h as readDescription, j as settableStatuses, k as readType, n as BOARD_NAME, r as FOLDERS_FILE, t as ALL_SCENES, v as wireKids } from "./board-tree-
|
|
5
|
-
import { c as setSceneTitle, d as annotateBoards, f as planNames, m as readContextFacts, n as isNoteFile, p as planWithStage, s as scanFrames, t as affectedFrameIds, u as writeManifest } from "./manifest-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { _ as tryFileLock, c as isRegularFile, d as parseBoard, f as pinFrames, g as takeFileLock, h as readRegistry, i as boardLock, l as listBoardFiles, m as readMembership, o as checkBoardsDir, r as boardFields, s as checkRealDirs, t as AUTHOR_FIELDS, u as nodeExists, x as hash, y as withRegistryLock } from "./boards-Cim1GTKc.mjs";
|
|
4
|
+
import { A as resolveType, D as readReason, E as readCapability, O as readStatusWord, S as HAS_STATUS, _ as validateWire, a as buildTree, c as folderMap, g as readTitle, h as readDescription, j as settableStatuses, k as readType, n as BOARD_NAME, r as FOLDERS_FILE, t as ALL_SCENES, v as wireKids } from "./board-tree-DGj0HhEE.mjs";
|
|
5
|
+
import { c as setSceneTitle, d as annotateBoards, f as planNames, m as readContextFacts, n as isNoteFile, p as planWithStage, s as scanFrames, t as affectedFrameIds, u as writeManifest } from "./manifest-CK8Qh4Nq.mjs";
|
|
6
|
+
import { c as newerVersion, o as checkShowTarget } from "./deep-link-DYtuT740.mjs";
|
|
7
|
+
import { g as LIVE_WIRE, h as LIVE_BOUNDS, i as marverHome, o as originOf, v as workspaceId } from "./slots-BOcfIqxy.mjs";
|
|
8
|
+
import { a as workActivity, r as boardsChanged } from "./work-Nv-n2_Un.mjs";
|
|
9
|
+
import { a as replay, t as asks } from "./events-Dieo1482.mjs";
|
|
8
10
|
import { a as readLog, i as listBoards } from "./comments-0BSbb04K.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { n as loadConfig } from "./config-
|
|
14
|
-
import { a as mergeSizes, c as serializeSizes, i as measuringFrames, l as sizesPath, n as autoWidthOf, o as readSizes, r as keptSizes, s as readSizesFile } from "./sizes-
|
|
15
|
-
import { c as pool, d as withBrowser,
|
|
16
|
-
import { a as appProofOk, o as proofHeaders, r as logoRoute } from "./logo-CXY-1yrn.mjs";
|
|
11
|
+
import { n as localProfile, t as isConnected } from "./profile-cdmSer1k.mjs";
|
|
12
|
+
import { c as recordChanged, i as initMarks, n as docRevs, o as observe, r as freshFrames, t as docRev } from "./marks-C8oX8kbE.mjs";
|
|
13
|
+
import { C as WRITE_MATCH_MS, S as WRITER_HEADERS, _ as ID12, b as RELOAD_BOUNDS, c as takePageBatch, l as takeReloadBatch, n as appendRun, r as logReloadLines, t as PAGE_BODY_MAX, u as tidyPerfDir, v as RECORDER_LEVELS, w as decodeCmds, y as RECORDER_PARAM } from "./perf-BB0XNt1M.mjs";
|
|
14
|
+
import { c as proofHeaders, i as logoRoute, s as appProofOk, t as findLogo } from "./logo-C9s7-Cy9.mjs";
|
|
15
|
+
import { n as loadConfig } from "./config-B0YcFtqS.mjs";
|
|
16
|
+
import { a as mergeSizes, c as serializeSizes, i as measuringFrames, l as sizesPath, n as autoWidthOf, o as readSizes, r as keptSizes, s as readSizesFile } from "./sizes-BckcL4Zz.mjs";
|
|
17
|
+
import { c as pool, d as withBrowser, h as launchFlags, l as shotConcurrency, p as Browser, r as SURFACE, t as AREA } from "./shot-BqwkdtKn.mjs";
|
|
17
18
|
import { closeSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, watch, writeFileSync } from "node:fs";
|
|
18
19
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
19
20
|
import { fileURLToPath } from "node:url";
|
|
@@ -22,6 +23,55 @@ import { arch, cpus, totalmem } from "node:os";
|
|
|
22
23
|
import { execFile } from "node:child_process";
|
|
23
24
|
import { stat } from "node:fs/promises";
|
|
24
25
|
import { isCSSRequest } from "vite";
|
|
26
|
+
//#region src/server/identity.ts
|
|
27
|
+
/**
|
|
28
|
+
* One identity resolver (spec 31 G.1): what a canvas is called, and which logo it wears - here, and nowhere else.
|
|
29
|
+
*
|
|
30
|
+
* - local name (`marver dev`: the app's tab and Home card through the slot file, the sidebar, the manifest's project):
|
|
31
|
+
* config `name` > `share.name` > the folder's name - today's runtime rule, with `name` on top.
|
|
32
|
+
* - published name (`marver build`'s meta.json: the gate's title, the sign-in screens): config `name` > `share.name` >
|
|
33
|
+
* package.json `name` > the folder's - today's build rule, with `name` on top.
|
|
34
|
+
* - logo: config `logo` > `share.logo` > logo.ts's ladder (`findLogo`).
|
|
35
|
+
*
|
|
36
|
+
* `share.*` keeps working and nothing is rewritten: a canvas that sets neither `name` nor `logo` resolves exactly as it
|
|
37
|
+
* did before.
|
|
38
|
+
*/
|
|
39
|
+
/** The host package.json's `name`, when it has one. */
|
|
40
|
+
function packageName(root) {
|
|
41
|
+
try {
|
|
42
|
+
const n = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name;
|
|
43
|
+
return typeof n === "string" && n ? n : void 0;
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function canvasIdentity(root, config) {
|
|
49
|
+
const own = config.name || config.share.name;
|
|
50
|
+
const folder = basename(root);
|
|
51
|
+
const pkg = own ? void 0 : packageName(root);
|
|
52
|
+
return {
|
|
53
|
+
local: own || folder,
|
|
54
|
+
published: own || pkg || folder,
|
|
55
|
+
nameFrom: config.name ? "name" : config.share.name ? "share.name" : "folder",
|
|
56
|
+
logos: [{
|
|
57
|
+
key: "logo",
|
|
58
|
+
path: config.logo
|
|
59
|
+
}, {
|
|
60
|
+
key: "share.logo",
|
|
61
|
+
path: config.share.logo
|
|
62
|
+
}]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** `marver dev`'s boot-line note (spec 31 G.2): what still makes this canvas look like any other in the app - its
|
|
66
|
+
* folder's name, the Marver mark - and the one place each is set. Null when it has both a name and a logo. */
|
|
67
|
+
function identityNudge(root, config) {
|
|
68
|
+
const id = canvasIdentity(root, config);
|
|
69
|
+
const folder = id.nameFrom === "folder";
|
|
70
|
+
const mark = !findLogo(root, id.logos);
|
|
71
|
+
if (!folder && !mark) return null;
|
|
72
|
+
return `this canvas still shows ${folder && mark ? `its folder's name ("${id.local}") and the Marver mark` : folder ? `its folder's name ("${id.local}")` : "the Marver mark"} - give it ${[folder ? "name: \"Your Product\" in design/config.ts" : "", mark ? "your product's logo at design/logo.svg" : ""].filter(Boolean).join(" and ")}`;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
25
75
|
//#region src/shared/frames.ts
|
|
26
76
|
/** A canvas made of content frames alone (Doc, Md, Diagram ship their own styling) needs no theme -
|
|
27
77
|
* only an app frame does (#4). Empty counts as not content-only: the warning still helps there. */
|
|
@@ -1812,6 +1862,11 @@ async function writeHeadlessProfile(home) {
|
|
|
1812
1862
|
* firewalled registries degrade to silence. MARVER_NO_UPDATE_CHECK=1 disables it.
|
|
1813
1863
|
* Published bundles never check anything - viewers are not the owner.
|
|
1814
1864
|
*/
|
|
1865
|
+
var update_exports = /* @__PURE__ */ __exportAll({
|
|
1866
|
+
checkUpdate: () => checkUpdate,
|
|
1867
|
+
installedVersion: () => installedVersion,
|
|
1868
|
+
updateStatus: () => updateStatus
|
|
1869
|
+
});
|
|
1815
1870
|
const TTL = 864e5;
|
|
1816
1871
|
/** Installed version: walk up from this module to the package's own package.json
|
|
1817
1872
|
* (one level from dist/, two from src/server/ - the walk covers both). */
|
|
@@ -1827,48 +1882,77 @@ function installedVersion() {
|
|
|
1827
1882
|
return null;
|
|
1828
1883
|
}
|
|
1829
1884
|
/** Strictly-newer numeric compare; anything non-numeric (prerelease tags) compares false. */
|
|
1830
|
-
const newer = (a, b) =>
|
|
1831
|
-
const pa = a.split(".").map((n) => parseInt(n, 10));
|
|
1832
|
-
const pb = b.split(".").map((n) => parseInt(n, 10));
|
|
1833
|
-
for (let i = 0; i < 3; i++) {
|
|
1834
|
-
const x = pa[i] ?? 0, y = pb[i] ?? 0;
|
|
1835
|
-
if (!Number.isFinite(x) || !Number.isFinite(y)) return false;
|
|
1836
|
-
if (x !== y) return x > y;
|
|
1837
|
-
}
|
|
1838
|
-
return false;
|
|
1839
|
-
};
|
|
1885
|
+
const newer = (a, b) => newerVersion(a, b);
|
|
1840
1886
|
/** The latest published version when strictly newer than installed, else null. Never throws. */
|
|
1841
1887
|
async function checkUpdate(root) {
|
|
1842
1888
|
if (process.env.MARVER_NO_UPDATE_CHECK) return null;
|
|
1843
1889
|
const current = installedVersion();
|
|
1844
1890
|
if (!current) return null;
|
|
1845
|
-
const latest = await latestVersion(root);
|
|
1891
|
+
const { latest } = await latestVersion(root);
|
|
1846
1892
|
return latest && newer(latest, current) ? latest : null;
|
|
1847
1893
|
}
|
|
1848
|
-
async function
|
|
1894
|
+
async function updateStatus(root) {
|
|
1895
|
+
const current = installedVersion();
|
|
1896
|
+
if (process.env.MARVER_NO_UPDATE_CHECK) return {
|
|
1897
|
+
current,
|
|
1898
|
+
latest: null,
|
|
1899
|
+
checkedAt: null,
|
|
1900
|
+
state: "disabled"
|
|
1901
|
+
};
|
|
1902
|
+
const r = await latestVersion(root);
|
|
1903
|
+
return {
|
|
1904
|
+
current,
|
|
1905
|
+
latest: r.latest,
|
|
1906
|
+
checkedAt: r.checkedAt,
|
|
1907
|
+
state: r.ok ? "ok" : "offline"
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
/** One registry read at a time per root: requests that come together share it. */
|
|
1911
|
+
const asking = /* @__PURE__ */ new Map();
|
|
1912
|
+
function latestVersion(root) {
|
|
1849
1913
|
const cacheFile = join(root, "design", ".local", "update-check.json");
|
|
1850
1914
|
const wellFormed = (v) => typeof v === "string" && /^\d+\.\d+\.\d+$/.test(v);
|
|
1851
1915
|
try {
|
|
1852
1916
|
const c = JSON.parse(readFileSync(cacheFile, "utf8"));
|
|
1853
1917
|
const age = Date.now() - c.checkedAt;
|
|
1854
|
-
if (typeof c.checkedAt === "number" && age >= 0 && age < TTL) return
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
if (res.ok) {
|
|
1860
|
-
const v = (await res.json())?.version;
|
|
1861
|
-
if (wellFormed(v)) latest = v;
|
|
1862
|
-
}
|
|
1863
|
-
} catch {}
|
|
1864
|
-
try {
|
|
1865
|
-
mkdirSync(join(root, "design", ".local"), { recursive: true });
|
|
1866
|
-
writeFileSync(cacheFile, JSON.stringify({
|
|
1867
|
-
checkedAt: Date.now(),
|
|
1868
|
-
latest
|
|
1869
|
-
}) + "\n");
|
|
1918
|
+
if (typeof c.checkedAt === "number" && age >= 0 && age < TTL) return Promise.resolve({
|
|
1919
|
+
latest: wellFormed(c.latest) ? c.latest : null,
|
|
1920
|
+
checkedAt: c.checkedAt,
|
|
1921
|
+
ok: typeof c.ok === "boolean" ? c.ok : wellFormed(c.latest)
|
|
1922
|
+
});
|
|
1870
1923
|
} catch {}
|
|
1871
|
-
|
|
1924
|
+
const had = asking.get(root);
|
|
1925
|
+
if (had) return had;
|
|
1926
|
+
const p = (async () => {
|
|
1927
|
+
let latest = null;
|
|
1928
|
+
let ok = false;
|
|
1929
|
+
try {
|
|
1930
|
+
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(PKG)}/latest`, { signal: AbortSignal.timeout(3e3) });
|
|
1931
|
+
if (res.ok) {
|
|
1932
|
+
const v = (await res.json())?.version;
|
|
1933
|
+
if (wellFormed(v)) {
|
|
1934
|
+
latest = v;
|
|
1935
|
+
ok = true;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
} catch {}
|
|
1939
|
+
const checkedAt = Date.now();
|
|
1940
|
+
try {
|
|
1941
|
+
mkdirSync(join(root, "design", ".local"), { recursive: true });
|
|
1942
|
+
writeFileSync(cacheFile, JSON.stringify({
|
|
1943
|
+
checkedAt,
|
|
1944
|
+
latest,
|
|
1945
|
+
ok
|
|
1946
|
+
}) + "\n");
|
|
1947
|
+
} catch {}
|
|
1948
|
+
return {
|
|
1949
|
+
latest,
|
|
1950
|
+
checkedAt,
|
|
1951
|
+
ok
|
|
1952
|
+
};
|
|
1953
|
+
})().finally(() => asking.delete(root));
|
|
1954
|
+
asking.set(root, p);
|
|
1955
|
+
return p;
|
|
1872
1956
|
}
|
|
1873
1957
|
//#endregion
|
|
1874
1958
|
//#region src/server/perf-run.ts
|
|
@@ -2746,6 +2830,46 @@ async function serveRun(req, res, o) {
|
|
|
2746
2830
|
}
|
|
2747
2831
|
}
|
|
2748
2832
|
//#endregion
|
|
2833
|
+
//#region src/server/show.ts
|
|
2834
|
+
const SHOW_OUTCOMES = ["shown", "notice"];
|
|
2835
|
+
const KEEP = 32;
|
|
2836
|
+
const PAGE = /^[A-Za-z0-9_-]{8,64}$/;
|
|
2837
|
+
function createShows() {
|
|
2838
|
+
let seq = 0;
|
|
2839
|
+
const kept = /* @__PURE__ */ new Map();
|
|
2840
|
+
return {
|
|
2841
|
+
start(t) {
|
|
2842
|
+
seq += 1;
|
|
2843
|
+
kept.set(seq, /* @__PURE__ */ new Map());
|
|
2844
|
+
for (const k of kept.keys()) if (k <= seq - KEEP) kept.delete(k);
|
|
2845
|
+
return {
|
|
2846
|
+
seq,
|
|
2847
|
+
cmd: {
|
|
2848
|
+
...t,
|
|
2849
|
+
seq
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
},
|
|
2853
|
+
ack(s, page, outcome) {
|
|
2854
|
+
if (typeof s !== "number" || !kept.has(s) || typeof page !== "string" || !PAGE.test(page)) return false;
|
|
2855
|
+
if (!SHOW_OUTCOMES.includes(outcome)) return false;
|
|
2856
|
+
kept.get(s).set(page, outcome);
|
|
2857
|
+
return true;
|
|
2858
|
+
},
|
|
2859
|
+
acks(s) {
|
|
2860
|
+
const m = kept.get(s);
|
|
2861
|
+
if (!m) return null;
|
|
2862
|
+
let shown = 0, notice = 0;
|
|
2863
|
+
for (const o of m.values()) if (o === "shown") shown++;
|
|
2864
|
+
else notice++;
|
|
2865
|
+
return {
|
|
2866
|
+
shown,
|
|
2867
|
+
notice
|
|
2868
|
+
};
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2872
|
+
//#endregion
|
|
2749
2873
|
//#region src/server/api.ts
|
|
2750
2874
|
const BODY_LIMIT = 1e6;
|
|
2751
2875
|
const CSRF_MAX_AGE = 2592e3;
|
|
@@ -2902,6 +3026,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
2902
3026
|
const notSymlink = (p) => !nodeExists(p) || isRegularFile(p);
|
|
2903
3027
|
const nodeExists$1 = nodeExists;
|
|
2904
3028
|
let sizesWarned = false;
|
|
3029
|
+
const shows = createShows();
|
|
2905
3030
|
/** A board file this request wrote (spec 30 #18), with the page and commands it names - the watcher's `sh:board`
|
|
2906
3031
|
* matches these bytes against it, as a candidate, never as proof. */
|
|
2907
3032
|
const wroteBoard = (req, board, content) => {
|
|
@@ -2915,7 +3040,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
2915
3040
|
* capture not sealed; then the bytes, 8 MB at most as they arrive, their signature and the whole PNG; and the capture
|
|
2916
3041
|
* still not sealed, just before it is stored. Nothing is stored once `stop` (the deadline) has fired. */
|
|
2917
3042
|
const livePicture = async (req, url, stop) => {
|
|
2918
|
-
const { CAPTURE_ID, addPictureBytes, checkPng, isPng, readCapture, sweepPictures } = await import("./capture-
|
|
3043
|
+
const { CAPTURE_ID, addPictureBytes, checkPng, isPng, readCapture, sweepPictures } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
|
|
2919
3044
|
if (String(req.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase() !== "image/png") return [415, { error: "expected image/png" }];
|
|
2920
3045
|
const capture = url.searchParams.get("capture") ?? "", frame = url.searchParams.get("frame") ?? "";
|
|
2921
3046
|
if (!CAPTURE_ID.test(capture)) return [400, { error: "bad capture id" }];
|
|
@@ -3177,7 +3302,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3177
3302
|
return json(res, 400, { error: "malformed JSON" });
|
|
3178
3303
|
}
|
|
3179
3304
|
if (!b || b.kind !== "capture" && b.kind !== "upload") return json(res, 400, { error: "kind must be capture or upload" });
|
|
3180
|
-
(await import("./perf-
|
|
3305
|
+
(await import("./perf-BB0XNt1M.mjs").then((n) => n.f)).logJam(root, b);
|
|
3181
3306
|
return json(res, 200, { ok: true });
|
|
3182
3307
|
}
|
|
3183
3308
|
if (path === "perf/page" && req.method === "POST") {
|
|
@@ -3200,7 +3325,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3200
3325
|
return json(res, "error" in answer ? 503 : 200, answer);
|
|
3201
3326
|
}
|
|
3202
3327
|
if (path === "perf/run" && req.method === "POST" || path === "perf/inputs" && req.method === "GET") {
|
|
3203
|
-
const { readDevInfo } = await import("./work-
|
|
3328
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3204
3329
|
const token = readDevInfo(root)?.token;
|
|
3205
3330
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3206
3331
|
if (path === "perf/inputs") {
|
|
@@ -3655,7 +3780,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3655
3780
|
}
|
|
3656
3781
|
}
|
|
3657
3782
|
if (path === "shot" && req.method === "GET") {
|
|
3658
|
-
const { readDevInfo } = await import("./work-
|
|
3783
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3659
3784
|
const token = readDevInfo(root)?.token;
|
|
3660
3785
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3661
3786
|
const frameId = url.searchParams.get("frame") ?? "";
|
|
@@ -3671,7 +3796,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3671
3796
|
};
|
|
3672
3797
|
const asPng = url.searchParams.get("format") === "png";
|
|
3673
3798
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3674
|
-
const { shootFrame } = await import("./shot-
|
|
3799
|
+
const { shootFrame } = await import("./shot-BqwkdtKn.mjs").then((n) => n.u);
|
|
3675
3800
|
const r = await shootFrame({
|
|
3676
3801
|
root,
|
|
3677
3802
|
viewports: opts.viewports ?? {},
|
|
@@ -3704,8 +3829,101 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3704
3829
|
});
|
|
3705
3830
|
return res.end(png);
|
|
3706
3831
|
}
|
|
3832
|
+
const pdfRoute = /^pdf(?:\/([^/]*)(\/file)?)?$/.exec(path);
|
|
3833
|
+
if (pdfRoute) {
|
|
3834
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3835
|
+
const token = readDevInfo(root)?.token;
|
|
3836
|
+
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3837
|
+
const pdf = await import("./pdf-CZENT6t3.mjs");
|
|
3838
|
+
if (pdfRoute[1] === void 0) {
|
|
3839
|
+
if (req.method !== "POST") return json(res, 405, { error: "POST to start a PDF" });
|
|
3840
|
+
const raw = await readBody(req);
|
|
3841
|
+
if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
|
|
3842
|
+
let b;
|
|
3843
|
+
try {
|
|
3844
|
+
b = JSON.parse(raw);
|
|
3845
|
+
} catch {
|
|
3846
|
+
return json(res, 400, { error: "malformed JSON" });
|
|
3847
|
+
}
|
|
3848
|
+
if (!b || typeof b !== "object" || Array.isArray(b)) return json(res, 400, { error: "expected an object" });
|
|
3849
|
+
if (!validName(b.board)) return json(res, 400, { error: "board must be a board name" });
|
|
3850
|
+
const opt = (k, ok) => b[k] === void 0 ? void 0 : ok(b[k]) ? b[k] : null;
|
|
3851
|
+
const theme = opt("theme", (v) => typeof v === "string" && /^[a-z0-9-]{1,32}$/i.test(v));
|
|
3852
|
+
const notes = opt("notes", (v) => typeof v === "boolean");
|
|
3853
|
+
const paper = opt("paper", (v) => v === "letter" || v === "a4");
|
|
3854
|
+
const mode = opt("mode", (v) => v === "auto" || v === "raster" || v === "vector");
|
|
3855
|
+
const keepGoing = opt("keepGoing", (v) => typeof v === "boolean");
|
|
3856
|
+
for (const [k, v] of Object.entries({
|
|
3857
|
+
theme,
|
|
3858
|
+
notes,
|
|
3859
|
+
paper,
|
|
3860
|
+
mode,
|
|
3861
|
+
keepGoing
|
|
3862
|
+
})) if (v === null) return json(res, 400, { error: `invalid ${k}` });
|
|
3863
|
+
const { docRev } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
|
|
3864
|
+
const { installedVersion } = await Promise.resolve().then(() => update_exports);
|
|
3865
|
+
const ctx = {
|
|
3866
|
+
root,
|
|
3867
|
+
origin: opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`,
|
|
3868
|
+
viewports: opts.viewports ?? {},
|
|
3869
|
+
themes: opts.themes ?? ["light", "dark"],
|
|
3870
|
+
canvasName: opts.canvasName?.() ?? root.split(sep).pop() ?? "canvas",
|
|
3871
|
+
version: installedVersion() ?? "0.0.0",
|
|
3872
|
+
frames: () => devManifest().frames,
|
|
3873
|
+
scenes: () => devManifest().scenes,
|
|
3874
|
+
settled: opts.settled ?? (() => true),
|
|
3875
|
+
docRev: (id) => docRev(root, devManifest().frames, id)
|
|
3876
|
+
};
|
|
3877
|
+
const r = await pdf.startPdfJob(ctx, {
|
|
3878
|
+
board: b.board,
|
|
3879
|
+
...theme ? { theme } : {},
|
|
3880
|
+
...notes ? { notes } : {},
|
|
3881
|
+
...paper ? { paper } : {},
|
|
3882
|
+
...mode ? { mode } : {},
|
|
3883
|
+
...keepGoing ? { keepGoing } : {}
|
|
3884
|
+
});
|
|
3885
|
+
if (!r.ok) return json(res, r.status, {
|
|
3886
|
+
error: r.error,
|
|
3887
|
+
...r.job ? { job: r.job } : {}
|
|
3888
|
+
});
|
|
3889
|
+
return json(res, 202, pdf.jobStatus(r.job));
|
|
3890
|
+
}
|
|
3891
|
+
const j = pdf.getJob(pdfRoute[1]);
|
|
3892
|
+
if (!j || j.root !== root) return json(res, 404, { error: "no such PDF job - a finished one is kept for an hour" });
|
|
3893
|
+
if (pdfRoute[2]) {
|
|
3894
|
+
if (req.method !== "GET") return json(res, 405, { error: "GET the file" });
|
|
3895
|
+
if (j.state !== "done" || !j.file) return json(res, 409, { error: j.state === "running" ? "the PDF is not finished yet" : `the export ${j.state}${j.error ? ` - ${j.error}` : ""}` });
|
|
3896
|
+
const { createReadStream, statSync } = await import("node:fs");
|
|
3897
|
+
let size;
|
|
3898
|
+
try {
|
|
3899
|
+
size = statSync(j.file).size;
|
|
3900
|
+
} catch {
|
|
3901
|
+
return json(res, 410, { error: "the PDF is gone - export it again" });
|
|
3902
|
+
}
|
|
3903
|
+
res.writeHead(200, {
|
|
3904
|
+
"content-type": "application/pdf",
|
|
3905
|
+
"content-length": size,
|
|
3906
|
+
"cache-control": "no-store",
|
|
3907
|
+
"x-content-type-options": "nosniff",
|
|
3908
|
+
"content-disposition": `attachment; filename="${j.filename.replace(/[^A-Za-z0-9._-]/g, "_")}"`
|
|
3909
|
+
});
|
|
3910
|
+
const st = createReadStream(j.file);
|
|
3911
|
+
st.on("error", () => res.destroy());
|
|
3912
|
+
res.on("close", () => st.destroy());
|
|
3913
|
+
return st.pipe(res);
|
|
3914
|
+
}
|
|
3915
|
+
if (req.method === "GET") return json(res, 200, pdf.jobStatus(j));
|
|
3916
|
+
if (req.method === "DELETE") {
|
|
3917
|
+
pdf.cancelPdfJob(j.id);
|
|
3918
|
+
return json(res, 200, {
|
|
3919
|
+
job: j.id,
|
|
3920
|
+
cancelled: j.state === "running" || j.state === "cancelled"
|
|
3921
|
+
});
|
|
3922
|
+
}
|
|
3923
|
+
return json(res, 405, { error: "GET or DELETE a job" });
|
|
3924
|
+
}
|
|
3707
3925
|
if (path === "shots" && req.method === "POST") {
|
|
3708
|
-
const { readDevInfo } = await import("./work-
|
|
3926
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3709
3927
|
const token = readDevInfo(root)?.token;
|
|
3710
3928
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3711
3929
|
const raw = await readBody(req);
|
|
@@ -3722,7 +3940,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3722
3940
|
if (typeof theme !== "string" || !/^[a-z0-9-]+$/i.test(theme)) return json(res, 400, { error: "invalid theme" });
|
|
3723
3941
|
const scale = body.scale === void 0 ? void 0 : body.scale;
|
|
3724
3942
|
if (scale !== void 0 && !(Number.isInteger(scale) && scale >= 1 && scale <= 4)) return json(res, 400, { error: "invalid scale" });
|
|
3725
|
-
const { resolveFrames, shootBatch } = await import("./shot-
|
|
3943
|
+
const { resolveFrames, shootBatch } = await import("./shot-BqwkdtKn.mjs").then((n) => n.u);
|
|
3726
3944
|
const sel = resolveFrames(root, body);
|
|
3727
3945
|
if (!sel.ok) return json(res, sel.status, { error: sel.error });
|
|
3728
3946
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
@@ -3740,7 +3958,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3740
3958
|
}
|
|
3741
3959
|
}
|
|
3742
3960
|
if (path === "anchor" && req.method === "POST") {
|
|
3743
|
-
const { readDevInfo } = await import("./work-
|
|
3961
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3744
3962
|
const token = readDevInfo(root)?.token;
|
|
3745
3963
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3746
3964
|
const raw = await readBody(req);
|
|
@@ -3756,7 +3974,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3756
3974
|
if (typeof target === "string") return json(res, 400, { error: target });
|
|
3757
3975
|
const others = Array.isArray(b.others) ? b.others.filter((o) => typeof o?.key === "string").slice(0, 200) : [];
|
|
3758
3976
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3759
|
-
const { checkAnchor, CheckInputError } = await import("./anchor-check-
|
|
3977
|
+
const { checkAnchor, CheckInputError } = await import("./anchor-check-B92s9tVv.mjs");
|
|
3760
3978
|
try {
|
|
3761
3979
|
return json(res, 200, await checkAnchor({
|
|
3762
3980
|
root,
|
|
@@ -3806,7 +4024,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3806
4024
|
});
|
|
3807
4025
|
docs.push(typeof a?.doc === "string" ? a.doc : void 0);
|
|
3808
4026
|
}
|
|
3809
|
-
const { docRev } = await import("./marks-
|
|
4027
|
+
const { docRev } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
|
|
3810
4028
|
const all = devManifest().frames;
|
|
3811
4029
|
const pending = opts.settled ? !opts.settled() : false;
|
|
3812
4030
|
const behind = docs.map((d, i) => d !== void 0 && (pending || d !== docRev(root, all, asks[i].frame)));
|
|
@@ -3864,8 +4082,8 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3864
4082
|
return json(res, 400, { error: "malformed JSON" });
|
|
3865
4083
|
}
|
|
3866
4084
|
const src = typeof b?.src === "string" ? b.src : "";
|
|
3867
|
-
const { ensurePoster, isLocalClip } = await import("./poster-
|
|
3868
|
-
const { isLocalAssetRef } = await import("./build-
|
|
4085
|
+
const { ensurePoster, isLocalClip } = await import("./poster-B7uSjlEP.mjs");
|
|
4086
|
+
const { isLocalAssetRef } = await import("./build-BNssmbqd.mjs");
|
|
3869
4087
|
if (!isLocalAssetRef(src) || !isLocalClip(src)) return json(res, 400, { error: "src must be a clip under design/assets/" });
|
|
3870
4088
|
const r = await ensurePoster(join(root, "design", "assets"), src);
|
|
3871
4089
|
if (!r.ok) return json(res, r.error.includes("does not exist") ? 404 : 503, { error: r.error });
|
|
@@ -3892,7 +4110,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3892
4110
|
}
|
|
3893
4111
|
const dir = join(root, "design", ".local");
|
|
3894
4112
|
mkdirSync(dir, { recursive: true });
|
|
3895
|
-
const { validAvatar } = await import("./collab-
|
|
4113
|
+
const { validAvatar } = await import("./collab-D2NcrOB8.mjs");
|
|
3896
4114
|
let cur = {};
|
|
3897
4115
|
try {
|
|
3898
4116
|
cur = JSON.parse(readFileSync(join(dir, "profile.json"), "utf8"));
|
|
@@ -3908,7 +4126,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3908
4126
|
}
|
|
3909
4127
|
if (path === "marks" || path === "marks/seen") {
|
|
3910
4128
|
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
3911
|
-
const { readMarks, markSeen } = await import("./marks-
|
|
4129
|
+
const { readMarks, markSeen } = await import("./marks-C8oX8kbE.mjs").then((n) => n.a);
|
|
3912
4130
|
const manifest = devManifest();
|
|
3913
4131
|
if (path === "marks" && req.method === "GET") return json(res, 200, readMarks(root, manifest));
|
|
3914
4132
|
if (path === "marks/seen" && req.method === "POST") {
|
|
@@ -3927,15 +4145,52 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3927
4145
|
}
|
|
3928
4146
|
return json(res, 405, { error: "method not allowed" });
|
|
3929
4147
|
}
|
|
4148
|
+
if (path === "show" || path === "show/ack" || path === "show/acks") {
|
|
4149
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
4150
|
+
const token = readDevInfo(root)?.token;
|
|
4151
|
+
const tokenOk = !!token && req.headers["x-mv-work"] === token;
|
|
4152
|
+
if (path === "show" && req.method === "POST") {
|
|
4153
|
+
if (!ownerGated(req) && !tokenOk) return json(res, 403, { error: "forbidden" });
|
|
4154
|
+
const raw = await readBody(req, 16384);
|
|
4155
|
+
if (raw == null) return json(res, 400, { error: "body too large or unreadable" });
|
|
4156
|
+
let b;
|
|
4157
|
+
try {
|
|
4158
|
+
b = JSON.parse(raw);
|
|
4159
|
+
} catch {
|
|
4160
|
+
return json(res, 400, { error: "malformed JSON" });
|
|
4161
|
+
}
|
|
4162
|
+
const t = checkShowTarget(b);
|
|
4163
|
+
if (!t) return json(res, 400, { error: "not a show target: { board, n?, f?, s?, c? } in the link grammar" });
|
|
4164
|
+
if (t.board !== "~unplaced" && (dirError() || !listBoardFiles(boardsDir).boards.some((x) => x.name === t.board))) return json(res, 404, { error: `no board "${t.board}"` });
|
|
4165
|
+
const { seq, cmd } = shows.start(t);
|
|
4166
|
+
opts.broadcast?.("sh:show", cmd);
|
|
4167
|
+
return json(res, 200, { seq });
|
|
4168
|
+
}
|
|
4169
|
+
if (path === "show/ack" && req.method === "POST") {
|
|
4170
|
+
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
4171
|
+
const raw = await readBody(req, 4096);
|
|
4172
|
+
let b = null;
|
|
4173
|
+
try {
|
|
4174
|
+
b = raw == null ? null : JSON.parse(raw);
|
|
4175
|
+
} catch {}
|
|
4176
|
+
return shows.ack(b?.seq, b?.page, b?.outcome) ? json(res, 200, { ok: true }) : json(res, 400, { error: "not an answer to a show kept here" });
|
|
4177
|
+
}
|
|
4178
|
+
if (path === "show/acks" && req.method === "GET") {
|
|
4179
|
+
if (!ownerGated(req) && !tokenOk) return json(res, 403, { error: "forbidden" });
|
|
4180
|
+
const a = shows.acks(Number(url.searchParams.get("seq")));
|
|
4181
|
+
return a ? json(res, 200, a) : json(res, 404, { error: "no such show" });
|
|
4182
|
+
}
|
|
4183
|
+
return json(res, 405, { error: "method not allowed" });
|
|
4184
|
+
}
|
|
3930
4185
|
if (path === "work") {
|
|
3931
|
-
const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-
|
|
4186
|
+
const { workActivity, readDevInfo, WORK_TTL_DEFAULT, WORK_TTL_MAX } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3932
4187
|
const tokenOk = () => {
|
|
3933
4188
|
const t = readDevInfo(root)?.token;
|
|
3934
4189
|
return !!t && req.headers["x-mv-work"] === t;
|
|
3935
4190
|
};
|
|
3936
4191
|
if (req.method === "GET") {
|
|
3937
4192
|
if (!ownerGated(req) && !tokenOk()) return json(res, 403, { error: "forbidden" });
|
|
3938
|
-
const { boardsShowing, activityClock } = await import("./work-
|
|
4193
|
+
const { boardsShowing, activityClock } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
3939
4194
|
const frames = workActivity.active();
|
|
3940
4195
|
return json(res, 200, {
|
|
3941
4196
|
frames,
|
|
@@ -3958,7 +4213,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3958
4213
|
if (!on && b.all === true) {
|
|
3959
4214
|
const done = workActivity.active().filter((f) => workActivity.has(f, "cli"));
|
|
3960
4215
|
if (done.length) {
|
|
3961
|
-
(await import("./marks-
|
|
4216
|
+
(await import("./marks-C8oX8kbE.mjs").then((n) => n.a)).recordChanged(root, devFrames(), done, { doc: false });
|
|
3962
4217
|
opts.notify?.("sh:marks");
|
|
3963
4218
|
}
|
|
3964
4219
|
workActivity.clearAll("cli");
|
|
@@ -3978,7 +4233,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3978
4233
|
for (const f of frames) on ? workActivity.mark(f, ttl, "cli") : workActivity.clear(f, "cli");
|
|
3979
4234
|
saveHolds(root, workActivity);
|
|
3980
4235
|
if (!on) {
|
|
3981
|
-
(await import("./marks-
|
|
4236
|
+
(await import("./marks-C8oX8kbE.mjs").then((n) => n.a)).recordChanged(root, devFrames(), frames, { doc: false });
|
|
3982
4237
|
opts.notify?.("sh:marks");
|
|
3983
4238
|
return json(res, 200, { frames: workActivity.active() });
|
|
3984
4239
|
}
|
|
@@ -4031,7 +4286,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4031
4286
|
} catch {
|
|
4032
4287
|
return json(res, 400, { error: "malformed JSON" });
|
|
4033
4288
|
}
|
|
4034
|
-
const { ACTIONS } = await import("./queue-
|
|
4289
|
+
const { ACTIONS } = await import("./queue-BLLfdlDw.mjs");
|
|
4035
4290
|
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? }" });
|
|
4036
4291
|
if ("kind" in b) return json(res, 400, { error: "a capture has no category" });
|
|
4037
4292
|
const { jamLive } = await Promise.resolve().then(() => live_exports);
|
|
@@ -4076,7 +4331,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4076
4331
|
if (!jamLive.session || !jamLive.view) return json(res, 409, { error: "jam is not running here" });
|
|
4077
4332
|
if (req.method === "GET") {
|
|
4078
4333
|
const ses = jamLive.view().session ?? null;
|
|
4079
|
-
const { readTalk, talkMinutes, recordFile } = await import("./session-
|
|
4334
|
+
const { readTalk, talkMinutes, recordFile } = await import("./session-DBF-nQvq.mjs").then((n) => n.s);
|
|
4080
4335
|
const folder = ses ? recordFile(root, ses.since, ses.id).replace(/[^/]+$/, "") : null;
|
|
4081
4336
|
return json(res, 200, {
|
|
4082
4337
|
session: ses,
|
|
@@ -4255,11 +4510,13 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4255
4510
|
}
|
|
4256
4511
|
if (path === "jam/capture" && req.method === "GET") {
|
|
4257
4512
|
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
4258
|
-
const { readCapture } = await import("./capture-
|
|
4513
|
+
const { readCapture } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
|
|
4259
4514
|
const id = url.searchParams.get("id") ?? "";
|
|
4260
4515
|
const cap = readCapture(root, id);
|
|
4261
4516
|
if (!cap) return json(res, 404, { error: "no such capture" });
|
|
4262
4517
|
const { jamLive } = await Promise.resolve().then(() => live_exports);
|
|
4518
|
+
const { captureWithdrawn } = await import("./queue-BLLfdlDw.mjs");
|
|
4519
|
+
if (jamLive.withdrawn?.(id) || captureWithdrawn(root, id, cap.record.context.board)) return json(res, 410, { error: "this capture was withdrawn - its comment was deleted" });
|
|
4263
4520
|
const card = jamLive.view?.().cards.find((c) => c.id === id);
|
|
4264
4521
|
return json(res, 200, {
|
|
4265
4522
|
record: cap.record,
|
|
@@ -4278,11 +4535,11 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4278
4535
|
} catch {
|
|
4279
4536
|
return json(res, 400, { error: "malformed JSON" });
|
|
4280
4537
|
}
|
|
4281
|
-
const { CAPTURE_ID, readCapture, addPicture, sweepPictures } = await import("./capture-
|
|
4538
|
+
const { CAPTURE_ID, readCapture, addPicture, sweepPictures } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
|
|
4282
4539
|
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? }" });
|
|
4283
4540
|
if (readCapture(root, b.capture)) return json(res, 409, { error: "that capture is sealed" });
|
|
4284
4541
|
const theme = typeof b.theme === "string" && /^[a-z0-9-]+$/i.test(b.theme) ? b.theme : "light";
|
|
4285
|
-
const { shootFrame } = await import("./shot-
|
|
4542
|
+
const { shootFrame } = await import("./shot-BqwkdtKn.mjs").then((n) => n.u);
|
|
4286
4543
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
4287
4544
|
const vp = typeof b.viewport === "string" ? opts.viewports?.[b.viewport] : void 0;
|
|
4288
4545
|
const dim = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
|
|
@@ -4331,7 +4588,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4331
4588
|
if (path === "jam/picture" && req.method === "GET") {
|
|
4332
4589
|
const site = String(req.headers["sec-fetch-site"] ?? "");
|
|
4333
4590
|
if (!ownerGated(req) && !(cookie(req, "mv_c") && (site === "same-origin" || site === "none"))) return json(res, 403, { error: "forbidden" });
|
|
4334
|
-
const { picturePath } = await import("./capture-
|
|
4591
|
+
const { picturePath } = await import("./capture-HaS-1or8.mjs").then((n) => n.i);
|
|
4335
4592
|
const p = picturePath(root, url.searchParams.get("id") ?? "");
|
|
4336
4593
|
if (!p) return json(res, 404, { error: "no such picture" });
|
|
4337
4594
|
const png = readFileSync(p.path);
|
|
@@ -4349,11 +4606,66 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4349
4606
|
stored: listBoards(join(root, "design", "comments"))
|
|
4350
4607
|
});
|
|
4351
4608
|
}
|
|
4609
|
+
if (path === "capabilities" && req.method === "GET") return json(res, 200, {
|
|
4610
|
+
delete: true,
|
|
4611
|
+
resolveAll: true
|
|
4612
|
+
});
|
|
4613
|
+
if (path === "comment-ownership" && req.method === "GET") {
|
|
4614
|
+
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
4615
|
+
const { ownership } = await import("./own-C8Mq0Hnf.mjs");
|
|
4616
|
+
return json(res, 200, { boards: ownership(root) });
|
|
4617
|
+
}
|
|
4618
|
+
if ((path === "comment-actions/resolve-all" || path === "comment-actions/undo") && req.method === "POST") {
|
|
4619
|
+
const { readDevInfo } = await import("./work-Nv-n2_Un.mjs").then((n) => n.o);
|
|
4620
|
+
const token = readDevInfo(root)?.token;
|
|
4621
|
+
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
4622
|
+
const raw = await readBody(req);
|
|
4623
|
+
if (raw == null) return json(res, 400, { error: "body too large" });
|
|
4624
|
+
let b;
|
|
4625
|
+
try {
|
|
4626
|
+
b = JSON.parse(raw);
|
|
4627
|
+
} catch {
|
|
4628
|
+
return json(res, 400, { error: "malformed JSON" });
|
|
4629
|
+
}
|
|
4630
|
+
const ca = await import("./comment-actions-Bxf9Ld4g.mjs");
|
|
4631
|
+
const { jamLive } = await Promise.resolve().then(() => live_exports);
|
|
4632
|
+
if (typeof b?.op !== "string" || !ca.OP_RE.test(b.op)) return json(res, 400, { error: "expected { op: <8-64 char token>, ... }" });
|
|
4633
|
+
if (path === "comment-actions/undo") {
|
|
4634
|
+
const u = ca.undoResolveAll(root, b.op);
|
|
4635
|
+
if ("error" in u) return json(res, u.status, { error: u.error });
|
|
4636
|
+
jamLive.poke?.();
|
|
4637
|
+
backgroundPush(root);
|
|
4638
|
+
return json(res, u.failed.length ? 207 : 200, {
|
|
4639
|
+
...u,
|
|
4640
|
+
summary: ca.undoSummary(u)
|
|
4641
|
+
});
|
|
4642
|
+
}
|
|
4643
|
+
const scope = ca.parseScope(b.scope);
|
|
4644
|
+
if (typeof scope === "string") return json(res, 400, { error: scope });
|
|
4645
|
+
const r = ca.resolveAll(root, b.op, scope, {
|
|
4646
|
+
busy: jamLive.busy,
|
|
4647
|
+
dryRun: b.dryRun === true
|
|
4648
|
+
});
|
|
4649
|
+
if ("error" in r) return json(res, r.status, { error: r.error });
|
|
4650
|
+
if (b.dryRun !== true) {
|
|
4651
|
+
jamLive.poke?.();
|
|
4652
|
+
backgroundPush(root);
|
|
4653
|
+
}
|
|
4654
|
+
return json(res, r.failed.length ? 207 : 200, {
|
|
4655
|
+
...r,
|
|
4656
|
+
summary: ca.resolveSummary(r)
|
|
4657
|
+
});
|
|
4658
|
+
}
|
|
4352
4659
|
const cm = /^comments\/([a-z0-9][a-z0-9-]*)$/.exec(path);
|
|
4353
4660
|
if (cm) {
|
|
4354
4661
|
const { appendEvents, readLog } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
|
|
4355
4662
|
const dir = join(root, "design", "comments");
|
|
4356
|
-
if (req.method === "GET")
|
|
4663
|
+
if (req.method === "GET") {
|
|
4664
|
+
const { deletedMessages, withoutDeletedWords } = await import("./events-Dieo1482.mjs").then((n) => n.i);
|
|
4665
|
+
const evs = readLog(dir, cm[1]);
|
|
4666
|
+
const gone = deletedMessages(evs);
|
|
4667
|
+
return json(res, 200, { events: evs.map((e) => withoutDeletedWords(e, gone)) });
|
|
4668
|
+
}
|
|
4357
4669
|
if (req.method === "POST") {
|
|
4358
4670
|
if (!ownerGated(req)) return json(res, 403, { error: "forbidden" });
|
|
4359
4671
|
const raw = await readBody(req);
|
|
@@ -4366,6 +4678,31 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4366
4678
|
}
|
|
4367
4679
|
const incoming = Array.isArray(b.events) ? b.events : [];
|
|
4368
4680
|
const me = localProfile(root);
|
|
4681
|
+
if (incoming.some((ev) => ev?.board !== void 0 && ev.board !== cm[1])) return json(res, 400, { error: "event board does not match the endpoint" });
|
|
4682
|
+
{
|
|
4683
|
+
const have = readLog(dir, cm[1]);
|
|
4684
|
+
const evIds = new Set(have.map((e) => e.id));
|
|
4685
|
+
const msgIds = new Set(have.filter((e) => (e.type === "create" || e.type === "reply") && e.commentId).map((e) => e.commentId));
|
|
4686
|
+
for (const ev of incoming) {
|
|
4687
|
+
if (ev?.type !== "create" && ev?.type !== "reply" || evIds.has(ev.id)) continue;
|
|
4688
|
+
if (typeof ev.commentId !== "string" || msgIds.has(ev.commentId)) return json(res, 409, { error: "a comment with that id already exists" });
|
|
4689
|
+
msgIds.add(ev.commentId);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
if (incoming.some((ev) => ev?.type === "edit" || ev?.type === "delete")) {
|
|
4693
|
+
const { ownsMessage } = await import("./own-C8Mq0Hnf.mjs");
|
|
4694
|
+
const { deletedMessages } = await import("./events-Dieo1482.mjs").then((n) => n.i);
|
|
4695
|
+
const log = readLog(dir, cm[1]);
|
|
4696
|
+
const gone = deletedMessages(log);
|
|
4697
|
+
const captures = new Set(log.filter((e) => e?.type === "create" && e.capture && e.commentId).map((e) => e.commentId));
|
|
4698
|
+
for (const ev of incoming) {
|
|
4699
|
+
if (ev?.type !== "edit" && ev?.type !== "delete") continue;
|
|
4700
|
+
if (typeof ev.commentId !== "string" || !ownsMessage(root, cm[1], ev.commentId)) return json(res, 403, { error: `only its author can ${ev.type} a comment` });
|
|
4701
|
+
if (ev.type === "edit" && gone.has(ev.commentId)) return json(res, 409, { error: "that comment was deleted" });
|
|
4702
|
+
if (ev.type === "edit" && captures.has(ev.commentId)) return json(res, 409, { error: "a capture is edited in Jam - here it can only be deleted" });
|
|
4703
|
+
if (ev.type === "edit" && (typeof ev.body !== "string" || !ev.body.trim())) return json(res, 400, { error: "an edit needs words - delete the comment instead" });
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4369
4706
|
const stamped = incoming.map((ev) => {
|
|
4370
4707
|
const { agent: _a, agentMeta: _am, origin: _o, ...clean } = ev;
|
|
4371
4708
|
return {
|
|
@@ -4375,20 +4712,24 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4375
4712
|
"create",
|
|
4376
4713
|
"reply",
|
|
4377
4714
|
"react",
|
|
4378
|
-
"edit"
|
|
4715
|
+
"edit",
|
|
4716
|
+
"delete"
|
|
4379
4717
|
].includes(clean.type) ? me : void 0)
|
|
4380
4718
|
};
|
|
4381
4719
|
});
|
|
4382
|
-
const fresh = appendEvents(dir, cm[1], stamped);
|
|
4383
4720
|
const { record } = await import("./ledger-D54iROST.mjs").then((n) => n.n);
|
|
4721
|
+
const { recordOwn } = await import("./own-C8Mq0Hnf.mjs");
|
|
4722
|
+
const fresh = appendEvents(dir, cm[1], stamped);
|
|
4384
4723
|
for (const ev of fresh) if (ev.type === "create" || ev.type === "reply" || ev.type === "edit") record(root, cm[1], ev.id);
|
|
4724
|
+
const mine = fresh.filter((ev) => (ev.type === "create" || ev.type === "reply") && typeof ev.commentId === "string").map((ev) => ev.commentId);
|
|
4725
|
+
if (mine.length) recordOwn(root, cm[1], mine);
|
|
4385
4726
|
(await Promise.resolve().then(() => live_exports)).jamLive.poke?.();
|
|
4386
4727
|
backgroundPush(root);
|
|
4387
4728
|
return json(res, 200, { accepted: fresh.length });
|
|
4388
4729
|
}
|
|
4389
4730
|
}
|
|
4390
4731
|
if (path === "sync" && req.method === "POST") {
|
|
4391
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
4732
|
+
const { loadCollab, syncOnce } = await import("./sync-BNWwh8OF.mjs").then((n) => n.o);
|
|
4392
4733
|
const collab = loadCollab(root);
|
|
4393
4734
|
if (!collab) return json(res, 200, { connected: false });
|
|
4394
4735
|
try {
|
|
@@ -4417,13 +4758,29 @@ function backgroundPush(root) {
|
|
|
4417
4758
|
pushTimer = setTimeout(async () => {
|
|
4418
4759
|
pushTimer = null;
|
|
4419
4760
|
try {
|
|
4420
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
4761
|
+
const { loadCollab, syncOnce } = await import("./sync-BNWwh8OF.mjs").then((n) => n.o);
|
|
4421
4762
|
const collab = loadCollab(root);
|
|
4422
4763
|
if (collab) await syncOnce(root, collab);
|
|
4423
4764
|
} catch {}
|
|
4424
4765
|
}, 1500);
|
|
4425
4766
|
}
|
|
4426
4767
|
//#endregion
|
|
4768
|
+
//#region src/server/pdf-reset.ts
|
|
4769
|
+
/**
|
|
4770
|
+
* The dev server's restart and close reach deck PDF jobs through this hook (spec 31): plugin.ts calls `resetPdf(root)`
|
|
4771
|
+
* without loading pdf.ts (and pdf-lib) on a canvas that never exported; pdf.ts registers itself when it first loads.
|
|
4772
|
+
*/
|
|
4773
|
+
let reset = null;
|
|
4774
|
+
function onPdfReset(fn) {
|
|
4775
|
+
reset = fn;
|
|
4776
|
+
}
|
|
4777
|
+
/** Cancel this canvas's running PDF job (its browser closes) and forget its jobs. A no-op until pdf.ts has loaded. */
|
|
4778
|
+
function resetPdf(root) {
|
|
4779
|
+
try {
|
|
4780
|
+
reset?.(root);
|
|
4781
|
+
} catch {}
|
|
4782
|
+
}
|
|
4783
|
+
//#endregion
|
|
4427
4784
|
//#region src/server/routes.ts
|
|
4428
4785
|
function routesMiddleware(server, clientDir, stamps, proof) {
|
|
4429
4786
|
const page = (dir) => {
|
|
@@ -4917,7 +5274,7 @@ function marverPlugin(ctx) {
|
|
|
4917
5274
|
/** a watcher this plugin makes, handed to the start (its error is said, not Node's crash) - as it is, outside one */
|
|
4918
5275
|
const guarded = (w) => ctx.startup?.watch?.(w) ?? w;
|
|
4919
5276
|
let project = {
|
|
4920
|
-
name:
|
|
5277
|
+
name: canvasIdentity(root, config).local,
|
|
4921
5278
|
description: config.description
|
|
4922
5279
|
};
|
|
4923
5280
|
const projectInfo = () => project;
|
|
@@ -5117,7 +5474,8 @@ function marverPlugin(ctx) {
|
|
|
5117
5474
|
zoomSpeed: config.zoomSpeed,
|
|
5118
5475
|
noTheme: themeFile() == null,
|
|
5119
5476
|
setup: setupPending,
|
|
5120
|
-
|
|
5477
|
+
devices: config.devices,
|
|
5478
|
+
projectName: canvasIdentity(root, config).local,
|
|
5121
5479
|
branding: config.share.branding,
|
|
5122
5480
|
jam: config.jam ? {
|
|
5123
5481
|
chime: config.jam.chime,
|
|
@@ -5224,18 +5582,34 @@ function marverPlugin(ctx) {
|
|
|
5224
5582
|
});
|
|
5225
5583
|
server.middlewares.use((req, res, next) => {
|
|
5226
5584
|
if (new URL(req.url ?? "/", "http://x").pathname !== `/__mv/api/update`) return next();
|
|
5227
|
-
update.then((
|
|
5585
|
+
update.then(() => updateStatus(root)).then((u) => {
|
|
5228
5586
|
res.setHeader("content-type", "application/json");
|
|
5229
5587
|
res.setHeader("cache-control", "no-store");
|
|
5230
|
-
res.end(JSON.stringify(
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
})
|
|
5588
|
+
res.end(JSON.stringify(u));
|
|
5589
|
+
}, () => {
|
|
5590
|
+
res.statusCode = 500;
|
|
5591
|
+
res.end("{}");
|
|
5234
5592
|
});
|
|
5235
5593
|
});
|
|
5236
5594
|
const listeningOrigin = () => originOf(server.httpServer?.address());
|
|
5237
5595
|
initMarks(root, manifest.frames);
|
|
5238
5596
|
tidyPerfDir(root);
|
|
5597
|
+
resetPdf(root);
|
|
5598
|
+
try {
|
|
5599
|
+
if (!checkRealDirs(root, [
|
|
5600
|
+
[join(root, "design"), "design"],
|
|
5601
|
+
[join(root, "design", ".local"), "design/.local"],
|
|
5602
|
+
[join(root, "design", ".local", "pdf"), "design/.local/pdf"]
|
|
5603
|
+
])) rmSync(join(root, "design", ".local", "pdf"), {
|
|
5604
|
+
recursive: true,
|
|
5605
|
+
force: true
|
|
5606
|
+
});
|
|
5607
|
+
} catch {}
|
|
5608
|
+
server.httpServer?.once("close", () => resetPdf(root));
|
|
5609
|
+
server.middlewares.use((req, res, next) => {
|
|
5610
|
+
if (!(req.url ?? "").startsWith(`/__mv/handout/`)) return next();
|
|
5611
|
+
import("./pdf-CZENT6t3.mjs").then((m) => m.handoutMiddleware()(req, res, next), next);
|
|
5612
|
+
});
|
|
5239
5613
|
server.middlewares.use(apiMiddleware(root, {
|
|
5240
5614
|
viewports: config.viewports,
|
|
5241
5615
|
origin: listeningOrigin,
|
|
@@ -5244,12 +5618,15 @@ function marverPlugin(ctx) {
|
|
|
5244
5618
|
server.ws.send(event, {});
|
|
5245
5619
|
liveChanged();
|
|
5246
5620
|
},
|
|
5621
|
+
broadcast: (event, payload) => server.ws.send(event, payload),
|
|
5247
5622
|
manifest: () => manifest,
|
|
5248
5623
|
settled,
|
|
5249
5624
|
workspace: ws,
|
|
5250
|
-
inputs
|
|
5625
|
+
inputs,
|
|
5626
|
+
themes: config.themes,
|
|
5627
|
+
canvasName: () => canvasIdentity(root, config).local
|
|
5251
5628
|
}));
|
|
5252
|
-
server.middlewares.use(logoRoute(root, () => config.
|
|
5629
|
+
server.middlewares.use(logoRoute(root, () => canvasIdentity(root, config).logos, ctx.proof));
|
|
5253
5630
|
server.middlewares.use(routesMiddleware(server, clientDir, {
|
|
5254
5631
|
doc: (id) => docRev(root, manifest.frames, id),
|
|
5255
5632
|
docs: () => docRevs(root, manifest.frames)
|
|
@@ -5376,7 +5753,7 @@ function marverPlugin(ctx) {
|
|
|
5376
5753
|
if (f !== configFile) return;
|
|
5377
5754
|
loadConfig(root).then((c) => {
|
|
5378
5755
|
project = {
|
|
5379
|
-
name:
|
|
5756
|
+
name: canvasIdentity(root, c).local,
|
|
5380
5757
|
description: c.description
|
|
5381
5758
|
};
|
|
5382
5759
|
regen();
|
|
@@ -5517,7 +5894,7 @@ function marverPlugin(ctx) {
|
|
|
5517
5894
|
});
|
|
5518
5895
|
return;
|
|
5519
5896
|
}
|
|
5520
|
-
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-
|
|
5897
|
+
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-BqwkdtKn.mjs").then((n) => n.u);
|
|
5521
5898
|
if (ways[0] === "frame") {
|
|
5522
5899
|
if (typeof spec.frame !== "string") {
|
|
5523
5900
|
write({
|
|
@@ -5688,4 +6065,4 @@ async function tailwind3Css(root) {
|
|
|
5688
6065
|
return null;
|
|
5689
6066
|
}
|
|
5690
6067
|
//#endregion
|
|
5691
|
-
export { live_exports as a,
|
|
6068
|
+
export { live_exports as a, installedVersion as c, canvasIdentity as d, identityNudge as f, jamLive as i, ASK_MAX as l, tailwind3Css as n, liveChanged as o, tailwind4Plugin as r, onPdfReset as s, marverPlugin as t, bakeBatch as u };
|