@1agh/maude 2.0.8 → 2.1.1

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 (401) hide show
  1. package/README.md +2 -1
  2. package/apps/hub/src/project-transactions/kernel.mjs +13 -7
  3. package/apps/studio/access/closure.ts +86 -10
  4. package/apps/studio/access/filters.ts +18 -1
  5. package/apps/studio/access/request.ts +8 -0
  6. package/apps/studio/acp/design-write-verb.ts +12 -2
  7. package/apps/studio/acp/env.ts +7 -2
  8. package/apps/studio/acp/index.ts +15 -4
  9. package/apps/studio/acp/login-state.ts +22 -5
  10. package/apps/studio/acp/may-scope.ts +38 -1
  11. package/apps/studio/acp/plugin-bootstrap.ts +13 -1
  12. package/apps/studio/acp/probe.ts +11 -4
  13. package/apps/studio/actions/agents.ts +110 -28
  14. package/apps/studio/actions/canvas-keys.ts +4 -2
  15. package/apps/studio/actions/ctx.ts +3 -0
  16. package/apps/studio/actions/defs/annotation.ts +84 -2
  17. package/apps/studio/actions/defs/app.ts +28 -1
  18. package/apps/studio/actions/defs/edit.ts +13 -0
  19. package/apps/studio/actions/defs/export.ts +12 -0
  20. package/apps/studio/actions/defs/sync.ts +18 -0
  21. package/apps/studio/actions/defs/video.ts +9 -0
  22. package/apps/studio/actions/documents.ts +6 -1
  23. package/apps/studio/actions/keymap.gen.ts +147 -9
  24. package/apps/studio/actions/menu.ts +5 -1
  25. package/apps/studio/actions/types.ts +4 -2
  26. package/apps/studio/actions/verbs.ts +9 -0
  27. package/apps/studio/actions.manifest.json +300 -45
  28. package/apps/studio/actions.parity.json +19 -1
  29. package/apps/studio/ai/save-hold.ts +2 -1
  30. package/apps/studio/ai/write-claim-scope.ts +7 -1
  31. package/apps/studio/ai/write-claim.ts +154 -3
  32. package/apps/studio/annotations/ai-read.ts +42 -6
  33. package/apps/studio/annotations/ai-write.ts +145 -2
  34. package/apps/studio/annotations/board-ops.ts +34 -3
  35. package/apps/studio/annotations/checklist-ops.ts +374 -0
  36. package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
  37. package/apps/studio/annotations/elements/sticky.model.ts +54 -2
  38. package/apps/studio/annotations/ops.ts +30 -0
  39. package/apps/studio/annotations/registry.ts +9 -1
  40. package/apps/studio/annotations/templates.ts +4 -2
  41. package/apps/studio/annotations/text-steps.ts +114 -10
  42. package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
  43. package/apps/studio/annotations/ui/checklist.tsx +429 -0
  44. package/apps/studio/annotations/ui/element-node.tsx +48 -2
  45. package/apps/studio/annotations/ui/template-place.ts +11 -1
  46. package/apps/studio/annotations/v1-adapter.ts +22 -3
  47. package/apps/studio/annotations-context-toolbar.tsx +12 -0
  48. package/apps/studio/annotations-layer.tsx +442 -49
  49. package/apps/studio/annotations-model.ts +4 -2
  50. package/apps/studio/api.ts +148 -21
  51. package/apps/studio/artboard-live-gate.tsx +54 -17
  52. package/apps/studio/artboard-still-persist.ts +166 -0
  53. package/apps/studio/artboard-still-raster.ts +6 -2
  54. package/apps/studio/artboard-still.ts +390 -20
  55. package/apps/studio/asset-added.ts +154 -0
  56. package/apps/studio/asset-details.ts +46 -3
  57. package/apps/studio/asset-origins.ts +5 -3
  58. package/apps/studio/asset-trash.ts +6 -1
  59. package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
  60. package/apps/studio/bin/_annotate-post.mjs +14 -5
  61. package/apps/studio/bin/_audio-search.mjs +8 -2
  62. package/apps/studio/bin/_curl-local.mjs +7 -4
  63. package/apps/studio/bin/_desktop-locate.sh +145 -0
  64. package/apps/studio/bin/_ds-check-live.mjs +2 -1
  65. package/apps/studio/bin/_exports.mjs +38 -2
  66. package/apps/studio/bin/_history.mjs +79 -8
  67. package/apps/studio/bin/_import-asset.mjs +14 -9
  68. package/apps/studio/bin/_import-figma.mjs +510 -98
  69. package/apps/studio/bin/_index-cli.mjs +10 -21
  70. package/apps/studio/bin/_ingest-footage.mjs +24 -6
  71. package/apps/studio/bin/_media-probe.mjs +232 -0
  72. package/apps/studio/bin/_perf-probe-open.mjs +6 -0
  73. package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
  74. package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
  75. package/apps/studio/bin/_perf-probe.mjs +8 -3
  76. package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
  77. package/apps/studio/bin/_perf-sweep.mjs +240 -0
  78. package/apps/studio/bin/_record-shot.sh +33 -8
  79. package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
  80. package/apps/studio/bin/_studio-verb.mjs +8 -3
  81. package/apps/studio/bin/_thumb-route.mjs +21 -0
  82. package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
  83. package/apps/studio/bin/_transcribe.mjs +22 -6
  84. package/apps/studio/bin/_unsynced-refs.mjs +22 -0
  85. package/apps/studio/bin/_url-guard.mjs +120 -5
  86. package/apps/studio/bin/_url-guard.sh +29 -7
  87. package/apps/studio/bin/_video-limits.mjs +104 -0
  88. package/apps/studio/bin/_video-playwright.mjs +119 -19
  89. package/apps/studio/bin/_video-proxy.mjs +130 -0
  90. package/apps/studio/bin/_write-claim.mjs +38 -16
  91. package/apps/studio/bin/annotate.mjs +12 -2
  92. package/apps/studio/bin/canvas-rects.sh +19 -4
  93. package/apps/studio/bin/chat-open.sh +7 -1
  94. package/apps/studio/bin/draw-proof.sh +6 -2
  95. package/apps/studio/bin/generate.sh +32 -10
  96. package/apps/studio/bin/handoff.sh +2 -2
  97. package/apps/studio/bin/perf.sh +96 -15
  98. package/apps/studio/bin/photo-adjust.sh +6 -3
  99. package/apps/studio/bin/photo-bg-remove.sh +2 -2
  100. package/apps/studio/bin/prep.sh +21 -4
  101. package/apps/studio/bin/read-annotations.mjs +3 -0
  102. package/apps/studio/bin/runtime-health.sh +27 -1
  103. package/apps/studio/bin/screenshot.sh +152 -12
  104. package/apps/studio/bin/server-up.sh +64 -6
  105. package/apps/studio/bin/smoke.sh +43 -8
  106. package/apps/studio/bin/to-lottie.sh +3 -2
  107. package/apps/studio/bin/video-proxy.sh +27 -0
  108. package/apps/studio/bin/visual-sanity.sh +3 -1
  109. package/apps/studio/bridge/dgn-protocol.ts +157 -1
  110. package/apps/studio/bridge/mode-shows.ts +8 -6
  111. package/apps/studio/bridge/still-webp.ts +233 -0
  112. package/apps/studio/build.ts +18 -0
  113. package/apps/studio/canvas-build.ts +93 -11
  114. package/apps/studio/canvas-comment-mount.tsx +53 -8
  115. package/apps/studio/canvas-edit.ts +34 -1
  116. package/apps/studio/canvas-lib-module.ts +210 -0
  117. package/apps/studio/canvas-lib.tsx +3 -12
  118. package/apps/studio/canvas-pipeline.ts +111 -5
  119. package/apps/studio/canvas-shell.tsx +8 -11
  120. package/apps/studio/canvas-theme-pill.tsx +5 -3
  121. package/apps/studio/check/index.ts +12 -5
  122. package/apps/studio/check/video.ts +18 -2
  123. package/apps/studio/client/app.jsx +65 -7
  124. package/apps/studio/client/clipboard-relay.ts +193 -16
  125. package/apps/studio/client/comments-overlay.css +18 -0
  126. package/apps/studio/client/export-center.jsx +30 -0
  127. package/apps/studio/client/generate-dialog.jsx +49 -4
  128. package/apps/studio/client/github.js +7 -0
  129. package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
  130. package/apps/studio/client/home/HomeConnection.jsx +111 -0
  131. package/apps/studio/client/home/home-accounts-model.js +110 -1
  132. package/apps/studio/client/home/home-api.js +9 -2
  133. package/apps/studio/client/home/home-app.jsx +126 -13
  134. package/apps/studio/client/home/home-model.js +69 -1
  135. package/apps/studio/client/home/home-where-model.js +105 -0
  136. package/apps/studio/client/home/home.css +239 -1
  137. package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
  138. package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
  139. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  140. package/apps/studio/client/panels/DiffView.jsx +7 -1
  141. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  142. package/apps/studio/client/panels/chat-context.js +2 -0
  143. package/apps/studio/client/panels/slash-commands.gen.js +13 -13
  144. package/apps/studio/client/selection-scope.js +16 -9
  145. package/apps/studio/client/share-link.js +12 -0
  146. package/apps/studio/client/shell/viewport.jsx +11 -1
  147. package/apps/studio/client/shell-events.js +8 -0
  148. package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
  149. package/apps/studio/client/styles/_index.css +4 -0
  150. package/apps/studio/client/v2/ai/Feed.jsx +1 -1
  151. package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
  152. package/apps/studio/client/v2/ai/activity-line.js +54 -1
  153. package/apps/studio/client/v2/ai/ai-offer.js +21 -1
  154. package/apps/studio/client/v2/ai/run-model.js +3 -1
  155. package/apps/studio/client/v2/annotations/vote-store.js +28 -4
  156. package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
  157. package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
  158. package/apps/studio/client/v2/assets/details-model.js +1 -1
  159. package/apps/studio/client/v2/assets/details.jsx +5 -0
  160. package/apps/studio/client/v2/assets/tile-drag.js +11 -7
  161. package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
  162. package/apps/studio/client/v2/create/duplicate-done.js +6 -2
  163. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  164. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  165. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  166. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  167. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
  168. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
  169. package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
  170. package/apps/studio/client/v2/ds/review.css +1 -1
  171. package/apps/studio/client/v2/export/exports-model.js +7 -0
  172. package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
  173. package/apps/studio/client/v2/export/job-row.jsx +32 -2
  174. package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
  175. package/apps/studio/client/v2/history/compare-view.jsx +1 -0
  176. package/apps/studio/client/v2/inspector/css-write.js +6 -1
  177. package/apps/studio/client/v2/inspector/frame.jsx +28 -4
  178. package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
  179. package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
  180. package/apps/studio/client/v2/inspector/model.js +21 -0
  181. package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
  182. package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
  183. package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
  184. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  185. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  186. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  187. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  188. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  189. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  190. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  191. package/apps/studio/client/v2/preview/link-follow.js +4 -2
  192. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
  193. package/apps/studio/client/v2/search/help-model.js +2 -0
  194. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  195. package/apps/studio/client/v2/settings/account.jsx +4 -2
  196. package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
  197. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  198. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  199. package/apps/studio/client/v2/settings/general-section.jsx +155 -24
  200. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  201. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  202. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  203. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  204. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  205. package/apps/studio/client/v2/settings/settings-model.js +100 -31
  206. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  207. package/apps/studio/client/v2/settings/settings.css +374 -64
  208. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  209. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  210. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  211. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  212. package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
  213. package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
  214. package/apps/studio/client/v2/shell/api-session.js +126 -0
  215. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  216. package/apps/studio/client/v2/shell/floating-panels.css +31 -1
  217. package/apps/studio/client/v2/shell/image-pick.js +61 -8
  218. package/apps/studio/client/v2/shell/menu-aim.js +43 -0
  219. package/apps/studio/client/v2/shell/menu-runner.js +25 -7
  220. package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
  221. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  222. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  223. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  224. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  225. package/apps/studio/client/v2/shell/project-account.css +237 -0
  226. package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
  227. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  228. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  229. package/apps/studio/client/v2/shell/shell-parity.json +71 -36
  230. package/apps/studio/client/v2/shell/still-bridge.js +194 -0
  231. package/apps/studio/client/v2/shell/still-store.js +319 -0
  232. package/apps/studio/client/v2/shell/use-account.js +2 -0
  233. package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
  234. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  235. package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
  236. package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
  237. package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
  238. package/apps/studio/clip-ops.ts +126 -8
  239. package/apps/studio/cloud/endpoints.ts +29 -4
  240. package/apps/studio/collab/ai-activity.ts +10 -8
  241. package/apps/studio/collab/awareness-bridge.ts +34 -9
  242. package/apps/studio/collab/index.ts +3 -0
  243. package/apps/studio/collab/registry.ts +41 -10
  244. package/apps/studio/comment-reattach.ts +149 -0
  245. package/apps/studio/comments/mine-stamp.ts +15 -7
  246. package/apps/studio/comments/ops.ts +52 -8
  247. package/apps/studio/comments-overlay.tsx +146 -9
  248. package/apps/studio/dist/client.bundle.js +892 -885
  249. package/apps/studio/dist/comment-mount.js +2 -2
  250. package/apps/studio/dist/styles.css +1 -1
  251. package/apps/studio/dom-selection.ts +87 -18
  252. package/apps/studio/ds/board/directions.css +8 -0
  253. package/apps/studio/ds/board/outline.tsx +16 -0
  254. package/apps/studio/ds/canvas-check.ts +6 -0
  255. package/apps/studio/edit-ops/clip/reframe.ts +19 -3
  256. package/apps/studio/edit-ops/clip-carry.ts +602 -0
  257. package/apps/studio/edit-ops/clipboard.ts +318 -23
  258. package/apps/studio/edit-ops/dispatch.ts +20 -2
  259. package/apps/studio/edit-ops/scope-names.ts +249 -40
  260. package/apps/studio/edit-ops/slot-defaults.ts +3 -0
  261. package/apps/studio/edit-ops/types.ts +6 -0
  262. package/apps/studio/editing/align-bar.tsx +33 -9
  263. package/apps/studio/editing/artboard-actions.ts +5 -0
  264. package/apps/studio/editing/artboard-menu.tsx +6 -2
  265. package/apps/studio/editing/click-to-type.ts +1 -1
  266. package/apps/studio/editing/clip-words.ts +48 -0
  267. package/apps/studio/editing/clipboard.ts +21 -6
  268. package/apps/studio/editing/declared-background.ts +25 -0
  269. package/apps/studio/editing/index.tsx +3 -0
  270. package/apps/studio/editing/object-keys.ts +4 -4
  271. package/apps/studio/editing/object-menu.tsx +13 -3
  272. package/apps/studio/editing/pen/points.tsx +61 -0
  273. package/apps/studio/editing/text-in-place.tsx +11 -0
  274. package/apps/studio/editing/video-frame-handle.tsx +425 -0
  275. package/apps/studio/exporters/capture-prepass.ts +374 -0
  276. package/apps/studio/exporters/degraded.ts +148 -0
  277. package/apps/studio/exporters/hub-render-door.ts +28 -2
  278. package/apps/studio/exporters/index.ts +3 -1
  279. package/apps/studio/exporters/job-budget.ts +93 -0
  280. package/apps/studio/exporters/jobs.ts +215 -28
  281. package/apps/studio/exporters/parity-check.ts +254 -0
  282. package/apps/studio/exporters/remote.ts +209 -15
  283. package/apps/studio/exporters/svg-inline.ts +87 -0
  284. package/apps/studio/exporters/video-render-lib.ts +88 -26
  285. package/apps/studio/exporters/video.ts +29 -6
  286. package/apps/studio/figma/assets.ts +58 -43
  287. package/apps/studio/figma/codegen-fonts.ts +100 -0
  288. package/apps/studio/figma/fig-decode.ts +390 -25
  289. package/apps/studio/figma/fig-kiwi.ts +18 -4
  290. package/apps/studio/figma/fig-vector.ts +59 -3
  291. package/apps/studio/figma/sanitize.ts +2 -0
  292. package/apps/studio/figma/style-map.ts +293 -48
  293. package/apps/studio/figma/to-artboard.ts +455 -69
  294. package/apps/studio/figma/to-strokes.ts +44 -11
  295. package/apps/studio/figma/types.ts +13 -0
  296. package/apps/studio/footage/schema.ts +3 -3
  297. package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
  298. package/apps/studio/generation/adapters/groq.ts +8 -1
  299. package/apps/studio/generation/spend.ts +312 -0
  300. package/apps/studio/generation/types.ts +12 -0
  301. package/apps/studio/handoff/run.ts +1 -1
  302. package/apps/studio/handoff/targets.ts +2 -2
  303. package/apps/studio/handoff/write-scopes.ts +1 -1
  304. package/apps/studio/history/describe-annotations.ts +4 -0
  305. package/apps/studio/home/accounts.ts +30 -11
  306. package/apps/studio/home/cloud.ts +6 -1
  307. package/apps/studio/home/create-local.ts +32 -3
  308. package/apps/studio/home/hub-health.ts +76 -0
  309. package/apps/studio/home/routes.ts +15 -4
  310. package/apps/studio/http.ts +438 -86
  311. package/apps/studio/imported-module-ids.ts +91 -0
  312. package/apps/studio/inspect.ts +2 -0
  313. package/apps/studio/migrate/hub.ts +8 -1
  314. package/apps/studio/notifications.tsx +47 -5
  315. package/apps/studio/paths.ts +10 -1
  316. package/apps/studio/port.ts +3 -2
  317. package/apps/studio/preview/preview-camera.tsx +15 -382
  318. package/apps/studio/readiness.ts +10 -1
  319. package/apps/studio/release-build.ts +51 -0
  320. package/apps/studio/routes/agent.ts +188 -9
  321. package/apps/studio/routes/ai.ts +43 -11
  322. package/apps/studio/routes/annotations.ts +27 -1
  323. package/apps/studio/routes/assets.ts +18 -1
  324. package/apps/studio/routes/canvas-origin.ts +12 -9
  325. package/apps/studio/routes/cloud-move.ts +15 -0
  326. package/apps/studio/routes/edit.ts +3 -0
  327. package/apps/studio/routes/export.ts +51 -0
  328. package/apps/studio/routes/generate.ts +42 -12
  329. package/apps/studio/routes/hub-link-folder.ts +334 -0
  330. package/apps/studio/routes/hub-signin.ts +78 -1
  331. package/apps/studio/routes/index.ts +9 -1
  332. package/apps/studio/routes/shell.ts +217 -5
  333. package/apps/studio/routes/sync.ts +136 -8
  334. package/apps/studio/routes/votes.ts +2 -1
  335. package/apps/studio/schema/annotations.v2.schema.json +143 -1
  336. package/apps/studio/schema/beats.v1.schema.json +1 -1
  337. package/apps/studio/schema/edl.v1.schema.json +1 -1
  338. package/apps/studio/schema/formats.ts +3 -3
  339. package/apps/studio/schema/transcript.v1.schema.json +1 -1
  340. package/apps/studio/server.ts +142 -43
  341. package/apps/studio/shell/api-key.ts +503 -0
  342. package/apps/studio/shell/attest.ts +59 -0
  343. package/apps/studio/shell/capture-url.ts +20 -0
  344. package/apps/studio/shell/cli-yield.ts +276 -0
  345. package/apps/studio/shell/clip-transfer.ts +302 -0
  346. package/apps/studio/shell/key-file.ts +108 -0
  347. package/apps/studio/shell/server-json.ts +75 -0
  348. package/apps/studio/shell/worktree.ts +19 -0
  349. package/apps/studio/spoof-chars.ts +9 -0
  350. package/apps/studio/studio-page-host.ts +1 -1
  351. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  352. package/apps/studio/sync/accepted-link.ts +76 -29
  353. package/apps/studio/sync/action-stage.ts +575 -44
  354. package/apps/studio/sync/adopt-held.ts +85 -0
  355. package/apps/studio/sync/ctl-heal.ts +58 -0
  356. package/apps/studio/sync/file-ledger.ts +38 -4
  357. package/apps/studio/sync/file-membership.ts +16 -1
  358. package/apps/studio/sync/file-plane.ts +289 -22
  359. package/apps/studio/sync/held-deletes.ts +86 -5
  360. package/apps/studio/sync/hub-link.ts +8 -0
  361. package/apps/studio/sync/index.ts +196 -12
  362. package/apps/studio/sync/journal-client.ts +50 -4
  363. package/apps/studio/sync/link-consent.ts +22 -75
  364. package/apps/studio/sync/link-survey.ts +252 -0
  365. package/apps/studio/sync/local-kernel.ts +296 -8
  366. package/apps/studio/sync/projection.ts +22 -3
  367. package/apps/studio/sync/seed-progress.ts +12 -0
  368. package/apps/studio/sync/source-recovery.ts +59 -3
  369. package/apps/studio/sync/status.ts +19 -2
  370. package/apps/studio/sync/unsynced-refs.ts +397 -0
  371. package/apps/studio/sync/writer-registry.ts +20 -0
  372. package/apps/studio/thumbs/service.ts +4 -1
  373. package/apps/studio/tool-palette.tsx +23 -0
  374. package/apps/studio/ui-prefs.ts +40 -0
  375. package/apps/studio/use-agent-presence.tsx +2 -2
  376. package/apps/studio/use-canvas-keys.ts +6 -1
  377. package/apps/studio/video/format-ids.ts +2 -2
  378. package/apps/studio/video/inject.ts +31 -0
  379. package/apps/studio/video/media-risk.ts +58 -0
  380. package/apps/studio/video/object-fit.ts +137 -0
  381. package/apps/studio/video/provider-transcript.ts +141 -0
  382. package/apps/studio/whats-new.json +137 -0
  383. package/apps/studio/workspace-mode.ts +1 -0
  384. package/apps/studio/ws.ts +5 -0
  385. package/cli/commands/design.mjs +119 -8
  386. package/cli/lib/bash-guard.mjs +366 -6
  387. package/cli/lib/confine-read.mjs +1 -0
  388. package/cli/lib/design-help.gen.mjs +3 -2
  389. package/cli/lib/design-hook.mjs +387 -81
  390. package/cli/lib/design-link.mjs +16 -1
  391. package/cli/lib/design-open.mjs +49 -3
  392. package/cli/lib/desktop-locate.mjs +770 -0
  393. package/cli/lib/handoff.mjs +1 -1
  394. package/cli/lib/hook-state.mjs +291 -0
  395. package/cli/lib/pkg-root.mjs +65 -13
  396. package/cli/lib/studio-locate.mjs +59 -16
  397. package/package.json +15 -8
  398. package/plugins/design/templates/_shell.html +13 -0
  399. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  400. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  401. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -25,16 +25,23 @@
