@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
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
import { createInterface } from 'node:readline';
|
|
33
33
|
|
|
34
34
|
import { afterPaint, launchChromium } from './_pw-launch.mjs';
|
|
35
|
+
import { isBlankCover, parseRgb } from './_thumb-blank.mjs';
|
|
36
|
+
import { pickAny, pickCover } from './_thumb-cover.mjs';
|
|
35
37
|
import { drawTile } from './_tile-draw.mjs';
|
|
36
38
|
|
|
37
39
|
const MAX_PAGES = 4;
|
|
@@ -269,27 +271,80 @@ async function harvest(page) {
|
|
|
269
271
|
return rows;
|
|
270
272
|
}
|
|
271
273
|
|
|
272
|
-
/** C31: the first artboard in "Order and notes…" when set, else row by row, left to right. */
|
|
273
|
-
function pickCover(rects, order) {
|
|
274
|
-
if (Array.isArray(order)) for (const id of order) if (rects.some((r) => r.id === id)) return id;
|
|
275
|
-
if (!rects.length) return null;
|
|
276
|
-
const minY = Math.min(...rects.map((r) => r.y));
|
|
277
|
-
const minH = Math.min(...rects.map((r) => r.h ?? 0).filter((h) => h > 0), 1);
|
|
278
|
-
const top = rects.filter((r) => r.y < minY + minH / 2);
|
|
279
|
-
return top.sort((a, b) => a.x - b.x)[0]?.id ?? rects[0].id;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
274
|
async function shoot(page, job, index, target, runtime, left) {
|
|
283
275
|
const t0 = performance.now();
|
|
284
276
|
const px = Math.max(16, Math.min(2048, Math.trunc(Number(target.px) || 480)));
|
|
285
277
|
let id = target.artboard == null ? null : String(target.artboard);
|
|
286
278
|
const domIds = runtime.map((a) => a.id);
|
|
279
|
+
// W5: a cover with no artboard worth showing is the BOARD (the annotation layer, which lives in the
|
|
280
|
+
// world beside the artboards, not in `#canvas-root`'s flow) — or, with no board, the biggest artboard
|
|
281
|
+
let board = false;
|
|
287
282
|
if (id === null && domIds.length) id = pickCover(runtime, job.coverOrder);
|
|
288
283
|
else if (id !== null && !domIds.includes(id)) return { target: index, missing: true };
|
|
284
|
+
if (id === null && target.artboard == null) {
|
|
285
|
+
board = await page.evaluate(
|
|
286
|
+
() => document.querySelector('[data-mdcc-annotations] .dc-annot-el') !== null
|
|
287
|
+
);
|
|
288
|
+
if (!board && domIds.length) id = pickAny(runtime);
|
|
289
|
+
}
|
|
289
290
|
|
|
290
291
|
const box = await page.evaluate(
|
|
291
|
-
([abId, size]) => {
|
|
292
|
+
([abId, size, boardMode]) => {
|
|
292
293
|
const world = document.querySelector('.dc-world');
|
|
294
|
+
if (boardMode && world) {
|
|
295
|
+
// The bounds of everything drawn in the world, in WORLD units: the annotation layer's elements
|
|
296
|
+
// are absolutely placed with inline left/top and carry their size on the geometry svg (their own
|
|
297
|
+
// boxes measure 0 x 0); artboards are real boxes. No transform is read, so the pan/zoom the page
|
|
298
|
+
// happens to be in does not matter.
|
|
299
|
+
let x0 = Number.POSITIVE_INFINITY;
|
|
300
|
+
let y0 = Number.POSITIVE_INFINITY;
|
|
301
|
+
let x1 = Number.NEGATIVE_INFINITY;
|
|
302
|
+
let y1 = Number.NEGATIVE_INFINITY;
|
|
303
|
+
const add = (x, y, w, h) => {
|
|
304
|
+
if (![x, y, w, h].every(Number.isFinite)) return;
|
|
305
|
+
x0 = Math.min(x0, x);
|
|
306
|
+
y0 = Math.min(y0, y);
|
|
307
|
+
x1 = Math.max(x1, x + Math.max(1, w));
|
|
308
|
+
y1 = Math.max(y1, y + Math.max(1, h));
|
|
309
|
+
};
|
|
310
|
+
// `?hide-chrome=1` hides the annotation layer (an export must not carry it, capture-chrome.ts); a
|
|
311
|
+
// board cover IS that layer, so this one capture puts it back (an inline !important beats the sheet's)
|
|
312
|
+
for (const scene of world.querySelectorAll('[data-mdcc-annotations]'))
|
|
313
|
+
scene.style.setProperty('display', 'block', 'important');
|
|
314
|
+
const px = (v) => Number.parseFloat(v);
|
|
315
|
+
for (const el of world.querySelectorAll('.dc-annot-el')) {
|
|
316
|
+
const vb = el.querySelector(':scope > svg.dc-annot-geo')?.viewBox?.baseVal;
|
|
317
|
+
if (vb && vb.width > 0 && vb.height > 0) add(vb.x, vb.y, vb.width, vb.height);
|
|
318
|
+
else
|
|
319
|
+
add(
|
|
320
|
+
px(el.style.left),
|
|
321
|
+
px(el.style.top),
|
|
322
|
+
px(el.style.width) || 160,
|
|
323
|
+
px(el.style.height) || 40
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
for (const el of world.querySelectorAll('[data-dc-screen]'))
|
|
327
|
+
add(el.offsetLeft, el.offsetTop, el.offsetWidth, el.offsetHeight);
|
|
328
|
+
if (!(x1 > x0 && y1 > y0)) return null;
|
|
329
|
+
const bw = x1 - x0;
|
|
330
|
+
const bh = y1 - y0;
|
|
331
|
+
const z = Math.min(1, size / bw);
|
|
332
|
+
world.style.zoom = '1';
|
|
333
|
+
world.style.transformOrigin = '0 0';
|
|
334
|
+
world.style.transform = 'none';
|
|
335
|
+
const o = world.getBoundingClientRect(); // where the world's origin sits in the page
|
|
336
|
+
world.style.transform = `translate(${-x0 * z}px, ${-y0 * z}px) scale(${z})`;
|
|
337
|
+
window.scrollTo(0, 0);
|
|
338
|
+
const cw = Math.min(bw * z, size);
|
|
339
|
+
// a cover is 1 : 0.5 .. 1 : 0.625 — a short, wide board gets some of the canvas below it, a tall
|
|
340
|
+
// one its top (the clip is cut from the board's own top-left corner)
|
|
341
|
+
return {
|
|
342
|
+
x: o.left,
|
|
343
|
+
y: o.top,
|
|
344
|
+
w: cw,
|
|
345
|
+
h: Math.max(cw * 0.5, Math.min(bh * z, (cw * 10) / 16)),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
293
348
|
if (abId !== null) {
|
|
294
349
|
const abs = [...document.querySelectorAll('[data-dc-screen]')];
|
|
295
350
|
const ab = abs.find((a) => a.getAttribute('data-dc-screen') === abId);
|
|
@@ -320,7 +375,7 @@ async function shoot(page, job, index, target, runtime, left) {
|
|
|
320
375
|
const cw = Math.min(b.width, size);
|
|
321
376
|
return { x: b.left, y: b.top, w: cw, h: Math.min(b.height, (cw * 10) / 16) };
|
|
322
377
|
},
|
|
323
|
-
[id, px]
|
|
378
|
+
[id, px, board]
|
|
324
379
|
);
|
|
325
380
|
if (!box) return { target: index, missing: id !== null };
|
|
326
381
|
|
|
@@ -503,6 +558,26 @@ async function render(msg) {
|
|
|
503
558
|
const shots = [];
|
|
504
559
|
for (const [i, t] of targets.entries()) shots.push(await shoot(page, job, i, t, runtime, left));
|
|
505
560
|
lap('shoot');
|
|
561
|
+
// W5: a flat-colour picture is a miss, not a cover — checked on a blank page, never on the canvas's
|
|
562
|
+
const pics = shots.filter((sh) => typeof sh.jpeg === 'string');
|
|
563
|
+
if (pics.length) {
|
|
564
|
+
// the colour an unpainted viewport shows: the canvas host's own background (read, then left behind)
|
|
565
|
+
const bg = parseRgb(
|
|
566
|
+
await bounded(
|
|
567
|
+
page.evaluate(() => {
|
|
568
|
+
for (const el of [document.querySelector('.dc-canvas'), document.body]) {
|
|
569
|
+
const c = el ? getComputedStyle(el).backgroundColor : '';
|
|
570
|
+
if (c && c !== 'rgba(0, 0, 0, 0)') return c;
|
|
571
|
+
}
|
|
572
|
+
return '';
|
|
573
|
+
}),
|
|
574
|
+
1000
|
|
575
|
+
)
|
|
576
|
+
);
|
|
577
|
+
await page.goto('about:blank').catch(() => {});
|
|
578
|
+
for (const sh of pics) if ((await isBlankCover(page, sh.jpeg, bg)) === true) sh.blank = true;
|
|
579
|
+
}
|
|
580
|
+
lap('blank');
|
|
506
581
|
return {
|
|
507
582
|
phases,
|
|
508
583
|
ok: true,
|
|
@@ -669,6 +744,8 @@ async function handle(msg) {
|
|
|
669
744
|
try {
|
|
670
745
|
send({ id, ...(await (msg.op === 'tile' ? tile(msg) : render(msg))) });
|
|
671
746
|
} catch (e) {
|
|
747
|
+
if (process.env.MAUDE_THUMBS_DEBUG)
|
|
748
|
+
process.stderr.write(`render failed: ${String(e?.stack ?? e)}\n`);
|
|
672
749
|
const code =
|
|
673
750
|
e?.code === 'origin' || e?.code === 'canvas-failed'
|
|
674
751
|
? e.code
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
# ds-check.sh --hook --canvas <file> # PostToolUse mode: always exit 0, hook JSON
|
|
15
15
|
# ds-check.sh --root <project> # default: $CLAUDE_PROJECT_DIR, else the current directory
|
|
16
16
|
#
|
|
17
|
+
# The canvas modes also ask the project's running studio (127.0.0.1 only) which canvases it refused after
|
|
18
|
+
# their build — a canvas that uses a file another canvas owns — and print why; with no studio they say so
|
|
19
|
+
# and print the import-walk reasons only. `--json` carries `studio` (true/false) and `refusedInputs`.
|
|
20
|
+
#
|
|
17
21
|
# Structure only — presence, per-theme presence, value TYPE, name/type collisions. Values,
|
|
18
22
|
# ordering and aesthetics are never judged (A14, DDR-043); they surface as notes.
|
|
19
23
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
@@ -24,7 +28,7 @@ if ! command -v bun >/dev/null 2>&1; then
|
|
|
24
28
|
fi
|
|
25
29
|
|
|
26
30
|
case "$1" in
|
|
27
|
-
--help|-h) sed -n '2,
|
|
31
|
+
--help|-h) sed -n '2,21p' "$0" | sed 's/^# \?//'; exit 0 ;;
|
|
28
32
|
esac
|
|
29
33
|
|
|
30
34
|
exec bun run "$SCRIPT_DIR/_ds-check.mjs" "$@"
|
package/apps/studio/bin/perf.sh
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# [--pan N] [--zoom N] [--timeout S] [--repeat N]
|
|
19
19
|
# [--engine chromium|safari] [--studio] [--fit-all]
|
|
20
20
|
# [--window WxH] [--frame today|pinned|full|WxH] [--compare-frame <same>]
|
|
21
|
-
# [--variant <tag>] [--inject-css <css>]
|
|
21
|
+
# [--variant <tag>] [--inject-css <css>] [--query <k=v&…>]
|
|
22
22
|
# [--history <path>] [--json]
|
|
23
23
|
#
|
|
24
24
|
# --engine safari measures WebKit through safaridriver (one-time
|
|
@@ -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
|
|
@@ -50,6 +54,8 @@
|
|
|
50
54
|
# difference. Refuses (exit 1) when the two geometries showed a
|
|
51
55
|
# different number of artboards on screen — not the same content.
|
|
52
56
|
# --variant A label for an A/B arm; keys the history row with the canvas.
|
|
57
|
+
# --query Extra canvas-page parameters for an A/B arm on the bare page (not --studio), e.g.
|
|
58
|
+
# `artboard-live=off` vs `artboard-live=sleep` (2.0.5 heavy canvases). Letters, digits, `=&_-` only.
|
|
53
59
|
# --inject-css CSS injected into the canvas document before each pass, to
|
|
54
60
|
# test a rendering hypothesis against the same build.
|
|
55
61
|
#
|
|
@@ -79,6 +85,7 @@ REPEAT=3
|
|
|
79
85
|
PROBE_ENGINE="chromium"
|
|
80
86
|
FIT_ALL=0
|
|
81
87
|
STUDIO=0
|
|
88
|
+
OPEN_LOAD=0
|
|
82
89
|
TIMEOUT=30
|
|
83
90
|
HISTORY=""
|
|
84
91
|
JSON=0
|
|
@@ -103,6 +110,7 @@ while [ $# -gt 0 ]; do
|
|
|
103
110
|
--engine) PROBE_ENGINE="$2"; shift 2 ;;
|
|
104
111
|
--fit-all) FIT_ALL=1; shift ;;
|
|
105
112
|
--studio) STUDIO=1; shift ;;
|
|
113
|
+
--open-load) OPEN_LOAD=1; shift ;;
|
|
106
114
|
--history) HISTORY="$2"; shift 2 ;;
|
|
107
115
|
--json) JSON=1; shift ;;
|
|
108
116
|
--window) WINDOW="$2"; shift 2 ;;
|
|
@@ -110,6 +118,7 @@ while [ $# -gt 0 ]; do
|
|
|
110
118
|
--compare-frame) COMPARE_FRAME="$2"; shift 2 ;;
|
|
111
119
|
--variant) VARIANT="$2"; shift 2 ;;
|
|
112
120
|
--inject-css) INJECT_CSS="$2"; shift 2 ;;
|
|
121
|
+
--query) QUERY="$2"; shift 2 ;;
|
|
113
122
|
--help|-h)
|
|
114
123
|
sed -n '2,/^[^#]/p' "$0" | sed '$d' | sed -E 's/^# ?//'
|
|
115
124
|
exit 0
|
|
@@ -227,6 +236,13 @@ esac
|
|
|
227
236
|
# or `%` would otherwise truncate or rewrite the query string.
|
|
228
237
|
REL_ENC=$("$JS_RUNTIME" -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$REL_FULL")
|
|
229
238
|
URL="http://localhost:${PORT}/_canvas-shell.html?canvas=${REL_ENC}"
|
|
239
|
+
if [ -n "${QUERY:-}" ]; then
|
|
240
|
+
case "$QUERY" in
|
|
241
|
+
*[!A-Za-z0-9=\&_-]*) echo "perf.sh: --query takes letters, digits and = & _ - only" >&2; exit 2 ;;
|
|
242
|
+
esac
|
|
243
|
+
[ "$STUDIO" = "1" ] && { echo "perf.sh: --query applies to the bare canvas page, not --studio" >&2; exit 2; }
|
|
244
|
+
URL="${URL}&${QUERY}"
|
|
245
|
+
fi
|
|
230
246
|
. "$SCRIPT_DIR/_url-guard.sh" && maude_url_guard "$URL" || exit 2 # V2-8.9 B2 — http(s) to this Mac only
|
|
231
247
|
|
|
232
248
|
# ---------- history path ----------
|
|
@@ -256,6 +272,19 @@ if [ -z "$ENGINE_TAG" ]; then
|
|
|
256
272
|
if [ -n "$MAUDE_DESKTOP" ]; then ENGINE_TAG="webkit-desktop"; else ENGINE_TAG="blink-headless"; fi
|
|
257
273
|
fi
|
|
258
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
|
+
|
|
259
288
|
if [ "$PROBE_ENGINE" = "safari" ]; then
|
|
260
289
|
# V2-8.9 M1: Safari takes no per-run proxy or resolver rule, so with AI may › Search the web off
|
|
261
290
|
# (MAUDE_NO_EGRESS=1) the WebKit lane is refused rather than run with the web on.
|
|
@@ -89,8 +89,13 @@ fi
|
|
|
89
89
|
if [ -n "$SERVER_BIN" ]; then
|
|
90
90
|
_sbase="$(basename "$SERVER_BIN")"
|
|
91
91
|
_sparent="$(basename "$(dirname "$SERVER_BIN")")"
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
# fix/ds-convert-hooks-cli #13 — or the desktop app's own bundled server, which the sidecar
|
|
93
|
+
# hands every helper (sidecar.rs, DDR-166 T0b): <Name>.app/Contents/MacOS/maude-server.
|
|
94
|
+
_sapp="$(basename "$(dirname "$(dirname "$(dirname "$SERVER_BIN")")")")"
|
|
95
|
+
_scontents="$(basename "$(dirname "$(dirname "$SERVER_BIN")")")"
|
|
96
|
+
case "$_sbase:$_sparent:$_scontents:$_sapp" in
|
|
97
|
+
maude:maude-*:*:* | maude.exe:maude-*:*:*) : ;;
|
|
98
|
+
maude-server:MacOS:Contents:*.app) : ;;
|
|
94
99
|
*)
|
|
95
100
|
echo "server-up.sh: ignoring dev-server binary outside the expected maude-<slug>/ layout ($SERVER_BIN) — falling back to source" >&2
|
|
96
101
|
SERVER_BIN=""
|
package/apps/studio/bin/smoke.sh
CHANGED
|
@@ -538,6 +538,25 @@ while IFS= read -r CANVAS; do
|
|
|
538
538
|
printf '%s\t%s\t%s\t%s\n' "$STATUS" "$REL" "$SHOT" "$DETAIL"
|
|
539
539
|
done <<< "$CANVASES"
|
|
540
540
|
|
|
541
|
+
# ---------- why a canvas is refused (2.0.5 #205) ----------
|
|
542
|
+
# A canvas that imports another canvas, or whose built module inlined a file another canvas owns, renders
|
|
543
|
+
# nothing in its frame. The server knows why (`/_index-data` canvasImportsCanvases + canvasRefusedInputs);
|
|
544
|
+
# say it here in the shell card's words, so the report is not a bare "error".
|
|
545
|
+
REASONS=""
|
|
546
|
+
if command -v bun >/dev/null 2>&1; then
|
|
547
|
+
REASONS=$(curl -fsS -m 5 "http://localhost:$PORT/_index-data" 2>/dev/null \
|
|
548
|
+
| bun "$(dirname "$0")/_canvas-reasons.mjs" 2>/dev/null)
|
|
549
|
+
fi
|
|
550
|
+
if [ -n "$REASONS" ]; then
|
|
551
|
+
printf '%s\n' "$REASONS" >&2
|
|
552
|
+
{
|
|
553
|
+
echo
|
|
554
|
+
echo "## Refused canvases"
|
|
555
|
+
echo
|
|
556
|
+
printf '%s\n' "$REASONS" | sed 's/^/- /'
|
|
557
|
+
} >> "$MD"
|
|
558
|
+
fi
|
|
559
|
+
|
|
541
560
|
TOTAL_FAIL=$((FAILED + LINT_FAILED))
|
|
542
561
|
{
|
|
543
562
|
echo
|
|
@@ -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);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// The camera a canvas opens on when nobody chose one (2.0.7 fix #6). Pure and React-free, so
|
|
2
|
+
// canvas-lib and the tests share one function.
|
|
3
|
+
//
|
|
4
|
+
// Michal (desktop 2.0.6, StudyFi): the Design system canvas opened as an empty canvas, and only
|
|
5
|
+
// zoom-to-fit showed the artboards — at 2 %, scattered over a huge area. Two causes:
|
|
6
|
+
// · with no stored camera the runtime fitted EVERYTHING, and a canvas 43 000 px wide fits at 2 %:
|
|
7
|
+
// on screen, but nothing on it can be read;
|
|
8
|
+
// · a stored camera (`_canvas-state/<slug>.view.json`, per machine) from an older layout was
|
|
9
|
+
// restored as-is, and pointed at a spot where no artboard is any more.
|
|
10
|
+
// So: fit-all while it is readable, else the top row, else the first artboard; and a stored camera
|
|
11
|
+
// that frames no artboard once the layout has settled is treated as no camera at all.
|
|
12
|
+
|
|
13
|
+
/** The slice of an artboard rect the camera reads. */
|
|
14
|
+
export interface CameraRect {
|
|
15
|
+
id: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
w: number;
|
|
19
|
+
h: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Camera {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
zoom: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Below this zoom a fit shows only thumbnails: a 1 440 px page is 144 screen px wide and its text
|
|
30
|
+
* is a grey line. A fit-all that small is not a view of the content, so the default camera frames
|
|
31
|
+
* less of it instead (⌘0 still fits everything).
|
|
32
|
+
*/
|
|
33
|
+
export const READABLE_ZOOM = 0.1;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How long the layout must stay still before a restored camera is judged (ms). Hugging artboards
|
|
37
|
+
* report their heights and the Design system canvas re-pitches its rows in the first frames; a
|
|
38
|
+
* camera is only "on nothing" once that is done.
|
|
39
|
+
*/
|
|
40
|
+
export const STORED_CAMERA_CHECK_MS = 400;
|
|
41
|
+
|
|
42
|
+
const finite = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The top row: the artboard nearest the top (then the left) and every artboard beside it — the
|
|
46
|
+
* ones whose vertical span overlaps its own — left to right.
|
|
47
|
+
*/
|
|
48
|
+
export function topRow<T extends CameraRect>(rects: readonly T[]): T[] {
|
|
49
|
+
if (rects.length === 0) return [];
|
|
50
|
+
let anchor = rects[0] as T;
|
|
51
|
+
for (const r of rects) if (r.y < anchor.y || (r.y === anchor.y && r.x < anchor.x)) anchor = r;
|
|
52
|
+
return rects
|
|
53
|
+
.filter((r) => r.y < anchor.y + anchor.h && r.y + r.h > anchor.y)
|
|
54
|
+
.slice()
|
|
55
|
+
.sort((a, b) => a.x - b.x);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The camera a canvas opens on with no camera of its own. `fit` is the runtime's own fit (host size,
|
|
60
|
+
* padding and the shell's occluded insets already applied).
|
|
61
|
+
*/
|
|
62
|
+
export function defaultCamera<T extends CameraRect>(
|
|
63
|
+
rects: readonly T[],
|
|
64
|
+
fit: (rects: T[]) => Camera
|
|
65
|
+
): Camera {
|
|
66
|
+
const all = fit(rects.slice());
|
|
67
|
+
if (rects.length <= 1 || all.zoom >= READABLE_ZOOM) return all;
|
|
68
|
+
const row = topRow(rects);
|
|
69
|
+
const r = fit(row);
|
|
70
|
+
if (row.length <= 1 || r.zoom >= READABLE_ZOOM) return r;
|
|
71
|
+
return fit([row[0] as T]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** True when the camera, on a `w` x `h` host, shows any part of any artboard. */
|
|
75
|
+
export function cameraShowsContent(
|
|
76
|
+
camera: Camera,
|
|
77
|
+
w: number,
|
|
78
|
+
h: number,
|
|
79
|
+
rects: readonly CameraRect[]
|
|
80
|
+
): boolean {
|
|
81
|
+
if (!finite(camera.x) || !finite(camera.y) || !finite(camera.zoom) || camera.zoom <= 0)
|
|
82
|
+
return false;
|
|
83
|
+
if (!(w > 0) || !(h > 0)) return false;
|
|
84
|
+
// screen = world * zoom + offset → the world rect on screen
|
|
85
|
+
const x0 = -camera.x / camera.zoom;
|
|
86
|
+
const y0 = -camera.y / camera.zoom;
|
|
87
|
+
const x1 = x0 + w / camera.zoom;
|
|
88
|
+
const y1 = y0 + h / camera.zoom;
|
|
89
|
+
return rects.some((r) => r.x < x1 && r.x + r.w > x0 && r.y < y1 && r.y + r.h > y0);
|
|
90
|
+
}
|
|
@@ -38,11 +38,11 @@ import {
|
|
|
38
38
|
useState,
|
|
39
39
|
} from 'react';
|
|
40
40
|
import { createRoot } from 'react-dom/client';
|
|
41
|
-
|
|
42
41
|
import { acceptFromShell } from './bridge/dgn-protocol.ts';
|
|
43
42
|
import { annotationElement, annotationIdAt, clientToWorld } from './comment-anchor.ts';
|
|
44
43
|
import { CommentsOverlay } from './comments-overlay.tsx';
|
|
45
44
|
import { deriveFile, hoverTargetToSelection } from './dom-selection.ts';
|
|
45
|
+
import { frameCaf, frameRaf } from './frame-clock.ts';
|
|
46
46
|
import {
|
|
47
47
|
type HoverTarget,
|
|
48
48
|
isOverlayTarget,
|
|
@@ -173,10 +173,10 @@ function CommentHost({ children, file }: { children: ReactNode; file: string | u
|
|
|
173
173
|
// re-check on the next frame + a short timeout before deciding.
|
|
174
174
|
const check = () => setIsSpecimen(isBareSpecimen());
|
|
175
175
|
check();
|
|
176
|
-
const raf =
|
|
176
|
+
const raf = frameRaf(check);
|
|
177
177
|
const t = setTimeout(check, 120);
|
|
178
178
|
return () => {
|
|
179
|
-
|
|
179
|
+
frameCaf(raf);
|
|
180
180
|
clearTimeout(t);
|
|
181
181
|
};
|
|
182
182
|
}, []);
|
|
@@ -321,11 +321,11 @@ function MountSelectionHalo({ el }: { el: HTMLElement }) {
|
|
|
321
321
|
} else if (div) {
|
|
322
322
|
div.style.display = 'none';
|
|
323
323
|
}
|
|
324
|
-
rafRef.current =
|
|
324
|
+
rafRef.current = frameRaf(tick);
|
|
325
325
|
};
|
|
326
|
-
rafRef.current =
|
|
326
|
+
rafRef.current = frameRaf(tick);
|
|
327
327
|
return () => {
|
|
328
|
-
if (rafRef.current != null)
|
|
328
|
+
if (rafRef.current != null) frameCaf(rafRef.current);
|
|
329
329
|
};
|
|
330
330
|
}, []);
|
|
331
331
|
|
|
@@ -377,11 +377,11 @@ function MountHoverHalo({ el }: { el: HTMLElement }) {
|
|
|
377
377
|
} else if (div) {
|
|
378
378
|
div.style.display = 'none';
|
|
379
379
|
}
|
|
380
|
-
rafRef.current =
|
|
380
|
+
rafRef.current = frameRaf(tick);
|
|
381
381
|
};
|
|
382
|
-
rafRef.current =
|
|
382
|
+
rafRef.current = frameRaf(tick);
|
|
383
383
|
return () => {
|
|
384
|
-
if (rafRef.current != null)
|
|
384
|
+
if (rafRef.current != null) frameCaf(rafRef.current);
|
|
385
385
|
};
|
|
386
386
|
}, []);
|
|
387
387
|
|