@weasel-js/core 1.9.3 → 1.10.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 (1139) hide show
  1. package/CHANGELOG.md +1106 -0
  2. package/README.md +7 -5
  3. package/dist/WeaselProvider.js +5 -7
  4. package/dist/WeaselProvider.js.map +1 -1
  5. package/dist/affordances/composeAffordanceLayer.js +91 -93
  6. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  7. package/dist/affordances/cornerResize.js +27 -18
  8. package/dist/affordances/cornerResize.js.map +1 -1
  9. package/dist/affordances/hitAffordanceRegions.js +65 -104
  10. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  11. package/dist/affordances/pathAnchors.js.map +1 -1
  12. package/dist/affordances/rotationHandle.js +22 -21
  13. package/dist/affordances/rotationHandle.js.map +1 -1
  14. package/dist/animation/behaviors/coast.js +21 -0
  15. package/dist/animation/behaviors/coast.js.map +1 -0
  16. package/dist/animation/behaviors/coastByWrite.js +107 -0
  17. package/dist/animation/behaviors/coastByWrite.js.map +1 -0
  18. package/dist/animation/behaviors/coastOnTargets.js +94 -0
  19. package/dist/animation/behaviors/coastOnTargets.js.map +1 -0
  20. package/dist/animation/behaviors/momentum.js +38 -88
  21. package/dist/animation/behaviors/momentum.js.map +1 -1
  22. package/dist/animation/clipTargets.js +12 -0
  23. package/dist/animation/clipTargets.js.map +1 -0
  24. package/dist/animation/index.js +15 -20
  25. package/dist/animation/poseHelpers.js +112 -33
  26. package/dist/animation/poseHelpers.js.map +1 -1
  27. package/dist/animation/poseTarget.js +115 -0
  28. package/dist/animation/poseTarget.js.map +1 -0
  29. package/dist/animation/reflow.js +113 -83
  30. package/dist/animation/reflow.js.map +1 -1
  31. package/dist/animation/rewind.js +66 -0
  32. package/dist/animation/rewind.js.map +1 -0
  33. package/dist/animation/rig/bindRig.js +85 -53
  34. package/dist/animation/rig/bindRig.js.map +1 -1
  35. package/dist/animation/rig/rigNode.js +93 -0
  36. package/dist/animation/rig/rigNode.js.map +1 -0
  37. package/dist/animation/rig/rigSeat.js +26 -0
  38. package/dist/animation/rig/rigSeat.js.map +1 -0
  39. package/dist/animation/rig/skinBinding.js +56 -0
  40. package/dist/animation/rig/skinBinding.js.map +1 -0
  41. package/dist/animation/rig/useRig.js +31 -16
  42. package/dist/animation/rig/useRig.js.map +1 -1
  43. package/dist/animation/wrappers/animateLifecycle.js +32 -24
  44. package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
  45. package/dist/animation/wrappers/animateOnSetPose.js +31 -29
  46. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
  47. package/dist/animation/wrappers/instantPose.js +13 -0
  48. package/dist/animation/wrappers/instantPose.js.map +1 -0
  49. package/dist/animation/writtenPoseTarget.js +33 -0
  50. package/dist/animation/writtenPoseTarget.js.map +1 -0
  51. package/dist/{autoPoseDescriptor-vCdt55xm.d.ts → autoPoseDescriptor-DHg5KqaJ.d.ts} +1 -1
  52. package/dist/barrel/canvas.js +31 -0
  53. package/dist/barrel/chrome.js +16 -0
  54. package/dist/barrel/input.js +18 -0
  55. package/dist/barrel/interactions.js +38 -0
  56. package/dist/barrel/paint.js +11 -0
  57. package/dist/barrel/paths.js +12 -0
  58. package/dist/barrel/renderer.js +14 -0
  59. package/dist/barrel/routing.js +57 -0
  60. package/dist/barrel/scene.js +37 -0
  61. package/dist/barrel/text.js +9 -0
  62. package/dist/barrel/viewport.js +42 -0
  63. package/dist/canvas/Canvas.js +280 -559
  64. package/dist/canvas/Canvas.js.map +1 -1
  65. package/dist/canvas/CanvasView.js +147 -167
  66. package/dist/canvas/CanvasView.js.map +1 -1
  67. package/dist/canvas/CursorCoordsHud.js +53 -49
  68. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  69. package/dist/canvas/DrawCanvas.js +40 -51
  70. package/dist/canvas/DrawCanvas.js.map +1 -1
  71. package/dist/canvas/ModalityHud.js.map +1 -1
  72. package/dist/canvas/NodeShape.js +55 -374
  73. package/dist/canvas/NodeShape.js.map +1 -1
  74. package/dist/canvas/PickHud.js +50 -47
  75. package/dist/canvas/PickHud.js.map +1 -1
  76. package/dist/canvas/SceneCanvas/DevHuds.js +40 -0
  77. package/dist/canvas/SceneCanvas/DevHuds.js.map +1 -0
  78. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +126 -0
  79. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +27 -31
  81. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
  82. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +64 -0
  83. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
  84. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
  85. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
  86. package/dist/canvas/SceneCanvas/coordTrace.js +46 -0
  87. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
  88. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +138 -85
  89. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  90. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
  91. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
  92. package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -1
  93. package/dist/canvas/SceneCanvas/features.js +74 -43
  94. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  95. package/dist/canvas/SceneCanvas/isDev.js +12 -0
  96. package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
  97. package/dist/canvas/SceneCanvas/poseGeometry.js +31 -34
  98. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  99. package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
  100. package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
  101. package/dist/canvas/SceneCanvas/props.js +39 -0
  102. package/dist/canvas/SceneCanvas/props.js.map +1 -0
  103. package/dist/canvas/SceneCanvas/toolRegistry.js +23 -0
  104. package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -0
  105. package/dist/canvas/SceneCanvas/useActionsPropResolver.js +6 -1
  106. package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
  107. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
  108. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  109. package/dist/canvas/SceneCanvas/useBuiltinTools.js +21 -0
  110. package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -0
  111. package/dist/canvas/SceneCanvas/useCanvasCamera.js +38 -0
  112. package/dist/canvas/SceneCanvas/useCanvasCamera.js.map +1 -0
  113. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js +20 -0
  114. package/dist/canvas/SceneCanvas/useCanvasDispatcher.js.map +1 -0
  115. package/dist/canvas/SceneCanvas/useCanvasSelection.js +16 -0
  116. package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -0
  117. package/dist/canvas/SceneCanvas/useCanvasTools.js +67 -0
  118. package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -0
  119. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +29 -29
  120. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  121. package/dist/canvas/SceneCanvas/useHeldModifiers.js +20 -0
  122. package/dist/canvas/SceneCanvas/useHeldModifiers.js.map +1 -0
  123. package/dist/canvas/SceneCanvas/useNodeAtPoint.js +26 -0
  124. package/dist/canvas/SceneCanvas/useNodeAtPoint.js.map +1 -0
  125. package/dist/canvas/SceneCanvas/useNodeKinds.js +26 -0
  126. package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -0
  127. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +48 -48
  128. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  129. package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +47 -0
  130. package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -0
  131. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +66 -0
  132. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -0
  133. package/dist/canvas/SceneCanvas/useSceneChrome.js +59 -0
  134. package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -0
  135. package/dist/canvas/SceneCanvas/useSceneRedrawSources.js +23 -0
  136. package/dist/canvas/SceneCanvas/useSceneRedrawSources.js.map +1 -0
  137. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +74 -78
  138. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  139. package/dist/canvas/SceneCanvas/useSceneSlotLayers.js +37 -0
  140. package/dist/canvas/SceneCanvas/useSceneSlotLayers.js.map +1 -0
  141. package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js +38 -0
  142. package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js.map +1 -0
  143. package/dist/canvas/SceneCanvas/useViewLayerGate.js +20 -0
  144. package/dist/canvas/SceneCanvas/useViewLayerGate.js.map +1 -0
  145. package/dist/canvas/SceneCanvas/useViewportActions.js +9 -1
  146. package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -1
  147. package/dist/canvas/SceneCanvas/worldPointAt.js +9 -0
  148. package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -0
  149. package/dist/canvas/SceneCanvas.js +311 -969
  150. package/dist/canvas/SceneCanvas.js.map +1 -1
  151. package/dist/canvas/SceneViewCanvas.js +42 -46
  152. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  153. package/dist/canvas/adapterDerivedPath.js +26 -0
  154. package/dist/canvas/adapterDerivedPath.js.map +1 -0
  155. package/dist/canvas/affordanceAt.js +11 -1
  156. package/dist/canvas/affordanceAt.js.map +1 -1
  157. package/dist/canvas/buildSceneLayer.js +111 -0
  158. package/dist/canvas/buildSceneLayer.js.map +1 -0
  159. package/dist/canvas/buildSceneTree.js +16 -19
  160. package/dist/canvas/buildSceneTree.js.map +1 -1
  161. package/dist/canvas/canvasRenderer.js +67 -55
  162. package/dist/canvas/canvasRenderer.js.map +1 -1
  163. package/dist/canvas/colorOverrides.js.map +1 -1
  164. package/dist/canvas/defaultDrawOne.js +12 -12
  165. package/dist/canvas/defaultDrawOne.js.map +1 -1
  166. package/dist/canvas/deps/areaSelect.js +4 -4
  167. package/dist/canvas/deps/areaSelect.js.map +1 -1
  168. package/dist/canvas/deps/changes.js +13 -0
  169. package/dist/canvas/deps/changes.js.map +1 -0
  170. package/dist/canvas/deps/debug.js.map +1 -1
  171. package/dist/canvas/deps/editAnchors.js +38 -57
  172. package/dist/canvas/deps/editAnchors.js.map +1 -1
  173. package/dist/canvas/deps/geometryProjection.js.map +1 -1
  174. package/dist/canvas/deps/hitTestArea.js +31 -26
  175. package/dist/canvas/deps/hitTestArea.js.map +1 -1
  176. package/dist/canvas/deps/insert.js +130 -91
  177. package/dist/canvas/deps/insert.js.map +1 -1
  178. package/dist/canvas/deps/lassoSelect.js +5 -5
  179. package/dist/canvas/deps/lassoSelect.js.map +1 -1
  180. package/dist/canvas/deps/poseDescriptor.js +1 -1
  181. package/dist/canvas/deps/poseDescriptor.js.map +1 -1
  182. package/dist/canvas/deps/resizePolicy.js.map +1 -1
  183. package/dist/canvas/deps/slice.js +26 -26
  184. package/dist/canvas/deps/slice.js.map +1 -1
  185. package/dist/canvas/deps/textEdit.js +6 -5
  186. package/dist/canvas/deps/textEdit.js.map +1 -1
  187. package/dist/canvas/deps/view.js.map +1 -1
  188. package/dist/canvas/derivedPath.js +47 -22
  189. package/dist/canvas/derivedPath.js.map +1 -1
  190. package/dist/canvas/drawEnvelope.js +8 -4
  191. package/dist/canvas/drawEnvelope.js.map +1 -1
  192. package/dist/canvas/getNodeAtPoint.js +4 -8
  193. package/dist/canvas/getNodeAtPoint.js.map +1 -1
  194. package/dist/canvas/hud.module.js +1 -1
  195. package/dist/canvas/hud.module.js.map +1 -1
  196. package/dist/canvas/insertPreviewExtent.js.map +1 -1
  197. package/dist/canvas/kitRequirements.js +2 -2
  198. package/dist/canvas/kitRequirements.js.map +1 -1
  199. package/dist/canvas/layerOrder.js +13 -6
  200. package/dist/canvas/layerOrder.js.map +1 -1
  201. package/dist/canvas/layerSlots.js +6 -1
  202. package/dist/canvas/layerSlots.js.map +1 -1
  203. package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
  204. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
  205. package/dist/canvas/nodeShapes/imagePainter.js +87 -0
  206. package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
  207. package/dist/canvas/nodeShapes/memo.js +9 -0
  208. package/dist/canvas/nodeShapes/memo.js.map +1 -0
  209. package/dist/canvas/nodeShapes/nodePaint.js +68 -0
  210. package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
  211. package/dist/canvas/nodeShapes/pathPainter.js +39 -0
  212. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
  213. package/dist/canvas/nodeShapes/poseBox.js +20 -0
  214. package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
  215. package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
  216. package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
  217. package/dist/canvas/nodeShapes/shapePainter.js +72 -0
  218. package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
  219. package/dist/canvas/nodeShapes/textPainter.js +55 -0
  220. package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
  221. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  222. package/dist/canvas/paintCull.js +11 -14
  223. package/dist/canvas/paintCull.js.map +1 -1
  224. package/dist/{features/cursor → canvas}/paintedCursorLayer.js +2 -2
  225. package/dist/canvas/paintedCursorLayer.js.map +1 -0
  226. package/dist/canvas/pickWalk.js +59 -68
  227. package/dist/canvas/pickWalk.js.map +1 -1
  228. package/dist/canvas/planeClips.js +18 -19
  229. package/dist/canvas/planeClips.js.map +1 -1
  230. package/dist/canvas/poseCascade.js +41 -0
  231. package/dist/canvas/poseCascade.js.map +1 -0
  232. package/dist/canvas/poseRotation.js +9 -23
  233. package/dist/canvas/poseRotation.js.map +1 -1
  234. package/dist/canvas/rasterReadback.js +22 -0
  235. package/dist/canvas/rasterReadback.js.map +1 -0
  236. package/dist/canvas/renderDebugSnapshot.js +11 -11
  237. package/dist/canvas/renderDebugSnapshot.js.map +1 -1
  238. package/dist/canvas/renderNeeds.js +3 -3
  239. package/dist/canvas/renderNeeds.js.map +1 -1
  240. package/dist/canvas/renderSceneToPixels.js +64 -81
  241. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  242. package/dist/canvas/sceneAdapter.js +68 -214
  243. package/dist/canvas/sceneAdapter.js.map +1 -1
  244. package/dist/canvas/sceneClipboard.js +112 -0
  245. package/dist/canvas/sceneClipboard.js.map +1 -0
  246. package/dist/canvas/sceneLayerPaint.js +4 -4
  247. package/dist/canvas/sceneLayerPaint.js.map +1 -1
  248. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  249. package/dist/canvas/sceneViewRender.js +39 -39
  250. package/dist/canvas/sceneViewRender.js.map +1 -1
  251. package/dist/canvas/slopsDebugLayer.js +4 -4
  252. package/dist/canvas/slopsDebugLayer.js.map +1 -1
  253. package/dist/canvas/surface.module.js +6 -0
  254. package/dist/canvas/surface.module.js.map +1 -0
  255. package/dist/canvas/surfaceBox.js +16 -0
  256. package/dist/canvas/surfaceBox.js.map +1 -0
  257. package/dist/canvas/useCanvasRenderer.js +26 -6
  258. package/dist/canvas/useCanvasRenderer.js.map +1 -1
  259. package/dist/canvas/useCanvasSurface.js +31 -0
  260. package/dist/canvas/useCanvasSurface.js.map +1 -0
  261. package/dist/canvas/useCanvasView.js +67 -0
  262. package/dist/canvas/useCanvasView.js.map +1 -0
  263. package/dist/canvas/useFrameLoop.js +39 -31
  264. package/dist/canvas/useFrameLoop.js.map +1 -1
  265. package/dist/canvas/useHostAnchor.js +35 -33
  266. package/dist/canvas/useHostAnchor.js.map +1 -1
  267. package/dist/canvas/useLateContentRedraw.js +8 -8
  268. package/dist/canvas/useLateContentRedraw.js.map +1 -1
  269. package/dist/canvas/useSceneLayerList.js +11 -0
  270. package/dist/canvas/useSceneLayerList.js.map +1 -0
  271. package/dist/canvas/useSurfaceInput.js +42 -0
  272. package/dist/canvas/useSurfaceInput.js.map +1 -0
  273. package/dist/canvas/useToolCursor.js +29 -0
  274. package/dist/canvas/useToolCursor.js.map +1 -0
  275. package/dist/canvas/useViewHelpers.js +46 -85
  276. package/dist/canvas/useViewHelpers.js.map +1 -1
  277. package/dist/canvas/viewInputs.js.map +1 -1
  278. package/dist/canvas/viewRegistry.js +25 -27
  279. package/dist/canvas/viewRegistry.js.map +1 -1
  280. package/dist/canvas/watchElementMove.js +43 -0
  281. package/dist/canvas/watchElementMove.js.map +1 -0
  282. package/dist/canvas/wrapNodeOutput.js.map +1 -1
  283. package/dist/clipboard.d.ts +16 -19
  284. package/dist/{types-B_9g6hMM.d.ts → clone-2a5hVbBd.d.ts} +123 -74
  285. package/dist/clone.d.ts +4 -7
  286. package/dist/clone.js +0 -2
  287. package/dist/core/device/index.js +5 -4
  288. package/dist/core/device/targets.js.map +1 -1
  289. package/dist/core/device/useDeviceProfile.js +38 -44
  290. package/dist/core/device/useDeviceProfile.js.map +1 -1
  291. package/dist/core/device/watchDevicePixelRatio.js +17 -0
  292. package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
  293. package/dist/{interactions/actions/resize → core/geometry}/autoPoseDescriptor.js +8 -7
  294. package/dist/core/geometry/autoPoseDescriptor.js.map +1 -0
  295. package/dist/core/geometry/pathPoseDescriptor.js +88 -0
  296. package/dist/core/geometry/pathPoseDescriptor.js.map +1 -0
  297. package/dist/core/geometry/poseDescriptor.js +68 -19
  298. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  299. package/dist/core/geometry/regionHit.js +31 -34
  300. package/dist/core/geometry/regionHit.js.map +1 -1
  301. package/dist/core/geometry/targetFrame.js +94 -0
  302. package/dist/core/geometry/targetFrame.js.map +1 -0
  303. package/dist/core/geometry/unionBounds.js +30 -29
  304. package/dist/core/geometry/unionBounds.js.map +1 -1
  305. package/dist/core/isPlainObject.js +2 -11
  306. package/dist/core/layers/backgroundFill.js +31 -0
  307. package/dist/core/layers/backgroundFill.js.map +1 -0
  308. package/dist/{features/groups → core/layers}/children.js +1 -1
  309. package/dist/core/layers/children.js.map +1 -0
  310. package/dist/core/layers/gateLayer.js +13 -0
  311. package/dist/core/layers/gateLayer.js.map +1 -0
  312. package/dist/core/layers/layerGroup.js +40 -0
  313. package/dist/core/layers/layerGroup.js.map +1 -0
  314. package/dist/core/layers/render.js +50 -76
  315. package/dist/core/layers/render.js.map +1 -1
  316. package/dist/core/ops/arrange.js +1 -0
  317. package/dist/core/ops/arrange.js.map +1 -1
  318. package/dist/core/ops/create.js +10 -5
  319. package/dist/core/ops/create.js.map +1 -1
  320. package/dist/core/ops/createHistory.js +9 -9
  321. package/dist/core/ops/createHistory.js.map +1 -1
  322. package/dist/core/ops/delete.js +12 -24
  323. package/dist/core/ops/delete.js.map +1 -1
  324. package/dist/core/ops/reorder/index.js +43 -40
  325. package/dist/core/ops/reorder/index.js.map +1 -1
  326. package/dist/core/ops/reorder/setChildOrder.js +34 -0
  327. package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
  328. package/dist/core/paint/meshKind.js +16 -0
  329. package/dist/core/paint/meshKind.js.map +1 -0
  330. package/dist/{features/meshPaint/lazyKind.js → core/paint/meshKindLazy.js} +282 -105
  331. package/dist/core/paint/meshKindLazy.js.map +1 -0
  332. package/dist/core/paint/paintKindEntry.js +8 -0
  333. package/dist/core/paint/paintKindEntry.js.map +1 -0
  334. package/dist/core/paint/paintKinds.js +144 -0
  335. package/dist/core/paint/paintKinds.js.map +1 -0
  336. package/dist/core/paint/registerMesh.js +7 -0
  337. package/dist/core/paint/registerMesh.js.map +1 -0
  338. package/dist/core/scene/NodeProperties.js.map +1 -1
  339. package/dist/core/scene/NodeRouting.js.map +1 -1
  340. package/dist/core/scene/appliedLog.js +37 -0
  341. package/dist/core/scene/appliedLog.js.map +1 -0
  342. package/dist/core/scene/arrivalWindow.js +102 -0
  343. package/dist/core/scene/arrivalWindow.js.map +1 -0
  344. package/dist/core/scene/boundOps.js +40 -0
  345. package/dist/core/scene/boundOps.js.map +1 -0
  346. package/dist/core/scene/composeFrame.js +9 -6
  347. package/dist/core/scene/composeFrame.js.map +1 -1
  348. package/dist/{features/groups → core/scene}/composePose.js +18 -18
  349. package/dist/core/scene/composePose.js.map +1 -0
  350. package/dist/core/scene/depMemo.js +31 -6
  351. package/dist/core/scene/depMemo.js.map +1 -1
  352. package/dist/core/scene/derivedPath.js +19 -20
  353. package/dist/core/scene/derivedPath.js.map +1 -1
  354. package/dist/core/scene/editMode.js +26 -0
  355. package/dist/core/scene/editMode.js.map +1 -0
  356. package/dist/core/scene/effectivePose.js +38 -39
  357. package/dist/core/scene/effectivePose.js.map +1 -1
  358. package/dist/core/scene/fieldEdits.js +98 -0
  359. package/dist/core/scene/fieldEdits.js.map +1 -0
  360. package/dist/core/scene/historyFacade.js +130 -0
  361. package/dist/core/scene/historyFacade.js.map +1 -0
  362. package/dist/core/scene/historyForm.js +6 -0
  363. package/dist/core/scene/historyForm.js.map +1 -0
  364. package/dist/core/scene/kitOps.js +185 -0
  365. package/dist/core/scene/kitOps.js.map +1 -0
  366. package/dist/core/scene/kitRegistry.js.map +1 -1
  367. package/dist/core/scene/layerStack.js +131 -0
  368. package/dist/core/scene/layerStack.js.map +1 -0
  369. package/dist/core/scene/layoutPass.js +58 -59
  370. package/dist/core/scene/layoutPass.js.map +1 -1
  371. package/dist/core/scene/lockGuard.js +37 -0
  372. package/dist/core/scene/lockGuard.js.map +1 -0
  373. package/dist/{features/groups → core/scene}/nestedHit.js +3 -3
  374. package/dist/core/scene/nestedHit.js.map +1 -0
  375. package/dist/core/scene/nodeFnFields.js +10 -11
  376. package/dist/core/scene/nodeFnFields.js.map +1 -1
  377. package/dist/core/scene/nodeMemo.js +45 -19
  378. package/dist/core/scene/nodeMemo.js.map +1 -1
  379. package/dist/core/scene/nodeStore.js +127 -0
  380. package/dist/core/scene/nodeStore.js.map +1 -0
  381. package/dist/core/scene/notifier.js +37 -0
  382. package/dist/core/scene/notifier.js.map +1 -0
  383. package/dist/core/scene/opTable.js +50 -0
  384. package/dist/core/scene/opTable.js.map +1 -0
  385. package/dist/core/scene/outerOps.js +66 -0
  386. package/dist/core/scene/outerOps.js.map +1 -0
  387. package/dist/core/scene/poseFeed.js +38 -38
  388. package/dist/core/scene/poseFeed.js.map +1 -1
  389. package/dist/core/scene/poseHold.js +39 -0
  390. package/dist/core/scene/poseHold.js.map +1 -0
  391. package/dist/core/scene/poseOverrides.js +44 -40
  392. package/dist/core/scene/poseOverrides.js.map +1 -1
  393. package/dist/core/scene/poseSnapshot.js.map +1 -1
  394. package/dist/core/scene/reconcileSpecs.js +3 -2
  395. package/dist/core/scene/reconcileSpecs.js.map +1 -1
  396. package/dist/core/scene/recorder.js +86 -0
  397. package/dist/core/scene/recorder.js.map +1 -0
  398. package/dist/core/scene/renderOrder.js +84 -0
  399. package/dist/core/scene/renderOrder.js.map +1 -0
  400. package/dist/core/scene/scene.js +80 -1266
  401. package/dist/core/scene/scene.js.map +1 -1
  402. package/dist/core/scene/sceneEdits.js +58 -0
  403. package/dist/core/scene/sceneEdits.js.map +1 -0
  404. package/dist/core/scene/sceneMutators.js +49 -0
  405. package/dist/core/scene/sceneMutators.js.map +1 -0
  406. package/dist/core/scene/scenePoseAdapter.js +16 -0
  407. package/dist/core/scene/scenePoseAdapter.js.map +1 -0
  408. package/dist/core/scene/sceneRecording.js +90 -0
  409. package/dist/core/scene/sceneRecording.js.map +1 -0
  410. package/dist/core/scene/sceneSelection.js +28 -0
  411. package/dist/core/scene/sceneSelection.js.map +1 -0
  412. package/dist/core/scene/sceneState.js +49 -0
  413. package/dist/core/scene/sceneState.js.map +1 -0
  414. package/dist/core/scene/serialization.js +71 -0
  415. package/dist/core/scene/serialization.js.map +1 -0
  416. package/dist/core/scene/staleReplay.js +51 -0
  417. package/dist/core/scene/staleReplay.js.map +1 -0
  418. package/dist/core/scene/statedFields.js +9 -0
  419. package/dist/core/scene/statedFields.js.map +1 -0
  420. package/dist/core/scene/treeEdits.js +127 -0
  421. package/dist/core/scene/treeEdits.js.map +1 -0
  422. package/dist/core/scene/treeOrder.js +13 -0
  423. package/dist/core/scene/treeOrder.js.map +1 -0
  424. package/dist/core/scene/treeReads.js +26 -0
  425. package/dist/core/scene/treeReads.js.map +1 -0
  426. package/dist/core/scene/types.js.map +1 -1
  427. package/dist/{features/groups → core/scene}/unionOfChildren.js +3 -3
  428. package/dist/core/scene/unionOfChildren.js.map +1 -0
  429. package/dist/core/scene/unitScopes.js +13 -0
  430. package/dist/core/scene/unitScopes.js.map +1 -0
  431. package/dist/core/scene/useScene.js.map +1 -1
  432. package/dist/core/selection/readOnlySelection.js +32 -0
  433. package/dist/core/selection/readOnlySelection.js.map +1 -0
  434. package/dist/core/selection/usePublishSceneSelection.js +26 -0
  435. package/dist/core/selection/usePublishSceneSelection.js.map +1 -0
  436. package/dist/core/selection/useSelection.js +34 -25
  437. package/dist/core/selection/useSelection.js.map +1 -1
  438. package/dist/core/shapeKinds.js.map +1 -1
  439. package/dist/core/stylus/stylus.js.map +1 -1
  440. package/dist/core/stylus/usePointerStylus.js.map +1 -1
  441. package/dist/core/usePaintKinds.js +1 -1
  442. package/dist/core/usePaintKinds.js.map +1 -1
  443. package/dist/core/viewport/clientToWorld.js.map +1 -1
  444. package/dist/core/viewport/fitViewToBounds.js.map +1 -1
  445. package/dist/core/viewport/parallax.js.map +1 -1
  446. package/dist/core/viewport/screenSlop.js +11 -11
  447. package/dist/core/viewport/screenSlop.js.map +1 -1
  448. package/dist/core/viewport/useCanvasSize.js.map +1 -1
  449. package/dist/core/viewport/useDecayLoop.js +8 -8
  450. package/dist/core/viewport/useDecayLoop.js.map +1 -1
  451. package/dist/core/viewport/useNodeOverlayFrame.js +84 -0
  452. package/dist/core/viewport/useNodeOverlayFrame.js.map +1 -0
  453. package/dist/core/viewport/useViewAnimation.js +102 -43
  454. package/dist/core/viewport/useViewAnimation.js.map +1 -1
  455. package/dist/core/viewport/view.js +9 -9
  456. package/dist/core/viewport/view.js.map +1 -1
  457. package/dist/core/viewport/wheelHandler.js.map +1 -1
  458. package/dist/core/viewport/zoomBounds.js +10 -8
  459. package/dist/core/viewport/zoomBounds.js.map +1 -1
  460. package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-BEshc4z3.d.ts} +11 -24
  461. package/dist/debug/createDebugOverlayLayer.js +97 -97
  462. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  463. package/dist/debug/createDebugSink.js.map +1 -1
  464. package/dist/debug/flag.js +2 -41
  465. package/dist/debug/frameStats.js.map +1 -1
  466. package/dist/debug/useDebugSink.js +52 -0
  467. package/dist/debug/useDebugSink.js.map +1 -0
  468. package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -1
  469. package/dist/features/chrome-caps/conditions.js.map +1 -1
  470. package/dist/features/chrome-caps/defaults.js.map +1 -1
  471. package/dist/features/chrome-caps/resolve.js.map +1 -1
  472. package/dist/features/chrome-caps/useChromeCaps.js +54 -0
  473. package/dist/features/chrome-caps/useChromeCaps.js.map +1 -0
  474. package/dist/features/chrome-caps/useHoverTracking.js +22 -17
  475. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  476. package/dist/features/ingestion/contentHandlers.js +28 -19
  477. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  478. package/dist/features/ingestion/imageHandler.js +21 -24
  479. package/dist/features/ingestion/imageHandler.js.map +1 -1
  480. package/dist/features/ingestion/openFilePicker.js.map +1 -1
  481. package/dist/features/ingestion/placement.js +16 -0
  482. package/dist/features/ingestion/placement.js.map +1 -0
  483. package/dist/features/ingestion/registerKitHandlers.js +7 -7
  484. package/dist/features/ingestion/svgHandler.js +5 -0
  485. package/dist/features/ingestion/svgHandler.js.map +1 -1
  486. package/dist/features/ingestion/textHandler.js +28 -0
  487. package/dist/features/ingestion/textHandler.js.map +1 -0
  488. package/dist/features/ingestion/useCanvasIngestion.js +48 -0
  489. package/dist/features/ingestion/useCanvasIngestion.js.map +1 -0
  490. package/dist/features/ingestion/weaselJsonHandler.js +22 -14
  491. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
  492. package/dist/features/longPress/longPressFeedback.js.map +1 -1
  493. package/dist/features/modes/modeLayers.js +7 -7
  494. package/dist/features/modes/modeLayers.js.map +1 -1
  495. package/dist/features/paths/editablePath.js +47 -0
  496. package/dist/features/paths/editablePath.js.map +1 -0
  497. package/dist/features/paths/index.js +9 -14
  498. package/dist/features/paths/pathEditState.js +41 -0
  499. package/dist/features/paths/pathEditState.js.map +1 -0
  500. package/dist/features/paths/pathEditingOverlayLayer.js +36 -38
  501. package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -1
  502. package/dist/features/paths/pathLayer.js +3 -2
  503. package/dist/features/paths/pathLayer.js.map +1 -1
  504. package/dist/features/paths/penPreviewLayer.js +86 -88
  505. package/dist/features/paths/penPreviewLayer.js.map +1 -1
  506. package/dist/features/paths/usePathEdit.js +34 -0
  507. package/dist/features/paths/usePathEdit.js.map +1 -0
  508. package/dist/features/poseRun/usePoseRun.js +44 -52
  509. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  510. package/dist/features/selection/overlay.js +171 -179
  511. package/dist/features/selection/overlay.js.map +1 -1
  512. package/dist/features/text/index.js +6 -0
  513. package/dist/features/text/textLayer.js +1 -1
  514. package/dist/features/text/textLayer.js.map +1 -1
  515. package/dist/features/text/useSceneTextEdit.js +100 -93
  516. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  517. package/dist/features/viewports/viewportLayer.js +25 -36
  518. package/dist/features/viewports/viewportLayer.js.map +1 -1
  519. package/dist/index.d.ts +8473 -9141
  520. package/dist/index.js +269 -307
  521. package/dist/input/keyState.js +38 -39
  522. package/dist/input/keyState.js.map +1 -1
  523. package/dist/input/useKeyModifiers.js +11 -0
  524. package/dist/input/useKeyModifiers.js.map +1 -0
  525. package/dist/interactions/actions/actionShortcuts.js.map +1 -1
  526. package/dist/interactions/actions/{defaults/align.js → align/action.js} +18 -20
  527. package/dist/interactions/actions/align/action.js.map +1 -0
  528. package/dist/interactions/actions/align/align.js +20 -20
  529. package/dist/interactions/actions/align/align.js.map +1 -1
  530. package/dist/interactions/actions/booleans/action.js +65 -0
  531. package/dist/interactions/actions/booleans/action.js.map +1 -0
  532. package/dist/interactions/actions/booleans/booleans.js +69 -78
  533. package/dist/interactions/actions/booleans/booleans.js.map +1 -1
  534. package/dist/interactions/actions/booleans/operands.js +40 -0
  535. package/dist/interactions/actions/booleans/operands.js.map +1 -0
  536. package/dist/interactions/actions/booleans/pieces.js +45 -0
  537. package/dist/interactions/actions/booleans/pieces.js.map +1 -0
  538. package/dist/interactions/actions/booleans/placement.js +24 -0
  539. package/dist/interactions/actions/booleans/placement.js.map +1 -0
  540. package/dist/interactions/actions/booleans/useBooleans.js +11 -9
  541. package/dist/interactions/actions/booleans/useBooleans.js.map +1 -1
  542. package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -1
  543. package/dist/interactions/actions/{defaults/clipboard.js → clipboard/action.js} +31 -15
  544. package/dist/interactions/actions/clipboard/action.js.map +1 -0
  545. package/dist/interactions/actions/clipboard/clipboardOps.js +44 -42
  546. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
  547. package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
  548. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
  549. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
  550. package/dist/interactions/actions/clone/action.js +98 -0
  551. package/dist/interactions/actions/clone/action.js.map +1 -0
  552. package/dist/interactions/actions/clone/behaviors.js +52 -0
  553. package/dist/interactions/actions/clone/behaviors.js.map +1 -0
  554. package/dist/interactions/actions/defaultCommitAdapter.js +7 -32
  555. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
  556. package/dist/interactions/actions/defaults/anchorEditing.js +60 -84
  557. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  558. package/dist/interactions/actions/defaults/areaSelect.js +35 -38
  559. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  560. package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
  561. package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
  562. package/dist/interactions/actions/defaults/copySubtree.js +40 -0
  563. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
  564. package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
  565. package/dist/interactions/actions/defaults/delete.js.map +1 -1
  566. package/dist/interactions/actions/defaults/duplicate.js +13 -53
  567. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  568. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  569. package/dist/interactions/actions/defaults/group.js +40 -50
  570. package/dist/interactions/actions/defaults/group.js.map +1 -1
  571. package/dist/interactions/actions/defaults/icons/booleanIcons.js +24 -1
  572. package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -1
  573. package/dist/interactions/actions/defaults/icons/outlineIcons.js +39 -1
  574. package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -1
  575. package/dist/interactions/actions/defaults/ingest.js +44 -38
  576. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  577. package/dist/interactions/actions/defaults/insertPathAnchor.js +11 -12
  578. package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
  579. package/dist/interactions/actions/defaults/nudge.js +40 -69
  580. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  581. package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
  582. package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
  583. package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
  584. package/dist/interactions/actions/defaults/reorder.js +2 -0
  585. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  586. package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
  587. package/dist/interactions/actions/defaults/setFill.js +14 -8
  588. package/dist/interactions/actions/defaults/setFill.js.map +1 -1
  589. package/dist/interactions/actions/defaults/setFillOpacity.js +7 -4
  590. package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -1
  591. package/dist/interactions/actions/defaults/setStroke.js +12 -12
  592. package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
  593. package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
  594. package/dist/interactions/actions/defaults/sliceOps.js +8 -10
  595. package/dist/interactions/actions/defaults/sliceOps.js.map +1 -1
  596. package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
  597. package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
  598. package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
  599. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  600. package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
  601. package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
  602. package/dist/interactions/actions/distribute/action.js +66 -0
  603. package/dist/interactions/actions/distribute/action.js.map +1 -0
  604. package/dist/interactions/actions/distribute/distribute.js +11 -11
  605. package/dist/interactions/actions/distribute/distribute.js.map +1 -1
  606. package/dist/interactions/actions/{defaults/editAnchors.js → edit-anchors/action.js} +7 -9
  607. package/dist/interactions/actions/edit-anchors/action.js.map +1 -0
  608. package/dist/interactions/actions/edit-anchors/geometry.js +30 -27
  609. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
  610. package/dist/interactions/actions/flip/action.js +124 -0
  611. package/dist/interactions/actions/flip/action.js.map +1 -0
  612. package/dist/interactions/actions/flip/helpers.js +30 -17
  613. package/dist/interactions/actions/flip/helpers.js.map +1 -1
  614. package/dist/interactions/actions/gestureFrames.js +18 -0
  615. package/dist/interactions/actions/gestureFrames.js.map +1 -0
  616. package/dist/interactions/actions/gestureLifecycle.js +47 -20
  617. package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
  618. package/dist/interactions/actions/hitSelection.js +8 -0
  619. package/dist/interactions/actions/hitSelection.js.map +1 -0
  620. package/dist/interactions/actions/insert/action.js +72 -0
  621. package/dist/interactions/actions/insert/action.js.map +1 -0
  622. package/dist/interactions/actions/insert/commit.js +28 -0
  623. package/dist/interactions/actions/insert/commit.js.map +1 -0
  624. package/dist/interactions/actions/insert/extras.js +65 -0
  625. package/dist/interactions/actions/insert/extras.js.map +1 -0
  626. package/dist/interactions/actions/insert/frame.js +48 -0
  627. package/dist/interactions/actions/insert/frame.js.map +1 -0
  628. package/dist/interactions/actions/insert/geometry.js +35 -0
  629. package/dist/interactions/actions/insert/geometry.js.map +1 -0
  630. package/dist/interactions/actions/insert/rotateAction.js +21 -0
  631. package/dist/interactions/actions/insert/rotateAction.js.map +1 -0
  632. package/dist/interactions/actions/insert/session.js +59 -0
  633. package/dist/interactions/actions/insert/session.js.map +1 -0
  634. package/dist/interactions/actions/insert/shape.js +34 -0
  635. package/dist/interactions/actions/insert/shape.js.map +1 -0
  636. package/dist/interactions/actions/lasso-select/action.js +143 -0
  637. package/dist/interactions/actions/lasso-select/action.js.map +1 -0
  638. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
  639. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
  640. package/dist/interactions/actions/move/action.js +87 -0
  641. package/dist/interactions/actions/move/action.js.map +1 -0
  642. package/dist/interactions/actions/move/behaviors/layoutDrop.js +51 -0
  643. package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -0
  644. package/dist/interactions/actions/move/behaviors/reparentOnDrop.js +15 -0
  645. package/dist/interactions/actions/move/behaviors/reparentOnDrop.js.map +1 -0
  646. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
  647. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
  648. package/dist/interactions/actions/move/behaviors/snapToContainer.js +39 -27
  649. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  650. package/dist/interactions/actions/move/capture.js +99 -0
  651. package/dist/interactions/actions/move/capture.js.map +1 -0
  652. package/dist/interactions/actions/move/commit/index.js +41 -0
  653. package/dist/interactions/actions/move/commit/index.js.map +1 -0
  654. package/dist/interactions/actions/move/commit/layoutDrop.js +44 -0
  655. package/dist/interactions/actions/move/commit/layoutDrop.js.map +1 -0
  656. package/dist/interactions/actions/move/commit/layoutRelease.js +100 -0
  657. package/dist/interactions/actions/move/commit/layoutRelease.js.map +1 -0
  658. package/dist/interactions/actions/move/commit/rebase.js +18 -0
  659. package/dist/interactions/actions/move/commit/rebase.js.map +1 -0
  660. package/dist/interactions/actions/move/commit/reparent.js +65 -0
  661. package/dist/interactions/actions/move/commit/reparent.js.map +1 -0
  662. package/dist/interactions/actions/move/delta.js +51 -0
  663. package/dist/interactions/actions/move/delta.js.map +1 -0
  664. package/dist/interactions/actions/move/frame.js +59 -0
  665. package/dist/interactions/actions/move/frame.js.map +1 -0
  666. package/dist/interactions/actions/move/gestureAdapter.js +22 -30
  667. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
  668. package/dist/interactions/actions/move/landedDescendants.js +33 -0
  669. package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
  670. package/dist/interactions/actions/move/layout/container.js +94 -0
  671. package/dist/interactions/actions/move/layout/container.js.map +1 -0
  672. package/dist/interactions/actions/move/layout/dragged.js +58 -0
  673. package/dist/interactions/actions/move/layout/dragged.js.map +1 -0
  674. package/dist/interactions/actions/move/layout/dropPass.js +122 -0
  675. package/dist/interactions/actions/move/layout/dropPass.js.map +1 -0
  676. package/dist/interactions/actions/move/layout/exits.js +38 -0
  677. package/dist/interactions/actions/move/layout/exits.js.map +1 -0
  678. package/dist/interactions/actions/move/layout/glide.js +48 -0
  679. package/dist/interactions/actions/move/layout/glide.js.map +1 -0
  680. package/dist/interactions/actions/move/session.js +63 -0
  681. package/dist/interactions/actions/move/session.js.map +1 -0
  682. package/dist/interactions/actions/move/translate.js +61 -0
  683. package/dist/interactions/actions/move/translate.js.map +1 -0
  684. package/dist/interactions/actions/outlines/createOutlines.js +16 -63
  685. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
  686. package/dist/interactions/actions/outlines/createOutlinesAction.js +51 -0
  687. package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -0
  688. package/dist/interactions/actions/outlines/outlineStroke.js +72 -0
  689. package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -0
  690. package/dist/interactions/actions/outlines/outlineStrokeAction.js +37 -0
  691. package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -0
  692. package/dist/interactions/actions/outlines/replaceWithPaths.js +54 -0
  693. package/dist/interactions/actions/outlines/replaceWithPaths.js.map +1 -0
  694. package/dist/interactions/actions/outlines/strokeRegion.js +27 -0
  695. package/dist/interactions/actions/outlines/strokeRegion.js.map +1 -0
  696. package/dist/interactions/actions/planeInput.js.map +1 -1
  697. package/dist/interactions/actions/pointerState.js +12 -0
  698. package/dist/interactions/actions/pointerState.js.map +1 -0
  699. package/dist/interactions/actions/poseDescriptorDep.js +16 -4
  700. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
  701. package/dist/interactions/actions/poseFrame.js +25 -20
  702. package/dist/interactions/actions/poseFrame.js.map +1 -1
  703. package/dist/interactions/actions/resize/action.js +55 -0
  704. package/dist/interactions/actions/resize/action.js.map +1 -0
  705. package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -1
  706. package/dist/interactions/actions/resize/boxFrame.js +16 -0
  707. package/dist/interactions/actions/resize/boxFrame.js.map +1 -0
  708. package/dist/interactions/actions/resize/capture.js +85 -0
  709. package/dist/interactions/actions/resize/capture.js.map +1 -0
  710. package/dist/interactions/actions/resize/commit.js +69 -0
  711. package/dist/interactions/actions/resize/commit.js.map +1 -0
  712. package/dist/interactions/actions/resize/frame.js +74 -0
  713. package/dist/interactions/actions/resize/frame.js.map +1 -0
  714. package/dist/interactions/actions/resize/pointSnap.js +111 -0
  715. package/dist/interactions/actions/resize/pointSnap.js.map +1 -0
  716. package/dist/interactions/actions/resize/ruleBounds.js +9 -0
  717. package/dist/interactions/actions/resize/ruleBounds.js.map +1 -0
  718. package/dist/interactions/actions/resize/session.js +49 -0
  719. package/dist/interactions/actions/resize/session.js.map +1 -0
  720. package/dist/interactions/actions/resolveOverlays.js.map +1 -1
  721. package/dist/interactions/actions/resolvePreviews.js.map +1 -1
  722. package/dist/interactions/actions/rotate/action.js +56 -0
  723. package/dist/interactions/actions/rotate/action.js.map +1 -0
  724. package/dist/interactions/actions/rotate/behaviors/index.js +7 -0
  725. package/dist/interactions/actions/rotate/behaviors/index.js.map +1 -0
  726. package/dist/interactions/actions/rotate/behaviors/snapRotation.js +12 -0
  727. package/dist/interactions/actions/rotate/behaviors/snapRotation.js.map +1 -0
  728. package/dist/interactions/actions/rotate/commit.js +40 -0
  729. package/dist/interactions/actions/rotate/commit.js.map +1 -0
  730. package/dist/interactions/actions/rotate/frame.js +65 -0
  731. package/dist/interactions/actions/rotate/frame.js.map +1 -0
  732. package/dist/interactions/actions/rotate/handle.js +12 -12
  733. package/dist/interactions/actions/rotate/handle.js.map +1 -1
  734. package/dist/interactions/actions/rotate/session.js +92 -0
  735. package/dist/interactions/actions/rotate/session.js.map +1 -0
  736. package/dist/interactions/actions/selectionSubtree.js +69 -0
  737. package/dist/interactions/actions/selectionSubtree.js.map +1 -0
  738. package/dist/interactions/actions/spatialReference.js.map +1 -1
  739. package/dist/interactions/actions/useStandardActions.js +87 -78
  740. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  741. package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
  742. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
  743. package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
  744. package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
  745. package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
  746. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
  747. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +62 -41
  748. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
  749. package/dist/interactions/gestures/shared/originProjection.js +1 -1
  750. package/dist/interactions/gestures/shared/originProjection.js.map +1 -1
  751. package/dist/interactions/gestures/shared/screenTolerance.js +8 -2
  752. package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
  753. package/dist/interactions/gestures/shared/snap.js.map +1 -1
  754. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
  755. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
  756. package/dist/layout/arrivals.js +20 -23
  757. package/dist/layout/arrivals.js.map +1 -1
  758. package/dist/math-CYUjoyyU.d.ts +33 -0
  759. package/dist/math.d.ts +5 -3
  760. package/dist/math.js +6 -6
  761. package/dist/mesh.d.ts +4 -268
  762. package/dist/mesh.js +3 -7
  763. package/dist/move.d.ts +14 -11
  764. package/dist/{originProjection-DEklpDc_.d.ts → originProjection-PPT88jZv.d.ts} +1 -1
  765. package/dist/patterns-builtin.d.ts +1 -118
  766. package/dist/patterns-builtin.js +2 -3
  767. package/dist/{poseDescriptor-D-OH-tu5.d.ts → poseDescriptor-Bqk-11Rl.d.ts} +26 -36
  768. package/dist/renderer.d.ts +1 -91
  769. package/dist/renderer.js +2 -18
  770. package/dist/resize.d.ts +10 -22
  771. package/dist/resize.js +6 -6
  772. package/dist/style.css +1 -1
  773. package/dist/test-hook/install.js +12 -6
  774. package/dist/test-hook/install.js.map +1 -1
  775. package/dist/test-hook/useTestHook.js +22 -0
  776. package/dist/test-hook/useTestHook.js.map +1 -0
  777. package/dist/test-seams-D0pyV3pR.d.ts +149 -0
  778. package/dist/test-seams.d.ts +4 -4
  779. package/dist/test-seams.js +2 -2
  780. package/dist/tools/builtin/bone/boneActions.js +130 -0
  781. package/dist/tools/builtin/bone/boneActions.js.map +1 -0
  782. package/dist/tools/builtin/bone/boneOverlay.js +58 -0
  783. package/dist/tools/builtin/bone/boneOverlay.js.map +1 -0
  784. package/dist/tools/builtin/bone/placedRig.js +24 -0
  785. package/dist/tools/builtin/bone/placedRig.js.map +1 -0
  786. package/dist/tools/builtin/bone/rigEditState.js +21 -0
  787. package/dist/tools/builtin/bone/rigEditState.js.map +1 -0
  788. package/dist/tools/builtin/bone/useBoneTool.js +98 -0
  789. package/dist/tools/builtin/bone/useBoneTool.js.map +1 -0
  790. package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
  791. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  792. package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
  793. package/dist/tools/builtin/hand/useHandTool.js +1 -0
  794. package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
  795. package/dist/tools/builtin/image/useImageTool.js.map +1 -1
  796. package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
  797. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
  798. package/dist/tools/builtin/line/useLineTool.js +1 -0
  799. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  800. package/dist/tools/builtin/pen/usePenTool.js +198 -150
  801. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  802. package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
  803. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
  804. package/dist/tools/builtin/pickTopMostHit.js.map +1 -1
  805. package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
  806. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  807. package/dist/tools/builtin/rect/useRectTool.js +1 -0
  808. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  809. package/dist/tools/builtin/select/adapterPointQuery.js +36 -0
  810. package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -0
  811. package/dist/tools/builtin/select/selectionContributions.js +25 -24
  812. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  813. package/dist/tools/builtin/select/useSelectTool.js +42 -67
  814. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  815. package/dist/tools/builtin/shared/pointerFollower.js +17 -0
  816. package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
  817. package/dist/tools/builtin/slice/useSliceTool.js +72 -82
  818. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  819. package/dist/tools/builtin/star/useStarTool.js +22 -16
  820. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  821. package/dist/tools/builtin/text/useTextTool.js +9 -0
  822. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  823. package/dist/tools/builtin/weight/useWeightTool.js +77 -0
  824. package/dist/tools/builtin/weight/useWeightTool.js.map +1 -0
  825. package/dist/tools/builtin/weight/weightActions.js +112 -0
  826. package/dist/tools/builtin/weight/weightActions.js.map +1 -0
  827. package/dist/tools/builtin/weight/weightOverlay.js +61 -0
  828. package/dist/tools/builtin/weight/weightOverlay.js.map +1 -0
  829. package/dist/tools/overlayBinding.js.map +1 -1
  830. package/dist/tools/useKeybindings.js +12 -22
  831. package/dist/tools/useKeybindings.js.map +1 -1
  832. package/dist/{types-A37hYkeR.d.ts → types-CIKDwlsP.d.ts} +113 -169
  833. package/dist/util/color.js +3 -3
  834. package/dist/util/color.js.map +1 -1
  835. package/dist/util/paint.js +1 -1
  836. package/dist/util/paint.js.map +1 -1
  837. package/dist/version.js +1 -1
  838. package/package.json +28 -21
  839. package/dist/animation/colorHelpers.js +0 -135
  840. package/dist/animation/colorHelpers.js.map +0 -1
  841. package/dist/animation/colorRegistry.js +0 -37
  842. package/dist/animation/colorRegistry.js.map +0 -1
  843. package/dist/animation/engine/axes.js +0 -36
  844. package/dist/animation/engine/axes.js.map +0 -1
  845. package/dist/animation/engine/codec.js +0 -170
  846. package/dist/animation/engine/codec.js.map +0 -1
  847. package/dist/animation/engine/integrator.js +0 -12
  848. package/dist/animation/engine/integrator.js.map +0 -1
  849. package/dist/animation/loop.js +0 -62
  850. package/dist/animation/loop.js.map +0 -1
  851. package/dist/animation/observe.js +0 -23
  852. package/dist/animation/observe.js.map +0 -1
  853. package/dist/animation/rig/blendPoses.js +0 -43
  854. package/dist/animation/rig/blendPoses.js.map +0 -1
  855. package/dist/animation/rig/mirrorPose.js +0 -19
  856. package/dist/animation/rig/mirrorPose.js.map +0 -1
  857. package/dist/animation/rig/resolveSkeleton.js +0 -33
  858. package/dist/animation/rig/resolveSkeleton.js.map +0 -1
  859. package/dist/animation/rig/solveIk.js +0 -103
  860. package/dist/animation/rig/solveIk.js.map +0 -1
  861. package/dist/animation/rig/types.js +0 -12
  862. package/dist/animation/rig/types.js.map +0 -1
  863. package/dist/animation/slew.js +0 -27
  864. package/dist/animation/slew.js.map +0 -1
  865. package/dist/animation/stagger.js +0 -138
  866. package/dist/animation/stagger.js.map +0 -1
  867. package/dist/animation/timeline/booking.js +0 -106
  868. package/dist/animation/timeline/booking.js.map +0 -1
  869. package/dist/animation/timeline/createTimeline.js +0 -116
  870. package/dist/animation/timeline/createTimeline.js.map +0 -1
  871. package/dist/animation/timeline/sampleTrack.js +0 -71
  872. package/dist/animation/timeline/sampleTrack.js.map +0 -1
  873. package/dist/animation/useAnimator.js +0 -378
  874. package/dist/animation/useAnimator.js.map +0 -1
  875. package/dist/builtins-C-VgUlWI.d.ts +0 -4514
  876. package/dist/canvas/MinimapCanvas.js +0 -139
  877. package/dist/canvas/MinimapCanvas.js.map +0 -1
  878. package/dist/canvas/deps/poseComposition.js +0 -11
  879. package/dist/canvas/deps/poseComposition.js.map +0 -1
  880. package/dist/canvas/minimapMath.js +0 -80
  881. package/dist/canvas/minimapMath.js.map +0 -1
  882. package/dist/canvas/toolPreview.js +0 -39
  883. package/dist/canvas/toolPreview.js.map +0 -1
  884. package/dist/core/adapters/arrayAdapter.js +0 -85
  885. package/dist/core/adapters/arrayAdapter.js.map +0 -1
  886. package/dist/core/adapters/useArrayAdapter.js +0 -13
  887. package/dist/core/adapters/useArrayAdapter.js.map +0 -1
  888. package/dist/core/fillInPoseFrame.js +0 -102
  889. package/dist/core/fillInPoseFrame.js.map +0 -1
  890. package/dist/core/geometry/poseRotation.js +0 -58
  891. package/dist/core/geometry/poseRotation.js.map +0 -1
  892. package/dist/core/gradient.js +0 -136
  893. package/dist/core/gradient.js.map +0 -1
  894. package/dist/core/isPlainObject.js.map +0 -1
  895. package/dist/core/markerInset.js +0 -24
  896. package/dist/core/markerInset.js.map +0 -1
  897. package/dist/core/mixed.js +0 -6
  898. package/dist/core/mixed.js.map +0 -1
  899. package/dist/core/paintKinds.js +0 -156
  900. package/dist/core/paintKinds.js.map +0 -1
  901. package/dist/core/strokeMarkerShapes.js +0 -139
  902. package/dist/core/strokeMarkerShapes.js.map +0 -1
  903. package/dist/core/strokeMarkers.js +0 -28
  904. package/dist/core/strokeMarkers.js.map +0 -1
  905. package/dist/core/viewport/meanScale.js +0 -8
  906. package/dist/core/viewport/meanScale.js.map +0 -1
  907. package/dist/core/viewport/pxExtent.js +0 -42
  908. package/dist/core/viewport/pxExtent.js.map +0 -1
  909. package/dist/debug/flag.js.map +0 -1
  910. package/dist/features/cursor/paintedCursorLayer.js.map +0 -1
  911. package/dist/features/focus/gateLayer.js +0 -14
  912. package/dist/features/focus/gateLayer.js.map +0 -1
  913. package/dist/features/focus/useCanvasFocus.js +0 -29
  914. package/dist/features/focus/useCanvasFocus.js.map +0 -1
  915. package/dist/features/groups/children.js.map +0 -1
  916. package/dist/features/groups/composePose.js.map +0 -1
  917. package/dist/features/groups/nestedHit.js.map +0 -1
  918. package/dist/features/groups/unionOfChildren.js.map +0 -1
  919. package/dist/features/images/imageCache.js +0 -94
  920. package/dist/features/images/imageCache.js.map +0 -1
  921. package/dist/features/ingestion/index.js +0 -8
  922. package/dist/features/meshPaint/bake.js +0 -79
  923. package/dist/features/meshPaint/bake.js.map +0 -1
  924. package/dist/features/meshPaint/bakeCache.js +0 -59
  925. package/dist/features/meshPaint/bakeCache.js.map +0 -1
  926. package/dist/features/meshPaint/handles.js +0 -86
  927. package/dist/features/meshPaint/handles.js.map +0 -1
  928. package/dist/features/meshPaint/lazyKind.js.map +0 -1
  929. package/dist/features/meshPaint/meshPaint.js +0 -236
  930. package/dist/features/meshPaint/meshPaint.js.map +0 -1
  931. package/dist/features/meshPaint/meshShader.js +0 -6
  932. package/dist/features/meshPaint/meshShader.js.map +0 -1
  933. package/dist/features/meshPaint/register.js +0 -7
  934. package/dist/features/meshPaint/register.js.map +0 -1
  935. package/dist/features/meshPaint/surface.js +0 -110
  936. package/dist/features/meshPaint/surface.js.map +0 -1
  937. package/dist/features/minimap/actions.js +0 -53
  938. package/dist/features/minimap/actions.js.map +0 -1
  939. package/dist/features/minimap/createMinimapContribution.js +0 -96
  940. package/dist/features/minimap/createMinimapContribution.js.map +0 -1
  941. package/dist/features/minimap/layers.js +0 -103
  942. package/dist/features/minimap/layers.js.map +0 -1
  943. package/dist/features/overlays/useNodeOverlayFrame.js +0 -103
  944. package/dist/features/overlays/useNodeOverlayFrame.js.map +0 -1
  945. package/dist/features/parallax/createParallaxLayer.js +0 -26
  946. package/dist/features/parallax/createParallaxLayer.js.map +0 -1
  947. package/dist/features/parallax/createParallaxPlane.js +0 -26
  948. package/dist/features/parallax/createParallaxPlane.js.map +0 -1
  949. package/dist/features/paths/anchorEdits.js +0 -156
  950. package/dist/features/paths/anchorEdits.js.map +0 -1
  951. package/dist/features/paths/anchors.js +0 -154
  952. package/dist/features/paths/anchors.js.map +0 -1
  953. package/dist/features/paths/booleans.js +0 -2
  954. package/dist/features/paths/markerCommands.js +0 -148
  955. package/dist/features/paths/markerCommands.js.map +0 -1
  956. package/dist/features/paths/markerSites.js +0 -59
  957. package/dist/features/paths/markerSites.js.map +0 -1
  958. package/dist/features/paths/markers.js +0 -95
  959. package/dist/features/paths/markers.js.map +0 -1
  960. package/dist/features/paths/nearestAnchor.js +0 -36
  961. package/dist/features/paths/nearestAnchor.js.map +0 -1
  962. package/dist/features/paths/pathInWorld.js +0 -41
  963. package/dist/features/paths/pathInWorld.js.map +0 -1
  964. package/dist/features/paths/poseDescriptor.js +0 -39
  965. package/dist/features/paths/poseDescriptor.js.map +0 -1
  966. package/dist/features/paths/tessellate/dash.js +0 -52
  967. package/dist/features/paths/tessellate/dash.js.map +0 -1
  968. package/dist/features/paths/tessellate/insets.js +0 -32
  969. package/dist/features/paths/tessellate/insets.js.map +0 -1
  970. package/dist/features/paths/tessellate/metric.js +0 -72
  971. package/dist/features/paths/tessellate/metric.js.map +0 -1
  972. package/dist/features/paths/tessellate/stroke.js +0 -170
  973. package/dist/features/paths/tessellate/stroke.js.map +0 -1
  974. package/dist/features/paths/tessellate/vertexWidths.js +0 -32
  975. package/dist/features/paths/tessellate/vertexWidths.js.map +0 -1
  976. package/dist/features/patterns/index.js +0 -23
  977. package/dist/features/patterns/index.js.map +0 -1
  978. package/dist/features/patterns/patterns-builtin.js +0 -38
  979. package/dist/features/patterns/patterns-builtin.js.map +0 -1
  980. package/dist/features/patterns/resolveSpec.js +0 -57
  981. package/dist/features/patterns/resolveSpec.js.map +0 -1
  982. package/dist/features/patterns/tileGeometry.js +0 -158
  983. package/dist/features/patterns/tileGeometry.js.map +0 -1
  984. package/dist/features/pointer/PointerContext.js +0 -45
  985. package/dist/features/pointer/PointerContext.js.map +0 -1
  986. package/dist/features/selection/SelectionContext.js +0 -46
  987. package/dist/features/selection/SelectionContext.js.map +0 -1
  988. package/dist/features/simulation/createSimulation.js +0 -61
  989. package/dist/features/simulation/createSimulation.js.map +0 -1
  990. package/dist/features/simulation/types.js +0 -6
  991. package/dist/features/simulation/types.js.map +0 -1
  992. package/dist/features/simulation/useSimulation.js +0 -74
  993. package/dist/features/simulation/useSimulation.js.map +0 -1
  994. package/dist/features/text/domRuns.js +0 -258
  995. package/dist/features/text/domRuns.js.map +0 -1
  996. package/dist/features/text/fitTextPose.js +0 -38
  997. package/dist/features/text/fitTextPose.js.map +0 -1
  998. package/dist/features/text/hitTest.js +0 -45
  999. package/dist/features/text/hitTest.js.map +0 -1
  1000. package/dist/features/text/renderLabel.js +0 -14
  1001. package/dist/features/text/renderLabel.js.map +0 -1
  1002. package/dist/features/text/runs/effectiveRangeStyle.js +0 -66
  1003. package/dist/features/text/runs/effectiveRangeStyle.js.map +0 -1
  1004. package/dist/features/text/runs/flagRange.js +0 -53
  1005. package/dist/features/text/runs/flagRange.js.map +0 -1
  1006. package/dist/features/text/runs/rangeStyle.js +0 -135
  1007. package/dist/features/text/runs/rangeStyle.js.map +0 -1
  1008. package/dist/features/text/textCommand.js +0 -59
  1009. package/dist/features/text/textCommand.js.map +0 -1
  1010. package/dist/features/text/textToPath.js +0 -181
  1011. package/dist/features/text/textToPath.js.map +0 -1
  1012. package/dist/features/text/useTextEdit.js +0 -467
  1013. package/dist/features/text/useTextEdit.js.map +0 -1
  1014. package/dist/features/tiling/createTiledLayer.js +0 -63
  1015. package/dist/features/tiling/createTiledLayer.js.map +0 -1
  1016. package/dist/features/tiling/tiledProject.js +0 -14
  1017. package/dist/features/tiling/tiledProject.js.map +0 -1
  1018. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +0 -26
  1019. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +0 -1
  1020. package/dist/interactions/actions/defaults/align.js.map +0 -1
  1021. package/dist/interactions/actions/defaults/booleans.js +0 -52
  1022. package/dist/interactions/actions/defaults/booleans.js.map +0 -1
  1023. package/dist/interactions/actions/defaults/clipboard.js.map +0 -1
  1024. package/dist/interactions/actions/defaults/clone.js +0 -107
  1025. package/dist/interactions/actions/defaults/clone.js.map +0 -1
  1026. package/dist/interactions/actions/defaults/createOutlines.js +0 -47
  1027. package/dist/interactions/actions/defaults/createOutlines.js.map +0 -1
  1028. package/dist/interactions/actions/defaults/distribute.js +0 -66
  1029. package/dist/interactions/actions/defaults/distribute.js.map +0 -1
  1030. package/dist/interactions/actions/defaults/editAnchors.js.map +0 -1
  1031. package/dist/interactions/actions/defaults/flip.js +0 -119
  1032. package/dist/interactions/actions/defaults/flip.js.map +0 -1
  1033. package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
  1034. package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
  1035. package/dist/interactions/actions/defaults/insert.js +0 -288
  1036. package/dist/interactions/actions/defaults/insert.js.map +0 -1
  1037. package/dist/interactions/actions/defaults/lassoSelect.js +0 -156
  1038. package/dist/interactions/actions/defaults/lassoSelect.js.map +0 -1
  1039. package/dist/interactions/actions/defaults/move.js +0 -760
  1040. package/dist/interactions/actions/defaults/move.js.map +0 -1
  1041. package/dist/interactions/actions/defaults/resize.js +0 -335
  1042. package/dist/interactions/actions/defaults/resize.js.map +0 -1
  1043. package/dist/interactions/actions/defaults/rotate.js +0 -184
  1044. package/dist/interactions/actions/defaults/rotate.js.map +0 -1
  1045. package/dist/interactions/actions/previewOverrides.js +0 -25
  1046. package/dist/interactions/actions/previewOverrides.js.map +0 -1
  1047. package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +0 -1
  1048. package/dist/math-Drrw4ewZ.d.ts +0 -160
  1049. package/dist/registerProgram-BMZRDgrh.d.ts +0 -197
  1050. package/dist/renderer/DrawCommand.js +0 -6
  1051. package/dist/renderer/DrawCommand.js.map +0 -1
  1052. package/dist/renderer/WeaselRenderer.js +0 -331
  1053. package/dist/renderer/WeaselRenderer.js.map +0 -1
  1054. package/dist/renderer/batchClip.js +0 -46
  1055. package/dist/renderer/batchClip.js.map +0 -1
  1056. package/dist/renderer/cache/GLImageCache.js +0 -64
  1057. package/dist/renderer/cache/GLImageCache.js.map +0 -1
  1058. package/dist/renderer/cache/GLMeshCache.js +0 -102
  1059. package/dist/renderer/cache/GLMeshCache.js.map +0 -1
  1060. package/dist/renderer/cache/GLTextureCache.js +0 -51
  1061. package/dist/renderer/cache/GLTextureCache.js.map +0 -1
  1062. package/dist/renderer/cache/GradientRampAtlas.js +0 -82
  1063. package/dist/renderer/cache/GradientRampAtlas.js.map +0 -1
  1064. package/dist/renderer/cache/cache.js +0 -13
  1065. package/dist/renderer/cache/cache.js.map +0 -1
  1066. package/dist/renderer/cache/markerCommandCache.js +0 -63
  1067. package/dist/renderer/cache/markerCommandCache.js.map +0 -1
  1068. package/dist/renderer/cache/outlineMeshCache.js +0 -15
  1069. package/dist/renderer/cache/outlineMeshCache.js.map +0 -1
  1070. package/dist/renderer/cache/outlineStrokeMeshCache.js +0 -36
  1071. package/dist/renderer/cache/outlineStrokeMeshCache.js.map +0 -1
  1072. package/dist/renderer/cache/strokeMeshCache.js +0 -55
  1073. package/dist/renderer/cache/strokeMeshCache.js.map +0 -1
  1074. package/dist/renderer/cullDrawCommands.js +0 -90
  1075. package/dist/renderer/cullDrawCommands.js.map +0 -1
  1076. package/dist/renderer/draw.js +0 -1135
  1077. package/dist/renderer/draw.js.map +0 -1
  1078. package/dist/renderer/drawBatch.js +0 -198
  1079. package/dist/renderer/drawBatch.js.map +0 -1
  1080. package/dist/renderer/effects/EffectTargets.js +0 -45
  1081. package/dist/renderer/effects/EffectTargets.js.map +0 -1
  1082. package/dist/renderer/effects/builtins.js +0 -31
  1083. package/dist/renderer/effects/builtins.js.map +0 -1
  1084. package/dist/renderer/effects/composite.js +0 -9
  1085. package/dist/renderer/effects/composite.js.map +0 -1
  1086. package/dist/renderer/effects/effectPrelude.js +0 -10
  1087. package/dist/renderer/effects/effectPrelude.js.map +0 -1
  1088. package/dist/renderer/effects/types.js +0 -10
  1089. package/dist/renderer/effects/types.js.map +0 -1
  1090. package/dist/renderer/glyphOutlineMesh.js +0 -67
  1091. package/dist/renderer/glyphOutlineMesh.js.map +0 -1
  1092. package/dist/renderer/index.js +0 -19
  1093. package/dist/renderer/math/color.js +0 -341
  1094. package/dist/renderer/math/color.js.map +0 -1
  1095. package/dist/renderer/math/mat3.js +0 -76
  1096. package/dist/renderer/math/mat3.js.map +0 -1
  1097. package/dist/renderer/math/patternSpace.js +0 -22
  1098. package/dist/renderer/math/patternSpace.js.map +0 -1
  1099. package/dist/renderer/math/viewToMat3.js +0 -19
  1100. package/dist/renderer/math/viewToMat3.js.map +0 -1
  1101. package/dist/renderer/paintResources.js +0 -18
  1102. package/dist/renderer/paintResources.js.map +0 -1
  1103. package/dist/renderer/paintScratch.js +0 -37
  1104. package/dist/renderer/paintScratch.js.map +0 -1
  1105. package/dist/renderer/shaders/ShaderProgram.js +0 -74
  1106. package/dist/renderer/shaders/ShaderProgram.js.map +0 -1
  1107. package/dist/renderer/shaders/batchFill.js +0 -119
  1108. package/dist/renderer/shaders/batchFill.js.map +0 -1
  1109. package/dist/renderer/shaders/customPrelude.js +0 -34
  1110. package/dist/renderer/shaders/customPrelude.js.map +0 -1
  1111. package/dist/renderer/shaders/extractUniformNames.js +0 -184
  1112. package/dist/renderer/shaders/extractUniformNames.js.map +0 -1
  1113. package/dist/renderer/shaders/glyphPaint.js +0 -61
  1114. package/dist/renderer/shaders/glyphPaint.js.map +0 -1
  1115. package/dist/renderer/shaders/gradFill.js +0 -30
  1116. package/dist/renderer/shaders/gradFill.js.map +0 -1
  1117. package/dist/renderer/shaders/imageFill.js +0 -14
  1118. package/dist/renderer/shaders/imageFill.js.map +0 -1
  1119. package/dist/renderer/shaders/pathFill.js +0 -13
  1120. package/dist/renderer/shaders/pathFill.js.map +0 -1
  1121. package/dist/renderer/shaders/patternFill.js +0 -24
  1122. package/dist/renderer/shaders/patternFill.js.map +0 -1
  1123. package/dist/renderer/shaders/registerProgram.js +0 -18
  1124. package/dist/renderer/shaders/registerProgram.js.map +0 -1
  1125. package/dist/renderer/spriteSheet.js +0 -14
  1126. package/dist/renderer/spriteSheet.js.map +0 -1
  1127. package/dist/renderer/state/GroupState.js +0 -77
  1128. package/dist/renderer/state/GroupState.js.map +0 -1
  1129. package/dist/renderer/strokeLengths.js +0 -50
  1130. package/dist/renderer/strokeLengths.js.map +0 -1
  1131. package/dist/renderer/syntheticItalic.js +0 -6
  1132. package/dist/renderer/syntheticItalic.js.map +0 -1
  1133. package/dist/renderer/textures/registerTexture.js +0 -14
  1134. package/dist/renderer/textures/registerTexture.js.map +0 -1
  1135. package/dist/scheduling/useVisibleRaf.js +0 -69
  1136. package/dist/scheduling/useVisibleRaf.js.map +0 -1
  1137. package/dist/test-seams-CuIxe0xY.d.ts +0 -356
  1138. package/dist/tools/prefs.js +0 -62
  1139. package/dist/tools/prefs.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["IDENTITY_VIEW","reportLayerFailure","layerId","error","subscribeToSources","offs","sources","l","listener","off","clockMs","drawLayers","layerById","layers","sequence","order","id","v","view","out","cache","groupOf","groupMembership","groups","bracketed","run","closeRun","start","t0","spans","c","wrapGroup","dims","layer","isLayerVisible","visibility","cmds","drawOneLayer","data","onLayerError","buildMs","group","stack","layerIds","byLayer","name","matched","claimed","declared","effects","children","isLayerPainted","layerCommands","viewToMat3","deps","entry","depsUnchanged","a","b","i"],"sources":["../../../src/core/layers/render.ts"],"sourcesContent":["import { viewToMat3, type DrawCommand } from '../../renderer';\nimport type { Effect } from '../../renderer/effects/types';\nimport type { View } from 'core/viewport/view';\n\nconst IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n\n/**\n * Canvas size in CSS pixels — passed to `draw` for layers that anchor to\n * canvas edges (e.g. the debug overlay's layer-list panel). The GL backend\n * supplies it explicitly so layers don't have to know about DPR.\n */\nexport interface Dims {\n width: number;\n height: number;\n}\n\n/**\n * What a layer's `draw` threw, and which layer threw it.\n *\n * A `draw` runs on the frame loop, so a throw that escapes it surfaces as an\n * uncaught `requestAnimationFrame` error on the window and takes the whole\n * frame with it — every other layer included. One broken layer painting\n * nothing, named in the console, is the lesser wrong.\n */\nexport interface LayerDrawFailure {\n layerId: string;\n error: unknown;\n}\n\n/** Default report: name the layer, keep the frame. */\nfunction reportLayerFailure({ layerId, error }: LayerDrawFailure): void {\n console.error(\n `[weasel] layer \"${layerId}\" threw while drawing; it painted nothing this frame.`,\n error,\n );\n}\n\n/**\n * Several consecutive layers composited as one.\n *\n * A layer's own `effects` run over that layer alone, which is the wrong\n * picture whenever a pass reads neighboring pixels: `blur(A over B)` is not\n * `blur(A) over blur(B)`, and it costs a buffer and a pass chain per layer. A\n * group draws its members into one buffer, runs one chain over it, and\n * composites the result back once.\n *\n * Membership is by `RenderLayer.id` — the same names `layerOrder` and\n * `layerVisibility` use, not the `layers` map's slot keys.\n *\n * Only *consecutive* members share a buffer, because anything drawn between\n * two members has to land between them. A group whose members are separated in\n * the render order is drawn as one bracket per run, with a warning: the\n * picture is right, the declaration almost certainly is not.\n *\n * This is a render-stack bracket, not a scene `ContainerNode` — it holds no\n * ids, survives no reload, and nothing in the scene knows about it.\n */\nexport interface LayerGroup {\n /** Names the group in warnings; not a layer id and never drawn. */\n id: string;\n /**\n * Member layer ids. Order here is ignored — the render order decides.\n *\n * A name claims that layer and every layer under it in the `:` namespace, so\n * `'scene'` covers the `scene:<layerId>` layers a scene with declared layers\n * draws as — the same set `before`/`after: 'scene'` anchors against. The\n * separator is required: `'scene'` does not reach `scenery`. A name matching\n * no layer being drawn is warned about rather than ignored.\n */\n layers: readonly string[];\n /**\n * Passes over the group's combined pixels, in order. A thunk is re-read on\n * every frame, so an animating radius costs no React render; an array is\n * read once per frame either way.\n */\n effects?: readonly Effect[] | ((view: View, dims: Dims) => readonly Effect[]);\n /** Opacity applied to the group's composited result, not to each member. */\n alpha?: number;\n /** 4×5 color matrix (row-major, 20 numbers) applied to the composited\n * result. See `GroupDrawCommand.colorMatrix`. */\n colorMatrix?: number[];\n}\n\n/** One layer's memoized output, keyed by layer id. Owned by the canvas that\n * calls `drawLayers`, not by `drawLayers` itself — the function is pure. */\nexport type LayerCommandCache = Map<\n string,\n { deps: readonly unknown[]; cmds: DrawCommand[] }\n>;\n\n/**\n * A single named render sub-layer within a canvas renderer.\n *\n * @template TData - The data object passed to each draw call.\n */\n/** Something outside React whose changes a paint reads — a mode registry, a\n * scoping lookup. A notification repaints the canvas; the listener takes no\n * arguments and the returned function unsubscribes. */\nexport interface RedrawSource {\n subscribe(listener: () => void): () => void;\n}\n\n/** The `subscribe` for a layer that draws `sources`: it notifies whenever any\n * of them does. A thunk is read when the subscription is made. Every layer\n * that draws other layers declares this, so wrapping never silences what\n * repaints a source. */\nexport function subscribeToSources(\n sources: readonly { subscribe?: RedrawSource['subscribe'] }[]\n | (() => readonly { subscribe?: RedrawSource['subscribe'] }[]),\n): RedrawSource['subscribe'] {\n return (listener) => {\n const list = typeof sources === 'function' ? sources() : sources;\n const offs = list.flatMap((l) => (l.subscribe ? [l.subscribe(listener)] : []));\n return () => { for (const off of offs) off(); };\n };\n}\n\n/** One layer of a canvas: `draw` turns `data` and the view into draw commands;\n * the other fields control caching, visibility, coordinate space and hit-testing. */\nexport interface RenderLayer<TData> {\n /** Unique identifier used in visibility maps and ordering arrays. When a\n * cache is in use, an id must identify the same logical layer across\n * frames — reusing it for a different layer can serve cross-layer commands. */\n id: string;\n /** Human-readable name for UI toggles. */\n label: string;\n /**\n * Emit a DrawCommand tree for the GL backend to dispatch.\n *\n * For world-space layers (the default), emit commands in WORLD COORDS —\n * `drawLayers` automatically wraps them in `{ kind: 'group', transform:\n * viewToMat3(view), ... }` before handing them to the renderer. Do NOT\n * apply the view transform yourself.\n *\n * For screen-space layers (`space: 'screen'`), emit commands in CSS-pixel\n * coords directly; `drawLayers` passes them through unchanged. If part\n * of a screen-space layer's output needs to track the view, wrap that\n * subset manually with `viewToMat3(view)`.\n */\n draw: (data: TData, view: View, dims: Dims) => DrawCommand[];\n /**\n * Optional cache key. When present and a `LayerCommandCache` is supplied to\n * `drawLayers`, the layer's previous `DrawCommand[]` is reused as long as\n * every entry is `Object.is`-equal to the previous call's. A layer with no\n * `deps` rebuilds on every frame.\n *\n * **The returned commands must be treated as immutable.** A cached tree is\n * handed to the renderer again on later frames, so mutating a tree you\n * previously returned corrupts the cache silently rather than erroring.\n *\n * **Screen-space layers are not protected against a stale `view`/`dims`\n * the way world-space layers are** (see `space` below) — include them in\n * `deps` if `draw` reads them.\n */\n deps?: (data: TData, view: View, dims: Dims) => readonly unknown[];\n /**\n * Whether the layer is shown when no explicit visibility entry exists.\n * Defaults to `true` when absent.\n */\n defaultVisible?: boolean;\n /**\n * When true, the layer is always drawn regardless of the visibility map.\n * Useful for layers that must never be hidden (e.g. base grid).\n */\n alwaysOn?: boolean;\n /**\n * Coordinate space the layer draws in.\n *\n * - `'world'` (default): the layer's `draw` returns world-space commands;\n * `drawLayers` wraps them in a `kind: 'group'` with `viewToMat3(view)`\n * automatically.\n * - `'screen'`: the layer's `draw` returns screen-space (CSS-pixel)\n * commands; `drawLayers` passes them through unchanged. World-anchored\n * chrome inside a screen-space layer must call `worldToScreen` or wrap\n * the relevant subset with `viewToMat3(view)` manually.\n */\n space?: 'world' | 'screen';\n /**\n * Where the layer learns that state `draw` reads, outside the scene and the\n * props, has changed. The canvas painting it subscribes while the layer is\n * mounted and repaints on every notification, so a layer reading a mode\n * registry needs no consumer code to follow a mode switch.\n */\n subscribe?: RedrawSource['subscribe'];\n /**\n * Full-screen passes run over this layer's own pixels before it joins the\n * frame — a blur here blurs the world and leaves the HUD drawn above it\n * sharp, which is the thing a CSS `filter` on the `<canvas>` cannot do.\n *\n * Costs nothing while empty: the renderer allocates no offscreen buffer\n * until a layer actually declares one. See `GroupDrawCommand.effects` for\n * what a pass may read, and {@link LayerGroup} to run one chain over\n * several layers at once instead of one chain each.\n */\n effects?: readonly Effect[];\n /**\n * Optional hit-test for **consumer-attached** layers.\n *\n * Only layers registered through `CanvasExtensionApi.registerLayer` are\n * hit-tested: `hitTestExtras` walks them last-registered-first on\n * pointerdown, and `<SceneCanvas>` folds the result into its `affordanceAt`\n * thunk ahead of the kit's own selection chrome. First non-null result\n * wins; null means \"I don't claim this hit, try the next layer.\"\n *\n * Layers that reach the draw stack some other way — a `Tool.overlay`, an\n * entry in the `layers` map — are painted but never hit-tested, so defining\n * `hitTest` on one has no effect. (The kit's own chrome doesn't need it: it\n * goes through `buildAffordanceAt`.)\n *\n * Coordinates are world-space. The `data` arg is the layer's\n * configured data slot (same as `draw`); `view` and `dims` mirror\n * `draw`'s arguments.\n */\n hitTest?: (\n worldX: number,\n worldY: number,\n data: TData,\n view: View,\n dims: Dims,\n /** Chrome-caps visibility predicate. When supplied, the layer must\n * not return a hit from any chrome element whose id reports\n * `false`. Absent → every element is hittable. */\n isVisible?: (id: string) => boolean,\n ) => import('../../affordances/types').LayerHit | null;\n /**\n * Called on every pointermove when no gesture is currently captured.\n * Lets layers (e.g. HUD widgets) track hover state without participating\n * in the drag pipeline. Coords are world-space; the layer is responsible\n * for any further conversion (e.g. world→screen for screen-space layers)\n * and for its own throttling.\n */\n onUncapturedMove?: (\n worldX: number,\n worldY: number,\n evt: PointerEvent,\n view: View,\n dims: Dims,\n ) => void;\n /**\n * Called when the cursor leaves the canvas element. Lets layers clear\n * any hover state they're holding.\n */\n onUncapturedLeave?: () => void;\n}\n\n/** Where one layer's commands landed in {@link drawLayers}' output,\n * `[start, end)`, and the CPU milliseconds its `draw` took. A layer group's\n * run is one span under the group's id. */\nexport interface LayerDrawSpan {\n id: string;\n start: number;\n end: number;\n buildMs: number;\n}\n\nfunction clockMs(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/**\n * Walk visible layers and concatenate their emitted DrawCommand arrays into\n * one flat list, ready to feed to `WeaselRenderer.render(commands)`.\n *\n * Visibility resolution order:\n * 1. `alwaysOn` — always drawn, ignores visibility map.\n * 2. Explicit entry in `visibility` map — overrides default.\n * 3. `layer.defaultVisible` — falls back to `true` when absent.\n *\n * Transform composition: world-space layers (the default; `space` unset or\n * `'world'`) have their commands wrapped in a `kind: 'group'` with\n * `viewToMat3(view)` before they reach the renderer. Screen-space layers\n * (`space: 'screen'`) pass through unchanged.\n *\n * A layer whose `draw` throws is dropped for the frame and reported through\n * `onLayerError` — the rest of the frame still paints.\n *\n * `groups` brackets runs of consecutive layers so they composite as one — see\n * `LayerGroup`. A layer named by no group is emitted exactly as it was before\n * groups existed, and a frame that declares none allocates nothing.\n *\n * `spans`, when passed, receives one {@link LayerDrawSpan} per layer drawn.\n */\nexport function drawLayers<TData>(\n layers: RenderLayer<TData>[],\n data: TData,\n visibility: Record<string, boolean>,\n order: string[] | undefined,\n view: View | undefined,\n dims: Dims,\n cache?: LayerCommandCache,\n onLayerError: (failure: LayerDrawFailure) => void = reportLayerFailure,\n groups?: readonly LayerGroup[],\n spans?: LayerDrawSpan[],\n): DrawCommand[] {\n const layerById = new Map(layers.map((l) => [l.id, l]));\n const sequence = order\n ? order.map((id) => layerById.get(id)).filter((l): l is RenderLayer<TData> => l !== undefined)\n : layers;\n const v = view ?? IDENTITY_VIEW;\n const out: DrawCommand[] = [];\n\n if (cache) {\n for (const id of [...cache.keys()]) {\n if (!layerById.has(id)) cache.delete(id);\n }\n }\n\n const groupOf = groupMembership(groups, layerById.keys());\n const bracketed = new Set<LayerGroup>();\n let run: { group: LayerGroup; children: DrawCommand[]; buildMs: number } | null = null;\n\n const closeRun = () => {\n if (!run) return;\n const start = out.length;\n const t0 = spans ? clockMs() : 0;\n for (const c of wrapGroup(run.group, run.children, v, dims)) out.push(c);\n spans?.push({ id: run.group.id, start, end: out.length, buildMs: run.buildMs + clockMs() - t0 });\n run = null;\n };\n\n for (const layer of sequence) {\n // `order` is already applied by `sequence`; passing it again would be a\n // second, redundant lookup for the same answer.\n if (!isLayerVisible(layer, visibility)) continue;\n\n const t0 = spans ? clockMs() : 0;\n const cmds = drawOneLayer(layer, data, v, dims, cache, onLayerError);\n const buildMs = spans ? clockMs() - t0 : 0;\n // A layer that painted nothing neither joins a run nor breaks one. Letting\n // it break one would split a group over a debug overlay that is switched\n // on but currently empty.\n if (cmds.length === 0) {\n spans?.push({ id: layer.id, start: out.length, end: out.length, buildMs });\n continue;\n }\n\n const group = groupOf?.get(layer.id);\n if (run && run.group !== group) closeRun();\n if (!group) {\n const start = out.length;\n for (const c of cmds) out.push(c);\n spans?.push({ id: layer.id, start, end: out.length, buildMs });\n continue;\n }\n if (!run) {\n if (bracketed.has(group)) {\n console.warn(\n `[weasel] layer group \"${group.id}\" is not one run — another layer is drawn ` +\n 'between its members, so it composites as more than one pass over more than ' +\n 'one buffer. Move its members together in the layer order.',\n );\n }\n bracketed.add(group);\n run = { group, children: [], buildMs: 0 };\n }\n run.buildMs += buildMs;\n for (const c of cmds) run.children.push(c);\n }\n closeRun();\n\n return out;\n}\n\n/**\n * Layer id → the group that owns it.\n *\n * A member name claims the layer of that exact id and every layer under it in\n * the `:` namespace, so `'scene'` claims the whole split scene slot. First\n * claim wins across groups, so a second one is a declaration bug rather than a\n * silent reassignment; the same group naming a layer twice — `['scene',\n * 'scene:tiles']` — is redundant, not a conflict, and passes quietly.\n */\nfunction groupMembership(\n groups: readonly LayerGroup[] | undefined,\n layerIds: Iterable<string>,\n): Map<string, LayerGroup> | null {\n if (!groups || groups.length === 0) return null;\n const stack = [...layerIds];\n const byLayer = new Map<string, LayerGroup>();\n for (const group of groups) {\n for (const name of group.layers) {\n let matched = false;\n for (const id of stack) {\n if (id !== name && !id.startsWith(`${name}:`)) continue;\n matched = true;\n const claimed = byLayer.get(id);\n if (claimed === group) continue;\n if (claimed) {\n console.warn(\n `[weasel] layer \"${id}\" is claimed by layer groups \"${claimed.id}\" and ` +\n `\"${group.id}\"; it stays in \"${claimed.id}\".`,\n );\n continue;\n }\n byLayer.set(id, group);\n }\n if (!matched) {\n console.warn(\n `[weasel] layer group \"${group.id}\" names \"${name}\", which matches no layer ` +\n 'being drawn, so it groups nothing. Check the id against the layer stack — a ' +\n 'scene with declared layers draws as \"scene:<layerId>\", which \"scene\" covers.',\n );\n }\n }\n }\n return byLayer;\n}\n\n/**\n * Put one run of a group's commands under its shared compositing.\n *\n * No transform: every member already carries its own space wrap, so a second\n * one here would apply the view twice to world layers and once to screen ones.\n * A group that composites plainly gets no wrapper at all — an extra group\n * command that changes nothing is still a push and a pop per frame.\n */\nfunction wrapGroup(\n group: LayerGroup,\n children: DrawCommand[],\n view: View,\n dims: Dims,\n): DrawCommand[] {\n const declared = typeof group.effects === 'function'\n ? group.effects(view, dims)\n : group.effects;\n const effects = declared && declared.length > 0 ? declared : undefined;\n if (!effects && group.alpha === undefined && group.colorMatrix === undefined) return children;\n return [{\n kind: 'group',\n ...(effects ? { effects } : {}),\n ...(group.alpha !== undefined ? { alpha: group.alpha } : {}),\n ...(group.colorMatrix !== undefined ? { colorMatrix: group.colorMatrix } : {}),\n children,\n }];\n}\n\n/**\n * Resolve one layer's visibility: `alwaysOn` wins, then an explicit entry in\n * `visibility`, then `defaultVisible`, defaulting to shown.\n */\nexport function isLayerVisible<TData>(\n layer: RenderLayer<TData>,\n visibility: Record<string, boolean>,\n): boolean {\n if (layer.alwaysOn) return true;\n if (layer.id in visibility) return visibility[layer.id]!;\n return layer.defaultVisible ?? true;\n}\n\n/**\n * Does this layer reach the screen at all — both gates, in the order\n * `drawLayers` applies them.\n *\n * **A listed `order` is the whole list**, so omission from it drops a layer\n * that `visibility` would have shown, and `alwaysOn` does not rescue it.\n * Hit-testing asks this, not `isLayerVisible`: a layer that is not painted\n * but still claims pointer events is a pointer landing on nothing the user\n * can see.\n */\nexport function isLayerPainted<TData>(\n layer: RenderLayer<TData>,\n visibility: Record<string, boolean>,\n order: string[] | undefined,\n): boolean {\n if (order && !order.includes(layer.id)) return false;\n return isLayerVisible(layer, visibility);\n}\n\n/**\n * Draw one layer and put its commands in the space its `space` declares:\n * world-space output wrapped in a `viewToMat3(view)` group, screen-space\n * output passed through.\n *\n * Anything rendering layers through a view — the canvas itself, a viewport\n * node's inner pass — goes through here. A second copy of this rule that\n * forgets the wrap draws world content at raw world coords, which looks\n * plausible at the identity view and wrong everywhere else.\n *\n * A `draw` that throws yields no commands, and `onLayerError` is told which\n * layer it was. The layer's cache entry goes with it, so the next frame is a\n * real re-attempt rather than a stale tree served under fresh deps.\n */\nexport function drawOneLayer<TData>(\n layer: RenderLayer<TData>,\n data: TData,\n view: View,\n dims: Dims,\n cache?: LayerCommandCache,\n onLayerError: (failure: LayerDrawFailure) => void = reportLayerFailure,\n): DrawCommand[] {\n let cmds: DrawCommand[];\n try {\n cmds = layerCommands(layer, data, view, dims, cache);\n } catch (error) {\n cache?.delete(layer.id);\n onLayerError({ layerId: layer.id, error });\n return [];\n }\n if (cmds.length === 0) return [];\n const effects = layer.effects && layer.effects.length > 0 ? layer.effects : undefined;\n if ((layer.space ?? 'world') === 'screen') {\n return effects ? [{ kind: 'group', effects, children: cmds }] : cmds;\n }\n return [{ kind: 'group', transform: viewToMat3(view), ...(effects ? { effects } : {}), children: cmds }];\n}\n\n/**\n * One layer's own commands, from cache when its deps are unchanged.\n *\n * What is cached is the layer's raw output, before the space wrap above. The\n * wrap is a function of `view`, and a layer whose content does not depend on\n * the camera is entitled to leave `view` out of its deps — caching the wrapped\n * group would then serve a stale transform the moment the camera moved.\n */\nfunction layerCommands<TData>(\n layer: RenderLayer<TData>,\n data: TData,\n view: View,\n dims: Dims,\n cache: LayerCommandCache | undefined,\n): DrawCommand[] {\n if (!cache || !layer.deps) return layer.draw(data, view, dims);\n\n const deps = layer.deps(data, view, dims);\n const entry = cache.get(layer.id);\n if (entry && depsUnchanged(entry.deps, deps)) return entry.cmds;\n\n const cmds = layer.draw(data, view, dims);\n cache.set(layer.id, { deps, cmds });\n return cmds;\n}\n\n/** Whether `b` matches `a` entry for entry under `Object.is` — how\n * `RenderLayer.deps` is compared, and any cache keyed the same way. */\nexport function depsUnchanged(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false;\n }\n return true;\n}\n"],"mappings":";;AAIA,IAAMA,IAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE;AA0BhE,SAASC,EAAmB,EAAE,YAAS,YAAiC;CACtE,QAAQ,MACN,mBAAmBC,EAAQ,w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AO;CAErC,OAAO;AACT"}