25
25
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
26
26
  import path from 'node:path';
27
27
 
28
- import { canvasLibPath, canvasLibResolver } from './canvas-lib-resolver.ts';
29
- import { transpileCanvasSource } from './canvas-pipeline.ts';
28
+ import { realOrSelf } from './canvas-lib-module.ts';
29
+ import { CANVAS_LIB_SPECIFIER, canvasLibPath, canvasLibResolver } from './canvas-lib-resolver.ts';
30
+ import {
31
+ importedModuleScope,
32
+ stampImportedModule,
33
+ transpileCanvasSource,
34
+ } from './canvas-pipeline.ts';
30
35
  import { CanvasBuildError, errorAt, fromBuildLogs, scrubPaths } from './canvas-source/errors.ts';
31
- import { dsResolver, usesDs } from './ds/ds-resolver.ts';
36
+ import { dsResolver, importsDsBoard, usesDs } from './ds/ds-resolver.ts';
32
37
  import type { LocatorMap } from './locator.ts';
33
38
  import { hasMacroImport, macroImportRefusal } from './macro-guard.ts';
34
39
  import { isUnderOrEqual } from './path-containment.ts';
35
40
  import { DEV_SERVER_ROOT } from './paths.ts';
41
+ import { canvasDefines } from './release-build.ts';
36
42
  import { RUNTIME_PACKAGES } from './runtime-bundle.ts';
