@rive-app/canvas 2.26.4 → 2.26.5

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",
3
- "version": "2.26.4",
3
+ "version": "2.26.5",
4
4
  "description": "Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -233,6 +233,10 @@ export interface RiveParameters {
233
233
  * EventType.RiveEvent
234
234
  */
235
235
  automaticallyHandleEvents?: boolean;
236
+ /**
237
+ * Rive will look for a default view model and view model instance to bind to the artboard
238
+ */
239
+ autoBind?: boolean;
236
240
  onLoad?: EventCallback;
237
241
  onLoadError?: EventCallback;
238
242
  onPlay?: EventCallback;
@@ -276,6 +280,7 @@ export interface RiveLoadParameters {
276
280
  buffer?: ArrayBuffer;
277
281
  riveFile?: RiveFile;
278
282
  autoplay?: boolean;
283
+ autoBind?: boolean;
279
284
  artboard?: string;
280
285
  animations?: string | string[];
281
286
  stateMachines?: string | string[];
@@ -287,6 +292,7 @@ export interface RiveResetParameters {
287
292
  animations?: string | string[];
288
293
  stateMachines?: string | string[];
289
294
  autoplay?: boolean;
295
+ autoBind?: boolean;
290
296
  }
291
297
  export interface RiveFileParameters {
292
298
  src?: string;
@@ -371,6 +377,8 @@ export declare class Rive {
371
377
  private _hasZeroSize;
372
378
  private _audioEventListener;
373
379
  private _boundDraw;
380
+ private _viewModelInstance;
381
+ private _dataEnums;
374
382
  durations: number[];
375
383
  frameTimes: number[];
376
384
  frameCount: number;
@@ -705,6 +713,153 @@ export declare class Rive {
705
713
  */
706
714
  get devicePixelRatioUsed(): number;
707
715
  set devicePixelRatioUsed(value: number);
716
+ /**
717
+ * Initialize the data context with the view model instance.
718
+ */
719
+ bindViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
720
+ get viewModelInstance(): ViewModelInstance | null;
721
+ viewModelByIndex(index: number): ViewModel | null;
722
+ viewModelByName(name: string): ViewModel | null;
723
+ enums(): DataEnum[];
724
+ defaultViewModel(): ViewModel | null;
725
+ }
726
+ export declare class ViewModel {
727
+ private _viewModel;
728
+ constructor(viewModel: rc.ViewModel);
729
+ get instanceCount(): number;
730
+ get name(): string;
731
+ instanceByIndex(index: number): ViewModelInstance | null;
732
+ instanceByName(name: string): ViewModelInstance | null;
733
+ defaultInstance(): ViewModelInstance | null;
734
+ instance(): ViewModelInstance | null;
735
+ get properties(): rc.ViewModelProperty[];
736
+ get instanceNames(): string[];
737
+ }
738
+ export declare class DataEnum {
739
+ private _dataEnum;
740
+ constructor(dataEnum: rc.DataEnum);
741
+ get name(): string;
742
+ get values(): string[];
743
+ }
744
+ export declare class ViewModelInstance {
745
+ private _runtimeInstance;
746
+ private _root;
747
+ private _propertiesWithCallbacks;
748
+ private _referenceCount;
749
+ constructor(runtimeInstance: rc.ViewModelInstance, root: ViewModelInstance | null);
750
+ get runtimeInstance(): rc.ViewModelInstance | null;
751
+ handleCallbacks(): void;
752
+ private clearCallbacks;
753
+ /**
754
+ * method to access a property instance of type number belonging
755
+ * to the view model instance or to a nested view model instance
756
+ * @param path - path to the number property
757
+ */
758
+ number(path: string): ViewModelInstanceNumber | null;
759
+ /**
760
+ * method to access a property instance of type string belonging
761
+ * to the view model instance or to a nested view model instance
762
+ * @param path - path to the number property
763
+ */
764
+ string(path: string): ViewModelInstanceString | null;
765
+ /**
766
+ * method to access a property instance of type boolean belonging
767
+ * to the view model instance or to a nested view model instance
768
+ * @param path - path to the number property
769
+ */
770
+ boolean(path: string): ViewModelInstanceBoolean | null;
771
+ /**
772
+ * method to access a property instance of type color belonging
773
+ * to the view model instance or to a nested view model instance
774
+ * @param path - path to the number property
775
+ */
776
+ color(path: string): ViewModelInstanceColor | null;
777
+ /**
778
+ * method to access a property instance of type trigger belonging
779
+ * to the view model instance or to a nested view model instance
780
+ * @param path - path to the number property
781
+ */
782
+ trigger(path: string): ViewModelInstanceTrigger | null;
783
+ /**
784
+ * method to access a property instance of type enum belonging
785
+ * to the view model instance or to a nested view model instance
786
+ * @param path - path to the number property
787
+ */
788
+ enum(path: string): ViewModelInstanceEnum | null;
789
+ /**
790
+ * method to access a view model property instance belonging
791
+ * to the view model instance or to a nested view model instance
792
+ * @param path - path to the number property
793
+ */
794
+ viewModel(path: string): ViewModelInstance | null;
795
+ /**
796
+ * method to replace a view model property with another view model value
797
+ * @param path - path to the view model property
798
+ * @param value - view model that will replace the original
799
+ */
800
+ replaceViewModel(path: string, value: ViewModelInstance): boolean;
801
+ addToCallbacks(property: ViewModelInstanceValue): void;
802
+ removeFromCallbacks(property: ViewModelInstanceValue): void;
803
+ incrementReferenceCount(): void;
804
+ decrementReferenceCount(): void;
805
+ get properties(): rc.ViewModelProperty[];
806
+ internalIncrementReferenceCount(): void;
807
+ cleanup(): void;
808
+ }
809
+ export declare class ViewModelInstanceValue {
810
+ protected _rootViewModel: ViewModelInstance;
811
+ protected callbacks: EventCallback[];
812
+ protected _viewModelInstanceValue: rc.ViewModelInstanceValue;
813
+ constructor(instance: rc.ViewModelInstanceValue, root: ViewModelInstance);
814
+ on(callback: EventCallback): void;
815
+ off(callback?: EventCallback): void;
816
+ internalHandleCallback(callback: Function): void;
817
+ handleCallbacks(): void;
818
+ clearCallbacks(): void;
819
+ get name(): string;
820
+ }
821
+ export declare class ViewModelInstanceString extends ViewModelInstanceValue {
822
+ constructor(instance: rc.ViewModelInstanceString, root: ViewModelInstance);
823
+ get value(): string;
824
+ set value(val: string);
825
+ internalHandleCallback(callback: Function): void;
826
+ }
827
+ export declare class ViewModelInstanceNumber extends ViewModelInstanceValue {
828
+ constructor(instance: rc.ViewModelInstanceNumber, root: ViewModelInstance);
829
+ get value(): number;
830
+ set value(val: number);
831
+ internalHandleCallback(callback: Function): void;
832
+ }
833
+ export declare class ViewModelInstanceBoolean extends ViewModelInstanceValue {
834
+ constructor(instance: rc.ViewModelInstanceBoolean, root: ViewModelInstance);
835
+ get value(): boolean;
836
+ set value(val: boolean);
837
+ internalHandleCallback(callback: Function): void;
838
+ }
839
+ export declare class ViewModelInstanceTrigger extends ViewModelInstanceValue {
840
+ constructor(instance: rc.ViewModelInstanceTrigger, root: ViewModelInstance);
841
+ trigger(): void;
842
+ internalHandleCallback(callback: Function): void;
843
+ }
844
+ export declare class ViewModelInstanceEnum extends ViewModelInstanceValue {
845
+ constructor(instance: rc.ViewModelInstanceEnum, root: ViewModelInstance);
846
+ get value(): string;
847
+ set value(val: string);
848
+ set valueIndex(val: number);
849
+ get valueIndex(): number;
850
+ get values(): string[];
851
+ internalHandleCallback(callback: Function): void;
852
+ }
853
+ export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
854
+ constructor(instance: rc.ViewModelInstanceColor, root: ViewModelInstance);
855
+ get value(): number;
856
+ set value(val: number);
857
+ rgb(r: number, g: number, b: number): void;
858
+ rgba(r: number, g: number, b: number, a: number): void;
859
+ argb(a: number, r: number, g: number, b: number): void;
860
+ alpha(a: number): void;
861
+ opacity(o: number): void;
862
+ internalHandleCallback(callback: Function): void;
708
863
  }
709
864
  /**
710
865
  * Contents of a state machine input