@weasel-js/core 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/README.md +33 -0
  3. package/dist/affordances/composeAffordanceLayer.js +21 -21
  4. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  5. package/dist/affordances/hitAffordanceRegions.js +48 -32
  6. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  7. package/dist/affordances/pathAnchors.js +50 -28
  8. package/dist/affordances/pathAnchors.js.map +1 -1
  9. package/dist/affordances/rotateCursor.js +12 -0
  10. package/dist/affordances/rotateCursor.js.map +1 -0
  11. package/dist/affordances/rotationHandle.js +40 -43
  12. package/dist/affordances/rotationHandle.js.map +1 -1
  13. package/dist/animation/rig/rigNode.js +9 -3
  14. package/dist/animation/rig/rigNode.js.map +1 -1
  15. package/dist/animation/rig/rigSeat.js +46 -13
  16. package/dist/animation/rig/rigSeat.js.map +1 -1
  17. package/dist/animation/rig/skinBinding.js +22 -14
  18. package/dist/animation/rig/skinBinding.js.map +1 -1
  19. package/dist/barrel/canvas.js +29 -28
  20. package/dist/barrel/interactions.js +33 -32
  21. package/dist/barrel/paths.js +11 -10
  22. package/dist/barrel/routing.js +49 -48
  23. package/dist/barrel/scene.js +10 -10
  24. package/dist/barrel/viewport.js +24 -21
  25. package/dist/canvas/Canvas.js +6 -17
  26. package/dist/canvas/Canvas.js.map +1 -1
  27. package/dist/canvas/CanvasView.js +34 -37
  28. package/dist/canvas/CanvasView.js.map +1 -1
  29. package/dist/canvas/CursorCoordsHud.js +3 -3
  30. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  31. package/dist/canvas/DrawCanvas.js +3 -3
  32. package/dist/canvas/DrawCanvas.js.map +1 -1
  33. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +24 -23
  34. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
  35. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +40 -49
  36. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -1
  37. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +297 -259
  38. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  39. package/dist/canvas/SceneCanvas/features.js +3 -24
  40. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  41. package/dist/canvas/SceneCanvas/insertPreviewCommands.js +97 -0
  42. package/dist/canvas/SceneCanvas/insertPreviewCommands.js.map +1 -0
  43. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  44. package/dist/canvas/SceneCanvas/props.js.map +1 -1
  45. package/dist/canvas/SceneCanvas/scenePointQuery.js +50 -0
  46. package/dist/canvas/SceneCanvas/scenePointQuery.js.map +1 -0
  47. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js +52 -0
  48. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js.map +1 -0
  49. package/dist/canvas/SceneCanvas/useActionTunings.js +17 -0
  50. package/dist/canvas/SceneCanvas/useActionTunings.js.map +1 -0
  51. package/dist/canvas/SceneCanvas/useCanvasCamera.js +37 -29
  52. package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -1
  53. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +11 -11
  54. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -1
  55. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +45 -109
  56. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  57. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +49 -41
  58. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  59. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +64 -96
  60. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  61. package/dist/canvas/SceneCanvas/worldPointAt.js +3 -4
  62. package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -1
  63. package/dist/canvas/SceneCanvas.js +77 -80
  64. package/dist/canvas/SceneCanvas.js.map +1 -1
  65. package/dist/canvas/SceneViewCanvas.js +3 -3
  66. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  67. package/dist/canvas/SurfaceCanvas.js +40 -0
  68. package/dist/canvas/SurfaceCanvas.js.map +1 -0
  69. package/dist/canvas/adapterDerivedPath.js +13 -13
  70. package/dist/canvas/adapterDerivedPath.js.map +1 -1
  71. package/dist/canvas/adapterPickSource.js +34 -0
  72. package/dist/canvas/adapterPickSource.js.map +1 -0
  73. package/dist/canvas/affordanceAt.js +1 -1
  74. package/dist/canvas/affordanceAt.js.map +1 -1
  75. package/dist/canvas/buildSceneLayer.js.map +1 -1
  76. package/dist/canvas/buildSceneTree.js +56 -34
  77. package/dist/canvas/buildSceneTree.js.map +1 -1
  78. package/dist/canvas/copiesAbove.js +27 -0
  79. package/dist/canvas/copiesAbove.js.map +1 -0
  80. package/dist/canvas/defaultDrawOne.js +24 -23
  81. package/dist/canvas/defaultDrawOne.js.map +1 -1
  82. package/dist/canvas/deps/editAnchors.js +45 -50
  83. package/dist/canvas/deps/editAnchors.js.map +1 -1
  84. package/dist/canvas/deps/hitTestArea.js +30 -15
  85. package/dist/canvas/deps/hitTestArea.js.map +1 -1
  86. package/dist/canvas/deps/insert.js +134 -100
  87. package/dist/canvas/deps/insert.js.map +1 -1
  88. package/dist/canvas/deps/layout.js +9 -15
  89. package/dist/canvas/deps/layout.js.map +1 -1
  90. package/dist/canvas/derivedPath.js +53 -29
  91. package/dist/canvas/derivedPath.js.map +1 -1
  92. package/dist/canvas/insertPreviewExtent.js +33 -31
  93. package/dist/canvas/insertPreviewExtent.js.map +1 -1
  94. package/dist/canvas/overChildren.js +29 -0
  95. package/dist/canvas/overChildren.js.map +1 -0
  96. package/dist/canvas/paintedCursorLayer.js.map +1 -1
  97. package/dist/canvas/pickReach.js +23 -0
  98. package/dist/canvas/pickReach.js.map +1 -0
  99. package/dist/canvas/pickWalk.js +51 -80
  100. package/dist/canvas/pickWalk.js.map +1 -1
  101. package/dist/canvas/sceneAdapter.js +14 -35
  102. package/dist/canvas/sceneAdapter.js.map +1 -1
  103. package/dist/canvas/sceneSlotWiring.js +11 -10
  104. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  105. package/dist/canvas/sceneViewRender.js +38 -44
  106. package/dist/canvas/sceneViewRender.js.map +1 -1
  107. package/dist/canvas/useCanvasView.js +42 -44
  108. package/dist/canvas/useCanvasView.js.map +1 -1
  109. package/dist/canvas/useSceneAdapter.js +22 -0
  110. package/dist/canvas/useSceneAdapter.js.map +1 -0
  111. package/dist/canvas/useSurfaceInput.js +13 -16
  112. package/dist/canvas/useSurfaceInput.js.map +1 -1
  113. package/dist/canvas/viewRegistry.js +31 -23
  114. package/dist/canvas/viewRegistry.js.map +1 -1
  115. package/dist/canvas/wrapNodeOutput.js +7 -2
  116. package/dist/canvas/wrapNodeOutput.js.map +1 -1
  117. package/dist/clipboard.d.ts +1 -1
  118. package/dist/{clone-2a5hVbBd.d.ts → clone-C0eADtS0.d.ts} +13 -13
  119. package/dist/clone.d.ts +2 -2
  120. package/dist/core/geometry/poseDescriptor.js +49 -23
  121. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  122. package/dist/core/geometry/regionHit.js +2 -2
  123. package/dist/core/geometry/regionHit.js.map +1 -1
  124. package/dist/core/geometry/targetFrame.js.map +1 -1
  125. package/dist/core/layers/children.js +1 -3
  126. package/dist/core/layers/children.js.map +1 -1
  127. package/dist/core/ops/create.js +2 -2
  128. package/dist/core/ops/create.js.map +1 -1
  129. package/dist/core/ops/delete.js +19 -23
  130. package/dist/core/ops/delete.js.map +1 -1
  131. package/dist/core/ops/reorder/index.js +3 -7
  132. package/dist/core/ops/reorder/index.js.map +1 -1
  133. package/dist/core/ops/reorder/setChildOrder.js +2 -4
  134. package/dist/core/ops/reorder/setChildOrder.js.map +1 -1
  135. package/dist/core/ops/reparent.js +0 -1
  136. package/dist/core/ops/reparent.js.map +1 -1
  137. package/dist/core/ops/slot.js +3 -6
  138. package/dist/core/ops/slot.js.map +1 -1
  139. package/dist/core/pages/fitViewToPage.js +15 -0
  140. package/dist/core/pages/fitViewToPage.js.map +1 -0
  141. package/dist/core/pages/pages.js +65 -0
  142. package/dist/core/pages/pages.js.map +1 -0
  143. package/dist/core/pages/pagesLayer.js +27 -0
  144. package/dist/core/pages/pagesLayer.js.map +1 -0
  145. package/dist/core/paint/meshKindLazy.js +2 -2
  146. package/dist/core/paint/meshKindLazy.js.map +1 -1
  147. package/dist/core/scene/NodeProperties.js.map +1 -1
  148. package/dist/core/scene/composeFrame.js.map +1 -1
  149. package/dist/core/scene/composePose.js +58 -20
  150. package/dist/core/scene/composePose.js.map +1 -1
  151. package/dist/core/scene/effectivePose.js +5 -1
  152. package/dist/core/scene/effectivePose.js.map +1 -1
  153. package/dist/core/scene/historyFacade.js +19 -13
  154. package/dist/core/scene/historyFacade.js.map +1 -1
  155. package/dist/core/scene/nodeFnFields.js +7 -0
  156. package/dist/core/scene/nodeFnFields.js.map +1 -1
  157. package/dist/core/scene/outerOps.js +2 -1
  158. package/dist/core/scene/outerOps.js.map +1 -1
  159. package/dist/core/scene/reconcileSpecs.js +1 -1
  160. package/dist/core/scene/reconcileSpecs.js.map +1 -1
  161. package/dist/core/scene/sceneRecording.js +2 -1
  162. package/dist/core/scene/sceneRecording.js.map +1 -1
  163. package/dist/core/scene/types.js.map +1 -1
  164. package/dist/core/viewport/screenSlop.js.map +1 -1
  165. package/dist/core/viewport/useDecayLoop.js +28 -30
  166. package/dist/core/viewport/useDecayLoop.js.map +1 -1
  167. package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -1
  168. package/dist/core/viewport/useViewAnimation.js +70 -69
  169. package/dist/core/viewport/useViewAnimation.js.map +1 -1
  170. package/dist/core/viewport/view.js +8 -5
  171. package/dist/core/viewport/view.js.map +1 -1
  172. package/dist/core/viewport/zoomAt.js +11 -2
  173. package/dist/core/viewport/zoomAt.js.map +1 -1
  174. package/dist/{cornerHandles-BEshc4z3.d.ts → cornerHandles-BSKbyuvQ.d.ts} +1 -1
  175. package/dist/features/paths/editablePath.js +24 -8
  176. package/dist/features/paths/editablePath.js.map +1 -1
  177. package/dist/features/paths/index.js +4 -4
  178. package/dist/features/paths/shapeGenerator.js +89 -0
  179. package/dist/features/paths/shapeGenerator.js.map +1 -0
  180. package/dist/features/paths/usePathEdit.js +13 -13
  181. package/dist/features/poseRun/usePoseRun.js +25 -25
  182. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  183. package/dist/features/text/useSceneTextEdit.js +82 -64
  184. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  185. package/dist/features/viewports/viewResolver.js +28 -24
  186. package/dist/features/viewports/viewResolver.js.map +1 -1
  187. package/dist/icons/SliceIcon.js +24 -0
  188. package/dist/icons/SliceIcon.js.map +1 -0
  189. package/dist/index.d.ts +956 -581
  190. package/dist/index.js +260 -251
  191. package/dist/interactions/actions/align/align.js +9 -9
  192. package/dist/interactions/actions/align/align.js.map +1 -1
  193. package/dist/interactions/actions/booleans/booleans.js +18 -18
  194. package/dist/interactions/actions/booleans/booleans.js.map +1 -1
  195. package/dist/interactions/actions/booleans/operands.js.map +1 -1
  196. package/dist/interactions/actions/clone/action.js +35 -30
  197. package/dist/interactions/actions/clone/action.js.map +1 -1
  198. package/dist/interactions/actions/defaults/anchorEditing.js +56 -59
  199. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  200. package/dist/interactions/actions/defaults/anchorHandles.js +42 -0
  201. package/dist/interactions/actions/defaults/anchorHandles.js.map +1 -0
  202. package/dist/interactions/actions/defaults/anchorJoin.js +92 -0
  203. package/dist/interactions/actions/defaults/anchorJoin.js.map +1 -0
  204. package/dist/interactions/actions/defaults/bendSegment.js +46 -0
  205. package/dist/interactions/actions/defaults/bendSegment.js.map +1 -0
  206. package/dist/interactions/actions/defaults/copySubtree.js +1 -1
  207. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -1
  208. package/dist/interactions/actions/defaults/duplicate.js +32 -17
  209. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  210. package/dist/interactions/actions/defaults/enterPathEdit.js +19 -7
  211. package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
  212. package/dist/interactions/actions/defaults/icons/anchorIcons.js +75 -0
  213. package/dist/interactions/actions/defaults/icons/anchorIcons.js.map +1 -0
  214. package/dist/interactions/actions/defaults/icons/editIcons.js +35 -8
  215. package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -1
  216. package/dist/interactions/actions/defaults/insertPathAnchor.js +16 -31
  217. package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
  218. package/dist/interactions/actions/defaults/nudge.js +28 -23
  219. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  220. package/dist/interactions/actions/defaults/pinchZoom.js +29 -29
  221. package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
  222. package/dist/interactions/actions/defaults/segmentUnder.js +22 -0
  223. package/dist/interactions/actions/defaults/segmentUnder.js.map +1 -0
  224. package/dist/interactions/actions/defaults/viewportZoom.js +82 -79
  225. package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
  226. package/dist/interactions/actions/distribute/distribute.js +8 -8
  227. package/dist/interactions/actions/distribute/distribute.js.map +1 -1
  228. package/dist/interactions/actions/edit-anchors/action.js +58 -55
  229. package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
  230. package/dist/interactions/actions/edit-anchors/preview.js +26 -0
  231. package/dist/interactions/actions/edit-anchors/preview.js.map +1 -0
  232. package/dist/interactions/actions/edit-anchors/symmetry.js +11 -0
  233. package/dist/interactions/actions/edit-anchors/symmetry.js.map +1 -0
  234. package/dist/interactions/actions/flip/action.js.map +1 -1
  235. package/dist/interactions/actions/geometryProjection.js.map +1 -1
  236. package/dist/interactions/actions/insert/action.js +37 -30
  237. package/dist/interactions/actions/insert/action.js.map +1 -1
  238. package/dist/interactions/actions/insert/frame.js +9 -2
  239. package/dist/interactions/actions/insert/frame.js.map +1 -1
  240. package/dist/interactions/actions/insert/repositionAction.js +31 -0
  241. package/dist/interactions/actions/insert/repositionAction.js.map +1 -0
  242. package/dist/interactions/actions/lasso-select/action.js +32 -32
  243. package/dist/interactions/actions/move/action.js +29 -25
  244. package/dist/interactions/actions/move/action.js.map +1 -1
  245. package/dist/interactions/actions/move/behaviors/snapToContainer.js +12 -6
  246. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  247. package/dist/interactions/actions/move/capture.js +32 -23
  248. package/dist/interactions/actions/move/capture.js.map +1 -1
  249. package/dist/interactions/actions/move/frame.js +2 -14
  250. package/dist/interactions/actions/move/frame.js.map +1 -1
  251. package/dist/interactions/actions/move/session.js +1 -1
  252. package/dist/interactions/actions/move/session.js.map +1 -1
  253. package/dist/interactions/actions/move/translate.js.map +1 -1
  254. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
  255. package/dist/interactions/actions/outlines/replaceWithPaths.js +13 -13
  256. package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -1
  257. package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -1
  258. package/dist/interactions/actions/pathCommands/cutJoin.js +102 -0
  259. package/dist/interactions/actions/pathCommands/cutJoin.js.map +1 -0
  260. package/dist/interactions/actions/pathCommands/livePathEdit.js +64 -0
  261. package/dist/interactions/actions/pathCommands/livePathEdit.js.map +1 -0
  262. package/dist/interactions/actions/pathCommands/pathNodes.js +99 -0
  263. package/dist/interactions/actions/pathCommands/pathNodes.js.map +1 -0
  264. package/dist/interactions/actions/pathCommands/simplifyOffset.js +42 -0
  265. package/dist/interactions/actions/pathCommands/simplifyOffset.js.map +1 -0
  266. package/dist/interactions/actions/resize/action.js +31 -20
  267. package/dist/interactions/actions/resize/action.js.map +1 -1
  268. package/dist/interactions/actions/resize/commit.js.map +1 -1
  269. package/dist/interactions/actions/resize/frame.js +29 -15
  270. package/dist/interactions/actions/resize/frame.js.map +1 -1
  271. package/dist/interactions/actions/resize/replay.js +47 -0
  272. package/dist/interactions/actions/resize/replay.js.map +1 -0
  273. package/dist/interactions/actions/resize/session.js +49 -35
  274. package/dist/interactions/actions/resize/session.js.map +1 -1
  275. package/dist/interactions/actions/resolveOverlays.js +2 -1
  276. package/dist/interactions/actions/resolveOverlays.js.map +1 -1
  277. package/dist/interactions/actions/rotate/action.js +40 -25
  278. package/dist/interactions/actions/rotate/action.js.map +1 -1
  279. package/dist/interactions/actions/rotate/frame.js +1 -1
  280. package/dist/interactions/actions/rotate/frame.js.map +1 -1
  281. package/dist/interactions/actions/rotate/replay.js +22 -0
  282. package/dist/interactions/actions/rotate/replay.js.map +1 -0
  283. package/dist/interactions/actions/rotate/session.js +42 -32
  284. package/dist/interactions/actions/rotate/session.js.map +1 -1
  285. package/dist/interactions/actions/transform-again/action.js +63 -0
  286. package/dist/interactions/actions/transform-again/action.js.map +1 -0
  287. package/dist/interactions/actions/transform-again/memory.js +35 -0
  288. package/dist/interactions/actions/transform-again/memory.js.map +1 -0
  289. package/dist/interactions/actions/useStandardActions.js +101 -83
  290. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  291. package/dist/move.d.ts +4 -4
  292. package/dist/{originProjection-PPT88jZv.d.ts → originProjection-CoNVpITV.d.ts} +1 -1
  293. package/dist/resize.d.ts +3 -3
  294. package/dist/style.css +1 -1
  295. package/dist/tools/builtin/ellipse/useEllipseTool.js +16 -15
  296. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  297. package/dist/tools/builtin/line/useLineTool.js +16 -15
  298. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  299. package/dist/tools/builtin/pen/usePenTool.js +111 -111
  300. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  301. package/dist/tools/builtin/pickTopMostHit.js +11 -14
  302. package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
  303. package/dist/tools/builtin/polygon/usePolygonTool.js +17 -15
  304. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  305. package/dist/tools/builtin/rect/useRectTool.js +15 -14
  306. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  307. package/dist/tools/builtin/select/adapterPointQuery.js +22 -18
  308. package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -1
  309. package/dist/tools/builtin/select/selectionContributions.js +1 -1
  310. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  311. package/dist/tools/builtin/select/useSelectTool.js +2 -1
  312. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  313. package/dist/tools/builtin/slice/useSliceTool.js +42 -40
  314. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  315. package/dist/tools/builtin/star/useStarTool.js +18 -16
  316. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  317. package/dist/tools/builtin/text/useTextTool.js +2 -2
  318. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  319. package/dist/{types-CIKDwlsP.d.ts → types-DBbbCy0i.d.ts} +22 -15
  320. package/dist/version.js +1 -1
  321. package/package.json +22 -22
  322. package/dist/canvas/surface.module.js +0 -6
  323. package/dist/canvas/surface.module.js.map +0 -1
  324. package/dist/canvas/surfaceBox.js +0 -16
  325. package/dist/canvas/surfaceBox.js.map +0 -1
  326. package/dist/layout/arrivals.js +0 -33
  327. package/dist/layout/arrivals.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["arraysEqual","a","b","i","createPartitionedReorderOp","args","argsForSerial","prevOrders","restore","adapter","byParent","id","ids","parent","list","snapshots","mutated","parentId","parentIds","before","after","fn","captured","createSetChildOrderOp","REORDER_DIRECTIONS","bringForward","sendBackward","bringToFront","sendToBack","createReorderOp","direction","label","defaultLabel","registerOpFactory","createMoveToIndexOp","eligible","current","moveToIndex","index","canBringForward","canSendBackward"],"sources":["../../../../src/core/ops/reorder/index.ts"],"sourcesContent":["import type { Op } from '../types';\nimport { registerOpFactory } from '../registry';\nimport {\n bringForward,\n sendBackward,\n bringToFront,\n sendToBack,\n moveToIndex,\n} from './algorithms';\n\nimport { createSetChildOrderOp } from './setChildOrder';\n\nexport { canBringForward, canSendBackward } from './algorithms';\nexport { createSetChildOrderOp, type ChildOrder, type SetChildOrderArgs } from './setChildOrder';\n\ninterface ReorderAdapter {\n getParent?(id: string): string | null;\n getChildren?(parentId: string | null): string[];\n setChildOrder?(parentId: string | null, ids: string[]): void;\n}\n\ntype ReorderFn = (list: string[], ids: string[]) => string[];\n\nfunction arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/** One parent's child order before a reorder, kept so undo can restore it. */\nexport interface ReorderRestoreEntry {\n parentId: string | null;\n before: string[];\n}\n\n/** Arguments to {@link createReorderOp}: move `ids` in paint order, one step or to the front/back. */\nexport interface ReorderArgs {\n ids: string[];\n direction: ReorderDirection;\n label?: string;\n /** Pre-mutation child order per touched parent. Filled in on first apply;\n * arrives populated when the op is rebuilt from a snapshot. */\n prevOrders?: ReorderRestoreEntry[];\n}\n\n/**\n * Build an op that, on apply, partitions `ids` by their current parent,\n * runs `fn(currentChildren, idsForParent)` per parent, and writes the\n * result back via setChildOrder. Records before-state per parent so invert\n * is exact.\n *\n * `prevOrders` is that before-state, mirrored into the op's serialized args\n * on first apply. A deserialized op has never run its own `apply`, so its\n * invert has nothing to capture — reading it back from the args is what lets\n * a reorder survive a reload, the same trick `createMoveToIndexOp` uses.\n */\nfunction createPartitionedReorderOp(args: {\n ids: string[];\n direction: ReorderDirection;\n fn: ReorderFn;\n label?: string;\n prevOrders?: ReorderRestoreEntry[];\n}): Op {\n const { ids, direction, fn, label, prevOrders } = args;\n const argsForSerial: ReorderArgs = {\n ids,\n direction,\n label,\n prevOrders: prevOrders ? prevOrders.map((e) => ({ ...e, before: e.before.slice() })) : undefined,\n };\n let restore: ReorderRestoreEntry[] | null =\n prevOrders ? prevOrders.map((e) => ({ ...e, before: e.before.slice() })) : null;\n\n return {\n name: 'reorder',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as ReorderAdapter;\n if (!a.getChildren || !a.setChildOrder) return false; // graceful no-op\n // Partition ids by current parent.\n const byParent = new Map<string | null, string[]>();\n for (const id of ids) {\n const parent = a.getParent ? a.getParent(id) : null;\n const list = byParent.get(parent) ?? [];\n list.push(id);\n byParent.set(parent, list);\n }\n const snapshots: ReorderRestoreEntry[] = [];\n let mutated = false;\n for (const [parentId, parentIds] of byParent) {\n const before = a.getChildren(parentId);\n const after = fn(before, parentIds);\n if (arraysEqual(before, after)) continue; // already at the desired order\n snapshots.push({ parentId, before: before.slice() });\n a.setChildOrder(parentId, after);\n mutated = true;\n }\n restore = snapshots;\n argsForSerial.prevOrders = snapshots.map((e) => ({ ...e, before: e.before.slice() }));\n return mutated;\n },\n invert() {\n const captured = restore;\n return {\n ...createSetChildOrderOp({\n orders: (captured ?? []).map((e) => ({ parentId: e.parentId, ids: e.before })),\n label,\n }),\n invert: () =>\n createPartitionedReorderOp({\n ids, direction, fn, label, prevOrders: captured ?? undefined,\n }),\n };\n },\n };\n}\n\n/** Direction of a sibling z-order reorder. */\nexport type ReorderDirection = 'forward' | 'backward' | 'front' | 'back';\n\nconst REORDER_DIRECTIONS: Record<ReorderDirection, { fn: ReorderFn; defaultLabel: string }> = {\n forward: { fn: bringForward, defaultLabel: 'Bring forward' },\n backward: { fn: sendBackward, defaultLabel: 'Send backward' },\n front: { fn: bringToFront, defaultLabel: 'Bring to front' },\n back: { fn: sendToBack, defaultLabel: 'Send to back' },\n};\n\n/**\n * Op: shift each id within its parent's child order per `direction`:\n * - `'forward'` — bump one step toward the top\n * - `'backward'` — bump one step toward the bottom\n * - `'front'` — move to the top, preserving relative order\n * - `'back'` — move to the bottom, preserving relative order\n */\nexport function createReorderOp(args: ReorderArgs): Op {\n const { ids, direction, label, prevOrders } = args;\n const { fn, defaultLabel } = REORDER_DIRECTIONS[direction];\n return createPartitionedReorderOp({\n ids, direction, fn, label: label ?? defaultLabel, prevOrders,\n });\n}\n\nregisterOpFactory<ReorderArgs>('reorder', (args) => createReorderOp(args));\n\n/** Arguments to {@link createMoveToIndexOp}: move `ids` to `index` under `parentId`. */\nexport interface MoveToIndexArgs {\n ids: string[];\n parentId: string | null;\n index: number;\n label?: string;\n /** Optional pre-mutation child order for the parent. When present, the op\n * uses it as the invert target instead of capturing at apply time — this\n * is how a deserialized op (whose original `apply` already ran in a prior\n * session) restores its invert behavior across an IDB round-trip. */\n prevPositions?: string[];\n}\n\n/** Op: move all `ids` to a contiguous block starting at `index` within `parentId`'s child order. */\nexport function createMoveToIndexOp(args: MoveToIndexArgs): Op {\n const { ids, parentId, index, label } = args;\n // Outer args record we'll mutate so the captured `before` lands in the\n // serialized form. `prevPositions` arrives populated when reconstructed\n // from a snapshot; otherwise it's filled in on first apply.\n const argsForSerial: MoveToIndexArgs = {\n ids,\n parentId,\n index,\n label,\n prevPositions: args.prevPositions ? args.prevPositions.slice() : undefined,\n };\n let before: string[] | null = args.prevPositions ? args.prevPositions.slice() : null;\n\n return {\n name: 'moveToIndex',\n args: argsForSerial,\n label: label ?? 'Move to index',\n apply(adapter) {\n const a = adapter as ReorderAdapter;\n if (!a.getChildren || !a.setChildOrder) return;\n // Filter to ids whose current parent matches target parent.\n const eligible = ids.filter((id) => {\n const p = a.getParent ? a.getParent(id) : null;\n return p === parentId;\n });\n const current = a.getChildren(parentId);\n // Only overwrite `before` the first time we apply; redo (a second\n // apply) must not clobber the originally-captured order, otherwise\n // invert would replay the post-move state and undo nothing.\n if (before === null) {\n before = current.slice();\n argsForSerial.prevPositions = before.slice();\n }\n const after = moveToIndex(current, eligible, index);\n a.setChildOrder(parentId, after);\n },\n invert() {\n const captured = before;\n return {\n ...createSetChildOrderOp({ orders: captured ? [{ parentId, ids: captured }] : [], label }),\n invert: () =>\n createMoveToIndexOp({\n ids, parentId, index, label, prevPositions: captured ?? undefined,\n }),\n };\n },\n };\n}\n\nreg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CAACR,EAAE,eAAe,CAACA,EAAE,eAAe;GAExC,IAAMkC,IAAWvB,EAAI,QAAQ,OACjBX,EAAE,YAAYA,EAAE,UAAUU,CAAE,IAAI,UAC7BM,CACd,GACKmB,IAAUnC,EAAE,YAAYgB,CAAQ;GAItC,AAAIE,MAAW,SACb,IAASiB,EAAQ,MAAM,GACvB,EAAc,gBAAgBjB,EAAO,MAAM;GAE7C,IAAMC,IAAQiB,EAAYD,GAASD,GAAUG,CAAK;GAClD,EAAE,cAAcrB,GAAUG,CAAK;EACjC;EACA,SAAS;GACP,IAAME,IAAWH;GACjB,OAAO;IACL,GAAGI,EAAsB;KAAE,QAAQD,IAAW,CAAC;MAAE;MAAU,KAAKA;KAAS,CAAC,IAAI,CAAC;KAAG;IAAM,CAAC;IACzF,cACEY,EAAoB;KAClB;KAAK;KAAU;KAAO;KAAO,eAAeZ,KAAY,KAAA;IAC1D,CAAC;GACL;EACF;CACF;AACF;AAEAW,EAAmC,gBAAgB,MAASC,EAAoB7B,CAAI,CAAC"}
