@weasel-js/core 0.7.2 → 0.8.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 (39) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/dist/{DrawCommand-CJtqqt8H.d.ts → DrawCommand-BKJ5JPkC.d.ts} +24 -1
  3. package/dist/{chunk-SYM6RAM4.js → chunk-6DAUIMTO.js} +3 -2
  4. package/dist/chunk-6DAUIMTO.js.map +1 -0
  5. package/dist/{chunk-VOVKONXA.js → chunk-BPRHGTLQ.js} +3 -3
  6. package/dist/{chunk-VOVKONXA.js.map → chunk-BPRHGTLQ.js.map} +1 -1
  7. package/dist/{chunk-BGGZ4CVF.js → chunk-CMBE45MT.js} +3 -3
  8. package/dist/{chunk-BGGZ4CVF.js.map → chunk-CMBE45MT.js.map} +1 -1
  9. package/dist/{chunk-5F3PIERN.js → chunk-DLV5F4NY.js} +520 -120
  10. package/dist/chunk-DLV5F4NY.js.map +1 -0
  11. package/dist/{chunk-CQNKCG34.js → chunk-GLZLSPGJ.js} +3 -3
  12. package/dist/chunk-GLZLSPGJ.js.map +1 -0
  13. package/dist/clipboard.d.ts +2 -2
  14. package/dist/clone.d.ts +1 -1
  15. package/dist/{geometry-D9BDMiQi.d.ts → geometry-DVeZ2i-c.d.ts} +1 -1
  16. package/dist/{grid-CaSK9bHV.d.ts → grid-XcFQVS0f.d.ts} +1 -1
  17. package/dist/{index-DOYRTfP0.d.ts → index-Clf_koyR.d.ts} +178 -6
  18. package/dist/index.d.ts +135 -31
  19. package/dist/index.js +5 -5
  20. package/dist/insert.d.ts +2 -2
  21. package/dist/insert.js +1 -1
  22. package/dist/move.d.ts +3 -3
  23. package/dist/move.js +2 -2
  24. package/dist/{options-DMWeTELe.d.ts → options-wAvCnOZd.d.ts} +1 -1
  25. package/dist/{pointSnapToGrid-C3EruUwt.d.ts → pointSnapToGrid-BuDZWBrL.d.ts} +2 -2
  26. package/dist/renderer.d.ts +5 -5
  27. package/dist/renderer.js +5 -5
  28. package/dist/resize.d.ts +3 -3
  29. package/dist/resize.js +2 -2
  30. package/dist/routing.d.ts +6 -6
  31. package/dist/routing.js +1 -1
  32. package/dist/{types-Dcaa0tPq.d.ts → types-BhJJ2OCM.d.ts} +9 -1
  33. package/dist/{types-Cpb4hii1.d.ts → types-DUpI7Apc.d.ts} +3 -95
  34. package/dist/{viewToMat3-D4lrBigW.d.ts → viewToMat3-DFMdZvVl.d.ts} +1 -1
  35. package/package.json +6 -6
  36. package/dist/chunk-5F3PIERN.js.map +0 -1
  37. package/dist/chunk-CQNKCG34.js.map +0 -1
  38. package/dist/chunk-SYM6RAM4.js.map +0 -1
  39. /package/dist/{types-B6MMiodD.d.ts → path-B6MMiodD.d.ts} +0 -0
@@ -1,25 +1,7 @@
1
1
  import * as _weasel_js_history from '@weasel-js/history';
2
2
  import { Op, SerializedHistory } from '@weasel-js/history';
3
- import { P as Path } from './types-B6MMiodD.js';
3
+ import { P as Path } from './path-B6MMiodD.js';
4
4
 
