@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.
Files changed (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -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: 'cannot move a canvas group root' };
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: 'destination must be inside a managed canvas group' };
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: 'cannot move a folder into itself' };
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: `"${base}" already exists in ${toDir || '.'}` };
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: `folder has ${found.length} canvases — the batch move cap is ${MAX_BATCH}; move a smaller subset`,
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
- return {
5523
- ok: false,
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: `"${path.basename(r)}" has a live shared session — cannot move the folder while it's pinned to the hub`,
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: 'parent must be inside a managed canvas group' };
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: `"${v.name}" already exists` };
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
- return {
5744
- ok: false,
5745
- status: 409,
5746
- error: `the project did not accept this folder (${folderCreate.code ?? 'rejected'})`,
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
- async function buildIndexData(viewer?: { role?: string | null }) {
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
+ `;