@takumi-rs/core 1.8.6 → 2.0.0-beta.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.
@@ -0,0 +1,329 @@
1
+ import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode, extractResourceUrls } from "@takumi-rs/helpers";
2
+ import { Properties } from "csstype";
3
+
4
+ //#region index.d.ts
5
+ type ByteBuf = Uint8Array | ArrayBuffer | Buffer;
6
+ interface FontDetails {
7
+ /**
8
+ * The name of the font. If not provided, the name in the font file will be used.
9
+ */
10
+ name?: string;
11
+ /**
12
+ * The font data.
13
+ */
14
+ data: ByteBuf;
15
+ /**
16
+ * The weight of the font. If not provided, the weight in the font file will be used.
17
+ */
18
+ weight?: number;
19
+ /**
20
+ * The style of the font. If not provided, the style in the font file will be used.
21
+ */
22
+ style?: "normal" | "italic" | "oblique" | `oblique ${number}deg` | (string & {});
23
+ }
24
+ type Font = FontDetails | ByteBuf;
25
+ type KeyframesMap = Record<string, Record<string, Properties>>;
26
+ type KeyframesRuleList = {
27
+ name: string;
28
+ keyframes: {
29
+ offsets: number[];
30
+ declarations: Record<string, Properties>;
31
+ }[];
32
+ }[];
33
+ type Keyframes = KeyframesMap | KeyframesRuleList;
34
+ /** Represents a single frame in a precomputed animation sequence. */
35
+ interface AnimationFrameSource {
36
+ /** The node tree to render for this frame. */
37
+ node: Node;
38
+ /** The duration of this frame in milliseconds. */
39
+ durationMs: number;
40
+ }
41
+ /** Output format for animated images. */
42
+ type AnimationOutputFormat = /** Animated WebP format. */'webp' | /** Animated PNG format. */'apng' | /** Animated GIF format. */'gif';
43
+ /** Represents a single scene in a sequential animation timeline. */
44
+ interface AnimationSceneSource {
45
+ /** The node tree to render for this scene. */
46
+ node: Node;
47
+ /** The duration of this scene in milliseconds. */
48
+ durationMs: number;
49
+ }
50
+ type DitheringAlgorithm = 'none' | 'ordered-bayer' | 'floyd-steinberg';
51
+ /** Options for encoding a precomputed frame sequence. */
52
+ interface EncodeFramesOptions$1 {
53
+ /** Whether to draw debug borders around layout elements. */
54
+ drawDebugBorder?: boolean;
55
+ /** The width of each frame in pixels. */
56
+ width: number;
57
+ /** The height of each frame in pixels. */
58
+ height: number;
59
+ /** The output animation format (WebP, APNG, or GIF). */
60
+ format?: AnimationOutputFormat;
61
+ /**
62
+ * The quality of lossy WebP (0-100). Ignored for APNG and GIF, and when
63
+ * `lossless` is set.
64
+ */
65
+ quality?: number;
66
+ /**
67
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
68
+ * `lossless` is given. Ignored for APNG and GIF.
69
+ */
70
+ lossless?: boolean;
71
+ /** Images keyed by `src`, each carrying raw bytes. */
72
+ images?: Array<ImageSource>;
73
+ /** CSS stylesheets to apply before rendering. */
74
+ stylesheets?: Array<string>;
75
+ /**
76
+ * The device pixel ratio.
77
+ * @default 1.0
78
+ */
79
+ devicePixelRatio?: number;
80
+ /**
81
+ * Per-render font stack: ordered family names used as the fallback chain.
82
+ * Defaults to all registered families in registration order.
83
+ */
84
+ fontFamilies?: Array<string>;
85
+ }
86
+ /** Cache policy for a decoded image. Defaults to `"auto"`. */
87
+ type ImageCacheMode = /** Cache the decoded image for reuse (evictable). */'auto' | /** Skip the decoded-image cache. */'none';
88
+ /** An image source with its URL and raw data. */
89
+ interface ImageSource {
90
+ /** The source URL of the image. */
91
+ src: string;
92
+ /** The raw image data (Uint8Array or ArrayBuffer). */
93
+ data: Uint8Array | ArrayBuffer;
94
+ /** Cache policy for the decoded image. Defaults to `"auto"`. */
95
+ cache?: ImageCacheMode;
96
+ }
97
+ /** Represents a node that has been measured, including its layout information. */
98
+ interface MeasuredNode {
99
+ /** The measured width of the node. */
100
+ width: number;
101
+ /** The measured height of the node. */
102
+ height: number;
103
+ /** The transformation matrix of the node. */
104
+ transform: [number, number, number, number, number, number];
105
+ /** The children of the node. */
106
+ children: Array<MeasuredNode>;
107
+ /** The text runs within the node. */
108
+ runs: Array<MeasuredTextRun>;
109
+ }
110
+ /** Represents a single run of text in a measured node. */
111
+ interface MeasuredTextRun {
112
+ /** The text content of the run. */
113
+ text: string;
114
+ /** The inline x-coordinate of the run. */
115
+ x: number;
116
+ /** The inline y-coordinate of the run. */
117
+ y: number;
118
+ /** The width of the run. */
119
+ width: number;
120
+ /** The height of the run. */
121
+ height: number;
122
+ }
123
+ /** Output format for static images. */
124
+ type OutputFormat = /** WebP format. */'webp' | /** PNG format. */'png' | /** JPEG format. */'jpeg' | /** ICO format. */'ico' | /** Raw pixels format. */'raw';
125
+ /** A single face within a `RegisteredFamily`. */
126
+ interface RegisteredFace {
127
+ /** Weight class, typically `1`–`1000`. */
128
+ weight: number;
129
+ /** CSS `font-style` value (`normal`, `italic`, or `oblique [<angle>deg]`). */
130
+ style: string;
131
+ /** Width as a percentage of normal (e.g. `100`). */
132
+ width: number;
133
+ /** Index of the face within its source collection. */
134
+ index: number;
135
+ }
136
+ /** A font family produced by `registerFont`, with the faces it contains. */
137
+ interface RegisteredFamily {
138
+ /** Family name as stored by the font system (normalized; reflects any override). */
139
+ name: string;
140
+ /** Faces registered under this family. */
141
+ faces: Array<RegisteredFace>;
142
+ }
143
+ /** Options for rendering a sequential scene animation. */
144
+ interface RenderAnimationOptions$1 {
145
+ /** The scenes to render sequentially. */
146
+ scenes: Array<AnimationSceneSource>;
147
+ /** Whether to draw debug borders around layout elements. */
148
+ drawDebugBorder?: boolean;
149
+ /** The width of each frame in pixels. */
150
+ width: number;
151
+ /** The height of each frame in pixels. */
152
+ height: number;
153
+ /** The output animation format (WebP, APNG, or GIF). */
154
+ format?: AnimationOutputFormat;
155
+ /**
156
+ * The quality of lossy WebP (0-100). Ignored for APNG and GIF, and when
157
+ * `lossless` is set.
158
+ */
159
+ quality?: number;
160
+ /**
161
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
162
+ * `lossless` is given. Ignored for APNG and GIF.
163
+ */
164
+ lossless?: boolean;
165
+ /** Frames per second for timeline sampling. */
166
+ fps: number;
167
+ /** Images keyed by `src`, each carrying raw bytes. */
168
+ images?: Array<ImageSource>;
169
+ /** CSS stylesheets to apply before rendering. */
170
+ stylesheets?: Array<string>;
171
+ /**
172
+ * The device pixel ratio.
173
+ * @default 1.0
174
+ */
175
+ devicePixelRatio?: number;
176
+ /**
177
+ * Per-render font stack: ordered family names used as the fallback chain.
178
+ * Defaults to all registered families in registration order.
179
+ */
180
+ fontFamilies?: Array<string>;
181
+ }
182
+ /** Options for rendering an image. */
183
+ interface RenderOptions$1 {
184
+ /** The width of the image. If not provided, the width will be automatically calculated based on the content. */
185
+ width?: number;
186
+ /** The height of the image. If not provided, the height will be automatically calculated based on the content. */
187
+ height?: number;
188
+ /** The format of the image. */
189
+ format?: OutputFormat;
190
+ /**
191
+ * The quality of lossy formats (0-100). For JPEG; for WebP it selects lossy
192
+ * encoding unless `lossless` is set.
193
+ */
194
+ quality?: number;
195
+ /**
196
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
197
+ * `lossless` is given.
198
+ */
199
+ lossless?: boolean;
200
+ /** Whether to draw debug borders. */
201
+ drawDebugBorder?: boolean;
202
+ /** Images keyed by `src`, each carrying raw bytes. */
203
+ images?: Array<ImageSource>;
204
+ /** CSS stylesheets to apply before rendering. */
205
+ stylesheets?: Array<string>;
206
+ /** Structured keyframes to register alongside stylesheets. */
207
+ keyframes?: Keyframes;
208
+ /**
209
+ * The device pixel ratio.
210
+ * @default 1.0
211
+ */
212
+ devicePixelRatio?: number;
213
+ /** The animation timeline time in milliseconds. */
214
+ timeMs?: number;
215
+ /** The output dithering algorithm. */
216
+ dithering?: DitheringAlgorithm;
217
+ /**
218
+ * Per-render font stack: ordered family names used as the fallback chain.
219
+ * Defaults to all registered families in registration order.
220
+ */
221
+ fontFamilies?: Array<string>;
222
+ }
223
+ /**
224
+ * Options for rendering a node tree to an SVG document. SVG is a vector
225
+ * format, so the raster-only knobs (`format`, `quality`, `lossless`,
226
+ * `dithering`, `drawDebugBorder`, `devicePixelRatio`) do not apply.
227
+ */
228
+ interface SvgRenderOptions$1 {
229
+ /** The width of the viewport. If not provided, it is derived from content. */
230
+ width?: number;
231
+ /** The height of the viewport. If not provided, it is derived from content. */
232
+ height?: number;
233
+ /** Images keyed by `src`, each carrying raw bytes. */
234
+ images?: Array<ImageSource>;
235
+ /** CSS stylesheets to apply before rendering. */
236
+ stylesheets?: Array<string>;
237
+ /** Structured keyframes to register alongside stylesheets. */
238
+ keyframes?: Keyframes;
239
+ /** The animation timeline time in milliseconds. */
240
+ timeMs?: number;
241
+ /**
242
+ * Per-render font stack: ordered family names used as the fallback chain.
243
+ * Defaults to all registered families in registration order.
244
+ */
245
+ fontFamilies?: Array<string>;
246
+ }
247
+ //#endregion
248
+ //#region src/export.d.ts
249
+ type FontLoader = Font | (Omit<FontDetails, "data"> & {
250
+ data: () => Promise<FontDetails["data"]> | FontDetails["data"];
251
+ } & ({
252
+ key: string;
253
+ } | {
254
+ name: string;
255
+ }));
256
+ type ImageLoaderData = ImageSource["data"];
257
+ type ImageLoader = Omit<ImageSource, "data"> & {
258
+ data: ImageLoaderData | (() => ImageLoaderData | Promise<ImageLoaderData>);
259
+ };
260
+ /**
261
+ * Output format. Format-specific options live on the variant that supports them,
262
+ * so `quality` cannot be paired with PNG/ICO/raw, and `lossless` is WebP-only.
263
+ * For WebP, `lossless` takes precedence over `quality`; omitting both encodes
264
+ * losslessly.
265
+ */
266
+ type OutputFormatOptions = {
267
+ format?: "png";
268
+ } | {
269
+ format: "jpeg";
270
+ quality?: number;
271
+ } | {
272
+ format: "webp";
273
+ quality?: number;
274
+ lossless?: boolean;
275
+ } | {
276
+ format: "ico";
277
+ } | {
278
+ format: "raw";
279
+ };
280
+ type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions & {
281
+ fonts?: FontLoader[];
282
+ signal?: AbortSignal;
283
+ images?: ImageLoader[];
284
+ };
285
+ /**
286
+ * Animation output format. `quality` and `lossless` are WebP-only; for WebP,
287
+ * `lossless` takes precedence over `quality`, and omitting both encodes
288
+ * losslessly.
289
+ */
290
+ type AnimationOutputFormatOptions = {
291
+ format?: "webp";
292
+ quality?: number;
293
+ lossless?: boolean;
294
+ } | {
295
+ format: "apng";
296
+ } | {
297
+ format: "gif";
298
+ };
299
+ type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
300
+ fonts?: FontLoader[];
301
+ signal?: AbortSignal;
302
+ images?: ImageLoader[];
303
+ };
304
+ type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
305
+ fonts?: FontLoader[];
306
+ signal?: AbortSignal;
307
+ images?: ImageLoader[];
308
+ };
309
+ type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
310
+ fonts?: FontLoader[];
311
+ signal?: AbortSignal;
312
+ images?: ImageLoader[];
313
+ };
314
+ declare class Renderer {
315
+ private fontMapping;
316
+ private inner;
317
+ private prepareFonts;
318
+ /** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
319
+ * the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
320
+ private resolveResources;
321
+ render(node: Node, options?: RenderOptions): Promise<Buffer>;
322
+ renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
323
+ measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
324
+ renderAnimation(options: RenderAnimationOptions): Promise<Buffer>;
325
+ encodeFrames(frames: AnimationFrameSource[], options: EncodeFramesOptions): Promise<Buffer>;
326
+ registerFont(font: FontLoader): Promise<any>;
327
+ }
328
+ //#endregion
329
+ export { type AnimationFrameSource, type AnimationOutputFormat, AnimationOutputFormatOptions, type AnimationSceneSource, type ByteBuf, type ContainerNode, type DitheringAlgorithm, EncodeFramesOptions, type Font, type FontDetails, FontLoader, type ImageCacheMode, ImageLoader, type ImageNode, type ImageSource, type Keyframes, type KeyframesMap, type KeyframesRuleList, type MeasuredNode, type MeasuredTextRun, type Node, type NodeMetadata, type OutputFormat, OutputFormatOptions, type RegisteredFace, type RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, type TextNode, extractResourceUrls };
@@ -0,0 +1,329 @@
1
+ import { ContainerNode, ImageNode, Node, NodeMetadata, TextNode, extractResourceUrls } from "@takumi-rs/helpers";
2
+ import { Properties } from "csstype";
3
+
4
+ //#region index.d.ts
5
+ type ByteBuf = Uint8Array | ArrayBuffer | Buffer;
6
+ interface FontDetails {
7
+ /**
8
+ * The name of the font. If not provided, the name in the font file will be used.
9
+ */
10
+ name?: string;
11
+ /**
12
+ * The font data.
13
+ */
14
+ data: ByteBuf;
15
+ /**
16
+ * The weight of the font. If not provided, the weight in the font file will be used.
17
+ */
18
+ weight?: number;
19
+ /**
20
+ * The style of the font. If not provided, the style in the font file will be used.
21
+ */
22
+ style?: "normal" | "italic" | "oblique" | `oblique ${number}deg` | (string & {});
23
+ }
24
+ type Font = FontDetails | ByteBuf;
25
+ type KeyframesMap = Record<string, Record<string, Properties>>;
26
+ type KeyframesRuleList = {
27
+ name: string;
28
+ keyframes: {
29
+ offsets: number[];
30
+ declarations: Record<string, Properties>;
31
+ }[];
32
+ }[];
33
+ type Keyframes = KeyframesMap | KeyframesRuleList;
34
+ /** Represents a single frame in a precomputed animation sequence. */
35
+ interface AnimationFrameSource {
36
+ /** The node tree to render for this frame. */
37
+ node: Node;
38
+ /** The duration of this frame in milliseconds. */
39
+ durationMs: number;
40
+ }
41
+ /** Output format for animated images. */
42
+ type AnimationOutputFormat = /** Animated WebP format. */'webp' | /** Animated PNG format. */'apng' | /** Animated GIF format. */'gif';
43
+ /** Represents a single scene in a sequential animation timeline. */
44
+ interface AnimationSceneSource {
45
+ /** The node tree to render for this scene. */
46
+ node: Node;
47
+ /** The duration of this scene in milliseconds. */
48
+ durationMs: number;
49
+ }
50
+ type DitheringAlgorithm = 'none' | 'ordered-bayer' | 'floyd-steinberg';
51
+ /** Options for encoding a precomputed frame sequence. */
52
+ interface EncodeFramesOptions$1 {
53
+ /** Whether to draw debug borders around layout elements. */
54
+ drawDebugBorder?: boolean;
55
+ /** The width of each frame in pixels. */
56
+ width: number;
57
+ /** The height of each frame in pixels. */
58
+ height: number;
59
+ /** The output animation format (WebP, APNG, or GIF). */
60
+ format?: AnimationOutputFormat;
61
+ /**
62
+ * The quality of lossy WebP (0-100). Ignored for APNG and GIF, and when
63
+ * `lossless` is set.
64
+ */
65
+ quality?: number;
66
+ /**
67
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
68
+ * `lossless` is given. Ignored for APNG and GIF.
69
+ */
70
+ lossless?: boolean;
71
+ /** Images keyed by `src`, each carrying raw bytes. */
72
+ images?: Array<ImageSource>;
73
+ /** CSS stylesheets to apply before rendering. */
74
+ stylesheets?: Array<string>;
75
+ /**
76
+ * The device pixel ratio.
77
+ * @default 1.0
78
+ */
79
+ devicePixelRatio?: number;
80
+ /**
81
+ * Per-render font stack: ordered family names used as the fallback chain.
82
+ * Defaults to all registered families in registration order.
83
+ */
84
+ fontFamilies?: Array<string>;
85
+ }
86
+ /** Cache policy for a decoded image. Defaults to `"auto"`. */
87
+ type ImageCacheMode = /** Cache the decoded image for reuse (evictable). */'auto' | /** Skip the decoded-image cache. */'none';
88
+ /** An image source with its URL and raw data. */
89
+ interface ImageSource {
90
+ /** The source URL of the image. */
91
+ src: string;
92
+ /** The raw image data (Uint8Array or ArrayBuffer). */
93
+ data: Uint8Array | ArrayBuffer;
94
+ /** Cache policy for the decoded image. Defaults to `"auto"`. */
95
+ cache?: ImageCacheMode;
96
+ }
97
+ /** Represents a node that has been measured, including its layout information. */
98
+ interface MeasuredNode {
99
+ /** The measured width of the node. */
100
+ width: number;
101
+ /** The measured height of the node. */
102
+ height: number;
103
+ /** The transformation matrix of the node. */
104
+ transform: [number, number, number, number, number, number];
105
+ /** The children of the node. */
106
+ children: Array<MeasuredNode>;
107
+ /** The text runs within the node. */
108
+ runs: Array<MeasuredTextRun>;
109
+ }
110
+ /** Represents a single run of text in a measured node. */
111
+ interface MeasuredTextRun {
112
+ /** The text content of the run. */
113
+ text: string;
114
+ /** The inline x-coordinate of the run. */
115
+ x: number;
116
+ /** The inline y-coordinate of the run. */
117
+ y: number;
118
+ /** The width of the run. */
119
+ width: number;
120
+ /** The height of the run. */
121
+ height: number;
122
+ }
123
+ /** Output format for static images. */
124
+ type OutputFormat = /** WebP format. */'webp' | /** PNG format. */'png' | /** JPEG format. */'jpeg' | /** ICO format. */'ico' | /** Raw pixels format. */'raw';
125
+ /** A single face within a `RegisteredFamily`. */
126
+ interface RegisteredFace {
127
+ /** Weight class, typically `1`–`1000`. */
128
+ weight: number;
129
+ /** CSS `font-style` value (`normal`, `italic`, or `oblique [<angle>deg]`). */
130
+ style: string;
131
+ /** Width as a percentage of normal (e.g. `100`). */
132
+ width: number;
133
+ /** Index of the face within its source collection. */
134
+ index: number;
135
+ }
136
+ /** A font family produced by `registerFont`, with the faces it contains. */
137
+ interface RegisteredFamily {
138
+ /** Family name as stored by the font system (normalized; reflects any override). */
139
+ name: string;
140
+ /** Faces registered under this family. */
141
+ faces: Array<RegisteredFace>;
142
+ }
143
+ /** Options for rendering a sequential scene animation. */
144
+ interface RenderAnimationOptions$1 {
145
+ /** The scenes to render sequentially. */
146
+ scenes: Array<AnimationSceneSource>;
147
+ /** Whether to draw debug borders around layout elements. */
148
+ drawDebugBorder?: boolean;
149
+ /** The width of each frame in pixels. */
150
+ width: number;
151
+ /** The height of each frame in pixels. */
152
+ height: number;
153
+ /** The output animation format (WebP, APNG, or GIF). */
154
+ format?: AnimationOutputFormat;
155
+ /**
156
+ * The quality of lossy WebP (0-100). Ignored for APNG and GIF, and when
157
+ * `lossless` is set.
158
+ */
159
+ quality?: number;
160
+ /**
161
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
162
+ * `lossless` is given. Ignored for APNG and GIF.
163
+ */
164
+ lossless?: boolean;
165
+ /** Frames per second for timeline sampling. */
166
+ fps: number;
167
+ /** Images keyed by `src`, each carrying raw bytes. */
168
+ images?: Array<ImageSource>;
169
+ /** CSS stylesheets to apply before rendering. */
170
+ stylesheets?: Array<string>;
171
+ /**
172
+ * The device pixel ratio.
173
+ * @default 1.0
174
+ */
175
+ devicePixelRatio?: number;
176
+ /**
177
+ * Per-render font stack: ordered family names used as the fallback chain.
178
+ * Defaults to all registered families in registration order.
179
+ */
180
+ fontFamilies?: Array<string>;
181
+ }
182
+ /** Options for rendering an image. */
183
+ interface RenderOptions$1 {
184
+ /** The width of the image. If not provided, the width will be automatically calculated based on the content. */
185
+ width?: number;
186
+ /** The height of the image. If not provided, the height will be automatically calculated based on the content. */
187
+ height?: number;
188
+ /** The format of the image. */
189
+ format?: OutputFormat;
190
+ /**
191
+ * The quality of lossy formats (0-100). For JPEG; for WebP it selects lossy
192
+ * encoding unless `lossless` is set.
193
+ */
194
+ quality?: number;
195
+ /**
196
+ * Encode WebP losslessly. Defaults to lossless when neither `quality` nor
197
+ * `lossless` is given.
198
+ */
199
+ lossless?: boolean;
200
+ /** Whether to draw debug borders. */
201
+ drawDebugBorder?: boolean;
202
+ /** Images keyed by `src`, each carrying raw bytes. */
203
+ images?: Array<ImageSource>;
204
+ /** CSS stylesheets to apply before rendering. */
205
+ stylesheets?: Array<string>;
206
+ /** Structured keyframes to register alongside stylesheets. */
207
+ keyframes?: Keyframes;
208
+ /**
209
+ * The device pixel ratio.
210
+ * @default 1.0
211
+ */
212
+ devicePixelRatio?: number;
213
+ /** The animation timeline time in milliseconds. */
214
+ timeMs?: number;
215
+ /** The output dithering algorithm. */
216
+ dithering?: DitheringAlgorithm;
217
+ /**
218
+ * Per-render font stack: ordered family names used as the fallback chain.
219
+ * Defaults to all registered families in registration order.
220
+ */
221
+ fontFamilies?: Array<string>;
222
+ }
223
+ /**
224
+ * Options for rendering a node tree to an SVG document. SVG is a vector
225
+ * format, so the raster-only knobs (`format`, `quality`, `lossless`,
226
+ * `dithering`, `drawDebugBorder`, `devicePixelRatio`) do not apply.
227
+ */
228
+ interface SvgRenderOptions$1 {
229
+ /** The width of the viewport. If not provided, it is derived from content. */
230
+ width?: number;
231
+ /** The height of the viewport. If not provided, it is derived from content. */
232
+ height?: number;
233
+ /** Images keyed by `src`, each carrying raw bytes. */
234
+ images?: Array<ImageSource>;
235
+ /** CSS stylesheets to apply before rendering. */
236
+ stylesheets?: Array<string>;
237
+ /** Structured keyframes to register alongside stylesheets. */
238
+ keyframes?: Keyframes;
239
+ /** The animation timeline time in milliseconds. */
240
+ timeMs?: number;
241
+ /**
242
+ * Per-render font stack: ordered family names used as the fallback chain.
243
+ * Defaults to all registered families in registration order.
244
+ */
245
+ fontFamilies?: Array<string>;
246
+ }
247
+ //#endregion
248
+ //#region src/export.d.ts
249
+ type FontLoader = Font | (Omit<FontDetails, "data"> & {
250
+ data: () => Promise<FontDetails["data"]> | FontDetails["data"];
251
+ } & ({
252
+ key: string;
253
+ } | {
254
+ name: string;
255
+ }));
256
+ type ImageLoaderData = ImageSource["data"];
257
+ type ImageLoader = Omit<ImageSource, "data"> & {
258
+ data: ImageLoaderData | (() => ImageLoaderData | Promise<ImageLoaderData>);
259
+ };
260
+ /**
261
+ * Output format. Format-specific options live on the variant that supports them,
262
+ * so `quality` cannot be paired with PNG/ICO/raw, and `lossless` is WebP-only.
263
+ * For WebP, `lossless` takes precedence over `quality`; omitting both encodes
264
+ * losslessly.
265
+ */
266
+ type OutputFormatOptions = {
267
+ format?: "png";
268
+ } | {
269
+ format: "jpeg";
270
+ quality?: number;
271
+ } | {
272
+ format: "webp";
273
+ quality?: number;
274
+ lossless?: boolean;
275
+ } | {
276
+ format: "ico";
277
+ } | {
278
+ format: "raw";
279
+ };
280
+ type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality" | "lossless"> & OutputFormatOptions & {
281
+ fonts?: FontLoader[];
282
+ signal?: AbortSignal;
283
+ images?: ImageLoader[];
284
+ };
285
+ /**
286
+ * Animation output format. `quality` and `lossless` are WebP-only; for WebP,
287
+ * `lossless` takes precedence over `quality`, and omitting both encodes
288
+ * losslessly.
289
+ */
290
+ type AnimationOutputFormatOptions = {
291
+ format?: "webp";
292
+ quality?: number;
293
+ lossless?: boolean;
294
+ } | {
295
+ format: "apng";
296
+ } | {
297
+ format: "gif";
298
+ };
299
+ type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
300
+ fonts?: FontLoader[];
301
+ signal?: AbortSignal;
302
+ images?: ImageLoader[];
303
+ };
304
+ type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format" | "quality" | "lossless"> & AnimationOutputFormatOptions & {
305
+ fonts?: FontLoader[];
306
+ signal?: AbortSignal;
307
+ images?: ImageLoader[];
308
+ };
309
+ type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
310
+ fonts?: FontLoader[];
311
+ signal?: AbortSignal;
312
+ images?: ImageLoader[];
313
+ };
314
+ declare class Renderer {
315
+ private fontMapping;
316
+ private inner;
317
+ private prepareFonts;
318
+ /** Registers `fonts` and resolves lazy `images`, yielding the `images`/`fontFamilies`
319
+ * the napi binding expects. Explicit `fontFamilies` wins over the registered set. */
320
+ private resolveResources;
321
+ render(node: Node, options?: RenderOptions): Promise<Buffer>;
322
+ renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
323
+ measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
324
+ renderAnimation(options: RenderAnimationOptions): Promise<Buffer>;
325
+ encodeFrames(frames: AnimationFrameSource[], options: EncodeFramesOptions): Promise<Buffer>;
326
+ registerFont(font: FontLoader): Promise<any>;
327
+ }
328
+ //#endregion
329
+ export { type AnimationFrameSource, type AnimationOutputFormat, AnimationOutputFormatOptions, type AnimationSceneSource, type ByteBuf, type ContainerNode, type DitheringAlgorithm, EncodeFramesOptions, type Font, type FontDetails, FontLoader, type ImageCacheMode, ImageLoader, type ImageNode, type ImageSource, type Keyframes, type KeyframesMap, type KeyframesRuleList, type MeasuredNode, type MeasuredTextRun, type Node, type NodeMetadata, type OutputFormat, OutputFormatOptions, type RegisteredFace, type RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, type TextNode, extractResourceUrls };