@rive-app/webgl-single 1.0.77 → 1.0.80

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/webgl-single",
3
- "version": "1.0.77",
3
+ "version": "1.0.80",
4
4
  "description": "Rive's webgl based web api with bundled wasm.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -171,7 +171,7 @@ k.run=sd;if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);
171
171
  /* 2 */
172
172
  /***/ ((module) => {
173
173
 
174
- module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.0.77","description":"Rive\'s webgl based web api with bundled wasm.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
174
+ module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.0.80","description":"Rive\'s webgl based web api with bundled wasm.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
175
175
 
176
176
  /***/ }),
177
177
  /* 3 */
@@ -1,325 +1,669 @@
1
1
  interface RiveOptions {
2
- locateFile(file: string): string
3
- }
4
-
5
- declare function Rive(options?: RiveOptions): Promise<RiveCanvas>;
6
- export default Rive;
7
-
8
- export interface RiveCanvas {
9
- Alignment: AlignmentFactory;
10
- CanvasRenderer: typeof CanvasRenderer;
11
- LinearAnimationInstance: typeof LinearAnimationInstance;
12
- StateMachineInstance: typeof StateMachineInstance;
13
- Mat2D: typeof Mat2D;
14
- Vec2D: typeof Vec2D;
15
- AABB: AABB;
16
- SMIInput: typeof SMIInput;
17
- renderFactory: CanvasRenderFactory;
18
-
19
- BlendMode: typeof BlendMode;
20
- FillRule: typeof FillRule;
21
- Fit: typeof Fit;
22
- RenderPaintStyle: typeof RenderPaintStyle;
23
- StrokeCap: typeof StrokeCap;
24
- StrokeJoin: typeof StrokeJoin;
25
-
26
- load(buffer: Uint8Array): Promise<File>;
27
- makeRenderer(canvas: HTMLCanvasElement | OffscreenCanvas, useOffscreenRenderer?: boolean) : CanvasRenderer;
28
- computeAlignment(fit: Fit, alignment: Alignment, frame: AABB, content: AABB): Mat2D;
29
- mapXY(matrix: Mat2D, canvasPoints: Vec2D): Vec2D;
30
- requestAnimationFrame(cb: (timestamp: DOMHighResTimeStamp) => void): number;
31
- cancelAnimationFrame(requestID: number): void;
32
- enableFPSCounter(cb: (fps: number) => void): void;
33
- disableFPSCounter(): void;
34
- }
35
-
36
- //////////////
37
- // RENDERER //
38
- //////////////
39
-
40
- export declare class RendererWrapper {
41
- save(): void;
42
- restore(): void;
43
- transform(tranform: Mat2D): void;
44
- drawPath(path: RenderPath, paint: RenderPaint): void;
45
- clipPath(path: RenderPath): void;
46
- clear(): void;
47
- flush(): void;
48
- translate(x: number, y: number): void;
49
- rotate(angle: number): void;
50
- }
51
-
52
- export declare class RenderPathWrapper {
53
- reset(): void;
54
- addPath(path: CommandPath, transform: Mat2D): void;
55
- fillRule(value: FillRule): void;
56
- moveTo(x: number, y: number): void
57
- lineTo(x: number, y: number): void
58
- cubicTo(ox: number, oy: number, ix: number, iy: number, x: number, y: number): void;
59
- close(): void;
60
- }
61
-
62
- export declare class RenderPaintWrapper {
63
- color(value: number): void;
64
- thickness(value: number): void;
65
- join(value: StrokeJoin): void;
66
- cap(value: StrokeCap): void;
67
- blendMode(value: BlendMode): void;
68
- style(value: RenderPaintStyle): void;
69
- linearGradient(sx: number, sy: number, ex: number, ey: number): void;
70
- radialGradient(sx: number, sy: number, ex: number, ey: number): void;
71
- addStop(color: number, stop: number): void;
72
- completeGradient(): void;
73
- }
74
-
75
- export declare class Renderer extends RendererWrapper {
76
- align(fit: Fit, alignment: Alignment, frame: AABB, content: AABB): void
77
- }
78
-
79
- export declare class CommandPath { }
80
-
81
- export declare class RenderPath extends RenderPathWrapper { }
82
-
83
- export declare class RenderPaint extends RenderPaintWrapper { }
84
-
85
-
86
- /////////////////////
87
- // CANVAS RENDERER //
88
- /////////////////////
89
-
90
- export declare class CanvasRenderer extends Renderer {
91
- constructor(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D);
92
- }
93
-
94
- export declare class CanvasRenderPaint extends RenderPaint {
95
- draw(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, path: RenderPath): void;
96
- }
97
-
98
- export declare class CanvasRenderPath extends RenderPath { }
99
-
100
- export interface CanvasRenderFactory {
101
- makeRenderPaint(): CanvasRenderPaint;
102
- makeRenderPath(): CanvasRenderPath;
103
- }
104
-
105
- //////////
106
- // File //
107
- //////////
108
- export declare class File {
109
- defaultArtboard(): Artboard; // rive::ArtboardInstance
110
- artboardByName(name: string): Artboard; // rive::ArtboardInstance
111
- artboardByIndex(index: number): Artboard; // rive::ArtboardInstance
112
- artboardCount(): number;
113
- }
114
-
115
- // This wraps rive::ArtboardInstance*
116
- export declare class Artboard {
117
- get name(): string;
118
- get bounds(): AABB;
119
- get frameOrigin(): boolean;
120
- set frameOrigin(val: boolean);
121
- // Deletes the backing wasm artboard instance
122
- delete(): void;
123
- advance(sec: number): any;
124
- draw(renderer: CanvasRenderer): void;
125
- animationByName(name: string): LinearAnimationInstance;
126
- animationByIndex(index: number): LinearAnimationInstance;
127
- animationCount(): number;
128
- stateMachineByName(name: string): StateMachineInstance;
129
- stateMachineByIndex(index: number): StateMachineInstance;
130
- stateMachineCount(): number;
131
- bone(name: string): Bone;
132
- node(name: string): Node;
133
- rootBone(name: string): RootBone;
134
- transformComponent(name: string): TransformComponent;
135
- }
136
-
137
- export declare class Bone extends TransformComponent {
138
- length: number;
139
- }
140
-
141
- export declare class RootBone extends Bone {
142
- x: number;
143
- y: number;
144
- }
145
-
146
- export declare class Node extends TransformComponent {
147
- x: number;
148
- y: number;
149
- }
150
-
151
- export declare class TransformComponent {
152
- rotation: number;
153
- scaleX: number;
154
- scaleY: number;
155
- worldTransform(): Mat2D;
156
- parentWorldTransform(result: Mat2D): void;
157
- }
158
-
159
- ///////////////
160
- // Animation //
161
- ///////////////
162
- export declare class LinearAnimationInstance {
163
- constructor(animation: LinearAnimationInstance, artboard: Artboard);
164
- get name(): string;
165
- get duration(): number;
166
- get fps(): number;
167
- get workStart(): number;
168
- get workEnd(): number;
169
- get loopValue(): number;
170
- get speed(): number;
171
- /** Time of the animation in seconds */
172
- time: number;
173
- didLoop: boolean;
174
- advance(sec: number): any;
175
- /**
176
- * Apply animation on the artboard
177
- * @param mix 0-1 the strength of the animation in the animations mix.
178
- */
179
- apply(mix: number): any;
180
- // Deletes the backing Wasm animation instance
181
- delete(): void;
182
- }
183
-
184
- export declare class StateMachineInstance {
185
- constructor(stateMachine: StateMachineInstance, artboard: Artboard);
186
- get name(): string;
187
- inputCount(): number;
188
- input(i: number): SMIInput;
189
- advance(sec: number): any;
190
- stateChangedCount(): number;
191
- stateChangedNameByIndex(i: number): string;
192
-
193
- // Call with coordinates in Artboard space
194
- pointerDown(x: number, y: number): void;
195
- pointerMove(x: number, y: number): void;
196
- pointerUp(x: number, y: number): void;
197
-
198
- // Deletes the backing Wasm state machine instance
199
- delete(): void;
200
- }
201
-
202
- export declare class SMIInput {
203
- static bool: number;
204
- static number: number;
205
- static trigger: number;
206
-
207
- get name(): string;
208
- get type(): number;
209
- get value(): boolean | number | undefined;
210
- set value(val: boolean | number | undefined);
211
- fire(): void;
212
- asBool(): SMIInput;
213
- asNumber(): SMIInput;
214
- asTrigger(): SMIInput;
215
- }
216
-
217
- export declare class SMIBool {
218
-
219
- }
220
-
221
- export declare class SMINumber {
222
-
223
- }
224
-
225
- export declare class SMITrigger {
226
-
227
- }
228
-
229
- ///////////
230
- // ENUMS //
231
- ///////////
232
-
233
- export enum Fit {
234
- fill,
235
- contain,
236
- cover,
237
- fitWidth,
238
- fitHeight,
239
- none,
240
- scaleDown,
241
- }
242
-
243
- export enum RenderPaintStyle {
244
- fill,
245
- stroke,
246
- }
247
-
248
- export enum FillRule {
249
- nonZero,
250
- evenOdd,
251
- }
252
-
253
- export enum StrokeCap {
254
- butt,
255
- round,
256
- square,
257
- }
258
- export enum StrokeJoin {
259
- miter,
260
- round,
261
- bevel,
262
- }
263
-
264
- export enum BlendMode {
265
- srcOver = 3,
266
- screen = 14,
267
- overlay = 15,
268
- darken = 16,
269
- lighten = 17,
270
- colorDodge = 18,
271
- colorBurn = 19,
272
- hardLight = 20,
273
- softLight = 21,
274
- difference = 22,
275
- exclusion = 23,
276
- multiply = 24,
277
- hue = 25,
278
- saturation = 26,
279
- color = 27,
280
- luminosity = 28,
281
- }
282
-
283
- ///////////
284
- // UTILS //
285
- ///////////
286
-
287
- export declare class Alignment {
288
- get x(): number;
289
- get y(): number;
290
- }
291
-
292
- export declare class AlignmentFactory {
293
- get topLeft(): Alignment;
294
- get topCenter(): Alignment;
295
- get topRight(): Alignment;
296
- get centerLeft(): Alignment;
297
- get center(): Alignment;
298
- get centerRight(): Alignment;
299
- get bottomLeft(): Alignment;
300
- get bottomCenter(): Alignment;
301
- get bottomRight(): Alignment;
302
- }
303
-
304
- export interface AABB {
305
- minX: number;
306
- minY: number;
307
- maxX: number;
308
- maxY: number;
309
- }
310
-
311
- export declare class Mat2D {
312
- xx: number;
313
- xy: number;
314
- yx: number;
315
- yy: number;
316
- tx: number;
317
- ty: number;
318
- invert(mat: Mat2D): boolean;
319
- }
320
-
321
- export declare class Vec2D {
322
- x(): void;
323
- y(): void;
324
- }
325
-
2
+ locateFile(file: string): string;
3
+ }
4
+
5
+ declare function Rive(options?: RiveOptions): Promise<RiveCanvas>;
6
+ export default Rive;
7
+
8
+ /**
9
+ * RiveCanvas is the main export object that contains references to different Rive classes to help
10
+ * build the Rive render loop for low-level API usage. In addition, this contains multiple methods
11
+ * that help aid in setup, such as loading in a Rive file, creating the renderer, and
12
+ * starting/finishing the render loop (requestAnimationFrame)
13
+ */
14
+ export interface RiveCanvas {
15
+ Alignment: AlignmentFactory;
16
+ CanvasRenderer: typeof CanvasRenderer;
17
+ LinearAnimationInstance: typeof LinearAnimationInstance;
18
+ StateMachineInstance: typeof StateMachineInstance;
19
+ Mat2D: typeof Mat2D;
20
+ Vec2D: typeof Vec2D;
21
+ AABB: AABB;
22
+ SMIInput: typeof SMIInput;
23
+ renderFactory: CanvasRenderFactory;
24
+
25
+ BlendMode: typeof BlendMode;
26
+ FillRule: typeof FillRule;
27
+ Fit: typeof Fit;
28
+ RenderPaintStyle: typeof RenderPaintStyle;
29
+ StrokeCap: typeof StrokeCap;
30
+ StrokeJoin: typeof StrokeJoin;
31
+
32
+ /**
33
+ * Loads a Rive file for the runtime and returns a Rive-specific File class
34
+ *
35
+ * @param buffer - Array buffer of a Rive file
36
+ * @returns A Promise for a Rive File class
37
+ */
38
+ load(buffer: Uint8Array): Promise<File>;
39
+
40
+ /**
41
+ * Creates the renderer to draw the Rive on the provided canvas element
42
+ *
43
+ * @param canvas - Canvas to draw the Rive on
44
+ * @param useOffscreenRenderer - Option for those using the WebGL-variant of the Rive JS library.
45
+ * This uses an offscreen renderer to draw on the canvas, allowing for multiple Rives/canvases on
46
+ * a given screen. It is highly recommended to set this to `true` when using with the
47
+ * `@rive-app/webgl` package
48
+ * @returns A Rive CanvasRenderer class
49
+ */
50
+ makeRenderer(
51
+ canvas: HTMLCanvasElement | OffscreenCanvas,
52
+ useOffscreenRenderer?: boolean
53
+ ): CanvasRenderer;
54
+
55
+ /**
56
+ * Computes how the Rive is laid out onto the canvas
57
+ * @param {Fit} fit - Fit enum (i.e Fit.contain)
58
+ * @param alignment - Alignment enum (i.e Alignment.center)
59
+ * @param frame - AABB object representing the bounds of the canvas frame
60
+ * @param content - AABB object representing the bounds of what to draw the Rive onto
61
+ * (i.e an artboard's size)
62
+ * @returns Mat2D - A Mat2D view matrix
63
+ */
64
+ computeAlignment(
65
+ fit: Fit,
66
+ alignment: Alignment,
67
+ frame: AABB,
68
+ content: AABB
69
+ ): Mat2D;
70
+ mapXY(matrix: Mat2D, canvasPoints: Vec2D): Vec2D;
71
+ /**
72
+ * A Rive-specific requestAnimationFrame function; this must be used instead of the global
73
+ * requestAnimationFrame function.
74
+ * @param cb - Callback function to call with an elapsed timestamp
75
+ * @returns number - An ID of the requestAnimationFrame request
76
+ */
77
+ requestAnimationFrame(cb: (timestamp: DOMHighResTimeStamp) => void): number;
78
+ /**
79
+ * A Rive-specific cancelAnimationFrame function; this must be used instead of the global
80
+ * cancelAnimationFrame function.
81
+ * @param requestID - ID of the requestAnimationFrame request to cancel
82
+ */
83
+ cancelAnimationFrame(requestID: number): void;
84
+ /**
85
+ * Debugging tool to showcase the FPS in the corner of the screen in a new div. If a callback
86
+ * function is provided, this function passes the FPS count to the callback instead of creating a
87
+ * new div so the client can decide what to do with that data.
88
+ */
89
+ enableFPSCounter(cb?: (fps: number) => void): void;
90
+ /**
91
+ * Debugging tool to remove the FPS counter that displays from enableFPSCounter
92
+ */
93
+ disableFPSCounter(): void;
94
+ }
95
+
96
+ //////////////
97
+ // RENDERER //
98
+ //////////////
99
+
100
+ /**
101
+ * Rive wrapper around a rendering context for a canvas element, implementing a subset of the APIs
102
+ * from the rendering context interface
103
+ */
104
+ export declare class RendererWrapper {
105
+ /**
106
+ * Saves the state of the canvas and pushes it onto a stack
107
+ *
108
+ * For the underlying API, check
109
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
110
+ */
111
+ save(): void;
112
+ /**
113
+ * Restores the most recent state of the canvas saved on the stack
114
+ *
115
+ * For the underlying API, check
116
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore
117
+ */
118
+ restore(): void;
119
+ transform(tranform: Mat2D): void;
120
+ drawPath(path: RenderPath, paint: RenderPaint): void;
121
+ clipPath(path: RenderPath): void;
122
+ /**
123
+ * Calls the context's clearRect() function to clear the entire canvas
124
+ *
125
+ * For the underlying API, check
126
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect
127
+ */
128
+ clear(): void;
129
+ flush(): void;
130
+ translate(x: number, y: number): void;
131
+ rotate(angle: number): void;
132
+ }
133
+
134
+ export declare class RenderPathWrapper {
135
+ reset(): void;
136
+ addPath(path: CommandPath, transform: Mat2D): void;
137
+ fillRule(value: FillRule): void;
138
+ moveTo(x: number, y: number): void;
139
+ lineTo(x: number, y: number): void;
140
+ cubicTo(
141
+ ox: number,
142
+ oy: number,
143
+ ix: number,
144
+ iy: number,
145
+ x: number,
146
+ y: number
147
+ ): void;
148
+ close(): void;
149
+ }
150
+
151
+ export declare class RenderPaintWrapper {
152
+ color(value: number): void;
153
+ thickness(value: number): void;
154
+ join(value: StrokeJoin): void;
155
+ cap(value: StrokeCap): void;
156
+ blendMode(value: BlendMode): void;
157
+ style(value: RenderPaintStyle): void;
158
+ linearGradient(sx: number, sy: number, ex: number, ey: number): void;
159
+ radialGradient(sx: number, sy: number, ex: number, ey: number): void;
160
+ addStop(color: number, stop: number): void;
161
+ completeGradient(): void;
162
+ }
163
+
164
+ /**
165
+ * Renderer returned when Rive makes a renderer via `makeRenderer()`
166
+ */
167
+ export declare class Renderer extends RendererWrapper {
168
+ /**
169
+ * Aligns the Rive content on the canvas space
170
+ * @param fit - Fit enum value
171
+ * @param alignment - Alignment enum value
172
+ * @param frame - Bounds of the canvas space
173
+ * @param content - Bounds of the Rive content
174
+ */
175
+ align(fit: Fit, alignment: Alignment, frame: AABB, content: AABB): void;
176
+ }
177
+
178
+ export declare class CommandPath {}
179
+
180
+ export declare class RenderPath extends RenderPathWrapper {}
181
+
182
+ export declare class RenderPaint extends RenderPaintWrapper {}
183
+
184
+ /////////////////////
185
+ // CANVAS RENDERER //
186
+ /////////////////////
187
+ export declare class CanvasRenderer extends Renderer {
188
+ constructor(
189
+ ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
190
+ );
191
+ }
192
+
193
+ export declare class CanvasRenderPaint extends RenderPaint {
194
+ draw(
195
+ ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
196
+ path: RenderPath
197
+ ): void;
198
+ }
199
+
200
+ export declare class CanvasRenderPath extends RenderPath {}
201
+
202
+ export interface CanvasRenderFactory {
203
+ makeRenderPaint(): CanvasRenderPaint;
204
+ makeRenderPath(): CanvasRenderPath;
205
+ }
206
+
207
+ //////////
208
+ // File //
209
+ //////////
210
+ /**
211
+ * Rive-specific File class that provides a number of functions to load instances of Artboards
212
+ */
213
+ export declare class File {
214
+ /**
215
+ * Returns the first Artboard found in the Rive file as a new Artboard instance
216
+ * @returns An Artboard instance
217
+ */
218
+ defaultArtboard(): Artboard; // rive::ArtboardInstance
219
+ /**
220
+ * Returns the named Artboard found in the Rive file as a new Artboard instance
221
+ * @param name - Name of the Artboard to create an instance for
222
+ */
223
+ artboardByName(name: string): Artboard; // rive::ArtboardInstance
224
+ /**
225
+ * Returns a new Artboard instance for the Artboard at the given index in the Rive file
226
+ * @param index - Index of the Artboard in the file to create an Artboard instance for
227
+ */
228
+ artboardByIndex(index: number): Artboard; // rive::ArtboardInstance
229
+ /**
230
+ * Returns the number of Artboards in the Rive File
231
+ * @returns Number of artboards in the Rive file
232
+ */
233
+ artboardCount(): number;
234
+ }
235
+
236
+ /**
237
+ * Rive class representing an Artboard instance. Use this class to create instances for
238
+ * LinearAnimations, StateMachines, Nodes, Bones, and more. This Artboard instance should also be
239
+ * advanced in the drawing render loop.
240
+ *
241
+ * Important: Make sure to delete this instance when it's no longer in use via the `delete()`
242
+ * method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
243
+ * be done in cases where the user navigates away from the page with this animation, the canvas is
244
+ * unmounted, etc.
245
+ */
246
+ export declare class Artboard {
247
+ /**
248
+ * Get the name of this Artboard instance
249
+ */
250
+ get name(): string;
251
+ /**
252
+ * Get the bounds of this Artboard instance
253
+ */
254
+ get bounds(): AABB;
255
+ get frameOrigin(): boolean;
256
+ set frameOrigin(val: boolean);
257
+ /**
258
+ * Deletes the underlying instance created via the WASM. It's important to clean up this
259
+ * instance when no longer in use
260
+ */
261
+ delete(): void;
262
+ /**
263
+ * Advances the Artboard instance by the set amount of seconds. This method updates each object
264
+ * in the Artboard with any changes that animations apply on properties of the objects. This
265
+ * should be called after calling `advance()` of a LinearAnimationInstance or StateMachineInstance
266
+ * @param sec - Scrub the Artboard instance by a number of seconds
267
+ */
268
+ advance(sec: number): boolean;
269
+ /**
270
+ * Draws the artboard with a given rendering context.
271
+ * @param renderer - Renderer context to draw with
272
+ */
273
+ draw(renderer: CanvasRenderer): void;
274
+ /**
275
+ * Creates a LinearAnimationinstance for the animation with the given name
276
+ * @param name - Name of the animation to create an instance for
277
+ * @returns A new LinearAnimationInstance object
278
+ */
279
+ animationByName(name: string): LinearAnimationInstance;
280
+ /**
281
+ * Creates a LinearAnimationinstance for the animation with the given index
282
+ * @param index - Index of the animation to create an instance for
283
+ * @returns A new LinearAnimationInstance object
284
+ */
285
+ animationByIndex(index: number): LinearAnimationInstance;
286
+ /**
287
+ * Returns the number of animations in the artboard
288
+ * @returns Number of animations on the Artboard
289
+ */
290
+ animationCount(): number;
291
+ /**
292
+ * Creates a StateMachineInstance for the state machine with the given name
293
+ * @param name - Name of the state machine to create an instance for
294
+ * @returns A new StateMachineInstance object
295
+ */
296
+ stateMachineByName(name: string): StateMachineInstance;
297
+ /**
298
+ * Creates a StateMachineInstance for the state machine with the given index
299
+ * @param index - Index of the state machine to create an instance for
300
+ * @returns A new StateMachineInstance object
301
+ */
302
+ stateMachineByIndex(index: number): StateMachineInstance;
303
+ /**
304
+ * Returns the number of state machines in the artboard
305
+ * @returns Number of state machines on the Artboard
306
+ */
307
+ stateMachineCount(): number;
308
+ /**
309
+ * Returns a reference for a Bone object of a given name.
310
+ * Learn more: https://help.rive.app/editor/manipulating-shapes/bones
311
+ *
312
+ * @param name - Name of the Bone to grab a reference to
313
+ */
314
+ bone(name: string): Bone;
315
+ /**
316
+ * Returns a reference for a Node object of a given name from the Artboard hierarchy
317
+ * @param name - Name of the Node from the Artboard hierarchy to grab a reference to
318
+ */
319
+ node(name: string): Node;
320
+ /**
321
+ * Returns a reference for a root Bone object of a given name
322
+ * @param name - Name of the root Bone to grab a reference to
323
+ */
324
+ rootBone(name: string): RootBone;
325
+ /**
326
+ * Returns a reference for a transform component object of a given name
327
+ * @param name - Name of the transform component to grab a reference to
328
+ */
329
+ transformComponent(name: string): TransformComponent;
330
+ }
331
+
332
+ export declare class Bone extends TransformComponent {
333
+ /**
334
+ * Length of the bone
335
+ */
336
+ length: number;
337
+ }
338
+
339
+ export declare class RootBone extends Bone {
340
+ /**
341
+ * X coordinate of the position on the RootBone
342
+ */
343
+ x: number;
344
+ /**
345
+ * Y coordinate of the position on the RootBone
346
+ */
347
+ y: number;
348
+ }
349
+
350
+ /**
351
+ * Representation of a node in the Artboard hierarchy (i.e group, shape, etc.)
352
+ */
353
+ export declare class Node extends TransformComponent {
354
+ /**
355
+ * X coordinate of the position on the Node
356
+ */
357
+ x: number;
358
+ /**
359
+ * Y coordinate of the position on the RootBone
360
+ */
361
+ y: number;
362
+ }
363
+
364
+ export declare class TransformComponent {
365
+ rotation: number;
366
+ scaleX: number;
367
+ scaleY: number;
368
+ worldTransform(): Mat2D;
369
+ parentWorldTransform(result: Mat2D): void;
370
+ }
371
+
372
+ ///////////////
373
+ // Animation //
374
+ ///////////////
375
+ /**
376
+ * Rive class representing a LinearAnimation instance. Use this class to advance and control a
377
+ * particular animation in the render loop (i.e speed, scrub, mix, etc.).
378
+ *
379
+ * Important: Make sure to delete this instance when it's no longer in use via the `delete()`
380
+ * method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
381
+ * be done in cases where the user navigates away from the page with this animation, the canvas is
382
+ * unmounted, etc.
383
+ */
384
+ export declare class LinearAnimationInstance {
385
+ /**
386
+ * Create a new LinearAnimationInstance reference
387
+ * @param animation - A LinearAnimationInstance retrieved via the Artboard
388
+ * (i.e `artboard.animationByName('foo')`)
389
+ * @param artboard - The Artboard instance for this animation
390
+ */
391
+ constructor(animation: LinearAnimationInstance, artboard: Artboard);
392
+ get name(): string;
393
+ get duration(): number;
394
+ get fps(): number;
395
+ get workStart(): number;
396
+ get workEnd(): number;
397
+ get loopValue(): number;
398
+ get speed(): number;
399
+ /**
400
+ * Number of seconds the animation has advanced by
401
+ */
402
+ time: number;
403
+ /**
404
+ * Flag to determine if the animation looped (this is reset when the loop restarts)
405
+ */
406
+ didLoop: boolean;
407
+ /**
408
+ * Advances/scrubs the LinearAnimationInstance by the set amount of seconds. Note that this only
409
+ * moves the "time" in the animation, but does not apply changes to the properties in the
410
+ * Artboard. This must be called before the `apply()` method of LinearAnimationInstance.
411
+ *
412
+ * @param sec - Scrub the animation instance by a number of seconds
413
+ */
414
+ advance(sec: number): boolean;
415
+ /**
416
+ * Apply a mixing value on the animation instance. This is useful if you are looking to blend
417
+ * multiple animations together and want to dictate a strength for each of the animations played
418
+ * back. This also applies new values to properties of objects on the Artboard according to the
419
+ * keys of the animation.
420
+ * This must be called after the `advance()` method of `LinearAnimationInstance`
421
+ *
422
+ * @param mix 0-1 the strength of the animation in the animations mix.
423
+ */
424
+ apply(mix: number): void;
425
+ /**
426
+ * Deletes the underlying instance created via the WASM. It's important to clean up this instance
427
+ * when no longer in use
428
+ */
429
+ delete(): void;
430
+ }
431
+
432
+ /**
433
+ * Rive class representing a StateMachine instance. Use this class to advance and control a
434
+ * particular state machine in the render loop (i.e scrub, grab state machine inputs, set up
435
+ * listener events, etc.).
436
+ *
437
+ * Important: Make sure to delete this instance when it's no longer in use via the `delete()`
438
+ * method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
439
+ * be done in cases where the user navigates away from the page with this animation, the canvas is
440
+ * unmounted, etc.
441
+ */
442
+ export declare class StateMachineInstance {
443
+ /**
444
+ * Create a new StateMachineInstance reference
445
+ * @param stateMachine - A StateMachineInstance retrieved via the Artboard
446
+ * (i.e `artboard.stateMachineByName('foo')`)
447
+ * @param artboard - The Artboard instance for this state machine
448
+ */
449
+ constructor(stateMachine: StateMachineInstance, artboard: Artboard);
450
+ get name(): string;
451
+ /**
452
+ * Returns the number of inputs associated with this state machine
453
+ * @returns Number of inputs
454
+ */
455
+ inputCount(): number;
456
+ /**
457
+ * Returns the state machine input at the given index
458
+ * @param i - Index to retrieve the state machine input at
459
+ * @returns SMIInput reference
460
+ */
461
+ input(i: number): SMIInput;
462
+ /**
463
+ * Advances/scrubs the StateMachineInstance by the set amount of seconds. Note that this does not
464
+ * apply changes to the properties of objects in the Artboard yet.
465
+ * @param sec - Scrub the state machine instance by a number of seconds
466
+ */
467
+ advance(sec: number): boolean;
468
+ /**
469
+ * Returns the number of states changed while the state machine played
470
+ * @returns Number of states changed in the duration of the state machine played
471
+ */
472
+ stateChangedCount(): number;
473
+ /**
474
+ * Returns the name of the state/animation transitioned to, given the index in the array of state
475
+ * changes in total
476
+ * @param i
477
+ * @returns Name of the state/animation transitioned to
478
+ */
479
+ stateChangedNameByIndex(i: number): string;
480
+
481
+ /**
482
+ * Notifies the state machine that the pointer has pressed down at the given coordinate in
483
+ * Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
484
+ * interest at a given moment.
485
+ *
486
+ * @param x - X coordinate
487
+ * @param y - Y coordinate
488
+ */
489
+ pointerDown(x: number, y: number): void;
490
+ /**
491
+ * Notifies the state machine that the pointer has moved to the given coordinate in
492
+ * Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
493
+ * interest at a given moment.
494
+ *
495
+ * @param x - X coordinate
496
+ * @param y - Y coordinate
497
+ */
498
+ pointerMove(x: number, y: number): void;
499
+ /**
500
+ * Notifies the state machine that the pointer has released at the given coordinate in
501
+ * Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
502
+ * interest at a given moment.
503
+ * @param x - X coordinate
504
+ * @param y - Y coordinate
505
+ */
506
+ pointerUp(x: number, y: number): void;
507
+
508
+ /**
509
+ * Deletes the underlying instance created via the WASM. It's important to clean up this instance
510
+ * when no longer in use
511
+ */
512
+ delete(): void;
513
+ }
514
+
515
+ export declare class SMIInput {
516
+ // TODO: Keep only the base SMIInput properties and make SMIBool, SMINumber, SMITriger extend it
517
+ static bool: number;
518
+ static number: number;
519
+ static trigger: number;
520
+
521
+ /**
522
+ * Getter for name of the state machine input
523
+ */
524
+ get name(): string;
525
+ get type(): number;
526
+ /**
527
+ * Getter for value of the state machine input
528
+ */
529
+ get value(): boolean | number | undefined;
530
+ /**
531
+ * Setter for value of the state machine input
532
+ */
533
+ set value(val: boolean | number | undefined);
534
+ /**
535
+ * Fires a trigger input on a state machine
536
+ */
537
+ fire(): void;
538
+ asBool(): SMIInput;
539
+ asNumber(): SMIInput;
540
+ asTrigger(): SMIInput;
541
+ }
542
+
543
+ export declare class SMIBool {}
544
+
545
+ export declare class SMINumber {}
546
+
547
+ export declare class SMITrigger {}
548
+
549
+ ///////////
550
+ // ENUMS //
551
+ ///////////
552
+
553
+ export enum Fit {
554
+ fill,
555
+ contain,
556
+ cover,
557
+ fitWidth,
558
+ fitHeight,
559
+ none,
560
+ scaleDown,
561
+ }
562
+
563
+ export enum RenderPaintStyle {
564
+ fill,
565
+ stroke,
566
+ }
567
+
568
+ export enum FillRule {
569
+ nonZero,
570
+ evenOdd,
571
+ }
572
+
573
+ export enum StrokeCap {
574
+ butt,
575
+ round,
576
+ square,
577
+ }
578
+ export enum StrokeJoin {
579
+ miter,
580
+ round,
581
+ bevel,
582
+ }
583
+
584
+ export enum BlendMode {
585
+ srcOver = 3,
586
+ screen = 14,
587
+ overlay = 15,
588
+ darken = 16,
589
+ lighten = 17,
590
+ colorDodge = 18,
591
+ colorBurn = 19,
592
+ hardLight = 20,
593
+ softLight = 21,
594
+ difference = 22,
595
+ exclusion = 23,
596
+ multiply = 24,
597
+ hue = 25,
598
+ saturation = 26,
599
+ color = 27,
600
+ luminosity = 28,
601
+ }
602
+
603
+ ///////////
604
+ // UTILS //
605
+ ///////////
606
+
607
+ export declare class Alignment {
608
+ get x(): number;
609
+ get y(): number;
610
+ }
611
+
612
+ export declare class AlignmentFactory {
613
+ get topLeft(): Alignment;
614
+ get topCenter(): Alignment;
615
+ get topRight(): Alignment;
616
+ get centerLeft(): Alignment;
617
+ get center(): Alignment;
618
+ get centerRight(): Alignment;
619
+ get bottomLeft(): Alignment;
620
+ get bottomCenter(): Alignment;
621
+ get bottomRight(): Alignment;
622
+ }
623
+
624
+ /**
625
+ * Axis-aligned bounding box
626
+ */
627
+ export interface AABB {
628
+ minX: number;
629
+ minY: number;
630
+ maxX: number;
631
+ maxY: number;
632
+ }
633
+
634
+ /**
635
+ * Column-major matrix described by the following:
636
+ * | xx yx tx |
637
+ * | xy yy ty |
638
+ * | 0 0 1 |
639
+ */
640
+ export declare class Mat2D {
641
+ xx: number;
642
+ xy: number;
643
+ yx: number;
644
+ yy: number;
645
+ tx: number;
646
+ ty: number;
647
+ /**
648
+ * Returns whether or not a matrix could be inverted, and if yes, sets the resulting Mat2D into
649
+ * the passed-in `mat` parameter
650
+ *
651
+ * @param mat - Reference Mat2D to store the newly inverted matrix into if successful
652
+ * @returns True if the matrix could be inverted
653
+ */
654
+ invert(mat: Mat2D): boolean;
655
+ }
656
+
657
+ /**
658
+ * Rive Vector class
659
+ */
660
+ export declare class Vec2D {
661
+ /**
662
+ * Returns the x coordinate of the vector
663
+ */
664
+ x(): void;
665
+ /**
666
+ * Returns the y coordinate of the vector
667
+ */
668
+ y(): void;
669
+ }