@weasel-js/core 1.13.0-rc.0 → 1.14.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 +408 -0
- package/README.md +8 -12
- package/dist/affordances/hitAffordanceRegions.js +1 -1
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/animation/clipTargets.js +1 -1
- package/dist/animation/clipTargets.js.map +1 -1
- package/dist/animation/poseTarget.js +5 -32
- package/dist/animation/poseTarget.js.map +1 -1
- package/dist/{autoPoseDescriptor-CZ1eXbzY.d.ts → autoPoseDescriptor-C25QVb0W.d.ts} +1 -1
- package/dist/barrel/canvas.js +8 -8
- package/dist/barrel/chrome.js +9 -9
- package/dist/barrel/input.js +1 -1
- package/dist/barrel/interactions.js +3 -3
- package/dist/barrel/paint.js +2 -2
- package/dist/barrel/paths.js +19 -17
- package/dist/barrel/renderer.js +11 -7
- package/dist/barrel/routing.js +4 -1
- package/dist/barrel/scene.js +16 -12
- package/dist/barrel/text.js +5 -5
- package/dist/barrel/viewport.js +8 -8
- package/dist/canvas/Canvas.js +2 -2
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +20 -14
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/GestureReason.js +64 -0
- package/dist/canvas/GestureReason.js.map +1 -0
- package/dist/canvas/GestureReason.module.js +7 -0
- package/dist/canvas/GestureReason.module.js.map +1 -0
- package/dist/canvas/LeanSceneCanvas.js +3 -1
- package/dist/canvas/LeanSceneCanvas.js.map +1 -1
- package/dist/canvas/NodeShape.js +2 -0
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/PickHud.js +7 -3
- package/dist/canvas/PickHud.js.map +1 -1
- package/dist/canvas/SceneCanvas/CanvasKitProviders.js +1 -1
- package/dist/canvas/SceneCanvas/CanvasKitProviders.js.map +1 -1
- package/dist/canvas/SceneCanvas/DevHuds.js +2 -2
- package/dist/canvas/SceneCanvas/DevHuds.js.map +1 -1
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +4 -2
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js +3 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
- package/dist/canvas/SceneCanvas/brushOverlay.js.map +1 -1
- package/dist/canvas/SceneCanvas/builtinToolSets.js +17 -9
- package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -1
- package/dist/canvas/SceneCanvas/canvasPassThrough.js +2 -1
- package/dist/canvas/SceneCanvas/canvasPassThrough.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +75 -19
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +7 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultTextEditor.js +108 -0
- package/dist/canvas/SceneCanvas/defaultTextEditor.js.map +1 -0
- package/dist/canvas/SceneCanvas/describePresets.js +47 -0
- package/dist/canvas/SceneCanvas/describePresets.js.map +1 -0
- package/dist/canvas/SceneCanvas/features.js +57 -16
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/mergeLayers.js +10 -1
- package/dist/canvas/SceneCanvas/mergeLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/namedPresets.js +52 -24
- package/dist/canvas/SceneCanvas/namedPresets.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/arrange.js +35 -10
- package/dist/canvas/SceneCanvas/presets/arrange.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/baseline.js +9 -0
- package/dist/canvas/SceneCanvas/presets/baseline.js.map +1 -0
- package/dist/canvas/SceneCanvas/presets/chrome.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/composites.js +43 -0
- package/dist/canvas/SceneCanvas/presets/composites.js.map +1 -0
- package/dist/canvas/SceneCanvas/presets/edit.js +79 -26
- package/dist/canvas/SceneCanvas/presets/edit.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/ingest.js +1 -0
- package/dist/canvas/SceneCanvas/presets/ingest.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/paths.js +58 -16
- package/dist/canvas/SceneCanvas/presets/paths.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/select.js +4 -2
- package/dist/canvas/SceneCanvas/presets/select.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/tools.js +24 -0
- package/dist/canvas/SceneCanvas/presets/tools.js.map +1 -0
- package/dist/canvas/SceneCanvas/presets/transform.js +4 -0
- package/dist/canvas/SceneCanvas/presets/transform.js.map +1 -1
- package/dist/canvas/SceneCanvas/presets/view.js +3 -1
- package/dist/canvas/SceneCanvas/presets/view.js.map +1 -1
- package/dist/canvas/SceneCanvas/props.js.map +1 -1
- package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js +1 -1
- package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/toolRegistry.js +5 -4
- package/dist/canvas/SceneCanvas/toolRegistry.js.map +1 -1
- package/dist/canvas/SceneCanvas/useCanvasTools.js +26 -10
- package/dist/canvas/SceneCanvas/useCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useContributionRoles.js +17 -2
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -1
- package/dist/canvas/SceneCanvas/useDepartureGhostLayer.js +5 -4
- package/dist/canvas/SceneCanvas/useDepartureGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +1 -1
- package/dist/canvas/SceneCanvas/useNodeAtPoint.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js +9 -8
- package/dist/canvas/SceneCanvas/useSceneCanvasLayers.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasPathEdit.js +2 -2
- package/dist/canvas/SceneCanvas/useSceneCanvasPathEdit.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js +4 -1
- package/dist/canvas/SceneCanvas/useSceneCanvasTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneChrome.js +7 -4
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js +9 -9
- package/dist/canvas/SceneCanvas/useSceneGestureDispatcher.js.map +1 -1
- package/dist/canvas/SceneCanvas/useScenePicking.js +4 -7
- package/dist/canvas/SceneCanvas/useScenePicking.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js +2 -1
- package/dist/canvas/SceneCanvas/useSceneRedrawSources.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +6 -6
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +2 -2
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js +1 -1
- package/dist/canvas/SceneCanvas/useSelectionOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSurfaceViewInputs.js.map +1 -1
- package/dist/canvas/SceneCanvas/useToolKeybindings.js +2 -2
- package/dist/canvas/SceneCanvas/useToolKeybindings.js.map +1 -1
- package/dist/canvas/SceneCanvas/useViewportActions.js +5 -2
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -1
- package/dist/canvas/SceneCanvas/worldPointAt.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +22 -11
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +1 -0
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/ViewMarker.js.map +1 -1
- package/dist/canvas/accentColor.js +14 -1
- package/dist/canvas/accentColor.js.map +1 -1
- package/dist/canvas/affordanceAt.js +2 -2
- package/dist/canvas/affordanceAt.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js +1 -1
- package/dist/canvas/buildSceneLayer.js.map +1 -1
- package/dist/canvas/buildSceneTree.js +5 -3
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/canvasRenderer.js +6 -2
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/deps/editAnchors.js +4 -4
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/enteredGroup.js +14 -5
- package/dist/canvas/deps/enteredGroup.js.map +1 -1
- package/dist/canvas/deps/ingestion.js +5 -1
- package/dist/canvas/deps/ingestion.js.map +1 -1
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/insertSite.js +5 -3
- package/dist/canvas/deps/insertSite.js.map +1 -1
- package/dist/canvas/deps/nodeAtPoint.js +1 -12
- package/dist/canvas/deps/nodeAtPoint.js.map +1 -1
- package/dist/canvas/deps/pathEditCommits.js +3 -3
- package/dist/canvas/deps/pathEditCommits.js.map +1 -1
- package/dist/canvas/deps/slice.js +16 -2
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/deps/snap.js +5 -5
- package/dist/canvas/deps/snap.js.map +1 -1
- package/dist/canvas/deps/textEdit.js +5 -6
- package/dist/canvas/deps/textEdit.js.map +1 -1
- package/dist/canvas/derivedPath.js +8 -3
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/getNodeAtPoint.js +2 -2
- package/dist/canvas/getNodeAtPoint.js.map +1 -1
- package/dist/canvas/insertPreviewExtent.js.map +1 -1
- package/dist/canvas/layerSlots.js.map +1 -1
- package/dist/canvas/nodeShapes/measurePainter.js +1 -1
- package/dist/canvas/nodeShapes/measurePainter.js.map +1 -1
- package/dist/canvas/nodeShapes/strokedBounds.js +5 -3
- package/dist/canvas/nodeShapes/strokedBounds.js.map +1 -1
- package/dist/canvas/overlayRoleStrokes.js +6 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/pickIndex/scenePickIndex.js +10 -12
- package/dist/canvas/pickIndex/scenePickIndex.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +10 -19
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +17 -4
- package/dist/canvas/sceneClipboard.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +7 -5
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/surfaceContribution.js.map +1 -1
- package/dist/canvas/useCanvasPaint.js +12 -4
- package/dist/canvas/useCanvasPaint.js.map +1 -1
- package/dist/canvas/useHitObserver.js +1 -1
- package/dist/canvas/useHitObserver.js.map +1 -1
- package/dist/canvas/useViewAim.js +1 -1
- package/dist/canvas/useViewAim.js.map +1 -1
- package/dist/canvas/useViewHelpers.js +8 -5
- package/dist/canvas/useViewHelpers.js.map +1 -1
- package/dist/canvas/useViewNesting.js +39 -12
- package/dist/canvas/useViewNesting.js.map +1 -1
- package/dist/canvas/viewInputs.js.map +1 -1
- package/dist/canvas/viewMarkers.js +2 -2
- package/dist/canvas/viewMarkers.js.map +1 -1
- package/dist/canvas/viewRegistry.js +2 -2
- package/dist/canvas/viewRegistry.js.map +1 -1
- package/dist/canvas/viewSnap.js +67 -0
- package/dist/canvas/viewSnap.js.map +1 -0
- package/dist/clipboard.d.ts +6 -12
- package/dist/{clone-qb2e1F5p.d.ts → clone-Bz4iqGfE.d.ts} +10 -5
- package/dist/clone.d.ts +5 -5
- package/dist/core/geometry/booleanOfPaths.js +23 -0
- package/dist/core/geometry/booleanOfPaths.js.map +1 -0
- package/dist/core/geometry/pathPoseDescriptor.js +12 -9
- package/dist/core/geometry/pathPoseDescriptor.js.map +1 -1
- package/dist/core/geometry/poseDescriptor.js +12 -3
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/targetFrame.js +2 -13
- package/dist/core/geometry/targetFrame.js.map +1 -1
- package/dist/core/layers/render.js +2 -1
- package/dist/core/layers/render.js.map +1 -1
- package/dist/core/layers/retain.js +5 -3
- package/dist/core/layers/retain.js.map +1 -1
- package/dist/core/ops/setPath.js +3 -0
- package/dist/core/ops/setPath.js.map +1 -1
- package/dist/core/paint/meshKindLazy.js.map +1 -1
- package/dist/core/paint/paintKindEntry.js.map +1 -1
- package/dist/core/paint/paintKinds.js +8 -1
- package/dist/core/paint/paintKinds.js.map +1 -1
- package/dist/core/scene/NodeProperties.js.map +1 -1
- package/dist/core/scene/NodeRouting.js.map +1 -1
- package/dist/core/scene/booleanGroup.js +33 -0
- package/dist/core/scene/booleanGroup.js.map +1 -0
- package/dist/core/scene/booleanOfChildren.js +53 -0
- package/dist/core/scene/booleanOfChildren.js.map +1 -0
- package/dist/core/scene/carryDescendants.js +18 -6
- package/dist/core/scene/carryDescendants.js.map +1 -1
- package/dist/core/scene/composeFrame.js +42 -5
- package/dist/core/scene/composeFrame.js.map +1 -1
- package/dist/core/scene/composePose.js +35 -16
- package/dist/core/scene/composePose.js.map +1 -1
- package/dist/core/scene/depMemo.js +36 -18
- package/dist/core/scene/depMemo.js.map +1 -1
- package/dist/core/scene/derivedParts.js +2 -23
- package/dist/core/scene/derivedParts.js.map +1 -1
- package/dist/core/scene/effectivePose.js +10 -0
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/historyForm.js +5 -4
- package/dist/core/scene/historyForm.js.map +1 -1
- package/dist/core/scene/kitOps.js +5 -71
- package/dist/core/scene/kitOps.js.map +1 -1
- package/dist/core/scene/kitRegistry.js +5 -0
- package/dist/core/scene/kitRegistry.js.map +1 -1
- package/dist/core/scene/layerOps.js +82 -0
- package/dist/core/scene/layerOps.js.map +1 -0
- package/dist/core/scene/layoutPass.js +14 -12
- package/dist/core/scene/layoutPass.js.map +1 -1
- package/dist/core/scene/lockGuard.js +9 -3
- package/dist/core/scene/lockGuard.js.map +1 -1
- package/dist/core/scene/nestedHit.js +5 -5
- package/dist/core/scene/nestedHit.js.map +1 -1
- package/dist/core/scene/nodeFlags.js +8 -2
- package/dist/core/scene/nodeFlags.js.map +1 -1
- package/dist/core/scene/nodeGates.js +31 -2
- package/dist/core/scene/nodeGates.js.map +1 -1
- package/dist/core/scene/pathEffects/effects.js +22 -3
- package/dist/core/scene/pathEffects/effects.js.map +1 -1
- package/dist/core/scene/pathEffects/textAlong.js +16 -3
- package/dist/core/scene/pathEffects/textAlong.js.map +1 -1
- package/dist/core/scene/pathEffects/textAlongBands.js +65 -0
- package/dist/core/scene/pathEffects/textAlongBands.js.map +1 -0
- package/dist/core/scene/reconcileSpecs.js +1 -1
- package/dist/core/scene/reconcileSpecs.js.map +1 -1
- package/dist/core/scene/scene.js +11 -5
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/sceneEdits.js +5 -2
- package/dist/core/scene/sceneEdits.js.map +1 -1
- package/dist/core/scene/scenePoseAdapter.js +10 -1
- package/dist/core/scene/scenePoseAdapter.js.map +1 -1
- package/dist/core/scene/scrollOffsets.js +93 -0
- package/dist/core/scene/scrollOffsets.js.map +1 -0
- package/dist/core/scene/serialization.js +15 -5
- package/dist/core/scene/serialization.js.map +1 -1
- package/dist/core/scene/statedFields.js +2 -1
- package/dist/core/scene/statedFields.js.map +1 -1
- package/dist/core/scene/strategyView.js +35 -0
- package/dist/core/scene/strategyView.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/scene/useScene.js +2 -0
- package/dist/core/scene/useScene.js.map +1 -1
- package/dist/core/scene/worldSave.js +87 -0
- package/dist/core/scene/worldSave.js.map +1 -0
- package/dist/core/selection/selectionTarget.js +1 -1
- package/dist/core/selection/selectionTarget.js.map +1 -1
- package/dist/{cornerHandles-CNCb7aTY.d.ts → cornerHandles-DpmQM_z5.d.ts} +1 -1
- package/dist/{depSchema-B1RS-IJx.d.ts → depSchema-C3BwxitB.d.ts} +130 -104
- package/dist/devtools-protocol.d.ts +2 -2
- package/dist/devtools.d.ts +2 -2
- package/dist/{features → domains}/chrome-caps/buildChromeCtx.js +1 -1
- package/dist/domains/chrome-caps/buildChromeCtx.js.map +1 -0
- package/dist/{features → domains}/chrome-caps/conditions.js +1 -1
- package/dist/domains/chrome-caps/conditions.js.map +1 -0
- package/dist/{features → domains}/chrome-caps/defaults.js +1 -1
- package/dist/domains/chrome-caps/defaults.js.map +1 -0
- package/dist/{features → domains}/chrome-caps/resolve.js +1 -1
- package/dist/domains/chrome-caps/resolve.js.map +1 -0
- package/dist/{features → domains}/chrome-caps/useChromeCaps.js +1 -1
- package/dist/domains/chrome-caps/useChromeCaps.js.map +1 -0
- package/dist/{features → domains}/chrome-caps/useHoverTracking.js +1 -1
- package/dist/domains/chrome-caps/useHoverTracking.js.map +1 -0
- package/dist/{features → domains}/ingestion/contentHandlers.js +20 -3
- package/dist/domains/ingestion/contentHandlers.js.map +1 -0
- package/dist/domains/ingestion/ghost.js +56 -0
- package/dist/domains/ingestion/ghost.js.map +1 -0
- package/dist/{features → domains}/ingestion/imageHandler.js +1 -1
- package/dist/domains/ingestion/imageHandler.js.map +1 -0
- package/dist/domains/ingestion/kitHandlers.js +22 -0
- package/dist/domains/ingestion/kitHandlers.js.map +1 -0
- package/dist/{features → domains}/ingestion/openFilePicker.js +1 -1
- package/dist/domains/ingestion/openFilePicker.js.map +1 -0
- package/dist/{features → domains}/ingestion/placement.js +1 -1
- package/dist/domains/ingestion/placement.js.map +1 -0
- package/dist/{features → domains}/ingestion/svgHandler.js +1 -1
- package/dist/domains/ingestion/svgHandler.js.map +1 -0
- package/dist/{features → domains}/ingestion/textHandler.js +9 -7
- package/dist/domains/ingestion/textHandler.js.map +1 -0
- package/dist/{features → domains}/ingestion/useCanvasIngestion.js +13 -15
- package/dist/domains/ingestion/useCanvasIngestion.js.map +1 -0
- package/dist/{features → domains}/ingestion/weaselJsonHandler.js +1 -1
- package/dist/domains/ingestion/weaselJsonHandler.js.map +1 -0
- package/dist/{features → domains}/longPress/longPressFeedback.js +1 -1
- package/dist/domains/longPress/longPressFeedback.js.map +1 -0
- package/dist/{features → domains}/measure/actionIds.js +1 -1
- package/dist/domains/measure/actionIds.js.map +1 -0
- package/dist/{features → domains}/measure/measureCommands.js +1 -1
- package/dist/domains/measure/measureCommands.js.map +1 -0
- package/dist/{features → domains}/measure/measureContribution.js +1 -1
- package/dist/domains/measure/measureContribution.js.map +1 -0
- package/dist/{features → domains}/measure/measureEdits.js +1 -1
- package/dist/domains/measure/measureEdits.js.map +1 -0
- package/dist/{features → domains}/measure/measureGestures.js +4 -7
- package/dist/domains/measure/measureGestures.js.map +1 -0
- package/dist/{features → domains}/measure/measureHit.js +1 -1
- package/dist/domains/measure/measureHit.js.map +1 -0
- package/dist/{features → domains}/measure/measureLayer.js +1 -1
- package/dist/domains/measure/measureLayer.js.map +1 -0
- package/dist/{features → domains}/measure/measurement.js +1 -1
- package/dist/domains/measure/measurement.js.map +1 -0
- package/dist/{features → domains}/measure/measurements.js +2 -2
- package/dist/domains/measure/measurements.js.map +1 -0
- package/dist/{features → domains}/modes/modeLayers.js +1 -1
- package/dist/domains/modes/modeLayers.js.map +1 -0
- package/dist/{features → domains}/modes/modeTriggers.js +3 -6
- package/dist/domains/modes/modeTriggers.js.map +1 -0
- package/dist/{features → domains}/pathEffects/effectSources.js +1 -1
- package/dist/domains/pathEffects/effectSources.js.map +1 -0
- package/dist/{features → domains}/pathEffects/index.js +1 -1
- package/dist/domains/pathEffects/index.js.map +1 -0
- package/dist/{features → domains}/pathEffects/readSource.js +1 -1
- package/dist/domains/pathEffects/readSource.js.map +1 -0
- package/dist/{features → domains}/pathEffects/textItems.js +11 -2
- package/dist/domains/pathEffects/textItems.js.map +1 -0
- package/dist/{features → domains}/pathEffects/useEffectSourcesLayer.js +1 -1
- package/dist/domains/pathEffects/useEffectSourcesLayer.js.map +1 -0
- package/dist/{features → domains}/paths/anchorData.js +1 -1
- package/dist/domains/paths/anchorData.js.map +1 -0
- package/dist/{features → domains}/paths/anchorMarkers.js +9 -7
- package/dist/domains/paths/anchorMarkers.js.map +1 -0
- package/dist/{features → domains}/paths/editablePath.js +1 -1
- package/dist/domains/paths/editablePath.js.map +1 -0
- package/dist/{features → domains}/paths/index.js +3 -3
- package/dist/{features → domains}/paths/originProjection.js +1 -1
- package/dist/domains/paths/originProjection.js.map +1 -0
- package/dist/{features → domains}/paths/pathEditExtension.js +1 -1
- package/dist/domains/paths/pathEditExtension.js.map +1 -0
- package/dist/{features → domains}/paths/pathEditState.js +1 -1
- package/dist/domains/paths/pathEditState.js.map +1 -0
- package/dist/{features → domains}/paths/pathEditingOverlayLayer.js +1 -1
- package/dist/domains/paths/pathEditingOverlayLayer.js.map +1 -0
- package/dist/{features → domains}/paths/pathLayer.js +1 -1
- package/dist/domains/paths/pathLayer.js.map +1 -0
- package/dist/{features → domains}/paths/pathRepresentation.js +1 -1
- package/dist/domains/paths/pathRepresentation.js.map +1 -0
- package/dist/{features → domains}/paths/pathSnap/glyphs.js +1 -1
- package/dist/domains/paths/pathSnap/glyphs.js.map +1 -0
- package/dist/{features → domains}/paths/pathSnap/pathSnapSource.js +1 -1
- package/dist/domains/paths/pathSnap/pathSnapSource.js.map +1 -0
- package/dist/{features → domains}/paths/pathSnap/sceneIndex.js +1 -1
- package/dist/domains/paths/pathSnap/sceneIndex.js.map +1 -0
- package/dist/{features → domains}/paths/pathSnap/snapGeometry.js +3 -2
- package/dist/domains/paths/pathSnap/snapGeometry.js.map +1 -0
- package/dist/{features → domains}/paths/penPreviewLayer.js +1 -1
- package/dist/domains/paths/penPreviewLayer.js.map +1 -0
- package/dist/{features → domains}/paths/shapeGenerator.js +6 -4
- package/dist/domains/paths/shapeGenerator.js.map +1 -0
- package/dist/{features → domains}/paths/strokeOutline.js +1 -1
- package/dist/domains/paths/strokeOutline.js.map +1 -0
- package/dist/{features → domains}/paths/useAnchorFields.js +1 -1
- package/dist/domains/paths/useAnchorFields.js.map +1 -0
- package/dist/{features → domains}/paths/usePathEdit.js +1 -1
- package/dist/domains/paths/usePathEdit.js.map +1 -0
- package/dist/{features → domains}/poseRun/usePoseRun.js +1 -1
- package/dist/domains/poseRun/usePoseRun.js.map +1 -0
- package/dist/{features → domains}/selection/enteredGroupFrame.js +49 -10
- package/dist/domains/selection/enteredGroupFrame.js.map +1 -0
- package/dist/{features → domains}/selection/enteredGroupScope.js +1 -1
- package/dist/domains/selection/enteredGroupScope.js.map +1 -0
- package/dist/domains/selection/enteredOperands.js +29 -0
- package/dist/domains/selection/enteredOperands.js.map +1 -0
- package/dist/{features → domains}/selection/handleCommands.js +1 -1
- package/dist/domains/selection/handleCommands.js.map +1 -0
- package/dist/{features → domains}/selection/overlay.js +1 -1
- package/dist/domains/selection/overlay.js.map +1 -0
- package/dist/{features → domains}/selection/selectionPose.js +1 -1
- package/dist/domains/selection/selectionPose.js.map +1 -0
- package/dist/{features → domains}/snap/angle2d.js +1 -1
- package/dist/domains/snap/angle2d.js.map +1 -0
- package/dist/{features → domains}/snap/debugCandidates.js +1 -1
- package/dist/domains/snap/debugCandidates.js.map +1 -0
- package/dist/{features → domains}/snap/gather.js +1 -1
- package/dist/domains/snap/gather.js.map +1 -0
- package/dist/{features → domains}/snap/inputSubspace.js +1 -1
- package/dist/domains/snap/inputSubspace.js.map +1 -0
- package/dist/{features → domains}/snap/lazySession.js +1 -1
- package/dist/domains/snap/lazySession.js.map +1 -0
- package/dist/{features → domains}/snap/marks.js +1 -1
- package/dist/domains/snap/marks.js.map +1 -0
- package/dist/{features → domains}/snap/outcomeStore.js +1 -1
- package/dist/domains/snap/outcomeStore.js.map +1 -0
- package/dist/{features → domains}/snap/pointSnap.js +1 -1
- package/dist/domains/snap/pointSnap.js.map +1 -0
- package/dist/{features → domains}/snap/probes2d.js +1 -1
- package/dist/domains/snap/probes2d.js.map +1 -0
- package/dist/{features → domains}/snap/readoutDraw.js +1 -1
- package/dist/domains/snap/readoutDraw.js.map +1 -0
- package/dist/{features → domains}/snap/readoutLayer.js +1 -1
- package/dist/domains/snap/readoutLayer.js.map +1 -0
- package/dist/{features → domains}/snap/registry.js +1 -1
- package/dist/domains/snap/registry.js.map +1 -0
- package/dist/{features → domains}/snap/resizeBox.js +1 -1
- package/dist/domains/snap/resizeBox.js.map +1 -0
- package/dist/{features → domains}/snap/roles.js +1 -1
- package/dist/domains/snap/roles.js.map +1 -0
- package/dist/{features → domains}/snap/rotationSource.js +1 -1
- package/dist/domains/snap/rotationSource.js.map +1 -0
- package/dist/{features → domains}/snap/sceneReads.js +24 -3
- package/dist/domains/snap/sceneReads.js.map +1 -0
- package/dist/{features → domains}/snap/sceneSession2d.js +3 -2
- package/dist/domains/snap/sceneSession2d.js.map +1 -0
- package/dist/{features → domains}/snap/screen.js +1 -1
- package/dist/domains/snap/screen.js.map +1 -0
- package/dist/{features → domains}/snap/session2d.js +3 -2
- package/dist/domains/snap/session2d.js.map +1 -0
- package/dist/{features → domains}/snap/spanSnap.js +1 -1
- package/dist/domains/snap/spanSnap.js.map +1 -0
- package/dist/{features → domains}/snap/stepAngles.js +1 -1
- package/dist/domains/snap/stepAngles.js.map +1 -0
- package/dist/{features → domains}/text/editingDrawOne.js +4 -4
- package/dist/domains/text/editingDrawOne.js.map +1 -0
- package/dist/domains/text/hostTextEditors.js +24 -0
- package/dist/domains/text/hostTextEditors.js.map +1 -0
- package/dist/{features → domains}/text/index.js +1 -1
- package/dist/{features → domains}/text/sceneTextDrafts.js +1 -1
- package/dist/domains/text/sceneTextDrafts.js.map +1 -0
- package/dist/{features → domains}/text/textHitAt.js +18 -2
- package/dist/domains/text/textHitAt.js.map +1 -0
- package/dist/{features → domains}/text/textLayer.js +1 -1
- package/dist/domains/text/textLayer.js.map +1 -0
- package/dist/{features → domains}/text/useSceneTextEdit.js +11 -3
- package/dist/domains/text/useSceneTextEdit.js.map +1 -0
- package/dist/{features → domains}/viewports/aim.js +1 -1
- package/dist/domains/viewports/aim.js.map +1 -0
- package/dist/{features → domains}/viewports/viewMarker.js +23 -5
- package/dist/domains/viewports/viewMarker.js.map +1 -0
- package/dist/{features → domains}/viewports/viewMarkerDrag.js +3 -3
- package/dist/domains/viewports/viewMarkerDrag.js.map +1 -0
- package/dist/{features → domains}/viewports/viewResolver.js +1 -1
- package/dist/domains/viewports/viewResolver.js.map +1 -0
- package/dist/{features → domains}/viewports/viewportLayer.js +3 -2
- package/dist/domains/viewports/viewportLayer.js.map +1 -0
- package/dist/icons.table.js +1 -1
- package/dist/icons.table.js.map +1 -1
- package/dist/icons.table.json +106 -6
- package/dist/index.d.ts +1445 -1053
- package/dist/index.js +90 -77
- package/dist/interactions/actions/admitsChild.js +6 -2
- package/dist/interactions/actions/admitsChild.js.map +1 -1
- package/dist/interactions/actions/align/align.js +1 -4
- package/dist/interactions/actions/align/align.js.map +1 -1
- package/dist/interactions/actions/booleans/booleanGroupAction.js +66 -0
- package/dist/interactions/actions/booleans/booleanGroupAction.js.map +1 -0
- package/dist/interactions/actions/booleans/keymap.js +52 -0
- package/dist/interactions/actions/booleans/keymap.js.map +1 -0
- package/dist/interactions/actions/booleans/operands.js +1 -1
- package/dist/interactions/actions/booleans/pieces.js +4 -11
- package/dist/interactions/actions/booleans/pieces.js.map +1 -1
- package/dist/interactions/actions/clipboard/action.js +3 -7
- package/dist/interactions/actions/clipboard/action.js.map +1 -1
- package/dist/interactions/actions/clipboard/clipboardOps.js +1 -1
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +6 -6
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
- package/dist/interactions/actions/defaults/containerScroll.js +170 -0
- package/dist/interactions/actions/defaults/containerScroll.js.map +1 -0
- package/dist/interactions/actions/defaults/contextMenu.js +2 -5
- package/dist/interactions/actions/defaults/contextMenu.js.map +1 -1
- package/dist/interactions/actions/defaults/delete.js +1 -1
- package/dist/interactions/actions/defaults/delete.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +1 -3
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/enterGroup.js +7 -12
- package/dist/interactions/actions/defaults/enterGroup.js.map +1 -1
- package/dist/interactions/actions/defaults/enterPathEdit.js +4 -8
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +12 -24
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +18 -10
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +3 -3
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
- package/dist/interactions/actions/defaults/nudgeSteps.js +3 -21
- package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -1
- package/dist/interactions/actions/defaults/pathEditMarks.js.map +1 -1
- package/dist/interactions/actions/defaults/selectDeep.js +2 -2
- package/dist/interactions/actions/defaults/selectDeep.js.map +1 -1
- package/dist/interactions/actions/distribute/distribute.js.map +1 -1
- package/dist/interactions/actions/dropVerdict.js +9 -0
- package/dist/interactions/actions/dropVerdict.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/action.js +2 -2
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/extensionDrags.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/geometry.js +8 -6
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/handleDrag.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/preview.js +1 -1
- package/dist/interactions/actions/edit-anchors/preview.js.map +1 -1
- package/dist/interactions/actions/flip/action.js +3 -2
- package/dist/interactions/actions/flip/action.js.map +1 -1
- package/dist/interactions/actions/geometryProjection.js +8 -3
- package/dist/interactions/actions/geometryProjection.js.map +1 -1
- package/dist/interactions/actions/gestureFrames.js +1 -0
- package/dist/interactions/actions/gestureFrames.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +6 -2
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/frame.js +1 -1
- package/dist/interactions/actions/insert/frame.js.map +1 -1
- package/dist/interactions/actions/insert/placeAction.js +6 -8
- package/dist/interactions/actions/insert/placeAction.js.map +1 -1
- package/dist/interactions/actions/insert/session.js +2 -2
- package/dist/interactions/actions/insert/session.js.map +1 -1
- package/dist/interactions/actions/move/action.js +6 -15
- package/dist/interactions/actions/move/action.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/layoutDrop.js +12 -2
- package/dist/interactions/actions/move/behaviors/layoutDrop.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js +29 -10
- package/dist/interactions/actions/move/behaviors/reparentOnDrop.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +42 -6
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/capture.js +4 -8
- package/dist/interactions/actions/move/capture.js.map +1 -1
- package/dist/interactions/actions/move/commit/index.js.map +1 -1
- package/dist/interactions/actions/move/commit/layoutDrop.js +4 -3
- package/dist/interactions/actions/move/commit/layoutDrop.js.map +1 -1
- package/dist/interactions/actions/move/commit/layoutRelease.js +15 -9
- package/dist/interactions/actions/move/commit/layoutRelease.js.map +1 -1
- package/dist/interactions/actions/move/commit/reparent.js +19 -13
- package/dist/interactions/actions/move/commit/reparent.js.map +1 -1
- package/dist/interactions/actions/move/delta.js +51 -5
- package/dist/interactions/actions/move/delta.js.map +1 -1
- package/dist/interactions/actions/move/frame.js +8 -4
- package/dist/interactions/actions/move/frame.js.map +1 -1
- package/dist/interactions/actions/move/layout/container.js +19 -9
- package/dist/interactions/actions/move/layout/container.js.map +1 -1
- package/dist/interactions/actions/move/layout/dragged.js +2 -2
- package/dist/interactions/actions/move/layout/dragged.js.map +1 -1
- package/dist/interactions/actions/move/layout/dropPass.js +36 -18
- package/dist/interactions/actions/move/layout/dropPass.js.map +1 -1
- package/dist/interactions/actions/move/layout/exits.js +2 -2
- package/dist/interactions/actions/move/layout/exits.js.map +1 -1
- package/dist/interactions/actions/move/layout/glide.js +5 -5
- package/dist/interactions/actions/move/layout/glide.js.map +1 -1
- package/dist/interactions/actions/move/layout/view.js +55 -0
- package/dist/interactions/actions/move/layout/view.js.map +1 -0
- package/dist/interactions/actions/move/refusal.js +52 -0
- package/dist/interactions/actions/move/refusal.js.map +1 -0
- package/dist/interactions/actions/move/session.js +9 -8
- package/dist/interactions/actions/move/session.js.map +1 -1
- package/dist/interactions/actions/move/translate.js +10 -4
- package/dist/interactions/actions/move/translate.js.map +1 -1
- package/dist/interactions/actions/moveNodes.js +21 -5
- package/dist/interactions/actions/moveNodes.js.map +1 -1
- package/dist/interactions/actions/pathCommands/pathNodes.js +3 -3
- package/dist/interactions/actions/pathCommands/pathNodes.js.map +1 -1
- package/dist/interactions/actions/planeInput.js +14 -13
- package/dist/interactions/actions/planeInput.js.map +1 -1
- package/dist/interactions/actions/poseFrame.js +21 -8
- package/dist/interactions/actions/poseFrame.js.map +1 -1
- package/dist/interactions/actions/resize/action.js +1 -1
- package/dist/interactions/actions/resize/action.js.map +1 -1
- package/dist/interactions/actions/resize/aspect.js +1 -1
- package/dist/interactions/actions/resize/aspect.js.map +1 -1
- package/dist/interactions/actions/resize/commit.js +10 -1
- package/dist/interactions/actions/resize/commit.js.map +1 -1
- package/dist/interactions/actions/resize/frame.js +3 -2
- package/dist/interactions/actions/resize/frame.js.map +1 -1
- package/dist/interactions/actions/resize/held.js +44 -0
- package/dist/interactions/actions/resize/held.js.map +1 -0
- package/dist/interactions/actions/resize/session.js +3 -1
- package/dist/interactions/actions/resize/session.js.map +1 -1
- package/dist/interactions/actions/resolveOverlays.js +9 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -1
- package/dist/interactions/actions/resolvePreviews.js +23 -7
- package/dist/interactions/actions/resolvePreviews.js.map +1 -1
- package/dist/interactions/actions/rotate/action.js +1 -1
- package/dist/interactions/actions/rotate/action.js.map +1 -1
- package/dist/interactions/actions/rotate/frame.js +1 -1
- package/dist/interactions/actions/rotate/frame.js.map +1 -1
- package/dist/interactions/actions/rotate/session.js +2 -2
- package/dist/interactions/actions/rotate/session.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +2 -4
- package/dist/interactions/actions/selectionSubtree.js.map +1 -1
- package/dist/interactions/actions/spatialReference.js +4 -9
- package/dist/interactions/actions/spatialReference.js.map +1 -1
- package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -1
- package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -1
- package/dist/kitSettingsSchema.js +2 -2
- package/dist/kitSettingsSchema.js.map +1 -1
- package/dist/{math-C_elShP_.d.ts → math-B_unOnF4.d.ts} +2 -2
- package/dist/math.d.ts +3 -3
- package/dist/move.d.ts +6 -6
- package/dist/{options-ClEm3SEl.d.ts → options-DAjkhbcs.d.ts} +5 -5
- package/dist/{poseDescriptor-DN2yfnq_.d.ts → poseDescriptor-CvSxVhCd.d.ts} +17 -4
- package/dist/resize.d.ts +6 -6
- package/dist/style.css +14 -0
- package/dist/test-seams.d.ts +11 -15
- package/dist/test-seams.js +1 -1
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +3 -6
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/measure/useMeasureTool.js +2 -2
- package/dist/tools/builtin/measure/useMeasureTool.js.map +1 -1
- package/dist/tools/builtin/pen/penHandle.js +2 -2
- package/dist/tools/builtin/pen/penHandle.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +13 -19
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/select/groupEntry.js +1 -1
- package/dist/tools/builtin/select/groupEntry.js.map +1 -1
- package/dist/tools/builtin/select/selectionContributions.js +1 -1
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +7 -7
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/slice/useSliceTool.js +5 -8
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +1 -1
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/{types-49uYJN3j.d.ts → types-A_sNJYRd.d.ts} +8 -0
- package/dist/{types-BEdRIhNc.d.ts → types-DW14eu9B.d.ts} +131 -36
- package/dist/{types-p2alu-R1.d.ts → types-VCtfchp-.d.ts} +4 -6
- package/dist/util/color.js +12 -14
- package/dist/util/color.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +25 -24
- package/dist/canvas/poseCascade.js +0 -65
- package/dist/canvas/poseCascade.js.map +0 -1
- package/dist/features/chrome-caps/buildChromeCtx.js.map +0 -1
- package/dist/features/chrome-caps/conditions.js.map +0 -1
- package/dist/features/chrome-caps/defaults.js.map +0 -1
- package/dist/features/chrome-caps/resolve.js.map +0 -1
- package/dist/features/chrome-caps/useChromeCaps.js.map +0 -1
- package/dist/features/chrome-caps/useHoverTracking.js.map +0 -1
- package/dist/features/ingestion/contentHandlers.js.map +0 -1
- package/dist/features/ingestion/imageHandler.js.map +0 -1
- package/dist/features/ingestion/openFilePicker.js.map +0 -1
- package/dist/features/ingestion/placement.js.map +0 -1
- package/dist/features/ingestion/registerKitHandlers.js +0 -43
- package/dist/features/ingestion/registerKitHandlers.js.map +0 -1
- package/dist/features/ingestion/svgHandler.js.map +0 -1
- package/dist/features/ingestion/textHandler.js.map +0 -1
- package/dist/features/ingestion/useCanvasIngestion.js.map +0 -1
- package/dist/features/ingestion/weaselJsonHandler.js.map +0 -1
- package/dist/features/longPress/longPressFeedback.js.map +0 -1
- package/dist/features/measure/actionIds.js.map +0 -1
- package/dist/features/measure/measureCommands.js.map +0 -1
- package/dist/features/measure/measureContribution.js.map +0 -1
- package/dist/features/measure/measureEdits.js.map +0 -1
- package/dist/features/measure/measureGestures.js.map +0 -1
- package/dist/features/measure/measureHit.js.map +0 -1
- package/dist/features/measure/measureLayer.js.map +0 -1
- package/dist/features/measure/measurement.js.map +0 -1
- package/dist/features/measure/measurements.js.map +0 -1
- package/dist/features/modes/modeLayers.js.map +0 -1
- package/dist/features/modes/modeTriggers.js.map +0 -1
- package/dist/features/pathEffects/effectSources.js.map +0 -1
- package/dist/features/pathEffects/index.js.map +0 -1
- package/dist/features/pathEffects/readSource.js.map +0 -1
- package/dist/features/pathEffects/textItems.js.map +0 -1
- package/dist/features/pathEffects/useEffectSourcesLayer.js.map +0 -1
- package/dist/features/paths/anchorData.js.map +0 -1
- package/dist/features/paths/anchorMarkers.js.map +0 -1
- package/dist/features/paths/editablePath.js.map +0 -1
- package/dist/features/paths/originProjection.js.map +0 -1
- package/dist/features/paths/pathEditExtension.js.map +0 -1
- package/dist/features/paths/pathEditState.js.map +0 -1
- package/dist/features/paths/pathEditingOverlayLayer.js.map +0 -1
- package/dist/features/paths/pathLayer.js.map +0 -1
- package/dist/features/paths/pathRepresentation.js.map +0 -1
- package/dist/features/paths/pathSnap/glyphs.js.map +0 -1
- package/dist/features/paths/pathSnap/pathSnapSource.js.map +0 -1
- package/dist/features/paths/pathSnap/sceneIndex.js.map +0 -1
- package/dist/features/paths/pathSnap/snapGeometry.js.map +0 -1
- package/dist/features/paths/penPreviewLayer.js.map +0 -1
- package/dist/features/paths/shapeGenerator.js.map +0 -1
- package/dist/features/paths/strokeOutline.js.map +0 -1
- package/dist/features/paths/useAnchorFields.js.map +0 -1
- package/dist/features/paths/usePathEdit.js.map +0 -1
- package/dist/features/poseRun/usePoseRun.js.map +0 -1
- package/dist/features/selection/enteredGroupFrame.js.map +0 -1
- package/dist/features/selection/enteredGroupScope.js.map +0 -1
- package/dist/features/selection/handleCommands.js.map +0 -1
- package/dist/features/selection/overlay.js.map +0 -1
- package/dist/features/selection/selectionPose.js.map +0 -1
- package/dist/features/snap/angle2d.js.map +0 -1
- package/dist/features/snap/debugCandidates.js.map +0 -1
- package/dist/features/snap/gather.js.map +0 -1
- package/dist/features/snap/inputSubspace.js.map +0 -1
- package/dist/features/snap/lazySession.js.map +0 -1
- package/dist/features/snap/marks.js.map +0 -1
- package/dist/features/snap/outcomeStore.js.map +0 -1
- package/dist/features/snap/pointSnap.js.map +0 -1
- package/dist/features/snap/probes2d.js.map +0 -1
- package/dist/features/snap/readoutDraw.js.map +0 -1
- package/dist/features/snap/readoutLayer.js.map +0 -1
- package/dist/features/snap/registry.js.map +0 -1
- package/dist/features/snap/resizeBox.js.map +0 -1
- package/dist/features/snap/roles.js.map +0 -1
- package/dist/features/snap/rotationSource.js.map +0 -1
- package/dist/features/snap/sceneReads.js.map +0 -1
- package/dist/features/snap/sceneSession2d.js.map +0 -1
- package/dist/features/snap/screen.js.map +0 -1
- package/dist/features/snap/session2d.js.map +0 -1
- package/dist/features/snap/spanSnap.js.map +0 -1
- package/dist/features/snap/stepAngles.js.map +0 -1
- package/dist/features/text/editingDrawOne.js.map +0 -1
- package/dist/features/text/sceneTextDrafts.js.map +0 -1
- package/dist/features/text/textHitAt.js.map +0 -1
- package/dist/features/text/textLayer.js.map +0 -1
- package/dist/features/text/useSceneTextEdit.js.map +0 -1
- package/dist/features/viewports/aim.js.map +0 -1
- package/dist/features/viewports/viewMarker.js.map +0 -1
- package/dist/features/viewports/viewMarkerDrag.js.map +0 -1
- package/dist/features/viewports/viewResolver.js.map +0 -1
- package/dist/features/viewports/viewportLayer.js.map +0 -1
- /package/dist/{features → domains}/chrome-caps/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneViewRender.js","names":["viewToMat3"],"sources":["../../src/canvas/sceneViewRender.ts"],"sourcesContent":["/**\n * `renderSceneToCanvas` — substrate for detached, read-only scene views\n * (`<SceneViewCanvas>` / `<MinimapCanvas>`). Given a `<canvas>`, a `Scene`,\n * a `View`, and a per-node `drawOne`, render one frame.\n */\n\nimport type { WeaselRenderer } from '@weasel-js/renderer';\nimport { cachedCanvasRenderer, paintCanvas } from './canvasRenderer';\nimport { viewToMat3 } from '@weasel-js/geom';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport type { View } from '../core/viewport/view';\nimport type { Node, NodeId, Scene } from '../core/scene/types';\nimport { wrapNodeOutput } from './wrapNodeOutput';\nimport { buildSceneTree, type HierarchicalAdapter } from './buildSceneTree';\nimport { sceneToAdapter } from './sceneAdapter';\nimport { withInheritedPaintBounds, withInheritedPaints } from './inheritedPaints';\nimport { withDerivedPaths, sceneDerivedPathOf } from './derivedPath';\nimport { withColorOverrides } from './colorOverrides';\nimport type { ColorOverrideRegistry } from '@weasel-js/animator';\nimport type { SceneViewDrawOne } from './NodeShape';\nimport { paintedSceneLayers } from './sceneLayerPaint';\nimport { cullDrawCommands } from '@weasel-js/renderer';\nimport { paintMissesView, type PaintBoundsFn } from './paintCull';\nimport { paintBoundsFor } from './defaultDrawOne';\nimport { nodeAsShown, shownLookup } from 'core/scene/nodeAsShown';\nimport { withShownNode } from './shownNodes';\n\nexport type { SceneViewDrawOne } from './NodeShape';\n\n/**\n * Which scene layers a detached view paints, on top of each layer's own\n * `visible` flag. Keyed the way `<SceneCanvas>` keys its scene layers —\n * `scene:<layerId>` — so the map a main canvas takes serves its minimap too.\n */\nexport interface SceneViewLayers {\n /** `false` hides that layer in this view. It cannot show one the scene hides. */\n layerVisibility?: Record<string, boolean>;\n /** Paint order, bottom first. A listed order is the whole list: a scene\n * layer left out of it is not painted. */\n layerOrder?: readonly string[];\n}\n\n/** The view size `buildSceneViewCommands` culls to, and how it bounds a\n * node's paint before painting it. */\nexport interface SceneViewCull<TData, TLayer extends string, TPose> {\n width: number;\n height: number;\n paintBounds?: PaintBoundsFn<Node<TData, TLayer, TPose>, TPose>;\n}\n\n/** What to draw into an existing canvas: the scene, the view, and the same\n * painting hooks `<SceneCanvas>` takes. */\nexport interface RenderSceneToCanvasArgs<TData, TLayer extends string, TPose> {\n /** The DOM canvas to paint into. The first call on a given canvas creates\n * its renderer and later calls reuse it;\n * `releaseCanvasRenderer(canvas)` frees it. */\n canvas: HTMLCanvasElement;\n scene: Scene<TData, TLayer, TPose>;\n /** Camera view applied to scene and `extraCommands` alike. */\n view: View;\n /** CSS-pixel size. The drawing buffer is set to `width × dpr` and\n * `height × dpr`; the element's CSS size is the caller's to set. */\n width: number;\n height: number;\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>;\n /** Commands appended after the scene-node output, wrapped in the same view\n * transform as scene commands. */\n extraCommands?: DrawCommand[];\n /** Per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot\n * `alphaFor`. Defaults to `() => 1`. */\n alphaFor?: (id: string) => number;\n /** Per-view layer visibility. See {@link SceneViewLayers}. */\n layerVisibility?: SceneViewLayers['layerVisibility'];\n /** Per-view layer order. See {@link SceneViewLayers}. */\n layerOrder?: SceneViewLayers['layerOrder'];\n /** Animated vertex colors to paint, typically an animator's\n * `colorOverrides` — see `NodePaintCtx.vertexColors`. */\n colorOverrides?: ColorOverrideRegistry;\n /** Skip what cannot reach the `width × height` view: nodes `paintBounds`\n * places outside it are not painted, and scene commands that cannot reach\n * it are dropped before the renderer — the scene slot's `cull`. Off by\n * default. `extraCommands` are never culled. */\n cull?: boolean;\n /** Where `drawOne`'s output for a node can reach, as on the scene slot.\n * Defaults to `defaultPaintBounds` when `drawOne` is `defaultDrawOne`. */\n paintBounds?: PaintBoundsFn<Node<TData, TLayer, TPose>, TPose>;\n /** Device-pixel ratio. Defaults to `window.devicePixelRatio || 1` when\n * available, otherwise 1. */\n dpr?: number;\n}\n\n/** Test seam: the renderer `renderSceneToCanvas` created for a canvas. Not\n * re-exported from the barrel. */\nexport function __getCachedRendererForTest(\n canvas: HTMLCanvasElement,\n): WeaselRenderer | undefined {\n return cachedCanvasRenderer(canvas);\n}\n\n/**\n * Present a `Scene` as the reading surface `buildSceneTree` walks: the scene\n * adapter's own reads, under this view's layer list.\n */\nfunction sceneAsHierarchy<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n layers: SceneViewLayers = {},\n): HierarchicalAdapter<Node<TData, TLayer, TPose>, TPose> {\n const { getNode, getChildren, getPose, composePose } = sceneToAdapter(scene);\n return {\n getLayers: () =>\n paintedSceneLayers(scene.layers, layers)\n .map((l) => ({ id: l.id, visible: l.visible, parallax: l.parallax })),\n getNode,\n getChildren,\n getPose,\n ...(composePose ? { composePose } : {}),\n };\n}\n\n/**\n * Build the DrawCommand list that `renderSceneToCanvas` would dispatch, in\n * screen space. Pure — no GL, no DOM. Walks the scene through `buildSceneTree`,\n * the same walk `<SceneCanvas>` uses, which is what keeps hidden layers\n * unpainted and container clips applied here.\n *\n * Each node's commands go through `wrapNodeOutput` — pose rotation, then the\n * `alphaFor` multiplier — so a `drawOne` that rotates its own output rotates\n * twice; emit unrotated geometry and let the pose drive it.\n *\n * Output is one group per **visible** layer, in scene-layer order (or\n * `layers.layerOrder`), each holding one group per node on that layer.\n */\nexport function buildSceneViewCommands<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n view: View,\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>,\n extraCommands?: ReadonlyArray<DrawCommand>,\n alphaFor?: (id: string) => number,\n /** This view's own layer visibility and order. */\n layers?: SceneViewLayers,\n /** Animated vertex colors to paint, typically an animator's `colorOverrides`. */\n colorOverrides?: ColorOverrideRegistry,\n /** Cull the scene to this CSS-pixel view size — see\n * `RenderSceneToCanvasArgs.cull`. Omit to paint every node. */\n cull?: SceneViewCull<TData, TLayer, TPose>,\n): DrawCommand[] {\n const shown = shownLookup(scene);\n const derivedOnly = withDerivedPaths(scene, withInheritedPaints(shown, drawOne));\n const derived = colorOverrides ? withColorOverrides(colorOverrides, derivedOnly) : derivedOnly;\n const derivedPathAt = sceneDerivedPathOf(scene);\n const derivedPathOf = (node: Node<TData, TLayer, TPose>) => derivedPathAt(nodeAsShown(scene.overrides, node));\n const wrappedDrawOne = (\n node: Node<TData, TLayer, TPose>,\n pose: TPose,\n v: View,\n ): DrawCommand[] => {\n const overrideAlpha = scene.overrides.read(node.id as NodeId)?.alpha ?? 1;\n return wrapNodeOutput(\n derived(nodeAsShown(scene.overrides, node), pose, v),\n pose,\n (alphaFor ? alphaFor(node.id) : 1) * overrideAlpha,\n );\n };\n\n const hierarchy = sceneAsHierarchy(scene, layers);\n\n const cullRect = cull ? { x: 0, y: 0, width: cull.width, height: cull.height } : undefined;\n const culled = cullRect && cull?.paintBounds\n ? paintMissesView(withShownNode(scene.overrides, withInheritedPaintBounds(shown, cull.paintBounds)), view, cullRect)\n : undefined;\n const tree: DrawCommand[] = buildSceneTree(\n hierarchy as Parameters<typeof buildSceneTree>[0],\n wrappedDrawOne as unknown as Parameters<typeof buildSceneTree>[1],\n view,\n undefined,\n derivedPathOf as unknown as Parameters<typeof buildSceneTree>[4],\n culled as Parameters<typeof buildSceneTree>[5],\n );\n const children = cullRect ? cullDrawCommands(tree, viewToMat3(view), cullRect) : tree;\n if (extraCommands && extraCommands.length > 0) {\n for (const cmd of extraCommands) children.push(cmd);\n }\n return [{\n kind: 'group',\n transform: viewToMat3(view),\n children,\n }];\n}\n\n/**\n * The commands `renderSceneToCanvas` paints for one frame — everything in\n * `args` but the canvas. `<SceneViewCanvas>` paints these through its own\n * renderer lease.\n */\nexport function sceneViewFrame<TData, TLayer extends string, TPose>(\n args: Omit<RenderSceneToCanvasArgs<TData, TLayer, TPose>, 'canvas'>,\n): DrawCommand[] {\n const {\n scene, view, width, height, drawOne, extraCommands, alphaFor, layerVisibility, layerOrder,\n colorOverrides, cull,\n } = args;\n return buildSceneViewCommands(\n scene, view, drawOne, extraCommands, alphaFor, { layerVisibility, layerOrder }, colorOverrides,\n cull ? { width, height, paintBounds: args.paintBounds ?? paintBoundsFor(drawOne) } : undefined,\n );\n}\n\n/**\n * Render one frame of `scene` at `view` into `canvas`. Where no WebGL2\n * context is available (jsdom) the call paints nothing. The canvas's renderer\n * lives until `releaseCanvasRenderer(canvas)`.\n */\nexport function renderSceneToCanvas<TData, TLayer extends string, TPose>(\n args: RenderSceneToCanvasArgs<TData, TLayer, TPose>,\n): void {\n const { canvas, view, width, height, dpr } = args;\n paintCanvas(canvas, sceneViewFrame(args), view, { width, height, dpr });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuGA,SAAS,iBACP,OACA,SAA0B,CAAC,GAC6B;CACxD,MAAM,EAAE,SAAS,aAAa,SAAS,gBAAgB,eAAe,KAAK;CAC3E,OAAO;EACL,iBACE,mBAAmB,MAAM,QAAQ,MAAM,CAAC,CACrC,KAAK,OAAO;GAAE,IAAI,EAAE;GAAI,SAAS,EAAE;GAAS,UAAU,EAAE;EAAS,EAAE;EACxE;EACA;EACA;EACA,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;CACvC;AACF;;;;;;;;;;;;;;AAeA,SAAgB,uBACd,OACA,MACA,SACA,eACA,UAEA,QAEA,gBAGA,MACe;CACf,MAAM,QAAQ,YAAY,KAAK;CAC/B,MAAM,cAAc,iBAAiB,OAAO,oBAAoB,OAAO,OAAO,CAAC;CAC/E,MAAM,UAAU,iBAAiB,mBAAmB,gBAAgB,WAAW,IAAI;CACnF,MAAM,gBAAgB,mBAAmB,KAAK;CAC9C,MAAM,iBAAiB,SAAqC,cAAc,YAAY,MAAM,WAAW,IAAI,CAAC;CAC5G,MAAM,kBACJ,MACA,MACA,MACkB;EAClB,MAAM,gBAAgB,MAAM,UAAU,KAAK,KAAK,EAAY,CAAC,EAAE,SAAS;EACxE,OAAO,eACL,QAAQ,YAAY,MAAM,WAAW,IAAI,GAAG,MAAM,CAAC,GACnD,OACC,WAAW,SAAS,KAAK,EAAE,IAAI,KAAK,aACvC;CACF;CAEA,MAAM,YAAY,iBAAiB,OAAO,MAAM;CAEhD,MAAM,WAAW,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,OAAO,KAAK;EAAO,QAAQ,KAAK;CAAO,IAAI;CACjF,MAAM,SAAS,YAAY,MAAM,cAC7B,gBAAgB,cAAc,MAAM,WAAW,yBAAyB,OAAO,KAAK,WAAW,CAAC,GAAG,MAAM,QAAQ,IACjH;CACJ,MAAM,OAAsB,eAC1B,WACA,gBACA,MACA,QACA,eACA,MACF;CACA,MAAM,WAAW,WAAW,iBAAiB,MAAMA,aAAW,IAAI,GAAG,QAAQ,IAAI;CACjF,IAAI,iBAAiB,cAAc,SAAS,GAC1C,KAAK,MAAM,OAAO,eAAe,SAAS,KAAK,GAAG;CAEpD,OAAO,CAAC;EACN,MAAM;EACN,WAAWA,aAAW,IAAI;EAC1B;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,eACd,MACe;CACf,MAAM,EACJ,OAAO,MAAM,OAAO,QAAQ,SAAS,eAAe,UAAU,iBAAiB,YAC/E,gBAAgB,SACd;CACJ,OAAO,uBACL,OAAO,MAAM,SAAS,eAAe,UAAU;EAAE;EAAiB;CAAW,GAAG,gBAChF,OAAO;EAAE;EAAO;EAAQ,aAAa,KAAK,eAAe,eAAe,OAAO;CAAE,IAAI,MACvF;AACF;;;;;;AAOA,SAAgB,oBACd,MACM;CACN,MAAM,EAAE,QAAQ,MAAM,OAAO,QAAQ,QAAQ;CAC7C,YAAY,QAAQ,eAAe,IAAI,GAAG,MAAM;EAAE;EAAO;EAAQ;CAAI,CAAC;AACxE"}
|
|
1
|
+
{"version":3,"file":"sceneViewRender.js","names":["viewToMat3"],"sources":["../../src/canvas/sceneViewRender.ts"],"sourcesContent":["/**\n * `renderSceneToCanvas` — substrate for detached, read-only scene views\n * (`<SceneViewCanvas>` / `<MinimapCanvas>`). Given a `<canvas>`, a `Scene`,\n * a `View`, and a per-node `drawOne`, render one frame.\n */\n\nimport type { WeaselRenderer } from '@weasel-js/renderer';\nimport { cachedCanvasRenderer, paintCanvas, resolveDpr } from './canvasRenderer';\nimport { viewToMat3 } from '@weasel-js/geom';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport type { View } from '../core/viewport/view';\nimport type { Node, NodeId, Scene } from '../core/scene/types';\nimport { wrapNodeOutput } from './wrapNodeOutput';\nimport { buildSceneTree, type HierarchicalAdapter } from './buildSceneTree';\nimport { sceneToAdapter } from './sceneAdapter';\nimport { withInheritedPaintBounds, withInheritedPaints } from './inheritedPaints';\nimport { withDerivedPaths, sceneDerivedPathOf } from './derivedPath';\nimport { withColorOverrides } from './colorOverrides';\nimport type { ColorOverrideRegistry } from '@weasel-js/animator';\nimport type { SceneViewDrawOne } from './NodeShape';\nimport { paintedSceneLayers } from './sceneLayerPaint';\nimport { cullDrawCommands } from '@weasel-js/renderer';\nimport { paintMissesView, type PaintBoundsFn } from './paintCull';\nimport { paintBoundsFor } from './defaultDrawOne';\nimport { nodeAsShown, shownLookup } from 'core/scene/nodeAsShown';\nimport { withShownNode } from './shownNodes';\n\nexport type { SceneViewDrawOne } from './NodeShape';\n\n/**\n * Which scene layers a detached view paints, on top of each layer's own\n * `visible` flag. Keyed the way `<SceneCanvas>` keys its scene layers —\n * `scene:<layerId>` — so the map a main canvas takes serves its minimap too.\n */\nexport interface SceneViewLayers {\n /** `false` hides that layer in this view. It cannot show one the scene hides. */\n layerVisibility?: Record<string, boolean>;\n /** Paint order, bottom first. A listed order is the whole list: a scene\n * layer left out of it is not painted. */\n layerOrder?: readonly string[];\n}\n\n/** The view size `buildSceneViewCommands` culls to, the density it will be\n * painted at, and how it bounds a node's paint before painting it. */\nexport interface SceneViewCull<TData, TLayer extends string, TPose> {\n width: number;\n height: number;\n dpr: number;\n paintBounds?: PaintBoundsFn<Node<TData, TLayer, TPose>, TPose>;\n}\n\n/** What to draw into an existing canvas: the scene, the view, and the same\n * painting hooks `<SceneCanvas>` takes. */\nexport interface RenderSceneToCanvasArgs<TData, TLayer extends string, TPose> {\n /** The DOM canvas to paint into. The first call on a given canvas creates\n * its renderer and later calls reuse it;\n * `releaseCanvasRenderer(canvas)` frees it. */\n canvas: HTMLCanvasElement;\n scene: Scene<TData, TLayer, TPose>;\n /** Camera view applied to scene and `extraCommands` alike. */\n view: View;\n /** CSS-pixel size. The drawing buffer is set to `width × dpr` and\n * `height × dpr`; the element's CSS size is the caller's to set. */\n width: number;\n height: number;\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>;\n /** Commands appended after the scene-node output, wrapped in the same view\n * transform as scene commands. */\n extraCommands?: DrawCommand[];\n /** Per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot\n * `alphaFor`. Defaults to `() => 1`. */\n alphaFor?: (id: string) => number;\n /** Per-view layer visibility. See {@link SceneViewLayers}. */\n layerVisibility?: SceneViewLayers['layerVisibility'];\n /** Per-view layer order. See {@link SceneViewLayers}. */\n layerOrder?: SceneViewLayers['layerOrder'];\n /** Animated vertex colors to paint, typically an animator's\n * `colorOverrides` — see `NodePaintCtx.vertexColors`. */\n colorOverrides?: ColorOverrideRegistry;\n /** Skip what cannot reach the `width × height` view: nodes `paintBounds`\n * places outside it are not painted, and scene commands that cannot reach\n * it are dropped before the renderer — the scene slot's `cull`. Off by\n * default. `extraCommands` are never culled. */\n cull?: boolean;\n /** Where `drawOne`'s output for a node can reach, as on the scene slot.\n * Defaults to `defaultPaintBounds` when `drawOne` is `defaultDrawOne`. */\n paintBounds?: PaintBoundsFn<Node<TData, TLayer, TPose>, TPose>;\n /** Device-pixel ratio. Defaults to `window.devicePixelRatio || 1` when\n * available, otherwise 1. */\n dpr?: number;\n}\n\n/** Test seam: the renderer `renderSceneToCanvas` created for a canvas. Not\n * re-exported from the barrel. */\nexport function __getCachedRendererForTest(\n canvas: HTMLCanvasElement,\n): WeaselRenderer | undefined {\n return cachedCanvasRenderer(canvas);\n}\n\n/**\n * Present a `Scene` as the reading surface `buildSceneTree` walks: the scene\n * adapter's own reads, under this view's layer list.\n */\nfunction sceneAsHierarchy<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n layers: SceneViewLayers = {},\n): HierarchicalAdapter<Node<TData, TLayer, TPose>, TPose> {\n const { getNode, getChildren, getPose, composePose, childFrame } = sceneToAdapter(scene);\n return {\n getLayers: () =>\n paintedSceneLayers(scene.layers, layers)\n .map((l) => ({ id: l.id, visible: l.visible, parallax: l.parallax })),\n getNode,\n getChildren,\n getPose,\n ...(composePose ? { composePose } : {}),\n ...(childFrame ? { childFrame } : {}),\n };\n}\n\n/**\n * Build the DrawCommand list that `renderSceneToCanvas` would dispatch, in\n * screen space. Pure — no GL, no DOM. Walks the scene through `buildSceneTree`,\n * the same walk `<SceneCanvas>` uses, which is what keeps hidden layers\n * unpainted and container clips applied here.\n *\n * Each node's commands go through `wrapNodeOutput` — pose rotation, then the\n * `alphaFor` multiplier — so a `drawOne` that rotates its own output rotates\n * twice; emit unrotated geometry and let the pose drive it.\n *\n * Output is one group per **visible** layer, in scene-layer order (or\n * `layers.layerOrder`), each holding one group per node on that layer.\n */\nexport function buildSceneViewCommands<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>,\n view: View,\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>,\n extraCommands?: ReadonlyArray<DrawCommand>,\n alphaFor?: (id: string) => number,\n /** This view's own layer visibility and order. */\n layers?: SceneViewLayers,\n /** Animated vertex colors to paint, typically an animator's `colorOverrides`. */\n colorOverrides?: ColorOverrideRegistry,\n /** Cull the scene to this CSS-pixel view size — see\n * `RenderSceneToCanvasArgs.cull`. Omit to paint every node. */\n cull?: SceneViewCull<TData, TLayer, TPose>,\n): DrawCommand[] {\n const shown = shownLookup(scene);\n const derivedOnly = withDerivedPaths(scene, withInheritedPaints(shown, drawOne));\n const derived = colorOverrides ? withColorOverrides(colorOverrides, derivedOnly) : derivedOnly;\n const derivedPathAt = sceneDerivedPathOf(scene);\n const derivedPathOf = (node: Node<TData, TLayer, TPose>) => derivedPathAt(nodeAsShown(scene.overrides, node));\n const wrappedDrawOne = (\n node: Node<TData, TLayer, TPose>,\n pose: TPose,\n v: View,\n ): DrawCommand[] => {\n const overrideAlpha = scene.overrides.read(node.id as NodeId)?.alpha ?? 1;\n return wrapNodeOutput(\n derived(nodeAsShown(scene.overrides, node), pose, v),\n pose,\n (alphaFor ? alphaFor(node.id) : 1) * overrideAlpha,\n );\n };\n\n const hierarchy = sceneAsHierarchy(scene, layers);\n\n const cullRect = cull ? { x: 0, y: 0, width: cull.width, height: cull.height } : undefined;\n const culled = cullRect && cull?.paintBounds\n ? paintMissesView(withShownNode(scene.overrides, withInheritedPaintBounds(shown, cull.paintBounds)), view, cullRect)\n : undefined;\n const tree: DrawCommand[] = buildSceneTree(\n hierarchy as Parameters<typeof buildSceneTree>[0],\n wrappedDrawOne as unknown as Parameters<typeof buildSceneTree>[1],\n view,\n undefined,\n derivedPathOf as unknown as Parameters<typeof buildSceneTree>[4],\n culled as Parameters<typeof buildSceneTree>[5],\n );\n const children = cull && cullRect ? cullDrawCommands(tree, viewToMat3(view), cullRect, cull.dpr) : tree;\n if (extraCommands && extraCommands.length > 0) {\n for (const cmd of extraCommands) children.push(cmd);\n }\n return [{\n kind: 'group',\n transform: viewToMat3(view),\n children,\n }];\n}\n\n/**\n * The commands `renderSceneToCanvas` paints for one frame — everything in\n * `args` but the canvas. `<SceneViewCanvas>` paints these through its own\n * renderer lease.\n */\nexport function sceneViewFrame<TData, TLayer extends string, TPose>(\n args: Omit<RenderSceneToCanvasArgs<TData, TLayer, TPose>, 'canvas'>,\n): DrawCommand[] {\n const {\n scene, view, width, height, drawOne, extraCommands, alphaFor, layerVisibility, layerOrder,\n colorOverrides, cull, dpr,\n } = args;\n return buildSceneViewCommands(\n scene, view, drawOne, extraCommands, alphaFor, { layerVisibility, layerOrder }, colorOverrides,\n cull ? { width, height, dpr: resolveDpr(dpr), paintBounds: args.paintBounds ?? paintBoundsFor(drawOne) } : undefined,\n );\n}\n\n/**\n * Render one frame of `scene` at `view` into `canvas`. Where no WebGL2\n * context is available (jsdom) the call paints nothing. The canvas's renderer\n * lives until `releaseCanvasRenderer(canvas)`.\n */\nexport function renderSceneToCanvas<TData, TLayer extends string, TPose>(\n args: RenderSceneToCanvasArgs<TData, TLayer, TPose>,\n): void {\n const { canvas, view, width, height, dpr } = args;\n paintCanvas(canvas, sceneViewFrame(args), view, { width, height, dpr });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwGA,SAAS,iBACP,OACA,SAA0B,CAAC,GAC6B;CACxD,MAAM,EAAE,SAAS,aAAa,SAAS,aAAa,eAAe,eAAe,KAAK;CACvF,OAAO;EACL,iBACE,mBAAmB,MAAM,QAAQ,MAAM,CAAC,CACrC,KAAK,OAAO;GAAE,IAAI,EAAE;GAAI,SAAS,EAAE;GAAS,UAAU,EAAE;EAAS,EAAE;EACxE;EACA;EACA;EACA,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;EACrC,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;CACrC;AACF;;;;;;;;;;;;;;AAeA,SAAgB,uBACd,OACA,MACA,SACA,eACA,UAEA,QAEA,gBAGA,MACe;CACf,MAAM,QAAQ,YAAY,KAAK;CAC/B,MAAM,cAAc,iBAAiB,OAAO,oBAAoB,OAAO,OAAO,CAAC;CAC/E,MAAM,UAAU,iBAAiB,mBAAmB,gBAAgB,WAAW,IAAI;CACnF,MAAM,gBAAgB,mBAAmB,KAAK;CAC9C,MAAM,iBAAiB,SAAqC,cAAc,YAAY,MAAM,WAAW,IAAI,CAAC;CAC5G,MAAM,kBACJ,MACA,MACA,MACkB;EAClB,MAAM,gBAAgB,MAAM,UAAU,KAAK,KAAK,EAAY,CAAC,EAAE,SAAS;EACxE,OAAO,eACL,QAAQ,YAAY,MAAM,WAAW,IAAI,GAAG,MAAM,CAAC,GACnD,OACC,WAAW,SAAS,KAAK,EAAE,IAAI,KAAK,aACvC;CACF;CAEA,MAAM,YAAY,iBAAiB,OAAO,MAAM;CAEhD,MAAM,WAAW,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,OAAO,KAAK;EAAO,QAAQ,KAAK;CAAO,IAAI;CACjF,MAAM,SAAS,YAAY,MAAM,cAC7B,gBAAgB,cAAc,MAAM,WAAW,yBAAyB,OAAO,KAAK,WAAW,CAAC,GAAG,MAAM,QAAQ,IACjH;CACJ,MAAM,OAAsB,eAC1B,WACA,gBACA,MACA,QACA,eACA,MACF;CACA,MAAM,WAAW,QAAQ,WAAW,iBAAiB,MAAMA,aAAW,IAAI,GAAG,UAAU,KAAK,GAAG,IAAI;CACnG,IAAI,iBAAiB,cAAc,SAAS,GAC1C,KAAK,MAAM,OAAO,eAAe,SAAS,KAAK,GAAG;CAEpD,OAAO,CAAC;EACN,MAAM;EACN,WAAWA,aAAW,IAAI;EAC1B;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,eACd,MACe;CACf,MAAM,EACJ,OAAO,MAAM,OAAO,QAAQ,SAAS,eAAe,UAAU,iBAAiB,YAC/E,gBAAgB,MAAM,QACpB;CACJ,OAAO,uBACL,OAAO,MAAM,SAAS,eAAe,UAAU;EAAE;EAAiB;CAAW,GAAG,gBAChF,OAAO;EAAE;EAAO;EAAQ,KAAK,WAAW,GAAG;EAAG,aAAa,KAAK,eAAe,eAAe,OAAO;CAAE,IAAI,MAC7G;AACF;;;;;;AAOA,SAAgB,oBACd,MACM;CACN,MAAM,EAAE,QAAQ,MAAM,OAAO,QAAQ,QAAQ;CAC7C,YAAY,QAAQ,eAAe,IAAI,GAAG,MAAM;EAAE;EAAO;EAAQ;CAAI,CAAC;AACxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaceContribution.js","names":["mergeContributions","mergeRoutingContributions"],"sources":["../../src/canvas/surfaceContribution.ts"],"sourcesContent":["/**\n * The canvas's unit of extension: a routing `Contribution` plus the roles only\n * a surface can install — views on it, and whatever else needs the mounted\n * canvas.\n */\nimport { mergeContributions as mergeRoutingContributions } from '@weasel-js/routing';\nimport type { DepName, DepSchema } from 'interactions/actions/depSchema';\nimport type { Contribution } from '../tools/overlayBinding';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport type { CanvasViewProps } from './CanvasView';\nimport type { ViewMarkerProps } from '../
|
|
1
|
+
{"version":3,"file":"surfaceContribution.js","names":["mergeContributions","mergeRoutingContributions"],"sources":["../../src/canvas/surfaceContribution.ts"],"sourcesContent":["/**\n * The canvas's unit of extension: a routing `Contribution` plus the roles only\n * a surface can install — views on it, and whatever else needs the mounted\n * canvas.\n */\nimport { mergeContributions as mergeRoutingContributions } from '@weasel-js/routing';\nimport type { DepName, DepSchema } from 'interactions/actions/depSchema';\nimport type { Contribution } from '../tools/overlayBinding';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport type { CanvasViewProps } from './CanvasView';\nimport type { ViewMarkerProps } from '../domains/viewports/viewMarker';\nimport type { View } from '../core/viewport/view';\nimport type { KitRequirements } from './kitRequirements';\n\n/** Reads the surface's deps from inside `SurfaceContribution.attach`. */\nexport interface ContributionDepReader {\n get<K extends DepName>(name: K): DepSchema[K] | undefined;\n}\n\n/** What {@link SurfaceContribution.beforePaint} and `afterPaint` are handed. */\nexport interface ContributionFrameCtx {\n /** The frame's timestamp, on `performance.now()`'s clock. Both phases of one\n * frame see the same value. */\n readonly time: number;\n /** The surface camera this frame paints with. */\n readonly view: View;\n /** Ask for another frame. A hook animating something calls this every frame\n * it still has work for, and stops calling it to let the loop go idle. */\n requestFrame(): void;\n /** The surface's deps, as `attach` reads them. */\n readonly deps: ContributionDepReader;\n}\n\n/**\n * A feature a surface installs in one step. Every role is optional: `bindings`,\n * `actions`, `deps`, `overlay` and `presentation` from `Contribution`, plus\n * the ones below. Installing it installs every role it declares, and removing\n * it removes them.\n */\nexport interface SurfaceContribution extends Contribution {\n /** Views this entry adds to the surface, as `<SceneCanvas views>` takes. */\n views?: readonly CanvasViewProps[];\n /** Markers this entry draws, as `<ViewMarker>` elements would. */\n markers?: readonly ViewMarkerProps[];\n /**\n * Runs once the surface mounts; returns its teardown. For what the roles\n * above cannot say — a registered (hit-testable) layer, a subscription.\n *\n * Keyed by the function's identity, so a contribution built once (in a\n * `useMemo`, or at module scope) attaches once however often the host\n * re-renders.\n */\n attach?: (api: CanvasExtensionApi, deps: ContributionDepReader) => () => void;\n /**\n * Runs on every frame the surface paints, before the paint — for state the\n * entry's layers read, advanced once per frame. Hooks run in the order the\n * surface lists its entries (registered tools, then `ambient` in array\n * order), and one that throws is reported and skipped without stopping the\n * frame.\n */\n beforePaint?: (ctx: ContributionFrameCtx) => void;\n /** Runs after a frame's pixels have landed, in the same order as\n * {@link beforePaint}. A frame that painted nothing runs no `afterPaint`. */\n afterPaint?: (ctx: ContributionFrameCtx) => void;\n /**\n * The kit versions this entry was written against, as semver ranges:\n * `{ core: '^1.7' }`. A mismatch warns in development, or throws where the\n * surface is set to `versionCheck=\"strict\"`.\n */\n requires?: KitRequirements;\n}\n\n/**\n * Concatenate contribution bundles into one registry, preserving order. Throws\n * on a duplicate entry id, dep name, view id or marker id — two features\n * answering for the same name is a bug in whichever was added second.\n */\nexport function mergeContributions<T extends SurfaceContribution>(\n ...bundles: readonly (readonly T[])[]\n): T[] {\n const out = mergeRoutingContributions<T>(...bundles);\n claimIds(out, 'view', (entry) => entry.views ?? []);\n claimIds(out, 'marker', (entry) => entry.markers ?? []);\n return out;\n}\n\nfunction claimIds<T extends SurfaceContribution>(\n entries: readonly T[], kind: 'view' | 'marker', of: (entry: T) => readonly { id: string }[],\n): void {\n const owners = new Map<string, string>();\n for (const entry of entries) {\n for (const { id } of of(entry)) {\n const owner = owners.get(id);\n if (owner !== undefined) {\n throw new Error(\n `mergeContributions: ${kind} \"${id}\" is added by both \"${owner}\" and \"${entry.id}\". `\n + `${kind === 'view' ? 'View' : 'Marker'} ids are unique per surface; rename one.`,\n );\n }\n owners.set(id, entry.id);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6EA,SAAgBA,qBACd,GAAG,SACE;CACL,MAAM,MAAMC,mBAA6B,GAAG,OAAO;CACnD,SAAS,KAAK,SAAS,UAAU,MAAM,SAAS,CAAC,CAAC;CAClD,SAAS,KAAK,WAAW,UAAU,MAAM,WAAW,CAAC,CAAC;CACtD,OAAO;AACT;AAEA,SAAS,SACP,SAAuB,MAAyB,IAC1C;CACN,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,SAAS,SAClB,KAAK,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG;EAC9B,MAAM,QAAQ,OAAO,IAAI,EAAE;EAC3B,IAAI,UAAU,QACZ,MAAM,IAAI,MACR,uBAAuB,KAAK,IAAI,GAAG,sBAAsB,MAAM,SAAS,MAAM,GAAG,KAC5E,SAAS,SAAS,SAAS,SAAS,yCAC3C;EAEF,OAAO,IAAI,IAAI,MAAM,EAAE;CACzB;AAEJ"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_LAYER_RETAIN } from "../core/layers/retain.js";
|
|
2
2
|
import { drawLayers } from "../core/layers/render.js";
|
|
3
|
+
import { resolveDpr } from "./canvasRenderer.js";
|
|
3
4
|
import { beginDebugFrame } from "../debug/useDebugSink.js";
|
|
4
5
|
import { NO_LAYER_VISIBILITY } from "./useExtraLayers.js";
|
|
6
|
+
import { ViewSnap } from "./viewSnap.js";
|
|
5
7
|
import { viewToMat3 } from "@weasel-js/renderer";
|
|
6
8
|
import { useCallback, useEffect, useInsertionEffect, useRef } from "react";
|
|
7
9
|
import { useLatest } from "@weasel-js/react";
|
|
@@ -31,10 +33,11 @@ function retainPolicy(retain) {
|
|
|
31
33
|
* leased renderer to whichever canvas pixels go to and draws the layer stack through the
|
|
32
34
|
* current view. The layer command cache lives as long as the canvas.
|
|
33
35
|
*/
|
|
34
|
-
function useCanvasPaint(paintRef, lease, target, frame, markPainted) {
|
|
36
|
+
function useCanvasPaint(paintRef, lease, target, frame, markPainted, requestRedraw) {
|
|
35
37
|
const { paintTargetRef, ownCanvasRef, paintRectRef } = target;
|
|
36
38
|
const { inputsRef, viewRef, gateRef, helpersRef } = frame;
|
|
37
39
|
const layerCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
40
|
+
const snapRef = useRef(new ViewSnap());
|
|
38
41
|
const paint = useCallback(() => {
|
|
39
42
|
const c = paintTargetRef.current ?? ownCanvasRef.current;
|
|
40
43
|
if (!c) return false;
|
|
@@ -54,16 +57,20 @@ function useCanvasPaint(paintRef, lease, target, frame, markPainted) {
|
|
|
54
57
|
shaders: paintShaders
|
|
55
58
|
});
|
|
56
59
|
if (!renderer) return false;
|
|
57
|
-
const
|
|
60
|
+
const dpr = resolveDpr(dprIn);
|
|
61
|
+
const view = snapRef.current.draw(viewRef.current, Math.round(w * dpr) / w, retain !== false && retain?.whole !== false);
|
|
58
62
|
const { layerVisibility: vis, layerOrder: order } = gateRef.current;
|
|
59
63
|
const spans = debugFrame?.time();
|
|
60
64
|
const commands = drawLayers(paintLayers, helpersRef.current, vis ?? NO_LAYER_VISIBILITY, order, view, {
|
|
61
65
|
width: w,
|
|
62
|
-
height: h
|
|
66
|
+
height: h,
|
|
67
|
+
dpr
|
|
63
68
|
}, layerCacheRef.current, void 0, groups, spans, retainPolicy(retain));
|
|
64
69
|
renderer.render(commands, viewToMat3(view), spans ? { spans } : void 0);
|
|
65
|
-
|
|
70
|
+
const stats = renderer.lastFrameStats();
|
|
71
|
+
debugFrame?.end(stats);
|
|
66
72
|
markPainted();
|
|
73
|
+
if (snapRef.current.owesFrame(stats.retained.declined)) requestRedraw();
|
|
67
74
|
return true;
|
|
68
75
|
}, [
|
|
69
76
|
gateRef,
|
|
@@ -74,6 +81,7 @@ function useCanvasPaint(paintRef, lease, target, frame, markPainted) {
|
|
|
74
81
|
ownCanvasRef,
|
|
75
82
|
paintRectRef,
|
|
76
83
|
paintTargetRef,
|
|
84
|
+
requestRedraw,
|
|
77
85
|
viewRef
|
|
78
86
|
]);
|
|
79
87
|
useInsertionEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasPaint.js","names":[],"sources":["../../src/canvas/useCanvasPaint.ts"],"sourcesContent":["import { useCallback, useEffect, useInsertionEffect, useRef } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { viewToMat3 } from '@weasel-js/renderer';\nimport type { View } from 'core/viewport/view';\nimport {\n DEFAULT_LAYER_RETAIN, drawLayers, type LayerCommandCache, type LayerRetainPolicy, type RenderLayer,\n} from 'core/layers/render';\nimport type { CanvasDebugSink } from '../debug/types';\nimport { beginDebugFrame } from '../debug/useDebugSink';\nimport type
|
|
1
|
+
{"version":3,"file":"useCanvasPaint.js","names":[],"sources":["../../src/canvas/useCanvasPaint.ts"],"sourcesContent":["import { useCallback, useEffect, useInsertionEffect, useRef } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { viewToMat3 } from '@weasel-js/renderer';\nimport type { View } from 'core/viewport/view';\nimport {\n DEFAULT_LAYER_RETAIN, drawLayers, type LayerCommandCache, type LayerRetainPolicy, type RenderLayer,\n} from 'core/layers/render';\nimport type { CanvasDebugSink } from '../debug/types';\nimport { beginDebugFrame } from '../debug/useDebugSink';\nimport { resolveDpr, type CanvasRendererLease } from './canvasRenderer';\nimport type { CanvasProps } from './canvasProps';\nimport type { CanvasElements } from './useCanvasElements';\nimport { NO_LAYER_VISIBILITY, type LayerGate } from './useExtraLayers';\nimport { ViewSnap } from './viewSnap';\n\n/** What a frame's paint reads that a React render owns. */\nexport interface PaintInputs extends Pick<CanvasProps<unknown>, 'dpr' | 'layerGroups' | 'shaders' | 'flattenTolerance' | 'imageMinification' | 'retain'> {\n layers: RenderLayer<unknown>[];\n width: number;\n height: number;\n debugSink: CanvasDebugSink | null;\n frameStats: boolean;\n}\n\n/** What a frame's paint reads that changes outside a render. */\nexport interface PaintFrame {\n inputsRef: { readonly current: PaintInputs };\n viewRef: { readonly current: View };\n gateRef: { readonly current: LayerGate };\n helpersRef: { readonly current: unknown };\n}\n\n/**\n * Which content version the last paint showed. `markPainted` records the current one, read\n * from `contentVersion`'s latest committed value.\n */\nexport function usePaintedVersion(contentVersion: (() => number) | undefined): {\n getPaintedVersion: () => number;\n markPainted: () => void;\n} {\n const contentVersionRef = useLatest(contentVersion);\n const paintedVersionRef = useRef(0);\n const getPaintedVersion = useCallback(() => paintedVersionRef.current, []);\n const markPainted = useCallback(() => {\n paintedVersionRef.current = contentVersionRef.current?.() ?? 0;\n }, [contentVersionRef]);\n return { getPaintedVersion, markPainted };\n}\n\nfunction retainPolicy(retain: PaintInputs['retain']): LayerRetainPolicy | false {\n if (retain === false) return false;\n const minCommands = retain?.minCommands;\n return minCommands === undefined ? DEFAULT_LAYER_RETAIN : { minCommands };\n}\n\n/**\n * Publish the canvas's paint into `paintRef`, which the frame loop calls. The paint binds the\n * leased renderer to whichever canvas pixels go to and draws the layer stack through the\n * current view. The layer command cache lives as long as the canvas.\n */\nexport function useCanvasPaint(\n paintRef: { current: () => boolean },\n lease: CanvasRendererLease,\n target: Pick<CanvasElements, 'paintTargetRef' | 'ownCanvasRef' | 'paintRectRef'>,\n frame: PaintFrame,\n markPainted: () => void,\n requestRedraw: () => void,\n): void {\n const { paintTargetRef, ownCanvasRef, paintRectRef } = target;\n const { inputsRef, viewRef, gateRef, helpersRef } = frame;\n const layerCacheRef = useRef<LayerCommandCache>(new Map());\n const snapRef = useRef(new ViewSnap());\n\n const paint = useCallback((): boolean => {\n const c = paintTargetRef.current ?? ownCanvasRef.current;\n if (!c) return false;\n const rect = paintRectRef.current;\n const {\n layers: paintLayers, width: w, height: h, debugSink: sink, frameStats: timed,\n dpr: dprIn,\n flattenTolerance: paintFlattenTolerance,\n layerGroups: groups, shaders: paintShaders, retain, imageMinification,\n } = inputsRef.current;\n if (w === 0 || h === 0) return false;\n\n const debugFrame = beginDebugFrame(sink, timed, paintLayers);\n\n const renderer = lease.bind(c, { width: w, height: h, dpr: dprIn }, {\n tile: rect,\n flattenTolerance: paintFlattenTolerance,\n retainBudget: retain ? retain.budget : undefined,\n imageMinification,\n shaders: paintShaders,\n });\n // No WebGL2 (jsdom), or a context that is lost for now: nothing to paint.\n if (!renderer) return false;\n\n const dpr = resolveDpr(dprIn);\n // The renderer's own device pixels to the CSS pixel, from its rounded buffer width.\n const view = snapRef.current.draw(viewRef.current, Math.round(w * dpr) / w, retain !== false && retain?.whole !== false);\n const { layerVisibility: vis, layerOrder: order } = gateRef.current;\n const spans = debugFrame?.time();\n const commands = drawLayers(\n paintLayers,\n helpersRef.current,\n vis ?? NO_LAYER_VISIBILITY,\n order,\n view,\n { width: w, height: h, dpr },\n layerCacheRef.current,\n undefined,\n groups,\n spans,\n retainPolicy(retain),\n );\n renderer.render(commands, viewToMat3(view), spans ? { spans } : undefined);\n const stats = renderer.lastFrameStats();\n debugFrame?.end(stats);\n markPainted();\n if (snapRef.current.owesFrame(stats.retained.declined)) requestRedraw();\n return true;\n }, [gateRef, helpersRef, inputsRef, lease, markPainted, ownCanvasRef, paintRectRef, paintTargetRef, requestRedraw, viewRef]);\n useInsertionEffect(() => {\n paintRef.current = paint;\n });\n\n useEffect(() => {\n const layerCache = layerCacheRef.current;\n return () => { layerCache.clear(); };\n }, []);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,gBAGhC;CACA,MAAM,oBAAoB,UAAU,cAAc;CAClD,MAAM,oBAAoB,OAAO,CAAC;CAKlC,OAAO;EAAE,mBAJiB,kBAAkB,kBAAkB,SAAS,CAAC,CAI/D;EAAmB,aAHR,kBAAkB;GACpC,kBAAkB,UAAU,kBAAkB,UAAU,KAAK;EAC/D,GAAG,CAAC,iBAAiB,CACO;CAAY;AAC1C;AAEA,SAAS,aAAa,QAA0D;CAC9E,IAAI,WAAW,OAAO,OAAO;CAC7B,MAAM,cAAc,QAAQ;CAC5B,OAAO,gBAAgB,SAAY,uBAAuB,EAAE,YAAY;AAC1E;;;;;;AAOA,SAAgB,eACd,UACA,OACA,QACA,OACA,aACA,eACM;CACN,MAAM,EAAE,gBAAgB,cAAc,iBAAiB;CACvD,MAAM,EAAE,WAAW,SAAS,SAAS,eAAe;CACpD,MAAM,gBAAgB,uBAA0B,IAAI,IAAI,CAAC;CACzD,MAAM,UAAU,OAAO,IAAI,SAAS,CAAC;CAErC,MAAM,QAAQ,kBAA2B;EACvC,MAAM,IAAI,eAAe,WAAW,aAAa;EACjD,IAAI,CAAC,GAAG,OAAO;EACf,MAAM,OAAO,aAAa;EAC1B,MAAM,EACJ,QAAQ,aAAa,OAAO,GAAG,QAAQ,GAAG,WAAW,MAAM,YAAY,OACvE,KAAK,OACL,kBAAkB,uBAClB,aAAa,QAAQ,SAAS,cAAc,QAAQ,sBAClD,UAAU;EACd,IAAI,MAAM,KAAK,MAAM,GAAG,OAAO;EAE/B,MAAM,aAAa,gBAAgB,MAAM,OAAO,WAAW;EAE3D,MAAM,WAAW,MAAM,KAAK,GAAG;GAAE,OAAO;GAAG,QAAQ;GAAG,KAAK;EAAM,GAAG;GAClE,MAAM;GACN,kBAAkB;GAClB,cAAc,SAAS,OAAO,SAAS;GACvC;GACA,SAAS;EACX,CAAC;EAED,IAAI,CAAC,UAAU,OAAO;EAEtB,MAAM,MAAM,WAAW,KAAK;EAE5B,MAAM,OAAO,QAAQ,QAAQ,KAAK,QAAQ,SAAS,KAAK,MAAM,IAAI,GAAG,IAAI,GAAG,WAAW,SAAS,QAAQ,UAAU,KAAK;EACvH,MAAM,EAAE,iBAAiB,KAAK,YAAY,UAAU,QAAQ;EAC5D,MAAM,QAAQ,YAAY,KAAK;EAC/B,MAAM,WAAW,WACf,aACA,WAAW,SACX,OAAO,qBACP,OACA,MACA;GAAE,OAAO;GAAG,QAAQ;GAAG;EAAI,GAC3B,cAAc,SACd,QACA,QACA,OACA,aAAa,MAAM,CACrB;EACA,SAAS,OAAO,UAAU,WAAW,IAAI,GAAG,QAAQ,EAAE,MAAM,IAAI,MAAS;EACzE,MAAM,QAAQ,SAAS,eAAe;EACtC,YAAY,IAAI,KAAK;EACrB,YAAY;EACZ,IAAI,QAAQ,QAAQ,UAAU,MAAM,SAAS,QAAQ,GAAG,cAAc;EACtE,OAAO;CACT,GAAG;EAAC;EAAS;EAAY;EAAW;EAAO;EAAa;EAAc;EAAc;EAAgB;EAAe;CAAO,CAAC;CAC3H,yBAAyB;EACvB,SAAS,UAAU;CACrB,CAAC;CAED,gBAAgB;EACd,MAAM,aAAa,cAAc;EACjC,aAAa;GAAE,WAAW,MAAM;EAAG;CACrC,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -12,7 +12,7 @@ function useHitObserver(cb, pickerRef) {
|
|
|
12
12
|
return useMemo(() => {
|
|
13
13
|
if (!wired) return void 0;
|
|
14
14
|
return (world) => {
|
|
15
|
-
const result = pickerRef.current?.(world
|
|
15
|
+
const result = pickerRef.current?.(world);
|
|
16
16
|
cbRef.current?.(result ? {
|
|
17
17
|
id: result.id,
|
|
18
18
|
kind: result.kind
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHitObserver.js","names":[],"sources":["../../src/canvas/useHitObserver.ts"],"sourcesContent":["import { useMemo, type MutableRefObject } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { SceneCanvasHit } from './SceneCanvas';\n\ntype Picker = ((
|
|
1
|
+
{"version":3,"file":"useHitObserver.js","names":[],"sources":["../../src/canvas/useHitObserver.ts"],"sourcesContent":["import { useMemo, type MutableRefObject } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { SceneCanvasHit } from './SceneCanvas';\nimport type { WorldPoint } from '@weasel-js/routing';\n\ntype Picker = ((world: WorldPoint) => { id: string; kind: string } | null | undefined) | undefined;\n\n/** Turns a consumer's hit callback into the world-point observer the gesture\n * dispatcher takes, resolving the hit with the canvas's own picker. Identity\n * changes only between wired and not, so the dispatcher isn't rebuilt per\n * render. */\nexport function useHitObserver(\n cb: ((hit: SceneCanvasHit | null) => void) | undefined,\n pickerRef: MutableRefObject<Picker>,\n): ((world: WorldPoint) => void) | undefined {\n const cbRef = useLatest(cb);\n const wired = Boolean(cb);\n return useMemo(() => {\n if (!wired) return undefined;\n return (world) => {\n const result = pickerRef.current?.(world);\n cbRef.current?.(result ? { id: result.id, kind: result.kind } : null);\n };\n }, [wired, cbRef, pickerRef]);\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,eACd,IACA,WAC2C;CAC3C,MAAM,QAAQ,UAAU,EAAE;CAC1B,MAAM,QAAQ,QAAQ,EAAE;CACxB,OAAO,cAAc;EACnB,IAAI,CAAC,OAAO,OAAO;EACnB,QAAQ,UAAU;GAChB,MAAM,SAAS,UAAU,UAAU,KAAK;GACxC,MAAM,UAAU,SAAS;IAAE,IAAI,OAAO;IAAI,MAAM,OAAO;GAAK,IAAI,IAAI;EACtE;CACF,GAAG;EAAC;EAAO;EAAO;CAAS,CAAC;AAC9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeView } from "../core/viewport/view.js";
|
|
2
|
-
import { isRectAim, rectAim, viewForAim } from "../
|
|
2
|
+
import { isRectAim, rectAim, viewForAim } from "../domains/viewports/aim.js";
|
|
3
3
|
import { viewportWorldRect } from "../core/viewport/viewportWorldRect.js";
|
|
4
4
|
import { useCanvasView } from "./useCanvasView.js";
|
|
5
5
|
import { sizeOf } from "./useViewNesting.js";
|
|
@@ -1 +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 '
|
|
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 'domains/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":"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"}
|
|
@@ -58,7 +58,7 @@ function useViewHelpers(opts) {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
}, [adapter]);
|
|
61
|
-
const
|
|
61
|
+
const selectionRef = useLatest(selection);
|
|
62
62
|
const effectiveBoundsOf = useMemo(() => boundsOf ?? baseBoundsOf, [boundsOf, baseBoundsOf]);
|
|
63
63
|
const { previewPoseOf, previewBoundsOf } = useInFlightBounds({
|
|
64
64
|
gestureSource,
|
|
@@ -78,8 +78,12 @@ function useViewHelpers(opts) {
|
|
|
78
78
|
return effectiveBoundsOf ? effectiveBoundsOf(id) : null;
|
|
79
79
|
}, [previewBoundsOf, effectiveBoundsOf]);
|
|
80
80
|
const chromeState = useMemo(() => buildChromeState({
|
|
81
|
-
selection
|
|
82
|
-
|
|
81
|
+
get selection() {
|
|
82
|
+
return selectionRef.current();
|
|
83
|
+
},
|
|
84
|
+
get multiActive() {
|
|
85
|
+
return selectionRef.current().length > 1;
|
|
86
|
+
},
|
|
83
87
|
effectiveBoundsOf: boundsWithPreview,
|
|
84
88
|
modifiers: {
|
|
85
89
|
alt: false,
|
|
@@ -96,8 +100,7 @@ function useViewHelpers(opts) {
|
|
|
96
100
|
...layerIsPainted ? { layerIsPainted } : {},
|
|
97
101
|
...adapter?.getNode ? { layerOf: (id) => adapter.getNode?.(id)?.layer } : {}
|
|
98
102
|
}), [
|
|
99
|
-
|
|
100
|
-
multiActive,
|
|
103
|
+
selectionRef,
|
|
101
104
|
boundsWithPreview,
|
|
102
105
|
geometry,
|
|
103
106
|
committedPoseOf,
|
|
@@ -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 { 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":"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"}
|
|
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 /** The ids selected, read whenever chrome asks: a view following another\n * reads that view's, which changes without this one rendering. */\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 selectionRef = useLatest(selection);\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 get selection() { return selectionRef.current(); },\n get multiActive() { return selectionRef.current().length > 1; },\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 [selectionRef, 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":"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"}
|
|
@@ -71,32 +71,59 @@ function useViewNesting(registry, live) {
|
|
|
71
71
|
const p = live.current.parent;
|
|
72
72
|
return p === void 0 ? void 0 : registry?.get(p);
|
|
73
73
|
}, [live, registry]);
|
|
74
|
+
const following = useRef(false);
|
|
75
|
+
/** `read` asked of the view this one follows, while it names a live one. */
|
|
76
|
+
const ofFollowed = useCallback((read) => {
|
|
77
|
+
const id = live.current.follows?.() ?? null;
|
|
78
|
+
const reg = id === null || following.current ? void 0 : registry?.get(id);
|
|
79
|
+
if (!reg) return null;
|
|
80
|
+
following.current = true;
|
|
81
|
+
try {
|
|
82
|
+
return { value: read(reg) };
|
|
83
|
+
} finally {
|
|
84
|
+
following.current = false;
|
|
85
|
+
}
|
|
86
|
+
}, [live, registry]);
|
|
74
87
|
/** The layers this view draws, in the order it draws them: of the surface's,
|
|
75
|
-
* or of what the view it is nested in draws. */
|
|
88
|
+
* or of what the view it is nested in or follows draws. */
|
|
76
89
|
const drawnLayers = useCallback(() => {
|
|
90
|
+
const followed = ofFollowed((reg) => reg.drawnLayers());
|
|
91
|
+
if (followed) return viewPaintedLayers(followed.value, live.current);
|
|
77
92
|
if (live.current.parent !== void 0) return viewPaintedLayers(parentReg()?.drawnLayers() ?? [], live.current);
|
|
78
93
|
return viewPaintedLayers(registry?.surface()?.layers() ?? [], live.current);
|
|
79
94
|
}, [
|
|
80
95
|
registry,
|
|
81
96
|
live,
|
|
82
|
-
parentReg
|
|
97
|
+
parentReg,
|
|
98
|
+
ofFollowed
|
|
83
99
|
]);
|
|
84
100
|
const [sceneLayerGate] = useState(createSceneLayerGate);
|
|
101
|
+
/** What this view's picks, marquees and select-alls ask of a scene layer:
|
|
102
|
+
* painted here, and in every view this one is nested in or follows. */
|
|
103
|
+
const layerIsPainted = useCallback((layerId) => {
|
|
104
|
+
if (!sceneLayerGate(registry?.surface()?.layers() ?? [], live.current)(layerId)) return false;
|
|
105
|
+
const followed = ofFollowed((reg) => reg.layerIsPainted(layerId));
|
|
106
|
+
if (followed) return followed.value;
|
|
107
|
+
if (live.current.parent === void 0) return true;
|
|
108
|
+
return parentReg()?.layerIsPainted(layerId) ?? false;
|
|
109
|
+
}, [
|
|
110
|
+
registry,
|
|
111
|
+
sceneLayerGate,
|
|
112
|
+
live,
|
|
113
|
+
parentReg,
|
|
114
|
+
ofFollowed
|
|
115
|
+
]);
|
|
116
|
+
/** The selection this view owns, or else the one the view it follows owns:
|
|
117
|
+
* `undefined` while it shares the surface's. */
|
|
118
|
+
const ownedSelection = useCallback(() => live.current.viewSelection ?? ofFollowed((reg) => reg.selection())?.value, [live, ofFollowed]);
|
|
85
119
|
return {
|
|
86
120
|
frameIn,
|
|
87
121
|
rectAt,
|
|
88
122
|
derivedAt,
|
|
89
123
|
drawnLayers,
|
|
90
|
-
layerIsPainted
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return parentReg()?.layerIsPainted(layerId) ?? false;
|
|
94
|
-
}, [
|
|
95
|
-
registry,
|
|
96
|
-
sceneLayerGate,
|
|
97
|
-
live,
|
|
98
|
-
parentReg
|
|
99
|
-
])
|
|
124
|
+
layerIsPainted,
|
|
125
|
+
ownedSelection,
|
|
126
|
+
selectionNow: useCallback(() => ownedSelection() ?? live.current.shared, [ownedSelection, live])
|
|
100
127
|
};
|
|
101
128
|
}
|
|
102
129
|
|
|
@@ -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'
|
|
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 { SelectionApi } from 'core/selection/useSelection';\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' | 'follows' | 'bounds' | 'layers' | 'layerVisibility' | 'layerOrder'> & {\n /** The selection the view owns, when it owns one. */\n viewSelection?: SelectionApi | undefined;\n /** The surface's selection, which the view acts on while it neither owns one nor follows a view that does. */\n shared: SelectionApi;\n};\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 // Set while this view asks the view it follows, so two views following each\n // other find nothing to follow rather than recursing.\n const following = useRef(false);\n /** `read` asked of the view this one follows, while it names a live one. */\n const ofFollowed = useCallback(<T>(read: (reg: ViewRegistration) => T): { value: T } | null => {\n const id = live.current.follows?.() ?? null;\n const reg = id === null || following.current ? undefined : registry?.get(id);\n if (!reg) return null;\n following.current = true;\n try {\n return { value: read(reg) };\n } finally {\n following.current = false;\n }\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 or follows draws. */\n const drawnLayers = useCallback((): readonly RenderLayer<unknown>[] => {\n const followed = ofFollowed((reg) => reg.drawnLayers());\n if (followed) return viewPaintedLayers(followed.value, live.current);\n if (live.current.parent !== undefined) return viewPaintedLayers(parentReg()?.drawnLayers() ?? [], live.current);\n return viewPaintedLayers(registry?.surface()?.layers() ?? [], live.current);\n }, [registry, live, parentReg, ofFollowed]);\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 or follows. */\n const layerIsPainted = useCallback((layerId: string): boolean => {\n if (!sceneLayerGate(registry?.surface()?.layers() ?? [], live.current)(layerId)) return false;\n const followed = ofFollowed((reg) => reg.layerIsPainted(layerId));\n if (followed) return followed.value;\n if (live.current.parent === undefined) return true;\n return parentReg()?.layerIsPainted(layerId) ?? false;\n }, [registry, sceneLayerGate, live, parentReg, ofFollowed]);\n\n /** The selection this view owns, or else the one the view it follows owns:\n * `undefined` while it shares the surface's. */\n const ownedSelection = useCallback((): SelectionApi | undefined => (\n live.current.viewSelection ?? ofFollowed((reg) => reg.selection())?.value\n ), [live, ofFollowed]);\n /** The selection this view acts on, as of now: a followed view's changes with the aim. */\n const selectionNow = useCallback(() => ownedSelection() ?? live.current.shared, [ownedSelection, live]);\n return { frameIn, rectAt, derivedAt, drawnLayers, layerIsPainted, ownedSelection, selectionNow };\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewInputs.js","names":[],"sources":["../../src/canvas/viewInputs.tsx"],"sourcesContent":["/**\n * What {@link useViewHelpers} needs that belongs to the surface rather than to\n * one view: the adapter, the geometry and the bounds resolver.\n *\n * These are read during a view's render, so they travel as context rather than\n * on the `SurfaceHandle`, which is not attached until an effect runs.\n */\nimport type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { createContext, useContext, type ReactNode } from 'react';\nimport type { UseViewHelpersOpts } from './useViewHelpers';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { View } from 'core/viewport/view';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport type { PlaneMap } from 'core/viewport/parallax';\nimport type { ChromeCaps } from '
|
|
1
|
+
{"version":3,"file":"viewInputs.js","names":[],"sources":["../../src/canvas/viewInputs.tsx"],"sourcesContent":["/**\n * What {@link useViewHelpers} needs that belongs to the surface rather than to\n * one view: the adapter, the geometry and the bounds resolver.\n *\n * These are read during a view's render, so they travel as context rather than\n * on the `SurfaceHandle`, which is not attached until an effect runs.\n */\nimport type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { createContext, useContext, type ReactNode } from 'react';\nimport type { UseViewHelpersOpts } from './useViewHelpers';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { View } from 'core/viewport/view';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\nimport type { PlaneMap } from 'core/viewport/parallax';\nimport type { ChromeCaps } from 'domains/chrome-caps/useChromeCaps';\nimport type { PickView } from './SceneCanvas/useSceneSelectTool';\nimport type { WorldPoint } from '@weasel-js/routing';\n\nexport type { ViewRuleInputs } from 'domains/chrome-caps/useChromeCaps';\n\n/**\n * @internal Provided by the surface, consumed by `<CanvasView>`.\n *\n * The scene-shaped half only. What a gesture is doing right now is read from\n * the asking view's own dispatcher, not from here.\n */\nexport interface SurfaceViewInputs\n extends Pick<UseViewHelpersOpts<unknown>, 'adapter' | 'geometry'> {\n /** A node's box for chrome, drawn under `view` — the camera of the view\n * asking, since a node on a parallax plane lands somewhere else in each. */\n boundsOf: ((id: string, view?: View | null) => Bounds | null) | undefined;\n /** How `view`'s world maps into the parallax plane `id` is drawn through,\n * or null when its layer moves with the camera. */\n planeOfNode?: ((id: string, view?: View | null) => PlaneMap | null) | undefined;\n /** `boundsOf` for `id` drawn at an in-flight `pose`, under `view`. */\n boundsOfPose?: ((id: string, pose: unknown, view?: View | null) => Bounds | null) | undefined;\n /** Every id under a world point, bottom-first. `view` is the view the\n * point was produced under — a screen-pixel tolerance cannot be converted\n * without its scale, nor a layer judged without its paint, and the world\n * point carries neither. */\n pickEvery?: (world: WorldPoint, view?: PickView | null) => string[];\n /** The one id a click resolves to, collapsing parent/child the way the\n * select tool does. Falls back to `pickEvery`'s last when absent. */\n pickBest?: (world: WorldPoint, view?: PickView | null) => string | null;\n /** A hit node's routing-trait kind, so `target: 'kind:text'` bindings match. */\n kindOfNode?: (id: string) => string | undefined;\n /** The node a double-click on a hit names (`doubleClickTarget`). */\n doubleClickNames?: ((hitId: string) => string) | undefined;\n /** The surface's chrome-caps rule table, evaluated against a view's own\n * context. */\n chromeCaps?: ChromeCaps;\n /** The surface's selection, which a view shares unless it was given one of\n * its own. */\n selectionApi: SelectionApi;\n /** The rotate badge the surface's selection overlay paints, which every\n * view drawing that overlay has to make grabbable where it is drawn. */\n rotationBadge?: { distancePx: number; sizePx: number } | null;\n /** The surface's resize-handle layout — which handles exist and their hit\n * radius — so every view grabs exactly the handles the overlay paints. */\n resizeHandles?: ResizeHandleLayout;\n}\n\nconst ViewInputsContext = createContext<SurfaceViewInputs | null>(null);\n\n/** @internal */\nexport function ViewInputsProvider(\n { value, children }: { value: SurfaceViewInputs; children: ReactNode },\n) {\n return <ViewInputsContext.Provider value={value}>{children}</ViewInputsContext.Provider>;\n}\n\n/** The hosting surface's view-helper inputs, or `null` outside one. */\nexport function useOptionalViewInputs(): SurfaceViewInputs | null {\n return useContext(ViewInputsContext);\n}\n"],"mappings":";;;;AA8DA,IAAM,oBAAoB,cAAwC,IAAI;;AAGtE,SAAgB,mBACd,EAAE,OAAO,YACT;CACA,OAAO,oBAAC,kBAAkB,UAAnB;EAAmC;EAAQ;CAAqC,CAAA;AACzF;;AAGA,SAAgB,wBAAkD;CAChE,OAAO,WAAW,iBAAiB;AACrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aimSpace2d } from "../
|
|
2
|
-
import { createViewMarkerLayer, grabViewMarker } from "../
|
|
1
|
+
import { aimSpace2d } from "../domains/viewports/aim.js";
|
|
2
|
+
import { createViewMarkerLayer, grabViewMarker } from "../domains/viewports/viewMarker.js";
|
|
3
3
|
import { layerAffordance } from "./affordanceAt.js";
|
|
4
4
|
|
|
5
5
|
//#region src/canvas/viewMarkers.ts
|
|
@@ -1 +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 '
|
|
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 'domains/viewports/aim';\nimport type { ResolvableView } from 'domains/viewports/viewResolver';\nimport type { View } from 'core/viewport/view';\nimport {\n createViewMarkerLayer, grabViewMarker, type ViewMarkerHost, type ViewMarkerProps,\n} from 'domains/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,KAAK;EAAE,CAAC,IAAI;CACjF;CACA,OAAO;EACL,iBAAiB,UAAU;GACzB,MAAM,EAAE,OAAO,MAAM;GACrB,KAAK,MAAM,QAAQ,QAAQ,KAAK,GAC9B,IAAI,KAAK,CAAC,CAAC,OAAO,IAAI;IACpB,QAAQ,MAAM,oCAAoC,GAAG,qGAAqG;IAC1J,aAAa,CAAC;GAChB;GAEF,QAAQ,IAAI,OAAO,sBAAsB,OAAO,KAAK,IAAI,CAAC;GAC1D,KAAK,QAAQ;GACb,aAAa;IAAE,QAAQ,OAAO,KAAK;IAAG,KAAK,QAAQ;GAAG;EACxD;EACA,eAAe,WAAW;GACxB,MAAM,MAA8B,CAAC;GACrC,KAAK,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,MAAM,CAAC,CAAC,WAAW,QAAQ,IAAI,KAAK,KAAK;GACnF,OAAO;EACT;EACA,WAAW,QAAQ,UAAU;GAC3B,IAAI,CAAC,OAAO,GAAG,OAAO;GACtB,MAAM,QAAQ,YAAY,MAAM;GAChC,MAAM,KAAK,OAAO,QAAQ,KAAK;GAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO;GAC1B,MAAM,OAAO,CAAC,GAAG,QAAQ,KAAK,CAAC;GAC/B,KAAK,IAAI,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;IACzC,MAAM,QAAQ,KAAK,EAAE,CAAE;IACvB,IAAI,MAAM,WAAW,QAAQ;IAC7B,MAAM,OAAO,eAAe,OAAO,KAAK,MAAM,OAAO,EAAE;IACvD,IAAI,MAAM,OAAO,gBAAgB,eAAe,MAAM,MAAM,EAAE,gBAAgB,KAAK,CAAC;GACtF;GACA,OAAO;EACT;EACA,cAAc,SAAS;GACrB,OAAO;GACP,aAAa;IAAE,IAAI,SAAS,MAAM,OAAO;GAAM;EACjD;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createViewResolver, viewContains } from "../
|
|
2
|
-
import { isRectAim, rectAim, viewForAim } from "../
|
|
1
|
+
import { createViewResolver, viewContains } from "../domains/viewports/viewResolver.js";
|
|
2
|
+
import { isRectAim, rectAim, viewForAim } from "../domains/viewports/aim.js";
|
|
3
3
|
import { viewportWorldRect } from "../core/viewport/viewportWorldRect.js";
|
|
4
4
|
import { createViewMarkerRegistry } from "./viewMarkers.js";
|
|
5
5
|
import { createEmitter } from "@weasel-js/registry";
|