@shopify/react-native-skia 0.1.172 → 0.1.174

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
  5. package/cpp/api/JsiSkSurface.h +7 -1
  6. package/cpp/api/JsiSkSurfaceFactory.h +15 -2
  7. package/cpp/rnskia/RNSkDomView.cpp +2 -4
  8. package/cpp/rnskia/RNSkJsView.cpp +3 -0
  9. package/cpp/rnskia/RNSkPictureView.h +3 -0
  10. package/cpp/rnskia/RNSkPlatformContext.h +9 -0
  11. package/cpp/rnskia/dom/JsiDomApi.h +1 -0
  12. package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
  13. package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
  14. package/cpp/rnskia/dom/base/Declaration.h +88 -0
  15. package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
  16. package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
  17. package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
  18. package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
  19. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
  20. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
  21. package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
  22. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
  23. package/cpp/rnskia/dom/base/NodeProp.h +12 -2
  24. package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
  25. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
  26. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
  27. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
  28. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
  29. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
  30. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
  31. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
  32. package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
  33. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
  34. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
  35. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
  36. package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
  37. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
  38. package/cpp/rnskia/dom/props/BezierProps.h +4 -2
  39. package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
  40. package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
  41. package/cpp/rnskia/dom/props/CircleProp.h +6 -5
  42. package/cpp/rnskia/dom/props/ClipProp.h +6 -4
  43. package/cpp/rnskia/dom/props/ColorProp.h +8 -4
  44. package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
  45. package/cpp/rnskia/dom/props/FontProp.h +4 -2
  46. package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
  47. package/cpp/rnskia/dom/props/ImageProps.h +9 -6
  48. package/cpp/rnskia/dom/props/LayerProp.h +6 -4
  49. package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
  50. package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
  51. package/cpp/rnskia/dom/props/PaintProps.h +55 -92
  52. package/cpp/rnskia/dom/props/PathProp.h +4 -2
  53. package/cpp/rnskia/dom/props/PictureProp.h +4 -2
  54. package/cpp/rnskia/dom/props/PointProp.h +4 -2
  55. package/cpp/rnskia/dom/props/PointsProp.h +8 -4
  56. package/cpp/rnskia/dom/props/RRectProp.h +23 -16
  57. package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
  58. package/cpp/rnskia/dom/props/RectProp.h +18 -12
  59. package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
  60. package/cpp/rnskia/dom/props/SvgProp.h +4 -2
  61. package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
  62. package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
  63. package/cpp/rnskia/dom/props/TransformProp.h +4 -2
  64. package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
  65. package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
  66. package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
  67. package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
  68. package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
  69. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
  70. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
  71. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +56 -25
  72. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
  73. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
  74. package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
  75. package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
  76. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
  77. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
  78. package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
  79. package/ios/RNSkiaModule.mm +5 -7
  80. package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
  81. package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
  82. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
  83. package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
  84. package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
  85. package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
  86. package/lib/commonjs/dom/nodes/Node.js +8 -26
  87. package/lib/commonjs/dom/nodes/Node.js.map +1 -1
  88. package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
  89. package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
  90. package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
  91. package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
  92. package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
  93. package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
  94. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  95. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  96. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
  97. package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  98. package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
  99. package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
  100. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  101. package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
  102. package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
  103. package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
  104. package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
  105. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
  106. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  107. package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
  108. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
  109. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  110. package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
  111. package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
  112. package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
  113. package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
  114. package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
  115. package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
  116. package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
  117. package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
  118. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  119. package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
  120. package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
  121. package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
  122. package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
  123. package/lib/commonjs/dom/types/DrawingContext.js +330 -0
  124. package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
  125. package/lib/commonjs/dom/types/Node.d.ts +4 -10
  126. package/lib/commonjs/dom/types/Node.js.map +1 -1
  127. package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
  128. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  129. package/lib/commonjs/dom/types/index.d.ts +1 -0
  130. package/lib/commonjs/dom/types/index.js +13 -0
  131. package/lib/commonjs/dom/types/index.js.map +1 -1
  132. package/lib/commonjs/index.d.ts +1 -0
  133. package/lib/commonjs/index.js +13 -0
  134. package/lib/commonjs/index.js.map +1 -1
  135. package/lib/commonjs/renderer/Canvas.js +3 -3
  136. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  137. package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
  138. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  139. package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
  140. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  141. package/lib/commonjs/renderer/HostConfig.js +1 -0
  142. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  143. package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
  144. package/lib/commonjs/renderer/Offscreen.js +31 -0
  145. package/lib/commonjs/renderer/Offscreen.js.map +1 -0
  146. package/lib/commonjs/renderer/Reconciler.js +0 -1
  147. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  148. package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
  149. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  150. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  151. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  152. package/lib/commonjs/skia/web/JsiSkDataFactory.js +0 -1
  153. package/lib/commonjs/skia/web/JsiSkDataFactory.js.map +1 -1
  154. package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
  155. package/lib/commonjs/skia/web/JsiSkImage.js +34 -3
  156. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  157. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
  158. package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
  159. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  160. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  161. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
  162. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  163. package/lib/commonjs/views/SkiaBaseWebView.js +14 -8
  164. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  165. package/lib/commonjs/views/SkiaDomView.web.js +3 -14
  166. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  167. package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
  168. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  169. package/lib/commonjs/views/SkiaView.web.js +0 -7
  170. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  171. package/lib/module/dom/nodes/DrawingNode.js +5 -1
  172. package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
  173. package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
  174. package/lib/module/dom/nodes/LayerNode.js +13 -7
  175. package/lib/module/dom/nodes/LayerNode.js.map +1 -1
  176. package/lib/module/dom/nodes/Node.d.ts +6 -11
  177. package/lib/module/dom/nodes/Node.js +8 -25
  178. package/lib/module/dom/nodes/Node.js.map +1 -1
  179. package/lib/module/dom/nodes/PaintContext.js.map +1 -1
  180. package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
  181. package/lib/module/dom/nodes/PaintNode.js +32 -15
  182. package/lib/module/dom/nodes/PaintNode.js.map +1 -1
  183. package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
  184. package/lib/module/dom/nodes/RenderNode.js +20 -187
  185. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  186. package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  187. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
  188. package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
  189. package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
  190. package/lib/module/dom/nodes/drawings/Box.js +3 -0
  191. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  192. package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
  193. package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
  194. package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
  195. package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
  196. package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
  197. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  198. package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
  199. package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
  200. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  201. package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
  202. package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
  203. package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
  204. package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
  205. package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
  206. package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
  207. package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
  208. package/lib/module/dom/nodes/paint/Shaders.js +28 -18
  209. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  210. package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
  211. package/lib/module/dom/types/DeclarationContext.js +107 -0
  212. package/lib/module/dom/types/DeclarationContext.js.map +1 -0
  213. package/lib/module/dom/types/DrawingContext.d.ts +18 -1
  214. package/lib/module/dom/types/DrawingContext.js +322 -1
  215. package/lib/module/dom/types/DrawingContext.js.map +1 -1
  216. package/lib/module/dom/types/Node.d.ts +4 -10
  217. package/lib/module/dom/types/Node.js.map +1 -1
  218. package/lib/module/dom/types/SkDOM.d.ts +22 -23
  219. package/lib/module/dom/types/SkDOM.js.map +1 -1
  220. package/lib/module/dom/types/index.d.ts +1 -0
  221. package/lib/module/dom/types/index.js +1 -0
  222. package/lib/module/dom/types/index.js.map +1 -1
  223. package/lib/module/index.d.ts +1 -0
  224. package/lib/module/index.js +1 -0
  225. package/lib/module/index.js.map +1 -1
  226. package/lib/module/renderer/Canvas.js +3 -3
  227. package/lib/module/renderer/Canvas.js.map +1 -1
  228. package/lib/module/renderer/DrawingContext.d.ts +4 -3
  229. package/lib/module/renderer/DrawingContext.js.map +1 -1
  230. package/lib/module/renderer/HostComponents.d.ts +35 -35
  231. package/lib/module/renderer/HostComponents.js.map +1 -1
  232. package/lib/module/renderer/HostConfig.js +1 -0
  233. package/lib/module/renderer/HostConfig.js.map +1 -1
  234. package/lib/module/renderer/Offscreen.d.ts +2 -0
  235. package/lib/module/renderer/Offscreen.js +19 -0
  236. package/lib/module/renderer/Offscreen.js.map +1 -0
  237. package/lib/module/renderer/Reconciler.js +0 -1
  238. package/lib/module/renderer/Reconciler.js.map +1 -1
  239. package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
  240. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  241. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  242. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  243. package/lib/module/skia/web/JsiSkDataFactory.js +0 -1
  244. package/lib/module/skia/web/JsiSkDataFactory.js.map +1 -1
  245. package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
  246. package/lib/module/skia/web/JsiSkImage.js +31 -3
  247. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  248. package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
  249. package/lib/module/skia/web/JsiSkSurface.js +4 -0
  250. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  251. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  252. package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
  253. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  254. package/lib/module/views/SkiaBaseWebView.js +14 -8
  255. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  256. package/lib/module/views/SkiaDomView.web.js +2 -11
  257. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  258. package/lib/module/views/SkiaPictureView.web.js +0 -5
  259. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  260. package/lib/module/views/SkiaView.web.js +0 -5
  261. package/lib/module/views/SkiaView.web.js.map +1 -1
  262. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
  263. package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
  264. package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
  265. package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
  266. package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
  267. package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
  268. package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
  269. package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
  270. package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
  271. package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
  272. package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
  273. package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
  274. package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
  275. package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
  276. package/lib/typescript/src/dom/types/Node.d.ts +4 -10
  277. package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
  278. package/lib/typescript/src/dom/types/index.d.ts +1 -0
  279. package/lib/typescript/src/index.d.ts +1 -0
  280. package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
  281. package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
  282. package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
  283. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
  284. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
  285. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
  286. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
  287. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  288. package/package.json +1 -1
  289. package/src/dom/nodes/DrawingNode.ts +5 -1
  290. package/src/dom/nodes/LayerNode.ts +13 -11
  291. package/src/dom/nodes/Node.ts +18 -41
  292. package/src/dom/nodes/PaintContext.ts +1 -0
  293. package/src/dom/nodes/PaintNode.ts +28 -18
  294. package/src/dom/nodes/RenderNode.ts +25 -183
  295. package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
  296. package/src/dom/nodes/drawings/Box.ts +6 -4
  297. package/src/dom/nodes/paint/BlendNode.ts +16 -63
  298. package/src/dom/nodes/paint/ColorFilters.ts +32 -55
  299. package/src/dom/nodes/paint/ImageFilters.ts +58 -53
  300. package/src/dom/nodes/paint/MaskFilters.ts +5 -7
  301. package/src/dom/nodes/paint/PathEffects.ts +37 -90
  302. package/src/dom/nodes/paint/Shaders.ts +31 -29
  303. package/src/dom/types/DeclarationContext.ts +105 -0
  304. package/src/dom/types/DrawingContext.ts +304 -1
  305. package/src/dom/types/Node.ts +4 -20
  306. package/src/dom/types/SkDOM.ts +22 -43
  307. package/src/dom/types/index.ts +1 -0
  308. package/src/index.ts +1 -0
  309. package/src/renderer/Canvas.tsx +3 -3
  310. package/src/renderer/DrawingContext.ts +4 -5
  311. package/src/renderer/HostComponents.ts +34 -53
  312. package/src/renderer/HostConfig.ts +1 -0
  313. package/src/renderer/Offscreen.tsx +24 -0
  314. package/src/renderer/Reconciler.tsx +0 -1
  315. package/src/skia/types/Surface/Surface.ts +5 -0
  316. package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
  317. package/src/skia/web/JsiSkDataFactory.ts +0 -1
  318. package/src/skia/web/JsiSkImage.ts +26 -2
  319. package/src/skia/web/JsiSkSurface.ts +4 -0
  320. package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
  321. package/src/views/SkiaBaseWebView.tsx +9 -2
  322. package/src/views/SkiaDomView.web.tsx +2 -13
  323. package/src/views/SkiaPictureView.web.tsx +0 -7
  324. package/src/views/SkiaView.web.tsx +0 -7
