@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
@@ -1 +1 @@
1
- {"version":3,"sources":["useDerivedValue.ts"],"names":["useMemo","ValueApi","isValue","useDerivedValue","cb","values","createDerivedValue","filter"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,gBAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC7BL,OAAO,CACL,MAAMC,QAAQ,CAACK,kBAAT,CAA+BF,EAA/B,EAAmCC,MAAM,CAACE,MAAP,CAAcL,OAAd,CAAnC,CADD,EAEL;AACAG,MAHK,CADF","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer\";\n\n/**\n * Creates a new derived value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useDerivedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createDerivedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n"]}
1
+ {"version":3,"sources":["useDerivedValue.ts"],"names":["useMemo","ValueApi","isValue","useDerivedValue","cb","values","createDerivedValue","filter"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,2BAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC7BL,OAAO,CACL,MAAMC,QAAQ,CAACK,kBAAT,CAA+BF,EAA/B,EAAmCC,MAAM,CAACE,MAAP,CAAcL,OAAd,CAAnC,CADD,EAEL;AACAG,MAHK,CADF","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors\";\n\n/**\n * Creates a new derived value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useDerivedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createDerivedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n"]}
@@ -1,3 +1,5 @@
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
+
1
3
  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
4
 
3
5
  import React from "react";
@@ -87,17 +89,16 @@ export class SkiaView extends React.Component {
87
89
 
88
90
  render() {
89
91
  const {
90
- style,
91
92
  mode,
92
- debug = false
93
+ debug = false,
94
+ ...viewProps
93
95
  } = this.props;
94
- return /*#__PURE__*/React.createElement(NativeSkiaView, {
95
- style: style,
96
+ return /*#__PURE__*/React.createElement(NativeSkiaView, _extends({
96
97
  collapsable: false,
97
98
  nativeID: `${this._nativeId}`,
98
99
  mode: mode,
99
100
  debug: debug
100
- });
101
+ }, viewProps));
101
102
  }
102
103
 
103
104
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["SkiaView.tsx"],"names":["React","requireNativeComponent","SkiaViewNativeId","NativeSkiaView","SkiaViewApi","global","SkiaView","Component","constructor","props","_nativeId","onDraw","assertDrawCallbacksEnabled","setDrawCallback","nativeId","componentDidUpdate","prevProps","makeImageSnapshot","rect","redraw","invalidateSkiaView","setDrawMode","mode","registerValues","values","registerValuesInView","render","style","debug","Error"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,sBAAT,QAAuC,cAAvC;AAYA,IAAIC,gBAAgB,GAAG,IAAvB;AAEA,MAAMC,cAAc,GAAGF,sBAAsB,CAC3C,qBAD2C,CAA7C;AAoBA,MAAM;AAAEG,EAAAA;AAAF,IAAkBC,MAAxB;AAEA,OAAO,MAAMC,QAAN,SAAuBN,KAAK,CAACO,SAA7B,CAAsD;AAC3DC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAChC,UAAMA,KAAN;;AADgC;;AAEhC,SAAKC,SAAL,GAAiBR,gBAAgB,EAAjC;AACA,UAAM;AAAES,MAAAA;AAAF,QAAaF,KAAnB;;AACA,QAAIE,MAAJ,EAAY;AACVC,MAAAA,0BAA0B;AAC1BR,MAAAA,WAAW,CAACS,eAAZ,CAA4B,KAAKH,SAAjC,EAA4CC,MAA5C;AACD;AACF;;AAIkB,MAARG,QAAQ,GAAG;AACpB,WAAO,KAAKJ,SAAZ;AACD;;AAEDK,EAAAA,kBAAkB,CAACC,SAAD,EAA2B;AAC3C,UAAM;AAAEL,MAAAA;AAAF,QAAa,KAAKF,KAAxB;;AACA,QAAIE,MAAM,KAAKK,SAAS,CAACL,MAAzB,EAAiC;AAC/BC,MAAAA,0BAA0B;AAC1BR,MAAAA,WAAW,CAACS,eAAZ,CAA4B,KAAKH,SAAjC,EAA4CC,MAA5C;AACD;AACF;AAED;AACF;AACA;AACA;AACA;;;AACSM,EAAAA,iBAAiB,CAACC,IAAD,EAAgB;AACtCN,IAAAA,0BAA0B;AAC1B,WAAOR,WAAW,CAACa,iBAAZ,CAA8B,KAAKP,SAAnC,EAA8CQ,IAA9C,CAAP;AACD;AAED;AACF;AACA;;;AACSC,EAAAA,MAAM,GAAG;AACdP,IAAAA,0BAA0B;AAC1BR,IAAAA,WAAW,CAACgB,kBAAZ,CAA+B,KAAKV,SAApC;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACSW,EAAAA,WAAW,CAACC,IAAD,EAAiB;AACjCV,IAAAA,0BAA0B;AAC1BR,IAAAA,WAAW,CAACiB,WAAZ,CAAwB,KAAKX,SAA7B,EAAwCY,IAAxC;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSC,EAAAA,cAAc,CAACC,MAAD,EAAuC;AAC1DZ,IAAAA,0BAA0B;AAC1B,WAAOR,WAAW,CAACqB,oBAAZ,CAAiC,KAAKf,SAAtC,EAAiDc,MAAjD,CAAP;AACD;;AAEDE,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEC,MAAAA,KAAF;AAASL,MAAAA,IAAT;AAAeM,MAAAA,KAAK,GAAG;AAAvB,QAAiC,KAAKnB,KAA5C;AACA,wBACE,oBAAC,cAAD;AACE,MAAA,KAAK,EAAEkB,KADT;AAEE,MAAA,WAAW,EAAE,KAFf;AAGE,MAAA,QAAQ,EAAG,GAAE,KAAKjB,SAAU,EAH9B;AAIE,MAAA,IAAI,EAAEY,IAJR;AAKE,MAAA,KAAK,EAAEM;AALT,MADF;AASD;;AA9E0D;;AAiF7D,MAAMhB,0BAA0B,GAAG,MAAM;AACvC,MACER,WAAW,KAAK,IAAhB,IACAA,WAAW,CAACS,eAAZ,IAA+B,IAD/B,IAEAT,WAAW,CAACgB,kBAAZ,IAAkC,IAHpC,EAIE;AACA,UAAMS,KAAK,CAAC,0BAAD,CAAX;AACD;AACF,CARD","sourcesContent":["import React from \"react\";\nimport { requireNativeComponent } from \"react-native\";\n\nimport type { SkImage, SkRect } from \"../skia\";\nimport type { SkiaReadonlyValue } from \"../values\";\n\nimport type {\n DrawMode,\n SkiaViewProps,\n RNSkiaDrawCallback,\n NativeSkiaViewProps,\n} from \"./types\";\n\nlet SkiaViewNativeId = 1000;\n\nconst NativeSkiaView = requireNativeComponent<NativeSkiaViewProps>(\n \"ReactNativeSkiaView\"\n);\n\ndeclare global {\n var SkiaViewApi: {\n invalidateSkiaView: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n setDrawCallback: (\n nativeId: number,\n callback: RNSkiaDrawCallback | undefined\n ) => void;\n setDrawMode: (nativeId: number, mode: DrawMode) => void;\n registerValuesInView: (\n nativeId: number,\n values: SkiaReadonlyValue<unknown>[]\n ) => () => void;\n };\n}\n\nconst { SkiaViewApi } = global;\n\nexport class SkiaView extends React.Component<SkiaViewProps> {\n constructor(props: SkiaViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId++;\n const { onDraw } = props;\n if (onDraw) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawCallback(this._nativeId, onDraw);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaViewProps) {\n const { onDraw } = this.props;\n if (onDraw !== prevProps.onDraw) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawCallback(this._nativeId, onDraw);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertDrawCallbacksEnabled();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertDrawCallbacksEnabled();\n SkiaViewApi.invalidateSkiaView(this._nativeId);\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawMode(this._nativeId, mode);\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(values: SkiaReadonlyValue<unknown>[]) {\n assertDrawCallbacksEnabled();\n return SkiaViewApi.registerValuesInView(this._nativeId, values);\n }\n\n render() {\n const { style, mode, debug = false } = this.props;\n return (\n <NativeSkiaView\n style={style}\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode}\n debug={debug}\n />\n );\n }\n}\n\nconst assertDrawCallbacksEnabled = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setDrawCallback == null ||\n SkiaViewApi.invalidateSkiaView == null\n ) {\n throw Error(\"Skia Api is not enabled.\");\n }\n};\n"]}
1
+ {"version":3,"sources":["SkiaView.tsx"],"names":["React","requireNativeComponent","SkiaViewNativeId","NativeSkiaView","SkiaViewApi","global","SkiaView","Component","constructor","props","_nativeId","onDraw","assertDrawCallbacksEnabled","setDrawCallback","nativeId","componentDidUpdate","prevProps","makeImageSnapshot","rect","redraw","invalidateSkiaView","setDrawMode","mode","registerValues","values","registerValuesInView","render","debug","viewProps","Error"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,sBAAT,QAAuC,cAAvC;AAWA,IAAIC,gBAAgB,GAAG,IAAvB;AAEA,MAAMC,cAAc,GAAGF,sBAAsB,CAC3C,qBAD2C,CAA7C;AAoBA,MAAM;AAAEG,EAAAA;AAAF,IAAkBC,MAAxB;AA0BA,OAAO,MAAMC,QAAN,SAAuBN,KAAK,CAACO,SAA7B,CAAsD;AAC3DC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAChC,UAAMA,KAAN;;AADgC;;AAEhC,SAAKC,SAAL,GAAiBR,gBAAgB,EAAjC;AACA,UAAM;AAAES,MAAAA;AAAF,QAAaF,KAAnB;;AACA,QAAIE,MAAJ,EAAY;AACVC,MAAAA,0BAA0B;AAC1BR,MAAAA,WAAW,CAACS,eAAZ,CAA4B,KAAKH,SAAjC,EAA4CC,MAA5C;AACD;AACF;;AAIkB,MAARG,QAAQ,GAAG;AACpB,WAAO,KAAKJ,SAAZ;AACD;;AAEDK,EAAAA,kBAAkB,CAACC,SAAD,EAA2B;AAC3C,UAAM;AAAEL,MAAAA;AAAF,QAAa,KAAKF,KAAxB;;AACA,QAAIE,MAAM,KAAKK,SAAS,CAACL,MAAzB,EAAiC;AAC/BC,MAAAA,0BAA0B;AAC1BR,MAAAA,WAAW,CAACS,eAAZ,CAA4B,KAAKH,SAAjC,EAA4CC,MAA5C;AACD;AACF;AAED;AACF;AACA;AACA;AACA;;;AACSM,EAAAA,iBAAiB,CAACC,IAAD,EAAgB;AACtCN,IAAAA,0BAA0B;AAC1B,WAAOR,WAAW,CAACa,iBAAZ,CAA8B,KAAKP,SAAnC,EAA8CQ,IAA9C,CAAP;AACD;AAED;AACF;AACA;;;AACSC,EAAAA,MAAM,GAAG;AACdP,IAAAA,0BAA0B;AAC1BR,IAAAA,WAAW,CAACgB,kBAAZ,CAA+B,KAAKV,SAApC;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACSW,EAAAA,WAAW,CAACC,IAAD,EAAiB;AACjCV,IAAAA,0BAA0B;AAC1BR,IAAAA,WAAW,CAACiB,WAAZ,CAAwB,KAAKX,SAA7B,EAAwCY,IAAxC;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSC,EAAAA,cAAc,CAACC,MAAD,EAAuC;AAC1DZ,IAAAA,0BAA0B;AAC1B,WAAOR,WAAW,CAACqB,oBAAZ,CAAiC,KAAKf,SAAtC,EAAiDc,MAAjD,CAAP;AACD;;AAEDE,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEJ,MAAAA,IAAF;AAAQK,MAAAA,KAAK,GAAG,KAAhB;AAAuB,SAAGC;AAA1B,QAAwC,KAAKnB,KAAnD;AACA,wBACE,oBAAC,cAAD;AACE,MAAA,WAAW,EAAE,KADf;AAEE,MAAA,QAAQ,EAAG,GAAE,KAAKC,SAAU,EAF9B;AAGE,MAAA,IAAI,EAAEY,IAHR;AAIE,MAAA,KAAK,EAAEK;AAJT,OAKMC,SALN,EADF;AASD;;AA9E0D;;AAiF7D,MAAMhB,0BAA0B,GAAG,MAAM;AACvC,MACER,WAAW,KAAK,IAAhB,IACAA,WAAW,CAACS,eAAZ,IAA+B,IAD/B,IAEAT,WAAW,CAACgB,kBAAZ,IAAkC,IAHpC,EAIE;AACA,UAAMS,KAAK,CAAC,0BAAD,CAAX;AACD;AACF,CARD","sourcesContent":["import React from \"react\";\nimport type { ViewProps } from \"react-native\";\nimport { requireNativeComponent } from \"react-native\";\n\nimport type { SkImage, SkRect } from \"../skia\";\nimport type { SkiaReadonlyValue } from \"../values\";\n\nimport type {\n DrawMode,\n RNSkiaDrawCallback,\n NativeSkiaViewProps,\n} from \"./types\";\n\nlet SkiaViewNativeId = 1000;\n\nconst NativeSkiaView = requireNativeComponent<NativeSkiaViewProps>(\n \"ReactNativeSkiaView\"\n);\n\ndeclare global {\n var SkiaViewApi: {\n invalidateSkiaView: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n setDrawCallback: (\n nativeId: number,\n callback: RNSkiaDrawCallback | undefined\n ) => void;\n setDrawMode: (nativeId: number, mode: DrawMode) => void;\n registerValuesInView: (\n nativeId: number,\n values: SkiaReadonlyValue<unknown>[]\n ) => () => void;\n };\n}\n\nconst { SkiaViewApi } = global;\n\nexport interface SkiaViewProps extends ViewProps {\n /**\n * Sets the drawing mode for the skia view. There are two drawing\n * modes, \"continuous\" and \"default\", where the continuous mode will\n * continuously redraw the view, and the default mode will only\n * redraw when any of the regular react properties are changed like\n * sizes and margins.\n */\n mode?: DrawMode;\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Draw callback. Will be called whenever the view is invalidated and\n * needs to redraw. This is either caused by a change in a react\n * property, a touch event, or a call to redraw. If the view is in\n * continuous mode the callback will be called 60 frames per second\n * by the native view.\n */\n onDraw?: RNSkiaDrawCallback;\n}\n\nexport class SkiaView extends React.Component<SkiaViewProps> {\n constructor(props: SkiaViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId++;\n const { onDraw } = props;\n if (onDraw) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawCallback(this._nativeId, onDraw);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaViewProps) {\n const { onDraw } = this.props;\n if (onDraw !== prevProps.onDraw) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawCallback(this._nativeId, onDraw);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertDrawCallbacksEnabled();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertDrawCallbacksEnabled();\n SkiaViewApi.invalidateSkiaView(this._nativeId);\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n assertDrawCallbacksEnabled();\n SkiaViewApi.setDrawMode(this._nativeId, mode);\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(values: SkiaReadonlyValue<unknown>[]) {\n assertDrawCallbacksEnabled();\n return SkiaViewApi.registerValuesInView(this._nativeId, values);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertDrawCallbacksEnabled = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setDrawCallback == null ||\n SkiaViewApi.invalidateSkiaView == null\n ) {\n throw Error(\"Skia Api is not enabled.\");\n }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"names":["TouchType"],"mappings":"AAWA,WAAYA,SAAZ;;WAAYA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { SkCanvas } from \"../skia/Canvas\";\n\nexport type DrawMode = \"continuous\" | \"default\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n mode?: DrawMode;\n debug?: boolean;\n};\n\nexport enum TouchType {\n Start,\n Active,\n End,\n Cancelled,\n}\n\nexport interface TouchInfo {\n x: number;\n y: number;\n force: number;\n type: TouchType;\n timestamp: number;\n}\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n touches: Array<Array<TouchInfo>>;\n}\n\nexport type ExtendedTouchInfo = TouchInfo & {\n // points per second\n velocityX: number;\n velocityY: number;\n};\n\nexport type TouchHandlers = {\n onStart?: (touchInfo: TouchInfo) => void;\n onActive?: (touchInfo: ExtendedTouchInfo) => void;\n onEnd?: (touchInfo: ExtendedTouchInfo) => void;\n};\n\nexport type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;\n\nexport type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;\n\nexport type SkiaViewProps = {\n style?: ViewProps[\"style\"];\n /**\n * Sets the drawing mode for the skia view. There are two drawing\n * modes, \"continuous\" and \"default\", where the continuous mode will\n * continuously redraw the view, and the default mode will only\n * redraw when any of the regular react properties are changed like\n * sizes and margins.\n */\n mode?: DrawMode;\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Draw callback. Will be called whenever the view is invalidated and\n * needs to redraw. This is either caused by a change in a react\n * property, a touch event, or a call to redraw. If the view is in\n * continuous mode the callback will be called 60 frames per second\n * by the native view.\n */\n onDraw?: RNSkiaDrawCallback;\n};\n\n/**\n * Listener interface for value changes\n */\nexport interface ValueListener {\n addListener: (callback: () => void) => number;\n removeListener: (id: number) => void;\n}\n"]}
1
+ {"version":3,"sources":["types.ts"],"names":["TouchType"],"mappings":"AAWA,WAAYA,SAAZ;;WAAYA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,KAAAA,S","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { SkCanvas } from \"../skia/Canvas\";\n\nexport type DrawMode = \"continuous\" | \"default\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n mode?: DrawMode;\n debug?: boolean;\n};\n\nexport enum TouchType {\n Start,\n Active,\n End,\n Cancelled,\n}\n\nexport interface TouchInfo {\n x: number;\n y: number;\n force: number;\n type: TouchType;\n timestamp: number;\n}\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n touches: Array<Array<TouchInfo>>;\n}\n\nexport type ExtendedTouchInfo = TouchInfo & {\n // points per second\n velocityX: number;\n velocityY: number;\n};\n\nexport type TouchHandlers = {\n onStart?: (touchInfo: TouchInfo) => void;\n onActive?: (touchInfo: ExtendedTouchInfo) => void;\n onEnd?: (touchInfo: ExtendedTouchInfo) => void;\n};\n\nexport type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;\n\nexport type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;\n\n/**\n * Listener interface for value changes\n */\nexport interface ValueListener {\n addListener: (callback: () => void) => number;\n removeListener: (id: number) => void;\n}\n"]}
@@ -1,19 +1,15 @@
1
1
  import React from "react";
