@1agh/maude 0.28.0 → 0.29.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 (361) hide show
  1. package/README.md +2 -2
  2. package/{plugins/design/dev-server → apps/studio}/ai-banner.tsx +1 -1
  3. package/{plugins/design/dev-server → apps/studio}/annotations-context-toolbar.tsx +286 -6
  4. package/{plugins/design/dev-server → apps/studio}/annotations-layer.tsx +1209 -122
  5. package/{plugins/design/dev-server → apps/studio}/api.ts +486 -32
  6. package/{plugins/design/dev-server → apps/studio}/artboard-activity-overlay.tsx +1 -1
  7. package/{plugins/design/dev-server → apps/studio}/artboard-marquee.tsx +1 -1
  8. package/apps/studio/bin/_motion-sample-playwright.mjs +129 -0
  9. package/{plugins/design/dev-server → apps/studio}/bin/canvas-edit.sh +1 -1
  10. package/{plugins/design/dev-server → apps/studio}/bin/draw-proof.sh +37 -2
  11. package/{plugins/design/dev-server → apps/studio}/bin/preflight.sh +1 -1
  12. package/apps/studio/bin/read-annotations.mjs +438 -0
  13. package/apps/studio/bin/read-annotations.sh +11 -0
  14. package/{plugins/design/dev-server → apps/studio}/bin/runtime-health.sh +1 -1
  15. package/{plugins/design/dev-server → apps/studio}/bin/scenario-report.mjs +1 -1
  16. package/{plugins/design/dev-server → apps/studio}/bin/screenshot.sh +62 -2
  17. package/apps/studio/bin/server-up.sh +234 -0
  18. package/apps/studio/bin/to-lottie-verify.html +68 -0
  19. package/apps/studio/bin/to-lottie.sh +128 -0
  20. package/{plugins/design/dev-server → apps/studio}/bin/visual-sanity.sh +19 -3
  21. package/{plugins/design/dev-server → apps/studio}/build.ts +5 -3
  22. package/{plugins/design/dev-server → apps/studio}/canvas-arrowheads.ts +1 -1
  23. package/{plugins/design/dev-server → apps/studio}/canvas-comment-mount.tsx +2 -2
  24. package/apps/studio/canvas-create.ts +104 -0
  25. package/{plugins/design/dev-server → apps/studio}/canvas-cursors.ts +47 -13
  26. package/{plugins/design/dev-server → apps/studio}/canvas-icons.tsx +60 -1
  27. package/{plugins/design/dev-server → apps/studio}/canvas-lib-inline.ts +1 -1
  28. package/{plugins/design/dev-server → apps/studio}/canvas-lib-resolver.ts +1 -1
  29. package/{plugins/design/dev-server → apps/studio}/canvas-lib.tsx +41 -33
  30. package/{plugins/design/dev-server → apps/studio}/canvas-shell.tsx +57 -42
  31. package/{plugins/design/dev-server → apps/studio}/client/app.jsx +1713 -530
  32. package/apps/studio/client/canvas-url.js +81 -0
  33. package/{plugins/design/dev-server → apps/studio}/client/comments-overlay.css +41 -27
  34. package/{plugins/design/dev-server → apps/studio}/client/index.html +2 -1
  35. package/apps/studio/client/styles/1-tokens-maude.css +296 -0
  36. package/apps/studio/client/styles/3-shell-maude.css +459 -0
  37. package/{plugins/design/dev-server → apps/studio}/client/styles/3-shell.css +129 -0
  38. package/apps/studio/client/styles/4-components-maude.css +74 -0
  39. package/{plugins/design/dev-server → apps/studio}/client/styles/4-components.css +357 -34
  40. package/apps/studio/client/styles/5-maude-overrides.css +123 -0
  41. package/{plugins/design/dev-server → apps/studio}/client/styles/_index.css +9 -0
  42. package/{plugins/design/dev-server → apps/studio}/client/styles.css +1 -1
  43. package/apps/studio/client/tour/overlay.jsx +191 -0
  44. package/apps/studio/client/tour/usage-tour.js +35 -0
  45. package/apps/studio/client/whats-new-seen.js +52 -0
  46. package/apps/studio/client/whats-new.jsx +250 -0
  47. package/{plugins/design/dev-server → apps/studio}/collab/index.ts +4 -4
  48. package/{plugins/design/dev-server → apps/studio}/collab/persistence.ts +1 -1
  49. package/{plugins/design/dev-server → apps/studio}/commands/annotation-strokes-command.ts +1 -1
  50. package/{plugins/design/dev-server → apps/studio}/commands/equal-spacing-command.ts +1 -1
  51. package/{plugins/design/dev-server → apps/studio}/commands/move-artboards-command.ts +1 -1
  52. package/{plugins/design/dev-server → apps/studio}/comments-overlay.tsx +25 -6
  53. package/{plugins/design/dev-server → apps/studio}/context-menu.tsx +2 -2
  54. package/{plugins/design/dev-server → apps/studio}/contextual-toolbar.tsx +4 -7
  55. package/{plugins/design/dev-server → apps/studio}/cursors-overlay.tsx +1 -1
  56. package/apps/studio/dist/client.bundle.js +22825 -0
  57. package/apps/studio/dist/comment-mount.js +1960 -0
  58. package/apps/studio/dist/runtime/lib0_decoding.js +1 -0
  59. package/apps/studio/dist/runtime/lib0_encoding.js +1 -0
  60. package/apps/studio/dist/runtime/motion.js +4 -0
  61. package/apps/studio/dist/runtime/motion_react.js +12 -0
  62. package/apps/studio/dist/runtime/pixi-js.js +3397 -0
  63. package/apps/studio/dist/runtime/react-dom.js +1 -0
  64. package/apps/studio/dist/runtime/react-dom_client.js +9 -0
  65. package/apps/studio/dist/runtime/react.js +1 -0
  66. package/apps/studio/dist/runtime/react_jsx-dev-runtime.js +1 -0
  67. package/apps/studio/dist/runtime/react_jsx-runtime.js +1 -0
  68. package/apps/studio/dist/runtime/y-protocols_awareness.js +1 -0
  69. package/apps/studio/dist/runtime/y-protocols_sync.js +1 -0
  70. package/apps/studio/dist/runtime/yjs.js +5 -0
  71. package/apps/studio/dist/styles.css +5695 -0
  72. package/{plugins/design/dev-server → apps/studio}/dom-selection.ts +75 -4
  73. package/apps/studio/draw/animate.ts +333 -0
  74. package/{plugins/design/dev-server → apps/studio}/draw/brush.ts +4 -4
  75. package/{plugins/design/dev-server → apps/studio}/draw/composition.ts +1 -1
  76. package/{plugins/design/dev-server → apps/studio}/draw/geometry.ts +1 -1
  77. package/{plugins/design/dev-server → apps/studio}/draw/index.ts +9 -6
  78. package/{plugins/design/dev-server → apps/studio}/draw/layout.ts +2 -2
  79. package/apps/studio/draw/morph.ts +204 -0
  80. package/{plugins/design/dev-server → apps/studio}/draw/optimize.ts +1 -1
  81. package/{plugins/design/dev-server → apps/studio}/draw/palette.ts +1 -1
  82. package/{plugins/design/dev-server → apps/studio}/draw/primitives.ts +1 -1
  83. package/apps/studio/draw/serialize-animate.ts +324 -0
  84. package/{plugins/design/dev-server → apps/studio}/draw/serialize.ts +9 -3
  85. package/apps/studio/draw/test/animate.test.ts +172 -0
  86. package/{plugins/design/dev-server → apps/studio}/draw/test/layout.test.ts +1 -1
  87. package/apps/studio/draw/test/morph.test.ts +107 -0
  88. package/apps/studio/draw/test/serialize-animate.test.ts +142 -0
  89. package/{plugins/design/dev-server → apps/studio}/draw/test/serialize.test.ts +1 -1
  90. package/{plugins/design/dev-server → apps/studio}/equal-spacing-detector.ts +1 -1
  91. package/{plugins/design/dev-server → apps/studio}/equal-spacing-handles.tsx +7 -29
  92. package/{plugins/design/dev-server → apps/studio}/examples/perf-100-artboards.tsx +1 -2
  93. package/{plugins/design/dev-server → apps/studio}/export-dialog.tsx +14 -2
  94. package/{plugins/design/dev-server → apps/studio}/exporters/index.ts +2 -2
  95. package/{plugins/design/dev-server → apps/studio}/http.ts +103 -2
  96. package/{plugins/design/dev-server → apps/studio}/input-router.tsx +8 -1
  97. package/{plugins/design/dev-server → apps/studio}/inspect.ts +20 -3
  98. package/{plugins/design/dev-server → apps/studio}/marquee-overlay.tsx +6 -3
  99. package/{plugins/design/dev-server → apps/studio}/participants-chrome.tsx +1 -1
  100. package/{plugins/design/dev-server → apps/studio}/paths.ts +15 -11
  101. package/{plugins/design/dev-server → apps/studio}/server.ts +19 -1
  102. package/{plugins/design/dev-server → apps/studio}/sync/index.ts +6 -6
  103. package/{plugins/design/dev-server → apps/studio}/sync/materialize.ts +2 -2
  104. package/{plugins/design/dev-server → apps/studio}/test/ai-activity.test.ts +1 -1
  105. package/{plugins/design/dev-server → apps/studio}/test/annotations-api.test.ts +1 -2
  106. package/{plugins/design/dev-server → apps/studio}/test/annotations-layer.test.ts +69 -6
  107. package/{plugins/design/dev-server → apps/studio}/test/annotations-roundtrip.test.ts +98 -1
  108. package/apps/studio/test/annotations-text-format.test.ts +396 -0
  109. package/apps/studio/test/asset-api.test.ts +149 -0
  110. package/{plugins/design/dev-server → apps/studio}/test/boot-self-heal.test.ts +1 -1
  111. package/apps/studio/test/canvas-create-api.test.ts +361 -0
  112. package/{plugins/design/dev-server → apps/studio}/test/canvas-cursors.test.ts +3 -1
  113. package/{plugins/design/dev-server → apps/studio}/test/canvas-edit.test.ts +1 -1
  114. package/{plugins/design/dev-server → apps/studio}/test/canvas-hmr-runtime.test.tsx +1 -1
  115. package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-inline.test.ts +1 -1
  116. package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-resolver.test.ts +2 -3
  117. package/apps/studio/test/canvas-media-drop.test.ts +158 -0
  118. package/{plugins/design/dev-server → apps/studio}/test/canvas-meta-api.test.ts +1 -2
  119. package/{plugins/design/dev-server → apps/studio}/test/canvas-origin-gate.test.ts +18 -3
  120. package/apps/studio/test/canvas-url.test.ts +99 -0
  121. package/{plugins/design/dev-server → apps/studio}/test/collab-annotations-bridge.test.ts +1 -1
  122. package/{plugins/design/dev-server → apps/studio}/test/collab-bridge.test.ts +1 -1
  123. package/{plugins/design/dev-server → apps/studio}/test/collab-room.test.ts +1 -1
  124. package/{plugins/design/dev-server → apps/studio}/test/collab-stress.test.ts +1 -1
  125. package/{plugins/design/dev-server → apps/studio}/test/comments-api.test.ts +1 -2
  126. package/{plugins/design/dev-server → apps/studio}/test/compile-entry.test.ts +1 -2
  127. package/{plugins/design/dev-server → apps/studio}/test/exporters/canva.test.ts +1 -2
  128. package/{plugins/design/dev-server → apps/studio}/test/exporters/history.test.ts +1 -2
  129. package/{plugins/design/dev-server → apps/studio}/test/exporters/pw-launch.test.ts +1 -1
  130. package/{plugins/design/dev-server → apps/studio}/test/exporters/scope.test.ts +1 -2
  131. package/{plugins/design/dev-server → apps/studio}/test/exporters/zip.test.ts +1 -2
  132. package/{plugins/design/dev-server → apps/studio}/test/git-lifecycle.test.ts +1 -2
  133. package/{plugins/design/dev-server → apps/studio}/test/handoff-static-frames.test.ts +1 -1
  134. package/{plugins/design/dev-server → apps/studio}/test/hmr-broadcast.test.ts +1 -1
  135. package/apps/studio/test/index-data-canvas-ds.test.ts +97 -0
  136. package/apps/studio/test/motion-sample.test.ts +35 -0
  137. package/{plugins/design/dev-server → apps/studio}/test/perf-harness.ts +1 -1
  138. package/{plugins/design/dev-server → apps/studio}/test/phase-3.6-smoke.test.ts +3 -1
  139. package/apps/studio/test/read-annotations.test.ts +409 -0
  140. package/{plugins/design/dev-server → apps/studio}/test/runtime-bundle.test.ts +1 -1
  141. package/{plugins/design/dev-server → apps/studio}/test/sanitize-annotation-svg.test.ts +108 -2
  142. package/{plugins/design/dev-server → apps/studio}/test/shared-doc-convergence.test.ts +2 -2
  143. package/{plugins/design/dev-server → apps/studio}/test/shared-doc-migrate.test.ts +2 -3
  144. package/{plugins/design/dev-server → apps/studio}/test/shared-doc-projection.test.ts +1 -1
  145. package/{plugins/design/dev-server → apps/studio}/test/snap-distance-pill.test.ts +1 -1
  146. package/{plugins/design/dev-server → apps/studio}/test/sync-agent.test.ts +2 -3
  147. package/{plugins/design/dev-server → apps/studio}/test/sync-atomic-write.test.ts +2 -3
  148. package/{plugins/design/dev-server → apps/studio}/test/sync-connection-state.test.ts +1 -1
  149. package/{plugins/design/dev-server → apps/studio}/test/sync-echo-guard.test.ts +1 -1
  150. package/{plugins/design/dev-server → apps/studio}/test/sync-fs-mirror.test.ts +1 -2
  151. package/{plugins/design/dev-server → apps/studio}/test/sync-hardening.test.ts +4 -5
  152. package/{plugins/design/dev-server → apps/studio}/test/sync-hubs-config.test.ts +1 -2
  153. package/{plugins/design/dev-server → apps/studio}/test/sync-runtime.test.ts +3 -8
  154. package/{plugins/design/dev-server → apps/studio}/test/sync-status.test.ts +1 -1
  155. package/{plugins/design/dev-server → apps/studio}/test/sync-untrusted.test.ts +1 -2
  156. package/apps/studio/test/tour-overlay.test.tsx +56 -0
  157. package/{plugins/design/dev-server → apps/studio}/test/use-agent-presence.test.tsx +4 -1
  158. package/{plugins/design/dev-server → apps/studio}/test/use-annotation-resize.test.ts +43 -0
  159. package/{plugins/design/dev-server → apps/studio}/test/use-snap-guides.test.ts +1 -1
  160. package/{plugins/design/dev-server → apps/studio}/test/use-tool-mode.test.tsx +4 -1
  161. package/apps/studio/test/whats-new.test.ts +101 -0
  162. package/apps/studio/text-imports.d.ts +9 -0
  163. package/{plugins/design/dev-server → apps/studio}/tool-palette.tsx +4 -69
  164. package/{plugins/design/dev-server → apps/studio}/undo-hud.tsx +1 -1
  165. package/{plugins/design/dev-server → apps/studio}/undo-stack.ts +1 -1
  166. package/{plugins/design/dev-server → apps/studio}/use-agent-presence.tsx +2 -2
  167. package/{plugins/design/dev-server → apps/studio}/use-annotation-resize.tsx +41 -12
  168. package/{plugins/design/dev-server → apps/studio}/use-annotation-selection.tsx +3 -7
  169. package/{plugins/design/dev-server → apps/studio}/use-annotations-visibility.tsx +2 -2
  170. package/{plugins/design/dev-server → apps/studio}/use-artboard-drag.tsx +2 -2
  171. package/{plugins/design/dev-server → apps/studio}/use-canvas-activity.tsx +2 -2
  172. package/apps/studio/use-canvas-media-drop.tsx +343 -0
  173. package/{plugins/design/dev-server → apps/studio}/use-collab.tsx +4 -5
  174. package/{plugins/design/dev-server → apps/studio}/use-cursor-modifiers.tsx +1 -1
  175. package/{plugins/design/dev-server → apps/studio}/use-keyboard-discipline.tsx +5 -2
  176. package/{plugins/design/dev-server → apps/studio}/use-selection-set.tsx +10 -2
  177. package/{plugins/design/dev-server → apps/studio}/use-snap-guides.tsx +1 -1
  178. package/{plugins/design/dev-server → apps/studio}/use-tool-mode.tsx +4 -2
  179. package/{plugins/design/dev-server → apps/studio}/use-undo-stack.tsx +5 -6
  180. package/apps/studio/whats-new.json +139 -0
  181. package/apps/studio/whats-new.schema.json +70 -0
  182. package/apps/studio/whats-new.ts +87 -0
  183. package/cli/bin/maude.mjs +10 -0
  184. package/cli/commands/design.mjs +84 -10
  185. package/cli/commands/design.test.mjs +133 -1
  186. package/cli/commands/help.mjs +8 -2
  187. package/cli/commands/hub.mjs +3 -3
  188. package/cli/commands/hub.test.mjs +1 -1
  189. package/cli/commands/scenario-report.mjs +2 -9
  190. package/cli/lib/cache.mjs +1 -1
  191. package/cli/lib/config-lint.mjs +1 -1
  192. package/cli/lib/copy-tree.mjs +1 -1
  193. package/cli/lib/design-link.mjs +1 -1
  194. package/cli/lib/flow-design-integration.test.mjs +2 -2
  195. package/cli/lib/gitignore-block.mjs +1 -0
  196. package/cli/lib/gitignore-block.test.mjs +2 -2
  197. package/cli/lib/plugin-cli-reachability.test.mjs +8 -7
  198. package/cli/lib/preflight.mjs +1 -1
  199. package/cli/lib/stack-detect.mjs +1 -1
  200. package/package.json +16 -16
  201. package/plugins/design/templates/_shell.html +3 -3
  202. package/plugins/design/templates/brief-board.tsx.template +61 -0
  203. package/plugins/design/templates/canvas.tsx.template +1 -1
  204. package/plugins/design/templates/design-system-inspiration/SUB-AGENT-PROMPTS.md +18 -3
  205. package/plugins/design/templates/design-system-inspiration/core/config.json.tpl +1 -1
  206. package/plugins/design/templates/design-system-inspiration/core/preview/_motion-readme.md.tpl +1 -1
  207. package/plugins/flow/.claude-plugin/config.schema.json +16 -0
  208. package/plugins/design/dev-server/bin/server-up.sh +0 -135
  209. package/plugins/design/dev-server/dist/client.bundle.js +0 -20692
  210. package/plugins/design/dev-server/dist/comment-mount.js +0 -1924
  211. package/plugins/design/dev-server/dist/runtime/lib0_decoding.js +0 -620
  212. package/plugins/design/dev-server/dist/runtime/lib0_encoding.js +0 -604
  213. package/plugins/design/dev-server/dist/runtime/motion.js +0 -4944
  214. package/plugins/design/dev-server/dist/runtime/motion_react.js +0 -10056
  215. package/plugins/design/dev-server/dist/runtime/pixi-js.js +0 -53104
  216. package/plugins/design/dev-server/dist/runtime/react-dom.js +0 -231
  217. package/plugins/design/dev-server/dist/runtime/react-dom_client.js +0 -10357
  218. package/plugins/design/dev-server/dist/runtime/react.js +0 -535
  219. package/plugins/design/dev-server/dist/runtime/react_jsx-dev-runtime.js +0 -60
  220. package/plugins/design/dev-server/dist/runtime/react_jsx-runtime.js +0 -85
  221. package/plugins/design/dev-server/dist/runtime/y-protocols_awareness.js +0 -376
  222. package/plugins/design/dev-server/dist/runtime/y-protocols_sync.js +0 -100
  223. package/plugins/design/dev-server/dist/runtime/yjs.js +0 -6687
  224. package/plugins/design/dev-server/dist/styles.css +0 -2710
  225. package/{plugins/design/dev-server → apps/studio}/activity.ts +0 -0
  226. package/{plugins/design/dev-server → apps/studio}/bin/_enumerate-artboards-playwright.mjs +0 -0
  227. package/{plugins/design/dev-server → apps/studio}/bin/_html-playwright.mjs +0 -0
  228. package/{plugins/design/dev-server → apps/studio}/bin/_pdf-playwright.mjs +0 -0
  229. package/{plugins/design/dev-server → apps/studio}/bin/_png-playwright.mjs +0 -0
  230. package/{plugins/design/dev-server → apps/studio}/bin/_pptx-playwright.mjs +0 -0
  231. package/{plugins/design/dev-server → apps/studio}/bin/_pw-launch.mjs +0 -0
  232. package/{plugins/design/dev-server → apps/studio}/bin/_screenshot-playwright.mjs +0 -0
  233. package/{plugins/design/dev-server → apps/studio}/bin/_svg-optimize.mjs +0 -0
  234. package/{plugins/design/dev-server → apps/studio}/bin/_svg-playwright.mjs +0 -0
  235. package/{plugins/design/dev-server → apps/studio}/bin/asset-sweep.sh +0 -0
  236. package/{plugins/design/dev-server → apps/studio}/bin/bootstrap-check.sh +0 -0
  237. package/{plugins/design/dev-server → apps/studio}/bin/check-runtime-bundles.sh +0 -0
  238. package/{plugins/design/dev-server → apps/studio}/bin/draw-build.sh +0 -0
  239. package/{plugins/design/dev-server → apps/studio}/bin/handoff.sh +0 -0
  240. package/{plugins/design/dev-server → apps/studio}/bin/prep.sh +0 -0
  241. package/{plugins/design/dev-server → apps/studio}/bin/slug.sh +0 -0
  242. package/{plugins/design/dev-server → apps/studio}/bin/smoke.sh +0 -0
  243. package/{plugins/design/dev-server → apps/studio}/bin/svg-optimize.sh +0 -0
  244. package/{plugins/design/dev-server → apps/studio}/boot-self-heal.ts +0 -0
  245. package/{plugins/design/dev-server → apps/studio}/canvas-build.ts +0 -0
  246. package/{plugins/design/dev-server → apps/studio}/canvas-edit.ts +0 -0
  247. package/{plugins/design/dev-server → apps/studio}/canvas-header.ts +0 -0
  248. package/{plugins/design/dev-server → apps/studio}/canvas-meta.schema.json +0 -0
  249. package/{plugins/design/dev-server → apps/studio}/canvas-pipeline.ts +0 -0
  250. package/{plugins/design/dev-server → apps/studio}/client/hmr.mjs +0 -0
  251. package/{plugins/design/dev-server → apps/studio}/client/iframe-lazy.mjs +0 -0
  252. package/{plugins/design/dev-server → apps/studio}/client/styles/0-reset.css +0 -0
  253. package/{plugins/design/dev-server → apps/studio}/client/styles/1-tokens.css +0 -0
  254. package/{plugins/design/dev-server → apps/studio}/client/styles/2-layout.css +0 -0
  255. package/{plugins/design/dev-server → apps/studio}/client/styles/5-utilities.css +0 -0
  256. package/{plugins/design/dev-server → apps/studio}/collab/ai-activity.ts +0 -0
  257. package/{plugins/design/dev-server → apps/studio}/collab/awareness-bridge.ts +1 -1
  258. package/{plugins/design/dev-server → apps/studio}/collab/git-lifecycle.ts +0 -0
  259. package/{plugins/design/dev-server → apps/studio}/collab/protocol.ts +0 -0
  260. package/{plugins/design/dev-server → apps/studio}/collab/registry.ts +0 -0
  261. package/{plugins/design/dev-server → apps/studio}/collab/room.ts +0 -0
  262. package/{plugins/design/dev-server → apps/studio}/config.schema.json +0 -0
  263. package/{plugins/design/dev-server → apps/studio}/context.ts +0 -0
  264. package/{plugins/design/dev-server → apps/studio}/dist/runtime/.min-sizes.json +0 -0
  265. package/{plugins/design/dev-server → apps/studio}/draw/test/brush.test.ts +0 -0
  266. package/{plugins/design/dev-server → apps/studio}/draw/test/composition.test.ts +0 -0
  267. package/{plugins/design/dev-server → apps/studio}/draw/test/geometry.test.ts +1 -1
  268. package/{plugins/design/dev-server → apps/studio}/draw/test/gradient.test.ts +0 -0
  269. package/{plugins/design/dev-server → apps/studio}/draw/test/optimize.test.ts +0 -0
  270. package/{plugins/design/dev-server → apps/studio}/draw/test/palette.test.ts +0 -0
  271. package/{plugins/design/dev-server → apps/studio}/draw/test/primitives.test.ts +1 -1
  272. package/{plugins/design/dev-server → apps/studio}/examples/README.md +0 -0
  273. package/{plugins/design/dev-server → apps/studio}/exporters/_browser-bundles.ts +0 -0
  274. package/{plugins/design/dev-server → apps/studio}/exporters/canva-handoff-prompt.ts +0 -0
  275. package/{plugins/design/dev-server → apps/studio}/exporters/canva.ts +0 -0
  276. package/{plugins/design/dev-server → apps/studio}/exporters/html.ts +1 -1
  277. package/{plugins/design/dev-server → apps/studio}/exporters/pdf.ts +1 -1
  278. package/{plugins/design/dev-server → apps/studio}/exporters/png.ts +1 -1
  279. package/{plugins/design/dev-server → apps/studio}/exporters/pptx.ts +1 -1
  280. package/{plugins/design/dev-server → apps/studio}/exporters/scope.ts +0 -0
  281. package/{plugins/design/dev-server → apps/studio}/exporters/svg.ts +1 -1
  282. package/{plugins/design/dev-server → apps/studio}/exporters/zip.ts +0 -0
  283. package/{plugins/design/dev-server → apps/studio}/fs-watch.ts +0 -0
  284. package/{plugins/design/dev-server → apps/studio}/handoff.ts +0 -0
  285. package/{plugins/design/dev-server → apps/studio}/history.ts +0 -0
  286. package/{plugins/design/dev-server → apps/studio}/hmr-broadcast.ts +0 -0
  287. package/{plugins/design/dev-server → apps/studio}/locator.ts +0 -0
  288. package/{plugins/design/dev-server → apps/studio}/mem.ts +0 -0
  289. package/{plugins/design/dev-server → apps/studio}/runtime-bundle.ts +0 -0
  290. package/{plugins/design/dev-server → apps/studio}/server.mjs +0 -0
  291. package/{plugins/design/dev-server → apps/studio}/sync/agent.ts +1 -1
  292. package/{plugins/design/dev-server → apps/studio}/sync/atomic-write.ts +0 -0
  293. package/{plugins/design/dev-server → apps/studio}/sync/codec.ts +0 -0
  294. package/{plugins/design/dev-server → apps/studio}/sync/connection-state.ts +0 -0
  295. package/{plugins/design/dev-server → apps/studio}/sync/echo-guard.ts +0 -0
  296. package/{plugins/design/dev-server → apps/studio}/sync/fs-mirror.ts +0 -0
  297. package/{plugins/design/dev-server → apps/studio}/sync/hubs-config.ts +0 -0
  298. package/{plugins/design/dev-server → apps/studio}/sync/migrate-seed.ts +1 -1
  299. package/{plugins/design/dev-server → apps/studio}/sync/origins.ts +0 -0
  300. package/{plugins/design/dev-server → apps/studio}/sync/projection.ts +3 -3
  301. package/{plugins/design/dev-server → apps/studio}/sync/status.ts +0 -0
  302. package/{plugins/design/dev-server → apps/studio}/sync/untrusted.ts +0 -0
  303. package/{plugins/design/dev-server → apps/studio}/test/_helpers.ts +0 -0
  304. package/{plugins/design/dev-server → apps/studio}/test/active-state.test.ts +0 -0
  305. package/{plugins/design/dev-server → apps/studio}/test/activity.test.ts +0 -0
  306. package/{plugins/design/dev-server → apps/studio}/test/annotation-strokes-command.test.ts +0 -0
  307. package/{plugins/design/dev-server → apps/studio}/test/annotations-draw-modifiers.test.ts +2 -2
  308. package/{plugins/design/dev-server → apps/studio}/test/artboard-activity-overlay.test.tsx +0 -0
  309. package/{plugins/design/dev-server → apps/studio}/test/binary-smoke.test.ts +0 -0
  310. package/{plugins/design/dev-server → apps/studio}/test/bundle-smoke.test.ts +0 -0
  311. package/{plugins/design/dev-server → apps/studio}/test/canvas-build.test.ts +0 -0
  312. package/{plugins/design/dev-server → apps/studio}/test/canvas-header.test.ts +1 -1
  313. package/{plugins/design/dev-server → apps/studio}/test/canvas-lib-motion.test.ts +0 -0
  314. package/{plugins/design/dev-server → apps/studio}/test/canvas-pipeline.test.ts +0 -0
  315. package/{plugins/design/dev-server → apps/studio}/test/canvas-route.test.ts +0 -0
  316. package/{plugins/design/dev-server → apps/studio}/test/collab-awareness-bridge.test.ts +0 -0
  317. package/{plugins/design/dev-server → apps/studio}/test/collab-loopback.test.ts +0 -0
  318. package/{plugins/design/dev-server → apps/studio}/test/collab-protocol.test.ts +2 -2
  319. package/{plugins/design/dev-server → apps/studio}/test/collab-reseed-guard.test.ts +0 -0
  320. package/{plugins/design/dev-server → apps/studio}/test/comment-mount.test.ts +0 -0
  321. package/{plugins/design/dev-server → apps/studio}/test/context-resolve-tokens.test.ts +0 -0
  322. package/{plugins/design/dev-server → apps/studio}/test/csp-canvas-shell.test.ts +0 -0
  323. package/{plugins/design/dev-server → apps/studio}/test/equal-spacing-detector.test.ts +0 -0
  324. package/{plugins/design/dev-server → apps/studio}/test/exporters/endpoint.test.ts +0 -0
  325. package/{plugins/design/dev-server → apps/studio}/test/exporters/html.test.ts +0 -0
  326. package/{plugins/design/dev-server → apps/studio}/test/exporters/pdf.test.ts +0 -0
  327. package/{plugins/design/dev-server → apps/studio}/test/exporters/png.test.ts +0 -0
  328. package/{plugins/design/dev-server → apps/studio}/test/exporters/pptx-deck.test.ts +0 -0
  329. package/{plugins/design/dev-server → apps/studio}/test/exporters/pptx.test.ts +0 -0
  330. package/{plugins/design/dev-server → apps/studio}/test/exporters/svg.test.ts +0 -0
  331. package/{plugins/design/dev-server → apps/studio}/test/fixtures/phase-20-annotations.svg +0 -0
  332. package/{plugins/design/dev-server → apps/studio}/test/fixtures/phase-21-annotations.svg +0 -0
  333. package/{plugins/design/dev-server → apps/studio}/test/fs-watch.test.ts +0 -0
  334. package/{plugins/design/dev-server → apps/studio}/test/handoff.test.ts +1 -1
  335. package/{plugins/design/dev-server → apps/studio}/test/history-rollback.test.ts +0 -0
  336. package/{plugins/design/dev-server → apps/studio}/test/hmr-classify.test.ts +0 -0
  337. package/{plugins/design/dev-server → apps/studio}/test/input-router.test.ts +2 -2
  338. package/{plugins/design/dev-server → apps/studio}/test/locator.test.ts +1 -1
  339. package/{plugins/design/dev-server → apps/studio}/test/marquee-overlay.test.ts +0 -0
  340. package/{plugins/design/dev-server → apps/studio}/test/move-artboards-command.test.ts +0 -0
  341. package/{plugins/design/dev-server → apps/studio}/test/participants-chrome.test.ts +0 -0
  342. package/{plugins/design/dev-server → apps/studio}/test/paths.test.ts +0 -0
  343. package/{plugins/design/dev-server → apps/studio}/test/runtime-bundle-error-mapping.test.ts +0 -0
  344. package/{plugins/design/dev-server → apps/studio}/test/server-lifecycle.test.ts +0 -0
  345. package/{plugins/design/dev-server → apps/studio}/test/shared-doc-foundation.test.ts +0 -0
  346. package/{plugins/design/dev-server → apps/studio}/test/sync-codec.test.ts +1 -1
  347. package/{plugins/design/dev-server → apps/studio}/test/sync-meta-codec.test.ts +1 -1
  348. package/{plugins/design/dev-server → apps/studio}/test/system-endpoint.test.ts +0 -0
  349. package/{plugins/design/dev-server → apps/studio}/test/tool-palette.test.tsx +0 -0
  350. package/{plugins/design/dev-server → apps/studio}/test/undo-stack.test.ts +2 -2
  351. package/{plugins/design/dev-server → apps/studio}/test/use-annotation-selection.test.tsx +0 -0
  352. package/{plugins/design/dev-server → apps/studio}/test/use-artboard-drag.test.ts +3 -3
  353. package/{plugins/design/dev-server → apps/studio}/test/use-canvas-activity.test.tsx +2 -2
  354. package/{plugins/design/dev-server → apps/studio}/test/use-collab.test.ts +0 -0
  355. package/{plugins/design/dev-server → apps/studio}/test/use-cursor-modifiers.test.ts +0 -0
  356. package/{plugins/design/dev-server → apps/studio}/test/use-keyboard-discipline.test.ts +0 -0
  357. package/{plugins/design/dev-server → apps/studio}/test/use-selection-set.test.tsx +1 -1
  358. package/{plugins/design/dev-server → apps/studio}/test/use-undo-stack.test.tsx +2 -2
  359. /package/{plugins/design/dev-server → apps/studio}/test/ws-handshake.test.ts +0 -0
  360. /package/{plugins/design/dev-server → apps/studio}/tsconfig.json +0 -0
  361. /package/{plugins/design/dev-server → apps/studio}/ws.ts +0 -0
