@shopify/react-native-skia 1.8.0 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (390) hide show
  1. package/cpp/api/JsiSkPaint.h +8 -1
  2. package/lib/commonjs/dom/types/Common.d.ts +6 -4
  3. package/lib/commonjs/dom/types/Common.js.map +1 -1
  4. package/lib/commonjs/dom/types/ImageFilters.d.ts +1 -1
  5. package/lib/commonjs/dom/types/ImageFilters.js.map +1 -1
  6. package/lib/commonjs/dom/types/Node.d.ts +0 -2
  7. package/lib/commonjs/dom/types/Node.js.map +1 -1
  8. package/lib/commonjs/external/reanimated/index.d.ts +0 -1
  9. package/lib/commonjs/external/reanimated/index.js +0 -11
  10. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  11. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
  12. package/lib/commonjs/external/reanimated/renderHelpers.js +5 -43
  13. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  14. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +1 -8
  15. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  16. package/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
  17. package/lib/commonjs/skia/core/AnimatedImage.js +1 -1
  18. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
  19. package/lib/commonjs/skia/core/Data.d.ts +1 -1
  20. package/lib/commonjs/skia/core/Data.js +2 -8
  21. package/lib/commonjs/skia/core/Data.js.map +1 -1
  22. package/lib/commonjs/skia/types/Paint/Paint.d.ts +1 -0
  23. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  24. package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
  25. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -0
  26. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  27. package/lib/commonjs/sksg/Container.d.ts +3 -2
  28. package/lib/commonjs/sksg/Container.js +32 -26
  29. package/lib/commonjs/sksg/Container.js.map +1 -1
  30. package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
  31. package/lib/commonjs/sksg/HostConfig.js +7 -25
  32. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  33. package/lib/commonjs/sksg/Node.d.ts +19 -0
  34. package/lib/commonjs/sksg/Node.js +78 -0
  35. package/lib/commonjs/sksg/Node.js.map +1 -0
  36. package/lib/commonjs/sksg/Reconciler.d.ts +1 -1
  37. package/lib/commonjs/sksg/Recorder/Core.d.ts +79 -0
  38. package/lib/commonjs/sksg/Recorder/Core.js +110 -0
  39. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -0
  40. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +18 -0
  41. package/lib/commonjs/sksg/Recorder/DrawingContext.js +105 -0
  42. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -0
  43. package/lib/commonjs/sksg/Recorder/Player.d.ts +3 -0
  44. package/lib/commonjs/sksg/Recorder/Player.js +127 -0
  45. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -0
  46. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +50 -0
  47. package/lib/commonjs/sksg/Recorder/Recorder.js +288 -0
  48. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -0
  49. package/lib/commonjs/sksg/Recorder/Recording.d.ts +7 -0
  50. package/lib/commonjs/sksg/Recorder/Recording.js +12 -0
  51. package/lib/commonjs/sksg/Recorder/Recording.js.map +1 -0
  52. package/lib/commonjs/sksg/Recorder/Visitor.d.ts +5 -0
  53. package/lib/commonjs/sksg/Recorder/Visitor.js +293 -0
  54. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -0
  55. package/lib/commonjs/sksg/Recorder/commands/Box.d.ts +13 -0
  56. package/lib/commonjs/sksg/Recorder/commands/Box.js +71 -0
  57. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -0
  58. package/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +3 -0
  59. package/lib/commonjs/sksg/Recorder/commands/CTM.js +79 -0
  60. package/lib/commonjs/sksg/Recorder/commands/CTM.js.map +1 -0
  61. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  62. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js +76 -0
  63. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -0
  64. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +24 -0
  65. package/lib/commonjs/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
  66. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -0
  67. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  68. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +183 -0
  69. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -0
  70. package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +4 -0
  71. package/lib/commonjs/sksg/Recorder/commands/Paint.js +70 -0
  72. package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -0
  73. package/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  74. package/lib/commonjs/sksg/Recorder/commands/PathEffects.js +137 -0
  75. package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -0
  76. package/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +5 -0
  77. package/lib/commonjs/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +58 -15
  78. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -0
  79. package/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  80. package/lib/commonjs/sksg/{nodes/utils.js → utils.js} +12 -2
  81. package/lib/commonjs/sksg/utils.js.map +1 -0
  82. package/lib/module/dom/types/Common.d.ts +6 -4
  83. package/lib/module/dom/types/Common.js.map +1 -1
  84. package/lib/module/dom/types/ImageFilters.d.ts +1 -1
  85. package/lib/module/dom/types/ImageFilters.js.map +1 -1
  86. package/lib/module/dom/types/Node.d.ts +0 -2
  87. package/lib/module/dom/types/Node.js.map +1 -1
  88. package/lib/module/external/reanimated/index.d.ts +0 -1
  89. package/lib/module/external/reanimated/index.js +0 -1
  90. package/lib/module/external/reanimated/index.js.map +1 -1
  91. package/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
  92. package/lib/module/external/reanimated/renderHelpers.js +4 -42
  93. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  94. package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -8
  95. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  96. package/lib/module/skia/core/AnimatedImage.d.ts +1 -1
  97. package/lib/module/skia/core/AnimatedImage.js +1 -1
  98. package/lib/module/skia/core/AnimatedImage.js.map +1 -1
  99. package/lib/module/skia/core/Data.d.ts +1 -1
  100. package/lib/module/skia/core/Data.js +2 -8
  101. package/lib/module/skia/core/Data.js.map +1 -1
  102. package/lib/module/skia/types/Paint/Paint.d.ts +1 -0
  103. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  104. package/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
  105. package/lib/module/skia/web/JsiSkPaint.js +3 -0
  106. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  107. package/lib/module/sksg/Container.d.ts +3 -2
  108. package/lib/module/sksg/Container.js +30 -24
  109. package/lib/module/sksg/Container.js.map +1 -1
  110. package/lib/module/sksg/HostConfig.d.ts +2 -2
  111. package/lib/module/sksg/HostConfig.js +7 -25
  112. package/lib/module/sksg/HostConfig.js.map +1 -1
  113. package/lib/module/sksg/Node.d.ts +19 -0
  114. package/lib/module/sksg/Node.js +67 -0
  115. package/lib/module/sksg/Node.js.map +1 -0
  116. package/lib/module/sksg/Reconciler.d.ts +1 -1
  117. package/lib/module/sksg/Recorder/Core.d.ts +79 -0
  118. package/lib/module/sksg/Recorder/Core.js +101 -0
  119. package/lib/module/sksg/Recorder/Core.js.map +1 -0
  120. package/lib/module/sksg/Recorder/DrawingContext.d.ts +18 -0
  121. package/lib/module/sksg/Recorder/DrawingContext.js +98 -0
  122. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -0
  123. package/lib/module/sksg/Recorder/Player.d.ts +3 -0
  124. package/lib/module/sksg/Recorder/Player.js +120 -0
  125. package/lib/module/sksg/Recorder/Player.js.map +1 -0
  126. package/lib/module/sksg/Recorder/Recorder.d.ts +50 -0
  127. package/lib/module/sksg/Recorder/Recorder.js +281 -0
  128. package/lib/module/sksg/Recorder/Recorder.js.map +1 -0
  129. package/lib/module/sksg/Recorder/Recording.d.ts +7 -0
  130. package/lib/module/sksg/Recorder/Recording.js +5 -0
  131. package/lib/module/sksg/Recorder/Recording.js.map +1 -0
  132. package/lib/module/sksg/Recorder/Visitor.d.ts +5 -0
  133. package/lib/module/sksg/Recorder/Visitor.js +285 -0
  134. package/lib/module/sksg/Recorder/Visitor.js.map +1 -0
  135. package/lib/module/sksg/Recorder/commands/Box.d.ts +13 -0
  136. package/lib/module/sksg/Recorder/commands/Box.js +63 -0
  137. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -0
  138. package/lib/module/sksg/Recorder/commands/CTM.d.ts +3 -0
  139. package/lib/module/sksg/Recorder/commands/CTM.js +72 -0
  140. package/lib/module/sksg/Recorder/commands/CTM.js.map +1 -0
  141. package/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  142. package/lib/module/sksg/Recorder/commands/ColorFilters.js +67 -0
  143. package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -0
  144. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +24 -0
  145. package/lib/module/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
  146. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -0
  147. package/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  148. package/lib/module/sksg/{nodes/imageFilters.js → Recorder/commands/ImageFilters.js} +87 -95
  149. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -0
  150. package/lib/module/sksg/Recorder/commands/Paint.d.ts +4 -0
  151. package/lib/module/sksg/Recorder/commands/Paint.js +62 -0
  152. package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -0
  153. package/lib/module/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  154. package/lib/module/sksg/Recorder/commands/PathEffects.js +128 -0
  155. package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -0
  156. package/lib/module/sksg/Recorder/commands/Shaders.d.ts +5 -0
  157. package/lib/module/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +63 -13
  158. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -0
  159. package/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  160. package/lib/module/sksg/{nodes/utils.js → utils.js} +10 -1
  161. package/lib/module/sksg/utils.js.map +1 -0
  162. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
  163. package/lib/typescript/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
  164. package/lib/typescript/lib/commonjs/skia/core/Data.d.ts +1 -1
  165. package/lib/typescript/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
  166. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +4 -0
  167. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -3
  168. package/lib/typescript/lib/commonjs/sksg/Node.d.ts +14 -0
  169. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +5 -0
  170. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +17 -0
  171. package/lib/typescript/lib/commonjs/sksg/Recorder/Player.d.ts +2 -0
  172. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +45 -0
  173. package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +5 -0
  174. package/lib/typescript/lib/commonjs/sksg/Recorder/Visitor.d.ts +27 -0
  175. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Box.d.ts +3 -0
  176. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +2 -0
  177. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +4 -0
  178. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +6 -0
  179. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +14 -0
  180. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +4 -0
  181. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +3 -0
  182. package/lib/typescript/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
  183. package/lib/typescript/lib/module/external/reanimated/index.d.ts +0 -1
  184. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
  185. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  186. package/lib/typescript/lib/module/skia/core/AnimatedImage.d.ts +1 -1
  187. package/lib/typescript/lib/module/skia/core/Data.d.ts +1 -1
  188. package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
  189. package/lib/typescript/lib/module/sksg/Container.d.ts +4 -0
  190. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -3
  191. package/lib/typescript/lib/module/sksg/Node.d.ts +13 -0
  192. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +4 -0
  193. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +16 -0
  194. package/lib/typescript/lib/module/sksg/Recorder/Player.d.ts +1 -0
  195. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +44 -0
  196. package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +4 -0
  197. package/lib/typescript/lib/module/sksg/Recorder/Visitor.d.ts +26 -0
  198. package/lib/typescript/lib/module/sksg/Recorder/commands/Box.d.ts +2 -0
  199. package/lib/typescript/lib/module/sksg/Recorder/commands/CTM.d.ts +1 -0
  200. package/lib/typescript/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +3 -0
  201. package/lib/typescript/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +5 -0
  202. package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +13 -0
  203. package/lib/typescript/lib/module/sksg/Recorder/commands/PathEffects.d.ts +3 -0
  204. package/lib/typescript/lib/module/sksg/Recorder/commands/Shaders.d.ts +2 -0
  205. package/lib/typescript/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
  206. package/lib/typescript/src/dom/types/Common.d.ts +6 -4
  207. package/lib/typescript/src/dom/types/ImageFilters.d.ts +1 -1
  208. package/lib/typescript/src/dom/types/Node.d.ts +0 -2
  209. package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
  210. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -1
  211. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +1 -1
  212. package/lib/typescript/src/skia/core/Data.d.ts +1 -1
  213. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +1 -0
  214. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  215. package/lib/typescript/src/sksg/Container.d.ts +3 -2
  216. package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
  217. package/lib/typescript/src/sksg/Node.d.ts +19 -0
  218. package/lib/typescript/src/sksg/Reconciler.d.ts +1 -1
  219. package/lib/typescript/src/sksg/Recorder/Core.d.ts +79 -0
  220. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +18 -0
  221. package/lib/typescript/src/sksg/Recorder/Player.d.ts +3 -0
  222. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +50 -0
  223. package/lib/typescript/src/sksg/Recorder/Recording.d.ts +7 -0
  224. package/lib/typescript/src/sksg/Recorder/Visitor.d.ts +5 -0
  225. package/lib/typescript/src/sksg/Recorder/commands/Box.d.ts +13 -0
  226. package/lib/typescript/src/sksg/Recorder/commands/CTM.d.ts +3 -0
  227. package/lib/typescript/src/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  228. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +24 -0
  229. package/lib/typescript/src/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  230. package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +4 -0
  231. package/lib/typescript/src/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  232. package/lib/typescript/src/sksg/Recorder/commands/Shaders.d.ts +5 -0
  233. package/lib/typescript/src/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  234. package/package.json +1 -1
  235. package/src/__tests__/snapshots/image-filter/test-shadow.png +0 -0
  236. package/src/dom/types/Common.ts +7 -5
  237. package/src/dom/types/ImageFilters.ts +2 -1
  238. package/src/dom/types/Node.ts +0 -4
  239. package/src/external/reanimated/index.ts +0 -1
  240. package/src/external/reanimated/renderHelpers.ts +4 -44
  241. package/src/external/reanimated/useAnimatedImageValue.ts +4 -15
  242. package/src/renderer/__tests__/e2e/ColorFilters.spec.tsx +15 -0
  243. package/src/renderer/__tests__/e2e/Composition/ColorFilterComposition.spec.tsx +23 -2
  244. package/src/renderer/__tests__/e2e/ImageFilters.spec.tsx +91 -2
  245. package/src/renderer/__tests__/setup.tsx +1 -1
  246. package/src/skia/core/AnimatedImage.ts +2 -3
  247. package/src/skia/core/Data.ts +3 -9
  248. package/src/skia/types/Paint/Paint.ts +2 -0
  249. package/src/skia/web/JsiSkPaint.ts +4 -0
  250. package/src/sksg/Container.ts +35 -29
  251. package/src/sksg/HostConfig.ts +5 -50
  252. package/src/sksg/Node.ts +105 -0
  253. package/src/sksg/Recorder/Core.ts +171 -0
  254. package/src/sksg/Recorder/DrawingContext.ts +130 -0
  255. package/src/sksg/Recorder/Player.ts +160 -0
  256. package/src/sksg/Recorder/Recorder.ts +259 -0
  257. package/src/sksg/Recorder/Recording.ts +13 -0
  258. package/src/sksg/Recorder/Visitor.ts +324 -0
  259. package/src/sksg/Recorder/commands/Box.ts +63 -0
  260. package/src/sksg/Recorder/commands/CTM.ts +72 -0
  261. package/src/sksg/Recorder/commands/ColorFilters.ts +87 -0
  262. package/src/sksg/{nodes/drawings.ts → Recorder/commands/Drawing.ts} +29 -65
  263. package/src/sksg/Recorder/commands/ImageFilters.ts +255 -0
  264. package/src/sksg/Recorder/commands/Paint.ts +77 -0
  265. package/src/sksg/Recorder/commands/PathEffects.ts +169 -0
  266. package/src/sksg/{nodes/shaders.ts → Recorder/commands/Shaders.ts} +100 -26
  267. package/src/sksg/{nodes/utils.ts → utils.ts} +14 -1
  268. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  269. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +0 -24
  270. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +0 -1
  271. package/lib/commonjs/sksg/DeclarationContext.d.ts +0 -56
  272. package/lib/commonjs/sksg/DeclarationContext.js +0 -77
  273. package/lib/commonjs/sksg/DeclarationContext.js.map +0 -1
  274. package/lib/commonjs/sksg/DrawingContext.d.ts +0 -13
  275. package/lib/commonjs/sksg/DrawingContext.js +0 -172
  276. package/lib/commonjs/sksg/DrawingContext.js.map +0 -1
  277. package/lib/commonjs/sksg/__tests__/Declarations.spec.d.ts +0 -1
  278. package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +0 -57
  279. package/lib/commonjs/sksg/nodes/Node.d.ts +0 -7
  280. package/lib/commonjs/sksg/nodes/Node.js +0 -6
  281. package/lib/commonjs/sksg/nodes/Node.js.map +0 -1
  282. package/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -10
  283. package/lib/commonjs/sksg/nodes/colorFilters.js +0 -79
  284. package/lib/commonjs/sksg/nodes/colorFilters.js.map +0 -1
  285. package/lib/commonjs/sksg/nodes/context.d.ts +0 -3
  286. package/lib/commonjs/sksg/nodes/context.js +0 -394
  287. package/lib/commonjs/sksg/nodes/context.js.map +0 -1
  288. package/lib/commonjs/sksg/nodes/drawings.d.ts +0 -30
  289. package/lib/commonjs/sksg/nodes/drawings.js.map +0 -1
  290. package/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -17
  291. package/lib/commonjs/sksg/nodes/imageFilters.js +0 -197
  292. package/lib/commonjs/sksg/nodes/imageFilters.js.map +0 -1
  293. package/lib/commonjs/sksg/nodes/index.d.ts +0 -3
  294. package/lib/commonjs/sksg/nodes/index.js +0 -39
  295. package/lib/commonjs/sksg/nodes/index.js.map +0 -1
  296. package/lib/commonjs/sksg/nodes/paint.d.ts +0 -3
  297. package/lib/commonjs/sksg/nodes/paint.js +0 -81
  298. package/lib/commonjs/sksg/nodes/paint.js.map +0 -1
  299. package/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -11
  300. package/lib/commonjs/sksg/nodes/pathEffects.js +0 -111
  301. package/lib/commonjs/sksg/nodes/pathEffects.js.map +0 -1
  302. package/lib/commonjs/sksg/nodes/shaders.d.ts +0 -11
  303. package/lib/commonjs/sksg/nodes/shaders.js.map +0 -1
  304. package/lib/commonjs/sksg/nodes/utils.js.map +0 -1
  305. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  306. package/lib/module/external/reanimated/useDerivedValueOnJS.js +0 -16
  307. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +0 -1
  308. package/lib/module/sksg/DeclarationContext.d.ts +0 -56
  309. package/lib/module/sksg/DeclarationContext.js +0 -69
  310. package/lib/module/sksg/DeclarationContext.js.map +0 -1
  311. package/lib/module/sksg/DrawingContext.d.ts +0 -13
  312. package/lib/module/sksg/DrawingContext.js +0 -165
  313. package/lib/module/sksg/DrawingContext.js.map +0 -1
  314. package/lib/module/sksg/__tests__/Declarations.spec.d.ts +0 -1
  315. package/lib/module/sksg/__tests__/MockDeclaration.d.ts +0 -57
  316. package/lib/module/sksg/nodes/Node.d.ts +0 -7
  317. package/lib/module/sksg/nodes/Node.js +0 -2
  318. package/lib/module/sksg/nodes/Node.js.map +0 -1
  319. package/lib/module/sksg/nodes/colorFilters.d.ts +0 -10
  320. package/lib/module/sksg/nodes/colorFilters.js +0 -66
  321. package/lib/module/sksg/nodes/colorFilters.js.map +0 -1
  322. package/lib/module/sksg/nodes/context.d.ts +0 -3
  323. package/lib/module/sksg/nodes/context.js +0 -387
  324. package/lib/module/sksg/nodes/context.js.map +0 -1
  325. package/lib/module/sksg/nodes/drawings.d.ts +0 -30
  326. package/lib/module/sksg/nodes/drawings.js.map +0 -1
  327. package/lib/module/sksg/nodes/imageFilters.d.ts +0 -17
  328. package/lib/module/sksg/nodes/imageFilters.js.map +0 -1
  329. package/lib/module/sksg/nodes/index.d.ts +0 -3
  330. package/lib/module/sksg/nodes/index.js +0 -4
  331. package/lib/module/sksg/nodes/index.js.map +0 -1
  332. package/lib/module/sksg/nodes/paint.d.ts +0 -3
  333. package/lib/module/sksg/nodes/paint.js +0 -74
  334. package/lib/module/sksg/nodes/paint.js.map +0 -1
  335. package/lib/module/sksg/nodes/pathEffects.d.ts +0 -11
  336. package/lib/module/sksg/nodes/pathEffects.js +0 -97
  337. package/lib/module/sksg/nodes/pathEffects.js.map +0 -1
  338. package/lib/module/sksg/nodes/shaders.d.ts +0 -11
  339. package/lib/module/sksg/nodes/shaders.js.map +0 -1
  340. package/lib/module/sksg/nodes/utils.js.map +0 -1
  341. package/lib/typescript/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -2
  342. package/lib/typescript/lib/commonjs/sksg/DeclarationContext.d.ts +0 -53
  343. package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +0 -22
  344. package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +0 -1
  345. package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -8
  346. package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +0 -2
  347. package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -12
  348. package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +0 -1
  349. package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +0 -2
  350. package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -9
  351. package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +0 -10
  352. package/lib/typescript/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  353. package/lib/typescript/lib/module/sksg/DeclarationContext.d.ts +0 -52
  354. package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +0 -21
  355. package/lib/typescript/lib/module/sksg/nodes/Node.d.ts +0 -1
  356. package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +0 -7
  357. package/lib/typescript/lib/module/sksg/nodes/context.d.ts +0 -1
  358. package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +0 -11
  359. package/lib/typescript/lib/module/sksg/nodes/index.d.ts +0 -3
  360. package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +0 -1
  361. package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +0 -8
  362. package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +0 -9
  363. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  364. package/lib/typescript/src/sksg/DeclarationContext.d.ts +0 -56
  365. package/lib/typescript/src/sksg/DrawingContext.d.ts +0 -13
  366. package/lib/typescript/src/sksg/__tests__/Declarations.spec.d.ts +0 -1
  367. package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +0 -57
  368. package/lib/typescript/src/sksg/nodes/Node.d.ts +0 -7
  369. package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +0 -10
  370. package/lib/typescript/src/sksg/nodes/context.d.ts +0 -3
  371. package/lib/typescript/src/sksg/nodes/drawings.d.ts +0 -30
  372. package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +0 -17
  373. package/lib/typescript/src/sksg/nodes/index.d.ts +0 -3
  374. package/lib/typescript/src/sksg/nodes/paint.d.ts +0 -3
  375. package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +0 -11
  376. package/lib/typescript/src/sksg/nodes/shaders.d.ts +0 -11
  377. package/src/external/reanimated/useDerivedValueOnJS.ts +0 -20
  378. package/src/sksg/DeclarationContext.ts +0 -85
  379. package/src/sksg/DrawingContext.ts +0 -226
  380. package/src/sksg/__tests__/Declarations.spec.tsx +0 -235
  381. package/src/sksg/__tests__/MockDeclaration.ts +0 -138
  382. package/src/sksg/nodes/Node.ts +0 -8
  383. package/src/sksg/nodes/colorFilters.ts +0 -79
  384. package/src/sksg/nodes/context.ts +0 -412
  385. package/src/sksg/nodes/imageFilters.ts +0 -235
  386. package/src/sksg/nodes/index.ts +0 -3
  387. package/src/sksg/nodes/paint.ts +0 -75
  388. package/src/sksg/nodes/pathEffects.ts +0 -118
  389. /package/lib/typescript/lib/commonjs/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
  390. /package/lib/typescript/lib/module/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["enumKey","processRadius","NodeType","BlendMode","BlurStyle","ColorChannel","processUniforms","TileMode","composeDeclarations","CommandType","MorphologyOperator","Black","Float32Array","of","MakeInnerShadow","Skia","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","Decal","f4","MakeCompose","SrcOver","declareBlurImageFilter","ctx","props","mode","blur","sigma","imgf","x","y","imageFilters","push","declareMorphologyImageFilter","operator","r","radius","Erode","MakeErode","MakeDilate","declareOffsetImageFilter","declareDropShadowImageFilter","cl","inner","Color","factory","bind","MakeDropShadowOnly","MakeDropShadow","declareBlendImageFilter","blend","splice","length","composer","declareDisplacementMapImageFilter","channelX","channelY","scale","shader","shaders","pop","Error","map","MakeShader","MakeDisplacementMap","declareRuntimeShaderImageFilter","source","uniforms","rtb","RuntimeShaderBuilder","MakeRuntimeShader","composeImageFilters","outer","setBlurMaskFilter","style","respectCTM","mf","MaskFilter","paint","setMaskFilter","isPushImageFilter","command","type","PushImageFilter","isImageFilter","imageFilterType","pushImageFilter","BlurImageFilter","MorphologyImageFilter","BlendImageFilter","DisplacementMapImageFilter","DropShadowImageFilter","OffsetImageFilter","RuntimeShaderImageFilter"],"sources":["ImageFilters.ts"],"sourcesContent":["import { enumKey, processRadius } from \"../../../dom/nodes\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n BlurMaskFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n MorphologyImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColor, SkImageFilter, Skia } from \"../../../skia/types\";\nimport {\n BlendMode,\n BlurStyle,\n ColorChannel,\n processUniforms,\n TileMode,\n} from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport enum MorphologyOperator {\n Erode,\n Dilate,\n}\n\nconst Black = Float32Array.of(0, 0, 0, 1);\n\nconst MakeInnerShadow = (\n Skia: Skia,\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n \"worklet\";\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n\nconst declareBlurImageFilter = (\n ctx: DrawingContext,\n props: BlurImageFilterProps\n) => {\n \"worklet\";\n const { mode, blur } = props;\n const sigma = processRadius(ctx.Skia, blur);\n const imgf = ctx.Skia.ImageFilter.MakeBlur(\n sigma.x,\n sigma.y,\n TileMode[enumKey(mode)],\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareMorphologyImageFilter = (\n ctx: DrawingContext,\n props: MorphologyImageFilterProps\n) => {\n \"worklet\";\n const { operator } = props;\n const r = processRadius(ctx.Skia, props.radius);\n let imgf;\n if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {\n imgf = ctx.Skia.ImageFilter.MakeErode(r.x, r.y, null);\n } else {\n imgf = ctx.Skia.ImageFilter.MakeDilate(r.x, r.y, null);\n }\n ctx.imageFilters.push(imgf);\n};\n\nconst declareOffsetImageFilter = (\n ctx: DrawingContext,\n props: OffsetImageFilterProps\n) => {\n \"worklet\";\n const { x, y } = props;\n const imgf = ctx.Skia.ImageFilter.MakeOffset(x, y, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareDropShadowImageFilter = (\n ctx: DrawingContext,\n props: DropShadowImageFilterProps\n) => {\n \"worklet\";\n const { dx, dy, blur, shadowOnly, color: cl, inner } = props;\n const color = ctx.Skia.Color(cl);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, ctx.Skia, shadowOnly);\n } else {\n factory = shadowOnly\n ? ctx.Skia.ImageFilter.MakeDropShadowOnly.bind(ctx.Skia.ImageFilter)\n : ctx.Skia.ImageFilter.MakeDropShadow.bind(ctx.Skia.ImageFilter);\n }\n const imgf = factory(dx, dy, blur, blur, color, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareBlendImageFilter = (\n ctx: DrawingContext,\n props: BlendImageFilterProps\n) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode)];\n // Blend ImageFilters\n const imageFilters = ctx.imageFilters.splice(0, ctx.imageFilters.length);\n const composer = ctx.Skia.ImageFilter.MakeBlend.bind(\n ctx.Skia.ImageFilter,\n blend\n );\n ctx.imageFilters.push(composeDeclarations(imageFilters, composer));\n};\n\nconst declareDisplacementMapImageFilter = (\n ctx: DrawingContext,\n props: DisplacementMapImageFilterProps\n) => {\n \"worklet\";\n const { channelX, channelY, scale } = props;\n const shader = ctx.shaders.pop();\n if (!shader) {\n throw new Error(\"DisplacementMap expects a shader as child\");\n }\n const map = ctx.Skia.ImageFilter.MakeShader(shader, null);\n const imgf = ctx.Skia.ImageFilter.MakeDisplacementMap(\n ColorChannel[enumKey(channelX)],\n ColorChannel[enumKey(channelY)],\n scale,\n map,\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareRuntimeShaderImageFilter = (\n ctx: DrawingContext,\n props: RuntimeShaderImageFilterProps\n) => {\n \"worklet\";\n const { source, uniforms } = props;\n const rtb = ctx.Skia.RuntimeShaderBuilder(source);\n if (uniforms) {\n processUniforms(source, uniforms, rtb);\n }\n const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);\n ctx.imageFilters.push(imgf);\n};\n\nexport const composeImageFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.imageFilters.length > 1) {\n const outer = ctx.imageFilters.pop()!;\n const inner = ctx.imageFilters.pop()!;\n ctx.imageFilters.push(ctx.Skia.ImageFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const setBlurMaskFilter = (\n ctx: DrawingContext,\n props: BlurMaskFilterProps\n) => {\n \"worklet\";\n const { blur, style, respectCTM } = props;\n const mf = ctx.Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n ctx.paint.setMaskFilter(mf);\n};\n\nexport const isPushImageFilter = (\n command: Command\n): command is Command<CommandType.PushImageFilter> => {\n \"worklet\";\n return command.type === CommandType.PushImageFilter;\n};\n\ntype Props = {\n [NodeType.OffsetImageFilter]: OffsetImageFilterProps;\n [NodeType.DisplacementMapImageFilter]: DisplacementMapImageFilterProps;\n [NodeType.BlurImageFilter]: BlurImageFilterProps;\n [NodeType.DropShadowImageFilter]: DropShadowImageFilterProps;\n [NodeType.MorphologyImageFilter]: MorphologyImageFilterProps;\n [NodeType.BlendImageFilter]: BlendImageFilterProps;\n [NodeType.RuntimeShaderImageFilter]: RuntimeShaderImageFilterProps;\n};\n\ninterface PushImageFilter<T extends keyof Props>\n extends Command<CommandType.PushImageFilter> {\n imageFilterType: T;\n props: Props[T];\n}\n\nconst isImageFilter = <T extends keyof Props>(\n command: Command<CommandType.PushImageFilter>,\n type: T\n): command is PushImageFilter<T> => {\n \"worklet\";\n return command.imageFilterType === type;\n};\n\nexport const pushImageFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushImageFilter>\n) => {\n \"worklet\";\n if (isImageFilter(command, NodeType.BlurImageFilter)) {\n declareBlurImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {\n declareMorphologyImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.BlendImageFilter)) {\n declareBlendImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DisplacementMapImageFilter)) {\n declareDisplacementMapImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DropShadowImageFilter)) {\n declareDropShadowImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.OffsetImageFilter)) {\n declareOffsetImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.RuntimeShaderImageFilter)) {\n declareRuntimeShaderImageFilter(ctx, command.props);\n } else {\n throw new Error(\"Invalid image filter type: \" + command.imageFilterType);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,aAAa,QAAQ,oBAAoB;AAW3D,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SACEC,SAAS,EACT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CAAiC,CAAC/B,GAAG,EAAE0D,OAAO,CAACzD,KAAK,CAAC;EACvD,CAAC,MAAM,IAAI4D,aAAa,CAACH,OAAO,EAAElG,QAAQ,CAAC4G,qBAAqB,CAAC,EAAE;IACjElD,4BAA4B,CAAClB,GAAG,EAAE0D,OAAO,CAACzD,KAAK,CAAC;EAClD,CAAC,MAAM,IAAI4D,aAAa,CAACH,OAAO,EAAElG,QAAQ,CAAC6G,iBAAiB,CAAC,EAAE;IAC7DpD,wBAAwB,CAACjB,GAAG,EAAE0D,OAAO,CAACzD,KAAK,CAAC;EAC9C,CAAC,MAAM,IAAI4D,aAAa,CAACH,OAAO,EAAElG,QAAQ,CAAC8G,wBAAwB,CAAC,EAAE;IACpE5B,+BAA+B,CAAC1C,GAAG,EAAE0D,OAAO,CAACzD,KAAK,CAAC;EACrD,CAAC,MAAM;IACL,MAAM,IAAIqC,KAAK,CAAC,6BAA6B,GAAGoB,OAAO,CAACI,eAAe,CAAC;EAC1E;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { PaintProps } from "../../../dom/types";
2
+ import type { SkPaint, Skia } from "../../../skia/types";
3
+ export declare const processColor: (Skia: Skia, color: number | string | Float32Array | number[]) => Float32Array;
4
+ export declare const setPaintProperties: (Skia: Skia, paint: SkPaint, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
@@ -0,0 +1,62 @@
1
+ import { enumKey } from "../../../dom/nodes";
2
+ import { BlendMode, PaintStyle, StrokeCap, StrokeJoin } from "../../../skia/types";
3
+ export const processColor = (Skia, color) => {
4
+ "worklet";
5
+
6
+ if (typeof color === "string" || typeof color === "number") {
7
+ return Skia.Color(color);
8
+ } else if (Array.isArray(color) || color instanceof Float32Array) {
9
+ return color instanceof Float32Array ? color : new Float32Array(color);
10
+ } else {
11
+ throw new Error(`Invalid color type: ${typeof color}. Expected number, string, or array.`);
12
+ }
13
+ };
14
+ export const setPaintProperties = (Skia, paint, {
15
+ opacity,
16
+ color,
17
+ blendMode,
18
+ strokeWidth,
19
+ style,
20
+ strokeJoin,
21
+ strokeCap,
22
+ strokeMiter,
23
+ antiAlias,
24
+ dither
25
+ }) => {
26
+ "worklet";
27
+
28
+ if (opacity !== undefined) {
29
+ paint.setAlphaf(paint.getAlphaf() * opacity);
30
+ }
31
+ if (color !== undefined) {
32
+ const currentOpacity = paint.getAlphaf();
33
+ paint.setShader(null);
34
+ paint.setColor(processColor(Skia, color));
35
+ paint.setAlphaf(currentOpacity * paint.getAlphaf());
36
+ }
37
+ if (blendMode !== undefined) {
38
+ paint.setBlendMode(BlendMode[enumKey(blendMode)]);
39
+ }
40
+ if (strokeWidth !== undefined) {
41
+ paint.setStrokeWidth(strokeWidth);
42
+ }
43
+ if (style !== undefined) {
44
+ paint.setStyle(PaintStyle[enumKey(style)]);
45
+ }
46
+ if (strokeJoin !== undefined) {
47
+ paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);
48
+ }
49
+ if (strokeCap !== undefined) {
50
+ paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);
51
+ }
52
+ if (strokeMiter !== undefined) {
53
+ paint.setStrokeMiter(strokeMiter);
54
+ }
55
+ if (antiAlias !== undefined) {
56
+ paint.setAntiAlias(antiAlias);
57
+ }
58
+ if (dither !== undefined) {
59
+ paint.setDither(dither);
60
+ }
61
+ };
62
+ //# sourceMappingURL=Paint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["enumKey","BlendMode","PaintStyle","StrokeCap","StrokeJoin","processColor","Skia","color","Color","Array","isArray","Float32Array","Error","setPaintProperties","paint","opacity","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","undefined","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","setBlendMode","setStrokeWidth","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { SkPaint, Skia } from \"../../../skia/types\";\n\nexport const processColor = (\n Skia: Skia,\n color: number | string | Float32Array | number[]\n) => {\n \"worklet\";\n if (typeof color === \"string\" || typeof color === \"number\") {\n return Skia.Color(color);\n } else if (Array.isArray(color) || color instanceof Float32Array) {\n return color instanceof Float32Array ? color : new Float32Array(color);\n } else {\n throw new Error(\n `Invalid color type: ${typeof color}. Expected number, string, or array.`\n );\n }\n};\n\nexport const setPaintProperties = (\n Skia: Skia,\n paint: SkPaint,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps\n) => {\n \"worklet\";\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 paint.setColor(processColor(Skia, color));\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\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};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,oBAAoB;AAE5C,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AA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AC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKO,SAAS,EAAE;IAC7BV,KAAK,CAACiB,cAAc,CAACd,WAAW,CAAC;EACnC;EACA,IAAIC,KAAK,KAAKM,SAAS,EAAE;IACvBV,KAAK,CAACkB,QAAQ,CAAC9B,UAAU,CAACF,OAAO,CAACkB,KAAK,CAAC,CAAC,CAAC;EAC5C;EACA,IAAIC,UAAU,KAAKK,SAAS,EAAE;IAC5BV,KAAK,CAACmB,aAAa,CAAC7B,UAAU,CAACJ,OAAO,CAACmB,UAAU,CAAC,CAAC,CAAC;EACtD;EACA,IAAIC,SAAS,KAAKI,SAAS,EAAE;IAC3BV,KAAK,CAACoB,YAAY,CAAC/B,SAAS,CAACH,OAAO,CAACoB,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKG,SAAS,EAAE;IAC7BV,KAAK,CAACqB,cAAc,CAACd,WAAW,CAAC;EACnC;EACA,IAAIC,SAAS,KAAKE,SAAS,EAAE;IAC3BV,KAAK,CAACsB,YAAY,CAACd,SAAS,CAAC;EAC/B;EACA,IAAIC,MAAM,KAAKC,SAAS,EAAE;IACxBV,KAAK,CAACuB,SAAS,CAACd,MAAM,CAAC;EACzB;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { Command } from "../Core";
2
+ import { CommandType } from "../Core";
3
+ import type { DrawingContext } from "../DrawingContext";
4
+ export declare const isPushPathEffect: (command: Command) => command is Command<CommandType.PushPathEffect>;
5
+ export declare const composePathEffects: (ctx: DrawingContext) => void;
6
+ export declare const pushPathEffect: (ctx: DrawingContext, command: Command<CommandType.PushPathEffect>) => void;
@@ -0,0 +1,128 @@
1
+ import { enumKey, processPath } from "../../../dom/nodes";
2
+ import { NodeType } from "../../../dom/types";
3
+ import { Path1DEffectStyle } from "../../../skia/types";
4
+ import { composeDeclarations } from "../../utils";
5
+ import { CommandType } from "../Core";
6
+ const declareDiscretePathEffect = (ctx, props) => {
7
+ "worklet";
8
+
9
+ const {
10
+ length,
11
+ deviation,
12
+ seed
13
+ } = props;
14
+ const pe = ctx.Skia.PathEffect.MakeDiscrete(length, deviation, seed);
15
+ ctx.pathEffects.push(pe);
16
+ };
17
+ const declarePath2DPathEffect = (ctx, props) => {
18
+ "worklet";
19
+
20
+ const {
21
+ matrix
22
+ } = props;
23
+ const path = processPath(ctx.Skia, props.path);
24
+ const pe = ctx.Skia.PathEffect.MakePath2D(matrix, path);
25
+ if (pe === null) {
26
+ throw new Error("Path2DPathEffect: invalid path");
27
+ }
28
+ ctx.pathEffects.push(pe);
29
+ };
30
+ const declareDashPathEffect = (ctx, props) => {
31
+ "worklet";
32
+
33
+ const {
34
+ intervals,
35
+ phase
36
+ } = props;
37
+ const pe = ctx.Skia.PathEffect.MakeDash(intervals, phase);
38
+ ctx.pathEffects.push(pe);
39
+ };
40
+ const declareCornerPathEffect = (ctx, props) => {
41
+ "worklet";
42
+
43
+ const {
44
+ r
45
+ } = props;
46
+ const pe = ctx.Skia.PathEffect.MakeCorner(r);
47
+ if (pe === null) {
48
+ throw new Error("CornerPathEffect: couldn't create path effect");
49
+ }
50
+ ctx.pathEffects.push(pe);
51
+ };
52
+ const declareSumPathEffect = ctx => {
53
+ "worklet";
54
+
55
+ // Note: decorateChildren functionality needs to be handled differently
56
+ const pes = ctx.pathEffects.splice(0, ctx.pathEffects.length);
57
+ const pe = composeDeclarations(pes, ctx.Skia.PathEffect.MakeSum.bind(ctx.Skia.PathEffect));
58
+ ctx.pathEffects.push(pe);
59
+ };
60
+ const declareLine2DPathEffect = (ctx, props) => {
61
+ "worklet";
62
+
63
+ const {
64
+ width,
65
+ matrix
66
+ } = props;
67
+ const pe = ctx.Skia.PathEffect.MakeLine2D(width, matrix);
68
+ if (pe === null) {
69
+ throw new Error("Line2DPathEffect: could not create path effect");
70
+ }
71
+ ctx.pathEffects.push(pe);
72
+ };
73
+ const declarePath1DPathEffect = (ctx, props) => {
74
+ "worklet";
75
+
76
+ const {
77
+ advance,
78
+ phase,
79
+ style
80
+ } = props;
81
+ const path = processPath(ctx.Skia, props.path);
82
+ const pe = ctx.Skia.PathEffect.MakePath1D(path, advance, phase, Path1DEffectStyle[enumKey(style)]);
83
+ if (pe === null) {
84
+ throw new Error("Path1DPathEffect: could not create path effect");
85
+ }
86
+ ctx.pathEffects.push(pe);
87
+ };
88
+ export const isPushPathEffect = command => {
89
+ "worklet";
90
+
91
+ return command.type === CommandType.PushPathEffect;
92
+ };
93
+ const isPathEffect = (command, type) => {
94
+ "worklet";
95
+
96
+ return command.pathEffectType === type;
97
+ };
98
+ export const composePathEffects = ctx => {
99
+ "worklet";
100
+
101
+ if (ctx.pathEffects.length > 1) {
102
+ const outer = ctx.pathEffects.pop();
103
+ const inner = ctx.pathEffects.pop();
104
+ ctx.pathEffects.push(ctx.Skia.PathEffect.MakeCompose(outer, inner));
105
+ }
106
+ };
107
+ export const pushPathEffect = (ctx, command) => {
108
+ "worklet";
109
+
110
+ if (isPathEffect(command, NodeType.DiscretePathEffect)) {
111
+ declareDiscretePathEffect(ctx, command.props);
112
+ } else if (isPathEffect(command, NodeType.DashPathEffect)) {
113
+ declareDashPathEffect(ctx, command.props);
114
+ } else if (isPathEffect(command, NodeType.Path1DPathEffect)) {
115
+ declarePath1DPathEffect(ctx, command.props);
116
+ } else if (isPathEffect(command, NodeType.Path2DPathEffect)) {
117
+ declarePath2DPathEffect(ctx, command.props);
118
+ } else if (isPathEffect(command, NodeType.CornerPathEffect)) {
119
+ declareCornerPathEffect(ctx, command.props);
120
+ } else if (isPathEffect(command, NodeType.SumPathEffect)) {
121
+ declareSumPathEffect(ctx);
122
+ } else if (isPathEffect(command, NodeType.Line2DPathEffect)) {
123
+ declareLine2DPathEffect(ctx, command.props);
124
+ } else {
125
+ throw new Error("Invalid image filter type: " + command.imageFilterType);
126
+ }
127
+ };
128
+ //# sourceMappingURL=PathEffects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["enumKey","processPath","NodeType","Path1DEffectStyle","composeDeclarations","CommandType","declareDiscretePathEffect","ctx","props","length","deviation","seed","pe","Skia","PathEffect","MakeDiscrete","pathEffects","push","declarePath2DPathEffect","matrix","path","MakePath2D","Error","declareDashPathEffect","intervals","phase","MakeDash","declareCornerPathEffect","r","MakeCorner","declareSumPathEffect","pes","splice","MakeSum","bind","declareLine2DPathEffect","width","MakeLine2D","declarePath1DPathEffect","advance","style","MakePath1D","isPushPathEffect","command","type","PushPathEffect","isPathEffect","pathEffectType","composePathEffects","outer","pop","inner","MakeCompose","pushPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","CornerPathEffect","SumPathEffect","Line2DPathEffect","imageFilterType"],"sources":["PathEffects.ts"],"sourcesContent":["import { enumKey, processPath } from \"../../../dom/nodes\";\nimport { NodeType } from \"../../../dom/types\";\nimport type {\n CornerPathEffectProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n} from \"../../../dom/types\";\nimport { Path1DEffectStyle } from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nconst declareDiscretePathEffect = (\n ctx: DrawingContext,\n props: DiscretePathEffectProps\n) => {\n \"worklet\";\n const { length, deviation, seed } = props;\n const pe = ctx.Skia.PathEffect.MakeDiscrete(length, deviation, seed);\n ctx.pathEffects.push(pe);\n};\n\nconst declarePath2DPathEffect = (\n ctx: DrawingContext,\n props: Path2DPathEffectProps\n) => {\n \"worklet\";\n const { matrix } = props;\n const path = processPath(ctx.Skia, props.path);\n const pe = ctx.Skia.PathEffect.MakePath2D(matrix, path);\n if (pe === null) {\n throw new Error(\"Path2DPathEffect: invalid path\");\n }\n ctx.pathEffects.push(pe);\n};\n\nconst declareDashPathEffect = (\n ctx: DrawingContext,\n props: DashPathEffectProps\n) => {\n \"worklet\";\n const { intervals, phase } = props;\n const pe = ctx.Skia.PathEffect.MakeDash(intervals, phase);\n ctx.pathEffects.push(pe);\n};\n\nconst declareCornerPathEffect = (\n ctx: DrawingContext,\n props: CornerPathEffectProps\n) => {\n \"worklet\";\n const { r } = props;\n const pe = ctx.Skia.PathEffect.MakeCorner(r);\n if (pe === null) {\n throw new Error(\"CornerPathEffect: couldn't create path effect\");\n }\n ctx.pathEffects.push(pe);\n};\n\nconst declareSumPathEffect = (ctx: DrawingContext) => {\n \"worklet\";\n // Note: decorateChildren functionality needs to be handled differently\n const pes = ctx.pathEffects.splice(0, ctx.pathEffects.length);\n const pe = composeDeclarations(\n pes,\n ctx.Skia.PathEffect.MakeSum.bind(ctx.Skia.PathEffect)\n );\n ctx.pathEffects.push(pe);\n};\n\nconst declareLine2DPathEffect = (\n ctx: DrawingContext,\n props: Line2DPathEffectProps\n) => {\n \"worklet\";\n const { width, matrix } = props;\n const pe = ctx.Skia.PathEffect.MakeLine2D(width, matrix);\n if (pe === null) {\n throw new Error(\"Line2DPathEffect: could not create path effect\");\n }\n ctx.pathEffects.push(pe);\n};\n\nconst declarePath1DPathEffect = (\n ctx: DrawingContext,\n props: Path1DPathEffectProps\n) => {\n \"worklet\";\n const { advance, phase, style } = props;\n const path = processPath(ctx.Skia, props.path);\n const pe = ctx.Skia.PathEffect.MakePath1D(\n path,\n advance,\n phase,\n Path1DEffectStyle[enumKey(style)]\n );\n if (pe === null) {\n throw new Error(\"Path1DPathEffect: could not create path effect\");\n }\n ctx.pathEffects.push(pe);\n};\n\nexport const isPushPathEffect = (\n command: Command\n): command is Command<CommandType.PushPathEffect> => {\n \"worklet\";\n return command.type === CommandType.PushPathEffect;\n};\n\ntype Props = {\n [NodeType.DiscretePathEffect]: DiscretePathEffectProps;\n [NodeType.DashPathEffect]: DashPathEffectProps;\n [NodeType.Path1DPathEffect]: Path1DPathEffectProps;\n [NodeType.Path2DPathEffect]: Path2DPathEffectProps;\n [NodeType.CornerPathEffect]: CornerPathEffectProps;\n [NodeType.SumPathEffect]: Record<string, never>;\n [NodeType.Line2DPathEffect]: Line2DPathEffectProps;\n};\n\ninterface PushPathEffect<T extends keyof Props>\n extends Command<CommandType.PushPathEffect> {\n pathEffectType: T;\n props: Props[T];\n}\n\nconst isPathEffect = <T extends keyof Props>(\n command: Command<CommandType.PushPathEffect>,\n type: T\n): command is PushPathEffect<T> => {\n \"worklet\";\n return command.pathEffectType === type;\n};\n\nexport const composePathEffects = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.pathEffects.length > 1) {\n const outer = ctx.pathEffects.pop()!;\n const inner = ctx.pathEffects.pop()!;\n ctx.pathEffects.push(ctx.Skia.PathEffect.MakeCompose(outer, inner));\n }\n};\n\nexport const pushPathEffect = (\n ctx: DrawingContext,\n command: Command<CommandType.PushPathEffect>\n) => {\n \"worklet\";\n if (isPathEffect(command, NodeType.DiscretePathEffect)) {\n declareDiscretePathEffect(ctx, command.props);\n } else if (isPathEffect(command, NodeType.DashPathEffect)) {\n declareDashPathEffect(ctx, command.props);\n } else if (isPathEffect(command, NodeType.Path1DPathEffect)) {\n declarePath1DPathEffect(ctx, command.props);\n } else if (isPathEffect(command, NodeType.Path2DPathEffect)) {\n declarePath2DPathEffect(ctx, command.props);\n } else if (isPathEffect(command, NodeType.CornerPathEffect)) {\n declareCornerPathEffect(ctx, command.props);\n } else if (isPathEffect(command, NodeType.SumPathEffect)) {\n declareSumPathEffect(ctx);\n } else if (isPathEffect(command, NodeType.Line2DPathEffect)) {\n declareLine2DPathEffect(ctx, command.props);\n } else {\n throw new Error(\"Invalid image filter type: \" + command.imageFilterType);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;AAS7C,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,WAAW,QAAQ,SAAS;AAGrC,MAAMC,yBAAyB,GAAGA,CAChCC,G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,CAAC,MAAM,IAAIsC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAACqD,cAAc,CAAC,EAAE;IACzDhC,qBAAqB,CAAChB,GAAG,EAAEoC,OAAO,CAACnC,KAAK,CAAC;EAC3C,CAAC,MAAM,IAAIsC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAACsD,gBAAgB,CAAC,EAAE;IAC3DlB,uBAAuB,CAAC/B,GAAG,EAAEoC,OAAO,CAACnC,KAAK,CAAC;EAC7C,CAAC,MAAM,IAAIsC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAACuD,gBAAgB,CAAC,EAAE;IAC3DvC,uBAAuB,CAACX,GAAG,EAAEoC,OAAO,CAACnC,KAAK,CAAC;EAC7C,CAAC,MAAM,IAAIsC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAACwD,gBAAgB,CAAC,EAAE;IAC3D/B,uBAAuB,CAACpB,GAAG,EAAEoC,OAAO,CAACnC,KAAK,CAAC;EAC7C,CAAC,MAAM,IAAIsC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAACyD,aAAa,CAAC,EAAE;IACxD7B,oBAAoB,CAACvB,GAAG,CAAC;EAC3B,CAAC,MAAM,IAAIuC,YAAY,CAACH,OAAO,EAAEzC,QAAQ,CAAC0D,gBAAgB,CAAC,EAAE;IAC3DzB,uBAAuB,CAAC5B,GAAG,EAAEoC,OAAO,CAACnC,KAAK,CAAC;EAC7C,CAAC,MAAM;IACL,MAAM,IAAIc,KAAK,CAAC,6BAA6B,GAAGqB,OAAO,CAACkB,eAAe,CAAC;EAC1E;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import type { Command } from "../Core";
2
+ import { CommandType } from "../Core";
3
+ import type { DrawingContext } from "../DrawingContext";
4
+ export declare const isPushShader: (command: Command) => command is Command<CommandType.PushShader>;
5
+ export declare const pushShader: (ctx: DrawingContext, command: Command<CommandType.PushShader>) => void;
@@ -1,6 +1,9 @@
1
- import { enumKey, fitRects, getRect, processGradientProps, processTransformProps, rect2rect } from "../../dom/nodes";
2
- import { FilterMode, MipmapMode, processUniforms, TileMode } from "../../skia/types";
3
- export const declareShader = (ctx, props) => {
1
+ import { enumKey, fitRects, getRect, processGradientProps, processTransformProps, rect2rect } from "../../../dom/nodes";
2
+ import { NodeType } from "../../../dom/types";
3
+ import { BlendMode, FilterMode, MipmapMode, processUniforms, TileMode } from "../../../skia/types";
4
+ import { composeDeclarations } from "../../utils";
5
+ import { CommandType } from "../Core";
6
+ const declareShader = (ctx, props) => {
4
7
  "worklet";
5
8
 
6
9
  const {
@@ -10,10 +13,10 @@ export const declareShader = (ctx, props) => {
10
13
  } = props;
11
14
  const m3 = ctx.Skia.Matrix();
12
15
  processTransformProps(m3, transform);
13
- const shader = source.makeShaderWithChildren(processUniforms(source, uniforms), ctx.shaders.popAll(), m3);
16
+ const shader = source.makeShaderWithChildren(processUniforms(source, uniforms), ctx.shaders.splice(0, ctx.shaders.length), m3);
14
17
  ctx.shaders.push(shader);
15
18
  };
16
- export const declareColorShader = (ctx, props) => {
19
+ const declareColorShader = (ctx, props) => {
17
20
  "worklet";
18
21
 
19
22
  const {
@@ -22,7 +25,7 @@ export const declareColorShader = (ctx, props) => {
22
25
  const shader = ctx.Skia.Shader.MakeColor(ctx.Skia.Color(color));
23
26
  ctx.shaders.push(shader);
24
27
  };
25
- export const declareFractalNoiseShader = (ctx, props) => {
28
+ const declareFractalNoiseShader = (ctx, props) => {
26
29
  "worklet";
27
30
 
28
31
  const {
@@ -36,7 +39,7 @@ export const declareFractalNoiseShader = (ctx, props) => {
36
39
  const shader = ctx.Skia.Shader.MakeFractalNoise(freqX, freqY, octaves, seed, tileWidth, tileHeight);
37
40
  ctx.shaders.push(shader);
38
41
  };
39
- export const declareTwoPointConicalGradientShader = (ctx, props) => {
42
+ const declareTwoPointConicalGradientShader = (ctx, props) => {
40
43
  "worklet";
41
44
 
42
45
  const {
@@ -55,7 +58,7 @@ export const declareTwoPointConicalGradientShader = (ctx, props) => {
55
58
  const shader = ctx.Skia.Shader.MakeTwoPointConicalGradient(start, startR, end, endR, colors, positions, mode, localMatrix, flags);
56
59
  ctx.shaders.push(shader);
57
60
  };
58
- export const declareRadialGradientShader = (ctx, props) => {
61
+ const declareRadialGradientShader = (ctx, props) => {
59
62
  "worklet";
60
63
 
61
64
  const {
@@ -72,7 +75,7 @@ export const declareRadialGradientShader = (ctx, props) => {
72
75
  const shader = ctx.Skia.Shader.MakeRadialGradient(c, r, colors, positions, mode, localMatrix, flags);
73
76
  ctx.shaders.push(shader);
74
77
  };
75
- export const declareSweepGradientShader = (ctx, props) => {
78
+ const declareSweepGradientShader = (ctx, props) => {
76
79
  "worklet";
77
80
 
78
81
  const {
@@ -90,7 +93,7 @@ export const declareSweepGradientShader = (ctx, props) => {
90
93
  const shader = ctx.Skia.Shader.MakeSweepGradient(c.x, c.y, colors, positions, mode, localMatrix, flags, start, end);
91
94
  ctx.shaders.push(shader);
92
95
  };
93
- export const declareLinearGradientShader = (ctx, props) => {
96
+ const declareLinearGradientShader = (ctx, props) => {
94
97
  "worklet";
95
98
 
96
99
  const {
@@ -107,7 +110,7 @@ export const declareLinearGradientShader = (ctx, props) => {
107
110
  const shader = ctx.Skia.Shader.MakeLinearGradient(start, end, colors, positions !== null && positions !== void 0 ? positions : null, mode, localMatrix, flags);
108
111
  ctx.shaders.push(shader);
109
112
  };
110
- export const declareTurbulenceShader = (ctx, props) => {
113
+ const declareTurbulenceShader = (ctx, props) => {
111
114
  "worklet";
112
115
 
113
116
  const {
@@ -121,7 +124,7 @@ export const declareTurbulenceShader = (ctx, props) => {
121
124
  const shader = ctx.Skia.Shader.MakeTurbulence(freqX, freqY, octaves, seed, tileWidth, tileHeight);
122
125
  ctx.shaders.push(shader);
123
126
  };
124
- export const declareImageShader = (ctx, props) => {
127
+ const declareImageShader = (ctx, props) => {
125
128
  "worklet";
126
129
 
127
130
  const {
@@ -155,4 +158,51 @@ export const declareImageShader = (ctx, props) => {
155
158
  const shader = image.makeShaderOptions(TileMode[enumKey(tx)], TileMode[enumKey(ty)], FilterMode[enumKey(fm)], MipmapMode[enumKey(mm)], lm);
156
159
  ctx.shaders.push(shader);
157
160
  };
158
- //# sourceMappingURL=shaders.js.map
161
+ const declareBlend = (ctx, props) => {
162
+ "worklet";
163
+
164
+ const blend = BlendMode[enumKey(props.mode)];
165
+ const shaders = ctx.shaders.splice(0, ctx.shaders.length);
166
+ if (shaders.length > 0) {
167
+ const composer = ctx.Skia.Shader.MakeBlend.bind(ctx.Skia.Shader, blend);
168
+ ctx.shaders.push(composeDeclarations(shaders, composer));
169
+ }
170
+ };
171
+ export const isPushShader = command => {
172
+ "worklet";
173
+
174
+ return command.type === CommandType.PushShader;
175
+ };
176
+ const isShader = (command, type) => {
177
+ "worklet";
178
+
179
+ return command.shaderType === type;
180
+ };
181
+ export const pushShader = (ctx, command) => {
182
+ "worklet";
183
+
184
+ if (isShader(command, NodeType.Shader)) {
185
+ declareShader(ctx, command.props);
186
+ } else if (isShader(command, NodeType.ImageShader)) {
187
+ declareImageShader(ctx, command.props);
188
+ } else if (isShader(command, NodeType.ColorShader)) {
189
+ declareColorShader(ctx, command.props);
190
+ } else if (isShader(command, NodeType.Turbulence)) {
191
+ declareTurbulenceShader(ctx, command.props);
192
+ } else if (isShader(command, NodeType.FractalNoise)) {
193
+ declareFractalNoiseShader(ctx, command.props);
194
+ } else if (isShader(command, NodeType.LinearGradient)) {
195
+ declareLinearGradientShader(ctx, command.props);
196
+ } else if (isShader(command, NodeType.RadialGradient)) {
197
+ declareRadialGradientShader(ctx, command.props);
198
+ } else if (isShader(command, NodeType.SweepGradient)) {
199
+ declareSweepGradientShader(ctx, command.props);
200
+ } else if (isShader(command, NodeType.TwoPointConicalGradient)) {
201
+ declareTwoPointConicalGradientShader(ctx, command.props);
202
+ } else if (isShader(command, NodeType.Blend)) {
203
+ declareBlend(ctx, command.props);
204
+ } else {
205
+ throw new Error(`Unknown shader type: ${command.shaderType}`);
206
+ }
207
+ };
208
+ //# sourceMappingURL=Shaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["enumKey","fitRects","getRect","processGradientProps","processTransformProps","rect2rect","NodeType","BlendMode","FilterMode","MipmapMode","processUniforms","TileMode","composeDeclarations","CommandType","declareShader","ctx","props","source","uniforms","transform","m3","Skia","Matrix","shader","makeShaderWithChildren","shaders","splice","length","push","declareColorShader","color","Shader","MakeColor","Color","declareFractalNoiseShader","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeFractalNoise","declareTwoPointConicalGradientShader","startR","endR","start","end","colors","positions","mode","localMatrix","flags","MakeTwoPointConicalGradient","declareRadialGradientShader","c","r","MakeRadialGradient","declareSweepGradientShader","MakeSweepGradient","x","y","declareLinearGradientShader","MakeLinearGradient","declareTurbulenceShader","MakeTurbulence","declareImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","rects","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","declareBlend","blend","composer","MakeBlend","bind","isPushShader","command","type","PushShader","isShader","shaderType","pushShader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","Blend","Error"],"sources":["Shaders.ts"],"sourcesContent":["import {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../../../dom/nodes\";\nimport { NodeType } from \"../../../dom/types\";\nimport type {\n BlendProps,\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../../dom/types\";\nimport {\n BlendMode,\n FilterMode,\n MipmapMode,\n processUniforms,\n TileMode,\n} from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nconst declareShader = (ctx: DrawingContext, props: ShaderProps) => {\n \"worklet\";\n const { source, uniforms, ...transform } = props;\n const m3 = ctx.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.splice(0, ctx.shaders.length),\n m3\n );\n ctx.shaders.push(shader);\n};\n\nconst declareColorShader = (ctx: DrawingContext, props: ColorProps) => {\n \"worklet\";\n const { color } = props;\n const shader = ctx.Skia.Shader.MakeColor(ctx.Skia.Color(color));\n ctx.shaders.push(shader);\n};\n\nconst declareFractalNoiseShader = (\n ctx: DrawingContext,\n props: FractalNoiseProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTwoPointConicalGradientShader = (\n ctx: DrawingContext,\n props: TwoPointConicalGradientProps\n) => {\n \"worklet\";\n const { startR, endR, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareRadialGradientShader = (\n ctx: DrawingContext,\n props: RadialGradientProps\n) => {\n \"worklet\";\n const { c, r } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareSweepGradientShader = (\n ctx: DrawingContext,\n props: SweepGradientProps\n) => {\n \"worklet\";\n const { c, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n};\n\nconst declareLinearGradientShader = (\n ctx: DrawingContext,\n props: LinearGradientProps\n) => {\n \"worklet\";\n const { start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTurbulenceShader = (\n ctx: DrawingContext,\n props: TurbulenceProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareImageShader = (ctx: DrawingContext, props: ImageShaderProps) => {\n \"worklet\";\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = props;\n if (!image) {\n return;\n }\n\n const rct = getRect(ctx.Skia, imageShaderProps);\n const m3 = ctx.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = ctx.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n};\n\nconst declareBlend = (ctx: DrawingContext, props: BlendProps) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode as BlendProps[\"mode\"])];\n const shaders = ctx.shaders.splice(0, ctx.shaders.length);\n if (shaders.length > 0) {\n const composer = ctx.Skia.Shader.MakeBlend.bind(ctx.Skia.Shader, blend);\n ctx.shaders.push(composeDeclarations(shaders, composer));\n }\n};\n\nexport const isPushShader = (\n command: Command\n): command is Command<CommandType.PushShader> => {\n \"worklet\";\n return command.type === CommandType.PushShader;\n};\n\ntype Props = {\n [NodeType.Shader]: ShaderProps;\n [NodeType.ImageShader]: ImageShaderProps;\n [NodeType.ColorShader]: ColorProps;\n [NodeType.Turbulence]: TurbulenceProps;\n [NodeType.FractalNoise]: FractalNoiseProps;\n [NodeType.LinearGradient]: LinearGradientProps;\n [NodeType.RadialGradient]: RadialGradientProps;\n [NodeType.SweepGradient]: SweepGradientProps;\n [NodeType.TwoPointConicalGradient]: TwoPointConicalGradientProps;\n [NodeType.Blend]: BlendProps;\n};\n\ninterface PushShader<T extends keyof Props>\n extends Command<CommandType.PushShader> {\n shaderType: T;\n props: Props[T];\n}\n\nconst isShader = <T extends keyof Props>(\n command: Command<CommandType.PushShader>,\n type: T\n): command is PushShader<T> => {\n \"worklet\";\n return command.shaderType === type;\n};\n\nexport const pushShader = (\n ctx: DrawingContext,\n command: Command<CommandType.PushShader>\n) => {\n \"worklet\";\n if (isShader(command, NodeType.Shader)) {\n declareShader(ctx, command.props);\n } else if (isShader(command, NodeType.ImageShader)) {\n declareImageShader(ctx, command.props);\n } else if (isShader(command, NodeType.ColorShader)) {\n declareColorShader(ctx, command.props);\n } else if (isShader(command, NodeType.Turbulence)) {\n declareTurbulenceShader(ctx, command.props);\n } else if (isShader(command, NodeType.FractalNoise)) {\n declareFractalNoiseShader(ctx, command.props);\n } else if (isShader(command, NodeType.LinearGradient)) {\n declareLinearGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.RadialGradient)) {\n declareRadialGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.SweepGradient)) {\n declareSweepGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.TwoPointConicalGradient)) {\n declareTwoPointConicalGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.Blend)) {\n declareBlend(ctx, command.props);\n } else {\n throw new Error(`Unknown shader type: ${command.shaderType}`);\n }\n};\n"],"mappings":"AAAA,SACEA,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,oBAAoB,EACpBC,qBAAqB,EACrBC,SAAS,QACJ,oBAAoB;AAC3B,SAASC,QAAQ,QAAQ,oBAAoB;AAa7C,SACEC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,QAAQ,QACH,qBAAqB;AAC5B,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,WAAW,QAAQ,SAAS;AAGrC,MAAMC,aAAa,GAAGA,CAACC,GAAmB,EAAEC,KAAkB,KAAK;EACjE,SAAS;;EACT,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAE,GAAGC;EAAU,CAAC,GAAGH,KAAK;EAChD,MAAMI,EAAE,GAAGL,GAAG,CAACM,IAAI,CAACC,MAAM,CAAC,CAAC;EAC5BlB,qBAAqB,CAACgB,EAAE,EAAED,SAAS,CAAC;EACpC,MAAMI,MAAM,GAAGN,MAAM,CAACO,sBAAsB,CAC1Cd,eAAe,CAACO,MAAM,EAAEC,QAAQ,CAAC,EACjCH,GAAG,CAACU,OAAO,CAACC,MAAM,CAAC,CAAC,EAAEX,GAAG,CAACU,OAAO,CAACE,MAAM,CAAC,EACzCP,EACF,CAAC;EACDL,GAAG,CAACU,OAAO,CAACG,IAAI,CAACL,MAAM,CAAC;AAC1B,CAAC;AAED,MAAMM,kBAAkB,GAAGA,CAACd,GAAmB,EAAEC,KAAiB,KAAK;EACrE,SAAS;;EACT,MAAM;IAAEc;EAAM,CAAC,GAAGd,KAAK;EACvB,MAAMO,MAAM,GAAGR,GAAG,CAACM,IAAI,CAACU,MAAM,CAACC,SAAS,CAACjB,GAAG,CAACM,IAAI,CAACY,KAAK,CAACH,KAAK,CAAC,CAAC;EAC/Df,GAAG,CAACU,OAAO,CAACG,IAAI,CAACL,MAAM,CAAC;AAC1B,CAAC;AAED,MAA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;EAC/C,CAAC,MAAM,IAAImF,QAAQ,CAACH,OAAO,EAAE1F,QAAQ,CAACoG,cAAc,CAAC,EAAE;IACrD7C,2BAA2B,CAAC9C,GAAG,EAAEiF,OAAO,CAAChF,KAAK,CAAC;EACjD,CAAC,MAAM,IAAImF,QAAQ,CAACH,OAAO,EAAE1F,QAAQ,CAACqG,cAAc,CAAC,EAAE;IACrDtD,2BAA2B,CAACtC,GAAG,EAAEiF,OAAO,CAAChF,KAAK,CAAC;EACjD,CAAC,MAAM,IAAImF,QAAQ,CAACH,OAAO,EAAE1F,QAAQ,CAACsG,aAAa,CAAC,EAAE;IACpDnD,0BAA0B,CAAC1C,GAAG,EAAEiF,OAAO,CAAChF,KAAK,CAAC;EAChD,CAAC,MAAM,IAAImF,QAAQ,CAACH,OAAO,EAAE1F,QAAQ,CAACuG,uBAAuB,CAAC,EAAE;IAC9DnE,oCAAoC,CAAC3B,GAAG,EAAEiF,OAAO,CAAChF,KAAK,CAAC;EAC1D,CAAC,MAAM,IAAImF,QAAQ,CAACH,OAAO,EAAE1F,QAAQ,CAACwG,KAAK,CAAC,EAAE;IAC5CpB,YAAY,CAAC3E,GAAG,EAAEiF,OAAO,CAAChF,KAAK,CAAC;EAClC,CAAC,MAAM;IACL,MAAM,IAAI+F,KAAK,CAAC,wBAAwBf,OAAO,CAACI,UAAU,EAAE,CAAC;EAC/D;AACF,CAAC","ignoreList":[]}
@@ -1,3 +1,6 @@
1
1
  import type { SharedValue } from "react-native-reanimated";
2
2
  export declare const isSharedValue: <T = unknown>(value: unknown) => value is SharedValue<T>;
3
3
  export declare const materialize: <T extends object>(props: T) => T;
4
+ type Composer<T> = (outer: T, inner: T) => T;
5
+ export declare const composeDeclarations: <T>(filters: T[], composer: Composer<T>) => T;
6
+ export {};
@@ -1,4 +1,4 @@
1
- import { mapKeys } from "../../renderer/typeddash";
1
+ import { mapKeys } from "../renderer/typeddash";
2
2
  export const isSharedValue = value => {
3
3
  "worklet";
4
4
 
@@ -17,4 +17,13 @@ export const materialize = props => {
17
17
  });
18
18
  return result;
19
19
  };
20
+ export const composeDeclarations = (filters, composer) => {
21
+ "worklet";
22
+
23
+ const len = filters.length;
24
+ if (len <= 1) {
25
+ return filters[0];
26
+ }
27
+ return filters.reduceRight((inner, outer) => inner ? composer(outer, inner) : outer);
28
+ };
20
29
  //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mapKeys","isSharedValue","value","_isReanimatedSharedValue","materialize","props","result","Object","assign","forEach","key","composeDeclarations","filters","composer","len","length","reduceRight","inner","outer"],"sources":["utils.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport { mapKeys } from \"../renderer/typeddash\";\n\nexport const isSharedValue = <T = unknown>(\n value: unknown\n): value is SharedValue<T> => {\n \"worklet\";\n // We cannot use `in` operator here because `value` could be a HostObject and therefore we cast.\n return (value as Record<string, unknown>)?._isReanimatedSharedValue === true;\n};\n\nexport const materialize = <T extends object>(props: T) => {\n \"worklet\";\n const result: T = Object.assign({}, props);\n mapKeys(result).forEach((key) => {\n const value = result[key];\n if (isSharedValue(value)) {\n result[key] = value.value as never;\n }\n });\n return result;\n};\n\ntype Composer<T> = (outer: T, inner: T) => T;\n\nexport const composeDeclarations = <T>(filters: T[], composer: Composer<T>) => {\n \"worklet\";\n const len = filters.length;\n if (len <= 1) {\n return filters[0];\n }\n return filters.reduceRight((inner, outer) =>\n inner ? composer(outer, inner) : outer\n );\n};\n"],"mappings":"AAEA,SAASA,OAAO,QAAQ,uBAAuB;AAE/C,OAAO,MAAMC,aAAa,GACxBC,KAAc,IACc;EAC5B,SAAS;;EACT;EACA,OAAO,CAACA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAA8BC,wBAAwB,MAAK,IAAI;AAC9E,CAAC;AAED,OAAO,MAAMC,WAAW,GAAsBC,KAAQ,IAAK;EACzD,SAAS;;EACT,MAAMC,MAAS,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEH,KAAK,CAAC;EAC1CL,OAAO,CAACM,MAAM,CAAC,CAACG,OAAO,CAAEC,GAAG,IAAK;IAC/B,MAAMR,KAAK,GAAGI,MAAM,CAACI,GAAG,CAAC;IACzB,IAAIT,aAAa,CAACC,KAAK,CAAC,EAAE;MACxBI,MAAM,CAACI,GAAG,CAAC,GAAGR,KAAK,CAACA,KAAc;IACpC;EACF,CAAC,CAAC;EACF,OAAOI,MAAM;AACf,CAAC;AAID,OAAO,MAAMK,mBAAmB,GAAGA,CAAIC,OAAY,EAAEC,QAAqB,KAAK;EAC7E,SAAS;;EACT,MAAMC,GAAG,GAAGF,OAAO,CAACG,MAAM;EAC1B,IAAID,GAAG,IAAI,CAAC,EAAE;IACZ,OAAOF,OAAO,CAAC,CAAC,CAAC;EACnB;EACA,OAAOA,OAAO,CAACI,WAAW,CAAC,CAACC,KAAK,EAAEC,KAAK,KACtCD,KAAK,GAAGJ,QAAQ,CAACK,KAAK,EAAED,KAAK,CAAC,GAAGC,KACnC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  export const __esModule: boolean;
2
- export const HAS_REANIMATED: any;
3
2
  export const HAS_REANIMATED_3: any;
4
3
  export function bindReanimatedProps(container: any, node: any, reanimatedProps: any): void;
5
4
  export function extractReanimatedProps(props: any): any[];
@@ -2,4 +2,4 @@ export const __esModule: boolean;
2
2
  /**
3
3
  * Returns a Skia Animated Image object
4
4
  * */
5
- export function useAnimatedImage(source: any, onError: any, managed?: boolean): null;
5
+ export function useAnimatedImage(source: any, onError: any): null;
@@ -1,5 +1,5 @@
1
1
  export const __esModule: boolean;
2
2
  export function loadData(source: any, factory: any, onError: any): Promise<any>;
3
3
  export function useCollectionLoading(source: any, loader: any): null;
4
- export function useRawData(source: any, factory: any, onError: any, manage?: boolean): null;
4
+ export function useRawData(source: any, factory: any, onError: any): null;
5
5
  export function useData(source: any, onError: any): null;
@@ -2,6 +2,7 @@ export const __esModule: boolean;
2
2
  export class JsiSkPaint extends _Host.HostObject {
3
3
  constructor(CanvasKit: any, ref: any);
4
4
  copy(): JsiSkPaint;
5
+ assign(paint: any): void;
5
6
  reset(): void;
6
7
  getAlphaf(): any;
7
8
  getColor(): any;
@@ -7,6 +7,10 @@ export class Container {
7
7
  get root(): any;
8
8
  mapperId: any;
9
9
  _root: any;
10
+ _recording: {
11
+ commands: any;
12
+ paintPool: never[];
13
+ } | undefined;
10
14
  clear(): void;
11
15
  redraw(): void;
12
16
  getNativeId(): any;
@@ -11,9 +11,8 @@ export namespace sksgHostConfig {
11
11
  function getChildHostContext(_parentHostContext: any, _type: any, _rootContainerInstance: any): null;
12
12
  function shouldSetTextContent(_type: any, _props: any): boolean;
13
13
  function createTextInstance(_text: any, _rootContainerInstance: any, _hostContext: any, _internalInstanceHandle: any): never;
14
- function createInstance(type: any, props: any, container: any, _hostContext: any, _internalInstanceHandle: any): {
14
+ function createInstance(type: any, propsWithChildren: any, container: any, _hostContext: any, _internalInstanceHandle: any): {
15
15
  type: any;
16
- isDeclaration: boolean;
17
16
  props: any;
18
17
  children: never[];
19
18
  };
@@ -31,7 +30,6 @@ export namespace sksgHostConfig {
31
30
  type: any;
32
31
  props: any;
33
32
  children: any[];
34
- isDeclaration: any;
35
33
  };
36
34
  function createContainerChildSet(): never[];
37
35
  function appendChildToContainerChildSet(childSet: any, child: any): void;
@@ -0,0 +1,14 @@
1
+ export const __esModule: boolean;
2
+ export function isColorFilter(type: any): boolean;
3
+ export function isPathEffect(type: any): boolean;
4
+ export function isImageFilter(type: any): boolean;
5
+ export function isShader(type: any): boolean;
6
+ export function sortNodeChildren(parent: any): {
7
+ colorFilters: any[];
8
+ drawings: any[];
9
+ maskFilters: any[];
10
+ shaders: any[];
11
+ pathEffects: any[];
12
+ imageFilters: any[];
13
+ paints: any[];
14
+ };
@@ -0,0 +1,5 @@
1
+ export const __esModule: boolean;
2
+ export const CommandType: {};
3
+ export function materializeProps(command: any): void;
4
+ export function isCommand(command: any, type: any): boolean;
5
+ export function isDrawCommand(command: any, type: any): boolean;
@@ -0,0 +1,17 @@
1
+ export const __esModule: boolean;
2
+ export function createDrawingContext(Skia: any, paintPool: any, canvas: any): {
3
+ Skia: any;
4
+ canvas: any;
5
+ paints: any[];
6
+ colorFilters: any[];
7
+ shaders: any[];
8
+ imageFilters: any[];
9
+ pathEffects: any[];
10
+ paintDeclarations: any[];
11
+ paintPool: any;
12
+ savePaint: () => void;
13
+ saveBackdropFilter: () => void;
14
+ readonly paint: any;
15
+ restorePaint: () => any;
16
+ materializePaint: () => void;
17
+ };
@@ -0,0 +1,2 @@
1
+ export const __esModule: boolean;
2
+ export function replay(ctx: any, commands: any): void;