@1agh/maude 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/acp/bridge.ts +15 -2
- package/apps/studio/acp/login-state.ts +1 -0
- package/apps/studio/acp/probe.ts +52 -1
- package/apps/studio/api.ts +431 -39
- package/apps/studio/asset-upload.ts +174 -0
- package/apps/studio/assets-s3.ts +37 -2
- package/apps/studio/bin/_curl-local.mjs +7 -0
- package/apps/studio/bin/_pdf-playwright.mjs +22 -1
- package/apps/studio/bin/_png-playwright.mjs +20 -1
- package/apps/studio/bin/_region.mjs +92 -0
- package/apps/studio/bin/annotate.mjs +16 -7
- package/apps/studio/bin/read-annotations.mjs +62 -4
- package/apps/studio/canvas-build.ts +59 -4
- package/apps/studio/canvas-lib.tsx +48 -1
- package/apps/studio/canvas-shell.tsx +28 -4
- package/apps/studio/client/app.jsx +441 -15903
- package/apps/studio/client/canvas-url.js +9 -0
- package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
- package/apps/studio/client/dialogs/command-palette.jsx +112 -0
- package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
- package/apps/studio/client/dialogs/help-modal.jsx +324 -0
- package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
- package/apps/studio/client/embed-view.jsx +284 -0
- package/apps/studio/client/embed.js +101 -0
- package/apps/studio/client/export-center.jsx +2 -0
- package/apps/studio/client/github.js +36 -3
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
- package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
- package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
- package/apps/studio/client/hooks/use-project-data.jsx +90 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
- package/apps/studio/client/hooks/use-tabs.jsx +723 -0
- package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
- package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
- package/apps/studio/client/inspector/color-picker.jsx +196 -0
- package/apps/studio/client/inspector/color.js +92 -0
- package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
- package/apps/studio/client/inspector/css-vocab.jsx +131 -0
- package/apps/studio/client/inspector/ds-tokens.js +90 -0
- package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
- package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
- package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
- package/apps/studio/client/inspector/layers.jsx +322 -0
- package/apps/studio/client/inspector/selection.js +65 -0
- package/apps/studio/client/inspector/token-popover.jsx +301 -0
- package/apps/studio/client/menus/menubar.jsx +856 -0
- package/apps/studio/client/report-bug.jsx +8 -2
- package/apps/studio/client/selection-scope.js +40 -0
- package/apps/studio/client/shell/banners.jsx +272 -0
- package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
- package/apps/studio/client/shell/comments-panel.jsx +177 -0
- package/apps/studio/client/shell/constants.js +60 -0
- package/apps/studio/client/shell/dock.jsx +131 -0
- package/apps/studio/client/shell/icons.jsx +370 -0
- package/apps/studio/client/shell/status-bar.jsx +215 -0
- package/apps/studio/client/shell/util.js +332 -0
- package/apps/studio/client/shell/viewport.jsx +254 -0
- package/apps/studio/client/system/system-view.jsx +255 -0
- package/apps/studio/client/tree/tree.jsx +1243 -0
- package/apps/studio/comments-overlay.tsx +6 -4
- package/apps/studio/config.schema.json +5 -0
- package/apps/studio/context.ts +20 -0
- package/apps/studio/dist/client.bundle.js +2728 -2728
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/embed-origins.ts +52 -0
- package/apps/studio/export-dialog.tsx +55 -3
- package/apps/studio/exporters/_browser-bundles.ts +21 -2
- package/apps/studio/exporters/format-scopes.ts +11 -3
- package/apps/studio/exporters/index.ts +17 -2
- package/apps/studio/exporters/jobs.ts +91 -23
- package/apps/studio/exporters/pdf.ts +10 -2
- package/apps/studio/exporters/png.ts +10 -2
- package/apps/studio/exporters/scope.ts +89 -15
- package/apps/studio/format.ts +296 -0
- package/apps/studio/generation/runtime-probe.ts +1 -1
- package/apps/studio/git/service.ts +1 -0
- package/apps/studio/http.ts +399 -36
- package/apps/studio/input-router.tsx +7 -1
- package/apps/studio/path-containment.ts +72 -0
- package/apps/studio/paths.ts +14 -1
- package/apps/studio/read-only-mode.ts +53 -0
- package/apps/studio/server.ts +123 -25
- package/apps/studio/sync/accepted-link.ts +6 -0
- package/apps/studio/sync/agent.ts +9 -1
- package/apps/studio/sync/cold-start-apply.ts +29 -4
- package/apps/studio/sync/cold-start.ts +78 -0
- package/apps/studio/sync/file-plane.ts +61 -1
- package/apps/studio/sync/format-sync.ts +160 -0
- package/apps/studio/sync/index.ts +208 -23
- package/apps/studio/sync/journal-client.ts +25 -5
- package/apps/studio/sync/migrate-seed.ts +8 -1
- package/apps/studio/sync/park.ts +39 -0
- package/apps/studio/sync/presentation.ts +9 -3
- package/apps/studio/sync/status.ts +2 -0
- package/apps/studio/sync/transaction-client.ts +130 -13
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/ui-prefs.ts +95 -10
- package/apps/studio/use-canvas-media-drop.tsx +8 -28
- package/apps/studio/whats-new.json +36 -0
- package/apps/studio/ws.ts +19 -4
- package/cli/bin/claude-design-server.mjs +0 -0
- package/cli/commands/design.mjs +9 -2
- package/cli/commands/hub-workspace.mjs +25 -0
- package/cli/lib/workspace-plan.mjs +51 -0
- package/package.json +11 -9
- package/plugins/design/templates/_shell.html +58 -0
|
@@ -29,6 +29,7 @@ import path from 'node:path';
|
|
|
29
29
|
import { readAllArtboardPrintProps } from '../canvas-edit.ts';
|
|
30
30
|
|
|
31
31
|
import type { Bus } from '../context.ts';
|
|
32
|
+
import { currentSession, normalizeSessionKey } from '../session-scope.ts';
|
|
32
33
|
import { resolveRenderLane } from '../workspace-mode.ts';
|
|
33
34
|
import {
|
|
34
35
|
type ExportContext,
|
|
@@ -115,12 +116,27 @@ export interface EnqueueArgs {
|
|
|
115
116
|
* is `local` and this is never read.
|
|
116
117
|
*/
|
|
117
118
|
remoteCanvas?: RemoteCanvasAccess;
|
|
119
|
+
/**
|
|
120
|
+
* V2-2.8 S5 — whose job this is: the proxy-vouched session key of the member
|
|
121
|
+
* who asked (session-scope.ts). Defaults to the ambient request's session;
|
|
122
|
+
* `''` (desktop, CLI, tests) is the one shared owner a desktop always had.
|
|
123
|
+
*/
|
|
124
|
+
session?: string;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
export type DownloadResult =
|
|
121
128
|
| { ok: true; bytes: Uint8Array; filename: string; contentType: string }
|
|
122
129
|
| { ok: false; reason: 'missing' | 'not-done' };
|
|
123
130
|
|
|
131
|
+
/**
|
|
132
|
+
* V2-2.8 S5 (V2-1.16 L7 "everyone-fix") — every read below is scoped to ONE
|
|
133
|
+
* owner: the `session` argument, defaulting to the ambient request's session
|
|
134
|
+
* key (session-scope.ts `currentSession()`, set per request by server.ts
|
|
135
|
+
* `withSession`). A cell serves every member from one process (DDR-209), and
|
|
136
|
+
* these used to answer with every member's jobs. An invisible job answers
|
|
137
|
+
* exactly like a missing one (U1). On a desktop every key is `''`, so the
|
|
138
|
+
* answers are unchanged.
|
|
139
|
+
*/
|
|
124
140
|
export interface ExportJobQueue {
|
|
125
141
|
enqueue(args: EnqueueArgs): { id: string; result: Promise<ExportResult> };
|
|
126
142
|
/**
|
|
@@ -128,11 +144,16 @@ export interface ExportJobQueue {
|
|
|
128
144
|
* lane) so it appears in the same ledger every other export does. No bytes
|
|
129
145
|
* are kept — the file never passed through this process.
|
|
130
146
|
*/
|
|
131
|
-
recordBrowserExport(args: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
recordBrowserExport(args: {
|
|
148
|
+
format: Format;
|
|
149
|
+
scope: Scope;
|
|
150
|
+
filename: string;
|
|
151
|
+
session?: string;
|
|
152
|
+
}): ExportHistoryEntry;
|
|
153
|
+
get(id: string, session?: string): ExportJob | undefined;
|
|
154
|
+
list(session?: string): ExportJob[];
|
|
155
|
+
loadHistory(session?: string): ExportHistoryEntry[];
|
|
156
|
+
getBytes(id: string, session?: string): Promise<DownloadResult>;
|
|
136
157
|
}
|
|
137
158
|
|
|
138
159
|
const HISTORY_DEPTH = 20;
|
|
@@ -304,6 +325,12 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
304
325
|
const maxConcurrent = Math.max(1, Number(process.env.MAUDE_EXPORT_MAX_CONCURRENT) || 2);
|
|
305
326
|
const semaphore = new Semaphore(maxConcurrent);
|
|
306
327
|
const jobs = new Map<string, ExportJob>();
|
|
328
|
+
// V2-2.8 S5 — job id → the session key that asked for it. Kept beside the job
|
|
329
|
+
// rather than on it so no response, socket frame or public ledger row ever
|
|
330
|
+
// carries a session key; only the on-disk ledger stores it (as `session`).
|
|
331
|
+
const owners = new Map<string, string>();
|
|
332
|
+
const ownerOf = (id: string): string => owners.get(id) ?? '';
|
|
333
|
+
const ownedBy = (session: string) => (job: ExportJob) => ownerOf(job.id) === session;
|
|
307
334
|
|
|
308
335
|
// Seed the ledger from disk ONCE — the only read of the history file. Every
|
|
309
336
|
// later persist derives fresh from `jobs` and overwrites; there is no
|
|
@@ -334,6 +361,10 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
334
361
|
filename: e.filename as string | undefined,
|
|
335
362
|
error: e.error as string | undefined,
|
|
336
363
|
});
|
|
364
|
+
// V2-2.8 S5 — a row written before ownership existed has no `session`
|
|
365
|
+
// and stays the shared ('') owner's, which in a cell is nobody.
|
|
366
|
+
const owner = normalizeSessionKey(typeof e.session === 'string' ? e.session : '');
|
|
367
|
+
if (owner) owners.set(id, owner);
|
|
337
368
|
}
|
|
338
369
|
}
|
|
339
370
|
} catch {
|
|
@@ -342,18 +373,27 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
342
373
|
|
|
343
374
|
// Orphaned `_export-jobs/*` dirs from a process that died mid-export — job
|
|
344
375
|
// state is in-memory only and doesn't survive a restart, so anything on
|
|
345
|
-
// disk from a prior run is stale. Best-effort, never blocks boot
|
|
346
|
-
|
|
376
|
+
// disk from a prior run is stale. Best-effort, never blocks boot — but a
|
|
377
|
+
// job's byte write waits for it: a zip finishes in milliseconds, and an
|
|
378
|
+
// unawaited sweep landing after that write deleted the fresh job's bytes
|
|
379
|
+
// (a 404 on download, seen on Linux CI).
|
|
380
|
+
const staleSwept: Promise<void> = rm(jobsDir, { recursive: true, force: true })
|
|
347
381
|
.catch(() => {})
|
|
348
|
-
.then(() => mkdir(jobsDir, { recursive: true }).catch(() => {}))
|
|
382
|
+
.then(() => mkdir(jobsDir, { recursive: true }).catch(() => {}))
|
|
383
|
+
.then(() => {});
|
|
349
384
|
|
|
350
385
|
function emit(job: ExportJob): void {
|
|
351
|
-
|
|
386
|
+
// V2-2.8 S5 — the socket push goes to the owner's shell only (ws.ts honours
|
|
387
|
+
// `meta.session`); a desktop job (owner '') still reaches every socket.
|
|
388
|
+
const owner = ownerOf(job.id);
|
|
389
|
+
bus.emit('export:job', { ...job }, owner ? { session: owner } : undefined);
|
|
352
390
|
}
|
|
353
391
|
|
|
354
|
-
|
|
392
|
+
/** `filter` scopes the PUBLIC view; the on-disk ledger passes none. */
|
|
393
|
+
function deriveHistory(filter?: (job: ExportJob) => boolean): ExportHistoryEntry[] {
|
|
355
394
|
return Array.from(jobs.values())
|
|
356
395
|
.filter(isFinished)
|
|
396
|
+
.filter((j) => (filter ? filter(j) : true))
|
|
357
397
|
.sort((a, b) => (b.finishedAt ?? '').localeCompare(a.finishedAt ?? ''))
|
|
358
398
|
.slice(0, HISTORY_DEPTH)
|
|
359
399
|
.map((j) => ({
|
|
@@ -375,7 +415,14 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
375
415
|
}
|
|
376
416
|
|
|
377
417
|
async function persistAndEvict(): Promise<void> {
|
|
378
|
-
|
|
418
|
+
// The ledger keeps every member's rows, each with its owner (`session`,
|
|
419
|
+
// only when there is one — a desktop ledger is byte-for-byte unchanged), so
|
|
420
|
+
// ownership survives a restart. It is runtime state (DDR-115), never served
|
|
421
|
+
// as-is: GET /_api/export-history reads `loadHistory(session)` instead.
|
|
422
|
+
const history = deriveHistory().map((entry) => {
|
|
423
|
+
const owner = entry.id ? ownerOf(entry.id) : '';
|
|
424
|
+
return owner ? { ...entry, session: owner } : entry;
|
|
425
|
+
});
|
|
379
426
|
await Bun.write(historyPath, JSON.stringify(history, null, 2));
|
|
380
427
|
|
|
381
428
|
const now = Date.now();
|
|
@@ -398,6 +445,7 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
398
445
|
});
|
|
399
446
|
for (const job of staleBytes) {
|
|
400
447
|
jobs.delete(job.id);
|
|
448
|
+
owners.delete(job.id);
|
|
401
449
|
await rm(path.join(jobsDir, job.id), { recursive: true, force: true }).catch(() => {});
|
|
402
450
|
}
|
|
403
451
|
|
|
@@ -407,7 +455,10 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
407
455
|
const byteless = Array.from(jobs.values())
|
|
408
456
|
.filter((j) => isFinished(j) && (j.deliveredInBrowser || !j.filename))
|
|
409
457
|
.sort((a, b) => (b.finishedAt ?? '').localeCompare(a.finishedAt ?? ''));
|
|
410
|
-
for (const job of byteless.slice(HISTORY_DEPTH))
|
|
458
|
+
for (const job of byteless.slice(HISTORY_DEPTH)) {
|
|
459
|
+
jobs.delete(job.id);
|
|
460
|
+
owners.delete(job.id);
|
|
461
|
+
}
|
|
411
462
|
}
|
|
412
463
|
|
|
413
464
|
function enqueue(args: EnqueueArgs): { id: string; result: Promise<ExportResult> } {
|
|
@@ -426,6 +477,8 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
426
477
|
status: 'queued',
|
|
427
478
|
createdAt: new Date().toISOString(),
|
|
428
479
|
};
|
|
480
|
+
const owner = normalizeSessionKey(args.session ?? currentSession());
|
|
481
|
+
if (owner) owners.set(id, owner);
|
|
429
482
|
jobs.set(id, job);
|
|
430
483
|
emit(job);
|
|
431
484
|
|
|
@@ -540,6 +593,15 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
540
593
|
},
|
|
541
594
|
});
|
|
542
595
|
|
|
596
|
+
// Bytes land on disk BEFORE the job reads `done`. The other way round,
|
|
597
|
+
// a poller saw `done` while the write was still in flight and its
|
|
598
|
+
// download 404'd (Linux CI, exporters/jobs.test.ts).
|
|
599
|
+
if (res.body.byteLength) {
|
|
600
|
+
const dir = path.join(jobsDir, id);
|
|
601
|
+
await staleSwept;
|
|
602
|
+
await mkdir(dir, { recursive: true });
|
|
603
|
+
await Bun.write(path.join(dir, res.filename), res.body);
|
|
604
|
+
}
|
|
543
605
|
job.status = 'done';
|
|
544
606
|
job.finishedAt = new Date().toISOString();
|
|
545
607
|
job.filename = res.filename;
|
|
@@ -550,11 +612,6 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
550
612
|
// the desktop app's stderr — see RCA
|
|
551
613
|
// issue-mp4-audio-export-html5audio-silent-degrade.
|
|
552
614
|
if (res.degraded) job.degraded = res.degraded;
|
|
553
|
-
if (res.body.byteLength) {
|
|
554
|
-
const dir = path.join(jobsDir, id);
|
|
555
|
-
await mkdir(dir, { recursive: true });
|
|
556
|
-
await Bun.write(path.join(dir, res.filename), res.body);
|
|
557
|
-
}
|
|
558
615
|
emit(job);
|
|
559
616
|
await persistAndEvict();
|
|
560
617
|
return res;
|
|
@@ -576,9 +633,15 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
576
633
|
|
|
577
634
|
return {
|
|
578
635
|
enqueue,
|
|
579
|
-
get
|
|
580
|
-
|
|
581
|
-
|
|
636
|
+
get(id, session = currentSession()) {
|
|
637
|
+
const job = jobs.get(id);
|
|
638
|
+
return job && ownerOf(id) === normalizeSessionKey(session) ? job : undefined;
|
|
639
|
+
},
|
|
640
|
+
list: (session = currentSession()) =>
|
|
641
|
+
Array.from(jobs.values())
|
|
642
|
+
.filter(ownedBy(normalizeSessionKey(session)))
|
|
643
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt)),
|
|
644
|
+
recordBrowserExport({ format, scope, filename, session = currentSession() }) {
|
|
582
645
|
const now = new Date().toISOString();
|
|
583
646
|
const job: ExportJob = {
|
|
584
647
|
id: crypto.randomUUID(),
|
|
@@ -592,6 +655,8 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
592
655
|
filename,
|
|
593
656
|
deliveredInBrowser: true,
|
|
594
657
|
};
|
|
658
|
+
const owner = normalizeSessionKey(session);
|
|
659
|
+
if (owner) owners.set(job.id, owner);
|
|
595
660
|
jobs.set(job.id, job);
|
|
596
661
|
emit(job);
|
|
597
662
|
// Fire-and-forget: the member already HAS the file, so a slow ledger
|
|
@@ -610,10 +675,13 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
610
675
|
deliveredInBrowser: true,
|
|
611
676
|
};
|
|
612
677
|
},
|
|
613
|
-
loadHistory:
|
|
614
|
-
|
|
678
|
+
loadHistory: (session = currentSession()) =>
|
|
679
|
+
deriveHistory(ownedBy(normalizeSessionKey(session))),
|
|
680
|
+
async getBytes(id, session = currentSession()) {
|
|
615
681
|
const job = jobs.get(id);
|
|
616
|
-
|
|
682
|
+
// Another member's job answers exactly like a missing one (V2-1.16 U1).
|
|
683
|
+
if (!job || ownerOf(id) !== normalizeSessionKey(session))
|
|
684
|
+
return { ok: false, reason: 'missing' };
|
|
617
685
|
if (job.status !== 'done') return { ok: false, reason: 'not-done' };
|
|
618
686
|
if (!job.filename) return { ok: false, reason: 'missing' };
|
|
619
687
|
const file = Bun.file(path.join(jobsDir, id, job.filename));
|
|
@@ -140,7 +140,7 @@ async function capturePdf(
|
|
|
140
140
|
const args = [
|
|
141
141
|
PDF_PLAYWRIGHT,
|
|
142
142
|
'--url',
|
|
143
|
-
canvasShellUrl(ctx, target.file),
|
|
143
|
+
canvasShellUrl(ctx, target.file, { annotations: target.annotations }),
|
|
144
144
|
'--selector',
|
|
145
145
|
target.cssPath,
|
|
146
146
|
'--timeout',
|
|
@@ -148,7 +148,15 @@ async function capturePdf(
|
|
|
148
148
|
'--scale',
|
|
149
149
|
String(deviceScale),
|
|
150
150
|
];
|
|
151
|
-
if (target.
|
|
151
|
+
if (target.region) {
|
|
152
|
+
// Issue #125 — one page covering a world-plane region (whole canvas / selection box).
|
|
153
|
+
args.push(
|
|
154
|
+
'--region',
|
|
155
|
+
target.region === 'canvas' ? 'canvas' : JSON.stringify(target.region),
|
|
156
|
+
'--out',
|
|
157
|
+
path.join(outDir, `${target.canvasSlug}.pdf`)
|
|
158
|
+
);
|
|
159
|
+
} else if (target.multi) args.push('--multi', '1', '--out-dir', outDir);
|
|
152
160
|
else {
|
|
153
161
|
// Widen to the enclosing artboard only when scope.ts requested it
|
|
154
162
|
// (artboard-via-descendant fallback). selection / artboard-by-id targets
|
|
@@ -92,7 +92,7 @@ async function captureElement(
|
|
|
92
92
|
const args = [
|
|
93
93
|
PNG_PLAYWRIGHT,
|
|
94
94
|
'--url',
|
|
95
|
-
canvasShellUrl(ctx, target.file),
|
|
95
|
+
canvasShellUrl(ctx, target.file, { annotations: target.annotations }),
|
|
96
96
|
'--selector',
|
|
97
97
|
target.cssPath,
|
|
98
98
|
'--scale',
|
|
@@ -100,7 +100,15 @@ async function captureElement(
|
|
|
100
100
|
'--timeout',
|
|
101
101
|
String(options.timeoutSec ?? 12),
|
|
102
102
|
];
|
|
103
|
-
if (target.
|
|
103
|
+
if (target.region) {
|
|
104
|
+
// Issue #125 — one image of a world-plane region (whole canvas / selection box).
|
|
105
|
+
args.push(
|
|
106
|
+
'--region',
|
|
107
|
+
target.region === 'canvas' ? 'canvas' : JSON.stringify(target.region),
|
|
108
|
+
'--out',
|
|
109
|
+
path.join(outDir, `${target.canvasSlug}.png`)
|
|
110
|
+
);
|
|
111
|
+
} else if (target.multi) {
|
|
104
112
|
args.push('--multi', '1', '--out-dir', outDir);
|
|
105
113
|
} else {
|
|
106
114
|
// Only widen to the enclosing artboard when scope.ts asked for it
|
|
@@ -13,8 +13,23 @@ import type { Dirent } from 'node:fs';
|
|
|
13
13
|
import { readdir } from 'node:fs/promises';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import { isRuntimeStateRel } from '../sync/file-membership.ts';
|
|
17
|
+
|
|
18
|
+
/** The user-facing scope choices from the export dialog. */
|
|
19
|
+
export type Scope =
|
|
20
|
+
| 'selection'
|
|
21
|
+
| 'artboard'
|
|
22
|
+
| 'canvas-as-separate'
|
|
23
|
+
| 'canvas-whole'
|
|
24
|
+
| 'selection-bounds'
|
|
25
|
+
| 'project-raw';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A world-plane region captured as ONE image / page (issue #125): the whole
|
|
29
|
+
* canvas (every artboard + annotation element) or the union bounding box of a
|
|
30
|
+
* list of selected elements. Layout between artboards is kept as-is.
|
|
31
|
+
*/
|
|
32
|
+
export type CaptureRegion = 'canvas' | { selectors: string[] };
|
|
18
33
|
|
|
19
34
|
/**
|
|
20
35
|
* What an adapter receives for each render unit. `element` targets carry a
|
|
@@ -44,6 +59,17 @@ export type Target =
|
|
|
44
59
|
* directly and leave this `false`.
|
|
45
60
|
*/
|
|
46
61
|
widen?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Capture this region of the world plane as one unit instead of the
|
|
64
|
+
* element at `cssPath` (which then only gates "the canvas has mounted").
|
|
65
|
+
*/
|
|
66
|
+
region?: CaptureRegion;
|
|
67
|
+
/**
|
|
68
|
+
* Render the annotation layer (the FigJam-style draw elements) into the
|
|
69
|
+
* capture. Comment pins stay hidden either way. Off unless the export
|
|
70
|
+
* options opt in with `includeAnnotations: true`.
|
|
71
|
+
*/
|
|
72
|
+
annotations?: boolean;
|
|
47
73
|
}
|
|
48
74
|
| {
|
|
49
75
|
kind: 'file-tree';
|
|
@@ -82,6 +108,8 @@ export interface ExportScopeHints {
|
|
|
82
108
|
* the worker). The live dialog knows which file it is looking at; trust it.
|
|
83
109
|
*/
|
|
84
110
|
canvasFile?: string | null;
|
|
111
|
+
/** Every selector of a multi-selection, for `selection-bounds`. */
|
|
112
|
+
selectionAll?: string[];
|
|
85
113
|
}
|
|
86
114
|
|
|
87
115
|
export interface ResolveScopeArgs {
|
|
@@ -119,21 +147,32 @@ function readHints(options: Record<string, unknown> | undefined): ExportScopeHin
|
|
|
119
147
|
typeof options.artboardId === 'string' && options.artboardId ? options.artboardId : null;
|
|
120
148
|
const canvasFile =
|
|
121
149
|
typeof options.canvasFile === 'string' && options.canvasFile ? options.canvasFile : null;
|
|
122
|
-
|
|
150
|
+
// Bounded: every selector is evaluated in the capture page, and a job body
|
|
151
|
+
// is member-supplied — thousands of `:has()` selectors would pin a slot.
|
|
152
|
+
const selectionAll = Array.isArray(options.selectionAll)
|
|
153
|
+
? (options.selectionAll as unknown[])
|
|
154
|
+
.filter(
|
|
155
|
+
(x): x is string => typeof x === 'string' && x.length > 0 && x.length <= MAX_SELECTOR_LEN
|
|
156
|
+
)
|
|
157
|
+
.slice(0, MAX_SELECTION_ALL)
|
|
158
|
+
: undefined;
|
|
159
|
+
return { selection, artboardId, canvasFile, selectionAll };
|
|
123
160
|
}
|
|
124
161
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
/** Caps on `options.selectionAll` (security review, issue #125). */
|
|
163
|
+
export const MAX_SELECTION_ALL = 256;
|
|
164
|
+
const MAX_SELECTOR_LEN = 1024;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Names a `project-raw` ZIP skips that are NOT Maude runtime state — build and
|
|
168
|
+
* OS litter. Runtime state is decided by the one DDR-115 classifier below
|
|
169
|
+
* (`isRuntimeStateRel`), never by a list here: this set used to carry its own
|
|
170
|
+
* copy of the runtime names, drifted, and shipped `_chat/` (every AI
|
|
171
|
+
* conversation), `_state/`, `_untrusted/`, `_trash/`, `_draw/`, `_reports/` and
|
|
172
|
+
* each member's `_active.<session>.json` to anyone who downloaded the project
|
|
173
|
+
* (V2-2.8 S8, V2-1.16 L7).
|
|
174
|
+
*/
|
|
175
|
+
const RAW_EXCLUDES = new Set(['node_modules', 'dist', '.DS_Store']);
|
|
137
176
|
|
|
138
177
|
/**
|
|
139
178
|
* Derive a canvas slug from a repo-relative or designRoot-relative file path.
|
|
@@ -190,6 +229,9 @@ async function walkProjectRaw(root: string): Promise<string[]> {
|
|
|
190
229
|
if (e.name.endsWith('.log')) continue;
|
|
191
230
|
const abs = path.join(absDir, e.name);
|
|
192
231
|
const rel = relDir ? path.posix.join(relDir, e.name) : e.name;
|
|
232
|
+
// DDR-115 runtime state, files and whole directories alike (the
|
|
233
|
+
// classifier matches a runtime dir's own path, so the walk never enters).
|
|
234
|
+
if (isRuntimeStateRel(rel)) continue;
|
|
193
235
|
if (e.isDirectory()) {
|
|
194
236
|
await walk(abs, rel);
|
|
195
237
|
} else if (e.isFile()) {
|
|
@@ -224,6 +266,38 @@ export async function resolveScope(args: ResolveScopeArgs): Promise<Target[]> {
|
|
|
224
266
|
const slug = slugify(activeFile, designRel);
|
|
225
267
|
const sel = firstSelection(activeJson.selected);
|
|
226
268
|
|
|
269
|
+
if (scope === 'canvas-whole' || scope === 'selection-bounds') {
|
|
270
|
+
const annotations = args.options?.includeAnnotations === true;
|
|
271
|
+
const selectors = hints.selectionAll?.length
|
|
272
|
+
? hints.selectionAll
|
|
273
|
+
: [hints.selection?.selector ?? sel?.selector ?? sel?.cssPath].filter(
|
|
274
|
+
(x): x is string => !!x
|
|
275
|
+
);
|
|
276
|
+
// No selection → the bounding box of "everything" is the whole canvas.
|
|
277
|
+
if (scope === 'canvas-whole' || !selectors.length) {
|
|
278
|
+
return [
|
|
279
|
+
{
|
|
280
|
+
kind: 'element',
|
|
281
|
+
cssPath: '[data-dc-screen]',
|
|
282
|
+
canvasSlug: slug,
|
|
283
|
+
file: activeFile,
|
|
284
|
+
region: 'canvas',
|
|
285
|
+
annotations,
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
return [
|
|
290
|
+
{
|
|
291
|
+
kind: 'element',
|
|
292
|
+
cssPath: selectors[0],
|
|
293
|
+
canvasSlug: slug,
|
|
294
|
+
file: activeFile,
|
|
295
|
+
region: { selectors },
|
|
296
|
+
annotations,
|
|
297
|
+
},
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
|
|
227
301
|
if (scope === 'selection') {
|
|
228
302
|
// Prefer the live submit-time snapshot over the persisted `_active.json`
|
|
229
303
|
// selection — the dialog can clear the canvas selection before the bridged
|