@weasel-js/core 1.6.1 → 1.7.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/README.md +24 -4
  3. package/dist/{builtins-HWyuLzE-.d.ts → builtins-DLn2lCr_.d.ts} +578 -10
  4. package/dist/{chunk-BJN5ZRIJ.js → chunk-3TY6FHAF.js} +7 -4
  5. package/dist/chunk-3TY6FHAF.js.map +1 -0
  6. package/dist/{chunk-H6N2JSZ3.js → chunk-DGWNNKGD.js} +3 -3
  7. package/dist/{chunk-H6N2JSZ3.js.map → chunk-DGWNNKGD.js.map} +1 -1
  8. package/dist/{chunk-MZAIDI6D.js → chunk-G4ZGQMY7.js} +2102 -1222
  9. package/dist/chunk-G4ZGQMY7.js.map +1 -0
  10. package/dist/{chunk-HPFJUUTF.js → chunk-LU4IJ52W.js} +5 -61
  11. package/dist/chunk-LU4IJ52W.js.map +1 -0
  12. package/dist/{chunk-D4AAWR64.js → chunk-M24CLARN.js} +4 -4
  13. package/dist/{chunk-D4AAWR64.js.map → chunk-M24CLARN.js.map} +1 -1
  14. package/dist/{chunk-4RJP2N2L.js → chunk-NE27EOLP.js} +8 -5
  15. package/dist/chunk-NE27EOLP.js.map +1 -0
  16. package/dist/{chunk-DOBSZOPR.js → chunk-UPZY4ART.js} +3 -3
  17. package/dist/{chunk-DOBSZOPR.js.map → chunk-UPZY4ART.js.map} +1 -1
  18. package/dist/{chunk-RMR4QMM6.js → chunk-WPNA6L5O.js} +4 -4
  19. package/dist/{chunk-RMR4QMM6.js.map → chunk-WPNA6L5O.js.map} +1 -1
  20. package/dist/{chunk-44EWMJV2.js → chunk-XMAWPGTK.js} +5 -5
  21. package/dist/{chunk-44EWMJV2.js.map → chunk-XMAWPGTK.js.map} +1 -1
  22. package/dist/clipboard.d.ts +1 -1
  23. package/dist/clipboard.js +3 -3
  24. package/dist/clone.d.ts +2 -2
  25. package/dist/clone.js +3 -3
  26. package/dist/grid-CY5UKlZh.d.ts +98 -0
  27. package/dist/index.css +11 -35
  28. package/dist/index.css.map +1 -1
  29. package/dist/index.d.ts +460 -784
  30. package/dist/index.js +9 -9
  31. package/dist/insert.d.ts +2 -3
  32. package/dist/insert.js +1 -1
  33. package/dist/move.d.ts +5 -4
  34. package/dist/move.js +4 -4
  35. package/dist/move.js.map +1 -1
  36. package/dist/patterns-builtin.js +1 -1
  37. package/dist/{pointSnapToGrid-7mCcm6qG.d.ts → pointSnapToGrid-Dp2IxLGb.d.ts} +53 -60
  38. package/dist/renderer.css +11 -35
  39. package/dist/renderer.css.map +1 -1
  40. package/dist/renderer.d.ts +16 -8
  41. package/dist/renderer.js +9 -9
  42. package/dist/resize.d.ts +3 -3
  43. package/dist/resize.js +2 -2
  44. package/dist/routing.d.ts +1 -1
  45. package/dist/routing.js +1 -1
  46. package/dist/{types-CxC8P6W0.d.ts → types-D-9QWBy5.d.ts} +9 -6
  47. package/dist/{types-D_74YlWs.d.ts → types-qYpyTAiZ.d.ts} +4 -7
  48. package/package.json +15 -12
  49. package/dist/chunk-4RJP2N2L.js.map +0 -1
  50. package/dist/chunk-BJN5ZRIJ.js.map +0 -1
  51. package/dist/chunk-HPFJUUTF.js.map +0 -1
  52. package/dist/chunk-MZAIDI6D.js.map +0 -1
  53. package/dist/grid-BXdz8GF2.d.ts +0 -158
  54. package/dist/options-CzjxFoYZ.d.ts +0 -67
