@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
@@ -36,10 +36,10 @@ export function resolveObjectKey(e: KeyEventLike, s: ObjectKeyState): ObjectOpAc
36
36
  return (r?.action.id as ObjectOpAction | undefined) ?? null;
37
37
  }
38
38
 
39
- // V2-clipboard-objects — ⌘C / ⌘X on an object selection, ⌘C on an artboard selection (Edit mode). ⌘V is
40
- // WebKit's own paste event (editing/clipboard.ts), so it has no chord here.
41
- type ClipKeyAction = 'object.copy' | 'object.cut' | 'artboard.copy';
42
- const CLIP_KEYS = canvasKeyIndex(['object.copy', 'object.cut', 'artboard.copy']);
39
+ // V2-clipboard-objects — ⌘C / ⌘X on an object selection, ⌘C / ⌘X on an artboard selection (Edit mode; #122
40
+ // added the artboard cut). ⌘V is WebKit's own paste event (editing/clipboard.ts), so it has no chord here.
41
+ type ClipKeyAction = 'object.copy' | 'object.cut' | 'artboard.copy' | 'artboard.cut';
42
+ const CLIP_KEYS = canvasKeyIndex(['object.copy', 'object.cut', 'artboard.copy', 'artboard.cut']);
43
43
 
44
44
  /** The clipboard action a keydown runs, or null. */
45
45
  export function resolveClipKey(e: KeyEventLike, s: ObjectKeyState): ClipKeyAction | null {
@@ -8,12 +8,13 @@
8
8
  // Bring to front ⌘] · Bring forward ] · Send backward [ · Send to back ⌘[
9
9
  // Lock ⇧⌘L (Unlock) · Hide (Show)
10
10
  // Version history of this object (one object)
11
- // Advanced ▸ Add comment · Inspect · Select layer ▸ · Insert ▸ · Replace image… · Edit Photo… ·
11
+ // Advanced ▸ Inspect · Select layer ▸ · Insert ▸ · Replace image… · Edit Photo… ·
12
12
  // Convert children to absolute position · Copy CSS · Copy data-cd-id ·
13
13
  // Export selection… · Deselect
14
14
  // Remove ⌫
15
15
  //
16
- // Ask AI about “<name>” ⌘/ opens the list (S2.22; it runs `ai.ask-selection` through the ask bubble). Cut / Copy /
16
+ // Ask AI about “<name>” ⌘/ opens the list, Add comment C right under it (#163, Michal: the main group, no
17
+ // longer under Advanced ▸) (S2.22; it runs `ai.ask-selection` through the ask bubble). Cut / Copy /
17
18
  // Paste are the object clipboard (V2-clipboard-objects, editing/clipboard.ts: edit-ops, the clipboard in the shell).
18
19
  // "Nothing deleted": every v1 row is either in the main list or under Advanced ▸ (D6). Pure over the item
19
20
  // structure — testable without a DOM.
@@ -45,7 +46,14 @@ export function objectNameOf(els: readonly Element[]): string | null {
45
46
  return el.tagName.toLowerCase();
46
47
  }
47
48
 
48
- const MAIN = new Set(['duplicate-element', 'copy-style', 'paste-style', 'delete-element', 'hide']);
49
+ const MAIN = new Set([
50
+ 'add-comment',
51
+ 'duplicate-element',
52
+ 'copy-style',
53
+ 'paste-style',
54
+ 'delete-element',
55
+ 'hide',
56
+ ]);
49
57
 
50
58
  // ── what the rows say about the selection ─────────────────────────────────────────────────────
51
59
 
@@ -130,6 +138,8 @@ export function objectMenuSections(v1: MenuSection[], deps: ObjectMenuDeps): Men
130
138
  icon: 'spark',
131
139
  onSelect: () => window.dispatchEvent(new CustomEvent(ASK_OBJECTS_EVENT)),
132
140
  },
141
+ // #163 — the v1 row as it was (id, label, C, handler); absent when the role's v1 menu has none
142
+ ...reuse('add-comment', { icon: 'comment' }),
133
143
  ],
