@shopify/react-native-skia 1.7.5 → 1.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (384) hide show
  1. package/android/cpp/rnskia-android/OpenGLWindowContext.h +8 -1
  2. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +4 -4
  3. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  4. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +13 -0
  5. package/android/src/main/java/com/shopify/reactnative/skia/SkiaTextureView.java +24 -1
  6. package/cpp/rnskia/RNSkJsiViewApi.h +0 -3
  7. package/cpp/rnskia/RNSkView.h +6 -6
  8. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +2 -2
  9. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +2 -2
  10. package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -2
  11. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  12. package/lib/commonjs/dom/nodes/datatypes/Circle.d.ts +2 -3
  13. package/lib/commonjs/dom/nodes/datatypes/Circle.js +11 -6
  14. package/lib/commonjs/dom/nodes/datatypes/Circle.js.map +1 -1
  15. package/lib/commonjs/dom/nodes/datatypes/Enum.js +1 -0
  16. package/lib/commonjs/dom/nodes/datatypes/Enum.js.map +1 -1
  17. package/lib/commonjs/dom/nodes/datatypes/Fitting.js +1 -10
  18. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  19. package/lib/commonjs/dom/nodes/datatypes/Gradient.js +3 -2
  20. package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
  21. package/lib/commonjs/dom/nodes/datatypes/Path.js +4 -1
  22. package/lib/commonjs/dom/nodes/datatypes/Path.js.map +1 -1
  23. package/lib/commonjs/dom/nodes/datatypes/Radius.js +1 -0
  24. package/lib/commonjs/dom/nodes/datatypes/Radius.js.map +1 -1
  25. package/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +3 -1
  26. package/lib/commonjs/dom/nodes/datatypes/Rect.js +17 -7
  27. package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
  28. package/lib/commonjs/dom/nodes/datatypes/Transform.d.ts +2 -1
  29. package/lib/commonjs/dom/nodes/datatypes/Transform.js +32 -1
  30. package/lib/commonjs/dom/nodes/datatypes/Transform.js.map +1 -1
  31. package/lib/commonjs/dom/nodes/drawings/Box.js +4 -5
  32. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  33. package/lib/commonjs/dom/nodes/drawings/CircleNode.js +1 -1
  34. package/lib/commonjs/dom/nodes/drawings/CircleNode.js.map +1 -1
  35. package/lib/commonjs/dom/types/DeclarationContext.d.ts +4 -4
  36. package/lib/commonjs/dom/types/DeclarationContext.js +8 -2
  37. package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -1
  38. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  39. package/lib/commonjs/external/reanimated/renderHelpers.js +11 -6
  40. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  41. package/lib/commonjs/renderer/HostConfig.js +8 -4
  42. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  43. package/lib/commonjs/renderer/__tests__/setup.d.ts +2 -3
  44. package/lib/commonjs/renderer/processors/Animations/Animations.d.ts +1 -2
  45. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  46. package/lib/commonjs/renderer/typeddash.js +5 -1
  47. package/lib/commonjs/renderer/typeddash.js.map +1 -1
  48. package/lib/commonjs/skia/__tests__/setup.d.ts +0 -3
  49. package/lib/commonjs/skia/types/Path/Path.js +5 -1
  50. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  51. package/lib/commonjs/skia/types/RRect.d.ts +1 -1
  52. package/lib/commonjs/skia/types/RRect.js +7 -3
  53. package/lib/commonjs/skia/types/RRect.js.map +1 -1
  54. package/lib/commonjs/skia/types/Shader/Shader.js +8 -6
  55. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +1 -1
  57. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
  58. package/lib/commonjs/sksg/Container.d.ts +19 -0
  59. package/lib/commonjs/sksg/Container.js +102 -0
  60. package/lib/commonjs/sksg/Container.js.map +1 -0
  61. package/lib/commonjs/sksg/DrawingContext.d.ts +16 -0
  62. package/lib/commonjs/sksg/DrawingContext.js +186 -0
  63. package/lib/commonjs/sksg/DrawingContext.js.map +1 -0
  64. package/lib/commonjs/sksg/HostConfig.d.ts +19 -0
  65. package/lib/commonjs/sksg/HostConfig.js +168 -0
  66. package/lib/commonjs/sksg/HostConfig.js.map +1 -0
  67. package/lib/commonjs/sksg/Reconciler.d.ts +17 -0
  68. package/lib/commonjs/sksg/Reconciler.js +54 -0
  69. package/lib/commonjs/sksg/Reconciler.js.map +1 -0
  70. package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +57 -0
  71. package/lib/commonjs/sksg/nodes/Node.d.ts +7 -0
  72. package/lib/commonjs/sksg/nodes/Node.js +6 -0
  73. package/lib/commonjs/sksg/nodes/Node.js.map +1 -0
  74. package/lib/commonjs/sksg/nodes/colorFilters.d.ts +7 -0
  75. package/lib/commonjs/sksg/nodes/colorFilters.js +55 -0
  76. package/lib/commonjs/sksg/nodes/colorFilters.js.map +1 -0
  77. package/lib/commonjs/sksg/nodes/context.d.ts +3 -0
  78. package/lib/commonjs/sksg/nodes/context.js +448 -0
  79. package/lib/commonjs/sksg/nodes/context.js.map +1 -0
  80. package/lib/commonjs/sksg/nodes/drawings.d.ts +31 -0
  81. package/lib/commonjs/sksg/nodes/drawings.js +361 -0
  82. package/lib/commonjs/sksg/nodes/drawings.js.map +1 -0
  83. package/lib/commonjs/sksg/nodes/imageFilters.d.ts +14 -0
  84. package/lib/commonjs/sksg/nodes/imageFilters.js +135 -0
  85. package/lib/commonjs/sksg/nodes/imageFilters.js.map +1 -0
  86. package/lib/commonjs/sksg/nodes/index.d.ts +3 -0
  87. package/lib/commonjs/sksg/nodes/index.js +39 -0
  88. package/lib/commonjs/sksg/nodes/index.js.map +1 -0
  89. package/lib/commonjs/sksg/nodes/paint.d.ts +2 -0
  90. package/lib/commonjs/sksg/nodes/paint.js +80 -0
  91. package/lib/commonjs/sksg/nodes/paint.js.map +1 -0
  92. package/lib/commonjs/sksg/nodes/pathEffects.d.ts +8 -0
  93. package/lib/commonjs/sksg/nodes/pathEffects.js +84 -0
  94. package/lib/commonjs/sksg/nodes/pathEffects.js.map +1 -0
  95. package/lib/commonjs/sksg/nodes/shaders.d.ts +10 -0
  96. package/lib/commonjs/sksg/nodes/shaders.js +156 -0
  97. package/lib/commonjs/sksg/nodes/shaders.js.map +1 -0
  98. package/lib/commonjs/sksg/nodes/utils.d.ts +3 -0
  99. package/lib/commonjs/sksg/nodes/utils.js +25 -0
  100. package/lib/commonjs/sksg/nodes/utils.js.map +1 -0
  101. package/lib/commonjs/views/SkiaDomView.js +3 -1
  102. package/lib/commonjs/views/SkiaDomView.js.map +1 -1
  103. package/lib/commonjs/views/SkiaPictureView.js +0 -2
  104. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  105. package/lib/commonjs/views/types.d.ts +2 -2
  106. package/lib/commonjs/views/types.js.map +1 -1
  107. package/lib/module/dom/nodes/JsiSkDOM.js +2 -2
  108. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  109. package/lib/module/dom/nodes/datatypes/Circle.d.ts +2 -3
  110. package/lib/module/dom/nodes/datatypes/Circle.js +12 -6
  111. package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
  112. package/lib/module/dom/nodes/datatypes/Enum.js +2 -0
  113. package/lib/module/dom/nodes/datatypes/Enum.js.map +1 -1
  114. package/lib/module/dom/nodes/datatypes/Fitting.js +2 -10
  115. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  116. package/lib/module/dom/nodes/datatypes/Gradient.js +4 -2
  117. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  118. package/lib/module/dom/nodes/datatypes/Path.js +5 -1
  119. package/lib/module/dom/nodes/datatypes/Path.js.map +1 -1
  120. package/lib/module/dom/nodes/datatypes/Radius.js +2 -0
  121. package/lib/module/dom/nodes/datatypes/Radius.js.map +1 -1
  122. package/lib/module/dom/nodes/datatypes/Rect.d.ts +3 -1
  123. package/lib/module/dom/nodes/datatypes/Rect.js +14 -5
  124. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  125. package/lib/module/dom/nodes/datatypes/Transform.d.ts +2 -1
  126. package/lib/module/dom/nodes/datatypes/Transform.js +31 -0
  127. package/lib/module/dom/nodes/datatypes/Transform.js.map +1 -1
  128. package/lib/module/dom/nodes/drawings/Box.js +1 -2
  129. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  130. package/lib/module/dom/nodes/drawings/CircleNode.js +1 -1
  131. package/lib/module/dom/nodes/drawings/CircleNode.js.map +1 -1
  132. package/lib/module/dom/types/DeclarationContext.d.ts +4 -4
  133. package/lib/module/dom/types/DeclarationContext.js +9 -2
  134. package/lib/module/dom/types/DeclarationContext.js.map +1 -1
  135. package/lib/module/external/reanimated/renderHelpers.d.ts +2 -0
  136. package/lib/module/external/reanimated/renderHelpers.js +8 -4
  137. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  138. package/lib/module/renderer/HostConfig.js +8 -4
  139. package/lib/module/renderer/HostConfig.js.map +1 -1
  140. package/lib/module/renderer/__tests__/setup.d.ts +2 -3
  141. package/lib/module/renderer/processors/Animations/Animations.d.ts +1 -2
  142. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  143. package/lib/module/renderer/typeddash.js +5 -1
  144. package/lib/module/renderer/typeddash.js.map +1 -1
  145. package/lib/module/skia/__tests__/setup.d.ts +0 -3
  146. package/lib/module/skia/types/Path/Path.js +5 -1
  147. package/lib/module/skia/types/Path/Path.js.map +1 -1
  148. package/lib/module/skia/types/RRect.d.ts +1 -1
  149. package/lib/module/skia/types/RRect.js +7 -3
  150. package/lib/module/skia/types/RRect.js.map +1 -1
  151. package/lib/module/skia/types/Shader/Shader.js +9 -6
  152. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  153. package/lib/module/skia/web/JsiSkParagraphStyle.js +1 -1
  154. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
  155. package/lib/module/sksg/Container.d.ts +19 -0
  156. package/lib/module/sksg/Container.js +94 -0
  157. package/lib/module/sksg/Container.js.map +1 -0
  158. package/lib/module/sksg/DrawingContext.d.ts +16 -0
  159. package/lib/module/sksg/DrawingContext.js +180 -0
  160. package/lib/module/sksg/DrawingContext.js.map +1 -0
  161. package/lib/module/sksg/HostConfig.d.ts +19 -0
  162. package/lib/module/sksg/HostConfig.js +161 -0
  163. package/lib/module/sksg/HostConfig.js.map +1 -0
  164. package/lib/module/sksg/Reconciler.d.ts +17 -0
  165. package/lib/module/sksg/Reconciler.js +46 -0
  166. package/lib/module/sksg/Reconciler.js.map +1 -0
  167. package/lib/module/sksg/__tests__/MockDeclaration.d.ts +57 -0
  168. package/lib/module/sksg/nodes/Node.d.ts +7 -0
  169. package/lib/module/sksg/nodes/Node.js +2 -0
  170. package/lib/module/sksg/nodes/Node.js.map +1 -0
  171. package/lib/module/sksg/nodes/colorFilters.d.ts +7 -0
  172. package/lib/module/sksg/nodes/colorFilters.js +44 -0
  173. package/lib/module/sksg/nodes/colorFilters.js.map +1 -0
  174. package/lib/module/sksg/nodes/context.d.ts +3 -0
  175. package/lib/module/sksg/nodes/context.js +443 -0
  176. package/lib/module/sksg/nodes/context.js.map +1 -0
  177. package/lib/module/sksg/nodes/drawings.d.ts +31 -0
  178. package/lib/module/sksg/nodes/drawings.js +334 -0
  179. package/lib/module/sksg/nodes/drawings.js.map +1 -0
  180. package/lib/module/sksg/nodes/imageFilters.d.ts +14 -0
  181. package/lib/module/sksg/nodes/imageFilters.js +122 -0
  182. package/lib/module/sksg/nodes/imageFilters.js.map +1 -0
  183. package/lib/module/sksg/nodes/index.d.ts +3 -0
  184. package/lib/module/sksg/nodes/index.js +4 -0
  185. package/lib/module/sksg/nodes/index.js.map +1 -0
  186. package/lib/module/sksg/nodes/paint.d.ts +2 -0
  187. package/lib/module/sksg/nodes/paint.js +74 -0
  188. package/lib/module/sksg/nodes/paint.js.map +1 -0
  189. package/lib/module/sksg/nodes/pathEffects.d.ts +8 -0
  190. package/lib/module/sksg/nodes/pathEffects.js +72 -0
  191. package/lib/module/sksg/nodes/pathEffects.js.map +1 -0
  192. package/lib/module/sksg/nodes/shaders.d.ts +10 -0
  193. package/lib/module/sksg/nodes/shaders.js +142 -0
  194. package/lib/module/sksg/nodes/shaders.js.map +1 -0
  195. package/lib/module/sksg/nodes/utils.d.ts +3 -0
  196. package/lib/module/sksg/nodes/utils.js +18 -0
  197. package/lib/module/sksg/nodes/utils.js.map +1 -0
  198. package/lib/module/views/SkiaDomView.js +3 -1
  199. package/lib/module/views/SkiaDomView.js.map +1 -1
  200. package/lib/module/views/SkiaPictureView.js +0 -2
  201. package/lib/module/views/SkiaPictureView.js.map +1 -1
  202. package/lib/module/views/types.d.ts +2 -2
  203. package/lib/module/views/types.js.map +1 -1
  204. package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Circle.d.ts +1 -1
  205. package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +2 -0
  206. package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Transform.d.ts +1 -0
  207. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  208. package/lib/typescript/lib/commonjs/renderer/HostConfig.d.ts +3 -1
  209. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +16 -0
  210. package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +26 -0
  211. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +50 -0
  212. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +16 -0
  213. package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +1 -0
  214. package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +7 -0
  215. package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +2 -0
  216. package/lib/typescript/lib/commonjs/sksg/nodes/drawings.d.ts +23 -0
  217. package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +10 -0
  218. package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +1 -0
  219. package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +2 -0
  220. package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +8 -0
  221. package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +10 -0
  222. package/lib/typescript/lib/commonjs/sksg/nodes/utils.d.ts +3 -0
  223. package/lib/typescript/lib/module/dom/nodes/datatypes/Circle.d.ts +1 -1
  224. package/lib/typescript/lib/module/dom/nodes/datatypes/Rect.d.ts +2 -0
  225. package/lib/typescript/lib/module/dom/nodes/datatypes/Transform.d.ts +1 -0
  226. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +2 -0
  227. package/lib/typescript/lib/module/mock/index.d.ts +4 -1
  228. package/lib/typescript/lib/module/renderer/HostConfig.d.ts +3 -1
  229. package/lib/typescript/lib/module/sksg/Container.d.ts +15 -0
  230. package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +26 -0
  231. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +49 -0
  232. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +15 -0
  233. package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +6 -0
  234. package/lib/typescript/lib/module/sksg/nodes/context.d.ts +1 -0
  235. package/lib/typescript/lib/module/sksg/nodes/drawings.d.ts +22 -0
  236. package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +9 -0
  237. package/lib/typescript/lib/module/sksg/nodes/index.d.ts +3 -0
  238. package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +1 -0
  239. package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +7 -0
  240. package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +9 -0
  241. package/lib/typescript/lib/module/sksg/nodes/utils.d.ts +2 -0
  242. package/lib/typescript/src/dom/nodes/datatypes/Circle.d.ts +2 -3
  243. package/lib/typescript/src/dom/nodes/datatypes/Rect.d.ts +3 -1
  244. package/lib/typescript/src/dom/nodes/datatypes/Transform.d.ts +2 -1
  245. package/lib/typescript/src/dom/types/DeclarationContext.d.ts +4 -4
  246. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +2 -0
  247. package/lib/typescript/src/renderer/__tests__/setup.d.ts +2 -3
  248. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +1 -2
  249. package/lib/typescript/src/skia/__tests__/setup.d.ts +0 -3
  250. package/lib/typescript/src/skia/types/RRect.d.ts +1 -1
  251. package/lib/typescript/src/sksg/Container.d.ts +19 -0
  252. package/lib/typescript/src/sksg/DrawingContext.d.ts +16 -0
  253. package/lib/typescript/src/sksg/HostConfig.d.ts +19 -0
  254. package/lib/typescript/src/sksg/Reconciler.d.ts +17 -0
  255. package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +57 -0
  256. package/lib/typescript/src/sksg/nodes/Node.d.ts +7 -0
  257. package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +7 -0
  258. package/lib/typescript/src/sksg/nodes/context.d.ts +3 -0
  259. package/lib/typescript/src/sksg/nodes/drawings.d.ts +31 -0
  260. package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +14 -0
  261. package/lib/typescript/src/sksg/nodes/index.d.ts +3 -0
  262. package/lib/typescript/src/sksg/nodes/paint.d.ts +2 -0
  263. package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +8 -0
  264. package/lib/typescript/src/sksg/nodes/shaders.d.ts +10 -0
  265. package/lib/typescript/src/sksg/nodes/utils.d.ts +3 -0
  266. package/lib/typescript/src/views/types.d.ts +2 -2
  267. package/libs/{ios → apple}/libskia.xcframework/Info.plist +15 -0
  268. package/libs/{ios → apple}/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  269. package/libs/{ios → apple}/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  270. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  271. package/libs/{ios → apple}/libskottie.xcframework/Info.plist +20 -5
  272. package/libs/{ios → apple}/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  273. package/libs/{ios → apple}/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  274. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  275. package/libs/{ios → apple}/libskparagraph.xcframework/Info.plist +20 -5
  276. package/libs/{ios → apple}/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  277. package/libs/{ios → apple}/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  278. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  279. package/libs/{ios → apple}/libsksg.xcframework/Info.plist +15 -0
  280. package/libs/{ios → apple}/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  281. package/libs/{ios → apple}/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  282. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  283. package/libs/{ios → apple}/libskshaper.xcframework/Info.plist +20 -5
  284. package/libs/{ios → apple}/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  285. package/libs/{ios → apple}/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  286. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  287. package/libs/{ios → apple}/libskunicode_core.xcframework/Info.plist +18 -3
  288. package/libs/{ios → apple}/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  289. package/libs/{ios → apple}/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  290. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  291. package/libs/{ios → apple}/libskunicode_libgrapheme.xcframework/Info.plist +15 -0
  292. package/libs/{ios → apple}/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  293. package/libs/{ios → apple}/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  294. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  295. package/libs/{ios → apple}/libsvg.xcframework/Info.plist +15 -0
  296. package/libs/{ios → apple}/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  297. package/libs/{ios → apple}/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  298. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  299. package/package.json +3 -3
  300. package/react-native-skia.podspec +9 -9
  301. package/src/__tests__/setup.ts +1 -1
  302. package/src/__tests__/snapshots/sksg/breathe-0.png +0 -0
  303. package/src/__tests__/snapshots/sksg/breathe.png +0 -0
  304. package/src/__tests__/snapshots/sksg/simple.png +0 -0
  305. package/src/__tests__/snapshots/sksg/simple2.png +0 -0
  306. package/src/dom/nodes/JsiSkDOM.ts +2 -4
  307. package/src/dom/nodes/datatypes/Circle.ts +7 -5
  308. package/src/dom/nodes/datatypes/Enum.ts +2 -0
  309. package/src/dom/nodes/datatypes/Fitting.ts +2 -5
  310. package/src/dom/nodes/datatypes/Gradient.ts +4 -7
  311. package/src/dom/nodes/datatypes/Path.ts +5 -2
  312. package/src/dom/nodes/datatypes/Radius.ts +2 -0
  313. package/src/dom/nodes/datatypes/Rect.ts +40 -6
  314. package/src/dom/nodes/datatypes/Transform.ts +29 -1
  315. package/src/dom/nodes/drawings/Box.ts +1 -29
  316. package/src/dom/nodes/drawings/CircleNode.ts +1 -1
  317. package/src/dom/types/DeclarationContext.ts +12 -2
  318. package/src/external/reanimated/renderHelpers.ts +8 -4
  319. package/src/renderer/HostConfig.ts +10 -4
  320. package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +2 -2
  321. package/src/renderer/__tests__/setup.tsx +17 -15
  322. package/src/renderer/processors/Animations/Animations.ts +1 -5
  323. package/src/renderer/typeddash.ts +4 -2
  324. package/src/skia/__tests__/setup.ts +1 -51
  325. package/src/skia/types/Path/Path.ts +4 -2
  326. package/src/skia/types/RRect.ts +9 -3
  327. package/src/skia/types/Shader/Shader.ts +7 -4
  328. package/src/skia/web/JsiSkParagraphStyle.ts +1 -3
  329. package/src/sksg/Container.ts +102 -0
  330. package/src/sksg/DrawingContext.ts +221 -0
  331. package/src/sksg/HostConfig.ts +287 -0
  332. package/src/sksg/Reconciler.ts +59 -0
  333. package/src/sksg/__tests__/Declarations.spec.tsx +235 -0
  334. package/src/sksg/__tests__/MockDeclaration.ts +140 -0
  335. package/src/sksg/__tests__/Simple.spec.tsx +148 -0
  336. package/src/sksg/nodes/Node.ts +8 -0
  337. package/src/sksg/nodes/colorFilters.ts +60 -0
  338. package/src/sksg/nodes/context.ts +489 -0
  339. package/src/sksg/nodes/drawings.ts +393 -0
  340. package/src/sksg/nodes/imageFilters.ts +183 -0
  341. package/src/sksg/nodes/index.ts +3 -0
  342. package/src/sksg/nodes/paint.ts +75 -0
  343. package/src/sksg/nodes/pathEffects.ts +95 -0
  344. package/src/sksg/nodes/shaders.ts +203 -0
  345. package/src/sksg/nodes/utils.ts +23 -0
  346. package/src/views/SkiaDomView.tsx +3 -1
  347. package/src/views/SkiaPictureView.tsx +0 -2
  348. package/src/views/types.ts +2 -2
  349. package/lib/commonjs/dom/__tests__/Shaders.spec.d.ts +0 -1
  350. package/lib/commonjs/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
  351. package/lib/module/dom/__tests__/Compose.spec.d.ts +0 -1
  352. package/lib/module/dom/__tests__/Demos.spec.d.ts +0 -1
  353. package/lib/module/dom/__tests__/DrawingContext.spec.d.ts +0 -1
  354. package/lib/module/dom/__tests__/Drawings.spec.d.ts +0 -1
  355. package/lib/module/dom/__tests__/Group.spec.d.ts +0 -1
  356. package/lib/module/dom/__tests__/Paint.spec.d.ts +0 -1
  357. package/lib/module/dom/__tests__/RenderNodes.spec.d.ts +0 -1
  358. package/lib/module/dom/__tests__/Shaders.spec.d.ts +0 -1
  359. package/lib/module/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
  360. package/lib/typescript/src/dom/__tests__/Compose.spec.d.ts +0 -1
  361. package/lib/typescript/src/dom/__tests__/Demos.spec.d.ts +0 -1
  362. package/lib/typescript/src/dom/__tests__/DrawingContext.spec.d.ts +0 -1
  363. package/lib/typescript/src/dom/__tests__/Drawings.spec.d.ts +0 -1
  364. package/lib/typescript/src/dom/__tests__/Group.spec.d.ts +0 -1
  365. package/lib/typescript/src/dom/__tests__/Paint.spec.d.ts +0 -1
  366. package/lib/typescript/src/dom/__tests__/RenderNodes.spec.d.ts +0 -1
  367. package/lib/typescript/src/dom/__tests__/Shaders.spec.d.ts +0 -1
  368. package/lib/typescript/src/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
  369. package/src/dom/__tests__/Compose.spec.tsx +0 -42
  370. package/src/dom/__tests__/Demos.spec.tsx +0 -145
  371. package/src/dom/__tests__/DrawingContext.spec.tsx +0 -99
  372. package/src/dom/__tests__/Drawings.spec.tsx +0 -95
  373. package/src/dom/__tests__/Group.spec.tsx +0 -132
  374. package/src/dom/__tests__/Paint.spec.tsx +0 -100
  375. package/src/dom/__tests__/RenderNodes.spec.tsx +0 -44
  376. package/src/dom/__tests__/Shaders.spec.tsx +0 -123
  377. package/src/renderer/__tests__/SkiaDOM.spec.tsx +0 -46
  378. /package/lib/commonjs/{dom/__tests__/Compose.spec.d.ts → sksg/__tests__/Declarations.spec.d.ts} +0 -0
  379. /package/lib/commonjs/{dom/__tests__/Demos.spec.d.ts → sksg/__tests__/Simple.spec.d.ts} +0 -0
  380. /package/lib/{commonjs/dom/__tests__/DrawingContext.spec.d.ts → module/sksg/__tests__/Declarations.spec.d.ts} +0 -0
  381. /package/lib/{commonjs/dom/__tests__/Drawings.spec.d.ts → module/sksg/__tests__/Simple.spec.d.ts} +0 -0
  382. /package/lib/{commonjs/dom/__tests__/Group.spec.d.ts → typescript/lib/module/sksg/nodes/Node.d.ts} +0 -0
  383. /package/lib/{commonjs/dom/__tests__/Paint.spec.d.ts → typescript/src/sksg/__tests__/Declarations.spec.d.ts} +0 -0
  384. /package/lib/{commonjs/dom/__tests__/RenderNodes.spec.d.ts → typescript/src/sksg/__tests__/Simple.spec.d.ts} +0 -0
