@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.
Files changed (272) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/closure.ts +156 -16
  3. package/apps/studio/access/filters.ts +39 -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/actions/agents.ts +59 -0
  7. package/apps/studio/actions/ctx.ts +3 -0
  8. package/apps/studio/actions/defs/app.ts +12 -0
  9. package/apps/studio/actions/defs/sync.ts +13 -0
  10. package/apps/studio/actions/defs/view.ts +59 -3
  11. package/apps/studio/actions/keymap.gen.ts +35 -0
  12. package/apps/studio/actions/menu.ts +2 -0
  13. package/apps/studio/actions/types.ts +3 -1
  14. package/apps/studio/actions.manifest.json +148 -1
  15. package/apps/studio/actions.parity.json +31 -1
  16. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  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/ride.ts +2 -1
  20. package/apps/studio/annotations/ui/text-style.ts +1 -1
  21. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  22. package/apps/studio/annotations-layer.tsx +4 -15
  23. package/apps/studio/api.ts +425 -128
  24. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  25. package/apps/studio/artboard-ai-copies.tsx +4 -4
  26. package/apps/studio/artboard-freeze.ts +108 -0
  27. package/apps/studio/artboard-live-gate.tsx +636 -0
  28. package/apps/studio/artboard-live.ts +831 -0
  29. package/apps/studio/artboard-placeholder.ts +197 -0
  30. package/apps/studio/artboard-still-raster.ts +485 -0
  31. package/apps/studio/artboard-still-warmup.ts +221 -0
  32. package/apps/studio/artboard-still.ts +1188 -0
  33. package/apps/studio/artboard-webgl.ts +669 -0
  34. package/apps/studio/asset-placeholder.tsx +237 -132
  35. package/apps/studio/asset-upload-bars.tsx +4 -4
  36. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  37. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  38. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  39. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  40. package/apps/studio/bin/_ds-check.mjs +4 -1
  41. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  42. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  43. package/apps/studio/bin/_import-asset.mjs +2 -1
  44. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  45. package/apps/studio/bin/_perf-probe.mjs +2 -1
  46. package/apps/studio/bin/_perf-shared.mjs +12 -7
  47. package/apps/studio/bin/_pw-launch.mjs +26 -1
  48. package/apps/studio/bin/_studio-verb.mjs +24 -3
  49. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  50. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  51. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  52. package/apps/studio/bin/ds-check.sh +5 -1
  53. package/apps/studio/bin/perf.sh +30 -1
  54. package/apps/studio/bin/server-up.sh +7 -2
  55. package/apps/studio/bin/smoke.sh +19 -0
  56. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  57. package/apps/studio/canvas-build-sandbox.ts +69 -13
  58. package/apps/studio/canvas-camera.ts +90 -0
  59. package/apps/studio/canvas-comment-mount.tsx +9 -9
  60. package/apps/studio/canvas-lib.tsx +289 -44
  61. package/apps/studio/canvas-pages-view.tsx +465 -0
  62. package/apps/studio/canvas-pages.ts +305 -0
  63. package/apps/studio/canvas-rows.ts +62 -0
  64. package/apps/studio/canvas-shell.tsx +62 -16
  65. package/apps/studio/canvas-theme-icons.tsx +41 -0
  66. package/apps/studio/canvas-theme-pill.tsx +15 -6
  67. package/apps/studio/canvas-theme.ts +12 -11
  68. package/apps/studio/client/app.jsx +7 -0
  69. package/apps/studio/client/canvas-url.js +36 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  71. package/apps/studio/client/home/Shelves.jsx +4 -3
  72. package/apps/studio/client/home/home-accounts-model.js +121 -0
  73. package/apps/studio/client/home/home-api.js +6 -0
  74. package/apps/studio/client/home/home-app.jsx +141 -40
  75. package/apps/studio/client/home/home-model.js +172 -6
  76. package/apps/studio/client/home/home.css +169 -5
  77. package/apps/studio/client/home/shell-mode.js +8 -1
  78. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  79. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  80. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  81. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  82. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  83. package/apps/studio/client/hooks/use-project-data.jsx +13 -2
  84. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  85. package/apps/studio/client/index-loader.ts +41 -21
  86. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  87. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  88. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  89. package/apps/studio/client/panels/caps-cache.js +46 -0
  90. package/apps/studio/client/shell/viewport.jsx +66 -22
  91. package/apps/studio/client/tree/tree.jsx +17 -0
  92. package/apps/studio/client/v2/access/access-client.js +2 -0
  93. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  94. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  95. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  96. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  97. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  98. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  99. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  100. package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
  101. package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
  102. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  103. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  104. package/apps/studio/client/v2/code/code-bus.js +5 -0
  105. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  106. package/apps/studio/client/v2/code/code-consent.js +67 -0
  107. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  108. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  109. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  110. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  111. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  112. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  113. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  114. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  115. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  116. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  117. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  118. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  119. package/apps/studio/client/v2/history/git-model.js +3 -1
  120. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  121. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  122. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  123. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  124. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  125. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  126. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  127. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  128. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  129. package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
  130. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  131. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  132. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  133. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  134. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  135. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  136. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  137. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  138. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  139. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  140. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  141. package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
  142. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  143. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  144. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  145. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  146. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  147. package/apps/studio/client/v2/shell/use-account.js +8 -1
  148. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  149. package/apps/studio/collab/persistence.ts +9 -1
  150. package/apps/studio/collab/registry.ts +32 -0
  151. package/apps/studio/collab/room.ts +8 -0
  152. package/apps/studio/comments-overlay.tsx +12 -11
  153. package/apps/studio/config-reload-wire.ts +56 -0
  154. package/apps/studio/config.schema.json +6 -0
  155. package/apps/studio/context.ts +37 -1
  156. package/apps/studio/dist/client.bundle.js +1198 -1198
  157. package/apps/studio/dist/comment-mount.js +2 -2
  158. package/apps/studio/dist/styles.css +1 -1
  159. package/apps/studio/ds/board/board.css +6 -0
  160. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  161. package/apps/studio/ds/board/specimen.tsx +16 -2
  162. package/apps/studio/ds/board/template.ts +39 -19
  163. package/apps/studio/ds/canvas-cli.ts +58 -2
  164. package/apps/studio/ds/check.ts +26 -1
  165. package/apps/studio/ds/cli.ts +14 -4
  166. package/apps/studio/ds/component-list.ts +2 -1
  167. package/apps/studio/ds/convert.ts +34 -6
  168. package/apps/studio/ds/default.ts +6 -1
  169. package/apps/studio/ds/ds-resolver.ts +58 -8
  170. package/apps/studio/ds/ds-verb.ts +13 -0
  171. package/apps/studio/ds/engine.ts +3 -1
  172. package/apps/studio/ds/folder-systems.ts +199 -0
  173. package/apps/studio/ds/pairing-css.ts +2 -1
  174. package/apps/studio/ds/post-build.ts +38 -0
  175. package/apps/studio/ds/rename.ts +10 -3
  176. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  177. package/apps/studio/ds/upgrade-apply.ts +27 -5
  178. package/apps/studio/ds/upgrade-cli.ts +22 -2
  179. package/apps/studio/ds/upgrade-prove.ts +198 -15
  180. package/apps/studio/ds/upgrade-stage.ts +10 -3
  181. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  182. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  183. package/apps/studio/editing/align-bar.tsx +4 -4
  184. package/apps/studio/editing/anchor-report.ts +3 -2
  185. package/apps/studio/editing/artboard-handles.tsx +4 -4
  186. package/apps/studio/editing/corner-dots.tsx +4 -4
  187. package/apps/studio/editing/crop-mode.tsx +4 -4
  188. package/apps/studio/editing/drop-chip.tsx +4 -4
  189. package/apps/studio/editing/empty-report.ts +3 -2
  190. package/apps/studio/editing/focus-model.tsx +4 -4
  191. package/apps/studio/editing/gap-bands.tsx +3 -3
  192. package/apps/studio/editing/hold-rings.tsx +4 -4
  193. package/apps/studio/editing/lock-badge.tsx +3 -3
  194. package/apps/studio/editing/long-page.ts +23 -1
  195. package/apps/studio/editing/nudge.tsx +2 -2
  196. package/apps/studio/editing/page-activity.ts +4 -3
  197. package/apps/studio/editing/paste-bar.tsx +4 -4
  198. package/apps/studio/editing/pen/overlay.tsx +4 -3
  199. package/apps/studio/editing/place-freely.tsx +3 -3
  200. package/apps/studio/editing/reorder-slot.tsx +3 -3
  201. package/apps/studio/editing/selection.tsx +4 -4
  202. package/apps/studio/editing/size-ghost.tsx +4 -4
  203. package/apps/studio/editing/tab-order.tsx +4 -4
  204. package/apps/studio/editing/text-in-place.tsx +4 -4
  205. package/apps/studio/editing/undo-preview.tsx +3 -3
  206. package/apps/studio/equal-spacing-handles.tsx +3 -3
  207. package/apps/studio/frame-clock.ts +89 -0
  208. package/apps/studio/history/trash.ts +6 -0
  209. package/apps/studio/home/accounts.ts +87 -0
  210. package/apps/studio/home/index-reader.ts +24 -2
  211. package/apps/studio/home/routes.ts +19 -0
  212. package/apps/studio/http.ts +80 -34
  213. package/apps/studio/index/ds-usage.ts +4 -1
  214. package/apps/studio/index-cache.ts +272 -0
  215. package/apps/studio/inspect-overlay.tsx +4 -3
  216. package/apps/studio/inspect.ts +7 -2
  217. package/apps/studio/link-chip-overlay.tsx +4 -3
  218. package/apps/studio/measure-overlay.tsx +4 -3
  219. package/apps/studio/present/pointer-dot.tsx +3 -2
  220. package/apps/studio/present/present-media.ts +6 -2
  221. package/apps/studio/present/present-stage.tsx +3 -2
  222. package/apps/studio/preview/preview-camera.tsx +3 -2
  223. package/apps/studio/routes/ds-convert.ts +18 -0
  224. package/apps/studio/routes/sync.ts +176 -0
  225. package/apps/studio/routes/trash.ts +16 -1
  226. package/apps/studio/safe-zones-overlay.tsx +3 -2
  227. package/apps/studio/server.ts +8 -10
  228. package/apps/studio/skip-dirs.ts +103 -47
  229. package/apps/studio/studio-page-host.ts +70 -0
  230. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  231. package/apps/studio/sync/asset-push.ts +146 -23
  232. package/apps/studio/sync/asset-state.ts +3 -2
  233. package/apps/studio/sync/code-module-consent.ts +86 -0
  234. package/apps/studio/sync/file-ledger.ts +24 -0
  235. package/apps/studio/sync/file-membership.ts +28 -3
  236. package/apps/studio/sync/file-plane.ts +497 -61
  237. package/apps/studio/sync/file-pull.ts +304 -33
  238. package/apps/studio/sync/held-deletes.ts +230 -0
  239. package/apps/studio/sync/hub-link.ts +1 -2
  240. package/apps/studio/sync/hubs-config.ts +59 -2
  241. package/apps/studio/sync/index.ts +405 -163
  242. package/apps/studio/sync/journal-client.ts +94 -5
  243. package/apps/studio/sync/pending-deletes.ts +100 -0
  244. package/apps/studio/sync/projection.ts +77 -12
  245. package/apps/studio/sync/seed-progress.ts +104 -3
  246. package/apps/studio/sync/settings.ts +36 -1
  247. package/apps/studio/sync/status.ts +17 -1
  248. package/apps/studio/sync/writer-registry.ts +5 -0
  249. package/apps/studio/text-caret.ts +5 -3
  250. package/apps/studio/thumbs/service.ts +12 -2
  251. package/apps/studio/thumbs/validate.ts +7 -0
  252. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  253. package/apps/studio/ui-prefs-migrate.ts +4 -0
  254. package/apps/studio/use-annotation-resize.tsx +4 -3
  255. package/apps/studio/use-artboard-drag.tsx +3 -2
  256. package/apps/studio/use-element-resize.tsx +7 -6
  257. package/apps/studio/use-grid-track-handles.tsx +5 -4
  258. package/apps/studio/use-selection-set.tsx +64 -4
  259. package/apps/studio/use-spacing-handles.tsx +7 -6
  260. package/apps/studio/video-comp.tsx +75 -39
  261. package/apps/studio/video-play-overlay.tsx +4 -3
  262. package/apps/studio/whats-new.json +99 -0
  263. package/cli/commands/design.mjs +5 -2
  264. package/cli/commands/hub.mjs +10 -1
  265. package/cli/lib/bash-guard.mjs +27 -1
  266. package/cli/lib/design-help.gen.mjs +1 -1
  267. package/cli/lib/design-hook.mjs +20 -0
  268. package/cli/lib/design-link.mjs +42 -17
  269. package/cli/lib/hub-purge.mjs +183 -0
  270. package/cli/lib/studio-locate.mjs +35 -10
  271. package/package.json +8 -8
  272. package/plugins/design/templates/_shell.html +164 -1