134
144
  [
135
145
  ...(deps.clip
@@ -107,6 +107,36 @@ interface Drag {
107
107
  at: Pt;
108
108
  }
109
109
 
110
+ // Point editing outlives the remount its own write causes: each edit writes the file, and the soft reload re-renders
111
+ // the canvas from it a beat later (~100 ms with the shared canvas-lib) — a fresh subtree whose svg is a new node and
112
+ // whose selection is empty. The path and the selected point are held here, beside the module (one shared canvas-lib
113
+ // per page), and a freshly mounted editor resumes on them once. ↵ / esc / leaving drops the hold.
114
+ const RESUME_MS = 3000;
115
+ let resume: { ref: ElementRef; sel: PointRef | null; until: number } | null = null;
116
+
117
+ /** Hold point editing on `ref` (with `sel` selected) for a remount within RESUME_MS of `now`. */
118
+ export function holdPointEdit(
119
+ ref: ElementRef,
120
+ sel: PointRef | null,
121
+ now: number = Date.now()
122
+ ): void {
123
+ resume = { ref, sel, until: now + RESUME_MS };
124
+ }
125
+
126
+ /** The path svg `ref` names in `doc`, or null. */
127
+ function pathSvgOf(doc: Document, ref: ElementRef): Element | null {
128
+ for (const el of Array.from(doc.querySelectorAll(PATH_SELECTOR))) {
129
+ const r = refOfElement(el);
130
+ if (
131
+ r?.artboard === ref.artboard &&
132
+ r.element === ref.element &&
133
+ (r.occurrence ?? 0) === (ref.occurrence ?? 0)
134
+ )
135
+ return el;
136
+ }
137
+ return null;
138
+ }
139
+
110
140
  export function PointEdit({ readOnly = false }: { readOnly?: boolean }) {
111
141
  const tm = useToolModeOptional();
112
142
  const tool = tm?.tool;
@@ -136,6 +166,7 @@ export function PointEdit({ readOnly = false }: { readOnly?: boolean }) {
136
166
 
137
167
  // `republish`: the path stays the selection (↵ / esc), so the shell is told the point is gone
138
168
  const leave = useCallback((republish = false) => {
169
+ resume = null;
139
170
  const svg = editRef.current?.svg;
140
171
  if (svg) {
141
172
  setPenPoint(svg, null);
@@ -145,6 +176,33 @@ export function PointEdit({ readOnly = false }: { readOnly?: boolean }) {
145
176
  setDrag(null);
146
177
  }, []);
147
178
 
179
+ // A fresh editor (the reload after this editor's own write remounted it) resumes on the held path, once.
180
+ useEffect(() => {
181
+ if (readOnly || typeof document === 'undefined') return;
182
+ let timer: ReturnType<typeof setTimeout> | undefined;
183
+ const tryResume = () => {
184
+ const r = resume;
185
+ if (!r || r.until <= Date.now()) {
186
+ resume = null;
187
+ return;
188
+ }
189
+ const svg = pathSvgOf(document, r.ref);
190
+ // the canvas may still be mounting its new subtree
191
+ if (!svg) {
192
+ timer = setTimeout(tryResume, 50);
193
+ return;
194
+ }
195
+ resume = null;
196
+ const model = modelOfSvg(svg);
197
+ if (!model || isLockedDom(svg)) return;
198
+ const sel = r.sel && model.subs[r.sel.sub]?.points[r.sel.i] ? r.sel : null;
199
+ ctx.current.selSet.replace(selectionOf(svg));
200
+ setEdit({ svg, ref: refOfElement(svg) ?? r.ref, model, sel });
201
+ };
202
+ tryResume();
203
+ return () => clearTimeout(timer);
204
+ }, [readOnly]);
205
+
148
206
  // Double-click a Pen path to edit its points.
149
207
  useEffect(() => {
150
208
  if (readOnly || typeof document === 'undefined') return;
@@ -228,6 +286,9 @@ export function PointEdit({ readOnly = false }: { readOnly?: boolean }) {
228
286
  const rec = editOpRecord(r.writeId, 'Edit path');
229
287
  if (rec) ctx.current.undo?.record(rec);
230
288
  }
289
+ // the write remounts the canvas a beat later: still editing this path → the fresh editor resumes on it
290
+ const cur = editRef.current;
291
+ if (cur && cur.svg === e.svg) holdPointEdit(cur.ref, cur.sel);
231
292
  return r;
232
293
  }, []);
233
294
 
@@ -45,6 +45,17 @@ export function ensureTextRingStyle(doc: Document = document): void {
45
45
  doc.head.appendChild(el);
46
46
  }
47
47
 
48
+ /**
49
+ * What a keydown means while a text is being edited where it stands. Esc keeps the typed words for every text,
50
+ * as Figma does (#163): it ends the edit and saves, it never puts the old text back — Undo is the way back.
51
+ * Enter (no Shift) ends the edit by blurring, which saves too.
52
+ */
53
+ export function textEditKey(e: { key: string; shiftKey?: boolean }): 'commit' | 'blur' | 'none' {
54
+ if (e.key === 'Escape') return 'commit';
55
+ if (e.key === 'Enter' && !e.shiftKey) return 'blur';
56
+ return 'none';
57
+ }
58
+
48
59
  export interface TieArc {
49
60
  /** the index of the space in the element's text */
50
61
  at: number;
@@ -0,0 +1,425 @@
1
+ // editing/video-frame-handle.tsx — #128 §5 (T3.6b): move and zoom the selected video clip's picture on the canvas.
2
+ //
3
+ // Enter the clip inspector's "Move on canvas", or ⌘K (`video.frame-handle`) with a picture clip selected in the
4
+ // Timeline. The SHELL names the clip (`video-frame-handle`: its artboard, its source size, the zoom and the
5
+ // focus the renderer shows at the playhead); this file only draws and measures.
6
+ // In a frame over the artboard's video, the whole picture's outline beyond it and four corner handles. Drag the
7
+ // picture to move it inside the frame; drag a corner to zoom (the opposite corner stays); the wheel or a
8
+ // trackpad pinch over the frame zooms about its centre and never moves the canvas camera.
9
+ // Out each drag (or a wheel run once it settles) is ONE `video-frame-commit` to the shell, which writes it as one
10
+ // `video.reframe` through the Timeline's clip pipe — the inspector's Zoom / Focus write, so undo, the toast
11
+ // and a refusal are the same. Leaving is the same action again, or selecting something else.
12
+ //
13
+ // `<Video>` is no `data-cd-id` element, so crop mode (crop-mode.tsx) can not take it; the arithmetic is crop mode's
14
+ // (crop-geometry.ts). A `<Reframe>` centres the output window on the focus, clamped to the picture, and draws the picture
15
+ // at cover × zoom — which is exactly crop mode's `object-position` rule, so a focus is converted to crop mode's X / Y and
16
+ // back (the focus is the picture point under the frame's centre). Nothing is written while the pointer is down, and a
17
+ // read-only canvas never draws the handle.
18
+
19
+ import { type ReactElement, useCallback, useEffect, useRef, useState } from 'react';
20
+ import { acceptFromShell } from '../bridge/dgn-protocol.ts';
21
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
22
+ import {
23
+ type Corner,
24
+ type Crop,
25
+ cornerPoint,
26
+ coverSize,
27
+ dragCorner,
28
+ pan,
29
+ pictureRect,
30
+ type Size,
31
+ ZOOM_MAX,
32
+ ZOOM_MIN,
33
+ } from './crop-geometry.ts';
34
+
35
+ type Focus = [number, number];
36
+
37
+ export interface FrameBox {
38
+ left: number;
39
+ top: number;
40
+ w: number;
41
+ h: number;
42
+ }
43
+
44
+ interface Want {
45
+ artboardId: string;
46
+ stableId: string;
47
+ label: string;
48
+ src: Size | null;
49
+ zoom: number;
50
+ focus: Focus;
51
+ }
52
+
53
+ const clamp = (n: number, lo: number, hi: number): number => Math.min(hi, Math.max(lo, n));
54
+ const r4 = (n: number): number => Math.round(n * 10000) / 10000;
55
+ const NO_ROOM = 0.01;
56
+
57
+ // ── the arithmetic ─────────────────────────────────────────────────────────────────────────
58
+
59
+ /** The crop (crop mode's zoom + X / Y %) whose picture is the `<Reframe>` box for this zoom and focus. */
60
+ export function cropOfFocus(
61
+ box: Size,
62
+ src: Size,
63
+ zoom: number,
64
+ focus: readonly [number, number]
65
+ ): Crop {
66
+ const z = clamp(zoom, ZOOM_MIN, ZOOM_MAX);
67
+ const base = coverSize(box, src);
68
+ const w = base.w * z;
69
+ const h = base.h * z;
70
+ const axis = (boxLen: number, len: number, f: number) => {
71
+ const room = boxLen - len; // ≤ 0
72
+ if (Math.abs(room) < NO_ROOM) return 50;
73
+ const lead = clamp(boxLen / 2 - clamp(f, 0, 1) * len, room, 0);
74
+ return (lead / room) * 100;
75
+ };
76
+ return { zoom: z, x: axis(box.w, w, focus[0]), y: axis(box.h, h, focus[1]) };
77
+ }
78
+
79
+ /** The focus of a crop: the picture point under the frame's centre; an axis with no room keeps `keep`. */
80
+ export function focusOfCrop(box: Size, src: Size, c: Crop, keep: readonly [number, number]): Focus {
81
+ const r = pictureRect(box, src, c);
82
+ const axis = (boxLen: number, len: number, lead: number, k: number) =>
83
+ Math.abs(boxLen - len) < NO_ROOM ? k : r4(clamp((boxLen / 2 - lead) / len, 0, 1));
84
+ return [axis(box.w, r.w, r.left, keep[0]), axis(box.h, r.h, r.top, keep[1])];
85
+ }
86
+
87
+ /** The zoom after one wheel step: up zooms in; a pinch (ctrl + wheel) is finer-grained per delta. Held to 1–8×. */
88
+ export function wheelZoom(zoom: number, deltaY: number, pinch: boolean): number {
89
+ const k = pinch ? 0.01 : 0.002;
90
+ return Math.round(clamp(zoom * Math.exp(-deltaY * k), ZOOM_MIN, ZOOM_MAX) * 1000) / 1000;
91
+ }
92
+
93
+ /** The artboard's video (its `<VideoComp>` host) in the canvas window's pixels, or null when it is not drawn. */
94
+ export function videoBox(doc: Document, artboardId: string): FrameBox | null {
95
+ let el: Element | null = null;
96
+ try {
97
+ el = doc.querySelector(`[data-dc-screen="${CSS.escape(artboardId)}"] .dc-video-comp`);
98
+ } catch {
99
+ return null;
100
+ }
101
+ if (!el) return null;
102
+ const r = el.getBoundingClientRect();
103
+ if (r.width <= 0 || r.height <= 0) return null;
104
+ return { left: r.left, top: r.top, w: r.width, h: r.height };
105
+ }
106
+
107
+ /** The picture's own size when the shell could not say it: the first decoded frame under the artboard's video. */
108
+ function sizeFromDom(doc: Document, artboardId: string): Size | null {
109
+ try {
110
+ const v = doc.querySelector(
111
+ `[data-dc-screen="${CSS.escape(artboardId)}"] .dc-video-comp video`
112
+ ) as HTMLVideoElement | null;
113
+ return v && v.videoWidth > 0 && v.videoHeight > 0
114
+ ? { w: v.videoWidth, h: v.videoHeight }
115
+ : null;
116
+ } catch {
117
+ return null;
118
+ }
119
+ }
120
+
121
+ // ── chrome ─────────────────────────────────────────────────────────────────────────────────
122
+
123
+ const CSS_TEXT = `
124
+ .ed-vframe-picture {
125
+ position: fixed; z-index: 5; box-sizing: border-box; pointer-events: auto; cursor: grab; touch-action: none;
126
+ border: 1.5px dashed var(--accent, #4a7bff);
127
+ background: color-mix(in oklab, var(--accent, #4a7bff) 6%, transparent);
128
+ }
129
+ .ed-vframe-picture[data-dragging] { cursor: grabbing; }
130
+ .ed-vframe-box {
131
+ position: fixed; z-index: 6; pointer-events: none;
132
+ box-shadow: 0 0 0 1.5px var(--accent, #4a7bff);
133
+ }
134
+ .ed-vframe-handle {
135
+ position: fixed; z-index: 8; width: 10px; height: 10px; margin: -5px 0 0 -5px;
136
+ border: 1.5px solid var(--accent, #4a7bff); border-radius: 2px; background: var(--bg-0, #fff); touch-action: none;
137
+ }
138
+ .ed-vframe-handle[data-c="nw"], .ed-vframe-handle[data-c="se"] { cursor: nwse-resize; }
139
+ .ed-vframe-handle[data-c="ne"], .ed-vframe-handle[data-c="sw"] { cursor: nesw-resize; }
140
+ .ed-vframe-tag {
141
+ position: fixed; z-index: 8; pointer-events: none; padding: 2px 8px; border-radius: 6px;
142
+ background: var(--accent, #4a7bff); color: var(--accent-fg, #fff);
143
+ font: 500 11px/16px var(--maude-chrome-font, system-ui, sans-serif); white-space: nowrap;
144
+ }
145
+ `.trim();
146
+
147
+ function ensureStyles(): void {
148
+ if (typeof document === 'undefined' || document.getElementById('ed-vframe-css')) return;
149
+ const s = document.createElement('style');
150
+ s.id = 'ed-vframe-css';
151
+ s.textContent = CSS_TEXT;
152
+ document.head.appendChild(s);
153
+ }
154
+
155
+ /** The words on the tag over the frame. */
156
+ export const frameTagText = (label: string): string =>
157
+ label ? `${label} · move and zoom` : 'Move and zoom';
158
+
159
+ /** A wheel run is written once it has been still this long (one undo step per run, not per notch). */
160
+ export const WHEEL_SETTLE_MS = 350;
161
+ /** A press that travels less than this is a click, and writes nothing. */
162
+ const CLICK_SLOP = 3;
163
+
164
+ type Drag =
165
+ | { kind: 'pan'; x: number; y: number; from: Crop; moved: boolean }
166
+ | { kind: 'corner'; corner: Corner; x: number; y: number; from: Crop; moved: boolean };
167
+
168
+ // ── the handle ─────────────────────────────────────────────────────────────────────────────
169
+
170
+ export function VideoFrameHandle({
171
+ readOnly = false,
172
+ }: {
173
+ readOnly?: boolean;
174
+ }): ReactElement | null {
175
+ const [want, setWant] = useState<Want | null>(null);
176
+ const [box, setBox] = useState<FrameBox | null>(null);
177
+ // the crop being shown while the person works (null = the shell's numbers)
178
+ const [live, setLive] = useState<Crop | null>(null);
179
+ const [dragging, setDragging] = useState(false);
180
+ const drag = useRef<Drag | null>(null);
181
+ const wantRef = useRef(want);
182
+ wantRef.current = want;
183
+ const boxRef = useRef(box);
184
+ boxRef.current = box;
185
+ const liveRef = useRef(live);
186
+ liveRef.current = live;
187
+ const wheelTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
188
+
189
+ // the shell names the clip, or takes the handle down
190
+ useEffect(() => {
191
+ const onMessage = (e: MessageEvent) => {
192
+ if (
193
+ e.source !== window.parent ||
194
+ (e.data as { dgn?: unknown } | null)?.dgn !== 'video-frame-handle'
195
+ )
196
+ return;
197
+ const m = acceptFromShell(e, window);
198
+ if (m?.dgn !== 'video-frame-handle') return;
199
+ setLive(null);
200
+ if (!m.artboardId || !m.stableId) {
201
+ setWant(null);
202
+ return;
203
+ }
204
+ setWant({
205
+ artboardId: m.artboardId,
206
+ stableId: m.stableId,
207
+ label: m.label ?? '',
208
+ src: m.src ?? null,
209
+ zoom: m.zoom ?? 1,
210
+ focus: m.focus ?? [0.5, 0.5],
211
+ });
212
+ };
213
+ window.addEventListener('message', onMessage);
214
+ return () => window.removeEventListener('message', onMessage);
215
+ }, []);
216
+
217
+ const on = !!want && !readOnly;
218
+ useEffect(() => {
219
+ if (on) ensureStyles();
220
+ }, [on]);
221
+
222
+ // the frame follows the artboard while the camera pans or zooms (not while a drag holds it)
223
+ useEffect(() => {
224
+ if (!on || !want) {
225
+ setBox(null);
226
+ return undefined;
227
+ }
228
+ let raf = 0;
229
+ const tick = () => {
230
+ if (!drag.current)
231
+ setBox((b) => {
232
+ const n = videoBox(document, want.artboardId);
233
+ if (!n) return null;
234
+ return b && b.left === n.left && b.top === n.top && b.w === n.w && b.h === n.h ? b : n;
235
+ });
236
+ raf = frameRaf(tick);
237
+ };
238
+ setBox(videoBox(document, want.artboardId));
239
+ raf = frameRaf(tick);
240
+ return () => frameCaf(raf);
241
+ }, [on, want]);
242
+
243
+ const srcOf = useCallback(
244
+ (w: Want): Size | null => w.src ?? sizeFromDom(document, w.artboardId),
245
+ []
246
+ );
247
+ const cropNow = useCallback((): Crop | null => {
248
+ const w = wantRef.current;
249
+ const b = boxRef.current;
250
+ const src = w ? srcOf(w) : null;
251
+ if (!w || !b || !src) return null;
252
+ return liveRef.current ?? cropOfFocus(b, src, w.zoom, w.focus);
253
+ }, [srcOf]);
254
+
255
+ const commit = useCallback(
256
+ (c: Crop) => {
257
+ const w = wantRef.current;
258
+ const b = boxRef.current;
259
+ const src = w ? srcOf(w) : null;
260
+ if (!w || !b || !src) return;
261
+ // an axis the picture can not move along keeps what the file says
262
+ const focus = focusOfCrop(b, src, c, w.focus);
263
+ try {
264
+ window.parent.postMessage(
265
+ {
266
+ dgn: 'video-frame-commit',
267
+ v: 1,
268
+ artboardId: w.artboardId,
269
+ stableId: w.stableId,
270
+ zoom: Math.round(c.zoom * 100) / 100,
271
+ focus,
272
+ },
273
+ '*'
274
+ );
275
+ } catch {
276
+ /* detached */
277
+ }
278
+ },
279
+ [srcOf]
280
+ );
281
+
282
+ // the wheel and the trackpad pinch over the frame are the picture's, not the camera's
283
+ useEffect(() => {
284
+ if (!on) return undefined;
285
+ const onWheel = (e: WheelEvent) => {
286
+ const b = boxRef.current;
287
+ if (!b || drag.current) return;
288
+ if (
289
+ e.clientX < b.left ||
290
+ e.clientX > b.left + b.w ||
291
+ e.clientY < b.top ||
292
+ e.clientY > b.top + b.h
293
+ )
294
+ return;
295
+ const cur = cropNow();
296
+ const w = wantRef.current;
297
+ const src = w ? srcOf(w) : null;
298
+ if (!cur || !w || !src) return;
299
+ e.preventDefault();
300
+ e.stopImmediatePropagation();
301
+ const zoom = wheelZoom(cur.zoom, e.deltaY, e.ctrlKey);
302
+ if (zoom === cur.zoom) return;
303
+ // about the frame's centre: the same focus, a bigger picture
304
+ const next = cropOfFocus(b, src, zoom, focusOfCrop(b, src, cur, w.focus));
305
+ setLive(next);
306
+ liveRef.current = next;
307
+ if (wheelTimer.current) clearTimeout(wheelTimer.current);
308
+ wheelTimer.current = setTimeout(() => {
309
+ wheelTimer.current = null;
310
+ const c = liveRef.current;
311
+ if (c) commit(c);
312
+ }, WHEEL_SETTLE_MS);
313
+ };
314
+ window.addEventListener('wheel', onWheel, { capture: true, passive: false });
315
+ return () => {
316
+ window.removeEventListener('wheel', onWheel, { capture: true });
317
+ if (wheelTimer.current) clearTimeout(wheelTimer.current);
318
+ wheelTimer.current = null;
319
+ };
320
+ }, [on, cropNow, srcOf, commit]);
321
+
322
+ const move = useCallback(
323
+ (e: PointerEvent) => {
324
+ const d = drag.current;
325
+ const b = boxRef.current;
326
+ const w = wantRef.current;
327
+ const src = w ? srcOf(w) : null;
328
+ if (!d || !b || !src) return;
329
+ const dx = e.clientX - d.x;
330
+ const dy = e.clientY - d.y;
331
+ if (!d.moved && Math.hypot(dx, dy) < CLICK_SLOP) return;
332
+ d.moved = true;
333
+ const rel = { w: b.w, h: b.h };
334
+ const next =
335
+ d.kind === 'pan'
336
+ ? pan(rel, src, d.from, dx, dy)
337
+ : dragCorner(rel, src, d.from, d.corner, e.clientX - b.left, e.clientY - b.top);
338
+ liveRef.current = next;
339
+ setLive(next);
340
+ },
341
+ [srcOf]
342
+ );
343
+ const up = useCallback(
344
+ (e: PointerEvent) => {
345
+ move(e);
346
+ const d = drag.current;
347
+ drag.current = null;
348
+ setDragging(false);
349
+ document.removeEventListener('pointermove', move, true);
350
+ document.removeEventListener('pointerup', up, true);
351
+ const c = liveRef.current;
352
+ if (d?.moved && c) commit(c);
353
+ },
354
+ [move, commit]
355
+ );
356
+ useEffect(
357
+ () => () => {
358
+ document.removeEventListener('pointermove', move, true);
359
+ document.removeEventListener('pointerup', up, true);
360
+ },
361
+ [move, up]
362
+ );
363
+
364
+ const begin = (kind: 'pan' | Corner) => (e: React.PointerEvent) => {
365
+ if (e.button !== 0) return;
366
+ const from = cropNow();
367
+ if (!from) return;
368
+ e.preventDefault();
369
+ e.stopPropagation();
370
+ drag.current =
371
+ kind === 'pan'
372
+ ? { kind: 'pan', x: e.clientX, y: e.clientY, from, moved: false }
373
+ : { kind: 'corner', corner: kind, x: e.clientX, y: e.clientY, from, moved: false };
374
+ setDragging(true);
375
+ document.addEventListener('pointermove', move, true);
376
+ document.addEventListener('pointerup', up, true);
377
+ };
378
+
379
+ if (!on || !want || !box) return null;
380
+ const src = srcOf(want);
381
+ const crop = src ? (live ?? cropOfFocus(box, src, want.zoom, want.focus)) : null;
382
+ const r = src && crop ? pictureRect({ w: box.w, h: box.h }, src, crop) : null;
383
+ const pic = r ? { left: box.left + r.left, top: box.top + r.top, w: r.w, h: r.h } : null;
384
+ const corners: Corner[] = ['nw', 'ne', 'se', 'sw'];
385
+ return (
386
+ <div data-testid="edit-video-frame" data-dc-chrome>
387
+ {pic ? (
388
+ <i
389
+ className="ed-vframe-picture"
390
+ data-testid="edit-video-frame-picture"
391
+ data-dragging={dragging ? 'true' : undefined}
392
+ style={{ left: pic.left, top: pic.top, width: pic.w, height: pic.h }}
393
+ onPointerDown={begin('pan')}
394
+ />
395
+ ) : null}
396
+ <i
397
+ className="ed-vframe-box"
398
+ data-testid="edit-video-frame-box"
399
+ style={{ left: box.left, top: box.top, width: box.w, height: box.h }}
400
+ />
401
+ {pic
402
+ ? corners.map((c) => {
403
+ const p = cornerPoint({ left: pic.left, top: pic.top, w: pic.w, h: pic.h }, c);
404
+ return (
405
+ <i
406
+ key={c}
407
+ className="ed-vframe-handle"
408
+ data-c={c}
409
+ data-testid={`edit-video-frame-handle-${c}`}
410
+ style={{ left: p.x, top: p.y }}
411
+ onPointerDown={begin(c)}
412
+ />
413
+ );
414
+ })
415
+ : null}
416
+ <span
417
+ className="ed-vframe-tag"
418
+ data-testid="edit-video-frame-tag"
419
+ style={{ left: box.left, top: box.top - 24 }}
420
+ >
421
+ {frameTagText(want.label)}
422
+ </span>
423
+ </div>
424
+ );
425
+ }