@rive-app/webgl2-threads 2.47.1 → 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/package.json +1 -1
- package/rive.d.ts +51 -1
- package/rive.js +1432 -762
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +87 -1
- package/rive_fallback.wasm +0 -0
- package/rive_threads.wasm +0 -0
- package/runtimeLoader.d.ts +25 -0
- package/utils/gamepadBatchEncoder.d.ts +51 -0
- package/utils/gamepadInteractions.d.ts +25 -0
- package/utils/index.d.ts +1 -0
package/rive.wasm
CHANGED
|
Binary file
|
package/rive_advanced.mjs.d.ts
CHANGED
|
@@ -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
|
/////////////////////
|
|
@@ -1200,9 +1259,19 @@ export declare class StateMachineInstance {
|
|
|
1200
1259
|
*/
|
|
1201
1260
|
textInput(text: string): boolean;
|
|
1202
1261
|
|
|
1262
|
+
/**
|
|
1263
|
+
* Submit one frame of gamepad input encoded in the v2 wire format
|
|
1264
|
+
* (see rive-runtime/include/rive/input/gamepad_batch.hpp). Events route to the primary focus
|
|
1265
|
+
* node and bubble up its ancestors; with nothing focused, only scripted drawables receive them.
|
|
1266
|
+
* @param batch - little-endian v2 batch of connected/update/disconnected records
|
|
1267
|
+
* @returns false if the batch was rejected (bad version, malformed record, unknown device,
|
|
1268
|
+
* or no focus manager)
|
|
1269
|
+
*/
|
|
1270
|
+
submitGamepadsFromBuffer(batch: Uint8Array): boolean;
|
|
1271
|
+
|
|
1203
1272
|
/**
|
|
1204
1273
|
* The selected text of the focused element, or an empty string when nothing with a
|
|
1205
|
-
* 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
|
|
1206
1275
|
* (i.e. a password) reports empty string.
|
|
1207
1276
|
*/
|
|
1208
1277
|
selectedText(): string;
|
|
@@ -1531,6 +1600,23 @@ export enum BlendMode {
|
|
|
1531
1600
|
luminosity = 28,
|
|
1532
1601
|
}
|
|
1533
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
|
+
|
|
1534
1620
|
///////////
|
|
1535
1621
|
// UTILS //
|
|
1536
1622
|
///////////
|
package/rive_fallback.wasm
CHANGED
|
Binary file
|
package/rive_threads.wasm
CHANGED
|
Binary file
|
package/runtimeLoader.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Must match `rive::kGamepadBatchWireVersion` (runtime/include/rive/input/gamepad_batch.hpp). */
|
|
2
|
+
export declare const GAMEPAD_BATCH_VERSION = 2;
|
|
3
|
+
export declare const GAMEPAD_MAX_BUTTONS = 32;
|
|
4
|
+
export declare const GAMEPAD_MAX_AXES = 16;
|
|
5
|
+
/** C++ `rive::GamepadRecordType`. */
|
|
6
|
+
export declare enum GamepadRecordType {
|
|
7
|
+
Connected = 0,
|
|
8
|
+
Update = 1,
|
|
9
|
+
Disconnected = 2
|
|
10
|
+
}
|
|
11
|
+
/** C++ `rive::GamepadInputChangeKind`. */
|
|
12
|
+
export declare enum GamepadChangeKind {
|
|
13
|
+
Button = 0,
|
|
14
|
+
Axis = 1
|
|
15
|
+
}
|
|
16
|
+
/** C++ `rive::GamepadMappingKind`. */
|
|
17
|
+
export declare enum GamepadMappingKind {
|
|
18
|
+
Standard = 0,
|
|
19
|
+
Unknown = 1
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Builds buffer to send to the state machine for gamepad input connection/updates/disconnect.
|
|
23
|
+
*
|
|
24
|
+
* Each `update` record carries a single change: the core
|
|
25
|
+
* applies and dispatches records in order, so N single-change records in one batch behave like
|
|
26
|
+
* N separate submits.
|
|
27
|
+
*
|
|
28
|
+
* `end()` returns a view into a reused scratch buffer, valid until the next `begin()`.
|
|
29
|
+
*/
|
|
30
|
+
export declare class GamepadBatchEncoder {
|
|
31
|
+
private buffer;
|
|
32
|
+
private view;
|
|
33
|
+
private bytes;
|
|
34
|
+
private offset;
|
|
35
|
+
constructor(initialCapacity?: number);
|
|
36
|
+
begin(): void;
|
|
37
|
+
/** True when no records were written since `begin()`. */
|
|
38
|
+
get isEmpty(): boolean;
|
|
39
|
+
/** Set up buffer size/initialized values for a connected device */
|
|
40
|
+
connected(deviceId: number, mapping: GamepadMappingKind, buttonValues: ArrayLike<number>, axes: ArrayLike<number>): void;
|
|
41
|
+
/** */
|
|
42
|
+
update(deviceId: number, kind: GamepadChangeKind, index: number, value: number): void;
|
|
43
|
+
disconnected(deviceId: number): void;
|
|
44
|
+
end(): Uint8Array;
|
|
45
|
+
/** ---------------- Helper/private methods ---------------- */
|
|
46
|
+
private writeU8;
|
|
47
|
+
private writeU32;
|
|
48
|
+
private writeI32;
|
|
49
|
+
private writeF32;
|
|
50
|
+
private ensure;
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as rc from "../rive_advanced.mjs";
|
|
2
|
+
export interface GamepadInteractionsParams {
|
|
3
|
+
/** Hold button/axis input at rest unless DOM focus is within the canvas/overlay. Pads still connect. */
|
|
4
|
+
requireFocus: boolean;
|
|
5
|
+
isFocusWithin: () => boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Per-Rive-instance gamepad bridge driving a single state machine. Tracks what that state
|
|
9
|
+
* machine has been sent and submits only the difference, so after a pause it catches up
|
|
10
|
+
* without duplicate connected events.
|
|
11
|
+
*/
|
|
12
|
+
export declare class GamepadInteractions {
|
|
13
|
+
private params;
|
|
14
|
+
private encoder;
|
|
15
|
+
private stateMachine;
|
|
16
|
+
private lastSentPads;
|
|
17
|
+
private submitFailures;
|
|
18
|
+
constructor(params: GamepadInteractionsParams);
|
|
19
|
+
/** Poll, diff and submit one batch. Call once per frame before advancing. */
|
|
20
|
+
handleGamepadInputs(time: number, stateMachine: rc.StateMachineInstance | undefined): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
/** Writes records that bring `lastSentPads` up to `pads`, updating it as it goes. */
|
|
23
|
+
private encodeDiff;
|
|
24
|
+
private encodeChanges;
|
|
25
|
+
}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { registerTouchInteractions } from "./registerTouchInteractions";
|
|
2
2
|
export { KeyboardInteractions, FocusSessionState } from "./registerKeyboardInteractions";
|
|
3
3
|
export type { KeyboardInteractionsParams } from "./registerKeyboardInteractions";
|
|
4
|
+
export { GamepadInteractions } from "./gamepadInteractions";
|
|
4
5
|
export { BLANK_URL, sanitizeUrl } from "./sanitizeUrl";
|
|
5
6
|
export { Finalizable, ImageWrapper, AudioWrapper, FontWrapper, FileAssetWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, finalizationRegistry, CustomFileAssetLoaderWrapper, AssetLoadCallbackWrapper, FileFinalizer, createFinalization, } from "./finalizationRegistry";
|
|
6
7
|
export { RiveFont } from "./riveFont";
|