@@ -1,2 +1,323 @@
1
- export {};
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
+
3
+ import { BlendMode, PaintStyle, StrokeCap, StrokeJoin } from "../../skia/types";
4
+ import { enumKey } from "../nodes/datatypes/Enum";
5
+ import { JsiDeclarationNode } from "../nodes/Node";
6
+ import { DeclarationContext } from "./DeclarationContext";
7
+ export class JsiDrawingContext {
8
+ constructor(Skia, canvas) {
9
+ this.Skia = Skia;
10
+ this.canvas = canvas;
11
+
12
+ _defineProperty(this, "paints", void 0);
13
+
14
+ _defineProperty(this, "declarationCtx", void 0);
15
+
16
+ const paint = this.Skia.Paint();
17
+ this.paints = [paint];
18
+ this.declarationCtx = new DeclarationContext(Skia);
19
+ }
20
+
21
+ get paint() {
22
+ return this.paints[this.paints.length - 1];
23
+ }
24
+
25
+ save() {
26
+ const childPaint = this.paint.copy();
27
+ this.paints.push(childPaint);
28
+ }
29
+
30
+ restore() {
31
+ this.paints.pop();
32
+ }
33
+
34
+ saveAndConcat(node, cache) {
35
+ if (cache) {
36
+ this.paints.push(cache);
37
+ return true;
38
+ }
39
+
40
+ const paint = new ConcatablePaint(this.Skia, this.declarationCtx, node);
41
+
42
+ if (!paint.isPristine()) {
43
+ this.save();
44
+ paint.concatTo(this.paint);
45
+ return true;
46
+ }
47
+
48
+ return false;
49
+ }
50
+
51
+ }
52
+
53
+ class ConcatablePaint {
54
+ constructor(Skia, declCtx, node) {
55
+ _defineProperty(this, "pristine", true);
56
+
57
+ _defineProperty(this, "_color", void 0);
58
+
59
+ _defineProperty(this, "_strokeWidth", void 0);
60
+
61
+ _defineProperty(this, "_blendMode", void 0);
62
+
63
+ _defineProperty(this, "_style", void 0);
64
+
65
+ _defineProperty(this, "_strokeJoin", void 0);
66
+
67
+ _defineProperty(this, "_strokeCap", void 0);
68
+
69
+ _defineProperty(this, "_strokeMiter", void 0);
70
+
71
+ _defineProperty(this, "_opacity", 1);
72
+
73
+ _defineProperty(this, "_antiAlias", void 0);
74
+
75
+ _defineProperty(this, "_imageFilter", void 0);
76
+
77
+ _defineProperty(this, "_shader", void 0);
78
+
79
+ _defineProperty(this, "_pathEffect", void 0);
80
+
81
+ _defineProperty(this, "_colorFilter", void 0);
82
+
83
+ _defineProperty(this, "_maskFilter", void 0);
84
+
85
+ const props = node.getProps();
86
+ const children = node.children();
87
+ this.setColor(props.color !== undefined ? Skia.Color(props.color) : props.color);
88
+ this.setStrokeWidth(props.strokeWidth);
89
+ this.setBlendMode(props.blendMode);
90
+ this.setStyle(props.style);
91
+ this.setStrokeJoin(props.strokeJoin);
92
+ this.setStrokeCap(props.strokeCap);
93
+ this.setStrokeMiter(props.strokeMiter);
94
+ this.setOpacity(props.opacity);
95
+ this.setAntiAlias(props.antiAlias);
96
+ declCtx.save();
97
+ children.forEach(child => {
98
+ if (child instanceof JsiDeclarationNode) {
99
+ child.decorate(declCtx);
100
+ }
101
+ });
102
+ const colorFilter = declCtx.colorFilters.popAllAsOne();
103
+ const imageFilter = declCtx.imageFilters.popAllAsOne();
104
+ const shader = declCtx.shaders.pop();
105
+ const maskFilter = declCtx.maskFilters.pop();
106
+ const pathEffect = declCtx.pathEffects.popAllAsOne();
107
+ declCtx.restore();
108
+
109
+ if (imageFilter) {
110
+ this.setImageFilter(imageFilter);
111
+ }
112
+
113
+ if (shader) {
114
+ this.setShader(shader);
115
+ }
116
+
117
+ if (pathEffect) {
118
+ this.setPathEffect(pathEffect);
119
+ }
120
+
121
+ if (colorFilter) {
122
+ this.setColorFilter(colorFilter);
123
+ }
124
+
125
+ if (maskFilter) {
126
+ this.setMaskFilter(maskFilter);
127
+ }
128
+ }
129
+
130
+ enum(value, key) {
131
+ if (key !== undefined) {
132
+ return value[enumKey(key)];
133
+ }
134
+
135
+ return undefined;
136
+ }
137
+
138
+ setValue(key, value) {
139
+ if (value !== undefined) {
140
+ this[key] = value;
141
+ this.pristine = false;
142
+ }
143
+ }
144
+
145
+ setColor(color) {
146
+ this.setValue("_color", color);
147
+ }
148
+
149
+ getColor() {
150
+ return this._color;
151
+ }
152
+
153
+ setStrokeWidth(strokeWidth) {
154
+ this.setValue("_strokeWidth", strokeWidth);
155
+ }
156
+
157
+ getStrokeWidth() {
158
+ return this._strokeWidth;
159
+ }
160
+
161
+ setBlendMode(blendMode) {
162
+ this.setValue("_blendMode", this.enum(BlendMode, blendMode));
163
+ }
164
+
165
+ getBlendMode() {
166
+ return this._blendMode;
167
+ }
168
+
169
+ setStyle(style) {
170
+ this.setValue("_style", this.enum(PaintStyle, style));
171
+ }
172
+
173
+ getStyle() {
174
+ return this._style;
175
+ }
176
+
177
+ setStrokeJoin(strokeJoin) {
178
+ this.setValue("_strokeJoin", this.enum(StrokeJoin, strokeJoin));
179
+ }
180
+
181
+ getStrokeJoin() {
182
+ return this._strokeJoin;
183
+ }
184
+
185
+ setStrokeCap(strokeCap) {
186
+ this.setValue("_strokeCap", this.enum(StrokeCap, strokeCap));
187
+ }
188
+
189
+ getStrokeCap() {
190
+ return this._strokeCap;
191
+ }
192
+
193
+ setStrokeMiter(strokeMiter) {
194
+ this.setValue("_strokeMiter", strokeMiter);
195
+ }
196
+
197
+ getStrokeMiter() {
198
+ return this._strokeMiter;
199
+ }
200
+
201
+ setOpacity(opacity) {
202
+ this.setValue("_opacity", opacity);
203
+ }
204
+
205
+ getOpacity() {
206
+ return this._opacity;
207
+ }
208
+
209
+ setAntiAlias(antiAlias) {
210
+ this.setValue("_antiAlias", antiAlias);
211
+ }
212
+
213
+ getAntiAlias() {
214
+ return this._antiAlias;
215
+ }
216
+
217
+ setImageFilter(imageFilter) {
218
+ this.setValue("_imageFilter", imageFilter);
219
+ }
220
+
221
+ getImageFilter() {
222
+ return this._imageFilter;
223
+ }
224
+
225
+ setShader(shader) {
226
+ this.setValue("_shader", shader);
227
+ }
228
+
229
+ getShader() {
230
+ return this._shader;
231
+ }
232
+
233
+ setPathEffect(pathEffect) {
234
+ this.setValue("_pathEffect", pathEffect);
235
+ }
236
+
237
+ getPathEffect() {
238
+ return this._pathEffect;
239
+ }
240
+
241
+ setColorFilter(colorFilter) {
242
+ this.setValue("_colorFilter", colorFilter);
243
+ }
244
+
245
+ getColorFilter() {
246
+ return this._colorFilter;
247
+ }
248
+
249
+ setMaskFilter(maskFilter) {
250
+ this.setValue("_maskFilter", maskFilter);
251
+ }
252
+
253
+ getMaskFilter() {
254
+ return this._maskFilter;
255
+ }
256
+
257
+ isPristine() {
258
+ return this.pristine;
259
+ }
260
+
261
+ concatTo(paint) {
262
+ if (this._opacity !== undefined) {
263
+ paint.setAlphaf(paint.getAlphaf() * this._opacity);
264
+ }
265
+
266
+ if (this._color !== undefined) {
267
+ const currentOpacity = paint.getAlphaf();
268
+ paint.setShader(null);
269
+ paint.setColor(this._color);
270
+ paint.setAlphaf(currentOpacity * paint.getAlphaf());
271
+ }
272
+
273
+ if (this._strokeWidth !== undefined) {
274
+ paint.setStrokeWidth(this._strokeWidth);
275
+ }
276
+
277
+ if (this._blendMode !== undefined) {
278
+ paint.setBlendMode(this._blendMode);
279
+ }
280
+
281
+ if (this._style !== undefined) {
282
+ paint.setStyle(this._style);
283
+ }
284
+
285
+ if (this._strokeJoin !== undefined) {
286
+ paint.setStrokeJoin(this._strokeJoin);
287
+ }
288
+
289
+ if (this._strokeCap !== undefined) {
290
+ paint.setStrokeCap(this._strokeCap);
291
+ }
292
+
293
+ if (this._strokeMiter !== undefined) {
294
+ paint.setStrokeMiter(this._strokeMiter);
295
+ }
296
+
297
+ if (this._antiAlias !== undefined) {
298
+ paint.setAntiAlias(this._antiAlias);
299
+ }
300
+
301
+ if (this._imageFilter !== undefined) {
302
+ paint.setImageFilter(this._imageFilter);
303
+ }
304
+
305
+ if (this._shader !== undefined) {
306
+ paint.setShader(this._shader);
307
+ }
308
+
309
+ if (this._pathEffect !== undefined) {
310
+ paint.setPathEffect(this._pathEffect);
311
+ }
312
+
313
+ if (this._colorFilter !== undefined) {
314
+ paint.setColorFilter(this._colorFilter);
315
+ }
316
+
317
+ if (this._maskFilter !== undefined) {
318
+ paint.setMaskFilter(this._maskFilter);
319
+ }
320
+ }
321
+
322
+ }
2
323
  //# sourceMappingURL=DrawingContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { SkCanvas, SkPaint } from \"../../skia/types\";\n\nexport interface DrawingContext {\n canvas: SkCanvas;\n paint: SkPaint;\n}\n"],"mappings":""}
