@weasel-js/core 1.14.1 → 1.15.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 +218 -0
- package/README.md +1 -1
- package/dist/affordances/pathAnchors.js +0 -1
- package/dist/affordances/pathAnchors.js.map +1 -1
- package/dist/barrel/paths.js +1 -1
- package/dist/barrel/renderer.js +2 -2
- package/dist/barrel/routing.js +6 -4
- package/dist/barrel/text.js +5 -3
- package/dist/canvas/Canvas.js +5 -1
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +5 -1
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js +4 -0
- package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
- package/dist/canvas/SceneCanvas/builtinToolSets.js +6 -3
- package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +1 -1
- package/dist/canvas/SceneCanvas/presets/paths.js +6 -6
- package/dist/canvas/SceneCanvas/presets/paths.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/useBuiltinTools.js +2 -0
- package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useContributionRoles.js +2 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneChrome.js +17 -5
- package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js +3 -0
- package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +5 -4
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +5 -1
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/affordanceAt.js +0 -1
- package/dist/canvas/affordanceAt.js.map +1 -1
- package/dist/canvas/deps/chromeRules.js +37 -0
- package/dist/canvas/deps/chromeRules.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +0 -6
- package/dist/canvas/deps/editAnchors.js.map +1 -1
- package/dist/canvas/deps/hitTestArea.js +3 -1
- package/dist/canvas/deps/hitTestArea.js.map +1 -1
- package/dist/canvas/deps/modeDefaultTool.js +23 -0
- package/dist/canvas/deps/modeDefaultTool.js.map +1 -0
- package/dist/canvas/deps/pathEditCommits.js +1 -1
- package/dist/canvas/deps/selectionSnapshot.js +23 -0
- package/dist/canvas/deps/selectionSnapshot.js.map +1 -0
- package/dist/canvas/deps/snap.js +1 -0
- package/dist/canvas/deps/snap.js.map +1 -1
- package/dist/canvas/pickReach.js +12 -8
- package/dist/canvas/pickReach.js.map +1 -1
- package/dist/canvas/pickWalk.js +7 -5
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/scenePickSource.js +2 -2
- package/dist/canvas/scenePickSource.js.map +1 -1
- package/dist/canvas/useCanvasSurface.js +21 -3
- package/dist/canvas/useCanvasSurface.js.map +1 -1
- package/dist/canvas/useFrameLoop.js +6 -7
- package/dist/canvas/useFrameLoop.js.map +1 -1
- package/dist/canvas/useSurfaceSize.js +4 -3
- package/dist/canvas/useSurfaceSize.js.map +1 -1
- package/dist/core/geometry/regionHit.js +35 -16
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/paint/meshKindLazy.js +9 -10
- package/dist/core/paint/meshKindLazy.js.map +1 -1
- package/dist/core/scene/editMode.js +4 -1
- package/dist/core/scene/editMode.js.map +1 -1
- package/dist/core/scene/historyFacade.js +7 -50
- package/dist/core/scene/historyFacade.js.map +1 -1
- package/dist/core/scene/lockGuard.js +1 -0
- package/dist/core/scene/lockGuard.js.map +1 -1
- package/dist/core/scene/nodeGates.js +43 -23
- package/dist/core/scene/nodeGates.js.map +1 -1
- package/dist/core/scene/opTable.js +8 -8
- package/dist/core/scene/opTable.js.map +1 -1
- package/dist/core/scene/outerOps.js +2 -2
- package/dist/core/scene/outerOps.js.map +1 -1
- package/dist/core/scene/poseRemovals.js +1 -0
- package/dist/core/scene/poseRemovals.js.map +1 -1
- package/dist/core/scene/poseWrites.js +16 -15
- package/dist/core/scene/poseWrites.js.map +1 -1
- package/dist/core/scene/sceneJournals.js +78 -0
- package/dist/core/scene/sceneJournals.js.map +1 -0
- package/dist/core/scene/sceneRecording.js +3 -2
- package/dist/core/scene/sceneRecording.js.map +1 -1
- package/dist/core/scene/statedFields.js +10 -8
- package/dist/core/scene/statedFields.js.map +1 -1
- package/dist/core/scene/treeEdits.js +4 -9
- package/dist/core/scene/treeEdits.js.map +1 -1
- package/dist/core/viewport/useCanvasSize.js +47 -26
- package/dist/core/viewport/useCanvasSize.js.map +1 -1
- package/dist/{depSchema-C3BwxitB.d.ts → depSchema-ChQPzEkW.d.ts} +56 -25
- package/dist/domains/chrome-caps/resolve.js +1 -0
- package/dist/domains/chrome-caps/resolve.js.map +1 -1
- package/dist/domains/chrome-caps/useChromeCaps.js +4 -2
- package/dist/domains/chrome-caps/useChromeCaps.js.map +1 -1
- package/dist/domains/paths/pathEditState.js +0 -24
- package/dist/domains/paths/pathEditState.js.map +1 -1
- package/dist/domains/snap/probes2d.js +5 -0
- package/dist/domains/snap/probes2d.js.map +1 -1
- package/dist/domains/snap/resizeBox.js +43 -22
- package/dist/domains/snap/resizeBox.js.map +1 -1
- package/dist/domains/snap/sceneReads.js +11 -1
- package/dist/domains/snap/sceneReads.js.map +1 -1
- package/dist/domains/snap/sceneSession2d.js +4 -2
- package/dist/domains/snap/sceneSession2d.js.map +1 -1
- package/dist/domains/snap/session2d.js +14 -7
- package/dist/domains/snap/session2d.js.map +1 -1
- package/dist/domains/text/index.js +2 -2
- package/dist/icons.table.js +1 -1
- package/dist/icons.table.js.map +1 -1
- package/dist/icons.table.json +5 -0
- package/dist/index.d.ts +114 -62
- package/dist/index.js +12 -8
- package/dist/interactions/actions/booleans/action.js +4 -2
- package/dist/interactions/actions/booleans/action.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +3 -6
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/bendSegment.js +1 -2
- package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
- package/dist/interactions/actions/defaults/exitPathEdit.js +17 -1
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/action.js +3 -4
- package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
- package/dist/interactions/actions/insert/action.js +21 -2
- package/dist/interactions/actions/insert/action.js.map +1 -1
- package/dist/interactions/actions/insert/params.js +43 -0
- package/dist/interactions/actions/insert/params.js.map +1 -0
- package/dist/interactions/actions/notices.js +17 -0
- package/dist/interactions/actions/notices.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +8 -6
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
- package/dist/interactions/actions/outlines/createOutlinesAction.js +13 -8
- package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -1
- package/dist/interactions/actions/outlines/outlineStrokeAction.js +3 -2
- package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -1
- package/dist/interactions/actions/pathCommands/pathNodes.js +1 -1
- package/dist/interactions/actions/testUtils.js +0 -7
- package/dist/interactions/actions/testUtils.js.map +1 -1
- package/dist/interactions/actions/useNotices.js +13 -0
- package/dist/interactions/actions/useNotices.js.map +1 -0
- package/dist/test-seams.d.ts +5 -12
- package/dist/tools/builtin/anchors/anchorsTool.js +31 -0
- package/dist/tools/builtin/anchors/anchorsTool.js.map +1 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js +1 -1
- package/dist/tools/builtin/star/useStarTool.js +1 -1
- package/dist/tools/index.js +4 -2
- package/dist/tools/toolOptions.js +47 -0
- package/dist/tools/toolOptions.js.map +1 -0
- package/dist/version.js +1 -1
- package/package.json +25 -25
- package/dist/interactions/actions/defaults/pathEditTools.js +0 -60
- package/dist/interactions/actions/defaults/pathEditTools.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneCanvasInput.js","names":["_Fragment"],"sources":["../../../src/canvas/SceneCanvas/SceneCanvasInput.tsx"],"sourcesContent":["import type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { RuleCtx } from 'domains/chrome-caps';\nimport type { Affordance } from 'affordances/types';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport { useContext, useEffect, type MutableRefObject, type RefObject } from 'react';\nimport { SnapSourceRegistryContext } from 'domains/snap/registry';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSource } from 'domains/snap/types';\nimport { dlog } from '../../debug/flag';\nimport { useDeviceProfile } from '../../core/device/useDeviceProfile';\nimport { useTestHook } from '../../test-hook/useTestHook';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport { useHitObserver } from '../useHitObserver';\nimport type { CanvasViewState } from '../useCanvasView';\nimport { GeometryProjectionRegistrar, ResizePolicyRegistrar } from './poseRegistrars';\nimport { usePointerPublisher } from './PointerProviderIfRoot';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport type { useSceneCanvasTools } from './useSceneCanvasTools';\nimport { useSceneGestureDispatcher } from './useSceneGestureDispatcher';\nimport { useCanvasDevtoolsRoot, type CanvasDevtools } from './useCanvasDevtoolsRoot';\nimport type { useScenePicking } from './useScenePicking';\nimport {\n useSceneStandardActions, type SceneStandardActionsInputs, type StandardActionsProps,\n} from './useSceneStandardActions';\nimport { useToolKeybindings } from './useToolKeybindings';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\ntype Picking = ReturnType<typeof useScenePicking<unknown, string, unknown>>;\n\n/** The `<SceneCanvas>` props its input wiring reads. */\nexport type SceneCanvasInputOptions = StandardActionsProps & Pick<\n Props,\n | 'selectTool' | 'geometryProjection' | 'enableGestureDispatcher' | 'enableKeybindings'\n | 'claimKeys' | 'longPress' | 'modes' | 'versionCheck' | 'onClick' | 'onDoubleClick' | 'routing'\n>;\n\n/** What `<SceneCanvas>` hands {@link SceneCanvasInput}. */\nexport interface SceneCanvasInputProps {\n props: SceneCanvasInputOptions;\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n descriptor: PoseDescriptor<unknown>;\n picking: Pick<\n Picking, 'pickEvery' | 'pickBest' | 'boundsOf' | 'planeOfNode' | 'kindOfNode' | 'doubleClickNames' | 'viewLayerGate' | 'alphaOf' | 'enteredGroup' | 'reachable'\n > & { adapter: BridgeAdapter };\n /** The node a hit resolves to, for the `onClick` / `onDoubleClick` observers. */\n nodeAtPointRef: MutableRefObject<NodeAtPoint | undefined>;\n tools: ReturnType<typeof useSceneCanvasTools>;\n viewOn: boolean;\n camera: { viewState: CanvasViewState; viewAnimation: SceneStandardActionsInputs['viewAnimation'] };\n dispatcher: Dispatcher;\n pathEdit: {\n state: SceneStandardActionsInputs['editAnchorsExternalState'];\n };\n chrome: { getIsVisible: () => (id: string) => boolean; getRuleCtx: () => RuleCtx | undefined };\n /** The selection overlay's rotate badge, and where the dispatcher reports the affordances\n * it hit-tests, for the slops overlay. */\n overlay: {\n rotationBadge: { distancePx: number; sizePx: number } | null | undefined;\n /** The resize-handle layout the overlay paints, so the hit-test grabs exactly those. */\n resizeHandles: ResizeHandleLayout;\n chromeAffordancesRef: MutableRefObject<readonly Affordance[]>;\n };\n canvas: {\n elementRef: MutableRefObject<HTMLElement | null>;\n apiRef: RefObject<CanvasExtensionApi | null>;\n ready: boolean;\n };\n ingestionClipboard: SceneStandardActionsInputs['ingestionClipboard'];\n ingestionHandlers: SceneStandardActionsInputs['ingestionHandlers'];\n /** The enabled presets' snap sources. */\n snapSources: readonly SnapSource[];\n /** The outcome store the canvas's readout layer draws. */\n snapStore: SnapOutcomeStore;\n devtools: CanvasDevtools;\n}\n\n/**\n * The canvas's input wiring: the pointer publisher, the standard actions and their deps, the\n * gesture dispatcher, and the tool keybindings, in that order, then the test hook.\n *\n * A component of its own, mounted ahead of `<SceneCanvas>`'s children, rather than hooks in the\n * canvas's body: dep sources and actions stack newest-live in effect order, and a parent's\n * effects run after its children's, so a child overriding a kit dep would lose to it.\n */\nexport function SceneCanvasInput(p: SceneCanvasInputProps) {\n const { props, scene, selection, picking, chrome, overlay, canvas } = p;\n const { viewState } = p.camera;\n const { selectTool, enableKeybindings = true } = props;\n const snapRegistry = useContext(SnapSourceRegistryContext);\n useEffect(() => {\n dlog('scene-canvas', 'mount');\n return () => dlog('scene-canvas', 'unmount');\n }, []);\n usePointerPublisher(canvas.elementRef, canvas.apiRef);\n useSceneStandardActions({\n props, viewOn: p.viewOn,\n selection, enteredGroup: picking.enteredGroup, scene, adapter: picking.adapter, standardActions: p.tools.standardActions,\n currentViewRef: viewState.viewRef, onViewChange: viewState.setViewFromInput,\n poseDescriptor: p.descriptor, dispatcher: p.dispatcher,\n pickEvery: picking.pickEvery, layerIsPainted: picking.viewLayerGate, alphaOf: picking.alphaOf, reachable: picking.reachable,\n viewAnimation: p.camera.viewAnimation, editAnchorsExternalState: p.pathEdit.state,\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef, ingestionClipboard: p.ingestionClipboard,\n ingestionHandlers: p.ingestionHandlers,\n snap: { sources: [...(props.snap?.sources ?? []), ...p.snapSources], registry: snapRegistry, store: p.snapStore },\n });\n\n // Rides the gesture dispatcher as an OBSERVER rather than an Action binding because the\n // prop is a notification, not a behavior: as a binding it would lose first-match-wins to\n // `enterPathEdit` on every body hit and silently stop firing.\n const onDoubleClick = useHitObserver(props.onDoubleClick, p.nodeAtPointRef);\n const onClick = useHitObserver(props.onClick, p.nodeAtPointRef);\n const selectionRef = useLatest(selection);\n const { targetScale } = useDeviceProfile();\n const { root, traces } = useCanvasDevtoolsRoot({\n scene, selection, viewState, tools: p.tools.tools, contributions: p.tools.contributions, routing: props.routing,\n element: canvas.elementRef, api: canvas.apiRef, devtools: p.devtools,\n });\n useSceneGestureDispatcher({\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef,\n tools: p.tools.tools, contributions: p.tools.contributions,\n enabled: props.enableGestureDispatcher ?? true, keyboard: enableKeybindings,\n claimKeys: props.claimKeys ?? false,\n selectionRef,\n boundsOf: picking.boundsOf, planeOfNode: picking.planeOfNode,\n pickEvery: picking.pickEvery, pickBest: picking.pickBest, kindOfNode: picking.kindOfNode,\n doubleClickNames: picking.doubleClickNames,\n viewRef: viewState.viewRef, dispatcher: p.dispatcher, traces,\n getIsVisibleForCanvas: chrome.getIsVisible, getRuleCtx: chrome.getRuleCtx,\n targetScale, handleHitRadius: overlay.resizeHandles.hitRadiusPx,\n edgeHandles: overlay.resizeHandles.edges,\n rotationBadge: overlay.rotationBadge, chromeAffordancesRef: overlay.chromeAffordancesRef,\n onDoubleClick, onClick, longPress: props.longPress,\n });\n useToolKeybindings({\n internalTools: p.tools.internal,\n toolsTakeover: p.tools.takeover ?? undefined,\n surface: p.tools.surface,\n enableKeybindings,\n modes: props.modes,\n canvasApi: canvas.ready ? canvas.apiRef.current : null,\n versionCheck: props.versionCheck,\n });\n useTestHook({\n getScene: () => scene as never,\n getSelectionIds: () => (selection.current as readonly string[] | undefined) ?? [],\n getView: () => viewState.viewRef.current,\n getActiveToolId: () => p.tools.tools.active ?? null,\n probes: root.probes,\n });\n\n // Mounted only when passed: an empty default registered with the deps above would land\n // after, and over, a dep one of these registered (child effects run first). Absent\n // `geometryProjection` leaves the dep undefined.\n return (\n <>\n {selectTool?.resize\n ? <ResizePolicyRegistrar options={selectTool.resize as UseResizeOptions<unknown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/SceneCanvas/SceneCanvasInput.tsx"],"sourcesContent":["import type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport { useDepSource } from '@weasel-js/routing/react';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { RuleCtx } from 'domains/chrome-caps';\nimport type { Affordance } from 'affordances/types';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport { useContext, useEffect, type MutableRefObject, type RefObject } from 'react';\nimport { SnapSourceRegistryContext } from 'domains/snap/registry';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSource } from 'domains/snap/types';\nimport { dlog } from '../../debug/flag';\nimport { useDeviceProfile } from '../../core/device/useDeviceProfile';\nimport { useTestHook } from '../../test-hook/useTestHook';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { ChromeRulesDep } from '../deps/chromeRules';\nimport { useModeDefaultToolDepSource } from '../deps/modeDefaultTool';\nimport { useHitObserver } from '../useHitObserver';\nimport type { CanvasViewState } from '../useCanvasView';\nimport { GeometryProjectionRegistrar, ResizePolicyRegistrar } from './poseRegistrars';\nimport { usePointerPublisher } from './PointerProviderIfRoot';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport type { useSceneCanvasTools } from './useSceneCanvasTools';\nimport { useSceneGestureDispatcher } from './useSceneGestureDispatcher';\nimport { useCanvasDevtoolsRoot, type CanvasDevtools } from './useCanvasDevtoolsRoot';\nimport type { useScenePicking } from './useScenePicking';\nimport {\n useSceneStandardActions, type SceneStandardActionsInputs, type StandardActionsProps,\n} from './useSceneStandardActions';\nimport { useToolKeybindings } from './useToolKeybindings';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\ntype Picking = ReturnType<typeof useScenePicking<unknown, string, unknown>>;\n\n/** The `<SceneCanvas>` props its input wiring reads. */\nexport type SceneCanvasInputOptions = StandardActionsProps & Pick<\n Props,\n | 'selectTool' | 'geometryProjection' | 'enableGestureDispatcher' | 'enableKeybindings'\n | 'claimKeys' | 'longPress' | 'modes' | 'versionCheck' | 'onClick' | 'onDoubleClick' | 'routing'\n>;\n\n/** What `<SceneCanvas>` hands {@link SceneCanvasInput}. */\nexport interface SceneCanvasInputProps {\n props: SceneCanvasInputOptions;\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n descriptor: PoseDescriptor<unknown>;\n picking: Pick<\n Picking, 'pickEvery' | 'pickBest' | 'boundsOf' | 'planeOfNode' | 'kindOfNode' | 'doubleClickNames' | 'viewLayerGate' | 'alphaOf' | 'enteredGroup' | 'reachable'\n > & { adapter: BridgeAdapter };\n /** The node a hit resolves to, for the `onClick` / `onDoubleClick` observers. */\n nodeAtPointRef: MutableRefObject<NodeAtPoint | undefined>;\n tools: ReturnType<typeof useSceneCanvasTools>;\n viewOn: boolean;\n camera: { viewState: CanvasViewState; viewAnimation: SceneStandardActionsInputs['viewAnimation'] };\n dispatcher: Dispatcher;\n pathEdit: {\n state: SceneStandardActionsInputs['editAnchorsExternalState'];\n };\n chrome: {\n getIsVisible: () => (id: string) => boolean;\n getRuleCtx: () => RuleCtx | undefined;\n chromeRules: ChromeRulesDep;\n };\n /** The selection overlay's rotate badge, and where the dispatcher reports the affordances\n * it hit-tests, for the slops overlay. */\n overlay: {\n rotationBadge: { distancePx: number; sizePx: number } | null | undefined;\n /** The resize-handle layout the overlay paints, so the hit-test grabs exactly those. */\n resizeHandles: ResizeHandleLayout;\n chromeAffordancesRef: MutableRefObject<readonly Affordance[]>;\n };\n canvas: {\n elementRef: MutableRefObject<HTMLElement | null>;\n apiRef: RefObject<CanvasExtensionApi | null>;\n ready: boolean;\n };\n ingestionClipboard: SceneStandardActionsInputs['ingestionClipboard'];\n ingestionHandlers: SceneStandardActionsInputs['ingestionHandlers'];\n /** The enabled presets' snap sources. */\n snapSources: readonly SnapSource[];\n /** The outcome store the canvas's readout layer draws. */\n snapStore: SnapOutcomeStore;\n devtools: CanvasDevtools;\n}\n\n/**\n * The canvas's input wiring: the pointer publisher, the standard actions and their deps, the\n * gesture dispatcher, and the tool keybindings, in that order, then the test hook.\n *\n * A component of its own, mounted ahead of `<SceneCanvas>`'s children, rather than hooks in the\n * canvas's body: dep sources and actions stack newest-live in effect order, and a parent's\n * effects run after its children's, so a child overriding a kit dep would lose to it.\n */\nexport function SceneCanvasInput(p: SceneCanvasInputProps) {\n const { props, scene, selection, picking, chrome, overlay, canvas } = p;\n const { viewState } = p.camera;\n const { selectTool, enableKeybindings = true } = props;\n const snapRegistry = useContext(SnapSourceRegistryContext);\n useEffect(() => {\n dlog('scene-canvas', 'mount');\n return () => dlog('scene-canvas', 'unmount');\n }, []);\n usePointerPublisher(canvas.elementRef, canvas.apiRef);\n useDepSource('chromeRules', () => chrome.chromeRules);\n useModeDefaultToolDepSource(props.modes, p.tools.tools);\n useSceneStandardActions({\n props, viewOn: p.viewOn,\n selection, enteredGroup: picking.enteredGroup, scene, adapter: picking.adapter, standardActions: p.tools.standardActions,\n currentViewRef: viewState.viewRef, onViewChange: viewState.setViewFromInput,\n poseDescriptor: p.descriptor, dispatcher: p.dispatcher,\n pickEvery: picking.pickEvery, layerIsPainted: picking.viewLayerGate, alphaOf: picking.alphaOf, reachable: picking.reachable,\n viewAnimation: p.camera.viewAnimation, editAnchorsExternalState: p.pathEdit.state,\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef, ingestionClipboard: p.ingestionClipboard,\n ingestionHandlers: p.ingestionHandlers,\n snap: { sources: [...(props.snap?.sources ?? []), ...p.snapSources], registry: snapRegistry, store: p.snapStore },\n });\n\n // Rides the gesture dispatcher as an OBSERVER rather than an Action binding because the\n // prop is a notification, not a behavior: as a binding it would lose first-match-wins to\n // `enterPathEdit` on every body hit and silently stop firing.\n const onDoubleClick = useHitObserver(props.onDoubleClick, p.nodeAtPointRef);\n const onClick = useHitObserver(props.onClick, p.nodeAtPointRef);\n const selectionRef = useLatest(selection);\n const { targetScale } = useDeviceProfile();\n const { root, traces } = useCanvasDevtoolsRoot({\n scene, selection, viewState, tools: p.tools.tools, contributions: p.tools.contributions, routing: props.routing,\n element: canvas.elementRef, api: canvas.apiRef, devtools: p.devtools,\n });\n useSceneGestureDispatcher({\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef,\n tools: p.tools.tools, contributions: p.tools.contributions,\n enabled: props.enableGestureDispatcher ?? true, keyboard: enableKeybindings,\n claimKeys: props.claimKeys ?? false,\n selectionRef,\n boundsOf: picking.boundsOf, planeOfNode: picking.planeOfNode,\n pickEvery: picking.pickEvery, pickBest: picking.pickBest, kindOfNode: picking.kindOfNode,\n doubleClickNames: picking.doubleClickNames,\n viewRef: viewState.viewRef, dispatcher: p.dispatcher, traces,\n getIsVisibleForCanvas: chrome.getIsVisible, getRuleCtx: chrome.getRuleCtx,\n targetScale, handleHitRadius: overlay.resizeHandles.hitRadiusPx,\n edgeHandles: overlay.resizeHandles.edges,\n rotationBadge: overlay.rotationBadge, chromeAffordancesRef: overlay.chromeAffordancesRef,\n onDoubleClick, onClick, longPress: props.longPress,\n });\n useToolKeybindings({\n internalTools: p.tools.internal,\n toolsTakeover: p.tools.takeover ?? undefined,\n surface: p.tools.surface,\n enableKeybindings,\n modes: props.modes,\n canvasApi: canvas.ready ? canvas.apiRef.current : null,\n versionCheck: props.versionCheck,\n });\n useTestHook({\n getScene: () => scene as never,\n getSelectionIds: () => (selection.current as readonly string[] | undefined) ?? [],\n getView: () => viewState.viewRef.current,\n getActiveToolId: () => p.tools.tools.active ?? null,\n probes: root.probes,\n });\n\n // Mounted only when passed: an empty default registered with the deps above would land\n // after, and over, a dep one of these registered (child effects run first). Absent\n // `geometryProjection` leaves the dep undefined.\n return (\n <>\n {selectTool?.resize\n ? <ResizePolicyRegistrar options={selectTool.resize as UseResizeOptions<unknown>} />\n : null}\n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
|
|
@@ -4,6 +4,8 @@ import { toolIdsOf, toolSet } from "@weasel-js/routing";
|
|
|
4
4
|
//#region src/canvas/SceneCanvas/builtinToolSets.ts
|
|
5
5
|
/** The selection tools: click and marquee, and the lasso. */
|
|
6
6
|
var SELECT_TOOLS = toolSet("select", ["select", ...kitShapeKindsOf("select")]);
|
|
7
|
+
/** Path edit's anchor editing. Path-edit tools of other packages join this group. */
|
|
8
|
+
var ANCHOR_TOOLS = toolSet("path-edit", ["anchors"]);
|
|
7
9
|
/** The view tools. */
|
|
8
10
|
var VIEW_TOOLS = toolSet("view", ["hand"]);
|
|
9
11
|
/** The tools that drag out a closed or open primitive. */
|
|
@@ -14,10 +16,11 @@ var DRAW_TOOLS = toolSet("draw", kitShapeKindsOf("draw"));
|
|
|
14
16
|
var TYPE_TOOLS = toolSet("type", kitShapeKindsOf("type"));
|
|
15
17
|
/** The tools that cut the page itself. */
|
|
16
18
|
var PAGE_TOOLS = toolSet("page", ["slice"]);
|
|
17
|
-
/** The built-in tool sets in palette order: selection, then navigation, then
|
|
18
|
-
* things. Each set is named for the presentation group its tools sit in. */
|
|
19
|
+
/** The built-in tool sets in palette order: selection and anchor editing, then navigation, then
|
|
20
|
+
* the tools that make things. Each set is named for the presentation group its tools sit in. */
|
|
19
21
|
var BUILTIN_TOOL_GROUPS = [
|
|
20
22
|
SELECT_TOOLS,
|
|
23
|
+
ANCHOR_TOOLS,
|
|
21
24
|
VIEW_TOOLS,
|
|
22
25
|
SHAPE_TOOLS,
|
|
23
26
|
DRAW_TOOLS,
|
|
@@ -34,5 +37,5 @@ var BUILTIN_TOOLS = toolSet("builtin", [...BUILTIN_TOOL_GROUPS, ...KIT_SHAPE_KIN
|
|
|
34
37
|
var BUILTIN_TOOL_IDS = toolIdsOf([BUILTIN_TOOLS]);
|
|
35
38
|
|
|
36
39
|
//#endregion
|
|
37
|
-
export { BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS };
|
|
40
|
+
export { ANCHOR_TOOLS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS };
|
|
38
41
|
//# sourceMappingURL=builtinToolSets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinToolSets.js","names":[],"sources":["../../../src/canvas/SceneCanvas/builtinToolSets.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS, kitShapeKindsOf, type BuiltinShapeToolId } from 'core/shapeKinds';\nimport { toolIdsOf, toolSet, type ToolSet } from '@weasel-js/routing';\n\n/** Built-in tool ids SceneCanvas knows how to mount, through `defaultTools` or a preset. */\nexport type BuiltinToolId = 'select' | 'hand' | BuiltinShapeToolId | 'slice';\n\n/** The selection tools: click and marquee, and the lasso. */\nexport const SELECT_TOOLS: ToolSet<BuiltinToolId> = toolSet('select', ['select', ...kitShapeKindsOf('select')]);\n/** The view tools. */\nexport const VIEW_TOOLS: ToolSet<BuiltinToolId> = toolSet('view', ['hand']);\n/** The tools that drag out a closed or open primitive. */\nexport const SHAPE_TOOLS: ToolSet<BuiltinToolId> = toolSet('shape', kitShapeKindsOf('shape'));\n/** The freehand and bezier path tools. */\nexport const DRAW_TOOLS: ToolSet<BuiltinToolId> = toolSet('draw', kitShapeKindsOf('draw'));\n/** The text tools: text and the sticky note. */\nexport const TYPE_TOOLS: ToolSet<BuiltinToolId> = toolSet('type', kitShapeKindsOf('type'));\n/** The tools that cut the page itself. */\nexport const PAGE_TOOLS: ToolSet<BuiltinToolId> = toolSet('page', ['slice']);\n\n/** The built-in tool sets in palette order: selection, then navigation, then the tools that make
|
|
1
|
+
{"version":3,"file":"builtinToolSets.js","names":[],"sources":["../../../src/canvas/SceneCanvas/builtinToolSets.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS, kitShapeKindsOf, type BuiltinShapeToolId } from 'core/shapeKinds';\nimport { toolIdsOf, toolSet, type ToolSet } from '@weasel-js/routing';\n\n/** Built-in tool ids SceneCanvas knows how to mount, through `defaultTools` or a preset. */\nexport type BuiltinToolId = 'select' | 'anchors' | 'hand' | BuiltinShapeToolId | 'slice';\n\n/** The selection tools: click and marquee, and the lasso. */\nexport const SELECT_TOOLS: ToolSet<BuiltinToolId> = toolSet('select', ['select', ...kitShapeKindsOf('select')]);\n/** Path edit's anchor editing. Path-edit tools of other packages join this group. */\nexport const ANCHOR_TOOLS: ToolSet<BuiltinToolId> = toolSet('path-edit', ['anchors']);\n/** The view tools. */\nexport const VIEW_TOOLS: ToolSet<BuiltinToolId> = toolSet('view', ['hand']);\n/** The tools that drag out a closed or open primitive. */\nexport const SHAPE_TOOLS: ToolSet<BuiltinToolId> = toolSet('shape', kitShapeKindsOf('shape'));\n/** The freehand and bezier path tools. */\nexport const DRAW_TOOLS: ToolSet<BuiltinToolId> = toolSet('draw', kitShapeKindsOf('draw'));\n/** The text tools: text and the sticky note. */\nexport const TYPE_TOOLS: ToolSet<BuiltinToolId> = toolSet('type', kitShapeKindsOf('type'));\n/** The tools that cut the page itself. */\nexport const PAGE_TOOLS: ToolSet<BuiltinToolId> = toolSet('page', ['slice']);\n\n/** The built-in tool sets in palette order: selection and anchor editing, then navigation, then\n * the tools that make things. Each set is named for the presentation group its tools sit in. */\nexport const BUILTIN_TOOL_GROUPS: readonly ToolSet<BuiltinToolId>[] = [\n SELECT_TOOLS, ANCHOR_TOOLS, VIEW_TOOLS, SHAPE_TOOLS, DRAW_TOOLS, TYPE_TOOLS, PAGE_TOOLS,\n];\n\n/** The natural order of palette groups, which `ToolPalette` follows unless given its own. */\nexport const TOOL_GROUP_ORDER: readonly string[] = BUILTIN_TOOL_GROUPS.map((set) => set.id);\n\n/** Every built-in tool, in palette order: {@link BUILTIN_TOOL_GROUPS} one after another, then any\n * shape kind in no family. */\nexport const BUILTIN_TOOLS: ToolSet<BuiltinToolId> = toolSet('builtin', [...BUILTIN_TOOL_GROUPS, ...KIT_SHAPE_KINDS]);\n\n/** Every built-in tool id, in palette order: {@link BUILTIN_TOOLS} opened. A palette orders the\n * tools within each group by it. */\nexport const BUILTIN_TOOL_IDS: readonly BuiltinToolId[] = toolIdsOf([BUILTIN_TOOLS]);\n"],"mappings":";;;;;AAOA,IAAa,eAAuC,QAAQ,UAAU,CAAC,UAAU,GAAG,gBAAgB,QAAQ,CAAC,CAAC;;AAE9G,IAAa,eAAuC,QAAQ,aAAa,CAAC,SAAS,CAAC;;AAEpF,IAAa,aAAqC,QAAQ,QAAQ,CAAC,MAAM,CAAC;;AAE1E,IAAa,cAAsC,QAAQ,SAAS,gBAAgB,OAAO,CAAC;;AAE5F,IAAa,aAAqC,QAAQ,QAAQ,gBAAgB,MAAM,CAAC;;AAEzF,IAAa,aAAqC,QAAQ,QAAQ,gBAAgB,MAAM,CAAC;;AAEzF,IAAa,aAAqC,QAAQ,QAAQ,CAAC,OAAO,CAAC;;;AAI3E,IAAa,sBAAyD;CACpE;CAAc;CAAc;CAAY;CAAa;CAAY;CAAY;AAC/E;;AAGA,IAAa,mBAAsC,oBAAoB,KAAK,QAAQ,IAAI,EAAE;;;AAI1F,IAAa,gBAAwC,QAAQ,WAAW,CAAC,GAAG,qBAAqB,GAAG,eAAe,CAAC;;;AAIpH,IAAa,mBAA6C,UAAU,CAAC,aAAa,CAAC"}
|
|
@@ -6,8 +6,8 @@ import { SHAPE_GENERATOR_SECTIONS } from "./shapeGeneratorProperties.js";
|
|
|
6
6
|
import { poseLinearOf } from "@weasel-js/geom";
|
|
7
7
|
import { dashForStrokeStyle, strokeDashStyleOf } from "@weasel-js/paint";
|
|
8
8
|
import { listMarkers, markerGeneration } from "@weasel-js/stroke";
|
|
9
|
-
import { ANGLE_RADIANS, decimal } from "@weasel-js/quantity";
|
|
10
9
|
import { prefUnit } from "@weasel-js/prefs";
|
|
10
|
+
import { ANGLE_RADIANS, decimal } from "@weasel-js/quantity";
|
|
11
11
|
|
|
12
12
|
//#region src/canvas/SceneCanvas/defaultNodeProperties.ts
|
|
13
13
|
/** Radians-stored / degrees-shown conversion for `pose.rotation` leaves.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { exitPathEditToolAction } from "../../../interactions/actions/defaults/pathEditTools.js";
|
|
2
1
|
import { editAnchorsAction } from "../../../interactions/actions/edit-anchors/action.js";
|
|
3
2
|
import { cutPathAtAnchorAction, deleteAnchorsAction, marqueeAnchorsAction, nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction, nudgeAnchorsUpAction, selectAnchorAction } from "../../../interactions/actions/defaults/anchorEditing.js";
|
|
4
3
|
import { makeHandlesSymmetricAction, retractHandlesAction } from "../../../interactions/actions/defaults/anchorHandles.js";
|
|
@@ -18,8 +17,8 @@ import { joinPathsAction, snipAtCrossingsAction } from "../../../interactions/ac
|
|
|
18
17
|
//#region src/canvas/SceneCanvas/presets/paths.ts
|
|
19
18
|
/**
|
|
20
19
|
* The path-edit keys that share a key with a node-level action: anchor nudging
|
|
21
|
-
* and deleting, and Escape out of path edit
|
|
22
|
-
*
|
|
20
|
+
* and deleting, and Escape out of path edit. Each is tried ahead of its twin,
|
|
21
|
+
* which is enabled whenever anything is selected.
|
|
23
22
|
*/
|
|
24
23
|
var anchorKeysPreset = {
|
|
25
24
|
id: "anchorKeys",
|
|
@@ -35,8 +34,7 @@ var anchorKeysPreset = {
|
|
|
35
34
|
nudgeAnchorsLeftAction,
|
|
36
35
|
nudgeAnchorsRightAction,
|
|
37
36
|
deleteAnchorsAction,
|
|
38
|
-
exitPathEditAction
|
|
39
|
-
exitPathEditToolAction
|
|
37
|
+
exitPathEditAction
|
|
40
38
|
]
|
|
41
39
|
};
|
|
42
40
|
/** The pathfinder booleans, and the live boolean group. */
|
|
@@ -61,10 +59,12 @@ var outlinesPreset = {
|
|
|
61
59
|
label: "Outlines",
|
|
62
60
|
actions: [createOutlinesAction, outlineStrokeAction]
|
|
63
61
|
};
|
|
64
|
-
/** Entering path edit, and editing anchors, handles, and segments in it
|
|
62
|
+
/** Entering path edit, and editing anchors, handles, and segments in it, with
|
|
63
|
+
* the `anchors` tool path edit starts on. */
|
|
65
64
|
var pathEditPreset = {
|
|
66
65
|
id: "pathEdit",
|
|
67
66
|
label: "Path edit",
|
|
67
|
+
tools: ["anchors"],
|
|
68
68
|
actions: [
|
|
69
69
|
editAnchorsAction,
|
|
70
70
|
enterPathEditAction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","names":[],"sources":["../../../../src/canvas/SceneCanvas/presets/paths.ts"],"sourcesContent":["import {\n cutPathAtAnchorAction, deleteAnchorsAction, marqueeAnchorsAction,\n nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction, nudgeAnchorsUpAction,\n selectAnchorAction,\n} from 'interactions/actions/defaults/anchorEditing';\nimport { makeHandlesSymmetricAction, retractHandlesAction } from 'interactions/actions/defaults/anchorHandles';\nimport { setAnchorFieldAction } from 'interactions/actions/defaults/anchorFields';\nimport { averageAnchorsAction, joinAnchorsAction } from 'interactions/actions/defaults/anchorJoin';\nimport { bendSegmentAction } from 'interactions/actions/defaults/bendSegment';\nimport { enterPathEditAction } from 'interactions/actions/defaults/enterPathEdit';\nimport { exitPathEditAction } from 'interactions/actions/defaults/exitPathEdit';\nimport { editAnchorsAction } from 'interactions/actions/edit-anchors/action';\nimport { insertPathAnchorAction } from 'interactions/actions/defaults/insertPathAnchor';\nimport {
|
|
1
|
+
{"version":3,"file":"paths.js","names":[],"sources":["../../../../src/canvas/SceneCanvas/presets/paths.ts"],"sourcesContent":["import {\n cutPathAtAnchorAction, deleteAnchorsAction, marqueeAnchorsAction,\n nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction, nudgeAnchorsUpAction,\n selectAnchorAction,\n} from 'interactions/actions/defaults/anchorEditing';\nimport { makeHandlesSymmetricAction, retractHandlesAction } from 'interactions/actions/defaults/anchorHandles';\nimport { setAnchorFieldAction } from 'interactions/actions/defaults/anchorFields';\nimport { averageAnchorsAction, joinAnchorsAction } from 'interactions/actions/defaults/anchorJoin';\nimport { bendSegmentAction } from 'interactions/actions/defaults/bendSegment';\nimport { enterPathEditAction } from 'interactions/actions/defaults/enterPathEdit';\nimport { exitPathEditAction } from 'interactions/actions/defaults/exitPathEdit';\nimport { editAnchorsAction } from 'interactions/actions/edit-anchors/action';\nimport { insertPathAnchorAction } from 'interactions/actions/defaults/insertPathAnchor';\nimport {\n pathfinderCropAction, pathfinderDivideAction, pathfinderExcludeAction, pathfinderIntersectAction,\n pathfinderMergeAction, pathfinderSubtractAction, pathfinderTrimAction, pathfinderUnionAction,\n} from 'interactions/actions/booleans/action';\nimport { makeBooleanGroupAction } from 'interactions/actions/booleans/booleanGroupAction';\nimport { createOutlinesAction } from 'interactions/actions/outlines/createOutlinesAction';\nimport { outlineStrokeAction } from 'interactions/actions/outlines/outlineStrokeAction';\nimport {\n joinPathsAction, offsetPathAction, simplifyPathAction, snipAtCrossingsAction,\n} from 'interactions/actions/pathCommands';\nimport type { FeaturePreset } from '../features';\n\n/**\n * The path-edit keys that share a key with a node-level action: anchor nudging\n * and deleting, and Escape out of path edit. Each is tried ahead of its twin,\n * which is enabled whenever anything is selected.\n */\nexport const anchorKeysPreset: FeaturePreset = {\n id: 'anchorKeys',\n label: 'Anchor keys',\n refines: ['nudge', 'delete', 'escape'],\n actions: [\n nudgeAnchorsUpAction, nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction,\n deleteAnchorsAction, exitPathEditAction,\n ],\n};\n\n/** The pathfinder booleans, and the live boolean group. */\nexport const pathfinderPreset: FeaturePreset = {\n id: 'pathfinder',\n label: 'Pathfinder',\n actions: [\n pathfinderUnionAction, pathfinderSubtractAction, pathfinderIntersectAction, pathfinderExcludeAction,\n pathfinderDivideAction, pathfinderCropAction, pathfinderTrimAction, pathfinderMergeAction,\n makeBooleanGroupAction,\n ],\n};\n\n/** Text and strokes to paths. */\nexport const outlinesPreset: FeaturePreset = {\n id: 'outlines', label: 'Outlines', actions: [createOutlinesAction, outlineStrokeAction],\n};\n\n/** Entering path edit, and editing anchors, handles, and segments in it, with\n * the `anchors` tool path edit starts on. */\nexport const pathEditPreset: FeaturePreset = {\n id: 'pathEdit',\n label: 'Path edit',\n tools: ['anchors'],\n actions: [\n editAnchorsAction, enterPathEditAction, insertPathAnchorAction, bendSegmentAction, cutPathAtAnchorAction,\n retractHandlesAction, makeHandlesSymmetricAction, averageAnchorsAction, joinAnchorsAction, setAnchorFieldAction,\n marqueeAnchorsAction, selectAnchorAction,\n ],\n};\n\n/** Simplify, offset, snip at crossings, and join paths. */\nexport const pathCommandsPreset: FeaturePreset = {\n id: 'pathCommands',\n label: 'Path commands',\n actions: [simplifyPathAction, offsetPathAction, snipAtCrossingsAction, joinPathsAction],\n};\n\n/** Pathfinder operations, path-edit entry, and anchor editing. */\nexport const pathsPreset: FeaturePreset = {\n id: 'paths',\n label: 'Paths',\n includes: [anchorKeysPreset, pathfinderPreset, outlinesPreset, pathEditPreset, pathCommandsPreset],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,mBAAkC;CAC7C,IAAI;CACJ,OAAO;CACP,SAAS;EAAC;EAAS;EAAU;CAAQ;CACrC,SAAS;EACP;EAAsB;EAAwB;EAAwB;EACtE;EAAqB;CACvB;AACF;;AAGA,IAAa,mBAAkC;CAC7C,IAAI;CACJ,OAAO;CACP,SAAS;EACP;EAAuB;EAA0B;EAA2B;EAC5E;EAAwB;EAAsB;EAAsB;EACpE;CACF;AACF;;AAGA,IAAa,iBAAgC;CAC3C,IAAI;CAAY,OAAO;CAAY,SAAS,CAAC,sBAAsB,mBAAmB;AACxF;;;AAIA,IAAa,iBAAgC;CAC3C,IAAI;CACJ,OAAO;CACP,OAAO,CAAC,SAAS;CACjB,SAAS;EACP;EAAmB;EAAqB;EAAwB;EAAmB;EACnF;EAAsB;EAA4B;EAAsB;EAAmB;EAC3F;EAAsB;CACxB;AACF;;AAGA,IAAa,qBAAoC;CAC/C,IAAI;CACJ,OAAO;CACP,SAAS;EAAC;EAAoB;EAAkB;EAAuB;CAAe;AACxF;;AAGA,IAAa,cAA6B;CACxC,IAAI;CACJ,OAAO;CACP,UAAU;EAAC;EAAkB;EAAkB;EAAgB;EAAgB;CAAkB;AACnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapeGeneratorProperties.js","names":[],"sources":["../../../src/canvas/SceneCanvas/shapeGeneratorProperties.ts"],"sourcesContent":["import type { PrefSection } from '@weasel-js/prefs';\nimport { decimal } from '@weasel-js/quantity';\nimport { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE } from 'domains/paths/shapeGenerator';\n\nconst WHOLE = decimal({ maxPlaces: 2, grouping: false });\n\n/**\n * The rows that edit a polygon's or a star's `data.generator`, each shown only\n * on a node holding that kind's generator. A write to one regenerates the\n * shape through the entry's `settle` (`settleShapeGenerator`).\n */\nexport const SHAPE_GENERATOR_SECTIONS: Record<string, PrefSection> = {\n polygon: {\n name: 'Polygon',\n showIf: { path: 'data.generator.sides' },\n members: {\n 'data.generator.sides': {\n kind: 'number', display: WHOLE, name: 'Sides', description: 'Number of sides.',\n default: 6, min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1,\n },\n },\n },\n star: {\n name: 'Star',\n showIf: { path: 'data.generator.points' },\n members: {\n 'data.generator.points': {\n kind: 'number', display: WHOLE, name: 'Points', description: 'Number of points.',\n default: 5, min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1,\n },\n 'data.generator.innerRadiusRatio': {\n kind: 'number', name: 'Inner', description: 'Inner radius as a fraction of the outer one.',\n default: 0.5, min: STAR_RATIO_RANGE.min, max: STAR_RATIO_RANGE.max, step: 0.01, control: 'slider',\n },\n },\n },\n};\n"],"mappings":";;;;AAIA,IAAM,QAAQ,QAAQ;CAAE,WAAW;CAAG,UAAU;AAAM,CAAC;;;;;;AAOvD,IAAa,2BAAwD;CACnE,SAAS;EACP,MAAM;EACN,QAAQ,EAAE,MAAM,uBAAuB;EACvC,SAAS,EACP,wBAAwB;GACtB,MAAM;GAAU,SAAS;GAAO,MAAM;GAAS,aAAa;GAC5D,SAAS;GAAG,KAAK,kBAAkB;GAAK,KAAK,kBAAkB;GAAK,MAAM;EAC5E,EACF;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ,EAAE,MAAM,wBAAwB;EACxC,SAAS;GACP,yBAAyB;IACvB,MAAM;IAAU,SAAS;IAAO,MAAM;IAAU,aAAa;IAC7D,SAAS;IAAG,KAAK,kBAAkB;IAAK,KAAK,kBAAkB;IAAK,MAAM;GAC5E;GACA,mCAAmC;IACjC,MAAM;IAAU,MAAM;
|
|
1
|
+
{"version":3,"file":"shapeGeneratorProperties.js","names":[],"sources":["../../../src/canvas/SceneCanvas/shapeGeneratorProperties.ts"],"sourcesContent":["import type { PrefSection } from '@weasel-js/prefs';\nimport { decimal } from '@weasel-js/quantity';\nimport { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE } from 'domains/paths/shapeGenerator';\n\nconst WHOLE = decimal({ maxPlaces: 2, grouping: false });\n\n/**\n * The rows that edit a polygon's or a star's `data.generator`, each shown only\n * on a node holding that kind's generator. A write to one regenerates the\n * shape through the entry's `settle` (`settleShapeGenerator`).\n */\nexport const SHAPE_GENERATOR_SECTIONS: Record<string, PrefSection> = {\n polygon: {\n name: 'Polygon',\n showIf: { path: 'data.generator.sides' },\n members: {\n 'data.generator.sides': {\n kind: 'number', display: WHOLE, name: 'Sides', description: 'Number of sides.',\n default: 6, min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1,\n },\n },\n },\n star: {\n name: 'Star',\n showIf: { path: 'data.generator.points' },\n members: {\n 'data.generator.points': {\n kind: 'number', display: WHOLE, name: 'Points', description: 'Number of points.',\n default: 5, min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1,\n },\n 'data.generator.innerRadiusRatio': {\n kind: 'number', name: 'Inner radius', description: 'Inner radius as a fraction of the outer one.',\n default: 0.5, min: STAR_RATIO_RANGE.min, max: STAR_RATIO_RANGE.max, step: 0.01, control: 'slider',\n },\n },\n },\n};\n"],"mappings":";;;;AAIA,IAAM,QAAQ,QAAQ;CAAE,WAAW;CAAG,UAAU;AAAM,CAAC;;;;;;AAOvD,IAAa,2BAAwD;CACnE,SAAS;EACP,MAAM;EACN,QAAQ,EAAE,MAAM,uBAAuB;EACvC,SAAS,EACP,wBAAwB;GACtB,MAAM;GAAU,SAAS;GAAO,MAAM;GAAS,aAAa;GAC5D,SAAS;GAAG,KAAK,kBAAkB;GAAK,KAAK,kBAAkB;GAAK,MAAM;EAC5E,EACF;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ,EAAE,MAAM,wBAAwB;EACxC,SAAS;GACP,yBAAyB;IACvB,MAAM;IAAU,SAAS;IAAO,MAAM;IAAU,aAAa;IAC7D,SAAS;IAAG,KAAK,kBAAkB;IAAK,KAAK,kBAAkB;IAAK,MAAM;GAC5E;GACA,mCAAmC;IACjC,MAAM;IAAU,MAAM;IAAgB,aAAa;IACnD,SAAS;IAAK,KAAK,iBAAiB;IAAK,KAAK,iBAAiB;IAAK,MAAM;IAAM,SAAS;GAC3F;EACF;CACF;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useHandTool } from "../../tools/builtin/hand/useHandTool.js";
|
|
2
|
+
import { anchorsTool } from "../../tools/builtin/anchors/anchorsTool.js";
|
|
2
3
|
import { useSliceTool } from "../../tools/builtin/slice/useSliceTool.js";
|
|
3
4
|
import { resolveToolRegistry } from "./toolRegistry.js";
|
|
4
5
|
import { useBuiltinShapeTools } from "./useBuiltinShapeTools.js";
|
|
@@ -14,6 +15,7 @@ function useBuiltinTools(args) {
|
|
|
14
15
|
return resolveToolRegistry({
|
|
15
16
|
builtins: {
|
|
16
17
|
select,
|
|
18
|
+
anchors: anchorsTool,
|
|
17
19
|
hand,
|
|
18
20
|
...shapes,
|
|
19
21
|
slice
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuiltinTools.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useBuiltinTools.ts"],"sourcesContent":["import type { InertiaConfig } from 'core/viewport/useDecayLoop';\nimport { useHandTool } from 'tools/builtin/hand';\nimport { useSliceTool } from 'tools/builtin/slice';\nimport type { Tool } from 'tools/overlayBinding';\nimport type { EnabledPresets } from './features';\nimport type { BuiltinToolId } from './props';\nimport type { ToolEntry } from '@weasel-js/routing';\nimport { resolveToolRegistry, type ToolsPatch } from './toolRegistry';\nimport { useBuiltinShapeTools, type BuiltinToolOptions } from './useBuiltinShapeTools';\n\nexport interface UseBuiltinToolsArgs {\n /** The canvas's select tool, which is built from its scene and pickers. */\n select: Tool;\n enabled: EnabledPresets;\n defaultTools?: readonly ToolEntry<BuiltinToolId>[];\n patch: ToolsPatch | null;\n toolOptions?: BuiltinToolOptions;\n /** `viewport.inertia`, which is the hand tool's. */\n inertia?: boolean | InertiaConfig;\n}\n\n/** The registry of tools `<SceneCanvas>` mounts for itself. Every built-in's\n * hook runs on every render; `resolveToolRegistry` decides which are in. */\nexport function useBuiltinTools(args: UseBuiltinToolsArgs): Record<string, Tool> {\n const { select, enabled, defaultTools, patch, toolOptions, inertia } = args;\n const hand = useHandTool({ inertia });\n const shapes = useBuiltinShapeTools({ options: toolOptions });\n const slice = useSliceTool(toolOptions?.slice);\n return resolveToolRegistry({\n builtins: { select, hand, ...shapes, slice },\n defaultTools,\n enabled,\n patch,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBuiltinTools.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useBuiltinTools.ts"],"sourcesContent":["import type { InertiaConfig } from 'core/viewport/useDecayLoop';\nimport { anchorsTool } from 'tools/builtin/anchors';\nimport { useHandTool } from 'tools/builtin/hand';\nimport { useSliceTool } from 'tools/builtin/slice';\nimport type { Tool } from 'tools/overlayBinding';\nimport type { EnabledPresets } from './features';\nimport type { BuiltinToolId } from './props';\nimport type { ToolEntry } from '@weasel-js/routing';\nimport { resolveToolRegistry, type ToolsPatch } from './toolRegistry';\nimport { useBuiltinShapeTools, type BuiltinToolOptions } from './useBuiltinShapeTools';\n\nexport interface UseBuiltinToolsArgs {\n /** The canvas's select tool, which is built from its scene and pickers. */\n select: Tool;\n enabled: EnabledPresets;\n defaultTools?: readonly ToolEntry<BuiltinToolId>[];\n patch: ToolsPatch | null;\n toolOptions?: BuiltinToolOptions;\n /** `viewport.inertia`, which is the hand tool's. */\n inertia?: boolean | InertiaConfig;\n}\n\n/** The registry of tools `<SceneCanvas>` mounts for itself. Every built-in's\n * hook runs on every render; `resolveToolRegistry` decides which are in. */\nexport function useBuiltinTools(args: UseBuiltinToolsArgs): Record<string, Tool> {\n const { select, enabled, defaultTools, patch, toolOptions, inertia } = args;\n const hand = useHandTool({ inertia });\n const shapes = useBuiltinShapeTools({ options: toolOptions });\n const slice = useSliceTool(toolOptions?.slice);\n return resolveToolRegistry({\n builtins: { select, anchors: anchorsTool, hand, ...shapes, slice },\n defaultTools,\n enabled,\n patch,\n });\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,gBAAgB,MAAiD;CAC/E,MAAM,EAAE,QAAQ,SAAS,cAAc,OAAO,aAAa,YAAY;CACvE,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;CACpC,MAAM,SAAS,qBAAqB,EAAE,SAAS,YAAY,CAAC;CAC5D,MAAM,QAAQ,aAAa,aAAa,KAAK;CAC7C,OAAO,oBAAoB;EACzB,UAAU;GAAE;GAAQ,SAAS;GAAa;GAAM,GAAG;GAAQ;EAAM;EACjE;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useToolOptionTunings } from "../../tools/toolOptions.js";
|
|
1
2
|
import { checkRequirements } from "../kitRequirements.js";
|
|
2
3
|
import { useContributionFrameHooks } from "./contributionFrameHooks.js";
|
|
3
4
|
import { useEffect, useRef } from "react";
|
|
@@ -94,6 +95,7 @@ function useContributionRoles(tools, api, versionCheck = "warn", surface = NO_SU
|
|
|
94
95
|
toolRegistry,
|
|
95
96
|
ambient
|
|
96
97
|
]);
|
|
98
|
+
useToolOptionTunings(registry, toolRegistry);
|
|
97
99
|
const menuHost = useMenuHost();
|
|
98
100
|
useEffect(() => {
|
|
99
101
|
if (!menuHost) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContributionRoles.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useContributionRoles.ts"],"sourcesContent":["/**\n * `useContributionRoles` — installs the roles of every entry in the tools\n * registry that a surface owns rather than the dispatcher: its actions into the\n * `<ActionsProvider>`, its deps into the dep registry, and its `attach` against\n * the mounted canvas. Views are the fourth such role; `<SceneCanvas>` renders\n * those itself, because a view is a component.\n *\n * Tool hooks run wherever the consumer calls them, which may be outside any\n * registry. Declaring roles on the entry and installing them from in here keeps\n * the tool hook callable from anywhere.\n */\nimport { useEffect, useRef } from 'react';\nimport { useActionsRegistry, useMenuHost, useOffhandAction, useOptionalDepRegistry } from '@weasel-js/routing/react';\nimport type { DepRegistry } from '@weasel-js/routing/react';\nimport type { DepName } from 'interactions/actions/depSchema';\nimport type { ToolsApi } from '../../tools/overlayBinding';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { SurfaceContribution } from '../surfaceContribution';\nimport { checkRequirements, type RequirementMismatch } from '../kitRequirements';\nimport { useContributionFrameHooks } from './contributionFrameHooks';\nimport { isDev } from '@weasel-js/react';\n\n/** How a surface treats an entry whose `requires` the running kit does not\n * meet: warn in development (the default), throw, or not check. */\nexport type VersionCheck = 'warn' | 'strict' | 'off';\n\nconst NO_DEPS = { get: () => undefined };\nconst warnedRequirements = new WeakSet<object>();\n\nfunction describeMismatch(m: RequirementMismatch): string {\n switch (m.reason) {\n case 'unsatisfied': return `${m.package} ${m.range} (running ${m.running})`;\n case 'invalid-range': return `${m.package} \"${m.range}\", which is not a range this check reads`;\n case 'unknown-package': return `${m.package} ${m.range}, but ${m.package} reports no version`;\n }\n}\n\nfunction checkEntryRequirements(entries: readonly SurfaceContribution[], mode: VersionCheck): void {\n if (mode === 'off') return;\n for (const entry of entries) {\n const requires = entry.requires;\n if (!requires) continue;\n if (mode === 'warn' && warnedRequirements.has(requires)) continue;\n const mismatches = checkRequirements(requires);\n if (mismatches.length === 0) continue;\n const message = `[weasel] contribution \"${entry.id}\" requires ${mismatches.map(describeMismatch).join('; ')}.`;\n if (mode === 'strict') throw new Error(message);\n warnedRequirements.add(requires);\n console.warn(message);\n }\n}\n\n/** Every entry the registry holds, registry and ambient alike. */\nexport function contributionEntries(tools: Pick<ToolsApi, 'registry' | 'ambient'>): SurfaceContribution[] {\n return [...Object.values(tools.registry), ...tools.ambient] as SurfaceContribution[];\n}\n\n/**\n * Keep one installation per key alive: install keys that appeared, tear down\n * keys that went. Keys are role objects the consumer owns, so an entry the\n * host re-wraps every render — `useTools` restates eligibility on a copy —\n * still installs once.\n */\nfunction useKeyedInstall(\n items: ReadonlyMap<object, () => () => void>,\n): void {\n const live = useRef(new Map<object, () => void>());\n useEffect(() => {\n for (const [key, teardown] of live.current) {\n if (items.has(key)) continue;\n teardown();\n live.current.delete(key);\n }\n for (const [key, install] of items) {\n if (live.current.has(key)) continue;\n live.current.set(key, install());\n }\n });\n useEffect(() => () => {\n for (const teardown of live.current.values()) teardown();\n live.current.clear();\n }, []);\n}\n\nconst NO_SURFACE: readonly SurfaceContribution[] = [];\n\n/**\n * `surface` is the canvas's own entries installed beside a takeover, which the\n * takeover's `ToolsApi` does not hold: their deps, `watch`, `attach`, frame\n * hooks and overlay install here, the overlay as a registered layer since no\n * tool set lists it. Their actions are the canvas's standard actions, so they\n * are not registered again.\n */\nexport function useContributionRoles(\n tools: ToolsApi,\n api: CanvasExtensionApi | null,\n versionCheck: VersionCheck = 'warn',\n surface: readonly SurfaceContribution[] = NO_SURFACE,\n): void {\n const registry = useActionsRegistry();\n const depRegistry = useOptionalDepRegistry();\n const { registry: toolRegistry, ambient } = tools;\n\n useEffect(() => {\n if (!registry) return;\n const unregisters: Array<() => void> = [];\n // Ambient entries included: an always-on entry owns actions its own\n // bindings reference exactly as a registry tool does, and leaving them out\n // gives the same silent failure this hook exists to prevent — a binding\n // pointing at an id nothing registered.\n for (const entry of contributionEntries({ registry: toolRegistry, ambient })) {\n for (const action of entry.actions ?? []) {\n unregisters.push(registry.register(action));\n }\n }\n return () => { for (const u of unregisters) u(); };\n }, [registry, toolRegistry, ambient]);\n\n const menuHost = useMenuHost();\n useEffect(() => {\n if (!menuHost) return;\n const releases: Array<() => void> = [];\n for (const [id, entry] of Object.entries(toolRegistry)) {\n for (const def of (entry as SurfaceContribution).menus ?? []) releases.push(menuHost.define(def, id));\n }\n for (const entry of ambient) {\n for (const def of (entry as SurfaceContribution).menus ?? []) releases.push(menuHost.define(def, null));\n }\n return () => { for (const r of releases) r(); };\n }, [menuHost, toolRegistry, ambient]);\n\n const entries = [...contributionEntries(tools), ...surface];\n // Development only for a warning; a strict surface asked to be stopped, so\n // it throws in every build.\n if (versionCheck === 'strict' || (versionCheck === 'warn' && isDev())) {\n checkEntryRequirements(entries, versionCheck);\n }\n\n const reader = depRegistry ?? NO_DEPS;\n const installs = new Map<object, () => () => void>();\n for (const entry of entries) {\n const deps = entry.deps;\n if (deps && depRegistry) installs.set(deps, () => registerDeps(depRegistry, deps));\n const watch = entry.watch;\n if (watch && depRegistry) installs.set(watch, () => watch(() => depRegistry.changed?.()));\n const attach = entry.attach;\n if (attach && api) installs.set(attach, () => attach(api, reader));\n }\n for (const entry of surface) {\n const overlay = entry.overlay;\n if (!overlay || !api) continue;\n for (const layer of Array.isArray(overlay) ? overlay : [overlay]) installs.set(layer, () => api.registerLayer(layer));\n }\n useKeyedInstall(installs);\n useContributionFrameHooks(entries, api, reader);\n\n // Tool assembly runs above the provider too, so its own registration of\n // held-key engagement finds no registry unless the consumer mounted one.\n useOffhandAction(contributionEntries(tools));\n}\n\nfunction registerDeps(\n depRegistry: DepRegistry,\n deps: NonNullable<SurfaceContribution['deps']>,\n): () => void {\n const unregisters = (Object.keys(deps) as DepName[]).map((name) =>\n depRegistry.register(name, deps[name] as never));\n return () => { for (const u of unregisters) u(); };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAM,UAAU,EAAE,WAAW,OAAU;AACvC,IAAM,qCAAqB,IAAI,QAAgB;AAE/C,SAAS,iBAAiB,GAAgC;CACxD,QAAQ,EAAE,QAAV;EACE,KAAK,eAAe,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,MAAM,YAAY,EAAE,QAAQ;EACzE,KAAK,iBAAiB,OAAO,GAAG,EAAE,QAAQ,IAAI,EAAE,MAAM;EACtD,KAAK,mBAAmB,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,MAAM,QAAQ,EAAE,QAAQ;CAC3E;AACF;AAEA,SAAS,uBAAuB,SAAyC,MAA0B;CACjG,IAAI,SAAS,OAAO;CACpB,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,WAAW,MAAM;EACvB,IAAI,CAAC,UAAU;EACf,IAAI,SAAS,UAAU,mBAAmB,IAAI,QAAQ,GAAG;EACzD,MAAM,aAAa,kBAAkB,QAAQ;EAC7C,IAAI,WAAW,WAAW,GAAG;EAC7B,MAAM,UAAU,0BAA0B,MAAM,GAAG,aAAa,WAAW,IAAI,gBAAgB,CAAC,CAAC,KAAK,IAAI,EAAE;EAC5G,IAAI,SAAS,UAAU,MAAM,IAAI,MAAM,OAAO;EAC9C,mBAAmB,IAAI,QAAQ;EAC/B,QAAQ,KAAK,OAAO;CACtB;AACF;;AAGA,SAAgB,oBAAoB,OAAsE;CACxG,OAAO,C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MAAM,KAAK,aAAa,EAAE;CAAG;AACnD"}
|
|
1
|
+
{"version":3,"file":"useContributionRoles.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useContributionRoles.ts"],"sourcesContent":["/**\n * `useContributionRoles` — installs the roles of every entry in the tools\n * registry that a surface owns rather than the dispatcher: its actions into the\n * `<ActionsProvider>`, its deps into the dep registry, and its `attach` against\n * the mounted canvas. Views are the fourth such role; `<SceneCanvas>` renders\n * those itself, because a view is a component.\n *\n * Tool hooks run wherever the consumer calls them, which may be outside any\n * registry. Declaring roles on the entry and installing them from in here keeps\n * the tool hook callable from anywhere.\n */\nimport { useEffect, useRef } from 'react';\nimport { useActionsRegistry, useMenuHost, useOffhandAction, useOptionalDepRegistry } from '@weasel-js/routing/react';\nimport type { DepRegistry } from '@weasel-js/routing/react';\nimport type { DepName } from 'interactions/actions/depSchema';\nimport { useToolOptionTunings } from 'tools/toolOptions';\nimport type { ToolsApi } from '../../tools/overlayBinding';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { SurfaceContribution } from '../surfaceContribution';\nimport { checkRequirements, type RequirementMismatch } from '../kitRequirements';\nimport { useContributionFrameHooks } from './contributionFrameHooks';\nimport { isDev } from '@weasel-js/react';\n\n/** How a surface treats an entry whose `requires` the running kit does not\n * meet: warn in development (the default), throw, or not check. */\nexport type VersionCheck = 'warn' | 'strict' | 'off';\n\nconst NO_DEPS = { get: () => undefined };\nconst warnedRequirements = new WeakSet<object>();\n\nfunction describeMismatch(m: RequirementMismatch): string {\n switch (m.reason) {\n case 'unsatisfied': return `${m.package} ${m.range} (running ${m.running})`;\n case 'invalid-range': return `${m.package} \"${m.range}\", which is not a range this check reads`;\n case 'unknown-package': return `${m.package} ${m.range}, but ${m.package} reports no version`;\n }\n}\n\nfunction checkEntryRequirements(entries: readonly SurfaceContribution[], mode: VersionCheck): void {\n if (mode === 'off') return;\n for (const entry of entries) {\n const requires = entry.requires;\n if (!requires) continue;\n if (mode === 'warn' && warnedRequirements.has(requires)) continue;\n const mismatches = checkRequirements(requires);\n if (mismatches.length === 0) continue;\n const message = `[weasel] contribution \"${entry.id}\" requires ${mismatches.map(describeMismatch).join('; ')}.`;\n if (mode === 'strict') throw new Error(message);\n warnedRequirements.add(requires);\n console.warn(message);\n }\n}\n\n/** Every entry the registry holds, registry and ambient alike. */\nexport function contributionEntries(tools: Pick<ToolsApi, 'registry' | 'ambient'>): SurfaceContribution[] {\n return [...Object.values(tools.registry), ...tools.ambient] as SurfaceContribution[];\n}\n\n/**\n * Keep one installation per key alive: install keys that appeared, tear down\n * keys that went. Keys are role objects the consumer owns, so an entry the\n * host re-wraps every render — `useTools` restates eligibility on a copy —\n * still installs once.\n */\nfunction useKeyedInstall(\n items: ReadonlyMap<object, () => () => void>,\n): void {\n const live = useRef(new Map<object, () => void>());\n useEffect(() => {\n for (const [key, teardown] of live.current) {\n if (items.has(key)) continue;\n teardown();\n live.current.delete(key);\n }\n for (const [key, install] of items) {\n if (live.current.has(key)) continue;\n live.current.set(key, install());\n }\n });\n useEffect(() => () => {\n for (const teardown of live.current.values()) teardown();\n live.current.clear();\n }, []);\n}\n\nconst NO_SURFACE: readonly SurfaceContribution[] = [];\n\n/**\n * `surface` is the canvas's own entries installed beside a takeover, which the\n * takeover's `ToolsApi` does not hold: their deps, `watch`, `attach`, frame\n * hooks and overlay install here, the overlay as a registered layer since no\n * tool set lists it. Their actions are the canvas's standard actions, so they\n * are not registered again.\n */\nexport function useContributionRoles(\n tools: ToolsApi,\n api: CanvasExtensionApi | null,\n versionCheck: VersionCheck = 'warn',\n surface: readonly SurfaceContribution[] = NO_SURFACE,\n): void {\n const registry = useActionsRegistry();\n const depRegistry = useOptionalDepRegistry();\n const { registry: toolRegistry, ambient } = tools;\n\n useEffect(() => {\n if (!registry) return;\n const unregisters: Array<() => void> = [];\n // Ambient entries included: an always-on entry owns actions its own\n // bindings reference exactly as a registry tool does, and leaving them out\n // gives the same silent failure this hook exists to prevent — a binding\n // pointing at an id nothing registered.\n for (const entry of contributionEntries({ registry: toolRegistry, ambient })) {\n for (const action of entry.actions ?? []) {\n unregisters.push(registry.register(action));\n }\n }\n return () => { for (const u of unregisters) u(); };\n }, [registry, toolRegistry, ambient]);\n useToolOptionTunings(registry, toolRegistry);\n\n const menuHost = useMenuHost();\n useEffect(() => {\n if (!menuHost) return;\n const releases: Array<() => void> = [];\n for (const [id, entry] of Object.entries(toolRegistry)) {\n for (const def of (entry as SurfaceContribution).menus ?? []) releases.push(menuHost.define(def, id));\n }\n for (const entry of ambient) {\n for (const def of (entry as SurfaceContribution).menus ?? []) releases.push(menuHost.define(def, null));\n }\n return () => { for (const r of releases) r(); };\n }, [menuHost, toolRegistry, ambient]);\n\n const entries = [...contributionEntries(tools), ...surface];\n // Development only for a warning; a strict surface asked to be stopped, so\n // it throws in every build.\n if (versionCheck === 'strict' || (versionCheck === 'warn' && isDev())) {\n checkEntryRequirements(entries, versionCheck);\n }\n\n const reader = depRegistry ?? NO_DEPS;\n const installs = new Map<object, () => () => void>();\n for (const entry of entries) {\n const deps = entry.deps;\n if (deps && depRegistry) installs.set(deps, () => registerDeps(depRegistry, deps));\n const watch = entry.watch;\n if (watch && depRegistry) installs.set(watch, () => watch(() => depRegistry.changed?.()));\n const attach = entry.attach;\n if (attach && api) installs.set(attach, () => attach(api, reader));\n }\n for (const entry of surface) {\n const overlay = entry.overlay;\n if (!overlay || !api) continue;\n for (const layer of Array.isArray(overlay) ? overlay : [overlay]) installs.set(layer, () => api.registerLayer(layer));\n }\n useKeyedInstall(installs);\n useContributionFrameHooks(entries, api, reader);\n\n // Tool assembly runs above the provider too, so its own registration of\n // held-key engagement finds no registry unless the consumer mounted one.\n useOffhandAction(contributionEntries(tools));\n}\n\nfunction registerDeps(\n depRegistry: DepRegistry,\n deps: NonNullable<SurfaceContribution['deps']>,\n): () => void {\n const unregisters = (Object.keys(deps) as DepName[]).map((name) =>\n depRegistry.register(name, deps[name] as never));\n return () => { for (const u of unregisters) u(); };\n}\n"],"mappings":";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AAG,GAAG,OAAO;CAG1D,IAAI,iBAAiB,YAAa,iBAAiB,UAAU,MAAM,GACjE,uBAAuB,SAAS,YAAY;CAG9C,MAAM,SAAS,eAAe;CAC9B,MAAM,2BAAW,IAAI,IAA8B;CACnD,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,MAAM;EACnB,IAAI,QAAQ,aAAa,SAAS,IAAI,YAAY,aAAa,aAAa,IAAI,CAAC;EACjF,MAAM,QAAQ,MAAM;EACpB,IAAI,SAAS,aAAa,SAAS,IAAI,aAAa,YAAY,YAAY,UAAU,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM;EACrB,IAAI,UAAU,KAAK,SAAS,IAAI,cAAc,OAAO,KAAK,MAAM,CAAC;CACnE;CACA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,UAAU,MAAM;EACtB,IAAI,CAAC,WAAW,CAAC,KAAK;EACtB,KAAK,MAAM,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,GAAG,SAAS,IAAI,aAAa,IAAI,cAAc,KAAK,CAAC;CACtH;CACA,gBAAgB,QAAQ;CACxB,0BAA0B,SAAS,KAAK,MAAM;CAI9C,iBAAiB,oBAAoB,KAAK,CAAC;AAC7C;AAEA,SAAS,aACP,aACA,MACY;CACZ,MAAM,cAAe,OAAO,KAAK,IAAI,CAAC,CAAe,KAAK,SACxD,YAAY,SAAS,MAAM,KAAK,KAAc,CAAC;CACjD,aAAa;EAAE,KAAK,MAAM,KAAK,aAAa,EAAE;CAAG;AACnD"}
|
|
@@ -5,6 +5,7 @@ import { never } from "../../domains/chrome-caps/conditions.js";
|
|
|
5
5
|
import { presetChromeRules } from "./features.js";
|
|
6
6
|
import { useHoverTracking } from "../../domains/chrome-caps/useHoverTracking.js";
|
|
7
7
|
import { useChromeCaps } from "../../domains/chrome-caps/useChromeCaps.js";
|
|
8
|
+
import { useChromeRulesDep } from "../deps/chromeRules.js";
|
|
8
9
|
import { useCallback, useMemo } from "react";
|
|
9
10
|
import { useLatest } from "@weasel-js/react";
|
|
10
11
|
|
|
@@ -66,6 +67,15 @@ function useChromeRules(args) {
|
|
|
66
67
|
enabled
|
|
67
68
|
]);
|
|
68
69
|
}
|
|
70
|
+
var hiddenSets = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
/** The chrome the active tool hides (`ToolDef.hides`), or undefined. */
|
|
72
|
+
function hiddenChromeOf(tools) {
|
|
73
|
+
const hides = tools.active ? tools.registry[tools.active]?.hides : void 0;
|
|
74
|
+
if (!hides) return void 0;
|
|
75
|
+
let set = hiddenSets.get(hides);
|
|
76
|
+
if (!set) hiddenSets.set(hides, set = new Set(hides));
|
|
77
|
+
return set;
|
|
78
|
+
}
|
|
69
79
|
/** The chrome-caps answers for the surface's own view. */
|
|
70
80
|
function useSurfaceChromeCaps(args) {
|
|
71
81
|
const { viewRef, dispatcher } = args;
|
|
@@ -87,8 +97,8 @@ function useSurfaceChromeCaps(args) {
|
|
|
87
97
|
};
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
90
|
-
* The surface's chrome: hover tracking, the visibility rules
|
|
91
|
-
* feed. `source` is the chrome-caps source minus the parts built here.
|
|
100
|
+
* The surface's chrome: hover tracking, the visibility rules with the `chromeRules` dep that sets
|
|
101
|
+
* them at run time, and the chrome-caps answers they feed. `source` is the chrome-caps source minus the parts built here.
|
|
92
102
|
*/
|
|
93
103
|
function useSceneCanvasChrome(args) {
|
|
94
104
|
const { rules, viewRef } = args;
|
|
@@ -97,10 +107,11 @@ function useSceneCanvasChrome(args) {
|
|
|
97
107
|
viewRef,
|
|
98
108
|
enabled: rules.chromeVisibility !== void 0 || args.hover.onChange !== void 0
|
|
99
109
|
});
|
|
110
|
+
const chromeRules = useChromeRulesDep(useChromeRules(rules));
|
|
100
111
|
return {
|
|
101
112
|
...useSurfaceChromeCaps({
|
|
102
113
|
source: {
|
|
103
|
-
rules:
|
|
114
|
+
rules: chromeRules.rules,
|
|
104
115
|
getHover,
|
|
105
116
|
...args.source
|
|
106
117
|
},
|
|
@@ -108,10 +119,11 @@ function useSceneCanvasChrome(args) {
|
|
|
108
119
|
viewRef,
|
|
109
120
|
dispatcher: args.dispatcher
|
|
110
121
|
}),
|
|
111
|
-
trackHoverOn
|
|
122
|
+
trackHoverOn,
|
|
123
|
+
chromeRules: chromeRules.dep
|
|
112
124
|
};
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
//#endregion
|
|
116
|
-
export { useChromeRules, useSceneCanvasChrome, useSceneHover, useSurfaceChromeCaps };
|
|
128
|
+
export { hiddenChromeOf, useChromeRules, useSceneCanvasChrome, useSceneHover, useSurfaceChromeCaps };
|
|
117
129
|
//# sourceMappingURL=useSceneChrome.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSceneChrome.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneChrome.ts"],"sourcesContent":["import { useCallback, useMemo, type RefObject } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher, RuleCtx } from '@weasel-js/routing';\nimport type { NodeId } from 'core/scene/types';\nimport type { View } from 'core/viewport/view';\nimport { never, useHoverTracking, type HoverTracking, type VisibilityRules } from 'domains/chrome-caps';\nimport {\n useChromeCaps,\n type ChromeCaps,\n type ChromeCapsSource,\n type ViewRuleInputs,\n} from 'domains/chrome-caps/useChromeCaps';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport { useOptionalViewRegistry } from '../viewRegistry';\nimport { presetChromeRules, type EnabledPresets } from './features';\nimport { PRESET_OWNED_CHROME } from './presets/chrome';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport { worldPointAt } from './worldPointAt';\n\n/**\n * The node under the pointer, for `RuleCtx.hover`. One lookup, not a\n * client-to-world thunk beside a picker: the point and the camera its\n * tolerance converts against have to come from the same view. Hover has no\n * pointer to capture, so whichever view is under the cursor owns the point.\n */\nexport function useSceneHover(args: {\n canvasApiRef: RefObject<Pick<CanvasExtensionApi, 'clientToWorld'> | null>;\n /** The surface's own camera, for a point no declared view claims. */\n viewRef: { readonly current: View };\n nodeAtPointRef: { readonly current: NodeAtPoint | undefined };\n enabled: boolean;\n onChange?: (id: NodeId | null) => void;\n}): HoverTracking {\n const { canvasApiRef, viewRef, nodeAtPointRef, enabled, onChange } = args;\n const surfaceViewRegistry = useOptionalViewRegistry();\n return useHoverTracking({\n nodeAtClientPoint: (clientX, clientY) => {\n const api = canvasApiRef.current;\n if (!api) return null;\n const target = surfaceViewRegistry?.resolver.at(null, clientX, clientY);\n const view = target?.view ?? viewRef.current;\n const [x, y] = worldPointAt(api, target, clientX, clientY);\n // A view judges its own layers; the surface's gate is the picker's default.\n const reg = target?.id != null\n ? surfaceViewRegistry?.list().find((r) => r.id === target.id)\n : undefined;\n const hit = nodeAtPointRef.current?.(\n { x, y }, reg ? { scale: view.scale, layerIsPainted: reg.layerIsPainted } : view,\n );\n return hit ? { id: hit.id as NodeId } : null;\n },\n enabled,\n ...(onChange ? { onChange } : {}),\n });\n}\n\n/**\n * The surface's chrome-visibility rules: the presets' defaults under the\n * consumer's `chromeVisibility`, which wins.\n *\n * An unselectable canvas hides the marquee and lasso by default: every\n * selection write no-ops there, so the select tool's empty-drag binding still\n * claims the gesture, keeping it from falling through to an ambient drag such\n * as insert, but paints nothing.\n */\nexport function useChromeRules(args: {\n enabled: EnabledPresets;\n selectable: boolean;\n chromeVisibility: VisibilityRules | undefined;\n}): VisibilityRules {\n const { enabled, selectable, chromeVisibility } = args;\n return useMemo(() => {\n const defaults = presetChromeRules(enabled, PRESET_OWNED_CHROME);\n if (!selectable) {\n defaults['action.marquee'] = never;\n defaults['action.lasso'] = never;\n }\n return { ...defaults, ...chromeVisibility };\n }, [chromeVisibility, selectable, enabled]);\n}\n\n/** The chrome-caps answers for the surface's own view. */\nexport function useSurfaceChromeCaps(args: {\n source: ChromeCapsSource;\n /** The selection as rendered. `SelectionApi.current` can be a live getter\n * that runs ahead of the commit the painted chrome was built from. */\n selection: readonly NodeId[];\n viewRef: { readonly current: View };\n dispatcher: Pick<Dispatcher, 'getActiveAction'>;\n}): {\n chromeCaps: ChromeCaps;\n getIsVisible: () => (id: string) => boolean;\n getRuleCtx: () => RuleCtx | undefined;\n} {\n const { viewRef, dispatcher } = args;\n const chromeCaps = useChromeCaps(args.source);\n const committedSelectionRef = useLatest(args.selection);\n const currentRuleInputs = useCallback((): ViewRuleInputs => ({\n selection: committedSelectionRef.current,\n view: viewRef.current,\n action: dispatcher.getActiveAction(),\n }), [dispatcher, committedSelectionRef, viewRef]);\n const getIsVisible = useCallback(\n (): ((id: string) => boolean) => chromeCaps.isVisible(currentRuleInputs()),\n [chromeCaps, currentRuleInputs],\n );\n const getRuleCtx = useCallback(\n () => chromeCaps.ruleCtx(currentRuleInputs()),\n [chromeCaps, currentRuleInputs],\n );\n return { chromeCaps, getIsVisible, getRuleCtx };\n}\n\n/**\n * The surface's chrome: hover tracking, the visibility rules, and the chrome-caps answers they
|
|
1
|
+
{"version":3,"file":"useSceneChrome.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneChrome.ts"],"sourcesContent":["import { useCallback, useMemo, type RefObject } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher, RuleCtx } from '@weasel-js/routing';\nimport type { NodeId } from 'core/scene/types';\nimport type { View } from 'core/viewport/view';\nimport { never, useHoverTracking, type HoverTracking, type VisibilityRules } from 'domains/chrome-caps';\nimport {\n useChromeCaps,\n type ChromeCaps,\n type ChromeCapsSource,\n type ViewRuleInputs,\n} from 'domains/chrome-caps/useChromeCaps';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport { useOptionalViewRegistry } from '../viewRegistry';\nimport { presetChromeRules, type EnabledPresets } from './features';\nimport { PRESET_OWNED_CHROME } from './presets/chrome';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport { worldPointAt } from './worldPointAt';\nimport { useChromeRulesDep } from '../deps/chromeRules';\n\n/**\n * The node under the pointer, for `RuleCtx.hover`. One lookup, not a\n * client-to-world thunk beside a picker: the point and the camera its\n * tolerance converts against have to come from the same view. Hover has no\n * pointer to capture, so whichever view is under the cursor owns the point.\n */\nexport function useSceneHover(args: {\n canvasApiRef: RefObject<Pick<CanvasExtensionApi, 'clientToWorld'> | null>;\n /** The surface's own camera, for a point no declared view claims. */\n viewRef: { readonly current: View };\n nodeAtPointRef: { readonly current: NodeAtPoint | undefined };\n enabled: boolean;\n onChange?: (id: NodeId | null) => void;\n}): HoverTracking {\n const { canvasApiRef, viewRef, nodeAtPointRef, enabled, onChange } = args;\n const surfaceViewRegistry = useOptionalViewRegistry();\n return useHoverTracking({\n nodeAtClientPoint: (clientX, clientY) => {\n const api = canvasApiRef.current;\n if (!api) return null;\n const target = surfaceViewRegistry?.resolver.at(null, clientX, clientY);\n const view = target?.view ?? viewRef.current;\n const [x, y] = worldPointAt(api, target, clientX, clientY);\n // A view judges its own layers; the surface's gate is the picker's default.\n const reg = target?.id != null\n ? surfaceViewRegistry?.list().find((r) => r.id === target.id)\n : undefined;\n const hit = nodeAtPointRef.current?.(\n { x, y }, reg ? { scale: view.scale, layerIsPainted: reg.layerIsPainted } : view,\n );\n return hit ? { id: hit.id as NodeId } : null;\n },\n enabled,\n ...(onChange ? { onChange } : {}),\n });\n}\n\n/**\n * The surface's chrome-visibility rules: the presets' defaults under the\n * consumer's `chromeVisibility`, which wins.\n *\n * An unselectable canvas hides the marquee and lasso by default: every\n * selection write no-ops there, so the select tool's empty-drag binding still\n * claims the gesture, keeping it from falling through to an ambient drag such\n * as insert, but paints nothing.\n */\nexport function useChromeRules(args: {\n enabled: EnabledPresets;\n selectable: boolean;\n chromeVisibility: VisibilityRules | undefined;\n}): VisibilityRules {\n const { enabled, selectable, chromeVisibility } = args;\n return useMemo(() => {\n const defaults = presetChromeRules(enabled, PRESET_OWNED_CHROME);\n if (!selectable) {\n defaults['action.marquee'] = never;\n defaults['action.lasso'] = never;\n }\n return { ...defaults, ...chromeVisibility };\n }, [chromeVisibility, selectable, enabled]);\n}\n\nconst hiddenSets = new WeakMap<readonly string[], ReadonlySet<string>>();\n\n/** The chrome the active tool hides (`ToolDef.hides`), or undefined. */\nexport function hiddenChromeOf(tools: { active: string | null; registry: Readonly<Record<string, { hides?: readonly string[] }>> }): ReadonlySet<string> | undefined {\n const hides = tools.active ? tools.registry[tools.active]?.hides : undefined;\n if (!hides) return undefined;\n let set = hiddenSets.get(hides);\n if (!set) hiddenSets.set(hides, (set = new Set(hides)));\n return set;\n}\n\n/** The chrome-caps answers for the surface's own view. */\nexport function useSurfaceChromeCaps(args: {\n source: ChromeCapsSource;\n /** The selection as rendered. `SelectionApi.current` can be a live getter\n * that runs ahead of the commit the painted chrome was built from. */\n selection: readonly NodeId[];\n viewRef: { readonly current: View };\n dispatcher: Pick<Dispatcher, 'getActiveAction'>;\n}): {\n chromeCaps: ChromeCaps;\n getIsVisible: () => (id: string) => boolean;\n getRuleCtx: () => RuleCtx | undefined;\n} {\n const { viewRef, dispatcher } = args;\n const chromeCaps = useChromeCaps(args.source);\n const committedSelectionRef = useLatest(args.selection);\n const currentRuleInputs = useCallback((): ViewRuleInputs => ({\n selection: committedSelectionRef.current,\n view: viewRef.current,\n action: dispatcher.getActiveAction(),\n }), [dispatcher, committedSelectionRef, viewRef]);\n const getIsVisible = useCallback(\n (): ((id: string) => boolean) => chromeCaps.isVisible(currentRuleInputs()),\n [chromeCaps, currentRuleInputs],\n );\n const getRuleCtx = useCallback(\n () => chromeCaps.ruleCtx(currentRuleInputs()),\n [chromeCaps, currentRuleInputs],\n );\n return { chromeCaps, getIsVisible, getRuleCtx };\n}\n\n/**\n * The surface's chrome: hover tracking, the visibility rules with the `chromeRules` dep that sets\n * them at run time, and the chrome-caps answers they feed. `source` is the chrome-caps source minus the parts built here.\n */\nexport function useSceneCanvasChrome(args: {\n source: Omit<ChromeCapsSource, 'rules' | 'getHover'>;\n rules: Parameters<typeof useChromeRules>[0];\n hover: Omit<Parameters<typeof useSceneHover>[0], 'enabled' | 'viewRef'>;\n selection: readonly NodeId[];\n viewRef: { readonly current: View };\n dispatcher: Pick<Dispatcher, 'getActiveAction'>;\n}) {\n const { rules, viewRef } = args;\n const { getHover, canvasRef: trackHoverOn } = useSceneHover({\n ...args.hover, viewRef, enabled: rules.chromeVisibility !== undefined || args.hover.onChange !== undefined,\n });\n const chromeRules = useChromeRulesDep(useChromeRules(rules));\n const caps = useSurfaceChromeCaps({\n source: { rules: chromeRules.rules, getHover, ...args.source },\n selection: args.selection,\n viewRef,\n dispatcher: args.dispatcher,\n });\n return { ...caps, trackHoverOn, chromeRules: chromeRules.dep };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAgB,cAAc,MAOZ;CAChB,MAAM,EAAE,cAAc,SAAS,gBAAgB,SAAS,aAAa;CACrE,MAAM,sBAAsB,wBAAwB;CACpD,OAAO,iBAAiB;EACtB,oBAAoB,SAAS,YAAY;GACvC,MAAM,MAAM,aAAa;GACzB,IAAI,CAAC,KAAK,OAAO;GACjB,MAAM,SAAS,qBAAqB,SAAS,GAAG,MAAM,SAAS,OAAO;GACtE,MAAM,OAAO,QAAQ,QAAQ,QAAQ;GACrC,MAAM,CAAC,GAAG,KAAK,aAAa,KAAK,QAAQ,SAAS,OAAO;GAEzD,MAAM,MAAM,QAAQ,MAAM,OACtB,qBAAqB,KAAK,CAAC,CAAC,MAAM,MAAM,EAAE,OAAO,OAAO,EAAE,IAC1D;GACJ,MAAM,MAAM,eAAe,UACzB;IAAE;IAAG;GAAE,GAAG,MAAM;IAAE,OAAO,KAAK;IAAO,gBAAgB,IAAI;GAAe,IAAI,IAC9E;GACA,OAAO,MAAM,EAAE,IAAI,IAAI,GAAa,IAAI;EAC1C;EACA;EACA,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CACjC,CAAC;AACH;;;;;;;;;;AAWA,SAAgB,eAAe,MAIX;CAClB,MAAM,EAAE,SAAS,YAAY,qBAAqB;CAClD,OAAO,cAAc;EACnB,MAAM,WAAW,kBAAkB,S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IAAO;IAAU,GAAG,KAAK;GAAO;GAC7D,WAAW,KAAK;GAChB;GACA,YAAY,KAAK;EACnB,CACY;EAAM;EAAc,aAAa,YAAY;CAAI;AAC/D"}
|
|
@@ -9,6 +9,7 @@ import { useNodeAtPointDepSource } from "../deps/nodeAtPoint.js";
|
|
|
9
9
|
import { useLassoSelectDepSource } from "../deps/lassoSelect.js";
|
|
10
10
|
import { useTextEditDepSource } from "../deps/textEdit.js";
|
|
11
11
|
import { useEditAnchorsDepSource } from "../deps/editAnchors.js";
|
|
12
|
+
import { useSelectionSnapshotDepSource } from "../deps/selectionSnapshot.js";
|
|
12
13
|
import { useInsertDepSource } from "../deps/insert.js";
|
|
13
14
|
import { useSnapDepSource } from "../deps/snap.js";
|
|
14
15
|
import { usePathLeafDepSources } from "../deps/pathLeafDeps.js";
|
|
@@ -87,6 +88,7 @@ function useSceneStandardActions(inputs) {
|
|
|
87
88
|
...props.snap?.reachPx !== void 0 ? { reachPx: props.snap.reachPx } : {},
|
|
88
89
|
...props.snap?.omit ? { omit: props.snap.omit } : {},
|
|
89
90
|
...props.snap?.originProjection ? { originProjection: props.snap.originProjection } : {},
|
|
91
|
+
...props.snap?.anchors ? { anchors: props.snap.anchors } : {},
|
|
90
92
|
poseDescriptor,
|
|
91
93
|
debug: () => canvasApiRef.current?.getDebug()
|
|
92
94
|
}, snap.store);
|
|
@@ -97,6 +99,7 @@ function useSceneStandardActions(inputs) {
|
|
|
97
99
|
useLassoSelectDepSource(scene, selection, poseDescriptor, alphaOf, reachable);
|
|
98
100
|
useTextEditDepSource(scene);
|
|
99
101
|
useEditAnchorsDepSource(scene, selection, adapter, editAnchorsExternalState, tune);
|
|
102
|
+
useSelectionSnapshotDepSource();
|
|
100
103
|
useDispatcherDepSource(dispatcher);
|
|
101
104
|
usePoseDescriptorDepSource(poseDescriptor);
|
|
102
105
|
useDepSource("boundsIncludeStroke", () => boundsIncludeStroke);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSceneStandardActions.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneStandardActions.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { Dispatcher, WorldPoint } from '@weasel-js/routing';\nimport { useActionsRegistry, useDepSource } from '@weasel-js/routing/react';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { useDecayLoop } from 'core/viewport/useDecayLoop';\nimport type { ViewAnimationApi } from 'core/viewport/useViewAnimation';\nimport type { View } from 'core/viewport/view';\nimport type { ClipboardIngestCtx } from 'interactions/actions/depSchema';\nimport type { ContentHandlerEntry } from 'domains/ingestion/contentHandlers';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { useActionSet, useStandardDeps } from 'interactions/actions/useActionSet';\nimport { drawnBoxes } from 'interactions/actions/drawnBoxes';\nimport type React from 'react';\nimport { useEffect, useMemo } from 'react';\nimport type { ReflowTransition } from '../../layout/types';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSourceRegistry } from 'domains/snap/registry';\nimport type { SnapSource } from 'domains/snap/types';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport {\n useAreaSelectDepSource,\n useDebugDepSource,\n usePreviewPathsDepSource,\n useDepChangeNotices,\n useDispatcherDepSource,\n useEditAnchorsDepSource,\n useEnteredGroupApiSource,\n useIngestionDepSource,\n useInsertDepSource,\n useLassoSelectDepSource,\n useLayoutDepSource,\n useNodeAtPointDepSource,\n usePoseDescriptorDepSource,\n usePathLeafDepSources,\n useSnapDepSource,\n useSurfaceDepSources,\n useTextEditDepSource,\n useViewDepSource,\n} from '../deps';\nimport type { EnteredGroupApi } from '../deps/enteredGroup';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport { useActionsPropResolver } from './useActionsPropResolver';\nimport { useActionTunings, useBindingOverrides } from './useActionTunings';\nimport { useViewportActions, viewportZoomOption } from './useViewportActions';\n\n/** The `<SceneCanvas>` props the standard actions and their deps read. */\nexport type StandardActionsProps = Pick<\n SceneCanvasProps<unknown, string, unknown>,\n | 'actions' | 'tune' | 'bindingOverrides' | 'geometry' | 'viewport' | 'layoutDropTarget'\n | 'reflowTransition' | 'insertNodeFactories' | 'insertPaint' | 'ingestion' | 'snap'\n>;\n\n/** What `<SceneCanvas>` hands {@link useSceneStandardActions}. */\nexport interface SceneStandardActionsInputs {\n props: StandardActionsProps;\n /** Whether the `view` preset is on; without it the viewport actions are off. */\n viewOn: boolean;\n selection: SelectionApi;\n /** The group a press resolves inside of, shared with the picking that names double-clicks. */\n enteredGroup: EnteredGroupApi;\n scene: Scene<unknown, string, unknown>;\n adapter: BridgeAdapter;\n /** The standard actions this canvas registers: its presets' and the ones\n * its tools bind, in registration order. */\n standardActions: readonly Action[];\n currentViewRef: React.RefObject<View>;\n onViewChange: (v: View) => void;\n /** Wires the `poseDescriptor` dep every built-in pose-touching action reads. */\n poseDescriptor: PoseDescriptor<unknown>;\n /** Forwarded so `cancelGestureAction` and other actions that need to\n * abort in-flight handles can read the dispatcher's control surface. */\n dispatcher: Dispatcher;\n /** World-space picker forwarded so the `nodeAtPoint` dep source can\n * reuse the same hit-test plumbing the tool dispatcher uses. */\n pickEvery: (world: WorldPoint) => string[];\n /** This canvas's own view gate for scene layers, published on the `view`\n * dep and read by the selecting actions. Absent when it hides nothing. */\n layerIsPainted?: (layerId: string) => boolean;\n /** The composed paint alpha, when the consumer fades anything, so a region\n * select passes over what is painted at zero. */\n alphaOf?: (id: string) => number;\n /** Whether a node takes hits: what a region select may take, as a press may. */\n reachable?: (id: string) => boolean;\n /** The canvas's camera runner, published on the `view` dep so\n * `viewport.zoom`'s discrete branches can animate. */\n viewAnimation: ViewAnimationApi;\n /** Lifted edit-mode state so the `pathEditingOverlay` chrome (rendered\n * outside this subtree) can read the same `editingId` the dep does. */\n editAnchorsExternalState: import('../deps/editAnchors').EditAnchorsStateSource;\n /** The snap sources a session asks: the prop's and the presets', then the registry's. */\n snap: { sources: readonly SnapSource[]; registry: SnapSourceRegistry | null; store: SnapOutcomeStore };\n /** The canvas element ref, so `useIngestionDepSource` can compute the\n * visible world rect from the client rect + current view. */\n canvasRef: React.RefObject<HTMLElement | null>;\n /** The canvas handle, whose debug sink backs the `debug` dep. */\n canvasApiRef: React.RefObject<CanvasExtensionApi | null>;\n /** Clipboard-paste ctx (this canvas's adapter + the consumer's reviver)\n * for the kit weasel-JSON handler, from `useCanvasIngestion`; absent\n * when disabled. */\n ingestionClipboard?: ClipboardIngestCtx;\n /** The canvas's own content handlers and the kit's it keeps, from `useCanvasIngestion`. */\n ingestionHandlers?: readonly ContentHandlerEntry[];\n}\n\n/**\n * Registers this canvas's standard actions, and the deps they read, into its\n * input scope, then applies the `actions` prop and `tune` over them.\n *\n * Called from a component ahead of `<SceneCanvas>`'s children, never from the\n * canvas's own body: registrations stack newest-live in effect order, and a\n * parent's effects run after its children's, so a child's override would lose.\n */\nexport function useSceneStandardActions(inputs: SceneStandardActionsInputs): void {\n const {\n props, viewOn, selection, enteredGroup, scene, adapter, standardActions, currentViewRef,\n onViewChange, poseDescriptor, dispatcher, pickEvery, layerIsPainted, alphaOf, reachable, viewAnimation,\n editAnchorsExternalState, snap, canvasRef, canvasApiRef, ingestionClipboard,\n ingestionHandlers,\n } = inputs;\n const { tune, viewport, ingestion } = props;\n const boundsIncludeStroke = props.geometry?.boundsIncludeStroke ?? true;\n const reflowTransition = props.reflowTransition as ReflowTransition<unknown> | null | undefined;\n const viewportZoom = useMemo(\n () => viewportZoomOption(viewport?.zoom, viewport?.animatedZoom),\n [viewport?.zoom, viewport?.animatedZoom],\n );\n const registry = useActionsRegistry();\n\n // Wire the dispatcher into the registry so registry.begin() can delegate\n // to dispatcher.beginUiOngoing() for UI-driven ongoing actions (color,\n // opacity).\n useEffect(() => {\n if (!registry) return;\n return registry.setDispatcher(dispatcher);\n }, [registry, dispatcher]);\n\n // Momentum for `viewport.dragPan`. The loop must be a hook (it owns a\n // `useVisibleRaf`), so it is built here and republished on the view dep.\n const decayLoop = useDecayLoop();\n\n // Build the ViewApi (stable identity, refreshed closures) and hand it to\n // useStandardDeps (which publishes the `view` dep along with selection,\n // scene, history, activeTool). `hostSize` reads the live canvas\n // element so keyboard zoom (Cmd+=/-) can anchor at the visible center.\n const view = useViewDepSource(\n currentViewRef,\n onViewChange,\n viewport?.recenter,\n () => {\n const el = canvasRef.current;\n return el ? { width: el.clientWidth, height: el.clientHeight } : null;\n },\n viewAnimation,\n decayLoop,\n layerIsPainted,\n );\n useStandardDeps({ selection, scene, view, history: scene.history });\n useActionSet(standardActions);\n // A view overlays `view` with its own camera; this name it leaves alone.\n useDepSource('rootView', () => view);\n useSurfaceDepSources(canvasRef, currentViewRef);\n useDepSource('actionParams', () => registry?.paramsOf);\n\n // viewport.pan / viewport.zoom are SceneCanvas-coupled (need the `view` dep\n // published just above), so they're registered here rather than in\n // KIT_STANDARD_DESCRIPTORS. Both default ON; consumer opts out via\n // `viewport={{ pan: false }}` / `viewport={{ zoom: false }}`.\n useViewportActions({\n pan: viewOn ? (viewport?.pan ?? true) : false,\n zoom: viewOn ? viewportZoom : false,\n pinchZoom: viewOn ? (viewport?.pinchZoom ?? true) : false,\n });\n\n // Per-dep wiring modules under `src/canvas/deps/`. See each file for the\n // dep's contract and trade-offs.\n useAreaSelectDepSource(scene, selection, poseDescriptor, alphaOf, reachable);\n useNodeAtPointDepSource(pickEvery);\n useLayoutDepSource(scene, props.layoutDropTarget, reflowTransition);\n useEnteredGroupApiSource(enteredGroup);\n useInsertDepSource(scene, adapter, props.insertNodeFactories, props.insertPaint);\n usePathLeafDepSources(scene, selection, adapter, poseDescriptor);\n useSnapDepSource(\n currentViewRef,\n {\n scene, boxes: () => drawnBoxes({ scene, poseDescriptor, view, boundsIncludeStroke }), sources: snap.sources,\n ...(snap.registry ? { registry: snap.registry } : {}),\n ...(props.snap?.reachPx !== undefined ? { reachPx: props.snap.reachPx } : {}),\n ...(props.snap?.omit ? { omit: props.snap.omit } : {}),\n ...(props.snap?.originProjection ? { originProjection: props.snap.originProjection } : {}),\n poseDescriptor,\n debug: () => canvasApiRef.current?.getDebug(),\n },\n snap.store,\n );\n useDebugDepSource(canvasApiRef);\n usePreviewPathsDepSource(canvasApiRef);\n useDepChangeNotices(scene, selection.current, editAnchorsExternalState);\n useIngestionDepSource(canvasRef, () => currentViewRef.current, ingestion?.resolveSrc, ingestion?.svg, ingestionClipboard, ingestionHandlers);\n useLassoSelectDepSource(scene, selection, poseDescriptor, alphaOf, reachable);\n useTextEditDepSource(scene);\n useEditAnchorsDepSource(scene, selection, adapter, editAnchorsExternalState, tune);\n useDispatcherDepSource(dispatcher);\n usePoseDescriptorDepSource(poseDescriptor);\n useDepSource('boundsIncludeStroke', () => boundsIncludeStroke);\n\n // Keyed on the set too: a re-registration of it would otherwise land over\n // the overrides applied on top of it.\n useActionsPropResolver(props.actions, standardActions.map((a) => a.id).join('|'));\n useActionTunings(tune);\n useBindingOverrides(props.bindingOverrides);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,SAAgB,wBAAwB,QAA0C;CAChF,MAAM,EACJ,OAAO,QAAQ,WAAW,cAAc,OAAO,SAAS,iBAAiB,gBACzE,cAAc,gBAAgB,YAAY,WAAW,gBAAgB,SAAS,WAAW,eACzF,0BAA0B,MAAM,WAAW,cAAc,oBACzD,sBACE;CACJ,MAAM,EAAE,MAAM,UAAU,cAAc;CACtC,MAAM,sBAAsB,MAAM,UAAU,uBAAuB;CACnE,MAAM,mBAAmB,MAAM;CAC/B,MAAM,eAAe,cACb,mBAAmB,UAAU,MAAM,UAAU,YAAY,GAC/D,CAAC,UAAU,MAAM,UAAU,YAAY,CACzC;CACA,MAAM,WAAW,mBAAmB;CAKpC,gBAAgB;EACd,IAAI,CAAC,UAAU;EACf,OAAO,SAAS,cAAc,UAAU;CAC1C,GAAG,CAAC,UAAU,UAAU,CAAC;CAIzB,MAAM,YAAY,aAAa;CAM/B,MAAM,OAAO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S,WAAW,YAAY,WAAW,KAAK,oBAAoB,iBAAiB;CAC3I,wBAAwB,OAAO,WAAW,gBAAgB,SAAS,SAAS;CAC5E,qBAAqB,KAAK;CAC1B,wBAAwB,OAAO,WAAW,SAAS,0BAA0B,IAAI;CACjF,uBAAuB,UAAU;CACjC,2BAA2B,cAAc;CACzC,aAAa,6BAA6B,mBAAmB;CAI7D,uBAAuB,MAAM,SAAS,gBAAgB,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;CAChF,iBAAiB,IAAI;CACrB,oBAAoB,MAAM,gBAAgB;AAC5C"}
|
|
1
|
+
{"version":3,"file":"useSceneStandardActions.js","names":[],"sources":["../../../src/canvas/SceneCanvas/useSceneStandardActions.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { Dispatcher, WorldPoint } from '@weasel-js/routing';\nimport { useActionsRegistry, useDepSource } from '@weasel-js/routing/react';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { useDecayLoop } from 'core/viewport/useDecayLoop';\nimport type { ViewAnimationApi } from 'core/viewport/useViewAnimation';\nimport type { View } from 'core/viewport/view';\nimport type { ClipboardIngestCtx } from 'interactions/actions/depSchema';\nimport type { ContentHandlerEntry } from 'domains/ingestion/contentHandlers';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { useActionSet, useStandardDeps } from 'interactions/actions/useActionSet';\nimport { drawnBoxes } from 'interactions/actions/drawnBoxes';\nimport type React from 'react';\nimport { useEffect, useMemo } from 'react';\nimport type { ReflowTransition } from '../../layout/types';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSourceRegistry } from 'domains/snap/registry';\nimport type { SnapSource } from 'domains/snap/types';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport {\n useAreaSelectDepSource,\n useDebugDepSource,\n usePreviewPathsDepSource,\n useDepChangeNotices,\n useDispatcherDepSource,\n useEditAnchorsDepSource,\n useSelectionSnapshotDepSource,\n useEnteredGroupApiSource,\n useIngestionDepSource,\n useInsertDepSource,\n useLassoSelectDepSource,\n useLayoutDepSource,\n useNodeAtPointDepSource,\n usePoseDescriptorDepSource,\n usePathLeafDepSources,\n useSnapDepSource,\n useSurfaceDepSources,\n useTextEditDepSource,\n useViewDepSource,\n} from '../deps';\nimport type { EnteredGroupApi } from '../deps/enteredGroup';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport { useActionsPropResolver } from './useActionsPropResolver';\nimport { useActionTunings, useBindingOverrides } from './useActionTunings';\nimport { useViewportActions, viewportZoomOption } from './useViewportActions';\n\n/** The `<SceneCanvas>` props the standard actions and their deps read. */\nexport type StandardActionsProps = Pick<\n SceneCanvasProps<unknown, string, unknown>,\n | 'actions' | 'tune' | 'bindingOverrides' | 'geometry' | 'viewport' | 'layoutDropTarget'\n | 'reflowTransition' | 'insertNodeFactories' | 'insertPaint' | 'ingestion' | 'snap'\n>;\n\n/** What `<SceneCanvas>` hands {@link useSceneStandardActions}. */\nexport interface SceneStandardActionsInputs {\n props: StandardActionsProps;\n /** Whether the `view` preset is on; without it the viewport actions are off. */\n viewOn: boolean;\n selection: SelectionApi;\n /** The group a press resolves inside of, shared with the picking that names double-clicks. */\n enteredGroup: EnteredGroupApi;\n scene: Scene<unknown, string, unknown>;\n adapter: BridgeAdapter;\n /** The standard actions this canvas registers: its presets' and the ones\n * its tools bind, in registration order. */\n standardActions: readonly Action[];\n currentViewRef: React.RefObject<View>;\n onViewChange: (v: View) => void;\n /** Wires the `poseDescriptor` dep every built-in pose-touching action reads. */\n poseDescriptor: PoseDescriptor<unknown>;\n /** Forwarded so `cancelGestureAction` and other actions that need to\n * abort in-flight handles can read the dispatcher's control surface. */\n dispatcher: Dispatcher;\n /** World-space picker forwarded so the `nodeAtPoint` dep source can\n * reuse the same hit-test plumbing the tool dispatcher uses. */\n pickEvery: (world: WorldPoint) => string[];\n /** This canvas's own view gate for scene layers, published on the `view`\n * dep and read by the selecting actions. Absent when it hides nothing. */\n layerIsPainted?: (layerId: string) => boolean;\n /** The composed paint alpha, when the consumer fades anything, so a region\n * select passes over what is painted at zero. */\n alphaOf?: (id: string) => number;\n /** Whether a node takes hits: what a region select may take, as a press may. */\n reachable?: (id: string) => boolean;\n /** The canvas's camera runner, published on the `view` dep so\n * `viewport.zoom`'s discrete branches can animate. */\n viewAnimation: ViewAnimationApi;\n /** Lifted edit-mode state so the `pathEditingOverlay` chrome (rendered\n * outside this subtree) can read the same `editingId` the dep does. */\n editAnchorsExternalState: import('../deps/editAnchors').EditAnchorsStateSource;\n /** The snap sources a session asks: the prop's and the presets', then the registry's. */\n snap: { sources: readonly SnapSource[]; registry: SnapSourceRegistry | null; store: SnapOutcomeStore };\n /** The canvas element ref, so `useIngestionDepSource` can compute the\n * visible world rect from the client rect + current view. */\n canvasRef: React.RefObject<HTMLElement | null>;\n /** The canvas handle, whose debug sink backs the `debug` dep. */\n canvasApiRef: React.RefObject<CanvasExtensionApi | null>;\n /** Clipboard-paste ctx (this canvas's adapter + the consumer's reviver)\n * for the kit weasel-JSON handler, from `useCanvasIngestion`; absent\n * when disabled. */\n ingestionClipboard?: ClipboardIngestCtx;\n /** The canvas's own content handlers and the kit's it keeps, from `useCanvasIngestion`. */\n ingestionHandlers?: readonly ContentHandlerEntry[];\n}\n\n/**\n * Registers this canvas's standard actions, and the deps they read, into its\n * input scope, then applies the `actions` prop and `tune` over them.\n *\n * Called from a component ahead of `<SceneCanvas>`'s children, never from the\n * canvas's own body: registrations stack newest-live in effect order, and a\n * parent's effects run after its children's, so a child's override would lose.\n */\nexport function useSceneStandardActions(inputs: SceneStandardActionsInputs): void {\n const {\n props, viewOn, selection, enteredGroup, scene, adapter, standardActions, currentViewRef,\n onViewChange, poseDescriptor, dispatcher, pickEvery, layerIsPainted, alphaOf, reachable, viewAnimation,\n editAnchorsExternalState, snap, canvasRef, canvasApiRef, ingestionClipboard,\n ingestionHandlers,\n } = inputs;\n const { tune, viewport, ingestion } = props;\n const boundsIncludeStroke = props.geometry?.boundsIncludeStroke ?? true;\n const reflowTransition = props.reflowTransition as ReflowTransition<unknown> | null | undefined;\n const viewportZoom = useMemo(\n () => viewportZoomOption(viewport?.zoom, viewport?.animatedZoom),\n [viewport?.zoom, viewport?.animatedZoom],\n );\n const registry = useActionsRegistry();\n\n // Wire the dispatcher into the registry so registry.begin() can delegate\n // to dispatcher.beginUiOngoing() for UI-driven ongoing actions (color,\n // opacity).\n useEffect(() => {\n if (!registry) return;\n return registry.setDispatcher(dispatcher);\n }, [registry, dispatcher]);\n\n // Momentum for `viewport.dragPan`. The loop must be a hook (it owns a\n // `useVisibleRaf`), so it is built here and republished on the view dep.\n const decayLoop = useDecayLoop();\n\n // Build the ViewApi (stable identity, refreshed closures) and hand it to\n // useStandardDeps (which publishes the `view` dep along with selection,\n // scene, history, activeTool). `hostSize` reads the live canvas\n // element so keyboard zoom (Cmd+=/-) can anchor at the visible center.\n const view = useViewDepSource(\n currentViewRef,\n onViewChange,\n viewport?.recenter,\n () => {\n const el = canvasRef.current;\n return el ? { width: el.clientWidth, height: el.clientHeight } : null;\n },\n viewAnimation,\n decayLoop,\n layerIsPainted,\n );\n useStandardDeps({ selection, scene, view, history: scene.history });\n useActionSet(standardActions);\n // A view overlays `view` with its own camera; this name it leaves alone.\n useDepSource('rootView', () => view);\n useSurfaceDepSources(canvasRef, currentViewRef);\n useDepSource('actionParams', () => registry?.paramsOf);\n\n // viewport.pan / viewport.zoom are SceneCanvas-coupled (need the `view` dep\n // published just above), so they're registered here rather than in\n // KIT_STANDARD_DESCRIPTORS. Both default ON; consumer opts out via\n // `viewport={{ pan: false }}` / `viewport={{ zoom: false }}`.\n useViewportActions({\n pan: viewOn ? (viewport?.pan ?? true) : false,\n zoom: viewOn ? viewportZoom : false,\n pinchZoom: viewOn ? (viewport?.pinchZoom ?? true) : false,\n });\n\n // Per-dep wiring modules under `src/canvas/deps/`. See each file for the\n // dep's contract and trade-offs.\n useAreaSelectDepSource(scene, selection, poseDescriptor, alphaOf, reachable);\n useNodeAtPointDepSource(pickEvery);\n useLayoutDepSource(scene, props.layoutDropTarget, reflowTransition);\n useEnteredGroupApiSource(enteredGroup);\n useInsertDepSource(scene, adapter, props.insertNodeFactories, props.insertPaint);\n usePathLeafDepSources(scene, selection, adapter, poseDescriptor);\n useSnapDepSource(\n currentViewRef,\n {\n scene, boxes: () => drawnBoxes({ scene, poseDescriptor, view, boundsIncludeStroke }), sources: snap.sources,\n ...(snap.registry ? { registry: snap.registry } : {}),\n ...(props.snap?.reachPx !== undefined ? { reachPx: props.snap.reachPx } : {}),\n ...(props.snap?.omit ? { omit: props.snap.omit } : {}),\n ...(props.snap?.originProjection ? { originProjection: props.snap.originProjection } : {}),\n ...(props.snap?.anchors ? { anchors: props.snap.anchors } : {}),\n poseDescriptor,\n debug: () => canvasApiRef.current?.getDebug(),\n },\n snap.store,\n );\n useDebugDepSource(canvasApiRef);\n usePreviewPathsDepSource(canvasApiRef);\n useDepChangeNotices(scene, selection.current, editAnchorsExternalState);\n useIngestionDepSource(canvasRef, () => currentViewRef.current, ingestion?.resolveSrc, ingestion?.svg, ingestionClipboard, ingestionHandlers);\n useLassoSelectDepSource(scene, selection, poseDescriptor, alphaOf, reachable);\n useTextEditDepSource(scene);\n useEditAnchorsDepSource(scene, selection, adapter, editAnchorsExternalState, tune);\n useSelectionSnapshotDepSource();\n useDispatcherDepSource(dispatcher);\n usePoseDescriptorDepSource(poseDescriptor);\n useDepSource('boundsIncludeStroke', () => boundsIncludeStroke);\n\n // Keyed on the set too: a re-registration of it would otherwise land over\n // the overrides applied on top of it.\n useActionsPropResolver(props.actions, standardActions.map((a) => a.id).join('|'));\n useActionTunings(tune);\n useBindingOverrides(props.bindingOverrides);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAgB,wBAAwB,QAA0C;CAChF,MAAM,EACJ,OAAO,QAAQ,WAAW,cAAc,OAAO,SAAS,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C;EAAG,SAAS,KAAK;EACpG,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;EACnD,GAAI,MAAM,MAAM,YAAY,SAAY,EAAE,SAAS,MAAM,KAAK,QAAQ,IAAI,CAAC;EAC3E,GAAI,MAAM,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,KAAK,IAAI,CAAC;EACpD,GAAI,MAAM,MAAM,mBAAmB,EAAE,kBAAkB,MAAM,KAAK,iBAAiB,IAAI,CAAC;EACxF,GAAI,MAAM,MAAM,UAAU,EAAE,SAAS,MAAM,KAAK,QAAQ,IAAI,CAAC;EAC7D;EACA,aAAa,aAAa,SAAS,SAAS;CAC9C,GACA,KAAK,KACP;CACA,kBAAkB,YAAY;CAC9B,yBAAyB,YAAY;CACrC,oBAAoB,OAAO,UAAU,SAAS,wBAAwB;CACtE,sBAAsB,iBAAiB,eAAe,SAAS,WAAW,YAAY,WAAW,KAAK,oBAAoB,iBAAiB;CAC3I,wBAAwB,OAAO,WAAW,gBAAgB,SAAS,SAAS;CAC5E,qBAAqB,KAAK;CAC1B,wBAAwB,OAAO,WAAW,SAAS,0BAA0B,IAAI;CACjF,8BAA8B;CAC9B,uBAAuB,UAAU;CACjC,2BAA2B,cAAc;CACzC,aAAa,6BAA6B,mBAAmB;CAI7D,uBAAuB,MAAM,SAAS,gBAAgB,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;CAChF,iBAAiB,IAAI;CACrB,oBAAoB,MAAM,gBAAgB;AAC5C"}
|
|
@@ -4,7 +4,7 @@ import { ViewRegistryProvider } from "./viewRegistry.js";
|
|
|
4
4
|
import { rotateAroundAABBCenter } from "./poseRotation.js";
|
|
5
5
|
import { defaultDrawOne } from "./defaultDrawOne.js";
|
|
6
6
|
import { useChromeColor } from "./accentColor.js";
|
|
7
|
-
import { BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS } from "./SceneCanvas/builtinToolSets.js";
|
|
7
|
+
import { ANCHOR_TOOLS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS } from "./SceneCanvas/builtinToolSets.js";
|
|
8
8
|
import { CORE_PRESET_SOURCE } from "./SceneCanvas/namedPresets.js";
|
|
9
9
|
import { useGroupEntryContribution } from "../tools/builtin/select/groupEntry.js";
|
|
10
10
|
import { useCanvasCamera } from "./SceneCanvas/useCanvasCamera.js";
|
|
@@ -32,7 +32,7 @@ import { ENTERED_FRAME_COLOR, ENTERED_FRAME_TOKEN } from "../domains/selection/e
|
|
|
32
32
|
import { useSceneCanvasLayers } from "./SceneCanvas/useSceneCanvasLayers.js";
|
|
33
33
|
import { useSceneCanvasPathEdit } from "./SceneCanvas/useSceneCanvasPathEdit.js";
|
|
34
34
|
import { useSceneCanvasTools } from "./SceneCanvas/useSceneCanvasTools.js";
|
|
35
|
-
import { useSceneCanvasChrome } from "./SceneCanvas/useSceneChrome.js";
|
|
35
|
+
import { hiddenChromeOf, useSceneCanvasChrome } from "./SceneCanvas/useSceneChrome.js";
|
|
36
36
|
import { useSceneRedrawSources } from "./SceneCanvas/useSceneRedrawSources.js";
|
|
37
37
|
import { useScenePicking } from "./SceneCanvas/useScenePicking.js";
|
|
38
38
|
import { useNodeKinds } from "./SceneCanvas/useNodeKinds.js";
|
|
@@ -160,7 +160,8 @@ function SceneCanvasInner(props, ref) {
|
|
|
160
160
|
getModifiers: heldModifiers.get,
|
|
161
161
|
resizable: selectToolOpts?.resize?.resizable,
|
|
162
162
|
editingAnchors: () => pathEditState.getEditingId() !== "",
|
|
163
|
-
device: deviceProfile
|
|
163
|
+
device: deviceProfile,
|
|
164
|
+
getHiddenChrome: () => hiddenChromeOf(tools.tools)
|
|
164
165
|
},
|
|
165
166
|
rules: {
|
|
166
167
|
enabled,
|
|
@@ -317,5 +318,5 @@ function SceneCanvasWrapper(props, ref) {
|
|
|
317
318
|
var SceneCanvas = /* @__PURE__ */ forwardRef(SceneCanvasWrapper);
|
|
318
319
|
|
|
319
320
|
//#endregion
|
|
320
|
-
export { BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DEFAULT_HANDLE_SIZE, DRAW_TOOLS, PAGE_TOOLS, SCENE_CANVAS_FEATURES, SELECT_TOOLS, SHAPE_TOOLS, SceneCanvas, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS, renderSceneCanvas, rotateAroundAABBCenter };
|
|
321
|
+
export { ANCHOR_TOOLS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DEFAULT_HANDLE_SIZE, DRAW_TOOLS, PAGE_TOOLS, SCENE_CANVAS_FEATURES, SELECT_TOOLS, SHAPE_TOOLS, SceneCanvas, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS, renderSceneCanvas, rotateAroundAABBCenter };
|
|
321
322
|
//# sourceMappingURL=SceneCanvas.js.map
|