@rive-app/canvas-lite 2.37.8 → 2.38.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-lite",
3
- "version": "2.37.8",
3
+ "version": "2.38.1",
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;
@@ -219,6 +234,10 @@ export interface RiveParameters {
219
234
  * Optional tab index to set for the canvas element if there are any Focus nodes within the graphic
220
235
  */
221
236
  tabIndex?: number;
237
+ /**
238
+ * Optional settings for focus behavior
239
+ */
240
+ focusOptions?: RiveFocusOptions;
222
241
  /**
223
242
  * Allow the runtime to automatically load assets hosted in Rive's CDN.
224
243
  * enabled by default.
@@ -420,7 +439,7 @@ export declare class Rive {
420
439
  private runtime;
421
440
  private artboard;
422
441
  private eventCleanup;
423
- private keyboardEventCleanup;
442
+ private _keyboardInteractions;
424
443
  private file;
425
444
  private riveFile;
426
445
  private eventManager;
@@ -449,6 +468,8 @@ export declare class Rive {
449
468
  private _viewModelInstance;
450
469
  private _dataEnums;
451
470
  private _tabIndex;
471
+ private _prevHasFocus;
472
+ private _focusOptions;
452
473
  private drawOptimization;
453
474
  private enablePerfMarks;
454
475
  durations: number[];
@@ -468,6 +489,7 @@ export declare class Rive {
468
489
  * i.e. { isTouchScrollEnabled: true }
469
490
  */
470
491
  setupRiveListeners(riveListenerOptions?: SetupRiveListenersOptions): void;
492
+ private cleanupKeyboardInteractions;
471
493
  /**
472
494
  * Remove Rive Listeners setup on the canvas
473
495
  */
@@ -482,6 +504,11 @@ export declare class Rive {
482
504
  private initArtboard;
483
505
  drawFrame(): void;
484
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;
485
512
  private lastRenderTime;
486
513
  private frameRequestId;
487
514
  /**
@@ -489,6 +516,13 @@ export declare class Rive {
489
516
  * Used for debugging purposes
490
517
  */
491
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;
492
526
  /**
493
527
  * Draw rendering loop; renders animation frames at the correct time interval.
494
528
  * @param time the time at which to render a frame
@@ -813,6 +847,11 @@ export declare class Rive {
813
847
  getArtboard(name: string): Artboard | null;
814
848
  getBindableArtboard(name: string): BindableArtboard | null;
815
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;
816
855
  }
817
856
  export declare enum DataType {
818
857
  none = "none",