modern-canvas 0.19.0 → 0.20.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.
@@ -20,6 +20,20 @@ export declare const isVideoElement: (node: unknown) => node is HTMLVideoElement
20
20
  export declare const isImageElement: (node: unknown) => node is HTMLImageElement;
21
21
  export declare function isCanvasElement(node: unknown): node is HTMLCanvasElement;
22
22
  export declare function isWebgl2(gl: unknown): gl is WebGL2RenderingContext;
23
- export declare function createHTMLCanvas(): HTMLCanvasElement | undefined;
24
- export declare function determineCrossOrigin(url: string, loc?: Location): string;
23
+ export type CanvasFactory = (width?: number, height?: number) => HTMLCanvasElement;
24
+ /**
25
+ * Inject a canvas factory for non-browser environments (e.g. node-canvas's
26
+ * `createCanvas`). Lets the engine create offscreen 2D canvases — used for
27
+ * gradients, text/canvas textures and pixel output — without a DOM.
28
+ * Pass `undefined` to clear it.
29
+ */
30
+ export declare function setCanvasFactory(factory: CanvasFactory | undefined): void;
31
+ export declare function getCanvasFactory(): CanvasFactory | undefined;
32
+ /**
33
+ * Create an (offscreen) canvas via the injected factory, falling back to
34
+ * `document.createElement('canvas')` in the browser. Returns `undefined` when
35
+ * neither is available (non-browser with no factory) — callers must guard.
36
+ */
37
+ export declare function createHTMLCanvas(width?: number, height?: number): HTMLCanvasElement | undefined;
38
+ export declare function determineCrossOrigin(url: string, loc?: Location | undefined): string;
25
39
  export declare function crossOrigin(element: HTMLImageElement | HTMLVideoElement, url: string, crossorigin: boolean | string | null): void;