@weasel-js/core 1.9.3 → 1.9.4

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 (542) hide show
  1. package/CHANGELOG.md +356 -0
  2. package/README.md +2 -2
  3. package/dist/WeaselProvider.js +5 -5
  4. package/dist/affordances/composeAffordanceLayer.js +10 -20
  5. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  6. package/dist/affordances/cornerResize.js +25 -17
  7. package/dist/affordances/cornerResize.js.map +1 -1
  8. package/dist/affordances/hitAffordanceRegions.js +27 -20
  9. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  10. package/dist/affordances/rotationHandle.js +18 -18
  11. package/dist/affordances/rotationHandle.js.map +1 -1
  12. package/dist/animation/behaviors/momentum.js +93 -55
  13. package/dist/animation/behaviors/momentum.js.map +1 -1
  14. package/dist/animation/loop.js +10 -12
  15. package/dist/animation/loop.js.map +1 -1
  16. package/dist/animation/reflow.js +8 -8
  17. package/dist/animation/reflow.js.map +1 -1
  18. package/dist/animation/stagger.js +64 -56
  19. package/dist/animation/stagger.js.map +1 -1
  20. package/dist/animation/timeline/booking.js +62 -54
  21. package/dist/animation/timeline/booking.js.map +1 -1
  22. package/dist/animation/timeline/createTimeline.js +85 -76
  23. package/dist/animation/timeline/createTimeline.js.map +1 -1
  24. package/dist/animation/timeline/sampleTrack.js +13 -5
  25. package/dist/animation/timeline/sampleTrack.js.map +1 -1
  26. package/dist/animation/useAnimator.js +45 -35
  27. package/dist/animation/useAnimator.js.map +1 -1
  28. package/dist/animation/wrappers/animateLifecycle.js +31 -24
  29. package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
  30. package/dist/animation/wrappers/animateOnSetPose.js +28 -26
  31. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
  32. package/dist/animation/wrappers/instantPose.js +13 -0
  33. package/dist/animation/wrappers/instantPose.js.map +1 -0
  34. package/dist/{poseDescriptor-D-OH-tu5.d.ts → autoPoseDescriptor-Ct7yqivU.d.ts} +28 -3
  35. package/dist/barrel/chrome.js +16 -0
  36. package/dist/barrel/input.js +19 -0
  37. package/dist/barrel/interactions.js +42 -0
  38. package/dist/barrel/paint.js +18 -0
  39. package/dist/barrel/paths.js +19 -0
  40. package/dist/barrel/renderer.js +20 -0
  41. package/dist/barrel/routing.js +51 -0
  42. package/dist/barrel/text.js +18 -0
  43. package/dist/barrel/viewport.js +52 -0
  44. package/dist/builtins-DPcdghtB.d.ts +1223 -0
  45. package/dist/canvas/Canvas.js +363 -448
  46. package/dist/canvas/Canvas.js.map +1 -1
  47. package/dist/canvas/CanvasView.js +164 -165
  48. package/dist/canvas/CanvasView.js.map +1 -1
  49. package/dist/canvas/CursorCoordsHud.js +37 -32
  50. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  51. package/dist/canvas/DrawCanvas.js +49 -43
  52. package/dist/canvas/DrawCanvas.js.map +1 -1
  53. package/dist/canvas/MinimapCanvas.js +26 -25
  54. package/dist/canvas/MinimapCanvas.js.map +1 -1
  55. package/dist/canvas/NodeShape.js +59 -377
  56. package/dist/canvas/NodeShape.js.map +1 -1
  57. package/dist/canvas/PickHud.js +50 -47
  58. package/dist/canvas/PickHud.js.map +1 -1
  59. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +167 -0
  60. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
  61. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +13 -13
  62. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +67 -0
  63. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
  64. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
  65. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
  66. package/dist/canvas/SceneCanvas/coordTrace.js +10 -0
  67. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
  68. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +112 -70
  69. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  70. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
  71. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
  72. package/dist/canvas/SceneCanvas/features.js +1 -0
  73. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  74. package/dist/canvas/SceneCanvas/isDev.js +12 -0
  75. package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
  76. package/dist/canvas/SceneCanvas/poseGeometry.js +29 -28
  77. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  78. package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
  79. package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/props.js +38 -0
  81. package/dist/canvas/SceneCanvas/props.js.map +1 -0
  82. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
  83. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  84. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  85. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +46 -48
  86. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  87. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +33 -33
  88. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  89. package/dist/canvas/SceneCanvas.js +534 -788
  90. package/dist/canvas/SceneCanvas.js.map +1 -1
  91. package/dist/canvas/SceneViewCanvas.js +45 -43
  92. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  93. package/dist/canvas/buildSceneLayer.js +91 -0
  94. package/dist/canvas/buildSceneLayer.js.map +1 -0
  95. package/dist/canvas/buildSceneTree.js +16 -19
  96. package/dist/canvas/buildSceneTree.js.map +1 -1
  97. package/dist/canvas/canvasRenderer.js +68 -52
  98. package/dist/canvas/canvasRenderer.js.map +1 -1
  99. package/dist/canvas/deps/changes.js +13 -0
  100. package/dist/canvas/deps/changes.js.map +1 -0
  101. package/dist/canvas/deps/editAnchors.js +28 -28
  102. package/dist/canvas/deps/insert.js +119 -91
  103. package/dist/canvas/deps/insert.js.map +1 -1
  104. package/dist/canvas/deps/slice.js +46 -45
  105. package/dist/canvas/deps/slice.js.map +1 -1
  106. package/dist/canvas/deps/textEdit.js +10 -9
  107. package/dist/canvas/deps/textEdit.js.map +1 -1
  108. package/dist/canvas/derivedPath.js +46 -23
  109. package/dist/canvas/derivedPath.js.map +1 -1
  110. package/dist/canvas/getNodeAtPoint.js +7 -7
  111. package/dist/canvas/getNodeAtPoint.js.map +1 -1
  112. package/dist/canvas/hud.module.js +1 -1
  113. package/dist/canvas/hud.module.js.map +1 -1
  114. package/dist/canvas/kitRequirements.js +2 -2
  115. package/dist/canvas/kitRequirements.js.map +1 -1
  116. package/dist/canvas/layerOrder.js +13 -6
  117. package/dist/canvas/layerOrder.js.map +1 -1
  118. package/dist/canvas/minimapMath.js +12 -10
  119. package/dist/canvas/minimapMath.js.map +1 -1
  120. package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
  121. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
  122. package/dist/canvas/nodeShapes/imagePainter.js +87 -0
  123. package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
  124. package/dist/canvas/nodeShapes/memo.js +9 -0
  125. package/dist/canvas/nodeShapes/memo.js.map +1 -0
  126. package/dist/canvas/nodeShapes/nodePaint.js +57 -0
  127. package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
  128. package/dist/canvas/nodeShapes/pathPainter.js +38 -0
  129. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
  130. package/dist/canvas/nodeShapes/poseBox.js +20 -0
  131. package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
  132. package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
  133. package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
  134. package/dist/canvas/nodeShapes/shapePainter.js +72 -0
  135. package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
  136. package/dist/canvas/nodeShapes/textPainter.js +55 -0
  137. package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
  138. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  139. package/dist/canvas/paintCull.js +10 -11
  140. package/dist/canvas/paintCull.js.map +1 -1
  141. package/dist/canvas/pickWalk.js +52 -63
  142. package/dist/canvas/pickWalk.js.map +1 -1
  143. package/dist/canvas/poseRotation.js +11 -23
  144. package/dist/canvas/poseRotation.js.map +1 -1
  145. package/dist/canvas/renderDebugSnapshot.js +5 -5
  146. package/dist/canvas/renderSceneToPixels.js +3 -1
  147. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  148. package/dist/canvas/sceneAdapter.js +66 -148
  149. package/dist/canvas/sceneAdapter.js.map +1 -1
  150. package/dist/canvas/sceneClipboard.js +112 -0
  151. package/dist/canvas/sceneClipboard.js.map +1 -0
  152. package/dist/canvas/sceneSlotWiring.js +4 -4
  153. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  154. package/dist/canvas/sceneViewRender.js +39 -40
  155. package/dist/canvas/sceneViewRender.js.map +1 -1
  156. package/dist/canvas/useCanvasRenderer.js +14 -6
  157. package/dist/canvas/useCanvasRenderer.js.map +1 -1
  158. package/dist/canvas/useCanvasView.js +58 -0
  159. package/dist/canvas/useCanvasView.js.map +1 -0
  160. package/dist/canvas/useFrameLoop.js +35 -26
  161. package/dist/canvas/useFrameLoop.js.map +1 -1
  162. package/dist/canvas/useSceneLayerList.js +21 -0
  163. package/dist/canvas/useSceneLayerList.js.map +1 -0
  164. package/dist/clipboard.d.ts +10 -6
  165. package/dist/clone.d.ts +4 -3
  166. package/dist/core/adapters/arrayAdapter.js +48 -39
  167. package/dist/core/adapters/arrayAdapter.js.map +1 -1
  168. package/dist/core/device/index.js +5 -4
  169. package/dist/core/device/useDeviceProfile.js +38 -44
  170. package/dist/core/device/useDeviceProfile.js.map +1 -1
  171. package/dist/core/device/watchDevicePixelRatio.js +17 -0
  172. package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
  173. package/dist/core/fillInPoseFrame.js.map +1 -1
  174. package/dist/core/geometry/poseDescriptor.js +21 -19
  175. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  176. package/dist/core/geometry/poseFrame.js +44 -0
  177. package/dist/core/geometry/poseFrame.js.map +1 -0
  178. package/dist/core/geometry/poseRotation.js.map +1 -1
  179. package/dist/core/geometry/regionHit.js +9 -10
  180. package/dist/core/geometry/regionHit.js.map +1 -1
  181. package/dist/core/geometry/unionBounds.js +31 -29
  182. package/dist/core/geometry/unionBounds.js.map +1 -1
  183. package/dist/core/isPlainObject.js +2 -11
  184. package/dist/core/ops/arrange.js +1 -0
  185. package/dist/core/ops/arrange.js.map +1 -1
  186. package/dist/core/ops/create.js +10 -5
  187. package/dist/core/ops/create.js.map +1 -1
  188. package/dist/core/ops/delete.js +12 -24
  189. package/dist/core/ops/delete.js.map +1 -1
  190. package/dist/core/ops/reorder/index.js +43 -40
  191. package/dist/core/ops/reorder/index.js.map +1 -1
  192. package/dist/core/ops/reorder/setChildOrder.js +34 -0
  193. package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
  194. package/dist/core/paintKinds.js +5 -5
  195. package/dist/core/paintKinds.js.map +1 -1
  196. package/dist/core/scene/NodeProperties.js.map +1 -1
  197. package/dist/core/scene/appliedLog.js +37 -0
  198. package/dist/core/scene/appliedLog.js.map +1 -0
  199. package/dist/core/scene/arrivalWindow.js +101 -0
  200. package/dist/core/scene/arrivalWindow.js.map +1 -0
  201. package/dist/core/scene/derivedPath.js.map +1 -1
  202. package/dist/core/scene/historyFacade.js +84 -0
  203. package/dist/core/scene/historyFacade.js.map +1 -0
  204. package/dist/core/scene/kitOps.js +173 -0
  205. package/dist/core/scene/kitOps.js.map +1 -0
  206. package/dist/core/scene/layerStack.js +38 -0
  207. package/dist/core/scene/layerStack.js.map +1 -0
  208. package/dist/core/scene/lockGuard.js +37 -0
  209. package/dist/core/scene/lockGuard.js.map +1 -0
  210. package/dist/core/scene/nodeFnFields.js +5 -6
  211. package/dist/core/scene/nodeFnFields.js.map +1 -1
  212. package/dist/core/scene/nodeMemo.js +45 -19
  213. package/dist/core/scene/nodeMemo.js.map +1 -1
  214. package/dist/core/scene/nodeStore.js +126 -0
  215. package/dist/core/scene/nodeStore.js.map +1 -0
  216. package/dist/core/scene/pickability.js +6 -0
  217. package/dist/core/scene/pickability.js.map +1 -0
  218. package/dist/core/scene/poseFeed.js +38 -38
  219. package/dist/core/scene/poseFeed.js.map +1 -1
  220. package/dist/core/scene/poseOverrides.js +34 -38
  221. package/dist/core/scene/poseOverrides.js.map +1 -1
  222. package/dist/core/scene/renderOrder.js +84 -0
  223. package/dist/core/scene/renderOrder.js.map +1 -0
  224. package/dist/core/scene/scene.js +289 -866
  225. package/dist/core/scene/scene.js.map +1 -1
  226. package/dist/core/scene/serialization.js +68 -0
  227. package/dist/core/scene/serialization.js.map +1 -0
  228. package/dist/core/scene/treeOrder.js +13 -0
  229. package/dist/core/scene/treeOrder.js.map +1 -0
  230. package/dist/core/scene/types.js.map +1 -1
  231. package/dist/core/viewport/meanScale.js +1 -1
  232. package/dist/core/viewport/meanScale.js.map +1 -1
  233. package/dist/core/viewport/view.js +12 -12
  234. package/dist/core/viewport/view.js.map +1 -1
  235. package/dist/core/viewport/zoomBounds.js +10 -8
  236. package/dist/core/viewport/zoomBounds.js.map +1 -1
  237. package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-CtCb8a3G.d.ts} +1 -1
  238. package/dist/debug/createDebugOverlayLayer.js +14 -14
  239. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  240. package/dist/debug/flag.js +2 -41
  241. package/dist/features/chrome-caps/useHoverTracking.js +22 -17
  242. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  243. package/dist/features/focus/gateLayer.js +3 -4
  244. package/dist/features/focus/gateLayer.js.map +1 -1
  245. package/dist/features/images/imageCache.js +19 -9
  246. package/dist/features/images/imageCache.js.map +1 -1
  247. package/dist/features/ingestion/contentHandlers.js +14 -11
  248. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  249. package/dist/features/ingestion/index.js +1 -1
  250. package/dist/features/ingestion/registerKitHandlers.js +7 -7
  251. package/dist/features/ingestion/weaselJsonHandler.js +17 -14
  252. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
  253. package/dist/features/meshPaint/lazyKind.js +201 -35
  254. package/dist/features/meshPaint/lazyKind.js.map +1 -1
  255. package/dist/features/meshPaint/meshPaint.js +82 -79
  256. package/dist/features/meshPaint/meshPaint.js.map +1 -1
  257. package/dist/features/minimap/createMinimapContribution.js +42 -42
  258. package/dist/features/minimap/layers.js +44 -62
  259. package/dist/features/minimap/layers.js.map +1 -1
  260. package/dist/features/parallax/createParallaxPlane.js +10 -14
  261. package/dist/features/parallax/createParallaxPlane.js.map +1 -1
  262. package/dist/features/paths/anchorEdits.js +19 -8
  263. package/dist/features/paths/anchorEdits.js.map +1 -1
  264. package/dist/features/paths/anchors.js +31 -26
  265. package/dist/features/paths/anchors.js.map +1 -1
  266. package/dist/features/paths/booleans.js +2 -2
  267. package/dist/features/paths/index.js +13 -11
  268. package/dist/features/paths/markerCommands.js +37 -36
  269. package/dist/features/paths/markerCommands.js.map +1 -1
  270. package/dist/features/paths/pathInWorld.js +19 -19
  271. package/dist/features/paths/pathInWorld.js.map +1 -1
  272. package/dist/features/paths/pathLayer.js.map +1 -1
  273. package/dist/features/paths/strokeToPath.js +40 -0
  274. package/dist/features/paths/strokeToPath.js.map +1 -0
  275. package/dist/features/paths/tessellate/stroke.js.map +1 -1
  276. package/dist/features/patterns/commandPaint.js +18 -0
  277. package/dist/features/patterns/commandPaint.js.map +1 -0
  278. package/dist/features/patterns/index.js +5 -17
  279. package/dist/features/patterns/index.js.map +1 -1
  280. package/dist/features/patterns/rasterizeTile.js +17 -0
  281. package/dist/features/patterns/rasterizeTile.js.map +1 -0
  282. package/dist/features/patterns/resolveSpec.js +52 -44
  283. package/dist/features/patterns/resolveSpec.js.map +1 -1
  284. package/dist/features/poseRun/usePoseRun.js +8 -3
  285. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  286. package/dist/features/selection/SelectionContext.js +5 -0
  287. package/dist/features/selection/SelectionContext.js.map +1 -1
  288. package/dist/features/selection/overlay.js +18 -18
  289. package/dist/features/selection/overlay.js.map +1 -1
  290. package/dist/features/text/domOffsets.js +82 -0
  291. package/dist/features/text/domOffsets.js.map +1 -0
  292. package/dist/features/text/domRuns.js +103 -131
  293. package/dist/features/text/domRuns.js.map +1 -1
  294. package/dist/features/text/hitTest.js +5 -2
  295. package/dist/features/text/hitTest.js.map +1 -1
  296. package/dist/features/text/isTextData.js +8 -0
  297. package/dist/features/text/isTextData.js.map +1 -0
  298. package/dist/features/text/overlayDirection.js +15 -0
  299. package/dist/features/text/overlayDirection.js.map +1 -0
  300. package/dist/features/text/runs/rangeStyle.js +32 -34
  301. package/dist/features/text/runs/rangeStyle.js.map +1 -1
  302. package/dist/features/text/textCommand.js +34 -33
  303. package/dist/features/text/textCommand.js.map +1 -1
  304. package/dist/features/text/textToPath.js +40 -40
  305. package/dist/features/text/textToPath.js.map +1 -1
  306. package/dist/features/text/useSceneTextEdit.js +76 -82
  307. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  308. package/dist/features/text/useTextEdit.js +184 -160
  309. package/dist/features/text/useTextEdit.js.map +1 -1
  310. package/dist/features/tiling/createTiledLayer.js +24 -22
  311. package/dist/features/tiling/createTiledLayer.js.map +1 -1
  312. package/dist/index.d.ts +11033 -7749
  313. package/dist/index.js +316 -309
  314. package/dist/input/keyState.js +42 -43
  315. package/dist/input/keyState.js.map +1 -1
  316. package/dist/input/useKeyModifiers.js +11 -0
  317. package/dist/input/useKeyModifiers.js.map +1 -0
  318. package/dist/interactions/actions/align/align.js +8 -8
  319. package/dist/interactions/actions/clipboard/clipboardOps.js +34 -32
  320. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
  321. package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
  322. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
  323. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
  324. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -1
  325. package/dist/interactions/actions/defaultCommitAdapter.js +20 -18
  326. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
  327. package/dist/interactions/actions/defaults/align.js +9 -10
  328. package/dist/interactions/actions/defaults/align.js.map +1 -1
  329. package/dist/interactions/actions/defaults/anchorEditing.js +59 -81
  330. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  331. package/dist/interactions/actions/defaults/areaSelect.js +35 -38
  332. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  333. package/dist/interactions/actions/defaults/clipboard.js +26 -10
  334. package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
  335. package/dist/interactions/actions/defaults/clone.js +44 -60
  336. package/dist/interactions/actions/defaults/clone.js.map +1 -1
  337. package/dist/interactions/actions/defaults/copySubtree.js +40 -0
  338. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
  339. package/dist/interactions/actions/defaults/distribute.js +14 -13
  340. package/dist/interactions/actions/defaults/distribute.js.map +1 -1
  341. package/dist/interactions/actions/defaults/duplicate.js +17 -57
  342. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  343. package/dist/interactions/actions/defaults/editAnchors.js +18 -18
  344. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  345. package/dist/interactions/actions/defaults/flip.js +52 -46
  346. package/dist/interactions/actions/defaults/flip.js.map +1 -1
  347. package/dist/interactions/actions/defaults/group.js +43 -48
  348. package/dist/interactions/actions/defaults/group.js.map +1 -1
  349. package/dist/interactions/actions/defaults/ingest.js +35 -33
  350. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  351. package/dist/interactions/actions/defaults/insert.js +50 -51
  352. package/dist/interactions/actions/defaults/insert.js.map +1 -1
  353. package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -7
  354. package/dist/interactions/actions/defaults/lassoSelect.js +67 -70
  355. package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
  356. package/dist/interactions/actions/defaults/move.js +267 -249
  357. package/dist/interactions/actions/defaults/move.js.map +1 -1
  358. package/dist/interactions/actions/defaults/nudge.js +40 -68
  359. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  360. package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
  361. package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
  362. package/dist/interactions/actions/defaults/reorder.js +2 -0
  363. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  364. package/dist/interactions/actions/defaults/resize.js +104 -98
  365. package/dist/interactions/actions/defaults/resize.js.map +1 -1
  366. package/dist/interactions/actions/defaults/rotate.js +111 -110
  367. package/dist/interactions/actions/defaults/rotate.js.map +1 -1
  368. package/dist/interactions/actions/defaults/setFill.js +7 -7
  369. package/dist/interactions/actions/defaults/setFillOpacity.js +4 -4
  370. package/dist/interactions/actions/defaults/setStroke.js +12 -12
  371. package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
  372. package/dist/interactions/actions/defaults/sliceOps.js +19 -19
  373. package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
  374. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  375. package/dist/interactions/actions/edit-anchors/geometry.js +28 -23
  376. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
  377. package/dist/interactions/actions/flip/helpers.js +30 -17
  378. package/dist/interactions/actions/flip/helpers.js.map +1 -1
  379. package/dist/interactions/actions/hitSelection.js +8 -0
  380. package/dist/interactions/actions/hitSelection.js.map +1 -0
  381. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
  382. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
  383. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
  384. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
  385. package/dist/interactions/actions/move/behaviors/snapToContainer.js +32 -21
  386. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  387. package/dist/interactions/actions/move/gestureAdapter.js +32 -15
  388. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
  389. package/dist/interactions/actions/move/landedDescendants.js +33 -0
  390. package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
  391. package/dist/interactions/actions/outlines/createOutlines.js +18 -18
  392. package/dist/interactions/actions/poseDescriptorDep.js +16 -4
  393. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
  394. package/dist/interactions/actions/poseFrame.js +11 -6
  395. package/dist/interactions/actions/poseFrame.js.map +1 -1
  396. package/dist/interactions/actions/previewOverrides.js +5 -5
  397. package/dist/interactions/actions/previewOverrides.js.map +1 -1
  398. package/dist/interactions/actions/selectionSubtree.js +69 -0
  399. package/dist/interactions/actions/selectionSubtree.js.map +1 -0
  400. package/dist/interactions/actions/useStandardActions.js +66 -62
  401. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  402. package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
  403. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
  404. package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
  405. package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
  406. package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
  407. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
  408. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +8 -6
  409. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
  410. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
  411. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
  412. package/dist/{math-Drrw4ewZ.d.ts → math-J-ACHyEg.d.ts} +1 -2
  413. package/dist/math.d.ts +2 -3
  414. package/dist/move.d.ts +12 -11
  415. package/dist/{originProjection-DEklpDc_.d.ts → originProjection-gHnOup4e.d.ts} +1 -1
  416. package/dist/{registerProgram-BMZRDgrh.d.ts → registerProgram-T9S_PfAX.d.ts} +18 -7
  417. package/dist/renderer/DrawCommand.js.map +1 -1
  418. package/dist/renderer/WeaselRenderer.js +75 -73
  419. package/dist/renderer/WeaselRenderer.js.map +1 -1
  420. package/dist/renderer/cache/GLImageCache.js +15 -5
  421. package/dist/renderer/cache/GLImageCache.js.map +1 -1
  422. package/dist/renderer/cache/GLMeshCache.js +23 -23
  423. package/dist/renderer/cache/GLMeshCache.js.map +1 -1
  424. package/dist/renderer/cache/GLTextureCache.js +18 -1
  425. package/dist/renderer/cache/GLTextureCache.js.map +1 -1
  426. package/dist/renderer/cache/cache.js.map +1 -1
  427. package/dist/renderer/cache/markerCommandCache.js.map +1 -1
  428. package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
  429. package/dist/renderer/cullDrawCommands.js +11 -11
  430. package/dist/renderer/draw/batch.js +133 -0
  431. package/dist/renderer/draw/batch.js.map +1 -0
  432. package/dist/renderer/draw/clip.js +89 -0
  433. package/dist/renderer/draw/clip.js.map +1 -0
  434. package/dist/renderer/draw/customShader.js +230 -0
  435. package/dist/renderer/draw/customShader.js.map +1 -0
  436. package/dist/renderer/draw/drawTriangles.js +8 -0
  437. package/dist/renderer/draw/drawTriangles.js.map +1 -0
  438. package/dist/renderer/draw/effects.js +28 -0
  439. package/dist/renderer/draw/effects.js.map +1 -0
  440. package/dist/renderer/draw/flushBatch.js +35 -0
  441. package/dist/renderer/draw/flushBatch.js.map +1 -0
  442. package/dist/renderer/draw/gradient.js +90 -0
  443. package/dist/renderer/draw/gradient.js.map +1 -0
  444. package/dist/renderer/draw/image.js +38 -0
  445. package/dist/renderer/draw/image.js.map +1 -0
  446. package/dist/renderer/draw/mesh.js +16 -0
  447. package/dist/renderer/draw/mesh.js.map +1 -0
  448. package/dist/renderer/draw/paintBind.js +70 -0
  449. package/dist/renderer/draw/paintBind.js.map +1 -0
  450. package/dist/renderer/draw/pathPaint.js +142 -0
  451. package/dist/renderer/draw/pathPaint.js.map +1 -0
  452. package/dist/renderer/draw/scratchPass.js +83 -0
  453. package/dist/renderer/draw/scratchPass.js.map +1 -0
  454. package/dist/renderer/draw/stencil.js +28 -0
  455. package/dist/renderer/draw/stencil.js.map +1 -0
  456. package/dist/renderer/draw/text.js +167 -0
  457. package/dist/renderer/draw/text.js.map +1 -0
  458. package/dist/renderer/draw/uniforms.js +77 -0
  459. package/dist/renderer/draw/uniforms.js.map +1 -0
  460. package/dist/renderer/draw.js +60 -1116
  461. package/dist/renderer/draw.js.map +1 -1
  462. package/dist/renderer/effects/EffectTargets.js +3 -0
  463. package/dist/renderer/effects/EffectTargets.js.map +1 -1
  464. package/dist/renderer/effects/composite.js +7 -5
  465. package/dist/renderer/effects/composite.js.map +1 -1
  466. package/dist/renderer/index.js +18 -17
  467. package/dist/renderer/math/color.js +63 -83
  468. package/dist/renderer/math/color.js.map +1 -1
  469. package/dist/renderer/math/mat3.js +15 -11
  470. package/dist/renderer/math/mat3.js.map +1 -1
  471. package/dist/renderer/math/viewToMat3.js +1 -1
  472. package/dist/renderer/math/viewToMat3.js.map +1 -1
  473. package/dist/renderer/shaders/ShaderProgram.js +13 -13
  474. package/dist/renderer/shaders/ShaderProgram.js.map +1 -1
  475. package/dist/renderer/shaders/glyphPaint.js +3 -3
  476. package/dist/renderer/shaders/glyphPaint.js.map +1 -1
  477. package/dist/renderer/shaders/gradFill.js +2 -1
  478. package/dist/renderer/shaders/gradFill.js.map +1 -1
  479. package/dist/renderer/shaders/pathFill.js +2 -1
  480. package/dist/renderer/shaders/pathFill.js.map +1 -1
  481. package/dist/renderer/shaders/patternFill.js +2 -1
  482. package/dist/renderer/shaders/patternFill.js.map +1 -1
  483. package/dist/renderer/shaders/registerProgram.js.map +1 -1
  484. package/dist/renderer/strokeLengths.js.map +1 -1
  485. package/dist/renderer/textures/registerTexture.js +25 -5
  486. package/dist/renderer/textures/registerTexture.js.map +1 -1
  487. package/dist/renderer.d.ts +16 -15
  488. package/dist/renderer.js +17 -16
  489. package/dist/resize.d.ts +5 -6
  490. package/dist/resize.js +5 -5
  491. package/dist/style.css +1 -1
  492. package/dist/test-hook/install.js +12 -6
  493. package/dist/test-hook/install.js.map +1 -1
  494. package/dist/{test-seams-CuIxe0xY.d.ts → test-seams-DM2B87-g.d.ts} +4 -4
  495. package/dist/test-seams.d.ts +2 -2
  496. package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
  497. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  498. package/dist/tools/builtin/hand/useHandTool.js +1 -0
  499. package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
  500. package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
  501. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
  502. package/dist/tools/builtin/line/useLineTool.js +1 -0
  503. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  504. package/dist/tools/builtin/pen/usePenTool.js +153 -103
  505. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  506. package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
  507. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
  508. package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
  509. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  510. package/dist/tools/builtin/rect/useRectTool.js +1 -0
  511. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  512. package/dist/tools/builtin/select/selectionContributions.js +24 -23
  513. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  514. package/dist/tools/builtin/select/useSelectTool.js +51 -48
  515. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  516. package/dist/tools/builtin/shared/pointerFollower.js +17 -0
  517. package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
  518. package/dist/tools/builtin/slice/useSliceTool.js +49 -54
  519. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  520. package/dist/tools/builtin/star/useStarTool.js +22 -16
  521. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  522. package/dist/tools/builtin/text/useTextTool.js +1 -0
  523. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  524. package/dist/tools/useKeybindings.js +14 -30
  525. package/dist/tools/useKeybindings.js.map +1 -1
  526. package/dist/{types-B_9g6hMM.d.ts → types-B4iJRHC3.d.ts} +5 -1
  527. package/dist/{types-A37hYkeR.d.ts → types-k-5Oqh-U.d.ts} +31 -7
  528. package/dist/util/color.js +3 -3
  529. package/dist/util/color.js.map +1 -1
  530. package/dist/util/paint.js.map +1 -1
  531. package/dist/version.js +1 -1
  532. package/package.json +20 -18
  533. package/dist/autoPoseDescriptor-vCdt55xm.d.ts +0 -27
  534. package/dist/builtins-C-VgUlWI.d.ts +0 -4514
  535. package/dist/core/isPlainObject.js.map +0 -1
  536. package/dist/debug/flag.js.map +0 -1
  537. package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
  538. package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
  539. package/dist/renderer/shaders/imageFill.js +0 -14
  540. package/dist/renderer/shaders/imageFill.js.map +0 -1
  541. package/dist/tools/prefs.js +0 -62
  542. package/dist/tools/prefs.js.map +0 -1
