@shopify/react-native-skia 2.0.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/android/CMakeLists.txt +20 -1
  2. package/cpp/api/JsiSkApi.h +3 -0
  3. package/cpp/api/JsiSkImageFilterFactory.h +478 -39
  4. package/cpp/api/JsiSkPath.h +2 -1
  5. package/cpp/api/JsiSkPathFactory.h +1 -1
  6. package/cpp/api/JsiSkSkottie.h +590 -0
  7. package/cpp/api/JsiSkottieFactory.h +65 -0
  8. package/cpp/api/recorder/Command.h +1 -0
  9. package/cpp/api/recorder/Convertor.h +16 -0
  10. package/cpp/api/recorder/Drawings.h +23 -0
  11. package/cpp/api/recorder/JsiRecorder.h +6 -0
  12. package/cpp/api/recorder/RNRecorder.h +9 -0
  13. package/cpp/api/third_party/SkottieUtils.cpp +333 -0
  14. package/cpp/api/third_party/SkottieUtils.h +172 -0
  15. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +980 -0
  16. package/cpp/skia/modules/jsonreader/SkJSONReader.h +389 -0
  17. package/cpp/skia/modules/skottie/include/ExternalLayer.h +56 -0
  18. package/cpp/skia/modules/skottie/include/Skottie.h +313 -0
  19. package/cpp/skia/modules/skottie/include/SkottieProperty.h +190 -0
  20. package/cpp/skia/modules/skottie/include/SlotManager.h +113 -0
  21. package/cpp/skia/modules/skottie/include/TextShaper.h +200 -0
  22. package/cpp/skia/modules/skottie/src/SkottieValue.h +56 -0
  23. package/cpp/skia/modules/skottie/src/animator/Animator.h +89 -0
  24. package/cpp/skia/modules/skottie/src/text/Font.h +82 -0
  25. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +155 -0
  26. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +121 -0
  27. package/cpp/skia/modules/skottie/src/text/TextValue.h +28 -0
  28. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
  29. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
  30. package/cpp/skia/modules/sksg/include/SkSGDraw.h +57 -0
  31. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
  32. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +181 -0
  33. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
  34. package/cpp/skia/modules/sksg/include/SkSGGradient.h +108 -0
  35. package/cpp/skia/modules/sksg/include/SkSGGroup.h +65 -0
  36. package/cpp/skia/modules/sksg/include/SkSGImage.h +59 -0
  37. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
  38. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
  39. package/cpp/skia/modules/sksg/include/SkSGMerge.h +74 -0
  40. package/cpp/skia/modules/sksg/include/SkSGNode.h +128 -0
  41. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
  42. package/cpp/skia/modules/sksg/include/SkSGPaint.h +112 -0
  43. package/cpp/skia/modules/sksg/include/SkSGPath.h +68 -0
  44. package/cpp/skia/modules/sksg/include/SkSGPlane.h +47 -0
  45. package/cpp/skia/modules/sksg/include/SkSGRect.h +122 -0
  46. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
  47. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
  48. package/cpp/skia/modules/sksg/include/SkSGScene.h +47 -0
  49. package/cpp/skia/modules/sksg/include/SkSGText.h +82 -0
  50. package/cpp/skia/modules/sksg/include/SkSGTransform.h +127 -0
  51. package/cpp/skia/src/base/SkArenaAlloc.h +371 -0
  52. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +15 -15
  53. package/lib/commonjs/dom/types/Drawings.d.ts +5 -1
  54. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  55. package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
  56. package/lib/commonjs/dom/types/NodeType.js +2 -0
  57. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  58. package/lib/commonjs/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  59. package/lib/commonjs/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  60. package/lib/commonjs/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  61. package/lib/commonjs/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  62. package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -0
  63. package/lib/commonjs/renderer/components/Skottie.d.ts +4 -0
  64. package/lib/commonjs/renderer/components/Skottie.js +13 -0
  65. package/lib/commonjs/renderer/components/Skottie.js.map +1 -0
  66. package/lib/commonjs/renderer/components/index.d.ts +1 -0
  67. package/lib/commonjs/renderer/components/index.js +11 -0
  68. package/lib/commonjs/renderer/components/index.js.map +1 -1
  69. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  70. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  71. package/lib/commonjs/skia/types/Matrix4.d.ts +11 -2
  72. package/lib/commonjs/skia/types/Matrix4.js +42 -1
  73. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  74. package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
  75. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  76. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  77. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  78. package/lib/commonjs/skia/types/Skottie.d.ts +223 -0
  79. package/lib/commonjs/skia/types/Skottie.js +73 -0
  80. package/lib/commonjs/skia/types/Skottie.js.map +1 -0
  81. package/lib/commonjs/skia/types/index.d.ts +1 -0
  82. package/lib/commonjs/skia/types/index.js +11 -0
  83. package/lib/commonjs/skia/types/index.js.map +1 -1
  84. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  85. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +88 -19
  86. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  87. package/lib/commonjs/skia/web/JsiSkia.js +2 -0
  88. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  89. package/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +59 -0
  90. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +243 -0
  91. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -0
  92. package/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +9 -0
  93. package/lib/commonjs/skia/web/JsiSkottieFactory.js +26 -0
  94. package/lib/commonjs/skia/web/JsiSkottieFactory.js.map +1 -0
  95. package/lib/commonjs/sksg/Elements.d.ts +2 -1
  96. package/lib/commonjs/sksg/Elements.js.map +1 -1
  97. package/lib/commonjs/sksg/Recorder/Core.d.ts +4 -2
  98. package/lib/commonjs/sksg/Recorder/Core.js +1 -0
  99. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  100. package/lib/commonjs/sksg/Recorder/Player.js +2 -0
  101. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  102. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  103. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
  104. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  105. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -1
  106. package/lib/commonjs/sksg/Recorder/Recorder.js +6 -0
  107. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  108. package/lib/commonjs/sksg/Recorder/Visitor.js +3 -0
  109. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  110. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +2 -2
  111. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
  112. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  113. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +1 -1
  114. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  115. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +15 -15
  116. package/lib/module/dom/types/Drawings.d.ts +5 -1
  117. package/lib/module/dom/types/Drawings.js.map +1 -1
  118. package/lib/module/dom/types/NodeType.d.ts +2 -1
  119. package/lib/module/dom/types/NodeType.js +2 -0
  120. package/lib/module/dom/types/NodeType.js.map +1 -1
  121. package/lib/module/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  122. package/lib/module/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  123. package/lib/module/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  124. package/lib/module/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  125. package/lib/module/renderer/__tests__/setup.d.ts +5 -0
  126. package/lib/module/renderer/components/Skottie.d.ts +4 -0
  127. package/lib/module/renderer/components/Skottie.js +5 -0
  128. package/lib/module/renderer/components/Skottie.js.map +1 -0
  129. package/lib/module/renderer/components/index.d.ts +1 -0
  130. package/lib/module/renderer/components/index.js +1 -0
  131. package/lib/module/renderer/components/index.js.map +1 -1
  132. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  133. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  134. package/lib/module/skia/types/Matrix4.d.ts +11 -2
  135. package/lib/module/skia/types/Matrix4.js +40 -0
  136. package/lib/module/skia/types/Matrix4.js.map +1 -1
  137. package/lib/module/skia/types/Recorder.d.ts +2 -1
  138. package/lib/module/skia/types/Recorder.js.map +1 -1
  139. package/lib/module/skia/types/Skia.d.ts +2 -0
  140. package/lib/module/skia/types/Skia.js.map +1 -1
  141. package/lib/module/skia/types/Skottie.d.ts +223 -0
  142. package/lib/module/skia/types/Skottie.js +74 -0
  143. package/lib/module/skia/types/Skottie.js.map +1 -0
  144. package/lib/module/skia/types/index.d.ts +1 -0
  145. package/lib/module/skia/types/index.js +1 -0
  146. package/lib/module/skia/types/index.js.map +1 -1
  147. package/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  148. package/lib/module/skia/web/JsiSkImageFilterFactory.js +88 -19
  149. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  150. package/lib/module/skia/web/JsiSkia.js +2 -0
  151. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkottieAnimation.d.ts +59 -0
  153. package/lib/module/skia/web/JsiSkottieAnimation.js +236 -0
  154. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -0
  155. package/lib/module/skia/web/JsiSkottieFactory.d.ts +9 -0
  156. package/lib/module/skia/web/JsiSkottieFactory.js +19 -0
  157. package/lib/module/skia/web/JsiSkottieFactory.js.map +1 -0
  158. package/lib/module/sksg/Elements.d.ts +2 -1
  159. package/lib/module/sksg/Elements.js.map +1 -1
  160. package/lib/module/sksg/Recorder/Core.d.ts +4 -2
  161. package/lib/module/sksg/Recorder/Core.js +1 -0
  162. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  163. package/lib/module/sksg/Recorder/Player.js +3 -1
  164. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  165. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  166. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
  167. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  168. package/lib/module/sksg/Recorder/Recorder.d.ts +2 -1
  169. package/lib/module/sksg/Recorder/Recorder.js +6 -0
  170. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  171. package/lib/module/sksg/Recorder/Visitor.js +3 -0
  172. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  173. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +2 -2
  174. package/lib/module/sksg/Recorder/commands/Drawing.js +9 -2
  175. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  176. package/lib/module/sksg/Recorder/commands/ImageFilters.js +1 -1
  177. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  178. package/lib/typescript/lib/commonjs/renderer/components/Skottie.d.ts +2 -0
  179. package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
  180. package/lib/typescript/lib/commonjs/skia/types/Skottie.d.ts +6 -0
  181. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  182. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  183. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +48 -0
  184. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +6 -0
  185. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  186. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  187. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -1
  188. package/lib/typescript/lib/module/mock/index.d.ts +7 -0
  189. package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
  190. package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -0
  191. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  192. package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
  193. package/lib/typescript/lib/module/skia/types/Skottie.d.ts +5 -0
  194. package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
  195. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  196. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  197. package/lib/typescript/lib/module/skia/web/JsiSkottieAnimation.d.ts +47 -0
  198. package/lib/typescript/lib/module/skia/web/JsiSkottieFactory.d.ts +5 -0
  199. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  200. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  201. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -1
  202. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +15 -15
  203. package/lib/typescript/src/dom/types/Drawings.d.ts +5 -1
  204. package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
  205. package/lib/typescript/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  206. package/lib/typescript/src/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  207. package/lib/typescript/src/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  208. package/lib/typescript/src/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  209. package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -0
  210. package/lib/typescript/src/renderer/components/Skottie.d.ts +4 -0
  211. package/lib/typescript/src/renderer/components/index.d.ts +1 -0
  212. package/lib/typescript/src/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  213. package/lib/typescript/src/skia/types/Matrix4.d.ts +11 -2
  214. package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
  215. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  216. package/lib/typescript/src/skia/types/Skottie.d.ts +223 -0
  217. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  218. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  219. package/lib/typescript/src/skia/web/JsiSkottieAnimation.d.ts +59 -0
  220. package/lib/typescript/src/skia/web/JsiSkottieFactory.d.ts +9 -0
  221. package/lib/typescript/src/sksg/Elements.d.ts +2 -1
  222. package/lib/typescript/src/sksg/Recorder/Core.d.ts +4 -2
  223. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  224. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -1
  225. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +2 -2
  226. package/libs/android/arm64-v8a/libjsonreader.a +0 -0
  227. package/libs/android/armeabi-v7a/libjsonreader.a +0 -0
  228. package/libs/android/x86/libjsonreader.a +0 -0
  229. package/libs/android/x86_64/libjsonreader.a +0 -0
  230. package/libs/apple/libpathops.xcframework/Info.plist +9 -9
  231. package/libs/apple/libskia.xcframework/Info.plist +14 -14
  232. package/libs/apple/libskottie.xcframework/Info.plist +13 -13
  233. package/libs/apple/libskparagraph.xcframework/Info.plist +15 -15
  234. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  235. package/libs/apple/libskshaper.xcframework/Info.plist +15 -15
  236. package/libs/apple/libskunicode_core.xcframework/Info.plist +9 -9
  237. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
  238. package/libs/apple/libsvg.xcframework/Info.plist +15 -15
  239. package/package.json +1 -1
  240. package/react-native-skia.podspec +4 -2
  241. package/src/__tests__/snapshots/matrix4/camera-corner.png +0 -0
  242. package/src/__tests__/snapshots/matrix4/camera-offset.png +0 -0
  243. package/src/__tests__/snapshots/matrix4/camera-top-left-center.png +0 -0
  244. package/src/__tests__/snapshots/matrix4/camera-zoom-out.png +0 -0
  245. package/src/__tests__/snapshots/matrix4/full-rect.png +0 -0
  246. package/src/__tests__/snapshots/matrix4/rect.png +0 -0
  247. package/src/__tests__/snapshots/matrix4/scaled-rect.png +0 -0
  248. package/src/__tests__/snapshots/matrix4/test-perspective.png +0 -0
  249. package/src/__tests__/snapshots/matrix4/test-perspective2.png +0 -0
  250. package/src/dom/types/Drawings.ts +6 -0
  251. package/src/dom/types/NodeType.ts +2 -0
  252. package/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.tsx +492 -0
  253. package/src/renderer/__tests__/e2e/Camera.spec.tsx +475 -0
  254. package/src/renderer/__tests__/e2e/LightingImageFilters.spec.tsx +1478 -0
  255. package/src/renderer/__tests__/e2e/Skottie.spec.tsx +440 -0
  256. package/src/renderer/__tests__/e2e/setup/skottie/basic_slots.json +1118 -0
  257. package/src/renderer/__tests__/e2e/setup/skottie/color-props.json +1 -0
  258. package/src/renderer/__tests__/e2e/setup/skottie/confetti.json +5899 -0
  259. package/src/renderer/__tests__/e2e/setup/skottie/drinks.json +43857 -0
  260. package/src/renderer/__tests__/e2e/setup/skottie/fingerprint.json +1 -0
  261. package/src/renderer/__tests__/e2e/setup/skottie/lego_loader.json +29540 -0
  262. package/src/renderer/__tests__/e2e/setup/skottie/new-drop.json +1 -0
  263. package/src/renderer/__tests__/e2e/setup/skottie/onboarding.json +1 -0
  264. package/src/renderer/__tests__/e2e/setup/skottie/text-layer.json +1 -0
  265. package/src/renderer/__tests__/setup.tsx +23 -0
  266. package/src/renderer/components/Skottie.tsx +8 -0
  267. package/src/renderer/components/index.ts +1 -0
  268. package/src/skia/__tests__/assets/Avenir-Heavy.ttf +0 -0
  269. package/src/skia/types/ImageFilter/ImageFilterFactory.ts +391 -21
  270. package/src/skia/types/Matrix4.ts +108 -2
  271. package/src/skia/types/Recorder.ts +2 -0
  272. package/src/skia/types/Skia.ts +2 -0
  273. package/src/skia/types/Skottie.ts +266 -0
  274. package/src/skia/types/index.ts +1 -0
  275. package/src/skia/web/JsiSkImageFilterFactory.ts +266 -31
  276. package/src/skia/web/JsiSkia.ts +2 -0
  277. package/src/skia/web/JsiSkottieAnimation.ts +259 -0
  278. package/src/skia/web/JsiSkottieFactory.ts +25 -0
  279. package/src/sksg/Elements.tsx +2 -0
  280. package/src/sksg/Recorder/Core.ts +3 -0
  281. package/src/sksg/Recorder/Player.ts +3 -0
  282. package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -0
  283. package/src/sksg/Recorder/Recorder.ts +5 -0
  284. package/src/sksg/Recorder/Visitor.ts +3 -0
  285. package/src/sksg/Recorder/commands/Drawing.ts +7 -3
  286. package/src/sksg/Recorder/commands/ImageFilters.ts +1 -1
  287. package/cpp/skia/include/pathops/SkPathOps.h +0 -17
