@marver-design/marver 0.34.0 → 0.35.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 +42 -0
- package/README.md +1 -1
- package/dist/{anchor-check-Cld22HFE.mjs → anchor-check-DREwCQiE.mjs} +1 -1
- package/dist/{build-C1AGScLz.mjs → build-3AH123fe.mjs} +3 -3
- package/dist/cli.mjs +3 -6
- package/dist/{daemon-CWl_0QF8.mjs → daemon-BE-t9iU-.mjs} +1 -1
- package/dist/{dev-Kfv8FgVw.mjs → dev-Dw6mcoP8.mjs} +7 -7
- package/dist/{notes-CRAX4wgk.mjs → notes-CmfQ9604.mjs} +13 -4
- package/dist/{pdf-6JNQAKJv.mjs → pdf-CkE4Ir2P.mjs} +3 -3
- package/dist/{plugin-C1SEQSU5.mjs → plugin-C6jEpbCx.mjs} +38 -15
- package/dist/{poster-BO971KQR.mjs → poster-d10h73z0.mjs} +1 -1
- package/dist/{publish-bakes-JCG2kvQP.mjs → publish-bakes-weNQnNqE.mjs} +2 -2
- package/dist/{recover-BIHPEDTa.mjs → recover-Dekpav7b.mjs} +1 -1
- package/dist/{shot-G0bBXwHl.mjs → shot-Ct2FiEbu.mjs} +2 -2
- package/docs/performance.md +4 -0
- package/package.json +1 -1
- package/src/client/const.ts +5 -0
- package/src/client/content/img-lod.ts +3 -1
- package/src/client/frame-host/inplace.ts +43 -0
- package/src/client/frame-host/main.tsx +10 -1
- package/src/client/shell/App.tsx +26 -18
- package/src/client/shell/LockedApp.tsx +6 -5
- package/src/client/shell/canvas/Canvas.tsx +50 -16
- package/src/client/shell/canvas/FrameNode.tsx +40 -7
- package/src/client/shell/canvas/admission.ts +138 -5
- package/src/client/shell/canvas/sleep.ts +258 -26
- package/src/client/shell/hash.ts +24 -0
- package/src/client/shell/jam-capture.ts +3 -2
- package/src/client/shell/notes.ts +11 -4
- package/src/client/shell/recorder.ts +1 -1
- package/src/client/shell/store.ts +63 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
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.35.0 - 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Highlights
|
|
8
|
+
|
|
9
|
+
- **Heavy boards are about 2x faster to open and up to 10x faster to work on.** The canvas engine now does far less
|
|
10
|
+
work to start a frame, switch a tool on and save an edit. On a board of 112 rich frames in the Mac app:
|
|
11
|
+
|
|
12
|
+
| | 0.34 | 0.35 | |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| Every frame ready | 32 s | 18 s | 1.8x faster |
|
|
15
|
+
| Frames on screen ready | 24 s | 12 s | 2x |
|
|
16
|
+
| Comment mode on | 8.4 s | 0.8 s | 10x |
|
|
17
|
+
| Laser on | 8 s | 0.9 s | 9x |
|
|
18
|
+
| Theme switch | 4.4 s | 1.3 s | 3.4x |
|
|
19
|
+
| Panning, slowest frames | about 75 ms | about 25 ms | 3x smoother |
|
|
20
|
+
| Memory | 1,080 MB | 950 MB | 12% less |
|
|
21
|
+
| Requests per saved edit | 650 | 530 | 17-40% fewer |
|
|
22
|
+
|
|
23
|
+
A board of 103 phone screens reloads in 15 s instead of 56 s (3.8x, in a fresh Chrome profile), a 270-frame board
|
|
24
|
+
that never finished loading is ready in under a minute, and boards that were already fast stay fast.
|
|
25
|
+
[Performance](docs/performance.md)
|
|
26
|
+
- **A board too big for one browser tab no longer crashes it.** Past a few hundred heavy frames the tab ran out of
|
|
27
|
+
memory and died. The canvas now stops starting frames before that point and starts the ones you look at when you
|
|
28
|
+
get to them, so the board stays open and usable. [Performance](docs/performance.md#making-a-board-faster)
|
|
29
|
+
- **A board at rest really rests.** A frame with a moving SVG - a spinner, an animated mark - kept the whole board
|
|
30
|
+
drawing sixty times a second with nothing happening. A resting frame's SVG animation now stands still, like its CSS
|
|
31
|
+
animation already did, and moves again the moment the frame wakes: about 50x less work at rest on such a board.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **Adding or deleting a file no longer restarts every frame** on a canvas whose theme is a module
|
|
36
|
+
(`design/theme.ts`). Each frame started itself again, lost what it was showing and kept its old copy in memory. A
|
|
37
|
+
theme that is a stylesheet was never affected.
|
|
38
|
+
- **A link, Back or Forward used while a board is still loading is no longer lost.** The canvas could write the
|
|
39
|
+
board's own address back over the one you had just asked for.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- While a frame starts in `marver dev`, React no longer records where each element was created, which was most of a
|
|
44
|
+
heavy frame's start. An element created at the top of a module shows React's generic stack in DevTools; elements
|
|
45
|
+
created in a render are unchanged.
|
|
46
|
+
|
|
5
47
|
## 0.34.0 - 2026-11-14
|
|
6
48
|
|
|
7
49
|
### Highlights
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Frames appear on the canvas the moment the files land. That's the loop.
|
|
|
47
47
|
- **Content frames.** Specs, Mermaid diagrams, mood boards, and slides live on the same canvas as the screens - import `Doc`, `Md`, `Diagram`, `Img`, `Slide`, `Chart`, `Video` from `@marver-design/marver/content` and think a feature through before any pixels exist. Works in a repo with no app at all: idea first, design second.
|
|
48
48
|
- **Boards that hold still.** A content frame is as tall as its content, which only a render can tell - so the height each one settles at is kept in `design/boards/_sizes.json` (written by `marver dev`, committed with the rest of `design/`), and a board opens with every frame at its real size: the content fills in and nothing moves. When an agent does make a doc taller, the frame you are looking at stays put on screen while the rows re-flow around it.
|
|
49
49
|
- **Sticky notes.** A markdown file beside a frame (`cart.note.md`) or a scene (`_note.md`) becomes a yellow note left of the frame on the canvas - what it is for, how two variations differ, an open question. Markdown, `goto:` links to frames, hand-drawn Mermaid; readers comment on a note's text like on a frame's, fold it to its corner, hide them all with `n`. The layout makes room for it, beside the frame and below; published canvases carry them.
|
|
50
|
-
- **Hi-fi at rest.** A frame at rest is its own live document, asleep: animations paused and every `backdrop-filter` element painted with a certified texture of its filtered backdrop (compiled by the dev server's headless Chrome), so a board of 30 glass screens pans like 30 statics and wakes pixel-identical on interact. Glass inside glass, blend modes and frames whose paint depends on random data or the clock stay live; `?awake=1` keeps every frame live for comparison.
|
|
50
|
+
- **Hi-fi at rest.** A frame at rest is its own live document, asleep: animations paused (CSS and SVG) and every `backdrop-filter` element painted with a certified texture of its filtered backdrop (compiled by the dev server's headless Chrome), so a board of 30 glass screens pans like 30 statics and wakes pixel-identical on interact. Glass inside glass, blend modes and frames whose paint depends on random data or the clock stay live; `?awake=1` keeps every frame live for comparison.
|
|
51
51
|
- **Charts and video in any frame.** `Chart` (Apache ECharts, SVG, still at rest) inherits the ink, typeface and accent of whatever frame it sits in - a Tailwind dashboard, a dark spec, a slide - sizes its type to the context and follows the layout on resize. `Video` is poster-first everywhere: click to play wherever the frame is live, `autoplay` for an ambient loop, `ratio` for vertical clips; omit the poster and marver renders one from the clip. A screen with a chart or a clip is still a screen.
|
|
52
52
|
- **Deck PDFs.** **Export PDF** on a board (or `npx marver pdf <board>`) prints it one page per slide (any other board, one page per frame): real text you can search, vector shapes, links that click, a bookmark per slide - and the glass, blur and shadows Chrome usually prints wrong, fixed and checked against the screen. `--notes` makes a handout with the speaker notes ([Deck PDFs](docs/pdf.md)).
|
|
53
53
|
- **Copy as image.** Select a frame, press `i` - a 2x PNG of it lands on the clipboard, rendered by the same headless Chrome that serves `marver shot`; `⇧i` for 4x (a 1280×720 slide is 5120×2880, whatever size its node has). Paste into Slack, a doc, or a chat with your agent.
|
|
@@ -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-Ct2FiEbu.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
|
|
@@ -6,7 +6,7 @@ import { a as readLog, o as shareable, r as legacyExposure, t as appendEvents }
|
|
|
6
6
|
import { t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
7
7
|
import { a as publishLogo, r as logoIcons } from "./logo-C9s7-Cy9.mjs";
|
|
8
8
|
import { n as loadConfig } from "./config-B0YcFtqS.mjs";
|
|
9
|
-
import { d as canvasIdentity, n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-
|
|
9
|
+
import { d as canvasIdentity, n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-C6jEpbCx.mjs";
|
|
10
10
|
import { i as measuringFrames, n as autoWidthOf, o as readSizes, r as keptSizes } from "./sizes-BckcL4Zz.mjs";
|
|
11
11
|
import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { dirname, join, sep } from "node:path";
|
|
@@ -790,7 +790,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
|
|
|
790
790
|
const realAssets = existsSync(assetsDir) ? realpathSync(assetsDir) : null;
|
|
791
791
|
for (const r of refs) {
|
|
792
792
|
if (!isLocalAssetRef(r) || !r.endsWith(".poster.png") || existsSync(join(assetsDir, r))) continue;
|
|
793
|
-
const { ensurePoster } = await import("./poster-
|
|
793
|
+
const { ensurePoster } = await import("./poster-d10h73z0.mjs");
|
|
794
794
|
const g = await ensurePoster(assetsDir, r.slice(0, -11));
|
|
795
795
|
if (!g.ok) throw new Error(`design/assets/${r}: ${g.error}`);
|
|
796
796
|
console.log(` poster: rendered design/assets/${r} (${g.width}×${g.height})`);
|
|
@@ -849,7 +849,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
|
|
|
849
849
|
}));
|
|
850
850
|
let textureLine = " textures: skipped (--no-textures)";
|
|
851
851
|
if (textures && bakeGen) {
|
|
852
|
-
const { bakePublished } = await import("./publish-bakes-
|
|
852
|
+
const { bakePublished } = await import("./publish-bakes-weNQnNqE.mjs");
|
|
853
853
|
const pubFrameFile = new Map(pubFrames.map((f) => [f.id, f]));
|
|
854
854
|
const r = await bakePublished({
|
|
855
855
|
root,
|
package/dist/cli.mjs
CHANGED
|
@@ -10,9 +10,6 @@ import { fileURLToPath } from "node:url";
|
|
|
10
10
|
const NAME = "marver";
|
|
11
11
|
const PKG = "@marver-design/marver";
|
|
12
12
|
const ROUTE = "/__mv";
|
|
13
|
-
/** Content-frame natural widths: Doc layout -> own-size width.
|
|
14
|
-
* Shared by the Doc primitive (measurement messages) and the server-side
|
|
15
|
-
* manifest scan (defaultSize for content frames) - one source, no drift. */
|
|
16
13
|
const CONTENT_WIDTH = {
|
|
17
14
|
document: 760,
|
|
18
15
|
wide: 1280
|
|
@@ -90,7 +87,7 @@ cli.command("init", "Scaffold design/ in this repo").option("--mode <mode>", "st
|
|
|
90
87
|
});
|
|
91
88
|
});
|
|
92
89
|
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-
|
|
90
|
+
const { dev, DevStartError, DevLockError } = await import("./dev-Dw6mcoP8.mjs");
|
|
94
91
|
let port;
|
|
95
92
|
if (opts.port !== void 0) {
|
|
96
93
|
const n = Number(opts.port);
|
|
@@ -102,7 +99,7 @@ for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot
|
|
|
102
99
|
process.exit(1);
|
|
103
100
|
};
|
|
104
101
|
try {
|
|
105
|
-
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-
|
|
102
|
+
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-Dekpav7b.mjs")).recoverCommand(resolve$1(opts.root), opts.recover, port, { onFail });
|
|
106
103
|
else await dev(resolve$1(opts.root), {
|
|
107
104
|
port,
|
|
108
105
|
onFail
|
|
@@ -118,7 +115,7 @@ cli.command("ls", "The canvases running on this Mac: slot, link, name, version,
|
|
|
118
115
|
(await import("./ls-DGVIW-Io.mjs")).lsCommand({ json: opts.json === true });
|
|
119
116
|
});
|
|
120
117
|
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-
|
|
118
|
+
const { buildSite } = await import("./build-3AH123fe.mjs");
|
|
122
119
|
try {
|
|
123
120
|
const boards = opts.boards === void 0 ? void 0 : typeof opts.boards === "string" ? opts.boards : "";
|
|
124
121
|
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, l as wrapupWithoutDeleted, n as buildWrapup, o as recordPathProblem, r as moreOf, t as SESSION_ID } from "./session-DBF-nQvq.mjs";
|
|
14
14
|
import { act, addCapture, addWrapup, answeredSince, beginStep, captureComment, captureIntact, conflictStep, createQueue, ctxFor, deletedEvents, dropDeleted, endSession, endStep, fail, failCard, form, joinAlone, liveThreads, looksGood, moreWrapup, ownerOnly, payloadKey, pending, prune, r as releaseLock, redelivering, requeue, runsAlone, sameComment, settle, startSession, stillOwned, t as acquireLock, textOf, tombstonesOf, undelivered, withdrawnCaptures, wrapupIntact, wrapupOf } from "./queue-BLLfdlDw.mjs";
|
|
15
15
|
import { d as logJam } from "./perf-BA_NDarr.mjs";
|
|
16
|
-
import { i as jamLive } from "./plugin-
|
|
16
|
+
import { i as jamLive } from "./plugin-C6jEpbCx.mjs";
|
|
17
17
|
import { t as PROTECTED_GLOBS } from "./permit-DDa6wqOs.mjs";
|
|
18
18
|
import { jamReservations, restoreHolds } from "./reserve-BURNQ2Y3.mjs";
|
|
19
19
|
import { recordOwn } from "./own-C8Mq0Hnf.mjs";
|
|
@@ -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-BOcfIqxy.mjs";
|
|
3
3
|
import { t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
4
4
|
import { n as loadConfig } from "./config-B0YcFtqS.mjs";
|
|
5
|
-
import { c as installedVersion, d as canvasIdentity, f as identityNudge, n as tailwind3Css, o as liveChanged, r as tailwind4Plugin, t as marverPlugin } from "./plugin-
|
|
5
|
+
import { c as installedVersion, d as canvasIdentity, f as identityNudge, n as tailwind3Css, o as liveChanged, r as tailwind4Plugin, t as marverPlugin } from "./plugin-C6jEpbCx.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";
|
|
@@ -1021,7 +1021,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1021
1021
|
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`);
|
|
1022
1022
|
setTimeout(async () => {
|
|
1023
1023
|
try {
|
|
1024
|
-
await (await import("./shot-
|
|
1024
|
+
await (await import("./shot-Ct2FiEbu.mjs").then((n) => n.u)).sweepGhosts((m) => console.log(` ${m}`));
|
|
1025
1025
|
} catch {}
|
|
1026
1026
|
}, 0);
|
|
1027
1027
|
try {
|
|
@@ -1108,8 +1108,8 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1108
1108
|
console.log(` comments: could not record who wrote what here - ${err.message}`);
|
|
1109
1109
|
}
|
|
1110
1110
|
if (config.jam) {
|
|
1111
|
-
const { startJam } = await import("./daemon-
|
|
1112
|
-
const { checkAnchor } = await import("./anchor-check-
|
|
1111
|
+
const { startJam } = await import("./daemon-BE-t9iU-.mjs");
|
|
1112
|
+
const { checkAnchor } = await import("./anchor-check-DREwCQiE.mjs");
|
|
1113
1113
|
const jam = startJam(root, config.jam, (m) => console.log(m), (board) => {
|
|
1114
1114
|
server.ws.send("sh:jam-comment", { board });
|
|
1115
1115
|
liveChanged();
|
|
@@ -1126,13 +1126,13 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1126
1126
|
return () => {
|
|
1127
1127
|
due ??= setTimeout(async () => {
|
|
1128
1128
|
due = null;
|
|
1129
|
-
const { jamLive } = await import("./plugin-
|
|
1129
|
+
const { jamLive } = await import("./plugin-C6jEpbCx.mjs").then((n) => n.a);
|
|
1130
1130
|
server.ws.send("sh:jam-queue", jamLive.view?.() ?? { cards: [] });
|
|
1131
1131
|
liveChanged();
|
|
1132
1132
|
}, 60);
|
|
1133
1133
|
};
|
|
1134
1134
|
})(), async (frameId, theme, entry, size) => {
|
|
1135
|
-
const { shootFrame } = await import("./shot-
|
|
1135
|
+
const { shootFrame } = await import("./shot-Ct2FiEbu.mjs").then((n) => n.u);
|
|
1136
1136
|
const r = await shootFrame({
|
|
1137
1137
|
root,
|
|
1138
1138
|
viewports: config.viewports,
|
|
@@ -1153,7 +1153,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1153
1153
|
t.defer(() => jam.stop());
|
|
1154
1154
|
if (config.jam.session !== false) try {
|
|
1155
1155
|
const { ensureConnectors, connectorLine } = await import("./connectors-DekQvKt9.mjs");
|
|
1156
|
-
const { jamLive } = await import("./plugin-
|
|
1156
|
+
const { jamLive } = await import("./plugin-C6jEpbCx.mjs").then((n) => n.a);
|
|
1157
1157
|
const results = ensureConnectors(root);
|
|
1158
1158
|
jamLive.connectors = results;
|
|
1159
1159
|
const line = connectorLine(results);
|
|
@@ -34,10 +34,13 @@ const noteHeight = (key) => noteHeights.get(key) ?? 0;
|
|
|
34
34
|
* the frames make way. An obstacle is another node's card, or its own note column (two columns
|
|
35
35
|
* running into each other cramp too) - the two rectangles, never their bounding box: the empty
|
|
36
36
|
* canvas under a card beside a long column is free. Missing nodes (a deleted frame's card, still
|
|
37
|
-
* drawn full size) block room but never host a note. `noteH` is the measured column extent
|
|
37
|
+
* drawn full size) block room but never host a note. `noteH` is the measured column extent - a pure lookup: it is
|
|
38
|
+
* asked once per node, when its room is first needed. */
|
|
38
39
|
function notesCramped(nodes, manifest, noteH = noteHeight) {
|
|
39
40
|
if (!manifest) return false;
|
|
40
|
-
const
|
|
41
|
+
const byId = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const f of manifest.frames) if (!byId.has(f.id)) byId.set(f.id, f);
|
|
43
|
+
const entry = (id) => byId.get(id);
|
|
41
44
|
const live = nodes.filter((n) => !n.missing);
|
|
42
45
|
const hosts = /* @__PURE__ */ new Set();
|
|
43
46
|
for (const s of manifest.scenes) {
|
|
@@ -61,12 +64,18 @@ function notesCramped(nodes, manifest, noteH = noteHeight) {
|
|
|
61
64
|
y1: n.y + Math.max(n.h + 28, noteH(n.key))
|
|
62
65
|
} : null;
|
|
63
66
|
};
|
|
67
|
+
const rooms = /* @__PURE__ */ new Map();
|
|
68
|
+
const roomOf = (n) => {
|
|
69
|
+
let r = rooms.get(n);
|
|
70
|
+
if (r === void 0) rooms.set(n, r = room(n));
|
|
71
|
+
return r;
|
|
72
|
+
};
|
|
64
73
|
return live.some((n) => {
|
|
65
|
-
const mine =
|
|
74
|
+
const mine = roomOf(n);
|
|
66
75
|
if (!mine) return false;
|
|
67
76
|
return nodes.some((o) => {
|
|
68
77
|
if (o === n) return false;
|
|
69
|
-
const theirs =
|
|
78
|
+
const theirs = roomOf(o);
|
|
70
79
|
return hit(mine, card(o)) || !!theirs && hit(mine, theirs);
|
|
71
80
|
});
|
|
72
81
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as ROUTE, o as slideSize } from "./cli.mjs";
|
|
2
2
|
import { s as checkRealDirs } from "./boards-Cim1GTKc.mjs";
|
|
3
3
|
import { n as BOARD_NAME } from "./board-tree-DGj0HhEE.mjs";
|
|
4
|
-
import { s as onPdfReset } from "./plugin-
|
|
5
|
-
import { c as pool, f as staleSurface, p as Browser } from "./shot-
|
|
4
|
+
import { s as onPdfReset } from "./plugin-C6jEpbCx.mjs";
|
|
5
|
+
import { c as pool, f as staleSurface, p as Browser } from "./shot-Ct2FiEbu.mjs";
|
|
6
6
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { join, sep } from "node:path";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
@@ -1216,7 +1216,7 @@ async function boardNodes(root, board, frames, viewports, themes, scenes = []) {
|
|
|
1216
1216
|
});
|
|
1217
1217
|
}
|
|
1218
1218
|
const { boardLayoutOf } = await import("./boards-Cim1GTKc.mjs").then((n) => n.a);
|
|
1219
|
-
const { notesCramped, tidyNodes } = await import("./notes-
|
|
1219
|
+
const { notesCramped, tidyNodes } = await import("./notes-CmfQ9604.mjs");
|
|
1220
1220
|
const { composed, flow } = boardLayoutOf(b);
|
|
1221
1221
|
const manifest = {
|
|
1222
1222
|
frames: frames.map((f) => ({
|
|
@@ -14,7 +14,7 @@ import { C as WRITE_MATCH_MS, S as WRITER_HEADERS, _ as ID12, b as RELOAD_BOUNDS
|
|
|
14
14
|
import { c as proofHeaders, i as logoRoute, s as appProofOk, t as findLogo } from "./logo-C9s7-Cy9.mjs";
|
|
15
15
|
import { n as loadConfig } from "./config-B0YcFtqS.mjs";
|
|
16
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-
|
|
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-Ct2FiEbu.mjs";
|
|
18
18
|
import { closeSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, watch, writeFileSync } from "node:fs";
|
|
19
19
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
@@ -184,8 +184,13 @@ function updatesPlugin(root, manifest, hooks, landed, changes) {
|
|
|
184
184
|
}
|
|
185
185
|
/** Wraps the client's hot channel: the reload guard and refused refreshes. `onStyles`: this server's, for a scanned file no
|
|
186
186
|
* document imports - it names the stylesheets that scan it, any of which may have new classes; no frame needs a reload. */
|
|
187
|
-
function guardUpdates(server, root, manifest, hooks, changes, onStyles) {
|
|
187
|
+
function guardUpdates(server, root, manifest, hooks, changes, onStyles, registryFile) {
|
|
188
188
|
const env = server.environments.client;
|
|
189
|
+
const registry = registryFile ? safeReal(registryFile) : null;
|
|
190
|
+
const viaRegistry = (u) => {
|
|
191
|
+
const f = u.path ? env.moduleGraph.urlToModuleMap.get(u.path)?.file : void 0;
|
|
192
|
+
return !!f && safeReal(f) === registry;
|
|
193
|
+
};
|
|
189
194
|
const notImported = (file) => [...env.moduleGraph.getModulesByFile(file) ?? []].every((m) => m.id == null || m.type === "asset");
|
|
190
195
|
const sheetsOf = (files) => {
|
|
191
196
|
const push = /* @__PURE__ */ new Set(), refused = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new Set();
|
|
@@ -216,6 +221,14 @@ function guardUpdates(server, root, manifest, hooks, changes, onStyles) {
|
|
|
216
221
|
const send = ch.send.bind(ch);
|
|
217
222
|
ch.send = (...a) => {
|
|
218
223
|
const p = a[0];
|
|
224
|
+
if (registry && typeof p === "object" && p?.type === "update" && p.updates.some(viaRegistry)) {
|
|
225
|
+
const updates = p.updates.filter((u) => !viaRegistry(u));
|
|
226
|
+
if (!updates.length) return;
|
|
227
|
+
a = [{
|
|
228
|
+
...p,
|
|
229
|
+
updates
|
|
230
|
+
}, ...a.slice(1)];
|
|
231
|
+
}
|
|
219
232
|
if (typeof p === "object" && p?.type === "full-reload") {
|
|
220
233
|
const passed = p.path === "*" && !p.triggeredBy;
|
|
221
234
|
const by = passed ? void 0 : p.triggeredBy ?? (p.path && p.path !== "*" ? join(root, p.path.replace(/^\//, "")) : void 0);
|
|
@@ -1383,7 +1396,8 @@ async function bakeBatch(opts) {
|
|
|
1383
1396
|
if (error !== void 0) return {
|
|
1384
1397
|
...ask,
|
|
1385
1398
|
ok: false,
|
|
1386
|
-
error
|
|
1399
|
+
error,
|
|
1400
|
+
kept: true
|
|
1387
1401
|
};
|
|
1388
1402
|
return readCached(root, gen, ask, urlBase) ?? theirs?.get(key(ask)) ?? (bakesEnded(owner) ? {
|
|
1389
1403
|
...ask,
|
|
@@ -1510,6 +1524,10 @@ async function bakeBatch(opts) {
|
|
|
1510
1524
|
if (!a.ok && keptFor(owner, a.error) && !bakesEnded(owner)) {
|
|
1511
1525
|
if (failed.size >= FAILED_MAX) failed.clear();
|
|
1512
1526
|
failed.set(key(job.ask), a.error);
|
|
1527
|
+
a = {
|
|
1528
|
+
...a,
|
|
1529
|
+
kept: true
|
|
1530
|
+
};
|
|
1513
1531
|
}
|
|
1514
1532
|
log?.(a);
|
|
1515
1533
|
settle(job, a);
|
|
@@ -3796,7 +3814,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3796
3814
|
};
|
|
3797
3815
|
const asPng = url.searchParams.get("format") === "png";
|
|
3798
3816
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3799
|
-
const { shootFrame } = await import("./shot-
|
|
3817
|
+
const { shootFrame } = await import("./shot-Ct2FiEbu.mjs").then((n) => n.u);
|
|
3800
3818
|
const r = await shootFrame({
|
|
3801
3819
|
root,
|
|
3802
3820
|
viewports: opts.viewports ?? {},
|
|
@@ -3834,7 +3852,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3834
3852
|
const { readDevInfo } = await import("./work-B4tydWnf.mjs").then((n) => n.c);
|
|
3835
3853
|
const token = readDevInfo(root)?.token;
|
|
3836
3854
|
if (!ownerGated(req) && !(token && req.headers["x-mv-work"] === token)) return json(res, 403, { error: "forbidden" });
|
|
3837
|
-
const pdf = await import("./pdf-
|
|
3855
|
+
const pdf = await import("./pdf-CkE4Ir2P.mjs");
|
|
3838
3856
|
if (pdfRoute[1] === void 0) {
|
|
3839
3857
|
if (req.method !== "POST") return json(res, 405, { error: "POST to start a PDF" });
|
|
3840
3858
|
const raw = await readBody(req);
|
|
@@ -3940,7 +3958,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3940
3958
|
if (typeof theme !== "string" || !/^[a-z0-9-]+$/i.test(theme)) return json(res, 400, { error: "invalid theme" });
|
|
3941
3959
|
const scale = body.scale === void 0 ? void 0 : body.scale;
|
|
3942
3960
|
if (scale !== void 0 && !(Number.isInteger(scale) && scale >= 1 && scale <= 4)) return json(res, 400, { error: "invalid scale" });
|
|
3943
|
-
const { resolveFrames, shootBatch } = await import("./shot-
|
|
3961
|
+
const { resolveFrames, shootBatch } = await import("./shot-Ct2FiEbu.mjs").then((n) => n.u);
|
|
3944
3962
|
const sel = resolveFrames(root, body);
|
|
3945
3963
|
if (!sel.ok) return json(res, sel.status, { error: sel.error });
|
|
3946
3964
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
@@ -3974,7 +3992,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
3974
3992
|
if (typeof target === "string") return json(res, 400, { error: target });
|
|
3975
3993
|
const others = Array.isArray(b.others) ? b.others.filter((o) => typeof o?.key === "string").slice(0, 200) : [];
|
|
3976
3994
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
3977
|
-
const { checkAnchor, CheckInputError } = await import("./anchor-check-
|
|
3995
|
+
const { checkAnchor, CheckInputError } = await import("./anchor-check-DREwCQiE.mjs");
|
|
3978
3996
|
try {
|
|
3979
3997
|
return json(res, 200, await checkAnchor({
|
|
3980
3998
|
root,
|
|
@@ -4082,8 +4100,8 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4082
4100
|
return json(res, 400, { error: "malformed JSON" });
|
|
4083
4101
|
}
|
|
4084
4102
|
const src = typeof b?.src === "string" ? b.src : "";
|
|
4085
|
-
const { ensurePoster, isLocalClip } = await import("./poster-
|
|
4086
|
-
const { isLocalAssetRef } = await import("./build-
|
|
4103
|
+
const { ensurePoster, isLocalClip } = await import("./poster-d10h73z0.mjs");
|
|
4104
|
+
const { isLocalAssetRef } = await import("./build-3AH123fe.mjs");
|
|
4087
4105
|
if (!isLocalAssetRef(src) || !isLocalClip(src)) return json(res, 400, { error: "src must be a clip under design/assets/" });
|
|
4088
4106
|
const r = await ensurePoster(join(root, "design", "assets"), src);
|
|
4089
4107
|
if (!r.ok) return json(res, r.error.includes("does not exist") ? 404 : 503, { error: r.error });
|
|
@@ -4539,7 +4557,7 @@ function apiMiddleware(root, opts = {}) {
|
|
|
4539
4557
|
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? }" });
|
|
4540
4558
|
if (readCapture(root, b.capture)) return json(res, 409, { error: "that capture is sealed" });
|
|
4541
4559
|
const theme = typeof b.theme === "string" && /^[a-z0-9-]+$/i.test(b.theme) ? b.theme : "light";
|
|
4542
|
-
const { shootFrame } = await import("./shot-
|
|
4560
|
+
const { shootFrame } = await import("./shot-Ct2FiEbu.mjs").then((n) => n.u);
|
|
4543
4561
|
const origin = opts.origin?.() ?? `http://${req.headers.host ?? "localhost"}`;
|
|
4544
4562
|
const vp = typeof b.viewport === "string" ? opts.viewports?.[b.viewport] : void 0;
|
|
4545
4563
|
const dim = (v) => typeof v === "number" && Number.isFinite(v) ? Math.round(v) : void 0;
|
|
@@ -5668,7 +5686,7 @@ function marverPlugin(ctx) {
|
|
|
5668
5686
|
server.httpServer?.once("close", () => resetPdf(root));
|
|
5669
5687
|
server.middlewares.use((req, res, next) => {
|
|
5670
5688
|
if (!(req.url ?? "").startsWith(`/__mv/handout/`)) return next();
|
|
5671
|
-
import("./pdf-
|
|
5689
|
+
import("./pdf-CkE4Ir2P.mjs").then((m) => m.handoutMiddleware()(req, res, next), next);
|
|
5672
5690
|
});
|
|
5673
5691
|
server.middlewares.use(apiMiddleware(root, {
|
|
5674
5692
|
viewports: config.viewports,
|
|
@@ -5696,7 +5714,7 @@ function marverPlugin(ctx) {
|
|
|
5696
5714
|
onClose(() => {
|
|
5697
5715
|
if (devServer === server) devServer = before;
|
|
5698
5716
|
});
|
|
5699
|
-
guardUpdates(server, root, () => manifest, hooks, changes, (sheets) => rescanTheme(sheets));
|
|
5717
|
+
guardUpdates(server, root, () => manifest, hooks, changes, (sheets) => rescanTheme(sheets), join(clientDir, "frame-host", "registry.ts"));
|
|
5700
5718
|
let framesKey = JSON.stringify(manifest.frames);
|
|
5701
5719
|
let scenesKey = JSON.stringify(manifest.scenes);
|
|
5702
5720
|
let unplacedKey = "";
|
|
@@ -5728,11 +5746,12 @@ function marverPlugin(ctx) {
|
|
|
5728
5746
|
if (!f) return [];
|
|
5729
5747
|
const out = [];
|
|
5730
5748
|
const seen = /* @__PURE__ */ new Set();
|
|
5749
|
+
const css = (mod) => String(mod.id ?? "").split("?")[0].endsWith(".css");
|
|
5731
5750
|
const walk = (mod) => {
|
|
5732
5751
|
if (!mod || seen.has(mod)) return;
|
|
5733
5752
|
seen.add(mod);
|
|
5734
|
-
out.push(mod);
|
|
5735
|
-
for (const im of mod.clientImportedModules ?? mod.importedModules ?? []) if (
|
|
5753
|
+
if (css(mod)) out.push(mod);
|
|
5754
|
+
for (const im of mod.clientImportedModules ?? mod.importedModules ?? []) if (css(im)) walk(im);
|
|
5736
5755
|
};
|
|
5737
5756
|
for (const mod of server.moduleGraph.getModulesByFile(f) ?? []) walk(mod);
|
|
5738
5757
|
return out;
|
|
@@ -5750,10 +5769,14 @@ function marverPlugin(ctx) {
|
|
|
5750
5769
|
pushTheme();
|
|
5751
5770
|
};
|
|
5752
5771
|
const localDir = join(root, "design", ".local"), boardsDirGen = join(root, "design", "boards"), manifestPath = join(root, "design", "manifest.json");
|
|
5772
|
+
let genPush;
|
|
5773
|
+
onClose(() => clearTimeout(genPush));
|
|
5753
5774
|
const bumpGen = (f) => {
|
|
5754
5775
|
if (f.startsWith(localDir) || f.startsWith(boardsDirGen) || f === manifestPath || f.includes("/node_modules/")) return;
|
|
5755
5776
|
bakeGen++;
|
|
5756
5777
|
prune();
|
|
5778
|
+
clearTimeout(genPush);
|
|
5779
|
+
genPush = setTimeout(() => server.ws.send("sh:bake-gen", { gen: bakeGen }), 300);
|
|
5757
5780
|
};
|
|
5758
5781
|
const pruning = /* @__PURE__ */ new Set();
|
|
5759
5782
|
const prune = () => {
|
|
@@ -5954,7 +5977,7 @@ function marverPlugin(ctx) {
|
|
|
5954
5977
|
});
|
|
5955
5978
|
return;
|
|
5956
5979
|
}
|
|
5957
|
-
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-
|
|
5980
|
+
const { shootFrame, shootBatch, resolveFrames } = await import("./shot-Ct2FiEbu.mjs").then((n) => n.u);
|
|
5958
5981
|
if (ways[0] === "frame") {
|
|
5959
5982
|
if (typeof spec.frame !== "string") {
|
|
5960
5983
|
write({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as capture, m as findChrome } from "./shot-
|
|
1
|
+
import { i as capture, m as findChrome } from "./shot-Ct2FiEbu.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 { l as ASK_MAX, u as bakeBatch } from "./plugin-
|
|
3
|
-
import { m as findChrome, s as planShot } from "./shot-
|
|
2
|
+
import { l as ASK_MAX, u as bakeBatch } from "./plugin-C6jEpbCx.mjs";
|
|
3
|
+
import { m as findChrome, s as planShot } from "./shot-Ct2FiEbu.mjs";
|
|
4
4
|
import { MIME } from "./serve-kcF6-H8V.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-BOcfIqxy.mjs";
|
|
3
|
-
import { DevStartError, dev } from "./dev-
|
|
3
|
+
import { DevStartError, dev } from "./dev-Dw6mcoP8.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-3AH123fe.mjs");
|
|
528
|
+
const { ensurePoster } = await import("./poster-d10h73z0.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
|
@@ -162,6 +162,10 @@ Read the load, name the lever, change it, compare the next load - you, or your a
|
|
|
162
162
|
file was deleted or renamed.
|
|
163
163
|
- **The weight** (`settled.weight`) says how heavy the settled board is: elements in the page and its
|
|
164
164
|
frames, frames awake and asleep, the heap.
|
|
165
|
+
- **A board too heavy for one tab** (in Chrome and the Mac app, which report the heap): past three quarters of the
|
|
166
|
+
tab's memory limit the canvas starts no more frames on its own. A frame you can read on screen - or select - still
|
|
167
|
+
starts within a few seconds, and the rest follow once memory is back under 60%. The board stays open where it used
|
|
168
|
+
to crash; frames not yet started show their placeholder. The lasting fix is still a smaller board: split it.
|
|
165
169
|
- **Late moves** came after the load ended - settled, or cut. After a cut at 120 s, or while the page was
|
|
166
170
|
hidden, they are the board still loading. After it settled - and any **`unknown`** move, with no cause
|
|
167
171
|
named - they say something moved the board after it looked done: worth a look, or an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marver-design/marver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
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,
|
package/src/client/const.ts
CHANGED
|
@@ -7,6 +7,11 @@ export const ROUTE = '/__mv'
|
|
|
7
7
|
/** Content-frame natural widths: Doc layout -> own-size width.
|
|
8
8
|
* Shared by the Doc primitive (measurement messages) and the server-side
|
|
9
9
|
* manifest scan (defaultSize for content frames) - one source, no drift. */
|
|
10
|
+
/** Image-LOD's smallest decode width, in device px (content/img-lod.ts's first bucket): under it a frame on screen is a
|
|
11
|
+
* thumbnail - the heap gate's "too small to be read" (canvas/admission.ts) uses the same line. */
|
|
12
|
+
export const LOD_MIN_PX = 256
|
|
13
|
+
/** The ordinary camera's closest zoom: a wheel or pinch (Canvas.tsx) and the zoom menu's top preset. */
|
|
14
|
+
export const ZOOM_MAX = 2
|
|
10
15
|
export const CONTENT_WIDTH: Record<string, number> = { document: 760, wide: 1280 }
|
|
11
16
|
|
|
12
17
|
/** The default slide stage: 16:9 at 1280×720, deliberately NOT a config viewport - no
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
// never triggers a decode/resample storm. Crisp at rest, cheap in motion. This mirrors how tldraw does
|
|
12
12
|
// LOD (resolution by on-screen size, debounced so it never thrashes mid-zoom).
|
|
13
13
|
|
|
14
|
+
import { LOD_MIN_PX } from '../const.ts'
|
|
15
|
+
|
|
14
16
|
/** Feature probe: createImageBitmap with resize + a canvas bitmaprenderer that can receive it. */
|
|
15
17
|
export const lodSupported = (() => {
|
|
16
18
|
try {
|
|
@@ -22,7 +24,7 @@ export const lodSupported = (() => {
|
|
|
22
24
|
|
|
23
25
|
// Quantized resize widths (device px). A `want` above the top bucket decodes at NATIVE (bucket 0 = no
|
|
24
26
|
// resize), reached only when a frame is zoomed in past ~2048 on-screen device px.
|
|
25
|
-
const BUCKETS = [
|
|
27
|
+
const BUCKETS = [LOD_MIN_PX, 640, 1280, 2048]
|
|
26
28
|
const DPR = (): number => Math.min(window.devicePixelRatio || 1, 2) // cap at 2; 3x buys nothing here
|
|
27
29
|
|
|
28
30
|
// Bounded decode pool: never run more than N createImageBitmap jobs at once (peak decode memory + CPU).
|
|
@@ -122,3 +122,46 @@ export function watchInplace(hot: { on(event: string, cb: (p: any) => void): voi
|
|
|
122
122
|
} catch { /* the same */ }
|
|
123
123
|
})
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
// ---- element stacks while modules load (item 9) --------------------------------------------------------------
|
|
127
|
+
// here rather than in a module of its own: one module fewer for every frame document to fetch
|
|
128
|
+
/**
|
|
129
|
+
* React's development build gives each element it makes a debug stack and a console task (an `Error` and a
|
|
130
|
+
* `console.createTask`), up to 10,000 a second, counted on its shared internals (`recentlyCreatedOwnerStacks`; the
|
|
131
|
+
* renderer gives the budget back at most once a second). An element a module makes as it LOADS - an icon library's
|
|
132
|
+
* hoisted glyphs: phosphor makes one per weight, six per icon, for the whole barrel - has no owner, and its stack would
|
|
133
|
+
* name the import chain. On a heavy frame those were a quarter of a second and megabytes of every document (measured,
|
|
134
|
+
* item 9: `createElement` was 25 s of a 112-frame board's 44).
|
|
135
|
+
*
|
|
136
|
+
* While the frame's own modules evaluate, the budget reads as spent - the path React itself takes past its limit: the
|
|
137
|
+
* element shares React's "unknown owner" stack and task. After, the count is put back where it was, as if those
|
|
138
|
+
* elements had never been counted: a render's elements get their stacks as they would on a frame without them - never
|
|
139
|
+
* fewer than before (a load of thousands of glyphs used to spend the budget before the first render, when it finished
|
|
140
|
+
* inside React's one-second reset). A React without the counter (a production build, React 18, 19.0) is left as it is.
|
|
141
|
+
*
|
|
142
|
+
* Held only while the frame host BOOTS (main.tsx): no root of the frame host exists yet, so no render of its own can
|
|
143
|
+
* make an element in the window. A renderer reset during the hold (React's, at most once a second, when it prepares a
|
|
144
|
+
* render) simply ends it early. One case it does not tell apart: a module that mounts a React root of its own while the
|
|
145
|
+
* frame is still loading - that root's elements made in the window share the stack too. Never held around an update
|
|
146
|
+
* applied in place: a root renders meanwhile, and Vite sends no vite:afterUpdate when a dispose or accept callback throws.
|
|
147
|
+
*/
|
|
148
|
+
const INTERNALS = '__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE'
|
|
149
|
+
/** Far past any limit React uses, so no element made during the hold is given a stack. */
|
|
150
|
+
const SPENT = 2 ** 40
|
|
151
|
+
|
|
152
|
+
/** Hold React's element stacks; the function returned gives the count back. Call it once, after the modules loaded. */
|
|
153
|
+
export function holdElementStacks(react: object): () => void {
|
|
154
|
+
const internals = (react as Record<string, unknown>)[INTERNALS] as { recentlyCreatedOwnerStacks?: unknown } | undefined
|
|
155
|
+
if (!internals || typeof internals.recentlyCreatedOwnerStacks !== 'number') return () => {}
|
|
156
|
+
const was = internals.recentlyCreatedOwnerStacks
|
|
157
|
+
internals.recentlyCreatedOwnerStacks = SPENT
|
|
158
|
+
let given = false
|
|
159
|
+
return () => {
|
|
160
|
+
if (given) return
|
|
161
|
+
given = true
|
|
162
|
+
const now = internals.recentlyCreatedOwnerStacks
|
|
163
|
+
// the renderer set it back meanwhile (a render during the hold, which ended it): its count is the true one
|
|
164
|
+
if (typeof now !== 'number' || now < SPENT) return
|
|
165
|
+
internals.recentlyCreatedOwnerStacks = was
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Boot failures (theme, providers, layouts, the frame itself) render a plain-DOM error card
|
|
4
4
|
* and post sh:error; an ErrorBoundary catches render-time throws the same way.
|
|
5
5
|
*/
|
|
6
|
+
import * as React from 'react'
|
|
6
7
|
import { Component, createElement, Profiler, useLayoutEffect, type ReactNode } from 'react'
|
|
7
8
|
import { createRoot } from 'react-dom/client'
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ import { frameRenders } from './signals.js'
|
|
|
11
12
|
import { frameFile, frames, layoutChain, layouts, providers } from './registry.ts'
|
|
12
13
|
import { SLIDE_DOC_CSS } from '../const.ts'
|
|
13
14
|
import { fullRecorder } from '../recorder-level.ts'
|
|
14
|
-
import { rootCommitted, watchInplace } from './inplace.ts'
|
|
15
|
+
import { holdElementStacks, rootCommitted, watchInplace } from './inplace.ts'
|
|
15
16
|
|
|
16
17
|
const params = new URLSearchParams(location.search)
|
|
17
18
|
const id = params.get('id') ?? ''
|
|
@@ -82,7 +83,12 @@ function Committed({ onCommit, children }: { onCommit: () => void; children?: Re
|
|
|
82
83
|
|
|
83
84
|
async function boot() {
|
|
84
85
|
const phases: Record<string, number> = { boot: Math.round(performance.now()) } // ms since navigation: where a boot spends its time (research/hifi/bootscale.ts)
|
|
86
|
+
// the elements the theme, the frame and its wrappers make as they load get no debug stack each (inplace.ts,
|
|
87
|
+
// holdElementStacks): no root of ours exists yet, so no render of ours can make an element in the window. Updates
|
|
88
|
+
// applied in place later are NOT held - a root renders meanwhile, and Vite skips vite:afterUpdate when a callback throws
|
|
89
|
+
let giveStacks = () => {}
|
|
85
90
|
try {
|
|
91
|
+
giveStacks = holdElementStacks(React)
|
|
86
92
|
await import('virtual:sh-theme' as string)
|
|
87
93
|
phases.theme = Math.round(performance.now())
|
|
88
94
|
|
|
@@ -113,6 +119,7 @@ async function boot() {
|
|
|
113
119
|
for (const lk of layoutChain(fileKey)) wrappers.push((await layouts[lk]() as any).default)
|
|
114
120
|
|
|
115
121
|
phases.wrappers = Math.round(performance.now())
|
|
122
|
+
giveStacks()
|
|
116
123
|
let tree: ReactNode = createElement(Frame)
|
|
117
124
|
for (const W of wrappers.reverse()) if (W != null) tree = createElement(W, null, tree)
|
|
118
125
|
|
|
@@ -126,6 +133,8 @@ async function boot() {
|
|
|
126
133
|
createRoot(document.getElementById('root')!).render(onRender ? createElement(Profiler, { id: 'frame', onRender }, app) : app)
|
|
127
134
|
} catch (err) {
|
|
128
135
|
fail((err as Error).message, err)
|
|
136
|
+
} finally {
|
|
137
|
+
giveStacks()
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
|