@1agh/maude 2.0.4 → 2.0.6
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/filters.ts +12 -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 +5 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -1
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-layer.tsx +0 -12
- package/apps/studio/api.ts +42 -0
- package/apps/studio/artboard-live-gate.tsx +267 -0
- package/apps/studio/artboard-live.ts +336 -0
- package/apps/studio/artboard-webgl.ts +668 -0
- 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.mjs +2 -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 +11 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/canvas-lib.tsx +131 -12
- package/apps/studio/client/canvas-url.js +13 -0
- 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/use-project-data.jsx +2 -0
- 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 +36 -8
- 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/code/canvas-imports-card.jsx +15 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- 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/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 +137 -0
- 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/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +137 -10
- 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/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/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/config-reload-wire.ts +53 -0
- package/apps/studio/dist/client.bundle.js +1232 -1232
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/specimen.tsx +12 -1
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +7 -3
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/post-build.ts +38 -0
- 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 +4 -1
- 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 +14 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/server.ts +8 -10
- 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/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +40 -9
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/index.ts +308 -150
- 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 +12 -1
- package/apps/studio/sync/status.ts +3 -1
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/video-comp.tsx +23 -0
- package/apps/studio/whats-new.json +72 -0
- package/cli/lib/bash-guard.mjs +13 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
|
@@ -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
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
# difference. Refuses (exit 1) when the two geometries showed a
|
|
51
51
|
# different number of artboards on screen — not the same content.
|
|
52
52
|
# --variant A label for an A/B arm; keys the history row with the canvas.
|
|
53
|
+
# --query Extra canvas-page parameters for an A/B arm on the bare page (not --studio), e.g.
|
|
54
|
+
# `artboard-live=off` vs `artboard-live=sleep` (2.0.5 heavy canvases). Letters, digits, `=&_-` only.
|
|
53
55
|
# --inject-css CSS injected into the canvas document before each pass, to
|
|
54
56
|
# test a rendering hypothesis against the same build.
|
|
55
57
|
#
|
|
@@ -110,6 +112,7 @@ while [ $# -gt 0 ]; do
|
|
|
110
112
|
--compare-frame) COMPARE_FRAME="$2"; shift 2 ;;
|
|
111
113
|
--variant) VARIANT="$2"; shift 2 ;;
|
|
112
114
|
--inject-css) INJECT_CSS="$2"; shift 2 ;;
|
|
115
|
+
--query) QUERY="$2"; shift 2 ;;
|
|
113
116
|
--help|-h)
|
|
114
117
|
sed -n '2,/^[^#]/p' "$0" | sed '$d' | sed -E 's/^# ?//'
|
|
115
118
|
exit 0
|
|
@@ -227,6 +230,13 @@ esac
|
|
|
227
230
|
# or `%` would otherwise truncate or rewrite the query string.
|
|
228
231
|
REL_ENC=$("$JS_RUNTIME" -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$REL_FULL")
|
|
229
232
|
URL="http://localhost:${PORT}/_canvas-shell.html?canvas=${REL_ENC}"
|
|
233
|
+
if [ -n "${QUERY:-}" ]; then
|
|
234
|
+
case "$QUERY" in
|
|
235
|
+
*[!A-Za-z0-9=\&_-]*) echo "perf.sh: --query takes letters, digits and = & _ - only" >&2; exit 2 ;;
|
|
236
|
+
esac
|
|
237
|
+
[ "$STUDIO" = "1" ] && { echo "perf.sh: --query applies to the bare canvas page, not --studio" >&2; exit 2; }
|
|
238
|
+
URL="${URL}&${QUERY}"
|
|
239
|
+
fi
|
|
230
240
|
. "$SCRIPT_DIR/_url-guard.sh" && maude_url_guard "$URL" || exit 2 # V2-8.9 B2 — http(s) to this Mac only
|
|
231
241
|
|
|
232
242
|
# ---------- history path ----------
|
|
@@ -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
|