@rive-app/webgl-single 2.1.4 → 2.2.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.
@@ -50,7 +50,7 @@ export interface RiveCanvas {
50
50
  makeRenderer(
51
51
  canvas: HTMLCanvasElement | OffscreenCanvas,
52
52
  useOffscreenRenderer?: boolean
53
- ): CanvasRenderer | Renderer;
53
+ ): WrappedRenderer;
54
54
 
55
55
  /**
56
56
  * Computes how the Rive is laid out onto the canvas
@@ -203,29 +203,38 @@ export declare class CanvasRenderer extends Renderer {
203
203
  constructor(
204
204
  ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
205
205
  );
206
-
207
- /**
208
- * Canvas2D API for drawing an image onto a canvas
209
- */
210
- drawImage: (
211
- image:
212
- | HTMLImageElement
213
- | SVGImageElement
214
- | HTMLVideoElement
215
- | HTMLCanvasElement
216
- | ImageBitmap
217
- | OffscreenCanvas,
218
- sx?: number,
219
- sy?: number,
220
- sWidth?: number,
221
- sHeight?: number,
222
- dx?: number,
223
- dy?: number,
224
- dWidth?: number,
225
- dHeight?: number
226
- ) => void;
227
206
  }
228
207
 
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";
221
+
222
+ /**
223
+ * Proxy class that handles calls to a CanvasRenderer instance and handles Rive-related rendering calls such
224
+ * as `save`, `restore`, `transform`, and more, effectively overriding and/or wrapping Canvas2D context
225
+ * APIs for Rive-specific purposes. Other calls not intentionally overridden are passed through to the
226
+ * Canvas2D context directly.
227
+ *
228
+ * Note: Currently, any calls to the Canvas2D context that you expect to return a value (i.e. `isPointInStroke()`)
229
+ * will return undefined
230
+ */
231
+ export type CanvasRendererProxy = CanvasRenderer & Omit<CanvasRenderingContext2D, OmittedCanvasRenderingContext2DMethods>;
232
+
233
+ /**
234
+ * Renderer type for `makeRenderer()` that returns Renderer (webgl) or a CanvasRendererProxy (canvas2d)
235
+ */
236
+ export type WrappedRenderer = Renderer | CanvasRendererProxy;
237
+
229
238
  export declare class CanvasRenderPaint extends RenderPaint {
230
239
  draw(
231
240
  ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,