@dexhq/canvas 0.13.0 → 0.15.0

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 (341) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +21 -18
  3. package/app/canvas/activity.tsx +8 -15
  4. package/app/canvas/anchoring.ts +3 -5
  5. package/app/canvas/canvas-input.ts +151 -14
  6. package/app/canvas/canvas-keys.ts +9 -0
  7. package/app/canvas/canvas-model.ts +5 -42
  8. package/app/canvas/canvas-panels.ts +1 -17
  9. package/app/canvas/canvas-scene.ts +7 -3
  10. package/app/canvas/canvas-ui.ts +2 -1
  11. package/app/canvas/canvas.css +61 -26
  12. package/app/canvas/change-notice.tsx +10 -1
  13. package/app/canvas/comment-layer.tsx +2 -1
  14. package/app/canvas/comments.tsx +204 -82
  15. package/app/canvas/element-picker.ts +200 -27
  16. package/app/canvas/engine/canvas-gestures.ts +72 -17
  17. package/app/canvas/engine/canvas-store.ts +17 -1
  18. package/app/canvas/engine/engine.css +6 -3
  19. package/app/canvas/find-bar.tsx +817 -0
  20. package/app/canvas/find-model.ts +135 -0
  21. package/app/canvas/flow-canvas.tsx +18 -2
  22. package/app/canvas/follow-pin.ts +26 -6
  23. package/app/canvas/frame-node.tsx +43 -26
  24. package/app/canvas/imported-reviews.tsx +12 -22
  25. package/app/canvas/layout.ts +27 -0
  26. package/app/canvas/live-page.ts +142 -19
  27. package/app/canvas/page-find.ts +220 -0
  28. package/app/canvas/page-style.ts +23 -0
  29. package/app/canvas/section-node.tsx +2 -0
  30. package/app/canvas/spec-threads.ts +24 -23
  31. package/app/canvas/thread-focus.tsx +14 -12
  32. package/app/canvas/tool-cursors.ts +16 -16
  33. package/app/canvas/use-activity.ts +0 -8
  34. package/app/canvas/use-agent-changes.tsx +34 -40
  35. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  36. package/app/canvas/xray.ts +3 -12
  37. package/app/frame.tsx +5 -0
  38. package/app/i18n/locales/en/messages.po +114 -12
  39. package/app/i18n/locales/en/messages.ts +1 -1
  40. package/app/i18n/locales/pseudo/messages.po +114 -12
  41. package/app/i18n/locales/pseudo/messages.ts +1 -1
  42. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
  43. package/app/icons/index.tsx +3 -3
  44. package/app/icons/types.ts +3 -10
  45. package/app/index.html +3 -3
  46. package/app/main.tsx +3 -0
  47. package/app/pages/canvas-settings.tsx +35 -0
  48. package/app/pages/canvas.tsx +27 -8
  49. package/app/pages/commands-settings.tsx +16 -2
  50. package/app/shell/about.tsx +5 -4
  51. package/app/shell/feedback-details.ts +0 -3
  52. package/app/shell/feedback-form.tsx +10 -21
  53. package/app/shell/feedback-link.tsx +2 -1
  54. package/app/shell/instructions-editor.tsx +1 -1
  55. package/app/shell/presence-style.ts +59 -0
  56. package/app/shell/presence.tsx +6 -3
  57. package/app/shell/scaled-frame.tsx +21 -9
  58. package/app/shell/settings-sections.ts +12 -0
  59. package/app/shell/sidebar.tsx +1 -1
  60. package/app/studio-ui.d.ts +0 -9
  61. package/app/types.ts +21 -205
  62. package/app/ui/file-drop.ts +128 -0
  63. package/app/ui/prompt-editor.tsx +1 -1
  64. package/app/ui/shadcn/input-group.tsx +2 -2
  65. package/dist/cli/banner.d.mts +4 -2
  66. package/dist/cli/banner.mjs +34 -11
  67. package/dist/cli/commands/app.mjs +19 -11
  68. package/dist/cli/commands/create.d.mts +26 -14
  69. package/dist/cli/commands/create.mjs +13 -7
  70. package/dist/cli/commands/dev.mjs +2 -3
  71. package/dist/cli/commands/hook.mjs +2 -1
  72. package/dist/cli/commands/init.d.mts +11 -6
  73. package/dist/cli/help.d.mts +1 -1
  74. package/dist/cli/help.mjs +3 -3
  75. package/dist/cli/main.d.mts +22 -12
  76. package/dist/config/index.d.mts +6 -5
  77. package/dist/config/project-files.d.mts +6 -3
  78. package/dist/config/project-files.mjs +14 -5
  79. package/dist/config/renamed.d.mts +0 -2
  80. package/dist/config/renamed.mjs +1 -3
  81. package/dist/config/schema.d.mts +0 -5
  82. package/dist/config/schema.mjs +0 -5
  83. package/dist/content/capture.d.mts +2 -2
  84. package/dist/content/capture.mjs +2 -2
  85. package/dist/content/content.d.mts +3 -141
  86. package/dist/content/content.mjs +7 -65
  87. package/dist/content/flow-specs.mjs +1 -1
  88. package/dist/content/prototype-summary.d.mts +3 -39
  89. package/dist/content/prototype-summary.mjs +2 -3
  90. package/dist/content/prototypes.mjs +1 -1
  91. package/dist/content/snapshot-client.mjs +1 -1
  92. package/dist/content/text-replace.d.mts +30 -0
  93. package/dist/content/text-replace.mjs +309 -0
  94. package/dist/content/thread-module.mjs +1 -1
  95. package/dist/content/threads.mjs +1 -1
  96. package/dist/paths.d.mts +0 -2
  97. package/dist/paths.mjs +1 -3
  98. package/dist/server/agent-env.d.mts +5 -1
  99. package/dist/server/agent-env.mjs +7 -2
  100. package/dist/server/agent-session.d.mts +14 -1
  101. package/dist/server/agent-session.mjs +84 -19
  102. package/dist/server/brief.mjs +3 -3
  103. package/dist/server/build-pictures.mjs +1 -1
  104. package/dist/server/channel.d.mts +19 -24
  105. package/dist/server/channel.mjs +70 -37
  106. package/dist/server/claimed-presence.d.mts +18 -0
  107. package/dist/server/claimed-presence.mjs +58 -0
  108. package/dist/server/close-check.mjs +2 -2
  109. package/dist/server/comments/actions.d.mts +153 -0
  110. package/dist/server/comments/actions.mjs +154 -0
  111. package/dist/server/comments/routes.d.mts +25 -0
  112. package/dist/server/comments/routes.mjs +88 -0
  113. package/dist/server/comments/tools.d.mts +6 -0
  114. package/dist/server/comments/tools.mjs +154 -0
  115. package/dist/server/dev-server.mjs +36 -13
  116. package/dist/server/file-errors.d.mts +7 -2
  117. package/dist/server/file-errors.mjs +31 -8
  118. package/dist/server/file-lock.d.mts +2 -2
  119. package/dist/server/file-lock.mjs +130 -36
  120. package/dist/server/mcp.d.mts +0 -2
  121. package/dist/server/mcp.mjs +7 -8
  122. package/dist/server/me.d.mts +1 -1
  123. package/dist/server/open-page.d.mts +22 -0
  124. package/dist/server/open-page.mjs +20 -2
  125. package/dist/server/outcome.d.mts +22 -0
  126. package/dist/server/outcome.mjs +8 -0
  127. package/dist/server/own-copies.mjs +2 -2
  128. package/dist/server/people.d.mts +1 -1
  129. package/dist/server/port.d.mts +12 -0
  130. package/dist/server/port.mjs +66 -14
  131. package/dist/server/presence.d.mts +4 -1
  132. package/dist/server/presence.mjs +2 -2
  133. package/dist/server/requests.d.mts +5 -1
  134. package/dist/server/requests.mjs +32 -47
  135. package/dist/server/studio-for.d.mts +5 -0
  136. package/dist/server/studio-for.mjs +18 -4
  137. package/dist/server/sync-install.d.mts +8 -12
  138. package/dist/server/sync-install.mjs +12 -30
  139. package/dist/server/thread-source.mjs +2 -2
  140. package/dist/server/tools/describe.d.mts +1 -1
  141. package/dist/server/tools/describe.mjs +1 -1
  142. package/dist/server/tools/feedback.d.mts +1 -1
  143. package/dist/server/tools/reading.mjs +13 -4
  144. package/dist/server/tools/show.d.mts +1 -1
  145. package/dist/server/tools/snapshot.d.mts +1 -1
  146. package/dist/server/tools/thread-list.mjs +1 -1
  147. package/dist/server/tools/watch.mjs +5 -3
  148. package/dist/server/vite.mjs +28 -31
  149. package/dist/server/web-app.mjs +7 -10
  150. package/dist/server/work-groups.mjs +1 -1
  151. package/dist/setup/apply.mjs +8 -14
  152. package/dist/setup/create.d.mts +4 -2
  153. package/dist/setup/create.mjs +118 -36
  154. package/dist/setup/design-system-checks.mjs +3 -12
  155. package/dist/setup/desktop-app-script.mjs +4 -3
  156. package/dist/setup/desktop-app-start.d.mts +8 -2
  157. package/dist/setup/desktop-app-start.mjs +64 -29
  158. package/dist/setup/desktop-app.d.mts +8 -0
  159. package/dist/setup/desktop-app.mjs +20 -4
  160. package/dist/setup/detect.d.mts +14 -7
  161. package/dist/setup/detect.mjs +56 -10
  162. package/dist/setup/doctor.mjs +2 -4
  163. package/dist/setup/existing-setup.d.mts +1 -3
  164. package/dist/setup/existing-setup.mjs +10 -11
  165. package/dist/setup/migrate/row-titles.mjs +1 -1
  166. package/dist/setup/own-app.d.mts +1 -2
  167. package/dist/setup/own-app.mjs +4 -5
  168. package/dist/setup/plan.d.mts +8 -6
  169. package/dist/setup/plan.mjs +64 -48
  170. package/dist/setup/project.d.mts +6 -17
  171. package/dist/setup/project.mjs +17 -61
  172. package/dist/setup/prompts.d.mts +5 -5
  173. package/dist/setup/prompts.mjs +28 -61
  174. package/dist/setup/questions.d.mts +12 -4
  175. package/dist/setup/questions.mjs +10 -25
  176. package/dist/setup/starters.d.mts +2 -0
  177. package/dist/setup/starters.mjs +26 -9
  178. package/dist/setup/workspace-setup.d.mts +1 -2
  179. package/dist/setup/workspace-setup.mjs +4 -6
  180. package/dist/setup/write.d.mts +15 -5
  181. package/dist/setup/write.mjs +35 -9
  182. package/dist/shared/annotations-core.mjs +1 -1
  183. package/dist/shared/canvas-core.mjs +1 -1
  184. package/dist/shared/canvas-file.d.mts +201 -0
  185. package/dist/shared/canvas-file.mjs +1 -0
  186. package/dist/shared/comments/routes.d.mts +53 -0
  187. package/dist/shared/comments/routes.mjs +37 -0
  188. package/dist/shared/feedback.d.mts +8 -0
  189. package/dist/shared/feedback.mjs +10 -2
  190. package/dist/shared/page-review.d.mts +2 -11
  191. package/dist/shared/page-review.mjs +4 -13
  192. package/dist/shared/presence-core.d.mts +11 -0
  193. package/dist/shared/presence-core.mjs +11 -2
  194. package/dist/shared/review-file.d.mts +5 -0
  195. package/dist/shared/review-file.mjs +23 -13
  196. package/dist/shared/server-page.mjs +7 -1
  197. package/dist/shared/signup.d.mts +2 -5
  198. package/dist/shared/signup.mjs +2 -35
  199. package/dist/shared/studio-events.d.mts +0 -6
  200. package/dist/shared/studio-events.mjs +1 -5
  201. package/dist/shared/studio-files.d.mts +12 -0
  202. package/dist/shared/studio-files.mjs +6 -1
  203. package/dist/shared/studio-routes.d.mts +16 -62
  204. package/dist/shared/studio-routes.mjs +1 -69
  205. package/dist/shared/threads-core.d.mts +2 -2
  206. package/dist/shared/threads-core.mjs +1 -1
  207. package/extension/dist/feedback.js +148 -138
  208. package/extension/dist/manifest.json +1 -1
  209. package/extension/dist/picker.js +146 -136
  210. package/package.json +3 -20
  211. package/src/cli/banner.ts +45 -11
  212. package/src/cli/commands/app.ts +23 -8
  213. package/src/cli/commands/create.ts +17 -9
  214. package/src/cli/commands/dev.ts +0 -3
  215. package/src/cli/commands/hook.ts +4 -1
  216. package/src/cli/help.ts +3 -3
  217. package/src/config/index.ts +6 -5
  218. package/src/config/project-files.ts +21 -11
  219. package/src/config/renamed.ts +0 -3
  220. package/src/config/schema.ts +0 -1
  221. package/src/content/capture.ts +6 -12
  222. package/src/content/content.ts +7 -244
  223. package/src/content/flow-specs.ts +2 -1
  224. package/src/content/prototype-summary.ts +4 -44
  225. package/src/content/review-pages.ts +2 -1
  226. package/src/content/snapshot-client.ts +1 -1
  227. package/src/content/text-replace.ts +449 -0
  228. package/src/paths.ts +0 -8
  229. package/src/server/agent-env.ts +12 -2
  230. package/src/server/agent-session.ts +124 -34
  231. package/src/server/brief.ts +8 -3
  232. package/src/server/channel.ts +121 -52
  233. package/src/server/claimed-presence.ts +93 -0
  234. package/src/server/comments/actions.ts +352 -0
  235. package/src/server/comments/routes.ts +176 -0
  236. package/src/server/comments/tools.ts +317 -0
  237. package/src/server/dev-server.ts +49 -15
  238. package/src/server/file-errors.ts +47 -13
  239. package/src/server/file-lock.ts +205 -54
  240. package/src/server/mcp.ts +13 -14
  241. package/src/server/me.ts +2 -5
  242. package/src/server/open-page.ts +54 -4
  243. package/src/server/outcome.ts +26 -0
  244. package/src/server/people.ts +2 -1
  245. package/src/server/port.ts +94 -20
  246. package/src/server/presence.ts +11 -3
  247. package/src/server/requests.ts +60 -70
  248. package/src/server/studio-for.ts +27 -3
  249. package/src/server/sync-install.ts +35 -26
  250. package/src/server/thread-place.ts +2 -4
  251. package/src/server/tools/reading.ts +16 -3
  252. package/src/server/tools/watch.ts +7 -7
  253. package/src/server/vite.ts +37 -40
  254. package/src/server/web-app.ts +14 -12
  255. package/src/setup/apply.ts +10 -16
  256. package/src/setup/create.ts +143 -37
  257. package/src/setup/design-system-checks.ts +7 -15
  258. package/src/setup/desktop-app-script.ts +4 -3
  259. package/src/setup/desktop-app-start.ts +94 -26
  260. package/src/setup/desktop-app.ts +24 -3
  261. package/src/setup/detect.ts +56 -14
  262. package/src/setup/doctor.ts +4 -4
  263. package/src/setup/existing-setup.ts +10 -12
  264. package/src/setup/own-app.ts +2 -5
  265. package/src/setup/plan.ts +93 -84
  266. package/src/setup/project.ts +25 -118
  267. package/src/setup/prompts.ts +44 -127
  268. package/src/setup/questions.ts +27 -29
  269. package/src/setup/starters.ts +35 -10
  270. package/src/setup/workspace-setup.ts +8 -18
  271. package/src/setup/write.ts +52 -9
  272. package/src/shared/canvas-file.ts +205 -0
  273. package/src/shared/comments/routes.ts +79 -0
  274. package/src/shared/feedback.ts +14 -4
  275. package/src/shared/page-review.ts +11 -16
  276. package/src/shared/presence-core.ts +16 -2
  277. package/src/shared/review-file.ts +28 -12
  278. package/src/shared/server-page.ts +11 -1
  279. package/src/shared/signup.ts +4 -28
  280. package/src/shared/studio-events.ts +0 -13
  281. package/src/shared/studio-files.ts +14 -0
  282. package/src/shared/studio-routes.ts +21 -64
  283. package/src/shared/threads-core.ts +2 -2
  284. package/templates/methods/review.md +2 -2
  285. package/templates/rules/canvas-frames.md +104 -0
  286. package/templates/rules/canvas.md +8 -142
  287. package/templates/rules/prototypes.md +1 -1
  288. package/templates/rules/snapshots.md +52 -0
  289. package/templates/starters/standalone/README.md +7 -7
  290. package/templates/starters/standalone/components.json +1 -1
  291. package/templates/starters/standalone/package.json +1 -2
  292. package/templates/starters/turborepo/README.md +6 -6
  293. package/templates/starters/turborepo/apps/web/components.json +1 -1
  294. package/templates/starters/turborepo/apps/web/package.json +1 -2
  295. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  296. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  297. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  298. package/templates/starters/vite/README.md +7 -6
  299. package/templates/starters/vite/components.json +1 -1
  300. package/templates/starters/vite/package.json +1 -2
  301. package/templates/starters/vite/src/app.tsx +3 -4
  302. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  303. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  304. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  305. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  306. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  307. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  308. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  309. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  310. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  311. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  312. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  313. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  314. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  315. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  316. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  317. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  318. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  319. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  320. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  321. package/templates/starters/vite/src/index.css +533 -111
  322. package/app/icons/sets/hugeicons.tsx +0 -259
  323. package/app/icons/sets/phosphor.tsx +0 -251
  324. package/dist/server/icon-set.d.mts +0 -15
  325. package/dist/server/icon-set.mjs +0 -31
  326. package/dist/server/tools/close-reply.d.mts +0 -6
  327. package/dist/server/tools/close-reply.mjs +0 -138
  328. package/dist/server/tools/comment.d.mts +0 -6
  329. package/dist/server/tools/comment.mjs +0 -49
  330. package/dist/shared/icon-sets.d.mts +0 -9
  331. package/dist/shared/icon-sets.mjs +0 -21
  332. package/src/server/icon-set.ts +0 -56
  333. package/src/server/tools/close-reply.ts +0 -271
  334. package/src/server/tools/comment.ts +0 -96
  335. package/src/shared/icon-sets.ts +0 -23
  336. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  337. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  338. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  339. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  340. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  341. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @dexhq/canvas
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7e4d6e8: ⌘F finds words on every frame of the canvas: each match painted yellow on its page, the canvas moving to the current one, the count, steps either way and a list of matches by frame. Replace all changes the words where they are written as text in your own files, with Undo.
8
+
9
+ ### Patch Changes
10
+
11
+ - ea8099e: Opening an agent from the canvas works when the login shell doesn't put Node on its PATH (nvm loaded only in some shells): the terminal Dex opens puts the Node running Dex first on it.
12
+ - 589f164: The Mac app made by a Dex that moved off a taken port now opens the port that Dex moved to, so it starts, and `dex app install` says which address the app opens. Opened from its start link, the app no longer starts a second `dex dev`. When something else holds the app's port, the app says what (another checkout's Dex, or the process), where this project's Dex runs if it runs elsewhere, and only suggests fixes the app can use.
13
+ - 3eaf154: A field in an input group shows its focus once, around the group: the canvas's comment search no longer draws a second outline through its search icon.
14
+ - 9ac6654: In Safari and the Dex app, the canvas's keys work again once you leave a live frame with Escape, or outline an element in one with the comment tool. Before, the frame's page kept the keyboard, so H, ⇧C and the other hotkeys did nothing; only C, V, Escape and the zoom keys reached the canvas.
15
+ - 6d1cb80: In Safari and the Mac app, the canvas stays sharp zoomed in with a frame selected or the pointer over it: the size label has no backdrop blur, and what fades or grows in on the canvas no longer makes WebKit draw the whole canvas at the screen's scale and stretch it.
16
+ - 2adbb05: The green tick where an agent's change landed now hides with the comment pins (⇧C), and shows only where its comment's pin would, so a Comments filter that leaves out resolved comments leaves out ticks too. A Done comment opened while comments are hidden shows its tick with its pin.
17
+ - b6582b4: Comments from people and agents now go through one set of actions, and request bodies are checked: a comment request with a field of the wrong type is refused, naming the field.
18
+ - 3e7bd3b: A comment opened from the agent heads-up now opens, one an agent completed too: the canvas moves to it, and its card appears at its pin, or by its frame when its element is gone, not at the top right. ⇧C hides comment pins on the canvas only: the Comments list still shows every comment, and one opened from it shows with its pin.
19
+ - 44c259f: Escape that closes a dialog on a live frame's page stays with the page, whatever design system made the dialog: the frame stays live and keeps showing Reset, where before it left the frame too, and a `<dialog>` opened with `showModal()` closes on Escape again.
20
+ - 087af74: A file dropped on the feedback form attaches wherever it lands: on its edge too, and in Safari and the Dex app when let go just as the pointer moves onto another part of the form, where it used to open in place of the page (or in Preview, from the app); dragging one over the form shows a copy, not a move.
21
+ - 087af74: A file dropped anywhere on Import reviews, or on the canvas just as the pointer reaches it, is taken in Safari and the Dex app too, and one dropped where nothing takes it (the toolbar, a dialog's backdrop, a live frame, Markup's panel) is refused instead of opening in place of the page.
22
+ - ca91b55: Remove canvas model code nothing called: moving a section, updating several frames at once, the off-canvas test and the panel feature list.
23
+ - 54dc82e: Code that was in two places is in one: the canvas's types, sending to the feedback relay, the update after Sync, a review's header and a suggestion's buttons. Nothing Dex or Markup does changes.
24
+ - 2863775: Remove CLI and server code nothing called, and stop shipping the interface's import check, which only a test ran.
25
+ - 41dffdd: An imported review stays on Comments' Reviews page once its comments are closed: resolved, Done and Not done comments show there, dimmed, and keep their pins, as the team's do. Hide resolved still hides them.
26
+ - 29c4136: Two Dex processes on one machine no longer end up holding one lock at once (the repository's turn, the install lock, comments, canvases, presence). A Dex that comes back late, after its lock was taken over, leaves the next holder's lock alone, and a takeover left halfway by a process that stopped no longer lets two waiters in.
27
+ - 339e54c: A comment's pin stays on its element when the element's words change, as when an agent rewrites a heading a comment is on, and when the words change before the comment is posted; it used to disappear while the comment stayed in the agent's threads. A comment whose row moves in a list, or whose element gets new markup around it, follows its words there. A plain element (no ARIA states, no design-system component) that another takes the place of keeps the pin there.
28
+ - e360183: In Chrome, zoomed out where frames show their pictures, a frame's comment pins and the ticks where an agent's changes landed stay on its picture, as in Safari and the Dex app, instead of going a moment later. So a comment opened from the heads-up on a tall frame opens beside its pin, not at the frame's corner.
29
+ - c1cdf84: `dex dev` no longer takes a port that another checkout's Dex, or another process, already holds on the other address family (IPv4 or IPv6) or on every address, where a browser on `localhost` could reach it instead. It counts that port as taken: it moves to the next free one, or, when `STUDIO_PORT` asks for that port, says what holds it.
30
+ - f8c405c: An agent stops showing at work on the canvas once its work ends, however it ends: a comment closed, answered or let go, back to `watch` with nothing in hand, or its session ended or killed. Claude Code's edit marks now go with it, not two minutes later. `where` says who the canvas shows at work on the open file, and until when.
31
+ - d21b6aa: Importing a review no longer reloads the page when its snapshots are written where earlier ones were deleted, so the Comments panel stays open on Reviews with the review listed. Their frames update in place.
32
+ - bf9b26c: Zoomed out so far that a section's name would reach into the section above (below about 7% with the browser's usual font size, as fitting a canvas of many stacked sections does), section names hide, as frame names already do further in. A press there reaches what is drawn, and dragging a section by its name no longer resizes a frame in the section above. A section drawn that far out still asks for its name.
33
+ - 3b50db2: Canvas: a section dragged while you zoom keeps its frames with it, even as their pages load and grow.
34
+ - ea8099e: `dex create` in a folder with files but no package.json (an agent's `work/` and `outputs/`) starts the new project beside them instead of stopping, and a new project connects the agent running setup instead of always Claude Code.
35
+ - 0e503a9: Run again under Bun, setup no longer takes a studio in Bun's global cache for one the project has installed, so it still runs the install the project needs.
36
+ - 029ae68: A thumbnail no longer shows the scrollbar of a scrolling area inside its frame, such as an app's main pane, where the system always shows scrollbars; a frame in use still scrolls as before.
37
+ - 65a5fbc: Canvas: in Safari and the Dex app, a pinch over a frame in use zooms as smoothly and as far as one over the empty canvas, and a pinch never jumps as it starts.
38
+
39
+ ## 0.14.0
40
+
41
+ ### Minor Changes
42
+
43
+ - 66fc3c9: `dex create --preset <code> --base <library>` sets shadcn up with the look and library you chose, setup connects the agent that runs it, and pnpm 11 projects install without stopping on esbuild's build script. A view with an import that doesn't resolve no longer reloads in a loop, and app components beside the design system's are styled in views.
44
+ - 25da0f8: A new project from `dex create` starts with the look of Dex's own interface: round controls, a visible focus outline, Inter and Lucide icons, in place of shadcn's Vega with Hugeicons. Setup adds a `dex` script, so Dex starts with `npm run dex`; a project set up before keeps its `studio` script.
45
+ - 2a55803: Dex's interface keeps its own look: it always draws with Lucide (`ui.icons` and `--icons` are gone; `create` takes `ui.icons` out of an older config), and `create` no longer builds the interface from your shadcn components unless you pass `--primitives`. The `/` menu's long descriptions no longer overlap the next command.
46
+ - 7f7c467: Every agent shows at work on the canvas again, not only Claude Code with its hook: an agent that edits a view it holds a comment on is shown there. Settings → Canvas chooses how agents at work show: in blocks, as an edge only, or not at all.
47
+
48
+ ### Patch Changes
49
+
50
+ - edc2fcf: The studio loads again: About no longer reads a homepage the package doesn't have, and links to Dex on npm. Publishing now type-checks the interface too.
51
+ - dd3d324: The tab, home-screen and installed-app icons have new file names (`dex-icon.svg`, `dex-192.png` and the rest), so browsers and installed apps that cached the old icons fetch the Dex mark. The "Dex isn't running" page now shows it in its tab too.
52
+ - 199979a: Canvas: a step's Play stays on its label while its page is used live or resized, and Reset and Pick no longer shift it as they come and change
53
+ - 64bc15b: Agents read less to work on a canvas: `rules/canvas.md` keeps the grid, frames and ownership, and snapshots (`rules/snapshots.md`) and specs, slides, devices, wireframes and Play (`rules/canvas-frames.md`) are read only when the work is about them. The brief names Dex's rules folder once instead of on every entry.
54
+ - d304a48: Canvas tool cursors are back to the system's size: 16 px with 1 px lines, where the comment pin and Select's arrow stood well above the system pointer.
55
+
3
56
  ## 0.13.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -125,11 +125,13 @@ npm create dex@latest
125
125
 
126
126
  `pnpm create dex`, `yarn create dex` and `bun create dex` work too;
127
127
  with npm, flags go after `--` (`npm create dex@latest -- --yes`). It runs
128
- `dex create` from `@dexhq/canvas`, which `npx @dexhq/canvas create` runs
129
- directly.
128
+ `dex create` from `@dexhq/canvas`, which
129
+ `npx --package=@dexhq/canvas dex create` runs directly (the package has two
130
+ commands, so npx needs the one to run).
130
131
 
131
132
  Run it where the project's `package.json` is, or anywhere in a workspace
132
- (monorepo). In an empty folder it starts a new project from the shadcn
133
+ (monorepo). In a folder with no `package.json` (empty, or holding only
134
+ notes or an agent's `work/` and `outputs/`) it starts a new project from the shadcn
133
135
  starter instead (Vite, React and shadcn on Base UI, with every component the
134
136
  studio's own interface uses), then sets the studio up in it the same way. It
135
137
  says what it does at each step:
@@ -177,11 +179,12 @@ it plans only what differs from what this version writes, as `storybook
177
179
  automigrate` does. The choices come from `dex.config.ts` first, then flags,
178
180
  then what it finds. Facts the project's files say are dropped from
179
181
  `designSystem`, only where the design system resolves the same without them;
180
- `ui.icons` and `plugins: [next()]` are added; a studio `tsconfig.json` that
181
- copies the project's paths extends its tsconfig instead; a file, an agent's
182
- config or the install an earlier run left out is made; and a `@dexhq/canvas`
183
- range too old for what it writes is raised. The config keeps its other keys,
184
- comments and formatting. What an older setup added to the project's own files
182
+ `plugins: [next()]` is added and `ui.icons`, no longer read, taken out; a
183
+ studio `tsconfig.json` that copies the project's paths extends its tsconfig
184
+ instead; a file, an agent's config or the install an earlier run left out is
185
+ made; and a `@dexhq/canvas` range too old for what it writes is raised. The
186
+ config keeps its other keys, comments and formatting. What an older setup
187
+ added to the project's own files
185
188
  (`.gitignore` lines, the `studio:build` and `studio:claude` scripts) stays,
186
189
  and the plan says so in a `note`; `DESIGN.md`, `provider.tsx`,
187
190
  `contributors.json` and files are never touched. It asks "Go ahead?" once;
@@ -275,10 +278,10 @@ Every question has a flag, so agents and CI can run it without a terminal:
275
278
  | `[folder]` | Where: the project, or a new one (default: here) |
276
279
  | `--app <name>` \| `--in <package>` | In a workspace: its own app, `apps/<name>`, or inside a package |
277
280
  | `--components <folder>` \| `none`, `--shadcn` | The components; `--shadcn` sets up shadcn first |
281
+ | `--preset <code>`, `--base base` \| `radix` \| `aria` | How `shadcn init` sets it up: a preset's name or the code [ui.shadcn.com/create](https://ui.shadcn.com/create) gives, and the component library. Either one implies `--shadcn` |
278
282
  | `--import <specifier>` | How prototypes import them, when it cannot tell |
279
283
  | `--styles <file>` \| `none` | The global stylesheet |
280
- | `--primitives`, `--no-primitives` | The studio's own interface from your components |
281
- | `--icons lucide\|phosphor\|hugeicons` | The icon set the interface draws with (`ui.icons`, always written). Default: `components.json`'s `iconLibrary`, else the set in your dependencies, else Lucide. Lucide comes with Dex; Phosphor and Hugeicons are optional peers, which setup installs when the project lacks them |
284
+ | `--primitives` | The studio's own interface from your components, when they are shadcn on Base UI (`ui.primitives`). Off by default: the interface keeps Dex's own look. |
282
285
  | `--provider <module>` \| `none` | What wraps every view (`designSystem.provider`): your own module, or none. Default: for Mantine, Chakra UI (its version decides which provider) or Radix Themes, a `provider.tsx` it writes in the studio's folder; otherwise none |
283
286
  | `--design-md draft` \| `none` \| `<path>` \| `<url>` | How `DESIGN.md` starts: a draft (default), empty, a file in the repository linked as the design system's guide, or a file or URL copied in |
284
287
  | `--agent <ids>` \| `none` | The agents: `claude,codex,cursor,copilot,opencode` |
@@ -305,7 +308,7 @@ exports, components that aren't React, a Tailwind 3 config.
305
308
  ```json
306
309
  {"step":"detect","key":"components","value":{"folder":"src/components/ui","import":"@/components/ui","count":12},"evidence":"components.json → aliases.ui","confidence":"certain"}
307
310
  {"step":"decide","key":"components","value":{"folder":"src/components/ui","import":"@/components/ui"},"source":"components.json → aliases.ui","flag":"--components"}
308
- {"step":"question","key":"icons","question":"Which icon set should Dex's interface draw with?","choices":[{"value":"phosphor","label":"Phosphor","flags":["--icons","phosphor"]},{"value":"hugeicons","label":"Hugeicons","flags":["--icons","hugeicons"]}],"default":"phosphor","flag":"--icons"}
311
+ {"step":"question","key":"styles","question":"Which stylesheet holds the design system's tokens, fonts and Tailwind?","choices":[{"value":"src/index.css","label":"src/index.css","flags":["--styles","src/index.css"]},{"value":"none","label":"None","flags":["--styles","none"]}],"default":"src/index.css","flag":"--styles"}
309
312
  {"step":"hint","key":"provider","message":"@primer/react exports BaseStyles and ThemeProvider: if its components need them, wrap every view in them with a provider module (designSystem.provider).","evidence":"node_modules/@primer/react/lib/index.d.ts"}
310
313
  {"step":"plan","action":"create","path":"dex.config.ts","detail":"design system acme, scanned from src/components/ui"}
311
314
  {"step":"write","action":"create","path":"dex.config.ts"}
@@ -316,9 +319,9 @@ exports, components that aren't React, a Tailwind 3 config.
316
319
 
317
320
  | `step` | Fields |
318
321
  | --- | --- |
319
- | `detect` | `key` (`studio` where one is set up: `{config, content}`; `workspace`, `components`, `styles`, `primitives`, `icons`, `designMd`, `agents`, `packageManager`, and `provider` when the design system needs one: `{library, component}`), `value`, `evidence`, `confidence` (`certain`, `likely`, `guess`) |
322
+ | `detect` | `key` (`studio` where one is set up: `{config, content}`; `workspace`, `components`, `styles`, `primitives`, `designMd`, `agents`, `packageManager`, and `provider` when the design system needs one: `{library, component}`), `value`, `evidence`, `confidence` (`certain`, `likely`, `guess`) |
320
323
  | `decide` | `key` (those, `dir`, and `placement` in a workspace: `{kind, folder, name}` or `{kind, folder, package}`), `value`, `source` (the flag, or the evidence), `flag`, `warning` for a guess. `designMd`'s value is `{kind: "draft", summary}` (counts of colours, typography, radii, spacing and components, the sections and the stylesheets), `{kind: "link", file}`, `{kind: "import", from, lines, problem}` or `{kind: "none"}`. `provider` (when the design system needs one, or `--provider` names one) is `{kind: "write", file, component}`, `{kind: "module", module}` or `"none"` |
321
- | `question` | A decision it took without being sure: `key` (`components`, `styles`, `icons`, `designMd`, `packageManager` or `placement`), `question` (one sentence), `choices` (what it found, plus `none` where that is an answer: each `{value, label, evidence, flags}`, `flags` the exact arguments that answer with it), `default` (the `value` it takes; left out when no choice is safe, and then a run that writes stops with code 2), `flag` |
324
+ | `question` | A decision it took without being sure: `key` (`components`, `styles`, `designMd`, `packageManager` or `placement`), `question` (one sentence), `choices` (what it found, plus `none` where that is an answer: each `{value, label, evidence, flags}`, `flags` the exact arguments that answer with it), `default` (the `value` it takes; left out when no choice is safe, and then a run that writes stops with code 2), `flag` |
322
325
  | `hint` | For the agent's part, changing nothing setup does: `key` (`provider`: a provider or theme the design system exports; `framework`: components that are Svelte, Vue, Lit or Astro; `tailwind`: a Tailwind 3 config views get; `next`: `next()` written), `message`, `evidence` |
323
326
  | `plan` | `action` (`create`, `edit`, `run`, `ask`, or `note` for what it leaves in your own files), `path` or `command`, `detail`: on a set-up studio, only what differs |
324
327
  | `write` | `action`, `path` |
@@ -490,11 +493,11 @@ run again:
490
493
  shadcn on Base UI (Vega style, Hugeicons), and its theme is plain shadcn
491
494
  neutral with Inter: the studio's own look, never the design system's.
492
495
  `node scripts/interface-components.mjs` brings them back to stock. A
493
- project's own Base UI components replace them with `ui.primitives`.
494
- - Icons (`app/icons`): one vocabulary of names (lucide's, which shadcn uses)
495
- and a set per library in `sets/`, each drawing every name. `ui.icons`
496
- picks the set and only it is bundled. To add an icon, add its name to
497
- `names.ts` and draw it in every set; TypeScript lists any set missing it.
496
+ project's own Base UI components replace them with `ui.primitives`, set
497
+ by hand or with `create --primitives`: off by default, so the interface
498
+ looks like Dex.
499
+ - Icons (`app/icons`): Lucide, by name, in `glyphs.tsx`; the interface
500
+ draws every icon through `<Icon>`. To add one, add it to `glyphs.tsx`.
498
501
  - Languages (`app/i18n`): Lingui. Write interface text with its macros
499
502
  (`<Trans>`, t`…`, msg`…`), then `npm run i18n --workspace dex`
500
503
  to extract and compile the catalogs in `app/i18n/locales` (committed).
@@ -42,7 +42,6 @@ import {
42
42
  Matrix,
43
43
  } from "./activity-parts";
44
44
  import { commentWords } from "./agent-changes";
45
- import type { ScreenPoint } from "./canvas-context";
46
45
  import { DoneTick } from "./change-notice";
47
46
  import { DOCKS_CHANGED } from "./toolbar-parts";
48
47
  import { type ActivityState, useActivity } from "./use-activity";
@@ -416,7 +415,7 @@ const ItemRow = ({
416
415
  onOpen,
417
416
  }: {
418
417
  item: ActivityItem;
419
- onOpen: (thread: Thread, at: HTMLElement) => void;
418
+ onOpen: (thread: Thread) => void;
420
419
  }) => {
421
420
  const { t } = useLingui();
422
421
  const words: Record<ActivityItem["status"], string> = {
@@ -447,7 +446,7 @@ const ItemRow = ({
447
446
  <span className="font-medium">{words[item.status]}</span>{" "}
448
447
  <button
449
448
  className="text-muted-foreground underline decoration-foreground/25 underline-offset-[3px] outline-none hover:text-foreground hover:decoration-foreground focus-visible:text-foreground"
450
- onClick={(event) => onOpen(item.thread, event.currentTarget)}
449
+ onClick={() => onOpen(item.thread)}
451
450
  type="button"
452
451
  >
453
452
  {commentWords(item.thread)}
@@ -487,7 +486,7 @@ const Log = ({
487
486
  items: ActivityItem[];
488
487
  /** The comment the bar speaks of, kept in the log however old. */
489
488
  news?: Thread;
490
- onOpen: (thread: Thread, at: HTMLElement) => void;
489
+ onOpen: (thread: Thread) => void;
491
490
  }) => {
492
491
  const ref = useRef<HTMLDivElement>(null);
493
492
  // At the newest end, a new comment keeps it there; scrolled away to read
@@ -680,7 +679,7 @@ const PanelContent = ({
680
679
  activity: ActivityState;
681
680
  kind: PanelKind;
682
681
  onFullSetup: () => void;
683
- onOpen: (thread: Thread, at: HTMLElement) => void;
682
+ onOpen: (thread: Thread) => void;
684
683
  opensUp: boolean;
685
684
  }) => {
686
685
  const { t } = useLingui();
@@ -810,13 +809,14 @@ const PANEL_FOR: Partial<Record<BarAction, PanelKind>> = {
810
809
  * The agent heads-up, docked in a corner of the canvas: a leaf that reads
811
810
  * the live data itself, so the canvas rendering never renders it, nor it the
812
811
  * canvas. `slug` is the file whose comments its log lists; `openThread`
813
- * opens one, and stays the same function.
812
+ * moves the canvas to one and opens it at its pin (one an agent completed
813
+ * also outlines where its change landed), and stays the same function.
814
814
  */
815
815
  export const Activity = memo(function Activity({
816
816
  openThread,
817
817
  slug,
818
818
  }: {
819
- openThread: (id: string, at: ScreenPoint) => void;
819
+ openThread: (id: string) => void;
820
820
  slug: string;
821
821
  }) {
822
822
  const [connecting, setConnecting] = useState(false);
@@ -857,14 +857,7 @@ export const Activity = memo(function Activity({
857
857
  setPanel(PANEL_FOR[action]);
858
858
  };
859
859
 
860
- const openItem = (thread: Thread, at: HTMLElement) => {
861
- if (thread.status === "resolved") {
862
- activity.goToChange(thread);
863
- return;
864
- }
865
- const box = at.getBoundingClientRect();
866
- openThread(thread.id, { left: box.left, top: box.top });
867
- };
860
+ const openItem = (thread: Thread) => openThread(thread.id);
868
861
 
869
862
  const shown = panel ? (
870
863
  <PanelContent
@@ -41,7 +41,8 @@ export interface Point {
41
41
 
42
42
  type Frames = ReadonlyMap<string, Frame>;
43
43
 
44
- const isOnFrame = (target: ThreadTarget): target is OnFrameTarget =>
44
+ /** Whether a comment is on a frame: on one of its elements, or all of it. */
45
+ export const isOnFrame = (target: ThreadTarget): target is OnFrameTarget =>
45
46
  target.kind === "element" || target.kind === "frame";
46
47
 
47
48
  const sameParams = (
@@ -171,10 +172,6 @@ const indexOf = (threads: readonly Thread[], canvas: Canvas): Index => {
171
172
  export const frameOf = (thread: Thread, canvas: Canvas) =>
172
173
  anchorIn(framesOf(canvas), thread);
173
174
 
174
- /** A comment on a frame that is no longer on the canvas. */
175
- export const isOffCanvas = (thread: Thread, canvas: Canvas) =>
176
- isOnFrame(thread.target) && frameOf(thread, canvas) === undefined;
177
-
178
175
  /** The threads on one frame, wherever it has moved. */
179
176
  export const threadsOn = (
180
177
  threads: readonly Thread[],
@@ -258,6 +255,7 @@ export const locatorsOf = (target: ThreadTarget): ElementLocator[] =>
258
255
  text: target.text,
259
256
  code: target.code,
260
257
  within: target.within,
258
+ openers: target.openers,
261
259
  },
262
260
  ...(target.also ?? []),
263
261
  ...(target.openers ?? []),
@@ -1,5 +1,6 @@
1
- import { toolFromFrame, zoomCommand } from "./canvas-keys.ts";
1
+ import { isFindKey, toolFromFrame, zoomCommand } from "./canvas-keys.ts";
2
2
  import { zoomsCanvas } from "./engine/camera.ts";
3
+ import { KEEPS_POINTER, MOVING } from "./engine/canvas-store.ts";
3
4
  import { isTyping, pressesControl } from "./typing.ts";
4
5
 
5
6
  // Wheels, pinches and zoom keys that are the canvas's wherever they happen,
@@ -23,7 +24,10 @@ import { isTyping, pressesControl } from "./typing.ts";
23
24
  // every live page on it ask, keeps the canvas or the page it started on
24
25
  // moving to its end, and nothing else.
25
26
 
26
- /** Wheel events this close together are one gesture, and go one way. */
27
+ /**
28
+ * Wheel events, or the steps of a pinch, this close together are one
29
+ * gesture, and go one way.
30
+ */
27
31
  const GESTURE_GAP_MS = 200;
28
32
  /** The canvas zooms by 2^(-deltaY / 50) for a pinch on a Mac (camera.ts). */
29
33
  const PINCH_DELTA_PER_DOUBLING = 50;
@@ -181,14 +185,18 @@ const gestureOn = (element: Element) =>
181
185
  /** Wheels a frame's page passed on: the gesture sent them to the canvas. */
182
186
  const passedOn = new WeakSet<Event>();
183
187
 
184
- /** Turns Safari's pinch into the ctrl-wheel the canvas zooms by. */
188
+ /**
189
+ * Turns Safari's pinch into the ctrl-wheel the canvas zooms by. WebKit keeps
190
+ * a scale per page and can start a pinch where an earlier one on that page
191
+ * left off, so each step zooms by its change from the scale before it.
192
+ */
185
193
  const pinchAsWheel = (onWheel: (wheel: WheelEventInit) => void) => {
186
194
  let scale = 1;
187
195
  return (event: Event) => {
188
196
  const gesture = event as GestureEvent;
189
197
  event.preventDefault();
190
198
  if (event.type === "gesturestart") {
191
- scale = 1;
199
+ scale = gesture.scale || 1;
192
200
  return;
193
201
  }
194
202
  const ratio = gesture.scale / scale;
@@ -206,13 +214,54 @@ const GESTURES = ["gesturestart", "gesturechange"] as const;
206
214
 
207
215
  /**
208
216
  * The keys a frame's page passes on and takes from the page: the zoom keys,
209
- * and Escape to leave the frame. The page uses them first: an Escape that
210
- * closes a menu there, or ends typing an accent, stays.
217
+ * ⌘F, and Escape to leave the frame. The page uses them first: an Escape that
218
+ * closes a dialog or menu there, or ends typing an accent, stays.
211
219
  */
212
220
  const isCanvasKey = (event: KeyboardEvent) =>
213
221
  zoomCommand(event) !== undefined ||
222
+ isFindKey(event) ||
214
223
  (event.key === "Escape" && !event.isComposing);
215
224
 
225
+ /**
226
+ * What Escape closes on a page wherever it is pressed: a modal (a `<dialog>`
227
+ * opened with showModal, or a dialog marked aria-modal) and a popover that
228
+ * light dismisses. In `:is()`, a browser that doesn't know one of them still
229
+ * reads the others.
230
+ */
231
+ const CLOSES_ON_ESCAPE =
232
+ ':is(:modal, :popover-open:not([popover="manual" i]), [aria-modal="true"])';
233
+
234
+ /**
235
+ * What Escape closes when it is pressed in it: those, in a shadow root too,
236
+ * and a design system's dialog marked only by its role. A `<dialog>` opened
237
+ * with show() stays open.
238
+ */
239
+ const CLOSES_FROM_INSIDE = `:is(${CLOSES_ON_ESCAPE}, [role="dialog"], [role="alertdialog"])`;
240
+
241
+ /**
242
+ * Whether an element shows. One kept on the page while closed is hidden;
243
+ * browsers without the check go by its being there.
244
+ */
245
+ const shows = (element: Element) =>
246
+ element.checkVisibility?.({
247
+ opacityProperty: true,
248
+ visibilityProperty: true,
249
+ }) ?? true;
250
+
251
+ /**
252
+ * Whether `page` has a use for an Escape, asked before it hears it: one
253
+ * pressed in a dialog or popover (CLOSES_FROM_INSIDE), or while a modal or
254
+ * popover shows there, closes it. A dialog that closes without preventing
255
+ * the key is gone by the time the page's window hears it, and a `<dialog>`
256
+ * or popover closes only if the key keeps its default.
257
+ */
258
+ const pageTakesEscape = (event: KeyboardEvent, page: Window) =>
259
+ event
260
+ .composedPath()
261
+ .some(
262
+ (target) => asElement(target)?.matches(CLOSES_FROM_INSIDE) === true
263
+ ) || [...page.document.querySelectorAll(CLOSES_ON_ESCAPE)].some(shows);
264
+
216
265
  /** Menus, lists and trees, which jump to the item a letter starts. */
217
266
  const TYPES_AHEAD =
218
267
  '[role="menu"], [role="menubar"], [role="listbox"], [role="tree"], [role="treegrid"]';
@@ -260,6 +309,53 @@ const HELD_KEYS = new Set([
260
309
  "ControlRight",
261
310
  ]);
262
311
 
312
+ /**
313
+ * Keeps a frame taking the pointer while the canvas moves with the pinch its
314
+ * page passes on (engine.css), until the pinch is over and the canvas has
315
+ * settled. WebKit gives a pinch only to the page it started on, and drops
316
+ * the rest of it once that page lets the pointer through. Wheels need no
317
+ * hold: WebKit keeps a scroll with the page it started on whatever the
318
+ * pointer does, and Chromium asks where each wheel is.
319
+ */
320
+ const holdPointer = (iframe: HTMLIFrameElement) => {
321
+ const surface = iframe.closest(RENDERER);
322
+ const moving = () => surface?.classList.contains(MOVING) === true;
323
+ let pinchEnd: ReturnType<typeof setTimeout> | undefined;
324
+ const cancelRelease = () => {
325
+ clearTimeout(pinchEnd);
326
+ settling.disconnect();
327
+ };
328
+ const release = () => {
329
+ cancelRelease();
330
+ iframe.removeAttribute(KEEPS_POINTER);
331
+ };
332
+ const settling = new MutationObserver(() => {
333
+ if (!moving()) {
334
+ release();
335
+ }
336
+ });
337
+ const pinchOver = () => {
338
+ if (surface && moving()) {
339
+ settling.observe(surface, { attributeFilter: ["class"] });
340
+ } else {
341
+ release();
342
+ }
343
+ };
344
+ return {
345
+ /** A step of the pinch its page passes on. */
346
+ hold: () => {
347
+ cancelRelease();
348
+ // Marked once: a pinch steps 60 to 120 times a second.
349
+ if (!iframe.hasAttribute(KEEPS_POINTER)) {
350
+ iframe.setAttribute(KEEPS_POINTER, "true");
351
+ }
352
+ pinchEnd = setTimeout(pinchOver, GESTURE_GAP_MS);
353
+ },
354
+ /** Lets the pointer through again: its page has gone, or is unwatched. */
355
+ release,
356
+ };
357
+ };
358
+
263
359
  /**
264
360
  * Passes what is the canvas's over a frame's page on to the canvas, as wheels
265
361
  * and keys over the frame: now, and on each page the frame loads. A page from
@@ -268,6 +364,7 @@ const HELD_KEYS = new Set([
268
364
  */
269
365
  export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
270
366
  const gesture = gestureOn(iframe);
367
+ const pointer = holdPointer(iframe);
271
368
  // The page's pixels are scaled by the canvas's zoom.
272
369
  const toCanvas = (wheel: WheelEventInit) => {
273
370
  const box = iframe.getBoundingClientRect();
@@ -331,7 +428,7 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
331
428
  * Lets go of every key the page passed down: its page has gone, or lost
332
429
  * the keyboard to another app, and their key-ups will never come.
333
430
  */
334
- const release = () => {
431
+ const releaseKeys = () => {
335
432
  for (const [code, key] of down) {
336
433
  iframe.dispatchEvent(
337
434
  new KeyboardEvent("keyup", { bubbles: true, code, key })
@@ -339,8 +436,17 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
339
436
  }
340
437
  down.clear();
341
438
  };
439
+ // The Escapes the page has a use for, noted before it hears them (listen).
440
+ const pageEscapes = new WeakSet<KeyboardEvent>();
441
+ // Whether the Escape held down went to the page: its repeats go there too,
442
+ // though the dialog it closed has gone. The page's until onKey hears it: a
443
+ // press the page stops never reaches onKey.
444
+ let escapeToPage = false;
342
445
  const onKey = (event: KeyboardEvent) => {
343
- if (event.defaultPrevented) {
446
+ if (event.key === "Escape" && !event.repeat) {
447
+ escapeToPage = event.defaultPrevented || pageEscapes.has(event);
448
+ }
449
+ if (event.defaultPrevented || (event.key === "Escape" && escapeToPage)) {
344
450
  return;
345
451
  }
346
452
  // Space held is the hand, as it is over the canvas, unless the page has
@@ -387,13 +493,29 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
387
493
  const onBlur = () => {
388
494
  setTimeout(() => {
389
495
  if (!iframe.ownerDocument.hasFocus()) {
390
- release();
496
+ releaseKeys();
391
497
  }
392
498
  }, 0);
393
499
  };
394
- const onGesture = pinchAsWheel(toCanvas);
500
+ const pinch = pinchAsWheel(toCanvas);
501
+ const onGesture = (event: Event) => {
502
+ pointer.hold();
503
+ pinch(event);
504
+ };
395
505
  const listen = (page: Window) => {
506
+ const onKeyBeforePage = (event: KeyboardEvent) => {
507
+ if (event.key !== "Escape") {
508
+ return;
509
+ }
510
+ if (!event.repeat) {
511
+ escapeToPage = true;
512
+ }
513
+ if (pageTakesEscape(event, page)) {
514
+ pageEscapes.add(event);
515
+ }
516
+ };
396
517
  page.addEventListener("wheel", onWheel, { passive: false });
518
+ page.addEventListener("keydown", onKeyBeforePage, { capture: true });
397
519
  page.addEventListener("keydown", onKey);
398
520
  page.addEventListener("keyup", onKeyUp);
399
521
  page.addEventListener("blur", onBlur);
@@ -402,6 +524,7 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
402
524
  }
403
525
  return () => {
404
526
  page.removeEventListener("wheel", onWheel);
527
+ page.removeEventListener("keydown", onKeyBeforePage, { capture: true });
405
528
  page.removeEventListener("keydown", onKey);
406
529
  page.removeEventListener("keyup", onKeyUp);
407
530
  page.removeEventListener("blur", onBlur);
@@ -412,18 +535,19 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
412
535
  };
413
536
  let unlisten: (() => void) | undefined;
414
537
  const unwatch = () => {
415
- release();
538
+ releaseKeys();
416
539
  try {
417
540
  unlisten?.();
418
541
  } catch {
419
542
  // The page is from another origin now, and took its listeners with it.
420
543
  }
421
544
  unlisten = undefined;
545
+ // The page that had a gesture has gone, and the next starts afresh.
546
+ gesture.forget(iframe);
547
+ pointer.release();
422
548
  };
423
549
  const watch = () => {
424
550
  unwatch();
425
- // The page that had a gesture has gone, and the next starts afresh.
426
- gesture.forget(iframe);
427
551
  try {
428
552
  const page = iframe.contentWindow;
429
553
  unlisten = page ? listen(page) : undefined;
@@ -436,10 +560,23 @@ export const watchFrameInput = (iframe: HTMLIFrameElement): (() => void) => {
436
560
  return () => {
437
561
  iframe.removeEventListener("load", watch);
438
562
  unwatch();
439
- gesture.forget(iframe);
440
563
  };
441
564
  };
442
565
 
566
+ /**
567
+ * Gives the canvas back the keyboard, if a frame's page has it. Blurring the
568
+ * iframe is not enough: WebKit (Safari, the Dex app) leaves the keyboard in
569
+ * its page, which keeps every key but the few it passes on (watchFrameInput).
570
+ * Focusing the canvas's window takes it back there too.
571
+ */
572
+ export const takeKeyboardFrom = (iframe: HTMLIFrameElement): void => {
573
+ if (iframe.ownerDocument.activeElement !== iframe) {
574
+ return;
575
+ }
576
+ iframe.blur();
577
+ iframe.ownerDocument.defaultView?.focus();
578
+ };
579
+
443
580
  /**
444
581
  * Makes `element`, a live frame on the canvas's own page, a page of its own
445
582
  * to the canvas's wheels (canvasTakesWheel): a gesture that starts by
@@ -145,6 +145,15 @@ export const zoomCommand = (
145
145
  }
146
146
  };
147
147
 
148
+ /**
149
+ * ⌘F (Ctrl F off a Mac): find on the frames, in place of the browser's own
150
+ * find, which would search the studio around them. It works while typing.
151
+ */
152
+ export const isFindKey = (key: CanvasKey): boolean =>
153
+ (key.metaKey || key.ctrlKey) &&
154
+ !(key.altKey || key.shiftKey) &&
155
+ key.key.toLowerCase() === "f";
156
+
148
157
  /**
149
158
  * ⌘ with Z, \, A or D, and ⌥⌘Enter, Figma's Present, to play the one selected
150
159
  * frame. While wireframing, ⌘A and ⌥⌘Enter leave the frames alone.
@@ -274,18 +274,12 @@ const rowFor = (section: Section, cell: Pick<Cell, "above" | "row">): Row => {
274
274
  return row;
275
275
  };
276
276
 
277
- /** Move a frame to a cell in any section, or to a new row. */
278
- export const placeFrame = (
279
- canvas: Canvas,
280
- from: FrameAddress,
281
- to: Cell
282
- ): Canvas => moveFrame(canvas, from, to).canvas;
283
-
284
277
  /**
285
- * placeFrame, with the key the frame ends at: its id may change, when the
286
- * row it lands in has a frame by that id. A frame already on that step, as
287
- * one pushed there by another frame of the same drop is, ends where it is.
288
- * No key when there is no such frame or cell.
278
+ * Move a frame to a cell in any section, or to a new row, with the key the
279
+ * frame ends at: its id may change, when the row it lands in has a frame by
280
+ * that id. A frame already on that step, as one pushed there by another
281
+ * frame of the same drop is, ends where it is. No key when there is no such
282
+ * frame or cell.
289
283
  */
290
284
  export const moveFrame = (
291
285
  canvas: Canvas,
@@ -662,17 +656,6 @@ export const editSketch = (
662
656
  };
663
657
  };
664
658
 
665
- /** Change several frames the same way: grids on every selected frame. */
666
- export const updateFrames = (
667
- canvas: Canvas,
668
- addresses: FrameAddress[],
669
- patch: FramePatch
670
- ): Canvas =>
671
- addresses.reduce(
672
- (changed, address) => updateFrame(changed, address, patch),
673
- canvas
674
- );
675
-
676
659
  export const frameName = (frame: Frame | NewFrame): string => {
677
660
  const it = kinded(frame);
678
661
  switch (it.kind) {
@@ -837,26 +820,6 @@ export function updateSection(
837
820
  return next;
838
821
  }
839
822
 
840
- /** Move a section so it sits before `index` (or last). */
841
- export function moveSection(
842
- canvas: Canvas,
843
- sectionId: string,
844
- index: number
845
- ): Canvas {
846
- const next = clone(canvas);
847
- const from = next.sections.findIndex((section) => section.id === sectionId);
848
- if (from < 0) {
849
- return canvas;
850
- }
851
- const [section] = next.sections.splice(from, 1);
852
- if (!section) {
853
- return canvas;
854
- }
855
- const at = index > from ? index - 1 : index;
856
- next.sections.splice(Math.min(at, next.sections.length), 0, section);
857
- return next;
858
- }
859
-
860
823
  /**
861
824
  * Move a row of a section so it sits before `index` among its rows (or last).
862
825
  * The same canvas when it is there already.