@marver-design/marver 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{anchor-check-c52IDkiQ.mjs → anchor-check-Bv4o-R2T.mjs} +1 -1
- package/dist/{build-C3mUtjEn.mjs → build-zWGXSzly.mjs} +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/{daemon-B0Wi1OQ3.mjs → daemon-CChgWJNq.mjs} +2 -4
- package/dist/{dev-5dlxoW28.mjs → dev-DOgIITpT.mjs} +7 -7
- package/dist/{plugin-CXRoMA8g.mjs → plugin-CFWBcAba.mjs} +67 -37
- package/dist/{poster-CYmCa00B.mjs → poster-DPPpQiva.mjs} +1 -1
- package/dist/{publish-bakes-C_2ZtHou.mjs → publish-bakes-_Zx8crP3.mjs} +2 -2
- package/dist/{recover-XD8iXJOj.mjs → recover-mDUVsnPd.mjs} +1 -1
- package/dist/{shot-CRRGgxru.mjs → shot-d4h_hJi9.mjs} +2 -2
- package/docs/performance.md +2 -1
- package/package.json +1 -1
- package/src/client/shell/recorder.ts +3 -2
- package/src/client/shell/store.ts +56 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@marver-design/marver`. Format follows [Keep a Changelog](https://keepachangelog.com); versions follow semver.
|
|
4
4
|
|
|
5
|
+
## 0.30.1 - 2026-11-09
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Your board no longer reloads when an agent changes it.** When the board file changed on disk (an agent moving or
|
|
10
|
+
adding a frame, `boards place`), every frame on the board reloaded about ten seconds later, and all at once on a second
|
|
11
|
+
write. Now the frames stay as they are and only what the file changed moves: on a 53-frame board, one outside write
|
|
12
|
+
reloaded all 53 frames, now none. A frame that had failed or never answered still loads once more, and one whose
|
|
13
|
+
width the file changed reloads at the new width.
|
|
14
|
+
- **Saving a note no longer redraws your board.** With Tailwind v4, saving a file Tailwind only scans for classes - a
|
|
15
|
+
`.md` note, a `_brief.md`, `context/`, `design/publish.json`, app code no frame imports - redrew every frame on the
|
|
16
|
+
board. Now nothing redraws, and new classes still reach open frames in place. A frame whose stylesheet cannot take
|
|
17
|
+
them in place (one imported with `?inline`, an HTML frame) still reloads.
|
|
18
|
+
- **[Performance](docs/performance.md) records tell a frame loaded again from one that stayed:** only a frame whose
|
|
19
|
+
document stood through a board read is marked `kept`.
|
|
20
|
+
|
|
5
21
|
## 0.30.0 - 2026-11-04
|
|
6
22
|
|
|
7
23
|
### Highlights
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as frameUrl, d as withBrowser, n as MOUNTED, o as manifestFrame, s as planShot } from "./shot-
|
|
1
|
+
import { a as frameUrl, d as withBrowser, n as MOUNTED, o as manifestFrame, s as planShot } from "./shot-d4h_hJi9.mjs";
|
|
2
2
|
//#region src/server/anchor-check.ts
|
|
3
3
|
/**
|
|
4
4
|
* The anchor check (spec 26, Part 6): `comments new --on|--at`, `comments move` and a Live Jam re-pin
|
|
@@ -5,7 +5,7 @@ import { g as PUBLISHABLE, s as scanFrames, v as publishableStatus } from "./man
|
|
|
5
5
|
import { a as readLog, o as shareable, r as legacyExposure, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
6
6
|
import { t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
7
7
|
import { n as loadConfig } from "./config-BezZTiov.mjs";
|
|
8
|
-
import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-
|
|
8
|
+
import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-CFWBcAba.mjs";
|
|
9
9
|
import { i as measuringFrames, n as autoWidthOf, o as readSizes, r as keptSizes } from "./sizes-wjXDev3b.mjs";
|
|
10
10
|
import { i as publishLogo, n as logoIcons } from "./logo-CXY-1yrn.mjs";
|
|
11
11
|
import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -789,7 +789,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
|
|
|
789
789
|
const realAssets = existsSync(assetsDir) ? realpathSync(assetsDir) : null;
|
|
790
790
|
for (const r of refs) {
|
|
791
791
|
if (!isLocalAssetRef(r) || !r.endsWith(".poster.png") || existsSync(join(assetsDir, r))) continue;
|
|
792
|
-
const { ensurePoster } = await import("./poster-
|
|
792
|
+
const { ensurePoster } = await import("./poster-DPPpQiva.mjs");
|
|
793
793
|
const g = await ensurePoster(assetsDir, r.slice(0, -11));
|
|
794
794
|
if (!g.ok) throw new Error(`design/assets/${r}: ${g.error}`);
|
|
795
795
|
console.log(` poster: rendered design/assets/${r} (${g.width}×${g.height})`);
|
|
@@ -852,7 +852,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
|
|
|
852
852
|
}));
|
|
853
853
|
let textureLine = " textures: skipped (--no-textures)";
|
|
854
854
|
if (textures && bakeGen) {
|
|
855
|
-
const { bakePublished } = await import("./publish-bakes-
|
|
855
|
+
const { bakePublished } = await import("./publish-bakes-_Zx8crP3.mjs");
|
|
856
856
|
const pubFrameFile = new Map(pubFrames.map((f) => [f.id, f]));
|
|
857
857
|
const r = await bakePublished({
|
|
858
858
|
root,
|
package/dist/cli.mjs
CHANGED
|
@@ -90,7 +90,7 @@ cli.command("init", "Scaffold design/ in this repo").option("--mode <mode>", "st
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot reload, comments, Live Jam)"], ["canvas", "Start the local canvas - same as dev"]]) cli.command(name, desc).option("--root <dir>", "Host repo root", { default: "." }).option("--port <port>", "A port of its own (default: a free slot, localhost:4805-4824 - usually the same one next time; a port in that range takes exactly that slot)").option("--recover [n]", "Run on an address this canvas had before, where an unsent Jam capture waits: alone it lists them; with a number it starts on that one; --recover --port <p>: the port 0.26 used").action(async (opts) => {
|
|
93
|
-
const { dev, DevStartError, DevLockError } = await import("./dev-
|
|
93
|
+
const { dev, DevStartError, DevLockError } = await import("./dev-DOgIITpT.mjs");
|
|
94
94
|
let port;
|
|
95
95
|
if (opts.port !== void 0) {
|
|
96
96
|
const n = Number(opts.port);
|
|
@@ -102,7 +102,7 @@ for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot
|
|
|
102
102
|
process.exit(1);
|
|
103
103
|
};
|
|
104
104
|
try {
|
|
105
|
-
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-
|
|
105
|
+
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-mDUVsnPd.mjs")).recoverCommand(resolve$1(opts.root), opts.recover, port, { onFail });
|
|
106
106
|
else await dev(resolve$1(opts.root), {
|
|
107
107
|
port,
|
|
108
108
|
onFail
|
|
@@ -118,7 +118,7 @@ cli.command("ls", "The canvases running on this Mac: slot, link, name, version,
|
|
|
118
118
|
(await import("./ls-NqmePKOf.mjs")).lsCommand({ json: opts.json === true });
|
|
119
119
|
});
|
|
120
120
|
cli.command("build", "Static export → design/.dist (what ships comes from design/publish.json - publishing is default-closed)").option("--boards <names>", "Publish only these boards (comma-separated); overrides the publish policy").option("--all-boards", "Publish every board - the loud override for the default-closed policy").option("--embed-seeds", "Copy comment history INTO the web root (identifying - every event carries its author's email)").option("--no-textures", "Skip compiling the glass textures the published frames rest under (needs Chrome; a CI without one skips on its own)").option("--root <dir>", "Host repo root", { default: "." }).action(async (opts) => {
|
|
121
|
-
const { buildSite } = await import("./build-
|
|
121
|
+
const { buildSite } = await import("./build-zWGXSzly.mjs");
|
|
122
122
|
try {
|
|
123
123
|
const boards = opts.boards === void 0 ? void 0 : typeof opts.boards === "string" ? opts.boards : "";
|
|
124
124
|
await buildSite(resolve$1(opts.root), boards, opts.allBoards === true, opts.embedSeeds === true, opts.textures !== false && !process.env.MARVER_NO_TEXTURES);
|
|
@@ -13,7 +13,7 @@ import { C as refusedAsk, S as parseMembers, T as sharedWhy, _ as wordsUntil, a
|
|
|
13
13
|
import { a as recordFile, c as storeWrapup, i as readWrapup, n as buildWrapup, o as recordPathProblem, r as moreOf, t as SESSION_ID } from "./session-VDJfXEEm.mjs";
|
|
14
14
|
import { act, addCapture, addWrapup, answeredSince, beginStep, captureComment, captureIntact, conflictStep, createQueue, ctxFor, endSession, endStep, fail, failCard, form, joinAlone, looksGood, moreWrapup, n as releaseLock, ownerOnly, payloadKey, pending, prune, redelivering, requeue, runsAlone, sameComment, settle, startSession, stillOwned, t as acquireLock, textOf, undelivered, wrapupIntact, wrapupOf } from "./queue-DeSQm24g.mjs";
|
|
15
15
|
import { d as logJam } from "./perf-BCxAo0IS.mjs";
|
|
16
|
-
import { i as jamLive } from "./plugin-
|
|
16
|
+
import { i as jamLive } from "./plugin-CFWBcAba.mjs";
|
|
17
17
|
import { t as PROTECTED_GLOBS } from "./permit-DDa6wqOs.mjs";
|
|
18
18
|
import { jamReservations, restoreHolds } from "./reserve-BURNQ2Y3.mjs";
|
|
19
19
|
import { closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
@@ -1101,9 +1101,7 @@ const STALL_MS = 9e5;
|
|
|
1101
1101
|
* MARVER_SLOT_BASE set (test-build.ts; as perf-run.ts's MV_PERF_RUN_T): a real stall in seconds, so a browser case
|
|
1102
1102
|
* drives one through this daemon and the page's own actions. */
|
|
1103
1103
|
const stallMs = () => {
|
|
1104
|
-
|
|
1105
|
-
const v = Number(process.env.MV_JAM_STALL_MS);
|
|
1106
|
-
return Number.isFinite(v) && v > 0 ? v : STALL_MS;
|
|
1104
|
+
return STALL_MS;
|
|
1107
1105
|
};
|
|
1108
1106
|
/** How long a request's answer is kept for the same request sent again. */
|
|
1109
1107
|
const RECEIPT_MS = 6e5;
|
|
@@ -2,7 +2,7 @@ import { i as PKG, r as NAME } from "./cli.mjs";
|
|
|
2
2
|
import { _ as runIdentity, a as notePrefer, c as ranDevBefore, f as startedWhere, i as marverHome, o as originOf, p as stopPrefer, s as place, t as forgetDevTraces } from "./slots-Dn4Onb0V.mjs";
|
|
3
3
|
import { t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
4
4
|
import { n as loadConfig } from "./config-BezZTiov.mjs";
|
|
5
|
-
import { n as tailwind3Css, o as liveChanged, r as tailwind4Plugin, s as installedVersion, t as marverPlugin } from "./plugin-
|
|
5
|
+
import { n as tailwind3Css, o as liveChanged, r as tailwind4Plugin, s as installedVersion, t as marverPlugin } from "./plugin-CFWBcAba.mjs";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch, writeSync } from "node:fs";
|
|
7
7
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -1019,7 +1019,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1019
1019
|
if (fromConfig !== void 0 && !placed.fellBackFrom) console.log(` this canvas keeps its own port (${fromConfig} in design/config.ts); remove it to use the slots\n`);
|
|
1020
1020
|
setTimeout(async () => {
|
|
1021
1021
|
try {
|
|
1022
|
-
await (await import("./shot-
|
|
1022
|
+
await (await import("./shot-d4h_hJi9.mjs").then((n) => n.u)).sweepGhosts((m) => console.log(` ${m}`));
|
|
1023
1023
|
} catch {}
|
|
1024
1024
|
}, 0);
|
|
1025
1025
|
try {
|
|
@@ -1101,8 +1101,8 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1101
1101
|
} catch {}
|
|
1102
1102
|
}
|
|
1103
1103
|
if (config.jam) {
|
|
1104
|
-
const { startJam } = await import("./daemon-
|
|
1105
|
-
const { checkAnchor } = await import("./anchor-check-
|
|
1104
|
+
const { startJam } = await import("./daemon-CChgWJNq.mjs");
|
|
1105
|
+
const { checkAnchor } = await import("./anchor-check-Bv4o-R2T.mjs");
|
|
1106
1106
|
const jam = startJam(root, config.jam, (m) => console.log(m), (board) => {
|
|
1107
1107
|
server.ws.send("sh:jam-comment", { board });
|
|
1108
1108
|
liveChanged();
|
|
@@ -1119,13 +1119,13 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1119
1119
|
return () => {
|
|
1120
1120
|
due ??= setTimeout(async () => {
|
|
1121
1121
|
due = null;
|
|
1122
|
-
const { jamLive } = await import("./plugin-
|
|
1122
|
+
const { jamLive } = await import("./plugin-CFWBcAba.mjs").then((n) => n.a);
|
|
1123
1123
|
server.ws.send("sh:jam-queue", jamLive.view?.() ?? { cards: [] });
|
|
1124
1124
|
liveChanged();
|
|
1125
1125
|
}, 60);
|
|
1126
1126
|
};
|
|
1127
1127
|
})(), async (frameId, theme, entry, size) => {
|
|
1128
|
-
const { shootFrame } = await import("./shot-
|
|
1128
|
+
const { shootFrame } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
|
|
1129
1129
|
const r = await shootFrame({
|
|
1130
1130
|
root,
|
|
1131
1131
|
viewports: config.viewports,
|
|
@@ -1146,7 +1146,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1146
1146
|
t.defer(() => jam.stop());
|
|
1147
1147
|
if (config.jam.session !== false) try {
|
|
1148
1148
|
const { ensureConnectors, connectorLine } = await import("./connectors-DekQvKt9.mjs");
|
|
1149
|
-
const { jamLive } = await import("./plugin-
|
|
1149
|
+
const { jamLive } = await import("./plugin-CFWBcAba.mjs").then((n) => n.a);
|
|
1150
1150
|
const results = ensureConnectors(root);
|
|
1151
1151
|
jamLive.connectors = results;
|
|
1152
1152
|
const line = connectorLine(results);
|
|
@@ -12,7 +12,7 @@ import { c as recordChanged, i as initMarks, n as docRevs, o as observe, r as fr
|
|
|
12
12
|
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-BCxAo0IS.mjs";
|
|
13
13
|
import { n as loadConfig } from "./config-BezZTiov.mjs";
|
|
14
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-wjXDev3b.mjs";
|
|
15
|
-
import { c as pool, d as withBrowser, f as Browser, l as shotConcurrency, m as launchFlags, r as SURFACE, t as AREA } from "./shot-
|
|
15
|
+
import { c as pool, d as withBrowser, f as Browser, l as shotConcurrency, m as launchFlags, r as SURFACE, t as AREA } from "./shot-d4h_hJi9.mjs";
|
|
16
16
|
import { a as appProofOk, o as proofHeaders, r as logoRoute } from "./logo-CXY-1yrn.mjs";
|
|
17
17
|
import { closeSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, watch, writeFileSync } from "node:fs";
|
|
18
18
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -21,6 +21,7 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
21
21
|
import { arch, cpus, totalmem } from "node:os";
|
|
22
22
|
import { execFile } from "node:child_process";
|
|
23
23
|
import { stat } from "node:fs/promises";
|
|
24
|
+
import { isCSSRequest } from "vite";
|
|
24
25
|
//#region src/shared/frames.ts
|
|
25
26
|
/** A canvas made of content frames alone (Doc, Md, Diagram ship their own styling) needs no theme -
|
|
26
27
|
* only an app frame does (#4). Empty counts as not content-only: the warning still helps there. */
|
|
@@ -43,8 +44,12 @@ const contentOnly = (frames) => frames.length > 0 && frames.every((f) => !!f.int
|
|
|
43
44
|
* has been applied in place: the frames past it are touched (marked) but not reloaded.
|
|
44
45
|
*
|
|
45
46
|
* Every other `full-reload` Vite or Tailwind sends is dropped and becomes reloads of the frames it
|
|
46
|
-
* names
|
|
47
|
-
*
|
|
47
|
+
* names - the shell never reloads for a design edit. One that names nothing, sent while a file no
|
|
48
|
+
* document imports is being handled, is Tailwind's for a file it only scans (a note, app code): the
|
|
49
|
+
* stylesheet is pushed in place and only the frames the marks find changed reload - with the frames of
|
|
50
|
+
* a stylesheet that cannot take its update in place, and every HTML frame. Named nothing
|
|
51
|
+
* otherwise, every frame reloads: the sender is unknown. The one that passes is the dependency
|
|
52
|
+
* optimiser's: module URLs changed, every document must reload.
|
|
48
53
|
*/
|
|
49
54
|
const safeReal = (p) => {
|
|
50
55
|
try {
|
|
@@ -127,9 +132,36 @@ function updatesPlugin(root, manifest, hooks, landed, changes) {
|
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
}
|
|
130
|
-
/** Wraps the client's hot channel: the reload guard and refused refreshes.
|
|
131
|
-
|
|
135
|
+
/** Wraps the client's hot channel: the reload guard and refused refreshes. `onStyles`: this server's, for a scanned file no
|
|
136
|
+
* document imports - it names the stylesheets that scan it, any of which may have new classes; no frame needs a reload. */
|
|
137
|
+
function guardUpdates(server, root, manifest, hooks, changes, onStyles) {
|
|
132
138
|
const env = server.environments.client;
|
|
139
|
+
const notImported = (file) => [...env.moduleGraph.getModulesByFile(file) ?? []].every((m) => m.id == null || m.type === "asset");
|
|
140
|
+
const sheetsOf = (files) => {
|
|
141
|
+
const push = /* @__PURE__ */ new Set(), refused = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set();
|
|
142
|
+
const up = files.flatMap((f) => [...env.moduleGraph.getModulesByFile(f) ?? []]);
|
|
143
|
+
while (up.length) {
|
|
144
|
+
const m = up.shift();
|
|
145
|
+
if (seen.has(m)) continue;
|
|
146
|
+
seen.add(m);
|
|
147
|
+
for (const by of m.importers) {
|
|
148
|
+
if (!isCSSRequest(by.id ?? by.url)) continue;
|
|
149
|
+
if (by.isSelfAccepting === true && by.file) push.add(by.file);
|
|
150
|
+
else refused.add(by);
|
|
151
|
+
up.push(by);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const reload = /* @__PURE__ */ new Set();
|
|
155
|
+
for (const m of refused) {
|
|
156
|
+
const t = framesFor(root, manifest(), m.file ?? "", [m]);
|
|
157
|
+
for (const id of [...t.doc, ...t.touched]) reload.add(id);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
push: [...push],
|
|
161
|
+
reload
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
const htmlFrames = () => manifest().frames.filter((f) => f.kind === "html").map((f) => f.id);
|
|
133
165
|
const wrap = (ch) => {
|
|
134
166
|
const send = ch.send.bind(ch);
|
|
135
167
|
ch.send = (...a) => {
|
|
@@ -144,14 +176,18 @@ function guardUpdates(server, root, manifest, hooks, changes) {
|
|
|
144
176
|
}, passed, at);
|
|
145
177
|
if (!passed) {
|
|
146
178
|
const mods = by ? env.moduleGraph.getModulesByFile(by) : void 0;
|
|
147
|
-
const
|
|
179
|
+
const scanned = by ? [] : changes.handling().filter(notImported);
|
|
180
|
+
const all = () => manifest().frames.map((f) => f.id);
|
|
181
|
+
const sheets = scanned.length ? sheetsOf(scanned) : null;
|
|
182
|
+
const doc = sheets ? [.../* @__PURE__ */ new Set([...sheets.reload, ...htmlFrames()])] : all();
|
|
148
183
|
const t = by ? framesFor(root, manifest(), by, mods ?? []) : {
|
|
149
184
|
file: "",
|
|
150
|
-
doc
|
|
185
|
+
doc,
|
|
151
186
|
touched: [],
|
|
152
187
|
unattributed: true
|
|
153
188
|
};
|
|
154
|
-
if (
|
|
189
|
+
if (sheets) onStyles(sheets.push);
|
|
190
|
+
if (t.doc.length || t.touched.length || scanned.length) hooks.onFrames(t, "reload", at);
|
|
155
191
|
return;
|
|
156
192
|
}
|
|
157
193
|
}
|
|
@@ -303,6 +339,10 @@ function createChanges(o) {
|
|
|
303
339
|
candidates: bounded(ids(flying))
|
|
304
340
|
};
|
|
305
341
|
},
|
|
342
|
+
/** The files whose hot update is running right now: a pathless reload was sent for one of these. */
|
|
343
|
+
handling() {
|
|
344
|
+
return [...brackets].map((t) => t.file);
|
|
345
|
+
},
|
|
306
346
|
/** A page-wide reload that names its file (Vite's dead end, an HTML page), sent after the file's hooks: that file's
|
|
307
347
|
* token still in flight - no time-window guess. */
|
|
308
348
|
ofFile(file) {
|
|
@@ -766,7 +806,7 @@ async function bakeIn(b, opts) {
|
|
|
766
806
|
const deadline = setTimeout(() => {
|
|
767
807
|
timedOut = true;
|
|
768
808
|
b.abort(me, TIMED_OUT);
|
|
769
|
-
},
|
|
809
|
+
}, DEADLINE_MS);
|
|
770
810
|
const closeTarget = async (id) => {
|
|
771
811
|
let t;
|
|
772
812
|
await Promise.race([b.send("Target.closeTarget", { targetId: id }).catch(() => {}), new Promise((r) => {
|
|
@@ -1251,13 +1291,11 @@ function endRunBakes(owner) {
|
|
|
1251
1291
|
* looks at a COMPILING outlast any held compile (A3.8 r1 #4's case, added by the review of a3-runs). */
|
|
1252
1292
|
const bakeSeams = {};
|
|
1253
1293
|
const holdMs = () => {
|
|
1254
|
-
|
|
1255
|
-
const v = process.env.MARVER_SLOT_BASE ? Number(process.env.MV_BAKE_HOLD_MS) : NaN;
|
|
1256
|
-
return Number.isFinite(v) && v > 0 ? Math.min(v, 6e4) : 0;
|
|
1294
|
+
return 0;
|
|
1257
1295
|
};
|
|
1258
1296
|
/** The suite's answer for a compile still running, under MV_BAKE_STOP_ASKING (above). */
|
|
1259
1297
|
const STOP_ASKING = "still compiling - the suite asks the page to stop asking";
|
|
1260
|
-
const stillCompiling = () =>
|
|
1298
|
+
const stillCompiling = () => COMPILING;
|
|
1261
1299
|
/** Compiles in flight, by generation and key: identical asks - inside one request or across
|
|
1262
1300
|
* concurrent ones - share one compile. */
|
|
1263
1301
|
const inflight = /* @__PURE__ */ new Map();
|
|
@@ -2033,17 +2071,7 @@ const runSeams = {};
|
|
|
2033
2071
|
/** RUN_T, with the suite's overrides: `runSeams.t` in-process, `MV_PERF_RUN_T` (JSON) for a dev server a test starts -
|
|
2034
2072
|
* both read only with MARVER_SLOT_BASE set (the suite's marker). */
|
|
2035
2073
|
function runT() {
|
|
2036
|
-
|
|
2037
|
-
if (!process.env.MARVER_SLOT_BASE) return t;
|
|
2038
|
-
let env = {};
|
|
2039
|
-
try {
|
|
2040
|
-
env = JSON.parse(process.env.MV_PERF_RUN_T ?? "{}");
|
|
2041
|
-
} catch {}
|
|
2042
|
-
for (const src of [env, runSeams.t ?? {}]) for (const k of Object.keys(t)) {
|
|
2043
|
-
const v = src[k];
|
|
2044
|
-
if (typeof v === "number" && v >= 0) t[k] = v;
|
|
2045
|
-
}
|
|
2046
|
-
return t;
|
|
2074
|
+
return { ...RUN_T };
|
|
2047
2075
|
}
|
|
2048
2076
|
/** The shell's address for a run's load: its run id, the warm-up's mark, the recorder's level when not `full` (spec 30
|
|
2049
2077
|
* #58: the shell reads it, `withWs()` carries it to the frames), the board. */
|
|
@@ -2111,7 +2139,6 @@ async function openPage(b, o) {
|
|
|
2111
2139
|
}
|
|
2112
2140
|
};
|
|
2113
2141
|
function call(m, p = {}, sid, ms = T.callMs) {
|
|
2114
|
-
runSeams.cdp?.(m, p);
|
|
2115
2142
|
const sent = b.send(m, p, sid, own);
|
|
2116
2143
|
let t;
|
|
2117
2144
|
const late = new Promise((_, reject) => {
|
|
@@ -2175,7 +2202,6 @@ async function openPage(b, o) {
|
|
|
2175
2202
|
async function closePage(b, page) {
|
|
2176
2203
|
page.stop();
|
|
2177
2204
|
const bounded = async (m, p, sid) => {
|
|
2178
|
-
runSeams.cdp?.(m, p);
|
|
2179
2205
|
let t;
|
|
2180
2206
|
await Promise.race([b.send(m, p, sid).catch(() => {}), new Promise((r) => {
|
|
2181
2207
|
t = setTimeout(r, 2e3);
|
|
@@ -2700,7 +2726,7 @@ async function serveRun(req, res, o) {
|
|
|
2700
2726
|
};
|
|
2701
2727
|
const beat = setInterval(() => write({ heartbeat: Date.now() }), T.heartbeatMs);
|
|
2702
2728
|
try {
|
|
2703
|
-
const drive =
|
|
2729
|
+
const drive = runOnce;
|
|
2704
2730
|
for (let i = 0; i < asked.req.repeat && !ac.signal.aborted; i++) write({ line: await drive({
|
|
2705
2731
|
root: o.root,
|
|
2706
2732
|
origin: o.origin,
|
|
@@ -3645,7 +3671,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3645
3671
|
};
|
|
3646
3672
|
const asPng = url.searchParams.get("format") === "png";
|
|
3647
3673
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3648
|
-
const { shootFrame } = await import("./shot-
|
|
3674
|
+
const { shootFrame } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
|
|
3649
3675
|
const r = await shootFrame({
|
|
3650
3676
|
root,
|
|
3651
3677
|
viewports: opts.viewports ?? {},
|
|
@@ -3696,7 +3722,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3696
3722
|
if (typeof theme !== "string" || !/^[a-z0-9-]+$/i.test(theme)) return json(res, 400, { error: "invalid theme" });
|
|
3697
3723
|
const scale = body.scale === void 0 ? void 0 : body.scale;
|
|
3698
3724
|
if (scale !== void 0 && !(Number.isInteger(scale) && scale >= 1 && scale <= 4)) return json(res, 400, { error: "invalid scale" });
|
|
3699
|
-
const { resolveFrames, shootBatch } = await import("./shot-
|
|
3725
|
+
const { resolveFrames, shootBatch } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
|
|
3700
3726
|
const sel = resolveFrames(root, body);
|
|
3701
3727
|
if (!sel.ok) return json(res, sel.status, { error: sel.error });
|
|
3702
3728
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
@@ -3730,7 +3756,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3730
3756
|
if (typeof target === "string") return json(res, 400, { error: target });
|
|
3731
3757
|
const others = Array.isArray(b.others) ? b.others.filter((o) => typeof o?.key === "string").slice(0, 200) : [];
|
|
3732
3758
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3733
|
-
const { checkAnchor, CheckInputError } = await import("./anchor-check-
|
|
3759
|
+
const { checkAnchor, CheckInputError } = await import("./anchor-check-Bv4o-R2T.mjs");
|
|
3734
3760
|
try {
|
|
3735
3761
|
return json(res, 200, await checkAnchor({
|
|
3736
3762
|
root,
|
|
@@ -3838,8 +3864,8 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3838
3864
|
return json(res, 400, { error: "malformed JSON" });
|
|
3839
3865
|
}
|
|
3840
3866
|
const src = typeof b?.src === "string" ? b.src : "";
|
|
3841
|
-
const { ensurePoster, isLocalClip } = await import("./poster-
|
|
3842
|
-
const { isLocalAssetRef } = await import("./build-
|
|
3867
|
+
const { ensurePoster, isLocalClip } = await import("./poster-DPPpQiva.mjs");
|
|
3868
|
+
const { isLocalAssetRef } = await import("./build-zWGXSzly.mjs");
|
|
3843
3869
|
if (!isLocalAssetRef(src) || !isLocalClip(src)) return json(res, 400, { error: "src must be a clip under design/assets/" });
|
|
3844
3870
|
const r = await ensurePoster(join(root, "design", "assets"), src);
|
|
3845
3871
|
if (!r.ok) return json(res, r.error.includes("does not exist") ? 404 : 503, { error: r.error });
|
|
@@ -4256,7 +4282,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4256
4282
|
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? }" });
|
|
4257
4283
|
if (readCapture(root, b.capture)) return json(res, 409, { error: "that capture is sealed" });
|
|
4258
4284
|
const theme = typeof b.theme === "string" && /^[a-z0-9-]+$/i.test(b.theme) ? b.theme : "light";
|
|
4259
|
-
const { shootFrame } = await import("./shot-
|
|
4285
|
+
const { shootFrame } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
|
|
4260
4286
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
4261
4287
|
const vp = typeof b.viewport === "string" ? opts.viewports?.[b.viewport] : void 0;
|
|
4262
4288
|
const dim = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
|
|
@@ -5233,7 +5259,7 @@ function marverPlugin(ctx) {
|
|
|
5233
5259
|
onClose(() => {
|
|
5234
5260
|
if (devServer === server) devServer = before;
|
|
5235
5261
|
});
|
|
5236
|
-
guardUpdates(server, root, () => manifest, hooks, changes);
|
|
5262
|
+
guardUpdates(server, root, () => manifest, hooks, changes, (sheets) => rescanTheme(sheets));
|
|
5237
5263
|
let framesKey = JSON.stringify(manifest.frames);
|
|
5238
5264
|
let scenesKey = JSON.stringify(manifest.scenes);
|
|
5239
5265
|
let unplacedKey = "";
|
|
@@ -5274,12 +5300,16 @@ function marverPlugin(ctx) {
|
|
|
5274
5300
|
for (const mod of server.moduleGraph.getModulesByFile(f) ?? []) walk(mod);
|
|
5275
5301
|
return out;
|
|
5276
5302
|
};
|
|
5303
|
+
const owed = /* @__PURE__ */ new Set();
|
|
5277
5304
|
const pushTheme = debounce(() => {
|
|
5278
|
-
|
|
5305
|
+
const sheets = [...owed].flatMap((f) => [...server.moduleGraph.getModulesByFile(f) ?? []]);
|
|
5306
|
+
owed.clear();
|
|
5307
|
+
for (const mod of /* @__PURE__ */ new Set([...themeModules(), ...sheets])) server.reloadModule(mod).catch(() => {});
|
|
5279
5308
|
}, 150);
|
|
5280
5309
|
onClose(pushTheme.cancel);
|
|
5281
|
-
const rescanTheme = () => {
|
|
5310
|
+
const rescanTheme = (sheets = []) => {
|
|
5282
5311
|
for (const mod of themeModules()) server.moduleGraph.invalidateModule(mod);
|
|
5312
|
+
for (const f of sheets) owed.add(f);
|
|
5283
5313
|
pushTheme();
|
|
5284
5314
|
};
|
|
5285
5315
|
const localDir = join(root, "design", ".local"), boardsDirGen = join(root, "design", "boards"), manifestPath = join(root, "design", "manifest.json");
|
|
@@ -5487,7 +5517,7 @@ function marverPlugin(ctx) {
|
|
|
5487
5517
|
});
|
|
5488
5518
|
return;
|
|
5489
5519
|
}
|
|
5490
|
-
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-
|
|
5520
|
+
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-d4h_hJi9.mjs").then((n) => n.u);
|
|
5491
5521
|
if (ways[0] === "frame") {
|
|
5492
5522
|
if (typeof spec.frame !== "string") {
|
|
5493
5523
|
write({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as capture, p as findChrome } from "./shot-
|
|
1
|
+
import { i as capture, p as findChrome } from "./shot-d4h_hJi9.mjs";
|
|
2
2
|
import { constants, copyFileSync, existsSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, sep } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as slideSize } from "./cli.mjs";
|
|
2
|
-
import { c as ASK_MAX, l as bakeBatch } from "./plugin-
|
|
3
|
-
import { p as findChrome, s as planShot } from "./shot-
|
|
2
|
+
import { c as ASK_MAX, l as bakeBatch } from "./plugin-CFWBcAba.mjs";
|
|
3
|
+
import { p as findChrome, s as planShot } from "./shot-d4h_hJi9.mjs";
|
|
4
4
|
import { MIME } from "./serve-DQv3Ti6X.mjs";
|
|
5
5
|
import { copyFileSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
2
|
import { d as recoverTarget, r as legacyEntry, u as recoverEntries, v as workspaceId } from "./slots-Dn4Onb0V.mjs";
|
|
3
|
-
import { DevStartError, dev } from "./dev-
|
|
3
|
+
import { DevStartError, dev } from "./dev-DOgIITpT.mjs";
|
|
4
4
|
//#region src/cli/recover.ts
|
|
5
5
|
/**
|
|
6
6
|
* `marver dev --recover` (spec 28 A1.6). A Jam capture the page could not send waits in that browser's
|
|
@@ -524,8 +524,8 @@ async function shootFrame(opts) {
|
|
|
524
524
|
};
|
|
525
525
|
const plan = planShot(frame, viewports, size);
|
|
526
526
|
if (frame.kind !== "html") try {
|
|
527
|
-
const { scanAssetRefs } = await import("./build-
|
|
528
|
-
const { ensurePoster } = await import("./poster-
|
|
527
|
+
const { scanAssetRefs } = await import("./build-zWGXSzly.mjs");
|
|
528
|
+
const { ensurePoster } = await import("./poster-DPPpQiva.mjs");
|
|
529
529
|
const refs = scanAssetRefs(readFileSync(join(root, frame.file), "utf8"), frame.file);
|
|
530
530
|
for (const r of refs) if (r.endsWith(".poster.png")) await ensurePoster(join(root, "design", "assets"), r.slice(0, -11));
|
|
531
531
|
} catch {}
|
package/docs/performance.md
CHANGED
|
@@ -182,7 +182,8 @@ Each frame of a load ends at one outcome:
|
|
|
182
182
|
|
|
183
183
|
An outcome counts only from the document the frame shows now: a message from a document since replaced, or
|
|
184
184
|
from one a reload is replacing, never counts. When the same board is read again its frames keep their
|
|
185
|
-
documents, and a frame whose document is older than the load is marked `kept
|
|
185
|
+
documents, and a frame whose document is older than the load is marked `kept` - all but a frame that had failed, one
|
|
186
|
+
silent past its retry, and one whose sizing the file changed: those load again, and are not `kept`. A load with missing or
|
|
186
187
|
never-ready frames settles anyway, and says so.
|
|
187
188
|
|
|
188
189
|
## Moves and why
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marver-design/marver",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "The agent-native design canvas. A design/ folder, one command, a canvas of live frames built from your repo's real components - comment @marver and your own coding agent does the work. The tool ships no AI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -220,7 +220,8 @@ function handover(id: string): void {
|
|
|
220
220
|
if (L && owner && owner !== L && !owner.done) cut(owner, owner.board === L.board ? 'reload' : 'switch')
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
/** `kept`: the board read again, the nodes whose document stands - any other starts its record over, whatever it held */
|
|
224
|
+
function commit(id: string, nodes: readonly Node[], manifest: Manifest, kept?: ReadonlySet<string>): void {
|
|
224
225
|
const L = pending.get(id) ?? lapsed.get(id)
|
|
225
226
|
if (!L) return
|
|
226
227
|
const late = !pending.has(id)
|
|
@@ -232,7 +233,7 @@ function commit(id: string, nodes: readonly Node[], manifest: Manifest): void {
|
|
|
232
233
|
// mounting is never a move: the baseline is the nodes about to mount
|
|
233
234
|
baseline = new Map(nodes.map((n) => [n.key, { x: n.x, y: n.y, w: n.w, h: n.h }]))
|
|
234
235
|
const keys = new Set(nodes.map((n) => n.key))
|
|
235
|
-
for (const k of [...tracks.keys()]) if (!keys.has(k)) tracks.delete(k)
|
|
236
|
+
for (const k of [...tracks.keys()]) if (!(kept ?? keys).has(k)) tracks.delete(k)
|
|
236
237
|
// a request already cut (its deadline passed, the page hid) mounts all the same: said, its cut kept - its board's
|
|
237
238
|
// geometry is its own from here, every move late
|
|
238
239
|
rec('commit', id, { request: id, ms: Math.round(L.committedAt - L.t0), ...facts(nodes, manifest), ...(late ? { late: true } : {}) })
|
|
@@ -338,6 +338,36 @@ const nodeKey = () => 'n_' + Math.random().toString(36).slice(2, 8)
|
|
|
338
338
|
let manifestRev = 0
|
|
339
339
|
export const bumpManifestRev = () => { manifestRev++ }
|
|
340
340
|
|
|
341
|
+
/** The board read again over itself: a frame still on it keeps its live document, so the node keeps what is known of
|
|
342
|
+
* that document. Read fresh it would wait for a ready that document sent long ago - the watchdog then reloads every
|
|
343
|
+
* frame - and its `nav`, back to none, would read as a request to navigate. Only a healthy document is kept: one that
|
|
344
|
+
* failed, one silent past its retry, and one whose sizing changed - its mode, or a content frame's human width (a
|
|
345
|
+
* measure it will never send again) - are asked anew.
|
|
346
|
+
* A kept content frame keeps the size it measured: the file holds none (auto) or the width alone is the human's
|
|
347
|
+
* (manual), and a document that stays never measures again unless its width changes. `kept`: the nodes whose
|
|
348
|
+
* document stands; `carried`: the nodes whose kept size differs from the file's. */
|
|
349
|
+
function keepDocuments(mounted: Node[], nodes: Node[]): { nodes: Node[]; kept: Set<string>; carried: Set<string> } {
|
|
350
|
+
const was = new Map(mounted.map((n) => [n.key, n]))
|
|
351
|
+
const kept = new Set<string>(), carried = new Set<string>()
|
|
352
|
+
const next = nodes.map((n) => {
|
|
353
|
+
const o = was.get(n.key)
|
|
354
|
+
if (!o || o.frame !== n.frame || o.missing || n.missing) return n
|
|
355
|
+
const { status, error, nav, rev, themeOn, readyRetried, stale, shown, want } = o
|
|
356
|
+
// only a frame that measures (renders a Doc) has a size of its own to keep; a bare Md or Img is the size its board says
|
|
357
|
+
const fits = measures(n.frame)
|
|
358
|
+
// a human width the file changed is sizing too: the document fits its height at a width only once it loads there
|
|
359
|
+
const resized = fits && n.sizeMode === 'manual' && Math.round(o.w) !== Math.round(n.w)
|
|
360
|
+
if (status === 'error' || (status === 'loading' && readyRetried) || o.sizeMode !== n.sizeMode || resized) return { ...n, nav: (nav ?? 0) + 1, stale, want }
|
|
361
|
+
kept.add(n.key)
|
|
362
|
+
// auto: the whole size is measured; manual: the height, at the width it has
|
|
363
|
+
const w = fits && o.sizeMode === 'auto' ? o.w : n.w
|
|
364
|
+
const h = fits && (o.sizeMode === 'auto' || o.sizeMode === 'manual') ? o.h : n.h
|
|
365
|
+
if (Math.round(w) !== Math.round(n.w) || Math.round(h) !== Math.round(n.h)) carried.add(n.key)
|
|
366
|
+
return { ...n, w, h, status, error, nav, rev, themeOn, readyRetried, stale, shown, want }
|
|
367
|
+
})
|
|
368
|
+
return { nodes: next, kept, carried }
|
|
369
|
+
}
|
|
370
|
+
|
|
341
371
|
/** ws= binds the document to this canvas (spec 28 A1.11): another project on this port later answers a
|
|
342
372
|
* frame's own reload with the "another canvas" page (server/guard.ts), never with its frame. */
|
|
343
373
|
export function frameUrl(frame: FrameEntry, theme: string): string {
|
|
@@ -542,7 +572,7 @@ export const recorderHooks = {
|
|
|
542
572
|
/** a request is about to commit: the load that was up ends - before the incoming sizes are installed, so it ends by
|
|
543
573
|
* the sizes it read (which frames measure), its board's nodes still in the store */
|
|
544
574
|
handover: (_request: string): void => {},
|
|
545
|
-
commit: (_request: string, _nodes: readonly Node[], _manifest: Manifest): void => {},
|
|
575
|
+
commit: (_request: string, _nodes: readonly Node[], _manifest: Manifest, _kept?: ReadonlySet<string>): void => {},
|
|
546
576
|
cut: (_request: string, _reason: RequestCut): void => {},
|
|
547
577
|
/** nothing of the reflow story is left: no reflow pending, no height held, none owed */
|
|
548
578
|
reflowIdle: (): void => {},
|
|
@@ -865,7 +895,12 @@ export const useStore = create<State>((set, get) => {
|
|
|
865
895
|
if (!holds.size && reflowOwed) { reflowOwed = false; scheduleReflow(null) }
|
|
866
896
|
else reflowSettled()
|
|
867
897
|
}
|
|
868
|
-
|
|
898
|
+
/** `keep`: nodes whose document a board read kept - a reload of theirs still on its way keeps its hold and the
|
|
899
|
+
* measure it held back (an image still loading lands when the hold lets go) */
|
|
900
|
+
const dropHolds = (keep?: ReadonlySet<string>) => {
|
|
901
|
+
for (const [k, h] of holds) if (!keep?.has(k)) { clearTimeout(h.timer); holds.delete(k) }
|
|
902
|
+
reflowOwed = reflowOwed && holds.size > 0 // a reflow owed to a hold that stays is still owed when it lets go
|
|
903
|
+
}
|
|
869
904
|
/** A content measure moved the rows: once, after the last held node lets go. */
|
|
870
905
|
const reflowAfterHolds = () => { reflowReasons.add('measured'); if (holds.size) reflowOwed = true; else scheduleReflow('measured') }
|
|
871
906
|
/** The recorder hears when nothing of the reflow story is left (spec 28 A1.7): no timer, no held height, none owed. */
|
|
@@ -915,10 +950,11 @@ export const useStore = create<State>((set, get) => {
|
|
|
915
950
|
* it: it already equals the committed one. So once the board is up, the recipe re-runs if the
|
|
916
951
|
* known heights differ from the ones its positions were laid out around (`laidOut`). A frame the
|
|
917
952
|
* human dragged, at heights that did not change, stays where they put it. */
|
|
918
|
-
const layoutStale = () => {
|
|
953
|
+
const layoutStale = (kept?: ReadonlySet<string>) => {
|
|
919
954
|
const { nodes, laidOut } = get()
|
|
920
955
|
const record = laidOut ?? {}
|
|
921
|
-
|
|
956
|
+
// `kept`: nodes whose size a board read kept from their live document - known as surely as a measured one
|
|
957
|
+
const known = (n: Node) => (n.sizeMode === 'auto' && hasKnownHeight(n.frame, Math.round(n.w))) || !!kept?.has(n.key)
|
|
922
958
|
const has = (n: Node) => Object.prototype.hasOwnProperty.call(record, n.key)
|
|
923
959
|
// a node the layout recorded, at another size now
|
|
924
960
|
if (nodes.some((n) => known(n) && has(n) && sizeOf(n) !== record[n.key])) return true
|
|
@@ -981,7 +1017,9 @@ export const useStore = create<State>((set, get) => {
|
|
|
981
1017
|
* mounted board reads: those it read come back with it, for the commit to install (installSizes).
|
|
982
1018
|
* null = failure (transport, malformed manifest, non-404 board error) - the caller
|
|
983
1019
|
* keeps whatever board is currently mounted. */
|
|
984
|
-
|
|
1020
|
+
/** `tidied`: this load laid the rows out itself (no positions, a cramped note) - every position is the recipe's, made
|
|
1021
|
+
* around the sizes it read */
|
|
1022
|
+
const loadBoardState = async (boardName: string): Promise<{ state: Partial<State>; sizes: SizeRead | null; tidied: boolean } | null> => {
|
|
985
1023
|
clearNoteHeights() // heights are per column drawn; a key shared by two board files carries none across
|
|
986
1024
|
loadErrors.delete(boardName)
|
|
987
1025
|
try {
|
|
@@ -1167,7 +1205,8 @@ export const useStore = create<State>((set, get) => {
|
|
|
1167
1205
|
// a note that landed while this board was closed has no room in the saved positions:
|
|
1168
1206
|
// a board with a recipe re-applies it (spec 18 - room is the layout's job)
|
|
1169
1207
|
const cramped = !!boardHash && !needTidy && !!(layout || sceneRows?.length || boardAuto) && notesCramped(nodes, manifest)
|
|
1170
|
-
|
|
1208
|
+
const tidied = (!boardHash || needTidy || cramped) && nodes.length > 0
|
|
1209
|
+
if (tidied) {
|
|
1171
1210
|
const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
|
|
1172
1211
|
for (const pl of placedAll) { const n = nodes.find((x) => x.key === pl.key)!; n.x = pl.x; n.y = pl.y }
|
|
1173
1212
|
laidOut = sizeRecord(nodes)
|
|
@@ -1180,7 +1219,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
1180
1219
|
if (layout && boardHash && !needTidy && !cramped && nodes.length) {
|
|
1181
1220
|
tidy(tidyInput(nodes, manifest), layout, layoutWarn, knownScenes(manifest))
|
|
1182
1221
|
}
|
|
1183
|
-
return { state: { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }, sizes }
|
|
1222
|
+
return { state: { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }, sizes, tidied }
|
|
1184
1223
|
} catch { return null } finally { preparing = null }
|
|
1185
1224
|
}
|
|
1186
1225
|
|
|
@@ -1203,13 +1242,20 @@ export const useStore = create<State>((set, get) => {
|
|
|
1203
1242
|
if (!loaded) { recorderHooks.cut(request, 'error'); get().toast(`board "${boardName}" failed to load${whyNot(boardName)}`); return false }
|
|
1204
1243
|
// the user kept editing while we fetched - their newer state wins over the reload
|
|
1205
1244
|
if (get().board !== boardName || editRev !== revAtStart || (mayCommit && !mayCommit())) { recorderHooks.cut(request, 'edited'); return false }
|
|
1206
|
-
const next = loaded.state
|
|
1207
1245
|
const live = get().manifest // a WS manifest update may have landed mid-fetch
|
|
1208
1246
|
recorderHooks.handover(request) // the load that was up ends by its own sizes
|
|
1209
1247
|
installSizes(loaded.sizes) // the sizes this load read are the page's from its commit
|
|
1210
|
-
|
|
1248
|
+
// after the install: which frames measure is this load's word
|
|
1249
|
+
const { nodes, kept, carried } = keepDocuments(get().nodes, loaded.state.nodes as Node[])
|
|
1250
|
+
const next = { ...loaded.state, nodes }
|
|
1251
|
+
recorderHooks.commit(request, next.nodes, next.manifest as Manifest, kept) // before the set: mounting is not a move
|
|
1211
1252
|
set(next)
|
|
1212
|
-
cancelReflow(); dropHolds()
|
|
1253
|
+
cancelReflow(); dropHolds(kept)
|
|
1254
|
+
// a kept size the file did not hold: rows this load laid out around the file's sizes are laid out again around the
|
|
1255
|
+
// kept ones; positions read from the file move only if the layout was not made around it - judged as a known
|
|
1256
|
+
// height is (a human's placement at the sizes it recorded stays)
|
|
1257
|
+
if (carried.size && composed(get())) scheduleReflow('stale', loaded.tidied ? undefined : () => layoutStale(carried))
|
|
1258
|
+
for (const k of [...reloadCause.keys()]) if (!kept.has(k)) reloadCause.delete(k) // a document still loading keeps its cause
|
|
1213
1259
|
if (next.dirty) scheduleSave() // load-time prune must reach the disk
|
|
1214
1260
|
if (live && manifestKey(live) !== manifestKey(next.manifest as Manifest)) get().applyManifest(live)
|
|
1215
1261
|
else if (scenesRev !== scenesAtStart && liveScenes) set({ manifest: { ...get().manifest!, scenes: liveScenes } }) // an sh:scenes that landed mid-fetch outranks the file we read
|