@@ -0,0 +1,98 @@
1
+ import { M as MoveBehavior, S as SnapStrategy } from './types-qYpyTAiZ.js';
2
+ import { UnitValue, UnitSystem } from '@weasel-js/quantity';
3
+ import { DebugSink } from '@weasel-js/routing';
4
+
5
+ /** Option surface for the `move` action. */
6
+
7
+ /** Options for the `move` action: the behaviors (snapping, momentum) layered
8
+ * over the raw drag, the ids a drag carries, and its history and lifecycle.
9
+ * `selectionMoveBindings` threads them into the move bindings. */
10
+ interface UseMoveOptions<TPose> {
11
+ behaviors?: MoveBehavior<TPose>[];
12
+ /** Screen travel, in CSS pixels, before the drag moves anything. Default
13
+ * `DRAG_THRESHOLD_PX`. The dispatcher opens no drag before that, so a
14
+ * smaller value has no effect; a larger one holds the selection in place
15
+ * until the pointer has gone that far. */
16
+ dragThresholdPx?: number;
17
+ /** History label for the committed move. Unset, a behavior's or a layout
18
+ * drop's own op label names it, else `'Move'`. */
19
+ moveLabel?: string;
20
+ /** Commit without an undo entry (`scene.untracked`), bypassing the
21
+ * consumer `applyOps` hook. Unset, a behavior's `defaultTransient` decides. */
22
+ transient?: boolean;
23
+ /** Fired once the drag passes its threshold, with the ids it moves. */
24
+ onGestureStart?(ids: string[]): void;
25
+ /** Fired once per `onGestureStart`: `true` when the move wrote to the
26
+ * document, `false` on cancel, a behavior abort, or no net movement. */
27
+ onGestureEnd?(committed: boolean): void;
28
+ /** Replace the selection with the ids the drag moves — to carry linked
29
+ * nodes along, say. Called once at drag start; the result is what
30
+ * behaviors see as `draggedIds` and what the commit writes (each id's
31
+ * descendants follow it as usual). Returning `[]` declines the drag.
32
+ * Default: the selection. */
33
+ expandIds?: (ids: string[]) => string[];
34
+ }
35
+
36
+ /**
37
+ * Projection used by `gridSnapStrategy` when `TPose` doesn't expose `{x,y}`
38
+ * directly (Path, polygon, etc.). The strategy reads the snap point via
39
+ * `getOrigin`, rounds it to the grid, then asks `translate` to move the
40
+ * pose by the resulting delta.
41
+ */
42
+ interface OriginProjection<TPose> {
43
+ getOrigin(pose: TPose): {
44
+ x: number;
45
+ y: number;
46
+ };
47
+ translate(pose: TPose, dx: number, dy: number): TPose;
48
+ }
49
+ /** Identity projection for `TPose extends { x; y }`. */
50
+ declare const RECT_ORIGIN_PROJECTION: OriginProjection<{
51
+ x: number;
52
+ y: number;
53
+ }>;
54
+ /** Snap-strategy that rounds the pose's origin to the nearest multiple of
55
+ * `spacing` (resolved through `unitSystem`). For non-rect TPose pass an
56
+ * `OriginProjection` so the strategy knows how to read/write the origin. */
57
+ declare function gridSnapStrategy<TPose>(spacing: UnitValue, unitSystem?: UnitSystem): SnapStrategy<TPose>;
58
+ /** As above, additionally reporting each candidate to a debug sink. */
59
+ declare function gridSnapStrategy<TPose>(spacing: UnitValue, opts: {
60
+ unitSystem?: UnitSystem;
61
+ debug?: DebugSink;
62
+ }): SnapStrategy<TPose>;
63
+ /** As above, for a `TPose` that is not a rect: `origin` tells the strategy how
64
+ * to read and write the pose's origin. */
65
+ declare function gridSnapStrategy<TPose>(spacing: UnitValue, opts: {
66
+ unitSystem?: UnitSystem;
67
+ origin: OriginProjection<TPose>;
68
+ debug?: DebugSink;
69
+ }): SnapStrategy<TPose>;
70
+ /**
71
+ * Compute the integer cell `{col, row}` that contains `point`, given a grid
72
+ * `spacing` and optional `origin` and `unitSystem`. Pair with
73
+ * `createCellHighlightLayer` (its `getCell` callback) to draw a snap-target
74
+ * preview that uses the same spacing as `gridSnapStrategy` — so the visual
75
+ * and behavioral grids stay in lockstep:
76
+ *
77
+ * const SPACING = 20;
78
+ * const snap = gridSnapStrategy(SPACING);
79
+ * // visual grid:
80
+ * createGridLayer({ spacing: SPACING, bounds: () => ... });
81
+ * // hover-preview overlay:
82
+ * createCellHighlightLayer({
83
+ * spacing: SPACING,
84
+ * getCell: () => hoverPoint && pointToGridCell(hoverPoint, SPACING),
85
+ * });
86
+ */
87
+ declare function pointToGridCell(point: {
88
+ x: number;
89
+ y: number;
90
+ }, spacing: UnitValue, unitSystem?: UnitSystem, origin?: {
91
+ x: number;
92
+ y: number;
93
+ }): {
94
+ col: number;
95
+ row: number;
96
+ };
97
+
98
+ export { type OriginProjection as O, RECT_ORIGIN_PROJECTION as R, type UseMoveOptions as U, gridSnapStrategy as g, pointToGridCell as p };
package/dist/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* src/canvas/PickHud.module.css */
1
+ /* src/canvas/hud.module.css */
2
2
  .hud {
3
3
  position: fixed;
4
4
  z-index: 10000;
@@ -14,17 +14,24 @@
14
14
  pointer-events: none;
15
15
  line-height: 1.4;
16
16
  text-align: right;
17
+ }
18
+ .sized {
17
19
  min-width: 120px;
18
20
  max-width: 260px;
19
21
  }
