@weasel-js/core 1.9.2 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (542) hide show
  1. package/CHANGELOG.md +393 -0
  2. package/README.md +2 -2
  3. package/dist/WeaselProvider.js +5 -5
  4. package/dist/affordances/composeAffordanceLayer.js +10 -20
  5. package/dist/affordances/composeAffordanceLayer.js.map +1 -1
  6. package/dist/affordances/cornerResize.js +25 -17
  7. package/dist/affordances/cornerResize.js.map +1 -1
  8. package/dist/affordances/hitAffordanceRegions.js +27 -20
  9. package/dist/affordances/hitAffordanceRegions.js.map +1 -1
  10. package/dist/affordances/rotationHandle.js +18 -18
  11. package/dist/affordances/rotationHandle.js.map +1 -1
  12. package/dist/animation/behaviors/momentum.js +93 -55
  13. package/dist/animation/behaviors/momentum.js.map +1 -1
  14. package/dist/animation/loop.js +10 -12
  15. package/dist/animation/loop.js.map +1 -1
  16. package/dist/animation/reflow.js +8 -8
  17. package/dist/animation/reflow.js.map +1 -1
  18. package/dist/animation/stagger.js +64 -56
  19. package/dist/animation/stagger.js.map +1 -1
  20. package/dist/animation/timeline/booking.js +62 -54
  21. package/dist/animation/timeline/booking.js.map +1 -1
  22. package/dist/animation/timeline/createTimeline.js +85 -76
  23. package/dist/animation/timeline/createTimeline.js.map +1 -1
  24. package/dist/animation/timeline/sampleTrack.js +13 -5
  25. package/dist/animation/timeline/sampleTrack.js.map +1 -1
  26. package/dist/animation/useAnimator.js +45 -35
  27. package/dist/animation/useAnimator.js.map +1 -1
  28. package/dist/animation/wrappers/animateLifecycle.js +31 -24
  29. package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
  30. package/dist/animation/wrappers/animateOnSetPose.js +28 -26
  31. package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
  32. package/dist/animation/wrappers/instantPose.js +13 -0
  33. package/dist/animation/wrappers/instantPose.js.map +1 -0
  34. package/dist/{poseDescriptor-D-OH-tu5.d.ts → autoPoseDescriptor-Ct7yqivU.d.ts} +28 -3
  35. package/dist/barrel/chrome.js +16 -0
  36. package/dist/barrel/input.js +19 -0
  37. package/dist/barrel/interactions.js +42 -0
  38. package/dist/barrel/paint.js +18 -0
  39. package/dist/barrel/paths.js +19 -0
  40. package/dist/barrel/renderer.js +20 -0
  41. package/dist/barrel/routing.js +51 -0
  42. package/dist/barrel/text.js +18 -0
  43. package/dist/barrel/viewport.js +52 -0
  44. package/dist/builtins-DPcdghtB.d.ts +1223 -0
  45. package/dist/canvas/Canvas.js +363 -448
  46. package/dist/canvas/Canvas.js.map +1 -1
  47. package/dist/canvas/CanvasView.js +164 -165
  48. package/dist/canvas/CanvasView.js.map +1 -1
  49. package/dist/canvas/CursorCoordsHud.js +37 -32
  50. package/dist/canvas/CursorCoordsHud.js.map +1 -1
  51. package/dist/canvas/DrawCanvas.js +49 -43
  52. package/dist/canvas/DrawCanvas.js.map +1 -1
  53. package/dist/canvas/MinimapCanvas.js +26 -25
  54. package/dist/canvas/MinimapCanvas.js.map +1 -1
  55. package/dist/canvas/NodeShape.js +59 -377
  56. package/dist/canvas/NodeShape.js.map +1 -1
  57. package/dist/canvas/PickHud.js +50 -47
  58. package/dist/canvas/PickHud.js.map +1 -1
  59. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +167 -0
  60. package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
  61. package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +13 -13
  62. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +67 -0
  63. package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
  64. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
  65. package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
  66. package/dist/canvas/SceneCanvas/coordTrace.js +10 -0
  67. package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
  68. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +146 -92
  69. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  70. package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
  71. package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
  72. package/dist/canvas/SceneCanvas/features.js +1 -0
  73. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  74. package/dist/canvas/SceneCanvas/isDev.js +12 -0
  75. package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
  76. package/dist/canvas/SceneCanvas/poseGeometry.js +29 -28
  77. package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
  78. package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
  79. package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
  80. package/dist/canvas/SceneCanvas/props.js +38 -0
  81. package/dist/canvas/SceneCanvas/props.js.map +1 -0
  82. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
  83. package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
  84. package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
  85. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +46 -48
  86. package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
  87. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +33 -33
  88. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  89. package/dist/canvas/SceneCanvas.js +534 -788
  90. package/dist/canvas/SceneCanvas.js.map +1 -1
  91. package/dist/canvas/SceneViewCanvas.js +45 -43
  92. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  93. package/dist/canvas/buildSceneLayer.js +91 -0
  94. package/dist/canvas/buildSceneLayer.js.map +1 -0
  95. package/dist/canvas/buildSceneTree.js +16 -19
  96. package/dist/canvas/buildSceneTree.js.map +1 -1
  97. package/dist/canvas/canvasRenderer.js +68 -52
  98. package/dist/canvas/canvasRenderer.js.map +1 -1
  99. package/dist/canvas/deps/changes.js +13 -0
  100. package/dist/canvas/deps/changes.js.map +1 -0
  101. package/dist/canvas/deps/editAnchors.js +28 -28
  102. package/dist/canvas/deps/insert.js +119 -91
  103. package/dist/canvas/deps/insert.js.map +1 -1
  104. package/dist/canvas/deps/slice.js +46 -45
  105. package/dist/canvas/deps/slice.js.map +1 -1
  106. package/dist/canvas/deps/textEdit.js +10 -9
  107. package/dist/canvas/deps/textEdit.js.map +1 -1
  108. package/dist/canvas/derivedPath.js +46 -23
  109. package/dist/canvas/derivedPath.js.map +1 -1
  110. package/dist/canvas/getNodeAtPoint.js +7 -7
  111. package/dist/canvas/getNodeAtPoint.js.map +1 -1
  112. package/dist/canvas/hud.module.js +1 -1
  113. package/dist/canvas/hud.module.js.map +1 -1
  114. package/dist/canvas/kitRequirements.js +2 -2
  115. package/dist/canvas/kitRequirements.js.map +1 -1
  116. package/dist/canvas/layerOrder.js +13 -6
  117. package/dist/canvas/layerOrder.js.map +1 -1
  118. package/dist/canvas/minimapMath.js +12 -10
  119. package/dist/canvas/minimapMath.js.map +1 -1
  120. package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
  121. package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
  122. package/dist/canvas/nodeShapes/imagePainter.js +87 -0
  123. package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
  124. package/dist/canvas/nodeShapes/memo.js +9 -0
  125. package/dist/canvas/nodeShapes/memo.js.map +1 -0
  126. package/dist/canvas/nodeShapes/nodePaint.js +57 -0
  127. package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
  128. package/dist/canvas/nodeShapes/pathPainter.js +38 -0
  129. package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
  130. package/dist/canvas/nodeShapes/poseBox.js +20 -0
  131. package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
  132. package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
  133. package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
  134. package/dist/canvas/nodeShapes/shapePainter.js +72 -0
  135. package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
  136. package/dist/canvas/nodeShapes/textPainter.js +55 -0
  137. package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
  138. package/dist/canvas/overlayRoleStrokes.js.map +1 -1
  139. package/dist/canvas/paintCull.js +10 -11
  140. package/dist/canvas/paintCull.js.map +1 -1
  141. package/dist/canvas/pickWalk.js +52 -63
  142. package/dist/canvas/pickWalk.js.map +1 -1
  143. package/dist/canvas/poseRotation.js +11 -23
  144. package/dist/canvas/poseRotation.js.map +1 -1
  145. package/dist/canvas/renderDebugSnapshot.js +5 -5
  146. package/dist/canvas/renderSceneToPixels.js +3 -1
  147. package/dist/canvas/renderSceneToPixels.js.map +1 -1
  148. package/dist/canvas/sceneAdapter.js +66 -148
  149. package/dist/canvas/sceneAdapter.js.map +1 -1
  150. package/dist/canvas/sceneClipboard.js +112 -0
  151. package/dist/canvas/sceneClipboard.js.map +1 -0
  152. package/dist/canvas/sceneSlotWiring.js +4 -4
  153. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  154. package/dist/canvas/sceneViewRender.js +39 -40
  155. package/dist/canvas/sceneViewRender.js.map +1 -1
  156. package/dist/canvas/useCanvasRenderer.js +14 -6
  157. package/dist/canvas/useCanvasRenderer.js.map +1 -1
  158. package/dist/canvas/useCanvasView.js +58 -0
  159. package/dist/canvas/useCanvasView.js.map +1 -0
  160. package/dist/canvas/useFrameLoop.js +35 -26
  161. package/dist/canvas/useFrameLoop.js.map +1 -1
  162. package/dist/canvas/useSceneLayerList.js +21 -0
  163. package/dist/canvas/useSceneLayerList.js.map +1 -0
  164. package/dist/clipboard.d.ts +10 -6
  165. package/dist/clone.d.ts +4 -3
  166. package/dist/core/adapters/arrayAdapter.js +48 -39
  167. package/dist/core/adapters/arrayAdapter.js.map +1 -1
  168. package/dist/core/device/index.js +5 -4
  169. package/dist/core/device/useDeviceProfile.js +38 -44
  170. package/dist/core/device/useDeviceProfile.js.map +1 -1
  171. package/dist/core/device/watchDevicePixelRatio.js +17 -0
  172. package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
  173. package/dist/core/fillInPoseFrame.js.map +1 -1
  174. package/dist/core/geometry/poseDescriptor.js +21 -19
  175. package/dist/core/geometry/poseDescriptor.js.map +1 -1
  176. package/dist/core/geometry/poseFrame.js +44 -0
  177. package/dist/core/geometry/poseFrame.js.map +1 -0
  178. package/dist/core/geometry/poseRotation.js.map +1 -1
  179. package/dist/core/geometry/regionHit.js +9 -10
  180. package/dist/core/geometry/regionHit.js.map +1 -1
  181. package/dist/core/geometry/unionBounds.js +31 -29
  182. package/dist/core/geometry/unionBounds.js.map +1 -1
  183. package/dist/core/isPlainObject.js +2 -11
  184. package/dist/core/ops/arrange.js +1 -0
  185. package/dist/core/ops/arrange.js.map +1 -1
  186. package/dist/core/ops/create.js +10 -5
  187. package/dist/core/ops/create.js.map +1 -1
  188. package/dist/core/ops/delete.js +12 -24
  189. package/dist/core/ops/delete.js.map +1 -1
  190. package/dist/core/ops/reorder/index.js +43 -40
  191. package/dist/core/ops/reorder/index.js.map +1 -1
  192. package/dist/core/ops/reorder/setChildOrder.js +34 -0
  193. package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
  194. package/dist/core/paintKinds.js +5 -5
  195. package/dist/core/paintKinds.js.map +1 -1
  196. package/dist/core/scene/NodeProperties.js.map +1 -1
  197. package/dist/core/scene/appliedLog.js +37 -0
  198. package/dist/core/scene/appliedLog.js.map +1 -0
  199. package/dist/core/scene/arrivalWindow.js +101 -0
  200. package/dist/core/scene/arrivalWindow.js.map +1 -0
  201. package/dist/core/scene/derivedPath.js.map +1 -1
  202. package/dist/core/scene/historyFacade.js +84 -0
  203. package/dist/core/scene/historyFacade.js.map +1 -0
  204. package/dist/core/scene/kitOps.js +173 -0
  205. package/dist/core/scene/kitOps.js.map +1 -0
  206. package/dist/core/scene/layerStack.js +38 -0
  207. package/dist/core/scene/layerStack.js.map +1 -0
  208. package/dist/core/scene/lockGuard.js +37 -0
  209. package/dist/core/scene/lockGuard.js.map +1 -0
  210. package/dist/core/scene/nodeFnFields.js +5 -6
  211. package/dist/core/scene/nodeFnFields.js.map +1 -1
  212. package/dist/core/scene/nodeMemo.js +45 -19
  213. package/dist/core/scene/nodeMemo.js.map +1 -1
  214. package/dist/core/scene/nodeStore.js +126 -0
  215. package/dist/core/scene/nodeStore.js.map +1 -0
  216. package/dist/core/scene/pickability.js +6 -0
  217. package/dist/core/scene/pickability.js.map +1 -0
  218. package/dist/core/scene/poseFeed.js +38 -38
  219. package/dist/core/scene/poseFeed.js.map +1 -1
  220. package/dist/core/scene/poseOverrides.js +34 -38
  221. package/dist/core/scene/poseOverrides.js.map +1 -1
  222. package/dist/core/scene/renderOrder.js +84 -0
  223. package/dist/core/scene/renderOrder.js.map +1 -0
  224. package/dist/core/scene/scene.js +289 -866
  225. package/dist/core/scene/scene.js.map +1 -1
  226. package/dist/core/scene/serialization.js +68 -0
  227. package/dist/core/scene/serialization.js.map +1 -0
  228. package/dist/core/scene/treeOrder.js +13 -0
  229. package/dist/core/scene/treeOrder.js.map +1 -0
  230. package/dist/core/scene/types.js.map +1 -1
  231. package/dist/core/viewport/meanScale.js +1 -1
  232. package/dist/core/viewport/meanScale.js.map +1 -1
  233. package/dist/core/viewport/view.js +12 -12
  234. package/dist/core/viewport/view.js.map +1 -1
  235. package/dist/core/viewport/zoomBounds.js +10 -8
  236. package/dist/core/viewport/zoomBounds.js.map +1 -1
  237. package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-CtCb8a3G.d.ts} +1 -1
  238. package/dist/debug/createDebugOverlayLayer.js +14 -14
  239. package/dist/debug/createDebugOverlayLayer.js.map +1 -1
  240. package/dist/debug/flag.js +2 -41
  241. package/dist/features/chrome-caps/useHoverTracking.js +22 -17
  242. package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
  243. package/dist/features/focus/gateLayer.js +3 -4
  244. package/dist/features/focus/gateLayer.js.map +1 -1
  245. package/dist/features/images/imageCache.js +19 -9
  246. package/dist/features/images/imageCache.js.map +1 -1
  247. package/dist/features/ingestion/contentHandlers.js +14 -11
  248. package/dist/features/ingestion/contentHandlers.js.map +1 -1
  249. package/dist/features/ingestion/index.js +1 -1
  250. package/dist/features/ingestion/registerKitHandlers.js +7 -7
  251. package/dist/features/ingestion/weaselJsonHandler.js +17 -14
  252. package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
  253. package/dist/features/meshPaint/lazyKind.js +201 -35
  254. package/dist/features/meshPaint/lazyKind.js.map +1 -1
  255. package/dist/features/meshPaint/meshPaint.js +82 -79
  256. package/dist/features/meshPaint/meshPaint.js.map +1 -1
  257. package/dist/features/minimap/createMinimapContribution.js +42 -42
  258. package/dist/features/minimap/layers.js +44 -62
  259. package/dist/features/minimap/layers.js.map +1 -1
  260. package/dist/features/parallax/createParallaxPlane.js +10 -14
  261. package/dist/features/parallax/createParallaxPlane.js.map +1 -1
  262. package/dist/features/paths/anchorEdits.js +19 -8
  263. package/dist/features/paths/anchorEdits.js.map +1 -1
  264. package/dist/features/paths/anchors.js +31 -26
  265. package/dist/features/paths/anchors.js.map +1 -1
  266. package/dist/features/paths/booleans.js +2 -2
  267. package/dist/features/paths/index.js +13 -11
  268. package/dist/features/paths/markerCommands.js +37 -36
  269. package/dist/features/paths/markerCommands.js.map +1 -1
  270. package/dist/features/paths/pathInWorld.js +19 -19
  271. package/dist/features/paths/pathInWorld.js.map +1 -1
  272. package/dist/features/paths/pathLayer.js.map +1 -1
  273. package/dist/features/paths/strokeToPath.js +40 -0
  274. package/dist/features/paths/strokeToPath.js.map +1 -0
  275. package/dist/features/paths/tessellate/stroke.js.map +1 -1
  276. package/dist/features/patterns/commandPaint.js +18 -0
  277. package/dist/features/patterns/commandPaint.js.map +1 -0
  278. package/dist/features/patterns/index.js +5 -17
  279. package/dist/features/patterns/index.js.map +1 -1
  280. package/dist/features/patterns/rasterizeTile.js +17 -0
  281. package/dist/features/patterns/rasterizeTile.js.map +1 -0
  282. package/dist/features/patterns/resolveSpec.js +52 -44
  283. package/dist/features/patterns/resolveSpec.js.map +1 -1
  284. package/dist/features/poseRun/usePoseRun.js +8 -3
  285. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  286. package/dist/features/selection/SelectionContext.js +5 -0
  287. package/dist/features/selection/SelectionContext.js.map +1 -1
  288. package/dist/features/selection/overlay.js +18 -18
  289. package/dist/features/selection/overlay.js.map +1 -1
  290. package/dist/features/text/domOffsets.js +82 -0
  291. package/dist/features/text/domOffsets.js.map +1 -0
  292. package/dist/features/text/domRuns.js +103 -131
  293. package/dist/features/text/domRuns.js.map +1 -1
  294. package/dist/features/text/hitTest.js +5 -2
  295. package/dist/features/text/hitTest.js.map +1 -1
  296. package/dist/features/text/isTextData.js +8 -0
  297. package/dist/features/text/isTextData.js.map +1 -0
  298. package/dist/features/text/overlayDirection.js +15 -0
  299. package/dist/features/text/overlayDirection.js.map +1 -0
  300. package/dist/features/text/runs/rangeStyle.js +32 -34
  301. package/dist/features/text/runs/rangeStyle.js.map +1 -1
  302. package/dist/features/text/textCommand.js +34 -33
  303. package/dist/features/text/textCommand.js.map +1 -1
  304. package/dist/features/text/textToPath.js +40 -40
  305. package/dist/features/text/textToPath.js.map +1 -1
  306. package/dist/features/text/useSceneTextEdit.js +76 -82
  307. package/dist/features/text/useSceneTextEdit.js.map +1 -1
  308. package/dist/features/text/useTextEdit.js +184 -160
  309. package/dist/features/text/useTextEdit.js.map +1 -1
  310. package/dist/features/tiling/createTiledLayer.js +24 -22
  311. package/dist/features/tiling/createTiledLayer.js.map +1 -1
  312. package/dist/index.d.ts +11010 -7700
  313. package/dist/index.js +316 -309
  314. package/dist/input/keyState.js +42 -43
  315. package/dist/input/keyState.js.map +1 -1
  316. package/dist/input/useKeyModifiers.js +11 -0
  317. package/dist/input/useKeyModifiers.js.map +1 -0
  318. package/dist/interactions/actions/align/align.js +8 -8
  319. package/dist/interactions/actions/clipboard/clipboardOps.js +34 -32
  320. package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
  321. package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
  322. package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
  323. package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
  324. package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -1
  325. package/dist/interactions/actions/defaultCommitAdapter.js +20 -18
  326. package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
  327. package/dist/interactions/actions/defaults/align.js +9 -10
  328. package/dist/interactions/actions/defaults/align.js.map +1 -1
  329. package/dist/interactions/actions/defaults/anchorEditing.js +59 -81
  330. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  331. package/dist/interactions/actions/defaults/areaSelect.js +35 -38
  332. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  333. package/dist/interactions/actions/defaults/clipboard.js +26 -10
  334. package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
  335. package/dist/interactions/actions/defaults/clone.js +44 -60
  336. package/dist/interactions/actions/defaults/clone.js.map +1 -1
  337. package/dist/interactions/actions/defaults/copySubtree.js +40 -0
  338. package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
  339. package/dist/interactions/actions/defaults/distribute.js +14 -13
  340. package/dist/interactions/actions/defaults/distribute.js.map +1 -1
  341. package/dist/interactions/actions/defaults/duplicate.js +17 -57
  342. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  343. package/dist/interactions/actions/defaults/editAnchors.js +18 -18
  344. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  345. package/dist/interactions/actions/defaults/flip.js +52 -46
  346. package/dist/interactions/actions/defaults/flip.js.map +1 -1
  347. package/dist/interactions/actions/defaults/group.js +43 -48
  348. package/dist/interactions/actions/defaults/group.js.map +1 -1
  349. package/dist/interactions/actions/defaults/ingest.js +35 -33
  350. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  351. package/dist/interactions/actions/defaults/insert.js +50 -51
  352. package/dist/interactions/actions/defaults/insert.js.map +1 -1
  353. package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -7
  354. package/dist/interactions/actions/defaults/lassoSelect.js +67 -70
  355. package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
  356. package/dist/interactions/actions/defaults/move.js +267 -249
  357. package/dist/interactions/actions/defaults/move.js.map +1 -1
  358. package/dist/interactions/actions/defaults/nudge.js +40 -68
  359. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  360. package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
  361. package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
  362. package/dist/interactions/actions/defaults/reorder.js +2 -0
  363. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  364. package/dist/interactions/actions/defaults/resize.js +104 -98
  365. package/dist/interactions/actions/defaults/resize.js.map +1 -1
  366. package/dist/interactions/actions/defaults/rotate.js +111 -110
  367. package/dist/interactions/actions/defaults/rotate.js.map +1 -1
  368. package/dist/interactions/actions/defaults/setFill.js +7 -7
  369. package/dist/interactions/actions/defaults/setFillOpacity.js +4 -4
  370. package/dist/interactions/actions/defaults/setStroke.js +12 -12
  371. package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
  372. package/dist/interactions/actions/defaults/sliceOps.js +19 -19
  373. package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
  374. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  375. package/dist/interactions/actions/edit-anchors/geometry.js +28 -23
  376. package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
  377. package/dist/interactions/actions/flip/helpers.js +30 -17
  378. package/dist/interactions/actions/flip/helpers.js.map +1 -1
  379. package/dist/interactions/actions/hitSelection.js +8 -0
  380. package/dist/interactions/actions/hitSelection.js.map +1 -0
  381. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
  382. package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
  383. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
  384. package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
  385. package/dist/interactions/actions/move/behaviors/snapToContainer.js +32 -21
  386. package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
  387. package/dist/interactions/actions/move/gestureAdapter.js +32 -15
  388. package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
  389. package/dist/interactions/actions/move/landedDescendants.js +33 -0
  390. package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
  391. package/dist/interactions/actions/outlines/createOutlines.js +18 -18
  392. package/dist/interactions/actions/poseDescriptorDep.js +16 -4
  393. package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
  394. package/dist/interactions/actions/poseFrame.js +11 -6
  395. package/dist/interactions/actions/poseFrame.js.map +1 -1
  396. package/dist/interactions/actions/previewOverrides.js +5 -5
  397. package/dist/interactions/actions/previewOverrides.js.map +1 -1
  398. package/dist/interactions/actions/selectionSubtree.js +69 -0
  399. package/dist/interactions/actions/selectionSubtree.js.map +1 -0
  400. package/dist/interactions/actions/useStandardActions.js +66 -62
  401. package/dist/interactions/actions/useStandardActions.js.map +1 -1
  402. package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
  403. package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
  404. package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
  405. package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
  406. package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
  407. package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
  408. package/dist/interactions/gestures/pointerDrag/pointerDrag.js +8 -6
  409. package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
  410. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
  411. package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
  412. package/dist/{math-Drrw4ewZ.d.ts → math-J-ACHyEg.d.ts} +1 -2
  413. package/dist/math.d.ts +2 -3
  414. package/dist/move.d.ts +12 -11
  415. package/dist/{originProjection-DEklpDc_.d.ts → originProjection-gHnOup4e.d.ts} +1 -1
  416. package/dist/{registerProgram-BMZRDgrh.d.ts → registerProgram-T9S_PfAX.d.ts} +18 -7
  417. package/dist/renderer/DrawCommand.js.map +1 -1
  418. package/dist/renderer/WeaselRenderer.js +75 -73
  419. package/dist/renderer/WeaselRenderer.js.map +1 -1
  420. package/dist/renderer/cache/GLImageCache.js +15 -5
  421. package/dist/renderer/cache/GLImageCache.js.map +1 -1
  422. package/dist/renderer/cache/GLMeshCache.js +23 -23
  423. package/dist/renderer/cache/GLMeshCache.js.map +1 -1
  424. package/dist/renderer/cache/GLTextureCache.js +18 -1
  425. package/dist/renderer/cache/GLTextureCache.js.map +1 -1
  426. package/dist/renderer/cache/cache.js.map +1 -1
  427. package/dist/renderer/cache/markerCommandCache.js.map +1 -1
  428. package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
  429. package/dist/renderer/cullDrawCommands.js +11 -11
  430. package/dist/renderer/draw/batch.js +133 -0
  431. package/dist/renderer/draw/batch.js.map +1 -0
  432. package/dist/renderer/draw/clip.js +89 -0
  433. package/dist/renderer/draw/clip.js.map +1 -0
  434. package/dist/renderer/draw/customShader.js +230 -0
  435. package/dist/renderer/draw/customShader.js.map +1 -0
  436. package/dist/renderer/draw/drawTriangles.js +8 -0
  437. package/dist/renderer/draw/drawTriangles.js.map +1 -0
  438. package/dist/renderer/draw/effects.js +28 -0
  439. package/dist/renderer/draw/effects.js.map +1 -0
  440. package/dist/renderer/draw/flushBatch.js +35 -0
  441. package/dist/renderer/draw/flushBatch.js.map +1 -0
  442. package/dist/renderer/draw/gradient.js +90 -0
  443. package/dist/renderer/draw/gradient.js.map +1 -0
  444. package/dist/renderer/draw/image.js +38 -0
  445. package/dist/renderer/draw/image.js.map +1 -0
  446. package/dist/renderer/draw/mesh.js +16 -0
  447. package/dist/renderer/draw/mesh.js.map +1 -0
  448. package/dist/renderer/draw/paintBind.js +70 -0
  449. package/dist/renderer/draw/paintBind.js.map +1 -0
  450. package/dist/renderer/draw/pathPaint.js +142 -0
  451. package/dist/renderer/draw/pathPaint.js.map +1 -0
  452. package/dist/renderer/draw/scratchPass.js +83 -0
  453. package/dist/renderer/draw/scratchPass.js.map +1 -0
  454. package/dist/renderer/draw/stencil.js +28 -0
  455. package/dist/renderer/draw/stencil.js.map +1 -0
  456. package/dist/renderer/draw/text.js +167 -0
  457. package/dist/renderer/draw/text.js.map +1 -0
  458. package/dist/renderer/draw/uniforms.js +77 -0
  459. package/dist/renderer/draw/uniforms.js.map +1 -0
  460. package/dist/renderer/draw.js +60 -1116
  461. package/dist/renderer/draw.js.map +1 -1
  462. package/dist/renderer/effects/EffectTargets.js +3 -0
  463. package/dist/renderer/effects/EffectTargets.js.map +1 -1
  464. package/dist/renderer/effects/composite.js +7 -5
  465. package/dist/renderer/effects/composite.js.map +1 -1
  466. package/dist/renderer/index.js +18 -17
  467. package/dist/renderer/math/color.js +63 -83
  468. package/dist/renderer/math/color.js.map +1 -1
  469. package/dist/renderer/math/mat3.js +15 -11
  470. package/dist/renderer/math/mat3.js.map +1 -1
  471. package/dist/renderer/math/viewToMat3.js +1 -1
  472. package/dist/renderer/math/viewToMat3.js.map +1 -1
  473. package/dist/renderer/shaders/ShaderProgram.js +13 -13
  474. package/dist/renderer/shaders/ShaderProgram.js.map +1 -1
  475. package/dist/renderer/shaders/glyphPaint.js +3 -3
  476. package/dist/renderer/shaders/glyphPaint.js.map +1 -1
  477. package/dist/renderer/shaders/gradFill.js +2 -1
  478. package/dist/renderer/shaders/gradFill.js.map +1 -1
  479. package/dist/renderer/shaders/pathFill.js +2 -1
  480. package/dist/renderer/shaders/pathFill.js.map +1 -1
  481. package/dist/renderer/shaders/patternFill.js +2 -1
  482. package/dist/renderer/shaders/patternFill.js.map +1 -1
  483. package/dist/renderer/shaders/registerProgram.js.map +1 -1
  484. package/dist/renderer/strokeLengths.js.map +1 -1
  485. package/dist/renderer/textures/registerTexture.js +25 -5
  486. package/dist/renderer/textures/registerTexture.js.map +1 -1
  487. package/dist/renderer.d.ts +16 -15
  488. package/dist/renderer.js +17 -16
  489. package/dist/resize.d.ts +5 -6
  490. package/dist/resize.js +5 -5
  491. package/dist/style.css +1 -1
  492. package/dist/test-hook/install.js +12 -6
  493. package/dist/test-hook/install.js.map +1 -1
  494. package/dist/{test-seams-CuIxe0xY.d.ts → test-seams-DM2B87-g.d.ts} +4 -4
  495. package/dist/test-seams.d.ts +2 -2
  496. package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
  497. package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
  498. package/dist/tools/builtin/hand/useHandTool.js +1 -0
  499. package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
  500. package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
  501. package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
  502. package/dist/tools/builtin/line/useLineTool.js +1 -0
  503. package/dist/tools/builtin/line/useLineTool.js.map +1 -1
  504. package/dist/tools/builtin/pen/usePenTool.js +153 -103
  505. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  506. package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
  507. package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
  508. package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
  509. package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
  510. package/dist/tools/builtin/rect/useRectTool.js +1 -0
  511. package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
  512. package/dist/tools/builtin/select/selectionContributions.js +24 -23
  513. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  514. package/dist/tools/builtin/select/useSelectTool.js +51 -48
  515. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  516. package/dist/tools/builtin/shared/pointerFollower.js +17 -0
  517. package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
  518. package/dist/tools/builtin/slice/useSliceTool.js +49 -54
  519. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  520. package/dist/tools/builtin/star/useStarTool.js +22 -16
  521. package/dist/tools/builtin/star/useStarTool.js.map +1 -1
  522. package/dist/tools/builtin/text/useTextTool.js +13 -2
  523. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  524. package/dist/tools/useKeybindings.js +14 -30
  525. package/dist/tools/useKeybindings.js.map +1 -1
  526. package/dist/{types-B_9g6hMM.d.ts → types-B4iJRHC3.d.ts} +5 -1
  527. package/dist/{types-A37hYkeR.d.ts → types-k-5Oqh-U.d.ts} +31 -7
  528. package/dist/util/color.js +3 -3
  529. package/dist/util/color.js.map +1 -1
  530. package/dist/util/paint.js.map +1 -1
  531. package/dist/version.js +1 -1
  532. package/package.json +20 -18
  533. package/dist/autoPoseDescriptor-vCdt55xm.d.ts +0 -27
  534. package/dist/builtins-C-VgUlWI.d.ts +0 -4514
  535. package/dist/core/isPlainObject.js.map +0 -1
  536. package/dist/debug/flag.js.map +0 -1
  537. package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
  538. package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
  539. package/dist/renderer/shaders/imageFill.js +0 -14
  540. package/dist/renderer/shaders/imageFill.js.map +0 -1
  541. package/dist/tools/prefs.js +0 -47
  542. package/dist/tools/prefs.js.map +0 -1
