@codehz/draw-call 0.1.2 → 0.2.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.
@@ -0,0 +1,437 @@
1
+ /**
2
+ * 示例:演示 Transform 组件的基础属性
3
+ * 展示移动(translate)、旋转(rotate)、放大(scale)等变换效果
4
+ * 运行: bun examples/transform.ts
5
+ */
6
+ import { Box, Text, Transform, printLayout } from "@codehz/draw-call";
7
+ import { createNodeCanvas } from "@codehz/draw-call/node";
8
+ import { GlobalFonts } from "@napi-rs/canvas";
9
+ import { fileURLToPath } from "bun";
10
+
11
+ GlobalFonts.registerFromPath(fileURLToPath(import.meta.resolve("@fontpkg/unifont/unifont-15.0.01.ttf")), "unifont");
12
+
13
+ const canvas = createNodeCanvas({
14
+ width: 800,
15
+ height: 1000,
16
+ pixelRatio: 2,
17
+ });
18
+
19
+ // 创建一个简单的演示盒子
20
+ function DemoBox(label: string, transform?: any) {
21
+ return Transform({
22
+ transform,
23
+ transformOrigin: ["50%", "50%"],
24
+ children: Box({
25
+ width: 80,
26
+ height: 80,
27
+ background: "#667eea",
28
+ border: { radius: 8 },
29
+ justify: "center",
30
+ align: "center",
31
+ children: [
32
+ Text({
33
+ content: label,
34
+ font: { size: 12, weight: "bold", family: "unifont" },
35
+ color: "#ffffff",
36
+ }),
37
+ ],
38
+ }),
39
+ });
40
+ }
41
+
42
+ const layout = canvas.render(
43
+ Box({
44
+ width: "fill",
45
+ height: "fill",
46
+ background: "#f5f7fa",
47
+ padding: 20,
48
+ direction: "column",
49
+ gap: 20,
50
+ children: [
51
+ // 标题
52
+ Text({
53
+ content: "Transform 变换演示",
54
+ font: { size: 28, weight: "bold", family: "unifont" },
55
+ color: "#333333",
56
+ }),
57
+
58
+ // 第一行:平移演示
59
+ Box({
60
+ direction: "column",
61
+ gap: 10,
62
+ children: [
63
+ Text({
64
+ content: "1. 平移 (Translate)",
65
+ font: { size: 16, weight: "bold", family: "unifont" },
66
+ color: "#666666",
67
+ }),
68
+ Box({
69
+ background: "#ffffff",
70
+ border: { radius: 8 },
71
+ padding: 20,
72
+ direction: "row",
73
+ gap: 30,
74
+ align: "center",
75
+ children: [
76
+ // 没有变换
77
+ Box({
78
+ direction: "column",
79
+ gap: 8,
80
+ align: "center",
81
+ children: [
82
+ DemoBox("原始"),
83
+ Text({
84
+ content: "原始位置",
85
+ font: { size: 12, family: "unifont" },
86
+ color: "#999999",
87
+ }),
88
+ ],
89
+ }),
90
+ // 向右平移 30 像素
91
+ Box({
92
+ direction: "column",
93
+ gap: 8,
94
+ align: "center",
95
+ children: [
96
+ DemoBox("右移30", {
97
+ translate: [30, 0],
98
+ }),
99
+ Text({
100
+ content: "translateX(30)",
101
+ font: { size: 12, family: "unifont" },
102
+ color: "#999999",
103
+ }),
104
+ ],
105
+ }),
106
+ // 向下平移 20 像素
107
+ Box({
108
+ direction: "column",
109
+ gap: 8,
110
+ align: "center",
111
+ children: [
112
+ DemoBox("下移20", {
113
+ translate: [0, 20],
114
+ }),
115
+ Text({
116
+ content: "translateY(20)",
117
+ font: { size: 12, family: "unifont" },
118
+ color: "#999999",
119
+ }),
120
+ ],
121
+ }),
122
+ // 同时平移
123
+ Box({
124
+ direction: "column",
125
+ gap: 8,
126
+ align: "center",
127
+ children: [
128
+ DemoBox("对角", {
129
+ translate: [25, 15],
130
+ }),
131
+ Text({
132
+ content: "translate(25, 15)",
133
+ font: { size: 12, family: "unifont" },
134
+ color: "#999999",
135
+ }),
136
+ ],
137
+ }),
138
+ ],
139
+ }),
140
+ ],
141
+ }),
142
+
143
+ // 第二行:缩放演示
144
+ Box({
145
+ direction: "column",
146
+ gap: 10,
147
+ children: [
148
+ Text({
149
+ content: "2. 缩放 (Scale)",
150
+ font: { size: 16, weight: "bold", family: "unifont" },
151
+ color: "#666666",
152
+ }),
153
+ Box({
154
+ background: "#ffffff",
155
+ border: { radius: 8 },
156
+ padding: 20,
157
+ direction: "row",
158
+ gap: 30,
159
+ align: "center",
160
+ children: [
161
+ // 原始
162
+ Box({
163
+ direction: "column",
164
+ gap: 8,
165
+ align: "center",
166
+ children: [
167
+ DemoBox("1.0"),
168
+ Text({
169
+ content: "scale(1.0)",
170
+ font: { size: 12, family: "unifont" },
171
+ color: "#999999",
172
+ }),
173
+ ],
174
+ }),
175
+ // 放大 1.5 倍
176
+ Box({
177
+ direction: "column",
178
+ gap: 8,
179
+ align: "center",
180
+ children: [
181
+ DemoBox("1.5倍", {
182
+ scale: 1.5,
183
+ }),
184
+ Text({
185
+ content: "scale(1.5)",
186
+ font: { size: 12, family: "unifont" },
187
+ color: "#999999",
188
+ }),
189
+ ],
190
+ }),
191
+ // 缩小到 0.7 倍
192
+ Box({
193
+ direction: "column",
194
+ gap: 8,
195
+ align: "center",
196
+ children: [
197
+ DemoBox("0.7倍", {
198
+ scale: 0.7,
199
+ }),
200
+ Text({
201
+ content: "scale(0.7)",
202
+ font: { size: 12, family: "unifont" },
203
+ color: "#999999",
204
+ }),
205
+ ],
206
+ }),
207
+ // 非均匀缩放
208
+ Box({
209
+ direction: "column",
210
+ gap: 8,
211
+ align: "center",
212
+ children: [
213
+ DemoBox("非均匀", {
214
+ scale: [1.3, 0.8],
215
+ }),
216
+ Text({
217
+ content: "scale(1.3, 0.8)",
218
+ font: { size: 12, family: "unifont" },
219
+ color: "#999999",
220
+ }),
221
+ ],
222
+ }),
223
+ ],
224
+ }),
225
+ ],
226
+ }),
227
+
228
+ // 第三行:旋转演示
229
+ Box({
230
+ direction: "column",
231
+ gap: 10,
232
+ children: [
233
+ Text({
234
+ content: "3. 旋转 (Rotate)",
235
+ font: { size: 16, weight: "bold", family: "unifont" },
236
+ color: "#666666",
237
+ }),
238
+ Box({
239
+ background: "#ffffff",
240
+ border: { radius: 8 },
241
+ padding: 20,
242
+ direction: "row",
243
+ gap: 30,
244
+ align: "center",
245
+ children: [
246
+ // 原始
247
+ Box({
248
+ direction: "column",
249
+ gap: 8,
250
+ align: "center",
251
+ children: [
252
+ DemoBox("0°"),
253
+ Text({
254
+ content: "rotate(0°)",
255
+ font: { size: 12, family: "unifont" },
256
+ color: "#999999",
257
+ }),
258
+ ],
259
+ }),
260
+ // 顺时针 45 度
261
+ Box({
262
+ direction: "column",
263
+ gap: 8,
264
+ align: "center",
265
+ children: [
266
+ DemoBox("45°", {
267
+ rotate: 45, // 45度
268
+ }),
269
+ Text({
270
+ content: "rotate(45°)",
271
+ font: { size: 12, family: "unifont" },
272
+ color: "#999999",
273
+ }),
274
+ ],
275
+ }),
276
+ // 旋转 90 度
277
+ Box({
278
+ direction: "column",
279
+ gap: 8,
280
+ align: "center",
281
+ children: [
282
+ DemoBox("90°", {
283
+ rotate: 90, // 90度
284
+ }),
285
+ Text({
286
+ content: "rotate(90°)",
287
+ font: { size: 12, family: "unifont" },
288
+ color: "#999999",
289
+ }),
290
+ ],
291
+ }),
292
+ // 旋转 -30 度
293
+ Box({
294
+ direction: "column",
295
+ gap: 8,
296
+ align: "center",
297
+ children: [
298
+ DemoBox("-30°", {
299
+ rotate: -30, // -30度
300
+ }),
301
+ Text({
302
+ content: "rotate(-30°)",
303
+ font: { size: 12, family: "unifont" },
304
+ color: "#999999",
305
+ }),
306
+ ],
307
+ }),
308
+ ],
309
+ }),
310
+ ],
311
+ }),
312
+
313
+ // 第四行:组合变换演示
314
+ Box({
315
+ direction: "column",
316
+ gap: 10,
317
+ children: [
318
+ Text({
319
+ content: "4. 组合变换",
320
+ font: { size: 16, weight: "bold", family: "unifont" },
321
+ color: "#666666",
322
+ }),
323
+ Box({
324
+ background: "#ffffff",
325
+ border: { radius: 8 },
326
+ padding: 20,
327
+ direction: "row",
328
+ gap: 30,
329
+ align: "center",
330
+ children: [
331
+ // 平移 + 旋转
332
+ Box({
333
+ direction: "column",
334
+ gap: 8,
335
+ align: "center",
336
+ children: [
337
+ DemoBox("移+转", {
338
+ translate: [20, 10],
339
+ rotate: 30, // 30度
340
+ }),
341
+ Text({
342
+ content: "移动 + 旋转",
343
+ font: { size: 12, family: "unifont" },
344
+ color: "#999999",
345
+ }),
346
+ ],
347
+ }),
348
+ // 缩放 + 旋转
349
+ Box({
350
+ direction: "column",
351
+ gap: 8,
352
+ align: "center",
353
+ children: [
354
+ DemoBox("缩+转", {
355
+ scale: 1.2,
356
+ rotate: -22.5, // -22.5度
357
+ }),
358
+ Text({
359
+ content: "缩放 + 旋转",
360
+ font: { size: 12, family: "unifont" },
361
+ color: "#999999",
362
+ }),
363
+ ],
364
+ }),
365
+ // 三个变换组合
366
+ Box({
367
+ direction: "column",
368
+ gap: 8,
369
+ align: "center",
370
+ children: [
371
+ DemoBox("全部", {
372
+ translate: [15, 10],
373
+ scale: 1.1,
374
+ rotate: 45, // 45度
375
+ }),
376
+ Text({
377
+ content: "移动 + 缩放 + 旋转",
378
+ font: { size: 12, family: "unifont" },
379
+ color: "#999999",
380
+ }),
381
+ ],
382
+ }),
383
+ // 使用 transformOrigin 改变变换中心
384
+ Box({
385
+ direction: "column",
386
+ gap: 8,
387
+ align: "center",
388
+ children: [
389
+ Transform({
390
+ transformOrigin: ["100%", "100%"],
391
+ transform: {
392
+ rotate: 45, // 45度
393
+ scale: 1.2,
394
+ },
395
+ children: Box({
396
+ width: 80,
397
+ height: 80,
398
+ background: "#764ba2",
399
+ border: { radius: 8 },
400
+ justify: "center",
401
+ align: "center",
402
+ children: [
403
+ Text({
404
+ content: "变换原点",
405
+ font: {
406
+ size: 12,
407
+ weight: "bold",
408
+ family: "unifont",
409
+ },
410
+ color: "#ffffff",
411
+ }),
412
+ ],
413
+ }),
414
+ }),
415
+ Text({
416
+ content: "自定义原点",
417
+ font: { size: 12, family: "unifont" },
418
+ color: "#999999",
419
+ }),
420
+ ],
421
+ }),
422
+ ],
423
+ }),
424
+ ],
425
+ }),
426
+ ],
427
+ })
428
+ );
429
+
430
+ // 保存文件
431
+ const buffer = await canvas.toBuffer("image/png");
432
+ await Bun.write("examples/transform.png", buffer);
433
+ console.log("Transform demo saved to examples/transform.png");
434
+
435
+ // 打印布局树
436
+ console.log("\n=== Layout Tree ===");
437
+ printLayout(layout);
package/index.cjs CHANGED
@@ -61,6 +61,15 @@ function Box(props) {
61
61
  };