@@ -1,70 +1,29 @@
1
- import { asNodeId as e } from "../../core/scene/types.js";
2
1
  import "../../core/shapeKinds.js";
3
- import { cycleFill as t, solid as n, strokeOf as r } from "../../util/paint.js";
4
- import { useTextTool as i } from "../../tools/builtin/text/useTextTool.js";
5
- import { usePenTool as a } from "../../tools/builtin/pen/usePenTool.js";
6
- import { useRectTool as o } from "../../tools/builtin/rect/useRectTool.js";
7
- import { useEllipseTool as s } from "../../tools/builtin/ellipse/useEllipseTool.js";
8
- import { useLineTool as c } from "../../tools/builtin/line/useLineTool.js";
9
- import { useLassoTool as l } from "../../tools/builtin/lasso/useLassoTool.js";
10
- import { usePolygonTool as u } from "../../tools/builtin/polygon/usePolygonTool.js";
11
- import { useStarTool as d } from "../../tools/builtin/star/useStarTool.js";
12
- import { usePencilTool as f } from "../../tools/builtin/pencil/usePencilTool.js";
13
- import { boundsOfPath as p } from "@weasel-js/geom";
14
- import { useRef as m } from "react";
2
+ import { useTextTool as e } from "../../tools/builtin/text/useTextTool.js";
3
+ import { usePenTool as t } from "../../tools/builtin/pen/usePenTool.js";
4
+ import { useRectTool as n } from "../../tools/builtin/rect/useRectTool.js";
5
+ import { useEllipseTool as r } from "../../tools/builtin/ellipse/useEllipseTool.js";
6
+ import { useLineTool as i } from "../../tools/builtin/line/useLineTool.js";
7
+ import { useLassoTool as a } from "../../tools/builtin/lasso/useLassoTool.js";
8
+ import { usePolygonTool as o } from "../../tools/builtin/polygon/usePolygonTool.js";
9
+ import { useStarTool as s } from "../../tools/builtin/star/useStarTool.js";
10
+ import { usePencilTool as c } from "../../tools/builtin/pencil/usePencilTool.js";
15
11
  //#region src/canvas/SceneCanvas/useBuiltinShapeTools.tsx
