@shopify/react-native-skia 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) 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/skia/types/Paint/Paint.d.ts +1 -0
  15. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  16. package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
  17. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -0
  18. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  19. package/lib/commonjs/sksg/Container.d.ts +3 -2
  20. package/lib/commonjs/sksg/Container.js +32 -26
  21. package/lib/commonjs/sksg/Container.js.map +1 -1
  22. package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
  23. package/lib/commonjs/sksg/HostConfig.js +7 -25
  24. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  25. package/lib/commonjs/sksg/Node.d.ts +19 -0
  26. package/lib/commonjs/sksg/Node.js +78 -0
  27. package/lib/commonjs/sksg/Node.js.map +1 -0
  28. package/lib/commonjs/sksg/Reconciler.d.ts +1 -1
  29. package/lib/commonjs/sksg/Recorder/Core.d.ts +79 -0
  30. package/lib/commonjs/sksg/Recorder/Core.js +110 -0
  31. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -0
  32. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +18 -0
  33. package/lib/commonjs/sksg/Recorder/DrawingContext.js +105 -0
  34. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -0
  35. package/lib/commonjs/sksg/Recorder/Player.d.ts +3 -0
  36. package/lib/commonjs/sksg/Recorder/Player.js +127 -0
  37. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -0
  38. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +50 -0
  39. package/lib/commonjs/sksg/Recorder/Recorder.js +288 -0
  40. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -0
  41. package/lib/commonjs/sksg/Recorder/Recording.d.ts +7 -0
  42. package/lib/commonjs/sksg/Recorder/Recording.js +12 -0
  43. package/lib/commonjs/sksg/Recorder/Recording.js.map +1 -0
  44. package/lib/commonjs/sksg/Recorder/Visitor.d.ts +5 -0
  45. package/lib/commonjs/sksg/Recorder/Visitor.js +293 -0
  46. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -0
  47. package/lib/commonjs/sksg/Recorder/commands/Box.d.ts +13 -0
  48. package/lib/commonjs/sksg/Recorder/commands/Box.js +71 -0
  49. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -0
  50. package/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +3 -0
  51. package/lib/commonjs/sksg/Recorder/commands/CTM.js +79 -0
  52. package/lib/commonjs/sksg/Recorder/commands/CTM.js.map +1 -0
  53. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  54. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js +76 -0
  55. package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -0
  56. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +24 -0
  57. package/lib/commonjs/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
  58. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -0
  59. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  60. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +183 -0
  61. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -0
  62. package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +4 -0
  63. package/lib/commonjs/sksg/Recorder/commands/Paint.js +70 -0
  64. package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -0
  65. package/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  66. package/lib/commonjs/sksg/Recorder/commands/PathEffects.js +137 -0
  67. package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -0
  68. package/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +5 -0
  69. package/lib/commonjs/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +58 -15
  70. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -0
  71. package/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  72. package/lib/commonjs/sksg/{nodes/utils.js → utils.js} +12 -2
  73. package/lib/commonjs/sksg/utils.js.map +1 -0
  74. package/lib/module/dom/types/Common.d.ts +6 -4
  75. package/lib/module/dom/types/Common.js.map +1 -1
  76. package/lib/module/dom/types/ImageFilters.d.ts +1 -1
  77. package/lib/module/dom/types/ImageFilters.js.map +1 -1
  78. package/lib/module/dom/types/Node.d.ts +0 -2
  79. package/lib/module/dom/types/Node.js.map +1 -1
  80. package/lib/module/external/reanimated/index.d.ts +0 -1
  81. package/lib/module/external/reanimated/index.js +0 -1
  82. package/lib/module/external/reanimated/index.js.map +1 -1
  83. package/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
  84. package/lib/module/external/reanimated/renderHelpers.js +4 -42
  85. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  86. package/lib/module/skia/types/Paint/Paint.d.ts +1 -0
  87. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
  89. package/lib/module/skia/web/JsiSkPaint.js +3 -0
  90. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  91. package/lib/module/sksg/Container.d.ts +3 -2
  92. package/lib/module/sksg/Container.js +30 -24
  93. package/lib/module/sksg/Container.js.map +1 -1
  94. package/lib/module/sksg/HostConfig.d.ts +2 -2
  95. package/lib/module/sksg/HostConfig.js +7 -25
  96. package/lib/module/sksg/HostConfig.js.map +1 -1
  97. package/lib/module/sksg/Node.d.ts +19 -0
  98. package/lib/module/sksg/Node.js +67 -0
  99. package/lib/module/sksg/Node.js.map +1 -0
  100. package/lib/module/sksg/Reconciler.d.ts +1 -1
  101. package/lib/module/sksg/Recorder/Core.d.ts +79 -0
  102. package/lib/module/sksg/Recorder/Core.js +101 -0
  103. package/lib/module/sksg/Recorder/Core.js.map +1 -0
  104. package/lib/module/sksg/Recorder/DrawingContext.d.ts +18 -0
  105. package/lib/module/sksg/Recorder/DrawingContext.js +98 -0
  106. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -0
  107. package/lib/module/sksg/Recorder/Player.d.ts +3 -0
  108. package/lib/module/sksg/Recorder/Player.js +120 -0
  109. package/lib/module/sksg/Recorder/Player.js.map +1 -0
  110. package/lib/module/sksg/Recorder/Recorder.d.ts +50 -0
  111. package/lib/module/sksg/Recorder/Recorder.js +281 -0
  112. package/lib/module/sksg/Recorder/Recorder.js.map +1 -0
  113. package/lib/module/sksg/Recorder/Recording.d.ts +7 -0
  114. package/lib/module/sksg/Recorder/Recording.js +5 -0
  115. package/lib/module/sksg/Recorder/Recording.js.map +1 -0
  116. package/lib/module/sksg/Recorder/Visitor.d.ts +5 -0
  117. package/lib/module/sksg/Recorder/Visitor.js +285 -0
  118. package/lib/module/sksg/Recorder/Visitor.js.map +1 -0
  119. package/lib/module/sksg/Recorder/commands/Box.d.ts +13 -0
  120. package/lib/module/sksg/Recorder/commands/Box.js +63 -0
  121. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -0
  122. package/lib/module/sksg/Recorder/commands/CTM.d.ts +3 -0
  123. package/lib/module/sksg/Recorder/commands/CTM.js +72 -0
  124. package/lib/module/sksg/Recorder/commands/CTM.js.map +1 -0
  125. package/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  126. package/lib/module/sksg/Recorder/commands/ColorFilters.js +67 -0
  127. package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -0
  128. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +24 -0
  129. package/lib/module/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
  130. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -0
  131. package/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  132. package/lib/module/sksg/{nodes/imageFilters.js → Recorder/commands/ImageFilters.js} +87 -95
  133. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -0
  134. package/lib/module/sksg/Recorder/commands/Paint.d.ts +4 -0
  135. package/lib/module/sksg/Recorder/commands/Paint.js +62 -0
  136. package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -0
  137. package/lib/module/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  138. package/lib/module/sksg/Recorder/commands/PathEffects.js +128 -0
  139. package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -0
  140. package/lib/module/sksg/Recorder/commands/Shaders.d.ts +5 -0
  141. package/lib/module/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +63 -13
  142. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -0
  143. package/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  144. package/lib/module/sksg/{nodes/utils.js → utils.js} +10 -1
  145. package/lib/module/sksg/utils.js.map +1 -0
  146. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
  147. package/lib/typescript/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
  148. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +4 -0
  149. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -3
  150. package/lib/typescript/lib/commonjs/sksg/Node.d.ts +14 -0
  151. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +5 -0
  152. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +17 -0
  153. package/lib/typescript/lib/commonjs/sksg/Recorder/Player.d.ts +2 -0
  154. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +45 -0
  155. package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +5 -0
  156. package/lib/typescript/lib/commonjs/sksg/Recorder/Visitor.d.ts +27 -0
  157. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Box.d.ts +3 -0
  158. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +2 -0
  159. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +4 -0
  160. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +6 -0
  161. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +14 -0
  162. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +4 -0
  163. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +3 -0
  164. package/lib/typescript/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
  165. package/lib/typescript/lib/module/external/reanimated/index.d.ts +0 -1
  166. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
  167. package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
  168. package/lib/typescript/lib/module/sksg/Container.d.ts +4 -0
  169. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -3
  170. package/lib/typescript/lib/module/sksg/Node.d.ts +13 -0
  171. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +4 -0
  172. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +16 -0
  173. package/lib/typescript/lib/module/sksg/Recorder/Player.d.ts +1 -0
  174. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +44 -0
  175. package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +4 -0
  176. package/lib/typescript/lib/module/sksg/Recorder/Visitor.d.ts +26 -0
  177. package/lib/typescript/lib/module/sksg/Recorder/commands/Box.d.ts +2 -0
  178. package/lib/typescript/lib/module/sksg/Recorder/commands/CTM.d.ts +1 -0
  179. package/lib/typescript/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +3 -0
  180. package/lib/typescript/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +5 -0
  181. package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +13 -0
  182. package/lib/typescript/lib/module/sksg/Recorder/commands/PathEffects.d.ts +3 -0
  183. package/lib/typescript/lib/module/sksg/Recorder/commands/Shaders.d.ts +2 -0
  184. package/lib/typescript/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
  185. package/lib/typescript/src/dom/types/Common.d.ts +6 -4
  186. package/lib/typescript/src/dom/types/ImageFilters.d.ts +1 -1
  187. package/lib/typescript/src/dom/types/Node.d.ts +0 -2
  188. package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
  189. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -1
  190. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +1 -0
  191. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  192. package/lib/typescript/src/sksg/Container.d.ts +3 -2
  193. package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
  194. package/lib/typescript/src/sksg/Node.d.ts +19 -0
  195. package/lib/typescript/src/sksg/Reconciler.d.ts +1 -1
  196. package/lib/typescript/src/sksg/Recorder/Core.d.ts +79 -0
  197. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +18 -0
  198. package/lib/typescript/src/sksg/Recorder/Player.d.ts +3 -0
  199. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +50 -0
  200. package/lib/typescript/src/sksg/Recorder/Recording.d.ts +7 -0
  201. package/lib/typescript/src/sksg/Recorder/Visitor.d.ts +5 -0
  202. package/lib/typescript/src/sksg/Recorder/commands/Box.d.ts +13 -0
  203. package/lib/typescript/src/sksg/Recorder/commands/CTM.d.ts +3 -0
  204. package/lib/typescript/src/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
  205. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +24 -0
  206. package/lib/typescript/src/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
  207. package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +4 -0
  208. package/lib/typescript/src/sksg/Recorder/commands/PathEffects.d.ts +6 -0
  209. package/lib/typescript/src/sksg/Recorder/commands/Shaders.d.ts +5 -0
  210. package/lib/typescript/src/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
  211. package/package.json +1 -1
  212. package/src/__tests__/snapshots/image-filter/test-shadow.png +0 -0
  213. package/src/dom/types/Common.ts +7 -5
  214. package/src/dom/types/ImageFilters.ts +2 -1
  215. package/src/dom/types/Node.ts +0 -4
  216. package/src/external/reanimated/index.ts +0 -1
  217. package/src/external/reanimated/renderHelpers.ts +4 -44
  218. package/src/renderer/__tests__/e2e/ColorFilters.spec.tsx +15 -0
  219. package/src/renderer/__tests__/e2e/Composition/ColorFilterComposition.spec.tsx +23 -2
  220. package/src/renderer/__tests__/e2e/ImageFilters.spec.tsx +91 -2
  221. package/src/renderer/__tests__/setup.tsx +1 -1
  222. package/src/skia/types/Paint/Paint.ts +2 -0
  223. package/src/skia/web/JsiSkPaint.ts +4 -0
  224. package/src/sksg/Container.ts +35 -29
  225. package/src/sksg/HostConfig.ts +5 -50
  226. package/src/sksg/Node.ts +105 -0
  227. package/src/sksg/Recorder/Core.ts +171 -0
  228. package/src/sksg/Recorder/DrawingContext.ts +130 -0
  229. package/src/sksg/Recorder/Player.ts +160 -0
  230. package/src/sksg/Recorder/Recorder.ts +259 -0
  231. package/src/sksg/Recorder/Recording.ts +13 -0
  232. package/src/sksg/Recorder/Visitor.ts +324 -0
  233. package/src/sksg/Recorder/commands/Box.ts +63 -0
  234. package/src/sksg/Recorder/commands/CTM.ts +72 -0
  235. package/src/sksg/Recorder/commands/ColorFilters.ts +87 -0
  236. package/src/sksg/{nodes/drawings.ts → Recorder/commands/Drawing.ts} +29 -65
  237. package/src/sksg/Recorder/commands/ImageFilters.ts +255 -0
  238. package/src/sksg/Recorder/commands/Paint.ts +77 -0
  239. package/src/sksg/Recorder/commands/PathEffects.ts +169 -0
  240. package/src/sksg/{nodes/shaders.ts → Recorder/commands/Shaders.ts} +100 -26
  241. package/src/sksg/{nodes/utils.ts → utils.ts} +14 -1
  242. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  243. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +0 -24
  244. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +0 -1
  245. package/lib/commonjs/sksg/DeclarationContext.d.ts +0 -56
  246. package/lib/commonjs/sksg/DeclarationContext.js +0 -77
  247. package/lib/commonjs/sksg/DeclarationContext.js.map +0 -1
  248. package/lib/commonjs/sksg/DrawingContext.d.ts +0 -13
  249. package/lib/commonjs/sksg/DrawingContext.js +0 -172
  250. package/lib/commonjs/sksg/DrawingContext.js.map +0 -1
  251. package/lib/commonjs/sksg/__tests__/Declarations.spec.d.ts +0 -1
  252. package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +0 -57
  253. package/lib/commonjs/sksg/nodes/Node.d.ts +0 -7
  254. package/lib/commonjs/sksg/nodes/Node.js +0 -6
  255. package/lib/commonjs/sksg/nodes/Node.js.map +0 -1
  256. package/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -10
  257. package/lib/commonjs/sksg/nodes/colorFilters.js +0 -79
  258. package/lib/commonjs/sksg/nodes/colorFilters.js.map +0 -1
  259. package/lib/commonjs/sksg/nodes/context.d.ts +0 -3
  260. package/lib/commonjs/sksg/nodes/context.js +0 -394
  261. package/lib/commonjs/sksg/nodes/context.js.map +0 -1
  262. package/lib/commonjs/sksg/nodes/drawings.d.ts +0 -30
  263. package/lib/commonjs/sksg/nodes/drawings.js.map +0 -1
  264. package/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -17
  265. package/lib/commonjs/sksg/nodes/imageFilters.js +0 -197
  266. package/lib/commonjs/sksg/nodes/imageFilters.js.map +0 -1
  267. package/lib/commonjs/sksg/nodes/index.d.ts +0 -3
  268. package/lib/commonjs/sksg/nodes/index.js +0 -39
  269. package/lib/commonjs/sksg/nodes/index.js.map +0 -1
  270. package/lib/commonjs/sksg/nodes/paint.d.ts +0 -3
  271. package/lib/commonjs/sksg/nodes/paint.js +0 -81
  272. package/lib/commonjs/sksg/nodes/paint.js.map +0 -1
  273. package/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -11
  274. package/lib/commonjs/sksg/nodes/pathEffects.js +0 -111
  275. package/lib/commonjs/sksg/nodes/pathEffects.js.map +0 -1
  276. package/lib/commonjs/sksg/nodes/shaders.d.ts +0 -11
  277. package/lib/commonjs/sksg/nodes/shaders.js.map +0 -1
  278. package/lib/commonjs/sksg/nodes/utils.js.map +0 -1
  279. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  280. package/lib/module/external/reanimated/useDerivedValueOnJS.js +0 -16
  281. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +0 -1
  282. package/lib/module/sksg/DeclarationContext.d.ts +0 -56
  283. package/lib/module/sksg/DeclarationContext.js +0 -69
  284. package/lib/module/sksg/DeclarationContext.js.map +0 -1
  285. package/lib/module/sksg/DrawingContext.d.ts +0 -13
  286. package/lib/module/sksg/DrawingContext.js +0 -165
  287. package/lib/module/sksg/DrawingContext.js.map +0 -1
  288. package/lib/module/sksg/__tests__/Declarations.spec.d.ts +0 -1
  289. package/lib/module/sksg/__tests__/MockDeclaration.d.ts +0 -57
  290. package/lib/module/sksg/nodes/Node.d.ts +0 -7
  291. package/lib/module/sksg/nodes/Node.js +0 -2
  292. package/lib/module/sksg/nodes/Node.js.map +0 -1
  293. package/lib/module/sksg/nodes/colorFilters.d.ts +0 -10
  294. package/lib/module/sksg/nodes/colorFilters.js +0 -66
  295. package/lib/module/sksg/nodes/colorFilters.js.map +0 -1
  296. package/lib/module/sksg/nodes/context.d.ts +0 -3
  297. package/lib/module/sksg/nodes/context.js +0 -387
  298. package/lib/module/sksg/nodes/context.js.map +0 -1
  299. package/lib/module/sksg/nodes/drawings.d.ts +0 -30
  300. package/lib/module/sksg/nodes/drawings.js.map +0 -1
  301. package/lib/module/sksg/nodes/imageFilters.d.ts +0 -17
  302. package/lib/module/sksg/nodes/imageFilters.js.map +0 -1
  303. package/lib/module/sksg/nodes/index.d.ts +0 -3
  304. package/lib/module/sksg/nodes/index.js +0 -4
  305. package/lib/module/sksg/nodes/index.js.map +0 -1
  306. package/lib/module/sksg/nodes/paint.d.ts +0 -3
  307. package/lib/module/sksg/nodes/paint.js +0 -74
  308. package/lib/module/sksg/nodes/paint.js.map +0 -1
  309. package/lib/module/sksg/nodes/pathEffects.d.ts +0 -11
  310. package/lib/module/sksg/nodes/pathEffects.js +0 -97
  311. package/lib/module/sksg/nodes/pathEffects.js.map +0 -1
  312. package/lib/module/sksg/nodes/shaders.d.ts +0 -11
  313. package/lib/module/sksg/nodes/shaders.js.map +0 -1
  314. package/lib/module/sksg/nodes/utils.js.map +0 -1
  315. package/lib/typescript/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -2
  316. package/lib/typescript/lib/commonjs/sksg/DeclarationContext.d.ts +0 -53
  317. package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +0 -22
  318. package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +0 -1
  319. package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -8
  320. package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +0 -2
  321. package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -12
  322. package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +0 -1
  323. package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +0 -2
  324. package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -9
  325. package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +0 -10
  326. package/lib/typescript/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  327. package/lib/typescript/lib/module/sksg/DeclarationContext.d.ts +0 -52
  328. package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +0 -21
  329. package/lib/typescript/lib/module/sksg/nodes/Node.d.ts +0 -1
  330. package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +0 -7
  331. package/lib/typescript/lib/module/sksg/nodes/context.d.ts +0 -1
  332. package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +0 -11
  333. package/lib/typescript/lib/module/sksg/nodes/index.d.ts +0 -3
  334. package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +0 -1
  335. package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +0 -8
  336. package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +0 -9
  337. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
  338. package/lib/typescript/src/sksg/DeclarationContext.d.ts +0 -56
  339. package/lib/typescript/src/sksg/DrawingContext.d.ts +0 -13
  340. package/lib/typescript/src/sksg/__tests__/Declarations.spec.d.ts +0 -1
  341. package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +0 -57
  342. package/lib/typescript/src/sksg/nodes/Node.d.ts +0 -7
  343. package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +0 -10
  344. package/lib/typescript/src/sksg/nodes/context.d.ts +0 -3
  345. package/lib/typescript/src/sksg/nodes/drawings.d.ts +0 -30
  346. package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +0 -17
  347. package/lib/typescript/src/sksg/nodes/index.d.ts +0 -3
  348. package/lib/typescript/src/sksg/nodes/paint.d.ts +0 -3
  349. package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +0 -11
  350. package/lib/typescript/src/sksg/nodes/shaders.d.ts +0 -11
  351. package/src/external/reanimated/useDerivedValueOnJS.ts +0 -20
  352. package/src/sksg/DeclarationContext.ts +0 -85
  353. package/src/sksg/DrawingContext.ts +0 -226
  354. package/src/sksg/__tests__/Declarations.spec.tsx +0 -235
  355. package/src/sksg/__tests__/MockDeclaration.ts +0 -138
  356. package/src/sksg/nodes/Node.ts +0 -8
  357. package/src/sksg/nodes/colorFilters.ts +0 -79
  358. package/src/sksg/nodes/context.ts +0 -412
  359. package/src/sksg/nodes/imageFilters.ts +0 -235
  360. package/src/sksg/nodes/index.ts +0 -3
  361. package/src/sksg/nodes/paint.ts +0 -75
  362. package/src/sksg/nodes/pathEffects.ts +0 -118
  363. /package/lib/typescript/lib/commonjs/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
  364. /package/lib/typescript/lib/module/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
