@rive-app/webgl2-threads 0.0.0-stage → 2.47.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/package.json +40 -3
- package/rive.d.ts +1608 -0
- package/rive.js +10770 -0
- package/rive.js.map +1 -0
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +1697 -0
- package/rive_fallback.wasm +0 -0
- package/rive_threads.wasm +0 -0
- package/runtimeLoader.d.ts +48 -0
- package/semantics/accessibilityOverlay.d.ts +272 -0
- package/semantics/claimedKeyEvents.d.ts +7 -0
- package/semantics/index.d.ts +5 -0
- package/semantics/semanticTreeModel.d.ts +66 -0
- package/semantics/types.d.ts +107 -0
- package/utils/canvasOffset.d.ts +8 -0
- package/utils/finalizationRegistry.d.ts +98 -0
- package/utils/index.d.ts +6 -0
- package/utils/keyMap.d.ts +141 -0
- package/utils/registerKeyboardInteractions.d.ts +174 -0
- package/utils/registerTouchInteractions.d.ts +25 -0
- package/utils/riveFont.d.ts +15 -0
- package/utils/sanitizeUrl.d.ts +2 -0
- package/utils/textInputProxy.d.ts +61 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1697 @@
|
|
|
1
|
+
// The high level wrappers by shape, since the advanced packages ship no utils.
|
|
2
|
+
interface ImageWrapper {
|
|
3
|
+
readonly nativeImage: ImageInternal;
|
|
4
|
+
unref(): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface AudioWrapper {
|
|
8
|
+
readonly nativeAudio: AudioInternal;
|
|
9
|
+
unref(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface FontWrapper {
|
|
13
|
+
readonly nativeFont: FontInternal;
|
|
14
|
+
unref(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RiveOptions {
|
|
18
|
+
locateFile(file: string): string;
|
|
19
|
+
wasmBinary?: ArrayBuffer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare function Rive(options?: RiveOptions): Promise<RiveCanvas>;
|
|
23
|
+
export default Rive;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* RiveCanvas is the main export object that contains references to different Rive classes to help
|
|
27
|
+
* build the Rive render loop for low-level API usage. In addition, this contains multiple methods
|
|
28
|
+
* that help aid in setup, such as loading in a Rive file, creating the renderer, and
|
|
29
|
+
* starting/finishing the render loop (requestAnimationFrame)
|
|
30
|
+
*/
|
|
31
|
+
export interface RiveCanvas {
|
|
32
|
+
Alignment: AlignmentFactory;
|
|
33
|
+
CanvasRenderer: typeof CanvasRenderer;
|
|
34
|
+
LinearAnimationInstance: typeof LinearAnimationInstance;
|
|
35
|
+
StateMachineInstance: typeof StateMachineInstance;
|
|
36
|
+
CustomFileAssetLoader: typeof CustomFileAssetLoader;
|
|
37
|
+
Mat2D: typeof Mat2D;
|
|
38
|
+
Vec2D: typeof Vec2D;
|
|
39
|
+
AABB: AABB;
|
|
40
|
+
SMIInput: typeof SMIInput;
|
|
41
|
+
renderFactory: CanvasRenderFactory;
|
|
42
|
+
|
|
43
|
+
BlendMode: typeof BlendMode;
|
|
44
|
+
FillRule: typeof FillRule;
|
|
45
|
+
Fit: typeof Fit;
|
|
46
|
+
RenderPaintStyle: typeof RenderPaintStyle;
|
|
47
|
+
StrokeCap: typeof StrokeCap;
|
|
48
|
+
StrokeJoin: typeof StrokeJoin;
|
|
49
|
+
decodeAudio: DecodeAudio;
|
|
50
|
+
decodeImage: DecodeImage;
|
|
51
|
+
decodeFont: DecodeFont;
|
|
52
|
+
// Returns a pointer value to the FontWrapper
|
|
53
|
+
setFallbackFontCallback: (callback: (missingGlyph: number, fallbackFontIndex: number, weight: number) => number | null) => void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @experimental Creates a deferred recording session. Only present in builds
|
|
57
|
+
* with deferred rendering compiled in, so always feature-detect it.
|
|
58
|
+
*
|
|
59
|
+
* The session is a Factory: pass it to `load()` and to the decode APIs of the
|
|
60
|
+
* assets that belong to that file, and attach it to exactly one renderer with
|
|
61
|
+
* `attachSession()`.
|
|
62
|
+
*
|
|
63
|
+
* Teardown order should be:
|
|
64
|
+
* 1. release the file the session imported,
|
|
65
|
+
* 2. `detachSession()` on the renderer it is attached to,
|
|
66
|
+
* 3. `delete()` the session.
|
|
67
|
+
* Deleting an attached session leaves the renderer pointing at freed memory
|
|
68
|
+
* on the canvas2d build — the next frame either draws from freed heap or
|
|
69
|
+
* throws `Cannot pass deleted object`. Detach first, always, even when the
|
|
70
|
+
* renderer is about to be deleted too.
|
|
71
|
+
*
|
|
72
|
+
* @returns A DeferredSession, or undefined if the session could not be created
|
|
73
|
+
*/
|
|
74
|
+
makeDeferredSession?(): DeferredSession | undefined;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Loads a Rive file for the runtime and returns a Rive-specific File class
|
|
78
|
+
*
|
|
79
|
+
* @param buffer - Array buffer of a Rive file
|
|
80
|
+
* @param assetLoader - FileAssetLoader used to optionally customize loading of font and image assets
|
|
81
|
+
* @param enableRiveAssetCDN - boolean flag to allow loading assets from the Rive CDN, enabled by default.
|
|
82
|
+
* @param session - @experimental Deferred session to import through. The file's mode is fixed
|
|
83
|
+
* at import: pass null (the default) for an immediate file.
|
|
84
|
+
* @returns A Promise for a Rive File class
|
|
85
|
+
*/
|
|
86
|
+
load(
|
|
87
|
+
buffer: Uint8Array,
|
|
88
|
+
assetLoader?: FileAssetLoader,
|
|
89
|
+
enableRiveAssetCDN?: boolean,
|
|
90
|
+
session?: DeferredSession | null,
|
|
91
|
+
): Promise<File>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Creates the renderer to draw the Rive on the provided canvas element
|
|
95
|
+
*
|
|
96
|
+
* @param canvas - Canvas to draw the Rive on
|
|
97
|
+
* @param useOffscreenRenderer - Option for those using the WebGL-variant of the Rive JS library.
|
|
98
|
+
* This uses an offscreen renderer to draw on the canvas, allowing for multiple Rives/canvases on
|
|
99
|
+
* a given screen. It is highly recommended to set this to `true` when using with the
|
|
100
|
+
* `@rive-app/webgl` package
|
|
101
|
+
* @param options - Renderer creation options
|
|
102
|
+
* @returns A Rive CanvasRenderer (Canvas2D) or Renderer (WebGL) class
|
|
103
|
+
*/
|
|
104
|
+
makeRenderer(
|
|
105
|
+
canvas: HTMLCanvasElement | OffscreenCanvas,
|
|
106
|
+
useOffscreenRenderer?: boolean,
|
|
107
|
+
options?: RendererOptions,
|
|
108
|
+
): WrappedRenderer;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Computes how the Rive is laid out onto the canvas
|
|
112
|
+
* @param {Fit} fit - Fit enum (i.e Fit.contain)
|
|
113
|
+
* @param alignment - Alignment enum (i.e Alignment.center)
|
|
114
|
+
* @param frame - AABB object representing the bounds of the canvas frame
|
|
115
|
+
* @param content - AABB object representing the bounds of what to draw the Rive onto
|
|
116
|
+
* (i.e an artboard's size)
|
|
117
|
+
* @param scaleFactor - Scale factor of the artboard when using `Fit.layout`
|
|
118
|
+
* @returns Mat2D - A Mat2D view matrix
|
|
119
|
+
*/
|
|
120
|
+
computeAlignment(
|
|
121
|
+
fit: Fit,
|
|
122
|
+
alignment: Alignment,
|
|
123
|
+
frame: AABB,
|
|
124
|
+
content: AABB,
|
|
125
|
+
scaleFactor?: number,
|
|
126
|
+
): Mat2D;
|
|
127
|
+
|
|
128
|
+
mapXY(matrix: Mat2D, canvasPoints: Vec2D): Vec2D;
|
|
129
|
+
/**
|
|
130
|
+
* A Rive-specific requestAnimationFrame function; this must be used instead of the global
|
|
131
|
+
* requestAnimationFrame function.
|
|
132
|
+
* @param cb - Callback function to call with an elapsed timestamp
|
|
133
|
+
* @returns number - An ID of the requestAnimationFrame request
|
|
134
|
+
*/
|
|
135
|
+
requestAnimationFrame(cb: (timestamp: DOMHighResTimeStamp) => void): number;
|
|
136
|
+
/**
|
|
137
|
+
* A Rive-specific cancelAnimationFrame function; this must be used instead of the global
|
|
138
|
+
* cancelAnimationFrame function.
|
|
139
|
+
* @param requestID - ID of the requestAnimationFrame request to cancel
|
|
140
|
+
*/
|
|
141
|
+
cancelAnimationFrame(requestID: number): void;
|
|
142
|
+
/**
|
|
143
|
+
* A Rive-specific function to "flush" queued up draw calls from using the renderer.
|
|
144
|
+
* It also ends the frame for scripts, which collect their memory then.
|
|
145
|
+
*
|
|
146
|
+
* This should only be invoked once at the end of a loop in a regular JS
|
|
147
|
+
* requestAnimationFrame loop, and should not be used with the Rive-wrapped
|
|
148
|
+
* requestAnimationFrame (aka, the requestAnimationFrame() API on this object) as that
|
|
149
|
+
* API will handle flushing the draw calls implicitly.
|
|
150
|
+
*/
|
|
151
|
+
resolveAnimationFrame(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Debugging tool to showcase the FPS in the corner of the screen in a new div. If a callback
|
|
154
|
+
* function is provided, this function passes the FPS count to the callback instead of creating a
|
|
155
|
+
* new div so the client can decide what to do with that data.
|
|
156
|
+
*/
|
|
157
|
+
enableFPSCounter(cb?: (fps: number) => void): void;
|
|
158
|
+
/**
|
|
159
|
+
* Debugging tool to remove the FPS counter that displays from enableFPSCounter
|
|
160
|
+
*/
|
|
161
|
+
disableFPSCounter(): void;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Cleans up any WASM-generate objects that need to be destroyed manually.
|
|
165
|
+
* This should be called when you wish to remove a rive animation from view.
|
|
166
|
+
*/
|
|
167
|
+
cleanup(): void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Returns whether or not there are Rive Listeners configured on a given StateMachineInstance
|
|
171
|
+
* @param stateMachine - StateMachineInstance to check for Listeners
|
|
172
|
+
* @returns bool - Boolean of if there are Listners on the state machine
|
|
173
|
+
*/
|
|
174
|
+
hasListeners(stateMachine: StateMachineInstance): boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//////////////
|
|
178
|
+
// RENDERER //
|
|
179
|
+
//////////////
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @experimental A deferred recording session, owned by the RiveFile that imported
|
|
183
|
+
* through it.
|
|
184
|
+
*
|
|
185
|
+
* A session records for one ore/GL context, so it binds to exactly one renderer
|
|
186
|
+
* and can never rebind once detached. It must outlive the file it imported.
|
|
187
|
+
*/
|
|
188
|
+
export declare class DeferredSession {
|
|
189
|
+
delete(): void;
|
|
190
|
+
/**
|
|
191
|
+
* @experimental Whether anything was recorded into this session's stream this
|
|
192
|
+
* frame, including ore content the artboard's own change flag cannot see.
|
|
193
|
+
* Only meaningful before the renderer clears: clear opens a recording window
|
|
194
|
+
* that marks the stream, so a later read reports every frame as recorded.
|
|
195
|
+
*/
|
|
196
|
+
recordedThisFrame(): boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface RendererOptions {
|
|
200
|
+
/**
|
|
201
|
+
* @experimental (WebGL2 only) Renders with inkbleed antialiasing instead of MSAA, which
|
|
202
|
+
* disables the canvas's native MSAA. Fills that don't use the clockwise fill rule are
|
|
203
|
+
* converted to clockwise on a best-effort basis
|
|
204
|
+
*/
|
|
205
|
+
inkbleed?: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Rive wrapper around a rendering context for a canvas element, implementing a subset of the APIs
|
|
210
|
+
* from the rendering context interface
|
|
211
|
+
*/
|
|
212
|
+
export declare class RendererWrapper {
|
|
213
|
+
/**
|
|
214
|
+
* Saves the state of the canvas and pushes it onto a stack
|
|
215
|
+
*
|
|
216
|
+
* For the underlying API, check
|
|
217
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
|
|
218
|
+
*/
|
|
219
|
+
save(): void;
|
|
220
|
+
/**
|
|
221
|
+
* Restores the most recent state of the canvas saved on the stack
|
|
222
|
+
*
|
|
223
|
+
* For the underlying API, check
|
|
224
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore
|
|
225
|
+
*/
|
|
226
|
+
restore(): void;
|
|
227
|
+
transform(tranform: Mat2D): void;
|
|
228
|
+
drawPath(path: RenderPath, paint: RenderPaint): void;
|
|
229
|
+
clipPath(path: RenderPath): void;
|
|
230
|
+
/**
|
|
231
|
+
* Begins a frame. Crucial to call this at the start of the render loop: besides clearing
|
|
232
|
+
* the canvas, it registers the renderer so that its queued draws actually get flushed.
|
|
233
|
+
*
|
|
234
|
+
* Pass clear=false to draw on top of whatever the canvas already holds instead of
|
|
235
|
+
* starting from a blank one.
|
|
236
|
+
*
|
|
237
|
+
* For the underlying clear, check
|
|
238
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect
|
|
239
|
+
*/
|
|
240
|
+
beginFrame(clear?: boolean): void;
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated Use {@link beginFrame} instead. Equivalent to `beginFrame(true)`.
|
|
243
|
+
*/
|
|
244
|
+
clear(): void;
|
|
245
|
+
delete(): void;
|
|
246
|
+
flush(): void;
|
|
247
|
+
translate(x: number, y: number): void;
|
|
248
|
+
rotate(angle: number): void;
|
|
249
|
+
/**
|
|
250
|
+
* (WebGL only) Makes the GL context that backs this renderer's textures current, before
|
|
251
|
+
* performing any WASM teardown that frees resources
|
|
252
|
+
*/
|
|
253
|
+
bindContext?(): void;
|
|
254
|
+
/**
|
|
255
|
+
* @experimental Binds a deferred session to this renderer's context: draws record
|
|
256
|
+
* into the session and replay at flush. Absent on renderers that cannot replay a
|
|
257
|
+
* session (an offscreen renderer, or a build without deferred support).
|
|
258
|
+
*
|
|
259
|
+
* @param session - The session the file was imported through
|
|
260
|
+
* @returns false if this renderer already has a session, or the session is (or was)
|
|
261
|
+
* bound elsewhere. Attaching is once per session: re-import into a fresh session instead
|
|
262
|
+
*/
|
|
263
|
+
attachSession?(session: DeferredSession): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* @experimental Releases the attached session's replay state. The session can never
|
|
266
|
+
* be attached again.
|
|
267
|
+
*/
|
|
268
|
+
detachSession?(): void;
|
|
269
|
+
/**
|
|
270
|
+
* @experimental Whether a deferred session is currently attached.
|
|
271
|
+
*/
|
|
272
|
+
deferredActive?(): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* @experimental (WebGL2 only) Toggles inkbleed antialiasing. Absent on renderers that
|
|
275
|
+
* cannot inkbleed (an offscreen renderer, or a non-WebGL2 build).
|
|
276
|
+
*
|
|
277
|
+
* @returns false if inkbleed was requested but the canvas context does not support it
|
|
278
|
+
*/
|
|
279
|
+
setInkbleed?(enabled: boolean): boolean;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export declare class RenderPathWrapper {
|
|
283
|
+
reset(): void;
|
|
284
|
+
addPath(
|
|
285
|
+
path: CommandPath,
|
|
286
|
+
xx: number,
|
|
287
|
+
xy: number,
|
|
288
|
+
yx: number,
|
|
289
|
+
yy: number,
|
|
290
|
+
tx: number,
|
|
291
|
+
ty: number,
|
|
292
|
+
): void;
|
|
293
|
+
fillRule(value: FillRule): void;
|
|
294
|
+
moveTo(x: number, y: number): void;
|
|
295
|
+
lineTo(x: number, y: number): void;
|
|
296
|
+
cubicTo(
|
|
297
|
+
ox: number,
|
|
298
|
+
oy: number,
|
|
299
|
+
ix: number,
|
|
300
|
+
iy: number,
|
|
301
|
+
x: number,
|
|
302
|
+
y: number,
|
|
303
|
+
): void;
|
|
304
|
+
close(): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export declare class RenderPaintWrapper {
|
|
308
|
+
color(value: number): void;
|
|
309
|
+
thickness(value: number): void;
|
|
310
|
+
join(value: StrokeJoin): void;
|
|
311
|
+
cap(value: StrokeCap): void;
|
|
312
|
+
blendMode(value: BlendMode): void;
|
|
313
|
+
style(value: RenderPaintStyle): void;
|
|
314
|
+
linearGradient(sx: number, sy: number, ex: number, ey: number): void;
|
|
315
|
+
radialGradient(sx: number, sy: number, ex: number, ey: number): void;
|
|
316
|
+
addStop(color: number, stop: number): void;
|
|
317
|
+
completeGradient(): void;
|
|
318
|
+
gradientTransform(
|
|
319
|
+
xx: number,
|
|
320
|
+
xy: number,
|
|
321
|
+
yx: number,
|
|
322
|
+
yy: number,
|
|
323
|
+
tx: number,
|
|
324
|
+
ty: number,
|
|
325
|
+
): void;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Renderer returned when Rive makes a renderer via `makeRenderer()`
|
|
330
|
+
*/
|
|
331
|
+
export declare class Renderer extends RendererWrapper {
|
|
332
|
+
/**
|
|
333
|
+
* Aligns the Rive content on the canvas space
|
|
334
|
+
* @param fit - Fit enum value
|
|
335
|
+
* @param alignment - Alignment enum value
|
|
336
|
+
* @param frame - Bounds of the canvas space
|
|
337
|
+
* @param content - Bounds of the Rive content
|
|
338
|
+
* @param _scaleFactor - Scale factor of the artboard when using `Fit.layout`
|
|
339
|
+
*/
|
|
340
|
+
align(
|
|
341
|
+
fit: Fit,
|
|
342
|
+
alignment: Alignment,
|
|
343
|
+
frame: AABB,
|
|
344
|
+
content: AABB,
|
|
345
|
+
scaleFactor?: number,
|
|
346
|
+
): void;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export declare class CommandPath { }
|
|
350
|
+
|
|
351
|
+
export declare class RenderPath extends RenderPathWrapper { }
|
|
352
|
+
|
|
353
|
+
export declare class RenderPaint extends RenderPaintWrapper { }
|
|
354
|
+
|
|
355
|
+
/////////////////////
|
|
356
|
+
// CANVAS RENDERER //
|
|
357
|
+
/////////////////////
|
|
358
|
+
export declare class CanvasRenderer extends Renderer {
|
|
359
|
+
constructor(
|
|
360
|
+
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
type OmittedCanvasRenderingContext2DMethods =
|
|
365
|
+
| "createConicGradient"
|
|
366
|
+
| "createImageData"
|
|
367
|
+
| "createLinearGradient"
|
|
368
|
+
| "createPattern"
|
|
369
|
+
| "createRadialGradient"
|
|
370
|
+
| "getContextAttributes"
|
|
371
|
+
| "getImageData"
|
|
372
|
+
| "getLineDash"
|
|
373
|
+
| "getTransform"
|
|
374
|
+
| "isContextLost"
|
|
375
|
+
| "isPointInPath"
|
|
376
|
+
| "isPointInStroke"
|
|
377
|
+
| "measureText";
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Proxy class that handles calls to a CanvasRenderer instance and handles Rive-related rendering calls such
|
|
381
|
+
* as `save`, `restore`, `transform`, and more, effectively overriding and/or wrapping Canvas2D context
|
|
382
|
+
* APIs for Rive-specific purposes. Other calls not intentionally overridden are passed through to the
|
|
383
|
+
* Canvas2D context directly.
|
|
384
|
+
*
|
|
385
|
+
* Note: Currently, any calls to the Canvas2D context that you expect to return a value (i.e. `isPointInStroke()`)
|
|
386
|
+
* will return undefined
|
|
387
|
+
*/
|
|
388
|
+
export type CanvasRendererProxy = CanvasRenderer &
|
|
389
|
+
Omit<CanvasRenderingContext2D, OmittedCanvasRenderingContext2DMethods>;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Renderer type for `makeRenderer()` that returns Renderer (webgl) or a CanvasRendererProxy (canvas2d)
|
|
393
|
+
*/
|
|
394
|
+
export type WrappedRenderer = Renderer | CanvasRendererProxy;
|
|
395
|
+
|
|
396
|
+
export declare class CanvasRenderPaint extends RenderPaint {
|
|
397
|
+
draw(
|
|
398
|
+
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
399
|
+
path: RenderPath,
|
|
400
|
+
): void;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export declare class CanvasRenderPath extends RenderPath { }
|
|
404
|
+
|
|
405
|
+
export interface CanvasRenderFactory {
|
|
406
|
+
makeRenderPaint(): CanvasRenderPaint;
|
|
407
|
+
makeRenderPath(): CanvasRenderPath;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export class AudioInternal {
|
|
411
|
+
unref(): void;
|
|
412
|
+
}
|
|
413
|
+
export class Audio {
|
|
414
|
+
unref(): void;
|
|
415
|
+
get nativeAudio(): AudioInternal;
|
|
416
|
+
}
|
|
417
|
+
export interface AudioCallback {
|
|
418
|
+
(audio: Audio): void;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The trailing session is the one of the deferred file the asset is bound into;
|
|
422
|
+
* an asset decoded against any other factory is dropped when that file draws.
|
|
423
|
+
*/
|
|
424
|
+
export interface DecodeAudio {
|
|
425
|
+
(
|
|
426
|
+
bytes: Uint8Array,
|
|
427
|
+
callback: AudioCallback,
|
|
428
|
+
session?: DeferredSession | null,
|
|
429
|
+
): void;
|
|
430
|
+
}
|
|
431
|
+
export class ImageInternal {
|
|
432
|
+
unref(): void;
|
|
433
|
+
}
|
|
434
|
+
export class Image {
|
|
435
|
+
unref(): void;
|
|
436
|
+
get nativeImage(): ImageInternal;
|
|
437
|
+
}
|
|
438
|
+
export interface ImageCallback {
|
|
439
|
+
(image: Image): void;
|
|
440
|
+
}
|
|
441
|
+
export interface DecodeImage {
|
|
442
|
+
(
|
|
443
|
+
bytes: Uint8Array,
|
|
444
|
+
callback: ImageCallback,
|
|
445
|
+
session?: DeferredSession | null,
|
|
446
|
+
): void;
|
|
447
|
+
}
|
|
448
|
+
export class FontInternal {
|
|
449
|
+
unref(): void;
|
|
450
|
+
ptr(): number;
|
|
451
|
+
}
|
|
452
|
+
export class Font {
|
|
453
|
+
unref(): void;
|
|
454
|
+
ptr(): number;
|
|
455
|
+
get nativeFont(): FontInternal;
|
|
456
|
+
}
|
|
457
|
+
export interface FontCallback {
|
|
458
|
+
(font: Font): void;
|
|
459
|
+
}
|
|
460
|
+
export interface DecodeFont {
|
|
461
|
+
(
|
|
462
|
+
bytes: Uint8Array,
|
|
463
|
+
callback: FontCallback,
|
|
464
|
+
session?: DeferredSession | null,
|
|
465
|
+
): void;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
//////////
|
|
469
|
+
// File //
|
|
470
|
+
//////////
|
|
471
|
+
/**
|
|
472
|
+
* Rive-specific File class that provides a number of functions to load instances of Artboards
|
|
473
|
+
*/
|
|
474
|
+
export declare class File {
|
|
475
|
+
/**
|
|
476
|
+
* Returns the first Artboard found in the Rive file as a new Artboard instance
|
|
477
|
+
* @returns An Artboard instance
|
|
478
|
+
*/
|
|
479
|
+
defaultArtboard(): Artboard; // rive::ArtboardInstance
|
|
480
|
+
/**
|
|
481
|
+
* Returns the named Artboard found in the Rive file as a new Artboard instance
|
|
482
|
+
* @param name - Name of the Artboard to create an instance for
|
|
483
|
+
*/
|
|
484
|
+
artboardByName(name: string): Artboard; // rive::ArtboardInstance
|
|
485
|
+
/**
|
|
486
|
+
* Returns a new Artboard instance for the Artboard at the given index in the Rive file
|
|
487
|
+
* @param index - Index of the Artboard in the file to create an Artboard instance for
|
|
488
|
+
*/
|
|
489
|
+
artboardByIndex(index: number): Artboard; // rive::ArtboardInstance
|
|
490
|
+
/**
|
|
491
|
+
* Returns the number of Artboards in the Rive File
|
|
492
|
+
* @returns Number of artboards in the Rive file
|
|
493
|
+
*/
|
|
494
|
+
artboardCount(): number;
|
|
495
|
+
/**
|
|
496
|
+
* Returns the number of View Models in the Rive File
|
|
497
|
+
* @returns Number of view models in the Rive file
|
|
498
|
+
*/
|
|
499
|
+
viewModelCount(): number;
|
|
500
|
+
/**
|
|
501
|
+
* Reports device pixels per layout point to scripts in this file
|
|
502
|
+
* @param scale - Device pixels per layout point
|
|
503
|
+
*/
|
|
504
|
+
displayScale(scale: number): void;
|
|
505
|
+
/**
|
|
506
|
+
* Returns a view model by the index in which it is located in the file
|
|
507
|
+
* @returns ViewModel
|
|
508
|
+
*/
|
|
509
|
+
viewModelByIndex(index: number): ViewModel;
|
|
510
|
+
/**
|
|
511
|
+
* Returns a view model by name
|
|
512
|
+
* @returns ViewModel
|
|
513
|
+
*/
|
|
514
|
+
viewModelByName(name: string): ViewModel;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Returns the default view model for the provided artboard
|
|
518
|
+
* @returns ViewModel
|
|
519
|
+
*/
|
|
520
|
+
defaultArtboardViewModel(artboard: Artboard): ViewModel;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Returns a list of all data enums
|
|
524
|
+
* @returns DataEnum array in the Rive file
|
|
525
|
+
*/
|
|
526
|
+
enums(): DataEnum[];
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Returns the names of the file's global view models, in file order.
|
|
530
|
+
* @returns array of global view model names
|
|
531
|
+
*/
|
|
532
|
+
globalViewModelNames(): string[];
|
|
533
|
+
|
|
534
|
+
unref(): void;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Returns a reference to a bindable artboard from this file by name
|
|
538
|
+
* @returns BindableArtboard
|
|
539
|
+
*/
|
|
540
|
+
bindableArtboardByName(name: string): BindableArtboard;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Returns a reference to the default bindable artboard
|
|
544
|
+
* @returns BindableArtboard
|
|
545
|
+
*/
|
|
546
|
+
bindableArtboardDefault(): BindableArtboard;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Returns a reference to a bindable artboard. FOR INTERNAL USE ONLY
|
|
550
|
+
* @param artboard - Name of the Artboard to create an instance for
|
|
551
|
+
* @returns BindableArtboard
|
|
552
|
+
*/
|
|
553
|
+
internalBindableArtboardFromArtboard(artboard: Artboard): BindableArtboard;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* If the file has an audio asset, returns true
|
|
557
|
+
*/
|
|
558
|
+
get hasAudio(): boolean;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Rive class representing an Artboard instance. Use this class to create instances for
|
|
563
|
+
* LinearAnimations, StateMachines, Nodes, Bones, and more. This Artboard instance should also be
|
|
564
|
+
* advanced in the drawing render loop.
|
|
565
|
+
*
|
|
566
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
567
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
568
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
569
|
+
* unmounted, etc.
|
|
570
|
+
*/
|
|
571
|
+
export declare class Artboard {
|
|
572
|
+
/**
|
|
573
|
+
* Get the name of this Artboard instance
|
|
574
|
+
*/
|
|
575
|
+
get name(): string;
|
|
576
|
+
/**
|
|
577
|
+
* Get the bounds of this Artboard instance
|
|
578
|
+
*/
|
|
579
|
+
get bounds(): AABB;
|
|
580
|
+
get hasAudio(): boolean;
|
|
581
|
+
get frameOrigin(): boolean;
|
|
582
|
+
set frameOrigin(val: boolean);
|
|
583
|
+
/**
|
|
584
|
+
* Getter and setter for the artboard volume
|
|
585
|
+
*/
|
|
586
|
+
get volume(): number;
|
|
587
|
+
set volume(val: number);
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Getter and setter for the artboard width
|
|
591
|
+
*/
|
|
592
|
+
get artboardWidth(): number;
|
|
593
|
+
set artboardWidth(val: number);
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Getter and setter for the artboard height
|
|
597
|
+
*/
|
|
598
|
+
get artboardHeight(): number;
|
|
599
|
+
set artboardHeight(val: number);
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Getter and setter used in rendering and canvas/artboard resizing
|
|
603
|
+
*/
|
|
604
|
+
get devicePixelRatioUsed(): number;
|
|
605
|
+
set devicePixelRatioUsed(val: number);
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Reset the artboard size to its original values
|
|
609
|
+
*/
|
|
610
|
+
resetArtboardSize(): void;
|
|
611
|
+
/**
|
|
612
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this
|
|
613
|
+
* instance when no longer in use
|
|
614
|
+
*/
|
|
615
|
+
delete(): void;
|
|
616
|
+
/**
|
|
617
|
+
* Advances the Artboard instance by the set amount of seconds. This method updates each object
|
|
618
|
+
* in the Artboard with any changes that animations apply on properties of the objects. This
|
|
619
|
+
* should be called after calling `advance()` of a LinearAnimationInstance or StateMachineInstance
|
|
620
|
+
* @param sec - Scrub the Artboard instance by a number of seconds
|
|
621
|
+
*/
|
|
622
|
+
advance(sec: number): boolean;
|
|
623
|
+
/**
|
|
624
|
+
* Draws the artboard with a given rendering context.
|
|
625
|
+
* @param renderer - Renderer context to draw with
|
|
626
|
+
*/
|
|
627
|
+
draw(renderer: CanvasRenderer | Renderer): void;
|
|
628
|
+
/**
|
|
629
|
+
* Creates a LinearAnimation for the animation with the given name
|
|
630
|
+
*
|
|
631
|
+
* Note: This does not create a LinearAnimationInstance to advance in the render loop.
|
|
632
|
+
* That needs to be created separately.
|
|
633
|
+
*
|
|
634
|
+
* @param name - Name of the animation to create a LinearAnimation reference for
|
|
635
|
+
* @returns A new LinearAnimation object
|
|
636
|
+
*/
|
|
637
|
+
animationByName(name: string): LinearAnimation;
|
|
638
|
+
/**
|
|
639
|
+
* Creates a LinearAnimation for the animation with the given index
|
|
640
|
+
*
|
|
641
|
+
* Note: This does not create a LinearAnimationInstance to advance in the render loop.
|
|
642
|
+
* That needs to be created separately.
|
|
643
|
+
*
|
|
644
|
+
* @param index - Index of the animation to create a LinearAnimation reference for
|
|
645
|
+
* @returns A new LinearAnimation object
|
|
646
|
+
*/
|
|
647
|
+
animationByIndex(index: number): LinearAnimation;
|
|
648
|
+
/**
|
|
649
|
+
* Returns the number of animations in the artboard
|
|
650
|
+
* @returns Number of animations on the Artboard
|
|
651
|
+
*/
|
|
652
|
+
animationCount(): number;
|
|
653
|
+
/**
|
|
654
|
+
* Creates a StateMachine for the state machine with the given name.
|
|
655
|
+
*
|
|
656
|
+
* Note: This does not create a StateMachineInstance to advance in the render loop.
|
|
657
|
+
* That needs to be created separately.
|
|
658
|
+
*
|
|
659
|
+
* @param name - Name of the state machine to create a StateMachine reference for
|
|
660
|
+
* @returns A new StateMachine object
|
|
661
|
+
*/
|
|
662
|
+
stateMachineByName(name: string): StateMachine;
|
|
663
|
+
/**
|
|
664
|
+
* Creates a StateMachine for the state machine with the given index
|
|
665
|
+
*
|
|
666
|
+
* Note: This does not create a StateMachineInstance to advance in the render loop.
|
|
667
|
+
* That needs to be created separately.
|
|
668
|
+
*
|
|
669
|
+
* @param index - Index of the state machine to create a StateMachine reference for
|
|
670
|
+
* @returns A new StateMachine object
|
|
671
|
+
*/
|
|
672
|
+
stateMachineByIndex(index: number): StateMachine;
|
|
673
|
+
/**
|
|
674
|
+
* Returns the number of state machines in the artboard
|
|
675
|
+
* @returns Number of state machines on the Artboard
|
|
676
|
+
*/
|
|
677
|
+
stateMachineCount(): number;
|
|
678
|
+
/**
|
|
679
|
+
* Returns a reference for a Bone object of a given name.
|
|
680
|
+
* Learn more: https://rive.app/community/doc/bones/docYyQwxrgI5
|
|
681
|
+
*
|
|
682
|
+
* @param name - Name of the Bone to grab a reference to
|
|
683
|
+
*/
|
|
684
|
+
bone(name: string): Bone;
|
|
685
|
+
/**
|
|
686
|
+
* Returns a reference for a Node object of a given name from the Artboard hierarchy
|
|
687
|
+
* @param name - Name of the Node from the Artboard hierarchy to grab a reference to
|
|
688
|
+
*/
|
|
689
|
+
node(name: string): Node;
|
|
690
|
+
/**
|
|
691
|
+
* Returns a reference for a root Bone object of a given name
|
|
692
|
+
* @param name - Name of the root Bone to grab a reference to
|
|
693
|
+
*/
|
|
694
|
+
rootBone(name: string): RootBone;
|
|
695
|
+
/**
|
|
696
|
+
* Returns a reference for a transform component object of a given name
|
|
697
|
+
* @param name - Name of the transform component to grab a reference to
|
|
698
|
+
*/
|
|
699
|
+
transformComponent(name: string): TransformComponent;
|
|
700
|
+
/**
|
|
701
|
+
* Returns a reference for a TextValueRun object to get/set a text value for
|
|
702
|
+
* @param name - Name of the Text Run to grab a reference to
|
|
703
|
+
*/
|
|
704
|
+
textRun(name: string): TextValueRun;
|
|
705
|
+
/**
|
|
706
|
+
* Returns a reference for a SMIInput object to get/set an input value for
|
|
707
|
+
* @param name - Name of the Input to grab a reference to
|
|
708
|
+
* @param path - Path of where the input exists at an artboard level
|
|
709
|
+
*/
|
|
710
|
+
inputByPath(name: string, path: string): SMIInput;
|
|
711
|
+
/**
|
|
712
|
+
* Returns a reference for a TextValueRun object to get/set a text value for
|
|
713
|
+
* @param name - Name of the Text Run to grab a reference to
|
|
714
|
+
* @param path - Path of where the text exists at an artboard level
|
|
715
|
+
*/
|
|
716
|
+
textByPath(name: string, path: string): TextValueRun;
|
|
717
|
+
/**
|
|
718
|
+
* Getter and setter for the artboard width
|
|
719
|
+
*/
|
|
720
|
+
get width(): number;
|
|
721
|
+
set width(val: number);
|
|
722
|
+
/**
|
|
723
|
+
* Getter and setter for the artboard height
|
|
724
|
+
*/
|
|
725
|
+
get height(): number;
|
|
726
|
+
set height(val: number);
|
|
727
|
+
/**
|
|
728
|
+
* Reset the artboard size to the original value
|
|
729
|
+
*/
|
|
730
|
+
resetArtboardSize(): void;
|
|
731
|
+
/**
|
|
732
|
+
* binds the view model instance to the artboard
|
|
733
|
+
* @param instance - Renderer context to draw with
|
|
734
|
+
*/
|
|
735
|
+
bindViewModelInstance(instance: ViewModelInstance): void;
|
|
736
|
+
/**
|
|
737
|
+
* Sets the main view model instance without rebinding. Call bind() to apply.
|
|
738
|
+
*/
|
|
739
|
+
setViewModelInstance(instance: ViewModelInstance): void;
|
|
740
|
+
/**
|
|
741
|
+
* Applies the current data context (rebinds data binds). No-op if nothing set.
|
|
742
|
+
*/
|
|
743
|
+
bind(): void;
|
|
744
|
+
/**
|
|
745
|
+
* Sets/replaces the global view model instance bound under the given global
|
|
746
|
+
* view model name without rebinding, preserving the main instance and the
|
|
747
|
+
* other globals' order. Call bind() to apply.
|
|
748
|
+
* @returns false if the name does not match a global view model in the file.
|
|
749
|
+
*/
|
|
750
|
+
setGlobalViewModelInstance(name: string, instance: ViewModelInstance): boolean;
|
|
751
|
+
/**
|
|
752
|
+
* @returns the global view model instance currently bound under the given
|
|
753
|
+
* name (the runtime-seeded default or a previously set instance), or null if
|
|
754
|
+
* the name does not match a global view model in the file.
|
|
755
|
+
*/
|
|
756
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
757
|
+
|
|
758
|
+
didChange(): boolean;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export declare class BindableArtboard {
|
|
762
|
+
unref(): void;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export declare class Bone extends TransformComponent {
|
|
766
|
+
/**
|
|
767
|
+
* Length of the bone
|
|
768
|
+
*/
|
|
769
|
+
length: number;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
export declare class RootBone extends Bone {
|
|
773
|
+
/**
|
|
774
|
+
* X coordinate of the position on the RootBone
|
|
775
|
+
*/
|
|
776
|
+
x: number;
|
|
777
|
+
/**
|
|
778
|
+
* Y coordinate of the position on the RootBone
|
|
779
|
+
*/
|
|
780
|
+
y: number;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Representation of a node in the Artboard hierarchy (i.e group, shape, etc.)
|
|
785
|
+
*/
|
|
786
|
+
export declare class Node extends TransformComponent {
|
|
787
|
+
/**
|
|
788
|
+
* X coordinate of the position on the Node
|
|
789
|
+
*/
|
|
790
|
+
x: number;
|
|
791
|
+
/**
|
|
792
|
+
* Y coordinate of the position on the RootBone
|
|
793
|
+
*/
|
|
794
|
+
y: number;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
export declare class TransformComponent {
|
|
798
|
+
rotation: number;
|
|
799
|
+
scaleX: number;
|
|
800
|
+
scaleY: number;
|
|
801
|
+
worldTransform(): Mat2D;
|
|
802
|
+
parentWorldTransform(result: Mat2D): void;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
///////////////
|
|
806
|
+
// Animation //
|
|
807
|
+
///////////////
|
|
808
|
+
/**
|
|
809
|
+
* Rive class representing a LinearAnimation instance. Use this class to advance and control a
|
|
810
|
+
* particular animation in the render loop (i.e speed, scrub, mix, etc.).
|
|
811
|
+
*
|
|
812
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
813
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
814
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
815
|
+
* unmounted, etc.
|
|
816
|
+
*/
|
|
817
|
+
export declare class LinearAnimationInstance {
|
|
818
|
+
/**
|
|
819
|
+
* Create a new LinearAnimationInstance reference
|
|
820
|
+
* @param animation - A LinearAnimation reference retrieved via the Artboard
|
|
821
|
+
* (i.e `artboard.animationByName('foo')`)
|
|
822
|
+
* @param artboard - The Artboard instance for this animation
|
|
823
|
+
*/
|
|
824
|
+
constructor(animation: LinearAnimation, artboard: Artboard);
|
|
825
|
+
get name(): string;
|
|
826
|
+
get duration(): number;
|
|
827
|
+
get fps(): number;
|
|
828
|
+
get workStart(): number;
|
|
829
|
+
get workEnd(): number;
|
|
830
|
+
get loopValue(): number;
|
|
831
|
+
get speed(): number;
|
|
832
|
+
/**
|
|
833
|
+
* Number of seconds the animation has advanced by
|
|
834
|
+
*/
|
|
835
|
+
time: number;
|
|
836
|
+
/**
|
|
837
|
+
* Flag to determine if the animation looped (this is reset when the loop restarts)
|
|
838
|
+
*/
|
|
839
|
+
didLoop: boolean;
|
|
840
|
+
/**
|
|
841
|
+
* Advances/scrubs the LinearAnimationInstance by the set amount of seconds. Note that this only
|
|
842
|
+
* moves the "time" in the animation, but does not apply changes to the properties in the
|
|
843
|
+
* Artboard. This must be called before the `apply()` method of LinearAnimationInstance.
|
|
844
|
+
*
|
|
845
|
+
* @param sec - Scrub the animation instance by a number of seconds
|
|
846
|
+
*/
|
|
847
|
+
advance(sec: number): boolean;
|
|
848
|
+
/**
|
|
849
|
+
* Apply a mixing value on the animation instance. This is useful if you are looking to blend
|
|
850
|
+
* multiple animations together and want to dictate a strength for each of the animations played
|
|
851
|
+
* back. This also applies new values to properties of objects on the Artboard according to the
|
|
852
|
+
* keys of the animation.
|
|
853
|
+
* This must be called after the `advance()` method of `LinearAnimationInstance`
|
|
854
|
+
*
|
|
855
|
+
* @param mix 0-1 the strength of the animation in the animations mix.
|
|
856
|
+
*/
|
|
857
|
+
apply(mix: number): void;
|
|
858
|
+
/**
|
|
859
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this instance
|
|
860
|
+
* when no longer in use
|
|
861
|
+
*/
|
|
862
|
+
delete(): void;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export declare class TextValueRun {
|
|
866
|
+
/**
|
|
867
|
+
* Getter for the name of the Text Run
|
|
868
|
+
*/
|
|
869
|
+
get name(): string;
|
|
870
|
+
/**
|
|
871
|
+
* Getter for text value of the Text Run
|
|
872
|
+
*/
|
|
873
|
+
get text(): string;
|
|
874
|
+
/**
|
|
875
|
+
* Setter for the text value of the Text Run
|
|
876
|
+
*/
|
|
877
|
+
set text(val: string);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Rive Event interface for "General" custom events defined in the Rive editor. Each event has a
|
|
882
|
+
* name and optionally some other custom properties and a type
|
|
883
|
+
*/
|
|
884
|
+
export interface RiveEvent {
|
|
885
|
+
/**
|
|
886
|
+
* Name of the event fired
|
|
887
|
+
*/
|
|
888
|
+
name: string;
|
|
889
|
+
/**
|
|
890
|
+
* Optional type of the specific kind of event fired (i.e. General, OpenUrl)
|
|
891
|
+
*/
|
|
892
|
+
type?: number;
|
|
893
|
+
/**
|
|
894
|
+
* Optional custom properties defined on the event
|
|
895
|
+
*/
|
|
896
|
+
properties?: RiveEventCustomProperties;
|
|
897
|
+
/**
|
|
898
|
+
* Optional elapsed time since the event specifically occurred
|
|
899
|
+
*/
|
|
900
|
+
delay?: number;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* A specific Rive Event type for "OpenUrl" events. This event type has a URL and optionally a
|
|
905
|
+
* target property to dictate how to open the URL
|
|
906
|
+
*/
|
|
907
|
+
export interface OpenUrlEvent extends RiveEvent {
|
|
908
|
+
/**
|
|
909
|
+
* URL to open when the event is invoked
|
|
910
|
+
*/
|
|
911
|
+
url: string;
|
|
912
|
+
/**
|
|
913
|
+
* Where to display the linked URL
|
|
914
|
+
*/
|
|
915
|
+
target?: string;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* A Rive Event may have any number of optional custom properties defined on itself with variable names
|
|
920
|
+
* and values that are either a number, boolean, or string
|
|
921
|
+
*/
|
|
922
|
+
export interface RiveEventCustomProperties {
|
|
923
|
+
/**
|
|
924
|
+
* Custom property may be named anything in the Rive editor, and given a value of
|
|
925
|
+
* a number, boolean, or string type
|
|
926
|
+
*/
|
|
927
|
+
[key: string]: number | boolean | string;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Snapshot of the focus state returned by StateMachineInstance.focusState().
|
|
932
|
+
* Poll this each frame after advanceAndApply() to detect focus changes and
|
|
933
|
+
* determine whether a virtual keyboard should be shown or hidden.
|
|
934
|
+
*/
|
|
935
|
+
export interface FocusState {
|
|
936
|
+
/** True if any element currently holds focus in this state machine's active focus manager. */
|
|
937
|
+
hasFocus: boolean;
|
|
938
|
+
/** True if the focused element accepts keyboard input (e.g. a TextInput node). */
|
|
939
|
+
expectsKeyboardInput: boolean;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
export declare class LinearAnimation {
|
|
943
|
+
/**
|
|
944
|
+
* The animation's loop type
|
|
945
|
+
*/
|
|
946
|
+
get loopValue(): number;
|
|
947
|
+
/**
|
|
948
|
+
* Name of the LinearAnimation
|
|
949
|
+
*/
|
|
950
|
+
get name(): string;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
export declare class StateMachine {
|
|
954
|
+
/**
|
|
955
|
+
* Name of the StateMachine
|
|
956
|
+
*/
|
|
957
|
+
get name(): string;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Rive class representing a StateMachine instance. Use this class to advance and control a
|
|
962
|
+
* particular state machine in the render loop (i.e scrub, grab state machine inputs, set up
|
|
963
|
+
* listener events, etc.).
|
|
964
|
+
*
|
|
965
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
966
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
967
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
968
|
+
* unmounted, etc.
|
|
969
|
+
*/
|
|
970
|
+
export declare class StateMachineInstance {
|
|
971
|
+
/**
|
|
972
|
+
* Create a new StateMachineInstance reference
|
|
973
|
+
* @param stateMachine - A StateMachine retrieved via the Artboard
|
|
974
|
+
* (i.e `artboard.stateMachineByName('foo')`)
|
|
975
|
+
* @param artboard - The Artboard instance for this state machine
|
|
976
|
+
*/
|
|
977
|
+
constructor(stateMachine: StateMachine, artboard: Artboard);
|
|
978
|
+
get name(): string;
|
|
979
|
+
/**
|
|
980
|
+
* Returns the number of inputs associated with this state machine
|
|
981
|
+
* @returns Number of inputs
|
|
982
|
+
*/
|
|
983
|
+
inputCount(): number;
|
|
984
|
+
/**
|
|
985
|
+
* Returns the state machine input at the given index
|
|
986
|
+
* @param i - Index to retrieve the state machine input at
|
|
987
|
+
* @returns SMIInput reference
|
|
988
|
+
*/
|
|
989
|
+
input(i: number): SMIInput;
|
|
990
|
+
/**
|
|
991
|
+
* Advances/scrubs the StateMachineInstance by the set amount of seconds. Note that this does not
|
|
992
|
+
* apply changes to the properties of objects in the Artboard yet.
|
|
993
|
+
* @param sec - Scrub the state machine instance by a number of seconds
|
|
994
|
+
*/
|
|
995
|
+
advance(sec: number): boolean;
|
|
996
|
+
/**
|
|
997
|
+
* Advances/scrubs the StateMachineInstance by the set amount of seconds. Note that this will
|
|
998
|
+
* apply changes to the properties of objects in the Artboard.
|
|
999
|
+
* @param sec - Scrub the state machine instance by a number of seconds
|
|
1000
|
+
*/
|
|
1001
|
+
advanceAndApply(sec: number): boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* Returns the number of states changed while the state machine played
|
|
1004
|
+
* @returns Number of states changed in the duration of the state machine played
|
|
1005
|
+
*/
|
|
1006
|
+
stateChangedCount(): number;
|
|
1007
|
+
/**
|
|
1008
|
+
* Returns the name of the state/animation transitioned to, given the index in the array of state
|
|
1009
|
+
* changes in total
|
|
1010
|
+
* @param i
|
|
1011
|
+
* @returns Name of the state/animation transitioned to
|
|
1012
|
+
*/
|
|
1013
|
+
stateChangedNameByIndex(i: number): string;
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Returns the number of events reported from the last advance call
|
|
1017
|
+
* @returns Number of events reported
|
|
1018
|
+
*/
|
|
1019
|
+
reportedEventCount(): number;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Returns a RiveEvent object emitted from the last advance call at the given index
|
|
1023
|
+
* of a list of potentially multiple events. If an event at the index is not found,
|
|
1024
|
+
* undefined is returned.
|
|
1025
|
+
* @param i index of the event reported in a list of potentially multiple events
|
|
1026
|
+
* @returns RiveEvent or extended RiveEvent object returned, or undefined
|
|
1027
|
+
*/
|
|
1028
|
+
reportedEventAt(i: number): OpenUrlEvent | RiveEvent | undefined;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Notifies the state machine that the pointer has pressed down at the given coordinate in
|
|
1032
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
1033
|
+
* interest at a given moment.
|
|
1034
|
+
*
|
|
1035
|
+
* @param x - X coordinate
|
|
1036
|
+
* @param y - Y coordinate
|
|
1037
|
+
*/
|
|
1038
|
+
pointerDown(x: number, y: number, id: number): void;
|
|
1039
|
+
/**
|
|
1040
|
+
* Notifies the state machine that the pointer has moved to the given coordinate in
|
|
1041
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
1042
|
+
* interest at a given moment.
|
|
1043
|
+
*
|
|
1044
|
+
* @param x - X coordinate
|
|
1045
|
+
* @param y - Y coordinate
|
|
1046
|
+
*/
|
|
1047
|
+
pointerMove(x: number, y: number, id: number): void;
|
|
1048
|
+
/**
|
|
1049
|
+
* Notifies the state machine that the pointer has released at the given coordinate in
|
|
1050
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
1051
|
+
* interest at a given moment.
|
|
1052
|
+
* @param x - X coordinate
|
|
1053
|
+
* @param y - Y coordinate
|
|
1054
|
+
*/
|
|
1055
|
+
pointerUp(x: number, y: number, id: number): void;
|
|
1056
|
+
/**
|
|
1057
|
+
* Notifies the state machine that the pointer has exited the detectable area of the canvas surface
|
|
1058
|
+
*
|
|
1059
|
+
* @param x - X coordinate
|
|
1060
|
+
* @param y - Y coordinate
|
|
1061
|
+
*/
|
|
1062
|
+
pointerExit(x: number, y: number, id: number): void;
|
|
1063
|
+
/**
|
|
1064
|
+
* Notifies the state machine of indirect scroll input (a mouse wheel, or a trackpad gesture the
|
|
1065
|
+
* platform already classified as a scroll) at the given coordinate in Artboard space. Direct
|
|
1066
|
+
* touch scrolling stays on the pointer path.
|
|
1067
|
+
*
|
|
1068
|
+
* A gesture latches to the scroll view that takes its first event and stays there, even past
|
|
1069
|
+
* that view's edge, until the gesture ends. A gesture with no end phase (a wheel) ends once the
|
|
1070
|
+
* state machine advances 0.1s without another scroll event.
|
|
1071
|
+
*
|
|
1072
|
+
* @param x - X coordinate
|
|
1073
|
+
* @param y - Y coordinate
|
|
1074
|
+
* @param dx - Horizontal distance the content moves, in Artboard pixels. Revealing content to
|
|
1075
|
+
* the right is negative, so a DOM wheel delta must be negated.
|
|
1076
|
+
* @param dy - Vertical distance the content moves, in Artboard pixels. Revealing content below
|
|
1077
|
+
* is negative.
|
|
1078
|
+
* @param phase - Where the event sits within its gesture: 0 begin, 1 update, 2 end,
|
|
1079
|
+
* 3 momentum, 4 inertiaCancel. A phaseless wheel only ever sends 1 (update).
|
|
1080
|
+
* @param precise - True for a pixel-precise source such as a trackpad, false for a detented
|
|
1081
|
+
* wheel.
|
|
1082
|
+
* @param timeStamp - Event time in seconds.
|
|
1083
|
+
* @param id - Pointer id
|
|
1084
|
+
* @returns 0 when nothing took the event, 1 when a scroll view did, 2 when an opaque scroll
|
|
1085
|
+
* view did.
|
|
1086
|
+
*/
|
|
1087
|
+
pointerScroll(
|
|
1088
|
+
x: number,
|
|
1089
|
+
y: number,
|
|
1090
|
+
dx: number,
|
|
1091
|
+
dy: number,
|
|
1092
|
+
phase: number,
|
|
1093
|
+
precise: boolean,
|
|
1094
|
+
timeStamp: number,
|
|
1095
|
+
id: number,
|
|
1096
|
+
): number;
|
|
1097
|
+
/**
|
|
1098
|
+
* Returns true if anything under the given Artboard coordinate would move for this scroll
|
|
1099
|
+
* event, without applying it. Always true while a gesture is latched.
|
|
1100
|
+
* See {@link pointerScroll} for the parameters.
|
|
1101
|
+
*/
|
|
1102
|
+
wantsScroll(
|
|
1103
|
+
x: number,
|
|
1104
|
+
y: number,
|
|
1105
|
+
dx: number,
|
|
1106
|
+
dy: number,
|
|
1107
|
+
phase: number,
|
|
1108
|
+
precise: boolean,
|
|
1109
|
+
): boolean;
|
|
1110
|
+
/**
|
|
1111
|
+
* Returns true if a wheel-enabled scroll view sits under the given Artboard coordinate, even
|
|
1112
|
+
* one that cannot move right now.
|
|
1113
|
+
*
|
|
1114
|
+
* @param x - X coordinate
|
|
1115
|
+
* @param y - Y coordinate
|
|
1116
|
+
*/
|
|
1117
|
+
hasScrollTargetAt(x: number, y: number): boolean;
|
|
1118
|
+
/**
|
|
1119
|
+
* Returns true while a scroll gesture is latched to a scroll view in this state machine or a
|
|
1120
|
+
* nested one.
|
|
1121
|
+
*/
|
|
1122
|
+
hasScrollLatch(): boolean;
|
|
1123
|
+
/**
|
|
1124
|
+
* Ends any scroll gesture in flight, latch included.
|
|
1125
|
+
*/
|
|
1126
|
+
cancelScroll(): void;
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Returns true if this state machine has any focus nodes registered in its focus tree.
|
|
1130
|
+
* Since the focus tree is unified across nested artboards, this covers the full scene.
|
|
1131
|
+
* Use this to gate whether tab/focus traversal DOM listeners should be attached.
|
|
1132
|
+
*/
|
|
1133
|
+
hasFocusNodes(): boolean;
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Move focus to the next focusable node in the focus tree via the state machine's focus manager.
|
|
1137
|
+
*/
|
|
1138
|
+
focusNext(): boolean;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Move focus to the previous focusable node in the focus tree via the state machine's focus manager.
|
|
1142
|
+
*/
|
|
1143
|
+
focusPrevious(): boolean;
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* Move focus to the nearest focusable node to the left of the current focus, by on-screen position.
|
|
1147
|
+
* @returns false if nothing is focused or no node lies in that direction
|
|
1148
|
+
*/
|
|
1149
|
+
focusLeft(): boolean;
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Move focus to the nearest focusable node to the right of the current focus, by on-screen position.
|
|
1153
|
+
* @returns false if nothing is focused or no node lies in that direction
|
|
1154
|
+
*/
|
|
1155
|
+
focusRight(): boolean;
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Move focus to the nearest focusable node above the current focus, by on-screen position.
|
|
1159
|
+
* @returns false if nothing is focused or no node lies in that direction
|
|
1160
|
+
*/
|
|
1161
|
+
focusUp(): boolean;
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Move focus to the nearest focusable node below the current focus, by on-screen position.
|
|
1165
|
+
* @returns false if nothing is focused or no node lies in that direction
|
|
1166
|
+
*/
|
|
1167
|
+
focusDown(): boolean;
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Clear focus from the Rive focus tree.
|
|
1171
|
+
*/
|
|
1172
|
+
clearFocus(): void;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Returns metadata about current focus state:
|
|
1176
|
+
* 1. Whether any node in the focus tree is currently focused
|
|
1177
|
+
* 2. Whether the currently focused node expects keyboard input (i.e. keyboard/text input listener)
|
|
1178
|
+
*/
|
|
1179
|
+
focusState(): FocusState;
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Forward a key press/release to the focus tree via the state machine's focus manager.
|
|
1183
|
+
* The event bubbles from the primary focus node up its ancestors until a handler consumes it.
|
|
1184
|
+
* Modifier keys are sent as keys too; held modifiers also go in the `modifiers` bitmask.
|
|
1185
|
+
* @param key - GLFW-style key code (see js/src/utils/keyMap.ts)
|
|
1186
|
+
* @param modifiers - KeyModifiers bitmask (shift=1, ctrl=2, alt=4, meta=8)
|
|
1187
|
+
* @param isPressed - true for keydown, false for keyup
|
|
1188
|
+
* @param isRepeat - true if this is an auto-repeat keydown
|
|
1189
|
+
* @returns true if a node in the focus chain consumed the event
|
|
1190
|
+
*/
|
|
1191
|
+
keyInput(key: number, modifiers: number, isPressed: boolean, isRepeat: boolean): boolean;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Forward committed text (a printable stroke, IME composition result, or paste) to the focus
|
|
1195
|
+
* tree. This is the only way characters get inserted into a focused text field; `keyInput`
|
|
1196
|
+
* never inserts text. For a printable stroke, hosts typically call both: `keyInput` so
|
|
1197
|
+
* keyboard listeners on that key fire, then `textInput` for the characters.
|
|
1198
|
+
* @param text - the committed text
|
|
1199
|
+
* @returns true if a node in the focus chain consumed the text
|
|
1200
|
+
*/
|
|
1201
|
+
textInput(text: string): boolean;
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* The selected text of the focused element, or an empty string when nothing with a
|
|
1205
|
+
* selection is focused. Used to fill the clipboard on copy/cut. An obscured field
|
|
1206
|
+
* (i.e. a password) reports empty string.
|
|
1207
|
+
*/
|
|
1208
|
+
selectedText(): string;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this instance
|
|
1212
|
+
* when no longer in use
|
|
1213
|
+
*/
|
|
1214
|
+
delete(): void;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* binds the view model instance to the state machine
|
|
1218
|
+
* @param instance - Renderer context to draw with
|
|
1219
|
+
*/
|
|
1220
|
+
bindViewModelInstance(instance: ViewModelInstance): void;
|
|
1221
|
+
/**
|
|
1222
|
+
* Sets the main view model instance without rebinding. Call bind() to apply.
|
|
1223
|
+
*/
|
|
1224
|
+
setViewModelInstance(instance: ViewModelInstance): void;
|
|
1225
|
+
/**
|
|
1226
|
+
* Applies the current data context (rebinds data binds). No-op if nothing set.
|
|
1227
|
+
*/
|
|
1228
|
+
bind(): void;
|
|
1229
|
+
/**
|
|
1230
|
+
* Sets/replaces the global view model instance bound under the given global
|
|
1231
|
+
* view model name without rebinding, preserving the main instance and the
|
|
1232
|
+
* other globals' order. Call bind() to apply.
|
|
1233
|
+
* @returns false if the name does not match a global view model in the file.
|
|
1234
|
+
*/
|
|
1235
|
+
setGlobalViewModelInstance(name: string, instance: ViewModelInstance): boolean;
|
|
1236
|
+
/**
|
|
1237
|
+
* @returns the global view model instance currently bound under the given
|
|
1238
|
+
* name (the runtime-seeded default or a previously set instance), or null if
|
|
1239
|
+
* the name does not match a global view model in the file.
|
|
1240
|
+
*/
|
|
1241
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Enables semantic tree tracking for this state machine instance.
|
|
1245
|
+
* Once enabled, the runtime builds and maintains a semantic tree that
|
|
1246
|
+
* describes the accessible structure of the artboard (roles, labels,
|
|
1247
|
+
* states, bounds). Call this before using drainSemanticsDiff().
|
|
1248
|
+
*/
|
|
1249
|
+
enableSemantics(): void;
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* Returns the incremental semantic diff since the last call, or null if
|
|
1253
|
+
* nothing changed. Each diff contains arrays of added/removed/moved nodes,
|
|
1254
|
+
* updated semantic properties, updated geometry, and children reorderings.
|
|
1255
|
+
*/
|
|
1256
|
+
drainSemanticsDiff(): SemanticsDiff | null;
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Fire a semantic action on the node with the given ID.
|
|
1260
|
+
* @param nodeId - The semantic node ID to target
|
|
1261
|
+
* @param actionType - 0 = tap, 1 = increase, 2 = decrease
|
|
1262
|
+
*/
|
|
1263
|
+
fireSemanticAction(nodeId: number, actionType: number): void;
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Request focus on the semantic node with the given ID.
|
|
1267
|
+
* Routes through SemanticManager to focus the FocusData sibling of the
|
|
1268
|
+
* SemanticData that owns the node. Returns true if focus was set.
|
|
1269
|
+
* @param nodeId - The semantic node ID to focus
|
|
1270
|
+
* @returns boolean - True if focus was set, false otherwise
|
|
1271
|
+
*/
|
|
1272
|
+
focusSemanticNode(nodeId: number): boolean;
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Clears focus from the currently focused node in the focus tree.
|
|
1276
|
+
*/
|
|
1277
|
+
clearFocus(): void;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
export interface SemanticsDiffNode {
|
|
1281
|
+
id: number;
|
|
1282
|
+
role: number;
|
|
1283
|
+
label: string;
|
|
1284
|
+
value: string;
|
|
1285
|
+
hint: string;
|
|
1286
|
+
stateFlags: number;
|
|
1287
|
+
traitFlags: number;
|
|
1288
|
+
headingLevel: number;
|
|
1289
|
+
minX: number;
|
|
1290
|
+
minY: number;
|
|
1291
|
+
maxX: number;
|
|
1292
|
+
maxY: number;
|
|
1293
|
+
parentId: number;
|
|
1294
|
+
siblingIndex: number;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
export interface SemanticsBoundsUpdate {
|
|
1298
|
+
id: number;
|
|
1299
|
+
minX: number;
|
|
1300
|
+
minY: number;
|
|
1301
|
+
maxX: number;
|
|
1302
|
+
maxY: number;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
export interface SemanticsChildrenUpdate {
|
|
1306
|
+
parentId: number;
|
|
1307
|
+
childIds: number[];
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
export interface SemanticsDiff {
|
|
1311
|
+
frameNumber: number;
|
|
1312
|
+
treeVersion: number;
|
|
1313
|
+
rootId: number;
|
|
1314
|
+
removed: number[];
|
|
1315
|
+
added: SemanticsDiffNode[];
|
|
1316
|
+
moved: SemanticsDiffNode[];
|
|
1317
|
+
childrenUpdated: SemanticsChildrenUpdate[];
|
|
1318
|
+
updatedSemantic: SemanticsDiffNode[];
|
|
1319
|
+
updatedGeometry: SemanticsBoundsUpdate[];
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
export declare class SMIInput {
|
|
1323
|
+
// TODO: Keep only the base SMIInput properties and make SMIBool, SMINumber, SMITriger extend it
|
|
1324
|
+
static bool: number;
|
|
1325
|
+
static number: number;
|
|
1326
|
+
static trigger: number;
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* Getter for name of the state machine input
|
|
1330
|
+
*/
|
|
1331
|
+
get name(): string;
|
|
1332
|
+
get type(): number;
|
|
1333
|
+
/**
|
|
1334
|
+
* Getter for value of the state machine input
|
|
1335
|
+
*/
|
|
1336
|
+
get value(): boolean | number | undefined;
|
|
1337
|
+
/**
|
|
1338
|
+
* Setter for value of the state machine input
|
|
1339
|
+
*/
|
|
1340
|
+
set value(val: boolean | number | undefined);
|
|
1341
|
+
/**
|
|
1342
|
+
* Fires a trigger input on a state machine
|
|
1343
|
+
*/
|
|
1344
|
+
fire(): void;
|
|
1345
|
+
asBool(): SMIInput;
|
|
1346
|
+
asNumber(): SMIInput;
|
|
1347
|
+
asTrigger(): SMIInput;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
export declare type ViewModelProperty = {
|
|
1351
|
+
name: string;
|
|
1352
|
+
type: DataType;
|
|
1353
|
+
enumName?: string;
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
export declare class ViewModelInstanceValue {
|
|
1357
|
+
get hasChanged(): boolean;
|
|
1358
|
+
clearChanges(): void;
|
|
1359
|
+
get name(): string;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
export declare class ViewModelInstanceNumber extends ViewModelInstanceValue {
|
|
1363
|
+
get value(): number;
|
|
1364
|
+
set value(val: number);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
export declare class ViewModelInstanceTrigger extends ViewModelInstanceValue {
|
|
1368
|
+
trigger(): void;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
export declare class ViewModelInstanceString extends ViewModelInstanceValue {
|
|
1372
|
+
get value(): string;
|
|
1373
|
+
set value(val: string);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
export declare class ViewModelInstanceBoolean extends ViewModelInstanceValue {
|
|
1377
|
+
get value(): boolean;
|
|
1378
|
+
set value(val: boolean);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
|
|
1382
|
+
get value(): number;
|
|
1383
|
+
set value(val: number);
|
|
1384
|
+
rgb(r: number, g: number, b: number): void;
|
|
1385
|
+
argb(a: number, r: number, g: number, b: number): void;
|
|
1386
|
+
alpha(a: number): void;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
export declare class ViewModelInstanceEnum extends ViewModelInstanceValue {
|
|
1390
|
+
get value(): string;
|
|
1391
|
+
set value(val: string);
|
|
1392
|
+
get valueIndex(): number;
|
|
1393
|
+
set valueIndex(val: number);
|
|
1394
|
+
get values(): string[];
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
export declare class ViewModelInstanceList extends ViewModelInstanceValue {
|
|
1398
|
+
get size(): number;
|
|
1399
|
+
addInstance(vmi: ViewModelInstance): void;
|
|
1400
|
+
addInstanceAt(vmi: ViewModelInstance, index: number): boolean;
|
|
1401
|
+
removeInstance(vmi: ViewModelInstance): void;
|
|
1402
|
+
removeInstanceAt(index: number): void;
|
|
1403
|
+
instanceAt(index: number): ViewModelInstance;
|
|
1404
|
+
swap(a: number, b: number): ViewModelInstance;
|
|
1405
|
+
}
|
|
1406
|
+
export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
|
|
1407
|
+
value(image: ImageInternal | null): void;
|
|
1408
|
+
}
|
|
1409
|
+
export declare class ViewModelInstanceAssetFont extends ViewModelInstanceValue {
|
|
1410
|
+
value(font: FontInternal | null): void;
|
|
1411
|
+
}
|
|
1412
|
+
export declare class ViewModelInstanceArtboard extends ViewModelInstanceValue {
|
|
1413
|
+
value(artboard: BindableArtboard | Artboard): void;
|
|
1414
|
+
viewModelInstance(viewModelInstance: ViewModelInstance): void;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
export declare class ViewModelInstance {
|
|
1418
|
+
get propertyCount(): number;
|
|
1419
|
+
number(path: string): ViewModelInstanceNumber;
|
|
1420
|
+
string(path: string): ViewModelInstanceString;
|
|
1421
|
+
boolean(path: string): ViewModelInstanceBoolean;
|
|
1422
|
+
color(path: string): ViewModelInstanceColor;
|
|
1423
|
+
enum(path: string): ViewModelInstanceEnum;
|
|
1424
|
+
trigger(path: string): ViewModelInstanceTrigger;
|
|
1425
|
+
list(path: string): ViewModelInstanceList;
|
|
1426
|
+
viewModel(path: string): ViewModelInstance;
|
|
1427
|
+
image(path: string): ViewModelInstanceAssetImage;
|
|
1428
|
+
font(path: string): ViewModelInstanceAssetFont;
|
|
1429
|
+
artboard(path: string): ViewModelInstanceArtboard;
|
|
1430
|
+
replaceViewModel(path: string, value: ViewModelInstance): boolean;
|
|
1431
|
+
incrementReferenceCount(): void;
|
|
1432
|
+
decrementReferenceCount(): void;
|
|
1433
|
+
delete(): void;
|
|
1434
|
+
unref(): void;
|
|
1435
|
+
getProperties(): ViewModelProperty[];
|
|
1436
|
+
getViewModelName(): string;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
export declare class ViewModel {
|
|
1440
|
+
get instanceCount(): number;
|
|
1441
|
+
instanceByIndex(index: number): ViewModelInstance;
|
|
1442
|
+
instanceByName(name: string): ViewModelInstance;
|
|
1443
|
+
defaultInstance(): ViewModelInstance;
|
|
1444
|
+
instance(): ViewModelInstance;
|
|
1445
|
+
getProperties(): ViewModelProperty[];
|
|
1446
|
+
getInstanceNames(): string[];
|
|
1447
|
+
get propertyCount(): number;
|
|
1448
|
+
get name(): string;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
export declare class DataEnum {
|
|
1452
|
+
get name(): string;
|
|
1453
|
+
get values(): string[];
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
export declare class SMIBool { }
|
|
1457
|
+
|
|
1458
|
+
export declare class SMINumber { }
|
|
1459
|
+
|
|
1460
|
+
export declare class SMITrigger { }
|
|
1461
|
+
|
|
1462
|
+
///////////
|
|
1463
|
+
// ENUMS //
|
|
1464
|
+
///////////
|
|
1465
|
+
|
|
1466
|
+
export enum DataType {
|
|
1467
|
+
none = 'none',
|
|
1468
|
+
string = 'string',
|
|
1469
|
+
number = 'number',
|
|
1470
|
+
boolean = 'boolean',
|
|
1471
|
+
color = 'color',
|
|
1472
|
+
list = 'list',
|
|
1473
|
+
enumType = 'enumType',
|
|
1474
|
+
trigger = 'trigger',
|
|
1475
|
+
viewModel = 'viewModel',
|
|
1476
|
+
integer = 'integer',
|
|
1477
|
+
listIndex = 'listIndex',
|
|
1478
|
+
image = 'image',
|
|
1479
|
+
artboard = 'artboard',
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
export enum Fit {
|
|
1483
|
+
fill,
|
|
1484
|
+
contain,
|
|
1485
|
+
cover,
|
|
1486
|
+
fitWidth,
|
|
1487
|
+
fitHeight,
|
|
1488
|
+
none,
|
|
1489
|
+
scaleDown,
|
|
1490
|
+
layout,
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
export enum RenderPaintStyle {
|
|
1494
|
+
fill,
|
|
1495
|
+
stroke,
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
export enum FillRule {
|
|
1499
|
+
nonZero,
|
|
1500
|
+
evenOdd,
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
export enum StrokeCap {
|
|
1504
|
+
butt,
|
|
1505
|
+
round,
|
|
1506
|
+
square,
|
|
1507
|
+
}
|
|
1508
|
+
export enum StrokeJoin {
|
|
1509
|
+
miter,
|
|
1510
|
+
round,
|
|
1511
|
+
bevel,
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
export enum BlendMode {
|
|
1515
|
+
srcOver = 3,
|
|
1516
|
+
additive = 12,
|
|
1517
|
+
screen = 14,
|
|
1518
|
+
overlay = 15,
|
|
1519
|
+
darken = 16,
|
|
1520
|
+
lighten = 17,
|
|
1521
|
+
colorDodge = 18,
|
|
1522
|
+
colorBurn = 19,
|
|
1523
|
+
hardLight = 20,
|
|
1524
|
+
softLight = 21,
|
|
1525
|
+
difference = 22,
|
|
1526
|
+
exclusion = 23,
|
|
1527
|
+
multiply = 24,
|
|
1528
|
+
hue = 25,
|
|
1529
|
+
saturation = 26,
|
|
1530
|
+
color = 27,
|
|
1531
|
+
luminosity = 28,
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
///////////
|
|
1535
|
+
// UTILS //
|
|
1536
|
+
///////////
|
|
1537
|
+
|
|
1538
|
+
export declare class Alignment {
|
|
1539
|
+
get x(): number;
|
|
1540
|
+
get y(): number;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
export declare class AlignmentFactory {
|
|
1544
|
+
get topLeft(): Alignment;
|
|
1545
|
+
get topCenter(): Alignment;
|
|
1546
|
+
get topRight(): Alignment;
|
|
1547
|
+
get centerLeft(): Alignment;
|
|
1548
|
+
get center(): Alignment;
|
|
1549
|
+
get centerRight(): Alignment;
|
|
1550
|
+
get bottomLeft(): Alignment;
|
|
1551
|
+
get bottomCenter(): Alignment;
|
|
1552
|
+
get bottomRight(): Alignment;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Axis-aligned bounding box
|
|
1557
|
+
*/
|
|
1558
|
+
export interface AABB {
|
|
1559
|
+
minX: number;
|
|
1560
|
+
minY: number;
|
|
1561
|
+
maxX: number;
|
|
1562
|
+
maxY: number;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* Column-major matrix described by the following:
|
|
1567
|
+
* | xx yx tx |
|
|
1568
|
+
* | xy yy ty |
|
|
1569
|
+
* | 0 0 1 |
|
|
1570
|
+
*/
|
|
1571
|
+
export declare class Mat2D {
|
|
1572
|
+
xx: number;
|
|
1573
|
+
xy: number;
|
|
1574
|
+
yx: number;
|
|
1575
|
+
yy: number;
|
|
1576
|
+
tx: number;
|
|
1577
|
+
ty: number;
|
|
1578
|
+
/**
|
|
1579
|
+
* Returns whether or not a matrix could be inverted, and if yes, sets the resulting Mat2D into
|
|
1580
|
+
* the passed-in `mat` parameter
|
|
1581
|
+
*
|
|
1582
|
+
* @param mat - Reference Mat2D to store the newly inverted matrix into if successful
|
|
1583
|
+
* @returns True if the matrix could be inverted
|
|
1584
|
+
*/
|
|
1585
|
+
invert(mat: Mat2D): boolean;
|
|
1586
|
+
|
|
1587
|
+
/**
|
|
1588
|
+
* Deletes the underlying CPP object created for this instance
|
|
1589
|
+
*/
|
|
1590
|
+
delete(): void;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Rive Vector class
|
|
1595
|
+
*/
|
|
1596
|
+
export declare class Vec2D {
|
|
1597
|
+
constructor(x: number, y: number);
|
|
1598
|
+
/**
|
|
1599
|
+
* Returns the x coordinate of the vector
|
|
1600
|
+
*/
|
|
1601
|
+
x(): number;
|
|
1602
|
+
/**
|
|
1603
|
+
* Returns the y coordinate of the vector
|
|
1604
|
+
*/
|
|
1605
|
+
y(): number;
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Deletes the underlying CPP object created for this instance
|
|
1609
|
+
*/
|
|
1610
|
+
delete(): void;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Rive class representing a FileAsset with relevant metadata fields to describe
|
|
1615
|
+
* an asset associated wtih the Rive File
|
|
1616
|
+
*/
|
|
1617
|
+
export declare class FileAsset {
|
|
1618
|
+
name: string;
|
|
1619
|
+
fileExtension: string;
|
|
1620
|
+
uniqueFilename: string;
|
|
1621
|
+
isAudio: boolean;
|
|
1622
|
+
isImage: boolean;
|
|
1623
|
+
isFont: boolean;
|
|
1624
|
+
cdnUuid: string;
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* @param session - @experimental The session of the deferred file this asset belongs
|
|
1628
|
+
* to, null for an immediate file. Wired by the runtime; pass it explicitly only when
|
|
1629
|
+
* calling the native asset directly.
|
|
1630
|
+
*/
|
|
1631
|
+
decode(bytes: Uint8Array, session?: DeferredSession | null): void;
|
|
1632
|
+
get nativeAsset(): FileAssetInternal;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Rive class representing a FileAsset with relevant metadata fields to describe
|
|
1637
|
+
* an asset associated wtih the Rive File
|
|
1638
|
+
*/
|
|
1639
|
+
export declare class FileAssetInternal {
|
|
1640
|
+
name: string;
|
|
1641
|
+
fileExtension: string;
|
|
1642
|
+
uniqueFilename: string;
|
|
1643
|
+
isAudio: boolean;
|
|
1644
|
+
isImage: boolean;
|
|
1645
|
+
isFont: boolean;
|
|
1646
|
+
cdnUuid: string;
|
|
1647
|
+
|
|
1648
|
+
decode(bytes: Uint8Array, session?: DeferredSession | null): void;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
export declare class AudioAssetInternal extends FileAssetInternal {
|
|
1652
|
+
setAudioSource(audio: AudioInternal): void;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Rive class extending the FileAsset that exposes a `setAudioSource()` API with a
|
|
1657
|
+
* decoded Audio (via the `decodeAudio()` API) to set a new Audio on the Rive FileAsset
|
|
1658
|
+
*/
|
|
1659
|
+
export declare class AudioAsset extends FileAsset {
|
|
1660
|
+
setAudioSource(audio: Audio | AudioWrapper): void;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
export declare class ImageAssetInternal extends FileAssetInternal {
|
|
1664
|
+
setRenderImage(image: ImageInternal): void;
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Rive class extending the FileAsset that exposes a `setRenderImage()` API with a
|
|
1668
|
+
* decoded Image (via the `decodeImage()` API) to set a new Image on the Rive FileAsset
|
|
1669
|
+
*/
|
|
1670
|
+
export declare class ImageAsset extends FileAsset {
|
|
1671
|
+
setRenderImage(image: Image | ImageWrapper): void;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
export declare class FontAssetInternal extends FileAssetInternal {
|
|
1675
|
+
setFont(font: FontInternal): void;
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Rive class extending the FileAsset that exposes a `setFont()` API with a
|
|
1679
|
+
* decoded Font (via the `decodeFont()` API) to set a new Font on the Rive FileAsset
|
|
1680
|
+
*/
|
|
1681
|
+
export declare class FontAsset extends FileAsset {
|
|
1682
|
+
// Accepts the high-level `FontWrapper` returned by `decodeFont()` as well as
|
|
1683
|
+
// the low-level embind `Font`. `FontWrapper` lacks the `ptr()` member that was
|
|
1684
|
+
// added to `Font`
|
|
1685
|
+
setFont(font: Font | FontWrapper): void;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
export declare class FileAssetLoader { }
|
|
1689
|
+
|
|
1690
|
+
export declare class CustomFileAssetLoader extends FileAssetLoader {
|
|
1691
|
+
constructor({ loadContents }: { loadContents: Function });
|
|
1692
|
+
loadContents(asset: FileAsset, bytes: any): boolean;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
export interface FinalizableTarget {
|
|
1696
|
+
selfUnref: boolean;
|
|
1697
|
+
}
|