@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.
- package/CHANGELOG.md +1006 -0
- package/README.md +28 -9
- package/dist/WeaselProvider.js +15 -0
- package/dist/WeaselProvider.js.map +1 -0
- package/dist/affordances/composeAffordanceLayer.js +224 -0
- package/dist/affordances/composeAffordanceLayer.js.map +1 -0
- package/dist/affordances/cornerResize.js +69 -0
- package/dist/affordances/cornerResize.js.map +1 -0
- package/dist/affordances/hitAffordanceRegions.js +138 -0
- package/dist/affordances/hitAffordanceRegions.js.map +1 -0
- package/dist/affordances/pathAnchors.js +66 -0
- package/dist/affordances/pathAnchors.js.map +1 -0
- package/dist/affordances/rotationHandle.js +103 -0
- package/dist/affordances/rotationHandle.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +118 -0
- package/dist/animation/behaviors/momentum.js.map +1 -0
- package/dist/animation/colorHelpers.js +135 -0
- package/dist/animation/colorHelpers.js.map +1 -0
- package/dist/animation/colorRegistry.js +37 -0
- package/dist/animation/colorRegistry.js.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/loop.js +62 -0
- package/dist/animation/loop.js.map +1 -0
- package/dist/animation/observe.js +23 -0
- package/dist/animation/observe.js.map +1 -0
- package/dist/animation/poseHelpers.js +50 -0
- package/dist/animation/poseHelpers.js.map +1 -0
- package/dist/animation/reflow.js +121 -0
- package/dist/animation/reflow.js.map +1 -0
- package/dist/animation/rig/bindRig.js +74 -0
- package/dist/animation/rig/bindRig.js.map +1 -0
- package/dist/animation/rig/blendPoses.js +43 -0
- package/dist/animation/rig/blendPoses.js.map +1 -0
- package/dist/animation/rig/mirrorPose.js +19 -0
- package/dist/animation/rig/mirrorPose.js.map +1 -0
- package/dist/animation/rig/resolveSkeleton.js +33 -0
- package/dist/animation/rig/resolveSkeleton.js.map +1 -0
- package/dist/animation/rig/solveIk.js +103 -0
- package/dist/animation/rig/solveIk.js.map +1 -0
- package/dist/animation/rig/types.js +12 -0
- package/dist/animation/rig/types.js.map +1 -0
- package/dist/animation/rig/useRig.js +23 -0
- package/dist/animation/rig/useRig.js.map +1 -0
- package/dist/animation/slew.js +27 -0
- package/dist/animation/slew.js.map +1 -0
- package/dist/animation/stagger.js +138 -0
- package/dist/animation/stagger.js.map +1 -0
- package/dist/animation/timeline/booking.js +106 -0
- package/dist/animation/timeline/booking.js.map +1 -0
- package/dist/animation/timeline/createTimeline.js +116 -0
- package/dist/animation/timeline/createTimeline.js.map +1 -0
- package/dist/animation/timeline/sampleTrack.js +29 -0
- package/dist/animation/timeline/sampleTrack.js.map +1 -0
- package/dist/animation/useAnimator.js +329 -0
- package/dist/animation/useAnimator.js.map +1 -0
- package/dist/animation/wrappers/animateLifecycle.js +40 -0
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -0
- package/dist/animation/wrappers/animateOnSetPose.js +44 -0
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -0
- package/dist/{autoPoseDescriptor-_XOyF7t4.d.ts → autoPoseDescriptor-BT_vp9FO.d.ts} +2 -2
- package/dist/{builtins-HWyuLzE-.d.ts → builtins-BSUfH8nU.d.ts} +1301 -508
- package/dist/canvas/Canvas.js +608 -0
- package/dist/canvas/Canvas.js.map +1 -0
- package/dist/canvas/CanvasView.js +255 -0
- package/dist/canvas/CanvasView.js.map +1 -0
- package/dist/canvas/CursorCoordsHud.js +75 -0
- package/dist/canvas/CursorCoordsHud.js.map +1 -0
- package/dist/canvas/DrawCanvas.js +67 -0
- package/dist/canvas/DrawCanvas.js.map +1 -0
- package/dist/canvas/MinimapCanvas.js +139 -0
- package/dist/canvas/MinimapCanvas.js.map +1 -0
- package/dist/canvas/ModalityHud.js +66 -0
- package/dist/canvas/ModalityHud.js.map +1 -0
- package/dist/canvas/NodeShape.js +391 -0
- package/dist/canvas/NodeShape.js.map +1 -0
- package/dist/canvas/PickHud.js +93 -0
- package/dist/canvas/PickHud.js.map +1 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +51 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js +42 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +549 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +26 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js +69 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -0
- package/dist/canvas/SceneCanvas/features.js +97 -0
- package/dist/canvas/SceneCanvas/features.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +46 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +48 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +70 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js +75 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +172 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +69 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +127 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +30 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +992 -0
- package/dist/canvas/SceneCanvas.js.map +1 -0
- package/dist/canvas/SceneViewCanvas.js +54 -0
- package/dist/canvas/SceneViewCanvas.js.map +1 -0
- package/dist/canvas/accentColor.js +9 -0
- package/dist/canvas/accentColor.js.map +1 -0
- package/dist/canvas/affordanceAt.js +63 -0
- package/dist/canvas/affordanceAt.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +65 -0
- package/dist/canvas/buildSceneTree.js.map +1 -0
- package/dist/canvas/canvasRenderer.js +89 -0
- package/dist/canvas/canvasRenderer.js.map +1 -0
- package/dist/canvas/colorOverrides.js +16 -0
- package/dist/canvas/colorOverrides.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +43 -0
- package/dist/canvas/defaultDrawOne.js.map +1 -0
- package/dist/canvas/deps/areaSelect.js +19 -0
- package/dist/canvas/deps/areaSelect.js.map +1 -0
- package/dist/canvas/deps/debug.js +9 -0
- package/dist/canvas/deps/debug.js.map +1 -0
- package/dist/canvas/deps/dispatcher.js +11 -0
- package/dist/canvas/deps/dispatcher.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +101 -0
- package/dist/canvas/deps/editAnchors.js.map +1 -0
- package/dist/canvas/deps/geometryProjection.js +11 -0
- package/dist/canvas/deps/geometryProjection.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +51 -0
- package/dist/canvas/deps/hitTestArea.js.map +1 -0
- package/dist/canvas/deps/ingestion.js +31 -0
- package/dist/canvas/deps/ingestion.js.map +1 -0
- package/dist/canvas/deps/insert.js +116 -0
- package/dist/canvas/deps/insert.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +20 -0
- package/dist/canvas/deps/lassoSelect.js.map +1 -0
- package/dist/canvas/deps/layout.js +34 -0
- package/dist/canvas/deps/layout.js.map +1 -0
- package/dist/canvas/deps/nodeAtPoint.js +19 -0
- package/dist/canvas/deps/nodeAtPoint.js.map +1 -0
- package/dist/canvas/deps/poseComposition.js +11 -0
- package/dist/canvas/deps/poseComposition.js.map +1 -0
- package/dist/canvas/deps/poseDescriptor.js +12 -0
- package/dist/canvas/deps/poseDescriptor.js.map +1 -0
- package/dist/canvas/deps/resizePolicy.js +35 -0
- package/dist/canvas/deps/resizePolicy.js.map +1 -0
- package/dist/canvas/deps/slice.js +99 -0
- package/dist/canvas/deps/slice.js.map +1 -0
- package/dist/canvas/deps/snap.js +11 -0
- package/dist/canvas/deps/snap.js.map +1 -0
- package/dist/canvas/deps/textEdit.js +21 -0
- package/dist/canvas/deps/textEdit.js.map +1 -0
- package/dist/canvas/deps/view.js +43 -0
- package/dist/canvas/deps/view.js.map +1 -0
- package/dist/canvas/derivedPath.js +47 -0
- package/dist/canvas/derivedPath.js.map +1 -0
- package/dist/canvas/drawEnvelope.js +22 -0
- package/dist/canvas/drawEnvelope.js.map +1 -0
- package/dist/canvas/getNodeAtPoint.js +18 -0
- package/dist/canvas/getNodeAtPoint.js.map +1 -0
- package/dist/canvas/hostAnchor.js +29 -0
- package/dist/canvas/hostAnchor.js.map +1 -0
- package/dist/canvas/hud.module.js +18 -0
- package/dist/canvas/hud.module.js.map +1 -0
- package/dist/canvas/insertPreviewExtent.js +103 -0
- package/dist/canvas/insertPreviewExtent.js.map +1 -0
- package/dist/canvas/kitRequirements.js +177 -0
- package/dist/canvas/kitRequirements.js.map +1 -0
- package/dist/canvas/layerOrder.js +66 -0
- package/dist/canvas/layerOrder.js.map +1 -0
- package/dist/canvas/layerSlots.js +14 -0
- package/dist/canvas/layerSlots.js.map +1 -0
- package/dist/canvas/minimapMath.js +80 -0
- package/dist/canvas/minimapMath.js.map +1 -0
- package/dist/canvas/mountedCanvases.js +20 -0
- package/dist/canvas/mountedCanvases.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js +17 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -0
- package/dist/canvas/paintCull.js +20 -0
- package/dist/canvas/paintCull.js.map +1 -0
- package/dist/canvas/pickWalk.js +158 -0
- package/dist/canvas/pickWalk.js.map +1 -0
- package/dist/canvas/planeClips.js +30 -0
- package/dist/canvas/planeClips.js.map +1 -0
- package/dist/canvas/poseRotation.js +35 -0
- package/dist/canvas/poseRotation.js.map +1 -0
- package/dist/canvas/rasterToPng.js +21 -0
- package/dist/canvas/rasterToPng.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +32 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -0
- package/dist/canvas/renderNeeds.js +25 -0
- package/dist/canvas/renderNeeds.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +143 -0
- package/dist/canvas/renderSceneToPixels.js.map +1 -0
- package/dist/canvas/sceneAdapter.js +270 -0
- package/dist/canvas/sceneAdapter.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +37 -0
- package/dist/canvas/sceneLayerPaint.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +20 -0
- package/dist/canvas/sceneSlotWiring.js.map +1 -0
- package/dist/canvas/sceneViewRender.js +72 -0
- package/dist/canvas/sceneViewRender.js.map +1 -0
- package/dist/canvas/slopsDebugLayer.js +61 -0
- package/dist/canvas/slopsDebugLayer.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +15 -0
- package/dist/canvas/surfaceContribution.js.map +1 -0
- package/dist/canvas/toolPreview.js +39 -0
- package/dist/canvas/toolPreview.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +11 -0
- package/dist/canvas/useCanvasRenderer.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +60 -0
- package/dist/canvas/useFrameLoop.js.map +1 -0
- package/dist/canvas/useHostAnchor.js +71 -0
- package/dist/canvas/useHostAnchor.js.map +1 -0
- package/dist/canvas/useLateContentRedraw.js +21 -0
- package/dist/canvas/useLateContentRedraw.js.map +1 -0
- package/dist/canvas/useRedrawOn.js +21 -0
- package/dist/canvas/useRedrawOn.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +120 -0
- package/dist/canvas/useViewHelpers.js.map +1 -0
- package/dist/canvas/viewInputs.js +17 -0
- package/dist/canvas/viewInputs.js.map +1 -0
- package/dist/canvas/viewRegistry.js +61 -0
- package/dist/canvas/viewRegistry.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js +14 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -0
- package/dist/clipboard.d.ts +10 -5
- package/dist/clipboard.js +3 -5
- package/dist/clone.d.ts +3 -3
- package/dist/clone.js +2 -5
- package/dist/core/adapters/arrayAdapter.js +85 -0
- package/dist/core/adapters/arrayAdapter.js.map +1 -0
- package/dist/core/adapters/useArrayAdapter.js +13 -0
- package/dist/core/adapters/useArrayAdapter.js.map +1 -0
- package/dist/core/applyOps.js +12 -0
- package/dist/core/applyOps.js.map +1 -0
- package/dist/core/device/index.js +4 -0
- package/dist/core/device/targets.js +17 -0
- package/dist/core/device/targets.js.map +1 -0
- package/dist/core/device/useDeviceProfile.js +75 -0
- package/dist/core/device/useDeviceProfile.js.map +1 -0
- package/dist/core/fillInPoseFrame.js +102 -0
- package/dist/core/fillInPoseFrame.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +98 -0
- package/dist/core/geometry/poseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseRotation.js +58 -0
- package/dist/core/geometry/poseRotation.js.map +1 -0
- package/dist/core/geometry/regionHit.js +102 -0
- package/dist/core/geometry/regionHit.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +60 -0
- package/dist/core/geometry/unionBounds.js.map +1 -0
- package/dist/core/gradient.js +136 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/isPlainObject.js +11 -0
- package/dist/core/isPlainObject.js.map +1 -0
- package/dist/core/layers/render.js +150 -0
- package/dist/core/layers/render.js.map +1 -0
- package/dist/core/markerInset.js +24 -0
- package/dist/core/markerInset.js.map +1 -0
- package/dist/core/mixed.js +6 -0
- package/dist/core/mixed.js.map +1 -0
- package/dist/core/ops/arrange.js +31 -0
- package/dist/core/ops/arrange.js.map +1 -0
- package/dist/core/ops/create.js +32 -0
- package/dist/core/ops/create.js.map +1 -0
- package/dist/core/ops/createHistory.js +20 -0
- package/dist/core/ops/createHistory.js.map +1 -0
- package/dist/core/ops/delete.js +89 -0
- package/dist/core/ops/delete.js.map +1 -0
- package/dist/core/ops/registry.js +17 -0
- package/dist/core/ops/registry.js.map +1 -0
- package/dist/core/ops/reorder/algorithms.js +55 -0
- package/dist/core/ops/reorder/algorithms.js.map +1 -0
- package/dist/core/ops/reorder/index.js +140 -0
- package/dist/core/ops/reorder/index.js.map +1 -0
- package/dist/core/ops/reparent.js +52 -0
- package/dist/core/ops/reparent.js.map +1 -0
- package/dist/core/ops/select.js +34 -0
- package/dist/core/ops/select.js.map +1 -0
- package/dist/core/ops/setData.js +34 -0
- package/dist/core/ops/setData.js.map +1 -0
- package/dist/core/ops/setLayer.js +34 -0
- package/dist/core/ops/setLayer.js.map +1 -0
- package/dist/core/ops/setLayout.js +31 -0
- package/dist/core/ops/setLayout.js.map +1 -0
- package/dist/core/ops/setPath.js +57 -0
- package/dist/core/ops/setPath.js.map +1 -0
- package/dist/core/ops/setText.js +34 -0
- package/dist/core/ops/setText.js.map +1 -0
- package/dist/core/ops/slot.js +37 -0
- package/dist/core/ops/slot.js.map +1 -0
- package/dist/core/ops/transform.js +42 -0
- package/dist/core/ops/transform.js.map +1 -0
- package/dist/core/paintKinds.js +156 -0
- package/dist/core/paintKinds.js.map +1 -0
- package/dist/core/scene/NodeProperties.js +20 -0
- package/dist/core/scene/NodeProperties.js.map +1 -0
- package/dist/core/scene/NodeRouting.js +24 -0
- package/dist/core/scene/NodeRouting.js.map +1 -0
- package/dist/core/scene/arrivals.js +12 -0
- package/dist/core/scene/arrivals.js.map +1 -0
- package/dist/core/scene/composeFrame.js +29 -0
- package/dist/core/scene/composeFrame.js.map +1 -0
- package/dist/core/scene/depMemo.js +18 -0
- package/dist/core/scene/depMemo.js.map +1 -0
- package/dist/core/scene/dependents.js +66 -0
- package/dist/core/scene/dependents.js.map +1 -0
- package/dist/core/scene/derivedPath.js +31 -0
- package/dist/core/scene/derivedPath.js.map +1 -0
- package/dist/core/scene/effectivePose.js +78 -0
- package/dist/core/scene/effectivePose.js.map +1 -0
- package/dist/core/scene/kitRegistry.js +33 -0
- package/dist/core/scene/kitRegistry.js.map +1 -0
- package/dist/core/scene/layoutPass.js +96 -0
- package/dist/core/scene/layoutPass.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +83 -0
- package/dist/core/scene/nodeFnFields.js.map +1 -0
- package/dist/core/scene/nodeMemo.js +28 -0
- package/dist/core/scene/nodeMemo.js.map +1 -0
- package/dist/core/scene/poseFeed.js +87 -0
- package/dist/core/scene/poseFeed.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +52 -0
- package/dist/core/scene/poseOverrides.js.map +1 -0
- package/dist/core/scene/poseSnapshot.js +54 -0
- package/dist/core/scene/poseSnapshot.js.map +1 -0
- package/dist/core/scene/scene.js +1271 -0
- package/dist/core/scene/scene.js.map +1 -0
- package/dist/core/scene/types.js +6 -0
- package/dist/core/scene/types.js.map +1 -0
- package/dist/core/scene/useScene.js +32 -0
- package/dist/core/scene/useScene.js.map +1 -0
- package/dist/core/selection/chromeState.js +31 -0
- package/dist/core/selection/chromeState.js.map +1 -0
- package/dist/core/selection/selectionTarget.js +6 -0
- package/dist/core/selection/selectionTarget.js.map +1 -0
- package/dist/core/selection/useSelection.js +71 -0
- package/dist/core/selection/useSelection.js.map +1 -0
- package/dist/core/shapeKinds.js +54 -0
- package/dist/core/shapeKinds.js.map +1 -0
- package/dist/core/strokeMarkerShapes.js +139 -0
- package/dist/core/strokeMarkerShapes.js.map +1 -0
- package/dist/core/strokeMarkers.js +28 -0
- package/dist/core/strokeMarkers.js.map +1 -0
- package/dist/core/stylus/stylus.js +39 -0
- package/dist/core/stylus/stylus.js.map +1 -0
- package/dist/core/stylus/usePointerStylus.js +51 -0
- package/dist/core/stylus/usePointerStylus.js.map +1 -0
- package/dist/core/usePaintKinds.js +17 -0
- package/dist/core/usePaintKinds.js.map +1 -0
- package/dist/core/viewport/clampView.js +24 -0
- package/dist/core/viewport/clampView.js.map +1 -0
- package/dist/core/viewport/clientToWorld.js +8 -0
- package/dist/core/viewport/clientToWorld.js.map +1 -0
- package/dist/core/viewport/createVelocityTracker.js +39 -0
- package/dist/core/viewport/createVelocityTracker.js.map +1 -0
- package/dist/core/viewport/fitToBounds.js +18 -0
- package/dist/core/viewport/fitToBounds.js.map +1 -0
- package/dist/core/viewport/fitViewToBounds.js +36 -0
- package/dist/core/viewport/fitViewToBounds.js.map +1 -0
- package/dist/core/viewport/interpolateView.js +34 -0
- package/dist/core/viewport/interpolateView.js.map +1 -0
- package/dist/core/viewport/meanScale.js +8 -0
- package/dist/core/viewport/meanScale.js.map +1 -0
- package/dist/core/viewport/parallax.js +111 -0
- package/dist/core/viewport/parallax.js.map +1 -0
- package/dist/core/viewport/pxExtent.js +42 -0
- package/dist/core/viewport/pxExtent.js.map +1 -0
- package/dist/core/viewport/sceneNodeClientRect.js +18 -0
- package/dist/core/viewport/sceneNodeClientRect.js.map +1 -0
- package/dist/core/viewport/screenSlop.js +27 -0
- package/dist/core/viewport/screenSlop.js.map +1 -0
- package/dist/core/viewport/useAutoCenter.js +32 -0
- package/dist/core/viewport/useAutoCenter.js.map +1 -0
- package/dist/core/viewport/useCanvasSize.js +29 -0
- package/dist/core/viewport/useCanvasSize.js.map +1 -0
- package/dist/core/viewport/useDecayLoop.js +63 -0
- package/dist/core/viewport/useDecayLoop.js.map +1 -0
- package/dist/core/viewport/useVelocityTracker.js +10 -0
- package/dist/core/viewport/useVelocityTracker.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +63 -0
- package/dist/core/viewport/useViewAnimation.js.map +1 -0
- package/dist/core/viewport/view.js +37 -0
- package/dist/core/viewport/view.js.map +1 -0
- package/dist/core/viewport/viewTransform.js +11 -0
- package/dist/core/viewport/viewTransform.js.map +1 -0
- package/dist/core/viewport/viewportWorldRect.js +13 -0
- package/dist/core/viewport/viewportWorldRect.js.map +1 -0
- package/dist/core/viewport/wheelHandler.js +30 -0
- package/dist/core/viewport/wheelHandler.js.map +1 -0
- package/dist/core/viewport/zoomAt.js +22 -0
- package/dist/core/viewport/zoomAt.js.map +1 -0
- package/dist/core/viewport/zoomBounds.js +20 -0
- package/dist/core/viewport/zoomBounds.js.map +1 -0
- package/dist/{pointSnapToGrid-7mCcm6qG.d.ts → cornerHandles-CDcZOV8h.d.ts} +54 -71
- package/dist/debug/createDebugOverlayLayer.js +358 -0
- package/dist/debug/createDebugOverlayLayer.js.map +1 -0
- package/dist/debug/createDebugSink.js +83 -0
- package/dist/debug/createDebugSink.js.map +1 -0
- package/dist/debug/defaultTheme.js +31 -0
- package/dist/debug/defaultTheme.js.map +1 -0
- package/dist/debug/flag.js +41 -0
- package/dist/debug/flag.js.map +1 -0
- package/dist/debug/frameStats.js +16 -0
- package/dist/debug/frameStats.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +32 -0
- package/dist/debug/parseDebugFlags.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js +16 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -0
- package/dist/features/chrome-caps/conditions.js +36 -0
- package/dist/features/chrome-caps/conditions.js.map +1 -0
- package/dist/features/chrome-caps/defaults.js +26 -0
- package/dist/features/chrome-caps/defaults.js.map +1 -0
- package/dist/features/chrome-caps/index.js +7 -0
- package/dist/features/chrome-caps/resolve.js +23 -0
- package/dist/features/chrome-caps/resolve.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +27 -0
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -0
- package/dist/features/cursor/paintedCursorLayer.js +60 -0
- package/dist/features/cursor/paintedCursorLayer.js.map +1 -0
- package/dist/features/focus/gateLayer.js +14 -0
- package/dist/features/focus/gateLayer.js.map +1 -0
- package/dist/features/focus/useCanvasFocus.js +29 -0
- package/dist/features/focus/useCanvasFocus.js.map +1 -0
- package/dist/features/groups/children.js +23 -0
- package/dist/features/groups/children.js.map +1 -0
- package/dist/features/groups/composePose.js +67 -0
- package/dist/features/groups/composePose.js.map +1 -0
- package/dist/features/groups/nestedHit.js +40 -0
- package/dist/features/groups/nestedHit.js.map +1 -0
- package/dist/features/groups/unionOfChildren.js +15 -0
- package/dist/features/groups/unionOfChildren.js.map +1 -0
- package/dist/features/images/imageCache.js +94 -0
- package/dist/features/images/imageCache.js.map +1 -0
- package/dist/features/ingestion/contentHandlers.js +37 -0
- package/dist/features/ingestion/contentHandlers.js.map +1 -0
- package/dist/features/ingestion/imageHandler.js +45 -0
- package/dist/features/ingestion/imageHandler.js.map +1 -0
- package/dist/features/ingestion/index.js +8 -0
- package/dist/features/ingestion/openFilePicker.js +15 -0
- package/dist/features/ingestion/openFilePicker.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +26 -0
- package/dist/features/ingestion/registerKitHandlers.js.map +1 -0
- package/dist/features/ingestion/svgHandler.js +58 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +39 -0
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -0
- package/dist/features/longPress/longPressFeedback.js +96 -0
- package/dist/features/longPress/longPressFeedback.js.map +1 -0
- package/dist/features/meshPaint/bake.js +79 -0
- package/dist/features/meshPaint/bake.js.map +1 -0
- package/dist/features/meshPaint/bakeCache.js +59 -0
- package/dist/features/meshPaint/bakeCache.js.map +1 -0
- package/dist/features/meshPaint/handles.js +86 -0
- package/dist/features/meshPaint/handles.js.map +1 -0
- package/dist/features/meshPaint/lazyKind.js +1298 -0
- package/dist/features/meshPaint/lazyKind.js.map +1 -0
- package/dist/features/meshPaint/meshPaint.js +236 -0
- package/dist/features/meshPaint/meshPaint.js.map +1 -0
- package/dist/features/meshPaint/meshShader.js +6 -0
- package/dist/features/meshPaint/meshShader.js.map +1 -0
- package/dist/features/meshPaint/register.js +7 -0
- package/dist/features/meshPaint/register.js.map +1 -0
- package/dist/features/meshPaint/surface.js +110 -0
- package/dist/features/meshPaint/surface.js.map +1 -0
- package/dist/features/minimap/actions.js +53 -0
- package/dist/features/minimap/actions.js.map +1 -0
- package/dist/features/minimap/createMinimapContribution.js +96 -0
- package/dist/features/minimap/createMinimapContribution.js.map +1 -0
- package/dist/features/minimap/layers.js +103 -0
- package/dist/features/minimap/layers.js.map +1 -0
- package/dist/features/modes/modeLayers.js +113 -0
- package/dist/features/modes/modeLayers.js.map +1 -0
- package/dist/features/overlays/useNodeOverlayFrame.js +103 -0
- package/dist/features/overlays/useNodeOverlayFrame.js.map +1 -0
- package/dist/features/parallax/createParallaxLayer.js +26 -0
- package/dist/features/parallax/createParallaxLayer.js.map +1 -0
- package/dist/features/parallax/createParallaxPlane.js +26 -0
- package/dist/features/parallax/createParallaxPlane.js.map +1 -0
- package/dist/features/paths/anchorEdits.js +156 -0
- package/dist/features/paths/anchorEdits.js.map +1 -0
- package/dist/features/paths/anchors.js +154 -0
- package/dist/features/paths/anchors.js.map +1 -0
- package/dist/features/paths/booleans.js +2 -0
- package/dist/features/paths/index.js +15 -0
- package/dist/features/paths/markerCommands.js +116 -0
- package/dist/features/paths/markerCommands.js.map +1 -0
- package/dist/features/paths/markerSites.js +59 -0
- package/dist/features/paths/markerSites.js.map +1 -0
- package/dist/features/paths/markers.js +95 -0
- package/dist/features/paths/markers.js.map +1 -0
- package/dist/features/paths/nearestAnchor.js +36 -0
- package/dist/features/paths/nearestAnchor.js.map +1 -0
- package/dist/features/paths/originProjection.js +16 -0
- package/dist/features/paths/originProjection.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +137 -0
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -0
- package/dist/features/paths/pathInWorld.js +41 -0
- package/dist/features/paths/pathInWorld.js.map +1 -0
- package/dist/features/paths/pathLayer.js +44 -0
- package/dist/features/paths/pathLayer.js.map +1 -0
- package/dist/features/paths/penPreviewLayer.js +220 -0
- package/dist/features/paths/penPreviewLayer.js.map +1 -0
- package/dist/features/paths/poseDescriptor.js +44 -0
- package/dist/features/paths/poseDescriptor.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js +230 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -0
- package/dist/features/patterns/index.js +23 -0
- package/dist/features/patterns/index.js.map +1 -0
- package/dist/features/patterns/patterns-builtin.js +38 -0
- package/dist/features/patterns/patterns-builtin.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +57 -0
- package/dist/features/patterns/resolveSpec.js.map +1 -0
- package/dist/features/patterns/tileGeometry.js +158 -0
- package/dist/features/patterns/tileGeometry.js.map +1 -0
- package/dist/features/pointer/PointerContext.js +45 -0
- package/dist/features/pointer/PointerContext.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +70 -0
- package/dist/features/poseRun/usePoseRun.js.map +1 -0
- package/dist/features/selection/SelectionContext.js +46 -0
- package/dist/features/selection/SelectionContext.js.map +1 -0
- package/dist/features/selection/overlay.js +442 -0
- package/dist/features/selection/overlay.js.map +1 -0
- package/dist/features/simulation/createSimulation.js +61 -0
- package/dist/features/simulation/createSimulation.js.map +1 -0
- package/dist/features/simulation/types.js +6 -0
- package/dist/features/simulation/types.js.map +1 -0
- package/dist/features/simulation/useSimulation.js +74 -0
- package/dist/features/simulation/useSimulation.js.map +1 -0
- package/dist/features/text/domRuns.js +258 -0
- package/dist/features/text/domRuns.js.map +1 -0
- package/dist/features/text/fitTextPose.js +38 -0
- package/dist/features/text/fitTextPose.js.map +1 -0
- package/dist/features/text/hitTest.js +45 -0
- package/dist/features/text/hitTest.js.map +1 -0
- package/dist/features/text/renderLabel.js +14 -0
- package/dist/features/text/renderLabel.js.map +1 -0
- package/dist/features/text/runs/effectiveRangeStyle.js +66 -0
- package/dist/features/text/runs/effectiveRangeStyle.js.map +1 -0
- package/dist/features/text/runs/flagRange.js +53 -0
- package/dist/features/text/runs/flagRange.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +135 -0
- package/dist/features/text/runs/rangeStyle.js.map +1 -0
- package/dist/features/text/textCommand.js +59 -0
- package/dist/features/text/textCommand.js.map +1 -0
- package/dist/features/text/textLayer.js +35 -0
- package/dist/features/text/textLayer.js.map +1 -0
- package/dist/features/text/textToPath.js +181 -0
- package/dist/features/text/textToPath.js.map +1 -0
- package/dist/features/text/useSceneTextEdit.js +138 -0
- package/dist/features/text/useSceneTextEdit.js.map +1 -0
- package/dist/features/text/useTextEdit.js +465 -0
- package/dist/features/text/useTextEdit.js.map +1 -0
- package/dist/features/tiling/createTiledLayer.js +63 -0
- package/dist/features/tiling/createTiledLayer.js.map +1 -0
- package/dist/features/tiling/tiledProject.js +14 -0
- package/dist/features/tiling/tiledProject.js.map +1 -0
- package/dist/features/viewports/viewResolver.js +59 -0
- package/dist/features/viewports/viewResolver.js.map +1 -0
- package/dist/features/viewports/viewportLayer.js +58 -0
- package/dist/features/viewports/viewportLayer.js.map +1 -0
- package/dist/icons/ArrowIcon.js +23 -0
- package/dist/icons/ArrowIcon.js.map +1 -0
- package/dist/icons/EllipseIcon.js +21 -0
- package/dist/icons/EllipseIcon.js.map +1 -0
- package/dist/icons/EyedropperIcon.js +49 -0
- package/dist/icons/EyedropperIcon.js.map +1 -0
- package/dist/icons/HandIcon.js +59 -0
- package/dist/icons/HandIcon.js.map +1 -0
- package/dist/icons/ImageIcon.js +34 -0
- package/dist/icons/ImageIcon.js.map +1 -0
- package/dist/icons/LassoIcon.js +22 -0
- package/dist/icons/LassoIcon.js.map +1 -0
- package/dist/icons/LineIcon.js +22 -0
- package/dist/icons/LineIcon.js.map +1 -0
- package/dist/icons/PenIcon.js +36 -0
- package/dist/icons/PenIcon.js.map +1 -0
- package/dist/icons/PencilIcon.js +25 -0
- package/dist/icons/PencilIcon.js.map +1 -0
- package/dist/icons/PolygonIcon.js +19 -0
- package/dist/icons/PolygonIcon.js.map +1 -0
- package/dist/icons/RectIcon.js +37 -0
- package/dist/icons/RectIcon.js.map +1 -0
- package/dist/icons/SelectIcon.js +20 -0
- package/dist/icons/SelectIcon.js.map +1 -0
- package/dist/icons/StarIcon.js +19 -0
- package/dist/icons/StarIcon.js.map +1 -0
- package/dist/icons/TextIcon.js +19 -0
- package/dist/icons/TextIcon.js.map +1 -0
- package/dist/icons/UnknownIcon.js +33 -0
- package/dist/icons/UnknownIcon.js.map +1 -0
- package/dist/icons/_base.js +12 -0
- package/dist/icons/_base.js.map +1 -0
- package/dist/index.css +2 -86
- package/dist/index.d.ts +2349 -2609
- package/dist/index.js +312 -13
- package/dist/input/keyState.js +76 -0
- package/dist/input/keyState.js.map +1 -0
- package/dist/input/useKeyState.js +22 -0
- package/dist/input/useKeyState.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js +32 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -0
- package/dist/interactions/actions/align/align.js +81 -0
- package/dist/interactions/actions/align/align.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +120 -0
- package/dist/interactions/actions/booleans/booleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +20 -0
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js +9 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +94 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -0
- package/dist/interactions/actions/clipboard/materializePaste.js +25 -0
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -0
- package/dist/interactions/actions/clipboard/wireFormat.js +43 -0
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +26 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +42 -0
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -0
- package/dist/interactions/actions/defaults/align.js +71 -0
- package/dist/interactions/actions/defaults/align.js.map +1 -0
- package/dist/interactions/actions/defaults/anchorEditing.js +235 -0
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -0
- package/dist/interactions/actions/defaults/areaSelect.js +75 -0
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/booleans.js +52 -0
- package/dist/interactions/actions/defaults/booleans.js.map +1 -0
- package/dist/interactions/actions/defaults/cancelGesture.js +24 -0
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -0
- package/dist/interactions/actions/defaults/clearSelection.js +19 -0
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/clipboard.js +78 -0
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -0
- package/dist/interactions/actions/defaults/clone.js +96 -0
- package/dist/interactions/actions/defaults/clone.js.map +1 -0
- package/dist/interactions/actions/defaults/createOutlines.js +47 -0
- package/dist/interactions/actions/defaults/createOutlines.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js +85 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -0
- package/dist/interactions/actions/defaults/delete.js +61 -0
- package/dist/interactions/actions/defaults/delete.js.map +1 -0
- package/dist/interactions/actions/defaults/distribute.js +66 -0
- package/dist/interactions/actions/defaults/distribute.js.map +1 -0
- package/dist/interactions/actions/defaults/duplicate.js +83 -0
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -0
- package/dist/interactions/actions/defaults/editAnchors.js +100 -0
- package/dist/interactions/actions/defaults/editAnchors.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +29 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js +20 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/escape.js +26 -0
- package/dist/interactions/actions/defaults/escape.js.map +1 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js +22 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/flip.js +119 -0
- package/dist/interactions/actions/defaults/flip.js.map +1 -0
- package/dist/interactions/actions/defaults/freshNodeId.js +10 -0
- package/dist/interactions/actions/defaults/freshNodeId.js.map +1 -0
- package/dist/interactions/actions/defaults/group.js +131 -0
- package/dist/interactions/actions/defaults/group.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js +40 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js +10 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js +173 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +171 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js +63 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js +280 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +53 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/ingest.js +58 -0
- package/dist/interactions/actions/defaults/ingest.js.map +1 -0
- package/dist/interactions/actions/defaults/insert.js +288 -0
- package/dist/interactions/actions/defaults/insert.js.map +1 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js +50 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -0
- package/dist/interactions/actions/defaults/lassoSelect.js +156 -0
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/move.js +656 -0
- package/dist/interactions/actions/defaults/move.js.map +1 -0
- package/dist/interactions/actions/defaults/nudge.js +110 -0
- package/dist/interactions/actions/defaults/nudge.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js +63 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -0
- package/dist/interactions/actions/defaults/reorder.js +143 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -0
- package/dist/interactions/actions/defaults/requiresSelection.js +10 -0
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/resize.js +332 -0
- package/dist/interactions/actions/defaults/resize.js.map +1 -0
- package/dist/interactions/actions/defaults/rotate.js +181 -0
- package/dist/interactions/actions/defaults/rotate.js.map +1 -0
- package/dist/interactions/actions/defaults/selectAll.js +27 -0
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +27 -0
- package/dist/interactions/actions/defaults/setFill.js.map +1 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js +15 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/setStroke.js +36 -0
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +21 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/slice.js +39 -0
- package/dist/interactions/actions/defaults/slice.js.map +1 -0
- package/dist/interactions/actions/defaults/sliceOps.js +60 -0
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -0
- package/dist/interactions/actions/defaults/toolActivate.js +35 -0
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js +26 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -0
- package/dist/interactions/actions/defaults/undoRedo.js +51 -0
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js +88 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js +57 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportZoom.js +143 -0
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +42 -0
- package/dist/interactions/actions/distribute/distribute.js.map +1 -0
- package/dist/interactions/actions/distribute/plan.js +29 -0
- package/dist/interactions/actions/distribute/plan.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +61 -0
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/handles.js +43 -0
- package/dist/interactions/actions/edit-anchors/handles.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +35 -0
- package/dist/interactions/actions/flip/helpers.js.map +1 -0
- package/dist/interactions/actions/geometryProjection.js +18 -0
- package/dist/interactions/actions/geometryProjection.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +44 -0
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +39 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +36 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +67 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +37 -0
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +84 -0
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js +9 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js.map +1 -0
- package/dist/interactions/actions/planeInput.js +168 -0
- package/dist/interactions/actions/planeInput.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +9 -0
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -0
- package/dist/interactions/actions/poseFrame.js +38 -0
- package/dist/interactions/actions/poseFrame.js.map +1 -0
- package/dist/interactions/actions/previewOverrides.js +25 -0
- package/dist/interactions/actions/previewOverrides.js.map +1 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js +32 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js +18 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/index.js +8 -0
- package/dist/interactions/actions/resize/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js +24 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -0
- package/dist/interactions/actions/resize/cornerHandles.js +72 -0
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js +60 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -0
- package/dist/interactions/actions/resolvePreviews.js +61 -0
- package/dist/interactions/actions/resolvePreviews.js.map +1 -0
- package/dist/interactions/actions/rotate/geometry.js +46 -0
- package/dist/interactions/actions/rotate/geometry.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +27 -0
- package/dist/interactions/actions/rotate/handle.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js +42 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +142 -0
- package/dist/interactions/actions/useStandardActions.js.map +1 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js +111 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js +117 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -0
- package/dist/interactions/gestures/dragRect/dragRect.js +164 -0
- package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +46 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +118 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -0
- package/dist/interactions/gestures/shared/originProjection.js +42 -0
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -0
- package/dist/interactions/gestures/shared/screenTolerance.js +21 -0
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -0
- package/dist/interactions/gestures/shared/snap.js +24 -0
- package/dist/interactions/gestures/shared/snap.js.map +1 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +30 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -0
- package/dist/layout/arrivals.js +36 -0
- package/dist/layout/arrivals.js.map +1 -0
- package/dist/{math-MCQcf_gc.d.ts → math-CUMxmZzn.d.ts} +8 -116
- package/dist/math.d.ts +4 -5
- package/dist/math.js +6 -4
- package/dist/mesh.d.ts +268 -0
- package/dist/mesh.js +7 -0
- package/dist/move.d.ts +7 -48
- package/dist/move.js +3 -142
- package/dist/originProjection-BSn4xiEy.d.ts +57 -0
- package/dist/patterns-builtin.js +3 -3
- package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-CjSXMf8X.d.ts} +3 -3
- package/dist/registerProgram-ateHDGjw.d.ts +193 -0
- package/dist/renderer/DrawCommand.js +6 -0
- package/dist/renderer/DrawCommand.js.map +1 -0
- package/dist/renderer/WeaselRenderer.js +328 -0
- package/dist/renderer/WeaselRenderer.js.map +1 -0
- package/dist/renderer/cache/GLImageCache.js +64 -0
- package/dist/renderer/cache/GLImageCache.js.map +1 -0
- package/dist/renderer/cache/GLMeshCache.js +102 -0
- package/dist/renderer/cache/GLMeshCache.js.map +1 -0
- package/dist/renderer/cache/GLTextureCache.js +51 -0
- package/dist/renderer/cache/GLTextureCache.js.map +1 -0
- package/dist/renderer/cache/GradientRampAtlas.js +82 -0
- package/dist/renderer/cache/GradientRampAtlas.js.map +1 -0
- package/dist/renderer/cache/cache.js +13 -0
- package/dist/renderer/cache/cache.js.map +1 -0
- package/dist/renderer/cache/markerCommandCache.js +59 -0
- package/dist/renderer/cache/markerCommandCache.js.map +1 -0
- package/dist/renderer/cache/outlineMeshCache.js +15 -0
- package/dist/renderer/cache/outlineMeshCache.js.map +1 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js +31 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -0
- package/dist/renderer/cache/strokeMeshCache.js +44 -0
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -0
- package/dist/renderer/cullDrawCommands.js +89 -0
- package/dist/renderer/cullDrawCommands.js.map +1 -0
- package/dist/renderer/draw.js +1109 -0
- package/dist/renderer/draw.js.map +1 -0
- package/dist/renderer/drawBatch.js +168 -0
- package/dist/renderer/drawBatch.js.map +1 -0
- package/dist/renderer/effects/EffectTargets.js +45 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -0
- package/dist/renderer/effects/builtins.js +31 -0
- package/dist/renderer/effects/builtins.js.map +1 -0
- package/dist/renderer/effects/composite.js +9 -0
- package/dist/renderer/effects/composite.js.map +1 -0
- package/dist/renderer/effects/effectPrelude.js +10 -0
- package/dist/renderer/effects/effectPrelude.js.map +1 -0
- package/dist/renderer/effects/types.js +10 -0
- package/dist/renderer/effects/types.js.map +1 -0
- package/dist/renderer/index.js +19 -0
- package/dist/renderer/math/color.js +341 -0
- package/dist/renderer/math/color.js.map +1 -0
- package/dist/renderer/math/mat3.js +71 -0
- package/dist/renderer/math/mat3.js.map +1 -0
- package/dist/renderer/math/patternSpace.js +22 -0
- package/dist/renderer/math/patternSpace.js.map +1 -0
- package/dist/renderer/math/viewToMat3.js +19 -0
- package/dist/renderer/math/viewToMat3.js.map +1 -0
- package/dist/renderer/paintResources.js +18 -0
- package/dist/renderer/paintResources.js.map +1 -0
- package/dist/renderer/paintScratch.js +37 -0
- package/dist/renderer/paintScratch.js.map +1 -0
- package/dist/renderer/shaders/ShaderProgram.js +74 -0
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -0
- package/dist/renderer/shaders/batchFill.js +118 -0
- package/dist/renderer/shaders/batchFill.js.map +1 -0
- package/dist/renderer/shaders/customPrelude.js +34 -0
- package/dist/renderer/shaders/customPrelude.js.map +1 -0
- package/dist/renderer/shaders/extractUniformNames.js +184 -0
- package/dist/renderer/shaders/extractUniformNames.js.map +1 -0
- package/dist/renderer/shaders/glyphPaint.js +61 -0
- package/dist/renderer/shaders/glyphPaint.js.map +1 -0
- package/dist/renderer/shaders/gradFill.js +30 -0
- package/dist/renderer/shaders/gradFill.js.map +1 -0
- package/dist/renderer/shaders/imageFill.js +14 -0
- package/dist/renderer/shaders/imageFill.js.map +1 -0
- package/dist/renderer/shaders/pathFill.js +13 -0
- package/dist/renderer/shaders/pathFill.js.map +1 -0
- package/dist/renderer/shaders/patternFill.js +24 -0
- package/dist/renderer/shaders/patternFill.js.map +1 -0
- package/dist/renderer/shaders/registerProgram.js +18 -0
- package/dist/renderer/shaders/registerProgram.js.map +1 -0
- package/dist/renderer/spriteSheet.js +14 -0
- package/dist/renderer/spriteSheet.js.map +1 -0
- package/dist/renderer/state/GroupState.js +77 -0
- package/dist/renderer/state/GroupState.js.map +1 -0
- package/dist/renderer/syntheticItalic.js +6 -0
- package/dist/renderer/syntheticItalic.js.map +1 -0
- package/dist/renderer/textures/registerTexture.js +14 -0
- package/dist/renderer/textures/registerTexture.js.map +1 -0
- package/dist/renderer.d.ts +18 -20
- package/dist/renderer.js +18 -13
- package/dist/resize.d.ts +10 -46
- package/dist/resize.js +7 -5
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +2 -3
- package/dist/scheduling/useVisibleRaf.js +69 -0
- package/dist/scheduling/useVisibleRaf.js.map +1 -0
- package/dist/test-hook/createTestHook.js +39 -0
- package/dist/test-hook/createTestHook.js.map +1 -0
- package/dist/test-hook/install.js +12 -0
- package/dist/test-hook/install.js.map +1 -0
- package/dist/test-seams-fYf6m5pu.d.ts +356 -0
- package/dist/test-seams.d.ts +6 -0
- package/dist/test-seams.js +3 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +33 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +55 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -0
- package/dist/tools/builtin/hand/dragPanContribution.js +17 -0
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -0
- package/dist/tools/builtin/hand/useHandTool.js +31 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -0
- package/dist/tools/builtin/image/useImageTool.js +41 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js +42 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -0
- package/dist/tools/builtin/line/useLineTool.js +33 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -0
- package/dist/tools/builtin/pen/usePenTool.js +414 -0
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js +36 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -0
- package/dist/tools/builtin/pickTopMostHit.js +45 -0
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js +81 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +32 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +109 -0
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -0
- package/dist/tools/builtin/select/useSelectTool.js +162 -0
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -0
- package/dist/tools/builtin/shared/insertToolOptions.js +8 -0
- package/dist/tools/builtin/shared/insertToolOptions.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +263 -0
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -0
- package/dist/tools/builtin/star/useStarTool.js +82 -0
- package/dist/tools/builtin/star/useStarTool.js.map +1 -0
- package/dist/tools/builtin/text/useTextTool.js +177 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -0
- package/dist/tools/overlayBinding.js +8 -0
- package/dist/tools/overlayBinding.js.map +1 -0
- package/dist/tools/prefs.js +47 -0
- package/dist/tools/prefs.js.map +1 -0
- package/dist/tools/useKeybindings.js +66 -0
- package/dist/tools/useKeybindings.js.map +1 -0
- package/dist/{types-CxC8P6W0.d.ts → types-CA54-mAZ.d.ts} +188 -17
- package/dist/{types-D_74YlWs.d.ts → types-DSjd6W3n.d.ts} +35 -12
- package/dist/util/color.js +26 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/constrainTo45.js +17 -0
- package/dist/util/constrainTo45.js.map +1 -0
- package/dist/util/paint.js +72 -0
- package/dist/util/paint.js.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +31 -18
- package/dist/chunk-44EWMJV2.js +0 -128
- package/dist/chunk-44EWMJV2.js.map +0 -1
- package/dist/chunk-4RJP2N2L.js +0 -143
- package/dist/chunk-4RJP2N2L.js.map +0 -1
- package/dist/chunk-BJN5ZRIJ.js +0 -167
- package/dist/chunk-BJN5ZRIJ.js.map +0 -1
- package/dist/chunk-D4AAWR64.js +0 -28
- package/dist/chunk-D4AAWR64.js.map +0 -1
- package/dist/chunk-DOBSZOPR.js +0 -29
- package/dist/chunk-DOBSZOPR.js.map +0 -1
- package/dist/chunk-H6N2JSZ3.js +0 -248
- package/dist/chunk-H6N2JSZ3.js.map +0 -1
- package/dist/chunk-HPFJUUTF.js +0 -167
- package/dist/chunk-HPFJUUTF.js.map +0 -1
- package/dist/chunk-L5YNZYEG.js +0 -648
- package/dist/chunk-L5YNZYEG.js.map +0 -1
- package/dist/chunk-MZAIDI6D.js +0 -32492
- package/dist/chunk-MZAIDI6D.js.map +0 -1
- package/dist/chunk-PNNZSYRD.js +0 -318
- package/dist/chunk-PNNZSYRD.js.map +0 -1
- package/dist/chunk-RMR4QMM6.js +0 -250
- package/dist/chunk-RMR4QMM6.js.map +0 -1
- package/dist/clipboard.js.map +0 -1
- package/dist/clone.js.map +0 -1
- package/dist/grid-BXdz8GF2.d.ts +0 -158
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/insert.d.ts +0 -37
- package/dist/insert.js +0 -81
- package/dist/insert.js.map +0 -1
- package/dist/math.js.map +0 -1
- package/dist/move.js.map +0 -1
- package/dist/options-CzjxFoYZ.d.ts +0 -67
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/patterns-builtin.js.map +0 -1
- package/dist/renderer.css +0 -86
- package/dist/renderer.css.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/dist/resize.js.map +0 -1
- package/dist/routing.js.map +0 -1
- package/dist/types-D2tTKEU0.d.ts +0 -18
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { targetSizesPx as e } from "../core/device/targets.js";
|
|
2
|
+
import { hitAffordanceRegions as t } from "../affordances/hitAffordanceRegions.js";
|
|
3
|
+
import { createCornerResizeAffordance as n } from "../affordances/cornerResize.js";
|
|
4
|
+
import { createRotationAffordance as r } from "../affordances/rotationHandle.js";
|
|
5
|
+
import { createPathAnchorAffordances as i } from "../affordances/pathAnchors.js";
|
|
6
|
+
//#region src/canvas/affordanceAt.ts
|
|
7
|
+
function a(t = {}) {
|
|
8
|
+
let a = e(t.targetScale), { handleHitRadius: o = a.handle, anchorHitRadius: s = a.anchor, rotateBandPx: c = a.rotationDistance, getAnchorState: l, rotationBadge: u } = t;
|
|
9
|
+
return [
|
|
10
|
+
r({
|
|
11
|
+
bandPx: c,
|
|
12
|
+
paint: null,
|
|
13
|
+
...u ? { handle: {
|
|
14
|
+
distancePx: u.distancePx,
|
|
15
|
+
hitRadiusPx: u.sizePx
|
|
16
|
+
} } : {}
|
|
17
|
+
}),
|
|
18
|
+
n({ handleHitRadius: o }),
|
|
19
|
+
...l ? i(l, { hitRadius: s }) : []
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
function o(e, t) {
|
|
23
|
+
return () => {
|
|
24
|
+
let n = e()?.get("editAnchors");
|
|
25
|
+
return n ? {
|
|
26
|
+
editingId: n.editingId ?? null,
|
|
27
|
+
getPose: (e) => t ? t(e, n.getEditablePath(e)) : n.getEditablePath(e)
|
|
28
|
+
} : null;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function s(e) {
|
|
32
|
+
let { getChromeState: n, getView: r, getIsVisible: i } = e, o = e.affordances ?? a(e);
|
|
33
|
+
return function({ x: e, y: a }) {
|
|
34
|
+
let s = t(o, e, a, n(), r(), i?.());
|
|
35
|
+
return s ? c(s) : null;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function c(e) {
|
|
39
|
+
let t = e.binding.initialScratch ?? {};
|
|
40
|
+
return {
|
|
41
|
+
kind: e.region.hitKind ?? `${e.affordanceId}:${e.regionId}`,
|
|
42
|
+
owner: e.affordanceId,
|
|
43
|
+
strength: "shared",
|
|
44
|
+
...t.targetId === void 0 ? {} : { targetIds: [t.targetId] },
|
|
45
|
+
...t.anchor === void 0 ? {} : { anchor: t.anchor },
|
|
46
|
+
...t.fixedPoint === void 0 ? {} : { fixedPoint: t.fixedPoint },
|
|
47
|
+
...e.region.cursor === void 0 ? {} : { cursor: e.region.cursor },
|
|
48
|
+
...e.binding.initialScratch === void 0 ? {} : { payload: e.binding.initialScratch }
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function l(e, t, n) {
|
|
52
|
+
return function({ x: r, y: i }) {
|
|
53
|
+
let a = t(r, i);
|
|
54
|
+
return a ? {
|
|
55
|
+
body: e().includes(a) ? "selected-body" : "unselected-body",
|
|
56
|
+
kind: n?.(a)
|
|
57
|
+
} : { body: "empty" };
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { o as anchorStateFrom, s as buildAffordanceAt, l as buildClassifyTarget, a as chromeAffordances };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=affordanceAt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affordanceAt.js","names":["chromeAffordances","sizes","targetSizesPx","opts","createRotationAffordance","rotateBandPx","rotationBadge","createCornerResizeAffordance","getAnchorState","createPathAnchorAffordances","anchorHitRadius","anchorStateFrom","dep","getRegistry","toCamera","id","buildAffordanceAt","affordances","wx","wy","hit","hitAffordanceRegions","getChromeState","getView","getIsVisible","toAffordanceHit","scratch","buildClassifyTarget","hitId","pickBest","getSelection","kindOfNode"],"sources":["../../src/canvas/affordanceAt.ts"],"sourcesContent":["/**\n * affordanceAt — the dispatcher-side affordance classifier.\n *\n * Answers \"what piece of selection chrome is under this world point?\" and\n * returns an `AffordanceHit`, which `GestureDispatcherMounter` packs onto\n * `InputEvent.pointerdown.affordance` so `resizeAction` / `rotateAction` /\n * `editAnchorsAction` can guard on affordance kind, and which the hover-cursor\n * pump reads `cursor` off of.\n *\n * It used to answer that question with its own geometry: its own corner\n * table, its own rotate-ring ellipse, its own anchor walk — all duplicating\n * the `Affordance` region declarations in `src/affordances/`, which had a\n * hit-tester of their own that nothing reached for kit chrome. Two\n * implementations of one question, and the declarative one was the dead\n * branch, which is why `AffordanceRegion.cursor` could be declared and set\n * and never consumed.\n *\n * Now this assembles the kit's affordances and runs the one shared walk\n * (`hitAffordanceRegions`). What remains here is the assembly and the\n * region-hit → `AffordanceHit` mapping.\n */\n\nimport type { BodyClassification } from '@weasel-js/gestures';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport type { View } from 'core/viewport/view';\nimport type { AffordanceHit } from '@weasel-js/routing';\nimport type { Affordance, CommonAffordanceScratch } from 'affordances/types';\nimport { hitAffordanceRegions, type AffordanceRegionHit } from 'affordances/hitAffordanceRegions';\nimport { createCornerResizeAffordance } from 'affordances/cornerResize';\nimport { createRotationAffordance } from 'affordances/rotationHandle';\nimport { createPathAnchorAffordances, type AnchorState } from 'affordances/pathAnchors';\nimport { targetSizesPx } from 'core/device/targets';\n\nexport type { AnchorState };\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/** What decides the kit's chrome affordances — their sizes and which ones\n * exist. Shared by the hit-test and the slops overlay, which draws them. */\nexport interface ChromeAffordanceOptions {\n /** Pointer-size multiplier from the live `DeviceProfile`. Every default\n * below is resolved through {@link targetSizesPx} at this scale, so the\n * grab zone tracks the painted chrome on a coarse pointer. Default 1. */\n targetScale?: number;\n /** Corner-handle hit radius in screen px. Overrides the device-scaled default. */\n handleHitRadius?: number;\n /** Anchor / control hit radius in screen px. Overrides the device-scaled default. */\n anchorHitRadius?: number;\n /** Minimum rotate-band thickness outside the selection AABB, in screen px.\n * Overrides the device-scaled default. */\n rotateBandPx?: number;\n /** The rotate badge the selection overlay paints (`rotationBadgeOf`), so\n * it can be grabbed where it is drawn. Omitted or null, only the rotate\n * ring is hit-tested. */\n rotationBadge?: { distancePx: number; sizePx: number } | null;\n /** Anchor-editing state. When omitted, anchors aren't hit-tested. */\n getAnchorState?: () => AnchorState | null;\n}\n\nexport interface BuildAffordanceAtOptions extends ChromeAffordanceOptions {\n /** Live ChromeState at call time — current selection plus effective bounds,\n * including in-flight move/resize ghost poses. */\n getChromeState: () => ChromeState;\n /** Live view. Needed because region hit radii and the rotate band are\n * declared in screen pixels and resolved against the current scale. */\n getView: () => View;\n /** The affordances to walk, when the caller built them itself to share\n * them (`chromeAffordances`). Otherwise built from these options. */\n affordances?: readonly Affordance[];\n /** Chrome-caps resolver. Keeps the hit-test and the renderer agreeing on\n * which chrome is live (resize handles gated by\n * `'selection.resize-handles'`, rotation by `'selection.rotation-handle'`,\n * anchors by `'path-edit.anchors'`). Omitting defaults to always-visible. */\n getIsVisible?: () => (id: string) => boolean;\n}\n\n/**\n * The kit's selection chrome as affordances, bottom → top: rotate ring (and\n * badge), corner handles, then anchors and their controls — a corner handle\n * beats the rotate band it sits inside, and a control handle beats everything.\n */\nexport function chromeAffordances(opts: ChromeAffordanceOptions = {}): Affordance[] {\n const sizes = targetSizesPx(opts.targetScale);\n const {\n handleHitRadius = sizes.handle,\n anchorHitRadius = sizes.anchor,\n rotateBandPx = sizes.rotationDistance,\n getAnchorState,\n rotationBadge,\n } = opts;\n return [\n createRotationAffordance({\n bandPx: rotateBandPx,\n paint: null,\n ...(rotationBadge\n ? { handle: { distancePx: rotationBadge.distancePx, hitRadiusPx: rotationBadge.sizePx } }\n : {}),\n }),\n createCornerResizeAffordance({ handleHitRadius }),\n ...(getAnchorState\n ? createPathAnchorAffordances(getAnchorState, { hitRadius: anchorHitRadius })\n : []),\n ];\n}\n\n/**\n * Read anchor-editing state off a dep registry, for\n * {@link BuildAffordanceAtOpts.getAnchorState}. Returns `null` while no\n * `editAnchors` dep is registered — nothing is in anchor-edit mode, so\n * anchors are not hit-tested.\n */\nexport function anchorStateFrom(\n getRegistry: () => { get(name: 'editAnchors'): EditAnchorsDep | undefined } | null,\n /** The editable path in the world the hit-test is asked in. A node on a\n * parallax plane stores its path in the plane's world; the surface carries\n * it into the asking camera's. Default: unchanged. */\n toCamera?: (id: string, path: unknown) => unknown,\n): () => AnchorState | null {\n return () => {\n const dep = getRegistry()?.get('editAnchors');\n if (!dep) return null;\n return {\n editingId: dep.editingId ?? null,\n // The hit-test reads world-coord anchor positions, so route through\n // `getEditablePath`: both pose-as-polygon and `data.path` consumers\n // resolve correctly.\n getPose: (id) => (toCamera ? toCamera(id, dep.getEditablePath(id)) : dep.getEditablePath(id)),\n };\n };\n}\n\n/**\n * Build the `affordanceAt` thunk for `GestureDispatcherMounter`.\n *\n * Returns `(worldPoint) => AffordanceHit | null`. The point is **world-space**;\n * callers convert from client coords first.\n *\n * Priority runs anchors → controls → resize handles → rotate ring, top to\n * bottom, matching how the chrome paints: a corner handle beats the rotate\n * band it sits inside, and a control handle beats everything.\n */\nexport function buildAffordanceAt(\n opts: BuildAffordanceAtOptions,\n): (worldPoint: { x: number; y: number }) => AffordanceHit | null {\n const { getChromeState, getView, getIsVisible } = opts;\n const affordances = opts.affordances ?? chromeAffordances(opts);\n\n return function affordanceAt({ x: wx, y: wy }) {\n const hit = hitAffordanceRegions(\n affordances,\n wx,\n wy,\n getChromeState(),\n getView(),\n getIsVisible?.(),\n );\n return hit ? toAffordanceHit(hit) : null;\n };\n}\n\n/**\n * Region hit → `AffordanceHit`.\n *\n * `hitKind` is the routing discriminator; the handful of scratch fields named\n * by {@link CommonAffordanceScratch} are lifted onto the hit because the\n * actions that consume them read them there. Everything else in scratch rides\n * along untouched as `payload`.\n */\nfunction toAffordanceHit(hit: AffordanceRegionHit): AffordanceHit {\n const scratch = (hit.binding.initialScratch ?? {}) as CommonAffordanceScratch;\n return {\n kind: hit.region.hitKind ?? `${hit.affordanceId}:${hit.regionId}`,\n owner: hit.affordanceId,\n strength: 'shared',\n ...(scratch.targetId !== undefined ? { targetIds: [scratch.targetId] } : {}),\n ...(scratch.anchor !== undefined ? { anchor: scratch.anchor } : {}),\n ...(scratch.fixedPoint !== undefined ? { fixedPoint: scratch.fixedPoint } : {}),\n ...(hit.region.cursor !== undefined ? { cursor: hit.region.cursor } : {}),\n ...(hit.binding.initialScratch !== undefined ? { payload: hit.binding.initialScratch } : {}),\n } as AffordanceHit;\n}\n\n// ---------------------------------------------------------------------------\n// classifyTarget helper\n// ---------------------------------------------------------------------------\n\n/**\n * Classify a world-space point against the current selection:\n * - `'empty'`: no scene body hit.\n * - `'selected-body'`: hit a node that is currently selected.\n * - `'unselected-body'`: hit a node that is NOT selected.\n *\n * The caller supplies the hit-test function (already wired from\n * `useSceneSelectTool.pickEvery`).\n *\n * @param kindOfNode - Optional resolver from a hit node id to its semantic\n * kind. `<SceneCanvas>` defaults it to the `data.kind` convention the kit\n * already reads in `deps/textEdit` and the shape-tool inserts; consumers\n * whose nodes name their kind elsewhere override it. Omitting it leaves\n * `kind` undefined, which makes every `kind:` TargetSpec form no-match.\n */\nexport function buildClassifyTarget(\n getSelection: () => readonly string[],\n pickBest: (wx: number, wy: number) => string | null,\n kindOfNode?: (id: string) => string | undefined,\n): (worldPoint: { x: number; y: number }) => BodyClassification {\n return function classifyTarget({ x: wx, y: wy }) {\n const hitId = pickBest(wx, wy);\n if (!hitId) return { body: 'empty' };\n const sel = getSelection();\n return {\n body: sel.includes(hitId) ? 'selected-body' : 'unselected-body',\n kind: kindOfNode?.(hitId),\n };\n };\n}\n"],"mappings":";;;;;;AAoFA,SAAgBA,EAAkB,IAAgC,CAAC,GAAiB;CAClF,IAAMC,IAAQC,EAAcC,EAAK,WAAW,GACtC,EACJ,qBAAkBF,EAAM,QACxB,qBAAkBA,EAAM,QACxB,kBAAeA,EAAM,kBACrB,mBACA,qBACEE;CACJ,OAAO;EACLC,EAAyB;GACvB,QAAQC;GACR,OAAO;GACP,GAAIC,IACA,EAAE,QAAQ;IAAE,YAAYA,EAAc;IAAY,aAAaA,EAAc;GAAO,EAAE,IACtF,CAAC;EACP,CAAC;EACDC,EAA6B,EAAE,mBAAgB,CAAC;EAChD,GAAIC,IACAC,EAA4BD,GAAgB,EAAE,WAAWE,EAAgB,CAAC,IAC1E,CAAC;CACP;AACF;AAQA,SAAgBC,EACd,GAIA,GAC0B;CAC1B,aAAa;EACX,IAAMC,IAAMC,EAAY,CAAC,EAAE,IAAI,aAAa;EAE5C,OADKD,IACE;GACL,WAAWA,EAAI,aAAa;GAI5B,UAAU,MAAQE,IAAWA,EAASC,GAAIH,EAAI,gBAAgBG,CAAE,CAAC,IAAIH,EAAI,gBAAg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C;AACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { deriveParallaxView as e, planeMap as t } from "../core/viewport/parallax.js";
|
|
2
|
+
import { definesFrame as n } from "../core/scene/effectivePose.js";
|
|
3
|
+
import { findShapeSilhouette as r } from "./NodeShape.js";
|
|
4
|
+
import { clipCarrier as i, planeTransform as a } from "./planeClips.js";
|
|
5
|
+
import { scenePlaneOf as o } from "./pickWalk.js";
|
|
6
|
+
//#region src/canvas/buildSceneTree.ts
|
|
7
|
+
function s(e, t, n, r) {
|
|
8
|
+
let i = {
|
|
9
|
+
kind: "group",
|
|
10
|
+
children: e
|
|
11
|
+
};
|
|
12
|
+
for (let e = t.length - 1; e >= 0; e--) i = {
|
|
13
|
+
kind: "group",
|
|
14
|
+
children: [i],
|
|
15
|
+
clip: r(t[e].path, t[e].layer, n)
|
|
16
|
+
};
|
|
17
|
+
return i;
|
|
18
|
+
}
|
|
19
|
+
function c(c, l, u, d, f, p) {
|
|
20
|
+
let m = c.getLayers(), h = /* @__PURE__ */ new Map();
|
|
21
|
+
for (let e of m) h.set(e.id, []);
|
|
22
|
+
let g = null;
|
|
23
|
+
for (let t of m) t.parallax && (g ??= /* @__PURE__ */ new Map()).set(t.id, e(u, t.parallax));
|
|
24
|
+
let _ = c.composePose?.bind(c), v = i(g ? o(m, u) : null);
|
|
25
|
+
function y(e, t, i) {
|
|
26
|
+
let a = c.getNode(e);
|
|
27
|
+
if (!a) return;
|
|
28
|
+
let o = c.getPose(e), m = _ && i !== null ? _(i, o) : o, b = d === void 0 || a.layer === d, x = g?.get(a.layer) ?? u, S = b && !p?.(a, m, x) ? l(a, m, x) : [], C = t, w = a;
|
|
29
|
+
if (w.kind === "container") {
|
|
30
|
+
let e;
|
|
31
|
+
e = typeof w.clipFromPose == "function" ? w.clipFromPose(m) : r(a, m, { derivedPath: f?.(a, m) }), e && (C = [...t, {
|
|
32
|
+
path: e,
|
|
33
|
+
layer: a.layer
|
|
34
|
+
}]);
|
|
35
|
+
}
|
|
36
|
+
if (b) {
|
|
37
|
+
let e = h.get(a.layer);
|
|
38
|
+
e && e.push(C.length > 0 ? s(S, C, a.layer, v) : {
|
|
39
|
+
kind: "group",
|
|
40
|
+
children: S
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
let T = n(a) ? m : i;
|
|
44
|
+
for (let t of c.getChildren(e)) y(t, C, T);
|
|
45
|
+
}
|
|
46
|
+
for (let e of c.getChildren(null)) y(e, [], null);
|
|
47
|
+
let b = [];
|
|
48
|
+
for (let e of m) {
|
|
49
|
+
if (!e.visible || d !== void 0 && e.id !== d) continue;
|
|
50
|
+
let n = h.get(e.id) ?? [], r = e.parallax ? a(t(u, e.parallax), null) : void 0;
|
|
51
|
+
b.push(r ? {
|
|
52
|
+
kind: "group",
|
|
53
|
+
transform: r,
|
|
54
|
+
children: n
|
|
55
|
+
} : {
|
|
56
|
+
kind: "group",
|
|
57
|
+
children: n
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return b;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { c as buildSceneTree };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=buildSceneTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSceneTree.js","names":["wrapInClips","node","cmds","i","clips","carry","toLayer","buildSceneTree","layers","adapter","buckets","l","planeViews","deriveParallaxView","view","compose","clipCarrier","scenePlaneOf","visit","id","local","pose","parentFrame","paints","forLayer","v","self","culled","drawOne","ownClips","ancestorClips","maybeContainer","clip","findShapeSilhouette","derivedPathOf","bucket","childFrame","definesFrame","cid","rootId","out","layer","children","transform","planeTransform","planeMap"],"sources":["../../src/canvas/buildSceneTree.ts"],"sourcesContent":["import type { DrawCommand, GroupDrawCommand } from '../renderer';\nimport type { View } from 'core/viewport/view';\nimport { findShapeSilhouette } from './NodeShape';\nimport type { Node } from 'core/scene/types';\nimport type { Path } from '@weasel-js/geom';\nimport { definesFrame } from 'core/scene/effectivePose';\nimport { deriveParallaxView, planeMap, type ParallaxOpts } from 'core/viewport/parallax';\nimport { scenePlaneOf } from './pickWalk';\nimport { clipCarrier, planeTransform } from './planeClips';\n\n/**\n * The scene-tree reading surface `buildSceneTree` walks. A `SceneCanvasAdapter`\n * satisfies this; flat (non-hierarchical) adapters don't. Canvas exposes these\n * as *optional* methods on `CanvasProps.adapter` (see `OptionalSceneHierarchy`)\n * and feature-detects them at draw time.\n */\nexport interface HierarchicalAdapter<TNode, TPose> {\n getLayers(): readonly { id: string; visible: boolean; parallax?: ParallaxOpts }[];\n getNode(id: string): TNode | undefined;\n getChildren(parentId: string | null): readonly string[];\n getPose(id: string): TPose;\n /** Folds a child's local pose into its parent's frame. Absent means the\n * scene stores absolute poses and a parent contributes no transform —\n * see `PoseComposition`. */\n composePose?(parent: TPose, child: TPose): TPose;\n}\n\n/** A clip on the chain, with the layer whose world it is drawn in. */\ninterface ChainClip { path: Path; layer: string }\n\n/** Wrap `cmds` in one nested group per clip so the renderer intersects them.\n * Outermost group carries the ancestor-most clip; innermost holds `cmds`. */\nfunction wrapInClips(\n cmds: DrawCommand[],\n clips: readonly ChainClip[],\n toLayer: string,\n carry: ReturnType<typeof clipCarrier>,\n): DrawCommand {\n let node: GroupDrawCommand = { kind: 'group', children: cmds };\n for (let i = clips.length - 1; i >= 0; i--) {\n node = { kind: 'group', children: [node], clip: carry(clips[i].path, clips[i].layer, toLayer) };\n }\n return node;\n}\n\n/**\n * Walk the adapter's scene tree once and emit each node's own paint into the\n * bucket for **that node's own `layer`** — not its parent's. So a child whose\n * `layer` differs from its parent (e.g. a planting tagged into a top-most\n * `plantings` layer while remaining a scene child of its container) draws in\n * its own layer's pass, on top of every container body, while staying a tree\n * child for hit-testing / move / reparent.\n *\n * Output is one group per visible layer, in adapter (`getLayers`) order.\n *\n * **Positioning** is world-space: `drawOne` returns world-coord commands (the\n * caller wraps the whole thing in the view transform). Because a node may be\n * drawn outside its parent's group, the tree nesting cannot carry geometry as\n * renderer state; instead the walk folds each node's pose into its parent's\n * frame on the way down and hands the painter a **world** pose. Clips are\n * accumulated the same way and are world-space for the same reason — each in\n * its container's plane, carried into the plane of the node it clips.\n *\n * With no `composePose` on the adapter the fold is the identity, every node\n * paints at its stored pose, and this is the absolute-pose behavior the kit\n * shipped before frames existed.\n *\n * A layer carrying `parallax` is a plane: its painters and its cull see the\n * view derived for it, and its group carries the transform from its world to\n * the camera's, so the caller's single camera wrap still lands it right.\n */\nexport function buildSceneTree<\n TNode extends { id: string; layer: string },\n TPose,\n>(\n adapter: HierarchicalAdapter<TNode, TPose>,\n drawOne: (obj: TNode, pose: TPose, view: View) => DrawCommand[],\n view: View,\n /** When set, only nodes on this layer paint (others are still walked for\n * ancestor clips) and only this layer's group is returned. Used to render\n * scene layers as separate, individually-orderable canvas slots. */\n forLayer?: string,\n /** The path a container computes from its dependencies' poses. Only a\n * scene-backed caller can answer — deriving needs the dependencies' poses —\n * so the bare-adapter path omits it and a derived container contributes no\n * clip there, exactly as before. */\n derivedPathOf?: (node: TNode, pose: TPose) => Path | null,\n /** True for a node whose paint cannot be seen — see `paintMissesView`. Its\n * painter is not called; its clip and its children are walked as usual. */\n culled?: (node: TNode, pose: TPose, view: View) => boolean,\n): DrawCommand[] {\n const layers = adapter.getLayers();\n const buckets = new Map<string, DrawCommand[]>();\n for (const l of layers) buckets.set(l.id, []);\n let planeViews: Map<string, View> | null = null;\n for (const l of layers) {\n if (l.parallax) (planeViews ??= new Map()).set(l.id, deriveParallaxView(view, l.parallax));\n }\n\n const compose = adapter.composePose?.bind(adapter);\n const carry = clipCarrier(planeViews ? scenePlaneOf(layers, view) : null);\n\n function visit(\n id: string,\n ancestorClips: readonly ChainClip[],\n parentFrame: TPose | null,\n ): void {\n const node = adapter.getNode(id);\n if (!node) return;\n const local = adapter.getPose(id);\n // Fold once, on the way down: O(1) per node where walking the parent chain\n // per node would be O(depth).\n const pose = compose && parentFrame !== null ? compose(parentFrame, local) : local;\n // Skip the (potentially expensive) painter for nodes we won't emit; their\n // clip still extends the chain for descendants below.\n const paints = forLayer === undefined || node.layer === forLayer;\n const v = planeViews?.get(node.layer) ?? view;\n const self = paints && !culled?.(node, pose, v) ? drawOne(node, pose, v) : [];\n\n // Extend the clip chain with this node's own clip when it is a container.\n let ownClips = ancestorClips;\n const maybeContainer = node as { kind?: string; clipFromPose?: (pose: TPose) => unknown };\n if (maybeContainer.kind === 'container') {\n let clip: unknown;\n if (typeof maybeContainer.clipFromPose === 'function') {\n // Explicit per-node clip wins — no fallback to the painter silhouette.\n clip = maybeContainer.clipFromPose(pose);\n } else {\n // No explicit clip → fall back to the painter silhouette for the\n // container's shape kind. Built-ins give rect-fallback containers\n // their own AABB as a clip; consumer painters can provide arbitrary\n // closed shapes (ellipse, polygon, …) without per-node wiring.\n clip = findShapeSilhouette(\n node as unknown as Node<unknown, string, TPose>,\n pose,\n { derivedPath: derivedPathOf?.(node, pose) },\n );\n }\n if (clip) ownClips = [...ancestorClips, { path: clip as Path, layer: node.layer }];\n }\n\n // Emit this node's own paint into its own layer's bucket, clipped by the\n // accumulated chain (ancestors + own). Every node emits a wrapper group\n // even with empty paint, keeping the per-node tree shape stable.\n if (paints) {\n const bucket = buckets.get(node.layer);\n if (bucket) {\n bucket.push(ownClips.length > 0 ? wrapInClips(self, ownClips, node.layer, carry) : { kind: 'group', children: self });\n }\n }\n\n // An envelope's children share its own parent's frame.\n const childFrame = definesFrame(node as never) ? pose : parentFrame;\n for (const cid of adapter.getChildren(id)) visit(cid, ownClips, childFrame);\n }\n\n for (const rootId of adapter.getChildren(null)) visit(rootId, [], null);\n\n const out: DrawCommand[] = [];\n for (const layer of layers) {\n if (!layer.visible) continue;\n if (forLayer !== undefined && layer.id !== forLayer) continue;\n const children = buckets.get(layer.id) ?? [];\n const transform = layer.parallax ? planeTransform(planeMap(view, layer.parallax), null) : undefined;\n out.push(transform ? { kind: 'group', transform, children } : { kind: 'group', children });\n }\n return out;\n}\n"],"mappings":";;;;;;A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
|
+
//#region src/canvas/canvasRenderer.ts
|
|
4
|
+
var n = /* @__PURE__ */ new WeakMap(), r = (e) => e?.map((e) => e.id).join("|") ?? "";
|
|
5
|
+
function i(e, t) {
|
|
6
|
+
if (t) for (let n of t) try {
|
|
7
|
+
e.registerProgram(n);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
console.warn(`weasel: failed to register shader "${n.id}":`, e);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function a(e) {
|
|
13
|
+
let t = n.get(e.canvas);
|
|
14
|
+
t?.delete(e.renderer), t && t.size === 0 && n.delete(e.canvas), e.renderer.dispose();
|
|
15
|
+
}
|
|
16
|
+
function o() {
|
|
17
|
+
let o = null, s = (t, s, c = {}) => {
|
|
18
|
+
let { width: l, height: u } = s, d = s.dpr ?? (typeof window < "u" && window.devicePixelRatio || 1), f = c.tile ?? null, p = f !== null;
|
|
19
|
+
if (o && (o.canvas !== t || o.shared !== p) && (a(o), o = null), o) (o.width !== l || o.height !== u || o.dpr !== d) && (o.renderer.resize({
|
|
20
|
+
width: l,
|
|
21
|
+
height: u,
|
|
22
|
+
dpr: d
|
|
23
|
+
}), o.width = l, o.height = u, o.dpr = d), o.flattenTolerance !== c.flattenTolerance && (o.renderer.setFlattenTolerance(c.flattenTolerance), o.flattenTolerance = c.flattenTolerance);
|
|
24
|
+
else {
|
|
25
|
+
let r = t.getContext("webgl2", {
|
|
26
|
+
preserveDrawingBuffer: !0,
|
|
27
|
+
stencil: !0
|
|
28
|
+
});
|
|
29
|
+
if (!r || typeof r.enable != "function") return null;
|
|
30
|
+
let i;
|
|
31
|
+
try {
|
|
32
|
+
i = new e({
|
|
33
|
+
gl: r,
|
|
34
|
+
...p ? {} : { canvas: t },
|
|
35
|
+
width: l,
|
|
36
|
+
height: u,
|
|
37
|
+
dpr: d,
|
|
38
|
+
flattenTolerance: c.flattenTolerance
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
o = {
|
|
44
|
+
canvas: t,
|
|
45
|
+
renderer: i,
|
|
46
|
+
shared: p,
|
|
47
|
+
width: l,
|
|
48
|
+
height: u,
|
|
49
|
+
dpr: d,
|
|
50
|
+
tileX: null,
|
|
51
|
+
tileY: null,
|
|
52
|
+
flattenTolerance: c.flattenTolerance,
|
|
53
|
+
shaderKey: ""
|
|
54
|
+
};
|
|
55
|
+
let a = n.get(t);
|
|
56
|
+
a || (a = /* @__PURE__ */ new Set(), n.set(t, a)), a.add(i);
|
|
57
|
+
}
|
|
58
|
+
let { renderer: m } = o, h = r(c.shaders);
|
|
59
|
+
h !== o.shaderKey && (i(m, c.shaders), o.shaderKey = h);
|
|
60
|
+
let g = f?.x ?? null, _ = f?.y ?? null;
|
|
61
|
+
return (g !== o.tileX || _ !== o.tileY) && (m.setTarget(f ? { origin: {
|
|
62
|
+
x: f.x,
|
|
63
|
+
y: f.y
|
|
64
|
+
} } : null), o.tileX = g, o.tileY = _), m;
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
bind: s,
|
|
68
|
+
paint(e, n, r, i, a) {
|
|
69
|
+
let o = s(e, i, a);
|
|
70
|
+
return o ? (o.render(n, t(r), a?.render), !0) : !1;
|
|
71
|
+
},
|
|
72
|
+
release() {
|
|
73
|
+
o && a(o), o = null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var s = /* @__PURE__ */ new WeakMap();
|
|
78
|
+
function c(e, t, n, r) {
|
|
79
|
+
let i = s.get(e);
|
|
80
|
+
return i || (i = o(), s.set(e, i)), i.paint(e, t, n, r);
|
|
81
|
+
}
|
|
82
|
+
function l(e) {
|
|
83
|
+
let t = s.get(e);
|
|
84
|
+
t && (s.delete(e), t.release());
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { o as leaseCanvasRenderer, c as paintCanvas, l as releaseCanvasRenderer };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=canvasRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvasRenderer.js","names":["TENANTS","shaderKeyOf","shaders","h","registerShaders","handle","free","set","held","leaseCanvasRenderer","bind","size","dpr","tile","options","shared","canvas","width","height","gl","renderer","WeaselRenderer","shaderKey","tileX","tileY","commands","viewToMat3","view","CANVAS_LEASES","paintCanvas","lease","releaseCanvasRenderer"],"sources":["../../src/canvas/canvasRenderer.ts"],"sourcesContent":["/**\n * The one renderer lifetime in core. Every on-screen surface — `<Canvas>`,\n * `<SceneViewCanvas>`, `<MinimapCanvas>`, `<DrawCanvas>` — holds its\n * `WeaselRenderer` through a `leaseCanvasRenderer` lease (the detached ones via\n * `useCanvasRenderer`): created on first paint, resized when the surface's\n * size or density changes, rebuilt when the surface moves to another element,\n * and freed on release.\n *\n * A lease holds its own renderer, so several can share one element: each\n * tenant painting a `tile` of a shared buffer gets a renderer of its own on\n * the element's one context. Release frees only what that renderer created;\n * the context itself is never lost.\n */\nimport { WeaselRenderer, type RenderOptions } from '../renderer/WeaselRenderer';\nimport { viewToMat3 } from '../renderer/math/viewToMat3';\nimport type { ShaderProgramHandle } from '../renderer/shaders/registerProgram';\nimport type { DrawCommand } from '../renderer/DrawCommand';\nimport type { View } from '../core/viewport/view';\n\n/** The live renderers painting into each element, across every lease. */\nconst TENANTS: WeakMap<HTMLCanvasElement, Set<WeaselRenderer>> = new WeakMap();\n\n/** A renderer painting into the canvas, if any lease holds one. Test seam. */\nexport function cachedCanvasRenderer(canvas: HTMLCanvasElement): WeaselRenderer | undefined {\n const set = TENANTS.get(canvas);\n return set ? set.values().next().value : undefined;\n}\n\n/** The size and density to paint a canvas at. `dpr` defaults to\n * `window.devicePixelRatio`, read per paint. */\nexport interface CanvasPaintSize {\n width: number;\n height: number;\n dpr?: number;\n}\n\n/** How one paint reaches the canvas, beyond its size. */\nexport interface CanvasPaintOptions {\n /** Paint a `width × height` tile of a buffer other surfaces share, at this\n * origin in CSS pixels. The buffer is then the caller's to size: the\n * renderer never resizes the element, which would have every co-tenant\n * resize it to its own pane. Omit to own the whole element. */\n tile?: { x: number; y: number } | null;\n /** `WeaselRendererOptions.flattenTolerance`, applied from this paint on. */\n flattenTolerance?: number;\n /** Custom programs to compile on the renderer. Compiled when the renderer\n * is created, and again when the set of ids changes. */\n shaders?: readonly ShaderProgramHandle[];\n}\n\n/** A paint's options, plus what `paint` hands `WeaselRenderer.render`. */\nexport interface CanvasRenderOptions extends CanvasPaintOptions {\n render?: RenderOptions;\n}\n\n/** A canvas renderer held for a surface's lifetime. */\nexport interface CanvasRendererLease {\n /** Draw `commands` into `canvas` — screen-space, one unit per CSS pixel,\n * with `view` passed on as the frame's world→screen transform. `bind`,\n * then render. Returns `false` without painting where `bind` finds no\n * renderer. */\n paint(\n canvas: HTMLCanvasElement,\n commands: DrawCommand[],\n view: View,\n size: CanvasPaintSize,\n options?: CanvasRenderOptions,\n ): boolean;\n /** The renderer that paints `canvas` at `size`, ready to render: created on\n * first use, resized, and given this paint's tile, tolerance and shaders.\n * Frees the previous renderer first if the surface moved to another\n * element, or between owning it whole and painting a tile of it. `null`\n * where no WebGL2 context is available (jsdom, or a failed context\n * creation), so a caller can skip building a frame nobody will see. */\n bind(canvas: HTMLCanvasElement, size: CanvasPaintSize, options?: CanvasPaintOptions): WeaselRenderer | null;\n /** Free the held renderer and every GL object it owns. A later `paint`\n * creates a fresh one. */\n release(): void;\n}\n\ninterface Held {\n canvas: HTMLCanvasElement;\n renderer: WeaselRenderer;\n shared: boolean;\n width: number;\n height: number;\n dpr: number;\n tileX: number | null;\n tileY: number | null;\n flattenTolerance: number | undefined;\n shaderKey: string;\n}\n\nconst shaderKeyOf = (shaders: readonly ShaderProgramHandle[] | undefined): string =>\n shaders?.map((h) => h.id).join('|') ?? '';\n\nfunction registerShaders(renderer: WeaselRenderer, shaders: readonly ShaderProgramHandle[] | undefined): void {\n if (!shaders) return;\n for (const handle of shaders) {\n try {\n renderer.registerProgram(handle);\n } catch (e) {\n console.warn(`weasel: failed to register shader \"${handle.id}\":`, e);\n }\n }\n}\n\nfunction free(held: Held): void {\n const set = TENANTS.get(held.canvas);\n set?.delete(held.renderer);\n if (set && set.size === 0) TENANTS.delete(held.canvas);\n held.renderer.dispose();\n}\n\n/** Hold the renderer of the canvas a surface paints into, until released. */\nexport function leaseCanvasRenderer(): CanvasRendererLease {\n let held: Held | null = null;\n const bind = (canvas: HTMLCanvasElement, size: CanvasPaintSize, options: CanvasPaintOptions = {}): WeaselRenderer | null => {\n const { width, height } = size;\n const dpr = size.dpr ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);\n const tile = options.tile ?? null;\n const shared = tile !== null;\n\n if (held && (held.canvas !== canvas || held.shared !== shared)) {\n free(held);\n held = null;\n }\n if (!held) {\n const gl = canvas.getContext('webgl2', { preserveDrawingBuffer: true, stencil: true });\n if (!gl || typeof (gl as Partial<WebGL2RenderingContext>).enable !== 'function') return null;\n let renderer: WeaselRenderer;\n try {\n renderer = new WeaselRenderer({\n gl: gl as WebGL2RenderingContext,\n ...(shared ? {} : { canvas }),\n width, height, dpr,\n flattenTolerance: options.flattenTolerance,\n });\n } catch {\n return null;\n }\n held = { canvas, renderer, shared, width, height, dpr, tileX: null, tileY: null,\n flattenTolerance: options.flattenTolerance, shaderKey: '' };\n let set = TENANTS.get(canvas);\n if (!set) { set = new Set(); TENANTS.set(canvas, set); }\n set.add(renderer);\n } else {\n if (held.width !== width || held.height !== height || held.dpr !== dpr) {\n held.renderer.resize({ width, height, dpr });\n held.width = width;\n held.height = height;\n held.dpr = dpr;\n }\n if (held.flattenTolerance !== options.flattenTolerance) {\n held.renderer.setFlattenTolerance(options.flattenTolerance);\n held.flattenTolerance = options.flattenTolerance;\n }\n }\n\n const { renderer } = held;\n const shaderKey = shaderKeyOf(options.shaders);\n if (shaderKey !== held.shaderKey) {\n registerShaders(renderer, options.shaders);\n held.shaderKey = shaderKey;\n }\n const tileX = tile?.x ?? null;\n const tileY = tile?.y ?? null;\n if (tileX !== held.tileX || tileY !== held.tileY) {\n renderer.setTarget(tile ? { origin: { x: tile.x, y: tile.y } } : null);\n held.tileX = tileX;\n held.tileY = tileY;\n }\n return renderer;\n };\n return {\n bind,\n paint(canvas, commands, view, size, options) {\n const renderer = bind(canvas, size, options);\n if (!renderer) return false;\n renderer.render(commands, viewToMat3(view), options?.render);\n return true;\n },\n release() {\n if (held) free(held);\n held = null;\n },\n };\n}\n\n/** Leases held on a canvas's behalf by `paintCanvas`, one per element. */\nconst CANVAS_LEASES: WeakMap<HTMLCanvasElement, CanvasRendererLease> = new WeakMap();\n\n/**\n * Paint `canvas` through a lease held for the element itself, for callers\n * with no component lifetime of their own (`renderSceneToCanvas`). The\n * renderer lives until `releaseCanvasRenderer(canvas)`.\n */\nexport function paintCanvas(\n canvas: HTMLCanvasElement,\n commands: DrawCommand[],\n view: View,\n size: CanvasPaintSize,\n): boolean {\n let lease = CANVAS_LEASES.get(canvas);\n if (!lease) {\n lease = leaseCanvasRenderer();\n CANVAS_LEASES.set(canvas, lease);\n }\n return lease.paint(canvas, commands, view, size);\n}\n\n/** Free the renderer `paintCanvas` holds for the canvas, and every GL object\n * it owns. The next paint creates a fresh one. Renderers a surface component\n * holds are that component's to free, on unmount. */\nexport function releaseCanvasRenderer(canvas: HTMLCanvasElement): void {\n const lease = CANVAS_LEASES.get(canvas);\n if (!lease) return;\n CANVAS_LEASES.delete(canvas);\n lease.release();\n}\n"],"mappings":";;;AAoBA,IAAMA,oBAA2D,IAAI,QAAQ,GAyEvEC,KAAe,MACnBC,GAAS,KAAK,MAAMC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,KAAK;AAEzC,SAASC,EAAgB,GAA0B,GAA2D;CAC5G,IAAKF,GACL,KAAK,IAAMG,KAAUH,GACnB,IAAI;EACF,EAAS,gBAAgBG,CAAM;CACjC,SAAS,GAAG;EACV,QAAQ,KAAK,sCAAsCA,EAAO,GAAG,KAAK,CAAC;CACrE;AAEJ;AAEA,SAASC,E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|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/canvas/colorOverrides.ts
|
|
2
|
+
var e = () => typeof performance < "u" ? performance.now() : Date.now();
|
|
3
|
+
function t(t, n, r = e) {
|
|
4
|
+
return (e, i, a, o) => {
|
|
5
|
+
if (!t.has(e.id)) return n(e, i, a, o);
|
|
6
|
+
let s = r();
|
|
7
|
+
return n(e, i, a, {
|
|
8
|
+
...o,
|
|
9
|
+
vertexColors: (n, r) => t.resolve(e.id, n, r, s)
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as withColorOverrides };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=colorOverrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorOverrides.js","names":["clock","withColorOverrides","registry","node","drawOne","pose","view","ctx","tMs","now","channel","base"],"sources":["../../src/canvas/colorOverrides.ts"],"sourcesContent":["/**\n * The render walk's half of animated vertex colors: handing a node's live\n * color overrides to its painter. The overrides live in an animator's\n * `ColorOverrideRegistry`, which `tweenVertexColors` and its siblings write.\n */\nimport type { ColorOverrideRegistry } from '../animation/colorRegistry';\nimport type { SceneViewDrawOne } from './NodeShape';\n\nconst clock = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\n\n/**\n * Wrap a `drawOne` so a node with a live color override reaches its painter\n * with {@link NodePaintCtx.vertexColors}. Both scene walks wrap here, and\n * `createPathLayer` resolves through the same `ColorOverrideRegistry.resolve`.\n *\n * A node nothing overrides passes the caller's `ctx` through untouched, so\n * the common case allocates nothing.\n */\nexport function withColorOverrides<TData, TLayer extends string, TPose>(\n registry: ColorOverrideRegistry,\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>,\n now: () => number = clock,\n): SceneViewDrawOne<TData, TLayer, TPose> {\n return (node, pose, view, ctx) => {\n if (!registry.has(node.id)) return drawOne(node, pose, view, ctx);\n const tMs = now();\n return drawOne(node, pose, view, {\n ...ctx,\n vertexColors: (channel, base) => registry.resolve(node.id, channel, base, tMs),\n });\n };\n}\n"],"mappings":";AAQA,IAAMA,UAAuB,OAAO,cAAgB,MAAc,YAAY,IAAI,IAAI,KAAK,IAAI;AAU/F,SAAgBC,EACd,GACA,GACA,IAAoBD,GACoB;CACxC,QAAQ,GAAM,GAAM,GAAM,MAAQ;EAChC,IAAI,CAACE,EAAS,IAAIC,EAAK,EAAE,GAAG,OAAOC,EAAQD,GAAME,GAAMC,GAAMC,CAAG;EAChE,IAAMC,IAAMC,EAAI;EAChB,OAAOL,EAAQD,GAAME,GAAMC,GAAM;GAC/B,GAAGC;GACH,eAAe,GAAS,MAASL,EAAS,QAAQC,EAAK,IAAIO,GAASC,GAAMH,CAAG;EAC/E,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { textCommandFromRuns as e } from "../features/text/textCommand.js";
|
|
2
|
+
import { findNodeShape as t, findShapeBounds as n } from "./NodeShape.js";
|
|
3
|
+
//#region src/canvas/defaultDrawOne.ts
|
|
4
|
+
function r(e) {
|
|
5
|
+
let t = typeof window < "u" && window.devicePixelRatio || 1;
|
|
6
|
+
return Math.max(Math.abs(e.scale.x), Math.abs(e.scale.y)) * t;
|
|
7
|
+
}
|
|
8
|
+
var i, a = {};
|
|
9
|
+
function o(e) {
|
|
10
|
+
let t = r(e);
|
|
11
|
+
return (e !== i || a.pixelScale !== t) && (i = e, a = { pixelScale: t }), a;
|
|
12
|
+
}
|
|
13
|
+
function s(n, i, a, s) {
|
|
14
|
+
let c = t(n), l = !a || s?.pixelScale !== void 0 ? s : s ? {
|
|
15
|
+
...s,
|
|
16
|
+
pixelScale: r(a)
|
|
17
|
+
} : o(a), u = c ? c.paint(n, i, l) : [], d = n.data;
|
|
18
|
+
if (d?.label && d.text == null) {
|
|
19
|
+
let t = i;
|
|
20
|
+
return [...u, e(t.x + 6, t.y + 14, [{
|
|
21
|
+
text: d.label,
|
|
22
|
+
fill: {
|
|
23
|
+
fill: "solid",
|
|
24
|
+
color: "rgba(0,0,0,0.7)"
|
|
25
|
+
}
|
|
26
|
+
}], {
|
|
27
|
+
fontFamily: "sans-serif",
|
|
28
|
+
fontSize: 11
|
|
29
|
+
})];
|
|
30
|
+
}
|
|
31
|
+
return u;
|
|
32
|
+
}
|
|
33
|
+
function c(e, t, r) {
|
|
34
|
+
let i = e.data;
|
|
35
|
+
return i?.label && i.text == null ? null : n(e, t, { scale: Math.sqrt(Math.abs(r.scale.x * r.scale.y)) });
|
|
36
|
+
}
|
|
37
|
+
function l(e) {
|
|
38
|
+
return e === s ? c : void 0;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { s as defaultDrawOne, c as defaultPaintBounds, l as paintBoundsFor };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=defaultDrawOne.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultDrawOne.js","names":["pixelScaleOf","dpr","view","lastView","lastViewCtx","viewOnlyCtx","pixelScale","defaultDrawOne","painter","findNodeShape","node","paintCtx","ctx","primary","pose","data","p","textCommandFromRuns","defaultPaintBounds","findShapeBounds","paintBoundsFor","drawOne"],"sources":["../../src/canvas/defaultDrawOne.ts"],"sourcesContent":["/**\n * `defaultDrawOne` — the kit's default per-node draw function.\n *\n * Extracted from `SceneCanvas.tsx` so non-React callers (headless\n * rasterization via `renderSceneToPixels`) can use it without importing\n * the React component tree.\n *\n * Default scene-slot `drawOne` — dispatches through the shape-painter\n * registry (`./NodeShape`). The kit registers built-in painters for\n * text (`kit:text`), paths (`kit:path`), and a rect-from-pose fallback\n * (`kit:rect-fallback`) at module load, so every shape it ships out of\n * the box (rect, ellipse, polygon, star, line, pen, pencil, text) paints\n * without consumer intervention.\n *\n * To teach the kit about a new kind of shape, register a painter — do\n * not override `drawOne`. See `registerNodeShape` for the API and\n * priority semantics. Override `drawOne` only for cross-cutting\n * decoration (post-process every node, mix in overlays from outside\n * the per-node data, etc.).\n *\n * This function also emits an optional `data.label` overlay (sans-serif\n * 11px, top-left) on every non-text painter's output — a convenience\n * for naming zones in demos. Nodes whose painter is `kit:text` skip the\n * overlay since their content already shows.\n */\nimport type { Node } from 'core/scene/types';\nimport type { View } from 'core/viewport/view';\nimport type { DrawCommand } from '../renderer';\nimport { textCommandFromRuns } from 'features/text/textCommand';\nimport { findNodeShape, findShapeBounds, type NodePaintCtx } from './NodeShape';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\nfunction pixelScaleOf(view: View): number {\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;\n return Math.max(Math.abs(view.scale.x), Math.abs(view.scale.y)) * dpr;\n}\n\n// Shared across a frame's nodes, which all arrive with the same view.\nlet lastView: View | undefined;\nlet lastViewCtx: NodePaintCtx = {};\nfunction viewOnlyCtx(view: View): NodePaintCtx {\n const pixelScale = pixelScaleOf(view);\n if (view !== lastView || lastViewCtx.pixelScale !== pixelScale) {\n lastView = view;\n lastViewCtx = { pixelScale };\n }\n return lastViewCtx;\n}\n\n/** Paint one node the way the kit does by default: dispatch to the first\n * registered node-shape painter that matches, then draw its `data.label` on\n * top when it has one. Consumers replace or wrap this via `drawOne`. */\nexport function defaultDrawOne<TData, TLayer extends string, TPose>(\n node: Node<TData, TLayer, TPose>,\n pose: TPose,\n view?: View,\n ctx?: NodePaintCtx,\n): DrawCommand[] {\n const painter = findNodeShape(node);\n const paintCtx = !view || ctx?.pixelScale !== undefined\n ? ctx\n : ctx ? { ...ctx, pixelScale: pixelScaleOf(view) } : viewOnlyCtx(view);\n const primary = painter ? painter.paint(node, pose, paintCtx) : [];\n\n // Label overlay — skipped for text nodes (their content is the label).\n const data = node.data as { label?: string; text?: string } | null;\n if (data?.label && data.text == null) {\n const p = pose as unknown as { x: number; y: number };\n // Copy rather than `push`. A painter's return value is not ours to grow:\n // one that memoizes its command list — which is the point of caching\n // `paint` — would gain another label command on every frame, forever.\n return [...primary, textCommandFromRuns(\n p.x + 6,\n p.y + 14,\n [{ text: data.label, fill: { fill: 'solid', color: 'rgba(0,0,0,0.7)' } }],\n { fontFamily: 'sans-serif', fontSize: 11 },\n )];\n }\n\n // Rotation and per-node alpha are applied OUTSIDE this function, by\n // `wrapNodeOutput` in the scene walks (`buildSceneLayer`,\n // `buildSceneViewCommands`) and the preview-ghost layer, so that\n // consumer-supplied painters get them too. Doing it here would double-wrap.\n return primary;\n}\n\n/**\n * The box {@link defaultDrawOne}'s output for `node` fits in — the matched\n * painter's `bounds` — or `null` when it has none, or when a `data.label`\n * overlay adds text nothing bounds cheaply. The scene slot's `cull` reads it\n * to skip painting nodes the view cannot see.\n */\nexport function defaultPaintBounds<TData, TLayer extends string, TPose>(\n node: Node<TData, TLayer, TPose>,\n pose: TPose,\n view: View,\n): Bounds | null {\n const data = node.data as { label?: string; text?: string } | null;\n if (data?.label && data.text == null) return null;\n return findShapeBounds(node, pose, { scale: Math.sqrt(Math.abs(view.scale.x * view.scale.y)) });\n}\n\n/**\n * `defaultPaintBounds` when `drawOne` is `defaultDrawOne`, and nothing\n * otherwise: a painter's box says nothing about what a replacement\n * `drawOne` paints.\n */\nexport function paintBoundsFor<TData, TLayer extends string, TPose>(\n drawOne: unknown,\n): typeof defaultPaintBounds<TData, TLayer, TPose> | undefined {\n return drawOne === defaultDrawOne ? defaultPaintBounds : undefined;\n}\n"],"mappings":";;;AAgCA,SAASA,EAAa,GAAoB;CACxC,IAAMC,IAAO,OAAO,SAAW,OAAe,OAAO,oBAAqB;CAC1E,OAAO,KAAK,IAAI,KAAK,IAAIC,EAAK,MAAM,CAAC,GAAG,KAAK,IAAIA,EAAK,MAAM,CAAC,CAAC,IAAID;AACpE;AAGA,IAAIE,GACAC,IAA4B,CAAC;AACjC,SAASC,EAAY,GAA0B;CAC7C,IAAMC,IAAaN,EAAaE,CAAI;CAKpC,QAJIA,MAASC,KAAYC,EAAY,eAAeE,OAClD,IAAWJ,GACX,IAAc,EAAE,cAAW,IAEtBE;AACT;AAKA,SAAgBG,EACd,GACA,GACA,GACA,GACe;CACf,IAAMC,IAAUC,EAAcC,CAAI,GAC5BC,IAAW,CAACT,KAAQU,GAAK,eAAe,KAAA,IAC1CA,IACAA,IAAM;EAAE,GAAGA;EAAK,YAAYZ,EAAaE,CAAI;CAAE,IAAIG,EAAYH,CAAI,GACjEW,IAAUL,IAAUA,EAAQ,MAAME,GAAMI,GAAMH,CAAQ,IAAI,CAAC,GAG3DI,IAAOL,EAAK;CAClB,IAAIK,GAAM,SAASA,EAAK,QAAQ,MAAM;EACpC,IAAMC,IAAIF;EAIV,OAAO,CAAC,GAAGD,GAASI,EAClBD,EAAE,IAAI,GACNA,EAAE,IAAI,IACN,CAAC;GAAE,MAAMD,EAAK;GAAO,MAAM;IAAE,MAAM;IAAS,OAAO;GAAkB;EAAE,CAAC,GACxE;GAAE,YAAY;GAAc,UAAU;EAAG,CAC3C,CAAC;CACH;CAMA,OAAOF;AACT;AAQA,SAAgBK,EACd,GACA,GACA,GACe;CACf,IAAMH,IAAOL,EAAK;CAElB,OADIK,GAAM,SAASA,EAAK,QAAQ,OAAa,OACtCI,EAAgBT,GAAMI,GAAM,EAAE,OAAO,KAAK,KAAK,KAAK,IAAIZ,EAAK,MAAM,IAAIA,EAAK,MAAM,CAAC,CAAC,EAAE,CAAC;AAChG;AAOA,SAAgBkB,EACd,GAC6D;CAC7D,OAAOC,MAAYd,IAAiBW,IAAqB,KAAA;AAC3D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { hitTestArea as e, regionPickOptions as t } from "./hitTestArea.js";
|
|
2
|
+
import { useLatest as n } from "@weasel-js/react";
|
|
3
|
+
import { useDepSource as r } from "@weasel-js/routing/react";
|
|
4
|
+
//#region src/canvas/deps/areaSelect.ts
|
|
5
|
+
function i(i, a, o, s, c) {
|
|
6
|
+
let l = n(i), u = n(a), d = n(o), f = n(c);
|
|
7
|
+
r("areaSelect", () => {
|
|
8
|
+
let n = l.current, r = u.current, i = d.current, a = f.current;
|
|
9
|
+
return {
|
|
10
|
+
hitTestArea: (r, o) => e(n, r, t(o, a, s), i),
|
|
11
|
+
getSelection: () => r.current,
|
|
12
|
+
setSelection: (e) => r.set(e)
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { i as useAreaSelectDepSource };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=areaSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areaSelect.js","names":["hitTestAreaShared","useAreaSelectDepSource","sceneRef","useLatest","scene","selectionRef","selection","descriptorRef","descriptor","alphaOfRef","alphaOf","sc","s","d","hitTestArea","bounds","regionPickOptions","view","poseComposition","ids"],"sources":["../../../src/canvas/deps/areaSelect.ts"],"sourcesContent":["/**\n * `useAreaSelectDepSource` — wires the `areaSelect` dep consumed by\n * `areaSelectAction`. The dep exposes:\n * - `hitTestArea(bounds)` — silhouette-aware scan over `scene.renderOrderNodes()`\n * (rect poses by AABB; polygon poses by the kernel polygon-overlap test).\n * - `getSelection` / `setSelection` — passthrough to the kit selection api.\n *\n * Built once per render and stabilised by `useDepSource` (which reads via a\n * ref internally), so callers can pass fresh selection/scene refs without\n * triggering re-registration.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { AreaSelectDep } from 'interactions/actions/depSchema';\nimport type { Scene, NodeId } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { hitTestArea as hitTestAreaShared, regionPickOptions } from './hitTestArea';\nimport type { PoseComposition } from 'features/groups/composePose';\n\nexport function useAreaSelectDepSource(\n scene: Scene<unknown, string, unknown>,\n selection: SelectionApi,\n descriptor?: PoseDescriptor<unknown>,\n poseComposition?: PoseComposition<unknown>,\n /** The painted alpha the surface's layers apply, which every view shares. */\n alphaOf?: (id: string) => number,\n): void {\n const sceneRef = useLatest(scene);\n const selectionRef = useLatest(selection);\n const descriptorRef = useLatest(descriptor);\n const alphaOfRef = useLatest(alphaOf);\n\n useDepSource('areaSelect', (): AreaSelectDep => {\n const sc = sceneRef.current;\n const s = selectionRef.current;\n const d = descriptorRef.current;\n const a = alphaOfRef.current;\n return {\n hitTestArea: (bounds, view) =>\n hitTestAreaShared(sc, bounds, regionPickOptions(view, a, poseComposition), d),\n getSelection: () => s.current as NodeId[],\n setSelection: (ids) => s.set(ids),\n };\n });\n}\n"],"mappings":";;;;AAoBA,SAAgBC,EACd,GACA,GACA,GACA,GAEA,GACM;CACN,IAAMC,IAAWC,EAAUC,CAAK,GAC1BC,IAAeF,EAAUG,CAAS,GAClCC,IAAgBJ,EAAUK,CAAU,GACpCC,IAAaN,EAAUO,CAAO;CAEpC,EAAa,oBAAmC;EAC9C,IAAMC,IAAKT,EAAS,SACdU,IAAIP,EAAa,SACjBQ,IAAIN,EAAc,SAClB,IAAIE,EAAW;EACrB,OAAO;GACL,cAAc,GAAQ,MACpBT,EAAkBW,GAAII,GAAQC,EAAkBC,GAAM,GAAGC,CAAe,GAAGL,CAAC;GAC9E,oBAAoBD,EAAE;GACtB,eAAe,MAAQA,EAAE,IAAIO,CAAG;EAClC;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","names":["useDebugDepSource","canvasApiRef"],"sources":["../../../src/canvas/deps/debug.ts"],"sourcesContent":["/**\n * `useDebugDepSource` — wires the `debug` dep: the sink of the canvas this\n * registrar belongs to, so actions report to the same debug overlay tools do\n * through `ToolCtx.debug`. Resolved at invocation, because the canvas creates\n * its sink after this registers and swaps it whenever `debug` changes.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport type { CanvasExtensionApi } from '../canvasExtension';\n\nexport function useDebugDepSource(canvasApiRef: React.RefObject<CanvasExtensionApi | null>): void {\n useDepSource('debug', () => canvasApiRef.current?.getDebug() ?? undefined);\n}\n"],"mappings":";;AASA,SAAgBA,EAAkB,GAAgE;CAChG,EAAa,eAAeC,EAAa,SAAS,SAAS,KAAK,KAAA,CAAS;AAC3E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useLatest as e } from "@weasel-js/react";
|
|
2
|
+
import { useDepSource as t } from "@weasel-js/routing/react";
|
|
3
|
+
//#region src/canvas/deps/dispatcher.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let r = e(n);
|
|
6
|
+
t("dispatcher", () => ({ cancelAll: (e) => r.current.cancelAll(e) }));
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as useDispatcherDepSource };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.js","names":["useDispatcherDepSource","ref","useLatest","dispatcher","reason"],"sources":["../../../src/canvas/deps/dispatcher.ts"],"sourcesContent":["/**\n * `useDispatcherDepSource` — wires the `dispatcher` dep so actions can\n * abort in-flight handles (`cancelGestureAction` is the kit's only\n * built-in consumer today; consumer-app actions wanting drag-cancel\n * semantics use the same surface).\n *\n * Exposes only the control methods actions might legitimately need —\n * `cancelAll(reason)` — not the full dispatcher API. Keeps the dep's\n * blast radius narrow.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher } from '@weasel-js/routing';\n\nexport function useDispatcherDepSource(dispatcher: Dispatcher): void {\n const ref = useLatest(dispatcher);\n\n useDepSource('dispatcher', () => ({\n cancelAll: (reason) => ref.current.cancelAll(reason),\n }));\n}\n"],"mappings":";;;AAcA,SAAgBA,EAAuB,GAA8B;CACnE,IAAMC,IAAMC,EAAUC,CAAU;CAEhC,EAAa,qBAAqB,EAChC,YAAY,MAAWF,EAAI,QAAQ,UAAUG,CAAM,EACrD,EAAE;AACJ"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createTransformOp as e } from "../../core/ops/transform.js";
|
|
2
|
+
import { createSetDataOp as t } from "../../core/ops/setData.js";
|
|
3
|
+
import { isRectPose as n } from "../../interactions/actions/resize/autoPoseDescriptor.js";
|
|
4
|
+
import { pathInWorld as r, worldEditToStorage as i } from "../../features/paths/pathInWorld.js";
|
|
5
|
+
import { useCallback as a, useState as o } from "react";
|
|
6
|
+
import { useLatest as s } from "@weasel-js/react";
|
|
7
|
+
import { recordModeSwitch as c } from "@weasel-js/routing";
|
|
8
|
+
import { useDepSource as l } from "@weasel-js/routing/react";
|
|
9
|
+
//#region src/canvas/deps/editAnchors.ts
|
|
10
|
+
function u(e) {
|
|
11
|
+
if (!e) return null;
|
|
12
|
+
if (e.pose?.kind === "polygon") return { kind: "pose" };
|
|
13
|
+
let t = e.data;
|
|
14
|
+
return t?.path && t.path.kind === "polygon" && n(e.pose) ? {
|
|
15
|
+
kind: "data",
|
|
16
|
+
pose: e.pose,
|
|
17
|
+
data: t
|
|
18
|
+
} : null;
|
|
19
|
+
}
|
|
20
|
+
function d(e) {
|
|
21
|
+
if (!e) return null;
|
|
22
|
+
let t = u(e);
|
|
23
|
+
return t ? t.kind === "pose" ? e.pose : r(t.data.path, t.pose) : null;
|
|
24
|
+
}
|
|
25
|
+
var f = /* @__PURE__ */ new Set();
|
|
26
|
+
function p(n, r, p, m, h) {
|
|
27
|
+
let g = s(n), _ = s(r), v = s(p), y = s(h?.anchorEditingAllowed), [b, x] = o(""), S = a((e) => {
|
|
28
|
+
x(e ?? "");
|
|
29
|
+
}, []), C = s(m), w = s(S), T = () => C.current ? C.current.getEditingId() : b;
|
|
30
|
+
l("editAnchors", () => {
|
|
31
|
+
let n = g.current, r = v.current, a = _.current, o = C.current, s = T();
|
|
32
|
+
if (s) {
|
|
33
|
+
let e = n.get(s), t = a.current.includes(s), r = !y.current || y.current();
|
|
34
|
+
(!e || !t || !r) && (s = "");
|
|
35
|
+
}
|
|
36
|
+
let l = s ? o?.getSelectedAnchors() ?? f : f, p = s ? o?.getMarquee() ?? null : null, m = (r, a, o) => {
|
|
37
|
+
let s = a, c = n.get(r);
|
|
38
|
+
if (!c) return [];
|
|
39
|
+
let l = u(c);
|
|
40
|
+
if (!l) return [];
|
|
41
|
+
if (l.kind === "pose") return [e({
|
|
42
|
+
id: r,
|
|
43
|
+
from: c.pose,
|
|
44
|
+
to: s,
|
|
45
|
+
label: o
|
|
46
|
+
})];
|
|
47
|
+
let { pose: d, path: f } = i(l.pose, s);
|
|
48
|
+
return [e({
|
|
49
|
+
id: r,
|
|
50
|
+
from: c.pose,
|
|
51
|
+
to: d,
|
|
52
|
+
label: o
|
|
53
|
+
}), t({
|
|
54
|
+
id: r,
|
|
55
|
+
from: c.data,
|
|
56
|
+
to: {
|
|
57
|
+
...c.data,
|
|
58
|
+
path: f
|
|
59
|
+
},
|
|
60
|
+
label: o
|
|
61
|
+
})];
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
editingId: s,
|
|
65
|
+
setEditingId(e) {
|
|
66
|
+
let t = e ?? "";
|
|
67
|
+
s !== t && (c("editAnchors.editingId", s || null, t || null, t ? "enter" : "exit"), o?.setSelectedAnchors(f), o?.setMarquee(null)), C.current ? C.current.setEditingId(e) : w.current(e);
|
|
68
|
+
},
|
|
69
|
+
selectedAnchors: l,
|
|
70
|
+
setSelectedAnchors(e) {
|
|
71
|
+
s && o?.setSelectedAnchors(new Set(e));
|
|
72
|
+
},
|
|
73
|
+
marquee: p,
|
|
74
|
+
setMarquee(e) {
|
|
75
|
+
s && o?.setMarquee(e);
|
|
76
|
+
},
|
|
77
|
+
getEditablePath(e) {
|
|
78
|
+
return d(n.get(e));
|
|
79
|
+
},
|
|
80
|
+
getStorageKind(e) {
|
|
81
|
+
return u(n.get(e))?.kind ?? null;
|
|
82
|
+
},
|
|
83
|
+
getNodeShape(e) {
|
|
84
|
+
let t = n.get(e);
|
|
85
|
+
return t ? {
|
|
86
|
+
pose: t.pose,
|
|
87
|
+
data: t.data
|
|
88
|
+
} : null;
|
|
89
|
+
},
|
|
90
|
+
applyEdit(e, t, n) {
|
|
91
|
+
let i = m(e, t, n);
|
|
92
|
+
i.length > 0 && r.applyOps(i, n);
|
|
93
|
+
},
|
|
94
|
+
editOps: m
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { d as resolveEditablePathOf, p as useEditAnchorsDepSource };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=editAnchors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editAnchors.js","names":["classifyStorage","node","data","isRectPose","resolveEditablePathOf","storage","pathInWorld","EMPTY_ANCHOR_SELECTION","useEditAnchorsDepSource","sceneRef","useLatest","scene","selectionRef","selection","adapterRef","adapter","allowedRef","options","localEditingId","setLocalEditingIdState","useState","setLocalEditingId","useCallback","id","externalRef","externalState","setLocalEditingIdRef","readEditingId","sc","ad","s","ext","effectiveId","inSelection","permitted","selectedAnchors","marquee","editOps","wp","worldPath","createTransformOp","newPose","aligned","worldEditToStorage","createSetDataOp","next","recordModeSwitch","rect","ops","label"],"sources":["../../../src/canvas/deps/editAnchors.ts"],"sourcesContent":["/**\n * `useEditAnchorsDepSource` — wires the `editAnchors` dep consumed by\n * `editAnchorsAction`, `enterPathEditAction`, `exitPathEditAction`, and\n * `insertPathAnchorAction`.\n *\n * `editingId` is explicit, set by `enterPathEditAction` (double-click)\n * and cleared by `exitPathEditAction` (Escape, or when the target leaves\n * the selection / is deleted).\n *\n * `getEditablePath(id)` returns the COMMITTED polygon in **world coords**,\n * regardless of where it's stored:\n * - `node.pose.kind === 'polygon'` → pose IS the polygon.\n * - `node.data.path` is a polygon → kit pen-tool default. Polygon's\n * stored coords are pose-local (aligned to pose origin); we project\n * to world via `pathInWorld` (translate + bake `pose.rotation`).\n *\n * `getStorageKind(id)` returns where the polygon lives (`'pose'` /\n * `'data'` / `null`). Actions use this to emit the right preview-ghost\n * axes: `previewPose` only for pose-as-polygon, `previewPose +\n * previewData` for data.path.\n *\n * `applyEdit(id, worldPath, label)` commits in the correct storage shape,\n * as one undoable batch. Pose-as-polygon is a `transform` op; data.path is\n * a `transform` (new bounds) plus a `setData` (re-aligned local path), so\n * the kit's render invariant (`pathInWorld(stored, pose) === world`) is\n * preserved. `editOps` returns those same ops unapplied, for a caller\n * folding the edit into a larger batch.\n *\n * Live previews ride the standard `OngoingHandle.previewIds/Pose/Data`\n * triple — this dep doesn't own preview state.\n */\nimport { useCallback, useState } from 'react';\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport type { Scene, NodeId, RectPose } from 'core/scene/types';\nimport { isRectPose } from 'interactions/actions/resize/autoPoseDescriptor';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { Path, PolygonPath } from '@weasel-js/geom';\nimport { pathInWorld, worldEditToStorage } from 'features/paths/pathInWorld';\nimport { recordModeSwitch } from '@weasel-js/routing';\nimport type { Op } from 'core/ops/types';\nimport { createTransformOp } from 'core/ops/transform';\nimport { createSetDataOp } from 'core/ops/setData';\n\ninterface OpsApplier {\n applyOps(ops: Op[], label?: string): void;\n}\n\n/** Optional shared state for the edit-mode `editingId`. Pass when the\n * consumer needs to read the current editingId from a sibling component\n * (e.g. the path-editing overlay layer rendered above the SceneCanvas\n * subtree where the dep is published). When omitted, the hook owns\n * local state. */\nexport interface EditAnchorsStateRef {\n getEditingId(): string;\n setEditingId(id: string | null): void;\n /** Selected anchors (flat indices) for the node in `editingId`. */\n getSelectedAnchors(): ReadonlySet<number>;\n setSelectedAnchors(next: ReadonlySet<number>): void;\n /** In-flight anchor-marquee rect in world coords. */\n getMarquee(): { x: number; y: number; width: number; height: number } | null;\n setMarquee(rect: { x: number; y: number; width: number; height: number } | null): void;\n}\n\n/** Extra wiring for {@link useEditAnchorsDepSource}. */\nexport interface EditAnchorsDepOptions {\n /**\n * Whether the host currently permits anchor editing — i.e. whether the\n * active mode allows the `edits-anchors` capability.\n *\n * **Omit this when no mode registry is wired.** Absent means \"no\n * modality, so nothing revokes edit mode\", which is the correct\n * behavior for the many consumers that never opt into modes; passing a\n * predicate built from an empty capability set would revoke edit mode\n * instantly. Same trap as `DEFAULT_ALLOWED_CAPABILITIES` guards against\n * on the chrome side.\n *\n * When supplied and it returns false, `editingId` reads as empty — the\n * overlay stops drawing, the anchors stop being hittable, and the\n * anchor selection is dropped. This is what makes leaving path-edit\n * mode by ANY route (Escape, breadcrumb, a consumer calling\n * `exitMode()` directly) tear down edit state, rather than only the one\n * route that happens to reach `exitPathEditAction`.\n */\n anchorEditingAllowed?: () => boolean;\n}\n\n/** Resolve where a node's editable polygon lives. Returns null when the\n * node has neither a polygon pose nor a polygon on `data.path`. */\nfunction classifyStorage(\n node: { pose: unknown; data: unknown } | undefined | null,\n): { kind: 'pose' } | { kind: 'data'; pose: RectPose; data: { path: PolygonPath } } | null {\n if (!node) return null;\n const pose = node.pose as { kind?: string } | undefined;\n if (pose?.kind === 'polygon') return { kind: 'pose' };\n const data = node.data as { path?: Path } | null;\n if (data?.path && (data.path as { kind?: string }).kind === 'polygon' && isRectPose(node.pose)) {\n return {\n kind: 'data',\n pose: node.pose,\n data: data as { path: PolygonPath },\n };\n }\n return null;\n}\n\n/** Resolve a node's editable polygon in world coords. Shared between the\n * dep source and SceneCanvas's chrome wiring so both apply the same\n * \"pose IS the polygon vs data.path with rect pose\" routing. Does NOT\n * consult any preview state — callers that want live state read\n * in-flight handles themselves. */\nexport function resolveEditablePathOf(\n node: { pose: unknown; data: unknown } | undefined | null,\n): PolygonPath | null {\n if (!node) return null;\n const storage = classifyStorage(node);\n if (!storage) return null;\n // Pose-as-polygon: the pose IS the polygon (polygon poses can't carry\n // rotation), so it's already world.\n if (storage.kind === 'pose') return (node as { pose: PolygonPath }).pose;\n // data.path: project to world via the world seam — translate to the pose\n // origin AND bake `pose.rotation`, so anchors render on the rotated contour\n // the renderer draws (not the unrotated one).\n return pathInWorld(storage.data.path, storage.pose) as PolygonPath;\n}\n\nconst EMPTY_ANCHOR_SELECTION: ReadonlySet<number> = new Set<number>();\n\nexport function useEditAnchorsDepSource(\n scene: Scene<unknown, string, unknown>,\n selection: SelectionApi,\n adapter: OpsApplier,\n externalState?: EditAnchorsStateRef,\n options?: EditAnchorsDepOptions,\n): void {\n const sceneRef = useLatest(scene);\n const selectionRef = useLatest(selection);\n const adapterRef = useLatest(adapter);\n const allowedRef = useLatest(options?.anchorEditingAllowed);\n\n const [localEditingId, setLocalEditingIdState] = useState<string>('');\n const setLocalEditingId = useCallback((id: string | null) => {\n setLocalEditingIdState(id ?? '');\n }, []);\n const externalRef = useLatest(externalState);\n const setLocalEditingIdRef = useLatest(setLocalEditingId);\n\n const readEditingId = (): string => {\n return externalRef.current ? externalRef.current.getEditingId() : localEditingId;\n };\n\n useDepSource('editAnchors', (): EditAnchorsDep => {\n const sc = sceneRef.current;\n const ad = adapterRef.current;\n const s = selectionRef.current;\n const ext = externalRef.current;\n let effectiveId = readEditingId();\n if (effectiveId) {\n const node = sc.get(effectiveId as NodeId);\n const inSelection = (s.current as NodeId[]).includes(effectiveId as NodeId);\n // A mode registry that no longer permits `edits-anchors` revokes\n // edit mode wholesale — see EditAnchorsDepOptions.anchorEditingAllowed.\n const permitted = allowedRef.current ? allowedRef.current() : true;\n if (!node || !inSelection || !permitted) effectiveId = '';\n }\n // Anchor selection and the marquee belong to one specific edited\n // node. The moment `editingId` reads as empty — exited, deselected,\n // deleted, or revoked by a mode change — they are stale by\n // definition, so never hand them out alongside an empty id.\n const selectedAnchors = effectiveId\n ? (ext?.getSelectedAnchors() ?? EMPTY_ANCHOR_SELECTION)\n : EMPTY_ANCHOR_SELECTION;\n const marquee = effectiveId ? (ext?.getMarquee() ?? null) : null;\n const editOps = (id: string, worldPath: unknown, label: string): Op[] => {\n const wp = worldPath as PolygonPath;\n const node = sc.get(id as NodeId);\n if (!node) return [];\n const storage = classifyStorage(node as { pose: unknown; data: unknown });\n if (!storage) return [];\n if (storage.kind === 'pose') return [createTransformOp({ id, from: node.pose, to: wp, label })];\n // Edited path arrives in world coords (rotation baked in by\n // resolveEditablePathOf); invert it back to the unrotated stored\n // shape so `pose.rotation` is preserved and edits round-trip.\n const { pose: newPose, path: aligned } = worldEditToStorage(storage.pose, wp);\n return [\n createTransformOp({ id, from: node.pose, to: newPose, label }),\n createSetDataOp({ id, from: node.data, to: { ...(node.data as object), path: aligned }, label }),\n ];\n };\n return {\n editingId: effectiveId,\n setEditingId(id: string | null) {\n const next = id ?? '';\n if (effectiveId !== next) {\n recordModeSwitch(\n 'editAnchors.editingId',\n effectiveId || null,\n next || null,\n next ? 'enter' : 'exit',\n );\n // Anchor indices only mean something relative to one path.\n ext?.setSelectedAnchors(EMPTY_ANCHOR_SELECTION);\n ext?.setMarquee(null);\n }\n if (externalRef.current) externalRef.current.setEditingId(id);\n else setLocalEditingIdRef.current(id);\n },\n selectedAnchors,\n setSelectedAnchors(next: Iterable<number>) {\n if (!effectiveId) return;\n ext?.setSelectedAnchors(new Set(next));\n },\n marquee,\n setMarquee(rect) {\n if (!effectiveId) return;\n ext?.setMarquee(rect);\n },\n getEditablePath(id: string): PolygonPath | null {\n const node = sc.get(id as NodeId);\n return resolveEditablePathOf(node as { pose: unknown; data: unknown });\n },\n getStorageKind(id: string): 'pose' | 'data' | null {\n const node = sc.get(id as NodeId);\n const storage = classifyStorage(node as { pose: unknown; data: unknown });\n return storage?.kind ?? null;\n },\n getNodeShape(id: string): { pose: unknown; data: unknown } | null {\n const node = sc.get(id as NodeId);\n if (!node) return null;\n return { pose: node.pose, data: node.data };\n },\n applyEdit(id: string, worldPath: unknown, label: string) {\n const ops = editOps(id, worldPath, label);\n if (ops.length > 0) ad.applyOps(ops, label);\n },\n editOps,\n };\n });\n}\n"],"mappings":";;;;;;;;;AA0FA,SAASA,EACP,GACyF;CACzF,IAAI,CAACC,GAAM,OAAO;CAElB,IADaA,EAAK,MACR,SAAS,WAAW,OAAO,EAAE,MA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AAS,QAAQ;GAC1B;GACA,aAAa,GAAqD;IAChE,IAAMtB,IAAO2B,EAAG,IAAIL,CAAY;IAEhC,OADKtB,IACE;KAAE,MAAMA,EAAK;KAAM,MAAMA,EAAK;IAAK,IADxB;GAEpB;GACA,UAAU,GAAY,GAAoB,GAAe;IACvD,IAAM+C,IAAMX,EAAQd,GAAIgB,GAAWU,CAAK;IACxC,AAAID,EAAI,SAAS,KAAGnB,EAAG,SAASmB,GAAKC,CAAK;GAC5C;GACA;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useLatest as e } from "@weasel-js/react";
|
|
2
|
+
import { useDepSource as t } from "@weasel-js/routing/react";
|
|
3
|
+
//#region src/canvas/deps/geometryProjection.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let r = e(n);
|
|
6
|
+
t("geometryProjection", () => r.current);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as useGeometryProjection };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=geometryProjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometryProjection.js","names":["useGeometryProjection","ref","useLatest","projection"],"sources":["../../../src/canvas/deps/geometryProjection.ts"],"sourcesContent":["/**\n * `useGeometryProjection` — wires the `geometryProjection` dep consumed by\n * pose-transform actions (move, resize, nudge, flip).\n *\n * When the prop is absent (`undefined`), calling this hook with `undefined`\n * registers a source that returns `undefined`, which is indistinguishable from\n * no registration — actions treat a missing dep as \"no geometry rewrite\".\n * The canonical usage is to mount a `<GeometryProjectionRegistrar>` only when\n * the consumer has supplied a projection, which avoids registering at all.\n *\n * @see GeometryProjection — the dep schema entry.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { GeometryProjection } from 'interactions/actions/geometryProjection';\n\nexport function useGeometryProjection(\n projection: GeometryProjection | undefined,\n): void {\n const ref = useLatest(projection);\n useDepSource('geometryProjection', () => ref.current);\n}\n"],"mappings":";;;AAgBA,SAAgBA,EACd,GACM;CACN,IAAMC,IAAMC,EAAUC,CAAU;CAChC,EAAa,4BAA4BF,EAAI,OAAO;AACtD"}
|