@rive-app/webgl-single 2.4.4 → 2.6.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.
@@ -16,6 +16,7 @@ export interface RiveCanvas {
16
16
  CanvasRenderer: typeof CanvasRenderer;
17
17
  LinearAnimationInstance: typeof LinearAnimationInstance;
18
18
  StateMachineInstance: typeof StateMachineInstance;
19
+ CustomFileAssetLoader: typeof CustomFileAssetLoader;
19
20
  Mat2D: typeof Mat2D;
20
21
  Vec2D: typeof Vec2D;
21
22
  AABB: AABB;
@@ -28,14 +29,22 @@ export interface RiveCanvas {
28
29
  RenderPaintStyle: typeof RenderPaintStyle;
29
30
  StrokeCap: typeof StrokeCap;
30
31
  StrokeJoin: typeof StrokeJoin;
32
+ decodeImage: Function;
33
+ decodeFont: Function;
31
34
 
32
35
  /**
33
36
  * Loads a Rive file for the runtime and returns a Rive-specific File class
34
37
  *
35
38
  * @param buffer - Array buffer of a Rive file
39
+ * @param assetLoader - FileAssetLoader used to optionally customize loading of font and image assets
40
+ * @param enableRiveAssetCDN - boolean flag to allow loading assets from the Rive CDN, enabled by default.
36
41
  * @returns A Promise for a Rive File class
37
42
  */
38
- load(buffer: Uint8Array): Promise<File>;
43
+ load(
44
+ buffer: Uint8Array,
45
+ assetLoader?: FileAssetLoader,
46
+ enableRiveAssetCDN?: boolean,
47
+ ): Promise<File>;
39
48
 
40
49
  /**
41
50
  * Creates the renderer to draw the Rive on the provided canvas element
@@ -49,7 +58,7 @@ export interface RiveCanvas {
49
58
  */
50
59
  makeRenderer(
51
60
  canvas: HTMLCanvasElement | OffscreenCanvas,
52
- useOffscreenRenderer?: boolean
61
+ useOffscreenRenderer?: boolean,
53
62
  ): WrappedRenderer;
54
63
 
55
64
  /**
@@ -65,7 +74,7 @@ export interface RiveCanvas {
65
74
  fit: Fit,
66
75
  alignment: Alignment,
67
76
  frame: AABB,
68
- content: AABB
77
+ content: AABB,
69
78
  ): Mat2D;
70
79
  mapXY(matrix: Mat2D, canvasPoints: Vec2D): Vec2D;
71
80
  /**
@@ -158,7 +167,7 @@ export declare class RenderPathWrapper {
158
167
  ix: number,
159
168
  iy: number,
160
169
  x: number,
161
- y: number
170
+ y: number,
162
171
  ): void;
163
172
  close(): void;
164
173
  }
@@ -201,34 +210,36 @@ export declare class RenderPaint extends RenderPaintWrapper {}
201
210
  /////////////////////
202
211
  export declare class CanvasRenderer extends Renderer {
203
212
  constructor(
204
- ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
213
+ ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
205
214
  );
206
215
  }
207
216
 
208
- type OmittedCanvasRenderingContext2DMethods = "createConicGradient" |
209
- "createImageData" |
210
- "createLinearGradient" |
211
- "createPattern" |
212
- "createRadialGradient" |
213
- "getContextAttributes" |
214
- "getImageData" |
215
- "getLineDash" |
216
- "getTransform" |
217
- "isContextLost" |
218
- "isPointInPath" |
219
- "isPointInStroke" |
220
- "measureText";
217
+ type OmittedCanvasRenderingContext2DMethods =
218
+ | "createConicGradient"
219
+ | "createImageData"
220
+ | "createLinearGradient"
221
+ | "createPattern"
222
+ | "createRadialGradient"
223
+ | "getContextAttributes"
224
+ | "getImageData"
225
+ | "getLineDash"
226
+ | "getTransform"
227
+ | "isContextLost"
228
+ | "isPointInPath"
229
+ | "isPointInStroke"
230
+ | "measureText";
221
231
 
222
232
  /**
223
233
  * Proxy class that handles calls to a CanvasRenderer instance and handles Rive-related rendering calls such
224
234
  * as `save`, `restore`, `transform`, and more, effectively overriding and/or wrapping Canvas2D context
225
235
  * APIs for Rive-specific purposes. Other calls not intentionally overridden are passed through to the
226
236
  * Canvas2D context directly.
227
- *
237
+ *
228
238
  * Note: Currently, any calls to the Canvas2D context that you expect to return a value (i.e. `isPointInStroke()`)
229
239
  * will return undefined
230
240
  */
231
- export type CanvasRendererProxy = CanvasRenderer & Omit<CanvasRenderingContext2D, OmittedCanvasRenderingContext2DMethods>;
241
+ export type CanvasRendererProxy = CanvasRenderer &
242
+ Omit<CanvasRenderingContext2D, OmittedCanvasRenderingContext2DMethods>;
232
243
 
233
244
  /**
234
245
  * Renderer type for `makeRenderer()` that returns Renderer (webgl) or a CanvasRendererProxy (canvas2d)
@@ -238,7 +249,7 @@ export type WrappedRenderer = Renderer | CanvasRendererProxy;
238
249
  export declare class CanvasRenderPaint extends RenderPaint {
239
250
  draw(
240
251
  ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
241
- path: RenderPath
252
+ path: RenderPath,
242
253
  ): void;
243
254
  }
244
255
 
@@ -498,6 +509,10 @@ export declare class LinearAnimationInstance {
498
509
  }
499
510
 
500
511
  export declare class TextValueRun {
512
+ /**
513
+ * Getter for the name of the Text Run
514
+ */
515
+ get name(): string;
501
516
  /**
502
517
  * Getter for text value of the Text Run
503
518
  */
@@ -840,3 +855,19 @@ export declare class Vec2D {
840
855
  */
841
856
  delete(): void;
842
857
  }
858
+
859
+ export declare class FileAsset {
860
+ name: string;
861
+ fileExtension: string;
862
+ isImage: boolean;
863
+ isFont: boolean;
864
+ cdnUuid: boolean;
865
+ }
866
+
867
+ export declare class FileAssetLoader {
868
+ }
869
+
870
+ export declare class CustomFileAssetLoader extends FileAssetLoader {
871
+ constructor({loadContents}: {loadContents:Function});
872
+ loadContents(asset: FileAsset, bytes:any): boolean;
873
+ }