@rive-app/webgl2-threads 0.0.0-stage → 2.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ export declare const Key: {
2
+ readonly space: 32;
3
+ readonly apostrophe: 39;
4
+ readonly comma: 44;
5
+ readonly minus: 45;
6
+ readonly period: 46;
7
+ readonly slash: 47;
8
+ readonly key0: 48;
9
+ readonly key1: 49;
10
+ readonly key2: 50;
11
+ readonly key3: 51;
12
+ readonly key4: 52;
13
+ readonly key5: 53;
14
+ readonly key6: 54;
15
+ readonly key7: 55;
16
+ readonly key8: 56;
17
+ readonly key9: 57;
18
+ readonly semicolon: 59;
19
+ readonly equal: 61;
20
+ readonly a: 65;
21
+ readonly b: 66;
22
+ readonly c: 67;
23
+ readonly d: 68;
24
+ readonly e: 69;
25
+ readonly f: 70;
26
+ readonly g: 71;
27
+ readonly h: 72;
28
+ readonly i: 73;
29
+ readonly j: 74;
30
+ readonly k: 75;
31
+ readonly l: 76;
32
+ readonly m: 77;
33
+ readonly n: 78;
34
+ readonly o: 79;
35
+ readonly p: 80;
36
+ readonly q: 81;
37
+ readonly r: 82;
38
+ readonly s: 83;
39
+ readonly t: 84;
40
+ readonly u: 85;
41
+ readonly v: 86;
42
+ readonly w: 87;
43
+ readonly x: 88;
44
+ readonly y: 89;
45
+ readonly z: 90;
46
+ readonly leftBracket: 91;
47
+ readonly backslash: 92;
48
+ readonly rightBracket: 93;
49
+ readonly graveAccent: 96;
50
+ readonly world1: 161;
51
+ readonly world2: 162;
52
+ readonly escape: 256;
53
+ readonly enter: 257;
54
+ readonly tab: 258;
55
+ readonly backspace: 259;
56
+ readonly insert: 260;
57
+ readonly deleteKey: 261;
58
+ readonly right: 262;
59
+ readonly left: 263;
60
+ readonly down: 264;
61
+ readonly up: 265;
62
+ readonly pageUp: 266;
63
+ readonly pageDown: 267;
64
+ readonly home: 268;
65
+ readonly end: 269;
66
+ readonly capsLock: 280;
67
+ readonly scrollLock: 281;
68
+ readonly numLock: 282;
69
+ readonly printScreen: 283;
70
+ readonly pause: 284;
71
+ readonly f1: 290;
72
+ readonly f2: 291;
73
+ readonly f3: 292;
74
+ readonly f4: 293;
75
+ readonly f5: 294;
76
+ readonly f6: 295;
77
+ readonly f7: 296;
78
+ readonly f8: 297;
79
+ readonly f9: 298;
80
+ readonly f10: 299;
81
+ readonly f11: 300;
82
+ readonly f12: 301;
83
+ readonly f13: 302;
84
+ readonly f14: 303;
85
+ readonly f15: 304;
86
+ readonly f16: 305;
87
+ readonly f17: 306;
88
+ readonly f18: 307;
89
+ readonly f19: 308;
90
+ readonly f20: 309;
91
+ readonly f21: 310;
92
+ readonly f22: 311;
93
+ readonly f23: 312;
94
+ readonly f24: 313;
95
+ readonly f25: 314;
96
+ readonly kp0: 320;
97
+ readonly kp1: 321;
98
+ readonly kp2: 322;
99
+ readonly kp3: 323;
100
+ readonly kp4: 324;
101
+ readonly kp5: 325;
102
+ readonly kp6: 326;
103
+ readonly kp7: 327;
104
+ readonly kp8: 328;
105
+ readonly kp9: 329;
106
+ readonly kpDecimal: 330;
107
+ readonly kpDivide: 331;
108
+ readonly kpMultiply: 332;
109
+ readonly kpSubtract: 333;
110
+ readonly kpAdd: 334;
111
+ readonly kpEnter: 335;
112
+ readonly kpEqual: 336;
113
+ readonly leftShift: 340;
114
+ readonly leftControl: 341;
115
+ readonly leftAlt: 342;
116
+ readonly leftSuper: 343;
117
+ readonly rightShift: 344;
118
+ readonly rightControl: 345;
119
+ readonly rightAlt: 346;
120
+ readonly rightSuper: 347;
121
+ readonly menu: 348;
122
+ };
123
+ export declare const KeyModifiers: {
124
+ readonly none: 0;
125
+ readonly shift: number;
126
+ readonly ctrl: number;
127
+ readonly alt: number;
128
+ readonly meta: number;
129
+ };
130
+ /**
131
+ * Maps a KeyboardEvent to a Rive key, or null if Rive has no equivalent.
132
+ *
133
+ * Resolves the logical key: what the user's layout labels the key, ignoring
134
+ * Shift, so a listener on "A" fires on AZERTY's A too. `event.key` is preferred;
135
+ * `event.code` is the fallback when `key` isn't a plain unshifted character
136
+ * (shifted symbols, Option/AltGr output, non-Latin letters, dead keys).
137
+ * Digit-row and numpad keys skip the character lookup so AZERTY's digit row
138
+ * still reports digits and numpad digits stay distinct from the digit row.
139
+ */
140
+ export declare function keyboardEventToRiveKey(event: KeyboardEvent): number | null;
141
+ export declare function modifiersFromEvent(event: KeyboardEvent): number;
@@ -0,0 +1,174 @@
1
+ import * as rc from "../rive_advanced.mjs";
2
+ import { TextInputProxy } from "./textInputProxy";
3
+ export interface KeyboardInteractionsParams {
4
+ canvas: HTMLCanvasElement;
5
+ stateMachine: rc.StateMachineInstance;
6
+ /**
7
+ * Whether this canvas has focus nodes that should participate in tab traversal.
8
+ * When true, Tab/Shift+Tab will be intercepted and routed to the Rive focus manager.
9
+ * Tab is released to the page only when focusNext() returns false and Rive no longer holds
10
+ * focus; a Stop edge also returns false but keeps focus, so Tab stays trapped.
11
+ */
12
+ hasFocusNodes: boolean;
13
+ /**
14
+ * Optional accessibility overlay that should be treated as part of this Rive
15
+ * instance's focus domain. This is lazy because the overlay may be created
16
+ * after keyboard listeners are registered.
17
+ */
18
+ getOverlayElement?: () => HTMLElement | null;
19
+ }
20
+ /**
21
+ * Tracks the relationship between DOM focus inside this Rive focus domain (canvas or semantic overlay)
22
+ * and Rive's internal focus for the current focus session.
23
+ *
24
+ * NotFocused — DOM focus left the domain, Rive released focus internally, or Tab walked
25
+ * off the end of the tree. Keyboard input isn't ours, so Tab is ignored and
26
+ * reaches the next page element.
27
+ * EntryPending — DOM focus is inside the domain but Rive holds no node yet, so the next Tab
28
+ * enters the focus tree. Set by pointer focus on the canvas, by assistive technology (AT) focus landing
29
+ * in the overlay, and by keyboard focus whose entry attempt found no eligible node.
30
+ * RiveFocused — a Rive node holds focus. Tab/Shift+Tab route to the Rive focus manager and stay
31
+ * inside the domain until either Rive reports focus ended (pollFocusState) or
32
+ * Tab walks off the edge of the tree (focusNext()/focusPrevious() returns false and
33
+ * Rive no longer holds focus).
34
+ *
35
+ * Keyboard focus on the canvas enters the tree immediately: onCanvasFocus infers direction from
36
+ * where focus came from and goes straight to RiveFocused when a node accepts.
37
+ */
38
+ export declare enum FocusSessionState {
39
+ NotFocused = "notFocused",
40
+ EntryPending = "entryPending",
41
+ RiveFocused = "riveFocused"
42
+ }
43
+ /**
44
+ * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas>, semantic
45
+ * overlay, text input proxy). Owns the proxy and the text input session state.
46
+ * Because keyboard events can apply on either part of the domain, we need to track what events we should
47
+ * handle/intercept, and when to release focus back to the page outside of the domain.
48
+ *
49
+ * Tracks the canvas focus session state (focusSessionState) and routes
50
+ * Tab/Shift+Tab to the Rive state machine's focus manager. Exposes shared
51
+ * state as properties so the Rive render loop can read them directly.
52
+ */
53
+ export declare class KeyboardInteractions {
54
+ focusSessionState: FocusSessionState;
55
+ private canvas;
56
+ private mainSm;
57
+ private hasFocusNodes;
58
+ /** Cached callback that returns the accessibility overlay element once created. */
59
+ private getOverlayElement?;
60
+ /** Whether the canvas currently has browser DOM focus. */
61
+ private canvasHasFocus;
62
+ /** After Tab exits the last Rive node, ignore keydowns until focus re-enters the focus domain. */
63
+ private focusDomainReleased;
64
+ /** Overlay element currently wired with focusin/keydown listeners, if any. */
65
+ private currentOverlayElement;
66
+ /** Canvas parent (or document) watched for focusin to attach overlay listeners lazily. */
67
+ private focusDomainHost;
68
+ /** Codes whose keydown an overlay widget took, so their keyup is skipped too. */
69
+ private claimedKeyCodes;
70
+ private readonly inputProxy;
71
+ private textInputSessionActive;
72
+ constructor({ canvas, stateMachine, hasFocusNodes, getOverlayElement, }: KeyboardInteractionsParams);
73
+ isTextInputSessionActive(): boolean;
74
+ /** Session active and the proxy holds DOM focus. */
75
+ isEditingHostFocused(): boolean;
76
+ /** @param focusProxy move DOM focus to the proxy; false leaves it where it is. */
77
+ beginTextInputSession(focusProxy: boolean): void;
78
+ /** @param fromBlur focus is already leaving; don't park it on the canvas. */
79
+ endTextInputSession(fromBlur?: boolean): void;
80
+ /** Must run synchronously in the pointer gesture or mobile keyboards won't open. */
81
+ summonForPointer(): void;
82
+ /** The text-input proxy, for the semantics layer to decorate while editing. */
83
+ get editingHost(): TextInputProxy;
84
+ /**
85
+ * The proxy is always empty: copy Rive's selection; always preventDefault.
86
+ */
87
+ private onCopy;
88
+ private handleProxyBlur;
89
+ /**
90
+ * Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
91
+ * helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
92
+ *
93
+ * @param state FocusSessionState enum
94
+ */
95
+ setFocusSessionState(state: FocusSessionState): void;
96
+ /**
97
+ * Called by pollFocusState on the Rive instance when it observes hasFocus=true. Rive acquired
98
+ * focus internally (e.g. via a listener action or state transition) without a DOM focus event,
99
+ * so mark the session RiveFocused. This cannot resurrect a session that a DOM blur ended,
100
+ * because onCanvasBlur clears Rive's focus alongside it.
101
+ */
102
+ notifyRiveFocused(): void;
103
+ /**
104
+ * Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
105
+ *
106
+ * Pointer-driven focus: the canvas now has focus but Rive holds nothing yet, so we move to EntryPending — this lets the
107
+ * next Tab enter the focus tree even when the focus is pointer-driven
108
+ *
109
+ * Keyboard-driven focus: we enter the Rive focus tree immediately once canvas gains focus.
110
+ * The direction is inferred from where focus came from: an element before the canvas in DOM order
111
+ * means a forward Tab (focusNext), one after means a Shift+Tab (focusPrevious). :focus-visible
112
+ * gates this so a click doesn't yank Rive focus to the first node on the focus event itself.
113
+ */
114
+ onCanvasFocus: (event: FocusEvent) => void;
115
+ /**
116
+ * Marks internal state that the canvas has lost DOM focus. Do not actually clear
117
+ * Rive focus though if:
118
+ * 1. DOM focus is still within Rive domain (i.e., semantic overlay)
119
+ * 2. Document just lost focus (i.e. tab switching)
120
+ *
121
+ * When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
122
+ */
123
+ onCanvasBlur: (event: FocusEvent) => void;
124
+ /** Blur into the focus domain, or the whole document losing focus (tab/window switch). */
125
+ private blurStaysWithRive;
126
+ /**
127
+ * Assistive technology (AT) focus landing inside the overlay is DOM focus inside the Rive focus domain, so open a
128
+ * session even when no Rive node holds focus yet. shouldRiveHandleKeyEvent treats NotFocused
129
+ * as authoritative, so without this the overlay's Tab keydowns reach onKeyDown and get dropped
130
+ * at that gate — the browser would move focus out of Rive instead of to the next focus node.
131
+ */
132
+ private onOverlayFocusIn;
133
+ /** Overlay listeners attach lazily, so the first focusin only ever lands here. */
134
+ private onFocusDomainHostFocusIn;
135
+ /**
136
+ * Handles keydown events in the Rive focus domain. We route certain keys to different functions, with the following
137
+ * fallback behavior:
138
+ * 1. Tab/Shift+Tab - check if keyInput() takes this key, if not, call focusNext/Previous traversal if there are focus nodes
139
+ * 2. Check - if a semantic overlay element's key handler claimed the event, don't intercept the key event further
140
+ * 3. Send key to `keyInput()` on Rive state machine if applicable.
141
+ * 4. If the keyInput returned false, and the key is directional arrow keys, call directional focus methods on state machine
142
+ * 5. Printables: in a session the proxy's input event supplies text; otherwise textInput().
143
+ * A printable fires both keyInput and textInput even if a listener claims it.
144
+ * @param event KeyboardEvent
145
+ * @returns void
146
+ */
147
+ onKeyDown: (event: KeyboardEvent) => void;
148
+ onKeyUp: (event: KeyboardEvent) => void;
149
+ /** Arrow keys map to directional focus; anything else is not a focus move. */
150
+ private focusInDirection;
151
+ /**
152
+ * Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
153
+ * DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
154
+ * has to reach the page rather than re-enter the tree.
155
+ *
156
+ * Otherwise, the event still has to belong to Rive:
157
+ * 1. If the current DOM focus is in Rive domain (canvas or semantic overlay)
158
+ * 2. If the target for the key input is for the semantic overlay, or the canvas
159
+ */
160
+ private shouldRiveHandleKeyEvent;
161
+ /** DOM that counts as inside Rive for focus: canvas, overlay subtree, text-input proxy. */
162
+ isInFocusDomain(target: EventTarget | null): boolean;
163
+ /** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
164
+ private isInOverlay;
165
+ private syncOverlayListener;
166
+ /**
167
+ * Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
168
+ * (vs pointer-) driven focus. For older browser versions that don't support this selector, return false
169
+ * so that we don't incorrectly assume pointer vs keyboard focus. Next tab would enter the focus tree in those edge cases.
170
+ */
171
+ private isKeyboardDrivenFocus;
172
+ private cameFromBeforeCanvas;
173
+ cleanup(): void;
174
+ }
@@ -0,0 +1,25 @@
1
+ import * as rc from "../rive_advanced.mjs";
2
+ export interface TouchInteractionsParams {
3
+ canvas: HTMLCanvasElement | OffscreenCanvas;
4
+ artboard: rc.Artboard;
5
+ stateMachines: rc.StateMachineInstance[];
6
+ renderer: rc.Renderer;
7
+ rive: rc.RiveCanvas;
8
+ fit: rc.Fit;
9
+ alignment: rc.Alignment;
10
+ isTouchScrollEnabled?: boolean;
11
+ dispatchPointerExit?: boolean;
12
+ enableMultiTouch?: boolean;
13
+ layoutScaleFactor?: number;
14
+ advanceAndDrain: (elapsedTime: number, options?: {
15
+ pointerDown?: boolean;
16
+ }) => void;
17
+ summonKeyboard?: () => void;
18
+ isTextProxyFocused?: () => boolean;
19
+ }
20
+ /**
21
+ * Registers mouse move/up/down and wheel callback handlers on the canvas to send meaningful
22
+ * coordinates to the state machine pointer move/up/down/scroll functions based on cursor
23
+ * interaction
24
+ */
25
+ export declare const registerTouchInteractions: ({ canvas, artboard, stateMachines, renderer, rive, fit, alignment, isTouchScrollEnabled, dispatchPointerExit, enableMultiTouch, layoutScaleFactor, advanceAndDrain, summonKeyboard, isTextProxyFocused, }: TouchInteractionsParams) => () => void;
@@ -0,0 +1,15 @@
1
+ import type { FontWrapper } from "./finalizationRegistry";
2
+ export type FallbackFontsCallback = (missingGlyph: number, weight: number) => FontWrapper | FontWrapper[] | null | undefined;
3
+ export declare class RiveFont {
4
+ private static _fallbackFontCallback;
5
+ private constructor();
6
+ /**
7
+ * Set a callback to dynamically set a list of fallback fonts based on the missing glyph and/or style of the default font.
8
+ * Set null to clear the callback.
9
+ * @param fontCallback Callback to set a list of fallback fonts.
10
+ */
11
+ static setFallbackFontCallback(fontCallback: FallbackFontsCallback | null): void;
12
+ private static _fontToPtr;
13
+ private static _getFallbackPtr;
14
+ private static _wireFallbackProc;
15
+ }
@@ -0,0 +1,2 @@
1
+ export declare const BLANK_URL = "about:blank";
2
+ export declare function sanitizeUrl(url?: string): string;
@@ -0,0 +1,61 @@
1
+ export interface TextInputProxyParams {
2
+ /** Where to mount the proxy — the canvas's parent so it scrolls/positions with it. */
3
+ container: HTMLElement;
4
+ /** The Rive canvas, used to position the proxy over it (iOS scroll-jump avoidance) and for domain checks. */
5
+ canvas: HTMLElement;
6
+ /** Forward committed text (typing, IME/dead-key commits, paste) into the focus tree. */
7
+ textInput: (text: string) => boolean;
8
+ /** Physical key events on the proxy route back through KeyboardInteractions' shared policy. */
9
+ onKeyDown: (event: KeyboardEvent) => void;
10
+ onKeyUp: (event: KeyboardEvent) => void;
11
+ /** The field is empty; fill the clipboard from Rive's selection. */
12
+ onCopy: (event: ClipboardEvent) => void;
13
+ /** Called when the proxy loses DOM focus; the receiver decides whether to tear the session down. */
14
+ onBlur: (relatedTarget: EventTarget | null) => void;
15
+ }
16
+ /**
17
+ * Invisible per-instance <input> capturing IME/dead-key/paste text; focusable inside a
18
+ * gesture to raise mobile keyboards. Always empty: C++ owns value and caret. Decorated
19
+ * for AT only while it holds DOM focus.
20
+ */
21
+ export declare class TextInputProxy {
22
+ private params;
23
+ private element;
24
+ private composing;
25
+ private decoratedKeys;
26
+ private lastLeft;
27
+ private lastTop;
28
+ constructor(params: TextInputProxyParams);
29
+ private listeners;
30
+ private createElement;
31
+ private positionOverCanvas;
32
+ /** Re-sync before input: the canvas may have scrolled since the session began. */
33
+ private reposition;
34
+ private onCompositionStart;
35
+ private onCompositionEnd;
36
+ private onInput;
37
+ /**
38
+ * Forward the field's text to Rive and clear it.
39
+ *
40
+ * TODO: iOS won't autorepeat Backspace in an empty field (needs a text mirror).
41
+ * */
42
+ private commit;
43
+ private onPaste;
44
+ private onBlur;
45
+ /** Clear any transient value and decoration. Does not blur the element. */
46
+ endSession(): void;
47
+ /** Must be called synchronously inside a gesture on iOS to raise the keyboard. */
48
+ focus(): void;
49
+ hasDomFocus(): boolean;
50
+ owns(target: EventTarget | null): boolean;
51
+ /** See EditingHost.decorate. */
52
+ decorate(attrs: Record<string, string | null>): void;
53
+ /**
54
+ * type=password for obscured fields so AT doesn't echo keys.
55
+ * TODO: source "type" from Core, not semantics.
56
+ */
57
+ setSecure(secure: boolean): void;
58
+ /** Drop all decoration and return to the AT-invisible baseline. */
59
+ resetDecoration(): void;
60
+ cleanup(): void;
61
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.