@@ -0,0 +1,94 @@
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
+ import Rea from "../external/reanimated/ReanimatedProxy";
5
+ import { HAS_REANIMATED, HAS_REANIMATED_3 } from "../external/reanimated/renderHelpers";
6
+ import { DrawingContext } from "./DrawingContext";
7
+ import { draw, isSharedValue } from "./nodes";
8
+ const drawOnscreen = (Skia, nativeId, root) => {
9
+ "worklet";
10
+
11
+ const rec = Skia.PictureRecorder();
12
+ const canvas = rec.beginRecording();
13
+ // TODO: This is only support from 3.15 and above (check the exact version)
14
+ // This could be polyfilled in C++ if needed (or in JS via functions only?)
15
+ const ctx = new DrawingContext(Skia, canvas);
16
+ root.forEach(node => {
17
+ draw(ctx, node);
18
+ });
19
+ const picture = rec.finishRecordingAsPicture();
20
+ SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
21
+ };
22
+ export class Container {
23
+ constructor(Skia, nativeId) {
24
+ this.Skia = Skia;
25
+ this.nativeId = nativeId;
26
+ _defineProperty(this, "_root", []);
27
+ _defineProperty(this, "unmounted", false);
28
+ _defineProperty(this, "values", new Set());
29
+ _defineProperty(this, "mapperId", null);
30
+ }
31
+ get root() {
32
+ return this._root;
33
+ }
34
+ set root(root) {
35
+ const isOnscreen = this.nativeId !== -1;
36
+ if (HAS_REANIMATED && !HAS_REANIMATED_3) {
37
+ throw new Error("React Native Skia only supports Reanimated 3 and above");
38
+ }
39
+ if (isOnscreen) {
40
+ if (this.mapperId !== null) {
41
+ Rea.stopMapper(this.mapperId);
42
+ }
43
+ const {
44
+ nativeId,
45
+ Skia
46
+ } = this;
47
+ this.mapperId = Rea.startMapper(() => {
48
+ "worklet";
49
+
50
+ drawOnscreen(Skia, nativeId, root);
51
+ }, Array.from(this.values));
52
+ }
53
+ this._root = root;
54
+ }
55
+ clear() {
56
+ console.log("clear container");
57
+ }
58
+ redraw() {
59
+ const isOnscreen = this.nativeId !== -1;
60
+ if (HAS_REANIMATED && !HAS_REANIMATED_3) {
61
+ throw new Error("React Native Skia only supports Reanimated 3 and above");
62
+ }
63
+ if (isOnscreen) {
64
+ const {
65
+ nativeId,
66
+ Skia,
67
+ root
68
+ } = this;
69
+ Rea.runOnUI(() => {
70
+ drawOnscreen(Skia, nativeId, root);
71
+ })();
72
+ }
73
+ }
74
+ getNativeId() {
75
+ return this.nativeId;
76
+ }
77
+ unregisterValues(values) {
78
+ Object.values(values).filter(isSharedValue).forEach(value => {
79
+ this.values.delete(value);
80
+ });
81
+ }
82
+ registerValues(values) {
83
+ Object.values(values).filter(isSharedValue).forEach(value => {
84
+ this.values.add(value);
85
+ });
86
+ }
87
+ drawOnCanvas(canvas) {
88
+ const ctx = new DrawingContext(this.Skia, canvas);
89
+ this.root.forEach(node => {
90
+ draw(ctx, node);
91
+ });
92
+ }
93
+ }
94
+ //# sourceMappingURL=Container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Rea","HAS_REANIMATED","HAS_REANIMATED_3","DrawingContext","draw","isSharedValue","drawOnscreen","Skia","nativeId","root","rec","PictureRecorder","canvas","beginRecording","ctx","forEach","node","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","Container","constructor","_defineProperty","Set","_root","isOnscreen","Error","mapperId","stopMapper","startMapper","Array","from","values","clear","console","log","redraw","runOnUI","getNativeId","unregisterValues","Object","filter","value","delete","registerValues","add","drawOnCanvas"],"sources":["Container.ts"],"sourcesContent":["import { type SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport {\n HAS_REANIMATED,\n HAS_REANIMATED_3,\n} from \"../external/reanimated/renderHelpers\";\n\nimport { DrawingContext } from \"./DrawingContext\";\nimport type { Node } from \"./nodes\";\nimport { draw, isSharedValue } from \"./nodes\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, root: Node[]) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n // TODO: This is only support from 3.15 and above (check the exact version)\n // This could be polyfilled in C++ if needed (or in JS via functions only?)\n const ctx = new DrawingContext(Skia, canvas);\n root.forEach((node) => {\n draw(ctx, node);\n });\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nexport class Container {\n public _root: Node[] = [];\n public unmounted = false;\n\n private values = new Set<SharedValue<unknown>>();\n private mapperId: number | null = null;\n\n constructor(public Skia: Skia, private nativeId: number) {}\n\n get root() {\n return this._root;\n }\n\n set root(root: Node[]) {\n const isOnscreen = this.nativeId !== -1;\n if (HAS_REANIMATED && !HAS_REANIMATED_3) {\n throw new Error(\"React Native Skia only supports Reanimated 3 and above\");\n }\n if (isOnscreen) {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n const { nativeId, Skia } = this;\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, root);\n }, Array.from(this.values));\n }\n this._root = root;\n }\n\n clear() {\n console.log(\"clear container\");\n }\n\n redraw() {\n const isOnscreen = this.nativeId !== -1;\n if (HAS_REANIMATED && !HAS_REANIMATED_3) {\n throw new Error(\"React Native Skia only supports Reanimated 3 and above\");\n }\n if (isOnscreen) {\n const { nativeId, Skia, root } = this;\n Rea.runOnUI(() => {\n drawOnscreen(Skia, nativeId, root);\n })();\n }\n }\n\n getNativeId() {\n return this.nativeId;\n }\n\n unregisterValues(values: object) {\n Object.values(values)\n .filter(isSharedValue)\n .forEach((value) => {\n this.values.delete(value);\n });\n }\n\n registerValues(values: object) {\n Object.values(values)\n .filter(isSharedValue)\n .forEach((value) => {\n this.values.add(value);\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n const ctx = new DrawingContext(this.Skia, canvas);\n this.root.forEach((node) => {\n draw(ctx, node);\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SACEC,cAAc,EACdC,gBAAgB,QACX,sCAAsC;AAE7C,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,SAASC,IAAI,EAAEC,aAAa,QAAQ,SAAS;AAE7C,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,IAAY,KAAK;EACnE,SAAS;;EACT,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;EACA;EACA,MAAMC,GAAG,GAAG,IAAIX,cAAc,CAACI,IAAI,EAAEK,MAAM,CAAC;EAC5CH,IAAI,CAACM,OAAO,CAAEC,IAAI,IAAK;IACrBZ,IAAI,CAACU,GAAG,EAAEE,IAAI,CAAC;EACjB,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
+ import type { DrawingNodeProps, GroupProps } from "../dom/types";
2
+ import { DeclarationContext } from "../dom/types";
3
+ import type { SkCanvas, Skia, SkPaint } from "../skia/types";
4
+ export declare class DrawingContext {
5
+ private paints;
6
+ declCtx: DeclarationContext;
7
+ Skia: Skia;
8
+ canvas: SkCanvas;
9
+ constructor(Skia: Skia, canvas: SkCanvas);
10
+ save(): void;
11
+ restore(): void;
12
+ get paint(): SkPaint;
13
+ getLocalPaints(): SkPaint[];
14
+ processPaint({ opacity, color, strokeWidth, blendMode, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, paint: paintProp, }: DrawingNodeProps): boolean;
15
+ processMatrixAndClipping(props: GroupProps, layer?: boolean | SkPaint): boolean;
16
+ }
@@ -0,0 +1,180 @@
1
+ "worklet";
2
+
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import { enumKey, isPathDef, processPath, processTransformProps2 } from "../dom/nodes";
7
+ import { DeclarationContext } from "../dom/types";
8
+ import { BlendMode, ClipOp, isRRect, PaintStyle, StrokeCap, StrokeJoin } from "../skia/types";
9
+ const computeClip = (Skia, clip) => {
10
+ if (clip) {
11
+ if (isPathDef(clip)) {
12
+ return {
13
+ clipPath: processPath(Skia, clip)
14
+ };
15
+ } else if (isRRect(clip)) {
16
+ return {
17
+ clipRRect: clip
18
+ };
19
+ } else {
20
+ return {
21
+ clipRect: clip
22
+ };
23
+ }
24
+ }
25
+ return undefined;
26
+ };
27
+ export class DrawingContext {
28
+ constructor(Skia, canvas) {
29
+ _defineProperty(this, "paints", void 0);
30
+ _defineProperty(this, "declCtx", void 0);
31
+ _defineProperty(this, "Skia", void 0);
32
+ _defineProperty(this, "canvas", void 0);
33
+ this.Skia = Skia;
34
+ this.canvas = canvas;
35
+ this.paints = [Skia.Paint()];
36
+ this.declCtx = new DeclarationContext(this.Skia);
37
+ }
38
+ save() {
39
+ this.paints.push(this.paint.copy());
40
+ }
41
+ restore() {
42
+ this.paints.pop();
43
+ }
44
+ get paint() {
45
+ const paint = this.paints[this.paints.length - 1];
46
+ if (!paint) {
47
+ throw new Error("Paint is undefined");
48
+ }
49
+ return paint;
50
+ }
51
+ getLocalPaints() {
52
+ const {
53
+ paint
54
+ } = this;
55
+ return [paint, ...this.declCtx.paints.popAll()];
56
+ }
57
+ processPaint({
58
+ opacity,
59
+ color,
60
+ strokeWidth,
61
+ blendMode,
62
+ style,
63
+ strokeJoin,
64
+ strokeCap,
65
+ strokeMiter,
66
+ antiAlias,
67
+ dither,
68
+ paint: paintProp
69
+ }) {
70
+ if (paintProp) {
71
+ this.declCtx.paints.push(paintProp);
72
+ return true;
73
+ }
74
+ let shouldRestore = false;
75
+ const colorFilter = this.declCtx.colorFilters.popAllAsOne();
76
+ const imageFilter = this.declCtx.imageFilters.popAllAsOne();
77
+ const shader = this.declCtx.shaders.pop();
78
+ const maskFilter = this.declCtx.maskFilters.pop();
79
+ const pathEffect = this.declCtx.pathEffects.popAllAsOne();
80
+ if (opacity !== undefined || color !== undefined || strokeWidth !== undefined || blendMode !== undefined || style !== undefined || strokeJoin !== undefined || strokeCap !== undefined || strokeMiter !== undefined || antiAlias !== undefined || dither !== undefined || colorFilter !== undefined || imageFilter !== undefined || shader !== undefined || maskFilter !== undefined || pathEffect !== undefined) {
81
+ if (!shouldRestore) {
82
+ this.save();
83
+ shouldRestore = true;
84
+ }
85
+ }
86
+ const {
87
+ paint
88
+ } = this;
89
+ if (opacity !== undefined) {
90
+ paint.setAlphaf(paint.getAlphaf() * opacity);
91
+ }
92
+ if (color !== undefined) {
93
+ const currentOpacity = paint.getAlphaf();
94
+ paint.setShader(null);
95
+ if (typeof color === "string" || typeof color === "number") {
96
+ paint.setColor(this.Skia.Color(color));
97
+ } else if (Array.isArray(color)) {
98
+ paint.setColor(new Float32Array(color));
99
+ } else if (color instanceof Float32Array) {
100
+ paint.setColor(color);
101
+ } else {
102
+ throw new Error("Invalid color");
103
+ }
104
+ paint.setAlphaf(currentOpacity * paint.getAlphaf());
105
+ }
106
+ if (strokeWidth !== undefined) {
107
+ paint.setStrokeWidth(strokeWidth);
108
+ }
109
+ if (blendMode !== undefined) {
110
+ paint.setBlendMode(BlendMode[enumKey(blendMode)]);
111
+ }
112
+ if (style !== undefined) {
113
+ paint.setStyle(PaintStyle[enumKey(style)]);
114
+ }
115
+ if (strokeJoin !== undefined) {
116
+ paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);
117
+ }
118
+ if (strokeCap !== undefined) {
119
+ paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);
120
+ }
121
+ if (strokeMiter !== undefined) {
122
+ paint.setStrokeMiter(strokeMiter);
123
+ }
124
+ if (antiAlias !== undefined) {
125
+ paint.setAntiAlias(antiAlias);
126
+ }
127
+ if (dither !== undefined) {
128
+ paint.setDither(dither);
129
+ }
130
+ if (colorFilter) {
131
+ paint.setColorFilter(colorFilter);
132
+ }
133
+ if (imageFilter) {
134
+ paint.setImageFilter(imageFilter);
135
+ }
136
+ if (shader) {
137
+ paint.setShader(shader);
138
+ }
139
+ if (maskFilter) {
140
+ paint.setMaskFilter(maskFilter);
141
+ }
142
+ if (pathEffect) {
143
+ paint.setPathEffect(pathEffect);
144
+ }
145
+ return shouldRestore;
146
+ }
147
+ processMatrixAndClipping(props, layer) {
148
+ const hasTransform = props.matrix !== undefined || props.transform !== undefined;
149
+ const clip = computeClip(this.Skia, props.clip);
150
+ const hasClip = clip !== undefined;
151
+ const op = props.invertClip ? ClipOp.Difference : ClipOp.Intersect;
152
+ const m3 = processTransformProps2(this.Skia, props);
153
+ const shouldSave = hasTransform || hasClip || !!layer;
154
+ if (shouldSave) {
155
+ if (layer) {
156
+ if (typeof layer === "boolean") {
157
+ this.canvas.saveLayer();
158
+ } else {
159
+ this.canvas.saveLayer(layer);
160
+ }
161
+ } else {
162
+ this.canvas.save();
163
+ }
164
+ }
165
+ if (m3) {
166
+ this.canvas.concat(m3);
167
+ }
168
+ if (clip) {
169
+ if ("clipRect" in clip) {
170
+ this.canvas.clipRect(clip.clipRect, op, true);
171
+ } else if ("clipRRect" in clip) {
172
+ this.canvas.clipRRect(clip.clipRRect, op, true);
173
+ } else {
174
+ this.canvas.clipPath(clip.clipPath, op, true);
175
+ }
176
+ }
177
+ return shouldSave;
178
+ }
179
+ }
180
+ //# sourceMappingURL=DrawingContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","enumKey","isPathDef","processPath","processTransformProps2","DeclarationContext","BlendMode","ClipOp","isRRect","PaintStyle","StrokeCap","StrokeJoin","computeClip","Skia","clip","clipPath","clipRRect","clipRect","undefined","DrawingContext","constructor","canvas","paints","Paint","declCtx","save","push","paint","copy","restore","pop","length","Error","getLocalPaints","popAll","processPaint","opacity","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paintProp","shouldRestore","colorFilter","colorFilters","popAllAsOne","imageFilter","imageFilters","shader","shaders","maskFilter","maskFilters","pathEffect","pathEffects","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","Color","Array","isArray","Float32Array","setStrokeWidth","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","processMatrixAndClipping","props","layer","hasTransform","matrix","transform","hasClip","op","invertClip","Difference","Intersect","m3","shouldSave","saveLayer","concat"],"sources":["DrawingContext.ts"],"sourcesContent":["\"worklet\";\n\nimport {\n enumKey,\n isPathDef,\n processPath,\n processTransformProps2,\n} from \"../dom/nodes\";\nimport type { ClipDef, DrawingNodeProps, GroupProps } from \"../dom/types\";\nimport { DeclarationContext } from \"../dom/types\";\nimport {\n BlendMode,\n ClipOp,\n isRRect,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../skia/types\";\nimport type {\n SkPath,\n SkRect,\n SkRRect,\n SkCanvas,\n Skia,\n SkPaint,\n} from \"../skia/types\";\n\nconst computeClip = (\n Skia: Skia,\n clip: ClipDef | undefined\n):\n | undefined\n | { clipPath: SkPath }\n | { clipRect: SkRect }\n | { clipRRect: SkRRect } => {\n if (clip) {\n if (isPathDef(clip)) {\n return { clipPath: processPath(Skia, clip) };\n } else if (isRRect(clip)) {\n return { clipRRect: clip };\n } else {\n return { clipRect: clip };\n }\n }\n return undefined;\n};\n\nexport class DrawingContext {\n private paints: SkPaint[];\n public declCtx: DeclarationContext;\n public Skia: Skia;\n public canvas: SkCanvas;\n\n constructor(Skia: Skia, canvas: SkCanvas) {\n this.Skia = Skia;\n this.canvas = canvas;\n this.paints = [Skia.Paint()];\n this.declCtx = new DeclarationContext(this.Skia);\n }\n\n save() {\n this.paints.push(this.paint.copy());\n }\n\n restore() {\n this.paints.pop();\n }\n\n get paint() {\n const paint = this.paints[this.paints.length - 1];\n if (!paint) {\n throw new Error(\"Paint is undefined\");\n }\n return paint;\n }\n\n getLocalPaints() {\n const { paint } = this;\n return [paint, ...this.declCtx.paints.popAll()];\n }\n\n processPaint({\n opacity,\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n paint: paintProp,\n }: DrawingNodeProps) {\n if (paintProp) {\n this.declCtx.paints.push(paintProp);\n return true;\n }\n let shouldRestore = false;\n const colorFilter = this.declCtx.colorFilters.popAllAsOne();\n const imageFilter = this.declCtx.imageFilters.popAllAsOne();\n const shader = this.declCtx.shaders.pop();\n const maskFilter = this.declCtx.maskFilters.pop();\n const pathEffect = this.declCtx.pathEffects.popAllAsOne();\n if (\n opacity !== undefined ||\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n antiAlias !== undefined ||\n dither !== undefined ||\n colorFilter !== undefined ||\n imageFilter !== undefined ||\n shader !== undefined ||\n maskFilter !== undefined ||\n pathEffect !== undefined\n ) {\n if (!shouldRestore) {\n this.save();\n shouldRestore = true;\n }\n }\n const { paint } = this;\n if (opacity !== undefined) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n }\n if (color !== undefined) {\n const currentOpacity = paint.getAlphaf();\n paint.setShader(null);\n if (typeof color === \"string\" || typeof color === \"number\") {\n paint.setColor(this.Skia.Color(color));\n } else if (Array.isArray(color)) {\n paint.setColor(new Float32Array(color));\n } else if (color instanceof Float32Array) {\n paint.setColor(color);\n } else {\n throw new Error(\"Invalid color\");\n }\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n if (colorFilter) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter) {\n paint.setImageFilter(imageFilter);\n }\n if (shader) {\n paint.setShader(shader);\n }\n if (maskFilter) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect) {\n paint.setPathEffect(pathEffect);\n }\n return shouldRestore;\n }\n\n processMatrixAndClipping(props: GroupProps, layer?: boolean | SkPaint) {\n const hasTransform =\n props.matrix !== undefined || props.transform !== undefined;\n const clip = computeClip(this.Skia, props.clip);\n const hasClip = clip !== undefined;\n const op = props.invertClip ? ClipOp.Difference : ClipOp.Intersect;\n const m3 = processTransformProps2(this.Skia, props);\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n this.canvas.saveLayer();\n } else {\n this.canvas.saveLayer(layer);\n }\n } else {\n this.canvas.save();\n }\n }\n\n if (m3) {\n this.canvas.concat(m3);\n }\n if (clip) {\n if (\"clipRect\" in clip) {\n this.canvas.clipRect(clip.clipRect, op, true);\n } else if (\"clipRRect\" in clip) {\n this.canvas.clipRRect(clip.clipRRect, op, true);\n } else {\n this.canvas.clipPath(clip.clipPath, op, true);\n }\n }\n return shouldSave;\n }\n}\n"],"mappings":"AAAA,SAAS;;AAAC,SAAAA,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ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UAAU,IAAIA,IAAI,EAAE;QACtB,IAAI,CAACO,MAAM,CAACJ,QAAQ,CAACH,IAAI,CAACG,QAAQ,EAAEsE,EAAE,EAAE,IAAI,CAAC;MAC/C,CAAC,MAAM,IAAI,WAAW,IAAIzE,IAAI,EAAE;QAC9B,IAAI,CAACO,MAAM,CAACL,SAAS,CAACF,IAAI,CAACE,SAAS,EAAEuE,EAAE,EAAE,IAAI,CAAC;MACjD,CAAC,MAAM;QACL,IAAI,CAAClE,MAAM,CAACN,QAAQ,CAACD,IAAI,CAACC,QAAQ,EAAEwE,EAAE,EAAE,IAAI,CAAC;MAC/C;IACF;IACA,OAAOK,UAAU;EACnB;AACF","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import type { HostConfig } from "react-reconciler";
2
+ import { NodeType } from "../dom/types";
3
+ import type { Node } from "./nodes/Node";
4
+ import type { Container } from "./Container";
5
+ export declare const debug: (message?: any, ...optionalParams: any[]) => void;
6
+ type Instance = Node;
7
+ type Props = object;
8
+ type TextInstance = Node;
9
+ type SuspenseInstance = Instance;
10
+ type HydratableInstance = Instance;
11
+ type PublicInstance = Instance;
12
+ type HostContext = null;
13
+ type UpdatePayload = Container;
14
+ type ChildSet = Node[];
15
+ type TimeoutHandle = NodeJS.Timeout;
16
+ type NoTimeout = -1;
17
+ type SkiaHostConfig = HostConfig<NodeType, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
18
+ export declare const sksgHostConfig: SkiaHostConfig;
19
+ export {};
@@ -0,0 +1,161 @@
1
+ /*global NodeJS*/
2
+
3
+ import { DefaultEventPriority } from "react-reconciler/constants";
4
+ import { NodeType } from "../dom/types";
5
+ import { shallowEq } from "../renderer/typeddash";
6
+ const DEBUG = false;
7
+ export const debug = (...args) => {
8
+ if (DEBUG) {
9
+ console.log(...args);
10
+ }
11
+ };
12
+ const isDeclaration = type => {
13
+ "worklet";
14
+
15
+ return (
16
+ // BlurMaskFilters
17
+ type === NodeType.BlurMaskFilter ||
18
+ // ImageFilters
19
+ type === NodeType.BlendImageFilter || type === NodeType.BlurImageFilter || type === NodeType.OffsetImageFilter || type === NodeType.DropShadowImageFilter || type === NodeType.MorphologyImageFilter || type === NodeType.DisplacementMapImageFilter || type === NodeType.RuntimeShaderImageFilter ||
20
+ // ColorFilters
21
+ type === NodeType.MatrixColorFilter || type === NodeType.BlendColorFilter || type === NodeType.LumaColorFilter || type === NodeType.LinearToSRGBGammaColorFilter || type === NodeType.SRGBToLinearGammaColorFilter || type === NodeType.LerpColorFilter ||
22
+ // Shaders
23
+ type === NodeType.Shader || type === NodeType.ImageShader || type === NodeType.ColorShader || type === NodeType.Turbulence || type === NodeType.FractalNoise || type === NodeType.LinearGradient || type === NodeType.RadialGradient || type === NodeType.SweepGradient || type === NodeType.TwoPointConicalGradient ||
24
+ // Path Effects
25
+ type === NodeType.CornerPathEffect || type === NodeType.DiscretePathEffect || type === NodeType.DashPathEffect || type === NodeType.Path1DPathEffect || type === NodeType.Path2DPathEffect || type === NodeType.SumPathEffect || type === NodeType.Line2DPathEffect ||
26
+ // Mixed
27
+ type === NodeType.Blend ||
28
+ // Paint
29
+ type === NodeType.Paint
30
+ );
31
+ };
32
+ export const sksgHostConfig = {
33
+ /**
34
+ * This function is used by the reconciler in order to calculate current time for prioritising work.
35
+ */
36
+ supportsMutation: false,
37
+ isPrimaryRenderer: false,
38
+ supportsPersistence: true,
39
+ supportsHydration: false,
40
+ //supportsMicrotask: true,
41
+ scheduleTimeout: setTimeout,
42
+ cancelTimeout: clearTimeout,
43
+ noTimeout: -1,
44
+ getRootHostContext: _rootContainerInstance => {
45
+ debug("getRootHostContext");
46
+ return null;
47
+ },
48
+ getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {
49
+ debug("getChildHostContext");
50
+ return null;
51
+ },
52
+ shouldSetTextContent(_type, _props) {
53
+ return false;
54
+ },
55
+ createTextInstance(_text, _rootContainerInstance, _hostContext, _internalInstanceHandle) {
56
+ debug("createTextInstance");
57
+ // return SpanNode({}, text) as SkNode;
58
+ throw new Error("Text nodes are not supported yet");
59
+ },
60
+ createInstance(type, props, container, _hostContext, _internalInstanceHandle) {
61
+ debug("createInstance", type);
62
+ container.registerValues(props);
63
+ const instance = {
64
+ type,
65
+ isDeclaration: isDeclaration(type),
66
+ props,
67
+ children: []
68
+ };
69
+ return instance;
70
+ },
71
+ appendInitialChild(parentInstance, child) {
72
+ parentInstance.children.push(child);
73
+ },
74
+ finalizeInitialChildren(parentInstance, _type, _props, _rootContainerInstance, _hostContext) {
75
+ debug("finalizeInitialChildren", parentInstance);
76
+ return false;
77
+ },
78
+ commitMount() {
79
+ // if finalizeInitialChildren = true
80
+ debug("commitMount");
81
+ },
82
+ prepareForCommit(_containerInfo) {
83
+ debug("prepareForCommit");
84
+ return null;
85
+ },
86
+ resetAfterCommit(container) {
87
+ debug("resetAfterCommit");
88
+ container.redraw();
89
+ },
90
+ getPublicInstance(node) {
91
+ debug("getPublicInstance");
92
+ return node;
93
+ },
94
+ commitTextUpdate: (_textInstance, _oldText, _newText) => {
95
+ // textInstance.instance = newText;
96
+ },
97
+ clearContainer: container => {
98
+ debug("clearContainer");
99
+ container.clear();
100
+ },
101
+ prepareUpdate(_instance, _type, oldProps, newProps, container, _hostContext) {
102
+ debug("prepareUpdate");
103
+ const propsAreEqual = shallowEq(oldProps, newProps);
104
+ if (propsAreEqual) {
105
+ return null;
106
+ }
107
+ container.unregisterValues(oldProps);
108
+ container.registerValues(newProps);
109
+ return container;
110
+ },
111
+ preparePortalMount: () => {
112
+ debug("preparePortalMount");
113
+ },
114
+ cloneInstance(instance, _updatePayload, _type, _oldProps, newProps, _internalInstanceHandle, keepChildren, _recyclableInstance) {
115
+ debug("cloneInstance");
116
+ return {
117
+ type: instance.type,
118
+ props: newProps,
119
+ children: keepChildren ? [...instance.children] : [],
120
+ isDeclaration: instance.isDeclaration
121
+ };
122
+ },
123
+ createContainerChildSet() {
124
+ debug("createContainerChildSet");
125
+ return [];
126
+ },
127
+ appendChildToContainerChildSet(childSet, child) {
128
+ childSet.push(child);
129
+ },
130
+ finalizeContainerChildren(container, newChildren) {
131
+ debug("finalizeContainerChildren");
132
+ container.root = newChildren;
133
+ },
134
+ replaceContainerChildren(container, newChildren) {
135
+ debug("replaceContainerChildren");
136
+ container.root = newChildren;
137
+ },
138
+ cloneHiddenInstance(_instance, _type, _props) {
139
+ debug("cloneHiddenInstance");
140
+ throw new Error("Not yet implemented.");
141
+ },
142
+ cloneHiddenTextInstance(_instance, _text) {
143
+ debug("cloneHiddenTextInstance");
144
+ throw new Error("Not yet implemented.");
145
+ },
146
+ // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
147
+ getCurrentEventPriority: () => DefaultEventPriority,
148
+ beforeActiveInstanceBlur: () => {},
149
+ afterActiveInstanceBlur: () => {},
150
+ detachDeletedInstance: () => {},
151
+ getInstanceFromNode: function (_node) {
152
+ throw new Error("Function not implemented.");
153
+ },
154
+ prepareScopeUpdate: function (_scopeInstance, _instance) {
155
+ throw new Error("Function not implemented.");
156
+ },
157
+ getInstanceFromScope: function (_scopeInstance) {
158
+ throw new Error("Function not implemented.");
159
+ }
160
+ };
161
+ //# sourceMappingURL=HostConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DefaultEventPriority","NodeType","shallowEq","DEBUG","debug","args","console","log","isDeclaration","type","BlurMaskFilter","BlendImageFilter","BlurImageFilter","OffsetImageFilter","DropShadowImageFilter","MorphologyImageFilter","DisplacementMapImageFilter","RuntimeShaderImageFilter","MatrixColorFilter","BlendColorFilter","LumaColorFilter","LinearToSRGBGammaColorFilter","SRGBToLinearGammaColorFilter","LerpColorFilter","Shader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","CornerPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","SumPathEffect","Line2DPathEffect","Blend","Paint","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","props","container","registerValues","instance","children","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","resetAfterCommit","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","clear","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","unregisterValues","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","getInstanceFromNode","_node","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./nodes/Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\nconst isDeclaration = (type: NodeType) => {\n \"worklet\";\n return (\n // BlurMaskFilters\n type === NodeType.BlurMaskFilter ||\n // ImageFilters\n type === NodeType.BlendImageFilter ||\n type === NodeType.BlurImageFilter ||\n type === NodeType.OffsetImageFilter ||\n type === NodeType.DropShadowImageFilter ||\n type === NodeType.MorphologyImageFilter ||\n type === NodeType.DisplacementMapImageFilter ||\n type === NodeType.RuntimeShaderImageFilter ||\n // ColorFilters\n type === NodeType.MatrixColorFilter ||\n type === NodeType.BlendColorFilter ||\n type === NodeType.LumaColorFilter ||\n type === NodeType.LinearToSRGBGammaColorFilter ||\n type === NodeType.SRGBToLinearGammaColorFilter ||\n type === NodeType.LerpColorFilter ||\n // Shaders\n type === NodeType.Shader ||\n type === NodeType.ImageShader ||\n type === NodeType.ColorShader ||\n type === NodeType.Turbulence ||\n type === NodeType.FractalNoise ||\n type === NodeType.LinearGradient ||\n type === NodeType.RadialGradient ||\n type === NodeType.SweepGradient ||\n type === NodeType.TwoPointConicalGradient ||\n // Path Effects\n type === NodeType.CornerPathEffect ||\n type === NodeType.DiscretePathEffect ||\n type === NodeType.DashPathEffect ||\n type === NodeType.Path1DPathEffect ||\n type === NodeType.Path2DPathEffect ||\n type === NodeType.SumPathEffect ||\n type === NodeType.Line2DPathEffect ||\n // Mixed\n type === NodeType.Blend ||\n // Paint\n type === NodeType.Paint\n );\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n props,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n container.registerValues(props);\n const instance = {\n type,\n isDeclaration: isDeclaration(type),\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (container) => {\n debug(\"clearContainer\");\n container.clear();\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n container.unregisterValues(oldProps);\n container.registerValues(newProps);\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: newProps,\n children: keepChildren ? [...instance.children] : [],\n isDeclaration: instance.isDeclaration,\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"replaceContainerChildren\");\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: () => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ,4BAA4B;AAEjE,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,QAAQ,uBAAuB;AAKjD,MAAMC,KAAK,GAAG,KAAK;AACnB,OAAO,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AAED,MAAMG,aAAa,GAAIC,IAAc,IAAK;EACxC,SA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AED6C,uBAAuBA,CAACnB,SAAmB,EAAE7B,KAAa,EAAgB;IACxExD,KAAK,CAAC,yBAAyB,CAAC;IAChC,MAAM,IAAI2D,KAAK,CAAC,sBAAsB,CAAC;EACzC,CAAC;EACD;EACA8C,uBAAuB,EAAEA,CAAA,KAAM7G,oBAAoB;EACnD8G,wBAAwB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClCC,uBAAuB,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjCC,qBAAqB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC/BC,mBAAmB,EAAE,SAAAA,CAAUC,KAAK,EAA4B;IAC9D,MAAM,IAAInD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDoD,kBAAkB,EAAE,SAAAA,CAAUC,cAAc,EAAE3B,SAAS,EAAQ;IAC7D,MAAM,IAAI1B,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDsD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAIrD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from "react";
2
+ import type { SkCanvas, Skia } from "../skia/types";
3
+ import { NodeType } from "../dom/types";
4
+ export declare class SkiaSGRoot {
5
+ private root;
6
+ private container;
7
+ constructor(Skia: Skia, nativeId?: number);
8
+ get sg(): {
9
+ type: NodeType;
10
+ props: {};
11
+ children: import("./nodes").Node<unknown>[];
12
+ isDeclaration: boolean;
13
+ };
14
+ render(element: ReactNode): void;
15
+ drawOnCanvas(canvas: SkCanvas): void;
16
+ unmount(): void;
17
+ }
@@ -0,0 +1,46 @@
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
+ import ReactReconciler from "react-reconciler";
5
+ import { NodeType } from "../dom/types";
6
+ import { debug, sksgHostConfig } from "./HostConfig";
7
+ import { Container } from "./Container";
8
+ const skiaReconciler = ReactReconciler(sksgHostConfig);
9
+ skiaReconciler.injectIntoDevTools({
10
+ bundleType: 1,
11
+ version: "0.0.1",
12
+ rendererPackageName: "react-native-skia"
13
+ });
14
+ export class SkiaSGRoot {
15
+ constructor(Skia, nativeId = -1) {
16
+ _defineProperty(this, "root", void 0);
17
+ _defineProperty(this, "container", void 0);
18
+ this.container = new Container(Skia, nativeId);
19
+ this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
20
+ }
21
+ get sg() {
22
+ const children = this.container.root;
23
+ return {
24
+ type: NodeType.Group,
25
+ props: {},
26
+ children,
27
+ isDeclaration: false
28
+ };
29
+ }
30
+ render(element) {
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ skiaReconciler.updateContainer(element, this.root, null, () => {
33
+ debug("updateContainer");
34
+ });
35
+ }
36
+ drawOnCanvas(canvas) {
37
+ this.container.drawOnCanvas(canvas);
38
+ }
39
+ unmount() {
40
+ this.container.unmounted = true;
41
+ skiaReconciler.updateContainer(null, this.root, null, () => {
42
+ debug("unmountContainer");
43
+ });
44
+ }
45
+ }
46
+ //# sourceMappingURL=Reconciler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","Container","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","createContainer","console","error","sg","children","type","Group","props","isDeclaration","render","element","updateContainer","drawOnCanvas","canvas","unmount","unmounted"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(Skia: Skia, nativeId = -1) {\n this.container = new Container(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n unmount() {\n this.container.unmounted = true;\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AACpD,SAASC,SAAS,QAAQ,aAAa;AAEvC,MAAMC,cAAc,GAAGL,eAAe,CAACG,cAAc,CAAC;AAEtDE,cAAc,CAACC,kBAAkB,CAAC;EAChCC,UAAU,EAAE,CAAC;EACbC,OAAO,EAAE,OAAO;EAChBC,mBAAmB,EAAE;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAACC,IAAU,EAAEC,QAAQ,G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