@1agh/maude 2.0.3 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/filters.ts +12 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +10 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +25 -1
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-layer.tsx +0 -12
- package/apps/studio/api.ts +73 -24
- package/apps/studio/artboard-live-gate.tsx +267 -0
- package/apps/studio/artboard-live.ts +336 -0
- package/apps/studio/artboard-webgl.ts +668 -0
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- 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 +93 -13
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +11 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-lib.tsx +131 -12
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/canvas-url.js +13 -0
- package/apps/studio/client/github.js +23 -3
- 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 +36 -19
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-project-data.jsx +2 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +49 -57
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +45 -8
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- 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/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
- 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 -12
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- 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 +21 -5
- package/apps/studio/client/v2/history/git-parts.jsx +76 -43
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +12 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- 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/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -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-activity.js +19 -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-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/config-reload-wire.ts +53 -0
- package/apps/studio/dist/client.bundle.js +1098 -1102
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/specimen.tsx +12 -1
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +7 -3
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +4 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +66 -8
- package/apps/studio/http.ts +131 -68
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +19 -1
- package/apps/studio/server.ts +19 -10
- package/apps/studio/sync/accepted-cold-start.ts +54 -16
- package/apps/studio/sync/accepted-link.ts +9 -4
- 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 +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +483 -86
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +381 -161
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +121 -14
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +58 -3
- package/apps/studio/sync/status.ts +3 -1
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/video-comp.tsx +23 -0
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +126 -0
- package/cli/lib/bash-guard.mjs +13 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
package/apps/studio/api.ts
CHANGED
|
@@ -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';
|
|
@@ -38,6 +39,7 @@ import { type BoardGuard, voteDoorOnly } from './annotations/vote-guard.ts';
|
|
|
38
39
|
import { createAssetMirror, s3ConfigFromEnv } from './assets-s3.ts';
|
|
39
40
|
import { canvasArtifacts, locatorKeyFor, relocatedName } from './canvas-artifacts.ts';
|
|
40
41
|
import {
|
|
42
|
+
FOLDER_WORDS,
|
|
41
43
|
foldToAllowedName,
|
|
42
44
|
nameFromPrompt,
|
|
43
45
|
nextFreeCanvasName,
|
|
@@ -61,6 +63,8 @@ import {
|
|
|
61
63
|
type OpActor,
|
|
62
64
|
type OpResult,
|
|
63
65
|
} from './comments/ops.ts';
|
|
66
|
+
import { trashFolderDsCanvas } from './ds/convert.ts';
|
|
67
|
+
import { DS_CANVAS } from './ds/engine.ts';
|
|
64
68
|
import { readHead } from './ds/head.ts';
|
|
65
69
|
import { dsRenderIndex } from './ds/render-rev.ts';
|
|
66
70
|
import { dropPin, rekeyUserState } from './home/user-state.ts';
|
|
@@ -146,6 +150,7 @@ import {
|
|
|
146
150
|
sanitizeReuseText,
|
|
147
151
|
} from './generation/audio-library.ts';
|
|
148
152
|
import { createHistory } from './history.ts';
|
|
153
|
+
import { createSingleFlight } from './index-flight.ts';
|
|
149
154
|
import { clearLocatorSlug, readLocator, writeLocator } from './locator.ts';
|
|
150
155
|
import { listMaterializable } from './materialize-client.ts';
|
|
151
156
|
import { resolveUrlPathUnder } from './path-containment.ts';
|
|
@@ -4582,6 +4587,38 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
4582
4587
|
return { ok: false, status: 400, error: 'path escapes the design root' };
|
|
4583
4588
|
}
|
|
4584
4589
|
|
|
4590
|
+
// fix/ds-convert-hooks-cli #8 — a Design system canvas (`<system>/design-system.tsx`) whose
|
|
4591
|
+
// system is a folder (no head.json — a Restore that sync brought back) goes to the Trash the
|
|
4592
|
+
// way Restore puts one there; a converted system's canvas IS the system: Restore is the way.
|
|
4593
|
+
if (path.posix.basename(rel) === DS_CANVAS && path.posix.dirname(rel) !== '.') {
|
|
4594
|
+
const dsRel = path.posix.dirname(rel);
|
|
4595
|
+
const inSystems = cfg.canvasGroups.some(
|
|
4596
|
+
(g) =>
|
|
4597
|
+
(g.label === 'Design system' || /^system(\/|$)/.test(g.path)) &&
|
|
4598
|
+
(dsRel === g.path || dsRel.startsWith(`${g.path.replace(/\/+$/, '')}/`))
|
|
4599
|
+
);
|
|
4600
|
+
if (inSystems && (await Bun.file(fileAbs).exists())) {
|
|
4601
|
+
const t = trashFolderDsCanvas(paths.designRoot, dsRel);
|
|
4602
|
+
if (!t) {
|
|
4603
|
+
return {
|
|
4604
|
+
ok: false,
|
|
4605
|
+
status: 409,
|
|
4606
|
+
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\``,
|
|
4607
|
+
};
|
|
4608
|
+
}
|
|
4609
|
+
const slug = fileSlug(rel);
|
|
4610
|
+
ctx.bus.emit('canvas-list-update', { action: 'removed', rel, slug });
|
|
4611
|
+
ctx.bus.emit('canvas-deleted', { slug });
|
|
4612
|
+
return {
|
|
4613
|
+
ok: true,
|
|
4614
|
+
rel,
|
|
4615
|
+
slug,
|
|
4616
|
+
trashed: t.moved.map((f) => path.posix.join(dsRel, f)),
|
|
4617
|
+
trashDir: path.relative(paths.repoRoot, path.join(paths.designRoot, t.trash)),
|
|
4618
|
+
};
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4585
4622
|
// Must live under a NON-DS canvas group — never the design system (`system`),
|
|
4586
4623
|
// never a loose root file (config.json, README). Deleting DS sources is not a
|
|
4587
4624
|
// canvas operation.
|
|
@@ -5388,14 +5425,10 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5388
5425
|
return abs === gAbs || abs.startsWith(`${gAbs}${path.sep}`);
|
|
5389
5426
|
});
|
|
5390
5427
|
if (!withinAGroup(resolvedDir)) {
|
|
5391
|
-
return {
|
|
5392
|
-
ok: false,
|
|
5393
|
-
status: 400,
|
|
5394
|
-
error: 'only folders under a managed canvas group can be moved',
|
|
5395
|
-
};
|
|
5428
|
+
return { ok: false, status: 400, error: FOLDER_WORDS.notHere };
|
|
5396
5429
|
}
|
|
5397
5430
|
if (deletable.some((g) => path.resolve(path.join(paths.designRoot, g.path)) === resolvedDir)) {
|
|
5398
|
-
return { ok: false, status: 400, error:
|
|
5431
|
+
return { ok: false, status: 400, error: FOLDER_WORDS.groupRoot };
|
|
5399
5432
|
}
|
|
5400
5433
|
if (!(await assertRealpathContained(resolvedDir))) {
|
|
5401
5434
|
return { ok: false, status: 400, error: 'source path escapes the design root via a symlink' };
|
|
@@ -5421,7 +5454,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5421
5454
|
return { ok: false, status: 400, error: 'destination resolves outside the design root' };
|
|
5422
5455
|
}
|
|
5423
5456
|
if (!withinAGroup(resolvedToDir)) {
|
|
5424
|
-
return { ok: false, status: 400, error:
|
|
5457
|
+
return { ok: false, status: 400, error: FOLDER_WORDS.notHere };
|
|
5425
5458
|
}
|
|
5426
5459
|
if (!(await assertRealpathContained(resolvedToDir))) {
|
|
5427
5460
|
return {
|
|
@@ -5432,7 +5465,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5432
5465
|
}
|
|
5433
5466
|
// Refuse a move into itself or a descendant of itself.
|
|
5434
5467
|
if (resolvedToDir === resolvedDir || resolvedToDir.startsWith(`${resolvedDir}${path.sep}`)) {
|
|
5435
|
-
return { ok: false, status: 400, error:
|
|
5468
|
+
return { ok: false, status: 400, error: FOLDER_WORDS.intoItself };
|
|
5436
5469
|
}
|
|
5437
5470
|
|
|
5438
5471
|
// A RENAME is a move to a new name in the same (or another) parent — one
|
|
@@ -5456,7 +5489,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5456
5489
|
if (closeFolder) return closeFolder;
|
|
5457
5490
|
try {
|
|
5458
5491
|
await statp(toDirFinalAbs);
|
|
5459
|
-
return { ok: false, status: 409, error:
|
|
5492
|
+
return { ok: false, status: 409, error: FOLDER_WORDS.taken(base) };
|
|
5460
5493
|
} catch {
|
|
5461
5494
|
/* good — doesn't exist yet */
|
|
5462
5495
|
}
|
|
@@ -5472,7 +5505,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5472
5505
|
return {
|
|
5473
5506
|
ok: false,
|
|
5474
5507
|
status: 400,
|
|
5475
|
-
error:
|
|
5508
|
+
error: FOLDER_WORDS.tooMany(path.basename(relDir), found.length, MAX_BATCH),
|
|
5476
5509
|
};
|
|
5477
5510
|
}
|
|
5478
5511
|
const canvasRels = found.map((p) =>
|
|
@@ -5519,11 +5552,8 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5519
5552
|
to: toRelDir,
|
|
5520
5553
|
});
|
|
5521
5554
|
if (folderMove?.status === 'rejected') {
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
status: 409,
|
|
5525
|
-
error: `the project did not accept this move (${folderMove.code ?? 'rejected'})`,
|
|
5526
|
-
};
|
|
5555
|
+
console.warn(`[fs-move] the project refused dir.move (${folderMove.code ?? 'rejected'})`);
|
|
5556
|
+
return { ok: false, status: 409, error: FOLDER_WORDS.refused };
|
|
5527
5557
|
}
|
|
5528
5558
|
|
|
5529
5559
|
// Collab guard for every canvas found, BEFORE any disk mutation. Same
|
|
@@ -5538,7 +5568,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5538
5568
|
return {
|
|
5539
5569
|
ok: false,
|
|
5540
5570
|
status: 409,
|
|
5541
|
-
error:
|
|
5571
|
+
error: FOLDER_WORDS.live(path.basename(r).replace(/\.tsx$/i, '')),
|
|
5542
5572
|
};
|
|
5543
5573
|
}
|
|
5544
5574
|
}
|
|
@@ -5706,7 +5736,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5706
5736
|
return resolvedParent === gAbs || resolvedParent.startsWith(`${gAbs}${path.sep}`);
|
|
5707
5737
|
});
|
|
5708
5738
|
if (!withinAGroup) {
|
|
5709
|
-
return { ok: false, status: 400, error:
|
|
5739
|
+
return { ok: false, status: 400, error: FOLDER_WORDS.notHere };
|
|
5710
5740
|
}
|
|
5711
5741
|
if (!(await assertRealpathContained(resolvedParent))) {
|
|
5712
5742
|
return {
|
|
@@ -5730,7 +5760,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5730
5760
|
if (closeFolder) return closeFolder;
|
|
5731
5761
|
try {
|
|
5732
5762
|
await statp(dirAbs); // throws if absent (works for files AND dirs)
|
|
5733
|
-
return { ok: false, status: 409, error:
|
|
5763
|
+
return { ok: false, status: 409, error: FOLDER_WORDS.taken(v.name) };
|
|
5734
5764
|
} catch {
|
|
5735
5765
|
/* good — doesn't exist yet */
|
|
5736
5766
|
}
|
|
@@ -5740,11 +5770,10 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
5740
5770
|
path: path.posix.join(parent, v.name),
|
|
5741
5771
|
});
|
|
5742
5772
|
if (folderCreate?.status === 'rejected') {
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
};
|
|
5773
|
+
console.warn(
|
|
5774
|
+
`[fs-mkdir] the project refused dir.create (${folderCreate.code ?? 'rejected'})`
|
|
5775
|
+
);
|
|
5776
|
+
return { ok: false, status: 409, error: FOLDER_WORDS.refused };
|
|
5748
5777
|
}
|
|
5749
5778
|
|
|
5750
5779
|
await mkdir(dirAbs, { recursive: true });
|
|
@@ -7855,7 +7884,20 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
7855
7884
|
|
|
7856
7885
|
// ---------- Index data + System data ----------
|
|
7857
7886
|
|
|
7858
|
-
|
|
7887
|
+
// #204 — one index build at a time per reader: a client that timed out and asked again joins the
|
|
7888
|
+
// build still running instead of starting another next to it (index-flight.ts). File events bump
|
|
7889
|
+
// it, so a build that started before a change is never handed to a later caller.
|
|
7890
|
+
const indexFlight = createSingleFlight<unknown>();
|
|
7891
|
+
ctx.bus.on('fs:any', () => indexFlight.bump());
|
|
7892
|
+
function buildIndexData(viewer?: { role?: string | null }) {
|
|
7893
|
+
// A canvas-only session's answer is filtered by its own grants: never shared.
|
|
7894
|
+
if (!projectVisibility(ctx).current().full) return buildIndexDataNow(viewer);
|
|
7895
|
+
return indexFlight.run(`${viewer?.role ?? ''}|${currentSession()}`, () =>
|
|
7896
|
+
buildIndexDataNow(viewer)
|
|
7897
|
+
);
|
|
7898
|
+
}
|
|
7899
|
+
|
|
7900
|
+
async function buildIndexDataNow(viewer?: { role?: string | null }) {
|
|
7859
7901
|
const groups = [];
|
|
7860
7902
|
|
|
7861
7903
|
// DDR-093 — per-canvas design-system map (repo-relative canvas path → DS
|
|
@@ -8085,6 +8127,12 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8085
8127
|
const imports = projectVisibility(ctx).canvasImports(canvasRels);
|
|
8086
8128
|
const canvasImportsCanvases: Record<string, string[]> = {};
|
|
8087
8129
|
for (const [rel, list] of imports) canvasImportsCanvases[`${prefix}${rel}`] = list;
|
|
8130
|
+
// 2.0.5 (#205) — a canvas whose BUILT module the inputs gate refused (it inlined a file another canvas
|
|
8131
|
+
// owns): the files, kept per canvas by the http layer (access/refused-inputs.ts). Main origin only — the
|
|
8132
|
+
// canvas origin's 403 stays the bare not-in-scope body.
|
|
8133
|
+
const refused = refusedInputsFor(ctx).report();
|
|
8134
|
+
const canvasRefusedInputs: Record<string, string[]> = {};
|
|
8135
|
+
for (const [rel, list] of refused) canvasRefusedInputs[`${prefix}${rel}`] = list;
|
|
8088
8136
|
|
|
8089
8137
|
// S9.10 (V2-1.16 L8) — a canvas-only session's tree: what it sees, nothing else.
|
|
8090
8138
|
return filterIndexData(
|
|
@@ -8096,6 +8144,7 @@ export function createApi(ctx: Context, hooks: ApiHooks): Api {
|
|
|
8096
8144
|
canvasDesignSystems,
|
|
8097
8145
|
canvasKinds,
|
|
8098
8146
|
...(imports.size ? { canvasImportsCanvases } : {}),
|
|
8147
|
+
...(refused.size ? { canvasRefusedInputs } : {}),
|
|
8099
8148
|
...(dsRender
|
|
8100
8149
|
? {
|
|
8101
8150
|
canvasDsRevs: Object.fromEntries(
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file artboard-live-gate.tsx — 2.0.5: the React half of artboard-live.ts
|
|
3
|
+
* @scope apps/studio/artboard-live-gate.tsx (used by canvas-lib.tsx's DCArtboardBody + DesignCanvas)
|
|
4
|
+
* @purpose One `LiveRegistry` + one `WebglBudget` per canvas document, fed by two shared
|
|
5
|
+
* IntersectionObservers. `ArtboardLiveGate` wraps an artboard's children: it hands them
|
|
6
|
+
* `useArtboardActive()` / `useArtboardSeen()`, pauses the artboard's `<video>`s and CSS
|
|
7
|
+
* animations while it sleeps, and in `light` mode mounts the children only while it is near
|
|
8
|
+
* (a placeholder of the last measured height stands in, so nothing reflows).
|
|
9
|
+
* `holdAllLive()` is the in-frame export's guarantee: every artboard live for the capture.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createContext,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
type RefObject,
|
|
16
|
+
useCallback,
|
|
17
|
+
useContext,
|
|
18
|
+
useEffect,
|
|
19
|
+
useLayoutEffect,
|
|
20
|
+
useRef,
|
|
21
|
+
useSyncExternalStore,
|
|
22
|
+
} from 'react';
|
|
23
|
+
import {
|
|
24
|
+
type ArtboardLiveState,
|
|
25
|
+
type LiveMode,
|
|
26
|
+
LiveRegistry,
|
|
27
|
+
NEAR_MARGIN,
|
|
28
|
+
resolveLiveMode,
|
|
29
|
+
} from './artboard-live.ts';
|
|
30
|
+
import { WebglBudget } from './artboard-webgl.ts';
|
|
31
|
+
|
|
32
|
+
const ALL_LIVE: ArtboardLiveState = { live: true, seen: true };
|
|
33
|
+
const LiveContext = createContext<ArtboardLiveState>(ALL_LIVE);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Is this artboard running live? `false` while it is offscreen or the canvas is zoomed out to its overview —
|
|
37
|
+
* pause a render loop, a video, a simulation. Always `true` outside an artboard, in captures and exports.
|
|
38
|
+
*/
|
|
39
|
+
export function useArtboardActive(): boolean {
|
|
40
|
+
return useContext(LiveContext).live;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Has this artboard been near the viewport yet? Gate an expensive first mount on it (the design-system
|
|
45
|
+
* board's specimens do). Always `true` in captures and exports.
|
|
46
|
+
*/
|
|
47
|
+
export function useArtboardSeen(): boolean {
|
|
48
|
+
return useContext(LiveContext).seen;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface Runtime {
|
|
52
|
+
registry: LiveRegistry;
|
|
53
|
+
budget: WebglBudget | null;
|
|
54
|
+
near: IntersectionObserver | null;
|
|
55
|
+
visible: IntersectionObserver | null;
|
|
56
|
+
ids: WeakMap<Element, string>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let runtime: Runtime | null = null;
|
|
60
|
+
let runtimeSearch: string | null = null;
|
|
61
|
+
|
|
62
|
+
function embedded(): boolean {
|
|
63
|
+
try {
|
|
64
|
+
return window.parent !== window;
|
|
65
|
+
} catch {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Test hook: forget the per-document runtime (the URL decides the mode at first use). */
|
|
71
|
+
export function resetArtboardLive(): void {
|
|
72
|
+
runtime = null;
|
|
73
|
+
runtimeSearch = null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getRuntime(): Runtime | null {
|
|
77
|
+
if (typeof window === 'undefined') return null;
|
|
78
|
+
if (runtime && runtimeSearch === window.location.search) return runtime;
|
|
79
|
+
const mode: LiveMode = resolveLiveMode({ search: window.location.search, embedded: embedded() });
|
|
80
|
+
runtimeSearch = window.location.search;
|
|
81
|
+
const schedule = (fn: () => void) =>
|
|
82
|
+
typeof requestAnimationFrame === 'function' ? requestAnimationFrame(fn) : setTimeout(fn, 16);
|
|
83
|
+
const registry = new LiveRegistry(mode, schedule);
|
|
84
|
+
const ids = new WeakMap<Element, string>();
|
|
85
|
+
let near: IntersectionObserver | null = null;
|
|
86
|
+
let visible: IntersectionObserver | null = null;
|
|
87
|
+
let budget: WebglBudget | null = null;
|
|
88
|
+
if (mode !== 'off' && typeof IntersectionObserver === 'function') {
|
|
89
|
+
near = new IntersectionObserver(
|
|
90
|
+
(entries) => {
|
|
91
|
+
for (const en of entries) {
|
|
92
|
+
const id = ids.get(en.target);
|
|
93
|
+
if (id) registry.setNear(id, en.isIntersecting);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{ rootMargin: NEAR_MARGIN }
|
|
97
|
+
);
|
|
98
|
+
visible = new IntersectionObserver((entries) => {
|
|
99
|
+
for (const en of entries) {
|
|
100
|
+
const id = ids.get(en.target);
|
|
101
|
+
if (id) registry.setVisible(id, en.isIntersecting);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
budget = new WebglBudget((id) => (id ? registry.isLive(id) : true));
|
|
105
|
+
budget.install(window as Window & typeof globalThis);
|
|
106
|
+
registry.onChange(() => budget?.update());
|
|
107
|
+
(window as unknown as { __maudeWebglStats?: () => unknown }).__maudeWebglStats = () => ({
|
|
108
|
+
...budget?.stats(),
|
|
109
|
+
mode,
|
|
110
|
+
visible: registry.visibleCount(),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
runtime = { registry, budget, near, visible, ids };
|
|
114
|
+
return runtime;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The mode this canvas document runs in. */
|
|
118
|
+
export function artboardLiveMode(): LiveMode {
|
|
119
|
+
return getRuntime()?.registry.mode ?? 'off';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Every artboard live for a capture, at once. Resolves after two frames (restored WebGL contexts and woken
|
|
124
|
+
* players draw again); call the returned release when the capture is done.
|
|
125
|
+
*/
|
|
126
|
+
export async function holdAllLive(): Promise<() => void> {
|
|
127
|
+
const rt = getRuntime();
|
|
128
|
+
if (!rt || rt.registry.mode === 'off') return () => {};
|
|
129
|
+
const release = rt.registry.holdAllLive();
|
|
130
|
+
rt.budget?.apply();
|
|
131
|
+
if (typeof requestAnimationFrame === 'function')
|
|
132
|
+
await new Promise<void>((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
|
|
133
|
+
return release;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Feeds the published (settle-cadence) zoom and the gesture flag. Renders nothing. */
|
|
137
|
+
export function ArtboardLiveFeed({ zoom, interacting }: { zoom: number; interacting: boolean }) {
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
const rt = getRuntime();
|
|
140
|
+
if (!rt || rt.registry.mode === 'off') return;
|
|
141
|
+
rt.registry.setZoom(zoom);
|
|
142
|
+
}, [zoom]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const rt = getRuntime();
|
|
145
|
+
if (!rt || rt.registry.mode === 'off') return;
|
|
146
|
+
rt.registry.setInteracting(interacting);
|
|
147
|
+
// A settle can change which contexts are nearest the centre.
|
|
148
|
+
if (!interacting) rt.budget?.update();
|
|
149
|
+
}, [interacting]);
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Pause what plays inside a sleeping artboard; resume what WE paused when it wakes. */
|
|
154
|
+
function useMediaSleep(articleRef: RefObject<HTMLElement | null>, live: boolean, on: boolean) {
|
|
155
|
+
const paused = useRef(new Set<HTMLMediaElement>());
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
const el = articleRef.current;
|
|
158
|
+
if (!on || !el) return;
|
|
159
|
+
el.toggleAttribute('data-dc-asleep', !live);
|
|
160
|
+
// VideoComp drives its own Player (useArtboardActive); its <video>s are the Player's to sync.
|
|
161
|
+
const own = (m: Element) => !m.closest('.dc-video-comp');
|
|
162
|
+
if (!live) {
|
|
163
|
+
for (const m of el.querySelectorAll<HTMLMediaElement>('video')) {
|
|
164
|
+
if (!own(m) || m.paused) continue;
|
|
165
|
+
m.pause();
|
|
166
|
+
paused.current.add(m);
|
|
167
|
+
}
|
|
168
|
+
// An autoplay that starts later (data arrives after we slept) is paused too.
|
|
169
|
+
const onPlay = (ev: Event) => {
|
|
170
|
+
const m = ev.target as HTMLMediaElement;
|
|
171
|
+
if (m instanceof HTMLVideoElement && own(m)) {
|
|
172
|
+
m.pause();
|
|
173
|
+
paused.current.add(m);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
el.addEventListener('play', onPlay, true);
|
|
177
|
+
return () => el.removeEventListener('play', onPlay, true);
|
|
178
|
+
}
|
|
179
|
+
for (const m of paused.current) if (m.isConnected) void m.play?.()?.catch?.(() => {});
|
|
180
|
+
paused.current.clear();
|
|
181
|
+
return undefined;
|
|
182
|
+
}, [articleRef, live, on]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function ArtboardLiveGate({
|
|
186
|
+
id,
|
|
187
|
+
articleRef,
|
|
188
|
+
bodyRef,
|
|
189
|
+
heightFloor,
|
|
190
|
+
children,
|
|
191
|
+
}: {
|
|
192
|
+
id: string;
|
|
193
|
+
articleRef: RefObject<HTMLElement | null>;
|
|
194
|
+
bodyRef: RefObject<HTMLElement | null>;
|
|
195
|
+
heightFloor: number;
|
|
196
|
+
children: ReactNode;
|
|
197
|
+
}) {
|
|
198
|
+
const rt = getRuntime();
|
|
199
|
+
const on = !!rt && rt.registry.mode !== 'off';
|
|
200
|
+
// Stable per (runtime, id): a new subscribe each render would drop the slot (and its near state) in between.
|
|
201
|
+
const subscribe = useCallback(
|
|
202
|
+
(fn: () => void) => (on && rt ? rt.registry.subscribe(id, fn) : () => {}),
|
|
203
|
+
[on, rt, id]
|
|
204
|
+
);
|
|
205
|
+
const state = useSyncExternalStore(
|
|
206
|
+
subscribe,
|
|
207
|
+
() => (on && rt ? rt.registry.get(id) : ALL_LIVE),
|
|
208
|
+
() => ALL_LIVE
|
|
209
|
+
);
|
|
210
|
+
const { live, seen } = state;
|
|
211
|
+
|
|
212
|
+
// Observe the artboard (the article — its size is stable whether its children are mounted or not).
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
const el = articleRef.current;
|
|
215
|
+
if (!on || !rt || !el) return;
|
|
216
|
+
if (!rt.near || !rt.visible) {
|
|
217
|
+
// No IntersectionObserver: fail open, everything near and on screen.
|
|
218
|
+
rt.registry.setNear(id, true);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
rt.ids.set(el, id);
|
|
222
|
+
rt.near.observe(el);
|
|
223
|
+
rt.visible.observe(el);
|
|
224
|
+
return () => {
|
|
225
|
+
rt.near?.unobserve(el);
|
|
226
|
+
rt.visible?.unobserve(el);
|
|
227
|
+
rt.registry.setNear(id, false);
|
|
228
|
+
rt.registry.setVisible(id, false);
|
|
229
|
+
};
|
|
230
|
+
}, [articleRef, id, on, rt]);
|
|
231
|
+
|
|
232
|
+
useMediaSleep(articleRef, live, on);
|
|
233
|
+
|
|
234
|
+
// light mode: remember the height the children had, so the placeholder holds it.
|
|
235
|
+
const lastHeight = useRef(0);
|
|
236
|
+
useLayoutEffect(() => {
|
|
237
|
+
if (!seen) return;
|
|
238
|
+
const b = bodyRef.current;
|
|
239
|
+
return () => {
|
|
240
|
+
if (b) lastHeight.current = b.offsetHeight;
|
|
241
|
+
};
|
|
242
|
+
}, [seen, bodyRef]);
|
|
243
|
+
|
|
244
|
+
const value = on ? state : ALL_LIVE;
|
|
245
|
+
const mountChildren = !on || rt?.registry.mode !== 'light' || seen;
|
|
246
|
+
return (
|
|
247
|
+
<LiveContext.Provider value={value}>
|
|
248
|
+
{mountChildren ? (
|
|
249
|
+
children
|
|
250
|
+
) : (
|
|
251
|
+
<div
|
|
252
|
+
className="dc-artboard-sleeping"
|
|
253
|
+
aria-hidden="true"
|
|
254
|
+
style={{ minHeight: Math.max(lastHeight.current, heightFloor) }}
|
|
255
|
+
/>
|
|
256
|
+
)}
|
|
257
|
+
</LiveContext.Provider>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Paused CSS animations while asleep. (A released WebGL canvas's picture is an overlay: artboard-webgl.ts.) */
|
|
262
|
+
export const ARTBOARD_LIVE_CSS = `
|
|
263
|
+
.dc-artboard[data-dc-asleep] .dc-artboard-body *,
|
|
264
|
+
.dc-artboard[data-dc-asleep] .dc-artboard-body *::before,
|
|
265
|
+
.dc-artboard[data-dc-asleep] .dc-artboard-body *::after { animation-play-state: paused !important; }
|
|
266
|
+
.dc-artboard-sleeping { width: 100%; }
|
|
267
|
+
`;
|