@shopify/react-native-skia 0.1.116 → 0.1.118

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) 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/lib/commonjs/renderer/Canvas.js +22 -36
  7. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  8. package/lib/commonjs/renderer/HostConfig.js +2 -24
  9. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  10. package/lib/commonjs/renderer/components/Drawing.js +31 -0
  11. package/lib/commonjs/renderer/components/Drawing.js.map +1 -0
  12. package/lib/commonjs/renderer/components/Group.js +1 -1
  13. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  14. package/lib/commonjs/renderer/components/Picture.js +35 -0
  15. package/lib/commonjs/renderer/components/Picture.js.map +1 -0
  16. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +5 -34
  17. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  18. package/lib/commonjs/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +19 -8
  19. package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -0
  20. package/lib/commonjs/renderer/components/imageFilters/index.js +4 -17
  21. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  22. package/lib/commonjs/renderer/components/index.js +26 -0
  23. package/lib/commonjs/renderer/components/index.js.map +1 -1
  24. package/lib/commonjs/renderer/components/maskFilters/Blur.js +1 -1
  25. package/lib/commonjs/renderer/components/maskFilters/Blur.js.map +1 -1
  26. package/lib/commonjs/renderer/components/shapes/Box.js +126 -0
  27. package/lib/commonjs/renderer/components/shapes/Box.js.map +1 -0
  28. package/lib/commonjs/renderer/components/shapes/index.js +13 -0
  29. package/lib/commonjs/renderer/components/shapes/index.js.map +1 -1
  30. package/lib/commonjs/renderer/index.js +13 -0
  31. package/lib/commonjs/renderer/index.js.map +1 -1
  32. package/lib/commonjs/renderer/nodes/Declaration.js +8 -1
  33. package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
  34. package/lib/commonjs/renderer/nodes/Drawing.js +5 -8
  35. package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
  36. package/lib/commonjs/renderer/processors/math/Math.js +19 -1
  37. package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
  38. package/lib/commonjs/renderer/processors/math/Matrix3.js +11 -5
  39. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  40. package/lib/commonjs/renderer/typeddash.js +26 -2
  41. package/lib/commonjs/renderer/typeddash.js.map +1 -1
  42. package/lib/commonjs/renderer/useContextBridge.js +35 -0
  43. package/lib/commonjs/renderer/useContextBridge.js.map +1 -0
  44. package/lib/commonjs/skia/Canvas.js.map +1 -1
  45. package/lib/commonjs/skia/Picture/Picture.js +6 -0
  46. package/lib/commonjs/skia/Picture/Picture.js.map +1 -0
  47. package/lib/commonjs/skia/Picture/PictureFactory.js +6 -0
  48. package/lib/commonjs/skia/Picture/PictureFactory.js.map +1 -0
  49. package/lib/commonjs/skia/Picture/PictureRecorder.js +6 -0
  50. package/lib/commonjs/skia/Picture/PictureRecorder.js.map +1 -0
  51. package/lib/commonjs/skia/Picture/index.js +58 -0
  52. package/lib/commonjs/skia/Picture/index.js.map +1 -0
  53. package/lib/commonjs/skia/Picture/usePicture.js +30 -0
  54. package/lib/commonjs/skia/Picture/usePicture.js.map +1 -0
  55. package/lib/commonjs/skia/Skia.js +2 -0
  56. package/lib/commonjs/skia/Skia.js.map +1 -1
  57. package/lib/commonjs/skia/index.js +14 -0
  58. package/lib/commonjs/skia/index.js.map +1 -1
  59. package/lib/commonjs/values/hooks/useDerivedValue.js +2 -2
  60. package/lib/commonjs/values/hooks/useDerivedValue.js.map +1 -1
  61. package/lib/commonjs/views/SkiaView.js +6 -5
  62. package/lib/commonjs/views/SkiaView.js.map +1 -1
  63. package/lib/commonjs/views/types.js.map +1 -1
  64. package/lib/module/renderer/Canvas.js +20 -32
  65. package/lib/module/renderer/Canvas.js.map +1 -1
  66. package/lib/module/renderer/HostConfig.js +1 -23
  67. package/lib/module/renderer/HostConfig.js.map +1 -1
  68. package/lib/module/renderer/components/Drawing.js +17 -0
  69. package/lib/module/renderer/components/Drawing.js.map +1 -0
  70. package/lib/module/renderer/components/Group.js +1 -1
  71. package/lib/module/renderer/components/Group.js.map +1 -1
  72. package/lib/module/renderer/components/Picture.js +21 -0
  73. package/lib/module/renderer/components/Picture.js.map +1 -0
  74. package/lib/module/renderer/components/imageFilters/InnerShadow.js +4 -26
  75. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  76. package/lib/module/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +16 -6
  77. package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -0
  78. package/lib/module/renderer/components/imageFilters/index.js +1 -2
  79. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  80. package/lib/module/renderer/components/index.js +2 -0
  81. package/lib/module/renderer/components/index.js.map +1 -1
  82. package/lib/module/renderer/components/maskFilters/Blur.js +1 -1
  83. package/lib/module/renderer/components/maskFilters/Blur.js.map +1 -1
  84. package/lib/module/renderer/components/shapes/Box.js +102 -0
  85. package/lib/module/renderer/components/shapes/Box.js.map +1 -0
  86. package/lib/module/renderer/components/shapes/index.js +1 -0
  87. package/lib/module/renderer/components/shapes/index.js.map +1 -1
  88. package/lib/module/renderer/index.js +1 -0
  89. package/lib/module/renderer/index.js.map +1 -1
  90. package/lib/module/renderer/nodes/Declaration.js +3 -0
  91. package/lib/module/renderer/nodes/Declaration.js.map +1 -1
  92. package/lib/module/renderer/nodes/Drawing.js +3 -4
  93. package/lib/module/renderer/nodes/Drawing.js.map +1 -1
  94. package/lib/module/renderer/processors/math/Math.js +15 -0
  95. package/lib/module/renderer/processors/math/Math.js.map +1 -1
  96. package/lib/module/renderer/processors/math/Matrix3.js +6 -2
  97. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  98. package/lib/module/renderer/typeddash.js +21 -0
  99. package/lib/module/renderer/typeddash.js.map +1 -1
  100. package/lib/module/renderer/useContextBridge.js +21 -0
  101. package/lib/module/renderer/useContextBridge.js.map +1 -0
  102. package/lib/module/skia/Canvas.js.map +1 -1
  103. package/lib/module/skia/Picture/Picture.js +2 -0
  104. package/lib/module/skia/Picture/Picture.js.map +1 -0
  105. package/lib/module/skia/Picture/PictureFactory.js +2 -0
  106. package/lib/module/skia/Picture/PictureFactory.js.map +1 -0
  107. package/lib/module/skia/Picture/PictureRecorder.js +2 -0
  108. package/lib/module/skia/Picture/PictureRecorder.js.map +1 -0
  109. package/lib/module/skia/Picture/index.js +5 -0
  110. package/lib/module/skia/Picture/index.js.map +1 -0
  111. package/lib/module/skia/Picture/usePicture.js +19 -0
  112. package/lib/module/skia/Picture/usePicture.js.map +1 -0
  113. package/lib/module/skia/Skia.js +2 -0
  114. package/lib/module/skia/Skia.js.map +1 -1
  115. package/lib/module/skia/index.js +1 -0
  116. package/lib/module/skia/index.js.map +1 -1
  117. package/lib/module/values/hooks/useDerivedValue.js +1 -1
  118. package/lib/module/values/hooks/useDerivedValue.js.map +1 -1
  119. package/lib/module/views/SkiaView.js +6 -5
  120. package/lib/module/views/SkiaView.js.map +1 -1
  121. package/lib/module/views/types.js.map +1 -1
  122. package/lib/typescript/src/renderer/Canvas.d.ts +5 -10
  123. package/lib/typescript/src/renderer/components/Drawing.d.ts +7 -0
  124. package/lib/typescript/src/renderer/components/Picture.d.ts +6 -0
  125. package/lib/typescript/src/renderer/components/imageFilters/InnerShadow.d.ts +3 -12
  126. package/lib/typescript/src/renderer/components/imageFilters/{DropShadow.d.ts → Shadow.d.ts} +3 -2
  127. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -2
  128. package/lib/typescript/src/renderer/components/index.d.ts +2 -0
  129. package/lib/typescript/src/renderer/components/shapes/Box.d.ts +23 -0
  130. package/lib/typescript/src/renderer/components/shapes/index.d.ts +1 -0
  131. package/lib/typescript/src/renderer/index.d.ts +1 -0
  132. package/lib/typescript/src/renderer/nodes/Declaration.d.ts +2 -0
  133. package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
  134. package/lib/typescript/src/renderer/processors/math/Math.d.ts +14 -0
  135. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -0
  136. package/lib/typescript/src/renderer/typeddash.d.ts +1 -0
  137. package/lib/typescript/src/renderer/useContextBridge.d.ts +5 -0
  138. package/lib/typescript/src/skia/Canvas.d.ts +6 -0
  139. package/lib/typescript/src/skia/Picture/Picture.d.ts +26 -0
  140. package/lib/typescript/src/skia/Picture/PictureFactory.d.ts +8 -0
  141. package/lib/typescript/src/skia/Picture/PictureRecorder.d.ts +15 -0
  142. package/lib/typescript/src/skia/Picture/index.d.ts +4 -0
  143. package/lib/typescript/src/skia/Picture/usePicture.d.ts +11 -0
  144. package/lib/typescript/src/skia/Skia.d.ts +5 -0
  145. package/lib/typescript/src/skia/index.d.ts +1 -0
  146. package/lib/typescript/src/views/SkiaView.d.ts +25 -1
  147. package/lib/typescript/src/views/types.d.ts +0 -24
  148. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  149. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  150. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  151. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  152. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  153. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  154. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  155. package/package.json +1 -1
  156. package/src/renderer/Canvas.tsx +14 -30
  157. package/src/renderer/HostConfig.ts +1 -19
  158. package/src/renderer/components/Drawing.tsx +16 -0
  159. package/src/renderer/components/Group.tsx +1 -1
  160. package/src/renderer/components/Picture.tsx +17 -0
  161. package/src/renderer/components/imageFilters/InnerShadow.tsx +33 -47
  162. package/src/renderer/components/imageFilters/Shadow.tsx +39 -0
  163. package/src/renderer/components/imageFilters/index.ts +1 -2
  164. package/src/renderer/components/index.ts +2 -0
  165. package/src/renderer/components/maskFilters/Blur.tsx +1 -1
  166. package/src/renderer/components/shapes/Box.tsx +98 -0
  167. package/src/renderer/components/shapes/index.ts +1 -0
  168. package/src/renderer/index.ts +1 -0
  169. package/src/renderer/nodes/Declaration.tsx +10 -0
  170. package/src/renderer/nodes/Drawing.tsx +6 -6
  171. package/src/renderer/processors/math/Math.ts +16 -0
  172. package/src/renderer/processors/math/Matrix3.ts +35 -31
  173. package/src/renderer/typeddash.ts +18 -0
  174. package/src/renderer/useContextBridge.tsx +21 -0
  175. package/src/skia/Canvas.ts +7 -0
  176. package/src/skia/Picture/Picture.ts +34 -0
  177. package/src/skia/Picture/PictureFactory.ts +9 -0
  178. package/src/skia/Picture/PictureRecorder.ts +18 -0
  179. package/src/skia/Picture/index.ts +4 -0
  180. package/src/skia/Picture/usePicture.ts +28 -0
  181. package/src/skia/Skia.ts +5 -0
  182. package/src/skia/index.ts +1 -0
  183. package/src/values/hooks/useDerivedValue.ts +1 -1
  184. package/src/views/SkiaView.tsx +27 -3
  185. package/src/views/types.ts +0 -25
  186. package/lib/commonjs/renderer/components/imageFilters/DropShadow.js.map +0 -1
  187. package/lib/module/renderer/components/imageFilters/DropShadow.js.map +0 -1
  188. package/src/renderer/components/imageFilters/DropShadow.tsx +0 -31
