@codehz/draw-call 0.1.1 → 0.1.2

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as radialGradient, i as linearGradient, n as computeLayout, r as createCanvasMeasureContext, t as renderNode } from "./engine-C88lMGbX.mjs";
1
+ import { a as radialGradient, i as linearGradient, n as computeLayout, r as createCanvasMeasureContext, t as renderNode } from "./render.mjs";
2
2
 
3
3
  //#region src/canvas.ts
4
4
  /**
@@ -24,6 +24,7 @@ function createCanvas(options) {
24
24
  width,
25
25
  height,
26
26
  pixelRatio,
27
+ canvas,
27
28
  render(element) {
28
29
  const layoutTree = computeLayout(element, measureCtx, {
29
30
  minWidth: 0,
@@ -44,7 +45,7 @@ function createCanvas(options) {
44
45
  if ("toDataURL" in canvas && typeof canvas.toDataURL === "function") return canvas.toDataURL(type, quality);
45
46
  throw new Error("toDataURL not supported");
46
47
  },
47
- async toBuffer(type = "image/png") {
48
+ toBuffer(type = "image/png") {
48
49
  if ("toBuffer" in canvas && typeof canvas.toBuffer === "function") return canvas.toBuffer(type);
49
50
  throw new Error("toBuffer not supported in this environment");
50
51
  }
@@ -60,6 +61,15 @@ function Box(props) {
60
61
  };
61
62
  }
62
63
 
64
+ //#endregion
65
+ //#region src/components/Image.ts
66
+ function Image(props) {
67
+ return {
68
+ type: "image",
69
+ ...props
70
+ };
71
+ }
72
+
63
73
  //#endregion
64
74
  //#region src/components/Stack.ts
65
75
  function Stack(props) {
@@ -69,6 +79,53 @@ function Stack(props) {
69
79
  };
70
80
  }
71
81
 
82
+ //#endregion
83
+ //#region src/components/Svg.ts
84
+ function Svg(props) {
85
+ return {
86
+ type: "svg",
87
+ ...props
88
+ };
89
+ }
90
+ const svg = {
91
+ rect: (props) => ({
92
+ type: "rect",
93
+ ...props
94
+ }),
95
+ circle: (props) => ({
96
+ type: "circle",
97
+ ...props
98
+ }),
99
+ ellipse: (props) => ({
100
+ type: "ellipse",
101
+ ...props
102
+ }),
103
+ line: (props) => ({
104
+ type: "line",
105
+ ...props
106
+ }),
107
+ polyline: (props) => ({
108
+ type: "polyline",
109
+ ...props
110
+ }),
111
+ polygon: (props) => ({
112
+ type: "polygon",
113
+ ...props
114
+ }),
115
+ path: (props) => ({
116
+ type: "path",
117
+ ...props
118
+ }),
119
+ text: (props) => ({
120
+ type: "text",
121
+ ...props
122
+ }),
123
+ g: (props) => ({
124
+ type: "g",
125
+ ...props
126
+ })
127
+ };
128
+
72
129
  //#endregion
73
130
  //#region src/components/Text.ts
74
131
  function Text(props) {
@@ -79,4 +136,4 @@ function Text(props) {
79
136
  }
80
137
 
81
138
  //#endregion
82
- export { Box, Stack, Text, computeLayout, createCanvas, createCanvasMeasureContext, linearGradient, radialGradient };
139
+ export { Box, Image, Stack, Svg, Text, computeLayout, createCanvas, createCanvasMeasureContext, linearGradient, radialGradient, svg };
package/node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_engine = require('./engine-OyKoV7Gn.cjs');
1
+ const require_render = require('./render.cjs');
2
2
  let _napi_rs_canvas = require("@napi-rs/canvas");
3
3
 
4
4
  //#region src/node.ts
@@ -13,19 +13,20 @@ function createCanvas(options) {
13
13
  const canvas = (0, _napi_rs_canvas.createCanvas)(width * pixelRatio, height * pixelRatio);
14
14
  const ctx = canvas.getContext("2d");
15
15
  if (pixelRatio !== 1) ctx.scale(pixelRatio, pixelRatio);
16
- const measureCtx = require_engine.createCanvasMeasureContext(ctx);
16
+ const measureCtx = require_render.createCanvasMeasureContext(ctx);
17
17
  return {
18
18
  width,
19
19
  height,
20
20
  pixelRatio,
21
+ canvas,
21
22
  render(element) {
22
- const layoutTree = require_engine.computeLayout(element, measureCtx, {
23
+ const layoutTree = require_render.computeLayout(element, measureCtx, {
23
24
  minWidth: 0,
24
25
  maxWidth: width,
25
26
  minHeight: 0,
26
27
  maxHeight: height
27
28
  });
28
- require_engine.renderNode(ctx, layoutTree);
29
+ require_render.renderNode(ctx, layoutTree);
29
30
  return layoutTree;
30
31
  },
31
32
  clear() {
@@ -37,7 +38,7 @@ function createCanvas(options) {
37
38
  toDataURL(type, quality) {
38
39
  return canvas.toDataURL(type, quality);
39
40
  },
40
- async toBuffer(type = "image/png") {
41
+ toBuffer(type = "image/png") {
41
42
  return canvas.toBuffer(type);
42
43
  }
43
44
  };
package/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as DrawCallCanvas, t as CanvasOptions } from "./canvas-CkpP3RNK.cjs";
1
+ import { n as DrawCallCanvas, t as CanvasOptions } from "./canvas.cjs";
2
2
 
3
3
  //#region src/node.d.ts
4
4
  /**
package/node.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as DrawCallCanvas, t as CanvasOptions } from "./canvas-BYrCq8eS.mjs";
1
+ import { n as DrawCallCanvas, t as CanvasOptions } from "./canvas.mjs";
2
2
 
3
3
  //#region src/node.d.ts
4
4
  /**
package/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as computeLayout, r as createCanvasMeasureContext, t as renderNode } from "./engine-C88lMGbX.mjs";
1
+ import { n as computeLayout, r as createCanvasMeasureContext, t as renderNode } from "./render.mjs";
2
2
  import { createCanvas as createCanvas$1 } from "@napi-rs/canvas";
3
3
 
4
4
  //#region src/node.ts
@@ -18,6 +18,7 @@ function createCanvas(options) {
18
18
  width,
19
19
  height,
20
20
  pixelRatio,
21
+ canvas,
21
22
  render(element) {
22
23
  const layoutTree = computeLayout(element, measureCtx, {
23
24
  minWidth: 0,
@@ -37,7 +38,7 @@ function createCanvas(options) {
37
38
  toDataURL(type, quality) {
38
39
  return canvas.toDataURL(type, quality);
39
40
  },
40
- async toBuffer(type = "image/png") {
41
+ toBuffer(type = "image/png") {
41
42
  return canvas.toBuffer(type);
42
43
  }
43
44
  };
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "optionalDependencies": {
26
26
  "@napi-rs/canvas": "^0.1.88"
27
27
  },
28
- "version": "0.1.1",
28
+ "version": "0.1.2",
29
29
  "main": "./index.cjs",
30
30
  "types": "./index.d.cts",
31
31
  "exports": {