@weasel-js/core 1.4.3 → 1.5.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/CHANGELOG.md +1299 -2197
- package/README.md +118 -75
- package/dist/{pointSnapToGrid-D1bRdq-j.d.ts → autoPoseDescriptor-CvjflWJK.d.ts} +35 -17
- package/dist/{chunk-ORZNKVXM.js → chunk-BDWAA634.js} +4 -22
- package/dist/chunk-BDWAA634.js.map +1 -0
- package/dist/{chunk-WYPSGIYS.js → chunk-MG7OXCAI.js} +4149 -5316
- package/dist/chunk-MG7OXCAI.js.map +1 -0
- package/dist/{chunk-BLJNRMKB.js → chunk-MQI4PIX3.js} +3 -3
- package/dist/chunk-MQI4PIX3.js.map +1 -0
- package/dist/{chunk-SBFC6J3C.js → chunk-UCPV7JXC.js} +201 -256
- package/dist/chunk-UCPV7JXC.js.map +1 -0
- package/dist/clipboard.d.ts +2 -3
- package/dist/clone.d.ts +3 -2
- package/dist/depSchema-nMqj_qTM.d.ts +3490 -0
- package/dist/{grid-Bw8cSde-.d.ts → grid-BrIa38gG.d.ts} +7 -23
- package/dist/index.d.ts +2134 -1210
- package/dist/index.js +4 -5
- package/dist/insert.d.ts +4 -4
- package/dist/insert.js +1 -1
- package/dist/move.d.ts +5 -6
- package/dist/move.js +3 -6
- package/dist/move.js.map +1 -1
- package/dist/{options-DYfUlZxk.d.ts → options-BDyCnrp8.d.ts} +3 -2
- package/dist/poseDescriptor-CGOgIgf8.d.ts +134 -0
- package/dist/renderer.d.ts +10 -4
- package/dist/renderer.js +4 -5
- package/dist/resize.d.ts +10 -11
- package/dist/resize.js +2 -2
- package/dist/routing.d.ts +1 -142
- package/dist/routing.js +1 -1
- package/dist/routing.js.map +1 -1
- package/dist/{types-BJqsTlXl.d.ts → types-DMyo7dnM.d.ts} +12 -41
- package/dist/{types-CoVTbo_y.d.ts → types-DtjCJA5r.d.ts} +10 -9
- package/package.json +13 -10
- package/dist/DrawCommand-CD-ug3d9.d.ts +0 -332
- package/dist/builtins-CtGORLCG.d.ts +0 -740
- package/dist/chunk-BLJNRMKB.js.map +0 -1
- package/dist/chunk-LEURURX3.js +0 -561
- package/dist/chunk-LEURURX3.js.map +0 -1
- package/dist/chunk-ORZNKVXM.js.map +0 -1
- package/dist/chunk-SBFC6J3C.js.map +0 -1
- package/dist/chunk-WYPSGIYS.js.map +0 -1
- package/dist/geometry-CHR36Ub_.d.ts +0 -114
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/registry-DnoTWGED.d.ts +0 -4003
- package/dist/types-BHK2dkMu.d.ts +0 -172
- package/dist/types-H7o6MaPo.d.ts +0 -512
- package/dist/view-DSQgxBJB.d.ts +0 -63
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { V as View } from './view-DSQgxBJB.js';
|
|
2
|
-
import { R as ResizePose, a as RotatedPose } from './types-BJqsTlXl.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Axis-aligned rectangle in world space. Kit-wide `Bounds` shape used by
|
|
6
|
-
* selection, group, and viewport helpers. The optional `rotation` field
|
|
7
|
-
* (radians, around the AABB center) lets selection chrome attach a rotated
|
|
8
|
-
* orientation to an otherwise axis-aligned rect without needing a parallel
|
|
9
|
-
* type.
|
|
10
|
-
*/
|
|
11
|
-
interface Bounds {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
rotation?: number;
|
|
17
|
-
}
|
|
18
|
-
/** Pixel dimensions of the canvas viewport. */
|
|
19
|
-
interface ViewportDims {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
}
|
|
23
|
-
/** Options for {@link fitViewToBounds}. */
|
|
24
|
-
interface FitViewToBoundsOptions {
|
|
25
|
-
/** Inset (in CSS px) around the bounds. Default 16. */
|
|
26
|
-
padding?: number;
|
|
27
|
-
/**
|
|
28
|
-
* Override the kit's system max scale. Defaults to the kit-wide max zoom
|
|
29
|
-
* used by `computeWheelAction` (`DEFAULT_MAX_ZOOM`).
|
|
30
|
-
*/
|
|
31
|
-
maxScale?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Override the kit's system min scale. Defaults to the kit-wide min zoom
|
|
34
|
-
* used by `computeWheelAction` (`DEFAULT_MIN_ZOOM`).
|
|
35
|
-
*/
|
|
36
|
-
minScale?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Fit mode:
|
|
39
|
-
* - `'contain'` (default): uniform scale = `min(availW/w, availH/h)`. Bounds fit entirely; one axis has letterboxing.
|
|
40
|
-
* - `'fill'`: uniform scale = `max(...)`. Bounds overflow viewport on one axis.
|
|
41
|
-
* - `'stretch'`: per-axis scale. Bounds match viewport exactly; scale is non-uniform.
|
|
42
|
-
*/
|
|
43
|
-
mode?: 'contain' | 'fill' | 'stretch';
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Compute the target {@link View} that fits `bounds` (world space) inside
|
|
47
|
-
* `viewportDims` (CSS px). The bounds are centered in the viewport with
|
|
48
|
-
* uniform padding on all sides; the resulting scale is clamped to the
|
|
49
|
-
* configured min/max.
|
|
50
|
-
*
|
|
51
|
-
* View semantics: `view.x` / `view.y` is the world point currently drawn at
|
|
52
|
-
* the canvas top-left, and `view.scale.{x,y}` is pixels per world unit on
|
|
53
|
-
* each axis (see `view.ts`). So:
|
|
54
|
-
* screenX = (worldX - view.x) * view.scale.x
|
|
55
|
-
* screenY = (worldY - view.y) * view.scale.y
|
|
56
|
-
*
|
|
57
|
-
* Empty / zero-sized bounds or viewports cannot be fit — in that case this
|
|
58
|
-
* returns `currentView` unchanged and logs a `console.warn`. Callers that
|
|
59
|
-
* want to no-op silently can detect zero area themselves before calling.
|
|
60
|
-
*/
|
|
61
|
-
declare function fitViewToBounds(bounds: Bounds, viewportDims: ViewportDims, currentView: View, opts?: FitViewToBoundsOptions): View;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Bridges arbitrary `TPose` shapes into the resize hook's bounds-driven math.
|
|
65
|
-
* The hook reads bounds via `getBounds`, runs anchor-relative math on those
|
|
66
|
-
* bounds, then asks `remapBounds` to project the result back into TPose.
|
|
67
|
-
*
|
|
68
|
-
* `remapBounds(pose, src, dst)` is a single operation that subsumes both
|
|
69
|
-
* "set my own AABB to dst" (single-leaf resize) and "scale me as a leaf
|
|
70
|
-
* inside parent's src→dst rect" (group resize) — they're the same affine
|
|
71
|
-
* map. For rect-shaped poses the default geometry interprets the pose as
|
|
72
|
-
* its own bounds; for Path or polygon poses the consumer supplies a
|
|
73
|
-
* projection that knows how to read and rewrite the underlying geometry.
|
|
74
|
-
*/
|
|
75
|
-
interface PoseProjection<TPose> {
|
|
76
|
-
getBounds(pose: TPose): ResizePose;
|
|
77
|
-
remapBounds(pose: TPose, src: ResizePose, dst: ResizePose): TPose;
|
|
78
|
-
/** Translate the pose by (dx, dy). Optional — when omitted, callers fall
|
|
79
|
-
* back to a translation derived from `remapBounds` (origin shifted, no
|
|
80
|
-
* scale). Path-shaped poses should provide this for performance. */
|
|
81
|
-
translate?(pose: TPose, dx: number, dy: number): TPose;
|
|
82
|
-
/** True iff any portion of the pose's geometry intersects `rect`. Optional
|
|
83
|
-
* — when omitted, area-select and similar callers test against `getBounds`
|
|
84
|
-
* AABB (looser, but correct for axis-aligned rect poses). */
|
|
85
|
-
intersectsRect?(pose: TPose, rect: ResizePose): boolean;
|
|
86
|
-
/** Interpolate between two poses. Optional — animation helpers fall back to
|
|
87
|
-
* rect-shape lerp when omitted (which fails for non-rect poses). */
|
|
88
|
-
lerp?(a: TPose, b: TPose, t: number): TPose;
|
|
89
|
-
/** Read the pose's rotation in radians. Pivot is the AABB center
|
|
90
|
-
* (`getBounds(pose)` center). Default 0 when omitted — descriptor
|
|
91
|
-
* declares "this pose has no rotation." When supplied and non-zero,
|
|
92
|
-
* `useResize` projects the drag delta into the leaf's local frame,
|
|
93
|
-
* runs anchor math there, and translates the resulting pose so the
|
|
94
|
-
* diagonally opposite world-space corner is pinned. */
|
|
95
|
-
getRotation?(pose: TPose): number;
|
|
96
|
-
/** True iff this pose shape can carry a rotation. Consulted by the
|
|
97
|
-
* rotation affordance to decide whether to render the rotate cursor /
|
|
98
|
-
* drag-band over a selection. When omitted, the kit assumes `true` for
|
|
99
|
-
* back-compat — descriptors whose poses lack `x/y/width/height/rotation`
|
|
100
|
-
* fields (e.g. polygon Paths) should return `false` so the affordance
|
|
101
|
-
* hides instead of exposing a non-functional rotate cursor. */
|
|
102
|
-
supportsRotation?(pose: TPose): boolean;
|
|
103
|
-
}
|
|
104
|
-
/** Identity geometry for `TPose extends ResizePose`. Treats the pose as its
|
|
105
|
-
* own bounds and remaps via affine scale against `src`/`dst`. */
|
|
106
|
-
declare const RECT_POSE_DESCRIPTOR: PoseProjection<ResizePose>;
|
|
107
|
-
/** Identity geometry for `RotatedPose`. Inherits rect-shape projection
|
|
108
|
-
* from `RECT_POSE_DESCRIPTOR` (the `RotatedPose extends ResizePose`
|
|
109
|
-
* subtype lets the rect descriptor's methods apply directly; `remapBounds`
|
|
110
|
-
* preserves the `rotation` field via `...p` spread). Adds `getRotation` so
|
|
111
|
-
* `useResize` knows to take the rotation-aware math path. */
|
|
112
|
-
declare const ROTATED_POSE_DESCRIPTOR: PoseProjection<RotatedPose>;
|
|
113
|
-
|
|
114
|
-
export { type Bounds as B, type FitViewToBoundsOptions as F, type PoseProjection as P, RECT_POSE_DESCRIPTOR as R, type ViewportDims as V, ROTATED_POSE_DESCRIPTOR as a, fitViewToBounds as f };
|
package/dist/path-JEV2c5If.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path data model. Vector-graphics primitive used kit-wide as the canonical
|
|
3
|
-
* shape (replacing per-shape ad-hoc poses). SVG-style command stream so we
|
|
4
|
-
* cover lines, polygons, beziers, and multi-contour shapes (think the inner
|
|
5
|
-
* hole of an "O") under one type.
|
|
6
|
-
*
|
|
7
|
-
* Storage: command codes in a `Uint8Array`, parameters in a `Float32Array`.
|
|
8
|
-
* Each command consumes a fixed number of float coords from the parameter
|
|
9
|
-
* array; the parser walks both arrays in lockstep. This keeps interaction
|
|
10
|
-
* hot loops monomorphic and keeps GC pressure low under heavy edits.
|
|
11
|
-
*
|
|
12
|
-
* Two path subtypes are distinguished at the type level so common-case
|
|
13
|
-
* machinery (selection AABBs, area-select intersection, hit-testing rect
|
|
14
|
-
* silhouettes) can short-circuit on `RectPath` without paying the polygon
|
|
15
|
-
* kernel cost. Polymorphic kernels accept either via the `Path` union and
|
|
16
|
-
* dispatch on `kind`.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/** Fill rule used by polygon path hit-testing and `ctx.fill()`. */
|
|
20
|
-
type PathFillRule = 'nonzero' | 'evenodd';
|
|
21
|
-
/**
|
|
22
|
-
* Polygon path with arbitrary contours and optional bezier segments.
|
|
23
|
-
* Multi-contour: each `M` opens a new subpath; `Z` closes the current one.
|
|
24
|
-
* Open subpaths (no `Z`) render as polylines and don't contribute to fills.
|
|
25
|
-
*/
|
|
26
|
-
interface PolygonPath {
|
|
27
|
-
kind: 'polygon';
|
|
28
|
-
commands: Uint8Array;
|
|
29
|
-
coords: Float32Array;
|
|
30
|
-
fillRule: PathFillRule;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Axis-aligned rectangle. Fast path for the (very common) case where the
|
|
34
|
-
* shape is just a rect — preserves O(1) bounds and hit-test, avoids the
|
|
35
|
-
* polygon kernel entirely. Promote to `PolygonPath` only when the shape
|
|
36
|
-
* grows beyond what a rect can express.
|
|
37
|
-
*/
|
|
38
|
-
interface RectPath {
|
|
39
|
-
kind: 'rect';
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
}
|
|
45
|
-
/** Canonical path shape — either an axis-aligned rect (fast path) or a polygon command stream. */
|
|
46
|
-
type Path = PolygonPath | RectPath;
|
|
47
|
-
|
|
48
|
-
export type { Path as P, RectPath as R, PolygonPath as a, PathFillRule as b };
|