@@ -0,0 +1,102 @@
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 { ClipOp, BlurStyle, Skia, processColor } from "../../../skia";
5
+ import { createDrawing } from "../../nodes";
6
+ import { add, vec, rrect } from "../../processors";
7
+ import { rect, isRRect } from "../../processors/Rects";
8
+ import { createDeclaration } from "../../nodes/Declaration";
9
+
10
+ const inflate = function (box, dx, dy) {
11
+ let tx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
12
+ let ty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
13
+ return rrect(rect(box.rect.x - dx + tx, box.rect.y - dy + ty, box.rect.width + 2 * dx, box.rect.height + 2 * dy), box.rx + dx, box.ry + dy);
14
+ };
15
+
16
+ const deflate = function (box, dx, dy) {
17
+ let tx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
18
+ let ty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
19
+ return inflate(box, -dx, -dy, tx, ty);
20
+ };
21
+
22
+ const onDeclare = createDeclaration(_ref => {
23
+ let {
24
+ dx,
25
+ dy,
26
+ spread,
27
+ blur,
28
+ color,
29
+ inner
30
+ } = _ref;
31
+ return {
32
+ dx,
33
+ dy,
34
+ spread,
35
+ blur,
36
+ color,
37
+ inner,
38
+ __typename__: "BoxShadow"
39
+ };
40
+ });
41
+ export const BoxShadow = props => {
42
+ return /*#__PURE__*/React.createElement("skDeclaration", _extends({
43
+ onDeclare: onDeclare
44
+ }, props));
45
+ };
46
+
47
+ const isBoxShadow = s => s.__typename__ === "BoxShadow";
48
+
49
+ const onDraw = createDrawing((ctx, _ref2, node) => {
50
+ let {
51
+ box: defaultBox
52
+ } = _ref2;
53
+ const box = isRRect(defaultBox) ? defaultBox : rrect(defaultBox, 0, 0);
54
+ const {
55
+ canvas,
56
+ paint,
57
+ opacity
58
+ } = ctx;
59
+ const shadows = node.visit(ctx).filter(isBoxShadow);
60
+ shadows.filter(shadow => !shadow.inner).map(shadow => {
61
+ const {
62
+ color = "black",
63
+ blur,
64
+ spread = 0,
65
+ dx = 0,
66
+ dy = 0
67
+ } = shadow;
68
+ const lPaint = Skia.Paint();
69
+ lPaint.setColor(processColor(color, opacity));
70
+ lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
71
+ canvas.drawRRect(inflate(box, spread, spread, dx, dy), lPaint);
72
+ });
73
+ canvas.drawRRect(box, paint);
74
+ shadows.filter(shadow => shadow.inner).map(shadow => {
75
+ const {
76
+ color = "black",
77
+ blur,
78
+ spread = 0,
79
+ dx = 0,
80
+ dy = 0
81
+ } = shadow;
82
+ const delta = add(vec(10, 10), vec(Math.abs(dx), Math.abs(dy)));
83
+ canvas.save();
84
+ canvas.clipRRect(box, ClipOp.Intersect, false);
85
+ const lPaint = Skia.Paint();
86
+ lPaint.setColor(processColor(color, opacity));
87
+ lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
88
+ const inner = deflate(box, spread, spread, dx, dy);
89
+ const outer = inflate(box, delta.x, delta.y);
90
+ canvas.drawDRRect(outer, inner, lPaint);
91
+ canvas.restore();
92
+ });
93
+ });
94
+ export const Box = props => {
95
+ return /*#__PURE__*/React.createElement("skDrawing", _extends({
96
+ onDraw: onDraw
97
+ }, props));
98
+ };
99
+ Box.defaultProps = {
100
+ shadows: []
101
+ };
102
+ //# sourceMappingURL=Box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Box.tsx"],"names":["React","ClipOp","BlurStyle","Skia","processColor","createDrawing","add","vec","rrect","rect","isRRect","createDeclaration","inflate","box","dx","dy","tx","ty","x","y","width","height","rx","ry","deflate","onDeclare","spread","blur","color","inner","__typename__","BoxShadow","props","isBoxShadow","s","onDraw","ctx","node","defaultBox","canvas","paint","opacity","shadows","visit","filter","shadow","map","lPaint","Paint","setColor","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore","Box","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,MAAT,EA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lD,SAAS,CAACmD,MAAnC,EAA2C1B,IAA3C,EAAiD,IAAjD,CADF;AAGA,UAAME,KAAK,GAAGL,OAAO,CAACX,GAAD,EAAMa,MAAN,EAAcA,MAAd,EAAsBZ,EAAtB,EAA0BC,EAA1B,CAArB;AACA,UAAM8C,KAAK,GAAGjD,OAAO,CAACC,GAAD,EAAM0C,KAAK,CAACrC,CAAZ,EAAeqC,KAAK,CAACpC,CAArB,CAArB;AACAoB,IAAAA,MAAM,CAACuB,UAAP,CAAkBD,KAAlB,EAAyBhC,KAAzB,EAAgCkB,MAAhC;AACAR,IAAAA,MAAM,CAACwB,OAAP;AACD,GAhBH;AAiBD,CAlC2B,CAA5B;AAoCA,OAAO,MAAMC,GAAG,GAAIhC,KAAD,IAAoC;AACrD,sBAAO;AAAW,IAAA,MAAM,EAAEG;AAAnB,KAA+BH,KAA/B,EAAP;AACD,CAFM;AAIPgC,GAAG,CAACC,YAAJ,GAAmB;AACjBvB,EAAAA,OAAO,EAAE;AADQ,CAAnB","sourcesContent":["import React from \"react\";\n\nimport type { Color, SkRRect } from \"../../../skia\";\nimport { ClipOp, BlurStyle, Skia, processColor } from \"../../../skia\";\nimport { createDrawing } from \"../../nodes\";\nimport type { AnimatedProps, CustomPaintProps } from \"../../processors\";\nimport { add, vec, rrect } from \"../../processors\";\nimport { rect, isRRect } from \"../../processors/Rects\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { SkJSIInstance } from \"../../../skia/JsiInstance\";\nimport type { SkRect } from \"../../../skia/Rect\";\n\nconst inflate = (box: SkRRect, dx: number, dy: number, tx = 0, ty = 0) =>\n rrect(\n rect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (box: SkRRect, dx: number, dy: number, tx = 0, ty = 0) =>\n inflate(box, -dx, -dy, tx, ty);\n\ninterface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n\ninterface BoxShadowDecl extends BoxShadowProps, SkJSIInstance<\"BoxShadow\"> {}\n\nconst onDeclare = createDeclaration<BoxShadowProps>(\n ({ dx, dy, spread, blur, color, inner }) => {\n return { dx, dy, spread, blur, color, inner, __typename__: \"BoxShadow\" };\n }\n);\n\nexport const BoxShadow = (props: AnimatedProps<BoxShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nconst isBoxShadow = (s: SkJSIInstance<string>): s is BoxShadowDecl =>\n s.__typename__ === \"BoxShadow\";\n\ninterface BoxProps extends CustomPaintProps {\n box: SkRRect | SkRect;\n}\n\nconst onDraw = createDrawing<BoxProps>((ctx, { box: defaultBox }, node) => {\n const box = isRRect(defaultBox) ? defaultBox : rrect(defaultBox, 0, 0);\n const { canvas, paint, opacity } = ctx;\n const shadows = node.visit(ctx).filter<BoxShadowDecl>(isBoxShadow);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(color, opacity));\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(inflate(box, spread, spread, dx, dy), lPaint);\n });\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = add(vec(10, 10), vec(Math.abs(dx), Math.abs(dy)));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(color, opacity));\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(box, spread, spread, dx, dy);\n const outer = inflate(box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n});\n\nexport const Box = (props: AnimatedProps<BoxProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nBox.defaultProps = {\n shadows: [],\n};\n"]}
@@ -10,4 +10,5 @@ export * from "./Patch";
10
10
  export * from "./Vertices";
