@rive-app/webgl2-threads 2.48.0 → 2.49.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/rive.wasm CHANGED
Binary file
@@ -46,6 +46,9 @@ export interface RiveCanvas {
46
46
  RenderPaintStyle: typeof RenderPaintStyle;
47
47
  StrokeCap: typeof StrokeCap;
48
48
  StrokeJoin: typeof StrokeJoin;
49
+ StrokePosition: typeof StrokePosition;
50
+ ImageFilter: typeof ImageFilter;
51
+ ImageWrap: typeof ImageWrap;
49
52
  decodeAudio: DecodeAudio;
50
53
  decodeImage: DecodeImage;
51
54
  decodeFont: DecodeFont;
@@ -73,6 +76,15 @@ export interface RiveCanvas {
73
76
  */
74
77
  makeDeferredSession?(): DeferredSession | undefined;
75
78
 
79
+ /**
80
+ * @experimental Lets deferred renderers replay on one worker shared by the
81
+ * page. Only in the threaded webgl2 build; call it before loading files, so
82
+ * their images reach the worker too.
83
+ *
84
+ * @returns false where the browser cannot draw WebGL2 on a transferred canvas
85
+ */
86
+ enableReplayWorker?(): boolean;
87
+
76
88
  /**
77
89
  * Loads a Rive file for the runtime and returns a Rive-specific File class
78
90
  *
@@ -203,6 +215,18 @@ export interface RendererOptions {
203
215
  * converted to clockwise on a best-effort basis
204
216
  */
205
217
  inkbleed?: boolean;
218
+ /**
219
+ * @experimental (webgl2-threads only) Hands the canvas to the replay worker,
220
+ * once `enableReplayWorker()` has succeeded. The renderer then replays only
221
+ * deferred sessions. A canvas handed over before keeps going to the worker.
222
+ */
223
+ replayWorker?: boolean;
224
+ /**
225
+ * @experimental (webgl2-threads only) Called when the replay worker
226
+ * restores the renderer's lost context, so an idle instance still draws
227
+ * and notices it.
228
+ */
229
+ onContextRestored?: () => void;
206
230
  }
207
231
 
208
232
  /**
@@ -277,6 +301,22 @@ export declare class RendererWrapper {
277
301
  * @returns false if inkbleed was requested but the canvas context does not support it
278
302
  */
279
303
  setInkbleed?(enabled: boolean): boolean;
304
+ /**
305
+ * @experimental Present on renderers whose canvas is on the replay worker,
306
+ * which can only draw deferred sessions.
307
+ */
308
+ replaysOnWorker?(): boolean;
309
+ /**
310
+ * @experimental False while the replay worker has yet to take the canvas, or
311
+ * is as many frames behind as it queues. Skip the frame rather than record it.
312
+ */
313
+ acceptsFrame?(): boolean;
314
+ /**
315
+ * @experimental True once the replay worker's context was lost and restored.
316
+ * What it held is gone, so the renderer and the file's session must be
317
+ * recreated.
318
+ */
319
+ contextRestored?(): boolean;
280
320
  }
281
321
 