@@ -42,6 +42,7 @@ import { HUB_SIGNIN_RETURN_PATH, returnPage } from '../sync/hub-browser-signin.t
42
42
  import { thumbNotFound, thumbResponse } from '../thumbs/routes.ts';
43
43
  import { checkJpeg } from '../thumbs/validate.ts';
44
44
  import { isLoopbackHost } from '../ws.ts';
45
+ import { createHomeAccounts } from './accounts.ts';
45
46
  import { createHomeAi, type HomeAi } from './ai.ts';
46
47
  import { createHomeCli, type HomeCli } from './cli.ts';
47
48
  import type { HomeCloud } from './cloud.ts';
@@ -281,6 +282,7 @@ export function homeRouteTable(deps: HomeDeps): HomeRoute[] {
281
282
  const cli = deps.cli ?? createHomeCli();
282
283
  const whatsNew = deps.whatsNew ?? createHomeWhatsNew();
283
284
  const github = deps.github ?? createHomeGithub();
285
+ const accounts = createHomeAccounts({ forgetCloud: (p) => deps.cloud.forget(p) });
284
286
  return [
285
287
  {
286
288
  method: 'GET',
@@ -481,6 +483,23 @@ export function homeRouteTable(deps: HomeDeps): HomeRoute[] {
481
483
  ),
482
484
  post('/_home/hub/signin/poll', 'home', (b) => hub.signInPoll(b)),
483
485
  post('/_home/hub/signin/cancel', 'home', (b) => hub.signInCancel(b)),
486
+ // 2.0.5 W4b — Home's avatar: each profile's team-server sign-ins (no tokens), and a sign-out per
487
+ // account (one credential out of that profile's own file)
488
+ {
489
+ method: 'GET',
490
+ path: '/_home/accounts',
491
+ kind: 'home',
492
+ handle: (_req, url) => {
493
+ const r = accounts.list(url.searchParams.get('profiles'));
494
+ return json(r.status, r.body);
495
+ },
496
+ },
497
+ post('/_home/hub/signout', 'home', (b) =>
498
+ accounts.hubSignOut((b ?? {}) as Record<string, unknown>)
499
+ ),
500
+ post('/_home/cloud/signout', 'home', (b) =>
501
+ accounts.cloudSignOut((b ?? {}) as Record<string, unknown>)
502
+ ),
484
503
  get('/_home/ai/status', () => ai.status()),
485
504
  post('/_home/ai/connect', 'home', (b) => ai.connect(b)),
486
505
  get('/_home/cli/status', () => cli.status()),
@@ -60,6 +60,7 @@ import {
60
60
  verifyFrameCap,
61
61
  } from './access/frame.ts';
62
62
  import { closureConfigFor } from './access/known-canvases.ts';
63
+ import { entryRel, refusedDesignInputs, refusedInputsFor } from './access/refused-inputs.ts';
63
64
  import {
64
65
  ACP_REFUSAL,
65
66
  accessForDesktop,
@@ -105,7 +106,12 @@ import { createRunRegistry, type RunRegistry } from './ai/runs.ts';
105
106
  import { type Api, ASSET_CHUNK_BYTES, ASSET_MAX_BYTES, ASSET_MAX_VIDEO_BYTES } from './api.ts';
106
107
  import { importBrandRequest } from './bin/_brand-site.mjs';
107
108
  import { buildCanvasModule } from './canvas-build.ts';
108
- import { buildCanvasSandboxed, buildStats, sandboxFailureClass } from './canvas-build-sandbox.ts';
109
+ import {
110
+ buildCanvasSandboxed,
111
+ buildStats,
112
+ sandboxFailureClass,
113
+ withBuildSlot,
114
+ } from './canvas-build-sandbox.ts';
109
115
  import { canvasLibPath } from './canvas-lib-resolver.ts';
110
116
  import { budgetFromEnv, createModuleCache, moduleBytes } from './canvas-module-cache.ts';
111
117
  import { TranspileError } from './canvas-pipeline.ts';
@@ -291,6 +297,7 @@ import {
291
297
  serveFile,
292
298
  serveIndexHtml,
293
299
  } from './static-lane.ts';
300
+ import { studioPageHostRedirect } from './studio-page-host.ts';
294
301
  import { sanitizeForLog } from './sync/cell-pairing.ts';
295
302
  import { linkHub } from './sync/hub-link.ts';
296
303
  import { accessFor, getHubRecord, linkRoleSource } from './sync/hubs-config.ts';
@@ -381,26 +388,28 @@ export function rootIdentity(root: string): string {
381
388
  }
382
389
 
383
390
  /**
384
- * DDR-247 — the studio page's CSP. Always `frame-ancestors`; in the `?embed=1`
385
- * view also `frame-src 'self' <canvas origin>`: the embed frames exactly one
386
- * canvas, and a hostile canvas must not be able to navigate its own frame to a
387
- * foreign origin (a look-alike sign-in page) inside someone else's app.
391
+ * DDR-247 — the studio page's CSP. Always `frame-ancestors`, and always `frame-src 'self' <canvas
392
+ * origin>`: every iframe the studio creates is a canvas shell (the canvas, Compare, the design-system
393
+ * grid, Present, Diff), so a hostile canvas must not be able to navigate its own frame to a foreign
394
+ * origin — a look-alike sign-in page inside Maude or inside an embedding app, and the one way left to
395
+ * carry out what its code could read (localhost cookies of other local servers, canvas text), since
396
+ * the canvas CSP already closes every fetch/img/media sink. The sandbox has no allow-top-navigation
397
+ * or allow-popups, so this closes the last navigation lane (decision v2-207-studio-frame-src-always;
398
+ * it was embed-only before).
388
399
  */
389
400
  export function studioPageCsp(
390
401
  mainOrigin: string | undefined,
391
402
  embedOrigins: readonly string[],
392
- { embed = false, canvasOrigin }: { embed?: boolean; canvasOrigin?: string } = {}
403
+ { canvasOrigin }: { embed?: boolean; canvasOrigin?: string } = {}
393
404
  ): string {
394
405
  const directives = [`frame-ancestors ${frameAncestors(mainOrigin, embedOrigins)}`];
395
- if (embed) {
396
- let canvas = '';
397
- try {
398
- canvas = canvasOrigin ? new URL(canvasOrigin).origin : '';
399
- } catch {
400
- /* unparseable — 'self' alone, the canvas then fails closed */
401
- }
402
- directives.push(`frame-src ${["'self'", canvas].filter(Boolean).join(' ')}`);
406
+ let canvas = '';
407
+ try {
408
+ canvas = canvasOrigin ? new URL(canvasOrigin).origin : '';
409
+ } catch {
410
+ /* unparseable — 'self' alone, the canvas then fails closed */
403
411
  }
412
+ directives.push(`frame-src ${["'self'", canvas].filter(Boolean).join(' ')}`);
404
413
  return directives.join('; ');
405
414
  }
406
415
 
@@ -1009,16 +1018,20 @@ export async function serveCanvasTsx(
1009
1018
  return respondWithCanvasModule(req, cached);
1010
1019
  }
1011
1020
  try {
1012
- result = await buildCanvasModule(absPath, source, {
1013
- designRoot: ctx.paths.designRoot,
1014
- // UNCONDITIONAL, desktop included (feature-sync-file-plane, Task 9 —
1015
- // the binding debate's CONDITION on the `code-module` class): a
1016
- // canvas import resolves inside the design root on EVERY runtime, so
1017
- // a synced module cannot make the build read the wider filesystem.
1018
- // The cell worker has always armed this (canvas-build-worker.ts).
1019
- restrictImportsTo: ctx.paths.designRoot,
1020
- assetUrlBase: designRootUrlBase(ctx.paths),
1021
- });
1021
+ // 2.0.7 (#3) — in one of the server's build slots, like the sandbox's workers: a design system
1022
+ // opening asks for many builds at once, and each in-process Bun.build holds its own module graph.
1023
+ result = await withBuildSlot(() =>
1024
+ buildCanvasModule(absPath, source, {
1025
+ designRoot: ctx.paths.designRoot,
1026
+ // UNCONDITIONAL, desktop included (feature-sync-file-plane, Task 9 —
1027
+ // the binding debate's CONDITION on the `code-module` class): a
1028
+ // canvas import resolves inside the design root on EVERY runtime, so
1029
+ // a synced module cannot make the build read the wider filesystem.
1030
+ // The cell worker has always armed this (canvas-build-worker.ts).
1031
+ restrictImportsTo: ctx.paths.designRoot,
1032
+ assetUrlBase: designRootUrlBase(ctx.paths),
1033
+ })
1034
+ );
1022
1035
  } catch (err) {
1023
1036
  // S11.6 — the build's own error (an import, the allowlist) for `/_api/canvas-errors`;
1024
1037
  // a syntax error is re-read from the file there, so only these need remembering.
@@ -1319,14 +1332,16 @@ async function serveHistoricalCanvas(
1319
1332
  const css = await laneAtRef(versionReaders(ctx), repoRel, sha, 'css', from);
1320
1333
  const cssSig = css == null ? todayCssSig(absPath) : null;
1321
1334
  try {
1322
- const result = await buildCanvasModule(absPath, source, {
1323
- overrides: cssOverridesFor(absPath, css),
1324
- designRoot: ctx.paths.designRoot,
1325
- // Same unconditional allowlist as the live build above — a HISTORICAL
1326
- // source is still tenant/peer-authored content.
1327
- restrictImportsTo: ctx.paths.designRoot,
1328
- assetUrlBase: designRootUrlBase(ctx.paths),
1329
- });
1335
+ const result = await withBuildSlot(() =>
1336
+ buildCanvasModule(absPath, source, {
1337
+ overrides: cssOverridesFor(absPath, css),
1338
+ designRoot: ctx.paths.designRoot,
1339
+ // Same unconditional allowlist as the live build above — a HISTORICAL
1340
+ // source is still tenant/peer-authored content.
1341
+ restrictImportsTo: ctx.paths.designRoot,
1342
+ assetUrlBase: designRootUrlBase(ctx.paths),
1343
+ })
1344
+ );
1330
1345
  const body = moduleBytes(result.js);
1331
1346
  cached = {
1332
1347
  body,
@@ -3592,6 +3607,9 @@ export function createHttp(
3592
3607
  Response.json(
3593
3608
  await api.buildIndexData({
3594
3609
  role: isWorkspaceMode() ? req.headers.get('x-maude-role') : null,
3610
+ fresh: new URL(req.url).searchParams.get('fresh') === '1',
3611
+ // #207 (list speed) — the tree loader takes the bare listing on a first open ever
3612
+ partial: new URL(req.url).searchParams.get('partial') === '1',
3595
3613
  }),
3596
3614
  { headers: { 'Cache-Control': 'no-store' } }
3597
3615
  ),
@@ -4511,8 +4529,18 @@ export function createHttp(
4511
4529
  syncFiles?: unknown;
4512
4530
  propagateDeletes?: unknown;
4513
4531
  resolveFirstAnchor?: unknown;
4532
+ addIgnoreFolder?: unknown;
4533
+ removeIgnoreFolder?: unknown;
4514
4534
  }>(req, 4 * 1024);
4515
4535
  const patch: Record<string, unknown> = {};
4536
+ // Issue #207 — Sync details › "Don't sync this folder" / "Sync it again": one folder at a time.
4537
+ for (const key of ['addIgnoreFolder', 'removeIgnoreFolder'] as const) {
4538
+ if (!(key in (body ?? {}))) continue;
4539
+ const v = body?.[key];
4540
+ if (typeof v !== 'string' || v.length === 0 || v.length > 1024)
4541
+ return new Response(`${key} must be a folder path`, { status: 400 });
4542
+ patch[key] = v;
4543
+ }
4516
4544
  if ('syncFiles' in (body ?? {})) {
4517
4545
  if (typeof body?.syncFiles !== 'boolean')
4518
4546
  return new Response('syncFiles must be a boolean', { status: 400 });
@@ -7476,6 +7504,13 @@ export function createHttp(
7476
7504
  }
7477
7505
 
7478
7506
  function serveStudioPage(req: Request): Promise<Response> {
7507
+ // 2.0.7 — on the canvas origin's site, or WebKit strips every frame's capability (studio-page-host.ts).
7508
+ const sameSite = studioPageHostRedirect(req, {
7509
+ canvasOrigin: ctx.canvasOrigin,
7510
+ mainOrigin: ctx.mainOrigin,
7511
+ workspace: isWorkspaceMode(),
7512
+ });
7513
+ if (sameSite) return Promise.resolve(sameSite);
7479
7514
  let embed = false;
7480
7515
  try {
7481
7516
  embed = new URL(req.url).searchParams.get('embed') === '1';
@@ -7962,8 +7997,19 @@ export function createHttp(
7962
7997
  function canvasInputsGate(req: Request): CanvasInputsGate | undefined {
7963
7998
  const see = seerFor(req);
7964
7999
  if (see === null) return undefined;
7965
- const gate: CanvasInputsGate = (inputs, entry) =>
7966
- inputsRefusal(inputs, designRoots, see, { entry });
8000
+ const gate: CanvasInputsGate = (inputs, entry) => {
8001
+ const refused = inputsRefusal(inputs, designRoots, see, { entry });
8002
+ // 2.0.5 (#205) — keep WHY on the server, per canvas; the main origin's /_index-data reports it
8003
+ // (`canvasRefusedInputs`). The answer here stays the bare not-in-scope body.
8004
+ const canvas = entryRel(entry, designRoots);
8005
+ if (canvas) {
8006
+ const names = refused ? refusedDesignInputs(inputs, designRoots, see) : [];
8007
+ const store = refusedInputsFor(ctx);
8008
+ const changed = names.length ? store.record(canvas, names) : store.clear(canvas);
8009
+ if (changed) ctx.bus.emit('canvas-list-update', { action: 'refused', rel: canvas });
8010
+ }
8011
+ return refused;
8012
+ };
7967
8013
  // gate-b-c4l (L-b) — a canvas whose import walk the closure blocked is refused before the build.
7968
8014
  gate.before = (entry) => {
7969
8015
  const closure = closureOf(accessOf(req));
@@ -26,6 +26,7 @@ import { listElements } from '../canvas-edit.ts';
26
26
  import { type CanvasContext, type CanvasState, checkCanvas } from '../ds/canvas-check.ts';
27
27
  import { checkSystem, type SystemReport } from '../ds/check.ts';
28
28
  import { type CssRule, ownDeclarations, scanCssRules, splitSelectorList } from '../ds/css-scan.ts';
29
+ import { isFolderSystemFile, withFolderSystems } from '../ds/folder-systems.ts';
29
30
  import { indexRegistry, loadRegistry, type RegistryIndex } from '../ds/registry.ts';
30
31
  import {
31
32
  diskFs,
@@ -537,7 +538,8 @@ export function createDsUsage(o: DsUsageOptions): DsUsageIndex {
537
538
  const fs = diskFs(root);
538
539
  const next = new Map<string, SysInfo>();
539
540
  const models = new Map<string, SystemModel>();
540
- const cfgs = systemConfigsFrom(config);
541
+ // 2.0.7 — the configured systems, then the folder-owned ones (ds/folder-systems.ts)
542
+ const cfgs = systemConfigsFrom(withFolderSystems(config, root));
541
543
  const hash = createHash('sha256');
542
544
  for (const cfg of cfgs) {
543
545
  const model = loadSystem(fs, cfg);
@@ -854,6 +856,7 @@ export function createDsUsage(o: DsUsageOptions): DsUsageIndex {
854
856
  // ── events ─────────────────────────────────────────────────────────────────────────────────
855
857
  const isSystemFile = (rel: string) =>
856
858
  rel === 'config.json' ||
859
+ isFolderSystemFile(rel) ||
857
860
  (rel.startsWith('system/') &&
858
861
  (rel.endsWith('.css') || rel.endsWith('components.json') || rel.endsWith('tokens.json')));
859
862
 
@@ -0,0 +1,272 @@
1
+ // apps/studio/index-cache.ts — #207: the project tree answers at once, from the last build.
2
+ //
3
+ // `/_index-data` walks every canvas group, reads every canvas's sidecar and every canvas's import
4
+ // closure. On StudyFi (8.3k paths, 316 canvases) that took 13 s on Michal's desktop, every time —
5
+ // nothing was kept between requests, and the client saw "taking a while — trying again…" on a
6
+ // project whose files are all local.
7
+ //
8
+ // This keeps the last build and hands it out until something it depends on changes:
9
+ // - `invalidate()` (a file event outside the root runtime folders, an API write announcing
10
+ // itself) marks it out of date; the next request waits for ONE rebuild — every request in the
11
+ // meantime joins it (never two builds at once, never a build per retry).
12
+ // - A copy of the last build on disk (`seed`) answers the first request after a restart at once,
13
+ // marked `stale`, while the real build runs; nothing else is ever served stale. A `fresh`
14
+ // request waits for a real build instead.
15
+ //
16
+ // `createIndexCache` is pure (no disk, no bus); api.ts wires the build, the seed and the events.
17
+ // Below it: the canvas part's shape, its disk copy, and which events make it out of date.
18
+
19
+ import { randomBytes } from 'node:crypto';
20
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
21
+ import path from 'node:path';
22
+
23
+ export interface IndexCacheOptions<T> {
24
+ /**
25
+ * Compute the value from the disk (the expensive part). `early` may be called once, before the
26
+ * content reads, with what a `partial` request is answered with meanwhile (the bare listing). It
27
+ * is never kept as the value nor persisted.
28
+ */
29
+ build: (early?: (value: T) => void) => Promise<T>;
30
+ /** The last value a previous run kept on disk, or null (read once, on the first request). */
31
+ seed?: () => T | null;
32
+ /** A build finished: keep a copy for the next run (called after the value is stored). */
33
+ persist?: (value: T) => void;
34
+ /** A background build failed (the seed path has no caller waiting on it). */
35
+ onError?: (error: unknown) => void;
36
+ }
37
+
38
+ export interface IndexCache<T> {
39
+ /**
40
+ * The current value. `stale` only for the seed of a previous run, served while the first build
41
+ * runs and the caller did not ask for `fresh` — or, when there is no seed either, for the listing
42
+ * the first build published early (`partial`), and only to a caller that asked for `partial`.
43
+ */
44
+ get(opts?: {
45
+ fresh?: boolean;
46
+ partial?: boolean;
47
+ }): Promise<{ value: T; stale: boolean; partial?: true }>;
48
+ /** Something the value depends on changed: the next `get` rebuilds. */
49
+ invalidate(): void;
50
+ /** For tests: builds started so far, and whether one is running. */
51
+ stats(): { builds: number; running: boolean };
52
+ }
53
+
54
+ /** Let every request already waiting run (and an answer already made get out) before going on. */
55
+ export const yieldToLoop = (): Promise<void> => new Promise((resolve) => setImmediate(resolve));
56
+
57
+ /** A build is retried at most this often in a row when the tree keeps changing under it. */
58
+ const MAX_CHASE = 3;
59
+
60
+ export function createIndexCache<T>(o: IndexCacheOptions<T>): IndexCache<T> {
61
+ let gen = 0;
62
+ let current: { value: T; gen: number } | null = null;
63
+ let seeded: { value: T } | null | undefined; // undefined = not read yet
64
+ let running: Promise<void> | null = null;
65
+ // #207 — what the running build published before its content reads; cleared when it ends.
66
+ let early: { value: T } | null = null;
67
+ let earlyWaiters: Array<() => void> = [];
68
+ let builds = 0;
69
+ const wakeEarly = () => {
70
+ const waiting = earlyWaiters;
71
+ earlyWaiters = [];
72
+ for (const wake of waiting) wake();
73
+ };
74
+
75
+ function start(): Promise<void> {
76
+ if (running) return running;
77
+ const at = gen;
78
+ builds++;
79
+ running = (async () => {
80
+ try {
81
+ const value = await o.build((v) => {
82
+ if (early) return;
83
+ early = { value: v };
84
+ wakeEarly();
85
+ });
86
+ // A slower build never replaces a newer one (only one runs at a time, but be exact).
87
+ if (!current || current.gen <= at) current = { value, gen: at };
88
+ try {
89
+ o.persist?.(value);
90
+ } catch (err) {
91
+ o.onError?.(err);
92
+ }
93
+ } finally {
94
+ running = null;
95
+ early = null;
96
+ wakeEarly();
97
+ }
98
+ })();
99
+ return running;
100
+ }
101
+
102
+ /** The first build's early listing; null once a whole value exists or the build ended without one. */
103
+ function earlyListing(): Promise<{ value: T } | null> {
104
+ return new Promise((resolve) => {
105
+ const take = () => resolve(current ? null : early);
106
+ if (early || !running) take();
107
+ else earlyWaiters.push(take);
108
+ });
109
+ }
110
+
111
+ async function fresh(): Promise<T> {
112
+ // The tree may change while a build runs; chase it a few times, then answer with the newest
113
+ // build there is (what the uncached route always did: an answer from just before the change).
114
+ for (let round = 0; ; round++) {
115
+ if (current && current.gen === gen) return current.value;
116
+ if (current && round >= MAX_CHASE) return current.value;
117
+ await start();
118
+ }
119
+ }
120
+
121
+ return {
122
+ async get(opts = {}) {
123
+ if (current && current.gen === gen) return { value: current.value, stale: false };
124
+ if (!current && !opts.fresh) {
125
+ if (seeded === undefined) {
126
+ try {
127
+ const v = o.seed?.() ?? null;
128
+ seeded = v === null ? null : { value: v };
129
+ } catch {
130
+ seeded = null;
131
+ }
132
+ }
133
+ if (seeded) {
134
+ start().catch((err) => o.onError?.(err));
135
+ return { value: seeded.value, stale: true };
136
+ }
137
+ // #207 — no copy either (the first open ever): the bare listing as soon as the build has it.
138
+ if (opts.partial) {
139
+ const whole = fresh();
140
+ const listing = await earlyListing();
141
+ if (listing) {
142
+ whole.catch((err) => o.onError?.(err)); // the caller's next request meets a failure
143
+ return { value: listing.value, stale: true, partial: true };
144
+ }
145
+ return { value: await whole, stale: false };
146
+ }
147
+ }
148
+ return { value: await fresh(), stale: false };
149
+ },
150
+ invalidate() {
151
+ gen++;
152
+ },
153
+ stats: () => ({ builds, running: running !== null }),
154
+ };
155
+ }
156
+
157
+ // ---------- the `/_index-data` canvas part, its disk copy, and what invalidates it ----------
158
+
159
+ /** The slow, reader-independent half of `/_index-data` (api.ts `buildCanvasIndexPart`). */
160
+ export interface CanvasIndexPart {
161
+ groups: Array<{
162
+ label: string;
163
+ paths: string[];
164
+ fullPath: string;
165
+ stripPrefix: string;
166
+ kind: 'project' | 'canvas' | 'runtime';
167
+ dsFolders?: Array<{ name: string; path: string; folder: string }>;
168
+ dirs?: string[];
169
+ }>;
170
+ canvasDesignSystems: Record<string, string>;
171
+ canvasKinds: Record<string, string>;
172
+ canvasImportsCanvases?: Record<string, string[]>;
173
+ canvasMissingImports?: Record<string, string[]>;
174
+ canvasDsRevs?: Record<string, string>;
175
+ canvasDsKept?: Record<string, string>;
176
+ systemHeads?: Record<string, string | null>;
177
+ dsConverted?: Record<string, boolean>;
178
+ dsRevGaps?: Record<string, string | null>;
179
+ }
180
+
181
+ /**
182
+ * A file event the canvas part cannot depend on: anything under a ROOT runtime name — a path inside
183
+ * a root runtime folder (`_canvas-state/x.view.json`, `_export-jobs/…`, `_cache/…`) or a root
184
+ * runtime file (`_locator.json`). The part lists no `_` name (findFiles skips them; the Runtime row
185
+ * is listed per request), and an import walk never follows one (closure.ts refuses a `_` first
186
+ * segment). Those are written all the time while the studio runs — each write used to throw the
187
+ * whole index away.
188
+ */
189
+ export function isRootRuntimeRel(rel: string): boolean {
190
+ if (typeof rel !== 'string') return false;
191
+ return rel.replace(/\\/g, '/').replace(/^\/+/, '').startsWith('_');
192
+ }
193
+
194
+ /**
195
+ * Bus events an API write raises before (or instead of) its file event: the client reloads the
196
+ * tree as soon as the write answers, so the cache must be out of date by then.
197
+ */
198
+ export const CANVAS_INDEX_WRITE_EVENTS = [
199
+ 'activity:suppress',
200
+ 'activity:unsuppress',
201
+ 'canvas-list-update',
202
+ 'canvas-move-begin',
203
+ 'canvas-created',
204
+ 'canvas-deleted',
205
+ 'source-writing',
206
+ 'source-written',
207
+ 'source-op',
208
+ 'config-updated',
209
+ 'access:changed',
210
+ 'ds:outside',
211
+ ] as const;
212
+
213
+ /** A burst of edits writes the disk copy once. */
214
+ export const CANVAS_INDEX_SEED_DEBOUNCE_MS = 1000;
215
+
216
+ const SEED_VERSION = 1;
217
+ /** A copy larger than this is not kept (a project that big pays its first build). */
218
+ const SEED_CAP_BYTES = 16 * 1024 * 1024;
219
+
220
+ const isStrList = (v: unknown): v is string[] =>
221
+ Array.isArray(v) && v.every((x) => typeof x === 'string');
222
+ const isStrRecord = (v: unknown): v is Record<string, string> =>
223
+ !!v &&
224
+ typeof v === 'object' &&
225
+ !Array.isArray(v) &&
226
+ Object.values(v as object).every((x) => typeof x === 'string');
227
+
228
+ /**
229
+ * The previous run's canvas part, or null. Machine cache (`~/.maude/index/v1/projects/<pid>/`, the
230
+ * V2-1.17 per-project folder — outside every project tree, never synced). It is only ever served
231
+ * marked stale and rebuilt at once; a copy written under another config, or of the wrong shape, is
232
+ * not served at all.
233
+ */
234
+ export function readCanvasIndexSeed(file: string, cfgKey: string): CanvasIndexPart | null {
235
+ let raw: string;
236
+ try {
237
+ raw = readFileSync(file, 'utf8');
238
+ } catch {
239
+ return null;
240
+ }
241
+ if (raw.length > SEED_CAP_BYTES) return null;
242
+ let doc: unknown;
243
+ try {
244
+ doc = JSON.parse(raw);
245
+ } catch {
246
+ return null;
247
+ }
248
+ const d = doc as { v?: unknown; cfgKey?: unknown; part?: unknown } | null;
249
+ if (!d || d.v !== SEED_VERSION || d.cfgKey !== cfgKey) return null;
250
+ const part = d.part as CanvasIndexPart | undefined;
251
+ if (!part || !Array.isArray(part.groups)) return null;
252
+ for (const g of part.groups) {
253
+ if (!g || typeof g.label !== 'string' || !isStrList(g.paths)) return null;
254
+ if (g.dirs !== undefined && !isStrList(g.dirs)) return null;
255
+ }
256
+ if (!isStrRecord(part.canvasDesignSystems) || !isStrRecord(part.canvasKinds)) return null;
257
+ return part;
258
+ }
259
+
260
+ /** Atomic write (tmp → rename), 0600 in a 0700 folder; a failure only costs the next cold start. */
261
+ export function writeCanvasIndexSeed(file: string, part: CanvasIndexPart, cfgKey: string): void {
262
+ try {
263
+ const text = JSON.stringify({ v: SEED_VERSION, cfgKey, part });
264
+ if (text.length > SEED_CAP_BYTES) return;
265
+ mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
266
+ const tmp = `${file}.tmp-${process.pid}-${randomBytes(4).toString('hex')}`;
267
+ writeFileSync(tmp, text, { mode: 0o600 });
268
+ renameSync(tmp, file);
269
+ } catch (err) {
270
+ console.warn('[index-data] could not keep the tree for the next start:', err);
271
+ }
272
+ }
@@ -17,6 +17,7 @@ import { canvasModeStore } from './bridge/canvas-mode-store.ts';
17
17
  import { modeShows } from './bridge/mode-shows.ts';
18
18
  import { useArtboardsContext } from './canvas-lib.tsx';
19
19
  import { resolveSelectionEl, shortText } from './dom-selection.ts';
20
+ import { frameCaf, frameRaf } from './frame-clock.ts';
20
21
  import { isAnnotationTool, isEditableTarget } from './input-router.tsx';
21
22
  import { inspectsSelection, type Neighbour, neighbourOf } from './inspect-canvas.ts';
22
23
  import { useCanvasKeys } from './use-canvas-keys.ts';
@@ -165,12 +166,12 @@ export function InspectOverlay() {
165
166
  } else {
166
167
  tag.dataset.on = 'false';
167
168
  }
168
- raf = requestAnimationFrame(tick);
169
+ raf = frameRaf(tick);
169
170
  };
170
- raf = requestAnimationFrame(tick);
171
+ raf = frameRaf(tick);
171
172
  return () => {
172
173
  alive = false;
173
- if (raf != null) cancelAnimationFrame(raf);
174
+ if (raf != null) frameCaf(raf);
174
175
  };
175
176
  }, [one, zoom]);
176
177
 
@@ -621,6 +621,11 @@ const INSPECTOR_SCRIPT = `
621
621
 
622
622
  var pinNodes = [];
623
623
  var rafToken = null;
624
+ // the pins follow the camera: never deferred by the gesture freeze (frame-clock.ts)
625
+ var pinRaf = function (fn) {
626
+ var ff = window.__maudeFrameFreeze;
627
+ return ff ? ff.raf(fn) : requestAnimationFrame(fn);
628
+ };
624
629
 
625
630
  function buildPinNodes() {
626
631
  pinLayer.innerHTML = '';
@@ -682,10 +687,10 @@ const INSPECTOR_SCRIPT = `
682
687
  function tick() {
683
688
  rafToken = null;
684
689
  placePins();
685
- if (pinNodes.length) rafToken = requestAnimationFrame(tick);
690
+ if (pinNodes.length) rafToken = pinRaf(tick);
686
691
  }
687
692
  function startTick() {
688
- if (rafToken == null && pinNodes.length) rafToken = requestAnimationFrame(tick);
693
+ if (rafToken == null && pinNodes.length) rafToken = pinRaf(tick);
689
694
  }
690
695
 
691
696
  function schedulePins() { buildPinNodes(); startTick(); }
@@ -12,6 +12,7 @@ import { linkLabel, parseLinkTarget } from './bridge/link-target.ts';
12
12
  import { modeShows } from './bridge/mode-shows.ts';
13
13
  import { DsIcon } from './canvas-ds-icons.tsx';
14
14
  import { resolveSelectionEl } from './dom-selection.ts';
15
+ import { frameCaf, frameRaf } from './frame-clock.ts';
15
16
  import { type Selection, useSelectionSet } from './use-selection-set.tsx';
16
17
 
17
18
  const LINK_ATTR = 'data-cd-link';
@@ -139,11 +140,11 @@ export function LinkChipOverlay() {
139
140
  : { words, left, top, from }
140
141
  );
141
142
  }
142
- raf.current = requestAnimationFrame(tick);
143
+ raf.current = frameRaf(tick);
143
144
  };
144
- raf.current = requestAnimationFrame(tick);
145
+ raf.current = frameRaf(tick);
145
146
  return () => {
146
- if (raf.current != null) cancelAnimationFrame(raf.current);
147
+ if (raf.current != null) frameCaf(raf.current);
147
148
  raf.current = null;
148
149
  };
149
150
  }, [editing, selected]);
@@ -29,6 +29,7 @@ import { modeShows } from './bridge/mode-shows.ts';
29
29
  import { useArtboardsContext } from './canvas-lib.tsx';
30
30
  import { resolveSelectionEl } from './dom-selection.ts';
31
31
  import { computePairGap } from './equal-spacing-detector.ts';
32
+ import { frameCaf, frameRaf } from './frame-clock.ts';
32
33
  import { resolveHoverTarget } from './input-router.tsx';
33
34
  import { type ModifierState, reduceModifiers } from './use-cursor-modifiers.tsx';
34
35
  import { useGovernedMode } from './use-governed-mode.ts';
@@ -234,12 +235,12 @@ export function MeasureOverlay() {
234
235
  } else {
235
236
  hideBoth();
236
237
  }
237
- rafId = requestAnimationFrame(tick);
238
+ rafId = frameRaf(tick);
238
239
  };
239
- rafId = requestAnimationFrame(tick);
240
+ rafId = frameRaf(tick);
240
241
  return () => {
241
242
  alive = false;
242
- if (rafId != null) cancelAnimationFrame(rafId);
243
+ if (rafId != null) frameCaf(rafId);
243
244
  };
244
245
  }, [active, one, hoverEl, zoom]);
245
246
 
@@ -13,6 +13,7 @@
13
13
 
14
14
  import { type JSX, useEffect, useRef } from 'react';
15
15
  import { canvasModeStore } from '../bridge/canvas-mode-store.ts';
16
+ import { frameCafOn, frameRafOn } from '../frame-clock.ts';
16
17
  import { useCollab, useForeignAwareness } from '../use-collab.tsx';
17
18
  import { sanitizePointer, type WorldPoint } from './pointer-point.ts';
18
19
 
@@ -310,8 +311,8 @@ export function usePointerDot(opts: UsePointerDotOptions): void {
310
311
  },
311
312
  color: () => collabRef.current?.myColor || 'oklch(0.74 0.16 40)',
312
313
  now: () => (typeof performance !== 'undefined' ? performance.now() : Date.now()),
313
- raf: (cb) => win.requestAnimationFrame(cb),
314
- caf: (id) => win.cancelAnimationFrame(id),
314
+ raf: (cb) => frameRafOn(win, cb),
315
+ caf: (id) => frameCafOn(win, id),
315
316
  reducedMotion: () => {
316
317
  try {
317
318
  return !!win.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
@@ -114,8 +114,12 @@ export interface PresentMedia extends StageMedia {
114
114
  hasClip(artboardId: string): boolean;
115
115
  }
116
116
 
117
- /** Retries for a Player that is not mounted yet, and the wait between them. */
118
- const MOUNT_TRIES = 5;
117
+ /**
118
+ * Retries for a Player that is not mounted yet, and the wait between them. A video artboard far from where the
119
+ * canvas was mounts its Player only once Present brings it on screen (2.0.7 — far media loads nothing), a frame
120
+ * or a few after `arrive`: ~1.2 s of patience.
121
+ */
122
+ const MOUNT_TRIES = 20;
119
123
  const MOUNT_WAIT_MS = 60;
120
124
  /** After this long a clip that was told to play with sound but is not playing is retried muted. */
121
125
  const SOUND_CHECK_MS = 400;