@vectojs/core 0.1.0 → 0.2.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.
- package/dist/animation/drivers.d.ts +48 -0
- package/dist/animation/easing.d.ts +16 -0
- package/dist/{chunk-M2IZPGOL.mjs → chunk-H3QIE77O.mjs} +316 -12
- package/dist/{chunk-53DAQC3U.js → chunk-LA3FJLP2.js} +369 -65
- package/dist/components/GridTextEntity.d.ts +15 -0
- package/dist/components/SplineEntity.d.ts +144 -0
- package/dist/components/TextEntity.d.ts +35 -0
- package/dist/index.d.ts +26 -577
- package/dist/index.js +121 -136
- package/dist/index.mjs +19 -34
- package/dist/{layout.d.mts → layout/LayoutEngine.d.ts} +15 -70
- package/dist/layout/LayoutWorker.d.ts +23 -0
- package/dist/layout/LayoutWorkerManager.d.ts +22 -0
- package/dist/layout/LayoutWorkerSource.d.ts +1 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/measure.d.ts +20 -0
- package/dist/math/SpatialHashGrid.d.ts +53 -0
- package/dist/math/SpringPhysics.d.ts +13 -0
- package/dist/renderer/CanvasRenderer.d.ts +81 -0
- package/dist/renderer/IRenderer.d.ts +178 -0
- package/dist/renderer/SVGRenderer.d.ts +69 -0
- package/dist/renderer/WebGLPointRenderer.d.ts +62 -0
- package/dist/renderer/WebGPUParticleSystemManager.d.ts +14 -0
- package/dist/renderer/colorParse.d.ts +17 -0
- package/dist/renderer/index.d.ts +6 -0
- package/dist/text/ArabicShaper.d.ts +10 -0
- package/dist/text/BidiResolver.d.ts +6 -0
- package/dist/{text.d.ts → text/MSDFFont.d.ts} +10 -82
- package/dist/text/MSDFTextEntity.d.ts +30 -0
- package/dist/text/SVGEntity.d.ts +22 -0
- package/dist/text/index.d.ts +5 -0
- package/dist/text.js +2 -2
- package/dist/text.mjs +1 -1
- package/dist/tree/ComputeParticleEntity.d.ts +118 -0
- package/dist/tree/DOMPortalEntity.d.ts +18 -0
- package/dist/{Entity-D-rfAFCf.d.mts → tree/Entity.d.ts} +71 -201
- package/dist/tree/Scene.d.ts +302 -0
- package/package.json +5 -5
- package/dist/Entity-D-rfAFCf.d.ts +0 -572
- package/dist/index-ByBDSmMK.d.mts +0 -365
- package/dist/index-C3Fd_XmG.d.ts +0 -365
- package/dist/index.d.mts +0 -577
- package/dist/layout.d.ts +0 -319
- package/dist/renderer.d.mts +0 -2
- package/dist/renderer.d.ts +0 -2
- package/dist/text.d.mts +0 -201
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Entity } from './Entity';
|
|
2
|
+
import { IRenderer } from '../renderer/IRenderer';
|
|
3
|
+
/**
|
|
4
|
+
* Options for configuring a {@link ComputeParticleEntity}.
|
|
5
|
+
*/
|
|
6
|
+
export interface ComputeParticleOptions {
|
|
7
|
+
/** Maximum number of particles to simulate. Defaults to 10000. */
|
|
8
|
+
maxParticles?: number;
|
|
9
|
+
/** Spring stiffness coefficient for returning to origin. Defaults to 0.05. */
|
|
10
|
+
springK?: number;
|
|
11
|
+
/** Velocity damping factor in `[0, 1]`. Defaults to 0.95. */
|
|
12
|
+
damping?: number;
|
|
13
|
+
/** Bounce damping factor for boundary collisions in `[0, 1]`. Defaults to 0.5. */
|
|
14
|
+
bounceDamping?: number;
|
|
15
|
+
/** Speed limit for particles. Defaults to 500.0. */
|
|
16
|
+
maxVelocity?: number;
|
|
17
|
+
/** Base particle size in pixels. Defaults to 4. */
|
|
18
|
+
size?: number;
|
|
19
|
+
/** CSS color string for the particles. Defaults to '#00f0ff'. */
|
|
20
|
+
color?: string;
|
|
21
|
+
/** Whether the particle layer captures pointer/hit events. Defaults to false. */
|
|
22
|
+
pointerEvents?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const PARTICLE_STRIDE_FLOATS = 8;
|
|
25
|
+
export declare const PARTICLE_OFFSET_POSITION_X = 0;
|
|
26
|
+
export declare const PARTICLE_OFFSET_POSITION_Y = 1;
|
|
27
|
+
export declare const PARTICLE_OFFSET_VELOCITY_X = 2;
|
|
28
|
+
export declare const PARTICLE_OFFSET_VELOCITY_Y = 3;
|
|
29
|
+
export declare const PARTICLE_OFFSET_ORIGIN_X = 4;
|
|
30
|
+
export declare const PARTICLE_OFFSET_ORIGIN_Y = 5;
|
|
31
|
+
export declare const PARTICLE_OFFSET_SIZE = 6;
|
|
32
|
+
export declare const PARTICLE_OFFSET_LIFE = 7;
|
|
33
|
+
/**
|
|
34
|
+
* An entity representing a high-performance WebGPU/CPU particle simulation layer.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ComputeParticleEntity extends Entity {
|
|
37
|
+
maxParticles: number;
|
|
38
|
+
springK: number;
|
|
39
|
+
damping: number;
|
|
40
|
+
bounceDamping: number;
|
|
41
|
+
maxVelocity: number;
|
|
42
|
+
size: number;
|
|
43
|
+
baseColor: string;
|
|
44
|
+
pointerEvents: boolean;
|
|
45
|
+
/** Flat array containing layout of all particles: position, velocity, origin, size, life. */
|
|
46
|
+
particleData: Float32Array;
|
|
47
|
+
/** Flag indicating whether the particle coordinates need to be initialized. */
|
|
48
|
+
needsInit: boolean;
|
|
49
|
+
/** Active explosion impulse to apply in the next simulation step. */
|
|
50
|
+
pendingExplosion: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
force: number;
|
|
54
|
+
} | null;
|
|
55
|
+
/** WebGPU storage buffer containing particle states. */
|
|
56
|
+
gpuStorageBuffer: any;
|
|
57
|
+
/** WebGPU uniform buffer containing simulation parameters. */
|
|
58
|
+
gpuUniformBuffer: any;
|
|
59
|
+
/** WebGPU bind group for the compute shader pass. */
|
|
60
|
+
computeBindGroup: any;
|
|
61
|
+
/** WebGPU bind group for the render pass (usually same as compute). */
|
|
62
|
+
renderBindGroup: any;
|
|
63
|
+
constructor(options?: ComputeParticleOptions);
|
|
64
|
+
/**
|
|
65
|
+
* Disperses all particles randomly across the specified screen bounds.
|
|
66
|
+
* Sets initial positions, velocities, origins, and sizes.
|
|
67
|
+
*
|
|
68
|
+
* @param width - Simulation zone width.
|
|
69
|
+
* @param height - Simulation zone height.
|
|
70
|
+
*/
|
|
71
|
+
initRandomParticles(width: number, height: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the origins (ox, oy) for a subset or all particles.
|
|
74
|
+
* Also sets position to origin if requestPositionReset is true.
|
|
75
|
+
*
|
|
76
|
+
* @param points - Flat Float32Array containing [x0, y0, x1, y1, ...]
|
|
77
|
+
* @param requestPositionReset - Whether to set current positions to the new origins. Defaults to true.
|
|
78
|
+
*/
|
|
79
|
+
setOrigins(points: Float32Array | number[], requestPositionReset?: boolean): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the current positions (x, y) for a subset or all particles.
|
|
82
|
+
*
|
|
83
|
+
* @param positions - Flat Float32Array containing [x0, y0, x1, y1, ...]
|
|
84
|
+
*/
|
|
85
|
+
setPositions(positions: Float32Array | number[]): void;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the current velocities (vx, vy) for a subset or all particles.
|
|
88
|
+
*
|
|
89
|
+
* @param velocities - Flat Float32Array containing [vx0, vy0, vx1, vy1, ...]
|
|
90
|
+
*/
|
|
91
|
+
setVelocities(velocities: Float32Array | number[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Triggers an explosion force center.
|
|
94
|
+
*
|
|
95
|
+
* @param x - Explosion center x-coordinate.
|
|
96
|
+
* @param y - Explosion center y-coordinate.
|
|
97
|
+
* @param force - Magnitude force scalar.
|
|
98
|
+
*/
|
|
99
|
+
triggerExplosion(x: number, y: number, force: number): void;
|
|
100
|
+
isPointInside(_x: number, _y: number): boolean;
|
|
101
|
+
render(_r: IRenderer): void;
|
|
102
|
+
/**
|
|
103
|
+
* Updates particle simulation on the CPU.
|
|
104
|
+
* Handles spring forces, mouse repulsion, explosion impulses, velocity capping, and bounds bouncing/clamping.
|
|
105
|
+
*
|
|
106
|
+
* @param dt - Delta time in seconds.
|
|
107
|
+
* @param mouseX - Mouse x-coordinate, or a value below -9000 if inactive.
|
|
108
|
+
* @param mouseY - Mouse y-coordinate, or a value below -9000 if inactive.
|
|
109
|
+
* @param width - Boundary width.
|
|
110
|
+
* @param height - Boundary height.
|
|
111
|
+
*/
|
|
112
|
+
updateCPU(dt: number, mouseX: number, mouseY: number, width: number, height: number): void;
|
|
113
|
+
destroy(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Frees all GPU resources allocated for WebGPU simulation.
|
|
116
|
+
*/
|
|
117
|
+
destroyGPUResources(): void;
|
|
118
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entity } from './Entity';
|
|
2
|
+
export declare class DOMPortalEntity extends Entity {
|
|
3
|
+
domElement: HTMLElement;
|
|
4
|
+
isDOMPortal: boolean;
|
|
5
|
+
private domListeners;
|
|
6
|
+
private resizeObserver;
|
|
7
|
+
cachedWidth: number;
|
|
8
|
+
cachedHeight: number;
|
|
9
|
+
lastWidth: string;
|
|
10
|
+
lastHeight: string;
|
|
11
|
+
lastTransform: string;
|
|
12
|
+
lastZIndex: string;
|
|
13
|
+
constructor(domElement: HTMLElement, width?: number, height?: number, id?: string);
|
|
14
|
+
isPointInside(globalX: number, globalY: number): boolean;
|
|
15
|
+
add(child: Entity): this;
|
|
16
|
+
render(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
@@ -1,186 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Implementations wrap a concrete drawing backend (Canvas 2D, WebGL, …) and
|
|
5
|
-
* expose a path-based drawing API. Entities must only depend on `IRenderer`
|
|
6
|
-
* so they remain backend-agnostic.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Inside an Entity.render() implementation:
|
|
10
|
-
* render(r: IRenderer) {
|
|
11
|
-
* r.beginPath();
|
|
12
|
-
* r.fill('#38bdf8');
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
interface IRenderer {
|
|
16
|
-
/** Clear the entire drawing surface to transparent / background color. */
|
|
17
|
-
clear(): void;
|
|
18
|
-
/** Push the current transform + state onto the renderer's stack. */
|
|
19
|
-
save(): void;
|
|
20
|
-
/** Pop the last saved transform + state from the renderer's stack. */
|
|
21
|
-
restore(): void;
|
|
22
|
-
/**
|
|
23
|
-
* Apply a translation to the current transform matrix.
|
|
24
|
-
*
|
|
25
|
-
* @param x - Horizontal offset in pixels.
|
|
26
|
-
* @param y - Vertical offset in pixels.
|
|
27
|
-
*/
|
|
28
|
-
translate(x: number, y: number): void;
|
|
29
|
-
/**
|
|
30
|
-
* Apply a scale to the current transform matrix.
|
|
31
|
-
*
|
|
32
|
-
* @param x - Horizontal scale factor.
|
|
33
|
-
* @param y - Vertical scale factor.
|
|
34
|
-
*/
|
|
35
|
-
scale(x: number, y: number): void;
|
|
36
|
-
/**
|
|
37
|
-
* Apply a clockwise rotation to the current transform matrix.
|
|
38
|
-
*
|
|
39
|
-
* @param angle - Rotation angle in radians.
|
|
40
|
-
*/
|
|
41
|
-
rotate(angle: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* Set the global opacity applied to all subsequent draw calls.
|
|
44
|
-
*
|
|
45
|
-
* @param alpha - Opacity in the range `[0, 1]`.
|
|
46
|
-
*/
|
|
47
|
-
setGlobalAlpha(alpha: number): void;
|
|
48
|
-
/**
|
|
49
|
-
* Intersect the current clip region with a rectangle. Affects all subsequent
|
|
50
|
-
* draws until the next {@link restore}; wrap in {@link save}/{@link restore}.
|
|
51
|
-
*
|
|
52
|
-
* @param x - Left edge.
|
|
53
|
-
* @param y - Top edge.
|
|
54
|
-
* @param width - Rectangle width.
|
|
55
|
-
* @param height - Rectangle height.
|
|
56
|
-
*/
|
|
57
|
-
clip(x: number, y: number, width: number, height: number): void;
|
|
58
|
-
/** Begin a new sub-path, discarding the current path. */
|
|
59
|
-
beginPath(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Move the pen to the given point without drawing a line.
|
|
62
|
-
*
|
|
63
|
-
* @param x - Target X coordinate.
|
|
64
|
-
* @param y - Target Y coordinate.
|
|
65
|
-
*/
|
|
66
|
-
moveTo(x: number, y: number): void;
|
|
67
|
-
/**
|
|
68
|
-
* Add a straight line segment from the current pen position to the given point.
|
|
69
|
-
*
|
|
70
|
-
* @param x - Target X coordinate.
|
|
71
|
-
* @param y - Target Y coordinate.
|
|
72
|
-
*/
|
|
73
|
-
lineTo(x: number, y: number): void;
|
|
74
|
-
/**
|
|
75
|
-
* Add a cubic Bézier curve to the current path.
|
|
76
|
-
*
|
|
77
|
-
* @param cp1x - X of the first control point.
|
|
78
|
-
* @param cp1y - Y of the first control point.
|
|
79
|
-
* @param cp2x - X of the second control point.
|
|
80
|
-
* @param cp2y - Y of the second control point.
|
|
81
|
-
* @param x - X of the end point.
|
|
82
|
-
* @param y - Y of the end point.
|
|
83
|
-
*/
|
|
84
|
-
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
85
|
-
/** Close the current sub-path by drawing a line back to its starting point. */
|
|
86
|
-
closePath(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Add a circular arc to the current path.
|
|
89
|
-
*
|
|
90
|
-
* @param x - X of the arc center.
|
|
91
|
-
* @param y - Y of the arc center.
|
|
92
|
-
* @param radius - Arc radius in pixels.
|
|
93
|
-
* @param startAngle - Start angle in radians (0 = 3 o'clock).
|
|
94
|
-
* @param endAngle - End angle in radians.
|
|
95
|
-
* @param counterclockwise - If `true`, draws the arc counter-clockwise.
|
|
96
|
-
*/
|
|
97
|
-
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
98
|
-
/**
|
|
99
|
-
* Add a rounded rectangle to the current path.
|
|
100
|
-
*
|
|
101
|
-
* @param x - Left edge.
|
|
102
|
-
* @param y - Top edge.
|
|
103
|
-
* @param width - Rectangle width.
|
|
104
|
-
* @param height - Rectangle height.
|
|
105
|
-
* @param radii - Corner radius (uniform) or per-corner array as accepted by `CanvasRenderingContext2D.roundRect()`.
|
|
106
|
-
*/
|
|
107
|
-
roundRect(x: number, y: number, width: number, height: number, radii: number | number[]): void;
|
|
108
|
-
/**
|
|
109
|
-
* Draw an image or video frame into the canvas.
|
|
110
|
-
*
|
|
111
|
-
* @param source - The image source (HTMLImageElement, HTMLVideoElement, HTMLCanvasElement, etc.).
|
|
112
|
-
* @param dx - Destination X.
|
|
113
|
-
* @param dy - Destination Y.
|
|
114
|
-
* @param dw - Destination width.
|
|
115
|
-
* @param dh - Destination height.
|
|
116
|
-
*/
|
|
117
|
-
drawImage(source: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void;
|
|
118
|
-
/**
|
|
119
|
-
* Fill the current path with the given color or gradient.
|
|
120
|
-
*
|
|
121
|
-
* @param colorOrGradient - CSS color string or a gradient object.
|
|
122
|
-
*/
|
|
123
|
-
fill(colorOrGradient: string | any): void;
|
|
124
|
-
/**
|
|
125
|
-
* Stroke the current path with the given color or gradient.
|
|
126
|
-
*
|
|
127
|
-
* @param colorOrGradient - CSS color string or a gradient object.
|
|
128
|
-
* @param lineWidth - Stroke width in pixels (default: `1`).
|
|
129
|
-
*/
|
|
130
|
-
stroke(colorOrGradient: string | any, lineWidth?: number): void;
|
|
131
|
-
/**
|
|
132
|
-
* Render a text string at the given position.
|
|
133
|
-
*
|
|
134
|
-
* @param text - The string to draw.
|
|
135
|
-
* @param x - Left edge of the text baseline.
|
|
136
|
-
* @param y - Baseline Y coordinate.
|
|
137
|
-
* @param font - CSS font shorthand, e.g. `'16px monospace'`.
|
|
138
|
-
* @param color - CSS color string or gradient.
|
|
139
|
-
*/
|
|
140
|
-
fillText(text: string, x: number, y: number, font: string, color: string | any): void;
|
|
141
|
-
/**
|
|
142
|
-
* Draw a filled circle through the order-preserving batch.
|
|
143
|
-
*
|
|
144
|
-
* Consecutive calls sharing the same `color` and `alpha` are coalesced into a
|
|
145
|
-
* single path and committed with one `fill()` on {@link flush} (or when the
|
|
146
|
-
* style changes / another draw call intervenes). Coordinates are in the
|
|
147
|
-
* current transform space. This collapses the per-entity
|
|
148
|
-
* `beginPath`/`arc`/`fill` of large point clouds into a handful of draw calls
|
|
149
|
-
* while preserving painter's-order semantics.
|
|
150
|
-
*
|
|
151
|
-
* @param cx - Center X in the current transform space.
|
|
152
|
-
* @param cy - Center Y in the current transform space.
|
|
153
|
-
* @param radius - Circle radius.
|
|
154
|
-
* @param color - CSS color string.
|
|
155
|
-
* @param alpha - Opacity in `[0, 1]` (default `1`).
|
|
156
|
-
*/
|
|
157
|
-
fillCircle(cx: number, cy: number, radius: number, color: string, alpha?: number): void;
|
|
158
|
-
/**
|
|
159
|
-
* Commit any pending batched draws (see {@link fillCircle}). Safe to call when
|
|
160
|
-
* no batch is active (no-op). The {@link Scene} flushes at the end of each
|
|
161
|
-
* sibling group and frame.
|
|
162
|
-
*/
|
|
163
|
-
flush(): void;
|
|
164
|
-
/**
|
|
165
|
-
* Create a linear gradient between two points with the given color stops.
|
|
166
|
-
*
|
|
167
|
-
* @param x0 - X of the gradient start point.
|
|
168
|
-
* @param y0 - Y of the gradient start point.
|
|
169
|
-
* @param x1 - X of the gradient end point.
|
|
170
|
-
* @param y1 - Y of the gradient end point.
|
|
171
|
-
* @param colorStops - Array of `{ stop, color }` pairs where `stop` is in `[0, 1]`.
|
|
172
|
-
* @returns An opaque gradient object suitable for {@link fill} or {@link stroke}.
|
|
173
|
-
*/
|
|
174
|
-
createLinearGradient(x0: number, y0: number, x1: number, y1: number, colorStops: {
|
|
175
|
-
stop: number;
|
|
176
|
-
color: string;
|
|
177
|
-
}[]): any;
|
|
178
|
-
}
|
|
179
|
-
|
|
1
|
+
import { type MotionConfig, type TweenConfig, type SpringConfig } from '../animation/drivers';
|
|
2
|
+
/** A numeric transform/visual property that participates in the animation system. */
|
|
3
|
+
export type AnimatableProp = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'opacity';
|
|
180
4
|
/**
|
|
181
5
|
* A 2-D coordinate in canvas/world space.
|
|
182
6
|
*/
|
|
183
|
-
interface Point {
|
|
7
|
+
export interface Point {
|
|
184
8
|
x: number;
|
|
185
9
|
y: number;
|
|
186
10
|
}
|
|
@@ -189,7 +13,7 @@ interface Point {
|
|
|
189
13
|
*
|
|
190
14
|
* Returned from {@link Entity.getBounds} to enable viewport culling.
|
|
191
15
|
*/
|
|
192
|
-
interface Bounds {
|
|
16
|
+
export interface Bounds {
|
|
193
17
|
x: number;
|
|
194
18
|
y: number;
|
|
195
19
|
width: number;
|
|
@@ -200,7 +24,7 @@ interface Bounds {
|
|
|
200
24
|
* origin, returned from {@link Entity.getBatchCircle} to opt into the renderer's
|
|
201
25
|
* draw-call batching fast-path.
|
|
202
26
|
*/
|
|
203
|
-
interface BatchCircle {
|
|
27
|
+
export interface BatchCircle {
|
|
204
28
|
/** Circle radius in the entity's local space. */
|
|
205
29
|
radius: number;
|
|
206
30
|
/** CSS fill color. */
|
|
@@ -211,7 +35,7 @@ interface BatchCircle {
|
|
|
211
35
|
* origin, returned from {@link Entity.getBatchRect} to opt into the GPU
|
|
212
36
|
* instanced-rectangle fast-path (WebGL `pointBackend` only).
|
|
213
37
|
*/
|
|
214
|
-
interface BatchRect {
|
|
38
|
+
export interface BatchRect {
|
|
215
39
|
/** Rectangle width in the entity's local space. */
|
|
216
40
|
width: number;
|
|
217
41
|
/** Rectangle height in the entity's local space. */
|
|
@@ -227,7 +51,7 @@ interface BatchRect {
|
|
|
227
51
|
* to create and label the shadow DOM node (e.g. a real `<button>` or `<a href>`)
|
|
228
52
|
* so the canvas stays accessible and clickable by automation/agents.
|
|
229
53
|
*/
|
|
230
|
-
interface A11yAttributes {
|
|
54
|
+
export interface A11yAttributes {
|
|
231
55
|
/** Shadow element tag to create. Defaults to `'div'`. */
|
|
232
56
|
tag?: 'div' | 'a' | 'button' | 'img' | 'input' | 'textarea';
|
|
233
57
|
/** ARIA role applied via the `role` attribute. */
|
|
@@ -263,9 +87,9 @@ interface A11yAttributes {
|
|
|
263
87
|
/**
|
|
264
88
|
* Union of all pointer/interaction events that can be emitted by an {@link Entity}.
|
|
265
89
|
*/
|
|
266
|
-
type VectoEvent = 'click' | 'hover' | 'pointerdown' | 'pointerup' | 'pointermove' | 'pointerleave' | 'change' | 'focus' | 'blur' | 'wheel' | 'keydown' | 'keyup';
|
|
90
|
+
export type VectoEvent = 'click' | 'hover' | 'pointerdown' | 'pointerup' | 'pointermove' | 'pointerleave' | 'change' | 'focus' | 'blur' | 'wheel' | 'keydown' | 'keyup';
|
|
267
91
|
/** Options for {@link Entity.on} / {@link Entity.off}. */
|
|
268
|
-
interface ListenerOptions {
|
|
92
|
+
export interface ListenerOptions {
|
|
269
93
|
/** Register the listener for the capture phase (root→target) instead of bubble. */
|
|
270
94
|
capture?: boolean;
|
|
271
95
|
}
|
|
@@ -279,7 +103,7 @@ interface ListenerOptions {
|
|
|
279
103
|
* `clientX`, `key`, …) and `preventDefault()` pass through to `nativeEvent`, so
|
|
280
104
|
* handlers written against the raw DOM event keep working.
|
|
281
105
|
*/
|
|
282
|
-
declare class VectoJSEvent<N = unknown> {
|
|
106
|
+
export declare class VectoJSEvent<N = unknown> {
|
|
283
107
|
/** The event name. */
|
|
284
108
|
readonly type: VectoEvent;
|
|
285
109
|
/** The entity the event originated on. */
|
|
@@ -334,7 +158,7 @@ declare class VectoJSEvent<N = unknown> {
|
|
|
334
158
|
* }
|
|
335
159
|
* }
|
|
336
160
|
*/
|
|
337
|
-
declare abstract class Entity {
|
|
161
|
+
export declare abstract class Entity {
|
|
338
162
|
id: string;
|
|
339
163
|
children: Entity[];
|
|
340
164
|
parent: Entity | null;
|
|
@@ -342,12 +166,28 @@ declare abstract class Entity {
|
|
|
342
166
|
* Walk up the parent chain to find the scene this entity is currently attached to.
|
|
343
167
|
*/
|
|
344
168
|
get scene(): any;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
169
|
+
private _x;
|
|
170
|
+
private _y;
|
|
171
|
+
private _scaleX;
|
|
172
|
+
private _scaleY;
|
|
173
|
+
private _rotation;
|
|
174
|
+
private _opacity;
|
|
175
|
+
private _hasTransitions;
|
|
176
|
+
private _transitions;
|
|
177
|
+
private _drivers;
|
|
178
|
+
private _mounted;
|
|
179
|
+
get x(): number;
|
|
180
|
+
set x(v: number);
|
|
181
|
+
get y(): number;
|
|
182
|
+
set y(v: number);
|
|
183
|
+
get scaleX(): number;
|
|
184
|
+
set scaleX(v: number);
|
|
185
|
+
get scaleY(): number;
|
|
186
|
+
set scaleY(v: number);
|
|
187
|
+
get rotation(): number;
|
|
188
|
+
set rotation(v: number);
|
|
189
|
+
get opacity(): number;
|
|
190
|
+
set opacity(v: number);
|
|
351
191
|
isDOMPortal: boolean;
|
|
352
192
|
private _interactive;
|
|
353
193
|
get interactive(): boolean;
|
|
@@ -383,6 +223,10 @@ declare abstract class Entity {
|
|
|
383
223
|
* @returns `this` for method chaining.
|
|
384
224
|
*/
|
|
385
225
|
add(child: Entity): this;
|
|
226
|
+
/** Called once when this entity becomes attached to a live Scene. Override to react. */
|
|
227
|
+
protected onMounted(): void;
|
|
228
|
+
/** Fire onMounted for this node and its descendants, guarded against double-fire. */
|
|
229
|
+
private _notifyMounted;
|
|
386
230
|
/**
|
|
387
231
|
* Remove a child entity from this node.
|
|
388
232
|
*
|
|
@@ -411,6 +255,26 @@ declare abstract class Entity {
|
|
|
411
255
|
* @example entity.animate({ x: 400, opacity: 0 }, 500);
|
|
412
256
|
*/
|
|
413
257
|
animate(targetProps: Partial<this>, durationMs: number): this;
|
|
258
|
+
/** Write a driver-computed value to a backing field without re-triggering the setter. */
|
|
259
|
+
private _applyAnimated;
|
|
260
|
+
private _currentOf;
|
|
261
|
+
/**
|
|
262
|
+
* Write a value immediately, bypassing any configured transition. For subclasses
|
|
263
|
+
* that need to seed a starting state (e.g. the presence helper's enter `from`).
|
|
264
|
+
*/
|
|
265
|
+
protected setImmediate(prop: AnimatableProp, v: number): void;
|
|
266
|
+
private _spawnDriver;
|
|
267
|
+
/** Assignment path when a declarative transition is configured for `prop`. */
|
|
268
|
+
private _animateProp;
|
|
269
|
+
/** Declare which properties animate, and how. Subsequent assignment animates them. */
|
|
270
|
+
setTransition(config: Partial<Record<AnimatableProp, MotionConfig>>): this;
|
|
271
|
+
/** Imperative tween toward targets; resolves when all reach their end. */
|
|
272
|
+
animateTo(props: Partial<Record<AnimatableProp, number>>, cfg: TweenConfig): Promise<void>;
|
|
273
|
+
/** Imperative spring toward targets; resolves when all reach rest. */
|
|
274
|
+
springTo(props: Partial<Record<AnimatableProp, number>>, cfg?: SpringConfig): Promise<void>;
|
|
275
|
+
private _driveTo;
|
|
276
|
+
/** Advance active property drivers one frame. Call from update(). */
|
|
277
|
+
protected tickDrivers(dt: number): void;
|
|
414
278
|
/**
|
|
415
279
|
* Advance the entity's internal state for one frame.
|
|
416
280
|
*
|
|
@@ -420,7 +284,7 @@ declare abstract class Entity {
|
|
|
420
284
|
* @param dt - Elapsed time since the last frame in milliseconds.
|
|
421
285
|
* @param time - Absolute timestamp from `performance.now()`.
|
|
422
286
|
*/
|
|
423
|
-
update(
|
|
287
|
+
update(dt: number, time: number): void;
|
|
424
288
|
/**
|
|
425
289
|
* Register a listener for a {@link VectoEvent}.
|
|
426
290
|
*
|
|
@@ -549,12 +413,20 @@ declare abstract class Entity {
|
|
|
549
413
|
*/
|
|
550
414
|
getBatchRect(): BatchRect | null;
|
|
551
415
|
/**
|
|
552
|
-
* Whether this entity still has a queued/running tween animation
|
|
416
|
+
* Whether this entity still has a queued/running tween animation, or an
|
|
417
|
+
* active {@link setTransition}/{@link animateTo}/{@link springTo} property
|
|
418
|
+
* driver.
|
|
553
419
|
*
|
|
554
|
-
* Used by {@link Scene}
|
|
555
|
-
*
|
|
420
|
+
* Used by {@link Scene} to keep rendering continuously while an animation
|
|
421
|
+
* is in flight — both in `onDemand` render mode, and to hold off the
|
|
422
|
+
* `always`-mode idle auto-throttle. Without checking `_drivers` here, a
|
|
423
|
+
* property driver becomes invisible to that throttle: `markDirty()` called
|
|
424
|
+
* from inside `update()`/`tickDrivers()` is wiped by the loop's own
|
|
425
|
+
* `dirty = false` at the end of that same tick, so once the throttle
|
|
426
|
+
* engages an in-flight spring/tween only advances one animation-frame per
|
|
427
|
+
* external `markDirty()` trigger instead of every render frame.
|
|
556
428
|
*
|
|
557
|
-
* @returns `true` if at least one animation remains.
|
|
429
|
+
* @returns `true` if at least one animation or property driver remains.
|
|
558
430
|
*/
|
|
559
431
|
hasPendingAnimations(): boolean;
|
|
560
432
|
abstract isPointInside(globalX: number, globalY: number): boolean;
|
|
@@ -568,5 +440,3 @@ declare abstract class Entity {
|
|
|
568
440
|
*/
|
|
569
441
|
abstract render(renderer: any): void;
|
|
570
442
|
}
|
|
571
|
-
|
|
572
|
-
export { type A11yAttributes as A, type Bounds as B, Entity as E, type IRenderer as I, type ListenerOptions as L, type Point as P, type VectoEvent as V, type BatchCircle as a, type BatchRect as b, VectoJSEvent as c };
|