62
62
  }
63
63
 
64
+ //#endregion
65
+ //#region src/components/CustomDraw.ts
66
+ function CustomDraw(props) {
67
+ return {
68
+ type: "customdraw",
69
+ ...props
70
+ };
71
+ }
72
+
64
73
  //#endregion
65
74
  //#region src/components/Image.ts
66
75
  function Image(props) {
@@ -70,6 +79,15 @@ function Image(props) {
70
79
  };
71
80
  }
72
81
 
82
+ //#endregion
83
+ //#region src/components/RichText.ts
84
+ function RichText(props) {
85
+ return {
86
+ type: "richtext",
87
+ ...props
88
+ };
89
+ }
90
+
73
91
  //#endregion
74
92
  //#region src/components/Stack.ts
75
93
  function Stack(props) {
@@ -135,15 +153,87 @@ function Text(props) {
135
153
  };
136
154
  }
137
155
 
156
+ //#endregion
157
+ //#region src/components/Transform.ts
158
+ function Transform(props) {
159
+ return {
160
+ type: "transform",
161
+ ...props
162
+ };
163
+ }
164
+
165
+ //#endregion
166
+ //#region src/layout/utils/print.ts
167
+ /**
168
+ * 获取元素类型的显示名称
169
+ */
170
+ function getElementType(element) {
171
+ switch (element.type) {
172
+ case "box": return "Box";
173
+ case "text": return `Text "${element.content.slice(0, 20)}${element.content.length > 20 ? "..." : ""}"`;
174
+ case "stack": return "Stack";
175
+ case "image": return "Image";
176
+ case "svg": return "Svg";
177
+ default: return element.type;
178
+ }
179
+ }
180
+ /**
181
+ * 递归打印布局树
182
+ */
183
+ function printLayoutToString(node, prefix = "", isLast = true, depth = 0) {
184
+ const lines = [];
185
+ const connector = isLast ? "└─ " : "├─ ";
186
+ const type = getElementType(node.element);
187
+ const { x, y, width, height } = node.layout;
188
+ const childCount = node.children.length;
189
+ lines.push(`${prefix}${connector}${type} @(${Math.round(x)},${Math.round(y)}) size:${Math.round(width)}x${Math.round(height)}`);
190
+ if (node.element.type === "text" && node.lines) {
191
+ const contentPrefix = prefix + (isLast ? " " : "│ ");
192
+ for (let i = 0; i < node.lines.length; i++) {
193
+ const lineText = node.lines[i];
194
+ const isLastLine = i === node.lines.length - 1 && childCount === 0;
195
+ lines.push(`${contentPrefix}${isLastLine ? "└─ " : "├─ "}${JSON.stringify(lineText)}`);
196
+ }
197
+ }
198
+ for (let i = 0; i < node.children.length; i++) {
199
+ const child = node.children[i];
200
+ const isChildLast = i === node.children.length - 1;
201
+ const childPrefix = prefix + (isLast ? " " : "│ ");
202
+ lines.push(...printLayoutToString(child, childPrefix, isChildLast, depth + 1));
203
+ }
204
+ return lines;
205
+ }
206
+ /**
207
+ * 打印 LayoutNode 树结构到控制台
208
+ */
209
+ function printLayout(node) {
210
+ const lines = printLayoutToString(node, "", true);
211
+ console.log(lines.join("\n"));
212
+ }
213
+ /**
214
+ * 将 LayoutNode 转换为美观的字符串
215
+ * @param node LayoutNode 根节点
216
+ * @param indent 缩进字符串,默认为两个空格
217
+ * @returns 格式化的字符串
218
+ */
219
+ function layoutToString(node, _indent = " ") {
220
+ return printLayoutToString(node, "", true).join("\n");
221
+ }
222
+
138
223
  //#endregion
