@rive-app/webgl2-threads 2.49.0 → 2.49.2

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/rive.wasm CHANGED
Binary file
@@ -85,6 +85,14 @@ export interface RiveCanvas {
85
85
  */
86
86
  enableReplayWorker?(): boolean;
87
87
 
88
+ /**
89
+ * @internal Settles once the replay worker's device caps reach the page, so
90
+ * scripts read truthful features before any canvas reaches the worker.
91
+ *
92
+ * @returns undefined when nothing replays on the worker
93
+ */
94
+ awaitReplayCaps?(): Promise<void> | undefined;
95
+
88
96
  /**
89
97
  * Loads a Rive file for the runtime and returns a Rive-specific File class
90
98
  *
@@ -311,6 +319,11 @@ export declare class RendererWrapper {
311
319
  * is as many frames behind as it queues. Skip the frame rather than record it.
312
320
  */
313
321
  acceptsFrame?(): boolean;
322
+ /**
323
+ * @experimental How long the replay worker's recent frames took to finish,
324
+ * in milliseconds, or 0 before its first.
325
+ */
326
+ replayMs?(): number;
314
327
  /**
315
328
  * @experimental True once the replay worker's context was lost and restored.
316
329
  * What it held is gone, so the renderer and the file's session must be
Binary file
package/rive_threads.wasm CHANGED
Binary file
@@ -12,6 +12,8 @@ export declare class RuntimeLoader {
12
12
  private static triedThreads;
13
13
  private static parallelParts;
14
14
  private static replayWorker;
15
+ private static replayCapsArrived;
16
+ private static readonly replayCapsTimeoutMs;
15
17
  private static errorCallbackQueue;
16
18
  private constructor();
17
19
  /**
@@ -25,6 +27,12 @@ export declare class RuntimeLoader {
25
27
  private static loadUnthreaded;
26
28
  static getInstance(callback: RuntimeCallback, onError?: (error: Error) => void): void;
27
29
  static awaitInstance(): Promise<rc.RiveCanvas>;
30
+ /**
31
+ * @internal Resolves once the replay worker's device caps reach the page,
32
+ * so scripts init against them. Null when there is nothing left to wait
33
+ * for, which keeps every later instance's load synchronous.
34
+ */
35
+ static awaitReplayCaps(): Promise<void> | null;
28
36
  static setWasmUrl(url: string): void;
29
37
  static getWasmUrl(): string;
30
38
  /**
package/utils/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { GamepadInteractions } from "./gamepadInteractions";
5
5
  export { BLANK_URL, sanitizeUrl } from "./sanitizeUrl";
6
6
  export { Finalizable, ImageWrapper, AudioWrapper, FontWrapper, FileAssetWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, finalizationRegistry, CustomFileAssetLoaderWrapper, AssetLoadCallbackWrapper, FileFinalizer, createFinalization, } from "./finalizationRegistry";
7
7
  export { RiveFont } from "./riveFont";
8
+ export { ReplayPacer } from "./replayPacer";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Paces recording to a replay worker slower than the display. Recording as
3
+ * soon as its queue frees sends frames in bursts, so instead they go out every
4
+ * N refreshes, with N following the worker's recent replay time.
5
+ */
6
+ export declare class ReplayPacer {
7
+ private lastTime;
8
+ private lastRecord;
9
+ private intervals;
10
+ private divisor;
11
+ private settle;
12
+ private nextProbe;
13
+ private probing;
14
+ private probeAfter;
15
+ private backedUp;
16
+ private recentBackups;
17
+ /**
18
+ * Called on every animation frame. Returns whether this one should record,
19
+ * given the worker's replay time and whether its queue has room.
20
+ */
21
+ shouldRecord(time: number, replayMs: number, accepts: boolean): boolean;
22
+ private adapt;
23
+ private setDivisor;
24
+ }