@rive-app/canvas-single 2.43.1 → 2.44.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.
@@ -286,6 +286,14 @@ export declare class RenderPaintWrapper {
286
286
  radialGradient(sx: number, sy: number, ex: number, ey: number): void;
287
287
  addStop(color: number, stop: number): void;
288
288
  completeGradient(): void;
289
+ gradientTransform(
290
+ xx: number,
291
+ xy: number,
292
+ yx: number,
293
+ yy: number,
294
+ tx: number,
295
+ ty: number,
296
+ ): void;
289
297
  }
290
298
 
291
299
  /**
@@ -460,6 +468,11 @@ export declare class File {
460
468
  * @returns Number of view models in the Rive file
461
469
  */
462
470
  viewModelCount(): number;
471
+ /**
472
+ * Reports device pixels per layout point to scripts in this file
473
+ * @param scale - Device pixels per layout point
474
+ */
475
+ displayScale(scale: number): void;
463
476
  /**
464
477
  * Returns a view model by the index in which it is located in the file
465
478
  * @returns ViewModel
@@ -1018,6 +1031,70 @@ export declare class StateMachineInstance {
1018
1031
  * @param y - Y coordinate
1019
1032
  */
1020
1033
  pointerExit(x: number, y: number, id: number): void;
1034
+ /**
1035
+ * Notifies the state machine of indirect scroll input (a mouse wheel, or a trackpad gesture the
1036
+ * platform already classified as a scroll) at the given coordinate in Artboard space. Direct
1037
+ * touch scrolling stays on the pointer path.
1038
+ *
1039
+ * A gesture latches to the scroll view that takes its first event and stays there, even past
1040
+ * that view's edge, until the gesture ends. A gesture with no end phase (a wheel) ends once the
1041
+ * state machine advances 0.1s without another scroll event.
1042
+ *
1043
+ * @param x - X coordinate
1044
+ * @param y - Y coordinate
1045
+ * @param dx - Horizontal distance the content moves, in Artboard pixels. Revealing content to
1046
+ * the right is negative, so a DOM wheel delta must be negated.
1047
+ * @param dy - Vertical distance the content moves, in Artboard pixels. Revealing content below
1048
+ * is negative.
1049
+ * @param phase - Where the event sits within its gesture: 0 begin, 1 update, 2 end,
1050
+ * 3 momentum, 4 inertiaCancel. A phaseless wheel only ever sends 1 (update).
1051
+ * @param precise - True for a pixel-precise source such as a trackpad, false for a detented
1052
+ * wheel.
1053
+ * @param timeStamp - Event time in seconds.
1054
+ * @param id - Pointer id
1055
+ * @returns 0 when nothing took the event, 1 when a scroll view did, 2 when an opaque scroll
1056
+ * view did.
1057
+ */
1058
+ pointerScroll(
1059
+ x: number,
1060
+ y: number,
1061
+ dx: number,
1062
+ dy: number,
1063
+ phase: number,
1064
+ precise: boolean,
1065
+ timeStamp: number,
1066
+ id: number,
1067
+ ): number;
1068
+ /**
1069
+ * Returns true if anything under the given Artboard coordinate would move for this scroll
1070
+ * event, without applying it. Always true while a gesture is latched.
1071
+ * See {@link pointerScroll} for the parameters.
1072
+ */
1073
+ wantsScroll(
1074
+ x: number,
1075
+ y: number,
1076
+ dx: number,
1077
+ dy: number,
1078
+ phase: number,
1079
+ precise: boolean,
1080
+ ): boolean;
1081
+ /**
1082
+ * Returns true if a wheel-enabled scroll view sits under the given Artboard coordinate, even
1083
+ * one that cannot move right now.
1084
+ *
1085
+ * @param x - X coordinate
1086
+ * @param y - Y coordinate
1087
+ */
1088
+ hasScrollTargetAt(x: number, y: number): boolean;
1089
+ /**
1090
+ * Returns true while a scroll gesture is latched to a scroll view in this state machine or a
1091
+ * nested one.
1092
+ */
1093
+ hasScrollLatch(): boolean;
1094
+ /**
1095
+ * Ends any scroll gesture in flight, latch included.
1096
+ */
1097
+ cancelScroll(): void;
1021
1098
 
1022
1099
  /**
1023
1100
  * Returns true if this state machine has any focus nodes registered in its focus tree.
@@ -1049,13 +1126,13 @@ export declare class StateMachineInstance {
1049
1126
  focusRight(): boolean;
1050
1127
 
1051
1128
  /**
1052
- * Move focus to the nearest focusable node to the up of the current focus, by on-screen position.
1129
+ * Move focus to the nearest focusable node above the current focus, by on-screen position.
1053
1130
  * @returns false if nothing is focused or no node lies in that direction
1054
1131
  */
