@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,45 @@
|
|
|
1
|
+
import { placementOps } from "./placement.js";
|
|
2
|
+
import { dispatchApplyBatch, locateChild } from "@weasel-js/core";
|
|
3
|
+
import * as coreOps from "@weasel-js/core/ops";
|
|
4
|
+
|
|
5
|
+
// src/booleans/commit.ts
|
|
6
|
+
/**
|
|
7
|
+
* Replace every entry with `pieces` as one undoable batch, and select what
|
|
8
|
+
* was made. Each piece is minted from its own source, wears the paint a stroke
|
|
9
|
+
* folded into that source left it, and takes its slot. Returns the new ids.
|
|
10
|
+
*/
|
|
11
|
+
function commitPieces(adapter, sel, entries, pieces, label) {
|
|
12
|
+
const slots = entries.map((e) => locateChild(adapter, e.id) ?? void 0);
|
|
13
|
+
const made = pieces.map((piece) => {
|
|
14
|
+
const { id, operand } = entries[piece.source];
|
|
15
|
+
return {
|
|
16
|
+
node: adapter.createPathNode(piece.path, piece.producedBy, id, operand.paint),
|
|
17
|
+
slot: slots[piece.source]
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
const newNodes = made.map((m) => m.node);
|
|
21
|
+
const ops = [];
|
|
22
|
+
const captured = entries.map((e, i) => ({
|
|
23
|
+
node: adapter.getNode(e.id) ?? { id: e.id },
|
|
24
|
+
index: slots[i]?.index ?? -1
|
|
25
|
+
}));
|
|
26
|
+
captured.sort((a, b) => b.index - a.index);
|
|
27
|
+
for (const { node, index } of captured) ops.push(coreOps.delete({
|
|
28
|
+
node,
|
|
29
|
+
index
|
|
30
|
+
}));
|
|
31
|
+
for (const n of newNodes) ops.push(coreOps.insert({ node: n }));
|
|
32
|
+
ops.push(...placementOps(made.map((m) => ({
|
|
33
|
+
id: m.node.id,
|
|
34
|
+
slot: m.slot
|
|
35
|
+
})), slots));
|
|
36
|
+
ops.push(coreOps.setSelection({
|
|
37
|
+
from: sel,
|
|
38
|
+
to: newNodes.map((n) => n.id)
|
|
39
|
+
}));
|
|
40
|
+
dispatchApplyBatch(adapter, ops, label);
|
|
41
|
+
return newNodes.map((n) => n.id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { commitPieces };
|
|
45
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.js","names":[],"sources":["../../src/booleans/commit.ts"],"sourcesContent":["import type { Path } from '@weasel-js/geom';\nimport { locateChild, dispatchApplyBatch } from '@weasel-js/core';\nimport type { Op, NodeId } from '@weasel-js/core';\nimport type { BooleanEntry, BooleanOp, BooleansAdapter, BooleanZOrder } from './booleans';\nimport { placementOps } from './placement';\nimport * as coreOps from '@weasel-js/core/ops';\n\n/** One path to mint: the index of the source it stands in for, and the op it\n * is recorded as made by. */\nexport interface BooleanCommitPiece {\n path: Path;\n source: number;\n producedBy: BooleanOp;\n}\n\n/**\n * Replace every entry with `pieces` as one undoable batch, and select what\n * was made. Each piece is minted from its own source, wears the paint a stroke\n * folded into that source left it, and takes its slot. Returns the new ids.\n */\nexport function commitPieces(\n adapter: BooleansAdapter,\n sel: readonly NodeId[],\n entries: readonly BooleanEntry[],\n pieces: readonly BooleanCommitPiece[],\n label: string,\n): string[] {\n // Every source's slot, read before the scene is mutated.\n const slots: (BooleanZOrder | undefined)[] =\n entries.map((e) => locateChild(adapter, e.id) ?? undefined);\n const made = pieces.map((piece) => {\n const { id, operand } = entries[piece.source]!;\n return { node: adapter.createPathNode(piece.path, piece.producedBy, id, operand.paint), slot: slots[piece.source] };\n });\n const newNodes = made.map((m) => m.node);\n const ops: Op[] = [];\n // Capture the full node so the delete's `invert()` (an insert) restores\n // every field on undo. The index is -1 for a source its parent does not list.\n const captured = entries.map((e, i) => ({\n node: adapter.getNode(e.id) ?? { id: e.id },\n index: slots[i]?.index ?? -1,\n }));\n // Order by index DESC so reverse-then-invert (history's undo path)\n // re-inserts ASC — each splice lands on a correctly-sized array\n // instead of clamping high indices to a still-growing length.\n captured.sort((a, b) => b.index - a.index);\n for (const { node, index } of captured) ops.push(coreOps.delete({ node, index }));\n for (const n of newNodes) ops.push(coreOps.insert({ node: n }));\n ops.push(...placementOps(made.map((m) => ({ id: m.node.id, slot: m.slot })), slots));\n ops.push(coreOps.setSelection({ from: sel, to: newNodes.map((n) => n.id as NodeId) }));\n dispatchApplyBatch(adapter, ops, label);\n return newNodes.map((n) => n.id);\n}\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,aACd,SACA,KACA,SACA,QACA,OACU;CAEV,MAAM,QACJ,QAAQ,KAAK,MAAM,YAAY,SAAS,EAAE,EAAE,KAAK,MAAS;CAC5D,MAAM,OAAO,OAAO,KAAK,UAAU;EACjC,MAAM,EAAE,IAAI,YAAY,QAAQ,MAAM;EACtC,OAAO;GAAE,MAAM,QAAQ,eAAe,MAAM,MAAM,MAAM,YAAY,IAAI,QAAQ,KAAK;GAAG,MAAM,MAAM,MAAM;EAAQ;CACpH,CAAC;CACD,MAAM,WAAW,KAAK,KAAK,MAAM,EAAE,IAAI;CACvC,MAAM,MAAY,CAAC;CAGnB,MAAM,WAAW,QAAQ,KAAK,GAAG,OAAO;EACtC,MAAM,QAAQ,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG;EAC1C,OAAO,MAAM,EAAE,EAAE,SAAS;CAC5B,EAAE;CAIF,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CACzC,KAAK,MAAM,EAAE,MAAM,WAAW,UAAU,IAAI,KAAK,QAAQ,OAAO;EAAE;EAAM;CAAM,CAAC,CAAC;CAChF,KAAK,MAAM,KAAK,UAAU,IAAI,KAAK,QAAQ,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9D,IAAI,KAAK,GAAG,aAAa,KAAK,KAAK,OAAO;EAAE,IAAI,EAAE,KAAK;EAAI,MAAM,EAAE;CAAK,EAAE,GAAG,KAAK,CAAC;CACnF,IAAI,KAAK,QAAQ,aAAa;EAAE,MAAM;EAAK,IAAI,SAAS,KAAK,MAAM,EAAE,EAAY;CAAE,CAAC,CAAC;CACrF,mBAAmB,SAAS,KAAK,KAAK;CACtC,OAAO,SAAS,KAAK,MAAM,EAAE,EAAE;AACjC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { resolveEntries } from "./booleans.js";
|
|
2
|
+
import { commitPieces } from "./commit.js";
|
|
3
|
+
|
|
4
|
+
// src/booleans/custom.ts
|
|
5
|
+
/**
|
|
6
|
+
* The operands the nodes among `ids` (the selection, when not given) give a
|
|
7
|
+
* Boolean operation, back to front, as the built-in operations resolve them;
|
|
8
|
+
* or why there are fewer than two.
|
|
9
|
+
* Reads the adapter and changes nothing.
|
|
10
|
+
*/
|
|
11
|
+
function resolveBooleanOperands(adapter, opts = {}, ids) {
|
|
12
|
+
const selection = [...adapter.getSelection()];
|
|
13
|
+
const entries = resolveEntries(adapter, ids ?? selection, "divide", opts);
|
|
14
|
+
if ("kind" in entries) return entries;
|
|
15
|
+
return {
|
|
16
|
+
selection,
|
|
17
|
+
sources: entries.map(({ id, operand: { path, paint } }) => paint ? {
|
|
18
|
+
id,
|
|
19
|
+
path,
|
|
20
|
+
paint
|
|
21
|
+
} : {
|
|
22
|
+
id,
|
|
23
|
+
path
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Replace `operands`' sources with `pieces` as one undo step named `label`,
|
|
29
|
+
* and select what was made. Each piece is minted from the source it names, as
|
|
30
|
+
* `BooleansAdapter.createPathNode` says, and stacks in that source's slot. An
|
|
31
|
+
* empty `pieces` deletes every source.
|
|
32
|
+
*/
|
|
33
|
+
function commitBooleanPieces(adapter, operands, pieces, label) {
|
|
34
|
+
const entries = operands.sources.map(({ id, path, paint }) => ({
|
|
35
|
+
id,
|
|
36
|
+
operand: paint ? {
|
|
37
|
+
path,
|
|
38
|
+
paint
|
|
39
|
+
} : { path }
|
|
40
|
+
}));
|
|
41
|
+
return {
|
|
42
|
+
kind: "applied",
|
|
43
|
+
resultIds: commitPieces(adapter, operands.selection, entries, pieces, label)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { commitBooleanPieces, resolveBooleanOperands };
|
|
48
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","names":[],"sources":["../../src/booleans/custom.ts"],"sourcesContent":["/**\n * A Boolean operation of the caller's own over the selection: the operands the\n * kit resolves from it, and the commit that replaces them with the pieces the\n * caller cut from those operands, as one undo step.\n */\nimport type { Path } from '@weasel-js/geom';\nimport type { PathPaint, NodeId } from '@weasel-js/core';\nimport { resolveEntries, type BooleanEntry, type BooleanOpResult, type BooleansAdapter } from './booleans';\nimport { commitPieces, type BooleanCommitPiece } from './commit';\nimport type { BooleanOpOptions } from './operands';\n\n/** One selected node's operand. */\nexport interface BooleanSource {\n id: NodeId;\n /** In world: its path, its glyph outlines, or the region its ink covers\n * once a stroke is counted. */\n path: Path;\n /** Set when a stroke went into `path`: what a piece standing in for this\n * source wears. */\n paint?: PathPaint;\n}\n\n/** What {@link resolveBooleanOperands} answers. */\nexport interface BooleanOperands {\n /** The selection the operands were read from. */\n selection: readonly NodeId[];\n /** Back to front. */\n sources: readonly BooleanSource[];\n}\n\n/**\n * The operands the nodes among `ids` (the selection, when not given) give a\n * Boolean operation, back to front, as the built-in operations resolve them;\n * or why there are fewer than two.\n * Reads the adapter and changes nothing.\n */\nexport function resolveBooleanOperands(\n adapter: BooleansAdapter,\n opts: BooleanOpOptions = {},\n ids?: readonly NodeId[],\n): BooleanOperands | Exclude<BooleanOpResult, { kind: 'applied' }> {\n const selection = [...adapter.getSelection()] as NodeId[];\n const entries = resolveEntries(adapter, ids ?? selection, 'divide', opts);\n if ('kind' in entries) return entries;\n return {\n selection,\n sources: entries.map(({ id, operand: { path, paint } }) => (paint ? { id, path, paint } : { id, path })),\n };\n}\n\n/**\n * Replace `operands`' sources with `pieces` as one undo step named `label`,\n * and select what was made. Each piece is minted from the source it names, as\n * `BooleansAdapter.createPathNode` says, and stacks in that source's slot. An\n * empty `pieces` deletes every source.\n */\nexport function commitBooleanPieces(\n adapter: BooleansAdapter,\n operands: BooleanOperands,\n pieces: readonly BooleanCommitPiece[],\n label: string,\n): Extract<BooleanOpResult, { kind: 'applied' }> {\n const entries = operands.sources.map(({ id, path, paint }): BooleanEntry => ({\n id,\n operand: paint ? { path, paint } : { path },\n }));\n return { kind: 'applied', resultIds: commitPieces(adapter, operands.selection, entries, pieces, label) };\n}\n\nexport type { BooleanCommitPiece };\n"],"mappings":";;;;;;;;;;AAoCA,SAAgB,uBACd,SACA,OAAyB,CAAC,GAC1B,KACiE;CACjE,MAAM,YAAY,CAAC,GAAG,QAAQ,aAAa,CAAC;CAC5C,MAAM,UAAU,eAAe,SAAS,OAAO,WAAW,UAAU,IAAI;CACxE,IAAI,UAAU,SAAS,OAAO;CAC9B,OAAO;EACL;EACA,SAAS,QAAQ,KAAK,EAAE,IAAI,SAAS,EAAE,MAAM,cAAe,QAAQ;GAAE;GAAI;GAAM;EAAM,IAAI;GAAE;GAAI;EAAK,CAAE;CACzG;AACF;;;;;;;AAQA,SAAgB,oBACd,SACA,UACA,QACA,OAC+C;CAC/C,MAAM,UAAU,SAAS,QAAQ,KAAK,EAAE,IAAI,MAAM,aAA2B;EAC3E;EACA,SAAS,QAAQ;GAAE;GAAM;EAAM,IAAI,EAAE,KAAK;CAC5C,EAAE;CACF,OAAO;EAAE,MAAM;EAAW,WAAW,aAAa,SAAS,SAAS,WAAW,SAAS,QAAQ,KAAK;CAAE;AACzG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { strokeRegion } from "@weasel-js/core";
|
|
2
|
+
import { resolveFill, resolveStroke } from "@weasel-js/paint";
|
|
3
|
+
import { pathUnion } from "@weasel-js/geom/booleans";
|
|
4
|
+
|
|
5
|
+
// src/booleans/operands.ts
|
|
6
|
+
function inkOf(source, strokes, frame, scale) {
|
|
7
|
+
const { path } = source;
|
|
8
|
+
const fill = resolveFill(source.fill);
|
|
9
|
+
const stroke = resolveStroke(source.stroke);
|
|
10
|
+
if (!stroke) return { path };
|
|
11
|
+
if (strokes === "ignore" || strokes === "unfilled" && fill !== null) return { path };
|
|
12
|
+
const ribbon = strokeRegion(path, stroke, frame, scale === void 0 ? {} : { scale });
|
|
13
|
+
if (ribbon.commands.length === 0) return { path };
|
|
14
|
+
return {
|
|
15
|
+
path: fill !== null ? pathUnion(path, ribbon) : ribbon,
|
|
16
|
+
paint: { fill: fill ?? { paint: stroke.paint } }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The operand behind `id`, or `undefined` for a node that is not one: a group,
|
|
21
|
+
* an outline that inks nothing, anything the adapter has neither a path nor an
|
|
22
|
+
* outline for. Throws `NodeOutlineError` for an outline that cannot be built.
|
|
23
|
+
*/
|
|
24
|
+
function resolveOperand(adapter, id, { strokes = "ignore", scale }) {
|
|
25
|
+
const path = adapter.getWorldPath(id);
|
|
26
|
+
if (path) {
|
|
27
|
+
const paint = strokes === "ignore" ? void 0 : adapter.getPaint?.(id);
|
|
28
|
+
return paint ? inkOf({
|
|
29
|
+
path,
|
|
30
|
+
...paint
|
|
31
|
+
}, strokes, adapter.getStrokeFrame?.(id), scale) : { path };
|
|
32
|
+
}
|
|
33
|
+
const outline = adapter.getOutline?.(id);
|
|
34
|
+
if (!outline) return void 0;
|
|
35
|
+
if (strokes === "ignore") {
|
|
36
|
+
const whole = outline.path();
|
|
37
|
+
return whole.kind === "rect" || whole.commands.length > 0 ? { path: whole } : void 0;
|
|
38
|
+
}
|
|
39
|
+
const inks = outline.parts().map((p) => inkOf(p, strokes, adapter.getStrokeFrame?.(id), scale));
|
|
40
|
+
if (inks.length === 0) return void 0;
|
|
41
|
+
const paint = inks.find((ink) => ink.paint)?.paint;
|
|
42
|
+
const whole = inks.length === 1 ? inks[0].path : pathUnion(...inks.map((ink) => ink.path));
|
|
43
|
+
return paint ? {
|
|
44
|
+
path: whole,
|
|
45
|
+
paint
|
|
46
|
+
} : { path: whole };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { resolveOperand };
|
|
50
|
+
//# sourceMappingURL=operands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operands.js","names":[],"sources":["../../src/booleans/operands.ts"],"sourcesContent":["/**\n * What each selected node gives a Boolean operation: its path, its outline\n * (a text node's glyphs), or the region its ink covers once a stroke is counted.\n */\nimport type { Affine, Path, Scale2 } from '@weasel-js/geom';\nimport { pathUnion } from '@weasel-js/geom/booleans';\nimport { resolveFill, resolveStroke } from '@weasel-js/paint';\nimport type { PathPaint, NodeId, PaintedPath } from '@weasel-js/core';\nimport { strokeRegion } from '@weasel-js/core';\nimport type { BooleansAdapter } from './booleans';\n\n/**\n * What a stroked operand gives a Boolean operation.\n *\n * - `'ignore'`: its path, as though it had no stroke.\n * - `'unfilled'`: the region its stroke covers when it has no fill, as a line\n * or an open pencil stroke has none; its path when it is filled.\n * - `'include'`: what it paints — its fill and its stroke together, or the\n * stroke alone when it has no fill.\n *\n * Any mode but `'ignore'` needs {@link BooleansAdapter.getPaint}.\n */\nexport type BooleanStrokes = 'ignore' | 'unfilled' | 'include';\n\n/** Options for `applyBooleanOp`. */\nexport interface BooleanOpOptions {\n /** Default `'ignore'`. */\n strokes?: BooleanStrokes;\n /** The view scale a `{ px }` stroke width resolves against: one number, or\n * the view's own scale per axis. Default 1. */\n scale?: number | Scale2;\n}\n\n/** @internal */\nexport interface BooleanOperand {\n path: Path;\n /** Set when a stroke went into `path`: what a result standing in for this\n * operand wears, the stroke being part of its shape now. */\n paint?: PathPaint;\n}\n\nfunction inkOf(\n source: PaintedPath,\n strokes: BooleanStrokes,\n frame: Affine | null | undefined,\n scale: number | Scale2 | undefined,\n): BooleanOperand {\n const { path } = source;\n const fill = resolveFill(source.fill);\n const stroke = resolveStroke(source.stroke);\n if (!stroke) return { path };\n if (strokes === 'ignore' || (strokes === 'unfilled' && fill !== null)) return { path };\n const ribbon = strokeRegion(path, stroke, frame, scale === undefined ? {} : { scale });\n if (ribbon.commands.length === 0) return { path };\n return { path: fill !== null ? pathUnion(path, ribbon) : ribbon, paint: { fill: fill ?? { paint: stroke.paint } } };\n}\n\n/**\n * The operand behind `id`, or `undefined` for a node that is not one: a group,\n * an outline that inks nothing, anything the adapter has neither a path nor an\n * outline for. Throws `NodeOutlineError` for an outline that cannot be built.\n */\nexport function resolveOperand(\n adapter: BooleansAdapter,\n id: NodeId,\n { strokes = 'ignore', scale }: BooleanOpOptions,\n): BooleanOperand | undefined {\n const path = adapter.getWorldPath(id);\n if (path) {\n const paint = strokes === 'ignore' ? undefined : adapter.getPaint?.(id);\n return paint ? inkOf({ path, ...paint }, strokes, adapter.getStrokeFrame?.(id), scale) : { path };\n }\n const outline = adapter.getOutline?.(id);\n if (!outline) return undefined;\n if (strokes === 'ignore') {\n const whole = outline.path();\n return whole.kind === 'rect' || whole.commands.length > 0 ? { path: whole } : undefined;\n }\n const inks = outline.parts().map((p) => inkOf(p, strokes, adapter.getStrokeFrame?.(id), scale));\n if (inks.length === 0) return undefined;\n const paint = inks.find((ink) => ink.paint)?.paint;\n const whole = inks.length === 1 ? inks[0]!.path : pathUnion(...inks.map((ink) => ink.path));\n return paint ? { path: whole, paint } : { path: whole };\n}\n"],"mappings":";;;;;AAyCA,SAAS,MACP,QACA,SACA,OACA,OACgB;CAChB,MAAM,EAAE,SAAS;CACjB,MAAM,OAAO,YAAY,OAAO,IAAI;CACpC,MAAM,SAAS,cAAc,OAAO,MAAM;CAC1C,IAAI,CAAC,QAAQ,OAAO,EAAE,KAAK;CAC3B,IAAI,YAAY,YAAa,YAAY,cAAc,SAAS,MAAO,OAAO,EAAE,KAAK;CACrF,MAAM,SAAS,aAAa,MAAM,QAAQ,OAAO,UAAU,SAAY,CAAC,IAAI,EAAE,MAAM,CAAC;CACrF,IAAI,OAAO,SAAS,WAAW,GAAG,OAAO,EAAE,KAAK;CAChD,OAAO;EAAE,MAAM,SAAS,OAAO,UAAU,MAAM,MAAM,IAAI;EAAQ,OAAO,EAAE,MAAM,QAAQ,EAAE,OAAO,OAAO,MAAM,EAAE;CAAE;AACpH;;;;;;AAOA,SAAgB,eACd,SACA,IACA,EAAE,UAAU,UAAU,SACM;CAC5B,MAAM,OAAO,QAAQ,aAAa,EAAE;CACpC,IAAI,MAAM;EACR,MAAM,QAAQ,YAAY,WAAW,SAAY,QAAQ,WAAW,EAAE;EACtE,OAAO,QAAQ,MAAM;GAAE;GAAM,GAAG;EAAM,GAAG,SAAS,QAAQ,iBAAiB,EAAE,GAAG,KAAK,IAAI,EAAE,KAAK;CAClG;CACA,MAAM,UAAU,QAAQ,aAAa,EAAE;CACvC,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,YAAY,UAAU;EACxB,MAAM,QAAQ,QAAQ,KAAK;EAC3B,OAAO,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS,IAAI,EAAE,MAAM,MAAM,IAAI;CAChF;CACA,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,MAAM,MAAM,GAAG,SAAS,QAAQ,iBAAiB,EAAE,GAAG,KAAK,CAAC;CAC9F,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,MAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,EAAE;CAC7C,MAAM,QAAQ,KAAK,WAAW,IAAI,KAAK,EAAE,CAAE,OAAO,UAAU,GAAG,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC;CAC1F,OAAO,QAAQ;EAAE,MAAM;EAAO;CAAM,IAAI,EAAE,MAAM,MAAM;AACxD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { booleanOfPaths } from "@weasel-js/core";
|
|
2
|
+
import { pathCropPieces, pathDividePieces, pathMerge, pathTrim } from "@weasel-js/geom/booleans";
|
|
3
|
+
|
|
4
|
+
// src/booleans/pieces.ts
|
|
5
|
+
/** A piece stands in for the topmost input left in it. */
|
|
6
|
+
function bySource(pieces) {
|
|
7
|
+
return pieces.map((p) => ({
|
|
8
|
+
path: p.path,
|
|
9
|
+
source: p.sources[p.sources.length - 1]
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
/** Run `op` over `paths`, back to front, dropping empty results. `mergeKey`
|
|
13
|
+
* answers alike for the paths a Merge unites. */
|
|
14
|
+
function booleanPieces(op, paths, mergeKey) {
|
|
15
|
+
const top = paths.length - 1;
|
|
16
|
+
const whole = (path) => [{
|
|
17
|
+
path,
|
|
18
|
+
source: top
|
|
19
|
+
}];
|
|
20
|
+
let pieces;
|
|
21
|
+
switch (op) {
|
|
22
|
+
case "union":
|
|
23
|
+
case "intersect":
|
|
24
|
+
case "exclude":
|
|
25
|
+
case "subtract":
|
|
26
|
+
pieces = whole(booleanOfPaths(op, paths));
|
|
27
|
+
break;
|
|
28
|
+
case "divide":
|
|
29
|
+
pieces = bySource(pathDividePieces(...paths));
|
|
30
|
+
break;
|
|
31
|
+
case "crop":
|
|
32
|
+
pieces = bySource(pathCropPieces(...paths));
|
|
33
|
+
break;
|
|
34
|
+
case "trim":
|
|
35
|
+
pieces = bySource(pathTrim(...paths));
|
|
36
|
+
break;
|
|
37
|
+
case "merge": pieces = bySource(pathMerge(paths, mergeKey));
|
|
38
|
+
}
|
|
39
|
+
return pieces.filter((p) => p.path.commands.length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { booleanPieces };
|
|
43
|
+
//# sourceMappingURL=pieces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieces.js","names":[],"sources":["../../src/booleans/pieces.ts"],"sourcesContent":["import {\n pathDividePieces,\n pathCropPieces,\n pathTrim,\n pathMerge,\n type BooleanPiece,\n} from '@weasel-js/geom/booleans';\nimport type { Path, PolygonPath } from '@weasel-js/geom';\nimport type { BooleanOp } from './booleans';\nimport { booleanOfPaths } from '@weasel-js/core';\n\n/** One result path, and the operand it stands in for: an index into the\n * operands, back to front. */\nexport interface ResultPiece {\n path: PolygonPath;\n source: number;\n}\n\n/** A piece stands in for the topmost input left in it. */\nfunction bySource(pieces: BooleanPiece[]): ResultPiece[] {\n return pieces.map((p) => ({ path: p.path, source: p.sources[p.sources.length - 1]! }));\n}\n\n/** Run `op` over `paths`, back to front, dropping empty results. `mergeKey`\n * answers alike for the paths a Merge unites. */\nexport function booleanPieces(op: BooleanOp, paths: Path[], mergeKey: (index: number) => unknown): ResultPiece[] {\n const top = paths.length - 1;\n const whole = (path: PolygonPath): ResultPiece[] => [{ path, source: top }];\n let pieces: ResultPiece[];\n switch (op) {\n case 'union':\n case 'intersect':\n case 'exclude':\n case 'subtract': pieces = whole(booleanOfPaths(op, paths)); break;\n case 'divide': pieces = bySource(pathDividePieces(...paths)); break;\n // Crop: every source below the topmost, clipped to it; the\n // topmost is consumed as the mask.\n case 'crop': pieces = bySource(pathCropPieces(...paths)); break;\n case 'trim': pieces = bySource(pathTrim(...paths)); break;\n case 'merge': pieces = bySource(pathMerge(paths, mergeKey)); break;\n }\n return pieces.filter((p) => p.path.commands.length > 0);\n}\n"],"mappings":";;;;;AAmBA,SAAS,SAAS,QAAuC;CACvD,OAAO,OAAO,KAAK,OAAO;EAAE,MAAM,EAAE;EAAM,QAAQ,EAAE,QAAQ,EAAE,QAAQ,SAAS;CAAI,EAAE;AACvF;;;AAIA,SAAgB,cAAc,IAAe,OAAe,UAAqD;CAC/G,MAAM,MAAM,MAAM,SAAS;CAC3B,MAAM,SAAS,SAAqC,CAAC;EAAE;EAAM,QAAQ;CAAI,CAAC;CAC1E,IAAI;CACJ,QAAQ,IAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;GAAa,SAAS,MAAM,eAAe,IAAI,KAAK,CAAC;GAAG;EAC7D,KAAK;GAAa,SAAS,SAAS,iBAAiB,GAAG,KAAK,CAAC;GAAG;EAGjE,KAAK;GAAa,SAAS,SAAS,eAAe,GAAG,KAAK,CAAC;GAAG;EAC/D,KAAK;GAAa,SAAS,SAAS,SAAS,GAAG,KAAK,CAAC;GAAG;EACzD,KAAK,SAAa,SAAS,SAAS,UAAU,OAAO,QAAQ,CAAC;CAChE;CACA,OAAO,OAAO,QAAQ,MAAM,EAAE,KAAK,SAAS,SAAS,CAAC;AACxD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { maxOf } from "@weasel-js/geom";
|
|
2
|
+
import * as coreOps from "@weasel-js/core/ops";
|
|
3
|
+
|
|
4
|
+
// src/booleans/placement.ts
|
|
5
|
+
/**
|
|
6
|
+
* The ops that put each result where its source was. Results are grouped by
|
|
7
|
+
* their source's parent, and each group lands as one block, in result order,
|
|
8
|
+
* in the slot of the topmost source in that parent.
|
|
9
|
+
*
|
|
10
|
+
* `sourceSlots` holds every source's slot, read before anything is deleted.
|
|
11
|
+
* The sources below a slot in the same parent are deleted before the reorder
|
|
12
|
+
* runs, so the block goes that many places lower. A result whose source has
|
|
13
|
+
* no slot is left wherever the insert put it.
|
|
14
|
+
*/
|
|
15
|
+
function placementOps(results, sourceSlots) {
|
|
16
|
+
const groups = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const r of results) {
|
|
18
|
+
if (!r.slot) continue;
|
|
19
|
+
const group = groups.get(r.slot.parentId);
|
|
20
|
+
if (group) group.push(r.id);
|
|
21
|
+
else groups.set(r.slot.parentId, [r.id]);
|
|
22
|
+
}
|
|
23
|
+
const ops = [];
|
|
24
|
+
for (const [parentId, ids] of groups) {
|
|
25
|
+
const indices = sourceSlots.flatMap((s) => s && s.parentId === parentId ? [s.index] : []);
|
|
26
|
+
const top = maxOf(indices);
|
|
27
|
+
ops.push(coreOps.moveToIndex({
|
|
28
|
+
ids,
|
|
29
|
+
parentId,
|
|
30
|
+
index: top - (indices.length - 1)
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return ops;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { placementOps };
|
|
37
|
+
//# sourceMappingURL=placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.js","names":[],"sources":["../../src/booleans/placement.ts"],"sourcesContent":["import type { Op } from '@weasel-js/core';\nimport { maxOf } from '@weasel-js/geom';\nimport type { BooleanZOrder } from './booleans';\nimport * as coreOps from '@weasel-js/core/ops';\n\n/**\n * The ops that put each result where its source was. Results are grouped by\n * their source's parent, and each group lands as one block, in result order,\n * in the slot of the topmost source in that parent.\n *\n * `sourceSlots` holds every source's slot, read before anything is deleted.\n * The sources below a slot in the same parent are deleted before the reorder\n * runs, so the block goes that many places lower. A result whose source has\n * no slot is left wherever the insert put it.\n */\nexport function placementOps(\n results: readonly { id: string; slot: BooleanZOrder | undefined }[],\n sourceSlots: readonly (BooleanZOrder | undefined)[],\n): Op[] {\n const groups = new Map<string | null, string[]>();\n for (const r of results) {\n if (!r.slot) continue;\n const group = groups.get(r.slot.parentId);\n if (group) group.push(r.id);\n else groups.set(r.slot.parentId, [r.id]);\n }\n const ops: Op[] = [];\n for (const [parentId, ids] of groups) {\n const indices = sourceSlots.flatMap((s) => (s && s.parentId === parentId ? [s.index] : []));\n const top = maxOf(indices);\n ops.push(coreOps.moveToIndex({ ids, parentId, index: top - (indices.length - 1) }));\n }\n return ops;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,aACd,SACA,aACM;CACN,MAAM,yBAAS,IAAI,IAA6B;CAChD,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,CAAC,EAAE,MAAM;EACb,MAAM,QAAQ,OAAO,IAAI,EAAE,KAAK,QAAQ;EACxC,IAAI,OAAO,MAAM,KAAK,EAAE,EAAE;OACrB,OAAO,IAAI,EAAE,KAAK,UAAU,CAAC,EAAE,EAAE,CAAC;CACzC;CACA,MAAM,MAAY,CAAC;CACnB,KAAK,MAAM,CAAC,UAAU,QAAQ,QAAQ;EACpC,MAAM,UAAU,YAAY,SAAS,MAAO,KAAK,EAAE,aAAa,WAAW,CAAC,EAAE,KAAK,IAAI,CAAC,CAAE;EAC1F,MAAM,MAAM,MAAM,OAAO;EACzB,IAAI,KAAK,QAAQ,YAAY;GAAE;GAAK;GAAU,OAAO,OAAO,QAAQ,SAAS;EAAG,CAAC,CAAC;CACpF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { applyBooleanOp } from "./booleans.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { isDev, useLatest } from "@weasel-js/react";
|
|
4
|
+
|
|
5
|
+
// src/booleans/useBooleans.ts
|
|
6
|
+
/**
|
|
7
|
+
* `useBooleans` — selection-driven Boolean ops on path layers. No-ops are
|
|
8
|
+
* silent in production; in dev, `subtract` with < 2 selected paths emits a
|
|
9
|
+
* `console.warn`.
|
|
10
|
+
*/
|
|
11
|
+
var dev = isDev();
|
|
12
|
+
/** Bind the Boolean path operations to an adapter that knows how to read the
|
|
13
|
+
* selection, fetch world-space paths and mint result nodes. */
|
|
14
|
+
function useBooleans(adapter, options = {}) {
|
|
15
|
+
const adapterRef = useLatest(adapter);
|
|
16
|
+
const optionsRef = useLatest(options);
|
|
17
|
+
const run = useCallback((op) => {
|
|
18
|
+
const result = applyBooleanOp(adapterRef.current, op, optionsRef.current);
|
|
19
|
+
if (dev && result.kind === "noop" && result.reason === "too-few-for-subtract") console.warn("[useBooleans] subtract requires at least 2 selected paths");
|
|
20
|
+
}, [adapterRef, optionsRef]);
|
|
21
|
+
return {
|
|
22
|
+
union: useCallback(() => run("union"), [run]),
|
|
23
|
+
intersect: useCallback(() => run("intersect"), [run]),
|
|
24
|
+
subtract: useCallback(() => run("subtract"), [run]),
|
|
25
|
+
exclude: useCallback(() => run("exclude"), [run]),
|
|
26
|
+
divide: useCallback(() => run("divide"), [run]),
|
|
27
|
+
crop: useCallback(() => run("crop"), [run]),
|
|
28
|
+
trim: useCallback(() => run("trim"), [run]),
|
|
29
|
+
merge: useCallback(() => run("merge"), [run])
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { useBooleans };
|
|
34
|
+
//# sourceMappingURL=useBooleans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBooleans.js","names":[],"sources":["../../src/booleans/useBooleans.ts"],"sourcesContent":["/**\n * `useBooleans` — selection-driven Boolean ops on path layers. No-ops are\n * silent in production; in dev, `subtract` with < 2 selected paths emits a\n * `console.warn`.\n */\nimport { useCallback } from 'react';\nimport { useLatest, isDev } from '@weasel-js/react';\nimport { applyBooleanOp, type BooleansAdapter, type BooleanOp } from './booleans';\nimport type { BooleanOpOptions } from './operands';\n\n/** The Boolean path operations, each acting on the current selection and\n * committing as one undo step. */\nexport interface UseBooleansReturn {\n union(): void;\n intersect(): void;\n subtract(): void;\n exclude(): void;\n divide(): void;\n crop(): void;\n trim(): void;\n merge(): void;\n}\n\n/** Options for `useBooleans`. */\nexport interface UseBooleansOptions extends BooleanOpOptions {\n /** No-op. Retained for source-compatibility; `useStandardActions`\n * registers the actions. */\n enableActions?: boolean;\n}\n\nconst dev = isDev();\n\n/** Bind the Boolean path operations to an adapter that knows how to read the\n * selection, fetch world-space paths and mint result nodes. */\nexport function useBooleans(\n adapter: BooleansAdapter,\n options: UseBooleansOptions = {},\n): UseBooleansReturn {\n const adapterRef = useLatest(adapter);\n const optionsRef = useLatest(options);\n\n const run = useCallback((op: BooleanOp) => {\n const result = applyBooleanOp(adapterRef.current, op, optionsRef.current);\n if (dev && result.kind === 'noop' && result.reason === 'too-few-for-subtract') {\n console.warn('[useBooleans] subtract requires at least 2 selected paths');\n }\n }, [adapterRef, optionsRef]);\n\n return {\n union: useCallback(() => run('union'), [run]),\n intersect: useCallback(() => run('intersect'), [run]),\n subtract: useCallback(() => run('subtract'), [run]),\n exclude: useCallback(() => run('exclude'), [run]),\n divide: useCallback(() => run('divide'), [run]),\n crop: useCallback(() => run('crop'), [run]),\n trim: useCallback(() => run('trim'), [run]),\n merge: useCallback(() => run('merge'), [run]),\n };\n}\n"],"mappings":";;;;;;;;;;AA8BA,IAAM,MAAM,MAAM;;;AAIlB,SAAgB,YACd,SACA,UAA8B,CAAC,GACZ;CACnB,MAAM,aAAa,UAAU,OAAO;CACpC,MAAM,aAAa,UAAU,OAAO;CAEpC,MAAM,MAAM,aAAa,OAAkB;EACzC,MAAM,SAAS,eAAe,WAAW,SAAS,IAAI,WAAW,OAAO;EACxE,IAAI,OAAO,OAAO,SAAS,UAAU,OAAO,WAAW,wBACrD,QAAQ,KAAK,2DAA2D;CAE5E,GAAG,CAAC,YAAY,UAAU,CAAC;CAE3B,OAAO;EACL,OAAO,kBAAkB,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC;EAC5C,WAAW,kBAAkB,IAAI,WAAW,GAAG,CAAC,GAAG,CAAC;EACpD,UAAU,kBAAkB,IAAI,UAAU,GAAG,CAAC,GAAG,CAAC;EAClD,SAAS,kBAAkB,IAAI,SAAS,GAAG,CAAC,GAAG,CAAC;EAChD,QAAQ,kBAAkB,IAAI,QAAQ,GAAG,CAAC,GAAG,CAAC;EAC9C,MAAM,kBAAkB,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC;EAC1C,MAAM,kBAAkB,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC;EAC1C,OAAO,kBAAkB,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC;CAC9C;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useDepSource } from "@weasel-js/routing/react";
|
|
2
|
+
|
|
3
|
+
// src/booleans/useBooleansAdapter.ts
|
|
4
|
+
/** Publish a Boolean-ops adapter so the built-in Pathfinder actions can run.
|
|
5
|
+
* Silently does nothing outside a `<DepRegistryProvider>`. */
|
|
6
|
+
function useBooleansAdapter(adapter) {
|
|
7
|
+
useDepSource("booleansAdapter", () => adapter);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { useBooleansAdapter };
|
|
11
|
+
//# sourceMappingURL=useBooleansAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBooleansAdapter.js","names":[],"sources":["../../src/booleans/useBooleansAdapter.ts"],"sourcesContent":["import { useDepSource } from '@weasel-js/routing/react';\nimport type { BooleansAdapter } from './booleans';\n\n/** Publish a Boolean-ops adapter so the built-in Pathfinder actions can run.\n * Silently does nothing outside a `<DepRegistryProvider>`. */\nexport function useBooleansAdapter(adapter: BooleansAdapter): void {\n useDepSource('booleansAdapter', () => adapter);\n}\n"],"mappings":";;;;;AAKA,SAAgB,mBAAmB,SAAgC;CACjE,aAAa,yBAAyB,OAAO;AAC/C"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { HANDLE_FILL_COLOR, HANDLE_OUTLINE_COLOR } from "../handleCommands.js";
|
|
2
|
+
import { HANDLE_BASE_PX, MULTI_RESIZE_TARGET_ID, localToWorld, transformOf } from "@weasel-js/core";
|
|
3
|
+
import { RESIZE_HANDLE_ANCHORS, fixedCornerOf as fixedCornerOf$1, handlePoint, isCornerHandle } from "@weasel-js/core/engine";
|
|
4
|
+
|
|
5
|
+
// src/chrome/affordances/cornerResize.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resize-handle affordance for the active selection (single member in
|
|
8
|
+
* single-mode; the union AABB in multi-mode): a handle at each corner and,
|
|
9
|
+
* unless `edges` is false, at each edge midpoint.
|
|
10
|
+
*
|
|
11
|
+
* Declares point regions in the target's local frame; the framework
|
|
12
|
+
* applies the target's bounds rotation for both paint and hit-test. A
|
|
13
|
+
* region's `bind()` carries only the scratch a hit hands to the resize
|
|
14
|
+
* action: the anchor, the target, and the world-space fixed point.
|
|
15
|
+
*/
|
|
16
|
+
function createCornerResizeAffordance(opts = {}) {
|
|
17
|
+
const { handleHitRadius = HANDLE_BASE_PX, handleSize = HANDLE_BASE_PX, fill = HANDLE_FILL_COLOR, stroke = HANDLE_OUTLINE_COLOR, edges = true } = opts;
|
|
18
|
+
const entries = edges ? RESIZE_HANDLE_ANCHORS : RESIZE_HANDLE_ANCHORS.filter(isCornerHandle);
|
|
19
|
+
const paint = {
|
|
20
|
+
kind: "square",
|
|
21
|
+
sizePx: handleSize,
|
|
22
|
+
fill: { paint: { color: fill } },
|
|
23
|
+
stroke: {
|
|
24
|
+
paint: { color: stroke },
|
|
25
|
+
width: 1
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
id: "selection.resize-handles",
|
|
30
|
+
regions(state) {
|
|
31
|
+
const target = pickRenderTarget(state);
|
|
32
|
+
if (!target) return [];
|
|
33
|
+
const b = target.bounds;
|
|
34
|
+
const xf = transformOf(state, target.id);
|
|
35
|
+
return entries.map((c) => {
|
|
36
|
+
const at = handlePoint(b, c);
|
|
37
|
+
const fixedLocal = fixedCornerOf$1(b, c.anchor);
|
|
38
|
+
const fixedPoint = localToWorld(xf, fixedLocal.x, fixedLocal.y);
|
|
39
|
+
const corner = isCornerHandle(c);
|
|
40
|
+
return {
|
|
41
|
+
id: `${corner ? "corner" : "edge"}-${c.tag}`,
|
|
42
|
+
targetId: target.id,
|
|
43
|
+
shape: {
|
|
44
|
+
kind: "point",
|
|
45
|
+
x: at.x,
|
|
46
|
+
y: at.y,
|
|
47
|
+
hitRadiusPx: handleHitRadius,
|
|
48
|
+
turned: true,
|
|
49
|
+
...corner ? { cornerOf: {
|
|
50
|
+
width: b.width,
|
|
51
|
+
height: b.height,
|
|
52
|
+
outward: {
|
|
53
|
+
x: c.xEdge === "min" ? -1 : 1,
|
|
54
|
+
y: c.yEdge === "min" ? -1 : 1
|
|
55
|
+
}
|
|
56
|
+
} } : { edgeOf: {
|
|
57
|
+
width: b.width,
|
|
58
|
+
height: b.height
|
|
59
|
+
} }
|
|
60
|
+
},
|
|
61
|
+
paint,
|
|
62
|
+
hitKind: c.kind,
|
|
63
|
+
cursor: resizeCursor(c, xf),
|
|
64
|
+
bind: () => ({ initialScratch: {
|
|
65
|
+
anchor: c.anchor,
|
|
66
|
+
targetId: target.id,
|
|
67
|
+
fixedPoint
|
|
68
|
+
} })
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** The resize cursor along the axis a handle drags, as that axis is drawn on
|
|
75
|
+
* screen: through the target's frame, a turn or a mirror included, and the
|
|
76
|
+
* view's scale. The glyph is horizontal at angle 0. A corner drags along a
|
|
77
|
+
* diagonal of its box picked by fixed-corner parity: a matched-axis anchor
|
|
78
|
+
* (min-min / max-max fixed) drags along local (1, 1), mixed axes along
|
|
79
|
+
* (1, -1). The keyword is the fallback rather than the answer: CSS has four
|
|
80
|
+
* of them, which cannot express a target rotated to anything but a multiple
|
|
81
|
+
* of 45°. */
|
|
82
|
+
function resizeCursor(c, xf) {
|
|
83
|
+
const matched = c.anchor.x === c.anchor.y;
|
|
84
|
+
const [lx, ly, fallback] = c.anchor.y === "free" ? [
|
|
85
|
+
1,
|
|
86
|
+
0,
|
|
87
|
+
"ew-resize"
|
|
88
|
+
] : c.anchor.x === "free" ? [
|
|
89
|
+
0,
|
|
90
|
+
1,
|
|
91
|
+
"ns-resize"
|
|
92
|
+
] : [
|
|
93
|
+
1,
|
|
94
|
+
matched ? 1 : -1,
|
|
95
|
+
matched ? "nwse-resize" : "nesw-resize"
|
|
96
|
+
];
|
|
97
|
+
const [a, b, cc, d] = xf.toWorld;
|
|
98
|
+
const wx = a * lx + cc * ly;
|
|
99
|
+
const wy = b * lx + d * ly;
|
|
100
|
+
return (_at, view) => ({
|
|
101
|
+
glyph: "resize",
|
|
102
|
+
angle: Math.atan2(wy * view.scale.y, wx * view.scale.x),
|
|
103
|
+
fallback
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function pickRenderTarget(state) {
|
|
107
|
+
if (state.multiActive && state.unionBounds) return {
|
|
108
|
+
id: MULTI_RESIZE_TARGET_ID,
|
|
109
|
+
bounds: state.unionBounds
|
|
110
|
+
};
|
|
111
|
+
if (state.selection.length === 1) {
|
|
112
|
+
const id = state.selection[0];
|
|
113
|
+
const b = state.boundsOf(id);
|
|
114
|
+
return b ? {
|
|
115
|
+
id,
|
|
116
|
+
bounds: b
|
|
117
|
+
} : null;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { createCornerResizeAffordance };
|
|
123
|
+
//# sourceMappingURL=cornerResize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cornerResize.js","names":["fixedCornerOf"],"sources":["../../../src/chrome/affordances/cornerResize.ts"],"sourcesContent":["import type { Affordance, AffordanceBinding, AffordanceRegion, CommonAffordanceScratch } from '@weasel-js/core';\nimport type { ChromeState, Bounds } from '@weasel-js/core';\nimport type { ResizeAnchor } from '@weasel-js/core';\nimport {\n RESIZE_HANDLE_ANCHORS, fixedCornerOf, handlePoint, isCornerHandle, type ResizeHandleAnchor,\n} from '@weasel-js/core/engine';\nimport { MULTI_RESIZE_TARGET_ID } from '@weasel-js/core';\nimport { localToWorld, transformOf, type TargetTransform } from '@weasel-js/core';\nimport type { View } from '@weasel-js/core';\nimport { HANDLE_BASE_PX } from '@weasel-js/core';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport { HANDLE_FILL_COLOR, HANDLE_OUTLINE_COLOR } from '../handleCommands';\n\n/** Options for `createCornerResizeAffordance` — the size and appearance of\n * the resize handles, and whether the edge midpoints get one. */\nexport interface CornerResizeAffordanceOptions {\n /** Hit radius (screen-px) for the handles. Default 8. */\n handleHitRadius?: number;\n /** Visual handle size (screen-px). Default 8. */\n handleSize?: number;\n fill?: string;\n stroke?: string;\n /** Add a handle at the middle of each edge, resizing along one axis with\n * the opposite edge pinned. A side under `EDGE_HANDLE_MIN_RADII` hit radii\n * on screen takes none. Default true. */\n edges?: boolean;\n}\n\n/** What a corner-resize hit hands to the resize action: which corner stays\n * put, what is being resized, and the world-space pivot to scale from. */\nexport interface CornerResizeScratch extends CommonAffordanceScratch {\n /** Resize anchor identifying the OPPOSITE corner or edge (the one that\n * stays fixed). Matches the kit's existing ResizeAnchor convention. */\n anchor: ResizeAnchor;\n /** Id of the resize target. In multi-mode this is `MULTI_RESIZE_TARGET_ID`. */\n targetId: string;\n /** The fixed corner (an edge handle's: the opposite edge's midpoint) in\n * **world** coords, with the target's rotation already applied. `resizeAction` scales from this point, and it has no access to\n * the target transform, so the affordance resolves it here. */\n fixedPoint: { x: number; y: number };\n}\n\n\n/**\n * Resize-handle affordance for the active selection (single member in\n * single-mode; the union AABB in multi-mode): a handle at each corner and,\n * unless `edges` is false, at each edge midpoint.\n *\n * Declares point regions in the target's local frame; the framework\n * applies the target's bounds rotation for both paint and hit-test. A\n * region's `bind()` carries only the scratch a hit hands to the resize\n * action: the anchor, the target, and the world-space fixed point.\n */\nexport function createCornerResizeAffordance(\n opts: CornerResizeAffordanceOptions = {},\n): Affordance {\n const {\n handleHitRadius = HANDLE_BASE_PX,\n handleSize = HANDLE_BASE_PX,\n fill = HANDLE_FILL_COLOR,\n stroke = HANDLE_OUTLINE_COLOR,\n edges = true,\n } = opts;\n const entries = edges ? RESIZE_HANDLE_ANCHORS : RESIZE_HANDLE_ANCHORS.filter(isCornerHandle);\n\n const paint = {\n kind: 'square' as const,\n sizePx: handleSize,\n fill: { paint: { color: fill } },\n stroke: { paint: { color: stroke }, width: 1 },\n };\n\n return {\n id: 'selection.resize-handles',\n regions(state: ChromeState): readonly AffordanceRegion[] {\n const target = pickRenderTarget(state);\n if (!target) return [];\n const b = target.bounds;\n // The transform the framework applies to these regions. Needed here too,\n // because `fixedPoint` leaves the local frame — it travels to\n // `resizeAction`, which works in world coords.\n const xf = transformOf(state, target.id);\n return entries.map((c) => {\n const at = handlePoint(b, c);\n const fixedLocal = fixedCornerOf(b, c.anchor);\n const fixedPoint = localToWorld(xf, fixedLocal.x, fixedLocal.y);\n const corner = isCornerHandle(c);\n return {\n id: `${corner ? 'corner' : 'edge'}-${c.tag}`,\n targetId: target.id,\n shape: {\n kind: 'point' as const,\n x: at.x,\n y: at.y,\n hitRadiusPx: handleHitRadius,\n turned: true,\n ...(corner\n ? {\n cornerOf: {\n width: b.width,\n height: b.height,\n outward: { x: c.xEdge === 'min' ? -1 : 1, y: c.yEdge === 'min' ? -1 : 1 },\n },\n }\n : { edgeOf: { width: b.width, height: b.height } }),\n },\n paint,\n hitKind: c.kind,\n cursor: resizeCursor(c, xf),\n bind: (): AffordanceBinding => ({\n initialScratch: {\n anchor: c.anchor,\n targetId: target.id,\n fixedPoint,\n } satisfies CornerResizeScratch,\n }),\n } satisfies AffordanceRegion;\n });\n },\n };\n}\n\n/** The resize cursor along the axis a handle drags, as that axis is drawn on\n * screen: through the target's frame, a turn or a mirror included, and the\n * view's scale. The glyph is horizontal at angle 0. A corner drags along a\n * diagonal of its box picked by fixed-corner parity: a matched-axis anchor\n * (min-min / max-max fixed) drags along local (1, 1), mixed axes along\n * (1, -1). The keyword is the fallback rather than the answer: CSS has four\n * of them, which cannot express a target rotated to anything but a multiple\n * of 45°. */\nfunction resizeCursor(c: ResizeHandleAnchor, xf: TargetTransform): (at: unknown, view: View) => CursorSpec {\n const matched = c.anchor.x === c.anchor.y;\n const [lx, ly, fallback]: [number, number, string] = c.anchor.y === 'free'\n ? [1, 0, 'ew-resize']\n : c.anchor.x === 'free'\n ? [0, 1, 'ns-resize']\n : [1, matched ? 1 : -1, matched ? 'nwse-resize' : 'nesw-resize'];\n const [a, b, cc, d] = xf.toWorld;\n const wx = a * lx + cc * ly;\n const wy = b * lx + d * ly;\n return (_at, view) => ({ glyph: 'resize', angle: Math.atan2(wy * view.scale.y, wx * view.scale.x), fallback });\n}\n\nfunction pickRenderTarget(state: ChromeState): { id: string; bounds: Bounds } | null {\n if (state.multiActive && state.unionBounds) {\n return { id: MULTI_RESIZE_TARGET_ID, bounds: state.unionBounds };\n }\n if (state.selection.length === 1) {\n const id = state.selection[0];\n const b = state.boundsOf(id);\n return b ? { id, bounds: b } : null;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqDA,SAAgB,6BACd,OAAsC,CAAC,GAC3B;CACZ,MAAM,EACJ,kBAAkB,gBAClB,aAAa,gBACb,OAAO,mBACP,SAAS,sBACT,QAAQ,SACN;CACJ,MAAM,UAAU,QAAQ,wBAAwB,sBAAsB,OAAO,cAAc;CAE3F,MAAM,QAAQ;EACZ,MAAM;EACN,QAAQ;EACR,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE;EAC/B,QAAQ;GAAE,OAAO,EAAE,OAAO,OAAO;GAAG,OAAO;EAAE;CAC/C;CAEA,OAAO;EACL,IAAI;EACJ,QAAQ,OAAiD;GACvD,MAAM,SAAS,iBAAiB,KAAK;GACrC,IAAI,CAAC,QAAQ,OAAO,CAAC;GACrB,MAAM,IAAI,OAAO;GAIjB,MAAM,KAAK,YAAY,OAAO,OAAO,EAAE;GACvC,OAAO,QAAQ,KAAK,MAAM;IACxB,MAAM,KAAK,YAAY,GAAG,CAAC;IAC3B,MAAM,aAAaA,gBAAc,GAAG,EAAE,MAAM;IAC5C,MAAM,aAAa,aAAa,IAAI,WAAW,GAAG,WAAW,CAAC;IAC9D,MAAM,SAAS,eAAe,CAAC;IAC/B,OAAO;KACL,IAAI,GAAG,SAAS,WAAW,OAAO,GAAG,EAAE;KACvC,UAAU,OAAO;KACjB,OAAO;MACL,MAAM;MACN,GAAG,GAAG;MACN,GAAG,GAAG;MACN,aAAa;MACb,QAAQ;MACR,GAAI,SACA,EACE,UAAU;OACR,OAAO,EAAE;OACT,QAAQ,EAAE;OACV,SAAS;QAAE,GAAG,EAAE,UAAU,QAAQ,KAAK;QAAG,GAAG,EAAE,UAAU,QAAQ,KAAK;OAAE;MAC1E,EACF,IACA,EAAE,QAAQ;OAAE,OAAO,EAAE;OAAO,QAAQ,EAAE;MAAO,EAAE;KACrD;KACA;KACA,SAAS,EAAE;KACX,QAAQ,aAAa,GAAG,EAAE;KAC1B,aAAgC,EAC9B,gBAAgB;MACd,QAAQ,EAAE;MACV,UAAU,OAAO;MACjB;KACF,EACF;IACF;GACF,CAAC;EACH;CACF;AACF;;;;;;;;;AAUA,SAAS,aAAa,GAAuB,IAA8D;CACzG,MAAM,UAAU,EAAE,OAAO,MAAM,EAAE,OAAO;CACxC,MAAM,CAAC,IAAI,IAAI,YAAsC,EAAE,OAAO,MAAM,SAChE;EAAC;EAAG;EAAG;CAAW,IAClB,EAAE,OAAO,MAAM,SACb;EAAC;EAAG;EAAG;CAAW,IAClB;EAAC;EAAG,UAAU,IAAI;EAAI,UAAU,gBAAgB;CAAa;CACnE,MAAM,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG;CACzB,MAAM,KAAK,IAAI,KAAK,KAAK;CACzB,MAAM,KAAK,IAAI,KAAK,IAAI;CACxB,QAAQ,KAAK,UAAU;EAAE,OAAO;EAAU,OAAO,KAAK,MAAM,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,CAAC;EAAG;CAAS;AAC9G;AAEA,SAAS,iBAAiB,OAA2D;CACnF,IAAI,MAAM,eAAe,MAAM,aAC7B,OAAO;EAAE,IAAI;EAAwB,QAAQ,MAAM;CAAY;CAEjE,IAAI,MAAM,UAAU,WAAW,GAAG;EAChC,MAAM,KAAK,MAAM,UAAU;EAC3B,MAAM,IAAI,MAAM,SAAS,EAAE;EAC3B,OAAO,IAAI;GAAE;GAAI,QAAQ;EAAE,IAAI;CACjC;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/chrome/affordances/rotateCursor.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `rotate` glyph for a pointer at world point `at` turning something
|
|
4
|
+
* about world point `pivot`, seen through a view of `scale`. The glyph's arc
|
|
5
|
+
* is drawn over the top of its box, so its up points from the pivot to the
|
|
6
|
+
* pointer and the opening faces what is being turned.
|
|
7
|
+
*/
|
|
8
|
+
function rotateCursorAt(pivot, at, scale) {
|
|
9
|
+
return {
|
|
10
|
+
glyph: "rotate",
|
|
11
|
+
angle: Math.atan2((at.x - pivot.x) * scale.x, -(at.y - pivot.y) * scale.y),
|
|
12
|
+
fallback: "grab"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { rotateCursorAt };
|
|
17
|
+
//# sourceMappingURL=rotateCursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotateCursor.js","names":[],"sources":["../../../src/chrome/affordances/rotateCursor.ts"],"sourcesContent":["import type { CursorSpec } from '@weasel-js/cursor';\nimport type { Scale2 } from '@weasel-js/geom';\n\n/**\n * The `rotate` glyph for a pointer at world point `at` turning something\n * about world point `pivot`, seen through a view of `scale`. The glyph's arc\n * is drawn over the top of its box, so its up points from the pivot to the\n * pointer and the opening faces what is being turned.\n */\nexport function rotateCursorAt(\n pivot: { x: number; y: number },\n at: { x: number; y: number },\n scale: Scale2,\n): CursorSpec {\n return {\n glyph: 'rotate',\n angle: Math.atan2((at.x - pivot.x) * scale.x, -(at.y - pivot.y) * scale.y),\n fallback: 'grab',\n };\n}\n"],"mappings":";;;;;;;AASA,SAAgB,eACd,OACA,IACA,OACY;CACZ,OAAO;EACL,OAAO;EACP,OAAO,KAAK,OAAO,GAAG,IAAI,MAAM,KAAK,MAAM,GAAG,EAAE,GAAG,IAAI,MAAM,KAAK,MAAM,CAAC;EACzE,UAAU;CACZ;AACF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { rotateCursorAt } from "./rotateCursor.js";
|
|
2
|
+
import { targetCanRotate } from "../rotationHandleGeometry.js";
|
|
3
|
+
import { MULTI_RESIZE_TARGET_ID, localToWorld, transformOf } from "@weasel-js/core";
|
|
4
|
+
|
|
5
|
+
// src/chrome/affordances/rotationHandle.ts
|
|
6
|
+
var isAnnulusForm = (paint) => "fill" in paint || "stroke" in paint || "insetPx" in paint;
|
|
7
|
+
var DEFAULT_PAINT = {
|
|
8
|
+
fill: { paint: {
|
|
9
|
+
kind: "solid",
|
|
10
|
+
color: "rgba(26, 19, 13, 0.12)"
|
|
11
|
+
} },
|
|
12
|
+
insetPx: 10
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Rotation affordance for the active selection: an elliptical ring that wraps the selection —
|
|
16
|
+
* the smallest ellipse containing the AABB, minus the AABB itself. Hovering the ring sets the
|
|
17
|
+
* cursor (default the `rotate` glyph) and a drag from it triggers `rotateAction`.
|
|
18
|
+
*
|
|
19
|
+
* The ring is target-local — under target rotation the ellipse rotates with the AABB.
|
|
20
|
+
* Visibility is gated by chrome-caps' `'selection.rotation-handle'` rule. `paint: null` leaves
|
|
21
|
+
* the cursor change as the only cue.
|
|
22
|
+
*/
|
|
23
|
+
function createRotationAffordance(opts = {}) {
|
|
24
|
+
const { bandPx = 24, paint = DEFAULT_PAINT, cursor, handle } = opts;
|
|
25
|
+
const annulusPaint = (() => {
|
|
26
|
+
if (!paint) return null;
|
|
27
|
+
if (!isAnnulusForm(paint)) return {
|
|
28
|
+
kind: "annulus",
|
|
29
|
+
stroke: paint
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
kind: "annulus",
|
|
33
|
+
...paint.fill ? { fill: paint.fill } : {},
|
|
34
|
+
...paint.stroke ? { stroke: paint.stroke } : {},
|
|
35
|
+
...paint.insetPx !== void 0 ? { insetPx: paint.insetPx } : {}
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
return {
|
|
39
|
+
id: "selection.rotation-handle",
|
|
40
|
+
regions(state) {
|
|
41
|
+
const target = pickTarget(state);
|
|
42
|
+
if (!target) return [];
|
|
43
|
+
const b = target.bounds;
|
|
44
|
+
const halfW = b.width / 2;
|
|
45
|
+
const halfH = b.height / 2;
|
|
46
|
+
const pivot = localToWorld(transformOf(state, target.id), b.x + halfW, b.y + halfH);
|
|
47
|
+
const regionCursor = cursor ?? ((at, view) => rotateCursorAt(pivot, at, view.scale));
|
|
48
|
+
const bind = () => ({ initialScratch: {
|
|
49
|
+
targetId: target.id,
|
|
50
|
+
fixedPoint: pivot
|
|
51
|
+
} });
|
|
52
|
+
const region = {
|
|
53
|
+
id: "selection.rotation-handle",
|
|
54
|
+
targetId: target.id,
|
|
55
|
+
shape: {
|
|
56
|
+
kind: "annulus",
|
|
57
|
+
cx: b.x + halfW,
|
|
58
|
+
cy: b.y + halfH,
|
|
59
|
+
rx: halfW * Math.SQRT2,
|
|
60
|
+
ry: halfH * Math.SQRT2,
|
|
61
|
+
innerX: b.x,
|
|
62
|
+
innerY: b.y,
|
|
63
|
+
innerWidth: b.width,
|
|
64
|
+
innerHeight: b.height,
|
|
65
|
+
minBandPx: bandPx
|
|
66
|
+
},
|
|
67
|
+
...annulusPaint ? { paint: annulusPaint } : {},
|
|
68
|
+
hitKind: "rotate-handle",
|
|
69
|
+
cursor: regionCursor,
|
|
70
|
+
bind
|
|
71
|
+
};
|
|
72
|
+
if (!handle) return [region];
|
|
73
|
+
return [region, {
|
|
74
|
+
id: "rotation-badge",
|
|
75
|
+
targetId: target.id,
|
|
76
|
+
shape: {
|
|
77
|
+
kind: "point",
|
|
78
|
+
x: b.x + halfW,
|
|
79
|
+
y: b.y,
|
|
80
|
+
hitRadiusPx: handle.hitRadiusPx,
|
|
81
|
+
standoff: {
|
|
82
|
+
px: handle.distancePx,
|
|
83
|
+
normal: {
|
|
84
|
+
x: 0,
|
|
85
|
+
y: -1
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
hitKind: "rotate-handle",
|
|
90
|
+
cursor: regionCursor,
|
|
91
|
+
bind
|
|
92
|
+
}];
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function pickTarget(state) {
|
|
97
|
+
if (state.selection.length === 1) {
|
|
98
|
+
const id = state.selection[0];
|
|
99
|
+
if (!targetCanRotate(state, id)) return null;
|
|
100
|
+
const b = state.boundsOf(id);
|
|
101
|
+
return b ? {
|
|
102
|
+
id,
|
|
103
|
+
bounds: b
|
|
104
|
+
} : null;
|
|
105
|
+
}
|
|
106
|
+
if (state.multiActive && state.unionBounds) {
|
|
107
|
+
if (!targetCanRotate(state, MULTI_RESIZE_TARGET_ID)) return null;
|
|
108
|
+
return {
|
|
109
|
+
id: MULTI_RESIZE_TARGET_ID,
|
|
110
|
+
bounds: state.unionBounds
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { createRotationAffordance };
|
|
117
|
+
//# sourceMappingURL=rotationHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotationHandle.js","names":[],"sources":["../../../src/chrome/affordances/rotationHandle.ts"],"sourcesContent":["import type { Affordance, AffordanceBinding, AffordanceRegion, CommonAffordanceScratch } from '@weasel-js/core';\nimport type { ChromeState, Bounds } from '@weasel-js/core';\nimport type { CommandStroke, CommandFill } from '@weasel-js/paint';\nimport { MULTI_RESIZE_TARGET_ID } from '@weasel-js/core';\nimport { localToWorld, transformOf } from '@weasel-js/core';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport { rotateCursorAt } from './rotateCursor';\nimport { targetCanRotate } from '../rotationHandleGeometry';\n\n/** Options for `createRotationAffordance` — how thick the rotate band is\n * outside the selection, and how (or whether) it is painted. */\nexport interface RotationAffordanceOptions {\n /** Minimum screen-space thickness of the rotate-zone band outside the selection AABB, so\n * the zone stays hoverable at any zoom and any selection size. Default 24. */\n bandPx?: number;\n /** Paint for the ring. `null` / `false` = invisible. Default is a semi-transparent fill of\n * the band, contracted by `insetPx` screen pixels on the outer edge. Pass a `Stroke` (or\n * `{ fill, stroke, insetPx }`) to override. */\n paint?:\n | CommandStroke\n | { fill?: CommandFill; stroke?: CommandStroke; insetPx?: number }\n | null\n | false;\n /** Cursor while hovering the ring. Defaults to the `rotate` glyph turned\n * square to the line from the pivot to the pointer, falling back to\n * `'grab'` if the browser rejects the image. */\n cursor?: CursorSpec;\n /** A grab region for a rotate badge painted off the top edge — the one\n * the selection overlay's `rotationHandle` draws. `distancePx` is how far\n * off the edge it sits and `hitRadiusPx` the half-extent of its square,\n * both in screen pixels. Placed by the same `standoff` the painted badge\n * is, so the two cannot drift apart. Omitted, only the ring rotates. */\n handle?: { distancePx: number; hitRadiusPx: number };\n}\n\n/** What a rotation-handle hit hands to the rotate action: what is being\n * rotated, and the world-space pivot it turns around. */\nexport interface RotationScratch extends CommonAffordanceScratch {\n /** Id of the rotation target — single selection id, or\n * `MULTI_RESIZE_TARGET_ID` for multi-selection. */\n targetId: string;\n /** Rotation pivot in world coords — the AABB (or union AABB) center. */\n fixedPoint: { x: number; y: number };\n}\n\ntype AnnulusPaintForm = { fill?: CommandFill; stroke?: CommandStroke; insetPx?: number };\n\nconst isAnnulusForm = (paint: CommandStroke | AnnulusPaintForm): paint is AnnulusPaintForm =>\n 'fill' in paint || 'stroke' in paint || 'insetPx' in paint;\n\nconst DEFAULT_PAINT: AnnulusPaintForm = {\n fill: { paint: { kind: 'solid', color: 'rgba(26, 19, 13, 0.12)' } },\n insetPx: 10,\n};\n\n/**\n * Rotation affordance for the active selection: an elliptical ring that wraps the selection —\n * the smallest ellipse containing the AABB, minus the AABB itself. Hovering the ring sets the\n * cursor (default the `rotate` glyph) and a drag from it triggers `rotateAction`.\n *\n * The ring is target-local — under target rotation the ellipse rotates with the AABB.\n * Visibility is gated by chrome-caps' `'selection.rotation-handle'` rule. `paint: null` leaves\n * the cursor change as the only cue.\n */\nexport function createRotationAffordance(\n opts: RotationAffordanceOptions = {},\n): Affordance {\n const { bandPx = 24, paint = DEFAULT_PAINT, cursor, handle } = opts;\n\n // A bare `Stroke` carries none of the object form's three keys, and cannot be told apart\n // by its own `paint` since that is optional.\n const annulusPaint:\n | { kind: 'annulus'; fill?: CommandFill; stroke?: CommandStroke; insetPx?: number }\n | null = (() => {\n if (!paint) return null;\n if (!isAnnulusForm(paint)) {\n return { kind: 'annulus' as const, stroke: paint };\n }\n return {\n kind: 'annulus' as const,\n ...(paint.fill ? { fill: paint.fill } : {}),\n ...(paint.stroke ? { stroke: paint.stroke } : {}),\n ...(paint.insetPx !== undefined ? { insetPx: paint.insetPx } : {}),\n };\n })();\n\n return {\n id: 'selection.rotation-handle',\n regions(state: ChromeState): readonly AffordanceRegion[] {\n const target = pickTarget(state);\n if (!target) return [];\n const b = target.bounds;\n\n // The natural ring is the smallest ellipse containing the AABB. `minBandPx` asks the\n // framework to widen it to at least `bandPx` screen pixels outside the rect; the floor is\n // declared in screen units because `ChromeState` carries no view scale.\n const halfW = b.width / 2;\n const halfH = b.height / 2;\n\n const pivot = localToWorld(transformOf(state, target.id), b.x + halfW, b.y + halfH);\n const regionCursor: AffordanceRegion['cursor'] = cursor\n ?? ((at, view) => rotateCursorAt(pivot, at, view.scale));\n const bind = (): AffordanceBinding => ({\n initialScratch: {\n targetId: target.id,\n // `rotateAction` recomputes its own union pivot for multi-selection,\n // but the single-target case reads this.\n fixedPoint: pivot,\n } satisfies RotationScratch,\n });\n\n const region: AffordanceRegion = {\n id: 'selection.rotation-handle',\n targetId: target.id,\n shape: {\n kind: 'annulus',\n cx: b.x + halfW,\n cy: b.y + halfH,\n rx: halfW * Math.SQRT2,\n ry: halfH * Math.SQRT2,\n innerX: b.x,\n innerY: b.y,\n innerWidth: b.width,\n innerHeight: b.height,\n minBandPx: bandPx,\n },\n ...(annulusPaint ? { paint: annulusPaint } : {}),\n hitKind: 'rotate-handle',\n cursor: regionCursor,\n bind,\n };\n if (!handle) return [region];\n const badge: AffordanceRegion = {\n id: 'rotation-badge',\n targetId: target.id,\n shape: {\n kind: 'point',\n x: b.x + halfW,\n y: b.y,\n hitRadiusPx: handle.hitRadiusPx,\n standoff: { px: handle.distancePx, normal: { x: 0, y: -1 } },\n },\n hitKind: 'rotate-handle',\n cursor: regionCursor,\n bind,\n };\n return [region, badge];\n },\n };\n}\n\nfunction pickTarget(state: ChromeState): { id: string; bounds: Bounds } | null {\n if (state.selection.length === 1) {\n const id = state.selection[0];\n // Skip when the selected node's pose-descriptor declares it can't carry a rotation;\n // otherwise the ring would offer a rotate cursor over a node whose write is dropped.\n if (!targetCanRotate(state, id)) return null;\n const b = state.boundsOf(id);\n return b ? { id, bounds: b } : null;\n }\n // Multi-selection: anchor the ring to the union AABB; `rotateAction` ignores the synthetic\n // id and pivots at its own union center. Every selected id must support rotation — a\n // partial multi-rotate would feel broken.\n if (state.multiActive && state.unionBounds) {\n if (!targetCanRotate(state, MULTI_RESIZE_TARGET_ID)) return null;\n return { id: MULTI_RESIZE_TARGET_ID, bounds: state.unionBounds };\n }\n return null;\n}\n"],"mappings":";;;;;AA+CA,IAAM,iBAAiB,UACrB,UAAU,SAAS,YAAY,SAAS,aAAa;AAEvD,IAAM,gBAAkC;CACtC,MAAM,EAAE,OAAO;EAAE,MAAM;EAAS,OAAO;CAAyB,EAAE;CAClE,SAAS;AACX;;;;;;;;;;AAWA,SAAgB,yBACd,OAAkC,CAAC,GACvB;CACZ,MAAM,EAAE,SAAS,IAAI,QAAQ,eAAe,QAAQ,WAAW;CAI/D,MAAM,sBAEY;EACd,IAAI,CAAC,OAAO,OAAO;EACnB,IAAI,CAAC,cAAc,KAAK,GACtB,OAAO;GAAE,MAAM;GAAoB,QAAQ;EAAM;EAEnD,OAAO;GACL,MAAM;GACN,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;GACzC,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;GAC/C,GAAI,MAAM,YAAY,SAAY,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;EAClE;CACF,EAAA,CAAG;CAEL,OAAO;EACL,IAAI;EACJ,QAAQ,OAAiD;GACvD,MAAM,SAAS,WAAW,KAAK;GAC/B,IAAI,CAAC,QAAQ,OAAO,CAAC;GACrB,MAAM,IAAI,OAAO;GAKjB,MAAM,QAAQ,EAAE,QAAQ;GACxB,MAAM,QAAQ,EAAE,SAAS;GAEzB,MAAM,QAAQ,aAAa,YAAY,OAAO,OAAO,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE,IAAI,KAAK;GAClF,MAAM,eAA2C,YAC1C,IAAI,SAAS,eAAe,OAAO,IAAI,KAAK,KAAK;GACxD,MAAM,cAAiC,EACrC,gBAAgB;IACd,UAAU,OAAO;IAGjB,YAAY;GACd,EACF;GAEA,MAAM,SAA2B;IAC/B,IAAI;IACJ,UAAU,OAAO;IACjB,OAAO;KACL,MAAM;KACN,IAAI,EAAE,IAAI;KACV,IAAI,EAAE,IAAI;KACV,IAAI,QAAQ,KAAK;KACjB,IAAI,QAAQ,KAAK;KACjB,QAAQ,EAAE;KACV,QAAQ,EAAE;KACV,YAAY,EAAE;KACd,aAAa,EAAE;KACf,WAAW;IACb;IACA,GAAI,eAAe,EAAE,OAAO,aAAa,IAAI,CAAC;IAC9C,SAAS;IACT,QAAQ;IACR;GACF;GACA,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM;GAe3B,OAAO,CAAC,QAAQ;IAbd,IAAI;IACJ,UAAU,OAAO;IACjB,OAAO;KACL,MAAM;KACN,GAAG,EAAE,IAAI;KACT,GAAG,EAAE;KACL,aAAa,OAAO;KACpB,UAAU;MAAE,IAAI,OAAO;MAAY,QAAQ;OAAE,GAAG;OAAG,GAAG;MAAG;KAAE;IAC7D;IACA,SAAS;IACT,QAAQ;IACR;GAEc,CAAK;EACvB;CACF;AACF;AAEA,SAAS,WAAW,OAA2D;CAC7E,IAAI,MAAM,UAAU,WAAW,GAAG;EAChC,MAAM,KAAK,MAAM,UAAU;EAG3B,IAAI,CAAC,gBAAgB,OAAO,EAAE,GAAG,OAAO;EACxC,MAAM,IAAI,MAAM,SAAS,EAAE;EAC3B,OAAO,IAAI;GAAE;GAAI,QAAQ;EAAE,IAAI;CACjC;CAIA,IAAI,MAAM,eAAe,MAAM,aAAa;EAC1C,IAAI,CAAC,gBAAgB,OAAO,sBAAsB,GAAG,OAAO;EAC5D,OAAO;GAAE,IAAI;GAAwB,QAAQ,MAAM;EAAY;CACjE;CACA,OAAO;AACT"}
|