@rive-app/canvas 2.36.0 → 2.37.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/rive.wasm CHANGED
Binary file
@@ -32,6 +32,8 @@ export interface RiveCanvas {
32
32
  decodeAudio: DecodeAudio;
33
33
  decodeImage: DecodeImage;
34
34
  decodeFont: DecodeFont;
35
+ // Returns a pointer value to the FontWrapper
36
+ setFallbackFontCallback: (callback: (missingGlyph: number, fallbackFontIndex: number, weight: number) => number | null) => void;
35
37
 
36
38
  /**
37
39
  * Loads a Rive file for the runtime and returns a Rive-specific File class
@@ -308,9 +310,11 @@ export interface DecodeImage {
308
310
  }
309
311
  export class FontInternal {
310
312
  unref(): void;
313
+ ptr(): number;
311
314
  }
312
315
  export class Font {
313
316
  unref(): void;
317
+ ptr(): number;
314
318
  get nativeFont(): FontInternal;
315
319
  }
316
320
  export interface FontCallback {
Binary file
@@ -0,0 +1,20 @@
1
+ import * as rc from "./rive_advanced.mjs";
2
+ export type RuntimeCallback = (rive: rc.RiveCanvas) => void;
3
+ export declare class RuntimeLoader {
4
+ private static runtime;
5
+ private static isLoading;
6
+ private static callBackQueue;
7
+ private static rive;
8
+ private static wasmURL;
9
+ private constructor();
10
+ /**
11
+ * When true, performance.mark / performance.measure entries are emitted for
12
+ * WASM initialization.
13
+ */
14
+ static enablePerfMarks: boolean;
15
+ private static loadRuntime;
16
+ static getInstance(callback: RuntimeCallback): void;
17
+ static awaitInstance(): Promise<rc.RiveCanvas>;
18
+ static setWasmUrl(url: string): void;
19
+ static getWasmUrl(): string;
20
+ }
@@ -0,0 +1,94 @@
1
+ import * as rc from "../rive_advanced.mjs";
2
+ interface Finalizable {
3
+ unref: () => void;
4
+ }
5
+ declare class FileFinalizer implements Finalizable {
6
+ private _file;
7
+ selfUnref: boolean;
8
+ constructor(file: rc.File);
9
+ unref(): void;
10
+ }
11
+ declare class AssetWrapper implements rc.FinalizableTarget {
12
+ selfUnref: boolean;
13
+ unref(): void;
14
+ }
15
+ declare class ImageWrapper extends AssetWrapper {
16
+ private _nativeImage;
17
+ constructor(image: rc.Image);
18
+ get nativeImage(): rc.ImageInternal;
19
+ unref(): void;
20
+ }
21
+ declare class AudioWrapper extends AssetWrapper {
22
+ private _nativeAudio;
23
+ constructor(audio: rc.Audio);
24
+ get nativeAudio(): rc.AudioInternal;
25
+ unref(): void;
26
+ }
27
+ declare class FontWrapper extends AssetWrapper {
28
+ private _nativeFont;
29
+ constructor(font: rc.Font);
30
+ get nativeFont(): rc.FontInternal;
31
+ unref(): void;
32
+ }
33
+ export type AssetLoadCallbackWrapper = (asset: rc.FileAssetInternal, bytes: Uint8Array) => Boolean;
34
+ declare class CustomFileAssetLoaderWrapper {
35
+ assetLoader: rc.CustomFileAssetLoader;
36
+ _assetLoaderCallback: AssetLoadCallbackWrapper;
37
+ constructor(runtime: rc.RiveCanvas, loaderCallback: AssetLoadCallbackWrapper);
38
+ loadContents(asset: rc.FileAsset, bytes: any): Boolean;
39
+ }
40
+ /**
41
+ * Rive class representing a FileAsset with relevant metadata fields to describe
42
+ * an asset associated wtih the Rive File
43
+ */
44
+ declare class FileAssetWrapper {
45
+ _nativeFileAsset: rc.FileAssetInternal;
46
+ constructor(nativeAsset: rc.FileAssetInternal);
47
+ decode(bytes: Uint8Array): void;
48
+ get name(): string;
49
+ get fileExtension(): string;
50
+ get uniqueFilename(): string;
51
+ get isAudio(): boolean;
52
+ get isImage(): boolean;
53
+ get isFont(): boolean;
54
+ get cdnUuid(): string;
55
+ get nativeFileAsset(): rc.FileAssetInternal;
56
+ }
57
+ /**
58
+ * Rive class extending the FileAsset that exposes a `setRenderImage()` API with a
59
+ * decoded Image (via the `decodeImage()` API) to set a new Image on the Rive FileAsset
60
+ */
61
+ declare class ImageAssetWrapper extends FileAssetWrapper {
62
+ setRenderImage(image: ImageWrapper): void;
63
+ }
64
+ /**
65
+ * Rive class extending the FileAsset that exposes a `setAudioSource()` API with a
66
+ * decoded Audio (via the `decodeAudio()` API) to set a new Audio on the Rive FileAsset
67
+ */
68
+ declare class AudioAssetWrapper extends FileAssetWrapper {
69
+ setAudioSource(audio: AudioWrapper): void;
70
+ }
71
+ /**
72
+ * Rive class extending the FileAsset that exposes a `setFont()` API with a
73
+ * decoded Font (via the `decodeFont()` API) to set a new Font on the Rive FileAsset
74
+ */
75
+ declare class FontAssetWrapper extends FileAssetWrapper {
76
+ setFont(font: FontWrapper): void;
77
+ }
78
+ declare const FinalizationRegistry: {
79
+ new (fn: Function): typeof FinalizationRegistry;
80
+ register<T extends rc.FinalizableTarget>(object: T, description: Finalizable): void;
81
+ unregister<T>(object: T): void;
82
+ };
83
+ declare class FakeFinalizationRegistry {
84
+ constructor(_: Function);
85
+ register(object: rc.FinalizableTarget): void;
86
+ unregister<T>(_: T): void;
87
+ }
88
+ declare const finalizationRegistry: {
89
+ new (fn: Function): typeof FinalizationRegistry;
90
+ register<T extends rc.FinalizableTarget>(object: T, description: Finalizable): void;
91
+ unregister<T>(object: T): void;
92
+ } | FakeFinalizationRegistry;
93
+ declare const createFinalization: <T extends Finalizable>(target: rc.FinalizableTarget, finalizable: T) => void;
94
+ export { finalizationRegistry, createFinalization, Finalizable, ImageWrapper, AudioWrapper, FontWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, CustomFileAssetLoaderWrapper, FileAssetWrapper, FileFinalizer, };
@@ -0,0 +1,4 @@
1
+ export { registerTouchInteractions } from "./registerTouchInteractions";
2
+ export { BLANK_URL, sanitizeUrl } from "./sanitizeUrl";
3
+ export { Finalizable, ImageWrapper, AudioWrapper, FontWrapper, FileAssetWrapper, ImageAssetWrapper, AudioAssetWrapper, FontAssetWrapper, finalizationRegistry, CustomFileAssetLoaderWrapper, AssetLoadCallbackWrapper, FileFinalizer, createFinalization, } from "./finalizationRegistry";
4
+ export { RiveFont } from "./riveFont";
@@ -0,0 +1,19 @@
1
+ import * as rc from "../rive_advanced.mjs";
2
+ export interface TouchInteractionsParams {
3
+ canvas: HTMLCanvasElement | OffscreenCanvas;
4
+ artboard: rc.Artboard;
5
+ stateMachines: rc.StateMachineInstance[];
6
+ renderer: rc.Renderer;
7
+ rive: rc.RiveCanvas;
8
+ fit: rc.Fit;
9
+ alignment: rc.Alignment;
10
+ isTouchScrollEnabled?: boolean;
11
+ dispatchPointerExit?: boolean;
12
+ enableMultiTouch?: boolean;
13
+ layoutScaleFactor?: number;
14
+ }
15
+ /**
16
+ * Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
17
+ * the state machine pointer move/up/down functions based on cursor interaction
18
+ */
19
+ export declare const registerTouchInteractions: ({ canvas, artboard, stateMachines, renderer, rive, fit, alignment, isTouchScrollEnabled, dispatchPointerExit, enableMultiTouch, layoutScaleFactor, }: TouchInteractionsParams) => () => void;
@@ -0,0 +1,15 @@
1
+ import type { FontWrapper } from "./finalizationRegistry";
2
+ export type FallbackFontsCallback = (missingGlyph: number, weight: number) => FontWrapper | FontWrapper[] | null | undefined;
3
+ export declare class RiveFont {
4
+ private static _fallbackFontCallback;
5
+ private constructor();
6
+ /**
7
+ * Set a callback to dynamically set a list of fallback fonts based on the missing glyph and/or style of the default font.
8
+ * Set null to clear the callback.
9
+ * @param fontCallback Callback to set a list of fallback fonts.
10
+ */
11
+ static setFallbackFontCallback(fontCallback: FallbackFontsCallback | null): void;
12
+ private static _fontToPtr;
13
+ private static _getFallbackPtr;
14
+ private static _wireFallbackProc;
15
+ }
@@ -0,0 +1,2 @@
1
+ export declare const BLANK_URL = "about:blank";
2
+ export declare function sanitizeUrl(url?: string): string;