@weasel-js/editing 0.0.0-stage → 1.19.1

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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/actions/align/action.js +102 -0
  4. package/dist/actions/align/action.js.map +1 -0
  5. package/dist/actions/align/align.js +114 -0
  6. package/dist/actions/align/align.js.map +1 -0
  7. package/dist/actions/clipboard/action.js +130 -0
  8. package/dist/actions/clipboard/action.js.map +1 -0
  9. package/dist/actions/distribute/action.js +93 -0
  10. package/dist/actions/distribute/action.js.map +1 -0
  11. package/dist/actions/distribute/distribute.js +60 -0
  12. package/dist/actions/distribute/distribute.js.map +1 -0
  13. package/dist/actions/distribute/plan.js +55 -0
  14. package/dist/actions/distribute/plan.js.map +1 -0
  15. package/dist/actions/edit/createPaintAction.js +109 -0
  16. package/dist/actions/edit/createPaintAction.js.map +1 -0
  17. package/dist/actions/edit/duplicate.js +91 -0
  18. package/dist/actions/edit/duplicate.js.map +1 -0
  19. package/dist/actions/edit/escape.js +34 -0
  20. package/dist/actions/edit/escape.js.map +1 -0
  21. package/dist/actions/edit/group.js +277 -0
  22. package/dist/actions/edit/group.js.map +1 -0
  23. package/dist/actions/edit/ingest.js +112 -0
  24. package/dist/actions/edit/ingest.js.map +1 -0
  25. package/dist/actions/edit/nudge.js +93 -0
  26. package/dist/actions/edit/nudge.js.map +1 -0
  27. package/dist/actions/edit/selectAll.js +48 -0
  28. package/dist/actions/edit/selectAll.js.map +1 -0
  29. package/dist/actions/edit/setFill.js +52 -0
  30. package/dist/actions/edit/setFill.js.map +1 -0
  31. package/dist/actions/edit/setFillOpacity.js +26 -0
  32. package/dist/actions/edit/setFillOpacity.js.map +1 -0
  33. package/dist/actions/edit/setStroke.js +57 -0
  34. package/dist/actions/edit/setStroke.js.map +1 -0
  35. package/dist/actions/edit/setStrokeOpacity.js +28 -0
  36. package/dist/actions/edit/setStrokeOpacity.js.map +1 -0
  37. package/dist/actions/edit/setStrokeWidth.js +48 -0
  38. package/dist/actions/edit/setStrokeWidth.js.map +1 -0
  39. package/dist/actions/edit/setVertexColor.js +38 -0
  40. package/dist/actions/edit/setVertexColor.js.map +1 -0
  41. package/dist/actions/flip/action.js +204 -0
  42. package/dist/actions/flip/action.js.map +1 -0
  43. package/dist/actions/flip/helpers.js +80 -0
  44. package/dist/actions/flip/helpers.js.map +1 -0
  45. package/dist/actions/pathfinder/action.js +107 -0
  46. package/dist/actions/pathfinder/action.js.map +1 -0
  47. package/dist/actions/pathfinder/booleanGroupAction.js +111 -0
  48. package/dist/actions/pathfinder/booleanGroupAction.js.map +1 -0
  49. package/dist/actions/pathfinder/keymap.js +51 -0
  50. package/dist/actions/pathfinder/keymap.js.map +1 -0
  51. package/dist/actions/reorder/reorder.js +243 -0
  52. package/dist/actions/reorder/reorder.js.map +1 -0
  53. package/dist/actions/transformAgain/action.js +88 -0
  54. package/dist/actions/transformAgain/action.js.map +1 -0
  55. package/dist/actions/transformAgain/transformSelection.js +35 -0
  56. package/dist/actions/transformAgain/transformSelection.js.map +1 -0
  57. package/dist/engineStandardActions.js +45 -0
  58. package/dist/engineStandardActions.js.map +1 -0
  59. package/dist/index.d.ts +679 -0
  60. package/dist/index.js +37 -0
  61. package/dist/namedPresets.js +71 -0
  62. package/dist/namedPresets.js.map +1 -0
  63. package/dist/presets/arrange.js +51 -0
  64. package/dist/presets/arrange.js.map +1 -0
  65. package/dist/presets/composites.js +43 -0
  66. package/dist/presets/composites.js.map +1 -0
  67. package/dist/presets/edit.js +113 -0
  68. package/dist/presets/edit.js.map +1 -0
  69. package/dist/presets/ingest.js +13 -0
  70. package/dist/presets/ingest.js.map +1 -0
  71. package/dist/presets/pathfinder.js +23 -0
  72. package/dist/presets/pathfinder.js.map +1 -0
  73. package/dist/presets/select.js +18 -0
  74. package/dist/presets/select.js.map +1 -0
  75. package/dist/presets/tools.js +15 -0
  76. package/dist/presets/tools.js.map +1 -0
  77. package/dist/presets/transform.js +39 -0
  78. package/dist/presets/transform.js.map +1 -0
  79. package/dist/useStandardActions.js +26 -0
  80. package/dist/useStandardActions.js.map +1 -0
  81. package/package.json +59 -4
