@rive-app/canvas-single 2.38.5 → 2.39.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 +118 -1
- package/rive.js +2392 -105
- package/rive.js.map +1 -1
- package/rive_advanced.mjs.d.ts +131 -0
- package/utils/registerKeyboardInteractions.d.ts +31 -1
package/rive_advanced.mjs.d.ts
CHANGED
|
@@ -391,6 +391,12 @@ export declare class File {
|
|
|
391
391
|
*/
|
|
392
392
|
enums(): DataEnum[];
|
|
393
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Returns the names of the file's global view models, in file order.
|
|
396
|
+
* @returns array of global view model names
|
|
397
|
+
*/
|
|
398
|
+
globalViewModelNames(): string[];
|
|
399
|
+
|
|
394
400
|
unref(): void;
|
|
395
401
|
|
|
396
402
|
/**
|
|
@@ -593,6 +599,27 @@ export declare class Artboard {
|
|
|
593
599
|
* @param instance - Renderer context to draw with
|
|
594
600
|
*/
|
|
595
601
|
bindViewModelInstance(instance: ViewModelInstance): void;
|
|
602
|
+
/**
|
|
603
|
+
* Sets the main view model instance without rebinding. Call bind() to apply.
|
|
604
|
+
*/
|
|
605
|
+
setViewModelInstance(instance: ViewModelInstance): void;
|
|
606
|
+
/**
|
|
607
|
+
* Applies the current data context (rebinds data binds). No-op if nothing set.
|
|
608
|
+
*/
|
|
609
|
+
bind(): void;
|
|
610
|
+
/**
|
|
611
|
+
* Sets/replaces the global view model instance bound under the given global
|
|
612
|
+
* view model name without rebinding, preserving the main instance and the
|
|
613
|
+
* other globals' order. Call bind() to apply.
|
|
614
|
+
* @returns false if the name does not match a global view model in the file.
|
|
615
|
+
*/
|
|
616
|
+
setGlobalViewModelInstance(name: string, instance: ViewModelInstance): boolean;
|
|
617
|
+
/**
|
|
618
|
+
* @returns the global view model instance currently bound under the given
|
|
619
|
+
* name (the runtime-seeded default or a previously set instance), or null if
|
|
620
|
+
* the name does not match a global view model in the file.
|
|
621
|
+
*/
|
|
622
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
596
623
|
|
|
597
624
|
didChange(): boolean;
|
|
598
625
|
}
|
|
@@ -940,6 +967,105 @@ export declare class StateMachineInstance {
|
|
|
940
967
|
* @param instance - Renderer context to draw with
|
|
941
968
|
*/
|
|
942
969
|
bindViewModelInstance(instance: ViewModelInstance): void;
|
|
970
|
+
/**
|
|
971
|
+
* Sets the main view model instance without rebinding. Call bind() to apply.
|
|
972
|
+
*/
|
|
973
|
+
setViewModelInstance(instance: ViewModelInstance): void;
|
|
974
|
+
/**
|
|
975
|
+
* Applies the current data context (rebinds data binds). No-op if nothing set.
|
|
976
|
+
*/
|
|
977
|
+
bind(): void;
|
|
978
|
+
/**
|
|
979
|
+
* Sets/replaces the global view model instance bound under the given global
|
|
980
|
+
* view model name without rebinding, preserving the main instance and the
|
|
981
|
+
* other globals' order. Call bind() to apply.
|
|
982
|
+
* @returns false if the name does not match a global view model in the file.
|
|
983
|
+
*/
|
|
984
|
+
setGlobalViewModelInstance(name: string, instance: ViewModelInstance): boolean;
|
|
985
|
+
/**
|
|
986
|
+
* @returns the global view model instance currently bound under the given
|
|
987
|
+
* name (the runtime-seeded default or a previously set instance), or null if
|
|
988
|
+
* the name does not match a global view model in the file.
|
|
989
|
+
*/
|
|
990
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Enables semantic tree tracking for this state machine instance.
|
|
994
|
+
* Once enabled, the runtime builds and maintains a semantic tree that
|
|
995
|
+
* describes the accessible structure of the artboard (roles, labels,
|
|
996
|
+
* states, bounds). Call this before using drainSemanticsDiff().
|
|
997
|
+
*/
|
|
998
|
+
enableSemantics(): void;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Returns the incremental semantic diff since the last call, or null if
|
|
1002
|
+
* nothing changed. Each diff contains arrays of added/removed/moved nodes,
|
|
1003
|
+
* updated semantic properties, updated geometry, and children reorderings.
|
|
1004
|
+
*/
|
|
1005
|
+
drainSemanticsDiff(): SemanticsDiff | null;
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Fire a semantic action on the node with the given ID.
|
|
1009
|
+
* @param nodeId - The semantic node ID to target
|
|
1010
|
+
* @param actionType - 0 = tap, 1 = increase, 2 = decrease
|
|
1011
|
+
*/
|
|
1012
|
+
fireSemanticAction(nodeId: number, actionType: number): void;
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Request focus on the semantic node with the given ID.
|
|
1016
|
+
* Routes through SemanticManager to focus the FocusData sibling of the
|
|
1017
|
+
* SemanticData that owns the node. Returns true if focus was set.
|
|
1018
|
+
* @param nodeId - The semantic node ID to focus
|
|
1019
|
+
* @returns boolean - True if focus was set, false otherwise
|
|
1020
|
+
*/
|
|
1021
|
+
focusSemanticNode(nodeId: number): boolean;
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Clears focus from the currently focused node in the focus tree.
|
|
1025
|
+
*/
|
|
1026
|
+
clearFocus(): void;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
export interface SemanticsDiffNode {
|
|
1030
|
+
id: number;
|
|
1031
|
+
role: number;
|
|
1032
|
+
label: string;
|
|
1033
|
+
value: string;
|
|
1034
|
+
hint: string;
|
|
1035
|
+
stateFlags: number;
|
|
1036
|
+
traitFlags: number;
|
|
1037
|
+
headingLevel: number;
|
|
1038
|
+
minX: number;
|
|
1039
|
+
minY: number;
|
|
1040
|
+
maxX: number;
|
|
1041
|
+
maxY: number;
|
|
1042
|
+
parentId: number;
|
|
1043
|
+
siblingIndex: number;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
export interface SemanticsBoundsUpdate {
|
|
1047
|
+
id: number;
|
|
1048
|
+
minX: number;
|
|
1049
|
+
minY: number;
|
|
1050
|
+
maxX: number;
|
|
1051
|
+
maxY: number;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
export interface SemanticsChildrenUpdate {
|
|
1055
|
+
parentId: number;
|
|
1056
|
+
childIds: number[];
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
export interface SemanticsDiff {
|
|
1060
|
+
frameNumber: number;
|
|
1061
|
+
treeVersion: number;
|
|
1062
|
+
rootId: number;
|
|
1063
|
+
removed: number[];
|
|
1064
|
+
added: SemanticsDiffNode[];
|
|
1065
|
+
moved: SemanticsDiffNode[];
|
|
1066
|
+
childrenUpdated: SemanticsChildrenUpdate[];
|
|
1067
|
+
updatedSemantic: SemanticsDiffNode[];
|
|
1068
|
+
updatedGeometry: SemanticsBoundsUpdate[];
|
|
943
1069
|
}
|
|
944
1070
|
|
|
945
1071
|
export declare class SMIInput {
|
|
@@ -973,6 +1099,7 @@ export declare class SMIInput {
|
|
|
973
1099
|
export declare type ViewModelProperty = {
|
|
974
1100
|
name: string;
|
|
975
1101
|
type: DataType;
|
|
1102
|
+
enumName?: string;
|
|
976
1103
|
};
|
|
977
1104
|
|
|
978
1105
|
export declare class ViewModelInstanceValue {
|
|
@@ -1028,6 +1155,9 @@ export declare class ViewModelInstanceList extends ViewModelInstanceValue {
|
|
|
1028
1155
|
export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
|
|
1029
1156
|
value(image: ImageInternal | null): void;
|
|
1030
1157
|
}
|
|
1158
|
+
export declare class ViewModelInstanceAssetFont extends ViewModelInstanceValue {
|
|
1159
|
+
value(font: FontInternal | null): void;
|
|
1160
|
+
}
|
|
1031
1161
|
export declare class ViewModelInstanceArtboard extends ViewModelInstanceValue {
|
|
1032
1162
|
value(artboard: BindableArtboard | Artboard): void;
|
|
1033
1163
|
viewModelInstance(viewModelInstance: ViewModelInstance): void;
|
|
@@ -1044,6 +1174,7 @@ export declare class ViewModelInstance {
|
|
|
1044
1174
|
list(path: string): ViewModelInstanceList;
|
|
1045
1175
|
viewModel(path: string): ViewModelInstance;
|
|
1046
1176
|
image(path: string): ViewModelInstanceAssetImage;
|
|
1177
|
+
font(path: string): ViewModelInstanceAssetFont;
|
|
1047
1178
|
artboard(path: string): ViewModelInstanceArtboard;
|
|
1048
1179
|
replaceViewModel(path: string, value: ViewModelInstance): boolean;
|
|
1049
1180
|
incrementReferenceCount(): void;
|
|
@@ -8,6 +8,12 @@ export interface KeyboardInteractionsParams {
|
|
|
8
8
|
* focusNext() returning false means no more traversable nodes — tab is released to the page.
|
|
9
9
|
*/
|
|
10
10
|
hasFocusNodes: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Optional accessibility overlay that should be treated as part of this Rive
|
|
13
|
+
* instance's focus domain. This is lazy because the overlay may be created
|
|
14
|
+
* after keyboard listeners are registered.
|
|
15
|
+
*/
|
|
16
|
+
getOverlayElement?: () => HTMLElement | null;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Tracks the relationship between the canvas's DOM focus and Rive's internal focus for the
|
|
@@ -43,7 +49,17 @@ export declare class KeyboardInteractions {
|
|
|
43
49
|
private canvas;
|
|
44
50
|
private mainSm;
|
|
45
51
|
private hasFocusNodes;
|
|
46
|
-
|
|
52
|
+
/** Cached callback that returns the accessibility overlay element once created. */
|
|
53
|
+
private getOverlayElement?;
|
|
54
|
+
/** Whether the canvas currently has browser DOM focus. */
|
|
55
|
+
private canvasHasFocus;
|
|
56
|
+
/** After Tab exits the last Rive node, ignore keydowns until focus re-enters the focus domain. */
|
|
57
|
+
private focusDomainReleased;
|
|
58
|
+
/** Overlay element currently wired with focusin/keydown listeners, if any. */
|
|
59
|
+
private currentOverlayElement;
|
|
60
|
+
/** Canvas parent (or document) watched for focusin to attach overlay listeners lazily. */
|
|
61
|
+
private focusDomainHost;
|
|
62
|
+
constructor({ canvas, stateMachine, hasFocusNodes, getOverlayElement, }: KeyboardInteractionsParams);
|
|
47
63
|
/**
|
|
48
64
|
* Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
|
|
49
65
|
* helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
|
|
@@ -70,7 +86,21 @@ export declare class KeyboardInteractions {
|
|
|
70
86
|
*/
|
|
71
87
|
onCanvasFocus: (event: FocusEvent) => void;
|
|
72
88
|
onCanvasBlur: (_event: FocusEvent) => void;
|
|
89
|
+
private onOverlayFocusIn;
|
|
90
|
+
private onFocusDomainHostFocusIn;
|
|
73
91
|
onKeyDown: (event: KeyboardEvent) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Whether Rive should handle this keydown — i.e. it currently owns keyboard input.
|
|
94
|
+
* True when focus is anywhere in the Rive focus domain (the canvas itself or the
|
|
95
|
+
* accessibility overlay), OR a focus session is active and the key landed on the
|
|
96
|
+
* canvas.
|
|
97
|
+
*/
|
|
98
|
+
private shouldRiveHandleKeyEvent;
|
|
99
|
+
/** Rive focus domain = the canvas itself OR the accessibility overlay. */
|
|
100
|
+
private isInFocusDomain;
|
|
101
|
+
/** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
|
|
102
|
+
private isInOverlay;
|
|
103
|
+
private syncOverlayListener;
|
|
74
104
|
/**
|
|
75
105
|
* Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
|
|
76
106
|
* (vs pointer-) driven focus. For older browser versions that don't support this selector, return false
|