@@ -14,12 +14,14 @@ import { GlobalRegistrator } from '@happy-dom/global-registrator';
14
14
 
15
15
  import {
16
16
  type ArrowStroke,
17
+ type ImageStroke,
18
+ type LinkStroke,
17
19
  type RectStroke,
18
20
  type StickyStroke,
19
21
  type Stroke,
20
- type TextStroke,
21
22
  strokesToSvg,
22
23
  svgToStrokes,
24
+ type TextStroke,
23
25
  } from '../annotations-layer.tsx';
24
26
  import { sanitizeAnnotationSvg } from '../api.ts';
25
27
 
@@ -217,6 +219,101 @@ describe('annotations round-trip / arrow heads + dash (4 dirs × 2 dash)', () =>
217
219
  }
218
220
  });
219
221
 
222
+ describe('annotations round-trip / image (Phase 23)', () => {
223
+ const image: ImageStroke = {
224
+ id: 'im1',
225
+ tool: 'image',
226
+ x: 120,
227
+ y: 80,
228
+ w: 320,
229
+ h: 240,
230
+ href: 'assets/a1b2c3d4.png',
231
+ };
232
+
233
+ test('image survives serialize → parse with all fields intact', () => {
234
+ const [parsed] = svgToStrokes(strokesToSvg([image])) as ImageStroke[];
235
+ expect(parsed).toEqual(image);
236
+ });
237
+
238
+ test('image alt text round-trips via data-alt', () => {
239
+ const withAlt: ImageStroke = { ...image, alt: 'competitor pricing page' };
240
+ const svg = strokesToSvg([withAlt]);
241
+ expect(svg).toContain('data-alt="competitor pricing page"');
242
+ const [parsed] = svgToStrokes(svg) as ImageStroke[];
243
+ expect(parsed?.alt).toBe('competitor pricing page');
244
+ });
245
+
246
+ test('image with no alt omits data-alt (no phantom default)', () => {
247
+ const svg = strokesToSvg([image]);
248
+ expect(svg).not.toContain('data-alt');
249
+ const [parsed] = svgToStrokes(svg) as ImageStroke[];
250
+ expect(parsed?.alt).toBeUndefined();
251
+ });
252
+
253
+ test('image persists a relative assets href (never a data: URL)', () => {
254
+ const svg = strokesToSvg([image]);
255
+ expect(svg).toContain('href="assets/a1b2c3d4.png"');
256
+ expect(svg).not.toContain('data:');
257
+ });
258
+
259
+ test('image serialize → parse is idempotent', () => {
260
+ const once = strokesToSvg([{ ...image, alt: 'x' }]);
261
+ expect(reparse(once)).toBe(once);
262
+ });
263
+
264
+ test('image SVG survives sanitizeAnnotationSvg byte-intact (PUT-path)', () => {
265
+ // The assets href must SURVIVE the sanitizer (Task 4 relaxation), so the
266
+ // persisted form comes back unchanged on every PUT.
267
+ const svg = strokesToSvg([image]);
268
+ expect(sanitizeAnnotationSvg(svg)).toBe(svg);
269
+ });
270
+ });
271
+
272
+ describe('annotations round-trip / link chip (Phase 23)', () => {
273
+ const link: LinkStroke = {
274
+ id: 'lk1',
275
+ tool: 'link',
276
+ x: 60,
277
+ y: 40,
278
+ w: 260,
279
+ h: 76,
280
+ url: 'https://example.com/blog/post?ref=maude',
281
+ title: 'A reference post worth reacting to',
282
+ domain: 'example.com',
283
+ };
284
+
285
+ test('link survives serialize → parse with all fields intact', () => {
286
+ const [parsed] = svgToStrokes(strokesToSvg([link])) as LinkStroke[];
287
+ expect(parsed).toEqual(link);
288
+ });
289
+
290
+ test('link never persists an <a href> (click-to-open is client-only)', () => {
291
+ const svg = strokesToSvg([link]);
292
+ expect(svg).not.toContain('<a ');
293
+ expect(svg).toContain('data-url="https://example.com/blog/post?ref=maude"');
294
+ });
295
+
296
+ test('link serialize → parse is idempotent (even with a long title)', () => {
297
+ const once = strokesToSvg([{ ...link, title: 'x'.repeat(200) }]);
298
+ expect(reparse(once)).toBe(once);
299
+ });
300
+
301
+ test('link SVG survives sanitizeAnnotationSvg byte-intact (PUT-path)', () => {
302
+ // rect/svg/path/text/data-* are all allowlisted; no on*/style/href → unchanged.
303
+ const svg = strokesToSvg([link]);
304
+ expect(sanitizeAnnotationSvg(svg)).toBe(svg);
305
+ });
306
+
307
+ test('link missing data-title falls back to the domain', () => {
308
+ const svg =
309
+ '<svg xmlns="http://www.w3.org/2000/svg" data-mdcc-annotations="1">' +
310
+ '<g data-id="lk2" data-tool="link" data-url="https://x.io" data-domain="x.io">' +
311
+ '<rect x="0" y="0" width="260" height="76" rx="8" ry="8"/></g></svg>';
312
+ const [parsed] = svgToStrokes(svg) as LinkStroke[];
313
+ expect(parsed?.title).toBe('x.io');
314
+ });
315
+ });
316
+
220
317
  describe('annotations round-trip / standalone vs anchored text', () => {
221
318
  test('standalone text round-trips its world (x, y) and stays unanchored', () => {
222
319
  const t: TextStroke = {
@@ -0,0 +1,396 @@
1
+ // annotations text-format polish — multi-line tspans, italic / underline,
2
+ // ordered + unordered lists, dashed shapes, and the highlighter pen. The PARSE
3
+ // side needs a DOMParser (happy-dom, registered per-file). The load-bearing
4
+ // assertions: every NEW field serializes ONLY when set (the byte-identical
5
+ // round-trip canary holds for legacy/unstyled strokes), and multi-line text
6
+ // reconstructs its `\n` from tspans (list markers stripped).
7
+
8
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
9
+ import { GlobalRegistrator } from '@happy-dom/global-registrator';
10
+
11
+ import {
12
+ type EllipseStroke,
13
+ listPrefixedBody,
14
+ type PenStroke,
15
+ type RectStroke,
16
+ type StickyStroke,
17
+ splitTextLines,
18
+ stickyCornerPath,
19
+ stripEditorMarkers,
20
+ strokeBBox,
21
+ strokesToSvg,
22
+ svgToStrokes,
23
+ type TextStroke,
24
+ } from '../annotations-layer.tsx';
25
+ import { sanitizeAnnotationSvg } from '../api.ts';
26
+
27
+ beforeAll(() => {
28
+ GlobalRegistrator.register();
29
+ });
30
+ afterAll(async () => {
31
+ await GlobalRegistrator.unregister();
32
+ });
33
+
34
+ /** Re-serialize a freshly-parsed SVG. Idempotency helper. */
35
+ function reparse(svg: string): string {
36
+ return strokesToSvg(svgToStrokes(svg));
37
+ }
38
+
39
+ const baseStandalone: TextStroke = {
40
+ id: 't1',
41
+ tool: 'text',
42
+ color: '#1f1f1f',
43
+ fontSize: 14,
44
+ text: 'one line',
45
+ x: 40,
46
+ y: 60,
47
+ };
48
+
49
+ // ─────────────────────────────────────────────────────────────────────────────
50
+ // Multi-line text (item 4a)
51
+
52
+ describe('text-format / multi-line tspans', () => {
53
+ test('single-line text emits NO tspan and round-trips byte-identical', () => {
54
+ const svg = strokesToSvg([baseStandalone]);
55
+ expect(svg).not.toContain('<tspan');
56
+ expect(reparse(svg)).toBe(svg);
57
+ });
58
+
59
+ test('standalone multi-line text emits one tspan per line and recovers \\n', () => {
60
+ const multi: TextStroke = { ...baseStandalone, text: 'line one\nline two\nline three' };
61
+ const svg = strokesToSvg([multi]);
62
+ expect((svg.match(/<tspan/g) ?? []).length).toBe(3);
63
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
64
+ expect(parsed?.text).toBe('line one\nline two\nline three');
65
+ expect(reparse(svg)).toBe(svg); // idempotent
66
+ });
67
+
68
+ test('anchored multi-line text round-trips its \\n', () => {
69
+ const anchored: TextStroke = {
70
+ id: 'ta',
71
+ tool: 'text',
72
+ color: '#1f1f1f',
73
+ fontSize: 16,
74
+ text: 'top\nbottom',
75
+ anchorId: 'host-1',
76
+ };
77
+ const svg = strokesToSvg([anchored]);
78
+ expect(svg).toContain('<tspan');
79
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
80
+ expect(parsed?.anchorId).toBe('host-1');
81
+ expect(parsed?.text).toBe('top\nbottom');
82
+ expect(reparse(svg)).toBe(svg);
83
+ });
84
+
85
+ test('multi-line text survives the PUT-path sanitizer byte-intact (tspan allowlisted)', () => {
86
+ const svg = strokesToSvg([{ ...baseStandalone, text: 'a\nb' }]);
87
+ expect(sanitizeAnnotationSvg(svg)).toBe(svg);
88
+ const [parsed] = svgToStrokes(sanitizeAnnotationSvg(svg)) as TextStroke[];
89
+ expect(parsed?.text).toBe('a\nb');
90
+ });
91
+ });
92
+
93
+ // ─────────────────────────────────────────────────────────────────────────────
94
+ // Italic + underline (item 4b)
95
+
96
+ describe('text-format / italic + underline', () => {
97
+ test('italic serializes font-style only when set; round-trips', () => {
98
+ const plain = strokesToSvg([baseStandalone]);
99
+ expect(plain).not.toContain('font-style');
100
+ const svg = strokesToSvg([{ ...baseStandalone, italic: true }]);
101
+ expect(svg).toContain('font-style="italic"');
102
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
103
+ expect(parsed?.italic).toBe(true);
104
+ expect(reparse(svg)).toBe(svg);
105
+ });
106
+
107
+ test('underline serializes text-decoration only when set; round-trips', () => {
108
+ const svg = strokesToSvg([{ ...baseStandalone, underline: true }]);
109
+ expect(svg).toContain('text-decoration="underline"');
110
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
111
+ expect(parsed?.underline).toBe(true);
112
+ expect(parsed?.strike).toBeUndefined();
113
+ expect(reparse(svg)).toBe(svg);
114
+ });
115
+
116
+ test('strike + underline combine into one text-decoration (order stable)', () => {
117
+ const svg = strokesToSvg([{ ...baseStandalone, strike: true, underline: true }]);
118
+ expect(svg).toContain('text-decoration="line-through underline"');
119
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
120
+ expect(parsed?.strike).toBe(true);
121
+ expect(parsed?.underline).toBe(true);
122
+ expect(reparse(svg)).toBe(svg);
123
+ });
124
+
125
+ test('strike-only stays byte-identical to the legacy line-through form', () => {
126
+ const svg = strokesToSvg([{ ...baseStandalone, strike: true }]);
127
+ expect(svg).toContain('text-decoration="line-through"');
128
+ expect(svg).not.toContain('underline');
129
+ });
130
+
131
+ test('all four formats (bold+italic+strike+underline) combine + round-trip', () => {
132
+ // The editors commit bold/italic/underline (Cmd+B/I/U) + strike together;
133
+ // assert every flag serializes and survives the round-trip.
134
+ const svg = strokesToSvg([
135
+ { ...baseStandalone, bold: true, italic: true, strike: true, underline: true },
136
+ ]);
137
+ expect(svg).toContain('font-weight="700"');
138
+ expect(svg).toContain('font-style="italic"');
139
+ expect(svg).toContain('text-decoration="line-through underline"');
140
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
141
+ expect(parsed?.bold).toBe(true);
142
+ expect(parsed?.italic).toBe(true);
143
+ expect(parsed?.strike).toBe(true);
144
+ expect(parsed?.underline).toBe(true);
145
+ expect(reparse(svg)).toBe(svg);
146
+ });
147
+
148
+ test('sticky italic + underline round-trip; a plain sticky gains no attrs', () => {
149
+ const plain: StickyStroke = {
150
+ id: 'st',
151
+ tool: 'sticky',
152
+ color: '#fce8a6',
153
+ x: 0,
154
+ y: 0,
155
+ w: 200,
156
+ h: 200,
157
+ text: 'note',
158
+ fontSize: 16,
159
+ };
160
+ expect(strokesToSvg([plain])).not.toContain('data-italic');
161
+ const svg = strokesToSvg([{ ...plain, italic: true, underline: true }]);
162
+ expect(svg).toContain('data-italic="1"');
163
+ expect(svg).toContain('data-underline="1"');
164
+ const [parsed] = svgToStrokes(svg) as StickyStroke[];
165
+ expect(parsed?.italic).toBe(true);
166
+ expect(parsed?.underline).toBe(true);
167
+ expect(reparse(svg)).toBe(svg);
168
+ });
169
+ });
170
+
171
+ // ─────────────────────────────────────────────────────────────────────────────
172
+ // Lists (item 4c)
173
+
174
+ describe('text-format / ordered + unordered lists', () => {
175
+ test('bullet list: data-list set, markers render-only, stored text clean', () => {
176
+ const svg = strokesToSvg([{ ...baseStandalone, text: 'apple\npear', listType: 'bullet' }]);
177
+ expect(svg).toContain('data-list="bullet"');
178
+ expect(svg).toContain('• apple');
179
+ expect(svg).toContain('• pear');
180
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
181
+ // Stored text has NO marker — markers are presentation only.
182
+ expect(parsed?.text).toBe('apple\npear');
183
+ expect(parsed?.listType).toBe('bullet');
184
+ expect(reparse(svg)).toBe(svg);
185
+ });
186
+
187
+ test('numbered list: per-line N. markers, re-numbered from stored text', () => {
188
+ const svg = strokesToSvg([
189
+ { ...baseStandalone, text: 'first\nsecond\nthird', listType: 'number' },
190
+ ]);
191
+ expect(svg).toContain('1. first');
192
+ expect(svg).toContain('2. second');
193
+ expect(svg).toContain('3. third');
194
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
195
+ expect(parsed?.text).toBe('first\nsecond\nthird');
196
+ expect(parsed?.listType).toBe('number');
197
+ expect(reparse(svg)).toBe(svg);
198
+ });
199
+
200
+ test('a single-line list item still round-trips (forces a tspan)', () => {
201
+ const svg = strokesToSvg([{ ...baseStandalone, text: 'solo', listType: 'bullet' }]);
202
+ expect(svg).toContain('<tspan');
203
+ expect(svg).toContain('• solo');
204
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
205
+ expect(parsed?.text).toBe('solo');
206
+ expect(parsed?.listType).toBe('bullet');
207
+ expect(reparse(svg)).toBe(svg);
208
+ });
209
+
210
+ test('a line that literally starts with the marker is not double-stripped', () => {
211
+ const svg = strokesToSvg([{ ...baseStandalone, text: '• already', listType: 'bullet' }]);
212
+ const [parsed] = svgToStrokes(svg) as TextStroke[];
213
+ expect(parsed?.text).toBe('• already');
214
+ expect(reparse(svg)).toBe(svg);
215
+ });
216
+
217
+ test('no list ⇒ no data-list attribute (canary)', () => {
218
+ expect(strokesToSvg([baseStandalone])).not.toContain('data-list');
219
+ });
220
+
221
+ test('sticky list round-trips with markers render-only (body text stays raw)', () => {
222
+ const svg = strokesToSvg([
223
+ {
224
+ id: 'sl',
225
+ tool: 'sticky',
226
+ color: '#fce8a6',
227
+ x: 0,
228
+ y: 0,
229
+ w: 200,
230
+ h: 200,
231
+ text: 'buy milk\nbuy eggs',
232
+ fontSize: 16,
233
+ listType: 'bullet',
234
+ },
235
+ ]);
236
+ expect(svg).toContain('data-list="bullet"');
237
+ // The persisted sticky body <text> keeps RAW text (no marker).
238
+ expect(svg).toContain('>buy milk\nbuy eggs<');
239
+ const [parsed] = svgToStrokes(svg) as StickyStroke[];
240
+ expect(parsed?.text).toBe('buy milk\nbuy eggs');
241
+ expect(parsed?.listType).toBe('bullet');
242
+ expect(reparse(svg)).toBe(svg);
243
+ });
244
+ });
245
+
246
+ // ─────────────────────────────────────────────────────────────────────────────
247
+ // Dashed rect / ellipse (item 7)
248
+
249
+ describe('text-format / dashed shapes', () => {
250
+ const rect: RectStroke = {
251
+ id: 'r',
252
+ tool: 'rect',
253
+ color: '#1f1f1f',
254
+ width: 2,
255
+ x: 0,
256
+ y: 0,
257
+ w: 80,
258
+ h: 60,
259
+ fill: null,
260
+ };
261
+ const ellipse: EllipseStroke = {
262
+ id: 'e',
263
+ tool: 'ellipse',
264
+ color: '#1f1f1f',
265
+ width: 2,
266
+ cx: 40,
267
+ cy: 30,
268
+ rx: 30,
269
+ ry: 20,
270
+ fill: null,
271
+ };
272
+
273
+ test('solid rect / ellipse emit no dash attr (canary)', () => {
274
+ expect(strokesToSvg([rect])).not.toContain('data-dash');
275
+ expect(strokesToSvg([ellipse])).not.toContain('data-dash');
276
+ expect(reparse(strokesToSvg([rect]))).toBe(strokesToSvg([rect]));
277
+ expect(reparse(strokesToSvg([ellipse]))).toBe(strokesToSvg([ellipse]));
278
+ });
279
+
280
+ test('dashed rect round-trips data-dash + stroke-dasharray', () => {
281
+ const svg = strokesToSvg([{ ...rect, dashed: true }]);
282
+ expect(svg).toContain('data-dash="1"');
283
+ expect(svg).toContain('stroke-dasharray="6 4"');
284
+ const [parsed] = svgToStrokes(svg) as RectStroke[];
285
+ expect(parsed?.dashed).toBe(true);
286
+ expect(reparse(svg)).toBe(svg);
287
+ });
288
+
289
+ test('dashed ellipse round-trips data-dash', () => {
290
+ const svg = strokesToSvg([{ ...ellipse, dashed: true }]);
291
+ expect(svg).toContain('data-dash="1"');
292
+ const [parsed] = svgToStrokes(svg) as EllipseStroke[];
293
+ expect(parsed?.dashed).toBe(true);
294
+ expect(reparse(svg)).toBe(svg);
295
+ });
296
+ });
297
+
298
+ // ─────────────────────────────────────────────────────────────────────────────
299
+ // Highlighter pen (item 8) — appended after Task 9.
300
+
301
+ describe('text-format / highlighter pen', () => {
302
+ const pen: PenStroke = {
303
+ id: 'p',
304
+ tool: 'pen',
305
+ color: '#1f1f1f',
306
+ width: 3,
307
+ points: [
308
+ [0, 0],
309
+ [10, 0],
310
+ ],
311
+ };
312
+
313
+ test('a normal pen emits no data-highlighter (canary)', () => {
314
+ const svg = strokesToSvg([pen]);
315
+ expect(svg).not.toContain('data-highlighter');
316
+ expect(reparse(svg)).toBe(svg);
317
+ });
318
+
319
+ test('a highlighter pen round-trips data-highlighter + wide translucent stroke', () => {
320
+ const hl: PenStroke = { ...pen, highlighter: true, width: 16, color: '#ffe40066' };
321
+ const svg = strokesToSvg([hl]);
322
+ expect(svg).toContain('data-highlighter="1"');
323
+ const [parsed] = svgToStrokes(svg) as PenStroke[];
324
+ expect(parsed?.highlighter).toBe(true);
325
+ expect(parsed?.width).toBe(16);
326
+ expect(parsed?.color).toBe('#ffe40066');
327
+ expect(reparse(svg)).toBe(svg);
328
+ });
329
+ });
330
+
331
+ // ─────────────────────────────────────────────────────────────────────────────
332
+ // Render-contract helpers (item 1 sticky corner + item 4a bbox)
333
+
334
+ describe('text-format / sticky sharp-corner path (item 1)', () => {
335
+ test('stickyCornerPath rounds TL/TR/BL and keeps the bottom-right SHARP', () => {
336
+ const d = stickyCornerPath(0, 0, 100, 80, 8);
337
+ // The BR corner is a straight L to the exact corner (no Q arc there): the
338
+ // right edge drops to (100,80) then the bottom edge runs to the BL arc.
339
+ expect(d).toContain('L100 80'); // sharp bottom-right corner vertex
340
+ // Three rounded corners ⇒ exactly three quadratic arcs (TR, BL, TL).
341
+ expect((d.match(/Q/g) ?? []).length).toBe(3);
342
+ expect(d.endsWith('Z')).toBe(true);
343
+ });
344
+
345
+ test('radius clamps to half the smaller side (never self-overlaps)', () => {
346
+ const d = stickyCornerPath(0, 0, 10, 200, 999);
347
+ // r clamps to min(999, 5, 100) = 5; the first move starts at x = r = 5.
348
+ expect(d.startsWith('M5 0')).toBe(true);
349
+ });
350
+ });
351
+
352
+ describe('text-format / editor list markers (item 4c — show while editing)', () => {
353
+ test('listPrefixedBody adds markers; stripEditorMarkers removes them (round-trip)', () => {
354
+ expect(listPrefixedBody('a\nb', 'bullet')).toBe('• a\n• b');
355
+ expect(listPrefixedBody('a\nb\nc', 'number')).toBe('1. a\n2. b\n3. c');
356
+ expect(listPrefixedBody('a\nb', undefined)).toBe('a\nb');
357
+ for (const list of ['bullet', 'number'] as const) {
358
+ const raw = 'milk\neggs\nbread';
359
+ // The editor shows markers; on commit they strip back to the raw text.
360
+ expect(stripEditorMarkers(listPrefixedBody(raw, list), list)).toBe(raw);
361
+ }
362
+ });
363
+
364
+ test('stripEditorMarkers removes a numbered prefix regardless of the typed number', () => {
365
+ // A user who edits/reorders lines may leave stale numbers; strip is generic.
366
+ expect(stripEditorMarkers('1. x\n5. y\nz', 'number')).toBe('x\ny\nz');
367
+ expect(stripEditorMarkers('• keep\nno marker', 'bullet')).toBe('keep\nno marker');
368
+ expect(stripEditorMarkers('untouched', undefined)).toBe('untouched');
369
+ });
370
+ });
371
+
372
+ describe('text-format / multi-line bbox (item 4a)', () => {
373
+ test('a standalone multi-line text bbox grows with line count', () => {
374
+ const single = strokeBBox({
375
+ id: 't',
376
+ tool: 'text',
377
+ color: '#000',
378
+ fontSize: 20,
379
+ text: 'one',
380
+ x: 0,
381
+ y: 0,
382
+ });
383
+ const triple = strokeBBox({
384
+ id: 't',
385
+ tool: 'text',
386
+ color: '#000',
387
+ fontSize: 20,
388
+ text: 'one\ntwo\nthree',
389
+ x: 0,
390
+ y: 0,
391
+ });
392
+ expect(single?.h).toBeCloseTo(20 * 1.2, 4); // single-line keeps legacy height
393
+ expect(triple?.h).toBeGreaterThan((single?.h ?? 0) * 2); // ~3 lines tall
394
+ expect(splitTextLines('one\ntwo\nthree')).toEqual(['one', 'two', 'three']);
395
+ });
396
+ });
@@ -0,0 +1,149 @@
1
+ // POST /_api/asset — Phase 23 content-addressed image upload (Task 5).
2
+ //
3
+ // Two layers:
4
+ // (1) the pure magic-byte sniff (`sniffImageType`) — the ONE gate that decides
5
+ // the stored type; a header lie / SVG is caught here;
6
+ // (2) the POST endpoint round-trip (boots a real server against a sandbox) —
7
+ // happy path for all four types, header-lie, oversize, SVG-reject,
8
+ // content-addressed dedupe, method gate.
9
+
10
+ import { describe, expect, test } from 'bun:test';
11
+ import { existsSync, readdirSync } from 'node:fs';
12
+ import { join } from 'node:path';
13
+
14
+ import { sniffImageType } from '../api.ts';
15
+ import { bootServer, killProc, makeSandbox, nextPort } from './_helpers.ts';
16
+
17
+ // ── Minimal valid magic-byte headers (padded so length checks pass). ──────────
18
+ const pad = (header: number[], len = 64): Uint8Array => {
19
+ const out = new Uint8Array(len);
20
+ out.set(header, 0);
21
+ return out;
22
+ };
23
+ const PNG = pad([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
24
+ const JPEG = pad([0xff, 0xd8, 0xff, 0xe0]);
25
+ const GIF = pad([0x47, 0x49, 0x46, 0x38, 0x39, 0x61]); // "GIF89a"
26
+ const WEBP = pad([0x52, 0x49, 0x46, 0x46, 0, 0, 0, 0, 0x57, 0x45, 0x42, 0x50]); // RIFF????WEBP
27
+ const SVG = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"><script/></svg>');
28
+
29
+ describe('asset-api / sniffImageType (the type gate)', () => {
30
+ test('recognizes each supported raster type by magic bytes', () => {
31
+ expect(sniffImageType(PNG)).toBe('png');
32
+ expect(sniffImageType(JPEG)).toBe('jpg');
33
+ expect(sniffImageType(GIF)).toBe('gif');
34
+ expect(sniffImageType(WEBP)).toBe('webp');
35
+ });
36
+
37
+ test('rejects SVG / text / empty / truncated headers', () => {
38
+ expect(sniffImageType(SVG)).toBeNull();
39
+ expect(sniffImageType(new TextEncoder().encode('not an image'))).toBeNull();
40
+ expect(sniffImageType(new Uint8Array(0))).toBeNull();
41
+ // Truncated PNG signature (only 4 of 8 bytes) must NOT match.
42
+ expect(sniffImageType(new Uint8Array([0x89, 0x50, 0x4e, 0x47]))).toBeNull();
43
+ // RIFF without the WEBP fourcc (e.g. a WAV) must NOT match.
44
+ expect(
45
+ sniffImageType(pad([0x52, 0x49, 0x46, 0x46, 0, 0, 0, 0, 0x57, 0x41, 0x56, 0x45]))
46
+ ).toBeNull();
47
+ });
48
+
49
+ test('content addresses the stored ext (a .png NAME with GIF bytes sniffs gif)', () => {
50
+ // The route names the file from sniffImageType(bytes), never the upload name.
51
+ expect(sniffImageType(GIF)).toBe('gif');
52
+ });
53
+ });
54
+
55
+ describe('asset-api / POST /_api/asset (endpoint round-trip)', () => {
56
+ async function withServer(
57
+ fn: (port: number, designRoot: string) => Promise<void>,
58
+ extraEnv?: Record<string, string>
59
+ ) {
60
+ const sandbox = makeSandbox();
61
+ const port = nextPort();
62
+ const proc = await bootServer(sandbox.root, port, extraEnv);
63
+ try {
64
+ await fn(port, sandbox.designRoot);
65
+ } finally {
66
+ await killProc(proc);
67
+ }
68
+ }
69
+
70
+ const postAsset = (port: number, body: Uint8Array, contentType = 'application/octet-stream') =>
71
+ fetch(`http://localhost:${port}/_api/asset`, {
72
+ method: 'POST',
73
+ headers: { 'Content-Type': contentType },
74
+ body,
75
+ });
76
+
77
+ test('writes a valid PNG/JPEG/WEBP/GIF and returns its assets path', async () => {
78
+ await withServer(async (port, designRoot) => {
79
+ for (const [bytes, ext] of [
80
+ [PNG, 'png'],
81
+ [JPEG, 'jpg'],
82
+ [WEBP, 'webp'],
83
+ [GIF, 'gif'],
84
+ ] as const) {
85
+ const res = await postAsset(port, bytes);
86
+ expect(res.status).toBe(201);
87
+ const json = (await res.json()) as { path: string };
88
+ expect(json.path).toMatch(new RegExp(`^assets/[0-9a-f]{8}\\.${ext}$`));
89
+ expect(existsSync(join(designRoot, json.path))).toBe(true);
90
+ }
91
+ });
92
+ });
93
+
94
+ test('a header-lie (declared image/png, GIF bytes) is stored as .gif (sniff wins)', async () => {
95
+ await withServer(async (port) => {
96
+ const res = await postAsset(port, GIF, 'image/png');
97
+ expect(res.status).toBe(201);
98
+ const json = (await res.json()) as { path: string };
99
+ expect(json.path.endsWith('.gif')).toBe(true);
100
+ });
101
+ });
102
+
103
+ test('rejects an SVG upload (no script-bearing vector) with 415', async () => {
104
+ await withServer(async (port) => {
105
+ const res = await postAsset(port, SVG, 'image/svg+xml');
106
+ expect(res.status).toBe(415);
107
+ });
108
+ });
109
+
110
+ test('rejects an oversize body (> 10 MB) with 413', async () => {
111
+ await withServer(async (port) => {
112
+ const big = new Uint8Array(10 * 1024 * 1024 + 1);
113
+ big.set([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], 0); // valid PNG header
114
+ const res = await postAsset(port, big);
115
+ expect(res.status).toBe(413);
116
+ });
117
+ });
118
+
119
+ test('identical bytes dedupe to ONE file (content-addressed; disk-fill guard)', async () => {
120
+ await withServer(async (port, designRoot) => {
121
+ const a = await (await postAsset(port, PNG)).json();
122
+ const b = await (await postAsset(port, PNG)).json();
123
+ expect(a.path).toBe(b.path);
124
+ const files = readdirSync(join(designRoot, 'assets'));
125
+ expect(files.length).toBe(1);
126
+ });
127
+ });
128
+
129
+ test('GET /_api/asset is method-not-allowed (write-only)', async () => {
130
+ await withServer(async (port) => {
131
+ const res = await fetch(`http://localhost:${port}/_api/asset`);
132
+ expect(res.status).toBe(405);
133
+ });
134
+ });
135
+
136
+ test('enforces the aggregate session write budget (disk-fill guard → 429)', async () => {
137
+ // Budget = 100 bytes; each padded magic-byte image is 64 bytes. The first
138
+ // DISTINCT write fits (64); a second distinct image (64) would total 128 >
139
+ // 100 → rejected. A dedupe hit (same bytes) is free and must NOT count.
140
+ await withServer(
141
+ async (port) => {
142
+ expect((await postAsset(port, PNG)).status).toBe(201); // 64 written
143
+ expect((await postAsset(port, PNG)).status).toBe(201); // dedupe — free
144
+ expect((await postAsset(port, JPEG)).status).toBe(429); // 64+64 > 100
145
+ },
146
+ { MAUDE_ASSET_SESSION_BUDGET: '100' }
147
+ );
148
+ });
149
+ });
@@ -9,7 +9,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
9
9
  import { tmpdir } from 'node:os';
10
10
  import { join } from 'node:path';
11
11
 
12
- import { type SelfHealOptions, bootSelfHeal } from '../boot-self-heal.ts';
12
+ import { bootSelfHeal, type SelfHealOptions } from '../boot-self-heal.ts';
13
13
 
14
14
  let TMP: string;
15
15