@@ -1,89 +1,88 @@
1
1
  import { normalizeView as e } from "../core/viewport/view.js";
2
2
  import { createViewportLayer as t } from "../features/viewports/viewportLayer.js";
3
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";
4
+ import { clampView as r } from "../core/viewport/clampView.js";
5
+ import { clientToWorld as i } from "../core/viewport/clientToWorld.js";
6
+ import { viewportWorldRect as a } from "../core/viewport/viewportWorldRect.js";
7
+ import { useSelection as o } from "../core/selection/useSelection.js";
8
+ import { AUTO_POSE_DESCRIPTOR as s } from "../interactions/actions/resize/autoPoseDescriptor.js";
9
+ import { useViewHelpers as c } from "./useViewHelpers.js";
10
+ import { anchorStateFrom as ee, buildAffordanceAt as te, buildClassifyTarget as ne } from "./affordanceAt.js";
11
+ import { pathFromPlane as re } from "./planeClips.js";
12
+ import { createDispatcherPreviewSources as ie, createGestureSource as ae } from "./SceneCanvas/dispatcherGestureBounds.js";
13
+ import { useOptionalViewInputs as oe } from "./viewInputs.js";
14
+ import { createSceneLayerGate as se, paintedLayers as ce } from "./sceneLayerPaint.js";
15
+ import { IDENTITY_VIEW as l, UNMEASURED_DIMS as u, useOptionalViewRegistry as le } from "./viewRegistry.js";
16
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
17
+ import { useLatest as g } from "@weasel-js/react";
18
+ import { createDispatcher as ue } from "@weasel-js/routing";
19
+ import { useOptionalDepRegistry as de } from "@weasel-js/routing/react";
20
20
  //#region src/canvas/CanvasView.tsx