11
11
  export * from "./Fill";
12
12
  export * from "./FitBox";
13
+ export * from "./Box";
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,QAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd","sourcesContent":["export * from \"./Circle\";\nexport * from \"./Rect\";\nexport * from \"./RoundedRect\";\nexport * from \"./DiffRect\";\nexport * from \"./Line\";\nexport * from \"./Path\";\nexport * from \"./Oval\";\nexport * from \"./Points\";\nexport * from \"./Patch\";\nexport * from \"./Vertices\";\nexport * from \"./Fill\";\nexport * from \"./FitBox\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,QAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,OAAd","sourcesContent":["export * from \"./Circle\";\nexport * from \"./Rect\";\nexport * from \"./RoundedRect\";\nexport * from \"./DiffRect\";\nexport * from \"./Line\";\nexport * from \"./Path\";\nexport * from \"./Oval\";\nexport * from \"./Points\";\nexport * from \"./Patch\";\nexport * from \"./Vertices\";\nexport * from \"./Fill\";\nexport * from \"./FitBox\";\nexport * from \"./Box\";\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from "./Canvas";
2
2
  export * from "./components";
3
3
  export * from "./nodes";
4
+ export * from "./useContextBridge";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd","sourcesContent":["export * from \"./Canvas\";\nexport * from \"./components\";\nexport * from \"./nodes\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd;AACA,cAAc,oBAAd","sourcesContent":["export * from \"./Canvas\";\nexport * from \"./components\";\nexport * from \"./nodes\";\nexport * from \"./useContextBridge\";\n"]}
@@ -1,8 +1,11 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
+ import { useCallback } from "react";
3
4
  import { isAnimated, materialize } from "../processors";
4
5
  import { Node } from "./Node";
5
6
  export const createDeclaration = cb => cb;