1055
1132
  focusUp(): boolean;
1056
1133
 
1057
1134
  /**
1058
- * Move focus to the nearest focusable node to the down of the current focus, by on-screen position.
1135
+ * Move focus to the nearest focusable node below the current focus, by on-screen position.
1059
1136
  * @returns false if nothing is focused or no node lies in that direction
1060
1137
  */
1061
1138
  focusDown(): boolean;
@@ -1075,7 +1152,7 @@ export declare class StateMachineInstance {
1075
1152
  /**
1076
1153
  * Forward a key press/release to the focus tree via the state machine's focus manager.
1077
1154
  * The event bubbles from the primary focus node up its ancestors until a handler consumes it.
1078
- * Standalone modifier keys must never be sent; fold held modifiers into the `modifiers` bitmask.
1155
+ * Modifier keys are sent as keys too; held modifiers also go in the `modifiers` bitmask.
1079
1156
  * @param key - GLFW-style key code (see js/src/utils/keyMap.ts)
1080
1157
  * @param modifiers - KeyModifiers bitmask (shift=1, ctrl=2, alt=4, meta=8)
1081
1158
  * @param isPressed - true for keydown, false for keyup
@@ -1094,6 +1171,13 @@ export declare class StateMachineInstance {
1094
1171
  */
1095
1172
  textInput(text: string): boolean;
1096
1173
 
1174
+ /**
1175
+ * The selected text of the focused element, or an empty string when nothing with a
1176
+ * selection is focused. Used to fill the clipboard on copy/cut. An obscured field
1177
+ * (i.e. a password) reports empty string.
1178
+ */
1179
+ selectedText(): string;
1180
+
1097
1181
  /**
1098
1182
  * Deletes the underlying instance created via the WASM. It's important to clean up this instance
1099
1183
  * when no longer in use
@@ -18,6 +18,11 @@ export interface AccessibilityOverlayOptions {
18
18
  * inside Rive (overlay or canvas); when true it may also pull focus from outside Rive.
19
19
  */
20
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;
21
26
  }
22
27
  /**
23
28
  * Indication of what changed since the last overlay update.
@@ -33,6 +38,18 @@ export interface OverlayChange {
33
38
  nodeGeometryChanged: boolean;
34
39
  layoutChanged: boolean;
35
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
+ }
36
53
  /**
37
54
  * Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
38
55
  * screen readers to discover and interact with the Rive content.
@@ -64,6 +81,8 @@ export declare class AccessibilityOverlay {
64
81
  private pendingTextGeometry;
65
82
  /** Last measured box-size|text key per text element, to skip redundant re-measures. */
66
83
  private textGeometryKeys;
84
+ /** Node data last passed to applyAttributes per element; see {@link setEditingHostNode}. */
85
+ private appliedNodes;
67
86
  private lastCanvasPositioning;
68
87
  /**
69
88
  * Set when a ResizeObserver/window-resize signals the canvas geometry may have
@@ -76,6 +95,12 @@ export declare class AccessibilityOverlay {
76
95
  private isUpdating;
77
96
  /** See {@link AccessibilityOverlayOptions.allowFocusInterrupt}. */
78
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;
79
104
  /**
80
105
  * Single child div of the overlay container that carries the artboard→CSS
81
106
  * transform. All semantic node elements are children of this div and express
@@ -94,6 +119,27 @@ export declare class AccessibilityOverlay {
94
119
  private positionObserver;
95
120
  private readonly _onWindowResize;
96
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;
97
143
  getSemanticOverlayContainer(): HTMLDivElement;
98
144
  private attachPositionObservers;
99
145
  /**
@@ -104,7 +150,14 @@ export declare class AccessibilityOverlay {
104
150
  */
105
151
  private observePosition;
106
152
  private scheduleReposition;
153
+ /** Returns true when the container's size changed (node transforms need recomputing). */
107
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;
108
161
  private createContainer;
109
162
  /**
110
163
  * Returns what changed since the last update, or null if nothing changed.
@@ -181,6 +234,7 @@ export declare class AccessibilityOverlay {
181
234
  */
182
235
  private attachRovingNav;
183
236
  private attachActionHandlers;
237
+ private isAriaHidden;
184
238
  private applyAttributes;
185
239
  /**
186
240
  * Positions an element in artboard-space coordinates relative to its parent.
@@ -208,7 +262,8 @@ export declare class AccessibilityOverlay {
208
262
  * Creates (on first call) and updates the artboard-space transform container.
209
263
  *
210
264
  * The container is sized to the artboard dimensions and carries a CSS
211
- * `transform: matrix(...)` equivalent to `forwardMat / dpr`. All semantic
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
212
267
  * node elements are children of this container and use raw artboard
213
268
  * coordinates as their CSS `left/top/width/height`, so the CSS compositor
214
269
  * applies the artboard→screen mapping in one pass.
@@ -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;
@@ -32,6 +32,8 @@ export declare class SemanticTreeModel {
32
32
  get roots(): readonly number[];
33
33
  /** Look up a node by its ID, or undefined if not in the tree. */
