@1agh/maude 2.0.6 → 2.0.8
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/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +27 -0
- package/apps/studio/actions/agents.ts +54 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +136 -1
- package/apps/studio/actions.parity.json +25 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -3
- package/apps/studio/api.ts +383 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +414 -45
- package/apps/studio/artboard-live.ts +526 -31
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +2 -1
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/perf.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +160 -34
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +23 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +11 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/shell/viewport.jsx +32 -16
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +7 -3
- package/apps/studio/client/v2/code/canvas-imports-words.js +16 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +40 -5
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +3 -1
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +4 -1
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +720 -720
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +6 -3
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/cli.ts +7 -1
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-stage.ts +6 -2
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/http.ts +66 -32
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-plane.ts +458 -53
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +99 -15
- package/apps/studio/sync/seed-progress.ts +92 -2
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +15 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +55 -42
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +27 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +14 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// _perf-probe-open.mjs — the OPEN lane behind `perf.sh --open` (2.0.7 smooth canvases).
|
|
3
|
+
//
|
|
4
|
+
// The pan/zoom probes start once a canvas is up. This one times what Michal felt: opening a heavy
|
|
5
|
+
// canvas inside the studio and moving it WHILE it loads. It opens the studio at `/?open=<rel>`,
|
|
6
|
+
// records from the canvas frame's first script (an init script, so nothing before the probe is missed):
|
|
7
|
+
//
|
|
8
|
+
// firstArtboard open → the first `[data-dc-screen]` in the frame
|
|
9
|
+
// firstPaint open → the first on-screen artboard whose content is drawn (not a placeholder)
|
|
10
|
+
// allVisible open → every on-screen artboard drawn (no placeholder inside, every <img> decoded)
|
|
11
|
+
// viewportCorrect gesture end → every on-screen artboard drawn (the camera settled: is what you see right?)
|
|
12
|
+
// long tasks during the open and during the gesture (Chromium; WebKit has none — long FRAMES
|
|
13
|
+
// (rAF delta ≥ 50 ms) are reported on both engines)
|
|
14
|
+
// gesture frames a pan + zoom that starts the moment the first artboard is there (the canvas is
|
|
15
|
+
// still loading), and how long its frames took
|
|
16
|
+
// placeholders how many on-screen artboards still showed a placeholder when the gesture ended,
|
|
17
|
+
// and whether any placeholder painted as solid black
|
|
18
|
+
// memory JS heap (Chromium) and the frame's DOM element count (both engines)
|
|
19
|
+
//
|
|
20
|
+
// Both engines through Playwright (`--engine chromium|webkit`); WebKit is what the desktop app runs.
|
|
21
|
+
// Deliberately not a CI gate (timings swing with machine load) — run before and after, same machine.
|
|
22
|
+
//
|
|
23
|
+
// Usage: node _perf-probe-open.mjs --url <studio-root> --open <designRoot-relative .tsx>
|
|
24
|
+
// [--engine chromium|webkit] [--window WxH] [--dpr N] [--gesture-ms N] [--timeout S]
|
|
25
|
+
// [--shot <png>] [--shot-mid <png>] [--json]
|
|
26
|
+
// Exit: 0 measured / 1 failed / 2 bad args.
|
|
27
|
+
|
|
28
|
+
import { launchChromium, launchWebkit } from './_pw-launch.mjs';
|
|
29
|
+
|
|
30
|
+
function parseArgs(argv) {
|
|
31
|
+
const o = {
|
|
32
|
+
url: '',
|
|
33
|
+
open: '',
|
|
34
|
+
engine: 'chromium',
|
|
35
|
+
window: '1600x1000',
|
|
36
|
+
dpr: 2,
|
|
37
|
+
gestureMs: 4000,
|
|
38
|
+
gestureDelay: 0,
|
|
39
|
+
timeout: 60,
|
|
40
|
+
shot: '',
|
|
41
|
+
shotMid: '',
|
|
42
|
+
profile: '',
|
|
43
|
+
bare: null,
|
|
44
|
+
injectCss: '',
|
|
45
|
+
json: false,
|
|
46
|
+
};
|
|
47
|
+
for (let i = 0; i < argv.length; i++) {
|
|
48
|
+
const a = argv[i];
|
|
49
|
+
const v = () => argv[++i];
|
|
50
|
+
if (a === '--url') o.url = v();
|
|
51
|
+
else if (a === '--open') o.open = v();
|
|
52
|
+
else if (a === '--engine') o.engine = v();
|
|
53
|
+
else if (a === '--window') o.window = v();
|
|
54
|
+
else if (a === '--dpr') o.dpr = Number(v());
|
|
55
|
+
else if (a === '--gesture-ms') o.gestureMs = Number(v());
|
|
56
|
+
// --gesture-delay: start the gesture this long after the first artboard (a settled canvas), not at once
|
|
57
|
+
else if (a === '--gesture-delay') o.gestureDelay = Number(v());
|
|
58
|
+
else if (a === '--timeout') o.timeout = Number(v());
|
|
59
|
+
else if (a === '--shot') o.shot = v();
|
|
60
|
+
else if (a === '--shot-mid') o.shotMid = v();
|
|
61
|
+
else if (a === '--profile') o.profile = v();
|
|
62
|
+
else if (a === '--bare') o.bare = v();
|
|
63
|
+
else if (a === '--inject-css') o.injectCss = v();
|
|
64
|
+
else if (a === '--json') o.json = true;
|
|
65
|
+
else {
|
|
66
|
+
console.error(`_perf-probe-open.mjs: unknown arg '${a}'`);
|
|
67
|
+
process.exit(2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const m = /^(\d{3,5})x(\d{3,5})$/.exec(o.window);
|
|
71
|
+
if (!o.url || !o.open || !m || !['chromium', 'webkit'].includes(o.engine)) {
|
|
72
|
+
console.error('_perf-probe-open.mjs: --url, --open, --window WxH, --engine chromium|webkit');
|
|
73
|
+
process.exit(2);
|
|
74
|
+
}
|
|
75
|
+
o.viewport = { width: Number(m[1]), height: Number(m[2]) };
|
|
76
|
+
return o;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Runs first in every frame; only the canvas frame records.
|
|
80
|
+
const INIT = `(() => {
|
|
81
|
+
if (!/_canvas-shell/.test(location.pathname)) return;
|
|
82
|
+
const P = (window.__maudeOpenProbe = { frames: [], long: [], marks: {}, black: 0 });
|
|
83
|
+
const now = () => performance.timeOrigin + performance.now();
|
|
84
|
+
let last = 0;
|
|
85
|
+
const loop = (t) => { const at = performance.timeOrigin + t; if (last) P.frames.push([at, at - last]); last = at; (window.__maudeFrameFreeze ? window.__maudeFrameFreeze.raf : requestAnimationFrame)(loop); };
|
|
86
|
+
(window.__maudeFrameFreeze ? window.__maudeFrameFreeze.raf : requestAnimationFrame)(loop);
|
|
87
|
+
try { new PerformanceObserver((l) => { for (const e of l.getEntries()) P.long.push([performance.timeOrigin + e.startTime, e.duration]); }).observe({ type: 'longtask', buffered: true }); } catch {}
|
|
88
|
+
const PH = '.dc-artboard-sleeping, .ds-specimen-pending, [data-dc-placeholder]';
|
|
89
|
+
// On-screen = an IntersectionObserver's answer, never getBoundingClientRect: a poll that forces a
|
|
90
|
+
// synchronous layout of a 40k-node canvas 20x a second measures the probe, not the canvas.
|
|
91
|
+
const onScreen = new Set();
|
|
92
|
+
const io = new IntersectionObserver((es) => { for (const e of es) e.isIntersecting ? onScreen.add(e.target) : onScreen.delete(e.target); });
|
|
93
|
+
const watched = new WeakSet();
|
|
94
|
+
P.state = () => {
|
|
95
|
+
let on = 0, drawn = 0, ph = 0, total = 0;
|
|
96
|
+
for (const a of document.querySelectorAll('[data-dc-screen]')) {
|
|
97
|
+
total++;
|
|
98
|
+
if (!watched.has(a)) { watched.add(a); io.observe(a); }
|
|
99
|
+
if (!onScreen.has(a)) continue;
|
|
100
|
+
on++;
|
|
101
|
+
const body = a.querySelector('.dc-artboard-body');
|
|
102
|
+
if (!body) continue;
|
|
103
|
+
if (body.querySelector(PH)) { ph++; continue; }
|
|
104
|
+
let ok = true;
|
|
105
|
+
for (const img of body.getElementsByTagName('img')) if (!img.complete) { ok = false; break; }
|
|
106
|
+
if (ok) drawn++;
|
|
107
|
+
}
|
|
108
|
+
return { total, on, drawn, ph };
|
|
109
|
+
};
|
|
110
|
+
const tick = () => {
|
|
111
|
+
const s = P.state();
|
|
112
|
+
const t = now();
|
|
113
|
+
if (s.total && !P.marks.firstArtboard) P.marks.firstArtboard = t;
|
|
114
|
+
if (s.drawn && !P.marks.firstPaint) P.marks.firstPaint = t;
|
|
115
|
+
if (s.on && s.drawn === s.on && !P.marks.allVisible) P.marks.allVisible = t;
|
|
116
|
+
if (P.marks.allVisible && s.drawn < s.on) P.marks.allVisible = 0; // a later artboard came on screen undrawn
|
|
117
|
+
// viewport correct: once the gesture is over (the probe sets settleFrom), every on-screen artboard drawn
|
|
118
|
+
if (P.settleFrom && !P.marks.viewportCorrect && s.on && s.drawn === s.on) P.marks.viewportCorrect = t;
|
|
119
|
+
};
|
|
120
|
+
setInterval(tick, 100);
|
|
121
|
+
})();`;
|
|
122
|
+
|
|
123
|
+
function stats(deltas) {
|
|
124
|
+
if (!deltas.length) return { n: 0, p50: 0, p95: 0, max: 0, long: 0 };
|
|
125
|
+
const s = [...deltas].sort((a, b) => a - b);
|
|
126
|
+
const q = (p) => Math.round(s[Math.min(s.length - 1, Math.floor(p * s.length))] * 10) / 10;
|
|
127
|
+
return {
|
|
128
|
+
n: s.length,
|
|
129
|
+
p50: q(0.5),
|
|
130
|
+
p95: q(0.95),
|
|
131
|
+
max: Math.round(s[s.length - 1]),
|
|
132
|
+
long: s.filter((d) => d >= 50).length,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
137
|
+
|
|
138
|
+
async function main() {
|
|
139
|
+
const o = parseArgs(process.argv.slice(2));
|
|
140
|
+
const browser = await (o.engine === 'webkit' ? launchWebkit() : launchChromium());
|
|
141
|
+
try {
|
|
142
|
+
const ctx = await browser.newContext({ viewport: o.viewport, deviceScaleFactor: o.dpr });
|
|
143
|
+
await ctx.addInitScript(INIT);
|
|
144
|
+
// --inject-css: test a rendering hypothesis against the same build (canvas frame only)
|
|
145
|
+
if (o.injectCss)
|
|
146
|
+
await ctx.addInitScript(
|
|
147
|
+
`if (/_canvas-shell/.test(location.pathname)) document.addEventListener('DOMContentLoaded', () => { const s = document.createElement('style'); s.textContent = ${JSON.stringify(o.injectCss)}; document.head.appendChild(s); });`
|
|
148
|
+
);
|
|
149
|
+
const page = await ctx.newPage();
|
|
150
|
+
// Chromium: where the main thread's time went (script vs style vs layout), whole open + gesture.
|
|
151
|
+
const cdp = o.engine === 'chromium' ? await ctx.newCDPSession(page).catch(() => null) : null;
|
|
152
|
+
if (cdp) await cdp.send('Performance.enable').catch(() => {});
|
|
153
|
+
const metrics = async () => {
|
|
154
|
+
if (!cdp) return null;
|
|
155
|
+
const r = await cdp.send('Performance.getMetrics').catch(() => null);
|
|
156
|
+
const m = {};
|
|
157
|
+
for (const { name, value } of r?.metrics || []) m[name] = value;
|
|
158
|
+
return m;
|
|
159
|
+
};
|
|
160
|
+
const t0 = Date.now();
|
|
161
|
+
const enc = o.open.split('/').map(encodeURIComponent).join('/');
|
|
162
|
+
// --bare <query>: the canvas page on its own (top level — every artboard live unless the query says
|
|
163
|
+
// otherwise, e.g. `artboard-live=sleep`), to A/B the runtime without the studio around it.
|
|
164
|
+
await page.goto(
|
|
165
|
+
o.bare != null
|
|
166
|
+
? `${o.url.replace(/\/$/, '')}/_canvas-shell.html?canvas=${enc}${o.bare ? `&${o.bare}` : ''}`
|
|
167
|
+
: `${o.url.replace(/\/$/, '')}/?open=${enc}`,
|
|
168
|
+
{ waitUntil: 'domcontentloaded' }
|
|
169
|
+
);
|
|
170
|
+
let frame = null;
|
|
171
|
+
const deadline = t0 + o.timeout * 1000;
|
|
172
|
+
while (Date.now() < deadline) {
|
|
173
|
+
frame = page.frames().find((f) => /_canvas-shell/.test(f.url())) || null;
|
|
174
|
+
if (frame) {
|
|
175
|
+
const ok = await frame
|
|
176
|
+
.evaluate(() => !!window.__maudeOpenProbe?.marks.firstArtboard)
|
|
177
|
+
.catch(() => false);
|
|
178
|
+
if (ok) break;
|
|
179
|
+
}
|
|
180
|
+
await sleep(25);
|
|
181
|
+
}
|
|
182
|
+
if (!frame) throw new Error('the canvas frame never appeared');
|
|
183
|
+
// The gesture starts NOW — the canvas is still loading. Pan and zoom over the frame.
|
|
184
|
+
const cx = o.viewport.width / 2;
|
|
185
|
+
const cy = o.viewport.height / 2;
|
|
186
|
+
await page.mouse.move(cx, cy);
|
|
187
|
+
if (cdp && o.profile) {
|
|
188
|
+
await cdp.send('Profiler.enable');
|
|
189
|
+
await cdp.send('Profiler.start');
|
|
190
|
+
}
|
|
191
|
+
if (o.gestureDelay > 0) await sleep(o.gestureDelay);
|
|
192
|
+
const m0 = await metrics();
|
|
193
|
+
const g0 = Date.now();
|
|
194
|
+
const steps = Math.max(1, Math.round(o.gestureMs / 16));
|
|
195
|
+
let mid = false;
|
|
196
|
+
let sent = 0;
|
|
197
|
+
for (let i = 0; i < steps && Date.now() - g0 < o.gestureMs; i++) {
|
|
198
|
+
const phase = (Date.now() - g0) / o.gestureMs;
|
|
199
|
+
sent++;
|
|
200
|
+
if (phase < 0.6) {
|
|
201
|
+
// pan: a slow loop to the right/down and back
|
|
202
|
+
const dir = phase < 0.3 ? 1 : -1;
|
|
203
|
+
await page.mouse.wheel(18 * dir, 10 * dir);
|
|
204
|
+
} else {
|
|
205
|
+
// zoom: in then out (ctrl+wheel is a pinch)
|
|
206
|
+
await page.keyboard.down('Control');
|
|
207
|
+
await page.mouse.wheel(0, phase < 0.8 ? -6 : 6);
|
|
208
|
+
await page.keyboard.up('Control');
|
|
209
|
+
}
|
|
210
|
+
if (!mid && o.shotMid && Date.now() - g0 > o.gestureMs * 0.25) {
|
|
211
|
+
mid = true;
|
|
212
|
+
await page.screenshot({ path: o.shotMid });
|
|
213
|
+
}
|
|
214
|
+
await sleep(16);
|
|
215
|
+
}
|
|
216
|
+
const g1 = Date.now();
|
|
217
|
+
await frame
|
|
218
|
+
.evaluate(() => {
|
|
219
|
+
window.__maudeOpenProbe.settleFrom = Date.now();
|
|
220
|
+
})
|
|
221
|
+
.catch(() => {});
|
|
222
|
+
const m1 = await metrics();
|
|
223
|
+
if (cdp && o.profile) {
|
|
224
|
+
const { profile } = await cdp.send('Profiler.stop');
|
|
225
|
+
// self time per function (url:line), top 25 — the raw profile is huge
|
|
226
|
+
const self = new Map();
|
|
227
|
+
const dt = profile.timeDeltas || [];
|
|
228
|
+
const byId = new Map(profile.nodes.map((n) => [n.id, n]));
|
|
229
|
+
(profile.samples || []).forEach((id, i) => {
|
|
230
|
+
const n = byId.get(id);
|
|
231
|
+
const f = n.callFrame;
|
|
232
|
+
const k = `${f.functionName || '(anon)'} ${f.url.replace(/^.*\//, '')}:${f.lineNumber}`;
|
|
233
|
+
self.set(k, (self.get(k) || 0) + (dt[i] || 0) / 1000);
|
|
234
|
+
});
|
|
235
|
+
// inclusive time per JS function (each function counted once per sample), to find the caller of a native hot spot
|
|
236
|
+
const parent = new Map();
|
|
237
|
+
for (const n of profile.nodes) for (const c of n.children || []) parent.set(c, n.id);
|
|
238
|
+
const incl = new Map();
|
|
239
|
+
(profile.samples || []).forEach((id, i) => {
|
|
240
|
+
const seen = new Set();
|
|
241
|
+
for (let cur = id; cur != null; cur = parent.get(cur)) {
|
|
242
|
+
const f = byId.get(cur).callFrame;
|
|
243
|
+
if (!f.url) continue;
|
|
244
|
+
const k = `${f.functionName || '(anon)'} ${f.url.replace(/^.*\//, '').replace(/\?.*$/, '')}:${f.lineNumber}`;
|
|
245
|
+
if (seen.has(k)) continue;
|
|
246
|
+
seen.add(k);
|
|
247
|
+
incl.set(k, (incl.get(k) || 0) + (dt[i] || 0) / 1000);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
// who calls the native hot spots (querySelectorAll, getBoundingClientRect…): native leaf ← nearest JS frame
|
|
251
|
+
const callers = new Map();
|
|
252
|
+
(profile.samples || []).forEach((id, i) => {
|
|
253
|
+
const leaf = byId.get(id).callFrame;
|
|
254
|
+
if (leaf.url || !leaf.functionName || leaf.functionName.startsWith('(')) return;
|
|
255
|
+
let cur = parent.get(id);
|
|
256
|
+
while (cur != null && !byId.get(cur).callFrame.url) cur = parent.get(cur);
|
|
257
|
+
const f = cur != null ? byId.get(cur).callFrame : null;
|
|
258
|
+
const k = `${leaf.functionName} <- ${f ? `${f.functionName || '(anon)'} ${f.url.replace(/^.*\//, '').replace(/\?.*$/, '')}:${f.lineNumber}` : '?'}`;
|
|
259
|
+
callers.set(k, (callers.get(k) || 0) + (dt[i] || 0) / 1000);
|
|
260
|
+
});
|
|
261
|
+
const top = [
|
|
262
|
+
...[...self]
|
|
263
|
+
.sort((a, b) => b[1] - a[1])
|
|
264
|
+
.slice(0, 15)
|
|
265
|
+
.map(([k, v]) => `self ${Math.round(v)}ms ${k}`),
|
|
266
|
+
...[...callers]
|
|
267
|
+
.sort((a, b) => b[1] - a[1])
|
|
268
|
+
.slice(0, 12)
|
|
269
|
+
.map(([k, v]) => `native ${Math.round(v)}ms ${k}`),
|
|
270
|
+
...[...incl]
|
|
271
|
+
.sort((a, b) => b[1] - a[1])
|
|
272
|
+
.slice(0, 30)
|
|
273
|
+
.map(([k, v]) => `incl ${Math.round(v)}ms ${k}`),
|
|
274
|
+
];
|
|
275
|
+
(await import('node:fs')).writeFileSync(o.profile, top.join('\n'));
|
|
276
|
+
}
|
|
277
|
+
process.stderr.write(`gesture done ${g1 - g0}ms, ${sent} wheels\n`);
|
|
278
|
+
const endState = await frame.evaluate(() => window.__maudeOpenProbe.state());
|
|
279
|
+
// Settle: wait for every on-screen artboard to be drawn (or the timeout).
|
|
280
|
+
while (Date.now() < deadline) {
|
|
281
|
+
const done = await frame.evaluate(
|
|
282
|
+
() =>
|
|
283
|
+
!!window.__maudeOpenProbe.marks.allVisible &&
|
|
284
|
+
!!window.__maudeOpenProbe.marks.viewportCorrect
|
|
285
|
+
);
|
|
286
|
+
if (done) break;
|
|
287
|
+
await sleep(100);
|
|
288
|
+
}
|
|
289
|
+
await sleep(500);
|
|
290
|
+
const raw = await frame.evaluate(() => {
|
|
291
|
+
const P = window.__maudeOpenProbe;
|
|
292
|
+
const mem = performance.memory
|
|
293
|
+
? Math.round(performance.memory.usedJSHeapSize / 1048576)
|
|
294
|
+
: null;
|
|
295
|
+
return {
|
|
296
|
+
frames: P.frames,
|
|
297
|
+
long: P.long,
|
|
298
|
+
marks: P.marks,
|
|
299
|
+
nodes: document.getElementsByTagName('*').length,
|
|
300
|
+
heapMB: mem,
|
|
301
|
+
state: P.state(),
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
if (o.shot) await page.screenshot({ path: o.shot });
|
|
305
|
+
const rel = (t) => (t ? Math.round(t - t0) : null);
|
|
306
|
+
const inGesture = raw.frames.filter(([t]) => t >= g0 && t <= g1).map(([, d]) => d);
|
|
307
|
+
const openEnd = raw.marks.allVisible || Date.now();
|
|
308
|
+
const inOpen = raw.frames.filter(([t]) => t <= g0).map(([, d]) => d);
|
|
309
|
+
const settleEnd = raw.marks.viewportCorrect || Date.now();
|
|
310
|
+
const inSettle = raw.frames.filter(([t]) => t > g1 && t <= settleEnd).map(([, d]) => d);
|
|
311
|
+
const longOpen = raw.long.filter(([t]) => t <= openEnd);
|
|
312
|
+
const longGesture = raw.long.filter(([t]) => t >= g0 && t <= g1);
|
|
313
|
+
const sum = (a) => Math.round(a.reduce((n, [, d]) => n + d, 0));
|
|
314
|
+
const out = {
|
|
315
|
+
canvas: o.open,
|
|
316
|
+
engine: o.engine,
|
|
317
|
+
firstArtboardMs: rel(raw.marks.firstArtboard),
|
|
318
|
+
firstPaintMs: rel(raw.marks.firstPaint),
|
|
319
|
+
allVisibleMs: rel(raw.marks.allVisible),
|
|
320
|
+
// gesture end → every on-screen artboard drawn (the camera settled; what the user looks at is right)
|
|
321
|
+
viewportCorrectMs: raw.marks.viewportCorrect
|
|
322
|
+
? Math.max(0, Math.round(raw.marks.viewportCorrect - g1))
|
|
323
|
+
: null,
|
|
324
|
+
openFrames: stats(inOpen),
|
|
325
|
+
settleFrames: stats(inSettle),
|
|
326
|
+
gesture: {
|
|
327
|
+
ms: g1 - g0,
|
|
328
|
+
wheelsSent: sent,
|
|
329
|
+
wheelsPerS: Math.round((sent / Math.max(1, g1 - g0)) * 10000) / 10,
|
|
330
|
+
...stats(inGesture),
|
|
331
|
+
},
|
|
332
|
+
longTasks: {
|
|
333
|
+
open: longOpen.length,
|
|
334
|
+
openMs: sum(longOpen),
|
|
335
|
+
openMax: Math.round(Math.max(0, ...longOpen.map(([, d]) => d))),
|
|
336
|
+
gesture: longGesture.length,
|
|
337
|
+
gestureMs: sum(longGesture),
|
|
338
|
+
},
|
|
339
|
+
placeholdersAtGestureEnd: endState,
|
|
340
|
+
final: raw.state,
|
|
341
|
+
mainThread: m1
|
|
342
|
+
? Object.fromEntries(
|
|
343
|
+
['TaskDuration', 'ScriptDuration', 'RecalcStyleDuration', 'LayoutDuration'].map((k) => [
|
|
344
|
+
k,
|
|
345
|
+
{
|
|
346
|
+
open: Math.round((m0?.[k] || 0) * 1000),
|
|
347
|
+
gesture: Math.round((m1[k] - (m0?.[k] || 0)) * 1000),
|
|
348
|
+
},
|
|
349
|
+
])
|
|
350
|
+
)
|
|
351
|
+
: null,
|
|
352
|
+
domNodes: raw.nodes,
|
|
353
|
+
heapMB: raw.heapMB,
|
|
354
|
+
};
|
|
355
|
+
console.log(o.json ? JSON.stringify(out) : JSON.stringify(out, null, 2));
|
|
356
|
+
} finally {
|
|
357
|
+
await browser.close().catch(() => {});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
main().catch((err) => {
|
|
362
|
+
console.error(`_perf-probe-open.mjs: ${err.message}`);
|
|
363
|
+
process.exit(1);
|
|
364
|
+
});
|
|
@@ -16,6 +16,11 @@ export const OCCLUDED_HZ = 50;
|
|
|
16
16
|
/** 500 ms idle windows the occlusion guard reads before refusing (a busy page settles, a frozen one never does). */
|
|
17
17
|
export const IDLE_WINDOWS = 20;
|
|
18
18
|
|
|
19
|
+
// 2.0.7 — every frame sampler and pacer below takes the canvas frame's EXEMPT clock
|
|
20
|
+
// (`__maudeFrameFreeze.raf`, frame-clock.ts) when it is there: the shell gates
|
|
21
|
+
// requestAnimationFrame while the camera moves, so a sampler on the gated one would
|
|
22
|
+
// record no frames during the very gesture it measures (and a pacer would stall it).
|
|
23
|
+
|
|
19
24
|
// ── Idle rAF probe (the WebKit cross-origin-frame throttle check) ────────────
|
|
20
25
|
//
|
|
21
26
|
// WebKit caps requestAnimationFrame at ~30 fps in a cross-origin iframe the
|
|
@@ -38,12 +43,12 @@ export function idleRafSource(frames = 40) {
|
|
|
38
43
|
const tick = (t) => {
|
|
39
44
|
if (last) deltas.push(t - last);
|
|
40
45
|
last = t;
|
|
41
|
-
if (deltas.length < ${n}) { window.requestAnimationFrame(tick); return; }
|
|
46
|
+
if (deltas.length < ${n}) { (window.__maudeFrameFreeze ? window.__maudeFrameFreeze.raf : window.requestAnimationFrame.bind(window))(tick); return; }
|
|
42
47
|
const s = deltas.slice().sort((a, b) => a - b);
|
|
43
48
|
window.__maudePerfIdle = { frames: s.length, p50: Math.round(s[Math.floor(s.length / 2)] * 100) / 100 };
|
|
44
49
|
if (typeof done === 'function') done(JSON.stringify(window.__maudePerfIdle));
|
|
45
50
|
};
|
|
46
|
-
window.requestAnimationFrame(tick);
|
|
51
|
+
(window.__maudeFrameFreeze ? window.__maudeFrameFreeze.raf : window.requestAnimationFrame.bind(window))(tick);
|
|
47
52
|
return 'STARTED';
|
|
48
53
|
})(typeof arguments !== 'undefined' ? arguments[arguments.length - 1] : undefined)`;
|
|
49
54
|
}
|
|
@@ -225,9 +230,9 @@ export function harnessSource({ pan, zoom, injectCss, fitAll, setFlags }) {
|
|
|
225
230
|
const tick = (t) => {
|
|
226
231
|
if (last) frames.push(t - last);
|
|
227
232
|
last = t;
|
|
228
|
-
if (running) win.requestAnimationFrame(tick);
|
|
233
|
+
if (running) (win.__maudeFrameFreeze ? win.__maudeFrameFreeze.raf : win.requestAnimationFrame.bind(win))(tick);
|
|
229
234
|
};
|
|
230
|
-
win.requestAnimationFrame(tick);
|
|
235
|
+
(win.__maudeFrameFreeze ? win.__maudeFrameFreeze.raf : win.requestAnimationFrame.bind(win))(tick);
|
|
231
236
|
|
|
232
237
|
const rect = host.getBoundingClientRect();
|
|
233
238
|
const cx = rect.left + rect.width / 2;
|
|
@@ -238,7 +243,7 @@ export function harnessSource({ pan, zoom, injectCss, fitAll, setFlags }) {
|
|
|
238
243
|
clientX: cx, clientY: cy, bubbles: true, cancelable: true,
|
|
239
244
|
}));
|
|
240
245
|
|
|
241
|
-
const nextFrame = () => new Promise((r) => win.requestAnimationFrame(() => r()));
|
|
246
|
+
const nextFrame = () => new Promise((r) => (win.__maudeFrameFreeze ? win.__maudeFrameFreeze.raf : win.requestAnimationFrame.bind(win))(() => r()));
|
|
242
247
|
|
|
243
248
|
// The world transform is the ground truth that the gesture LANDED. Without
|
|
244
249
|
// this check a probe whose synthetic events get swallowed reports a beautiful
|
|
@@ -264,9 +269,9 @@ export function harnessSource({ pan, zoom, injectCss, fitAll, setFlags }) {
|
|
|
264
269
|
const idleTick = () => {
|
|
265
270
|
if (!idleOn) return;
|
|
266
271
|
idleFrames += 1;
|
|
267
|
-
win.requestAnimationFrame(idleTick);
|
|
272
|
+
(win.__maudeFrameFreeze ? win.__maudeFrameFreeze.raf : win.requestAnimationFrame.bind(win))(idleTick);
|
|
268
273
|
};
|
|
269
|
-
win.requestAnimationFrame(idleTick);
|
|
274
|
+
(win.__maudeFrameFreeze ? win.__maudeFrameFreeze.raf : win.requestAnimationFrame.bind(win))(idleTick);
|
|
270
275
|
await new Promise((r) => win.setTimeout(r, 500));
|
|
271
276
|
idleOn = false;
|
|
272
277
|
idleHz = Math.max(idleHz, idleFrames * 2);
|
|
@@ -18,7 +18,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
18
18
|
import { existsSync } from 'node:fs';
|
|
19
19
|
import { dirname, join } from 'node:path';
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
|
-
import { chromium } from 'playwright';
|
|
21
|
+
import { chromium, webkit } from 'playwright';
|
|
22
22
|
|
|
23
23
|
/** Exit code the shims surface for "Chromium browser binary not installed". */
|
|
24
24
|
export const NO_BROWSER_EXIT = 3;
|
|
@@ -137,6 +137,31 @@ export async function launchChromium(opts) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* 2.0.7 — the WebKit twin of `launchChromium`, for the measurement helpers that compare both
|
|
142
|
+
* engines (WKWebView is what the desktop app runs). WebKit takes no Chromium flags, so the
|
|
143
|
+
* no-egress rule is a dead proxy for everything but loopback when `MAUDE_NO_EGRESS === '1'`.
|
|
144
|
+
* A missing WebKit build exits cleanly with the install hint, like Chromium.
|
|
145
|
+
*/
|
|
146
|
+
export function noEgressWebkitOptions(opts, env = process.env) {
|
|
147
|
+
const base = opts ?? {};
|
|
148
|
+
if (env?.MAUDE_NO_EGRESS !== '1') return base;
|
|
149
|
+
return { ...base, proxy: { server: 'http://127.0.0.1:9', bypass: 'localhost,127.0.0.1' } };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function launchWebkit(opts) {
|
|
153
|
+
try {
|
|
154
|
+
return await webkit.launch(noEgressWebkitOptions(opts));
|
|
155
|
+
} catch (err) {
|
|
156
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
157
|
+
if (isMissingBrowserError(msg)) {
|
|
158
|
+
console.error(INSTALL_HINT);
|
|
159
|
+
process.exit(NO_BROWSER_EXIT);
|
|
160
|
+
}
|
|
161
|
+
throw err;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
140
165
|
// Shared by every multi-artboard export shim (_png/_pdf-playwright.mjs) that
|
|
141
166
|
// names its output file after an artboard's `data-dc-screen` id for T5's
|
|
142
167
|
// filename-correlation convenience. That id comes straight off a live DOM
|
package/apps/studio/bin/perf.sh
CHANGED
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
# sticky-only field. Serialized via strokesToSvg (needs bun). Warns
|
|
37
37
|
# when the v2 board exceeds the 4 MB cap (DDR-242; the v1 1 MB cap bit at ~3750 mixed elements).
|
|
38
38
|
# --json Raw JSON (current + previous run) instead of the human report.
|
|
39
|
+
# --open-load (2.0.7) Time the OPEN instead: the studio opens the canvas and a pan + zoom starts the
|
|
40
|
+
# moment the first artboard is there, while it still loads (`_perf-probe-open.mjs`): open →
|
|
41
|
+
# first artboard / first drawn / all on-screen drawn, long tasks and long frames, placeholders
|
|
42
|
+
# left at the gesture's end, DOM size, JS heap. `--engine safari` runs it in Playwright WebKit.
|
|
39
43
|
# --studio (chromium: Playwright, dpr-2 page at --window, V2-8.8) (safari) Measure inside the real studio shell, not the bare canvas
|
|
40
44
|
# page. Makes one real WebDriver click into the canvas frame first and
|
|
41
45
|
# proves it lifted WebKit's ~30 fps throttle on an untouched
|
|
@@ -81,6 +85,7 @@ REPEAT=3
|
|
|
81
85
|
PROBE_ENGINE="chromium"
|
|
82
86
|
FIT_ALL=0
|
|
83
87
|
STUDIO=0
|
|
88
|
+
OPEN_LOAD=0
|
|
84
89
|
TIMEOUT=30
|
|
85
90
|
HISTORY=""
|
|
86
91
|
JSON=0
|
|
@@ -105,6 +110,7 @@ while [ $# -gt 0 ]; do
|
|
|
105
110
|
--engine) PROBE_ENGINE="$2"; shift 2 ;;
|
|
106
111
|
--fit-all) FIT_ALL=1; shift ;;
|
|
107
112
|
--studio) STUDIO=1; shift ;;
|
|
113
|
+
--open-load) OPEN_LOAD=1; shift ;;
|
|
108
114
|
--history) HISTORY="$2"; shift 2 ;;
|
|
109
115
|
--json) JSON=1; shift ;;
|
|
110
116
|
--window) WINDOW="$2"; shift 2 ;;
|
|
@@ -266,6 +272,19 @@ if [ -z "$ENGINE_TAG" ]; then
|
|
|
266
272
|
if [ -n "$MAUDE_DESKTOP" ]; then ENGINE_TAG="webkit-desktop"; else ENGINE_TAG="blink-headless"; fi
|
|
267
273
|
fi
|
|
268
274
|
|
|
275
|
+
if [ "$OPEN_LOAD" = "1" ]; then
|
|
276
|
+
# 2.0.7 — the OPEN lane: open the canvas in the studio and pan/zoom while it loads (first paint, all visible,
|
|
277
|
+
# long tasks/frames, placeholders left, DOM size). Playwright Chromium or Playwright WebKit (`--engine safari`).
|
|
278
|
+
OPEN_ENGINE="chromium"
|
|
279
|
+
[ "$PROBE_ENGINE" = "safari" ] && OPEN_ENGINE="webkit"
|
|
280
|
+
echo "→ perf --open-load: $REL_FULL | port: $PORT | engine: $OPEN_ENGINE" >&2
|
|
281
|
+
ARGS=(--url "http://localhost:${PORT}/" --open "${REL_FULL#"$DESIGN_REL"/}" --engine "$OPEN_ENGINE" --timeout "$TIMEOUT")
|
|
282
|
+
[ -n "$WINDOW" ] && ARGS+=(--window "$WINDOW")
|
|
283
|
+
[ -n "$INJECT_CSS" ] && ARGS+=(--inject-css "$INJECT_CSS")
|
|
284
|
+
[ "$JSON" = "1" ] && ARGS+=(--json)
|
|
285
|
+
exec node "$SCRIPT_DIR/_perf-probe-open.mjs" "${ARGS[@]}"
|
|
286
|
+
fi
|
|
287
|
+
|
|
269
288
|
if [ "$PROBE_ENGINE" = "safari" ]; then
|
|
270
289
|
# V2-8.9 M1: Safari takes no per-run proxy or resolver rule, so with AI may › Search the web off
|
|
271
290
|
# (MAUDE_NO_EGRESS=1) the WebKit lane is refused rather than run with the web on.
|
|
@@ -402,6 +402,15 @@ export interface CanvasToShell {
|
|
|
402
402
|
'annotation-prefs-set': { prefs: AnnotationPrefsPayload };
|
|
403
403
|
// fit: the camera is where the last ⌘0 / Zoom to fit put it (V2-8.5 c7: "Zoom to fit · N %").
|
|
404
404
|
'viewport-zoom': { zoom: number; fit?: boolean };
|
|
405
|
+
// 2.0.7 B2 — the canvas's Canvas | Pages view (canvas-pages.ts): Pages on, and which page of how many. The shell
|
|
406
|
+
// turns Preview and Present off while it is on (canvas-mode.js `pages`).
|
|
407
|
+
// 2.0.7 polish — `id`: the artboard on the page while on (the left panel marks it).
|
|
408
|
+
'pages-view': { v: 1; on: boolean; index: number; total: number; id?: string };
|
|
409
|
+
// 2.0.7 B2 — a person switched Canvas | Pages: the shell writes `canvasView` for the canvas it has open
|
|
410
|
+
// (client/v2/shell/pages-pick.js); the canvas origin has no lane for it.
|
|
411
|
+
'pages-pick': { v: 1; view: 'canvas' | 'pages' };
|
|
412
|
+
// 2.0.7 B2 — the same for the Light | Dark pick (canvas-theme.ts): the shell writes `canvasTheme`.
|
|
413
|
+
'theme-pick': { v: 1; theme: 'light' | 'dark' };
|
|
405
414
|
// S3.7a — `sid` / `seq` (S3-present-session §3): the presenting session, and its step count.
|
|
406
415
|
'present-position': { index: number; total: number; artboardId: Id; sid?: string; seq?: number };
|
|
407
416
|
// S3.6b — the Present run's artboards with their world rects and labels, in canvas order: the presenter
|
|
@@ -1881,6 +1890,32 @@ const c2s: C2S = {
|
|
|
1881
1890
|
'present/present-zoom.ts (S3.2b) + v2/preview/zoom-only (S3.9) ← canvas-lib ViewportZoomReporter',
|
|
1882
1891
|
parse: p({ zoom: num, fit: opt(bool) }),
|
|
1883
1892
|
},
|
|
1893
|
+
// 2.0.7 B2 — the active canvas's Canvas | Pages view (canvas-pages-view.tsx) → the shell's mode store
|
|
1894
|
+
// (use-canvas-mode-lane), which holds Preview and Present off while Pages is on.
|
|
1895
|
+
'pages-view': {
|
|
1896
|
+
gate: 'active',
|
|
1897
|
+
status: 'live',
|
|
1898
|
+
owner: 'canvas-pages-view.tsx (2.0.7 B2) → v2/shell/use-canvas-mode-lane',
|
|
1899
|
+
parse: p({
|
|
1900
|
+
v: lit(1),
|
|
1901
|
+
on: bool,
|
|
1902
|
+
index: intIn(0, 10000),
|
|
1903
|
+
total: intIn(0, 10000),
|
|
1904
|
+
id: opt(shortStr(256)),
|
|
1905
|
+
}),
|
|
1906
|
+
},
|
|
1907
|
+
'pages-pick': {
|
|
1908
|
+
gate: 'active',
|
|
1909
|
+
status: 'live',
|
|
1910
|
+
owner: 'canvas-pages.ts (2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)',
|
|
1911
|
+
parse: p({ v: lit(1), view: lit('canvas', 'pages') }),
|
|
1912
|
+
},
|
|
1913
|
+
'theme-pick': {
|
|
1914
|
+
gate: 'active',
|
|
1915
|
+
status: 'live',
|
|
1916
|
+
owner: 'canvas-theme.ts (r4 #6, 2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)',
|
|
1917
|
+
parse: p({ v: lit(1), theme: lit('light', 'dark') }),
|
|
1918
|
+
},
|
|
1884
1919
|
// S3.1 — live: the Present stage (S3.2a) reports through canvas-mode-store `reportPresentPosition`;
|
|
1885
1920
|
// the shell's mode store keeps it (use-canvas-mode-lane).
|
|
1886
1921
|
'present-position': {
|
|
@@ -93,6 +93,58 @@ export const BUILD_RSS_LIMIT_MB = sandboxKnob(
|
|
|
93
93
|
128,
|
|
94
94
|
8_192
|
|
95
95
|
);
|
|
96
|
+
/**
|
|
97
|
+
* 2.0.7 (#3) — how many canvas builds run AT ONCE, across every canvas of this server. `inflight`
|
|
98
|
+
* below bounds builds per canvas; nothing bounded them across canvases, and opening a design system
|
|
99
|
+
* asks for many at once (the board, the gallery's specimens, thumbnails): the board plus its 58
|
|
100
|
+
* specimens started 48 worker processes together, 1.2 GB resident, and the board itself took 6.3 s
|
|
101
|
+
* instead of 0.7 s — on a two-core cell, long enough to outlive the request and show the error card
|
|
102
|
+
* (#2). The rest wait their turn, in the order they were asked for. Desktop in-process builds share
|
|
103
|
+
* the same slots (`withBuildSlot`, http.ts).
|
|
104
|
+
*/
|
|
105
|
+
export const BUILD_CONCURRENCY = sandboxKnob(
|
|
106
|
+
process.env,
|
|
107
|
+
'MAUDE_CANVAS_BUILD_CONCURRENCY',
|
|
108
|
+
2,
|
|
109
|
+
1,
|
|
110
|
+
16
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
/** A FIFO counting semaphore: at most `limit` tasks run; the rest start as earlier ones settle. */
|
|
114
|
+
export function createBuildSlots(limit: number) {
|
|
115
|
+
let active = 0;
|
|
116
|
+
const waiting: Array<() => void> = [];
|
|
117
|
+
const release = () => {
|
|
118
|
+
active--;
|
|
119
|
+
const next = waiting.shift();
|
|
120
|
+
if (next) next();
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
async run<T>(task: () => Promise<T>): Promise<T> {
|
|
124
|
+
if (active >= limit) await new Promise<void>((go) => waiting.push(go));
|
|
125
|
+
active++;
|
|
126
|
+
try {
|
|
127
|
+
return await task();
|
|
128
|
+
} finally {
|
|
129
|
+
release();
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
stats: () => ({ active, queued: waiting.length, limit }),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const buildSlots = createBuildSlots(BUILD_CONCURRENCY);
|
|
137
|
+
|
|
138
|
+
/** Run one canvas build in a slot (the sandbox's workers and the desktop's in-process builds). */
|
|
139
|
+
export function withBuildSlot<T>(task: () => Promise<T>): Promise<T> {
|
|
140
|
+
return buildSlots.run(task);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** How many builds are running and waiting now (for `/_health.render`). */
|
|
144
|
+
export function buildSlotStats() {
|
|
145
|
+
return buildSlots.stats();
|
|
146
|
+
}
|
|
147
|
+
|
|
96
148
|
/** How many built modules to keep. Each is a string that bundles the shared chrome — ~2 MB of
|
|
97
149
|
* text however small the canvas (issue #204), so the byte bound below is the one that bites. */
|
|
98
150
|
export const CACHE_MAX_ENTRIES = sandboxKnob(
|
|
@@ -544,19 +596,23 @@ function startBuild({
|
|
|
544
596
|
const started = Date.now();
|
|
545
597
|
entry.promise = (async (): Promise<SandboxBuildResult> => {
|
|
546
598
|
try {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
599
|
+
// In a slot (#3): the ceiling starts when the worker does, not while it waits its turn, and a
|
|
600
|
+
// build superseded while it waited never spawns.
|
|
601
|
+
const result = await withBuildSlot(async () =>
|
|
602
|
+
stoppedWith
|
|
603
|
+
? stoppedWith
|
|
604
|
+
: await runWorker({
|
|
605
|
+
designRoot,
|
|
606
|
+
canvasAbs,
|
|
607
|
+
assetUrlBase,
|
|
608
|
+
env,
|
|
609
|
+
ceilingMs,
|
|
610
|
+
onStart: (stop) => {
|
|
611
|
+
stopEarly = stop;
|
|
612
|
+
if (stoppedWith) stop(stoppedWith);
|
|
613
|
+
},
|
|
614
|
+
})
|
|
615
|
+
);
|
|
560
616
|
const elapsed = Date.now() - started;
|
|
561
617
|
counters.cpuMsTotal += elapsed;
|
|
562
618
|
counters.durationsMs.push(elapsed);
|