@rive-app/canvas-single 2.43.1 → 2.44.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 +1 -1
- package/rive.d.ts +14 -4
- package/rive.js +1361 -204
- package/rive.js.map +1 -1
- package/rive_advanced.mjs.d.ts +10 -3
- package/semantics/accessibilityOverlay.d.ts +56 -1
- package/semantics/claimedKeyEvents.d.ts +7 -0
- package/semantics/semanticTreeModel.d.ts +2 -0
- package/utils/canvasOffset.d.ts +8 -0
- package/utils/keyMap.d.ts +141 -0
- package/utils/registerKeyboardInteractions.d.ts +42 -7
- package/utils/registerTouchInteractions.d.ts +6 -2
- package/utils/textInputProxy.d.ts +61 -0
package/rive_advanced.mjs.d.ts
CHANGED
|
@@ -1049,13 +1049,13 @@ export declare class StateMachineInstance {
|
|
|
1049
1049
|
focusRight(): boolean;
|
|
1050
1050
|
|
|
1051
1051
|
/**
|
|
1052
|
-
* Move focus to the nearest focusable node
|
|
1052
|
+
* Move focus to the nearest focusable node above the current focus, by on-screen position.
|
|
1053
1053
|
* @returns false if nothing is focused or no node lies in that direction
|
|
1054
1054
|
*/
|
|
1055
1055
|
focusUp(): boolean;
|
|
1056
1056
|
|
|
1057
1057
|
/**
|
|
1058
|
-
* Move focus to the nearest focusable node
|
|
1058
|
+
* Move focus to the nearest focusable node below the current focus, by on-screen position.
|
|
1059
1059
|
* @returns false if nothing is focused or no node lies in that direction
|
|
1060
1060
|
*/
|
|
1061
1061
|
focusDown(): boolean;
|
|
@@ -1075,7 +1075,7 @@ export declare class StateMachineInstance {
|
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Forward a key press/release to the focus tree via the state machine's focus manager.
|
|
1077
1077
|
* The event bubbles from the primary focus node up its ancestors until a handler consumes it.
|
|
1078
|
-
*
|
|
1078
|
+
* Modifier keys are sent as keys too; held modifiers also go in the `modifiers` bitmask.
|
|
1079
1079
|
* @param key - GLFW-style key code (see js/src/utils/keyMap.ts)
|
|
1080
1080
|
* @param modifiers - KeyModifiers bitmask (shift=1, ctrl=2, alt=4, meta=8)
|
|
1081
1081
|
* @param isPressed - true for keydown, false for keyup
|
|
@@ -1094,6 +1094,13 @@ export declare class StateMachineInstance {
|
|
|
1094
1094
|
*/
|
|
1095
1095
|
textInput(text: string): boolean;
|
|
1096
1096
|
|
|
1097
|
+
/**
|
|
1098
|
+
* The selected text of the focused element, or an empty string when nothing with a
|
|
1099
|
+
* selection is focused. Used to fill the clipboard on copy/cut. An obscured field
|
|
1100
|
+
* (i.e. a password) reports empty string.
|
|
1101
|
+
*/
|
|
1102
|
+
selectedText(): string;
|
|
1103
|
+
|
|
1097
1104
|
/**
|
|
1098
1105
|
* Deletes the underlying instance created via the WASM. It's important to clean up this instance
|
|
1099
1106
|
* 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(...)`
|
|
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,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
|
|
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
|
-
|
|
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,14 @@ export interface TouchInteractionsParams {
|
|
|
11
11
|
dispatchPointerExit?: boolean;
|
|
12
12
|
enableMultiTouch?: boolean;
|
|
13
13
|
layoutScaleFactor?: number;
|
|
14
|
-
advanceAndDrain: (elapsedTime: number
|
|
14
|
+
advanceAndDrain: (elapsedTime: number, options?: {
|
|
15
|
+
pointerDown?: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
summonKeyboard?: () => void;
|
|
18
|
+
isTextProxyFocused?: () => boolean;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
|
|
18
22
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
19
23
|
*/
|
|
20
|
-
export declare const registerTouchInteractions: ({ canvas, artboard, stateMachines, renderer, rive, fit, alignment, isTouchScrollEnabled, dispatchPointerExit, enableMultiTouch, layoutScaleFactor, advanceAndDrain, }: TouchInteractionsParams) => () => void;
|
|
24
|
+
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
|
+
}
|