282
322
  export declare class RenderPathWrapper {
@@ -304,11 +344,15 @@ export declare class RenderPathWrapper {
304
344
  close(): void;
305
345
  }
306
346
 
347
+ export declare class RenderImageWrapper {
348
+ }
349
+
307
350
  export declare class RenderPaintWrapper {
308
351
  color(value: number): void;
309
352
  thickness(value: number): void;
310
353
  join(value: StrokeJoin): void;
311
354
  cap(value: StrokeCap): void;
355
+ strokePosition(value: StrokePosition): void;
312
356
  blendMode(value: BlendMode): void;
313
357
  style(value: RenderPaintStyle): void;
314
358
  linearGradient(sx: number, sy: number, ex: number, ey: number): void;
@@ -323,6 +367,19 @@ export declare class RenderPaintWrapper {
323
367
  tx: number,
324
368
  ty: number,
325
369
  ): void;
370
+
371
+ modulatedImage(
372
+ image: RenderImage,
373
+ filter: ImageFilter,
374
+ wrapX: ImageWrap,
375
+ wrapY: ImageWrap,
376
+ xx: number,
377
+ xy: number,
378
+ yx: number,
379
+ yy: number,
380
+ tx: number,
381
+ ty: number,
382
+ ): void;
326
383
  }
327
384
 
328
385
  /**
@@ -352,6 +409,8 @@ export declare class RenderPath extends RenderPathWrapper { }
352
409
 
353
410
  export declare class RenderPaint extends RenderPaintWrapper { }
354
411
 
412
+ export declare class RenderImage extends RenderImageWrapper { }
413
+
355
414
  /////////////////////
356
415
  // CANVAS RENDERER //
357
416
  /////////////////////
@@ -1212,7 +1271,7 @@ export declare class StateMachineInstance {
1212
1271
 
1213
1272
  /**
1214
1273
  * The selected text of the focused element, or an empty string when nothing with a
1215
- * selection is focused. Used to fill the clipboard on copy/cut. An obscured field
1274
+ * selection is focused. Used to fill the clipboard on copy/cut. An obscured field
1216
1275
  * (i.e. a password) reports empty string.
1217
1276
  */
1218
1277
  selectedText(): string;
@@ -1541,6 +1600,23 @@ export enum BlendMode {
1541
1600
  luminosity = 28,
1542
1601
  }
1543
1602
 
1603
+ export enum ImageFilter {
1604
+ bilinear,
1605
+ nearest,
1606
+ }
1607
+
1608
+ export enum ImageWrap {
1609
+ clamp,
1610
+ repeat,
1611
+ mirror,
1612
+ }
1613
+
1614
+ export enum StrokePosition {
1615
+ inside,
1616
+ center,
1617
+ outside,
1618
+ }
1619
+
1544
1620
  ///////////
1545
1621
  // UTILS //
1546
1622
  ///////////
Binary file
package/rive_threads.wasm CHANGED
Binary file
@@ -10,6 +10,8 @@ export declare class RuntimeLoader {
10
10
  private static wasmBinary;
11
11
  private static wasmThreadsURL;
12
12
  private static triedThreads;
13
+ private static parallelParts;
14
+ private static replayWorker;
13
15
  private static errorCallbackQueue;
14
16
  private constructor();
15
17
  /**
@@ -43,6 +45,29 @@ export declare class RuntimeLoader {
43
45
  */
44
46
  static setWasmThreadsUrl(url: string | null): void;
45
47
  static getWasmThreadsUrl(): string | null;
48
+ /**
49
+ * Sets how many parts a script's parallel call gets on a page that runs
50
+ * the threaded build, the page's thread and one worker thread for each
51
+ * other part. 1 turns parallel calls off, and null leaves the runtime's
52
+ * default of one part per core, up to 8. Set it before the first file
53
+ * loads.
54
+ */
55
+ static setParallelParts(parts: number | null): void;
56
+ static getParallelParts(): number | null;
57
+ private static applyParallelParts;
58
+ /**
59
+ * @experimental When the threaded build loads, instances with
60
+ * `enableGPUCanvas` hand their canvas to one worker that replays every
61
+ * instance's frames while the page records the next ones. Pass `false`
62
+ * before the runtime loads to keep replay on the page's thread; a single
63
+ * instance can opt out with `useReplayWorker: false`. Pages where the
64
+ * browser cannot draw WebGL2 on a transferred canvas stay on the page's
65
+ * thread regardless.
66
+ *
67
+ * True by default.
68
+ */
69
+ static setReplayWorker(enabled: boolean): void;
70
+ static getReplayWorker(): boolean;
46
71
  static setWasmBinary(value: ArrayBuffer | null): void;
47
72
  static getWasmBinary(): ArrayBuffer | null;
48
73
  }