1
+ {"version":3,"names":["BlendMode","PaintStyle","StrokeCap","StrokeJoin","enumKey","JsiDeclarationNode","DeclarationContext","JsiDrawingContext","constructor","Skia","canvas","paint","Paint","paints","declarationCtx","length","save","childPaint","copy","push","restore","pop","saveAndConcat","node","cache","ConcatablePaint","isPristine","concatTo","declCtx","props","getProps","children","setColor","color","undefined","Color","setStrokeWidth","strokeWidth","setBlendMode","blendMode","setStyle","style","setStrokeJoin","strokeJoin","setStrokeCap","strokeCap","setStrokeMiter","strokeMiter","setOpacity","opacity","setAntiAlias","antiAlias","forEach","child","decorate","colorFilter","colorFilters","popAllAsOne","imageFilter","imageFilters","shader","shaders","maskFilter","maskFilters","pathEffect","pathEffects","setImageFilter","setShader","setPathEffect","setColorFilter","setMaskFilter","enum","value","key","setValue","pristine","getColor","_color","getStrokeWidth","_strokeWidth","getBlendMode","_blendMode","getStyle","_style","getStrokeJoin","_strokeJoin","getStrokeCap","_strokeCap","getStrokeMiter","_strokeMiter","getOpacity","_opacity","getAntiAlias","_antiAlias","getImageFilter","_imageFilter","getShader","_shader","getPathEffect","_pathEffect","getColorFilter","_colorFilter","getMaskFilter","_maskFilter","setAlphaf","getAlphaf","currentOpacity"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n SkCanvas,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPaint,\n SkPathEffect,\n SkShader,\n Skia,\n} from \"../../skia/types\";\nimport { BlendMode, PaintStyle, StrokeCap, StrokeJoin } from \"../../skia/types\";\nimport { enumKey } from \"../nodes/datatypes/Enum\";\nimport { JsiDeclarationNode } from \"../nodes/Node\";\n\nimport type { PaintProps, SkEnum } from \"./Common\";\nimport { DeclarationContext } from \"./DeclarationContext\";\nimport type { Node } from \"./Node\";\n\nexport interface DrawingContext {\n canvas: SkCanvas;\n paint: SkPaint;\n saveAndConcat(node: Node<PaintProps>, cache?: SkPaint): boolean;\n restore(): void;\n declarationCtx: DeclarationContext;\n}\n\nexport class JsiDrawingContext implements DrawingContext {\n paints: SkPaint[];\n\n declarationCtx: DeclarationContext;\n\n constructor(private readonly Skia: Skia, public readonly canvas: SkCanvas) {\n const paint = this.Skia.Paint();\n this.paints = [paint];\n this.declarationCtx = new DeclarationContext(Skia);\n }\n\n get paint() {\n return this.paints[this.paints.length - 1];\n }\n\n private save() {\n const childPaint = this.paint.copy();\n this.paints.push(childPaint);\n }\n\n restore(): void {\n this.paints.pop();\n }\n\n saveAndConcat(node: Node<PaintProps>, cache?: SkPaint) {\n if (cache) {\n this.paints.push(cache);\n return true;\n }\n const paint = new ConcatablePaint(this.Skia, this.declarationCtx, node);\n if (!paint.isPristine()) {\n this.save();\n paint.concatTo(this.paint);\n return true;\n }\n return false;\n }\n}\n\nclass ConcatablePaint {\n private pristine = true;\n\n _color?: SkColor;\n _strokeWidth?: number;\n _blendMode?: BlendMode;\n _style?: PaintStyle;\n _strokeJoin?: StrokeJoin;\n _strokeCap?: StrokeCap;\n _strokeMiter?: number;\n _opacity = 1;\n _antiAlias?: boolean;\n\n _imageFilter?: SkImageFilter;\n _shader?: SkShader;\n _pathEffect?: SkPathEffect;\n _colorFilter?: SkColorFilter;\n _maskFilter?: SkMaskFilter;\n\n constructor(Skia: Skia, declCtx: DeclarationContext, node: Node<PaintProps>) {\n const props = node.getProps();\n const children = node.children();\n this.setColor(\n props.color !== undefined ? Skia.Color(props.color) : props.color\n );\n this.setStrokeWidth(props.strokeWidth);\n this.setBlendMode(props.blendMode);\n this.setStyle(props.style);\n this.setStrokeJoin(props.strokeJoin);\n this.setStrokeCap(props.strokeCap);\n this.setStrokeMiter(props.strokeMiter);\n this.setOpacity(props.opacity);\n this.setAntiAlias(props.antiAlias);\n declCtx.save();\n children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n child.decorate(declCtx);\n }\n });\n const colorFilter = declCtx.colorFilters.popAllAsOne();\n const imageFilter = declCtx.imageFilters.popAllAsOne();\n const shader = declCtx.shaders.pop();\n const maskFilter = declCtx.maskFilters.pop();\n const pathEffect = declCtx.pathEffects.popAllAsOne();\n declCtx.restore();\n if (imageFilter) {\n this.setImageFilter(imageFilter);\n }\n if (shader) {\n this.setShader(shader);\n }\n if (pathEffect) {\n this.setPathEffect(pathEffect);\n }\n if (colorFilter) {\n this.setColorFilter(colorFilter);\n }\n if (maskFilter) {\n this.setMaskFilter(maskFilter);\n }\n }\n\n private enum<T>(value: T, key?: Uncapitalize<string>) {\n if (key !== undefined) {\n return value[enumKey(key) as keyof T];\n }\n return undefined;\n }\n\n private setValue<T extends keyof typeof this>(\n key: T,\n value?: typeof this[T]\n ) {\n if (value !== undefined) {\n this[key] = value;\n this.pristine = false;\n }\n }\n\n setColor(color?: SkColor) {\n this.setValue(\"_color\", color);\n }\n\n getColor() {\n return this._color;\n }\n\n setStrokeWidth(strokeWidth?: number) {\n this.setValue(\"_strokeWidth\", strokeWidth);\n }\n\n getStrokeWidth() {\n return this._strokeWidth;\n }\n\n setBlendMode(blendMode?: SkEnum<typeof BlendMode>) {\n this.setValue(\"_blendMode\", this.enum(BlendMode, blendMode));\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setStyle(style?: SkEnum<typeof PaintStyle>) {\n this.setValue(\"_style\", this.enum(PaintStyle, style));\n }\n\n getStyle() {\n return this._style;\n }\n\n setStrokeJoin(strokeJoin?: SkEnum<typeof StrokeJoin>) {\n this.setValue(\"_strokeJoin\", this.enum(StrokeJoin, strokeJoin));\n }\n\n getStrokeJoin() {\n return this._strokeJoin;\n }\n\n setStrokeCap(strokeCap?: SkEnum<typeof StrokeCap>) {\n this.setValue(\"_strokeCap\", this.enum(StrokeCap, strokeCap));\n }\n\n getStrokeCap() {\n return this._strokeCap;\n }\n\n setStrokeMiter(strokeMiter?: number) {\n this.setValue(\"_strokeMiter\", strokeMiter);\n }\n\n getStrokeMiter() {\n return this._strokeMiter;\n }\n\n setOpacity(opacity?: number) {\n this.setValue(\"_opacity\", opacity);\n }\n\n getOpacity() {\n return this._opacity;\n }\n\n setAntiAlias(antiAlias?: boolean) {\n this.setValue(\"_antiAlias\", antiAlias);\n }\n\n getAntiAlias() {\n return this._antiAlias;\n }\n\n setImageFilter(imageFilter?: SkImageFilter) {\n this.setValue(\"_imageFilter\", imageFilter);\n }\n\n getImageFilter() {\n return this._imageFilter;\n }\n\n setShader(shader?: SkShader) {\n this.setValue(\"_shader\", shader);\n }\n\n getShader() {\n return this._shader;\n }\n\n setPathEffect(pathEffect?: SkPathEffect) {\n this.setValue(\"_pathEffect\", pathEffect);\n }\n\n getPathEffect() {\n return this._pathEffect;\n }\n\n setColorFilter(colorFilter?: SkColorFilter) {\n this.setValue(\"_colorFilter\", colorFilter);\n }\n\n getColorFilter() {\n return this._colorFilter;\n }\n\n setMaskFilter(maskFilter?: SkMaskFilter) {\n this.setValue(\"_maskFilter\", maskFilter);\n }\n\n getMaskFilter() {\n return this._maskFilter;\n }\n\n isPristine() {\n return this.pristine;\n }\n\n concatTo(paint: SkPaint) {\n if (this._opacity !== undefined) {\n paint.setAlphaf(paint.getAlphaf() * this._opacity);\n }\n if (this._color !== undefined) {\n const currentOpacity = paint.getAlphaf();\n paint.setShader(null);\n paint.setColor(this._color);\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (this._strokeWidth !== undefined) {\n paint.setStrokeWidth(this._strokeWidth);\n }\n if (this._blendMode !== undefined) {\n paint.setBlendMode(this._blendMode);\n }\n if (this._style !== undefined) {\n paint.setStyle(this._style);\n }\n if (this._strokeJoin !== undefined) {\n paint.setStrokeJoin(this._strokeJoin);\n }\n if (this._strokeCap !== undefined) {\n paint.setStrokeCap(this._strokeCap);\n }\n if (this._strokeMiter !== undefined) {\n paint.setStrokeMiter(this._strokeMiter);\n }\n if (this._antiAlias !== undefined) {\n paint.setAntiAlias(this._antiAlias);\n }\n if (this._imageFilter !== undefined) {\n paint.setImageFilter(this._imageFilter);\n }\n if (this._shader !== undefined) {\n paint.setShader(this._shader);\n }\n if (this._pathEffect !== undefined) {\n paint.setPathEffect(this._pathEffect);\n }\n if (this._colorFilter !== undefined) {\n paint.setColorFilter(this._colorFilter);\n }\n if (this._maskFilter !== undefined) {\n paint.setMaskFilter(this._maskFilter);\n }\n }\n}\n"],"mappings":";;AAWA,SAASA,SAAT,EAAoBC,UAApB,EAAgCC,SAAhC,EAA2CC,UAA3C,QAA6D,kBAA7D;AACA,SAASC,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N,CAAe,KAAK2C,MAApB;IACD;;IACD,IAAI,KAAKE,WAAL,KAAqBnD,SAAzB,EAAoC;MAClCvB,KAAK,CAAC+B,aAAN,CAAoB,KAAK2C,WAAzB;IACD;;IACD,IAAI,KAAKE,UAAL,KAAoBrD,SAAxB,EAAmC;MACjCvB,KAAK,CAACiC,YAAN,CAAmB,KAAK2C,UAAxB;IACD;;IACD,IAAI,KAAKE,YAAL,KAAsBvD,SAA1B,EAAqC;MACnCvB,KAAK,CAACmC,cAAN,CAAqB,KAAK2C,YAA1B;IACD;;IACD,IAAI,KAAKI,UAAL,KAAoB3D,SAAxB,EAAmC;MACjCvB,KAAK,CAACuC,YAAN,CAAmB,KAAK2C,UAAxB;IACD;;IACD,IAAI,KAAKE,YAAL,KAAsB7D,SAA1B,EAAqC;MACnCvB,KAAK,CAACuD,cAAN,CAAqB,KAAK6B,YAA1B;IACD;;IACD,IAAI,KAAKE,OAAL,KAAiB/D,SAArB,EAAgC;MAC9BvB,KAAK,CAACwD,SAAN,CAAgB,KAAK8B,OAArB;IACD;;IACD,IAAI,KAAKE,WAAL,KAAqBjE,SAAzB,EAAoC;MAClCvB,KAAK,CAACyD,aAAN,CAAoB,KAAK+B,WAAzB;IACD;;IACD,IAAI,KAAKE,YAAL,KAAsBnE,SAA1B,EAAqC;MACnCvB,KAAK,CAAC0D,cAAN,CAAqB,KAAKgC,YAA1B;IACD;;IACD,IAAI,KAAKE,WAAL,KAAqBrE,SAAzB,EAAoC;MAClCvB,KAAK,CAAC2D,aAAN,CAAoB,KAAKiC,WAAzB;IACD;EACF;;AAjPmB"}
@@ -1,7 +1,7 @@
1
- import type { SkColorFilter, SkImageFilter, SkMaskFilter, SkPaint, SkPathEffect, SkShader } from "../../skia/types";
2
1
  import type { GroupProps } from "./Common";
