@weasel-js/core 1.11.0 → 1.12.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 +611 -0
- package/README.md +1 -1
- package/dist/WeaselProvider.js +1 -1
- package/dist/affordances/pathAnchors.js +10 -6
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/animation/index.js +3 -3
- package/dist/animation/rig/bindRig.js +1 -1
- package/dist/animation/rig/rigNode.js.map +1 -1
- package/dist/barrel/canvas.js +9 -3
- package/dist/barrel/interactions.js +5 -4
- package/dist/barrel/paint.js +4 -4
- package/dist/barrel/paths.js +10 -6
- package/dist/barrel/renderer.js +5 -3
- package/dist/barrel/routing.js +7 -12
- package/dist/barrel/scene.js +9 -5
- package/dist/barrel/text.js +2 -2
- package/dist/barrel/viewport.js +9 -4
- package/dist/canvas/Canvas.js +5 -2
- 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 +4 -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 +17 -3
- 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/builtinToolSets.js +30 -0
- package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js +2 -0
- package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
- package/dist/canvas/SceneCanvas/coordTrace.js +5 -16
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +5 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +45 -5
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js +1 -11
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/scenePointQuery.js +7 -3
- package/dist/canvas/SceneCanvas/scenePointQuery.js.map +1 -1
- package/dist/canvas/SceneCanvas/toolRegistry.js +8 -4
- package/dist/canvas/SceneCanvas/toolRegistry.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/useActionsPropResolver.js +1 -11
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useBuiltinTools.js +2 -9
- package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js +94 -0
- package/dist/canvas/SceneCanvas/useCanvasDevtoolsRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/useCanvasSelection.js +7 -2
- package/dist/canvas/SceneCanvas/useCanvasSelection.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasTools.js +15 -10
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useNodeKinds.js +1 -1
- package/dist/canvas/SceneCanvas/useNodeKinds.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 +23 -4
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +2 -3
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneChrome.js +6 -7
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +24 -7
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useScenePicking.js +2 -3
- package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +2 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +5 -5
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +27 -24
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SurfaceCanvas.js +5 -22
- package/dist/canvas/SurfaceCanvas.js.map +1 -1
- package/dist/canvas/ViewMarker.js +35 -0
- package/dist/canvas/ViewMarker.js.map +1 -0
- package/dist/canvas/canvasRenderer.js +9 -5
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/contextAttributes.js +14 -0
- package/dist/canvas/contextAttributes.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +2 -0
- package/dist/canvas/defaultDrawOne.js.map +1 -1
- package/dist/canvas/deps/booleans.js +2 -1
- package/dist/canvas/deps/booleans.js.map +1 -1
- package/dist/canvas/deps/editAnchors.js +9 -113
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/hitTestArea.js +2 -2
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/insert.js +10 -4
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/pathEditCommits.js +189 -0
- package/dist/canvas/deps/pathEditCommits.js.map +1 -0
- package/dist/canvas/deps/snap.js +12 -9
- package/dist/canvas/deps/snap.js.map +1 -1
- package/dist/canvas/deps/transformFollowers.js +20 -0
- package/dist/canvas/deps/transformFollowers.js.map +1 -0
- package/dist/canvas/derivedPath.js +20 -1
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/drawnBounds.js +38 -4
- package/dist/canvas/drawnBounds.js.map +1 -1
- package/dist/canvas/inheritedPaints.js +44 -0
- package/dist/canvas/inheritedPaints.js.map +1 -0
- package/dist/canvas/nodeShapes/derivedPainter.js +23 -16
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -1
- package/dist/canvas/nodeShapes/nodePaint.js +13 -34
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -1
- package/dist/canvas/nodeShapes/pathPainter.js +12 -10
- 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 +12 -11
- 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/overlayRoleStrokes.js +12 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/pathOverlay.js +27 -7
- package/dist/canvas/pathOverlay.js.map +1 -1
- package/dist/canvas/pickReach.js +3 -3
- package/dist/canvas/pickReach.js.map +1 -1
- package/dist/canvas/pickWalk.js +3 -1
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/renderDebugSnapshot.js +1 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -1
- package/dist/canvas/renderSceneToPixels.js +7 -6
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneSlotWiring.js +2 -1
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +2 -1
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/surfaceContribution.js +12 -8
- package/dist/canvas/surfaceContribution.js.map +1 -1
- package/dist/canvas/useCanvasPaint.js +2 -1
- package/dist/canvas/useCanvasPaint.js.map +1 -1
- package/dist/canvas/useCanvasView.js +4 -2
- package/dist/canvas/useCanvasView.js.map +1 -1
- package/dist/canvas/useInFlightBounds.js +52 -0
- package/dist/canvas/useInFlightBounds.js.map +1 -0
- package/dist/canvas/useLayerStack.js +6 -2
- package/dist/canvas/useLayerStack.js.map +1 -1
- package/dist/canvas/useViewAim.js +121 -0
- package/dist/canvas/useViewAim.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +7 -9
- package/dist/canvas/useViewHelpers.js.map +1 -1
- 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 +3 -2
- package/dist/{clone-DZDrfIlU.d.ts → clone-C3e0OTuF.d.ts} +8 -21
- package/dist/clone.d.ts +4 -3
- package/dist/core/geometry/autoPoseDescriptor.js +1 -1
- package/dist/core/ops/setDependsOn.js +37 -0
- package/dist/core/ops/setDependsOn.js.map +1 -0
- package/dist/core/ops/writtenBy.js +53 -0
- package/dist/core/ops/writtenBy.js.map +1 -0
- package/dist/core/pages/fitViewToPage.js +12 -1
- package/dist/core/pages/fitViewToPage.js.map +1 -1
- package/dist/core/pages/pageEdits.js +163 -0
- package/dist/core/pages/pageEdits.js.map +1 -0
- package/dist/core/pages/pages.js +30 -1
- package/dist/core/pages/pages.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 +8 -3
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/arrivalWindow.js.map +1 -1
- package/dist/core/scene/carryDescendants.js +51 -0
- package/dist/core/scene/carryDescendants.js.map +1 -0
- package/dist/core/scene/clipNothing.js +13 -0
- package/dist/core/scene/clipNothing.js.map +1 -0
- package/dist/core/scene/depMemo.js +11 -3
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/dependents.js +7 -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/docValues.js +57 -0
- package/dist/core/scene/docValues.js.map +1 -0
- package/dist/core/scene/editPass.js +111 -0
- package/dist/core/scene/editPass.js.map +1 -0
- package/dist/core/scene/effectivePose.js +13 -2
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/fieldEdits.js +4 -1
- 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/historyFacade.js +1 -0
- package/dist/core/scene/historyFacade.js.map +1 -1
- package/dist/core/scene/inheritedPaint.js +75 -0
- package/dist/core/scene/inheritedPaint.js.map +1 -0
- package/dist/core/scene/kitRegistry.js +5 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layoutPass.js +28 -3
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +15 -7
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/pathEffects/blend.js.map +1 -1
- package/dist/core/scene/pathEffects/derive.js +7 -2
- 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/textAlong.js +95 -0
- package/dist/core/scene/pathEffects/textAlong.js.map +1 -0
- package/dist/core/scene/recorder.js +28 -19
- package/dist/core/scene/recorder.js.map +1 -1
- package/dist/core/scene/scene.js +15 -9
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneChanges.js +13 -0
- package/dist/core/scene/sceneChanges.js.map +1 -0
- package/dist/core/scene/sceneEdits.js +8 -1
- package/dist/core/scene/sceneEdits.js.map +1 -1
- package/dist/core/scene/sceneMutators.js +1 -0
- package/dist/core/scene/sceneMutators.js.map +1 -1
- package/dist/core/scene/sceneRecording.js +20 -3
- package/dist/core/scene/sceneRecording.js.map +1 -1
- package/dist/core/scene/sceneSelection.js +4 -1
- package/dist/core/scene/sceneSelection.js.map +1 -1
- package/dist/core/scene/sceneState.js +11 -5
- package/dist/core/scene/sceneState.js.map +1 -1
- package/dist/core/scene/serialization.js +5 -3
- package/dist/core/scene/serialization.js.map +1 -1
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/unitScopes.js +19 -1
- package/dist/core/scene/unitScopes.js.map +1 -1
- package/dist/core/selection/usePublishSceneSelection.js +6 -12
- package/dist/core/selection/usePublishSceneSelection.js.map +1 -1
- package/dist/core/shapeKinds.js +25 -11
- package/dist/core/shapeKinds.js.map +1 -1
- package/dist/{cornerHandles-Camw_yeu.d.ts → cornerHandles-p8fDIAKt.d.ts} +3 -2
- package/dist/debug/createDebugOverlayLayer.js +16 -111
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/createDebugSink.js +2 -1
- package/dist/debug/createDebugSink.js.map +1 -1
- package/dist/debug/defaultTheme.js +4 -2
- package/dist/debug/defaultTheme.js.map +1 -1
- package/dist/debug/features.js +17 -0
- package/dist/debug/features.js.map +1 -0
- package/dist/debug/overlayPanels.js +117 -0
- package/dist/debug/overlayPanels.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +4 -13
- package/dist/debug/parseDebugFlags.js.map +1 -1
- package/dist/{depSchema-Cgfu_G9s.d.ts → depSchema-mG19aEdD.d.ts} +174 -904
- package/dist/devtools/handlers.js +112 -0
- package/dist/devtools/handlers.js.map +1 -0
- package/dist/devtools/history.js +71 -0
- package/dist/devtools/history.js.map +1 -0
- package/dist/devtools/hook.js +74 -0
- package/dist/devtools/hook.js.map +1 -0
- package/dist/devtools/label.js +25 -0
- package/dist/devtools/label.js.map +1 -0
- package/dist/devtools/notices.js +58 -0
- package/dist/devtools/notices.js.map +1 -0
- package/dist/devtools/protocol.js +7 -0
- package/dist/devtools/protocol.js.map +1 -0
- package/dist/devtools/registry.js +90 -0
- package/dist/devtools/registry.js.map +1 -0
- package/dist/devtools/root.js +80 -0
- package/dist/devtools/root.js.map +1 -0
- package/dist/devtools/serialize.js +86 -0
- package/dist/devtools/serialize.js.map +1 -0
- package/dist/devtools/session.js +111 -0
- package/dist/devtools/session.js.map +1 -0
- package/dist/devtools/transport.js +67 -0
- package/dist/devtools/transport.js.map +1 -0
- package/dist/devtools/useDevtoolsRoot.js +81 -0
- package/dist/devtools/useDevtoolsRoot.js.map +1 -0
- package/dist/devtools-protocol.d.ts +435 -0
- package/dist/devtools-protocol.js +7 -0
- package/dist/devtools.d.ts +8 -0
- package/dist/devtools.js +12 -0
- package/dist/devtools.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +16 -10
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +25 -2
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/measure/measureCommands.js +7 -5
- package/dist/features/measure/measureCommands.js.map +1 -1
- package/dist/features/measure/measureContribution.js +4 -2
- package/dist/features/measure/measureContribution.js.map +1 -1
- package/dist/features/modes/modeTriggers.js +7 -3
- package/dist/features/modes/modeTriggers.js.map +1 -1
- package/dist/features/pathEffects/effectSources.js +60 -0
- package/dist/features/pathEffects/effectSources.js.map +1 -0
- package/dist/features/pathEffects/readSource.js +17 -1
- 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 +57 -0
- package/dist/features/pathEffects/useEffectSourcesLayer.js.map +1 -0
- package/dist/features/paths/index.js +2 -2
- package/dist/features/paths/pathEditExtension.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/pathSnapSource.js +5 -5
- package/dist/features/paths/pathSnap/pathSnapSource.js.map +1 -1
- package/dist/features/paths/pathSnap/sceneIndex.js +10 -3
- package/dist/features/paths/pathSnap/sceneIndex.js.map +1 -1
- package/dist/features/selection/selectionPose.js +4 -1
- package/dist/features/selection/selectionPose.js.map +1 -1
- package/dist/features/snap/gather.js +9 -1
- package/dist/features/snap/gather.js.map +1 -1
- package/dist/features/snap/lazySession.js +17 -0
- package/dist/features/snap/lazySession.js.map +1 -0
- package/dist/features/snap/marks.js.map +1 -1
- package/dist/features/snap/probes2d.js +27 -19
- package/dist/features/snap/probes2d.js.map +1 -1
- package/dist/features/snap/readoutLayer.js.map +1 -1
- package/dist/features/snap/roles.js +2 -1
- package/dist/features/snap/roles.js.map +1 -1
- package/dist/features/snap/rotationSource.js +25 -8
- package/dist/features/snap/rotationSource.js.map +1 -1
- package/dist/features/snap/sceneSession2d.js +6 -4
- package/dist/features/snap/sceneSession2d.js.map +1 -1
- package/dist/features/snap/session2d.js +37 -23
- package/dist/features/snap/session2d.js.map +1 -1
- package/dist/features/snap/spanSnap.js +5 -2
- package/dist/features/snap/spanSnap.js.map +1 -1
- package/dist/features/text/sceneTextDrafts.js +65 -0
- package/dist/features/text/sceneTextDrafts.js.map +1 -0
- package/dist/features/text/textHitAt.js +31 -2
- package/dist/features/text/textHitAt.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +22 -18
- 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/icons.table.js +1 -1
- package/dist/icons.table.js.map +1 -1
- package/dist/icons.table.json +0 -10
- package/dist/index.d.ts +1198 -894
- package/dist/index.js +55 -38
- package/dist/interactions/actions/align/action.js +6 -4
- package/dist/interactions/actions/align/action.js.map +1 -1
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/action.js +7 -1
- package/dist/interactions/actions/booleans/action.js.map +1 -1
- 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/clone/action.js +1 -1
- package/dist/interactions/actions/clone/behaviors.js +4 -4
- package/dist/interactions/actions/clone/behaviors.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 +8 -5
- 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 +17 -8
- package/dist/interactions/actions/defaults/contextMenu.js.map +1 -1
- package/dist/interactions/actions/defaults/createPaintAction.js +2 -2
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js +64 -41
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +12 -9
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterPathEdit.js +19 -9
- package/dist/interactions/actions/defaults/enterPathEdit.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 +21 -15
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +17 -9
- 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 +21 -40
- 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 +8 -5
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -1
- 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/distribute/action.js +6 -4
- package/dist/interactions/actions/distribute/action.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 +10 -10
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/preview.js +41 -8
- package/dist/interactions/actions/edit-anchors/preview.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +14 -6
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/gestureLifecycle.js +5 -2
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +1 -2
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/commit.js +1 -1
- package/dist/interactions/actions/insert/parent.js +11 -0
- package/dist/interactions/actions/insert/parent.js.map +1 -0
- package/dist/interactions/actions/insert/placeAction.js +7 -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 +5 -1
- package/dist/interactions/actions/insert/session.js.map +1 -1
- package/dist/interactions/actions/move/action.js +15 -8
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/layoutDrop.js +0 -1
- package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +1 -1
- package/dist/interactions/actions/move/capture.js +1 -1
- package/dist/interactions/actions/move/commit/index.js +0 -2
- package/dist/interactions/actions/move/commit/index.js.map +1 -1
- package/dist/interactions/actions/move/commit/layoutDrop.js +2 -2
- package/dist/interactions/actions/move/commit/layoutRelease.js +2 -2
- package/dist/interactions/actions/move/commit/reparent.js +11 -5
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
- package/dist/interactions/actions/move/frame.js +4 -10
- package/dist/interactions/actions/move/frame.js.map +1 -1
- package/dist/interactions/actions/move/landedDescendants.js +20 -17
- package/dist/interactions/actions/move/landedDescendants.js.map +1 -1
- package/dist/interactions/actions/move/layout/container.js +2 -1
- package/dist/interactions/actions/move/layout/container.js.map +1 -1
- package/dist/interactions/actions/move/layout/dragged.js +1 -1
- package/dist/interactions/actions/move/layout/dropPass.js +18 -1
- package/dist/interactions/actions/move/layout/dropPass.js.map +1 -1
- package/dist/interactions/actions/move/layout/exits.js +5 -5
- package/dist/interactions/actions/move/layout/exits.js.map +1 -1
- package/dist/interactions/actions/move/session.js +14 -3
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/move/translate.js +8 -37
- package/dist/interactions/actions/move/translate.js.map +1 -1
- package/dist/interactions/actions/moveNodes.js +87 -0
- package/dist/interactions/actions/moveNodes.js.map +1 -0
- 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/planeInput.js.map +1 -1
- package/dist/interactions/actions/resize/action.js +83 -72
- package/dist/interactions/actions/resize/action.js.map +1 -1
- package/dist/interactions/actions/resize/commit.js +2 -1
- package/dist/interactions/actions/resize/commit.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/resize/session.js +2 -0
- package/dist/interactions/actions/resize/session.js.map +1 -1
- package/dist/interactions/actions/resolvePreviews.js +3 -3
- package/dist/interactions/actions/resolvePreviews.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +7 -4
- package/dist/interactions/actions/rotate/action.js.map +1 -1
- package/dist/interactions/actions/rotate/commit.js +2 -1
- package/dist/interactions/actions/rotate/commit.js.map +1 -1
- package/dist/interactions/actions/rotate/session.js +2 -0
- package/dist/interactions/actions/rotate/session.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +25 -9
- package/dist/interactions/actions/selectionSubtree.js.map +1 -1
- package/dist/interactions/actions/testUtils.js.map +1 -1
- package/dist/interactions/actions/transform-again/action.js +13 -11
- package/dist/interactions/actions/transform-again/action.js.map +1 -1
- package/dist/interactions/actions/transformFinish.js +106 -0
- package/dist/interactions/actions/transformFinish.js.map +1 -0
- package/dist/json.d.ts +4 -0
- package/dist/json.js +3 -0
- package/dist/kitSettingsSchema.js +8 -5
- package/dist/kitSettingsSchema.js.map +1 -1
- package/dist/{math-CrJULaZI.d.ts → math-B56zxVs5.d.ts} +10 -1
- package/dist/math.d.ts +1 -1
- package/dist/math.js +2 -1
- package/dist/move.d.ts +5 -4
- package/dist/{options-p9GZMXbY.d.ts → options-DBxEryYq.d.ts} +1 -1
- package/dist/resize.d.ts +4 -3
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +2 -2
- package/dist/test-hook/createTestHook.js +1 -1
- package/dist/test-hook/createTestHook.js.map +1 -1
- package/dist/test-hook/useTestHook.js +2 -1
- package/dist/test-hook/useTestHook.js.map +1 -1
- package/dist/test-seams.d.ts +9 -5
- 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/penHandle.js +3 -5
- package/dist/tools/builtin/pen/penHandle.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/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/adapterPointQuery.js +3 -2
- package/dist/tools/builtin/select/adapterPointQuery.js.map +1 -1
- 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 +13 -10
- 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/tools/index.js +26 -0
- package/dist/{types-CHVXGfYm.d.ts → types-7puAuVD2.d.ts} +3 -262
- package/dist/types-BN9hbdMI.d.ts +184 -0
- package/dist/types-CniVctmk.d.ts +949 -0
- package/dist/types-oFeQ5VjV.d.ts +264 -0
- package/dist/util/paint.js +1 -3
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +39 -25
- package/dist/canvas/SceneCanvas/useBuiltinRigTools.js +0 -65
- package/dist/canvas/SceneCanvas/useBuiltinRigTools.js.map +0 -1
- package/dist/tools/builtin/bone/boneActions.js +0 -156
- package/dist/tools/builtin/bone/boneActions.js.map +0 -1
- package/dist/tools/builtin/bone/boneOverlay.js +0 -71
- package/dist/tools/builtin/bone/boneOverlay.js.map +0 -1
- package/dist/tools/builtin/bone/placedRig.js +0 -28
- package/dist/tools/builtin/bone/placedRig.js.map +0 -1
- package/dist/tools/builtin/bone/rigEditState.js +0 -30
- package/dist/tools/builtin/bone/rigEditState.js.map +0 -1
- package/dist/tools/builtin/bone/useBoneTool.js +0 -125
- package/dist/tools/builtin/bone/useBoneTool.js.map +0 -1
- package/dist/tools/builtin/weight/useWeightTool.js +0 -101
- package/dist/tools/builtin/weight/useWeightTool.js.map +0 -1
- package/dist/tools/builtin/weight/weightActions.js +0 -140
- package/dist/tools/builtin/weight/weightActions.js.map +0 -1
- package/dist/tools/builtin/weight/weightOverlay.js +0 -78
- package/dist/tools/builtin/weight/weightOverlay.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayerStack.js","names":[],"sources":["../../src/canvas/useLayerStack.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useSyncExternalStore } from 'react';\nimport type { RenderLayer } from 'core/layers/render';\nimport type { Paint } from '@weasel-js/paint';\nimport { createBackgroundFillLayer } from 'core/layers/backgroundFill';\nimport { composeOrderedLayers, placeToolOverlays } from './layerOrder';\nimport { STANDARD_SLOTS, isCustomEntry } from './layerSlots';\nimport type { CanvasProps } from './canvasProps';\nimport type { ViewRegistry } from './viewRegistry';\n\n/** The `layers` prop's slots and custom entries in draw order, with the background fill beneath,\n * the decoration layer above, and the active tool's overlays placed among them. */\nexport function useSlotLayers(\n layersMap: CanvasProps<unknown>['layers'],\n tools: CanvasProps<unknown>['tools'],\n backgroundFill: Paint | undefined,\n decorationLayer: RenderLayer<unknown> | undefined,\n): RenderLayer<unknown>[] {\n const backgroundLayer = useMemo(\n () => (backgroundFill ? createBackgroundFillLayer(backgroundFill) : undefined),\n [backgroundFill],\n );\n\n return useMemo<RenderLayer<unknown>[]>(() => {\n const standardLayers: Partial<\n Record<(typeof STANDARD_SLOTS)[number], RenderLayer<unknown>>\n > = {};\n for (const slot of ['grid', 'cellHighlight', 'selectionOverlay'] as const) {\n const entry = layersMap[slot];\n if (isCustomEntry(entry)) standardLayers[slot] = entry.layer;\n }\n const out: RenderLayer<unknown>[] = composeOrderedLayers(\n decorationLayer ? { ...layersMap, decorationLayer: { layer: decorationLayer } } : layersMap,\n standardLayers, layersMap.scene?.layers, backgroundLayer,\n );\n if (tools) {\n placeToolOverlays(out, standardLayers.selectionOverlay, tools.getActiveOverlays);\n }\n return out;\n }, [layersMap, tools, backgroundLayer, decorationLayer]);\n}\n\n/** What the canvas paints on top of its slot layers. */\nexport interface StackAbove {\n viewRegistry: ViewRegistry | null;\n debugOverlay: RenderLayer<unknown> | null | undefined;\n /** Registered layers; re-read whenever `extrasVersion` changes. */\n extrasRef: { readonly current: ReadonlySet<RenderLayer<unknown>> };\n extrasVersion: number;\n cursorLayer: RenderLayer<unknown>;\n}\n\n/**\n * The full stack the canvas paints: its slot layers, then registered views, the debug overlay,\n * externally registered layers, and the cursor. Every layer that can change on its own\n * repaints the canvas through `requestRedraw`.\n */\nexport function useComposedLayers(\n layers: readonly RenderLayer<unknown>[],\n above: StackAbove,\n requestRedraw: () => void,\n): RenderLayer<unknown>[] {\n const { viewRegistry, debugOverlay, extrasRef, extrasVersion, cursorLayer } = above;\n const viewRegistryVersion = useSyncExternalStore(\n useCallback((cb: () => void) => viewRegistry?.subscribe(cb) ?? (() => {}), [viewRegistry]),\n () => viewRegistry?.getVersion() ?? 0,\n () => 0,\n );\n\n const composed = useMemo(() => {\n // Views paint through the surface's own stack, so they sit above it and\n // below both the debug overlay and externally-registered layers.\n const withViews = viewRegistry\n ? [...layers
|
|
1
|
+
{"version":3,"file":"useLayerStack.js","names":[],"sources":["../../src/canvas/useLayerStack.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useSyncExternalStore } from 'react';\nimport type { RenderLayer } from 'core/layers/render';\nimport type { Paint } from '@weasel-js/paint';\nimport { createBackgroundFillLayer } from 'core/layers/backgroundFill';\nimport { composeOrderedLayers, placeToolOverlays } from './layerOrder';\nimport { STANDARD_SLOTS, isCustomEntry } from './layerSlots';\nimport type { CanvasProps } from './canvasProps';\nimport type { ViewRegistry } from './viewRegistry';\n\n/** The `layers` prop's slots and custom entries in draw order, with the background fill beneath,\n * the decoration layer above, and the active tool's overlays placed among them. */\nexport function useSlotLayers(\n layersMap: CanvasProps<unknown>['layers'],\n tools: CanvasProps<unknown>['tools'],\n backgroundFill: Paint | undefined,\n decorationLayer: RenderLayer<unknown> | undefined,\n): RenderLayer<unknown>[] {\n const backgroundLayer = useMemo(\n () => (backgroundFill ? createBackgroundFillLayer(backgroundFill) : undefined),\n [backgroundFill],\n );\n\n return useMemo<RenderLayer<unknown>[]>(() => {\n const standardLayers: Partial<\n Record<(typeof STANDARD_SLOTS)[number], RenderLayer<unknown>>\n > = {};\n for (const slot of ['grid', 'cellHighlight', 'selectionOverlay'] as const) {\n const entry = layersMap[slot];\n if (isCustomEntry(entry)) standardLayers[slot] = entry.layer;\n }\n const out: RenderLayer<unknown>[] = composeOrderedLayers(\n decorationLayer ? { ...layersMap, decorationLayer: { layer: decorationLayer } } : layersMap,\n standardLayers, layersMap.scene?.layers, backgroundLayer,\n );\n if (tools) {\n placeToolOverlays(out, standardLayers.selectionOverlay, tools.getActiveOverlays);\n }\n return out;\n }, [layersMap, tools, backgroundLayer, decorationLayer]);\n}\n\n/** What the canvas paints on top of its slot layers. */\nexport interface StackAbove {\n viewRegistry: ViewRegistry | null;\n debugOverlay: RenderLayer<unknown> | null | undefined;\n /** Registered layers; re-read whenever `extrasVersion` changes. */\n extrasRef: { readonly current: ReadonlySet<RenderLayer<unknown>> };\n extrasVersion: number;\n cursorLayer: RenderLayer<unknown>;\n}\n\n/**\n * The full stack the canvas paints: its slot layers, then root view markers, registered views, the debug overlay,\n * externally registered layers, and the cursor. Every layer that can change on its own\n * repaints the canvas through `requestRedraw`.\n */\nexport function useComposedLayers(\n layers: readonly RenderLayer<unknown>[],\n above: StackAbove,\n requestRedraw: () => void,\n): RenderLayer<unknown>[] {\n const { viewRegistry, debugOverlay, extrasRef, extrasVersion, cursorLayer } = above;\n const viewRegistryVersion = useSyncExternalStore(\n useCallback((cb: () => void) => viewRegistry?.subscribe(cb) ?? (() => {}), [viewRegistry]),\n () => viewRegistry?.getVersion() ?? 0,\n () => 0,\n );\n\n const composed = useMemo(() => {\n // Views paint through the surface's own stack, so they sit above it and\n // below both the debug overlay and externally-registered layers. Root\n // markers sit under the views, as a view's own markers sit under its nested ones.\n const withViews = viewRegistry\n ? [\n ...layers,\n ...viewRegistry.markerLayers(null),\n ...viewRegistry.list().filter((r) => r.paint).map((r) => r.layer as RenderLayer<unknown>),\n ]\n : layers;\n const base = debugOverlay ? [...withViews, debugOverlay] : withViews;\n // The cursor goes last: it is the one thing that is always in front of\n // everything, including a consumer's own registered layers.\n return [...base, ...extrasRef.current, cursorLayer];\n // extrasVersion drives re-reads of extrasRef when layers are registered/detached;\n // viewRegistryVersion does the same for registered views.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layers, debugOverlay, extrasVersion, viewRegistry, viewRegistryVersion,\n cursorLayer]);\n\n useEffect(() => {\n const redraw = (): void => { requestRedraw(); };\n const offs: (() => void)[] = [];\n for (const layer of composed) if (layer.subscribe) offs.push(layer.subscribe(redraw));\n return () => { for (const off of offs) off(); };\n }, [composed, requestRedraw]);\n\n return composed;\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,cACd,WACA,OACA,gBACA,iBACwB;CACxB,MAAM,kBAAkB,cACf,iBAAiB,0BAA0B,cAAc,IAAI,QACpE,CAAC,cAAc,CACjB;CAEA,OAAO,cAAsC;EAC3C,MAAM,iBAEF,CAAC;EACL,KAAK,MAAM,QAAQ;GAAC;GAAQ;GAAiB;EAAkB,GAAY;GACzE,MAAM,QAAQ,UAAU;GACxB,IAAI,cAAc,KAAK,GAAG,eAAe,QAAQ,MAAM;EACzD;EACA,MAAM,MAA8B,qBAClC,kBAAkB;GAAE,GAAG;GAAW,iBAAiB,EAAE,OAAO,gBAAgB;EAAE,IAAI,WAClF,gBAAgB,UAAU,OAAO,QAAQ,eAC3C;EACA,IAAI,OACF,kBAAkB,KAAK,eAAe,kBAAkB,MAAM,iBAAiB;EAEjF,OAAO;CACT,GAAG;EAAC;EAAW;EAAO;EAAiB;CAAe,CAAC;AACzD;;;;;;AAiBA,SAAgB,kBACd,QACA,OACA,eACwB;CACxB,MAAM,EAAE,cAAc,cAAc,WAAW,eAAe,gBAAgB;CAC9E,MAAM,sBAAsB,qBAC1B,aAAa,OAAmB,cAAc,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,SACnF,cAAc,WAAW,KAAK,SAC9B,CACR;CAEA,MAAM,WAAW,cAAc;EAI7B,MAAM,YAAY,eACd;GACE,GAAG;GACH,GAAG,aAAa,aAAa,IAAI;GACjC,GAAG,aAAa,KAAK,CAAC,CAAC,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC,KAAK,MAAM,EAAE,KAA6B;EAC1F,IACA;EAIJ,OAAO;GAAC,GAHK,eAAe,CAAC,GAAG,WAAW,YAAY,IAAI;GAG1C,GAAG,UAAU;GAAS;EAAW;CAIpD,GAAG;EAAC;EAAQ;EAAc;EAAe;EAAc;EACnD;CAAW,CAAC;CAEhB,gBAAgB;EACd,MAAM,eAAqB;GAAE,cAAc;EAAG;EAC9C,MAAM,OAAuB,CAAC;EAC9B,KAAK,MAAM,SAAS,UAAU,IAAI,MAAM,WAAW,KAAK,KAAK,MAAM,UAAU,MAAM,CAAC;EACpF,aAAa;GAAE,KAAK,MAAM,OAAO,MAAM,IAAI;EAAG;CAChD,GAAG,CAAC,UAAU,aAAa,CAAC;CAE5B,OAAO;AACT"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { normalizeView } from "../core/viewport/view.js";
|
|
2
|
+
import { isRectAim, rectAim, viewForAim } from "../features/viewports/aim.js";
|
|
3
|
+
import { viewportWorldRect } from "../core/viewport/viewportWorldRect.js";
|
|
4
|
+
import { useCanvasView } from "./useCanvasView.js";
|
|
5
|
+
import { sizeOf } from "./useViewNesting.js";
|
|
6
|
+
import { IDENTITY_VIEW, UNMEASURED_DIMS } from "./viewRegistry.js";
|
|
7
|
+
import { useCallback } from "react";
|
|
8
|
+
import { useLatest } from "@weasel-js/react";
|
|
9
|
+
|
|
10
|
+
//#region src/canvas/useViewAim.ts
|
|
11
|
+
/**
|
|
12
|
+
* A `<CanvasView>`'s camera and its aim, whichever of the two the view holds.
|
|
13
|
+
* A camera-held view answers its aim from its camera; an aim-held one derives
|
|
14
|
+
* its camera from the aim, through the same thunk a derived `view` uses.
|
|
15
|
+
*/
|
|
16
|
+
/** `held` carried by the camera move that turns the world rect `from` into `to`: panned and scaled
|
|
17
|
+
* with it, so the aim keeps its own shape rather than taking the frame's. */
|
|
18
|
+
function carried(held, from, to) {
|
|
19
|
+
const kx = from.width > 0 ? to.width / from.width : 1;
|
|
20
|
+
const ky = from.height > 0 ? to.height / from.height : 1;
|
|
21
|
+
return {
|
|
22
|
+
x: to.x + (held.x - from.x) * kx,
|
|
23
|
+
y: to.y + (held.y - from.y) * ky,
|
|
24
|
+
width: held.width * kx,
|
|
25
|
+
height: held.height * ky
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function useViewAim(args) {
|
|
29
|
+
const { props, id, registry, derivedAt, rectAt, rectNow } = args;
|
|
30
|
+
const { view, defaultView, onViewChange, viewBounds, aim: aimProp, onAimChange } = props;
|
|
31
|
+
const held = aimProp !== void 0 ? "aim" : "camera";
|
|
32
|
+
const live = useLatest({
|
|
33
|
+
view,
|
|
34
|
+
onViewChange,
|
|
35
|
+
aimProp,
|
|
36
|
+
onAimChange
|
|
37
|
+
});
|
|
38
|
+
/** The rect an aim-held view holds, for a surface frame. */
|
|
39
|
+
const heldAt = useCallback((outer, dims) => {
|
|
40
|
+
const a = live.current.aimProp;
|
|
41
|
+
return typeof a === "function" ? derivedAt(a, outer, dims) : a;
|
|
42
|
+
}, [live, derivedAt]);
|
|
43
|
+
/** The camera derived for a surface frame, or `undefined` for a camera the view keeps. */
|
|
44
|
+
const derivedCamera = useCallback((outer, dims) => {
|
|
45
|
+
const rect = heldAt(outer, dims);
|
|
46
|
+
if (rect) return viewForAim(rect, sizeOf(rectAt(outer, dims)), "contain");
|
|
47
|
+
const v = live.current.view;
|
|
48
|
+
return typeof v === "function" ? normalizeView(derivedAt(v, outer, dims)) : void 0;
|
|
49
|
+
}, [
|
|
50
|
+
live,
|
|
51
|
+
heldAt,
|
|
52
|
+
rectAt,
|
|
53
|
+
derivedAt
|
|
54
|
+
]);
|
|
55
|
+
const surfaceFrame = useCallback(() => {
|
|
56
|
+
const surface = registry?.surface();
|
|
57
|
+
return [surface?.view() ?? IDENTITY_VIEW, surface?.dims() ?? UNMEASURED_DIMS];
|
|
58
|
+
}, [registry]);
|
|
59
|
+
/** A camera write on an aim-held view, reported as the held rect it carries. */
|
|
60
|
+
const reportWrite = useCallback((next) => {
|
|
61
|
+
const frame = surfaceFrame();
|
|
62
|
+
const held = heldAt(...frame);
|
|
63
|
+
const current = derivedCamera(...frame);
|
|
64
|
+
if (!held || !current) return;
|
|
65
|
+
const size = sizeOf(rectAt(...frame));
|
|
66
|
+
live.current.onAimChange?.(carried(held, viewportWorldRect(current, size), viewportWorldRect(next, size)));
|
|
67
|
+
}, [
|
|
68
|
+
live,
|
|
69
|
+
surfaceFrame,
|
|
70
|
+
heldAt,
|
|
71
|
+
derivedCamera,
|
|
72
|
+
rectAt
|
|
73
|
+
]);
|
|
74
|
+
const state = useCanvasView({
|
|
75
|
+
view: held === "aim" || typeof view === "function" ? () => derivedCamera(...surfaceFrame()) : view,
|
|
76
|
+
defaultView,
|
|
77
|
+
onViewChange: held === "aim" ? onAimChange && reportWrite : onViewChange,
|
|
78
|
+
viewBounds,
|
|
79
|
+
dims: () => sizeOf(rectNow()),
|
|
80
|
+
requestRedraw: () => registry?.surface()?.requestRedraw(),
|
|
81
|
+
controlledBy: held === "aim" ? "aim" : "view"
|
|
82
|
+
});
|
|
83
|
+
const { getView, setViewFromInput } = state;
|
|
84
|
+
const aim = useCallback(() => {
|
|
85
|
+
const rect = heldAt(...surfaceFrame());
|
|
86
|
+
return rectAim(id, rect ?? viewportWorldRect(getView(), sizeOf(rectNow())));
|
|
87
|
+
}, [
|
|
88
|
+
id,
|
|
89
|
+
heldAt,
|
|
90
|
+
surfaceFrame,
|
|
91
|
+
getView,
|
|
92
|
+
rectNow
|
|
93
|
+
]);
|
|
94
|
+
const setAim = useCallback((next) => {
|
|
95
|
+
if (!isRectAim(next)) return false;
|
|
96
|
+
const { view: v, onViewChange: onView, aimProp: a, onAimChange: report } = live.current;
|
|
97
|
+
if (a === void 0) {
|
|
98
|
+
if (v !== void 0 && !onView) return false;
|
|
99
|
+
setViewFromInput(viewForAim(next.extent, sizeOf(rectNow()), "exact"));
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
report?.(next.extent);
|
|
103
|
+
return report !== void 0;
|
|
104
|
+
}, [
|
|
105
|
+
live,
|
|
106
|
+
setViewFromInput,
|
|
107
|
+
rectNow
|
|
108
|
+
]);
|
|
109
|
+
const cameraAt = useCallback((outer, dims) => derivedCamera(outer, dims) ?? getView(), [derivedCamera, getView]);
|
|
110
|
+
return {
|
|
111
|
+
...state,
|
|
112
|
+
held,
|
|
113
|
+
aim,
|
|
114
|
+
setAim,
|
|
115
|
+
cameraAt
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { useViewAim };
|
|
121
|
+
//# sourceMappingURL=useViewAim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewAim.js","names":[],"sources":["../../src/canvas/useViewAim.ts"],"sourcesContent":["/**\n * A `<CanvasView>`'s camera and its aim, whichever of the two the view holds.\n * A camera-held view answers its aim from its camera; an aim-held one derives\n * its camera from the aim, through the same thunk a derived `view` uses.\n */\nimport { useCallback } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dims } from 'core/layers/render';\nimport { normalizeView, type View } from 'core/viewport/view';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport { viewportWorldRect } from 'core/viewport/viewportWorldRect';\nimport { isRectAim, rectAim, viewForAim, type ViewAim } from 'features/viewports/aim';\nimport { useCanvasView, type CanvasViewState } from './useCanvasView';\nimport type { CanvasViewProps, ViewRect } from './canvasViewProps';\nimport { sizeOf, type useViewNesting } from './useViewNesting';\nimport { IDENTITY_VIEW, UNMEASURED_DIMS, type ViewRegistry } from './viewRegistry';\n\n/** `held` carried by the camera move that turns the world rect `from` into `to`: panned and scaled\n * with it, so the aim keeps its own shape rather than taking the frame's. */\nfunction carried(held: Bounds, from: Bounds, to: Bounds): Bounds {\n const kx = from.width > 0 ? to.width / from.width : 1;\n const ky = from.height > 0 ? to.height / from.height : 1;\n return {\n x: to.x + (held.x - from.x) * kx,\n y: to.y + (held.y - from.y) * ky,\n width: held.width * kx,\n height: held.height * ky,\n };\n}\n\ntype Nesting = ReturnType<typeof useViewNesting>;\n\nexport function useViewAim(args: {\n props: Pick<CanvasViewProps, 'view' | 'defaultView' | 'onViewChange' | 'viewBounds' | 'aim' | 'onAimChange'>;\n id: string;\n registry: ViewRegistry | null;\n derivedAt: Nesting['derivedAt'];\n rectAt: Nesting['rectAt'];\n rectNow: () => ViewRect;\n}): CanvasViewState & {\n held: 'camera' | 'aim';\n aim(): ViewAim;\n setAim(aim: ViewAim): boolean;\n /** The camera for a frame the caller names. A derived camera is asked for that frame; any other is\n * the same whatever the surface is doing. */\n cameraAt(outer: View, dims: Dims): View;\n} {\n const { props, id, registry, derivedAt, rectAt, rectNow } = args;\n const { view, defaultView, onViewChange, viewBounds, aim: aimProp, onAimChange } = props;\n const held = aimProp !== undefined ? 'aim' : 'camera';\n const live = useLatest({ view, onViewChange, aimProp, onAimChange });\n\n /** The rect an aim-held view holds, for a surface frame. */\n const heldAt = useCallback((outer: View, dims: Dims): Bounds | undefined => {\n const a = live.current.aimProp;\n return typeof a === 'function' ? derivedAt(a, outer, dims) : a;\n }, [live, derivedAt]);\n\n /** The camera derived for a surface frame, or `undefined` for a camera the view keeps. */\n const derivedCamera = useCallback((outer: View, dims: Dims): View | undefined => {\n const rect = heldAt(outer, dims);\n if (rect) return viewForAim(rect, sizeOf(rectAt(outer, dims)), 'contain');\n const v = live.current.view;\n return typeof v === 'function' ? normalizeView(derivedAt(v, outer, dims)) : undefined;\n }, [live, heldAt, rectAt, derivedAt]);\n\n const surfaceFrame = useCallback((): [View, Dims] => {\n const surface = registry?.surface();\n return [surface?.view() ?? IDENTITY_VIEW, surface?.dims() ?? UNMEASURED_DIMS];\n }, [registry]);\n\n /** A camera write on an aim-held view, reported as the held rect it carries. */\n const reportWrite = useCallback((next: View): void => {\n const frame = surfaceFrame();\n const held = heldAt(...frame);\n const current = derivedCamera(...frame);\n if (!held || !current) return;\n const size = sizeOf(rectAt(...frame));\n live.current.onAimChange?.(carried(held, viewportWorldRect(current, size), viewportWorldRect(next, size)));\n }, [live, surfaceFrame, heldAt, derivedCamera, rectAt]);\n\n const state = useCanvasView({\n view: held === 'aim' || typeof view === 'function' ? () => derivedCamera(...surfaceFrame())! : view,\n defaultView,\n onViewChange: held === 'aim'\n ? onAimChange && reportWrite\n : onViewChange,\n viewBounds,\n dims: () => sizeOf(rectNow()),\n requestRedraw: () => registry?.surface()?.requestRedraw(),\n controlledBy: held === 'aim' ? 'aim' : 'view',\n });\n const { getView, setViewFromInput } = state;\n\n const aim = useCallback((): ViewAim => {\n const rect = heldAt(...surfaceFrame());\n return rectAim(id, rect ?? viewportWorldRect(getView(), sizeOf(rectNow())));\n }, [id, heldAt, surfaceFrame, getView, rectNow]);\n\n const setAim = useCallback((next: ViewAim): boolean => {\n if (!isRectAim(next)) return false;\n const { view: v, onViewChange: onView, aimProp: a, onAimChange: report } = live.current;\n if (a === undefined) {\n if (v !== undefined && !onView) return false;\n setViewFromInput(viewForAim(next.extent, sizeOf(rectNow()), 'exact'));\n return true;\n }\n report?.(next.extent);\n return report !== undefined;\n }, [live, setViewFromInput, rectNow]);\n\n const cameraAt = useCallback(\n (outer: View, dims: Dims): View => derivedCamera(outer, dims) ?? getView(),\n [derivedCamera, getView],\n );\n\n return { ...state, held, aim, setAim, cameraAt };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAS,QAAQ,MAAc,MAAc,IAAoB;CAC/D,MAAM,KAAK,KAAK,QAAQ,IAAI,GAAG,QAAQ,KAAK,QAAQ;CACpD,MAAM,KAAK,KAAK,SAAS,IAAI,GAAG,SAAS,KAAK,SAAS;CACvD,OAAO;EACL,GAAG,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;EAC9B,GAAG,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;EA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framedBounds } from "../core/geometry/poseDescriptor.js";
|
|
3
|
+
import { useInFlightBounds } from "./useInFlightBounds.js";
|
|
3
4
|
import { buildChromeState } from "../core/selection/chromeState.js";
|
|
4
5
|
import { drawnBoundsOf } from "./drawnBounds.js";
|
|
5
6
|
import { useCallback, useMemo } from "react";
|
|
@@ -58,16 +59,13 @@ function useViewHelpers(opts) {
|
|
|
58
59
|
}
|
|
59
60
|
}, [adapter]);
|
|
60
61
|
const multiActive = selection.length > 1;
|
|
61
|
-
const previewPoseExtraRef = useLatest(previewPoseExtra);
|
|
62
62
|
const effectiveBoundsOf = useMemo(() => boundsOf ?? baseBoundsOf, [boundsOf, baseBoundsOf]);
|
|
63
|
-
const previewPoseOf =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return p != null ? boxOf(id, p) : null;
|
|
70
|
-
}, [previewPoseOf, boxOf]);
|
|
63
|
+
const { previewPoseOf, previewBoundsOf } = useInFlightBounds({
|
|
64
|
+
gestureSource,
|
|
65
|
+
previewPoseExtra,
|
|
66
|
+
boxOf,
|
|
67
|
+
committedPoseOf
|
|
68
|
+
});
|
|
71
69
|
/**
|
|
72
70
|
* Bounds for `id` with any in-flight gesture folded in — what the user can
|
|
73
71
|
* see, not what is committed. Both the chrome state and the layer helpers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewHelpers.js","names":[],"sources":["../../src/canvas/useViewHelpers.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { framedBounds } from 'core/geometry/poseDescriptor';\nimport { useLatest } from '@weasel-js/react';\nimport type { GestureSource, GesturePreviewSource } from './gestureBounds';\nimport type { OngoingOverlay } from '@weasel-js/routing';\nimport { unionAABB } from 'core/geometry/unionBounds';\nimport { buildChromeState, type ChromeState } from 'core/selection/chromeState';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { NodeId } from 'core/scene/types';\nimport type { DebugSink } from '../debug/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport type { Scale2 } from '@weasel-js/geom';\nimport { drawnBoundsOf, type DrawnBoundsScene } from './drawnBounds';\n\nconst noOpUnsubscribe = (): void => {};\n\nconst alwaysVisible = (): boolean => true;\n\n/**\n * The half of {@link CanvasHelpers} that belongs to one view — everything\n * answered by a camera's own tools, gestures and selection. A canvas hosting\n * several viewports needs one of these per view; the surface half is shared.\n */\nexport interface CanvasViewHelpers<TPose> {\n /** Pose currently displayed for `id` — drag/resize/rotate overlay if active,\n * otherwise the committed pose from the adapter. Returns `null` if the id\n * isn't known. */\n getEffectivePose(id: string): TPose | null;\n /** Overlay-aware bounds for `id`. */\n getEffectiveBounds(id: string): Bounds | null;\n /**\n * World-space AABB of everything the in-flight gesture proposes — the\n * displaced poses of nodes being moved / resized / rotated / cloned, plus\n * any nascent insert that has no scene node yet. `null` when no gesture is\n * in flight.\n *\n * This reports the *gesture*, not the document: committed content the\n * gesture isn't touching is excluded. Select-only gestures are excluded\n * too: a marquee or lasso has geometry but proposes no content.\n *\n * The result is a plain AABB — never rotated. Rotated parts are folded in\n * by their rotated extent.\n */\n getGestureBounds(): Bounds | null;\n /**\n * Subscribe to the gesture layer's change signal, for everything on this\n * object that moves during a drag (`getEffectivePose`, `getEffectiveBounds`,\n * `getGestureBounds`). Returns an unsubscribe.\n *\n * Fires once per dispatcher pump: gesture start, every pointermove that\n * reaches an in-flight handle, end, and cancel — plus UI-driven ongoing\n * actions. It fires on the pump, not on a diff: a pump that changed nothing\n * observable still notifies, so don't hang expensive work directly off the\n * callback.\n *\n * It does **not** cover committed scene edits (subscribe to the scene for\n * those) or previews a consumer's own tool publishes from React state.\n * Without a gesture source wired — a bare `<Canvas>` — it never fires.\n */\n subscribeGestures(fn: () => void): () => void;\n /**\n * Monotonic counter bumped on exactly the events `subscribeGestures` fires\n * on. Pair the two for `useSyncExternalStore`:\n *\n * ```ts\n * const gestureVersion = useSyncExternalStore(\n * useCallback((cb) => helpersRef.current?.subscribeGestures(cb) ?? (() => {}), []),\n * () => helpersRef.current?.getGestureVersion() ?? 0,\n * );\n * ```\n *\n * Starts at 0 and only increases. `0` is also what a bare `<Canvas>` with\n * no gesture source reports, forever.\n */\n getGestureVersion(): number;\n /** The live ChromeState built once per render: overlay-aware selection\n * state for affordances and custom layers. */\n getChromeState(): ChromeState;\n /**\n * Everything publishing an in-flight preview for this view: the handles in\n * flight on its dispatcher, in dispatch order. Readers take the first\n * non-null answer per id.\n *\n * A ghost layer must read this off its draw envelope rather than close over\n * a dispatcher: one layer array paints every view, so a closure ghosts view\n * zero's drag into every panel.\n */\n getPreviewSources(): readonly GesturePreviewSource[];\n /** Overlay shapes this view's in-flight handles publish — marquee, lasso,\n * insert preview, raw commands. Same envelope rule as\n * {@link CanvasViewHelpers.getPreviewSources}. */\n getGestureOverlays(): readonly OngoingOverlay[];\n /**\n * Chrome-caps visibility predicate, keyed by chrome id. Overlay layers and\n * affordances call it per element to decide whether to draw / hit-test.\n * Unwired, it is the universal `() => true`.\n */\n getIsVisible(): (id: string) => boolean;\n}\n\n/**\n * The half of {@link CanvasHelpers} that belongs to the surface — one GL\n * context, one debug sink, however many views are drawn on it.\n */\nexport interface CanvasSurfaceHelpers {\n /** Active debug sink, when `<Canvas debug=...>` is enabled, for layers to\n * call from their `draw` callback. `null` when debug is off. */\n getDebug(): DebugSink | null;\n}\n\n/** Live overlay-aware lookups exposed to custom layers via `helpersRef`, and\n * what a layer receives as its `data` argument. */\nexport interface CanvasHelpers<TPose> extends CanvasViewHelpers<TPose>, CanvasSurfaceHelpers {\n /**\n * The view this draw is for: a `<CanvasView>` id, or `null` for the\n * surface's own camera. One layer array paints every view, so a layer that\n * belongs in some views and not others — a minimap's indicator — declines\n * the rest by this id.\n */\n readonly viewId: string | null;\n}\n\n/** What a view's pose and bounds lookups read of an adapter. */\nexport interface ViewPoseAdapter<TPose> {\n getPose(id: string): TPose;\n /** Where the node is drawn, when the adapter composes poses. An adapter\n * without it stores absolute poses, where the two agree. */\n getWorldPose?(id: string): TPose;\n /** The node an id names, whose `layer` decides whether a view that hides\n * that layer shows its selection chrome. */\n getNode?(id: string): { layer?: string } | undefined;\n}\n\nexport interface UseViewHelpersOpts<TPose> {\n adapter: ViewPoseAdapter<TPose> | undefined;\n geometry: PoseDescriptor<TPose>;\n /** Consumer-supplied bounds resolver. Falls back to the adapter's pose. */\n boundsOf: ((id: string) => Bounds | null) | undefined;\n /** Bounds of `id` drawn at an in-flight `pose`. Falls back to the\n * geometry's box of that pose, which is wrong wherever the surface draws a\n * node somewhere its pose does not say — a parallax plane. */\n boundsOfPose?: ((id: string, pose: TPose) => Bounds | null) | undefined;\n /** The nodes the adapter's ids name: with them, the fallbacks box each as\n * drawn, stroke included, rather than by its pose. */\n nodes?: DrawnBoundsScene | undefined;\n /** The view's scale, which a screen-pixel stroke is resolved at. Default 1. */\n getScale?: (() => Scale2) | undefined;\n selection: readonly NodeId[];\n gestureSource: GestureSource | undefined;\n /** The dispatcher's preview pose for an id, read through a ref so a change\n * mid-gesture doesn't rebuild the memos that depend on it. */\n previewPoseExtra: ((id: string) => unknown) | undefined;\n /** Chrome-caps predicate for this view. Absent means everything is visible. */\n getIsVisible?: (() => (id: string) => boolean) | undefined;\n /** Whether a scene layer reaches the screen in this view. Absent means\n * every layer the scene shows does. */\n layerIsPainted?: ((layerId: string) => boolean) | undefined;\n}\n\nexport interface ViewHelpersBundle<TPose> {\n helpers: CanvasViewHelpers<TPose>;\n}\n\nfunction worldPoseOf<TPose>(adapter: ViewPoseAdapter<TPose>, id: string): TPose {\n return typeof adapter.getWorldPose === 'function' ? adapter.getWorldPose(id) : adapter.getPose(id);\n}\n\n/**\n * Build one view's overlay-aware state: its chrome and the lookups its layers\n * draw and hit-test against. A canvas with N views mounts N components each\n * calling this once.\n */\nexport function useViewHelpers<TPose>(\n opts: UseViewHelpersOpts<TPose>,\n): ViewHelpersBundle<TPose> {\n const {\n adapter, geometry, boundsOf, boundsOfPose, nodes, getScale, selection, gestureSource,\n previewPoseExtra, getIsVisible, layerIsPainted,\n } = opts;\n const getScaleRef = useLatest(getScale);\n const poseBoxOf = useCallback((id: string, pose: TPose): Bounds => {\n if (!nodes) return framedBounds(pose, geometry);\n const scale = getScaleRef.current?.();\n return drawnBoundsOf(nodes, id as NodeId, pose, {\n descriptor: geometry as PoseDescriptor<unknown>,\n ...(adapter ? { worldPoseOf: (m: NodeId) => worldPoseOf(adapter, m) } : {}),\n ...(scale ? { scale } : {}),\n });\n }, [nodes, geometry, adapter, getScaleRef]);\n const boxOf = useCallback(\n (id: string, pose: TPose): Bounds | null =>\n (boundsOfPose ? boundsOfPose(id, pose) : poseBoxOf(id, pose)),\n [boundsOfPose, poseBoxOf],\n );\n\n const baseBoundsOf = useMemo(() => {\n if (boundsOf) return boundsOf;\n if (!adapter) return undefined;\n return (id: string): Bounds | null => {\n try {\n // World: chrome is drawn over the picture, so it has to agree with\n // where the renderer put the node, not with where its pose is stored.\n return poseBoxOf(id, worldPoseOf(adapter, id));\n } catch {\n return null;\n }\n };\n }, [boundsOf, adapter, poseBoxOf]);\n\n const committedPoseOf = useCallback((id: string): TPose | null => {\n if (!adapter) return null;\n try {\n return worldPoseOf(adapter, id);\n } catch {\n return null;\n }\n }, [adapter]);\n\n const multiActive = selection.length > 1;\n\n const previewPoseExtraRef = useLatest(previewPoseExtra);\n\n const effectiveBoundsOf = useMemo(() => boundsOf ?? baseBoundsOf, [boundsOf, baseBoundsOf]);\n\n const previewPoseOf = useCallback((id: string): TPose | null => {\n const p = previewPoseExtraRef.current?.(id);\n return p != null ? (p as TPose) : null;\n }, [previewPoseExtraRef]);\n const previewBoundsOf = useCallback((id: string): Bounds | null => {\n const p = previewPoseOf(id);\n return p != null ? boxOf(id, p) : null;\n }, [previewPoseOf, boxOf]);\n\n /**\n * Bounds for `id` with any in-flight gesture folded in — what the user can\n * see, not what is committed. Both the chrome state and the layer helpers\n * answer bounds questions with this, so resize handles cannot end up a frame\n * away from the shape they belong to.\n */\n const boundsWithPreview = useCallback((id: string): Bounds | null => {\n const previewed = previewBoundsOf(id);\n if (previewed) return previewed;\n return effectiveBoundsOf ? effectiveBoundsOf(id) : null;\n }, [previewBoundsOf, effectiveBoundsOf]);\n\n const chromeState: ChromeState = useMemo(\n () => buildChromeState({\n selection,\n multiActive,\n effectiveBoundsOf: boundsWithPreview,\n modifiers: { alt: false, shift: false, meta: false, ctrl: false },\n // Absent adapter / unknown ids fall back to `true` so the affordance\n // stays visible for consumers that wire bounds without an adapter.\n canRotate: (id) => {\n if (!geometry.supportsRotation) return true;\n const pose = committedPoseOf(id);\n if (pose == null) return true;\n return geometry.supportsRotation(pose);\n },\n ...(layerIsPainted ? { layerIsPainted } : {}),\n ...(adapter?.getNode ? { layerOf: (id: string) => adapter.getNode?.(id)?.layer } : {}),\n }),\n [selection, multiActive, boundsWithPreview, geometry, committedPoseOf, layerIsPainted, adapter],\n );\n\n const helpers: CanvasViewHelpers<TPose> = {\n getEffectivePose: (id: string): TPose | null => {\n return previewPoseOf(id) ?? committedPoseOf(id);\n },\n getEffectiveBounds: boundsWithPreview,\n getGestureBounds: (): Bounds | null => {\n // The same id sets the ghost layer walks, so this cannot disagree with\n // what the user sees ghosted.\n const parts: (Bounds | null)[] = [];\n for (const id of new Set(gestureSource?.ids() ?? [])) parts.push(previewBoundsOf(id));\n const extraBounds = gestureSource?.bounds();\n if (extraBounds) for (const b of extraBounds) parts.push(b);\n return unionAABB(parts);\n },\n subscribeGestures: (fn: () => void): (() => void) =>\n gestureSource?.subscribe(fn) ?? noOpUnsubscribe,\n getGestureVersion: (): number => gestureSource?.getVersion() ?? 0,\n getChromeState: () => chromeState,\n getPreviewSources: (): readonly GesturePreviewSource[] => gestureSource?.previewSources() ?? [],\n getGestureOverlays: (): readonly OngoingOverlay[] => gestureSource?.overlays() ?? [],\n getIsVisible: (): ((id: string) => boolean) => getIsVisible?.() ?? alwaysVisible,\n };\n\n return { helpers };\n}\n"],"mappings":";;;;;;;;AAcA,IA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e,IAAI,KAAK,CAAC,CAAC,GAAG,MAAM,KAAK,gBAAgB,EAAE,CAAC;GACpF,MAAM,cAAc,eAAe,OAAO;GAC1C,IAAI,aAAa,KAAK,MAAM,KAAK,aAAa,MAAM,KAAK,CAAC;GAC1D,OAAO,UAAU,KAAK;EACxB;EACA,oBAAoB,OAClB,eAAe,UAAU,EAAE,KAAK;EAClC,yBAAiC,eAAe,WAAW,KAAK;EAChE,sBAAsB;EACtB,yBAA0D,eAAe,eAAe,KAAK,CAAC;EAC9F,0BAAqD,eAAe,SAAS,KAAK,CAAC;EACnF,oBAA+C,eAAe,KAAK;CAG5D,EAAQ;AACnB"}
|
|
1
|
+
{"version":3,"file":"useViewHelpers.js","names":[],"sources":["../../src/canvas/useViewHelpers.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { framedBounds } from 'core/geometry/poseDescriptor';\nimport { useLatest } from '@weasel-js/react';\nimport type { GestureSource, GesturePreviewSource } from './gestureBounds';\nimport { useInFlightBounds } from './useInFlightBounds';\nimport type { OngoingOverlay } from '@weasel-js/routing';\nimport { unionAABB } from 'core/geometry/unionBounds';\nimport { buildChromeState, type ChromeState } from 'core/selection/chromeState';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { NodeId } from 'core/scene/types';\nimport type { DebugSink } from '../debug/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport type { Scale2 } from '@weasel-js/geom';\nimport { drawnBoundsOf, type DrawnBoundsScene } from './drawnBounds';\n\nconst noOpUnsubscribe = (): void => {};\n\nconst alwaysVisible = (): boolean => true;\n\n/**\n * The half of {@link CanvasHelpers} that belongs to one view — everything\n * answered by a camera's own tools, gestures and selection. A canvas hosting\n * several viewports needs one of these per view; the surface half is shared.\n */\nexport interface CanvasViewHelpers<TPose> {\n /** Pose currently displayed for `id` — drag/resize/rotate overlay if active,\n * otherwise the committed pose from the adapter. Returns `null` if the id\n * isn't known. */\n getEffectivePose(id: string): TPose | null;\n /** Overlay-aware bounds for `id`. */\n getEffectiveBounds(id: string): Bounds | null;\n /**\n * World-space AABB of everything the in-flight gesture proposes — the\n * displaced poses of nodes being moved / resized / rotated / cloned, plus\n * any nascent insert that has no scene node yet. `null` when no gesture is\n * in flight.\n *\n * This reports the *gesture*, not the document: committed content the\n * gesture isn't touching is excluded. Select-only gestures are excluded\n * too: a marquee or lasso has geometry but proposes no content.\n *\n * The result is a plain AABB — never rotated. Rotated parts are folded in\n * by their rotated extent.\n */\n getGestureBounds(): Bounds | null;\n /**\n * Subscribe to the gesture layer's change signal, for everything on this\n * object that moves during a drag (`getEffectivePose`, `getEffectiveBounds`,\n * `getGestureBounds`). Returns an unsubscribe.\n *\n * Fires once per dispatcher pump: gesture start, every pointermove that\n * reaches an in-flight handle, end, and cancel — plus UI-driven ongoing\n * actions. It fires on the pump, not on a diff: a pump that changed nothing\n * observable still notifies, so don't hang expensive work directly off the\n * callback.\n *\n * It does **not** cover committed scene edits (subscribe to the scene for\n * those) or previews a consumer's own tool publishes from React state.\n * Without a gesture source wired — a bare `<Canvas>` — it never fires.\n */\n subscribeGestures(fn: () => void): () => void;\n /**\n * Monotonic counter bumped on exactly the events `subscribeGestures` fires\n * on. Pair the two for `useSyncExternalStore`:\n *\n * ```ts\n * const gestureVersion = useSyncExternalStore(\n * useCallback((cb) => helpersRef.current?.subscribeGestures(cb) ?? (() => {}), []),\n * () => helpersRef.current?.getGestureVersion() ?? 0,\n * );\n * ```\n *\n * Starts at 0 and only increases. `0` is also what a bare `<Canvas>` with\n * no gesture source reports, forever.\n */\n getGestureVersion(): number;\n /** The live ChromeState built once per render: overlay-aware selection\n * state for affordances and custom layers. */\n getChromeState(): ChromeState;\n /**\n * Everything publishing an in-flight preview for this view: the handles in\n * flight on its dispatcher, in dispatch order. Readers take the first\n * non-null answer per id.\n *\n * A ghost layer must read this off its draw envelope rather than close over\n * a dispatcher: one layer array paints every view, so a closure ghosts view\n * zero's drag into every panel.\n */\n getPreviewSources(): readonly GesturePreviewSource[];\n /** Overlay shapes this view's in-flight handles publish — marquee, lasso,\n * insert preview, raw commands. Same envelope rule as\n * {@link CanvasViewHelpers.getPreviewSources}. */\n getGestureOverlays(): readonly OngoingOverlay[];\n /**\n * Chrome-caps visibility predicate, keyed by chrome id. Overlay layers and\n * affordances call it per element to decide whether to draw / hit-test.\n * Unwired, it is the universal `() => true`.\n */\n getIsVisible(): (id: string) => boolean;\n}\n\n/**\n * The half of {@link CanvasHelpers} that belongs to the surface — one GL\n * context, one debug sink, however many views are drawn on it.\n */\nexport interface CanvasSurfaceHelpers {\n /** Active debug sink, when `<Canvas debug=...>` is enabled, for layers to\n * call from their `draw` callback. `null` when debug is off. */\n getDebug(): DebugSink | null;\n}\n\n/** Live overlay-aware lookups exposed to custom layers via `helpersRef`, and\n * what a layer receives as its `data` argument. */\nexport interface CanvasHelpers<TPose> extends CanvasViewHelpers<TPose>, CanvasSurfaceHelpers {\n /**\n * The view this draw is for: a `<CanvasView>` id, or `null` for the\n * surface's own camera. One layer array paints every view, so a layer that\n * belongs in some views and not others — a minimap's indicator — declines\n * the rest by this id.\n */\n readonly viewId: string | null;\n}\n\n/** What a view's pose and bounds lookups read of an adapter. */\nexport interface ViewPoseAdapter<TPose> {\n getPose(id: string): TPose;\n /** Where the node is drawn, when the adapter composes poses. An adapter\n * without it stores absolute poses, where the two agree. */\n getWorldPose?(id: string): TPose;\n /** The node an id names, whose `layer` decides whether a view that hides\n * that layer shows its selection chrome. */\n getNode?(id: string): { layer?: string } | undefined;\n}\n\nexport interface UseViewHelpersOpts<TPose> {\n adapter: ViewPoseAdapter<TPose> | undefined;\n geometry: PoseDescriptor<TPose>;\n /** Consumer-supplied bounds resolver. Falls back to the adapter's pose. */\n boundsOf: ((id: string) => Bounds | null) | undefined;\n /** Bounds of `id` drawn at an in-flight `pose`. Falls back to the\n * geometry's box of that pose, which is wrong wherever the surface draws a\n * node somewhere its pose does not say — a parallax plane. */\n boundsOfPose?: ((id: string, pose: TPose) => Bounds | null) | undefined;\n /** The nodes the adapter's ids name: with them, the fallbacks box each as\n * drawn, stroke included, rather than by its pose. */\n nodes?: DrawnBoundsScene | undefined;\n /** The view's scale, which a screen-pixel stroke is resolved at. Default 1. */\n getScale?: (() => Scale2) | undefined;\n selection: readonly NodeId[];\n gestureSource: GestureSource | undefined;\n /** The dispatcher's preview pose for an id, read through a ref so a change\n * mid-gesture doesn't rebuild the memos that depend on it. */\n previewPoseExtra: ((id: string) => unknown) | undefined;\n /** Chrome-caps predicate for this view. Absent means everything is visible. */\n getIsVisible?: (() => (id: string) => boolean) | undefined;\n /** Whether a scene layer reaches the screen in this view. Absent means\n * every layer the scene shows does. */\n layerIsPainted?: ((layerId: string) => boolean) | undefined;\n}\n\nexport interface ViewHelpersBundle<TPose> {\n helpers: CanvasViewHelpers<TPose>;\n}\n\nfunction worldPoseOf<TPose>(adapter: ViewPoseAdapter<TPose>, id: string): TPose {\n return typeof adapter.getWorldPose === 'function' ? adapter.getWorldPose(id) : adapter.getPose(id);\n}\n\n/**\n * Build one view's overlay-aware state: its chrome and the lookups its layers\n * draw and hit-test against. A canvas with N views mounts N components each\n * calling this once.\n */\nexport function useViewHelpers<TPose>(\n opts: UseViewHelpersOpts<TPose>,\n): ViewHelpersBundle<TPose> {\n const {\n adapter, geometry, boundsOf, boundsOfPose, nodes, getScale, selection, gestureSource,\n previewPoseExtra, getIsVisible, layerIsPainted,\n } = opts;\n const getScaleRef = useLatest(getScale);\n const poseBoxOf = useCallback((id: string, pose: TPose): Bounds => {\n if (!nodes) return framedBounds(pose, geometry);\n const scale = getScaleRef.current?.();\n return drawnBoundsOf(nodes, id as NodeId, pose, {\n descriptor: geometry as PoseDescriptor<unknown>,\n ...(adapter ? { worldPoseOf: (m: NodeId) => worldPoseOf(adapter, m) } : {}),\n ...(scale ? { scale } : {}),\n });\n }, [nodes, geometry, adapter, getScaleRef]);\n const boxOf = useCallback(\n (id: string, pose: TPose): Bounds | null =>\n (boundsOfPose ? boundsOfPose(id, pose) : poseBoxOf(id, pose)),\n [boundsOfPose, poseBoxOf],\n );\n\n const baseBoundsOf = useMemo(() => {\n if (boundsOf) return boundsOf;\n if (!adapter) return undefined;\n return (id: string): Bounds | null => {\n try {\n // World: chrome is drawn over the picture, so it has to agree with\n // where the renderer put the node, not with where its pose is stored.\n return poseBoxOf(id, worldPoseOf(adapter, id));\n } catch {\n return null;\n }\n };\n }, [boundsOf, adapter, poseBoxOf]);\n\n const committedPoseOf = useCallback((id: string): TPose | null => {\n if (!adapter) return null;\n try {\n return worldPoseOf(adapter, id);\n } catch {\n return null;\n }\n }, [adapter]);\n\n const multiActive = selection.length > 1;\n\n const effectiveBoundsOf = useMemo(() => boundsOf ?? baseBoundsOf, [boundsOf, baseBoundsOf]);\n const { previewPoseOf, previewBoundsOf } = useInFlightBounds({ gestureSource, previewPoseExtra, boxOf, committedPoseOf });\n\n /**\n * Bounds for `id` with any in-flight gesture folded in — what the user can\n * see, not what is committed. Both the chrome state and the layer helpers\n * answer bounds questions with this, so resize handles cannot end up a frame\n * away from the shape they belong to.\n */\n const boundsWithPreview = useCallback((id: string): Bounds | null => {\n const previewed = previewBoundsOf(id);\n if (previewed) return previewed;\n return effectiveBoundsOf ? effectiveBoundsOf(id) : null;\n }, [previewBoundsOf, effectiveBoundsOf]);\n\n const chromeState: ChromeState = useMemo(\n () => buildChromeState({\n selection,\n multiActive,\n effectiveBoundsOf: boundsWithPreview,\n modifiers: { alt: false, shift: false, meta: false, ctrl: false },\n // Absent adapter / unknown ids fall back to `true` so the affordance\n // stays visible for consumers that wire bounds without an adapter.\n canRotate: (id) => {\n if (!geometry.supportsRotation) return true;\n const pose = committedPoseOf(id);\n if (pose == null) return true;\n return geometry.supportsRotation(pose);\n },\n ...(layerIsPainted ? { layerIsPainted } : {}),\n ...(adapter?.getNode ? { layerOf: (id: string) => adapter.getNode?.(id)?.layer } : {}),\n }),\n [selection, multiActive, boundsWithPreview, geometry, committedPoseOf, layerIsPainted, adapter],\n );\n\n const helpers: CanvasViewHelpers<TPose> = {\n getEffectivePose: (id: string): TPose | null => {\n return previewPoseOf(id) ?? committedPoseOf(id);\n },\n getEffectiveBounds: boundsWithPreview,\n getGestureBounds: (): Bounds | null => {\n // The same id sets the ghost layer walks, so this cannot disagree with\n // what the user sees ghosted.\n const parts: (Bounds | null)[] = [];\n for (const id of new Set(gestureSource?.ids() ?? [])) parts.push(previewBoundsOf(id));\n const extraBounds = gestureSource?.bounds();\n if (extraBounds) for (const b of extraBounds) parts.push(b);\n return unionAABB(parts);\n },\n subscribeGestures: (fn: () => void): (() => void) =>\n gestureSource?.subscribe(fn) ?? noOpUnsubscribe,\n getGestureVersion: (): number => gestureSource?.getVersion() ?? 0,\n getChromeState: () => chromeState,\n getPreviewSources: (): readonly GesturePreviewSource[] => gestureSource?.previewSources() ?? [],\n getGestureOverlays: (): readonly OngoingOverlay[] => gestureSource?.overlays() ?? [],\n getIsVisible: (): ((id: string) => boolean) => getIsVisible?.() ?? alwaysVisible,\n };\n\n return { helpers };\n}\n"],"mappings":";;;;;;;;;AAeA,IAAM,wBAA8B,CAAC;AAErC,IAAM,sBAA+B;AAmJrC,SAAS,YAAmB,SAAiC,IAAmB;CAC9E,OAAO,OAAO,QAAQ,iBAAiB,aAAa,QAAQ,aAAa,EAAE,IAAI,QAAQ,QAAQ,EAAE;AACnG;;;;;;AAOA,SAAgB,eACd,MAC0B;CAC1B,MAAM,EACJ,SAAS,UAAU,UAAU,cAAc,OAAO,UAAU,WAAW,eACvE,kBAAkB,cAAc,mBAC9B;CACJ,MAAM,cAAc,UAAU,QAAQ;CACtC,MAAM,YAAY,aAAa,IAAY,SAAwB;EACjE,IAAI,CAAC,OAAO,OAAO,aAAa,MAAM,QAAQ;EAC9C,MAAM,QAAQ,YAAY,UAAU;EACpC,OAAO,cAAc,OAAO,IAAc,MAAM;GAC9C,YAAY;GACZ,GAAI,UAAU,EAAE,cAAc,MAAc,YAAY,SAAS,CAAC,EAAE,IAAI,CAAC;GACzE,GAAI,QAAQ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IAAI;EACvC;EACA,GAAI,iBAAiB,EAAE,eAAe,IAAI,CAAC;EAC3C,GAAI,SAAS,UAAU,EAAE,UAAU,OAAe,QAAQ,UAAU,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC;CACtF,CAAC,GACD;EAAC;EAAW;EAAa;EAAmB;EAAU;EAAiB;EAAgB;CAAO,CAChG;CAyBA,OAAO,EAAE;EAtBP,mBAAmB,OAA6B;GAC9C,OAAO,cAAc,EAAE,KAAK,gBAAgB,EAAE;EAChD;EACA,oBAAoB;EACpB,wBAAuC;GAGrC,MAAM,QAA2B,CAAC;GAClC,KAAK,MAAM,MAAM,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC,CAAC,GAAG,MAAM,KAAK,gBAAgB,EAAE,CAAC;GACpF,MAAM,cAAc,eAAe,OAAO;GAC1C,IAAI,aAAa,KAAK,MAAM,KAAK,aAAa,MAAM,KAAK,CAAC;GAC1D,OAAO,UAAU,KAAK;EACxB;EACA,oBAAoB,OAClB,eAAe,UAAU,EAAE,KAAK;EAClC,yBAAiC,eAAe,WAAW,KAAK;EAChE,sBAAsB;EACtB,yBAA0D,eAAe,eAAe,KAAK,CAAC;EAC9F,0BAAqD,eAAe,SAAS,KAAK,CAAC;EACnF,oBAA+C,eAAe,KAAK;CAG5D,EAAQ;AACnB"}
|
|
@@ -13,6 +13,7 @@ var NO_RECT = {
|
|
|
13
13
|
w: 0,
|
|
14
14
|
h: 0
|
|
15
15
|
};
|
|
16
|
+
/** A view rect's size, as the `Dims` its camera looks through. */
|
|
16
17
|
var sizeOf = (rect) => ({
|
|
17
18
|
width: rect.w,
|
|
18
19
|
height: rect.h
|
|
@@ -60,7 +61,7 @@ function useViewNesting(registry, live) {
|
|
|
60
61
|
y: r.y + frame.origin.y
|
|
61
62
|
};
|
|
62
63
|
}, [live, frameIn]);
|
|
63
|
-
/** A derived camera, for a surface frame: asked of the frame it is measured in. */
|
|
64
|
+
/** A derived camera or aim, for a surface frame: asked of the frame it is measured in. */
|
|
64
65
|
const derivedAt = useCallback((derive, outer, dims) => {
|
|
65
66
|
const frame = frameIn(outer, dims);
|
|
66
67
|
return frame ? derive(frame.view, frame.dims) : derive(outer, dims);
|
|
@@ -100,5 +101,5 @@ function useViewNesting(registry, live) {
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
//#endregion
|
|
103
|
-
export { NO_RECT, useViewNesting };
|
|
104
|
+
export { NO_RECT, sizeOf, useViewNesting };
|
|
104
105
|
//# sourceMappingURL=useViewNesting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewNesting.js","names":[],"sources":["../../src/canvas/useViewNesting.ts"],"sourcesContent":["/**\n * How a `<CanvasView>` sits in the view it is nested in: the frame its\n * `bounds` and derived camera are measured against, and the layers it may\n * paint. Without a `parent` the frame is the surface's.\n */\nimport { useCallback, useRef, useState } from 'react';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { View } from 'core/viewport/view';\nimport type { CanvasViewProps, ViewRect } from './canvasViewProps';\nimport { createSceneLayerGate, viewPaintedLayers } from './sceneLayerPaint';\nimport type { ViewRegistration, ViewRegistry } from './viewRegistry';\n\nexport const NO_RECT: ViewRect = { x: 0, y: 0, w: 0, h: 0 };\n\n/** What a view's `bounds` and `view` are measured against: the surface, or\n * the view it is nested in. `origin` and `clip` are in canvas CSS px. */\nexport interface OuterFrame { view: View; dims: Dims; origin: { x: number; y: number }; clip?: ViewRect }\n\n/** The props the nesting reads, as of the last committed render. */\nexport type ViewNestingInputs = Pick<CanvasViewProps, 'parent' | 'bounds' | 'layers' | 'layerVisibility' | 'layerOrder'>;\n\
|
|
1
|
+
{"version":3,"file":"useViewNesting.js","names":[],"sources":["../../src/canvas/useViewNesting.ts"],"sourcesContent":["/**\n * How a `<CanvasView>` sits in the view it is nested in: the frame its\n * `bounds` and derived camera are measured against, and the layers it may\n * paint. Without a `parent` the frame is the surface's.\n */\nimport { useCallback, useRef, useState } from 'react';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { View } from 'core/viewport/view';\nimport type { CanvasViewProps, ViewRect } from './canvasViewProps';\nimport { createSceneLayerGate, viewPaintedLayers } from './sceneLayerPaint';\nimport type { ViewRegistration, ViewRegistry } from './viewRegistry';\n\nexport const NO_RECT: ViewRect = { x: 0, y: 0, w: 0, h: 0 };\n\n/** What a view's `bounds` and `view` are measured against: the surface, or\n * the view it is nested in. `origin` and `clip` are in canvas CSS px. */\nexport interface OuterFrame { view: View; dims: Dims; origin: { x: number; y: number }; clip?: ViewRect }\n\n/** The props the nesting reads, as of the last committed render. */\nexport type ViewNestingInputs = Pick<CanvasViewProps, 'parent' | 'bounds' | 'layers' | 'layerVisibility' | 'layerOrder'>;\n\n/** A view rect's size, as the `Dims` its camera looks through. */\nexport const sizeOf = (rect: ViewRect): Dims => ({ width: rect.w, height: rect.h });\n\nexport function useViewNesting(\n registry: ViewRegistry | null,\n live: { readonly current: ViewNestingInputs },\n) {\n // Set while this view asks its parent for a frame, so a parent chain that\n // loops back finds no frame rather than recursing.\n const measuring = useRef(false);\n /** The frame this view is measured in, for a surface frame; `null` while\n * its parent is missing. */\n const frameIn = useCallback((outer: View, dims: Dims): OuterFrame | null => {\n const p = live.current.parent;\n if (p === undefined) return { view: outer, dims, origin: { x: 0, y: 0 } };\n const reg = registry?.get(p);\n if (!reg || measuring.current) return null;\n measuring.current = true;\n try {\n const r = reg.layer.resolvable(outer, dims);\n return {\n view: r.view, dims: sizeOf(r.rect), origin: { x: r.rect.x, y: r.rect.y }, clip: r.clip ?? r.rect,\n };\n } finally {\n measuring.current = false;\n }\n }, [live, registry]);\n\n const rectAt = useCallback((outer: View, dims: Dims): ViewRect => {\n const frame = frameIn(outer, dims);\n if (!frame) return NO_RECT;\n const b = live.current.bounds;\n const r = typeof b === 'function' ? b(frame.view, frame.dims) : b;\n return { ...r, x: r.x + frame.origin.x, y: r.y + frame.origin.y };\n }, [live, frameIn]);\n\n /** A derived camera or aim, for a surface frame: asked of the frame it is measured in. */\n const derivedAt = useCallback(<T>(derive: (outer: View, dims: Dims) => T, outer: View, dims: Dims): T => {\n const frame = frameIn(outer, dims);\n return frame ? derive(frame.view, frame.dims) : derive(outer, dims);\n }, [frameIn]);\n\n /** The view this one is nested in, while it is registered. */\n const parentReg = useCallback((): ViewRegistration | undefined => {\n const p = live.current.parent;\n return p === undefined ? undefined : registry?.get(p);\n }, [live, registry]);\n\n /** The layers this view draws, in the order it draws them: of the surface's,\n * or of what the view it is nested in draws. */\n const drawnLayers = useCallback((): readonly RenderLayer<unknown>[] => {\n if (live.current.parent !== undefined) return viewPaintedLayers(parentReg()?.drawnLayers() ?? [], live.current);\n return viewPaintedLayers(registry?.surface()?.layers() ?? [], live.current);\n }, [registry, live, parentReg]);\n\n const [sceneLayerGate] = useState(createSceneLayerGate);\n /** What this view's picks, marquees and select-alls ask of a scene layer:\n * painted here, and in every view this one is nested in. */\n const layerIsPainted = useCallback((layerId: string): boolean => {\n if (!sceneLayerGate(registry?.surface()?.layers() ?? [], live.current)(layerId)) return false;\n if (live.current.parent === undefined) return true;\n return parentReg()?.layerIsPainted(layerId) ?? false;\n }, [registry, sceneLayerGate, live, parentReg]);\n return { frameIn, rectAt, derivedAt, drawnLayers, layerIsPainted };\n}\n"],"mappings":";;;;;;;;;AAYA,IAAa,UAAoB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;;AAU1D,IAAa,UAAU,UAA0B;CAAE,OAAO,KAAK;CAAG,QAAQ,KAAK;AAAE;AAEjF,SAAgB,eACd,UACA,MACA;CAGA,MAAM,YAAY,OAAO,KAAK;;;CAG9B,MAAM,UAAU,aAAa,OAAa,SAAkC;EAC1E,MAAM,IAAI,KAAK,QAAQ;EACvB,IAAI,MAAM,QAAW,OAAO;GAAE,MAAM;GAAO;GAAM,QAAQ;IAAE,GAAG;IAAG,GAAG;GAAE;EAAE;EACxE,MAAM,MAAM,UAAU,IAAI,CAAC;EAC3B,IAAI,CAAC,OAAO,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;CAC5E,GAAG;EAAC;EAAU;EAAM;CAAS,CAAC;CAE9B,MAAM,CAAC,kBAAkB,SAAS,oBAAoB;CAQtD,OAAO;EAAE;EAAS;EAAQ;EAAW;EAAa,gBAL3B,aAAa,YAA6B;GAC/D,IAAI,CAAC,eAAe,UAAU,QAAQ,CAAC,EAAE,OAAO,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,OAAO,GAAG,OAAO;GACxF,IAAI,KAAK,QAAQ,WAAW,QAAW,OAAO;GAC9C,OAAO,UAAU,CAAC,EAAE,eAAe,OAAO,KAAK;EACjD,GAAG;GAAC;GAAU;GAAgB;GAAM;EAAS,CACK;CAAe;AACnE"}
|
|
@@ -10,7 +10,7 @@ import { useLatest } from "@weasel-js/react";
|
|
|
10
10
|
function useViewRegistrySurface(viewRegistry, layers, frame, services) {
|
|
11
11
|
const surfaceLayersRef = useLatest(layers);
|
|
12
12
|
const { viewRef, dimsRef, helpersRef } = frame;
|
|
13
|
-
const { requestRedraw, hitTestExtrasIn, clientToWorld } = services;
|
|
13
|
+
const { requestRedraw, hitTestExtrasIn, clientToWorld, setView } = services;
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
return viewRegistry?.attachSurface({
|
|
16
16
|
view: () => viewRef.current,
|
|
@@ -20,6 +20,7 @@ function useViewRegistrySurface(viewRegistry, layers, frame, services) {
|
|
|
20
20
|
chromeState: () => helpersRef.current.getChromeState(),
|
|
21
21
|
hitTestExtras: hitTestExtrasIn,
|
|
22
22
|
clientToWorld,
|
|
23
|
+
setView,
|
|
23
24
|
claimsAbove: (x, y) => {
|
|
24
25
|
const view = viewRef.current;
|
|
25
26
|
const worldX = x / view.scale.x + view.x;
|
|
@@ -35,7 +36,8 @@ function useViewRegistrySurface(viewRegistry, layers, frame, services) {
|
|
|
35
36
|
surfaceLayersRef,
|
|
36
37
|
viewRef,
|
|
37
38
|
helpersRef,
|
|
38
|
-
clientToWorld
|
|
39
|
+
clientToWorld,
|
|
40
|
+
setView
|
|
39
41
|
]);
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewRegistrySurface.js","names":[],"sources":["../../src/canvas/useViewRegistrySurface.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { View } from 'core/viewport/view';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { CanvasHelpers } from './useViewHelpers';\nimport type { SurfaceHandle, ViewRegistry } from './viewRegistry';\n\n/** What the canvas reads at draw and hit time that changes outside a render. */\nexport interface SurfaceFrame {\n viewRef: { readonly current: View };\n dimsRef: { readonly current: Dims };\n helpersRef: { readonly current: Pick<CanvasHelpers<unknown>, 'getChromeState'> | null };\n}\n\n/** What the canvas does for a view that asks. */\nexport interface SurfaceServices {\n requestRedraw: () => void;\n hitTestExtrasIn: SurfaceHandle['hitTestExtras'];\n clientToWorld: SurfaceHandle['clientToWorld'];\n}\n\n/**\n * Attach this canvas to the view registry as its surface. The stack a view paints through its\n * own camera is this canvas's `layers`, before the views themselves are folded in — otherwise\n * a view would contain itself. Published by reference and read at draw time.\n */\nexport function useViewRegistrySurface(\n viewRegistry: ViewRegistry | null,\n layers: readonly RenderLayer<unknown>[],\n frame: SurfaceFrame,\n services: SurfaceServices,\n): void {\n const surfaceLayersRef = useLatest<readonly RenderLayer<unknown>[]>(layers);\n const { viewRef, dimsRef, helpersRef } = frame;\n const { requestRedraw, hitTestExtrasIn, clientToWorld } = services;\n useEffect(() => {\n return viewRegistry?.attachSurface({\n view: () => viewRef.current,\n dims: () => dimsRef.current,\n layers: () => surfaceLayersRef.current,\n requestRedraw,\n chromeState: () => helpersRef.current!.getChromeState(),\n hitTestExtras: hitTestExtrasIn,\n clientToWorld,\n claimsAbove: (x, y) => {\n const view = viewRef.current;\n const worldX = x / view.scale.x + view.x;\n const worldY = y / view.scale.y + view.y;\n return hitTestExtrasIn(worldX, worldY, view, dimsRef.current, helpersRef.current) !== null;\n },\n });\n }, [viewRegistry, requestRedraw, hitTestExtrasIn, dimsRef, surfaceLayersRef, viewRef, helpersRef, clientToWorld]);\n}\n"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useViewRegistrySurface.js","names":[],"sources":["../../src/canvas/useViewRegistrySurface.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { View } from 'core/viewport/view';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { CanvasHelpers } from './useViewHelpers';\nimport type { SurfaceHandle, ViewRegistry } from './viewRegistry';\n\n/** What the canvas reads at draw and hit time that changes outside a render. */\nexport interface SurfaceFrame {\n viewRef: { readonly current: View };\n dimsRef: { readonly current: Dims };\n helpersRef: { readonly current: Pick<CanvasHelpers<unknown>, 'getChromeState'> | null };\n}\n\n/** What the canvas does for a view that asks. */\nexport interface SurfaceServices {\n requestRedraw: () => void;\n hitTestExtrasIn: SurfaceHandle['hitTestExtras'];\n clientToWorld: SurfaceHandle['clientToWorld'];\n setView: NonNullable<SurfaceHandle['setView']>;\n}\n\n/**\n * Attach this canvas to the view registry as its surface. The stack a view paints through its\n * own camera is this canvas's `layers`, before the views themselves are folded in — otherwise\n * a view would contain itself. Published by reference and read at draw time.\n */\nexport function useViewRegistrySurface(\n viewRegistry: ViewRegistry | null,\n layers: readonly RenderLayer<unknown>[],\n frame: SurfaceFrame,\n services: SurfaceServices,\n): void {\n const surfaceLayersRef = useLatest<readonly RenderLayer<unknown>[]>(layers);\n const { viewRef, dimsRef, helpersRef } = frame;\n const { requestRedraw, hitTestExtrasIn, clientToWorld, setView } = services;\n useEffect(() => {\n return viewRegistry?.attachSurface({\n view: () => viewRef.current,\n dims: () => dimsRef.current,\n layers: () => surfaceLayersRef.current,\n requestRedraw,\n chromeState: () => helpersRef.current!.getChromeState(),\n hitTestExtras: hitTestExtrasIn,\n clientToWorld,\n setView,\n claimsAbove: (x, y) => {\n const view = viewRef.current;\n const worldX = x / view.scale.x + view.x;\n const worldY = y / view.scale.y + view.y;\n return hitTestExtrasIn(worldX, worldY, view, dimsRef.current, helpersRef.current) !== null;\n },\n });\n }, [viewRegistry, requestRedraw, hitTestExtrasIn, dimsRef, surfaceLayersRef, viewRef, helpersRef, clientToWorld, setView]);\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,uBACd,cACA,QACA,OACA,UACM;CACN,MAAM,mBAAmB,UAA2C,MAAM;CAC1E,MAAM,EAAE,SAAS,SAAS,eAAe;CACzC,MAAM,EAAE,eAAe,iBAAiB,eAAe,YAAY;CACnE,gBAAgB;EACd,OAAO,cAAc,cAAc;GACjC,YAAY,QAAQ;GACpB,YAAY,QAAQ;GACpB,cAAc,iBAAiB;GAC/B;GACA,mBAAmB,WAAW,QAAS,eAAe;GACtD,eAAe;GACf;GACA;GACA,cAAc,GAAG,MAAM;IACrB,MAAM,OAAO,QAAQ;IACrB,MAAM,SAAS,IAAI,KAAK,MAAM,IAAI,KAAK;IACvC,MAAM,SAAS,IAAI,KAAK,MAAM,IAAI,KAAK;IACvC,OAAO,gBAAgB,QAAQ,QAAQ,MAAM,QAAQ,SAAS,WAAW,OAAO,MAAM;GACxF;EACF,CAAC;CACH,GAAG;EAAC;EAAc;EAAe;EAAiB;EAAS;EAAkB;EAAS;EAAY;EAAe;CAAO,CAAC;AAC3H"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { aimSpace2d } from "../features/viewports/aim.js";
|
|
2
|
+
import { createViewMarkerLayer, grabViewMarker } from "../features/viewports/viewMarker.js";
|
|
3
|
+
import { layerAffordance } from "./affordanceAt.js";
|
|
4
|
+
|
|
5
|
+
//#region src/canvas/viewMarkers.ts
|
|
6
|
+
/** @internal */
|
|
7
|
+
function createViewMarkerRegistry(markers, deps) {
|
|
8
|
+
let gate = null;
|
|
9
|
+
const targetSpace = (target) => {
|
|
10
|
+
const surface = deps.surface();
|
|
11
|
+
if (!surface) return null;
|
|
12
|
+
if (target === null) return aimSpace2d(null, surface.view(), surface.dims());
|
|
13
|
+
const v = deps.resolve(target, surface.view(), surface.dims());
|
|
14
|
+
return v ? aimSpace2d(target, v.view, {
|
|
15
|
+
width: v.rect.w,
|
|
16
|
+
height: v.rect.h
|
|
17
|
+
}) : null;
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
registerMarker: (props) => {
|
|
21
|
+
const { id } = props();
|
|
22
|
+
for (const live of markers.keys()) if (live().id === id) {
|
|
23
|
+
console.error(`[weasel] registerMarker: marker "${id}" is already on this surface, so this one is skipped. Marker ids are unique per surface; rename one.`);
|
|
24
|
+
return () => {};
|
|
25
|
+
}
|
|
26
|
+
markers.set(props, createViewMarkerLayer(props, deps.host));
|
|
27
|
+
deps.changed();
|
|
28
|
+
return () => {
|
|
29
|
+
markers.delete(props);
|
|
30
|
+
deps.changed();
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
markerLayers: (target) => {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const [props, layer] of markers) if (props().target === target) out.push(layer);
|
|
36
|
+
return out;
|
|
37
|
+
},
|
|
38
|
+
markerAt: (target, world) => {
|
|
39
|
+
if (!gate?.()) return null;
|
|
40
|
+
const space = targetSpace(target);
|
|
41
|
+
const at = space?.project(world);
|
|
42
|
+
if (!space || !at) return null;
|
|
43
|
+
const live = [...markers.keys()];
|
|
44
|
+
for (let i = live.length - 1; i >= 0; i--) {
|
|
45
|
+
const props = live[i]();
|
|
46
|
+
if (props.target !== target) continue;
|
|
47
|
+
const grab = grabViewMarker(props, deps.host, space, at);
|
|
48
|
+
if (grab) return layerAffordance(`view-marker:${props.id}`, { initialScratch: grab });
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
},
|
|
52
|
+
gateMarkers: (open) => {
|
|
53
|
+
gate = open;
|
|
54
|
+
return () => {
|
|
55
|
+
if (gate === open) gate = null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { createViewMarkerRegistry };
|
|
63
|
+
//# sourceMappingURL=viewMarkers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewMarkers.js","names":[],"sources":["../../src/canvas/viewMarkers.ts"],"sourcesContent":["/**\n * The marker half of a surface's view registry: which markers are live, the\n * layers they draw, and which one a press lands on.\n */\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { AffordanceHit } from '@weasel-js/routing';\nimport { aimSpace2d, type AimSpace } from 'features/viewports/aim';\nimport type { ResolvableView } from 'features/viewports/viewResolver';\nimport type { View } from 'core/viewport/view';\nimport {\n createViewMarkerLayer, grabViewMarker, type ViewMarkerHost, type ViewMarkerProps,\n} from 'features/viewports/viewMarker';\nimport { layerAffordance } from './affordanceAt';\n\n/** @internal Composed into `ViewRegistry`. */\nexport interface ViewMarkerRegistry {\n /** Returns an unregister. `props` is read at every draw. An id already live\n * on the surface logs an error and is skipped, and its unregister does nothing. */\n registerMarker(props: () => ViewMarkerProps): () => void;\n /** The layers of the markers drawn in `target`'s frame, in mount order. */\n markerLayers(target: string | null): readonly RenderLayer<unknown>[];\n /** The topmost interactive marker drawn in `target` under `world` (a point\n * in `target`'s world), as the affordance a press there routes. */\n markerAt(target: string | null, world: { x: number; y: number }): AffordanceHit | null;\n /** Lets `markerAt` answer while `open()` says the surface binds a marker drag;\n * until then it answers `null`, so a press falls through. Returns an undo. */\n gateMarkers(open: () => boolean): () => void;\n}\n\n/** What the marker half reads off the rest of the registry. */\nexport interface ViewMarkerRegistryDeps {\n host: ViewMarkerHost;\n /** The surface's camera and size, or `null` before one attaches. */\n surface(): { view(): View; dims(): Dims } | null;\n /** View `id` resolved against the surface, or `undefined` while there is none. */\n resolve(id: string, outer: View, dims: Dims): ResolvableView | undefined;\n changed(): void;\n}\n\n/** @internal */\nexport function createViewMarkerRegistry(\n markers: Map<() => ViewMarkerProps, RenderLayer<unknown>>,\n deps: ViewMarkerRegistryDeps,\n): ViewMarkerRegistry {\n let gate: (() => boolean) | null = null;\n const targetSpace = (target: string | null): AimSpace | null => {\n const surface = deps.surface();\n if (!surface) return null;\n if (target === null) return aimSpace2d(null, surface.view(), surface.dims());\n const v = deps.resolve(target, surface.view(), surface.dims());\n return v ? aimSpace2d(target, v.view, { width: v.rect.w, height: v.rect.h }) : null;\n };\n return {\n registerMarker: (props) => {\n const { id } = props();\n for (const live of markers.keys()) {\n if (live().id === id) {\n console.error(`[weasel] registerMarker: marker \"${id}\" is already on this surface, so this one is skipped. Marker ids are unique per surface; rename one.`);\n return () => {};\n }\n }\n markers.set(props, createViewMarkerLayer(props, deps.host));\n deps.changed();\n return () => { markers.delete(props); deps.changed(); };\n },\n markerLayers: (target) => {\n const out: RenderLayer<unknown>[] = [];\n for (const [props, layer] of markers) if (props().target === target) out.push(layer);\n return out;\n },\n markerAt: (target, world) => {\n if (!gate?.()) return null;\n const space = targetSpace(target);\n const at = space?.project(world);\n if (!space || !at) return null;\n const live = [...markers.keys()];\n for (let i = live.length - 1; i >= 0; i--) {\n const props = live[i]!();\n if (props.target !== target) continue;\n const grab = grabViewMarker(props, deps.host, space, at);\n if (grab) return layerAffordance(`view-marker:${props.id}`, { initialScratch: grab });\n }\n return null;\n },\n gateMarkers: (open) => {\n gate = open;\n return () => { if (gate === open) gate = null; };\n },\n };\n}\n"],"mappings":";;;;;;AAwCA,SAAgB,yBACd,SACA,MACoB;CACpB,IAAI,OAA+B;CACnC,MAAM,eAAe,WAA2C;EAC9D,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,CAAC,SAAS,OAAO;EACrB,IAAI,WAAW,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,GAAG,QAAQ,KAAK,CAAC;EAC3E,MAAM,IAAI,KAAK,QAAQ,QAAQ,QAAQ,KAAK,GAAG,QAAQ,KAAK,CAAC;EAC7D,OAAO,IAAI,WAAW,QAAQ,EAAE,MAAM;GAAE,OAAO,EAAE,KAAK;GAAG,QAAQ,EAAE,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import { isRectAim, rectAim, viewForAim } from "../features/viewports/aim.js";
|
|
3
|
+
import { viewportWorldRect } from "../core/viewport/viewportWorldRect.js";
|
|
4
|
+
import { createViewMarkerRegistry } from "./viewMarkers.js";
|
|
2
5
|
import { createEmitter } from "@weasel-js/registry";
|
|
3
6
|
import { createContext, useContext, useMemo, useRef } from "react";
|
|
4
7
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -40,6 +43,7 @@ function ViewRegistryProvider({ children }) {
|
|
|
40
43
|
const seqRef = useRef(0);
|
|
41
44
|
const versionRef = useRef(0);
|
|
42
45
|
const surfaceRef = useRef(null);
|
|
46
|
+
const markersRef = useRef(/* @__PURE__ */ new Map());
|
|
43
47
|
const registry = useMemo(() => {
|
|
44
48
|
const listeners = createEmitter();
|
|
45
49
|
const changed = () => {
|
|
@@ -59,7 +63,7 @@ function ViewRegistryProvider({ children }) {
|
|
|
59
63
|
}
|
|
60
64
|
return false;
|
|
61
65
|
};
|
|
62
|
-
|
|
66
|
+
const registry = {
|
|
63
67
|
resolver: createViewResolver({
|
|
64
68
|
views: () => {
|
|
65
69
|
const surface = surfaceRef.current;
|
|
@@ -108,6 +112,27 @@ function ViewRegistryProvider({ children }) {
|
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
114
|
},
|
|
115
|
+
aimOf: (id) => {
|
|
116
|
+
if (id !== null) return get(id)?.aim() ?? null;
|
|
117
|
+
const surface = surfaceRef.current;
|
|
118
|
+
return surface ? rectAim(null, viewportWorldRect(surface.view(), surface.dims())) : null;
|
|
119
|
+
},
|
|
120
|
+
setAim: (id, aim) => {
|
|
121
|
+
if (id !== null) return get(id)?.setAim(aim) ?? false;
|
|
122
|
+
const surface = surfaceRef.current;
|
|
123
|
+
if (!isRectAim(aim) || !surface?.setView) return false;
|
|
124
|
+
surface.setView(viewForAim(aim.extent, surface.dims(), "exact"));
|
|
125
|
+
return true;
|
|
126
|
+
},
|
|
127
|
+
...createViewMarkerRegistry(markersRef.current, {
|
|
128
|
+
host: {
|
|
129
|
+
aimOf: (id) => registry.aimOf(id),
|
|
130
|
+
setAim: (id, aim) => registry.setAim(id, aim)
|
|
131
|
+
},
|
|
132
|
+
surface: () => surfaceRef.current,
|
|
133
|
+
resolve: (id, outer, dims) => get(id)?.layer.resolvable(outer, dims),
|
|
134
|
+
changed
|
|
135
|
+
}),
|
|
111
136
|
getVersion: () => versionRef.current,
|
|
112
137
|
subscribe: listeners.subscribe,
|
|
113
138
|
surface: () => surfaceRef.current,
|
|
@@ -118,6 +143,7 @@ function ViewRegistryProvider({ children }) {
|
|
|
118
143
|
};
|
|
119
144
|
}
|
|
120
145
|
};
|
|
146
|
+
return registry;
|
|
121
147
|
}, []);
|
|
122
148
|
return /* @__PURE__ */ jsx(ViewRegistryContext.Provider, {
|
|
123
149
|
value: registry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewRegistry.js","names":[],"sources":["../../src/canvas/viewRegistry.tsx"],"sourcesContent":["/**\n * The seam between a canvas surface and the views drawn on it.\n *\n * Traffic runs both ways: the surface attaches a handle onto its frame and its\n * layer stack, and each view registers what it contributes back — the viewport\n * node it paints into and the record the gesture dispatcher routes its events\n * to. Both sides are thunks, read at draw and dispatch time, so neither can\n * serve the other a frame that has already moved.\n */\nimport { createContext, useContext, useMemo, useRef, type ReactNode } from 'react';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { LayerHit } from 'affordances/types';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport type { View } from 'core/viewport/view';\nimport type { ViewportLayer } from 'features/viewports/viewportLayer';\nimport type { DispatcherViewTarget } from '@weasel-js/routing/internal';\nimport { createViewResolver, viewContains, type ViewResolver } from 'features/viewports/viewResolver';\nimport { createEmitter } from '@weasel-js/registry';\nimport type { ViewAt } from './canvasExtension';\n\n/**\n * What a view needs from the surface hosting it.\n *\n * @internal Attached by the surface, read by `<CanvasView>`.\n */\nexport interface SurfaceHandle {\n /** A client point in the surface's own world — the conversion the surface\n * itself makes, its `clientToWorld` override included. */\n clientToWorld(clientX: number, clientY: number): [number, number];\n /** The outer camera. */\n view(): View;\n /** The canvas's CSS-pixel size. */\n dims(): Dims;\n /** The stack a view paints through its own camera, unless it narrows it. */\n layers(): readonly RenderLayer<unknown>[];\n requestRedraw(): void;\n /** The canvas's own view chrome — its selection, its overlay-aware bounds.\n * What a `<CanvasView>` answers for itself, answered for view zero. */\n chromeState(): ChromeState;\n /** Hit-test the externally registered layers at a world point, against the\n * frame and draw envelope of whichever view is asking. The public\n * `hitTestExtras` is this with the canvas's own frame and envelope. */\n hitTestExtras(\n worldX: number,\n worldY: number,\n view: View,\n dims: Dims,\n data: unknown,\n /** Consider only these layers — the ones the asking view paints. A layer\n * asked on a frame it was not drawn in answers for the wrong pixels. */\n only?: readonly RenderLayer<unknown>[],\n ): { layerId: string; hit: LayerHit } | null;\n /** Whether a registered layer claims a canvas-local point on the surface's\n * own frame. Registered layers paint over every view, so such a point is\n * theirs even inside a view's rect. */\n claimsAbove(x: number, y: number): boolean;\n}\n\n/**\n * A client point in the surface's CSS pixels, from its top-left: the surface's\n * own world point put back through its camera, so a `clientToWorld` override\n * reaches every view declared on it.\n *\n * @internal\n */\nexport function surfaceLocal(\n surface: Pick<SurfaceHandle, 'clientToWorld' | 'view'> | null,\n clientX: number,\n clientY: number,\n): { x: number; y: number } {\n if (!surface) return { x: clientX, y: clientY };\n const [worldX, worldY] = surface.clientToWorld(clientX, clientY);\n const view = surface.view();\n return { x: (worldX - view.x) * view.scale.x, y: (worldY - view.y) * view.scale.y };\n}\n\n/**\n * What one view contributes to the surface hosting it.\n *\n * @internal Written by `<CanvasView>`, read by the surface. Consumers declare\n * a view, not a registration.\n */\nexport interface ViewRegistration {\n id: string;\n /** The view this one is nested in: listed, painted and hit after it, and\n * its `layer` measures itself from that view's rect and camera. */\n parent?: string;\n /**\n * Paint and hit order, low to high. Views declared as props take their array\n * index; a view mounted as a child takes `Infinity`, so it lands after them\n * however React happens to order the mount effects.\n */\n order: number;\n /** The viewport node this view paints into. Its `resolvable` is what routes\n * input here. */\n layer: ViewportLayer<unknown>;\n /** `false` keeps input over the view on the canvas beneath it. */\n interactive: boolean;\n /** `false` leaves `layer` for a host to draw — a HUD window's interior — so\n * the surface does not paint it too. */\n paint: boolean;\n /** Everything about dispatching to this view except its id. */\n target: Omit<DispatcherViewTarget, 'id'>;\n /** Whether a scene layer reaches the screen in this view. For input that\n * reaches a view without a dispatch — hover — so it judges this view's\n * paint rather than the surface's. */\n layerIsPainted(layerId: string): boolean;\n /** The layers this view draws, in order — what a view nested in it paints\n * from. */\n drawnLayers(): readonly RenderLayer<unknown>[];\n}\n\n\n/** @internal */\nexport interface ViewRegistry {\n /** Returns an unregister. */\n register(reg: ViewRegistration): () => void;\n /** Live registrations in paint order, each nested view after the view it\n * is nested in. */\n list(): readonly ViewRegistration[];\n /** The live registration with `id`, if any. */\n get(id: string): ViewRegistration | undefined;\n /** The innermost view painted under a canvas-local point, whether or not it\n * takes input, passing over `except` and the views nested in it. */\n viewAt(at: { x: number; y: number }, opts?: { except?: string }): ViewAt;\n /** Bumped whenever the list changes. Pair with {@link ViewRegistry.subscribe}\n * for `useSyncExternalStore`. */\n getVersion(): number;\n subscribe(fn: () => void): () => void;\n /** Which view a client point belongs to, sticky for a captured pointer.\n * One per surface: every caller that routes input — the dispatcher, pinch,\n * hover — must agree about where a point landed. */\n readonly resolver: ViewResolver;\n /** The hosting surface, or `null` before one attaches. */\n surface(): SurfaceHandle | null;\n /** Returns a detach, which leaves a handle attached since alone. */\n attachSurface(handle: SurfaceHandle): () => void;\n}\n\nconst ViewRegistryContext = createContext<ViewRegistry | null>(null);\n\n/** Mounts the registry for one surface. `<SceneCanvas>` mounts one; a view\n * declaring itself as a child must be inside it. */\nexport function ViewRegistryProvider({ children }: { children: ReactNode }) {\n const entriesRef = useRef(new Map<ViewRegistration, number>());\n const seqRef = useRef(0);\n const versionRef = useRef(0);\n const surfaceRef = useRef<SurfaceHandle | null>(null);\n\n const registry = useMemo<ViewRegistry>(() => {\n const listeners = createEmitter();\n const changed = (): void => {\n versionRef.current++;\n listeners.emit();\n };\n const ordered = (): ViewRegistration[] => nestedOrder([...entriesRef.current.keys()].sort((a, b) => (\n a.order - b.order || entriesRef.current.get(a)! - entriesRef.current.get(b)!\n )));\n const get = (id: string): ViewRegistration | undefined => {\n for (const r of entriesRef.current.keys()) if (r.id === id) return r;\n return undefined;\n };\n /** Whether `r` is `id` or nested in it, however deep. */\n const within = (r: ViewRegistration, id: string): boolean => {\n const seen = new Set<ViewRegistration>();\n for (let at: ViewRegistration | undefined = r; at && !seen.has(at); at = at.parent === undefined ? undefined : get(at.parent)) {\n if (at.id === id) return true;\n seen.add(at);\n }\n return false;\n };\n const resolver = createViewResolver({\n views: () => {\n const surface = surfaceRef.current;\n const view = surface?.view() ?? IDENTITY_VIEW;\n const dims = surface?.dims() ?? UNMEASURED_DIMS;\n return ordered().filter((r) => r.interactive).map((r) => r.layer.resolvable(view, dims));\n },\n root: () => surfaceRef.current?.view() ?? IDENTITY_VIEW,\n toLocal: (clientX, clientY) => surfaceLocal(surfaceRef.current, clientX, clientY),\n occluded: (x, y) => surfaceRef.current?.claimsAbove(x, y) ?? false,\n });\n return {\n resolver,\n register: (reg) => {\n entriesRef.current.set(reg, seqRef.current++);\n changed();\n return () => { entriesRef.current.delete(reg); changed(); };\n },\n list: ordered,\n get,\n viewAt: ({ x, y }, opts) => {\n const surface = surfaceRef.current;\n const view = surface?.view() ?? IDENTITY_VIEW;\n const dims = surface?.dims() ?? UNMEASURED_DIMS;\n const except = opts?.except;\n const list = ordered();\n for (let i = list.length - 1; i >= 0; i--) {\n const r = list[i]!;\n if (except !== undefined && within(r, except)) continue;\n const v = r.layer.resolvable(view, dims);\n if (viewContains(v, x, y)) return { id: v.id, view: v.view, rect: v.rect };\n }\n return { id: null, view, rect: { x: 0, y: 0, w: dims.width, h: dims.height } };\n },\n getVersion: () => versionRef.current,\n subscribe: listeners.subscribe,\n surface: () => surfaceRef.current,\n attachSurface: (handle) => {\n surfaceRef.current = handle;\n return () => { if (surfaceRef.current === handle) surfaceRef.current = null; };\n },\n };\n }, []);\n\n return <ViewRegistryContext.Provider value={registry}>{children}</ViewRegistryContext.Provider>;\n}\n\n/** The surface's view registry, or `null` outside one. */\nexport function useOptionalViewRegistry(): ViewRegistry | null {\n return useContext(ViewRegistryContext);\n}\n\n/** Each view followed by the views nested in it, in the order given. A view\n * whose parent is not registered keeps its place; one caught in a cycle\n * goes last. */\nfunction nestedOrder(sorted: readonly ViewRegistration[]): ViewRegistration[] {\n const ids = new Set(sorted.map((r) => r.id));\n const out: ViewRegistration[] = [];\n const placed = new Set<ViewRegistration>();\n const place = (r: ViewRegistration): void => {\n if (placed.has(r)) return;\n placed.add(r);\n out.push(r);\n for (const child of sorted) if (child.parent === r.id) place(child);\n };\n for (const r of sorted) if (r.parent === undefined || !ids.has(r.parent)) place(r);\n for (const r of sorted) place(r);\n return out;\n}\n\n/** The `Dims` a surface reports before it has measured itself. */\nexport const UNMEASURED_DIMS: Dims = { width: 0, height: 0 };\n\n/** The camera a view resolves against before its surface attaches. */\nexport const IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,aACd,SACA,SACA,SAC0B;CAC1B,IAAI,CAAC,SAAS,OAAO;EAAE,GAAG;EAAS,GAAG;CAAQ;CAC9C,MAAM,CAAC,QAAQ,UAAU,QAAQ,cAAc,SAAS,OAAO;CAC/D,MAAM,OAAO,QAAQ,KAAK;CAC1B,OAAO;EAAE,IAAI,SAAS,KAAK,KAAK,KAAK,MAAM;EAAG,IAAI,SAAS,KAAK,KAAK,KAAK,MAAM;CAAE;AACpF;AAiEA,IAAM,sBAAsB,cAAmC,IAAI;;;AAInE,SAAgB,qBAAqB,EAAE,YAAqC;CAC1E,MAAM,aAAa,uBAAO,IAAI,IAA8B,CAAC;CAC7D,MAAM,SAAS,OAAO,CAAC;C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ACnB,OAAO,IAAI,CAAC;EACZ,IAAI,KAAK,CAAC;EACV,KAAK,MAAM,SAAS,QAAQ,IAAI,MAAM,WAAW,EAAE,IAAI,MAAM,KAAK;CACpE;CACA,KAAK,MAAM,KAAK,QAAQ,IAAI,EAAE,WAAW,UAAa,CAAC,IAAI,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACjF,KAAK,MAAM,KAAK,QAAQ,MAAM,CAAC;CAC/B,OAAO;AACT;;AAGA,IAAa,kBAAwB;CAAE,OAAO;CAAG,QAAQ;AAAE;;AAG3D,IAAa,gBAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE"}
|
|
1
|
+
{"version":3,"file":"viewRegistry.js","names":[],"sources":["../../src/canvas/viewRegistry.tsx"],"sourcesContent":["/**\n * The seam between a canvas surface and the views drawn on it.\n *\n * Traffic runs both ways: the surface attaches a handle onto its frame and its\n * layer stack, and each view registers what it contributes back — the viewport\n * node it paints into and the record the gesture dispatcher routes its events\n * to. Both sides are thunks, read at draw and dispatch time, so neither can\n * serve the other a frame that has already moved.\n */\nimport { createContext, useContext, useMemo, useRef, type ReactNode } from 'react';\nimport type { Dims, RenderLayer } from 'core/layers/render';\nimport type { LayerHit } from 'affordances/types';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport type { View } from 'core/viewport/view';\nimport type { ViewportLayer } from 'features/viewports/viewportLayer';\nimport type { DispatcherViewTarget } from '@weasel-js/routing/internal';\nimport { createViewResolver, viewContains, type ViewResolver } from 'features/viewports/viewResolver';\nimport { createEmitter } from '@weasel-js/registry';\nimport type { ViewAt } from './canvasExtension';\nimport { isRectAim, rectAim, viewForAim, type ViewAim } from 'features/viewports/aim';\nimport { viewportWorldRect } from 'core/viewport/viewportWorldRect';\nimport type { ViewMarkerProps } from 'features/viewports/viewMarker';\nimport { createViewMarkerRegistry, type ViewMarkerRegistry } from './viewMarkers';\n\n/**\n * What a view needs from the surface hosting it.\n *\n * @internal Attached by the surface, read by `<CanvasView>`.\n */\nexport interface SurfaceHandle {\n /** A client point in the surface's own world — the conversion the surface\n * itself makes, its `clientToWorld` override included. */\n clientToWorld(clientX: number, clientY: number): [number, number];\n /** The outer camera. */\n view(): View;\n /** The canvas's CSS-pixel size. */\n dims(): Dims;\n /** The stack a view paints through its own camera, unless it narrows it. */\n layers(): readonly RenderLayer<unknown>[];\n requestRedraw(): void;\n /** The canvas's own view chrome — its selection, its overlay-aware bounds.\n * What a `<CanvasView>` answers for itself, answered for view zero. */\n chromeState(): ChromeState;\n /** Hit-test the externally registered layers at a world point, against the\n * frame and draw envelope of whichever view is asking. The public\n * `hitTestExtras` is this with the canvas's own frame and envelope. */\n hitTestExtras(\n worldX: number,\n worldY: number,\n view: View,\n dims: Dims,\n data: unknown,\n /** Consider only these layers — the ones the asking view paints. A layer\n * asked on a frame it was not drawn in answers for the wrong pixels. */\n only?: readonly RenderLayer<unknown>[],\n ): { layerId: string; hit: LayerHit } | null;\n /** Whether a registered layer claims a canvas-local point on the surface's\n * own frame. Registered layers paint over every view, so such a point is\n * theirs even inside a view's rect. */\n claimsAbove(x: number, y: number): boolean;\n /** The root camera's input write: clamped, forwarded when controlled, and ending a glide. */\n setView?(next: View): void;\n}\n\n/**\n * A client point in the surface's CSS pixels, from its top-left: the surface's\n * own world point put back through its camera, so a `clientToWorld` override\n * reaches every view declared on it.\n *\n * @internal\n */\nexport function surfaceLocal(\n surface: Pick<SurfaceHandle, 'clientToWorld' | 'view'> | null,\n clientX: number,\n clientY: number,\n): { x: number; y: number } {\n if (!surface) return { x: clientX, y: clientY };\n const [worldX, worldY] = surface.clientToWorld(clientX, clientY);\n const view = surface.view();\n return { x: (worldX - view.x) * view.scale.x, y: (worldY - view.y) * view.scale.y };\n}\n\n/**\n * What one view contributes to the surface hosting it.\n *\n * @internal Written by `<CanvasView>`, read by the surface. Consumers declare\n * a view, not a registration.\n */\nexport interface ViewRegistration {\n id: string;\n /** The view this one is nested in: listed, painted and hit after it, and\n * its `layer` measures itself from that view's rect and camera. */\n parent?: string;\n /**\n * Paint and hit order, low to high. Views declared as props take their array\n * index; a view mounted as a child takes `Infinity`, so it lands after them\n * however React happens to order the mount effects.\n */\n order: number;\n /** The viewport node this view paints into. Its `resolvable` is what routes\n * input here. */\n layer: ViewportLayer<unknown>;\n /** `false` keeps input over the view on the canvas beneath it. */\n interactive: boolean;\n /** `false` leaves `layer` for a host to draw — a HUD window's interior — so\n * the surface does not paint it too. */\n paint: boolean;\n /** Everything about dispatching to this view except its id. */\n target: Omit<DispatcherViewTarget, 'id'>;\n /** Whether a scene layer reaches the screen in this view. For input that\n * reaches a view without a dispatch — hover — so it judges this view's\n * paint rather than the surface's. */\n layerIsPainted(layerId: string): boolean;\n /** The layers this view draws, in order — what a view nested in it paints\n * from. */\n drawnLayers(): readonly RenderLayer<unknown>[];\n /** Whether the view keeps its camera or its aim; the other is derived. */\n held: 'camera' | 'aim';\n /** What the view shows: the aim it holds, or its camera's. */\n aim(): ViewAim;\n /** `false` for an aim the view cannot read, or one with nowhere to go. */\n setAim(aim: ViewAim): boolean;\n}\n\n\n/** @internal */\nexport interface ViewRegistry extends ViewMarkerRegistry {\n /** Returns an unregister. */\n register(reg: ViewRegistration): () => void;\n /** Live registrations in paint order, each nested view after the view it\n * is nested in. */\n list(): readonly ViewRegistration[];\n /** The live registration with `id`, if any. */\n get(id: string): ViewRegistration | undefined;\n /** The innermost view painted under a canvas-local point, whether or not it\n * takes input, passing over `except` and the views nested in it. */\n viewAt(at: { x: number; y: number }, opts?: { except?: string }): ViewAt;\n /** What view `id` shows (`null`: the surface's root), or `null` while there is no such view. */\n aimOf(id: string | null): ViewAim | null;\n /** Point view `id` at `aim`; `false` when it cannot. */\n setAim(id: string | null, aim: ViewAim): boolean;\n /** Bumped whenever the list changes. Pair with {@link ViewRegistry.subscribe}\n * for `useSyncExternalStore`. */\n getVersion(): number;\n subscribe(fn: () => void): () => void;\n /** Which view a client point belongs to, sticky for a captured pointer.\n * One per surface: every caller that routes input — the dispatcher, pinch,\n * hover — must agree about where a point landed. */\n readonly resolver: ViewResolver;\n /** The hosting surface, or `null` before one attaches. */\n surface(): SurfaceHandle | null;\n /** Returns a detach, which leaves a handle attached since alone. */\n attachSurface(handle: SurfaceHandle): () => void;\n}\n\nconst ViewRegistryContext = createContext<ViewRegistry | null>(null);\n\n/** Mounts the registry for one surface. `<SceneCanvas>` mounts one; a view\n * declaring itself as a child must be inside it. */\nexport function ViewRegistryProvider({ children }: { children: ReactNode }) {\n const entriesRef = useRef(new Map<ViewRegistration, number>());\n const seqRef = useRef(0);\n const versionRef = useRef(0);\n const surfaceRef = useRef<SurfaceHandle | null>(null);\n const markersRef = useRef(new Map<() => ViewMarkerProps, RenderLayer<unknown>>());\n\n const registry = useMemo<ViewRegistry>(() => {\n const listeners = createEmitter();\n const changed = (): void => {\n versionRef.current++;\n listeners.emit();\n };\n const ordered = (): ViewRegistration[] => nestedOrder([...entriesRef.current.keys()].sort((a, b) => (\n a.order - b.order || entriesRef.current.get(a)! - entriesRef.current.get(b)!\n )));\n const get = (id: string): ViewRegistration | undefined => {\n for (const r of entriesRef.current.keys()) if (r.id === id) return r;\n return undefined;\n };\n /** Whether `r` is `id` or nested in it, however deep. */\n const within = (r: ViewRegistration, id: string): boolean => {\n const seen = new Set<ViewRegistration>();\n for (let at: ViewRegistration | undefined = r; at && !seen.has(at); at = at.parent === undefined ? undefined : get(at.parent)) {\n if (at.id === id) return true;\n seen.add(at);\n }\n return false;\n };\n const resolver = createViewResolver({\n views: () => {\n const surface = surfaceRef.current;\n const view = surface?.view() ?? IDENTITY_VIEW;\n const dims = surface?.dims() ?? UNMEASURED_DIMS;\n return ordered().filter((r) => r.interactive).map((r) => r.layer.resolvable(view, dims));\n },\n root: () => surfaceRef.current?.view() ?? IDENTITY_VIEW,\n toLocal: (clientX, clientY) => surfaceLocal(surfaceRef.current, clientX, clientY),\n occluded: (x, y) => surfaceRef.current?.claimsAbove(x, y) ?? false,\n });\n const registry: ViewRegistry = {\n resolver,\n register: (reg) => {\n entriesRef.current.set(reg, seqRef.current++);\n changed();\n return () => { entriesRef.current.delete(reg); changed(); };\n },\n list: ordered,\n get,\n viewAt: ({ x, y }, opts) => {\n const surface = surfaceRef.current;\n const view = surface?.view() ?? IDENTITY_VIEW;\n const dims = surface?.dims() ?? UNMEASURED_DIMS;\n const except = opts?.except;\n const list = ordered();\n for (let i = list.length - 1; i >= 0; i--) {\n const r = list[i]!;\n if (except !== undefined && within(r, except)) continue;\n const v = r.layer.resolvable(view, dims);\n if (viewContains(v, x, y)) return { id: v.id, view: v.view, rect: v.rect };\n }\n return { id: null, view, rect: { x: 0, y: 0, w: dims.width, h: dims.height } };\n },\n aimOf: (id) => {\n if (id !== null) return get(id)?.aim() ?? null;\n const surface = surfaceRef.current;\n return surface ? rectAim(null, viewportWorldRect(surface.view(), surface.dims())) : null;\n },\n setAim: (id, aim) => {\n if (id !== null) return get(id)?.setAim(aim) ?? false;\n const surface = surfaceRef.current;\n if (!isRectAim(aim) || !surface?.setView) return false;\n surface.setView(viewForAim(aim.extent, surface.dims(), 'exact'));\n return true;\n },\n ...createViewMarkerRegistry(markersRef.current, {\n host: { aimOf: (id) => registry.aimOf(id), setAim: (id, aim) => registry.setAim(id, aim) },\n surface: () => surfaceRef.current,\n resolve: (id, outer, dims) => get(id)?.layer.resolvable(outer, dims),\n changed,\n }),\n getVersion: () => versionRef.current,\n subscribe: listeners.subscribe,\n surface: () => surfaceRef.current,\n attachSurface: (handle) => {\n surfaceRef.current = handle;\n return () => { if (surfaceRef.current === handle) surfaceRef.current = null; };\n },\n };\n return registry;\n }, []);\n\n return <ViewRegistryContext.Provider value={registry}>{children}</ViewRegistryContext.Provider>;\n}\n\n/** The surface's view registry, or `null` outside one. */\nexport function useOptionalViewRegistry(): ViewRegistry | null {\n return useContext(ViewRegistryContext);\n}\n\n/** Each view followed by the views nested in it, in the order given. A view\n * whose parent is not registered keeps its place; one caught in a cycle\n * goes last. */\nfunction nestedOrder(sorted: readonly ViewRegistration[]): ViewRegistration[] {\n const ids = new Set(sorted.map((r) => r.id));\n const out: ViewRegistration[] = [];\n const placed = new Set<ViewRegistration>();\n const place = (r: ViewRegistration): void => {\n if (placed.has(r)) return;\n placed.add(r);\n out.push(r);\n for (const child of sorted) if (child.parent === r.id) place(child);\n };\n for (const r of sorted) if (r.parent === undefined || !ids.has(r.parent)) place(r);\n for (const r of sorted) place(r);\n return out;\n}\n\n/** The `Dims` a surface reports before it has measured itself. */\nexport const UNMEASURED_DIMS: Dims = { width: 0, height: 0 };\n\n/** The camera a view resolves against before its surface attaches. */\nexport const IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAgB,aACd,SACA,SACA,SAC0B;CAC1B,IAAI,CAAC,SAAS,OAAO;EAAE,GAAG;EAAS,GAAG;CAAQ;CAC9C,MAAM,CAAC,QAAQ,UAAU,QAAQ,cAAc,SAAS,OAAO;CAC/D,MAAM,OAAO,QAAQ,KAAK;CAC1B,OAAO;EAAE,IAAI,SAAS,KAAK,KAAK,KAAK,MAAM;EAAG,IAAI,SAAS,KAAK,KAAK,KAAK,MAAM;CAAE;AACpF;AA2EA,IAAM,sBAAsB,cAAmC,IAAI;;;AAInE,SAAgB,qBAAqB,EAAE,YAAqC;CAC1E,MAAM,aAAa,uBAAO,IAAI,IAA8B,CAAC;CAC7D,MAAM,SAAS,OAAO,CAAC;CACvB,MAAM,aAAa,OAAO,CAAC;CAC3B,MAAM,aAAa,OAA6B,IAAI;CACpD,MAAM,aAAa,uBAAO,IAAI,IAAiD,CAAC;CAEhF,MAAM,WAAW,cAA4B;EAC3C,MAAM,YAAY,cAAc;EAChC,MAAM,gBAAsB;GAC1B,WAAW;GACX,UAAU,KAAK;EACjB;EACA,MAAM,gBAAoC,YAAY,CAAC,GAAG,WAAW,QAAQ,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG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AC1B,gBAAgB,WAAW;IACzB,WAAW,UAAU;IACrB,aAAa;KAAE,IAAI,WAAW,YAAY,QAAQ,WAAW,UAAU;IAAM;GAC/E;EACF;EACA,OAAO;CACT,GAAG,CAAC,CAAC;CAEL,OAAO,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAAW;CAAuC,CAAA;AAChG;;AAGA,SAAgB,0BAA+C;CAC7D,OAAO,WAAW,mBAAmB;AACvC;;;;AAKA,SAAS,YAAY,QAAyD;CAC5E,MAAM,MAAM,IAAI,IAAI,OAAO,KAAK,MAAM,EAAE,EAAE,CAAC;CAC3C,MAAM,MAA0B,CAAC;CACjC,MAAM,yBAAS,IAAI,IAAsB;CACzC,MAAM,SAAS,MAA8B;EAC3C,IAAI,OAAO,IAAI,CAAC,GAAG;EACnB,OAAO,IAAI,CAAC;EACZ,IAAI,KAAK,CAAC;EACV,KAAK,MAAM,SAAS,QAAQ,IAAI,MAAM,WAAW,EAAE,IAAI,MAAM,KAAK;CACpE;CACA,KAAK,MAAM,KAAK,QAAQ,IAAI,EAAE,WAAW,UAAa,CAAC,IAAI,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACjF,KAAK,MAAM,KAAK,QAAQ,MAAM,CAAC;CAC/B,OAAO;AACT;;AAGA,IAAa,kBAAwB;CAAE,OAAO;CAAG,QAAQ;AAAE;;AAG3D,IAAa,gBAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE"}
|
package/dist/clipboard.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeId } from '@weasel-js/routing';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { P as PasteOmission, C as ClipboardSnapshot, I as InsertAdapter } from './types-oFeQ5VjV.js';
|
|
3
|
+
import './types-7puAuVD2.js';
|
|
4
4
|
import '@weasel-js/geom';
|
|
5
|
+
import '@weasel-js/history';
|
|
5
6
|
import './poseDescriptor-DN2yfnq_.js';
|
|
6
7
|
import '@weasel-js/animator';
|
|
7
8
|
|