@@ -1,7 +1,7 @@
1
1
  type Point = { x: number; y: number };
2
2
  type Vec2 = readonly [number, number];
3
- type Vec3 = readonly [number, number, number];
4
- type Vec4 = readonly [number, number, number, number];
3
+ export type Vec3 = readonly [number, number, number];
4
+ export type Vec4 = readonly [number, number, number, number];
5
5
 
6
6
  export type Matrix3 = readonly [
7
7
  number,
@@ -471,3 +471,109 @@ export const invert4 = (m: Matrix4): Matrix4 => {
471
471
  b33 * invDet,
472
472
  ] as Matrix4;
473
473
  };
474
+
475
+ const vecSub = (a: Vec3, b: Vec3): Vec3 => {
476
+ "worklet";
477
+ return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
478
+ };
479
+
480
+ const vecCross = (a: Vec3, b: Vec3): Vec3 => {
481
+ "worklet";
482
+ return [
483
+ a[1] * b[2] - a[2] * b[1],
484
+ a[2] * b[0] - a[0] * b[2],
485
+ a[0] * b[1] - a[1] * b[0],
486
+ ];
487
+ };
488
+
489
+ const lookat = (eyeVec: Vec3, centerVec: Vec3, upVec: Vec3): Matrix4 => {
490
+ "worklet";
491
+ const f = normalizeVec(vecSub(centerVec, eyeVec));
492
+ const u = normalizeVec(upVec);
493
+ const s = normalizeVec(vecCross(f, u));
494
+ const uf = vecCross(s, f);
495
+
496
+ // Build the look-at matrix directly
497
+ const m: Matrix4 = [
498
+ s[0],
499
+ uf[0],
500
+ -f[0],
501
+ eyeVec[0],
502
+ s[1],
503
+ uf[1],
504
+ -f[1],
505
+ eyeVec[1],
506
+ s[2],
507
+ uf[2],
508
+ -f[2],
509
+ eyeVec[2],
510
+ 0,
511
+ 0,
512
+ 0,
513
+ 1,
514
+ ];
515
+
516
+ return invert4(m);
517
+ };
518
+
519
+ const perspectiveMatrix = (
520
+ near: number,
521
+ far: number,
522
+ angle: number
523
+ ): Matrix4 => {
524
+ "worklet";
525
+ const dInv = 1 / (far - near);
526
+ const halfAngle = angle / 2;
527
+ const cot = Math.cos(halfAngle) / Math.sin(halfAngle);
528
+ return [
529
+ cot,
530
+ 0,
531
+ 0,
532
+ 0,
533
+ 0,
534
+ cot,
535
+ 0,
536
+ 0,
537
+ 0,
538
+ 0,
539
+ (far + near) * dInv,
540
+ 2 * far * near * dInv,
541
+ 0,
542
+ 0,
543
+ -1,
544
+ 1,
545
+ ];
546
+ };
547
+
548
+ export interface CameraConfig {
549
+ eye: Vec3;
550
+ coa: Vec3;
551
+ up: Vec3;
552
+ near: number;
553
+ far: number;
554
+ angle: number;
555
+ }
556
+
557
+ export const setupCamera = (
558
+ area: Vec4,
559
+ zscale: number,
560
+ cam: CameraConfig
561
+ ): Matrix4 => {
562
+ "worklet";
563
+ const camera = lookat(cam.eye, cam.coa, cam.up);
564
+ const p = perspectiveMatrix(cam.near, cam.far, cam.angle);
565
+ const center: Vec3 = [(area[0] + area[2]) / 2, (area[1] + area[3]) / 2, 0];
566
+ const viewScale: Vec3 = [
567
+ (area[2] - area[0]) / 2,
568
+ (area[3] - area[1]) / 2,
569
+ zscale,
570
+ ];
571
+ const viewport = multiply4(
572
+ translate(center[0], center[1], center[2]),
573
+ scale(viewScale[0], viewScale[1], viewScale[2])
574
+ );
575
+ return multiply4(
576
+ multiply4(viewport, p),
577
+ multiply4(camera, invert4(viewport))
578
+ );
579
+ };
@@ -26,6 +26,7 @@ import type {
26
26
  TextBlobProps,
27
27
  TextPathProps,
28
28
  VerticesProps,
29
+ SkottieProps,
29
30
  } from "../../dom/types";