3
- import type { DrawingContext } from "./DrawingContext";
4
2
  import type { DeclarationType, NodeType } from "./NodeType";
3
+ import type { DeclarationContext } from "./DeclarationContext";
4
+ import type { DrawingContext } from "./DrawingContext";
5
5
  export interface Node<P> {
6
6
  type: NodeType;
7
7
  setProps(props: P): void;
@@ -13,16 +13,10 @@ export interface Node<P> {
13
13
  insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
14
14
  }
15
15
  export declare type Invalidate = () => void;
16
- export interface DeclarationNode<P, T, Nullable extends null | never = never> extends Node<P> {
16
+ export interface DeclarationNode<P> extends Node<P> {
17
17
  declarationType: DeclarationType;
18
- materialize(): T | Nullable;
18
+ decorate(ctx: DeclarationContext): void;
19
19
  setInvalidate(invalidate: Invalidate): void;
20
- isPaint(): this is DeclarationNode<unknown, SkPaint>;
21
- isImageFilter(): this is DeclarationNode<unknown, SkImageFilter>;
22
- isColorFilter(): this is DeclarationNode<unknown, SkColorFilter>;
23
- isShader(): this is DeclarationNode<unknown, SkShader>;
24
- isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter>;
25
- isPathEffect(): this is DeclarationNode<unknown, SkPathEffect>;
26
20
  }
27
21
  export interface RenderNode<P extends GroupProps> extends Node<P> {
28
22
  render(ctx: DrawingContext): void;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Node.ts"],"sourcesContent":["import type {\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPaint,\n SkPathEffect,\n SkShader,\n} from \"../../skia/types\";\n\nimport type { GroupProps } from \"./Common\";\nimport type { DrawingContext } from \"./DrawingContext\";\nimport type { DeclarationType, NodeType } from \"./NodeType\";\n\nexport interface Node<P> {\n type: NodeType;\n\n setProps(props: P): void;\n setProp<K extends keyof P>(name: K, v: P[K]): boolean;\n getProps(): P;\n\n children(): Node<unknown>[];\n addChild(child: Node<unknown>): void;\n removeChild(child: Node<unknown>): void;\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;\n}\n\nexport type Invalidate = () => void;\n\nexport interface DeclarationNode<P, T, Nullable extends null | never = never>\n extends Node<P> {\n declarationType: DeclarationType;\n materialize(): T | Nullable;\n\n setInvalidate(invalidate: Invalidate): void;\n\n isPaint(): this is DeclarationNode<unknown, SkPaint>;\n isImageFilter(): this is DeclarationNode<unknown, SkImageFilter>;\n isColorFilter(): this is DeclarationNode<unknown, SkColorFilter>;\n isShader(): this is DeclarationNode<unknown, SkShader>;\n isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter>;\n isPathEffect(): this is DeclarationNode<unknown, SkPathEffect>;\n}\n\nexport interface RenderNode<P extends GroupProps> extends Node<P> {\n render(ctx: DrawingContext): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Node.ts"],"sourcesContent":["import type { GroupProps } from \"./Common\";\nimport type { DeclarationType, NodeType } from \"./NodeType\";\nimport type { DeclarationContext } from \"./DeclarationContext\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface Node<P> {\n type: NodeType;\n\n setProps(props: P): void;\n setProp<K extends keyof P>(name: K, v: P[K]): boolean;\n getProps(): P;\n\n children(): Node<unknown>[];\n addChild(child: Node<unknown>): void;\n removeChild(child: Node<unknown>): void;\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;\n}\n\nexport type Invalidate = () => void;\n\nexport interface DeclarationNode<P> extends Node<P> {\n declarationType: DeclarationType;\n decorate(ctx: DeclarationContext): void;\n\n setInvalidate(invalidate: Invalidate): void;\n}\n\nexport interface RenderNode<P extends GroupProps> extends Node<P> {\n render(ctx: DrawingContext): void;\n}\n"],"mappings":""}
@@ -1,4 +1,3 @@
1
- import type { SkImageFilter, SkMaskFilter, SkShader, SkColorFilter, SkPathEffect, SkPaint } from "../../skia/types";
2
1
  import type { ChildrenProps, GroupProps, PaintProps } from "./Common";
3
2
  import type { BlendImageFilterProps, BlurImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, DisplacementMapImageFilterProps, MorphologyImageFilterProps, BlendProps } from "./ImageFilters";
4
3
  import type { DeclarationNode, RenderNode } from "./Node";
@@ -7,14 +6,14 @@ import type { ImageProps, CircleProps, PathProps, CustomDrawingNodeProps, LinePr
7
6
  import type { BlurMaskFilterProps } from "./MaskFilters";
8
7
  import type { FractalNoiseProps, SweepGradientProps, ImageShaderProps, LinearGradientProps, ShaderProps, TurbulenceProps, TwoPointConicalGradientProps, RadialGradientProps, ColorProps } from "./Shaders";
9
8
  import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "./PathEffects";
10
- declare type ImageFilterNode<P> = DeclarationNode<P, SkImageFilter>;
11
- declare type PathEffectNode<P> = DeclarationNode<P, SkPathEffect>;
12
- declare type NullablePathEffectNode<P> = DeclarationNode<P, SkPathEffect, null>;
9
+ declare type ImageFilterNode<P> = DeclarationNode<P>;
10
+ declare type PathEffectNode<P> = DeclarationNode<P>;
11
+ declare type NullablePathEffectNode<P> = DeclarationNode<P>;
13
12
  declare type DrawingNode<P extends GroupProps> = RenderNode<P>;
14
13
  export interface SkDOM {
15
14
  Layer(props?: ChildrenProps): RenderNode<ChildrenProps>;
16
15
  Group(props?: GroupProps): RenderNode<GroupProps>;
17
- Paint(props: PaintProps): DeclarationNode<PaintProps, SkPaint>;
16
+ Paint(props: PaintProps): DeclarationNode<PaintProps>;
18
17
  Fill(props?: DrawingNodeProps): DrawingNode<DrawingNodeProps>;
19
18
  Image(props: ImageProps): DrawingNode<ImageProps>;
20
19
  Circle(props: CircleProps): DrawingNode<CircleProps>;
@@ -34,7 +33,7 @@ export interface SkDOM {
34
33
  DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;
35
34
  Picture(props: PictureProps): DrawingNode<PictureProps>;
36
35
  ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;
37
- BlurMaskFilter(props: BlurMaskFilterProps): DeclarationNode<BlurMaskFilterProps, SkMaskFilter>;
36
+ BlurMaskFilter(props: BlurMaskFilterProps): DeclarationNode<BlurMaskFilterProps>;
38
37
  BlendImageFilter(props: BlendImageFilterProps): ImageFilterNode<BlendImageFilterProps>;
39
38
  BlurImageFilter(props: BlurImageFilterProps): ImageFilterNode<BlurImageFilterProps>;
40
39
  OffsetImageFilter(props: OffsetImageFilterProps): ImageFilterNode<OffsetImageFilterProps>;
@@ -42,21 +41,21 @@ export interface SkDOM {
42
41
  MorphologyImageFilter(props: MorphologyImageFilterProps): ImageFilterNode<MorphologyImageFilterProps>;
43
42
  DisplacementMapImageFilter(props: DisplacementMapImageFilterProps): ImageFilterNode<DisplacementMapImageFilterProps>;
44
43
  RuntimeShaderImageFilter(props: RuntimeShaderImageFilterProps): ImageFilterNode<RuntimeShaderImageFilterProps>;
45
- MatrixColorFilter(props: MatrixColorFilterProps): DeclarationNode<MatrixColorFilterProps, SkColorFilter>;
46
- BlendColorFilter(props: BlendColorFilterProps): DeclarationNode<BlendColorFilterProps, SkColorFilter>;
47
- LumaColorFilter(): DeclarationNode<null, SkColorFilter>;
48
- LinearToSRGBGammaColorFilter(): DeclarationNode<null, SkColorFilter>;
49
- SRGBToLinearGammaColorFilter(): DeclarationNode<null, SkColorFilter>;
50
- LerpColorFilter(props: LerpColorFilterProps): DeclarationNode<LerpColorFilterProps, SkColorFilter>;
51
- Shader(props: ShaderProps): DeclarationNode<ShaderProps, SkShader>;
52
- ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps, SkShader>;
53
- ColorShader(props: ColorProps): DeclarationNode<ColorProps, SkShader>;
54
- Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps, SkShader>;
55
- FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps, SkShader>;
56
- LinearGradient(props: LinearGradientProps): DeclarationNode<LinearGradientProps, SkShader>;
57
- RadialGradient(props: RadialGradientProps): DeclarationNode<RadialGradientProps, SkShader>;
58
- SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps, SkShader>;
59
- TwoPointConicalGradient(props: TwoPointConicalGradientProps): DeclarationNode<TwoPointConicalGradientProps, SkShader>;
44
+ MatrixColorFilter(props: MatrixColorFilterProps): DeclarationNode<MatrixColorFilterProps>;
45
+ BlendColorFilter(props: BlendColorFilterProps): DeclarationNode<BlendColorFilterProps>;
46
+ LumaColorFilter(): DeclarationNode<null>;
47
+ LinearToSRGBGammaColorFilter(): DeclarationNode<null>;
48
+ SRGBToLinearGammaColorFilter(): DeclarationNode<null>;
49
+ LerpColorFilter(props: LerpColorFilterProps): DeclarationNode<LerpColorFilterProps>;
50
+ Shader(props: ShaderProps): DeclarationNode<ShaderProps>;
51
+ ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps>;
52
+ ColorShader(props: ColorProps): DeclarationNode<ColorProps>;
53
+ Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps>;
54
+ FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps>;
55
+ LinearGradient(props: LinearGradientProps): DeclarationNode<LinearGradientProps>;
56
+ RadialGradient(props: RadialGradientProps): DeclarationNode<RadialGradientProps>;
57
+ SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps>;
58
+ TwoPointConicalGradient(props: TwoPointConicalGradientProps): DeclarationNode<TwoPointConicalGradientProps>;
60
59
  CornerPathEffect(props: CornerPathEffectProps): NullablePathEffectNode<CornerPathEffectProps>;
61
60
  DiscretePathEffect(props: DiscretePathEffectProps): PathEffectNode<DiscretePathEffectProps>;
62
61
  DashPathEffect(props: DashPathEffectProps): PathEffectNode<DashPathEffectProps>;
@@ -64,9 +63,9 @@ export interface SkDOM {
64
63
  Path2DPathEffect(props: Path2DPathEffectProps): NullablePathEffectNode<Path2DPathEffectProps>;
65
64
  SumPathEffect(): NullablePathEffectNode<null>;
66
65
  Line2DPathEffect(props: Line2DPathEffectProps): NullablePathEffectNode<Line2DPathEffectProps>;
67
- Blend(props: BlendProps): DeclarationNode<BlendProps, SkShader | SkImageFilter>;
66
+ Blend(props: BlendProps): DeclarationNode<BlendProps>;
68
67
  BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;
69
68
  Box(props: BoxProps): RenderNode<BoxProps>;
70
- BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps, BoxShadowProps>;
69
+ BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps>;
71
70
  }
72
71
  export {};
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["SkDOM.ts"],"sourcesContent":["import type {\n SkImageFilter,\n SkMaskFilter,\n SkShader,\n SkColorFilter,\n SkPathEffect,\n SkPaint,\n} from \"../../skia/types\";\n\nimport type { ChildrenProps, GroupProps, PaintProps } from \"./Common\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n DisplacementMapImageFilterProps,\n MorphologyImageFilterProps,\n BlendProps,\n} from \"./ImageFilters\";\nimport type { DeclarationNode, RenderNode } from \"./Node\";\nimport type {\n BlendColorFilterProps,\n MatrixColorFilterProps,\n LerpColorFilterProps,\n} from \"./ColorFilters\";\nimport type {\n ImageProps,\n CircleProps,\n PathProps,\n CustomDrawingNodeProps,\n LineProps,\n OvalProps,\n PatchProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n VerticesProps,\n TextProps,\n DiffRectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n DrawingNodeProps,\n BoxProps,\n BoxShadowProps,\n} from \"./Drawings\";\nimport type { BlurMaskFilterProps } from \"./MaskFilters\";\nimport type {\n FractalNoiseProps,\n SweepGradientProps,\n ImageShaderProps,\n LinearGradientProps,\n ShaderProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n RadialGradientProps,\n ColorProps,\n} from \"./Shaders\";\nimport type {\n CornerPathEffectProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n} from \"./PathEffects\";\n\ntype ImageFilterNode<P> = DeclarationNode<P, SkImageFilter>;\n\ntype PathEffectNode<P> = DeclarationNode<P, SkPathEffect>;\ntype NullablePathEffectNode<P> = DeclarationNode<P, SkPathEffect, null>;\n\ntype DrawingNode<P extends GroupProps> = RenderNode<P>;\n\nexport interface SkDOM {\n Layer(props?: ChildrenProps): RenderNode<ChildrenProps>;\n Group(props?: GroupProps): RenderNode<GroupProps>;\n Paint(props: PaintProps): DeclarationNode<PaintProps, SkPaint>;\n\n // Drawings\n Fill(props?: DrawingNodeProps): DrawingNode<DrawingNodeProps>;\n Image(props: ImageProps): DrawingNode<ImageProps>;\n Circle(props: CircleProps): DrawingNode<CircleProps>;\n Path(props: PathProps): DrawingNode<PathProps>;\n CustomDrawing(\n props: CustomDrawingNodeProps\n ): DrawingNode<CustomDrawingNodeProps>;\n Line(props: LineProps): DrawingNode<LineProps>;\n Oval(props: OvalProps): DrawingNode<OvalProps>;\n Patch(props: PatchProps): DrawingNode<PatchProps>;\n Points(props: PointsProps): DrawingNode<PointsProps>;\n Rect(props: RectProps): DrawingNode<RectProps>;\n RRect(props: RoundedRectProps): DrawingNode<RoundedRectProps>;\n Vertices(props: VerticesProps): DrawingNode<VerticesProps>;\n Text(props: TextProps): DrawingNode<TextProps>;\n TextPath(props: TextPathProps): DrawingNode<TextPathProps>;\n TextBlob(props: TextBlobProps): DrawingNode<TextBlobProps>;\n Glyphs(props: GlyphsProps): DrawingNode<GlyphsProps>;\n DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;\n Picture(props: PictureProps): DrawingNode<PictureProps>;\n ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;\n\n // BlurMaskFilters\n BlurMaskFilter(\n props: BlurMaskFilterProps\n ): DeclarationNode<BlurMaskFilterProps, SkMaskFilter>;\n\n // ImageFilters\n BlendImageFilter(\n props: BlendImageFilterProps\n ): ImageFilterNode<BlendImageFilterProps>;\n BlurImageFilter(\n props: BlurImageFilterProps\n ): ImageFilterNode<BlurImageFilterProps>;\n OffsetImageFilter(\n props: OffsetImageFilterProps\n ): ImageFilterNode<OffsetImageFilterProps>;\n DropShadowImageFilter(\n props: DropShadowImageFilterProps\n ): ImageFilterNode<DropShadowImageFilterProps>;\n MorphologyImageFilter(\n props: MorphologyImageFilterProps\n ): ImageFilterNode<MorphologyImageFilterProps>;\n DisplacementMapImageFilter(\n props: DisplacementMapImageFilterProps\n ): ImageFilterNode<DisplacementMapImageFilterProps>;\n RuntimeShaderImageFilter(\n props: RuntimeShaderImageFilterProps\n ): ImageFilterNode<RuntimeShaderImageFilterProps>;\n\n // ColorFilters\n MatrixColorFilter(\n props: MatrixColorFilterProps\n ): DeclarationNode<MatrixColorFilterProps, SkColorFilter>;\n BlendColorFilter(\n props: BlendColorFilterProps\n ): DeclarationNode<BlendColorFilterProps, SkColorFilter>;\n LumaColorFilter(): DeclarationNode<null, SkColorFilter>;\n LinearToSRGBGammaColorFilter(): DeclarationNode<null, SkColorFilter>;\n SRGBToLinearGammaColorFilter(): DeclarationNode<null, SkColorFilter>;\n LerpColorFilter(\n props: LerpColorFilterProps\n ): DeclarationNode<LerpColorFilterProps, SkColorFilter>;\n\n // Shaders\n Shader(props: ShaderProps): DeclarationNode<ShaderProps, SkShader>;\n ImageShader(\n props: ImageShaderProps\n ): DeclarationNode<ImageShaderProps, SkShader>;\n ColorShader(props: ColorProps): DeclarationNode<ColorProps, SkShader>;\n Turbulence(\n props: TurbulenceProps\n ): DeclarationNode<TurbulenceProps, SkShader>;\n FractalNoise(\n props: FractalNoiseProps\n ): DeclarationNode<FractalNoiseProps, SkShader>;\n LinearGradient(\n props: LinearGradientProps\n ): DeclarationNode<LinearGradientProps, SkShader>;\n RadialGradient(\n props: RadialGradientProps\n ): DeclarationNode<RadialGradientProps, SkShader>;\n SweepGradient(\n props: SweepGradientProps\n ): DeclarationNode<SweepGradientProps, SkShader>;\n TwoPointConicalGradient(\n props: TwoPointConicalGradientProps\n ): DeclarationNode<TwoPointConicalGradientProps, SkShader>;\n\n // Path Effects\n CornerPathEffect(\n props: CornerPathEffectProps\n ): NullablePathEffectNode<CornerPathEffectProps>;\n DiscretePathEffect(\n props: DiscretePathEffectProps\n ): PathEffectNode<DiscretePathEffectProps>;\n DashPathEffect(\n props: DashPathEffectProps\n ): PathEffectNode<DashPathEffectProps>;\n Path1DPathEffect(\n props: Path1DPathEffectProps\n ): NullablePathEffectNode<Path1DPathEffectProps>;\n Path2DPathEffect(\n props: Path2DPathEffectProps\n ): NullablePathEffectNode<Path2DPathEffectProps>;\n SumPathEffect(): NullablePathEffectNode<null>;\n Line2DPathEffect(\n props: Line2DPathEffectProps\n ): NullablePathEffectNode<Line2DPathEffectProps>;\n\n // Mixed\n Blend(\n props: BlendProps\n ): DeclarationNode<BlendProps, SkShader | SkImageFilter>;\n BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;\n Box(props: BoxProps): RenderNode<BoxProps>;\n BoxShadow(\n props: BoxShadowProps\n ): DeclarationNode<BoxShadowProps, BoxShadowProps>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["SkDOM.ts"],"sourcesContent":["import type { ChildrenProps, GroupProps, PaintProps } from \"./Common\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n DisplacementMapImageFilterProps,\n MorphologyImageFilterProps,\n BlendProps,\n} from \"./ImageFilters\";\nimport type { DeclarationNode, RenderNode } from \"./Node\";\nimport type {\n BlendColorFilterProps,\n MatrixColorFilterProps,\n LerpColorFilterProps,\n} from \"./ColorFilters\";\nimport type {\n ImageProps,\n CircleProps,\n PathProps,\n CustomDrawingNodeProps,\n LineProps,\n OvalProps,\n PatchProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n VerticesProps,\n TextProps,\n DiffRectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n DrawingNodeProps,\n BoxProps,\n BoxShadowProps,\n} from \"./Drawings\";\nimport type { BlurMaskFilterProps } from \"./MaskFilters\";\nimport type {\n FractalNoiseProps,\n SweepGradientProps,\n ImageShaderProps,\n LinearGradientProps,\n ShaderProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n RadialGradientProps,\n ColorProps,\n} from \"./Shaders\";\nimport type {\n CornerPathEffectProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n} from \"./PathEffects\";\n\ntype ImageFilterNode<P> = DeclarationNode<P>;\n\ntype PathEffectNode<P> = DeclarationNode<P>;\ntype NullablePathEffectNode<P> = DeclarationNode<P>;\n\ntype DrawingNode<P extends GroupProps> = RenderNode<P>;\n\nexport interface SkDOM {\n Layer(props?: ChildrenProps): RenderNode<ChildrenProps>;\n Group(props?: GroupProps): RenderNode<GroupProps>;\n Paint(props: PaintProps): DeclarationNode<PaintProps>;\n\n // Drawings\n Fill(props?: DrawingNodeProps): DrawingNode<DrawingNodeProps>;\n Image(props: ImageProps): DrawingNode<ImageProps>;\n Circle(props: CircleProps): DrawingNode<CircleProps>;\n Path(props: PathProps): DrawingNode<PathProps>;\n CustomDrawing(\n props: CustomDrawingNodeProps\n ): DrawingNode<CustomDrawingNodeProps>;\n Line(props: LineProps): DrawingNode<LineProps>;\n Oval(props: OvalProps): DrawingNode<OvalProps>;\n Patch(props: PatchProps): DrawingNode<PatchProps>;\n Points(props: PointsProps): DrawingNode<PointsProps>;\n Rect(props: RectProps): DrawingNode<RectProps>;\n RRect(props: RoundedRectProps): DrawingNode<RoundedRectProps>;\n Vertices(props: VerticesProps): DrawingNode<VerticesProps>;\n Text(props: TextProps): DrawingNode<TextProps>;\n TextPath(props: TextPathProps): DrawingNode<TextPathProps>;\n TextBlob(props: TextBlobProps): DrawingNode<TextBlobProps>;\n Glyphs(props: GlyphsProps): DrawingNode<GlyphsProps>;\n DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;\n Picture(props: PictureProps): DrawingNode<PictureProps>;\n ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;\n\n // BlurMaskFilters\n BlurMaskFilter(\n props: BlurMaskFilterProps\n ): DeclarationNode<BlurMaskFilterProps>;\n\n // ImageFilters\n BlendImageFilter(\n props: BlendImageFilterProps\n ): ImageFilterNode<BlendImageFilterProps>;\n BlurImageFilter(\n props: BlurImageFilterProps\n ): ImageFilterNode<BlurImageFilterProps>;\n OffsetImageFilter(\n props: OffsetImageFilterProps\n ): ImageFilterNode<OffsetImageFilterProps>;\n DropShadowImageFilter(\n props: DropShadowImageFilterProps\n ): ImageFilterNode<DropShadowImageFilterProps>;\n MorphologyImageFilter(\n props: MorphologyImageFilterProps\n ): ImageFilterNode<MorphologyImageFilterProps>;\n DisplacementMapImageFilter(\n props: DisplacementMapImageFilterProps\n ): ImageFilterNode<DisplacementMapImageFilterProps>;\n RuntimeShaderImageFilter(\n props: RuntimeShaderImageFilterProps\n ): ImageFilterNode<RuntimeShaderImageFilterProps>;\n\n // ColorFilters\n MatrixColorFilter(\n props: MatrixColorFilterProps\n ): DeclarationNode<MatrixColorFilterProps>;\n BlendColorFilter(\n props: BlendColorFilterProps\n ): DeclarationNode<BlendColorFilterProps>;\n LumaColorFilter(): DeclarationNode<null>;\n LinearToSRGBGammaColorFilter(): DeclarationNode<null>;\n SRGBToLinearGammaColorFilter(): DeclarationNode<null>;\n LerpColorFilter(\n props: LerpColorFilterProps\n ): DeclarationNode<LerpColorFilterProps>;\n\n // Shaders\n Shader(props: ShaderProps): DeclarationNode<ShaderProps>;\n ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps>;\n ColorShader(props: ColorProps): DeclarationNode<ColorProps>;\n Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps>;\n FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps>;\n LinearGradient(\n props: LinearGradientProps\n ): DeclarationNode<LinearGradientProps>;\n RadialGradient(\n props: RadialGradientProps\n ): DeclarationNode<RadialGradientProps>;\n SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps>;\n TwoPointConicalGradient(\n props: TwoPointConicalGradientProps\n ): DeclarationNode<TwoPointConicalGradientProps>;\n\n // Path Effects\n CornerPathEffect(\n props: CornerPathEffectProps\n ): NullablePathEffectNode<CornerPathEffectProps>;\n DiscretePathEffect(\n props: DiscretePathEffectProps\n ): PathEffectNode<DiscretePathEffectProps>;\n DashPathEffect(\n props: DashPathEffectProps\n ): PathEffectNode<DashPathEffectProps>;\n Path1DPathEffect(\n props: Path1DPathEffectProps\n ): NullablePathEffectNode<Path1DPathEffectProps>;\n Path2DPathEffect(\n props: Path2DPathEffectProps\n ): NullablePathEffectNode<Path2DPathEffectProps>;\n SumPathEffect(): NullablePathEffectNode<null>;\n Line2DPathEffect(\n props: Line2DPathEffectProps\n ): NullablePathEffectNode<Line2DPathEffectProps>;\n\n // Mixed\n Blend(props: BlendProps): DeclarationNode<BlendProps>;\n BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;\n Box(props: BoxProps): RenderNode<BoxProps>;\n BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps>;\n}\n"],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  export * from "./DrawingContext";
2
+ export * from "./DeclarationContext";
2
3
  export * from "./Node";
3
4
  export * from "./NodeType";
4
5
  export * from "./SkDOM";
@@ -1,4 +1,5 @@
1
1
  export * from "./DrawingContext";
2
+ export * from "./DeclarationContext";
2
3
  export * from "./Node";
3
4
  export * from "./NodeType";
4
5
  export * from "./SkDOM";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./DrawingContext\";\nexport * from \"./Node\";\nexport * from \"./NodeType\";\nexport * from \"./SkDOM\";\nexport * from \"./Common\";\nexport * from \"./Drawings\";\nexport * from \"./ImageFilters\";\nexport * from \"./ColorFilters\";\nexport * from \"./MaskFilters\";\nexport * from \"./PathEffects\";\nexport * from \"./Shaders\";\n"],"mappings":"AAAA,cAAc,kBAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,WAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./DrawingContext\";\nexport * from \"./DeclarationContext\";\nexport * from \"./Node\";\nexport * from \"./NodeType\";\nexport * from \"./SkDOM\";\nexport * from \"./Common\";\nexport * from \"./Drawings\";\nexport * from \"./ImageFilters\";\nexport * from \"./ColorFilters\";\nexport * from \"./MaskFilters\";\nexport * from \"./PathEffects\";\nexport * from \"./Shaders\";\n"],"mappings":"AAAA,cAAc,kBAAd;AACA,cAAc,sBAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,WAAd"}
@@ -1,6 +1,7 @@
1
1
  import "./skia/NativeSetup";
2
2
  export * from "./renderer";
3
3
  export * from "./renderer/Canvas";
4
+ export * from "./renderer/Offscreen";
4
5
  export * from "./views";
5
6
  export * from "./skia";
6
7
  export * from "./external";
@@ -1,6 +1,7 @@
1
1
  import "./skia/NativeSetup";
2
2
  export * from "./renderer";
3
3
  export * from "./renderer/Canvas";
4
+ export * from "./renderer/Offscreen";
4
5
  export * from "./views";
5
6
  export * from "./skia";
6
7
  export * from "./external";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import \"./skia/NativeSetup\";\nexport * from \"./renderer\";\nexport * from \"./renderer/Canvas\";\nexport * from \"./views\";\nexport * from \"./skia\";\nexport * from \"./external\";\nexport * from \"./values\";\nexport * from \"./animation\";\nexport * from \"./dom/types\";\nexport * from \"./dom/nodes\";\n"],"mappings":"AAAA,OAAO,oBAAP;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,UAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import \"./skia/NativeSetup\";\nexport * from \"./renderer\";\nexport * from \"./renderer/Canvas\";\nexport * from \"./renderer/Offscreen\";\nexport * from \"./views\";\nexport * from \"./skia\";\nexport * from \"./external\";\nexport * from \"./values\";\nexport * from \"./animation\";\nexport * from \"./dom/types\";\nexport * from \"./dom/nodes\";\n"],"mappings":"AAAA,OAAO,oBAAP;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,sBAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,UAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd"}
