@weasel-js/editing 0.0.0-stage → 2.0.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 (368) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -2
  3. package/dist/actionGroups.js +27 -0
  4. package/dist/actionGroups.js.map +1 -0
  5. package/dist/actions/align/action.js +105 -0
  6. package/dist/actions/align/action.js.map +1 -0
  7. package/dist/actions/align/align.js +115 -0
  8. package/dist/actions/align/align.js.map +1 -0
  9. package/dist/actions/clipboard/action.js +133 -0
  10. package/dist/actions/clipboard/action.js.map +1 -0
  11. package/dist/actions/clone/action.js +217 -0
  12. package/dist/actions/clone/action.js.map +1 -0
  13. package/dist/actions/clone/behaviors.js +65 -0
  14. package/dist/actions/clone/behaviors.js.map +1 -0
  15. package/dist/actions/delete/delete.js +123 -0
  16. package/dist/actions/delete/delete.js.map +1 -0
  17. package/dist/actions/derivedBox.js +16 -0
  18. package/dist/actions/derivedBox.js.map +1 -0
  19. package/dist/actions/distribute/action.js +96 -0
  20. package/dist/actions/distribute/action.js.map +1 -0
  21. package/dist/actions/distribute/distribute.js +61 -0
  22. package/dist/actions/distribute/distribute.js.map +1 -0
  23. package/dist/actions/distribute/plan.js +55 -0
  24. package/dist/actions/distribute/plan.js.map +1 -0
  25. package/dist/actions/edit/createPaintAction.js +138 -0
  26. package/dist/actions/edit/createPaintAction.js.map +1 -0
  27. package/dist/actions/edit/deselect.js +34 -0
  28. package/dist/actions/edit/deselect.js.map +1 -0
  29. package/dist/actions/edit/duplicate.js +93 -0
  30. package/dist/actions/edit/duplicate.js.map +1 -0
  31. package/dist/actions/edit/group.js +281 -0
  32. package/dist/actions/edit/group.js.map +1 -0
  33. package/dist/actions/edit/ingest.js +114 -0
  34. package/dist/actions/edit/ingest.js.map +1 -0
  35. package/dist/actions/edit/nudge.js +97 -0
  36. package/dist/actions/edit/nudge.js.map +1 -0
  37. package/dist/actions/edit/selectAll.js +48 -0
  38. package/dist/actions/edit/selectAll.js.map +1 -0
  39. package/dist/actions/edit/setFill.js +52 -0
  40. package/dist/actions/edit/setFill.js.map +1 -0
  41. package/dist/actions/edit/setFillOpacity.js +26 -0
  42. package/dist/actions/edit/setFillOpacity.js.map +1 -0
  43. package/dist/actions/edit/setStroke.js +57 -0
  44. package/dist/actions/edit/setStroke.js.map +1 -0
  45. package/dist/actions/edit/setStrokeOpacity.js +28 -0
  46. package/dist/actions/edit/setStrokeOpacity.js.map +1 -0
  47. package/dist/actions/edit/setStrokeWidth.js +53 -0
  48. package/dist/actions/edit/setStrokeWidth.js.map +1 -0
  49. package/dist/actions/edit/setVertexColor.js +45 -0
  50. package/dist/actions/edit/setVertexColor.js.map +1 -0
  51. package/dist/actions/flip/action.js +209 -0
  52. package/dist/actions/flip/action.js.map +1 -0
  53. package/dist/actions/flip/helpers.js +80 -0
  54. package/dist/actions/flip/helpers.js.map +1 -0
  55. package/dist/actions/group/enterGroup.js +81 -0
  56. package/dist/actions/group/enterGroup.js.map +1 -0
  57. package/dist/actions/insert/action.js +152 -0
  58. package/dist/actions/insert/action.js.map +1 -0
  59. package/dist/actions/insert/commit.js +52 -0
  60. package/dist/actions/insert/commit.js.map +1 -0
  61. package/dist/actions/insert/extras.js +88 -0
  62. package/dist/actions/insert/extras.js.map +1 -0
  63. package/dist/actions/insert/frame.js +96 -0
  64. package/dist/actions/insert/frame.js.map +1 -0
  65. package/dist/actions/insert/geometry.js +35 -0
  66. package/dist/actions/insert/geometry.js.map +1 -0
  67. package/dist/actions/insert/lands.js +41 -0
  68. package/dist/actions/insert/lands.js.map +1 -0
  69. package/dist/actions/insert/params.js +42 -0
  70. package/dist/actions/insert/params.js.map +1 -0
  71. package/dist/actions/insert/placeAction.js +137 -0
  72. package/dist/actions/insert/placeAction.js.map +1 -0
  73. package/dist/actions/insert/repositionAction.js +47 -0
  74. package/dist/actions/insert/repositionAction.js.map +1 -0
  75. package/dist/actions/insert/rotateAction.js +34 -0
  76. package/dist/actions/insert/rotateAction.js.map +1 -0
  77. package/dist/actions/insert/session.js +99 -0
  78. package/dist/actions/insert/session.js.map +1 -0
  79. package/dist/actions/insert/shape.js +117 -0
  80. package/dist/actions/insert/shape.js.map +1 -0
  81. package/dist/actions/insert/style.js +23 -0
  82. package/dist/actions/insert/style.js.map +1 -0
  83. package/dist/actions/lassoSelect/action.js +201 -0
  84. package/dist/actions/lassoSelect/action.js.map +1 -0
  85. package/dist/actions/lassoSelect/behaviors/selectFromLasso.js +61 -0
  86. package/dist/actions/lassoSelect/behaviors/selectFromLasso.js.map +1 -0
  87. package/dist/actions/lockedWrites.js +20 -0
  88. package/dist/actions/lockedWrites.js.map +1 -0
  89. package/dist/actions/move/action.js +138 -0
  90. package/dist/actions/move/action.js.map +1 -0
  91. package/dist/actions/move/behaviors/clampMove.js +42 -0
  92. package/dist/actions/move/behaviors/clampMove.js.map +1 -0
  93. package/dist/actions/move/behaviors/layoutDrop.js +84 -0
  94. package/dist/actions/move/behaviors/layoutDrop.js.map +1 -0
  95. package/dist/actions/move/behaviors/pageDrop.js +30 -0
  96. package/dist/actions/move/behaviors/pageDrop.js.map +1 -0
  97. package/dist/actions/move/behaviors/reparentOnDrop.js +44 -0
  98. package/dist/actions/move/behaviors/reparentOnDrop.js.map +1 -0
  99. package/dist/actions/move/behaviors/snapBackOrDelete.js +52 -0
  100. package/dist/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
  101. package/dist/actions/move/behaviors/snapToContainer.js +214 -0
  102. package/dist/actions/move/behaviors/snapToContainer.js.map +1 -0
  103. package/dist/actions/move/behaviors/swapOnDrop.js +180 -0
  104. package/dist/actions/move/behaviors/swapOnDrop.js.map +1 -0
  105. package/dist/actions/move/capture.js +116 -0
  106. package/dist/actions/move/capture.js.map +1 -0
  107. package/dist/actions/move/commit/index.js +47 -0
  108. package/dist/actions/move/commit/index.js.map +1 -0
  109. package/dist/actions/move/commit/layoutDrop.js +68 -0
  110. package/dist/actions/move/commit/layoutDrop.js.map +1 -0
  111. package/dist/actions/move/commit/layoutRelease.js +146 -0
  112. package/dist/actions/move/commit/layoutRelease.js.map +1 -0
  113. package/dist/actions/move/commit/pageDrop.js +162 -0
  114. package/dist/actions/move/commit/pageDrop.js.map +1 -0
  115. package/dist/actions/move/commit/rebase.js +24 -0
  116. package/dist/actions/move/commit/rebase.js.map +1 -0
  117. package/dist/actions/move/commit/reparent.js +157 -0
  118. package/dist/actions/move/commit/reparent.js.map +1 -0
  119. package/dist/actions/move/delta.js +127 -0
  120. package/dist/actions/move/delta.js.map +1 -0
  121. package/dist/actions/move/dragSnap.js +55 -0
  122. package/dist/actions/move/dragSnap.js.map +1 -0
  123. package/dist/actions/move/frame.js +67 -0
  124. package/dist/actions/move/frame.js.map +1 -0
  125. package/dist/actions/move/gestureAdapter.js +36 -0
  126. package/dist/actions/move/gestureAdapter.js.map +1 -0
  127. package/dist/actions/move/landedDescendants.js +50 -0
  128. package/dist/actions/move/landedDescendants.js.map +1 -0
  129. package/dist/actions/move/layout/container.js +119 -0
  130. package/dist/actions/move/layout/container.js.map +1 -0
  131. package/dist/actions/move/layout/dragged.js +75 -0
  132. package/dist/actions/move/layout/dragged.js.map +1 -0
  133. package/dist/actions/move/layout/dropPass.js +205 -0
  134. package/dist/actions/move/layout/dropPass.js.map +1 -0
  135. package/dist/actions/move/layout/exits.js +62 -0
  136. package/dist/actions/move/layout/exits.js.map +1 -0
  137. package/dist/actions/move/layout/glide.js +70 -0
  138. package/dist/actions/move/layout/glide.js.map +1 -0
  139. package/dist/actions/move/layout/view.js +60 -0
  140. package/dist/actions/move/layout/view.js.map +1 -0
  141. package/dist/actions/move/refusal.js +49 -0
  142. package/dist/actions/move/refusal.js.map +1 -0
  143. package/dist/actions/move/session.js +105 -0
  144. package/dist/actions/move/session.js.map +1 -0
  145. package/dist/actions/move/sessionOf.js +27 -0
  146. package/dist/actions/move/sessionOf.js.map +1 -0
  147. package/dist/actions/move/translate.js +49 -0
  148. package/dist/actions/move/translate.js.map +1 -0
  149. package/dist/actions/pathfinder/action.js +109 -0
  150. package/dist/actions/pathfinder/action.js.map +1 -0
  151. package/dist/actions/pathfinder/booleanGroupAction.js +117 -0
  152. package/dist/actions/pathfinder/booleanGroupAction.js.map +1 -0
  153. package/dist/actions/pathfinder/keymap.js +51 -0
  154. package/dist/actions/pathfinder/keymap.js.map +1 -0
  155. package/dist/actions/reorder/reorder.js +245 -0
  156. package/dist/actions/reorder/reorder.js.map +1 -0
  157. package/dist/actions/resize/action.js +105 -0
  158. package/dist/actions/resize/action.js.map +1 -0
  159. package/dist/actions/resize/aspect.js +42 -0
  160. package/dist/actions/resize/aspect.js.map +1 -0
  161. package/dist/actions/resize/behaviors/clampMinSize.js +100 -0
  162. package/dist/actions/resize/behaviors/clampMinSize.js.map +1 -0
  163. package/dist/actions/resize/boxFrame.js +19 -0
  164. package/dist/actions/resize/boxFrame.js.map +1 -0
  165. package/dist/actions/resize/capture.js +121 -0
  166. package/dist/actions/resize/capture.js.map +1 -0
  167. package/dist/actions/resize/commit.js +104 -0
  168. package/dist/actions/resize/commit.js.map +1 -0
  169. package/dist/actions/resize/frame.js +171 -0
  170. package/dist/actions/resize/frame.js.map +1 -0
  171. package/dist/actions/resize/held.js +44 -0
  172. package/dist/actions/resize/held.js.map +1 -0
  173. package/dist/actions/resize/minimum.js +34 -0
  174. package/dist/actions/resize/minimum.js.map +1 -0
  175. package/dist/actions/resize/replay.js +58 -0
  176. package/dist/actions/resize/replay.js.map +1 -0
  177. package/dist/actions/resize/ruleBounds.js +11 -0
  178. package/dist/actions/resize/ruleBounds.js.map +1 -0
  179. package/dist/actions/resize/session.js +118 -0
  180. package/dist/actions/resize/session.js.map +1 -0
  181. package/dist/actions/rotate/action.js +99 -0
  182. package/dist/actions/rotate/action.js.map +1 -0
  183. package/dist/actions/rotate/commit.js +48 -0
  184. package/dist/actions/rotate/commit.js.map +1 -0
  185. package/dist/actions/rotate/frame.js +96 -0
  186. package/dist/actions/rotate/frame.js.map +1 -0
  187. package/dist/actions/rotate/replay.js +25 -0
  188. package/dist/actions/rotate/replay.js.map +1 -0
  189. package/dist/actions/rotate/session.js +135 -0
  190. package/dist/actions/rotate/session.js.map +1 -0
  191. package/dist/actions/select/areaSelect.js +83 -0
  192. package/dist/actions/select/areaSelect.js.map +1 -0
  193. package/dist/actions/select/clearSelection.js +33 -0
  194. package/dist/actions/select/clearSelection.js.map +1 -0
  195. package/dist/actions/swap/action.js +63 -0
  196. package/dist/actions/swap/action.js.map +1 -0
  197. package/dist/actions/swap/swapOps.js +160 -0
  198. package/dist/actions/swap/swapOps.js.map +1 -0
  199. package/dist/actions/transformAgain/action.js +90 -0
  200. package/dist/actions/transformAgain/action.js.map +1 -0
  201. package/dist/actions/transformAgain/transformSelection.js +49 -0
  202. package/dist/actions/transformAgain/transformSelection.js.map +1 -0
  203. package/dist/booleans/booleans.js +130 -0
  204. package/dist/booleans/booleans.js.map +1 -0
  205. package/dist/booleans/commit.js +45 -0
  206. package/dist/booleans/commit.js.map +1 -0
  207. package/dist/booleans/custom.js +48 -0
  208. package/dist/booleans/custom.js.map +1 -0
  209. package/dist/booleans/operands.js +50 -0
  210. package/dist/booleans/operands.js.map +1 -0
  211. package/dist/booleans/pieces.js +43 -0
  212. package/dist/booleans/pieces.js.map +1 -0
  213. package/dist/booleans/placement.js +37 -0
  214. package/dist/booleans/placement.js.map +1 -0
  215. package/dist/booleans/useBooleans.js +34 -0
  216. package/dist/booleans/useBooleans.js.map +1 -0
  217. package/dist/booleans/useBooleansAdapter.js +11 -0
  218. package/dist/booleans/useBooleansAdapter.js.map +1 -0
  219. package/dist/chrome/affordances/cornerResize.js +123 -0
  220. package/dist/chrome/affordances/cornerResize.js.map +1 -0
  221. package/dist/chrome/affordances/rotateCursor.js +17 -0
  222. package/dist/chrome/affordances/rotateCursor.js.map +1 -0
  223. package/dist/chrome/affordances/rotationHandle.js +117 -0
  224. package/dist/chrome/affordances/rotationHandle.js.map +1 -0
  225. package/dist/chrome/handleCommands.js +110 -0
  226. package/dist/chrome/handleCommands.js.map +1 -0
  227. package/dist/chrome/overlay.js +271 -0
  228. package/dist/chrome/overlay.js.map +1 -0
  229. package/dist/chrome/rotationBadge.js +132 -0
  230. package/dist/chrome/rotationBadge.js.map +1 -0
  231. package/dist/chrome/rotationHandleGeometry.js +49 -0
  232. package/dist/chrome/rotationHandleGeometry.js.map +1 -0
  233. package/dist/chrome/selectionChrome.js +25 -0
  234. package/dist/chrome/selectionChrome.js.map +1 -0
  235. package/dist/chrome/selectionPose.js +112 -0
  236. package/dist/chrome/selectionPose.js.map +1 -0
  237. package/dist/chrome/shapeOutline.js +137 -0
  238. package/dist/chrome/shapeOutline.js.map +1 -0
  239. package/dist/clipboard/clipboardOps.js +48 -0
  240. package/dist/clipboard/clipboardOps.js.map +1 -0
  241. package/dist/clipboard/materializePaste.js +34 -0
  242. package/dist/clipboard/materializePaste.js.map +1 -0
  243. package/dist/clipboard/osClipboard.js +67 -0
  244. package/dist/clipboard/osClipboard.js.map +1 -0
  245. package/dist/clipboard/useClipboard.js +64 -0
  246. package/dist/clipboard/useClipboard.js.map +1 -0
  247. package/dist/clipboard/wireFormat.js +108 -0
  248. package/dist/clipboard/wireFormat.js.map +1 -0
  249. package/dist/deps/areaSelect.js +42 -0
  250. package/dist/deps/areaSelect.js.map +1 -0
  251. package/dist/deps/booleans.js +99 -0
  252. package/dist/deps/booleans.js.map +1 -0
  253. package/dist/deps/insert.js +260 -0
  254. package/dist/deps/insert.js.map +1 -0
  255. package/dist/deps/lassoSelect.js +37 -0
  256. package/dist/deps/lassoSelect.js.map +1 -0
  257. package/dist/deps/presetDeps.js +40 -0
  258. package/dist/deps/presetDeps.js.map +1 -0
  259. package/dist/deps/resizePolicy.js +41 -0
  260. package/dist/deps/resizePolicy.js.map +1 -0
  261. package/dist/engine-BV9RDHOL.d.ts +339 -0
  262. package/dist/engine.d.ts +6 -0
  263. package/dist/engine.js +10 -0
  264. package/dist/engineStandardActions.js +54 -0
  265. package/dist/engineStandardActions.js.map +1 -0
  266. package/dist/groups.d.ts +27 -0
  267. package/dist/groups.js +4 -0
  268. package/dist/icons.gen.js +8 -0
  269. package/dist/icons.gen.js.map +1 -0
  270. package/dist/icons.table.d.ts +6 -0
  271. package/dist/icons.table.js +8 -0
  272. package/dist/icons.table.js.map +1 -0
  273. package/dist/icons.table.json +156 -0
  274. package/dist/icons2.table.js +163 -0
  275. package/dist/icons2.table.js.map +1 -0
  276. package/dist/index.d.ts +1867 -0
  277. package/dist/index.js +86 -0
  278. package/dist/ingest/ghost.js +58 -0
  279. package/dist/ingest/ghost.js.map +1 -0
  280. package/dist/ingest/imageHandler.js +80 -0
  281. package/dist/ingest/imageHandler.js.map +1 -0
  282. package/dist/ingest/kitHandlers.js +15 -0
  283. package/dist/ingest/kitHandlers.js.map +1 -0
  284. package/dist/ingest/svgHandler.js +97 -0
  285. package/dist/ingest/svgHandler.js.map +1 -0
  286. package/dist/ingest/weaselJsonHandler.js +68 -0
  287. package/dist/ingest/weaselJsonHandler.js.map +1 -0
  288. package/dist/namedPresets.js +83 -0
  289. package/dist/namedPresets.js.map +1 -0
  290. package/dist/presets/arrange.js +65 -0
  291. package/dist/presets/arrange.js.map +1 -0
  292. package/dist/presets/booleans.js +13 -0
  293. package/dist/presets/booleans.js.map +1 -0
  294. package/dist/presets/composites.js +46 -0
  295. package/dist/presets/composites.js.map +1 -0
  296. package/dist/presets/edit.js +125 -0
  297. package/dist/presets/edit.js.map +1 -0
  298. package/dist/presets/ingest.js +17 -0
  299. package/dist/presets/ingest.js.map +1 -0
  300. package/dist/presets/insert.js +28 -0
  301. package/dist/presets/insert.js.map +1 -0
  302. package/dist/presets/pathfinder.js +26 -0
  303. package/dist/presets/pathfinder.js.map +1 -0
  304. package/dist/presets/select.js +31 -0
  305. package/dist/presets/select.js.map +1 -0
  306. package/dist/presets/selection.js +13 -0
  307. package/dist/presets/selection.js.map +1 -0
  308. package/dist/presets/selectionChrome.js +15 -0
  309. package/dist/presets/selectionChrome.js.map +1 -0
  310. package/dist/presets/tools.js +84 -0
  311. package/dist/presets/tools.js.map +1 -0
  312. package/dist/presets/transform.js +52 -0
  313. package/dist/presets/transform.js.map +1 -0
  314. package/dist/presets.d.ts +104 -0
  315. package/dist/presets.js +15 -0
  316. package/dist/selection/useSelection.js +127 -0
  317. package/dist/selection/useSelection.js.map +1 -0
  318. package/dist/test-seams.d.ts +50 -0
  319. package/dist/test-seams.js +4 -0
  320. package/dist/tools/ellipse/useEllipseTool.js +72 -0
  321. package/dist/tools/ellipse/useEllipseTool.js.map +1 -0
  322. package/dist/tools/eyedropper/useEyedropperTool.js +100 -0
  323. package/dist/tools/eyedropper/useEyedropperTool.js.map +1 -0
  324. package/dist/tools/image/useImageTool.js +57 -0
  325. package/dist/tools/image/useImageTool.js.map +1 -0
  326. package/dist/tools/lasso/useLassoTool.js +96 -0
  327. package/dist/tools/lasso/useLassoTool.js.map +1 -0
  328. package/dist/tools/line/useLineTool.js +67 -0
  329. package/dist/tools/line/useLineTool.js.map +1 -0
  330. package/dist/tools/polygon/usePolygonTool.js +149 -0
  331. package/dist/tools/polygon/usePolygonTool.js.map +1 -0
  332. package/dist/tools/rect/useRectTool.js +74 -0
  333. package/dist/tools/rect/useRectTool.js.map +1 -0
  334. package/dist/tools/select/adapterPointQuery.js +56 -0
  335. package/dist/tools/select/adapterPointQuery.js.map +1 -0
  336. package/dist/tools/select/collapseDeferred.js +35 -0
  337. package/dist/tools/select/collapseDeferred.js.map +1 -0
  338. package/dist/tools/select/extendPressLocked.js +17 -0
  339. package/dist/tools/select/extendPressLocked.js.map +1 -0
  340. package/dist/tools/select/groupEntry.js +73 -0
  341. package/dist/tools/select/groupEntry.js.map +1 -0
  342. package/dist/tools/select/pressDecision.js +39 -0
  343. package/dist/tools/select/pressDecision.js.map +1 -0
  344. package/dist/tools/select/selectDeep.js +39 -0
  345. package/dist/tools/select/selectDeep.js.map +1 -0
  346. package/dist/tools/select/selectPick.js +60 -0
  347. package/dist/tools/select/selectPick.js.map +1 -0
  348. package/dist/tools/select/selectionContributions.js +191 -0
  349. package/dist/tools/select/selectionContributions.js.map +1 -0
  350. package/dist/tools/select/usePickerSelectTool.js +145 -0
  351. package/dist/tools/select/usePickerSelectTool.js.map +1 -0
  352. package/dist/tools/select/useSelectTool.js +54 -0
  353. package/dist/tools/select/useSelectTool.js.map +1 -0
  354. package/dist/tools/shared/countOption.js +24 -0
  355. package/dist/tools/shared/countOption.js.map +1 -0
  356. package/dist/tools/shared/insertToolOptions.js +8 -0
  357. package/dist/tools/shared/insertToolOptions.js.map +1 -0
  358. package/dist/tools/shared/pointerFollower.js +23 -0
  359. package/dist/tools/shared/pointerFollower.js.map +1 -0
  360. package/dist/tools/shared/styleOptions.js +76 -0
  361. package/dist/tools/shared/styleOptions.js.map +1 -0
  362. package/dist/tools/star/useStarTool.js +149 -0
  363. package/dist/tools/star/useStarTool.js.map +1 -0
  364. package/dist/tools/toolSets.js +26 -0
  365. package/dist/tools/toolSets.js.map +1 -0
  366. package/dist/useStandardActions.js +26 -0
  367. package/dist/useStandardActions.js.map +1 -0
  368. package/package.json +87 -4
