@1agh/maude 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +27 -0
- package/apps/studio/actions/agents.ts +54 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +136 -1
- package/apps/studio/actions.parity.json +25 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -3
- package/apps/studio/api.ts +383 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +414 -45
- package/apps/studio/artboard-live.ts +526 -31
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +2 -1
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/perf.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +160 -34
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +23 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +11 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/shell/viewport.jsx +32 -16
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +7 -3
- package/apps/studio/client/v2/code/canvas-imports-words.js +16 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +40 -5
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +3 -1
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +4 -1
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +720 -720
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +6 -3
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/cli.ts +7 -1
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-stage.ts +6 -2
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/http.ts +66 -32
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-plane.ts +458 -53
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +99 -15
- package/apps/studio/sync/seed-progress.ts +92 -2
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +15 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +55 -42
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +27 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +14 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// Tokens only: the accent is the canvas's own `--maude-hud-accent`; the arc and ring take no other colour.
|
|
12
12
|
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
|
-
|
|
15
14
|
import { isCzech, tiePositions } from '../edit-ops/czech-ties.ts';
|
|
15
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
16
16
|
import { langIn } from './type-role.ts';
|
|
17
17
|
|
|
18
18
|
export const TEXT_RING_STYLE_ID = 'maude-text-in-place-css';
|
|
@@ -153,17 +153,17 @@ export function TextInPlace({ readOnly }: { readOnly?: boolean }) {
|
|
|
153
153
|
// pan / zoom fire no DOM event: follow them with rAF for as long as a text is being edited (the
|
|
154
154
|
// discrete events below keep the arcs right where rAF is paused, e.g. an occluded WKWebView)
|
|
155
155
|
const loop = () => {
|
|
156
|
-
raf = measure() ?
|
|
156
|
+
raf = measure() ? frameRaf(loop) : 0;
|
|
157
157
|
};
|
|
158
158
|
const kick = () => {
|
|
159
159
|
measure(true);
|
|
160
|
-
if (!raf && document.querySelector(EDITING)) raf =
|
|
160
|
+
if (!raf && document.querySelector(EDITING)) raf = frameRaf(loop);
|
|
161
161
|
};
|
|
162
162
|
const events = ['input', 'keyup', 'focusin', 'focusout', 'selectionchange'] as const;
|
|
163
163
|
for (const e of events) document.addEventListener(e, kick, true);
|
|
164
164
|
return () => {
|
|
165
165
|
for (const e of events) document.removeEventListener(e, kick, true);
|
|
166
|
-
if (raf)
|
|
166
|
+
if (raf) frameCaf(raf);
|
|
167
167
|
};
|
|
168
168
|
}, [readOnly]);
|
|
169
169
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// artboards (`[data-dc-screen="<id>"]`), follows them while the camera moves, and never writes.
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef, useState } from 'react';
|
|
10
|
-
|
|
11
10
|
import { acceptFromShell } from '../bridge/dgn-protocol.ts';
|
|
11
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
12
12
|
|
|
13
13
|
type Lit = { id: string; left: number; top: number; width: number; height: number };
|
|
14
14
|
|
|
@@ -82,11 +82,11 @@ export function UndoPreview() {
|
|
|
82
82
|
last = key;
|
|
83
83
|
setLit(next); // only when a box moved — a still camera re-renders nothing
|
|
84
84
|
}
|
|
85
|
-
raf.current =
|
|
85
|
+
raf.current = frameRaf(tick);
|
|
86
86
|
};
|
|
87
87
|
tick();
|
|
88
88
|
return () => {
|
|
89
|
-
if (raf.current != null)
|
|
89
|
+
if (raf.current != null) frameCaf(raf.current);
|
|
90
90
|
raf.current = null;
|
|
91
91
|
};
|
|
92
92
|
}, [want]);
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { useEffect, useRef, useState } from 'react';
|
|
16
|
-
|
|
17
16
|
import { resolveSelectionEl } from './dom-selection.ts';
|
|
18
17
|
import { detectEqualSpacing, type EqualSpacingResult } from './equal-spacing-detector.ts';
|
|
18
|
+
import { frameCaf, frameRaf } from './frame-clock.ts';
|
|
19
19
|
import { useSelectionSet } from './use-selection-set.tsx';
|
|
20
20
|
|
|
21
21
|
const HOVER_PADDING_PX = 40;
|
|
@@ -198,7 +198,7 @@ export function EqualSpacingHandles() {
|
|
|
198
198
|
|
|
199
199
|
const onFrame = () => {
|
|
200
200
|
if (rafRef.current != null) return;
|
|
201
|
-
rafRef.current =
|
|
201
|
+
rafRef.current = frameRaf(tick);
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
// Initial paint + continuous follow on pan/zoom/scroll.
|
|
@@ -211,7 +211,7 @@ export function EqualSpacingHandles() {
|
|
|
211
211
|
|
|
212
212
|
return () => {
|
|
213
213
|
alive = false;
|
|
214
|
-
if (rafRef.current != null)
|
|
214
|
+
if (rafRef.current != null) frameCaf(rafRef.current);
|
|
215
215
|
window.removeEventListener('scroll', recheck, { capture: true } as EventListenerOptions);
|
|
216
216
|
window.removeEventListener('resize', recheck);
|
|
217
217
|
observer.disconnect();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file frame-clock.ts — 2.0.7: Maude's own frame callbacks, exempt from the gesture freeze
|
|
3
|
+
* @scope apps/studio/frame-clock.ts (canvas frame only; React-free)
|
|
4
|
+
* @purpose While the camera moves, an artboard's own frame callbacks wait (Michal: "while you pan or zoom,
|
|
5
|
+
* artboards must not redraw"). The canvas frame's document (`plugins/design/templates/_shell.html`,
|
|
6
|
+
* script `maude-frame-freeze`) gates `window.requestAnimationFrame` before any module loads, so the
|
|
7
|
+
* canvas runtime (motion captures it when it loads), Remotion's Player, pixi, three.js and a canvas's
|
|
8
|
+
* own loops all wait while frozen and run on the first frame after the thaw, in the order they asked.
|
|
9
|
+
*
|
|
10
|
+
* Maude's own frame code must never wait — the camera's animation, the gesture's own end
|
|
11
|
+
* (`afterQuietFrame`), the mount ring's queue, the stills' slices and the chrome that follows the camera
|
|
12
|
+
* (halos, comment pins, toolbars). It calls `frameRaf` / `frameCaf` instead of the globals:
|
|
13
|
+
* `test/v2-207-gesture-freeze.test.tsx` fails on a bare `requestAnimationFrame(` anywhere in the frame's
|
|
14
|
+
* import graph.
|
|
15
|
+
*
|
|
16
|
+
* Without the shell's script (tests, a document that is not the canvas shell) these are the plain
|
|
17
|
+
* globals and `setFrameFreeze` does nothing.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The API the shell's `maude-frame-freeze` script installs on the canvas frame's window. */
|
|
21
|
+
export interface FrameFreezeApi {
|
|
22
|
+
v: number;
|
|
23
|
+
/** The platform's requestAnimationFrame — never deferred. */
|
|
24
|
+
raf(cb: FrameRequestCallback): number;
|
|
25
|
+
/** Cancels a frame callback of either kind (a deferred one too). */
|
|
26
|
+
caf(id: number): void;
|
|
27
|
+
/** Freeze (renews the watchdog) or thaw. */
|
|
28
|
+
set(on: boolean): void;
|
|
29
|
+
frozen(): boolean;
|
|
30
|
+
/** Called on every freeze / thaw transition (a watchdog thaw too). */
|
|
31
|
+
on(fn: (frozen: boolean) => void): () => void;
|
|
32
|
+
stats(): {
|
|
33
|
+
frozen: boolean;
|
|
34
|
+
freezes: number;
|
|
35
|
+
held: number;
|
|
36
|
+
deferred: number;
|
|
37
|
+
flushed: number;
|
|
38
|
+
watchdog: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const FRAME_FREEZE_KEY = '__maudeFrameFreeze';
|
|
43
|
+
|
|
44
|
+
export function frameFreezeApi(): FrameFreezeApi | null {
|
|
45
|
+
if (typeof window === 'undefined') return null;
|
|
46
|
+
const a = (window as unknown as Record<string, unknown>)[FRAME_FREEZE_KEY] as
|
|
47
|
+
| FrameFreezeApi
|
|
48
|
+
| undefined;
|
|
49
|
+
return a && typeof a.raf === 'function' ? a : null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** requestAnimationFrame for Maude's own code: runs on the next frame even while the gesture freeze holds. */
|
|
53
|
+
export function frameRaf(cb: FrameRequestCallback): number {
|
|
54
|
+
const a = frameFreezeApi();
|
|
55
|
+
return a ? a.raf(cb) : requestAnimationFrame(cb);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** cancelAnimationFrame for a handle from `frameRaf` (or any other). */
|
|
59
|
+
export function frameCaf(id: number): void {
|
|
60
|
+
const a = frameFreezeApi();
|
|
61
|
+
if (a) a.caf(id);
|
|
62
|
+
else cancelAnimationFrame(id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `win.requestAnimationFrame` for a window Maude's code was handed: the exempt one when it is this frame's. */
|
|
66
|
+
export function frameRafOn(win: Window, cb: FrameRequestCallback): number {
|
|
67
|
+
return typeof window !== 'undefined' && win === window
|
|
68
|
+
? frameRaf(cb)
|
|
69
|
+
: win.requestAnimationFrame(cb);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function frameCafOn(win: Window, id: number): void {
|
|
73
|
+
if (typeof window !== 'undefined' && win === window) frameCaf(id);
|
|
74
|
+
else win.cancelAnimationFrame(id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The camera is moving (renew on every input) / it stopped. */
|
|
78
|
+
export function setFrameFreeze(on: boolean): void {
|
|
79
|
+
frameFreezeApi()?.set(on);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function frameFrozen(): boolean {
|
|
83
|
+
return frameFreezeApi()?.frozen() ?? false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Freeze / thaw transitions; a no-op subscription without the shell's script. */
|
|
87
|
+
export function onFrameFreeze(fn: (frozen: boolean) => void): () => void {
|
|
88
|
+
return frameFreezeApi()?.on(fn) ?? (() => {});
|
|
89
|
+
}
|
package/apps/studio/http.ts
CHANGED
|
@@ -106,7 +106,12 @@ import { createRunRegistry, type RunRegistry } from './ai/runs.ts';
|
|
|
106
106
|
import { type Api, ASSET_CHUNK_BYTES, ASSET_MAX_BYTES, ASSET_MAX_VIDEO_BYTES } from './api.ts';
|
|
107
107
|
import { importBrandRequest } from './bin/_brand-site.mjs';
|
|
108
108
|
import { buildCanvasModule } from './canvas-build.ts';
|
|
109
|
-
import {
|
|
109
|
+
import {
|
|
110
|
+
buildCanvasSandboxed,
|
|
111
|
+
buildStats,
|
|
112
|
+
sandboxFailureClass,
|
|
113
|
+
withBuildSlot,
|
|
114
|
+
} from './canvas-build-sandbox.ts';
|
|
110
115
|
import { canvasLibPath } from './canvas-lib-resolver.ts';
|
|
111
116
|
import { budgetFromEnv, createModuleCache, moduleBytes } from './canvas-module-cache.ts';
|
|
112
117
|
import { TranspileError } from './canvas-pipeline.ts';
|
|
@@ -292,6 +297,7 @@ import {
|
|
|
292
297
|
serveFile,
|
|
293
298
|
serveIndexHtml,
|
|
294
299
|
} from './static-lane.ts';
|
|
300
|
+
import { studioPageHostRedirect } from './studio-page-host.ts';
|
|
295
301
|
import { sanitizeForLog } from './sync/cell-pairing.ts';
|
|
296
302
|
import { linkHub } from './sync/hub-link.ts';
|
|
297
303
|
import { accessFor, getHubRecord, linkRoleSource } from './sync/hubs-config.ts';
|
|
@@ -382,26 +388,28 @@ export function rootIdentity(root: string): string {
|
|
|
382
388
|
}
|
|
383
389
|
|
|
384
390
|
/**
|
|
385
|
-
* DDR-247 — the studio page's CSP. Always `frame-ancestors
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
391
|
+
* DDR-247 — the studio page's CSP. Always `frame-ancestors`, and always `frame-src 'self' <canvas
|
|
392
|
+
* origin>`: every iframe the studio creates is a canvas shell (the canvas, Compare, the design-system
|
|
393
|
+
* grid, Present, Diff), so a hostile canvas must not be able to navigate its own frame to a foreign
|
|
394
|
+
* origin — a look-alike sign-in page inside Maude or inside an embedding app, and the one way left to
|
|
395
|
+
* carry out what its code could read (localhost cookies of other local servers, canvas text), since
|
|
396
|
+
* the canvas CSP already closes every fetch/img/media sink. The sandbox has no allow-top-navigation
|
|
397
|
+
* or allow-popups, so this closes the last navigation lane (decision v2-207-studio-frame-src-always;
|
|
398
|
+
* it was embed-only before).
|
|
389
399
|
*/
|
|
390
400
|
export function studioPageCsp(
|
|
391
401
|
mainOrigin: string | undefined,
|
|
392
402
|
embedOrigins: readonly string[],
|
|
393
|
-
{
|
|
403
|
+
{ canvasOrigin }: { embed?: boolean; canvasOrigin?: string } = {}
|
|
394
404
|
): string {
|
|
395
405
|
const directives = [`frame-ancestors ${frameAncestors(mainOrigin, embedOrigins)}`];
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
/* unparseable — 'self' alone, the canvas then fails closed */
|
|
402
|
-
}
|
|
403
|
-
directives.push(`frame-src ${["'self'", canvas].filter(Boolean).join(' ')}`);
|
|
406
|
+
let canvas = '';
|
|
407
|
+
try {
|
|
408
|
+
canvas = canvasOrigin ? new URL(canvasOrigin).origin : '';
|
|
409
|
+
} catch {
|
|
410
|
+
/* unparseable — 'self' alone, the canvas then fails closed */
|
|
404
411
|
}
|
|
412
|
+
directives.push(`frame-src ${["'self'", canvas].filter(Boolean).join(' ')}`);
|
|
405
413
|
return directives.join('; ');
|
|
406
414
|
}
|
|
407
415
|
|
|
@@ -1010,16 +1018,20 @@ export async function serveCanvasTsx(
|
|
|
1010
1018
|
return respondWithCanvasModule(req, cached);
|
|
1011
1019
|
}
|
|
1012
1020
|
try {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1021
|
+
// 2.0.7 (#3) — in one of the server's build slots, like the sandbox's workers: a design system
|
|
1022
|
+
// opening asks for many builds at once, and each in-process Bun.build holds its own module graph.
|
|
1023
|
+
result = await withBuildSlot(() =>
|
|
1024
|
+
buildCanvasModule(absPath, source, {
|
|
1025
|
+
designRoot: ctx.paths.designRoot,
|
|
1026
|
+
// UNCONDITIONAL, desktop included (feature-sync-file-plane, Task 9 —
|
|
1027
|
+
// the binding debate's CONDITION on the `code-module` class): a
|
|
1028
|
+
// canvas import resolves inside the design root on EVERY runtime, so
|
|
1029
|
+
// a synced module cannot make the build read the wider filesystem.
|
|
1030
|
+
// The cell worker has always armed this (canvas-build-worker.ts).
|
|
1031
|
+
restrictImportsTo: ctx.paths.designRoot,
|
|
1032
|
+
assetUrlBase: designRootUrlBase(ctx.paths),
|
|
1033
|
+
})
|
|
1034
|
+
);
|
|
1023
1035
|
} catch (err) {
|
|
1024
1036
|
// S11.6 — the build's own error (an import, the allowlist) for `/_api/canvas-errors`;
|
|
1025
1037
|
// a syntax error is re-read from the file there, so only these need remembering.
|
|
@@ -1320,14 +1332,16 @@ async function serveHistoricalCanvas(
|
|
|
1320
1332
|
const css = await laneAtRef(versionReaders(ctx), repoRel, sha, 'css', from);
|
|
1321
1333
|
const cssSig = css == null ? todayCssSig(absPath) : null;
|
|
1322
1334
|
try {
|
|
1323
|
-
const result = await
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1335
|
+
const result = await withBuildSlot(() =>
|
|
1336
|
+
buildCanvasModule(absPath, source, {
|
|
1337
|
+
overrides: cssOverridesFor(absPath, css),
|
|
1338
|
+
designRoot: ctx.paths.designRoot,
|
|
1339
|
+
// Same unconditional allowlist as the live build above — a HISTORICAL
|
|
1340
|
+
// source is still tenant/peer-authored content.
|
|
1341
|
+
restrictImportsTo: ctx.paths.designRoot,
|
|
1342
|
+
assetUrlBase: designRootUrlBase(ctx.paths),
|
|
1343
|
+
})
|
|
1344
|
+
);
|
|
1331
1345
|
const body = moduleBytes(result.js);
|
|
1332
1346
|
cached = {
|
|
1333
1347
|
body,
|
|
@@ -3593,6 +3607,9 @@ export function createHttp(
|
|
|
3593
3607
|
Response.json(
|
|
3594
3608
|
await api.buildIndexData({
|
|
3595
3609
|
role: isWorkspaceMode() ? req.headers.get('x-maude-role') : null,
|
|
3610
|
+
fresh: new URL(req.url).searchParams.get('fresh') === '1',
|
|
3611
|
+
// #207 (list speed) — the tree loader takes the bare listing on a first open ever
|
|
3612
|
+
partial: new URL(req.url).searchParams.get('partial') === '1',
|
|
3596
3613
|
}),
|
|
3597
3614
|
{ headers: { 'Cache-Control': 'no-store' } }
|
|
3598
3615
|
),
|
|
@@ -4512,8 +4529,18 @@ export function createHttp(
|
|
|
4512
4529
|
syncFiles?: unknown;
|
|
4513
4530
|
propagateDeletes?: unknown;
|
|
4514
4531
|
resolveFirstAnchor?: unknown;
|
|
4532
|
+
addIgnoreFolder?: unknown;
|
|
4533
|
+
removeIgnoreFolder?: unknown;
|
|
4515
4534
|
}>(req, 4 * 1024);
|
|
4516
4535
|
const patch: Record<string, unknown> = {};
|
|
4536
|
+
// Issue #207 — Sync details › "Don't sync this folder" / "Sync it again": one folder at a time.
|
|
4537
|
+
for (const key of ['addIgnoreFolder', 'removeIgnoreFolder'] as const) {
|
|
4538
|
+
if (!(key in (body ?? {}))) continue;
|
|
4539
|
+
const v = body?.[key];
|
|
4540
|
+
if (typeof v !== 'string' || v.length === 0 || v.length > 1024)
|
|
4541
|
+
return new Response(`${key} must be a folder path`, { status: 400 });
|
|
4542
|
+
patch[key] = v;
|
|
4543
|
+
}
|
|
4517
4544
|
if ('syncFiles' in (body ?? {})) {
|
|
4518
4545
|
if (typeof body?.syncFiles !== 'boolean')
|
|
4519
4546
|
return new Response('syncFiles must be a boolean', { status: 400 });
|
|
@@ -7477,6 +7504,13 @@ export function createHttp(
|
|
|
7477
7504
|
}
|
|
7478
7505
|
|
|
7479
7506
|
function serveStudioPage(req: Request): Promise<Response> {
|
|
7507
|
+
// 2.0.7 — on the canvas origin's site, or WebKit strips every frame's capability (studio-page-host.ts).
|
|
7508
|
+
const sameSite = studioPageHostRedirect(req, {
|
|
7509
|
+
canvasOrigin: ctx.canvasOrigin,
|
|
7510
|
+
mainOrigin: ctx.mainOrigin,
|
|
7511
|
+
workspace: isWorkspaceMode(),
|
|
7512
|
+
});
|
|
7513
|
+
if (sameSite) return Promise.resolve(sameSite);
|
|
7480
7514
|
let embed = false;
|
|
7481
7515
|
try {
|
|
7482
7516
|
embed = new URL(req.url).searchParams.get('embed') === '1';
|
|
@@ -26,6 +26,7 @@ import { listElements } from '../canvas-edit.ts';
|
|
|
26
26
|
import { type CanvasContext, type CanvasState, checkCanvas } from '../ds/canvas-check.ts';
|
|
27
27
|
import { checkSystem, type SystemReport } from '../ds/check.ts';
|
|
28
28
|
import { type CssRule, ownDeclarations, scanCssRules, splitSelectorList } from '../ds/css-scan.ts';
|
|
29
|
+
import { isFolderSystemFile, withFolderSystems } from '../ds/folder-systems.ts';
|
|
29
30
|
import { indexRegistry, loadRegistry, type RegistryIndex } from '../ds/registry.ts';
|
|
30
31
|
import {
|
|
31
32
|
diskFs,
|
|
@@ -537,7 +538,8 @@ export function createDsUsage(o: DsUsageOptions): DsUsageIndex {
|
|
|
537
538
|
const fs = diskFs(root);
|
|
538
539
|
const next = new Map<string, SysInfo>();
|
|
539
540
|
const models = new Map<string, SystemModel>();
|
|
540
|
-
|
|
541
|
+
// 2.0.7 — the configured systems, then the folder-owned ones (ds/folder-systems.ts)
|
|
542
|
+
const cfgs = systemConfigsFrom(withFolderSystems(config, root));
|
|
541
543
|
const hash = createHash('sha256');
|
|
542
544
|
for (const cfg of cfgs) {
|
|
543
545
|
const model = loadSystem(fs, cfg);
|
|
@@ -854,6 +856,7 @@ export function createDsUsage(o: DsUsageOptions): DsUsageIndex {
|
|
|
854
856
|
// ── events ─────────────────────────────────────────────────────────────────────────────────
|
|
855
857
|
const isSystemFile = (rel: string) =>
|
|
856
858
|
rel === 'config.json' ||
|
|
859
|
+
isFolderSystemFile(rel) ||
|
|
857
860
|
(rel.startsWith('system/') &&
|
|
858
861
|
(rel.endsWith('.css') || rel.endsWith('components.json') || rel.endsWith('tokens.json')));
|
|
859
862
|
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// apps/studio/index-cache.ts — #207: the project tree answers at once, from the last build.
|
|
2
|
+
//
|
|
3
|
+
// `/_index-data` walks every canvas group, reads every canvas's sidecar and every canvas's import
|
|
4
|
+
// closure. On StudyFi (8.3k paths, 316 canvases) that took 13 s on Michal's desktop, every time —
|
|
5
|
+
// nothing was kept between requests, and the client saw "taking a while — trying again…" on a
|
|
6
|
+
// project whose files are all local.
|
|
7
|
+
//
|
|
8
|
+
// This keeps the last build and hands it out until something it depends on changes:
|
|
9
|
+
// - `invalidate()` (a file event outside the root runtime folders, an API write announcing
|
|
10
|
+
// itself) marks it out of date; the next request waits for ONE rebuild — every request in the
|
|
11
|
+
// meantime joins it (never two builds at once, never a build per retry).
|
|
12
|
+
// - A copy of the last build on disk (`seed`) answers the first request after a restart at once,
|
|
13
|
+
// marked `stale`, while the real build runs; nothing else is ever served stale. A `fresh`
|
|
14
|
+
// request waits for a real build instead.
|
|
15
|
+
//
|
|
16
|
+
// `createIndexCache` is pure (no disk, no bus); api.ts wires the build, the seed and the events.
|
|
17
|
+
// Below it: the canvas part's shape, its disk copy, and which events make it out of date.
|
|
18
|
+
|
|
19
|
+
import { randomBytes } from 'node:crypto';
|
|
20
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
|
|
23
|
+
export interface IndexCacheOptions<T> {
|
|
24
|
+
/**
|
|
25
|
+
* Compute the value from the disk (the expensive part). `early` may be called once, before the
|
|
26
|
+
* content reads, with what a `partial` request is answered with meanwhile (the bare listing). It
|
|
27
|
+
* is never kept as the value nor persisted.
|
|
28
|
+
*/
|
|
29
|
+
build: (early?: (value: T) => void) => Promise<T>;
|
|
30
|
+
/** The last value a previous run kept on disk, or null (read once, on the first request). */
|
|
31
|
+
seed?: () => T | null;
|
|
32
|
+
/** A build finished: keep a copy for the next run (called after the value is stored). */
|
|
33
|
+
persist?: (value: T) => void;
|
|
34
|
+
/** A background build failed (the seed path has no caller waiting on it). */
|
|
35
|
+
onError?: (error: unknown) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IndexCache<T> {
|
|
39
|
+
/**
|
|
40
|
+
* The current value. `stale` only for the seed of a previous run, served while the first build
|
|
41
|
+
* runs and the caller did not ask for `fresh` — or, when there is no seed either, for the listing
|
|
42
|
+
* the first build published early (`partial`), and only to a caller that asked for `partial`.
|
|
43
|
+
*/
|
|
44
|
+
get(opts?: {
|
|
45
|
+
fresh?: boolean;
|
|
46
|
+
partial?: boolean;
|
|
47
|
+
}): Promise<{ value: T; stale: boolean; partial?: true }>;
|
|
48
|
+
/** Something the value depends on changed: the next `get` rebuilds. */
|
|
49
|
+
invalidate(): void;
|
|
50
|
+
/** For tests: builds started so far, and whether one is running. */
|
|
51
|
+
stats(): { builds: number; running: boolean };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Let every request already waiting run (and an answer already made get out) before going on. */
|
|
55
|
+
export const yieldToLoop = (): Promise<void> => new Promise((resolve) => setImmediate(resolve));
|
|
56
|
+
|
|
57
|
+
/** A build is retried at most this often in a row when the tree keeps changing under it. */
|
|
58
|
+
const MAX_CHASE = 3;
|
|
59
|
+
|
|
60
|
+
export function createIndexCache<T>(o: IndexCacheOptions<T>): IndexCache<T> {
|
|
61
|
+
let gen = 0;
|
|
62
|
+
let current: { value: T; gen: number } | null = null;
|
|
63
|
+
let seeded: { value: T } | null | undefined; // undefined = not read yet
|
|
64
|
+
let running: Promise<void> | null = null;
|
|
65
|
+
// #207 — what the running build published before its content reads; cleared when it ends.
|
|
66
|
+
let early: { value: T } | null = null;
|
|
67
|
+
let earlyWaiters: Array<() => void> = [];
|
|
68
|
+
let builds = 0;
|
|
69
|
+
const wakeEarly = () => {
|
|
70
|
+
const waiting = earlyWaiters;
|
|
71
|
+
earlyWaiters = [];
|
|
72
|
+
for (const wake of waiting) wake();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
function start(): Promise<void> {
|
|
76
|
+
if (running) return running;
|
|
77
|
+
const at = gen;
|
|
78
|
+
builds++;
|
|
79
|
+
running = (async () => {
|
|
80
|
+
try {
|
|
81
|
+
const value = await o.build((v) => {
|
|
82
|
+
if (early) return;
|
|
83
|
+
early = { value: v };
|
|
84
|
+
wakeEarly();
|
|
85
|
+
});
|
|
86
|
+
// A slower build never replaces a newer one (only one runs at a time, but be exact).
|
|
87
|
+
if (!current || current.gen <= at) current = { value, gen: at };
|
|
88
|
+
try {
|
|
89
|
+
o.persist?.(value);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
o.onError?.(err);
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
running = null;
|
|
95
|
+
early = null;
|
|
96
|
+
wakeEarly();
|
|
97
|
+
}
|
|
98
|
+
})();
|
|
99
|
+
return running;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The first build's early listing; null once a whole value exists or the build ended without one. */
|
|
103
|
+
function earlyListing(): Promise<{ value: T } | null> {
|
|
104
|
+
return new Promise((resolve) => {
|
|
105
|
+
const take = () => resolve(current ? null : early);
|
|
106
|
+
if (early || !running) take();
|
|
107
|
+
else earlyWaiters.push(take);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function fresh(): Promise<T> {
|
|
112
|
+
// The tree may change while a build runs; chase it a few times, then answer with the newest
|
|
113
|
+
// build there is (what the uncached route always did: an answer from just before the change).
|
|
114
|
+
for (let round = 0; ; round++) {
|
|
115
|
+
if (current && current.gen === gen) return current.value;
|
|
116
|
+
if (current && round >= MAX_CHASE) return current.value;
|
|
117
|
+
await start();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
async get(opts = {}) {
|
|
123
|
+
if (current && current.gen === gen) return { value: current.value, stale: false };
|
|
124
|
+
if (!current && !opts.fresh) {
|
|
125
|
+
if (seeded === undefined) {
|
|
126
|
+
try {
|
|
127
|
+
const v = o.seed?.() ?? null;
|
|
128
|
+
seeded = v === null ? null : { value: v };
|
|
129
|
+
} catch {
|
|
130
|
+
seeded = null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (seeded) {
|
|
134
|
+
start().catch((err) => o.onError?.(err));
|
|
135
|
+
return { value: seeded.value, stale: true };
|
|
136
|
+
}
|
|
137
|
+
// #207 — no copy either (the first open ever): the bare listing as soon as the build has it.
|
|
138
|
+
if (opts.partial) {
|
|
139
|
+
const whole = fresh();
|
|
140
|
+
const listing = await earlyListing();
|
|
141
|
+
if (listing) {
|
|
142
|
+
whole.catch((err) => o.onError?.(err)); // the caller's next request meets a failure
|
|
143
|
+
return { value: listing.value, stale: true, partial: true };
|
|
144
|
+
}
|
|
145
|
+
return { value: await whole, stale: false };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { value: await fresh(), stale: false };
|
|
149
|
+
},
|
|
150
|
+
invalidate() {
|
|
151
|
+
gen++;
|
|
152
|
+
},
|
|
153
|
+
stats: () => ({ builds, running: running !== null }),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---------- the `/_index-data` canvas part, its disk copy, and what invalidates it ----------
|
|
158
|
+
|
|
159
|
+
/** The slow, reader-independent half of `/_index-data` (api.ts `buildCanvasIndexPart`). */
|
|
160
|
+
export interface CanvasIndexPart {
|
|
161
|
+
groups: Array<{
|
|
162
|
+
label: string;
|
|
163
|
+
paths: string[];
|
|
164
|
+
fullPath: string;
|
|
165
|
+
stripPrefix: string;
|
|
166
|
+
kind: 'project' | 'canvas' | 'runtime';
|
|
167
|
+
dsFolders?: Array<{ name: string; path: string; folder: string }>;
|
|
168
|
+
dirs?: string[];
|
|
169
|
+
}>;
|
|
170
|
+
canvasDesignSystems: Record<string, string>;
|
|
171
|
+
canvasKinds: Record<string, string>;
|
|
172
|
+
canvasImportsCanvases?: Record<string, string[]>;
|
|
173
|
+
canvasMissingImports?: Record<string, string[]>;
|
|
174
|
+
canvasDsRevs?: Record<string, string>;
|
|
175
|
+
canvasDsKept?: Record<string, string>;
|
|
176
|
+
systemHeads?: Record<string, string | null>;
|
|
177
|
+
dsConverted?: Record<string, boolean>;
|
|
178
|
+
dsRevGaps?: Record<string, string | null>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A file event the canvas part cannot depend on: anything under a ROOT runtime name — a path inside
|
|
183
|
+
* a root runtime folder (`_canvas-state/x.view.json`, `_export-jobs/…`, `_cache/…`) or a root
|
|
184
|
+
* runtime file (`_locator.json`). The part lists no `_` name (findFiles skips them; the Runtime row
|
|
185
|
+
* is listed per request), and an import walk never follows one (closure.ts refuses a `_` first
|
|
186
|
+
* segment). Those are written all the time while the studio runs — each write used to throw the
|
|
187
|
+
* whole index away.
|
|
188
|
+
*/
|
|
189
|
+
export function isRootRuntimeRel(rel: string): boolean {
|
|
190
|
+
if (typeof rel !== 'string') return false;
|
|
191
|
+
return rel.replace(/\\/g, '/').replace(/^\/+/, '').startsWith('_');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Bus events an API write raises before (or instead of) its file event: the client reloads the
|
|
196
|
+
* tree as soon as the write answers, so the cache must be out of date by then.
|
|
197
|
+
*/
|
|
198
|
+
export const CANVAS_INDEX_WRITE_EVENTS = [
|
|
199
|
+
'activity:suppress',
|
|
200
|
+
'activity:unsuppress',
|
|
201
|
+
'canvas-list-update',
|
|
202
|
+
'canvas-move-begin',
|
|
203
|
+
'canvas-created',
|
|
204
|
+
'canvas-deleted',
|
|
205
|
+
'source-writing',
|
|
206
|
+
'source-written',
|
|
207
|
+
'source-op',
|
|
208
|
+
'config-updated',
|
|
209
|
+
'access:changed',
|
|
210
|
+
'ds:outside',
|
|
211
|
+
] as const;
|
|
212
|
+
|
|
213
|
+
/** A burst of edits writes the disk copy once. */
|
|
214
|
+
export const CANVAS_INDEX_SEED_DEBOUNCE_MS = 1000;
|
|
215
|
+
|
|
216
|
+
const SEED_VERSION = 1;
|
|
217
|
+
/** A copy larger than this is not kept (a project that big pays its first build). */
|
|
218
|
+
const SEED_CAP_BYTES = 16 * 1024 * 1024;
|
|
219
|
+
|
|
220
|
+
const isStrList = (v: unknown): v is string[] =>
|
|
221
|
+
Array.isArray(v) && v.every((x) => typeof x === 'string');
|
|
222
|
+
const isStrRecord = (v: unknown): v is Record<string, string> =>
|
|
223
|
+
!!v &&
|
|
224
|
+
typeof v === 'object' &&
|
|
225
|
+
!Array.isArray(v) &&
|
|
226
|
+
Object.values(v as object).every((x) => typeof x === 'string');
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The previous run's canvas part, or null. Machine cache (`~/.maude/index/v1/projects/<pid>/`, the
|
|
230
|
+
* V2-1.17 per-project folder — outside every project tree, never synced). It is only ever served
|
|
231
|
+
* marked stale and rebuilt at once; a copy written under another config, or of the wrong shape, is
|
|
232
|
+
* not served at all.
|
|
233
|
+
*/
|
|
234
|
+
export function readCanvasIndexSeed(file: string, cfgKey: string): CanvasIndexPart | null {
|
|
235
|
+
let raw: string;
|
|
236
|
+
try {
|
|
237
|
+
raw = readFileSync(file, 'utf8');
|
|
238
|
+
} catch {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (raw.length > SEED_CAP_BYTES) return null;
|
|
242
|
+
let doc: unknown;
|
|
243
|
+
try {
|
|
244
|
+
doc = JSON.parse(raw);
|
|
245
|
+
} catch {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const d = doc as { v?: unknown; cfgKey?: unknown; part?: unknown } | null;
|
|
249
|
+
if (!d || d.v !== SEED_VERSION || d.cfgKey !== cfgKey) return null;
|
|
250
|
+
const part = d.part as CanvasIndexPart | undefined;
|
|
251
|
+
if (!part || !Array.isArray(part.groups)) return null;
|
|
252
|
+
for (const g of part.groups) {
|
|
253
|
+
if (!g || typeof g.label !== 'string' || !isStrList(g.paths)) return null;
|
|
254
|
+
if (g.dirs !== undefined && !isStrList(g.dirs)) return null;
|
|
255
|
+
}
|
|
256
|
+
if (!isStrRecord(part.canvasDesignSystems) || !isStrRecord(part.canvasKinds)) return null;
|
|
257
|
+
return part;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Atomic write (tmp → rename), 0600 in a 0700 folder; a failure only costs the next cold start. */
|
|
261
|
+
export function writeCanvasIndexSeed(file: string, part: CanvasIndexPart, cfgKey: string): void {
|
|
262
|
+
try {
|
|
263
|
+
const text = JSON.stringify({ v: SEED_VERSION, cfgKey, part });
|
|
264
|
+
if (text.length > SEED_CAP_BYTES) return;
|
|
265
|
+
mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
266
|
+
const tmp = `${file}.tmp-${process.pid}-${randomBytes(4).toString('hex')}`;
|
|
267
|
+
writeFileSync(tmp, text, { mode: 0o600 });
|
|
268
|
+
renameSync(tmp, file);
|
|
269
|
+
} catch (err) {
|
|
270
|
+
console.warn('[index-data] could not keep the tree for the next start:', err);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -17,6 +17,7 @@ import { canvasModeStore } from './bridge/canvas-mode-store.ts';
|
|
|
17
17
|
import { modeShows } from './bridge/mode-shows.ts';
|
|
18
18
|
import { useArtboardsContext } from './canvas-lib.tsx';
|
|
19
19
|
import { resolveSelectionEl, shortText } from './dom-selection.ts';
|
|
20
|
+
import { frameCaf, frameRaf } from './frame-clock.ts';
|
|
20
21
|
import { isAnnotationTool, isEditableTarget } from './input-router.tsx';
|
|
21
22
|
import { inspectsSelection, type Neighbour, neighbourOf } from './inspect-canvas.ts';
|
|
22
23
|
import { useCanvasKeys } from './use-canvas-keys.ts';
|
|
@@ -165,12 +166,12 @@ export function InspectOverlay() {
|
|
|
165
166
|
} else {
|
|
166
167
|
tag.dataset.on = 'false';
|
|
167
168
|
}
|
|
168
|
-
raf =
|
|
169
|
+
raf = frameRaf(tick);
|
|
169
170
|
};
|
|
170
|
-
raf =
|
|
171
|
+
raf = frameRaf(tick);
|
|
171
172
|
return () => {
|
|
172
173
|
alive = false;
|
|
173
|
-
if (raf != null)
|
|
174
|
+
if (raf != null) frameCaf(raf);
|
|
174
175
|
};
|
|
175
176
|
}, [one, zoom]);
|
|
176
177
|
|