@shopify/react-native-skia 1.12.3 → 2.0.0-next.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.
Files changed (116) hide show
  1. package/android/build.gradle +1 -1
  2. package/lib/commonjs/Platform/Platform.web.js +1 -0
  3. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  4. package/lib/commonjs/external/reanimated/textures.js +4 -3
  5. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  6. package/lib/commonjs/headless/index.d.ts +1 -1
  7. package/lib/commonjs/headless/index.js +2 -2
  8. package/lib/commonjs/headless/index.js.map +1 -1
  9. package/lib/commonjs/renderer/Canvas.d.ts +3 -3
  10. package/lib/commonjs/renderer/Canvas.js +10 -27
  11. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  12. package/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  13. package/lib/commonjs/renderer/Offscreen.js +4 -4
  14. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  15. package/lib/commonjs/renderer/__tests__/setup.d.ts +6 -5
  16. package/lib/commonjs/sksg/Container.d.ts +3 -1
  17. package/lib/commonjs/sksg/Container.js +7 -1
  18. package/lib/commonjs/sksg/Container.js.map +1 -1
  19. package/lib/commonjs/sksg/Elements.d.ts +1 -1
  20. package/lib/commonjs/sksg/Elements.js.map +1 -1
  21. package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
  22. package/lib/commonjs/sksg/HostConfig.js +36 -6
  23. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  24. package/lib/commonjs/sksg/Reconciler.d.ts +3 -2
  25. package/lib/commonjs/sksg/Reconciler.js +15 -6
  26. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  27. package/lib/module/Platform/Platform.web.js +1 -0
  28. package/lib/module/Platform/Platform.web.js.map +1 -1
  29. package/lib/module/external/reanimated/textures.js +5 -4
  30. package/lib/module/external/reanimated/textures.js.map +1 -1
  31. package/lib/module/headless/index.d.ts +1 -1
  32. package/lib/module/headless/index.js +2 -2
  33. package/lib/module/headless/index.js.map +1 -1
  34. package/lib/module/renderer/Canvas.d.ts +3 -3
  35. package/lib/module/renderer/Canvas.js +9 -27
  36. package/lib/module/renderer/Canvas.js.map +1 -1
  37. package/lib/module/renderer/Offscreen.d.ts +2 -2
  38. package/lib/module/renderer/Offscreen.js +4 -4
  39. package/lib/module/renderer/Offscreen.js.map +1 -1
  40. package/lib/module/renderer/__tests__/setup.d.ts +6 -5
  41. package/lib/module/sksg/Container.d.ts +3 -1
  42. package/lib/module/sksg/Container.js +7 -1
  43. package/lib/module/sksg/Container.js.map +1 -1
  44. package/lib/module/sksg/Elements.d.ts +1 -1
  45. package/lib/module/sksg/Elements.js.map +1 -1
  46. package/lib/module/sksg/HostConfig.d.ts +2 -2
  47. package/lib/module/sksg/HostConfig.js +36 -7
  48. package/lib/module/sksg/HostConfig.js.map +1 -1
  49. package/lib/module/sksg/Reconciler.d.ts +3 -2
  50. package/lib/module/sksg/Reconciler.js +15 -6
  51. package/lib/module/sksg/Reconciler.js.map +1 -1
  52. package/lib/typescript/lib/commonjs/headless/index.d.ts +1 -1
  53. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +9 -1
  54. package/lib/typescript/lib/commonjs/renderer/Offscreen.d.ts +2 -2
  55. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +3 -0
  56. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +21 -4
  57. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +9 -2
  58. package/lib/typescript/lib/module/Platform/Platform.web.d.ts +1 -1
  59. package/lib/typescript/lib/module/headless/index.d.ts +1 -1
  60. package/lib/typescript/lib/module/mock/index.d.ts +22 -11
  61. package/lib/typescript/lib/module/renderer/Canvas.d.ts +10 -2
  62. package/lib/typescript/lib/module/renderer/Offscreen.d.ts +2 -2
  63. package/lib/typescript/lib/module/sksg/Container.d.ts +3 -0
  64. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +20 -4
  65. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +9 -2
  66. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +1 -1
  67. package/lib/typescript/src/headless/index.d.ts +1 -1
  68. package/lib/typescript/src/renderer/Canvas.d.ts +3 -3
  69. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -2
  70. package/lib/typescript/src/renderer/__tests__/setup.d.ts +6 -5
  71. package/lib/typescript/src/sksg/Container.d.ts +3 -1
  72. package/lib/typescript/src/sksg/Elements.d.ts +1 -1
  73. package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
  74. package/lib/typescript/src/sksg/Reconciler.d.ts +3 -2
  75. package/package.json +11 -10
  76. package/src/Platform/Platform.web.tsx +2 -1
  77. package/src/__tests__/snapshots/screens/snapshot2-android-ci.png +0 -0
  78. package/src/__tests__/snapshots/screens/snapshot3-android-ci.png +0 -0
  79. package/src/external/reanimated/textures.tsx +5 -4
  80. package/src/headless/index.ts +2 -2
  81. package/src/renderer/Canvas.tsx +57 -80
  82. package/src/renderer/Offscreen.tsx +4 -4
  83. package/src/renderer/__tests__/Data.spec.tsx +9 -10
  84. package/src/renderer/__tests__/Drawings.spec.tsx +11 -11
  85. package/src/renderer/__tests__/FitBox.spec.tsx +10 -10
  86. package/src/renderer/__tests__/Glyphs.spec.tsx +2 -2
  87. package/src/renderer/__tests__/Image.spec.tsx +2 -2
  88. package/src/renderer/__tests__/Paths.spec.tsx +8 -8
  89. package/src/renderer/__tests__/Picture.spec.tsx +10 -12
  90. package/src/renderer/__tests__/Simple.spec.tsx +6 -6
  91. package/src/renderer/__tests__/Surfaces.spec.tsx +2 -2
  92. package/src/renderer/__tests__/Text.spec.tsx +12 -12
  93. package/src/renderer/__tests__/Transform.spec.tsx +8 -8
  94. package/src/renderer/__tests__/documentation/Group.spec.tsx +12 -12
  95. package/src/renderer/__tests__/documentation/getting-started/HelloWorld.spec.tsx +2 -2
  96. package/src/renderer/__tests__/documentation/paint/Overview.spec.tsx +8 -8
  97. package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +4 -4
  98. package/src/renderer/__tests__/e2e/Atlas.spec.tsx +3 -3
  99. package/src/renderer/__tests__/e2e/Offscreen.spec.tsx +1 -1
  100. package/src/renderer/__tests__/examples/BlendModes.spec.tsx +4 -4
  101. package/src/renderer/__tests__/setup.tsx +17 -13
  102. package/src/sksg/Container.ts +9 -1
  103. package/src/sksg/Elements.tsx +1 -1
  104. package/src/sksg/HostConfig.ts +37 -7
  105. package/src/sksg/Reconciler.ts +16 -6
  106. package/src/sksg/__tests__/Simple.spec.tsx +8 -8
  107. package/lib/commonjs/sksg/HostConfig2.d.ts +0 -19
  108. package/lib/commonjs/sksg/HostConfig2.js +0 -159
  109. package/lib/commonjs/sksg/HostConfig2.js.map +0 -1
  110. package/lib/module/sksg/HostConfig2.d.ts +0 -19
  111. package/lib/module/sksg/HostConfig2.js +0 -152
  112. package/lib/module/sksg/HostConfig2.js.map +0 -1
  113. package/lib/typescript/lib/commonjs/sksg/HostConfig2.d.ts +0 -44
  114. package/lib/typescript/lib/module/sksg/HostConfig2.d.ts +0 -43
  115. package/lib/typescript/src/sksg/HostConfig2.d.ts +0 -19
  116. package/src/sksg/HostConfig2.ts +0 -247