1
+ {"version":3,"file":"render.js","names":["IDENTITY_VIEW","reportLayerFailure","layerId","error","subscribeToSources","offs","sources","l","listener","off","clockMs","drawLayers","layerById","layers","view","out","cache","id","groupOf","groupMembership","groups","bracketed","run","closeRun","start","t0","spans","c","wrapGroup","dims","layer","paintedLayers","visibility","order","cmds","drawOneLayer","data","onLayerError","buildMs","group","isLayerVisible","isLayerPainted","byId","layerCommands","effects","viewToMat3","deps","entry","depsUnchanged","a","b","i"],"sources":["../../../src/core/layers/render.ts"],"sourcesContent":["import { viewToMat3, type DrawCommand } from '@weasel-js/renderer';\nimport type { Effect } from '@weasel-js/renderer';\nimport type { View } from 'core/viewport/view';\nimport { groupMembership, wrapGroup, type LayerGroup } from './layerGroup';\n\nexport type { LayerGroup };\n\nconst IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n\n/** Canvas size in CSS pixels, so layers don't have to know about DPR. */\nexport interface Dims {\n width: number;\n height: number;\n}\n\n/**\n * What a layer's `draw` threw, and which layer threw it. A throw that escaped\n * the frame loop would take the whole frame with it, every other layer\n * included.\n */\nexport interface LayerDrawFailure {\n layerId: string;\n error: unknown;\n}\n\n/** Default report: name the layer, keep the frame. */\nfunction reportLayerFailure({ layerId, error }: LayerDrawFailure): void {\n console.error(\n `[weasel] layer \"${layerId}\" threw while drawing; it painted nothing this frame.`,\n error,\n );\n}\n\n/** One layer's memoized output, keyed by layer id. Owned by the canvas that\n * calls `drawLayers`, not by `drawLayers` itself — the function is pure. */\nexport type LayerCommandCache = Map<\n string,\n { deps: readonly unknown[]; cmds: DrawCommand[] }\n>;\n\n/** Something outside React whose changes a paint reads — a mode registry, a\n * scoping lookup. A notification repaints the canvas; the listener takes no\n * arguments and the returned function unsubscribes. */\nexport interface RedrawSource {\n subscribe(listener: () => void): () => void;\n}\n\n/** The `subscribe` for a layer that draws `sources`: it notifies whenever any\n * of them does. A thunk is read when the subscription is made. */\nexport function subscribeToSources(\n sources: readonly { subscribe?: RedrawSource['subscribe'] }[]\n | (() => readonly { subscribe?: RedrawSource['subscribe'] }[]),\n): RedrawSource['subscribe'] {\n return (listener) => {\n const list = typeof sources === 'function' ? sources() : sources;\n const offs = list.flatMap((l) => (l.subscribe ? [l.subscribe(listener)] : []));\n return () => { for (const off of offs) off(); };\n };\n}\n\n/**\n * One layer of a canvas: `draw` turns `data` and the view into draw commands;\n * the other fields control caching, visibility, coordinate space and hit-testing.\n *\n * @template TData - The data object passed to each draw call.\n */\nexport interface RenderLayer<TData> {\n /** Unique identifier used in visibility maps and ordering arrays. When a\n * cache is in use, an id must identify the same logical layer across\n * frames — reusing it for a different layer can serve cross-layer commands. */\n id: string;\n /** Human-readable name for UI toggles. */\n label: string;\n /**\n * Emit a DrawCommand tree, in the coordinates `space` names. A world-space\n * layer must NOT apply the view transform itself.\n */\n draw: (data: TData, view: View, dims: Dims) => DrawCommand[];\n /**\n * Optional cache key. When present and a `LayerCommandCache` is supplied to\n * `drawLayers`, the layer's previous `DrawCommand[]` is reused as long as\n * every entry is `Object.is`-equal to the previous call's. A layer with no\n * `deps` rebuilds on every frame.\n *\n * **The returned commands must be treated as immutable.** A cached tree is\n * handed to the renderer again on later frames, so mutating a tree you\n * previously returned corrupts the cache silently rather than erroring.\n *\n * **Screen-space layers are not protected against a stale `view`/`dims`\n * the way world-space layers are** (see `space` below) — include them in\n * `deps` if `draw` reads them.\n */\n deps?: (data: TData, view: View, dims: Dims) => readonly unknown[];\n /** Whether the layer is shown when no explicit visibility entry exists.\n * Defaults to `true` when absent. */\n defaultVisible?: boolean;\n /** When true, the layer is always drawn regardless of the visibility map. */\n alwaysOn?: boolean;\n /**\n * Coordinate space the layer draws in.\n *\n * - `'world'` (default): the layer's `draw` returns world-space commands;\n * `drawLayers` wraps them in a `kind: 'group'` with `viewToMat3(view)`\n * automatically.\n * - `'screen'`: the layer's `draw` returns screen-space (CSS-pixel)\n * commands; `drawLayers` passes them through unchanged. World-anchored\n * chrome inside a screen-space layer must call `worldToScreen` or wrap\n * the relevant subset with `viewToMat3(view)` manually.\n */\n space?: 'world' | 'screen';\n /**\n * Where the layer learns that state `draw` reads, outside the scene and the\n * props, has changed. The canvas painting it subscribes while the layer is\n * mounted and repaints on every notification.\n */\n subscribe?: RedrawSource['subscribe'];\n /**\n * Full-screen passes run over this layer's own pixels before it joins the\n * frame. See `GroupDrawCommand.effects` for what a pass may read, and\n * {@link LayerGroup} to run one chain over several layers at once.\n */\n effects?: readonly Effect[];\n /**\n * Optional hit-test for **consumer-attached** layers.\n *\n * Only layers registered through `CanvasExtensionApi.registerLayer` are\n * hit-tested, last-registered-first, ahead of the kit's own selection\n * chrome. First non-null result wins; null means \"I don't claim this hit,\n * try the next layer.\"\n *\n * Layers that reach the draw stack some other way — a `Tool.overlay`, an\n * entry in the `layers` map — are painted but never hit-tested, so defining\n * `hitTest` on one has no effect.\n *\n * Coordinates are world-space.\n */\n hitTest?: (\n worldX: number,\n worldY: number,\n data: TData,\n view: View,\n dims: Dims,\n /** Chrome-caps visibility predicate. When supplied, the layer must\n * not return a hit from any chrome element whose id reports\n * `false`. Absent → every element is hittable. */\n isVisible?: (id: string) => boolean,\n ) => import('../../affordances/types').LayerHit | null;\n /**\n * Called on every pointermove when no gesture is currently captured, so a\n * layer can track hover state. Coords are world-space, and the layer does\n * its own throttling.\n */\n onUncapturedMove?: (\n worldX: number,\n worldY: number,\n evt: PointerEvent,\n view: View,\n dims: Dims,\n ) => void;\n /** Called when the cursor leaves the canvas element. */\n onUncapturedLeave?: () => void;\n}\n\n/** Where one layer's commands landed in {@link drawLayers}' output,\n * `[start, end)`, and the CPU milliseconds its `draw` took. A layer group's\n * run is one span under the group's id. */\nexport interface LayerDrawSpan {\n id: string;\n start: number;\n end: number;\n buildMs: number;\n}\n\nfunction clockMs(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/**\n * Walk visible layers and concatenate their emitted DrawCommand arrays into\n * one flat list, ready to feed to `WeaselRenderer.render(commands)`.\n *\n * A layer whose `draw` throws is dropped for the frame and reported through\n * `onLayerError` — the rest of the frame still paints.\n *\n * `groups` brackets runs of consecutive layers so they composite as one — see\n * `LayerGroup`. `spans`, when passed, receives one {@link LayerDrawSpan} per\n * layer drawn.\n */\nexport function drawLayers<TData>(\n layers: RenderLayer<TData>[],\n data: TData,\n visibility: Record<string, boolean>,\n order: string[] | undefined,\n view: View | undefined,\n dims: Dims,\n cache?: LayerCommandCache,\n onLayerError: (failure: LayerDrawFailure) => void = reportLayerFailure,\n groups?: readonly LayerGroup[],\n spans?: LayerDrawSpan[],\n): DrawCommand[] {\n const layerById = new Map(layers.map((l) => [l.id, l]));\n const v = view ?? IDENTITY_VIEW;\n const out: DrawCommand[] = [];\n\n if (cache) {\n for (const id of [...cache.keys()]) {\n if (!layerById.has(id)) cache.delete(id);\n }\n }\n\n const groupOf = groupMembership(groups, layerById.keys());\n const bracketed = new Set<LayerGroup>();\n let run: { group: LayerGroup; children: DrawCommand[]; buildMs: number } | null = null;\n\n const closeRun = () => {\n if (!run) return;\n const start = out.length;\n const t0 = spans ? clockMs() : 0;\n for (const c of wrapGroup(run.group, run.children, v, dims)) out.push(c);\n spans?.push({ id: run.group.id, start, end: out.length, buildMs: run.buildMs + clockMs() - t0 });\n run = null;\n };\n\n for (const layer of paintedLayers(layers, visibility, order)) {\n const t0 = spans ? clockMs() : 0;\n const cmds = drawOneLayer(layer, data, v, dims, cache, onLayerError);\n const buildMs = spans ? clockMs() - t0 : 0;\n // A layer that painted nothing neither joins a run nor breaks one.\n if (cmds.length === 0) {\n spans?.push({ id: layer.id, start: out.length, end: out.length, buildMs });\n continue;\n }\n\n const group = groupOf?.get(layer.id);\n if (run && run.group !== group) closeRun();\n if (!group) {\n const start = out.length;\n for (const c of cmds) out.push(c);\n spans?.push({ id: layer.id, start, end: out.length, buildMs });\n continue;\n }\n if (!run) {\n if (bracketed.has(group)) {\n console.warn(\n `[weasel] layer group \"${group.id}\" is not one run — another layer is drawn ` +\n 'between its members, so it composites as more than one pass over more than ' +\n 'one buffer. Move its members together in the layer order.',\n );\n }\n bracketed.add(group);\n run = { group, children: [], buildMs: 0 };\n }\n run.buildMs += buildMs;\n for (const c of cmds) run.children.push(c);\n }\n closeRun();\n\n return out;\n}\n\n/**\n * Resolve one layer's visibility: `alwaysOn` wins, then an explicit entry in\n * `visibility`, then `defaultVisible`, defaulting to shown.\n */\nexport function isLayerVisible<TData>(\n layer: RenderLayer<TData>,\n visibility: Record<string, boolean>,\n): boolean {\n if (layer.alwaysOn) return true;\n if (layer.id in visibility) return visibility[layer.id]!;\n return layer.defaultVisible ?? true;\n}\n\n/**\n * Does this layer reach the screen at all — membership of\n * {@link paintedLayers}, asked of one layer.\n *\n * **A listed `order` is the whole list**, so omission from it drops a layer\n * that `visibility` would have shown, and `alwaysOn` does not rescue it.\n * Hit-testing asks this, not `isLayerVisible`.\n */\nexport function isLayerPainted<TData>(\n layer: RenderLayer<TData>,\n visibility: Record<string, boolean>,\n order: readonly string[] | undefined,\n): boolean {\n if (order && !order.includes(layer.id)) return false;\n return isLayerVisible(layer, visibility);\n}\n\n/**\n * The layers that reach the screen, in the order they are drawn: `order`\n * sequences them and drops what it leaves out, then `visibility` drops what is\n * hidden. What `drawLayers` paints, and what a view narrows its stack with.\n */\nexport function paintedLayers<TData>(\n layers: readonly RenderLayer<TData>[],\n visibility: Record<string, boolean>,\n order: readonly string[] | undefined,\n): RenderLayer<TData>[] {\n if (!order) return layers.filter((l) => isLayerVisible(l, visibility));\n const byId = new Map(layers.map((l) => [l.id, l]));\n return order\n .map((id) => byId.get(id))\n .filter((l): l is RenderLayer<TData> => l !== undefined && isLayerVisible(l, visibility));\n}\n\n/**\n * Draw one layer and put its commands in the space its `space` declares:\n * world-space output wrapped in a `viewToMat3(view)` group, screen-space\n * output passed through.\n *\n * Anything rendering layers through a view goes through here.\n *\n * A `draw` that throws yields no commands, and `onLayerError` is told which\n * layer it was. The layer's cache entry goes with it, so the next frame is a\n * real re-attempt.\n */\nexport function drawOneLayer<TData>(\n layer: RenderLayer<TData>,\n data: TData,\n view: View,\n dims: Dims,\n cache?: LayerCommandCache,\n onLayerError: (failure: LayerDrawFailure) => void = reportLayerFailure,\n): DrawCommand[] {\n let cmds: DrawCommand[];\n try {\n cmds = layerCommands(layer, data, view, dims, cache);\n } catch (error) {\n cache?.delete(layer.id);\n onLayerError({ layerId: layer.id, error });\n return [];\n }\n if (cmds.length === 0) return [];\n const effects = layer.effects && layer.effects.length > 0 ? layer.effects : undefined;\n if ((layer.space ?? 'world') === 'screen') {\n return effects ? [{ kind: 'group', effects, children: cmds }] : cmds;\n }\n return [{ kind: 'group', transform: viewToMat3(view), ...(effects ? { effects } : {}), children: cmds }];\n}\n\n/**\n * One layer's own commands, from cache when its deps are unchanged.\n *\n * What is cached is the layer's raw output, before the space wrap above. The\n * wrap is a function of `view`, and a layer whose content does not depend on\n * the camera is entitled to leave `view` out of its deps — caching the wrapped\n * group would then serve a stale transform the moment the camera moved.\n */\nfunction layerCommands<TData>(\n layer: RenderLayer<TData>,\n data: TData,\n view: View,\n dims: Dims,\n cache: LayerCommandCache | undefined,\n): DrawCommand[] {\n if (!cache || !layer.deps) return layer.draw(data, view, dims);\n\n const deps = layer.deps(data, view, dims);\n const entry = cache.get(layer.id);\n if (entry && depsUnchanged(entry.deps, deps)) return entry.cmds;\n\n const cmds = layer.draw(data, view, dims);\n cache.set(layer.id, { deps, cmds });\n return cmds;\n}\n\n/** Whether `b` matches `a` entry for entry under `Object.is` — how\n * `RenderLayer.deps` is compared, and any cache keyed the same way. */\nexport function depsUnchanged(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false;\n }\n return true;\n}\n"],"mappings":";;;AAOA,IAAMA,IAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE;AAmBhE,SAASC,EAAmB,EA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OADAb,EAAM,IAAIc,EAAM,IAAI;EAAE;EAAM;CAAK,CAAC,GAC3BI;AACT;AAIA,SAAgBc,EAAc,GAAuB,GAAgC;CACnF,IAAIC,EAAE,WAAWC,EAAE,QAAQ,OAAO;CAClC,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAE,QAAQ,KAC5B,IAAI,CAAC,OAAO,GAAGA,EAAEE,IAAID,EAAEC,EAAE,GAAG,OAAO;CAErC,OAAO;AACT"}
@@ -6,6 +6,7 @@ function t(e, n, r) {
6
6
  name: "arrange",
7
7
  args: i,
8
8
  label: "Arrange",
9
+ elideNoop: !0,
9
10
  get coalesceKey() {
10
11
  return i.placed === void 0 ? void 0 : `arrange:${i.placed.map((e) => e.id).sort().join(",")}`;
11
12
  },
@@ -1 +1 @@
1
- {"version":3,"file":"arrange.js","names":["createArrangeOp","self","args","p","compute","set","write","adapter","id","pose","registerOpFactory"],"sources":["../../../src/core/ops/arrange.ts"],"sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface ArrangeAdapter {\n setPose(id: string, pose: unknown): void;\n}\n\n/** One pose write an {@link createArrangeOp} made. */\nexport interface ArrangedPose {\n id: string;\n from: unknown;\n to: unknown;\n}\n\n/** Arguments to {@link createArrangeOp}. */\nexport interface ArrangeArgs {\n /** The writes to make. Absent until a computed arrangement has run once. */\n placed?: ArrangedPose[];\n}\n\n/**\n * Op: write a set of poses decided when the op first applies, not when it is\n * built. The scene appends one to an edit that moves nodes into a container,\n * and `compute` asks the container what to do with them after the rest of\n * the edit has landed. Every later apply — redo, or a rebuild from a\n * serialized history — replays the writes it recorded, so the arrangement is\n * decided once. `write` replaces the adapter's `setPose` for this op and its\n * inverses — the scene passes its own, since not every adapter an edit is\n * applied through can write poses.\n */\nexport function createArrangeOp(\n args: ArrangeArgs,\n compute?: () => ArrangedPose[],\n write?: (id: string, pose: unknown) => void,\n): Op {\n const self: ArrangeArgs = { ...(args.placed ? { placed: args.placed } : {}) };\n return {\n name: 'arrange',\n args: self,\n label: 'Arrange',\n // Names what it moved, so a coalesced entry never undoes to a pose only\n // a later push wrote.\n get coalesceKey() {\n return self.placed === undefined ? undefined : `arrange:${self.placed.map((p) => p.id).sort().join(',')}`;\n },\n apply(adapter) {\n if (self.placed === undefined) self.placed = compute?.() ?? [];\n const set = write ?? ((id: string, pose: unknown) => (adapter as ArrangeAdapter).setPose(id, pose));\n for (const p of self.placed) set(p.id, p.to);\n return self.placed.length > 0 ? undefined : 'noop';\n },\n invert() {\n const placed = self.placed ?? [];\n return createArrangeOp({\n placed: [...placed].reverse().map((p) => ({ id: p.id, from: p.to, to: p.from })),\n }, undefined, write);\n },\n };\n}\n\nregisterOpFactory<ArrangeArgs>('arrange', (args) => createArrangeOp(args));\n"],"mappings":";;AA8BA,SAAgBA,EACd,GACA,GACA,GACI;CACJ,IAAMC,IAAoB,EAAE,GAAIC,EAAK,SAAS,EAAE,QAAQA,EAAK,OAAO,IAAI,CAAC,EAAG;CAC5E,OAAO;EACL,MAAM;EACN,MAAMD;EACN,OAAO;EAGP,IAAI,cAAc;GAChB,OAAOA,EAAK,WAAW,KAAA,IAAY,KAAA,IAAY,WAAWA,EAAK,OAAO,KAAK,MAAME,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EACxG;EACA,MAAM,GAAS;GACb,AAAIF,EAAK,WAAW,KAAA,MAAW,EAAK,SAASG,IAAU,KAAK,CAAC;GAC7D,IAAMC,IAAMC,OAAW,GAAY,MAAmBC,EAA2B,QAAQC,GAAIC,CAAI;GACjG,KAAK,IAAMN,KAAKF,EAAK,QAAQ,EAAIE,EAAE,IAAIA,EAAE,EAAE;GAC3C,OAAOF,EAAK,OAAO,SAAS,IAAI,KAAA,IAAY;EAC9C;EACA,SAAS;GAEP,OAAOD,EAAgB,EACrB,QAAQ,CAAC,GAFIC,EAAK,UAAU,CAAC,CAEX,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,OAAO;IAAE,IAAIE,EAAE;IAAI,MAAMA,EAAE;IAAI,IAAIA,EAAE;GAAK,EAAE,EACjF,GAAG,KAAA,GAAWG,CAAK;EACrB;CACF;AACF;AAEAI,EAA+B,YAAY,MAASV,EAAgBE,CAAI,CAAC"}
1
+ {"version":3,"file":"arrange.js","names":["createArrangeOp","self","args","p","compute","set","write","adapter","id","pose","registerOpFactory"],"sources":["../../../src/core/ops/arrange.ts"],"sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface ArrangeAdapter {\n setPose(id: string, pose: unknown): void;\n}\n\n/** One pose write an {@link createArrangeOp} made. */\nexport interface ArrangedPose {\n id: string;\n from: unknown;\n to: unknown;\n}\n\n/** Arguments to {@link createArrangeOp}. */\nexport interface ArrangeArgs {\n /** The writes to make. Absent until a computed arrangement has run once. */\n placed?: ArrangedPose[];\n}\n\n/**\n * Op: write a set of poses decided when the op first applies, not when it is\n * built. The scene appends one to an edit that moves nodes into a container,\n * and `compute` asks the container what to do with them after the rest of\n * the edit has landed. Every later apply — redo, or a rebuild from a\n * serialized history — replays the writes it recorded, so the arrangement is\n * decided once. `write` replaces the adapter's `setPose` for this op and its\n * inverses — the scene passes its own, since not every adapter an edit is\n * applied through can write poses.\n */\nexport function createArrangeOp(\n args: ArrangeArgs,\n compute?: () => ArrangedPose[],\n write?: (id: string, pose: unknown) => void,\n): Op {\n const self: ArrangeArgs = { ...(args.placed ? { placed: args.placed } : {}) };\n return {\n name: 'arrange',\n args: self,\n label: 'Arrange',\n elideNoop: true,\n // Names what it moved, so a coalesced entry never undoes to a pose only\n // a later push wrote.\n get coalesceKey() {\n return self.placed === undefined ? undefined : `arrange:${self.placed.map((p) => p.id).sort().join(',')}`;\n },\n apply(adapter) {\n if (self.placed === undefined) self.placed = compute?.() ?? [];\n const set = write ?? ((id: string, pose: unknown) => (adapter as ArrangeAdapter).setPose(id, pose));\n for (const p of self.placed) set(p.id, p.to);\n return self.placed.length > 0 ? undefined : 'noop';\n },\n invert() {\n const placed = self.placed ?? [];\n return createArrangeOp({\n placed: [...placed].reverse().map((p) => ({ id: p.id, from: p.to, to: p.from })),\n }, undefined, write);\n },\n };\n}\n\nregisterOpFactory<ArrangeArgs>('arrange', (args) => createArrangeOp(args));\n"],"mappings":";;AA8BA,SAAgBA,EACd,GACA,GACA,GACI;CACJ,IAAMC,IAAoB,EAAE,GAAIC,EAAK,SAAS,EAAE,QAAQA,EAAK,OAAO,IAAI,CAAC,EAAG;CAC5E,OAAO;EACL,MAAM;EACN,MAAMD;EACN,OAAO;EACP,WAAW;EAGX,IAAI,cAAc;GAChB,OAAOA,EAAK,WAAW,KAAA,IAAY,KAAA,IAAY,WAAWA,EAAK,OAAO,KAAK,MAAME,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG;EACxG;EACA,MAAM,GAAS;GACb,AAAIF,EAAK,WAAW,KAAA,MAAW,EAAK,SAASG,IAAU,KAAK,CAAC;GAC7D,IAAMC,IAAMC,OAAW,GAAY,MAAmBC,EAA2B,QAAQC,GAAIC,CAAI;GACjG,KAAK,IAAMN,KAAKF,EAAK,QAAQ,EAAIE,EAAE,IAAIA,EAAE,EAAE;GAC3C,OAAOF,EAAK,OAAO,SAAS,IAAI,KAAA,IAAY;EAC9C;EACA,SAAS;GAEP,OAAOD,EAAgB,EACrB,QAAQ,CAAC,GAFIC,EAAK,UAAU,CAAC,CAEX,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,OAAO;IAAE,IAAIE,EAAE;IAAI,MAAMA,EAAE;IAAI,IAAIA,EAAE;GAAK,EAAE,EACjF,GAAG,KAAA,GAAWG,CAAK;EACrB;CACF;AACF;AAEAI,EAA+B,YAAY,MAASV,EAAgBE,CAAI,CAAC"}
@@ -3,24 +3,29 @@ import { parentOf as t, resolveSlot as n, slotFromIndex as r } from "./slot.js";
3
3
  import { createDeleteOp as i } from "./delete.js";
