@shopify/react-native-skia 0.1.116 → 0.1.120

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. package/cpp/api/JsiSkApi.h +13 -9
  2. package/cpp/api/JsiSkCanvas.h +9 -1
  3. package/cpp/api/JsiSkPicture.h +71 -0
  4. package/cpp/api/JsiSkPictureFactory.h +50 -0
  5. package/cpp/api/JsiSkPictureRecorder.h +53 -0
  6. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +3 -6
  7. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -4
  8. package/ios/RNSkia-iOS/SkiaDrawView.mm +3 -2
  9. package/lib/commonjs/renderer/Canvas.js +22 -36
  10. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  11. package/lib/commonjs/renderer/HostConfig.js +3 -25
  12. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  13. package/lib/commonjs/renderer/components/{Defs.js → Drawing.js} +13 -12
  14. package/lib/commonjs/renderer/components/Drawing.js.map +1 -0
  15. package/lib/commonjs/renderer/components/Group.js +7 -4
  16. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  17. package/lib/commonjs/renderer/components/Paint.js +1 -21
  18. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  19. package/lib/commonjs/renderer/components/Picture.js +35 -0
  20. package/lib/commonjs/renderer/components/Picture.js.map +1 -0
  21. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +5 -34
  22. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  23. package/lib/commonjs/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +19 -8
  24. package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -0
  25. package/lib/commonjs/renderer/components/imageFilters/index.js +4 -17
  26. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  27. package/lib/commonjs/renderer/components/index.js +17 -4
  28. package/lib/commonjs/renderer/components/index.js.map +1 -1
  29. package/lib/commonjs/renderer/components/maskFilters/Blur.js +1 -1
  30. package/lib/commonjs/renderer/components/maskFilters/Blur.js.map +1 -1
  31. package/lib/commonjs/renderer/components/shapes/Box.js +126 -0
  32. package/lib/commonjs/renderer/components/shapes/Box.js.map +1 -0
  33. package/lib/commonjs/renderer/components/shapes/index.js +13 -0
  34. package/lib/commonjs/renderer/components/shapes/index.js.map +1 -1
  35. package/lib/commonjs/renderer/index.js +13 -0
  36. package/lib/commonjs/renderer/index.js.map +1 -1
  37. package/lib/commonjs/renderer/nodes/Declaration.js +12 -1
  38. package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
  39. package/lib/commonjs/renderer/nodes/Drawing.js +9 -24
  40. package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
  41. package/lib/commonjs/renderer/nodes/Node.js +9 -16
  42. package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
  43. package/lib/commonjs/renderer/processors/Paint.js +24 -26
  44. package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
  45. package/lib/commonjs/renderer/processors/math/Math.js +19 -1
  46. package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
  47. package/lib/commonjs/renderer/processors/math/Matrix3.js +11 -5
  48. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  49. package/lib/commonjs/renderer/typeddash.js +26 -2
  50. package/lib/commonjs/renderer/typeddash.js.map +1 -1
  51. package/lib/commonjs/renderer/useContextBridge.js +35 -0
  52. package/lib/commonjs/renderer/useContextBridge.js.map +1 -0
  53. package/lib/commonjs/skia/Canvas.js.map +1 -1
  54. package/lib/commonjs/skia/Picture/Picture.js +6 -0
  55. package/lib/commonjs/skia/Picture/Picture.js.map +1 -0
  56. package/lib/commonjs/skia/Picture/PictureFactory.js +6 -0
  57. package/lib/commonjs/skia/Picture/PictureFactory.js.map +1 -0
  58. package/lib/commonjs/skia/Picture/PictureRecorder.js +6 -0
  59. package/lib/commonjs/skia/Picture/PictureRecorder.js.map +1 -0
  60. package/lib/commonjs/skia/Picture/index.js +58 -0
  61. package/lib/commonjs/skia/Picture/index.js.map +1 -0
  62. package/lib/commonjs/skia/Picture/usePicture.js +30 -0
  63. package/lib/commonjs/skia/Picture/usePicture.js.map +1 -0
  64. package/lib/commonjs/skia/Skia.js +2 -0
  65. package/lib/commonjs/skia/Skia.js.map +1 -1
  66. package/lib/commonjs/skia/index.js +14 -0
  67. package/lib/commonjs/skia/index.js.map +1 -1
  68. package/lib/commonjs/values/hooks/useDerivedValue.js +2 -2
  69. package/lib/commonjs/values/hooks/useDerivedValue.js.map +1 -1
  70. package/lib/commonjs/views/SkiaView.js +6 -5
  71. package/lib/commonjs/views/SkiaView.js.map +1 -1
  72. package/lib/commonjs/views/types.js.map +1 -1
  73. package/lib/module/renderer/Canvas.js +20 -32
  74. package/lib/module/renderer/Canvas.js.map +1 -1
  75. package/lib/module/renderer/HostConfig.js +2 -24
  76. package/lib/module/renderer/HostConfig.js.map +1 -1
  77. package/lib/module/renderer/components/Drawing.js +17 -0
  78. package/lib/module/renderer/components/Drawing.js.map +1 -0
  79. package/lib/module/renderer/components/Group.js +8 -6
  80. package/lib/module/renderer/components/Group.js.map +1 -1
  81. package/lib/module/renderer/components/Paint.js +2 -22
  82. package/lib/module/renderer/components/Paint.js.map +1 -1
  83. package/lib/module/renderer/components/Picture.js +21 -0
  84. package/lib/module/renderer/components/Picture.js.map +1 -0
  85. package/lib/module/renderer/components/imageFilters/InnerShadow.js +4 -26
  86. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  87. package/lib/module/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +16 -6
  88. package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -0
  89. package/lib/module/renderer/components/imageFilters/index.js +1 -2
  90. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  91. package/lib/module/renderer/components/index.js +2 -1
  92. package/lib/module/renderer/components/index.js.map +1 -1
  93. package/lib/module/renderer/components/maskFilters/Blur.js +1 -1
  94. package/lib/module/renderer/components/maskFilters/Blur.js.map +1 -1
  95. package/lib/module/renderer/components/shapes/Box.js +102 -0
  96. package/lib/module/renderer/components/shapes/Box.js.map +1 -0
  97. package/lib/module/renderer/components/shapes/index.js +1 -0
  98. package/lib/module/renderer/components/shapes/index.js.map +1 -1
  99. package/lib/module/renderer/index.js +1 -0
  100. package/lib/module/renderer/index.js.map +1 -1
  101. package/lib/module/renderer/nodes/Declaration.js +4 -0
  102. package/lib/module/renderer/nodes/Declaration.js.map +1 -1
  103. package/lib/module/renderer/nodes/Drawing.js +8 -21
  104. package/lib/module/renderer/nodes/Drawing.js.map +1 -1
  105. package/lib/module/renderer/nodes/Node.js +9 -15
  106. package/lib/module/renderer/nodes/Node.js.map +1 -1
  107. package/lib/module/renderer/processors/Paint.js +22 -21
  108. package/lib/module/renderer/processors/Paint.js.map +1 -1
  109. package/lib/module/renderer/processors/math/Math.js +15 -0
  110. package/lib/module/renderer/processors/math/Math.js.map +1 -1
  111. package/lib/module/renderer/processors/math/Matrix3.js +6 -2
  112. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  113. package/lib/module/renderer/typeddash.js +21 -0
  114. package/lib/module/renderer/typeddash.js.map +1 -1
  115. package/lib/module/renderer/useContextBridge.js +21 -0
  116. package/lib/module/renderer/useContextBridge.js.map +1 -0
  117. package/lib/module/skia/Canvas.js.map +1 -1
  118. package/lib/module/skia/Picture/Picture.js +2 -0
  119. package/lib/module/skia/Picture/Picture.js.map +1 -0
  120. package/lib/module/skia/Picture/PictureFactory.js +2 -0
  121. package/lib/module/skia/Picture/PictureFactory.js.map +1 -0
  122. package/lib/module/skia/Picture/PictureRecorder.js +2 -0
  123. package/lib/module/skia/Picture/PictureRecorder.js.map +1 -0
  124. package/lib/module/skia/Picture/index.js +5 -0
  125. package/lib/module/skia/Picture/index.js.map +1 -0
  126. package/lib/module/skia/Picture/usePicture.js +19 -0
  127. package/lib/module/skia/Picture/usePicture.js.map +1 -0
  128. package/lib/module/skia/Skia.js +2 -0
  129. package/lib/module/skia/Skia.js.map +1 -1
  130. package/lib/module/skia/index.js +1 -0
  131. package/lib/module/skia/index.js.map +1 -1
  132. package/lib/module/values/hooks/useDerivedValue.js +1 -1
  133. package/lib/module/values/hooks/useDerivedValue.js.map +1 -1
  134. package/lib/module/views/SkiaView.js +6 -5
  135. package/lib/module/views/SkiaView.js.map +1 -1
  136. package/lib/module/views/types.js.map +1 -1
  137. package/lib/typescript/src/renderer/Canvas.d.ts +5 -10
  138. package/lib/typescript/src/renderer/components/Drawing.d.ts +7 -0
  139. package/lib/typescript/src/renderer/components/Picture.d.ts +6 -0
  140. package/lib/typescript/src/renderer/components/imageFilters/InnerShadow.d.ts +3 -12
  141. package/lib/typescript/src/renderer/components/imageFilters/{DropShadow.d.ts → Shadow.d.ts} +3 -2
  142. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -2
  143. package/lib/typescript/src/renderer/components/index.d.ts +2 -1
  144. package/lib/typescript/src/renderer/components/shapes/Box.d.ts +23 -0
  145. package/lib/typescript/src/renderer/components/shapes/index.d.ts +1 -0
  146. package/lib/typescript/src/renderer/index.d.ts +1 -0
  147. package/lib/typescript/src/renderer/nodes/Declaration.d.ts +3 -0
  148. package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
  149. package/lib/typescript/src/renderer/nodes/Node.d.ts +2 -2
  150. package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -2
  151. package/lib/typescript/src/renderer/processors/math/Math.d.ts +14 -0
  152. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -0
  153. package/lib/typescript/src/renderer/typeddash.d.ts +1 -0
  154. package/lib/typescript/src/renderer/useContextBridge.d.ts +5 -0
  155. package/lib/typescript/src/skia/Canvas.d.ts +6 -0
  156. package/lib/typescript/src/skia/Picture/Picture.d.ts +26 -0
  157. package/lib/typescript/src/skia/Picture/PictureFactory.d.ts +8 -0
  158. package/lib/typescript/src/skia/Picture/PictureRecorder.d.ts +15 -0
  159. package/lib/typescript/src/skia/Picture/index.d.ts +4 -0
  160. package/lib/typescript/src/skia/Picture/usePicture.d.ts +11 -0
  161. package/lib/typescript/src/skia/Skia.d.ts +5 -0
  162. package/lib/typescript/src/skia/index.d.ts +1 -0
  163. package/lib/typescript/src/views/SkiaView.d.ts +25 -1
  164. package/lib/typescript/src/views/types.d.ts +0 -24
  165. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  166. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  167. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  168. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  169. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  170. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  171. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  172. package/package.json +1 -1
  173. package/src/renderer/Canvas.tsx +14 -30
  174. package/src/renderer/HostConfig.ts +2 -20
  175. package/src/renderer/components/Drawing.tsx +16 -0
  176. package/src/renderer/components/Group.tsx +25 -15
  177. package/src/renderer/components/Paint.tsx +5 -35
  178. package/src/renderer/components/Picture.tsx +17 -0
  179. package/src/renderer/components/imageFilters/InnerShadow.tsx +33 -47
  180. package/src/renderer/components/imageFilters/Shadow.tsx +39 -0
  181. package/src/renderer/components/imageFilters/index.ts +1 -2
  182. package/src/renderer/components/index.ts +2 -1
  183. package/src/renderer/components/maskFilters/Blur.tsx +1 -1
  184. package/src/renderer/components/shapes/Box.tsx +98 -0
  185. package/src/renderer/components/shapes/index.ts +1 -0
  186. package/src/renderer/index.ts +1 -0
  187. package/src/renderer/nodes/Declaration.tsx +14 -0
  188. package/src/renderer/nodes/Drawing.tsx +16 -26
  189. package/src/renderer/nodes/Node.ts +9 -12
  190. package/src/renderer/processors/Paint.ts +34 -31
  191. package/src/renderer/processors/math/Math.ts +16 -0
  192. package/src/renderer/processors/math/Matrix3.ts +35 -31
  193. package/src/renderer/typeddash.ts +18 -0
  194. package/src/renderer/useContextBridge.tsx +21 -0
  195. package/src/skia/Canvas.ts +7 -0
  196. package/src/skia/Picture/Picture.ts +34 -0
  197. package/src/skia/Picture/PictureFactory.ts +9 -0
  198. package/src/skia/Picture/PictureRecorder.ts +18 -0
  199. package/src/skia/Picture/index.ts +4 -0
  200. package/src/skia/Picture/usePicture.ts +28 -0
  201. package/src/skia/Skia.ts +5 -0
  202. package/src/skia/index.ts +1 -0
  203. package/src/values/hooks/useDerivedValue.ts +1 -1
  204. package/src/views/SkiaView.tsx +27 -3
  205. package/src/views/types.ts +0 -25
  206. package/lib/commonjs/renderer/components/Defs.js.map +0 -1
  207. package/lib/commonjs/renderer/components/imageFilters/DropShadow.js.map +0 -1
  208. package/lib/module/renderer/components/Defs.js +0 -16
  209. package/lib/module/renderer/components/Defs.js.map +0 -1
  210. package/lib/module/renderer/components/imageFilters/DropShadow.js.map +0 -1
  211. package/lib/typescript/src/renderer/components/Defs.d.ts +0 -5
  212. package/src/renderer/components/Defs.tsx +0 -19
  213. package/src/renderer/components/imageFilters/DropShadow.tsx +0 -31
