@weasel-js/core 1.11.1 → 1.13.0-rc.0
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 +275 -0
- package/dist/WeaselProvider.js +1 -1
- package/dist/affordances/pathAnchors.js +10 -6
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/animation/poseTarget.js +46 -15
- package/dist/animation/poseTarget.js.map +1 -1
- package/dist/animation/poseTransition.js +3 -3
- package/dist/animation/poseTransition.js.map +1 -1
- package/dist/animation/reflow.js +3 -6
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/rig/bindRig.js +2 -2
- package/dist/animation/rig/bindRig.js.map +1 -1
- package/dist/animation/rig/skinBinding.js +2 -2
- package/dist/animation/rig/skinBinding.js.map +1 -1
- package/dist/barrel/canvas.js +5 -1
- package/dist/barrel/chrome.js +3 -1
- package/dist/barrel/paint.js +4 -4
- package/dist/barrel/paths.js +9 -4
- package/dist/barrel/renderer.js +3 -2
- package/dist/barrel/routing.js +4 -4
- package/dist/barrel/scene.js +7 -1
- package/dist/barrel/text.js +2 -2
- package/dist/barrel/viewport.js +6 -2
- package/dist/canvas/Canvas.js +2 -1
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +23 -34
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/ModalityHud.js +1 -1
- package/dist/canvas/NodeShape.js +5 -1
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +1 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js +2 -0
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
- package/dist/canvas/SceneCanvas/SurfaceDeclarations.js +23 -0
- package/dist/canvas/SceneCanvas/SurfaceDeclarations.js.map +1 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js +2 -1
- package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +2 -2
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/scenePointQuery.js +27 -5
- package/dist/canvas/SceneCanvas/scenePointQuery.js.map +1 -1
- package/dist/canvas/SceneCanvas/useActionTunings.js +6 -1
- package/dist/canvas/SceneCanvas/useActionTunings.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js +1 -0
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasTools.js +10 -2
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +25 -19
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js +9 -3
- package/dist/canvas/SceneCanvas/useSceneCanvasHandle.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +17 -2
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +2 -0
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +19 -4
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useScenePicking.js +31 -6
- package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +4 -5
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +7 -4
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +30 -12
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/ViewMarker.js +35 -0
- package/dist/canvas/ViewMarker.js.map +1 -0
- package/dist/canvas/accentColor.js +26 -3
- package/dist/canvas/accentColor.js.map +1 -1
- package/dist/canvas/buildSceneTree.js +14 -20
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/copiesAbove.js +1 -1
- package/dist/canvas/copiesAbove.js.map +1 -1
- package/dist/canvas/defaultDrawOne.js +11 -6
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/areaSelect.js +5 -2
- package/dist/canvas/deps/areaSelect.js.map +1 -1
- package/dist/canvas/deps/booleans.js +3 -2
- package/dist/canvas/deps/booleans.js.map +1 -1
- package/dist/canvas/deps/enteredGroup.js +81 -0
- package/dist/canvas/deps/enteredGroup.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +28 -16
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +10 -38
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/insertSite.js +39 -0
- package/dist/canvas/deps/insertSite.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +6 -3
- package/dist/canvas/deps/lassoSelect.js.map +1 -1
- package/dist/canvas/deps/pathEditCommits.js +3 -7
- package/dist/canvas/deps/pathEditCommits.js.map +1 -1
- package/dist/canvas/deps/pathLeaf.js +1 -1
- package/dist/canvas/deps/pathLeaf.js.map +1 -1
- package/dist/canvas/deps/slice.js +2 -1
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/derivedPath.js +14 -6
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/doubleClickTarget.js +9 -11
- package/dist/canvas/doubleClickTarget.js.map +1 -1
- package/dist/canvas/drawnBounds.js +26 -9
- package/dist/canvas/drawnBounds.js.map +1 -1
- package/dist/canvas/inheritedPaints.js +55 -0
- package/dist/canvas/inheritedPaints.js.map +1 -0
- package/dist/canvas/nodeShapes/derivedPainter.js +15 -16
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/nodePaint.js +7 -34
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -1
- package/dist/canvas/nodeShapes/pathPainter.js +7 -7
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/rectFallbackPainter.js +4 -5
- package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/shapePainter.js +9 -9
- package/dist/canvas/nodeShapes/shapePainter.js.map +1 -1
- package/dist/canvas/nodeShapes/textPainter.js +13 -12
- package/dist/canvas/nodeShapes/textPainter.js.map +1 -1
- package/dist/canvas/ownClip.js +24 -0
- package/dist/canvas/ownClip.js.map +1 -0
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/canvas/pickIndex/nodeBroadBox.js +86 -0
- package/dist/canvas/pickIndex/nodeBroadBox.js.map +1 -0
- package/dist/canvas/pickIndex/scenePickIndex.js +208 -0
- package/dist/canvas/pickIndex/scenePickIndex.js.map +1 -0
- package/dist/canvas/pickReach.js +3 -3
- package/dist/canvas/pickReach.js.map +1 -1
- package/dist/canvas/pickWalk.js +17 -91
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/poseCascade.js +1 -1
- package/dist/canvas/poseCascade.js.map +1 -1
- package/dist/canvas/publishPreviews.js +97 -0
- package/dist/canvas/publishPreviews.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +1 -1
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +7 -5
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +17 -10
- package/dist/canvas/sceneClipboard.js.map +1 -1
- package/dist/canvas/scenePickReads.js +37 -0
- package/dist/canvas/scenePickReads.js.map +1 -0
- package/dist/canvas/scenePickSource.js +74 -0
- package/dist/canvas/scenePickSource.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +9 -3
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +9 -4
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/shownNodes.js +15 -0
- package/dist/canvas/shownNodes.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +12 -8
- package/dist/canvas/surfaceContribution.js.map +1 -1
- package/dist/canvas/useCanvasView.js +4 -2
- package/dist/canvas/useCanvasView.js.map +1 -1
- package/dist/canvas/useLayerStack.js +6 -2
- package/dist/canvas/useLayerStack.js.map +1 -1
- package/dist/canvas/useSceneAdapter.js +5 -3
- package/dist/canvas/useSceneAdapter.js.map +1 -1
- package/dist/canvas/useViewAim.js +121 -0
- package/dist/canvas/useViewAim.js.map +1 -0
- package/dist/canvas/useViewNesting.js +3 -2
- package/dist/canvas/useViewNesting.js.map +1 -1
- package/dist/canvas/useViewRegistrySurface.js +4 -2
- package/dist/canvas/useViewRegistrySurface.js.map +1 -1
- package/dist/canvas/viewMarkers.js +63 -0
- package/dist/canvas/viewMarkers.js.map +1 -0
- package/dist/canvas/viewRegistry.js +27 -1
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/clipboard.d.ts +2 -2
- package/dist/{clone-C3e0OTuF.d.ts → clone-qb2e1F5p.d.ts} +2 -2
- package/dist/clone.d.ts +3 -3
- package/dist/core/isPlainObject.js +2 -2
- package/dist/core/layers/layerGroup.js.map +1 -1
- package/dist/core/pages/pageEdits.js +2 -3
- package/dist/core/pages/pageEdits.js.map +1 -1
- package/dist/core/paint/meshKindLazy.js +59 -2
- package/dist/core/paint/meshKindLazy.js.map +1 -1
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/arrivalWindow.js +1 -1
- package/dist/core/scene/arrivalWindow.js.map +1 -1
- package/dist/core/scene/clipNothing.js +10 -0
- package/dist/core/scene/clipNothing.js.map +1 -0
- package/dist/core/scene/declaredFieldSetters.js +44 -0
- package/dist/core/scene/declaredFieldSetters.js.map +1 -0
- package/dist/core/scene/depMemo.js +14 -3
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/dependents.js +9 -1
- package/dist/core/scene/dependents.js.map +1 -1
- package/dist/core/scene/derivedParts.js +10 -11
- package/dist/core/scene/derivedParts.js.map +1 -1
- package/dist/core/scene/documentOf.js +43 -0
- package/dist/core/scene/documentOf.js.map +1 -0
- package/dist/core/scene/effectivePose.js +44 -15
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +17 -14
- package/dist/core/scene/fieldEdits.js.map +1 -1
- package/dist/core/scene/fontReads.js +37 -0
- package/dist/core/scene/fontReads.js.map +1 -0
- package/dist/core/scene/historyForm.js +4 -4
- package/dist/core/scene/historyForm.js.map +1 -1
- package/dist/core/scene/inheritedPaint.js +97 -0
- package/dist/core/scene/inheritedPaint.js.map +1 -0
- package/dist/core/scene/kitOps.js +3 -23
- package/dist/core/scene/kitOps.js.map +1 -1
- package/dist/core/scene/kitRegistry.js +5 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layoutPass.js +1 -2
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/nodeAsShown.js +72 -0
- package/dist/core/scene/nodeAsShown.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +2 -10
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +21 -8
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/nodeStore.js +2 -4
- package/dist/core/scene/nodeStore.js.map +1 -1
- package/dist/core/scene/pathEffects/blend.js.map +1 -1
- package/dist/core/scene/pathEffects/derive.js +10 -4
- package/dist/core/scene/pathEffects/derive.js.map +1 -1
- package/dist/core/scene/pathEffects/effects.js +3 -1
- package/dist/core/scene/pathEffects/effects.js.map +1 -1
- package/dist/core/scene/pathEffects/foundHidden.js +35 -0
- package/dist/core/scene/pathEffects/foundHidden.js.map +1 -0
- package/dist/core/scene/pathEffects/textAlong.js +95 -0
- package/dist/core/scene/pathEffects/textAlong.js.map +1 -0
- package/dist/core/scene/plyStacks.js +89 -0
- package/dist/core/scene/plyStacks.js.map +1 -0
- package/dist/core/scene/poseHold.js +42 -24
- package/dist/core/scene/poseHold.js.map +1 -1
- package/dist/core/scene/poseOverrides.js +35 -38
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/posePlies.js +59 -0
- package/dist/core/scene/posePlies.js.map +1 -0
- package/dist/core/scene/reconcileSpecs.js +6 -15
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/renderOrder.js +10 -4
- package/dist/core/scene/renderOrder.js.map +1 -1
- package/dist/core/scene/sameValue.js +17 -0
- package/dist/core/scene/sameValue.js.map +1 -0
- package/dist/core/scene/scene.js +3 -3
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneEdits.js +8 -0
- package/dist/core/scene/sceneEdits.js.map +1 -1
- package/dist/core/scene/sceneState.js +1 -2
- package/dist/core/scene/sceneState.js.map +1 -1
- package/dist/core/scene/serialization.js +45 -9
- package/dist/core/scene/serialization.js.map +1 -1
- package/dist/core/scene/staleReplay.js +5 -2
- package/dist/core/scene/staleReplay.js.map +1 -1
- package/dist/core/scene/statedFields.js +4 -2
- package/dist/core/scene/statedFields.js.map +1 -1
- package/dist/core/scene/treeEdits.js +2 -4
- package/dist/core/scene/treeEdits.js.map +1 -1
- package/dist/core/scene/treeOrder.js +3 -1
- package/dist/core/scene/treeOrder.js.map +1 -1
- package/dist/core/scene/treeReads.js +1 -2
- package/dist/core/scene/treeReads.js.map +1 -1
- package/dist/core/scene/treeShape.js +13 -0
- package/dist/core/scene/treeShape.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/useScene.js +1 -1
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/{cornerHandles-BHuoMs1o.d.ts → cornerHandles-CNCb7aTY.d.ts} +3 -2
- package/dist/{depSchema-BpZNOv7q.d.ts → depSchema-B1RS-IJx.d.ts} +39 -18
- package/dist/devtools/handlers.js +1 -1
- package/dist/devtools/handlers.js.map +1 -1
- package/dist/devtools/protocol.js.map +1 -1
- package/dist/devtools/registry.js +4 -4
- package/dist/devtools/registry.js.map +1 -1
- package/dist/devtools-protocol.d.ts +4 -3
- package/dist/devtools.d.ts +3 -2
- package/dist/features/measure/measureContribution.js +4 -2
- package/dist/features/measure/measureContribution.js.map +1 -1
- package/dist/features/measure/measureHit.js +5 -3
- package/dist/features/measure/measureHit.js.map +1 -1
- package/dist/features/measure/measurement.js +1 -1
- package/dist/features/measure/measurement.js.map +1 -1
- package/dist/features/modes/modeLayers.js +14 -7
- package/dist/features/modes/modeLayers.js.map +1 -1
- package/dist/features/modes/modeTriggers.js +10 -6
- package/dist/features/modes/modeTriggers.js.map +1 -1
- package/dist/features/pathEffects/effectSources.js +69 -0
- package/dist/features/pathEffects/effectSources.js.map +1 -0
- package/dist/features/pathEffects/readSource.js +18 -2
- package/dist/features/pathEffects/readSource.js.map +1 -1
- package/dist/features/pathEffects/textItems.js +53 -0
- package/dist/features/pathEffects/textItems.js.map +1 -0
- package/dist/features/pathEffects/useEffectSourcesLayer.js +53 -0
- package/dist/features/pathEffects/useEffectSourcesLayer.js.map +1 -0
- package/dist/features/paths/editablePath.js +1 -1
- package/dist/features/paths/editablePath.js.map +1 -1
- package/dist/features/paths/pathEditState.js +5 -2
- package/dist/features/paths/pathEditState.js.map +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js.map +1 -1
- package/dist/features/selection/enteredGroupFrame.js +65 -0
- package/dist/features/selection/enteredGroupFrame.js.map +1 -0
- package/dist/features/selection/enteredGroupScope.js +44 -0
- package/dist/features/selection/enteredGroupScope.js.map +1 -0
- package/dist/features/text/sceneTextDrafts.js +64 -0
- package/dist/features/text/sceneTextDrafts.js.map +1 -0
- package/dist/features/text/textHitAt.js +34 -3
- package/dist/features/text/textHitAt.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +23 -19
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/viewports/aim.js +105 -0
- package/dist/features/viewports/aim.js.map +1 -0
- package/dist/features/viewports/viewMarker.js +82 -0
- package/dist/features/viewports/viewMarker.js.map +1 -0
- package/dist/features/viewports/viewMarkerDrag.js +55 -0
- package/dist/features/viewports/viewMarkerDrag.js.map +1 -0
- package/dist/index.d.ts +709 -258
- package/dist/index.js +33 -12
- package/dist/interactions/actions/admitsChild.js +11 -0
- package/dist/interactions/actions/admitsChild.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +2 -1
- package/dist/interactions/actions/booleans/booleans.js.map +1 -1
- package/dist/interactions/actions/booleans/operands.js +6 -5
- package/dist/interactions/actions/booleans/operands.js.map +1 -1
- package/dist/interactions/actions/clipboard/action.js +27 -17
- package/dist/interactions/actions/clipboard/action.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +44 -23
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorJoin.js +12 -6
- package/dist/interactions/actions/defaults/anchorJoin.js.map +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js +7 -4
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
- package/dist/interactions/actions/defaults/cancelGesture.js +11 -8
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
- package/dist/interactions/actions/defaults/contextMenu.js +33 -11
- package/dist/interactions/actions/defaults/contextMenu.js.map +1 -1
- package/dist/interactions/actions/defaults/createPaintAction.js +5 -2
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js +28 -14
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +11 -8
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterGroup.js +88 -0
- package/dist/interactions/actions/defaults/enterGroup.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +20 -10
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js +1 -1
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/escape.js +11 -8
- package/dist/interactions/actions/defaults/escape.js.map +1 -1
- package/dist/interactions/actions/defaults/exitPathEdit.js +7 -4
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +26 -20
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +10 -4
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -4
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +8 -2
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/pathEditTools.js +11 -8
- package/dist/interactions/actions/defaults/pathEditTools.js.map +1 -1
- package/dist/interactions/actions/defaults/pinchZoom.js +7 -4
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
- package/dist/interactions/actions/defaults/reorder.js +24 -6
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/selectAll.js +15 -8
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -1
- package/dist/interactions/actions/defaults/selectDeep.js +35 -0
- package/dist/interactions/actions/defaults/selectDeep.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +7 -3
- package/dist/interactions/actions/defaults/setFill.js.map +1 -1
- package/dist/interactions/actions/defaults/setFillOpacity.js +1 -1
- package/dist/interactions/actions/defaults/setStroke.js +12 -11
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -1
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +1 -1
- package/dist/interactions/actions/defaults/toolActivate.js +7 -1
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
- package/dist/interactions/actions/defaults/toolResetToDefault.js +7 -4
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
- package/dist/interactions/actions/defaults/undoRedo.js +19 -13
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportWheelPan.js +16 -7
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
- package/dist/interactions/actions/defaults/viewportZoom.js +24 -6
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
- package/dist/interactions/actions/drawnBoxes.js +2 -1
- package/dist/interactions/actions/drawnBoxes.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/action.js +7 -4
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +8 -2
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +1 -0
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/parent.js +7 -5
- package/dist/interactions/actions/insert/parent.js.map +1 -1
- package/dist/interactions/actions/insert/placeAction.js +3 -2
- package/dist/interactions/actions/insert/placeAction.js.map +1 -1
- package/dist/interactions/actions/insert/repositionAction.js +2 -1
- package/dist/interactions/actions/insert/repositionAction.js.map +1 -1
- package/dist/interactions/actions/insert/session.js +2 -2
- package/dist/interactions/actions/insert/session.js.map +1 -1
- package/dist/interactions/actions/move/action.js +7 -4
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/commit/reparent.js +1 -1
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
- package/dist/interactions/actions/move/gestureAdapter.js +6 -7
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
- package/dist/interactions/actions/move/layout/exits.js +1 -1
- package/dist/interactions/actions/move/layout/exits.js.map +1 -1
- package/dist/interactions/actions/move/session.js +4 -4
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlinesAction.js +8 -5
- package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -1
- package/dist/interactions/actions/outlines/outlineStroke.js +5 -3
- package/dist/interactions/actions/outlines/outlineStroke.js.map +1 -1
- package/dist/interactions/actions/pathCommands/cutJoin.js +8 -5
- package/dist/interactions/actions/pathCommands/cutJoin.js.map +1 -1
- package/dist/interactions/actions/pathCommands/pathNodes.js +14 -5
- package/dist/interactions/actions/pathCommands/pathNodes.js.map +1 -1
- package/dist/interactions/actions/resize/cornerHandles.js +2 -1
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +12 -7
- package/dist/interactions/actions/selectionSubtree.js.map +1 -1
- package/dist/interactions/actions/transform-again/action.js +8 -5
- package/dist/interactions/actions/transform-again/action.js.map +1 -1
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +14 -2
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
- package/dist/json.d.ts +4 -0
- package/dist/json.js +3 -0
- package/dist/kitSettingsSchema.js +8 -1
- package/dist/kitSettingsSchema.js.map +1 -1
- package/dist/{math-CrJULaZI.d.ts → math-C_elShP_.d.ts} +7 -1
- package/dist/math.d.ts +1 -1
- package/dist/math.js +2 -1
- package/dist/move.d.ts +4 -4
- package/dist/{options-DBxEryYq.d.ts → options-ClEm3SEl.d.ts} +1 -1
- package/dist/resize.d.ts +4 -4
- package/dist/test-seams.d.ts +6 -6
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +2 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/hand/dragPanContribution.js +4 -1
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -1
- package/dist/tools/builtin/hand/useHandTool.js +7 -4
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
- package/dist/tools/builtin/image/useImageTool.js +1 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -1
- package/dist/tools/builtin/lasso/useLassoTool.js +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +1 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/measure/useMeasureTool.js +12 -5
- package/dist/tools/builtin/measure/useMeasureTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +14 -6
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +13 -4
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/pressTarget.js +22 -0
- package/dist/tools/builtin/pressTarget.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +6 -5
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -1
- package/dist/tools/builtin/select/collapseDeferred.js +40 -0
- package/dist/tools/builtin/select/collapseDeferred.js.map +1 -0
- package/dist/tools/builtin/select/groupEntry.js +82 -0
- package/dist/tools/builtin/select/groupEntry.js.map +1 -0
- package/dist/tools/builtin/select/pressDecision.js +32 -0
- package/dist/tools/builtin/select/pressDecision.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +22 -13
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +74 -55
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/slice/useSliceTool.js +22 -8
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +13 -4
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/sticky/stickyNode.js +4 -1
- package/dist/tools/builtin/sticky/stickyNode.js.map +1 -1
- package/dist/tools/builtin/sticky/useStickyTool.js +10 -5
- package/dist/tools/builtin/sticky/useStickyTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +3 -1
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/{types-7puAuVD2.d.ts → types-49uYJN3j.d.ts} +1 -1
- package/dist/{types-CniVctmk.d.ts → types-BEdRIhNc.d.ts} +272 -109
- package/dist/{types-oFeQ5VjV.d.ts → types-p2alu-R1.d.ts} +1 -1
- package/dist/util/paint.js +1 -3
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +29 -25
|
@@ -5,11 +5,11 @@ import { isTextData } from "@weasel-js/text";
|
|
|
5
5
|
function isObj(d) {
|
|
6
6
|
return typeof d === "object" && d !== null;
|
|
7
7
|
}
|
|
8
|
-
/** Routes a
|
|
8
|
+
/** Routes a group node as `'group'`, whatever its data holds. `inferredNodeRouting` leads
|
|
9
9
|
* with it; spread it ahead of `defaultNodeRouting`, which is the shape-kind table alone. */
|
|
10
10
|
var groupNodeRouting = {
|
|
11
11
|
name: "group",
|
|
12
|
-
matches: (_data, node) => node?.kind === "
|
|
12
|
+
matches: (_data, node) => node?.kind === "group"
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Routing classifiers for the kit's built-in shape kinds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultNodeRouting.js","names":[],"sources":["../../../src/canvas/SceneCanvas/defaultNodeRouting.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\nimport { isTextData } from '@weasel-js/text';\n\nfunction isObj(d: unknown): d is Record<string, unknown> {\n return typeof d === 'object' && d !== null;\n}\n\n/** Routes a
|
|
1
|
+
{"version":3,"file":"defaultNodeRouting.js","names":[],"sources":["../../../src/canvas/SceneCanvas/defaultNodeRouting.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS } from 'core/shapeKinds';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\nimport { isTextData } from '@weasel-js/text';\n\nfunction isObj(d: unknown): d is Record<string, unknown> {\n return typeof d === 'object' && d !== null;\n}\n\n/** Routes a group node as `'group'`, whatever its data holds. `inferredNodeRouting` leads\n * with it; spread it ahead of `defaultNodeRouting`, which is the shape-kind table alone. */\nexport const groupNodeRouting: NodeRoutingEntry = {\n name: 'group',\n matches: (_data, node) => node?.kind === 'group',\n};\n\n/**\n * Routing classifiers for the kit's built-in shape kinds\n * (`KIT_SHAPE_KINDS`): each entry matches `data.kind === '<name>'`. Routing\n * kinds and shape kinds are independent — `'group'` has no shape painter.\n *\n * Spread it into `<SceneCanvas routing={...}>` when scene data carries a\n * `kind` tag. Data with no `kind` that follows the kit's common shapes\n * (`{ path }`, `{ text }`, `{ image }`) wants `inferredNodeRouting`, which\n * SceneCanvas applies when `routing` is unset.\n */\nexport const defaultNodeRouting: readonly NodeRoutingEntry[] = KIT_SHAPE_KINDS.map(\n (name) => ({\n name,\n matches: (data) =>\n isObj(data) &&\n (data as { kind?: unknown }).kind === name,\n }),\n);\n\n/**\n * Routing classifiers used when a consumer doesn't pass `routing` to\n * `<SceneCanvas>`, keyed on the data's shape rather than a `data.kind` tag.\n *\n * Order matters: `'text'` beats `'path'` so an SVG-imported text node\n * carrying a fallback `path` routes to text-edit.\n */\nexport const inferredNodeRouting: readonly NodeRoutingEntry[] = [\n groupNodeRouting,\n { name: 'text', matches: isTextData },\n { name: 'path', matches: (d) => isObj(d) && d.path != null },\n { name: 'image', matches: (d) => isObj(d) && d.image != null },\n];\n"],"mappings":";;;;AAIA,SAAS,MAAM,GAA0C;CACvD,OAAO,OAAO,MAAM,YAAY,MAAM;AACxC;;;AAIA,IAAa,mBAAqC;CAChD,MAAM;CACN,UAAU,OAAO,SAAS,MAAM,SAAS;AAC3C;;;;;;;;;;;AAYA,IAAa,qBAAkD,gBAAgB,KAC5E,UAAU;CACT;CACA,UAAU,SACR,MAAM,IAAI,KACT,KAA4B,SAAS;AAC1C,EACF;;;;;;;;AASA,IAAa,sBAAmD;CAC9D;CACA;EAAE,MAAM;EAAQ,SAAS;CAAW;CACpC;EAAE,MAAM;EAAQ,UAAU,MAAM,MAAM,CAAC,KAAK,EAAE,QAAQ;CAAK;CAC3D;EAAE,MAAM;EAAS,UAAU,MAAM,MAAM,CAAC,KAAK,EAAE,SAAS;CAAK;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","names":[],"sources":["../../../src/canvas/SceneCanvas/props.ts"],"sourcesContent":["import type { ModeRegistry } from '@weasel-js/modes';\nimport type { PathEditHost, PathEditOpening } from './pathEditHost';\nimport type { SceneCanvasGeometry } from './geometryProps';\nimport type { SceneCanvasHit, SceneCanvasPointerProps } from './pointerProps';\nimport type { Paint } from '@weasel-js/paint';\nimport type { ActionsProp, ActionTunings } from '@weasel-js/routing';\nimport { Yoke } from '@weasel-js/routing/react';\nimport type { PasteOmission } from 'core/adapters/types';\nimport type { Op } from 'core/ops/types';\nimport type { Node, Scene, SerializedScene } from 'core/scene/types';\nimport type { SelectionApi, UseSelectionOptions } from 'core/selection/useSelection';\nimport type { ContentHandlerEntry } from 'features/ingestion';\nimport type { SceneCanvasSnap } from 'features/snap/types';\nimport type { SvgIngestOptions } from 'interactions/actions/depSchema';\nimport type { GeometryProjection } from 'interactions/actions/geometryProjection';\nimport type { UseMoveOptions } from 'interactions/actions/move/options';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport type { UseRotateOptions } from 'interactions/actions/rotate/options';\nimport type { ReactNode } from 'react';\nimport type { Animator } from '@weasel-js/animator';\nimport type { PoseTransitionSeat } from '../../animation/poseTransition';\nimport { HANDLE_BASE_PX } from '../../core/device/targets';\nimport type { DeviceProfile } from '../../core/device/types';\nimport type { NodeRoutingEntry } from '../../core/scene/NodeRouting';\nimport type { DebugConfig } from '../../debug/types';\nimport type { LayoutDropTargetMode, ReflowTransition } from '../../layout/types';\nimport type { FlattenTolerance, ShaderProgramHandle } from '@weasel-js/renderer';\nimport type { Tool, ToolsApi } from '../../tools/overlayBinding';\nimport type { SceneSlotConfig } from '../buildSceneLayer';\nimport type { CanvasProps } from '../Canvas';\nimport type { LayersMap } from '../layerSlots';\nimport type { CanvasViewProps } from '../CanvasView';\nimport type { InsertNodeFactory, InsertPaint } from '../deps';\nimport type { SurfaceContribution } from '../surfaceContribution';\nimport type { CameraProps } from '../useCanvasView';\nimport type { FeatureEntry } from './features';\nimport type { BuiltinToolOptions } from './useBuiltinShapeTools';\nimport type { VersionCheck } from './useContributionRoles';\nimport type { SceneCanvasViewport } from './viewportProp';\n\n/** The adapter surface delete / duplicate / group / ungroup need, narrowed from\n * `SceneCanvasAdapter` because `useSceneStandardActions` is non-generic. */\nexport interface BridgeAdapter {\n applyOps(ops: Op[], label?: string): void;\n insertNode(node: { id: string; [k: string]: unknown }): void;\n removeNode(id: string): void;\n setSelection(ids: string[]): void;\n}\n\n/** Default size in CSS pixels for selection corner-handles AND their\n * hit-test radius, at `targetScale = 1`. Deliberately unscaled; kit-internal\n * use sites multiply by `DeviceProfile.targetScale`. */\nexport const DEFAULT_HANDLE_SIZE = HANDLE_BASE_PX;\n\n/** `<SceneCanvas longPress>`. */\nexport interface SceneCanvasLongPress {\n /**\n * Shown while a long-press is held and some binding would fire on it.\n * Default: a ring that fills around the press point\n * (`createLongPressFeedbackContribution()`), static under\n * `prefers-reduced-motion`. `false` shows nothing; a contribution replaces\n * it, reading the `longPress` dep. Installed beside `ambient`, so under a\n * `tools` takeover add it to your own `useTools` call instead.\n */\n feedback?: boolean | SurfaceContribution;\n /** Default true. A long-press some binding handled pulses\n * `navigator.vibrate` briefly, for touch and pen, where the API exists. */\n haptics?: boolean;\n /** Hold time in ms. Default `LONG_PRESS_MS` (500). */\n duration?: number;\n}\n\n/** `<SceneCanvas layers>`: a {@link LayersMap} whose scene slot may be partial,\n * since the defaults fill in whatever it leaves out. */\nexport type SceneCanvasLayers<TNode extends { id: string }, TPose> = LayersMap<\n TNode,\n TPose,\n Partial<SceneSlotConfig<TNode, TPose>>\n>;\n\nimport type { BuiltinToolId } from './builtinToolSets';\nimport type { ToolEntry } from '@weasel-js/routing';\nexport { BUILTIN_TOOL_IDS, type BuiltinToolId } from './builtinToolSets';\n\nexport type { SceneCanvasHit };\n\n/** Props for `<SceneCanvas>`. A scene is the only thing it needs. With nothing\n * else it renders that scene and keeps a selection no input sets; `features`\n * turns behavior on by preset, and the rest configures what those turn on. */\nexport type SceneCanvasProps<TData, TLayer extends string, TPose> =\n Omit<\n CanvasProps<TPose>,\n | 'adapter' | 'boundsOf' | 'selection' | 'tools'\n | 'viewState' // SceneCanvas makes the camera from the view props below\n | 'layers' // stripped so we can re-add as optional below\n | 'getIsVisible' // SceneCanvas synthesizes this from chromeVisibility\n | 'contentVersion' // SceneCanvas wires this to the scene's own version\n | 'layerVisibility' | 'layerOrder' // re-declared below: they gate picking here too\n | 'debug' // re-declared below with SceneCanvas's own `slops`\n > & CameraProps\n & {\n /** A `Scene` (typically from `useScene`) — or a `SerializedScene` JSON\n * object, which SceneCanvas bakes into a Scene on first render. The\n * serialized form is read once; pass a `key` on `<SceneCanvas>` to force\n * a fresh canvas from updated JSON.\n *\n * The JSON shape is relaxed (`version: number` rather than the `1`\n * literal) so an `import json from './x.json'` result satisfies the type\n * without an `as` cast. */\n scene:\n | Scene<TData, TLayer, TPose>\n | SerializedScene<TData, TLayer, TPose>\n | { version: number; systemLayers?: ReadonlyArray<{ id: string }>; nodes: ReadonlyArray<unknown> };\n\n /** Layer configuration. When omitted, SceneCanvas applies kit defaults\n * (a scene slot that paints `node.data.fill` rects + a default\n * selection overlay). A partial scene or selection-overlay config is\n * spread over that slot's defaults; pass `slot: null` to suppress a\n * default explicitly. */\n layers?: SceneCanvasLayers<Node<TData, TLayer, TPose>, TPose>;\n\n /** Which layout container a drag lands in when several contain the drop\n * point — the innermost (default), the topmost in paint order, or only\n * containers whose strategy declares a `dropRegion`. Decides both the\n * drag-time reflow preview and the commit. */\n layoutDropTarget?: LayoutDropTargetMode;\n\n /** Carries the siblings a layout reflow displaces to their slots over time\n * instead of snapping them — `useAnimatedReflow` builds one. Covers a\n * drag's reflow and every one the scene records (an insert, delete,\n * reorder or resize inside a laid-out container). Absent or `null`,\n * they snap. */\n reflowTransition?: ReflowTransition<TPose> | null;\n\n /** Glides what is shown when the scene writes a pose — a `scene.setPose`, an undo — and sees\n * removed nodes off with `exit`. Absent or `null`, writes snap. See {@link PoseTransitionSeat}. */\n poseTransition?: PoseTransitionSeat<TPose> | null;\n\n /**\n * Lets pose-transform actions (move, resize, nudge, flip — NOT rotate) also rewrite a\n * node's data-held geometry. Given a node and the affine `m` applied to its pose,\n * `transform(node, m)` returns updated `data`, or `null` for nodes with no data-held\n * geometry. When absent, the kit emits only the pose op and leaves `data` untouched.\n *\n * @see GeometryProjection\n */\n geometryProjection?: GeometryProjection;\n\n /**\n * Routing-trait classifiers. The kit builds a `NodeRouting` registry per `<SceneCanvas>`\n * from this prop and uses it to derive each hit's `kind`, which tool routing tables\n * (e.g. `{ target: 'rect', actionId: 'move' }`) match against. Pass `defaultNodeRouting`\n * for the kit's built-in shape kinds; spread additional entries for consumer-defined\n * kinds.\n *\n * **Memoize the `routing` value.** The registry is memoized on the prop's reference\n * identity: a fresh array each render rebuilds it and cascades into a new adapter,\n * churning gesture state.\n */\n routing?: readonly NodeRoutingEntry[];\n\n /** How to read and rewrite this scene's poses. Every built-in action,\n * the selection chrome and picking read it. Default `AUTO_POSE_DESCRIPTOR`\n * (rect poses and `Path` poses). */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n // --- Geometry: hit-test + bounds overrides consumed by the internal\n // `useSelectTool`. Ignored if the consumer passes their own `tools`. ---\n geometry?: SceneCanvasGeometry;\n\n // --- Selection options. `pickBest` and `handleHitRadius` configure the\n // internal select tool, and are ignored under a `tools` takeover;\n // `move`, `resize` and `rotate` configure the `move`,\n // `resize` and `rotate` presets, and apply either way. ---\n selectTool?: {\n move?: UseMoveOptions<TPose>;\n resize?: UseResizeOptions<TPose>;\n /** Rotation options, or `false` to hide the rotation handle and bind it to\n * nothing; the `rotate` action stays, for other tools and `actions.rotate`. */\n rotate?: UseRotateOptions<TPose> | false;\n handleHitRadius?: number;\n /** Override the body-pick used on click/pointerdown. Alt-aware: receives\n * the live alt state + current selection so consumers can implement\n * alt-cycling through an overlapping stack. Default: top-most hit\n * (alt ignored). */\n pickBest?: (worldX: number, worldY: number, alt: boolean, sel: readonly string[]) => string | null;\n };\n\n /** Consumer node factories for the `insert` action, keyed by tool `kind`.\n * Each factory receives the drag AABB + tool `extras` and returns the\n * node's `data` (in this canvas's own data shape) plus an optional `pose`.\n * A factory for a kit kind (`rect`, `line`, …) replaces the kit's default\n * `{ path, fill }` node for that kind; a factory for a novel kind (e.g.\n * `text`) adds insert support the kit doesn't ship. The dep supplies id,\n * layer, and the undoable op. Return `null` to reject an insert. */\n insertNodeFactories?: Record<string, InsertNodeFactory>;\n\n /** The fill, stroke, and fill rule a kit-built shape is inserted with, by\n * tool `kind` and insert count; the kit keeps the geometry. Default\n * `paletteInsertPaint`, the kit palette in turn. A kind with a factory in\n * `insertNodeFactories` is not asked. */\n insertPaint?: InsertPaint;\n\n /** External-content ingestion (OS drop / clipboard paste / picker).\n *\n * - `handlers` — consumer content handlers registered for this canvas's\n * lifetime (priority 0 by default — they beat the kit's `image/*` /\n * `image/svg+xml` handlers at -100/-90).\n * - `resolveSrc` — overrides the image handler's `data:`-URI embed (e.g.\n * upload to an asset store, return the URL).\n * - `svg.unpack` — makes the kit SVG handler parse dropped SVG files into\n * native scene nodes instead of one embedded-image node each.\n * - `clipboard` — the kit weasel-JSON paste handler, enabled by default.\n * `reviver` restores JSON-unfriendly values the copying side encoded via\n * `jsonReplacer`. `enabled: false` opts the canvas out, but the kit\n * handler still consumes weasel-matching items and declines them inert\n * rather than letting them fall through. Also governs Cmd/Ctrl+V under\n * the `edit` preset; the rest takes the `ingest` preset.\n *\n * Memoize `handlers` and `clipboard.reviver`: an inline array literal\n * re-registers the handlers on every render. */\n ingestion?: {\n handlers?: ContentHandlerEntry[];\n resolveSrc?: (file: File) => Promise<string>;\n svg?: SvgIngestOptions;\n clipboard?: {\n reviver?: (key: string, value: unknown) => unknown;\n enabled?: boolean;\n /** Called when a paste left copied nodes out, with each one and the\n * reason. `useClipboardOps` takes the same callback as\n * `onPasteOmitted` for a paste from its own in-memory copy. */\n onOmitted?: (omitted: PasteOmission[]) => void;\n };\n };\n\n selection?: SelectionApi;\n selectionOptions?: UseSelectionOptions;\n\n /**\n * `false` stops the canvas writing the selection: no click, marquee,\n * lasso, action or tool, and no op committed through the adapter it hands\n * its tools. The consumer's own `SelectionApi` — the `selection` prop, or\n * `useSelection({ scene })` — still writes, and the canvas draws what it\n * holds. Undo and redo still restore the selection each history entry\n * recorded. Default `true`.\n *\n * Click policy (whether shift-click extends) is the selection's `mode`:\n * `useSelection({ mode: 'multi' })`, or `selectionOptions={{ mode: 'multi' }}`\n * for the selection the canvas builds itself.\n */\n selectable?: boolean;\n\n /**\n * Behavior presets to turn on, composable in any combination. A canvas\n * with none renders its scene and keeps a selection (the `selection` API\n * works) that no input sets: no tools, no standard actions or their keys,\n * no clipboard, no drop or paste, and no selection chrome. The dispatcher\n * is still mounted, so bindings a consumer adds work.\n *\n * - `view` — wheel pan and zoom, pinch, the zoom keys, and the hand tool\n * (H, or hold Space). Passing `viewport` implies it.\n * - `select` — the select tool, as the initial active tool and Escape's\n * return target: click to pick, drag on empty to marquee, click on empty\n * to clear.\n * - `outline` — the selection outline, whichever tool sets the selection.\n * - `pick` — `select` and `outline`.\n * - `move` — drag a body to move it, Alt-drag to clone it. Ambient, so it\n * runs under any tool that does not claim the drag.\n * - `resize` — resize handles, drawn and bound.\n * - `rotate` — the rotation handle, drawn and bound.\n * - `transform` — `resize` and `rotate`.\n * - `edit` — undo/redo, delete, duplicate, group/ungroup, nudge,\n * select-all, Escape, cancel-gesture, cut/copy/paste, fill and stroke,\n * and their keys. Cmd/Ctrl+V pastes nodes a kit canvas copied, from\n * this tab or another, and nothing else.\n * - `arrange` — align, distribute, reorder, flip.\n * - `paths` — pathfinder operations, path-edit entry and anchor editing.\n * - `ingest` — dropped and pasted content: images, SVG, files, and\n * whatever `ingestion.handlers` accept, on Cmd/Ctrl+V or an OS drop.\n * - `draw` — all of the above.\n *\n * Any `FeaturePreset` object goes beside the names: core's own\n * (`pathsPreset`), or one a package ships.\n * Tools add the actions they bind — a shape tool brings `insert` — so\n * `defaultTools` composes with any preset. `actions` then adds, overrides\n * or removes on top of what the presets registered.\n */\n features?: readonly FeatureEntry[];\n\n /** Extra tools or overrides keyed by id, or a full `ToolsApi` takeover.\n *\n * **Patch form** (`Record<string, Tool | true | false>`): merged\n * into the built-in registry on top of whatever `defaultTools` and\n * `features` already selected.\n * - `true` pulls in the built-in for this id (`'pen'`, `'lasso'`,\n * `'hand'`, …), the same as listing it in `defaultTools`. Unknown\n * built-in ids warn in dev and are ignored.\n * - `Tool` adds a new id or replaces an existing one in place\n * (dev-only warning if `defaultTools` also names that id).\n * - `false` omits a bundled tool entirely.\n * Auto-wiring (keybindings, dispatcher, action registry) still runs.\n *\n * **Takeover form** (`ToolsApi`): the internal registry is bypassed and\n * this `tools` value is forwarded to Canvas as-is — the consumer owns\n * active-slot management, and `pick`'s select tool is theirs to supply.\n * Every other preset still applies. Keybindings are still auto-wired\n * against the supplied registry; pass `enableKeybindings={false}` to opt\n * out. */\n tools?: ToolsApi | Record<string, Tool | true | false>;\n\n /**\n * Auto-wire keyboard shortcuts. Default `true`. When `false`, SceneCanvas still mounts\n * its tools but routes no keyboard input to them — neither tool hotkeys nor\n * keyboard-bound actions like delete / escape / nudge. Pointer, wheel, and contextmenu\n * interactions are unaffected.\n */\n enableKeybindings?: boolean;\n\n /**\n * Take the keyboard on mount, as a press in the canvas would. A key that\n * reaches the page goes to the canvas the user last pressed or scrolled\n * in, and to no canvas before the first such interaction, so a canvas in a\n * side panel does not take Space from a page that wants it. An app whose\n * canvas is the page sets this so its shortcuts work before the first\n * click. Default `false`.\n */\n claimKeys?: boolean;\n\n /**\n * Auto-mount the gesture dispatcher (`useGestureDispatcher`). Default `true`. `false` is\n * for tests or demos that drive actions another way, or that call\n * `useGestureDispatcher` themselves.\n */\n enableGestureDispatcher?: boolean;\n\n /** Called with the `ToolsApi` SceneCanvas constructs or receives, whenever its identity\n * changes. For introspection. */\n onToolsCreated?: (tools: ToolsApi) => void;\n\n /**\n * Built-in tools SceneCanvas registers in its internal `useTools`, on top\n * of the ones presets bring (`select` from `pick`, `hand` from `view`):\n * ids, or sets of them such as `SHAPE_TOOLS`, or `withoutTools(...)` of one.\n * Default: none. Each tool also registers the kit actions it binds, so\n * `['rect']` brings `insert`. Ignored when the consumer supplies their own\n * `tools` prop.\n */\n defaultTools?: readonly ToolEntry<BuiltinToolId>[];\n\n /** Per-tool option overrides for the built-in tools. Each entry is a\n * narrow subset of the underlying hook's options surface — `lasso.mode`,\n * `rig.state`, etc. */\n toolOptions?: BuiltinToolOptions;\n /** What gestures snap to, and how near it pulls. */\n snap?: SceneCanvasSnap;\n\n /** Initial active-slot tool id. Default: `'select'` when it is\n * registered, otherwise none — a canvas can run on ambient bindings\n * alone. Must be one of the registered tools. Ignored when the consumer\n * supplies their own `tools` prop. */\n initialActiveTool?: string;\n\n /** Always-on entries to register alongside the internal tools — every one\n * a `SurfaceContribution`, whose views, deps, overlay, bindings, actions\n * and `attach` all install from this one list, and uninstall when the\n * entry leaves it. A tool is a contribution too, so one can go here. If\n * you supply your own `tools` prop, this is ignored — wire `ambient`\n * through your own `useTools` call instead. */\n ambient?: readonly SurfaceContribution[];\n\n /** What an entry's `requires` does when the running kit does not meet\n * it: `'warn'` (the default) logs in development, `'strict'` throws,\n * `'off'` skips the check. */\n versionCheck?: VersionCheck;\n\n /** Touch and pen long-press: its hold time, its haptic, and the\n * feedback shown while it is held. */\n longPress?: SceneCanvasLongPress;\n\n /** Configures the `view` preset, and implies it. See {@link SceneCanvasViewport}. */\n viewport?: SceneCanvasViewport;\n\n /**\n * Tune actions on this canvas without restating them, keyed by action id:\n * `params` every invocation starts from, and `bindings` added beside the\n * action's own. A tuning applies to whichever descriptor holds the id, a\n * preset's or a tool's. Pass a stable object; a params thunk is read on\n * every call. See the core README (\"Tuning an action\").\n */\n tune?: ActionTunings;\n\n /**\n * Replace, add or mute whole action descriptors. Pass `null` to disable\n * all defaults. To change a built-in's params or add a key, use `tune`.\n */\n actions?: ActionsProp;\n\n /**\n * Given a scene node, return a short human-readable \"kind\" label (e.g. `'rectangle'`,\n * `'sticky note'`), which the kit publishes per id into any surrounding\n * `<SelectionContextProvider>`. Return `undefined` to skip an entry. When omitted,\n * each node reports its routing kind (see `routing`), and a node that routes as\n * `'unknown'` is left unlabeled.\n */\n describeKind?: (node: Node<TData, TLayer, TPose>) => string | undefined;\n\n /**\n * Animator to bind for per-frame redraws. SceneCanvas requests a redraw on every active\n * animation frame and paints `animator.colorOverrides` onto the scene's nodes: the\n * kit's path and shape painters apply them, and a custom `drawOne` receives them as\n * `ctx.vertexColors`.\n */\n animator?: Animator;\n\n /**\n * Extra views on this canvas: each is a camera over a rect of the same\n * surface, drawn through one GL context, with input routed to it. The flat\n * `view` / `onViewChange` props above stay the canvas's own camera — view\n * zero — and are unaffected by anything declared here.\n *\n * Order is paint and hit order, low to high. Each entry is a\n * `<CanvasView>`; mounting one as a child is the same declaration, and\n * children land after every entry here.\n */\n views?: readonly CanvasViewProps[];\n\n /**\n * Children rendered alongside the canvas, inside its input scope (e.g.\n * shortcuts overlays, probes).\n */\n children?: ReactNode;\n\n /** A yoke to join, from `useYoke()`: canvases on one yoke share the active tool, the gesture\n * in flight and history. Omitted, this canvas keeps its own. */\n yoke?: Yoke;\n\n /**\n * Chrome-caps visibility overrides, keyed by chrome id (`selection.outline`,\n * `selection.rotation-handle`, `gesture.marquee`, …). Each entry is a composable\n * {@link Condition} built from the `cond()` builder, merged on top of the kit's\n * `defaultVisibilityRules`. Set an id to `never` to suppress a chrome element\n * entirely (also unhittable), or to `always` to force-show.\n */\n chromeVisibility?: import('features/chrome-caps').VisibilityRules;\n\n /**\n * The app's mode registry (`createModeRegistry` in `@weasel-js/modes`).\n * The canvas reads the active mode from it to gate chrome, tool\n * activation and the dispatcher's eligibility filter, repaints when it\n * switches, and hands every registered mode to the dev-time route-conflict\n * check. Omitted, the canvas behaves as the kit's normal mode and nothing\n * revokes anchor editing.\n */\n modes?: ModeRegistry;\n\n /** Hands which path is being anchor-edited to the host. See {@link PathEditHost}. */\n pathEdit?: PathEditHost;\n /** A path to open in anchor edit as the canvas mounts, with anchors selected. Read once. */\n defaultPathEdit?: PathEditOpening;\n\n /**\n * Override detected device facts. Merged over what `matchMedia` reports;\n * `targetScale` is re-derived from the merged `coarsePointer` unless you\n * override it explicitly.\n */\n device?: Partial<DeviceProfile>;\n\n /**\n * Live focus getter for chrome-caps' `focused` ctx field, for visibility rules that\n * read the `focused` atom (the kit's default `selection.rotation-handle` rule does).\n * Omit to default `focused` to `true`.\n */\n getFocused?: () => boolean;\n\n /** Custom shader programs to compile on the renderer. See `CanvasProps.shaders`. */\n shaders?: ShaderProgramHandle[];\n\n /** Flatness tolerance for curve tessellation. See `CanvasProps.flattenTolerance`. */\n flattenTolerance?: FlattenTolerance;\n\n /** Fill for the full canvas behind the scene, drawn as a screen-space layer slotted\n * before `'scene'` — independent of pan / zoom. */\n backgroundFill?: Paint;\n /** Dev HUD: a fixed-position widget showing live cursor coords in both viewport\n * (client) and canvas (world) frames. */\n cursorCoordsHud?: boolean;\n /** Dev HUD: a fixed-position widget listing the ids `pickEvery(world)` returns under\n * the cursor. */\n pickHud?: boolean;\n /**\n * The debug overlay: `<Canvas debug>`'s config, plus `slops: true` for\n * translucent halos at every affordance hit zone. `false` turns it off;\n * absent reads `?debug=…` from the URL, as `<Canvas>` does.\n */\n debug?: (DebugConfig & { slops?: boolean }) | false;\n /**\n * Dev HUD: when true (or object), mounts a fixed-position widget below\n * the pick HUD showing the active modality mode, active-slot tool, and\n * hotkey stack. Pass `{ modeId }` to populate the mode line.\n */\n modalityHud?: boolean | { modeId?: string };\n\n /**\n * Per-id alpha multiplier for the scene-render slot: each node's draw output is wrapped\n * in a group with the returned alpha, and 1 emits no wrapper. Typical use: dimming\n * non-active nodes during a mode transition.\n */\n alphaFor?: (id: string) => number;\n\n /**\n * Show or hide render layers in this canvas's own view, by id — the map\n * `<Canvas>` takes. Each scene layer paints as its own render layer, keyed\n * `scene:<layerId>`, so `{ 'scene:guides': false }` hides one scene layer\n * here and nowhere else.\n *\n * A layer hidden this way is gone from this view: it does not paint, and a\n * click, a marquee or Cmd+A here passes over it. Another view of the same\n * scene — a `<CanvasView>`, a second canvas, a minimap — still shows it and\n * can still take it. It applies on top of the scene's own\n * `LayerRecord.visible` and cannot show a layer the scene hides.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order for this view, by render-layer id, bottom first. A listed\n * order is the whole list: a scene layer left out of it is neither painted\n * nor picked here. See `CanvasProps.layerOrder`.\n */\n layerOrder?: string[];\n } & SceneCanvasPointerProps;\n"],"mappings":";;;;;;;;AAqDA,IAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"props.js","names":[],"sources":["../../../src/canvas/SceneCanvas/props.ts"],"sourcesContent":["import type { ModeRegistry } from '@weasel-js/modes';\nimport type { PathEditHost, PathEditOpening } from './pathEditHost';\nimport type { SceneCanvasGeometry } from './geometryProps';\nimport type { SceneCanvasHit, SceneCanvasPointerProps } from './pointerProps';\nimport type { Paint } from '@weasel-js/paint';\nimport type { SceneCanvasActionProps } from './actionProps';\nimport { Yoke } from '@weasel-js/routing/react';\nimport type { PasteOmission } from 'core/adapters/types';\nimport type { Op } from 'core/ops/types';\nimport type { Node, Scene, SerializedScene } from 'core/scene/types';\nimport type { SelectionApi, UseSelectionOptions } from 'core/selection/useSelection';\nimport type { ContentHandlerEntry } from 'features/ingestion';\nimport type { SceneCanvasSnap } from 'features/snap/types';\nimport type { SvgIngestOptions } from 'interactions/actions/depSchema';\nimport type { GeometryProjection } from 'interactions/actions/geometryProjection';\nimport type { UseMoveOptions } from 'interactions/actions/move/options';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport type { UseRotateOptions } from 'interactions/actions/rotate/options';\nimport type { ReactNode } from 'react';\nimport type { Animator } from '@weasel-js/animator';\nimport type { PoseTransitionSeat } from '../../animation/poseTransition';\nimport { HANDLE_BASE_PX } from '../../core/device/targets';\nimport type { DeviceProfile } from '../../core/device/types';\nimport type { NodeRoutingEntry } from '../../core/scene/NodeRouting';\nimport type { DebugConfig } from '../../debug/types';\nimport type { LayoutDropTargetMode, ReflowTransition } from '../../layout/types';\nimport type { FlattenTolerance, ShaderProgramHandle } from '@weasel-js/renderer';\nimport type { Tool, ToolsApi } from '../../tools/overlayBinding';\nimport type { SceneSlotConfig } from '../buildSceneLayer';\nimport type { CanvasProps } from '../Canvas';\nimport type { LayersMap } from '../layerSlots';\nimport type { CanvasViewProps } from '../CanvasView';\nimport type { InsertNodeFactory, InsertPaint } from '../deps';\nimport type { SurfaceContribution } from '../surfaceContribution';\nimport type { CameraProps } from '../useCanvasView';\nimport type { FeatureEntry } from './features';\nimport type { BuiltinToolOptions } from './useBuiltinShapeTools';\nimport type { VersionCheck } from './useContributionRoles';\nimport type { SceneCanvasViewport } from './viewportProp';\n\n/** The adapter surface delete / duplicate / group / ungroup need, narrowed from\n * `SceneCanvasAdapter` because `useSceneStandardActions` is non-generic. */\nexport interface BridgeAdapter {\n applyOps(ops: Op[], label?: string): void;\n insertNode(node: { id: string; [k: string]: unknown }): void;\n removeNode(id: string): void;\n setSelection(ids: string[]): void;\n}\n\n/** Default size in CSS pixels for selection corner-handles AND their\n * hit-test radius, at `targetScale = 1`. Deliberately unscaled; kit-internal\n * use sites multiply by `DeviceProfile.targetScale`. */\nexport const DEFAULT_HANDLE_SIZE = HANDLE_BASE_PX;\n\n/** `<SceneCanvas longPress>`. */\nexport interface SceneCanvasLongPress {\n /**\n * Shown while a long-press is held and some binding would fire on it.\n * Default: a ring that fills around the press point\n * (`createLongPressFeedbackContribution()`), static under\n * `prefers-reduced-motion`. `false` shows nothing; a contribution replaces\n * it, reading the `longPress` dep. Installed beside `ambient`, so under a\n * `tools` takeover add it to your own `useTools` call instead.\n */\n feedback?: boolean | SurfaceContribution;\n /** Default true. A long-press some binding handled pulses\n * `navigator.vibrate` briefly, for touch and pen, where the API exists. */\n haptics?: boolean;\n /** Hold time in ms. Default `LONG_PRESS_MS` (500). */\n duration?: number;\n}\n\n/** `<SceneCanvas layers>`: a {@link LayersMap} whose scene slot may be partial,\n * since the defaults fill in whatever it leaves out. */\nexport type SceneCanvasLayers<TNode extends { id: string }, TPose> = LayersMap<\n TNode,\n TPose,\n Partial<SceneSlotConfig<TNode, TPose>>\n>;\n\nimport type { BuiltinToolId } from './builtinToolSets';\nimport type { ToolEntry } from '@weasel-js/routing';\nexport { BUILTIN_TOOL_IDS, type BuiltinToolId } from './builtinToolSets';\n\nexport type { SceneCanvasHit };\n\n/** Props for `<SceneCanvas>`. A scene is the only thing it needs. With nothing\n * else it renders that scene and keeps a selection no input sets; `features`\n * turns behavior on by preset, and the rest configures what those turn on. */\nexport type SceneCanvasProps<TData, TLayer extends string, TPose> =\n Omit<\n CanvasProps<TPose>,\n | 'adapter' | 'boundsOf' | 'selection' | 'tools'\n | 'viewState' // SceneCanvas makes the camera from the view props below\n | 'layers' // stripped so we can re-add as optional below\n | 'getIsVisible' // SceneCanvas synthesizes this from chromeVisibility\n | 'contentVersion' // SceneCanvas wires this to the scene's own version\n | 'layerVisibility' | 'layerOrder' // re-declared below: they gate picking here too\n | 'debug' // re-declared below with SceneCanvas's own `slops`\n > & CameraProps\n & {\n /** A `Scene` (typically from `useScene`) — or a `SerializedScene` JSON\n * object, which SceneCanvas bakes into a Scene on first render. The\n * serialized form is read once; pass a `key` on `<SceneCanvas>` to force\n * a fresh canvas from updated JSON.\n *\n * The JSON shape is relaxed (`version: number` rather than the `1`\n * literal) so an `import json from './x.json'` result satisfies the type\n * without an `as` cast. */\n scene:\n | Scene<TData, TLayer, TPose>\n | SerializedScene<TData, TLayer, TPose>\n | { version: number; systemLayers?: ReadonlyArray<{ id: string }>; nodes: ReadonlyArray<unknown> };\n\n /** Layer configuration. When omitted, SceneCanvas applies kit defaults\n * (a scene slot that paints `node.data.fill` rects + a default\n * selection overlay). A partial scene or selection-overlay config is\n * spread over that slot's defaults; pass `slot: null` to suppress a\n * default explicitly. */\n layers?: SceneCanvasLayers<Node<TData, TLayer, TPose>, TPose>;\n\n /** Which layout container a drag lands in when several contain the drop\n * point — the innermost (default), the topmost in paint order, or only\n * containers whose strategy declares a `dropRegion`. Decides both the\n * drag-time reflow preview and the commit. */\n layoutDropTarget?: LayoutDropTargetMode;\n\n /** Carries the siblings a layout reflow displaces to their slots over time\n * instead of snapping them — `useAnimatedReflow` builds one. Covers a\n * drag's reflow and every one the scene records (an insert, delete,\n * reorder or resize inside a laid-out container). Absent or `null`,\n * they snap. */\n reflowTransition?: ReflowTransition<TPose> | null;\n\n /** Glides what is shown when the scene writes a pose — a `scene.setPose`, an undo — and sees\n * removed nodes off with `exit`. Absent or `null`, writes snap. See {@link PoseTransitionSeat}. */\n poseTransition?: PoseTransitionSeat<TPose> | null;\n\n /**\n * Lets pose-transform actions (move, resize, nudge, flip — NOT rotate) also rewrite a\n * node's data-held geometry. Given a node and the affine `m` applied to its pose,\n * `transform(node, m)` returns updated `data`, or `null` for nodes with no data-held\n * geometry. When absent, the kit emits only the pose op and leaves `data` untouched.\n *\n * @see GeometryProjection\n */\n geometryProjection?: GeometryProjection;\n\n /**\n * Routing-trait classifiers. The kit builds a `NodeRouting` registry per `<SceneCanvas>`\n * from this prop and uses it to derive each hit's `kind`, which tool routing tables\n * (e.g. `{ target: 'rect', actionId: 'move' }`) match against. Pass `defaultNodeRouting`\n * for the kit's built-in shape kinds; spread additional entries for consumer-defined\n * kinds.\n *\n * **Memoize the `routing` value.** The registry is memoized on the prop's reference\n * identity: a fresh array each render rebuilds it and cascades into a new adapter,\n * churning gesture state.\n */\n routing?: readonly NodeRoutingEntry[];\n\n /** How to read and rewrite this scene's poses. Every built-in action,\n * the selection chrome and picking read it. Default `AUTO_POSE_DESCRIPTOR`\n * (rect poses and `Path` poses). */\n poseDescriptor?: PoseDescriptor<TPose>;\n\n // --- Geometry: hit-test + bounds overrides consumed by the internal\n // `useSelectTool`. Ignored if the consumer passes their own `tools`. ---\n geometry?: SceneCanvasGeometry;\n\n // --- Selection options. `pickBest` and `handleHitRadius` configure the\n // internal select tool, and are ignored under a `tools` takeover;\n // `move`, `resize` and `rotate` configure the `move`,\n // `resize` and `rotate` presets, and apply either way. ---\n selectTool?: {\n move?: UseMoveOptions<TPose>;\n resize?: UseResizeOptions<TPose>;\n /** Rotation options, or `false` to hide the rotation handle and bind it to\n * nothing; the `rotate` action stays, for other tools and `actions.rotate`. */\n rotate?: UseRotateOptions<TPose> | false;\n handleHitRadius?: number;\n /** Override the body-pick used on click/pointerdown. Alt-aware: receives\n * the live alt state + current selection so consumers can implement\n * alt-cycling through an overlapping stack. Default: top-most hit\n * (alt ignored). */\n pickBest?: (worldX: number, worldY: number, alt: boolean, sel: readonly string[]) => string | null;\n };\n\n /** Consumer node factories for the `insert` action, keyed by tool `kind`.\n * Each factory receives the drag AABB + tool `extras` and returns the\n * node's `data` (in this canvas's own data shape) plus an optional `pose`.\n * A factory for a kit kind (`rect`, `line`, …) replaces the kit's default\n * `{ path, fill }` node for that kind; a factory for a novel kind (e.g.\n * `text`) adds insert support the kit doesn't ship. The dep supplies id,\n * layer, and the undoable op. Return `null` to reject an insert. */\n insertNodeFactories?: Record<string, InsertNodeFactory>;\n\n /** The fill, stroke, and fill rule a kit-built shape is inserted with, by\n * tool `kind` and insert count; the kit keeps the geometry. Default\n * `paletteInsertPaint`, the kit palette in turn. A kind with a factory in\n * `insertNodeFactories` is not asked. */\n insertPaint?: InsertPaint;\n\n /** External-content ingestion (OS drop / clipboard paste / picker).\n *\n * - `handlers` — consumer content handlers registered for this canvas's\n * lifetime (priority 0 by default — they beat the kit's `image/*` /\n * `image/svg+xml` handlers at -100/-90).\n * - `resolveSrc` — overrides the image handler's `data:`-URI embed (e.g.\n * upload to an asset store, return the URL).\n * - `svg.unpack` — makes the kit SVG handler parse dropped SVG files into\n * native scene nodes instead of one embedded-image node each.\n * - `clipboard` — the kit weasel-JSON paste handler, enabled by default.\n * `reviver` restores JSON-unfriendly values the copying side encoded via\n * `jsonReplacer`. `enabled: false` opts the canvas out, but the kit\n * handler still consumes weasel-matching items and declines them inert\n * rather than letting them fall through. Also governs Cmd/Ctrl+V under\n * the `edit` preset; the rest takes the `ingest` preset.\n *\n * Memoize `handlers` and `clipboard.reviver`: an inline array literal\n * re-registers the handlers on every render. */\n ingestion?: {\n handlers?: ContentHandlerEntry[];\n resolveSrc?: (file: File) => Promise<string>;\n svg?: SvgIngestOptions;\n clipboard?: {\n reviver?: (key: string, value: unknown) => unknown;\n enabled?: boolean;\n /** Called when a paste left copied nodes out, with each one and the\n * reason. `useClipboardOps` takes the same callback as\n * `onPasteOmitted` for a paste from its own in-memory copy. */\n onOmitted?: (omitted: PasteOmission[]) => void;\n };\n };\n\n selection?: SelectionApi;\n selectionOptions?: UseSelectionOptions;\n\n /**\n * `false` stops the canvas writing the selection: no click, marquee,\n * lasso, action or tool, and no op committed through the adapter it hands\n * its tools. The consumer's own `SelectionApi` — the `selection` prop, or\n * `useSelection({ scene })` — still writes, and the canvas draws what it\n * holds. Undo and redo still restore the selection each history entry\n * recorded. Default `true`.\n *\n * Click policy (whether shift-click extends) is the selection's `mode`:\n * `useSelection({ mode: 'multi' })`, or `selectionOptions={{ mode: 'multi' }}`\n * for the selection the canvas builds itself.\n */\n selectable?: boolean;\n\n /**\n * Behavior presets to turn on, composable in any combination. A canvas\n * with none renders its scene and keeps a selection (the `selection` API\n * works) that no input sets: no tools, no standard actions or their keys,\n * no clipboard, no drop or paste, and no selection chrome. The dispatcher\n * is still mounted, so bindings a consumer adds work.\n *\n * - `view` — wheel pan and zoom, pinch, the zoom keys, and the hand tool\n * (H, or hold Space). Passing `viewport` implies it.\n * - `select` — the select tool, as the initial active tool and Escape's\n * return target: click to pick, drag on empty to marquee, click on empty\n * to clear.\n * - `outline` — the selection outline, whichever tool sets the selection.\n * - `pick` — `select` and `outline`.\n * - `move` — drag a body to move it, Alt-drag to clone it. Ambient, so it\n * runs under any tool that does not claim the drag.\n * - `resize` — resize handles, drawn and bound.\n * - `rotate` — the rotation handle, drawn and bound.\n * - `transform` — `resize` and `rotate`.\n * - `edit` — undo/redo, delete, duplicate, group/ungroup, nudge,\n * select-all, Escape, cancel-gesture, cut/copy/paste, fill and stroke,\n * and their keys. Cmd/Ctrl+V pastes nodes a kit canvas copied, from\n * this tab or another, and nothing else.\n * - `arrange` — align, distribute, reorder, flip.\n * - `paths` — pathfinder operations, path-edit entry and anchor editing.\n * - `ingest` — dropped and pasted content: images, SVG, files, and\n * whatever `ingestion.handlers` accept, on Cmd/Ctrl+V or an OS drop.\n * - `draw` — all of the above.\n *\n * Any `FeaturePreset` object goes beside the names: core's own\n * (`pathsPreset`), or one a package ships.\n * Tools add the actions they bind — a shape tool brings `insert` — so\n * `defaultTools` composes with any preset. `actions` then adds, overrides\n * or removes on top of what the presets registered.\n */\n features?: readonly FeatureEntry[];\n\n /** Extra tools or overrides keyed by id, or a full `ToolsApi` takeover.\n *\n * **Patch form** (`Record<string, Tool | true | false>`): merged\n * into the built-in registry on top of whatever `defaultTools` and\n * `features` already selected.\n * - `true` pulls in the built-in for this id (`'pen'`, `'lasso'`,\n * `'hand'`, …), the same as listing it in `defaultTools`. Unknown\n * built-in ids warn in dev and are ignored.\n * - `Tool` adds a new id or replaces an existing one in place\n * (dev-only warning if `defaultTools` also names that id).\n * - `false` omits a bundled tool entirely.\n * Auto-wiring (keybindings, dispatcher, action registry) still runs.\n *\n * **Takeover form** (`ToolsApi`): the internal registry is bypassed and\n * this `tools` value is forwarded to Canvas as-is — the consumer owns\n * active-slot management, and `pick`'s select tool is theirs to supply.\n * Every other preset still applies. Keybindings are still auto-wired\n * against the supplied registry; pass `enableKeybindings={false}` to opt\n * out. */\n tools?: ToolsApi | Record<string, Tool | true | false>;\n\n /**\n * Auto-wire keyboard shortcuts. Default `true`. When `false`, SceneCanvas still mounts\n * its tools but routes no keyboard input to them — neither tool hotkeys nor\n * keyboard-bound actions like delete / escape / nudge. Pointer, wheel, and contextmenu\n * interactions are unaffected.\n */\n enableKeybindings?: boolean;\n\n /**\n * Take the keyboard on mount, as a press in the canvas would. A key that\n * reaches the page goes to the canvas the user last pressed or scrolled\n * in, and to no canvas before the first such interaction, so a canvas in a\n * side panel does not take Space from a page that wants it. An app whose\n * canvas is the page sets this so its shortcuts work before the first\n * click. Default `false`.\n */\n claimKeys?: boolean;\n\n /**\n * Auto-mount the gesture dispatcher (`useGestureDispatcher`). Default `true`. `false` is\n * for tests or demos that drive actions another way, or that call\n * `useGestureDispatcher` themselves.\n */\n enableGestureDispatcher?: boolean;\n\n /** Called with the `ToolsApi` SceneCanvas constructs or receives, whenever its identity\n * changes. For introspection. */\n onToolsCreated?: (tools: ToolsApi) => void;\n\n /**\n * Built-in tools SceneCanvas registers in its internal `useTools`, on top\n * of the ones presets bring (`select` from `pick`, `hand` from `view`):\n * ids, or sets of them such as `SHAPE_TOOLS`, or `withoutTools(...)` of one.\n * Default: none. Each tool also registers the kit actions it binds, so\n * `['rect']` brings `insert`. Ignored when the consumer supplies their own\n * `tools` prop.\n */\n defaultTools?: readonly ToolEntry<BuiltinToolId>[];\n\n /** Per-tool option overrides for the built-in tools. Each entry is a\n * narrow subset of the underlying hook's options surface — `lasso.mode`,\n * `rig.state`, etc. */\n toolOptions?: BuiltinToolOptions;\n /** What gestures snap to, and how near it pulls. */\n snap?: SceneCanvasSnap;\n\n /** Initial active-slot tool id. Default: `'select'` when it is\n * registered, otherwise none — a canvas can run on ambient bindings\n * alone. Must be one of the registered tools. Ignored when the consumer\n * supplies their own `tools` prop. */\n initialActiveTool?: string;\n\n /** Always-on entries to register alongside the internal tools — every one\n * a `SurfaceContribution`, whose views, deps, overlay, bindings, actions\n * and `attach` all install from this one list, and uninstall when the\n * entry leaves it. A tool is a contribution too, so one can go here. If\n * you supply your own `tools` prop, this is ignored — wire `ambient`\n * through your own `useTools` call instead. */\n ambient?: readonly SurfaceContribution[];\n\n /** What an entry's `requires` does when the running kit does not meet\n * it: `'warn'` (the default) logs in development, `'strict'` throws,\n * `'off'` skips the check. */\n versionCheck?: VersionCheck;\n\n /** Touch and pen long-press: its hold time, its haptic, and the\n * feedback shown while it is held. */\n longPress?: SceneCanvasLongPress;\n\n /** Configures the `view` preset, and implies it. See {@link SceneCanvasViewport}. */\n viewport?: SceneCanvasViewport;\n\n /**\n * Given a scene node, return a short human-readable \"kind\" label (e.g. `'rectangle'`,\n * `'sticky note'`), which the kit publishes per id into any surrounding\n * `<SelectionContextProvider>`. Return `undefined` to skip an entry. When omitted,\n * each node reports its routing kind (see `routing`), and a node that routes as\n * `'unknown'` is left unlabeled.\n */\n describeKind?: (node: Node<TData, TLayer, TPose>) => string | undefined;\n\n /**\n * Animator to bind for per-frame redraws. SceneCanvas requests a redraw on every active\n * animation frame and paints `animator.colorOverrides` onto the scene's nodes: the\n * kit's path and shape painters apply them, and a custom `drawOne` receives them as\n * `ctx.vertexColors`.\n */\n animator?: Animator;\n\n /**\n * Extra views on this canvas: each is a camera over a rect of the same\n * surface, drawn through one GL context, with input routed to it. The flat\n * `view` / `onViewChange` props above stay the canvas's own camera — view\n * zero — and are unaffected by anything declared here.\n *\n * Order is paint and hit order, low to high. Each entry is a\n * `<CanvasView>`; mounting one as a child is the same declaration, and\n * children land after every entry here.\n */\n views?: readonly CanvasViewProps[];\n\n /**\n * Children rendered alongside the canvas, inside its input scope (e.g.\n * shortcuts overlays, probes).\n */\n children?: ReactNode;\n\n /** A yoke to join, from `useYoke()`: canvases on one yoke share the active tool, the gesture\n * in flight and history. Omitted, this canvas keeps its own. */\n yoke?: Yoke;\n\n /**\n * Chrome-caps visibility overrides, keyed by chrome id (`selection.outline`,\n * `selection.rotation-handle`, `gesture.marquee`, …). Each entry is a composable\n * {@link Condition} built from the `cond()` builder, merged on top of the kit's\n * `defaultVisibilityRules`. Set an id to `never` to suppress a chrome element\n * entirely (also unhittable), or to `always` to force-show.\n */\n chromeVisibility?: import('features/chrome-caps').VisibilityRules;\n\n /**\n * The app's mode registry (`createModeRegistry` in `@weasel-js/modes`).\n * The canvas reads the active mode from it to gate chrome, tool\n * activation and the dispatcher's eligibility filter, repaints when it\n * switches, and hands every registered mode to the dev-time route-conflict\n * check. Omitted, the canvas behaves as the kit's normal mode and nothing\n * revokes anchor editing.\n */\n modes?: ModeRegistry;\n\n /** Hands which path is being anchor-edited to the host. See {@link PathEditHost}. */\n pathEdit?: PathEditHost;\n /** A path to open in anchor edit as the canvas mounts, with anchors selected. Read once. */\n defaultPathEdit?: PathEditOpening;\n\n /**\n * Override detected device facts. Merged over what `matchMedia` reports;\n * `targetScale` is re-derived from the merged `coarsePointer` unless you\n * override it explicitly.\n */\n device?: Partial<DeviceProfile>;\n\n /**\n * Live focus getter for chrome-caps' `focused` ctx field, for visibility rules that\n * read the `focused` atom (the kit's default `selection.rotation-handle` rule does).\n * Omit to default `focused` to `true`.\n */\n getFocused?: () => boolean;\n\n /** Custom shader programs to compile on the renderer. See `CanvasProps.shaders`. */\n shaders?: ShaderProgramHandle[];\n\n /** Flatness tolerance for curve tessellation. See `CanvasProps.flattenTolerance`. */\n flattenTolerance?: FlattenTolerance;\n\n /** Fill for the full canvas behind the scene, drawn as a screen-space layer slotted\n * before `'scene'` — independent of pan / zoom. */\n backgroundFill?: Paint;\n /** Dev HUD: a fixed-position widget showing live cursor coords in both viewport\n * (client) and canvas (world) frames. */\n cursorCoordsHud?: boolean;\n /** Dev HUD: a fixed-position widget listing the ids `pickEvery(world)` returns under\n * the cursor. */\n pickHud?: boolean;\n /**\n * The debug overlay: `<Canvas debug>`'s config, plus `slops: true` for\n * translucent halos at every affordance hit zone. `false` turns it off;\n * absent reads `?debug=…` from the URL, as `<Canvas>` does.\n */\n debug?: (DebugConfig & { slops?: boolean }) | false;\n /**\n * Dev HUD: when true (or object), mounts a fixed-position widget below\n * the pick HUD showing the active modality mode, active-slot tool, and\n * hotkey stack. Pass `{ modeId }` to populate the mode line.\n */\n modalityHud?: boolean | { modeId?: string };\n\n /**\n * Per-id alpha multiplier for the scene-render slot: each node's draw output is wrapped\n * in a group with the returned alpha, and 1 emits no wrapper. Typical use: dimming\n * non-active nodes during a mode transition.\n */\n alphaFor?: (id: string) => number;\n\n /**\n * Show or hide render layers in this canvas's own view, by id — the map\n * `<Canvas>` takes. Each scene layer paints as its own render layer, keyed\n * `scene:<layerId>`, so `{ 'scene:guides': false }` hides one scene layer\n * here and nowhere else.\n *\n * A layer hidden this way is gone from this view: it does not paint, and a\n * click, a marquee or Cmd+A here passes over it. Another view of the same\n * scene — a `<CanvasView>`, a second canvas, a minimap — still shows it and\n * can still take it. It applies on top of the scene's own\n * `LayerRecord.visible` and cannot show a layer the scene hides.\n */\n layerVisibility?: Record<string, boolean>;\n\n /**\n * Draw order for this view, by render-layer id, bottom first. A listed\n * order is the whole list: a scene layer left out of it is neither painted\n * nor picked here. See `CanvasProps.layerOrder`.\n */\n layerOrder?: string[];\n } & SceneCanvasPointerProps & SceneCanvasActionProps;\n"],"mappings":";;;;;;;;AAqDA,IAAa,sBAAsB"}
|
|
@@ -8,15 +8,22 @@ import { applyToPoint, meanScale, pathContainsPoint } from "@weasel-js/geom";
|
|
|
8
8
|
* `pickTolerancePx` of screen slop, refined to the painter's ink when
|
|
9
9
|
* `shapePicking` is on. */
|
|
10
10
|
function scenePointQuery(d, shapePicking, pickTolerancePx) {
|
|
11
|
-
const pointQuery = (px, py, s) => {
|
|
11
|
+
const pointQuery = (px, py, s) => ({
|
|
12
|
+
...bareQuery(px, py, s),
|
|
13
|
+
broad: pointBroad(px, py, s, pickTolerancePx)
|
|
14
|
+
});
|
|
15
|
+
const bareQuery = (px, py, s) => {
|
|
12
16
|
const scale = meanScale(s);
|
|
13
17
|
const tolerance = {
|
|
14
18
|
px: pickTolerancePx,
|
|
15
19
|
scale: s
|
|
16
20
|
};
|
|
17
21
|
return {
|
|
18
|
-
hits: (n, pose, derived) => {
|
|
19
|
-
const ink = shapePicking ? findShapeInk(n, pose, {
|
|
22
|
+
hits: (n, pose, derived, inherited) => {
|
|
23
|
+
const ink = shapePicking ? findShapeInk(n, pose, {
|
|
24
|
+
scale,
|
|
25
|
+
inherited
|
|
26
|
+
}) : null;
|
|
20
27
|
const slop = {
|
|
21
28
|
...tolerance,
|
|
22
29
|
px: tolerance.px + (ink?.outsetPx ?? 0),
|
|
@@ -26,7 +33,8 @@ function scenePointQuery(d, shapePicking, pickTolerancePx) {
|
|
|
26
33
|
return !shapePicking || shapeCoversPoint(n, pose, px, py, {
|
|
27
34
|
tolerance,
|
|
28
35
|
scale,
|
|
29
|
-
derivedPath: derived
|
|
36
|
+
derivedPath: derived,
|
|
37
|
+
inherited
|
|
30
38
|
});
|
|
31
39
|
},
|
|
32
40
|
clipAdmits: (clip) => pathContainsPoint(clip, px, py),
|
|
@@ -43,7 +51,7 @@ function scenePointQuery(d, shapePicking, pickTolerancePx) {
|
|
|
43
51
|
inCopy: (m) => {
|
|
44
52
|
const [x, y] = applyToPoint(m, px, py);
|
|
45
53
|
const k = Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));
|
|
46
|
-
return
|
|
54
|
+
return bareQuery(x, y, {
|
|
47
55
|
x: s.x / k,
|
|
48
56
|
y: s.y / k
|
|
49
57
|
});
|
|
@@ -52,6 +60,20 @@ function scenePointQuery(d, shapePicking, pickTolerancePx) {
|
|
|
52
60
|
};
|
|
53
61
|
return pointQuery;
|
|
54
62
|
}
|
|
63
|
+
/** The world box the point query's slop reaches, on the least-scaled axis. */
|
|
64
|
+
function pointBroad(px, py, s, tolerancePx) {
|
|
65
|
+
const least = Math.min(Math.abs(s.x), Math.abs(s.y));
|
|
66
|
+
const r = tolerancePx / least;
|
|
67
|
+
return {
|
|
68
|
+
box: {
|
|
69
|
+
x: px - r,
|
|
70
|
+
y: py - r,
|
|
71
|
+
width: 2 * r,
|
|
72
|
+
height: 2 * r
|
|
73
|
+
},
|
|
74
|
+
pxPerWorld: least
|
|
75
|
+
};
|
|
76
|
+
}
|
|
55
77
|
|
|
56
78
|
//#endregion
|
|
57
79
|
export { scenePointQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenePointQuery.js","names":[],"sources":["../../../src/canvas/SceneCanvas/scenePointQuery.ts"],"sourcesContent":["import { applyToPoint, meanScale, pathContainsPoint } from '@weasel-js/geom';\nimport type { PickQuery } from 'canvas/pickWalk';\nimport { findShapeInk, shapeCoversPoint } from 'canvas/NodeShape';\nimport { toPlane } from 'core/viewport/parallax';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { poseContains, poseContainsRotated } from './poseGeometry';\n\n/** The point query `<SceneCanvas>`'s default pick asks: a world point with\n * `pickTolerancePx` of screen slop, refined to the painter's ink when\n * `shapePicking` is on. */\nexport function scenePointQuery<TPose>(\n d: PoseDescriptor<unknown>,\n shapePicking: boolean,\n pickTolerancePx: number,\n): (px: number, py: number, s: { x: number; y: number }) => PickQuery<TPose> {\n // `s` makes the slop a screen distance, so the grab zone stays the same\n // apparent thickness at any zoom and on every axis. A `{ px }` stroke's\n // reach is on screen too, and joins the slop there.\n const pointQuery = (px: number, py: number, s: { x: number; y: number }): PickQuery<TPose> => {\n const scale = meanScale(s);\n const tolerance = { px: pickTolerancePx, scale: s };\n return {\n hits: (n, pose, derived) => {\n // The pre-filter has to be at least as generous as the refinement\n // that follows it, or it rejects points the refinement would have\n // claimed. A stroke reaches past the pose box by `outset` — a whole\n // stroke width for an outer align — on top of the pointer slop.\n const ink = shapePicking ? findShapeInk(n as never, pose, { scale }) : null;\n // A derived node's pose is a placeholder — typically zero-sized at\n // the origin — so its own box rejects every point the path covers.\n // The path is the region to test instead, and `poseContains` already\n // reads a path-like pose as one.\n const slop = { ...tolerance, px: tolerance.px + (ink?.outsetPx ?? 0), reach: ink?.outset ?? 0 };\n const admitted = derived\n ? poseContains(derived as never, px, py, slop, d as PoseDescriptor<unknown>)\n : poseContainsRotated(pose, px, py, slop, d as PoseDescriptor<unknown>);\n if (!admitted) return false;\n // `shapeCoversPoint` narrows the rect to the ink the painter actually\n // lays down (and answers `true` for painters that have no silhouette,\n // so nothing becomes unpickable).\n return !shapePicking\n || shapeCoversPoint(n as never, pose, px, py, {\n tolerance, scale, derivedPath: derived,\n });\n },\n clipAdmits: (clip) => pathContainsPoint(clip, px, py),\n inPlane: (m) => {\n const p = toPlane(m, { x: px, y: py });\n return pointQuery(p.x, p.y, { x: s.x / m.scale.x, y: s.y / m.scale.y });\n },\n inCopy: (m) => {\n const [x, y] = applyToPoint(m, px, py);\n const k = Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));\n return
|
|
1
|
+
{"version":3,"file":"scenePointQuery.js","names":[],"sources":["../../../src/canvas/SceneCanvas/scenePointQuery.ts"],"sourcesContent":["import { applyToPoint, meanScale, pathContainsPoint } from '@weasel-js/geom';\nimport type { PickBroad, PickQuery } from 'canvas/pickWalk';\nimport { findShapeInk, shapeCoversPoint } from 'canvas/NodeShape';\nimport { toPlane } from 'core/viewport/parallax';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { poseContains, poseContainsRotated } from './poseGeometry';\n\n/** The point query `<SceneCanvas>`'s default pick asks: a world point with\n * `pickTolerancePx` of screen slop, refined to the painter's ink when\n * `shapePicking` is on. */\nexport function scenePointQuery<TPose>(\n d: PoseDescriptor<unknown>,\n shapePicking: boolean,\n pickTolerancePx: number,\n): (px: number, py: number, s: { x: number; y: number }) => PickQuery<TPose> {\n // `s` makes the slop a screen distance, so the grab zone stays the same\n // apparent thickness at any zoom and on every axis. A `{ px }` stroke's\n // reach is on screen too, and joins the slop there.\n const pointQuery = (px: number, py: number, s: { x: number; y: number }): PickQuery<TPose> =>\n ({ ...bareQuery(px, py, s), broad: pointBroad(px, py, s, pickTolerancePx) });\n // A copy is tested by every walk, so the query carried into one asks no index.\n const bareQuery = (px: number, py: number, s: { x: number; y: number }): PickQuery<TPose> => {\n const scale = meanScale(s);\n const tolerance = { px: pickTolerancePx, scale: s };\n return {\n hits: (n, pose, derived, inherited) => {\n // The pre-filter has to be at least as generous as the refinement\n // that follows it, or it rejects points the refinement would have\n // claimed. A stroke reaches past the pose box by `outset` — a whole\n // stroke width for an outer align — on top of the pointer slop.\n const ink = shapePicking ? findShapeInk(n as never, pose, { scale, inherited }) : null;\n // A derived node's pose is a placeholder — typically zero-sized at\n // the origin — so its own box rejects every point the path covers.\n // The path is the region to test instead, and `poseContains` already\n // reads a path-like pose as one.\n const slop = { ...tolerance, px: tolerance.px + (ink?.outsetPx ?? 0), reach: ink?.outset ?? 0 };\n const admitted = derived\n ? poseContains(derived as never, px, py, slop, d as PoseDescriptor<unknown>)\n : poseContainsRotated(pose, px, py, slop, d as PoseDescriptor<unknown>);\n if (!admitted) return false;\n // `shapeCoversPoint` narrows the rect to the ink the painter actually\n // lays down (and answers `true` for painters that have no silhouette,\n // so nothing becomes unpickable).\n return !shapePicking\n || shapeCoversPoint(n as never, pose, px, py, {\n tolerance, scale, derivedPath: derived, inherited,\n });\n },\n clipAdmits: (clip) => pathContainsPoint(clip, px, py),\n inPlane: (m) => {\n const p = toPlane(m, { x: px, y: py });\n return pointQuery(p.x, p.y, { x: s.x / m.scale.x, y: s.y / m.scale.y });\n },\n inCopy: (m) => {\n const [x, y] = applyToPoint(m, px, py);\n const k = Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));\n return bareQuery(x, y, { x: s.x / k, y: s.y / k });\n },\n };\n };\n return pointQuery;\n}\n\n/** The world box the point query's slop reaches, on the least-scaled axis. */\nfunction pointBroad(px: number, py: number, s: { x: number; y: number }, tolerancePx: number): PickBroad {\n const least = Math.min(Math.abs(s.x), Math.abs(s.y));\n const r = tolerancePx / least;\n return { box: { x: px - r, y: py - r, width: 2 * r, height: 2 * r }, pxPerWorld: least };\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,gBACd,GACA,cACA,iBAC2E;CAI3E,MAAM,cAAc,IAAY,IAAY,OACzC;EAAE,GAAG,UAAU,IAAI,IAAI,CAAC;EAAG,OAAO,WAAW,IAAI,IAAI,GAAG,eAAe;CAAE;CAE5E,MAAM,aAAa,IAAY,IAAY,MAAkD;EAC3F,MAAM,QAAQ,UAAU,CAAC;EACzB,MAAM,YAAY;GAAE,IAAI;GAAiB,OAAO;EAAE;EAClD,OAAO;GACL,OAAO,GAAG,MAAM,SAAS,cAAc;IAKrC,MAAM,MAAM,eAAe,aAAa,GAAY,MAAM;KAAE;KAAO;IAAU,CAAC,IAAI;IAKlF,MAAM,OAAO;KAAE,GAAG;KAAW,IAAI,UAAU,MAAM,KAAK,YAAY;KAAI,OAAO,KAAK,UAAU;IAAE;IAI9F,IAAI,EAHa,UACb,aAAa,SAAkB,IAAI,IAAI,MAAM,CAA4B,IACzE,oBAAoB,MAAM,IAAI,IAAI,MAAM,CAA4B,IACzD,OAAO;IAItB,OAAO,CAAC,gBACH,iBAAiB,GAAY,MAAM,IAAI,IAAI;KAC5C;KAAW;KAAO,aAAa;KAAS;IAC1C,CAAC;GACL;GACA,aAAa,SAAS,kBAAkB,MAAM,IAAI,EAAE;GACpD,UAAU,MAAM;IACd,MAAM,IAAI,QAAQ,GAAG;KAAE,GAAG;KAAI,GAAG;IAAG,CAAC;IACrC,OAAO,WAAW,EAAE,GAAG,EAAE,GAAG;KAAE,GAAG,EAAE,IAAI,EAAE,MAAM;KAAG,GAAG,EAAE,IAAI,EAAE,MAAM;IAAE,CAAC;GACxE;GACA,SAAS,MAAM;IACb,MAAM,CAAC,GAAG,KAAK,aAAa,GAAG,IAAI,EAAE;IACrC,MAAM,IAAI,KAAK,KAAK,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;IACvD,OAAO,UAAU,GAAG,GAAG;KAAE,GAAG,EAAE,IAAI;KAAG,GAAG,EAAE,IAAI;IAAE,CAAC;GACnD;EACF;CACF;CACA,OAAO;AACT;;AAGA,SAAS,WAAW,IAAY,IAAY,GAA6B,aAAgC;CACvG,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,EAAE,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;CACnD,MAAM,IAAI,cAAc;CACxB,OAAO;EAAE,KAAK;GAAE,GAAG,KAAK;GAAG,GAAG,KAAK;GAAG,OAAO,IAAI;GAAG,QAAQ,IAAI;EAAE;EAAG,YAAY;CAAM;AACzF"}
|
|
@@ -14,7 +14,12 @@ function useActionTunings(tune) {
|
|
|
14
14
|
};
|
|
15
15
|
}, [reg, tune]);
|
|
16
16
|
}
|
|
17
|
+
/** Hold `overrides` on the registry in scope for as long as the object is the same one. */
|
|
18
|
+
function useBindingOverrides(overrides) {
|
|
19
|
+
const reg = useActionsRegistry();
|
|
20
|
+
useEffect(() => reg && overrides ? reg.overrideBindings(overrides) : void 0, [reg, overrides]);
|
|
21
|
+
}
|
|
17
22
|
|
|
18
23
|
//#endregion
|
|
19
|
-
export { useActionTunings };
|
|
24
|
+
export { useActionTunings, useBindingOverrides };
|
|
20
25
|
//# sourceMappingURL=useActionTunings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionTunings.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useActionTunings.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { ActionTuning, ActionTunings } from '@weasel-js/routing';\nimport { useActionsRegistry } from '@weasel-js/routing/react';\n\n/** Hold `tune`'s tunings on the registry in scope for as long as the object\n * is the same one. */\nexport function useActionTunings(tune: ActionTunings | undefined): void {\n const reg = useActionsRegistry();\n useEffect(() => {\n if (!reg || !tune) return;\n const releases = Object.entries(tune).flatMap(([id, t]) => (t ? [reg.tune(id, t as ActionTuning)] : []));\n return () => { for (const release of releases) release(); };\n }, [reg, tune]);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,iBAAiB,MAAuC;CACtE,MAAM,MAAM,mBAAmB;CAC/B,gBAAgB;EACd,IAAI,CAAC,OAAO,CAAC,MAAM;EACnB,MAAM,WAAW,OAAO,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,OAAQ,IAAI,CAAC,IAAI,KAAK,IAAI,CAAiB,CAAC,IAAI,CAAC,CAAE;EACvG,aAAa;GAAE,KAAK,MAAM,WAAW,UAAU,QAAQ;EAAG;CAC5D,GAAG,CAAC,KAAK,IAAI,CAAC;AAChB"}
|
|
1
|
+
{"version":3,"file":"useActionTunings.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useActionTunings.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { ActionTuning, ActionTunings, BindingOverrides } from '@weasel-js/routing';\nimport { useActionsRegistry } from '@weasel-js/routing/react';\n\n/** Hold `tune`'s tunings on the registry in scope for as long as the object\n * is the same one. */\nexport function useActionTunings(tune: ActionTunings | undefined): void {\n const reg = useActionsRegistry();\n useEffect(() => {\n if (!reg || !tune) return;\n const releases = Object.entries(tune).flatMap(([id, t]) => (t ? [reg.tune(id, t as ActionTuning)] : []));\n return () => { for (const release of releases) release(); };\n }, [reg, tune]);\n}\n\n/** Hold `overrides` on the registry in scope for as long as the object is the same one. */\nexport function useBindingOverrides(overrides: BindingOverrides | undefined): void {\n const reg = useActionsRegistry();\n useEffect(() => (reg && overrides ? reg.overrideBindings(overrides) : undefined), [reg, overrides]);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,iBAAiB,MAAuC;CACtE,MAAM,MAAM,mBAAmB;CAC/B,gBAAgB;EACd,IAAI,CAAC,OAAO,CAAC,MAAM;EACnB,MAAM,WAAW,OAAO,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,OAAQ,IAAI,CAAC,IAAI,KAAK,IAAI,CAAiB,CAAC,IAAI,CAAC,CAAE;EACvG,aAAa;GAAE,KAAK,MAAM,WAAW,UAAU,QAAQ;EAAG;CAC5D,GAAG,CAAC,KAAK,IAAI,CAAC;AAChB;;AAGA,SAAgB,oBAAoB,WAA+C;CACjF,MAAM,MAAM,mBAAmB;CAC/B,gBAAiB,OAAO,YAAY,IAAI,iBAAiB,SAAS,IAAI,QAAY,CAAC,KAAK,SAAS,CAAC;AACpG"}
|
|
@@ -51,6 +51,7 @@ function useCanvasDevtoolsRoot(c) {
|
|
|
51
51
|
contributions: c.contributions,
|
|
52
52
|
actions,
|
|
53
53
|
deps,
|
|
54
|
+
...actions ? { overrides: actions.bindingOverrides() } : {},
|
|
54
55
|
routingKinds: (c.routing ?? inferredNodeRouting).map((k) => k.name)
|
|
55
56
|
}),
|
|
56
57
|
subscribeRegistry(listener) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasDevtoolsRoot.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useCanvasDevtoolsRoot.ts"],"sourcesContent":["import { useEffect, useState, type MutableRefObject, type RefObject } from 'react';\nimport {\n createDispatchTrace, createTraceRing, type Contribution, type DepRegistry, type DispatchTrace, type TraceRing,\n} from '@weasel-js/routing';\nimport { useActionsRegistry, useDepRegistry } from '@weasel-js/routing/react';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { DebugConfig } from '../../debug/types';\nimport { parseDebugFlags } from '../../debug/parseDebugFlags';\nimport { recordHistory } from '../../devtools/history';\nimport type { DevtoolsHistoryRecord } from '../../devtools/protocol';\nimport { useDevtoolsLabel } from '../../devtools/label';\nimport { describeRegistry } from '../../devtools/registry';\nimport type { DevtoolsRoot } from '../../devtools/root';\nimport { useDevtoolsRoot, type DevtoolsOverride } from '../../devtools/useDevtoolsRoot';\nimport type { ToolsApi } from '../../tools/overlayBinding';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { CanvasViewState } from '../useCanvasView';\nimport type { CoordTraceEntry } from './coordTrace';\nimport { inferredNodeRouting } from './defaultNodeRouting';\n\n/** A canvas's trace buffers: its dispatchers' decisions, its `clientToWorld` conversions, and its scene's history steps. */\nexport interface CanvasTraces {\n dispatch: DispatchTrace;\n coords: TraceRing<CoordTraceEntry>;\n history: TraceRing<DevtoolsHistoryRecord>;\n}\n\n/** What `<SceneCanvas>` hands its input wiring for devtools: the `debug` in effect and the override's setter. */\nexport interface CanvasDevtools {\n debug: DebugConfig | false | undefined;\n setOverride(override: DevtoolsOverride | null): void;\n}\n\nfunction resolved(debug: DebugConfig | false | undefined): DebugConfig | null {\n if (debug === false) return null;\n if (debug !== undefined) return debug;\n return typeof window === 'undefined' ? null : parseDebugFlags(window.location.search);\n}\n\n/** What `get-registry` reports of `deps`, as one comparable string; null for a registry that cannot list itself. */\nfunction depListingKey(deps: DepRegistry): string | null {\n return deps.list?.().map((d) => `${d.name}:${d.depth}:${d.stacked}`).join('\\u0000') ?? null;\n}\n\n/** This canvas's trace buffers and its devtools root, read from the latest render. */\nexport function useCanvasDevtoolsRoot(c: {\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n viewState: CanvasViewState;\n tools: ToolsApi;\n /** The entries the canvas's `features` presets brought beside its tools. */\n contributions: readonly Contribution<unknown>[];\n routing: readonly NodeRoutingEntry[] | undefined;\n element: MutableRefObject<HTMLElement | null>;\n api: RefObject<CanvasExtensionApi | null>;\n devtools: CanvasDevtools;\n}): { root: DevtoolsRoot; traces: CanvasTraces } {\n const [traces] = useState<CanvasTraces>(() => ({\n dispatch: createDispatchTrace(),\n coords: createTraceRing<CoordTraceEntry>(),\n history: createTraceRing<DevtoolsHistoryRecord>(),\n }));\n const actions = useActionsRegistry();\n const deps = useDepRegistry();\n const framed = useDevtoolsLabel();\n const root = useDevtoolsRoot({\n label: () => {\n const el = c.element.current;\n return el?.getAttribute('aria-label') || el?.id || framed\n || el?.parentElement?.closest('[aria-label]')?.getAttribute('aria-label') || '';\n },\n scene: () => c.scene,\n selection: () => c.selection.current,\n select: (ids) => c.selection.set([...ids] as NodeId[]),\n view: () => c.viewState.getView(),\n activeTool: () => c.tools.active ?? null,\n tools: () => Object.keys(c.tools.registry),\n setTool: (id) => c.tools.setActive(id),\n trace: traces.dispatch,\n coords: traces.coords,\n frame: () => c.api.current?.getDebug()?.snapshot().frame ?? null,\n overlays: () => resolved(c.devtools.debug),\n setOverride: (o) => c.devtools.setOverride(o),\n subscribeView: c.viewState.subscribeView,\n registry: () => describeRegistry({\n tools: c.tools, contributions: c.contributions, actions, deps,\n routingKinds: (c.routing ?? inferredNodeRouting).map((k) => k.name),\n }),\n subscribeRegistry(listener) {\n // The dep registry also notifies when a source's value changes, as every selection does; only the listing is ours.\n let listed = depListingKey(deps);\n const onDeps = (): void => {\n const next = depListingKey(deps);\n if (next !== null && next === listed) return;\n listed = next;\n listener();\n };\n const offs = [actions?.subscribe(listener), deps.subscribe?.(onDeps)];\n return () => { for (const off of offs) off?.(); };\n },\n history: traces.history,\n }, { selection: c.selection.current, tool: c.tools.active ?? null });\n useEffect(() => recordHistory(c.scene.history, traces.history), [c.scene, traces.history]);\n const { registry, ambient } = c.tools;\n useEffect(() => { root.notify('registry'); }, [root, registry, ambient, c.contributions, c.routing]);\n return { root, traces };\n}\n"],"mappings":";;;;;;;;;;;AAmCA,SAAS,SAAS,OAA4D;CAC5E,IAAI,UAAU,OAAO,OAAO;CAC5B,IAAI,UAAU,QAAW,OAAO;CAChC,OAAO,OAAO,WAAW,cAAc,OAAO,gBAAgB,OAAO,SAAS,MAAM;AACtF;;AAGA,SAAS,cAAc,MAAkC;CACvD,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,MAAM,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,IAAQ,KAAK;AACzF;;AAGA,SAAgB,sBAAsB,GAWW;CAC/C,MAAM,CAAC,UAAU,gBAA8B;EAC7C,UAAU,oBAAoB;EAC9B,QAAQ,gBAAiC;EACzC,SAAS,gBAAuC;CAClD,EAAE;CACF,MAAM,UAAU,mBAAmB;CACnC,MAAM,OAAO,eAAe;CAC5B,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,gBAAgB;EAC3B,aAAa;GACX,MAAM,KAAK,EAAE,QAAQ;GACrB,OAAO,IAAI,aAAa,YAAY,KAAK,IAAI,MAAM,UAC9C,IAAI,eAAe,QAAQ,cAAc,CAAC,EAAE,aAAa,YAAY,KAAK;EACjF;EACA,aAAa,EAAE;EACf,iBAAiB,EAAE,UAAU;EAC7B,SAAS,QAAQ,EAAE,UAAU,IAAI,CAAC,GAAG,GAAG,CAAa;EACrD,YAAY,EAAE,UAAU,QAAQ;EAChC,kBAAkB,EAAE,MAAM,UAAU;EACpC,aAAa,OAAO,KAAK,EAAE,MAAM,QAAQ;EACzC,UAAU,OAAO,EAAE,MAAM,UAAU,EAAE;EACrC,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,aAAa,EAAE,IAAI,SAAS,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,SAAS;EAC5D,gBAAgB,SAAS,EAAE,SAAS,KAAK;EACzC,cAAc,MAAM,EAAE,SAAS,YAAY,CAAC;EAC5C,eAAe,EAAE,UAAU;EAC3B,gBAAgB,iBAAiB;GAC/B,OAAO,EAAE;GAAO,eAAe,EAAE;GAAe;GAAS;GACzD,eAAe,EAAE,WAAW,oBAAA,CAAqB,KAAK,MAAM,EAAE,IAAI;EACpE,CAAC;EACD,kBAAkB,UAAU;GAE1B,IAAI,SAAS,cAAc,IAAI;GAC/B,MAAM,eAAqB;IACzB,MAAM,OAAO,cAAc,IAAI;IAC/B,IAAI,SAAS,QAAQ,SAAS,QAAQ;IACtC,SAAS;IACT,SAAS;GACX;GACA,MAAM,OAAO,CAAC,SAAS,UAAU,QAAQ,GAAG,KAAK,YAAY,MAAM,CAAC;GACpE,aAAa;IAAE,KAAK,MAAM,OAAO,MAAM,MAAM;GAAG;EAClD;EACA,SAAS,OAAO;CAClB,GAAG;EAAE,WAAW,EAAE,UAAU;EAAS,MAAM,EAAE,MAAM,UAAU;CAAK,CAAC;CACnE,gBAAgB,cAAc,EAAE,MAAM,SAAS,OAAO,OAAO,GAAG,CAAC,EAAE,OAAO,OAAO,OAAO,CAAC;CACzF,MAAM,EAAE,UAAU,YAAY,EAAE;CAChC,gBAAgB;EAAE,KAAK,OAAO,UAAU;CAAG,GAAG;EAAC;EAAM;EAAU;EAAS,EAAE;EAAe,EAAE;CAAO,CAAC;CACnG,OAAO;EAAE;EAAM;CAAO;AACxB"}
|
|
1
|
+
{"version":3,"file":"useCanvasDevtoolsRoot.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useCanvasDevtoolsRoot.ts"],"sourcesContent":["import { useEffect, useState, type MutableRefObject, type RefObject } from 'react';\nimport {\n createDispatchTrace, createTraceRing, type Contribution, type DepRegistry, type DispatchTrace, type TraceRing,\n} from '@weasel-js/routing';\nimport { useActionsRegistry, useDepRegistry } from '@weasel-js/routing/react';\nimport type { NodeRoutingEntry } from 'core/scene/NodeRouting';\nimport type { NodeId, Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { DebugConfig } from '../../debug/types';\nimport { parseDebugFlags } from '../../debug/parseDebugFlags';\nimport { recordHistory } from '../../devtools/history';\nimport type { DevtoolsHistoryRecord } from '../../devtools/protocol';\nimport { useDevtoolsLabel } from '../../devtools/label';\nimport { describeRegistry } from '../../devtools/registry';\nimport type { DevtoolsRoot } from '../../devtools/root';\nimport { useDevtoolsRoot, type DevtoolsOverride } from '../../devtools/useDevtoolsRoot';\nimport type { ToolsApi } from '../../tools/overlayBinding';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { CanvasViewState } from '../useCanvasView';\nimport type { CoordTraceEntry } from './coordTrace';\nimport { inferredNodeRouting } from './defaultNodeRouting';\n\n/** A canvas's trace buffers: its dispatchers' decisions, its `clientToWorld` conversions, and its scene's history steps. */\nexport interface CanvasTraces {\n dispatch: DispatchTrace;\n coords: TraceRing<CoordTraceEntry>;\n history: TraceRing<DevtoolsHistoryRecord>;\n}\n\n/** What `<SceneCanvas>` hands its input wiring for devtools: the `debug` in effect and the override's setter. */\nexport interface CanvasDevtools {\n debug: DebugConfig | false | undefined;\n setOverride(override: DevtoolsOverride | null): void;\n}\n\nfunction resolved(debug: DebugConfig | false | undefined): DebugConfig | null {\n if (debug === false) return null;\n if (debug !== undefined) return debug;\n return typeof window === 'undefined' ? null : parseDebugFlags(window.location.search);\n}\n\n/** What `get-registry` reports of `deps`, as one comparable string; null for a registry that cannot list itself. */\nfunction depListingKey(deps: DepRegistry): string | null {\n return deps.list?.().map((d) => `${d.name}:${d.depth}:${d.stacked}`).join('\\u0000') ?? null;\n}\n\n/** This canvas's trace buffers and its devtools root, read from the latest render. */\nexport function useCanvasDevtoolsRoot(c: {\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n viewState: CanvasViewState;\n tools: ToolsApi;\n /** The entries the canvas's `features` presets brought beside its tools. */\n contributions: readonly Contribution<unknown>[];\n routing: readonly NodeRoutingEntry[] | undefined;\n element: MutableRefObject<HTMLElement | null>;\n api: RefObject<CanvasExtensionApi | null>;\n devtools: CanvasDevtools;\n}): { root: DevtoolsRoot; traces: CanvasTraces } {\n const [traces] = useState<CanvasTraces>(() => ({\n dispatch: createDispatchTrace(),\n coords: createTraceRing<CoordTraceEntry>(),\n history: createTraceRing<DevtoolsHistoryRecord>(),\n }));\n const actions = useActionsRegistry();\n const deps = useDepRegistry();\n const framed = useDevtoolsLabel();\n const root = useDevtoolsRoot({\n label: () => {\n const el = c.element.current;\n return el?.getAttribute('aria-label') || el?.id || framed\n || el?.parentElement?.closest('[aria-label]')?.getAttribute('aria-label') || '';\n },\n scene: () => c.scene,\n selection: () => c.selection.current,\n select: (ids) => c.selection.set([...ids] as NodeId[]),\n view: () => c.viewState.getView(),\n activeTool: () => c.tools.active ?? null,\n tools: () => Object.keys(c.tools.registry),\n setTool: (id) => c.tools.setActive(id),\n trace: traces.dispatch,\n coords: traces.coords,\n frame: () => c.api.current?.getDebug()?.snapshot().frame ?? null,\n overlays: () => resolved(c.devtools.debug),\n setOverride: (o) => c.devtools.setOverride(o),\n subscribeView: c.viewState.subscribeView,\n registry: () => describeRegistry({\n tools: c.tools, contributions: c.contributions, actions, deps,\n ...(actions ? { overrides: actions.bindingOverrides() } : {}),\n routingKinds: (c.routing ?? inferredNodeRouting).map((k) => k.name),\n }),\n subscribeRegistry(listener) {\n // The dep registry also notifies when a source's value changes, as every selection does; only the listing is ours.\n let listed = depListingKey(deps);\n const onDeps = (): void => {\n const next = depListingKey(deps);\n if (next !== null && next === listed) return;\n listed = next;\n listener();\n };\n const offs = [actions?.subscribe(listener), deps.subscribe?.(onDeps)];\n return () => { for (const off of offs) off?.(); };\n },\n history: traces.history,\n }, { selection: c.selection.current, tool: c.tools.active ?? null });\n useEffect(() => recordHistory(c.scene.history, traces.history), [c.scene, traces.history]);\n const { registry, ambient } = c.tools;\n useEffect(() => { root.notify('registry'); }, [root, registry, ambient, c.contributions, c.routing]);\n return { root, traces };\n}\n"],"mappings":";;;;;;;;;;;AAmCA,SAAS,SAAS,OAA4D;CAC5E,IAAI,UAAU,OAAO,OAAO;CAC5B,IAAI,UAAU,QAAW,OAAO;CAChC,OAAO,OAAO,WAAW,cAAc,OAAO,gBAAgB,OAAO,SAAS,MAAM;AACtF;;AAGA,SAAS,cAAc,MAAkC;CACvD,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,MAAM,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,IAAQ,KAAK;AACzF;;AAGA,SAAgB,sBAAsB,GAWW;CAC/C,MAAM,CAAC,UAAU,gBAA8B;EAC7C,UAAU,oBAAoB;EAC9B,QAAQ,gBAAiC;EACzC,SAAS,gBAAuC;CAClD,EAAE;CACF,MAAM,UAAU,mBAAmB;CACnC,MAAM,OAAO,eAAe;CAC5B,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,gBAAgB;EAC3B,aAAa;GACX,MAAM,KAAK,EAAE,QAAQ;GACrB,OAAO,IAAI,aAAa,YAAY,KAAK,IAAI,MAAM,UAC9C,IAAI,eAAe,QAAQ,cAAc,CAAC,EAAE,aAAa,YAAY,KAAK;EACjF;EACA,aAAa,EAAE;EACf,iBAAiB,EAAE,UAAU;EAC7B,SAAS,QAAQ,EAAE,UAAU,IAAI,CAAC,GAAG,GAAG,CAAa;EACrD,YAAY,EAAE,UAAU,QAAQ;EAChC,kBAAkB,EAAE,MAAM,UAAU;EACpC,aAAa,OAAO,KAAK,EAAE,MAAM,QAAQ;EACzC,UAAU,OAAO,EAAE,MAAM,UAAU,EAAE;EACrC,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,aAAa,EAAE,IAAI,SAAS,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,SAAS;EAC5D,gBAAgB,SAAS,EAAE,SAAS,KAAK;EACzC,cAAc,MAAM,EAAE,SAAS,YAAY,CAAC;EAC5C,eAAe,EAAE,UAAU;EAC3B,gBAAgB,iBAAiB;GAC/B,OAAO,EAAE;GAAO,eAAe,EAAE;GAAe;GAAS;GACzD,GAAI,UAAU,EAAE,WAAW,QAAQ,iBAAiB,EAAE,IAAI,CAAC;GAC3D,eAAe,EAAE,WAAW,oBAAA,CAAqB,KAAK,MAAM,EAAE,IAAI;EACpE,CAAC;EACD,kBAAkB,UAAU;GAE1B,IAAI,SAAS,cAAc,IAAI;GAC/B,MAAM,eAAqB;IACzB,MAAM,OAAO,cAAc,IAAI;IAC/B,IAAI,SAAS,QAAQ,SAAS,QAAQ;IACtC,SAAS;IACT,SAAS;GACX;GACA,MAAM,OAAO,CAAC,SAAS,UAAU,QAAQ,GAAG,KAAK,YAAY,MAAM,CAAC;GACpE,aAAa;IAAE,KAAK,MAAM,OAAO,MAAM,MAAM;GAAG;EAClD;EACA,SAAS,OAAO;CAClB,GAAG;EAAE,WAAW,EAAE,UAAU;EAAS,MAAM,EAAE,MAAM,UAAU;CAAK,CAAC;CACnE,gBAAgB,cAAc,EAAE,MAAM,SAAS,OAAO,OAAO,GAAG,CAAC,EAAE,OAAO,OAAO,OAAO,CAAC;CACzF,MAAM,EAAE,UAAU,YAAY,EAAE;CAChC,gBAAgB;EAAE,KAAK,OAAO,UAAU;CAAG,GAAG;EAAC;EAAM;EAAU;EAAS,EAAE;EAAe,EAAE;CAAO,CAAC;CACnG,OAAO;EAAE;EAAM;CAAO;AACxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createViewMarkerContribution } from "../../features/viewports/viewMarkerDrag.js";
|
|
1
2
|
import { createLongPressFeedbackContribution } from "../../features/longPress/longPressFeedback.js";
|
|
2
3
|
import { useTools } from "../../tools/overlayBinding.js";
|
|
3
4
|
import { presetActions, presetAmbient, presetContributions, resolveFeatures } from "./features.js";
|
|
@@ -52,14 +53,21 @@ function useCanvasTools(args) {
|
|
|
52
53
|
const defaultPressFeedback = useMemo(() => createLongPressFeedbackContribution(), []);
|
|
53
54
|
const feedbackOpt = args.pressFeedback ?? true;
|
|
54
55
|
const pressFeedback = feedbackOpt === true ? defaultPressFeedback : feedbackOpt || null;
|
|
56
|
+
const defaultMarkerDrag = useMemo(() => createViewMarkerContribution(), []);
|
|
57
|
+
const markerDrag = args.actions === null ? null : defaultMarkerDrag;
|
|
58
|
+
const groupEntry = args.actions === null ? null : args.groupEntry;
|
|
55
59
|
const mergedAmbient = useMemo(() => [
|
|
56
60
|
...presetContributions(enabled),
|
|
61
|
+
...groupEntry ? [groupEntry] : [],
|
|
57
62
|
...ambient ?? [],
|
|
58
|
-
...pressFeedback ? [pressFeedback] : []
|
|
63
|
+
...pressFeedback ? [pressFeedback] : [],
|
|
64
|
+
...markerDrag ? [markerDrag] : []
|
|
59
65
|
], [
|
|
60
66
|
enabled,
|
|
67
|
+
groupEntry,
|
|
61
68
|
ambient,
|
|
62
|
-
pressFeedback
|
|
69
|
+
pressFeedback,
|
|
70
|
+
markerDrag
|
|
63
71
|
]);
|
|
64
72
|
const internal = useTools({
|
|
65
73
|
active: initialActiveTool ?? ("select" in registry ? "select" : null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasTools.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useCanvasTools.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Action } from '@weasel-js/routing';\nimport { createLongPressFeedbackContribution } from '../../features/longPress/longPressFeedback';\nimport { useTools, type Contribution, type Tool, type ToolsApi } from '../../tools/overlayBinding';\nimport {\n presetActions,\n presetAmbient,\n presetContributions,\n resolveFeatures,\n type EnabledPresets,\n type FeatureBindingOptions,\n type FeatureEntry,\n type NamedPresets,\n} from './features';\nimport type { SceneCanvasProps } from './props';\nimport type { ToolsPatch } from './toolRegistry';\nimport { useBuiltinTools } from './useBuiltinTools';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\n\n/** Discriminate the polymorphic `tools` prop: `ToolsApi` has `setActive`\n * / `active` / `registry`; the patch record shape has none of those. */\nfunction isToolsApi(tools: ToolsApi | ToolsPatch): tools is ToolsApi {\n return typeof (tools as ToolsApi).setActive === 'function';\n}\n\nconst presetSerials = new WeakMap<object, number>();\nlet nextSerial = 0;\nconst entryKey = (e: FeatureEntry): string => {\n if (typeof e === 'string') return e;\n let n = presetSerials.get(e);\n if (n === undefined) presetSerials.set(e, (n = nextSerial++));\n return `#${n}`;\n};\n\n/** The presets a canvas runs with. Keyed on the entries, not the array, so\n * an inline `features={['draw', pathTools]}` does not re-derive every render. */\nexport function useEnabledFeatures(\n features: readonly FeatureEntry[] | undefined,\n named: NamedPresets | null,\n hasViewport: boolean,\n selectRotates: boolean,\n): EnabledPresets {\n const featuresKey = (features ?? []).map(entryKey).join('|');\n return useMemo(\n () => resolveFeatures(features, named, { viewport: hasViewport, selectRotates }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [featuresKey, named, hasViewport, selectRotates],\n );\n}\n\n/**\n * The canvas's tools: a caller's own `ToolsApi` when the `tools` prop is one\n * (the takeover form), and otherwise the built-ins the presets and\n * `defaultTools` name, patched by a `tools` record.\n */\nexport function useCanvasTools(args: {\n /** The canvas's select tool, which is built from its scene and pickers. */\n select: Tool;\n enabled: EnabledPresets;\n tools: Props['tools'];\n defaultTools: Props['defaultTools'];\n toolOptions: Props['toolOptions'];\n /** `viewport.inertia`, which is the hand tool's. */\n inertia: NonNullable<Props['viewport']>['inertia'];\n ambient: Props['ambient'];\n /** `longPress.feedback`. Default true, which installs the kit's own. */\n pressFeedback: NonNullable<Props['longPress']>['feedback'];\n initialActiveTool: Props['initialActiveTool'];\n modes: Props['modes'];\n onToolsCreated: Props['onToolsCreated'];\n}): {\n /** What the canvas routes input through: the takeover, or `internal`. */\n tools: ToolsApi;\n /** The canvas's own api, built whether or not a takeover replaces it. */\n internal: ToolsApi;\n takeover: ToolsApi | null;\n} {\n const { select, enabled, tools: toolsProp, defaultTools, toolOptions, inertia, ambient, initialActiveTool, modes, onToolsCreated } = args;\n\n const takeover = toolsProp && isToolsApi(toolsProp) ? toolsProp : null;\n const registry = useBuiltinTools({\n select,\n enabled,\n defaultTools,\n patch: toolsProp && !isToolsApi(toolsProp) ? toolsProp : null,\n toolOptions,\n inertia,\n });\n\n const defaultPressFeedback = useMemo(() => createLongPressFeedbackContribution(), []);\n const feedbackOpt = args.pressFeedback ?? true;\n const pressFeedback = feedbackOpt === true ? defaultPressFeedback : feedbackOpt || null;\n const mergedAmbient = useMemo(\n () => [...presetContributions(enabled), ...(
|
|
1
|
+
{"version":3,"file":"useCanvasTools.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useCanvasTools.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Action } from '@weasel-js/routing';\nimport { createLongPressFeedbackContribution } from '../../features/longPress/longPressFeedback';\nimport { createViewMarkerContribution } from '../../features/viewports/viewMarkerDrag';\nimport { useTools, type Contribution, type Tool, type ToolsApi } from '../../tools/overlayBinding';\nimport {\n presetActions,\n presetAmbient,\n presetContributions,\n resolveFeatures,\n type EnabledPresets,\n type FeatureBindingOptions,\n type FeatureEntry,\n type NamedPresets,\n} from './features';\nimport type { SceneCanvasProps } from './props';\nimport type { ToolsPatch } from './toolRegistry';\nimport { useBuiltinTools } from './useBuiltinTools';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\n\n/** Discriminate the polymorphic `tools` prop: `ToolsApi` has `setActive`\n * / `active` / `registry`; the patch record shape has none of those. */\nfunction isToolsApi(tools: ToolsApi | ToolsPatch): tools is ToolsApi {\n return typeof (tools as ToolsApi).setActive === 'function';\n}\n\nconst presetSerials = new WeakMap<object, number>();\nlet nextSerial = 0;\nconst entryKey = (e: FeatureEntry): string => {\n if (typeof e === 'string') return e;\n let n = presetSerials.get(e);\n if (n === undefined) presetSerials.set(e, (n = nextSerial++));\n return `#${n}`;\n};\n\n/** The presets a canvas runs with. Keyed on the entries, not the array, so\n * an inline `features={['draw', pathTools]}` does not re-derive every render. */\nexport function useEnabledFeatures(\n features: readonly FeatureEntry[] | undefined,\n named: NamedPresets | null,\n hasViewport: boolean,\n selectRotates: boolean,\n): EnabledPresets {\n const featuresKey = (features ?? []).map(entryKey).join('|');\n return useMemo(\n () => resolveFeatures(features, named, { viewport: hasViewport, selectRotates }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [featuresKey, named, hasViewport, selectRotates],\n );\n}\n\n/**\n * The canvas's tools: a caller's own `ToolsApi` when the `tools` prop is one\n * (the takeover form), and otherwise the built-ins the presets and\n * `defaultTools` name, patched by a `tools` record.\n */\nexport function useCanvasTools(args: {\n /** The canvas's select tool, which is built from its scene and pickers. */\n select: Tool;\n /** The canvas's group entry and leave, or null where the select preset is off. */\n groupEntry: Contribution | null;\n enabled: EnabledPresets;\n tools: Props['tools'];\n defaultTools: Props['defaultTools'];\n toolOptions: Props['toolOptions'];\n /** `viewport.inertia`, which is the hand tool's. */\n inertia: NonNullable<Props['viewport']>['inertia'];\n ambient: Props['ambient'];\n /** `null` leaves out the kit's default actions, the marker drag among them. */\n actions: Props['actions'];\n /** `longPress.feedback`. Default true, which installs the kit's own. */\n pressFeedback: NonNullable<Props['longPress']>['feedback'];\n initialActiveTool: Props['initialActiveTool'];\n modes: Props['modes'];\n onToolsCreated: Props['onToolsCreated'];\n}): {\n /** What the canvas routes input through: the takeover, or `internal`. */\n tools: ToolsApi;\n /** The canvas's own api, built whether or not a takeover replaces it. */\n internal: ToolsApi;\n takeover: ToolsApi | null;\n} {\n const { select, enabled, tools: toolsProp, defaultTools, toolOptions, inertia, ambient, initialActiveTool, modes, onToolsCreated } = args;\n\n const takeover = toolsProp && isToolsApi(toolsProp) ? toolsProp : null;\n const registry = useBuiltinTools({\n select,\n enabled,\n defaultTools,\n patch: toolsProp && !isToolsApi(toolsProp) ? toolsProp : null,\n toolOptions,\n inertia,\n });\n\n const defaultPressFeedback = useMemo(() => createLongPressFeedbackContribution(), []);\n const feedbackOpt = args.pressFeedback ?? true;\n const pressFeedback = feedbackOpt === true ? defaultPressFeedback : feedbackOpt || null;\n const defaultMarkerDrag = useMemo(() => createViewMarkerContribution(), []);\n const markerDrag = args.actions === null ? null : defaultMarkerDrag;\n const groupEntry = args.actions === null ? null : args.groupEntry;\n const mergedAmbient = useMemo(\n () => [\n ...presetContributions(enabled), ...(groupEntry ? [groupEntry] : []), ...(ambient ?? []),\n ...(pressFeedback ? [pressFeedback] : []), ...(markerDrag ? [markerDrag] : []),\n ],\n [enabled, groupEntry, ambient, pressFeedback, markerDrag],\n );\n\n const internal = useTools({\n active: initialActiveTool ?? ('select' in registry ? 'select' : null),\n registry,\n ...(mergedAmbient.length ? { ambient: mergedAmbient } : {}),\n ...(modes ? { modes } : {}),\n });\n const tools = takeover ?? internal;\n\n const onToolsCreatedRef = useLatest(onToolsCreated);\n useEffect(() => { onToolsCreatedRef.current?.(tools); }, [tools, onToolsCreatedRef]);\n\n return { tools, internal, takeover };\n}\n\n/**\n * The presets' ambient bindings, and the standard actions the canvas\n * registers. The bindings are not tools and sit outside `tools`, so they apply\n * under a takeover too. An action is registered when an enabled preset brings\n * it, or when it is in `pool` and a tool or contribution on this canvas binds\n * it: a tool brings the actions it routes to, so `defaultTools={['rect']}`\n * works under any preset.\n */\nexport function useFeatureBindings(args: {\n enabled: EnabledPresets;\n /** Actions registered only when something binds them. */\n pool: readonly Action[];\n tools: Pick<ToolsApi, 'registry' | 'ambient'>;\n move: FeatureBindingOptions['move'];\n rotate: FeatureBindingOptions['rotate'];\n}): { contributions: Contribution[]; standardActions: Action[] } {\n const { enabled, pool, tools, move, rotate } = args;\n const contributions = useMemo<Contribution[]>(\n () => presetAmbient(enabled, { move, rotate }),\n [enabled, move, rotate],\n );\n const standardActions = useMemo(() => {\n const out = presetActions(enabled);\n const have = new Set(out.map((a) => a.id));\n const bound = new Set<string>();\n for (const entry of [...Object.values(tools.registry), ...tools.ambient, ...contributions]) {\n for (const b of entry.bindings ?? []) bound.add(b.actionId);\n }\n for (const a of pool) {\n if (bound.has(a.id) && !have.has(a.id)) {\n have.add(a.id);\n out.push(a);\n }\n }\n return out;\n }, [enabled, pool, tools, contributions]);\n return { contributions, standardActions };\n}\n\n"],"mappings":";;;;;;;;;;;AAwBA,SAAS,WAAW,OAAiD;CACnE,OAAO,OAAQ,MAAmB,cAAc;AAClD;AAEA,IAAM,gCAAgB,IAAI,QAAwB;AAClD,IAAI,aAAa;AACjB,IAAM,YAAY,MAA4B;CAC5C,IAAI,OAAO,MAAM,UAAU,OAAO;CAClC,IAAI,IAAI,cAAc,IAAI,CAAC;CAC3B,IAAI,MAAM,QAAW,cAAc,IAAI,GAAI,IAAI,YAAa;CAC5D,OAAO,IAAI;AACb;;;AAIA,SAAgB,mBACd,UACA,OACA,aACA,eACgB;CAChB,MAAM,eAAe,YAAY,CAAC,EAAA,CAAG,IAAI,QAAQ,CAAC,CAAC,KAAK,GAAG;CAC3D,OAAO,cACC,gBAAgB,UAAU,OAAO;EAAE,UAAU;EAAa;CAAc,CAAC,GAE/E;EAAC;EAAa;EAAO;EAAa;CAAa,CACjD;AACF;;;;;;AAOA,SAAgB,eAAe,MAyB7B;CACA,MAAM,EAAE,QAAQ,SAAS,OAAO,WAAW,cAAc,aAAa,SAAS,SAAS,mBAAmB,OAAO,mBAAmB;CAErI,MAAM,WAAW,aAAa,WAAW,SAAS,IAAI,YAAY;CAClE,MAAM,WAAW,gBAAgB;EAC/B;EACA;EACA;EACA,OAAO,aAAa,CAAC,WAAW,SAAS,IAAI,YAAY;EACzD;EACA;CACF,CAAC;CAED,MAAM,uBAAuB,cAAc,oCAAoC,GAAG,CAAC,CAAC;CACpF,MAAM,cAAc,KAAK,iBAAiB;CAC1C,MAAM,gBAAgB,gBAAgB,OAAO,uBAAuB,eAAe;CACnF,MAAM,oBAAoB,cAAc,6BAA6B,GAAG,CAAC,CAAC;CAC1E,MAAM,aAAa,KAAK,YAAY,OAAO,OAAO;CAClD,MAAM,aAAa,KAAK,YAAY,OAAO,OAAO,KAAK;CACvD,MAAM,gBAAgB,cACd;EACJ,GAAG,oBAAoB,OAAO;EAAG,GAAI,aAAa,CAAC,UAAU,IAAI,CAAC;EAAI,GAAI,WAAW,CAAC;EACtF,GAAI,gBAAgB,CAAC,aAAa,IAAI,CAAC;EAAI,GAAI,aAAa,CAAC,UAAU,IAAI,CAAC;CAC9E,GACA;EAAC;EAAS;EAAY;EAAS;EAAe;CAAU,CAC1D;CAEA,MAAM,WAAW,SAAS;EACxB,QAAQ,sBAAsB,YAAY,WAAW,WAAW;EAChE;EACA,GAAI,cAAc,SAAS,EAAE,SAAS,cAAc,IAAI,CAAC;EACzD,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;CACD,MAAM,QAAQ,YAAY;CAE1B,MAAM,oBAAoB,UAAU,cAAc;CAClD,gBAAgB;EAAE,kBAAkB,UAAU,KAAK;CAAG,GAAG,CAAC,OAAO,iBAAiB,CAAC;CAEnF,OAAO;EAAE;EAAO;EAAU;CAAS;AACrC;;;;;;;;;AAUA,SAAgB,mBAAmB,MAO8B;CAC/D,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,WAAW;CAC/C,MAAM,gBAAgB,cACd,cAAc,SAAS;EAAE;EAAM;CAAO,CAAC,GAC7C;EAAC;EAAS;EAAM;CAAM,CACxB;CAgBA,OAAO;EAAE;EAAe,iBAfA,cAAc;GACpC,MAAM,MAAM,cAAc,OAAO;GACjC,MAAM,OAAO,IAAI,IAAI,IAAI,KAAK,MAAM,EAAE,EAAE,CAAC;GACzC,MAAM,wBAAQ,IAAI,IAAY;GAC9B,KAAK,MAAM,SAAS;IAAC,GAAG,OAAO,OAAO,MAAM,QAAQ;IAAG,GAAG,MAAM;IAAS,GAAG;GAAa,GACvF,KAAK,MAAM,KAAK,MAAM,YAAY,CAAC,GAAG,MAAM,IAAI,EAAE,QAAQ;GAE5D,KAAK,MAAM,KAAK,MACd,IAAI,MAAM,IAAI,EAAE,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,GAAG;IACtC,KAAK,IAAI,EAAE,EAAE;IACb,IAAI,KAAK,CAAC;GACZ;GAEF,OAAO;EACT,GAAG;GAAC;GAAS;GAAM;GAAO;EAAa,CACf;CAAgB;AAC1C"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { deriveParallaxView } from "../../core/viewport/parallax.js";
|
|
2
|
-
import {
|
|
2
|
+
import { inheritedPaintOf, inheritsPaint, sceneAncestors } from "../../core/scene/inheritedPaint.js";
|
|
3
|
+
import { withShownData } from "../../core/scene/nodeAsShown.js";
|
|
3
4
|
import { planeTransform } from "../planeClips.js";
|
|
4
5
|
import { wrapWithPoseRotation } from "../poseRotation.js";
|
|
6
|
+
import { ownClipOf } from "../ownClip.js";
|
|
5
7
|
import { scenePaintedPoseOf } from "../derivedPath.js";
|
|
6
|
-
import { scenePlaneOf } from "../
|
|
8
|
+
import { scenePlaneOf } from "../scenePickSource.js";
|
|
7
9
|
import { copiesAbove } from "../copiesAbove.js";
|
|
8
10
|
import { isCustomEntry } from "../layerSlots.js";
|
|
9
11
|
import { previewSourcesFrom } from "../drawEnvelope.js";
|
|
10
|
-
import { resolvePreviews } from "../../interactions/actions/resolvePreviews.js";
|
|
12
|
+
import { flattenPreviews, resolvePreviews } from "../../interactions/actions/resolvePreviews.js";
|
|
11
13
|
import "@weasel-js/renderer";
|
|
12
14
|
import { mat3 as mat3$1 } from "@weasel-js/geom";
|
|
13
15
|
import { useEffect, useMemo, useReducer } from "react";
|
|
@@ -51,36 +53,40 @@ function usePreviewGhostLayer(args) {
|
|
|
51
53
|
const parallax = planeOf ? sc.layers.find((l) => l.id === layer)?.parallax : void 0;
|
|
52
54
|
return parallax ? deriveParallaxView(view, parallax) : view;
|
|
53
55
|
};
|
|
54
|
-
const drawEntry = (entry, parentPlane) => {
|
|
55
|
-
const effNode = entry.data === entry.node.data ? entry.node :
|
|
56
|
-
...entry.node,
|
|
57
|
-
data: entry.data
|
|
58
|
-
};
|
|
56
|
+
const drawEntry = (entry, parentPlane, above) => {
|
|
57
|
+
const effNode = entry.data === entry.node.data ? entry.node : withShownData(entry.node, entry.data);
|
|
59
58
|
const plane = mapOf(entry.node.layer);
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
59
|
+
const ctx = inheritsPaint(effNode) ? { inherited: inheritedPaintOf(effNode, above()) } : void 0;
|
|
60
|
+
const self = drawOne(effNode, entry.pose, viewOf(entry.node.layer), ctx);
|
|
61
|
+
const kids = [];
|
|
62
|
+
for (const child of entry.children) for (const cmd of drawEntry(child, plane, () => [effNode, ...above()])) kids.push(cmd);
|
|
63
|
+
const clip = kids.length > 0 ? ownClipOf(effNode, entry.pose, () => slot.derivedPathOf?.(effNode, entry.pose)) : null;
|
|
64
|
+
const children = [...wrapWithPoseRotation(self, entry.pose), ...clip ? [{
|
|
65
|
+
kind: "group",
|
|
66
|
+
clip,
|
|
67
|
+
children: kids
|
|
68
|
+
}] : kids];
|
|
63
69
|
const transform = planeTransform(plane, parentPlane);
|
|
64
|
-
|
|
70
|
+
return [transform ? {
|
|
65
71
|
kind: "group",
|
|
66
72
|
transform,
|
|
67
73
|
children
|
|
68
74
|
} : {
|
|
69
75
|
kind: "group",
|
|
70
76
|
children
|
|
71
|
-
};
|
|
72
|
-
if (effNode.kind === "container") {
|
|
73
|
-
const clip = findShapeSilhouette(effNode, entry.pose, { derivedPath: slot.derivedPathOf?.(effNode, entry.pose) ?? null });
|
|
74
|
-
if (clip) group.clip = clip;
|
|
75
|
-
}
|
|
76
|
-
return [group];
|
|
77
|
+
}];
|
|
77
78
|
};
|
|
78
79
|
const ghosted = [];
|
|
79
80
|
const settled = [];
|
|
80
81
|
const paintedPose = scenePaintedPoseOf(sc);
|
|
82
|
+
const previewed = new Map(flattenPreviews(roots).map((e) => [e.id, e.data]));
|
|
83
|
+
const asPreviewed = (n) => previewed.has(n.id) ? {
|
|
84
|
+
kind: n.kind,
|
|
85
|
+
data: previewed.get(n.id)
|
|
86
|
+
} : n;
|
|
81
87
|
for (const root of roots) {
|
|
82
88
|
const sink = root.opaque ? settled : ghosted;
|
|
83
|
-
const cmds = drawEntry(root, null);
|
|
89
|
+
const cmds = drawEntry(root, null, () => [...sceneAncestors((id) => sc.get(id), root.node)].map(asPreviewed));
|
|
84
90
|
for (const cmd of cmds) sink.push(cmd);
|
|
85
91
|
for (const m of copiesAbove(sc, root.node.id, paintedPose)) sink.push({
|
|
86
92
|
kind: "group",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewGhostLayer.js","names":["mat3"],"sources":["../../../src/canvas/SceneCanvas/usePreviewGhostLayer.ts"],"sourcesContent":["/**\n * Preview-ghost render layer for `<SceneCanvas>`. Renders in-flight gesture\n * poses on top of the committed scene by reusing the scene slot's `drawOne`.\n * Which ids are displaced (`previewIds`) and where (`previewPose`) comes from\n * the drawing view's preview sources on the draw envelope: that view's\n * in-flight handles.\n *\n * This replaces the per-tool `drawGhost` fold-in — a single SceneCanvas\n * concern instead of every consumer wiring it.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { type DrawCommand, type GroupDrawCommand } from '@weasel-js/renderer';\nimport type { RenderLayer } from 'core/layers/render';\nimport { isCustomEntry, type LayersMap } from '../layerSlots';\nimport type { Node, Scene } from 'core/scene/types';\nimport {
|
|
1
|
+
{"version":3,"file":"usePreviewGhostLayer.js","names":["mat3"],"sources":["../../../src/canvas/SceneCanvas/usePreviewGhostLayer.ts"],"sourcesContent":["/**\n * Preview-ghost render layer for `<SceneCanvas>`. Renders in-flight gesture\n * poses on top of the committed scene by reusing the scene slot's `drawOne`.\n * Which ids are displaced (`previewIds`) and where (`previewPose`) comes from\n * the drawing view's preview sources on the draw envelope: that view's\n * in-flight handles.\n *\n * This replaces the per-tool `drawGhost` fold-in — a single SceneCanvas\n * concern instead of every consumer wiring it.\n */\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { type DrawCommand, type GroupDrawCommand } from '@weasel-js/renderer';\nimport type { RenderLayer } from 'core/layers/render';\nimport { isCustomEntry, type LayersMap } from '../layerSlots';\nimport type { Node, Scene } from 'core/scene/types';\nimport { ownClipOf } from '../ownClip';\nimport { wrapWithPoseRotation } from '../poseRotation';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport { previewSourcesFrom } from '../drawEnvelope';\nimport { flattenPreviews, resolvePreviews, type PreviewNode } from 'interactions/actions/resolvePreviews';\nimport { scenePlaneOf } from '../pickWalk';\nimport { planeTransform } from '../planeClips';\nimport { deriveParallaxView } from 'core/viewport/parallax';\nimport type { PlaneMap } from 'core/viewport/parallax';\nimport { mat3 } from '@weasel-js/geom';\nimport { copiesAbove } from '../copiesAbove';\nimport { scenePaintedPoseOf } from '../derivedPath';\nimport { inheritedPaintOf, inheritsPaint, sceneAncestors } from 'core/scene/inheritedPaint';\nimport { withShownData } from 'core/scene/nodeAsShown';\n\nconst GHOST_ALPHA = 0.85;\n\nexport function usePreviewGhostLayer<TData, TLayer extends string, TPose>(args: {\n scene: Scene<TData, TLayer, TPose>;\n sceneSlot: LayersMap<Node<TData, TLayer, TPose>, TPose>['scene'];\n /**\n * The surface's dispatcher, subscribed to only so a pump repaints — preview\n * poses mutate silently inside handles otherwise. What gets *painted* is the\n * drawing view's own `getPreviewSources()`, off the draw envelope.\n */\n dispatcher?: Dispatcher | null;\n}): RenderLayer<unknown> {\n const { scene, sceneSlot, dispatcher } = args;\n\n // Refs let the layer body read the last committed scene/slot without\n // re-creating the layer on every host render.\n const sceneRef = useLatest(scene);\n const sceneSlotRef = useLatest(sceneSlot);\n\n // Subscribe to dispatcher state changes so the canvas re-renders on every\n // ongoing-action pump (preview poses mutate silently inside handles\n // otherwise — single-frame ghost stuck on the start pose).\n const [, forceRerender] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n if (!dispatcher) return;\n const unsub = dispatcher.subscribe(forceRerender);\n return unsub;\n }, [dispatcher]);\n\n return useMemo<RenderLayer<unknown>>(() => ({\n id: 'preview-ghost',\n label: 'Preview ghost',\n draw: (data, view) => {\n const slot = sceneSlotRef.current;\n if (!slot || isCustomEntry(slot) || !slot.drawOne) return [];\n const drawOne = slot.drawOne;\n // Whose gesture this frame is showing belongs to the view being drawn,\n // not to the surface that built the layer.\n const sources = previewSourcesFrom(data);\n const sc = sceneRef.current;\n const roots = resolvePreviews(sources, sc);\n if (roots.length === 0) return [];\n\n // A node on a parallax layer ghosts where its plane draws it: through\n // the plane's view, inside a group carrying it into its parent's world.\n const planeOf = scenePlaneOf(sc.layers, view);\n const mapOf = (layer: string): PlaneMap | null => planeOf?.(layer) ?? null;\n const viewOf = (layer: string) => {\n const parallax = planeOf ? sc.layers.find((l) => l.id === layer)?.parallax : undefined;\n return parallax ? deriveParallaxView(view, parallax) : view;\n };\n\n // Mirrors buildSceneTree's structure, but drawn from the previewed pose\n // and data, so children are clipped to the shape the node is taking and\n // inherit the paint it is taking. `above` is its containers, innermost first.\n const drawEntry = (\n entry: PreviewNode<TData, TLayer, TPose>,\n parentPlane: PlaneMap | null,\n above: () => Iterable<{ kind?: string; data?: unknown }>,\n ): DrawCommand[] => {\n const effNode = entry.data === entry.node.data ? entry.node : withShownData(entry.node, entry.data);\n const plane = mapOf(entry.node.layer);\n const ctx = inheritsPaint(effNode) ? { inherited: inheritedPaintOf(effNode, above()) } : undefined;\n const self = drawOne(effNode, entry.pose, viewOf(entry.node.layer), ctx);\n const kids: DrawCommand[] = [];\n for (const child of entry.children) {\n for (const cmd of drawEntry(child, plane, () => [effNode, ...above()])) kids.push(cmd);\n }\n // The node's clip is its children's, not its own paint's.\n const clip = kids.length > 0\n ? ownClipOf(effNode, entry.pose, () => slot.derivedPathOf?.(effNode, entry.pose)) : null;\n const children: DrawCommand[] = [\n ...wrapWithPoseRotation(self, entry.pose as unknown),\n ...(clip ? [{ kind: 'group', clip, children: kids } as GroupDrawCommand] : kids),\n ];\n const transform = planeTransform(plane, parentPlane);\n return [transform ? { kind: 'group', transform, children } : { kind: 'group', children }];\n };\n\n // Opaque is honored at subtree-root granularity, as it always was: a\n // sibling reflowing into place brings its own contents with it.\n const ghosted: DrawCommand[] = [];\n const settled: DrawCommand[] = [];\n // A node an ancestor draws copies of is ghosted in each copy too, or\n // the copies vanish for the length of the gesture.\n const paintedPose = scenePaintedPoseOf(sc);\n // A root's containers are read as previewed too, where one is.\n const previewed = new Map(flattenPreviews(roots).map((e) => [e.id as string, e.data]));\n const asPreviewed = (n: Node<TData, TLayer, TPose>) => (previewed.has(n.id) ? { kind: n.kind, data: previewed.get(n.id) } : n);\n for (const root of roots) {\n const sink = root.opaque ? settled : ghosted;\n const cmds = drawEntry(root, null, () => [...sceneAncestors((id: never) => sc.get(id), root.node)].map(asPreviewed));\n for (const cmd of cmds) sink.push(cmd);\n for (const m of copiesAbove(sc, root.node.id, paintedPose)) {\n sink.push({ kind: 'group', transform: mat3.fromAffine(m), children: cmds });\n }\n }\n if (ghosted.length === 0 && settled.length === 0) return [];\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n const out: DrawCommand[] = [];\n if (settled.length > 0) out.push({ kind: 'group', children: settled });\n if (ghosted.length > 0) out.push({ kind: 'group', alpha: GHOST_ALPHA, children: ghosted });\n return out;\n },\n }), [sceneRef, sceneSlotRef]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,cAAc;AAEpB,SAAgB,qBAA0D,MASjD;CACvB,MAAM,EAAE,OAAO,WAAW,eAAe;CAIzC,MAAM,WAAW,UAAU,KAAK;CAChC,MAAM,eAAe,UAAU,SAAS;CAKxC,MAAM,GAAG,iBAAiB,YAAY,MAAc,IAAI,GAAG,CAAC;CAC5D,gBAAgB;EACd,IAAI,CAAC,YAAY;EAEjB,OADc,WAAW,UAAU,aAC5B;CACT,GAAG,CAAC,UAAU,CAAC;CAEf,OAAO,eAAqC;EAC1C,IAAI;EACJ,OAAO;EACP,OAAO,MAAM,SAAS;GACpB,MAAM,OAAO,aAAa;GAC1B,IAAI,CAAC,QAAQ,cAAc,IAAI,KAAK,CAAC,KAAK,SAAS,OAAO,CAAC;GAC3D,MAAM,UAAU,KAAK;GAGrB,MAAM,UAAU,mBAAmB,IAAI;GACvC,MAAM,KAAK,SAAS;GACpB,MAAM,QAAQ,gBAAgB,SAAS,EAAE;GACzC,IAAI,MAAM,WAAW,GAAG,OAAO,CAAC;GAIhC,MAAM,UAAU,aAAa,GAAG,QAAQ,IAAI;GAC5C,MAAM,SAAS,UAAmC,UAAU,KAAK,KAAK;GACtE,MAAM,UAAU,UAAkB;IAChC,MAAM,WAAW,UAAU,GAAG,OAAO,MAAM,MAAM,EAAE,OAAO,KAAK,CAAC,EAAE,WAAW;IAC7E,OAAO,WAAW,mBAAmB,MAAM,QAAQ,IAAI;GACzD;GAKA,MAAM,aACJ,OACA,aACA,UACkB;IAClB,MAAM,UAAU,MAAM,SAAS,MAAM,KAAK,OAAO,MAAM,OAAO,cAAc,MAAM,MAAM,MAAM,IAAI;IAClG,MAAM,QAAQ,MAAM,MAAM,KAAK,KAAK;IACpC,MAAM,MAAM,cAAc,OAAO,IAAI,EAAE,WAAW,iBAAiB,SAAS,MAAM,CAAC,EAAE,IAAI;IACzF,MAAM,OAAO,QAAQ,SAAS,MAAM,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG,GAAG;IACvE,MAAM,OAAsB,CAAC;IAC7B,KAAK,MAAM,SAAS,MAAM,UACxB,KAAK,MAAM,OAAO,UAAU,OAAO,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,KAAK,GAAG;IAGvF,MAAM,OAAO,KAAK,SAAS,IACvB,UAAU,SAAS,MAAM,YAAY,KAAK,gBAAgB,SAAS,MAAM,IAAI,CAAC,IAAI;IACtF,MAAM,WAA0B,CAC9B,GAAG,qBAAqB,MAAM,MAAM,IAAe,GACnD,GAAI,OAAO,CAAC;KAAE,MAAM;KAAS;KAAM,UAAU;IAAK,CAAqB,IAAI,IAC7E;IACA,MAAM,YAAY,eAAe,OAAO,WAAW;IACnD,OAAO,CAAC,YAAY;KAAE,MAAM;KAAS;KAAW;IAAS,IAAI;KAAE,MAAM;KAAS;IAAS,CAAC;GAC1F;GAIA,MAAM,UAAyB,CAAC;GAChC,MAAM,UAAyB,CAAC;GAGhC,MAAM,cAAc,mBAAmB,EAAE;GAEzC,MAAM,YAAY,IAAI,IAAI,gBAAgB,KAAK,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,IAAc,EAAE,IAAI,CAAC,CAAC;GACrF,MAAM,eAAe,MAAmC,UAAU,IAAI,EAAE,EAAE,IAAI;IAAE,MAAM,EAAE;IAAM,MAAM,UAAU,IAAI,EAAE,EAAE;GAAE,IAAI;GAC5H,KAAK,MAAM,QAAQ,OAAO;IACxB,MAAM,OAAO,KAAK,SAAS,UAAU;IACrC,MAAM,OAAO,UAAU,MAAM,YAAY,CAAC,GAAG,gBAAgB,OAAc,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;IACnH,KAAK,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;IACrC,KAAK,MAAM,KAAK,YAAY,IAAI,KAAK,KAAK,IAAI,WAAW,GACvD,KAAK,KAAK;KAAE,MAAM;KAAS,WAAWA,OAAK,WAAW,CAAC;KAAG,UAAU;IAAK,CAAC;GAE9E;GACA,IAAI,QAAQ,WAAW,KAAK,QAAQ,WAAW,GAAG,OAAO,CAAC;GAE1D,MAAM,MAAqB,CAAC;GAC5B,IAAI,QAAQ,SAAS,GAAG,IAAI,KAAK;IAAE,MAAM;IAAS,UAAU;GAAQ,CAAC;GACrE,IAAI,QAAQ,SAAS,GAAG,IAAI,KAAK;IAAE,MAAM;IAAS,OAAO;IAAa,UAAU;GAAQ,CAAC;GACzF,OAAO;EACT;CACF,IAAI,CAAC,UAAU,YAAY,CAAC;AAC9B"}
|
|
@@ -26,7 +26,9 @@ function useAddedViews() {
|
|
|
26
26
|
w: 0,
|
|
27
27
|
h: 0
|
|
28
28
|
}
|
|
29
|
-
}, [surfaceViewRegistry])
|
|
29
|
+
}, [surfaceViewRegistry]),
|
|
30
|
+
aimOf: useCallback((id) => surfaceViewRegistry?.aimOf(id) ?? null, [surfaceViewRegistry]),
|
|
31
|
+
setAim: useCallback((id, aim) => surfaceViewRegistry?.setAim(id, aim) ?? false, [surfaceViewRegistry])
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
@@ -35,7 +37,7 @@ function useAddedViews() {
|
|
|
35
37
|
* and keeps the canvas's own copies of the element and the handle current.
|
|
36
38
|
*/
|
|
37
39
|
function useSceneCanvasHandle(args) {
|
|
38
|
-
const { ref, elementRef, apiRef, onElement, ingest, viewAnimation, camera, addView, viewAt } = args;
|
|
40
|
+
const { ref, elementRef, apiRef, onElement, ingest, viewAnimation, camera, addView, viewAt, aimOf, setAim } = args;
|
|
39
41
|
const [ready, setReady] = useState(false);
|
|
40
42
|
return {
|
|
41
43
|
handleRef: useCallback((node) => {
|
|
@@ -49,7 +51,9 @@ function useSceneCanvasHandle(args) {
|
|
|
49
51
|
isViewAnimating: viewAnimation.isAnimating,
|
|
50
52
|
camera,
|
|
51
53
|
addView,
|
|
52
|
-
viewAt
|
|
54
|
+
viewAt,
|
|
55
|
+
aimOf,
|
|
56
|
+
setAim
|
|
53
57
|
} : null;
|
|
54
58
|
apiRef.current = extended;
|
|
55
59
|
setReady(extended !== null);
|
|
@@ -63,6 +67,8 @@ function useSceneCanvasHandle(args) {
|
|
|
63
67
|
camera,
|
|
64
68
|
addView,
|
|
65
69
|
viewAt,
|
|
70
|
+
aimOf,
|
|
71
|
+
setAim,
|
|
66
72
|
onElement
|
|
67
73
|
]),
|
|
68
74
|
ready
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSceneCanvasHandle.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneCanvasHandle.ts"],"sourcesContent":["import { useCallback, useState, type ForwardedRef, type MutableRefObject } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport type { ViewAnimationApi } from 'core/viewport/useViewAnimation';\nimport type { CanvasViewProps } from '../CanvasView';\nimport type { CanvasExtensionApi, CanvasViewHandle, SceneCanvasApi } from '../canvasExtension';\nimport { IDENTITY_VIEW, useOptionalViewRegistry } from '../viewRegistry';\n\n/** Views added through the handle rather than declared as props or children. */\nexport function useAddedViews(): {\n views: readonly CanvasViewProps[];\n addView: SceneCanvasApi['addView'];\n viewAt: SceneCanvasApi['viewAt'];\n} {\n const surfaceViewRegistry = useOptionalViewRegistry();\n const [views, setViews] = useState<readonly CanvasViewProps[]>([]);\n const addView = useCallback((props: CanvasViewProps): CanvasViewHandle => {\n setViews((list) => [...list.filter((v) => v.id !== props.id), props]);\n return {\n id: props.id,\n draw: (data, outer, dims) =>\n surfaceViewRegistry?.list().find((r) => r.id === props.id)?.layer.draw(data, outer, dims) ?? [],\n remove: () => setViews((list) => list.filter((v) => v !== props)),\n };\n }, [surfaceViewRegistry]);\n const viewAt = useCallback<SceneCanvasApi['viewAt']>((at, opts) => (\n surfaceViewRegistry?.viewAt(at, opts) ?? { id: null, view: IDENTITY_VIEW, rect: { x: 0, y: 0, w: 0, h: 0 } }\n ), [surfaceViewRegistry]);\n return { views, addView, viewAt };\n}\n\n/**\n * The ref callback `<SceneCanvas>` hands `<Canvas>`. It extends the\n * primitive's handle into the `SceneCanvasApi` the consumer's ref receives,\n * and keeps the canvas's own copies of the element and the handle current.\n */\nexport function useSceneCanvasHandle(args: {\n ref: ForwardedRef<SceneCanvasApi>;\n /** Written with the canvas element, for the input listeners. */\n elementRef: MutableRefObject<HTMLElement | null>;\n /** Written with the extended handle, for `requestRedraw` and point conversion. */\n apiRef: MutableRefObject<CanvasExtensionApi | null>;\n /** Told the element whenever it attaches or detaches. */\n onElement: (element: HTMLElement | null) => void;\n ingest: SceneCanvasApi['ingest'];\n viewAnimation: Pick<ViewAnimationApi, 'animate' | 'stop' | 'isAnimating'>;\n camera: SceneCanvasApi['camera'];\n addView: SceneCanvasApi['addView'];\n viewAt: SceneCanvasApi['viewAt'];\n}): {\n handleRef: (node: CanvasExtensionApi | null) => void;\n /** Whether the handle is attached, as state: an effect needing the handle\n * keys off this instead of assuming when React attaches it. */\n ready: boolean;\n} {\n const { ref, elementRef, apiRef, onElement, ingest, viewAnimation, camera, addView, viewAt } = args;\n const [ready, setReady] = useState(false);\n const handleRef = useCallback(\n (node: CanvasExtensionApi | null) => {\n elementRef.current = node?.element ?? null;\n onElement(elementRef.current);\n const extended: SceneCanvasApi | null = node\n ? {\n ...node,\n ingest,\n animateView: viewAnimation.animate,\n stopViewAnimation: viewAnimation.stop,\n isViewAnimating: viewAnimation.isAnimating,\n camera,\n addView,\n viewAt,\n }\n : null;\n apiRef.current = extended;\n setReady(extended !== null);\n assignRef(ref, extended);\n },\n [ref, elementRef, apiRef, ingest, viewAnimation, camera, addView, viewAt, onElement],\n );\n return { handleRef, ready };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,
|
|
1
|
+
{"version":3,"file":"useSceneCanvasHandle.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneCanvasHandle.ts"],"sourcesContent":["import { useCallback, useState, type ForwardedRef, type MutableRefObject } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport type { ViewAnimationApi } from 'core/viewport/useViewAnimation';\nimport type { CanvasViewProps } from '../CanvasView';\nimport type { CanvasExtensionApi, CanvasViewHandle, SceneCanvasApi } from '../canvasExtension';\nimport { IDENTITY_VIEW, useOptionalViewRegistry } from '../viewRegistry';\n\n/** Views added through the handle rather than declared as props or children. */\nexport function useAddedViews(): {\n views: readonly CanvasViewProps[];\n addView: SceneCanvasApi['addView'];\n viewAt: SceneCanvasApi['viewAt'];\n aimOf: SceneCanvasApi['aimOf'];\n setAim: SceneCanvasApi['setAim'];\n} {\n const surfaceViewRegistry = useOptionalViewRegistry();\n const [views, setViews] = useState<readonly CanvasViewProps[]>([]);\n const addView = useCallback((props: CanvasViewProps): CanvasViewHandle => {\n setViews((list) => [...list.filter((v) => v.id !== props.id), props]);\n return {\n id: props.id,\n draw: (data, outer, dims) =>\n surfaceViewRegistry?.list().find((r) => r.id === props.id)?.layer.draw(data, outer, dims) ?? [],\n remove: () => setViews((list) => list.filter((v) => v !== props)),\n };\n }, [surfaceViewRegistry]);\n const viewAt = useCallback<SceneCanvasApi['viewAt']>((at, opts) => (\n surfaceViewRegistry?.viewAt(at, opts) ?? { id: null, view: IDENTITY_VIEW, rect: { x: 0, y: 0, w: 0, h: 0 } }\n ), [surfaceViewRegistry]);\n const aimOf = useCallback<SceneCanvasApi['aimOf']>(\n (id) => surfaceViewRegistry?.aimOf(id) ?? null, [surfaceViewRegistry]);\n const setAim = useCallback<SceneCanvasApi['setAim']>(\n (id, aim) => surfaceViewRegistry?.setAim(id, aim) ?? false, [surfaceViewRegistry]);\n return { views, addView, viewAt, aimOf, setAim };\n}\n\n/**\n * The ref callback `<SceneCanvas>` hands `<Canvas>`. It extends the\n * primitive's handle into the `SceneCanvasApi` the consumer's ref receives,\n * and keeps the canvas's own copies of the element and the handle current.\n */\nexport function useSceneCanvasHandle(args: {\n ref: ForwardedRef<SceneCanvasApi>;\n /** Written with the canvas element, for the input listeners. */\n elementRef: MutableRefObject<HTMLElement | null>;\n /** Written with the extended handle, for `requestRedraw` and point conversion. */\n apiRef: MutableRefObject<CanvasExtensionApi | null>;\n /** Told the element whenever it attaches or detaches. */\n onElement: (element: HTMLElement | null) => void;\n ingest: SceneCanvasApi['ingest'];\n viewAnimation: Pick<ViewAnimationApi, 'animate' | 'stop' | 'isAnimating'>;\n camera: SceneCanvasApi['camera'];\n addView: SceneCanvasApi['addView'];\n viewAt: SceneCanvasApi['viewAt'];\n aimOf: SceneCanvasApi['aimOf'];\n setAim: SceneCanvasApi['setAim'];\n}): {\n handleRef: (node: CanvasExtensionApi | null) => void;\n /** Whether the handle is attached, as state: an effect needing the handle\n * keys off this instead of assuming when React attaches it. */\n ready: boolean;\n} {\n const { ref, elementRef, apiRef, onElement, ingest, viewAnimation, camera, addView, viewAt, aimOf, setAim } = args;\n const [ready, setReady] = useState(false);\n const handleRef = useCallback(\n (node: CanvasExtensionApi | null) => {\n elementRef.current = node?.element ?? null;\n onElement(elementRef.current);\n const extended: SceneCanvasApi | null = node\n ? {\n ...node,\n ingest,\n animateView: viewAnimation.animate,\n stopViewAnimation: viewAnimation.stop,\n isViewAnimating: viewAnimation.isAnimating,\n camera,\n addView,\n viewAt,\n aimOf,\n setAim,\n }\n : null;\n apiRef.current = extended;\n setReady(extended !== null);\n assignRef(ref, extended);\n },\n [ref, elementRef, apiRef, ingest, viewAnimation, camera, addView, viewAt, aimOf, setAim, onElement],\n );\n return { handleRef, ready };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,gBAMd;CACA,MAAM,sBAAsB,wBAAwB;CACpD,MAAM,CAAC,OAAO,YAAY,SAAqC,CAAC,CAAC;CAiBjE,OAAO;EAAE;EAAO,SAhBA,aAAa,UAA6C;GACxE,UAAU,SAAS,CAAC,GAAG,KAAK,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,GAAG,KAAK,CAAC;GACpE,OAAO;IACL,IAAI,MAAM;IACV,OAAO,MAAM,OAAO,SAClB,qBAAqB,KAAK,CAAC,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC;IAChG,cAAc,UAAU,SAAS,KAAK,QAAQ,MAAM,MAAM,KAAK,CAAC;GAClE;EACF,GAAG,CAAC,mBAAmB,CAQP;EAAS,QAPV,aAAuC,IAAI,SACxD,qBAAqB,OAAO,IAAI,IAAI,KAAK;GAAE,IAAI;GAAM,MAAM;GAAe,MAAM;IAAE,GAAG;IAAG,GAAG;IAAG,GAAG;IAAG,GAAG;GAAE;EAAE,GAC1G,CAAC,mBAAmB,CAKE;EAAQ,OAJnB,aACX,OAAO,qBAAqB,MAAM,EAAE,KAAK,MAAM,CAAC,mBAAmB,CAGrC;EAAO,QAFzB,aACZ,IAAI,QAAQ,qBAAqB,OAAO,IAAI,GAAG,KAAK,OAAO,CAAC,mBAAmB,CAC1C;CAAO;AACjD;;;;;;AAOA,SAAgB,qBAAqB,MAoBnC;CACA,MAAM,EAAE,KAAK,YAAY,QAAQ,WAAW,QAAQ,eAAe,QAAQ,SAAS,QAAQ,OAAO,WAAW;CAC9G,MAAM,CAAC,OAAO,YAAY,SAAS,KAAK;CAyBxC,OAAO;EAAE,WAxBS,aACf,SAAoC;GACnC,WAAW,UAAU,MAAM,WAAW;GACtC,UAAU,WAAW,OAAO;GAC5B,MAAM,WAAkC,OACpC;IACE,GAAG;IACH;IACA,aAAa,cAAc;IAC3B,mBAAmB,cAAc;IACjC,iBAAiB,cAAc;IAC/B;IACA;IACA;IACA;IACA;GACF,IACA;GACJ,OAAO,UAAU;GACjB,SAAS,aAAa,IAAI;GAC1B,UAAU,KAAK,QAAQ;EACzB,GACA;GAAC;GAAK;GAAY;GAAQ;GAAQ;GAAe;GAAQ;GAAS;GAAQ;GAAO;GAAQ;EAAS,CAE3F;EAAW;CAAM;AAC5B"}
|