5
- /**
6
- * Pose composition for hierarchical scene graphs.
7
- *
8
- * As of the nesting change, `getPose(id)` on adapters returns the
9
- * **local** pose — relative to the object's direct parent. Anything in the
10
- * kit that needs to draw, hit-test, snap, or otherwise reason about world
11
- * coordinates routes through `composeWorldPose`, which walks the parent
12
- * chain and folds local poses together via a consumer-supplied `compose`.
13
- *
14
- * Pose shape is generic, so the compose strategy is too. For the common
15
- * `{x, y, width, height}` axis-aligned rect, use `composeRectPose` —
16
- * translation only, child dimensions preserved. Custom pose shapes (paths,
17
- * matrix transforms) supply their own.
18
- *
19
- * The inverse — `rebaseLocalPose` — converts a world-space pose into a
20
- * local pose under a target parent. Used when reparenting so the visual
21
- * world position of a child is preserved across the parent change.
22
- */
23
5
  /**
24
6
  * Axis-aligned rectangle pose with optional rotation. The canonical pose
25
7
  * shape used by `composeRectPose` and the `unionBounds` helper. Rotation is
@@ -27,8 +9,7 @@ import { P as Path } from './types-B6MMiodD.js';
27
9
  * code that consumes rotation already reads `pose.rotation ?? 0`
28
10
  * (`SceneCanvas.defaultDrawOne`, `rotate/handle.ts`, `pathInWorld.ts`), so
29
11
  * the slot exists on every default scene whether or not the consumer
30
- * populates it. Defined here in core/transforms so the compose helpers
31
- * don't depend on features.
12
+ * populates it.
32
13
  */
