@weasel-js/core 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/CHANGELOG.md +427 -0
  2. package/README.md +1 -1
  3. package/dist/animation/index.js +3 -3
  4. package/dist/animation/rig/bindRig.js +1 -1
  5. package/dist/animation/rig/rigNode.js.map +1 -1
  6. package/dist/barrel/canvas.js +7 -3
  7. package/dist/barrel/interactions.js +5 -4
  8. package/dist/barrel/paths.js +3 -3
  9. package/dist/barrel/renderer.js +3 -2
  10. package/dist/barrel/routing.js +6 -11
  11. package/dist/barrel/scene.js +8 -5
  12. package/dist/barrel/viewport.js +4 -3
  13. package/dist/canvas/Canvas.js +3 -1
  14. package/dist/canvas/Canvas.js.map +1 -1
  15. package/dist/canvas/SceneCanvas/SceneCanvasInput.js +17 -3
  16. package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
  17. package/dist/canvas/SceneCanvas/builtinToolSets.js +30 -0
  18. package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -0
  19. package/dist/canvas/SceneCanvas/canvasPassThrough.js +1 -0
  20. package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
  21. package/dist/canvas/SceneCanvas/coordTrace.js +5 -16
  22. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -1
  23. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +5 -0
  24. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  25. package/dist/canvas/SceneCanvas/features.js +45 -5
  26. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  27. package/dist/canvas/SceneCanvas/props.js +1 -11
  28. package/dist/canvas/SceneCanvas/props.js.map +1 -1
  29. package/dist/canvas/SceneCanvas/toolRegistry.js +8 -4
  30. package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -1
  31. package/dist/canvas/SceneCanvas/useActionsPropResolver.js +1 -11
  32. package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
  33. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  34. package/dist/canvas/SceneCanvas/useBuiltinTools.js +2 -9
  35. package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
  36. package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js +93 -0
  37. package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js.map +1 -0
  38. package/dist/canvas/SceneCanvas/useCanvasSelection.js +7 -2
  39. package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -1
  40. package/dist/canvas/SceneCanvas/useCanvasTools.js +8 -8
  41. package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
  42. package/dist/canvas/SceneCanvas/useNodeKinds.js +1 -1
  43. package/dist/canvas/SceneCanvas/useNodeKinds.js.map +1 -1
  44. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +13 -2
  45. package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
  46. package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +1 -3
  47. package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
  48. package/dist/canvas/SceneCanvas/useSceneChrome.js +6 -7
  49. package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
  50. package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +5 -3
  51. package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
  52. package/dist/canvas/SceneCanvas/useScenePicking.js +2 -3
  53. package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
  54. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +2 -1
  55. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  56. package/dist/canvas/SceneCanvas/useSceneStandardActions.js +3 -4
  57. package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
  58. package/dist/canvas/SceneCanvas.js +16 -14
  59. package/dist/canvas/SceneCanvas.js.map +1 -1
  60. package/dist/canvas/SurfaceCanvas.js +5 -22
  61. package/dist/canvas/SurfaceCanvas.js.map +1 -1
  62. package/dist/canvas/canvasRenderer.js +9 -5
  63. package/dist/canvas/canvasRenderer.js.map +1 -1
  64. package/dist/canvas/contextAttributes.js +14 -0
  65. package/dist/canvas/contextAttributes.js.map +1 -0
  66. package/dist/canvas/deps/editAnchors.js +9 -113
  67. package/dist/canvas/deps/editAnchors.js.map +1 -1
  68. package/dist/canvas/deps/insert.js +4 -2
  69. package/dist/canvas/deps/insert.js.map +1 -1
  70. package/dist/canvas/deps/pathEditCommits.js +193 -0
  71. package/dist/canvas/deps/pathEditCommits.js.map +1 -0
  72. package/dist/canvas/deps/snap.js +12 -9
  73. package/dist/canvas/deps/snap.js.map +1 -1
  74. package/dist/canvas/deps/transformFollowers.js +20 -0
  75. package/dist/canvas/deps/transformFollowers.js.map +1 -0
  76. package/dist/canvas/derivedPath.js +20 -1
  77. package/dist/canvas/derivedPath.js.map +1 -1
  78. package/dist/canvas/drawnBounds.js +29 -3
  79. package/dist/canvas/drawnBounds.js.map +1 -1
  80. package/dist/canvas/nodeShapes/derivedPainter.js +9 -1
  81. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -1
  82. package/dist/canvas/nodeShapes/pathPainter.js +3 -2
  83. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -1
  84. package/dist/canvas/nodeShapes/shapePainter.js +1 -1
  85. package/dist/canvas/overlayRoleStrokes.js +12 -0
  86. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  87. package/dist/canvas/pathOverlay.js +27 -7
  88. package/dist/canvas/pathOverlay.js.map +1 -1
  89. package/dist/canvas/renderDebugSnapshot.js +1 -0
  90. package/dist/canvas/renderDebugSnapshot.js.map +1 -1
  91. package/dist/canvas/renderSceneToPixels.js +6 -5
  92. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  93. package/dist/canvas/sceneAdapter.js.map +1 -1
  94. package/dist/canvas/useCanvasPaint.js +2 -1
  95. package/dist/canvas/useCanvasPaint.js.map +1 -1
  96. package/dist/canvas/useInFlightBounds.js +52 -0
  97. package/dist/canvas/useInFlightBounds.js.map +1 -0
  98. package/dist/canvas/useViewHelpers.js +7 -9
  99. package/dist/canvas/useViewHelpers.js.map +1 -1
  100. package/dist/clipboard.d.ts +3 -2
  101. package/dist/{clone-DZDrfIlU.d.ts → clone-C3e0OTuF.d.ts} +8 -21
  102. package/dist/clone.d.ts +4 -3
  103. package/dist/core/geometry/autoPoseDescriptor.js +1 -1
  104. package/dist/core/ops/setDependsOn.js +37 -0
  105. package/dist/core/ops/setDependsOn.js.map +1 -0
  106. package/dist/core/ops/writtenBy.js +53 -0
  107. package/dist/core/ops/writtenBy.js.map +1 -0
  108. package/dist/core/pages/fitViewToPage.js +12 -1
  109. package/dist/core/pages/fitViewToPage.js.map +1 -1
  110. package/dist/core/pages/pageEdits.js +164 -0
  111. package/dist/core/pages/pageEdits.js.map +1 -0
  112. package/dist/core/pages/pages.js +30 -1
  113. package/dist/core/pages/pages.js.map +1 -1
  114. package/dist/core/scene/NodeRouting.js +8 -3
  115. package/dist/core/scene/NodeRouting.js.map +1 -1
  116. package/dist/core/scene/arrivalWindow.js.map +1 -1
  117. package/dist/core/scene/carryDescendants.js +51 -0
  118. package/dist/core/scene/carryDescendants.js.map +1 -0
  119. package/dist/core/scene/docValues.js +57 -0
  120. package/dist/core/scene/docValues.js.map +1 -0
  121. package/dist/core/scene/editPass.js +111 -0
  122. package/dist/core/scene/editPass.js.map +1 -0
  123. package/dist/core/scene/effectivePose.js +7 -1
  124. package/dist/core/scene/effectivePose.js.map +1 -1
  125. package/dist/core/scene/fieldEdits.js +4 -1
  126. package/dist/core/scene/fieldEdits.js.map +1 -1
  127. package/dist/core/scene/historyFacade.js +1 -0
  128. package/dist/core/scene/historyFacade.js.map +1 -1
  129. package/dist/core/scene/layoutPass.js +28 -3
  130. package/dist/core/scene/layoutPass.js.map +1 -1
  131. package/dist/core/scene/recorder.js +28 -19
  132. package/dist/core/scene/recorder.js.map +1 -1
  133. package/dist/core/scene/scene.js +15 -9
  134. package/dist/core/scene/scene.js.map +1 -1
  135. package/dist/core/scene/sceneChanges.js +13 -0
  136. package/dist/core/scene/sceneChanges.js.map +1 -0
  137. package/dist/core/scene/sceneEdits.js +8 -1
  138. package/dist/core/scene/sceneEdits.js.map +1 -1
  139. package/dist/core/scene/sceneMutators.js +1 -0
  140. package/dist/core/scene/sceneMutators.js.map +1 -1
  141. package/dist/core/scene/sceneRecording.js +20 -3
  142. package/dist/core/scene/sceneRecording.js.map +1 -1
  143. package/dist/core/scene/sceneSelection.js +4 -1
  144. package/dist/core/scene/sceneSelection.js.map +1 -1
  145. package/dist/core/scene/sceneState.js +11 -5
  146. package/dist/core/scene/sceneState.js.map +1 -1
  147. package/dist/core/scene/serialization.js +5 -3
  148. package/dist/core/scene/serialization.js.map +1 -1
  149. package/dist/core/scene/types.js.map +1 -1
  150. package/dist/core/scene/unitScopes.js +19 -1
  151. package/dist/core/scene/unitScopes.js.map +1 -1
  152. package/dist/core/selection/usePublishSceneSelection.js +6 -12
  153. package/dist/core/selection/usePublishSceneSelection.js.map +1 -1
  154. package/dist/core/shapeKinds.js +25 -11
  155. package/dist/core/shapeKinds.js.map +1 -1
  156. package/dist/{cornerHandles-Camw_yeu.d.ts → cornerHandles-BHuoMs1o.d.ts} +1 -1
  157. package/dist/debug/createDebugOverlayLayer.js +16 -111
  158. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  159. package/dist/debug/createDebugSink.js +2 -1
  160. package/dist/debug/createDebugSink.js.map +1 -1
  161. package/dist/debug/defaultTheme.js +4 -2
  162. package/dist/debug/defaultTheme.js.map +1 -1
  163. package/dist/debug/features.js +17 -0
  164. package/dist/debug/features.js.map +1 -0
  165. package/dist/debug/overlayPanels.js +117 -0
  166. package/dist/debug/overlayPanels.js.map +1 -0
  167. package/dist/debug/parseDebugFlags.js +4 -13
  168. package/dist/debug/parseDebugFlags.js.map +1 -1
  169. package/dist/{depSchema-Cgfu_G9s.d.ts → depSchema-BpZNOv7q.d.ts} +114 -892
  170. package/dist/devtools/handlers.js +112 -0
  171. package/dist/devtools/handlers.js.map +1 -0
  172. package/dist/devtools/history.js +71 -0
  173. package/dist/devtools/history.js.map +1 -0
  174. package/dist/devtools/hook.js +74 -0
  175. package/dist/devtools/hook.js.map +1 -0
  176. package/dist/devtools/label.js +25 -0
  177. package/dist/devtools/label.js.map +1 -0
  178. package/dist/devtools/notices.js +58 -0
  179. package/dist/devtools/notices.js.map +1 -0
  180. package/dist/devtools/protocol.js +7 -0
  181. package/dist/devtools/protocol.js.map +1 -0
  182. package/dist/devtools/registry.js +90 -0
  183. package/dist/devtools/registry.js.map +1 -0
  184. package/dist/devtools/root.js +80 -0
  185. package/dist/devtools/root.js.map +1 -0
  186. package/dist/devtools/serialize.js +86 -0
  187. package/dist/devtools/serialize.js.map +1 -0
  188. package/dist/devtools/session.js +111 -0
  189. package/dist/devtools/session.js.map +1 -0
  190. package/dist/devtools/transport.js +67 -0
  191. package/dist/devtools/transport.js.map +1 -0
  192. package/dist/devtools/useDevtoolsRoot.js +81 -0
  193. package/dist/devtools/useDevtoolsRoot.js.map +1 -0
  194. package/dist/devtools-protocol.d.ts +435 -0
  195. package/dist/devtools-protocol.js +7 -0
  196. package/dist/devtools.d.ts +8 -0
  197. package/dist/devtools.js +12 -0
  198. package/dist/devtools.js.map +1 -0
  199. package/dist/features/chrome-caps/useHoverTracking.js +16 -10
  200. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  201. package/dist/features/ingestion/contentHandlers.js +25 -2
  202. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  203. package/dist/features/measure/measureCommands.js +7 -5
  204. package/dist/features/measure/measureCommands.js.map +1 -1
  205. package/dist/features/paths/index.js +2 -2
  206. package/dist/features/paths/pathEditExtension.js.map +1 -1
  207. package/dist/features/paths/pathSnap/pathSnapSource.js +5 -5
  208. package/dist/features/paths/pathSnap/pathSnapSource.js.map +1 -1
  209. package/dist/features/paths/pathSnap/sceneIndex.js +10 -3
  210. package/dist/features/paths/pathSnap/sceneIndex.js.map +1 -1
  211. package/dist/features/selection/selectionPose.js +4 -1
  212. package/dist/features/selection/selectionPose.js.map +1 -1
  213. package/dist/features/snap/gather.js +9 -1
  214. package/dist/features/snap/gather.js.map +1 -1
  215. package/dist/features/snap/lazySession.js +17 -0
  216. package/dist/features/snap/lazySession.js.map +1 -0
  217. package/dist/features/snap/marks.js.map +1 -1
  218. package/dist/features/snap/probes2d.js +27 -19
  219. package/dist/features/snap/probes2d.js.map +1 -1
  220. package/dist/features/snap/readoutLayer.js.map +1 -1
  221. package/dist/features/snap/roles.js +2 -1
  222. package/dist/features/snap/roles.js.map +1 -1
  223. package/dist/features/snap/rotationSource.js +25 -8
  224. package/dist/features/snap/rotationSource.js.map +1 -1
  225. package/dist/features/snap/sceneSession2d.js +6 -4
  226. package/dist/features/snap/sceneSession2d.js.map +1 -1
  227. package/dist/features/snap/session2d.js +37 -23
  228. package/dist/features/snap/session2d.js.map +1 -1
  229. package/dist/features/snap/spanSnap.js +5 -2
  230. package/dist/features/snap/spanSnap.js.map +1 -1
  231. package/dist/icons.table.js +1 -1
  232. package/dist/icons.table.js.map +1 -1
  233. package/dist/icons.table.json +0 -10
  234. package/dist/index.d.ts +701 -696
  235. package/dist/index.js +35 -29
  236. package/dist/interactions/actions/align/action.js +6 -4
  237. package/dist/interactions/actions/align/action.js.map +1 -1
  238. package/dist/interactions/actions/align/align.js.map +1 -1
  239. package/dist/interactions/actions/booleans/action.js +7 -1
  240. package/dist/interactions/actions/booleans/action.js.map +1 -1
  241. package/dist/interactions/actions/clone/action.js +1 -1
  242. package/dist/interactions/actions/clone/behaviors.js +4 -4
  243. package/dist/interactions/actions/clone/behaviors.js.map +1 -1
  244. package/dist/interactions/actions/defaults/bendSegment.js +1 -1
  245. package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
  246. package/dist/interactions/actions/defaults/createPaintAction.js +1 -1
  247. package/dist/interactions/actions/defaults/delete.js +48 -39
  248. package/dist/interactions/actions/defaults/delete.js.map +1 -1
  249. package/dist/interactions/actions/defaults/duplicate.js +1 -1
  250. package/dist/interactions/actions/defaults/group.js +2 -2
  251. package/dist/interactions/actions/defaults/ingest.js +7 -5
  252. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  253. package/dist/interactions/actions/defaults/nudge.js +13 -38
  254. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  255. package/dist/interactions/actions/distribute/action.js +6 -4
  256. package/dist/interactions/actions/distribute/action.js.map +1 -1
  257. package/dist/interactions/actions/drawnBoxes.js +2 -1
  258. package/dist/interactions/actions/drawnBoxes.js.map +1 -1
  259. package/dist/interactions/actions/edit-anchors/action.js +3 -6
  260. package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
  261. package/dist/interactions/actions/edit-anchors/preview.js +41 -8
  262. package/dist/interactions/actions/edit-anchors/preview.js.map +1 -1
  263. package/dist/interactions/actions/flip/action.js +6 -4
  264. package/dist/interactions/actions/flip/action.js.map +1 -1
  265. package/dist/interactions/actions/gestureLifecycle.js +5 -2
  266. package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
  267. package/dist/interactions/actions/insert/action.js +1 -2
  268. package/dist/interactions/actions/insert/action.js.map +1 -1
  269. package/dist/interactions/actions/insert/commit.js +1 -1
  270. package/dist/interactions/actions/insert/parent.js +11 -0
  271. package/dist/interactions/actions/insert/parent.js.map +1 -0
  272. package/dist/interactions/actions/insert/placeAction.js +7 -2
  273. package/dist/interactions/actions/insert/placeAction.js.map +1 -1
  274. package/dist/interactions/actions/insert/session.js +5 -1
  275. package/dist/interactions/actions/insert/session.js.map +1 -1
  276. package/dist/interactions/actions/move/action.js +8 -4
  277. package/dist/interactions/actions/move/action.js.map +1 -1
  278. package/dist/interactions/actions/move/behaviors/layoutDrop.js +0 -1
  279. package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -1
  280. package/dist/interactions/actions/move/behaviors/snapToContainer.js +1 -1
  281. package/dist/interactions/actions/move/capture.js +1 -1
  282. package/dist/interactions/actions/move/commit/index.js +0 -2
  283. package/dist/interactions/actions/move/commit/index.js.map +1 -1
  284. package/dist/interactions/actions/move/commit/layoutDrop.js +2 -2
  285. package/dist/interactions/actions/move/commit/layoutRelease.js +2 -2
  286. package/dist/interactions/actions/move/commit/reparent.js +11 -5
  287. package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
  288. package/dist/interactions/actions/move/frame.js +4 -10
  289. package/dist/interactions/actions/move/frame.js.map +1 -1
  290. package/dist/interactions/actions/move/landedDescendants.js +20 -17
  291. package/dist/interactions/actions/move/landedDescendants.js.map +1 -1
  292. package/dist/interactions/actions/move/layout/container.js +2 -1
  293. package/dist/interactions/actions/move/layout/container.js.map +1 -1
  294. package/dist/interactions/actions/move/layout/dragged.js +1 -1
  295. package/dist/interactions/actions/move/layout/dropPass.js +18 -1
  296. package/dist/interactions/actions/move/layout/dropPass.js.map +1 -1
  297. package/dist/interactions/actions/move/layout/exits.js +5 -5
  298. package/dist/interactions/actions/move/layout/exits.js.map +1 -1
  299. package/dist/interactions/actions/move/session.js +14 -3
  300. package/dist/interactions/actions/move/session.js.map +1 -1
  301. package/dist/interactions/actions/move/translate.js +8 -37
  302. package/dist/interactions/actions/move/translate.js.map +1 -1
  303. package/dist/interactions/actions/moveNodes.js +87 -0
  304. package/dist/interactions/actions/moveNodes.js.map +1 -0
  305. package/dist/interactions/actions/planeInput.js.map +1 -1
  306. package/dist/interactions/actions/resize/action.js +83 -72
  307. package/dist/interactions/actions/resize/action.js.map +1 -1
  308. package/dist/interactions/actions/resize/commit.js +2 -1
  309. package/dist/interactions/actions/resize/commit.js.map +1 -1
  310. package/dist/interactions/actions/resize/session.js +2 -0
  311. package/dist/interactions/actions/resize/session.js.map +1 -1
  312. package/dist/interactions/actions/resolvePreviews.js +3 -3
  313. package/dist/interactions/actions/resolvePreviews.js.map +1 -1
  314. package/dist/interactions/actions/rotate/action.js +7 -4
  315. package/dist/interactions/actions/rotate/action.js.map +1 -1
  316. package/dist/interactions/actions/rotate/commit.js +2 -1
  317. package/dist/interactions/actions/rotate/commit.js.map +1 -1
  318. package/dist/interactions/actions/rotate/session.js +2 -0
  319. package/dist/interactions/actions/rotate/session.js.map +1 -1
  320. package/dist/interactions/actions/selectionSubtree.js +13 -2
  321. package/dist/interactions/actions/selectionSubtree.js.map +1 -1
  322. package/dist/interactions/actions/testUtils.js.map +1 -1
  323. package/dist/interactions/actions/transform-again/action.js +5 -6
  324. package/dist/interactions/actions/transform-again/action.js.map +1 -1
  325. package/dist/interactions/actions/transformFinish.js +106 -0
  326. package/dist/interactions/actions/transformFinish.js.map +1 -0
  327. package/dist/kitSettingsSchema.js +0 -4
  328. package/dist/kitSettingsSchema.js.map +1 -1
  329. package/dist/move.d.ts +5 -4
  330. package/dist/{options-p9GZMXbY.d.ts → options-DBxEryYq.d.ts} +1 -1
  331. package/dist/resize.d.ts +4 -3
  332. package/dist/routing.d.ts +1 -1
  333. package/dist/routing.js +2 -2
  334. package/dist/test-hook/createTestHook.js +1 -1
  335. package/dist/test-hook/createTestHook.js.map +1 -1
  336. package/dist/test-hook/useTestHook.js +2 -1
  337. package/dist/test-hook/useTestHook.js.map +1 -1
  338. package/dist/test-seams.d.ts +9 -5
  339. package/dist/tools/builtin/pen/penHandle.js +3 -5
  340. package/dist/tools/builtin/pen/penHandle.js.map +1 -1
  341. package/dist/tools/index.js +26 -0
  342. package/dist/{types-CHVXGfYm.d.ts → types-7puAuVD2.d.ts} +3 -262
  343. package/dist/types-BN9hbdMI.d.ts +184 -0
  344. package/dist/types-CniVctmk.d.ts +949 -0
  345. package/dist/types-oFeQ5VjV.d.ts +264 -0
  346. package/dist/version.js +1 -1
  347. package/package.json +35 -25
  348. package/dist/canvas/SceneCanvas/useBuiltinRigTools.js +0 -65
  349. package/dist/canvas/SceneCanvas/useBuiltinRigTools.js.map +0 -1
  350. package/dist/tools/builtin/bone/boneActions.js +0 -156
  351. package/dist/tools/builtin/bone/boneActions.js.map +0 -1
  352. package/dist/tools/builtin/bone/boneOverlay.js +0 -71
  353. package/dist/tools/builtin/bone/boneOverlay.js.map +0 -1
  354. package/dist/tools/builtin/bone/placedRig.js +0 -28
  355. package/dist/tools/builtin/bone/placedRig.js.map +0 -1
  356. package/dist/tools/builtin/bone/rigEditState.js +0 -30
  357. package/dist/tools/builtin/bone/rigEditState.js.map +0 -1
  358. package/dist/tools/builtin/bone/useBoneTool.js +0 -125
  359. package/dist/tools/builtin/bone/useBoneTool.js.map +0 -1
  360. package/dist/tools/builtin/weight/useWeightTool.js +0 -101
  361. package/dist/tools/builtin/weight/useWeightTool.js.map +0 -1
  362. package/dist/tools/builtin/weight/weightActions.js +0 -140
  363. package/dist/tools/builtin/weight/weightActions.js.map +0 -1
  364. package/dist/tools/builtin/weight/weightOverlay.js +0 -78
  365. package/dist/tools/builtin/weight/weightOverlay.js.map +0 -1
