@rive-app/canvas-advanced-single 2.38.5 → 2.39.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-advanced-single",
3
- "version": "2.38.5",
3
+ "version": "2.39.1",
4
4
  "description": "Rive's lightweight low-level canvas based web api all in one js file.",
5
5
  "main": "canvas_advanced_single.mjs",
6
6
  "homepage": "https://rive.app",
@@ -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;