1
+ {"version":3,"file":"index.js","names":["arraysEqual","a","b","i","createPartitionedReorderOp","args","argsForSerial","prevOrders","restore","adapter","byParent","id","ids","parent","list","snapshots","mutated","parentId","parentIds","before","after","fn","captured","createSetChildOrderOp","REORDER_DIRECTIONS","bringForward","sendBackward","bringToFront","sendToBack","createReorderOp","direction","label","defaultLabel","registerOpFactory","createMoveToIndexOp","eligible","current","moveToIndex","index","canBringForward","canSendBackward"],"sources":["../../../../src/core/ops/reorder/index.ts"],"sourcesContent":["import type { Op } from '../types';\nimport { registerOpFactory } from '../registry';\nimport {\n bringForward,\n sendBackward,\n bringToFront,\n sendToBack,\n moveToIndex,\n} from './algorithms';\n\nimport { createSetChildOrderOp } from './setChildOrder';\n\nexport { canBringForward, canSendBackward } from './algorithms';\nexport { createSetChildOrderOp, type ChildOrder, type SetChildOrderArgs } from './setChildOrder';\n\ninterface ReorderAdapter {\n getParent(id: string): string | null;\n getChildren(parentId: string | null): string[];\n setChildOrder(parentId: string | null, ids: string[]): void;\n}\n\ntype ReorderFn = (list: string[], ids: string[]) => string[];\n\nfunction arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/** One parent's child order before a reorder, kept so undo can restore it. */\nexport interface ReorderRestoreEntry {\n parentId: string | null;\n before: string[];\n}\n\n/** Arguments to {@link createReorderOp}: move `ids` in paint order, one step or to the front/back. */\nexport interface ReorderArgs {\n ids: string[];\n direction: ReorderDirection;\n label?: string;\n /** Pre-mutation child order per touched parent. Filled in on first apply;\n * arrives populated when the op is rebuilt from a snapshot. */\n prevOrders?: ReorderRestoreEntry[];\n}\n\n/**\n * Build an op that, on apply, partitions `ids` by their current parent,\n * runs `fn(currentChildren, idsForParent)` per parent, and writes the\n * result back via setChildOrder. Records before-state per parent so invert\n * is exact.\n *\n * `prevOrders` is that before-state, mirrored into the op's serialized args\n * on first apply. A deserialized op has never run its own `apply`, so its\n * invert has nothing to capture — reading it back from the args is what lets\n * a reorder survive a reload, the same trick `createMoveToIndexOp` uses.\n */\nfunction createPartitionedReorderOp(args: {\n ids: string[];\n direction: ReorderDirection;\n fn: ReorderFn;\n label?: string;\n prevOrders?: ReorderRestoreEntry[];\n}): Op {\n const { ids, direction, fn, label, prevOrders } = args;\n const argsForSerial: ReorderArgs = {\n ids,\n direction,\n label,\n prevOrders: prevOrders ? prevOrders.map((e) => ({ ...e, before: e.before.slice() })) : undefined,\n };\n let restore: ReorderRestoreEntry[] | null =\n prevOrders ? prevOrders.map((e) => ({ ...e, before: e.before.slice() })) : null;\n\n return {\n name: 'reorder',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as ReorderAdapter;\n // Partition ids by current parent.\n const byParent = new Map<string | null, string[]>();\n for (const id of ids) {\n const parent = a.getParent(id);\n const list = byParent.get(parent) ?? [];\n list.push(id);\n byParent.set(parent, list);\n }\n const snapshots: ReorderRestoreEntry[] = [];\n let mutated = false;\n for (const [parentId, parentIds] of byParent) {\n const before = a.getChildren(parentId);\n const after = fn(before, parentIds);\n if (arraysEqual(before, after)) continue; // already at the desired order\n snapshots.push({ parentId, before: before.slice() });\n a.setChildOrder(parentId, after);\n mutated = true;\n }\n restore = snapshots;\n argsForSerial.prevOrders = snapshots.map((e) => ({ ...e, before: e.before.slice() }));\n return mutated;\n },\n invert() {\n const captured = restore;\n return {\n ...createSetChildOrderOp({\n orders: (captured ?? []).map((e) => ({ parentId: e.parentId, ids: e.before })),\n label,\n }),\n invert: () =>\n createPartitionedReorderOp({\n ids, direction, fn, label, prevOrders: captured ?? undefined,\n }),\n };\n },\n };\n}\n\n/** Direction of a sibling z-order reorder. */\nexport type ReorderDirection = 'forward' | 'backward' | 'front' | 'back';\n\nconst REORDER_DIRECTIONS: Record<ReorderDirection, { fn: ReorderFn; defaultLabel: string }> = {\n forward: { fn: bringForward, defaultLabel: 'Bring forward' },\n backward: { fn: sendBackward, defaultLabel: 'Send backward' },\n front: { fn: bringToFront, defaultLabel: 'Bring to front' },\n back: { fn: sendToBack, defaultLabel: 'Send to back' },\n};\n\n/**\n * Op: shift each id within its parent's child order per `direction`:\n * - `'forward'` — bump one step toward the top\n * - `'backward'` — bump one step toward the bottom\n * - `'front'` — move to the top, preserving relative order\n * - `'back'` — move to the bottom, preserving relative order\n */\nexport function createReorderOp(args: ReorderArgs): Op {\n const { ids, direction, label, prevOrders } = args;\n const { fn, defaultLabel } = REORDER_DIRECTIONS[direction];\n return createPartitionedReorderOp({\n ids, direction, fn, label: label ?? defaultLabel, prevOrders,\n });\n}\n\nregisterOpFactory<ReorderArgs>('reorder', (args) => createReorderOp(args));\n\n/** Arguments to {@link createMoveToIndexOp}: move `ids` to `index` under `parentId`. */\nexport interface MoveToIndexArgs {\n ids: string[];\n parentId: string | null;\n index: number;\n label?: string;\n /** Optional pre-mutation child order for the parent. When present, the op\n * uses it as the invert target instead of capturing at apply time — this\n * is how a deserialized op (whose original `apply` already ran in a prior\n * session) restores its invert behavior across an IDB round-trip. */\n prevPositions?: string[];\n}\n\n/** Op: move all `ids` to a contiguous block starting at `index` within `parentId`'s child order. */\nexport function createMoveToIndexOp(args: MoveToIndexArgs): Op {\n const { ids, parentId, index, label } = args;\n // Outer args record we'll mutate so the captured `before` lands in the\n // serialized form. `prevPositions` arrives populated when reconstructed\n // from a snapshot; otherwise it's filled in on first apply.\n const argsForSerial: MoveToIndexArgs = {\n ids,\n parentId,\n index,\n label,\n prevPositions: args.prevPositions ? args.prevPositions.slice() : undefined,\n };\n let before: string[] | null = args.prevPositions ? args.prevPositions.slice() : null;\n\n return {\n name: 'moveToIndex',\n args: argsForSerial,\n label: label ?? 'Move to index',\n apply(adapter) {\n const a = adapter as ReorderAdapter;\n // Filter to ids whose current parent matches target parent.\n const eligible = ids.filter((id) => a.getParent(id) === parentId);\n const current = a.getChildren(parentId);\n // Only overwrite `before` the first time we apply; redo (a second\n // apply) must not clobber the originally-captured order, otherwise\n // invert would replay the post-move state and undo nothing.\n if (before === null) {\n before = current.slice();\n argsForSerial.prevPositions = before.slice();\n }\n const after = moveToIndex(current, eligible, index);\n a.setChildOrder(parentId, after);\n },\n invert() {\n const captured = before;\n return {\n ...createSetChildOrderOp({ orders: captured ? [{ parentId, ids: captured }] : [], label }),\n invert: () =>\n createMoveToIndexOp({\n ids, parentId, index, label, prevPositions: captured ?? undefined,\n }),\n };\n },\n };\n}\n\nregisterOpFactory<MoveToIndexArgs>('moveToIndex', (args) => createMoveToIndexOp(args));\n"],"mappings":";;;;AAuBA,SAASA,EAAY,GAAsB,GAA+B;CACxE,IAAIC,EAAE,WAAWC,EAAE,QAAQ,OAAO;CAClC,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAE,QAAQ,KAAK,IAAIA,EAAEE,OAAOD,EAAEC,IAAI,OAAO;CAC7D,OAAO;AACT;AA6BA,SAASC,EAA2B,GAM7B;CACL,IAAM,EAAE,QAAK,cAAW,OAAI,UAAO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AC;IACzF,cACEY,EAAoB;KAClB;KAAK;KAAU;KAAO;KAAO,eAAeZ,KAAY,KAAA;IAC1D,CAAC;GACL;EACF;CACF;AACF;AAEAW,EAAmC,gBAAgB,MAASC,EAAoB7B,CAAI,CAAC"}
@@ -12,11 +12,9 @@ function t(e) {
12
12
  label: r,
13
13
  apply(e) {
14
14
  let t = e;
15
- if (!t.setChildOrder) return !1;
16
- let { getChildren: r } = t;
17
- a === null && r && (a = n.map((e) => ({
15
+ a === null && (a = n.map((e) => ({
18
16
  parentId: e.parentId,
19
- ids: r.call(t, e.parentId).slice()
17
+ ids: t.getChildren(e.parentId).slice()
20
18
  })), i.prevOrders = a);
21
19
  for (let e of n) t.setChildOrder(e.parentId, e.ids.slice());
22
20
  },
@@ -1 +1 @@
1
- {"version":3,"file":"setChildOrder.js","names":["createSetChildOrderOp","args","argsForSerial","before","a","adapter","getChildren","orders","o","registerOpFactory"],"sources":["../../../../src/core/ops/reorder/setChildOrder.ts"],"sourcesContent":["import type { Op } from '../types';\nimport { registerOpFactory } from '../registry';\n\ninterface ChildOrderAdapter {\n getChildren?(parentId: string | null): string[];\n setChildOrder?(parentId: string | null, ids: string[]): void;\n}\n\n/** One parent's children, in order. */\nexport interface ChildOrder {\n parentId: string | null;\n ids: string[];\n}\n\n/** Arguments to {@link createSetChildOrderOp}: the whole child order to write, per parent. */\nexport interface SetChildOrderArgs {\n orders: ChildOrder[];\n label?: string;\n /** Each parent's order before the write. Filled in on first apply;\n * arrives populated when the op is rebuilt from a snapshot. */\n prevOrders?: ChildOrder[];\n}\n\n/** Op: write each listed parent's whole child order; inverts to a write of the\n * orders it replaced. Where `createMoveToIndexOp` keeps the moved ids in their\n * current relative order, this states every position. */\nexport function createSetChildOrderOp(args: SetChildOrderArgs): Op {\n const { orders, label } = args;\n const argsForSerial: SetChildOrderArgs = { orders, label, prevOrders: args.prevOrders };\n let before: ChildOrder[] | null = args.prevOrders ?? null;\n return {\n name: 'setChildOrder',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as ChildOrderAdapter;\n if (!a.setChildOrder) return false;\n const { getChildren } = a;\n if (before === null && getChildren) {\n before = orders.map((o) => ({ parentId: o.parentId, ids: getChildren.call(a, o.parentId).slice() }));\n argsForSerial.prevOrders = before;\n }\n for (const o of orders) a.setChildOrder(o.parentId, o.ids.slice());\n return undefined;\n },\n invert: () => createSetChildOrderOp({ orders: before ?? [], label, prevOrders: orders }),\n };\n}\n\nregisterOpFactory<SetChildOrderArgs>('setChildOrder', (args) => createSetChildOrderOp(args));\n"],"mappings":";;AA0BA,SAAgBA,EAAsB,GAA6B;CACjE,IAAM,EAAE,WAAQ,aAAUC,GACpBC,IAAmC;EAAE;EAAQ;EAAO,YAAYD,EAAK;CAAW,GAClFE,IAA8BF,EAAK,cAAc;CACrD,OAAO;EACL,MAAM;EACN,MAAMC;EACN;EACA,MAAM,GAAS;GACb,IAAME,IAAIC;GACV,IAAI,CAACD,EAAE,eAAe,OAAO;GAC7B,IAAM,EAAE,mBAAgBA;GACxB,AAAID,MAAW,QAAQG,MACrB,IAASC,EAAO,KAAK,OAAO;IAAE,UAAUC,EAAE;IAAU,KAAKF,EAAY,KAAKF,GAAGI,EAAE,QAAQ,CAAC,CAAC,MAAM;GAAE,EAAE,GACnG,EAAc,aAAaL;GAE7B,KAAK,IAAMK,KAAKD,GAAQ,EAAE,cAAcC,EAAE,UAAUA,EAAE,IAAI,MAAM,CAAC;EAEnE;EACA,cAAcR,EAAsB;GAAE,QAAQG,KAAU,CAAC;GAAG;GAAO,YAAYI;EAAO,CAAC;CACzF;AACF;AAEAE,EAAqC,kBAAkB,MAAST,EAAsBC,CAAI,CAAC"}
1
+ {"version":3,"file":"setChildOrder.js","names":["createSetChildOrderOp","args","argsForSerial","before","a","adapter","orders","o","registerOpFactory"],"sources":["../../../../src/core/ops/reorder/setChildOrder.ts"],"sourcesContent":["import type { Op } from '../types';\nimport { registerOpFactory } from '../registry';\n\ninterface ChildOrderAdapter {\n getChildren(parentId: string | null): string[];\n setChildOrder(parentId: string | null, ids: string[]): void;\n}\n\n/** One parent's children, in order. */\nexport interface ChildOrder {\n parentId: string | null;\n ids: string[];\n}\n\n/** Arguments to {@link createSetChildOrderOp}: the whole child order to write, per parent. */\nexport interface SetChildOrderArgs {\n orders: ChildOrder[];\n label?: string;\n /** Each parent's order before the write. Filled in on first apply;\n * arrives populated when the op is rebuilt from a snapshot. */\n prevOrders?: ChildOrder[];\n}\n\n/** Op: write each listed parent's whole child order; inverts to a write of the\n * orders it replaced. Where `createMoveToIndexOp` keeps the moved ids in their\n * current relative order, this states every position. */\nexport function createSetChildOrderOp(args: SetChildOrderArgs): Op {\n const { orders, label } = args;\n const argsForSerial: SetChildOrderArgs = { orders, label, prevOrders: args.prevOrders };\n let before: ChildOrder[] | null = args.prevOrders ?? null;\n return {\n name: 'setChildOrder',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as ChildOrderAdapter;\n if (before === null) {\n before = orders.map((o) => ({ parentId: o.parentId, ids: a.getChildren(o.parentId).slice() }));\n argsForSerial.prevOrders = before;\n }\n for (const o of orders) a.setChildOrder(o.parentId, o.ids.slice());\n return undefined;\n },\n invert: () => createSetChildOrderOp({ orders: before ?? [], label, prevOrders: orders }),\n };\n}\n\nregisterOpFactory<SetChildOrderArgs>('setChildOrder', (args) => createSetChildOrderOp(args));\n"],"mappings":";;AA0BA,SAAgBA,EAAsB,GAA6B;CACjE,IAAM,EAAE,WAAQ,aAAUC,GACpBC,IAAmC;EAAE;EAAQ;EAAO,YAAYD,EAAK;CAAW,GAClFE,IAA8BF,EAAK,cAAc;CACrD,OAAO;EACL,MAAM;EACN,MAAMC;EACN;EACA,MAAM,GAAS;GACb,IAAME,IAAIC;GACV,AAAIF,MAAW,SACb,IAASG,EAAO,KAAK,OAAO;IAAE,UAAUC,EAAE;IAAU,KAAKH,EAAE,YAAYG,EAAE,QAAQ,CAAC,CAAC,MAAM;GAAE,EAAE,GAC7F,EAAc,aAAaJ;GAE7B,KAAK,IAAMI,KAAKD,GAAQ,EAAE,cAAcC,EAAE,UAAUA,EAAE,IAAI,MAAM,CAAC;EAEnE;EACA,cAAcP,EAAsB;GAAE,QAAQG,KAAU,CAAC;GAAG;GAAO,YAAYG;EAAO,CAAC;CACzF;AACF;AAEAE,EAAqC,kBAAkB,MAASR,EAAsBC,CAAI,CAAC"}
@@ -2,7 +2,6 @@ import { registerOpFactory as e } from "./registry.js";
2
2
  import { captureSlot as t, resolveSlot as n, slotFromIndex as r } from "./slot.js";
3
3
  //#region src/core/ops/reparent.ts
4
4
  function i(e, t, r, i) {
5
- if (!e.getChildren || !e.setChildOrder) return;
6
5
  let a = e.getChildren(t), o = a.indexOf(r);
7
6
  if (o < 0) return;
8
7
  let s = a.slice();
@@ -1 +1 @@
1
- {"version":3,"file":"reparent.js","names":["placeAt","a","current","parentId","from","id","next","resolved","resolveSlot","slot","to","optionalSlot","index","slotFromIndex","createReparentOp","args","fromSlot","toSlot","argsForSerial","adapter","observed","captureSlot","fromParentId","toParentId","registerOpFactory"],"sources":["../../../src/core/ops/reparent.ts"],"sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, resolveSlot, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface ReparentAdapter extends OrderedReader {\n setParent(id: string, parentId: string | null): void;\n /** Sibling-order write, paired with `getChildren`. Optional: an adapter\n * without both silently ignores slots and appends. */\n setChildOrder?(parentId: string | null, ids: string[]): void;\n}\n\n/** Arguments to {@link createReparentOp}: move node `id` from one parent to another. */\nexport interface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n /** Sibling ordinal under the old parent. Sugar for `fromSlot: { index }`,\n * and only a seed: `apply` re-observes the node's full slot through the\n * adapter and that observation supersedes this. */\n fromIndex?: number;\n /** Sibling ordinal under the new parent. Sugar for `toSlot: { index }`.\n * Omit to append. */\n toIndex?: number;\n /** Slot under the old parent, anchor included. `invert()` forwards it as\n * the destination slot; without it undo re-parents with no position and\n * the node lands last, quietly changing paint order. */\n fromSlot?: SiblingSlot;\n /** Slot under the new parent, anchor included. Omit to append. */\n toSlot?: SiblingSlot;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Move `id` to `slot` among `parentId`'s children. No-op when the adapter\n * has no ordering seam, when `id` isn't there, or when it's already in\n * place. */\nfunction placeAt(\n a: ReparentAdapter,\n parentId: string | null,\n id: string,\n slot: SiblingSlot,\n): void {\n if (!a.getChildren || !a.setChildOrder) return;\n const current = a.getChildren(parentId);\n const from = current.indexOf(id);\n if (from < 0) return;\n const next = current.slice();\n next.splice(from, 1);\n const resolved = resolveSlot(next, slot);\n const to = resolved === undefined ? next.length : Math.max(0, Math.min(resolved, next.length));\n if (from === to) return;\n next.splice(to, 0, id);\n a.setChildOrder(parentId, next);\n}\n\n/** Present when the caller named a destination at all; `undefined` leaves\n * placement to the adapter. */\nfunction optionalSlot(slot: SiblingSlot | undefined, index: number | undefined): SiblingSlot | undefined {\n if (slot) return slot;\n return index === undefined ? undefined : slotFromIndex(index);\n}\n\n/**\n * Op: change `id`'s parent and sibling slot, inverting back to the prior\n * parent and slot.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const {\n id, fromParentId, toParentId,\n label = 'Reparent', coalesceKey = `reparent:${id}`,\n } = args;\n let fromSlot = optionalSlot(args.fromSlot, args.fromIndex);\n const toSlot = optionalSlot(args.toSlot, args.toIndex);\n const argsForSerial: ReparentArgs = {\n id, fromParentId, toParentId, fromSlot, toSlot, label, coalesceKey,\n };\n return {\n name: 'reparent',\n args: argsForSerial,\n label,\n coalesceKey,\n apply(adapter) {\n const a = adapter as ReparentAdapter;\n const observed = captureSlot(a, fromParentId, id);\n if (observed) {\n fromSlot = observed;\n argsForSerial.fromSlot = observed;\n }\n a.setParent(id, toParentId);\n if (toSlot) placeAt(a, toParentId, id, toSlot);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n fromSlot: toSlot,\n toSlot: fromSlot,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n"],"mappings":";;;AAoCA,SAASA,EACP,GACA,GACA,GACA,GACM;CACN,IAAI,CAACC,EAAE,eAAe,CAACA,EAAE,eAAe;CACxC,IAAMC,IAAUD,EAAE,YAAYE,CAAQ,GAChCC,IAAOF,EAAQ,QAAQG,CAAE;CAC/B,IAAID,IAAO,GAAG;CACd,IAAME,IAAOJ,EAAQ,MAAM;CAC3B,EAAK,OAAOE,GAAM,CAAC;CACnB,IAAMG,IAAWC,EAAYF,GAAMG,CAAI,GACjCC,IAAKH,MAAa,KAAA,IAAYD,EAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAIC,GAAUD,EAAK,MAAM,CAAC;CAC7F,AAAIF,MAASM,MACbJ,EAAK,OAAOI,GAAI,GAAGL,CAAE,GACrBJ,EAAE,cAAcE,GAAUG,CAAI;AAChC;AAIA,SAASK,EAAa,GAA+B,GAAoD;CAEvG,OADIF,MACGG,MAAU,KAAA,IAAY,KAAA,IAAYC,EAAcD,CAAK;AAC9D;AASA,SAAgBE,EAAiB,GAAwB;CACvD,IAAM,EACJ,OAAI,iBAAc,eAClB,WAAQ,YAAY,iBAAc,YAAYT,QAC5CU,GACAC,IAAWL,EAAaI,EAAK,UAAUA,EAAK,SAAS,GACnDE,IAASN,EAAaI,EAAK,QAAQA,EAAK,OAAO,GAC/CG,IAA8B;EAClC;EAAI;EAAc;EAAY;EAAU;EAAQ;EAAO;CACzD;CACA,OAAO;EACL,MAAM;EACN,MAAMA;EACN;EACA;EACA,MAAM,GAAS;GACb,IAAM,IAAIC,GACJC,IAAWC,EAAY,GAAGC,GAAcjB,CAAE;GAMhD,AALIe,MACF,IAAWA,GACX,EAAc,WAAWA,IAE3B,EAAE,UAAUf,GAAIkB,CAAU,GACtBN,KAAQjB,EAAQ,GAAGuB,GAAYlB,GAAIY,CAAM;EAC/C;EACA,SAAS;GACP,OAAOH,EAAiB;IACtB;IACA,cAAcS;IACd,YAAYD;IACZ,UAAUL;IACV,QAAQD;IACR;IACA;GACF,CAAC;EACH;CACF;AACF;AAEAQ,EAAgC,aAAa,MAASV,EAAiBC,CAAI,CAAC"}
1
+ {"version":3,"file":"reparent.js","names":["placeAt","current","a","parentId","from","id","next","resolved","resolveSlot","slot","to","optionalSlot","index","slotFromIndex","createReparentOp","args","fromSlot","toSlot","argsForSerial","adapter","observed","captureSlot","fromParentId","toParentId","registerOpFactory"],"sources":["../../../src/core/ops/reparent.ts"],"sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, resolveSlot, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface ReparentAdapter extends OrderedReader {\n setParent(id: string, parentId: string | null): void;\n /** Sibling-order write, paired with `getChildren`. */\n setChildOrder(parentId: string | null, ids: string[]): void;\n}\n\n/** Arguments to {@link createReparentOp}: move node `id` from one parent to another. */\nexport interface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n /** Sibling ordinal under the old parent. Sugar for `fromSlot: { index }`,\n * and only a seed: `apply` re-observes the node's full slot through the\n * adapter and that observation supersedes this. */\n fromIndex?: number;\n /** Sibling ordinal under the new parent. Sugar for `toSlot: { index }`.\n * Omit to append. */\n toIndex?: number;\n /** Slot under the old parent, anchor included. `invert()` forwards it as\n * the destination slot; without it undo re-parents with no position and\n * the node lands last, quietly changing paint order. */\n fromSlot?: SiblingSlot;\n /** Slot under the new parent, anchor included. Omit to append. */\n toSlot?: SiblingSlot;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Move `id` to `slot` among `parentId`'s children. No-op when `id` isn't\n * there or is already in place. */\nfunction placeAt(\n a: ReparentAdapter,\n parentId: string | null,\n id: string,\n slot: SiblingSlot,\n): void {\n const current = a.getChildren(parentId);\n const from = current.indexOf(id);\n if (from < 0) return;\n const next = current.slice();\n next.splice(from, 1);\n const resolved = resolveSlot(next, slot);\n const to = resolved === undefined ? next.length : Math.max(0, Math.min(resolved, next.length));\n if (from === to) return;\n next.splice(to, 0, id);\n a.setChildOrder(parentId, next);\n}\n\n/** Present when the caller named a destination at all; `undefined` leaves\n * placement to the adapter. */\nfunction optionalSlot(slot: SiblingSlot | undefined, index: number | undefined): SiblingSlot | undefined {\n if (slot) return slot;\n return index === undefined ? undefined : slotFromIndex(index);\n}\n\n/**\n * Op: change `id`'s parent and sibling slot, inverting back to the prior\n * parent and slot.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const {\n id, fromParentId, toParentId,\n label = 'Reparent', coalesceKey = `reparent:${id}`,\n } = args;\n let fromSlot = optionalSlot(args.fromSlot, args.fromIndex);\n const toSlot = optionalSlot(args.toSlot, args.toIndex);\n const argsForSerial: ReparentArgs = {\n id, fromParentId, toParentId, fromSlot, toSlot, label, coalesceKey,\n };\n return {\n name: 'reparent',\n args: argsForSerial,\n label,\n coalesceKey,\n apply(adapter) {\n const a = adapter as ReparentAdapter;\n const observed = captureSlot(a, fromParentId, id);\n if (observed) {\n fromSlot = observed;\n argsForSerial.fromSlot = observed;\n }\n a.setParent(id, toParentId);\n if (toSlot) placeAt(a, toParentId, id, toSlot);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n fromSlot: toSlot,\n toSlot: fromSlot,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n"],"mappings":";;;AAkCA,SAASA,EACP,GACA,GACA,GACA,GACM;CACN,IAAMC,IAAUC,EAAE,YAAYC,CAAQ,GAChCC,IAAOH,EAAQ,QAAQI,CAAE;CAC/B,IAAID,IAAO,GAAG;CACd,IAAME,IAAOL,EAAQ,MAAM;CAC3B,EAAK,OAAOG,GAAM,CAAC;CACnB,IAAMG,IAAWC,EAAYF,GAAMG,CAAI,GACjCC,IAAKH,MAAa,KAAA,IAAYD,EAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAIC,GAAUD,EAAK,MAAM,CAAC;CAC7F,AAAIF,MAASM,MACbJ,EAAK,OAAOI,GAAI,GAAGL,CAAE,GACrBH,EAAE,cAAcC,GAAUG,CAAI;AAChC;AAIA,SAASK,EAAa,GAA+B,GAAoD;CAEvG,OADIF,MACGG,MAAU,KAAA,IAAY,KAAA,IAAYC,EAAcD,CAAK;AAC9D;AASA,SAAgBE,EAAiB,GAAwB;CACvD,IAAM,EACJ,OAAI,iBAAc,eAClB,WAAQ,YAAY,iBAAc,YAAYT,QAC5CU,GACAC,IAAWL,EAAaI,EAAK,UAAUA,EAAK,SAAS,GACnDE,IAASN,EAAaI,EAAK,QAAQA,EAAK,OAAO,GAC/CG,IAA8B;EAClC;EAAI;EAAc;EAAY;EAAU;EAAQ;EAAO;CACzD;CACA,OAAO;EACL,MAAM;EACN,MAAMA;EACN;EACA;EACA,MAAM,GAAS;GACb,IAAM,IAAIC,GACJC,IAAWC,EAAY,GAAGC,GAAcjB,CAAE;GAMhD,AALIe,MACF,IAAWA,GACX,EAAc,WAAWA,IAE3B,EAAE,UAAUf,GAAIkB,CAAU,GACtBN,KAAQjB,EAAQ,GAAGuB,GAAYlB,GAAIY,CAAM;EAC/C;EACA,SAAS;GACP,OAAOH,EAAiB;IACtB;IACA,cAAcS;IACd,YAAYD;IACZ,UAAUL;IACV,QAAQD;IACR;IACA;GACF,CAAC;EACH;CACF;AACF;AAEAQ,EAAgC,aAAa,MAASV,EAAiBC,CAAI,CAAC"}
@@ -1,8 +1,6 @@
1
1
  //#region src/core/ops/slot.ts
2
2
  function e(e, t, n) {
3
- let r = e.getChildren?.(t);
4
- if (!r) return null;
5
- let i = r.indexOf(n);
3
+ let r = e.getChildren(t), i = r.indexOf(n);
6
4
  return i < 0 ? null : {
7
5
  index: i,
8
6
  before: i + 1 < r.length ? r[i + 1] : null
@@ -10,7 +8,7 @@ function e(e, t, n) {
10
8
  }
11
9
  function t(e, t) {
12
10
  if (t.before !== null) {
13
- if (t.before !== void 0 && e) {
11
+ if (t.before !== void 0) {
14
12
  let n = e.indexOf(t.before);
15
13
  if (n >= 0) return n;
16
14
  }
@@ -18,8 +16,7 @@ function t(e, t) {
18
16
  }
19
17
  }
20
18
  function n(e, t) {
21
- if (!e.getChildren) return null;
22
- let n = e.getParent ? e.getParent(t) : null, r = e.getChildren(n).indexOf(t);
19
+ let n = e.getParent(t), r = e.getChildren(n).indexOf(t);
23
20
  return r < 0 ? null : {
24
21
  parentId: n,
25
22
  index: r
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","names":["captureSlot","siblings","a","parentId","id","resolveSlot","slot","at","locateChild","index","slotFromIndex","parentOf","node"],"sources":["../../../src/core/ops/slot.ts"],"sourcesContent":["/** Sibling-order read seam. Optional everywhere: a flat adapter has none. */\nexport interface OrderedReader {\n getChildren?(parentId: string | null): string[];\n}\n\n/**\n * A node's position among its siblings, recorded so an op can put it back.\n *\n * Recorded as an anchor (`before`) plus an ordinal (`index`). The anchor is\n * the source of truth: `History` replays a batch's inverses in reverse order,\n * so an ordinal captured before the mutation is replayed against a list that\n * has not been refilled yet and clamps to the end, while \"put this back before\n * `e`\" stays true however much else has already moved. The ordinal is the\n * fallback for the cases the anchor cannot cover — an adapter with no\n * `getChildren` seam, or an anchor that is itself gone by replay time.\n */\nexport interface SiblingSlot {\n /** Ordinal among the siblings. `-1` means \"nowhere in particular\". */\n index: number;\n /** Id of the sibling that followed at capture time; `null` when the node\n * was last. Absent when nothing observed it — `null` survives JSON and\n * `undefined` does not, so the two stay distinguishable across a\n * serialize/restore round trip. */\n before?: string | null;\n}\n\n/** Observe `id`'s slot among `parentId`'s children. `null` when the adapter\n * has no ordering seam or `id` isn't there — callers keep whatever weaker\n * slot they already had rather than overwriting it with a guess. */\nexport function captureSlot(\n a: OrderedReader,\n parentId: string | null,\n id: string,\n): SiblingSlot | null {\n const siblings = a.getChildren?.(parentId);\n if (!siblings) return null;\n const i = siblings.indexOf(id);\n if (i < 0) return null;\n return { index: i, before: i + 1 < siblings.length ? siblings[i + 1]! : null };\n}\n\n/**\n * Index `slot` denotes in `siblings`, which must NOT contain the node being\n * placed. `undefined` means \"no position\" — the caller appends, or lets the\n * adapter's default placement stand.\n */\nexport function resolveSlot(\n siblings: readonly string[] | undefined,\n slot: SiblingSlot,\n): number | undefined {\n if (slot.before === null) return undefined;\n if (slot.before !== undefined && siblings) {\n const at = siblings.indexOf(slot.before);\n if (at >= 0) return at;\n }\n return slot.index >= 0 ? slot.index : undefined;\n}\n\n/** The reads that locate a live node: its parent, and that parent's children. */\nexport interface ParentedReader {\n getParent?(id: string): string | null;\n getChildren?(parentId: string | null): readonly string[];\n}\n\n/** A node's parent (`null` at the top level) and its ordinal among that\n * parent's children — the position a replacement takes to keep its z-order. */\nexport interface ChildPosition {\n parentId: string | null;\n index: number;\n}\n\n/** Where `id` sits under its parent. An adapter with no `getParent` is flat,\n * as the reorder ops read it. `null` when there is no `getChildren` or it\n * does not list `id`. */\nexport function locateChild(a: ParentedReader, id: string): ChildPosition | null {\n if (!a.getChildren) return null;\n const parentId = a.getParent ? a.getParent(id) : null;\n const index = a.getChildren(parentId).indexOf(id);\n return index < 0 ? null : { parentId, index };\n}\n\n/** Normalize the `index` sugar every op factory accepts into a slot. */\nexport function slotFromIndex(index: number | undefined): SiblingSlot {\n return { index: index ?? -1 };\n}\n\n/** The parent a node claims. Nodes in a flat adapter have none. */\nexport function parentOf(node: object): string | null {\n return ((node as { parent?: unknown }).parent ?? null) as string | null;\n}\n"],"mappings":";AA6BA,SAAgBA,EACd,GACA,GACA,GACoB;CACpB,IAAMC,IAAWC,EAAE,cAAcC,CAAQ;CACzC,IAAI,CAACF,GAAU,OAAO;CACtB,IAAM,IAAIA,EAAS,QAAQG,CAAE;CAE7B,OADI,IAAI,IAAU,OACX;EAAE,OAAO;EAAG,QAAQ,IAAI,IAAIH,EAAS,SAASA,EAAS,IAAI,KAAM;CAAK;AAC/E;AAOA,SAAgBI,EACd,GACA,GACoB;CACpB,IAAIC,EAAK,WAAW,MACpB;MAAIA,EAAK,WAAW,KAAA,KAAaL,GAAU;GACzC,IAAMM,IAAKN,EAAS,QAAQK,EAAK,MAAM;GACvC,IAAIC,KAAM,GAAG,OAAOA;EACtB;EACA,OAAOD,EAAK,SAAS,IAAIA,EAAK,QAAQ,KAAA;CADtC;AAEF;AAkBA,SAAgBE,EAAY,GAAmB,GAAkC;CAC/E,IAAI,CAACN,EAAE,aAAa,OAAO;CAC3B,IAAMC,IAAWD,EAAE,YAAYA,EAAE,UAAUE,CAAE,IAAI,MAC3CK,IAAQP,EAAE,YAAYC,CAAQ,CAAC,CAAC,QAAQC,CAAE;CAChD,OAAOK,IAAQ,IAAI,OAAO;EAAE;EAAU;CAAM;AAC9C;AAGA,SAAgBC,EAAc,GAAwC;CACpE,OAAO,EAAE,OAAOD,KAAS,GAAG;AAC9B;AAGA,SAAgBE,EAAS,GAA6B;CACpD,OAASC,EAA8B,UAAU;AACnD"}
1
+ {"version":3,"file":"slot.js","names":["captureSlot","siblings","a","parentId","id","resolveSlot","slot","at","locateChild","index","slotFromIndex","parentOf","node"],"sources":["../../../src/core/ops/slot.ts"],"sourcesContent":["/** The sibling-order read: `parentId`'s children, bottom first. */\nexport interface OrderedReader {\n getChildren(parentId: string | null): string[];\n}\n\n/**\n * A node's position among its siblings, recorded so an op can put it back.\n *\n * Recorded as an anchor (`before`) plus an ordinal (`index`). The anchor is\n * the source of truth: `History` replays a batch's inverses in reverse order,\n * so an ordinal captured before the mutation is replayed against a list that\n * has not been refilled yet and clamps to the end, while \"put this back before\n * `e`\" stays true however much else has already moved. The ordinal is the\n * fallback for the case the anchor cannot cover: an anchor that is itself\n * gone by replay time.\n */\nexport interface SiblingSlot {\n /** Ordinal among the siblings. `-1` means \"nowhere in particular\". */\n index: number;\n /** Id of the sibling that followed at capture time; `null` when the node\n * was last. Absent when nothing observed it — `null` survives JSON and\n * `undefined` does not, so the two stay distinguishable across a\n * serialize/restore round trip. */\n before?: string | null;\n}\n\n/** Observe `id`'s slot among `parentId`'s children. `null` when `id` isn't\n * there — callers keep whatever weaker slot they already had rather than\n * overwriting it with a guess. */\nexport function captureSlot(\n a: OrderedReader,\n parentId: string | null,\n id: string,\n): SiblingSlot | null {\n const siblings = a.getChildren(parentId);\n const i = siblings.indexOf(id);\n if (i < 0) return null;\n return { index: i, before: i + 1 < siblings.length ? siblings[i + 1]! : null };\n}\n\n/**\n * Index `slot` denotes in `siblings`, which must NOT contain the node being\n * placed. `undefined` means \"no position\" — the caller appends, or lets the\n * adapter's default placement stand.\n */\nexport function resolveSlot(\n siblings: readonly string[],\n slot: SiblingSlot,\n): number | undefined {\n if (slot.before === null) return undefined;\n if (slot.before !== undefined) {\n const at = siblings.indexOf(slot.before);\n if (at >= 0) return at;\n }\n return slot.index >= 0 ? slot.index : undefined;\n}\n\n/** The reads that locate a live node: its parent, and that parent's children. */\nexport interface ParentedReader {\n getParent(id: string): string | null;\n getChildren(parentId: string | null): readonly string[];\n}\n\n/** A node's parent (`null` at the top level) and its ordinal among that\n * parent's children — the position a replacement takes to keep its z-order. */\nexport interface ChildPosition {\n parentId: string | null;\n index: number;\n}\n\n/** Where `id` sits under its parent. `null` when the parent's children do\n * not list `id`. */\nexport function locateChild(a: ParentedReader, id: string): ChildPosition | null {\n const parentId = a.getParent(id);\n const index = a.getChildren(parentId).indexOf(id);\n return index < 0 ? null : { parentId, index };\n}\n\n/** Normalize the `index` sugar every op factory accepts into a slot. */\nexport function slotFromIndex(index: number | undefined): SiblingSlot {\n return { index: index ?? -1 };\n}\n\n/** The parent a node claims; `null` for a root. */\nexport function parentOf(node: object): string | null {\n return ((node as { parent?: unknown }).parent ?? null) as string | null;\n}\n"],"mappings":";AA6BA,SAAgBA,EACd,GACA,GACA,GACoB;CACpB,IAAMC,IAAWC,EAAE,YAAYC,CAAQ,GACjC,IAAIF,EAAS,QAAQG,CAAE;CAE7B,OADI,IAAI,IAAU,OACX;EAAE,OAAO;EAAG,QAAQ,IAAI,IAAIH,EAAS,SAASA,EAAS,IAAI,KAAM;CAAK;AAC/E;AAOA,SAAgBI,EACd,GACA,GACoB;CACpB,IAAIC,EAAK,WAAW,MACpB;MAAIA,EAAK,WAAW,KAAA,GAAW;GAC7B,IAAMC,IAAKN,EAAS,QAAQK,EAAK,MAAM;GACvC,IAAIC,KAAM,GAAG,OAAOA;EACtB;EACA,OAAOD,EAAK,SAAS,IAAIA,EAAK,QAAQ,KAAA;CADtC;AAEF;AAiBA,SAAgBE,EAAY,GAAmB,GAAkC;CAC/E,IAAML,IAAWD,EAAE,UAAUE,CAAE,GACzBK,IAAQP,EAAE,YAAYC,CAAQ,CAAC,CAAC,QAAQC,CAAE;CAChD,OAAOK,IAAQ,IAAI,OAAO;EAAE;EAAU;CAAM;AAC9C;AAGA,SAAgBC,EAAc,GAAwC;CACpE,OAAO,EAAE,OAAOD,KAAS,GAAG;AAC9B;AAGA,SAAgBE,EAAS,GAA6B;CACpD,OAASC,EAA8B,UAAU;AACnD"}
@@ -0,0 +1,15 @@
1
+ import { fitViewToBounds as e } from "../viewport/fitViewToBounds.js";
2
+ //#region src/core/pages/fitViewToPage.ts
3
+ function t(t, n, r, i) {
4
+ let { x: a, y: o, width: s, height: c } = t;
5
+ return e({
6
+ x: a,
7
+ y: o,
8
+ width: s,
9
+ height: c
10
+ }, n, r, i);
11
+ }
12
+ //#endregion
13
+ export { t as fitViewToPage };
14
+
15
+ //# sourceMappingURL=fitViewToPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fitViewToPage.js","names":["fitViewToPage","page","fitViewToBounds","viewportDims","currentView","options"],"sources":["../../../src/core/pages/fitViewToPage.ts"],"sourcesContent":["import {\n fitViewToBounds,\n type FitViewToBoundsOptions,\n type ViewportDims,\n} from '../viewport/fitViewToBounds';\nimport type { View } from '../viewport/view';\nimport type { PlacedPage } from './pages';\n\n/** The view that shows one placed page whole: `fitViewToBounds` on its rect. */\nexport function fitViewToPage(\n page: PlacedPage,\n viewportDims: ViewportDims,\n currentView: View,\n options?: FitViewToBoundsOptions,\n): View {\n const { x, y, width, height } = page;\n return fitViewToBounds({ x, y, width, height }, viewportDims, currentView, options);\n}\n"],"mappings":";;AASA,SAAgBA,EACd,GACA,GACA,GACA,GACM;CACN,IAAM,EAAE,MAAG,MAAG,UAAO,cAAWC;CAChC,OAAOC,EAAgB;EAAE;EAAG;EAAG;EAAO;CAAO,GAAGC,GAAcC,GAAaC,CAAO;AACpF"}
@@ -0,0 +1,65 @@
1
+ //#region src/core/pages/pages.ts
2
+ var e = {
3
+ start: 0,
4
+ center: .5,
5
+ end: 1
6
+ };
7
+ function t(t, n = {}) {
8
+ let { direction: r = "row", gap: i = 40, align: a = "start", origin: o = {
9
+ x: 0,
10
+ y: 0
11
+ } } = n, s = r === "row", c = Math.max(0, ...t.map((e) => s ? e.height : e.width)), l = /* @__PURE__ */ new Set(), u = 0;
12
+ return t.map((t, n) => {
13
+ if (l.has(t.id)) throw Error(`layoutPages: two pages have the id "${t.id}"`);
14
+ l.add(t.id);
15
+ let r = (c - (s ? t.height : t.width)) * e[a], d = {
16
+ ...t,
17
+ x: o.x + (s ? u : r),
18
+ y: o.y + (s ? r : u),
19
+ index: n
20
+ };
21
+ return u += (s ? t.width : t.height) + i, d;
22
+ });
23
+ }
24
+ function n(e, t) {
25
+ return i(e, {
26
+ x: t.x,
27
+ y: t.y,
28
+ width: 0,
29
+ height: 0
30
+ });
31
+ }
32
+ function r(e, t) {
33
+ let n = Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x), r = Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y);
34
+ return n < 0 || r < 0 ? null : n * r;
35
+ }
36
+ function i(e, t) {
37
+ let n = null, i = -1;
38
+ for (let a of e) {
39
+ let e = r(a, t);
40
+ e !== null && e > i && (n = a, i = e);
41
+ }
42
+ return n;
43
+ }
44
+ function a(e, t, n, r = {}) {
45
+ let i = e.length;
46
+ if (i === 0) return null;
47
+ let a = e.findIndex((e) => e.id === t);
48
+ if (a < 0) return e[n < 0 ? i - 1 : 0] ?? null;
49
+ let o = a + n;
50
+ return e[r.wrap ? (o % i + i) % i : o] ?? null;
51
+ }
52
+ function o(e) {
53
+ if (e.length === 0) return null;
54
+ let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y));
55
+ return {
56
+ x: t,
57
+ y: n,
58
+ width: Math.max(...e.map((e) => e.x + e.width)) - t,
59
+ height: Math.max(...e.map((e) => e.y + e.height)) - n
60
+ };
61
+ }
62
+ //#endregion
63
+ export { a as adjacentPage, t as layoutPages, n as pageAt, i as pageOfBounds, o as pagesBounds };
64
+
65
+ //# sourceMappingURL=pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.js","names":["ALIGN","layoutPages","options","row","direction","across","pages","p","seen","along","page","offset","align","placed","origin","gap","pageAt","pageOfBounds","point","overlap","w","b","h","best","most","area","bounds","adjacentPage","n","at","current","step","to","pagesBounds","x","y"],"sources":["../../../src/core/pages/pages.ts"],"sourcesContent":["import type { Bounds } from '@weasel-js/routing';\n\n/** One page of a document: a sheet of a fixed size, in world units. */\nexport interface Page {\n readonly id: string;\n readonly name?: string;\n readonly width: number;\n readonly height: number;\n}\n\n/** A page and where it sits in world space. */\nexport interface PlacedPage extends Page {\n readonly x: number;\n readonly y: number;\n /** Its place in the document's page order. */\n readonly index: number;\n}\n\n/** Options for {@link layoutPages}. */\nexport interface PageLayoutOptions {\n /** Which way the pages run. Default `'row'`. */\n direction?: 'row' | 'column';\n /** World units between neighbors. Default 40. */\n gap?: number;\n /** Where a page sits across the run, against the largest page. Default `'start'`. */\n align?: 'start' | 'center' | 'end';\n /** Where the first page's run starts. Default the world origin. */\n origin?: { readonly x: number; readonly y: number };\n}\n\nconst ALIGN = { start: 0, center: 0.5, end: 1 } as const;\n\n/**\n * Place a document's pages in one world space, in order, so a single scene,\n * view, and history serve all of them. With the defaults the first page's\n * top-left corner is the world origin, where a one-page document's page is.\n * Throws on two pages with one id.\n */\nexport function layoutPages(pages: readonly Page[], options: PageLayoutOptions = {}): PlacedPage[] {\n const { direction = 'row', gap = 40, align = 'start', origin = { x: 0, y: 0 } } = options;\n const row = direction === 'row';\n const across = Math.max(0, ...pages.map((p) => (row ? p.height : p.width)));\n const seen = new Set<string>();\n let along = 0;\n return pages.map((page, index) => {\n if (seen.has(page.id)) throw new Error(`layoutPages: two pages have the id \"${page.id}\"`);\n seen.add(page.id);\n const offset = (across - (row ? page.height : page.width)) * ALIGN[align];\n const placed = {\n ...page,\n x: origin.x + (row ? along : offset),\n y: origin.y + (row ? offset : along),\n index,\n };\n along += (row ? page.width : page.height) + gap;\n return placed;\n });\n}\n\n/** The page under a world point, or `null` between and outside them. A point on an edge is on the page. */\nexport function pageAt(\n pages: readonly PlacedPage[],\n point: { readonly x: number; readonly y: number },\n): PlacedPage | null {\n return pageOfBounds(pages, { x: point.x, y: point.y, width: 0, height: 0 });\n}\n\nfunction overlap(page: PlacedPage, b: Bounds): number | null {\n const w = Math.min(page.x + page.width, b.x + b.width) - Math.max(page.x, b.x);\n const h = Math.min(page.y + page.height, b.y + b.height) - Math.max(page.y, b.y);\n return w < 0 || h < 0 ? null : w * h;\n}\n\n/**\n * The page a world-space box belongs to: the one it overlaps most, the earlier\n * of two it overlaps equally, and `null` when it touches none. This is the\n * rule that says which page an object is on.\n */\nexport function pageOfBounds(pages: readonly PlacedPage[], bounds: Bounds): PlacedPage | null {\n let best: PlacedPage | null = null;\n let most = -1;\n for (const page of pages) {\n const area = overlap(page, bounds);\n if (area !== null && area > most) {\n best = page;\n most = area;\n }\n }\n return best;\n}\n\n/**\n * The page `step` places along the page order from the one with id `current`:\n * the next slide is `1`, the one before is `-1`. `null` past either end, unless\n * `wrap`. With no current page in the list, a step forward starts at the first\n * page and a step back at the last.\n */\nexport function adjacentPage(\n pages: readonly PlacedPage[],\n current: string | null,\n step: number,\n options: { wrap?: boolean } = {},\n): PlacedPage | null {\n const n = pages.length;\n if (n === 0) return null;\n const at = pages.findIndex((p) => p.id === current);\n if (at < 0) return pages[step < 0 ? n - 1 : 0] ?? null;\n const to = at + step;\n return pages[options.wrap ? ((to % n) + n) % n : to] ?? null;\n}\n\n/** The box around every page, or `null` for a document with none. */\nexport function pagesBounds(pages: readonly PlacedPage[]): Bounds | null {\n if (pages.length === 0) return null;\n const x = Math.min(...pages.map((p) => p.x));\n const y = Math.min(...pages.map((p) => p.y));\n return {\n x,\n y,\n width: Math.max(...pages.map((p) => p.x + p.width)) - x,\n height: Math.max(...pages.map((p) => p.y + p.height)) - y,\n };\n}\n"],"mappings":";AA8BA,IAAMA,IAAQ;CAAE,OAAO;CAAG,QAAQ;CAAK,KAAK;AAAE;AAQ9C,SAAgBC,EAAY,GAAwB,IAA6B,CAAC,GAAiB;CACjG,IAAM,EAAE,eAAY,OAAO,SAAM,IAAI,WAAQ,SAAS,YAAS;EAAE,GAAG;EAAG,GAAG;CAAE,MAAMC,GAC5EC,IAAMC,MAAc,OACpBC,IAAS,KAAK,IAAI,GAAG,GAAGC,EAAM,KAAK,MAAOH,IAAMI,EAAE,SAASA,EAAE,KAAM,CAAC,GACpEC,oBAAO,IAAI,IAAY,GACzBC,IAAQ;CACZ,OAAOH,EAAM,KAAK,GAAM,MAAU;EAChC,IAAIE,EAAK,IAAIE,EAAK,EAAE,GAAG,MAAU,MAAM,uCAAuCA,EAAK,GAAG,EAAE;EACxF,EAAK,IAAIA,EAAK,EAAE;EAChB,IAAMC,KAAUN,KAAUF,IAAMO,EAAK,SAASA,EAAK,UAAUV,EAAMY,IAC7DC,IAAS;GACb,GAAGH;GACH,GAAGI,EAAO,KAAKX,IAAMM,IAAQE;GAC7B,GAAGG,EAAO,KAAKX,IAAMQ,IAASF;GAC9B;EACF;EAEA,OADA,MAAUN,IAAMO,EAAK,QAAQA,EAAK,UAA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C,CAAC,GACrC4B,IAAI,KAAK,IAAI,GAAG7B,EAAM,KAAK,MAAMC,EAAE,CAAC,CAAC;CAC3C,OAAO;EACL;EACA;EACA,OAAO,KAAK,IAAI,GAAGD,EAAM,KAAK,MAAMC,EAAE,IAAIA,EAAE,KAAK,CAAC,IAAI2B;EACtD,QAAQ,KAAK,IAAI,GAAG5B,EAAM,KAAK,MAAMC,EAAE,IAAIA,EAAE,MAAM,CAAC,IAAI4B;CAC1D;AACF"}
@@ -0,0 +1,27 @@
1
+ //#region src/core/pages/pagesLayer.ts
2
+ function e(e, t) {
3
+ let { fill: n, id: r = "pages", label: i = "Pages" } = t, a = typeof n == "function" ? n : () => n;
4
+ return {
5
+ id: r,
6
+ label: i,
7
+ deps: () => [e, n],
8
+ draw: () => e.map((e) => ({
9
+ kind: "path",
10
+ path: {
11
+ kind: "rect",
12
+ x: e.x,
13
+ y: e.y,
14
+ width: e.width,
15
+ height: e.height
16
+ },
17
+ fill: { paint: {
18
+ kind: "solid",
19
+ color: a(e)
20
+ } }
21
+ }))
22
+ };
23
+ }
24
+ //#endregion
25
+ export { e as pagesLayer };
26
+
27
+ //# sourceMappingURL=pagesLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagesLayer.js","names":["pagesLayer","options","colorOf","fill","pages","page"],"sources":["../../../src/core/pages/pagesLayer.ts"],"sourcesContent":["import type { RenderLayer } from '../layers/render';\nimport type { PlacedPage } from './pages';\n\n/** Options for {@link pagesLayer}. */\nexport interface PagesLayerOptions {\n /** Each page's color: one for all, or one per page. */\n fill: string | ((page: PlacedPage) => string);\n /** Default `'pages'`. */\n id?: string;\n /** Default `'Pages'`. */\n label?: string;\n}\n\n/**\n * The sheets themselves: a world-space layer that paints each placed page as a\n * filled rect, to sit under the scene. Build it again when the pages or the\n * fill change; its commands are cached on both.\n */\nexport function pagesLayer(pages: readonly PlacedPage[], options: PagesLayerOptions): RenderLayer<unknown> {\n const { fill, id = 'pages', label = 'Pages' } = options;\n const colorOf = typeof fill === 'function' ? fill : () => fill;\n return {\n id,\n label,\n deps: () => [pages, fill],\n draw: () =>\n pages.map((page) => ({\n kind: 'path' as const,\n path: { kind: 'rect' as const, x: page.x, y: page.y, width: page.width, height: page.height },\n fill: { paint: { kind: 'solid' as const, color: colorOf(page) } },\n })),\n };\n}\n"],"mappings":";AAkBA,SAAgBA,EAAW,GAA8B,GAAkD;CACzG,IAAM,EAAE,SAAM,QAAK,SAAS,WAAQ,YAAYC,GAC1CC,IAAU,OAAOC,KAAS,aAAaA,UAAaA;CAC1D,OAAO;EACL;EACA;EACA,YAAY,CAACC,GAAOD,CAAI;EACxB,YACEC,EAAM,KAAK,OAAU;GACnB,MAAM;GACN,MAAM;IAAE,MAAM;IAAiB,GAAGC,EAAK;IAAG,GAAGA,EAAK;IAAG,OAAOA,EAAK;IAAO,QAAQA,EAAK;GAAO;GAC5F,MAAM,EAAE,OAAO;IAAE,MAAM;IAAkB,OAAOH,EAAQG,CAAI;GAAE,EAAE;EAClE,EAAE;CACN;AACF"}
@@ -591,7 +591,7 @@ const NAMED_COLORS = (() => {
591
591
  return out;
592
592
  })();
593
593
  //#endregion
594
- //#region ../geom/src/mat3.ts
594
+ //#region ../geom/src/affine.ts
595
595
  /**
596
596
  * 2D affine transforms in canvas/DOMMatrix order: [a, b, c, d, e, f].
597
597
  * x' = a·x + c·y + e
@@ -726,7 +726,7 @@ function minScaleOf(m) {
726
726
  }
727
727
  /** The renderer's 3x3 matrix operations, as one namespace. These work on the
728
728
  * 9-element form the GL uniform upload wants — distinct from the 6-element
729
- * affine `Mat3`, though the logical element order is the same. */
729
+ * `Affine`, though the logical element order is the same. */
730
730
  const mat3 = {
731
731
  identity,
732
732
  toAffine,