@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.
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ import * as rc from "./rive_advanced.mjs";
2
+ export type RuntimeCallback = (rive: rc.RiveCanvas) => void;
3
+ export declare class RuntimeLoader {
4
+ private static runtime;
5
+ private static isLoading;
6
+ private static callBackQueue;
7
+ private static rive;
8
+ private static wasmURL;
9
+ private static wasmFallbackURL;
10
+ private static wasmBinary;
11
+ private static wasmThreadsURL;
12
+ private static triedThreads;
13
+ private static errorCallbackQueue;
14
+ private constructor();
15
+ /**
16
+ * When true, performance.mark / performance.measure entries are emitted for
17
+ * WASM initialization.
18
+ */
19
+ static enablePerfMarks: boolean;
20
+ private static notifyError;
21
+ private static loaded;
22
+ private static loadRuntime;
23
+ private static loadUnthreaded;
24
+ static getInstance(callback: RuntimeCallback, onError?: (error: Error) => void): void;
25
+ static awaitInstance(): Promise<rc.RiveCanvas>;
26
+ static setWasmUrl(url: string): void;
27
+ static getWasmUrl(): string;
28
+ /**
29
+ * Sets the URL used as a fallback when the primary WASM URL fails to load.
30
+ * Pass `null` to disable the fallback entirely.
31
+ *
32
+ * Defaults to pulling from the jsdelivr CDN.
33
+ */
34
+ static setWasmFallbackUrl(url: string | null): void;
35
+ static getWasmFallbackUrl(): string | null;
36
+ /**
37
+ * Sets the URL of the threaded build's wasm, which
38
+ * `@rive-app/webgl2-threads` loads on a cross origin isolated page. Pass
39
+ * `null` to always load the build without threads. Other packages have no
40
+ * threaded build and ignore it.
41
+ *
42
+ * Defaults to pulling from the unpkg CDN.
43
+ */
44
+ static setWasmThreadsUrl(url: string | null): void;
45
+ static getWasmThreadsUrl(): string | null;
46
+ static setWasmBinary(value: ArrayBuffer | null): void;
47
+ static getWasmBinary(): ArrayBuffer | null;
48
+ }
@@ -0,0 +1,272 @@
1
+ import type * as rc from "../rive_advanced.mjs";
2
+ import type { SemanticTreeModel } from "./semanticTreeModel";
3
+ import { SemanticActionType, RiveSemanticsOptions } from "./types";
4
+ export interface AccessibilityOverlayOptions {
5
+ canvas: HTMLCanvasElement;
6
+ /** Unique string per Rive instance (used for prefixed IDs). */
7
+ instanceId: string;
8
+ /** Optional options for controlling semantic tree behavior and rendering */
9
+ semanticsOptions: RiveSemanticsOptions;
10
+ /** Callback to fire a semantic action back into the state machine. */
11
+ fireAction: (nodeId: number, actionType: SemanticActionType) => void;
12
+ /** Callback when AT focuses a semantic node (routes to SemanticManager::requestFocus). */
13
+ requestFocus: (nodeId: number) => void;
14
+ /** Callback when AT focus leaves a semantic node. */
15
+ clearFocus: () => void;
16
+ /**
17
+ * When false (default), the overlay only moves focus while focus is already
18
+ * inside Rive (overlay or canvas); when true it may also pull focus from outside Rive.
19
+ */
20
+ allowFocusInterrupt?: boolean;
21
+ /**
22
+ * True while a text input session holds DOM focus on the hidden text-input proxy.
23
+ * Defaults to false when text input isn't wired.
24
+ */
25
+ isEditingHostFocused?: () => boolean;
26
+ }
27
+ /**
28
+ * Indication of what changed since the last overlay update.
29
+ *
30
+ * - `semanticChanged` — semantic tree content/structure changed; attributes,
31
+ * DOM order, and stale removal need reconciling.
32
+ * - `nodeGeometryChanged` — node bounds changed in the tree model.
33
+ * - `layoutChanged` — canvas size/position changed (or the transform container
34
+ * hasn't been created yet); the artboard→canvas transform must be recomputed.
35
+ */
36
+ export interface OverlayChange {
37
+ semanticChanged: boolean;
38
+ nodeGeometryChanged: boolean;
39
+ layoutChanged: boolean;
40
+ }
41
+ /**
42
+ * What the overlay needs from the element capturing text for a focused Rive text
43
+ * field (the hidden text-input proxy).
44
+ */
45
+ export interface EditingHost {
46
+ /** Apply accessibility attributes; a null value removes that attribute. */
47
+ decorate(attrs: Record<string, string | null>): void;
48
+ resetDecoration(): void;
49
+ /** Capture as a secure (password) field while standing in for an obscured one. */
50
+ setSecure(secure: boolean): void;
51
+ hasDomFocus(): boolean;
52
+ }
53
+ /**
54
+ * Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
55
+ * screen readers to discover and interact with the Rive content.
56
+ *
57
+ * Each semantic node in the {@link SemanticTreeModel} gets a corresponding
58
+ * DOM element with appropriate ARIA role, states, and action handlers so
59
+ * assistive technologies (i.e. screen readers) can discover
60
+ * and interact with the Rive content.
61
+ *
62
+ * Each node receives a prefixed ID (`id=rive-{instanceId}-sem-{nodeId}`) to avoid host-page ID collisions.
63
+ * The nodeID is Rive's semantic node ID from core runtime.
64
+ * Each node is styled with `pointer-events: none`. Interactive nodes can receive
65
+ * programmatic focus and keydown events without entering the browser Tab order.
66
+ */
67
+ export declare class AccessibilityOverlay {
68
+ private container;
69
+ private canvas;
70
+ private semanticsOptions;
71
+ private elements;
72
+ /** Visually-hidden description spans keyed by node ID, referenced by aria-describedby. */
73
+ private descElements;
74
+ private instanceId;
75
+ private fireAction;
76
+ private requestFocus;
77
+ private clearFocus;
78
+ private lastSemanticVersion;
79
+ private lastGeometryVersion;
80
+ /** Text elements whose fit-scale needs recomputing, batched per update (see flushTextGeometry). */
81
+ private pendingTextGeometry;
82
+ /** Last measured box-size|text key per text element, to skip redundant re-measures. */
83
+ private textGeometryKeys;
84
+ /** Node data last passed to applyAttributes per element; see {@link setEditingHostNode}. */
85
+ private appliedNodes;
86
+ private lastCanvasPositioning;
87
+ /**
88
+ * Set when a ResizeObserver/window-resize signals the canvas geometry may have
89
+ * changed, cleared once the transform is re-synced. Lets {@link needsUpdate}
90
+ * report geometry changes without a per-frame `getBoundingClientRect()` reflow.
91
+ * Starts true so the first update computes the transform.
92
+ */
93
+ private _geometryDirty;
94
+ /** True while reconciling the DOM (reserved for future focus-sync guards). */
95
+ private isUpdating;
96
+ /** See {@link AccessibilityOverlayOptions.allowFocusInterrupt}. */
97
+ private allowFocusInterrupt;
98
+ /** See {@link AccessibilityOverlayOptions.isEditingHostFocused}. */
99
+ private isEditingHostFocused;
100
+ /** Node whose element the editing host stands in for, or null. */
101
+ private editingHostNodeId;
102
+ /** Semantic version last folded into the editing host's decoration. */
103
+ private editingHostSemanticVersion;
104
+ /**
105
+ * Single child div of the overlay container that carries the artboard→CSS
106
+ * transform. All semantic node elements are children of this div and express
107
+ * their positions in raw artboard-space coordinates. The CSS transform on
108
+ * this container maps artboard units to CSS pixels in one GPU pass — no
109
+ * per-node matrix multiplication required.
110
+ */
111
+ private transformContainer;
112
+ private _artboardBounds;
113
+ private repositionTimer;
114
+ private canvasResizeObserver;
115
+ private parentResizeObserver;
116
+ /**
117
+ * Detects canvas *position* drift. See {@link observePosition}.
118
+ */
119
+ private positionObserver;
120
+ private readonly _onWindowResize;
121
+ constructor(options: AccessibilityOverlayOptions);
122
+ /**
123
+ * Hide the stood-in node's element (no duplicate textbox for AT); re-derive the previous
124
+ * one's aria-hidden.
125
+ */
126
+ setEditingHostNode(nodeId: number | null): void;
127
+ /**
128
+ * Describe the focused text field on the host and hide its element; no-op unless
129
+ * semantics changed.
130
+ * @param force - apply even if semantics are unchanged (session start).
131
+ */
132
+ syncEditingHost(tree: SemanticTreeModel, host: EditingHost, force: boolean): void;
133
+ /** True while the editing host stands in for a node's element. */
134
+ hasEditingHost(): boolean;
135
+ /**
136
+ * Undo the stand-in; if the host still has DOM focus, move it to the focused node's
137
+ * element so AT announces it.
138
+ */
139
+ releaseEditingHost(tree: SemanticTreeModel | null, host: EditingHost | null): void;
140
+ /** Move DOM focus onto a node's element. No-op for a node with no element. */
141
+ focusNodeElement(nodeId: number): void;
142
+ private focusElementInPlace;
143
+ getSemanticOverlayContainer(): HTMLDivElement;
144
+ private attachPositionObservers;
145
+ /**
146
+ * Arms an IntersectionObserver whose root box is bounded to the canvas, so it
147
+ * fires when the canvas moves relative to the viewport — position drift that
148
+ * no ResizeObserver reports. Lets us re-sync the overlay container on a move
149
+ * instead of recalculating the canvas bounding box every frame.
150
+ */
151
+ private observePosition;
152
+ private scheduleReposition;
153
+ /** Returns true when the container's size changed (node transforms need recomputing). */
154
+ private syncContainerGeometry;
155
+ /**
156
+ * Re-align the container right before focusing one of its elements. The position
157
+ * observer re-syncs after scrolling on a throttle; focusing an element while the
158
+ * container is stale would make the browser scroll the page to where it sits.
159
+ */
160
+ private syncContainerBeforeFocus;
161
+ private createContainer;
162
+ /**
163
+ * Returns what changed since the last update, or null if nothing changed.
164
+ *
165
+ * Callers use this to avoid recomputing the (relatively expensive)
166
+ * artboard→canvas transform on frames where only node bounds changed in the
167
+ * tree: the transform only needs recomputing when `layoutChanged` is true.
168
+ */
169
+ needsUpdate(tree: SemanticTreeModel): OverlayChange | null;
170
+ /**
171
+ * Update the overlay DOM to reflect the current state of the semantic tree.
172
+ * Call once per frame after `applyDiff` when {@link needsUpdate} reports a
173
+ * change, when layout/transform inputs are dirty, or when a fresh
174
+ * `forwardMat` is supplied (even if the tree versions are unchanged).
175
+ *
176
+ * @param tree The in-memory semantic tree model
177
+ * @param forwardMat Artboard→canvas-pixel transform from `computeAlignment`,
178
+ * or null to reuse the existing CSS transform on the
179
+ * transform container
180
+ * @param dpr Device pixel ratio used for the canvas backing store
181
+ * @param artboardBounds The artboard's own bounding rectangle
182
+ */
183
+ update(tree: SemanticTreeModel, forwardMat: rc.Mat2D | null, dpr: number, artboardBounds: rc.AABB, change?: OverlayChange | null): void;
184
+ private performUpdate;
185
+ /** Remove the overlay from the DOM entirely. */
186
+ destroy(): void;
187
+ /**
188
+ * Reconcile a parent DOM element's children with an ordered list of
189
+ * semantic node IDs. Creates, updates, and reorders elements as needed.
190
+ *
191
+ * Node positions are expressed in artboard-space coordinates. The CSS
192
+ * transform on the transform container maps artboard units to CSS pixels,
193
+ * so no per-node matrix multiplication is required here.
194
+ *
195
+ * @param parentArtboardLeft Absolute artboard minX of the parent node (0 for roots)
196
+ * @param parentArtboardTop Absolute artboard minY of the parent node (0 for roots)
197
+ */
198
+ private rebuildChildren;
199
+ /**
200
+ * Reposition only the subtrees whose bounds changed in the latest diff.
201
+ * Descendants are included because node CSS positions are parent-relative.
202
+ */
203
+ private updateGeometryForChangedNodes;
204
+ private updateNodeGeometrySubtree;
205
+ /**
206
+ * Whether the overlay may move focus now. Following focus already inside this
207
+ * instance is always allowed; pulling it in from the host page is gated behind
208
+ * allowFocusInterrupt (from the Rive class).
209
+ */
210
+ private canMoveFocus;
211
+ /**
212
+ * Move focus into a newly appeared modal/alert dialog so screen readers
213
+ * announce and read its content (web ATs don't auto-enter a freshly mounted
214
+ * dialog). Skips when focus can't move (see canMoveFocus) or a descendant
215
+ * already holds it. The dialog's aria-modal keeps focus trapped inside.
216
+ */
217
+ private autoFocusDialogOnAppear;
218
+ /**
219
+ * Resolve the element assistive technologies (AT) should focus on appearance. Walks the subtree
220
+ * depth-first and returns the first focusable node's host element, else the
221
+ * inner <span> of the first labeled leaf. Container and unlabeled nodes are
222
+ * descended into but never focused. Returns null if nothing qualifies.
223
+ */
224
+ private routeDefaultFocusTarget;
225
+ /** Shared `id` prefix for all semantic node elements of this instance. */
226
+ private get nodeIdPrefix();
227
+ /** Recover the semantic node ID from an overlay element, or null. */
228
+ private nodeIdFromElement;
229
+ private createElement;
230
+ /**
231
+ * Wire arrow-key roving focus for a group member (tab, radio). Arrow keys
232
+ * move focus to the next/previous member (wrapping), optionally Home/End jump
233
+ * to first/last, and the newly focused member receives a tap action.
234
+ */
235
+ private attachRovingNav;
236
+ private attachActionHandlers;
237
+ private isAriaHidden;
238
+ private applyAttributes;
239
+ /**
240
+ * Positions an element in artboard-space coordinates relative to its parent.
241
+ *
242
+ * Node bounds stay in raw artboard units — the CSS `transform: matrix(...)`
243
+ * on the transform container maps artboard units to CSS pixels in one GPU
244
+ * pass. No per-node forwardMat multiplication or DPR division needed here.
245
+ *
246
+ * Round to whole artboard units before comparing to avoid triggering AX
247
+ * layout notifications from sub-unit floating-point animation jitter.
248
+ */
249
+ private applyPosition;
250
+ /**
251
+ * Scale each queued text span to fit its layout box, batched so a frame
252
+ * pays at most one synchronous layout: all measurement-reset writes first,
253
+ * then all rect reads, then all transform writes. Interleaving
254
+ * write→read→write per node would force a reflow per text node instead.
255
+ *
256
+ * Nodes whose box size and text are unchanged since the last pass are
257
+ * skipped entirely (their existing transform is still correct — the scale
258
+ * is a ratio of two rects, so ancestor transform changes cancel out).
259
+ */
260
+ private flushTextGeometry;
261
+ /**
262
+ * Creates (on first call) and updates the artboard-space transform container.
263
+ *
264
+ * The container is sized to the artboard dimensions and carries a CSS
265
+ * `transform: matrix(...)` that maps artboard coordinates to the canvas's CSS box
266
+ * (forwardMat in backing-store pixels, scaled by CSS size / backing-store size). All semantic
267
+ * node elements are children of this container and use raw artboard
268
+ * coordinates as their CSS `left/top/width/height`, so the CSS compositor
269
+ * applies the artboard→screen mapping in one pass.
270
+ */
271
+ private syncTransformContainer;
272
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Marks a key event as handled by a semantic overlay widget (and prevents its
3
+ * default), so the Rive keyboard handler leaves it alone. A plain
4
+ * `defaultPrevented` check can't tell these apart from host-page handlers.
5
+ */
6
+ export declare function claimKeyEvent(event: Event): void;
7
+ export declare function isKeyEventClaimed(event: Event): boolean;
@@ -0,0 +1,5 @@
1
+ export { SemanticTreeModel } from "./semanticTreeModel";
2
+ export { AccessibilityOverlay } from "./accessibilityOverlay";
3
+ export type { AccessibilityOverlayOptions } from "./accessibilityOverlay";
4
+ export { SemanticRole, SemanticState, SemanticCheckState, SemanticTrait, SemanticActionType, SemanticMode, CHECK_STATE_OFFSET, CHECK_STATE_MASK, checkStateOf, hasState, hasTrait, roleName, stateNames, traitNames, } from "./types";
5
+ export type { SemanticsDiffNode, SemanticsDiff, SemanticNodeData, RiveSemanticsOptions, } from "./types";
@@ -0,0 +1,66 @@
1
+ import type { SemanticsDiff, SemanticNodeData } from "./types";
2
+ /**
3
+ * Maintains an in-memory semantic tree built from incremental
4
+ * {@link SemanticsDiff} updates received each frame from the WASM runtime.
5
+ *
6
+ * Processing order within {@link applyDiff} follows the contract defined in
7
+ * `semantic_snapshot.hpp`: removed → added → moved → childrenUpdated →
8
+ * updatedSemantic → updatedGeometry.
9
+ */
10
+ export declare class SemanticTreeModel {
11
+ private _nodesById;
12
+ private _roots;
13
+ private _semanticVersion;
14
+ private _geometryVersion;
15
+ private _geometryChangedIds;
16
+ private _semanticChangedIds;
17
+ get nodeCount(): number;
18
+ /** Bumped when semantic content or tree structure changes. */
19
+ get semanticVersion(): number;
20
+ /** Bumped when node bounds change without a semantic/structural change. */
21
+ get geometryVersion(): number;
22
+ /** Node IDs whose bounds changed in the most recent {@link applyDiff}. */
23
+ get geometryChangedIds(): ReadonlySet<number>;
24
+ /**
25
+ * Node IDs whose semantic fields (role/label/value/hint/flags/headingLevel)
26
+ * changed in the most recent {@link applyDiff}. Structural changes (moves,
27
+ * child reorders, removals) bump {@link semanticVersion} but don't mark
28
+ * nodes here — element attributes don't depend on tree position.
29
+ */
30
+ get semanticChangedIds(): ReadonlySet<number>;
31
+ /** Root node IDs in sibling order. */
32
+ get roots(): readonly number[];
33
+ /** Look up a node by its ID, or undefined if not in the tree. */
34
+ nodeById(id: number): SemanticNodeData | undefined;
35
+ /** The node with SemanticState.Focused, or undefined. */
36
+ focusedNode(): SemanticNodeData | undefined;
37
+ /** Current index of a node among its siblings (or roots), or -1 if absent. */
38
+ private siblingIndexOf;
39
+ /** Detach a node from its current parent (or from roots). */
40
+ private detach;
41
+ /** Attach a node under a parent at a given sibling index (or as root). */
42
+ private attach;
43
+ /** Recursively remove a node and all descendants. */
44
+ private removeSubtree;
45
+ /**
46
+ * Apply an incremental diff to the tree. Bumps version counters and notifies
47
+ * listeners only when the tree actually changed.
48
+ *
49
+ * No-op diffs (field values identical to current model) do not bump
50
+ * versions — the native side guards against emitting these, but applyDiff
51
+ * defends its subscribers regardless.
52
+ */
53
+ applyDiff(diff: SemanticsDiff): void;
54
+ private _debug;
55
+ /** Enable/disable debug logging of diffs to the console. */
56
+ set debug(enabled: boolean);
57
+ private logDiff;
58
+ /**
59
+ * Returns every node in depth-first order, paired with its depth level.
60
+ * Useful for debug logging / rendering a flat list.
61
+ */
62
+ flattened(): Array<{
63
+ depth: number;
64
+ node: SemanticNodeData;
65
+ }>;
66
+ }
@@ -0,0 +1,107 @@
1
+ import type { SemanticsDiffNode, SemanticsDiff } from "../rive_advanced.mjs";
2
+ export type { SemanticsDiffNode, SemanticsDiff, };
3
+ export declare const SemanticRole: {
4
+ readonly none: 0;
5
+ readonly button: 1;
6
+ readonly link: 2;
7
+ readonly checkbox: 3;
8
+ readonly switchControl: 4;
9
+ readonly slider: 5;
10
+ readonly textField: 6;
11
+ readonly text: 7;
12
+ readonly image: 8;
13
+ readonly group: 9;
14
+ readonly list: 10;
15
+ readonly listItem: 11;
16
+ readonly tab: 12;
17
+ readonly tabList: 13;
18
+ readonly dialog: 14;
19
+ readonly alertDialog: 15;
20
+ readonly radioGroup: 16;
21
+ readonly radioButton: 17;
22
+ };
23
+ export type SemanticRole = (typeof SemanticRole)[keyof typeof SemanticRole];
24
+ export declare const SemanticState: {
25
+ readonly None: 0;
26
+ readonly Expanded: number;
27
+ readonly Selected: number;
28
+ readonly Toggled: number;
29
+ readonly Required: number;
30
+ readonly Disabled: number;
31
+ readonly Focused: number;
32
+ readonly Hidden: number;
33
+ readonly LiveRegion: number;
34
+ readonly ReadOnly: number;
35
+ readonly Modal: number;
36
+ readonly Obscured: number;
37
+ readonly Multiline: number;
38
+ };
39
+ export declare function hasState(flags: number, state: number): boolean;
40
+ export declare const SemanticCheckState: {
41
+ readonly Unchecked: 0;
42
+ readonly Checked: 1;
43
+ readonly Mixed: 2;
44
+ };
45
+ export type SemanticCheckState = (typeof SemanticCheckState)[keyof typeof SemanticCheckState];
46
+ /** Bit offset of the check field within stateFlags. */
47
+ export declare const CHECK_STATE_OFFSET = 2;
48
+ /** Mask of the check field within stateFlags. */
49
+ export declare const CHECK_STATE_MASK: number;
50
+ /**
51
+ * Decodes the check field out of `flags`. The field is two bits. Returns 0, 1, or 2
52
+ * per the mapping in SemanticCheckState.
53
+ */
54
+ export declare function checkStateOf(flags: number): SemanticCheckState;
55
+ /**
56
+ * Controls when the instance builds semantic trees and accessibility overlays.
57
+ *
58
+ * - `disabled`: no semantics work.
59
+ * - `enabled`: semantics and overlay are active immediately after load.
60
+ */
61
+ export declare const SemanticMode: {
62
+ readonly Disabled: "disabled";
63
+ readonly Enabled: "enabled";
64
+ };
65
+ export type SemanticMode = (typeof SemanticMode)[keyof typeof SemanticMode];
66
+ export interface RiveSemanticsOptions {
67
+ /**
68
+ * aria-label for the semantic DOM container element
69
+ */
70
+ riveCanvasLabel?: string;
71
+ }
72
+ export declare const SemanticTrait: {
73
+ readonly None: 0;
74
+ readonly Expandable: number;
75
+ readonly Selectable: number;
76
+ readonly Checkable: number;
77
+ readonly Toggleable: number;
78
+ readonly Requirable: number;
79
+ readonly Enablable: number;
80
+ readonly Focusable: number;
81
+ };
82
+ export declare function hasTrait(flags: number, trait: number): boolean;
83
+ export declare const SemanticActionType: {
84
+ readonly tap: 0;
85
+ readonly increase: 1;
86
+ readonly decrease: 2;
87
+ };
88
+ export type SemanticActionType = (typeof SemanticActionType)[keyof typeof SemanticActionType];
89
+ export interface SemanticNodeData {
90
+ readonly id: number;
91
+ parentId: number;
92
+ role: number;
93
+ label: string;
94
+ value: string;
95
+ hint: string;
96
+ stateFlags: number;
97
+ traitFlags: number;
98
+ headingLevel: number;
99
+ minX: number;
100
+ minY: number;
101
+ maxX: number;
102
+ maxY: number;
103
+ children: number[];
104
+ }
105
+ export declare function roleName(role: number): string;
106
+ export declare function stateNames(flags: number): string;
107
+ export declare function traitNames(flags: number): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Canvas offset within its offsetParent, minus the scroll of ancestors in between (they
3
+ * move the canvas, not absolutely positioned siblings).
4
+ */
5
+ export declare function canvasOffset(canvas: HTMLElement): {
6
+ top: number;
7
+ left: number;
8
+ };
@@ -0,0 +1,98 @@
1
+ import * as rc from "../rive_advanced.mjs";
2
+ interface Finalizable {
3
+ unref: () => void;
4
+ }
5
+ declare class FileFinalizer implements Finalizable {
6
+ private _file;
7
+ private _session;
8
+ selfUnref: boolean;
9
+ constructor(file: rc.File, session?: rc.DeferredSession | null);
10
+ unref(): void;
11
+ release(): void;
12
+ }
13
+ declare class AssetWrapper implements rc.FinalizableTarget {
14
+ selfUnref: boolean;
15
+ unref(): void;
16
+ }
17
+ declare class ImageWrapper extends AssetWrapper {
18
+ private _nativeImage;
19
+ constructor(image: rc.Image);
20
+ get nativeImage(): rc.ImageInternal;
21
+ unref(): void;
22
+ }
23
+ declare class AudioWrapper extends AssetWrapper {
24
+ private _nativeAudio;
25
+ constructor(audio: rc.Audio);
26
+ get nativeAudio(): rc.AudioInternal;
27
+ unref(): void;
28
+ }
29
+ declare class FontWrapper extends AssetWrapper {
30
+ private _nativeFont;
31
+ constructor(font: rc.Font);
32
+ get nativeFont(): rc.FontInternal;
33
+ unref(): void;
34
+ }
35
+ export type AssetLoadCallbackWrapper = (asset: rc.FileAssetInternal, bytes: Uint8Array) => Boolean;
36
+ declare class CustomFileAssetLoaderWrapper {
37
+ assetLoader: rc.CustomFileAssetLoader;
38
+ _assetLoaderCallback: AssetLoadCallbackWrapper;
39
+ _session: rc.DeferredSession | null;
40
+ constructor(runtime: rc.RiveCanvas, loaderCallback: AssetLoadCallbackWrapper, session?: rc.DeferredSession | null);
41
+ loadContents(asset: rc.FileAsset, bytes: any): false | Boolean;
42
+ }
43
+ /**
44
+ * Rive class representing a FileAsset with relevant metadata fields to describe
45
+ * an asset associated wtih the Rive File
46
+ */
47
+ declare class FileAssetWrapper {
48
+ _nativeFileAsset: rc.FileAssetInternal;
49
+ _session: rc.DeferredSession | null;
50
+ constructor(nativeAsset: rc.FileAssetInternal, session?: rc.DeferredSession | null);
51
+ decode(bytes: Uint8Array): void;
52
+ get name(): string;
53
+ get fileExtension(): string;
54
+ get uniqueFilename(): string;
55
+ get isAudio(): boolean;
56
+ get isImage(): boolean;
57
+ get isFont(): boolean;
58
+ get cdnUuid(): string;
59
+ get nativeFileAsset(): rc.FileAssetInternal;
60
+ }
61
+ /**
62
+ * Rive class extending the FileAsset that exposes a `setRenderImage()` API with a
63
+ * decoded Image (via the `decodeImage()` API) to set a new Image on the Rive FileAsset
64
+ */
65
+ declare class ImageAssetWrapper extends FileAssetWrapper {
66
+ setRenderImage(image: ImageWrapper): void;
67
+ }
68
+ /**
69
+ * Rive class extending the FileAsset that exposes a `setAudioSource()` API with a
70
+ * decoded Audio (via the `decodeAudio()` API) to set a new Audio on the Rive FileAsset
71
+ */
72
+ declare class AudioAssetWrapper extends FileAssetWrapper {
73
+ setAudioSource(audio: AudioWrapper): void;
74
+ }
75
+ /**
76
+ * Rive class extending the FileAsset that exposes a `setFont()` API with a
77
+ * decoded Font (via the `decodeFont()` API) to set a new Font on the Rive FileAsset
78
+ */
79
+ declare class FontAssetWrapper extends FileAssetWrapper {
80
+ setFont(font: FontWrapper): void;
81
+ }
82
+ declare const FinalizationRegistry: {
83
+ new (fn: Function): typeof FinalizationRegistry;
84
+ register<T extends rc.FinalizableTarget>(object: T, description: Finalizable): void;
85
+ unregister<T>(object: T): void;
86
+ };
87
+ declare class FakeFinalizationRegistry {
88
+ constructor(_: Function);
89
+ register(object: rc.FinalizableTarget): void;
90
+ unregister<T>(_: T): void;
91
+ }
92
+ declare const finalizationRegistry: {
93
+ new (fn: Function): typeof FinalizationRegistry;
94
+ register<T extends rc.FinalizableTarget>(object: T, description: Finalizable): void;
95
+ unregister<T>(object: T): void;
96
+ } | FakeFinalizationRegistry;
97
+ declare const createFinalization: <T extends Finalizable>(target: rc.FinalizableTarget, finalizable: T) => void;
98
+ export { finalizationRegistry, createFinalization, Finalizable, ImageWrapper, AudioWrapper, FontWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, CustomFileAssetLoaderWrapper, FileAssetWrapper, FileFinalizer, };
@@ -0,0 +1,6 @@
1
+ export { registerTouchInteractions } from "./registerTouchInteractions";
2
+ export { KeyboardInteractions, FocusSessionState } from "./registerKeyboardInteractions";
3
+ export type { KeyboardInteractionsParams } from "./registerKeyboardInteractions";
4
+ export { BLANK_URL, sanitizeUrl } from "./sanitizeUrl";
5
+ export { Finalizable, ImageWrapper, AudioWrapper, FontWrapper, FileAssetWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, finalizationRegistry, CustomFileAssetLoaderWrapper, AssetLoadCallbackWrapper, FileFinalizer, createFinalization, } from "./finalizationRegistry";
6
+ export { RiveFont } from "./riveFont";