@rive-app/webgl2 2.51.0 → 2.52.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/webgl2",
3
- "version": "2.51.0",
3
+ "version": "2.52.0",
4
4
  "description": "Rive web runtime with the WebGL2 renderer. Rive is an agent-native 2D and 3D engine for games, apps, and interactive UI.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -119,7 +119,8 @@ export declare enum StateMachineInputType {
119
119
  export declare class StateMachineInput {
120
120
  readonly type: StateMachineInputType;
121
121
  private runtimeInput;
122
- constructor(type: StateMachineInputType, runtimeInput: rc.SMIInput);
122
+ private onChange?;
123
+ constructor(type: StateMachineInputType, runtimeInput: rc.SMIInput, onChange?: () => void);
123
124
  /**
124
125
  * Returns the name of the input
125
126
  */
@@ -439,6 +440,17 @@ export interface RiveParameters {
439
440
  * Enum with drawing options for optimizations
440
441
  */
441
442
  drawingOptions?: DrawOptimizationOptions;
443
+ /**
444
+ * Stop the render loop once every playing state machine has nothing left to
445
+ * animate, and restart it when something changes: pointer, keyboard, focus
446
+ * or gamepad input, state machine inputs, view model values, text runs,
447
+ * assets, layout or size. While stopped, `isSettled` is true and nothing is
448
+ * advanced or drawn. Changes the runtime can't see (for example writing
449
+ * `canvas.width` directly) need a `drawFrame()` call. Linear animations
450
+ * without a state machine never settle. Defaults to false, but will be enabled
451
+ * by default in the next major version.
452
+ */
453
+ enableSettling?: boolean;
442
454
  /**
443
455
  * @experimental This API is early and may encounter breaking behavior change without a major version bump
444
456
  *
@@ -800,6 +812,10 @@ export declare class Rive {
800
812
  private _boundDraw;
801
813
  private _pageVisibilityHandler;
802
814
  private _explicitlyStoppedRendering;
815
+ private _enableSettling;
816
+ private _wakeGeneration;
817
+ private readonly _wakeFromViewModel;
818
+ private static wakeSettledInstances;
803
819
  private _viewModelInstance;
804
820
  private _globalViewModelInstances;
805
821
  private _dataEnums;
@@ -919,6 +935,7 @@ export declare class Rive {
919
935
  *
920
936
  * @param elapsedTime time to advance the state machine by
921
937
  * @param frameTime the rAF timestamp; omitted by pointer drains, which skip gamepad polling.
938
+ * @returns false when only state machines are playing and none has anything left to animate
922
939
  */
923
940
  private advanceAndReportChanges;
924
941
  /**
@@ -1273,6 +1290,22 @@ export declare class Rive {
1273
1290
  * renderer is already active, then this will have zero effect.
1274
1291
  */
1275
1292
  startRendering(): void;
1293
+ /**
1294
+ * True while `enableSettling` has stopped the render loop because every
1295
+ * playing state machine has nothing left to animate. Not set by `pause()`
1296
+ * or `stopRendering()`.
1297
+ */
1298
+ get isSettled(): boolean;
1299
+ private get isInSettledInstances();
1300
+ private addToSettledInstances;
1301
+ private removeFromSettledInstances;
1302
+ private removeFromSettledInstancesIfNotPlaying;
1303
+ /** Whether the loop needs another frame: always, unless settled with no gamepad to poll. */
1304
+ private get needsNextFrame();
1305
+ /** The state machine that receives gamepad input. */
1306
+ private get gamepadStateMachine();
1307
+ /** Records a change, and restarts the loop if it stopped because it settled. */
1308
+ private wake;
1276
1309
  private scheduleRendering;
1277
1310
  /**
1278
1311
  * Called when document.visibilitychange fires (tab change, window minimize, etc.).
@@ -1356,6 +1389,9 @@ export declare class Rive {
1356
1389
  * to batch multiple changes into a single rebind.
1357
1390
  */
1358
1391
  setViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
1392
+ /** Takes a reference to `next` in place of `previous`; with settling on, writes to `next` wake this instance. */
1393
+ private holdViewModelInstance;
1394
+ private releaseViewModelInstance;
1359
1395
  /**
1360
1396
  * Applies any pending `set*` view model instance changes by rebinding the
1361
1397
  * data binds once.
@@ -1446,11 +1482,16 @@ export declare class ViewModelInstance {
1446
1482
  private _viewModelInstances;
1447
1483
  private _propertiesWithCallbacks;
1448
1484
  private _referenceCount;
1485
+ private _wakeCallbacks;
1449
1486
  selfUnref: boolean;
1450
1487
  constructor(runtimeInstance: rc.ViewModelInstance, parent: ViewModelInstance | null);
1451
1488
  get runtimeInstance(): rc.ViewModelInstance | null;
1452
1489
  get nativeInstance(): rc.ViewModelInstance | null;
1453
1490
  handleCallbacks(): void;
1491
+ internalAddWakeCallback(callback: () => void): void;
1492
+ internalRemoveWakeCallback(callback: () => void): void;
1493
+ internalWake(): void;
1494
+ private wakeOwners;
1454
1495
  addParent(parent: ViewModelInstance): void;
1455
1496
  removeParent(parent: ViewModelInstance): void;
1456
1497
  addToPropertyCallbacks(property: ViewModelInstanceValue): void;
@@ -1553,6 +1594,8 @@ export declare class ViewModelInstanceValue {
1553
1594
  on(callback: EventCallback): void;
1554
1595
  off(callback?: EventCallback): void;
1555
1596
  internalHandleCallback(callback: Function): void;
1597
+ /** Wakes every Rive instance the owning view model instance is bound to. */
1598
+ protected wakeOwners(): void;
1556
1599
  handleCallbacks(): void;
1557
1600
  clearChanges(): void;
1558
1601
  clearCallbacks(): void;