@@ -0,0 +1,61 @@
1
+ import { alignBoxReader } from "../align/align.js";
2
+ import { planDistribute } from "./plan.js";
3
+ import { IDENTITY_POSE_COMPOSITION, RECT_POSE_DESCRIPTOR, dispatchApplyBatch, poseFrame, translatePoseViaDescriptor, uncarried } from "@weasel-js/core";
4
+ import { useCallback } from "react";
5
+ import * as coreOps from "@weasel-js/core/ops";
6
+ import { useLatest } from "@weasel-js/react";
7
+
8
+ // src/actions/distribute/distribute.ts
9
+ /** Distribute the current multi-selection along `axis`. Requires ≥3 items;
10
+ * no-op otherwise. Endpoints (min and max along the axis) stay put; the
11
+ * remaining items are repositioned. Single batch — one undo step.
12
+ *
13
+ * The span being divided is a world span: bounds are measured and translated
14
+ * in world, and each result is stored back in its own parent's frame. A node
15
+ * in a singular frame stays where it is. */
16
+ function useDistribute(adapter, options = {}) {
17
+ const adapterRef = useLatest(adapter);
18
+ const optsRef = useLatest(options);
19
+ return { distribute: useCallback((axis, mode) => {
20
+ const a = adapterRef.current;
21
+ const o = optsRef.current;
22
+ const geom = o.geometry ?? RECT_POSE_DESCRIPTOR;
23
+ const m = mode ?? o.defaultMode ?? "centers";
24
+ const frame = poseFrame({
25
+ getPose: (id) => a.getPose(id),
26
+ getParent: (id) => a.getParent(id)
27
+ }, o.composition ?? IDENTITY_POSE_COMPOSITION);
28
+ const sel = uncarried(frame, a.getSelection());
29
+ if (sel.length < 3) return;
30
+ const boxOf = alignBoxReader(o, geom, frame.world);
31
+ const items = sel.map((id) => {
32
+ const pose = frame.world(id);
33
+ return {
34
+ id,
35
+ pose,
36
+ b: boxOf(id, pose)
37
+ };
38
+ });
39
+ const targets = planDistribute(items.map((it) => it.b), axis, m);
40
+ const ops = [];
41
+ for (let i = 0; i < items.length; i++) {
42
+ const it = items[i];
43
+ const delta = targets[i] - (axis === "x" ? it.b.x : it.b.y);
44
+ if (delta === 0) continue;
45
+ const dx = axis === "x" ? delta : 0;
46
+ const dy = axis === "y" ? delta : 0;
47
+ const to = frame.local(it.id, translatePoseViaDescriptor(it.pose, dx, dy, geom));
48
+ if (to === null) continue;
49
+ ops.push(coreOps.setPose({
50
+ id: it.id,
51
+ from: a.getPose(it.id),
52
+ to
53
+ }));
54
+ }
55
+ if (ops.length === 0) return;
56
+ dispatchApplyBatch(a, ops, o.label ?? "Distribute");
57
+ }, [adapterRef, optsRef]) };
58
+ }
59
+
60
+ export { useDistribute };
61
+ //# sourceMappingURL=distribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribute.js","names":[],"sources":["../../../src/actions/distribute/distribute.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { dispatchApplyBatch, RECT_POSE_DESCRIPTOR, type PoseDescriptor, translatePoseViaDescriptor, poseFrame, type PoseFrame, uncarried, IDENTITY_POSE_COMPOSITION, type PoseComposition } from '@weasel-js/core';\nimport type { Op, NodeId } from '@weasel-js/core';\nimport { alignBoxReader, type UseAlignOptions } from '../align/align';\nimport { planDistribute } from './plan';\nimport * as coreOps from '@weasel-js/core/ops';\n\n/** Axis along which selection is distributed. `'x'` spreads horizontally. */\nexport type DistributeAxis = 'x' | 'y';\n\n/** `'centers'` spaces centers equally; `'gaps'` makes the gap between\n * consecutive items equal. Both measure a rotated item by its ink extent.\n * Endpoints stay put in both modes. */\nexport type DistributeMode = 'centers' | 'gaps';\n\n/** Adapter for `useDistribute`. */\nexport interface DistributeAdapter<TPose> {\n getSelection(): NodeId[];\n /** The pose as stored — local to the node's parent. */\n getPose(id: NodeId): TPose;\n /** The node's container, `null` for a root: the chain a pose is composed\n * through when container poses define a frame. */\n getParent(id: NodeId): NodeId | null;\n applyOps?(ops: Op[], label?: string): void;\n}\n\n/** Options for `useDistribute`. */\nexport interface UseDistributeOptions<TPose> {\n /** Projection between `TPose` and bounds. Defaults to `RECT_POSE_DESCRIPTOR`\n * for `{x,y,width,height}` poses. */\n geometry?: PoseDescriptor<TPose>;\n /** Default mode when `distribute(axis)` is called without one. Default 'centers'. */\n defaultMode?: DistributeMode;\n /** Label passed to applyOps. Default 'Distribute'. */\n label?: string;\n /** How local poses fold up to world. Default IDENTITY, which takes every\n * pose the adapter answers as world; over a scene's adapter, pass\n * `scene.composition`. */\n composition?: PoseComposition<TPose>;\n /** The nodes behind the adapter's ids, as `useAlign` takes them: with it, a\n * stroked node is spaced by the box it is drawn with. */\n scene?: UseAlignOptions<TPose>['scene'];\n /** View scale a screen-pixel stroke is resolved at. Default 1. */\n viewScale?: UseAlignOptions<TPose>['viewScale'];\n}\n\n/** Return shape of `useDistribute`. */\nexport interface UseDistributeReturn {\n /** Imperative trigger. No-op when fewer than 3 items selected. */\n distribute(axis: DistributeAxis, mode?: DistributeMode): void;\n}\n\n/** Distribute the current multi-selection along `axis`. Requires ≥3 items;\n * no-op otherwise. Endpoints (min and max along the axis) stay put; the\n * remaining items are repositioned. Single batch — one undo step.\n *\n * The span being divided is a world span: bounds are measured and translated\n * in world, and each result is stored back in its own parent's frame. A node\n * in a singular frame stays where it is. */\nexport function useDistribute<TPose>(\n adapter: DistributeAdapter<TPose>,\n options: UseDistributeOptions<TPose> = {},\n): UseDistributeReturn {\n const adapterRef = useLatest(adapter);\n const optsRef = useLatest(options);\n\n const distribute = useCallback((axis: DistributeAxis, mode?: DistributeMode): void => {\n const a = adapterRef.current;\n const o = optsRef.current;\n const geom =\n o.geometry ??\n (RECT_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>);\n const m = mode ?? o.defaultMode ?? 'centers';\n\n const frame = poseFrame<TPose>(\n {\n getPose: (id) => a.getPose(id as NodeId),\n getParent: (id) => a.getParent(id as NodeId) as string | null,\n },\n o.composition ?? (IDENTITY_POSE_COMPOSITION as PoseComposition<TPose>),\n );\n const sel = uncarried(frame as PoseFrame<unknown>, a.getSelection());\n if (sel.length < 3) return;\n const boxOf = alignBoxReader(o, geom, frame.world);\n const items = sel.map((id) => {\n const pose = frame.world(id);\n return { id, pose, b: boxOf(id, pose) };\n });\n const targets = planDistribute(items.map((it) => it.b), axis, m);\n\n const ops: Op[] = [];\n for (let i = 0; i < items.length; i++) {\n const it = items[i];\n const delta = targets[i] - (axis === 'x' ? it.b.x : it.b.y);\n if (delta === 0) continue;\n const dx = axis === 'x' ? delta : 0;\n const dy = axis === 'y' ? delta : 0;\n const to = frame.local(it.id, translatePoseViaDescriptor(it.pose, dx, dy, geom));\n // No stored pose in a singular frame reaches the spacing, so the node stays where it is.\n if (to === null) continue;\n ops.push(coreOps.setPose<TPose>({ id: it.id, from: a.getPose(it.id), to }));\n }\n if (ops.length === 0) return;\n dispatchApplyBatch(a, ops, o.label ?? 'Distribute');\n }, [adapterRef, optsRef]);\n\n return { distribute };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4DA,SAAgB,cACd,SACA,UAAuC,CAAC,GACnB;CACrB,MAAM,aAAa,UAAU,OAAO;CACpC,MAAM,UAAU,UAAU,O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GAAG,CAAC,YAAY,OAAO,CAEd,EAAW;AACtB"}
@@ -0,0 +1,55 @@
1
+ import { settleWithinRounding } from "@weasel-js/core";
2
+
3
+ // src/actions/distribute/plan.ts
4
+ /**
5
+ * Where each box's min edge along `axis` should land. Result is parallel to
6
+ * `bounds`. The two extreme boxes stay put in both modes; `'centers'` spaces
7
+ * centers evenly between the outermost two centers, `'gaps'` spaces the empty
8
+ * runs evenly between the boxes that start first and last.
9
+ *
10
+ * Callers translate by `target - currentMin`, so the plan is expressed in the
11
+ * same frame as the bounds it was given. A target within rounding of where a
12
+ * box already starts is where it starts, so a distributed selection plans no
13
+ * move when distributed again.
14
+ */
15
+ function planDistribute(bounds, axis, mode) {
16
+ const min = (b) => axis === "x" ? b.x : b.y;
17
+ const size = (b) => axis === "x" ? b.width : b.height;
18
+ const center = (b) => min(b) + size(b) / 2;
19
+ const key = mode === "centers" ? center : min;
20
+ const order = bounds.map((b, i) => ({
21
+ b,
22
+ i
23
+ })).sort((p, q) => key(p.b) - key(q.b));
24
+ const n = order.length;
25
+ const targets = new Array(n);
26
+ if (n === 0) return targets;
27
+ const first = order[0].b;
28
+ const last = order[n - 1].b;
29
+ let scale = 0;
30
+ for (const { b } of order) scale = Math.max(scale, Math.abs(min(b)), Math.abs(min(b) + size(b)));
31
+ const settle = (b, target) => settleWithinRounding(min(b), target, scale);
32
+ if (mode === "centers") {
33
+ const c0 = center(first);
34
+ const stride = n === 1 ? 0 : (center(last) - c0) / (n - 1);
35
+ for (let i = 0; i < n; i++) {
36
+ const { b, i: orig } = order[i];
37
+ targets[orig] = settle(b, c0 + stride * i - size(b) / 2);
38
+ }
39
+ return targets;
40
+ }
41
+ const span = min(last) + size(last) - min(first);
42
+ let sumSizes = 0;
43
+ for (const { b } of order) sumSizes += size(b);
44
+ const gap = n === 1 ? 0 : (span - sumSizes) / (n - 1);
45
+ let cursor = min(first);
46
+ for (let i = 0; i < n; i++) {
47
+ const { b, i: orig } = order[i];
48
+ targets[orig] = settle(b, cursor);
49
+ cursor += size(b) + gap;
50
+ }
51
+ return targets;
52
+ }
53
+
54
+ export { planDistribute };
55
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","names":[],"sources":["../../../src/actions/distribute/plan.ts"],"sourcesContent":["import { settleWithinRounding } from '@weasel-js/core';\nimport type { DistributeAxis, DistributeMode } from './distribute';\nimport type { Rect } from '@weasel-js/geom';\n\n/**\n * Where each box's min edge along `axis` should land. Result is parallel to\n * `bounds`. The two extreme boxes stay put in both modes; `'centers'` spaces\n * centers evenly between the outermost two centers, `'gaps'` spaces the empty\n * runs evenly between the boxes that start first and last.\n *\n * Callers translate by `target - currentMin`, so the plan is expressed in the\n * same frame as the bounds it was given. A target within rounding of where a\n * box already starts is where it starts, so a distributed selection plans no\n * move when distributed again.\n */\nexport function planDistribute(\n bounds: readonly Rect[],\n axis: DistributeAxis,\n mode: DistributeMode,\n): number[] {\n const min = (b: Rect): number => (axis === 'x' ? b.x : b.y);\n const size = (b: Rect): number => (axis === 'x' ? b.width : b.height);\n const center = (b: Rect): number => min(b) + size(b) / 2;\n\n const key = mode === 'centers' ? center : min;\n const order = bounds.map((b, i) => ({ b, i })).sort((p, q) => key(p.b) - key(q.b));\n const n = order.length;\n const targets = new Array<number>(n);\n if (n === 0) return targets;\n const first = order[0].b;\n const last = order[n - 1].b;\n\n let scale = 0;\n for (const { b } of order) scale = Math.max(scale, Math.abs(min(b)), Math.abs(min(b) + size(b)));\n const settle = (b: Rect, target: number): number => settleWithinRounding(min(b), target, scale);\n\n if (mode === 'centers') {\n const c0 = center(first);\n const stride = n === 1 ? 0 : (center(last) - c0) / (n - 1);\n for (let i = 0; i < n; i++) {\n const { b, i: orig } = order[i];\n targets[orig] = settle(b, c0 + stride * i - size(b) / 2);\n }\n return targets;\n }\n\n const span = (min(last) + size(last)) - min(first);\n let sumSizes = 0;\n for (const { b } of order) sumSizes += size(b);\n const gap = n === 1 ? 0 : (span - sumSizes) / (n - 1);\n let cursor = min(first);\n for (let i = 0; i < n; i++) {\n const { b, i: orig } = order[i];\n targets[orig] = settle(b, cursor);\n cursor += size(b) + gap;\n }\n return targets;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,eACd,QACA,MACA,MACU;CACV,MAAM,OAAO,MAAqB,SAAS,MAAM,EAAE,IAAI,EAAE;CACzD,MAAM,QAAQ,MAAqB,SAAS,MAAM,EAAE,QAAQ,EAAE;CAC9D,MAAM,UAAU,MAAoB,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI;CAEvD,MAAM,MAAM,SAAS,YAAY,SAAS;CAC1C,MAAM,QAAQ,OAAO,KAAK,GAAG,OAAO;EAAE;EAAG;CAAE,EAAE,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;CACjF,MAAM,IAAI,MAAM;CAChB,MAAM,UAAU,IAAI,MAAc,CAAC;CACnC,IAAI,MAAM,GAAG,OAAO;CACpB,MAAM,QAAQ,MAAM,EAAE,CAAC;CACvB,MAAM,OAAO,MAAM,IAAI,EAAE,CAAC;CAE1B,IAAI,QAAQ;CACZ,KAAK,MAAM,EAAE,OAAO,OAAO,QAAQ,KAAK,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;CAC/F,MAAM,UAAU,GAAS,WAA2B,qBAAqB,IAAI,CAAC,GAAG,QAAQ,KAAK;CAE9F,IAAI,SAAS,WAAW;EACtB,MAAM,KAAK,OAAO,KAAK;EACvB,MAAM,SAAS,MAAM,IAAI,KAAK,OAAO,IAAI,IAAI,OAAO,IAAI;EACxD,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;GAC1B,MAAM,EAAE,GAAG,GAAG,SAAS,MAAM;GAC7B,QAAQ,QAAQ,OAAO,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC;EACzD;EACA,OAAO;CACT;CAEA,MAAM,OAAQ,IAAI,IAAI,IAAI,KAAK,IAAI,IAAK,IAAI,KAAK;CACjD,IAAI,WAAW;CACf,KAAK,MAAM,EAAE,OAAO,OAAO,YAAY,KAAK,CAAC;CAC7C,MAAM,MAAM,MAAM,IAAI,KAAK,OAAO,aAAa,IAAI;CACnD,IAAI,SAAS,IAAI,KAAK;CACtB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC1B,MAAM,EAAE,GAAG,GAAG,SAAS,MAAM;EAC7B,QAAQ,QAAQ,OAAO,GAAG,MAAM;EAChC,UAAU,KAAK,CAAC,IAAI;CACtB;CACA,OAAO;AACT"}
@@ -0,0 +1,138 @@
1
+ import { asNodeId, operandContent, requiresContent, withoutPageStructure } from "@weasel-js/core";
2
+ import { ActionDisabledReason, defineAction, resolveParams } from "@weasel-js/routing";
3
+ import { INHERIT } from "@weasel-js/paint";
4
+ import { commitOps, inheritedPaintIn, paintInheritors } from "@weasel-js/core/engine";
5
+ import * as coreOps from "@weasel-js/core/ops";
6
+ import { deepEqual, isFiniteNumber } from "@weasel-js/registry";
7
+
8
+ // src/actions/edit/createPaintAction.ts
9
+ /** `v` when it is a finite number, else `fallback`: how a paint action reads a numeric param. */
10
+ var finiteOr = (v, fallback) => isFiniteNumber(v) ? v : fallback;
11
+ /** Whether `merge` handed back the value it was given, or one equal to it: nothing to write. */
12
+ var unchanged = (prev, next) => next === null && prev === void 0 || deepEqual(prev, next, { undefinedAsAbsent: true });
13
+ /** The nodes a paint action edits: the params' `ids` when given, else the selection's content. */
14
+ function targetsOf$1(deps, params) {
15
+ const ids = explicitIds(params);
16
+ if (ids === void 0) return operandContent(deps);
17
+ const scene = deps?.scene;
18
+ return scene ? withoutPageStructure(scene, ids.map(asNodeId)) : ids.map(asNodeId);
19
+ }
20
+ function explicitIds(params) {
21
+ const ids = params?.ids;
22
+ return Array.isArray(ids) ? ids : void 0;
23
+ }
24
+ /**
25
+ * The ongoing-action body the paint actions share: it previews without
26
+ * touching the scene, and commits one batch (one undo entry) through
27
+ * `commitOps`.
28
+ *
29
+ * The `from` data is re-read at commit rather than reused from the start
30
+ * snapshot, so a concurrent edit to a field this action does not own is not
31
+ * clobbered.
32
+ */
33
+ function createPaintAction(spec) {
34
+ const refreshPreviews = (scratch) => {
35
+ scratch.previews.clear();
36
+ for (const id of scratch.ids) {
37
+ const prev = scratch.startData.get(id);
38
+ const next = spec.merge(scratch.bases.get(id), scratch.state);
39
+ if (!unchanged(prev?.[spec.dataKey], next)) scratch.previews.set(id, {
40
+ ...prev ?? {},
41
+ [spec.dataKey]: next
42
+ });
43
+ }
44
+ };
45
+ const baseOf = (scene, id) => {
46
+ const node = scene.get(id);
47
+ const own = (node?.data)?.[spec.dataKey];
48
+ if (own !== INHERIT || !node) return own;
49
+ const key = spec.dataKey;
50
+ if (key !== "fill" && key !== "stroke") return own;
51
+ return inheritedPaintIn(scene, node)?.[key] ?? null;
52
+ };
53
+ return defineAction({
54
+ id: spec.id,
55
+ label: spec.label,
56
+ eligible: { capability: "applies-fill" },
57
+ requires: [
58
+ "operands",
59
+ "scene",
60
+ "applyOps"
61
+ ],
62
+ invoker: {
63
+ timing: "ongoing",
64
+ start(ctx, opts) {
65
+ const selection = ctx.deps.operands;
66
+ const scene = ctx.deps.scene;
67
+ if (!selection || !scene) return {};
68
+ const fallback = resolveParams(opts?.params);
69
+ const ids = [...targetsOf$1(ctx.deps, { ids: ctx.params?.ids ?? fallback?.ids })];
70
+ if (ids.length === 0) return {};
71
+ const pick = (key) => ctx.params?.[key] !== void 0 ? ctx.params[key] : fallback?.[key];
72
+ const startData = /* @__PURE__ */ new Map();
73
+ const bases = /* @__PURE__ */ new Map();
74
+ for (const id of ids) {
75
+ const node = scene.get(id);
76
+ if (!node) continue;
77
+ startData.set(id, { ...node.data });
78
+ bases.set(id, baseOf(scene, id));
79
+ }
80
+ const scratch = {
81
+ ids,
82
+ scene,
83
+ startData,
84
+ bases,
85
+ state: spec.initialState(pick),
86
+ previews: /* @__PURE__ */ new Map()
87
+ };
88
+ refreshPreviews(scratch);
89
+ const key = spec.dataKey;
90
+ const inheritors = key === "fill" || key === "stroke" ? [...new Set(ids.flatMap((id) => paintInheritors(scene, id, key)))].filter((id) => !startData.has(id)) : [];
91
+ return {
92
+ onMove(moveCtx) {
93
+ const next = spec.readParams(scratch.state, moveCtx.params);
94
+ if (next === null) return;
95
+ scratch.state = next;
96
+ refreshPreviews(scratch);
97
+ },
98
+ onEnd(_endCtx, reason) {
99
+ if (reason === "cancel") {
100
+ scratch.previews.clear();
101
+ return;
102
+ }
103
+ const ops = [];
104
+ for (const id of scratch.ids) {
105
+ const start = scratch.startData.get(id)?.[spec.dataKey];
106
+ const merged = spec.merge(scratch.bases.get(id), scratch.state);
107
+ const nodeNow = scratch.scene.get(id);
108
+ if (!nodeNow || unchanged(start, merged)) continue;
109
+ const from = { ...nodeNow.data };
110
+ const to = {
111
+ ...from,
112
+ [spec.dataKey]: merged
113
+ };
114
+ ops.push(coreOps.setData({
115
+ id,
116
+ from,
117
+ to
118
+ }));
119
+ }
120
+ commitOps(ctx.deps, ops, spec.label);
121
+ scratch.previews.clear();
122
+ },
123
+ previewIds: () => scratch.previews.size === 0 ? [] : [...scratch.previews.keys(), ...inheritors],
124
+ previewData: (id) => scratch.previews.get(id) ?? null
125
+ };
126
+ }
127
+ },
128
+ enabled: (deps, _at, _carried, params) => {
129
+ const given = explicitIds(params) !== void 0 ? true : requiresContent(1)(deps);
130
+ const scene = deps?.scene;
131
+ if (given !== true || !spec.writable || !scene) return given;
132
+ return targetsOf$1(deps, params).some((id) => scene.get(id) && spec.writable(baseOf(scene, id))) ? true : ActionDisabledReason.NotApplicable;
133
+ }
134
+ });
135
+ }
136
+
137
+ export { createPaintAction, finiteOr };
138
+ //# sourceMappingURL=createPaintAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPaintAction.js","names":["targetsOf"],"sources":["../../../src/actions/edit/createPaintAction.ts"],"sourcesContent":["import type { Action, ActionDeps, InvocationCtx } from '@weasel-js/routing';\nimport { ActionDisabledReason, defineAction, resolveParams } from '@weasel-js/routing';\nimport type { Scene, NodeId, Op } from '@weasel-js/core';\nimport { commitOps, inheritedPaintIn, paintInheritors } from '@weasel-js/core/engine';\nimport { INHERIT } from '@weasel-js/paint';\nimport { deepEqual, isFiniteNumber } from '@weasel-js/registry';\nimport * as coreOps from '@weasel-js/core/ops';\nimport { asNodeId, operandContent, requiresContent, withoutPageStructure } from '@weasel-js/core';\n\n/** The node data one paint action reads and writes: its own key, nothing else. */\ntype PaintData<K extends string, TValue> = { [P in K]?: TValue | null };\n\n/** Read a param from the invocation, falling back to the binding's. */\nexport type PickParam<P> = <Key extends keyof P>(key: Key) => P[Key] | undefined;\n\n/**\n * What distinguishes one paint action from another.\n *\n * `TState` is the action's gesture state. It is a reducer, not a paint:\n * `setFill` and `setStroke` supersede a paint with a later color, which no\n * per-field merge of the params can express.\n */\nexport interface PaintActionSpec<TState, TValue, K extends string, P> {\n id: string;\n label: string;\n /** The `data` key this action owns. */\n dataKey: K;\n /** Gesture state at start. */\n initialState(pick: PickParam<P>): TState;\n /** The state one onMove tick moves to, or `null` when its params carry\n * nothing this action reads — the preview then stands. */\n readParams(prev: TState, params: Readonly<Partial<P>> | undefined): TState | null;\n /** The value to write for one node, from that node's value at gesture start —\n * for an `'inherit'` fill or stroke, the paint it inherits, so a write takes\n * that paint over rather than the string. `null` writes the absence of paint, which is a value like any other —\n * a node with `fill: null` paints no fill. Handing back `prev`, or a value\n * equal to it, leaves the node out of the preview and the commit. */\n merge(prev: TValue | null | undefined, state: TState): TValue | null;\n /** Whether some run could change a node holding `prev`. The action is\n * `NotApplicable` while no operand passes. Omitted, every node can change. */\n writable?(prev: TValue | null | undefined): boolean;\n}\n\n/** `v` when it is a finite number, else `fallback`: how a paint action reads a numeric param. */\nexport const finiteOr = <T>(v: unknown, fallback: T): number | T => (isFiniteNumber(v) ? v : fallback);\n\n/** Whether `merge` handed back the value it was given, or one equal to it: nothing to write. */\nconst unchanged = (prev: unknown, next: unknown): boolean =>\n (next === null && prev === undefined) || deepEqual(prev, next, { undefinedAsAbsent: true });\n\ninterface Scratch<TState, TValue, K extends string> {\n ids: NodeId[];\n scene: Scene<PaintData<K, TValue>, string, unknown>;\n /** Data snapshot at gesture start, keyed by node id. */\n startData: Map<NodeId, PaintData<K, TValue>>;\n /** What `merge` starts from per node: its value at gesture start, `'inherit'` resolved. */\n bases: Map<NodeId, TValue | null | undefined>;\n state: TState;\n /** Preview data entries — the merged value per selected node. */\n previews: Map<NodeId, PaintData<K, TValue>>;\n}\n\n/** The nodes a paint action edits: the params' `ids` when given, else the selection's content. */\nfunction targetsOf(deps: ActionDeps | undefined, params: Readonly<Record<string, unknown>> | undefined): readonly NodeId[] {\n const ids = explicitIds(params);\n if (ids === undefined) return operandContent(deps);\n const scene = deps?.scene;\n return scene ? withoutPageStructure(scene, ids.map(asNodeId)) : ids.map(asNodeId);\n}\n\nfunction explicitIds(params: Readonly<Record<string, unknown>> | undefined): readonly string[] | undefined {\n const ids = params?.ids;\n return Array.isArray(ids) ? (ids as readonly string[]) : undefined;\n}\n\n/**\n * The ongoing-action body the paint actions share: it previews without\n * touching the scene, and commits one batch (one undo entry) through\n * `commitOps`.\n *\n * The `from` data is re-read at commit rather than reused from the start\n * snapshot, so a concurrent edit to a field this action does not own is not\n * clobbered.\n */\nexport function createPaintAction<TState, TValue, K extends string, P>(\n spec: PaintActionSpec<TState, TValue, K, P>,\n): Action {\n type Data = PaintData<K, TValue>;\n\n const refreshPreviews = (scratch: Scratch<TState, TValue, K>): void => {\n scratch.previews.clear();\n for (const id of scratch.ids) {\n const prev = scratch.startData.get(id);\n const next = spec.merge(scratch.bases.get(id), scratch.state);\n if (!unchanged(prev?.[spec.dataKey], next)) scratch.previews.set(id, { ...(prev ?? {}), [spec.dataKey]: next } as Data);\n }\n };\n\n const baseOf = (scene: Scene<Data, string, unknown>, id: NodeId): TValue | null | undefined => {\n const node = scene.get(id);\n const own = (node?.data as Data | undefined)?.[spec.dataKey];\n if ((own as unknown) !== INHERIT || !node) return own;\n const key = spec.dataKey as string;\n if (key !== 'fill' && key !== 'stroke') return own;\n return (inheritedPaintIn(scene as never, node as never)?.[key] ?? null) as TValue | null;\n };\n\n return defineAction<string, P>({\n id: spec.id,\n label: spec.label,\n eligible: { capability: 'applies-fill' },\n requires: ['operands', 'scene', 'applyOps'],\n invoker: {\n timing: 'ongoing',\n start(ctx, opts) {\n const selection = ctx.deps.operands;\n const scene = ctx.deps.scene as Scene<Data, string, unknown> | undefined;\n\n if (!selection || !scene) return {};\n\n const fallback = resolveParams(opts?.params);\n type Targeted = { ids?: unknown } | undefined;\n const ids = [...targetsOf(ctx.deps, { ids: (ctx.params as Targeted)?.ids ?? (fallback as Targeted)?.ids })];\n if (ids.length === 0) return {};\n\n // `??` would lose a `paint: null`, which is None, not \"no paint given\".\n const pick: PickParam<P> = (key) => (ctx.params?.[key] !== undefined ? ctx.params[key] : fallback?.[key]);\n\n const startData = new Map<NodeId, Data>();\n const bases = new Map<NodeId, TValue | null | undefined>();\n for (const id of ids) {\n const node = scene.get(id);\n if (!node) continue;\n startData.set(id, { ...(node.data as Data) });\n bases.set(id, baseOf(scene, id));\n }\n\n const scratch: Scratch<TState, TValue, K> = {\n ids,\n scene,\n startData,\n bases,\n state: spec.initialState(pick),\n previews: new Map(),\n };\n refreshPreviews(scratch);\n // Members that inherit the paint being changed preview with it.\n const key = spec.dataKey as string;\n const inheritors = key === 'fill' || key === 'stroke'\n ? [...new Set(ids.flatMap((id) => paintInheritors(scene, id, key)))].filter((id) => !startData.has(id as NodeId))\n : [];\n\n return {\n onMove(moveCtx: InvocationCtx<P>): void {\n const next = spec.readParams(scratch.state, moveCtx.params);\n if (next === null) return;\n scratch.state = next;\n refreshPreviews(scratch);\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n if (reason === 'cancel') {\n scratch.previews.clear();\n return;\n }\n const ops: Op[] = [];\n for (const id of scratch.ids) {\n const start = scratch.startData.get(id)?.[spec.dataKey];\n const merged = spec.merge(scratch.bases.get(id), scratch.state);\n const nodeNow = scratch.scene.get(id);\n if (!nodeNow || unchanged(start, merged)) continue;\n const from = { ...(nodeNow.data as object) } as Data;\n const to = { ...from, [spec.dataKey]: merged } as Data;\n ops.push(coreOps.setData<Data>({ id: id as string, from, to }));\n }\n commitOps(ctx.deps, ops, spec.label);\n scratch.previews.clear();\n },\n previewIds: () => (scratch.previews.size === 0 ? [] : [...scratch.previews.keys(), ...inheritors]),\n previewData: (id: string) => scratch.previews.get(id as unknown as NodeId) ?? null,\n };\n },\n },\n enabled: (deps, _at, _carried, params) => {\n const given = explicitIds(params) !== undefined ? true : requiresContent(1)(deps);\n const scene = deps?.scene as Scene<Data, string, unknown> | undefined;\n if (given !== true || !spec.writable || !scene) return given;\n const ids = targetsOf(deps, params);\n return ids.some((id) => scene.get(id) && spec.writable!(baseOf(scene, id))) ? true : ActionDisabledReason.NotApplicable;\n },\n });\n}\n"],"mappings":";;;;;;;;;AA4CA,IAAa,YAAe,GAAY,aAA6B,eAAe,CAAC,IAAI,IAAI;;AAG7F,IAAM,aAAa,MAAe,SAC/B,SAAS,QAAQ,SAAS,UAAc,UAAU,MAAM,MAAM,EAAE,mBAAmB,KAAK,CAAC;;AAe5F,SAASA,YAAU,MAA8B,QAA0E;CACzH,MAAM,MAAM,YAAY,MAAM;CAC9B,IAAI,QAAQ,QAAW,OAAO,eAAe,IAAI;CACjD,MAAM,QAAQ,MAAM;CACpB,OAAO,QAAQ,qBAAqB,OAAO,IAAI,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI,QAAQ;AAClF;AAEA,SAAS,YAAY,QAAsF;CACzG,MAAM,MAAM,QAAQ;CACpB,OAAO,MAAM,QAAQ,GAAG,IAAK,MAA4B;AAC3D;;;;;;;;;;AAWA,SAAgB,kBACd,MACQ;CAGR,MAAM,mBAAmB,YAA8C;EACrE,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,CAAC;MAChE;MACA,UAAU,IAAI,MAAM,KAAK,KAAK,KAAK;MACnC,QAAQ,SAAS,MAAM;KACzB;KACA,kBAAmB,QAAQ,SAAS,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,SAAS,KAAK,GAAG,GAAG,UAAU;KAChG,cAAc,OAAe,QAAQ,SAAS,IAAI,EAAuB,KAAK;IAChF;GACF;EACF;EACA,UAAU,MAAM,KAAK,UAAU,WAAW;GACxC,MAAM,QAAQ,YAAY,MAAM,MAAM,SAAY,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI;GAChF,MAAM,QAAQ,MAAM;GACpB,IAAI,UAAU,QAAQ,CAAC,KAAK,YAAY,CAAC,OAAO,OAAO;GAEvD,OADYA,YAAU,MAAM,MACrB,CAAA,CAAI,MAAM,OAAO,MAAM,IAAI,EAAE,KAAK,KAAK,SAAU,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,OAAO,qBAAqB;EAC5G;CACF,CAAC;AACH"}
@@ -0,0 +1,34 @@
1
+ import { ActionDisabledReason, BETWEEN_GESTURES } from "@weasel-js/routing";
2
+
3
+ // src/actions/edit/deselect.ts
4
+ /**
5
+ * Static descriptor for the `deselect` Action, bound to Escape. Clears the selection.
6
+ */
7
+ var deselectAction = {
8
+ id: "deselect",
9
+ label: "Deselect",
10
+ defaultBinding: [{
11
+ spec: {
12
+ kind: "key",
13
+ key: "Escape",
14
+ phase: BETWEEN_GESTURES
15
+ },
16
+ opts: { id: "deselect.key" }
17
+ }],
18
+ requires: ["selection", "editAnchors"],
19
+ invoker: {
20
+ timing: "immediate",
21
+ run: (deps) => {
22
+ if ((deps.selection?.get() ?? []).length === 0) return;
23
+ deps.selection?.set([]);
24
+ }
25
+ },
26
+ enabled: (deps) => {
27
+ if ((deps?.editAnchors)?.editingId) return ActionDisabledReason.NotApplicable;
28
+ if ((deps?.selection?.get() ?? []).length === 0) return ActionDisabledReason.NotApplicable;
29
+ return true;
30
+ }
31
+ };
32
+
33
+ export { deselectAction };
34
+ //# sourceMappingURL=deselect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deselect.js","names":[],"sources":["../../../src/actions/edit/deselect.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport { ActionDisabledReason, BETWEEN_GESTURES } from '@weasel-js/routing';\n\n/**\n * Static descriptor for the `deselect` Action, bound to Escape. Clears the selection.\n */\n// No `eligible` field → always eligible. Escape works in every mode; the\n// runtime `enabled` thunk handles the path-edit defer-to-exit case.\nexport const deselectAction: Action & { requires: string[] } = {\n id: 'deselect',\n label: 'Deselect',\n // Gated to \"no tool is engaged\" so a mid-drag Escape goes to\n // `cancelAllAction` (cancels the drag) instead of clearing\n // selection.\n defaultBinding: [{\n spec: {\n kind: 'key',\n key: 'Escape',\n phase: BETWEEN_GESTURES,\n },\n opts: { id: 'deselect.key' },\n }],\n requires: ['selection', 'editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const sel = deps.selection?.get() ?? [];\n if (sel.length === 0) return;\n deps.selection?.set([]);\n },\n },\n // Defer to `leavePathEdit` while path-anchor edit mode is active.\n // Otherwise the more-specific phase qualifier on this binding would beat\n // `leavePathEdit`'s bare key spec, swallowing the Escape that should leave\n // edit mode. With this gate, `deselect` reports a disabled reason in that\n // case and the dispatcher falls through to `leavePathEdit`.\n // With nothing selected there is nothing to clear, so the press falls\n // through to `tool.resetToDefault` instead of being spent here.\n enabled: (deps) => {\n const editAnchors = deps?.editAnchors;\n if (editAnchors?.editingId) return ActionDisabledReason.NotApplicable;\n const sel = deps?.selection?.get() ?? [];\n if (sel.length === 0) return ActionDisabledReason.NotApplicable;\n return true;\n },\n};\n"],"mappings":";;;;;;AAQA,IAAa,iBAAkD;CAC7D,IAAI;CACJ,OAAO;CAIP,gBAAgB,CAAC;EACf,MAAM;GACJ,MAAM;GACN,KAAK;GACL,OAAO;EACT;EACA,MAAM,EAAE,IAAI,eAAe;CAC7B,CAAC;CACD,UAAU,CAAC,aAAa,aAAa;CACrC,SAAS;EACP,QAAQ;EACR,MAAM,SAAS;GAEb,KADY,KAAK,WAAW,IAAI,KAAK,CAAC,EAClC,CAAI,WAAW,GAAG;GACtB,KAAK,WAAW,IAAI,CAAC,CAAC;EACxB;CACF;CAQA,UAAU,SAAS;EAEjB,KADoB,MAAM,YACtB,EAAa,WAAW,OAAO,qBAAqB;EAExD,KADY,MAAM,WAAW,IAAI,KAAK,CAAC,EACnC,CAAI,WAAW,GAAG,OAAO,qBAAqB;EAClD,OAAO;CACT;AACF"}
@@ -0,0 +1,93 @@
1
+ import { EDIT_GROUP } from "../../actionGroups.js";
2
+ import { DUPLICATE_OFFSET, copyOps, recordTransform, requiresContent, storedDelta } from "@weasel-js/core";
3
+ import { BETWEEN_GESTURES } from "@weasel-js/routing";
4
+ import { commitOps, nodeDescriptors as nodeDescriptors$1, poseDescriptorOf as poseDescriptorOf$1, scenePoseFrame as scenePoseFrame$1, translatePoseViaDescriptor as translatePoseViaDescriptor$1 } from "@weasel-js/core/engine";
5
+ import { pref } from "@weasel-js/prefs-schema";
6
+ import { isFiniteNumber } from "@weasel-js/registry";
7
+
8
+ // src/actions/edit/duplicate.ts
9
+ var offsetLeaf = (name, axis) => pref.number(name, DUPLICATE_OFFSET, {
10
+ description: `How far the copies land from the originals ${axis}, in world units.`,
11
+ min: -500,
12
+ max: 500,
13
+ step: 1
14
+ });
15
+ /** Duplicate's params as a form: the last-operation panel's after a run. */
16
+ var DUPLICATE_PARAMS = pref.group("Duplicate", {
17
+ dx: offsetLeaf("Horizontal offset", "across"),
18
+ dy: offsetLeaf("Vertical offset", "down")
19
+ });
20
+ var offsetOf = (v) => isFiniteNumber(v) ? v : DUPLICATE_OFFSET;
21
+ /**
22
+ * Copy each selected node, with its subtree, offset by `(dx, dy)` in world
23
+ * space whatever frame it is stored in, as one
24
+ * undoable batch labeled `label`, and select the copies. Returns the copies'
25
+ * ids, or null when nothing was copied or the scene refused the copies.
26
+ */
27
+ function duplicateSelection(deps, dx, dy, label = "Duplicate") {
28
+ const selection = deps.operands;
29
+ const scene = deps.scene;
30
+ if (!selection || !scene) return null;
31
+ const ids = selection.get();
32
+ if (ids.length === 0) return null;
33
+ const descriptorOf = nodeDescriptors$1(scene, poseDescriptorOf$1(deps.poseDescriptor));
34
+ const frame = scenePoseFrame$1(scene);
35
+ const { ops, copies } = copyOps(scene, ids, (id, node, isRoot) => {
36
+ if (!isRoot) return node.pose;
37
+ const l = storedDelta(frame, descriptorOf(id), id, dx, dy);
38
+ return l === null ? node.pose : translatePoseViaDescriptor$1(node.pose, l.dx, l.dy, descriptorOf(id));
39
+ }, label);
40
+ if (ops.length === 0) return null;
41
+ return commitOps(deps, ops, label, { select: copies }) ? copies : null;
42
+ }
43
+ /**
44
+ * Static descriptor for the `duplicate` Action. Copies each selected node —
45
+ * with its subtree, so duplicating a group produces a populated group — offset
46
+ * by a small nudge, as one undoable batch, then selects the copies.
47
+ */
48
+ var duplicateAction = {
49
+ id: "duplicate",
50
+ label: "Duplicate",
51
+ icon: /* @icon */ "editing:duplicate",
52
+ group: EDIT_GROUP,
53
+ defaultBinding: [{
54
+ spec: {
55
+ kind: "key",
56
+ key: "d",
57
+ mods: {
58
+ mod: true,
59
+ shift: true
60
+ },
61
+ phase: BETWEEN_GESTURES
62
+ },
63
+ opts: { id: "duplicate.key" }
64
+ }],
65
+ eligible: { capability: ["edits-page", "creates-selection"] },
66
+ requires: [
67
+ "scene",
68
+ "operands",
69
+ "applyOps",
70
+ "poseDescriptor"
71
+ ],
72
+ params: DUPLICATE_PARAMS,
73
+ invoker: {
74
+ timing: "immediate",
75
+ run: (deps, params) => {
76
+ const scene = deps.scene;
77
+ const selection = deps.operands;
78
+ if (!scene || !selection) return;
79
+ const dx = offsetOf(params?.dx);
80
+ const dy = offsetOf(params?.dy);
81
+ const copies = duplicateSelection(deps, dx, dy);
82
+ if (copies) recordTransform(scene, {
83
+ kind: "duplicate",
84
+ dx,
85
+ dy
86
+ }, copies);
87
+ }
88
+ },
89
+ enabled: requiresContent(1)
90
+ };
91
+
92
+ export { DUPLICATE_PARAMS, duplicateAction, duplicateSelection };
93
+ //# sourceMappingURL=duplicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duplicate.js","names":["nodeDescriptors","poseDescriptorOf","scenePoseFrame","translatePoseViaDescriptor"],"sources":["../../../src/actions/edit/duplicate.ts"],"sourcesContent":["import type { Action, ActionDeps } from '@weasel-js/routing';\nimport { commitOps, nodeDescriptors, poseDescriptorOf, translatePoseViaDescriptor, scenePoseFrame } from '@weasel-js/core/engine';\nimport { copyOps, requiresContent, storedDelta, recordTransform, DUPLICATE_OFFSET } from '@weasel-js/core';\nimport { icon } from '../../icons.gen';\nimport { BETWEEN_GESTURES } from '@weasel-js/routing';\nimport { pref } from '@weasel-js/prefs-schema';\nimport { isFiniteNumber } from '@weasel-js/registry';\nimport { EDIT_GROUP } from '../../actionGroups';\n\n\nconst offsetLeaf = (name: string, axis: string) => pref.number(name, DUPLICATE_OFFSET, {\n description: `How far the copies land from the originals ${axis}, in world units.`, min: -500, max: 500, step: 1,\n});\n\n/** Duplicate's params as a form: the last-operation panel's after a run. */\nexport const DUPLICATE_PARAMS = pref.group('Duplicate', {\n dx: offsetLeaf('Horizontal offset', 'across'),\n dy: offsetLeaf('Vertical offset', 'down'),\n});\n\nconst offsetOf = (v: unknown): number => (isFiniteNumber(v) ? v : DUPLICATE_OFFSET);\n\n/**\n * Copy each selected node, with its subtree, offset by `(dx, dy)` in world\n * space whatever frame it is stored in, as one\n * undoable batch labeled `label`, and select the copies. Returns the copies'\n * ids, or null when nothing was copied or the scene refused the copies.\n */\nexport function duplicateSelection(\n deps: ActionDeps,\n dx: number,\n dy: number,\n label = 'Duplicate',\n): string[] | null {\n const selection = deps.operands;\n const scene = deps.scene;\n if (!selection || !scene) return null;\n const ids = selection.get();\n if (ids.length === 0) return null;\n\n const descriptorOf = nodeDescriptors(scene, poseDescriptorOf(deps.poseDescriptor));\n const frame = scenePoseFrame(scene);\n const { ops, copies } = copyOps(\n scene,\n ids,\n (id, node, isRoot) => {\n // A child's pose is relative to its frame, which the root's offset carries.\n if (!isRoot) return node.pose;\n const l = storedDelta(frame, descriptorOf(id), id, dx, dy);\n return l === null ? node.pose : translatePoseViaDescriptor(node.pose, l.dx, l.dy, descriptorOf(id));\n },\n label,\n );\n\n if (ops.length === 0) return null;\n return commitOps(deps, ops, label, { select: copies }) ? copies as string[] : null;\n}\n\n/**\n * Static descriptor for the `duplicate` Action. Copies each selected node —\n * with its subtree, so duplicating a group produces a populated group — offset\n * by a small nudge, as one undoable batch, then selects the copies.\n */\nexport const duplicateAction: Action & { requires: string[] } = {\n id: 'duplicate',\n label: 'Duplicate',\n icon: icon('duplicate'),\n group: EDIT_GROUP,\n // Cmd/Ctrl+D is `transformAgain`, which duplicates when nothing else is\n // there to repeat.\n defaultBinding: [{ spec: { kind: 'key', key: 'd', mods: { mod: true, shift: true }, phase: BETWEEN_GESTURES }, opts: { id: 'duplicate.key' } }],\n eligible: { capability: ['edits-page', 'creates-selection'] },\n // `operands` is read by the `enabled` gate as well as the invoker. An\n // undeclared read throws inside the dev-build deps Proxy before the gate can\n // answer, which is how this action spent a while doing nothing at all.\n requires: ['scene', 'operands', 'applyOps', 'poseDescriptor'],\n params: DUPLICATE_PARAMS,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const scene = deps.scene;\n const selection = deps.operands;\n if (!scene || !selection) return;\n const dx = offsetOf(params?.dx);\n const dy = offsetOf(params?.dy);\n const copies = duplicateSelection(deps, dx, dy);\n if (copies) recordTransform(scene, { kind: 'duplicate', dx, dy }, copies);\n },\n },\n enabled: requiresContent(1),\n};\n"],"mappings":";;;;;;;;AAUA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,C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