@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
package/rive.d.ts
ADDED
|
@@ -0,0 +1,1608 @@
|
|
|
1
|
+
import * as rc from "./rive_advanced.mjs";
|
|
2
|
+
import { RuntimeLoader, type RuntimeCallback } from "./runtimeLoader";
|
|
3
|
+
import { SemanticTreeModel, AccessibilityOverlay, SemanticMode, type RiveSemanticsOptions } from "./semantics";
|
|
4
|
+
import { ImageWrapper, AudioWrapper, FontWrapper, RiveFont as RiveFontClassUtil } from "./utils";
|
|
5
|
+
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => boolean;
|
|
6
|
+
export { RiveFontClassUtil as RiveFont };
|
|
7
|
+
export { SemanticMode };
|
|
8
|
+
export type { RiveSemanticsOptions };
|
|
9
|
+
export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* Generic type for a parameterless void callback
|
|
12
|
+
*/
|
|
13
|
+
export type VoidCallback = () => void;
|
|
14
|
+
interface SetupRiveListenersOptions {
|
|
15
|
+
isTouchScrollEnabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type for artboard bounds
|
|
19
|
+
*/
|
|
20
|
+
export type Bounds = rc.AABB;
|
|
21
|
+
export declare enum Fit {
|
|
22
|
+
Cover = "cover",
|
|
23
|
+
Contain = "contain",
|
|
24
|
+
Fill = "fill",
|
|
25
|
+
FitWidth = "fitWidth",
|
|
26
|
+
FitHeight = "fitHeight",
|
|
27
|
+
None = "none",
|
|
28
|
+
ScaleDown = "scaleDown",
|
|
29
|
+
Layout = "layout"
|
|
30
|
+
}
|
|
31
|
+
export declare enum Alignment {
|
|
32
|
+
Center = "center",
|
|
33
|
+
TopLeft = "topLeft",
|
|
34
|
+
TopCenter = "topCenter",
|
|
35
|
+
TopRight = "topRight",
|
|
36
|
+
CenterLeft = "centerLeft",
|
|
37
|
+
CenterRight = "centerRight",
|
|
38
|
+
BottomLeft = "bottomLeft",
|
|
39
|
+
BottomCenter = "bottomCenter",
|
|
40
|
+
BottomRight = "bottomRight"
|
|
41
|
+
}
|
|
42
|
+
export declare enum DrawOptimizationOptions {
|
|
43
|
+
AlwaysDraw = "alwaysDraw",
|
|
44
|
+
DrawOnChanged = "drawOnChanged"
|
|
45
|
+
}
|
|
46
|
+
export interface RiveFocusOptions {
|
|
47
|
+
/**
|
|
48
|
+
* When true, allows Rive to interrupt browser focus and programmatically
|
|
49
|
+
* set/release focus on the canvas when the state machine reports focus
|
|
50
|
+
* changes in Rive. This allows apps to direct focus to/from the canvas or
|
|
51
|
+
* related elements as needed if not currently focused, which can happen at
|
|
52
|
+
* any point in the Rive render loop.
|
|
53
|
+
*
|
|
54
|
+
* Note: Nodes in the Rive graphic may still receive/release focus respecting
|
|
55
|
+
* any focus rules defined in the state machine.
|
|
56
|
+
*
|
|
57
|
+
* @default false to prevent unwanted focus interruptions
|
|
58
|
+
*/
|
|
59
|
+
allowFocusInterrupt: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface LayoutParameters {
|
|
62
|
+
fit?: Fit;
|
|
63
|
+
alignment?: Alignment;
|
|
64
|
+
layoutScaleFactor?: number;
|
|
65
|
+
minX?: number;
|
|
66
|
+
minY?: number;
|
|
67
|
+
maxX?: number;
|
|
68
|
+
maxY?: number;
|
|
69
|
+
}
|
|
70
|
+
export declare class Layout {
|
|
71
|
+
private cachedRuntimeFit;
|
|
72
|
+
private cachedRuntimeAlignment;
|
|
73
|
+
readonly fit: Fit;
|
|
74
|
+
readonly alignment: Alignment;
|
|
75
|
+
readonly layoutScaleFactor: number;
|
|
76
|
+
readonly minX: number;
|
|
77
|
+
readonly minY: number;
|
|
78
|
+
readonly maxX: number;
|
|
79
|
+
readonly maxY: number;
|
|
80
|
+
constructor(params?: LayoutParameters);
|
|
81
|
+
static new({ fit, alignment, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
|
|
82
|
+
/**
|
|
83
|
+
* Makes a copy of the layout, replacing any specified parameters
|
|
84
|
+
*/
|
|
85
|
+
copyWith({ fit, alignment, layoutScaleFactor, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
|
|
86
|
+
runtimeFit(rive: rc.RiveCanvas): rc.Fit;
|
|
87
|
+
runtimeAlignment(rive: rc.RiveCanvas): rc.Alignment;
|
|
88
|
+
}
|
|
89
|
+
export { RuntimeLoader, type RuntimeCallback };
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated State machine inputs are deprecated and will be removed in a
|
|
92
|
+
* future major version: please use data binding properties instead. See
|
|
93
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
94
|
+
* for how to migrate.
|
|
95
|
+
*/
|
|
96
|
+
export declare enum StateMachineInputType {
|
|
97
|
+
Number = 56,
|
|
98
|
+
Trigger = 58,
|
|
99
|
+
Boolean = 59
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* An input for a state machine
|
|
103
|
+
* @deprecated State machine inputs are deprecated and will be removed in a
|
|
104
|
+
* future major version: please use data binding properties instead. See
|
|
105
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
106
|
+
* for how to migrate.
|
|
107
|
+
*/
|
|
108
|
+
export declare class StateMachineInput {
|
|
109
|
+
readonly type: StateMachineInputType;
|
|
110
|
+
private runtimeInput;
|
|
111
|
+
constructor(type: StateMachineInputType, runtimeInput: rc.SMIInput);
|
|
112
|
+
/**
|
|
113
|
+
* Returns the name of the input
|
|
114
|
+
*/
|
|
115
|
+
get name(): string;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the current value of the input
|
|
118
|
+
*/
|
|
119
|
+
get value(): number | boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Sets the value of the input
|
|
122
|
+
*/
|
|
123
|
+
set value(value: number | boolean);
|
|
124
|
+
/**
|
|
125
|
+
* Fires a trigger; does nothing on Number or Boolean input types
|
|
126
|
+
*/
|
|
127
|
+
fire(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Deletes the input
|
|
130
|
+
*/
|
|
131
|
+
delete(): void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Subscribing to Rive Events at runtime is deprecated and will be removed in a future major
|
|
135
|
+
* version: please use data binding instead. See
|
|
136
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
137
|
+
*/
|
|
138
|
+
export declare enum RiveEventType {
|
|
139
|
+
General = 128,
|
|
140
|
+
OpenUrl = 131
|
|
141
|
+
}
|
|
142
|
+
declare class BaseArtboard {
|
|
143
|
+
isBindableArtboard: boolean;
|
|
144
|
+
constructor(_isBindableArtboard: boolean);
|
|
145
|
+
}
|
|
146
|
+
declare class Artboard extends BaseArtboard {
|
|
147
|
+
nativeArtboard: rc.Artboard;
|
|
148
|
+
file: RiveFile;
|
|
149
|
+
constructor(artboard: rc.Artboard, _file: RiveFile);
|
|
150
|
+
}
|
|
151
|
+
declare class BindableArtboard extends BaseArtboard implements rc.FinalizableTarget {
|
|
152
|
+
selfUnref: boolean;
|
|
153
|
+
nativeArtboard: rc.BindableArtboard;
|
|
154
|
+
nativeViewModel: rc.ViewModelInstance | null;
|
|
155
|
+
constructor(artboard: rc.BindableArtboard);
|
|
156
|
+
set viewModel(value: ViewModelInstance);
|
|
157
|
+
destroy(): void;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Supported event types triggered in Rive
|
|
161
|
+
*/
|
|
162
|
+
export declare enum EventType {
|
|
163
|
+
Load = "load",
|
|
164
|
+
LoadError = "loaderror",
|
|
165
|
+
Play = "play",
|
|
166
|
+
Pause = "pause",
|
|
167
|
+
Stop = "stop",
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Loop events are deprecated and will be removed in a future
|
|
170
|
+
* major version: they are only reported for linear animation playback, which
|
|
171
|
+
* is deprecated. Use a state machine to control playback and data binding to
|
|
172
|
+
* react to changes instead. See
|
|
173
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide} for how
|
|
174
|
+
* to migrate.
|
|
175
|
+
*/
|
|
176
|
+
Loop = "loop",
|
|
177
|
+
Draw = "draw",
|
|
178
|
+
Advance = "advance",
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated Subscribing to state change events at runtime is deprecated
|
|
181
|
+
* and will be removed in a future major version: use data binding (view model
|
|
182
|
+
* property observers) or state machine actions to react to changes from your
|
|
183
|
+
* graphic instead. See
|
|
184
|
+
* {@link https://rive.app/docs/editor/state-machine/states#actions} for more details.
|
|
185
|
+
*/
|
|
186
|
+
StateChange = "statechange",
|
|
187
|
+
/**
|
|
188
|
+
* @deprecated Subscribing to Rive Events at runtime is deprecated and will be removed in a future
|
|
189
|
+
* major version: please use data binding instead. See
|
|
190
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
191
|
+
*/
|
|
192
|
+
RiveEvent = "riveevent",
|
|
193
|
+
AudioStatusChange = "audiostatuschange"
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated Subscribing to Rive Events at runtime is deprecated and will be removed in a future major
|
|
197
|
+
* version: please use data binding instead. See
|
|
198
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
199
|
+
*/
|
|
200
|
+
export type RiveEventPayload = rc.RiveEvent | rc.OpenUrlEvent;
|
|
201
|
+
/**
|
|
202
|
+
* The deprecations this runtime warns about. Each warning prints its own id, so
|
|
203
|
+
* the value can be copied straight out of the console into
|
|
204
|
+
* {@link Rive.suppressDeprecationWarnings}.
|
|
205
|
+
*/
|
|
206
|
+
export declare const DeprecationKeys: {
|
|
207
|
+
readonly animationNames: "animation-names";
|
|
208
|
+
readonly animationsParam: "animations-param";
|
|
209
|
+
readonly defaultStateMachine: "default-state-machine";
|
|
210
|
+
readonly legacyConstructors: "legacy-constructors";
|
|
211
|
+
readonly legacyUnsubscribe: "legacy-unsubscribe";
|
|
212
|
+
readonly loopEvents: "loop-events";
|
|
213
|
+
readonly namesArray: "names-array";
|
|
214
|
+
readonly riveEvents: "rive-events";
|
|
215
|
+
readonly scrub: "scrub";
|
|
216
|
+
readonly stateChangeEvents: "state-change-events";
|
|
217
|
+
readonly stateMachineInputs: "state-machine-inputs";
|
|
218
|
+
readonly stateMachinesParam: "state-machines-param";
|
|
219
|
+
readonly textRuns: "text-runs";
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* An id accepted by {@link Rive.suppressDeprecationWarnings}, as either a
|
|
223
|
+
* {@link DeprecationKeys} entry or the string literal it holds.
|
|
224
|
+
*/
|
|
225
|
+
export type DeprecationId = (typeof DeprecationKeys)[keyof typeof DeprecationKeys];
|
|
226
|
+
export interface Event {
|
|
227
|
+
type: EventType;
|
|
228
|
+
data?: string | string[] | LoopEvent | number | RiveEventPayload | RiveFile;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Looping types: one-shot, loop, and ping-pong
|
|
232
|
+
* @deprecated Loop events are deprecated and will be removed in a future major
|
|
233
|
+
* version: they are only reported for linear animation playback, which is
|
|
234
|
+
* deprecated. Use a state machine to control playback and data binding to
|
|
235
|
+
* react to changes instead.
|
|
236
|
+
*/
|
|
237
|
+
export declare enum LoopType {
|
|
238
|
+
OneShot = "oneshot",// has value 0 in runtime
|
|
239
|
+
Loop = "loop",// has value 1 in runtime
|
|
240
|
+
PingPong = "pingpong"
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Loop events are returned through onloop callbacks
|
|
244
|
+
* @deprecated Loop events are deprecated and will be removed in a future major
|
|
245
|
+
* version: they are only reported for linear animation playback, which is
|
|
246
|
+
* deprecated. Use a state machine to control playback and data binding to
|
|
247
|
+
* react to changes instead.
|
|
248
|
+
*/
|
|
249
|
+
export interface LoopEvent {
|
|
250
|
+
animation: string;
|
|
251
|
+
type: LoopType;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Loop events are returned through onloop callbacks
|
|
255
|
+
*/
|
|
256
|
+
export type EventCallback = (event: Event) => void;
|
|
257
|
+
/**
|
|
258
|
+
* Event listeners registered with the event manager
|
|
259
|
+
*/
|
|
260
|
+
export interface EventListener {
|
|
261
|
+
type: EventType;
|
|
262
|
+
callback: EventCallback;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* FPS Reporting through callbacks sent to the WASM runtime
|
|
266
|
+
*/
|
|
267
|
+
export type FPSCallback = (fps: number) => void;
|
|
268
|
+
declare class EventManager {
|
|
269
|
+
private listeners;
|
|
270
|
+
constructor(listeners?: EventListener[]);
|
|
271
|
+
private getListeners;
|
|
272
|
+
add(listener: EventListener): void;
|
|
273
|
+
/**
|
|
274
|
+
* Removes a listener
|
|
275
|
+
* @param listener the listener with the callback to be removed
|
|
276
|
+
*/
|
|
277
|
+
remove(listener: EventListener): void;
|
|
278
|
+
/**
|
|
279
|
+
* Clears all listeners of specified type, or every listener if no type is
|
|
280
|
+
* specified
|
|
281
|
+
* @param type the type of listeners to clear, or all listeners if not
|
|
282
|
+
* specified
|
|
283
|
+
*/
|
|
284
|
+
removeAll(type?: EventType): void;
|
|
285
|
+
fire(event: Event): void;
|
|
286
|
+
}
|
|
287
|
+
export interface Task {
|
|
288
|
+
action?: VoidCallback;
|
|
289
|
+
event?: Event;
|
|
290
|
+
}
|
|
291
|
+
declare class TaskQueueManager {
|
|
292
|
+
private eventManager;
|
|
293
|
+
private queue;
|
|
294
|
+
constructor(eventManager: EventManager);
|
|
295
|
+
add(task: Task): void;
|
|
296
|
+
process(): void;
|
|
297
|
+
}
|
|
298
|
+
export interface RiveParameters {
|
|
299
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
300
|
+
/**
|
|
301
|
+
* URI of the `.riv` file to load. Will be fetched by the runtime. Can be used instead of
|
|
302
|
+
* `buffer` or `riveFile`.
|
|
303
|
+
*/
|
|
304
|
+
src?: string;
|
|
305
|
+
/**
|
|
306
|
+
* ArrayBuffer of .riv file contents. Can be used instead of `src` or `riveFile` if you
|
|
307
|
+
* fetch the file contents yourself.
|
|
308
|
+
*/
|
|
309
|
+
buffer?: ArrayBuffer;
|
|
310
|
+
/**
|
|
311
|
+
* RiveFile instance if created separately. Useful if you reuse a Rive file across multiple instances.
|
|
312
|
+
* Can be used instead of `src` or `buffer`.
|
|
313
|
+
*/
|
|
314
|
+
riveFile?: RiveFile;
|
|
315
|
+
/**
|
|
316
|
+
* Name of the artboard to display.
|
|
317
|
+
*/
|
|
318
|
+
artboard?: string;
|
|
319
|
+
/**
|
|
320
|
+
* Name of the state machine to play.
|
|
321
|
+
*/
|
|
322
|
+
stateMachine?: string;
|
|
323
|
+
/**
|
|
324
|
+
* @deprecated Use the `stateMachine` parameter to play a state machine
|
|
325
|
+
* instead. Support for starting playback with named animations will be
|
|
326
|
+
* removed in a future major version.
|
|
327
|
+
*/
|
|
328
|
+
animations?: string | string[];
|
|
329
|
+
/**
|
|
330
|
+
* @deprecated Use `stateMachine` with a single state machine name instead.
|
|
331
|
+
* Support for playing multiple state machines at once will be removed in a
|
|
332
|
+
* future major version.
|
|
333
|
+
*/
|
|
334
|
+
stateMachines?: string | string[];
|
|
335
|
+
layout?: Layout;
|
|
336
|
+
autoplay?: boolean;
|
|
337
|
+
useOffscreenRenderer?: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* @experimental (WebGL2 only) Renders with inkbleed antialiasing instead of MSAA, which
|
|
340
|
+
* disables the canvas's native MSAA. Fills that don't use the clockwise fill rule are
|
|
341
|
+
* converted to clockwise on a best-effort basis. Toggle it later
|
|
342
|
+
* with `rive.inkbleed`, which only works if enabled here.
|
|
343
|
+
*/
|
|
344
|
+
enableInkbleed?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Optional tab index to set for the canvas element if there are any Focus nodes within the graphic
|
|
347
|
+
*/
|
|
348
|
+
tabIndex?: number;
|
|
349
|
+
/**
|
|
350
|
+
* Optional settings for focus behavior
|
|
351
|
+
*/
|
|
352
|
+
focusOptions?: RiveFocusOptions;
|
|
353
|
+
/**
|
|
354
|
+
* Allow the runtime to automatically load assets hosted in Rive's CDN.
|
|
355
|
+
* enabled by default.
|
|
356
|
+
*/
|
|
357
|
+
enableRiveAssetCDN?: boolean;
|
|
358
|
+
/**
|
|
359
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
360
|
+
*
|
|
361
|
+
* When to build semantic trees and the accessibility DOM overlay.
|
|
362
|
+
* Defaults to {@link SemanticMode.Disabled}.
|
|
363
|
+
*/
|
|
364
|
+
semanticsMode?: SemanticMode;
|
|
365
|
+
/**
|
|
366
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
367
|
+
*
|
|
368
|
+
* Optional options for the accessibility overlay container.
|
|
369
|
+
*/
|
|
370
|
+
semanticsOptions?: RiveSemanticsOptions;
|
|
371
|
+
/**
|
|
372
|
+
* Turn off Rive Listeners. This means state machines that have Listeners
|
|
373
|
+
* will not be invoked, and also, no event listeners pertaining to Listeners
|
|
374
|
+
* will be attached to the <canvas> element
|
|
375
|
+
*/
|
|
376
|
+
shouldDisableRiveListeners?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* For Rive Listeners, allows scrolling behavior to still occur on canvas elements
|
|
379
|
+
* when a touch/drag action is performed on touch-enabled devices. Otherwise,
|
|
380
|
+
* scroll behavior may be prevented on touch/drag actions on the canvas by default.
|
|
381
|
+
*/
|
|
382
|
+
isTouchScrollEnabled?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Enable Rive Events to be handled by the runtime. This means any special Rive Event may have
|
|
385
|
+
* a side effect that takes place implicitly.
|
|
386
|
+
*
|
|
387
|
+
* For example, if during the render loop an OpenUrlEvent is detected, the
|
|
388
|
+
* browser may try to open the specified URL in the payload.
|
|
389
|
+
*
|
|
390
|
+
* This flag is false by default to prevent any unwanted behaviors from taking place.
|
|
391
|
+
* This means any special Rive Event will have to be handled manually by subscribing to
|
|
392
|
+
* EventType.RiveEvent
|
|
393
|
+
*
|
|
394
|
+
* @deprecated Subscribing to Rive Events at runtime is deprecated and will be removed in a future
|
|
395
|
+
* major version: please use data binding instead. See
|
|
396
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
397
|
+
*/
|
|
398
|
+
automaticallyHandleEvents?: boolean;
|
|
399
|
+
/**
|
|
400
|
+
* Rive will look for a default view model and view model instance to bind to the artboard
|
|
401
|
+
*/
|
|
402
|
+
autoBind?: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* For Rive Listeners, dispatch a pointer exit when the pointer exits the canvas.
|
|
405
|
+
*/
|
|
406
|
+
dispatchPointerExit?: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Enables multi touch support
|
|
409
|
+
*/
|
|
410
|
+
enableMultiTouch?: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Enum with drawing options for optimizations
|
|
413
|
+
*/
|
|
414
|
+
drawingOptions?: DrawOptimizationOptions;
|
|
415
|
+
/**
|
|
416
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
417
|
+
*
|
|
418
|
+
* Render GPU Canvas content, which draws through the deferred renderer.
|
|
419
|
+
*
|
|
420
|
+
* Only applies when this instance loads its own file (`src`/`buffer`), where it
|
|
421
|
+
* is forwarded to that file as {@link RiveFileParameters.enableGPUCanvas}. With a
|
|
422
|
+
* supplied `riveFile` the file's own flag wins, since a file's mode is fixed at
|
|
423
|
+
* import. False by default.
|
|
424
|
+
*/
|
|
425
|
+
enableGPUCanvas?: boolean;
|
|
426
|
+
/**
|
|
427
|
+
* Emit performance.mark / performance.measure entries for load lifecycle
|
|
428
|
+
* events and the first 3 render frames. Useful for profiling Rive's
|
|
429
|
+
* contribution to load and render time in browser devtools.
|
|
430
|
+
* False by default.
|
|
431
|
+
*/
|
|
432
|
+
enablePerfMarks?: boolean;
|
|
433
|
+
onLoad?: EventCallback;
|
|
434
|
+
onLoadError?: EventCallback;
|
|
435
|
+
onPlay?: EventCallback;
|
|
436
|
+
onPause?: EventCallback;
|
|
437
|
+
onStop?: EventCallback;
|
|
438
|
+
/**
|
|
439
|
+
* @deprecated Loop events are deprecated and will be removed in a future
|
|
440
|
+
* major version: they are only reported for linear animation playback, which
|
|
441
|
+
* is deprecated. Use a state machine to control playback and data binding to
|
|
442
|
+
* react to changes instead. See
|
|
443
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide} for how
|
|
444
|
+
* to migrate.
|
|
445
|
+
*/
|
|
446
|
+
onLoop?: EventCallback;
|
|
447
|
+
/**
|
|
448
|
+
* @deprecated Subscribing to state change events at runtime is deprecated
|
|
449
|
+
* and will be removed in a future major version: use data binding (view model
|
|
450
|
+
* property observers) or state machine actions to react to changes from your
|
|
451
|
+
* graphic instead. See
|
|
452
|
+
* {@link https://rive.app/docs/editor/state-machine/states#actions} for how
|
|
453
|
+
* to migrate.
|
|
454
|
+
*/
|
|
455
|
+
onStateChange?: EventCallback;
|
|
456
|
+
onAdvance?: EventCallback;
|
|
457
|
+
assetLoader?: AssetLoadCallback;
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated Use `onLoad()` instead
|
|
460
|
+
*/
|
|
461
|
+
onload?: EventCallback;
|
|
462
|
+
/**
|
|
463
|
+
* @deprecated Use `onLoadError()` instead
|
|
464
|
+
*/
|
|
465
|
+
onloaderror?: EventCallback;
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated Use `onPlay()` instead
|
|
468
|
+
*/
|
|
469
|
+
onplay?: EventCallback;
|
|
470
|
+
/**
|
|
471
|
+
* @deprecated Use `onPause()` instead
|
|
472
|
+
*/
|
|
473
|
+
onpause?: EventCallback;
|
|
474
|
+
/**
|
|
475
|
+
* @deprecated Use `onStop()` instead
|
|
476
|
+
*/
|
|
477
|
+
onstop?: EventCallback;
|
|
478
|
+
/**
|
|
479
|
+
* @deprecated Use `onLoop()` instead
|
|
480
|
+
*/
|
|
481
|
+
onloop?: EventCallback;
|
|
482
|
+
/**
|
|
483
|
+
* @deprecated Use `onStateChange()` instead
|
|
484
|
+
*/
|
|
485
|
+
onstatechange?: EventCallback;
|
|
486
|
+
}
|
|
487
|
+
export interface RiveLoadParameters {
|
|
488
|
+
src?: string;
|
|
489
|
+
buffer?: ArrayBuffer;
|
|
490
|
+
riveFile?: RiveFile;
|
|
491
|
+
autoplay?: boolean;
|
|
492
|
+
autoBind?: boolean;
|
|
493
|
+
artboard?: string;
|
|
494
|
+
/**
|
|
495
|
+
* Name of the state machine to play.
|
|
496
|
+
*/
|
|
497
|
+
stateMachine?: string;
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated Use the `stateMachine` parameter to play a state machine
|
|
500
|
+
* instead. Support for starting playback with named animations will be
|
|
501
|
+
* removed in a future major version.
|
|
502
|
+
*/
|
|
503
|
+
animations?: string | string[];
|
|
504
|
+
/**
|
|
505
|
+
* @deprecated Use `stateMachine` with a single state machine name instead.
|
|
506
|
+
* Support for playing multiple state machines at once will be removed in a
|
|
507
|
+
* future major version.
|
|
508
|
+
*/
|
|
509
|
+
stateMachines?: string | string[];
|
|
510
|
+
useOffscreenRenderer?: boolean;
|
|
511
|
+
shouldDisableRiveListeners?: boolean;
|
|
512
|
+
tabIndex?: number;
|
|
513
|
+
semanticsMode?: SemanticMode;
|
|
514
|
+
semanticsOptions?: RiveSemanticsOptions;
|
|
515
|
+
/**
|
|
516
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
517
|
+
*
|
|
518
|
+
* Render GPU Canvas content, which draws through the deferred renderer. Forwarded
|
|
519
|
+
* to the file this instance loads; with a supplied `riveFile` the file's flag wins.
|
|
520
|
+
* False by default.
|
|
521
|
+
*/
|
|
522
|
+
enableGPUCanvas?: boolean;
|
|
523
|
+
}
|
|
524
|
+
export interface RiveResetParameters {
|
|
525
|
+
artboard?: string;
|
|
526
|
+
/**
|
|
527
|
+
* Name of the state machine to play.
|
|
528
|
+
*/
|
|
529
|
+
stateMachine?: string;
|
|
530
|
+
/**
|
|
531
|
+
* @deprecated Use the `stateMachine` parameter to play a state machine
|
|
532
|
+
* instead. Support for starting playback with named animations will be
|
|
533
|
+
* removed in a future major version.
|
|
534
|
+
*/
|
|
535
|
+
animations?: string | string[];
|
|
536
|
+
/**
|
|
537
|
+
* @deprecated Use `stateMachine` with a single state machine name instead.
|
|
538
|
+
* Support for playing multiple state machines at once will be removed in a
|
|
539
|
+
* future major version.
|
|
540
|
+
*/
|
|
541
|
+
stateMachines?: string | string[];
|
|
542
|
+
autoplay?: boolean;
|
|
543
|
+
autoBind?: boolean;
|
|
544
|
+
}
|
|
545
|
+
export interface RiveFileParameters {
|
|
546
|
+
src?: string;
|
|
547
|
+
buffer?: ArrayBuffer;
|
|
548
|
+
assetLoader?: AssetLoadCallback;
|
|
549
|
+
enableRiveAssetCDN?: boolean;
|
|
550
|
+
onLoad?: EventCallback;
|
|
551
|
+
onLoadError?: EventCallback;
|
|
552
|
+
/**
|
|
553
|
+
* Emit performance.mark / performance.measure entries for load lifecycle
|
|
554
|
+
* events. False by default.
|
|
555
|
+
*/
|
|
556
|
+
enablePerfMarks?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
559
|
+
*
|
|
560
|
+
* Render GPU Canvas content in this file, importing it through a deferred
|
|
561
|
+
* rendering session.
|
|
562
|
+
*
|
|
563
|
+
* Fixed at import and has no setter: a file's resources are typed by the factory
|
|
564
|
+
* that made them and can never switch. The session records for the one canvas that
|
|
565
|
+
* displays the file, so a second Rive instance sharing this file re-imports it into
|
|
566
|
+
* a session of its own.
|
|
567
|
+
* False by default.
|
|
568
|
+
*/
|
|
569
|
+
enableGPUCanvas?: boolean;
|
|
570
|
+
}
|
|
571
|
+
export declare class RiveFile implements rc.FinalizableTarget {
|
|
572
|
+
private static readonly missingErrorMessage;
|
|
573
|
+
private static readonly fileLoadErrorMessage;
|
|
574
|
+
private src;
|
|
575
|
+
private buffer;
|
|
576
|
+
private runtime;
|
|
577
|
+
private file;
|
|
578
|
+
private assetLoader;
|
|
579
|
+
private enableRiveAssetCDN;
|
|
580
|
+
private enablePerfMarks;
|
|
581
|
+
private eventManager;
|
|
582
|
+
private referenceCount;
|
|
583
|
+
private destroyed;
|
|
584
|
+
selfUnref: boolean;
|
|
585
|
+
private bindableArtboards;
|
|
586
|
+
private deferred;
|
|
587
|
+
private session;
|
|
588
|
+
private _sessionClaimed;
|
|
589
|
+
private fileFinalizer;
|
|
590
|
+
private boundElsewhereWarned;
|
|
591
|
+
private static deferredUnsupportedWarned;
|
|
592
|
+
constructor(params: RiveFileParameters);
|
|
593
|
+
private releaseFile;
|
|
594
|
+
private releaseSession;
|
|
595
|
+
private releaseBindableArtboards;
|
|
596
|
+
private initData;
|
|
597
|
+
private loadRiveFileBytes;
|
|
598
|
+
private loadRuntime;
|
|
599
|
+
init(): Promise<void>;
|
|
600
|
+
private fireLoadError;
|
|
601
|
+
/**
|
|
602
|
+
* Subscribe to Rive-generated events
|
|
603
|
+
* @param type the type of event to subscribe to
|
|
604
|
+
* @param callback callback to fire when the event occurs
|
|
605
|
+
*/
|
|
606
|
+
on(type: EventType, callback: EventCallback): void;
|
|
607
|
+
/**
|
|
608
|
+
* Unsubscribes from a Rive-generated event
|
|
609
|
+
* @param type the type of event to unsubscribe from
|
|
610
|
+
* @param callback the callback to unsubscribe
|
|
611
|
+
*/
|
|
612
|
+
off(type: EventType, callback: EventCallback): void;
|
|
613
|
+
cleanup(): void;
|
|
614
|
+
private static makeDeferredSession;
|
|
615
|
+
/**
|
|
616
|
+
* @internal The deferred session this file imported through, or null if it
|
|
617
|
+
* was imported in immediate mode.
|
|
618
|
+
*/
|
|
619
|
+
get deferredSession(): rc.DeferredSession | null;
|
|
620
|
+
/**
|
|
621
|
+
* @internal Whether deferred was asked for, even when this build could not
|
|
622
|
+
* honor it and imported immediate.
|
|
623
|
+
*/
|
|
624
|
+
get deferredRequested(): boolean;
|
|
625
|
+
/**
|
|
626
|
+
* @internal Whether this file's session has ever been attached to a renderer.
|
|
627
|
+
* Attaching is once per session, so a claimed file re-imports for the next
|
|
628
|
+
* instance even after the renderer it was bound to is gone.
|
|
629
|
+
*/
|
|
630
|
+
get sessionClaimed(): boolean;
|
|
631
|
+
/**
|
|
632
|
+
* @internal Marks this file's session as spent. There is no matching release:
|
|
633
|
+
* a session that has been attached can never replay for another renderer.
|
|
634
|
+
*/
|
|
635
|
+
claimSession(): void;
|
|
636
|
+
/**
|
|
637
|
+
* @internal One warning per file however many instances collide on it.
|
|
638
|
+
*/
|
|
639
|
+
warnBoundElsewhereOnce(): void;
|
|
640
|
+
/**
|
|
641
|
+
* @internal Re-imports this file from its retained buffer into a mode of its
|
|
642
|
+
* own. The copy is owned by whoever asked for it and never joins this file's
|
|
643
|
+
* reference count.
|
|
644
|
+
*/
|
|
645
|
+
reimport(deferred: boolean): Promise<RiveFile>;
|
|
646
|
+
/**
|
|
647
|
+
* Unsubscribes all Rive listeners from an event type, or everything if no type is
|
|
648
|
+
* given
|
|
649
|
+
* @param type the type of event to unsubscribe from, or all types if
|
|
650
|
+
* undefined
|
|
651
|
+
*/
|
|
652
|
+
removeAllRiveEventListeners(type?: EventType): void;
|
|
653
|
+
getInstance(): rc.File;
|
|
654
|
+
destroyIfUnused(): void;
|
|
655
|
+
private createBindableArtboard;
|
|
656
|
+
/**
|
|
657
|
+
* @deprecated This function is deprecated. For better stability and memory management
|
|
658
|
+
* use `getBindableArtboard()` instead.
|
|
659
|
+
* @param {string} name - The name of the artboard.
|
|
660
|
+
* @returns {Artboard} The artboard to bind to.
|
|
661
|
+
*/
|
|
662
|
+
getArtboard(name: string): Artboard | null;
|
|
663
|
+
getBindableArtboard(name: string): BindableArtboard | null;
|
|
664
|
+
getDefaultBindableArtboard(): BindableArtboard | null;
|
|
665
|
+
internalBindableArtboardFromArtboard(artboard: rc.Artboard): BindableArtboard | null;
|
|
666
|
+
viewModelByName(name: string): ViewModel | null;
|
|
667
|
+
/**
|
|
668
|
+
* @returns the names of the file's global view models, in file order.
|
|
669
|
+
*/
|
|
670
|
+
globalViewModelNames(): string[];
|
|
671
|
+
}
|
|
672
|
+
export declare class Rive {
|
|
673
|
+
private readonly canvas;
|
|
674
|
+
private src;
|
|
675
|
+
private buffer;
|
|
676
|
+
private _layout;
|
|
677
|
+
private renderer;
|
|
678
|
+
private loaded;
|
|
679
|
+
private destroyed;
|
|
680
|
+
private _observed;
|
|
681
|
+
/**
|
|
682
|
+
* Tracks if a Rive file is loaded; we need this in addition to loaded as some
|
|
683
|
+
* commands (e.g. contents) can be called as soon as the file is loaded.
|
|
684
|
+
* However, playback commands need to be queued and run in order once initial
|
|
685
|
+
* animations and autoplay has been sorted out. This applies to play, pause,
|
|
686
|
+
* and start.
|
|
687
|
+
*/
|
|
688
|
+
private readyForPlaying;
|
|
689
|
+
private runtime;
|
|
690
|
+
private deferredRenderer;
|
|
691
|
+
private _inkbleedCapable;
|
|
692
|
+
private _inkbleed;
|
|
693
|
+
private static inkbleedUnsupportedWarned;
|
|
694
|
+
private static inkbleedNotCapableWarned;
|
|
695
|
+
private ownsRiveFile;
|
|
696
|
+
private artboard;
|
|
697
|
+
private eventCleanup;
|
|
698
|
+
private _keyboardInteractions;
|
|
699
|
+
private file;
|
|
700
|
+
private riveFile;
|
|
701
|
+
private eventManager;
|
|
702
|
+
private taskQueue;
|
|
703
|
+
private animator;
|
|
704
|
+
private assetLoader;
|
|
705
|
+
private static readonly missingErrorMessage;
|
|
706
|
+
private static readonly cleanupErrorMessage;
|
|
707
|
+
/**
|
|
708
|
+
* Deprecation warnings to silence, by {@link DeprecationId}. Each warning
|
|
709
|
+
* prints the id needed to silence it, so you can copy it out of the console.
|
|
710
|
+
*
|
|
711
|
+
* ```ts
|
|
712
|
+
* Rive.suppressDeprecationWarnings = ["rive-events", "text-runs"];
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* Assigning replaces the whole list.
|
|
716
|
+
* There is no option to silence everything
|
|
717
|
+
*/
|
|
718
|
+
static get suppressDeprecationWarnings(): readonly DeprecationId[];
|
|
719
|
+
static set suppressDeprecationWarnings(ids: readonly DeprecationId[]);
|
|
720
|
+
private shouldDisableRiveListeners;
|
|
721
|
+
private automaticallyHandleEvents;
|
|
722
|
+
private dispatchPointerExit;
|
|
723
|
+
private enableMultiTouch;
|
|
724
|
+
private enableRiveAssetCDN;
|
|
725
|
+
private semanticsMode;
|
|
726
|
+
private semanticsOptions;
|
|
727
|
+
/** True when this instance may drain semantics and render the overlay. */
|
|
728
|
+
private _semanticsActive;
|
|
729
|
+
private _volume;
|
|
730
|
+
private _artboardWidth;
|
|
731
|
+
private _artboardHeight;
|
|
732
|
+
private _devicePixelRatioUsed;
|
|
733
|
+
private _hasZeroSize;
|
|
734
|
+
private _needsRedraw;
|
|
735
|
+
private _currentCanvasWidth;
|
|
736
|
+
private _currentCanvasHeight;
|
|
737
|
+
private _audioEventListener;
|
|
738
|
+
private _boundDraw;
|
|
739
|
+
private _pageVisibilityHandler;
|
|
740
|
+
private _explicitlyStoppedRendering;
|
|
741
|
+
private _viewModelInstance;
|
|
742
|
+
private _globalViewModelInstances;
|
|
743
|
+
private _dataEnums;
|
|
744
|
+
private _tabIndex;
|
|
745
|
+
private _prevHasFocus;
|
|
746
|
+
private _prevWantsTextInputSession;
|
|
747
|
+
private _inPointerDownDrain;
|
|
748
|
+
private _focusOptions;
|
|
749
|
+
private _semanticTree;
|
|
750
|
+
private _accessibilityOverlay;
|
|
751
|
+
/**
|
|
752
|
+
* True when an input to the accessibility overlay's artboard→canvas transform
|
|
753
|
+
* (layout fit/alignment/bounds, devicePixelRatio, or layout scale) has changed
|
|
754
|
+
* and the matrix must be recomputed on the next overlay update. Avoids calling
|
|
755
|
+
* computeAlignment every frame when only the semantic tree changed.
|
|
756
|
+
*/
|
|
757
|
+
private _overlayTransformDirty;
|
|
758
|
+
private readonly _instanceId;
|
|
759
|
+
private drawOptimization;
|
|
760
|
+
private enablePerfMarks;
|
|
761
|
+
durations: number[];
|
|
762
|
+
frameTimes: number[];
|
|
763
|
+
frameCount: number;
|
|
764
|
+
isTouchScrollEnabled: boolean;
|
|
765
|
+
constructor(params: RiveParameters);
|
|
766
|
+
get viewModelCount(): number;
|
|
767
|
+
static new(params: RiveParameters): Rive;
|
|
768
|
+
/**
|
|
769
|
+
* @experimental Turns on semantics and the accessibility overlay for this
|
|
770
|
+
* instance. Idempotent; safe to call before or after load. Use this to drive
|
|
771
|
+
* a consumer-controlled accessibility toggle when constructed with the
|
|
772
|
+
* default {@link SemanticMode.Disabled}.
|
|
773
|
+
*/
|
|
774
|
+
enableSemantics(): void;
|
|
775
|
+
private activateSemantics;
|
|
776
|
+
private syncSemanticsOnStateMachines;
|
|
777
|
+
/**
|
|
778
|
+
* Tears down the semantic tree and accessibility overlay. The overlay captures the
|
|
779
|
+
* active state machine in its action closures, so it must not outlive the
|
|
780
|
+
* instances it points at (reset/load delete them)
|
|
781
|
+
*/
|
|
782
|
+
private cleanupSemantics;
|
|
783
|
+
private onSystemAudioChanged;
|
|
784
|
+
private onCanvasResize;
|
|
785
|
+
private init;
|
|
786
|
+
/**
|
|
787
|
+
* Setup Rive Listeners on the canvas
|
|
788
|
+
* @param riveListenerOptions - Enables TouchEvent events on the canvas. Set to true to allow
|
|
789
|
+
* touch scrolling on the canvas element on touch-enabled devices
|
|
790
|
+
* i.e. { isTouchScrollEnabled: true }
|
|
791
|
+
*/
|
|
792
|
+
setupRiveListeners(riveListenerOptions?: SetupRiveListenersOptions): void;
|
|
793
|
+
private isEditingHostFocused;
|
|
794
|
+
private get focusStateMachine();
|
|
795
|
+
/**
|
|
796
|
+
* Wire keyboard interactions when a playing state machine has focus nodes.
|
|
797
|
+
* Called at listener setup and lazily each frame so late-bound bindable artboards work.
|
|
798
|
+
*/
|
|
799
|
+
private ensureKeyboardInteractions;
|
|
800
|
+
/** Runs inside touchend/mouseup so focusing the proxy raises the mobile keyboard. */
|
|
801
|
+
private summonKeyboardForGesture;
|
|
802
|
+
/** expectsKeyboardInput, and (with semantics on) the focused node is a textField. */
|
|
803
|
+
private wantsTextInputSession;
|
|
804
|
+
private advanceAndDrainForPointer;
|
|
805
|
+
private cleanupKeyboardInteractions;
|
|
806
|
+
/**
|
|
807
|
+
* Remove Rive Listeners setup on the canvas
|
|
808
|
+
*/
|
|
809
|
+
removeRiveListeners(): void;
|
|
810
|
+
/**
|
|
811
|
+
* If the instance has audio and the system audio is not ready
|
|
812
|
+
* we hook the instance to the audio manager
|
|
813
|
+
*/
|
|
814
|
+
private initializeAudio;
|
|
815
|
+
private initArtboardSize;
|
|
816
|
+
private initData;
|
|
817
|
+
/**
|
|
818
|
+
* Settles which rendering mode this Rive instance runs in. The file dictates: its rendering mode
|
|
819
|
+
* is fixed at import, and an immediate renderer silently drops a deferred
|
|
820
|
+
* file's resources. Every mismatch warns and degrades to something that
|
|
821
|
+
* renders, so users shouldn't have a blank canvas. A fallback self-reimport replaces `this.riveFile`;
|
|
822
|
+
* only a file this instance imported is released when that happens.
|
|
823
|
+
*/
|
|
824
|
+
private resolveDeferredRendering;
|
|
825
|
+
private initArtboard;
|
|
826
|
+
drawFrame(): void;
|
|
827
|
+
private _canvasSizeChanged;
|
|
828
|
+
private _deferredWorkPending;
|
|
829
|
+
/** Rive can move focus on its own, so reconcile the text session and DOM focus each frame. */
|
|
830
|
+
private pollFocusState;
|
|
831
|
+
/** Begin/end the text session on wantsSession edges; decorate the proxy while it has DOM focus. */
|
|
832
|
+
private syncTextInputSession;
|
|
833
|
+
/** Mirror Rive's hasFocus into the keyboard session state and, on opt-in, canvas focus. */
|
|
834
|
+
private syncRiveFocus;
|
|
835
|
+
private lastRenderTime;
|
|
836
|
+
private frameRequestId;
|
|
837
|
+
/**
|
|
838
|
+
* Used be draw to track when a second of active rendering time has passed.
|
|
839
|
+
* Used for debugging purposes
|
|
840
|
+
*/
|
|
841
|
+
private renderSecondTimer;
|
|
842
|
+
/**
|
|
843
|
+
* Handles important sequence of reporting Rive events, advancing the state machine or animation, and invoking various callbacks
|
|
844
|
+
* due to state changes, view model property changes, etc.
|
|
845
|
+
*
|
|
846
|
+
* @param elapsedTime time to advance the state machine by
|
|
847
|
+
*/
|
|
848
|
+
private advanceAndReportChanges;
|
|
849
|
+
/**
|
|
850
|
+
* Draw rendering loop; renders animation frames at the correct time interval.
|
|
851
|
+
* @param time the time at which to render a frame
|
|
852
|
+
*/
|
|
853
|
+
private draw;
|
|
854
|
+
/**
|
|
855
|
+
* Align the renderer
|
|
856
|
+
*/
|
|
857
|
+
private alignRenderer;
|
|
858
|
+
get fps(): number;
|
|
859
|
+
get frameTime(): string | 0;
|
|
860
|
+
/**
|
|
861
|
+
* Cleans up all Wasm-generated objects that need to be manually destroyed:
|
|
862
|
+
* artboard instances, animation instances, state machine instances,
|
|
863
|
+
* renderer instance, file and runtime.
|
|
864
|
+
*
|
|
865
|
+
* Once this is called, you will need to initialise a new instance of the
|
|
866
|
+
* Rive class
|
|
867
|
+
*/
|
|
868
|
+
cleanup(): void;
|
|
869
|
+
/**
|
|
870
|
+
* Drops this instance's hold on `this.riveFile`. A reference taken through
|
|
871
|
+
* getInstance() is given back; a file we imported but never referenced is
|
|
872
|
+
* released outright so its session goes with it. A caller-supplied file we
|
|
873
|
+
* never referenced is left alone.
|
|
874
|
+
*
|
|
875
|
+
* `isTeardown` distinguishes cleanup() from a reload. Teardown always hands
|
|
876
|
+
* the reference back, as it always has. A reload must not do that for a
|
|
877
|
+
* caller-supplied file: a RiveFile carries no reference for its creator, so
|
|
878
|
+
* releasing here would take the last one and destroy a file the caller still
|
|
879
|
+
* holds.
|
|
880
|
+
*/
|
|
881
|
+
private releaseCurrentRiveFile;
|
|
882
|
+
/**
|
|
883
|
+
* Cleans up the Renderer object. Only call this API if you no longer
|
|
884
|
+
* need to render Rive content in your session.
|
|
885
|
+
*/
|
|
886
|
+
deleteRiveRenderer(): void;
|
|
887
|
+
/**
|
|
888
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
889
|
+
*
|
|
890
|
+
* Whether this instance is rendering through a deferred session. False whenever
|
|
891
|
+
* a fallback ran, whatever was requested.
|
|
892
|
+
*/
|
|
893
|
+
get deferredRendererActive(): boolean;
|
|
894
|
+
/**
|
|
895
|
+
* Cleans up any Wasm-generated objects that need to be manually destroyed:
|
|
896
|
+
* artboard instances, animation instances, state machine instances.
|
|
897
|
+
*
|
|
898
|
+
* Once this is called, things will need to be reinitialized or bad things
|
|
899
|
+
* might happen.
|
|
900
|
+
*/
|
|
901
|
+
cleanupInstances(): void;
|
|
902
|
+
/**
|
|
903
|
+
* Tries to query the setup Artboard for a text run node with the given name.
|
|
904
|
+
*
|
|
905
|
+
* @param textRunName - Name of the text run node associated with a text object
|
|
906
|
+
* @returns - TextValueRun node or undefined if the text run cannot be queried
|
|
907
|
+
*/
|
|
908
|
+
private retrieveTextRun;
|
|
909
|
+
/**
|
|
910
|
+
* Returns a string from a given text run node name, or undefined if the text run
|
|
911
|
+
* cannot be queried.
|
|
912
|
+
*
|
|
913
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
914
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
915
|
+
* for how to migrate.
|
|
916
|
+
* @param textRunName - Name of the text run node associated with a text object
|
|
917
|
+
* @returns - String value of the text run node or undefined
|
|
918
|
+
*/
|
|
919
|
+
getTextRunValue(textRunName: string): string | undefined;
|
|
920
|
+
/**
|
|
921
|
+
* Sets a text value for a given text run node name if possible
|
|
922
|
+
*
|
|
923
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
924
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
925
|
+
* for how to migrate.
|
|
926
|
+
* @param textRunName - Name of the text run node associated with a text object
|
|
927
|
+
* @param textRunValue - String value to set on the text run node
|
|
928
|
+
*/
|
|
929
|
+
setTextRunValue(textRunName: string, textRunValue: string): void;
|
|
930
|
+
/**
|
|
931
|
+
* Warns when playback-control names match linear animations in the
|
|
932
|
+
* Animator's instanced context; state machine playback remain supported.
|
|
933
|
+
*
|
|
934
|
+
* Remove for v3 release
|
|
935
|
+
*/
|
|
936
|
+
private warnIfLinearAnimationNames;
|
|
937
|
+
/**
|
|
938
|
+
* Plays specified animations or state machines; if none specified, it
|
|
939
|
+
* unpauses everything.
|
|
940
|
+
* @param animationNames Animation or state machine name(s) to play.
|
|
941
|
+
*
|
|
942
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
943
|
+
* state machine instead) and passing an array of names (this parameter
|
|
944
|
+
* becomes a single string in the next major version).
|
|
945
|
+
*/
|
|
946
|
+
play(animationNames?: string | string[], autoplay?: true): void;
|
|
947
|
+
/**
|
|
948
|
+
* Pauses specified animations or state machines; if none specified, pauses
|
|
949
|
+
* all.
|
|
950
|
+
* @param animationNames Animation or state machine name(s) to pause.
|
|
951
|
+
*
|
|
952
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
953
|
+
* state machine instead) and passing an array of names (this parameter
|
|
954
|
+
* becomes a single string in the next major version).
|
|
955
|
+
*/
|
|
956
|
+
pause(animationNames?: string | string[]): void;
|
|
957
|
+
/**
|
|
958
|
+
* Scrubs specified animations to the given time; if none specified, scrubs
|
|
959
|
+
* all of them.
|
|
960
|
+
* @deprecated `scrub()` will be removed in a future major version: use a
|
|
961
|
+
* state machine to control playback instead
|
|
962
|
+
*/
|
|
963
|
+
scrub(animationNames?: string | string[], value?: number): void;
|
|
964
|
+
/**
|
|
965
|
+
* Stops specified animations or state machines; if none specified, stops
|
|
966
|
+
* them all.
|
|
967
|
+
* @param animationNames Animation or state machine name(s) to stop.
|
|
968
|
+
*
|
|
969
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
970
|
+
* state machine instead) and passing an array of names (this parameter
|
|
971
|
+
* becomes a single string in the next major version).
|
|
972
|
+
*/
|
|
973
|
+
stop(animationNames?: string | string[] | undefined): void;
|
|
974
|
+
/**
|
|
975
|
+
* Resets the animation
|
|
976
|
+
* @param artboard the name of the artboard, or default if none given
|
|
977
|
+
* @param stateMachine the name of the state machine for playback
|
|
978
|
+
* @param autoplay whether to autoplay when reset, defaults to false
|
|
979
|
+
*
|
|
980
|
+
*/
|
|
981
|
+
reset(params?: RiveResetParameters): void;
|
|
982
|
+
load(params: RiveLoadParameters): void;
|
|
983
|
+
set layout(layout: Layout);
|
|
984
|
+
/**
|
|
985
|
+
* Returns the current layout. Note that layout should be treated as
|
|
986
|
+
* immutable. If you want to change the layout, create a new one use the
|
|
987
|
+
* layout setter
|
|
988
|
+
*/
|
|
989
|
+
get layout(): Layout;
|
|
990
|
+
/**
|
|
991
|
+
* Sets the layout bounds to the current canvas size; this is typically called
|
|
992
|
+
* when the canvas is resized
|
|
993
|
+
*/
|
|
994
|
+
resizeToCanvas(): void;
|
|
995
|
+
/**
|
|
996
|
+
* Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
|
|
997
|
+
* Uses the size of the backing canvas to set new width/height attributes. Need to re-render
|
|
998
|
+
* and resize the layout to match the new drawing surface afterwards.
|
|
999
|
+
* Useful function for consumers to include in a window resize listener.
|
|
1000
|
+
*
|
|
1001
|
+
* This method will set the {@link devicePixelRatioUsed} property.
|
|
1002
|
+
*
|
|
1003
|
+
* Optionally, you can provide a {@link customDevicePixelRatio} to provide a
|
|
1004
|
+
* custom value.
|
|
1005
|
+
*/
|
|
1006
|
+
resizeDrawingSurfaceToCanvas(customDevicePixelRatio?: number): void;
|
|
1007
|
+
get source(): string;
|
|
1008
|
+
/**
|
|
1009
|
+
* Returns the name of the active artboard
|
|
1010
|
+
*/
|
|
1011
|
+
get activeArtboard(): string;
|
|
1012
|
+
/**
|
|
1013
|
+
* Returns the semantic tree model when semantics are enabled, or null.
|
|
1014
|
+
* The overlay and external consumers use this to inspect the
|
|
1015
|
+
* current state of the semantic tree.
|
|
1016
|
+
*/
|
|
1017
|
+
get semanticTree(): SemanticTreeModel | null;
|
|
1018
|
+
/**
|
|
1019
|
+
* Returns the accessibility overlay when semantics are enabled, or null.
|
|
1020
|
+
* External consumers can use this to inspect the
|
|
1021
|
+
* current state of the accessibility overlay for this instance.
|
|
1022
|
+
*/
|
|
1023
|
+
get accessibilityOverlay(): AccessibilityOverlay | null;
|
|
1024
|
+
get animationNames(): string[];
|
|
1025
|
+
/**
|
|
1026
|
+
* Returns a list of state machine names from the current artboard
|
|
1027
|
+
*/
|
|
1028
|
+
get stateMachineNames(): string[];
|
|
1029
|
+
/**
|
|
1030
|
+
* Returns the inputs for the specified instanced state machine, or an empty
|
|
1031
|
+
* list if the name is invalid or the state machine is not instanced. Returns
|
|
1032
|
+
* undefined if the file is not loaded yet.
|
|
1033
|
+
*
|
|
1034
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
1035
|
+
* properties instead. See
|
|
1036
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
1037
|
+
* for how to migrate.
|
|
1038
|
+
* @param name the state machine name
|
|
1039
|
+
* @returns the inputs for the named state machine or undefined
|
|
1040
|
+
*/
|
|
1041
|
+
stateMachineInputs(name: string): StateMachineInput[] | undefined;
|
|
1042
|
+
private retrieveInputAtPath;
|
|
1043
|
+
/**
|
|
1044
|
+
* Set the boolean input with the provided name at the given path with value
|
|
1045
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
1046
|
+
* properties instead. See
|
|
1047
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
1048
|
+
* for how to migrate.
|
|
1049
|
+
* @param input the state machine input name
|
|
1050
|
+
* @param value the value to set the input to
|
|
1051
|
+
* @param path the path the input is located at an artboard level
|
|
1052
|
+
*/
|
|
1053
|
+
setBooleanStateAtPath(inputName: string, value: boolean, path: string): void;
|
|
1054
|
+
/**
|
|
1055
|
+
* Set the number input with the provided name at the given path with value
|
|
1056
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
1057
|
+
* properties instead. See
|
|
1058
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
1059
|
+
* for how to migrate.
|
|
1060
|
+
* @param input the state machine input name
|
|
1061
|
+
* @param value the value to set the input to
|
|
1062
|
+
* @param path the path the input is located at an artboard level
|
|
1063
|
+
*/
|
|
1064
|
+
setNumberStateAtPath(inputName: string, value: number, path: string): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Fire the trigger with the provided name at the given path
|
|
1067
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
1068
|
+
* properties instead. See
|
|
1069
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
1070
|
+
* for how to migrate.
|
|
1071
|
+
* @param input the state machine input name
|
|
1072
|
+
* @param path the path the input is located at an artboard level
|
|
1073
|
+
*/
|
|
1074
|
+
fireStateAtPath(inputName: string, path: string): void;
|
|
1075
|
+
private retrieveTextAtPath;
|
|
1076
|
+
/**
|
|
1077
|
+
* Retrieves the text value for a specified text run at a given path
|
|
1078
|
+
* @param textName The name of the text run
|
|
1079
|
+
* @param path The path to the text run within the artboard
|
|
1080
|
+
* @returns The text value of the text run, or undefined if not found
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* // Get the text value for a text run named "title" at one nested artboard deep
|
|
1084
|
+
* const titleText = riveInstance.getTextRunValueAtPath("title", "artboard1");
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* // Get the text value for a text run named "subtitle" within a nested group two artboards deep
|
|
1088
|
+
* const subtitleText = riveInstance.getTextRunValueAtPath("subtitle", "group/nestedGroup");
|
|
1089
|
+
*
|
|
1090
|
+
* @remarks
|
|
1091
|
+
* If the text run cannot be found at the specified path, a warning will be logged to the console.
|
|
1092
|
+
*
|
|
1093
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
1094
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
1095
|
+
* for how to migrate.
|
|
1096
|
+
*/
|
|
1097
|
+
getTextRunValueAtPath(textName: string, path: string): string | undefined;
|
|
1098
|
+
/**
|
|
1099
|
+
* Sets the text value for a specified text run at a given path
|
|
1100
|
+
* @param textName The name of the text run
|
|
1101
|
+
* @param value The new text value to set
|
|
1102
|
+
* @param path The path to the text run within the artboard
|
|
1103
|
+
* @returns void
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* // Set the text value for a text run named "title" at one nested artboard deep
|
|
1107
|
+
* riveInstance.setTextRunValueAtPath("title", "New Title", "artboard1");
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* // Set the text value for a text run named "subtitle" within a nested group two artboards deep
|
|
1111
|
+
* riveInstance.setTextRunValueAtPath("subtitle", "New Subtitle", "group/nestedGroup");
|
|
1112
|
+
*
|
|
1113
|
+
* @remarks
|
|
1114
|
+
* If the text run cannot be found at the specified path, a warning will be logged to the console.
|
|
1115
|
+
*
|
|
1116
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
1117
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
1118
|
+
* for how to migrate.
|
|
1119
|
+
*/
|
|
1120
|
+
setTextRunValueAtPath(textName: string, value: string, path: string): void;
|
|
1121
|
+
get playingStateMachineNames(): string[];
|
|
1122
|
+
get playingAnimationNames(): string[];
|
|
1123
|
+
get pausedAnimationNames(): string[];
|
|
1124
|
+
/**
|
|
1125
|
+
* Returns a list of paused machine names
|
|
1126
|
+
* @returns a list of state machine names that are paused
|
|
1127
|
+
*/
|
|
1128
|
+
get pausedStateMachineNames(): string[];
|
|
1129
|
+
/**
|
|
1130
|
+
* @returns true if any animation is playing
|
|
1131
|
+
*/
|
|
1132
|
+
get isPlaying(): boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* @returns true if all instanced animations are paused
|
|
1135
|
+
*/
|
|
1136
|
+
get isPaused(): boolean;
|
|
1137
|
+
/**
|
|
1138
|
+
* @returns true if no animations are playing or paused
|
|
1139
|
+
*/
|
|
1140
|
+
get isStopped(): boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* @returns the bounds of the current artboard, or undefined if the artboard
|
|
1143
|
+
* isn't loaded yet.
|
|
1144
|
+
*/
|
|
1145
|
+
get bounds(): Bounds;
|
|
1146
|
+
/**
|
|
1147
|
+
* Subscribe to Rive-generated events
|
|
1148
|
+
*
|
|
1149
|
+
* Note: subscribing to {@link EventType.RiveEvent},
|
|
1150
|
+
* {@link EventType.StateChange}, or {@link EventType.Loop} is deprecated;
|
|
1151
|
+
* use data binding instead. See
|
|
1152
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} (Rive Events) and
|
|
1153
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide} for how
|
|
1154
|
+
* to migrate Rive graphics to a data binding workflow instead.
|
|
1155
|
+
* @param type the type of event to subscribe to
|
|
1156
|
+
* @param callback callback to fire when the event occurs
|
|
1157
|
+
*/
|
|
1158
|
+
on(type: EventType, callback: EventCallback): void;
|
|
1159
|
+
/**
|
|
1160
|
+
* Unsubscribes from a Rive-generated event
|
|
1161
|
+
* @param type the type of event to unsubscribe from
|
|
1162
|
+
* @param callback the callback to unsubscribe
|
|
1163
|
+
*/
|
|
1164
|
+
off(type: EventType, callback: EventCallback): void;
|
|
1165
|
+
/**
|
|
1166
|
+
* Unsubscribes from a Rive-generated event
|
|
1167
|
+
* @deprecated
|
|
1168
|
+
* @param callback the callback to unsubscribe from
|
|
1169
|
+
*/
|
|
1170
|
+
unsubscribe(type: EventType, callback: EventCallback): void;
|
|
1171
|
+
/**
|
|
1172
|
+
* Unsubscribes all Rive listeners from an event type, or everything if no type is
|
|
1173
|
+
* given
|
|
1174
|
+
* @param type the type of event to unsubscribe from, or all types if
|
|
1175
|
+
* undefined
|
|
1176
|
+
*/
|
|
1177
|
+
removeAllRiveEventListeners(type?: EventType): void;
|
|
1178
|
+
/**
|
|
1179
|
+
* Unsubscribes all listeners from an event type, or everything if no type is
|
|
1180
|
+
* given
|
|
1181
|
+
* @deprecated
|
|
1182
|
+
* @param type the type of event to unsubscribe from, or all types if
|
|
1183
|
+
* undefined
|
|
1184
|
+
*/
|
|
1185
|
+
unsubscribeAll(type?: EventType): void;
|
|
1186
|
+
/**
|
|
1187
|
+
* Stops the rendering loop; this is different from pausing in that it doesn't
|
|
1188
|
+
* change the state of any animation. It stops rendering from occurring. This
|
|
1189
|
+
* is designed for situations such as when Rive isn't visible.
|
|
1190
|
+
*
|
|
1191
|
+
* The only way to start rendering again is to call `startRendering`.
|
|
1192
|
+
* Animations that are marked as playing will start from the position that
|
|
1193
|
+
* they would have been at if rendering had not been stopped.
|
|
1194
|
+
*/
|
|
1195
|
+
stopRendering(): void;
|
|
1196
|
+
/**
|
|
1197
|
+
* Starts the rendering loop if it has been previously stopped. If the
|
|
1198
|
+
* renderer is already active, then this will have zero effect.
|
|
1199
|
+
*/
|
|
1200
|
+
startRendering(): void;
|
|
1201
|
+
private scheduleRendering;
|
|
1202
|
+
/**
|
|
1203
|
+
* Called when document.visibilitychange fires (tab change, window minimize, etc.).
|
|
1204
|
+
* Cancels the rAF loop on hide and resets the time reference so that no accumulated time is
|
|
1205
|
+
* applied to state machines when the tab becomes visible again. This prevents state machine
|
|
1206
|
+
* advances with large time deltas when rAF starts up again.
|
|
1207
|
+
*/
|
|
1208
|
+
private _onPageVisibilityChange;
|
|
1209
|
+
/**
|
|
1210
|
+
* Enables frames-per-second (FPS) reporting for the runtime
|
|
1211
|
+
* If no callback is provided, Rive will append a fixed-position div at the top-right corner of
|
|
1212
|
+
* the page with the FPS reading
|
|
1213
|
+
* @param fpsCallback - Callback from the runtime during the RAF loop that supplies the FPS value
|
|
1214
|
+
*/
|
|
1215
|
+
enableFPSCounter(fpsCallback?: FPSCallback): void;
|
|
1216
|
+
/**
|
|
1217
|
+
* Disables frames-per-second (FPS) reporting for the runtime
|
|
1218
|
+
*/
|
|
1219
|
+
disableFPSCounter(): void;
|
|
1220
|
+
/**
|
|
1221
|
+
* Returns the contents of a Rive file: the artboards, animations, and state machines
|
|
1222
|
+
*/
|
|
1223
|
+
get contents(): RiveFileContents;
|
|
1224
|
+
/**
|
|
1225
|
+
* Getter / Setter for the volume of the artboard
|
|
1226
|
+
*/
|
|
1227
|
+
get volume(): number;
|
|
1228
|
+
set volume(value: number);
|
|
1229
|
+
/**
|
|
1230
|
+
* The width of the artboard.
|
|
1231
|
+
*
|
|
1232
|
+
* This will return 0 if the artboard is not loaded yet and a custom
|
|
1233
|
+
* width has not been set.
|
|
1234
|
+
*
|
|
1235
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
1236
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
|
|
1237
|
+
* automatically set.
|
|
1238
|
+
*/
|
|
1239
|
+
get artboardWidth(): number;
|
|
1240
|
+
set artboardWidth(value: number);
|
|
1241
|
+
/**
|
|
1242
|
+
* The height of the artboard.
|
|
1243
|
+
*
|
|
1244
|
+
* This will return 0 if the artboard is not loaded yet and a custom
|
|
1245
|
+
* height has not been set.
|
|
1246
|
+
*
|
|
1247
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
1248
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
|
|
1249
|
+
* automatically set.
|
|
1250
|
+
*/
|
|
1251
|
+
get artboardHeight(): number;
|
|
1252
|
+
set artboardHeight(value: number);
|
|
1253
|
+
/**
|
|
1254
|
+
* Reset the artboard size to its original values.
|
|
1255
|
+
*/
|
|
1256
|
+
resetArtboardSize(): void;
|
|
1257
|
+
/**
|
|
1258
|
+
* The device pixel ratio used in rendering and canvas/artboard resizing.
|
|
1259
|
+
*
|
|
1260
|
+
* This value will be overidden by the device pixel ratio used in
|
|
1261
|
+
* {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
|
|
1262
|
+
*/
|
|
1263
|
+
get devicePixelRatioUsed(): number;
|
|
1264
|
+
set devicePixelRatioUsed(value: number);
|
|
1265
|
+
/**
|
|
1266
|
+
* @experimental (WebGL2 only) Whether inkbleed antialiasing is in effect. Can only be
|
|
1267
|
+
* turned on if `enableInkbleed: true` was passed at construction.
|
|
1268
|
+
*/
|
|
1269
|
+
get inkbleed(): boolean;
|
|
1270
|
+
set inkbleed(value: boolean);
|
|
1271
|
+
private applyInkbleed;
|
|
1272
|
+
private reportDisplayScale;
|
|
1273
|
+
/**
|
|
1274
|
+
* Sets the main view model instance and applies it (rebinds). Equivalent to
|
|
1275
|
+
* `setViewModelInstance(vmi)` followed by `bind()`.
|
|
1276
|
+
*/
|
|
1277
|
+
bindViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
|
|
1278
|
+
/**
|
|
1279
|
+
* Sets the main view model instance in the data context WITHOUT rebinding.
|
|
1280
|
+
* Call {@link bind} to apply. Use this with {@link setGlobalViewModelInstance}
|
|
1281
|
+
* to batch multiple changes into a single rebind.
|
|
1282
|
+
*/
|
|
1283
|
+
setViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
|
|
1284
|
+
/**
|
|
1285
|
+
* Applies any pending `set*` view model instance changes by rebinding the
|
|
1286
|
+
* data binds once.
|
|
1287
|
+
* Implicitly creates and binds any view models that have not been set.
|
|
1288
|
+
*/
|
|
1289
|
+
bind(): void;
|
|
1290
|
+
get viewModelInstance(): ViewModelInstance | null;
|
|
1291
|
+
/**
|
|
1292
|
+
* Sets (or replaces) the global view model instance for the given global view
|
|
1293
|
+
* model name in the data context WITHOUT rebinding. The main instance and any
|
|
1294
|
+
* other globals keep their order. Call {@link bind} to apply — batch several
|
|
1295
|
+
* `set*` calls then a single `bind()` to avoid rebinding per set.
|
|
1296
|
+
* @param name - the name of the global view model
|
|
1297
|
+
* @param viewModelInstance - the instance to set for that global
|
|
1298
|
+
* @returns whether the instance was set (false if `name` does not match a
|
|
1299
|
+
* global view model in the file)
|
|
1300
|
+
*/
|
|
1301
|
+
setGlobalViewModelInstance(name: string, viewModelInstance: ViewModelInstance): boolean;
|
|
1302
|
+
/**
|
|
1303
|
+
* @param name - the name of the global view model
|
|
1304
|
+
* @returns the global view model instance bound under the given name — the
|
|
1305
|
+
* instance set via {@link setGlobalViewModelInstance} or one created by
|
|
1306
|
+
* auto-bind — or null if none has been set/created for that name (globals are
|
|
1307
|
+
* not auto-created; the getter never creates one).
|
|
1308
|
+
*/
|
|
1309
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
1310
|
+
/**
|
|
1311
|
+
* @returns the names of the file's global view models, in file order. Use
|
|
1312
|
+
* these with {@link setGlobalViewModelInstance} / {@link globalViewModelInstance}.
|
|
1313
|
+
*/
|
|
1314
|
+
globalViewModelNames(): string[];
|
|
1315
|
+
viewModelByIndex(index: number): ViewModel | null;
|
|
1316
|
+
viewModelByName(name: string): ViewModel | null;
|
|
1317
|
+
enums(): DataEnum[];
|
|
1318
|
+
defaultViewModel(): ViewModel | null;
|
|
1319
|
+
/**
|
|
1320
|
+
* @deprecated This function is deprecated. For better stability and memory management
|
|
1321
|
+
* use `getBindableArtboard()` instead.
|
|
1322
|
+
* @param {string} name - The name of the artboard.
|
|
1323
|
+
* @returns {Artboard} The artboard to bind to.
|
|
1324
|
+
*/
|
|
1325
|
+
getArtboard(name: string): Artboard | null;
|
|
1326
|
+
getBindableArtboard(name: string): BindableArtboard | null;
|
|
1327
|
+
getDefaultBindableArtboard(): BindableArtboard | null;
|
|
1328
|
+
/**
|
|
1329
|
+
* Clear focus applicable to active state machines with focus nodes. Useful if users want to
|
|
1330
|
+
* reset focus state and behavior within the Rive graphic at any point (i.e. blurring off the canvas)
|
|
1331
|
+
*/
|
|
1332
|
+
clearFocus(): void;
|
|
1333
|
+
}
|
|
1334
|
+
export declare enum DataType {
|
|
1335
|
+
none = "none",
|
|
1336
|
+
string = "string",
|
|
1337
|
+
number = "number",
|
|
1338
|
+
boolean = "boolean",
|
|
1339
|
+
color = "color",
|
|
1340
|
+
list = "list",
|
|
1341
|
+
enumType = "enumType",
|
|
1342
|
+
trigger = "trigger",
|
|
1343
|
+
viewModel = "viewModel",
|
|
1344
|
+
integer = "integer",
|
|
1345
|
+
listIndex = "listIndex",
|
|
1346
|
+
image = "image",
|
|
1347
|
+
artboard = "artboard"
|
|
1348
|
+
}
|
|
1349
|
+
export declare class ViewModel {
|
|
1350
|
+
private _viewModel;
|
|
1351
|
+
constructor(viewModel: rc.ViewModel);
|
|
1352
|
+
get instanceCount(): number;
|
|
1353
|
+
get name(): string;
|
|
1354
|
+
instanceByIndex(index: number): ViewModelInstance | null;
|
|
1355
|
+
instanceByName(name: string): ViewModelInstance | null;
|
|
1356
|
+
defaultInstance(): ViewModelInstance | null;
|
|
1357
|
+
instance(): ViewModelInstance;
|
|
1358
|
+
get properties(): rc.ViewModelProperty[];
|
|
1359
|
+
get instanceNames(): string[];
|
|
1360
|
+
}
|
|
1361
|
+
export declare class DataEnum {
|
|
1362
|
+
private _dataEnum;
|
|
1363
|
+
constructor(dataEnum: rc.DataEnum);
|
|
1364
|
+
get name(): string;
|
|
1365
|
+
get values(): string[];
|
|
1366
|
+
}
|
|
1367
|
+
export declare class ViewModelInstance {
|
|
1368
|
+
private _runtimeInstance;
|
|
1369
|
+
private _parents;
|
|
1370
|
+
private _children;
|
|
1371
|
+
private _viewModelInstances;
|
|
1372
|
+
private _propertiesWithCallbacks;
|
|
1373
|
+
private _referenceCount;
|
|
1374
|
+
selfUnref: boolean;
|
|
1375
|
+
constructor(runtimeInstance: rc.ViewModelInstance, parent: ViewModelInstance | null);
|
|
1376
|
+
get runtimeInstance(): rc.ViewModelInstance | null;
|
|
1377
|
+
get nativeInstance(): rc.ViewModelInstance | null;
|
|
1378
|
+
handleCallbacks(): void;
|
|
1379
|
+
addParent(parent: ViewModelInstance): void;
|
|
1380
|
+
removeParent(parent: ViewModelInstance): void;
|
|
1381
|
+
addToPropertyCallbacks(property: ViewModelInstanceValue): void;
|
|
1382
|
+
removeFromPropertyCallbacks(property: ViewModelInstanceValue): void;
|
|
1383
|
+
addToViewModelCallbacks(instance: ViewModelInstance): void;
|
|
1384
|
+
removeFromViewModelCallbacks(instance: ViewModelInstance): void;
|
|
1385
|
+
private clearCallbacks;
|
|
1386
|
+
private propertyFromPath;
|
|
1387
|
+
private viewModelFromPathSegments;
|
|
1388
|
+
private propertyFromPathSegments;
|
|
1389
|
+
private internalViewModelInstance;
|
|
1390
|
+
/**
|
|
1391
|
+
* method to access a property instance of type number belonging
|
|
1392
|
+
* to the view model instance or to a nested view model instance
|
|
1393
|
+
* @param path - path to the number property
|
|
1394
|
+
*/
|
|
1395
|
+
number(path: string): ViewModelInstanceNumber | null;
|
|
1396
|
+
/**
|
|
1397
|
+
* method to access a property instance of type string belonging
|
|
1398
|
+
* to the view model instance or to a nested view model instance
|
|
1399
|
+
* @param path - path to the string property
|
|
1400
|
+
*/
|
|
1401
|
+
string(path: string): ViewModelInstanceString | null;
|
|
1402
|
+
/**
|
|
1403
|
+
* method to access a property instance of type boolean belonging
|
|
1404
|
+
* to the view model instance or to a nested view model instance
|
|
1405
|
+
* @param path - path to the boolean property
|
|
1406
|
+
*/
|
|
1407
|
+
boolean(path: string): ViewModelInstanceBoolean | null;
|
|
1408
|
+
/**
|
|
1409
|
+
* method to access a property instance of type color belonging
|
|
1410
|
+
* to the view model instance or to a nested view model instance
|
|
1411
|
+
* @param path - path to the ttrigger property
|
|
1412
|
+
*/
|
|
1413
|
+
color(path: string): ViewModelInstanceColor | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* method to access a property instance of type trigger belonging
|
|
1416
|
+
* to the view model instance or to a nested view model instance
|
|
1417
|
+
* @param path - path to the trigger property
|
|
1418
|
+
*/
|
|
1419
|
+
trigger(path: string): ViewModelInstanceTrigger | null;
|
|
1420
|
+
/**
|
|
1421
|
+
* method to access a property instance of type enum belonging
|
|
1422
|
+
* to the view model instance or to a nested view model instance
|
|
1423
|
+
* @param path - path to the enum property
|
|
1424
|
+
*/
|
|
1425
|
+
enum(path: string): ViewModelInstanceEnum | null;
|
|
1426
|
+
/**
|
|
1427
|
+
* method to access a property instance of type list belonging
|
|
1428
|
+
* to the view model instance or to a nested view model instance
|
|
1429
|
+
* @param path - path to the list property
|
|
1430
|
+
*/
|
|
1431
|
+
list(path: string): ViewModelInstanceList | null;
|
|
1432
|
+
/**
|
|
1433
|
+
* method to access a view model property instance belonging
|
|
1434
|
+
* to the view model instance or to a nested view model instance
|
|
1435
|
+
* @param path - path to the image property
|
|
1436
|
+
*/
|
|
1437
|
+
image(path: string): ViewModelInstanceAssetImage | null;
|
|
1438
|
+
/**
|
|
1439
|
+
* method to access a view model property instance belonging
|
|
1440
|
+
* to the view model instance or to a nested view model instance
|
|
1441
|
+
* @param path - path to the font property
|
|
1442
|
+
*/
|
|
1443
|
+
font(path: string): ViewModelInstanceAssetFont | null;
|
|
1444
|
+
/**
|
|
1445
|
+
* method to access an artboard property instance belonging
|
|
1446
|
+
* to the view model instance or to a nested view model instance
|
|
1447
|
+
* @param path - path to the image property
|
|
1448
|
+
*/
|
|
1449
|
+
artboard(path: string): ViewModelInstanceArtboard | null;
|
|
1450
|
+
/**
|
|
1451
|
+
* method to access a view model property instance belonging
|
|
1452
|
+
* to the view model instance or to a nested view model instance
|
|
1453
|
+
* @param path - path to the view model property
|
|
1454
|
+
*/
|
|
1455
|
+
viewModel(path: string): ViewModelInstance | null;
|
|
1456
|
+
internalReplaceViewModel(name: string, value: ViewModelInstance): boolean;
|
|
1457
|
+
/**
|
|
1458
|
+
* method to replace a view model property with another view model value
|
|
1459
|
+
* @param path - path to the view model property
|
|
1460
|
+
* @param value - view model that will replace the original
|
|
1461
|
+
*/
|
|
1462
|
+
replaceViewModel(path: string, value: ViewModelInstance): boolean;
|
|
1463
|
+
incrementReferenceCount(): void;
|
|
1464
|
+
decrementReferenceCount(): void;
|
|
1465
|
+
get properties(): rc.ViewModelProperty[];
|
|
1466
|
+
/**
|
|
1467
|
+
* Get the name of the ViewModel definition this instance was created from.
|
|
1468
|
+
*/
|
|
1469
|
+
get viewModelName(): string;
|
|
1470
|
+
internalIncrementReferenceCount(): void;
|
|
1471
|
+
cleanup(): void;
|
|
1472
|
+
}
|
|
1473
|
+
export declare class ViewModelInstanceValue {
|
|
1474
|
+
protected _parentViewModel: ViewModelInstance;
|
|
1475
|
+
protected callbacks: EventCallback[];
|
|
1476
|
+
protected _viewModelInstanceValue: rc.ViewModelInstanceValue;
|
|
1477
|
+
constructor(instance: rc.ViewModelInstanceValue, parent: ViewModelInstance);
|
|
1478
|
+
on(callback: EventCallback): void;
|
|
1479
|
+
off(callback?: EventCallback): void;
|
|
1480
|
+
internalHandleCallback(callback: Function): void;
|
|
1481
|
+
handleCallbacks(): void;
|
|
1482
|
+
clearChanges(): void;
|
|
1483
|
+
clearCallbacks(): void;
|
|
1484
|
+
get name(): string;
|
|
1485
|
+
}
|
|
1486
|
+
export declare class ViewModelInstanceString extends ViewModelInstanceValue {
|
|
1487
|
+
constructor(instance: rc.ViewModelInstanceString, parent: ViewModelInstance);
|
|
1488
|
+
get value(): string;
|
|
1489
|
+
set value(val: string);
|
|
1490
|
+
internalHandleCallback(callback: Function): void;
|
|
1491
|
+
}
|
|
1492
|
+
export declare class ViewModelInstanceNumber extends ViewModelInstanceValue {
|
|
1493
|
+
constructor(instance: rc.ViewModelInstanceNumber, parent: ViewModelInstance);
|
|
1494
|
+
get value(): number;
|
|
1495
|
+
set value(val: number);
|
|
1496
|
+
internalHandleCallback(callback: Function): void;
|
|
1497
|
+
}
|
|
1498
|
+
export declare class ViewModelInstanceBoolean extends ViewModelInstanceValue {
|
|
1499
|
+
constructor(instance: rc.ViewModelInstanceBoolean, parent: ViewModelInstance);
|
|
1500
|
+
get value(): boolean;
|
|
1501
|
+
set value(val: boolean);
|
|
1502
|
+
internalHandleCallback(callback: Function): void;
|
|
1503
|
+
}
|
|
1504
|
+
export declare class ViewModelInstanceTrigger extends ViewModelInstanceValue {
|
|
1505
|
+
constructor(instance: rc.ViewModelInstanceTrigger, parent: ViewModelInstance);
|
|
1506
|
+
trigger(): void;
|
|
1507
|
+
internalHandleCallback(callback: Function): void;
|
|
1508
|
+
}
|
|
1509
|
+
export declare class ViewModelInstanceEnum extends ViewModelInstanceValue {
|
|
1510
|
+
constructor(instance: rc.ViewModelInstanceEnum, parent: ViewModelInstance);
|
|
1511
|
+
get value(): string;
|
|
1512
|
+
set value(val: string);
|
|
1513
|
+
set valueIndex(val: number);
|
|
1514
|
+
get valueIndex(): number;
|
|
1515
|
+
get values(): string[];
|
|
1516
|
+
internalHandleCallback(callback: Function): void;
|
|
1517
|
+
}
|
|
1518
|
+
export declare class ViewModelInstanceList extends ViewModelInstanceValue {
|
|
1519
|
+
constructor(instance: rc.ViewModelInstanceList, parent: ViewModelInstance);
|
|
1520
|
+
get length(): number;
|
|
1521
|
+
addInstance(instance: ViewModelInstance): void;
|
|
1522
|
+
addInstanceAt(instance: ViewModelInstance, index: number): boolean;
|
|
1523
|
+
removeInstance(instance: ViewModelInstance): void;
|
|
1524
|
+
removeInstanceAt(index: number): void;
|
|
1525
|
+
instanceAt(index: number): ViewModelInstance | null;
|
|
1526
|
+
swap(a: number, b: number): void;
|
|
1527
|
+
internalHandleCallback(callback: Function): void;
|
|
1528
|
+
}
|
|
1529
|
+
export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
|
|
1530
|
+
constructor(instance: rc.ViewModelInstanceColor, parent: ViewModelInstance);
|
|
1531
|
+
get value(): number;
|
|
1532
|
+
set value(val: number);
|
|
1533
|
+
rgb(r: number, g: number, b: number): void;
|
|
1534
|
+
rgba(r: number, g: number, b: number, a: number): void;
|
|
1535
|
+
argb(a: number, r: number, g: number, b: number): void;
|
|
1536
|
+
alpha(a: number): void;
|
|
1537
|
+
opacity(o: number): void;
|
|
1538
|
+
internalHandleCallback(callback: Function): void;
|
|
1539
|
+
}
|
|
1540
|
+
export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
|
|
1541
|
+
constructor(instance: rc.ViewModelInstanceAssetImage, root: ViewModelInstance);
|
|
1542
|
+
set value(image: rc.Image | null);
|
|
1543
|
+
internalHandleCallback(callback: Function): void;
|
|
1544
|
+
}
|
|
1545
|
+
export declare class ViewModelInstanceAssetFont extends ViewModelInstanceValue {
|
|
1546
|
+
constructor(instance: rc.ViewModelInstanceAssetFont, root: ViewModelInstance);
|
|
1547
|
+
set value(font: rc.Font | null);
|
|
1548
|
+
internalHandleCallback(callback: Function): void;
|
|
1549
|
+
}
|
|
1550
|
+
export declare class ViewModelInstanceArtboard extends ViewModelInstanceValue {
|
|
1551
|
+
constructor(instance: rc.ViewModelInstanceArtboard, root: ViewModelInstance);
|
|
1552
|
+
set value(artboard: BaseArtboard | null);
|
|
1553
|
+
internalHandleCallback(callback: Function): void;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Contents of a state machine input
|
|
1557
|
+
*/
|
|
1558
|
+
interface StateMachineInputContents {
|
|
1559
|
+
name: string;
|
|
1560
|
+
type: StateMachineInputType;
|
|
1561
|
+
initialValue?: boolean | number;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Contents of a state machine
|
|
1565
|
+
*/
|
|
1566
|
+
interface StateMachineContents {
|
|
1567
|
+
name: string;
|
|
1568
|
+
inputs: StateMachineInputContents[];
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Contents of an artboard
|
|
1572
|
+
*/
|
|
1573
|
+
interface ArtboardContents {
|
|
1574
|
+
animations: string[];
|
|
1575
|
+
stateMachines: StateMachineContents[];
|
|
1576
|
+
name: string;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* contents of a Rive file
|
|
1580
|
+
*/
|
|
1581
|
+
interface RiveFileContents {
|
|
1582
|
+
artboards?: ArtboardContents[];
|
|
1583
|
+
}
|
|
1584
|
+
export declare const Testing: {
|
|
1585
|
+
EventManager: typeof EventManager;
|
|
1586
|
+
TaskQueueManager: typeof TaskQueueManager;
|
|
1587
|
+
};
|
|
1588
|
+
/**
|
|
1589
|
+
* Decodes bytes into an audio asset.
|
|
1590
|
+
*
|
|
1591
|
+
* Be sure to call `.unref()` on the audio once it is no longer needed. This
|
|
1592
|
+
* allows the engine to clean it up when it is not used by any more animations.
|
|
1593
|
+
*/
|
|
1594
|
+
export declare const decodeAudio: (bytes: Uint8Array) => Promise<AudioWrapper>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Decodes bytes into an image.
|
|
1597
|
+
*
|
|
1598
|
+
* Be sure to call `.unref()` on the image once it is no longer needed. This
|
|
1599
|
+
* allows the engine to clean it up when it is not used by any more animations.
|
|
1600
|
+
*/
|
|
1601
|
+
export declare const decodeImage: (bytes: Uint8Array) => Promise<ImageWrapper>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Decodes bytes into a font.
|
|
1604
|
+
*
|
|
1605
|
+
* Be sure to call `.unref()` on the font once it is no longer needed. This
|
|
1606
|
+
* allows the engine to clean it up when it is not used by any more animations.
|
|
1607
|
+
*/
|
|
1608
|
+
export declare const decodeFont: (bytes: Uint8Array) => Promise<FontWrapper>;
|