@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
@@ -18,7 +18,27 @@ class JsiSkSurfaceFactory extends _Host.Host {
18
18
  const surface = this.CanvasKit.MakeSurface(width, height);
19
19
 
20
20
  if (!surface) {
21
- throw new Error("Could not create surface");
21
+ return null;
22
+ }
23
+
24
+ return new _JsiSkSurface.JsiSkSurface(this.CanvasKit, surface);
25
+ }
26
+
27
+ MakeOffscreen(width, height) {
28
+ // OffscreenCanvas may be unvailable in some environments.
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const OC = globalThis.OffscreenCanvas;
31
+ let surface;
32
+
33
+ if (OC === undefined) {
34
+ surface = this.CanvasKit.MakeSurface(width, height);
35
+ } else {
36
+ const offscreen = new OC(width, height);
37
+ surface = this.CanvasKit.MakeWebGLCanvasSurface(offscreen);
38
+ }
39
+
40
+ if (!surface) {
41
+ return null;
22
42
  }
23
43
 
24
44
  return new _JsiSkSurface.JsiSkSurface(this.CanvasKit, surface);
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkSurfaceFactory","Host","constructor","CanvasKit","Make","width","height","surface","MakeSurface","Error","JsiSkSurface"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SurfaceFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n const surface = this.CanvasKit.MakeSurface(width, height);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,CAACC,KAAD,EAAgBC,MAAhB,EAAgC;IAClC,MAAMC,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAhB;;IACA,IAAI,CAACC,OAAL,EAAc;MACZ,MAAM,IAAIE,KAAJ,CAAU,0BAAV,CAAN;IACD;;IACD,OAAO,IAAIC,0BAAJ,CAAiB,KAAKP,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;AAXqE"}
1
+ {"version":3,"names":["JsiSkSurfaceFactory","Host","constructor","CanvasKit","Make","width","height","surface","MakeSurface","JsiSkSurface","MakeOffscreen","OC","globalThis","OffscreenCanvas","undefined","offscreen","MakeWebGLCanvasSurface"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SurfaceFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n const surface = this.CanvasKit.MakeSurface(width, height);\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n\n MakeOffscreen(width: number, height: number) {\n // OffscreenCanvas may be unvailable in some environments.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const OC = (globalThis as any).OffscreenCanvas;\n let surface: Surface | null;\n if (OC === undefined) {\n surface = this.CanvasKit.MakeSurface(width, height);\n } else {\n const offscreen = new OC(width, height);\n surface = this.CanvasKit.MakeWebGLCanvasSurface(\n offscreen as unknown as HTMLCanvasElement\n );\n }\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,CAACC,KAAD,EAAgBC,MAAhB,EAAgC;IAClC,MAAMC,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAhB;;IACA,IAAI,CAACC,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;EAEDG,aAAa,CAACL,KAAD,EAAgBC,MAAhB,EAAgC;IAC3C;IACA;IACA,MAAMK,EAAE,GAAIC,UAAD,CAAoBC,eAA/B;IACA,IAAIN,OAAJ;;IACA,IAAII,EAAE,KAAKG,SAAX,EAAsB;MACpBP,OAAO,GAAG,KAAKJ,SAAL,CAAeK,WAAf,CAA2BH,KAA3B,EAAkCC,MAAlC,CAAV;IACD,CAFD,MAEO;MACL,MAAMS,SAAS,GAAG,IAAIJ,EAAJ,CAAON,KAAP,EAAcC,MAAd,CAAlB;MACAC,OAAO,GAAG,KAAKJ,SAAL,CAAea,sBAAf,CACRD,SADQ,CAAV;IAGD;;IACD,IAAI,CAACR,OAAL,EAAc;MACZ,OAAO,IAAP;IACD;;IACD,OAAO,IAAIE,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCI,OAAjC,CAAP;EACD;;AA9BqE"}
@@ -114,9 +114,13 @@ class SkiaBaseWebView extends _react.default.Component {
114
114
 
115
115
 
116
116
  makeImageSnapshot(rect) {
117
- var _this$_surface;
117
+ var _this$_surface, _this$_surface2;
118
118
 
119
- return (_this$_surface = this._surface) === null || _this$_surface === void 0 ? void 0 : _this$_surface.makeImageSnapshot(rect);
119
+ this._canvas.clear(CanvasKit.TRANSPARENT);
120
+
121
+ this.renderInCanvas(this._canvas, []);
122
+ (_this$_surface = this._surface) === null || _this$_surface === void 0 ? void 0 : _this$_surface.ref.flush();
123
+ return (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.makeImageSnapshot(rect);
120
124
  }
121
125
  /**
122
126
  * Override to render
@@ -131,15 +135,17 @@ class SkiaBaseWebView extends _react.default.Component {
131
135
  this._redrawRequests = 0;
132
136
 
133
137
  if (this._canvas) {
134
- var _this$_surface2;
138
+ var _this$_surface3;
135
139
 
136
140
  const touches = [...this._touches];
137
141
  this._touches = [];
138
-
139
- this._canvas.clear(CanvasKit.TRANSPARENT);
140
-
141
- this.renderInCanvas(this._canvas, touches);
142
- (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.ref.flush();
142
+ const canvas = this._canvas;
143
+ canvas.clear(Float32Array.of(0, 0, 0, 0));
144
+ canvas.save();
145
+ canvas.scale(pd, pd);
146
+ this.renderInCanvas(canvas, touches);
147
+ canvas.restore();
148
+ (_this$_surface3 = this._surface) === null || _this$_surface3 === void 0 ? void 0 : _this$_surface3.ref.flush();
143
149
  }
144
150
  }
145
151
 
@@ -1 +1 @@
1
- {"version":3,"names":["pd","PixelRatio","get","SkiaBaseWebView","React","Component","constructor","props","createRef","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","CanvasKit","global","width","height","nativeEvent","layout","_canvasRef","current","canvas","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","makeImageSnapshot","rect","_redrawRequests","touches","_touches","clear","TRANSPARENT","renderInCanvas","ref","flush","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","createTouchHandler","render","debug","viewProps","display","flex","TouchType","Start","Active","End","Cancelled"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { PixelRatio, View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n const { width, height } = evt.nativeEvent.layout;\n this.width = width;\n this.height = height;\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n const canvas = this._canvasRef.current;\n canvas.width = width * pd;\n canvas.height = height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\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 return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, touches);\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\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 this._mode = mode;\n this.tick();\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: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.createTouchHandler(TouchType.Start)}\n onPointerMove={this.createTouchHandler(TouchType.Active)}\n onPointerUp={this.createTouchHandler(TouchType.End)}\n onPointerCancel={this.createTouchHandler(TouchType.Cancelled)}\n onPointerLeave={this.createTouchHandler(TouchType.End)}\n onPointerOut={this.createTouchHandler(TouchType.End)}\n />\n </View>\n );\n }\n}\n"],"mappings":";;;;;;;AACA;;AAGA;;AAIA;;AAGA;;;;;;;;AAEA,MAAMA,EAAE,GAAGC,uBAAA,CAAWC,GAAX,EAAX;;AAEO,MAAeC,eAAf,SAEGC,cAAA,CAAMC,SAFT,CAE2B;EAChCC,WAAW,CAACC,KAAD,EAAgB;IACzB,MAAMA,KAAN;;IADyB,kCAKa,IALb;;IAAA,0CAMmB,EANnB;;IAAA,kCAOU,EAPV;;IAAA,iCAQQ,IARR;;IAAA,iDASNH,cAAA,CAAMI,SAAN,EATM;;IAAA;;IAAA,yCAWD,CAX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AIE,aAAa,EAAE,KAAKP,kBAAL,CAAwBM,gBAAA,CAAUE,MAAlC,CAJjB;MAKE,WAAW,EAAE,KAAKR,kBAAL,CAAwBM,gBAAA,CAAUG,GAAlC,CALf;MAME,eAAe,EAAE,KAAKT,kBAAL,CAAwBM,gBAAA,CAAUI,SAAlC,CANnB;MAOE,cAAc,EAAE,KAAKV,kBAAL,CAAwBM,gBAAA,CAAUG,GAAlC,CAPlB;MAQE,YAAY,EAAE,KAAKT,kBAAL,CAAwBM,gBAAA,CAAUG,GAAlC;IARhB,EADF,CADF;EAcD;;AAvK+B"}
1
+ {"version":3,"names":["pd","PixelRatio","get","SkiaBaseWebView","React","Component","constructor","props","createRef","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","CanvasKit","global","width","height","nativeEvent","layout","_canvasRef","current","canvas","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","makeImageSnapshot","rect","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","touches","_touches","Float32Array","of","save","scale","restore","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","createTouchHandler","render","debug","viewProps","display","flex","TouchType","Start","Active","End","Cancelled"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { PixelRatio, View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n const { width, height } = evt.nativeEvent.layout;\n this.width = width;\n this.height = height;\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n const canvas = this._canvasRef.current;\n canvas.width = width * pd;\n canvas.height = height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\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 this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, []);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas, touches);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\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 this._mode = mode;\n this.tick();\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: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.createTouchHandler(TouchType.Start)}\n onPointerMove={this.createTouchHandler(TouchType.Active)}\n onPointerUp={this.createTouchHandler(TouchType.End)}\n onPointerCancel={this.createTouchHandler(TouchType.Cancelled)}\n onPointerLeave={this.createTouchHandler(TouchType.End)}\n onPointerOut={this.createTouchHandler(TouchType.End)}\n />\n </View>\n );\n }\n}\n"],"mappings":";;;;;;;AACA;;AAGA;;AAIA;;AAGA;;;;;;;;AAEA,MAAMA,EAAE,GAAGC,uBAAA,CAAWC,GAAX,EAAX;;AAEO,MAAeC,eAAf,SAEGC,cAAA,CAAMC,SAFT,CAE2B;EAChCC,WAAW,CAACC,KAAD,EAAgB;IACzB,MAAMA,KAAN;;IADyB,kCAKa,IALb;;IAAA,0CAMmB,EANnB;;IAAA,kCAOU,EAPV;;IAAA,iCAQQ,IARR;;IAAA,iDASNH,cAAA,CAAMI,SAAN,EATM;;IAAA;;IAAA,yCAWD,CAXC;;IAAA,mCAYP,CAZO;;IAAA,+BAcT,CAdS;;IAAA,gCAeR,CAfQ;;IAEzB,KAAKC,KAAL,GAAaF,KAAK,CAACG,IAAN,IAAc,SAA3B;EACD;;EAcOC,cAAc,GAAG;IACvB,KAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;IACA,KAAKF,gBAAL,GAAwB,EAAxB;EACD;;EAEOG,QAAQ,CAACC,GAAD,EAAyB;IACvC,MAAM;MAAEC;IAAF,IAAgBC,MAAtB;IACA,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBJ,GAAG,CAACK,WAAJ,CAAgBC,MAA1C;IACA,KAAKH,KAAL,GAAaA,KAAb;IACA,KAAKC,MAAL,GAAcA,MAAd,CAJuC,CAKvC;;IACA,IAAI,KAAKG,UAAL,CAAgBC,OAApB,EAA6B;MAC3B,MAAMC,MAAM,GAAG,KAAKF,UAAL,CAAgBC,OAA/B;MACAC,MAAM,CAACN,KAAP,GAAeA,KAAK,GAAGnB,EAAvB;MACAyB,MAAM,CAACL,MAAP,GAAgBA,MAAM,GAAGpB,EAAzB;MACA,MA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B,EADF,CADF;EAcD;;AA9K+B"}
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SkiaDomView = void 0;
7
7
 
8
- var _reactNative = require("react-native");
9
-
10
8
  var _skia = require("../skia");
11
9
 
12
- var _SkiaBaseWebView = require("./SkiaBaseWebView");
10
+ var _DrawingContext = require("../dom/types/DrawingContext");
13
11
 
14
- const pd = _reactNative.PixelRatio.get();
12
+ var _SkiaBaseWebView = require("./SkiaBaseWebView");
15
13
 
16
14
  class SkiaDomView extends _SkiaBaseWebView.SkiaBaseWebView {
17
15
  constructor(props) {
@@ -35,17 +33,8 @@ class SkiaDomView extends _SkiaBaseWebView.SkiaBaseWebView {
35
33
  }
36
34
 
37
35
  if (this.props.root) {
38
- const paint = _skia.Skia.Paint();
39
-
40
- const ctx = {
41
- canvas,
42
- paint,
43
- opacity: 1
44
- };
45
- canvas.save();
46
- canvas.scale(pd, pd);
36
+ const ctx = new _DrawingContext.JsiDrawingContext(_skia.Skia, canvas);
47
37
  this.props.root.render(ctx);
48
- canvas.restore();
49
38
  }
50
39
  }
51
40
 
@@ -1 +1 @@
1
- {"version":3,"names":["pd","PixelRatio","get","SkiaDomView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","touches","onTouch","onSize","width","height","getSize","current","root","paint","Skia","Paint","ctx","opacity","save","scale","render","restore"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { PixelRatio } from \"react-native\";\n\nimport { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type { SkiaDomViewProps, TouchInfo } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport class SkiaDomView extends SkiaBaseWebView<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas, touches: TouchInfo[]): void {\n if (this.props.onTouch) {\n this.props.onTouch([touches]);\n }\n if (this.props.onSize) {\n const { width, height } = this.getSize();\n this.props.onSize.current = { width, height };\n }\n if (this.props.root) {\n const paint = Skia.Paint();\n const ctx = {\n canvas,\n paint,\n opacity: 1,\n };\n canvas.save();\n canvas.scale(pd, pd);\n this.props.root.render(ctx);\n canvas.restore();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAGA,MAAMA,EAAE,GAAGC,uBAAA,CAAWC,GAAX,EAAX;;AAEO,MAAMC,WAAN,SAA0BC,gCAA1B,CAA4D;EACjEC,WAAW,CAACC,KAAD,EAA0B;IACnC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAmBC,OAAnB,EAA+C;IACrE,IAAI,KAAKH,KAAL,CAAWI,OAAf,EAAwB;MACtB,KAAKJ,KAAL,CAAWI,OAAX,CAAmB,CAACD,OAAD,CAAnB;IACD;;IACD,IAAI,KAAKH,KAAL,CAAWK,MAAf,EAAuB;MACrB,MAAM;QAAEC,KAAF;QAASC;MAAT,IAAoB,KAAKC,OAAL,EAA1B;MACA,KAAKR,KAAL,CAAWK,MAAX,CAAkBI,OAAlB,GAA4B;QAAEH,KAAF;QAASC;MAAT,CAA5B;IACD;;IACD,IAAI,KAAKP,KAAL,CAAWU,IAAf,EAAqB;MACnB,MAAMC,KAAK,GAAGC,UAAA,CAAKC,KAAL,EAAd;;MACA,MAAMC,GAAG,GAAG;QACVZ,MADU;QAEVS,KAFU;QAGVI,OAAO,EAAE;MAHC,CAAZ;MAKAb,MAAM,CAACc,IAAP;MACAd,MAAM,CAACe,KAAP,CAAavB,EAAb,EAAiBA,EAAjB;MACA,KAAKM,KAAL,CAAWU,IAAX,CAAgBQ,MAAhB,CAAuBJ,GAAvB;MACAZ,MAAM,CAACiB,OAAP;IACD;EACF;;AAzBgE"}
1
+ {"version":3,"names":["SkiaDomView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","touches","onTouch","onSize","width","height","getSize","current","root","ctx","JsiDrawingContext","Skia","render"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\nimport { JsiDrawingContext } from \"../dom/types/DrawingContext\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type { SkiaDomViewProps, TouchInfo } from \"./types\";\n\nexport class SkiaDomView extends SkiaBaseWebView<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas, touches: TouchInfo[]): void {\n if (this.props.onTouch) {\n this.props.onTouch([touches]);\n }\n if (this.props.onSize) {\n const { width, height } = this.getSize();\n this.props.onSize.current = { width, height };\n }\n if (this.props.root) {\n const ctx = new JsiDrawingContext(Skia, canvas);\n this.props.root.render(ctx);\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAGO,MAAMA,WAAN,SAA0BC,gCAA1B,CAA4D;EACjEC,WAAW,CAACC,KAAD,EAA0B;IACnC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAmBC,OAAnB,EAA+C;IACrE,IAAI,KAAKH,KAAL,CAAWI,OAAf,EAAwB;MACtB,KAAKJ,KAAL,CAAWI,OAAX,CAAmB,CAACD,OAAD,CAAnB;IACD;;IACD,IAAI,KAAKH,KAAL,CAAWK,MAAf,EAAuB;MACrB,MAAM;QAAEC,KAAF;QAASC;MAAT,IAAoB,KAAKC,OAAL,EAA1B;MACA,KAAKR,KAAL,CAAWK,MAAX,CAAkBI,OAAlB,GAA4B;QAAEH,KAAF;QAASC;MAAT,CAA5B;IACD;;IACD,IAAI,KAAKP,KAAL,CAAWU,IAAf,EAAqB;MACnB,MAAMC,GAAG,GAAG,IAAIC,iCAAJ,CAAsBC,UAAtB,EAA4BX,MAA5B,CAAZ;MACA,KAAKF,KAAL,CAAWU,IAAX,CAAgBI,MAAhB,CAAuBH,GAAvB;IACD;EACF;;AAjBgE"}
@@ -5,12 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SkiaPictureView = void 0;
7
7
 
8
- var _reactNative = require("react-native");
9
-
10
8
  var _SkiaBaseWebView = require("./SkiaBaseWebView");
11
9
 
12
- const pd = _reactNative.PixelRatio.get();
13
-
14
10
  class SkiaPictureView extends _SkiaBaseWebView.SkiaBaseWebView {
15
11
  constructor(props) {
16
12
  super(props);
@@ -18,10 +14,7 @@ class SkiaPictureView extends _SkiaBaseWebView.SkiaBaseWebView {
18
14
 
19
15
  renderInCanvas(canvas) {
20
16
  if (this.props.picture) {
21
- canvas.save();
22
- canvas.scale(pd, pd);
23
17
  canvas.drawPicture(this.props.picture);
24
- canvas.restore();
25
18
  }
26
19
  }
27
20
 
@@ -1 +1 @@
1
- {"version":3,"names":["pd","PixelRatio","get","SkiaPictureView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","picture","save","scale","drawPicture","restore"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import { PixelRatio } from \"react-native\";\n\nimport type { SkCanvas } from \"../skia/types\";\n\nimport type { SkiaPictureViewProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nconst pd = PixelRatio.get();\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewProps> {\n constructor(props: SkiaPictureViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.save();\n canvas.scale(pd, pd);\n canvas.drawPicture(this.props.picture);\n canvas.restore();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAEA,MAAMA,EAAE,GAAGC,uBAAA,CAAWC,GAAX,EAAX;;AAEO,MAAMC,eAAN,SAA8BC,gCAA9B,CAAoE;EACzEC,WAAW,CAACC,KAAD,EAA8B;IACvC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAyB;IAC/C,IAAI,KAAKF,KAAL,CAAWG,OAAf,EAAwB;MACtBD,MAAM,CAACE,IAAP;MACAF,MAAM,CAACG,KAAP,CAAaX,EAAb,EAAiBA,EAAjB;MACAQ,MAAM,CAACI,WAAP,CAAmB,KAAKN,KAAL,CAAWG,OAA9B;MACAD,MAAM,CAACK,OAAP;IACD;EACF;;AAZwE"}
1
+ {"version":3,"names":["SkiaPictureView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","picture","drawPicture"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type { SkiaPictureViewProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewProps> {\n constructor(props: SkiaPictureViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.drawPicture(this.props.picture);\n }\n }\n}\n"],"mappings":";;;;;;;AAGA;;AAEO,MAAMA,eAAN,SAA8BC,gCAA9B,CAAoE;EACzEC,WAAW,CAACC,KAAD,EAA8B;IACvC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAyB;IAC/C,IAAI,KAAKF,KAAL,CAAWG,OAAf,EAAwB;MACtBD,MAAM,CAACE,WAAP,CAAmB,KAAKJ,KAAL,CAAWG,OAA9B;IACD;EACF;;AATwE"}
@@ -5,12 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SkiaView = void 0;
7
7
 
8
- var _reactNative = require("react-native");
9
-
10
8
  var _SkiaBaseWebView = require("./SkiaBaseWebView");
11
9
 
12
- const pd = _reactNative.PixelRatio.get();
13
-
14
10
  class SkiaView extends _SkiaBaseWebView.SkiaBaseWebView {
15
11
  constructor(props) {
16
12
  super(props);
@@ -24,10 +20,7 @@ class SkiaView extends _SkiaBaseWebView.SkiaBaseWebView {
24
20
  timestamp: Date.now(),
25
21
  touches: touches.map(t => [t])
26
22
  };
27
- canvas.save();
28
- canvas.scale(pd, pd);
29
23
  this.props.onDraw(canvas, info);
30
- canvas.restore();
31
24
  }
32
25
  }
33
26
 
@@ -1 +1 @@
1
- {"version":3,"names":["pd","PixelRatio","get","SkiaView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","touches","onDraw","info","height","width","timestamp","Date","now","map","t","save","scale","restore"],"sources":["SkiaView.web.tsx"],"sourcesContent":["import { PixelRatio } from \"react-native\";\n\nimport type { SkCanvas } from \"../skia/types\";\n\nimport type { DrawingInfo, SkiaDrawViewProps, TouchInfo } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nconst pd = PixelRatio.get();\n\nexport class SkiaView extends SkiaBaseWebView<SkiaDrawViewProps> {\n constructor(props: SkiaDrawViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas, touches: TouchInfo[]): void {\n if (this.props.onDraw) {\n const info: DrawingInfo = {\n height: this.height,\n width: this.width,\n timestamp: Date.now(),\n touches: touches.map((t) => [t]),\n };\n canvas.save();\n canvas.scale(pd, pd);\n this.props.onDraw(canvas, info);\n canvas.restore();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAEA,MAAMA,EAAE,GAAGC,uBAAA,CAAWC,GAAX,EAAX;;AAEO,MAAMC,QAAN,SAAuBC,gCAAvB,CAA0D;EAC/DC,WAAW,CAACC,KAAD,EAA2B;IACpC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAmBC,OAAnB,EAA+C;IACrE,IAAI,KAAKH,KAAL,CAAWI,MAAf,EAAuB;MACrB,MAAMC,IAAiB,GAAG;QACxBC,MAAM,EAAE,KAAKA,MADW;QAExBC,KAAK,EAAE,KAAKA,KAFY;QAGxBC,SAAS,EAAEC,IAAI,CAACC,GAAL,EAHa;QAIxBP,OAAO,EAAEA,OAAO,CAACQ,GAAR,CAAaC,CAAD,IAAO,CAACA,CAAD,CAAnB;MAJe,CAA1B;MAMAV,MAAM,CAACW,IAAP;MACAX,MAAM,CAACY,KAAP,CAAapB,EAAb,EAAiBA,EAAjB;MACA,KAAKM,KAAL,CAAWI,MAAX,CAAkBF,MAAlB,EAA0BG,IAA1B;MACAH,MAAM,CAACa,OAAP;IACD;EACF;;AAlB8D"}
1
+ {"version":3,"names":["SkiaView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","touches","onDraw","info","height","width","timestamp","Date","now","map","t"],"sources":["SkiaView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type { DrawingInfo, SkiaDrawViewProps, TouchInfo } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaView extends SkiaBaseWebView<SkiaDrawViewProps> {\n constructor(props: SkiaDrawViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas, touches: TouchInfo[]): void {\n if (this.props.onDraw) {\n const info: DrawingInfo = {\n height: this.height,\n width: this.width,\n timestamp: Date.now(),\n touches: touches.map((t) => [t]),\n };\n this.props.onDraw(canvas, info);\n }\n }\n}\n"],"mappings":";;;;;;;AAGA;;AAEO,MAAMA,QAAN,SAAuBC,gCAAvB,CAA0D;EAC/DC,WAAW,CAACC,KAAD,EAA2B;IACpC,MAAMA,KAAN;EACD;;EAESC,cAAc,CAACC,MAAD,EAAmBC,OAAnB,EAA+C;IACrE,IAAI,KAAKH,KAAL,CAAWI,MAAf,EAAuB;MACrB,MAAMC,IAAiB,GAAG;QACxBC,MAAM,EAAE,KAAKA,MADW;QAExBC,KAAK,EAAE,KAAKA,KAFY;QAGxBC,SAAS,EAAEC,IAAI,CAACC,GAAL,EAHa;QAIxBP,OAAO,EAAEA,OAAO,CAACQ,GAAR,CAAaC,CAAD,IAAO,CAACA,CAAD,CAAnB;MAJe,CAA1B;MAMA,KAAKZ,KAAL,CAAWI,MAAX,CAAkBF,MAAlB,EAA0BG,IAA1B;IACD;EACF;;AAf8D"}
@@ -56,7 +56,11 @@ export class JsiDrawingNode extends JsiRenderNode {
56
56
 
57
57
  this.children().map(child => {
58
58
  if (child instanceof PaintNode) {
59
- const paint = child.materialize();
59
+ const declCtx = ctx.declarationCtx;
60
+ declCtx.save();
61
+ child.decorate(declCtx);
62
+ const paint = declCtx.paints.pop();
63
+ declCtx.restore();
60
64
  this.draw({ ...ctx,
61
65
  paint
62
66
  });
@@ -1 +1 @@
1
- {"version":3,"names":["JsiDeclarationNode","PaintNode","JsiRenderNode","JsiDrawingNode","constructor","ctx","type","props","derived","deriveProps","setProps","setProp","name","value","hasChanged","addChild","child","Error","insertChildBefore","before","renderNode","paint","draw","children","map","materialize"],"sources":["DrawingNode.ts"],"sourcesContent":["import type {\n DrawingContext,\n DrawingNodeProps,\n Node,\n NodeType,\n RenderNode,\n} from \"../types\";\n\nimport type { NodeContext } from \"./Node\";\nimport { JsiDeclarationNode } from \"./Node\";\nimport { PaintNode } from \"./PaintNode\";\nimport { JsiRenderNode } from \"./RenderNode\";\n\nexport abstract class JsiDrawingNode<P extends DrawingNodeProps, C>\n extends JsiRenderNode<P>\n implements RenderNode<P>\n{\n protected derived?: C;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.derived = this.deriveProps();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.derived = this.deriveProps();\n }\n\n setProp<K extends keyof P>(name: K, value: P[K]) {\n const hasChanged = super.setProp(name, value);\n if (hasChanged) {\n this.derived = this.deriveProps();\n }\n return hasChanged;\n }\n\n addChild(child: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add ${child.type} to ${this.type}`);\n }\n super.addChild(child);\n this.derived = this.deriveProps();\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add ${child.type} to ${this.type}`);\n }\n super.insertChildBefore(child, before);\n this.derived = this.deriveProps();\n }\n\n renderNode(ctx: DrawingContext): void {\n if (this.props.paint) {\n this.draw({ ...ctx, paint: this.props.paint });\n } else {\n this.draw(ctx);\n }\n this.children().map((child) => {\n if (child instanceof PaintNode) {\n const paint = child.materialize();\n this.draw({ ...ctx, paint });\n }\n });\n }\n\n protected abstract draw(ctx: DrawingContext): void;\n protected abstract deriveProps(): C;\n}\n"],"mappings":";;AASA,SAASA,kBAAT,QAAmC,QAAnC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA,OAAO,MAAeC,cAAf,SACGD,aADH,CAGP;EAGEE,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD;;IAEtD,KAAKC,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDC,QAAQ,CAACH,KAAD,EAAW;IACjB,MAAMG,QAAN,CAAeH,KAAf;IACA,KAAKC,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDE,OAAO,CAAoBC,IAApB,EAA6BC,KAA7B,EAA0C;IAC/C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,IAAd,EAAoBC,KAApB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKN,OAAL,GAAe,KAAKC,WAAL,EAAf;IACD;;IACD,OAAOK,UAAP;EACD;;EAEDC,QAAQ,CAACC,KAAD,EAA6B;IACnC,IAAI,EAAEA,KAAK,YAAYhB,kBAAnB,CAAJ,EAA4C;MAC1C,MAAM,IAAIiB,KAAJ,CAAW,cAAaD,KAAK,CAACV,IAAK,OAAM,KAAKA,IAAK,EAAnD,CAAN;IACD;;IACD,MAAMS,QAAN,CAAeC,KAAf;IACA,KAAKR,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDS,iBAAiB,CAACF,KAAD,EAAuBG,MAAvB,EAAoD;IACnE,IAAI,EAAEH,KAAK,YAAYhB,kBAAnB,CAAJ,EAA4C;MAC1C,MAAM,IAAIiB,KAAJ,CAAW,cAAaD,KAAK,CAACV,IAAK,OAAM,KAAKA,IAAK,EAAnD,CAAN;IACD;;IACD,MAAMY,iBAAN,CAAwBF,KAAxB,EAA+BG,MAA/B;IACA,KAAKX,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDW,UAAU,CAACf,GAAD,EAA4B;IACpC,IAAI,KAAKE,KAAL,CAAWc,KAAf,EAAsB;MACpB,KAAKC,IAAL,CAAU,EAAE,GAAGjB,GAAL;QAAUgB,KAAK,EAAE,KAAKd,KAAL,CAAWc;MAA5B,CAAV;IACD,CAFD,MAEO;MACL,KAAKC,IAAL,CAAUjB,GAAV;IACD;;IACD,KAAKkB,QAAL,GAAgBC,GAAhB,CAAqBR,KAAD,IAAW;MAC7B,IAAIA,KAAK,YAAYf,SAArB,EAAgC;QAC9B,MAAMoB,KAAK,GAAGL,KAAK,CAACS,WAAN,EAAd;QACA,KAAKH,IAAL,CAAU,EAAE,GAAGjB,GAAL;UAAUgB;QAAV,CAAV;MACD;IACF,CALD;EAMD;;AAjDH"}
1
+ {"version":3,"names":["JsiDeclarationNode","PaintNode","JsiRenderNode","JsiDrawingNode","constructor","ctx","type","props","derived","deriveProps","setProps","setProp","name","value","hasChanged","addChild","child","Error","insertChildBefore","before","renderNode","paint","draw","children","map","declCtx","declarationCtx","save","decorate","paints","pop","restore"],"sources":["DrawingNode.ts"],"sourcesContent":["import type {\n DrawingContext,\n DrawingNodeProps,\n Node,\n NodeType,\n RenderNode,\n} from \"../types\";\n\nimport type { NodeContext } from \"./Node\";\nimport { JsiDeclarationNode } from \"./Node\";\nimport { PaintNode } from \"./PaintNode\";\nimport { JsiRenderNode } from \"./RenderNode\";\n\nexport abstract class JsiDrawingNode<P extends DrawingNodeProps, C>\n extends JsiRenderNode<P>\n implements RenderNode<P>\n{\n protected derived?: C;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.derived = this.deriveProps();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.derived = this.deriveProps();\n }\n\n setProp<K extends keyof P>(name: K, value: P[K]) {\n const hasChanged = super.setProp(name, value);\n if (hasChanged) {\n this.derived = this.deriveProps();\n }\n return hasChanged;\n }\n\n addChild(child: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add ${child.type} to ${this.type}`);\n }\n super.addChild(child);\n this.derived = this.deriveProps();\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add ${child.type} to ${this.type}`);\n }\n super.insertChildBefore(child, before);\n this.derived = this.deriveProps();\n }\n\n renderNode(ctx: DrawingContext): void {\n if (this.props.paint) {\n this.draw({ ...ctx, paint: this.props.paint });\n } else {\n this.draw(ctx);\n }\n this.children().map((child) => {\n if (child instanceof PaintNode) {\n const declCtx = ctx.declarationCtx;\n declCtx.save();\n child.decorate(declCtx);\n const paint = declCtx.paints.pop()!;\n declCtx.restore();\n this.draw({ ...ctx, paint });\n }\n });\n }\n\n protected abstract draw(ctx: DrawingContext): void;\n protected abstract deriveProps(): C;\n}\n"],"mappings":";;AASA,SAASA,kBAAT,QAAmC,QAAnC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA,OAAO,MAAeC,cAAf,SACGD,aADH,CAGP;EAGEE,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD;;IAEtD,KAAKC,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDC,QAAQ,CAACH,KAAD,EAAW;IACjB,MAAMG,QAAN,CAAeH,KAAf;IACA,KAAKC,OAAL,GAAe,KAAKC,WAAL,EAAf;EACD;;EAEDE,OAAO,CAAoBC,IAApB,EAA6BC,KAA7B,EAA0C;IAC/C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,IAAd,EAAoBC,KAApB,CAAnB;;IACA,IAA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,GAAL;UAAUgB;QAAV,CAAV;MACD;IACF,CATD;EAUD;;AArDH"}
@@ -1,14 +1,13 @@
1
1
  import type { PathProps, SkDOM, GroupProps, ImageProps, BlurImageFilterProps, MatrixColorFilterProps, CircleProps, BlurMaskFilterProps, LinearGradientProps, PaintProps, ShaderProps, ImageShaderProps, CustomDrawingNodeProps, LineProps, OvalProps, PatchProps, PointsProps, RectProps, RoundedRectProps, VerticesProps, TextProps, DiffRectProps, OffsetImageFilterProps, BlendColorFilterProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, FractalNoiseProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, DrawingNodeProps, BoxProps, BoxShadowProps, ChildrenProps } from "../types";
2
2
  import type { BlendImageFilterProps, BlendProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, RuntimeShaderImageFilterProps } from "../types/ImageFilters";
3
3
  import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "../types/PathEffects";
4
- import { CornerPathEffectNode, Path1DPathEffectNode, Path2DPathEffectNode, Line2DPathEffectNode, BlendNode } from "./paint";
5
4
  import type { NodeContext } from "./Node";
6
5
  export declare class JsiSkDOM implements SkDOM {
7
6
  private ctx;
8
7
  constructor(ctx: NodeContext);
9
8
  Layer(props?: ChildrenProps): import("../types").RenderNode<ChildrenProps>;
10
9
  Group(props?: GroupProps): import("../types").RenderNode<GroupProps>;
11
- Paint(props: PaintProps): import("../types").DeclarationNode<PaintProps, import("../..").SkPaint, never>;
10
+ Paint(props: PaintProps): import("../types").DeclarationNode<PaintProps>;
12
11
  Fill(props?: DrawingNodeProps): import("../types").RenderNode<PaintProps>;
13
12
  Image(props: ImageProps): import("../types").RenderNode<ImageProps>;
14
13
  Circle(props: CircleProps): import("../types").RenderNode<CircleProps>;
@@ -28,38 +27,38 @@ export declare class JsiSkDOM implements SkDOM {
28
27
  DiffRect(props: DiffRectProps): import("../types").RenderNode<DiffRectProps>;
29
28
  Picture(props: PictureProps): import("../types").RenderNode<PictureProps>;
30
29
  ImageSVG(props: ImageSVGProps): import("../types").RenderNode<ImageSVGProps>;
31
- BlurMaskFilter(props: BlurMaskFilterProps): import("../types").DeclarationNode<BlurMaskFilterProps, import("../..").SkMaskFilter, never>;
32
- BlendImageFilter(props: BlendImageFilterProps): import("../types").DeclarationNode<BlendImageFilterProps, import("../..").SkImageFilter, never>;
33
- DropShadowImageFilter(props: DropShadowImageFilterProps): import("../types").DeclarationNode<DropShadowImageFilterProps, import("../..").SkImageFilter, never>;
34
- DisplacementMapImageFilter(props: DisplacementMapImageFilterProps): import("../types").DeclarationNode<DisplacementMapImageFilterProps, import("../..").SkImageFilter, never>;
35
- BlurImageFilter(props: BlurImageFilterProps): import("../types").DeclarationNode<BlurImageFilterProps, import("../..").SkImageFilter, never>;
36
- OffsetImageFilter(props: OffsetImageFilterProps): import("../types").DeclarationNode<OffsetImageFilterProps, import("../..").SkImageFilter, never>;
37
- MorphologyImageFilter(props: MorphologyImageFilterProps): import("../types").DeclarationNode<MorphologyImageFilterProps, import("../..").SkImageFilter, never>;
38
- RuntimeShaderImageFilter(props: RuntimeShaderImageFilterProps): import("../types").DeclarationNode<RuntimeShaderImageFilterProps, import("../..").SkImageFilter, never>;
39
- MatrixColorFilter(props: MatrixColorFilterProps): import("../types").DeclarationNode<MatrixColorFilterProps, import("../..").SkColorFilter, never>;
40
- BlendColorFilter(props: BlendColorFilterProps): import("../types").DeclarationNode<BlendColorFilterProps, import("../..").SkColorFilter, never>;
41
- LumaColorFilter(): import("../types").DeclarationNode<null, import("../..").SkColorFilter, never>;
42
- LinearToSRGBGammaColorFilter(): import("../types").DeclarationNode<null, import("../..").SkColorFilter, never>;
43
- SRGBToLinearGammaColorFilter(): import("../types").DeclarationNode<null, import("../..").SkColorFilter, never>;
44
- LerpColorFilter(props: LerpColorFilterProps): import("../types").DeclarationNode<LerpColorFilterProps, import("../..").SkColorFilter, never>;
45
- Shader(props: ShaderProps): import("../types").DeclarationNode<ShaderProps, import("../..").SkShader, never>;
46
- ImageShader(props: ImageShaderProps): import("../types").DeclarationNode<ImageShaderProps, import("../..").SkShader, never>;
47
- ColorShader(props: ColorProps): import("../types").DeclarationNode<ColorProps, import("../..").SkShader, never>;
48
- SweepGradient(props: SweepGradientProps): import("../types").DeclarationNode<SweepGradientProps, import("../..").SkShader, never>;
49
- Turbulence(props: TurbulenceProps): import("../types").DeclarationNode<TurbulenceProps, import("../..").SkShader, never>;
50
- FractalNoise(props: FractalNoiseProps): import("../types").DeclarationNode<FractalNoiseProps, import("../..").SkShader, never>;
51
- LinearGradient(props: LinearGradientProps): import("../types").DeclarationNode<LinearGradientProps, import("../..").SkShader, never>;
52
- RadialGradient(props: RadialGradientProps): import("../types").DeclarationNode<RadialGradientProps, import("../..").SkShader, never>;
53
- TwoPointConicalGradient(props: TwoPointConicalGradientProps): import("../types").DeclarationNode<TwoPointConicalGradientProps, import("../..").SkShader, never>;
54
- CornerPathEffect(props: CornerPathEffectProps): CornerPathEffectNode | import("../types").DeclarationNode<CornerPathEffectProps, import("../..").SkPathEffect, never>;
55
- DiscretePathEffect(props: DiscretePathEffectProps): import("../types").DeclarationNode<DiscretePathEffectProps, import("../..").SkPathEffect, never>;
56
- DashPathEffect(props: DashPathEffectProps): import("../types").DeclarationNode<DashPathEffectProps, import("../..").SkPathEffect, never>;
57
- Path1DPathEffect(props: Path1DPathEffectProps): Path1DPathEffectNode | import("../types").DeclarationNode<Path1DPathEffectProps, import("../..").SkPathEffect, never>;
58
- Path2DPathEffect(props: Path2DPathEffectProps): Path2DPathEffectNode | import("../types").DeclarationNode<Path2DPathEffectProps, import("../..").SkPathEffect, never>;
59
- SumPathEffect(): import("../types").DeclarationNode<null, import("../..").SkPathEffect, never>;
60
- Line2DPathEffect(props: Line2DPathEffectProps): Line2DPathEffectNode | import("../types").DeclarationNode<Line2DPathEffectProps, import("../..").SkPathEffect, never>;
61
- Blend(props: BlendProps): BlendNode | import("../types").DeclarationNode<BlendProps, import("../..").SkImageFilter, never>;
30
+ BlurMaskFilter(props: BlurMaskFilterProps): import("../types").DeclarationNode<BlurMaskFilterProps>;
31
+ BlendImageFilter(props: BlendImageFilterProps): import("../types").DeclarationNode<BlendImageFilterProps>;
32
+ DropShadowImageFilter(props: DropShadowImageFilterProps): import("../types").DeclarationNode<DropShadowImageFilterProps>;
33
+ DisplacementMapImageFilter(props: DisplacementMapImageFilterProps): import("../types").DeclarationNode<DisplacementMapImageFilterProps>;
34
+ BlurImageFilter(props: BlurImageFilterProps): import("../types").DeclarationNode<BlurImageFilterProps>;
35
+ OffsetImageFilter(props: OffsetImageFilterProps): import("../types").DeclarationNode<OffsetImageFilterProps>;
36
+ MorphologyImageFilter(props: MorphologyImageFilterProps): import("../types").DeclarationNode<MorphologyImageFilterProps>;
37
+ RuntimeShaderImageFilter(props: RuntimeShaderImageFilterProps): import("../types").DeclarationNode<RuntimeShaderImageFilterProps>;
38
+ MatrixColorFilter(props: MatrixColorFilterProps): import("../types").DeclarationNode<MatrixColorFilterProps>;
39
+ BlendColorFilter(props: BlendColorFilterProps): import("../types").DeclarationNode<BlendColorFilterProps>;
40
+ LumaColorFilter(): import("../types").DeclarationNode<null>;
41
+ LinearToSRGBGammaColorFilter(): import("../types").DeclarationNode<null>;
42
+ SRGBToLinearGammaColorFilter(): import("../types").DeclarationNode<null>;
43
+ LerpColorFilter(props: LerpColorFilterProps): import("../types").DeclarationNode<LerpColorFilterProps>;
44
+ Shader(props: ShaderProps): import("../types").DeclarationNode<ShaderProps>;
45
+ ImageShader(props: ImageShaderProps): import("../types").DeclarationNode<ImageShaderProps>;
46
+ ColorShader(props: ColorProps): import("../types").DeclarationNode<ColorProps>;
47
+ SweepGradient(props: SweepGradientProps): import("../types").DeclarationNode<SweepGradientProps>;
48
+ Turbulence(props: TurbulenceProps): import("../types").DeclarationNode<TurbulenceProps>;
49
+ FractalNoise(props: FractalNoiseProps): import("../types").DeclarationNode<FractalNoiseProps>;
50
+ LinearGradient(props: LinearGradientProps): import("../types").DeclarationNode<LinearGradientProps>;
51
+ RadialGradient(props: RadialGradientProps): import("../types").DeclarationNode<RadialGradientProps>;
52
+ TwoPointConicalGradient(props: TwoPointConicalGradientProps): import("../types").DeclarationNode<TwoPointConicalGradientProps>;
53
+ CornerPathEffect(props: CornerPathEffectProps): import("../types").DeclarationNode<CornerPathEffectProps>;
54
+ DiscretePathEffect(props: DiscretePathEffectProps): import("../types").DeclarationNode<DiscretePathEffectProps>;
55
+ DashPathEffect(props: DashPathEffectProps): import("../types").DeclarationNode<DashPathEffectProps>;
56
+ Path1DPathEffect(props: Path1DPathEffectProps): import("../types").DeclarationNode<Path1DPathEffectProps>;
57
+ Path2DPathEffect(props: Path2DPathEffectProps): import("../types").DeclarationNode<Path2DPathEffectProps>;
58
+ SumPathEffect(): import("../types").DeclarationNode<null>;
59
+ Line2DPathEffect(props: Line2DPathEffectProps): import("../types").DeclarationNode<Line2DPathEffectProps>;
60
+ Blend(props: BlendProps): import("../types").DeclarationNode<BlendProps>;
62
61
  BackdropFilter(props: ChildrenProps): import("../types").RenderNode<ChildrenProps>;
63
62
  Box(props: BoxProps): import("../types").RenderNode<BoxProps>;
64
- BoxShadow(props: BoxShadowProps): import("../types").DeclarationNode<BoxShadowProps, BoxShadowProps, never>;
63
+ BoxShadow(props: BoxShadowProps): import("../types").DeclarationNode<BoxShadowProps>;
65
64
  }
@@ -1,20 +1,26 @@
1
1
  import { NodeType } from "../types";
2
2
  import { JsiRenderNode } from "./RenderNode";
3
3
  import { JsiDeclarationNode } from "./Node";
4
-
5
- const isLayer = node => node instanceof JsiDeclarationNode && node.isPaint();
6
-
7
4
  export class LayerNode extends JsiRenderNode {
8
5
  constructor(ctx, props) {
9
6
  super(ctx, NodeType.Layer, props);
10
7
  }
11
8
 
12
9
  renderNode(ctx) {
10
+ let hasLayer = false;
13
11
  const [layer, ...children] = this.children();
14
12
 
15
- if (isLayer(layer)) {
16
- const paint = layer.materialize();
17
- ctx.canvas.saveLayer(paint);
13
+ if (layer instanceof JsiDeclarationNode) {
14
+ const declCtx = ctx.declarationCtx;
15
+ declCtx.save();
16
+ layer.decorate(declCtx);
17
+ const paint = declCtx.paints.pop();
18
+ declCtx.restore();
19
+
20
+ if (paint) {
21
+ hasLayer = true;
22
+ ctx.canvas.saveLayer(paint);
23
+ }
18
24
  }
19
25
 
20
26
  children.map(child => {
@@ -23,7 +29,7 @@ export class LayerNode extends JsiRenderNode {
23
29
  }
24
30
  });
25
31
 
26
- if (isLayer(layer)) {
32
+ if (hasLayer) {
27
33
  ctx.canvas.restore();
28
34
  }
29
35
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NodeType","JsiRenderNode","JsiDeclarationNode","isLayer","node","isPaint","LayerNode","constructor","ctx","props","Layer","renderNode","layer","children","paint","materialize","canvas","saveLayer","map","child","render","restore"],"sources":["LayerNode.ts"],"sourcesContent":["import type { DeclarationNode, DrawingContext, Node } from \"../types\";\nimport { NodeType } from \"../types\";\nimport type { ChildrenProps } from \"../types/Common\";\nimport type { SkPaint } from \"../../skia\";\n\nimport { JsiRenderNode } from \"./RenderNode\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiDeclarationNode } from \"./Node\";\n\nconst isLayer = (\n node: Node<unknown>\n): node is DeclarationNode<unknown, SkPaint> =>\n node instanceof JsiDeclarationNode && node.isPaint();\n\nexport class LayerNode extends JsiRenderNode<ChildrenProps> {\n constructor(ctx: NodeContext, props: ChildrenProps) {\n super(ctx, NodeType.Layer, props);\n }\n\n renderNode(ctx: DrawingContext): void {\n const [layer, ...children] = this.children();\n if (isLayer(layer)) {\n const paint = layer.materialize() as SkPaint;\n ctx.canvas.saveLayer(paint);\n }\n children.map((child) => {\n if (child instanceof JsiRenderNode) {\n child.render(ctx);\n }\n });\n if (isLayer(layer)) {\n ctx.canvas.restore();\n }\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,UAAzB;AAIA,SAASC,aAAT,QAA8B,cAA9B;AAEA,SAASC,kBAAT,QAAmC,QAAnC;;AAEA,MAAMC,OAAO,GACXC,IADc,IAGdA,IAAI,YAAYF,kBAAhB,IAAsCE,IAAI,CAACC,OAAL,EAHxC;;AAKA,OAAO,MAAMC,SAAN,SAAwBL,aAAxB,CAAqD;EAC1DM,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWR,QAAQ,CAACU,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,UAAU,CAACH,GAAD,EAA4B;IACpC,MAAM,CAACI,KAAD,EAAQ,GAAGC,QAAX,IAAuB,KAAKA,QAAL,EAA7B;;IACA,IAAIV,OAAO,CAACS,KAAD,CAAX,EAAoB;MAClB,MAAME,KAAK,GAAGF,KAAK,CAACG,WAAN,EAAd;MACAP,GAAG,CAACQ,MAAJ,CAAWC,SAAX,CAAqBH,KAArB;IACD;;IACDD,QAAQ,CAACK,GAAT,CAAcC,KAAD,IAAW;MACtB,IAAIA,KAAK,YAAYlB,aAArB,EAAoC;QAClCkB,KAAK,CAACC,MAAN,CAAaZ,GAAb;MACD;IACF,CAJD;;IAKA,IAAIL,OAAO,CAACS,KAAD,CAAX,EAAoB;MAClBJ,GAAG,CAACQ,MAAJ,CAAWK,OAAX;IACD;EACF;;AAnByD"}
1
+ {"version":3,"names":["NodeType","JsiRenderNode","JsiDeclarationNode","LayerNode","constructor","ctx","props","Layer","renderNode","hasLayer","layer","children","declCtx","declarationCtx","save","decorate","paint","paints","pop","restore","canvas","saveLayer","map","child","render"],"sources":["LayerNode.ts"],"sourcesContent":["import type { DrawingContext } from \"../types\";\nimport { NodeType } from \"../types\";\nimport type { ChildrenProps } from \"../types/Common\";\n\nimport { JsiRenderNode } from \"./RenderNode\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiDeclarationNode } from \"./Node\";\n\nexport class LayerNode extends JsiRenderNode<ChildrenProps> {\n constructor(ctx: NodeContext, props: ChildrenProps) {\n super(ctx, NodeType.Layer, props);\n }\n\n renderNode(ctx: DrawingContext): void {\n let hasLayer = false;\n const [layer, ...children] = this.children();\n if (layer instanceof JsiDeclarationNode) {\n const declCtx = ctx.declarationCtx;\n declCtx.save();\n layer.decorate(declCtx);\n const paint = declCtx.paints.pop();\n declCtx.restore();\n if (paint) {\n hasLayer = true;\n ctx.canvas.saveLayer(paint);\n }\n }\n children.map((child) => {\n if (child instanceof JsiRenderNode) {\n child.render(ctx);\n }\n });\n if (hasLayer) {\n ctx.canvas.restore();\n }\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,UAAzB;AAGA,SAASC,aAAT,QAA8B,cAA9B;AAEA,SAASC,kBAAT,QAAmC,QAAnC;AAEA,OAAO,MAAMC,SAAN,SAAwBF,aAAxB,CAAqD;EAC1DG,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWL,QAAQ,CAACO,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,UAAU,CAACH,GAAD,EAA4B;IACpC,IAAII,QAAQ,GAAG,KAAf;IACA,MAAM,CAACC,KAAD,EAAQ,GAAGC,QAAX,IAAuB,KAAKA,QAAL,EAA7B;;IACA,IAAID,KAAK,YAAYR,kBAArB,EAAyC;MACvC,MAAMU,OAAO,GAAGP,GAAG,CAACQ,cAApB;MACAD,OAAO,CAACE,IAAR;MACAJ,KAAK,CAACK,QAAN,CAAeH,OAAf;MACA,MAAMI,KAAK,GAAGJ,OAAO,CAACK,MAAR,CAAeC,GAAf,EAAd;MACAN,OAAO,CAACO,OAAR;;MACA,IAAIH,KAAJ,EAAW;QACTP,QAAQ,GAAG,IAAX;QACAJ,GAAG,CAACe,MAAJ,CAAWC,SAAX,CAAqBL,KAArB;MACD;IACF;;IACDL,QAAQ,CAACW,GAAT,CAAcC,KAAD,IAAW;MACtB,IAAIA,KAAK,YAAYtB,aAArB,EAAoC;QAClCsB,KAAK,CAACC,MAAN,CAAanB,GAAb;MACD;IACF,CAJD;;IAKA,IAAII,QAAJ,EAAc;MACZJ,GAAG,CAACe,MAAJ,CAAWD,OAAX;IACD;EACF;;AA3ByD"}
@@ -1,7 +1,7 @@
1
- import type { SkColorFilter, Skia, SkImageFilter, SkMaskFilter, SkShader, SkPathEffect, SkPaint } from "../../skia/types";
2
- import type { Node, DeclarationNode, NodeType } from "../types";
3
- import { DeclarationType } from "../types";
1
+ import type { Skia } from "../../skia/types";
2
+ import type { Node, DeclarationNode, NodeType, DeclarationType } from "../types";
4
3
  import type { DependencyManager } from "../../renderer/DependencyManager";
4
+ import type { DeclarationContext } from "../types/DeclarationContext";
5
5
  export interface NodeContext {
6
6
  Skia: Skia;
7
7
  depMgr: DependencyManager;
@@ -23,21 +23,16 @@ export declare abstract class JsiNode<P> implements Node<P> {
23
23
  insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
24
24
  }
25
25
  export declare type Invalidate = () => void;
26
- export declare abstract class JsiDeclarationNode<P, T, Nullable extends null | never = never> extends JsiNode<P> implements DeclarationNode<P, T, Nullable> {
26
+ export declare abstract class JsiDeclarationNode<P> extends JsiNode<P> implements DeclarationNode<P> {
27
27
  declarationType: DeclarationType;
28
28
  private invalidate;
29
29
  constructor(ctx: NodeContext, declarationType: DeclarationType, type: NodeType, props: P);
30
- abstract materialize(): T | Nullable;
30
+ abstract decorate(ctx: DeclarationContext): void;
31
+ protected decorateChildren(ctx: DeclarationContext): void;
31
32
  addChild(child: Node<unknown>): void;
32
33
  insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
33
34
  dispose(): void;
34
35
  setInvalidate(invalidate: Invalidate): void;
35
36
  setProps(props: P): void;
36
37
  setProp<K extends keyof P>(name: K, v: P[K]): boolean;
37
- isPaint(): this is DeclarationNode<unknown, SkPaint>;
38
- isImageFilter(): this is DeclarationNode<unknown, SkImageFilter>;
39
- isColorFilter(): this is DeclarationNode<unknown, SkColorFilter>;
40
- isShader(): this is DeclarationNode<unknown, SkShader>;
41
- isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter>;
42
- isPathEffect(): this is DeclarationNode<unknown, SkPathEffect>;
43
38
  }
@@ -1,6 +1,5 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import { DeclarationType } from "../types";
4
3
  export class JsiNode {
5
4
  constructor(ctx, type, props) {
6
5
  this.type = type;
@@ -75,6 +74,14 @@ export class JsiDeclarationNode extends JsiNode {
75
74
  _defineProperty(this, "invalidate", () => {});
76
75
  }
77
76
 
77
+ decorateChildren(ctx) {
78
+ this.children().forEach(child => {
79
+ if (child instanceof JsiDeclarationNode) {
80
+ child.decorate(ctx);
81
+ }
82
+ });
83
+ }
84
+
78
85
  addChild(child) {
79
86
  if (!(child instanceof JsiDeclarationNode)) {
80
87
  throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
@@ -117,29 +124,5 @@ export class JsiDeclarationNode extends JsiNode {
117
124
  return hasChanged;
118
125
  }
119
126
 
120
- isPaint() {
121
- return this.declarationType === DeclarationType.Paint;
122
- }
123
-
124
- isImageFilter() {
125
- return this.declarationType === DeclarationType.ImageFilter;
126
- }
127
-
128
- isColorFilter() {
129
- return this.declarationType === DeclarationType.ColorFilter;
130
- }
131
-
132
- isShader() {
133
- return this.declarationType === DeclarationType.Shader;
134
- }
135
-
136
- isMaskFilter() {
137
- return this.declarationType === DeclarationType.MaskFilter;
138
- }
139
-
140
- isPathEffect() {
141
- return this.declarationType === DeclarationType.PathEffect;
142
- }
143
-
144
127
  }
145
128
  //# sourceMappingURL=Node.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DeclarationType","JsiNode","constructor","ctx","type","props","Skia","depMgr","setProps","setProp","name","v","hasChanged","getProps","children","_children","addChild","child","push","dispose","unsubscribeNode","forEach","removeChild","index","indexOf","node","splice","insertChildBefore","before","beforeIndex","JsiDeclarationNode","declarationType","Error","invalidate","setInvalidate","isPaint","Paint","isImageFilter","ImageFilter","isColorFilter","ColorFilter","isShader","Shader","isMaskFilter","MaskFilter","isPathEffect","PathEffect"],"sources":["Node.ts"],"sourcesContent":["import type {\n SkColorFilter,\n Skia,\n SkImageFilter,\n SkMaskFilter,\n SkShader,\n SkPathEffect,\n SkPaint,\n} from \"../../skia/types\";\nimport type { Node, DeclarationNode, NodeType } from \"../types\";\nimport { DeclarationType } from \"../types\";\nimport type { DependencyManager } from \"../../renderer/DependencyManager\";\n\nexport interface NodeContext {\n Skia: Skia;\n depMgr: DependencyManager;\n}\n\nexport abstract class JsiNode<P> implements Node<P> {\n protected _children: JsiNode<unknown>[] = [];\n protected Skia: Skia;\n protected depMgr: DependencyManager;\n\n constructor(ctx: NodeContext, public type: NodeType, protected props: P) {\n this.Skia = ctx.Skia;\n this.depMgr = ctx.depMgr;\n }\n\n setProps(props: P) {\n this.props = props;\n }\n\n setProp<K extends keyof P>(name: K, v: P[K]) {\n const hasChanged = this.props[name] !== v;\n this.props[name] = v;\n return hasChanged;\n }\n\n getProps() {\n return this.props;\n }\n\n children() {\n return this._children;\n }\n\n addChild(child: Node<unknown>) {\n this._children.push(child as JsiNode<unknown>);\n }\n\n dispose() {\n this.depMgr.unsubscribeNode(this);\n this._children.forEach((child) => child.dispose());\n }\n\n removeChild(child: Node<unknown>) {\n const index = this._children.indexOf(child as JsiNode<unknown>);\n if (index !== -1) {\n const [node] = this._children.splice(index, 1);\n node.dispose();\n }\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n const index = this._children.indexOf(child as JsiNode<unknown>);\n if (index !== -1) {\n this._children.splice(index, 1);\n }\n const beforeIndex = this._children.indexOf(before as JsiNode<unknown>);\n this._children.splice(beforeIndex, 0, child as JsiNode<unknown>);\n }\n}\n\nexport type Invalidate = () => void;\n\nexport abstract class JsiDeclarationNode<\n P,\n T,\n Nullable extends null | never = never\n >\n extends JsiNode<P>\n implements DeclarationNode<P, T, Nullable>\n{\n private invalidate: Invalidate = () => {};\n\n constructor(\n ctx: NodeContext,\n public declarationType: DeclarationType,\n type: NodeType,\n props: P\n ) {\n super(ctx, type, props);\n }\n\n abstract materialize(): T | Nullable;\n\n addChild(child: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.addChild(child);\n this.invalidate();\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.insertChildBefore(child, before);\n this.invalidate();\n }\n\n dispose() {\n this.invalidate();\n super.dispose();\n }\n\n setInvalidate(invalidate: Invalidate) {\n this.invalidate = invalidate;\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.invalidate();\n }\n\n setProp<K extends keyof P>(name: K, v: P[K]) {\n const hasChanged = super.setProp(name, v);\n if (hasChanged) {\n this.invalidate();\n }\n return hasChanged;\n }\n\n isPaint(): this is DeclarationNode<unknown, SkPaint> {\n return this.declarationType === DeclarationType.Paint;\n }\n\n isImageFilter(): this is DeclarationNode<unknown, SkImageFilter> {\n return this.declarationType === DeclarationType.ImageFilter;\n }\n\n isColorFilter(): this is DeclarationNode<unknown, SkColorFilter> {\n return this.declarationType === DeclarationType.ColorFilter;\n }\n\n isShader(): this is DeclarationNode<unknown, SkShader> {\n return this.declarationType === DeclarationType.Shader;\n }\n\n isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter> {\n return this.declarationType === DeclarationType.MaskFilter;\n }\n\n isPathEffect(): this is DeclarationNode<unknown, SkPathEffect> {\n return this.declarationType === DeclarationType.PathEffect;\n }\n}\n"],"mappings":";;AAUA,SAASA,eAAT,QAAgC,UAAhC;AAQA,OAAO,MAAeC,OAAf,CAA6C;EAKlDC,WAAW,CAACC,GAAD,EAA0BC,IAA1B,EAAoDC,KAApD,EAA8D;IAAA,KAApCD,IAA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EACD;;EAEDxB,OAAO,CAAoBC,IAApB,EAA6BC,CAA7B,EAAsC;IAC3C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,IAAd,EAAoBC,CAApB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKqB,UAAL;IACD;;IACD,OAAOrB,UAAP;EACD;;EAEDuB,OAAO,GAA8C;IACnD,OAAO,KAAKJ,eAAL,KAAyB/B,eAAe,CAACoC,KAAhD;EACD;;EAEDC,aAAa,GAAoD;IAC/D,OAAO,KAAKN,eAAL,KAAyB/B,eAAe,CAACsC,WAAhD;EACD;;EAEDC,aAAa,GAAoD;IAC/D,OAAO,KAAKR,eAAL,KAAyB/B,eAAe,CAACwC,WAAhD;EACD;;EAEDC,QAAQ,GAA+C;IACrD,OAAO,KAAKV,eAAL,KAAyB/B,eAAe,CAAC0C,MAAhD;EACD;;EAEDC,YAAY,GAAmD;IAC7D,OAAO,KAAKZ,eAAL,KAAyB/B,eAAe,CAAC4C,UAAhD;EACD;;EAEDC,YAAY,GAAmD;IAC7D,OAAO,KAAKd,eAAL,KAAyB/B,eAAe,CAAC8C,UAAhD;EACD;;AA1EH"}
1
+ {"version":3,"names":["JsiNode","constructor","ctx","type","props","Skia","depMgr","setProps","setProp","name","v","hasChanged","getProps","children","_children","addChild","child","push","dispose","unsubscribeNode","forEach","removeChild","index","indexOf","node","splice","insertChildBefore","before","beforeIndex","JsiDeclarationNode","declarationType","decorateChildren","decorate","Error","invalidate","setInvalidate"],"sources":["Node.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\nimport type {\n Node,\n DeclarationNode,\n NodeType,\n DeclarationType,\n} from \"../types\";\nimport type { DependencyManager } from \"../../renderer/DependencyManager\";\nimport type { DeclarationContext } from \"../types/DeclarationContext\";\n\nexport interface NodeContext {\n Skia: Skia;\n depMgr: DependencyManager;\n}\n\nexport abstract class JsiNode<P> implements Node<P> {\n protected _children: JsiNode<unknown>[] = [];\n protected Skia: Skia;\n protected depMgr: DependencyManager;\n\n constructor(ctx: NodeContext, public type: NodeType, protected props: P) {\n this.Skia = ctx.Skia;\n this.depMgr = ctx.depMgr;\n }\n\n setProps(props: P) {\n this.props = props;\n }\n\n setProp<K extends keyof P>(name: K, v: P[K]) {\n const hasChanged = this.props[name] !== v;\n this.props[name] = v;\n return hasChanged;\n }\n\n getProps() {\n return this.props;\n }\n\n children() {\n return this._children;\n }\n\n addChild(child: Node<unknown>) {\n this._children.push(child as JsiNode<unknown>);\n }\n\n dispose() {\n this.depMgr.unsubscribeNode(this);\n this._children.forEach((child) => child.dispose());\n }\n\n removeChild(child: Node<unknown>) {\n const index = this._children.indexOf(child as JsiNode<unknown>);\n if (index !== -1) {\n const [node] = this._children.splice(index, 1);\n node.dispose();\n }\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n const index = this._children.indexOf(child as JsiNode<unknown>);\n if (index !== -1) {\n this._children.splice(index, 1);\n }\n const beforeIndex = this._children.indexOf(before as JsiNode<unknown>);\n this._children.splice(beforeIndex, 0, child as JsiNode<unknown>);\n }\n}\n\nexport type Invalidate = () => void;\n\nexport abstract class JsiDeclarationNode<P>\n extends JsiNode<P>\n implements DeclarationNode<P>\n{\n private invalidate: Invalidate = () => {};\n\n constructor(\n ctx: NodeContext,\n public declarationType: DeclarationType,\n type: NodeType,\n props: P\n ) {\n super(ctx, type, props);\n }\n\n abstract decorate(ctx: DeclarationContext): void;\n\n protected decorateChildren(ctx: DeclarationContext) {\n this.children().forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n child.decorate(ctx);\n }\n });\n }\n\n addChild(child: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.addChild(child);\n this.invalidate();\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {\n if (!(child instanceof JsiDeclarationNode)) {\n throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);\n }\n super.insertChildBefore(child, before);\n this.invalidate();\n }\n\n dispose() {\n this.invalidate();\n super.dispose();\n }\n\n setInvalidate(invalidate: Invalidate) {\n this.invalidate = invalidate;\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.invalidate();\n }\n\n setProp<K extends keyof P>(name: K, v: P[K]) {\n const hasChanged = super.setProp(name, v);\n if (hasChanged) {\n this.invalidate();\n }\n return hasChanged;\n }\n}\n"],"mappings":";;AAeA,OAAO,MAAeA,OAAf,CAA6C;EAKlDC,WAAW,CAACC,GAAD,EAA0BC,IAA1B,EAAoDC,KAApD,EAA8D;IAAA,KAApCD,IAAoC,GAApCA,IAAoC;IAAA,KAAVC,KAAU,GAAVA,KAAU;;IAAA,mCAJ/B,EAI+B;;IAAA;;IAAA;;IACvE,KAAKC,IAAL,GAAYH,GAAG,CAACG,IAAhB;IACA,KAAKC,MAAL,GAAcJ,GAAG,CAACI,MAAlB;EACD;;EAEDC,QAAQ,CAACH,KAAD,EAAW;IACjB,KAAKA,KAAL,GAAaA,KAAb;EACD;;EAEDI,OAAO,CAAoBC,IAApB,EAA6BC,CAA7B,EAAsC;IAC3C,MAAMC,UAAU,GAAG,KAAKP,KAAL,CAAWK,IAAX,MAAqBC,CAAxC;IACA,KAAKN,KAAL,CAAWK,IAAX,IAAmBC,CAAnB;IACA,OAAOC,UAAP;EACD;;EAEDC,QAAQ,GAAG;IACT,OAAO,KAAKR,KAAZ;EACD;;EAEDS,QAAQ,GAAG;IACT,OAAO,KAAKC,SAAZ;EACD;;EAEDC,QAAQ,CAACC,KAAD,EAAuB;IAC7B,KAAKF,SAAL,CAAeG,IAAf,CAAoBD,KAApB;EACD;;EAEDE,OAAO,GAAG;IACR,KAAKZ,MAAL,CAAYa,eAAZ,CAA4B,IAA5B;;IACA,KAAKL,SAAL,CAAeM,OAAf,CAAwBJ,KAAD,IAAWA,KAAK,CAACE,OAAN,EAAlC;EACD;;EAEDG,WAAW,CAACL,KAAD,EAAuB;IAChC,MAAMM,KAAK,GAAG,KAAKR,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N;IACD;;IACD,MAAMY,QAAN,CAAeC,KAAf;IACA,KAAKkB,UAAL;EACD;;EAEDR,iBAAiB,CAACV,KAAD,EAAuBW,MAAvB,EAAoD;IACnE,IAAI,EAAEX,KAAK,YAAYa,kBAAnB,CAAJ,EAA4C;MAC1C,MAAM,IAAII,KAAJ,CAAW,4BAA2BjB,KAAK,CAACb,IAAK,OAAM,KAAKA,IAAK,EAAjE,CAAN;IACD;;IACD,MAAMuB,iBAAN,CAAwBV,KAAxB,EAA+BW,MAA/B;IACA,KAAKO,UAAL;EACD;;EAEDhB,OAAO,GAAG;IACR,KAAKgB,UAAL;IACA,MAAMhB,OAAN;EACD;;EAEDiB,aAAa,CAACD,UAAD,EAAyB;IACpC,KAAKA,UAAL,GAAkBA,UAAlB;EACD;;EAED3B,QAAQ,CAACH,KAAD,EAAW;IACjB,MAAMG,QAAN,CAAeH,KAAf;IACA,KAAK8B,UAAL;EACD;;EAED1B,OAAO,CAAoBC,IAApB,EAA6BC,CAA7B,EAAsC;IAC3C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,IAAd,EAAoBC,CAApB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKuB,UAAL;IACD;;IACD,OAAOvB,UAAP;EACD;;AA1DH"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\n// TODO: to remove\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
@@ -1,8 +1,8 @@
1
- import type { SkPaint } from "../../skia/types";
2
1
  import type { DeclarationNode, PaintProps } from "../types";
2
+ import type { DeclarationContext } from "../types/DeclarationContext";
3
3
  import type { NodeContext } from "./Node";
4
4
  import { JsiDeclarationNode } from "./Node";
5
- export declare class PaintNode extends JsiDeclarationNode<PaintProps, SkPaint> implements DeclarationNode<PaintProps, SkPaint> {
5
+ export declare class PaintNode extends JsiDeclarationNode<PaintProps> implements DeclarationNode<PaintProps> {
6
6
  constructor(ctx: NodeContext, props?: PaintProps);
7
- materialize(): SkPaint;
7
+ decorate(ctx: DeclarationContext): void;
8
8
  }