@rive-app/canvas-lite 2.37.7 → 2.38.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-lite",
3
- "version": "2.37.7",
3
+ "version": "2.38.0",
4
4
  "description": "A lite version of Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -40,6 +40,21 @@ export declare enum DrawOptimizationOptions {
40
40
  AlwaysDraw = "alwaysDraw",
41
41
  DrawOnChanged = "drawOnChanged"
42
42
  }
43
+ export interface RiveFocusOptions {
44
+ /**
45
+ * When true, allows Rive to interrupt browser focus and programmatically
46
+ * set/release focus on the canvas when the state machine reports focus
47
+ * changes in Rive. This allows apps to direct focus to/from the canvas or
48
+ * related elements as needed if not currently focused, which can happen at
49
+ * any point in the Rive render loop.
50
+ *
51
+ * Note: Nodes in the Rive graphic may still receive/release focus respecting
52
+ * any focus rules defined in the state machine.
53
+ *
54
+ * @default false to prevent unwanted focus interruptions
55
+ */
56
+ allowFocusInterrupt: boolean;
57
+ }
43
58
  export interface LayoutParameters {
44
59
  fit?: Fit;
45
60
  alignment?: Alignment;
@@ -215,6 +230,14 @@ export interface RiveParameters {
215
230
  layout?: Layout;
216
231
  autoplay?: boolean;
217
232
  useOffscreenRenderer?: boolean;
233
+ /**
234
+ * Optional tab index to set for the canvas element if there are any Focus nodes within the graphic
235
+ */
236
+ tabIndex?: number;
237
+ /**
238
+ * Optional settings for focus behavior
239
+ */
240
+ focusOptions?: RiveFocusOptions;
218
241
  /**
219
242
  * Allow the runtime to automatically load assets hosted in Rive's CDN.
220
243
  * enabled by default.
@@ -316,6 +339,7 @@ export interface RiveLoadParameters {
316
339
  stateMachines?: string | string[];
317
340
  useOffscreenRenderer?: boolean;
318
341
  shouldDisableRiveListeners?: boolean;
342
+ tabIndex?: number;
319
343
  }
320
344
  export interface RiveResetParameters {
321
345
  artboard?: string;
@@ -415,6 +439,7 @@ export declare class Rive {
415
439
  private runtime;
416
440
  private artboard;
417
441
  private eventCleanup;
442
+ private _keyboardInteractions;
418
443
  private file;
419
444
  private riveFile;
420
445
  private eventManager;
@@ -438,8 +463,13 @@ export declare class Rive {
438
463
  private _currentCanvasHeight;
439
464
  private _audioEventListener;
440
465
  private _boundDraw;
466
+ private _pageVisibilityHandler;
467
+ private _explicitlyStoppedRendering;
441
468
  private _viewModelInstance;
442
469
  private _dataEnums;
470
+ private _tabIndex;
471
+ private _prevHasFocus;
472
+ private _focusOptions;
443
473
  private drawOptimization;
444
474
  private enablePerfMarks;
445
475
  durations: number[];
@@ -459,6 +489,7 @@ export declare class Rive {
459
489
  * i.e. { isTouchScrollEnabled: true }
460
490
  */
461
491
  setupRiveListeners(riveListenerOptions?: SetupRiveListenersOptions): void;
492
+ private cleanupKeyboardInteractions;
462
493
  /**
463
494
  * Remove Rive Listeners setup on the canvas
464
495
  */
@@ -473,6 +504,11 @@ export declare class Rive {
473
504
  private initArtboard;
474
505
  drawFrame(): void;
475
506
  private _canvasSizeChanged;
507
+ /**
508
+ * Poll focus state each frame to see if we should focus/blur the canvas in case
509
+ * Rive internally updated focus outside of user interaction (e.g., via listener action)
510
+ */
511
+ private pollFocusState;
476
512
  private lastRenderTime;
477
513
  private frameRequestId;
478
514
  /**
@@ -480,6 +516,13 @@ export declare class Rive {
480
516
  * Used for debugging purposes
481
517
  */
482
518
  private renderSecondTimer;
519
+ /**
520
+ * Handles important sequence of reporting Rive events, advancing the state machine or animation, and invoking various callbacks
521
+ * due to state changes, view model property changes, etc.
522
+ *
523
+ * @param elapsedTime time to advance the state machine by
524
+ */
525
+ private advanceAndReportChanges;
483
526
  /**
484
527
  * Draw rendering loop; renders animation frames at the correct time interval.
485
528
  * @param time the time at which to render a frame
@@ -723,6 +766,13 @@ export declare class Rive {
723
766
  */
724
767
  startRendering(): void;
725
768
  private scheduleRendering;
769
+ /**
770
+ * Called when document.visibilitychange fires (tab change, window minimize, etc.).
771
+ * Cancels the rAF loop on hide and resets the time reference so that no accumulated time is
772
+ * applied to state machines when the tab becomes visible again. This prevents state machine
773
+ * advances with large time deltas when rAF starts up again.
774
+ */
775
+ private _onPageVisibilityChange;
726
776
  /**
727
777
  * Enables frames-per-second (FPS) reporting for the runtime
728
778
  * If no callback is provided, Rive will append a fixed-position div at the top-right corner of
@@ -797,6 +847,11 @@ export declare class Rive {
797
847
  getArtboard(name: string): Artboard | null;
798
848
  getBindableArtboard(name: string): BindableArtboard | null;
799
849
  getDefaultBindableArtboard(): BindableArtboard | null;
850
+ /**
851
+ * Clear focus applicable to active state machines with focus nodes. Useful if users want to
852
+ * reset focus state and behavior within the Rive graphic at any point (i.e. blurring off the canvas)
853
+ */
854
+ clearFocus(): void;
800
855
  }
801
856
  export declare enum DataType {
802
857
  none = "none",