7
+ export const useDeclaration = (cb, deps) => // eslint-disable-next-line react-hooks/exhaustive-deps
8
+ useCallback(cb, deps !== null && deps !== void 0 ? deps : []);
6
9
  export class DeclarationNode extends Node {
7
10
  constructor(depMgr, onDeclare, props) {
8
11
  super(depMgr, props);
@@ -1 +1 @@
1
- {"version":3,"sources":["Declaration.tsx"],"names":["isAnimated","materialize","Node","createDeclaration","cb","DeclarationNode","constructor","depMgr","onDeclare","props","memoizable","_props","draw","ctx","children","visit","obj"],"mappings":";;AAGA,SAASA,UAAT,EAAqBC,WAArB,QAAwC,eAAxC;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,iBAAiB,GAC5BC,EAD+B,IAEJA,EAFtB;AAQP,OAAO,MAAMC,eAAN,SAAiCH,IAAjC,CAAyC;AAG9CI,EAAAA,WAAW,CACTC,MADS,EAETC,SAFS,EAGTC,KAHS,EAIT;AACA,UAAMF,MAAN,EAAcE,KAAd;;AADA;;AAEA,UAAMC,UAAN,GAAmB,CAACV,UAAU,CAACS,KAAD,CAA9B;AACA,SAAKD,SAAL,GAAiBA,SAAjB;AACD;;AAEQ,MAALC,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKC,UAAL,GAAkB,CAACV,UAAU,CAACS,KAAD,CAA7B;AACA,UAAMA,KAAN,GAAcA,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKE,MAAZ;AACD;;AAEDC,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,QAAQ,GAAG,KAAKC,KAAL,CAAWF,GAAX,CAAjB;AACA,UAAMJ,KAAK,GAAGR,WAAW,CAAC,KAAKQ,KAAN,CAAzB;AACA,UAAMO,GAAG,GAAG,KAAKR,SAAL,CAAeC,KAAf,EAAsBK,QAAtB,EAAgCD,GAAhC,CAAZ;AACA,WAAOG,GAAP;AACD;;AA3B6C","sourcesContent":["import type { DrawingContext } from \"../DrawingContext\";\nimport type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { AnimatedProps } from \"../processors\";\nimport { isAnimated, materialize } from \"../processors\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\nexport type DeclarationResult = SkJSIInstance<string> | null;\n\ntype DeclarationCallback<T> = (\n props: T,\n children: DeclarationResult[],\n ctx: DrawingContext\n) => DeclarationResult;\n\nexport const createDeclaration = <T,>(\n cb: DeclarationCallback<T>\n): DeclarationCallback<T> => cb;\n\nexport interface DeclarationProps<P> {\n onDeclare: DeclarationCallback<P>;\n}\n\nexport class DeclarationNode<P> extends Node<P> {\n private onDeclare: DeclarationCallback<P>;\n\n constructor(\n depMgr: DependencyManager,\n onDeclare: DeclarationCallback<P>,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n super.memoizable = !isAnimated(props);\n this.onDeclare = onDeclare;\n }\n\n set props(props: AnimatedProps<P>) {\n this.memoizable = !isAnimated(props);\n super.props = props;\n }\n\n get props() {\n return this._props;\n }\n\n draw(ctx: DrawingContext) {\n const children = this.visit(ctx);\n const props = materialize(this.props);\n const obj = this.onDeclare(props, children, ctx);\n return obj;\n }\n}\n"]}
1
+ {"version":3,"sources":["Declaration.tsx"],"names":["useCallback","isAnimated","materialize","Node","createDeclaration","cb","useDeclaration","deps","DeclarationNode","constructor","depMgr","onDeclare","props","memoizable","_props","draw","ctx","children","visit","obj"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAKA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,eAAxC;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,iBAAiB,GAC5BC,EAD+B,IAEJA,EAFtB;AAIP,OAAO,MAAMC,cAAc,GAAG,CAC5BD,EAD4B,EAE5BE,IAF4B,KAI5B;AACAP,WAAW,CAACK,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CALN;AAWP,OAAO,MAAMC,eAAN,SAAiCL,IAAjC,CAAyC;AAG9CM,EAAAA,WAAW,CACTC,MADS,EAETC,SAFS,EAGTC,KAHS,EAIT;AACA,UAAMF,MAAN,EAAcE,KAAd;;AADA;;AAEA,UAAMC,UAAN,GAAmB,CAACZ,UAAU,CAACW,KAAD,CAA9B;AACA,SAAKD,SAAL,GAAiBA,SAAjB;AACD;;AAEQ,MAALC,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKC,UAAL,GAAkB,CAACZ,UAAU,CAACW,KAAD,CAA7B;AACA,UAAMA,KAAN,GAAcA,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKE,MAAZ;AACD;;AAEDC,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,QAAQ,GAAG,KAAKC,KAAL,CAAWF,GAAX,CAAjB;AACA,UAAMJ,KAAK,GAAGV,WAAW,CAAC,KAAKU,KAAN,CAAzB;AACA,UAAMO,GAAG,GAAG,KAAKR,SAAL,CAAeC,KAAf,EAAsBK,QAAtB,EAAgCD,GAAhC,CAAZ;AACA,WAAOG,GAAP;AACD;;AA3B6C","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { AnimatedProps } from \"../processors\";\nimport { isAnimated, materialize } from \"../processors\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\nexport type DeclarationResult = SkJSIInstance<string> | null;\n\ntype DeclarationCallback<T> = (\n props: T,\n children: DeclarationResult[],\n ctx: DrawingContext\n) => DeclarationResult;\n\nexport const createDeclaration = <T,>(\n cb: DeclarationCallback<T>\n): DeclarationCallback<T> => cb;\n\nexport const useDeclaration = <P,>(\n cb: DeclarationCallback<P>,\n deps?: DependencyList\n) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport interface DeclarationProps<P> {\n onDeclare: DeclarationCallback<P>;\n}\n\nexport class DeclarationNode<P> extends Node<P> {\n private onDeclare: DeclarationCallback<P>;\n\n constructor(\n depMgr: DependencyManager,\n onDeclare: DeclarationCallback<P>,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n super.memoizable = !isAnimated(props);\n this.onDeclare = onDeclare;\n }\n\n set props(props: AnimatedProps<P>) {\n this.memoizable = !isAnimated(props);\n super.props = props;\n }\n\n get props() {\n return this._props;\n }\n\n draw(ctx: DrawingContext) {\n const children = this.visit(ctx);\n const props = materialize(this.props);\n const obj = this.onDeclare(props, children, ctx);\n return obj;\n }\n}\n"]}
@@ -1,14 +1,13 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import React from "react";
3
+ import { useCallback } from "react";
4
4
  import { processPaint, selectPaint } from "../processors";
5
5
  import { materialize } from "../processors/Animations/Animations";
6
6
  import { isPaint } from "../../skia";
7
7
  import { Node } from "./Node";
8
8
  export const createDrawing = cb => cb;
9
- export const Drawing = props => {
10
- return /*#__PURE__*/React.createElement("skDrawing", props);
11
- };
9
+ export const useDrawing = (cb, deps) => // eslint-disable-next-line react-hooks/exhaustive-deps
10
+ useCallback(cb, deps !== null && deps !== void 0 ? deps : []);
12
11
  export class DrawingNode extends Node {
13
12
  constructor(depMgr, onDraw, skipProcessing, props) {
14
13
  super(depMgr, props);
@@ -1 +1 @@
1
- {"version":3,"sources":["Drawing.tsx"],"names":["React","processPaint","selectPaint","materialize","isPaint","Node","createDrawing","cb","Drawing","props","DrawingNode","constructor","depMgr","onDraw","skipProcessing","draw","ctx","drawingProps","selectedPaint","paint","opacity","children","map","child","ret","filter","forEach"],"mappings":";;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,YAAT,EAAuBC,WAAvB,QAA0C,eAA1C;AAEA,SAASC,WAAT,QAA4B,qCAA5B;AACA,SAASC,OAAT,QAAwB,YAAxB;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,aAAa,GAAQC,EAAL,IAC3BA,EADK;AASP,OAAO,MAAMC,OAAO,GAAQC,KAAL,IAAgC;AACrD,sBAAO,iCAAeA,KAAf,CAAP;AACD,CAFM;AAIP,OAAO,MAAMC,WAAN,SAA6BL,IAA7B,CAAqC;AAI1CM,EAAAA,WAAW,CACTC,MADS,EAETC,MAFS,EAGTC,cAHS,EAITL,KAJS,EAKT;AACA,UAAMG,MAAN,EAAcH,KAAd;;AADA;;AAAA;;AAEA,SAAKI,MAAL,GAAcA,MAAd;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACD;;AAEDC,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,YAAY,GAAGd,WAAW,CAAC,KAAKM,KAAN,CAAhC;;AACA,QAAI,KAAKK,cAAT,EAAyB;AACvB,WAAKD,MAAL,CAAYG,GAAZ,EAAiBC,YAAjB,EAA+B,IAA/B;AACD,KAFD,MAEO;AACL,YAAMC,aAAa,GAAGhB,WAAW,CAACc,GAAG,CAACG,KAAL,EAAYF,YAAZ,CAAjC;AACAhB,MAAAA,YAAY,CAACiB,aAAD,EAAgBF,GAAG,CAACI,OAApB,EAA6BH,YAA7B,CAAZ,CAFK,CAGL;AACA;;AACA,OACEC,aADF,EAEE,GAAG,KAAKG,QAAL,CACAC,GADA,CACKC,KAAD,IAAW;AACd;AACA,cAAMC,GAAG,GAAGD,KAAK,CAACR,IAAN,CAAWC,GAAX,CAAZ;;AACA,YAAIQ,GAAJ,EAAS;AACP,iBAAOA,GAAP;AACD,SALa,CAMd;;;AACA,eAAO,IAAP;AACD,OATA,EAUAC,MAVA,CAUOrB,OAVP,CAFL,EAaEsB,OAbF,CAaWP,KAAD,IAAW;AACnB,aAAKN,MAAL,CAAY,EAAE,GAAGG,GAAL;AAAUG,UAAAA;AAAV,SAAZ,EAA+BF,YAA/B,EAA6C,IAA7C;AACD,OAfD;AAgBD;AACF;;AAzCyC","sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport { processPaint, selectPaint } from \"../processors\";\nimport type { AnimatedProps } from \"../processors/Animations/Animations\";\nimport { materialize } from \"../processors/Animations/Animations\";\nimport { isPaint } from \"../../skia\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\ntype DrawingCallback<P> = (\n ctx: DrawingContext,\n props: P,\n node: Node<P>\n) => void;\n\ntype OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;\n\nexport const createDrawing = <P,>(cb: OnDrawCallback<P>): DrawingCallback<P> =>\n cb;\n\nexport type DrawingProps<T> = {\n onDraw: DrawingCallback<T>;\n skipProcessing?: boolean;\n children?: ReactNode | ReactNode[];\n};\n\nexport const Drawing = <P,>(props: DrawingProps<P>) => {\n return <skDrawing {...props} />;\n};\n\nexport class DrawingNode<P> extends Node<P> {\n onDraw: DrawingCallback<P>;\n skipProcessing: boolean;\n\n constructor(\n depMgr: DependencyManager,\n onDraw: DrawingCallback<P>,\n skipProcessing: boolean,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n this.onDraw = onDraw;\n this.skipProcessing = skipProcessing;\n }\n\n draw(ctx: DrawingContext) {\n const drawingProps = materialize(this.props);\n if (this.skipProcessing) {\n this.onDraw(ctx, drawingProps, this);\n } else {\n const selectedPaint = selectPaint(ctx.paint, drawingProps);\n processPaint(selectedPaint, ctx.opacity, drawingProps);\n // to draw only once:\n // onDraw({ ...ctx, paint: selectedPaint }, children);\n [\n selectedPaint,\n ...this.children\n .map((child) => {\n //if (child.type === NodeType.Declaration) {\n const ret = child.draw(ctx);\n if (ret) {\n return ret;\n }\n //}\n return null;\n })\n .filter(isPaint),\n ].forEach((paint) => {\n this.onDraw({ ...ctx, paint }, drawingProps, this);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["Drawing.tsx"],"names":["useCallback","processPaint","selectPaint","materialize","isPaint","Node","createDrawing","cb","useDrawing","deps","DrawingNode","constructor","depMgr","onDraw","skipProcessing","props","draw","ctx","drawingProps","selectedPaint","paint","opacity","children","map","child","ret","filter","forEach"],"mappings":";;AACA,SAASA,WAAT,QAA4B,OAA5B;AAGA,SAASC,YAAT,EAAuBC,WAAvB,QAA0C,eAA1C;AAEA,SAASC,WAAT,QAA4B,qCAA5B;AACA,SAASC,OAAT,QAAwB,YAAxB;AAGA,SAASC,IAAT,QAAqB,QAArB;AAUA,OAAO,MAAMC,aAAa,GAAQC,EAAL,IAC3BA,EADK;AAGP,OAAO,MAAMC,UAAU,GAAG,CAAKD,EAAL,EAA4BE,IAA5B,KACxB;AACAT,WAAW,CAACO,EAAD,EAAKE,IAAL,aAAKA,IAAL,cAAKA,IAAL,GAAa,EAAb,CAFN;AAUP,OAAO,MAAMC,WAAN,SAA6BL,IAA7B,CAAqC;AAI1CM,EAAAA,WAAW,CACTC,MADS,EAETC,MAFS,EAGTC,cAHS,EAITC,KAJS,EAKT;AACA,UAAMH,MAAN,EAAcG,KAAd;;AADA;;AAAA;;AAEA,SAAKF,MAAL,GAAcA,MAAd;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACD;;AAEDE,EAAAA,IAAI,CAACC,GAAD,EAAsB;AACxB,UAAMC,YAAY,GAAGf,WAAW,CAAC,KAAKY,KAAN,CAAhC;;AACA,QAAI,KAAKD,cAAT,EAAyB;AACvB,WAAKD,MAAL,CAAYI,GAAZ,EAAiBC,YAAjB,EAA+B,IAA/B;AACD,KAFD,MAEO;AACL,YAAMC,aAAa,GAAGjB,WAAW,CAACe,GAAG,CAACG,KAAL,EAAYF,YAAZ,CAAjC;AACAjB,MAAAA,YAAY,CAACkB,aAAD,EAAgBF,GAAG,CAACI,OAApB,EAA6BH,YAA7B,CAAZ,CAFK,CAGL;AACA;;AACA,OACEC,aADF,EAEE,GAAG,KAAKG,QAAL,CACAC,GADA,CACKC,KAAD,IAAW;AACd;AACA,cAAMC,GAAG,GAAGD,KAAK,CAACR,IAAN,CAAWC,GAAX,CAAZ;;AACA,YAAIQ,GAAJ,EAAS;AACP,iBAAOA,GAAP;AACD,SALa,CAMd;;;AACA,eAAO,IAAP;AACD,OATA,EAUAC,MAVA,CAUOtB,OAVP,CAFL,EAaEuB,OAbF,CAaWP,KAAD,IAAW;AACnB,aAAKP,MAAL,CAAY,EAAE,GAAGI,GAAL;AAAUG,UAAAA;AAAV,SAAZ,EAA+BF,YAA/B,EAA6C,IAA7C;AACD,OAfD;AAgBD;AACF;;AAzCyC","sourcesContent":["import type { DependencyList, ReactNode } from \"react\";\nimport { useCallback } from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport { processPaint, selectPaint } from \"../processors\";\nimport type { AnimatedProps } from \"../processors/Animations/Animations\";\nimport { materialize } from \"../processors/Animations/Animations\";\nimport { isPaint } from \"../../skia\";\nimport type { DependencyManager } from \"../DependencyManager\";\n\nimport { Node } from \"./Node\";\n\ntype DrawingCallback<P> = (\n ctx: DrawingContext,\n props: P,\n node: Node<P>\n) => void;\n\ntype OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;\n\nexport const createDrawing = <P,>(cb: OnDrawCallback<P>): DrawingCallback<P> =>\n cb;\n\nexport const useDrawing = <P,>(cb: OnDrawCallback<P>, deps?: DependencyList) =>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useCallback(cb, deps ?? []);\n\nexport type DrawingProps<T> = {\n onDraw: DrawingCallback<T>;\n skipProcessing?: boolean;\n children?: ReactNode | ReactNode[];\n};\n\nexport class DrawingNode<P> extends Node<P> {\n onDraw: DrawingCallback<P>;\n skipProcessing: boolean;\n\n constructor(\n depMgr: DependencyManager,\n onDraw: DrawingCallback<P>,\n skipProcessing: boolean,\n props: AnimatedProps<P>\n ) {\n super(depMgr, props);\n this.onDraw = onDraw;\n this.skipProcessing = skipProcessing;\n }\n\n draw(ctx: DrawingContext) {\n const drawingProps = materialize(this.props);\n if (this.skipProcessing) {\n this.onDraw(ctx, drawingProps, this);\n } else {\n const selectedPaint = selectPaint(ctx.paint, drawingProps);\n processPaint(selectedPaint, ctx.opacity, drawingProps);\n // to draw only once:\n // onDraw({ ...ctx, paint: selectedPaint }, children);\n [\n selectedPaint,\n ...this.children\n .map((child) => {\n //if (child.type === NodeType.Declaration) {\n const ret = child.draw(ctx);\n if (ret) {\n return ret;\n }\n //}\n return null;\n })\n .filter(isPaint),\n ].forEach((paint) => {\n this.onDraw({ ...ctx, paint }, drawingProps, this);\n });\n }\n }\n}\n"]}
@@ -1,2 +1,17 @@
1
+ /**
2
+ * Linear interpolation
3
+ * @param value
4
+ * @param x
5
+ * @param y
6
+ */
1
7
  export const mix = (value, x, y) => x * (1 - value) + y * value;
8
+ /**
9
+ * @summary Clamps a node with a lower and upper bound.
10
+ * @example
11
+ clamp(-1, 0, 100); // 0
12
+ clamp(1, 0, 100); // 1
13
+ clamp(101, 0, 100); // 100
14
+ */
15
+
16
+ export const clamp = (value, lowerBound, upperBound) => Math.min(Math.max(lowerBound, value), upperBound);
2
17
  //# sourceMappingURL=Math.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Math.ts"],"names":["mix","value","x","y"],"mappings":"AAAA,OAAO,MAAMA,GAAG,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,CAA3B,KACjBD,CAAC,IAAI,IAAID,KAAR,CAAD,GAAkBE,CAAC,GAAGF,KADjB","sourcesContent":["export const mix = (value: number, x: number, y: number) =>\n x * (1 - value) + y * value;\n"]}
1
+ {"version":3,"sources":["Math.ts"],"names":["mix","value","x","y","clamp","lowerBound","upperBound","Math","min","max"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,GAAG,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,CAA3B,KACjBD,CAAC,IAAI,IAAID,KAAR,CAAD,GAAkBE,CAAC,GAAGF,KADjB;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,KAAK,GAAG,CAACH,KAAD,EAAgBI,UAAhB,EAAoCC,UAApC,KACnBC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASJ,UAAT,EAAqBJ,KAArB,CAAT,EAAsCK,UAAtC,CADK","sourcesContent":["/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n */\nexport const mix = (value: number, x: number, y: number) =>\n x * (1 - value) + y * value;\n\n/**\n * @summary Clamps a node with a lower and upper bound.\n * @example\n clamp(-1, 0, 100); // 0\n clamp(1, 0, 100); // 1\n clamp(101, 0, 100); // 100\n */\nexport const clamp = (value: number, lowerBound: number, upperBound: number) =>\n Math.min(Math.max(lowerBound, value), upperBound);\n"]}
@@ -26,11 +26,15 @@ const multiply3 = (m1, m2) => {
26
26
  return [[dot3(m1[0], col0), dot3(m1[0], col1), dot3(m1[0], col2)], [dot3(m1[1], col0), dot3(m1[1], col1), dot3(m1[1], col2)], [dot3(m1[2], col0), dot3(m1[2], col1), dot3(m1[2], col2)]];
27
27
  };
28
28
 
29
+ export const matrixVecMul3 = (m, v) => [dot3(m[0], v), dot3(m[1], v), dot3(m[2], v)];
30
+
29
31
  const skiaMatrix3 = m => {
30
32
  return [m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]];
31
33
  };
32
34
 
33
- export const processTransform2d = transforms => skiaMatrix3(transforms.reduce((acc, transform) => {
35
+ export const processTransform2d = transforms => skiaMatrix3(processTransform(transforms));
36
+
37
+ const processTransform = transforms => transforms.reduce((acc, transform) => {
34
38
  const key = Object.keys(transform)[0];
35
39
  const value = transform[key];
36
40
 
@@ -67,5 +71,5 @@ export const processTransform2d = transforms => skiaMatrix3(transforms.reduce((a
67
71
  }
68
72
 
69
73
  return exhaustiveCheck(key);
70
- }, identityMatrix));
74
+ }, identityMatrix);
71
75
  //# sourceMappingURL=Matrix3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Matrix3.ts"],"names":["exhaustiveCheck","identityMatrix","translateXMatrix","x","translateYMatrix","y","scaleMatrix","s","scaleXMatrix","scaleYMatrix","skewXMatrix","Math","tan","skewYMatrix","rotateZMatrix","r","cos","sin","dot3","row","col","multiply3","m1","m2","col0","col1","col2","skiaMatrix3","m","processTransform2d","transforms","reduce","acc","transform","key","Object","keys","value"],"mappings":"AAAA,SAASA,eAAT,QAAgC,iBAAhC;AAoCA,MAAMC,cAAuB,GAAG,CAC9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAD8B,EAE9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAF8B,EAG9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAH8B,CAAhC;;AAMA,MAAMC,gBAAgB,GAAIC,CAAD,IAAwB,CAC/C,CAAC,CAAD,EAAI,CAAJ,EAAOA,CAAP,CAD+C,EAE/C,CAAC,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AAnB,CAAhB;AACD;;AACD,SAAOrC,eAAe,CAACkC,GAAD,CAAtB;AACD,CA5BD,EA4BGjC,cA5BH,CADS,CADN","sourcesContent":["import { exhaustiveCheck } from \"../../typeddash\";\nimport type { SkMatrix } from \"../../../skia/Matrix\";\n\nexport type Vec3 = readonly [number, number, number];\n\nexport type Matrix3 = readonly [Vec3, Vec3, Vec3];\n\ntype Transform2dName =\n | \"translateX\"\n | \"translateY\"\n | \"scale\"\n | \"skewX\"\n | \"skewY\"\n | \"scaleX\"\n | \"scaleY\"\n | \"rotateZ\"\n | \"rotate\";\n\nexport interface TransformProp {\n transform?: Transforms2d;\n}\n\ntype Transformations = {\n readonly [Name in Transform2dName]: number;\n};\nexport type Transforms2d = readonly (\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"rotate\">\n)[];\n\nconst identityMatrix: Matrix3 = [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst translateXMatrix = (x: number): Matrix3 => [\n [1, 0, x],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst translateYMatrix = (y: number): Matrix3 => [\n [1, 0, 0],\n [0, 1, y],\n [0, 0, 1],\n];\n\nconst scaleMatrix = (s: number): Matrix3 => [\n [s, 0, 0],\n [0, s, 0],\n [0, 0, 1],\n];\n\nconst scaleXMatrix = (s: number): Matrix3 => [\n [s, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst scaleYMatrix = (s: number): Matrix3 => [\n [1, 0, 0],\n [0, s, 0],\n [0, 0, 1],\n];\n\nconst skewXMatrix = (s: number): Matrix3 => [\n [1, Math.tan(s), 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst skewYMatrix = (s: number): Matrix3 => [\n [1, 0, 0],\n [Math.tan(s), 1, 0],\n [0, 0, 1],\n];\n\nconst rotateZMatrix = (r: number): Matrix3 => [\n [Math.cos(r), -1 * Math.sin(r), 0],\n [Math.sin(r), Math.cos(r), 0],\n [0, 0, 1],\n];\n\nconst dot3 = (row: Vec3, col: Vec3) =>\n row[0] * col[0] + row[1] * col[1] + row[2] * col[2];\n\nconst multiply3 = (m1: Matrix3, m2: Matrix3) => {\n const col0 = [m2[0][0], m2[1][0], m2[2][0]] as const;\n const col1 = [m2[0][1], m2[1][1], m2[2][1]] as const;\n const col2 = [m2[0][2], m2[1][2], m2[2][2]] as const;\n return [\n [dot3(m1[0], col0), dot3(m1[0], col1), dot3(m1[0], col2)],\n [dot3(m1[1], col0), dot3(m1[1], col1), dot3(m1[1], col2)],\n [dot3(m1[2], col0), dot3(m1[2], col1), dot3(m1[2], col2)],\n ] as const;\n};\n\nconst skiaMatrix3 = (m: Matrix3): SkMatrix => {\n return [\n m[0][0],\n m[0][1],\n m[0][2],\n m[1][0],\n m[1][1],\n m[1][2],\n m[2][0],\n m[2][1],\n m[2][2],\n ];\n};\n\nexport const processTransform2d = (transforms: Transforms2d) =>\n skiaMatrix3(\n transforms.reduce((acc, transform) => {\n const key = Object.keys(transform)[0] as Transform2dName;\n const value = (transform as Pick<Transformations, typeof key>)[key];\n if (key === \"translateX\") {\n return multiply3(acc, translateXMatrix(value));\n }\n if (key === \"translateY\") {\n return multiply3(acc, translateYMatrix(value));\n }\n if (key === \"scale\") {\n return multiply3(acc, scaleMatrix(value));\n }\n if (key === \"scaleX\") {\n return multiply3(acc, scaleXMatrix(value));\n }\n if (key === \"scaleY\") {\n return multiply3(acc, scaleYMatrix(value));\n }\n if (key === \"skewX\") {\n return multiply3(acc, skewXMatrix(value));\n }\n if (key === \"skewY\") {\n return multiply3(acc, skewYMatrix(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n return multiply3(acc, rotateZMatrix(value));\n }\n return exhaustiveCheck(key);\n }, identityMatrix)\n );\n"]}
1
+ {"version":3,"sources":["Matrix3.ts"],"names":["exhaustiveCheck","identityMatrix","translateXMatrix","x","translateYMatrix","y","scaleMatrix","s","scaleXMatrix","scaleYMatrix","skewXMatrix","Math","tan","skewYMatrix","rotateZMatrix","r","cos","sin","dot3","row","col","multiply3","m1","m2","col0","col1","col2","matrixVecMul3","m","v","skiaMatrix3","processTransform2d","transforms","processTransform","reduce","acc","transform","key","Object","keys","value"],"mappings":"AAAA,SAASA,eAAT,QAAgC,iBAAhC;AAoCA,MAAMC,cAAuB,GAAG,CAC9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAD8B,EAE9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAF8B,EAG9B,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAH8B,CAAhC;;AAMA,MAAMC,gBAAgB,GAAIC,CAAD,IAAwB,CAC/C,CAAC,CAAD,EAAI,CAAJ,EAAOA,CAAP,CAD+C,EAE/C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAF+C,EAG/C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAH+C,CAAjD;;AAMA,MAAMC,gBAAgB,GAAIC,CAAD,IAAwB,CAC/C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAD+C,EAE/C,CAAC,CAAD,EAAI,CAAJ,EAAOA,CAAP,CAF+C,EAG/C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAH+C,CAAjD;;AAMA,MAAMC,WAAW,GAAIC,CAAD,IAAwB,CAC1C,CAACA,CAAD,EAAI,CAAJ,EAAO,CAAP,CAD0C,EAE1C,CAAC,CAAD,EAAIA,CAAJ,EAAO,CAAP,CAF0C,EAG1C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAH0C,CAA5C;;AAMA,MAAMC,YAAY,GAAID,CAAD,IAAwB,CAC3C,CAACA,CAAD,EAAI,CAAJ,EAAO,CAAP,CAD2C,EAE3C,CAAC,CAAD,EAAI,CAAJ,E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Z,EAA0B;AACxB,WAAOhB,SAAS,CAACc,GAAD,EAAMjC,gBAAgB,CAACsC,KAAD,CAAtB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,YAAZ,EAA0B;AACxB,WAAOhB,SAAS,CAACc,GAAD,EAAM/B,gBAAgB,CAACoC,KAAD,CAAtB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,OAAZ,EAAqB;AACnB,WAAOhB,SAAS,CAACc,GAAD,EAAM7B,WAAW,CAACkC,KAAD,CAAjB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,QAAZ,EAAsB;AACpB,WAAOhB,SAAS,CAACc,GAAD,EAAM3B,YAAY,CAACgC,KAAD,CAAlB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,QAAZ,EAAsB;AACpB,WAAOhB,SAAS,CAACc,GAAD,EAAM1B,YAAY,CAAC+B,KAAD,CAAlB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,OAAZ,EAAqB;AACnB,WAAOhB,SAAS,CAACc,GAAD,EAAMzB,WAAW,CAAC8B,KAAD,CAAjB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,OAAZ,EAAqB;AACnB,WAAOhB,SAAS,CAACc,GAAD,EAAMtB,WAAW,CAAC2B,KAAD,CAAjB,CAAhB;AACD;;AACD,MAAIH,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,SAAhC,EAA2C;AACzC,WAAOhB,SAAS,CAACc,GAAD,EAAMrB,aAAa,CAAC0B,KAAD,CAAnB,CAAhB;AACD;;AACD,SAAOxC,eAAe,CAACqC,GAAD,CAAtB;AACD,CA5BD,EA4BGpC,cA5BH,CADF","sourcesContent":["import { exhaustiveCheck } from \"../../typeddash\";\nimport type { SkMatrix } from \"../../../skia/Matrix\";\n\nexport type Vec3 = readonly [number, number, number];\n\nexport type Matrix3 = readonly [Vec3, Vec3, Vec3];\n\ntype Transform2dName =\n | \"translateX\"\n | \"translateY\"\n | \"scale\"\n | \"skewX\"\n | \"skewY\"\n | \"scaleX\"\n | \"scaleY\"\n | \"rotateZ\"\n | \"rotate\";\n\nexport interface TransformProp {\n transform?: Transforms2d;\n}\n\ntype Transformations = {\n readonly [Name in Transform2dName]: number;\n};\nexport type Transforms2d = readonly (\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"rotate\">\n)[];\n\nconst identityMatrix: Matrix3 = [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst translateXMatrix = (x: number): Matrix3 => [\n [1, 0, x],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst translateYMatrix = (y: number): Matrix3 => [\n [1, 0, 0],\n [0, 1, y],\n [0, 0, 1],\n];\n\nconst scaleMatrix = (s: number): Matrix3 => [\n [s, 0, 0],\n [0, s, 0],\n [0, 0, 1],\n];\n\nconst scaleXMatrix = (s: number): Matrix3 => [\n [s, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst scaleYMatrix = (s: number): Matrix3 => [\n [1, 0, 0],\n [0, s, 0],\n [0, 0, 1],\n];\n\nconst skewXMatrix = (s: number): Matrix3 => [\n [1, Math.tan(s), 0],\n [0, 1, 0],\n [0, 0, 1],\n];\n\nconst skewYMatrix = (s: number): Matrix3 => [\n [1, 0, 0],\n [Math.tan(s), 1, 0],\n [0, 0, 1],\n];\n\nconst rotateZMatrix = (r: number): Matrix3 => [\n [Math.cos(r), -1 * Math.sin(r), 0],\n [Math.sin(r), Math.cos(r), 0],\n [0, 0, 1],\n];\n\nconst dot3 = (row: Vec3, col: Vec3) =>\n row[0] * col[0] + row[1] * col[1] + row[2] * col[2];\n\nconst multiply3 = (m1: Matrix3, m2: Matrix3) => {\n const col0 = [m2[0][0], m2[1][0], m2[2][0]] as const;\n const col1 = [m2[0][1], m2[1][1], m2[2][1]] as const;\n const col2 = [m2[0][2], m2[1][2], m2[2][2]] as const;\n return [\n [dot3(m1[0], col0), dot3(m1[0], col1), dot3(m1[0], col2)],\n [dot3(m1[1], col0), dot3(m1[1], col1), dot3(m1[1], col2)],\n [dot3(m1[2], col0), dot3(m1[2], col1), dot3(m1[2], col2)],\n ] as const;\n};\n\nexport const matrixVecMul3 = (m: Matrix3, v: Vec3) =>\n [dot3(m[0], v), dot3(m[1], v), dot3(m[2], v)] as const;\n\nconst skiaMatrix3 = (m: Matrix3): SkMatrix => {\n return [\n m[0][0],\n m[0][1],\n m[0][2],\n m[1][0],\n m[1][1],\n m[1][2],\n m[2][0],\n m[2][1],\n m[2][2],\n ];\n};\n\nexport const processTransform2d = (transforms: Transforms2d) =>\n skiaMatrix3(processTransform(transforms));\n\nconst processTransform = (transforms: Transforms2d) =>\n transforms.reduce((acc, transform) => {\n const key = Object.keys(transform)[0] as Transform2dName;\n const value = (transform as Pick<Transformations, typeof key>)[key];\n if (key === \"translateX\") {\n return multiply3(acc, translateXMatrix(value));\n }\n if (key === \"translateY\") {\n return multiply3(acc, translateYMatrix(value));\n }\n if (key === \"scale\") {\n return multiply3(acc, scaleMatrix(value));\n }\n if (key === \"scaleX\") {\n return multiply3(acc, scaleXMatrix(value));\n }\n if (key === \"scaleY\") {\n return multiply3(acc, scaleYMatrix(value));\n }\n if (key === \"skewX\") {\n return multiply3(acc, skewXMatrix(value));\n }\n if (key === \"skewY\") {\n return multiply3(acc, skewYMatrix(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n return multiply3(acc, rotateZMatrix(value));\n }\n return exhaustiveCheck(key);\n }, identityMatrix);\n"]}
@@ -1,5 +1,26 @@
1
1
  export const mapKeys = obj => Object.keys(obj);
2
2
  export const exhaustiveCheck = a => {
3
3
  throw new Error(`Unexhaustive handling for ${a}`);
4
+ }; // Shallow eq on props (without children)
5
+
6
+ export const shallowEq = (p1, p2) => {
7
+ const keys1 = mapKeys(p1);
8
+ const keys2 = mapKeys(p2);
9
+
10
+ if (keys1.length !== keys2.length) {
11
+ return false;
12
+ }
13
+
14
+ for (const key of keys1) {
15
+ if (key === "children") {
16
+ continue;
17
+ }
18
+
19
+ if (p1[key] !== p2[key]) {
20
+ return false;
21
+ }
22
+ }
23
+
24
+ return true;
4
25
  };
5
26
  //# sourceMappingURL=typeddash.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["typeddash.ts"],"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAOC,GAAJ,IAAeC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CAA/B;AAEP,OAAO,MAAMG,eAAe,GAAIC,CAAD,IAAqB;AAClD,QAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAFM","sourcesContent":["export const mapKeys = <T>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n"]}
1
+ {"version":3,"sources":["typeddash.ts"],"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error","shallowEq","p1","p2","keys1","keys2","length","key"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAOC,GAAJ,IAAeC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CAA/B;AAEP,OAAO,MAAMG,eAAe,GAAIC,CAAD,IAAqB;AAClD,QAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAFM,C,CAIP;;AACA,OAAO,MAAME,SAAS,GAAG,CAAIC,EAAJ,EAAWC,EAAX,KAA8B;AACrD,QAAMC,KAAK,GAAGV,OAAO,CAACQ,EAAD,CAArB;AACA,QAAMG,KAAK,GAAGX,OAAO,CAACS,EAAD,CAArB;;AACA,MAAIC,KAAK,CAACE,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;AACjC,WAAO,KAAP;AACD;;AACD,OAAK,MAAMC,GAAX,IAAkBH,KAAlB,EAAyB;AACvB,QAAIG,GAAG,KAAK,UAAZ,EAAwB;AACtB;AACD;;AACD,QAAIL,EAAE,CAACK,GAAD,CAAF,KAAYJ,EAAE,CAACI,GAAD,CAAlB,EAAyB;AACvB,aAAO,KAAP;AACD;AACF;;AACD,SAAO,IAAP;AACD,CAfM","sourcesContent":["export const mapKeys = <T>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n// Shallow eq on props (without children)\nexport const shallowEq = <P>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import React, { useMemo, useContext } from "react";
2
+ // useContextBridge() is taken from https://github.com/pmndrs/drei#usecontextbridge
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ export const useContextBridge = function () {
5
+ for (var _len = arguments.length, contexts = new Array(_len), _key = 0; _key < _len; _key++) {
6
+ contexts[_key] = arguments[_key];
7
+ }
8
+
9
+ const values = // eslint-disable-next-line react-hooks/rules-of-hooks
10
+ contexts.map(context => useContext(context));
11
+ return useMemo(() => _ref => {
12
+ let {
13
+ children
14
+ } = _ref;
15
+ return contexts.reduceRight((acc, Context, i) => /*#__PURE__*/React.createElement(Context.Provider, {
16
+ value: values[i],
17
+ children: acc
18
+ }), children);
19
+ }, [contexts, values]);
20
+ };
21
+ //# sourceMappingURL=useContextBridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useContextBridge.tsx"],"names":["React","useMemo","useContext","useContextBridge","contexts","values","map","context","children","reduceRight","acc","Context","i"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,UAAzB,QAA2C,OAA3C;AAGA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,YAAiC;AAAA,oCAA7BC,QAA6B;AAA7BA,IAAAA,QAA6B;AAAA;;AAC/D,QAAMC,MAAM,GACV;AACAD,EAAAA,QAAQ,CAACE,GAAT,CAAcC,OAAD,IAAaL,UAAU,CAACK,OAAD,CAApC,CAFF;AAGA,SAAON,OAAO,CACZ,MACE;AAAA,QAAC;AAAEO,MAAAA;AAAF,KAAD;AAAA,WACEJ,QAAQ,CAACK,WAAT,CACE,CAACC,GAAD,EAAMC,OAAN,EAAeC,CAAf,kBACE,oBAAC,OAAD,CAAS,QAAT;AAAkB,MAAA,KAAK,EAAEP,MAAM,CAACO,CAAD,CAA/B;AAAoC,MAAA,QAAQ,EAAEF;AAA9C,MAFJ,EAIEF,QAJF,CADF;AAAA,GAFU,EASZ,CAACJ,QAAD,EAAWC,MAAX,CATY,CAAd;AAWD,CAfM","sourcesContent":["import React, { useMemo, useContext } from \"react\";\nimport type { ReactNode, Context, ReactElement } from \"react\";\n\n// useContextBridge() is taken from https://github.com/pmndrs/drei#usecontextbridge\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useContextBridge = (...contexts: Context<any>[]) => {\n const values =\n // eslint-disable-next-line react-hooks/rules-of-hooks\n contexts.map((context) => useContext(context));\n return useMemo(\n () =>\n ({ children }: { children: ReactNode }) =>\n contexts.reduceRight(\n (acc, Context, i) => (\n <Context.Provider value={values[i]} children={acc} />\n ),\n children\n ) as ReactElement,\n [contexts, values]\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Canvas.ts"],"names":["ClipOp","SaveLayerFlag"],"mappings":"AAeA,WAAYA,MAAZ;;WAAYA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAKZ,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix): void;\n}\n"]}
1
+ {"version":3,"sources":["Canvas.ts"],"names":["ClipOp","SaveLayerFlag"],"mappings":"AAgBA,WAAYA,MAAZ;;WAAYA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAKZ,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Picture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PictureFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PictureRecorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,5 @@
1
+ export * from "./Picture";
2
+ export * from "./PictureRecorder";
3
+ export * from "./usePicture";
4
+ export * from "./PictureFactory";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,mBAAd;AACA,cAAc,cAAd;AACA,cAAc,kBAAd","sourcesContent":["export * from \"./Picture\";\nexport * from \"./PictureRecorder\";\nexport * from \"./usePicture\";\nexport * from \"./PictureFactory\";\n"]}
@@ -0,0 +1,19 @@
1
+ import { useMemo } from "react";
2
+ import { Skia } from "../Skia";
3
+
4
+ /**
5
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
6
+ * @param rect Picture bounds
7
+ * @param cb Callback for drawing to the canvas
8
+ * @returns SkPicture
9
+ */
10
+ export const usePicture = function (rect, cb) {
11
+ let deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
12
+ return useMemo(() => {
13
+ const recorder = Skia.PictureRecorder();
14
+ const canvas = recorder.beginRecording(rect);
15
+ cb(canvas);
16
+ return recorder.finishRecordingAsPicture(); // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ }, [cb, rect, deps]);
18
+ };
19
+ //# sourceMappingURL=usePicture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePicture.ts"],"names":["useMemo","Skia","usePicture","rect","cb","deps","recorder","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAIA,SAASC,IAAT,QAAqB,SAArB;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,UACxBC,IADwB,EAExBC,EAFwB,EAIV;AAAA,MADdC,IACc,uEADS,EACT;AACd,SAAOL,OAAO,CAAC,MAAM;AACnB,UAAMM,QAAQ,GAAGL,IAAI,CAACM,eAAL,EAAjB;AACA,UAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAT,CAAwBN,IAAxB,CAAf;AACAC,IAAAA,EAAE,CAACI,MAAD,CAAF;AACA,WAAOF,QAAQ,CAACI,wBAAT,EAAP,CAJmB,CAKnB;AACD,GANa,EAMX,CAACN,EAAD,EAAKD,IAAL,EAAWE,IAAX,CANW,CAAd;AAOD,CAZM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport type { SkCanvas } from \"../Canvas\";\nimport type { SkRect } from \"../Rect\";\nimport { Skia } from \"../Skia\";\n\nimport type { SkPicture } from \"./Picture\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const usePicture = (\n rect: SkRect,\n cb: (canvas: SkCanvas) => void,\n deps: DependencyList = []\n): SkPicture => {\n return useMemo(() => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [cb, rect, deps]);\n};\n"]}
@@ -24,6 +24,8 @@ export const Skia = {
24
24
  XYWHRect: SkiaApi.XYWHRect,
25
25
  RRectXY: SkiaApi.RRectXY,
26
26
  Paint: SkiaApi.Paint,
27
+ PictureRecorder: SkiaApi.PictureRecorder,
28
+ Picture: SkiaApi.Picture,
27
29
  Path: SkiaApi.Path,
28
30
  ColorFilter: SkiaApi.ColorFilter,
29
31
  ContourMeasureIter: SkiaApi.ContourMeasureIter,
@@ -1 +1 @@
1
- {"version":3,"sources":["Skia.ts"],"names":["processColor","Skia","Typeface","SkiaApi","MaskFilter","RuntimeEffect","Shader","ImageFilter","PathEffect","Data","SVG","FontMgr","TextBlob","Matrix","Font","Point","XYWHRect","RRectXY","Paint","Path","ColorFilter","ContourMeasureIter","Color","color","RSXform","MakeSurface","Surface","Make","MakeImageFromEncoded","Image","MakeImage","MakeVertices"],"mappings":"AAAA;AAcA,SAASA,YAAT,QAA6B,SAA7B;AAUA,OAAO,eAAP;;AA8DA;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG;AAClB;AACAC,EAAAA,QAAQ,EAAEC,OAAO,CAACD,QAFA;AAGlBE,EAAAA,UAAU,EAAED,OAAO,CAACC,UAHF;AAIlBC,EAAAA,aAAa,EAAEF,OAAO,CAACE,aAJL;AAKlBC,EAAAA,MAAM,EAAEH,OAAO,CAACG,MALE;AAMlBC,EAAAA,WAAW,EAAEJ,OAAO,CAACI,WANH;AAOlBC,EAAAA,UAAU,EAAEL,OAAO,CAACK,UAPF;AAQlBC,EAAAA,IAAI,EAAEN,OAAO,CAACM,IARI;AASlBC,EAAAA,GAAG,EAAEP,OAAO,CAACO,GATK;AAUlBC,EAAAA,OAAO,EAAER,OAAO,CAACQ,OAVC;AAWlBC,EAAAA,QAAQ,EAAET,OAAO,CAACS,QAXA;AAYlB;AACAC,EAAAA,MAAM,EAAEV,OAAO,CAACU,MAbE;AAclBC,EAAAA,IAAI,EAAEX,OAAO,CAACW,IAdI;AAelBC,EAAAA,KAAK,EAAEZ,OAAO,CAACY,KAfG;AAgBlBC,EAAAA,QAAQ,EAAEb,OAAO,CAACa,QAhBA;AAiBlBC,EAAAA,OAAO,EAAEd,OAAO,CAACc,OAjBC;AAkBlBC,EAAAA,KAAK,EAAEf,OAAO,CAACe,KAlBG;AAmBlBC,EAAAA,IAAI,EAAEhB,OAAO,CAACgB,IAnBI;AAoBlBC,EAAAA,WAAW,EAAEjB,OAAO,CAACiB,WApBH;AAqBlBC,EAAAA,kBAAkB,EAAElB,OAAO,CAACkB,kBArBV;AAsBlB;AACAC,EAAAA,KAAK,EAAGC,KAAD,IAA+CvB,YAAY,CAACuB,KAAD,EAAQ,CAAR,CAvBhD;AAwBlBC,EAAAA,OAAO,EAAErB,OAAO,CAACqB,OAxBC;AAyBlB;AACAC,EAAAA,WAAW,EAAEtB,OAAO,CAACuB,OAAR,CAAgBC,IA1BX;AA2BlBC,EAAAA,oBAAoB,EAAEzB,OAAO,CAAC0B,KAAR,CAAcD,oBA3BlB;AA4BlBE,EAAAA,SAAS,EAAE3B,OAAO,CAAC0B,KAAR,CAAcC,SA5BP;AA6BlBC,EAAAA,YAAY,EAAE5B,OAAO,CAAC4B;AA7BJ,CAAb","sourcesContent":["/*global SkiaApi*/\nimport type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type { RuntimeEffectFactory } from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkColor } from \"./Color\";\nimport { processColor } from \"./Color\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { FontMgrFactory } from \"./FontMgr/FontMgrFactory\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport \"./NativeSetup\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n Path: PathFactory;\n Matrix: () => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n SVG: SVGFactory;\n FontMgr: FontMgrFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n\n/**\n * Declares the SkiaApi as an available object in the global scope\n */\ndeclare global {\n var SkiaApi: Skia;\n}\n\n/**\n * Declares the implemented API with overrides.\n */\nexport const Skia = {\n // Factories\n Typeface: SkiaApi.Typeface,\n MaskFilter: SkiaApi.MaskFilter,\n RuntimeEffect: SkiaApi.RuntimeEffect,\n Shader: SkiaApi.Shader,\n ImageFilter: SkiaApi.ImageFilter,\n PathEffect: SkiaApi.PathEffect,\n Data: SkiaApi.Data,\n SVG: SkiaApi.SVG,\n FontMgr: SkiaApi.FontMgr,\n TextBlob: SkiaApi.TextBlob,\n // Constructors\n Matrix: SkiaApi.Matrix,\n Font: SkiaApi.Font,\n Point: SkiaApi.Point,\n XYWHRect: SkiaApi.XYWHRect,\n RRectXY: SkiaApi.RRectXY,\n Paint: SkiaApi.Paint,\n Path: SkiaApi.Path,\n ColorFilter: SkiaApi.ColorFilter,\n ContourMeasureIter: SkiaApi.ContourMeasureIter,\n // Here are constructors for data types which are represented as typed arrays in CanvasKit\n Color: (color: Parameters<typeof processColor>[0]) => processColor(color, 1),\n RSXform: SkiaApi.RSXform,\n // For the following methods the factory symmetry is broken to be comptatible with CanvasKit\n MakeSurface: SkiaApi.Surface.Make,\n MakeImageFromEncoded: SkiaApi.Image.MakeImageFromEncoded,\n MakeImage: SkiaApi.Image.MakeImage,\n MakeVertices: SkiaApi.MakeVertices,\n};\n"]}
1
+ {"version":3,"sources":["Skia.ts"],"names":["processColor","Skia","Typeface","SkiaApi","MaskFilter","RuntimeEffect","Shader","ImageFilter","PathEffect","Data","SVG","FontMgr","TextBlob","Matrix","Font","Point","XYWHRect","RRectXY","Paint","PictureRecorder","Picture","Path","ColorFilter","ContourMeasureIter","Color","color","RSXform","MakeSurface","Surface","Make","MakeImageFromEncoded","Image","MakeImage","MakeVertices"],"mappings":"AAAA;AAcA,SAASA,YAAT,QAA6B,SAA7B;AAUA,OAAO,eAAP;;AAiEA;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG;AAClB;AACAC,EAAAA,QAAQ,EAAEC,OAAO,CAACD,QAFA;AAGlBE,EAAAA,UAAU,EAAED,OAAO,CAACC,UAHF;AAIlBC,EAAAA,aAAa,EAAEF,OAAO,CAACE,aAJL;AAKlBC,EAAAA,MAAM,EAAEH,OAAO,CAACG,MALE;AAMlBC,EAAAA,WAAW,EAAEJ,OAAO,CAACI,WANH;AAOlBC,EAAAA,UAAU,EAAEL,OAAO,CAACK,UAPF;AAQlBC,EAAAA,IAAI,EAAEN,OAAO,CAACM,IARI;AASlBC,EAAAA,GAAG,EAAEP,OAAO,CAACO,GATK;AAUlBC,EAAAA,OAAO,EAAER,OAAO,CAACQ,OAVC;AAWlBC,EAAAA,QAAQ,EAAET,OAAO,CAACS,QAXA;AAYlB;AACAC,EAAAA,MAAM,EAAEV,OAAO,CAACU,MAbE;AAclBC,EAAAA,IAAI,EAAEX,OAAO,CAACW,IAdI;AAelBC,EAAAA,KAAK,EAAEZ,OAAO,CAACY,KAfG;AAgBlBC,EAAAA,QAAQ,EAAEb,OAAO,CAACa,QAhBA;AAiBlBC,EAAAA,OAAO,EAAEd,OAAO,CAACc,OAjBC;AAkBlBC,EAAAA,KAAK,EAAEf,OAAO,CAACe,KAlBG;AAmBlBC,EAAAA,eAAe,EAAEhB,OAAO,CAACgB,eAnBP;AAoBlBC,EAAAA,OAAO,EAAEjB,OAAO,CAACiB,OApBC;AAqBlBC,EAAAA,IAAI,EAAElB,OAAO,CAACkB,IArBI;AAsBlBC,EAAAA,WAAW,EAAEnB,OAAO,CAACmB,WAtBH;AAuBlBC,EAAAA,kBAAkB,EAAEpB,OAAO,CAACoB,kBAvBV;AAwBlB;AACAC,EAAAA,KAAK,EAAGC,KAAD,IAA+CzB,YAAY,CAACyB,KAAD,EAAQ,CAAR,CAzBhD;AA0BlBC,EAAAA,OAAO,EAAEvB,OAAO,CAACuB,OA1BC;AA2BlB;AACAC,EAAAA,WAAW,EAAExB,OAAO,CAACyB,OAAR,CAAgBC,IA5BX;AA6BlBC,EAAAA,oBAAoB,EAAE3B,OAAO,CAAC4B,KAAR,CAAcD,oBA7BlB;AA8BlBE,EAAAA,SAAS,EAAE7B,OAAO,CAAC4B,KAAR,CAAcC,SA9BP;AA+BlBC,EAAAA,YAAY,EAAE9B,OAAO,CAAC8B;AA/BJ,CAAb","sourcesContent":["/*global SkiaApi*/\nimport type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type { RuntimeEffectFactory } from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkColor } from \"./Color\";\nimport { processColor } from \"./Color\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { FontMgrFactory } from \"./FontMgr/FontMgrFactory\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport \"./NativeSetup\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: () => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n SVG: SVGFactory;\n FontMgr: FontMgrFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n\n/**\n * Declares the SkiaApi as an available object in the global scope\n */\ndeclare global {\n var SkiaApi: Skia;\n}\n\n/**\n * Declares the implemented API with overrides.\n */\nexport const Skia = {\n // Factories\n Typeface: SkiaApi.Typeface,\n MaskFilter: SkiaApi.MaskFilter,\n RuntimeEffect: SkiaApi.RuntimeEffect,\n Shader: SkiaApi.Shader,\n ImageFilter: SkiaApi.ImageFilter,\n PathEffect: SkiaApi.PathEffect,\n Data: SkiaApi.Data,\n SVG: SkiaApi.SVG,\n FontMgr: SkiaApi.FontMgr,\n TextBlob: SkiaApi.TextBlob,\n // Constructors\n Matrix: SkiaApi.Matrix,\n Font: SkiaApi.Font,\n Point: SkiaApi.Point,\n XYWHRect: SkiaApi.XYWHRect,\n RRectXY: SkiaApi.RRectXY,\n Paint: SkiaApi.Paint,\n PictureRecorder: SkiaApi.PictureRecorder,\n Picture: SkiaApi.Picture,\n Path: SkiaApi.Path,\n ColorFilter: SkiaApi.ColorFilter,\n ContourMeasureIter: SkiaApi.ContourMeasureIter,\n // Here are constructors for data types which are represented as typed arrays in CanvasKit\n Color: (color: Parameters<typeof processColor>[0]) => processColor(color, 1),\n RSXform: SkiaApi.RSXform,\n // For the following methods the factory symmetry is broken to be comptatible with CanvasKit\n MakeSurface: SkiaApi.Surface.Make,\n MakeImageFromEncoded: SkiaApi.Image.MakeImageFromEncoded,\n MakeImage: SkiaApi.Image.MakeImage,\n MakeVertices: SkiaApi.MakeVertices,\n};\n"]}
@@ -20,5 +20,6 @@ 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";
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["Skia"],"mappings":"AAAA,SAASA,IAAT,QAAqB,QAArB;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,iBAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,OAAd;AACA,cAAc,WAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd","sourcesContent":["export { Skia } from \"./Skia\";\nexport * from \"./Canvas\";\nexport * from \"./Paint\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./Point\";\nexport * from \"./Path\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./MaskFilter\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./PathEffect\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./Matrix\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./FontMgr\";\nexport * from \"./Vertices\";\nexport * from \"./Color\";\nexport * from \"./Data\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["Skia"],"mappings":"AAAA,SAASA,IAAT,QAAqB,QAArB;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,iBAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,OAAd;AACA,cAAc,WAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd","sourcesContent":["export { Skia } from \"./Skia\";\nexport * from \"./Canvas\";\nexport * from \"./Paint\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./Point\";\nexport * from \"./Path\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./MaskFilter\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./PathEffect\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./Matrix\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./FontMgr\";\nexport * from \"./Vertices\";\nexport * from \"./Color\";\nexport * from \"./Picture\";\nexport * from \"./Data\";\n"]}
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from "react";
2
2
  import { ValueApi } from "../api";
3
- import { isValue } from "../../renderer";
3
+ import { isValue } from "../../renderer/processors";
4
4
  /**
5
5
  * Creates a new derived value - a value that will calculate its value depending
6
6
  * on other values.