@@ -9,9 +9,9 @@ import { Circle, FitBox, Rect, Image, Group, fitbox } from "../components";
9
9
  import { drawOnNode, width, height, importSkia } from "./setup";
10
10
 
11
11
  describe("FitBox", () => {
12
- it("Should scale the rectangle in half", () => {
12
+ it("Should scale the rectangle in half", async () => {
13
13
  const { Skia } = importSkia();
14
- const surface = drawOnNode(
14
+ const surface = await drawOnNode(
15
15
  <FitBox
16
16
  src={Skia.XYWHRect(0, 0, width, height)}
17
17
  dst={Skia.XYWHRect(width / 4, height / 4, width / 2, height / 2)}
@@ -21,9 +21,9 @@ describe("FitBox", () => {
21
21
  );
22
22
  processResult(surface, "snapshots/drawings/lightblue-rect.png");
23
23
  });
24
- it("Should take the bottom right quarter of the circle and scale to the full canvas", () => {
24
+ it("Should take the bottom right quarter of the circle and scale to the full canvas", async () => {
25
25
  const { Skia } = importSkia();
26
- const surface = drawOnNode(
26
+ const surface = await drawOnNode(
27
27
  <FitBox
28
28
  src={Skia.XYWHRect(width / 2, height / 2, width / 2, height / 2)}
29
29
  dst={Skia.XYWHRect(0, 0, width, height)}
@@ -38,7 +38,7 @@ describe("FitBox", () => {
38
38
  );
39
39
  processResult(surface, "snapshots/drawings/lightblue-quarter-circle.png");
40
40
  });
41
- it("Should scale the image (1)", () => {
41
+ it("Should scale the image (1)", async () => {
42
42
  const { Skia, rect } = importSkia();
43
43
  const image = Skia.Image.MakeImageFromEncoded(
44
44
  Skia.Data.fromBytes(
@@ -47,7 +47,7 @@ describe("FitBox", () => {
47
47
  )
48
48
  )
49
49
  )!;
50
- const surface = drawOnNode(
50
+ const surface = await drawOnNode(
51
51
  <Group
52
52
  transform={fitbox(
53
53
  "cover",
@@ -66,7 +66,7 @@ describe("FitBox", () => {
66
66
  );
67
67
  processResult(surface, "snapshots/drawings/scaled-image.png");
68
68
  });
69
- it("Should scale the image (2)", () => {
69
+ it("Should scale the image (2)", async () => {
70
70
  const { Skia, rect } = importSkia();
71
71
  const image = Skia.Image.MakeImageFromEncoded(
72
72
  Skia.Data.fromBytes(
@@ -76,7 +76,7 @@ describe("FitBox", () => {
76
76
  )
77
77
  )!;
78
78
  const screen = rect(256, 128, 256, 512);
79
- const surface = drawOnNode(
79
+ const surface = await drawOnNode(
80
80
  <Group>
81
81
  <Image
82
82
  image={image}
@@ -95,7 +95,7 @@ describe("FitBox", () => {
95
95
  );
96
96
  processResult(surface, "snapshots/drawings/scaled-image2.png");
97
97
  });
98
- it("Should rotate and scale the image", () => {
98
+ it("Should rotate and scale the image", async () => {
99
99
  const { Skia, rect } = importSkia();
100
100
  const image = Skia.Image.MakeImageFromEncoded(
101
101
  Skia.Data.fromBytes(
@@ -107,7 +107,7 @@ describe("FitBox", () => {
107
107
  const screen = rect(256, 128, 256, 512);
108
108
  const imageRect = rect(0, 0, image.width(), image.height());
109
109
  const transform = fitbox("contain", imageRect, screen, 270);
110
- const surface = drawOnNode(
110
+ const surface = await drawOnNode(
111
111
  <Group>
112
112
  <Image
113
113
  image={image}
@@ -25,7 +25,7 @@ describe("Glyphs", () => {
25
25
  font = Skia.Font(tf!, 64);
26
26
  expect(font !== null).toBe(true);
27
27
  });
28
- it("Should draw glyphs in lightblue", () => {
28
+ it("Should draw glyphs in lightblue", async () => {
29
29
  const { Skia } = importSkia();
30
30
  const ids = font.getGlyphIDs("ab");
31
31
  const glyphs = [
@@ -38,7 +38,7 @@ describe("Glyphs", () => {
38
38
  ),
39
39
  },
40
40
  ];
41
- const surface = drawOnNode(
41
+ const surface = await drawOnNode(
42
42
  <Glyphs x={0} y={0} font={font} glyphs={glyphs} color="lightblue" />
43
43
  );
44
44
  processResult(surface, "snapshots/glyphs/simple.png");
@@ -9,7 +9,7 @@ import { Fill, ImageShader, Shader } from "../components";
9
9
  import { drawOnNode, width, height, importSkia } from "./setup";
10
10
 
11
11
  describe("Test Image Component", () => {
12
- it("Should display the image with a filter", () => {
12
+ it("Should display the image with a filter", async () => {
13
13
  const { Skia } = importSkia();
14
14
  const image = Skia.Image.MakeImageFromEncoded(
15
15
  Skia.Data.fromBytes(
@@ -26,7 +26,7 @@ half4 main(float2 xy) {
26
26
  xy.x += sin(xy.y / r) * 4;
27
27
  return image.eval(xy).rbga;
28
28
  }`)!;
29
- const surface = drawOnNode(
29
+ const surface = await drawOnNode(
30
30
  <Fill>
31
31
  <Shader source={filter} uniforms={{ r: 50 }}>
32
32
  <ImageShader
@@ -8,7 +8,7 @@ import { drawOnNode, width, importSkia } from "./setup";
8
8
  const size = width;
9
9
 
10
10
  describe("Path Examples", () => {
11
- it("Should draw an arc", () => {
11
+ it("Should draw an arc", async () => {
12
12
  const { Skia } = importSkia();
13
13
  const path = Skia.Path.Make();
14
14
  const arcRect = {
@@ -18,11 +18,11 @@ describe("Path Examples", () => {
18
18
  height: size,
19
19
  };
20
20
  path.addArc(arcRect, 45, 270);
21
- const surface = drawOnNode(<Path path={path} color="lightblue" />);
21
+ const surface = await drawOnNode(<Path path={path} color="lightblue" />);
22
22
  processResult(surface, "snapshots/paths/arc.png");
23
23
  });
24
24
 
25
- it("Should draw an oval", () => {
25
+ it("Should draw an oval", async () => {
26
26
  const { Skia } = importSkia();
27
27
  const path = Skia.Path.Make();
28
28
  const rct = {
@@ -32,11 +32,11 @@ describe("Path Examples", () => {
32
32
  height: size,
33
33
  };
34
34
  path.addOval(rct);
35
- const surface = drawOnNode(<Path path={path} color="lightblue" />);
35
+ const surface = await drawOnNode(<Path path={path} color="lightblue" />);
36
36
  processResult(surface, "snapshots/paths/oval.png");
37
37
  });
38
38
 
39
- it("Should draw an rounded rectangle", () => {
39
+ it("Should draw an rounded rectangle", async () => {
40
40
  const { Skia } = importSkia();
41
41
  const path = Skia.Path.Make();
42
42
  path.addRRect({
@@ -49,11 +49,11 @@ describe("Path Examples", () => {
49
49
  rx: size / 4,
50
50
  ry: size / 4,
51
51
  });
52
- const surface = drawOnNode(<Path path={path} color="lightblue" />);
52
+ const surface = await drawOnNode(<Path path={path} color="lightblue" />);
53
53
  processResult(surface, "snapshots/paths/rrect.png");
54
54
  });
55
55
 
56
- it("Should draw a polygon", () => {
56
+ it("Should draw a polygon", async () => {
57
57
  const { Skia, vec } = importSkia();
58
58
  const path = Skia.Path.Make();
59
59
  const r = size / 4;
@@ -67,7 +67,7 @@ describe("Path Examples", () => {
67
67
  true
68
68
  );
69
69
 
70
- const surface = drawOnNode(
70
+ const surface = await drawOnNode(
71
71
  <Path path={path} strokeWidth={4} style="stroke" color="lightblue" />
72
72
  );
73
73
  processResult(surface, "snapshots/paths/poly.png");
@@ -4,7 +4,7 @@ import { processResult } from "../../__tests__/setup";
4
4
  import { Fill, Picture, Group } from "../components";
5
5
 
6
6
  import type { EmptyProps } from "./setup";
7
- import { wait, importSkia, mountCanvas, width } from "./setup";
7
+ import { importSkia, mountCanvas, wait, width } from "./setup";
8
8
 
9
9
  const CheckPicture = ({}: EmptyProps) => {
10
10
  const { createPicture, Skia } = importSkia();
@@ -22,9 +22,7 @@ const CheckPicture = ({}: EmptyProps) => {
22
22
  paint.setColor(Skia.Color(color));
23
23
  canvas.drawCircle(r, r, r, paint);
24
24
  }),
25
- // In a non-test environment, createPicture and Skia will be top-level, not part of the array
26
- // eslint-disable-next-line react-hooks/exhaustive-deps
27
- [color]
25
+ [Skia, color, createPicture, r]
28
26
  );
29
27
  return (
30
28
  <Group>
@@ -63,20 +61,20 @@ const CheckPicture2 = ({}: EmptyProps) => {
63
61
 
64
62
  describe("Picture", () => {
65
63
  it("should respect dependency array", async () => {
66
- const { surface, draw } = mountCanvas(<CheckPicture />);
67
- draw();
64
+ const { surface, draw } = await mountCanvas(<CheckPicture />);
65
+ await draw();
68
66
  processResult(surface, "snapshots/pictures/green.png");
69
- await wait(32);
70
- draw();
67
+ await wait(1000);
68
+ await draw();
71
69
  processResult(surface, "snapshots/pictures/red.png");
72
70
  });
73
71
 
74
72
  it("should not redraw if there are no dependency", async () => {
75
- const { surface, draw } = mountCanvas(<CheckPicture2 />);
76
- draw();
73
+ const { surface, draw } = await mountCanvas(<CheckPicture2 />);
74
+ await draw();
77
75
  processResult(surface, "snapshots/pictures/green.png");
78
- await wait(32);
79
- draw();
76
+ await wait(1000);
77
+ await draw();
80
78
  processResult(surface, "snapshots/pictures/green.png");
81
79
  });
82
80
  });
@@ -12,8 +12,8 @@ describe("Renderer", () => {
12
12
  it("Loads renderer without Skia", () => {
13
13
  expect(SkiaRenderer).toBeDefined();
14
14
  });
15
- it("Light blue rectangle", () => {
16
- const surface = drawOnNode(
15
+ it("Light blue rectangle", async () => {
16
+ const surface = await drawOnNode(
17
17
  <Rect
18
18
  x={(width - size) / 2}
19
19
  y={(width - size) / 2}
@@ -24,10 +24,10 @@ describe("Renderer", () => {
24
24
  );
25
25
  processResult(surface, "snapshots/drawings/lightblue-rect.png");
26
26
  });
27
- it("Scaled light blue rectangle", () => {
27
+ it("Scaled light blue rectangle", async () => {
28
28
  const scale = 2;
29
29
  const scaled = size / scale;
30
- const surface = drawOnNode(
30
+ const surface = await drawOnNode(
31
31
  <Group transform={[{ scale }]} origin={center}>
32
32
  <Rect
33
33
  x={(width - scaled) / 2}
@@ -40,7 +40,7 @@ describe("Renderer", () => {
40
40
  );
41
41
  processResult(surface, "snapshots/drawings/lightblue-rect.png");
42
42
  });
43
- it("Points", () => {
43
+ it("Points", async () => {
44
44
  const { vec } = importSkia();
45
45
  const c = { x: width / 2, y: size / 2 + 16 };
46
46
  const S = 25;
@@ -69,7 +69,7 @@ describe("Renderer", () => {
69
69
  ];
70
70
 
71
71
  const cubics = [...c1, ...c2, ...c3, ...c4];
72
- const surface = drawOnNode(
72
+ const surface = await drawOnNode(
73
73
  <Group color="#61DAFB" style="stroke" strokeWidth={3}>
74
74
  <Points mode="polygon" points={cubics} />
75
75
  <Line p1={c} p2={vec(size, 0)} />
@@ -51,11 +51,11 @@ describe("Surface", () => {
51
51
  surface.dispose();
52
52
  }
53
53
  });
54
- it("A raster surface shouldn't leak (3)", () => {
54
+ it("A raster surface shouldn't leak (3)", async () => {
55
55
  for (let i = 0; i < 10; i++) {
56
56
  //const t = performance.now();
57
57
  const r = 128;
58
- const surface = drawOnNode(
58
+ const surface = await drawOnNode(
59
59
  <>
60
60
  <Group blendMode="multiply">
61
61
  <Circle cx={r} cy={r} r={r} color="cyan" />
@@ -16,9 +16,9 @@ import {
16
16
  } from "./setup";
17
17
 
18
18
  describe("Test different text examples", () => {
19
- it("Should draw Hello World", () => {
19
+ it("Should draw Hello World", async () => {
20
20
  const font = loadFont("skia/__tests__/assets/Roboto-Medium.ttf");
21
- const surface = drawOnNode(
21
+ const surface = await drawOnNode(
22
22
  <>
23
23
  <Fill color="white" />
24
24
  <Text x={0} y={fontSize} font={font} text="Hello World" />
@@ -27,13 +27,13 @@ describe("Test different text examples", () => {
27
27
  processResult(surface, docPath("text/hello-world.png"));
28
28
  });
29
29
 
30
- it("Should draw Hello World vertically", () => {
30
+ it("Should draw Hello World vertically", async () => {
31
31
  const font = loadFont("skia/__tests__/assets/Roboto-Medium.ttf");
32
32
  const { Skia } = importSkia();
33
33
  const glyphs = font
34
34
  .getGlyphIDs("Hello World!")
35
35
  .map((id, i) => ({ id, pos: Skia.Point(0, (i + 1) * fontSize) }));
36
- const surface = drawOnNode(
36
+ const surface = await drawOnNode(
37
37
  <>
38
38
  <Fill color="white" />
39
39
  <Glyphs font={font} glyphs={glyphs} />
@@ -42,13 +42,13 @@ describe("Test different text examples", () => {
42
42
  processResult(surface, docPath("text/hello-world-vertical.png"));
43
43
  });
44
44
 
45
- it("Should render the text around a circle", () => {
45
+ it("Should render the text around a circle", async () => {
46
46
  const font = loadFont("skia/__tests__/assets/Roboto-Medium.ttf");
47
47
  const { Skia } = importSkia();
48
48
  const path = Skia.Path.Make();
49
49
  const r = width / 2;
50
50
  path.addCircle(r, r, r / 2);
51
- const surface = drawOnNode(
51
+ const surface = await drawOnNode(
52
52
  <>
53
53
  <Fill color="white" />
54
54
  <Group transform={[{ rotate: Math.PI }]} origin={Skia.Point(r, r)}>
@@ -59,11 +59,11 @@ describe("Test different text examples", () => {
59
59
  processResult(surface, docPath("text/text-path.png"));
60
60
  });
61
61
 
62
- it("Should render a text blob", () => {
62
+ it("Should render a text blob", async () => {
63
63
  const font = loadFont("skia/__tests__/assets/Roboto-Medium.ttf");
64
64
  const { Skia } = importSkia();
65
65
  const blob = Skia.TextBlob.MakeFromText("Hello World!", font);
66
- const surface = drawOnNode(
66
+ const surface = await drawOnNode(
67
67
  <>
68
68
  <Fill color="white" />
69
69
  <TextBlob blob={blob} y={fontSize} x={0} />
@@ -72,7 +72,7 @@ describe("Test different text examples", () => {
72
72
  processResult(surface, docPath("text/text-blob.png"));
73
73
  });
74
74
 
75
- it("Should render text with Emojis", () => {
75
+ it("Should render text with Emojis", async () => {
76
76
  const { Skia } = importSkia();
77
77
  const data = Skia.Data.fromBytes(
78
78
  fs.readFileSync(
@@ -85,7 +85,7 @@ describe("Test different text examples", () => {
85
85
  const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data)!;
86
86
  expect(tf).toBeTruthy();
87
87
  const emojiFont = Skia.Font(tf, fontSize);
88
- const surface = drawOnNode(
88
+ const surface = await drawOnNode(
89
89
  <>
90
90
  <Fill color="white" />
91
91
  <Text text="🙋🌎" font={emojiFont} y={fontSize} x={0} />
@@ -94,7 +94,7 @@ describe("Test different text examples", () => {
94
94
  processResult(surface, docPath("text/text-emoji.png"));
95
95
  });
96
96
 
97
- it("Should calculate chinese text width correctly", () => {
97
+ it("Should calculate chinese text width correctly", async () => {
98
98
  const { Skia } = importSkia();
99
99
  const data = Skia.Data.fromBytes(
100
100
  fs.readFileSync(
@@ -109,7 +109,7 @@ describe("Test different text examples", () => {
109
109
  const font = Skia.Font(tf, fontSize);
110
110
  const text = "欢迎";
111
111
  const padding = 16;
112
- const surface = drawOnNode(
112
+ const surface = await drawOnNode(
113
113
  <>
114
114
  <Text
115
115
  text={text}
@@ -10,18 +10,18 @@ describe("Renderer", () => {
10
10
  it("Loads renderer without Skia", () => {
11
11
  expect(SkiaRenderer).toBeDefined();
12
12
  });
13
- it("Scale with origin", () => {
13
+ it("Scale with origin", async () => {
14
14
  const { Skia } = importSkia();
15
15
  const size = width;
16
16
  const origin = Skia.Point(size / 2, size / 2);
17
- const surface = drawOnNode(
17
+ const surface = await drawOnNode(
18
18
  <Group transform={[{ scale: 0.5 }]} origin={origin}>
19
19
  <Rect x={0} y={0} width={size} height={size} color="lightblue" />
20
20
  </Group>
21
21
  );
22
22
  processResult(surface, "snapshots/transform/scale-origin.png");
23
23
  });
24
- it("Scale with origin using a matrix", () => {
24
+ it("Scale with origin using a matrix", async () => {
25
25
  const { Skia } = importSkia();
26
26
  const size = width;
27
27
  const matrix = Skia.Matrix();
@@ -31,32 +31,32 @@ describe("Renderer", () => {
31
31
  .scale(0.5)
32
32
  .translate(-origin.x, -origin.y);
33
33
  expect(matrix.get()).toStrictEqual([0.5, 0, 192, 0, 0.5, 192, 0, 0, 1]);
34
- const surface = drawOnNode(
34
+ const surface = await drawOnNode(
35
35
  <Group matrix={matrix}>
36
36
  <Rect x={0} y={0} width={size} height={size} color="lightblue" />
37
37
  </Group>
38
38
  );
39
39
  processResult(surface, "snapshots/transform/scale-origin.png");
40
40
  });
41
- it("Scale with matrix and origin", () => {
41
+ it("Scale with matrix and origin", async () => {
42
42
  const { Skia } = importSkia();
43
43
  const size = width;
44
44
  const matrix = Skia.Matrix();
45
45
  const origin = Skia.Point(size / 2, size / 2);
46
46
  matrix.scale(0.5);
47
- const surface = drawOnNode(
47
+ const surface = await drawOnNode(
48
48
  <Group matrix={matrix} origin={origin}>
49
49
  <Rect x={0} y={0} width={size} height={size} color="lightblue" />
50
50
  </Group>
51
51
  );
52
52
  processResult(surface, "snapshots/transform/scale-origin.png");
53
53
  });
54
- it("Should rotate a rectangle to 180deg", () => {
54
+ it("Should rotate a rectangle to 180deg", async () => {
55
55
  const { Skia } = importSkia();
56
56
  const size = width;
57
57
  const origin = Skia.Point(size / 2, size / 2);
58
58
  const w = size / 4;
59
- const surface = drawOnNode(
59
+ const surface = await drawOnNode(
60
60
  <Group transform={[{ rotate: Math.PI }]} origin={origin}>
61
61
  <Rect
62
62
  x={origin.x - w / 2}
@@ -51,12 +51,12 @@ const TestRasterization = () => {
51
51
  };
52
52
 
53
53
  describe("Group", () => {
54
- it("Should use a rectangle as a clip", () => {
54
+ it("Should use a rectangle as a clip", async () => {
55
55
  const image = loadImage("skia/__tests__/assets/oslo.jpg");
56
56
  const { rect } = importSkia();
57
57
  expect(image).toBeTruthy();
58
58
  const rct = rect(padding, padding, size - padding * 2, size - padding * 2);
59
- const surface = drawOnNode(
59
+ const surface = await drawOnNode(
60
60
  <>
61
61
  <Fill color="lightblue" />
62
62
  <Group clip={rct}>
@@ -73,7 +73,7 @@ describe("Group", () => {
73
73
  );
74
74
  processResult(surface, docPath("group/clip-rect.png"));
75
75
  });
76
- it("Should use a rounded rectangle as a clip", () => {
76
+ it("Should use a rounded rectangle as a clip", async () => {
77
77
  const image = loadImage("skia/__tests__/assets/oslo.jpg");
78
78
  const { rect, rrect } = importSkia();
79
79
  expect(image).toBeTruthy();
@@ -82,7 +82,7 @@ describe("Group", () => {
82
82
  r,
83
83
  r
84
84
  );
85
- const surface = drawOnNode(
85
+ const surface = await drawOnNode(
86
86
  <Group clip={rct}>
87
87
  <Image
88
88
  image={image}
@@ -96,7 +96,7 @@ describe("Group", () => {
96
96
  );
97
97
  processResult(surface, docPath("group/clip-rrect.png"));
98
98
  });
99
- it("Should use a path as a clip", () => {
99
+ it("Should use a path as a clip", async () => {
100
100
  const image = loadImage("skia/__tests__/assets/oslo.jpg");
101
101
  const { processTransform2d, Skia } = importSkia();
102
102
  expect(image).toBeTruthy();
@@ -105,7 +105,7 @@ describe("Group", () => {
105
105
  )!;
106
106
  expect(star).toBeTruthy();
107
107
  star.transform(processTransform2d([{ scale: 3 }]));
108
- const surface = drawOnNode(
108
+ const surface = await drawOnNode(
109
109
  <Group clip={star}>
110
110
  <Image
111
111
  image={image}
@@ -119,7 +119,7 @@ describe("Group", () => {
119
119
  );
120
120
  processResult(surface, docPath("group/clip-path.png"));
121
121
  });
122
- it("Should invert a clip", () => {
122
+ it("Should invert a clip", async () => {
123
123
  const image = loadImage("skia/__tests__/assets/oslo.jpg");
124
124
  const { processTransform2d, Skia } = importSkia();
125
125
  expect(image).toBeTruthy();
@@ -128,7 +128,7 @@ describe("Group", () => {
128
128
  )!;
129
129
  expect(star).toBeTruthy();
130
130
  star.transform(processTransform2d([{ scale: 3 }]));
131
- const surface = drawOnNode(
131
+ const surface = await drawOnNode(
132
132
  <Group clip={star} invertClip>
133
133
  <Image
134
134
  image={image}
@@ -142,7 +142,7 @@ describe("Group", () => {
142
142
  );
143
143
  processResult(surface, docPath("group/invert-clip.png"));
144
144
  });
145
- it("Should scale an SVG Path properly", () => {
145
+ it("Should scale an SVG Path properly", async () => {
146
146
  const { rect, Skia } = importSkia();
147
147
  const svgPath =
148
148
  // eslint-disable-next-line max-len
@@ -151,7 +151,7 @@ describe("Group", () => {
151
151
  expect(path).toBeTruthy();
152
152
  const src = path.computeTightBounds();
153
153
  const strokeWidth = 30 * PIXEL_RATIO;
154
- const surface = drawOnNode(
154
+ const surface = await drawOnNode(
155
155
  <FitBox src={src} dst={rect(0, 0, width, height)}>
156
156
  <Path
157
157
  path={path}
@@ -164,8 +164,8 @@ describe("Group", () => {
164
164
  );
165
165
  processResult(surface, docPath("group/scale-path.png"));
166
166
  });
167
- it("Should use saveLayer() properly", () => {
168
- const surface = drawOnNode(<TestRasterization />);
167
+ it("Should use saveLayer() properly", async () => {
168
+ const surface = await drawOnNode(<TestRasterization />);
169
169
  processResult(surface, docPath("group/rasterize.png"));
170
170
  });
171
171
  });
@@ -35,8 +35,8 @@ describe("Getting Started / Hello World", () => {
35
35
  docPath("getting-started/hello-world/blend-modes.png")
36
36
  );
37
37
  });
38
- it("Hello world with the declarative API", () => {
39
- const surface = drawOnNode(
38
+ it("Hello world with the declarative API", async () => {
39
+ const surface = await drawOnNode(
40
40
  <Group blendMode="multiply">
41
41
  <Circle cx={r} cy={r} r={r} color="cyan" />
42
42
  <Circle cx={size - r} cy={r} r={r} color="magenta" />
@@ -19,12 +19,12 @@ const TestPaintAssignment = () => {
19
19
  };
20
20
 
21
21
  describe("Paint", () => {
22
- it("should draw the color fill and strokes properly", () => {
22
+ it("should draw the color fill and strokes properly", async () => {
23
23
  const { vec } = importSkia();
24
24
  const strokeWidth = 10 * PIXEL_RATIO;
25
25
  const c = vec(width / 2, height / 2);
26
26
  const r = (width - strokeWidth) / 2;
27
- const surface = drawOnNode(
27
+ const surface = await drawOnNode(
28
28
  <>
29
29
  <Circle c={c} r={r} color="red">
30
30
  <Paint color="lightblue" />
@@ -36,10 +36,10 @@ describe("Paint", () => {
36
36
  processResult(surface, docPath("paint/stroke.png"));
37
37
  });
38
38
 
39
- it("should use paint inheritance properly", () => {
39
+ it("should use paint inheritance properly", async () => {
40
40
  const r = width / 6;
41
41
  const strokeWidth = 10 * PIXEL_RATIO;
42
- const surface = drawOnNode(
42
+ const surface = await drawOnNode(
43
43
  <Group color="lightblue">
44
44
  <Circle cx={r} cy={r} r={r} />
45
45
  <Group style="stroke" strokeWidth={strokeWidth}>
@@ -50,17 +50,17 @@ describe("Paint", () => {
50
50
  processResult(surface, docPath("paint/inheritance.png"));
51
51
  });
52
52
 
53
- it("should use paint assignement properly", () => {
54
- const surface = drawOnNode(<TestPaintAssignment />);
53
+ it("should use paint assignement properly", async () => {
54
+ const surface = await drawOnNode(<TestPaintAssignment />);
55
55
  processResult(surface, docPath("paint/assignement.png"));
56
56
  });
57
57
 
58
- it("should use the opacity property properly", () => {
58
+ it("should use the opacity property properly", async () => {
59
59
  const { vec } = importSkia();
60
60
  const strokeWidth = 30 * PIXEL_RATIO;
61
61
  const r = width / 2 - strokeWidth / 2;
62
62
  const c = vec(width / 2, height / 2);
63
- const surface = drawOnNode(
63
+ const surface = await drawOnNode(
64
64
  <Group opacity={0.5}>
65
65
  <Circle c={c} r={r} color="red" />
66
66
  <Circle
@@ -5,11 +5,11 @@ import { docPath, processResult } from "../../../../__tests__/setup";
5
5
  import { Box, BoxShadow, Fill } from "../../../components";
6
6
 
7
7
  describe("Box", () => {
8
- it("should draw a box with inner and outer shadow", () => {
8
+ it("should draw a box with inner and outer shadow", async () => {
9
9
  const { rect, rrect } = importSkia();
10
10
  const size = width / 2;
11
11
  const d = 10 * PIXEL_RATIO;
12
- const surface = drawOnNode(
12
+ const surface = await drawOnNode(
13
13
  <>
14
14
  <Fill color="#add8e6" />
15
15
  <Box
@@ -29,9 +29,9 @@ describe("Box", () => {
29
29
  );
30
30
  processResult(surface, docPath("box/shadows.png"));
31
31
  });
32
- it("should draw a box with red stroke", () => {
32
+ it("should draw a box with red stroke", async () => {
33
33
  const size = width / 2;
34
- const surface = drawOnNode(
34
+ const surface = await drawOnNode(
35
35
  <>
36
36
  <Box
37
37
  box={{ width: size, height: size, x: 1, y: 1 }}
@@ -168,7 +168,7 @@ describe("Atlas", () => {
168
168
  width: size.width + strokeWidth,
169
169
  height: size.height + strokeWidth,
170
170
  };
171
- const texture = drawAsImage(
171
+ const texture = await drawAsImage(
172
172
  <Group>
173
173
  <Rect
174
174
  rect={rect(strokeWidth / 2, strokeWidth / 2, size.width, size.height)}
@@ -211,7 +211,7 @@ describe("Atlas", () => {
211
211
  width: size.width + strokeWidth,
212
212
  height: size.height + strokeWidth,
213
213
  };
214
- const texture = drawAsImage(
214
+ const texture = await drawAsImage(
215
215
  <Group>
216
216
  <Rect
217
217
  rect={rect(strokeWidth / 2, strokeWidth / 2, size.width, size.height)}
@@ -283,7 +283,7 @@ describe("Atlas", () => {
283
283
  width: size.width + strokeWidth,
284
284
  height: size.height + strokeWidth,
285
285
  };
286
- const texture = drawAsImage(
286
+ const texture = await drawAsImage(
287
287
  <Group>
288
288
  <Rect
289
289
  rect={rect(strokeWidth / 2, strokeWidth / 2, size.width, size.height)}
@@ -100,7 +100,7 @@ describe("Offscreen Drawings", () => {
100
100
  const { width, height } = surface;
101
101
  const { drawAsImage } = importSkia();
102
102
  const r = width / 2;
103
- const image = drawAsImage(
103
+ const image = await drawAsImage(
104
104
  <Circle r={r} cx={r} cy={r} color="lightblue" />,
105
105
  { width, height }
106
106
  );