139
224
  exports.Box = Box;
225
+ exports.CustomDraw = CustomDraw;
140
226
  exports.Image = Image;
227
+ exports.RichText = RichText;
141
228
  exports.Stack = Stack;
142
229
  exports.Svg = Svg;
143
230
  exports.Text = Text;
231
+ exports.Transform = Transform;
144
232
  exports.computeLayout = require_render.computeLayout;
145
233
  exports.createCanvas = createCanvas;
146
234
  exports.createCanvasMeasureContext = require_render.createCanvasMeasureContext;
235
+ exports.layoutToString = layoutToString;
147
236
  exports.linearGradient = require_render.linearGradient;
237
+ exports.printLayout = printLayout;
148
238
  exports.radialGradient = require_render.radialGradient;
149
239
  exports.svg = svg;
package/index.d.cts CHANGED
@@ -1,11 +1,17 @@
1
- import { A as AlignItems, B as Color, C as SvgProps, D as SvgTransformProps, E as SvgTextChild, F as LayoutConstraints, G as RadialGradientDescriptor, H as FontProps, I as LayoutNode, J as Spacing, K as Shadow, L as LayoutProps, M as ContainerLayoutProps, N as FlexDirection, O as TextElement, P as JustifyContent, R as Border, S as SvgPolylineChild, T as SvgStyleProps, U as GradientDescriptor, V as ColorStop, W as LinearGradientDescriptor, X as linearGradient, Y as StrokeProps, Z as radialGradient, _ as SvgEllipseChild, a as BoxElement, b as SvgPathChild, c as ImageElement, d as StackElement, f as StackProps, g as SvgElement, h as SvgCircleChild, i as createCanvas, j as AlignSelf, k as TextProps, l as ImageProps, m as SvgChild, n as DrawCallCanvas, o as BoxProps, p as SvgAlign, q as Size, r as LayoutSize, s as Element, t as CanvasOptions, u as StackAlign, v as SvgGroupChild, w as SvgRectChild, x as SvgPolygonChild, y as SvgLineChild, z as Bounds } from "./canvas.cjs";
1
+ import { $ as GradientDescriptor, A as SvgRectChild, B as ContainerLayoutProps, C as SvgEllipseChild, D as SvgPolygonChild, E as SvgPathChild, F as TextProps, G as LayoutProps, H as JustifyContent, I as TransformElement, J as Border, K as MeasureContext, L as TransformProps, M as SvgTextChild, N as SvgTransformProps, O as SvgPolylineChild, P as TextElement, Q as FontProps, R as AlignItems, S as SvgElement, T as SvgLineChild, U as LayoutConstraints, V as FlexDirection, W as LayoutNode, X as Color, Y as Bounds, Z as ColorStop, _ as StackElement, a as BoxElement, at as StrokeProps, b as SvgChild, c as CustomDrawProps, d as ImageProps, et as LinearGradientDescriptor, f as ProxiedCanvasContextOptions, g as StackAlign, h as RichTextSpan, i as createCanvas, it as Spacing, j as SvgStyleProps, k as SvgProps, l as Element, m as RichTextProps, n as DrawCallCanvas, nt as Shadow, o as BoxProps, ot as linearGradient, p as RichTextElement, q as createCanvasMeasureContext, r as LayoutSize, rt as Size, s as CustomDrawElement, st as radialGradient, t as CanvasOptions, tt as RadialGradientDescriptor, u as ImageElement, v as StackProps, w as SvgGroupChild, x as SvgCircleChild, y as SvgAlign, z as AlignSelf } from "./canvas.cjs";
2
2
 
