@1agh/maude 2.0.4 → 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/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -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 +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -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 +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- 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 +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.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 +289 -44
- 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 +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -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 +13 -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/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- 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 +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -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-bus.js +5 -0
- 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/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- 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/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- 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/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- 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-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- 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 +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- 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/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- 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/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- 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/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- 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 +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- 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
|
+
});
|
|
@@ -28,6 +28,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
28
28
|
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
29
29
|
import { dirname } from 'node:path';
|
|
30
30
|
|
|
31
|
+
import { resolveAgentBrowserBin } from './_agent-browser-bin.mjs';
|
|
31
32
|
import {
|
|
32
33
|
buildRow,
|
|
33
34
|
emptyViewportRefusal,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
renderReport,
|
|
40
41
|
} from './_perf-shared.mjs';
|
|
41
42
|
|
|
42
|
-
const AB =
|
|
43
|
+
const AB = resolveAgentBrowserBin();
|
|
43
44
|
|
|
44
45
|
// agent-browser is a SHARED singleton by default: a concurrent session running
|
|
45
46
|
// its own smoke sweep will navigate the same tab out from under a measurement
|
|
@@ -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
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { randomBytes } from 'node:crypto';
|
|
12
12
|
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
13
|
-
import { DESIGN_REL, findProjectRoot,
|
|
13
|
+
import { DESIGN_REL, findProjectRoot, probeStudio } from '../../../cli/lib/studio-locate.mjs';
|
|
14
14
|
|
|
15
15
|
export { DESIGN_REL };
|
|
16
16
|
|
|
@@ -66,8 +66,23 @@ export function canvasRepoRel(root, canvas) {
|
|
|
66
66
|
return `${DESIGN_REL}/${rel.split(sep).join('/')}`;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/** How long `/_health` gets, and how often it is asked, before a live studio counts as busy. */
|
|
70
|
+
export const HEALTH_TIMEOUT_MS = 3000;
|
|
71
|
+
export const HEALTH_ATTEMPTS = 3;
|
|
72
|
+
|
|
69
73
|
/** The studio serving `root`, or null. */
|
|
70
|
-
export const studioFor = (root) =>
|
|
74
|
+
export const studioFor = async (root) => (await studioState(root)).studio ?? null;
|
|
75
|
+
|
|
76
|
+
/** `{ studio }` | `{ state: 'none' | 'busy' }` (#13: a studio under load is not "not running"). */
|
|
77
|
+
export const studioState = (root, env = process.env) =>
|
|
78
|
+
probeStudio(root, {
|
|
79
|
+
timeoutMs:
|
|
80
|
+
Number(env.MAUDE_HEALTH_TIMEOUT_MS) > 0
|
|
81
|
+
? Number(env.MAUDE_HEALTH_TIMEOUT_MS)
|
|
82
|
+
: HEALTH_TIMEOUT_MS,
|
|
83
|
+
attempts: HEALTH_ATTEMPTS,
|
|
84
|
+
retryDelayMs: 500,
|
|
85
|
+
});
|
|
71
86
|
|
|
72
87
|
/**
|
|
73
88
|
* p8-a1-claims — a write names the chat this shell is (`MAUDE_CHAT_ID`, set per chat by the ACP spawn):
|
|
@@ -209,7 +224,13 @@ export async function connect(name, rootFlag) {
|
|
|
209
224
|
);
|
|
210
225
|
return { exit: 2 };
|
|
211
226
|
}
|
|
212
|
-
const studio = await
|
|
227
|
+
const { studio, state } = await studioState(root);
|
|
228
|
+
if (!studio && state === 'busy') {
|
|
229
|
+
process.stderr.write(
|
|
230
|
+
`maude design ${name}: the Maude studio for this project is busy — it is running but did not answer in time. Wait a moment and try again.\n`
|
|
231
|
+
);
|
|
232
|
+
return { exit: 3 };
|
|
233
|
+
}
|
|
213
234
|
if (!studio) {
|
|
214
235
|
process.stderr.write(
|
|
215
236
|
`maude design ${name}: no Maude studio is running for this project. Open it in Maude (or \`maude design serve\`) and try again.\n`
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// _thumb-blank.mjs — "is this cover a blank card?" for the thumbnail renderer (2.0.5 W5).
|
|
2
|
+
//
|
|
3
|
+
// A cover that is one flat colour (an empty viewport, a canvas that drew nothing, the page's own
|
|
4
|
+
// background) is worse than no cover: Home would cache it as a fresh hit and never look again.
|
|
5
|
+
// The renderer asks this of every JPEG it is about to hand back; the server treats `blank: true` as
|
|
6
|
+
// a retryable miss (thumbs/service.ts), so Home keeps its placeholder instead.
|
|
7
|
+
//
|
|
8
|
+
// The check runs on a BLANK page (`about:blank`) — never on the canvas page, whose code is untrusted
|
|
9
|
+
// (DDR-054) — by decoding the JPEG in the browser (the shim has no image library), shrinking it to
|
|
10
|
+
// 64 px wide and counting how much of it is the single most common colour (4 bits per channel, so
|
|
11
|
+
// JPEG noise on a flat area still counts as flat). It is "blank" only when that colour is white or the
|
|
12
|
+
// canvas's own background (what an unpainted viewport shows): a design that is one deliberate colour
|
|
13
|
+
// (a dark hero, a brand-colour poster) is a cover.
|
|
14
|
+
|
|
15
|
+
/** more than this share of one colour = blank. A text-only slice of a white page stays well under. */
|
|
16
|
+
export const BLANK_SHARE = 0.99;
|
|
17
|
+
|
|
18
|
+
/** Runs in the page: base64 JPEG → { share of the most common colour (0..1), its rgb }, or null when it cannot decode. */
|
|
19
|
+
export async function dominantShare(b64) {
|
|
20
|
+
try {
|
|
21
|
+
const bin = atob(b64);
|
|
22
|
+
const u8 = new Uint8Array(bin.length);
|
|
23
|
+
for (let i = 0; i < bin.length; i++) u8[i] = bin.charCodeAt(i);
|
|
24
|
+
const bmp = await createImageBitmap(new Blob([u8], { type: 'image/jpeg' }));
|
|
25
|
+
const w = Math.min(64, bmp.width);
|
|
26
|
+
const h = Math.max(1, Math.round((w * bmp.height) / bmp.width));
|
|
27
|
+
const c = new OffscreenCanvas(w, h);
|
|
28
|
+
const g = c.getContext('2d', { willReadFrequently: true });
|
|
29
|
+
g.drawImage(bmp, 0, 0, w, h);
|
|
30
|
+
const px = g.getImageData(0, 0, w, h).data;
|
|
31
|
+
const counts = new Map();
|
|
32
|
+
let top = 0;
|
|
33
|
+
let topKey = 0;
|
|
34
|
+
for (let i = 0; i < px.length; i += 4) {
|
|
35
|
+
const k = ((px[i] >> 4) << 8) | ((px[i + 1] >> 4) << 4) | (px[i + 2] >> 4);
|
|
36
|
+
const n = (counts.get(k) ?? 0) + 1;
|
|
37
|
+
counts.set(k, n);
|
|
38
|
+
if (n > top) {
|
|
39
|
+
top = n;
|
|
40
|
+
topKey = k;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// the bucket's centre
|
|
44
|
+
const rgb = [(topKey >> 8) & 15, (topKey >> 4) & 15, topKey & 15].map((v) => v * 16 + 8);
|
|
45
|
+
return { share: top / (w * h), rgb };
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const NEAR = 24;
|
|
52
|
+
const near = (a, b) => a.every((v, i) => Math.abs(v - b[i]) <= NEAR);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `page` must be on about:blank; `bg` = the canvas page's background colour as [r, g, b] (or null).
|
|
56
|
+
* true = blank, false = has content, null = could not tell (kept).
|
|
57
|
+
*/
|
|
58
|
+
export async function isBlankCover(page, b64, bg = null) {
|
|
59
|
+
const r = await page.evaluate(dominantShare, b64).catch(() => null);
|
|
60
|
+
if (!r || typeof r.share !== 'number') return null;
|
|
61
|
+
if (r.share <= BLANK_SHARE) return false;
|
|
62
|
+
return near(r.rgb, [255, 255, 255]) || (Array.isArray(bg) && near(r.rgb, bg));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** "rgb(22, 24, 29)" / "rgba(…)" → [22, 24, 29]; a transparent or unparsable value → null. */
|
|
66
|
+
export function parseRgb(css) {
|
|
67
|
+
const m = /^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(String(css));
|
|
68
|
+
if (!m || (m[4] !== undefined && Number(m[4]) === 0)) return null;
|
|
69
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
70
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// _thumb-cover.mjs — which artboard is a canvas's cover (C31, W5). Pure: the thumbnail renderer
|
|
2
|
+
// (`_thumbs-playwright.mjs`) imports it, and the tests import it without starting a browser.
|
|
3
|
+
|
|
4
|
+
/** An artboard worth being a cover: not a sliver (a header strip, a divider) — a cover is shown at ~16:10. */
|
|
5
|
+
export const MIN_COVER_SIDE = 80;
|
|
6
|
+
export const MAX_COVER_ASPECT = 5;
|
|
7
|
+
export const coverWorthy = (r) =>
|
|
8
|
+
(r.w ?? 0) >= MIN_COVER_SIDE &&
|
|
9
|
+
(r.h ?? 0) >= MIN_COVER_SIDE &&
|
|
10
|
+
Math.max(r.w / r.h, r.h / r.w) <= MAX_COVER_ASPECT;
|
|
11
|
+
|
|
12
|
+
/** The first of `rects` row by row, left to right. */
|
|
13
|
+
export function topLeft(rects) {
|
|
14
|
+
if (!rects.length) return null;
|
|
15
|
+
const minY = Math.min(...rects.map((r) => r.y));
|
|
16
|
+
const minH = Math.min(...rects.map((r) => r.h ?? 0).filter((h) => h > 0), 1);
|
|
17
|
+
const top = rects.filter((r) => r.y < minY + minH / 2);
|
|
18
|
+
return top.sort((a, b) => a.x - b.x)[0]?.id ?? rects[0].id;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* C31: the first artboard in "Order and notes…" when set (that always wins), else the top-left one among
|
|
23
|
+
* those worth a cover (W5: a 480 x 42 header slice or a 3320 x 200 strip is not one — the phone below it
|
|
24
|
+
* is). null when none is: the caller then shows the board, or falls back to `pickAny`.
|
|
25
|
+
*/
|
|
26
|
+
export function pickCover(rects, order) {
|
|
27
|
+
if (Array.isArray(order)) for (const id of order) if (rects.some((r) => r.id === id)) return id;
|
|
28
|
+
return topLeft(rects.filter(coverWorthy));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** No artboard is worth a cover and there is no board: the biggest one beats a blank card. */
|
|
32
|
+
export function pickAny(rects) {
|
|
33
|
+
const big = [...rects].sort((a, b) => (b.w ?? 0) * (b.h ?? 0) - (a.w ?? 0) * (a.h ?? 0))[0];
|
|
34
|
+
return big?.id ?? null;
|
|
35
|
+
}
|