@remotion/web-renderer 4.0.405 → 4.0.407
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/dist/compose.d.ts +3 -2
- package/dist/create-scaffold.d.ts +7 -2
- package/dist/drawing/draw-background.d.ts +2 -1
- package/dist/drawing/draw-element.d.ts +2 -1
- package/dist/drawing/get-background-fill.d.ts +8 -0
- package/dist/drawing/handle-3d-transform.d.ts +2 -1
- package/dist/drawing/handle-mask.d.ts +2 -1
- package/dist/drawing/process-node.d.ts +2 -1
- package/dist/drawing/scale-rect.d.ts +4 -0
- package/dist/drawing/text/draw-text.d.ts +3 -2
- package/dist/drawing/text/find-line-breaks.text.d.ts +5 -4
- package/dist/drawing/text/get-collapsed-text.d.ts +8 -1
- package/dist/drawing/text/handle-text-node.d.ts +3 -2
- package/dist/drawing/transform-in-3d.d.ts +2 -1
- package/dist/drawing/transform.d.ts +2 -1
- package/dist/esm/index.mjs +351 -407
- package/dist/render-media-on-web.d.ts +1 -0
- package/dist/render-still-on-web.d.ts +1 -0
- package/dist/take-screenshot.d.ts +6 -31
- package/dist/tree-walker-cleanup-after-children.d.ts +1 -1
- package/dist/validate-scale.d.ts +1 -0
- package/dist/{drawing/precompose-and-draw.d.ts → walk-over-node.d.ts} +9 -14
- package/package.json +7 -6
- package/dist/drawing/elements-and-bounds.d.ts +0 -9
- package/dist/drawing/precompose-element.d.ts +0 -0
- package/dist/drawing/renoun.d.ts +0 -125
- package/dist/drawing/transform-origin.d.ts +0 -21
- package/dist/drawing/transform-perspective-origin.d.ts +0 -17
- package/dist/get-audio-sample-source.d.ts +0 -8
- package/dist/renoun.d.ts +0 -119
|
@@ -50,6 +50,7 @@ type OptionalRenderMediaOnWebOptions<Schema extends AnyZodObject> = {
|
|
|
50
50
|
outputTarget: WebRendererOutputTarget | null;
|
|
51
51
|
licenseKey: string | undefined;
|
|
52
52
|
muted: boolean;
|
|
53
|
+
scale: number;
|
|
53
54
|
};
|
|
54
55
|
export type RenderMediaOnWebOptions<Schema extends AnyZodObject, Props extends Record<string, unknown>> = MandatoryRenderMediaOnWebOptions<Schema, Props> & Partial<OptionalRenderMediaOnWebOptions<Schema>> & InputPropsIfHasProps<Schema, Props>;
|
|
55
56
|
export declare const renderMediaOnWeb: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(options: RenderMediaOnWebOptions<Schema, Props>) => Promise<RenderMediaOnWebResult>;
|
|
@@ -18,6 +18,7 @@ type OptionalRenderStillOnWebOptions<Schema extends AnyZodObject> = {
|
|
|
18
18
|
signal: AbortSignal | null;
|
|
19
19
|
onArtifact: WebRendererOnArtifact | null;
|
|
20
20
|
licenseKey: string | undefined;
|
|
21
|
+
scale: number;
|
|
21
22
|
};
|
|
22
23
|
export type RenderStillOnWebOptions<Schema extends AnyZodObject, Props extends Record<string, unknown>> = MandatoryRenderStillOnWebOptions<Schema, Props> & Partial<OptionalRenderStillOnWebOptions<Schema>> & InputPropsIfHasProps<Schema, Props>;
|
|
23
24
|
export declare const renderStillOnWeb: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(options: RenderStillOnWebOptions<Schema, Props>) => Promise<{
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
1
|
+
export declare const createLayer: ({ element, scale, logLevel, internalState, onlyBackgroundClipText, cutout, }: {
|
|
2
|
+
element: HTMLElement | SVGElement;
|
|
3
|
+
scale: number;
|
|
6
4
|
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
7
5
|
internalState: {
|
|
8
6
|
getDrawn3dPixels: () => number;
|
|
@@ -22,29 +20,6 @@ export declare const createFrame: ({ div, width, height, logLevel, internalState
|
|
|
22
20
|
getAudioMixingTime: () => number;
|
|
23
21
|
addAudioMixingTime: (time: number) => void;
|
|
24
22
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
width: number;
|
|
29
|
-
height: number;
|
|
30
|
-
imageFormat: RenderStillOnWebImageFormat;
|
|
31
|
-
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
32
|
-
internalState: {
|
|
33
|
-
getDrawn3dPixels: () => number;
|
|
34
|
-
getPrecomposedTiles: () => number;
|
|
35
|
-
addPrecompose: ({ canvasWidth, canvasHeight, }: {
|
|
36
|
-
canvasWidth: number;
|
|
37
|
-
canvasHeight: number;
|
|
38
|
-
}) => void;
|
|
39
|
-
helperCanvasState: import("./internal-state").HelperCanvasState;
|
|
40
|
-
[Symbol.dispose]: () => void;
|
|
41
|
-
getWaitForReadyTime: () => number;
|
|
42
|
-
addWaitForReadyTime: (time: number) => void;
|
|
43
|
-
getAddSampleTime: () => number;
|
|
44
|
-
addAddSampleTime: (time: number) => void;
|
|
45
|
-
getCreateFrameTime: () => number;
|
|
46
|
-
addCreateFrameTime: (time: number) => void;
|
|
47
|
-
getAudioMixingTime: () => number;
|
|
48
|
-
addAudioMixingTime: (time: number) => void;
|
|
49
|
-
};
|
|
50
|
-
}) => Promise<Blob>;
|
|
23
|
+
onlyBackgroundClipText: boolean;
|
|
24
|
+
cutout: DOMRect;
|
|
25
|
+
}) => Promise<OffscreenCanvasRenderingContext2D>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const createTreeWalkerCleanupAfterChildren: (treeWalker: TreeWalker) => {
|
|
2
2
|
checkCleanUpAtBeginningOfIteration: () => void;
|
|
3
3
|
addCleanup: (element: Node, cleanupFn: () => void) => void;
|
|
4
|
-
|
|
4
|
+
[Symbol.dispose]: () => void;
|
|
5
5
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateScale: (scale: unknown) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ProcessNodeReturnValue } from './drawing/process-node';
|
|
2
|
+
export declare const walkOverNode: ({ node, context, logLevel, parentRect, internalState, rootElement, onlyBackgroundClipText, scale, }: {
|
|
3
|
+
node: Node;
|
|
4
|
+
context: OffscreenCanvasRenderingContext2D;
|
|
5
5
|
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
6
6
|
parentRect: DOMRect;
|
|
7
7
|
internalState: {
|
|
@@ -11,7 +11,7 @@ export declare const precompose: ({ element, logLevel, parentRect, internalState
|
|
|
11
11
|
canvasWidth: number;
|
|
12
12
|
canvasHeight: number;
|
|
13
13
|
}) => void;
|
|
14
|
-
helperCanvasState: import("
|
|
14
|
+
helperCanvasState: import("./internal-state").HelperCanvasState;
|
|
15
15
|
[Symbol.dispose]: () => void;
|
|
16
16
|
getWaitForReadyTime: () => number;
|
|
17
17
|
addWaitForReadyTime: (time: number) => void;
|
|
@@ -22,12 +22,7 @@ export declare const precompose: ({ element, logLevel, parentRect, internalState
|
|
|
22
22
|
getAudioMixingTime: () => number;
|
|
23
23
|
addAudioMixingTime: (time: number) => void;
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}) => Promise<{
|
|
30
|
-
drawable: OffscreenCanvas;
|
|
31
|
-
rectAfterTransforms: DOMRect;
|
|
32
|
-
elementsToBeRenderedIndependently: ElementAndBounds[];
|
|
33
|
-
} | null>;
|
|
25
|
+
rootElement: HTMLElement | SVGElement;
|
|
26
|
+
onlyBackgroundClipText: boolean;
|
|
27
|
+
scale: number;
|
|
28
|
+
}) => Promise<ProcessNodeReturnValue>;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/web-renderer"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/web-renderer",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.407",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"formatting": "prettier --experimental-cli src --check",
|
|
12
12
|
"lint": "eslint src",
|
|
13
13
|
"make": "tsgo && bun --env-file=../.env.bundle bundle.ts",
|
|
14
|
+
"watch": "tsgo -w",
|
|
14
15
|
"testwebrenderer": "vitest src/test --browser --run",
|
|
15
16
|
"studio": "cd ../example && bunx remotion studio ../web-renderer/src/test/studio.ts --public-dir=../example-videos/videos",
|
|
16
17
|
"remotion": "cd ../example && bunx remotion studio ../web-renderer/src/test/studio.ts --public-dir=../example-videos/videos"
|
|
@@ -18,14 +19,14 @@
|
|
|
18
19
|
"author": "Remotion <jonny@remotion.dev>",
|
|
19
20
|
"license": "UNLICENSED",
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@remotion/licensing": "4.0.
|
|
22
|
-
"remotion": "4.0.
|
|
22
|
+
"@remotion/licensing": "4.0.407",
|
|
23
|
+
"remotion": "4.0.407",
|
|
23
24
|
"mediabunny": "1.27.3"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
27
|
-
"@remotion/player": "4.0.
|
|
28
|
-
"@remotion/media": "4.0.
|
|
27
|
+
"@remotion/eslint-config-internal": "4.0.407",
|
|
28
|
+
"@remotion/player": "4.0.407",
|
|
29
|
+
"@remotion/media": "4.0.407",
|
|
29
30
|
"@typescript/native-preview": "7.0.0-dev.20260105.1",
|
|
30
31
|
"@vitejs/plugin-react": "4.1.0",
|
|
31
32
|
"@vitest/browser-playwright": "4.0.9",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Precompositing } from './calculate-transforms';
|
|
2
|
-
export type ElementAndBounds = {
|
|
3
|
-
element: Element;
|
|
4
|
-
bounds: DOMRect;
|
|
5
|
-
transform: DOMMatrix;
|
|
6
|
-
parentRect: DOMRect;
|
|
7
|
-
precompositing: Precompositing;
|
|
8
|
-
establishes3DRenderingContext: DOMMatrix | null;
|
|
9
|
-
};
|
|
File without changes
|
package/dist/drawing/renoun.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/** Image format for encoded screenshot output. */
|
|
2
|
-
export type ImageFormat = 'png' | 'jpeg' | 'webp';
|
|
3
|
-
/** Options for rendering a screenshot to canvas. */
|
|
4
|
-
export interface RenderOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Canvas background color. Set to `null` (or omit) for a transparent canvas.
|
|
7
|
-
* When provided, the string is passed directly to `fillStyle`.
|
|
8
|
-
*/
|
|
9
|
-
backgroundColor?: string | null;
|
|
10
|
-
/**
|
|
11
|
-
* Optional existing canvas to render into.
|
|
12
|
-
* When omitted, a new canvas element is created.
|
|
13
|
-
*/
|
|
14
|
-
canvas?: HTMLCanvasElement;
|
|
15
|
-
/**
|
|
16
|
-
* Rendering scale factor. Defaults to `window.devicePixelRatio` (or `1`).
|
|
17
|
-
*/
|
|
18
|
-
scale?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Crop origin X (CSS pixels) relative to the element's left edge.
|
|
21
|
-
* Defaults to the element's left edge.
|
|
22
|
-
*/
|
|
23
|
-
x?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Crop origin Y (CSS pixels) relative to the element's top edge.
|
|
26
|
-
* Defaults to the element's top edge.
|
|
27
|
-
*/
|
|
28
|
-
y?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Output width in CSS pixels. Defaults to the element's width.
|
|
31
|
-
*/
|
|
32
|
-
width?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Output height in CSS pixels. Defaults to the element's height.
|
|
35
|
-
*/
|
|
36
|
-
height?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Controls how `position: fixed` elements outside the captured subtree are
|
|
39
|
-
* handled.
|
|
40
|
-
*
|
|
41
|
-
* - `none` – ignore all fixed elements outside `element`.
|
|
42
|
-
* - `intersecting` – include fixed elements whose bounding rect intersects the capture rect.
|
|
43
|
-
* - `all` – include all fixed elements that overlap the viewport.
|
|
44
|
-
*/
|
|
45
|
-
includeFixed?: 'none' | 'intersecting' | 'all';
|
|
46
|
-
/**
|
|
47
|
-
* CSS selector used to skip elements from rendering.
|
|
48
|
-
* Defaults to `[data-screenshot-ignore]`. Set to `null` or an empty string
|
|
49
|
-
* to disable selector-based skipping.
|
|
50
|
-
*/
|
|
51
|
-
ignoreSelector?: string | null;
|
|
52
|
-
}
|
|
53
|
-
/** Options for encoding a canvas to an image format. */
|
|
54
|
-
export interface EncodeOptions {
|
|
55
|
-
/**
|
|
56
|
-
* Image format to encode. Defaults to `'png'`.
|
|
57
|
-
*/
|
|
58
|
-
format?: ImageFormat;
|
|
59
|
-
/**
|
|
60
|
-
* Image quality for lossy formats (`jpeg`, `webp`). A number between `0` and `1`.
|
|
61
|
-
* Ignored for `png`. Defaults to `0.92`.
|
|
62
|
-
*/
|
|
63
|
-
quality?: number;
|
|
64
|
-
}
|
|
65
|
-
/** Combined options for one-shot screenshot methods that render and encode. */
|
|
66
|
-
export type ScreenshotOptions = RenderOptions & EncodeOptions;
|
|
67
|
-
/**
|
|
68
|
-
* A promise-like object representing a screenshot capture. The underlying
|
|
69
|
-
* render happens once; subsequent calls to `.canvas()`, `.blob()`, or `.url()`
|
|
70
|
-
* reuse the same rendered canvas.
|
|
71
|
-
*/
|
|
72
|
-
export interface ScreenshotTask extends Promise<HTMLCanvasElement> {
|
|
73
|
-
/** Returns the rendered canvas. */
|
|
74
|
-
canvas(): Promise<HTMLCanvasElement>;
|
|
75
|
-
/** Encodes the rendered canvas to a Blob. */
|
|
76
|
-
blob(options?: EncodeOptions): Promise<Blob>;
|
|
77
|
-
/**
|
|
78
|
-
* Encodes the rendered canvas to a Blob and creates an object URL.
|
|
79
|
-
* Remember to call `URL.revokeObjectURL(url)` when done to avoid memory leaks.
|
|
80
|
-
*/
|
|
81
|
-
url(options?: EncodeOptions): Promise<string>;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Renders a DOM element into a canvas using modern browser features.
|
|
85
|
-
*
|
|
86
|
-
* Returns a `ScreenshotTask` that is both a Promise and provides methods
|
|
87
|
-
* to encode the rendered canvas. The underlying render happens once;
|
|
88
|
-
* subsequent calls to `.canvas()`, `.blob()`, or `.url()` reuse the same result.
|
|
89
|
-
*
|
|
90
|
-
* This implementation targets evergreen browsers only and assumes a real DOM +
|
|
91
|
-
* Canvas2D environment (not Node.js).
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* // Capture handle pattern - render once, encode multiple ways
|
|
95
|
-
* const shot = screenshot(element, { scale: 2 })
|
|
96
|
-
* const canvas = await shot.canvas()
|
|
97
|
-
* const pngBlob = await shot.blob({ format: 'png' })
|
|
98
|
-
* const webpUrl = await shot.url({ format: 'webp', quality: 0.9 })
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* // Direct await returns the canvas
|
|
102
|
-
* const canvas = await screenshot(element)
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* // One-shot convenience methods
|
|
106
|
-
* const canvas = await screenshot.canvas(element, { scale: 2 })
|
|
107
|
-
* const blob = await screenshot.blob(element, { format: 'jpeg', quality: 0.85 })
|
|
108
|
-
* const url = await screenshot.url(element, { format: 'png' })
|
|
109
|
-
*/
|
|
110
|
-
declare function screenshot(target: Element | string, options?: RenderOptions): ScreenshotTask;
|
|
111
|
-
declare namespace screenshot {
|
|
112
|
-
var canvas: (target: string | Element, options?: RenderOptions | undefined) => Promise<HTMLCanvasElement>;
|
|
113
|
-
}
|
|
114
|
-
declare namespace screenshot {
|
|
115
|
-
var blob: (target: string | Element, options?: ScreenshotOptions | undefined) => Promise<Blob>;
|
|
116
|
-
}
|
|
117
|
-
declare namespace screenshot {
|
|
118
|
-
var url: (target: string | Element, options?: ScreenshotOptions | undefined) => Promise<string>;
|
|
119
|
-
}
|
|
120
|
-
export { screenshot };
|
|
121
|
-
declare global {
|
|
122
|
-
interface CanvasRenderingContext2D {
|
|
123
|
-
_filterPolyfillValue?: string;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type Transform = {
|
|
2
|
-
matrices: DOMMatrix[];
|
|
3
|
-
element: Element;
|
|
4
|
-
transformOrigin: string;
|
|
5
|
-
boundingClientRect: DOMRect | null;
|
|
6
|
-
};
|
|
7
|
-
export declare const parseTransformOriginOrPerspectiveOrigin: (transformOrigin: string) => {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
} | null;
|
|
11
|
-
export declare const getInternalOrigin: (origin: string, boundingClientRect: DOMRect) => {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
};
|
|
15
|
-
export declare const getGlobalOrigin: ({ origin, boundingClientRect, }: {
|
|
16
|
-
origin: string;
|
|
17
|
-
boundingClientRect: DOMRect;
|
|
18
|
-
}) => {
|
|
19
|
-
x: number;
|
|
20
|
-
y: number;
|
|
21
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Transform = {
|
|
2
|
-
matrices: DOMMatrix[];
|
|
3
|
-
element: Element;
|
|
4
|
-
transformOrigin: string;
|
|
5
|
-
boundingClientRect: DOMRect | null;
|
|
6
|
-
};
|
|
7
|
-
export declare const parseTransformOriginOrPerspectiveOrigin: (transformOrigin: string) => {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
} | null;
|
|
11
|
-
export declare const getAbsoluteOrigin: ({ origin, boundingClientRect, }: {
|
|
12
|
-
origin: string;
|
|
13
|
-
boundingClientRect: DOMRect;
|
|
14
|
-
}) => {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AudioSampleSource, type BufferTarget, type Output, type OutputFormat, type StreamTarget } from 'mediabunny';
|
|
2
|
-
export declare const addAudioSampleSource: ({ muted, output, }: {
|
|
3
|
-
muted: boolean;
|
|
4
|
-
output: Output<OutputFormat, BufferTarget | StreamTarget>;
|
|
5
|
-
}) => Promise<{
|
|
6
|
-
audioSampleSource: AudioSampleSource;
|
|
7
|
-
[Symbol.dispose]: () => void;
|
|
8
|
-
} | null>;
|
package/dist/renoun.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/** Image format for encoded screenshot output. */
|
|
2
|
-
export type ImageFormat = 'png' | 'jpeg' | 'webp';
|
|
3
|
-
/** Options for rendering a screenshot to canvas. */
|
|
4
|
-
export interface RenderOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Canvas background color. Set to `null` (or omit) for a transparent canvas.
|
|
7
|
-
* When provided, the string is passed directly to `fillStyle`.
|
|
8
|
-
*/
|
|
9
|
-
backgroundColor?: string | null;
|
|
10
|
-
/**
|
|
11
|
-
* Optional existing canvas to render into.
|
|
12
|
-
* When omitted, a new canvas element is created.
|
|
13
|
-
*/
|
|
14
|
-
canvas?: HTMLCanvasElement;
|
|
15
|
-
/**
|
|
16
|
-
* Rendering scale factor. Defaults to `window.devicePixelRatio` (or `1`).
|
|
17
|
-
*/
|
|
18
|
-
scale?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Crop origin X (CSS pixels) relative to the element's left edge.
|
|
21
|
-
* Defaults to the element's left edge.
|
|
22
|
-
*/
|
|
23
|
-
x?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Crop origin Y (CSS pixels) relative to the element's top edge.
|
|
26
|
-
* Defaults to the element's top edge.
|
|
27
|
-
*/
|
|
28
|
-
y?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Output width in CSS pixels. Defaults to the element's width.
|
|
31
|
-
*/
|
|
32
|
-
width?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Output height in CSS pixels. Defaults to the element's height.
|
|
35
|
-
*/
|
|
36
|
-
height?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Controls how `position: fixed` elements outside the captured subtree are
|
|
39
|
-
* handled.
|
|
40
|
-
*
|
|
41
|
-
* - `none` – ignore all fixed elements outside `element`.
|
|
42
|
-
* - `intersecting` – include fixed elements whose bounding rect intersects the capture rect.
|
|
43
|
-
* - `all` – include all fixed elements that overlap the viewport.
|
|
44
|
-
*/
|
|
45
|
-
includeFixed?: 'none' | 'intersecting' | 'all';
|
|
46
|
-
}
|
|
47
|
-
/** Options for encoding a canvas to an image format. */
|
|
48
|
-
export interface EncodeOptions {
|
|
49
|
-
/**
|
|
50
|
-
* Image format to encode. Defaults to `'png'`.
|
|
51
|
-
*/
|
|
52
|
-
format?: ImageFormat;
|
|
53
|
-
/**
|
|
54
|
-
* Image quality for lossy formats (`jpeg`, `webp`). A number between `0` and `1`.
|
|
55
|
-
* Ignored for `png`. Defaults to `0.92`.
|
|
56
|
-
*/
|
|
57
|
-
quality?: number;
|
|
58
|
-
}
|
|
59
|
-
/** Combined options for one-shot screenshot methods that render and encode. */
|
|
60
|
-
export type ScreenshotOptions = RenderOptions & EncodeOptions;
|
|
61
|
-
/**
|
|
62
|
-
* A promise-like object representing a screenshot capture. The underlying
|
|
63
|
-
* render happens once; subsequent calls to `.canvas()`, `.blob()`, or `.url()`
|
|
64
|
-
* reuse the same rendered canvas.
|
|
65
|
-
*/
|
|
66
|
-
export interface ScreenshotTask extends Promise<HTMLCanvasElement> {
|
|
67
|
-
/** Returns the rendered canvas. */
|
|
68
|
-
canvas(): Promise<HTMLCanvasElement>;
|
|
69
|
-
/** Encodes the rendered canvas to a Blob. */
|
|
70
|
-
blob(options?: EncodeOptions): Promise<Blob>;
|
|
71
|
-
/**
|
|
72
|
-
* Encodes the rendered canvas to a Blob and creates an object URL.
|
|
73
|
-
* Remember to call `URL.revokeObjectURL(url)` when done to avoid memory leaks.
|
|
74
|
-
*/
|
|
75
|
-
url(options?: EncodeOptions): Promise<string>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Renders a DOM element into a canvas using modern browser features.
|
|
79
|
-
*
|
|
80
|
-
* Returns a `ScreenshotTask` that is both a Promise and provides methods
|
|
81
|
-
* to encode the rendered canvas. The underlying render happens once;
|
|
82
|
-
* subsequent calls to `.canvas()`, `.blob()`, or `.url()` reuse the same result.
|
|
83
|
-
*
|
|
84
|
-
* This implementation targets evergreen browsers only and assumes a real DOM +
|
|
85
|
-
* Canvas2D environment (not Node.js).
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* // Capture handle pattern - render once, encode multiple ways
|
|
89
|
-
* const shot = screenshot(element, { scale: 2 })
|
|
90
|
-
* const canvas = await shot.canvas()
|
|
91
|
-
* const pngBlob = await shot.blob({ format: 'png' })
|
|
92
|
-
* const webpUrl = await shot.url({ format: 'webp', quality: 0.9 })
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* // Direct await returns the canvas
|
|
96
|
-
* const canvas = await screenshot(element)
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* // One-shot convenience methods
|
|
100
|
-
* const canvas = await screenshot.canvas(element, { scale: 2 })
|
|
101
|
-
* const blob = await screenshot.blob(element, { format: 'jpeg', quality: 0.85 })
|
|
102
|
-
* const url = await screenshot.url(element, { format: 'png' })
|
|
103
|
-
*/
|
|
104
|
-
declare function screenshot(target: Element | string, options?: RenderOptions): ScreenshotTask;
|
|
105
|
-
declare namespace screenshot {
|
|
106
|
-
var canvas: (target: string | Element, options?: RenderOptions | undefined) => Promise<HTMLCanvasElement>;
|
|
107
|
-
}
|
|
108
|
-
declare namespace screenshot {
|
|
109
|
-
var blob: (target: string | Element, options?: ScreenshotOptions | undefined) => Promise<Blob>;
|
|
110
|
-
}
|
|
111
|
-
declare namespace screenshot {
|
|
112
|
-
var url: (target: string | Element, options?: ScreenshotOptions | undefined) => Promise<string>;
|
|
113
|
-
}
|
|
114
|
-
export { screenshot };
|
|
115
|
-
declare global {
|
|
116
|
-
interface CanvasRenderingContext2D {
|
|
117
|
-
_filterPolyfillValue?: string;
|
|
118
|
-
}
|
|
119
|
-
}
|