@@ -0,0 +1,285 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import { NodeType } from "../../dom/types";
4
+ import { isImageFilter, isShader, sortNodeChildren } from "../Node";
5
+ export const processPaint = ({
6
+ opacity,
7
+ color,
8
+ strokeWidth,
9
+ blendMode,
10
+ style,
11
+ strokeJoin,
12
+ strokeCap,
13
+ strokeMiter,
14
+ antiAlias,
15
+ dither,
16
+ paint: paintRef
17
+ }) => {
18
+ const paint = {};
19
+ if (opacity !== undefined) {
20
+ paint.opacity = opacity;
21
+ }
22
+ if (color !== undefined) {
23
+ paint.color = color;
24
+ }
25
+ if (strokeWidth !== undefined) {
26
+ paint.strokeWidth = strokeWidth;
27
+ }
28
+ if (blendMode !== undefined) {
29
+ paint.blendMode = blendMode;
30
+ }
31
+ if (style !== undefined) {
32
+ paint.style = style;
33
+ }
34
+ if (strokeJoin !== undefined) {
35
+ paint.strokeJoin = strokeJoin;
36
+ }
37
+ if (strokeCap !== undefined) {
38
+ paint.strokeCap = strokeCap;
39
+ }
40
+ if (strokeMiter !== undefined) {
41
+ paint.strokeMiter = strokeMiter;
42
+ }
43
+ if (antiAlias !== undefined) {
44
+ paint.antiAlias = antiAlias;
45
+ }
46
+ if (dither !== undefined) {
47
+ paint.dither = dither;
48
+ }
49
+ if (paintRef !== undefined) {
50
+ paint.paint = paintRef;
51
+ }
52
+ if (opacity !== undefined || color !== undefined || strokeWidth !== undefined || blendMode !== undefined || style !== undefined || strokeJoin !== undefined || strokeCap !== undefined || strokeMiter !== undefined || antiAlias !== undefined || dither !== undefined || paintRef !== undefined) {
53
+ return paint;
54
+ }
55
+ return null;
56
+ };
57
+ const processCTM = ({
58
+ clip,
59
+ invertClip,
60
+ transform,
61
+ origin,
62
+ matrix,
63
+ layer
64
+ }) => {
65
+ const ctm = {};
66
+ if (clip) {
67
+ ctm.clip = clip;
68
+ }
69
+ if (invertClip) {
70
+ ctm.invertClip = invertClip;
71
+ }
72
+ if (transform) {
73
+ ctm.transform = transform;
74
+ }
75
+ if (origin) {
76
+ ctm.origin = origin;
77
+ }
78
+ if (matrix) {
79
+ ctm.matrix = matrix;
80
+ }
81
+ if (layer) {
82
+ ctm.layer = layer;
83
+ }
84
+ if (clip !== undefined || invertClip !== undefined || transform !== undefined || origin !== undefined || matrix !== undefined || layer !== undefined) {
85
+ return ctm;
86
+ }
87
+ return null;
88
+ };
89
+ const pushColorFilters = (recorder, colorFilters) => {
90
+ colorFilters.forEach(colorFilter => {
91
+ if (colorFilter.children.length > 0) {
92
+ pushColorFilters(recorder, colorFilter.children);
93
+ }
94
+ recorder.pushColorFilter(colorFilter.type, colorFilter.props);
95
+ const needsComposition = colorFilter.type !== NodeType.LerpColorFilter && colorFilter.children.length > 0;
96
+ if (needsComposition) {
97
+ recorder.composeColorFilter();
98
+ }
99
+ });
100
+ };
101
+ const pushPathEffects = (recorder, pathEffects) => {
102
+ pathEffects.forEach(pathEffect => {
103
+ if (pathEffect.children.length > 0) {
104
+ pushPathEffects(recorder, pathEffect.children);
105
+ }
106
+ recorder.pushPathEffect(pathEffect.type, pathEffect.props);
107
+ const needsComposition = pathEffect.type !== NodeType.SumPathEffect && pathEffect.children.length > 0;
108
+ if (needsComposition) {
109
+ recorder.composePathEffect();
110
+ }
111
+ });
112
+ };
113
+ const pushImageFilters = (recorder, imageFilters) => {
114
+ imageFilters.forEach(imageFilter => {
115
+ if (imageFilter.children.length > 0) {
116
+ pushImageFilters(recorder, imageFilter.children);
117
+ }
118
+ if (isImageFilter(imageFilter.type)) {
119
+ recorder.pushImageFilter(imageFilter.type, imageFilter.props);
120
+ } else if (isShader(imageFilter.type)) {
121
+ recorder.pushShader(imageFilter.type, imageFilter.props);
122
+ }
123
+ const needsComposition = imageFilter.type !== NodeType.BlendImageFilter && imageFilter.children.length > 0;
124
+ if (needsComposition) {
125
+ recorder.composeImageFilter();
126
+ }
127
+ });
128
+ };
129
+ const pushShaders = (recorder, shaders) => {
130
+ shaders.forEach(shader => {
131
+ if (shader.children.length > 0) {
132
+ pushShaders(recorder, shader.children);
133
+ }
134
+ recorder.pushShader(shader.type, shader.props);
135
+ });
136
+ };
137
+ const pushMaskFilters = (recorder, maskFilters) => {
138
+ if (maskFilters.length > 0) {
139
+ recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);
140
+ }
141
+ };
142
+ const pushPaints = (recorder, paints) => {
143
+ paints.forEach(paint => {
144
+ recorder.savePaint(paint.props);
145
+ const {
146
+ colorFilters,
147
+ maskFilters,
148
+ shaders,
149
+ imageFilters,
150
+ pathEffects
151
+ } = sortNodeChildren(paint);
152
+ pushColorFilters(recorder, colorFilters);
153
+ pushImageFilters(recorder, imageFilters);
154
+ pushMaskFilters(recorder, maskFilters);
155
+ pushShaders(recorder, shaders);
156
+ pushPathEffects(recorder, pathEffects);
157
+ recorder.restorePaintDeclaration();
158
+ });
159
+ };
160
+ const visitNode = (recorder, node) => {
161
+ const {
162
+ props
163
+ } = node;
164
+ const {
165
+ colorFilters,
166
+ maskFilters,
167
+ drawings,
168
+ shaders,
169
+ imageFilters,
170
+ pathEffects,
171
+ paints
172
+ } = sortNodeChildren(node);
173
+ const paint = processPaint(props);
174
+ const shouldPushPaint = paint || colorFilters.length > 0 || maskFilters.length > 0 || imageFilters.length > 0 || pathEffects.length > 0 || shaders.length > 0;
175
+ if (shouldPushPaint) {
176
+ recorder.savePaint(paint !== null && paint !== void 0 ? paint : {});
177
+ pushColorFilters(recorder, colorFilters);
178
+ pushImageFilters(recorder, imageFilters);
179
+ pushMaskFilters(recorder, maskFilters);
180
+ pushShaders(recorder, shaders);
181
+ pushPathEffects(recorder, pathEffects);
182
+ // For mixed nodes like BackdropFilters we don't materialize the paint
183
+ if (node.type === NodeType.BackdropFilter) {
184
+ recorder.saveBackdropFilter();
185
+ } else {
186
+ recorder.materializePaint();
187
+ }
188
+ }
189
+ pushPaints(recorder, paints);
190
+ if (node.type === NodeType.Layer) {
191
+ recorder.saveLayer();
192
+ }
193
+ const ctm = processCTM(props);
194
+ const shouldRestore = !!ctm || node.type === NodeType.Layer;
195
+ if (ctm) {
196
+ recorder.saveCTM(ctm);
197
+ }
198
+ switch (node.type) {
199
+ case NodeType.Box:
200
+ const shadows = node.children.filter(n => n.type === NodeType.BoxShadow)
201
+ // eslint-disable-next-line @typescript-eslint/no-shadow
202
+ .map(({
203
+ props
204
+ }) => ({
205
+ props
206
+ }));
207
+ recorder.drawBox(props, shadows);
208
+ break;
209
+ case NodeType.Fill:
210
+ recorder.drawPaint();
211
+ break;
212
+ case NodeType.Image:
213
+ recorder.drawImage(node.props);
214
+ break;
215
+ case NodeType.Circle:
216
+ recorder.drawCircle(node.props);
217
+ break;
218
+ case NodeType.Points:
219
+ recorder.drawPoints(props);
220
+ break;
221
+ case NodeType.Path:
222
+ recorder.drawPath(props);
223
+ break;
224
+ case NodeType.Rect:
225
+ recorder.drawRect(props);
226
+ break;
227
+ case NodeType.RRect:
228
+ recorder.drawRRect(props);
229
+ break;
230
+ case NodeType.Oval:
231
+ recorder.drawOval(props);
232
+ break;
233
+ case NodeType.Line:
234
+ recorder.drawLine(props);
235
+ break;
236
+ case NodeType.Patch:
237
+ recorder.drawPatch(props);
238
+ break;
239
+ case NodeType.Vertices:
240
+ recorder.drawVertices(props);
241
+ break;
242
+ case NodeType.DiffRect:
243
+ recorder.drawDiffRect(props);
244
+ break;
245
+ case NodeType.Text:
246
+ recorder.drawText(props);
247
+ break;
248
+ case NodeType.TextPath:
249
+ recorder.drawTextPath(props);
250
+ break;
251
+ case NodeType.TextBlob:
252
+ recorder.drawTextBlob(props);
253
+ break;
254
+ case NodeType.Glyphs:
255
+ recorder.drawGlyphs(props);
256
+ break;
257
+ case NodeType.Picture:
258
+ recorder.drawPicture(props);
259
+ break;
260
+ case NodeType.ImageSVG:
261
+ recorder.drawImageSVG(props);
262
+ break;
263
+ case NodeType.Paragraph:
264
+ recorder.drawParagraph(props);
265
+ break;
266
+ case NodeType.Atlas:
267
+ recorder.drawAtlas(props);
268
+ break;
269
+ }
270
+ drawings.forEach(drawing => {
271
+ visitNode(recorder, drawing);
272
+ });
273
+ if (shouldPushPaint) {
274
+ recorder.restorePaint();
275
+ }
276
+ if (shouldRestore) {
277
+ recorder.restoreCTM();
278
+ }
279
+ };
280
+ export const visit = (recorder, root) => {
281
+ root.forEach(node => {
282
+ visitNode(recorder, node);
283
+ });
284
+ };
285
+ //# sourceMappingURL=Visitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NodeType","isImageFilter","isShader","sortNodeChildren","processPaint","opacity","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","paintRef","undefined","processCTM","clip","invertClip","transform","origin","matrix","layer","ctm","pushColorFilters","recorder","colorFilters","forEach","colorFilter","children","length","pushColorFilter","type","props","needsComposition","LerpColorFilter","composeColorFilter","pushPathEffects","pathEffects","pathEffect","pushPathEffect","SumPathEffect","composePathEffect","pushImageFilters","imageFilters","imageFilter","pushImageFilter","pushShader","BlendImageFilter","composeImageFilter","pushShaders","shaders","shader","pushMaskFilters","maskFilters","pushBlurMaskFilter","pushPaints","paints","savePaint","restorePaintDeclaration","visitNode","node","drawings","shouldPushPaint","BackdropFilter","saveBackdropFilter","materializePaint","Layer","saveLayer","shouldRestore","saveCTM","Box","shadows","filter","n","BoxShadow","map","drawBox","Fill","drawPaint","Image","drawImage","Circle","drawCircle","Points","drawPoints","Path","drawPath","Rect","drawRect","RRect","drawRRect","Oval","drawOval","Line","drawLine","Patch","drawPatch","Vertices","drawVertices","DiffRect","drawDiffRect","Text","drawText","TextPath","drawTextPath","TextBlob","drawTextBlob","Glyphs","drawGlyphs","Picture","drawPicture","ImageSVG","drawImageSVG","Paragraph","drawParagraph","Atlas","drawAtlas","drawing","restorePaint","restoreCTM","visit","root"],"sources":["Visitor.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n CTMProps,\n DrawingNodeProps,\n BoxShadowProps,\n} from \"../../dom/types\";\nimport { NodeType } from \"../../dom/types\";\nimport type { Node } from \"../Node\";\nimport { isImageFilter, isShader, sortNodeChildren } from \"../Node\";\n\nimport type { Recorder } from \"./Recorder\";\n\nexport const processPaint = ({\n opacity,\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n paint: paintRef,\n}: DrawingNodeProps) => {\n const paint: DrawingNodeProps = {};\n if (opacity !== undefined) {\n paint.opacity = opacity;\n }\n if (color !== undefined) {\n paint.color = color;\n }\n if (strokeWidth !== undefined) {\n paint.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n paint.blendMode = blendMode;\n }\n if (style !== undefined) {\n paint.style = style;\n }\n if (strokeJoin !== undefined) {\n paint.strokeJoin = strokeJoin;\n }\n if (strokeCap !== undefined) {\n paint.strokeCap = strokeCap;\n }\n if (strokeMiter !== undefined) {\n paint.strokeMiter = strokeMiter;\n }\n if (antiAlias !== undefined) {\n paint.antiAlias = antiAlias;\n }\n if (dither !== undefined) {\n paint.dither = dither;\n }\n\n if (paintRef !== undefined) {\n paint.paint = paintRef;\n }\n\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 paintRef !== undefined\n ) {\n return paint;\n }\n return null;\n};\n\nconst processCTM = ({\n clip,\n invertClip,\n transform,\n origin,\n matrix,\n layer,\n}: CTMProps) => {\n const ctm: CTMProps = {};\n if (clip) {\n ctm.clip = clip;\n }\n if (invertClip) {\n ctm.invertClip = invertClip;\n }\n if (transform) {\n ctm.transform = transform;\n }\n if (origin) {\n ctm.origin = origin;\n }\n if (matrix) {\n ctm.matrix = matrix;\n }\n if (layer) {\n ctm.layer = layer;\n }\n if (\n clip !== undefined ||\n invertClip !== undefined ||\n transform !== undefined ||\n origin !== undefined ||\n matrix !== undefined ||\n layer !== undefined\n ) {\n return ctm;\n }\n return null;\n};\n\nconst pushColorFilters = (recorder: Recorder, colorFilters: Node<any>[]) => {\n colorFilters.forEach((colorFilter) => {\n if (colorFilter.children.length > 0) {\n pushColorFilters(recorder, colorFilter.children);\n }\n recorder.pushColorFilter(colorFilter.type, colorFilter.props);\n const needsComposition =\n colorFilter.type !== NodeType.LerpColorFilter &&\n colorFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeColorFilter();\n }\n });\n};\n\nconst pushPathEffects = (recorder: Recorder, pathEffects: Node<any>[]) => {\n pathEffects.forEach((pathEffect) => {\n if (pathEffect.children.length > 0) {\n pushPathEffects(recorder, pathEffect.children);\n }\n recorder.pushPathEffect(pathEffect.type, pathEffect.props);\n const needsComposition =\n pathEffect.type !== NodeType.SumPathEffect &&\n pathEffect.children.length > 0;\n if (needsComposition) {\n recorder.composePathEffect();\n }\n });\n};\n\nconst pushImageFilters = (recorder: Recorder, imageFilters: Node<any>[]) => {\n imageFilters.forEach((imageFilter) => {\n if (imageFilter.children.length > 0) {\n pushImageFilters(recorder, imageFilter.children);\n }\n if (isImageFilter(imageFilter.type)) {\n recorder.pushImageFilter(imageFilter.type, imageFilter.props);\n } else if (isShader(imageFilter.type)) {\n recorder.pushShader(imageFilter.type, imageFilter.props);\n }\n const needsComposition =\n imageFilter.type !== NodeType.BlendImageFilter &&\n imageFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeImageFilter();\n }\n });\n};\n\nconst pushShaders = (recorder: Recorder, shaders: Node<any>[]) => {\n shaders.forEach((shader) => {\n if (shader.children.length > 0) {\n pushShaders(recorder, shader.children);\n }\n recorder.pushShader(shader.type, shader.props);\n });\n};\n\nconst pushMaskFilters = (recorder: Recorder, maskFilters: Node<any>[]) => {\n if (maskFilters.length > 0) {\n recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);\n }\n};\n\nconst pushPaints = (recorder: Recorder, paints: Node<any>[]) => {\n paints.forEach((paint) => {\n recorder.savePaint(paint.props);\n const { colorFilters, maskFilters, shaders, imageFilters, pathEffects } =\n sortNodeChildren(paint);\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n recorder.restorePaintDeclaration();\n });\n};\n\nconst visitNode = (recorder: Recorder, node: Node<any>) => {\n const { props } = node;\n const {\n colorFilters,\n maskFilters,\n drawings,\n shaders,\n imageFilters,\n pathEffects,\n paints,\n } = sortNodeChildren(node);\n const paint = processPaint(props);\n const shouldPushPaint =\n paint ||\n colorFilters.length > 0 ||\n maskFilters.length > 0 ||\n imageFilters.length > 0 ||\n pathEffects.length > 0 ||\n shaders.length > 0;\n if (shouldPushPaint) {\n recorder.savePaint(paint ?? {});\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n // For mixed nodes like BackdropFilters we don't materialize the paint\n if (node.type === NodeType.BackdropFilter) {\n recorder.saveBackdropFilter();\n } else {\n recorder.materializePaint();\n }\n }\n pushPaints(recorder, paints);\n if (node.type === NodeType.Layer) {\n recorder.saveLayer();\n }\n const ctm = processCTM(props);\n const shouldRestore = !!ctm || node.type === NodeType.Layer;\n if (ctm) {\n recorder.saveCTM(ctm);\n }\n switch (node.type) {\n case NodeType.Box:\n const shadows = node.children\n .filter((n) => n.type === NodeType.BoxShadow)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(({ props }) => ({ props } as { props: BoxShadowProps }));\n recorder.drawBox(props, shadows);\n break;\n case NodeType.Fill:\n recorder.drawPaint();\n break;\n case NodeType.Image:\n recorder.drawImage(node.props);\n break;\n case NodeType.Circle:\n recorder.drawCircle(node.props);\n break;\n case NodeType.Points:\n recorder.drawPoints(props);\n break;\n case NodeType.Path:\n recorder.drawPath(props);\n break;\n case NodeType.Rect:\n recorder.drawRect(props);\n break;\n case NodeType.RRect:\n recorder.drawRRect(props);\n break;\n case NodeType.Oval:\n recorder.drawOval(props);\n break;\n case NodeType.Line:\n recorder.drawLine(props);\n break;\n case NodeType.Patch:\n recorder.drawPatch(props);\n break;\n case NodeType.Vertices:\n recorder.drawVertices(props);\n break;\n case NodeType.DiffRect:\n recorder.drawDiffRect(props);\n break;\n case NodeType.Text:\n recorder.drawText(props);\n break;\n case NodeType.TextPath:\n recorder.drawTextPath(props);\n break;\n case NodeType.TextBlob:\n recorder.drawTextBlob(props);\n break;\n case NodeType.Glyphs:\n recorder.drawGlyphs(props);\n break;\n case NodeType.Picture:\n recorder.drawPicture(props);\n break;\n case NodeType.ImageSVG:\n recorder.drawImageSVG(props);\n break;\n case NodeType.Paragraph:\n recorder.drawParagraph(props);\n break;\n case NodeType.Atlas:\n recorder.drawAtlas(props);\n break;\n }\n drawings.forEach((drawing) => {\n visitNode(recorder, drawing);\n });\n if (shouldPushPaint) {\n recorder.restorePaint();\n }\n if (shouldRestore) {\n recorder.restoreCTM();\n }\n};\n\nexport const visit = (recorder: Recorder, root: Node[]) => {\n root.forEach((node) => {\n visitNode(recorder, node);\n });\n};\n"],"mappings":"AAAA;;AAMA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,EAAEC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AAInE,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,WAAW;EACXC,SAAS;EACTC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC,MAAM;EACNC,KAAK,EAAEC;AACS,CAAC,KAAK;EACtB,MAAMD,KAAuB,GAAG,CAAC,CAAC;EAClC,IAAIV,OAAO,KAAKY,SAAS,EAAE;IACzBF,KAAK,CAACV,OAAO,GAAGA,OAAO;EACzB;EACA,IAAIC,KAAK,KAAKW,SAAS,EAAE;IACvBF,KAAK,CAACT,KAAK,GAAGA,KAAK;EACrB;EACA,IAAIC,WAAW,KAAKU,SAAS,EAAE;IAC7BF,KAAK,CAACR,WAAW,GAAGA,WAAW;EACjC;EACA,IAAIC,SAAS,KAAKS,SAAS,EAAE;IAC3BF,KAAK,CAACP,SAAS,GAAGA,SAAS;EAC7B;EACA,IAAIC,KAAK,KAAKQ,SAAS,EAAE;IACvBF,KAAK,CAACN,KAAK,GAAGA,KAAK;EACrB;EACA,IAAIC,UAAU,KAAKO,SAAS,EAAE;IAC5BF,KAAK,CAACL,UAAU,GAAGA,UAAU;EAC/B;EACA,IAAIC,SAAS,KAAKM,SAAS,EAAE;IAC3BF,KAAK,CAACJ,SAAS,GAAGA,SAAS;EAC7B;EACA,IAAIC,WAAW,KAAKK,SAAS,EAAE;IAC7BF,KAAK,CAACH,WAAW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AQ,EAAEoC,IAAI,CAAC;EAC3B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import type { BoxProps, BoxShadowProps } from "../../../dom/types";
2
+ import type { Command } from "../Core";
3
+ import { CommandType } from "../Core";
4
+ import type { DrawingContext } from "../DrawingContext";
5
+ interface BoxCommand extends Command<CommandType.DrawBox> {
6
+ props: BoxProps;
7
+ shadows: {
8
+ props: BoxShadowProps;
9
+ }[];
10
+ }
11
+ export declare const isBoxCommand: (command: Command) => command is BoxCommand;
12
+ export declare const drawBox: (ctx: DrawingContext, command: BoxCommand) => void;
13
+ export {};
@@ -0,0 +1,63 @@
1
+ import { deflate, inflate } from "../../../dom/nodes";
2
+ import { BlurStyle, ClipOp, isRRect } from "../../../skia/types";
3
+ import { CommandType, materializeProps } from "../Core";
4
+ export const isBoxCommand = command => {
5
+ "worklet";
6
+
7
+ return command.type === CommandType.DrawBox;
8
+ };
9
+ export const drawBox = (ctx, command) => {
10
+ "worklet";
11
+
12
+ command.shadows.forEach(shadow => {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ materializeProps(shadow);
15
+ });
16
+ const shadows = command.shadows.map(shadow => shadow.props);
17
+ const {
18
+ paint,
19
+ Skia,
20
+ canvas
21
+ } = ctx;
22
+ const {
23
+ box: defaultBox
24
+ } = command.props;
25
+ const opacity = paint.getAlphaf();
26
+ const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);
27
+ shadows.filter(shadow => !shadow.inner).map(shadow => {
28
+ const {
29
+ color = "black",
30
+ blur,
31
+ spread = 0,
32
+ dx = 0,
33
+ dy = 0
34
+ } = shadow;
35
+ const lPaint = Skia.Paint();
36
+ lPaint.setColor(Skia.Color(color));
37
+ lPaint.setAlphaf(paint.getAlphaf() * opacity);
38
+ lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
39
+ canvas.drawRRect(inflate(Skia, box, spread, spread, dx, dy), lPaint);
40
+ });
41
+ canvas.drawRRect(box, paint);
42
+ shadows.filter(shadow => shadow.inner).map(shadow => {
43
+ const {
44
+ color = "black",
45
+ blur,
46
+ spread = 0,
47
+ dx = 0,
48
+ dy = 0
49
+ } = shadow;
50
+ const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));
51
+ canvas.save();
52
+ canvas.clipRRect(box, ClipOp.Intersect, false);
53
+ const lPaint = Skia.Paint();
54
+ lPaint.setColor(Skia.Color(color));
55
+ lPaint.setAlphaf(paint.getAlphaf() * opacity);
56
+ lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
57
+ const inner = deflate(Skia, box, spread, spread, dx, dy);
58
+ const outer = inflate(Skia, box, delta.x, delta.y);
59
+ canvas.drawDRRect(outer, inner, lPaint);
60
+ canvas.restore();
61
+ });
62
+ };
63
+ //# sourceMappingURL=Box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deflate","inflate","BlurStyle","ClipOp","isRRect","CommandType","materializeProps","isBoxCommand","command","type","DrawBox","drawBox","ctx","shadows","forEach","shadow","map","props","paint","Skia","canvas","box","defaultBox","opacity","getAlphaf","RRectXY","filter","inner","color","blur","spread","dx","dy","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","Intersect","outer","x","y","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import { deflate, inflate } from \"../../../dom/nodes\";\nimport type { BoxProps, BoxShadowProps } from \"../../../dom/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { Command } from \"../Core\";\nimport { CommandType, materializeProps } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\ninterface BoxCommand extends Command<CommandType.DrawBox> {\n props: BoxProps;\n shadows: { props: BoxShadowProps }[];\n}\n\nexport const isBoxCommand = (command: Command): command is BoxCommand => {\n \"worklet\";\n return command.type === CommandType.DrawBox;\n};\n\nexport const drawBox = (ctx: DrawingContext, command: BoxCommand) => {\n \"worklet\";\n command.shadows.forEach((shadow) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n materializeProps(shadow as any);\n });\n const shadows = command.shadows.map((shadow) => shadow.props);\n const { paint, Skia, canvas } = ctx;\n const { box: defaultBox } = command.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(inflate(Skia, box, spread, spread, dx, dy), lPaint);\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = Skia.Paint();\n lPaint.setColor(Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(Skia, box, spread, spread, dx, dy);\n const outer = inflate(Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,OAAO,QAAQ,oBAAoB;AAErD,SAASC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,qBAAqB;AAEhE,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,SAAS;AAQvD,OAAO,MAAMC,YAAY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G3B,OAAO,CAACmB,IAAI,EAAEE,GAAG,EAAES,MAAM,EAAEA,MAAM,EAAEC,EAAE,EAAEC,EAAE,CAAC;IACxD,MAAMkB,KAAK,GAAGjD,OAAO,CAACkB,IAAI,EAAEE,GAAG,EAAEsB,KAAK,CAACQ,CAAC,EAAER,KAAK,CAACS,CAAC,CAAC;IAClDhC,MAAM,CAACiC,UAAU,CAACH,KAAK,EAAEvB,KAAK,EAAEM,MAAM,CAAC;IACvCb,MAAM,CAACkC,OAAO,CAAC,CAAC;EAClB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { CTMProps } from "../../../dom/types";
2
+ import type { DrawingContext } from "../DrawingContext";
3
+ export declare const saveCTM: (ctx: DrawingContext, props: CTMProps) => void;
@@ -0,0 +1,72 @@
1
+ import { isPathDef, processPath, processTransformProps2 } from "../../../dom/nodes";
2
+ import { ClipOp, isRRect } from "../../../skia/types";
3
+ const computeClip = (Skia, clip) => {
4
+ "worklet";
5
+
6
+ if (clip) {
7
+ if (isPathDef(clip)) {
8
+ return {
9
+ clipPath: processPath(Skia, clip)
10
+ };
11
+ } else if (isRRect(clip)) {
12
+ return {
13
+ clipRRect: clip
14
+ };
15
+ } else {
16
+ return {
17
+ clipRect: clip
18
+ };
19
+ }
20
+ }
21
+ return undefined;
22
+ };
23
+ export const saveCTM = (ctx, props) => {
24
+ "worklet";
25
+
26
+ const {
27
+ canvas,
28
+ Skia
29
+ } = ctx;
30
+ const {
31
+ clip: rawClip,
32
+ invertClip,
33
+ matrix,
34
+ transform,
35
+ origin,
36
+ layer
37
+ } = props;
38
+ const hasTransform = matrix !== undefined || transform !== undefined;
39
+ const clip = computeClip(Skia, rawClip);
40
+ const hasClip = clip !== undefined;
41
+ const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;
42
+ const m3 = processTransformProps2(Skia, {
43
+ matrix,
44
+ transform,
45
+ origin
46
+ });
47
+ const shouldSave = hasTransform || hasClip || !!layer;
48
+ if (shouldSave) {
49
+ if (layer) {
50
+ if (typeof layer === "boolean") {
51
+ canvas.saveLayer();
52
+ } else {
53
+ canvas.saveLayer(layer);
54
+ }
55
+ } else {
56
+ canvas.save();
57
+ }
58
+ }
59
+ if (m3) {
60
+ canvas.concat(m3);
61
+ }
62
+ if (clip) {
63
+ if ("clipRect" in clip) {
64
+ canvas.clipRect(clip.clipRect, op, true);
65
+ } else if ("clipRRect" in clip) {
66
+ canvas.clipRRect(clip.clipRRect, op, true);
67
+ } else {
68
+ canvas.clipPath(clip.clipPath, op, true);
69
+ }
70
+ }
71
+ };
72
+ //# sourceMappingURL=CTM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isPathDef","processPath","processTransformProps2","ClipOp","isRRect","computeClip","Skia","clip","clipPath","clipRRect","clipRect","undefined","saveCTM","ctx","props","canvas","rawClip","invertClip","matrix","transform","origin","layer","hasTransform","hasClip","op","Difference","Intersect","m3","shouldSave","saveLayer","save","concat"],"sources":["CTM.ts"],"sourcesContent":["import {\n isPathDef,\n processPath,\n processTransformProps2,\n} from \"../../../dom/nodes\";\nimport type { ClipDef, CTMProps } from \"../../../dom/types\";\nimport type { Skia, SkPath, SkRect, SkRRect } from \"../../../skia/types\";\nimport { ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nconst computeClip = (\n Skia: Skia,\n clip: ClipDef | undefined\n):\n | undefined\n | { clipPath: SkPath }\n | { clipRect: SkRect }\n | { clipRRect: SkRRect } => {\n \"worklet\";\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 const saveCTM = (ctx: DrawingContext, props: CTMProps) => {\n \"worklet\";\n const { canvas, Skia } = ctx;\n const {\n clip: rawClip,\n invertClip,\n matrix,\n transform,\n origin,\n layer,\n } = props as CTMProps;\n const hasTransform = matrix !== undefined || transform !== undefined;\n const clip = computeClip(Skia, rawClip);\n const hasClip = clip !== undefined;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n const m3 = processTransformProps2(Skia, { matrix, transform, origin });\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n if (m3) {\n canvas.concat(m3);\n }\n if (clip) {\n if (\"clipRect\" in clip) {\n canvas.clipRect(clip.clipRect, op, true);\n } else if (\"clipRRect\" in clip) {\n canvas.clipRRect(clip.clipRRect, op, true);\n } else {\n canvas.clipPath(clip.clipPath, op, true);\n }\n }\n};\n"],"mappings":"AAAA,SACEA,SAAS,EACTC,WAAW,EACXC,sBAAsB,QACjB,oBAAoB;AAG3B,SAASC,MAAM,EAAEC,OAAO,QAAQ,qBAAqB;AAGrD,MAAMC,WAAW,GAAGA,CAClBC,IAAU,EACVC,IAAyB,KAKG;EAC5B,SAAS;;EACT,IAAIA,IAAI,EAAE;IACR,IAAIP,SAAS,CAACO,IAAI,CAAC,EAAE;MACnB,OAAO;QAAEC,QAAQ,EAAEP,WAAW,CAACK,IAAI,EAAEC,IAAI;MAAE,CAAC;IAC9C,CAAC,MAAM,IAAIH,OAAO,CAACG,IAAI,CAAC,EAAE;MACxB,OAAO;QAAEE,SAAS,EAAEF;MAAK,CAAC;IAC5B,CAAC,MAAM;MACL,OAAO;QAAEG,QAAQ,EAAEH;MAAK,CAAC;IAC3B;EACF;EACA,OAAOI,SAAS;AAClB,CAAC;AAED,OAAO,MAAMC,OAAO,GAAGA,CAACC,GAAmB,EAAEC,KAAe,KAAK;EAC/D,SAAS;;EACT,MAAM;IAAEC,MAAM;IAAET;EAAK,CAAC,GAAGO,GAAG;EAC5B,MAAM;IACJN,IAAI,EAAES,OAAO;IACbC,UAAU;IACVC,MAAM;IACNC,SAAS;IACTC,MAAM;IACNC;EACF,CA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+1,6 @@
1
+ import { CommandType } from "../Core";
2
+ import type { Command } from "../Core";
3
+ import type { DrawingContext } from "../DrawingContext";
4
+ export declare const isPushColorFilter: (command: Command) => command is Command<CommandType.PushColorFilter>;
5
+ export declare const composeColorFilters: (ctx: DrawingContext) => void;
6
+ export declare const pushColorFilter: (ctx: DrawingContext, command: Command<CommandType.PushColorFilter>) => void;
@@ -0,0 +1,67 @@
1
+ import { enumKey } from "../../../dom/nodes";
2
+ import { NodeType } from "../../../dom/types";
3
+ import { BlendMode } from "../../../skia/types";
4
+ import { CommandType } from "../Core";
5
+ export const isPushColorFilter = command => {
6
+ "worklet";
7
+
8
+ return command.type === CommandType.PushColorFilter;
9
+ };
10
+ const isColorFilter = (command, type) => {
11
+ "worklet";
12
+
13
+ return command.colorFilterType === type;
14
+ };
15
+ export const composeColorFilters = ctx => {
16
+ "worklet";
17
+
18
+ if (ctx.colorFilters.length > 1) {
19
+ const outer = ctx.colorFilters.pop();
20
+ const inner = ctx.colorFilters.pop();
21
+ ctx.colorFilters.push(ctx.Skia.ColorFilter.MakeCompose(outer, inner));
22
+ }
23
+ };
24
+ export const pushColorFilter = (ctx, command) => {
25
+ "worklet";
26
+
27
+ let cf;
28
+ if (isColorFilter(command, NodeType.BlendColorFilter)) {
29
+ const {
30
+ props
31
+ } = command;
32
+ const {
33
+ mode
34
+ } = props;
35
+ const color = ctx.Skia.Color(props.color);
36
+ cf = ctx.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);
37
+ } else if (isColorFilter(command, NodeType.MatrixColorFilter)) {
38
+ const {
39
+ matrix
40
+ } = command.props;
41
+ cf = ctx.Skia.ColorFilter.MakeMatrix(matrix);
42
+ } else if (isColorFilter(command, NodeType.LerpColorFilter)) {
43
+ const {
44
+ props
45
+ } = command;
46
+ const {
47
+ t
48
+ } = props;
49
+ const second = ctx.colorFilters.pop();
50
+ const first = ctx.colorFilters.pop();
51
+ if (!first || !second) {
52
+ throw new Error("LerpColorFilter requires two color filters");
53
+ }
54
+ cf = ctx.Skia.ColorFilter.MakeLerp(t, first, second);
55
+ } else if (isColorFilter(command, NodeType.LumaColorFilter)) {
56
+ cf = ctx.Skia.ColorFilter.MakeLumaColorFilter();
57
+ } else if (isColorFilter(command, NodeType.LinearToSRGBGammaColorFilter)) {
58
+ cf = ctx.Skia.ColorFilter.MakeLinearToSRGBGamma();
59
+ } else if (isColorFilter(command, NodeType.SRGBToLinearGammaColorFilter)) {
60
+ cf = ctx.Skia.ColorFilter.MakeSRGBToLinearGamma();
61
+ }
62
+ if (!cf) {
63
+ throw new Error(`Unknown color filter type: ${command.colorFilterType}`);
64
+ }
65
+ ctx.colorFilters.push(cf);
66
+ };
67
+ //# sourceMappingURL=ColorFilters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["enumKey","NodeType","BlendMode","CommandType","isPushColorFilter","command","type","PushColorFilter","isColorFilter","colorFilterType","composeColorFilters","ctx","colorFilters","length","outer","pop","inner","push","Skia","ColorFilter","MakeCompose","pushColorFilter","cf","BlendColorFilter","props","mode","color","Color","MakeBlend","MatrixColorFilter","matrix","MakeMatrix","LerpColorFilter","t","second","first","Error","MakeLerp","LumaColorFilter","MakeLumaColorFilter","LinearToSRGBGammaColorFilter","MakeLinearToSRGBGamma","SRGBToLinearGammaColorFilter","MakeSRGBToLinearGamma"],"sources":["ColorFilters.ts"],"sourcesContent":["import { enumKey } from \"../../../dom/nodes\";\nimport type {\n BlendColorFilterProps,\n LerpColorFilterProps,\n MatrixColorFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColorFilter } from \"../../../skia/types\";\nimport { BlendMode } from \"../../../skia/types\";\nimport { CommandType } from \"../Core\";\nimport type { Command } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const isPushColorFilter = (\n command: Command\n): command is Command<CommandType.PushColorFilter> => {\n \"worklet\";\n return command.type === CommandType.PushColorFilter;\n};\n\ntype Props = {\n [NodeType.BlendColorFilter]: BlendColorFilterProps;\n [NodeType.MatrixColorFilter]: MatrixColorFilterProps;\n [NodeType.LerpColorFilter]: LerpColorFilterProps;\n [NodeType.LumaColorFilter]: Record<string, never>;\n [NodeType.LinearToSRGBGammaColorFilter]: Record<string, never>;\n [NodeType.SRGBToLinearGammaColorFilter]: Record<string, never>;\n};\n\ninterface PushColorFilter<T extends keyof Props>\n extends Command<CommandType.PushColorFilter> {\n colorFilterType: T;\n props: Props[T];\n}\n\nconst isColorFilter = <T extends keyof Props>(\n command: Command<CommandType.PushColorFilter>,\n type: T\n): command is PushColorFilter<T> => {\n \"worklet\";\n return command.colorFilterType === type;\n};\n\nexport const composeColorFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.colorFilters.length > 1) {\n const outer = ctx.colorFilters.pop()!;\n const inner = ctx.colorFilters.pop()!;\n ctx.colorFilters.push(ctx.Skia.ColorFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const pushColorFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushColorFilter>\n) => {\n \"worklet\";\n let cf: SkColorFilter | undefined;\n if (isColorFilter(command, NodeType.BlendColorFilter)) {\n const { props } = command;\n const { mode } = props;\n const color = ctx.Skia.Color(props.color);\n cf = ctx.Skia.ColorFilter.MakeBlend(color, BlendMode[enumKey(mode)]);\n } else if (isColorFilter(command, NodeType.MatrixColorFilter)) {\n const { matrix } = command.props;\n cf = ctx.Skia.ColorFilter.MakeMatrix(matrix);\n } else if (isColorFilter(command, NodeType.LerpColorFilter)) {\n const { props } = command;\n const { t } = props;\n const second = ctx.colorFilters.pop();\n const first = ctx.colorFilters.pop();\n if (!first || !second) {\n throw new Error(\"LerpColorFilter requires two color filters\");\n }\n cf = ctx.Skia.ColorFilter.MakeLerp(t, first, second);\n } else if (isColorFilter(command, NodeType.LumaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeLumaColorFilter();\n } else if (isColorFilter(command, NodeType.LinearToSRGBGammaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeLinearToSRGBGamma();\n } else if (isColorFilter(command, NodeType.SRGBToLinearGammaColorFilter)) {\n cf = ctx.Skia.ColorFilter.MakeSRGBToLinearGamma();\n }\n if (!cf) {\n throw new Error(`Unknown color filter type: ${command.colorFilterType}`);\n }\n ctx.colorFilters.push(cf);\n};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,oBAAoB;AAM5C,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,WAAW,QAAQ,SAAS;AAIrC,OAAO,MAAMC,iBAAiB,GAC5BC,OAAgB,IACoC;EACpD,SAAS;;EACT,OAAOA,OAAO,CAACC,IAAI,KAAKH,WAAW,CAACI,eAAe;AACrD,CAAC;AAiBD,MAAMC,aAAa,GAAGA,CACpBH,OAA6C,EAC7CC,IAAO,KAC2B;EAClC,SAAS;;EACT,OAAOD,OAAO,CAACI,eAAe,KAAKH,IAAI;AACzC,CAAC;AAED,OAAO,MAAMI,mBAAmB,GAAIC,GAAmB,IAAK;EAC1D,SAAS;;EACT,IAAIA,GAAG,CAACC,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;IAC/B,MAAMC,KAAK,GAAGH,GAAG,CAACC,YAAY,CAACG,GAAG,CAAC,CAAE;IACrC,MAAMC,KAAK,GAAGL,GAAG,CAACC,YAAY,CAACG,GAAG,CAAC,CAAE;IACrCJ,GAAG,CAACC,YAAY,CAACK,IAAI,CAACN,GAAG,CAACO,IAAI,CAACC,WAAW,CAACC,WAAW,CAACN,KAAK,EAAEE,KAAK,CAAC,CAAC;EACvE;AACF,CAAC;AAED,OAAO,MAAMK,eAAe,GAAGA,CAC7BV,GAAmB,EACnBN,OAA6C,KAC1C;EACH,SAAS;;EACT,IAAIiB,EAA6B;EACjC,IAAId,aAAa,CAACH,OAAO,EAAEJ,QAAQ,CAACsB,gBAAgB,CAAC,EAAE;IACrD,MAAM;MAAEC;IAAM,CAAC,GAAGnB,OAAO;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,EAAEJ,QAAQ,CAACuC,4BAA4B,CAAC,EAAE;IACxElB,EAAE,GAAGX,GAAG,CAACO,IAAI,CAACC,WAAW,CAACsB,qBAAqB,CAAC,CAAC;EACnD,CAAC,MAAM,IAAIjC,aAAa,CAACH,OAAO,EAAEJ,QAAQ,CAACyC,4BAA4B,CAAC,EAAE;IACxEpB,EAAE,GAAGX,GAAG,CAACO,IAAI,CAACC,WAAW,CAACwB,qBAAqB,CAAC,CAAC;EACnD;EACA,IAAI,CAACrB,EAAE,EAAE;IACP,MAAM,IAAIc,KAAK,CAAC,8BAA8B/B,OAAO,CAACI,eAAe,EAAE,CAAC;EAC1E;EACAE,GAAG,CAACC,YAAY,CAACK,IAAI,CAACK,EAAE,CAAC;AAC3B,CAAC","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import type { AtlasProps, BoxProps, CircleProps, DiffRectProps, DrawingNodeProps, GlyphsProps, ImageProps, ImageSVGProps, LineProps, OvalProps, ParagraphProps, PatchProps, PathProps, PictureProps, PointsProps, RectProps, RoundedRectProps, TextBlobProps, TextPathProps, TextProps, VerticesProps } from "../../../dom/types";
2
+ import type { Node } from "../../Node";
3
+ import type { DrawingContext } from "../DrawingContext";
4
+ export declare const drawLine: (ctx: DrawingContext, props: LineProps) => void;
5
+ export declare const drawOval: (ctx: DrawingContext, props: OvalProps) => void;
6
+ export declare const drawBox: (ctx: DrawingContext, props: BoxProps, children: Node<any>[]) => void;
7
+ export declare const drawImage: (ctx: DrawingContext, props: ImageProps) => void;
8
+ export declare const drawPoints: (ctx: DrawingContext, props: PointsProps) => void;
9
+ export declare const drawVertices: (ctx: DrawingContext, props: VerticesProps) => void;
10
+ export declare const drawDiffRect: (ctx: DrawingContext, props: DiffRectProps) => void;
11
+ export declare const drawTextPath: (ctx: DrawingContext, props: TextPathProps) => void;
12
+ export declare const drawText: (ctx: DrawingContext, props: TextProps) => void;
13
+ export declare const drawPatch: (ctx: DrawingContext, props: PatchProps) => void;
14
+ export declare const drawPath: (ctx: DrawingContext, props: PathProps) => void;
15
+ export declare const drawRect: (ctx: DrawingContext, props: RectProps) => void;
16
+ export declare const drawRRect: (ctx: DrawingContext, props: RoundedRectProps) => void;
17
+ export declare const drawTextBlob: (ctx: DrawingContext, props: TextBlobProps) => void;
18
+ export declare const drawGlyphs: (ctx: DrawingContext, props: GlyphsProps) => void;
19
+ export declare const drawImageSVG: (ctx: DrawingContext, props: ImageSVGProps) => void;
20
+ export declare const drawParagraph: (ctx: DrawingContext, props: ParagraphProps) => void;
21
+ export declare const drawPicture: (ctx: DrawingContext, props: PictureProps) => void;
22
+ export declare const drawAtlas: (ctx: DrawingContext, props: AtlasProps) => void;
23
+ export declare const drawCircle: (ctx: DrawingContext, props: CircleProps) => void;
24
+ export declare const drawFill: (ctx: DrawingContext, _props: DrawingNodeProps) => void;
@@ -1,7 +1,7 @@
1
- import { deflate, enumKey, fitRects, inflate, NodeType, processCircle, processPath, processRect, processRRect } from "../../dom/nodes";
2
- import { saturate } from "../../renderer/processors";
3
- import { BlendMode, BlurStyle, ClipOp, FillType, isRRect, PointMode, VertexMode } from "../../skia/types";
4
- import { materialize } from "./utils";
1
+ import { deflate, enumKey, fitRects, inflate, NodeType, processCircle, processPath, processRect, processRRect } from "../../../dom/nodes";
2
+ import { saturate } from "../../../renderer/processors";
3
+ import { BlendMode, BlurStyle, ClipOp, FillType, isRRect, PointMode, VertexMode } from "../../../skia/types";
4
+ import { materialize } from "../../utils";
5
5
  export const drawLine = (ctx, props) => {
6
6
  "worklet";
7
7
 
@@ -368,4 +368,4 @@ export const drawFill = (ctx, _props) => {
368
368
 
369
369
  ctx.canvas.drawPaint(ctx.paint);
370
370
  };
371
- //# sourceMappingURL=drawings.js.map
371
+ //# sourceMappingURL=Drawing.js.map