16
- function h(h) {
17
- let { scene: g, adapter: _, options: v } = h, y = m(0), b = (t) => e(`${t}-${++y.current}`), x = () => t(y.current), S = () => g.layers[0]?.id ?? "default", C = (e, t, n) => ({
18
- id: e,
19
- kind: "leaf",
20
- layer: S(),
21
- pose: t,
22
- data: n,
23
- parent: null
24
- }), w = v?.snapPoint, T = v?.insert ?? {}, E = o(T), D = s(T), O = c(T), k = u(T), A = d(T), j = f(T), M = (e) => {
25
- let t = b("pn"), i = x();
26
- return C(t, e.bounds, {
27
- path: e.path,
28
- fill: e.closed ? n(x()) : null,
29
- stroke: r(i, 2)
30
- });
31
- };
12
+ function l(l = {}) {
13
+ let { options: u } = l, d = u?.snapPoint, f = u?.insert ?? {}, p = n(f), m = r(f), h = i(f), g = o(f), _ = s(f), v = c(f);
32
14
  return {
33
- rect: E,
34
- ellipse: D,
35
- line: O,
36
- polygon: k,
37
- star: A,
38
- pen: a({
39
- snapPoint: w,
40
- wrapPath: (e, { closed: t }) => {
41
- let n = p(e);
42
- return {
43
- path: e,
44
- closed: t,
45
- bounds: {
46
- x: n.x,
47
- y: n.y,
48
- width: n.width,
49
- height: n.height
50
- }
51
- };
52
- },
53
- adapter: {
54
- addNode: (e) => {
55
- let t = M(e);
56
- return _.insertNode(t), String(t.id);
57
- },
58
- makeNode: (e) => M(e),
59
- setSelection: (e) => _.setSelection(e)
60
- }
61
- }),
62
- pencil: j,
63
- lasso: l(_, v?.lasso ?? {}),
64
- text: i(T)
15
+ rect: p,
16
+ ellipse: m,
17
+ line: h,
18
+ polygon: g,
19
+ star: _,
20
+ pen: t({ snapPoint: d }),
21
+ pencil: v,
22
+ lasso: a(u?.lasso ?? {}),
23
+ text: e(f)
65
24
  };
66
25
  }
67
26
  //#endregion
68
- export { h as useBuiltinShapeTools };
27
+ export { l as useBuiltinShapeTools };
69
28
 
70
29
  //# sourceMappingURL=useBuiltinShapeTools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBuiltinShapeTools.js","names":["useBuiltinShapeTools","args","seqRef","useRef","freshId","asNodeId","prefix","nextFill","cycleFill","layerOf","scene","makeLeaf","snapPoint","options","insert","rect","useRectTool","ellipse","useEllipseTool","line","useLineTool","polygon","usePolygonTool","star","useStarTool","pencil","usePencilTool","makePenLeaf","id","color","carrier","solid","strokeOf","usePenTool","b","boundsOfPath","path","node","adapter","ids","useLassoTool","useTextTool"],"sources":["../../../src/canvas/SceneCanvas/useBuiltinShapeTools.tsx"],"sourcesContent":["/**\n * Shape-tool synthesis for `<SceneCanvas>` — calls the kit's per-shape tool\n * hooks with default `create` callbacks that produce leaf nodes shaped for\n * the kit's PATH_PAINTER (`data: { path, fill }`). Lets consumers opt into\n * a complete drawing toolset via `<SceneCanvas defaultTools={['rect', 'ellipse']}>`\n * without writing per-tool factory code.\n *\n * All hooks are always called (React rules of hooks) — `<SceneCanvas>` only\n * registers the ones requested via `defaultTools`.\n */\nimport { useRef } from 'react';\nimport { asNodeId } from 'core/scene/types';\nimport { boundsOfPath } from '@weasel-js/geom';\nimport { cycleFill, solid, strokeOf } from '../../util/paint';\nimport { useEllipseTool } from 'tools/builtin/ellipse/useEllipseTool';\nimport { useLassoTool } from 'tools/builtin/lasso/useLassoTool';\nimport { useLineTool } from 'tools/builtin/line/useLineTool';\nimport { usePencilTool } from 'tools/builtin/pencil/usePencilTool';\nimport { usePenTool } from 'tools/builtin/pen/usePenTool';\nimport { usePolygonTool } from 'tools/builtin/polygon/usePolygonTool';\nimport { useRectTool } from 'tools/builtin/rect/useRectTool';\nimport { useStarTool } from 'tools/builtin/star/useStarTool';\nimport { useTextTool } from 'tools/builtin/text/useTextTool';\nimport type { AnyTool, FillStyle, InsertToolOptions, LassoHitMode, NodeId, Path, PolygonPath, Scene, SceneNode, Stroke } from '@weasel-js/core';\nimport type { SceneCanvasAdapter } from '../sceneAdapter';\nimport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\n/** Per-tool option overrides for the built-in shape/lasso tools.\n * Each entry is a narrow subset of the underlying hook's options surface\n * — just the knobs that need consumer control under the bundle pattern. */\nexport interface BuiltinToolOptions {\n lasso?: { mode?: LassoHitMode };\n /** Insert-action options for every drag-to-insert tool (rect / ellipse /\n * line / polygon / star / pencil / text): `behaviors` become each insert\n * binding's `opts.behaviors`, the way `selectTool.move.behaviors` do for\n * move. */\n insert?: InsertToolOptions;\n /** Snap world-space points to the active grid (or any other snap target).\n *\n * Registered as the `snap` dep, which `insertAction` applies to the\n * drag start and current point — so the live preview and the committed\n * geometry agree — and which the pen tool reads for its own anchor\n * placement. Covers every drag-to-insert tool (rect / ellipse / line /\n * polygon / star / text); freehand pencil samples are deliberately left\n * unsnapped. */\n snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };\n}\n\n// `BuiltinShapeToolId` / `KIT_SHAPE_KINDS` derive from the `core/shapeKinds`\n// table, a dependency-free module, so barrel-reachable code can reach them\n// without entering this file's `@weasel-js/core` self-import cycle.\n// Re-exported here so existing importers of this module keep working.\nexport { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nexport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\nexport interface UseBuiltinShapeToolsArgs<TData, TLayer extends string, TPose> {\n scene: Scene<TData, TLayer, TPose>;\n adapter: SceneCanvasAdapter<TData, TLayer, TPose>;\n /** Per-tool option overrides (lasso mode, etc.). */\n options?: BuiltinToolOptions;\n}\n\nexport type BuiltinShapeTools = Record<BuiltinShapeToolId, AnyTool>;\n\n/** Synthesize the full shape-tool registry. Hooks always run; consumers\n * decide via `wants(...)` which to register with `useTools`. */\nexport function useBuiltinShapeTools<TData, TLayer extends string, TPose>(\n args: UseBuiltinShapeToolsArgs<TData, TLayer, TPose>,\n): BuiltinShapeTools {\n const { scene, adapter, options } = args;\n\n // Per-canvas counter + fill cycler. Refs survive renders and stay\n // private to the SceneCanvas instance.\n const seqRef = useRef(0);\n const freshId = (prefix: string) => asNodeId(`${prefix}-${++seqRef.current}`);\n const nextFill = () => cycleFill(seqRef.current);\n\n // First system-or-trivial layer is the default insertion layer. Falls back\n // to 'default' when the scene has none yet (rare — useScene synthesizes\n // a 'default' layer when systemLayers is omitted).\n const layerOf = (): TLayer => (scene.layers[0]?.id ?? ('default' as TLayer));\n\n // Helper to build the kit's leaf-node template — `data: { path, fill }`\n // matches PATH_PAINTER's `matches`/`paint` contract. The cast through\n // `unknown` reflects the kit's intentional looseness around TData when\n // synthesized defaults are in play.\n type Pose = { x: number; y: number; width: number; height: number };\n const makeLeaf = (\n id: NodeId,\n pose: Pose,\n data: { path: Path; fill: FillStyle | null; stroke?: Stroke; text?: string },\n ): SceneNode<TData, TLayer, TPose> => ({\n id,\n kind: 'leaf',\n layer: layerOf(),\n pose: pose as unknown as TPose,\n data: data as unknown as TData,\n parent: null,\n });\n\n type LeafNode = SceneNode<TData, TLayer, TPose> & { id: NodeId };\n\n const snapPoint = options?.snapPoint;\n // Every drag-to-insert tool is a declarative shell: the drag is owned by\n // the dispatcher's `insertAction` and the node is minted by the `insert`\n // dep (`useInsertDepSource`). Tool-side `create` factories were removed\n // when the dispatcher took over — consumers wanting custom node\n // factories override the dep, not the tool.\n const insert = options?.insert ?? {};\n const rect = useRectTool(insert);\n const ellipse = useEllipseTool(insert);\n const line = useLineTool(insert);\n const polygon = usePolygonTool(insert);\n const star = useStarTool(insert);\n const pencil = usePencilTool(insert);\n // Pen: takes an opaque \"pose\" carrier (here, the committed PolygonPath +\n // closed flag + AABB) and an addNode/setSelection adapter. We construct\n // the carrier in `wrapPath` and unpack it in `addNode` into a\n // PATH_PAINTER-shaped leaf. (Pen is the one built-in still commiting\n // through its own adapter rather than the `insert` dep — see §4b of the\n // 2026-07-27 inspector handoff.)\n // Editing a committed path is not the pen's job — double-click it to\n // enter anchor-edit mode (see `usePenTool`'s PenScratch docs).\n type PenCarrier = { path: PolygonPath; closed: boolean; bounds: { x: number; y: number; width: number; height: number } };\n const makePenLeaf = (carrier: PenCarrier): LeafNode => {\n const id = freshId('pn');\n const color = nextFill();\n return makeLeaf(id, carrier.bounds, {\n path: carrier.path,\n fill: carrier.closed ? solid(nextFill()) : null,\n stroke: strokeOf(color, 2),\n }) as LeafNode;\n };\n const pen = usePenTool<PenCarrier>({\n snapPoint,\n wrapPath: (path, { closed }): PenCarrier => {\n const b = boundsOfPath(path);\n return { path, closed, bounds: { x: b.x, y: b.y, width: b.width, height: b.height } };\n },\n adapter: {\n addNode: (carrier) => {\n const node = makePenLeaf(carrier);\n adapter.insertNode(node);\n return String(node.id);\n },\n makeNode: (carrier) => makePenLeaf(carrier),\n setSelection: (ids) => adapter.setSelection(ids),\n },\n });\n const lasso = useLassoTool(adapter, options?.lasso ?? {});\n const text = useTextTool(insert);\n return { rect, ellipse, line, polygon, star, pen, pencil, lasso, text };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkEA,SAAgBA,EACd,GACmB;CACnB,IAAM,EAAE,UAAO,YAAS,eAAYC,GAI9BC,IAASC,EAAO,CAAC,GACjBC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,GAAS,SAAS,CAAC,CAEG;EAAO,MADpD4B,EAAY3B,CACwC;CAAK;AACxE"}
1
+ {"version":3,"file":"useBuiltinShapeTools.js","names":["useBuiltinShapeTools","args","snapPoint","options","insert","rect","useRectTool","ellipse","useEllipseTool","line","useLineTool","polygon","usePolygonTool","star","useStarTool","pencil","usePencilTool","usePenTool","useLassoTool","useTextTool"],"sources":["../../../src/canvas/SceneCanvas/useBuiltinShapeTools.tsx"],"sourcesContent":["/**\n * Shape-tool synthesis for `<SceneCanvas>` — calls the kit's per-shape tool\n * hooks; the `insert` dep mints each tool's node. Lets consumers opt into\n * a complete drawing toolset via `<SceneCanvas defaultTools={['rect', 'ellipse']}>`\n * without writing per-tool factory code.\n *\n * All hooks are always called (React rules of hooks) — `<SceneCanvas>` only\n * registers the ones requested via `defaultTools`.\n */\nimport { useEllipseTool } from 'tools/builtin/ellipse/useEllipseTool';\nimport { useLassoTool } from 'tools/builtin/lasso/useLassoTool';\nimport { useLineTool } from 'tools/builtin/line/useLineTool';\nimport { usePencilTool } from 'tools/builtin/pencil/usePencilTool';\nimport { usePenTool } from 'tools/builtin/pen/usePenTool';\nimport { usePolygonTool } from 'tools/builtin/polygon/usePolygonTool';\nimport { useRectTool } from 'tools/builtin/rect/useRectTool';\nimport { useStarTool } from 'tools/builtin/star/useStarTool';\nimport { useTextTool } from 'tools/builtin/text/useTextTool';\nimport type { AnyTool } from 'tools/overlayBinding';\nimport type { InsertToolOptions } from 'tools/builtin/shared/insertToolOptions';\nimport type { LassoHitMode } from 'core/adapters/types';\nimport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\n/** Per-tool option overrides for the built-in shape/lasso tools.\n * Each entry is a narrow subset of the underlying hook's options surface\n * — just the knobs that need consumer control under the bundle pattern. */\nexport interface BuiltinToolOptions {\n lasso?: { mode?: LassoHitMode };\n /** Insert-action options for every drag-to-insert tool (rect / ellipse /\n * line / polygon / star / pencil / text): `behaviors` become each insert\n * binding's `opts.behaviors`, the way `selectTool.move.behaviors` do for\n * move. */\n insert?: InsertToolOptions;\n /** Snap world-space points to the active grid (or any other snap target).\n *\n * Registered as the `snap` dep, which `insertAction` applies to the\n * drag start and current point — so the live preview and the committed\n * geometry agree — and which the pen tool reads for its own anchor\n * placement. Covers every drag-to-insert tool (rect / ellipse / line /\n * polygon / star / text); freehand pencil samples are deliberately left\n * unsnapped. */\n snapPoint?: (p: { x: number; y: number }) => { x: number; y: number };\n}\n\n// `BuiltinShapeToolId` / `KIT_SHAPE_KINDS` derive from the `core/shapeKinds`\n// table, a dependency-free module, so barrel-reachable code can reach them\n// without entering this file's `@weasel-js/core` self-import cycle.\n// Re-exported here so existing importers of this module keep working.\nexport { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nexport type { BuiltinShapeToolId } from 'core/shapeKinds';\n\nexport interface UseBuiltinShapeToolsArgs {\n /** Per-tool option overrides (lasso mode, etc.). */\n options?: BuiltinToolOptions;\n}\n\nexport type BuiltinShapeTools = Record<BuiltinShapeToolId, AnyTool>;\n\n/** Synthesize the full shape-tool registry. Hooks always run; consumers\n * decide via `wants(...)` which to register with `useTools`. */\nexport function useBuiltinShapeTools(args: UseBuiltinShapeToolsArgs = {}): BuiltinShapeTools {\n const { options } = args;\n\n const snapPoint = options?.snapPoint;\n // Every tool here is a declarative shell: the `insert` dep\n // (`useInsertDepSource`) mints the node, so a consumer wanting its own node\n // shape overrides the dep, not the tool.\n const insert = options?.insert ?? {};\n const rect = useRectTool(insert);\n const ellipse = useEllipseTool(insert);\n const line = useLineTool(insert);\n const polygon = usePolygonTool(insert);\n const star = useStarTool(insert);\n const pencil = usePencilTool(insert);\n const pen = usePenTool({ snapPoint });\n const lasso = useLassoTool(options?.lasso ?? {});\n const text = useTextTool(insert);\n return { rect, ellipse, line, polygon, star, pen, pencil, lasso, text };\n}\n"],"mappings":";;;;;;;;;;;AA4DA,SAAgBA,EAAqB,IAAiC,CAAC,GAAsB;CAC3F,IAAM,EAAE,eAAYC,GAEdC,IAAYC,GAAS,WAIrBC,IAASD,GAAS,UAAU,CAAC,GAC7BE,IAAOC,EAAYF,CAAM,GACzBG,IAAUC,EAAeJ,CAAM,GAC/BK,IAAOC,EAAYN,CAAM,GACzBO,IAAUC,EAAeR,CAAM,GAC/BS,IAAOC,EAAYV,CAAM,GACzBW,IAASC,EAAcZ,CAAM;CAInC,OAAO;EAAE;EAAM;EAAS;EAAM;EAAS;EAAM,KAHjCa,EAAW,EAAE,aAAU,CAGU;EAAK;EAAQ,OAF5CC,EAAaf,GAAS,SAAS,CAAC,CAEY;EAAO,MADpDgB,EAAYf,CACwC;CAAK;AACxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDispatcherOverlayLayer.js","names":["DEFAULT_STYLE","PREVIEW_CONTENT_OPACITY","useDispatcherOverlayLayer","args","styleRef","useLatest","style","forceRerender","useReducer","n","useEffect","dispatcher","useMemo","cfg","roles","OVERLAY_ROLE_STROKES","t","viewToTransform","view","out","isVisible","isVisibleFrom","data","passes","id","ov","resolveOverlays","gestureOverlaysFrom","b","sx","sy","worldToScreen","cmd","projectPoint","wx","wy","projectPoints","pts","p","radialScale","pathCmd","geom","sw","sh","e","bmp","getImageBitmap","ellipsePath","rectPath","linePath","regularPolygonPath","starPath","polylineFromPoints","anchorScreen","screenPts","v","polygonFromPoints","stroke","pt"],"sources":["../../../src/canvas/SceneCanvas/useDispatcherOverlayLayer.ts"],"sourcesContent":["/**\n * Dispatcher overlay render layer for `<SceneCanvas>`.\n *\n * Paints the overlay shapes the drawing view's in-flight handles publish,\n * taken off the draw envelope so a panel shows its own gesture rather than\n * the surface's. `resolveOverlays` does the reading — normalizing the drag,\n * sizing the nascent shape, dropping what is degenerate — and everything left\n * here is painting: projection into screen coordinates, the chrome-caps gate,\n * fill/stroke policy, the stroke each overlay role reads as, the anchor dot's\n * size, and the image bitmap.\n *\n * Distinct from `usePreviewGhostLayer`, which paints displaced scene-node\n * silhouettes via `previewIds()` / `previewPose(id)`. The dispatcher\n * overlay layer is for gestures whose visual feedback isn't a moved scene\n * node — marquee rect (area-select), polyline + dashed close-line (lasso),\n * and any future overlay-only chrome an action wants to render.\n *\n * Replaces the per-tool `select-overlay` rendering for the same gestures\n * once the dispatcher path is the sole driver. Until\n * then both run side-by-side; the visuals overlap exactly so the\n * user-visible result is identical.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { DrawCommand, PathDrawCommand } from '../../renderer';\nimport type { Stroke } from '@weasel-js/paint';\nimport type { RenderLayer } from 'core/layers/render';\nimport { viewToTransform } from 'core/viewport/view';\nimport { worldToScreen } from 'core/viewport/viewTransform';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport {\n polygonFromPoints,\n polylineFromPoints,\n rectPath,\n ellipsePath,\n linePath,\n regularPolygonPath,\n starPath,\n} from '@weasel-js/geom';\nimport { getImageBitmap } from 'features/images/imageCache';\nimport { resolveOverlays } from 'interactions/actions/resolveOverlays';\nimport { gestureOverlaysFrom, isVisibleFrom } from '../drawEnvelope';\nimport { OVERLAY_ROLE_STROKES } from '../overlayRoleStrokes';\n\n/** Style knobs for the dispatcher-overlay layer's marquee + lasso paints.\n * Defaults match the legacy `useSelectTool` `areaSelectOverlayStyle`\n * defaults so the visual swap is invisible to users. */\nexport interface DispatcherOverlayStyle {\n fill?: string;\n stroke?: string;\n dash?: number[];\n lineWidth?: number;\n /** Stroke per `polyline` overlay role, merged over the kit's. A role with\n * no entry here and none of the kit's paints as plain chrome — the\n * `stroke` / `lineWidth` / `dash` above. */\n roles?: Readonly<Record<string, Stroke>>;\n}\n\nconst DEFAULT_STYLE: Required<Omit<DispatcherOverlayStyle, 'roles'>> = {\n fill: 'rgba(164, 139, 212, 0.18)',\n stroke: '#a48bd4',\n dash: [3, 3],\n lineWidth: 1,\n};\n\n/** Alpha for content previewed inside an in-flight gesture. Matches the\n * preview-ghost layer, so a dragged node and an uncommitted insert read as\n * equally provisional. */\nconst PREVIEW_CONTENT_OPACITY = 0.85;\n\n\nexport function useDispatcherOverlayLayer(args: {\n /** The surface's dispatcher, subscribed to only so a pump repaints. What\n * gets painted is the drawing view's own `getGestureOverlays()`. */\n dispatcher: Dispatcher | null | undefined;\n style?: DispatcherOverlayStyle;\n}): RenderLayer<unknown> {\n const { dispatcher, style } = args;\n\n const styleRef = useLatest(style);\n\n // Re-render on every dispatcher pump so live overlay (marquee, lasso\n // polyline) tracks pointermove instead of freezing on the first frame.\n const [, forceRerender] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n if (!dispatcher) return;\n return dispatcher.subscribe(forceRerender);\n }, [dispatcher]);\n\n return useMemo<RenderLayer<unknown>>(\n () => ({\n id: 'dispatcher-overlay',\n label: 'Dispatcher overlay',\n space: 'screen',\n draw: (data, view) => {\n const cfg = { ...DEFAULT_STYLE, ...(styleRef.current ?? {}) };\n // Merged rather than replaced: naming one role must not delete the\n // kit's others.\n const roles = { ...OVERLAY_ROLE_STROKES, ...(styleRef.current?.roles ?? {}) };\n const t = viewToTransform(view);\n const out: DrawCommand[] = [];\n\n // Chrome-caps gate. Mirrors `composeAffordanceLayer` /\n // `createSelectionOverlayLayer`: pull a visibility predicate off\n // the data envelope and consult it per overlay before pushing draw\n // commands. Absent envelope → every overlay paints. This stays on the\n // painting side: the predicate is a property of the view's envelope,\n // and two views of one surface may answer differently for the same\n // in-flight gesture.\n const isVisible = isVisibleFrom(data);\n const passes = (id: string) => (isVisible ? isVisible(id) : true);\n\n for (const ov of resolveOverlays(gestureOverlaysFrom(data))) {\n if (!passes(ov.visibilityId)) continue;\n\n if (ov.kind === 'marquee') {\n const b = ov.bounds;\n const [sx, sy] = worldToScreen(b.x, b.y, t);\n const sw = b.width * view.scale.x;\n const sh = b.height * view.scale.y;\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: { kind: 'rect', x: sx, y: sy, width: sw, height: sh },\n fill: { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n continue;\n }\n\n if (ov.kind === 'insertPreview') {\n const b = ov.bounds;\n const projectPoint = (wx: number, wy: number): { x: number; y: number } => {\n const [sx, sy] = worldToScreen(wx, wy, t);\n return { x: sx, y: sy };\n };\n const projectPoints = (\n pts: ReadonlyArray<{ x: number; y: number }>,\n ): { x: number; y: number }[] => pts.map((p) => projectPoint(p.x, p.y));\n // Radial shapes inscribe in a square, so a single screen-space\n // radius needs one scale factor; average the axes.\n const radialScale = (view.scale.x + view.scale.y) / 2;\n\n let pathCmd: PathDrawCommand['path'] | null = null;\n const geom = ov.geometry;\n switch (geom.kind) {\n case 'box': {\n const [sx, sy] = worldToScreen(b.x, b.y, t);\n const sw = b.width * view.scale.x;\n const sh = b.height * view.scale.y;\n if (ov.shape === 'image') {\n const e = ov.extras as Partial<{ src: string; preview: string }>;\n // The bitmap when it has decoded, the bare outline until then\n // (or when the tool opted out) — the outline is drawn either\n // way, so the drag always has an edge to read.\n const bmp = e.preview === 'outline' || !e.src\n ? undefined\n : getImageBitmap(e.src);\n if (bmp) {\n out.push({\n kind: 'image',\n image: bmp,\n x: sx, y: sy, w: sw, h: sh,\n opacity: PREVIEW_CONTENT_OPACITY,\n });\n }\n }\n pathCmd = ov.shape === 'ellipse'\n ? ellipsePath({ x: sx, y: sy, width: sw, height: sh })\n : rectPath(sx, sy, sw, sh);\n break;\n }\n case 'line':\n pathCmd = linePath(projectPoint(geom.a.x, geom.a.y), projectPoint(geom.b.x, geom.b.y));\n break;\n case 'polygon':\n pathCmd = regularPolygonPath(\n projectPoint(geom.center.x, geom.center.y),\n geom.radius * radialScale,\n geom.sides,\n geom.rotation,\n );\n break;\n case 'star':\n pathCmd = starPath(\n projectPoint(geom.center.x, geom.center.y),\n geom.outerRadius * radialScale,\n geom.points,\n geom.innerRadius * radialScale,\n geom.rotation,\n );\n break;\n case 'pencil':\n // Genuinely open: `polygonFromPoints` closes the path, and the\n // closing edge from the last sample back to the first reads as\n // a marquee rather than as the stroke being drawn.\n pathCmd = polylineFromPoints(projectPoints(geom.samples));\n break;\n }\n\n if (!pathCmd) continue;\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: pathCmd,\n fill: ov.shape === 'line' || ov.shape === 'pencil' || ov.shape === 'image'\n ? undefined\n : { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n // Anchor dot at the drag's click point. Sells the anchoring\n // visually for radial shapes (polygon/star — no vertex sits\n // at the AABB corner) and for center mode (dot marks the\n // growth axis). 4 CSS-px radius, same stroke color as the\n // ghost so it reads as part of the chrome.\n if (ov.anchorPoint) {\n const anchorScreen = projectPoint(ov.anchorPoint.x, ov.anchorPoint.y);\n out.push({\n kind: 'path',\n path: ellipsePath({\n x: anchorScreen.x - 4,\n y: anchorScreen.y - 4,\n width: 8,\n height: 8,\n }),\n fill: { color: cfg.stroke },\n });\n }\n continue;\n }\n\n if (ov.kind === 'lasso') {\n // Project every vertex to screen coords; build a single polygon\n // path. The polygon already closes (polygonFromPoints adds Z),\n // which renders as the dashed \"close-line\" implicit in the\n // legacy hook's visual. Fill paints the would-be selection\n // region; stroke paints the polyline + close-line.\n const screenPts: { x: number; y: number }[] = [];\n for (const v of ov.vertices) {\n const [sx, sy] = worldToScreen(v.x, v.y, t);\n screenPts.push({ x: sx, y: sy });\n }\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: polygonFromPoints(screenPts),\n fill: { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n continue;\n }\n\n if (ov.kind === 'polyline') {\n const stroke =\n roles[ov.role] ??\n { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash };\n const screenPts: { x: number; y: number }[] = [];\n for (const pt of ov.points) {\n const [sx, sy] = worldToScreen(pt.x, pt.y, t);\n screenPts.push({ x: sx, y: sy });\n }\n out.push({\n kind: 'path',\n path: polylineFromPoints(screenPts),\n stroke,\n } satisfies PathDrawCommand);\n continue;\n }\n }\n\n if (out.length === 0) return [];\n // Screen-space layer: emit commands directly. The worldToScreen\n // projection above has already mapped every coord into CSS pixels.\n return out;\n },\n }),\n [styleRef],\n );\n}\n"],"mappings":";;;;;;;;;;AA0DA,IAAMA,IAAiE;CACrE,MAAM;CACN,QAAQ;CACR,MAAM,CAAC,GAAG,CAAC;CACX,WAAW;AACb,GAKMC,IAA0B;AAGhC,SAAgBC,EAA0B,GAKjB;CACvB,IAAM,EAAE,eAAY,aAAUC,GAExBC,IAAWC,EAAUC,CAAK,GAI1B,GAAGC,KAAiBC,GAAY,MAAcC,IAAI,GAAG,CAAC;CAM5D,OALAC,QAAgB;EACd,IAAKC,GACL,OAAOA,EAAW,UAAUJ,CAAa;CAC3C,GAAG,CAACI,CAAU,CAAC,GAERC,SACE;EACL,IAAI;EACJ,OAAO;EACP,OAAO;EACP,OAAO,GAAM,MAAS;GACpB,IAAMC,IAAM;IAAE,GAAGb;IAAe,GAAII,EAAS,WAAW,CAAC;GAAG,GAGtDU,IAAQ;IAAE,GAAGC;IAAsB,GAAIX,EAAS,SAAS,SAAS,CAAC;GAAG,GACtEY,IAAIC,EAAgBC,CAAI,GACxBC,IAAqB,CAAC,GAStBC,IAAYC,EAAcC,CAAI,GAC9BC,KAAU,MAAgB,MAAYH,EAAUI,CAAE;GAExD,KAAK,IAAMC,KAAMC,EAAgBC,EAAoBL,CAAI,CAAC,GACxD,IAAKC,EAAOE,EAAG,YAAY,GAE3B;QAAIA,EAAG,SAAS,WAAW;KACzB,IAAMG,IAAIH,EAAG,QACP,CAACI,GAAIC,KAAMC,EAAcH,EAAE,GAAGA,EAAE,GAAGZ,CAAC,GAGpCgB,IAAuB;MAC3B,MAAM;MACN,MAAM;OAAE,MAAM;OAAQ,GAAGH;OAAI,GAAGC;OAAI,OAJ3BF,EAAE,QAAQV,EAAK,MAAM;OAIiB,QAHtCU,EAAE,SAASV,EAAK,MAAM;MAG2B;MAC1D,MAAM,EAAE,OAAOL,E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C;MAAG,CAAC;KACjC;KACA,IAAME,IAAuB;MAC3B,MAAM;MACN,MAAMwB,EAAkBF,CAAS;MACjC,MAAM,EAAE,OAAOzC,EAAI,KAAK;MACxB,QAAQ;OAAE,OAAO,EAAE,OAAOA,EAAI,OAAO;OAAG,OAAOA,EAAI;OAAW,MAAMA,EAAI;MAAK;KAC/E;KACA,EAAI,KAAKmB,CAAG;KACZ;IACF;IAEA,IAAIP,EAAG,SAAS,YAAY;KAC1B,IAAMgC,IACJ3C,EAAMW,EAAG,SACT;MAAE,OAAO,EAAE,OAAOZ,EAAI,OAAO;MAAG,OAAOA,EAAI;MAAW,MAAMA,EAAI;KAAK,GACjEyC,IAAwC,CAAC;KAC/C,KAAK,IAAMI,KAAMjC,EAAG,QAAQ;MAC1B,IAAM,CAACI,GAAIC,KAAMC,EAAc2B,EAAG,GAAGA,EAAG,GAAG1C,CAAC;MAC5C,EAAU,KAAK;OAAE,GAAGa;OAAI,GAAGC;MAAG,CAAC;KACjC;KACA,EAAI,KAAK;MACP,MAAM;MACN,MAAMsB,EAAmBE,CAAS;MAClC;KACF,CAA2B;KAC3B;IACF;GA3IA;GAiJF,OAHInC,EAAI,WAAW,IAAU,CAAC,IAGvBA;EACT;CACF,IACA,CAACf,CAAQ,CACX;AACF"}
1
+ {"version":3,"file":"useDispatcherOverlayLayer.js","names":["DEFAULT_STYLE","PREVIEW_CONTENT_OPACITY","useDispatcherOverlayLayer","args","styleRef","useLatest","style","forceRerender","useReducer","n","useEffect","dispatcher","useMemo","cfg","roles","OVERLAY_ROLE_STROKES","t","viewToTransform","view","out","isVisible","isVisibleFrom","data","passes","id","ov","resolveOverlays","gestureOverlaysFrom","b","sx","sy","worldToScreen","cmd","projectPoint","wx","wy","projectPoints","pts","p","radialScale","pathCmd","geom","sw","sh","e","bmp","getImageBitmap","ellipsePath","rectPath","linePath","regularPolygonPath","starPath","polylineFromPoints","anchorScreen","screenPts","v","polygonFromPoints","stroke","pt"],"sources":["../../../src/canvas/SceneCanvas/useDispatcherOverlayLayer.ts"],"sourcesContent":["/**\n * Dispatcher overlay render layer for `<SceneCanvas>`.\n *\n * Paints the overlay shapes the drawing view's in-flight handles publish,\n * taken off the draw envelope so a panel shows its own gesture rather than\n * the surface's. `resolveOverlays` does the reading — normalizing the drag,\n * sizing the nascent shape, dropping what is degenerate — and everything left\n * here is painting: projection into screen coordinates, the chrome-caps gate,\n * fill/stroke policy, the stroke each overlay role reads as, the anchor dot's\n * size, and the image bitmap.\n *\n * Distinct from `usePreviewGhostLayer`, which paints displaced scene-node\n * silhouettes via `previewIds()` / `previewPose(id)`. The dispatcher\n * overlay layer is for gestures whose visual feedback isn't a moved scene\n * node — marquee rect (area-select), polyline + dashed close-line (lasso),\n * and any future overlay-only chrome an action wants to render.\n *\n * Replaces the per-tool `select-overlay` rendering for the same gestures\n * once the dispatcher path is the sole driver. Until\n * then both run side-by-side; the visuals overlap exactly so the\n * user-visible result is identical.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { DrawCommand, PathDrawCommand } from '../../renderer';\nimport type { CommandStroke } from '@weasel-js/paint';\nimport type { RenderLayer } from 'core/layers/render';\nimport { viewToTransform } from 'core/viewport/view';\nimport { worldToScreen } from 'core/viewport/viewTransform';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport {\n polygonFromPoints,\n polylineFromPoints,\n rectPath,\n ellipsePath,\n linePath,\n regularPolygonPath,\n starPath,\n} from '@weasel-js/geom';\nimport { getImageBitmap } from 'features/images/imageCache';\nimport { resolveOverlays } from 'interactions/actions/resolveOverlays';\nimport { gestureOverlaysFrom, isVisibleFrom } from '../drawEnvelope';\nimport { OVERLAY_ROLE_STROKES } from '../overlayRoleStrokes';\n\n/** Style knobs for the dispatcher-overlay layer's marquee + lasso paints.\n * Defaults match the legacy `useSelectTool` `areaSelectOverlayStyle`\n * defaults so the visual swap is invisible to users. */\nexport interface DispatcherOverlayStyle {\n fill?: string;\n stroke?: string;\n dash?: number[];\n lineWidth?: number;\n /** Stroke per `polyline` overlay role, merged over the kit's. A role with\n * no entry here and none of the kit's paints as plain chrome — the\n * `stroke` / `lineWidth` / `dash` above. */\n roles?: Readonly<Record<string, CommandStroke>>;\n}\n\nconst DEFAULT_STYLE: Required<Omit<DispatcherOverlayStyle, 'roles'>> = {\n fill: 'rgba(164, 139, 212, 0.18)',\n stroke: '#a48bd4',\n dash: [3, 3],\n lineWidth: 1,\n};\n\n/** Alpha for content previewed inside an in-flight gesture. Matches the\n * preview-ghost layer, so a dragged node and an uncommitted insert read as\n * equally provisional. */\nconst PREVIEW_CONTENT_OPACITY = 0.85;\n\n\nexport function useDispatcherOverlayLayer(args: {\n /** The surface's dispatcher, subscribed to only so a pump repaints. What\n * gets painted is the drawing view's own `getGestureOverlays()`. */\n dispatcher: Dispatcher | null | undefined;\n style?: DispatcherOverlayStyle;\n}): RenderLayer<unknown> {\n const { dispatcher, style } = args;\n\n const styleRef = useLatest(style);\n\n // Re-render on every dispatcher pump so live overlay (marquee, lasso\n // polyline) tracks pointermove instead of freezing on the first frame.\n const [, forceRerender] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n if (!dispatcher) return;\n return dispatcher.subscribe(forceRerender);\n }, [dispatcher]);\n\n return useMemo<RenderLayer<unknown>>(\n () => ({\n id: 'dispatcher-overlay',\n label: 'Dispatcher overlay',\n space: 'screen',\n draw: (data, view) => {\n const cfg = { ...DEFAULT_STYLE, ...(styleRef.current ?? {}) };\n // Merged rather than replaced: naming one role must not delete the\n // kit's others.\n const roles = { ...OVERLAY_ROLE_STROKES, ...(styleRef.current?.roles ?? {}) };\n const t = viewToTransform(view);\n const out: DrawCommand[] = [];\n\n // Chrome-caps gate. Mirrors `composeAffordanceLayer` /\n // `createSelectionOverlayLayer`: pull a visibility predicate off\n // the data envelope and consult it per overlay before pushing draw\n // commands. Absent envelope → every overlay paints. This stays on the\n // painting side: the predicate is a property of the view's envelope,\n // and two views of one surface may answer differently for the same\n // in-flight gesture.\n const isVisible = isVisibleFrom(data);\n const passes = (id: string) => (isVisible ? isVisible(id) : true);\n\n for (const ov of resolveOverlays(gestureOverlaysFrom(data))) {\n if (!passes(ov.visibilityId)) continue;\n\n if (ov.kind === 'marquee') {\n const b = ov.bounds;\n const [sx, sy] = worldToScreen(b.x, b.y, t);\n const sw = b.width * view.scale.x;\n const sh = b.height * view.scale.y;\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: { kind: 'rect', x: sx, y: sy, width: sw, height: sh },\n fill: { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n continue;\n }\n\n if (ov.kind === 'insertPreview') {\n const b = ov.bounds;\n const projectPoint = (wx: number, wy: number): { x: number; y: number } => {\n const [sx, sy] = worldToScreen(wx, wy, t);\n return { x: sx, y: sy };\n };\n const projectPoints = (\n pts: ReadonlyArray<{ x: number; y: number }>,\n ): { x: number; y: number }[] => pts.map((p) => projectPoint(p.x, p.y));\n // Radial shapes inscribe in a square, so a single screen-space\n // radius needs one scale factor; average the axes.\n const radialScale = (view.scale.x + view.scale.y) / 2;\n\n let pathCmd: PathDrawCommand['path'] | null = null;\n const geom = ov.geometry;\n switch (geom.kind) {\n case 'box': {\n const [sx, sy] = worldToScreen(b.x, b.y, t);\n const sw = b.width * view.scale.x;\n const sh = b.height * view.scale.y;\n if (ov.shape === 'image') {\n const e = ov.extras as Partial<{ src: string; preview: string }>;\n // The bitmap when it has decoded, the bare outline until then\n // (or when the tool opted out) — the outline is drawn either\n // way, so the drag always has an edge to read.\n const bmp = e.preview === 'outline' || !e.src\n ? undefined\n : getImageBitmap(e.src);\n if (bmp) {\n out.push({\n kind: 'image',\n image: bmp,\n x: sx, y: sy, w: sw, h: sh,\n opacity: PREVIEW_CONTENT_OPACITY,\n });\n }\n }\n pathCmd = ov.shape === 'ellipse'\n ? ellipsePath({ x: sx, y: sy, width: sw, height: sh })\n : rectPath(sx, sy, sw, sh);\n break;\n }\n case 'line':\n pathCmd = linePath(projectPoint(geom.a.x, geom.a.y), projectPoint(geom.b.x, geom.b.y));\n break;\n case 'polygon':\n pathCmd = regularPolygonPath(\n projectPoint(geom.center.x, geom.center.y),\n geom.radius * radialScale,\n geom.sides,\n geom.rotation,\n );\n break;\n case 'star':\n pathCmd = starPath(\n projectPoint(geom.center.x, geom.center.y),\n geom.outerRadius * radialScale,\n geom.points,\n geom.innerRadius * radialScale,\n geom.rotation,\n );\n break;\n case 'pencil':\n // Genuinely open: `polygonFromPoints` closes the path, and the\n // closing edge from the last sample back to the first reads as\n // a marquee rather than as the stroke being drawn.\n pathCmd = polylineFromPoints(projectPoints(geom.samples));\n break;\n }\n\n if (!pathCmd) continue;\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: pathCmd,\n fill: ov.shape === 'line' || ov.shape === 'pencil' || ov.shape === 'image'\n ? undefined\n : { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n // Anchor dot at the drag's click point. Sells the anchoring\n // visually for radial shapes (polygon/star — no vertex sits\n // at the AABB corner) and for center mode (dot marks the\n // growth axis). 4 CSS-px radius, same stroke color as the\n // ghost so it reads as part of the chrome.\n if (ov.anchorPoint) {\n const anchorScreen = projectPoint(ov.anchorPoint.x, ov.anchorPoint.y);\n out.push({\n kind: 'path',\n path: ellipsePath({\n x: anchorScreen.x - 4,\n y: anchorScreen.y - 4,\n width: 8,\n height: 8,\n }),\n fill: { color: cfg.stroke },\n });\n }\n continue;\n }\n\n if (ov.kind === 'lasso') {\n // Project every vertex to screen coords; build a single polygon\n // path. The polygon already closes (polygonFromPoints adds Z),\n // which renders as the dashed \"close-line\" implicit in the\n // legacy hook's visual. Fill paints the would-be selection\n // region; stroke paints the polyline + close-line.\n const screenPts: { x: number; y: number }[] = [];\n for (const v of ov.vertices) {\n const [sx, sy] = worldToScreen(v.x, v.y, t);\n screenPts.push({ x: sx, y: sy });\n }\n const cmd: PathDrawCommand = {\n kind: 'path',\n path: polygonFromPoints(screenPts),\n fill: { color: cfg.fill },\n stroke: { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash },\n };\n out.push(cmd);\n continue;\n }\n\n if (ov.kind === 'polyline') {\n const stroke =\n roles[ov.role] ??\n { paint: { color: cfg.stroke }, width: cfg.lineWidth, dash: cfg.dash };\n const screenPts: { x: number; y: number }[] = [];\n for (const pt of ov.points) {\n const [sx, sy] = worldToScreen(pt.x, pt.y, t);\n screenPts.push({ x: sx, y: sy });\n }\n out.push({\n kind: 'path',\n path: polylineFromPoints(screenPts),\n stroke,\n } satisfies PathDrawCommand);\n continue;\n }\n }\n\n if (out.length === 0) return [];\n // Screen-space layer: emit commands directly. The worldToScreen\n // projection above has already mapped every coord into CSS pixels.\n return out;\n },\n }),\n [styleRef],\n );\n}\n"],"mappings":";;;;;;;;;;AA0DA,IAAMA,IAAiE;CACrE,MAAM;CACN,QAAQ;CACR,MAAM,CAAC,GAAG,CAAC;CACX,WAAW;AACb,GAKMC,IAA0B;AAGhC,SAAgBC,EAA0B,GAKjB;CACvB,IAAM,EAAE,eAAY,aAAUC,GAExBC,IAAWC,EAAUC,CAAK,GAI1B,GAAGC,KAAiBC,GAAY,MAAcC,IAAI,GAAG,CAAC;CAM5D,OALAC,QAAgB;EACd,IAAKC,GACL,OAAOA,EAAW,UAAUJ,CAAa;CAC3C,GAAG,CAACI,CAAU,CAAC,GAERC,SACE;EACL,IAAI;EACJ,OAAO;EACP,OAAO;EACP,OAAO,GAAM,MAAS;GACpB,IAAMC,IAAM;IAAE,GAAGb;IAAe,GAAII,EAAS,WAAW,CAAC;GAAG,GAGtDU,IAAQ;IAAE,GAAGC;IAAsB,GAAIX,EAAS,SAAS,SAAS,CAAC;GAAG,GACtEY,IAAIC,EAAgBC,CAAI,GACxBC,IAAqB,CAAC,GAStBC,IAAYC,EAAcC,CAAI,GAC9BC,KAAU,MAAgB,MAAYH,EAAUI,CAAE;GA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veParallaxView as e } from "../../core/viewport/parallax.js";
2
- import { resolveDerivedPath as t } from "../../core/scene/derivedPath.js";
3
- import { findShapeSilhouette as n } from "../NodeShape.js";
4
- import { sceneDepLookup as r } from "../derivedPath.js";
5
- import { planeTransform as i } from "../planeClips.js";
6
- import { scenePlaneOf as a } from "../pickWalk.js";
7
- import { wrapWithPoseRotation as o } from "../poseRotation.js";
8
- import { previewSourcesFrom as s } from "../drawEnvelope.js";
9
- import { resolvePreviews as c } from "../../interactions/actions/resolvePreviews.js";
10
- import { useEffect as l, useMemo as u, useReducer as d } from "react";
11
- import { useLatest as f } from "@weasel-js/react";
2
+ import { planeTransform as t } from "../planeClips.js";
3
+ import { wrapWithPoseRotation as n } from "../poseRotation.js";
4
+ import { findShapeSilhouette as r } from "../NodeShape.js";
5
+ import { scenePlaneOf as i } from "../pickWalk.js";
6
+ import { previewSourcesFrom as a } from "../drawEnvelope.js";
7
+ import { resolvePreviews as o } from "../../interactions/actions/resolvePreviews.js";
8
+ import { useEffect as s, useMemo as c, useReducer as l } from "react";
9
+ import { useLatest as u } from "@weasel-js/react";
12
10
  //#region src/canvas/SceneCanvas/usePreviewGhostLayer.ts
13
- var p = .85;
14
- function m(m) {
15
- let { scene: h, sceneSlot: g, dispatcher: _ } = m, v = f(h), y = f(g), [, b] = d((e) => e + 1, 0);
16
- return l(() => {
17
- if (_) return _.subscribe(b);
18
- }, [_]), u(() => ({
11
+ var d = .85;
12
+ function f(f) {
13
+ let { scene: p, sceneSlot: m, dispatcher: h } = f, g = u(p), _ = u(m), [, v] = l((e) => e + 1, 0);
14
+ return s(() => {
15
+ if (h) return h.subscribe(v);
16
+ }, [h]), c(() => ({
19
17
  id: "preview-ghost",
20
18
  label: "Preview ghost",
21
- draw: (l, u) => {
22
- let d = y.current, f = d?.drawOne;
23
- if (!d || !f) return [];
24
- let m = s(l), h = v.current, g = c(m, h);
25
- if (g.length === 0) return [];
26
- let _ = r(h), b = a(h.layers, u), x = (e) => b?.(e) ?? null, S = (t) => {
27
- let n = b ? h.layers.find((e) => e.id === t)?.parallax : void 0;
28
- return n ? e(u, n) : u;
29
- }, C = (e, r) => {
19
+ draw: (s, c) => {
20
+ let l = _.current, u = l?.drawOne;
21
+ if (!l || !u) return [];
22
+ let f = a(s), p = g.current, m = o(f, p);
23
+ if (m.length === 0) return [];
24
+ let h = i(p.layers, c), v = (e) => h?.(e) ?? null, y = (t) => {
25
+ let n = h ? p.layers.find((e) => e.id === t)?.parallax : void 0;
26
+ return n ? e(c, n) : c;
27
+ }, b = (e, i) => {
30
28
  let a = e.data === e.node.data ? e.node : {
31
29
  ...e.node,
32
30
  data: e.data
33
- }, s = x(e.node.layer), c = f(a, e.pose, S(e.node.layer)), l = [...o(c, e.pose)];
34
- for (let t of e.children) for (let e of C(t, s)) l.push(e);
35
- let u = i(s, r), d = u ? {
31
+ }, o = v(e.node.layer), s = u(a, e.pose, y(e.node.layer)), c = [...n(s, e.pose)];
32
+ for (let t of e.children) for (let e of b(t, o)) c.push(e);
33
+ let d = t(o, i), f = d ? {
36
34
  kind: "group",
37
- transform: u,
38
- children: l
35
+ transform: d,
36
+ children: c
39
37
  } : {
40
38
  kind: "group",
41
- children: l
39
+ children: c
42
40
  };
43
41
  if (a.kind === "container") {
44
- let r = n(a, e.pose, { derivedPath: t(a, _, (e) => h.childrenOf(e)) });
45
- r && (d.clip = r);
42
+ let t = r(a, e.pose, { derivedPath: l.derivedPathOf?.(a, e.pose) ?? null });
43
+ t && (f.clip = t);
46
44
  }
47
- return [d];
48
- }, w = [], T = [];
49
- for (let e of g) {
50
- let t = e.opaque ? T : w;
51
- for (let n of C(e, null)) t.push(n);
45
+ return [f];
46
+ }, x = [], S = [];
47
+ for (let e of m) {
48
+ let t = e.opaque ? S : x;
49
+ for (let n of b(e, null)) t.push(n);
52
50
  }
53
- if (w.length === 0 && T.length === 0) return [];
54
- let E = [];
55
- return T.length > 0 && E.push({
51
+ if (x.length === 0 && S.length === 0) return [];
52
+ let C = [];
53
+ return S.length > 0 && C.push({
56
54
  kind: "group",
57
- children: T
58
- }), w.length > 0 && E.push({
55
+ children: S
56
+ }), x.length > 0 && C.push({
59
57
  kind: "group",
60
- alpha: p,
61
- children: w
62
- }), E;
58
+ alpha: d,
59
+ children: x
60
+ }), C;
63
61
  }
64
- }), [v, y]);
62
+ }), [g, _]);
65
63
  }
66
64
  //#endregion
67
- export { m as usePreviewGhostLayer };
65
+ export { f as usePreviewGhostLayer };
68
66
 
69
67
  //# sourceMappingURL=usePreviewGhostLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePreviewGhostLayer.js","names":["GHOST_ALPHA","usePreviewGhostLayer","args","sceneRef","useLatest","scene","sceneSlotRef","sceneSlot","forceRerender","useReducer","n","useEffect","dispatcher","useMemo","slot","drawOne","sources","previewSourcesFrom","data","sc","roots","resolvePreviews","depOf","sceneDepLookup","planeOf","scenePlaneOf","view","mapOf","layer","viewOf","parallax","l","deriveParallaxView","drawEntry","effNode","entry","plane","self","children","wrapWithPoseRotation","child","cmd","transform","planeTransform","parentPlane","group","clip","findShapeSilhouette","resolveDerivedPath","nid","ghosted","settled","root","sink","out"],"sources":["../../../src/canvas/SceneCanvas/usePreviewGhostLayer.ts"],"sourcesContent":["/**\n * Preview-ghost render layer for `<SceneCanvas>`. Renders in-flight gesture\n * poses on top of the committed scene by reusing the scene slot's `drawOne`.\n * Which ids are displaced (`previewIds`) and where (`previewPose`) comes from\n * the drawing view's preview sources on the draw envelope — tools first, then\n * that view's in-flight handles.\n *\n * This replaces the per-tool `drawGhost` fold-in — a single SceneCanvas\n * concern instead of every consumer wiring it.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { type DrawCommand, type GroupDrawCommand } from '../../renderer';\nimport type { RenderLayer } from 'core/layers/render';\nimport type { LayersMap } from '../Canvas';\nimport type { Node, Scene } from 'core/scene/types';\nimport { findShapeSilhouette } from '../NodeShape';\nimport { wrapWithPoseRotation } from '../poseRotation';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport { previewSourcesFrom } from '../drawEnvelope';\nimport { resolvePreviews, type PreviewNode } from 'interactions/actions/resolvePreviews';\nimport { resolveDerivedPath, sceneDepLookup } from '../derivedPath';\nimport { scenePlaneOf } from '../pickWalk';\nimport { planeTransform } from '../planeClips';\nimport { deriveParallaxView } from 'core/viewport/parallax';\nimport type { PlaneMap } from 'core/viewport/parallax';\n\nconst GHOST_ALPHA = 0.85;\n\nexport function usePreviewGhostLayer<TData, TLayer extends string, TPose>(args: {\n scene: Scene<TData, TLayer, TPose>;\n sceneSlot: LayersMap<Node<TData, TLayer, TPose>, TPose>['scene'];\n /**\n * The surface's dispatcher, subscribed to only so a pump repaints — preview\n * poses mutate silently inside handles otherwise. What gets *painted* is the\n * drawing view's own `getPreviewSources()`, off the draw envelope.\n */\n dispatcher?: Dispatcher | null;\n}): RenderLayer<unknown> {\n const { scene, sceneSlot, dispatcher } = args;\n\n // Refs let the layer body read the last committed scene/slot without\n // re-creating the layer on every host render.\n const sceneRef = useLatest(scene);\n const sceneSlotRef = useLatest(sceneSlot);\n\n // Subscribe to dispatcher state changes so the canvas re-renders on every\n // ongoing-action pump (preview poses mutate silently inside handles\n // otherwise — single-frame ghost stuck on the start pose).\n const [, forceRerender] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n if (!dispatcher) return;\n const unsub = dispatcher.subscribe(forceRerender);\n return unsub;\n }, [dispatcher]);\n\n return useMemo<RenderLayer<unknown>>(() => ({\n id: 'preview-ghost',\n label: 'Preview ghost',\n draw: (data, view) => {\n const slot = sceneSlotRef.current;\n const drawOne = slot?.drawOne;\n if (!slot || !drawOne) return [];\n // Whose gesture this frame is showing belongs to the view being drawn,\n // not to the surface that built the layer.\n const sources = previewSourcesFrom(data);\n const sc = sceneRef.current;\n const roots = resolvePreviews(sources, sc);\n if (roots.length === 0) return [];\n\n // Reads the same overrides an in-flight gesture publishes, so a derived\n // container ghosts with the clip it will actually impose.\n const depOf = sceneDepLookup(sc);\n\n // A node on a parallax layer ghosts where its plane draws it: through\n // the plane's view, inside a group carrying it into its parent's world.\n const planeOf = scenePlaneOf(sc.layers, view);\n const mapOf = (layer: string): PlaneMap | null => planeOf?.(layer) ?? null;\n const viewOf = (layer: string) => {\n const parallax = planeOf ? sc.layers.find((l) => l.id === layer)?.parallax : undefined;\n return parallax ? deriveParallaxView(view, parallax) : view;\n };\n\n // Mirrors buildSceneTree's structure — a container group carries a clip\n // from its painter's silhouette — but drawn from the previewed pose and\n // data, so children are clipped to the shape the container is taking.\n const drawEntry = (\n entry: PreviewNode<TData, TLayer, TPose>,\n parentPlane: PlaneMap | null,\n ): DrawCommand[] => {\n const effNode = entry.data === entry.node.data\n ? entry.node\n : ({ ...entry.node, data: entry.data } as typeof entry.node);\n const plane = mapOf(entry.node.layer);\n const self = drawOne(effNode, entry.pose, viewOf(entry.node.layer));\n const children: DrawCommand[] = [...wrapWithPoseRotation(self, entry.pose as unknown)];\n for (const child of entry.children) {\n for (const cmd of drawEntry(child, plane)) children.push(cmd);\n }\n const transform = planeTransform(plane, parentPlane);\n const group: GroupDrawCommand = transform ? { kind: 'group', transform, children } : { kind: 'group', children };\n if (effNode.kind === 'container') {\n const clip = findShapeSilhouette(\n effNode as unknown as Node<unknown, string, TPose>,\n entry.pose,\n { derivedPath: resolveDerivedPath(effNode, depOf, (nid) => sc.childrenOf(nid)) },\n );\n if (clip) group.clip = clip;\n }\n return [group];\n };\n\n // Opaque is honored at subtree-root granularity, as it always was: a\n // sibling reflowing into place brings its own contents with it.\n const ghosted: DrawCommand[] = [];\n const settled: DrawCommand[] = [];\n for (const root of roots) {\n const sink = root.opaque ? settled : ghosted;\n for (const cmd of drawEntry(root, null)) sink.push(cmd);\n }\n if (ghosted.length === 0 && settled.length === 0) return [];\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n const out: DrawCommand[] = [];\n if (settled.length > 0) out.push({ kind: 'group', children: settled });\n if (ghosted.length > 0) out.push({ kind: 'group', al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,CAAC,GAAGC,EAAqBF,GAAMF,EAAM,IAAe,CAAC;IACrF,KAAK,IAAMK,KAASL,EAAM,UACxB,KAAK,IAAMM,KAAOR,EAAUO,GAAOJ,CAAK,GAAG,EAAS,KAAKK,CAAG;IAE9D,IAAMC,IAAYC,EAAeP,GAAOQ,CAAW,GAC7CC,IAA0BH,IAAY;KAAE,MAAM;KAAS;KAAW;IAAS,IAAI;KAAE,MAAM;KAAS;IAAS;IAC/G,IAAIR,EAAQ,SAAS,aAAa;KAChC,IAAMY,IAAOC,EACXb,GACAC,EAAM,MACN,EAAE,aAAaa,EAAmBd,GAASZ,IAAQ,MAAQH,EAAG,WAAW8B,CAAG,CAAC,EAAE,CACjF;KACA,AAAIH,MAAM,EAAM,OAAOA;IACzB;IACA,OAAO,CAACD,CAAK;GACf,GAIMK,IAAyB,CAAC,GAC1BC,IAAyB,CAAC;GAChC,KAAK,IAAMC,KAAQhC,GAAO;IACxB,IAAMiC,IAAOD,EAAK,SAASD,IAAUD;IACrC,KAAK,IAAMT,KAAOR,EAAUmB,GAAM,IAAI,GAAG,EAAK,KAAKX,CAAG;GACxD;GACA,IAAIS,EAAQ,WAAW,KAAKC,EAAQ,WAAW,GAAG,OAAO,CAAC;GAE1D,IAAMG,IAAqB,CAAC;GAG5B,OAFIH,EAAQ,SAAS,KAAGG,EAAI,KAAK;IAAE,MAAM;IAAS,UAAUH;GAAQ,CAAC,GACjED,EAAQ,SAAS,KAAGI,EAAI,KAAK;IAAE,MAAM;IAAS,OAAOtD;IAAa,UAAUkD;GAAQ,CAAC,GAClFI;EACT;CACF,IAAI,CAACnD,GAAUG,CAAY,CAAC;AAC9B"}
1
+ {"version":3,"file":"usePreviewGhostLayer.js","names":["GHOST_ALPHA","usePreviewGhostLayer","args","sceneRef","useLatest","scene","sceneSlotRef","sceneSlot","forceRerender","useReducer","n","useEffect","dispatcher","useMemo","slot","drawOne","sources","previewSourcesFrom","data","sc","roots","resolvePreviews","planeOf","scenePlaneOf","view","mapOf","layer","viewOf","parallax","l","deriveParallaxView","drawEntry","effNode","entry","plane","self","children","wrapWithPoseRotation","child","cmd","transform","planeTransform","parentPlane","group","clip","findShapeSilhouette","ghosted","settled","root","sink","out"],"sources":["../../../src/canvas/SceneCanvas/usePreviewGhostLayer.ts"],"sourcesContent":["/**\n * Preview-ghost render layer for `<SceneCanvas>`. Renders in-flight gesture\n * poses on top of the committed scene by reusing the scene slot's `drawOne`.\n * Which ids are displaced (`previewIds`) and where (`previewPose`) comes from\n * the drawing view's preview sources on the draw envelope — tools first, then\n * that view's in-flight handles.\n *\n * This replaces the per-tool `drawGhost` fold-in — a single SceneCanvas\n * concern instead of every consumer wiring it.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { type DrawCommand, type GroupDrawCommand } from '../../renderer';\nimport type { RenderLayer } from 'core/layers/render';\nimport type { LayersMap } from '../Canvas';\nimport type { Node, Scene } from 'core/scene/types';\nimport { findShapeSilhouette } from '../NodeShape';\nimport { wrapWithPoseRotation } from '../poseRotation';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport { previewSourcesFrom } from '../drawEnvelope';\nimport { resolvePreviews, type PreviewNode } from 'interactions/actions/resolvePreviews';\nimport { scenePlaneOf } from '../pickWalk';\nimport { planeTransform } from '../planeClips';\nimport { deriveParallaxView } from 'core/viewport/parallax';\nimport type { PlaneMap } from 'core/viewport/parallax';\n\nconst GHOST_ALPHA = 0.85;\n\nexport function usePreviewGhostLayer<TData, TLayer extends string, TPose>(args: {\n scene: Scene<TData, TLayer, TPose>;\n sceneSlot: LayersMap<Node<TData, TLayer, TPose>, TPose>['scene'];\n /**\n * The surface's dispatcher, subscribed to only so a pump repaints — preview\n * poses mutate silently inside handles otherwise. What gets *painted* is the\n * drawing view's own `getPreviewSources()`, off the draw envelope.\n */\n dispatcher?: Dispatcher | null;\n}): RenderLayer<unknown> {\n const { scene, sceneSlot, dispatcher } = args;\n\n // Refs let the layer body read the last committed scene/slot without\n // re-creating the layer on every host render.\n const sceneRef = useLatest(scene);\n const sceneSlotRef = useLatest(sceneSlot);\n\n // Subscribe to dispatcher state changes so the canvas re-renders on every\n // ongoing-action pump (preview poses mutate silently inside handles\n // otherwise — single-frame ghost stuck on the start pose).\n const [, forceRerender] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n if (!dispatcher) return;\n const unsub = dispatcher.subscribe(forceRerender);\n return unsub;\n }, [dispatcher]);\n\n return useMemo<RenderLayer<unknown>>(() => ({\n id: 'preview-ghost',\n label: 'Preview ghost',\n draw: (data, view) => {\n const slot = sceneSlotRef.current;\n const drawOne = slot?.drawOne;\n if (!slot || !drawOne) return [];\n // Whose gesture this frame is showing belongs to the view being drawn,\n // not to the surface that built the layer.\n const sources = previewSourcesFrom(data);\n const sc = sceneRef.current;\n const roots = resolvePreviews(sources, sc);\n if (roots.length === 0) return [];\n\n // A node on a parallax layer ghosts where its plane draws it: through\n // the plane's view, inside a group carrying it into its parent's world.\n const planeOf = scenePlaneOf(sc.layers, view);\n const mapOf = (layer: string): PlaneMap | null => planeOf?.(layer) ?? null;\n const viewOf = (layer: string) => {\n const parallax = planeOf ? sc.layers.find((l) => l.id === layer)?.parallax : undefined;\n return parallax ? deriveParallaxView(view, parallax) : view;\n };\n\n // Mirrors buildSceneTree's structure — a container group carries a clip\n // from its painter's silhouette — but drawn from the previewed pose and\n // data, so children are clipped to the shape the container is taking.\n const drawEntry = (\n entry: PreviewNode<TData, TLayer, TPose>,\n parentPlane: PlaneMap | null,\n ): DrawCommand[] => {\n const effNode = entry.data === entry.node.data\n ? entry.node\n : ({ ...entry.node, data: entry.data } as typeof entry.node);\n const plane = mapOf(entry.node.layer);\n const self = drawOne(effNode, entry.pose, viewOf(entry.node.layer));\n const children: DrawCommand[] = [...wrapWithPoseRotation(self, entry.pose as unknown)];\n for (const child of entry.children) {\n for (const cmd of drawEntry(child, plane)) children.push(cmd);\n }\n const transform = planeTransform(plane, parentPlane);\n const group: GroupDrawCommand = transform ? { kind: 'group', transform, children } : { kind: 'group', children };\n if (effNode.kind === 'container') {\n const clip = findShapeSilhouette(\n effNode as unknown as Node<unknown, string, TPose>,\n entry.pose,\n { derivedPath: slot.derivedPathOf?.(effNode, entry.pose) ?? null },\n );\n if (clip) group.clip = clip;\n }\n return [group];\n };\n\n // Opaque is honored at subtree-root granularity, as it always was: a\n // sibling reflowing into place brings its own contents with it.\n const ghosted: DrawCommand[] = [];\n const settled: DrawCommand[] = [];\n for (const root of roots) {\n const sink = root.opaque ? settled : ghosted;\n for (const cmd of drawEntry(root, null)) sink.push(cmd);\n }\n if (ghosted.length === 0 && settled.length === 0) return [];\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n const out: DrawCommand[] = [];\n if (settled.length > 0) out.push({ kind: 'group', children: settled });\n if (ghosted.length > 0) out.push({ kind: 'group', alpha: GHOST_ALPHA, children: ghosted });\n return out;\n },\n }), [sceneRef, sceneSlotRef]);\n}\n"],"mappings":";;;;;;;;;;AA0BA,IAAMA,IAAc;AAEpB,SAAgBC,EAA0D,GASjD;CACvB,IAAM,EAAE,UAAO,cAAW,kBAAeC,GAInCC,IAAWC,EAAUC,CAAK,GAC1BC,IAAeF,EAAUG,CAAS,GAKlC,GAAGC,KAAiBC,GAAY,MAAcC,IAAI,GAAG,CAAC;CAO5D,OANAC,QAAgB;EACd,IAAKC,GAEL,OADcA,EAAW,UAAUJ,CAC5B;CACT,GAAG,CAACI,CAAU,CAAC,GAERC,SAAqC;EAC1C,IAAI;EACJ,OAAO;EACP,OAAO,GAAM,MAAS;GACpB,IAAMC,IAAOR,EAAa,SACpBS,IAAUD,GAAM;GACtB,IAAI,CAACA,KAAQ,CAACC,GAAS,OAAO,CAAC;GAG/B,IAAMC,IAAUC,EAAmBC,CAAI,GACjCC,IAAKhB,EAAS,SACdiB,IAAQC,EAAgBL,GAASG,CAAE;GACzC,IAAIC,EAAM,WAAW,GAAG,OAAO,CAAC;GAIhC,IAAME,IAAUC,EAAaJ,EAAG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O,CAAC;GAE1D,IAAMG,IAAqB,CAAC;GAG5B,OAFIH,EAAQ,SAAS,KAAGG,EAAI,KAAK;IAAE,MAAM;IAAS,UAAUH;GAAQ,CAAC,GACjED,EAAQ,SAAS,KAAGI,EAAI,KAAK;IAAE,MAAM;IAAS,OAAOlD;IAAa,UAAU8C;GAAQ,CAAC,GAClFI;EACT;CACF,IAAI,CAAC/C,GAAUG,CAAY,CAAC;AAC9B"}
@@ -1,9 +1,9 @@
1
- import { rectFromPlane as e, toPlane as t } from "../../core/viewport/parallax.js";
2
- import { meanScale as n } from "../../core/viewport/meanScale.js";
3
- import { asNodeId as r } from "../../core/scene/types.js";
4
- import { poseDescriptorForNode as i } from "../../core/geometry/poseDescriptor.js";
5
- import { AUTO_POSE_DESCRIPTOR as a } from "../../interactions/actions/resize/autoPoseDescriptor.js";
6
- import { findShapeInk as o, shapeCoversPoint as s } from "../NodeShape.js";
1
+ import { meanScale as e } from "../../core/viewport/meanScale.js";
2
+ import { rectFromPlane as t, toPlane as n } from "../../core/viewport/parallax.js";
3
+ import { poseDescriptorForNode as r } from "../../core/geometry/poseDescriptor.js";
4
+ import { AUTO_POSE_DESCRIPTOR as i } from "../../interactions/actions/resize/autoPoseDescriptor.js";
5
+ import { findShapeInk as a, shapeCoversPoint as o } from "../NodeShape.js";
6
+ import { asNodeId as s } from "../../core/scene/types.js";
7
7
  import { pickWalk as c, scenePickSource as l, scenePlaneOf as u } from "../pickWalk.js";
8
8
  import { pickTopMostHit as d } from "../../tools/builtin/pickTopMostHit.js";
9
9
  import { useSelectTool as f } from "../../tools/builtin/select/useSelectTool.js";
@@ -22,55 +22,55 @@ function b(e) {
22
22
  } : null;
23
23
  }
24
24
  function x(x) {
25
- let { scene: S, adapter: C, geometry: w, selectTool: T, getView: E, alphaOf: D, layerIsPainted: O } = x, k = x.poseDescriptor ?? a, A = w?.pickEvery, j = w?.boundsOf, M = (w?.picking ?? "shape") === "shape", N = w?.pickTolerancePx ?? y, P = T?.move, F = T?.snap, I = _(() => {
25
+ let { scene: S, adapter: C, geometry: w, selectTool: T, getView: E, alphaOf: D, layerIsPainted: O } = x, k = x.poseDescriptor ?? i, A = w?.pickEvery, j = w?.boundsOf, M = (w?.picking ?? "shape") === "shape", N = w?.pickTolerancePx ?? y, P = T?.move, F = T?.snap, I = _(() => {
26
26
  let e = { ...P ?? {} };
27
27
  if (F) {
28
28
  let t = e.behaviors ?? [];
29
29
  e.behaviors = [p(F), ...t];
30
30
  }
31
31
  return e;
32
- }, [P, F]), L = _(() => (e, r, i) => {
32
+ }, [P, F]), L = _(() => (t, r, i) => {
33
33
  if (A) {
34
- let t = A(e, r);
35
- return t == null ? [] : Array.isArray(t) ? t : [t];
34
+ let e = A(t, r);
35
+ return e == null ? [] : Array.isArray(e) ? e : [e];
36
36
  }
37
- let a = i ?? E?.() ?? null, u = i?.alphaOf ?? D, d = i?.layerIsPainted ?? O, f = b(a), p = l(S, {
37
+ let s = i ?? E?.() ?? null, u = i?.alphaOf ?? D, d = i?.layerIsPainted ?? O, f = b(s), p = l(S, {
38
38
  getPose: (e) => C.getWorldPose(e),
39
39
  ...u ? { alphaOf: u } : {},
40
40
  ...d ? { layerIsPainted: d } : {},
41
41
  ...f ? { camera: f } : {}
42
- }), _ = (e, r, i) => {
43
- let a = n(i), c = {
42
+ }), _ = (t, r, i) => {
43
+ let s = e(i), c = {
44
44
  px: N,
45
45
  scale: i
46
46
  };
47
47
  return {
48
- hits: (t, n, i) => {
49
- let l = M ? o(t, n, { scale: a }) : null, u = {
48
+ hits: (e, n, i) => {
49
+ let l = M ? a(e, n, { scale: s }) : null, u = {
50
50
  ...c,
51
51
  px: c.px + (l?.outsetPx ?? 0),
52
52
  reach: l?.outset ?? 0
53
53
  };
54
- return (i ? m(i, e, r, u, k) : h(n, e, r, u, k)) ? !M || s(t, n, e, r, {
54
+ return (i ? m(i, t, r, u, k) : h(n, t, r, u, k)) ? !M || o(e, n, t, r, {
55
55
  tolerance: c,
56
- scale: a,
56
+ scale: s,
57
57
  derivedPath: i
58
58
  }) : !1;
59
59
  },
60
- clipAdmits: (t) => g(t, e, r),
61
- inPlane: (n) => {
62
- let a = t(n, {
63
- x: e,
60
+ clipAdmits: (e) => g(e, t, r),
61
+ inPlane: (e) => {
62
+ let a = n(e, {
63
+ x: t,
64
64
  y: r
65
65
  });
66
66
  return _(a.x, a.y, {
67
- x: i.x / n.scale.x,
68
- y: i.y / n.scale.y
67
+ x: i.x / e.scale.x,
68
+ y: i.y / e.scale.y
69
69
  });
70
70
  }
71
71
  };
72
72
  };
73
- return c(p, _(e, r, a?.scale ?? {
73
+ return c(p, _(t, r, s?.scale ?? {
74
74
  x: 1,
75
75
  y: 1
76
76
  }));
@@ -85,21 +85,21 @@ function x(x) {
85
85
  O,
86
86
  k
87
87
  ]), R = v(E), z = _(() => (e, t) => {
88
- let n = S.get(r(e)), i = b(t ?? R.current?.() ?? null);
89
- return !n || !i ? null : u(S.layers, i)?.(n.layer) ?? null;
90
- }, [S, R]), B = _(() => (t, n, a) => {
91
- let o = S.get(r(t));
92
- if (!o) return null;
93
- let s = i(k, o), c = s.getBounds(n), l = s.getRotation?.(n) ?? c.rotation ?? 0, u = l ? {
88
+ let n = S.get(s(e)), r = b(t ?? R.current?.() ?? null);
89
+ return !n || !r ? null : u(S.layers, r)?.(n.layer) ?? null;
90
+ }, [S, R]), B = _(() => (e, n, i) => {
91
+ let a = S.get(s(e));
92
+ if (!a) return null;
93
+ let o = r(k, a), c = o.getBounds(n), l = o.getRotation?.(n) ?? c.rotation ?? 0, u = l ? {
94
94
  ...c,
95
95
  rotation: l
96
- } : c, d = z(t, a);
97
- return d ? e(d, u) : u;
96
+ } : c, d = z(e, i);
97
+ return d ? t(d, u) : u;
98
98
  }, [
99
99
  S,
100
100
  k,
101
101
  z
102
- ]), V = _(() => (e, t) => j ? j(e) : S.get(r(e)) ? B(e, C.getWorldPose(e), t) : null, [
102
+ ]), V = _(() => (e, t) => j ? j(e) : S.get(s(e)) ? B(e, C.getWorldPose(e), t) : null, [
103
103
  S,
104
104
  C,
105
105
  j,