34
34
  nodeById(id: number): SemanticNodeData | undefined;
35
+ /** The node with SemanticState.Focused, or undefined. */
36
+ focusedNode(): SemanticNodeData | undefined;
35
37
  /** Current index of a node among its siblings (or roots), or -1 if absent. */
36
38
  private siblingIndexOf;
37
39
  /** Detach a node from its current parent (or from roots). */
@@ -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,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;
@@ -1,4 +1,5 @@
1
1
  import * as rc from "../rive_advanced.mjs";
2
+ import { TextInputProxy } from "./textInputProxy";
2
3
  export interface KeyboardInteractionsParams {
3
4
  canvas: HTMLCanvasElement;
4
5
  stateMachine: rc.StateMachineInstance;
@@ -40,7 +41,8 @@ export declare enum FocusSessionState {
40
41
  RiveFocused = "riveFocused"
41
42
  }
42
43
  /**
43
- * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas> or semantic overlay).
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.
44
46
  * Because keyboard events can apply on either part of the domain, we need to track what events we should
45
47
  * handle/intercept, and when to release focus back to the page outside of the domain.
46
48
  *
@@ -63,7 +65,27 @@ export declare class KeyboardInteractions {
63
65
  private currentOverlayElement;
64
66
  /** Canvas parent (or document) watched for focusin to attach overlay listeners lazily. */
65
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;
66
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;
67
89
  /**
68
90
  * Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
69
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
@@ -99,6 +121,8 @@ export declare class KeyboardInteractions {
99
121
  * When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
100
122
  */
101
123
  onCanvasBlur: (event: FocusEvent) => void;
124
+ /** Blur into the focus domain, or the whole document losing focus (tab/window switch). */
125
+ private blurStaysWithRive;
102
126
  /**
103
127
  * Assistive technology (AT) focus landing inside the overlay is DOM focus inside the Rive focus domain, so open a
104
128
  * session even when no Rive node holds focus yet. shouldRiveHandleKeyEvent treats NotFocused
@@ -108,7 +132,22 @@ export declare class KeyboardInteractions {
108
132
  private onOverlayFocusIn;
109
133
  /** Overlay listeners attach lazily, so the first focusin only ever lands here. */
110
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
+ */
111
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;
112
151
  /**
113
152
  * Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
114
153
  * DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
@@ -119,12 +158,8 @@ export declare class KeyboardInteractions {
119
158
  * 2. If the target for the key input is for the semantic overlay, or the canvas
120
159
  */
121
160
  private shouldRiveHandleKeyEvent;
122
- /**
123
- * The Rive focus domain: the DOM that counts as "inside" Rive for focus purposes — today the
124
- * canvas itself OR the accessibility overlay subtree. Anything added later belongs here, so
125
- * session bookkeeping and keydown routing pick it up for free.
126
- */
127
- private isInFocusDomain;
161
+ /** DOM that counts as inside Rive for focus: canvas, overlay subtree, text-input proxy. */
162
+ isInFocusDomain(target: EventTarget | null): boolean;
128
163
  /** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
129
164
  private isInOverlay;
130
165
  private syncOverlayListener;
@@ -11,10 +11,15 @@ export interface TouchInteractionsParams {
11
11
  dispatchPointerExit?: boolean;
12
12
  enableMultiTouch?: boolean;
13
13
  layoutScaleFactor?: number;
14
- advanceAndDrain: (elapsedTime: number) => void;
14
+ advanceAndDrain: (elapsedTime: number, options?: {
15
+ pointerDown?: boolean;
16
+ }) => void;
17
+ summonKeyboard?: () => void;
18
+ isTextProxyFocused?: () => boolean;
15
19
  }
16
20
  /**
17
- * Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
18
- * the state machine pointer move/up/down functions based on cursor interaction
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
19
24
  */
20
- export declare const registerTouchInteractions: ({ canvas, artboard, stateMachines, renderer, rive, fit, alignment, isTouchScrollEnabled, dispatchPointerExit, enableMultiTouch, layoutScaleFactor, advanceAndDrain, }: TouchInteractionsParams) => () => void;
25
+ export declare const registerTouchInteractions: ({ canvas, artboard, stateMachines, renderer, rive, fit, alignment, isTouchScrollEnabled, dispatchPointerExit, enableMultiTouch, layoutScaleFactor, advanceAndDrain, summonKeyboard, isTextProxyFocused, }: TouchInteractionsParams) => () => void;
@@ -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
+ }