@@ -0,0 +1,949 @@
1
+ import * as _weasel_js_history from '@weasel-js/history';
2
+ import { Op, SerializedHistory, History } from '@weasel-js/history';
3
+ import { P as ParallaxOpts, C as ContainerBounds, L as LayoutStrategy } from './types-7puAuVD2.js';
4
+ import { UnitScope } from '@weasel-js/quantity';
5
+ import { NodeId } from '@weasel-js/routing';
6
+ import { Path, PoseLinear, Affine } from '@weasel-js/geom';
7
+
8
+ /**
9
+ * Scene edit passes: functions that hear what a live edit did, once its own
10
+ * mutations and the arrival handler have run, and answer with ops that join
11
+ * the same undo entry.
12
+ *
13
+ * Passes run by ascending order, and each hears the edit's own changes plus
14
+ * every write the passes before it made. A pass still runs once per edit, so
15
+ * none re-triggers itself or another. Undo, redo, and history replays never
16
+ * run passes: they restore an edit whose passes already ran.
17
+ */
18
+
19
+ /** What one live edit did to the scene's nodes, by id. */
20
+ interface SceneEditSummary {
21
+ added: ReadonlySet<NodeId>;
22
+ removed: ReadonlySet<NodeId>;
23
+ posed: ReadonlySet<NodeId>;
24
+ /** Nodes that changed parent. A reorder among siblings is not here. */
25
+ reparented: ReadonlySet<NodeId>;
26
+ dataChanged: ReadonlySet<NodeId>;
27
+ /** The document-value keys (`scene.doc`) set. */
28
+ docChanged: ReadonlySet<string>;
29
+ }
30
+ /** Where a pass runs among the others. */
31
+ interface SceneEditPassOptions {
32
+ /** Passes run by ascending order, ties in the order they were added.
33
+ * Default 0. */
34
+ order?: number;
35
+ }
36
+ /** A scene edit pass: the ops `summary`'s edit also makes, or null for none. */
37
+ type SceneEditPass = (summary: SceneEditSummary) => readonly Op[] | null;
38
+ /** The scene's edit-pass member. */
39
+ interface SceneEditPasses {
40
+ /** Add a pass that hears each live edit once its own mutations and the
41
+ * arrival handler have run, and answers with ops that join the same undo
42
+ * entry. A bare scene call runs as an edit of its own while any pass is
43
+ * added. A pass hears what the passes ordered before it wrote, never what
44
+ * it or a later one writes, and undo, redo, and history replays never run
45
+ * it. Returns the pass's remover. */
46
+ addEditPass(pass: SceneEditPass, opts?: SceneEditPassOptions): () => void;
47
+ }
48
+
49
+ /**
50
+ * How a scene mutation becomes an undo entry: recorded on its own, collected
51
+ * into the batch it runs in, or left to the engine or the untracked run that
52
+ * is driving it.
53
+ */
54
+
55
+ /** Options for `scene.batch`. */
56
+ interface SceneBatchOptions {
57
+ /** Fold this batch's entry into the one before it when that one carries the same key and
58
+ * nothing came between: one undo entry for a run of batches, such as a color dragged. */
59
+ coalesceKey?: string;
60
+ }
61
+
62
+ /** The form a scene's undo entries are recorded in. A serialized history
63
+ * carries it, and one carrying another is not restored. Form 2 holds the
64
+ * scene's own ops for every edit; before it, an `applyBatch` entry held the
65
+ * ops it was given. */
66
+ declare const SCENE_HISTORY_FORM = 2;
67
+ /** What `Scene.serializeHistory` answers with. */
68
+ interface SerializedSceneHistory extends SerializedHistory {
69
+ form: typeof SCENE_HISTORY_FORM;
70
+ }
71
+
72
+ interface LayerRecordBase<TLayer extends string> {
73
+ id: TLayer;
74
+ visible: boolean;
75
+ locked: boolean;
76
+ /** Draw this layer as a parallax plane: through a view derived from the
77
+ * camera's (see `deriveParallaxView`), and picked through the same one.
78
+ * Absent means the layer moves with the camera. */
79
+ parallax?: ParallaxOpts;
80
+ /** A non-printing layer of aids — measurements, notes — rather than content.
81
+ * Its nodes draw on the canvas and save with the scene, but export leaves
82
+ * them out and content picking passes through them. Read it through
83
+ * `isAnnotationLayer`. Absent means content. */
84
+ annotation?: boolean;
85
+ }
86
+ /** A layer declared when the scene was created. Fixed set, no display name —
87
+ * these are the kit's own render bands, not something a user manages. */
88
+ interface SystemLayerRecord<TLayer extends string> extends LayerRecordBase<TLayer> {
89
+ kind: 'system';
90
+ }
91
+ /** A layer the user created and can rename, reorder or delete. */
92
+ interface UserLayerRecord<TLayer extends string> extends LayerRecordBase<TLayer> {
93
+ kind: 'user';
94
+ name: string;
95
+ }
96
+ /** Per-layer metadata held by the scene: whether it is visible and locked,
97
+ * and where it sits in the render stack. Distinct from a node's `layer` tag,
98
+ * which merely names one of these. */
99
+ type LayerRecord<TLayer extends string> = SystemLayerRecord<TLayer> | UserLayerRecord<TLayer>;
100
+ /** One of the layers a scene is created with. */
101
+ interface SystemLayerSpec<TLayer extends string> {
102
+ id: TLayer;
103
+ visible?: boolean;
104
+ locked?: boolean;
105
+ /** See `LayerRecord.parallax`. */
106
+ parallax?: ParallaxOpts;
107
+ /** See `LayerRecord.annotation`. */
108
+ annotation?: boolean;
109
+ }
110
+ /** Argument to `Scene.addLayer`. Always produces a `UserLayerRecord`
111
+ * (`kind: 'user'`). */
112
+ interface AddLayerSpec<TLayer extends string> {
113
+ id: TLayer;
114
+ name: string;
115
+ /** Default `true`. */
116
+ visible?: boolean;
117
+ /** Default `false`. */
118
+ locked?: boolean;
119
+ /** See `LayerRecord.parallax`. */
120
+ parallax?: ParallaxOpts;
121
+ /** See `LayerRecord.annotation`. */
122
+ annotation?: boolean;
123
+ /** Render-stack position. Default: top of stack (highest render index). */
124
+ index?: number;
125
+ }
126
+
127
+ /** A pose a container's layout wrote — reported by `Scene.onReflow` — in the
128
+ * node's stored frame. */
129
+ interface LayoutMove<TPose> {
130
+ id: NodeId;
131
+ from: TPose;
132
+ to: TPose;
133
+ }
134
+ /** How a scene reads and resizes a laid-out container's bounds. */
135
+ interface LayoutFrame<TPose> {
136
+ /** The container's bounds, from its world pose. Default: the pose's own
137
+ * `x`/`y`/`width`/`height`; a pose without them is not laid out. */
138
+ bounds?(pose: TPose): ContainerBounds | null;
139
+ /** `pose` resized from bounds `from` to `to`, for a layout that grows its
140
+ * container. Default: `to`'s fields written over the pose. */
141
+ remap?(pose: TPose, from: ContainerBounds, to: ContainerBounds): TPose;
142
+ }
143
+
144
+ /** Folding a node's pose up its parent chain to world, and back down. */
145
+ /** Minimal adapter needed by `composeWorldPose` and friends — pose lookup plus parent walk. */
146
+ interface PoseAdapter<TPose> {
147
+ getPose(id: string): TPose;
148
+ getParent(id: string): string | null;
149
+ /** Whether `id`'s pose is a frame its children are expressed in. Absent
150
+ * means every node is one. A container whose pose derives from its children
151
+ * is not: its children share its frame, so the fold passes over it. */
152
+ definesFrame?(id: string): boolean;
153
+ }
154
+ /**
155
+ * What a container's pose does to its children under a `compose`: nothing,
156
+ * an offset, or a whole frame. `'rigid'` is the frame: a container's rotation
157
+ * and its `transform` both reach its children, and a child's `transform`
158
+ * holds the skew or stretch its box and rotation cannot.
159
+ */
160
+ type PoseClosure = 'identity' | 'translation' | 'rigid';
161
+ /** Consumer's pose-composition strategy for hierarchical scenes. `compose`
162
+ * folds a child's pose (in parent's frame) up to the next frame; `decompose`
163
+ * is its inverse. Default is IDENTITY — an absolute-pose scene where every
164
+ * node already stores world coords (parent is grouping-only, no transform). */
165
+ interface PoseComposition<TPose> {
166
+ compose(parent: TPose, child: TPose): TPose;
167
+ decompose(parent: TPose, world: TPose): TPose;
168
+ closure: PoseClosure;
169
+ }
170
+ /** Default pose-composition strategy: IDENTITY, an absolute-pose scene. */
171
+ declare const IDENTITY_POSE_COMPOSITION: PoseComposition<unknown>;
172
+ /** Whether `composition` makes a container's pose a frame, so a stored pose
173
+ * is local to it. False for the absolute-pose model. */
174
+ declare function composesFrames(composition: {
175
+ closure: PoseClosure;
176
+ }): boolean;
177
+ /**
178
+ * Walk `id`'s parent chain and fold local poses into a world pose via
179
+ * `compose`. Cycle-safe.
180
+ *
181
+ * `compose(parent, child)` interprets `child` as expressed *in `parent`'s
182
+ * local frame* and returns the equivalent pose in the next frame up.
183
+ */
184
+ declare function composeWorldPose<TPose>(adapter: PoseAdapter<TPose>, id: string, compose: (parent: TPose, child: TPose) => TPose): TPose;
185
+ /**
186
+ * Convert `worldPose` into a local pose expressed under `newParentId`'s
187
+ * frame, so a reparented child keeps its visual world position.
188
+ *
189
+ * `decompose(parent, world)` returns the local pose `child` such that
190
+ * `compose(parent, child) === world`. Pass `newParentId === null` for the
191
+ * root frame; the function returns `worldPose` unchanged.
192
+ */
193
+ declare function rebaseLocalPose<TPose>(adapter: PoseAdapter<TPose>, worldPose: TPose, newParentId: string | null, compose: (parent: TPose, child: TPose) => TPose, decompose: (parent: TPose, world: TPose) => TPose): TPose;
194
+
195
+ /**
196
+ * Where a reported pose write came from.
197
+ *
198
+ * - `'call'` — a scene method called directly, alone or inside `scene.batch`:
199
+ * a button's `scene.setPose`, a `scene.add`.
200
+ * - `'ops'` — ops applied as one edit through `applyBatch` or `history.apply`,
201
+ * which is how actions commit: a drag's release, a resize, a nudge, an align.
202
+ * - `'undo'` / `'redo'` — a history step, a jump through the history included.
203
+ * - `'layout'` — a container's layout arranging what a live edit changed; also
204
+ * reported to `onReflow`.
205
+ * - `'untracked'` — a write inside `scene.untracked`, such as a pose target
206
+ * committing an animation's destination.
207
+ */
208
+ type PoseWriteOrigin = 'call' | 'ops' | 'undo' | 'redo' | 'layout' | 'untracked';
209
+ /** One node's pose as a scene change left it, in the node's stored frame. */
210
+ interface PoseWrite<TPose> {
211
+ id: NodeId;
212
+ /** The pose before the change; `undefined` for a node the change added. */
213
+ from: TPose | undefined;
214
+ to: TPose;
215
+ origin: PoseWriteOrigin;
216
+ /** The edit's label (`'setPose'`, a batch's, an action's `'Move'`) for
217
+ * `'call'` and `'ops'`; `undefined` otherwise. */
218
+ label?: string;
219
+ }
220
+ /** A removed node as it was last shown, with the descendants it took along. */
221
+ interface RemovedNode<TPose, TNode = unknown> {
222
+ /** The node as it stood before the change removed it. */
223
+ node: TNode;
224
+ /** Where it was shown, override included, in its stored frame. */
225
+ pose: TPose;
226
+ children: readonly RemovedNode<TPose, TNode>[];
227
+ }
228
+ /** One node a scene change removed, a removal's root: its descendants ride
229
+ * beneath it rather than being reported apart. */
230
+ interface PoseRemoval<TPose, TNode = unknown> extends RemovedNode<TPose, TNode> {
231
+ id: NodeId;
232
+ /** The parent it was removed from, which may still be in the scene. */
233
+ parent: NodeId | null;
234
+ origin: PoseWriteOrigin;
235
+ label?: string;
236
+ }
237
+ /** What a scene reports about the poses its edits write. */
238
+ interface ScenePoseReports<TPose, TNode = unknown> {
239
+ /** Called with the poses each live edit's layout pass wrote, after the
240
+ * edit lands — never for an undo or redo, which restore poses rather than
241
+ * arrange them. What a reflow animation glides from. */
242
+ onReflow(listener: (moves: readonly LayoutMove<TPose>[]) => void): () => void;
243
+ /** Called once per change, before the scene's subscribers hear of it, with
244
+ * every node whose pose the change wrote or that it added, and every node
245
+ * it removed — an undone add among them. A node written back to the pose
246
+ * it had, or both added and removed by the change, is left out of both.
247
+ * Not called for `loadState` or the scene's initial nodes. */
248
+ onPoseWrite(listener: (writes: readonly PoseWrite<TPose>[], removed: readonly PoseRemoval<TPose, TNode>[]) => void): () => void;
249
+ }
250
+
251
+ /**
252
+ * One node's ephemeral presentation override — what a frame loop wants to say
253
+ * about a node without saying it about the document.
254
+ *
255
+ * Not document content: never recorded in history, never in `toJSON`, and
256
+ * writing one does not bump `Scene.getVersion()`. Hoist one entry per node and
257
+ * mutate it in place on a frame loop; `PoseOverrides.commit()` is what makes a
258
+ * mutation visible.
259
+ */
260
+ interface PoseOverride<TPose> {
261
+ /** Replaces the node's document pose everywhere the render and hit-test
262
+ * paths read one, including the clip a container derives from its pose, and
263
+ * winning over a `derivePose`. Resolved by `effectivePose` — reading
264
+ * `node.pose` directly is how those paths came to disagree about where a
265
+ * node is. */
266
+ pose?: TPose;
267
+ /** Multiplied into the node's painted alpha, on top of any `alphaFor`. */
268
+ alpha?: number;
269
+ /** Replaces the geometry the node paints and is picked by: the path in its data, or the one
270
+ * it derives. It is in the frame a painter draws in, so give `pose` beside it, as the
271
+ * path's bounds with no rotation, or the pose's turn is applied to the path again and the
272
+ * selection chrome stays on the old box. A skinned rig is the writer. */
273
+ path?: Path;
274
+ }
275
+ /**
276
+ * The scene's ephemeral per-node overrides — see {@link PoseOverride}.
277
+ *
278
+ * The intended shape of a frame is: `set` each node once, mutate the entries
279
+ * in place per frame, `commit()` once. `commit` is not optional bookkeeping —
280
+ * the painter memo keys on pose *reference*, so a mutation without a commit
281
+ * paints the previous frame with no error.
282
+ *
283
+ * To promote a frame to document state (dropping a drag, baking an animation),
284
+ * write it once through `Scene.setPose` and `clear` the override.
285
+ */
286
+ interface PoseOverrides<TPose> {
287
+ /** Store `entry` for `id` **by reference**; the caller keeps mutating it. */
288
+ set(id: NodeId, entry: PoseOverride<TPose>): void;
289
+ /** The entry `set` stored, by reference — what a writer checks to know
290
+ * whether its own entry is still installed. Painting reads `read`. */
291
+ get(id: NodeId): PoseOverride<TPose> | undefined;
292
+ /** What the node is drawn and picked with: every source of overrides for
293
+ * it folded into one, as of the last write or `commit()`. `undefined` for
294
+ * a node nothing overrides. The object is reused per node. */
295
+ read(id: NodeId): PoseOverride<TPose> | undefined;
296
+ has(id: NodeId): boolean;
297
+ /** The overridden ids, as a snapshot array. */
298
+ ids(): readonly NodeId[];
299
+ clear(id: NodeId): void;
300
+ clearAll(): void;
301
+ /** Publish this frame's in-place mutations: invalidate the painter memo for
302
+ * every overridden node, then notify subscribers. */
303
+ commit(): void;
304
+ /** Notified after every write. The canvas uses this to repaint without a
305
+ * scene version bump. */
306
+ subscribe(fn: () => void): () => void;
307
+ /** Monotonic write counter. A snapshot for observers that poll. */
308
+ getGeneration(): number;
309
+ /** A claim on some nodes' poses for a writer that publishes a whole frame
310
+ * at a time: a gesture's preview, a layout run. Each call is a new claim. */
311
+ hold(): PoseHold<TPose>;
312
+ }
313
+ /**
314
+ * One writer's claim on some nodes' pose overrides, from
315
+ * {@link PoseOverrides.hold}.
316
+ *
317
+ * A hold knows which entries are its own, so several writers share the table
318
+ * without clearing each other: a drag and a layout run each publish their
319
+ * frame, and each sees the other's nodes as pinned.
320
+ */
321
+ interface PoseHold<TPose> {
322
+ /** Publish this frame's poses. It is the whole picture, not a delta: an id
323
+ * the frame leaves out is released. Subscribers are notified once. */
324
+ set(poses: Iterable<readonly [NodeId, TPose]>): void;
325
+ /** The poses other writers are publishing, by id. */
326
+ others(): ReadonlyMap<NodeId, TPose>;
327
+ /** Release every id still held. An id whose entry another writer has since
328
+ * replaced is left alone: that writer owns it now. When the frame is being
329
+ * committed to the document, call this after the write lands, or the scene
330
+ * answers with the old pose in between. */
331
+ drop(): void;
332
+ }
333
+
334
+ /** How a scene tells its readers it changed. */
335
+
336
+ interface SceneChanges {
337
+ /** Hear every change, a change of selection included. Returns the unsubscribe. */
338
+ subscribe(listener: () => void): () => void;
339
+ /** Monotonically increasing version. Snapshot for `useSyncExternalStore`. */
340
+ getVersion(): number;
341
+ /** {@link SceneChanges.getVersion} less the changes that only moved the selection: unmoved
342
+ * across a notice that changed nothing else. */
343
+ getContentVersion(): number;
344
+ }
345
+
346
+ /** One layer as it appears in a snapshot. A snapshot written before layer
347
+ * kind was serialized carries neither field, and loads as a system layer —
348
+ * which is what every layer in such a snapshot was. */
349
+ interface SerializedLayer<TLayer extends string> extends SystemLayerSpec<TLayer> {
350
+ kind?: 'system' | 'user';
351
+ /** Present on a user layer, absent on a system one. */
352
+ name?: string;
353
+ }
354
+ /** JSON-serializable shape of a Scene's current state. Produced by
355
+ * `scene.toJSON()`; consumed by `sceneFromJSON()`. Function fields
356
+ * (e.g., `clipFromPose`) appear as string keys (`clipFromPoseKey`) and
357
+ * are resolved through `SceneRegistry` at load time. */
358
+ interface SerializedScene<TData, TLayer extends string, TPose> {
359
+ version: 1;
360
+ /** The whole layer stack, system and user alike — the name predates user
361
+ * layers and is kept so existing snapshots still parse. */
362
+ systemLayers: readonly SerializedLayer<TLayer>[];
363
+ nodes: readonly SerializedNode<TData, TLayer, TPose>[];
364
+ /** The scene's document values, JSON only. Omitted when it has none. */
365
+ doc?: Readonly<Record<string, unknown>>;
366
+ }
367
+ /** JSON-serializable shape of a single node. Mirrors `AddNodeSpec` but
368
+ * with function fields replaced by registry keys. */
369
+ interface SerializedNode<TData, TLayer extends string, TPose> {
370
+ id: string;
371
+ kind: 'leaf' | 'container';
372
+ layer: TLayer;
373
+ pose: TPose;
374
+ data: TData;
375
+ /** Parent id; omitted for roots. */
376
+ parent?: string;
377
+ /** Registry key for the container's clip-path factory.
378
+ * Containers only; omitted when the container has no clip. */
379
+ clipFromPoseKey?: string;
380
+ /** Registry key for the container's `copiesFromPose`. Containers only;
381
+ * omitted when it draws no copies. */
382
+ copiesFromPoseKey?: string;
383
+ /** Ids this node's geometry derives from, or `'children'`. Omitted when it
384
+ * derives from nothing. */
385
+ dependsOn?: readonly string[] | 'children';
386
+ /** Mirrors `SceneNode.pickable`. Omitted when the node is pickable. */
387
+ pickable?: boolean;
388
+ /** Mirrors `SceneNode.hidden`. Omitted when the node is shown. */
389
+ hidden?: boolean;
390
+ /** Mirrors `SceneNode.locked`. Omitted when the node is unlocked. */
391
+ locked?: boolean;
392
+ /** Registry key for the node's `derivePath` function. Omitted when it has none. */
393
+ derivePathKey?: string;
394
+ /** Registry key for the node's `derivePose` function. Omitted when it has none. */
395
+ derivePoseKey?: string;
396
+ /** Registry key for the container's layout strategy. Omitted when it has none. */
397
+ layoutKey?: string;
398
+ /** Mirrors `ContainerNode.units`. Omitted when the container declares none. */
399
+ units?: UnitScope;
400
+ }
401
+
402
+ /**
403
+ * A scene's document values. Keys are namespaced by their owner
404
+ * (`core:pages`, `diagram:theme`); values are JSON, and are not to be mutated
405
+ * once set. A `set` is a scene edit: undoable, part of an enclosing `batch`,
406
+ * skipped when the value is deep-equal to the current one, and heard by
407
+ * `subscribe`. Setting `undefined` removes the key.
408
+ */
409
+ interface SceneDoc {
410
+ get<T = unknown>(key: string): T | undefined;
411
+ set(key: string, value: unknown): void;
412
+ keys(): readonly string[];
413
+ }
414
+ /** The part of `Scene` that carries its document values. */
415
+ interface SceneDocValues {
416
+ readonly doc: SceneDoc;
417
+ }
418
+ /** A snapshot's document values. */
419
+ type SerializedDoc = Readonly<Record<string, unknown>>;
420
+
421
+ /**
422
+ * Axis-aligned rectangle pose with optional rotation. Rotation is in
423
+ * radians, pivoted on the unrotated AABB center; absent === 0.
424
+ */
425
+ interface RectPose {
426
+ x: number;
427
+ y: number;
428
+ width: number;
429
+ height: number;
430
+ /** Rotation in radians around the unrotated AABB center. Absent === 0. */
431
+ rotation?: number;
432
+ /** A skew or per-axis scale the box and rotation cannot hold; see
433
+ * {@link PoseLinear}. Absent is the identity. */
434
+ transform?: PoseLinear;
435
+ }
436
+
437
+ /**
438
+ * One dependency, as a derivation reads it: the node itself and the pose it is
439
+ * painted at.
440
+ *
441
+ * The node comes along because a connector legitimately reads more than a box
442
+ * — an edge that thickens with its endpoint's weight, or routes only to nodes
443
+ * on a given layer, is answering off `data` and `layer`.
444
+ */
445
+ interface DerivedDep<TPose, TData = unknown, TLayer extends string = string> {
446
+ node: Node<TData, TLayer, TPose>;
447
+ /** Its override when it has one, else its own derived pose, else the pose
448
+ * the document stores — `effectivePose`, the same answer the renderer uses. */
449
+ pose: TPose;
450
+ /** The path a pose override shows it by, else the one it derives, else
451
+ * `null`; the document reading skips the override, and a `toPose` lookup
452
+ * carries it into the box its `toPose` answers. Read
453
+ * it to place something *along* a dependency: a label on a routed edge.
454
+ * Resolved on first read and memoized on the dependency. */
455
+ readonly path: Path | null;
456
+ }
457
+ /** `F` with its parameters checked bivariantly, as a method's are, so that a
458
+ * `Scene<D, L, MyPose>` is a `Scene<unknown, string, unknown>`. A callback for
459
+ * an unrelated pose is still rejected; one for a narrower pose is not. */
460
+ type Bivariant<F extends (...args: never[]) => unknown> = {
461
+ method(...args: Parameters<F>): ReturnType<F>;
462
+ }['method'];
463
+ /** Computes a node's path from its dependencies: the type of a node's
464
+ * `derivePath` and of each entry in `SceneRegistry.derivePath`. */
465
+ type DerivePathFn<TPose, TData = unknown, TLayer extends string = string> = Bivariant<(node: Node<TData, TLayer, TPose>, deps: readonly (DerivedDep<TPose, TData, TLayer> | undefined)[]) => Path | null>;
466
+ /** Computes a node's pose from its dependencies: the type of a node's
467
+ * `derivePose` and of each entry in `SceneRegistry.derivePose`. */
468
+ type DerivePoseFn<TPose, TData = unknown, TLayer extends string = string> = Bivariant<(node: Node<TData, TLayer, TPose>, deps: readonly (DerivedDep<TPose, TData, TLayer> | undefined)[]) => TPose | null>;
469
+ /** A container's clip, from its pose: the type of `ContainerNode.clipFromPose`
470
+ * and of each entry in `SceneRegistry.clipFromPose`. */
471
+ type ClipFromPoseFn<TPose> = Bivariant<(pose: TPose) => Path | null>;
472
+ /** The extra times a container draws its children: the type of
473
+ * `ContainerNode.copiesFromPose` and of each entry in
474
+ * `SceneRegistry.copiesFromPose`. Each affine is in world coordinates and
475
+ * carries the children, as drawn, to one copy. */
476
+ type CopiesFromPoseFn<TPose, TData = unknown, TLayer extends string = string> = Bivariant<(pose: TPose, node: ContainerNode<TData, TLayer, TPose>) => readonly Affine[] | null>;
477
+
478
+ /** Brand a string as a NodeId. */
479
+ declare const asNodeId: (s: string) => NodeId;
480
+
481
+ interface NodeBase<TData, TLayer extends string, TPose> {
482
+ id: NodeId;
483
+ layer: TLayer;
484
+ pose: TPose;
485
+ data: TData;
486
+ parent: NodeId | null;
487
+ /** Nodes whose poses this node's geometry is computed from. Fixed at add
488
+ * time. Absent or empty means the node's geometry is authored, which is the
489
+ * normal case.
490
+ *
491
+ * `'children'` means "my own children, in child order" — a container that
492
+ * hugs its contents, which a fixed id list cannot express because
493
+ * reparenting would have to maintain it. The two forms differ in lifetime
494
+ * as well as in membership: deleting a node deletes everything that names
495
+ * it in `dependsOn`, but a container outlives the children it derives
496
+ * from — an emptied group is still a group. */
497
+ dependsOn?: readonly NodeId[] | 'children';
498
+ /** Whether the hit-test walk can return this node. Default `true`; `false`
499
+ * makes it transparent to picking, so a click on it lands on whatever is
500
+ * behind — normally its own container.
501
+ *
502
+ * For content a container owns rather than content the user selects on its
503
+ * own: the label inside a box, a body's rows. It does not hide the node
504
+ * from anything else — it still paints, still clips, and a consumer can
505
+ * still select it by id. */
506
+ pickable?: boolean;
507
+ /** Not drawn, with its whole subtree: picking, area selection, select-all,
508
+ * snapping and the selection pass over it, and an SVG export writes it with
509
+ * `display="none"`. Absent means shown; `Scene.isHidden` folds in its
510
+ * ancestors' flags and its layer's visibility. */
511
+ hidden?: boolean;
512
+ /** Out of reach, with its whole subtree: still drawn, but picking and area
513
+ * selection pass over it, the selection drops it, and every edit to it
514
+ * throws, as on a locked layer. Absent means unlocked; `Scene.isLocked`
515
+ * folds in its ancestors' and its layer's. */
516
+ locked?: boolean;
517
+ /** Computes this node's path from its dependencies, in `dependsOn` order —
518
+ * each one the node and the pose it is painted at.
519
+ * A dependency that has been removed arrives as `undefined`.
520
+ * Returning `null` means "nothing to draw right now". Re-evaluated when a
521
+ * dependency's world pose changes, never authored. */
522
+ derivePath?: DerivePathFn<TPose, TData, TLayer>;
523
+ /** Computes this node's pose from its dependencies' poses, the same way
524
+ * `derivePath` computes its path — same `dependsOn` list, same
525
+ * registry-keyed serialization.
526
+ *
527
+ * Where a derived path is resolved at paint time and reaches only the
528
+ * painter, a derived pose is what the node *is* at: it feeds bounds,
529
+ * hit-testing, selection chrome, snapping and layout, and every reader
530
+ * gets it through `effectivePose`. A pose override still wins over it.
531
+ *
532
+ * Returning `null` means "I have nothing to derive from right now", and
533
+ * the node falls back to its authored `pose`. `setPose` on a derived node
534
+ * still writes that authored pose; it is simply not what anything reads. */
535
+ derivePose?: DerivePoseFn<TPose, TData, TLayer>;
536
+ }
537
+ /** A node with no children — a shape, a label, an image. */
538
+ interface LeafNode<TData, TLayer extends string, TPose = RectPose> extends NodeBase<TData, TLayer, TPose> {
539
+ kind: 'leaf';
540
+ }
541
+ /** A node with an ordered list of children. This is the real group: what
542
+ * Cmd+G creates, what SVG `<g>` round-trips to. A container has its own pose,
543
+ * which its children's poses are relative to, and may optionally clip them. */
544
+ interface ContainerNode<TData, TLayer extends string, TPose = RectPose> extends NodeBase<TData, TLayer, TPose> {
545
+ kind: 'container';
546
+ children: NodeId[];
547
+ /** Optional clip-path source. Re-evaluated each render. Returning `null`
548
+ * means "no clip for this container right now"; an empty / zero-area path
549
+ * means "clip everything out" (children render nowhere). */
550
+ clipFromPose?: ClipFromPoseFn<TPose>;
551
+ /** Draws the whole subtree again under each affine it returns, on top of
552
+ * the original, which still draws once as authored. The copies are paint,
553
+ * not nodes: nothing stores them, so they follow every edit to the
554
+ * children, and a pick that lands on one answers with the child it copies.
555
+ * A copy is a copy of the clipped content — the clip travels with it.
556
+ * Re-evaluated each render; `null` or `[]` draws no copies. */
557
+ copiesFromPose?: CopiesFromPoseFn<TPose, TData, TLayer>;
558
+ /** How this container arranges its children. Whenever the container's
559
+ * child set or order changes, its bounds change size, or a child's pose is
560
+ * written, the scene hands the change to the strategy — `depart` for children that left it,
561
+ * `arrive` for children that joined it, `childPoses` otherwise — and records the poses it writes in the same
562
+ * undo entry as the change. A drag reads it too: it is the layout `move`
563
+ * reflows and drops against. */
564
+ layout?: LayoutStrategy<TPose>;
565
+ /** The units its children are shown, typed and snapped in (their poses stay
566
+ * in world units), and what one base unit is worth in the enclosing scope's.
567
+ * It covers the children, not the container; `sceneUnitScopes` reads the chain. */
568
+ units?: UnitScope;
569
+ }
570
+ /** A node in the scene tree: either a leaf or a container. Re-exported
571
+ * publicly as `SceneNode`, to avoid colliding with the DOM's `Node`. */
572
+ type Node<TData, TLayer extends string, TPose = RectPose> = LeafNode<TData, TLayer, TPose> | ContainerNode<TData, TLayer, TPose>;
573
+ /** What `Scene.add` needs to mint a node. Everything except the id is
574
+ * required; the id is generated unless one is supplied. */
575
+ interface AddNodeSpec<TData, TLayer extends string, TPose = RectPose> {
576
+ kind: 'leaf' | 'container';
577
+ layer: TLayer;
578
+ pose: TPose;
579
+ data: TData;
580
+ parent?: NodeId | null;
581
+ index?: number;
582
+ /** Explicit id wins over the Scene's `generateId` and the kit default. */
583
+ id?: NodeId;
584
+ /** Mirrors `SceneNode.pickable`. Omit for the default, which is pickable. */
585
+ pickable?: boolean;
586
+ /** Mirrors `SceneNode.hidden`. */
587
+ hidden?: boolean;
588
+ /** Mirrors `SceneNode.locked`. */
589
+ locked?: boolean;
590
+ /** Only meaningful when `kind === 'container'`. Attach a clip-path function
591
+ * to the node; ignored for leaves. Mirrors `ContainerNode.clipFromPose`. */
592
+ clipFromPose?: ClipFromPoseFn<TPose>;
593
+ /** Mirrors `ContainerNode.copiesFromPose`; ignored for leaves. */
594
+ copiesFromPose?: CopiesFromPoseFn<TPose, TData, TLayer>;
595
+ /** Mirrors `SceneNode.dependsOn`. */
596
+ dependsOn?: readonly NodeId[] | 'children';
597
+ /** Mirrors `SceneNode.derivePath`. Taken as a live function; its registry key is
598
+ * looked up from it, never passed in. */
599
+ derivePath?: DerivePathFn<TPose, TData, TLayer>;
600
+ /** Mirrors `SceneNode.derivePose`, on the same terms as `derivePath`. */
601
+ derivePose?: DerivePoseFn<TPose, TData, TLayer>;
602
+ /** Mirrors `ContainerNode.layout`; ignored for leaves. */
603
+ layout?: LayoutStrategy<TPose>;
604
+ /** Mirrors `ContainerNode.units`; ignored for leaves. */
605
+ units?: UnitScope;
606
+ }
607
+ /** A custom scene mutation registered with `Scene.registerOp`: how to apply
608
+ * it and how to undo it. The pair is what makes it participate in history. */
609
+ interface RegisteredOp<P> {
610
+ apply: (payload: P) => void;
611
+ revert: (payload: P) => void;
612
+ /** Opts this kind into coalescing under `UseSceneOptions.coalesceWindowMs`:
613
+ * two entries of this kind that return the same key inside the window
614
+ * merge, and undoing the merged entry calls `revert` with the first
615
+ * payload only. Declare it only when `revert` restores an absolute state
616
+ * (a stored "from" value), never for a relative payload such as a delta.
617
+ * Omitted, or returning `undefined`, the op is always its own entry. */
618
+ coalesceKey?: (payload: P) => string | undefined;
619
+ }
620
+ /** Per-scene registry mapping string keys to live function references.
621
+ * Passed to `createScene({ ..., registry })` and `sceneFromJSON(json, { registry })`.
622
+ * Each function-field type has its own keyed map. */
623
+ interface SceneRegistry<TPose, TData = unknown, TLayer extends string = string> {
624
+ /** Maps registry keys to `clipFromPose` factory functions for container nodes. */
625
+ clipFromPose?: Readonly<Record<string, ClipFromPoseFn<TPose>>>;
626
+ /** Maps registry keys to `copiesFromPose` functions for container nodes. */
627
+ copiesFromPose?: Readonly<Record<string, CopiesFromPoseFn<TPose, TData, TLayer>>>;
628
+ /** Maps registry keys to `derivePath` functions for nodes with `dependsOn`. */
629
+ derivePath?: Readonly<Record<string, DerivePathFn<TPose, TData, TLayer>>>;
630
+ /** Maps registry keys to `derivePose` functions for nodes with `dependsOn`. */
631
+ derivePose?: Readonly<Record<string, DerivePoseFn<TPose, TData, TLayer>>>;
632
+ /** Maps registry keys to container layout strategies. */
633
+ layout?: Readonly<Record<string, LayoutStrategy<TPose>>>;
634
+ }
635
+ /**
636
+ * Decides what one edit's changes to containers do to their children.
637
+ * `arrivals` maps each container to the ids that joined it — by an `add`
638
+ * under it or a `move` into it, whatever op or call made them — in the order
639
+ * they arrived. `changed` names every container whose child set or order
640
+ * changed, whose pose changed size, or one of whose children was posed,
641
+ * arrivals included. Both are read once the edit's other mutations have landed.
642
+ *
643
+ * Return the poses to write, in each node's stored frame; they become part of
644
+ * the same edit, and so of the same undo step. An empty map writes nothing.
645
+ * Return `null` to refuse: the whole edit is reverted (see
646
+ * `SceneArrivalRefused`).
647
+ *
648
+ * Runs only for live edits. Undo, redo and a restored history replay the
649
+ * arrangement that was decided the first time. With none installed, a scene
650
+ * holding declared layouts (`ContainerNode.layout`) runs its own.
651
+ */
652
+ type SceneArrivalHandler<TPose> = (arrivals: ReadonlyMap<NodeId, readonly NodeId[]>, changed: ReadonlySet<NodeId>,
653
+ /** The nodes that left each container in the edit, by the container they
654
+ * left — removed, or moved out. */
655
+ departures: ReadonlyMap<NodeId, readonly NodeId[]>) => ReadonlyMap<NodeId, TPose> | null;
656
+ /**
657
+ * The kit-owned scene tree: nodes, layers, and the undo history over both.
658
+ *
659
+ * A scene is logical, not visual — it says what exists and where, and nothing
660
+ * about how it is painted. Every mutating method is undoable, and reads are
661
+ * snapshots rather than live views. Nodes are addressed by `NodeId`; hold ids
662
+ * across mutations, not node objects.
663
+ *
664
+ * Three type parameters keep it domain-agnostic: `TData` is the app's payload,
665
+ * which the kit never inspects; `TPose` is the transform shape, `RectPose` by
666
+ * default; `TLayer` is the union of layer names.
667
+ */
668
+ interface Scene<TData, TLayer extends string, TPose = RectPose> extends ScenePoseReports<TPose, Node<TData, TLayer, TPose>>, SceneChanges, SceneDocValues, SceneEditPasses {
669
+ readonly nodes: ReadonlyMap<NodeId, Node<TData, TLayer, TPose>>;
670
+ readonly roots: readonly NodeId[];
671
+ readonly layers: readonly LayerRecord<TLayer>[];
672
+ /** The registry this scene resolves node functions against — the consumer's
673
+ * entries over the kit's. */
674
+ readonly registry: SceneRegistry<TPose, TData, TLayer>;
675
+ /** See {@link UseSceneOptions.composition}. */
676
+ readonly composition: PoseComposition<TPose>;
677
+ get(id: NodeId): Node<TData, TLayer, TPose> | undefined;
678
+ /** A token for the node `id` names right now, for telling one node from a
679
+ * later one that reuses its id. It holds for as long as the node stays in
680
+ * the scene, whatever edits it takes, and is different every time the id
681
+ * enters the scene — by `add`, by an undo or redo that brings it back, or
682
+ * by `loadState`. `undefined` when `id` is not in the scene. Compare tokens
683
+ * for equality only; their order means nothing. */
684
+ incarnation(id: NodeId): number | undefined;
685
+ childrenOf(id: NodeId): readonly NodeId[];
686
+ ancestorsOf(id: NodeId): readonly NodeId[];
687
+ renderOrder(): Iterable<NodeId>;
688
+ /** The same layer-major sequence as {@link Scene.renderOrder}, as the nodes
689
+ * themselves. Prefer this wherever the ids are only going to be resolved
690
+ * back to nodes. Cached until a structural edit, so repeat calls hand back
691
+ * the same array — a snapshot, not a live view, and not yours to mutate. */
692
+ renderOrderNodes(): readonly Node<TData, TLayer, TPose>[];
693
+ /** The nodes on one layer, in render order. Cached alongside
694
+ * {@link Scene.renderOrderNodes} until a structural edit. A snapshot, not
695
+ * a live view, and not yours to mutate. An unknown layer id yields an
696
+ * empty array. */
697
+ nodesOnLayer(layer: TLayer): readonly Node<TData, TLayer, TPose>[];
698
+ /** A fresh id from this scene's `generateId`, or the kit default: the id
699
+ * `add` would give a spec with none. For code that has to name a node
700
+ * before it exists, such as one building an insert op. */
701
+ mintId(): NodeId;
702
+ add(spec: AddNodeSpec<TData, TLayer, TPose>): NodeId;
703
+ /** Delete `id`, its **entire subtree**, and **everything that derives from**
704
+ * any of those nodes — a node listing one of them in `dependsOn` goes too,
705
+ * along with its own subtree, transitively. A dependent can live anywhere in
706
+ * the tree, so this deletes nodes the caller never named and may unlink
707
+ * several disjoint subtrees at once. Recorded as one undoable step; `undo()`
708
+ * restores every one of them where it was, child order intact. */
709
+ remove(id: NodeId): void;
710
+ /** {@link remove} over several roots at once, as a **single** undoable step.
711
+ * Ids resolve against the tree as it stands at the call, so an id that
712
+ * another one would cascade away is absorbed rather than removed twice —
713
+ * which is what makes it safe to pass a whole selection. Throws if any id is
714
+ * not in the scene; an empty list does nothing and records no step. */
715
+ removeMany(ids: readonly NodeId[]): void;
716
+ /** Every node {@link removeMany} would take if given `ids`: each id, its
717
+ * subtree, everything deriving from any of those, and those nodes' subtrees
718
+ * in turn. Ids not in the scene come back unchanged.
719
+ *
720
+ * A set, not a restore order: a dependent can be reached before the parent
721
+ * it sits under, which is also in the closure. */
722
+ removalClosure(ids: readonly NodeId[]): readonly NodeId[];
723
+ update(id: NodeId, patch: {
724
+ data: TData;
725
+ }): void;
726
+ setPose(id: NodeId, pose: TPose): void;
727
+ /** Retag `id` to `layer`. On a **container this cascades**: every descendant
728
+ * is moved to the same layer, recorded as a **single** undo step.
729
+ *
730
+ * Invariants:
731
+ * - **Layer floor** — a child may not render below its parent, so retagging
732
+ * to a layer *below* the node's parent throws. Retagging to the parent's
733
+ * layer or any higher one is allowed; a node with no parent is
734
+ * unconstrained.
735
+ * - **No-op elision** — setting the layer a node already has does nothing
736
+ * and pushes **no** history entry. */
737
+ setLayer(id: NodeId, layer: TLayer): void;
738
+ /** Point `id` at a different set of dependencies — retargeting an edge's end
739
+ * onto another node, or switching a container between an id list and
740
+ * `'children'`. Recorded as one undoable step.
741
+ *
742
+ * Order is significant: a derivation reads its dependencies positionally,
743
+ * so `[b, a]` is not `[a, b]`. Ids need not be in the scene — a declared
744
+ * dependency that appears later invalidates the node when it does, the same
745
+ * as one declared at `add`. Passing `undefined` drops the declaration, after
746
+ * which nothing cascades the node away.
747
+ *
748
+ * **No-op elision** — declaring what the node already declares does nothing
749
+ * and pushes no history entry. */
750
+ setDependsOn(id: NodeId, dependsOn: readonly NodeId[] | 'children' | undefined): void;
751
+ /** Give container `id` a different layout — a strategy, its key in
752
+ * `SceneRegistry.layout`, or `null` for none — and re-arrange its children
753
+ * under it, as one undoable step. Throws for a leaf, or a key the registry
754
+ * does not hold. A registered layout is recorded by its key, so a
755
+ * serialized history restores it; an unregistered one lives only as long
756
+ * as the session.
757
+ *
758
+ * **No-op elision** — setting the layout a container already has does
759
+ * nothing and pushes no history entry. */
760
+ setLayout(id: NodeId, layout: LayoutStrategy<TPose> | string | null): void;
761
+ /** Reparent `id` under `parent` (or to a root when `parent` is `null`) at
762
+ * `index` within the new sibling list, appending when `index` is omitted.
763
+ * Siblings are reindexed. Recorded as one undoable step.
764
+ *
765
+ * Rejected (throws) when:
766
+ * - `parent` exists but is a **leaf**, not a container;
767
+ * - the move would form a **cycle** — `parent` is `id` itself or one of
768
+ * `id`'s own descendants;
769
+ * - it would drop `id` **below its new parent's layer** (child may not
770
+ * render below its parent).
771
+ *
772
+ * `move(id, null)` — detaching to a root — is always allowed regardless of
773
+ * layer, since a root has no parent to render beneath. */
774
+ move(id: NodeId, parent: NodeId | null, index?: number): void;
775
+ /** Shift `id` to `index` within its **current** parent's child list. Unlike
776
+ * {@link move}, the parent never changes — only sibling order. */
777
+ reorder(id: NodeId, index: number): void;
778
+ /** Show or hide a layer. Hiding drops its nodes from the selection. */
779
+ setLayerVisible(layer: TLayer, visible: boolean): void;
780
+ /** Lock or unlock a layer. A locked layer still paints, but its nodes are
781
+ * out of reach: picking and area selection pass over them, the selection
782
+ * drops them, and every node mutation on them throws. Locking is never
783
+ * blocked by the lock, and neither are the other layer operations. */
784
+ setLayerLocked(layer: TLayer, locked: boolean): void;
785
+ /** Set or clear (`undefined`) a layer's parallax — see
786
+ * `LayerRecord.parallax`. Undoable; an animation tweening it writes inside
787
+ * {@link Scene.untracked} so no frame becomes an undo step. */
788
+ setLayerParallax(layer: TLayer, parallax: ParallaxOpts | undefined): void;
789
+ /** Whether `id` is locked: it or an ancestor carries `locked`, or sits on a
790
+ * locked layer. A lock covers its whole subtree, whatever layers the
791
+ * descendants are tagged to. An id not in the scene is not locked. */
792
+ isLocked(id: NodeId): boolean;
793
+ /** Whether `id` is not drawn: its own layer is hidden, or it or an ancestor
794
+ * carries `hidden`. A hidden layer hides only the nodes tagged to it. An
795
+ * id not in the scene is not hidden. */
796
+ isHidden(id: NodeId): boolean;
797
+ /** Hide or show node `id` and its subtree — see `SceneNode.hidden`. One
798
+ * undo step; hiding drops the subtree from the selection. Never blocked by
799
+ * a lock, and setting what the node already has records nothing. */
800
+ setHidden(id: NodeId, hidden: boolean): void;
801
+ /** Lock or unlock node `id` and its subtree — see `SceneNode.locked`. One
802
+ * undo step; locking drops the subtree from the selection. Never blocked
803
+ * by a lock, and setting what the node already has records nothing. */
804
+ setLocked(id: NodeId, locked: boolean): void;
805
+ /** Run `fn` with the lock guard lifted, for a programmatic edit that has to
806
+ * reach a locked node. Undo and redo never need it. */
807
+ unlocked<T>(fn: () => T): T;
808
+ addLayer(spec: AddLayerSpec<TLayer>): void;
809
+ /** Drop a user layer and every node tagged to it, as one undoable step.
810
+ * Removal cascades, so this also deletes nodes **on other layers** that
811
+ * derive from a node on this one. */
812
+ removeLayer(layer: TLayer): void;
813
+ renameLayer(layer: TLayer, name: string): void;
814
+ moveLayer(layer: TLayer, index: number): void;
815
+ registerOp<P>(kind: string, handler: RegisteredOp<P>): void;
816
+ recordOp<P>(op: {
817
+ kind: string;
818
+ payload: P;
819
+ }): void;
820
+ /** Install (or clear with `null`) the active-journal accessor after scene
821
+ * construction, for a journal source built with `scene.history` as a
822
+ * dependency. Overrides any `getActiveJournal` set in `UseSceneOptions`. */
823
+ setActiveJournalAccessor(fn: (() => _weasel_js_history.Journal | null) | null): void;
824
+ /** Install what the scene does when nodes join a container, replacing any
825
+ * handler installed before; `null` removes it. Returns a function that
826
+ * removes this handler, and does nothing once another has replaced it.
827
+ * See {@link SceneArrivalHandler}. */
828
+ setArrivalHandler(handler: SceneArrivalHandler<TPose> | null): () => void;
829
+ /** Apply a batch of ops against `adapter` as one undo entry.
830
+ *
831
+ * The entry holds the scene writes the ops made, as a direct call records
832
+ * them, and beside them any op that wrote no scene state, bound to
833
+ * `adapter`. Undo restores those writes; it does not call an op's
834
+ * `invert()` or the adapter again. **What an op states is not recorded**:
835
+ * one applied over a document that already holds its result, as after an
836
+ * `untracked` preview, records a write from that pose to itself, and undo
837
+ * goes nowhere. Put the document back first.
838
+ *
839
+ * The entry lands in the open `batch` when there is one, else on the
840
+ * active journal, else on the scene's own history, where it can coalesce
841
+ * under `coalesceWindowMs` with one whose ops' keys match.
842
+ *
843
+ * Returns false when the arrival handler refused the batch: it is reverted
844
+ * and unrecorded. Inside `batch` it is true; that batch may still refuse. */
845
+ applyBatch(ops: Op[], label: string, adapter: unknown): boolean;
846
+ /** The transient set of active ids — "operate on these N as a unit".
847
+ * Shared by every view over this scene unless a view supplies its own
848
+ * (see `CanvasView.selection`). Not document content: it never appears
849
+ * in `toJSON`. It does ride on history entries, so undo and redo put
850
+ * back the selection an edit was made under; changing it is never an
851
+ * undo step of its own. Removing a node deselects it. */
852
+ getSelection(): readonly NodeId[];
853
+ setSelection(ids: readonly NodeId[]): void;
854
+ /** Per-node pose / alpha overrides the render and hit-test paths read
855
+ * through. Like {@link Scene.getSelection} this is not document content:
856
+ * writes are never recorded, never serialized, and do not bump
857
+ * {@link Scene.getVersion}. See {@link PoseOverrides}. */
858
+ readonly overrides: PoseOverrides<TPose>;
859
+ /** The scene's undo/redo engine, in the shape `@weasel-js/history` defines.
860
+ * Mutating members route through
861
+ * the scene's own wrappers, so an undo driven through this bumps
862
+ * {@link Scene.getVersion} and notifies subscribers exactly as
863
+ * {@link Scene.undo} does; `getVersion` / `subscribe` on it report the
864
+ * engine's history version, not the scene's. */
865
+ readonly history: History;
866
+ undo(): boolean;
867
+ redo(): boolean;
868
+ canUndo(): boolean;
869
+ canRedo(): boolean;
870
+ batch<T>(label: string, fn: () => T, options?: SceneBatchOptions): T;
871
+ /** The layout container `id` declares, or `null` for a leaf or a
872
+ * container that declares none. */
873
+ layoutOf(id: NodeId): LayoutStrategy<TPose> | null;
874
+ /** Declare the unit scope of container `id`, or clear it with `null`. */
875
+ setUnits(id: NodeId, units: UnitScope | null): void;
876
+ /** Run `fn` with every mutation applied but none recorded — for writes
877
+ * that are not edits, such as a simulation stepping poses each frame.
878
+ * Undo and redo move between recorded states and never restore an
879
+ * untracked write; the next recorded change starts from whatever the
880
+ * untracked writes left, so undoing it lands there. A `batch` inside
881
+ * records nothing; inside a `batch`, these writes stay out of its entry.
882
+ * Notifies once, reverts `fn`'s writes if it throws, and throws on
883
+ * `applyBatch` and `history.apply` / `applyOps`, which exist to record. */
884
+ untracked<T>(fn: () => T): T;
885
+ /** Read-only snapshot of every history entry currently reachable from
886
+ * the present state. Oldest applied first, then redoable entries in
887
+ * the order they'd be re-applied. Each entry id is stable. */
888
+ historyEntries(): readonly {
889
+ id: string;
890
+ label: string;
891
+ }[];
892
+ /** Index of the "current state". Equals the count of applied entries;
893
+ * `0` means "nothing applied" (initial). */
894
+ historyIndex(): number;
895
+ /** Jump to the given history index, clamped to [0, total]. Returns true
896
+ * if any movement occurred. */
897
+ jumpToHistoryIndex(index: number): boolean;
898
+ /** Snapshot the undo/redo history in a JSON-serializable form (the
899
+ * engine's `SerializedHistory`, marked with the scene's recorded form).
900
+ * An entry holds the scene's own ops, whichever way the edit was made.
901
+ * An op handed to `applyBatch` that wrote no scene state is held as
902
+ * itself, and an entry with a nameless one is dropped. Payload
903
+ * JSON-safety (e.g. typed arrays inside poses) is the caller's concern.
904
+ * Do not call mid-`batch` — the open batch's ops are not yet recorded. */
905
+ serializeHistory(): SerializedSceneHistory;
906
+ /** Replace the undo/redo history from a `serializeHistory()` snapshot.
907
+ * Call on a scene whose node/layer state already matches the snapshot's
908
+ * head state (i.e. right after `loadState` from the paired scene
909
+ * snapshot); node state is NOT mutated. Ops re-registered via
910
+ * `registerOp` before this call round-trip; unknown kinds become no-op
911
+ * placeholders; external ops rebuild via the global op-factory registry
912
+ * and replay against the `setHistoryAdapter` accessor. Restored entries
913
+ * never coalesce with new ones. Notifies once. A snapshot that is not in
914
+ * the current recorded form (see `SCENE_HISTORY_FORM`) is dropped:
915
+ * the history is left as it was. Do not call mid-`batch`:
916
+ * the stacks are replaced underneath the open batch, whose eventual
917
+ * flush would graft onto (and evict against) the restored stacks. */
918
+ restoreHistory(snapshot: SerializedHistory): void;
919
+ /** Install (or clear with `null`) the accessor for the adapter that
920
+ * RESTORED external ops apply against on undo/redo: the ops handed to
921
+ * `applyBatch` that wrote no scene state, such as a selection change,
922
+ * rebuilt from a `restoreHistory` snapshot. Resolved lazily at each
923
+ * apply, so wiring order relative to `restoreHistory` doesn't matter.
924
+ * Live `applyBatch` entries are unaffected (they bind their call-site
925
+ * adapter). If unset when a restored op applies, the op is a debug-warned
926
+ * no-op. */
927
+ setHistoryAdapter(fn: (() => unknown) | null): void;
928
+ /** Snapshot the current scene state to a JSON-serializable shape.
929
+ * History (undo/redo stacks) is NOT captured. Function fields like
930
+ * `ContainerNode.clipFromPose` are translated to string keys via the
931
+ * scene's registry; throws if any function field has no matching key. */
932
+ toJSON(): SerializedScene<TData, TLayer, TPose>;
933
+ /** Replace this scene's entire node + layer state in place from a snapshot
934
+ * produced by `toJSON()`. Unlike `sceneFromJSON`, the existing Scene
935
+ * instance is preserved — holders such as `<SceneCanvas>` keep their
936
+ * reference. History (undo/redo) is cleared, matching `sceneFromJSON`.
937
+ * Bumps `getVersion()` and notifies subscribers exactly once. Selected
938
+ * ids the snapshot does not hold leave the selection, and every pose
939
+ * override is cleared.
940
+ *
941
+ * Throws inside any other edit — `batch`, `untracked`, `applyBatch`, an
942
+ * undo — which would revert to a state this replaces. Throws on an unsupported version or unknown registry/layer ids; on a
943
+ * malformed snapshot the scene is left empty or partially populated (callers should treat a
944
+ * `loadState` throw as fatal and reload). Snapshots from `toJSON()` are
945
+ * always well-formed. */
946
+ loadState(json: SerializedScene<TData, TLayer, TPose>): void;
947
+ }
948
+
949
+ export { type AddNodeSpec as A, type Bivariant as B, type ClipFromPoseFn as C, type DerivePoseFn as D, type SceneDocValues as E, type SceneEditPass as F, type SceneEditPassOptions as G, type SceneEditSummary as H, IDENTITY_POSE_COMPOSITION as I, type SerializedDoc as J, type SerializedLayer as K, type LayoutFrame as L, type SerializedNode as M, type Node as N, type SerializedSceneHistory as O, type PoseComposition as P, type SystemLayerRecord as Q, type RectPose as R, type Scene as S, asNodeId as T, type UserLayerRecord as U, composeWorldPose as V, composesFrames as W, rebaseLocalPose as X, type SystemLayerSpec as a, type RegisteredOp as b, type SceneRegistry as c, type PoseAdapter as d, type PoseRemoval as e, type PoseWrite as f, type ScenePoseReports as g, type PoseOverrides as h, type SerializedScene as i, type DerivePathFn as j, type DerivedDep as k, type AddLayerSpec as l, type ContainerNode as m, type CopiesFromPoseFn as n, type LayerRecord as o, type LayoutMove as p, type LeafNode as q, type PoseClosure as r, type PoseHold as s, type PoseOverride as t, type PoseWriteOrigin as u, type RemovedNode as v, SCENE_HISTORY_FORM as w, type SceneArrivalHandler as x, type SceneBatchOptions as y, type SceneDoc as z };