@@ -1,8 +1,8 @@
1
- import type { ReactNode } from "react";
2
- import React from "react";
1
+ import type { DependencyList, ReactNode } from "react";
2
+ import { useCallback } from "react";
3
3
 
4
4
  import type { DrawingContext } from "../DrawingContext";
5
- import { processPaint, selectPaint } from "../processors";
5
+ import { processPaint } from "../processors";
6
6
  import type { AnimatedProps } from "../processors/Animations/Animations";
7
7
  import { materialize } from "../processors/Animations/Animations";
8
8
  import { isPaint } from "../../skia";
@@ -21,16 +21,16 @@ type OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;
21
21
  export const createDrawing = <P,>(cb: OnDrawCallback<P>): DrawingCallback<P> =>
22
22
  cb;
23
23
 
24
+ export const useDrawing = <P,>(cb: OnDrawCallback<P>, deps?: DependencyList) =>
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ useCallback(cb, deps ?? []);
27
+
24
28
  export type DrawingProps<T> = {
25
29
  onDraw: DrawingCallback<T>;
26
30
  skipProcessing?: boolean;
27
31
  children?: ReactNode | ReactNode[];
28
32
  };
29
33
 
30
- export const Drawing = <P,>(props: DrawingProps<P>) => {
31
- return <skDrawing {...props} />;
32
- };
33
-
34
34
  export class DrawingNode<P> extends Node<P> {
35
35
  onDraw: DrawingCallback<P>;
36
36
  skipProcessing: boolean;
@@ -51,25 +51,15 @@ export class DrawingNode<P> extends Node<P> {
51
51
  if (this.skipProcessing) {
52
52
  this.onDraw(ctx, drawingProps, this);
53
53
  } else {
54
- const selectedPaint = selectPaint(ctx.paint, drawingProps);
55
- processPaint(selectedPaint, ctx.opacity, drawingProps);
56
- // to draw only once:
57
- // onDraw({ ...ctx, paint: selectedPaint }, children);
58
- [
59
- selectedPaint,
60
- ...this.children
61
- .map((child) => {
62
- //if (child.type === NodeType.Declaration) {
63
- const ret = child.draw(ctx);
64
- if (ret) {
65
- return ret;
66
- }
67
- //}
68
- return null;
69
- })
70
- .filter(isPaint),
71
- ].forEach((paint) => {
72
- this.onDraw({ ...ctx, paint }, drawingProps, this);
54
+ const declarations = this.visit(ctx);
55
+ const paint = processPaint(
56
+ ctx.paint.copy(),
57
+ ctx.opacity,
58
+ drawingProps,
59
+ declarations
60
+ );
61
+ [paint, ...declarations.filter(isPaint)].forEach((currentPaint) => {
62
+ this.onDraw({ ...ctx, paint: currentPaint }, drawingProps, this);
73
63
  });
74
64
  }
75
65
  }
@@ -1,4 +1,3 @@
1
- import { isPaint } from "../../skia";
2
1
  import type { SkJSIInstance } from "../../skia/JsiInstance";
3
2
  import type { DependencyManager } from "../DependencyManager";
4
3
  import type { DrawingContext } from "../DrawingContext";
@@ -15,7 +14,7 @@ export abstract class Node<P = unknown> {
15
14
  readonly children: Node[] = [];
16
15
  _props: AnimatedProps<P>;
17
16
  memoizable = false;
18
- memoized = false;
17
+ memoized: DeclarationResult | null = null;
19
18
  parent?: Node;
20
19
  depMgr: DependencyManager;
21
20
 
@@ -38,21 +37,19 @@ export abstract class Node<P = unknown> {
38
37
  return this._props;
39
38
  }
40
39
 
41
- visit(ctx: DrawingContext) {
40
+ visit(ctx: DrawingContext, children?: Node[]) {
42
41
  const returnedValues: Exclude<DeclarationResult, null>[] = [];
43
- let currentCtx = ctx;
44
- this.children.forEach((child) => {
42
+ (children ?? this.children).forEach((child) => {
45
43
  if (!child.memoized) {
46
- const ret = child.draw(currentCtx);
44
+ const ret = child.draw(ctx);
47
45
  if (ret) {
48
- if (isPaint(ret)) {
49
- currentCtx = { ...currentCtx, paint: ret };
50
- }
51
46
  returnedValues.push(ret);
47
+ if (child.memoizable) {
48
+ child.memoized = ret;
49
+ }
52
50
  }
53
- if (child.memoizable) {
54
- child.memoized = true;
55
- }
51
+ } else {
52
+ returnedValues.push(child.memoized);
56
53
  }
57
54
  });
58
55
  return returnedValues;
@@ -6,14 +6,22 @@ import {
6
6
  StrokeJoin,
7
7
  StrokeCap,
8
8
  processColor,
9
+ isShader,
10
+ isMaskFilter,
11
+ isColorFilter,
12
+ isPathEffect,
13
+ isImageFilter,
14
+ Skia,
9
15
  } from "../../skia";
10
- import type { SkPaint, Color } from "../../skia";
16
+ import type { SkPaint, Color, SkImageFilter } from "../../skia";
17
+ import type { DeclarationResult } from "../nodes";
11
18
  export type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
12
19
 
13
20
  export interface ChildrenProps {
14
21
  children?: ReactNode | ReactNode[];
15
22
  }
16
23
 
24
+ // TODO: rename to paint props?
17
25
  export interface CustomPaintProps extends ChildrenProps {
18
26
  paint?: RefObject<SkPaint>;
19
27
  color?: Color;
@@ -33,6 +41,7 @@ export const processPaint = (
33
41
  paint: SkPaint,
34
42
  currentOpacity: number,
35
43
  {
44
+ paint: paintRef,
36
45
  color,
37
46
  blendMode,
38
47
  style,
@@ -41,8 +50,12 @@ export const processPaint = (
41
50
  strokeCap,
42
51
  strokeMiter,
43
52
  opacity,
44
- }: CustomPaintProps
53
+ }: CustomPaintProps,
54
+ children: DeclarationResult[]
45
55
  ) => {
56
+ if (paintRef && paintRef.current) {
57
+ return paintRef.current;
58
+ }
46
59
  if (color !== undefined) {
47
60
  const c = processColor(color, currentOpacity);
48
61
  paint.setShader(null);
@@ -72,34 +85,24 @@ export const processPaint = (
72
85
  if (opacity !== undefined) {
73
86
  paint.setAlphaf(opacity);
74
87
  }
75
- };
76
-
77
- export const selectPaint = (
78
- currentPaint: SkPaint,
79
- {
80
- paint,
81
- color: cl,
82
- blendMode,
83
- style: paintStyle,
84
- strokeWidth,
85
- strokeJoin,
86
- strokeCap,
87
- strokeMiter,
88
- opacity,
89
- }: CustomPaintProps
90
- ) => {
91
- const hasCustomPaint =
92
- cl !== undefined ||
93
- blendMode !== undefined ||
94
- paintStyle !== undefined ||
95
- strokeWidth !== undefined ||
96
- strokeJoin !== undefined ||
97
- opacity !== undefined ||
98
- strokeCap !== undefined ||
99
- strokeMiter !== undefined;
100
- const parentPaint = paint?.current ?? currentPaint;
101
- if (hasCustomPaint) {
102
- return parentPaint.copy();
88
+ children.forEach((child) => {
89
+ if (isShader(child)) {
90
+ paint.setShader(child);
91
+ } else if (isMaskFilter(child)) {
92
+ paint.setMaskFilter(child);
93
+ } else if (isColorFilter(child)) {
94
+ paint.setColorFilter(child);
95
+ } else if (isPathEffect(child)) {
96
+ paint.setPathEffect(child);
97
+ }
98
+ });
99
+ const filters = children.filter(isImageFilter);
100
+ if (filters.length > 0) {
101
+ paint.setImageFilter(
102
+ filters
103
+ .reverse()
104
+ .reduce<SkImageFilter | null>(Skia.ImageFilter.MakeCompose, null)
105
+ );
103
106
  }
104
- return parentPaint;
107
+ return paint;
105
108
  };
@@ -1,2 +1,18 @@
1
+ /**
2
+ * Linear interpolation
3
+ * @param value
4
+ * @param x
5
+ * @param y
6
+ */
1
7
  export const mix = (value: number, x: number, y: number) =>
2
8
  x * (1 - value) + y * value;
9
+
10
+ /**
11
+ * @summary Clamps a node with a lower and upper bound.
12
+ * @example
13
+ clamp(-1, 0, 100); // 0
14
+ clamp(1, 0, 100); // 1
15
+ clamp(101, 0, 100); // 100
16
+ */
17
+ export const clamp = (value: number, lowerBound: number, upperBound: number) =>
18
+ Math.min(Math.max(lowerBound, value), upperBound);
@@ -102,6 +102,9 @@ const multiply3 = (m1: Matrix3, m2: Matrix3) => {
102
102
  ] as const;
103
103
  };
104
104
 
105
+ export const matrixVecMul3 = (m: Matrix3, v: Vec3) =>
106
+ [dot3(m[0], v), dot3(m[1], v), dot3(m[2], v)] as const;
107
+
105
108
  const skiaMatrix3 = (m: Matrix3): SkMatrix => {
106
109
  return [
107
110
  m[0][0],
@@ -117,34 +120,35 @@ const skiaMatrix3 = (m: Matrix3): SkMatrix => {
117
120
  };
118
121
 
119
122
  export const processTransform2d = (transforms: Transforms2d) =>
120
- skiaMatrix3(
121
- transforms.reduce((acc, transform) => {
122
- const key = Object.keys(transform)[0] as Transform2dName;
123
- const value = (transform as Pick<Transformations, typeof key>)[key];
124
- if (key === "translateX") {
125
- return multiply3(acc, translateXMatrix(value));
126
- }
127
- if (key === "translateY") {
128
- return multiply3(acc, translateYMatrix(value));
129
- }
130
- if (key === "scale") {
131
- return multiply3(acc, scaleMatrix(value));
132
- }
133
- if (key === "scaleX") {
134
- return multiply3(acc, scaleXMatrix(value));
135
- }
136
- if (key === "scaleY") {
137
- return multiply3(acc, scaleYMatrix(value));
138
- }
139
- if (key === "skewX") {
140
- return multiply3(acc, skewXMatrix(value));
141
- }
142
- if (key === "skewY") {
143
- return multiply3(acc, skewYMatrix(value));
144
- }
145
- if (key === "rotate" || key === "rotateZ") {
146
- return multiply3(acc, rotateZMatrix(value));
147
- }
148
- return exhaustiveCheck(key);
149
- }, identityMatrix)
150
- );
123
+ skiaMatrix3(processTransform(transforms));
124
+
125
+ const processTransform = (transforms: Transforms2d) =>
126
+ transforms.reduce((acc, transform) => {
127
+ const key = Object.keys(transform)[0] as Transform2dName;
128
+ const value = (transform as Pick<Transformations, typeof key>)[key];
129
+ if (key === "translateX") {
130
+ return multiply3(acc, translateXMatrix(value));
131
+ }
132
+ if (key === "translateY") {
133
+ return multiply3(acc, translateYMatrix(value));
134
+ }
135
+ if (key === "scale") {
136
+ return multiply3(acc, scaleMatrix(value));
137
+ }
138
+ if (key === "scaleX") {
139
+ return multiply3(acc, scaleXMatrix(value));
140
+ }
141
+ if (key === "scaleY") {
142
+ return multiply3(acc, scaleYMatrix(value));
143
+ }
144
+ if (key === "skewX") {
145
+ return multiply3(acc, skewXMatrix(value));
146
+ }
147
+ if (key === "skewY") {
148
+ return multiply3(acc, skewYMatrix(value));
149
+ }
150
+ if (key === "rotate" || key === "rotateZ") {
151
+ return multiply3(acc, rotateZMatrix(value));
152
+ }
153
+ return exhaustiveCheck(key);
154
+ }, identityMatrix);
@@ -3,3 +3,21 @@ export const mapKeys = <T>(obj: T) => Object.keys(obj) as (keyof T)[];
3
3
  export const exhaustiveCheck = (a: never): never => {
4
4
  throw new Error(`Unexhaustive handling for ${a}`);
5
5
  };
6
+
7
+ // Shallow eq on props (without children)
8
+ export const shallowEq = <P>(p1: P, p2: P): boolean => {
9
+ const keys1 = mapKeys(p1);
10
+ const keys2 = mapKeys(p2);
11
+ if (keys1.length !== keys2.length) {
12
+ return false;
13
+ }
14
+ for (const key of keys1) {
15
+ if (key === "children") {
16
+ continue;
17
+ }
18
+ if (p1[key] !== p2[key]) {
19
+ return false;
20
+ }
21
+ }
22
+ return true;
23
+ };
@@ -0,0 +1,21 @@
1
+ import React, { useMemo, useContext } from "react";
2
+ import type { ReactNode, Context, ReactElement } from "react";
3
+
4
+ // useContextBridge() is taken from https://github.com/pmndrs/drei#usecontextbridge
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ export const useContextBridge = (...contexts: Context<any>[]) => {
7
+ const values =
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ contexts.map((context) => useContext(context));
10
+ return useMemo(
11
+ () =>
12
+ ({ children }: { children: ReactNode }) =>
13
+ contexts.reduceRight(
14
+ (acc, Context, i) => (
15
+ <Context.Provider value={values[i]} children={acc} />
16
+ ),
17
+ children
18
+ ) as ReactElement,
19
+ [contexts, values]
20
+ );
21
+ };
@@ -12,6 +12,7 @@ import type { SkMatrix } from "./Matrix";
12
12
  import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
15
+ import type { SkPicture } from "./Picture";
15
16
 
16
17
  export enum ClipOp {
17
18
  Difference,
@@ -485,4 +486,10 @@ export interface SkCanvas {
485
486
  * @param m
486
487
  */
487
488
  concat(m: SkMatrix): void;
489
+
490
+ /**
491
+ * Draws the given picture using the current clip, current matrix, and the provided paint.
492
+ * @param skp
493
+ */
494
+ drawPicture(skp: SkPicture): void;
488
495
  }
@@ -0,0 +1,34 @@
1
+ import type { InputColorMatrix } from "../ColorFilter";
2
+ import type { FilterMode } from "../Image";
3
+ import type { TileMode } from "../ImageFilter";
4
+ import type { SkRect } from "../Rect";
5
+ import type { IShader } from "../Shader";
6
+
7
+ export interface SkPicture {
8
+ /**
9
+ * Returns a new shader that will draw with this picture.
10
+ *
11
+ * @param tmx The tiling mode to use when sampling in the x-direction.
12
+ * @param tmy The tiling mode to use when sampling in the y-direction.
13
+ * @param mode How to filter the tiles
14
+ * @param localMatrix Optional matrix used when sampling
15
+ * @param tileRect The tile rectangle in picture coordinates: this represents the subset
16
+ * (or superset) of the picture used when building a tile. It is not
17
+ * affected by localMatrix and does not imply scaling (only translation
18
+ * and cropping). If null, the tile rect is considered equal to the picture
19
+ * bounds.
20
+ */
21
+ makeShader(
22
+ tmx: TileMode,
23
+ tmy: TileMode,
24
+ mode: FilterMode,
25
+ localMatrix?: InputColorMatrix,
26
+ tileRect?: SkRect
27
+ ): IShader;
28
+
29
+ /**
30
+ * Returns the serialized format of this SkPicture. The format may change at anytime and
31
+ * no promises are made for backwards or forward compatibility.
32
+ */
33
+ serialize(): Uint8Array | null;
34
+ }
@@ -0,0 +1,9 @@
1
+ import type { SkPicture } from "./Picture";
2
+
3
+ export interface PictureFactory {
4
+ /**
5
+ * Returns an SkPicture which has been serialized previously to the given bytes.
6
+ * @param bytes
7
+ */
8
+ MakePicture(bytes: Uint8Array | ArrayBuffer): SkPicture | null;
9
+ }
@@ -0,0 +1,18 @@
1
+ import type { SkCanvas } from "../Canvas";
2
+ import type { SkRect } from "../Rect";
3
+
4
+ import type { SkPicture } from "./Picture";
5
+
6
+ export interface SkPictureRecorder {
7
+ /**
8
+ * Returns a canvas on which to draw. When done drawing, call finishRecordingAsPicture()
9
+ *
10
+ * @param bounds - a rect to cull the results.
11
+ */
12
+ beginRecording(bounds: SkRect): SkCanvas;
13
+
14
+ /**
15
+ * Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
16
+ */
17
+ finishRecordingAsPicture(): SkPicture;
18
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Picture";
2
+ export * from "./PictureRecorder";
3
+ export * from "./usePicture";
4
+ export * from "./PictureFactory";
@@ -0,0 +1,28 @@
1
+ import type { DependencyList } from "react";
2
+ import { useMemo } from "react";
3
+
4
+ import type { SkCanvas } from "../Canvas";
5
+ import type { SkRect } from "../Rect";
6
+ import { Skia } from "../Skia";
7
+
8
+ import type { SkPicture } from "./Picture";
9
+
10
+ /**
11
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
12
+ * @param rect Picture bounds
13
+ * @param cb Callback for drawing to the canvas
14
+ * @returns SkPicture
15
+ */
16
+ export const usePicture = (
17
+ rect: SkRect,
18
+ cb: (canvas: SkCanvas) => void,
19
+ deps: DependencyList = []
20
+ ): SkPicture => {
21
+ return useMemo(() => {
22
+ const recorder = Skia.PictureRecorder();
23
+ const canvas = recorder.beginRecording(rect);
24
+ cb(canvas);
25
+ return recorder.finishRecordingAsPicture();
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, [cb, rect, deps]);
28
+ };
package/src/skia/Skia.ts CHANGED
@@ -26,6 +26,7 @@ import "./NativeSetup";
26
26
  import type { SkRSXform } from "./RSXform";
27
27
  import type { SkPath } from "./Path/Path";
28
28
  import type { SkContourMeasureIter } from "./ContourMeasure";
29
+ import type { PictureFactory, SkPictureRecorder } from "./Picture";
29
30
 
30
31
  /**
31
32
  * Declares the interface for the native Skia API
@@ -41,6 +42,8 @@ export interface Skia {
41
42
  resScale: number
42
43
  ) => SkContourMeasureIter;
43
44
  Paint: () => SkPaint;
45
+ PictureRecorder: () => SkPictureRecorder;
46
+ Picture: PictureFactory;
44
47
  Path: PathFactory;
45
48
  Matrix: () => SkMatrix;
46
49
  ColorFilter: ColorFilterFactory;
@@ -106,6 +109,8 @@ export const Skia = {
106
109
  XYWHRect: SkiaApi.XYWHRect,
107
110
  RRectXY: SkiaApi.RRectXY,
108
111
  Paint: SkiaApi.Paint,
112
+ PictureRecorder: SkiaApi.PictureRecorder,
113
+ Picture: SkiaApi.Picture,
109
114
  Path: SkiaApi.Path,
110
115
  ColorFilter: SkiaApi.ColorFilter,
111
116
  ContourMeasureIter: SkiaApi.ContourMeasureIter,
package/src/skia/index.ts CHANGED
@@ -20,4 +20,5 @@ export * from "./Surface";
20
20
  export * from "./FontMgr";
21
21
  export * from "./Vertices";
22
22
  export * from "./Color";
23
+ export * from "./Picture";
23
24
  export * from "./Data";
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from "react";
2
2
 
3
3
  import { ValueApi } from "../api";
4
- import { isValue } from "../../renderer";
4
+ import { isValue } from "../../renderer/processors";
5
5
 
6
6
  /**
7
7
  * Creates a new derived value - a value that will calculate its value depending
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { ViewProps } from "react-native";
2
3
  import { requireNativeComponent } from "react-native";
3
4
 
4
5
  import type { SkImage, SkRect } from "../skia";
@@ -6,7 +7,6 @@ import type { SkiaReadonlyValue } from "../values";
6
7
 
7
8
  import type {
8
9
  DrawMode,
9
- SkiaViewProps,
10
10
  RNSkiaDrawCallback,
11
11
  NativeSkiaViewProps,
12
12
  } from "./types";
@@ -35,6 +35,30 @@ declare global {
35
35
 
36
36
  const { SkiaViewApi } = global;
37
37
 
38
+ export interface SkiaViewProps extends ViewProps {
39
+ /**
40
+ * Sets the drawing mode for the skia view. There are two drawing
41
+ * modes, "continuous" and "default", where the continuous mode will
42
+ * continuously redraw the view, and the default mode will only
43
+ * redraw when any of the regular react properties are changed like
44
+ * sizes and margins.
45
+ */
46
+ mode?: DrawMode;
47
+ /**
48
+ * When set to true the view will display information about the
49
+ * average time it takes to render.
50
+ */
51
+ debug?: boolean;
52
+ /**
53
+ * Draw callback. Will be called whenever the view is invalidated and
54
+ * needs to redraw. This is either caused by a change in a react
55
+ * property, a touch event, or a call to redraw. If the view is in
56
+ * continuous mode the callback will be called 60 frames per second
57
+ * by the native view.
58
+ */
59
+ onDraw?: RNSkiaDrawCallback;
60
+ }
61
+
38
62
  export class SkiaView extends React.Component<SkiaViewProps> {
39
63
  constructor(props: SkiaViewProps) {
40
64
  super(props);
@@ -103,14 +127,14 @@ export class SkiaView extends React.Component<SkiaViewProps> {
103
127
  }
104
128
 
105
129
  render() {
106
- const { style, mode, debug = false } = this.props;
130
+ const { mode, debug = false, ...viewProps } = this.props;
107
131
  return (
108
132
  <NativeSkiaView
109
- style={style}
110
133
  collapsable={false}
111
134
  nativeID={`${this._nativeId}`}
112
135
  mode={mode}
113
136
  debug={debug}
137
+ {...viewProps}
114
138
  />
115
139
  );
116
140
  }
@@ -47,31 +47,6 @@ export type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;
47
47
 
48
48
  export type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;
49
49
 
50
- export type SkiaViewProps = {
51
- style?: ViewProps["style"];
52
- /**
53
- * Sets the drawing mode for the skia view. There are two drawing
54
- * modes, "continuous" and "default", where the continuous mode will
55
- * continuously redraw the view, and the default mode will only
56
- * redraw when any of the regular react properties are changed like
57
- * sizes and margins.
58
- */
59
- mode?: DrawMode;
60
- /**
61
- * When set to true the view will display information about the
62
- * average time it takes to render.
63
- */
64
- debug?: boolean;
65
- /**
66
- * Draw callback. Will be called whenever the view is invalidated and
67
- * needs to redraw. This is either caused by a change in a react
68
- * property, a touch event, or a call to redraw. If the view is in
69
- * continuous mode the callback will be called 60 frames per second
70
- * by the native view.
71
- */
72
- onDraw?: RNSkiaDrawCallback;
73
- };
74
-
75
50
  /**
76
51
  * Listener interface for value changes
77
52
  */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Defs.tsx"],"names":["onDeclare","Defs","props"],"mappings":";;;;;;;AAAA;;AAGA;;;;;;AAMA,MAAMA,SAAS,GAAG,8BAAkB,MAAM;AACxC;AACA;AACA;AACA,SAAO,IAAP;AACD,CALiB,CAAlB;;AAOO,MAAMC,IAAI,GAAIC,KAAD,IAAsB;AACxC,sBAAO;AAAe,IAAA,SAAS,EAAEF;AAA1B,KAAyCE,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { createDeclaration } from \"../nodes\";\n\nexport interface DefsProps {\n children: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration(() => {\n // Do nothing.\n // The goal of this component is to avoid declared paint from\n // being used in the drawing context automatically\n return null;\n});\n\nexport const Defs = (props: DefsProps) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["DropShadow.tsx"],"names":["onDeclare","children","dx","dy","blur","color","shadowOnly","opacity","input","factory","Skia","ImageFilter","MakeDropShadowOnly","MakeDropShadow","DropShadow","props"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAGA;;AAEA;;;;;;AAUA,MAAMA,SAAS,GAAG,oCAChB,OAAsCC,QAAtC,YAAgE;AAAA,MAA/D;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,EAAN;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,KAAhB;AAAuBC,IAAAA;AAAvB,GAA+D;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,QAAMC,KAAK,GAAG,wBAASP,QAAT,CAAd;AACA,QAAMQ,OAAO,GAAGH,UAAU,GACtBI,WAAKC,WAAL,CAAiBC,kBADK,GAEtBF,WAAKC,WAAL,CAAiBE,cAFrB;AAGA,SAAOJ,OAAO,CAACP,EAAD,EAAKC,EAAL,EAASC,IAAT,EAAeA,IAAf,EAAqB,yBAAaC,KAAb,EAAoBE,OAApB,CAArB,EAAmDC,KAAnD,CAAd;AACD,CAPe,CAAlB;;AAUO,MAAMM,UAAU,GAAIC,KAAD,IAA2C;AACnE,sBAAO;AAAe,IAAA,SAAS,EAAEf;AAA1B,KAAyCe,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\nimport type { Color } from \"../../../skia/Color\";\nimport { processColor } from \"../../../skia/Color\";\n\nimport { getInput } from \"./getInput\";\n\nexport interface DropShadowProps {\n dx: number;\n dy: number;\n blur: number;\n color: Color;\n shadowOnly?: boolean;\n}\n\nconst onDeclare = createDeclaration<DropShadowProps>(\n ({ dx, dy, blur, color, shadowOnly }, children, { opacity }) => {\n const input = getInput(children);\n const factory = shadowOnly\n ? Skia.ImageFilter.MakeDropShadowOnly\n : Skia.ImageFilter.MakeDropShadow;\n return factory(dx, dy, blur, blur, processColor(color, opacity), input);\n }\n);\n\nexport const DropShadow = (props: AnimatedProps<DropShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -1,16 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from "react";
4
- import { createDeclaration } from "../nodes";
5
- const onDeclare = createDeclaration(() => {
6
- // Do nothing.
7
- // The goal of this component is to avoid declared paint from
8
- // being used in the drawing context automatically
9
- return null;
10
- });
11
- export const Defs = props => {
12
- return /*#__PURE__*/React.createElement("skDeclaration", _extends({
13
- onDeclare: onDeclare
14
- }, props));
15
- };
16
- //# sourceMappingURL=Defs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Defs.tsx"],"names":["React","createDeclaration","onDeclare","Defs","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,iBAAT,QAAkC,UAAlC;AAMA,MAAMC,SAAS,GAAGD,iBAAiB,CAAC,MAAM;AACxC;AACA;AACA;AACA,SAAO,IAAP;AACD,CALkC,CAAnC;AAOA,OAAO,MAAME,IAAI,GAAIC,KAAD,IAAsB;AACxC,sBAAO;AAAe,IAAA,SAAS,EAAEF;AAA1B,KAAyCE,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { createDeclaration } from \"../nodes\";\n\nexport interface DefsProps {\n children: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration(() => {\n // Do nothing.\n // The goal of this component is to avoid declared paint from\n // being used in the drawing context automatically\n return null;\n});\n\nexport const Defs = (props: DefsProps) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["DropShadow.tsx"],"names":["React","Skia","createDeclaration","processColor","getInput","onDeclare","children","dx","dy","blur","color","shadowOnly","opacity","input","factory","ImageFilter","MakeDropShadowOnly","MakeDropShadow","DropShadow","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAGA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,SAASC,QAAT,QAAyB,YAAzB;AAUA,MAAMC,SAAS,GAAGH,iBAAiB,CACjC,OAAsCI,QAAtC,YAAgE;AAAA,MAA/D;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,EAAN;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,KAAhB;AAAuBC,IAAAA;AAAvB,GAA+D;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC9D,QAAMC,KAAK,GAAGT,QAAQ,CAACE,QAAD,CAAtB;AACA,QAAMQ,OAAO,GAAGH,UAAU,GACtBV,IAAI,CAACc,WAAL,CAAiBC,kBADK,GAEtBf,IAAI,CAACc,WAAL,CAAiBE,cAFrB;AAGA,SAAOH,OAAO,CAACP,EAAD,EAAKC,EAAL,EAASC,IAAT,EAAeA,IAAf,EAAqBN,YAAY,CAACO,KAAD,EAAQE,OAAR,CAAjC,EAAmDC,KAAnD,CAAd;AACD,CAPgC,CAAnC;AAUA,OAAO,MAAMK,UAAU,GAAIC,KAAD,IAA2C;AACnE,sBAAO;AAAe,IAAA,SAAS,EAAEd;AAA1B,KAAyCc,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\nimport type { Color } from \"../../../skia/Color\";\nimport { processColor } from \"../../../skia/Color\";\n\nimport { getInput } from \"./getInput\";\n\nexport interface DropShadowProps {\n dx: number;\n dy: number;\n blur: number;\n color: Color;\n shadowOnly?: boolean;\n}\n\nconst onDeclare = createDeclaration<DropShadowProps>(\n ({ dx, dy, blur, color, shadowOnly }, children, { opacity }) => {\n const input = getInput(children);\n const factory = shadowOnly\n ? Skia.ImageFilter.MakeDropShadowOnly\n : Skia.ImageFilter.MakeDropShadow;\n return factory(dx, dy, blur, blur, processColor(color, opacity), input);\n }\n);\n\nexport const DropShadow = (props: AnimatedProps<DropShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -1,5 +0,0 @@
1
- import type { ReactNode } from "react";
2
- export interface DefsProps {
3
- children: ReactNode | ReactNode[];
4
- }
5
- export declare const Defs: (props: DefsProps) => JSX.Element;