@@ -0,0 +1,679 @@
1
+ import * as _weasel_js_routing from '@weasel-js/routing';
2
+ import { WorldPoint, Action, ActionDeps, Contribution } from '@weasel-js/routing';
3
+ import { SpatialReference, NodeId, Op, PoseDescriptor, PoseComposition, DrawnBoundsScene, Bounds, SpatialReferenceSources, FeaturePreset, RepeatableTransform, BooleanStrokes } from '@weasel-js/core';
4
+ import { Scale2 } from '@weasel-js/geom';
5
+ import { StandardDeps, AnyScene, BooleanShapeOp } from '@weasel-js/core/engine';
6
+ import { KeySpec } from '@weasel-js/gestures';
7
+
8
+ /** Edge or center the selection should align to within the reference's
9
+ * bounds (rotated members contribute their ink extent). */
10
+ type AlignEdge = 'left' | 'right' | 'top' | 'bottom' | 'center-x' | 'center-y';
11
+ /** What the selection aligns to: `'union'` — the selection's
12
+ * own visual union AABB, the default — or a {@link SpatialReference}. */
13
+ type AlignReference = 'union' | SpatialReference;
14
+ /** The bounds each member of `bounds` aligns to under `to`, or
15
+ * `null` when there is nothing to align: a union of fewer than two members,
16
+ * an empty selection, or a reference that names nothing right now. */
17
+ declare function alignTargetBounds(bounds: readonly Bounds[], to: AlignReference | undefined, src: SpatialReferenceSources): Bounds | null;
18
+ /** Adapter for `useAlign`. */
19
+ interface AlignAdapter<TPose> {
20
+ getSelection(): NodeId[];
21
+ /** The pose as stored — local to the node's parent. */
22
+ getPose(id: NodeId): TPose;
23
+ /** The node's container, `null` for a root: the chain a pose is composed
24
+ * through when container poses define a frame. */
25
+ getParent(id: NodeId): NodeId | null;
26
+ applyOps?(ops: Op[], label?: string): void;
27
+ }
28
+ /** Options for `useAlign`. */
29
+ interface UseAlignOptions<TPose> {
30
+ /** Projection between `TPose` and bounds. Defaults to `RECT_POSE_DESCRIPTOR`
31
+ * for `{x,y,width,height}` poses. Pass `pathPoseDescriptor` for `Path`
32
+ * poses so polygon coords translate correctly. */
33
+ geometry?: PoseDescriptor<TPose>;
34
+ /** Label passed to applyOps. Default 'Align'. */
35
+ label?: string;
36
+ /** How local poses fold up to world. Default IDENTITY, which takes every
37
+ * pose the adapter answers as world; over a scene's adapter, pass
38
+ * `scene.composition`. */
39
+ composition?: PoseComposition<TPose>;
40
+ /** The nodes behind the adapter's ids. With it, a stroked node aligns by
41
+ * the box it is drawn with (`drawnBoundsOf`); without, by its pose box.
42
+ * Pass a `Scene` through `drawnBoundsScene` so a path-derived node is
43
+ * boxed by its path. */
44
+ scene?: DrawnBoundsScene;
45
+ /** View scale a screen-pixel stroke is resolved at. Default 1. */
46
+ viewScale?: () => number | Scale2;
47
+ }
48
+ /** Return shape of `useAlign`. */
49
+ interface UseAlignReturn {
50
+ /** Imperative trigger. `to` defaults to `'union'`, which needs two items;
51
+ * any other reference aligns a single item too. `'pointer'` reads the
52
+ * surrounding `<PointerContextProvider>`. */
53
+ align(edge: AlignEdge, to?: AlignReference): void;
54
+ }
55
+ /** Compute the (dx, dy) translation that moves AABB `b` so that the requested
56
+ * `edge`/center matches the corresponding feature of the union AABB `u`. */
57
+ declare function alignDeltaFor(b: Bounds, u: Bounds, edge: AlignEdge): {
58
+ dx: number;
59
+ dy: number;
60
+ };
61
+ /** Align the current selection to a shared edge or center of the selection's
62
+ * union AABB, or of another reference. Single batch — one undo step.
63
+ *
64
+ * The edge is a world edge: bounds are measured and translated in world, and
65
+ * each result is stored back in its own parent's frame. A node in a singular
66
+ * frame, where no stored pose reaches the edge, stays where it is. */
67
+ declare function useAlign<TPose>(adapter: AlignAdapter<TPose>, options?: UseAlignOptions<TPose>): UseAlignReturn;
68
+
69
+ /** Axis along which selection is distributed. `'x'` spreads horizontally. */
70
+ type DistributeAxis = 'x' | 'y';
71
+ /** `'centers'` spaces centers equally; `'gaps'` makes the gap between
72
+ * consecutive items equal. Both measure a rotated item by its ink extent.
73
+ * Endpoints stay put in both modes. */
74
+ type DistributeMode = 'centers' | 'gaps';
75
+ /** Adapter for `useDistribute`. */
76
+ interface DistributeAdapter<TPose> {
77
+ getSelection(): NodeId[];
78
+ /** The pose as stored — local to the node's parent. */
79
+ getPose(id: NodeId): TPose;
80
+ /** The node's container, `null` for a root: the chain a pose is composed
81
+ * through when container poses define a frame. */
82
+ getParent(id: NodeId): NodeId | null;
83
+ applyOps?(ops: Op[], label?: string): void;
84
+ }
85
+ /** Options for `useDistribute`. */
86
+ interface UseDistributeOptions<TPose> {
87
+ /** Projection between `TPose` and bounds. Defaults to `RECT_POSE_DESCRIPTOR`
88
+ * for `{x,y,width,height}` poses. */
89
+ geometry?: PoseDescriptor<TPose>;
90
+ /** Default mode when `distribute(axis)` is called without one. Default 'centers'. */
91
+ defaultMode?: DistributeMode;
92
+ /** Label passed to applyOps. Default 'Distribute'. */
93
+ label?: string;
94
+ /** How local poses fold up to world. Default IDENTITY, which takes every
95
+ * pose the adapter answers as world; over a scene's adapter, pass
96
+ * `scene.composition`. */
97
+ composition?: PoseComposition<TPose>;
98
+ /** The nodes behind the adapter's ids, as `useAlign` takes them: with it, a
99
+ * stroked node is spaced by the box it is drawn with. */
100
+ scene?: UseAlignOptions<TPose>['scene'];
101
+ /** View scale a screen-pixel stroke is resolved at. Default 1. */
102
+ viewScale?: UseAlignOptions<TPose>['viewScale'];
103
+ }
104
+ /** Return shape of `useDistribute`. */
105
+ interface UseDistributeReturn {
106
+ /** Imperative trigger. No-op when fewer than 3 items selected. */
107
+ distribute(axis: DistributeAxis, mode?: DistributeMode): void;
108
+ }
109
+ /** Distribute the current multi-selection along `axis`. Requires ≥3 items;
110
+ * no-op otherwise. Endpoints (min and max along the axis) stay put; the
111
+ * remaining items are repositioned. Single batch — one undo step.
112
+ *
113
+ * The span being divided is a world span: bounds are measured and translated
114
+ * in world, and each result is stored back in its own parent's frame. A node
115
+ * in a singular frame stays where it is. */
116
+ declare function useDistribute<TPose>(adapter: DistributeAdapter<TPose>, options?: UseDistributeOptions<TPose>): UseDistributeReturn;
117
+
118
+ /**
119
+ * Pose-flip helpers used by `flipAction` (via `defaults/flip.ts`).
120
+ *
121
+ * These were extracted from the legacy `useFlip` hook when it was removed —
122
+ * they remain because the descriptor-style `flipAction` still needs to reflect
123
+ * arbitrary `TPose` values through a `PoseDescriptor`.
124
+ */
125
+
126
+ /** Axis for flip. `'x'` mirrors horizontally (left↔right); `'y'` mirrors vertically (top↔bottom). */
127
+ type FlipAxis = 'x' | 'y';
128
+ /** How a multi-selection flip chooses its pivot.
129
+ *
130
+ * - `'each'` — every pose mirrors about its own AABB; spatial layout of the
131
+ * selection is unchanged, individual items are reflected in place.
132
+ * - `'union'` — every pose mirrors about the selection's union AABB; items
133
+ * swap sides as well as reflect, matching Illustrator/Figma defaults.
134
+ * - a {@link SpatialReference} — every pose mirrors about the center of the
135
+ * bounds it names: the pointer, a world point or rect, or a key node. */
136
+ type FlipPivot = 'each' | 'union' | SpatialReference;
137
+
138
+ /**
139
+ * The params editing's own actions read, merged into routing's
140
+ * `ActionParamSchema` so `<SceneCanvas tune>` types them.
141
+ */
142
+
143
+ /** `align.*`'s params. */
144
+ type AlignParams = {
145
+ /** The point a reference of `'pointer'` resolves to in place of the pointer dep. */
146
+ world?: WorldPoint;
147
+ /** Default the selection. */
148
+ to?: AlignReference;
149
+ };
150
+ /** `flip`'s params. */
151
+ type FlipParams = {
152
+ /** The point a pivot of `'pointer'` resolves to in place of the pointer dep. */
153
+ world?: WorldPoint;
154
+ /** Default `'x'`. */
155
+ axis?: FlipAxis;
156
+ /** Default `'each'`. */
157
+ pivot?: FlipPivot;
158
+ };
159
+ /** A `distribute.*` action's params: what it spaces evenly. */
160
+ type DistributeParams = {
161
+ mode?: DistributeMode;
162
+ };
163
+ /** A reorder action's params: one step, or all the way to the front or back. */
164
+ type ReorderParams = {
165
+ distance?: 'adjacent' | 'extreme';
166
+ };
167
+ declare module '@weasel-js/routing' {
168
+ interface ActionParamSchema {
169
+ 'align.left': AlignParams;
170
+ 'align.centerX': AlignParams;
171
+ 'align.right': AlignParams;
172
+ 'align.top': AlignParams;
173
+ 'align.centerY': AlignParams;
174
+ 'align.bottom': AlignParams;
175
+ flip: FlipParams;
176
+ 'distribute.horizontal': DistributeParams;
177
+ 'distribute.vertical': DistributeParams;
178
+ 'reorder.forward': ReorderParams;
179
+ 'reorder.backward': ReorderParams;
180
+ }
181
+ }
182
+
183
+ /** The select and lasso tools: click, marquee, lasso, and clearing on an empty click. */
184
+ declare const selectPreset: FeaturePreset;
185
+
186
+ /** The selection outline, drawn only while this is on. */
187
+ declare const outlinePreset: FeaturePreset;
188
+ /** Resize handles, drawn and bound. A handle sits over the selected body, so
189
+ * it refines `move`, whose binding matches a handle drag too. */
190
+ declare const resizePreset: FeaturePreset;
191
+ /** The rotation handle, drawn and bound. It refines `move` as `resize` does. */
192
+ declare const rotatePreset: FeaturePreset;
193
+ /** Drag a body to move it, Alt-drag to clone it, under any tool that does not
194
+ * claim the drag. */
195
+ declare const movePreset: FeaturePreset;
196
+
197
+ /** Escape, and canceling the gesture in flight. */
198
+ declare const escapePreset: FeaturePreset;
199
+ /** The context menu. */
200
+ declare const contextMenuPreset: FeaturePreset;
201
+ /** Cmd/Ctrl+A. */
202
+ declare const selectAllPreset: FeaturePreset;
203
+ /** Duplicate, and repeating the last transform. */
204
+ declare const duplicatePreset: FeaturePreset;
205
+ /** Deleting the selection. */
206
+ declare const deletePreset: FeaturePreset;
207
+ /** Group and ungroup. */
208
+ declare const groupPreset: FeaturePreset;
209
+ /** The arrow keys. */
210
+ declare const nudgePreset: FeaturePreset;
211
+ /** Fill and stroke, their opacities, the stroke's width, and a path's vertex colors. */
212
+ declare const stylePreset: FeaturePreset;
213
+ /**
214
+ * Cut, copy, and paste.
215
+ *
216
+ * Cmd/Ctrl+V arrives as a DOM `paste` event, and two presets answer it. This
217
+ * one brings `clipboard.pasteEvent`, which pastes nodes a kit canvas copied
218
+ * and nothing else; `ingest` takes those plus images, SVG, files, and every
219
+ * OS drop. With both on, `ingest` answers alone.
220
+ */
221
+ declare const clipboardPreset: FeaturePreset;
222
+ /** Every edit preset above, and their keys. */
223
+ declare const editPreset: FeaturePreset;
224
+
225
+ /** Flipping the selection. */
226
+ declare const flipPreset: FeaturePreset;
227
+ /** Bringing forward and sending backward. */
228
+ declare const reorderPreset: FeaturePreset;
229
+ /** Aligning edges and centers. */
230
+ declare const alignPreset: FeaturePreset;
231
+ /** Distributing across or down. */
232
+ declare const distributePreset: FeaturePreset;
233
+ /** Align, distribute, reorder, and flip. */
234
+ declare const arrangePreset: FeaturePreset;
235
+
236
+ /** The pathfinder booleans, and the live boolean group. */
237
+ declare const pathfinderPreset: FeaturePreset;
238
+
239
+ /** The select tool and the lasso. */
240
+ declare const selectToolsPreset: FeaturePreset;
241
+ /** The tools that drag out a primitive: rect, ellipse, line, polygon, star. */
242
+ declare const shapeToolsPreset: FeaturePreset;
243
+
244
+ /** Select, and the selection's outline. */
245
+ declare const pickPreset: FeaturePreset;
246
+ /** Resize and rotate handles. */
247
+ declare const transformPreset: FeaturePreset;
248
+ /** Every kit behavior: view, pick, transform, move, edit, arrange, the pathfinder, and ingest. Tools that make
249
+ * things are left to the canvas, through the `tools:` presets or `defaultTools`; path editing is
250
+ * `@weasel-js/path-tools`'. */
251
+ declare const drawPreset: FeaturePreset;
252
+
253
+ /** Dropped and pasted content: images, SVG, files, and whatever
254
+ * `ingestion.handlers` accept, on Cmd/Ctrl+V or an OS drop. */
255
+ declare const ingestPreset: FeaturePreset;
256
+
257
+ /**
258
+ * The kit's presets by name, core's view presets and editing's, for
259
+ * `namedFeatures('draw')` and for listings that key presets by name. Importing
260
+ * this module loads every preset's actions; a canvas handed preset objects
261
+ * carries only those.
262
+ */
263
+
264
+ /** Each kit preset by name, each after the presets it includes. */
265
+ declare const FEATURE_PRESETS: {
266
+ readonly 'tools:select': FeaturePreset;
267
+ readonly 'tools:view': FeaturePreset;
268
+ readonly 'tools:shape': FeaturePreset;
269
+ readonly view: FeaturePreset;
270
+ readonly select: FeaturePreset;
271
+ readonly outline: FeaturePreset;
272
+ readonly pick: FeaturePreset;
273
+ readonly move: FeaturePreset;
274
+ readonly resize: FeaturePreset;
275
+ readonly rotate: FeaturePreset;
276
+ readonly transform: FeaturePreset;
277
+ readonly escape: FeaturePreset;
278
+ readonly contextMenu: FeaturePreset;
279
+ readonly selectAll: FeaturePreset;
280
+ readonly duplicate: FeaturePreset;
281
+ readonly delete: FeaturePreset;
282
+ readonly group: FeaturePreset;
283
+ readonly nudge: FeaturePreset;
284
+ readonly style: FeaturePreset;
285
+ readonly clipboard: FeaturePreset;
286
+ readonly edit: FeaturePreset;
287
+ readonly flip: FeaturePreset;
288
+ readonly reorder: FeaturePreset;
289
+ readonly align: FeaturePreset;
290
+ readonly distribute: FeaturePreset;
291
+ readonly arrange: FeaturePreset;
292
+ readonly pathfinder: FeaturePreset;
293
+ readonly ingest: FeaturePreset;
294
+ readonly draw: FeaturePreset;
295
+ };
296
+ /** A kit preset's name, as `namedFeatures` takes it. */
297
+ type FeatureName = keyof typeof FEATURE_PRESETS;
298
+ /** Every kit preset's name, each after the presets it includes. */
299
+ declare const FEATURE_NAMES: readonly FeatureName[];
300
+ /**
301
+ * The kit's presets for the given names, in order: `namedFeatures('pick', 'move')`
302
+ * is `[pickPreset, movePreset]`, and means exactly what passing those objects
303
+ * means. It resolves names only; nothing else is implied, so a canvas that
304
+ * pans and zooms names `'view'` (or `'draw'`, which includes it). Importing it
305
+ * puts every kit preset in the bundle; import the objects to carry only those.
306
+ */
307
+ declare function namedFeatures(...names: readonly FeatureName[]): FeaturePreset[];
308
+ /** The kit-standard action ids each preset registers itself, leaving out those of the presets it includes. */
309
+ declare const FEATURE_ACTION_IDS: Readonly<Record<FeatureName, readonly string[]>>;
310
+ /** Every kit-standard action: the baseline, each kit preset's in table order, then the
311
+ * tool-driven ones. */
312
+ declare const KIT_STANDARD_ACTIONS: readonly Action[];
313
+
314
+ /**
315
+ * `useStandardActions` — register the kit-standard action descriptors into the
316
+ * nearest `<ActionsProvider>` and publish dep sources into the nearest
317
+ * `<DepRegistryProvider>`. Falls back silently to a no-op when either is
318
+ * not in scope.
319
+ */
320
+
321
+ /** Options for `useStandardActions`: which actions to register, and the deps they read. */
322
+ interface UseStandardActionsOptions extends StandardDeps {
323
+ /**
324
+ * The actions to register, in order. Default: every kit-standard action
325
+ * (`KIT_STANDARD_ACTION_IDS`). A preset's `actions` is a set in this form.
326
+ */
327
+ actions?: readonly Action[];
328
+ /**
329
+ * Ids of kit-standard actions to leave unregistered, so a consumer can bind
330
+ * its own. Ids that name no kit action are ignored;
331
+ * `KIT_STANDARD_ACTION_IDS` is the full list.
332
+ */
333
+ exclude?: Iterable<string>;
334
+ }
335
+ /** Every id `useStandardActions` can register, each kit preset's in turn and
336
+ * then the tool-driven ones. It holds `clipboard.pasteEvent` back while
337
+ * `ingest` is registered. */
338
+ declare const KIT_STANDARD_ACTION_IDS: readonly string[];
339
+ /**
340
+ * Register each kit-standard dep source and action descriptor into the
341
+ * surrounding `<ActionsProvider>` and `<DepRegistryProvider>` (typically
342
+ * provided by `<SceneCanvas>`); a silent no-op when either is absent.
343
+ *
344
+ * Each dep option is published as a live source in the dep registry under its
345
+ * canonical name (`selection`, `scene`, …). The source reads the latest
346
+ * option value at invocation time, so consumers don't have to memoize their
347
+ * dep objects.
348
+ */
349
+ declare function useStandardActions(opts: UseStandardActionsOptions): void;
350
+
351
+ /**
352
+ * Flips the selection. `params.axis` (`'x'` | `'y'`, default `'x'`) picks the
353
+ * direction, and the optional `params.pivot` (a `FlipPivot`, default `'each'`)
354
+ * picks what it mirrors about.
355
+ */
356
+ declare const flipAction: _weasel_js_routing.Action & {
357
+ id: "flip";
358
+ };
359
+
360
+ /**
361
+ * Parametric descriptor for forward reorder (`reorder.forward`).
362
+ *
363
+ * Collapses the old `reorder.forward` (adjacent) and `reorder.front`
364
+ * (extreme) actions into one descriptor with two keybindings. The distance
365
+ * param (`'adjacent'` | `'extreme'`) is carried in `opts.params.distance`
366
+ * and forwarded to `invoker.run` by the dispatcher.
367
+ */
368
+ declare const reorderForwardAction: _weasel_js_routing.Action & {
369
+ id: "reorder.forward";
370
+ };
371
+ /**
372
+ * Parametric descriptor for backward reorder (`reorder.backward`).
373
+ *
374
+ * Collapses the old `reorder.backward` (adjacent) and `reorder.back`
375
+ * (extreme) actions into one descriptor with two keybindings.
376
+ */
377
+ declare const reorderBackwardAction: _weasel_js_routing.Action & {
378
+ id: "reorder.backward";
379
+ };
380
+
381
+ /** Static descriptor for align-left. */
382
+ declare const alignLeftAction: Action;
383
+ /** Static descriptor for align-right. */
384
+ declare const alignRightAction: Action;
385
+ /** Static descriptor for align-top. */
386
+ declare const alignTopAction: Action;
387
+ /** Static descriptor for align-bottom. */
388
+ declare const alignBottomAction: Action;
389
+ /** Static descriptor for align-center-x. */
390
+ declare const alignCenterXAction: Action;
391
+ /** Static descriptor for align-center-y. */
392
+ declare const alignCenterYAction: Action;
393
+
394
+ /** Static descriptor for distribute-horizontal. */
395
+ declare const distributeHorizontalAction: Action;
396
+ /** Static descriptor for distribute-vertical. */
397
+ declare const distributeVerticalAction: Action;
398
+
399
+ /**
400
+ * The kit-standard actions a host of any dimension registers: history,
401
+ * selection, move and clone, insert, nudge, duplicate, delete, group, and the
402
+ * keys that leave a gesture. Pass it to `useActionSet`. None loads the 2D stack;
403
+ * the 2D editing features (style, align, paths, clipboard, ingest) are
404
+ * `useStandardActions`' alone.
405
+ */
406
+ declare const ENGINE_STANDARD_ACTIONS: readonly Action[];
407
+
408
+ /**
409
+ * Static descriptor for the `escape` Action. Clears selection.
410
+ */
411
+ declare const escapeAction: Action & {
412
+ requires: string[];
413
+ };
414
+
415
+ /**
416
+ * Static descriptor for the `selectAll` Action. Selects every scene node the
417
+ * user can see and reach — hidden and locked nodes, pages and the page run
418
+ * (`nodeGates`), and nodes on a layer the asking view does not paint, are left
419
+ * out, so Cmd+A then Delete cannot take content that is off screen or locked.
420
+ * Inside an entered group it selects only what the group holds.
421
+ */
422
+ declare const selectAllAction: Action & {
423
+ requires: string[];
424
+ };
425
+
426
+ /**
427
+ * Copy each selected node, with its subtree, offset by `(dx, dy)` in world
428
+ * space whatever frame it is stored in, as one
429
+ * undoable batch labeled `label`, and select the copies. Returns the copies'
430
+ * ids, or null when nothing was copied or the scene refused the copies.
431
+ */
432
+ declare function duplicateSelection(deps: ActionDeps, dx: number, dy: number, label?: string): string[] | null;
433
+ /**
434
+ * Static descriptor for the `duplicate` Action. Copies each selected node —
435
+ * with its subtree, so duplicating a group produces a populated group — offset
436
+ * by a small nudge, as one undoable batch, then selects the copies.
437
+ */
438
+ declare const duplicateAction: Action & {
439
+ requires: string[];
440
+ };
441
+
442
+ /**
443
+ * Creates a structural `GroupNode` and reparents the current selection
444
+ * under it as a single undoable batch, in the container `groupingSite` names,
445
+ * in the frontmost member's place, the members keeping their stacking.
446
+ *
447
+ * Grouping never moves a member on screen, unless with the pasteboard off
448
+ * the members lie wholly off every page and move onto one. The container takes the world
449
+ * envelope of its members' ink, and each member is re-expressed in that
450
+ * container's frame. The container is a frame, so its pose is authored rather
451
+ * than derived from its members, whose poses are expressed in it. A node
452
+ * following a member that changes page goes where `followerMoves` says.
453
+ */
454
+ declare const groupAction: Action & {
455
+ requires: string[];
456
+ };
457
+ /**
458
+ * Dissolves each selected group, or boolean group, by reparenting its children up to the
459
+ * container's own parent (preserving z-order) and removing the now-empty
460
+ * container, as a single undoable batch. Selected marks, children or not, are
461
+ * ignored. The freed children become the new selection, and nothing moves on
462
+ * screen. Every node deriving from a dissolved container, a freed child or not, drops that container from its
463
+ * `dependsOn`, so the batch removes the containers and nothing else. Disabled while any node it would move,
464
+ * rewrite, or remove is locked, and while a child would land in a singular frame, where it could not stay
465
+ * where it is shown. A child of a singular container keeps the flat place it is shown at.
466
+ */
467
+ declare const ungroupAction: Action & {
468
+ requires: string[];
469
+ };
470
+
471
+ /** Nudge up: the Up arrow, a big step with Shift. */
472
+ declare const nudgeUpAction: Action & {
473
+ requires: string[];
474
+ };
475
+ /** Nudge down: the Down arrow, a big step with Shift. */
476
+ declare const nudgeDownAction: Action & {
477
+ requires: string[];
478
+ };
479
+ /** Nudge left: the Left arrow, a big step with Shift. */
480
+ declare const nudgeLeftAction: Action & {
481
+ requires: string[];
482
+ };
483
+ /** Nudge right: the Right arrow, a big step with Shift. */
484
+ declare const nudgeRightAction: Action & {
485
+ requires: string[];
486
+ };
487
+
488
+ /**
489
+ * Static descriptor for the `setFill` Action.
490
+ *
491
+ * Takes either `color` (a hex string) or `paint` (a whole `Paint`, for
492
+ * gradients and patterns). `paint` wins when both are present.
493
+ *
494
+ * Alpha semantics: alpha lives on the paint's `opacity`. A 6-char (no-alpha)
495
+ * color adopts the alpha of the node's existing paint; an 8-char color states
496
+ * its own. A `paint` is written verbatim.
497
+ */
498
+ declare const setFillAction: Action;
499
+
500
+ /**
501
+ * Static descriptor for the `setFillOpacity` Action.
502
+ *
503
+ * `params.alpha01` (0..1) becomes each node's fill paint `opacity`, leaving
504
+ * the rest of the paint — color, gradient stops, pattern — alone. That is the
505
+ * one alpha slot a gradient or a pattern has, so it is the slot all of them
506
+ * use. A node with no fill yet takes the kit's default one.
507
+ */
508
+ declare const setFillOpacityAction: Action;
509
+
510
+ /**
511
+ * Static descriptor for the `setStroke` Action.
512
+ *
513
+ * Takes either `color` (a hex string) or `paint` (a whole `Paint`, for
514
+ * gradients and patterns). `paint` wins when both are present. A stroke's
515
+ * width, cap, join, dash and align survive either.
516
+ *
517
+ * Alpha semantics: alpha lives on the stroke paint's `opacity`. A 6-char
518
+ * (no-alpha) color adopts the alpha of the node's existing stroke paint; an
519
+ * 8-char color states its own. A `paint` is written verbatim.
520
+ */
521
+ declare const setStrokeAction: Action;
522
+
523
+ /**
524
+ * Static descriptor for the `setStrokeOpacity` Action.
525
+ *
526
+ * `params.alpha01` (0..1) becomes each node's stroke paint `opacity`, leaving
527
+ * the rest of the stroke — color, width, cap, join, dash — alone. A node with
528
+ * no stroke yet gets a hairline one.
529
+ */
530
+ declare const setStrokeOpacityAction: Action;
531
+
532
+ /**
533
+ * Static descriptor for the `setStrokeWidth` Action.
534
+ *
535
+ * `params.width` becomes each node's stroke `width`, and `params.vertexWidths`
536
+ * its per-anchor widths (`null` removes them), leaving the paint, cap, join and
537
+ * dash alone. A node with no stroke yet gets a hairline one in the kit default
538
+ * color.
539
+ */
540
+ declare const setStrokeWidthAction: Action;
541
+
542
+ /**
543
+ * Static descriptor for the `setVertexColor` Action.
544
+ *
545
+ * `params.index` names an anchor and `params.rgba` its new color, written into
546
+ * each selected node's `data.vertexColors` (one RGBA per anchor of its path),
547
+ * leaving the other anchors alone. A node with no vertex colors, or fewer
548
+ * anchors than `index` names, is left as it is.
549
+ */
550
+ declare const setVertexColorAction: Action;
551
+
552
+ /** Ingest: places what a drop or a paste brings, through the canvas's content handlers. */
553
+ declare const ingestAction: _weasel_js_routing.Action & {
554
+ id: "ingest";
555
+ };
556
+
557
+ /**
558
+ * Repeat the last move, rotate, resize, nudge, duplicate, or Alt-drag clone on
559
+ * the current selection, as one undo entry. A repeated duplicate copies the
560
+ * selection — the last copies — again by the same offset, so pressing it over
561
+ * and over makes a step-and-repeat; moving the copies between a duplicate and
562
+ * its repeat changes that offset. With nothing to repeat it duplicates.
563
+ */
564
+ declare const transformAgainAction: Action & {
565
+ requires: string[];
566
+ };
567
+
568
+ /** A move, rotate or resize the selection can be given: a {@link RepeatableTransform} other than a duplicate. */
569
+ type SelectionTransform = Exclude<RepeatableTransform, {
570
+ kind: 'duplicate';
571
+ }>;
572
+ /**
573
+ * Apply `t` to the selection as one undo entry labeled `label`, finished by
574
+ * the `transformFollowers` dep as a drag's transform is, and record it for
575
+ * Transform Again. An action calling it requires what Transform Again does
576
+ * for that kind: `scene`, `selection`, `applyOps`, `poseDescriptor`,
577
+ * `transformFollowers`, and `geometryProjection` for a move or `view`,
578
+ * `boundsIncludeStroke` and `drawnBoxes` for a rotate or a resize. Returns
579
+ * whether anything changed.
580
+ */
581
+ declare function transformSelection(deps: ActionDeps, t: SelectionTransform, label: string): boolean;
582
+
583
+ /**
584
+ * Static descriptor for the `clipboard.copy` Action (Cmd/Ctrl+C).
585
+ */
586
+ declare const clipboardCopyAction: Action & {
587
+ requires: string[];
588
+ };
589
+ /**
590
+ * Static descriptor for the `clipboard.cut` Action (Cmd/Ctrl+X) — copy, then
591
+ * the same batched delete `deleteAction` performs, as one undo entry: the
592
+ * sources a path effect hid go too.
593
+ */
594
+ declare const clipboardCutAction: Action & {
595
+ requires: string[];
596
+ };
597
+ /**
598
+ * Static descriptor for the `clipboard.paste` Action — what a Paste button or
599
+ * menu item triggers, pasting the last copy this canvas made. It has no key
600
+ * binding: Cmd/Ctrl+V already arrives as a DOM `paste` event, which the
601
+ * dispatcher routes to `clipboard.pasteEvent` or `ingest`, and a binding here
602
+ * would fire alongside it and paste twice.
603
+ */
604
+ declare const clipboardPasteAction: Action & {
605
+ id: "clipboard.paste";
606
+ };
607
+ /**
608
+ * Static descriptor for the `clipboard.pasteEvent` Action — Cmd/Ctrl+V on a
609
+ * canvas that edits and does not ingest. It answers the DOM `paste` event by
610
+ * pasting nodes a kit canvas copied to the OS clipboard, in this tab or
611
+ * another, and nothing else: an image, SVG, or file on the clipboard, and
612
+ * every consumer content handler, need `ingest`. `ingest` binds the same
613
+ * event and takes this payload among the rest, so `useStandardActions`
614
+ * leaves this one unregistered wherever `ingest` is registered.
615
+ *
616
+ * Bound to `text/plain` because that is the only flavor of a copy a paste
617
+ * event carries; a paste without text stays the page's.
618
+ */
619
+ declare const clipboardPasteEventAction: Action & {
620
+ id: "clipboard.pasteEvent";
621
+ };
622
+
623
+ /** What a stroked operand gives the built-in Pathfinder actions, and a tool
624
+ * that should count strokes as they do. */
625
+ declare const PATHFINDER_STROKES: BooleanStrokes;
626
+ /** Static descriptor for pathfinder-union. */
627
+ declare const pathfinderUnionAction: Action;
628
+ /** Static descriptor for pathfinder-subtract. */
629
+ declare const pathfinderSubtractAction: Action;
630
+ /** Static descriptor for pathfinder-intersect. */
631
+ declare const pathfinderIntersectAction: Action;
632
+ /** Static descriptor for pathfinder-exclude. */
633
+ declare const pathfinderExcludeAction: Action;
634
+ /** Static descriptor for pathfinder-divide. */
635
+ declare const pathfinderDivideAction: Action;
636
+ /** Static descriptor for pathfinder-crop. */
637
+ declare const pathfinderCropAction: Action;
638
+ /** Static descriptor for pathfinder-trim. */
639
+ declare const pathfinderTrimAction: Action;
640
+ /** Static descriptor for pathfinder-merge. */
641
+ declare const pathfinderMergeAction: Action;
642
+
643
+ /**
644
+ * The ops that put `ids` under a new boolean group of `op`, in the frontmost one's place
645
+ * in the container `groupingSite` names, labeled `label`; nothing moves on
646
+ * screen, unless the operands lie wholly off every page with the pasteboard
647
+ * off and move onto one, and a node following one that changes page goes
648
+ * where `followerMoves` says. The group wears the frontmost
649
+ * operand's `fill` and `stroke`. The operands are the outermost of `ids`, so a selected node's selected
650
+ * descendant stays where it is. Null when fewer than two operands are nodes on one layer, or when one would land in
651
+ * a singular frame.
652
+ */
653
+ declare function booleanGroupOps(scene: AnyScene, ids: readonly string[], op?: BooleanShapeOp, label?: string): {
654
+ ops: Op[];
655
+ group: NodeId;
656
+ } | null;
657
+ /** {@link booleanGroupOps} committed straight to `scene` as one undo entry. Returns the group's id, or null. */
658
+ declare function makeBooleanGroup(scene: AnyScene, ids: readonly string[], op?: BooleanShapeOp): NodeId | null;
659
+ /** Put the selection under a new boolean group, a union until its operation is changed. */
660
+ declare const makeBooleanGroupAction: Action & {
661
+ requires: string[];
662
+ };
663
+
664
+ /** The Pathfinder keymap's id; its leader action is `keymap.pathfinder`. */
665
+ declare const PATHFINDER_KEYMAP_ID = "pathfinder";
666
+ /** Alt+P, by the physical key too, since with Alt held on a Mac it types `π`. */
667
+ declare const PATHFINDER_LEADER: KeySpec;
668
+ /**
669
+ * The Pathfinder operations on held keys, behind the leader Alt+P: holding
670
+ * an operation's key previews it on the selection, releasing runs it, and
671
+ * Escape while it is held cancels it. Each binding's id is its hold's action
672
+ * id (`pathfinder.union.hold`), which is what a host rebinds it by. The
673
+ * operations themselves come from the `paths` preset; this carries only their
674
+ * holds. Install it with `<SceneCanvas ambient>`.
675
+ */
676
+ declare const PATHFINDER_KEYMAP: readonly Contribution<never>[];
677
+
678
+ export { ENGINE_STANDARD_ACTIONS, FEATURE_ACTION_IDS, FEATURE_NAMES, FEATURE_PRESETS, KIT_STANDARD_ACTIONS, KIT_STANDARD_ACTION_IDS, PATHFINDER_KEYMAP, PATHFINDER_KEYMAP_ID, PATHFINDER_LEADER, PATHFINDER_STROKES, alignBottomAction, alignCenterXAction, alignCenterYAction, alignDeltaFor, alignLeftAction, alignPreset, alignRightAction, alignTargetBounds, alignTopAction, arrangePreset, booleanGroupOps, clipboardCopyAction, clipboardCutAction, clipboardPasteAction, clipboardPasteEventAction, clipboardPreset, contextMenuPreset, deletePreset, distributeHorizontalAction, distributePreset, distributeVerticalAction, drawPreset, duplicateAction, duplicatePreset, duplicateSelection, editPreset, escapeAction, escapePreset, flipAction, flipPreset, groupAction, groupPreset, ingestAction, ingestPreset, makeBooleanGroup, makeBooleanGroupAction, movePreset, namedFeatures, nudgeDownAction, nudgeLeftAction, nudgePreset, nudgeRightAction, nudgeUpAction, outlinePreset, pathfinderCropAction, pathfinderDivideAction, pathfinderExcludeAction, pathfinderIntersectAction, pathfinderMergeAction, pathfinderPreset, pathfinderSubtractAction, pathfinderTrimAction, pathfinderUnionAction, pickPreset, reorderBackwardAction, reorderForwardAction, reorderPreset, resizePreset, rotatePreset, selectAllAction, selectAllPreset, selectPreset, selectToolsPreset, setFillAction, setFillOpacityAction, setStrokeAction, setStrokeOpacityAction, setStrokeWidthAction, setVertexColorAction, shapeToolsPreset, stylePreset, transformAgainAction, transformPreset, transformSelection, ungroupAction, useAlign, useDistribute, useStandardActions };
679
+ export type { AlignAdapter, AlignEdge, AlignParams, AlignReference, DistributeAdapter, DistributeAxis, DistributeMode, DistributeParams, FeatureName, FlipAxis, FlipParams, FlipPivot, ReorderParams, SelectionTransform, UseAlignOptions, UseAlignReturn, UseDistributeOptions, UseDistributeReturn, UseStandardActionsOptions };