@weasel-js/editing 1.19.1 → 2.0.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/README.md +23 -11
- package/dist/actionGroups.js +27 -0
- package/dist/actionGroups.js.map +1 -0
- package/dist/actions/align/action.js +12 -9
- package/dist/actions/align/action.js.map +1 -1
- package/dist/actions/align/align.js +5 -4
- package/dist/actions/align/align.js.map +1 -1
- package/dist/actions/clipboard/action.js +10 -7
- package/dist/actions/clipboard/action.js.map +1 -1
- package/dist/actions/clone/action.js +217 -0
- package/dist/actions/clone/action.js.map +1 -0
- package/dist/actions/clone/behaviors.js +65 -0
- package/dist/actions/clone/behaviors.js.map +1 -0
- package/dist/actions/delete/delete.js +123 -0
- package/dist/actions/delete/delete.js.map +1 -0
- package/dist/actions/derivedBox.js +16 -0
- package/dist/actions/derivedBox.js.map +1 -0
- package/dist/actions/distribute/action.js +6 -3
- package/dist/actions/distribute/action.js.map +1 -1
- package/dist/actions/distribute/distribute.js +3 -2
- package/dist/actions/distribute/distribute.js.map +1 -1
- package/dist/actions/distribute/plan.js.map +1 -1
- package/dist/actions/edit/createPaintAction.js +42 -13
- package/dist/actions/edit/createPaintAction.js.map +1 -1
- package/dist/actions/edit/{escape.js → deselect.js} +8 -8
- package/dist/actions/edit/deselect.js.map +1 -0
- package/dist/actions/edit/duplicate.js +9 -7
- package/dist/actions/edit/duplicate.js.map +1 -1
- package/dist/actions/edit/group.js +24 -20
- package/dist/actions/edit/group.js.map +1 -1
- package/dist/actions/edit/ingest.js +4 -2
- package/dist/actions/edit/ingest.js.map +1 -1
- package/dist/actions/edit/nudge.js +14 -10
- package/dist/actions/edit/nudge.js.map +1 -1
- package/dist/actions/edit/selectAll.js +1 -1
- package/dist/actions/edit/setFill.js +1 -1
- package/dist/actions/edit/setFill.js.map +1 -1
- package/dist/actions/edit/setFillOpacity.js +5 -5
- package/dist/actions/edit/setFillOpacity.js.map +1 -1
- package/dist/actions/edit/setStroke.js +1 -1
- package/dist/actions/edit/setStroke.js.map +1 -1
- package/dist/actions/edit/setStrokeOpacity.js +6 -6
- package/dist/actions/edit/setStrokeOpacity.js.map +1 -1
- package/dist/actions/edit/setStrokeWidth.js +13 -8
- package/dist/actions/edit/setStrokeWidth.js.map +1 -1
- package/dist/actions/edit/setVertexColor.js +13 -6
- package/dist/actions/edit/setVertexColor.js.map +1 -1
- package/dist/actions/flip/action.js +19 -14
- package/dist/actions/flip/action.js.map +1 -1
- package/dist/actions/flip/helpers.js.map +1 -1
- package/dist/actions/group/enterGroup.js +81 -0
- package/dist/actions/group/enterGroup.js.map +1 -0
- package/dist/actions/insert/action.js +152 -0
- package/dist/actions/insert/action.js.map +1 -0
- package/dist/actions/insert/commit.js +52 -0
- package/dist/actions/insert/commit.js.map +1 -0
- package/dist/actions/insert/extras.js +88 -0
- package/dist/actions/insert/extras.js.map +1 -0
- package/dist/actions/insert/frame.js +96 -0
- package/dist/actions/insert/frame.js.map +1 -0
- package/dist/actions/insert/geometry.js +35 -0
- package/dist/actions/insert/geometry.js.map +1 -0
- package/dist/actions/insert/lands.js +41 -0
- package/dist/actions/insert/lands.js.map +1 -0
- package/dist/actions/insert/params.js +42 -0
- package/dist/actions/insert/params.js.map +1 -0
- package/dist/actions/insert/placeAction.js +137 -0
- package/dist/actions/insert/placeAction.js.map +1 -0
- package/dist/actions/insert/repositionAction.js +47 -0
- package/dist/actions/insert/repositionAction.js.map +1 -0
- package/dist/actions/insert/rotateAction.js +34 -0
- package/dist/actions/insert/rotateAction.js.map +1 -0
- package/dist/actions/insert/session.js +99 -0
- package/dist/actions/insert/session.js.map +1 -0
- package/dist/actions/insert/shape.js +117 -0
- package/dist/actions/insert/shape.js.map +1 -0
- package/dist/actions/insert/style.js +23 -0
- package/dist/actions/insert/style.js.map +1 -0
- package/dist/actions/lassoSelect/action.js +201 -0
- package/dist/actions/lassoSelect/action.js.map +1 -0
- package/dist/actions/lassoSelect/behaviors/selectFromLasso.js +61 -0
- package/dist/actions/lassoSelect/behaviors/selectFromLasso.js.map +1 -0
- package/dist/actions/lockedWrites.js +20 -0
- package/dist/actions/lockedWrites.js.map +1 -0
- package/dist/actions/move/action.js +138 -0
- package/dist/actions/move/action.js.map +1 -0
- package/dist/actions/move/behaviors/clampMove.js +42 -0
- package/dist/actions/move/behaviors/clampMove.js.map +1 -0
- package/dist/actions/move/behaviors/layoutDrop.js +84 -0
- package/dist/actions/move/behaviors/layoutDrop.js.map +1 -0
- package/dist/actions/move/behaviors/pageDrop.js +30 -0
- package/dist/actions/move/behaviors/pageDrop.js.map +1 -0
- package/dist/actions/move/behaviors/reparentOnDrop.js +44 -0
- package/dist/actions/move/behaviors/reparentOnDrop.js.map +1 -0
- package/dist/actions/move/behaviors/snapBackOrDelete.js +52 -0
- package/dist/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
- package/dist/actions/move/behaviors/snapToContainer.js +214 -0
- package/dist/actions/move/behaviors/snapToContainer.js.map +1 -0
- package/dist/actions/move/behaviors/swapOnDrop.js +180 -0
- package/dist/actions/move/behaviors/swapOnDrop.js.map +1 -0
- package/dist/actions/move/capture.js +116 -0
- package/dist/actions/move/capture.js.map +1 -0
- package/dist/actions/move/commit/index.js +47 -0
- package/dist/actions/move/commit/index.js.map +1 -0
- package/dist/actions/move/commit/layoutDrop.js +68 -0
- package/dist/actions/move/commit/layoutDrop.js.map +1 -0
- package/dist/actions/move/commit/layoutRelease.js +146 -0
- package/dist/actions/move/commit/layoutRelease.js.map +1 -0
- package/dist/actions/move/commit/pageDrop.js +162 -0
- package/dist/actions/move/commit/pageDrop.js.map +1 -0
- package/dist/actions/move/commit/rebase.js +24 -0
- package/dist/actions/move/commit/rebase.js.map +1 -0
- package/dist/actions/move/commit/reparent.js +157 -0
- package/dist/actions/move/commit/reparent.js.map +1 -0
- package/dist/actions/move/delta.js +127 -0
- package/dist/actions/move/delta.js.map +1 -0
- package/dist/actions/move/dragSnap.js +55 -0
- package/dist/actions/move/dragSnap.js.map +1 -0
- package/dist/actions/move/frame.js +67 -0
- package/dist/actions/move/frame.js.map +1 -0
- package/dist/actions/move/gestureAdapter.js +36 -0
- package/dist/actions/move/gestureAdapter.js.map +1 -0
- package/dist/actions/move/landedDescendants.js +50 -0
- package/dist/actions/move/landedDescendants.js.map +1 -0
- package/dist/actions/move/layout/container.js +119 -0
- package/dist/actions/move/layout/container.js.map +1 -0
- package/dist/actions/move/layout/dragged.js +75 -0
- package/dist/actions/move/layout/dragged.js.map +1 -0
- package/dist/actions/move/layout/dropPass.js +205 -0
- package/dist/actions/move/layout/dropPass.js.map +1 -0
- package/dist/actions/move/layout/exits.js +62 -0
- package/dist/actions/move/layout/exits.js.map +1 -0
- package/dist/actions/move/layout/glide.js +70 -0
- package/dist/actions/move/layout/glide.js.map +1 -0
- package/dist/actions/move/layout/view.js +60 -0
- package/dist/actions/move/layout/view.js.map +1 -0
- package/dist/actions/move/refusal.js +49 -0
- package/dist/actions/move/refusal.js.map +1 -0
- package/dist/actions/move/session.js +105 -0
- package/dist/actions/move/session.js.map +1 -0
- package/dist/actions/move/sessionOf.js +27 -0
- package/dist/actions/move/sessionOf.js.map +1 -0
- package/dist/actions/move/translate.js +49 -0
- package/dist/actions/move/translate.js.map +1 -0
- package/dist/actions/pathfinder/action.js +8 -6
- package/dist/actions/pathfinder/action.js.map +1 -1
- package/dist/actions/pathfinder/booleanGroupAction.js +16 -10
- package/dist/actions/pathfinder/booleanGroupAction.js.map +1 -1
- package/dist/actions/pathfinder/keymap.js +2 -2
- package/dist/actions/pathfinder/keymap.js.map +1 -1
- package/dist/actions/reorder/reorder.js +13 -11
- package/dist/actions/reorder/reorder.js.map +1 -1
- package/dist/actions/resize/action.js +105 -0
- package/dist/actions/resize/action.js.map +1 -0
- package/dist/actions/resize/aspect.js +42 -0
- package/dist/actions/resize/aspect.js.map +1 -0
- package/dist/actions/resize/behaviors/clampMinSize.js +100 -0
- package/dist/actions/resize/behaviors/clampMinSize.js.map +1 -0
- package/dist/actions/resize/boxFrame.js +19 -0
- package/dist/actions/resize/boxFrame.js.map +1 -0
- package/dist/actions/resize/capture.js +121 -0
- package/dist/actions/resize/capture.js.map +1 -0
- package/dist/actions/resize/commit.js +104 -0
- package/dist/actions/resize/commit.js.map +1 -0
- package/dist/actions/resize/frame.js +171 -0
- package/dist/actions/resize/frame.js.map +1 -0
- package/dist/actions/resize/held.js +44 -0
- package/dist/actions/resize/held.js.map +1 -0
- package/dist/actions/resize/minimum.js +34 -0
- package/dist/actions/resize/minimum.js.map +1 -0
- package/dist/actions/resize/replay.js +58 -0
- package/dist/actions/resize/replay.js.map +1 -0
- package/dist/actions/resize/ruleBounds.js +11 -0
- package/dist/actions/resize/ruleBounds.js.map +1 -0
- package/dist/actions/resize/session.js +118 -0
- package/dist/actions/resize/session.js.map +1 -0
- package/dist/actions/rotate/action.js +99 -0
- package/dist/actions/rotate/action.js.map +1 -0
- package/dist/actions/rotate/commit.js +48 -0
- package/dist/actions/rotate/commit.js.map +1 -0
- package/dist/actions/rotate/frame.js +96 -0
- package/dist/actions/rotate/frame.js.map +1 -0
- package/dist/actions/rotate/replay.js +25 -0
- package/dist/actions/rotate/replay.js.map +1 -0
- package/dist/actions/rotate/session.js +135 -0
- package/dist/actions/rotate/session.js.map +1 -0
- package/dist/actions/select/areaSelect.js +83 -0
- package/dist/actions/select/areaSelect.js.map +1 -0
- package/dist/actions/select/clearSelection.js +33 -0
- package/dist/actions/select/clearSelection.js.map +1 -0
- package/dist/actions/swap/action.js +63 -0
- package/dist/actions/swap/action.js.map +1 -0
- package/dist/actions/swap/swapOps.js +160 -0
- package/dist/actions/swap/swapOps.js.map +1 -0
- package/dist/actions/transformAgain/action.js +16 -14
- package/dist/actions/transformAgain/action.js.map +1 -1
- package/dist/actions/transformAgain/transformSelection.js +19 -5
- package/dist/actions/transformAgain/transformSelection.js.map +1 -1
- package/dist/booleans/booleans.js +130 -0
- package/dist/booleans/booleans.js.map +1 -0
- package/dist/booleans/commit.js +45 -0
- package/dist/booleans/commit.js.map +1 -0
- package/dist/booleans/custom.js +48 -0
- package/dist/booleans/custom.js.map +1 -0
- package/dist/booleans/operands.js +50 -0
- package/dist/booleans/operands.js.map +1 -0
- package/dist/booleans/pieces.js +43 -0
- package/dist/booleans/pieces.js.map +1 -0
- package/dist/booleans/placement.js +37 -0
- package/dist/booleans/placement.js.map +1 -0
- package/dist/booleans/useBooleans.js +34 -0
- package/dist/booleans/useBooleans.js.map +1 -0
- package/dist/booleans/useBooleansAdapter.js +11 -0
- package/dist/booleans/useBooleansAdapter.js.map +1 -0
- package/dist/chrome/affordances/cornerResize.js +123 -0
- package/dist/chrome/affordances/cornerResize.js.map +1 -0
- package/dist/chrome/affordances/rotateCursor.js +17 -0
- package/dist/chrome/affordances/rotateCursor.js.map +1 -0
- package/dist/chrome/affordances/rotationHandle.js +117 -0
- package/dist/chrome/affordances/rotationHandle.js.map +1 -0
- package/dist/chrome/handleCommands.js +110 -0
- package/dist/chrome/handleCommands.js.map +1 -0
- package/dist/chrome/overlay.js +271 -0
- package/dist/chrome/overlay.js.map +1 -0
- package/dist/chrome/rotationBadge.js +132 -0
- package/dist/chrome/rotationBadge.js.map +1 -0
- package/dist/chrome/rotationHandleGeometry.js +49 -0
- package/dist/chrome/rotationHandleGeometry.js.map +1 -0
- package/dist/chrome/selectionChrome.js +25 -0
- package/dist/chrome/selectionChrome.js.map +1 -0
- package/dist/chrome/selectionPose.js +112 -0
- package/dist/chrome/selectionPose.js.map +1 -0
- package/dist/chrome/shapeOutline.js +137 -0
- package/dist/chrome/shapeOutline.js.map +1 -0
- package/dist/clipboard/clipboardOps.js +48 -0
- package/dist/clipboard/clipboardOps.js.map +1 -0
- package/dist/clipboard/materializePaste.js +34 -0
- package/dist/clipboard/materializePaste.js.map +1 -0
- package/dist/clipboard/osClipboard.js +67 -0
- package/dist/clipboard/osClipboard.js.map +1 -0
- package/dist/clipboard/useClipboard.js +64 -0
- package/dist/clipboard/useClipboard.js.map +1 -0
- package/dist/clipboard/wireFormat.js +108 -0
- package/dist/clipboard/wireFormat.js.map +1 -0
- package/dist/deps/areaSelect.js +42 -0
- package/dist/deps/areaSelect.js.map +1 -0
- package/dist/deps/booleans.js +99 -0
- package/dist/deps/booleans.js.map +1 -0
- package/dist/deps/insert.js +260 -0
- package/dist/deps/insert.js.map +1 -0
- package/dist/deps/lassoSelect.js +37 -0
- package/dist/deps/lassoSelect.js.map +1 -0
- package/dist/deps/presetDeps.js +40 -0
- package/dist/deps/presetDeps.js.map +1 -0
- package/dist/deps/resizePolicy.js +41 -0
- package/dist/deps/resizePolicy.js.map +1 -0
- package/dist/engine-BV9RDHOL.d.ts +339 -0
- package/dist/engine.d.ts +6 -0
- package/dist/engine.js +10 -0
- package/dist/engineStandardActions.js +16 -7
- package/dist/engineStandardActions.js.map +1 -1
- package/dist/groups.d.ts +27 -0
- package/dist/groups.js +4 -0
- package/dist/icons.gen.js +8 -0
- package/dist/icons.gen.js.map +1 -0
- package/dist/icons.table.d.ts +6 -0
- package/dist/icons.table.js +8 -0
- package/dist/icons.table.js.map +1 -0
- package/dist/icons.table.json +156 -0
- package/dist/icons2.table.js +163 -0
- package/dist/icons2.table.js.map +1 -0
- package/dist/index.d.ts +1293 -105
- package/dist/index.js +61 -12
- package/dist/ingest/ghost.js +58 -0
- package/dist/ingest/ghost.js.map +1 -0
- package/dist/ingest/imageHandler.js +80 -0
- package/dist/ingest/imageHandler.js.map +1 -0
- package/dist/ingest/kitHandlers.js +15 -0
- package/dist/ingest/kitHandlers.js.map +1 -0
- package/dist/ingest/svgHandler.js +97 -0
- package/dist/ingest/svgHandler.js.map +1 -0
- package/dist/ingest/weaselJsonHandler.js +68 -0
- package/dist/ingest/weaselJsonHandler.js.map +1 -0
- package/dist/namedPresets.js +23 -11
- package/dist/namedPresets.js.map +1 -1
- package/dist/presets/arrange.js +21 -7
- package/dist/presets/arrange.js.map +1 -1
- package/dist/presets/booleans.js +13 -0
- package/dist/presets/booleans.js.map +1 -0
- package/dist/presets/composites.js +8 -5
- package/dist/presets/composites.js.map +1 -1
- package/dist/presets/edit.js +25 -13
- package/dist/presets/edit.js.map +1 -1
- package/dist/presets/ingest.js +7 -3
- package/dist/presets/ingest.js.map +1 -1
- package/dist/presets/insert.js +28 -0
- package/dist/presets/insert.js.map +1 -0
- package/dist/presets/pathfinder.js +5 -2
- package/dist/presets/pathfinder.js.map +1 -1
- package/dist/presets/select.js +16 -3
- package/dist/presets/select.js.map +1 -1
- package/dist/presets/selection.js +13 -0
- package/dist/presets/selection.js.map +1 -0
- package/dist/presets/selectionChrome.js +15 -0
- package/dist/presets/selectionChrome.js.map +1 -0
- package/dist/presets/tools.js +78 -9
- package/dist/presets/tools.js.map +1 -1
- package/dist/presets/transform.js +20 -7
- package/dist/presets/transform.js.map +1 -1
- package/dist/presets.d.ts +104 -0
- package/dist/presets.js +15 -0
- package/dist/selection/useSelection.js +127 -0
- package/dist/selection/useSelection.js.map +1 -0
- package/dist/test-seams.d.ts +50 -0
- package/dist/test-seams.js +4 -0
- package/dist/tools/ellipse/useEllipseTool.js +72 -0
- package/dist/tools/ellipse/useEllipseTool.js.map +1 -0
- package/dist/tools/eyedropper/useEyedropperTool.js +100 -0
- package/dist/tools/eyedropper/useEyedropperTool.js.map +1 -0
- package/dist/tools/image/useImageTool.js +57 -0
- package/dist/tools/image/useImageTool.js.map +1 -0
- package/dist/tools/lasso/useLassoTool.js +96 -0
- package/dist/tools/lasso/useLassoTool.js.map +1 -0
- package/dist/tools/line/useLineTool.js +67 -0
- package/dist/tools/line/useLineTool.js.map +1 -0
- package/dist/tools/polygon/usePolygonTool.js +149 -0
- package/dist/tools/polygon/usePolygonTool.js.map +1 -0
- package/dist/tools/rect/useRectTool.js +74 -0
- package/dist/tools/rect/useRectTool.js.map +1 -0
- package/dist/tools/select/adapterPointQuery.js +56 -0
- package/dist/tools/select/adapterPointQuery.js.map +1 -0
- package/dist/tools/select/collapseDeferred.js +35 -0
- package/dist/tools/select/collapseDeferred.js.map +1 -0
- package/dist/tools/select/extendPressLocked.js +17 -0
- package/dist/tools/select/extendPressLocked.js.map +1 -0
- package/dist/tools/select/groupEntry.js +73 -0
- package/dist/tools/select/groupEntry.js.map +1 -0
- package/dist/tools/select/pressDecision.js +39 -0
- package/dist/tools/select/pressDecision.js.map +1 -0
- package/dist/tools/select/selectDeep.js +39 -0
- package/dist/tools/select/selectDeep.js.map +1 -0
- package/dist/tools/select/selectPick.js +60 -0
- package/dist/tools/select/selectPick.js.map +1 -0
- package/dist/tools/select/selectionContributions.js +191 -0
- package/dist/tools/select/selectionContributions.js.map +1 -0
- package/dist/tools/select/usePickerSelectTool.js +145 -0
- package/dist/tools/select/usePickerSelectTool.js.map +1 -0
- package/dist/tools/select/useSelectTool.js +54 -0
- package/dist/tools/select/useSelectTool.js.map +1 -0
- package/dist/tools/shared/countOption.js +24 -0
- package/dist/tools/shared/countOption.js.map +1 -0
- package/dist/tools/shared/insertToolOptions.js +8 -0
- package/dist/tools/shared/insertToolOptions.js.map +1 -0
- package/dist/tools/shared/pointerFollower.js +23 -0
- package/dist/tools/shared/pointerFollower.js.map +1 -0
- package/dist/tools/shared/styleOptions.js +76 -0
- package/dist/tools/shared/styleOptions.js.map +1 -0
- package/dist/tools/star/useStarTool.js +149 -0
- package/dist/tools/star/useStarTool.js.map +1 -0
- package/dist/tools/toolSets.js +26 -0
- package/dist/tools/toolSets.js.map +1 -0
- package/package.json +39 -11
- package/dist/actions/edit/escape.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePickerSelectTool.js","names":[],"sources":["../../../src/tools/select/usePickerSelectTool.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { View, Tool } from '@weasel-js/core';\nimport type { LayerEnumerableAdapter, MoveAdapter, AreaSelectAdapter, PoseDescriptor } from '@weasel-js/core/engine';\nimport { defineTool, topmostOf, rangeAmong } from '@weasel-js/core';\nimport type { WorldPoint } from '@weasel-js/routing';\nimport { ANY_MODS } from '@weasel-js/gestures';\nimport { createSelectPickAction } from './selectPick';\nimport { createCollapseDeferredAction, type DeferredClick } from './collapseDeferred';\nimport { GROUP_LEAVE_PRESS_BINDING } from './groupEntry';\nimport { createSelectDeepAction } from './selectDeep';\nimport { isBodyOffChrome, isEmptyOffChrome } from './selectionContributions';\nimport { icon } from '../../icons.gen';\nimport type {} from '@weasel-js/core';\n\n/** Options for `useSelectTool`: how a point resolves to nodes, how a click\n * chooses among them, and the appearance of the marquee. */\nexport interface UseSelectToolOptions<TPose> {\n /** Return ids of all objects whose painted body covers `world`.\n * Order doesn't matter — the tool collapses parent/child overlap via\n * `topmostOf`. When omitted, defaults to an AABB-vs-point walk of\n * the adapter's tree using the pose descriptor. Override for tighter\n * shapes (path / polygon hit-tests). `viewId` is the view the press\n * landed in, where the host routes views. */\n pickEvery?: (world: WorldPoint, viewId?: string | null) => string[];\n /** Optional alt-aware selection-update hit returning the single id the\n * click should act on. */\n pickBest?: (world: WorldPoint, alt: boolean, selection: readonly string[], viewId?: string | null) => string | null;\n /** How to read poses for the default `pickEvery` and `between`. Default\n * `AUTO_POSE_DESCRIPTOR`. */\n poseDescriptor?: PoseDescriptor<TPose>;\n /**\n * How the default `pickEvery` decides a **leaf** node covers the pointer.\n * Ignored when `pickEvery` is supplied.\n *\n * - `'aabb'` (default) — the pose rect: a click anywhere in the bounding\n * box selects the node.\n * - `'silhouette'` — the pose rect as a pre-test, then the ink the painter\n * lays down: `findShapeSilhouette` filled or not per the painter's `ink`,\n * plus its outline widened by the stroke half-width and `pickTolerance`.\n * A click inside the bounding box but outside the drawn shape misses —\n * the concave notch of a star, the corner outside an ellipse, the blank\n * half of a text box — while a click on the thin outline of an unfilled\n * shape hits.\n *\n * Container nodes already consult their silhouette unconditionally (it is\n * how their clip is derived). A painter with no `silhouette` falls back to\n * the AABB.\n */\n leafPicking?: 'aabb' | 'silhouette';\n /**\n * Grab slop around a shape's outline, in **world** units. Default 0.\n *\n * Consulted under `leafPicking: 'silhouette'`, and under `'aabb'` for a node\n * that derives its path (a connector route), as slop around that path's\n * box: a straight horizontal or vertical route has a box with no area, and\n * is hit only within this distance of its line. World units because\n * this hook has no view; `<SceneCanvas>` takes a screen-pixel figure\n * (`geometry.pickTolerancePx`) and divides by scale on its own pick path.\n * Without some slop a hairline outline is an unhittable target.\n */\n pickTolerance?: number;\n /** Painted alpha per node in the view this tool picks for. A node painted\n * at alpha 0 is not under the pointer, nor in a range. Read by the default\n * `pickEvery` and `between`. */\n alphaOf?: (id: string) => number;\n /** Whether a node's `layer` reaches the screen in the view this tool picks\n * for. Read by the default `pickEvery` and `between`. */\n layerIsPainted?: (layer: string) => boolean;\n /** The camera of the view this tool picks for. With it, a node on an\n * adapter layer carrying `parallax` (`getLayers`) is picked where that\n * camera's plane paints it; without it, every layer is taken to move with\n * the camera. Ignored when `pickEvery` is supplied. */\n getView?: () => View | null;\n /**\n * When this returns true, a toggle or range click must NOT change the\n * node selection.\n *\n * `<SceneCanvas>` wires it to \"a path is in anchor-edit mode\", where\n * Shift-click means \"add this anchor to the anchor selection\". Without\n * the lock the same click also toggles the edited node out of the node\n * selection, and the `editAnchors` dep treats that as the edit target\n * disappearing.\n *\n * Only extend-clicks are locked. A plain click still re-selects, so\n * clicking a different node exits edit mode as usual.\n */\n extendClickLocked?: () => boolean;\n /**\n * The nodes a range from `from` to `to` covers. The tool keeps those a press there could\n * select itself, so a range takes a group whole, and inside an entered group stays in it.\n * `useSelectTool` defaults it to every node whose center lies in the box the two span;\n * without it a range walks the selection's own order.\n */\n between?: (from: string, to: string) => readonly string[];\n}\n\n/** Intersection of the move + area-select adapter interfaces.\n * Resize and rotate run through `resizeAction` / `rotateAction`. */\nexport type SelectAdapter<TNode extends { id: string }, TPose> =\n MoveAdapter<TNode, TPose>\n & AreaSelectAdapter\n & LayerEnumerableAdapter;\n\n/**\n * What the press classified, carried from `select.pick` (pointerDown) to\n * `select.collapseDeferred` (click) and to the tool's cursor.\n *\n * This is tool-local bookkeeping between two dispatches of the same gesture,\n * so it lives in a ref the tool owns rather than in dispatcher state.\n *\n * @internal\n */\ninterface PressClassification {\n /**\n * Set when a press with no extend modifier hit an already-selected node\n * inside a multi-selection, or a node inside a selected group.\n *\n * The selection is deliberately NOT collapsed on the press: the user may be\n * starting a drag of the whole set, or of the group. If the gesture turns out to be a click,\n * `select.collapseDeferred` collapses to this id on release, with the press's modifiers.\n */\n deferred: DeferredClick | null;\n}\n\n\n\n/** The routed view as a trailing argument, or none: a pick no view was routed for is asked as before. */\nfunction routed(viewId: string | null | undefined): [] | [string | null] {\n return viewId === undefined ? [] : [viewId];\n}\n\n// Declarative bindings for the gesture dispatcher. The select tool\n// only chooses: press → classify + select, release → collapse a\n// deferred multi-click, empty drag → marquee, click on empty → clear.\n// Moving, cloning, resizing and rotating the selection are ambient\n// bindings owned by the selection (`selectionContributions.ts`), so\n// they run under any tool that leaves the gesture unclaimed.\nconst SELECT_TOOL_BINDINGS = [\n // Cmd+Alt-press selects the node itself, past every group. It outranks\n // `select.pick` because a required modifier counts in specificity.\n {\n spec: {\n kind: 'pointerDown' as const,\n target: { kindOf: isBodyOffChrome },\n mods: { mod: true, alt: true, shift: 'optional' as const },\n },\n actionId: 'select.deep',\n opts: { id: 'select.deep' },\n },\n // Every press that landed on the scene rather than on chrome. It\n // classifies the press and applies the selection change, and it does\n // not consume the gesture — the same press goes on to open a drag or\n // synthesize a click.\n //\n // The no-affordance target is load-bearing twice over. A press on a\n // resize handle, a rotate ring, a path anchor, or a registered\n // layer's own chrome is not a body pick, and re-picking underneath\n // it would change the selection the user was about to act on. And\n // because it is expressed in the SPEC rather than as an early\n // return in the action, the press falls through to whatever owns\n // that chrome instead of being consumed here — which is how an\n // ambient binding (`@weasel-js/hud`) gets to see it at all.\n //\n // Modifiers are all `'optional'` because they are *data* here\n // (forwarded to `SelectionApi.applyClick`) rather than a route.\n {\n spec: {\n kind: 'pointerDown' as const,\n target: { kindOf: isBodyOffChrome },\n mods: ANY_MODS,\n },\n actionId: 'select.pick',\n opts: { id: 'select.pick' },\n },\n // Release half of the deferred multi-click, modifiers as above. On a node\n // only: a drag leaves a deferral unspent, and a click on empty must clear.\n {\n spec: {\n kind: 'click' as const,\n target: { kindOf: isBodyOffChrome },\n mods: ANY_MODS,\n },\n actionId: 'select.collapseDeferred',\n opts: { id: 'select.collapseDeferred' },\n },\n GROUP_LEAVE_PRESS_BINDING,\n // Empty drag → marquee, adding to the selection with Shift held. `isEmptyOffChrome` rather than a bare `'empty'`\n // target: the ambient bindings that own the handles rank below this\n // active one, so `'empty'` took drags that start on them.\n {\n spec: { kind: 'drag' as const, target: { kindOf: isEmptyOffChrome }, mods: { shift: 'optional' as const } },\n actionId: 'areaSelect',\n opts: { id: 'select.marquee' },\n },\n // resize/rotate bind only drag (no click), so a click on either handle\n // (body genuinely empty) would hit target:'empty' and wrongly clear selection.\n {\n spec: { kind: 'click' as const, target: { kindOf: isEmptyOffChrome }, mods: {} },\n actionId: 'clearSelection',\n opts: { id: 'select.clearOnClick' },\n },\n];\n\n/** The select tool over a picker the host supplies (`pickEvery`), with no\n * 2D default: what a host that is not a 2D canvas builds on. `useSelectTool`\n * is this with the kit's adapter walk as the default picker.\n *\n * Active-slot Tool:\n * - `select.pick` classifies the press (pointerDown) — it runs the tool's own\n * pickBest/pickEvery so click semantics (selection replace, extend,\n * deferred collapse) live in one place.\n * - an empty drag marquees (`areaSelect`) and a click on empty clears the\n * selection (`clearSelection`); the marquee renders via the dispatcher\n * overlay layer, driven by areaSelectAction's `overlay()`.\n * - moving and transforming the selection are not the tool's: they are the\n * ambient bindings in `selectionContributions.ts`.\n */\nexport function createPickerSelectTool<TNode extends { id: string }, TPose>(\n adapter: () => SelectAdapter<TNode, TPose>,\n options: () => UseSelectToolOptions<TPose> & Required<Pick<UseSelectToolOptions<TPose>, 'pickEvery'>>,\n): Tool {\n // What the last press classified. Written by `select.pick`, read by\n // `select.collapseDeferred` and the cursor. See `PressClassification`.\n const pressRef: { current: PressClassification } = { current: { deferred: null } };\n\n // The node under a point, before any group above it is considered.\n const pickHit = (world: WorldPoint, alt: boolean, sel: readonly string[], viewId?: string | null): string | null => {\n const opts = options();\n if (opts.pickBest) return opts.pickBest(world, alt, sel, ...routed(viewId));\n const ids = opts.pickEvery(world, ...routed(viewId));\n if (ids.length === 0) return null;\n return topmostOf(ids, adapter()) ?? ids[0];\n };\n\n const extendLocked = () => options().extendClickLocked?.() === true;\n const settled = () => { pressRef.current = { deferred: null }; };\n // A range among what a press inside `level` selects.\n const rangeIn = (level: string | null) => {\n const between = options().between;\n if (!between) return undefined;\n return rangeAmong(between, adapter(), level);\n };\n const deepAction = createSelectDeepAction({\n pickHit, extendLocked, settled, rangeAt: (hit) => rangeIn(adapter().getParent(hit)),\n });\n const pickAction = createSelectPickAction({\n pickHit, extendLocked, rangeIn,\n tree: () => adapter(),\n pressed: (deferred) => { pressRef.current = { deferred }; },\n });\n const collapseDeferredAction = createCollapseDeferredAction(pressRef);\n\n const base = defineTool({\n id: 'select',\n keybinding: { key: 'V' },\n capabilities: ['creates-selection'],\n hookName: 'useSelectTool',\n // The mid-gesture cursors live on the actions that own those gestures\n // (`moveAction.activeCursor`, `areaSelectAction.activeCursor`).\n cursor: 'default',\n presentation: {\n label: 'Select',\n icon: icon('select'),\n group: 'select',\n },\n actions: [pickAction, deepAction, collapseDeferredAction],\n });\n\n return { ...base, bindings: SELECT_TOOL_BINDINGS };\n}\n\n/** {@link createPickerSelectTool} for the life of the calling component, reading `adapter` and `options` live. */\nexport function usePickerSelectTool<TNode extends { id: string }, TPose>(\n adapter: SelectAdapter<TNode, TPose>,\n options: UseSelectToolOptions<TPose> & Required<Pick<UseSelectToolOptions<TPose>, 'pickEvery'>>,\n): Tool {\n const liveAdapter = useLatest(adapter);\n const liveOptions = useLatest(options);\n return useMemo(\n () => createPickerSelectTool(() => liveAdapter.current, () => liveOptions.current),\n [liveAdapter, liveOptions],\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgIA,CAAA,CAAA,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A,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA;AACrC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA;AACrC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA6B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CACjF,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAC3B,CAAA;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { adapterPointQuery } from "./adapterPointQuery.js";
|
|
2
|
+
import { createPickerSelectTool, usePickerSelectTool } from "./usePickerSelectTool.js";
|
|
3
|
+
import { adapterPickSource, centersBetween, createLayerPlaneLookup, pickWalk } from "@weasel-js/core";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { AUTO_POSE_DESCRIPTOR } from "@weasel-js/core/engine";
|
|
6
|
+
import { useLatest } from "@weasel-js/react";
|
|
7
|
+
|
|
8
|
+
// src/tools/select/useSelectTool.ts
|
|
9
|
+
/** The kit's picker for a bare adapter: a walk of its tree, each leaf tested
|
|
10
|
+
* against its pose box, or its painted silhouette under
|
|
11
|
+
* `leafPicking: 'silhouette'`. */
|
|
12
|
+
function adapterPickEvery(adapter, options) {
|
|
13
|
+
const d = options.poseDescriptor ?? AUTO_POSE_DESCRIPTOR;
|
|
14
|
+
const query = adapterPointQuery(d, options.leafPicking === "silhouette");
|
|
15
|
+
const tolerance = options.pickTolerance ?? 0;
|
|
16
|
+
return (world) => {
|
|
17
|
+
const camera = options.getView?.() ?? null;
|
|
18
|
+
const planeOf = camera ? createLayerPlaneLookup(adapter.getLayers?.(), camera) : null;
|
|
19
|
+
return pickWalk(adapterPickSource(adapter, {
|
|
20
|
+
...options.alphaOf ? { alphaOf: options.alphaOf } : {},
|
|
21
|
+
...options.layerIsPainted ? { layerIsPainted: options.layerIsPainted } : {},
|
|
22
|
+
...planeOf ? { planeOf } : {}
|
|
23
|
+
}), query(world.x, world.y, tolerance));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** The kit's range for a bare adapter: every node whose center lies in the box the two ends span. */
|
|
27
|
+
function adapterBetween(adapter, options) {
|
|
28
|
+
return centersBetween(adapter, options.poseDescriptor ?? AUTO_POSE_DESCRIPTOR, {
|
|
29
|
+
...options.alphaOf ? { alphaOf: options.alphaOf } : {},
|
|
30
|
+
...options.layerIsPainted ? { layerIsPainted: options.layerIsPainted } : {}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** The select tool: {@link createPickerSelectTool} with `options().pickEvery` and `options().between`, or the kit's
|
|
34
|
+
* adapter walks where they are omitted, read live. */
|
|
35
|
+
function createSelectTool(adapter, options) {
|
|
36
|
+
return createPickerSelectTool(adapter, () => {
|
|
37
|
+
const o = options();
|
|
38
|
+
const a = adapter();
|
|
39
|
+
return {
|
|
40
|
+
...o,
|
|
41
|
+
pickEvery: o.pickEvery ?? adapterPickEvery(a, o),
|
|
42
|
+
between: o.between ?? adapterBetween(a, o)
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** {@link createSelectTool} for the life of the calling component, reading `adapter` and `options` live. */
|
|
47
|
+
function useSelectTool(adapter, options) {
|
|
48
|
+
const liveAdapter = useLatest(adapter);
|
|
49
|
+
const liveOptions = useLatest(options);
|
|
50
|
+
return useMemo(() => createSelectTool(() => liveAdapter.current, () => liveOptions.current), [liveAdapter, liveOptions]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { createPickerSelectTool, createSelectTool, usePickerSelectTool, useSelectTool };
|
|
54
|
+
//# sourceMappingURL=useSelectTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectTool.js","names":[],"sources":["../../../src/tools/select/useSelectTool.ts"],"sourcesContent":["import type { WorldPoint } from '@weasel-js/routing';\nimport { pickWalk, adapterPickSource, createLayerPlaneLookup, centersBetween } from '@weasel-js/core';\nimport { AUTO_POSE_DESCRIPTOR } from '@weasel-js/core/engine';\nimport type { PoseDescriptor } from '@weasel-js/core/engine';\nimport type { Tool } from '@weasel-js/core';\nimport { adapterPointQuery } from './adapterPointQuery';\nimport { useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { createPickerSelectTool, type SelectAdapter, type UseSelectToolOptions } from './usePickerSelectTool';\n\nexport { createPickerSelectTool, usePickerSelectTool } from './usePickerSelectTool';\nexport type { SelectAdapter, UseSelectToolOptions } from './usePickerSelectTool';\n\n/** The kit's picker for a bare adapter: a walk of its tree, each leaf tested\n * against its pose box, or its painted silhouette under\n * `leafPicking: 'silhouette'`. */\nfunction adapterPickEvery<TNode extends { id: string }, TPose>(\n adapter: SelectAdapter<TNode, TPose>,\n options: UseSelectToolOptions<TPose>,\n): (world: WorldPoint) => string[] {\n const d = (options.poseDescriptor ?? AUTO_POSE_DESCRIPTOR) as PoseDescriptor<TPose>;\n const query = adapterPointQuery(d, options.leafPicking === 'silhouette');\n const tolerance = options.pickTolerance ?? 0;\n return (world) => {\n const camera = options.getView?.() ?? null;\n const planeOf = camera ? createLayerPlaneLookup(adapter.getLayers?.(), camera) : null;\n return pickWalk<TPose>(adapterPickSource(adapter, {\n ...(options.alphaOf ? { alphaOf: options.alphaOf } : {}),\n ...(options.layerIsPainted ? { layerIsPainted: options.layerIsPainted } : {}),\n ...(planeOf ? { planeOf } : {}),\n }), query(world.x, world.y, tolerance));\n };\n}\n\n/** The kit's range for a bare adapter: every node whose center lies in the box the two ends span. */\nfunction adapterBetween<TNode extends { id: string }, TPose>(\n adapter: SelectAdapter<TNode, TPose>,\n options: UseSelectToolOptions<TPose>,\n): (from: string, to: string) => string[] {\n return centersBetween<TPose>(adapter, (options.poseDescriptor ?? AUTO_POSE_DESCRIPTOR) as PoseDescriptor<TPose>, {\n ...(options.alphaOf ? { alphaOf: options.alphaOf } : {}),\n ...(options.layerIsPainted ? { layerIsPainted: options.layerIsPainted } : {}),\n });\n}\n\n/** The select tool: {@link createPickerSelectTool} with `options().pickEvery` and `options().between`, or the kit's\n * adapter walks where they are omitted, read live. */\nexport function createSelectTool<TNode extends { id: string }, TPose>(\n adapter: () => SelectAdapter<TNode, TPose>,\n options: () => UseSelectToolOptions<TPose>,\n): Tool {\n return createPickerSelectTool(adapter, () => {\n const o = options();\n const a = adapter();\n return { ...o, pickEvery: o.pickEvery ?? adapterPickEvery(a, o), between: o.between ?? adapterBetween(a, o) };\n });\n}\n\n/** {@link createSelectTool} for the life of the calling component, reading `adapter` and `options` live. */\nexport function useSelectTool<TNode extends { id: string }, TPose>(\n adapter: SelectAdapter<TNode, TPose>,\n options: UseSelectToolOptions<TPose>,\n): Tool {\n const liveAdapter = useLatest(adapter);\n const liveOptions = useLatest(options);\n return useMemo(() => createSelectTool(() => liveAdapter.current, () => liveOptions.current), [liveAdapter, liveOptions]);\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,iBACP,SACA,SACiC;CACjC,MAAM,IAAK,QAAQ,kBAAkB;CACrC,MAAM,QAAQ,kBAAkB,GAAG,QAAQ,gBAAgB,YAAY;CACvE,MAAM,YAAY,QAAQ,iBAAiB;CAC3C,QAAQ,UAAU;EAChB,MAAM,SAAS,QAAQ,UAAU,KAAK;EACtC,MAAM,UAAU,SAAS,uBAAuB,QAAQ,YAAY,GAAG,MAAM,IAAI;EACjF,OAAO,SAAgB,kBAAkB,SAAS;GAChD,GAAI,QAAQ,UAAU,EAAE,SAAS,QAAQ,QAAQ,IAAI,CAAC;GACtD,GAAI,QAAQ,iBAAiB,EAAE,gBAAgB,QAAQ,eAAe,IAAI,CAAC;GAC3E,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC/B,CAAC,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACxC;AACF;;AAGA,SAAS,eACP,SACA,SACwC;CACxC,OAAO,eAAsB,SAAU,QAAQ,kBAAkB,sBAAgD;EAC/G,GAAI,QAAQ,UAAU,EAAE,SAAS,QAAQ,QAAQ,IAAI,CAAC;EACtD,GAAI,QAAQ,iBAAiB,EAAE,gBAAgB,QAAQ,eAAe,IAAI,CAAC;CAC7E,CAAC;AACH;;;AAIA,SAAgB,iBACd,SACA,SACM;CACN,OAAO,uBAAuB,eAAe;EAC3C,MAAM,IAAI,QAAQ;EAClB,MAAM,IAAI,QAAQ;EAClB,OAAO;GAAE,GAAG;GAAG,WAAW,EAAE,aAAa,iBAAiB,GAAG,CAAC;GAAG,SAAS,EAAE,WAAW,eAAe,GAAG,CAAC;EAAE;CAC9G,CAAC;AACH;;AAGA,SAAgB,cACd,SACA,SACM;CACN,MAAM,cAAc,UAAU,OAAO;CACrC,MAAM,cAAc,UAAU,OAAO;CACrC,OAAO,cAAc,uBAAuB,YAAY,eAAe,YAAY,OAAO,GAAG,CAAC,aAAa,WAAW,CAAC;AACzH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { setToolOption, steppedOption, toolOptionNumberLeaf, toolOptionParams } from "@weasel-js/routing";
|
|
2
|
+
import { getOwn } from "@weasel-js/registry";
|
|
3
|
+
|
|
4
|
+
// src/tools/shared/countOption.ts
|
|
5
|
+
/** Step `toolId`'s count option `option` by one, up or down as `params` say: a key binding's `delta`, or a wheel's
|
|
6
|
+
* `deltaY`, where up (deltaY > 0 under natural scrolling) adds one. Held to the leaf's bounds. Returns whether it
|
|
7
|
+
* moved anything. */
|
|
8
|
+
function stepCountOption(toolId, options, option, values, params) {
|
|
9
|
+
const leaf = toolOptionNumberLeaf(options, option);
|
|
10
|
+
const step = params?.delta ?? (params?.deltaY ? Math.sign(params.deltaY) : 0);
|
|
11
|
+
if (!values || !leaf || step === 0) return false;
|
|
12
|
+
const current = getOwn(toolOptionParams(toolId, options, values), option);
|
|
13
|
+
const from = typeof current === "number" ? current : leaf.default ?? 0;
|
|
14
|
+
const next = steppedOption(leaf, from, {
|
|
15
|
+
option,
|
|
16
|
+
plus: 1
|
|
17
|
+
}, step > 0 ? 1 : -1);
|
|
18
|
+
if (next === from) return false;
|
|
19
|
+
setToolOption(toolId, options, values, option, next);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { stepCountOption };
|
|
24
|
+
//# sourceMappingURL=countOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countOption.js","names":[],"sources":["../../../src/tools/shared/countOption.ts"],"sourcesContent":["import { getOwn } from '@weasel-js/registry';\nimport type { CountStepParams } from '@weasel-js/core';\nimport { setToolOption, steppedOption, toolOptionNumberLeaf, toolOptionParams, type ToolOptionsSpec, type ToolOptionValues } from '@weasel-js/routing';\n\n/** Step `toolId`'s count option `option` by one, up or down as `params` say: a key binding's `delta`, or a wheel's\n * `deltaY`, where up (deltaY > 0 under natural scrolling) adds one. Held to the leaf's bounds. Returns whether it\n * moved anything. */\nexport function stepCountOption(\n toolId: string,\n options: ToolOptionsSpec,\n option: string,\n values: ToolOptionValues | undefined,\n params: Readonly<Partial<CountStepParams>> | undefined,\n): boolean {\n const leaf = toolOptionNumberLeaf(options, option);\n const step = params?.delta ?? (params?.deltaY ? Math.sign(params.deltaY) : 0);\n if (!values || !leaf || step === 0) return false;\n const current = getOwn(toolOptionParams(toolId, options, values), option);\n const from = typeof current === 'number' ? current : leaf.default ?? 0;\n const next = steppedOption(leaf, from, { option, plus: 1 }, step > 0 ? 1 : -1);\n if (next === from) return false;\n setToolOption(toolId, options, values, option, next);\n return true;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,gBACd,QACA,SACA,QACA,QACA,QACS;CACT,MAAM,OAAO,qBAAqB,SAAS,MAAM;CACjD,MAAM,OAAO,QAAQ,UAAU,QAAQ,SAAS,KAAK,KAAK,OAAO,MAAM,IAAI;CAC3E,IAAI,CAAC,UAAU,CAAC,QAAQ,SAAS,GAAG,OAAO;CAC3C,MAAM,UAAU,OAAO,iBAAiB,QAAQ,SAAS,MAAM,GAAG,MAAM;CACxE,MAAM,OAAO,OAAO,YAAY,WAAW,UAAU,KAAK,WAAW;CACrE,MAAM,OAAO,cAAc,MAAM,MAAM;EAAE;EAAQ,MAAM;CAAE,GAAG,OAAO,IAAI,IAAI,EAAE;CAC7E,IAAI,SAAS,MAAM,OAAO;CAC1B,cAAc,QAAQ,SAAS,QAAQ,QAAQ,IAAI;CACnD,OAAO;AACT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/tools/shared/insertToolOptions.ts
|
|
2
|
+
/** The insert binding's `opts.behaviors` entry, left out when there are none. */
|
|
3
|
+
function insertBindingBehaviors(behaviors) {
|
|
4
|
+
return behaviors?.length ? { behaviors: [...behaviors] } : {};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { insertBindingBehaviors };
|
|
8
|
+
//# sourceMappingURL=insertToolOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertToolOptions.js","names":[],"sources":["../../../src/tools/shared/insertToolOptions.ts"],"sourcesContent":["import type { BindingOptions, ToolOptionShare } from '@weasel-js/routing';\nimport type { InsertBehavior } from '@weasel-js/core/engine';\n\n/** Options every drag-to-insert tool takes. */\nexport interface InsertToolOptions {\n /** Behaviors `insertAction` runs over the drag's start and current point\n * after the snap session, in order. Keep the array stable across renders:\n * a new one rebuilds the tool. */\n behaviors?: readonly InsertBehavior<unknown>[];\n /** Laid over the tool's own option shares: `{ fill: null }` keeps this\n * tool's fill its own rather than the one every shape tool shares. Keep it\n * stable across renders: a new one rebuilds the tool. */\n share?: ToolOptionShare;\n}\n\n/** The insert binding's `opts.behaviors` entry, left out when there are none. */\nexport function insertBindingBehaviors(\n behaviors: InsertToolOptions['behaviors'],\n): Pick<BindingOptions, 'behaviors'> {\n return behaviors?.length ? { behaviors: [...behaviors] } : {};\n}\n"],"mappings":";;AAgBA,SAAgB,uBACd,WACmC;CACnC,OAAO,WAAW,SAAS,EAAE,WAAW,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC;AAC9D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/tools/shared/pointerFollower.ts
|
|
2
|
+
/** `onMove` runs after every change of the followed pointer. */
|
|
3
|
+
function createPointerFollower(onMove) {
|
|
4
|
+
let pointer = null;
|
|
5
|
+
let off = null;
|
|
6
|
+
return {
|
|
7
|
+
pointer: () => pointer,
|
|
8
|
+
follow(next) {
|
|
9
|
+
if (!next || next === pointer) return;
|
|
10
|
+
off?.();
|
|
11
|
+
pointer = next;
|
|
12
|
+
off = next.subscribe(onMove);
|
|
13
|
+
},
|
|
14
|
+
unfollow() {
|
|
15
|
+
off?.();
|
|
16
|
+
off = null;
|
|
17
|
+
pointer = null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { createPointerFollower };
|
|
23
|
+
//# sourceMappingURL=pointerFollower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerFollower.js","names":[],"sources":["../../../src/tools/shared/pointerFollower.ts"],"sourcesContent":["import type { PointerContextValue } from '@weasel-js/routing/react';\n\n/** A tool's subscription to the `pointer` dep, held only while it has\n * something trailing to the pointer. */\nexport interface PointerFollower {\n /** The store being followed, or `null`. */\n pointer(): PointerContextValue | null;\n /** Start following `next`; a no-op for the store already followed. */\n follow(next: PointerContextValue | undefined): void;\n unfollow(): void;\n}\n\n/** `onMove` runs after every change of the followed pointer. */\nexport function createPointerFollower(onMove: () => void): PointerFollower {\n let pointer: PointerContextValue | null = null;\n let off: (() => void) | null = null;\n return {\n pointer: () => pointer,\n follow(next) {\n if (!next || next === pointer) return;\n off?.();\n pointer = next;\n off = next.subscribe(onMove);\n },\n unfollow() {\n off?.();\n off = null;\n pointer = null;\n },\n };\n}\n"],"mappings":";;AAaA,SAAgB,sBAAsB,QAAqC;CACzE,IAAI,UAAsC;CAC1C,IAAI,MAA2B;CAC/B,OAAO;EACL,eAAe;EACf,OAAO,MAAM;GACX,IAAI,CAAC,QAAQ,SAAS,SAAS;GAC/B,MAAM;GACN,UAAU;GACV,MAAM,KAAK,UAAU,MAAM;EAC7B;EACA,WAAW;GACT,MAAM;GACN,MAAM;GACN,UAAU;EACZ;CACF;AACF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DEFAULT_STROKE_WIDTH } from "../../actions/insert/style.js";
|
|
2
|
+
import { isSolidPaint, paletteColorAt, solid, toHex8 } from "@weasel-js/paint";
|
|
3
|
+
|
|
4
|
+
// src/tools/shared/styleOptions.ts
|
|
5
|
+
/** The kit's color for a new shape: the first of its palette. */
|
|
6
|
+
var DEFAULT_SHAPE_PAINT = solid(paletteColorAt(0));
|
|
7
|
+
/** `paint` in the one spelling every tool option's color default takes: `solid`'s, six hex digits with any alpha
|
|
8
|
+
* as `opacity`, so `#000` and `#000000ff` read as one value. Any other paint comes back as it is. */
|
|
9
|
+
function toolOptionPaint(paint) {
|
|
10
|
+
if (!isSolidPaint(paint)) return paint;
|
|
11
|
+
const out = solid(toHex8(paint.color));
|
|
12
|
+
const opacity = (paint.opacity ?? 1) * (out.opacity ?? 1);
|
|
13
|
+
return opacity === 1 ? out : {
|
|
14
|
+
...out,
|
|
15
|
+
opacity
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var paintLeaf = (name, description, value) => ({
|
|
19
|
+
kind: "paint",
|
|
20
|
+
name,
|
|
21
|
+
description,
|
|
22
|
+
alpha: true,
|
|
23
|
+
default: toolOptionPaint(value)
|
|
24
|
+
});
|
|
25
|
+
/** Each style option's leaf, defaulting to `defaults`. */
|
|
26
|
+
function styleOptionLeaves(defaults, keys) {
|
|
27
|
+
const all = {
|
|
28
|
+
fill: paintLeaf("Fill", "What a new shape is filled with.", defaults.fill ?? null),
|
|
29
|
+
stroke: paintLeaf("Stroke", "What a new shape’s outline is painted with.", defaults.stroke ?? null),
|
|
30
|
+
strokeWidth: {
|
|
31
|
+
kind: "number",
|
|
32
|
+
name: "Stroke width",
|
|
33
|
+
description: "How thick a new shape’s outline is, in world units.",
|
|
34
|
+
default: defaults.strokeWidth ?? DEFAULT_STROKE_WIDTH,
|
|
35
|
+
min: 0,
|
|
36
|
+
max: 200,
|
|
37
|
+
step: .5
|
|
38
|
+
},
|
|
39
|
+
fillRule: {
|
|
40
|
+
kind: "enum",
|
|
41
|
+
name: "Fill rule",
|
|
42
|
+
description: "Which regions of a new path its fill covers.",
|
|
43
|
+
default: defaults.fillRule ?? "nonzero",
|
|
44
|
+
options: [{
|
|
45
|
+
value: "nonzero",
|
|
46
|
+
label: "Nonzero"
|
|
47
|
+
}, {
|
|
48
|
+
value: "evenodd",
|
|
49
|
+
label: "Even-odd"
|
|
50
|
+
}]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const key of keys) out[key] = all[key];
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** A shape tool's options: its style options, each shared under its own name, and its own beside them. */
|
|
58
|
+
function shapeToolOptions(spec) {
|
|
59
|
+
const share = {};
|
|
60
|
+
for (const key of spec.keys) share[key] = key;
|
|
61
|
+
return {
|
|
62
|
+
actionId: spec.actionId,
|
|
63
|
+
prefs: {
|
|
64
|
+
name: spec.name,
|
|
65
|
+
as: "bar",
|
|
66
|
+
children: {
|
|
67
|
+
...styleOptionLeaves(spec.style, spec.keys),
|
|
68
|
+
...spec.own
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
share
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { DEFAULT_SHAPE_PAINT, shapeToolOptions, styleOptionLeaves, toolOptionPaint };
|
|
76
|
+
//# sourceMappingURL=styleOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleOptions.js","names":[],"sources":["../../../src/tools/shared/styleOptions.ts"],"sourcesContent":["/**\n * The style a shape tool draws with, declared as its tool options: fill,\n * stroke, stroke width, and a path's fill rule. Each is shared under its own\n * name, so every shape tool reads one fill until a tool or its user keeps one\n * of its own (`share: { fill: null }`).\n */\nimport type { PrefGroup, PrefLeaf } from '@weasel-js/prefs-schema';\nimport { isSolidPaint, type Paint, paletteColorAt, solid, toHex8 } from '@weasel-js/paint';\nimport type { ToolOptionsSpec } from '@weasel-js/routing';\nimport { DEFAULT_STROKE_WIDTH } from '../../actions/insert/style';\nimport { type InsertStyle } from '../../actions/insert/style';\nimport { type StyleOptionKey } from '../../actions/insert/style';\n\n/** The kit's color for a new shape: the first of its palette. */\nexport const DEFAULT_SHAPE_PAINT: Paint = solid(paletteColorAt(0));\n\n/** `paint` in the one spelling every tool option's color default takes: `solid`'s, six hex digits with any alpha\n * as `opacity`, so `#000` and `#000000ff` read as one value. Any other paint comes back as it is. */\nexport function toolOptionPaint(paint: Paint | null): Paint | null {\n if (!isSolidPaint(paint)) return paint;\n const out = solid(toHex8(paint.color));\n const opacity = (paint.opacity ?? 1) * (out.opacity ?? 1);\n return opacity === 1 ? out : { ...out, opacity };\n}\n\nconst paintLeaf = (name: string, description: string, value: Paint | null): PrefLeaf => ({\n kind: 'paint', name, description, alpha: true, default: toolOptionPaint(value),\n});\n\n/** Each style option's leaf, defaulting to `defaults`. */\nexport function styleOptionLeaves(defaults: InsertStyle, keys: readonly StyleOptionKey[]): Record<string, PrefLeaf> {\n const all: Record<StyleOptionKey, PrefLeaf> = {\n fill: paintLeaf('Fill', 'What a new shape is filled with.', defaults.fill ?? null),\n stroke: paintLeaf('Stroke', 'What a new shape’s outline is painted with.', defaults.stroke ?? null),\n strokeWidth: {\n kind: 'number', name: 'Stroke width', description: 'How thick a new shape’s outline is, in world units.',\n default: defaults.strokeWidth ?? DEFAULT_STROKE_WIDTH, min: 0, max: 200, step: 0.5,\n },\n fillRule: {\n kind: 'enum', name: 'Fill rule', description: 'Which regions of a new path its fill covers.',\n default: defaults.fillRule ?? 'nonzero',\n options: [{ value: 'nonzero', label: 'Nonzero' }, { value: 'evenodd', label: 'Even-odd' }],\n },\n };\n const out: Record<string, PrefLeaf> = {};\n for (const key of keys) out[key] = all[key];\n return out;\n}\n\n/** What a shape tool declares about its options. */\nexport interface ShapeToolOptionsSpec {\n /** The action, or actions, the options are params of. */\n actionId: ToolOptionsSpec['actionId'];\n /** The options group's name: the tool's. */\n name: string;\n /** Which style options it takes, and their defaults. */\n style: InsertStyle;\n keys: readonly StyleOptionKey[];\n /** Its options besides the style ones, kept per tool. */\n own?: PrefGroup['children'];\n}\n\n/** A shape tool's options: its style options, each shared under its own name, and its own beside them. */\nexport function shapeToolOptions(spec: ShapeToolOptionsSpec): ToolOptionsSpec {\n const share: Record<string, string> = {};\n for (const key of spec.keys) share[key] = key;\n return {\n actionId: spec.actionId,\n prefs: { name: spec.name, as: 'bar', children: { ...styleOptionLeaves(spec.style, sp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AE;EAC5G;CACF;AACF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { insertBindingBehaviors } from "../shared/insertToolOptions.js";
|
|
2
|
+
import { DEFAULT_SHAPE_PAINT, shapeToolOptions } from "../shared/styleOptions.js";
|
|
3
|
+
import { stepCountOption } from "../shared/countOption.js";
|
|
4
|
+
import { INSERT_REPOSITION_BINDING } from "../../actions/insert/repositionAction.js";
|
|
5
|
+
import { STAR_INSERT_PARAMS } from "../../actions/insert/params.js";
|
|
6
|
+
import { INSERT_DRAG_MODS } from "../../actions/insert/action.js";
|
|
7
|
+
import { defineTool } from "@weasel-js/core";
|
|
8
|
+
import { defineAction, shareToolOptions, withToolOptionDefault } from "@weasel-js/routing";
|
|
9
|
+
import { useCallback, useMemo, useState } from "react";
|
|
10
|
+
import { cursorFor } from "@weasel-js/cursor";
|
|
11
|
+
|
|
12
|
+
// src/tools/star/useStarTool.tsx
|
|
13
|
+
/** The star tool's options: the style it draws with, shared with every shape tool, and its points and inner radius. */
|
|
14
|
+
var STAR_TOOL_OPTIONS = shapeToolOptions({
|
|
15
|
+
actionId: "insert",
|
|
16
|
+
name: "Star",
|
|
17
|
+
keys: [
|
|
18
|
+
"fill",
|
|
19
|
+
"stroke",
|
|
20
|
+
"strokeWidth",
|
|
21
|
+
"fillRule"
|
|
22
|
+
],
|
|
23
|
+
style: {
|
|
24
|
+
fill: DEFAULT_SHAPE_PAINT,
|
|
25
|
+
stroke: null
|
|
26
|
+
},
|
|
27
|
+
own: STAR_INSERT_PARAMS.children
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Drag-from-center star tool. Pointerdown sets center; drag determines
|
|
31
|
+
* outer radius + rotation; release commits via `insertAction`. Inner
|
|
32
|
+
* radius = outer × `innerRatio` (default 0.5). Point count defaults to
|
|
33
|
+
* 5, adjustable mid-gesture via ArrowUp/Down or wheel.
|
|
34
|
+
*
|
|
35
|
+
* Live preview painted by the dispatcher overlay layer reading
|
|
36
|
+
* `insertAction.overlay()`. Consumers wanting custom star geometry
|
|
37
|
+
* override the `insert` dep.
|
|
38
|
+
*
|
|
39
|
+
* A point change mid-drag calls `onCountChange`.
|
|
40
|
+
*/
|
|
41
|
+
function createStarTool(options = {}) {
|
|
42
|
+
const { points, innerRatio, label = "Star", behaviors, share } = options;
|
|
43
|
+
const toolOptions = withToolOptionDefault(withToolOptionDefault(shareToolOptions(STAR_TOOL_OPTIONS, share), "points", points), "innerRadiusRatio", innerRatio);
|
|
44
|
+
const adjust = defineAction({
|
|
45
|
+
id: "star.adjustPoints",
|
|
46
|
+
label: "Star — adjust points",
|
|
47
|
+
requires: ["toolOptionValues"],
|
|
48
|
+
invoker: {
|
|
49
|
+
timing: "immediate",
|
|
50
|
+
run: (deps, params) => {
|
|
51
|
+
if (stepCountOption("star", toolOptions, "points", deps.toolOptionValues, params)) options.onCountChange?.();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return defineTool({
|
|
56
|
+
id: "star",
|
|
57
|
+
capabilities: ["creates-shapes"],
|
|
58
|
+
hookName: "useStarTool",
|
|
59
|
+
options: toolOptions,
|
|
60
|
+
cursor: cursorFor("crosshair", {
|
|
61
|
+
mark: "star",
|
|
62
|
+
fallback: "crosshair"
|
|
63
|
+
}),
|
|
64
|
+
actions: [adjust],
|
|
65
|
+
presentation: {
|
|
66
|
+
label,
|
|
67
|
+
group: "shape",
|
|
68
|
+
icon: /* @icon */ "editing:star"
|
|
69
|
+
},
|
|
70
|
+
bindings: [
|
|
71
|
+
{
|
|
72
|
+
spec: {
|
|
73
|
+
kind: "drag",
|
|
74
|
+
mods: INSERT_DRAG_MODS
|
|
75
|
+
},
|
|
76
|
+
actionId: "insert",
|
|
77
|
+
opts: {
|
|
78
|
+
id: "star.drag",
|
|
79
|
+
params: { kind: "star" },
|
|
80
|
+
...insertBindingBehaviors(behaviors)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
INSERT_REPOSITION_BINDING,
|
|
84
|
+
{
|
|
85
|
+
spec: {
|
|
86
|
+
kind: "wheel",
|
|
87
|
+
phase: "engaged"
|
|
88
|
+
},
|
|
89
|
+
actionId: "star.adjustPoints",
|
|
90
|
+
opts: { id: "star.wheelPoints" }
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
spec: {
|
|
94
|
+
kind: "wheel",
|
|
95
|
+
phase: "engaged",
|
|
96
|
+
mods: { shift: true }
|
|
97
|
+
},
|
|
98
|
+
actionId: "insert.rotate",
|
|
99
|
+
opts: { id: "star.wheelRotation" }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
spec: {
|
|
103
|
+
kind: "key",
|
|
104
|
+
key: "ArrowUp"
|
|
105
|
+
},
|
|
106
|
+
actionId: "star.adjustPoints",
|
|
107
|
+
opts: {
|
|
108
|
+
id: "star.morePoints",
|
|
109
|
+
params: { delta: 1 }
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
spec: {
|
|
114
|
+
kind: "key",
|
|
115
|
+
key: "ArrowDown"
|
|
116
|
+
},
|
|
117
|
+
actionId: "star.adjustPoints",
|
|
118
|
+
opts: {
|
|
119
|
+
id: "star.fewerPoints",
|
|
120
|
+
params: { delta: -1 }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** {@link createStarTool}, kept while its options are, re-rendering its caller when the point count changes. */
|
|
127
|
+
function useStarTool(options = {}) {
|
|
128
|
+
const { points, innerRatio, label = "Star", behaviors, share } = options;
|
|
129
|
+
const [, setTick] = useState(0);
|
|
130
|
+
const onCountChange = useCallback(() => setTick((n) => n + 1), []);
|
|
131
|
+
return useMemo(() => createStarTool({
|
|
132
|
+
points,
|
|
133
|
+
innerRatio,
|
|
134
|
+
label,
|
|
135
|
+
behaviors,
|
|
136
|
+
share,
|
|
137
|
+
onCountChange
|
|
138
|
+
}), [
|
|
139
|
+
points,
|
|
140
|
+
innerRatio,
|
|
141
|
+
label,
|
|
142
|
+
behaviors,
|
|
143
|
+
share,
|
|
144
|
+
onCountChange
|
|
145
|
+
]);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { STAR_TOOL_OPTIONS, createStarTool, useStarTool };
|
|
149
|
+
//# sourceMappingURL=useStarTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStarTool.js","names":[],"sources":["../../../src/tools/star/useStarTool.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { defineTool } from '@weasel-js/core';\nimport type { Tool } from '@weasel-js/core';\nimport { insertBindingBehaviors, type InsertToolOptions } from '../shared/insertToolOptions';\nimport { defineAction, shareToolOptions, withToolOptionDefault, type WorldPoint } from '@weasel-js/routing';\nimport { DEFAULT_SHAPE_PAINT, shapeToolOptions } from '../shared/styleOptions';\nimport { stepCountOption } from '../shared/countOption';\nimport { cursorFor } from '@weasel-js/cursor';\nimport { icon } from '../../icons.gen';\nimport { INSERT_REPOSITION_BINDING } from '../../actions/insert/repositionAction';\nimport { STAR_INSERT_PARAMS } from '../../actions/insert/params';\nimport { INSERT_DRAG_MODS } from '../../actions/insert/action';\n\n/** A point in world coordinates. */\nexport type StarPoint = WorldPoint;\n\n/** Options for `useStarTool`. */\nexport interface UseStarToolOptions extends InsertToolOptions {\n label?: string;\n /** The point count before its user changes it, the `points` option's\n * default. Persists across gestures, adjustable\n * mid-drag via ArrowUp/Down or wheel (range 3–32). */\n points?: number;\n /** The inner-radius / outer-radius ratio before its user changes it, the\n * `innerRadiusRatio` option's default. Default 0.5. */\n innerRatio?: number;\n}\n\n/** The star tool's options: the style it draws with, shared with every shape tool, and its points and inner radius. */\nexport const STAR_TOOL_OPTIONS = shapeToolOptions({\n actionId: 'insert', name: 'Star', keys: ['fill', 'stroke', 'strokeWidth', 'fillRule'],\n style: { fill: DEFAULT_SHAPE_PAINT, stroke: null }, own: STAR_INSERT_PARAMS.children,\n});\n\n/** {@link useStarTool}'s options, and what to call when a gesture changes the point count, so the live preview\n * repaints. */\nexport interface CreateStarToolOptions extends UseStarToolOptions {\n onCountChange?: () => void;\n}\n\n/**\n * Drag-from-center star tool. Pointerdown sets center; drag determines\n * outer radius + rotation; release commits via `insertAction`. Inner\n * radius = outer × `innerRatio` (default 0.5). Point count defaults to\n * 5, adjustable mid-gesture via ArrowUp/Down or wheel.\n *\n * Live preview painted by the dispatcher overlay layer reading\n * `insertAction.overlay()`. Consumers wanting custom star geometry\n * override the `insert` dep.\n *\n * A point change mid-drag calls `onCountChange`.\n */\nexport function createStarTool(options: CreateStarToolOptions = {}): Tool {\n const { points, innerRatio, label = 'Star', behaviors, share } = options;\n const toolOptions = withToolOptionDefault(\n withToolOptionDefault(shareToolOptions(STAR_TOOL_OPTIONS, share), 'points', points), 'innerRadiusRatio', innerRatio,\n );\n const adjust = defineAction({\n id: 'star.adjustPoints',\n label: 'Star — adjust points',\n requires: ['toolOptionValues'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n if (stepCountOption('star', toolOptions, 'points', deps.toolOptionValues, params)) options.onCountChange?.();\n },\n },\n });\n return defineTool({\n id: 'star',\n capabilities: ['creates-shapes'],\n hookName: 'useStarTool',\n options: toolOptions,\n cursor: cursorFor('crosshair', { mark: 'star', fallback: 'crosshair' }),\n // Registered by <ToolActionsMounter>, inside the ActionsProvider —\n // see `ToolDef.actions` for why the hook can't register it itself.\n actions: [adjust],\n presentation: {\n label,\n group: 'shape',\n icon: icon('star'),\n },\n bindings: [\n // Default = drag from corner; anchor dot in the overlay sells\n // the click point. Alt flips to center mode (live toggle).\n {\n spec: { kind: 'drag', mods: INSERT_DRAG_MODS },\n actionId: 'insert',\n opts: { id: 'star.drag', params: { kind: 'star' }, ...insertBindingBehaviors(behaviors) },\n },\n INSERT_REPOSITION_BINDING,\n {\n spec: { kind: 'wheel', phase: 'engaged' },\n actionId: 'star.adjustPoints',\n opts: { id: 'star.wheelPoints' },\n },\n {\n spec: { kind: 'wheel', phase: 'engaged', mods: { shift: true } },\n actionId: 'insert.rotate',\n opts: { id: 'star.wheelRotation' },\n },\n // ArrowUp/Down → adjust point count. Ported off the phase table for\n // the same reason as polygon's: as an `initial.keyDown` route the\n // key was claimed on the tool pipeline while `nudge.*` matched the\n // same press on the interactions dispatcher, so both fired.\n {\n spec: { kind: 'key', key: 'ArrowUp' },\n actionId: 'star.adjustPoints',\n opts: { id: 'star.morePoints', params: { delta: 1 } },\n },\n {\n spec: { kind: 'key', key: 'ArrowDown' },\n actionId: 'star.adjustPoints',\n opts: { id: 'star.fewerPoints', params: { delta: -1 } },\n },\n ],\n });\n}\n\n/** {@link createStarTool}, kept while its options are, re-rendering its caller when the point count changes. */\nexport function useStarTool(options: UseStarToolOptions = {}): Tool {\n const { points, innerRatio, label = 'Star', behaviors, share } = options;\n const [, setTick] = useState(0);\n const onCountChange = useCallback(() => setTick((n) => n + 1), []);\n return useMemo(\n () => createStarTool({ points, innerRatio, label, behaviors, share, onCountChange }),\n [points, innerRatio, label, behaviors, share, onCountChange],\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB;AAChD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM;AAAC,CAAA,CAAA,CAAA,CAAA,CAAA,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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAa,CAAA,CAC7D,CAAA;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KIT_SHAPE_KINDS, VIEW_TOOLS, kitShapeKindsOf } from "@weasel-js/core";
|
|
2
|
+
import { toolIdsOf, toolSet } from "@weasel-js/routing";
|
|
3
|
+
|
|
4
|
+
// src/tools/toolSets.ts
|
|
5
|
+
/** The selection tools: click and marquee, and the lasso. */
|
|
6
|
+
var SELECT_TOOLS = toolSet("select", ["select", ...kitShapeKindsOf("select")], { label: "Select" });
|
|
7
|
+
/** The tools that drag out a closed or open primitive. */
|
|
8
|
+
var SHAPE_TOOLS = toolSet("shape", kitShapeKindsOf("shape"), { label: "Shapes" });
|
|
9
|
+
/** The kit's tool sets in palette order: selection, then navigation, then the tools that make things. Each set is
|
|
10
|
+
* named for the presentation group its tools sit in. */
|
|
11
|
+
var KIT_TOOL_GROUPS = [
|
|
12
|
+
SELECT_TOOLS,
|
|
13
|
+
VIEW_TOOLS,
|
|
14
|
+
SHAPE_TOOLS
|
|
15
|
+
];
|
|
16
|
+
/** The natural order of palette groups, as `ToolPalette`'s `groupOrder`. */
|
|
17
|
+
var TOOL_GROUP_ORDER = KIT_TOOL_GROUPS.map((set) => set.id);
|
|
18
|
+
/** Every kit tool, in palette order: {@link KIT_TOOL_GROUPS} one after another, then any shape kind in no
|
|
19
|
+
* family. */
|
|
20
|
+
var KIT_TOOLS = toolSet("kit", [...KIT_TOOL_GROUPS, ...KIT_SHAPE_KINDS], { label: "Tools" });
|
|
21
|
+
/** Every kit tool id, in palette order: {@link KIT_TOOLS} opened. A palette orders the tools within each group
|
|
22
|
+
* by it. */
|
|
23
|
+
var KIT_TOOL_IDS = toolIdsOf([KIT_TOOLS]);
|
|
24
|
+
|
|
25
|
+
export { KIT_TOOLS, KIT_TOOL_GROUPS, KIT_TOOL_IDS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER };
|
|
26
|
+
//# sourceMappingURL=toolSets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolSets.js","names":[],"sources":["../../src/tools/toolSets.ts"],"sourcesContent":["import { KIT_SHAPE_KINDS, kitShapeKindsOf, VIEW_TOOLS, type BuiltinShapeToolId, type BuiltinToolId } from '@weasel-js/core';\nimport { toolIdsOf, toolSet, type ToolSet } from '@weasel-js/routing';\n\n/** Every tool id the kit ships: core's own (the hand) and the ones editing's presets offer. */\nexport type KitToolId = BuiltinToolId | 'select' | BuiltinShapeToolId;\n\n/** The selection tools: click and marquee, and the lasso. */\nexport const SELECT_TOOLS: ToolSet<KitToolId> = toolSet('select', ['select', ...kitShapeKindsOf('select')], { label: 'Select' });\n/** The tools that drag out a closed or open primitive. */\nexport const SHAPE_TOOLS: ToolSet<KitToolId> = toolSet('shape', kitShapeKindsOf('shape'), { label: 'Shapes' });\n\n/** The kit's tool sets in palette order: selection, then navigation, then the tools that make things. Each set is\n * named for the presentation group its tools sit in. */\nexport const KIT_TOOL_GROUPS: readonly ToolSet<KitToolId>[] = [SELECT_TOOLS, VIEW_TOOLS, SHAPE_TOOLS];\n\n/** The natural order of palette groups, as `ToolPalette`'s `groupOrder`. */\nexport const TOOL_GROUP_ORDER: readonly string[] = KIT_TOOL_GROUPS.map((set) => set.id);\n\n/** Every kit tool, in palette order: {@link KIT_TOOL_GROUPS} one after another, then any shape kind in no\n * family. */\nexport const KIT_TOOLS: ToolSet<KitToolId> = toolSet('kit', [...KIT_TOOL_GROUPS, ...KIT_SHAPE_KINDS], { label: 'Tools' });\n\n/** Every kit tool id, in palette order: {@link KIT_TOOLS} opened. A palette orders the tools within each group\n * by it. */\nexport const KIT_TOOL_IDS: readonly KitToolId[] = toolIdsOf([KIT_TOOLS]);\n"],"mappings":";;;;;AAOA,IAAa,eAAmC,QAAQ,UAAU,CAAC,UAAU,GAAG,gBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC;;AAE/H,IAAa,cAAkC,QAAQ,SAAS,gBAAgB,OAAO,GAAG,EAAE,OAAO,SAAS,CAAC;;;AAI7G,IAAa,kBAAiD;CAAC;CAAc;CAAY;AAAW;;AAGpG,IAAa,mBAAsC,gBAAgB,KAAK,QAAQ,IAAI,EAAE;;;AAItF,IAAa,YAAgC,QAAQ,OAAO,CAAC,GAAG,iBAAiB,GAAG,eAAe,GAAG,EAAE,OAAO,QAAQ,CAAC;;;AAIxH,IAAa,eAAqC,UAAU,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/editing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Editing for a weasel canvas, as presets an app opts into: selecting, moving, resizing and rotating, the edit, arrange and Pathfinder commands, and paste and drop.",
|
|
5
5
|
"weasel": {
|
|
6
6
|
"tier": "plugin"
|
|
@@ -16,8 +16,31 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./engine": {
|
|
20
|
+
"types": "./dist/engine.d.ts",
|
|
21
|
+
"import": "./dist/engine.js"
|
|
22
|
+
},
|
|
23
|
+
"./presets": {
|
|
24
|
+
"types": "./dist/presets.d.ts",
|
|
25
|
+
"import": "./dist/presets.js"
|
|
26
|
+
},
|
|
27
|
+
"./groups": {
|
|
28
|
+
"types": "./dist/groups.d.ts",
|
|
29
|
+
"import": "./dist/groups.js"
|
|
30
|
+
},
|
|
31
|
+
"./test-seams": {
|
|
32
|
+
"types": "./dist/test-seams.d.ts",
|
|
33
|
+
"import": "./dist/test-seams.js"
|
|
34
|
+
},
|
|
35
|
+
"./icons": {
|
|
36
|
+
"types": "./dist/icons.table.d.ts",
|
|
37
|
+
"import": "./dist/icons.table.js"
|
|
38
|
+
},
|
|
19
39
|
"./package.json": "./package.json"
|
|
20
40
|
},
|
|
41
|
+
"weaselIcons": {
|
|
42
|
+
"table": "./dist/icons.table.json"
|
|
43
|
+
},
|
|
21
44
|
"author": "orochi235",
|
|
22
45
|
"homepage": "https://orochi235.github.io/weasel/",
|
|
23
46
|
"repository": {
|
|
@@ -37,21 +60,26 @@
|
|
|
37
60
|
"LICENSE"
|
|
38
61
|
],
|
|
39
62
|
"scripts": {
|
|
40
|
-
"build": "vite build && tsup",
|
|
63
|
+
"build": "vite build && tsup && cp src/icons.table.json dist/",
|
|
41
64
|
"test": "node ../../scripts/package-test.mjs"
|
|
42
65
|
},
|
|
43
66
|
"dependencies": {
|
|
44
|
-
"@weasel-js/
|
|
45
|
-
"@weasel-js/
|
|
46
|
-
"@weasel-js/
|
|
47
|
-
"@weasel-js/
|
|
48
|
-
"@weasel-js/
|
|
49
|
-
"@weasel-js/
|
|
50
|
-
"@weasel-js/
|
|
67
|
+
"@weasel-js/cursor": "2.0.0",
|
|
68
|
+
"@weasel-js/gestures": "2.0.0",
|
|
69
|
+
"@weasel-js/icons": "2.0.0",
|
|
70
|
+
"@weasel-js/paint": "2.0.0",
|
|
71
|
+
"@weasel-js/prefs-schema": "2.0.0",
|
|
72
|
+
"@weasel-js/react": "2.0.0",
|
|
73
|
+
"@weasel-js/registry": "2.0.0",
|
|
74
|
+
"@weasel-js/renderer": "2.0.0",
|
|
75
|
+
"@weasel-js/routing": "2.0.0",
|
|
76
|
+
"@weasel-js/select": "2.0.0",
|
|
77
|
+
"@weasel-js/stroke": "2.0.0",
|
|
78
|
+
"polygon-clipping": "^0.15.7"
|
|
51
79
|
},
|
|
52
80
|
"peerDependencies": {
|
|
53
|
-
"@weasel-js/core": "
|
|
54
|
-
"@weasel-js/geom": "
|
|
81
|
+
"@weasel-js/core": "2.0.0",
|
|
82
|
+
"@weasel-js/geom": "2.0.0",
|
|
55
83
|
"react": ">=18"
|
|
56
84
|
},
|
|
57
85
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escape.js","names":[],"sources":["../../../src/actions/edit/escape.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport { ActionDisabledReason, BETWEEN_GESTURES } from '@weasel-js/routing';\n\n/**\n * Static descriptor for the `escape` Action. Clears selection.\n */\n// No `eligible` field → always eligible. Escape works in every mode; the\n// runtime `enabled` thunk handles the path-edit defer-to-exit case.\nexport const escapeAction: Action & { requires: string[] } = {\n id: 'escape',\n label: 'Escape',\n // Gated to \"no tool is engaged\" so a mid-drag Escape goes to\n // `cancelGestureAction` (cancels the drag) instead of clearing\n // selection.\n defaultBinding: [{\n spec: {\n kind: 'key',\n key: 'Escape',\n phase: BETWEEN_GESTURES,\n },\n opts: { id: 'escape.key' },\n }],\n requires: ['selection', 'editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const sel = deps.selection?.get() ?? [];\n if (sel.length === 0) return;\n deps.selection?.set([]);\n },\n },\n // Defer to `exitPathEditAction` while path-anchor edit mode is active.\n // Otherwise the more-specific phase qualifier on this binding would beat\n // `exitPathEdit`'s bare key spec, swallowing the Escape that should leave\n // edit mode. With this gate, `escape` reports a disabled reason in that\n // case and the dispatcher falls through to `exitPathEdit`.\n // With nothing selected there is nothing to clear, so the press falls\n // through to `tool.resetToDefault` instead of being spent here.\n enabled: (deps) => {\n const editAnchors = deps?.editAnchors;\n if (editAnchors?.editingId) return ActionDisabledReason.NotApplicable;\n const sel = deps?.selection?.get() ?? [];\n if (sel.length === 0) return ActionDisabledReason.NotApplicable;\n return true;\n },\n};\n"],"mappings":";;;;;;AAQA,IAAa,eAAgD;CAC3D,IAAI;CACJ,OAAO;CAIP,gBAAgB,CAAC;EACf,MAAM;GACJ,MAAM;GACN,KAAK;GACL,OAAO;EACT;EACA,MAAM,EAAE,IAAI,aAAa;CAC3B,CAAC;CACD,UAAU,CAAC,aAAa,aAAa;CACrC,SAAS;EACP,QAAQ;EACR,MAAM,SAAS;GAEb,KADY,KAAK,WAAW,IAAI,KAAK,CAAC,EAClC,CAAI,WAAW,GAAG;GACtB,KAAK,WAAW,IAAI,CAAC,CAAC;EACxB;CACF;CAQA,UAAU,SAAS;EAEjB,KADoB,MAAM,YACtB,EAAa,WAAW,OAAO,qBAAqB;EAExD,KADY,MAAM,WAAW,IAAI,KAAK,CAAC,EACnC,CAAI,WAAW,GAAG,OAAO,qBAAqB;EAClD,OAAO;CACT;AACF"}
|