37
43
  import { injectCompMedia } from './video/inject.ts';
44
+ import { mapVideoObjectFit } from './video/object-fit.ts';
38
45
 
39
46
  // Sanity-check the dev-server-bundled canvas-lib once per process boot. If the
40
47
  // install is corrupt (file missing), surface that before the first canvas build
@@ -81,6 +88,11 @@ export interface CanvasBundleResult {
81
88
  * canvas's board, a canvas the opener cannot read — fails the serve closed.
82
89
  */
83
90
  inputs: string[];
91
+ /**
92
+ * #169 T8.1c — the module imports `@maude/canvas-lib` (the shell's shared module) instead of
93
+ * inlining it. Always false without `BuildCanvasOptions.sharedCanvasLib`.
94
+ */
95
+ sharedLib: boolean;
84
96
  }
85
97
 
86
98
  /** The build's metafile `inputs` as absolute paths (Bun reports them relative to the cwd). */
@@ -93,6 +105,15 @@ function metafileInputs(metafile: { inputs?: Record<string, unknown> } | undefin
93
105
  }
94
106
 
95
107
  export interface BuildCanvasOptions {
108
+ /**
109
+ * #169 T8.1c — leave `@maude/canvas-lib` EXTERNAL: the shell's importmap maps it to the one
110
+ * shared module (canvas-lib-module.ts), so a canvas module carries only its own code. Pass the
111
+ * shared module's `inputs` only when the shell this module is served to carries that mapping.
112
+ * A build that would still inline one of those files (a module the canvas reaches by path, e.g.
113
+ * the DS board's) is redone with canvas-lib inlined — a second copy of a canvas-lib module is a
114
+ * second copy of its state.
115
+ */
116
+ sharedCanvasLib?: { inputs: ReadonlySet<string> };
96
117
  /**
97
118
  * Absolute path to the design root. Per DDR-025 canvas-lib is dev-server
98
119
  * bundled, so this value is no longer required to resolve `@maude/canvas-lib`
@@ -317,13 +338,40 @@ function cssUrlAssets(designRoot: string, base: string): import('bun').BunPlugin
317
338
  /**
318
339
  * Build a single canvas TSX file end-to-end. Identity pass is from
319
340
  * canvas-pipeline.ts; the module pass is Bun.build with React externalised
320
- * and `@maude/canvas-lib` resolved to the dev-server-bundled canvas-lib.
341
+ * and `@maude/canvas-lib` resolved to the dev-server-bundled canvas-lib — or,
342
+ * with `sharedCanvasLib`, left external for the shell's shared module.
321
343
  */
322
344
  export async function buildCanvasModule(
323
345
  canvasAbsPath: string,
324
346
  source: string,
325
347
  options: BuildCanvasOptions = {}
326
348
  ): Promise<CanvasBundleResult> {
349
+ const shared = options.sharedCanvasLib;
350
+ // #169 T8.1c — a DS board imports the board code, which shares canvas-lib's own modules
351
+ // (`canvas-theme.ts`, …) by path: it always inlines, so skip the build that would be thrown away.
352
+ if (!shared || importsDsBoard(source)) {
353
+ return {
354
+ ...(await buildCanvasModuleOnce(canvasAbsPath, source, options, false)),
355
+ sharedLib: false,
356
+ };
357
+ }
358
+ const built = await buildCanvasModuleOnce(canvasAbsPath, source, options, true);
359
+ // A file of the shared module inlined here would be a SECOND instance of its module state beside
360
+ // the shared one (two theme registries, two frame clocks) — redo the build the old way.
361
+ if (!built.inputs.some((p) => shared.inputs.has(p) || shared.inputs.has(realOrSelf(p))))
362
+ return { ...built, sharedLib: true };
363
+ return {
364
+ ...(await buildCanvasModuleOnce(canvasAbsPath, source, options, false)),
365
+ sharedLib: false,
366
+ };
367
+ }
368
+
369
+ async function buildCanvasModuleOnce(
370
+ canvasAbsPath: string,
371
+ source: string,
372
+ options: BuildCanvasOptions,
373
+ shareLib: boolean
374
+ ): Promise<Omit<CanvasBundleResult, 'sharedLib'>> {
327
375
  // gate-b-c4n — a Bun macro import runs at build time, in THIS process (or the sandbox worker):
328
376
  // pass 1's Bun.Transpiler and Bun.build below both evaluate it. Refuse it before either sees the
329
377
  // text; `macroGuard` (first plugin) does the same for every file the bundle loads.
@@ -337,15 +385,17 @@ export async function buildCanvasModule(
337
385
  // S7.5 (V2-1.10 §5.3) — the comp vocabulary's derived data (`__words` on <Captions>, `__speech`
338
386
  // on <Duck>), computed from the comp's clips on disk × their transcripts. Never written to the
339
387
  // file; the transcripts are freshness deps (`videoDepsFor`, access/closure.ts).
340
- const withMedia = injectCompMedia(canvasAbsPath, source, pass1.withIds, {
388
+ const injected = injectCompMedia(canvasAbsPath, source, pass1.withIds, {
341
389
  designRoot: options.restrictImportsTo ?? options.designRoot,
342
390
  }).code;
391
+ // #128 §3 — <Video> reads the `objectFit` PROP and drops `style.objectFit`; map the style to the prop.
392
+ const withMedia = mapVideoObjectFit(canvasAbsPath, injected);
343
393
  // What Bun.build will parse as the entry (pass 1 + the injected comp data), held to the same rule.
344
394
  if (hasMacroImport(withMedia)) throw macroRefused(macroCtx, canvasAbsPath);
345
395
 
346
396
  // Sanity-check the dev-server-bundled canvas-lib once per process — if the
347
397
  // install is corrupt, fail loud before Bun.build collapses plugin throws.
348
- if (/@maude\/canvas-lib/.test(source)) {
398
+ if (!shareLib && /@maude\/canvas-lib/.test(source)) {
349
399
  verifyCanvasLibPresence();
350
400
  }
351
401
 
@@ -364,6 +414,8 @@ export async function buildCanvasModule(
364
414
  // in the bundle). The flatMap legacy alias for `react-dom` is no longer
365
415
  // needed; RUNTIME_PACKAGES already lists every specifier the importmap covers.
366
416
  const externalSpecifiers = new Set<string>(RUNTIME_PACKAGES);
417
+ // #169 T8.1c — the shell's importmap maps it to the shared module (canvas-lib-module.ts).
418
+ if (shareLib) externalSpecifiers.add(CANVAS_LIB_SPECIFIER);
367
419
  const denials: Array<{ specifier: string; reason: string }> = [];
368
420
  const macroRefusals: string[] = [];
369
421
  const allowlist = options.restrictImportsTo
@@ -409,6 +461,8 @@ export async function buildCanvasModule(
409
461
  // dev variant. Both halves of the system MUST agree on the JSX runtime
410
462
  // flavour.
411
463
  'process.env.NODE_ENV': '"production"',
464
+ // #212 §5 — a release server builds release canvases (no still globals on the window)
465
+ ...canvasDefines(),
412
466
  },
413
467
  plugins: [
414
468
  // gate-b-c4n — FIRST, so it reads every file the bundle loads before any other loader
@@ -431,8 +485,9 @@ export async function buildCanvasModule(
431
485
  },
432
486
  },
433
487
  // Resolve `@maude/canvas-lib` BEFORE exact-externals — we want the bare
434
- // specifier to map to the dev-server-bundled lib, not get marked external.
435
- canvasLibResolver(),
488
+ // specifier to map to the dev-server-bundled lib, not get marked external
489
+ // (unless it is shared: then exact-externals below leaves it external).
490
+ ...(shareLib ? [] : [canvasLibResolver()]),
436
491
  // `@maude/ds` — per canvas: the system's override or the defaults, and the system registered
437
492
  ...(options.designRoot && usesDs(source)
438
493
  ? [dsResolver(options.designRoot, canvasAbsPath)]
@@ -465,7 +520,9 @@ export async function buildCanvasModule(
465
520
  // After the allowlist: only an override whose file is gone today, already judged above.
466
521
  ...(overrides ? [overrides.resolveMissing] : []),
467
522
  // p8-c4 — LAST: answers every remaining file load with the bytes it checked (no re-read).
468
- macroPinnedLoad(macroRefusals, macroCtx.designRoot),
523
+ macroPinnedLoad(macroRefusals, macroCtx.designRoot, {
524
+ stampImportedUnder: macroCtx.designRoot,
525
+ }),
469
526
  ],
470
527
  });
471
528
 
@@ -842,7 +899,18 @@ const BINARY_LOADERS = new Set(['file', 'dataurl', 'base64']);
842
899
  * for whatever is left it reads the file ONCE, checks those bytes and hands Bun exactly those bytes
843
900
  * with the loader Bun chose. What Bun parses is what was checked. Exported for the unit test.
844
901
  */
845
- export function macroPinnedLoad(refusals: string[], designRoot: string): import('bun').BunPlugin {
902
+ export function macroPinnedLoad(
903
+ refusals: string[],
904
+ designRoot: string,
905
+ /**
906
+ * #151 §3 — also stamp the JSX of the local modules a canvas imports (canvas-pipeline.ts
907
+ * `stampImportedModule`): the files under this root, but not the design system's (`system/` is
908
+ * selected as an instance) nor runtime state (`_*`) nor anything vendored. The stamp is made on
909
+ * the very bytes that were just checked.
910
+ */
911
+ options: { stampImportedUnder?: string } = {}
912
+ ): import('bun').BunPlugin {
913
+ const stampRoot = options.stampImportedUnder ? realRoot(options.stampImportedUnder) : null;
846
914
  return {
847
915
  name: 'maude-macro-pinned-load',
848
916
  setup(builder) {
@@ -864,8 +932,13 @@ export function macroPinnedLoad(refusals: string[], designRoot: string): import(
864
932
  refusals.push(reason);
865
933
  throw new Error(reason);
866
934
  }
935
+ const stamped =
936
+ stampRoot && (loader === 'tsx' || loader === 'jsx')
937
+ ? importedModuleScope(args.path, stampRoot)
938
+ : null;
939
+ const contents = stamped ? stampImportedModule(args.path, text, stamped) : null;
867
940
  return {
868
- contents: BINARY_LOADERS.has(loader) ? bytes : text,
941
+ contents: contents ?? (BINARY_LOADERS.has(loader) ? bytes : text),
869
942
  loader: loader as import('bun').Loader,
870
943
  };
871
944
  }
@@ -874,6 +947,15 @@ export function macroPinnedLoad(refusals: string[], designRoot: string): import(
874
947
  };
875
948
  }
876
949
 
950
+ /** `root` as Bun reports file paths (macOS `/tmp` is `/private/tmp`). */
951
+ function realRoot(root: string): string {
952
+ try {
953
+ return realpathSync(root);
954
+ } catch {
955
+ return path.resolve(root);
956
+ }
957
+ }
958
+
877
959
  function loaderForExt(file: string): string | null {
878
960
  const ext = path.extname(file).toLowerCase();
879
961
  if (ext === '.tsx' || ext === '.jsx' || ext === '.ts' || ext === '.css' || ext === '.json')
@@ -40,8 +40,14 @@ import {
40
40
  import { createRoot } from 'react-dom/client';
41
41
  import { acceptFromShell } from './bridge/dgn-protocol.ts';
42
42
  import { annotationElement, annotationIdAt, clientToWorld } from './comment-anchor.ts';
43
+ import {
44
+ cancelReattach,
45
+ listenForReattach,
46
+ pendingReattach,
47
+ pickForReattach,
48
+ } from './comment-reattach.ts';
43
49
  import { CommentsOverlay } from './comments-overlay.tsx';
44
- import { deriveFile, hoverTargetToSelection } from './dom-selection.ts';
50
+ import { commentSelectionFor, deriveFile, hoverTargetToSelection } from './dom-selection.ts';
45
51
  import { frameCaf, frameRaf } from './frame-clock.ts';
46
52
  import {
47
53
  type HoverTarget,
@@ -162,6 +168,25 @@ function CommentHost({ children, file }: { children: ReactNode; file: string | u
162
168
  if (tool !== 'comment') setHoverEl(null);
163
169
  }, [tool]);
164
170
 
171
+ // #151 D5 — "Re-attach to element": the thread card asks, the next comment-tool click names the
172
+ // element (dropComment hands it to the overlay instead of opening a composer). The tool is armed
173
+ // for that one click and put back after it; Esc or a closed thread ends the wait.
174
+ const armedForReattach = useRef(false);
175
+ useEffect(
176
+ () =>
177
+ listenForReattach(
178
+ () => {
179
+ armedForReattach.current = toolRef.current !== 'comment';
180
+ setTool('comment');
181
+ },
182
+ () => {
183
+ if (armedForReattach.current) setTool('move');
184
+ armedForReattach.current = false;
185
+ }
186
+ ),
187
+ [setTool]
188
+ );
189
+
165
190
  // feature-element-editing-robustness Stage E — element SELECT on a bare
166
191
  // specimen. `selectedEl` drives the selection halo; `isSpecimen` gates the
167
192
  // resize overlay so it mounts on specimens ONLY (a UI canvas already mounts
@@ -260,8 +285,9 @@ function CommentHost({ children, file }: { children: ReactNode; file: string | u
260
285
  setHoverEl((prev) => (prev === el ? prev : el));
261
286
  },
262
287
  onTool: ({ tool: t }) => setTool(t),
263
- onEscape: () =>
264
- commentMountEscape(isBareSpecimen(), () => {
288
+ onEscape: () => {
289
+ if (pendingReattach() !== null) cancelReattach();
290
+ return commentMountEscape(isBareSpecimen(), () => {
265
291
  if (toolRef.current !== 'move') setTool('move');
266
292
  setHoverEl(null);
267
293
  selSet.clear();
@@ -272,8 +298,17 @@ function CommentHost({ children, file }: { children: ReactNode; file: string | u
272
298
  /* parent detached */
273
299
  }
274
300
  }
275
- }),
276
- onDropComment: ({ clientX, clientY }) => dropComment(clientX, clientY, selSet, file),
301
+ });
302
+ },
303
+ onDropComment: ({ clientX, clientY }) => {
304
+ const waiting = pendingReattach() !== null;
305
+ dropComment(clientX, clientY, selSet, file);
306
+ // The one click was taken as the new anchor: the tool we armed for it goes back.
307
+ if (waiting && pendingReattach() === null && armedForReattach.current) {
308
+ armedForReattach.current = false;
309
+ setTool('move');
310
+ }
311
+ },
277
312
  },
278
313
  });
279
314
 
@@ -423,6 +458,8 @@ function dropComment(
423
458
  // artboards, so what the user clicked is the annotation, not the element
424
459
  // underneath it.
425
460
  const annotationId = annotationIdAt(clientX, clientY);
461
+ // A re-attach waits for an ELEMENT: a click on a board object names none, so it is not taken.
462
+ if (annotationId && pendingReattach() !== null) return;
426
463
  if (annotationId) {
427
464
  const el = annotationElement(annotationId);
428
465
  const r = el?.getBoundingClientRect();
@@ -478,6 +515,8 @@ function dropComment(
478
515
  if (el) target = { el, cdId: el.getAttribute('data-cd-id'), artboardId: null };
479
516
  }
480
517
 
518
+ if (!target && pendingReattach() !== null) return; // dead space is no element — keep waiting
519
+
481
520
  if (!target) {
482
521
  // Floating comment — no element anchor, just the click point (e.g. a click
483
522
  // on empty canvas/specimen dead space). The overlay renders the pin at the
@@ -500,9 +539,15 @@ function dropComment(
500
539
  return;
501
540
  }
502
541
 
503
- const sel = hoverTargetToSelection(target, file);
504
- selSet.replace(sel);
505
- openComposer(sel, clientX, clientY);
542
+ // The comment's anchor, not the plain selection: a real element path when the element has no
543
+ // data-cd-id, and the click's world point so the pin follows pan and zoom (#151).
544
+ // The SELECTION stays what a plain pick makes (an uninstrumented element is a whole-artboard pick to
545
+ // the halo and Delete); only the composer carries the comment anchor.
546
+ const anchor = commentSelectionFor(target, clientX, clientY, file);
547
+ // "Re-attach to element" is waiting for this click: it names the element, there is no new comment.
548
+ if (pickForReattach(anchor, clientX, clientY)) return;
549
+ selSet.replace(hoverTargetToSelection(target, file));
550
+ openComposer(anchor, clientX, clientY);
506
551
  }
507
552
 
508
553
  function openComposer(selection: Selection, clientX: number, clientY: number): void {
@@ -2000,6 +2000,15 @@ function collectNumericConsts(program: AnyNode): Record<string, number> {
2000
2000
  }
2001
2001
 
2002
2002
  /** Resolve a numeric JSX attribute (`from={20}` / `durationInFrames={A}`). */
2003
+ /** A literal string prop: `name="x"` or `name={"x"}`. */
2004
+ function stringAttr(opening: AnyNode, name: string): string | null {
2005
+ let v = findAttribute(opening, name)?.value;
2006
+ if (v?.type === 'JSXExpressionContainer') v = v.expression;
2007
+ return (v?.type === 'Literal' || v?.type === 'StringLiteral') && typeof v.value === 'string'
2008
+ ? v.value
2009
+ : null;
2010
+ }
2011
+
2003
2012
  function numAttr(opening: AnyNode, name: string, consts: Record<string, number>): number | null {
2004
2013
  const a = findAttribute(opening, name);
2005
2014
  let v = a?.value;
@@ -2468,6 +2477,9 @@ export interface ClipInfo {
2468
2477
  filter: string | null;
2469
2478
  /** Crop/reposition wrapper marker (`data-mframe="scale,x,y"`). */
2470
2479
  framing: { scale: number; x: number; y: number } | null;
2480
+ /** #128 §5 — the fit the media declares: the `objectFit` PROP, else a literal `style.objectFit` (the build maps
2481
+ * it to the prop, T1.2). Null = not declared, which a `<Video>` renders as `contain`. */
2482
+ objectFit: string | null;
2471
2483
  } | null;
2472
2484
  /** S7.10 — the title's entrance (`<TitleMotion preset frames>` around its content), read as literal text
2473
2485
  * like `data-mframe`; null when the clip has none. The clip inspector's Motion row shows it. */
@@ -2683,6 +2695,7 @@ export function enumerateClips(
2683
2695
  if (direct) {
2684
2696
  const mo = direct.openingElement;
2685
2697
  let filter: string | null = null;
2698
+ let styleFit: string | null = null;
2686
2699
  const st = findAttribute(mo, 'style');
2687
2700
  if (
2688
2701
  st?.value?.type === 'JSXExpressionContainer' &&
@@ -2696,6 +2709,12 @@ export function enumerateClips(
2696
2709
  ) {
2697
2710
  filter = String(p.value.value);
2698
2711
  }
2712
+ if (
2713
+ key === 'objectFit' &&
2714
+ (p.value?.type === 'Literal' || p.value?.type === 'StringLiteral')
2715
+ ) {
2716
+ styleFit = String(p.value.value);
2717
+ }
2699
2718
  }
2700
2719
  }
2701
2720
  let framing: { scale: number; x: number; y: number } | null = null;
@@ -2708,6 +2727,7 @@ export function enumerateClips(
2708
2727
  trimBefore: numAttr(mo, 'trimBefore', consts) ?? numAttr(mo, 'startFrom', consts),
2709
2728
  filter,
2710
2729
  framing,
2730
+ objectFit: stringAttr(mo, 'objectFit') ?? styleFit,
2711
2731
  };
2712
2732
  }
2713
2733
  return {
@@ -6244,7 +6264,20 @@ if (import.meta.main) {
6244
6264
  try {
6245
6265
  const { abs: canvas, rel } = resolveCliCanvas(arg);
6246
6266
  const before = await Bun.file(canvas).text();
6247
- const after = applyEdit(canvas, before, id, attr, value).source;
6267
+ let after: string;
6268
+ try {
6269
+ after = applyEdit(canvas, before, id, attr, value).source;
6270
+ } catch (e) {
6271
+ // #151 T2.3b — an element of a module the canvas imports: selectable, edit-read-only. Name the
6272
+ // file (the AI can edit it directly) instead of "not found in <abs path>".
6273
+ if (e instanceof CanvasEditError) {
6274
+ const { moduleOwningId, moduleRefusalForAi } = await import('./imported-module-ids.ts');
6275
+ const designRoot = path.resolve(canvas, ...rel.split('/').map(() => '..'));
6276
+ const module = moduleOwningId(canvas, designRoot, id);
6277
+ if (module) throw new CliRefusal(moduleRefusalForAi(module), 1);
6278
+ }
6279
+ throw e;
6280
+ }
6248
6281
  assertCliEditUnlocked(rel, before, after);
6249
6282
  // p8-a1-claims — inside a Maude chat these bytes are claimed for its run before they land
6250
6283
  // (bin/_write-claim.mjs); a person's own save meanwhile is different bytes and stays theirs
@@ -0,0 +1,210 @@
1
+ // #169 T8.1c — `@maude/canvas-lib` as ONE shared browser module (decision v2-2.17-version-picture-
2
+ // budget-open: "the lever is smaller canvas modules — share canvas-lib").
3
+ //
4
+ // Every canvas module used to inline the whole canvas library (~2.3 MB of the ~2.4 MB a canvas
5
+ // module weighs), so each canvas frame and each version picture fetched, parsed and evaluated its
6
+ // own copy. It is now built once per server (per chrome edit) and served beside the runtime bundles
7
+ // at `/_canvas-runtime/canvas-lib.<hash>.js`; the shell's importmap maps the bare specifier to it,
8
+ // and a canvas build leaves the specifier external (canvas-build.ts `sharedCanvasLib`).
9
+ //
10
+ // Why `/_canvas-runtime/` and not a new route: it IS runtime — Maude's own code, with no project
11
+ // content in it — and that prefix is already in every canvas-origin list with the same meaning
12
+ // (`CANVAS_SAFE_API`'s prefix rule, `framelessAllowed`, the capture origin's GET-only gate), so the
13
+ // shared module adds no route and no allowlist entry. It cannot join the committed `dist/runtime`
14
+ // bundles: it is source, rebuilt when the studio's own files change.
15
+ //
16
+ // The hash in the URL is the content's, so the answer is immutable: a frame on a canvas-lib edit is
17
+ // reloaded with a new shell (new importmap), never handed different bytes under the same URL. The
18
+ // last few builds stay servable, so a shell loaded just before an edit still finds its module.
19
+ //
20
+ // One module instance per document is also what canvas-lib's module state was written for: the
21
+ // soft reload re-imports only the canvas, so the live camera (`liveViewport`) outlives the remount.
22
+
23
+ import { realpathSync } from 'node:fs';
24
+ import path from 'node:path';
25
+
26
+ import { canvasLibPath } from './canvas-lib-resolver.ts';
27
+ import { canvasDefines } from './release-build.ts';
28
+ import { RUNTIME_PACKAGES } from './runtime-bundle.ts';
29
+
30
+ export interface SharedCanvasLib {
31
+ /** Module bytes (UTF-8). */
32
+ bytes: Uint8Array<ArrayBuffer>;
33
+ /** Content hash (hex) — the URL key and the ETag. */
34
+ hash: string;
35
+ /** The URL the shell's importmap names, relative to the shell document. */
36
+ url: string;
37
+ /** Every file the module bundled, absolute real paths. A canvas bundle may inline none of them. */
38
+ inputs: ReadonlySet<string>;
39
+ /**
40
+ * #169 item 1 — the runtime packages the module imports STATICALLY (bare specifiers). The shell
41
+ * preloads them with the module itself, so the browser fetches the whole graph at once instead of
42
+ * one level per round trip (canvas → canvas-lib → remotion …). Absent = preload the module only.
43
+ */
44
+ staticImports?: readonly string[];
45
+ }
46
+
47
+ /** `/_canvas-runtime/<slug>` of the shared module (the hash is hex). */
48
+ export const SHARED_LIB_SLUG_RE = /^canvas-lib\.([0-9a-f]{8,32})\.js$/;
49
+
50
+ const KEEP = 3;
51
+ const served = new Map<string, SharedCanvasLib>();
52
+ let current: Promise<SharedCanvasLib> | null = null;
53
+ let builder: () => Promise<SharedCanvasLib> = buildSharedCanvasLib;
54
+
55
+ /**
56
+ * The shared module for the studio's canvas-lib as it is now: built on first use, then reused until
57
+ * `invalidateSharedCanvasLib`. A failed build stays failed until then, so a shell and the canvas
58
+ * builds of one chrome version agree on whether the module exists.
59
+ */
60
+ export function sharedCanvasLib(): Promise<SharedCanvasLib> {
61
+ if (!current) {
62
+ current = builder().then((lib) => {
63
+ served.delete(lib.hash);
64
+ served.set(lib.hash, lib);
65
+ while (served.size > KEEP) served.delete(served.keys().next().value as string);
66
+ return lib;
67
+ });
68
+ current.catch(() => {});
69
+ }
70
+ return current;
71
+ }
72
+
73
+ /** The studio's own source changed (http.ts chrome watchers): the next use rebuilds. */
74
+ export function invalidateSharedCanvasLib(): void {
75
+ current = null;
76
+ }
77
+
78
+ /** A built module by the hash in its URL — the current one or one of the last few. */
79
+ export function sharedCanvasLibByHash(hash: string): SharedCanvasLib | null {
80
+ return served.get(hash) ?? null;
81
+ }
82
+
83
+ /** @internal Test seam — swap the builder (and forget every build). */
84
+ export function setSharedCanvasLibBuilderForTest(
85
+ fn: (() => Promise<SharedCanvasLib>) | null
86
+ ): void {
87
+ builder = fn ?? buildSharedCanvasLib;
88
+ served.clear();
89
+ current = null;
90
+ }
91
+
92
+ async function buildSharedCanvasLib(): Promise<SharedCanvasLib> {
93
+ const externals = new Set<string>(RUNTIME_PACKAGES);
94
+ const built = await Bun.build({
95
+ entrypoints: [canvasLibPath()],
96
+ target: 'browser',
97
+ format: 'esm',
98
+ splitting: false,
99
+ throw: false,
100
+ metafile: true,
101
+ // Whitespace + syntax only: identifiers keep their names (component names, `fn.name`), and the
102
+ // build's `// <path>` comments — the install path — do not reach the canvas origin.
103
+ minify: { whitespace: true, syntax: true, identifiers: false },
104
+ // The canvas builds' own defines (canvas-build.ts): both halves agree on the JSX runtime flavour.
105
+ define: { 'process.env.NODE_ENV': '"production"', ...canvasDefines() },
106
+ plugins: [
107
+ {
108
+ name: 'runtime-externals',
109
+ setup(b) {
110
+ b.onResolve({ filter: /.*/ }, (args) =>
111
+ externals.has(args.path) ? { path: args.path, external: true } : null
112
+ );
113
+ },
114
+ },
115
+ ],
116
+ });
117
+ if (!built.success) {
118
+ throw new Error(
119
+ `[@maude/canvas-lib] shared module build failed: ${built.logs.map((l) => l.message).join('\n')}`
120
+ );
121
+ }
122
+ const js = built.outputs.find((o) => o.kind === 'entry-point');
123
+ if (!js || built.outputs.length !== 1) {
124
+ // A second output (a stylesheet, a chunk) would be bytes no canvas loads: never serve a
125
+ // half-module. The caller falls back to inlining canvas-lib into each canvas.
126
+ throw new Error('[@maude/canvas-lib] shared module build produced more than one output');
127
+ }
128
+ const bytes = new Uint8Array(await js.arrayBuffer());
129
+ const hash = Bun.hash(bytes).toString(16).padStart(16, '0');
130
+ const inputs = new Set<string>();
131
+ for (const key of Object.keys(built.metafile?.inputs ?? {})) {
132
+ inputs.add(realOrSelf(path.isAbsolute(key) ? key : path.resolve(process.cwd(), key)));
133
+ }
134
+ // Bun's metafile lists no external imports, so they are read off the module: `import … from "x"`
135
+ // / `import "x"` (never `import("x")`, which loads on demand), kept to the runtime packages.
136
+ const staticImports = new Set<string>();
137
+ const text = new TextDecoder().decode(bytes);
138
+ for (const m of text.matchAll(STATIC_IMPORT_RE)) {
139
+ if (externals.has(m[1] as string)) staticImports.add(m[1] as string);
140
+ }
141
+ return {
142
+ bytes,
143
+ hash,
144
+ url: `./_canvas-runtime/canvas-lib.${hash}.js`,
145
+ inputs,
146
+ staticImports: [...staticImports].sort(),
147
+ };
148
+ }
149
+
150
+ /** `p` resolved through symlinks (a missing file as given) — both sides of the overlap check. */
151
+ export function realOrSelf(p: string): string {
152
+ try {
153
+ return realpathSync(p);
154
+ } catch {
155
+ return p;
156
+ }
157
+ }
158
+
159
+ const IMPORTMAP_RE = /(<script type="importmap">\s*)([\s\S]*?)(\s*<\/script>)/;
160
+
161
+ /**
162
+ * The shell with `@maude/canvas-lib` mapped to the shared module. Applied before the CSP hashes the
163
+ * inline scripts (http.ts `serveCanvasShell`), so the policy matches what is served. A shell whose
164
+ * importmap cannot be read is returned unchanged (its canvases then fail to load the specifier,
165
+ * which the canvas builds never emit without this mapping — see http.ts `sharedLibForCanvas`).
166
+ *
167
+ * #169 item 1 — also preloads the module and the runtime packages it imports statically
168
+ * (`staticImports`, by default the served build's own list), right after the importmap: a version
169
+ * picture otherwise waited one round trip per import level before React could mount. Only
170
+ * `./_canvas-runtime/*.js` URLs the importmap names are preloaded (Maude's own code, served without a
171
+ * frame capability), and none the shell already preloads.
172
+ */
173
+ export function withSharedCanvasLib(
174
+ shellHtml: string,
175
+ url: string,
176
+ staticImports: readonly string[] = staticImportsOf(url)
177
+ ): string {
178
+ const m = IMPORTMAP_RE.exec(shellHtml);
179
+ if (!m) return shellHtml;
180
+ let map: { imports?: Record<string, string> };
181
+ try {
182
+ map = JSON.parse(m[2] as string);
183
+ } catch {
184
+ return shellHtml;
185
+ }
186
+ const imports: Record<string, string> = { ...(map.imports ?? {}), '@maude/canvas-lib': url };
187
+ const next = { ...map, imports };
188
+ const have = new Set([...shellHtml.matchAll(PRELOAD_RE)].map((p) => p[1]));
189
+ const links: string[] = [];
190
+ for (const href of [url, ...staticImports.map((s) => imports[s])]) {
191
+ if (typeof href !== 'string' || !RUNTIME_URL_RE.test(href) || have.has(href)) continue;
192
+ have.add(href);
193
+ links.push(`\n <link rel="modulepreload" href="${href}" />`);
194
+ }
195
+ return shellHtml.replace(
196
+ IMPORTMAP_RE,
197
+ (_all, open: string, _body: string, close: string) =>
198
+ `${open}${JSON.stringify(next, null, 2)}${close}${links.join('')}`
199
+ );
200
+ }
201
+
202
+ const STATIC_IMPORT_RE = /\bimport\s*(?:[\w$*{}\s,]+?\s*from\s*)?"([^"]+)"/g;
203
+ const PRELOAD_RE = /<link rel="modulepreload" href="([^"]+)"/g;
204
+ const RUNTIME_URL_RE = /^\.\/_canvas-runtime\/[A-Za-z0-9@._-]+\.js$/;
205
+
206
+ /** The static runtime imports of a served build, by the hash in its URL (none if unknown). */
207
+ function staticImportsOf(url: string): readonly string[] {
208
+ const hash = SHARED_LIB_SLUG_RE.exec(url.slice(url.lastIndexOf('/') + 1))?.[1];
209
+ return (hash ? served.get(hash)?.staticImports : undefined) ?? [];
210
+ }
@@ -140,7 +140,7 @@ import { frameCaf, frameRaf, setFrameFreeze } from './frame-clock.ts';
140
140
  import { pressStartsPan } from './input-router.tsx';
141
141
  import { summaryWords } from './kinds/warnings.ts';
142
142
  import { presentHidesCss, usePresentStage } from './present/present-stage.tsx';
143
- import { usePreviewCamera, usePreviewing } from './preview/preview-camera.tsx';
143
+ import { usePreviewing, usePreviewMark } from './preview/preview-camera.tsx';
144
144
  import { previewWheelPassthrough } from './preview/wheel-scroll.ts';
145
145
  import type { ArtboardPrintProp } from './print/units.ts';
146
146
  import { useGovernedMode } from './use-governed-mode.ts';
@@ -2663,17 +2663,8 @@ function DesignCanvasInner({ children, controls }: DesignCanvasProps) {
2663
2663
  onSpaceTap: () => playSelectedVideos(document, tapSelRef.current?.selected),
2664
2664
  });
2665
2665
 
2666
- // S3.9 — Edit ⇄ Preview: the camera eases onto the artboard in view, once (preview/preview-camera.tsx).
2667
- usePreviewCamera({
2668
- hostRef,
2669
- artboards,
2670
- controller,
2671
- getCamera: getLiveViewport,
2672
- fit: (rect) => {
2673
- const host = hostRef.current;
2674
- return host ? computeFit([rect], host, 24, canvasInsets()) : { x: 0, y: 0, zoom: 1 };
2675
- },
2676
- });
2666
+ // Edit ⇄ Preview marks the document (`html[data-maude-preview]`); the camera never moves (TD1d, preview/preview-camera.tsx).
2667
+ usePreviewMark();
2677
2668
 
2678
2669
  // V2-1.2 §5.6 I2 — boot re-fit, once only. The shell's first `occluded-insets` usually lands after
2679
2670
  // the boot fit (the runtime listener installs after `loaded`), which would leave a fresh canvas fitted