@1agh/maude 2.0.4 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +289 -44
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +13 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
package/apps/studio/api.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Returns plain objects; http.ts wraps them in Response.json().
|
|
3
3
|
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
|
-
import { type Dirent, existsSync, renameSync } from 'node:fs';
|
|
5
|
+
import { type Dirent, existsSync, lstatSync, readdirSync, renameSync } from 'node:fs';
|
|
6
6
|
import {
|
|
7
7
|
lstat,
|
|
8
8
|
mkdir,
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
projectVisibility,
|
|
22
22
|
} from './access/filters.ts';
|
|
23
23
|
import { currentFrameKey } from './access/frame.ts';
|
|
24
|
+
import { refusedInputsFor } from './access/refused-inputs.ts';
|
|
24
25
|
import { currentAccess, toDesignRel } from './access/request.ts';
|
|
25
26
|
import { asPersonSave, saveHold } from './ai/save-hold.ts';
|
|
26
27
|
import { canonicalAnnotations } from './annotations/board-text.ts';
|
|
@@ -62,6 +63,9 @@ import {
|
|
|
62
63
|
type OpActor,
|
|
63
64
|
type OpResult,
|
|
64
65
|
} from './comments/ops.ts';
|
|
66
|
+
import { trashFolderDsCanvas } from './ds/convert.ts';
|
|
67
|
+
import { folderSystemOf } from './ds/ds-resolver.ts';
|
|
68
|
+
import { DS_CANVAS } from './ds/engine.ts';
|
|
65
69
|
import { readHead } from './ds/head.ts';
|
|
66
70
|
import { dsRenderIndex } from './ds/render-rev.ts';
|
|
67
71
|
import { dropPin, rekeyUserState } from './home/user-state.ts';
|
|
@@ -147,6 +151,17 @@ import {
|
|
|
147
151
|
sanitizeReuseText,
|
|
148
152
|
} from './generation/audio-library.ts';
|
|
149
153
|
import { createHistory } from './history.ts';
|
|
154
|
+
import { pidOf, projectDir } from './index/snapshot.ts';
|
|
155
|
+
import {
|
|
156
|
+
CANVAS_INDEX_SEED_DEBOUNCE_MS,
|
|
157
|
+
CANVAS_INDEX_WRITE_EVENTS,
|
|
158
|
+
type CanvasIndexPart,
|
|
159
|
+
createIndexCache,
|
|
160
|
+
isRootRuntimeRel,
|
|
161
|
+
readCanvasIndexSeed,
|
|
162
|
+
writeCanvasIndexSeed,
|
|
163
|
+
yieldToLoop,
|
|
164
|
+
} from './index-cache.ts';
|
|
150
165
|
import { createSingleFlight } from './index-flight.ts';
|
|
151
166
|
import { clearLocatorSlug, readLocator, writeLocator } from './locator.ts';
|
|
152
167
|
import { listMaterializable } from './materialize-client.ts';
|
|
@@ -322,24 +337,26 @@ export async function findFiles(
|
|
|
322
337
|
exts: string[],
|
|
323
338
|
dirsOut?: string[]
|
|
324
339
|
): Promise<string[]> {
|
|
325
|
-
const out: string[] = [];
|
|
326
340
|
let entries: Dirent[];
|
|
327
341
|
try {
|
|
328
342
|
entries = await readdir(absRoot, { withFileTypes: true });
|
|
329
343
|
} catch {
|
|
330
|
-
return
|
|
344
|
+
return [];
|
|
331
345
|
}
|
|
332
346
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
347
|
+
// 2.0.7 (#207) — a folder's files are `lstat`-ed together, not one await after another: on an
|
|
348
|
+
// 11k-file project the serial awaits alone held `/_index-data` seconds whenever the server was
|
|
349
|
+
// busy. Order is unchanged (each entry keeps its slot; folders are walked in the same order).
|
|
350
|
+
const slots: Array<string[] | Promise<string | null>> = [];
|
|
333
351
|
for (const e of entries) {
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
if (SKIP_DIRS.has(e.name)) continue;
|
|
352
|
+
const kind = findFilesEntry(e, exts);
|
|
353
|
+
if (!kind) continue;
|
|
337
354
|
const full = path.join(absRoot, e.name);
|
|
338
355
|
const rel = path.posix.join(prefix, e.name);
|
|
339
|
-
if (
|
|
356
|
+
if (kind === 'dir') {
|
|
340
357
|
dirsOut?.push(rel);
|
|
341
|
-
|
|
342
|
-
} else
|
|
358
|
+
slots.push(await findFiles(full, rel, exts, dirsOut));
|
|
359
|
+
} else {
|
|
343
360
|
// feature-studio-file-preview security review — `e.isFile()` (not just
|
|
344
361
|
// "not a directory") excludes symlinks: a symlink Dirent is neither
|
|
345
362
|
// isDirectory() nor isFile(), so without this check a symlink dropped
|
|
@@ -356,14 +373,72 @@ export async function findFiles(
|
|
|
356
373
|
// legitimately multiply-linked, so excluding them closes the same
|
|
357
374
|
// one-click-disclosure path for a hardlink planted at, say, a
|
|
358
375
|
// teammate's readable dotfile.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
376
|
+
slots.push(
|
|
377
|
+
lstat(full).then(
|
|
378
|
+
(st) => (singlyLinked(st) ? rel : null),
|
|
379
|
+
() => null
|
|
380
|
+
)
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const out: string[] = [];
|
|
385
|
+
for (const slot of slots) {
|
|
386
|
+
if (Array.isArray(slot)) {
|
|
387
|
+
for (const f of slot) out.push(f);
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const rel = await slot;
|
|
391
|
+
if (rel !== null) out.push(rel);
|
|
392
|
+
}
|
|
393
|
+
return out;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** What `findFiles` does with one directory entry: walk it, list it (after the link check), or skip it. */
|
|
397
|
+
function findFilesEntry(e: Dirent, exts: readonly string[]): 'dir' | 'file' | null {
|
|
398
|
+
if (e.name.startsWith('.') && !HIDDEN_OK.has(e.name)) return null;
|
|
399
|
+
if (e.name.startsWith('_')) return null;
|
|
400
|
+
if (SKIP_DIRS.has(e.name)) return null;
|
|
401
|
+
if (e.isDirectory()) return 'dir';
|
|
402
|
+
// `isFile()` excludes symlinks (see findFiles)
|
|
403
|
+
if (e.isFile() && exts.some((x) => e.name.toLowerCase().endsWith(x))) return 'file';
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
/** A hardlinked file (`nlink > 1`) is never listed (see findFiles). */
|
|
407
|
+
const singlyLinked = (st: { nlink: number }) => st.nlink <= 1;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* #207 (list speed) — `findFiles` in one go: the same entries, skips, link check and order, without
|
|
411
|
+
* an await per folder and per file. The tree's first answer walks this way: StudyFi's 109 folders and
|
|
412
|
+
* 1.5k files take ~20 ms, where the awaited walk gave the loop away ~1.7k times and, on a server busy
|
|
413
|
+
* right after boot, took most of a second.
|
|
414
|
+
*/
|
|
415
|
+
export function findFilesSync(
|
|
416
|
+
absRoot: string,
|
|
417
|
+
prefix: string,
|
|
418
|
+
exts: string[],
|
|
419
|
+
dirsOut?: string[]
|
|
420
|
+
): string[] {
|
|
421
|
+
let entries: Dirent[];
|
|
422
|
+
try {
|
|
423
|
+
entries = readdirSync(absRoot, { withFileTypes: true });
|
|
424
|
+
} catch {
|
|
425
|
+
return [];
|
|
426
|
+
}
|
|
427
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
428
|
+
const out: string[] = [];
|
|
429
|
+
for (const e of entries) {
|
|
430
|
+
const kind = findFilesEntry(e, exts);
|
|
431
|
+
if (!kind) continue;
|
|
432
|
+
const full = path.join(absRoot, e.name);
|
|
433
|
+
const rel = path.posix.join(prefix, e.name);
|
|
434
|
+
if (kind === 'dir') {
|
|
435
|
+
dirsOut?.push(rel);
|
|
436
|
+
for (const f of findFilesSync(full, rel, exts, dirsOut)) out.push(f);
|
|
437
|
+
continue;
|
|
366
438
|
}
|
|
439
|
+
try {
|
|
440
|
+
if (singlyLinked(lstatSync(full))) out.push(rel);
|
|
441
|
+
} catch {}
|
|
367
442
|
}
|
|
368
443
|
return out;
|
|
369
444
|
}
|
|
@@ -1037,7 +1112,13 @@ export interface Api {
|
|
|
1037
1112
|
}): Promise<ReorderRevertResult>;
|
|
1038
1113
|
// Aggregate data
|
|
1039
1114
|
/** `viewer.role` — the proxy-vouched role in a cell (`null` on a desktop). */
|
|
1040
|
-
|
|
1115
|
+
/** #207 — `fresh`: wait for a real build instead of a previous run's copy (`indexStale`).
|
|
1116
|
+
* `partial`: with no copy either, the bare listing may answer first (`indexPartial`). */
|
|
1117
|
+
buildIndexData(viewer?: {
|
|
1118
|
+
role?: string | null;
|
|
1119
|
+
fresh?: boolean;
|
|
1120
|
+
partial?: boolean;
|
|
1121
|
+
}): Promise<unknown>;
|
|
1041
1122
|
buildSystemData(dsName?: string | null): Promise<unknown>;
|
|
1042
1123
|
}
|
|
1043
1124
|
|
|
@@ -2338,6 +2419,12 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
2338
2419
|
return v === 'light' || v === 'dark' ? v : null;
|
|
2339
2420
|
}
|
|
2340
2421
|
|
|
2422
|
+
// 2.0.7 B2 — the person's Canvas | Pages pick for this canvas (canvas-pages.ts). Same class as canvasTheme:
|
|
2423
|
+
// per user, per Mac, view.json only (DDR-115); a closed set from the untrusted canvas origin.
|
|
2424
|
+
function normalizeCanvasView(v: unknown): 'canvas' | 'pages' | null {
|
|
2425
|
+
return v === 'canvas' || v === 'pages' ? v : null;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2341
2428
|
// Issue #91 security follow-up — `layout.artboards[]` (DDR-027 position-only
|
|
2342
2429
|
// entries) is reachable from the untrusted canvas origin (DDR-054) via the
|
|
2343
2430
|
// same PATCH lane as overlays/locked above, but previously had no count or
|
|
@@ -2394,6 +2481,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
2394
2481
|
overlays?: Record<string, boolean>;
|
|
2395
2482
|
locked?: string[];
|
|
2396
2483
|
canvasTheme?: 'light' | 'dark';
|
|
2484
|
+
canvasView?: 'canvas' | 'pages';
|
|
2397
2485
|
} | null> {
|
|
2398
2486
|
const viewAbs = canvasViewPath(file);
|
|
2399
2487
|
if (!viewAbs) return null;
|
|
@@ -2404,16 +2492,19 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
2404
2492
|
const ov = normalizeOverlays((obj as { overlays?: unknown }).overlays);
|
|
2405
2493
|
const lk = normalizeLocked((obj as { locked?: unknown }).locked);
|
|
2406
2494
|
const ct = normalizeCanvasTheme((obj as { canvasTheme?: unknown }).canvasTheme);
|
|
2495
|
+
const cv = normalizeCanvasView((obj as { canvasView?: unknown }).canvasView);
|
|
2407
2496
|
const result: {
|
|
2408
2497
|
viewport?: { x: number; y: number; zoom: number };
|
|
2409
2498
|
overlays?: Record<string, boolean>;
|
|
2410
2499
|
locked?: string[];
|
|
2411
2500
|
canvasTheme?: 'light' | 'dark';
|
|
2501
|
+
canvasView?: 'canvas' | 'pages';
|
|
2412
2502
|
} = {};
|
|
2413
2503
|
if (vp) result.viewport = vp;
|
|
2414
2504
|
if (ov && Object.keys(ov).length > 0) result.overlays = ov;
|
|
2415
2505
|
if (lk && lk.length > 0) result.locked = lk;
|
|
2416
2506
|
if (ct) result.canvasTheme = ct;
|
|
2507
|
+
if (cv) result.canvasView = cv;
|
|
2417
2508
|
return result;
|
|
2418
2509
|
}
|
|
2419
2510
|
return null;
|
|
@@ -2505,15 +2596,25 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
2505
2596
|
obj.locked = undefined;
|
|
2506
2597
|
// r4 #6 — `canvasTheme` (the Light | Dark pick) is the same class.
|
|
2507
2598
|
obj.canvasTheme = undefined;
|
|
2599
|
+
// 2.0.7 B2 — `canvasView` (Canvas | Pages) is the same class.
|
|
2600
|
+
obj.canvasView = undefined;
|
|
2508
2601
|
const view = await loadCanvasView(file);
|
|
2509
2602
|
if (view?.viewport) obj.viewport = view.viewport;
|
|
2510
2603
|
if (view?.overlays) obj.overlays = view.overlays;
|
|
2511
2604
|
if (view?.locked) obj.locked = view.locked;
|
|
2512
2605
|
if (view?.canvasTheme) obj.canvasTheme = view.canvasTheme;
|
|
2606
|
+
if (view?.canvasView) obj.canvasView = view.canvasView;
|
|
2513
2607
|
// Preserve the historic contract: no meta AND no camera/overlays → null
|
|
2514
2608
|
// (GET → {}, PATCH-on-rejected-path → 404). A view-only canvas still
|
|
2515
2609
|
// returns its camera/overlays.
|
|
2516
|
-
if (
|
|
2610
|
+
if (
|
|
2611
|
+
!hadMeta &&
|
|
2612
|
+
!view?.viewport &&
|
|
2613
|
+
!view?.overlays &&
|
|
2614
|
+
!view?.locked &&
|
|
2615
|
+
!view?.canvasTheme &&
|
|
2616
|
+
!view?.canvasView
|
|
2617
|
+
)
|
|
2517
2618
|
return null;
|
|
2518
2619
|
return obj;
|
|
2519
2620
|
}
|
|
@@ -2642,6 +2743,33 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
2642
2743
|
}
|
|
2643
2744
|
}
|
|
2644
2745
|
|
|
2746
|
+
// --- Per-user Canvas | Pages lane (2.0.7 B2): canvasView → view file, never the versioned meta. Same shape as
|
|
2747
|
+
// the Light | Dark lane above: REPLACE, `null` forgets the pick (back to Canvas), anything else is a no-op.
|
|
2748
|
+
if (patch.canvasView !== undefined) {
|
|
2749
|
+
const viewAbs = canvasViewPath(file);
|
|
2750
|
+
if (viewAbs) {
|
|
2751
|
+
try {
|
|
2752
|
+
const current = await readCanvasViewRaw(file);
|
|
2753
|
+
if (patch.canvasView === null) {
|
|
2754
|
+
const { canvasView: _drop, ...rest } = current;
|
|
2755
|
+
await mkdir(sessionDir(paths.canvasStateDir), { recursive: true });
|
|
2756
|
+
await Bun.write(viewAbs, `${JSON.stringify(rest, null, 2)}\n`);
|
|
2757
|
+
} else {
|
|
2758
|
+
const cv = normalizeCanvasView(patch.canvasView);
|
|
2759
|
+
if (cv !== null) {
|
|
2760
|
+
await mkdir(sessionDir(paths.canvasStateDir), { recursive: true });
|
|
2761
|
+
await Bun.write(
|
|
2762
|
+
viewAbs,
|
|
2763
|
+
`${JSON.stringify({ ...current, canvasView: cv }, null, 2)}\n`
|
|
2764
|
+
);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
} catch {
|
|
2768
|
+
/* best-effort */
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2645
2773
|
// --- Shared document lane: layout → versioned meta, stamps last_modified. ---
|
|
2646
2774
|
if (patch.layout !== undefined) {
|
|
2647
2775
|
let current: Record<string, unknown> = {};
|
|
@@ -4584,6 +4712,38 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
4584
4712
|
return { ok: false, status: 400, error: 'path escapes the design root' };
|
|
4585
4713
|
}
|
|
4586
4714
|
|
|
4715
|
+
// fix/ds-convert-hooks-cli #8 — a Design system canvas (`<system>/design-system.tsx`) whose
|
|
4716
|
+
// system is a folder (no head.json — a Restore that sync brought back) goes to the Trash the
|
|
4717
|
+
// way Restore puts one there; a converted system's canvas IS the system: Restore is the way.
|
|
4718
|
+
if (path.posix.basename(rel) === DS_CANVAS && path.posix.dirname(rel) !== '.') {
|
|
4719
|
+
const dsRel = path.posix.dirname(rel);
|
|
4720
|
+
const inSystems = cfg.canvasGroups.some(
|
|
4721
|
+
(g) =>
|
|
4722
|
+
(g.label === 'Design system' || /^system(\/|$)/.test(g.path)) &&
|
|
4723
|
+
(dsRel === g.path || dsRel.startsWith(`${g.path.replace(/\/+$/, '')}/`))
|
|
4724
|
+
);
|
|
4725
|
+
if (inSystems && (await Bun.file(fileAbs).exists())) {
|
|
4726
|
+
const t = trashFolderDsCanvas(paths.designRoot, dsRel);
|
|
4727
|
+
if (!t) {
|
|
4728
|
+
return {
|
|
4729
|
+
ok: false,
|
|
4730
|
+
status: 409,
|
|
4731
|
+
error: `this is the Design system canvas of ${path.posix.basename(dsRel)} — to turn it back into a folder, run \`maude design ds convert ${path.posix.basename(dsRel)} --restore\``,
|
|
4732
|
+
};
|
|
4733
|
+
}
|
|
4734
|
+
const slug = fileSlug(rel);
|
|
4735
|
+
ctx.bus.emit('canvas-list-update', { action: 'removed', rel, slug });
|
|
4736
|
+
ctx.bus.emit('canvas-deleted', { slug });
|
|
4737
|
+
return {
|
|
4738
|
+
ok: true,
|
|
4739
|
+
rel,
|
|
4740
|
+
slug,
|
|
4741
|
+
trashed: t.moved.map((f) => path.posix.join(dsRel, f)),
|
|
4742
|
+
trashDir: path.relative(paths.repoRoot, path.join(paths.designRoot, t.trash)),
|
|
4743
|
+
};
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4587
4747
|
// Must live under a NON-DS canvas group — never the design system (`system`),
|
|
4588
4748
|
// never a loose root file (config.json, README). Deleting DS sources is not a
|
|
4589
4749
|
// canvas operation.
|
|
@@ -7854,16 +8014,83 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7854
8014
|
// it, so a build that started before a change is never handed to a later caller.
|
|
7855
8015
|
const indexFlight = createSingleFlight<unknown>();
|
|
7856
8016
|
ctx.bus.on('fs:any', () => indexFlight.bump());
|
|
7857
|
-
|
|
8017
|
+
// #207 — on a desktop the expensive part (the canvas groups and what is derived from each
|
|
8018
|
+
// canvas) is kept between requests (index-cache.ts) and rebuilt only when something it reads
|
|
8019
|
+
// changes; a copy on disk answers the first request after a restart at once. A cell keeps the
|
|
8020
|
+
// per-request build: its listing also follows the hub's journal, which raises no file event.
|
|
8021
|
+
const canvasIndex = createIndexCache<CanvasIndexPart>({
|
|
8022
|
+
build: (early) => buildCanvasIndexPart(early),
|
|
8023
|
+
seed: () => readCanvasIndexSeed(canvasIndexSeedPath(), cfgIndexKey()),
|
|
8024
|
+
persist: (part) => scheduleCanvasIndexSeed(part),
|
|
8025
|
+
onError: (err) => console.warn('[index-data] background build failed:', err),
|
|
8026
|
+
});
|
|
8027
|
+
ctx.bus.on('fs:any', (rel: string) => {
|
|
8028
|
+
if (!isRootRuntimeRel(rel)) canvasIndex.invalidate();
|
|
8029
|
+
});
|
|
8030
|
+
// An API write announces itself before the disk event arrives, and the client reloads the tree
|
|
8031
|
+
// as soon as the write answers: the cache must already know (else it answers "fresh" from before).
|
|
8032
|
+
for (const e of CANVAS_INDEX_WRITE_EVENTS) ctx.bus.on(e, () => canvasIndex.invalidate());
|
|
8033
|
+
let seedTimer: ReturnType<typeof setTimeout> | null = null;
|
|
8034
|
+
let seedPending: CanvasIndexPart | null = null;
|
|
8035
|
+
function scheduleCanvasIndexSeed(part: CanvasIndexPart) {
|
|
8036
|
+
seedPending = part;
|
|
8037
|
+
if (seedTimer) return;
|
|
8038
|
+
seedTimer = setTimeout(() => {
|
|
8039
|
+
seedTimer = null;
|
|
8040
|
+
const p = seedPending;
|
|
8041
|
+
seedPending = null;
|
|
8042
|
+
if (p) writeCanvasIndexSeed(canvasIndexSeedPath(), p, cfgIndexKey());
|
|
8043
|
+
}, CANVAS_INDEX_SEED_DEBOUNCE_MS);
|
|
8044
|
+
(seedTimer as { unref?: () => void }).unref?.();
|
|
8045
|
+
}
|
|
8046
|
+
function canvasIndexSeedPath() {
|
|
8047
|
+
return path.join(projectDir(pidOf(paths.repoRoot)), 'tree.json');
|
|
8048
|
+
}
|
|
8049
|
+
/** What the cached part was built under: a config reload with other groups/systems is a miss. */
|
|
8050
|
+
function cfgIndexKey() {
|
|
8051
|
+
return JSON.stringify([
|
|
8052
|
+
paths.designRel,
|
|
8053
|
+
cfg.canvasGroups,
|
|
8054
|
+
cfg.designSystems ?? [],
|
|
8055
|
+
cfg.defaultDesignSystem ?? null,
|
|
8056
|
+
]);
|
|
8057
|
+
}
|
|
8058
|
+
let cachedCfgKey = '';
|
|
8059
|
+
|
|
8060
|
+
function buildIndexData(viewer?: { role?: string | null; fresh?: boolean; partial?: boolean }) {
|
|
7858
8061
|
// A canvas-only session's answer is filtered by its own grants: never shared.
|
|
7859
8062
|
if (!projectVisibility(ctx).current().full) return buildIndexDataNow(viewer);
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
8063
|
+
if (isWorkspaceMode())
|
|
8064
|
+
return indexFlight.run(`${viewer?.role ?? ''}|${currentSession()}`, () =>
|
|
8065
|
+
buildIndexDataNow(viewer)
|
|
8066
|
+
);
|
|
8067
|
+
const key = cfgIndexKey();
|
|
8068
|
+
if (key !== cachedCfgKey) {
|
|
8069
|
+
cachedCfgKey = key;
|
|
8070
|
+
canvasIndex.invalidate();
|
|
8071
|
+
}
|
|
8072
|
+
// Only the route (which always passes a viewer) may be answered from a previous run's copy; an
|
|
8073
|
+
// internal caller (S11.4 availability: "what is on this Mac") always waits for a real build.
|
|
8074
|
+
// #207 (list speed) — the tree loader asks `partial`: on the first open ever (no copy) it is
|
|
8075
|
+
// answered with the bare listing the build publishes before any content read.
|
|
8076
|
+
return canvasIndex
|
|
8077
|
+
.get({ fresh: viewer === undefined || viewer.fresh === true, partial: viewer?.partial })
|
|
8078
|
+
.then(({ value, stale, partial }) => assembleIndexData(value, viewer, stale, partial));
|
|
7863
8079
|
}
|
|
7864
8080
|
|
|
7865
8081
|
async function buildIndexDataNow(viewer?: { role?: string | null }) {
|
|
7866
|
-
|
|
8082
|
+
return assembleIndexData(await buildCanvasIndexPart(), viewer, false);
|
|
8083
|
+
}
|
|
8084
|
+
|
|
8085
|
+
/**
|
|
8086
|
+
* The canvas groups and everything derived per canvas — the slow, reader-independent part.
|
|
8087
|
+
* `early` gets the bare listing first: the groups as one walk of names (no file is read), with
|
|
8088
|
+
* nothing derived — no design system, kind, revision or import report.
|
|
8089
|
+
*/
|
|
8090
|
+
async function buildCanvasIndexPart(
|
|
8091
|
+
early?: (listing: CanvasIndexPart) => void
|
|
8092
|
+
): Promise<CanvasIndexPart> {
|
|
8093
|
+
const groups: CanvasIndexPart['groups'] = [];
|
|
7867
8094
|
|
|
7868
8095
|
// DDR-093 — per-canvas design-system map (repo-relative canvas path → DS
|
|
7869
8096
|
// name) so the client's canvasUrl() injects each UI canvas's OWN tokens
|
|
@@ -7872,11 +8099,13 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7872
8099
|
const canvasDesignSystems: Record<string, string> = {};
|
|
7873
8100
|
// S10.4 (V2-1.6 §5.8) — the revision a canvas was left on (`dsRev`), for the converted systems only:
|
|
7874
8101
|
// an unconverted project builds none of this, and its payload is what it always was.
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
.
|
|
7879
|
-
|
|
8102
|
+
// (read after the listing is out: a system's head is a content read)
|
|
8103
|
+
const readConvertedDs = () =>
|
|
8104
|
+
new Set(
|
|
8105
|
+
(cfg.designSystems ?? [])
|
|
8106
|
+
.filter((d) => readHead(path.join(paths.designRoot, d.path)).state === 'ok')
|
|
8107
|
+
.map((d) => d.name)
|
|
8108
|
+
);
|
|
7880
8109
|
const canvasRevs: Record<string, { system: string; dsRev: string; kept?: string }> = {};
|
|
7881
8110
|
// DDR-174 (T15) — surface a canvas's `.meta.json` `kind` in the file tree
|
|
7882
8111
|
// when it's a value the user should notice at a glance (today: only
|
|
@@ -7905,36 +8134,16 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7905
8134
|
const owner = (cfg.designSystems ?? []).find(
|
|
7906
8135
|
(d) => d.path === `system/${folder}` || d.path.endsWith(`/${folder}`)
|
|
7907
8136
|
);
|
|
7908
|
-
|
|
8137
|
+
// 2.0.7 — a system folder the config does not list owns its own files too (folderSystemOf).
|
|
8138
|
+
return (
|
|
8139
|
+
owner?.name ??
|
|
8140
|
+
folderSystemOf(r, cfg.designSystems ?? [], (f) =>
|
|
8141
|
+
existsSync(path.join(paths.designRoot, ...f.split('/')))
|
|
8142
|
+
)?.name ??
|
|
8143
|
+
null
|
|
8144
|
+
);
|
|
7909
8145
|
};
|
|
7910
8146
|
|
|
7911
|
-
// PROJECT — top-level .design/ files (README.md, INDEX.md, config.json, …).
|
|
7912
|
-
// These are non-HTML so they're listed but not openable in the iframe; the
|
|
7913
|
-
// sidebar can still display them as context (mirrors CV-08 mock).
|
|
7914
|
-
const projectFiles: string[] = [];
|
|
7915
|
-
try {
|
|
7916
|
-
const entries = await readdir(paths.designRoot, { withFileTypes: true });
|
|
7917
|
-
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
7918
|
-
for (const e of entries) {
|
|
7919
|
-
if (!e.isFile()) continue;
|
|
7920
|
-
if (e.name.startsWith('_')) continue;
|
|
7921
|
-
if (e.name.startsWith('.')) continue;
|
|
7922
|
-
if (!/\.(md|json|txt|yml|yaml|css)$/i.test(e.name)) continue;
|
|
7923
|
-
projectFiles.push(path.posix.join(paths.designRel, e.name));
|
|
7924
|
-
}
|
|
7925
|
-
} catch {}
|
|
7926
|
-
if (projectFiles.length) {
|
|
7927
|
-
groups.push({
|
|
7928
|
-
label: 'Project',
|
|
7929
|
-
paths: projectFiles,
|
|
7930
|
-
fullPath: paths.designRel,
|
|
7931
|
-
// Strip `.design/` — the section header already names the parent;
|
|
7932
|
-
// the chain `▾ .design → file` was redundant.
|
|
7933
|
-
stripPrefix: `${paths.designRel}/`,
|
|
7934
|
-
kind: 'project' as const,
|
|
7935
|
-
});
|
|
7936
|
-
}
|
|
7937
|
-
|
|
7938
8147
|
// Canvas groups — strip just `.design/` so the immediate subdir
|
|
7939
8148
|
// (`system`, `ui`, …) shows up as a dir wrapper in the tree (mirrors
|
|
7940
8149
|
// CV-08's `▾ ui` / `▾ system/project` headers).
|
|
@@ -7945,6 +8154,9 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7945
8154
|
// (FileRow non-HTML branch).
|
|
7946
8155
|
// Cell materializer — the media the hub can serve although this checkout
|
|
7947
8156
|
// does not hold it. `null` everywhere else (desktop, self-hosted hub).
|
|
8157
|
+
// #207 (list speed) — an answer already made (a previous run's copy handed out by the request that
|
|
8158
|
+
// started this build) gets out before the walk below takes the loop.
|
|
8159
|
+
await yieldToLoop();
|
|
7948
8160
|
const materializable = await listMaterializable();
|
|
7949
8161
|
for (const g of cfg.canvasGroups) {
|
|
7950
8162
|
const groupAbs = path.join(paths.designRoot, g.path);
|
|
@@ -7965,7 +8177,8 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7965
8177
|
const groupExts = isDs
|
|
7966
8178
|
? ['.tsx', '.html', '.md', '.css', '.json', ...PREVIEW_ASSET_EXTS]
|
|
7967
8179
|
: ['.tsx', '.html', '.css', '.json', ...PREVIEW_ASSET_EXTS];
|
|
7968
|
-
|
|
8180
|
+
// #207 (list speed) — one walk of names that never gives the loop away (findFilesSync).
|
|
8181
|
+
const filePaths = findFilesSync(groupAbs, groupRel, groupExts, dirs);
|
|
7969
8182
|
// A materializing cell lists media its checkout does not hold.
|
|
7970
8183
|
if (materializable) {
|
|
7971
8184
|
mergeMaterializable(filePaths, dirs, materializable, {
|
|
@@ -7974,36 +8187,6 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7974
8187
|
exts: PREVIEW_ASSET_EXTS,
|
|
7975
8188
|
});
|
|
7976
8189
|
}
|
|
7977
|
-
// DDR-093 — record each `.tsx` canvas's design system. canvasUrl() only
|
|
7978
|
-
// injects tokens for `.tsx`, so skip everything else. Path-owned DS wins
|
|
7979
|
-
// (system/<ds>/…); otherwise the sidecar's `meta.designSystem`, defaulting
|
|
7980
|
-
// to the project default when the canvas declares none.
|
|
7981
|
-
for (const fp of filePaths) {
|
|
7982
|
-
if (!fp.endsWith('.tsx')) continue;
|
|
7983
|
-
let dsName = ownerDsName(fp);
|
|
7984
|
-
let meta: Record<string, unknown> | null = null;
|
|
7985
|
-
if (!dsName) {
|
|
7986
|
-
meta = await loadCanvasMeta(fp);
|
|
7987
|
-
const declared = meta?.designSystem;
|
|
7988
|
-
dsName = typeof declared === 'string' && declared.trim() ? declared : defaultDs;
|
|
7989
|
-
const kind = meta?.kind;
|
|
7990
|
-
if (typeof kind === 'string' && NOTABLE_KINDS.has(kind)) canvasKinds[fp] = kind;
|
|
7991
|
-
}
|
|
7992
|
-
canvasDesignSystems[fp] = dsName;
|
|
7993
|
-
if (convertedDs.has(dsName)) {
|
|
7994
|
-
// a canvas inside the system's own folder carries no sidecar read above
|
|
7995
|
-
meta ??= await loadCanvasMeta(fp);
|
|
7996
|
-
const dsRev = meta?.dsRev;
|
|
7997
|
-
// p8-dead-reasons — `dsKept`: the head a person declined with "Keep this version" (the card stays away)
|
|
7998
|
-
const kept = meta?.dsKept;
|
|
7999
|
-
if (typeof dsRev === 'string' && dsRev)
|
|
8000
|
-
canvasRevs[fp] = {
|
|
8001
|
-
system: dsName,
|
|
8002
|
-
dsRev,
|
|
8003
|
-
...(typeof kept === 'string' && kept ? { kept } : {}),
|
|
8004
|
-
};
|
|
8005
|
-
}
|
|
8006
|
-
}
|
|
8007
8190
|
// Strip down to `g.path` so per-DS folders (`project`, `beta`, …) show
|
|
8008
8191
|
// up as the top-level dirs inside the DS section. Single-DS configs get
|
|
8009
8192
|
// a wrapper folder too — slightly more verbose, but consistent with
|
|
@@ -8036,6 +8219,142 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8036
8219
|
});
|
|
8037
8220
|
}
|
|
8038
8221
|
|
|
8222
|
+
// #207 (list speed) — the bare listing goes out now (the tree loader on a first open ever draws it),
|
|
8223
|
+
// and the answer it belongs to gets out before the content reads below take the loop.
|
|
8224
|
+
if (early) {
|
|
8225
|
+
early({ groups: [...groups], canvasDesignSystems: {}, canvasKinds: {} });
|
|
8226
|
+
await yieldToLoop();
|
|
8227
|
+
}
|
|
8228
|
+
// tests only: hold the content reads until a file exists (the listing-first test proves the order)
|
|
8229
|
+
const gate = process.env.MAUDE_TEST_INDEX_DETAILS_GATE;
|
|
8230
|
+
while (gate && !existsSync(gate)) await new Promise((r) => setTimeout(r, 20));
|
|
8231
|
+
|
|
8232
|
+
// DDR-093 — record each `.tsx` canvas's design system. canvasUrl() only
|
|
8233
|
+
// injects tokens for `.tsx`, so skip everything else. Path-owned DS wins
|
|
8234
|
+
// (system/<ds>/…); otherwise the sidecar's `meta.designSystem`, defaulting
|
|
8235
|
+
// to the project default when the canvas declares none.
|
|
8236
|
+
const convertedDs = readConvertedDs();
|
|
8237
|
+
for (const g of groups) {
|
|
8238
|
+
for (const fp of g.paths) {
|
|
8239
|
+
if (!fp.endsWith('.tsx')) continue;
|
|
8240
|
+
let dsName = ownerDsName(fp);
|
|
8241
|
+
let meta: Record<string, unknown> | null = null;
|
|
8242
|
+
if (!dsName) {
|
|
8243
|
+
meta = await loadCanvasMeta(fp);
|
|
8244
|
+
const declared = meta?.designSystem;
|
|
8245
|
+
dsName = typeof declared === 'string' && declared.trim() ? declared : defaultDs;
|
|
8246
|
+
const kind = meta?.kind;
|
|
8247
|
+
if (typeof kind === 'string' && NOTABLE_KINDS.has(kind)) canvasKinds[fp] = kind;
|
|
8248
|
+
}
|
|
8249
|
+
canvasDesignSystems[fp] = dsName;
|
|
8250
|
+
if (convertedDs.has(dsName)) {
|
|
8251
|
+
// a canvas inside the system's own folder carries no sidecar read above
|
|
8252
|
+
meta ??= await loadCanvasMeta(fp);
|
|
8253
|
+
const dsRev = meta?.dsRev;
|
|
8254
|
+
// p8-dead-reasons — `dsKept`: the head a person declined with "Keep this version" (the card stays away)
|
|
8255
|
+
const kept = meta?.dsKept;
|
|
8256
|
+
if (typeof dsRev === 'string' && dsRev)
|
|
8257
|
+
canvasRevs[fp] = {
|
|
8258
|
+
system: dsName,
|
|
8259
|
+
dsRev,
|
|
8260
|
+
...(typeof kept === 'string' && kept ? { kept } : {}),
|
|
8261
|
+
};
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
|
|
8266
|
+
// S10.4 — which revision each canvas renders. Present only once a system is converted: a project that
|
|
8267
|
+
// has none gets the payload it always had.
|
|
8268
|
+
const dsRender =
|
|
8269
|
+
convertedDs.size > 0
|
|
8270
|
+
? dsRenderIndex(paths.designRoot, cfg.designSystems ?? [], canvasRevs)
|
|
8271
|
+
: null;
|
|
8272
|
+
|
|
8273
|
+
// gate-b-c4j — a canvas importing another canvas does not render in its frame (access/closure.ts
|
|
8274
|
+
// `walkImports`: the module is refused); the shell says why on it. The same for every reader;
|
|
8275
|
+
// filterIndexData below holds both sides to what this reader sees.
|
|
8276
|
+
const prefix = `${paths.designRel}/`;
|
|
8277
|
+
const canvasRels = Object.keys(canvasDesignSystems)
|
|
8278
|
+
.filter((fp) => fp.startsWith(prefix))
|
|
8279
|
+
.map((fp) => fp.slice(prefix.length))
|
|
8280
|
+
.sort();
|
|
8281
|
+
const imports = projectVisibility(ctx).canvasImports(canvasRels);
|
|
8282
|
+
const canvasImportsCanvases: Record<string, string[]> = {};
|
|
8283
|
+
for (const [rel, list] of imports) canvasImportsCanvases[`${prefix}${rel}`] = list;
|
|
8284
|
+
// 2.0.7 — an import that resolves to no file blocks the canvas the same way (its frame answers 403
|
|
8285
|
+
// before any build could name the file): the shell names the missing file on the card.
|
|
8286
|
+
const missing = projectVisibility(ctx).canvasMissingImports?.(canvasRels) ?? new Map();
|
|
8287
|
+
const canvasMissingImports: Record<string, string[]> = {};
|
|
8288
|
+
for (const [rel, list] of missing) canvasMissingImports[`${prefix}${rel}`] = list;
|
|
8289
|
+
return {
|
|
8290
|
+
groups,
|
|
8291
|
+
canvasDesignSystems,
|
|
8292
|
+
canvasKinds,
|
|
8293
|
+
...(imports.size ? { canvasImportsCanvases } : {}),
|
|
8294
|
+
...(missing.size ? { canvasMissingImports } : {}),
|
|
8295
|
+
...(dsRender
|
|
8296
|
+
? {
|
|
8297
|
+
canvasDsRevs: Object.fromEntries(
|
|
8298
|
+
Object.entries(canvasRevs).map(([fp, r]) => [fp, r.dsRev])
|
|
8299
|
+
),
|
|
8300
|
+
canvasDsKept: Object.fromEntries(
|
|
8301
|
+
Object.entries(canvasRevs)
|
|
8302
|
+
.filter(([, r]) => r.kept)
|
|
8303
|
+
.map(([fp, r]) => [fp, r.kept as string])
|
|
8304
|
+
),
|
|
8305
|
+
systemHeads: dsRender.systemHeads,
|
|
8306
|
+
dsConverted: dsRender.dsConverted,
|
|
8307
|
+
dsRevGaps: dsRender.dsRevGaps,
|
|
8308
|
+
}
|
|
8309
|
+
: {}),
|
|
8310
|
+
};
|
|
8311
|
+
}
|
|
8312
|
+
|
|
8313
|
+
/**
|
|
8314
|
+
* #207 — the payload for one request: the (cached) canvas part plus what is cheap and per request —
|
|
8315
|
+
* the Project and Runtime rows (one root listing each; the Runtime row depends on the reader), the
|
|
8316
|
+
* refused-inputs report the http layer keeps in memory, and the reader's filter.
|
|
8317
|
+
*/
|
|
8318
|
+
async function assembleIndexData(
|
|
8319
|
+
part: CanvasIndexPart,
|
|
8320
|
+
viewer: { role?: string | null } | undefined,
|
|
8321
|
+
stale: boolean,
|
|
8322
|
+
partial?: boolean
|
|
8323
|
+
) {
|
|
8324
|
+
const head: CanvasIndexPart['groups'] = [];
|
|
8325
|
+
const tail: CanvasIndexPart['groups'] = [];
|
|
8326
|
+
// #207 (list speed) — ONE listing of the design root, read in this tick: an answer from the cache
|
|
8327
|
+
// (a copy, the bare listing) is then made at once, never after a build's next slice of work.
|
|
8328
|
+
let rootEntries: Dirent[] = [];
|
|
8329
|
+
try {
|
|
8330
|
+
rootEntries = readdirSync(paths.designRoot, { withFileTypes: true });
|
|
8331
|
+
rootEntries.sort((a, b) => a.name.localeCompare(b.name));
|
|
8332
|
+
} catch {}
|
|
8333
|
+
// PROJECT — top-level .design/ files (README.md, INDEX.md, config.json, …).
|
|
8334
|
+
// These are non-HTML so they're listed but not openable in the iframe; the
|
|
8335
|
+
// sidebar can still display them as context (mirrors CV-08 mock).
|
|
8336
|
+
const projectFiles: string[] = [];
|
|
8337
|
+
{
|
|
8338
|
+
for (const e of rootEntries) {
|
|
8339
|
+
if (!e.isFile()) continue;
|
|
8340
|
+
if (e.name.startsWith('_')) continue;
|
|
8341
|
+
if (e.name.startsWith('.')) continue;
|
|
8342
|
+
if (!/\.(md|json|txt|yml|yaml|css)$/i.test(e.name)) continue;
|
|
8343
|
+
projectFiles.push(path.posix.join(paths.designRel, e.name));
|
|
8344
|
+
}
|
|
8345
|
+
}
|
|
8346
|
+
if (projectFiles.length) {
|
|
8347
|
+
head.push({
|
|
8348
|
+
label: 'Project',
|
|
8349
|
+
paths: projectFiles,
|
|
8350
|
+
fullPath: paths.designRel,
|
|
8351
|
+
// Strip `.design/` — the section header already names the parent;
|
|
8352
|
+
// the chain `▾ .design → file` was redundant.
|
|
8353
|
+
stripPrefix: `${paths.designRel}/`,
|
|
8354
|
+
kind: 'project' as const,
|
|
8355
|
+
});
|
|
8356
|
+
}
|
|
8357
|
+
|
|
8039
8358
|
// RUNTIME — gitignored state files (_active.json, _server.json) +
|
|
8040
8359
|
// pointers to _history/ and _comments/ dirs. Visible but inert in the
|
|
8041
8360
|
// sidebar; matches the CV-08 mock's bottom section.
|
|
@@ -8049,9 +8368,8 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8049
8368
|
const showRuntime = !workspace || viewer?.role === 'owner';
|
|
8050
8369
|
const mySession = currentSession();
|
|
8051
8370
|
const runtimeFiles: string[] = [];
|
|
8052
|
-
|
|
8053
|
-
const entries = showRuntime ?
|
|
8054
|
-
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
8371
|
+
{
|
|
8372
|
+
const entries = showRuntime ? rootEntries : [];
|
|
8055
8373
|
for (const e of entries) {
|
|
8056
8374
|
if (!e.name.startsWith('_')) continue;
|
|
8057
8375
|
if (workspace) {
|
|
@@ -8061,9 +8379,9 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8061
8379
|
}
|
|
8062
8380
|
runtimeFiles.push(path.posix.join(paths.designRel, e.name));
|
|
8063
8381
|
}
|
|
8064
|
-
}
|
|
8382
|
+
}
|
|
8065
8383
|
if (runtimeFiles.length) {
|
|
8066
|
-
|
|
8384
|
+
tail.push({
|
|
8067
8385
|
label: 'Runtime',
|
|
8068
8386
|
paths: runtimeFiles,
|
|
8069
8387
|
fullPath: paths.designRel,
|
|
@@ -8074,24 +8392,14 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8074
8392
|
});
|
|
8075
8393
|
}
|
|
8076
8394
|
|
|
8077
|
-
// S10.4 — which revision each canvas renders. Present only once a system is converted: a project that
|
|
8078
|
-
// has none gets the payload it always had.
|
|
8079
|
-
const dsRender =
|
|
8080
|
-
convertedDs.size > 0
|
|
8081
|
-
? dsRenderIndex(paths.designRoot, cfg.designSystems ?? [], canvasRevs)
|
|
8082
|
-
: null;
|
|
8083
|
-
|
|
8084
|
-
// gate-b-c4j — a canvas importing another canvas does not render in its frame (access/closure.ts
|
|
8085
|
-
// `walkImports`: the module is refused); the shell says why on it. The same for every reader;
|
|
8086
|
-
// filterIndexData below holds both sides to what this reader sees.
|
|
8087
8395
|
const prefix = `${paths.designRel}/`;
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
const
|
|
8093
|
-
const
|
|
8094
|
-
|
|
8396
|
+
// 2.0.5 (#205) — a canvas whose BUILT module the inputs gate refused (it inlined a file another canvas
|
|
8397
|
+
// owns): the files, kept per canvas by the http layer (access/refused-inputs.ts). Main origin only — the
|
|
8398
|
+
// canvas origin's 403 stays the bare not-in-scope body.
|
|
8399
|
+
const refused = refusedInputsFor(ctx).report();
|
|
8400
|
+
const canvasRefusedInputs: Record<string, string[]> = {};
|
|
8401
|
+
for (const [rel, list] of refused) canvasRefusedInputs[`${prefix}${rel}`] = list;
|
|
8402
|
+
const { groups, ...derived } = part;
|
|
8095
8403
|
|
|
8096
8404
|
// S9.10 (V2-1.16 L8) — a canvas-only session's tree: what it sees, nothing else.
|
|
8097
8405
|
return filterIndexData(
|
|
@@ -8099,25 +8407,14 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8099
8407
|
project: cfg.name,
|
|
8100
8408
|
projectLabel: ctx.projectLabel,
|
|
8101
8409
|
designRoot: paths.designRel,
|
|
8102
|
-
groups,
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
...(
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
),
|
|
8111
|
-
canvasDsKept: Object.fromEntries(
|
|
8112
|
-
Object.entries(canvasRevs)
|
|
8113
|
-
.filter(([, r]) => r.kept)
|
|
8114
|
-
.map(([fp, r]) => [fp, r.kept as string])
|
|
8115
|
-
),
|
|
8116
|
-
systemHeads: dsRender.systemHeads,
|
|
8117
|
-
dsConverted: dsRender.dsConverted,
|
|
8118
|
-
dsRevGaps: dsRender.dsRevGaps,
|
|
8119
|
-
}
|
|
8120
|
-
: {}),
|
|
8410
|
+
groups: [...head, ...groups, ...tail],
|
|
8411
|
+
...derived,
|
|
8412
|
+
...(refused.size ? { canvasRefusedInputs } : {}),
|
|
8413
|
+
// #207 — a previous run's copy, answered while the first build runs; the client asks again.
|
|
8414
|
+
...(stale ? { indexStale: true } : {}),
|
|
8415
|
+
// #207 (list speed) — the bare listing: no canvas has its design system, kind or import
|
|
8416
|
+
// report yet (and nothing is granted by it); the client draws the tree and asks again.
|
|
8417
|
+
...(partial ? { indexPartial: true } : {}),
|
|
8121
8418
|
},
|
|
8122
8419
|
projectVisibility(ctx).current(),
|
|
8123
8420
|
paths.designRel,
|