@@ -23,11 +23,11 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
23
23
  (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.redraw();
24
24
  }, [innerRef]);
25
25
  const registerValues = useCallback(values => {
26
- if (ref.current === null) {
27
- throw new Error("Canvas ref is not set");
26
+ if (ref.current !== null) {
27
+ return ref.current.registerValues(values);
28
28
  }
29
29
 
30
- return ref.current.registerValues(values);
30
+ return () => {};
31
31
  }, [ref]);
32
32
  const root = useMemo(() => new SkiaRoot(Skia, registerValues, redraw), [redraw, registerValues]); // Render effect
33
33
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaRoot","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","registerValues","values","Error","root","render","unmount","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw),\n [redraw, registerValues]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\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vB,SAAS,CAAC,MAAM;IACd0B,IAAI,CAACC,MAAL,CAAYhB,QAAZ;EACD,CAFQ,EAEN,CAACA,QAAD,EAAWe,IAAX,EAAiBL,MAAjB,CAFM,CAAT;EAIArB,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX0B,IAAI,CAACE,OAAL;IACD,CAFD;EAGD,CAJQ,EAIN,CAACF,IAAD,CAJM,CAAT;EAMA,oBACE,oBAAC,WAAD;IACE,GAAG,EAAEP,GADP;IAEE,KAAK,EAAEP,KAFT;IAGE,IAAI,EAAEc,IAAI,CAACG,GAHb;IAIE,OAAO,EAAEd,OAJX;IAKE,MAAM,EAAEC,MALV;IAME,IAAI,EAAEF,IANR;IAOE,KAAK,EAAED;EAPT,GAQMI,KARN,EADF;AAYD,CAhD6B,CAAzB;AAmDP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAU,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGhC,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB8B,IAAI,CAACE,OAAL,CAAcb,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACY,SAAS,CAACT,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcS,SAAS,CAACT,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACQ,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaRoot","useCanvasRef","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","registerValues","values","root","render","unmount","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw),\n [redraw, registerValues]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAcA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAIA,SAASC,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMJ,MAAM,CAAc,IAAd,CAAjC;AAQP,OAAO,MAAMK,MAAM,gBAAGN,UAAU,CAC9B,OAEEO,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGV,YAAY,EAA7B;EACA,MAAMW,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAGpB,WAAW,CAAC,MAAM;IAAA;;IAC/B,qBAAAiB,QAAQ,CAACI,OAAT,wEAAkBD,MAAlB;EACD,CAFyB,EAEvB,CAACH,QAAD,CAFuB,CAA1B;EAIA,MAAMK,cAAc,GAAGtB,WAAW,CAC/BuB,MAAD,IAAuC;IACrC,IAAIL,GAAG,CAACG,OAAJ,KAAgB,IAApB,EAA0B;MACxB,OAAOH,GAAG,CAACG,OAAJ,CAAYC,cAAZ,CAA2BC,MAA3B,CAAP;IACD;;IACD,OAAO,MAAM,CAAE,CAAf;EACD,CAN+B,EAOhC,CAACL,GAAD,CAPgC,CAAlC;EASA,MAAMM,IAAI,GAAGvB,OAAO,CAClB,MAAM,IAAIK,QAAJ,CAAaD,IAAb,EAAmBiB,cAAnB,EAAmCF,MAAnC,CADY,EAElB,CAACA,MAAD,EAASE,cAAT,CAFkB,CAApB,CAhBG,CAqBH;;EACAvB,SAAS,CAAC,MAAM;IACdyB,IAAI,CAACC,MAAL,CAAYf,QAAZ;EACD,CAFQ,EAEN,CAACA,QAAD,EAAWc,IAAX,EAAiBJ,MAAjB,CAFM,CAAT;EAIArB,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXyB,IAAI,CAACE,OAAL;IACD,CAFD;EAGD,CAJQ,EAIN,CAACF,IAAD,CAJM,CAAT;EAMA,oBACE,oBAAC,WAAD;IACE,GAAG,EAAEN,GADP;IAEE,KAAK,EAAEP,KAFT;IAGE,IAAI,EAAEa,IAAI,CAACG,GAHb;IAIE,OAAO,EAAEb,OAJX;IAKE,MAAM,EAAEC,MALV;IAME,IAAI,EAAEF,IANR;IAOE,KAAK,EAAED;EAPT,GAQMI,KARN,EADF;AAYD,CAhD6B,CAAzB;AAmDP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAS,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAG/B,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB6B,IAAI,CAACE,OAAL,CAAcZ,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACW,SAAS,CAACR,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcQ,SAAS,CAACR,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACO,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -1,6 +1,7 @@
1
1
  import type { DrawingInfo } from "../views";
2
- import type { Skia } from "../skia/types";
3
- import type { DrawingContext as DOMDrawingContext } from "../dom/types";
4
- export interface DrawingContext extends Omit<DrawingInfo, "touches">, DOMDrawingContext {
2
+ import type { Skia, SkCanvas, SkPaint } from "../skia/types";
3
+ export interface DrawingContext extends Omit<DrawingInfo, "touches"> {
5
4
  Skia: Skia;
5
+ canvas: SkCanvas;
6
+ paint: SkPaint;
6
7
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { DrawingInfo } from \"../views\";\nimport type { Skia } from \"../skia/types\";\nimport type { DrawingContext as DOMDrawingContext } from \"../dom/types\";\n\nexport interface DrawingContext\n extends Omit<DrawingInfo, \"touches\">,\n DOMDrawingContext {\n Skia: Skia;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { DrawingInfo } from \"../views\";\nimport type { Skia, SkCanvas, SkPaint } from \"../skia/types\";\n\nexport interface DrawingContext extends Omit<DrawingInfo, \"touches\"> {\n Skia: Skia;\n canvas: SkCanvas;\n paint: SkPaint;\n}\n"],"mappings":""}