@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,75 @@
|
|
|
1
|
+
import { createContext as e, createElement as t, useContext as n, useEffect as r, useMemo as i, useState as a } from "react";
|
|
2
|
+
import { DEFAULT_DEVICE_PROFILE as o, resolveDeviceProfile as s } from "@weasel-js/routing";
|
|
3
|
+
//#region src/core/device/useDeviceProfile.ts
|
|
4
|
+
var c = "(pointer: coarse)", l = "(hover: hover)";
|
|
5
|
+
function u() {
|
|
6
|
+
return typeof window < "u" && typeof window.matchMedia == "function";
|
|
7
|
+
}
|
|
8
|
+
function d() {
|
|
9
|
+
let e = typeof window < "u" && window.devicePixelRatio || 1;
|
|
10
|
+
return u() ? {
|
|
11
|
+
coarsePointer: window.matchMedia(c).matches,
|
|
12
|
+
canHover: window.matchMedia(l).matches,
|
|
13
|
+
dpr: e
|
|
14
|
+
} : {
|
|
15
|
+
coarsePointer: o.coarsePointer,
|
|
16
|
+
canHover: o.canHover,
|
|
17
|
+
dpr: e
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function f() {
|
|
21
|
+
let [e, t] = a(d);
|
|
22
|
+
return r(() => {
|
|
23
|
+
if (!u()) return;
|
|
24
|
+
let e = window.matchMedia(c), n = window.matchMedia(l), r = (e) => t((t) => ({
|
|
25
|
+
...t,
|
|
26
|
+
coarsePointer: e.matches
|
|
27
|
+
})), i = (e) => t((t) => ({
|
|
28
|
+
...t,
|
|
29
|
+
canHover: e.matches
|
|
30
|
+
}));
|
|
31
|
+
e.addEventListener("change", r), n.addEventListener("change", i);
|
|
32
|
+
let a = !1, o = null, s = () => {
|
|
33
|
+
if (a) return;
|
|
34
|
+
let e = window.devicePixelRatio || 1;
|
|
35
|
+
t((t) => t.dpr === e ? t : {
|
|
36
|
+
...t,
|
|
37
|
+
dpr: e
|
|
38
|
+
}), d();
|
|
39
|
+
};
|
|
40
|
+
function d() {
|
|
41
|
+
a || (o?.removeEventListener("change", s), o = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`), o.addEventListener("change", s));
|
|
42
|
+
}
|
|
43
|
+
return d(), t({
|
|
44
|
+
coarsePointer: e.matches,
|
|
45
|
+
canHover: n.matches,
|
|
46
|
+
dpr: window.devicePixelRatio || 1
|
|
47
|
+
}), () => {
|
|
48
|
+
a = !0, e.removeEventListener("change", r), n.removeEventListener("change", i), o?.removeEventListener("change", s);
|
|
49
|
+
};
|
|
50
|
+
}, []), e;
|
|
51
|
+
}
|
|
52
|
+
var p = e(null);
|
|
53
|
+
function m(e) {
|
|
54
|
+
let t = n(p), r = f(), a = t ?? r, { coarsePointer: o, canHover: c, dpr: l, targetScale: u } = e ?? {};
|
|
55
|
+
return i(() => s(a, {
|
|
56
|
+
...o === void 0 ? {} : { coarsePointer: o },
|
|
57
|
+
...c === void 0 ? {} : { canHover: c },
|
|
58
|
+
...l === void 0 ? {} : { dpr: l },
|
|
59
|
+
...u === void 0 ? {} : { targetScale: u }
|
|
60
|
+
}), [
|
|
61
|
+
a,
|
|
62
|
+
o,
|
|
63
|
+
c,
|
|
64
|
+
l,
|
|
65
|
+
u
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
function h({ value: e, children: n }) {
|
|
69
|
+
let r = m(e);
|
|
70
|
+
return t(p.Provider, { value: r }, n);
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { h as DeviceProfileProvider, m as useDeviceProfile };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=useDeviceProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeviceProfile.js","names":["COARSE_QUERY","HOVER_QUERY","hasMatchMedia","detectOnce","dpr","DEFAULT_DEVICE_PROFILE","useDetectedFacts","facts","setFacts","useState","useEffect","coarseMq","hoverMq","onCoarse","f","onHover","disposed","densityMq","onDensity","next","arm","DeviceProfileContext","createContext","useDeviceProfile","provided","useContext","detected","base","overrides","useMemo","resolveDeviceProfile","coarsePointer","canHover","targetScale","DeviceProfileProvider","profile","value","createElement","children"],"sources":["../../../src/core/device/useDeviceProfile.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\nimport type { DetectedDeviceFacts, DeviceProfile } from './types';\nimport { DEFAULT_DEVICE_PROFILE, resolveDeviceProfile } from '@weasel-js/routing';\n\nconst COARSE_QUERY = '(pointer: coarse)';\nconst HOVER_QUERY = '(hover: hover)';\n\nfunction hasMatchMedia(): boolean {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n}\n\nfunction detectOnce(): DetectedDeviceFacts {\n // Density is read unconditionally: `devicePixelRatio` does not depend on\n // `matchMedia` existing. Only *watching* density needs a media query.\n // Gating this read behind `hasMatchMedia()` would report density 1 under\n // any environment without matchMedia — including jsdom, which would\n // silently break `useCanvasSize`'s existing DPR assertions.\n const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;\n if (!hasMatchMedia()) {\n return {\n coarsePointer: DEFAULT_DEVICE_PROFILE.coarsePointer,\n canHover: DEFAULT_DEVICE_PROFILE.canHover,\n dpr,\n };\n }\n return {\n coarsePointer: window.matchMedia(COARSE_QUERY).matches,\n canHover: window.matchMedia(HOVER_QUERY).matches,\n dpr,\n };\n}\n\n/**\n * Detect device facts and keep them live.\n *\n * Three subscriptions: pointer coarseness, hover capability, and pixel\n * density. The density one is special — `(resolution: Ndppx)` stops matching\n * as soon as density changes, so a single listener fires once and goes dead.\n * We re-arm a fresh query at the new density on every change.\n */\nfunction useDetectedFacts(): DetectedDeviceFacts {\n const [facts, setFacts] = useState<DetectedDeviceFacts>(detectOnce);\n\n useEffect(() => {\n if (!hasMatchMedia()) return;\n\n const coarseMq = window.matchMedia(COARSE_QUERY);\n const hoverMq = window.matchMedia(HOVER_QUERY);\n\n const onCoarse = (e: MediaQueryListEvent | { matches: boolean }) =>\n setFacts((f) => ({ ...f, coarsePointer: e.matches }));\n const onHover = (e: MediaQueryListEvent | { matches: boolean }) =>\n setFacts((f) => ({ ...f, canHover: e.matches }));\n\n coarseMq.addEventListener('change', onCoarse as EventListener);\n hoverMq.addEventListener('change', onHover as EventListener);\n\n // Re-arming density watcher.\n let disposed = false;\n let densityMq: MediaQueryList | null = null;\n const onDensity = () => {\n if (disposed) return;\n const next = window.devicePixelRatio || 1;\n setFacts((f) => (f.dpr === next ? f : { ...f, dpr: next }));\n arm();\n };\n function arm(): void {\n if (disposed) return;\n densityMq?.removeEventListener('change', onDensity as EventListener);\n densityMq = window.matchMedia(\n `(resolution: ${window.devicePixelRatio || 1}dppx)`,\n );\n densityMq.addEventListener('change', onDensity as EventListener);\n }\n arm();\n\n // Re-sync once on mount: a query could have changed between the\n // useState initializer and the effect running.\n setFacts({\n coarsePointer: coarseMq.matches,\n canHover: hoverMq.matches,\n dpr: window.devicePixelRatio || 1,\n });\n\n return () => {\n disposed = true;\n coarseMq.removeEventListener('change', onCoarse as EventListener);\n hoverMq.removeEventListener('change', onHover as EventListener);\n densityMq?.removeEventListener('change', onDensity as EventListener);\n };\n }, []);\n\n return facts;\n}\n\nconst DeviceProfileContext = createContext<DeviceProfile | null>(null);\n\n/**\n * Read the ambient device profile.\n *\n * Uses the nearest {@link DeviceProfileProvider} when one exists, and\n * otherwise detects for itself — so a standalone overlay or a labkit panel\n * rendered outside a `<SceneCanvas>` still gets correct facts.\n *\n * `overrides` always wins over both, which is what makes tests and\n * force-touch-chrome demos possible without stubbing `matchMedia`.\n */\nexport function useDeviceProfile(overrides?: Partial<DeviceProfile>): DeviceProfile {\n const provided = useContext(DeviceProfileContext);\n const detected = useDetectedFacts();\n const base: DetectedDeviceFacts = provided ?? detected;\n const { coarsePointer, canHover, dpr, targetScale } = overrides ?? {};\n return useMemo(\n () =>\n resolveDeviceProfile(base, {\n ...(coarsePointer !== undefined ? { coarsePointer } : {}),\n ...(canHover !== undefined ? { canHover } : {}),\n ...(dpr !== undefined ? { dpr } : {}),\n ...(targetScale !== undefined ? { targetScale } : {}),\n }),\n [base, coarsePointer, canHover, dpr, targetScale],\n );\n}\n\n/** Props for `<DeviceProfileProvider>`. */\nexport interface DeviceProfileProviderProps {\n /** Partial override folded over detected facts. */\n value?: Partial<DeviceProfile>;\n children: ReactNode;\n}\n\n/**\n * Publish one resolved profile to a subtree. `<SceneCanvas>` renders this so\n * overlays, affordances, and consumer chrome all read the same object.\n */\nexport function DeviceProfileProvider({ value, children }: DeviceProfileProviderProps) {\n const profile = useDeviceProfile(value);\n return createElement(DeviceProfileContext.Provider, { value: profile }, children);\n}\n"],"mappings":";;;AAYA,IAAMA,IAAe,qBACfC,IAAc;AAEpB,SAASC,IAAyB;CAChC,OAAO,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe;AACvE;AAEA,SAASC,IAAkC;C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AoB,UAAUG,CAAwB,GAC9DE,GAAW,oBAAoB,UAAUC,CAA0B;EACrE;CACF,GAAG,CAAC,CAAC,GAEEX;AACT;AAEA,IAAMc,IAAuBC,EAAoC,IAAI;AAYrE,SAAgBC,EAAiB,GAAmD;CAClF,IAAMC,IAAWC,EAAWJ,CAAoB,GAC1CK,IAAWpB,EAAiB,GAC5BqB,IAA4BH,KAAYE,GACxC,EAAE,kBAAe,aAAU,QAAK,mBAAgBE,KAAa,CAAC;CACpE,OAAOC,QAEHC,EAAqBH,GAAM;EACzB,GAAII,MAAkB,KAAA,IAAgC,CAAC,IAArB,EAAE,iBAAc;EAClD,GAAIC,MAAa,KAAA,IAA2B,CAAC,IAAhB,EAAE,YAAS;EACxC,GAAI5B,MAAQ,KAAA,IAAsB,CAAC,IAAX,EAAE,OAAI;EAC9B,GAAI6B,MAAgB,KAAA,IAA8B,CAAC,IAAnB,EAAE,eAAY;CAChD,CAAC,GACH;EAACN;EAAMI;EAAeC;EAAU5B;EAAK6B;CAAW,CAClD;AACF;AAaA,SAAgBC,EAAsB,EAAE,UAAO,eAAwC;CACrF,IAAMC,IAAUZ,EAAiBa,CAAK;CACtC,OAAOC,EAAchB,EAAqB,UAAU,EAAE,OAAOc,EAAQ,GAAGG,CAAQ;AAClF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getPaintKind as e } from "./paintKinds.js";
|
|
2
|
+
//#region src/core/fillInPoseFrame.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (!a(t)) return e(t.fill)?.inPoseFrame?.(t, n) ?? t;
|
|
5
|
+
if (r(t)) {
|
|
6
|
+
let e = t.origin ?? {
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
...t,
|
|
12
|
+
origin: {
|
|
13
|
+
x: n.x + e.x,
|
|
14
|
+
y: n.y + e.y
|
|
15
|
+
},
|
|
16
|
+
units: "local"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (!i(t)) return t;
|
|
20
|
+
let o = (e) => ({
|
|
21
|
+
x: n.x + e.x * n.width,
|
|
22
|
+
y: n.y + e.y * n.height
|
|
23
|
+
});
|
|
24
|
+
if (t.fill === "linear-gradient") return {
|
|
25
|
+
...t,
|
|
26
|
+
from: o(t.from),
|
|
27
|
+
to: o(t.to),
|
|
28
|
+
units: "local"
|
|
29
|
+
};
|
|
30
|
+
if (t.fill === "radial-gradient") {
|
|
31
|
+
let e = Math.hypot(n.width, n.height) / Math.SQRT2;
|
|
32
|
+
return {
|
|
33
|
+
...t,
|
|
34
|
+
center: o(t.center),
|
|
35
|
+
radius: t.radius * e,
|
|
36
|
+
units: "local"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...t,
|
|
41
|
+
center: o(t.center),
|
|
42
|
+
units: "local"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function n(t, n) {
|
|
46
|
+
if (!a(t)) return e(t.fill)?.toBoundsFrame?.(t, n) ?? t;
|
|
47
|
+
if (t.fill === "pattern") {
|
|
48
|
+
let e = t.origin ?? {
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
...t,
|
|
54
|
+
origin: {
|
|
55
|
+
x: e.x - n.x,
|
|
56
|
+
y: e.y - n.y
|
|
57
|
+
},
|
|
58
|
+
units: "bounds"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (t.fill !== "linear-gradient" && t.fill !== "radial-gradient" && t.fill !== "conic-gradient" || n.width === 0 || n.height === 0) return t;
|
|
62
|
+
let r = (e) => ({
|
|
63
|
+
x: (e.x - n.x) / n.width,
|
|
64
|
+
y: (e.y - n.y) / n.height
|
|
65
|
+
});
|
|
66
|
+
if (t.fill === "linear-gradient") return {
|
|
67
|
+
...t,
|
|
68
|
+
from: r(t.from),
|
|
69
|
+
to: r(t.to),
|
|
70
|
+
units: "bounds"
|
|
71
|
+
};
|
|
72
|
+
if (t.fill === "radial-gradient") {
|
|
73
|
+
let e = Math.hypot(n.width, n.height) / Math.SQRT2;
|
|
74
|
+
return {
|
|
75
|
+
...t,
|
|
76
|
+
center: r(t.center),
|
|
77
|
+
radius: t.radius / e,
|
|
78
|
+
units: "bounds"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...t,
|
|
83
|
+
center: r(t.center),
|
|
84
|
+
units: "bounds"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function r(e) {
|
|
88
|
+
return e.fill === "pattern" && e.units === "bounds";
|
|
89
|
+
}
|
|
90
|
+
function i(e) {
|
|
91
|
+
if (e === void 0) return !1;
|
|
92
|
+
let t = e.fill;
|
|
93
|
+
return t !== "linear-gradient" && t !== "radial-gradient" && t !== "conic-gradient" ? !1 : e.units === "bounds";
|
|
94
|
+
}
|
|
95
|
+
function a(e) {
|
|
96
|
+
let t = e.fill ?? "solid";
|
|
97
|
+
return t === "solid" || t === "pattern" || t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient";
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { t as fillInPoseFrame, n as fillToBoundsFrame };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=fillInPoseFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fillInPoseFrame.js","names":["fillInPoseFrame","isBuiltinKind","fill","getPaintKind","box","isBoundsPattern","o","isBoundsGradient","toBox","p","scale","fillToBoundsFrame","fromBox","kind"],"sources":["../../src/core/fillInPoseFrame.ts"],"sourcesContent":["/**\n * Resolve a `units: 'bounds'` gradient into the frame its node is painted in.\n *\n * Node painters bake the pose into their geometry (`pathInPoseFrame`) rather\n * than emitting a per-node transform, so by the time the renderer sees a\n * scene node there is no node-local space left for a gradient to refer to.\n * This is the paint-side counterpart: it maps box-relative gradient geometry\n * onto the same box the path was just projected into, so the two arrive in\n * the renderer in one frame.\n */\n\nimport type { FillStyle, GradientFill } from '@weasel-js/paint';\nimport { getPaintKind } from './paintKinds';\n\n/** The box a `'bounds'` gradient's normalized geometry is mapped onto —\n * usually a node's bounds. */\nexport interface FillPoseBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Map a `'bounds'` gradient's `0..1` geometry onto `box`, returning it in the\n * box's own frame (`units: 'local'`). Any other fill — solid, pattern, or a\n * gradient in another space — is returned untouched.\n *\n * Radii scale by the box's normalized diagonal, SVG's rule for a percentage\n * radius against `objectBoundingBox`: `sqrt(w² + h²) / sqrt(2)`, which is\n * exactly `w` for a square box. The renderer's radial gradient is circular,\n * so a non-square box cannot make it the ellipse SVG would — this keeps the\n * radius proportionate instead.\n */\nexport function fillInPoseFrame(fill: FillStyle, box: FillPoseBox): FillStyle {\n if (!isBuiltinKind(fill)) {\n return getPaintKind(fill.fill)?.inPoseFrame?.(fill, box) ?? fill;\n }\n if (isBoundsPattern(fill)) {\n const o = fill.origin ?? { x: 0, y: 0 };\n return { ...fill, origin: { x: box.x + o.x, y: box.y + o.y }, units: 'local' as const };\n }\n if (!isBoundsGradient(fill)) return fill;\n\n const toBox = (p: { x: number; y: number }): { x: number; y: number } => ({\n x: box.x + p.x * box.width,\n y: box.y + p.y * box.height,\n });\n\n if (fill.fill === 'linear-gradient') {\n return { ...fill, from: toBox(fill.from), to: toBox(fill.to), units: 'local' as const };\n }\n if (fill.fill === 'radial-gradient') {\n const scale = Math.hypot(box.width, box.height) / Math.SQRT2;\n return { ...fill, center: toBox(fill.center), radius: fill.radius * scale, units: 'local' as const };\n }\n return { ...fill, center: toBox(fill.center), units: 'local' as const };\n}\n\n/**\n * Inverse of {@link fillInPoseFrame}: express a gradient already positioned\n * in `box`'s frame as `0..1` fractions of that box (`units: 'bounds'`), so\n * it follows the node when moved or resized.\n *\n * The importer's counterpart — SVG `userSpaceOnUse` coordinates arrive in\n * page space, and normalizing them here makes an imported gradient behave\n * exactly like one drawn in the app.\n *\n * A zero-width or zero-height box has no frame to normalize against; the\n * fill is returned untouched rather than divided by zero.\n */\nexport function fillToBoundsFrame(fill: FillStyle, box: FillPoseBox): FillStyle {\n if (!isBuiltinKind(fill)) {\n return getPaintKind(fill.fill)?.toBoundsFrame?.(fill, box) ?? fill;\n }\n if (fill.fill === 'pattern') {\n const o = fill.origin ?? { x: 0, y: 0 };\n return { ...fill, origin: { x: o.x - box.x, y: o.y - box.y }, units: 'bounds' as const };\n }\n const isGradient = fill.fill === 'linear-gradient'\n || fill.fill === 'radial-gradient'\n || fill.fill === 'conic-gradient';\n if (!isGradient) return fill;\n if (box.width === 0 || box.height === 0) return fill;\n\n const fromBox = (p: { x: number; y: number }): { x: number; y: number } => ({\n x: (p.x - box.x) / box.width,\n y: (p.y - box.y) / box.height,\n });\n\n if (fill.fill === 'linear-gradient') {\n return { ...fill, from: fromBox(fill.from), to: fromBox(fill.to), units: 'bounds' as const };\n }\n if (fill.fill === 'radial-gradient') {\n const scale = Math.hypot(box.width, box.height) / Math.SQRT2;\n return { ...fill, center: fromBox(fill.center), radius: fill.radius / scale, units: 'bounds' as const };\n }\n return { ...fill, center: fromBox(fill.center), units: 'bounds' as const };\n}\n\n/** True when this fill is a pattern anchored to the painted node's box.\n * Rebasing it is a translation only — a resize must reveal more tiles, not\n * stretch them, which is the whole reason patterns get their own branch. */\nfunction isBoundsPattern(\n fill: FillStyle,\n): fill is Extract<FillStyle, { fill: 'pattern' }> {\n return fill.fill === 'pattern' && fill.units === 'bounds';\n}\n\n/** True when this fill is a gradient declaring box-relative geometry. */\nfunction isBoundsGradient(fill: FillStyle | undefined): fill is GradientFill {\n if (fill === undefined) return false;\n const kind = fill.fill;\n if (kind !== 'linear-gradient' && kind !== 'radial-gradient' && kind !== 'conic-gradient') {\n return false;\n }\n return fill.units === 'bounds';\n}\n\n/** The five kinds whose frame conversion is written above. Anything else is a\n * registered kind and converts through its own entry. */\nfunction isBuiltinKind(fill: FillStyle): boolean {\n const kind = fill.fill ?? 'solid';\n return kind === 'solid' || kind === 'pattern'\n || kind === 'linear-gradient' || kind === 'radial-gradient' || kind === 'conic-gradient';\n}\n"],"mappings":";;AAkCA,SAAgBA,EAAgB,GAAiB,GAA6B;CAC5E,IAAI,CAACC,EAAcC,CAAI,GACrB,OAAOC,EAAaD,EAAK,IAAI,CAAC,EAAE,cAAcA,GAAME,CAAG,KAAKF;CAE9D,IAAIG,EAAgBH,CAAI,GAAG;EACzB,IAAMI,IAAIJ,EAAK,UAAU;GAAE,GAAG;GAAG,GAAG;EAAE;EACtC,OAAO;GAAE,GAAGA;GAAM,QAAQ;IAAE,GAAGE,EAAI,IAAIE,EAAE;IAAG,GAAGF,EAAI,IAAIE,EAAE;GAAE;GAAG,OAAO;EAAiB;CACxF;CACA,IAAI,CAACC,EAAiBL,CAAI,GAAG,OAAOA;CAEpC,IAAMM,KAAS,OAA2D;EACxE,GAAGJ,EAAI,IAAIK,EAAE,IAAIL,EAAI;EACrB,GAAGA,EAAI,IAAIK,EAAE,IAAIL,EAAI;CACvB;CAEA,IAAIF,EAAK,SAAS,mBAChB,OAAO;EAAE,GAAGA;EAAM,MAAMM,EAAMN,EAAK,IAAI;EAAG,IAAIM,EAAMN,EAAK,EAAE;EAAG,OAAO;CAAiB;CAExF,IAAIA,EAAK,SAAS,mBAAmB;EACnC,IAAMQ,IAAQ,KAAK,MAAMN,EAAI,OAAOA,EAAI,MAAM,IAAI,KAAK;EACvD,OAAO;GAAE,GAAGF;GAAM,QAAQM,EAAMN,EAAK,MAAM;GAAG,QAAQA,EAAK,SAASQ;GAAO,OAAO;EAAiB;CACrG;CACA,OAAO;EAAE,GAAGR;EAAM,QAAQM,EAAMN,EAAK,MAAM;EAAG,OAAO;CAAiB;AACxE;AAcA,SAAgBS,EAAkB,GAAiB,GAA6B;CAC9E,IAAI,CAACV,EAAcC,CAAI,GACrB,OAAOC,EAAaD,EAAK,IAAI,CAAC,EAAE,gBAAgBA,GAAME,CAAG,KAAKF;C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AAOW,MAAS,WAAWA,MAAS,aAC/BA,MAAS,qBAAqBA,MAAS,qBAAqBA,MAAS;AAC5E"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { axisAlignedBounds as e } from "./unionBounds.js";
|
|
2
|
+
//#region src/core/geometry/poseDescriptor.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return e.forNode?.(t) ?? e;
|
|
5
|
+
}
|
|
6
|
+
function n(e, t) {
|
|
7
|
+
return e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y;
|
|
8
|
+
}
|
|
9
|
+
var r = {
|
|
10
|
+
getBounds: (e) => e,
|
|
11
|
+
remapBounds: (e, t, n) => {
|
|
12
|
+
let r = t.width === 0 ? 1 : n.width / t.width, i = t.height === 0 ? 1 : n.height / t.height;
|
|
13
|
+
return {
|
|
14
|
+
...e,
|
|
15
|
+
x: n.x + (e.x - t.x) * r,
|
|
16
|
+
y: n.y + (e.y - t.y) * i,
|
|
17
|
+
width: e.width * r,
|
|
18
|
+
height: e.height * i
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
fromBounds: (e) => ({
|
|
22
|
+
x: e.x,
|
|
23
|
+
y: e.y,
|
|
24
|
+
width: e.width,
|
|
25
|
+
height: e.height
|
|
26
|
+
}),
|
|
27
|
+
translate: (e, t, n) => ({
|
|
28
|
+
...e,
|
|
29
|
+
x: e.x + t,
|
|
30
|
+
y: e.y + n
|
|
31
|
+
}),
|
|
32
|
+
intersectsRect: (e, t) => n(e, t),
|
|
33
|
+
lerp: (e, t, n) => ({
|
|
34
|
+
...e,
|
|
35
|
+
x: e.x + (t.x - e.x) * n,
|
|
36
|
+
y: e.y + (t.y - e.y) * n,
|
|
37
|
+
width: e.width + (t.width - e.width) * n,
|
|
38
|
+
height: e.height + (t.height - e.height) * n
|
|
39
|
+
}),
|
|
40
|
+
getRotation: (e) => e.rotation ?? 0,
|
|
41
|
+
withRotation: (e, t) => ({
|
|
42
|
+
...e,
|
|
43
|
+
rotation: t
|
|
44
|
+
})
|
|
45
|
+
}, i = {
|
|
46
|
+
getBounds: r.getBounds,
|
|
47
|
+
remapBounds: r.remapBounds,
|
|
48
|
+
translate: r.translate,
|
|
49
|
+
intersectsRect: r.intersectsRect,
|
|
50
|
+
lerp: r.lerp,
|
|
51
|
+
fromBounds: (e) => ({
|
|
52
|
+
x: e.x,
|
|
53
|
+
y: e.y,
|
|
54
|
+
width: e.width,
|
|
55
|
+
height: e.height,
|
|
56
|
+
rotation: 0
|
|
57
|
+
}),
|
|
58
|
+
getRotation: (e) => e.rotation,
|
|
59
|
+
withRotation: (e, t) => ({
|
|
60
|
+
...e,
|
|
61
|
+
rotation: t
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
function a(e, t, n) {
|
|
65
|
+
let r = t.width === 0 ? 1 : n.width / t.width, i = t.height === 0 ? 1 : n.height / t.height, a = e.rotation ?? 0, o = Math.cos(a), s = Math.sin(a), c = r * o, l = i * s, u = -r * s, d = i * o, f = e.width * Math.hypot(c, l), p = e.height * Math.hypot(u, d), m = Math.atan2(l, c), h = n.x + (e.x + e.width / 2 - t.x) * r, g = n.y + (e.y + e.height / 2 - t.y) * i;
|
|
66
|
+
return {
|
|
67
|
+
...e,
|
|
68
|
+
x: h - f / 2,
|
|
69
|
+
y: g - p / 2,
|
|
70
|
+
width: f,
|
|
71
|
+
height: p,
|
|
72
|
+
rotation: m
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function o(t, n) {
|
|
76
|
+
let r = n.getBounds(t), i = n.getRotation?.(t) ?? r.rotation ?? 0;
|
|
77
|
+
return e({
|
|
78
|
+
x: r.x,
|
|
79
|
+
y: r.y,
|
|
80
|
+
width: r.width,
|
|
81
|
+
height: r.height,
|
|
82
|
+
rotation: i
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function s(e, t, n, r) {
|
|
86
|
+
if (r.translate) return r.translate(e, t, n);
|
|
87
|
+
let i = r.getBounds(e), a = {
|
|
88
|
+
x: i.x + t,
|
|
89
|
+
y: i.y + n,
|
|
90
|
+
width: i.width,
|
|
91
|
+
height: i.height
|
|
92
|
+
};
|
|
93
|
+
return r.remapBounds(e, i, a);
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { r as RECT_POSE_DESCRIPTOR, i as ROTATED_POSE_DESCRIPTOR, n as aabbIntersectsRect, t as poseDescriptorForNode, a as remapRotatedLeaf, s as translatePoseViaDescriptor, o as visualBoundsViaDescriptor };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=poseDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poseDescriptor.js","names":["poseDescriptorForNode","descriptor","node","aabbIntersectsRect","b","r","RECT_POSE_DESCRIPTOR","p","sx","src","dst","sy","dx","dy","a","t","ROTATED_POSE_DESCRIPTOR","remapRotatedLeaf","theta","pose","cos","sin","ux","uy","vx","vy","width","height","rotation","cxNew","cyNew","visualBoundsViaDescriptor","geometry","axisAlignedBounds","translatePoseViaDescriptor"],"sources":["../../../src/core/geometry/poseDescriptor.ts"],"sourcesContent":["import type { Bounds } from 'core/viewport/fitViewToBounds';\nimport { axisAlignedBounds } from 'core/geometry/unionBounds';\n\n/** `Bounds` with a required rotation angle (radians). Pivot is the AABB\n * center of the unrotated `{x, y, width, height}`. */\nexport interface RotatedPose extends Bounds {\n rotation: number;\n}\n\n/**\n * Bridges arbitrary `TPose` shapes into the resize hook's bounds-driven math.\n * The hook reads bounds via `getBounds`, runs anchor-relative math on those\n * bounds, then asks `remapBounds` to project the result back into TPose.\n *\n * `remapBounds(pose, src, dst)` is a single operation that subsumes both\n * \"set my own AABB to dst\" (single-leaf resize) and \"scale me as a leaf\n * inside parent's src→dst rect\" (group resize) — they're the same affine\n * map. For rect-shaped poses the default geometry interprets the pose as\n * its own bounds; for Path or polygon poses the consumer supplies a\n * projection that knows how to read and rewrite the underlying geometry.\n */\nexport interface PoseDescriptor<TPose, TNode = unknown> {\n getBounds(pose: TPose): Bounds;\n remapBounds(pose: TPose, src: Bounds, dst: Bounds): TPose;\n /** A pose occupying `bounds`, of the same kind as `template`. Unlike\n * `remapBounds`, the result carries none of the template's shape. */\n fromBounds(bounds: Bounds, template: TPose): TPose;\n /** Translate the pose by (dx, dy). Optional — when omitted, callers fall\n * back to a translation derived from `remapBounds` (origin shifted, no\n * scale). Path-shaped poses should provide this for performance. */\n translate?(pose: TPose, dx: number, dy: number): TPose;\n /** True iff any portion of the pose's geometry intersects `rect`. Optional.\n * Marquee and lasso do not read it: both test the node's drawn outline\n * (`core/geometry/regionHit`). */\n intersectsRect?(pose: TPose, rect: Bounds): boolean;\n /** Interpolate between two poses. Optional — animation helpers fall back to\n * rect-shape lerp when omitted (which fails for non-rect poses). */\n lerp?(a: TPose, b: TPose, t: number): TPose;\n /** Read the pose's rotation in radians. Pivot is the AABB center\n * (`getBounds(pose)` center). Default 0 when omitted — descriptor\n * declares \"this pose has no rotation.\" When supplied and non-zero,\n * `useResize` projects the drag delta into the leaf's local frame,\n * runs anchor math there, and translates the resulting pose so the\n * diagonally opposite world-space corner is pinned. */\n getRotation?(pose: TPose): number;\n /** True iff this pose shape can carry a rotation. Consulted by the\n * rotation affordance to decide whether to render the rotate cursor /\n * drag-band over a selection. When omitted, the kit assumes `true` for\n * back-compat — descriptors whose poses lack `x/y/width/height/rotation`\n * fields (e.g. polygon Paths) should return `false` so the affordance\n * hides instead of exposing a non-functional rotate cursor. */\n supportsRotation?(pose: TPose): boolean;\n /** Write a rotation (radians) into the pose, bounds unchanged. Absent means\n * the pose cannot carry one, and the rotate action leaves it alone. */\n withRotation?(pose: TPose, rotation: number): TPose;\n /**\n * A descriptor specialized to one node. Every other method here sees only\n * the pose, so shapes sharing a pose type — a sphere and a box both posed by\n * position/rotation/scale — are indistinguishable to them. Implement this to\n * read `node.data` once and hand back a descriptor that knows which shape it\n * is describing.\n *\n * Callers reach it through {@link poseDescriptorForNode}, at whichever site\n * holds the node; the specialized descriptor then travels into the bounds and\n * hit-test helpers in place of this one. Sites with only an id keep using the\n * unspecialized descriptor, which is why this is optional on both ends.\n */\n forNode?(node: TNode): PoseDescriptor<TPose, TNode>;\n}\n\n/** The descriptor `node` should be read through: its own specialization when\n * it declares one, and otherwise the descriptor unchanged. */\nexport function poseDescriptorForNode<TPose, TNode>(\n descriptor: PoseDescriptor<TPose, TNode>,\n node: TNode,\n): PoseDescriptor<TPose, TNode> {\n return descriptor.forNode?.(node) ?? descriptor;\n}\n\n/** AABB-vs-AABB overlap. Exported for callers building a default\n * `intersectsRect` from `getBounds`. */\nexport function aabbIntersectsRect(b: Bounds, r: Bounds): boolean {\n return b.x < r.x + r.width && b.x + b.width > r.x && b.y < r.y + r.height && b.y + b.height > r.y;\n}\n\n/** Identity geometry for `TPose extends Bounds`. Treats the pose as its\n * own bounds and remaps via affine scale against `src`/`dst`. */\nexport const RECT_POSE_DESCRIPTOR: PoseDescriptor<Bounds> = {\n getBounds: (p) => p,\n remapBounds: (p, src, dst) => {\n const sx = src.width === 0 ? 1 : dst.width / src.width;\n const sy = src.height === 0 ? 1 : dst.height / src.height;\n return {\n ...p,\n x: dst.x + (p.x - src.x) * sx,\n y: dst.y + (p.y - src.y) * sy,\n width: p.width * sx,\n height: p.height * sy,\n };\n },\n fromBounds: (b) => ({ x: b.x, y: b.y, width: b.width, height: b.height }),\n translate: (p, dx, dy) => ({ ...p, x: p.x + dx, y: p.y + dy }),\n intersectsRect: (p, r) => aabbIntersectsRect(p, r),\n lerp: (a, b, t) => ({\n ...a,\n x: a.x + (b.x - a.x) * t,\n y: a.y + (b.y - a.y) * t,\n width: a.width + (b.width - a.width) * t,\n height: a.height + (b.height - a.height) * t,\n }),\n // `Bounds` carries an optional `rotation`, and `withRotation` writes into\n // it — so reading it back has to be the same channel, or a pose reports\n // itself unrotated to `useResize` and to port placement while painting\n // rotated.\n getRotation: (p) => p.rotation ?? 0,\n withRotation: (p, rotation) => ({ ...p, rotation }),\n};\n\n/** Identity geometry for `RotatedPose`. Inherits rect-shape projection\n * from `RECT_POSE_DESCRIPTOR` (the `RotatedPose extends Bounds`\n * subtype lets the rect descriptor's methods apply directly; `remapBounds`\n * preserves the `rotation` field via `...p` spread). Adds `getRotation` so\n * `useResize` knows to take the rotation-aware math path. */\nexport const ROTATED_POSE_DESCRIPTOR: PoseDescriptor<RotatedPose> = {\n getBounds: RECT_POSE_DESCRIPTOR.getBounds as PoseDescriptor<RotatedPose>['getBounds'],\n remapBounds: RECT_POSE_DESCRIPTOR.remapBounds as PoseDescriptor<RotatedPose>['remapBounds'],\n translate: RECT_POSE_DESCRIPTOR.translate as PoseDescriptor<RotatedPose>['translate'],\n intersectsRect: RECT_POSE_DESCRIPTOR.intersectsRect as PoseDescriptor<RotatedPose>['intersectsRect'],\n lerp: RECT_POSE_DESCRIPTOR.lerp as PoseDescriptor<RotatedPose>['lerp'],\n fromBounds: (b) => ({ x: b.x, y: b.y, width: b.width, height: b.height, rotation: 0 }),\n getRotation: (p) => p.rotation,\n withRotation: (p, rotation) => ({ ...p, rotation }),\n};\n\n/**\n * Remap a **rotated** leaf inside a group resize.\n *\n * The naive `remapBounds` scales a leaf's axis-aligned `width`/`height` by the\n * group's per-axis factors and carries `rotation` through untouched. That is\n * right when `src`/`dst` are already expressed in the leaf's own frame — the\n * single-leaf resize path, where the drag delta was projected into that frame\n * before the anchor math ran. In a group resize they are world-frame, so the\n * leaf's local axes do not line up with the axes being scaled: at 90° a\n * horizontal stretch should grow the leaf's `height`, and the naive map grows\n * its `width`.\n *\n * What this computes is the group affine applied to the leaf's local frame,\n * with the shear dropped — the pose model is `{x, y, width, height, rotation}`\n * and cannot represent the parallelogram a non-uniform scale of a rotated box\n * actually produces. The center moves exactly; each local axis takes the\n * length of its own image; the rotation follows the image of the local x-axis.\n *\n * Degenerates to the naive map at `rotation === 0`, and to a plain uniform\n * scale when `sx === sy`, both exactly.\n */\nexport function remapRotatedLeaf<TPose extends RotatedPose>(\n pose: TPose,\n src: Bounds,\n dst: Bounds,\n): TPose {\n const sx = src.width === 0 ? 1 : dst.width / src.width;\n const sy = src.height === 0 ? 1 : dst.height / src.height;\n const theta = pose.rotation ?? 0;\n const cos = Math.cos(theta);\n const sin = Math.sin(theta);\n\n // Images of the leaf's local unit axes under the group's diagonal scale.\n const ux = sx * cos, uy = sy * sin;\n const vx = -sx * sin, vy = sy * cos;\n\n const width = pose.width * Math.hypot(ux, uy);\n const height = pose.height * Math.hypot(vx, vy);\n const rotation = Math.atan2(uy, ux);\n\n // The center is a point, so it takes the group affine directly.\n const cxNew = dst.x + (pose.x + pose.width / 2 - src.x) * sx;\n const cyNew = dst.y + (pose.y + pose.height / 2 - src.y) * sy;\n\n return {\n ...pose,\n x: cxNew - width / 2,\n y: cyNew - height / 2,\n width,\n height,\n rotation,\n };\n}\n\n/** The pose's visual bounds: its frame expanded to cover the rotated\n * rectangle, so a turned shape reports the extent of its ink. */\nexport function visualBoundsViaDescriptor<TPose>(\n pose: TPose,\n geometry: PoseDescriptor<TPose>,\n): Bounds {\n const b = geometry.getBounds(pose);\n const rotation =\n geometry.getRotation?.(pose) ?? (b as { rotation?: number }).rotation ?? 0;\n return axisAlignedBounds({ x: b.x, y: b.y, width: b.width, height: b.height, rotation });\n}\n\n/** Translate through `geometry.translate`, or via `remapBounds` onto a shifted\n * copy of the pose's own bounds when the descriptor has none. */\nexport function translatePoseViaDescriptor<TPose>(\n pose: TPose,\n dx: number,\n dy: number,\n geometry: PoseDescriptor<TPose>,\n): TPose {\n if (geometry.translate) return geometry.translate(pose, dx, dy);\n const src = geometry.getBounds(pose);\n const dst = { x: src.x + dx, y: src.y + dy, width: src.width, height: src.height };\n return geometry.remapBounds(pose, src, dst);\n}\n"],"mappings":";;AAwEA,SAAgBA,EACd,GACA,GAC8B;CAC9B,OAAOC,EAAW,UAAUC,CAAI,KAAKD;AACvC;AAIA,SAAgBE,EAAmB,GAAW,GAAoB;CAChE,OAAOC,EAAE,IAAIC,EAAE,IAA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A,GACA,GACO;CACP,IAAIF,EAAS,WAAW,OAAOA,EAAS,UAAUb,GAAMP,GAAIC,CAAE;CAC9D,IAAMJ,IAAMuB,EAAS,UAAUb,CAAI,GAC7BT,IAAM;EAAE,GAAGD,EAAI,IAAIG;EAAI,GAAGH,EAAI,IAAII;EAAI,OAAOJ,EAAI;EAAO,QAAQA,EAAI;CAAO;CACjF,OAAOuB,EAAS,YAAYb,GAAMV,GAAKC,CAAG;AAC5C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PATH_L as e, PATH_M as t, PATH_Z as n, forEachSegment as r, pathCommandCoordCount as i } from "@weasel-js/geom";
|
|
2
|
+
//#region src/core/geometry/poseRotation.ts
|
|
3
|
+
function a(e) {
|
|
4
|
+
let t = e;
|
|
5
|
+
return t.rotation && t.x != null && t.y != null && t.width != null && t.height != null ? {
|
|
6
|
+
cx: t.x + t.width / 2,
|
|
7
|
+
cy: t.y + t.height / 2,
|
|
8
|
+
rotation: t.rotation
|
|
9
|
+
} : null;
|
|
10
|
+
}
|
|
11
|
+
function o(e, t, n, r) {
|
|
12
|
+
return e.kind === "rect" ? c(e.x, e.y, e.width, e.height, t, n, r) : s(e, t, n, r);
|
|
13
|
+
}
|
|
14
|
+
function s(e, t, n, a) {
|
|
15
|
+
let o = Math.cos(a), s = Math.sin(a), { commands: c, coords: l } = e, u = new Float32Array(l.length);
|
|
16
|
+
return r(c, l, (e, r) => {
|
|
17
|
+
for (let a = 0, c = i(e); a < c; a += 2) {
|
|
18
|
+
let e = l[r + a] - t, i = l[r + a + 1] - n;
|
|
19
|
+
u[r + a] = t + e * o - i * s, u[r + a + 1] = n + e * s + i * o;
|
|
20
|
+
}
|
|
21
|
+
}), {
|
|
22
|
+
kind: "polygon",
|
|
23
|
+
commands: e.commands,
|
|
24
|
+
coords: u,
|
|
25
|
+
fillRule: e.fillRule
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function c(r, i, a, o, s, c, l) {
|
|
29
|
+
let u = Math.cos(l), d = Math.sin(l), f = (e, t) => {
|
|
30
|
+
let n = e - s, r = t - c;
|
|
31
|
+
return [s + n * u - r * d, c + n * d + r * u];
|
|
32
|
+
}, [p, m] = f(r, i), [h, g] = f(r + a, i), [_, v] = f(r + a, i + o), [y, b] = f(r, i + o);
|
|
33
|
+
return {
|
|
34
|
+
kind: "polygon",
|
|
35
|
+
commands: new Uint8Array([
|
|
36
|
+
t,
|
|
37
|
+
e,
|
|
38
|
+
e,
|
|
39
|
+
e,
|
|
40
|
+
n
|
|
41
|
+
]),
|
|
42
|
+
coords: new Float32Array([
|
|
43
|
+
p,
|
|
44
|
+
m,
|
|
45
|
+
h,
|
|
46
|
+
g,
|
|
47
|
+
_,
|
|
48
|
+
v,
|
|
49
|
+
y,
|
|
50
|
+
b
|
|
51
|
+
]),
|
|
52
|
+
fillRule: "nonzero"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { a as poseRotationOf, o as rotatePathAround };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=poseRotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poseRotation.js","names":["poseRotationOf","p","pose","rotatePathAround","path","rotateRectCorners","cx","cy","rotation","rotatePolygon","cos","sin","next","coords","forEachSegment","commands","k","len","pathCommandCoordCount","cmd","dx","ci","dy","rotate","px","py","x0","y0","x","y","x1","y1","w","x2","y2","h","x3","y3","PATH_M","PATH_L","PATH_Z"],"sources":["../../../src/core/geometry/poseRotation.ts"],"sourcesContent":["/**\n * The kit's single encoding of the pose-rotation convention: \"rotate about the\n * pose's unrotated AABB center by `pose.rotation` (radians).\"\n *\n * Every consumer that needs to apply rotation — the render-tree wrap\n * (`canvas/poseRotation.ts`), the world coordinate bake (`pathInWorld`), the\n * silhouette/clip bake (`findShapeSilhouette`), the hit-test inverse\n * (`poseContainsRotated`), and selection chrome — derives its pivot + angle\n * from `poseRotationOf` rather than re-inlining the `if (rotation && x != null\n * …)` gate. If the convention ever changes (different pivot, a transform\n * field, etc.), it changes here.\n *\n * Lives in `core/geometry` so `core/`'s own adapters can bake rotation too.\n */\nimport {\n forEachSegment,\n pathCommandCoordCount,\n PATH_L,\n PATH_M,\n PATH_Z,\n type Path,\n type PolygonPath,\n} from '@weasel-js/geom';\n\n/** Pivot (`cx`, `cy`) and angle resolved from a pose's rotation convention. */\nexport interface PoseRotation {\n cx: number;\n cy: number;\n rotation: number;\n}\n\n/**\n * Resolve a pose's rotation transform, or `null` when the pose carries no\n * effective rotation. Non-null requires a nonzero `rotation` **and** all four\n * AABB fields (`x`, `y`, `width`, `height`) — the pivot is the unrotated AABB\n * center. Poses missing any AABB field (e.g. a bare polygon pose) or with\n * zero/absent rotation return `null`, so callers can treat `null` as \"draw /\n * hit / clip in the local frame, no rotation step.\"\n */\nexport function poseRotationOf(pose: unknown): PoseRotation | null {\n const p = pose as Partial<{ x: number; y: number; width: number; height: number; rotation: number }>;\n if (p.rotation && p.x != null && p.y != null && p.width != null && p.height != null) {\n return { cx: p.x + p.width / 2, cy: p.y + p.height / 2, rotation: p.rotation };\n }\n return null;\n}\n\n/**\n * Rotate every coordinate of `path` about `(cx, cy)` by `rotation` radians.\n * A `rect` promotes to a four-corner polygon (axis-aligned rects can't encode\n * rotation); a polygon keeps its command list and rotates each coord. Returns\n * a fresh `PolygonPath`; never mutates the input. This is the coordinate-baking\n * companion to `poseRotationOf` — `pathInWorld` and `findShapeSilhouette` both\n * apply it so they share one rotation implementation.\n */\nexport function rotatePathAround(path: Path, cx: number, cy: number, rotation: number): PolygonPath {\n if (path.kind === 'rect') {\n return rotateRectCorners(path.x, path.y, path.width, path.height, cx, cy, rotation);\n }\n return rotatePolygon(path, cx, cy, rotation);\n}\n\nfunction rotatePolygon(path: PolygonPath, cx: number, cy: number, rotation: number): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const { commands, coords } = path;\n const next = new Float32Array(coords.length);\n forEachSegment(commands, coords, (cmd, ci) => {\n for (let k = 0, len = pathCommandCoordCount(cmd); k < len; k += 2) {\n const dx = coords[ci + k] - cx;\n const dy = coords[ci + k + 1] - cy;\n next[ci + k] = cx + dx * cos - dy * sin;\n next[ci + k + 1] = cy + dx * sin + dy * cos;\n }\n });\n return { kind: 'polygon', commands: path.commands, coords: next, fillRule: path.fillRule };\n}\n\nfunction rotateRectCorners(\n x: number, y: number, w: number, h: number,\n cx: number, cy: number, rotation: number,\n): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const rotate = (px: number, py: number): [number, number] => {\n const dx = px - cx;\n const dy = py - cy;\n return [cx + dx * cos - dy * sin, cy + dx * sin + dy * cos];\n };\n const [x0, y0] = rotate(x, y);\n const [x1, y1] = rotate(x + w, y);\n const [x2, y2] = rotate(x + w, y + h);\n const [x3, y3] = rotate(x, y + h);\n // M, L, L, L, Z\n const commands = new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]);\n const coords = new Float32Array([x0, y0, x1, y1, x2, y2, x3, y3]);\n return { kind: 'polygon', commands, coords, fillRule: 'nonzero' };\n}\n"],"mappings":";;AAuCA,SAAgBA,EAAe,GAAoC;CACjE,IAAMC,IAAIC;CAIV,OAHID,EAAE,YAAYA,EAAE,KAAK,QAAQA,EAAE,KAAK,QAAQA,EAAE,SAAS,QAAQA,EAAE,UAAU,OACtE;EAAE,IAAIA,EAAE,IAAIA,EAAE,QAAQ;EAAG,IAAIA,EAAE,IAAIA,EAAE,SAAS;EAAG,UAAUA,EAAE;CAAS,IAExE;AACT;AAUA,SAAgBE,EAAiB,GAAY,GAAY,GAAY,GAA+B;CAIlG,OAHIC,EAAK,SAAS,SACTC,EAAkBD,EAAK,GAAGA,EAAK,GAAGA,EAAK,OAAOA,EAAK,QAAQE,GAAIC,GAAIC,CAAQ,IAE7EC,EAAcL,GAAME,GAAIC,GAAIC,CAAQ;AAC7C;AAEA,SAASC,EAAc,GAAmB,GAAY,GAAY,GAA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B,aAAa;GAACd;GAAIC;GAAIG;GAAIC;GAAIE;GAAIC;GAAIE;GAAIC;EAAE,CAC3B;EAAQ,UAAU;CAAU;AAClE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { nodeMemo as e } from "../scene/nodeMemo.js";
|
|
2
|
+
import { poseRotationOf as t, rotatePathAround as n } from "./poseRotation.js";
|
|
3
|
+
import { visualBoundsViaDescriptor as r } from "./poseDescriptor.js";
|
|
4
|
+
import { boxContainsBox as i, pointInPolygon as a, polygonContainsPath as o, polygonIntersectsPath as s } from "@weasel-js/geom";
|
|
5
|
+
//#region src/core/geometry/regionHit.ts
|
|
6
|
+
function c(e) {
|
|
7
|
+
let { x: t, y: n, width: r, height: i } = e;
|
|
8
|
+
return l([
|
|
9
|
+
t,
|
|
10
|
+
n,
|
|
11
|
+
t + r,
|
|
12
|
+
n,
|
|
13
|
+
t + r,
|
|
14
|
+
n + i,
|
|
15
|
+
t,
|
|
16
|
+
n + i
|
|
17
|
+
], {
|
|
18
|
+
x: t,
|
|
19
|
+
y: n,
|
|
20
|
+
width: r,
|
|
21
|
+
height: i
|
|
22
|
+
}, !0);
|
|
23
|
+
}
|
|
24
|
+
function l(e, t, n = !1) {
|
|
25
|
+
let r = [], i = [], a = Infinity, o = Infinity, s = -Infinity, c = -Infinity;
|
|
26
|
+
for (let t = 0; t + 1 < e.length; t += 2) {
|
|
27
|
+
let n = e[t], l = e[t + 1];
|
|
28
|
+
r.push({
|
|
29
|
+
x: n,
|
|
30
|
+
y: l
|
|
31
|
+
}), i.push(n, l), n < a && (a = n), l < o && (o = l), n > s && (s = n), l > c && (c = l);
|
|
32
|
+
}
|
|
33
|
+
return r.length === 0 ? null : {
|
|
34
|
+
verts: r,
|
|
35
|
+
coords: i,
|
|
36
|
+
bounds: t ?? {
|
|
37
|
+
x: a,
|
|
38
|
+
y: o,
|
|
39
|
+
width: s - a,
|
|
40
|
+
height: c - o
|
|
41
|
+
},
|
|
42
|
+
isRect: n
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function u(e) {
|
|
46
|
+
if (e.length < 3) return null;
|
|
47
|
+
let t = [];
|
|
48
|
+
for (let n of e) t.push(n.x, n.y);
|
|
49
|
+
return l(t);
|
|
50
|
+
}
|
|
51
|
+
function d(e) {
|
|
52
|
+
return typeof e == "object" && !!e && e.kind === "polygon";
|
|
53
|
+
}
|
|
54
|
+
function f(t, n, i) {
|
|
55
|
+
return d(n) ? e(t, "aabb", n, () => i.getBounds(n)) : r(n, i);
|
|
56
|
+
}
|
|
57
|
+
function p(e, r) {
|
|
58
|
+
let i = t(e);
|
|
59
|
+
if (i) {
|
|
60
|
+
let t = e;
|
|
61
|
+
return n({
|
|
62
|
+
kind: "rect",
|
|
63
|
+
x: t.x,
|
|
64
|
+
y: t.y,
|
|
65
|
+
width: t.width,
|
|
66
|
+
height: t.height
|
|
67
|
+
}, i.cx, i.cy, i.rotation);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
kind: "rect",
|
|
71
|
+
x: r.x,
|
|
72
|
+
y: r.y,
|
|
73
|
+
width: r.width,
|
|
74
|
+
height: r.height
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function m(e, t, n, r, c) {
|
|
78
|
+
if (!Number.isFinite(r.x) || !Number.isFinite(r.y) || !Number.isFinite(r.width) || !Number.isFinite(r.height)) return !1;
|
|
79
|
+
let l = e.bounds;
|
|
80
|
+
if (r.x >= l.x + l.width || r.x + r.width <= l.x || r.y >= l.y + l.height || r.y + r.height <= l.y) return !1;
|
|
81
|
+
if (t === "centers") return a(e.coords, r.x + r.width / 2, r.y + r.height / 2);
|
|
82
|
+
let u = i([
|
|
83
|
+
l.x,
|
|
84
|
+
l.y,
|
|
85
|
+
l.x + l.width,
|
|
86
|
+
l.y + l.height
|
|
87
|
+
], [
|
|
88
|
+
r.x,
|
|
89
|
+
r.y,
|
|
90
|
+
r.x + r.width,
|
|
91
|
+
r.y + r.height
|
|
92
|
+
]), f = d(n);
|
|
93
|
+
if (t === "enclosed") return u ? o(e.verts, f ? n : c()) : !1;
|
|
94
|
+
if (e.isRect && u) return !0;
|
|
95
|
+
if (f) return s(e.verts, n);
|
|
96
|
+
let p = c();
|
|
97
|
+
return p.kind === "rect" && e.isRect ? !0 : s(e.verts, p);
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { d as isSilhouettePose, u as polygonRegion, p as poseOutline, c as rectRegion, f as regionBoundsOf, l as regionOf, m as regionTakes };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=regionHit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regionHit.js","names":["rectRegion","w","h","r","regionOf","x","y","verts","flat","minX","minY","maxX","maxY","i","coords","bounds","polygonRegion","polygon","p","isSilhouettePose","pose","regionBoundsOf","nodeMemo","node","g","visualBoundsViaDescriptor","poseOutline","poseRotationOf","rotatePathAround","b","regionTakes","ab","region","mode","pointInPolygon","inBox","boxContainsBox","silhouette","polygonContainsPath","outline","polygonIntersectsPath","drawn"],"sources":["../../../src/core/geometry/regionHit.ts"],"sourcesContent":["/**\n * Whether a marquee or a lasso takes one node: the per-node decision shared by\n * `sceneToAdapter` (through `canvas/deps/hitTestArea`) and `arrayAdapter`.\n *\n * What a node draws is not knowable here — the painters sit above `core/` — so\n * the caller hands in the node's outline as a thunk, asked for only when the\n * bounds cannot decide. A pose that is itself a polygon path is its own\n * outline and never asks.\n */\nimport {\n boxContainsBox,\n pointInPolygon,\n polygonContainsPath,\n polygonIntersectsPath,\n type Path,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport type { LassoHitMode } from 'core/adapters/types';\nimport { nodeMemo } from 'core/scene/nodeMemo';\nimport type { Vec2 } from './vec2';\nimport { poseRotationOf, rotatePathAround } from './poseRotation';\nimport { visualBoundsViaDescriptor, type PoseDescriptor } from './poseDescriptor';\n\n/** A closed selection area: a marquee rect or a lasso polygon. */\nexport interface SelectRegion {\n /** The area's vertices; the closing edge back to the first is implicit. */\n readonly verts: readonly Vec2[];\n /** `verts` interleaved as `[x0, y0, x1, y1, …]`. */\n readonly coords: readonly number[];\n readonly bounds: Bounds;\n /** True when the area is its own bounding rect, so a node inside `bounds`\n * is inside the area without further work. Never true for a lasso: a node\n * inside the hull's box can still miss the hull. */\n readonly isRect: boolean;\n}\n\n/** A marquee's region. */\nexport function rectRegion(r: Bounds): SelectRegion {\n const { x, y, width: w, height: h } = r;\n return regionOf([x, y, x + w, y, x + w, y + h, x, y + h], { x, y, width: w, height: h }, true)!;\n}\n\n/** A region from interleaved coords. `bounds` is derived when omitted; `null`\n * when there are no coords to bound. */\nexport function regionOf(\n coords: ArrayLike<number>,\n bounds?: Bounds,\n isRect = false,\n): SelectRegion | null {\n const verts: Vec2[] = [];\n const flat: number[] = [];\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (let i = 0; i + 1 < coords.length; i += 2) {\n const x = coords[i], y = coords[i + 1];\n verts.push({ x, y });\n flat.push(x, y);\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n if (verts.length === 0) return null;\n return {\n verts,\n coords: flat,\n bounds: bounds ?? { x: minX, y: minY, width: maxX - minX, height: maxY - minY },\n isRect,\n };\n}\n\n/** A lasso's region, or `null` for fewer than three vertices. */\nexport function polygonRegion(polygon: ReadonlyArray<Vec2>): SelectRegion | null {\n if (polygon.length < 3) return null;\n const coords: number[] = [];\n for (const p of polygon) coords.push(p.x, p.y);\n return regionOf(coords);\n}\n\n/** A pose that is its own drawn outline. */\nexport function isSilhouettePose(pose: unknown): pose is PolygonPath {\n return pose !== null && typeof pose === 'object' && (pose as Path).kind === 'polygon';\n}\n\n/**\n * The box a region fast-rejects a node against: a silhouette pose's own bounds,\n * else the pose's visual bounds — which for a rotated pose is the box of its\n * rotated ink, reaching past the pose box. `g` is the node's descriptor.\n */\nexport function regionBoundsOf(node: object, pose: unknown, g: PoseDescriptor<unknown>): Bounds {\n // Memo is silhouettes-only: a rect pose's bounds are the pose itself, and\n // memoizing it costs more than it saves. The result may be shared; never mutate it.\n return isSilhouettePose(pose)\n ? nodeMemo(node, 'aabb', pose, () => g.getBounds(pose))\n : visualBoundsViaDescriptor(pose, g);\n}\n\n/** The outline of a node nothing paints: its pose rect, turned by the pose's\n * rotation, else its visual bounds `b`. */\nexport function poseOutline(pose: unknown, b: Bounds): Path {\n const r = poseRotationOf(pose);\n if (r) {\n const p = pose as Bounds;\n return rotatePathAround(\n { kind: 'rect', x: p.x, y: p.y, width: p.width, height: p.height },\n r.cx, r.cy, r.rotation,\n );\n }\n return { kind: 'rect', x: b.x, y: b.y, width: b.width, height: b.height };\n}\n\n/**\n * Whether `region` takes a node under `mode`, given its pose, its bounds `b`\n * from {@link regionBoundsOf}, and its drawn outline on demand.\n *\n * - `intersect` — the outline meets the region anywhere.\n * - `enclosed` — the whole outline lies inside it.\n * - `centers` — the center of `b` lies inside it.\n *\n * A node without finite bounds is never taken.\n */\nexport function regionTakes(\n region: SelectRegion,\n mode: LassoHitMode,\n pose: unknown,\n b: Bounds,\n outline: () => Path,\n): boolean {\n if (\n !Number.isFinite(b.x) || !Number.isFinite(b.y) ||\n !Number.isFinite(b.width) || !Number.isFinite(b.height)\n ) {\n return false;\n }\n const ab = region.bounds;\n if (\n b.x >= ab.x + ab.width || b.x + b.width <= ab.x ||\n b.y >= ab.y + ab.height || b.y + b.height <= ab.y\n ) {\n return false;\n }\n if (mode === 'centers') {\n return pointInPolygon(region.coords, b.x + b.width / 2, b.y + b.height / 2);\n }\n const inBox = boxContainsBox(\n [ab.x, ab.y, ab.x + ab.width, ab.y + ab.height],\n [b.x, b.y, b.x + b.width, b.y + b.height],\n );\n const silhouette = isSilhouettePose(pose);\n if (mode === 'enclosed') {\n // A node sticking out of the region's box cannot be inside the region.\n if (!inBox) return false;\n return polygonContainsPath(region.verts, silhouette ? pose : outline());\n }\n // Swallowed whole by a marquee: no outline can change the answer.\n if (region.isRect && inBox) return true;\n if (silhouette) return polygonIntersectsPath(region.verts, pose);\n const drawn = outline();\n // An axis-aligned rect overlapping a marquee's box already meets it.\n if (drawn.kind === 'rect' && region.isRect) return true;\n return polygonIntersectsPath(region.verts, drawn);\n}\n"],"mappings":";;;;;AAsCA,SAAgBA,EAAW,GAAyB;CAClD,IAAM,EAAE,MAAG,MAAG,OAAOC,GAAG,QAAQC,MAAMC;CACtC,OAAOC,EAAS;EAACC;EAAGC;EAAGD,IAAIJ;EAAGK;EAAGD,IAAIJ;EAAGK,IAAIJ;EAAGG;EAAGC,IAAIJ;CAAC,GAAG;EAAE;EAAG;EAAG,OAAOD;EAAG,QAAQC;CAAE,GAAG,EAAI;AAC/F;AAIA,SAAgBE,EACd,GACA,GACA,IAAS,IACY;CACrB,IAAMG,IAAgB,CAAC,GACjBC,IAAiB,CAAC,GACpBC,IAAO,UAAUC,IAAO,UAAUC,IAAO,WAAWC,IAAO;CAC/D,KAAK,IAAIC,IAAI,GAAGA,IAAI,IAAIC,EAAO,QAAQ,KAAK,GAAG;EAC7C,IAAMT,IAAIS,EAAOD,IAAIP,IAAIQ,EAAOD,IAAI;EAMpC,AALAN,EAAM,KAAK;GAAE;GAAG;EAAE,CAAC,GACnBC,EAAK,KAAKH,GAAGC,CAAC,GACVD,IAAII,MAAM,IAAOJ,IACjBC,IAAII,MAAM,IAAOJ,IACjBD,IAAIM,MAAM,IAAON,IACjBC,IAAIM,MAAM,IAAON;CACvB;CAEA,OADIC,EAAM,WAAW,IAAU,OACxB;EACL;EACA,QAAQC;EACR,QAAQO,KAAU;GAAE,GAAGN;GAAM,GAAGC;GAAM,OAAOC,IAAOF;GAAM,QAAQG,IAAOF;EAAK;EAC9E;CACF;AACF;AAGA,SAAgBM,EAAc,GAAmD;CAC/E,IAAIC,EAAQ,SAAS,GAAG,OAAO;CAC/B,IAAMH,IAAmB,CAAC;CAC1B,KAAK,IAAMI,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A,EAAE,SAAS,CAAC;CAE5E,IAAMM,IAAQC,EACZ;EAACL,EAAG;EAAGA,EAAG;EAAGA,EAAG,IAAIA,EAAG;EAAOA,EAAG,IAAIA,EAAG;CAAM,GAC9C;EAACF,EAAE;EAAGA,EAAE;EAAGA,EAAE,IAAIA,EAAE;EAAOA,EAAE,IAAIA,EAAE;CAAM,CAC1C,GACMQ,IAAalB,EAAiBC,CAAI;CACxC,IAAIa,MAAS,YAGX,OADKE,IACEG,EAAoBN,EAAO,OAAOK,IAAajB,IAAOmB,EAAQ,CAAC,IADnD;CAIrB,IAAIP,EAAO,UAAUG,GAAO,OAAO;CACnC,IAAIE,GAAY,OAAOG,EAAsBR,EAAO,OAAOZ,CAAI;CAC/D,IAAMqB,IAAQF,EAAQ;CAGtB,OADIE,EAAM,SAAS,UAAUT,EAAO,SAAe,KAC5CQ,EAAsBR,EAAO,OAAOS,CAAK;AAClD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/core/geometry/unionBounds.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity, a = !1;
|
|
4
|
+
for (let o of e) {
|
|
5
|
+
a = !0, o.x < t && (t = o.x), o.y < n && (n = o.y);
|
|
6
|
+
let e = o.x + o.width, s = o.y + o.height;
|
|
7
|
+
e > r && (r = e), s > i && (i = s);
|
|
8
|
+
}
|
|
9
|
+
return a ? {
|
|
10
|
+
x: t,
|
|
11
|
+
y: n,
|
|
12
|
+
width: r - t,
|
|
13
|
+
height: i - n
|
|
14
|
+
} : null;
|
|
15
|
+
}
|
|
16
|
+
function t(e) {
|
|
17
|
+
let t = e.rotation;
|
|
18
|
+
if (!t) return {
|
|
19
|
+
x: e.x,
|
|
20
|
+
y: e.y,
|
|
21
|
+
width: e.width,
|
|
22
|
+
height: e.height
|
|
23
|
+
};
|
|
24
|
+
let n = Math.cos(t), r = Math.sin(t), i = e.x + e.width / 2, a = e.y + e.height / 2, o = Infinity, s = Infinity, c = -Infinity, l = -Infinity, u = [
|
|
25
|
+
[e.x, e.y],
|
|
26
|
+
[e.x + e.width, e.y],
|
|
27
|
+
[e.x + e.width, e.y + e.height],
|
|
28
|
+
[e.x, e.y + e.height]
|
|
29
|
+
];
|
|
30
|
+
for (let [e, t] of u) {
|
|
31
|
+
let u = e - i, d = t - a, f = i + u * n - d * r, p = a + u * r + d * n;
|
|
32
|
+
f < o && (o = f), f > c && (c = f), p < s && (s = p), p > l && (l = p);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
x: o,
|
|
36
|
+
y: s,
|
|
37
|
+
width: c - o,
|
|
38
|
+
height: l - s
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function n(e) {
|
|
42
|
+
let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity, o = !1;
|
|
43
|
+
for (let s of e) {
|
|
44
|
+
if (!s) continue;
|
|
45
|
+
let e = t(s);
|
|
46
|
+
o = !0, e.x < n && (n = e.x), e.y < r && (r = e.y);
|
|
47
|
+
let c = e.x + e.width, l = e.y + e.height;
|
|
48
|
+
c > i && (i = c), l > a && (a = l);
|
|
49
|
+
}
|
|
50
|
+
return o ? {
|
|
51
|
+
x: n,
|
|
52
|
+
y: r,
|
|
53
|
+
width: i - n,
|
|
54
|
+
height: a - r
|
|
55
|
+
} : null;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { t as axisAlignedBounds, n as unionAABB, e as unionBounds };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=unionBounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unionBounds.js","names":["unionBounds","minX","minY","maxX","maxY","any","p","poses","right","bottom","axisAlignedBounds","rotation","b","cos","sin","cx","cy","corners","px","py","dx","dy","rx","ry","unionAABB","part","parts"],"sources":["../../../src/core/geometry/unionBounds.ts"],"sourcesContent":["/**\n * Union math over rect-shaped poses.\n *\n * Two answers, deliberately distinct. `unionBounds` folds the *unrotated*\n * boxes and is what commit-time actions want, because they go on to write\n * poses back in that same frame. `unionAABB` expands each rotated member to\n * the extent of its ink first, and is what anything a user looks at or clicks\n * wants — selection chrome, gesture bounds, an export viewBox. Folding the\n * unrotated box there under-reports the extent of a rotated member exactly\n * when the consumer is watching it move.\n */\n\nimport type { RectPose } from 'core/scene/types';\nexport type { RectPose };\n\n/** Compute the AABB envelope of a set of rect-shaped poses, ignoring any\n * rotation they carry. See the module docstring before reaching for this\n * over {@link unionAABB}. */\nexport function unionBounds<TPose extends RectPose>(poses: Iterable<TPose>): RectPose | null {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let any = false;\n for (const p of poses) {\n any = true;\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n const right = p.x + p.width;\n const bottom = p.y + p.height;\n if (right > maxX) maxX = right;\n if (bottom > maxY) maxY = bottom;\n }\n if (!any) return null;\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Axis-align a pose that carries a `rotation`: returns the AABB of the\n * rotated rectangle, with `rotation` dropped. Follows the kit's rotation\n * convention (`poseRotationOf`): rotate about the unrotated AABB center.\n *\n * Unrotated input is returned as-is.\n */\nexport function axisAlignedBounds<TPose extends RectPose>(b: TPose): RectPose {\n const rotation = b.rotation;\n if (!rotation) {\n // Strip an explicit `rotation: 0` so callers can rely on the absence of\n // the field meaning \"axis-aligned\".\n return { x: b.x, y: b.y, width: b.width, height: b.height };\n }\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const cx = b.x + b.width / 2;\n const cy = b.y + b.height / 2;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n const corners: ReadonlyArray<readonly [number, number]> = [\n [b.x, b.y],\n [b.x + b.width, b.y],\n [b.x + b.width, b.y + b.height],\n [b.x, b.y + b.height],\n ];\n for (const [px, py] of corners) {\n const dx = px - cx;\n const dy = py - cy;\n const rx = cx + dx * cos - dy * sin;\n const ry = cy + dx * sin + dy * cos;\n if (rx < minX) minX = rx;\n if (rx > maxX) maxX = rx;\n if (ry < minY) minY = ry;\n if (ry > maxY) maxY = ry;\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Fold every part into one world-space AABB, skipping `null` / `undefined`\n * entries. Rotated parts are expanded via {@link axisAlignedBounds} first;\n * the result never carries a `rotation` (a union of several oriented boxes\n * has no single orientation to report).\n *\n * Returns `null` when nothing was contributed.\n */\nexport function unionAABB<TPose extends RectPose>(\n parts: Iterable<TPose | null | undefined>,\n): RectPose | null {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let any = false;\n for (const part of parts) {\n if (!part) continue;\n const b = axisAlignedBounds(part);\n any = true;\n if (b.x < minX) minX = b.x;\n if (b.y < minY) minY = b.y;\n const right = b.x + b.width;\n const bottom = b.y + b.height;\n if (right > maxX) maxX = right;\n if (bottom > maxY) maxY = bottom;\n }\n if (!any) return null;\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n"],"mappings":";AAkBA,SAAgBA,EAAoC,GAAyC;CAC3F,IAAIC,IAAO,UACPC,IAAO,UACPC,IAAO,WACPC,IAAO,WACPC,IAAM;CACV,KAAK,IAAMC,KAAKC,GAAO;EAGrB,AAFA,IAAM,IACFD,EAAE,IAAIL,MAAM,IAAOK,EAAE,IACrBA,EAAE,IAAIJ,MAAM,IAAOI,EAAE;EACzB,IAAME,IAAQF,EAAE,IAAIA,EAAE,OAChBG,IAASH,EAAE,IAAIA,EAAE;EAEvB,AADIE,IAAQL,MAAM,IAAOK,IACrBC,IAASL,MAAM,IAAOK;CAC5B;CAEA,OADKJ,IACE;EAAE,GAAGJ;EAAM,GAAGC;EAAM,OAAOC,IAAOF;EAAM,QAAQG,IAAOF;CAAK,IADlD;AAEnB;AASA,SAAgBQ,EAA0C,GAAoB;CAC5E,IAAMC,IAAWC,E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