@weasel-js/core 1.6.1 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1005) hide show
  1. package/CHANGELOG.md +1006 -0
  2. package/README.md +28 -9
  3. package/dist/WeaselProvider.js +15 -0
  4. package/dist/WeaselProvider.js.map +1 -0
  5. package/dist/affordances/composeAffordanceLayer.js +224 -0
  6. package/dist/affordances/composeAffordanceLayer.js.map +1 -0
  7. package/dist/affordances/cornerResize.js +69 -0
  8. package/dist/affordances/cornerResize.js.map +1 -0
  9. package/dist/affordances/hitAffordanceRegions.js +138 -0
  10. package/dist/affordances/hitAffordanceRegions.js.map +1 -0
  11. package/dist/affordances/pathAnchors.js +66 -0
  12. package/dist/affordances/pathAnchors.js.map +1 -0
  13. package/dist/affordances/rotationHandle.js +103 -0
  14. package/dist/affordances/rotationHandle.js.map +1 -0
  15. package/dist/animation/behaviors/momentum.js +118 -0
  16. package/dist/animation/behaviors/momentum.js.map +1 -0
  17. package/dist/animation/colorHelpers.js +135 -0
  18. package/dist/animation/colorHelpers.js.map +1 -0
  19. package/dist/animation/colorRegistry.js +37 -0
  20. package/dist/animation/colorRegistry.js.map +1 -0
  21. package/dist/animation/index.js +20 -0
  22. package/dist/animation/loop.js +62 -0
  23. package/dist/animation/loop.js.map +1 -0
  24. package/dist/animation/observe.js +23 -0
  25. package/dist/animation/observe.js.map +1 -0
  26. package/dist/animation/poseHelpers.js +50 -0
  27. package/dist/animation/poseHelpers.js.map +1 -0
  28. package/dist/animation/reflow.js +121 -0
  29. package/dist/animation/reflow.js.map +1 -0
  30. package/dist/animation/rig/bindRig.js +74 -0
  31. package/dist/animation/rig/bindRig.js.map +1 -0
  32. package/dist/animation/rig/blendPoses.js +43 -0
  33. package/dist/animation/rig/blendPoses.js.map +1 -0
  34. package/dist/animation/rig/mirrorPose.js +19 -0
  35. package/dist/animation/rig/mirrorPose.js.map +1 -0
  36. package/dist/animation/rig/resolveSkeleton.js +33 -0
  37. package/dist/animation/rig/resolveSkeleton.js.map +1 -0
  38. package/dist/animation/rig/solveIk.js +103 -0
  39. package/dist/animation/rig/solveIk.js.map +1 -0
  40. package/dist/animation/rig/types.js +12 -0
  41. package/dist/animation/rig/types.js.map +1 -0
  42. package/dist/animation/rig/useRig.js +23 -0
  43. package/dist/animation/rig/useRig.js.map +1 -0
  44. package/dist/animation/slew.js +27 -0
  45. package/dist/animation/slew.js.map +1 -0
  46. package/dist/animation/stagger.js +138 -0
  47. package/dist/animation/stagger.js.map +1 -0
  48. package/dist/animation/timeline/booking.js +106 -0
  49. package/dist/animation/timeline/booking.js.map +1 -0
  50. package/dist/animation/timeline/createTimeline.js +116 -0
  51. package/dist/animation/timeline/createTimeline.js.map +1 -0
  52. package/dist/animation/timeline/sampleTrack.js +29 -0
  53. package/dist/animation/timeline/sampleTrack.js.map +1 -0
  54. package/dist/animation/useAnimator.js +329 -0
  55. package/dist/animation/useAnimator.js.map +1 -0
  56. package/dist/animation/wrappers/animateLifecycle.js +40 -0
  57. package/dist/animation/wrappers/animateLifecycle.js.map +1 -0
  58. package/dist/animation/wrappers/animateOnSetPose.js +44 -0
  59. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -0
  60. package/dist/{autoPoseDescriptor-_XOyF7t4.d.ts → autoPoseDescriptor-BT_vp9FO.d.ts} +2 -2
  61. package/dist/{builtins-HWyuLzE-.d.ts → builtins-BSUfH8nU.d.ts} +1301 -508
  62. package/dist/canvas/Canvas.js +608 -0
  63. package/dist/canvas/Canvas.js.map +1 -0
  64. package/dist/canvas/CanvasView.js +255 -0
  65. package/dist/canvas/CanvasView.js.map +1 -0
  66. package/dist/canvas/CursorCoordsHud.js +75 -0
  67. package/dist/canvas/CursorCoordsHud.js.map +1 -0
  68. package/dist/canvas/DrawCanvas.js +67 -0
  69. package/dist/canvas/DrawCanvas.js.map +1 -0
  70. package/dist/canvas/MinimapCanvas.js +139 -0
  71. package/dist/canvas/MinimapCanvas.js.map +1 -0
  72. package/dist/canvas/ModalityHud.js +66 -0
  73. package/dist/canvas/ModalityHud.js.map +1 -0
  74. package/dist/canvas/NodeShape.js +391 -0
  75. package/dist/canvas/NodeShape.js.map +1 -0
  76. package/dist/canvas/PickHud.js +93 -0
  77. package/dist/canvas/PickHud.js.map +1 -0
  78. package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +10 -0
  79. package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +10 -0
  81. package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js.map +1 -0
  82. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +51 -0
  83. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -0
  84. package/dist/canvas/SceneCanvas/contributionFrameHooks.js +42 -0
  85. package/dist/canvas/SceneCanvas/contributionFrameHooks.js.map +1 -0
  86. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +549 -0
  87. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -0
  88. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +26 -0
  89. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -0
  90. package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js +69 -0
  91. package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -0
  92. package/dist/canvas/SceneCanvas/features.js +97 -0
  93. package/dist/canvas/SceneCanvas/features.js.map +1 -0
  94. package/dist/canvas/SceneCanvas/poseGeometry.js +46 -0
  95. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -0
  96. package/dist/canvas/SceneCanvas/useActionsPropResolver.js +48 -0
  97. package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -0
  98. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +70 -0
  99. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -0
  100. package/dist/canvas/SceneCanvas/useContributionRoles.js +75 -0
  101. package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -0
  102. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +172 -0
  103. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -0
  104. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +69 -0
  105. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -0
  106. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +127 -0
  107. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -0
  108. package/dist/canvas/SceneCanvas/useViewportActions.js +30 -0
  109. package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -0
  110. package/dist/canvas/SceneCanvas.js +992 -0
  111. package/dist/canvas/SceneCanvas.js.map +1 -0
  112. package/dist/canvas/SceneViewCanvas.js +54 -0
  113. package/dist/canvas/SceneViewCanvas.js.map +1 -0
  114. package/dist/canvas/accentColor.js +9 -0
  115. package/dist/canvas/accentColor.js.map +1 -0
  116. package/dist/canvas/affordanceAt.js +63 -0
  117. package/dist/canvas/affordanceAt.js.map +1 -0
  118. package/dist/canvas/buildSceneTree.js +65 -0
  119. package/dist/canvas/buildSceneTree.js.map +1 -0
  120. package/dist/canvas/canvasRenderer.js +89 -0
  121. package/dist/canvas/canvasRenderer.js.map +1 -0
  122. package/dist/canvas/colorOverrides.js +16 -0
  123. package/dist/canvas/colorOverrides.js.map +1 -0
  124. package/dist/canvas/defaultDrawOne.js +43 -0
  125. package/dist/canvas/defaultDrawOne.js.map +1 -0
  126. package/dist/canvas/deps/areaSelect.js +19 -0
  127. package/dist/canvas/deps/areaSelect.js.map +1 -0
  128. package/dist/canvas/deps/debug.js +9 -0
  129. package/dist/canvas/deps/debug.js.map +1 -0
  130. package/dist/canvas/deps/dispatcher.js +11 -0
  131. package/dist/canvas/deps/dispatcher.js.map +1 -0
  132. package/dist/canvas/deps/editAnchors.js +101 -0
  133. package/dist/canvas/deps/editAnchors.js.map +1 -0
  134. package/dist/canvas/deps/geometryProjection.js +11 -0
  135. package/dist/canvas/deps/geometryProjection.js.map +1 -0
  136. package/dist/canvas/deps/hitTestArea.js +51 -0
  137. package/dist/canvas/deps/hitTestArea.js.map +1 -0
  138. package/dist/canvas/deps/ingestion.js +31 -0
  139. package/dist/canvas/deps/ingestion.js.map +1 -0
  140. package/dist/canvas/deps/insert.js +116 -0
  141. package/dist/canvas/deps/insert.js.map +1 -0
  142. package/dist/canvas/deps/lassoSelect.js +20 -0
  143. package/dist/canvas/deps/lassoSelect.js.map +1 -0
  144. package/dist/canvas/deps/layout.js +34 -0
  145. package/dist/canvas/deps/layout.js.map +1 -0
  146. package/dist/canvas/deps/nodeAtPoint.js +19 -0
  147. package/dist/canvas/deps/nodeAtPoint.js.map +1 -0
  148. package/dist/canvas/deps/poseComposition.js +11 -0
  149. package/dist/canvas/deps/poseComposition.js.map +1 -0
  150. package/dist/canvas/deps/poseDescriptor.js +12 -0
  151. package/dist/canvas/deps/poseDescriptor.js.map +1 -0
  152. package/dist/canvas/deps/resizePolicy.js +35 -0
  153. package/dist/canvas/deps/resizePolicy.js.map +1 -0
  154. package/dist/canvas/deps/slice.js +99 -0
  155. package/dist/canvas/deps/slice.js.map +1 -0
  156. package/dist/canvas/deps/snap.js +11 -0
  157. package/dist/canvas/deps/snap.js.map +1 -0
  158. package/dist/canvas/deps/textEdit.js +21 -0
  159. package/dist/canvas/deps/textEdit.js.map +1 -0
  160. package/dist/canvas/deps/view.js +43 -0
  161. package/dist/canvas/deps/view.js.map +1 -0
  162. package/dist/canvas/derivedPath.js +47 -0
  163. package/dist/canvas/derivedPath.js.map +1 -0
  164. package/dist/canvas/drawEnvelope.js +22 -0
  165. package/dist/canvas/drawEnvelope.js.map +1 -0
  166. package/dist/canvas/getNodeAtPoint.js +18 -0
  167. package/dist/canvas/getNodeAtPoint.js.map +1 -0
  168. package/dist/canvas/hostAnchor.js +29 -0
  169. package/dist/canvas/hostAnchor.js.map +1 -0
  170. package/dist/canvas/hud.module.js +18 -0
  171. package/dist/canvas/hud.module.js.map +1 -0
  172. package/dist/canvas/insertPreviewExtent.js +103 -0
  173. package/dist/canvas/insertPreviewExtent.js.map +1 -0
  174. package/dist/canvas/kitRequirements.js +177 -0
  175. package/dist/canvas/kitRequirements.js.map +1 -0
  176. package/dist/canvas/layerOrder.js +66 -0
  177. package/dist/canvas/layerOrder.js.map +1 -0
  178. package/dist/canvas/layerSlots.js +14 -0
  179. package/dist/canvas/layerSlots.js.map +1 -0
  180. package/dist/canvas/minimapMath.js +80 -0
  181. package/dist/canvas/minimapMath.js.map +1 -0
  182. package/dist/canvas/mountedCanvases.js +20 -0
  183. package/dist/canvas/mountedCanvases.js.map +1 -0
  184. package/dist/canvas/overlayRoleStrokes.js +17 -0
  185. package/dist/canvas/overlayRoleStrokes.js.map +1 -0
  186. package/dist/canvas/paintCull.js +20 -0
  187. package/dist/canvas/paintCull.js.map +1 -0
  188. package/dist/canvas/pickWalk.js +158 -0
  189. package/dist/canvas/pickWalk.js.map +1 -0
  190. package/dist/canvas/planeClips.js +30 -0
  191. package/dist/canvas/planeClips.js.map +1 -0
  192. package/dist/canvas/poseRotation.js +35 -0
  193. package/dist/canvas/poseRotation.js.map +1 -0
  194. package/dist/canvas/rasterToPng.js +21 -0
  195. package/dist/canvas/rasterToPng.js.map +1 -0
  196. package/dist/canvas/renderDebugSnapshot.js +32 -0
  197. package/dist/canvas/renderDebugSnapshot.js.map +1 -0
  198. package/dist/canvas/renderNeeds.js +25 -0
  199. package/dist/canvas/renderNeeds.js.map +1 -0
  200. package/dist/canvas/renderSceneToPixels.js +143 -0
  201. package/dist/canvas/renderSceneToPixels.js.map +1 -0
  202. package/dist/canvas/sceneAdapter.js +270 -0
  203. package/dist/canvas/sceneAdapter.js.map +1 -0
  204. package/dist/canvas/sceneLayerPaint.js +37 -0
  205. package/dist/canvas/sceneLayerPaint.js.map +1 -0
  206. package/dist/canvas/sceneSlotWiring.js +20 -0
  207. package/dist/canvas/sceneSlotWiring.js.map +1 -0
  208. package/dist/canvas/sceneViewRender.js +72 -0
  209. package/dist/canvas/sceneViewRender.js.map +1 -0
  210. package/dist/canvas/slopsDebugLayer.js +61 -0
  211. package/dist/canvas/slopsDebugLayer.js.map +1 -0
  212. package/dist/canvas/surfaceContribution.js +15 -0
  213. package/dist/canvas/surfaceContribution.js.map +1 -0
  214. package/dist/canvas/toolPreview.js +39 -0
  215. package/dist/canvas/toolPreview.js.map +1 -0
  216. package/dist/canvas/useCanvasRenderer.js +11 -0
  217. package/dist/canvas/useCanvasRenderer.js.map +1 -0
  218. package/dist/canvas/useFrameLoop.js +60 -0
  219. package/dist/canvas/useFrameLoop.js.map +1 -0
  220. package/dist/canvas/useHostAnchor.js +71 -0
  221. package/dist/canvas/useHostAnchor.js.map +1 -0
  222. package/dist/canvas/useLateContentRedraw.js +21 -0
  223. package/dist/canvas/useLateContentRedraw.js.map +1 -0
  224. package/dist/canvas/useRedrawOn.js +21 -0
  225. package/dist/canvas/useRedrawOn.js.map +1 -0
  226. package/dist/canvas/useViewHelpers.js +120 -0
  227. package/dist/canvas/useViewHelpers.js.map +1 -0
  228. package/dist/canvas/viewInputs.js +17 -0
  229. package/dist/canvas/viewInputs.js.map +1 -0
  230. package/dist/canvas/viewRegistry.js +61 -0
  231. package/dist/canvas/viewRegistry.js.map +1 -0
  232. package/dist/canvas/wrapNodeOutput.js +14 -0
  233. package/dist/canvas/wrapNodeOutput.js.map +1 -0
  234. package/dist/clipboard.d.ts +10 -5
  235. package/dist/clipboard.js +3 -5
  236. package/dist/clone.d.ts +3 -3
  237. package/dist/clone.js +2 -5
  238. package/dist/core/adapters/arrayAdapter.js +85 -0
  239. package/dist/core/adapters/arrayAdapter.js.map +1 -0
  240. package/dist/core/adapters/useArrayAdapter.js +13 -0
  241. package/dist/core/adapters/useArrayAdapter.js.map +1 -0
  242. package/dist/core/applyOps.js +12 -0
  243. package/dist/core/applyOps.js.map +1 -0
  244. package/dist/core/device/index.js +4 -0
  245. package/dist/core/device/targets.js +17 -0
  246. package/dist/core/device/targets.js.map +1 -0
  247. package/dist/core/device/useDeviceProfile.js +75 -0
  248. package/dist/core/device/useDeviceProfile.js.map +1 -0
  249. package/dist/core/fillInPoseFrame.js +102 -0
  250. package/dist/core/fillInPoseFrame.js.map +1 -0
  251. package/dist/core/geometry/poseDescriptor.js +98 -0
  252. package/dist/core/geometry/poseDescriptor.js.map +1 -0
  253. package/dist/core/geometry/poseRotation.js +58 -0
  254. package/dist/core/geometry/poseRotation.js.map +1 -0
  255. package/dist/core/geometry/regionHit.js +102 -0
  256. package/dist/core/geometry/regionHit.js.map +1 -0
  257. package/dist/core/geometry/unionBounds.js +60 -0
  258. package/dist/core/geometry/unionBounds.js.map +1 -0
  259. package/dist/core/gradient.js +136 -0
  260. package/dist/core/gradient.js.map +1 -0
  261. package/dist/core/isPlainObject.js +11 -0
  262. package/dist/core/isPlainObject.js.map +1 -0
  263. package/dist/core/layers/render.js +150 -0
  264. package/dist/core/layers/render.js.map +1 -0
  265. package/dist/core/markerInset.js +24 -0
  266. package/dist/core/markerInset.js.map +1 -0
  267. package/dist/core/mixed.js +6 -0
  268. package/dist/core/mixed.js.map +1 -0
  269. package/dist/core/ops/arrange.js +31 -0
  270. package/dist/core/ops/arrange.js.map +1 -0
  271. package/dist/core/ops/create.js +32 -0
  272. package/dist/core/ops/create.js.map +1 -0
  273. package/dist/core/ops/createHistory.js +20 -0
  274. package/dist/core/ops/createHistory.js.map +1 -0
  275. package/dist/core/ops/delete.js +89 -0
  276. package/dist/core/ops/delete.js.map +1 -0
  277. package/dist/core/ops/registry.js +17 -0
  278. package/dist/core/ops/registry.js.map +1 -0
  279. package/dist/core/ops/reorder/algorithms.js +55 -0
  280. package/dist/core/ops/reorder/algorithms.js.map +1 -0
  281. package/dist/core/ops/reorder/index.js +140 -0
  282. package/dist/core/ops/reorder/index.js.map +1 -0
  283. package/dist/core/ops/reparent.js +52 -0
  284. package/dist/core/ops/reparent.js.map +1 -0
  285. package/dist/core/ops/select.js +34 -0
  286. package/dist/core/ops/select.js.map +1 -0
  287. package/dist/core/ops/setData.js +34 -0
  288. package/dist/core/ops/setData.js.map +1 -0
  289. package/dist/core/ops/setLayer.js +34 -0
  290. package/dist/core/ops/setLayer.js.map +1 -0
  291. package/dist/core/ops/setLayout.js +31 -0
  292. package/dist/core/ops/setLayout.js.map +1 -0
  293. package/dist/core/ops/setPath.js +57 -0
  294. package/dist/core/ops/setPath.js.map +1 -0
  295. package/dist/core/ops/setText.js +34 -0
  296. package/dist/core/ops/setText.js.map +1 -0
  297. package/dist/core/ops/slot.js +37 -0
  298. package/dist/core/ops/slot.js.map +1 -0
  299. package/dist/core/ops/transform.js +42 -0
  300. package/dist/core/ops/transform.js.map +1 -0
  301. package/dist/core/paintKinds.js +156 -0
  302. package/dist/core/paintKinds.js.map +1 -0
  303. package/dist/core/scene/NodeProperties.js +20 -0
  304. package/dist/core/scene/NodeProperties.js.map +1 -0
  305. package/dist/core/scene/NodeRouting.js +24 -0
  306. package/dist/core/scene/NodeRouting.js.map +1 -0
  307. package/dist/core/scene/arrivals.js +12 -0
  308. package/dist/core/scene/arrivals.js.map +1 -0
  309. package/dist/core/scene/composeFrame.js +29 -0
  310. package/dist/core/scene/composeFrame.js.map +1 -0
  311. package/dist/core/scene/depMemo.js +18 -0
  312. package/dist/core/scene/depMemo.js.map +1 -0
  313. package/dist/core/scene/dependents.js +66 -0
  314. package/dist/core/scene/dependents.js.map +1 -0
  315. package/dist/core/scene/derivedPath.js +31 -0
  316. package/dist/core/scene/derivedPath.js.map +1 -0
  317. package/dist/core/scene/effectivePose.js +78 -0
  318. package/dist/core/scene/effectivePose.js.map +1 -0
  319. package/dist/core/scene/kitRegistry.js +33 -0
  320. package/dist/core/scene/kitRegistry.js.map +1 -0
  321. package/dist/core/scene/layoutPass.js +96 -0
  322. package/dist/core/scene/layoutPass.js.map +1 -0
  323. package/dist/core/scene/nodeFnFields.js +83 -0
  324. package/dist/core/scene/nodeFnFields.js.map +1 -0
  325. package/dist/core/scene/nodeMemo.js +28 -0
  326. package/dist/core/scene/nodeMemo.js.map +1 -0
  327. package/dist/core/scene/poseFeed.js +87 -0
  328. package/dist/core/scene/poseFeed.js.map +1 -0
  329. package/dist/core/scene/poseOverrides.js +52 -0
  330. package/dist/core/scene/poseOverrides.js.map +1 -0
  331. package/dist/core/scene/poseSnapshot.js +54 -0
  332. package/dist/core/scene/poseSnapshot.js.map +1 -0
  333. package/dist/core/scene/scene.js +1271 -0
  334. package/dist/core/scene/scene.js.map +1 -0
  335. package/dist/core/scene/types.js +6 -0
  336. package/dist/core/scene/types.js.map +1 -0
  337. package/dist/core/scene/useScene.js +32 -0
  338. package/dist/core/scene/useScene.js.map +1 -0
  339. package/dist/core/selection/chromeState.js +31 -0
  340. package/dist/core/selection/chromeState.js.map +1 -0
  341. package/dist/core/selection/selectionTarget.js +6 -0
  342. package/dist/core/selection/selectionTarget.js.map +1 -0
  343. package/dist/core/selection/useSelection.js +71 -0
  344. package/dist/core/selection/useSelection.js.map +1 -0
  345. package/dist/core/shapeKinds.js +54 -0
  346. package/dist/core/shapeKinds.js.map +1 -0
  347. package/dist/core/strokeMarkerShapes.js +139 -0
  348. package/dist/core/strokeMarkerShapes.js.map +1 -0
  349. package/dist/core/strokeMarkers.js +28 -0
  350. package/dist/core/strokeMarkers.js.map +1 -0
  351. package/dist/core/stylus/stylus.js +39 -0
  352. package/dist/core/stylus/stylus.js.map +1 -0
  353. package/dist/core/stylus/usePointerStylus.js +51 -0
  354. package/dist/core/stylus/usePointerStylus.js.map +1 -0
  355. package/dist/core/usePaintKinds.js +17 -0
  356. package/dist/core/usePaintKinds.js.map +1 -0
  357. package/dist/core/viewport/clampView.js +24 -0
  358. package/dist/core/viewport/clampView.js.map +1 -0
  359. package/dist/core/viewport/clientToWorld.js +8 -0
  360. package/dist/core/viewport/clientToWorld.js.map +1 -0
  361. package/dist/core/viewport/createVelocityTracker.js +39 -0
  362. package/dist/core/viewport/createVelocityTracker.js.map +1 -0
  363. package/dist/core/viewport/fitToBounds.js +18 -0
  364. package/dist/core/viewport/fitToBounds.js.map +1 -0
  365. package/dist/core/viewport/fitViewToBounds.js +36 -0
  366. package/dist/core/viewport/fitViewToBounds.js.map +1 -0
  367. package/dist/core/viewport/interpolateView.js +34 -0
  368. package/dist/core/viewport/interpolateView.js.map +1 -0
  369. package/dist/core/viewport/meanScale.js +8 -0
  370. package/dist/core/viewport/meanScale.js.map +1 -0
  371. package/dist/core/viewport/parallax.js +111 -0
  372. package/dist/core/viewport/parallax.js.map +1 -0
  373. package/dist/core/viewport/pxExtent.js +42 -0
  374. package/dist/core/viewport/pxExtent.js.map +1 -0
  375. package/dist/core/viewport/sceneNodeClientRect.js +18 -0
  376. package/dist/core/viewport/sceneNodeClientRect.js.map +1 -0
  377. package/dist/core/viewport/screenSlop.js +27 -0
  378. package/dist/core/viewport/screenSlop.js.map +1 -0
  379. package/dist/core/viewport/useAutoCenter.js +32 -0
  380. package/dist/core/viewport/useAutoCenter.js.map +1 -0
  381. package/dist/core/viewport/useCanvasSize.js +29 -0
  382. package/dist/core/viewport/useCanvasSize.js.map +1 -0
  383. package/dist/core/viewport/useDecayLoop.js +63 -0
  384. package/dist/core/viewport/useDecayLoop.js.map +1 -0
  385. package/dist/core/viewport/useVelocityTracker.js +10 -0
  386. package/dist/core/viewport/useVelocityTracker.js.map +1 -0
  387. package/dist/core/viewport/useViewAnimation.js +63 -0
  388. package/dist/core/viewport/useViewAnimation.js.map +1 -0
  389. package/dist/core/viewport/view.js +37 -0
  390. package/dist/core/viewport/view.js.map +1 -0
  391. package/dist/core/viewport/viewTransform.js +11 -0
  392. package/dist/core/viewport/viewTransform.js.map +1 -0
  393. package/dist/core/viewport/viewportWorldRect.js +13 -0
  394. package/dist/core/viewport/viewportWorldRect.js.map +1 -0
  395. package/dist/core/viewport/wheelHandler.js +30 -0
  396. package/dist/core/viewport/wheelHandler.js.map +1 -0
  397. package/dist/core/viewport/zoomAt.js +22 -0
  398. package/dist/core/viewport/zoomAt.js.map +1 -0
  399. package/dist/core/viewport/zoomBounds.js +20 -0
  400. package/dist/core/viewport/zoomBounds.js.map +1 -0
  401. package/dist/{pointSnapToGrid-7mCcm6qG.d.ts → cornerHandles-CDcZOV8h.d.ts} +54 -71
  402. package/dist/debug/createDebugOverlayLayer.js +358 -0
  403. package/dist/debug/createDebugOverlayLayer.js.map +1 -0
  404. package/dist/debug/createDebugSink.js +83 -0
  405. package/dist/debug/createDebugSink.js.map +1 -0
  406. package/dist/debug/defaultTheme.js +31 -0
  407. package/dist/debug/defaultTheme.js.map +1 -0
  408. package/dist/debug/flag.js +41 -0
  409. package/dist/debug/flag.js.map +1 -0
  410. package/dist/debug/frameStats.js +16 -0
  411. package/dist/debug/frameStats.js.map +1 -0
  412. package/dist/debug/parseDebugFlags.js +32 -0
  413. package/dist/debug/parseDebugFlags.js.map +1 -0
  414. package/dist/features/chrome-caps/buildChromeCtx.js +16 -0
  415. package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -0
  416. package/dist/features/chrome-caps/conditions.js +36 -0
  417. package/dist/features/chrome-caps/conditions.js.map +1 -0
  418. package/dist/features/chrome-caps/defaults.js +26 -0
  419. package/dist/features/chrome-caps/defaults.js.map +1 -0
  420. package/dist/features/chrome-caps/index.js +7 -0
  421. package/dist/features/chrome-caps/resolve.js +23 -0
  422. package/dist/features/chrome-caps/resolve.js.map +1 -0
  423. package/dist/features/chrome-caps/useHoverTracking.js +27 -0
  424. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -0
  425. package/dist/features/cursor/paintedCursorLayer.js +60 -0
  426. package/dist/features/cursor/paintedCursorLayer.js.map +1 -0
  427. package/dist/features/focus/gateLayer.js +14 -0
  428. package/dist/features/focus/gateLayer.js.map +1 -0
  429. package/dist/features/focus/useCanvasFocus.js +29 -0
  430. package/dist/features/focus/useCanvasFocus.js.map +1 -0
  431. package/dist/features/groups/children.js +23 -0
  432. package/dist/features/groups/children.js.map +1 -0
  433. package/dist/features/groups/composePose.js +67 -0
  434. package/dist/features/groups/composePose.js.map +1 -0
  435. package/dist/features/groups/nestedHit.js +40 -0
  436. package/dist/features/groups/nestedHit.js.map +1 -0
  437. package/dist/features/groups/unionOfChildren.js +15 -0
  438. package/dist/features/groups/unionOfChildren.js.map +1 -0
  439. package/dist/features/images/imageCache.js +94 -0
  440. package/dist/features/images/imageCache.js.map +1 -0
  441. package/dist/features/ingestion/contentHandlers.js +37 -0
  442. package/dist/features/ingestion/contentHandlers.js.map +1 -0
  443. package/dist/features/ingestion/imageHandler.js +45 -0
  444. package/dist/features/ingestion/imageHandler.js.map +1 -0
  445. package/dist/features/ingestion/index.js +8 -0
  446. package/dist/features/ingestion/openFilePicker.js +15 -0
  447. package/dist/features/ingestion/openFilePicker.js.map +1 -0
  448. package/dist/features/ingestion/registerKitHandlers.js +26 -0
  449. package/dist/features/ingestion/registerKitHandlers.js.map +1 -0
  450. package/dist/features/ingestion/svgHandler.js +58 -0
  451. package/dist/features/ingestion/svgHandler.js.map +1 -0
  452. package/dist/features/ingestion/weaselJsonHandler.js +39 -0
  453. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -0
  454. package/dist/features/longPress/longPressFeedback.js +96 -0
  455. package/dist/features/longPress/longPressFeedback.js.map +1 -0
  456. package/dist/features/meshPaint/bake.js +79 -0
  457. package/dist/features/meshPaint/bake.js.map +1 -0
  458. package/dist/features/meshPaint/bakeCache.js +59 -0
  459. package/dist/features/meshPaint/bakeCache.js.map +1 -0
  460. package/dist/features/meshPaint/handles.js +86 -0
  461. package/dist/features/meshPaint/handles.js.map +1 -0
  462. package/dist/features/meshPaint/lazyKind.js +1298 -0
  463. package/dist/features/meshPaint/lazyKind.js.map +1 -0
  464. package/dist/features/meshPaint/meshPaint.js +236 -0
  465. package/dist/features/meshPaint/meshPaint.js.map +1 -0
  466. package/dist/features/meshPaint/meshShader.js +6 -0
  467. package/dist/features/meshPaint/meshShader.js.map +1 -0
  468. package/dist/features/meshPaint/register.js +7 -0
  469. package/dist/features/meshPaint/register.js.map +1 -0
  470. package/dist/features/meshPaint/surface.js +110 -0
  471. package/dist/features/meshPaint/surface.js.map +1 -0
  472. package/dist/features/minimap/actions.js +53 -0
  473. package/dist/features/minimap/actions.js.map +1 -0
  474. package/dist/features/minimap/createMinimapContribution.js +96 -0
  475. package/dist/features/minimap/createMinimapContribution.js.map +1 -0
  476. package/dist/features/minimap/layers.js +103 -0
  477. package/dist/features/minimap/layers.js.map +1 -0
  478. package/dist/features/modes/modeLayers.js +113 -0
  479. package/dist/features/modes/modeLayers.js.map +1 -0
  480. package/dist/features/overlays/useNodeOverlayFrame.js +103 -0
  481. package/dist/features/overlays/useNodeOverlayFrame.js.map +1 -0
  482. package/dist/features/parallax/createParallaxLayer.js +26 -0
  483. package/dist/features/parallax/createParallaxLayer.js.map +1 -0
  484. package/dist/features/parallax/createParallaxPlane.js +26 -0
  485. package/dist/features/parallax/createParallaxPlane.js.map +1 -0
  486. package/dist/features/paths/anchorEdits.js +156 -0
  487. package/dist/features/paths/anchorEdits.js.map +1 -0
  488. package/dist/features/paths/anchors.js +154 -0
  489. package/dist/features/paths/anchors.js.map +1 -0
  490. package/dist/features/paths/booleans.js +2 -0
  491. package/dist/features/paths/index.js +15 -0
  492. package/dist/features/paths/markerCommands.js +116 -0
  493. package/dist/features/paths/markerCommands.js.map +1 -0
  494. package/dist/features/paths/markerSites.js +59 -0
  495. package/dist/features/paths/markerSites.js.map +1 -0
  496. package/dist/features/paths/markers.js +95 -0
  497. package/dist/features/paths/markers.js.map +1 -0
  498. package/dist/features/paths/nearestAnchor.js +36 -0
  499. package/dist/features/paths/nearestAnchor.js.map +1 -0
  500. package/dist/features/paths/originProjection.js +16 -0
  501. package/dist/features/paths/originProjection.js.map +1 -0
  502. package/dist/features/paths/pathEditingOverlayLayer.js +137 -0
  503. package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -0
  504. package/dist/features/paths/pathInWorld.js +41 -0
  505. package/dist/features/paths/pathInWorld.js.map +1 -0
  506. package/dist/features/paths/pathLayer.js +44 -0
  507. package/dist/features/paths/pathLayer.js.map +1 -0
  508. package/dist/features/paths/penPreviewLayer.js +220 -0
  509. package/dist/features/paths/penPreviewLayer.js.map +1 -0
  510. package/dist/features/paths/poseDescriptor.js +44 -0
  511. package/dist/features/paths/poseDescriptor.js.map +1 -0
  512. package/dist/features/paths/tessellate/stroke.js +230 -0
  513. package/dist/features/paths/tessellate/stroke.js.map +1 -0
  514. package/dist/features/patterns/index.js +23 -0
  515. package/dist/features/patterns/index.js.map +1 -0
  516. package/dist/features/patterns/patterns-builtin.js +38 -0
  517. package/dist/features/patterns/patterns-builtin.js.map +1 -0
  518. package/dist/features/patterns/resolveSpec.js +57 -0
  519. package/dist/features/patterns/resolveSpec.js.map +1 -0
  520. package/dist/features/patterns/tileGeometry.js +158 -0
  521. package/dist/features/patterns/tileGeometry.js.map +1 -0
  522. package/dist/features/pointer/PointerContext.js +45 -0
  523. package/dist/features/pointer/PointerContext.js.map +1 -0
  524. package/dist/features/poseRun/usePoseRun.js +70 -0
  525. package/dist/features/poseRun/usePoseRun.js.map +1 -0
  526. package/dist/features/selection/SelectionContext.js +46 -0
  527. package/dist/features/selection/SelectionContext.js.map +1 -0
  528. package/dist/features/selection/overlay.js +442 -0
  529. package/dist/features/selection/overlay.js.map +1 -0
  530. package/dist/features/simulation/createSimulation.js +61 -0
  531. package/dist/features/simulation/createSimulation.js.map +1 -0
  532. package/dist/features/simulation/types.js +6 -0
  533. package/dist/features/simulation/types.js.map +1 -0
  534. package/dist/features/simulation/useSimulation.js +74 -0
  535. package/dist/features/simulation/useSimulation.js.map +1 -0
  536. package/dist/features/text/domRuns.js +258 -0
  537. package/dist/features/text/domRuns.js.map +1 -0
  538. package/dist/features/text/fitTextPose.js +38 -0
  539. package/dist/features/text/fitTextPose.js.map +1 -0
  540. package/dist/features/text/hitTest.js +45 -0
  541. package/dist/features/text/hitTest.js.map +1 -0
  542. package/dist/features/text/renderLabel.js +14 -0
  543. package/dist/features/text/renderLabel.js.map +1 -0
  544. package/dist/features/text/runs/effectiveRangeStyle.js +66 -0
  545. package/dist/features/text/runs/effectiveRangeStyle.js.map +1 -0
  546. package/dist/features/text/runs/flagRange.js +53 -0
  547. package/dist/features/text/runs/flagRange.js.map +1 -0
  548. package/dist/features/text/runs/rangeStyle.js +135 -0
  549. package/dist/features/text/runs/rangeStyle.js.map +1 -0
  550. package/dist/features/text/textCommand.js +59 -0
  551. package/dist/features/text/textCommand.js.map +1 -0
  552. package/dist/features/text/textLayer.js +35 -0
  553. package/dist/features/text/textLayer.js.map +1 -0
  554. package/dist/features/text/textToPath.js +181 -0
  555. package/dist/features/text/textToPath.js.map +1 -0
  556. package/dist/features/text/useSceneTextEdit.js +138 -0
  557. package/dist/features/text/useSceneTextEdit.js.map +1 -0
  558. package/dist/features/text/useTextEdit.js +465 -0
  559. package/dist/features/text/useTextEdit.js.map +1 -0
  560. package/dist/features/tiling/createTiledLayer.js +63 -0
  561. package/dist/features/tiling/createTiledLayer.js.map +1 -0
  562. package/dist/features/tiling/tiledProject.js +14 -0
  563. package/dist/features/tiling/tiledProject.js.map +1 -0
  564. package/dist/features/viewports/viewResolver.js +59 -0
  565. package/dist/features/viewports/viewResolver.js.map +1 -0
  566. package/dist/features/viewports/viewportLayer.js +58 -0
  567. package/dist/features/viewports/viewportLayer.js.map +1 -0
  568. package/dist/icons/ArrowIcon.js +23 -0
  569. package/dist/icons/ArrowIcon.js.map +1 -0
  570. package/dist/icons/EllipseIcon.js +21 -0
  571. package/dist/icons/EllipseIcon.js.map +1 -0
  572. package/dist/icons/EyedropperIcon.js +49 -0
  573. package/dist/icons/EyedropperIcon.js.map +1 -0
  574. package/dist/icons/HandIcon.js +59 -0
  575. package/dist/icons/HandIcon.js.map +1 -0
  576. package/dist/icons/ImageIcon.js +34 -0
  577. package/dist/icons/ImageIcon.js.map +1 -0
  578. package/dist/icons/LassoIcon.js +22 -0
  579. package/dist/icons/LassoIcon.js.map +1 -0
  580. package/dist/icons/LineIcon.js +22 -0
  581. package/dist/icons/LineIcon.js.map +1 -0
  582. package/dist/icons/PenIcon.js +36 -0
  583. package/dist/icons/PenIcon.js.map +1 -0
  584. package/dist/icons/PencilIcon.js +25 -0
  585. package/dist/icons/PencilIcon.js.map +1 -0
  586. package/dist/icons/PolygonIcon.js +19 -0
  587. package/dist/icons/PolygonIcon.js.map +1 -0
  588. package/dist/icons/RectIcon.js +37 -0
  589. package/dist/icons/RectIcon.js.map +1 -0
  590. package/dist/icons/SelectIcon.js +20 -0
  591. package/dist/icons/SelectIcon.js.map +1 -0
  592. package/dist/icons/StarIcon.js +19 -0
  593. package/dist/icons/StarIcon.js.map +1 -0
  594. package/dist/icons/TextIcon.js +19 -0
  595. package/dist/icons/TextIcon.js.map +1 -0
  596. package/dist/icons/UnknownIcon.js +33 -0
  597. package/dist/icons/UnknownIcon.js.map +1 -0
  598. package/dist/icons/_base.js +12 -0
  599. package/dist/icons/_base.js.map +1 -0
  600. package/dist/index.css +2 -86
  601. package/dist/index.d.ts +2349 -2609
  602. package/dist/index.js +312 -13
  603. package/dist/input/keyState.js +76 -0
  604. package/dist/input/keyState.js.map +1 -0
  605. package/dist/input/useKeyState.js +22 -0
  606. package/dist/input/useKeyState.js.map +1 -0
  607. package/dist/interactions/actions/actionShortcuts.js +32 -0
  608. package/dist/interactions/actions/actionShortcuts.js.map +1 -0
  609. package/dist/interactions/actions/align/align.js +81 -0
  610. package/dist/interactions/actions/align/align.js.map +1 -0
  611. package/dist/interactions/actions/booleans/booleans.js +120 -0
  612. package/dist/interactions/actions/booleans/booleans.js.map +1 -0
  613. package/dist/interactions/actions/booleans/useBooleans.js +20 -0
  614. package/dist/interactions/actions/booleans/useBooleans.js.map +1 -0
  615. package/dist/interactions/actions/booleans/useBooleansAdapter.js +9 -0
  616. package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -0
  617. package/dist/interactions/actions/clipboard/clipboardOps.js +94 -0
  618. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -0
  619. package/dist/interactions/actions/clipboard/materializePaste.js +25 -0
  620. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -0
  621. package/dist/interactions/actions/clipboard/wireFormat.js +43 -0
  622. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -0
  623. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +26 -0
  624. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -0
  625. package/dist/interactions/actions/defaultCommitAdapter.js +42 -0
  626. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -0
  627. package/dist/interactions/actions/defaults/align.js +71 -0
  628. package/dist/interactions/actions/defaults/align.js.map +1 -0
  629. package/dist/interactions/actions/defaults/anchorEditing.js +235 -0
  630. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -0
  631. package/dist/interactions/actions/defaults/areaSelect.js +75 -0
  632. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -0
  633. package/dist/interactions/actions/defaults/booleans.js +52 -0
  634. package/dist/interactions/actions/defaults/booleans.js.map +1 -0
  635. package/dist/interactions/actions/defaults/cancelGesture.js +24 -0
  636. package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -0
  637. package/dist/interactions/actions/defaults/clearSelection.js +19 -0
  638. package/dist/interactions/actions/defaults/clearSelection.js.map +1 -0
  639. package/dist/interactions/actions/defaults/clipboard.js +78 -0
  640. package/dist/interactions/actions/defaults/clipboard.js.map +1 -0
  641. package/dist/interactions/actions/defaults/clone.js +96 -0
  642. package/dist/interactions/actions/defaults/clone.js.map +1 -0
  643. package/dist/interactions/actions/defaults/createOutlines.js +47 -0
  644. package/dist/interactions/actions/defaults/createOutlines.js.map +1 -0
  645. package/dist/interactions/actions/defaults/createPaintAction.js +85 -0
  646. package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -0
  647. package/dist/interactions/actions/defaults/delete.js +61 -0
  648. package/dist/interactions/actions/defaults/delete.js.map +1 -0
  649. package/dist/interactions/actions/defaults/distribute.js +66 -0
  650. package/dist/interactions/actions/defaults/distribute.js.map +1 -0
  651. package/dist/interactions/actions/defaults/duplicate.js +83 -0
  652. package/dist/interactions/actions/defaults/duplicate.js.map +1 -0
  653. package/dist/interactions/actions/defaults/editAnchors.js +100 -0
  654. package/dist/interactions/actions/defaults/editAnchors.js.map +1 -0
  655. package/dist/interactions/actions/defaults/enterPathEdit.js +29 -0
  656. package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -0
  657. package/dist/interactions/actions/defaults/enterTextEdit.js +20 -0
  658. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -0
  659. package/dist/interactions/actions/defaults/escape.js +26 -0
  660. package/dist/interactions/actions/defaults/escape.js.map +1 -0
  661. package/dist/interactions/actions/defaults/exitPathEdit.js +22 -0
  662. package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -0
  663. package/dist/interactions/actions/defaults/flip.js +119 -0
  664. package/dist/interactions/actions/defaults/flip.js.map +1 -0
  665. package/dist/interactions/actions/defaults/freshNodeId.js +10 -0
  666. package/dist/interactions/actions/defaults/freshNodeId.js.map +1 -0
  667. package/dist/interactions/actions/defaults/group.js +131 -0
  668. package/dist/interactions/actions/defaults/group.js.map +1 -0
  669. package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js +40 -0
  670. package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js.map +1 -0
  671. package/dist/interactions/actions/defaults/icons/actionGlyphs.js +10 -0
  672. package/dist/interactions/actions/defaults/icons/actionGlyphs.js.map +1 -0
  673. package/dist/interactions/actions/defaults/icons/alignIcons.js +173 -0
  674. package/dist/interactions/actions/defaults/icons/alignIcons.js.map +1 -0
  675. package/dist/interactions/actions/defaults/icons/booleanIcons.js +171 -0
  676. package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -0
  677. package/dist/interactions/actions/defaults/icons/distributeIcons.js +63 -0
  678. package/dist/interactions/actions/defaults/icons/distributeIcons.js.map +1 -0
  679. package/dist/interactions/actions/defaults/icons/editIcons.js +280 -0
  680. package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -0
  681. package/dist/interactions/actions/defaults/icons/outlineIcons.js +53 -0
  682. package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -0
  683. package/dist/interactions/actions/defaults/ingest.js +58 -0
  684. package/dist/interactions/actions/defaults/ingest.js.map +1 -0
  685. package/dist/interactions/actions/defaults/insert.js +288 -0
  686. package/dist/interactions/actions/defaults/insert.js.map +1 -0
  687. package/dist/interactions/actions/defaults/insertPathAnchor.js +50 -0
  688. package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -0
  689. package/dist/interactions/actions/defaults/lassoSelect.js +156 -0
  690. package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -0
  691. package/dist/interactions/actions/defaults/move.js +656 -0
  692. package/dist/interactions/actions/defaults/move.js.map +1 -0
  693. package/dist/interactions/actions/defaults/nudge.js +110 -0
  694. package/dist/interactions/actions/defaults/nudge.js.map +1 -0
  695. package/dist/interactions/actions/defaults/pinchZoom.js +63 -0
  696. package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -0
  697. package/dist/interactions/actions/defaults/reorder.js +143 -0
  698. package/dist/interactions/actions/defaults/reorder.js.map +1 -0
  699. package/dist/interactions/actions/defaults/requiresSelection.js +10 -0
  700. package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -0
  701. package/dist/interactions/actions/defaults/resize.js +332 -0
  702. package/dist/interactions/actions/defaults/resize.js.map +1 -0
  703. package/dist/interactions/actions/defaults/rotate.js +181 -0
  704. package/dist/interactions/actions/defaults/rotate.js.map +1 -0
  705. package/dist/interactions/actions/defaults/selectAll.js +27 -0
  706. package/dist/interactions/actions/defaults/selectAll.js.map +1 -0
  707. package/dist/interactions/actions/defaults/setFill.js +27 -0
  708. package/dist/interactions/actions/defaults/setFill.js.map +1 -0
  709. package/dist/interactions/actions/defaults/setFillOpacity.js +15 -0
  710. package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -0
  711. package/dist/interactions/actions/defaults/setStroke.js +36 -0
  712. package/dist/interactions/actions/defaults/setStroke.js.map +1 -0
  713. package/dist/interactions/actions/defaults/setStrokeOpacity.js +21 -0
  714. package/dist/interactions/actions/defaults/setStrokeOpacity.js.map +1 -0
  715. package/dist/interactions/actions/defaults/slice.js +39 -0
  716. package/dist/interactions/actions/defaults/slice.js.map +1 -0
  717. package/dist/interactions/actions/defaults/sliceOps.js +60 -0
  718. package/dist/interactions/actions/defaults/sliceOps.js.map +1 -0
  719. package/dist/interactions/actions/defaults/toolActivate.js +35 -0
  720. package/dist/interactions/actions/defaults/toolActivate.js.map +1 -0
  721. package/dist/interactions/actions/defaults/toolResetToDefault.js +26 -0
  722. package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -0
  723. package/dist/interactions/actions/defaults/undoRedo.js +51 -0
  724. package/dist/interactions/actions/defaults/undoRedo.js.map +1 -0
  725. package/dist/interactions/actions/defaults/viewportDragPan.js +88 -0
  726. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -0
  727. package/dist/interactions/actions/defaults/viewportWheelPan.js +57 -0
  728. package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -0
  729. package/dist/interactions/actions/defaults/viewportZoom.js +143 -0
  730. package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -0
  731. package/dist/interactions/actions/distribute/distribute.js +42 -0
  732. package/dist/interactions/actions/distribute/distribute.js.map +1 -0
  733. package/dist/interactions/actions/distribute/plan.js +29 -0
  734. package/dist/interactions/actions/distribute/plan.js.map +1 -0
  735. package/dist/interactions/actions/edit-anchors/geometry.js +61 -0
  736. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -0
  737. package/dist/interactions/actions/edit-anchors/handles.js +43 -0
  738. package/dist/interactions/actions/edit-anchors/handles.js.map +1 -0
  739. package/dist/interactions/actions/flip/helpers.js +35 -0
  740. package/dist/interactions/actions/flip/helpers.js.map +1 -0
  741. package/dist/interactions/actions/geometryProjection.js +18 -0
  742. package/dist/interactions/actions/geometryProjection.js.map +1 -0
  743. package/dist/interactions/actions/gestureLifecycle.js +44 -0
  744. package/dist/interactions/actions/gestureLifecycle.js.map +1 -0
  745. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +39 -0
  746. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -0
  747. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +36 -0
  748. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
  749. package/dist/interactions/actions/move/behaviors/snapToContainer.js +67 -0
  750. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -0
  751. package/dist/interactions/actions/move/gestureAdapter.js +37 -0
  752. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -0
  753. package/dist/interactions/actions/outlines/createOutlines.js +84 -0
  754. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -0
  755. package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js +9 -0
  756. package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js.map +1 -0
  757. package/dist/interactions/actions/planeInput.js +168 -0
  758. package/dist/interactions/actions/planeInput.js.map +1 -0
  759. package/dist/interactions/actions/poseDescriptorDep.js +9 -0
  760. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -0
  761. package/dist/interactions/actions/poseFrame.js +38 -0
  762. package/dist/interactions/actions/poseFrame.js.map +1 -0
  763. package/dist/interactions/actions/previewOverrides.js +25 -0
  764. package/dist/interactions/actions/previewOverrides.js.map +1 -0
  765. package/dist/interactions/actions/resize/autoPoseDescriptor.js +32 -0
  766. package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +1 -0
  767. package/dist/interactions/actions/resize/behaviors/clampMinSize.js +18 -0
  768. package/dist/interactions/actions/resize/behaviors/clampMinSize.js.map +1 -0
  769. package/dist/interactions/actions/resize/behaviors/index.js +8 -0
  770. package/dist/interactions/actions/resize/behaviors/index.js.map +1 -0
  771. package/dist/interactions/actions/resize/behaviors/lockAspect.js +24 -0
  772. package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -0
  773. package/dist/interactions/actions/resize/cornerHandles.js +72 -0
  774. package/dist/interactions/actions/resize/cornerHandles.js.map +1 -0
  775. package/dist/interactions/actions/resolveOverlays.js +60 -0
  776. package/dist/interactions/actions/resolveOverlays.js.map +1 -0
  777. package/dist/interactions/actions/resolvePreviews.js +61 -0
  778. package/dist/interactions/actions/resolvePreviews.js.map +1 -0
  779. package/dist/interactions/actions/rotate/geometry.js +46 -0
  780. package/dist/interactions/actions/rotate/geometry.js.map +1 -0
  781. package/dist/interactions/actions/rotate/handle.js +27 -0
  782. package/dist/interactions/actions/rotate/handle.js.map +1 -0
  783. package/dist/interactions/actions/spatialReference.js +42 -0
  784. package/dist/interactions/actions/spatialReference.js.map +1 -0
  785. package/dist/interactions/actions/useStandardActions.js +142 -0
  786. package/dist/interactions/actions/useStandardActions.js.map +1 -0
  787. package/dist/interactions/gestures/dragGesture/dragGesture.js +111 -0
  788. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -0
  789. package/dist/interactions/gestures/dragRadial/dragRadial.js +117 -0
  790. package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -0
  791. package/dist/interactions/gestures/dragRect/dragRect.js +164 -0
  792. package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -0
  793. package/dist/interactions/gestures/handleDrag/handleDrag.js +46 -0
  794. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -0
  795. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +118 -0
  796. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -0
  797. package/dist/interactions/gestures/shared/originProjection.js +42 -0
  798. package/dist/interactions/gestures/shared/originProjection.js.map +1 -0
  799. package/dist/interactions/gestures/shared/screenTolerance.js +21 -0
  800. package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -0
  801. package/dist/interactions/gestures/shared/snap.js +24 -0
  802. package/dist/interactions/gestures/shared/snap.js.map +1 -0
  803. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +30 -0
  804. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -0
  805. package/dist/layout/arrivals.js +36 -0
  806. package/dist/layout/arrivals.js.map +1 -0
  807. package/dist/{math-MCQcf_gc.d.ts → math-CUMxmZzn.d.ts} +8 -116
  808. package/dist/math.d.ts +4 -5
  809. package/dist/math.js +6 -4
  810. package/dist/mesh.d.ts +268 -0
  811. package/dist/mesh.js +7 -0
  812. package/dist/move.d.ts +7 -48
  813. package/dist/move.js +3 -142
  814. package/dist/originProjection-BSn4xiEy.d.ts +57 -0
  815. package/dist/patterns-builtin.js +3 -3
  816. package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-CjSXMf8X.d.ts} +3 -3
  817. package/dist/registerProgram-ateHDGjw.d.ts +193 -0
  818. package/dist/renderer/DrawCommand.js +6 -0
  819. package/dist/renderer/DrawCommand.js.map +1 -0
  820. package/dist/renderer/WeaselRenderer.js +328 -0
  821. package/dist/renderer/WeaselRenderer.js.map +1 -0
  822. package/dist/renderer/cache/GLImageCache.js +64 -0
  823. package/dist/renderer/cache/GLImageCache.js.map +1 -0
  824. package/dist/renderer/cache/GLMeshCache.js +102 -0
  825. package/dist/renderer/cache/GLMeshCache.js.map +1 -0
  826. package/dist/renderer/cache/GLTextureCache.js +51 -0
  827. package/dist/renderer/cache/GLTextureCache.js.map +1 -0
  828. package/dist/renderer/cache/GradientRampAtlas.js +82 -0
  829. package/dist/renderer/cache/GradientRampAtlas.js.map +1 -0
  830. package/dist/renderer/cache/cache.js +13 -0
  831. package/dist/renderer/cache/cache.js.map +1 -0
  832. package/dist/renderer/cache/markerCommandCache.js +59 -0
  833. package/dist/renderer/cache/markerCommandCache.js.map +1 -0
  834. package/dist/renderer/cache/outlineMeshCache.js +15 -0
  835. package/dist/renderer/cache/outlineMeshCache.js.map +1 -0
  836. package/dist/renderer/cache/outlineStrokeMeshCache.js +31 -0
  837. package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -0
  838. package/dist/renderer/cache/strokeMeshCache.js +44 -0
  839. package/dist/renderer/cache/strokeMeshCache.js.map +1 -0
  840. package/dist/renderer/cullDrawCommands.js +89 -0
  841. package/dist/renderer/cullDrawCommands.js.map +1 -0
  842. package/dist/renderer/draw.js +1109 -0
  843. package/dist/renderer/draw.js.map +1 -0
  844. package/dist/renderer/drawBatch.js +168 -0
  845. package/dist/renderer/drawBatch.js.map +1 -0
  846. package/dist/renderer/effects/EffectTargets.js +45 -0
  847. package/dist/renderer/effects/EffectTargets.js.map +1 -0
  848. package/dist/renderer/effects/builtins.js +31 -0
  849. package/dist/renderer/effects/builtins.js.map +1 -0
  850. package/dist/renderer/effects/composite.js +9 -0
  851. package/dist/renderer/effects/composite.js.map +1 -0
  852. package/dist/renderer/effects/effectPrelude.js +10 -0
  853. package/dist/renderer/effects/effectPrelude.js.map +1 -0
  854. package/dist/renderer/effects/types.js +10 -0
  855. package/dist/renderer/effects/types.js.map +1 -0
  856. package/dist/renderer/index.js +19 -0
  857. package/dist/renderer/math/color.js +341 -0
  858. package/dist/renderer/math/color.js.map +1 -0
  859. package/dist/renderer/math/mat3.js +71 -0
  860. package/dist/renderer/math/mat3.js.map +1 -0
  861. package/dist/renderer/math/patternSpace.js +22 -0
  862. package/dist/renderer/math/patternSpace.js.map +1 -0
  863. package/dist/renderer/math/viewToMat3.js +19 -0
  864. package/dist/renderer/math/viewToMat3.js.map +1 -0
  865. package/dist/renderer/paintResources.js +18 -0
  866. package/dist/renderer/paintResources.js.map +1 -0
  867. package/dist/renderer/paintScratch.js +37 -0
  868. package/dist/renderer/paintScratch.js.map +1 -0
  869. package/dist/renderer/shaders/ShaderProgram.js +74 -0
  870. package/dist/renderer/shaders/ShaderProgram.js.map +1 -0
  871. package/dist/renderer/shaders/batchFill.js +118 -0
  872. package/dist/renderer/shaders/batchFill.js.map +1 -0
  873. package/dist/renderer/shaders/customPrelude.js +34 -0
  874. package/dist/renderer/shaders/customPrelude.js.map +1 -0
  875. package/dist/renderer/shaders/extractUniformNames.js +184 -0
  876. package/dist/renderer/shaders/extractUniformNames.js.map +1 -0
  877. package/dist/renderer/shaders/glyphPaint.js +61 -0
  878. package/dist/renderer/shaders/glyphPaint.js.map +1 -0
  879. package/dist/renderer/shaders/gradFill.js +30 -0
  880. package/dist/renderer/shaders/gradFill.js.map +1 -0
  881. package/dist/renderer/shaders/imageFill.js +14 -0
  882. package/dist/renderer/shaders/imageFill.js.map +1 -0
  883. package/dist/renderer/shaders/pathFill.js +13 -0
  884. package/dist/renderer/shaders/pathFill.js.map +1 -0
  885. package/dist/renderer/shaders/patternFill.js +24 -0
  886. package/dist/renderer/shaders/patternFill.js.map +1 -0
  887. package/dist/renderer/shaders/registerProgram.js +18 -0
  888. package/dist/renderer/shaders/registerProgram.js.map +1 -0
  889. package/dist/renderer/spriteSheet.js +14 -0
  890. package/dist/renderer/spriteSheet.js.map +1 -0
  891. package/dist/renderer/state/GroupState.js +77 -0
  892. package/dist/renderer/state/GroupState.js.map +1 -0
  893. package/dist/renderer/syntheticItalic.js +6 -0
  894. package/dist/renderer/syntheticItalic.js.map +1 -0
  895. package/dist/renderer/textures/registerTexture.js +14 -0
  896. package/dist/renderer/textures/registerTexture.js.map +1 -0
  897. package/dist/renderer.d.ts +18 -20
  898. package/dist/renderer.js +18 -13
  899. package/dist/resize.d.ts +10 -46
  900. package/dist/resize.js +7 -5
  901. package/dist/routing.d.ts +1 -1
  902. package/dist/routing.js +2 -3
  903. package/dist/scheduling/useVisibleRaf.js +69 -0
  904. package/dist/scheduling/useVisibleRaf.js.map +1 -0
  905. package/dist/test-hook/createTestHook.js +39 -0
  906. package/dist/test-hook/createTestHook.js.map +1 -0
  907. package/dist/test-hook/install.js +12 -0
  908. package/dist/test-hook/install.js.map +1 -0
  909. package/dist/test-seams-fYf6m5pu.d.ts +356 -0
  910. package/dist/test-seams.d.ts +6 -0
  911. package/dist/test-seams.js +3 -0
  912. package/dist/tools/builtin/ellipse/useEllipseTool.js +33 -0
  913. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -0
  914. package/dist/tools/builtin/eyedropper/useEyedropperTool.js +55 -0
  915. package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -0
  916. package/dist/tools/builtin/hand/dragPanContribution.js +17 -0
  917. package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -0
  918. package/dist/tools/builtin/hand/useHandTool.js +31 -0
  919. package/dist/tools/builtin/hand/useHandTool.js.map +1 -0
  920. package/dist/tools/builtin/image/useImageTool.js +41 -0
  921. package/dist/tools/builtin/image/useImageTool.js.map +1 -0
  922. package/dist/tools/builtin/lasso/useLassoTool.js +42 -0
  923. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -0
  924. package/dist/tools/builtin/line/useLineTool.js +33 -0
  925. package/dist/tools/builtin/line/useLineTool.js.map +1 -0
  926. package/dist/tools/builtin/pen/usePenTool.js +414 -0
  927. package/dist/tools/builtin/pen/usePenTool.js.map +1 -0
  928. package/dist/tools/builtin/pencil/usePencilTool.js +36 -0
  929. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -0
  930. package/dist/tools/builtin/pickTopMostHit.js +45 -0
  931. package/dist/tools/builtin/pickTopMostHit.js.map +1 -0
  932. package/dist/tools/builtin/polygon/usePolygonTool.js +81 -0
  933. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -0
  934. package/dist/tools/builtin/rect/useRectTool.js +32 -0
  935. package/dist/tools/builtin/rect/useRectTool.js.map +1 -0
  936. package/dist/tools/builtin/select/selectionContributions.js +109 -0
  937. package/dist/tools/builtin/select/selectionContributions.js.map +1 -0
  938. package/dist/tools/builtin/select/useSelectTool.js +162 -0
  939. package/dist/tools/builtin/select/useSelectTool.js.map +1 -0
  940. package/dist/tools/builtin/shared/insertToolOptions.js +8 -0
  941. package/dist/tools/builtin/shared/insertToolOptions.js.map +1 -0
  942. package/dist/tools/builtin/slice/useSliceTool.js +263 -0
  943. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -0
  944. package/dist/tools/builtin/star/useStarTool.js +82 -0
  945. package/dist/tools/builtin/star/useStarTool.js.map +1 -0
  946. package/dist/tools/builtin/text/useTextTool.js +177 -0
  947. package/dist/tools/builtin/text/useTextTool.js.map +1 -0
  948. package/dist/tools/overlayBinding.js +8 -0
  949. package/dist/tools/overlayBinding.js.map +1 -0
  950. package/dist/tools/prefs.js +47 -0
  951. package/dist/tools/prefs.js.map +1 -0
  952. package/dist/tools/useKeybindings.js +66 -0
  953. package/dist/tools/useKeybindings.js.map +1 -0
  954. package/dist/{types-CxC8P6W0.d.ts → types-CA54-mAZ.d.ts} +188 -17
  955. package/dist/{types-D_74YlWs.d.ts → types-DSjd6W3n.d.ts} +35 -12
  956. package/dist/util/color.js +26 -0
  957. package/dist/util/color.js.map +1 -0
  958. package/dist/util/constrainTo45.js +17 -0
  959. package/dist/util/constrainTo45.js.map +1 -0
  960. package/dist/util/paint.js +72 -0
  961. package/dist/util/paint.js.map +1 -0
  962. package/dist/version.js +6 -0
  963. package/dist/version.js.map +1 -0
  964. package/package.json +31 -18
  965. package/dist/chunk-44EWMJV2.js +0 -128
  966. package/dist/chunk-44EWMJV2.js.map +0 -1
  967. package/dist/chunk-4RJP2N2L.js +0 -143
  968. package/dist/chunk-4RJP2N2L.js.map +0 -1
  969. package/dist/chunk-BJN5ZRIJ.js +0 -167
  970. package/dist/chunk-BJN5ZRIJ.js.map +0 -1
  971. package/dist/chunk-D4AAWR64.js +0 -28
  972. package/dist/chunk-D4AAWR64.js.map +0 -1
  973. package/dist/chunk-DOBSZOPR.js +0 -29
  974. package/dist/chunk-DOBSZOPR.js.map +0 -1
  975. package/dist/chunk-H6N2JSZ3.js +0 -248
  976. package/dist/chunk-H6N2JSZ3.js.map +0 -1
  977. package/dist/chunk-HPFJUUTF.js +0 -167
  978. package/dist/chunk-HPFJUUTF.js.map +0 -1
  979. package/dist/chunk-L5YNZYEG.js +0 -648
  980. package/dist/chunk-L5YNZYEG.js.map +0 -1
  981. package/dist/chunk-MZAIDI6D.js +0 -32492
  982. package/dist/chunk-MZAIDI6D.js.map +0 -1
  983. package/dist/chunk-PNNZSYRD.js +0 -318
  984. package/dist/chunk-PNNZSYRD.js.map +0 -1
  985. package/dist/chunk-RMR4QMM6.js +0 -250
  986. package/dist/chunk-RMR4QMM6.js.map +0 -1
  987. package/dist/clipboard.js.map +0 -1
  988. package/dist/clone.js.map +0 -1
  989. package/dist/grid-BXdz8GF2.d.ts +0 -158
  990. package/dist/index.css.map +0 -1
  991. package/dist/index.js.map +0 -1
  992. package/dist/insert.d.ts +0 -37
  993. package/dist/insert.js +0 -81
  994. package/dist/insert.js.map +0 -1
  995. package/dist/math.js.map +0 -1
  996. package/dist/move.js.map +0 -1
  997. package/dist/options-CzjxFoYZ.d.ts +0 -67
  998. package/dist/path-JEV2c5If.d.ts +0 -48
  999. package/dist/patterns-builtin.js.map +0 -1
  1000. package/dist/renderer.css +0 -86
  1001. package/dist/renderer.css.map +0 -1
  1002. package/dist/renderer.js.map +0 -1
  1003. package/dist/resize.js.map +0 -1
  1004. package/dist/routing.js.map +0 -1
  1005. package/dist/types-D2tTKEU0.d.ts +0 -18
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Canvas.js","names":["clientToWorldHelper","_Fragment","alwaysVisible","buildSceneLayer","toPose","cfg","adapter","obj","drawOne","postProcess","finish","cullDrawCommands","cmds","viewToMat3","view","dims","paintBounds","culledIn","paintMissesView","slot","hidden","hideIds","a","filteredDrawOne","pose","v","debugSink","b","boundsOfFn","ox","oy","wrapNodeOutput","hierarchicalAdapter","id","tree","buildSceneTree","objects","children","culled","wrapped","cmd","buildSceneLayers","sceneLayerIds","l","sceneLayerKey","resolveToolsCursor","tools","tool","resolveCursorTier","ctxBase","base","NO_LAYER_VISIBILITY","toWorld","override","canvas","clientX","clientY","clientToWorld","CanvasInner","dprProp","adapterProp","layersMap","geometry","AUTO_POSE_DESCRIPTOR","viewProp","debugProp","props","debugKey","resolvedDebugConfig","useMemo","parseDebugFlags","createDebugSink","committedDebugSinkRef","useLatest","getDebug","useCallback","canvasRef","useRef","ownCanvasRef","setOwnCanvas","el","detached","paintInto","inputElement","paintTarget","paintTargetRef","paintRect","paintRectRef","helpersForLayersRef","dimsRef","getIsVisibleRef","getIsVisible","layerVisibilityRef","layerVisibility","layerOrderRef","layerOrder","paintRef","useFrameLoop","contentVersionRef","contentVersion","paintedVersionRef","getPaintedVersion","extrasVersion","setExtrasVersion","useState","extrasRef","registerLayer","layer","n","hitTestExtrasIn","layers","isVisible","visibility","order","only","isLayerPainted","hit","worldX","worldY","data","hitTestExtras","frame","viewRef","normalizeView","defaultView","isControlled","controlledView","viewSubsRef","onViewChangeRef","onViewChange","viewBoundsRef","viewBounds","isControlledRef","controlledWarnedRef","setView","resolved","next","bounds","clamped","clampView","forward","fn","requestRedraw","getView","subscribeView","element","registerMountedCanvas","paintedCursor","createPaintedCursorState","paintedCursorLayer","createPaintedCursorLayer","getSurfaceRect","origin","w","h","ref","subscribeFrame","subscribeBeforePaint","lease","useCanvasRenderer","layerCacheRef","viewRegistry","useOptionalViewRegistry","noopAdapter","effectiveAdapter","noopSelection","effectiveSelection","selection","effectiveAdapterRef","clientToWorldRef","toolsCtxBase","c","rect","ops","label","pickEveryRef","pickEvery","pickBestRef","pickBest","stablePickEveryForHud","pe","raw","wx","wy","stablePickBestForHud","selectedIdsForWiring","viewHelpers","viewChromeState","useViewHelpers","surfaceHelpers","helpersForLayers","pointerDownRef","handlePointerDown","autoFocusOnPointerDown","handlePointerMove","layersWithDebug","handlePointerLeave","handlePointerUp","backgroundLayer","backgroundFill","standardLayers","grid","isCustomEntry","cellHighlight","sceneCfg","sceneLayers","effectiveBoundsOf","ids","aggregatePreviewIds","extra","previewExtraRef","selSlot","createSelectionOverlayLayer","out","composeOrderedLayers","decorationLayer","placeToolOverlays","viewRegistryVersion","useSyncExternalStore","cb","surfaceLayersRef","r","x","y","withViews","createDebugOverlayLayer","useEffect","redraw","offs","off","useRedrawOn","redrawOn","shaderIdKey","shaders","paintInputs","paintInputsRef","helpersRef","debugSinkRef","paint","paintLayers","sink","dprIn","vis","paintFlattenTolerance","groups","paintShaders","i","renderer","spans","frameStats","paintT0","commands","drawLayers","frameStatsOf","useInsertionEffect","useLayoutEffect","width","height","flattenTolerance","layerGroups","syncPaint","layerCache","viewSubs","seen","getProgramSource","programSourceRegistry","now","changed","src","toolsCursorTier","toolsCursor","effectiveStyle","style","toolsPainted","toolsPaintedKey","layersForMoveRef","onDown","onMove","e","onUp","onLeave","onMenu","huds","Fragment","cursorCoordsHud","CursorCoordsHud","pickHud","PickHud","modalityHud","ModalityHud","Canvas","forwardRef"],"sources":["../../src/canvas/Canvas.tsx"],"sourcesContent":["/**\n * Low-level WebGL surface + viewport + pointer routing primitive.\n * Composes layers into a single GL render pass, applies a view transform,\n * routes pointer/keyboard events to the supplied `tools.dispatcher`, and\n * exposes scene-agnostic slot props (`backgroundFill`, `cursorCoordsHud`,\n * `pickHud`).\n *\n * Canvas owns NO scene-shaped state — selection, picking, kind registry,\n * scene-aware overlays — all live in `<SceneCanvas>` (the public consumer\n * entry point) which wraps `<Canvas>`.\n *\n * The `layers` prop is a map keyed by slot name. Standard slots render at a\n * canonical position; custom entries (any other key, value carrying `.layer`)\n * insert at `after`/`before` an existing slot, defaulting to the top.\n *\n * @internal\n * @deprecated Bare `<Canvas>` is not a supported consumer surface.\n * Use `<SceneCanvas>` instead. Re-promotion is tracked in\n * `docs/TODO.md`.\n */\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport type React from 'react';\nimport type { FillStyle } from '@weasel-js/paint';\nimport { composeOrderedLayers, placeToolOverlays } from './layerOrder';\nimport { sceneLayerKey } from './sceneLayerPaint';\nimport {\n STANDARD_SLOTS,\n isCustomEntry,\n type CustomLayerEntry,\n} from './layerSlots';\nexport { STANDARD_SLOTS, isCustomEntry } from './layerSlots';\nexport type { StandardSlotName, CustomLayerEntry } from './layerSlots';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport { registerMountedCanvas } from './mountedCanvases';\nimport type { ToolsApi } from '../tools/overlayBinding';\nimport { aggregatePreviewIds } from './toolPreview';\nimport type { GestureSource } from './gestureBounds';\nimport { useViewHelpers } from './useViewHelpers';\nimport { useOptionalViewRegistry } from './viewRegistry';\nimport { useFrameLoop } from './useFrameLoop';\nimport { useRedrawOn } from './useRedrawOn';\nimport type { CanvasHelpers, CanvasSurfaceHelpers } from './useViewHelpers';\n\nimport type { ToolCtx } from '@weasel-js/routing';\nimport { useLatest } from '@weasel-js/react';\nimport type { Op } from 'core/ops/types';\nimport type { Path } from '@weasel-js/geom';\nimport { dispatchApplyBatch } from 'core/applyOps';\nimport { normalizeView, type View } from 'core/viewport/view';\nimport type { NodePaintCtx } from './NodeShape';\nimport { clampView } from 'core/viewport/clampView';\nimport { clientToWorld as clientToWorldHelper } from 'core/viewport/clientToWorld';\nimport {\n drawLayers, isLayerPainted,\n type Dims, type LayerCommandCache, type LayerDrawSpan, type LayerGroup, type RedrawSource, type RenderLayer,\n} from 'core/layers/render';\nimport { viewToMat3, cullDrawCommands, type DrawCommand, type ShaderProgramHandle } from '../renderer';\nimport { useCanvasRenderer } from './useCanvasRenderer';\nimport { getProgramSource, programSourceRegistry } from '../renderer/shaders/registerProgram';\nimport {\n type SelectionApi,\n} from 'core/selection/useSelection';\nimport type {\n MoveAdapter,\n ResizeAdapter,\n RotateAdapter,\n} from 'core/adapters/types';\nimport {\n createSelectionOverlayLayer,\n type SelectionOverlayLayerOpts,\n} from 'features/selection/overlay';\nimport { AUTO_POSE_DESCRIPTOR } from 'interactions/actions/resize/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { CanvasDebugSink, DebugConfig, DebugSink } from '../debug/types';\nimport { parseDebugFlags } from '../debug/parseDebugFlags';\nimport { createDebugSink } from '../debug/createDebugSink';\nimport { createDebugOverlayLayer } from '../debug/createDebugOverlayLayer';\nimport { frameStatsOf } from '../debug/frameStats';\n\nconst alwaysVisible = (_id: string): boolean => true;\nimport { buildSceneTree, type HierarchicalAdapter } from './buildSceneTree';\nimport { resolveCursorTier } from '@weasel-js/cursor';\nimport type { ResolvedCursor } from '@weasel-js/cursor';\nimport { createPaintedCursorState } from '@weasel-js/cursor';\nimport type { PaintedCursor, PaintedCursorState } from '@weasel-js/cursor';\nimport { createPaintedCursorLayer } from '../features/cursor/paintedCursorLayer';\n\n/**\n * The scene-tree reading methods Canvas feature-detects at draw time, as an\n * *optional* mixin. A `SceneCanvasAdapter` supplies them; flat / bare-Canvas\n * adapters don't. `getPose` already lives on the base move adapter, so only the\n * three tree-walk methods are added here.\n */\ntype OptionalSceneHierarchy<TNode, TPose> = Partial<\n Pick<HierarchicalAdapter<TNode, TPose>, 'getLayers' | 'getNode' | 'getChildren'>\n>;\n\n/** The full adapter shape Canvas threads through layers + gesture hooks: the\n * move/resize/rotate intersection plus the optional scene-tree methods. */\ntype CanvasAdapter<TNode extends { id: string }, TPose> = MoveAdapter<TNode, TPose> &\n ResizeAdapter<TNode, TPose> &\n RotateAdapter<TNode, TPose> &\n OptionalSceneHierarchy<TNode, TPose>;\nimport { wrapNodeOutput } from './wrapNodeOutput';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport { paintMissesView, type PaintBoundsFn } from './paintCull';\nimport { CursorCoordsHud } from './CursorCoordsHud';\nimport { PickHud } from './PickHud';\nimport { ModalityHud } from './ModalityHud';\n\n\n\n/** Scene slot config — describes how to draw one object with its effective pose. */\nexport interface SceneSlotConfig<TNode extends { id: string }, TPose> {\n /** Override `adapter.getNodes()` for the object iteration. */\n objects?: TNode[];\n /** Project an object to its committed pose. Defaults to `adapter.getPose(obj.id)`. */\n toPose?: (obj: TNode) => TPose;\n /** Draw a single object as a `DrawCommand` tree. `ctx` carries what only a\n * scene-aware caller can supply (a node's derived path); `<SceneCanvas>`\n * fills it in, bare `<Canvas>` never does. */\n drawOne: (obj: TNode, pose: TPose, view: View, ctx?: NodePaintCtx) => DrawCommand[];\n /** The path a container derives from its dependencies' poses, for the clip\n * it imposes on its subtree. The other half of what only a scene-aware\n * caller can supply — `drawOne`'s `ctx` carries the derived path a node\n * *paints*, this one the clip it *imposes*. */\n derivedPathOf?: (obj: TNode, pose: TPose) => Path | null;\n /** Default ghost alpha for the move-overlay slot. Default 0.85. */\n ghostAlpha?: number;\n /**\n * Optional per-id alpha multiplier. When supplied, each node's emitted\n * `DrawCommand[]` is wrapped in a `{ kind: 'group', alpha }` when the\n * returned value is not 1. The scoping-dim integration supplies this to\n * dim non-active nodes during a mode transition.\n *\n * Defaults to `() => 1` (no effect).\n */\n alphaFor?: (id: string) => number;\n /**\n * Optional post-processor for the scene slot's emitted commands. Called\n * with the final world-space `DrawCommand[]` each time a scene canvas\n * layer draws (after per-node rotation wrapping and `alphaFor`); the\n * return value replaces the array handed to the renderer. When the scene\n * slot is split into per-scene-layer canvas layers (`scene:<layerId>`),\n * it runs once per layer. Identity by default.\n *\n * Commands are world-space — `drawLayers` applies the view transform\n * afterward, so e.g. a `clip` path in a wrapping group is authored in\n * world coordinates. Note clip nesting is capped at 7 levels; a wrapping\n * group with `clip` consumes one.\n *\n * The move-overlay ghost (drag preview) is not post-processed.\n */\n postProcess?: (cmds: DrawCommand[], view: View, dims: Dims) => DrawCommand[];\n /**\n * Skip what cannot reach the view. A node `paintBounds` places outside the\n * `dims` rectangle under `view` is not painted at all; then, after\n * `postProcess`, `cullDrawCommands` drops any remaining command that cannot\n * reach it — see there for what it can and cannot bound. So `postProcess`\n * sees an empty group where a culled node would have painted.\n *\n * Off by default because it makes the layer's world-space output depend on\n * the view: anything that draws this layer once and shows the result under\n * another view — a cache keyed without `view`, a consumer re-wrapping the\n * commands — would show the first view's cull.\n */\n cull?: boolean;\n /**\n * Where `drawOne`'s output for a node can reach, in the frame it paints in\n * — before the pose rotation the slot wraps it in. `null` for a node it\n * cannot bound cheaply. Read only under `cull`, which skips `drawOne` for a\n * node whose box misses the view, so it must enclose everything `drawOne`\n * paints: a box too small makes a node vanish before it leaves the screen.\n *\n * `<SceneCanvas>` supplies `defaultPaintBounds` while `drawOne` is\n * `defaultDrawOne`. Omit it with any other `drawOne` and culling only\n * trims commands after painting.\n */\n paintBounds?: PaintBoundsFn<TNode, TPose>;\n}\n\n/** Selection-overlay slot config — passed through to `createSelectionOverlayLayer`,\n * minus the `getSelection`/`getPose` Canvas wires automatically. */\nexport type SelectionOverlaySlotConfig<TPose> = Omit<\n SelectionOverlayLayerOpts<TPose>,\n 'getSelection' | 'getPose'\n> & {\n /** Override the auto-wired pose lookup (overlay-aware → adapter fallback). */\n poseById?: (id: string) => TPose | null;\n};\n\n\n/** Per-slot config union. The key narrows it in practice. */\nexport type StandardSlotConfig<TNode extends { id: string }, TPose> =\n | SceneSlotConfig<TNode, TPose>\n | SelectionOverlaySlotConfig<TPose>;\n\n/** What may fill one of the canvas's named layer slots: a config the canvas\n * builds the layer from, a pre-built layer, or `null` to leave the slot\n * empty. */\nexport type LayerSlotValue<TNode extends { id: string }, TPose> =\n | StandardSlotConfig<TNode, TPose>\n | CustomLayerEntry\n | null;\n\n/** The canvas's render stack, as named slots. The standard slots (grid,\n * scene, selection overlay, cell highlight) fix where a layer sits in the\n * stack; scene and selection overlay can be configured, and every one can be\n * given a layer of your own or switched off. Further keys add custom layers.\n * `TSceneSlot` is what the scene slot accepts: `<SceneCanvas>` takes a\n * partial config and fills the rest from its defaults. */\nexport type LayersMap<\n TNode extends { id: string },\n TPose,\n TSceneSlot = SceneSlotConfig<TNode, TPose>,\n> = {\n /** Grid slot, beneath the scene. Takes a pre-built layer (`{ layer }`) —\n * e.g. `createGridLayer` from `@weasel-js/guides` — or `null`. */\n grid?: CustomLayerEntry | null;\n scene?: TSceneSlot | null;\n /** Selection-overlay slot. Canvas constructs the layer from a\n * `SelectionOverlaySlotConfig`; pass a `CustomLayerEntry` (`{ layer }`) to\n * supply a pre-built layer (e.g. from `<SceneCanvas>`). */\n selectionOverlay?: SelectionOverlaySlotConfig<TPose> | CustomLayerEntry | null;\n /** Cell-highlight overlay slot, drawn immediately after the grid. Takes a\n * pre-built layer (`{ layer }`) — e.g. `createCellHighlightLayer` from\n * `@weasel-js/guides` — or `null`. */\n cellHighlight?: CustomLayerEntry | null;\n} & {\n [customKey: string]: LayerSlotValue<TNode, TPose> | TSceneSlot | undefined;\n};\n\n/**\n * Props for `<Canvas>` — the low-level WebGL surface + viewport +\n * pointer routing primitive.\n *\n * Canvas is scene-agnostic. It owns the GL surface, view state, pointer/\n * keyboard dispatch, and slot composition. It does NOT own selection state,\n * picking logic, kind registries, or scene-aware overlays — those belong in\n * `<SceneCanvas>`.\n */\nexport interface CanvasProps<TNode extends { id: string } = { id: string }, TPose = unknown> {\n /** CSS-pixel width. */\n width: number;\n /** CSS-pixel height. */\n height: number;\n\n /** Drawing-buffer density (device pixels per CSS pixel). When omitted the\n * canvas reads `window.devicePixelRatio` per paint — the long-standing\n * screen behavior. Supplying it makes density an explicit parameter, the\n * same contract the headless `renderSceneToPixels` path follows (that\n * path never reads ambient density at all). */\n dpr?: number;\n\n /** Flatness tolerance for curve tessellation, in world units. Forwarded to\n * `WeaselRendererOptions.flattenTolerance`. Leave unset for the cached\n * default (`DEFAULT_FLATTEN_TOLERANCE`, 0.5); a scene whose world unit is\n * not a pixel — feet, inches, millimetres — needs a value scaled to its\n * unit or sub-unit curves flatten to a handful of vertices. */\n flattenTolerance?: number;\n\n /** The version of whatever content this canvas draws, sampled at paint time\n * and reported by {@link CanvasExtensionApi.getPaintedVersion}.\n * `<SceneCanvas>` wires this to `scene.getVersion`. Chrome that must not\n * show DOM ahead of pixels compares the two and defers a frame. */\n contentVersion?: () => number;\n\n /** Paint inside the React commit rather than on the next animation frame.\n * Costs a synchronous paint per commit and per redraw request; buys\n * single-commit consistency between React-rendered DOM and canvas pixels.\n * For consumers with DOM chrome pinned to canvas content that cannot\n * tolerate a frame of skew. Live: toggling it switches modes from the next\n * redraw on. A redraw requested from inside a layer's `draw`, or from a\n * `subscribeFrame` callback, still waits for a frame — painting it in place\n * would recurse. */\n syncPaint?: boolean;\n\n /** External state the paint reads that no layer declares — typically what\n * an `alphaFor` consults. Each source is subscribed while mounted and\n * repaints the canvas when it notifies. A layer that reads outside state\n * declares it on `RenderLayer.subscribe` instead. */\n redrawOn?: readonly RedrawSource[];\n\n /**\n * Combined adapter for scene-slot rendering, bounds computation, and\n * move/resize/rotate gesture math. Optional — bare-Canvas consumers that\n * don't need a scene slot may omit it.\n *\n * Canvas threads this adapter into layer factories and gesture hooks. The\n * type is the move/resize/rotate intersection plus the *optional* scene-tree\n * methods (`getLayers`/`getNode`/`getChildren`) — present on a hierarchical\n * `SceneCanvasAdapter`, absent on flat adapters. The `buildSceneLayer` path\n * feature-detects them at draw time.\n *\n * `<SceneCanvas>` synthesizes this from a `Scene`; bare-`<Canvas>` consumers\n * must supply it explicitly when using the scene or selection-overlay slots.\n */\n adapter?: CanvasAdapter<TNode, TPose>;\n\n /** Layer map. See module docstring for slot semantics. */\n layers: LayersMap<TNode, TPose>;\n\n /**\n * Current selection state. Canvas is a pure pass-through — it owns no\n * selection state of its own. When absent, Canvas behaves as if nothing is\n * selected: no selection chrome, no select-on-click, no clear-on-background.\n *\n * `<SceneCanvas>` always supplies this from its internal `useSelection`.\n * Bare-`<Canvas>` consumers may omit it for non-selection use cases (e.g.\n * force-graph renderers or read-only viewers).\n */\n selection?: SelectionApi;\n\n\n /**\n * How to read and rewrite a pose. Drives the default `boundsOf` fallback and\n * the selection-overlay bounds.\n * Defaults to the rect identity (`AUTO_POSE_DESCRIPTOR`).\n *\n * This is a math helper, not a scene-shaped concern — it converts a pose\n * value to an AABB and extracts rotation for the selection chrome. Bare-\n * Canvas consumers that use a non-rect pose type should supply this.\n */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n // --- Gesture overrides (escape hatches for non-rect / group-aware apps) ---\n /**\n * Used by `PickHud` to display the list of ids under the cursor.\n * NOT used for tool routing — see `getNodeAtPoint` for that.\n * `<SceneCanvas>` passes its internal pick function here so the HUD\n * stays in sync with the scene's actual hit-test order.\n */\n pickEvery?: (worldX: number, worldY: number) => string | string[] | null;\n /**\n * Override for committed bounds lookup. When supplied, takes precedence over\n * the `poseDescriptor`-derived fallback. Used by the selection overlay, the\n * multi-select union AABB, and `helpersRef.getEffectiveBounds`. Optional —\n * bare-Canvas consumers that use a custom bounds shape should supply this;\n * `<SceneCanvas>` derives it from its scene adapter and passes it via the\n * scene-slot layer config rather than this prop.\n */\n boundsOf?: (id: string) => Bounds | null;\n /** Bounds of `id` drawn at an in-flight pose — how chrome boxes a preview.\n * Defaults to the `poseDescriptor`'s box of that pose. */\n boundsOfPose?: (id: string, pose: TPose) => Bounds | null;\n /**\n * Custom pointer-to-world coordinate transform. When supplied, overrides the\n * default `(clientX - canvasRect.left) / scale + pan` calculation. Useful\n * for consumers that apply an additional CSS transform to the canvas element.\n */\n clientToWorld?: (canvas: HTMLElement, cx: number, cy: number) => [number, number];\n\n /**\n * Paint into a caller-owned canvas at a rect on it, instead of an element\n * this component creates. `x`/`y` are the rect's top-left in that canvas's\n * CSS pixels; the rect's size is the existing `width`/`height` props.\n *\n * Requires `inputElement`: with no element of its own there is nowhere for\n * pointer input, focus or the cursor to live, and nothing renders.\n *\n * N canvases can then share one GL context and one buffer.\n */\n paintInto?: { canvas: HTMLCanvasElement | null; x: number; y: number };\n /**\n * The element pointer input, focus and the cursor come from, and the element\n * every client→world conversion measures. Only read alongside `paintInto`;\n * an attached canvas uses the one it renders.\n */\n inputElement?: HTMLElement | null;\n\n // --- Visuals / DOM passthrough ---\n className?: string;\n style?: React.CSSProperties;\n tabIndex?: number;\n /** Fired when the canvas element gains focus. The canvas is focusable by\n * default (`tabIndex` 0), so consumers driving focus-dependent chrome —\n * a focus ring, a \"keyboard shortcuts active\" hint — need to observe it. */\n onFocus?: React.FocusEventHandler<HTMLCanvasElement>;\n /** Fired when the canvas element loses focus. */\n onBlur?: React.FocusEventHandler<HTMLCanvasElement>;\n /**\n * When `true` (default), the canvas element receives focus on `pointerdown`\n * so keyboard events (tool hotkeys, undo/redo) are captured without a\n * separate click-to-focus step. Set to `false` for canvases embedded inside\n * a larger focus-managed layout where auto-focus would steal focus from\n * sibling inputs.\n */\n autoFocusOnPointerDown?: boolean;\n\n /** Opt-in keyboard-driven actions wired against the canvas's effective\n * selection. Each key turns the action on; values may be `true` (defaults)\n * or a config dict. Omitting a key leaves the action unbound. */\n /** Tool primitive substrate. Pointer/keyboard/wheel events are routed\n * through `tools.dispatcher`. */\n tools?: import('../tools/overlayBinding').ToolsApi;\n\n /** Controlled viewport. When supplied, Canvas does not own the value —\n * the consumer must supply `onViewChange` and re-render with the new\n * view. See `View` JSDoc for the camera-position convention. */\n view?: View;\n /** Initial viewport for the uncontrolled path. Default `{x:0, y:0}`. */\n defaultView?: View;\n /** Fires whenever the viewport changes — in both controlled and\n * uncontrolled modes. */\n onViewChange?: (next: View) => void;\n /**\n * Optional world-space rect that constrains pan. When supplied, every\n * `setView` call passes through `clampView(next, viewBounds, {width, height})`\n * before commit, keeping the visible rect inside `viewBounds`. If the visible\n * rect is larger than the bounds along an axis (zoomed out past extent), that\n * axis is centered. Has no effect on `scale`.\n *\n * A viewport concern, not scene-shaped. Consumers that want the pan to stay\n * inside a document page boundary should wire this with the page dimensions.\n */\n viewBounds?: { x: number; y: number; width: number; height: number };\n /**\n * Mutable ref Canvas writes overlay-aware pose/bounds lookups to on every\n * render. Custom layers can read it from inside their `draw` closure to\n * reflect in-flight gestures (move/resize/rotate) instead of the committed\n * scene. Both lookups apply when an id is in the active overlay; otherwise\n * they fall back to the adapter.\n *\n * Useful for custom layers that render scene content outside of the standard\n * slot system and need to stay in sync with gesture previews.\n */\n helpersRef?: React.MutableRefObject<CanvasHelpers<TPose> | null>;\n\n /**\n * Debug overlay configuration.\n * - `undefined` (default): read `?debug=…` from the URL.\n * - `false`: force off, ignore URL.\n * - `DebugConfig` object: force on with that config, ignore URL.\n *\n * When enabled, the Canvas appends a screen-space `debug-overlay` layer\n * at the top of the layer stack and threads a `DebugSink` into every\n * interaction hook so they record hit math + handle positions.\n */\n debug?: DebugConfig | false;\n\n /** Test-only escape hatch: writes the live debug sink to this ref so tests\n * can call `snapshot()` after a render. No effect when debug is off. */\n debugSinkRef?: React.MutableRefObject<CanvasDebugSink | null>;\n\n /**\n * Custom shader programs to compile on the renderer. Each handle must come\n * from a module-level `registerProgram()` call. Compiled once per handle id\n * on first render (or on context restore). Pass a stable reference (e.g.\n * defined at module scope) — the array is read at renderer init time.\n * Re-registering one of these ids with new source repaints the canvas, and\n * the renderer recompiles it for that frame.\n */\n shaders?: ShaderProgramHandle[];\n\n /**\n * Extra source of ids whose committed paint should be suppressed during the\n * current frame (in addition to those reported by the tools' `previewIds()`).\n *\n * Wired by `<SceneCanvas>` to expose the new gesture-dispatcher's in-flight\n * handles: as legacy hooks are removed from tools, the\n * source-hide for move/clone/etc. needs to follow the preview-ghost layer\n * onto the dispatcher's `OngoingHandle.previewIds()`. Optional — bare\n * `<Canvas>` consumers don't need to wire it.\n */\n previewIdsExtra?: () => Iterable<string> | null;\n\n /**\n * Extra preview-pose lookup checked after the active tool's `previewPose`\n * misses. Wired by `<SceneCanvas>` to expose the gesture-dispatcher's\n * in-flight `OngoingHandle.previewPose(id)` so selection chrome (resize/\n * rotation handles, AABB outline) tracks the ghost during dispatcher-driven\n * drags. Returns `null` / `undefined` when no preview is in flight.\n */\n previewPoseExtra?: (id: string) => unknown;\n\n /**\n * In-flight gesture state `<Canvas>` can't see for itself. Backs the\n * `getGestureBounds` / `subscribeGestures` / `getGestureVersion` trio on\n * `helpersRef`; wired by `<SceneCanvas>` from the gesture dispatcher\n * (`createGestureSource`). Leaving it unwired is fine — those three then\n * report \"no gesture in flight\" and never fire.\n */\n gestureSource?: GestureSource;\n\n /**\n * FillStyle applied to the full canvas surface behind the scene. Accepts the\n * kit's `FillStyle` union (solid / pattern / linear-gradient / radial-gradient /\n * conic-gradient) so consumers don't have to author a background node just to\n * colorize the canvas.\n *\n * Rendered as a screen-space layer slotted before `'scene'` — independent of\n * pan / zoom. Canvas owns this layer; `<SceneCanvas>` forwards its own\n * `backgroundFill` prop verbatim so consumer apps see no breaking change.\n */\n backgroundFill?: FillStyle;\n\n /**\n * Dev HUD: when true, mounts a fixed-position widget showing live cursor\n * coords in both viewport (client) and canvas (world) frames. Useful for\n * diagnosing pointer-coord drift / pan-zoom misalignment without\n * instrumenting events.\n */\n cursorCoordsHud?: boolean;\n\n /**\n * Dev HUD: when true, mounts a fixed-position widget just below the\n * cursor-coords HUD listing the ids returned by `pickEvery(world)` under\n * the cursor. Useful for diagnosing hit-test order and container/leaf\n * overlap during select-tool work.\n */\n pickHud?: boolean;\n\n /**\n * Dev HUD: mounts a fixed-position widget below the pick HUD reporting\n * the active modality mode, the active-slot tool, and the hotkey stack.\n * Pass `true` to enable with no mode (renders `—` for the mode line —\n * useful until the modality machine is wired). Pass an object to supply\n * the current mode id.\n */\n modalityHud?: boolean | { modeId?: string };\n\n /**\n * Optional single-best hit resolver for the `pickHud` — the id this point\n * would select on a bare click. When omitted the HUD skips the bold-best\n * highlight. `<SceneCanvas>` forwards its `internalPickBest` here so the\n * HUD shows the same best-candidate SceneCanvas would pick.\n */\n pickBest?: (worldX: number, worldY: number) => string | null;\n\n\n /**\n * Optional mode-owned decoration layer. When supplied, Canvas inserts it\n * between the scene-render slot and the tool-overlay slot so decoration\n * draw commands (e.g. path-edit anchor dots) paint above scene content but\n * below tool overlays (drag rects, etc.).\n *\n * Slot ordering: scene → (scoping mask) → **decoration** → tool overlay → chrome.\n *\n * Wired by the modality machine after it activates a mode whose\n * `ModeDefinition` supplies a `paint()` factory. Omitting this prop is a\n * no-op — existing consumers are unaffected.\n */\n decorationLayer?: RenderLayer<unknown>;\n\n /**\n * Chrome-caps visibility resolver. When supplied, Canvas:\n * - exposes the predicate on `helpersForLayers.getIsVisible` so\n * custom layers (notably `composeAffordanceLayer`) can gate\n * paint by chrome id;\n * - threads it into the affordance-pipeline `HitTestContext.isVisible`\n * so the same gate applies to hit-testing.\n *\n * Called fresh per draw / per hitTest, so the consumer can return a\n * predicate that closes over per-frame `ChromeCtx`. Omit to leave\n * every chrome element visible (pre-chrome-caps behavior).\n */\n getIsVisible?: () => (id: string) => boolean;\n\n /**\n * Show or hide whole render layers by id. An id absent from the map falls\n * back to the layer's own `defaultVisible`, and a layer marked `alwaysOn`\n * ignores the map entirely.\n *\n * Hiding a layer also stops it claiming pointer events through\n * `hitTestExtras` — a layer nobody can see must not swallow a click.\n *\n * This is `getIsVisible`'s coarser sibling: that one gates individual\n * chrome elements *within* a layer, this one gates the layer.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order, by layer id, bottom first. Omit for the order the layers\n * arrive in.\n *\n * **A listed order is the whole list:** any layer whose id is missing from\n * it is not drawn. Reordering two layers means naming all of them.\n */\n layerOrder?: string[];\n\n /**\n * Runs of consecutive layers that composite as one — the surface for\n * blurring the world while the chrome above it stays sharp. Members are\n * named by layer id, and a layer in no group draws exactly as it did\n * before. See {@link LayerGroup}.\n */\n layerGroups?: readonly LayerGroup[];\n}\n\nexport type {\n CanvasViewHelpers,\n CanvasSurfaceHelpers,\n CanvasHelpers,\n} from './useViewHelpers';\n\n// Walks every registered + ambient tool: resize/rotate will register as\n/**\n * Build the scene layer. Tool ghosts (in-flight drag/resize/rotate poses) are\n * published via the active tool's `previewPose`/`previewIds` and rendered on\n * top of this layer (see SceneCanvas's preview-ghost layer); we draw committed\n * poses here, and `hideIds()` lets us skip the committed paint of ids the\n * active tool is currently ghosting so the source doesn't show through.\n */\nexport function buildSceneLayer<TNode extends { id: string }, TPose>(\n cfg: SceneSlotConfig<TNode, TPose>,\n adapter: CanvasAdapter<TNode, TPose> | undefined,\n debugSink: DebugSink | null,\n boundsOfFn: ((id: string) => Bounds | null) | undefined,\n hideIds: () => Set<string> | null,\n /** When set, the returned layer carries this `id` and paints ONLY the named\n * scene layer (the rest are walked for ancestor clips). Used to split the\n * scene slot into per-scene-layer, individually-orderable canvas layers\n * (`scene:<layerId>`) so consumers can interleave custom layers between\n * them. Omit for the single bundled `scene` layer. */\n slot?: { id: string; forLayer: string },\n): RenderLayer<unknown> {\n const toPose =\n cfg.toPose ??\n ((obj: TNode) => (adapter ? adapter.getPose(obj.id) : (obj as unknown as TPose)));\n const drawOne = cfg.drawOne;\n const postProcess = cfg.postProcess;\n const finish = cfg.cull\n ? (cmds: DrawCommand[], view: View, dims: Dims): DrawCommand[] =>\n cullDrawCommands(cmds, viewToMat3(view), { x: 0, y: 0, width: dims.width, height: dims.height })\n : (cmds: DrawCommand[]): DrawCommand[] => cmds;\n const paintBounds = cfg.cull ? cfg.paintBounds : undefined;\n const culledIn = (view: View, dims: Dims) => paintBounds\n ? paintMissesView(paintBounds, view, { x: 0, y: 0, width: dims.width, height: dims.height })\n : undefined;\n return {\n id: slot?.id ?? 'scene',\n label: slot ? `Scene: ${slot.forLayer}` : 'Scene',\n draw: (_data, view, dims) => {\n const hidden = hideIds();\n const a = adapter;\n if (\n a &&\n cfg.objects === undefined &&\n typeof a.getLayers === 'function' &&\n typeof a.getNode === 'function' &&\n typeof a.getChildren === 'function' &&\n drawOne\n ) {\n const filteredDrawOne = (obj: TNode, pose: TPose, v: View): DrawCommand[] => {\n if (hidden && hidden.has(obj.id)) return [];\n const cmds = drawOne(obj, pose, v);\n if (debugSink) {\n const b = boundsOfFn ? boundsOfFn(obj.id) : null;\n if (b) debugSink.recordBounds(obj.id, b);\n const ox = (pose as { x?: number }).x ?? (b ? b.x : 0);\n const oy = (pose as { y?: number }).y ?? (b ? b.y : 0);\n debugSink.recordOrigin(obj.id, { x: ox, y: oy });\n }\n return wrapNodeOutput(cmds, pose, cfg.alphaFor ? cfg.alphaFor(obj.id) : 1);\n };\n // Honor cfg.toPose on the hierarchical path by shimming getPose on the\n // adapter so buildSceneTree routes through it instead of the raw adapter.\n const hierarchicalAdapter = cfg.toPose\n ? {\n ...a,\n getPose: (id: string) => {\n const obj = a.getNode!(id);\n return obj ? toPose(obj) : a.getPose(id);\n },\n }\n : a;\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n const tree = buildSceneTree(\n hierarchicalAdapter as Parameters<typeof buildSceneTree>[0],\n filteredDrawOne as unknown as Parameters<typeof buildSceneTree>[1],\n view,\n slot?.forLayer,\n cfg.derivedPathOf as Parameters<typeof buildSceneTree>[4],\n culledIn(view, dims) as Parameters<typeof buildSceneTree>[5],\n );\n return finish(postProcess ? postProcess(tree, view, dims) : tree, view, dims);\n }\n // Flat fallback — keep existing body verbatim. (Per-layer slotting only\n // applies on the hierarchical path; a flat adapter has no scene layers,\n // so the `scene:<layer>` split is a no-op and we emit the whole scene.)\n const objects = cfg.objects ?? adapter?.getNodes() ?? [];\n const children: DrawCommand[] = [];\n const culled = culledIn(view, dims);\n for (const obj of objects) {\n if (hidden && hidden.has(obj.id)) continue;\n const pose: TPose = toPose(obj);\n if (drawOne && !culled?.(obj, pose)) {\n const cmds = drawOne(obj, pose, view);\n const wrapped = wrapNodeOutput(cmds, pose, cfg.alphaFor ? cfg.alphaFor(obj.id) : 1);\n for (const cmd of wrapped) children.push(cmd);\n }\n if (debugSink) {\n const b = boundsOfFn ? boundsOfFn(obj.id) : null;\n if (b) debugSink.recordBounds(obj.id, { x: b.x, y: b.y, width: b.width, height: b.height });\n const ox = (pose as { x?: number }).x ?? (b ? b.x : 0);\n const oy = (pose as { y?: number }).y ?? (b ? b.y : 0);\n debugSink.recordOrigin(obj.id, { x: ox, y: oy });\n }\n }\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n return finish(postProcess ? postProcess(children, view, dims) : children, view, dims);\n },\n };\n}\n\n/**\n * Build the scene slot as one canvas layer **per scene layer** — keyed\n * `scene:<layerId>` — when the adapter is hierarchical (exposes `getLayers`).\n * This lets consumers interleave custom layers *between* scene layers via the\n * standard slot anchoring (`before: 'scene:plantings'`). Each per-layer canvas\n * layer re-runs the scene walk for its own layer only (others are still walked\n * for ancestor clips). Falls back to a single `scene` layer for flat adapters\n * or adapters with no declared layers.\n */\nexport function buildSceneLayers<TNode extends { id: string }, TPose>(\n cfg: SceneSlotConfig<TNode, TPose>,\n adapter: CanvasAdapter<TNode, TPose> | undefined,\n debugSink: DebugSink | null,\n boundsOfFn: ((id: string) => Bounds | null) | undefined,\n hideIds: () => Set<string> | null,\n): Array<{ key: string; layer: RenderLayer<unknown> }> {\n const sceneLayerIds =\n cfg.objects === undefined && typeof adapter?.getLayers === 'function'\n ? adapter.getLayers().map((l) => l.id)\n : null;\n if (!sceneLayerIds || sceneLayerIds.length === 0) {\n return [{ key: 'scene', layer: buildSceneLayer(cfg, adapter, debugSink, boundsOfFn, hideIds) }];\n }\n return sceneLayerIds.map((id) => ({\n key: sceneLayerKey(id),\n layer: buildSceneLayer(cfg, adapter, debugSink, boundsOfFn, hideIds, {\n id: sceneLayerKey(id),\n forLayer: id,\n }),\n }));\n}\n\nfunction resolveToolsCursor(\n tools: ToolsApi,\n ctxBase?: () => Omit<ToolCtx, 'scratch'>,\n): ResolvedCursor | undefined {\n const id = tools.hotkeyEngaged ?? tools.active;\n const tool = id === null ? undefined : tools.registry[id];\n if (!tool?.cursor) return undefined;\n if (typeof tool.cursor !== 'function') return resolveCursorTier(tool.cursor);\n if (!ctxBase) return undefined;\n // Function form: invoke at render time with the live base ctx.\n //\n // `ctx.scratch` is always null here. It used to be the tool-routing\n // dispatcher's in-flight gesture scratch, which is how `grab` became\n // `grabbing` and how select swapped to `move` — mid-gesture cursors are now\n // `Action.activeCursor`, applied imperatively by the hover pump. A tool that\n // wants a cursor driven by its own state closes over its own ref (the pen\n // does, for its close-path hint).\n try {\n const base = ctxBase();\n return resolveCursorTier(tool.cursor({ ...base, scratch: null }));\n } catch {\n return undefined;\n }\n}\n\n/** Stable empty map, so an omitted `layerVisibility` doesn't remake the paint\n * effect's deps every render. */\nconst NO_LAYER_VISIBILITY: Record<string, boolean> = {};\n\n/** Client coords to world, through the `clientToWorld` prop when one is\n * supplied and the canvas rect otherwise. Every pointer path in this file\n * goes through here so the two cannot drift. */\nfunction toWorld(\n canvas: HTMLElement,\n clientX: number,\n clientY: number,\n view: View,\n override: CanvasProps<never, never>['clientToWorld'],\n): [number, number] {\n if (override) return override(canvas, clientX, clientY);\n return clientToWorldHelper(clientX, clientY, canvas.getBoundingClientRect(), view);\n}\n\nfunction CanvasInner<TNode extends { id: string }, TPose>(\n props: CanvasProps<TNode, TPose>,\n ref: React.ForwardedRef<CanvasExtensionApi>,\n) {\n const {\n width,\n height,\n dpr: dprProp,\n flattenTolerance,\n contentVersion,\n syncPaint = false,\n redrawOn,\n adapter: adapterProp,\n layers: layersMap,\n selection,\n boundsOf,\n boundsOfPose,\n pickEvery,\n clientToWorld,\n paintInto,\n inputElement,\n poseDescriptor: geometry = AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>,\n className,\n style,\n tabIndex = 0,\n onFocus,\n onBlur,\n autoFocusOnPointerDown = true,\n helpersRef,\n tools,\n view: viewProp,\n defaultView,\n onViewChange,\n viewBounds,\n debug: debugProp,\n debugSinkRef,\n shaders,\n previewIdsExtra,\n previewPoseExtra,\n gestureSource,\n backgroundFill,\n cursorCoordsHud,\n pickHud,\n modalityHud,\n pickBest,\n decorationLayer,\n getIsVisible,\n layerVisibility,\n layerOrder,\n layerGroups,\n } = props;\n\n // Resolve debug config: explicit prop wins; `undefined` falls back to URL;\n // `false` forces off. Keyed on content, so a config written inline does not\n // rebuild the sink, and lose what it has recorded, on every render.\n const debugKey = debugProp === undefined ? undefined : JSON.stringify(debugProp);\n const resolvedDebugConfig = useMemo<DebugConfig | null>(() => {\n if (debugKey !== undefined) return (JSON.parse(debugKey) as DebugConfig | false) || null;\n if (typeof window === 'undefined') return null;\n return parseDebugFlags(window.location.search);\n }, [debugKey]);\n\n // Lazily build one sink per Canvas mount (per resolved config).\n const debugSink = useMemo<CanvasDebugSink | null>(() => {\n if (resolvedDebugConfig === null) return null;\n return createDebugSink(resolvedDebugConfig);\n }, [resolvedDebugConfig]);\n const committedDebugSinkRef = useLatest(debugSink);\n const getDebug = useCallback(() => committedDebugSinkRef.current, [committedDebugSinkRef]);\n\n const adapter = adapterProp;\n\n // The element input comes from and every client→world conversion measures.\n // Normally the `<canvas>` this component renders; under `paintInto` it is\n // the caller's `inputElement` instead — nothing downstream of here asks\n // which of the two it is holding, because nothing downstream needs a canvas.\n const canvasRef = useRef<HTMLElement | null>(null);\n // The `<canvas>` this component rendered, if it rendered one. `paint` is the\n // only thing that needs a real canvas, for `getContext`.\n const ownCanvasRef = useRef<HTMLCanvasElement | null>(null);\n // Stable, so a commit does not detach the element: an inline ref is nulled\n // until the layout phase reaches it, and a sync paint asked for before that\n // finds no canvas.\n const setOwnCanvas = useCallback((el: HTMLCanvasElement | null) => {\n ownCanvasRef.current = el;\n canvasRef.current = el;\n }, []);\n const detached = !!paintInto;\n // The detached input element reaches `canvasRef` at commit; the own canvas\n // arrives through `setOwnCanvas`, React's ref callback.\n useInsertionEffect(() => {\n if (detached) canvasRef.current = inputElement ?? null;\n });\n // Where pixels go. Split from `canvasRef` only when detached.\n const paintTarget = detached ? (paintInto.canvas ?? null) : null;\n const paintTargetRef = useLatest(paintTarget);\n const paintRect = detached ? { x: paintInto.x, y: paintInto.y } : null;\n const paintRectRef = useLatest(paintRect);\n\n // Read by `hitTestExtras`, which is built once and must see live values.\n const helpersForLayersRef = useRef<CanvasHelpers<TPose> | null>(null);\n const dimsRef = useLatest({ width, height });\n const getIsVisibleRef = useLatest(getIsVisible);\n const layerVisibilityRef = useLatest(layerVisibility);\n const layerOrderRef = useLatest(layerOrder);\n\n // React does not drive the paint; the frame loop does. The thunk defers to\n // `paint` below, which needs inputs this render has not computed yet.\n const paintRef = useRef<() => boolean>(() => false);\n const { requestRedraw, subscribeFrame, subscribeBeforePaint } = useFrameLoop(\n useCallback(() => paintRef.current(), []),\n { syncPaint, target: canvasRef },\n );\n\n const contentVersionRef = useLatest(contentVersion);\n const paintedVersionRef = useRef(0);\n const getPaintedVersion = useCallback(() => paintedVersionRef.current, []);\n\n // The `layersWithDebug` memo reads `extrasRef.current`, so registration has\n // to bump state to re-run it. Rare (a HUD attaching, a loupe mounting).\n const [extrasVersion, setExtrasVersion] = useState(0);\n const extrasRef = useRef<Set<RenderLayer<unknown>>>(new Set());\n const registerLayer = useCallback((layer: RenderLayer<unknown>) => {\n extrasRef.current.add(layer);\n setExtrasVersion(n => n + 1);\n return () => {\n extrasRef.current.delete(layer);\n setExtrasVersion(n => n + 1);\n };\n }, []);\n\n // Hit-test registered layers topmost-first. Registration order is draw\n // order, so the last-registered layer is on top and gets first refusal —\n // the reverse of the Set's iteration order.\n //\n // `<SceneCanvas>` folds this into its `affordanceAt` thunk. Canvas can't do\n // that itself: it has the layers but not the dispatcher.\n const hitTestExtrasIn = useCallback((\n worldX: number,\n worldY: number,\n view: View,\n dims: Dims,\n data: unknown,\n only?: readonly RenderLayer<unknown>[],\n ) => {\n const layers = [...extrasRef.current].reverse();\n const isVisible = getIsVisibleRef.current?.() ?? alwaysVisible;\n const visibility = layerVisibilityRef.current ?? NO_LAYER_VISIBILITY;\n const order = layerOrderRef.current;\n for (const layer of layers) {\n if (!layer.hitTest) continue;\n if (only && !only.includes(layer)) continue;\n if (!isLayerPainted(layer, visibility, order)) continue;\n const hit = layer.hitTest(worldX, worldY, data, view, dims, isVisible);\n if (hit) return { layerId: layer.id, hit };\n }\n return null;\n }, [getIsVisibleRef, layerOrderRef, layerVisibilityRef]);\n\n const hitTestExtras = useCallback((\n worldX: number,\n worldY: number,\n frame?: { view: View; dims: Dims },\n ) => hitTestExtrasIn(\n worldX,\n worldY,\n frame?.view ?? viewRef.current,\n frame?.dims ?? dimsRef.current,\n helpersForLayersRef.current,\n ), [hitTestExtrasIn, dimsRef]);\n\n // The uncontrolled view lives in a ref, not `useState`, so a camera moving\n // at 60 Hz costs no React render; DOM that mirrors it subscribes instead.\n const viewRef = useRef<View>(normalizeView(viewProp ?? defaultView ?? { x: 0, y: 0, scale: { x: 1, y: 1 } }));\n const isControlled = viewProp !== undefined;\n const controlledView = isControlled ? normalizeView(viewProp) : undefined;\n const viewSubsRef = useRef<Set<(v: View) => void>>(new Set());\n const onViewChangeRef = useLatest(onViewChange);\n const viewBoundsRef = useLatest(viewBounds);\n const isControlledRef = useLatest(isControlled);\n const controlledWarnedRef = useRef(false);\n\n const setView = useCallback((next: View | ((current: View) => View)) => {\n const resolved = normalizeView(typeof next === 'function' ? next(viewRef.current) : next);\n const bounds = viewBoundsRef.current;\n const clamped = bounds ? clampView(resolved, bounds, dimsRef.current) : resolved;\n if (isControlledRef.current) {\n // The prop is the authority; writing the ref would put pixels and props\n // out of step with nothing to reconcile them.\n const forward = onViewChangeRef.current;\n if (!controlledWarnedRef.current) {\n controlledWarnedRef.current = true;\n console.warn(forward\n ? '[weasel] setView not applied locally: this canvas is controlled by its `view` prop. The value was forwarded to `onViewChange` — update the prop from there, or drop it to take the imperative path.'\n : '[weasel] setView ignored: this canvas is controlled by its `view` prop and has no `onViewChange`, so the value has nowhere to go. Update the prop, or drop it to take the imperative path.');\n }\n forward?.(clamped);\n return;\n }\n viewRef.current = clamped;\n for (const fn of viewSubsRef.current) fn(clamped);\n onViewChangeRef.current?.(clamped);\n requestRedraw();\n }, [requestRedraw, dimsRef, isControlledRef, onViewChangeRef, viewBoundsRef]);\n\n const getView = useCallback(() => viewRef.current, []);\n const subscribeView = useCallback((fn: (v: View) => void) => {\n viewSubsRef.current.add(fn);\n return () => { viewSubsRef.current.delete(fn); };\n }, []);\n\n useLayoutEffect(() => {\n const element = canvasRef.current;\n if (!element) return;\n return registerMountedCanvas({ element, getView });\n }, [detached, inputElement, getView]);\n\n // The painted tier's channel. `<Canvas>` owns it because it owns both ends:\n // the tool cursor that feeds it and the frame loop that has to repaint when\n // it changes. The hover pump reaches it through the ref handle below.\n const paintedCursor = useMemo<PaintedCursorState>(() => createPaintedCursorState(), []);\n const paintedCursorLayer = useMemo(\n () => createPaintedCursorLayer(paintedCursor),\n [paintedCursor],\n );\n // An idle pointermove repaints nothing on its own, so a cursor the compositor\n // is not drawing needs its own pump. The store stays quiet unless something\n // painted is actually on screen.\n useEffect(() => paintedCursor.subscribe(() => { requestRedraw(); }), [paintedCursor, requestRedraw]);\n\n const getSurfaceRect = useCallback(() => {\n const origin = paintRectRef.current;\n const { width: w, height: h } = dimsRef.current;\n return { x: origin?.x ?? 0, y: origin?.y ?? 0, width: w, height: h };\n }, [dimsRef, paintRectRef]);\n\n useImperativeHandle(ref, () => ({\n // Named rather than read off `canvasRef` so the handle rebuilds when a\n // detached surface's input element arrives, which is a render later.\n element: detached ? inputElement ?? null : canvasRef.current,\n surface: detached ? paintInto?.canvas ?? null : ownCanvasRef.current,\n getSurfaceRect,\n requestRedraw,\n subscribeFrame,\n subscribeBeforePaint,\n registerLayer,\n hitTestExtras,\n getView,\n setView,\n subscribeView,\n getPaintedVersion,\n paintedCursor,\n getDebug,\n }), [canvasRef, ownCanvasRef, detached, inputElement, paintInto?.canvas,\n getSurfaceRect, requestRedraw, subscribeFrame, subscribeBeforePaint, registerLayer,\n hitTestExtras, getView, setView, subscribeView, getPaintedVersion,\n paintedCursor, getDebug]);\n\n // Created on the first paint, rebuilt when the paint target moves, and\n // freed on unmount.\n const lease = useCanvasRenderer();\n const layerCacheRef = useRef<LayerCommandCache>(new Map());\n\n // Views registered on this surface — declared as `views` descriptors or\n // mounted as `<CanvasView>` children. Null outside a surface that mounts a\n // registry, which is the single-view case.\n const viewRegistry = useOptionalViewRegistry();\n\n // Internal hooks always run (rules of hooks). They consult a noop adapter\n // when none is supplied; their controllers are then unused because the\n // gesture wiring below only enables move/resize when `adapter` is present.\n const noopAdapter = useMemo(\n () =>\n ({\n getPose: () => ({}) as TPose,\n getNodes: () => [],\n }) as unknown as MoveAdapter<TNode, TPose>\n & ResizeAdapter<TNode, TPose>\n & RotateAdapter<TNode, TPose>,\n [],\n );\n const effectiveAdapter = (adapter ?? noopAdapter) as MoveAdapter<TNode, TPose>\n & ResizeAdapter<TNode, TPose>\n & RotateAdapter<TNode, TPose>;\n\n // Canvas owns no selection state. The `selection` prop is the sole source.\n // When absent, behave as if no selection exists (no chrome, no overlay).\n // A no-op fallback keeps all downstream reads safe without branching.\n const noopSelection = useMemo<SelectionApi>(\n () => ({\n current: [],\n get: () => [],\n contains: () => false,\n set: () => {},\n add: () => {},\n remove: () => {},\n toggle: () => {},\n clear: () => {},\n applyClick: () => {},\n adapterMethods: {\n getSelection: () => [],\n setSelection: () => {},\n },\n }),\n [],\n );\n const effectiveSelection: SelectionApi = selection ?? noopSelection;\n\n // Base ctx for the function form of `Tool.cursor` — the last consumer of\n // `ToolCtx` now that the tool-routing dispatcher is gone. The cursor is\n // resolved during render, so the ctx carries this render's values; only\n // `applyOps`, which a cursor function could call later, reads a ref.\n const effectiveAdapterRef = useLatest(effectiveAdapter);\n const clientToWorldRef = useLatest(clientToWorld);\n const toolsCtxBase = () => {\n const view = controlledView ?? viewRef.current;\n const c = detached ? inputElement ?? null : canvasRef.current;\n const rect = c ? c.getBoundingClientRect() : (typeof DOMRect !== 'undefined' ? new DOMRect() : ({ x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 } as DOMRect));\n return {\n worldX: 0,\n worldY: 0,\n modifiers: { alt: false, shift: false, meta: false, ctrl: false },\n selection: effectiveSelection,\n adapter: effectiveAdapter,\n applyOps: (ops: Op[], label: string) => {\n dispatchApplyBatch(effectiveAdapterRef.current, ops, label);\n },\n view,\n setView,\n canvasRect: rect,\n debug: debugSink ?? undefined,\n };\n };\n\n // Stable wrappers for HUD props — read the ref at call time so the HUDs\n // don't reinstall their useEffect on every render when the prop identity\n // changes (e.g. when SceneCanvas re-renders with a new lambda reference).\n // pickEvery and pickBest are HUD-only.\n const pickEveryRef = useLatest(pickEvery);\n const pickBestRef = useLatest(pickBest);\n const stablePickEveryForHud = useCallback(\n (wx: number, wy: number): readonly string[] => {\n const pe = pickEveryRef.current;\n if (!pe) return [];\n const raw = pe(wx, wy);\n if (!raw) return [];\n return Array.isArray(raw) ? raw : [raw];\n },\n [pickEveryRef],\n );\n const stablePickBestForHud = useCallback(\n (wx: number, wy: number): string | null => pickBestRef.current?.(wx, wy) ?? null,\n [pickBestRef],\n );\n // Selection-driven action gestures (delete/nudge/undoRedo/duplicate) used\n // to be wired here via legacy hooks. They now go through the Actions\n // Registry / dispatcher path; consumers register them via the kit's\n // standard descriptors (see `useStandardActions`).\n\n const selectedIdsForWiring = effectiveSelection.current;\n\n // One view's overlay-aware state. A hook, so N views are N components each\n // calling it once — not a loop in this body.\n const {\n helpers: viewHelpers,\n chromeState: viewChromeState,\n effectiveBoundsOf,\n previewExtraRef,\n } = useViewHelpers<TPose>({\n adapter,\n geometry,\n boundsOf,\n boundsOfPose,\n selection: selectedIdsForWiring,\n tools,\n gestureSource,\n previewPoseExtra,\n previewIdsExtra,\n getIsVisible: () => getIsVisibleRef.current?.() ?? alwaysVisible,\n });\n\n // The affordance-layer hit-test used to be wired into the tool-routing\n // dispatcher from here, so its pointerdown could walk tool overlays\n // top-down. `<SceneCanvas>` now composes the equivalent walk into the\n // `affordanceAt` thunk it hands `useGestureDispatcher` — over registered\n // layers via `hitTestExtras` above, and over selection chrome itself.\n\n const surfaceHelpers: CanvasSurfaceHelpers = {\n getDebug: () => debugSink,\n };\n const helpersForLayers: CanvasHelpers<TPose> = { ...viewHelpers, ...surfaceHelpers, viewId: null };\n\n // Pointer-pressed flag. The only thing `<Canvas>` still needs to know about\n // pointer state: `onUncapturedMove` means \"hover\", so it stands down while a\n // button is held. Everything else about pointer input — thresholds, click and\n // double-click synthesis, drag handles, the document-level backstop for a\n // release that lands off-canvas — belongs to `useGestureDispatcher`, which\n // attaches its own listeners to this same element.\n const pointerDownRef = useRef(false);\n\n const handlePointerDown = (e: React.PointerEvent<HTMLCanvasElement>) => {\n if (autoFocusOnPointerDown) e.currentTarget.focus();\n pointerDownRef.current = true;\n };\n const handlePointerMove =\n ((e: React.PointerEvent<HTMLCanvasElement>) => {\n // Dispatch onUncapturedMove to layers when no button is held.\n if (pointerDownRef.current) return;\n const c = e.currentTarget;\n const view = viewRef.current;\n const [worldX, worldY] = toWorld(c, e.clientX, e.clientY, view, clientToWorldRef.current);\n for (const layer of layersWithDebug) {\n layer.onUncapturedMove?.(worldX, worldY, e.nativeEvent, view, { width, height });\n }\n });\n const handlePointerLeave = (_e: React.PointerEvent<HTMLCanvasElement>) => {\n pointerDownRef.current = false;\n for (const layer of layersWithDebug) layer.onUncapturedLeave?.();\n };\n const handlePointerUp = (_e: React.PointerEvent<HTMLCanvasElement>) => {\n pointerDownRef.current = false;\n };\n const handlePointerCancel = undefined;\n\n // Background-fill layer: screen-space, emits a single full-canvas rect with\n // the configured FillStyle. Drawn beneath every other layer.\n // Independent of pan / zoom — backgrounds are canvas chrome, not world content.\n const backgroundLayer = useMemo<RenderLayer<unknown> | null>(() => {\n if (!backgroundFill) return null;\n return {\n id: 'scene-background-fill',\n label: 'Background fill',\n space: 'screen',\n draw: (_data, _view, dims) => [{\n kind: 'path',\n path: { kind: 'rect', x: 0, y: 0, width: dims.width, height: dims.height },\n fill: backgroundFill,\n }],\n };\n }, [backgroundFill]);\n\n const layers = useMemo<RenderLayer<unknown>[]>(() => {\n const standardLayers: Partial<\n Record<(typeof STANDARD_SLOTS)[number], RenderLayer<unknown>>\n > = {};\n\n const grid = layersMap.grid;\n if (isCustomEntry(grid)) standardLayers.grid = grid.layer;\n const cellHighlight = layersMap.cellHighlight;\n if (isCustomEntry(cellHighlight)) standardLayers.cellHighlight = cellHighlight.layer;\n\n const sceneCfg = layersMap.scene as SceneSlotConfig<TNode, TPose> | null | undefined;\n let sceneLayers: Array<{ key: string; layer: RenderLayer<unknown> }> | undefined;\n if (\n sceneCfg &&\n !isCustomEntry(sceneCfg) &&\n (sceneCfg as SceneSlotConfig<TNode, TPose>).drawOne\n ) {\n sceneLayers = buildSceneLayers<TNode, TPose>(\n sceneCfg,\n adapter,\n debugSink,\n effectiveBoundsOf,\n () => {\n const ids = aggregatePreviewIds(tools);\n const extra = previewExtraRef.current.previewIdsExtra?.();\n if (extra) {\n for (const id of extra) ids.add(id);\n }\n return ids.size > 0 ? ids : null;\n },\n );\n }\n\n const selSlot = layersMap.selectionOverlay as\n | SelectionOverlaySlotConfig<TPose>\n | CustomLayerEntry\n | null\n | undefined;\n if (isCustomEntry(selSlot)) {\n // Pre-built layer (e.g. from SceneCanvas) — pass through directly.\n standardLayers.selectionOverlay = selSlot.layer;\n } else if (selSlot !== null) {\n const cfg = (selSlot ?? {}) as SelectionOverlaySlotConfig<TPose>;\n standardLayers.selectionOverlay = createSelectionOverlayLayer<TPose>({\n ...cfg,\n // A consumer-supplied pose lookup still needs the configured geometry\n // to project with; without one the layer reads bounds off the chrome\n // state and never calls either.\n ...(cfg.poseById\n ? { getPose: cfg.poseById, poseDescriptor: cfg.poseDescriptor ?? geometry }\n : {}),\n });\n }\n\n const out: RenderLayer<unknown>[] = composeOrderedLayers(\n layersMap, standardLayers, sceneLayers, backgroundLayer ?? undefined,\n );\n // Decoration layer: above scene, below tool overlay (per slot ordering doc).\n if (decorationLayer) out.push(decorationLayer);\n if (tools) {\n placeToolOverlays(out, standardLayers.selectionOverlay, tools.getActiveOverlays);\n }\n return out;\n }, [layersMap, adapter, effectiveBoundsOf, debugSink, tools, backgroundLayer,\n decorationLayer, geometry, previewExtraRef]);\n\n const viewRegistryVersion = useSyncExternalStore(\n useCallback((cb: () => void) => viewRegistry?.subscribe(cb) ?? (() => {}), [viewRegistry]),\n () => viewRegistry?.getVersion() ?? 0,\n () => 0,\n );\n\n // The stack a view paints through its own camera is this canvas's, before\n // the views themselves are folded in — otherwise a view would contain\n // itself. Published by reference and read at draw time.\n const surfaceLayersRef = useLatest<readonly RenderLayer<unknown>[]>(layers);\n useEffect(() => {\n viewRegistry?.attachSurface({\n origin: () => {\n const c = canvasRef.current;\n if (!c) return { left: 0, top: 0 };\n const r = c.getBoundingClientRect();\n return { left: r.left, top: r.top };\n },\n view: () => viewRef.current,\n dims: () => dimsRef.current,\n layers: () => surfaceLayersRef.current,\n requestRedraw,\n chromeState: () => helpersForLayersRef.current!.getChromeState(),\n hitTestExtras: hitTestExtrasIn,\n claimsAbove: (x, y) => {\n const view = viewRef.current;\n return hitTestExtrasIn(\n view.x + x / view.scale.x, view.y + y / view.scale.y,\n view, dimsRef.current, helpersForLayersRef.current,\n ) !== null;\n },\n });\n }, [viewRegistry, canvasRef, requestRedraw, hitTestExtrasIn, dimsRef, surfaceLayersRef]);\n\n // Append the debug overlay layer at the very top of the stack when debug\n // is enabled. The layer reads from `debugSink.snapshot()` and paints in\n // screen space.\n const layersWithDebug = useMemo(() => {\n // Views paint through the surface's own stack, so they sit above it and\n // below both the debug overlay and externally-registered layers.\n const withViews = viewRegistry\n ? [...layers, ...viewRegistry.list().filter((r) => r.paint).map((r) => r.layer as RenderLayer<unknown>)]\n : layers;\n const base = debugSink && resolvedDebugConfig\n ? [...withViews, createDebugOverlayLayer({ sink: debugSink, config: resolvedDebugConfig })]\n : withViews;\n // The cursor goes last: it is the one thing that is always in front of\n // everything, including a consumer's own registered layers.\n return [...base, ...extrasRef.current, paintedCursorLayer];\n // extrasVersion drives re-reads of extrasRef when layers are registered/detached;\n // viewRegistryVersion does the same for registered views.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layers, debugSink, resolvedDebugConfig, extrasVersion, viewRegistry, viewRegistryVersion,\n paintedCursorLayer]);\n\n useEffect(() => {\n const redraw = (): void => { requestRedraw(); };\n const offs: (() => void)[] = [];\n for (const layer of layersWithDebug) if (layer.subscribe) offs.push(layer.subscribe(redraw));\n return () => { for (const off of offs) off(); };\n }, [layersWithDebug, requestRedraw]);\n\n useRedrawOn(redrawOn, requestRedraw);\n\n const shaderIdKey = shaders?.map((h) => h.id).join('|') ?? '';\n\n // Everything the paint, hit-testing and the view registry read that a React\n // render owns. `useLatest` and the insertion effect below publish committed\n // renders only, ahead of every layout effect in the commit, any of which may\n // ask for a sync paint.\n const paintInputs = {\n layers: layersWithDebug, width, height, debugSink,\n frameStats: resolvedDebugConfig?.fps === true,\n dpr: dprProp, layerVisibility, layerOrder, layerGroups, shaders,\n flattenTolerance,\n };\n const paintInputsRef = useLatest(paintInputs);\n useInsertionEffect(() => {\n if (controlledView) viewRef.current = controlledView;\n helpersForLayersRef.current = helpersForLayers;\n if (helpersRef) helpersRef.current = helpersForLayers;\n if (debugSinkRef) debugSinkRef.current = debugSink;\n });\n\n const paint = useCallback((): boolean => {\n const c = paintTargetRef.current ?? ownCanvasRef.current;\n if (!c) return false;\n const rect = paintRectRef.current;\n const {\n layers: paintLayers, width: w, height: h, debugSink: sink, frameStats,\n dpr: dprIn, layerVisibility: vis, layerOrder: order,\n flattenTolerance: paintFlattenTolerance,\n layerGroups: groups, shaders: paintShaders,\n } = paintInputsRef.current;\n\n // Clear sink at the top of every paint so per-frame records don't leak.\n sink?.beginFrame();\n if (sink) {\n for (let i = 0; i < paintLayers.length; i++) {\n const layer = paintLayers[i];\n if (layer.id === 'debug-overlay') continue;\n sink.recordLayer(layer.id, layer.label, layer.space ?? 'world', i);\n }\n }\n\n const renderer = lease.bind(c, { width: w, height: h, dpr: dprIn }, {\n tile: rect,\n flattenTolerance: paintFlattenTolerance,\n shaders: paintShaders,\n });\n // jsdom or unsupported environment: no WebGL2, nothing to paint.\n if (!renderer) return false;\n\n const view = viewRef.current;\n const spans: LayerDrawSpan[] | undefined = sink && frameStats ? [] : undefined;\n const paintT0 = spans ? performance.now() : 0;\n const commands = drawLayers(\n paintLayers,\n helpersForLayersRef.current,\n vis ?? NO_LAYER_VISIBILITY,\n order,\n view,\n { width: w, height: h },\n layerCacheRef.current,\n undefined,\n groups,\n spans,\n );\n renderer.render(commands, viewToMat3(view), spans ? { spans } : undefined);\n if (sink && spans) sink.recordFrame(frameStatsOf(spans, renderer.lastFrameStats(), performance.now() - paintT0));\n paintedVersionRef.current = contentVersionRef.current?.() ?? 0;\n return true;\n }, [contentVersionRef, lease, paintInputsRef, paintRectRef, paintTargetRef]);\n useInsertionEffect(() => {\n paintRef.current = paint;\n });\n\n // A tripwire, not a list of values this effect uses: every paint input that\n // arrives on a render must appear here, or changing it paints stale.\n // `viewChromeState` stands in for the whole overlay-aware set the layer\n // helpers expose — it re-memoizes on exactly the selection, bounds and\n // preview inputs they read. What moves between renders instead (a scene\n // write, a gesture pump, a late image decode) pushes its own redraw.\n // Layout, not passive, so a `syncPaint` surface lands its pixels in the same\n // commit as the DOM.\n useLayoutEffect(() => {\n requestRedraw();\n }, [layersWithDebug, width, height, viewProp, debugSink, dprProp, flattenTolerance,\n layerVisibility, layerOrder, layerGroups, shaderIdKey, syncPaint,\n viewChromeState, getIsVisible, paintTarget, paintRect?.x, paintRect?.y, requestRedraw]);\n\n useEffect(() => {\n const layerCache = layerCacheRef.current;\n const viewSubs = viewSubsRef.current;\n return () => {\n layerCache.clear();\n viewSubs.clear();\n };\n }, []);\n\n useEffect(() => {\n if (!shaderIdKey) return;\n const ids = shaderIdKey.split('|');\n let seen = ids.map(getProgramSource);\n return programSourceRegistry.subscribe(() => {\n const now = ids.map(getProgramSource);\n const changed = now.some((src, i) => src !== seen[i]);\n seen = now;\n if (changed) requestRedraw();\n });\n }, [shaderIdKey, requestRedraw]);\n\n // Resolved during render, so it reads this render's view, not the ref's\n // last committed one.\n const toolsCursorTier = tools\n ? resolveToolsCursor(tools, toolsCtxBase)\n : undefined;\n // A painted tool cursor gets `none` here and the layer draws it instead.\n const toolsCursor =\n toolsCursorTier === undefined\n ? undefined\n : toolsCursorTier.kind === 'css'\n ? toolsCursorTier.css\n : 'none';\n const effectiveStyle: React.CSSProperties | undefined = toolsCursor\n ? { ...style, cursor: toolsCursor }\n : style;\n const toolsPainted: PaintedCursor | null =\n toolsCursorTier?.kind === 'painted' ? toolsCursorTier : null;\n // Keyed on the value, not the object: the tier is rebuilt every render, and\n // publishing from render would notify a repaint mid-render.\n const toolsPaintedKey = toolsPainted\n ? `${toolsPainted.glyph}|${toolsPainted.angle}|${toolsPainted.size}|${toolsPainted.worldRadius}`\n : '';\n useEffect(() => {\n paintedCursor.setBase(toolsPainted);\n // `toolsPainted` is a fresh object each render; the key is its identity.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paintedCursor, toolsPaintedKey]);\n\n // Detached: the four handlers below are declared as JSX props on an element\n // this component no longer renders, so attach them to the caller's instead.\n // Everything else about pointer input already attaches to `canvasRef`, which\n // is that same element.\n const layersForMoveRef = useLatest(layersWithDebug);\n useEffect(() => {\n if (!detached || !inputElement) return;\n const el = inputElement;\n const onDown = (): void => {\n if (autoFocusOnPointerDown) el.focus();\n pointerDownRef.current = true;\n };\n const onMove = (e: PointerEvent): void => {\n if (pointerDownRef.current) return;\n const view = viewRef.current;\n const [worldX, worldY] = toWorld(\n el, e.clientX, e.clientY, view, clientToWorldRef.current,\n );\n const dims = dimsRef.current;\n for (const layer of layersForMoveRef.current) {\n layer.onUncapturedMove?.(worldX, worldY, e, view, dims);\n }\n };\n const onUp = (): void => { pointerDownRef.current = false; };\n const onLeave = (): void => {\n pointerDownRef.current = false;\n for (const layer of layersForMoveRef.current) layer.onUncapturedLeave?.();\n };\n const onMenu = (e: Event): void => e.preventDefault();\n el.addEventListener('pointerdown', onDown);\n el.addEventListener('pointermove', onMove);\n el.addEventListener('pointerup', onUp);\n el.addEventListener('pointerleave', onLeave);\n el.addEventListener('contextmenu', onMenu);\n return () => {\n el.removeEventListener('pointerdown', onDown);\n el.removeEventListener('pointermove', onMove);\n el.removeEventListener('pointerup', onUp);\n el.removeEventListener('pointerleave', onLeave);\n el.removeEventListener('contextmenu', onMenu);\n };\n }, [detached, inputElement, autoFocusOnPointerDown, clientToWorldRef, dimsRef, layersForMoveRef]);\n\n // The cursor is a tool's, but under `paintInto` it has no element of ours to\n // sit on. Written imperatively rather than by the caller, so a tool's cursor\n // keeps working without the caller mirroring tool state.\n useEffect(() => {\n if (!detached || !inputElement) return;\n inputElement.style.cursor = toolsCursor ?? '';\n }, [detached, inputElement, toolsCursor]);\n\n const huds = (\n <>\n {cursorCoordsHud && (\n <CursorCoordsHud\n canvasRef={canvasRef}\n {...(detached ? { anchorRef: canvasRef } : {})}\n viewRef={viewRef}\n />\n )}\n {pickHud && (\n <PickHud\n canvasRef={canvasRef}\n {...(detached ? { anchorRef: canvasRef } : {})}\n viewRef={viewRef}\n pickEvery={stablePickEveryForHud}\n pickBest={stablePickBestForHud}\n />\n )}\n {modalityHud && (\n <ModalityHud\n canvasRef={canvasRef}\n {...(detached ? { anchorRef: canvasRef } : {})}\n modeId={typeof modalityHud === 'object' ? modalityHud.modeId : undefined}\n />\n )}\n </>\n );\n\n // Detached: no element of our own, but the HUDs are DOM and still belong to\n // this pane. Held until the input element arrives — `useHostAnchor` resolves\n // its host on mount and again only when the panel or the window moves, so a\n // HUD mounted against a null host would latch off.\n if (detached) return inputElement ? huds : null;\n\n return (\n <>\n <canvas\n ref={setOwnCanvas}\n width={width}\n height={height}\n tabIndex={tabIndex}\n className={className}\n style={effectiveStyle}\n onFocus={onFocus}\n onBlur={onBlur}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerCancel}\n onPointerLeave={handlePointerLeave}\n // Suppress the browser's default right-click menu over the canvas.\n // Canvases are interaction surfaces; the browser's context menu\n // (Save Image / Inspect Element / etc.) is almost never what the\n // user wants, and right-click is a useful gesture surface that\n // tools may consume. Consumers using right-click for their own\n // gestures should add their own onContextMenu handler — calling\n // `e.preventDefault()` is the no-op default; calling something\n // else still works (this handler runs before the default menu).\n onContextMenu={(e) => e.preventDefault()}\n />\n {huds}\n </>\n );\n}\n\n/**\n * Forward-ref'd `<canvas>` wrapper. Generic over the object and pose types —\n * TypeScript will infer them from the `adapter` (or `move`/`resize`) prop.\n */\nexport const Canvas = forwardRef(CanvasInner) as <\n TNode extends { id: string } = { id: string },\n TPose = TNode,\n>(\n props: CanvasProps<TNode, TPose> & { ref?: React.ForwardedRef<CanvasExtensionApi> },\n) => ReturnType<typeof CanvasInner>;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,IAAME,MAAiB,MAAyB;AA4gBhD,SAAgBC,EACd,GACA,GACA,GACA,GACA,GAMA,GACsB;CACtB,IAAMC,IACJC,EAAI,YACF,MAAgBC,IAAUA,EAAQ,QAAQC,EAAI,EAAE,IAAKA,IACnDC,IAAUH,EAAI,SACdI,IAAcJ,EAAI,aAClBK,IAASL,EAAI,QACd,GAAqB,GAAY,MAClCM,EAAiBC,GAAMC,EAAWC,CAAI,GAAG;EAAE,GAAG;EAAG,GAAG;EAAG,OAAOC,EAAK;EAAO,QAAQA,EAAK;CAAO,CAAC,KAC9F,MAAuCH,GACtCI,IAAcX,EAAI,OAAOA,EAAI,cAAc,KAAA,GAC3CY,KAAY,GAAY,MAAeD,IACzCE,GAAgBF,GAAaF,GAAM;EAAE,GAAG;EAAG,GAAG;EAAG,OAAOC,EAAK;EAAO,QAAQA,EAAK;CAAO,CAAC,IACzF,KAAA;CACJ,OAAO;EACL,IAAII,GAAM,MAAM;EAChB,OAAOA,IAAO,UAAUA,EAAK,aAAa;EAC1C,OAAO,GAAO,GAAM,MAAS;GAC3B,IAAMC,IAASC,EAAQ,GACjBC,IAAIhB;GACV,IACEgB,KACAjB,EAAI,YAAY,KAAA,KAChB,OAAOiB,EAAE,aAAc,cACvB,OAAOA,EAAE,WAAY,cACrB,OAAOA,EAAE,eAAgB,cACzBd,GACA;IACA,IAAMe,KAAmB,GAAY,GAAa,MAA2B;KAC3E,IAAIH,KAAUA,EAAO,IAAIb,EAAI,EAAE,GAAG,OAAO,CAAC;KAC1C,IAAMK,IAAOJ,EAAQD,GAAKiB,GAAMC,CAAC;KACjC,IAAIC,GAAW;MACb,IAAMC,IAAIC,IAAaA,EAAWrB,EAAI,EAAE,IAAI;MAC5C,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SAAS,KAAA;EAChE,CAAA;CAEH,EAAA,CAAA;CASJ,OAFI/M,IAAiBE,IAAeuM,KAAO,OAGzC,mBAAAzR,IAAA,EAAA,UAAA,CACE,mBAAC,UAAD;EACE,KAAK8E;EACE;EACC;EACE;EACC;EACX,OAAOgM;EACE;EACD;EACR,eAAe/E;EACf,eAAeE;EACf,aAAaG;EACb,iBAAiB;EACjB,gBAAgBD;EAShB,gBAAgB,MAAM,EAAE,eAAe;CACxC,CAAA,GACAsF,EACD,EAAA,CAAA;AAEN;AAMA,IAAaQ,IAASC,GAAWzO,EAAW"}
@@ -0,0 +1,255 @@
1
+ import { normalizeView as e } from "../core/viewport/view.js";
2
+ import { createViewportLayer as t } from "../features/viewports/viewportLayer.js";
3
+ import { useDeviceProfile as n } from "../core/device/useDeviceProfile.js";
4
+ import { clientToWorld as r } from "../core/viewport/clientToWorld.js";
5
+ import { clampView as i } from "../core/viewport/clampView.js";
6
+ import { AUTO_POSE_DESCRIPTOR as a } from "../interactions/actions/resize/autoPoseDescriptor.js";
7
+ import { pathFromPlane as o } from "./planeClips.js";
8
+ import { createSceneLayerGate as s, paintedLayers as c } from "./sceneLayerPaint.js";
9
+ import { useViewHelpers as ee } from "./useViewHelpers.js";
10
+ import { IDENTITY_VIEW as l, UNMEASURED_DIMS as u, useOptionalViewRegistry as te } from "./viewRegistry.js";
11
+ import { useSelection as ne } from "../core/selection/useSelection.js";
12
+ import { useOptionalViewInputs as re } from "./viewInputs.js";
13
+ import { viewportWorldRect as ie } from "../core/viewport/viewportWorldRect.js";
14
+ import { anchorStateFrom as ae, buildAffordanceAt as oe, buildClassifyTarget as se } from "./affordanceAt.js";
15
+ import { createDispatcherPreviewSources as ce, createGestureSource as le } from "./SceneCanvas/dispatcherGestureBounds.js";
16
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as ue, useState as m } from "react";
17
+ import { useLatest as h } from "@weasel-js/react";
18
+ import { createDispatcher as de } from "@weasel-js/routing";
19
+ import { useOptionalDepRegistry as fe } from "@weasel-js/routing/react";
20
+ //#region src/canvas/CanvasView.tsx
21
+ var pe = {
22
+ adapter: void 0,
23
+ geometry: a,
24
+ boundsOf: void 0,
25
+ tools: void 0
26
+ }, me = () => !0, he = (e) => e;
27
+ function g(a) {
28
+ let { id: g, bounds: ge, view: _, defaultView: _e, onViewChange: ve, viewBounds: ye, layers: be = he, layerVisibility: xe, layerOrder: Se, background: v, order: y = Infinity, label: b, selection: Ce, selectionOptions: x, interactive: S = !0, paint: C = !0 } = a, w = te(), we = fe(), T = h(we), E = ne(x), D = Ce ?? (x ? E : void 0), [Te, Ee] = m(() => e(_e ?? l)), O = _ ?? Te, k = re(), A = D ?? k?.selectionApi ?? E, j = h({
29
+ view: O,
30
+ bounds: ge,
31
+ layers: be,
32
+ layerVisibility: xe,
33
+ layerOrder: Se,
34
+ onViewChange: ve,
35
+ viewBounds: ye,
36
+ viewProp: _,
37
+ viewSelection: D,
38
+ selection: A
39
+ }), M = d((e, t) => {
40
+ let n = j.current.bounds;
41
+ return typeof n == "function" ? n(e, t) : n;
42
+ }, [j]), N = d(() => {
43
+ let e = w?.surface();
44
+ return M(e?.view() ?? l, e?.dims() ?? u);
45
+ }, [w, M]), P = d((t, n) => {
46
+ let r = j.current.view;
47
+ return e(typeof r == "function" ? r(t, n) : r);
48
+ }, [j]), F = d(() => {
49
+ let e = w?.surface();
50
+ return P(e?.view() ?? l, e?.dims() ?? u);
51
+ }, [w, P]), I = d(() => c(w?.surface()?.layers() ?? [], j.current), [w, j]), [L] = m(s), R = d((e) => L(w?.surface()?.layers() ?? [], j.current)(e), [
52
+ w,
53
+ L,
54
+ j
55
+ ]), z = d((t) => {
56
+ let { viewBounds: n, onViewChange: r, viewProp: a } = j.current, o = N(), s = e(t), c = n ? i(s, n, {
57
+ width: o.w,
58
+ height: o.h
59
+ }) : s;
60
+ a === void 0 && Ee(c), r?.(c), w?.surface()?.requestRedraw();
61
+ }, [
62
+ w,
63
+ N,
64
+ j
65
+ ]), B = p(() => ({
66
+ get: F,
67
+ set: z,
68
+ hostSize: () => {
69
+ let e = N();
70
+ return {
71
+ width: e.w,
72
+ height: e.h
73
+ };
74
+ },
75
+ layerIsPainted: R
76
+ }), [
77
+ F,
78
+ N,
79
+ z,
80
+ R
81
+ ]), V = p(() => {
82
+ let e = () => T.current?.get("ingestion");
83
+ return {
84
+ viewportWorldRect: () => {
85
+ let e = N();
86
+ return ie(F(), {
87
+ width: e.w,
88
+ height: e.h
89
+ });
90
+ },
91
+ get resolveSrc() {
92
+ return e()?.resolveSrc;
93
+ },
94
+ get svg() {
95
+ return e()?.svg;
96
+ },
97
+ get clipboard() {
98
+ return e()?.clipboard;
99
+ }
100
+ };
101
+ }, [
102
+ F,
103
+ N,
104
+ T
105
+ ]), H = ue(null);
106
+ H.current ||= de();
107
+ let U = k?.rotationBadge ?? null, De = p(() => ({
108
+ gestureSource: le(() => H.current),
109
+ ...ce(() => H.current)
110
+ }), []), W = h(k), G = d(() => ({
111
+ selection: j.current.selection.get(),
112
+ view: F(),
113
+ action: H.current.getActiveAction()
114
+ }), [F, j]), K = k?.boundsOf, Oe = p(() => K ? (e) => K(e, F()) : void 0, [K, F]), q = k?.boundsOfPose, ke = p(() => q ? (e, t) => q(e, t, F()) : void 0, [q, F]), { helpers: Ae } = ee({
115
+ ...k ?? pe,
116
+ boundsOf: Oe,
117
+ boundsOfPose: ke,
118
+ ...De,
119
+ selection: A.current,
120
+ getIsVisible: () => W.current?.chromeCaps?.isVisible(G()) ?? me
121
+ }), J = h(Ae), Y = d((e, t) => {
122
+ let n = w?.surface()?.origin() ?? {
123
+ left: 0,
124
+ top: 0
125
+ }, i = N(), [a, o] = r(e, t, {
126
+ left: n.left + i.x,
127
+ top: n.top + i.y
128
+ }, F());
129
+ return {
130
+ x: a,
131
+ y: o
132
+ };
133
+ }, [
134
+ w,
135
+ N,
136
+ F
137
+ ]), X = p(() => ae(() => T.current, (e, t) => o(t, W.current?.planeOfNode?.(e, F()) ?? null)), [
138
+ F,
139
+ T,
140
+ W
141
+ ]), { targetScale: Z } = n(), Q = p(() => {
142
+ let e = oe({
143
+ getChromeState: () => J.current.getChromeState(),
144
+ getView: F,
145
+ targetScale: Z,
146
+ rotationBadge: U,
147
+ getAnchorState: X,
148
+ getIsVisible: () => J.current.getIsVisible()
149
+ });
150
+ return (t) => {
151
+ let n = N(), r = (w?.surface())?.hitTestExtras(t.x, t.y, F(), {
152
+ width: n.w,
153
+ height: n.h
154
+ }, J.current, I());
155
+ if (r) {
156
+ let e = r.hit;
157
+ return {
158
+ kind: `layer:${r.layerId}`,
159
+ owner: r.layerId,
160
+ strength: e.strength ?? "shared",
161
+ ...e.claimedKinds === void 0 ? {} : { claimedKinds: e.claimedKinds },
162
+ ...e.cursor === void 0 ? {} : { cursor: e.cursor },
163
+ ...e.initialScratch === void 0 ? {} : { payload: e.initialScratch }
164
+ };
165
+ }
166
+ return e(t);
167
+ };
168
+ }, [
169
+ X,
170
+ N,
171
+ w,
172
+ Z,
173
+ F,
174
+ I,
175
+ U,
176
+ J
177
+ ]), je = p(() => {
178
+ let e = se(() => j.current.selection.get(), (e, t) => {
179
+ let n = W.current, r = {
180
+ ...F(),
181
+ layerIsPainted: R
182
+ };
183
+ if (n?.pickBest) return n.pickBest(e, t, r);
184
+ let i = n?.pickEvery?.(e, t, r) ?? [];
185
+ return i.length > 0 ? i[i.length - 1] : null;
186
+ }, (e) => W.current?.kindOfNode?.(e));
187
+ return (t) => e(t);
188
+ }, [
189
+ F,
190
+ R,
191
+ j,
192
+ W
193
+ ]), $ = p(() => ({
194
+ id: g,
195
+ order: y,
196
+ interactive: S,
197
+ paint: C,
198
+ layer: t({
199
+ id: g,
200
+ label: b ?? g,
201
+ source: I,
202
+ view: P,
203
+ bounds: (e, t) => M(e, t),
204
+ data: (e) => ({
205
+ ...e,
206
+ ...J.current,
207
+ viewId: g
208
+ }),
209
+ ...v === void 0 ? {} : { background: v }
210
+ }),
211
+ layerIsPainted: R,
212
+ target: {
213
+ dispatcher: H.current,
214
+ affordanceAt: Q,
215
+ classifyTarget: je,
216
+ clientToWorld: Y,
217
+ deps: () => ({
218
+ view: B,
219
+ ingestion: V,
220
+ dispatcher: { cancelAll: (e) => H.current.cancelAll(e) },
221
+ ...j.current.viewSelection ? { selection: j.current.viewSelection } : {}
222
+ }),
223
+ getRuleCtx: () => W.current?.chromeCaps?.ruleCtx(G())
224
+ }
225
+ }), [
226
+ g,
227
+ y,
228
+ S,
229
+ C,
230
+ b,
231
+ v,
232
+ M,
233
+ P,
234
+ B,
235
+ Q,
236
+ je,
237
+ Y,
238
+ G,
239
+ V,
240
+ I,
241
+ R,
242
+ j,
243
+ W,
244
+ J
245
+ ]);
246
+ return f(() => {
247
+ if (w) return w.register($);
248
+ }, [w, $]), f(() => {
249
+ w?.surface()?.requestRedraw();
250
+ }, [w, O]), null;
251
+ }
252
+ //#endregion
253
+ export { g as CanvasView };
254
+
255
+ //# sourceMappingURL=CanvasView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanvasView.js","names":["NO_INPUTS","AUTO_POSE_DESCRIPTOR","ALWAYS_VISIBLE","ALL_LAYERS","s","CanvasView","viewProp","selectionProp","props","registry","useOptionalViewRegistry","depRegistry","useOptionalDepRegistry","depRegistryRef","useLatest","ownSelection","useSelection","selectionOptions","viewSelection","internalView","setInternalView","useState","normalizeView","defaultView","IDENTITY_VIEW","effectiveView","inputs","useOptionalViewInputs","selection","live","rectAt","useCallback","b","outer","dims","rectNow","surface","UNMEASURED_DIMS","cameraAt","v","camera","drawnLayers","paintedLayers","sceneLayerGate","createSceneLayerGate","layerIsPainted","layerId","setView","vb","cb","controlled","rect","valid","next","clamped","clampView","viewApi","useMemo","ingestionApi","base","viewportWorldRect","dispatcherRef","useRef","createDispatcher","rotationBadge","own","createGestureSource","createDispatcherPreviewSources","inputsRef","ruleInputs","surfaceBoundsOf","boundsOf","id","surfaceBoundsOfPose","boundsOfPose","pose","useViewHelpers","helpersRef","helpers","clientToWorldHere","canvas","x","y","clientToWorld","cx","cy","getAnchorState","anchorStateFrom","pathFromPlane","path","useDeviceProfile","affordanceAt","inner","buildAffordanceAt","extra","world","claim","targetScale","classifyTarget","buildClassifyTarget","i","frame","wx","wy","ids","registration","createViewportLayer","label","background","reason","order","interactive","paint","useEffect"],"sources":["../../src/canvas/CanvasView.tsx"],"sourcesContent":["/**\n * `<CanvasView>` — a second view on an existing canvas: its own camera over a\n * rect of the surface, with input routed to it.\n *\n * Mount one inside `<SceneCanvas>`, or declare the same thing through the\n * surface's `views` prop, which renders one of these per descriptor.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport { normalizeView, type View } from 'core/viewport/view';\nimport { clientToWorld } from 'core/viewport/clientToWorld';\nimport { clampView } from 'core/viewport/clampView';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport { createViewportLayer } from 'features/viewports/viewportLayer';\nimport { createDispatcher } from '@weasel-js/routing';\nimport type { IngestionDep, ViewApi } from 'interactions/actions/depSchema';\nimport { viewportWorldRect } from 'core/viewport/viewportWorldRect';\nimport { useSelection, type SelectionApi, type UseSelectionOptions } from 'core/selection/useSelection';\nimport { AUTO_POSE_DESCRIPTOR } from 'interactions/actions/resize/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { useViewHelpers } from './useViewHelpers';\nimport { anchorStateFrom, buildAffordanceAt, buildClassifyTarget } from './affordanceAt';\nimport { pathFromPlane } from './planeClips';\nimport { useOptionalDepRegistry } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport { useDeviceProfile } from 'core/device/useDeviceProfile';\nimport {\n createGestureSource,\n createDispatcherPreviewSources,\n} from './SceneCanvas/dispatcherGestureBounds';\nimport { useOptionalViewInputs, type SurfaceViewInputs, type ViewRuleInputs } from './viewInputs';\nimport { createSceneLayerGate, paintedLayers } from './sceneLayerPaint';\nimport {\n useOptionalViewRegistry,\n IDENTITY_VIEW,\n UNMEASURED_DIMS,\n type ViewRegistration,\n} from './viewRegistry';\n\n/** A rect on the surface, in CSS pixels from the canvas top-left. */\nexport interface ViewRect { x: number; y: number; w: number; h: number }\n\n/** Props for `<CanvasView>`. @experimental */\nexport interface CanvasViewProps {\n /** Identifies the view to the surface and to input routing. Must be unique\n * among the views on one canvas. */\n id: string;\n /** Where this view paints, recomputed every frame so the rect can track the\n * outer camera. A plain rect is accepted for a fixed panel. */\n bounds: ViewRect | ((outer: View, dims: Dims) => ViewRect);\n /** Camera. Supply this to control it; otherwise the view keeps its own,\n * seeded from `defaultView`. `onViewChange` fires either way.\n *\n * A thunk is a camera derived from the canvas's — a loupe following the\n * pointer — read fresh at every paint and every event, so the two cannot\n * disagree mid-gesture. It is controlled: a pan inside the view reaches\n * only `onViewChange`. */\n view?: View | ((outer: View, dims: Dims) => View);\n defaultView?: View;\n onViewChange?: (v: View) => void;\n /** Pan limits, applied to every camera change the same way `<Canvas>`\n * applies its own. */\n viewBounds?: Bounds;\n /** Which of the surface's layers this view paints. Defaults to all of them —\n * the same content through a second camera. */\n layers?: (surface: readonly RenderLayer<unknown>[]) => readonly RenderLayer<unknown>[];\n /**\n * Show or hide layers in this view only, by id — the map `<Canvas>` takes,\n * applied after `layers` narrows the stack. A scene layer paints as\n * `scene:<layerId>`; one hidden here neither paints nor picks in this view,\n * and a marquee or Cmd+A routed here passes over it. The surface and every\n * other view are unaffected.\n */\n layerVisibility?: Record<string, boolean>;\n /** Draw order for this view, by layer id, bottom first. A listed order is\n * the whole list, so a layer left out of it is neither painted nor picked\n * here. */\n layerOrder?: string[];\n /** Opaque ground painted before the source layers, so the surface does not\n * show through where the inner camera sees nothing. */\n background?: string;\n /** Paint and hit order. Defaults to `Infinity` — after every view the\n * surface declared as a prop. */\n order?: number;\n /** Label for debug overlays. Defaults to the id. */\n label?: string;\n /**\n * Whether input over the view resolves through its camera. Default `true`:\n * a press selects what the view shows, and a drag moves it in the view's\n * world units. `false` paints only, and input over it reaches the canvas\n * beneath as though the view were not there.\n *\n * Views do not nest. A view paints and routes the surface's own stack,\n * never another view; overlapping views are hit in paint order.\n */\n interactive?: boolean;\n /**\n * Whether the surface paints the view. Default `true`. `false` is for a\n * host that draws the view inside chrome of its own — a HUD window's\n * interior — through `SceneCanvasApi.addView`'s `draw`, so it lands in\n * that chrome's z-order rather than the surface's.\n */\n paint?: boolean;\n /** A selection of this view's own, which actions dispatched inside it read\n * and write instead of the surface's. Omit both this and\n * `selectionOptions` and the view shares the surface's selection — the\n * default, so undo restores one selection rather than N. */\n selection?: SelectionApi;\n /** Opts this view into owning a selection, configured thus. Ignored when\n * `selection` is supplied. */\n selectionOptions?: UseSelectionOptions;\n}\n\n/** What a view builds its helpers from outside a surface: nothing but the\n * default geometry, which answers `null` for every lookup. */\n// A view outside a surface has no inputs to inherit — including a selection,\n// so it falls back to owning one.\nconst NO_INPUTS: Omit<SurfaceViewInputs, 'selectionApi'> = {\n adapter: undefined,\n geometry: AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<unknown>,\n boundsOf: undefined,\n tools: undefined,\n};\n\nconst ALWAYS_VISIBLE = (): boolean => true;\n\nconst ALL_LAYERS = (s: readonly RenderLayer<unknown>[]): readonly RenderLayer<unknown>[] => s;\n\n/**\n * @experimental\n *\n * One view on a shared canvas. Owns a camera, contributes the viewport node\n * that paints it, and registers the dispatch record that sends gestures inside\n * its rect to that camera rather than to the canvas's.\n *\n * Renders nothing itself — it is a declaration, and the surface does the\n * drawing. Outside a surface that mounts a view registry it is inert.\n */\nexport function CanvasView(props: CanvasViewProps): null {\n const {\n id, bounds, view: viewProp, defaultView, onViewChange, viewBounds,\n layers = ALL_LAYERS, layerVisibility, layerOrder, background, order = Infinity, label,\n selection: selectionProp, selectionOptions, interactive = true, paint = true,\n } = props;\n\n const registry = useOptionalViewRegistry();\n const depRegistry = useOptionalDepRegistry();\n const depRegistryRef = useLatest(depRegistry);\n\n // Hooks run unconditionally; the owned selection goes unused unless this\n // view asked for one.\n const ownSelection = useSelection(selectionOptions);\n const viewSelection = selectionProp ?? (selectionOptions ? ownSelection : undefined);\n\n const [internalView, setInternalView] = useState<View>(() => normalizeView(defaultView ?? IDENTITY_VIEW));\n const effectiveView = viewProp ?? internalView;\n\n const inputs = useOptionalViewInputs();\n // The selection this view acts on: its own when it has one, the surface's\n // otherwise.\n const selection = viewSelection ?? inputs?.selectionApi ?? ownSelection;\n\n // Everything the registration reads is behind a ref: the registration object\n // is registered once and must not churn, but what it answers with has to be\n // the last committed render's.\n const live = useLatest({\n view: effectiveView, bounds, layers, layerVisibility, layerOrder, onViewChange, viewBounds, viewProp,\n viewSelection, selection,\n });\n\n const rectAt = useCallback((outer: View, dims: Dims): ViewRect => {\n const b = live.current.bounds;\n return typeof b === 'function' ? b(outer, dims) : b;\n }, [live]);\n\n /** The rect for the surface's current frame — what a client point and a\n * clamp are measured against outside a draw call. */\n const rectNow = useCallback((): ViewRect => {\n const surface = registry?.surface();\n return rectAt(surface?.view() ?? IDENTITY_VIEW, surface?.dims() ?? UNMEASURED_DIMS);\n }, [registry, rectAt]);\n\n const cameraAt = useCallback((outer: View, dims: Dims): View => {\n const v = live.current.view;\n return normalizeView(typeof v === 'function' ? v(outer, dims) : v);\n }, [live]);\n\n /** The camera for the surface's current frame. */\n const camera = useCallback((): View => {\n const surface = registry?.surface();\n return cameraAt(surface?.view() ?? IDENTITY_VIEW, surface?.dims() ?? UNMEASURED_DIMS);\n }, [registry, cameraAt]);\n\n /** The surface's layers this view draws, in the order it draws them. */\n const drawnLayers = useCallback((): readonly RenderLayer<unknown>[] => (\n paintedLayers(registry?.surface()?.layers() ?? [], live.current)\n ), [registry, live]);\n\n const [sceneLayerGate] = useState(createSceneLayerGate);\n /** What this view's picks, marquees and select-alls ask of a scene layer. */\n const layerIsPainted = useCallback((layerId: string): boolean => (\n sceneLayerGate(registry?.surface()?.layers() ?? [], live.current)(layerId)\n ), [registry, sceneLayerGate, live]);\n\n const setView = useCallback((next: View) => {\n const { viewBounds: vb, onViewChange: cb, viewProp: controlled } = live.current;\n const rect = rectNow();\n const valid = normalizeView(next);\n const clamped = vb ? clampView(valid, vb, { width: rect.w, height: rect.h }) : valid;\n if (controlled === undefined) setInternalView(clamped);\n cb?.(clamped);\n registry?.surface()?.requestRedraw();\n }, [registry, rectNow, live]);\n\n const viewApi = useMemo<ViewApi>(() => ({\n get: camera,\n set: setView,\n hostSize: () => {\n const rect = rectNow();\n return { width: rect.w, height: rect.h };\n },\n layerIsPainted,\n }), [camera, rectNow, setView, layerIsPainted]);\n\n // Paste placement is a camera question, so it is this view's when the paste\n // routed here. The rest of the dep — `resolveSrc`, `svg`, `clipboard` — is\n // the surface's one wiring, read live off the canvas registry.\n const ingestionApi = useMemo<IngestionDep>(() => {\n const base = (): IngestionDep | undefined => depRegistryRef.current?.get('ingestion');\n return {\n viewportWorldRect: () => {\n const rect = rectNow();\n return viewportWorldRect(camera(), { width: rect.w, height: rect.h });\n },\n get resolveSrc() { return base()?.resolveSrc; },\n get svg() { return base()?.svg; },\n get clipboard() { return base()?.clipboard; },\n };\n }, [camera, rectNow, depRegistryRef]);\n\n // One dispatcher per view: in-flight handles are per-view state, and two\n // views must not be able to see each other's.\n const dispatcherRef = useRef<ReturnType<typeof createDispatcher> | null>(null);\n if (!dispatcherRef.current) dispatcherRef.current = createDispatcher();\n\n // This view's overlay-aware state. The scene half comes from the surface —\n // same adapter, same tools — but everything gesture-shaped is read off this\n // view's own dispatcher, which is where a gesture inside this view lands.\n const rotationBadge = inputs?.rotationBadge ?? null;\n const own = useMemo(() => ({\n gestureSource: createGestureSource(() => dispatcherRef.current),\n ...createDispatcherPreviewSources(() => dispatcherRef.current),\n }), []);\n\n const inputsRef = useLatest(inputs);\n\n /** The chrome-caps context this view answers for: its selection, its camera,\n * its dispatcher's in-flight action. */\n const ruleInputs = useCallback((): ViewRuleInputs => ({\n selection: live.current.selection.get(),\n view: camera(),\n action: dispatcherRef.current!.getActiveAction(),\n }), [camera, live]);\n\n // The surface's resolver, asked for this view's camera.\n const surfaceBoundsOf = inputs?.boundsOf;\n const boundsOf = useMemo(\n () => (surfaceBoundsOf ? (id: string) => surfaceBoundsOf(id, camera()) : undefined),\n [surfaceBoundsOf, camera],\n );\n const surfaceBoundsOfPose = inputs?.boundsOfPose;\n const boundsOfPose = useMemo(\n () => (surfaceBoundsOfPose\n ? (id: string, pose: unknown) => surfaceBoundsOfPose(id, pose, camera())\n : undefined),\n [surfaceBoundsOfPose, camera],\n );\n\n const { helpers } = useViewHelpers<unknown>({\n ...(inputs ?? NO_INPUTS),\n boundsOf,\n boundsOfPose,\n ...own,\n selection: selection.current,\n getIsVisible: () =>\n inputsRef.current?.chromeCaps?.isVisible(ruleInputs()) ?? ALWAYS_VISIBLE,\n });\n const helpersRef = useLatest(helpers);\n\n /** A client point in this view's world. The rect moves with the outer\n * camera, so it is read per call rather than closed over. */\n const clientToWorldHere = useCallback((cx: number, cy: number): { x: number; y: number } => {\n const canvas = registry?.surface()?.origin() ?? { left: 0, top: 0 };\n const rect = rectNow();\n const [x, y] = clientToWorld(\n cx, cy,\n { left: canvas.left + rect.x, top: canvas.top + rect.y },\n camera(),\n );\n return { x, y };\n }, [registry, rectNow, camera]);\n\n // Anchors are hit in this view's camera world, where its plane draws them.\n const getAnchorState = useMemo(() => anchorStateFrom(\n () => depRegistryRef.current,\n (id, path) => pathFromPlane(path, inputsRef.current?.planeOfNode?.(id, camera()) ?? null),\n ), [camera, depRegistryRef, inputsRef]);\n\n const { targetScale } = useDeviceProfile();\n\n // Selection chrome hit-testing for this view: same construction the surface\n // does for its own, against this view's chrome and camera.\n const affordanceAt = useMemo(() => {\n const inner = buildAffordanceAt({\n getChromeState: () => helpersRef.current.getChromeState(),\n getView: camera,\n targetScale,\n rotationBadge,\n getAnchorState,\n getIsVisible: () => helpersRef.current.getIsVisible(),\n });\n return (world: { x: number; y: number }) => {\n // A registered layer this view paints gets first refusal, on this\n // view's frame and envelope. One painted over the surface already had\n // its chance: it occludes the view before routing reaches here.\n const rect = rectNow();\n const surface = registry?.surface();\n const extra = surface?.hitTestExtras(\n world.x, world.y, camera(), { width: rect.w, height: rect.h },\n helpersRef.current, drawnLayers(),\n );\n if (extra) {\n const claim = extra.hit;\n return {\n kind: `layer:${extra.layerId}`,\n owner: extra.layerId,\n strength: claim.strength ?? 'shared',\n ...(claim.claimedKinds !== undefined ? { claimedKinds: claim.claimedKinds } : {}),\n ...(claim.cursor !== undefined ? { cursor: claim.cursor } : {}),\n ...(claim.initialScratch !== undefined ? { payload: claim.initialScratch } : {}),\n };\n }\n return inner(world);\n };\n }, [getAnchorState, rectNow, registry, targetScale, camera, drawnLayers, rotationBadge, helpersRef]);\n\n const classifyTarget = useMemo(() => {\n const inner = buildClassifyTarget(\n () => live.current.selection.get(),\n (wx, wy) => {\n const i = inputsRef.current;\n // This view's camera: the dispatcher converted with `clientToWorldHere`,\n // and a screen-pixel tolerance needs the scale that produced it. The\n // layer gate is this view's too, never the surface's.\n const frame = { ...camera(), layerIsPainted };\n if (i?.pickBest) return i.pickBest(wx, wy, frame);\n const ids = i?.pickEvery?.(wx, wy, frame) ?? [];\n return ids.length > 0 ? ids[ids.length - 1]! : null;\n },\n (id) => inputsRef.current?.kindOfNode?.(id),\n );\n return (world: { x: number; y: number }) => inner(world);\n }, [camera, layerIsPainted, live, inputsRef]);\n\n const registration = useMemo<ViewRegistration>(() => ({\n id,\n order,\n interactive,\n paint,\n layer: createViewportLayer<unknown, unknown>({\n id,\n label: label ?? id,\n source: drawnLayers,\n view: cameraAt,\n bounds: (outer, dims) => rectAt(outer, dims),\n // The surface half of the envelope passes through; the view half is\n // this view's, so its layers paint its chrome rather than the\n // surface's.\n data: (outer) => ({ ...(outer as object), ...helpersRef.current, viewId: id }),\n ...(background !== undefined ? { background } : {}),\n }),\n layerIsPainted,\n target: {\n dispatcher: dispatcherRef.current!,\n affordanceAt,\n classifyTarget,\n clientToWorld: clientToWorldHere,\n deps: () => ({\n view: viewApi,\n ingestion: ingestionApi,\n // An Escape here cancels what is in flight here.\n dispatcher: { cancelAll: (reason) => dispatcherRef.current!.cancelAll(reason) },\n // Only a view with its own selection overlays that one; otherwise the\n // surface's answer stands, wrappers (`selectable`) included.\n ...(live.current.viewSelection ? { selection: live.current.viewSelection } : {}),\n }),\n // Action eligibility is chrome-caps evaluated against this view, so a\n // rule that hides an action in one panel cannot decline a gesture in\n // another.\n getRuleCtx: () => inputsRef.current?.chromeCaps?.ruleCtx(ruleInputs()),\n },\n }), [id, order, interactive, paint, label, background, rectAt, cameraAt, viewApi,\n affordanceAt, classifyTarget, clientToWorldHere, ruleInputs, ingestionApi, drawnLayers,\n layerIsPainted, live, inputsRef, helpersRef]);\n\n useEffect(() => {\n if (!registry) return;\n return registry.register(registration);\n }, [registry, registration]);\n\n // A camera change is invisible until the surface repaints, and nothing else\n // observes this component's state.\n useEffect(() => {\n registry?.surface()?.requestRedraw();\n }, [registry, effectiveView]);\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqHA,IAAMA,KAAqD;CACzD,SAAS,KAAA;CACT,UAAUC;CACV,UAAU,KAAA;CACV,OAAO,KAAA;AACT,GAEMC,WAAgC,IAEhCC,MAAc,MAAwEC;AAY5F,SAAgBC,EAAW,GAA8B;CACvD,IAAM,EACJ,OAAI,YAAQ,MAAMC,GAAU,iBAAa,kBAAc,gBACvD,aAASH,IAAY,qBAAiB,gBAAY,eAAY,WAAQ,UAAU,UAChF,WAAWI,IAAe,qBAAkB,iBAAc,IAAM,WAAQ,OACtEC,GAEEC,IAAWC,GAAwB,GACnCC,KAAcC,GAAuB,GACrCC,IAAiBC,EAAUH,EAAW,GAItCI,IAAeC,GAAaC,CAAgB,GAC5CC,IAAgBX,OAAkBU,IAAmBF,IAAe,KAAA,IAEpE,CAACI,IAAcC,MAAmBC,QAAqBC,EAAcC,MAAeC,CAAa,CAAC,GAClGC,IAAgBnB,KAAYa,IAE5BO,IAASC,GAAsB,GAG/BC,IAAYV,KAAiBQ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I,CAAE,CAC5C;EACA,QAAQ,MAAoCoB,EAAMG,CAAK;CACzD,GAAG;EAACvD;EAAQK;EAAgBhB;EAAMuC;CAAS,CAAC,GAEtCqC,IAAehD,SAAiC;EACpD;EACA;EACA;EACA;EACA,OAAOiD,EAAsC;GAC3C;GACA,OAAOC,KAASnC;GAChB,QAAQ/B;GACR,MAAMH;GACN,SAAS,GAAO,MAASR,EAAOG,GAAOC,CAAI;GAI3C,OAAO,OAAW;IAAE,GAAID;IAAkB,GAAG4C,EAAW;IAAS,QAAQL;GAAG;GAC5E,GAAIoC,MAAe,KAAA,IAA6B,CAAC,IAAlB,EAAE,cAAW;EAC9C,CAAC;EACD;EACA,QAAQ;GACN,YAAY/C,EAAc;GAC1B;GACA;GACA,eAAekB;GACf,aAAa;IACX,MAAMvB;IACN,WAAWE;IAEX,YAAY,EAAE,YAAY,MAAWG,EAAc,QAAS,UAAUgD,CAAM,EAAE;IAG9E,GAAIhF,EAAK,QAAQ,gBAAgB,EAAE,WAAWA,EAAK,QAAQ,cAAc,IAAI,CAAC;GAChF;GAIA,kBAAkBuC,EAAU,SAAS,YAAY,QAAQC,EAAW,CAAC;EACvE;CACF,IAAI;EAACG;EAAIsC;EAAOC;EAAaC;EAAOL;EAAOC;EAAY9E;EAAQQ;EAAUkB;EACpEmC;EAAcO;EAAgBnB;EAAmBV;EAAYX;EAAcjB;EAC3EI;EAAgBhB;EAAMuC;EAAWS;CAAU,CAAC;CAajD,OAXAoC,QAAgB;EACd,IAAKxG,GACL,OAAOA,EAAS,SAASgG,CAAY;CACvC,GAAG,CAAChG,GAAUgG,CAAY,CAAC,GAI3BQ,QAAgB;EACd,GAAU,QAAQ,CAAC,EAAE,cAAc;CACrC,GAAG,CAACxG,GAAUgB,CAAa,CAAC,GAErB;AACT"}
@@ -0,0 +1,75 @@
1
+ import { useVisibleRaf as e } from "../scheduling/useVisibleRaf.js";
2
+ import { clientToWorld as t } from "../core/viewport/clientToWorld.js";
3
+ import n from "./hud.module.js";
4
+ import { useHostAnchor as r } from "./useHostAnchor.js";
5
+ import { useEffect as i, useRef as a, useState as o } from "react";
6
+ import { jsxs as s } from "react/jsx-runtime";
7
+ //#region src/canvas/CursorCoordsHud.tsx
8
+ function c({ canvasRef: c, anchorRef: l, viewRef: u, offset: d }) {
9
+ let [f, p] = o({
10
+ client: {
11
+ x: 0,
12
+ y: 0
13
+ },
14
+ world: null,
15
+ inCanvas: !1
16
+ }), [m, h] = o(0), { ref: g, style: _ } = r(() => l?.current ?? c.current?.parentElement ?? c.current, {
17
+ align: {
18
+ x: "end",
19
+ y: "start"
20
+ },
21
+ offset: {
22
+ x: d?.right ?? 8,
23
+ y: d?.top ?? 8
24
+ }
25
+ }), v = a(0), y = a(0), b = e(() => {
26
+ v.current++;
27
+ let e = performance.now(), t = e - y.current;
28
+ t >= 1e3 && (h(Math.round(v.current * 1e3 / t)), v.current = 0, y.current = e), b.request();
29
+ }, { onResume: () => {
30
+ v.current = 0, y.current = performance.now();
31
+ } });
32
+ return i(() => (y.current = performance.now(), b.request(), () => b.cancel()), [b]), i(() => {
33
+ let e = (e) => {
34
+ let n = c.current, r = u.current, i = {
35
+ x: e.clientX,
36
+ y: e.clientY
37
+ };
38
+ if (!n || !r) {
39
+ p({
40
+ client: i,
41
+ world: null,
42
+ inCanvas: !1
43
+ });
44
+ return;
45
+ }
46
+ let a = n.getBoundingClientRect(), o = e.clientX >= a.left && e.clientX <= a.right && e.clientY >= a.top && e.clientY <= a.bottom, [s, l] = t(e.clientX, e.clientY, a, r);
47
+ p({
48
+ client: i,
49
+ world: {
50
+ x: s,
51
+ y: l
52
+ },
53
+ inCanvas: o
54
+ });
55
+ };
56
+ return document.addEventListener("pointermove", e), () => {
57
+ document.removeEventListener("pointermove", e);
58
+ };
59
+ }, [c, u]), _ ? /* @__PURE__ */ s("div", {
60
+ ref: g,
61
+ className: `${n.hud} ${n.pre}`,
62
+ style: _,
63
+ children: [
64
+ `fps ${m.toString().padStart(3)}`,
65
+ "\n",
66
+ `client (${f.client.x.toFixed(0)}, ${f.client.y.toFixed(0)})`,
67
+ "\n",
68
+ f.world ? `world (${f.world.x.toFixed(1)}, ${f.world.y.toFixed(1)})${f.inCanvas ? "" : " (off-canvas)"}` : "world — (no canvas/view yet)"
69
+ ]
70
+ }) : null;
71
+ }
72
+ //#endregion
73
+ export { c as CursorCoordsHud };
74
+
75
+ //# sourceMappingURL=CursorCoordsHud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CursorCoordsHud.js","names":["s","hud_module_default","CursorCoordsHud","state","setState","useState","fps","setFps","anchorStyle","useHostAnchor","anchorRef","canvasRef","offset","framesRef","useRef","lastFlushRef","fpsLoop","useVisibleRaf","now","dt","useEffect","onMove","canvas","view","viewRef","client","rect","inCanvas","wx","wy","clientToWorld"],"sources":["../../src/canvas/CursorCoordsHud.tsx"],"sourcesContent":["/**\n * Fixed-position dev HUD that shows the cursor's current viewport\n * (client) coords next to the equivalent canvas (world) coords. Mounts\n * top-left of the viewport; listens to `document` pointermove so it\n * reads the cursor even when it leaves the canvas.\n *\n * Mount inside a `<SceneCanvas>` subtree (or anywhere with access to a\n * canvas + view ref) for quick coord-reconciliation during gesture\n * debugging.\n */\nimport { useEffect, useRef, useState } from 'react';\nimport { useVisibleRaf } from '../scheduling/useVisibleRaf';\nimport s from './hud.module.css';\nimport { useHostAnchor } from './useHostAnchor';\nimport type { View } from 'core/viewport/view';\nimport { clientToWorld } from 'core/viewport/clientToWorld';\n\n/** Props for `<CursorCoordsHud>`. */\nexport interface CursorCoordsHudProps {\n canvasRef: React.RefObject<HTMLElement | null>;\n /** Element the HUD pins its corner to. Defaults to the canvas's parent — the\n * wrapper a bare `<canvas>` sits in. A detached canvas passes its own input\n * box, whose parent is the shared surface every pane sits in. */\n anchorRef?: React.RefObject<HTMLElement | null>;\n viewRef: React.RefObject<View>;\n /** Inset from the canvas's top-right corner, in px. Default 8 on both axes. */\n offset?: { top?: number; right?: number };\n}\n\ninterface HudState {\n client: { x: number; y: number };\n world: { x: number; y: number } | null;\n inCanvas: boolean;\n}\n\n/** Debug overlay showing the pointer's client and world coordinates and the\n * current frame rate, pinned to the canvas's top-right corner. */\nexport function CursorCoordsHud({ canvasRef, anchorRef, viewRef, offset }: CursorCoordsHudProps) {\n const [state, setState] = useState<HudState>({\n client: { x: 0, y: 0 }, world: null, inCanvas: false,\n });\n const [fps, setFps] = useState<number>(0);\n const { ref, style: anchorStyle } = useHostAnchor(\n () => anchorRef?.current ?? canvasRef.current?.parentElement ?? canvasRef.current,\n {\n align: { x: 'end', y: 'start' },\n offset: { x: offset?.right ?? 8, y: offset?.top ?? 8 },\n },\n );\n\n // FPS counter: tally frames per rAF tick; flush once a second.\n const framesRef = useRef(0);\n const lastFlushRef = useRef(0);\n const fpsLoop = useVisibleRaf(\n () => {\n framesRef.current++;\n const now = performance.now();\n const dt = now - lastFlushRef.current;\n if (dt >= 1000) {\n setFps(Math.round((framesRef.current * 1000) / dt));\n framesRef.current = 0;\n lastFlushRef.current = now;\n }\n fpsLoop.request();\n },\n // Frames not drawn while hidden are not frames that were slow to draw:\n // without this the readout would flush a near-zero rate on resume.\n {\n onResume: () => {\n framesRef.current = 0;\n lastFlushRef.current = performance.now();\n },\n },\n );\n\n useEffect(() => {\n lastFlushRef.current = performance.now();\n fpsLoop.request();\n return () => fpsLoop.cancel();\n }, [fpsLoop]);\n\n useEffect(() => {\n const onMove = (e: PointerEvent) => {\n const canvas = canvasRef.current;\n const view = viewRef.current;\n const client = { x: e.clientX, y: e.clientY };\n if (!canvas || !view) {\n setState({ client, world: null, inCanvas: false });\n return;\n }\n const rect = canvas.getBoundingClientRect();\n const inCanvas =\n e.clientX >= rect.left && e.clientX <= rect.right &&\n e.clientY >= rect.top && e.clientY <= rect.bottom;\n const [wx, wy] = clientToWorld(e.clientX, e.clientY, rect, view);\n const world = { x: wx, y: wy };\n setState({ client, world, inCanvas });\n };\n\n document.addEventListener('pointermove', onMove);\n\n return () => {\n document.removeEventListener('pointermove', onMove);\n };\n }, [canvasRef, viewRef]);\n\n if (!anchorStyle) return null;\n\n return (\n <div\n ref={ref}\n className={`${s.hud} ${s.pre}`}\n style={anchorStyle}\n >\n {`fps ${fps.toString().padStart(3)}`}\n {'\\n'}\n {`client (${state.client.x.toFixed(0)}, ${state.client.y.toFixed(0)})`}\n {'\\n'}\n {state.world\n ? `world (${state.world.x.toFixed(1)}, ${state.world.y.toFixed(1)})${state.inCanvas ? '' : ' (off-canvas)'}`\n : 'world — (no canvas/view yet)'}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAqCA,SAAgBE,EAAgB,EAAE,cAAW,cAAW,YAAS,aAAgC;CAC/F,IAAM,CAACC,GAAOC,KAAYC,EAAmB;EAC3C,QAAQ;GAAE,GAAG;GAAG,GAAG;EAAE;EAAG,OAAO;EAAM,UAAU;CACjD,CAAC,GACK,CAACC,GAAKC,KAAUF,EAAiB,CAAC,GAClC,EAAE,QAAK,OAAOG,MAAgBC,QAC5BC,GAAW,WAAWC,EAAU,SAAS,iBAAiBA,EAAU,SAC1E;EACE,OAAO;GAAE,GAAG;GAAO,GAAG;EAAQ;EAC9B,QAAQ;GAAE,GAAGC,GAAQ,SAAS;GAAG,GAAGA,GAAQ,OAAO;EAAE;CACvD,CACF,GAGMC,IAAYC,EAAO,CAAC,GACpBC,IAAeD,EAAO,CAAC,GACvBE,IAAUC,QACR;EACJ,EAAU;EACV,IAAMC,IAAM,YAAY,IAAI,GACtBC,IAAKD,IAAMH,EAAa;EAM9B,AALII,KAAM,QACRZ,EAAO,KAAK,MAAOM,EAAU,UAAU,MAAQM,CAAE,CAAC,GAClD,EAAU,UAAU,GACpB,EAAa,UAAUD,IAEzBF,EAAQ,QAAQ;CAClB,GAGA,EACE,gBAAgB;EAEd,AADA,EAAU,UAAU,GACpB,EAAa,UAAU,YAAY,IAAI;CACzC,EACF,CACF;CAmCA,OAjCAI,SACE,EAAa,UAAU,YAAY,IAAI,GACvCJ,EAAQ,QAAQ,SACHA,EAAQ,O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