3
3
  //#region src/components/Box.d.ts
4
4
  declare function Box(props: BoxProps): BoxElement;
5
5
  //#endregion
6
+ //#region src/components/CustomDraw.d.ts
7
+ declare function CustomDraw(props: CustomDrawProps): CustomDrawElement;
8
+ //#endregion
6
9
  //#region src/components/Image.d.ts
7
10
  declare function Image(props: ImageProps): ImageElement;
8
11
  //#endregion
12
+ //#region src/components/RichText.d.ts
13
+ declare function RichText(props: RichTextProps): RichTextElement;
14
+ //#endregion
9
15
  //#region src/components/Stack.d.ts
10
16
  declare function Stack(props: StackProps): StackElement;
11
17
  //#endregion
@@ -26,17 +32,23 @@ declare const svg: {
26
32
  //#region src/components/Text.d.ts
27
33
  declare function Text(props: TextProps): TextElement;
28
34
  //#endregion
29
- //#region src/layout/utils/measure.d.ts
30
- interface MeasureContext {
31
- measureText(text: string, font: FontProps): {
32
- width: number;
33
- height: number;
34
- offset: number;
35
- };
36
- }
37
- declare function createCanvasMeasureContext(ctx: CanvasRenderingContext2D): MeasureContext;
35
+ //#region src/components/Transform.d.ts
36
+ declare function Transform(props: TransformProps): TransformElement;
38
37
  //#endregion
39
38
  //#region src/layout/engine.d.ts
40
39
  declare function computeLayout(element: Element, ctx: MeasureContext, constraints: LayoutConstraints, x?: number, y?: number): LayoutNode;
41
40
  //#endregion
42
- export { type AlignItems, type AlignSelf, type Border, type Bounds, Box, type BoxElement, type BoxProps, type CanvasOptions, type Color, type ColorStop, type ContainerLayoutProps, type DrawCallCanvas, type Element, type FlexDirection, type FontProps, type GradientDescriptor, Image, type JustifyContent, type LayoutNode, type LayoutProps, type LayoutSize, type LinearGradientDescriptor, type MeasureContext, type RadialGradientDescriptor, type Shadow, type Size, type Spacing, Stack, type StackAlign, type StackElement, type StackProps, type StrokeProps, Svg, type SvgAlign, type SvgChild, type SvgCircleChild, type SvgElement, type SvgEllipseChild, type SvgGroupChild, type SvgLineChild, type SvgPathChild, type SvgPolygonChild, type SvgPolylineChild, type SvgProps, type SvgRectChild, type SvgStyleProps, type SvgTextChild, type SvgTransformProps, Text, type TextElement, type TextProps, computeLayout, createCanvas, createCanvasMeasureContext, linearGradient, radialGradient, svg };
41
+ //#region src/layout/utils/print.d.ts
42
+ /**
43
+ * 打印 LayoutNode 树结构到控制台
44
+ */
45
+ declare function printLayout(node: LayoutNode): void;
46
+ /**
47
+ * 将 LayoutNode 转换为美观的字符串
48
+ * @param node LayoutNode 根节点
49
+ * @param indent 缩进字符串,默认为两个空格
50
+ * @returns 格式化的字符串
51
+ */
52
+ declare function layoutToString(node: LayoutNode, _indent?: string): string;
53
+ //#endregion
54
+ export { type AlignItems, type AlignSelf, type Border, type Bounds, Box, type BoxElement, type BoxProps, type CanvasOptions, type Color, type ColorStop, type ContainerLayoutProps, CustomDraw, type CustomDrawElement, type CustomDrawProps, type DrawCallCanvas, type Element, type FlexDirection, type FontProps, type GradientDescriptor, Image, type JustifyContent, type LayoutNode, type LayoutProps, type LayoutSize, type LinearGradientDescriptor, type MeasureContext, type ProxiedCanvasContextOptions, type RadialGradientDescriptor, RichText, type RichTextElement, type RichTextProps, type RichTextSpan, type Shadow, type Size, type Spacing, Stack, type StackAlign, type StackElement, type StackProps, type StrokeProps, Svg, type SvgAlign, type SvgChild, type SvgCircleChild, type SvgElement, type SvgEllipseChild, type SvgGroupChild, type SvgLineChild, type SvgPathChild, type SvgPolygonChild, type SvgPolylineChild, type SvgProps, type SvgRectChild, type SvgStyleProps, type SvgTextChild, type SvgTransformProps, Text, type TextElement, type TextProps, Transform, type TransformElement, type TransformProps, computeLayout, createCanvas, createCanvasMeasureContext, layoutToString, linearGradient, printLayout, radialGradient, svg };
package/index.d.mts CHANGED
@@ -1,11 +1,17 @@
1
- import { A as AlignItems, B as Color, C as SvgProps, D as SvgTransformProps, E as SvgTextChild, F as LayoutConstraints, G as RadialGradientDescriptor, H as FontProps, I as LayoutNode, J as Spacing, K as Shadow, L as LayoutProps, M as ContainerLayoutProps, N as FlexDirection, O as TextElement, P as JustifyContent, R as Border, S as SvgPolylineChild, T as SvgStyleProps, U as GradientDescriptor, V as ColorStop, W as LinearGradientDescriptor, X as linearGradient, Y as StrokeProps, Z as radialGradient, _ as SvgEllipseChild, a as BoxElement, b as SvgPathChild, c as ImageElement, d as StackElement, f as StackProps, g as SvgElement, h as SvgCircleChild, i as createCanvas, j as AlignSelf, k as TextProps, l as ImageProps, m as SvgChild, n as DrawCallCanvas, o as BoxProps, p as SvgAlign, q as Size, r as LayoutSize, s as Element, t as CanvasOptions, u as StackAlign, v as SvgGroupChild, w as SvgRectChild, x as SvgPolygonChild, y as SvgLineChild, z as Bounds } from "./canvas.mjs";
1
+ import { $ as GradientDescriptor, A as SvgRectChild, B as ContainerLayoutProps, C as SvgEllipseChild, D as SvgPolygonChild, E as SvgPathChild, F as TextProps, G as LayoutProps, H as JustifyContent, I as TransformElement, J as Border, K as MeasureContext, L as TransformProps, M as SvgTextChild, N as SvgTransformProps, O as SvgPolylineChild, P as TextElement, Q as FontProps, R as AlignItems, S as SvgElement, T as SvgLineChild, U as LayoutConstraints, V as FlexDirection, W as LayoutNode, X as Color, Y as Bounds, Z as ColorStop, _ as StackElement, a as BoxElement, at as StrokeProps, b as SvgChild, c as CustomDrawProps, d as ImageProps, et as LinearGradientDescriptor, f as ProxiedCanvasContextOptions, g as StackAlign, h as RichTextSpan, i as createCanvas, it as Spacing, j as SvgStyleProps, k as SvgProps, l as Element, m as RichTextProps, n as DrawCallCanvas, nt as Shadow, o as BoxProps, ot as linearGradient, p as RichTextElement, q as createCanvasMeasureContext, r as LayoutSize, rt as Size, s as CustomDrawElement, st as radialGradient, t as CanvasOptions, tt as RadialGradientDescriptor, u as ImageElement, v as StackProps, w as SvgGroupChild, x as SvgCircleChild, y as SvgAlign, z as AlignSelf } from "./canvas.mjs";
2
2
 
3
3
  //#region src/components/Box.d.ts
4
4
  declare function Box(props: BoxProps): BoxElement;
5
5
  //#endregion
6
+ //#region src/components/CustomDraw.d.ts
7
+ declare function CustomDraw(props: CustomDrawProps): CustomDrawElement;
8
+ //#endregion
6
9
  //#region src/components/Image.d.ts
7
10
  declare function Image(props: ImageProps): ImageElement;
8
11
  //#endregion
12
+ //#region src/components/RichText.d.ts
13
+ declare function RichText(props: RichTextProps): RichTextElement;
14
+ //#endregion
9
15
  //#region src/components/Stack.d.ts
10
16
  declare function Stack(props: StackProps): StackElement;
11
17
  //#endregion
@@ -26,17 +32,23 @@ declare const svg: {
26
32
  //#region src/components/Text.d.ts
27
33
  declare function Text(props: TextProps): TextElement;
28
34
  //#endregion
29
- //#region src/layout/utils/measure.d.ts
30
- interface MeasureContext {
31
- measureText(text: string, font: FontProps): {
32
- width: number;
33
- height: number;
34
- offset: number;
35
- };
36
- }
37
- declare function createCanvasMeasureContext(ctx: CanvasRenderingContext2D): MeasureContext;
35
+ //#region src/components/Transform.d.ts
36
+ declare function Transform(props: TransformProps): TransformElement;
38
37
  //#endregion
39
38
  //#region src/layout/engine.d.ts
40
39
  declare function computeLayout(element: Element, ctx: MeasureContext, constraints: LayoutConstraints, x?: number, y?: number): LayoutNode;
41
40
  //#endregion
42
- export { type AlignItems, type AlignSelf, type Border, type Bounds, Box, type BoxElement, type BoxProps, type CanvasOptions, type Color, type ColorStop, type ContainerLayoutProps, type DrawCallCanvas, type Element, type FlexDirection, type FontProps, type GradientDescriptor, Image, type JustifyContent, type LayoutNode, type LayoutProps, type LayoutSize, type LinearGradientDescriptor, type MeasureContext, type RadialGradientDescriptor, type Shadow, type Size, type Spacing, Stack, type StackAlign, type StackElement, type StackProps, type StrokeProps, Svg, type SvgAlign, type SvgChild, type SvgCircleChild, type SvgElement, type SvgEllipseChild, type SvgGroupChild, type SvgLineChild, type SvgPathChild, type SvgPolygonChild, type SvgPolylineChild, type SvgProps, type SvgRectChild, type SvgStyleProps, type SvgTextChild, type SvgTransformProps, Text, type TextElement, type TextProps, computeLayout, createCanvas, createCanvasMeasureContext, linearGradient, radialGradient, svg };
41
+ //#region src/layout/utils/print.d.ts
42
+ /**
43
+ * 打印 LayoutNode 树结构到控制台
44
+ */
45
+ declare function printLayout(node: LayoutNode): void;
46
+ /**
47
+ * 将 LayoutNode 转换为美观的字符串
48
+ * @param node LayoutNode 根节点
49
+ * @param indent 缩进字符串,默认为两个空格
50
+ * @returns 格式化的字符串
51
+ */
52
+ declare function layoutToString(node: LayoutNode, _indent?: string): string;
53
+ //#endregion
54
+ export { type AlignItems, type AlignSelf, type Border, type Bounds, Box, type BoxElement, type BoxProps, type CanvasOptions, type Color, type ColorStop, type ContainerLayoutProps, CustomDraw, type CustomDrawElement, type CustomDrawProps, type DrawCallCanvas, type Element, type FlexDirection, type FontProps, type GradientDescriptor, Image, type JustifyContent, type LayoutNode, type LayoutProps, type LayoutSize, type LinearGradientDescriptor, type MeasureContext, type ProxiedCanvasContextOptions, type RadialGradientDescriptor, RichText, type RichTextElement, type RichTextProps, type RichTextSpan, type Shadow, type Size, type Spacing, Stack, type StackAlign, type StackElement, type StackProps, type StrokeProps, Svg, type SvgAlign, type SvgChild, type SvgCircleChild, type SvgElement, type SvgEllipseChild, type SvgGroupChild, type SvgLineChild, type SvgPathChild, type SvgPolygonChild, type SvgPolylineChild, type SvgProps, type SvgRectChild, type SvgStyleProps, type SvgTextChild, type SvgTransformProps, Text, type TextElement, type TextProps, Transform, type TransformElement, type TransformProps, computeLayout, createCanvas, createCanvasMeasureContext, layoutToString, linearGradient, printLayout, radialGradient, svg };