4
4
  //#region src/core/ops/create.ts
5
5
  function a(e) {
6
- let { node: a, label: o } = e, s = e.slot ?? r(e.index);
6
+ let { node: a, label: o, cascaded: s } = e, c = e.slot ?? r(e.index);
7
7
  return {
8
8
  name: "insert",
9
9
  args: {
10
10
  node: a,
11
11
  label: o,
12
- slot: s
12
+ slot: c,
13
+ ...s ? { cascaded: s } : {}
13
14
  },
14
15
  label: o,
15
16
  apply(e) {
16
- let r = e, i = t(a);
17
- r.insertNode(a, n(r.getChildren?.(i), s));
17
+ let r = e, i = () => {
18
+ r.insertNode(a, n(r.getChildren?.(t(a)), c));
19
+ };
20
+ if (!s || s.length === 0) return i();
21
+ for (let e of s) r.getNode?.(e.node.id) || (e.node.id === a.id ? i() : r.insertNode(e.node, e.index));
18
22
  },
19
23
  invert() {
20
24
  return i({
21
25
  node: a,
22
26
  label: o,
23
- slot: s
27
+ slot: c,
28
+ ...s ? { cascaded: s } : {}
24
29
  });
25
30
  }
26
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","names":["createInsertOp","args","slot","slotFromIndex","a","adapter","parentId","parentOf","node","resolveSlot","createDeleteOp","registerOpFactory"],"sources":["../../../src/core/ops/create.ts"],"sourcesContent":["import type { Op } from './types';\nimport { createDeleteOp } from './delete';\nimport { registerOpFactory } from './registry';\nimport { parentOf, resolveSlot, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface InsertAdapter<TNode> extends OrderedReader {\n /** When `index` is supplied, insert at that position; adapters that ignore\n * the second arg (or don't expose it) fall back to their default\n * placement (typically append-to-end). */\n insertNode(node: TNode, index?: number): void;\n}\n\n/** Type alias for ops produced by `createInsertOp`. Carries no extra type info today;\n * exists so consumers can name the op type when needed. */\nexport type InsertOp = Op;\n\n/** Arguments to {@link createInsertOp}: the node to insert and where among its siblings. */\nexport interface InsertArgs<TNode extends { id: string }> {\n node: TNode;\n label?: string;\n /** Sibling ordinal to insert at. Sugar for `slot: { index }` — the weaker\n * of the two forms, and all a fresh-insert callsite can know. */\n index?: number;\n /** Full slot, anchor included. Produced only by `captureSlot` (via a\n * delete op's `invert`), and supersedes `index` when present. */\n slot?: SiblingSlot;\n}\n\n/** Op: insert `node` into the scene; inverts to a delete of the same id. */\nexport function createInsertOp<TNode extends { id: string }>(args: InsertArgs<TNode>): InsertOp {\n const { node, label } = args;\n const slot: SiblingSlot = args.slot ?? slotFromIndex(args.index);\n return {\n name: 'insert',\n args: { node, label, slot },\n label,\n apply(adapter) {\n const a = adapter as InsertAdapter<TNode>;\n const parentId = parentOf(node);\n a.insertNode(node, resolveSlot(a.getChildren?.(parentId), slot));\n },\n invert() {\n return createDeleteOp({ node, label, slot });\n },\n };\n}\n\nregisterOpFactory<InsertArgs<{ id: string }>>('insert', (args) => createInsertOp(args));\n"],"mappings":";;;;AA6BA,SAAgBA,EAA6C,GAAmC;CAC9F,IAAM,EAAE,SAAM,aAAUC,GAClBC,IAAoBD,EAAK,QAAQE,EAAcF,EAAK,KAAK;CAC/D,OAAO;EACL,MAAM;EACN,MAAM;GAAE;GAAM;GAAO;EAAK;EAC1B;EACA,MAAM,GAAS;GACb,IAAMG,IAAIC,GACJC,IAAWC,EAASC,CAAI;GAC9B,EAAE,WAAWA,GAAMC,EAAYL,EAAE,cAAcE,CAAQ,GAAGJ,CAAI,CAAC;EACjE;EACA,SAAS;GACP,OAAOQ,EAAe;IAAE;IAAM;IAAO;GAAK,CAAC;EAC7C;CACF;AACF;AAEAC,EAA8C,WAAW,MAASX,EAAeC,CAAI,CAAC"}
1
+ {"version":3,"file":"create.js","names":["createInsertOp","args","slot","slotFromIndex","cascaded","a","adapter","insertRoot","node","resolveSlot","parentOf","entry","createDeleteOp","registerOpFactory"],"sources":["../../../src/core/ops/create.ts"],"sourcesContent":["import type { Op } from './types';\nimport { createDeleteOp, type PlacedNode } from './delete';\nimport { registerOpFactory } from './registry';\nimport { parentOf, resolveSlot, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface InsertAdapter<TNode> extends OrderedReader {\n getNode?(id: string): TNode | undefined;\n /** When `index` is supplied, insert at that position; adapters that ignore\n * the second arg (or don't expose it) fall back to their default\n * placement (typically append-to-end). */\n insertNode(node: TNode, index?: number): void;\n}\n\n/** Type alias for ops produced by `createInsertOp`. Carries no extra type info today;\n * exists so consumers can name the op type when needed. */\nexport type InsertOp = Op;\n\n/** Arguments to {@link createInsertOp}: the node to insert and where among its siblings. */\nexport interface InsertArgs<TNode extends { id: string }> {\n node: TNode;\n label?: string;\n /** Sibling ordinal to insert at. Sugar for `slot: { index }` — the weaker\n * of the two forms, and all a fresh-insert callsite can know. */\n index?: number;\n /** Full slot, anchor included. Produced only by `captureSlot` (via a\n * delete op's `invert`), and supersedes `index` when present. */\n slot?: SiblingSlot;\n /** Every node to insert, `node` itself included, each at its ordinal among\n * its own parent's children and ordered so a parent precedes its children.\n * What a delete's `cascaded` captures, and how its inverse brings the whole\n * set back; `node` still goes in at `slot`. One already present is skipped. */\n cascaded?: PlacedNode<TNode>[];\n}\n\n/** Op: insert `node`, and the rest of `cascaded` with it; inverts to a delete\n * of `node`. */\nexport function createInsertOp<TNode extends { id: string }>(args: InsertArgs<TNode>): InsertOp {\n const { node, label, cascaded } = args;\n const slot: SiblingSlot = args.slot ?? slotFromIndex(args.index);\n return {\n name: 'insert',\n args: { node, label, slot, ...(cascaded ? { cascaded } : {}) },\n label,\n apply(adapter) {\n const a = adapter as InsertAdapter<TNode>;\n const insertRoot = (): void => {\n a.insertNode(node, resolveSlot(a.getChildren?.(parentOf(node)), slot));\n };\n if (!cascaded || cascaded.length === 0) return insertRoot();\n for (const entry of cascaded) {\n // A flat adapter's removeNode doesn't cascade, so its children\n // were never gone — re-inserting them would duplicate them.\n if (a.getNode?.(entry.node.id)) continue;\n if (entry.node.id === node.id) insertRoot();\n else a.insertNode(entry.node, entry.index);\n }\n },\n invert() {\n return createDeleteOp({ node, label, slot, ...(cascaded ? { cascaded } : {}) });\n },\n };\n}\n\nregisterOpFactory<InsertArgs<{ id: string }>>('insert', (args) => createInsertOp(args));\n"],"mappings":";;;;AAoCA,SAAgBA,EAA6C,GAAmC;CAC9F,IAAM,EAAE,SAAM,UAAO,gBAAaC,GAC5BC,IAAoBD,EAAK,QAAQE,EAAcF,EAAK,KAAK;CAC/D,OAAO;EACL,MAAM;EACN,MAAM;GAAE;GAAM;GAAO;GAAM,GAAIG,IAAW,EAAE,YAAS,IAAI,CAAC;EAAG;EAC7D;EACA,MAAM,GAAS;GACb,IAAMC,IAAIC,GACJC,UAAyB;IAC7B,EAAE,WAAWC,GAAMC,EAAYJ,EAAE,cAAcK,EAASF,CAAI,CAAC,GAAGN,CAAI,CAAC;GACvE;GACA,IAAI,CAACE,KAAYA,EAAS,WAAW,GAAG,OAAOG,EAAW;GAC1D,KAAK,IAAMI,KAASP,GAGlB,AAAIC,EAAE,UAAUM,EAAM,KAAK,EAAE,MACzBA,EAAM,KAAK,OAAOH,EAAK,KAAID,EAAW,IACrCF,EAAE,WAAWM,EAAM,MAAMA,EAAM,KAAK;EAE7C;EACA,SAAS;GACP,OAAOC,EAAe;IAAE;IAAM;IAAO;IAAM,GAAIR,IAAW,EAAE,YAAS,IAAI,CAAC;GAAG,CAAC;EAChF;CACF;AACF;AAEAS,EAA8C,WAAW,MAASb,EAAeC,CAAI,CAAC"}
@@ -1,17 +1,17 @@
1
- import { rebuildOp as e } from "./registry.js";
2
- import { dlog as t, dwarn as n } from "../../debug/flag.js";
1
+ import { dlog as e, dwarn as t } from "../../debug/flag.js";
2
+ import { rebuildOp as n } from "./registry.js";
3
3
  import { createHistory as r } from "@weasel-js/history";
4
4
  //#region src/core/ops/createHistory.ts
5
5
  var i = {
6
- log: (e) => t("history", e),
7
- warn: (e) => n("history", e)
6
+ log: (t) => e("history", t),
7
+ warn: (e) => t("history", e)
8
8
  };
9
- function a(t, n = {}) {
10
- let a = n.rebuildOp;
11
- return r(t, {
9
+ function a(e, t = {}) {
10
+ let a = t.rebuildOp;
11
+ return r(e, {
12
12
  debug: i,
13
- ...n,
14
- rebuildOp: (t, n) => a?.(t, n) ?? e(t, n)
13
+ ...t,
14
+ rebuildOp: (e, t) => a?.(e, t) ?? n(e, t)
15
15
  });
16
16
  }
17
17
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"createHistory.js","names":["createHistory","createHistoryEngine","kitLogger","dlog","message","dwarn","createHistory$1","custom","options","createHistory","adapter","name","args","rebuildOp"],"sources":["../../../src/core/ops/createHistory.ts"],"sourcesContent":["import {\n createHistory as createHistoryEngine,\n type History,\n type CreateHistoryOptions,\n type HistoryLogger,\n} from '@weasel-js/history';\nimport { rebuildOp } from './registry';\nimport { dlog, dwarn } from '../../debug/flag';\n\n/** Routes the engine's diagnostics into the kit's `history` debug namespace,\n * so `localStorage.setItem('weasel.debug', '1')` still surfaces them. */\nconst kitLogger: HistoryLogger = {\n log: (message) => dlog('history', message),\n warn: (message) => dwarn('history', message),\n};\n\n/**\n * Build an op-batched undo/redo `History`, defaulting restore-time op\n * hydration to core's global op-factory registry and its diagnostics to the\n * kit's debug namespace.\n *\n * The engine in `@weasel-js/history` is registry-agnostic: it can only rebuild\n * a serialized `(name, args)` pair through the `rebuildOp` hook it is handed,\n * which is what lets that package build without depending on core. Core owns\n * the registry, so this wrapper supplies it — meaning `createHistory(adapter)`\n * with no options still restores kit-emitted ops, exactly as before.\n *\n * A caller-supplied `rebuildOp` wins; return `null` from it to fall through to\n * the registry.\n */\nexport function createHistory(adapter: unknown, options: CreateHistoryOptions = {}): History {\n const custom = options.rebuildOp;\n return createHistoryEngine(adapter, {\n debug: kitLogger,\n ...options,\n rebuildOp: (name, args) => custom?.(name, args) ?? rebuildOp(name, args),\n });\n}\n"],"mappings":";;;;AAWA,IAAME,IAA2B;CAC/B,MAAM,MAAYC,EAAK,WAAWC,CAAO;CACzC,OAAO,MAAYC,EAAM,WAAWD,CAAO;AAC7C;AAgBA,SAAgBJ,EAAc,GAAkB,IAAgC,CAAC,GAAY;CAC3F,IAAMO,IAASC,EAAQ;CACvB,OAAOP,EAAoBS,GAAS;EAClC,OAAOR;EACP,GAAGM;EACH,YAAY,GAAM,MAASD,IAASI,GAAMC,CAAI,KAAKC,EAAUF,GAAMC,CAAI;CACzE,CAAC;AACH"}
1
+ {"version":3,"file":"createHistory.js","names":["createHistory","createHistoryEngine","kitLogger","dlog","message","dwarn","createHistory$1","custom","options","createHistory","adapter","name","args","rebuildOp"],"sources":["../../../src/core/ops/createHistory.ts"],"sourcesContent":["import {\n createHistory as createHistoryEngine,\n type History,\n type CreateHistoryOptions,\n type HistoryLogger,\n} from '@weasel-js/history';\nimport { rebuildOp } from './registry';\nimport { dlog, dwarn } from '../../debug/flag';\n\n/** Routes the engine's diagnostics into the kit's `history` debug namespace,\n * so `localStorage.setItem('weasel.debug', '1')` still surfaces them. */\nconst kitLogger: HistoryLogger = {\n log: (message) => dlog('history', message),\n warn: (message) => dwarn('history', message),\n};\n\n/**\n * Build an op-batched undo/redo `History`, defaulting restore-time op\n * hydration to core's global op-factory registry and its diagnostics to the\n * kit's debug namespace. A caller-supplied `rebuildOp` wins; return `null`\n * from it to fall through to the registry.\n */\nexport function createHistory(adapter: unknown, options: CreateHistoryOptions = {}): History {\n const custom = options.rebuildOp;\n return createHistoryEngine(adapter, {\n debug: kitLogger,\n ...options,\n rebuildOp: (name, args) => custom?.(name, args) ?? rebuildOp(name, args),\n });\n}\n"],"mappings":";;;;AAWA,IAAME,IAA2B;CAC/B,MAAM,MAAYC,EAAK,WAAWC,CAAO;CACzC,OAAO,MAAYC,EAAM,WAAWD,CAAO;AAC7C;AAQA,SAAgBJ,EAAc,GAAkB,IAAgC,CAAC,GAAY;CAC3F,IAAMO,IAASC,EAAQ;CACvB,OAAOP,EAAoBS,GAAS;EAClC,OAAOR;EACP,GAAGM;EACH,YAAY,GAAM,MAASD,IAASI,GAAMC,CAAI,KAAKC,EAAUF,GAAMC,CAAI;CACzE,CAAC;AACH"}
@@ -44,41 +44,29 @@ function o(e, t) {
44
44
  return l;
45
45
  }
46
46
  function s(e) {
47
- let { node: a, label: c } = e, l = e.slot ?? r(e.index), u = {
47
+ let { node: a, label: s } = e, c = e.slot ?? r(e.index), l = {
48
48
  node: a,
49
- label: c,
50
- slot: l,
49
+ label: s,
50
+ slot: c,
51
51
  cascaded: e.cascaded
52
- }, d = e.cascaded ?? [];
52
+ }, u = e.cascaded ?? [];
53
53
  return {
54
54
  name: "delete",
55
- args: u,
56
- label: c,
55
+ args: l,
56
+ label: s,
57
57
  apply(e) {
58
58
  let r = e, i = t(r, n(a), a.id);
59
- i && (l = i, u.slot = i);
59
+ i && (c = i, l.slot = i);
60
60
  let s = o(r, a.id);
61
- s && (d = s, u.cascaded = s), r.removeNode(a.id);
61
+ s && (u = s, l.cascaded = s), r.removeNode(a.id);
62
62
  },
63
63
  invert() {
64
- let e = d, t = l, n = i({
64
+ return i({
65
65
  node: a,
66
- label: c,
67
- slot: t
66
+ label: s,
67
+ slot: c,
68
+ ...u.length > 0 ? { cascaded: u } : {}
68
69
  });
69
- return e.length === 0 ? n : {
70
- label: c,
71
- apply(t) {
72
- let r = t;
73
- for (let i of e) r.getNode?.(i.node.id) || (i.node.id === a.id ? n.apply(t) : r.insertNode(i.node, i.index));
74
- },
75
- invert: () => s({
76
- node: a,
77
- label: c,
78
- slot: t,
79
- cascaded: e
80
- })
81
- };
82
70
  }
83
71
  };
84
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"delete.js","names":["indexIn","a","parentId","id","captureCascade","getChildren","getNode","closure","rootId","taken","node","walk","kid","detachRoots","p","parentOf","n","l","r","out","emitSubtree","entry","kids","i","child","createDeleteOp","args","slot","slotFromIndex","argsForSerial","captured","adapter","observed","captureSlot","snapshot","cascaded","restoredSlot","reinsertRoot","createInsertOp","registerOpFactory"],"sources":["../../../src/core/ops/delete.ts"],"sourcesContent":["import type { Op } from './types';\nimport { createInsertOp } from './create';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, parentOf, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface DeleteAdapter<TNode> extends OrderedReader {\n removeNode(id: string): void;\n /** Subtree reads, used to snapshot the cascade before it runs. Optional\n * — a flat adapter has neither, and a delete there is a single node. */\n getNode?(id: string): TNode | undefined;\n /** Every id `removeNode` would take with this one. Optional: a store whose\n * removal cascades along nothing but the subtree needs no such answer, and\n * `getChildren` is enough. A store that cascades further — the kit's scene\n * takes a deleted node's dependents too — must answer here, or the nodes it\n * cascades away are absent from the snapshot and undo brings back the named\n * node alone. */\n getRemovalClosure?(ids: readonly string[]): readonly string[];\n}\n\ninterface InsertAdapter<TNode> {\n insertNode(node: TNode, index?: number): void;\n getNode?(id: string): TNode | undefined;\n}\n\n/** A captured node plus its slot in its own parent's child list. */\nexport interface PlacedNode<TNode> {\n node: TNode;\n index: number;\n}\n\n/** Arguments to {@link createDeleteOp}: the node to remove, plus what undo needs to put it back. */\nexport interface DeleteArgs<TNode extends { id: string }> {\n node: TNode;\n label?: string;\n /** Sibling ordinal the node occupies at the moment of delete. Sugar for\n * `slot: { index }`, and only a seed: `apply` re-observes the node's full\n * slot through the adapter and that observation supersedes this. Kept\n * because it is the whole story for a flat adapter with no `getChildren`,\n * where nothing can be observed. */\n index?: number;\n /** Full slot, anchor included. Written by `apply`; supersedes `index`. */\n slot?: SiblingSlot;\n /** Everything `removeNode` takes, `node` itself included — its subtree, and\n * whatever else the adapter cascades. An inverse that re-inserts `node`\n * alone brings a container back empty and leaves every dependent deleted.\n * Ordered so a node's parent precedes it, which is the order they have to\n * be re-inserted in. Captured on apply; mirrored into the serialized args so\n * a rebuilt op can invert without having run. */\n cascaded?: PlacedNode<TNode>[];\n}\n\n/** `id`'s ordinal among `parentId`'s children, or `-1` when unobservable. */\nfunction indexIn(a: OrderedReader, parentId: string | null, id: string): number {\n return a.getChildren?.(parentId)?.indexOf(id) ?? -1;\n}\n\n/**\n * Snapshot everything removing `rootId` takes with it, `rootId` included.\n *\n * Returns `null` when the adapter can't enumerate, which leaves any previously\n * captured snapshot in place rather than clobbering it with an empty one.\n *\n * The order is the whole point. A cascade unlinks several disjoint subtrees, so\n * the captured set is walked as a forest: a node whose parent is not also going\n * is a detach root, and each one is emitted — ascending sibling index first, so\n * every slot still means what it meant — followed by its captured descendants\n * preorder. The closure's own order will not do: it reaches a dependent before\n * the parent it sits under whenever that parent is in the closure as a\n * dependent too, and re-inserting a child under a parent that is not back yet\n * puts it in the wrong place.\n */\nfunction captureCascade<TNode extends { id: string }>(\n a: DeleteAdapter<TNode>,\n rootId: string,\n): PlacedNode<TNode>[] | null {\n const { getChildren, getNode } = a;\n if (!getChildren || !getNode) return null;\n\n const closure = a.getRemovalClosure?.([rootId]);\n const taken = new Map<string, TNode>();\n if (closure) {\n for (const id of closure) {\n const node = getNode.call(a, id);\n if (node) taken.set(id, node);\n }\n } else {\n // No closure read: the cascade is the subtree, discovered here.\n const walk = (id: string): void => {\n const node = getNode.call(a, id);\n if (!node) return;\n taken.set(id, node);\n for (const kid of getChildren.call(a, id)) walk(kid);\n };\n walk(rootId);\n }\n\n const detachRoots = [...taken.values()]\n .filter((n) => { const p = parentOf(n); return p === null || !taken.has(p); })\n .map((n) => ({ node: n, index: indexIn(a, parentOf(n), n.id) }))\n .sort((l, r) => l.index - r.index);\n\n const out: PlacedNode<TNode>[] = [];\n const emitSubtree = (entry: PlacedNode<TNode>): void => {\n out.push(entry);\n const kids = getChildren.call(a, entry.node.id);\n for (let i = 0; i < kids.length; i++) {\n const child = taken.get(kids[i]!);\n if (child) emitSubtree({ node: child, index: i });\n }\n };\n for (const entry of detachRoots) emitSubtree(entry);\n return out;\n}\n\n/** Op: remove `node` and everything the adapter cascades with it; inverts to a\n * re-insert of the whole set at its captured slots. */\nexport function createDeleteOp<TNode extends { id: string }>(args: DeleteArgs<TNode>): Op {\n const { node, label } = args;\n let slot: SiblingSlot = args.slot ?? slotFromIndex(args.index);\n const argsForSerial: DeleteArgs<TNode> = { node, label, slot, cascaded: args.cascaded };\n let captured: PlacedNode<TNode>[] = args.cascaded ?? [];\n return {\n name: 'delete',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as DeleteAdapter<TNode>;\n const observed = captureSlot(a, parentOf(node), node.id);\n if (observed) {\n slot = observed;\n argsForSerial.slot = observed;\n }\n const snapshot = captureCascade(a, node.id);\n if (snapshot) {\n captured = snapshot;\n argsForSerial.cascaded = snapshot;\n }\n a.removeNode(node.id);\n },\n invert() {\n const cascaded = captured;\n const restoredSlot = slot;\n // The root's own placement keeps the anchor-bearing slot; the rest have\n // only an ordinal, which is all `getChildren` can observe of them.\n const reinsertRoot = createInsertOp<TNode>({ node, label, slot: restoredSlot });\n if (cascaded.length === 0) return reinsertRoot;\n return {\n label,\n apply(adapter) {\n const a = adapter as InsertAdapter<TNode>;\n for (const entry of cascaded) {\n // A flat adapter's removeNode doesn't cascade, so its children\n // were never gone — re-inserting them would duplicate them.\n if (a.getNode?.(entry.node.id)) continue;\n if (entry.node.id === node.id) reinsertRoot.apply(adapter);\n else a.insertNode(entry.node, entry.index);\n }\n },\n invert: () =>\n createDeleteOp<TNode>({ node, label, slot: restoredSlot, cascaded }),\n };\n },\n };\n}\n\nregisterOpFactory<DeleteArgs<{ id: string }>>('delete', (args) => createDeleteOp(args));\n"],"mappings":";;;;AAoDA,SAASA,EAAQ,GAAkB,GAAyB,GAAoB;CAC9E,OAAOC,EAAE,cAAcC,CAAQ,CAAC,EAAE,QAAQC,CAAE,KAAK;AACnD;AAiBA,SAASC,EACP,GACA,GAC4B;CAC5B,IAAM,EAAE,gBAAa,eAAYH;CACjC,IAAI,CAACI,KAAe,CAACC,GAAS,OAAO;CAErC,IAAMC,IAAUN,EAAE,oBAAoB,CAACO,CAAM,CAAC,GACxCC,oBAAQ,IAAI,IAAmB;CACrC,IAAIF,GACF,KAAK,IAAMJ,KAAMI,GAAS;EACxB,IAAMG,IAAOJ,EAAQ,KAAKL,GAAGE,CAAE;EAC/B,AAAIO,KAAMD,EAAM,IAAIN,GAAIO,CAAI;CAC9B;MACK;EAEL,IAAMC,KAAQ,MAAqB;GACjC,IAAMD,IAAOJ,EAAQ,KAAKL,GAA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,MACF,IAAOA,GACP,EAAc,OAAOA;GAEvB,IAAME,IAAW9B,EAAeH,GAAGS,EAAK,EAAE;GAK1C,AAJIwB,MACF,IAAWA,GACX,EAAc,WAAWA,IAE3BjC,EAAE,WAAWS,EAAK,EAAE;EACtB;EACA,SAAS;GACP,IAAMyB,IAAWL,GACXM,IAAeT,GAGfU,IAAeC,EAAsB;IAAE;IAAM;IAAO,MAAMF;GAAa,CAAC;GAE9E,OADID,EAAS,WAAW,IAAUE,IAC3B;IACL;IACA,MAAM,GAAS;KACb,IAAMpC,IAAI8B;KACV,KAAK,IAAMV,KAASc,GAGlB,AAAIlC,EAAE,UAAUoB,EAAM,KAAK,EAAE,MACzBA,EAAM,KAAK,OAAOX,EAAK,KAAI2B,EAAa,MAAMN,CAAO,IACpD9B,EAAE,WAAWoB,EAAM,MAAMA,EAAM,KAAK;IAE7C;IACA,cACEI,EAAsB;KAAE;KAAM;KAAO,MAAMW;KAAc;IAAS,CAAC;GACvE;EACF;CACF;AACF;AAEAG,EAA8C,WAAW,MAASd,EAAeC,CAAI,CAAC"}
1
+ {"version":3,"file":"delete.js","names":["indexIn","a","parentId","id","captureCascade","getChildren","getNode","closure","rootId","taken","node","walk","kid","detachRoots","p","parentOf","n","l","r","out","emitSubtree","entry","kids","i","child","createDeleteOp","args","slot","slotFromIndex","argsForSerial","captured","adapter","observed","captureSlot","snapshot","createInsertOp","registerOpFactory"],"sources":["../../../src/core/ops/delete.ts"],"sourcesContent":["import type { Op } from './types';\nimport { createInsertOp } from './create';\nimport { registerOpFactory } from './registry';\nimport { captureSlot, parentOf, slotFromIndex, type OrderedReader, type SiblingSlot } from './slot';\n\ninterface DeleteAdapter<TNode> extends OrderedReader {\n removeNode(id: string): void;\n /** Subtree reads, used to snapshot the cascade before it runs. Optional\n * — a flat adapter has neither, and a delete there is a single node. */\n getNode?(id: string): TNode | undefined;\n /** Every id `removeNode` would take with this one. A store whose removal\n * cascades past the subtree — the kit's scene takes a deleted node's\n * dependents too — must answer here, or those nodes are absent from the\n * snapshot and undo does not bring them back. */\n getRemovalClosure?(ids: readonly string[]): readonly string[];\n}\n\n/** A captured node plus its slot in its own parent's child list. */\nexport interface PlacedNode<TNode> {\n node: TNode;\n index: number;\n}\n\n/** Arguments to {@link createDeleteOp}: the node to remove, plus what undo needs to put it back. */\nexport interface DeleteArgs<TNode extends { id: string }> {\n node: TNode;\n label?: string;\n /** Sibling ordinal the node occupies at the moment of delete. Sugar for\n * `slot: { index }`, and only a seed: `apply` re-observes the node's full\n * slot through the adapter, where it can, and that supersedes this. */\n index?: number;\n /** Full slot, anchor included. Written by `apply`; supersedes `index`. */\n slot?: SiblingSlot;\n /** Everything `removeNode` takes, `node` itself included — its subtree, and\n * whatever else the adapter cascades. Ordered so a node's parent precedes\n * it, which is the order they have to be re-inserted in. Captured on apply;\n * mirrored into the serialized args so a rebuilt op can invert without\n * having run. */\n cascaded?: PlacedNode<TNode>[];\n}\n\n/** `id`'s ordinal among `parentId`'s children, or `-1` when unobservable. */\nfunction indexIn(a: OrderedReader, parentId: string | null, id: string): number {\n return a.getChildren?.(parentId)?.indexOf(id) ?? -1;\n}\n\n/**\n * Snapshot everything removing `rootId` takes with it, `rootId` included.\n *\n * Returns `null` when the adapter can't enumerate, which leaves any previously\n * captured snapshot in place rather than clobbering it with an empty one.\n *\n * A cascade unlinks several disjoint subtrees, so the captured set is walked\n * as a forest: a node whose parent is not also going is a detach root, and\n * each one is emitted — ascending sibling index first, so every slot still\n * means what it meant — followed by its captured descendants preorder. The\n * closure's own order will not do: it can reach a dependent before the parent\n * it sits under, and re-inserting a child under a parent that is not back yet\n * puts it in the wrong place.\n */\nfunction captureCascade<TNode extends { id: string }>(\n a: DeleteAdapter<TNode>,\n rootId: string,\n): PlacedNode<TNode>[] | null {\n const { getChildren, getNode } = a;\n if (!getChildren || !getNode) return null;\n\n const closure = a.getRemovalClosure?.([rootId]);\n const taken = new Map<string, TNode>();\n if (closure) {\n for (const id of closure) {\n const node = getNode.call(a, id);\n if (node) taken.set(id, node);\n }\n } else {\n // No closure read: the cascade is the subtree, discovered here.\n const walk = (id: string): void => {\n const node = getNode.call(a, id);\n if (!node) return;\n taken.set(id, node);\n for (const kid of getChildren.call(a, id)) walk(kid);\n };\n walk(rootId);\n }\n\n const detachRoots = [...taken.values()]\n .filter((n) => { const p = parentOf(n); return p === null || !taken.has(p); })\n .map((n) => ({ node: n, index: indexIn(a, parentOf(n), n.id) }))\n .sort((l, r) => l.index - r.index);\n\n const out: PlacedNode<TNode>[] = [];\n const emitSubtree = (entry: PlacedNode<TNode>): void => {\n out.push(entry);\n const kids = getChildren.call(a, entry.node.id);\n for (let i = 0; i < kids.length; i++) {\n const child = taken.get(kids[i]!);\n if (child) emitSubtree({ node: child, index: i });\n }\n };\n for (const entry of detachRoots) emitSubtree(entry);\n return out;\n}\n\n/** Op: remove `node` and everything the adapter cascades with it; inverts to a\n * re-insert of the whole set at its captured slots. */\nexport function createDeleteOp<TNode extends { id: string }>(args: DeleteArgs<TNode>): Op {\n const { node, label } = args;\n let slot: SiblingSlot = args.slot ?? slotFromIndex(args.index);\n const argsForSerial: DeleteArgs<TNode> = { node, label, slot, cascaded: args.cascaded };\n let captured: PlacedNode<TNode>[] = args.cascaded ?? [];\n return {\n name: 'delete',\n args: argsForSerial,\n label,\n apply(adapter) {\n const a = adapter as DeleteAdapter<TNode>;\n const observed = captureSlot(a, parentOf(node), node.id);\n if (observed) {\n slot = observed;\n argsForSerial.slot = observed;\n }\n const snapshot = captureCascade(a, node.id);\n if (snapshot) {\n captured = snapshot;\n argsForSerial.cascaded = snapshot;\n }\n a.removeNode(node.id);\n },\n invert() {\n // The root's own placement keeps the anchor-bearing slot; the rest have\n // only an ordinal, which is all `getChildren` can observe of them.\n return createInsertOp<TNode>({\n node, label, slot,\n ...(captured.length > 0 ? { cascaded: captured } : {}),\n });\n },\n };\n}\n\nregisterOpFactory<DeleteArgs<{ id: string }>>('delete', (args) => createDeleteOp(args));\n"],"mappings":";;;;AA0C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,EAAM,IAAIa,EAAKC,EAAG;GAChC,AAAIC,KAAOJ,EAAY;IAAE,MAAMI;IAAO,OAAOD;GAAE,CAAC;EAClD;CACF;CACA,KAAK,IAAMF,KAASR,GAAa,EAAYQ,CAAK;CAClD,OAAOF;AACT;AAIA,SAAgBM,EAA6C,GAA6B;CACxF,IAAM,EAAE,SAAM,aAAUC,GACpBC,IAAoBD,EAAK,QAAQE,EAAcF,EAAK,KAAK,GACvDG,IAAmC;EAAE;EAAM;EAAO;EAAM,UAAUH,EAAK;CAAS,GAClFI,IAAgCJ,EAAK,YAAY,CAAC;CACtD,OAAO;EACL,MAAM;EACN,MAAMG;EACN;EACA,MAAM,GAAS;GACb,IAAM5B,IAAI8B,GACJC,IAAWC,EAAYhC,GAAGc,EAASL,CAAI,GAAGA,EAAK,EAAE;GACvD,AAAIsB,MACF,IAAOA,GACP,EAAc,OAAOA;GAEvB,IAAME,IAAW9B,EAAeH,GAAGS,EAAK,EAAE;GAK1C,AAJIwB,MACF,IAAWA,GACX,EAAc,WAAWA,IAE3BjC,EAAE,WAAWS,EAAK,EAAE;EACtB;EACA,SAAS;GAGP,OAAOyB,EAAsB;IAC3B;IAAM;IAAO;IACb,GAAIL,EAAS,SAAS,IAAI,EAAE,UAAUA,EAAS,IAAI,CAAC;GACtD,CAAC;EACH;CACF;AACF;AAEAM,EAA8C,WAAW,MAASX,EAAeC,CAAI,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import { registerOpFactory as e } from "../registry.js";
2
2
  import { bringForward as t, bringToFront as n, canBringForward as r, canSendBackward as i, moveToIndex as a, sendBackward as o, sendToBack as s } from "./algorithms.js";
3
+ import { createSetChildOrderOp as c } from "./setChildOrder.js";
3
4
  //#region src/core/ops/reorder/index.ts
4
- function c(e, t) {
5
+ function l(e, t) {
5
6
  if (e.length !== t.length) return !1;
6
7
  for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
7
8
  return !0;
8
9
  }
9
- function l(e) {
10
+ function u(e) {
10
11
  let { ids: t, direction: n, fn: r, label: i, prevOrders: a } = e, o = {
11
12
  ids: t,
12
13
  direction: n,
@@ -31,41 +32,41 @@ function l(e) {
31
32
  let t = n.getParent ? n.getParent(e) : null, r = i.get(t) ?? [];
32
33
  r.push(e), i.set(t, r);
33
34
  }
34
- let a = [], l = !1;
35
+ let a = [], c = !1;
35
36
  for (let [e, t] of i) {
36
37
  let i = n.getChildren(e), o = r(i, t);
37
- c(i, o) || (a.push({
38
+ l(i, o) || (a.push({
38
39
  parentId: e,
39
40
  before: i.slice()
40
- }), n.setChildOrder(e, o), l = !0);
41
+ }), n.setChildOrder(e, o), c = !0);
41
42
  }
42
43
  return s = a, o.prevOrders = a.map((e) => ({
43
44
  ...e,
44
45
  before: e.before.slice()
45
- })), l;
46
+ })), c;
46
47
  },
47
48
  invert() {
48
49
  let e = s;
49
50
  return {
50
- label: i,
51
- apply(t) {
52
- if (!e) return;
53
- let n = t;
54
- if (n.setChildOrder) for (let t of e) n.setChildOrder(t.parentId, t.before.slice());
55
- },
56
- invert() {
57
- return {
58
- apply() {},
59
- invert() {
60
- return this;
61
- }
62
- };
63
- }
51
+ ...c({
52
+ orders: (e ?? []).map((e) => ({
53
+ parentId: e.parentId,
54
+ ids: e.before
55
+ })),
56
+ label: i
57
+ }),
58
+ invert: () => u({
59
+ ids: t,
60
+ direction: n,
61
+ fn: r,
62
+ label: i,
63
+ prevOrders: e ?? void 0
64
+ })
64
65
  };
65
66
  }
66
67
  };
67
68
  }
68
- var u = {
69
+ var d = {
69
70
  forward: {
70
71
  fn: t,
71
72
  defaultLabel: "Bring forward"
@@ -83,9 +84,9 @@ var u = {
83
84
  defaultLabel: "Send to back"
84
85
  }
85
86
  };
86
- function d(e) {
87
- let { ids: t, direction: n, label: r, prevOrders: i } = e, { fn: a, defaultLabel: o } = u[n];
88
- return l({
87
+ function f(e) {
88
+ let { ids: t, direction: n, label: r, prevOrders: i } = e, { fn: a, defaultLabel: o } = d[n];
89
+ return u({
89
90
  ids: t,
90
91
  direction: n,
91
92
  fn: a,
@@ -93,8 +94,8 @@ function d(e) {
93
94
  prevOrders: i
94
95
  });
95
96
  }
96
- e("reorder", (e) => d(e));
97
- function f(e) {
97
+ e("reorder", (e) => f(e));
98
+ function p(e) {
98
99
  let { ids: t, parentId: n, index: r, label: i } = e, o = {
99
100
  ids: t,
100
101
  parentId: n,
@@ -117,24 +118,26 @@ function f(e) {
117
118
  invert() {
118
119
  let e = s;
119
120
  return {
120
- label: i,
121
- apply(t) {
122
- e && t.setChildOrder?.(n, e.slice());
123
- },
124
- invert() {
125
- return {
126
- apply() {},
127
- invert() {
128
- return this;
129
- }
130
- };
131
- }
121
+ ...c({
122
+ orders: e ? [{
123
+ parentId: n,
124
+ ids: e
125
+ }] : [],
126
+ label: i
127
+ }),
128
+ invert: () => p({
129
+ ids: t,
130
+ parentId: n,
131
+ index: r,
132
+ label: i,
133
+ prevPositions: e ?? void 0
134
+ })
132
135
  };
133
136
  }
134
137
  };
135
138
  }
136
- e("moveToIndex", (e) => f(e));
139
+ e("moveToIndex", (e) => p(e));
137
140
  //#endregion
138
- export { r as canBringForward, i as canSendBackward, f as createMoveToIndexOp, d as createReorderOp };
141
+ export { r as canBringForward, i as canSendBackward, p as createMoveToIndexOp, f as createReorderOp, c as createSetChildOrderOp };
139
142
 
140
143
  //# sourceMappingURL=index.js.map
@@ -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","entry","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\nexport { canBringForward, canSendBackward } from './algorithms';\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 label,\n apply(adapter) {\n if (!captured) return;\n const a = adapter as ReorderAdapter;\n if (!a.setChildOrder) return;\n for (const entry of captured) {\n a.setChildOrder(entry.parentId, entry.before.slice());\n }\n },\n invert() {\n // Inverting twice should reapply the original; we don't support\n // this round-trip beyond two levels — the kit's history layer\n // doesn't need it. Return a no-op for safety.\n return { apply() {}, invert() { return this; } };\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 label,\n apply(adapter) {\n if (!captured) return;\n const a = adapter as ReorderAdapter;\n a.setChildOrder?.(parentId, captured.slice());\n },\n invert() { return { apply() {}, invert() { return this; } }; },\n };\n },\n };\n}\n\nregisterOpFactory<MoveToI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AAM9B,IAAIQ;GACV,IAAI,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;IACA,MAAM,GAAS;KACb,AAAKG,KAELb,EAAE,gBAAgBQ,GAAUK,EAAS,MAAM,CAAC;IAC9C;IACA,SAAS;KAAE,OAAO;MAAE,QAAQ,CAAC;MAAG,SAAS;OAAE,OAAO;MAAM;KAAE;IAAG;GAC/D;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 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\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,IA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AM,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"}
@@ -0,0 +1,34 @@
1
+ import { registerOpFactory as e } from "../registry.js";
2
+ //#region src/core/ops/reorder/setChildOrder.ts
3
+ function t(e) {
4
+ let { orders: n, label: r } = e, i = {
5
+ orders: n,
6
+ label: r,
7
+ prevOrders: e.prevOrders
8
+ }, a = e.prevOrders ?? null;
9
+ return {
10
+ name: "setChildOrder",
11
+ args: i,
12
+ label: r,
13
+ apply(e) {
14
+ let t = e;
15
+ if (!t.setChildOrder) return !1;
16
+ let { getChildren: r } = t;
17
+ a === null && r && (a = n.map((e) => ({
18
+ parentId: e.parentId,
19
+ ids: r.call(t, e.parentId).slice()
20
+ })), i.prevOrders = a);
21
+ for (let e of n) t.setChildOrder(e.parentId, e.ids.slice());
22
+ },
23
+ invert: () => t({
24
+ orders: a ?? [],
25
+ label: r,
26
+ prevOrders: n
27
+ })
28
+ };
29
+ }
30
+ e("setChildOrder", (e) => t(e));
31
+ //#endregion
32
+ export { t as createSetChildOrderOp };
33
+
34
+ //# sourceMappingURL=setChildOrder.js.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ import { meshDrawKind as e, meshFromStops as t, meshGradientXml as n, meshStops as r, seedMeshPatch as i } from "@weasel-js/renderer/mesh";
2
+ //#region src/core/paint/meshKind.ts
3
+ var a = (e) => e, o = (e) => e, s = {
4
+ ...e,
5
+ label: "Mesh",
6
+ icon: "paintMesh",
7
+ seed: (e) => o(i(e)),
8
+ colorOf: (e) => a(e).patches?.[0]?.colors?.[0],
9
+ stopsOf: (e) => r(a(e)),
10
+ fromStops: (e) => o(t(e)),
11
+ toSvg: (e, t) => n(e, a(t))
12
+ };
13
+ //#endregion
14
+ export { s as meshGradientKind };
15
+
16
+ //# sourceMappingURL=meshKind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meshKind.js","names":["asMesh","fill","asFill","mesh","meshGradientKind","meshDrawKind","seedMeshPatch","color","paint","meshStops","meshFromStops","stops","meshGradientXml","id"],"sources":["../../../src/core/paint/meshKind.ts"],"sourcesContent":["import type { Paint } from '@weasel-js/paint';\nimport {\n meshDrawKind, meshFromStops, meshGradientXml, meshStops, seedMeshPatch, type MeshGradientPaint,\n} from '@weasel-js/renderer/mesh';\nimport type { PaintKindEntry } from './paintKindEntry';\n\n// `asPaint`'s cast both ways, kept local: this module must import nothing\n// stateful, or `meshKindLazy`'s self-contained copy would duplicate it.\nconst asMesh = (fill: Paint): MeshGradientPaint => fill as unknown as MeshGradientPaint;\nconst asFill = (mesh: MeshGradientPaint): Paint => mesh as unknown as Paint;\n\n/** The `mesh-gradient` kind's registry entry. `./registerMesh` registers it;\n * the paint-kind registry loads it on demand otherwise. */\nexport const meshGradientKind: PaintKindEntry = {\n ...meshDrawKind,\n label: 'Mesh',\n icon: 'paintMesh',\n seed: (color) => asFill(seedMeshPatch(color)),\n // The first corner of the first patch: a mesh has no single color, and this\n // is the one a fallback swatch and an SVG paint fallback both read.\n colorOf: (paint) => asMesh(paint).patches?.[0]?.colors?.[0],\n stopsOf: (paint) => meshStops(asMesh(paint)),\n fromStops: (stops) => asFill(meshFromStops(stops)),\n toSvg: (id, fill) => meshGradientXml(id, asMesh(fill)),\n};\n"],"mappings":";;AAQA,IAAMA,KAAU,MAAmCC,GAC7CC,KAAU,MAAmCC,GAItCC,IAAmC;CAC9C,GAAGC;CACH,OAAO;CACP,MAAM;CACN,OAAO,MAAUH,EAAOI,EAAcC,CAAK,CAAC;CAG5C,UAAU,MAAUP,EAAOQ,CAAK,CAAC,CAAC,UAAU,EAAE,EAAE,SAAS;CACzD,UAAU,MAAUC,EAAUT,EAAOQ,CAAK,CAAC;CAC3C,YAAY,MAAUN,EAAOQ,EAAcC,CAAK,CAAC;CACjD,QAAQ,GAAI,MAASC,EAAgBC,GAAIb,EAAOC,CAAI,CAAC;AACvD"}