2
- import type { RefObject, ReactNode, ComponentProps, Context } from "react";
2
+ import type { RefObject, ReactNode, ComponentProps } from "react";
3
3
  import ReactReconciler from "react-reconciler";
4
4
  import { SkiaView } from "../views";
5
5
  import type { TouchHandler } from "../views";
6
6
  import type { FontMgr } from "../skia/FontMgr/FontMgr";
7
+ import type { SkiaReadonlyValue } from "../values/types";
7
8
  import { Container } from "./nodes";
8
- export declare const useContextBridge: (...contexts: Context<any>[]) => ({ children }: {
9
- children: ReactNode;
10
- }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
11
- interface CanvasContext {
9
+ export declare const useCanvasSize: () => SkiaReadonlyValue<{
12
10
  width: number;
13
11
  height: number;
14
- }
15
- declare const CanvasContext: React.Context<CanvasContext | null>;
16
- export declare const useCanvas: () => CanvasContext;
12
+ }>;
17
13
  export declare const skiaReconciler: ReactReconciler.Reconciler<Container, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>>;
18
14
  export declare const useCanvasRef: () => React.RefObject<SkiaView>;
19
15
  export interface CanvasProps extends ComponentProps<typeof SkiaView> {
@@ -22,5 +18,4 @@ export interface CanvasProps extends ComponentProps<typeof SkiaView> {
22
18
  onTouch?: TouchHandler;
23
19
  fontMgr?: FontMgr;
24
20
  }
25
- export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "style" | "mode" | "debug" | "onDraw" | "children" | "onTouch" | "fontMgr"> & React.RefAttributes<SkiaView>>;
26
- export {};
21
+ export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "style" | "children" | "mode" | "debug" | "onDraw" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "onTouch" | "fontMgr"> & React.RefAttributes<SkiaView>>;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { DrawingContext } from "../DrawingContext";
3
+ interface DrawingProps {
4
+ drawing: (ctx: DrawingContext) => void;
5
+ }
6
+ export declare const Drawing: (props: DrawingProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SkPicture } from "../../skia";
3
+ export interface PictureProps {
4
+ picture: SkPicture;
5
+ }
6
+ export declare const Picture: (props: PictureProps) => JSX.Element;
@@ -1,12 +1,3 @@
1
- /// <reference types="react" />
2
- import type { AnimatedProps } from "../../processors";
3
- import type { Color } from "../../../skia";
4
- export interface InnerShadowProps {
5
- dx: number;
6
- dy: number;
7
- blur: number;
8
- color: Color;
9
- shadowOnly?: boolean;
10
- inner?: boolean;
11
- }
12
- export declare const InnerShadow: (props: AnimatedProps<InnerShadowProps>) => JSX.Element;
1
+ import type { SkColor } from "../../../skia";
2
+ import type { SkImageFilter } from "../../../skia/ImageFilter/ImageFilter";
3
+ export declare const MakeInnerShadow: (shadowOnly: boolean | undefined, dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null) => SkImageFilter;
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import type { AnimatedProps } from "../../processors/Animations/Animations";
3
3
  import type { Color } from "../../../skia/Color";
4
- export interface DropShadowProps {
4
+ export interface ShadowProps {
5
5
  dx: number;
6
6
  dy: number;
7
7
  blur: number;
8
8
  color: Color;
9
+ inner?: boolean;
9
10
  shadowOnly?: boolean;
10
11
  }
11
- export declare const DropShadow: (props: AnimatedProps<DropShadowProps>) => JSX.Element;
12
+ export declare const Shadow: (props: AnimatedProps<ShadowProps>) => JSX.Element;
@@ -1,6 +1,5 @@
1
1
  export * from "./Blur";
2
2
  export * from "./Offset";
3
3
  export * from "./DisplacementMap";
4
- export * from "./DropShadow";
5
- export * from "./InnerShadow";
4
+ export * from "./Shadow";
6
5
  export * from "./Morphology";
@@ -8,9 +8,11 @@ export * from "./maskFilters";
8
8
  export * from "./imageFilters";
9
9
  export * from "./pathEffects";
10
10
  export * from "../processors";
11
+ export * from "./Picture";
11
12
  export * from "./Group";
12
13
  export * from "./Mask";
13
14
  export * from "./Paint";
14
15
  export * from "./Compose";
15
16
  export * from "./Blend";
16
17
  export * from "./Defs";
18
+ export * from "./Drawing";
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import type { Color, SkRRect } from "../../../skia";
3
+ import type { AnimatedProps, CustomPaintProps } from "../../processors";
4
+ import type { SkRect } from "../../../skia/Rect";
5
+ interface BoxShadowProps {
6
+ dx?: number;
7
+ dy?: number;
8
+ spread?: number;
9
+ blur: number;
10
+ color?: Color;
11
+ inner?: boolean;
12
+ }
13
+ export declare const BoxShadow: (props: AnimatedProps<BoxShadowProps>) => JSX.Element;
14
+ interface BoxProps extends CustomPaintProps {
15
+ box: SkRRect | SkRect;
16
+ }
17
+ export declare const Box: {
18
+ (props: AnimatedProps<BoxProps>): JSX.Element;
19
+ defaultProps: {
20
+ shadows: never[];
21
+ };
22
+ };
23
+ export {};
@@ -10,3 +10,4 @@ export * from "./Patch";
10
10
  export * from "./Vertices";
11
11
  export * from "./Fill";
12
12
  export * from "./FitBox";
13
+ export * from "./Box";
@@ -1,3 +1,4 @@
1
1
  export * from "./Canvas";
2
2
  export * from "./components";
3
3
  export * from "./nodes";
4
+ export * from "./useContextBridge";
@@ -1,3 +1,4 @@
1
+ import type { DependencyList } from "react";
1
2
  import type { DrawingContext } from "../DrawingContext";
2
3
  import type { SkJSIInstance } from "../../skia/JsiInstance";
3
4
  import type { AnimatedProps } from "../processors";
@@ -6,6 +7,7 @@ import { Node } from "./Node";
6
7
  export declare type DeclarationResult = SkJSIInstance<string> | null;
7
8
  declare type DeclarationCallback<T> = (props: T, children: DeclarationResult[], ctx: DrawingContext) => DeclarationResult;
8
9
  export declare const createDeclaration: <T>(cb: DeclarationCallback<T>) => DeclarationCallback<T>;
10
+ export declare const useDeclaration: <P>(cb: DeclarationCallback<P>, deps?: DependencyList | undefined) => DeclarationCallback<P>;
9
11
  export interface DeclarationProps<P> {
10
12
  onDeclare: DeclarationCallback<P>;
11
13
  }
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import type { DependencyList, ReactNode } from "react";
2
2
  import type { DrawingContext } from "../DrawingContext";
3
3
  import type { AnimatedProps } from "../processors/Animations/Animations";
4
4
  import type { DependencyManager } from "../DependencyManager";
@@ -6,12 +6,12 @@ import { Node } from "./Node";
6
6
  declare type DrawingCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;
7
7
  declare type OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;
8
8
  export declare const createDrawing: <P>(cb: OnDrawCallback<P>) => DrawingCallback<P>;
9
+ export declare const useDrawing: <P>(cb: OnDrawCallback<P>, deps?: DependencyList | undefined) => OnDrawCallback<P>;
9
10
  export declare type DrawingProps<T> = {
10
11
  onDraw: DrawingCallback<T>;
11
12
  skipProcessing?: boolean;
12
13
  children?: ReactNode | ReactNode[];
13
14
  };
14
- export declare const Drawing: <P>(props: DrawingProps<P>) => JSX.Element;
15
15
  export declare class DrawingNode<P> extends Node<P> {
16
16
  onDraw: DrawingCallback<P>;
17
17
  skipProcessing: boolean;
@@ -1 +1,15 @@
1
+ /**
2
+ * Linear interpolation
3
+ * @param value
4
+ * @param x
5
+ * @param y
6
+ */
1
7
  export declare const mix: (value: number, x: number, y: number) => number;
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
+ export declare const clamp: (value: number, lowerBound: number, upperBound: number) => number;
@@ -9,5 +9,6 @@ declare type Transformations = {
9
9
  readonly [Name in Transform2dName]: number;
10
10
  };
11
11
  export declare type Transforms2d = readonly (Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "rotate">)[];
12
+ export declare const matrixVecMul3: (m: Matrix3, v: Vec3) => readonly [number, number, number];
12
13
  export declare const processTransform2d: (transforms: Transforms2d) => SkMatrix;
13
14
  export {};
@@ -1,2 +1,3 @@
1
1
  export declare const mapKeys: <T>(obj: T) => (keyof T)[];
2
2
  export declare const exhaustiveCheck: (a: never) => never;
3
+ export declare const shallowEq: <P>(p1: P, p2: P) => boolean;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import type { ReactNode, Context } from "react";
3
+ export declare const useContextBridge: (...contexts: Context<any>[]) => ({ children }: {
4
+ children: ReactNode;
5
+ }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
@@ -12,6 +12,7 @@ import type { SkMatrix } from "./Matrix";
12
12
  import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
15
+ import type { SkPicture } from "./Picture";
15
16
  export declare enum ClipOp {
16
17
  Difference = 0,
17
18
  Intersect = 1
@@ -372,4 +373,9 @@ export interface SkCanvas {
372
373
  * @param m
373
374
  */
374
375
  concat(m: SkMatrix): void;
376
+ /**
377
+ * Draws the given picture using the current clip, current matrix, and the provided paint.
378
+ * @param skp
379
+ */
380
+ drawPicture(skp: SkPicture): void;
375
381
  }
@@ -0,0 +1,26 @@
1
+ import type { InputColorMatrix } from "../ColorFilter";
2
+ import type { FilterMode } from "../Image";
3
+ import type { TileMode } from "../ImageFilter";
4
+ import type { SkRect } from "../Rect";
5
+ import type { IShader } from "../Shader";
6
+ export interface SkPicture {
7
+ /**
8
+ * Returns a new shader that will draw with this picture.
9
+ *
10
+ * @param tmx The tiling mode to use when sampling in the x-direction.
11
+ * @param tmy The tiling mode to use when sampling in the y-direction.
12
+ * @param mode How to filter the tiles
13
+ * @param localMatrix Optional matrix used when sampling
14
+ * @param tileRect The tile rectangle in picture coordinates: this represents the subset
15
+ * (or superset) of the picture used when building a tile. It is not
16
+ * affected by localMatrix and does not imply scaling (only translation
17
+ * and cropping). If null, the tile rect is considered equal to the picture
18
+ * bounds.
19
+ */
20
+ makeShader(tmx: TileMode, tmy: TileMode, mode: FilterMode, localMatrix?: InputColorMatrix, tileRect?: SkRect): IShader;
21
+ /**
22
+ * Returns the serialized format of this SkPicture. The format may change at anytime and
23
+ * no promises are made for backwards or forward compatibility.
24
+ */
25
+ serialize(): Uint8Array | null;
26
+ }
@@ -0,0 +1,8 @@
1
+ import type { SkPicture } from "./Picture";
2
+ export interface PictureFactory {
3
+ /**
4
+ * Returns an SkPicture which has been serialized previously to the given bytes.
5
+ * @param bytes
6
+ */
7
+ MakePicture(bytes: Uint8Array | ArrayBuffer): SkPicture | null;
8
+ }
@@ -0,0 +1,15 @@
1
+ import type { SkCanvas } from "../Canvas";
2
+ import type { SkRect } from "../Rect";
3
+ import type { SkPicture } from "./Picture";
4
+ export interface SkPictureRecorder {
5
+ /**
6
+ * Returns a canvas on which to draw. When done drawing, call finishRecordingAsPicture()
7
+ *
8
+ * @param bounds - a rect to cull the results.
9
+ */
10
+ beginRecording(bounds: SkRect): SkCanvas;
11
+ /**
12
+ * Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
13
+ */
14
+ finishRecordingAsPicture(): SkPicture;
15
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Picture";
2
+ export * from "./PictureRecorder";
3
+ export * from "./usePicture";
4
+ export * from "./PictureFactory";
@@ -0,0 +1,11 @@
1
+ import type { DependencyList } from "react";
2
+ import type { SkCanvas } from "../Canvas";
3
+ import type { SkRect } from "../Rect";
4
+ import type { SkPicture } from "./Picture";
5
+ /**
6
+ * Memoizes and returns an SkPicture that can be drawn to another canvas.
7
+ * @param rect Picture bounds
8
+ * @param cb Callback for drawing to the canvas
9
+ * @returns SkPicture
10
+ */
11
+ export declare const usePicture: (rect: SkRect, cb: (canvas: SkCanvas) => void, deps?: DependencyList) => SkPicture;
@@ -25,6 +25,7 @@ import "./NativeSetup";
25
25
  import type { SkRSXform } from "./RSXform";
26
26
  import type { SkPath } from "./Path/Path";
27
27
  import type { SkContourMeasureIter } from "./ContourMeasure";
28
+ import type { PictureFactory, SkPictureRecorder } from "./Picture";
28
29
  /**
29
30
  * Declares the interface for the native Skia API
30
31
  */
@@ -35,6 +36,8 @@ export interface Skia {
35
36
  RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;
36
37
  ContourMeasureIter: (path: SkPath, forceClosed: boolean, resScale: number) => SkContourMeasureIter;
37
38
  Paint: () => SkPaint;
39
+ PictureRecorder: () => SkPictureRecorder;
40
+ Picture: PictureFactory;
38
41
  Path: PathFactory;
39
42
  Matrix: () => SkMatrix;
40
43
  ColorFilter: ColorFilterFactory;
@@ -89,6 +92,8 @@ export declare const Skia: {
89
92
  XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;
90
93
  RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;
91
94
  Paint: () => SkPaint;
95
+ PictureRecorder: () => SkPictureRecorder;
96
+ Picture: PictureFactory;
92
97
  Path: PathFactory;
93
98
  ColorFilter: ColorFilterFactory;
94
99
  ContourMeasureIter: (path: SkPath, forceClosed: boolean, resScale: number) => SkContourMeasureIter;
@@ -20,4 +20,5 @@ export * from "./Surface";
20
20
  export * from "./FontMgr";
21
21
  export * from "./Vertices";
22
22
  export * from "./Color";
23
+ export * from "./Picture";
23
24
  export * from "./Data";
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
+ import type { ViewProps } from "react-native";
2
3
  import type { SkImage, SkRect } from "../skia";
3
4
  import type { SkiaReadonlyValue } from "../values";
4
- import type { DrawMode, SkiaViewProps, RNSkiaDrawCallback } from "./types";
5
+ import type { DrawMode, RNSkiaDrawCallback } from "./types";
5
6
  declare global {
6
7
  var SkiaViewApi: {
7
8
  invalidateSkiaView: (nativeId: number) => void;
@@ -11,6 +12,29 @@ declare global {
11
12
  registerValuesInView: (nativeId: number, values: SkiaReadonlyValue<unknown>[]) => () => void;
12
13
  };
13
14
  }
15
+ export interface SkiaViewProps extends ViewProps {
16
+ /**
17
+ * Sets the drawing mode for the skia view. There are two drawing
18
+ * modes, "continuous" and "default", where the continuous mode will
19
+ * continuously redraw the view, and the default mode will only
20
+ * redraw when any of the regular react properties are changed like
21
+ * sizes and margins.
22
+ */
23
+ mode?: DrawMode;
24
+ /**
25
+ * When set to true the view will display information about the
26
+ * average time it takes to render.
27
+ */
28
+ debug?: boolean;
29
+ /**
30
+ * Draw callback. Will be called whenever the view is invalidated and
31
+ * needs to redraw. This is either caused by a change in a react
32
+ * property, a touch event, or a call to redraw. If the view is in
33
+ * continuous mode the callback will be called 60 frames per second
34
+ * by the native view.
35
+ */
36
+ onDraw?: RNSkiaDrawCallback;
37
+ }
14
38
  export declare class SkiaView extends React.Component<SkiaViewProps> {
15
39
  constructor(props: SkiaViewProps);
16
40
  private _nativeId;
@@ -35,30 +35,6 @@ export declare type TouchHandlers = {
35
35
  };
36
36
  export declare type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;
37
37
  export declare type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;
38
- export declare type SkiaViewProps = {
39
- style?: ViewProps["style"];
40
- /**
41
- * Sets the drawing mode for the skia view. There are two drawing
42
- * modes, "continuous" and "default", where the continuous mode will
43
- * continuously redraw the view, and the default mode will only
44
- * redraw when any of the regular react properties are changed like
45
- * sizes and margins.
46
- */
47
- mode?: DrawMode;
48
- /**
49
- * When set to true the view will display information about the
50
- * average time it takes to render.
51
- */
52
- debug?: boolean;
53
- /**
54
- * Draw callback. Will be called whenever the view is invalidated and
55
- * needs to redraw. This is either caused by a change in a react
56
- * property, a touch event, or a call to redraw. If the view is in
57
- * continuous mode the callback will be called 60 frames per second
58
- * by the native view.
59
- */
60
- onDraw?: RNSkiaDrawCallback;
61
- };
62
38
  /**
63
39
  * Listener interface for value changes
64
40
  */
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e_x86_64-simulator</string>
9
+ <string>ios-arm64_arm64e</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libsvg.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
- <string>x86_64</string>
17
16
  </array>
18
17
  <key>SupportedPlatform</key>
19
18
  <string>ios</string>
20
- <key>SupportedPlatformVariant</key>
21
- <string>simulator</string>
22
19
  </dict>
23
20
  <dict>
24
21
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_arm64e</string>
22
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
26
23
  <key>LibraryPath</key>
27
24
  <string>libsvg.a</string>
28
25
  <key>SupportedArchitectures</key>
29
26
  <array>
30
27
  <string>arm64</string>
31
28
  <string>arm64e</string>
29
+ <string>x86_64</string>
32
30
  </array>
33
31
  <key>SupportedPlatform</key>
34
32
  <string>ios</string>
33
+ <key>SupportedPlatformVariant</key>
34
+ <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "React Native Skia",
7
- "version": "0.1.116",
7
+ "version": "0.1.118",
8
8
  "description": "High-performance React Native Graphics using Skia",
9
9
  "main": "lib/module/index.js",
10
10
  "files": [