21
- var pe = {
21
+ var fe = {
22
22
  adapter: void 0,
23
- geometry: a,
23
+ geometry: s,
24
24
  boundsOf: void 0,
25
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;
26
+ }, pe = () => !0, me = (e) => e;
27
+ function _(s) {
28
+ let { id: _, bounds: he, view: v, defaultView: ge, onViewChange: _e, viewBounds: ve, layers: ye = me, layerVisibility: be, layerOrder: xe, background: y, order: b = Infinity, label: x, selection: Se, selectionOptions: S, interactive: C = !0, paint: w = !0 } = s, T = le(), Ce = de(), E = g(Ce), D = o(S), O = Se ?? (S ? D : void 0), [we] = h(() => e(ge ?? l)), k = m(we), A = oe(), j = O ?? A?.selectionApi ?? D, M = g({
29
+ bounds: he,
30
+ layers: ye,
31
+ layerVisibility: be,
32
+ layerOrder: xe,
33
+ onViewChange: _e,
34
+ viewBounds: ve,
35
+ viewProp: v,
36
+ viewSelection: O,
37
+ selection: j
38
+ }), N = d((e, t) => {
39
+ let n = M.current.bounds;
41
40
  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;
41
+ }, [M]), P = d(() => {
42
+ let e = T?.surface();
43
+ return N(e?.view() ?? l, e?.dims() ?? u);
44
+ }, [T, N]), F = d((t, n) => {
45
+ let r = M.current.viewProp ?? k.current;
47
46
  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, {
47
+ }, [M]), I = d(() => {
48
+ let e = T?.surface();
49
+ return F(e?.view() ?? l, e?.dims() ?? u);
50
+ }, [T, F]), L = d(() => ce(T?.surface()?.layers() ?? [], M.current), [T, M]), [R] = h(se), z = d((e) => R(T?.surface()?.layers() ?? [], M.current)(e), [
51
+ T,
52
+ R,
53
+ M
54
+ ]), B = d((t) => {
55
+ let { viewBounds: n, onViewChange: i, viewProp: a } = M.current, o = P(), s = e(t), c = n ? r(s, n, {
57
56
  width: o.w,
58
57
  height: o.h
59
58
  }) : s;
60
- a === void 0 && Ee(c), r?.(c), w?.surface()?.requestRedraw();
59
+ a === void 0 && (k.current = c), i?.(c), T?.surface()?.requestRedraw();
61
60
  }, [
62
- w,
63
- N,
64
- j
65
- ]), B = p(() => ({
66
- get: F,
67
- set: z,
61
+ T,
62
+ P,
63
+ M
64
+ ]), V = p(() => ({
65
+ get: I,
66
+ set: B,
68
67
  hostSize: () => {
69
- let e = N();
68
+ let e = P();
70
69
  return {
71
70
  width: e.w,
72
71
  height: e.h
73
72
  };
74
73
  },
75
- layerIsPainted: R
74
+ layerIsPainted: z
76
75
  }), [
77
- F,
78
- N,
79
- z,
80
- R
81
- ]), V = p(() => {
82
- let e = () => T.current?.get("ingestion");
76
+ I,
77
+ P,
78
+ B,
79
+ z
80
+ ]), H = p(() => {
81
+ let e = () => E.current?.get("ingestion");
83
82
  return {
84
83
  viewportWorldRect: () => {
85
- let e = N();
86
- return ie(F(), {
84
+ let e = P();
85
+ return a(I(), {
87
86
  width: e.w,
88
87
  height: e.h
89
88
  });
@@ -99,59 +98,59 @@ function g(a) {
99
98
  }
100
99
  };
101
100
  }, [
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() ?? {
101
+ I,
102
+ P,
103
+ E
104
+ ]), U = m(null);
105
+ U.current ||= ue();
106
+ let W = A?.rotationBadge ?? null, Te = p(() => ({
107
+ gestureSource: ae(() => U.current),
108
+ ...ie(() => U.current)
109
+ }), []), G = g(A), K = d(() => ({
110
+ selection: M.current.selection.get(),
111
+ view: I(),
112
+ action: U.current.getActiveAction()
113
+ }), [I, M]), q = A?.boundsOf, Ee = p(() => q ? (e) => q(e, I()) : void 0, [q, I]), J = A?.boundsOfPose, De = p(() => J ? (e, t) => J(e, t, I()) : void 0, [J, I]), { helpers: Oe } = c({
114
+ ...A ?? fe,
115
+ boundsOf: Ee,
116
+ boundsOfPose: De,
117
+ ...Te,
118
+ selection: j.current,
119
+ getIsVisible: () => G.current?.chromeCaps?.isVisible(K()) ?? pe
120
+ }), Y = g(Oe), X = d((e, t) => {
121
+ let n = T?.surface()?.origin() ?? {
123
122
  left: 0,
124
123
  top: 0
125
- }, i = N(), [a, o] = r(e, t, {
126
- left: n.left + i.x,
127
- top: n.top + i.y
128
- }, F());
124
+ }, r = P(), [a, o] = i(e, t, {
125
+ left: n.left + r.x,
126
+ top: n.top + r.y
127
+ }, I());
129
128
  return {
130
129
  x: a,
131
130
  y: o
132
131
  };
133
132
  }, [
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
133
  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()
134
+ P,
135
+ I
136
+ ]), Z = p(() => ee(() => E.current, (e, t) => re(t, G.current?.planeOfNode?.(e, I()) ?? null)), [
137
+ I,
138
+ E,
139
+ G
140
+ ]), { targetScale: Q } = n(), $ = p(() => {
141
+ let e = te({
142
+ getChromeState: () => Y.current.getChromeState(),
143
+ getView: I,
144
+ targetScale: Q,
145
+ rotationBadge: W,
146
+ getAnchorState: Z,
147
+ getIsVisible: () => Y.current.getIsVisible()
149
148
  });
150
149
  return (t) => {
151
- let n = N(), r = (w?.surface())?.hitTestExtras(t.x, t.y, F(), {
150
+ let n = P(), r = (T?.surface())?.hitTestExtras(t.x, t.y, I(), {
152
151
  width: n.w,
153
152
  height: n.h
154
- }, J.current, I());
153
+ }, Y.current, L());
155
154
  if (r) {
156
155
  let e = r.hit;
157
156
  return {
@@ -166,90 +165,90 @@ function g(a) {
166
165
  return e(t);
167
166
  };
168
167
  }, [
169
- X,
170
- N,
171
- w,
172
168
  Z,
173
- F,
169
+ P,
170
+ T,
171
+ Q,
174
172
  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
173
+ L,
174
+ W,
175
+ Y
176
+ ]), ke = p(() => {
177
+ let e = ne(() => M.current.selection.get(), (e, t) => {
178
+ let n = G.current, r = {
179
+ ...I(),
180
+ layerIsPainted: z
182
181
  };
183
182
  if (n?.pickBest) return n.pickBest(e, t, r);
184
183
  let i = n?.pickEvery?.(e, t, r) ?? [];
185
184
  return i.length > 0 ? i[i.length - 1] : null;
186
- }, (e) => W.current?.kindOfNode?.(e));
185
+ }, (e) => G.current?.kindOfNode?.(e));
187
186
  return (t) => e(t);
188
187
  }, [
189
- F,
190
- R,
191
- j,
192
- W
193
- ]), $ = p(() => ({
194
- id: g,
195
- order: y,
196
- interactive: S,
197
- paint: C,
188
+ I,
189
+ z,
190
+ M,
191
+ G
192
+ ]), Ae = p(() => ({
193
+ id: _,
194
+ order: b,
195
+ interactive: C,
196
+ paint: w,
198
197
  layer: t({
199
- id: g,
200
- label: b ?? g,
201
- source: I,
202
- view: P,
203
- bounds: (e, t) => M(e, t),
198
+ id: _,
199
+ label: x ?? _,
200
+ source: L,
201
+ view: F,
202
+ bounds: (e, t) => N(e, t),
204
203
  data: (e) => ({
205
204
  ...e,
206
- ...J.current,
207
- viewId: g
205
+ ...Y.current,
206
+ viewId: _
208
207
  }),
209
- ...v === void 0 ? {} : { background: v }
208
+ ...y === void 0 ? {} : { background: y }
210
209
  }),
211
- layerIsPainted: R,
210
+ layerIsPainted: z,
212
211
  target: {
213
- dispatcher: H.current,
214
- affordanceAt: Q,
215
- classifyTarget: je,
216
- clientToWorld: Y,
212
+ dispatcher: U.current,
213
+ affordanceAt: $,
214
+ classifyTarget: ke,
215
+ clientToWorld: X,
217
216
  deps: () => ({
218
- view: B,
219
- ingestion: V,
220
- dispatcher: { cancelAll: (e) => H.current.cancelAll(e) },
221
- ...j.current.viewSelection ? { selection: j.current.viewSelection } : {}
217
+ view: V,
218
+ ingestion: H,
219
+ dispatcher: { cancelAll: (e) => U.current.cancelAll(e) },
220
+ ...M.current.viewSelection ? { selection: M.current.viewSelection } : {}
222
221
  }),
223
- getRuleCtx: () => W.current?.chromeCaps?.ruleCtx(G())
222
+ getRuleCtx: () => G.current?.chromeCaps?.ruleCtx(K())
224
223
  }
225
224
  }), [
226
- g,
227
- y,
228
- S,
229
- C,
225
+ _,
230
226
  b,
231
- v,
227
+ C,
228
+ w,
229
+ x,
230
+ y,
231
+ N,
232
+ F,
233
+ V,
234
+ $,
235
+ ke,
236
+ X,
237
+ K,
238
+ H,
239
+ L,
240
+ z,
232
241
  M,
233
- P,
234
- B,
235
- Q,
236
- je,
237
- Y,
238
242
  G,
239
- V,
240
- I,
241
- R,
242
- j,
243
- W,
244
- J
243
+ Y
245
244
  ]);
246
245
  return f(() => {
247
- if (w) return w.register($);
248
- }, [w, $]), f(() => {
249
- w?.surface()?.requestRedraw();
250
- }, [w, O]), null;
246
+ if (T) return T.register(Ae);
247
+ }, [T, Ae]), f(() => () => U.current?.cancelAll("cancel"), []), f(() => {
248
+ T?.surface()?.requestRedraw();
249
+ }, [T, v]), null;
251
250
  }
252
251
  //#endregion
253
- export { g as CanvasView };
252
+ export { _ as CanvasView };
254
253
 
255
254
  //# sourceMappingURL=CanvasView.js.map
@@ -1 +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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C,GAI3BQ,QAAgB;EACd,GAAU,QAAQ,CAAC,EAAE,cAAc;CACrC,GAAG,CAACxG,GAAUgB,CAAa,CAAC,GAErB;AACT"}
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","initialView","useState","normalizeView","defaultView","IDENTITY_VIEW","internalViewRef","useRef","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","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 // The uncontrolled camera lives in a ref, as `<Canvas>`'s does: a write is\n // readable at once, so a second one before React commits builds on the first.\n const [initialView] = useState<View>(() => normalizeView(defaultView ?? IDENTITY_VIEW));\n const internalViewRef = useRef(initialView);\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 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.viewProp ?? internalViewRef.current;\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) internalViewRef.current = 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 // Apart from the registration, which is replaced whenever a prop it reads\n // changes: only the view going away ends what is in flight over it.\n useEffect(() => () => dispatcherRef.current?.cancelAll('cancel'), []);\n\n // A controlled camera change is invisible until the surface repaints; an\n // uncontrolled one asks for its repaint in `setView`.\n useEffect(() => {\n registry?.surface()?.requestRedraw();\n }, [registry, viewProp]);\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,EAAaC,CAAgB,GAC5CC,IAAgBX,OAAkBU,IAAmBF,IAAe,KAAA,IAIpE,CAACI,MAAeC,QAAqBC,EAAcC,MAAeC,CAAa,CAAC,GAChFC,IAAkBC,EAAON,EAAW,GAEpCO,IAASC,GAAsB,GAG/BC,IAAYV,KAAiBQ,GAAQ,gBAAgBX,GAKrDc,IAAOf,EAAU;EACrB;EAAQ;EAAQ;EAAiB;EAAY;EAAc;EAAY;EACvE;EAAe;CACjB,CAAC,GAEKgB,IAASC,GAAa,GAAa,MAAyB;EAChE,IAAMC,IAAIH,EAAK,QAAQ;EACvB,OAAO,OAAOG,KAAM,aAAaA,EAAEC,GAAOC,CAAI,IAAIF;CACpD,GAAG,CAACH,CAAI,CAAC,GAIHM,IAAUJ,QAA4B;EAC1C,IAAMK,IAAU3B,GAAU,QAAQ;EACl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