33
14
  interface RectPose {
34
15
  x: number;
@@ -38,79 +19,6 @@ interface RectPose {
38
19
  /** Rotation in radians around the unrotated AABB center. Absent === 0. */
39
20
  rotation?: number;
40
21
  }
41
- /** Minimal adapter needed by `composeWorldPose` and friends — pose lookup plus parent walk. */
42
- interface PoseAdapter<TPose> {
43
- getPose(id: string): TPose;
44
- getParent(id: string): string | null;
45
- }
46
- /** Consumer's pose-composition strategy for hierarchical scenes. `compose`
47
- * folds a child's pose (in parent's frame) up to the next frame; `decompose`
48
- * is its inverse. Default is IDENTITY — an absolute-pose scene where every
49
- * node already stores world coords (parent is grouping-only, no transform). */
50
- interface PoseComposition<TPose> {
51
- compose: (parent: TPose, child: TPose) => TPose;
52
- decompose: (parent: TPose, world: TPose) => TPose;
53
- }
54
- /** Default pose-composition strategy: IDENTITY. Both `compose` and
55
- * `decompose` return the child/world pose unchanged, modeling an
56
- * absolute-pose scene where every node stores world coords and parents are
57
- * grouping-only (no transform). With this strategy `composeWorldPose`
58
- * returns a node's own raw pose and `rebaseLocalPose` is a no-op. */
59
- declare const IDENTITY_POSE_COMPOSITION: PoseComposition<unknown>;
60
- /**
61
- * Walk `id`'s parent chain (root first to id last) and fold local poses into
62
- * a world pose via `compose`. Returns the world pose for `id`. Cycle-safe:
63
- * a visited-set guard breaks if the chain ever loops back to itself.
64
- *
65
- * `compose(parent, child)` interprets `child` as expressed *in `parent`'s
66
- * local frame* and returns the equivalent pose in the next frame up. For a
67
- * standard translation-only rect: `world = { x: p.x + c.x, y: p.y + c.y,
68
- * width: c.width, height: c.height }`.
69
- */
70
- declare function composeWorldPose<TPose>(adapter: PoseAdapter<TPose>, id: string, compose: (parent: TPose, child: TPose) => TPose): TPose;
71
- /**
72
- * Default `compose` for axis-aligned rectangles. Adds translation; preserves
73
- * child width/height. Treat as the canonical compose for any
74
- * `{x, y, width, height}` pose under a translation-only hierarchy.
75
- *
76
- * Generic over the concrete pose type so callers with a wider pose
77
- * (e.g. `RectPose & { rotation }`) can pass it through; the extra fields
78
- * are taken from the child unchanged.
79
- */
80
- declare function composeRectPose<TPose extends RectPose>(parent: TPose, child: TPose): TPose;
81
- /**
82
- * Translate a `RectPose`-shaped pose by `(dx, dy)`. Suitable as the default
83
- * `translatePose` for `useMove` when poses carry top-level `x`/`y`. Other
84
- * fields (width/height, plus any extra props on `TPose`) are preserved.
85
- */
86
- declare function translateRectPose<TPose extends RectPose>(pose: TPose, dx: number, dy: number): TPose;
87
- /**
88
- * Convert `worldPose` into a local pose expressed under `newParentId`'s
89
- * frame. Used when reparenting so the child's visual world position is
90
- * preserved despite the change of frame. Inverse of one `compose` step.
91
- *
92
- * `decompose(parent, world)` returns the local pose `child` such that
93
- * `compose(parent, child) === world`. For axis-aligned rects:
94
- * `child = { ...world, x: world.x - parent.x, y: world.y - parent.y }`.
95
- *
96
- * Pass `newParentId === null` for the root frame; the function returns
97
- * `worldPose` unchanged.
98
- */
99
- declare function rebaseLocalPose<TPose>(adapter: PoseAdapter<TPose>, worldPose: TPose, newParentId: string | null, compose: (parent: TPose, child: TPose) => TPose, decompose: (parent: TPose, world: TPose) => TPose): TPose;
100
- /** Inverse of `composeRectPose` — subtracts parent translation. */
101
- declare function decomposeRectPose<TPose extends RectPose>(parent: TPose, world: TPose): TPose;
102
- /**
103
- * Build a `(id) => world pose | null` callback over a `PoseAdapter`.
104
- * Convenience for RenderLayers that take a `getPose` callback (selection
105
- * overlays, debug layers, etc.) so consumers don't hand-write a
106
- * `composeWorldPose` call per layer.
107
- *
108
- * Returns `null` when `adapter.getPose` or `adapter.getParent` throws — the
109
- * common case is an id removed mid-render between selection state and the
110
- * next paint. Layers should treat `null` as "skip this id."
111
- */
112
- declare function worldPoseLookup<TPose>(adapter: PoseAdapter<TPose>, compose: (parent: TPose, child: TPose) => TPose): (id: string) => TPose | null;
113
-
114
22
  /**
115
23
  * # SceneNode — the thing in the scene
116
24
  *
@@ -442,4 +350,4 @@ interface Scene<TData, TLayer extends string, TPose = RectPose> {
442
350
  getVersion(): number;
443
351
  }
444
352
 
445
- export { type AddLayerSpec as A, type ContainerNode as C, IDENTITY_POSE_COMPOSITION as I, type LayerRecord as L, type NodeId as N, type PoseComposition as P, type RectPose as R, type Scene as S, type UseSceneOptions as U, type Node as a, type SerializedScene as b, type SceneRegistry as c, type RegisteredOp as d, type AddNodeSpec as e, type LeafNode as f, type PoseAdapter as g, type SerializedNode as h, type SystemLayerRecord as i, type SystemLayerSpec as j, type UserLayerRecord as k, asNodeId as l, composeRectPose as m, composeWorldPose as n, decomposeRectPose as o, rebaseLocalPose as r, translateRectPose as t, worldPoseLookup as w };
353
+ export { type AddLayerSpec as A, type ContainerNode as C, type LayerRecord as L, type NodeId as N, type RectPose as R, type Scene as S, type UseSceneOptions as U, type Node as a, type SerializedScene as b, type SceneRegistry as c, type RegisteredOp as d, type AddNodeSpec as e, type LeafNode as f, type SerializedNode as g, type SystemLayerRecord as h, type SystemLayerSpec as i, type UserLayerRecord as j, asNodeId as k };
@@ -1,4 +1,4 @@
1
- import { M as Mat3 } from './DrawCommand-CJtqqt8H.js';
1
+ import { M as Mat3 } from './DrawCommand-BKJ5JPkC.js';
2
2
 
3
3
  /**
4
4
  * GL texture upload cache for ImageBitmap objects.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weasel-js/core",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Domain-agnostic 2D scene graph primitives for React: viewport math, drag/resize/insert/clone interactions, layered canvas rendering.",
5
5
  "license": "MIT",
6
6
  "author": "orochi235",
@@ -74,11 +74,11 @@
74
74
  "react": ">=18"
75
75
  },
76
76
  "dependencies": {
77
- "@weasel-js/font": "0.7.2",
78
- "@weasel-js/geom": "0.7.2",
79
- "@weasel-js/gestures": "0.7.2",
80
- "@weasel-js/history": "0.7.2",
81
- "@weasel-js/modes": "0.7.2",
77
+ "@weasel-js/font": "0.8.0",
78
+ "@weasel-js/geom": "0.8.0",
79
+ "@weasel-js/gestures": "0.8.0",
80
+ "@weasel-js/history": "0.8.0",
81
+ "@weasel-js/modes": "0.8.0",
82
82
  "earcut": "2.2.4",
83
83
  "polygon-clipping": "^0.15.7"
84
84
  },