20
- .header {
22
+ .pre {
23
+ white-space: pre;
24
+ }
25
+ .muted {
21
26
  color: #888;
22
- margin-bottom: 2px;
23
27
  }
24
- .empty {
28
+ .absent {
25
29
  color: #888;
26
30
  font-style: italic;
27
31
  }
32
+ .header {
33
+ margin-bottom: 2px;
34
+ }
28
35
  .list {
29
36
  list-style: none;
30
37
  margin: 0;
@@ -41,46 +48,15 @@
41
48
  .itemBest {
42
49
  font-weight: 700;
43
50
  }
44
-
45
- /* src/canvas/ModalityHud.module.css */
46
- .hud {
47
- position: fixed;
48
- z-index: 10000;
49
- background: rgba(0, 0, 0, 0.7);
50
- color: #e8e8e8;
51
- font:
52
- 11px ui-monospace,
53
- SFMono-Regular,
54
- Menlo,
55
- monospace;
56
- padding: 6px 8px;
57
- border-radius: 4px;
58
- pointer-events: none;
59
- line-height: 1.4;
60
- text-align: right;
61
- min-width: 120px;
62
- max-width: 260px;
63
- }
64
51
  .row {
65
52
  display: flex;
66
53
  gap: 8px;
67
54
  justify-content: flex-end;
68
55
  white-space: nowrap;
69
56
  }
70
- .label {
71
- color: #888;
72
- }
73
- .value {
74
- color: #e8e8e8;
75
- }
76
- .valueMuted {
77
- color: #888;
78
- font-style: italic;
79
- }
80
57
  .stack {
81
58
  display: flex;
82
59
  flex-direction: column;
83
- gap: 0;
84
60
  align-items: flex-end;
85
61
  }
86
62
  /*# sourceMappingURL=index.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/canvas/PickHud.module.css","../src/canvas/ModalityHud.module.css"],"sourcesContent":[".hud {\n position: fixed;\n z-index: 10000;\n background: rgba(0, 0, 0, 0.7);\n color: #e8e8e8;\n font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;\n padding: 6px 8px;\n border-radius: 4px;\n pointer-events: none;\n line-height: 1.4;\n text-align: right;\n min-width: 120px;\n max-width: 260px;\n}\n\n.header {\n color: #888;\n margin-bottom: 2px;\n}\n\n.empty {\n color: #888;\n font-style: italic;\n}\n\n.list {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 1px;\n}\n\n.item {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.itemBest {\n font-weight: 700;\n}\n",".hud {\n position: fixed;\n z-index: 10000;\n background: rgba(0, 0, 0, 0.7);\n color: #e8e8e8;\n font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;\n padding: 6px 8px;\n border-radius: 4px;\n pointer-events: none;\n line-height: 1.4;\n text-align: right;\n min-width: 120px;\n max-width: 260px;\n}\n\n.row {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n white-space: nowrap;\n}\n\n.label {\n color: #888;\n}\n\n.value {\n color: #e8e8e8;\n}\n\n.valueMuted {\n color: #888;\n font-style: italic;\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n gap: 0;\n align-items: flex-end;\n}\n"],"mappings":";AAAA,CAAC;AACC,YAAU;AACV,WAAS;AACT,cAAY,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AAC1B,SAAO;AACP;AAAA,IAAM,KAAK,YAAY;AAAA,IAAE,cAAc;AAAA,IAAE,KAAK;AAAA,IAAE;AAChD,WAAS,IAAI;AACb,iBAAe;AACf,kBAAgB;AAChB,eAAa;AACb,cAAY;AACZ,aAAW;AACX,aAAW;AACb;AAEA,CAAC;AACC,SAAO;AACP,iBAAe;AACjB;AAEA,CAAC;AACC,SAAO;AACP,cAAY;AACd;AAEA,CAAC;AACC,cAAY;AACZ,UAAQ;AACR,WAAS;AACT,WAAS;AACT,kBAAgB;AAChB,OAAK;AACP;AAEA,CAAC;AACC,eAAa;AACb,YAAU;AACV,iBAAe;AACjB;AAEA,CAAC;AACC,eAAa;AACf;;;AC1CA,CAAC;AACC,YAAU;AACV,WAAS;AACT,cAAY,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AAC1B,SAAO;AACP;AAAA,IAAM,KAAK,YAAY;AAAA,IAAE,cAAc;AAAA,IAAE,KAAK;AAAA,IAAE;AAChD,WAAS,IAAI;AACb,iBAAe;AACf,kBAAgB;AAChB,eAAa;AACb,cAAY;AACZ,aAAW;AACX,aAAW;AACb;AAEA,CAAC;AACC,WAAS;AACT,OAAK;AACL,mBAAiB;AACjB,eAAa;AACf;AAEA,CAAC;AACC,SAAO;AACT;AAEA,CAAC;AACC,SAAO;AACT;AAEA,CAAC;AACC,SAAO;AACP,cAAY;AACd;AAEA,CAAC;AACC,WAAS;AACT,kBAAgB;AAChB,OAAK;AACL,eAAa;AACf;","names":[]}
1
+ {"version":3,"sources":["../src/canvas/hud.module.css"],"sourcesContent":["/* The debug HUDs <Canvas> can draw: CursorCoordsHud, PickHud, ModalityHud. */\n.hud {\n position: fixed;\n z-index: 10000;\n background: rgba(0, 0, 0, 0.7);\n color: #e8e8e8;\n font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;\n padding: 6px 8px;\n border-radius: 4px;\n pointer-events: none;\n line-height: 1.4;\n text-align: right;\n}\n\n.sized {\n min-width: 120px;\n max-width: 260px;\n}\n\n.pre {\n white-space: pre;\n}\n\n.muted {\n color: #888;\n}\n\n/* A value that is not there: an em dash, \"off-canvas\". */\n.absent {\n color: #888;\n font-style: italic;\n}\n\n.header {\n margin-bottom: 2px;\n}\n\n.list {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 1px;\n}\n\n.item {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.itemBest {\n font-weight: 700;\n}\n\n.row {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n white-space: nowrap;\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n"],"mappings":";AACA,CAAC;AACC,YAAU;AACV,WAAS;AACT,cAAY,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AAC1B,SAAO;AACP;AAAA,IAAM,KAAK,YAAY;AAAA,IAAE,cAAc;AAAA,IAAE,KAAK;AAAA,IAAE;AAChD,WAAS,IAAI;AACb,iBAAe;AACf,kBAAgB;AAChB,eAAa;AACb,cAAY;AACd;AAEA,CAAC;AACC,aAAW;AACX,aAAW;AACb;AAEA,CAAC;AACC,eAAa;AACf;AAEA,CAAC;AACC,SAAO;AACT;AAGA,CAAC;AACC,SAAO;AACP,cAAY;AACd;AAEA,CAAC;AACC,iBAAe;AACjB;AAEA,CAAC;AACC,cAAY;AACZ,UAAQ;AACR,WAAS;AACT,WAAS;AACT,kBAAgB;AAChB,OAAK;AACP;AAEA,CAAC;AACC,eAAa;AACb,YAAU;AACV,iBAAe;AACjB;AAEA,CAAC;AACC,eAAa;AACf;AAEA,CAAC;AACC,WAAS;AACT,OAAK;AACL,mBAAiB;AACjB,eAAa;AACf;AAEA,CAAC;AACC,WAAS;AACT,kBAAgB;AAChB,eAAa;AACf;","names":[]}