30
31
  import type { AnimatedProps } from "../../renderer/processors/Animations/Animations";
31
32
 
@@ -82,6 +83,7 @@ export interface BaseRecorder {
82
83
  drawPicture(props: AnimatedProps<PictureProps>): void;
83
84
  drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;
84
85
  drawParagraph(props: AnimatedProps<ParagraphProps>): void;
86
+ drawSkottie(props: AnimatedProps<SkottieProps>): void;
85
87
  drawAtlas(props: AnimatedProps<AtlasProps>): void;
86
88
  }
87
89
 
@@ -33,6 +33,7 @@ import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
33
33
  import type { Video } from "./Video";
34
34
  import type { NativeBufferFactory } from "./NativeBuffer";
35
35
  import type { JsiRecorder } from "./Recorder";
36
+ import type { SkottieFactory } from "./Skottie";
36
37
 
37
38
  export interface SkiaContext {
38
39
  getSurface(): SkSurface;
@@ -102,6 +103,7 @@ export interface Skia {
102
103
  TextBlob: TextBlobFactory;
103
104
  Surface: SurfaceFactory;
104
105
  ParagraphBuilder: ParagraphBuilderFactory;
106
+ Skottie: SkottieFactory;
105
107
  Video: (url: string) => Promise<Video> | Video;
106
108
  Context(surface: bigint, width: number, height: number): SkiaContext;
107
109
  NativeBuffer: NativeBufferFactory;
@@ -0,0 +1,266 @@
1
+ import type { SkCanvas } from "./Canvas";
2
+ import type { SkColor } from "./Color";
3
+ import type { SkData } from "./Data";
4
+ import type { SkJSIInstance } from "./JsiInstance";
5
+ import type { StrokeJoin } from "./Paint";
6
+ import type { TextAlign, TextDirection } from "./Paragraph";
7
+ import type { SkPoint } from "./Point";
8
+ import type { SkRect } from "./Rect";
9
+ import type { SkSize } from "./Size";
10
+ import type { SkTypeface } from "./Typeface";
11
+
12
+ export enum LineBreakType {
13
+ SoftLineBreak,
14
+ HardtLineBreak,
15
+ }
16
+
17
+ export enum VerticalTextAlign {
18
+ Top,
19
+ TopBaseline,
20
+ // Skottie vertical alignment extensions
21
+ // Visual alignement modes -- these are using tight visual bounds for the paragraph.
22
+ VisualTop, // visual top -> text box top
23
+ VisualCenter, // visual center -> text box center
24
+ VisualBottom, // visual bottom -> text box bottom
25
+ }
26
+
27
+ export enum ResizePolicy {
28
+ // Use the specified text size.
29
+ None,
30
+ // Resize the text such that the extent box fits (snuggly) in the text box,
31
+ // both horizontally and vertically.
32
+ ScaleToFit,
33
+ // Same kScaleToFit if the text doesn't fit at the specified font size.
34
+ // Otherwise, same as kNone.
35
+ DownscaleToFit,
36
+ }
37
+
38
+ export enum InputState {
39
+ Down,
40
+ Up,
41
+ Move,
42
+ Right,
43
+ Left,
44
+ }
45
+
46
+ export enum ModifierKey {
47
+ None,
48
+ Shift,
49
+ Control,
50
+ Option,
51
+ Command,
52
+ FirstPress,
53
+ }
54
+
55
+ export interface AnimationMarker {
56
+ name: string;
57
+ t0: number; // 0.0 to 1.0
58
+ t1: number; // 0.0 to 1.0
59
+ }
60
+
61
+ export interface ColorProperty {
62
+ /**
63
+ * Property identifier, usually the node name.
64
+ */
65
+ key: string;
66
+ /**
67
+ * Property value (RGBA, 255-based).
68
+ */
69
+ value: SkColor;
70
+ }
71
+
72
+ /**
73
+ * Named opacity property.
74
+ */
75
+ export interface OpacityProperty {
76
+ /**
77
+ * Property identifier, usually the node name.
78
+ */
79
+ key: string;
80
+ /**
81
+ * Property value (0..100).
82
+ */
83
+ value: number;
84
+ }
85
+
86
+ /**
87
+ * Text property value.
88
+ */
89
+ export interface TextValue {
90
+ /**
91
+ * The text string payload.
92
+ */
93
+ text: string;
94
+ /**
95
+ * Font size.
96
+ */
97
+ size: number;
98
+ }
99
+
100
+ /**
101
+ * Named text property.
102
+ */
103
+ export interface TextProperty {
104
+ /**
105
+ * Property identifier, usually the node name.
106
+ */
107
+ key: string;
108
+ /**
109
+ * Property value.
110
+ */
111
+ value: TextValue;
112
+ }
113
+
114
+ /**
115
+ * Transform property value. Maps to AE styled transform.
116
+ */
117
+ export interface TransformValue {
118
+ /**
119
+ * Anchor point for transform. x and y value.
120
+ */
121
+ anchor: SkPoint;
122
+ /**
123
+ * Position of transform. x and y value.
124
+ */
125
+ position: SkPoint;
126
+ /**
127
+ * Scale of transform. x and y value.
128
+ */
129
+ scale: SkPoint;
130
+ /**
131
+ * Rotation of transform in degrees.
132
+ */
133
+ rotation: number;
134
+ /**
135
+ * Skew to apply during transform.
136
+ */
137
+ skew: number;
138
+ /**
139
+ * Direction of skew in degrees.
140
+ */
141
+ skewAxis: number;
142
+ }
143
+
144
+ /**
145
+ * Named transform property for Skottie property observer.
146
+ */
147
+ export interface TransformProperty {
148
+ /**
149
+ * Property identifier, usually the node name.
150
+ */
151
+ key: string;
152
+ /**
153
+ * Property value.
154
+ */
155
+ value: TransformValue;
156
+ }
157
+
158
+ /**
159
+ * Collection of slot IDs sorted by value type
160
+ */
161
+ export interface SlotInfo {
162
+ colorSlotIDs: string[];
163
+ scalarSlotIDs: string[];
164
+ vec2SlotIDs: string[];
165
+ imageSlotIDs: string[];
166
+ textSlotIDs: string[];
167
+ }
168
+
169
+ /**
170
+ * Text property for ManagedAnimation's slot support
171
+ */
172
+ export interface SlottableTextProperty {
173
+ typeface?: SkTypeface;
174
+ text?: string;
175
+ textSize?: number;
176
+
177
+ minTextSize?: number;
178
+ maxTextSize?: number;
179
+ strokeWidth?: number;
180
+ lineHeight?: number;
181
+ lineShift?: number;
182
+ ascent?: number;
183
+ maxLines?: number;
184
+
185
+ horizAlign?: TextAlign;
186
+ vertAlign?: VerticalTextAlign;
187
+ strokeJoin?: StrokeJoin;
188
+ direction?: TextDirection;
189
+ linebreak?: LineBreakType;
190
+ resize?: ResizePolicy;
191
+
192
+ boundingBox?: SkRect;
193
+ fillColor?: SkColor;
194
+ strokeColor?: SkColor;
195
+ }
196
+
197
+ export interface SkSkottieAnimation extends SkJSIInstance<"SkottieAnimation"> {
198
+ /**
199
+ * Returns the animation duration in seconds.
200
+ */
201
+ duration(): number;
202
+ /**
203
+ * Returns the animation frame rate (frames / second).
204
+ */
205
+ fps(): number;
206
+
207
+ /**
208
+ * Draws current animation frame. Must call seek or seekFrame first.
209
+ * @param canvas
210
+ * @param dstRect
211
+ */
212
+ render(canvas: SkCanvas, dstRect?: SkRect): void;
213
+
214
+ /**
215
+ * Update the animation state to match |t|, specified as a frame index
216
+ * i.e. relative to duration() * fps().
217
+ *
218
+ * Returns the rectangle that was affected by this animation.
219
+ *
220
+ * @param frame - Fractional values are allowed and meaningful - e.g.
221
+ * 0.0 -> first frame
222
+ * 1.0 -> second frame
223
+ * 0.5 -> halfway between first and second frame
224
+ * @param damageRect - will copy damage frame into this if provided.
225
+ */
226
+ seekFrame(frame: number, damageRect?: SkRect): void;
227
+
228
+ size(): SkSize;
229
+
230
+ version(): string;
231
+
232
+ getSlotInfo(): SlotInfo;
233
+
234
+ setColorSlot(key: string, color: SkColor): boolean;
235
+ setScalarSlot(key: string, scalar: number): boolean;
236
+ setVec2Slot(key: string, vec2: SkPoint): boolean;
237
+ setTextSlot(key: string, text: SlottableTextProperty): boolean;
238
+ setImageSlot(key: string, assetName: string): boolean;
239
+
240
+ getColorSlot(key: string): SkColor | null;
241
+ getScalarSlot(key: string): number | null;
242
+ getVec2Slot(key: string): SkPoint | null;
243
+ getTextSlot(key: string): SlottableTextProperty | null;
244
+
245
+ getColorProps(): ColorProperty[];
246
+ getTextProps(): TextProperty[];
247
+ getOpacityProps(): OpacityProperty[];
248
+ getTransformProps(): TransformProperty[];
249
+
250
+ setColor(key: string, color: SkColor): boolean;
251
+ setText(key: string, text: string, size: number): boolean;
252
+ setOpacity(key: string, opacity: number): boolean;
253
+ setTransform(
254
+ key: string,
255
+ anchor: SkPoint,
256
+ position: SkPoint,
257
+ scale: SkPoint,
258
+ rotation: number,
259
+ skew: number,
260
+ skewAxis: number
261
+ ): boolean;
262
+ }
263
+
264
+ export interface SkottieFactory {
265
+ Make(json: string, assets?: Record<string, SkData>): SkSkottieAnimation;
266
+ }
@@ -32,3 +32,4 @@ export * from "./Matrix4";
32
32
  export * from "./NativeBuffer";
33
33
  export * from "./Recorder";
34
34
  export * from "./Video";
35
+ export * from "./Skottie";