react-native-skia 3.0.1 → 3.0.3

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 (269) hide show
  1. package/Package.swift +14 -13
  2. package/README.md +19 -2
  3. package/android/CMakeLists.txt +13 -42
  4. package/android/build.gradle +54 -63
  5. package/android/cpp/jni/JniLoad.cpp +2 -4
  6. package/android/cpp/jni/include/JniSkiaView.h +123 -0
  7. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
  8. package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
  10. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
  11. package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
  12. package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
  13. package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
  14. package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
  15. package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
  16. package/apple/MetalLayerColorSpace.mm +10 -12
  17. package/apple/RNSkApplePlatformContext.h +12 -14
  18. package/apple/RNSkApplePlatformContext.mm +19 -112
  19. package/apple/RNSkMetalCanvasProvider.h +14 -19
  20. package/apple/RNSkMetalCanvasProvider.mm +39 -70
  21. package/apple/RNSkiaModule.mm +10 -0
  22. package/apple/SkiaView.h +20 -0
  23. package/apple/SkiaView.mm +210 -0
  24. package/cpp/api/JsiSkApi.h +2 -13
  25. package/cpp/api/JsiSkCanvas.h +4 -18
  26. package/cpp/api/JsiSkGraphiteContext.h +1 -5
  27. package/cpp/api/JsiSkGraphiteRecording.h +1 -5
  28. package/cpp/api/JsiSkImage.h +7 -41
  29. package/cpp/api/JsiSkImageFactory.h +0 -14
  30. package/cpp/api/JsiSkSurface.h +2 -16
  31. package/cpp/api/JsiSkSurfaceFactory.h +0 -8
  32. package/cpp/rnskia/RNDawnContext.h +3 -2
  33. package/cpp/rnskia/RNDawnInterop.cpp +0 -4
  34. package/cpp/rnskia/RNDawnUtils.h +12 -1
  35. package/cpp/rnskia/RNDawnWindowContext.cpp +12 -1
  36. package/cpp/rnskia/RNDawnWindowContext.h +19 -7
  37. package/cpp/rnskia/RNMetalLayerColorSpace.h +4 -2
  38. package/cpp/rnskia/RNSkCanvasProvider.h +231 -0
  39. package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
  40. package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
  41. package/cpp/rnskia/RNSkGraphiteTarget.h +396 -0
  42. package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
  43. package/cpp/rnskia/RNSkPlatformContext.h +17 -15
  44. package/cpp/rnskia/RNSkView.h +362 -246
  45. package/jestSetup.js +1 -3
  46. package/lib/commonjs/Platform/Platform.web.js +1 -1
  47. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  48. package/lib/commonjs/external/reanimated/interpolators.js +1 -1
  49. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  50. package/lib/commonjs/index.d.ts +1 -3
  51. package/lib/commonjs/index.js +3 -12
  52. package/lib/commonjs/index.js.map +1 -1
  53. package/lib/commonjs/mock/index.js +0 -1
  54. package/lib/commonjs/mock/index.js.map +1 -1
  55. package/lib/commonjs/renderer/Canvas.d.ts +15 -12
  56. package/lib/commonjs/renderer/Canvas.js +25 -21
  57. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  58. package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
  59. package/lib/commonjs/skia/types/Graphite.js.map +1 -1
  60. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
  61. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  62. package/lib/commonjs/skia/types/Skia.d.ts +1 -2
  63. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  64. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  65. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  66. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
  67. package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
  68. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  69. package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
  70. package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  71. package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
  72. package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  73. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
  74. package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
  75. package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
  76. package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
  77. package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
  78. package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
  79. package/lib/commonjs/views/SkiaPictureView.js +12 -10
  80. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  81. package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
  82. package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
  83. package/lib/commonjs/views/SkiaView.web.js.map +1 -0
  84. package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
  85. package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
  86. package/lib/commonjs/views/android.d.ts +6 -0
  87. package/lib/commonjs/views/android.js +17 -0
  88. package/lib/commonjs/views/android.js.map +1 -0
  89. package/lib/commonjs/views/types.d.ts +3 -12
  90. package/lib/commonjs/views/types.js.map +1 -1
  91. package/lib/module/Platform/Platform.web.js +1 -1
  92. package/lib/module/Platform/Platform.web.js.map +1 -1
  93. package/lib/module/external/reanimated/interpolators.js +1 -1
  94. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  95. package/lib/module/index.d.ts +1 -3
  96. package/lib/module/index.js +1 -3
  97. package/lib/module/index.js.map +1 -1
  98. package/lib/module/mock/index.js +0 -1
  99. package/lib/module/mock/index.js.map +1 -1
  100. package/lib/module/renderer/Canvas.d.ts +15 -12
  101. package/lib/module/renderer/Canvas.js +25 -20
  102. package/lib/module/renderer/Canvas.js.map +1 -1
  103. package/lib/module/skia/types/Graphite.d.ts +3 -3
  104. package/lib/module/skia/types/Graphite.js.map +1 -1
  105. package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
  106. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  107. package/lib/module/skia/types/Skia.d.ts +1 -2
  108. package/lib/module/skia/types/Skia.js.map +1 -1
  109. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  110. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  111. package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
  112. package/lib/module/specs/NativeSkiaModule.web.js +5 -9
  113. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  114. package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
  115. package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
  116. package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
  117. package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  118. package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
  119. package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
  120. package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
  121. package/lib/module/views/SkiaGraphiteView.js +23 -12
  122. package/lib/module/views/SkiaGraphiteView.js.map +1 -1
  123. package/lib/module/views/SkiaPictureView.d.ts +4 -1
  124. package/lib/module/views/SkiaPictureView.js +12 -10
  125. package/lib/module/views/SkiaPictureView.js.map +1 -1
  126. package/lib/module/views/SkiaView.web.d.ts +12 -0
  127. package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
  128. package/lib/module/views/SkiaView.web.js.map +1 -0
  129. package/lib/module/views/SkiaWebRenderer.js +1 -1
  130. package/lib/module/views/SkiaWebRenderer.js.map +1 -1
  131. package/lib/module/views/android.d.ts +6 -0
  132. package/lib/module/views/android.js +10 -0
  133. package/lib/module/views/android.js.map +1 -0
  134. package/lib/module/views/types.d.ts +3 -12
  135. package/lib/module/views/types.js.map +1 -1
  136. package/lib/typescript/src/index.d.ts +1 -3
  137. package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
  138. package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
  139. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
  140. package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
  141. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
  142. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
  143. package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
  144. package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
  145. package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
  146. package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
  147. package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
  148. package/lib/typescript/src/views/android.d.ts +6 -0
  149. package/lib/typescript/src/views/types.d.ts +3 -12
  150. package/package.json +5 -13
  151. package/react-native-skia.podspec +34 -58
  152. package/src/Platform/Platform.web.tsx +1 -1
  153. package/src/external/reanimated/interpolators.ts +1 -1
  154. package/src/index.ts +1 -3
  155. package/src/mock/index.ts +0 -1
  156. package/src/renderer/Canvas.tsx +24 -28
  157. package/src/skia/types/Graphite.ts +3 -3
  158. package/src/skia/types/Image/ImageFactory.ts +2 -2
  159. package/src/skia/types/Skia.ts +1 -2
  160. package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
  161. package/src/specs/NativeSkiaModule.web.ts +9 -21
  162. package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
  163. package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
  164. package/src/views/SkiaGraphiteView.tsx +27 -16
  165. package/src/views/SkiaPictureView.tsx +11 -10
  166. package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
  167. package/src/views/SkiaWebRenderer.ts +1 -1
  168. package/src/views/android.ts +16 -0
  169. package/src/views/types.ts +3 -14
  170. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
  171. package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
  172. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
  173. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
  174. package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
  175. package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
  176. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
  177. package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
  178. package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
  179. package/android/cpp/rnskia-android/gl/Context.h +0 -80
  180. package/android/cpp/rnskia-android/gl/Display.h +0 -123
  181. package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
  182. package/android/cpp/rnskia-android/gl/Error.h +0 -8
  183. package/android/cpp/rnskia-android/gl/Surface.h +0 -43
  184. package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
  185. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
  186. package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
  187. package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
  188. package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
  189. package/apple/MetalContext.h +0 -116
  190. package/apple/MetalContext.mm +0 -38
  191. package/apple/MetalWindowContext.h +0 -42
  192. package/apple/MetalWindowContext.mm +0 -95
  193. package/apple/RNSkAppleView.h +0 -49
  194. package/apple/RNSkAppleView.mm +0 -35
  195. package/apple/SkiaCVPixelBufferUtils.h +0 -122
  196. package/apple/SkiaCVPixelBufferUtils.mm +0 -535
  197. package/apple/SkiaGraphiteView.h +0 -26
  198. package/apple/SkiaGraphiteView.mm +0 -180
  199. package/apple/SkiaPictureView.h +0 -7
  200. package/apple/SkiaPictureView.mm +0 -70
  201. package/apple/SkiaUIView.h +0 -31
  202. package/apple/SkiaUIView.mm +0 -164
  203. package/cpp/rnskia/RNSkGraphiteView.h +0 -708
  204. package/cpp/rnskia/RNSkPictureView.cpp +0 -69
  205. package/cpp/rnskia/RNSkPictureView.h +0 -211
  206. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
  207. package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
  208. package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
  209. package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
  210. package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
  211. package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
  212. package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
  213. package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
  214. package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
  215. package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
  216. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  217. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
  218. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  219. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  220. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
  221. package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  222. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  223. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  224. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
  225. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  226. package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
  227. package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
  228. package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
  229. package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
  230. package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
  231. package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
  232. package/lib/module/renderer/DefaultCanvas.js +0 -34
  233. package/lib/module/renderer/DefaultCanvas.js.map +0 -1
  234. package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
  235. package/lib/module/renderer/GraphiteCanvas.js +0 -57
  236. package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
  237. package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
  238. package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
  239. package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
  240. package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  241. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
  242. package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
  243. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  244. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
  245. package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
  246. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
  247. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  248. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
  249. package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
  250. package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
  251. package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
  252. package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
  253. package/lib/module/views/SkiaPictureView.web.js +0 -156
  254. package/lib/module/views/SkiaPictureView.web.js.map +0 -1
  255. package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
  256. package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
  257. package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
  258. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
  259. package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
  260. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
  261. package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
  262. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
  263. package/libs/.graphite +0 -1
  264. package/src/renderer/DefaultCanvas.tsx +0 -41
  265. package/src/renderer/GraphiteCanvas.tsx +0 -61
  266. package/src/renderer/GraphiteCanvas.web.tsx +0 -3
  267. package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
  268. package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
  269. package/src/views/SkiaPictureView.web.tsx +0 -224
@@ -1 +1 @@
1
- {"version":3,"names":["hasPicture","view","hasContext","global","SkiaViewApi","views","deferedPictures","unregisteredViews","Set","deferedOnSize","web","registerView","nativeId","delete","setPicture","unregisterView","add","setJsiProperty","name","value","id","has","size","getSize","width","height","requestRedraw","_this$views","redraw","applyUpdates","makeImageSnapshot","rect","Error","makeGraphiteContext","getContext","makeImageSnapshotAsync","Promise","resolve","reject","result"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n} from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\n\n/** What every web view registers under its native id. */\nexport interface SkiaWebViewHandle {\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaGraphiteViewHandle extends SkiaWebViewHandle {\n getContext(): SkGraphiteContext;\n}\n\ninterface PictureHandle extends SkiaWebViewHandle {\n setPicture(picture: SkPicture): void;\n}\n\nconst hasPicture = (view: SkiaWebViewHandle): view is PictureHandle =>\n \"setPicture\" in view;\n\nconst hasContext = (view: SkiaWebViewHandle): view is SkiaGraphiteViewHandle =>\n \"getContext\" in view;\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaWebViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n unregisteredViews: Set<string>;\n registerView(nativeId: string, view: SkiaWebViewHandle): void;\n unregisterView(nativeId: string): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n unregisteredViews: new Set<string>(),\n deferedOnSize: {},\n web: true,\n registerView(nativeId: string, view: SkiaWebViewHandle) {\n this.unregisteredViews.delete(nativeId);\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId] && hasPicture(view)) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n delete this.deferedPictures[nativeId];\n }\n this.views[nativeId] = view;\n },\n unregisterView(nativeId: string) {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n this.unregisteredViews.add(nativeId);\n delete this.views[nativeId];\n delete this.deferedPictures[nativeId];\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n const id = `${nativeId}`;\n const view = this.views[id];\n if (view) {\n if (hasPicture(view)) {\n view.setPicture(value);\n }\n } else if (!this.unregisteredViews.has(id)) {\n this.deferedPictures[id] = value;\n }\n // Otherwise the view has unmounted (e.g. a trailing animation frame):\n // drop the picture instead of deferring it for an id that will never\n // register again, which would retain it forever.\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n // The view may already have unmounted (e.g. a trailing animation frame).\n this.views[`${nativeId}`]?.redraw();\n },\n applyUpdates() {\n // Web canvases are driven from JS (see Container.web.ts); there is no\n // view-owned recorder to update.\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n );\n }\n return view.makeImageSnapshot(rect);\n },\n makeGraphiteContext(nativeId: number) {\n const view = this.views[`${nativeId}`];\n if (!view || !hasContext(view)) {\n throw new Error(\n `Cannot make a Graphite context: no SkiaGraphiteView with nativeID ${nativeId} is mounted`\n );\n }\n return view.getContext();\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const view = this.views[`${nativeId}`];\n if (!view) {\n reject(\n new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n )\n );\n return;\n }\n const result = view.makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":"AAAA;;AASA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,qEAAqEpB,QAAQ,aAC/E,CAAC;IACH;IACA,OAAOX,IAAI,CAACiC,UAAU,CAAC,CAAC;EAC1B,CAAC;EACDC,sBAAsBA,CAACvB,QAAgB,EAAEmB,IAAa,EAAE;IACtD,OAAO,IAAIK,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMrC,IAAI,GAAG,IAAI,CAACI,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;MACtC,IAAI,CAACX,IAAI,EAAE;QACTqC,MAAM,CACJ,IAAIN,KAAK,CACP,kDAAkDpB,QAAQ,4CAC5D,CACF,CAAC;QACD;MACF;MACA,MAAM2B,MAAM,GAAGtC,IAAI,CAAC6B,iBAAiB,CAACC,IAAI,CAAC;MAC3C,IAAIQ,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIN,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AACA,eAAe,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["global","SkiaViewApi","views","deferedPictures","unregisteredViews","Set","deferedOnSize","web","registerView","nativeId","view","delete","setPicture","unregisterView","add","setJsiProperty","name","value","id","has","size","getSize","width","height","requestRedraw","_this$views","redraw","applyUpdates","makeImageSnapshot","rect","Error","makeGraphiteContext","getContext","makeImageSnapshotAsync","Promise","resolve","reject","result"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type {\n SkGraphiteContext,\n SkImage,\n SkPicture,\n SkRect,\n} from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\n\n/** What the web view registers under its native id. */\nexport interface SkiaWebViewHandle {\n /** Shows a picture: the frame of a <Canvas> or a <SkiaPictureView>. */\n setPicture(picture: SkPicture): void;\n /** The recording side of the view, see SkiaGraphiteView. */\n getContext(): SkGraphiteContext;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaWebViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n unregisteredViews: Set<string>;\n registerView(nativeId: string, view: SkiaWebViewHandle): void;\n unregisterView(nativeId: string): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n unregisteredViews: new Set<string>(),\n deferedOnSize: {},\n web: true,\n registerView(nativeId: string, view: SkiaWebViewHandle) {\n this.unregisteredViews.delete(nativeId);\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n delete this.deferedPictures[nativeId];\n }\n this.views[nativeId] = view;\n },\n unregisterView(nativeId: string) {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n this.unregisteredViews.add(nativeId);\n delete this.views[nativeId];\n delete this.deferedPictures[nativeId];\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n const id = `${nativeId}`;\n const view = this.views[id];\n if (view) {\n view.setPicture(value);\n } else if (!this.unregisteredViews.has(id)) {\n this.deferedPictures[id] = value;\n }\n // Otherwise the view has unmounted (e.g. a trailing animation frame):\n // drop the picture instead of deferring it for an id that will never\n // register again, which would retain it forever.\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n // The view may already have unmounted (e.g. a trailing animation frame).\n this.views[`${nativeId}`]?.redraw();\n },\n applyUpdates() {\n // Web canvases are driven from JS (see Container.web.ts); there is no\n // view-owned recorder to update.\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n );\n }\n return view.makeImageSnapshot(rect);\n },\n makeGraphiteContext(nativeId: number) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make a Graphite context: no view with nativeID ${nativeId} is mounted`\n );\n }\n return view.getContext();\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const view = this.views[`${nativeId}`];\n if (!view) {\n reject(\n new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n )\n );\n return;\n }\n const result = view.makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":"AAAA;;AASA;;AAgCAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,iBAAiB,EAAE,IAAIC,GAAG,CAAS,CAAC;EACpCC,aAAa,EAAE,CAAC,CAAC;EACjBC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,IAAuB,EAAE;IACtD,IAAI,CAACN,iBAAiB,CAACO,MAAM,CAACF,QAAQ,CAAC;IACvC;IACA,IAAI,IAAI,CAACN,eAAe,CAACM,QAAQ,CAAC,EAAE;MAClCC,IAAI,CAACE,UAAU,CAAC,IAAI,CAACT,eAAe,CAACM,QAAQ,CAAc,CAAC;MAC5D,OAAO,IAAI,CAACN,eAAe,CAACM,QAAQ,CAAC;IACvC;IACA,IAAI,CAACP,KAAK,CAACO,QAAQ,CAAC,GAAGC,IAAI;EAC7B,CAAC;EACDG,cAAcA,C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a,EAAE;IACjD,MAAMnB,IAAI,GAAG,IAAI,CAACR,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;IACtC,IAAI,CAACC,IAAI,EAAE;MACT,MAAM,IAAIoB,KAAK,CACb,kDAAkDrB,QAAQ,4CAC5D,CAAC;IACH;IACA,OAAOC,IAAI,CAACkB,iBAAiB,CAACC,IAAI,CAAC;EACrC,CAAC;EACDE,mBAAmBA,CAACtB,QAAgB,EAAE;IACpC,MAAMC,IAAI,GAAG,IAAI,CAACR,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;IACtC,IAAI,CAACC,IAAI,EAAE;MACT,MAAM,IAAIoB,KAAK,CACb,yDAAyDrB,QAAQ,aACnE,CAAC;IACH;IACA,OAAOC,IAAI,CAACsB,UAAU,CAAC,CAAC;EAC1B,CAAC;EACDC,sBAAsBA,CAACxB,QAAgB,EAAEoB,IAAa,EAAE;IACtD,OAAO,IAAIK,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAM1B,IAAI,GAAG,IAAI,CAACR,KAAK,CAAC,GAAGO,QAAQ,EAAE,CAAC;MACtC,IAAI,CAACC,IAAI,EAAE;QACT0B,MAAM,CACJ,IAAIN,KAAK,CACP,kDAAkDrB,QAAQ,4CAC5D,CACF,CAAC;QACD;MACF;MACA,MAAM4B,MAAM,GAAG3B,IAAI,CAACkB,iBAAiB,CAACC,IAAI,CAAC;MAC3C,IAAIQ,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIN,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AACA,eAAe,CAAC,CAAC","ignoreList":[]}
@@ -1,11 +1,8 @@
1
1
  import { type ViewProps } from "react-native";
2
2
  import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
3
3
  export interface NativeProps extends ViewProps {
4
- debug?: boolean;
5
4
  opaque?: boolean;
6
- colorSpace?: string;
7
5
  highBitDepth?: boolean;
8
- androidWarmup?: boolean;
9
6
  androidSurfaceType?: WithDefault<"auto" | "SurfaceView" | "TextureView", "auto">;
10
7
  androidZOrderOnTop?: WithDefault<boolean, false>;
11
8
  pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
@@ -4,5 +4,5 @@ import { codegenNativeComponent } from "react-native";
4
4
  // @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings
5
5
 
6
6
  // eslint-disable-next-line import/no-default-export
7
- export default codegenNativeComponent("SkiaPictureView");
8
- //# sourceMappingURL=SkiaPictureViewNativeComponent.js.map
7
+ export default codegenNativeComponent("SkiaView");
8
+ //# sourceMappingURL=SkiaViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sources":["SkiaViewNativeComponent.ts"],"sourcesContent":["import { codegenNativeComponent, type ViewProps } from \"react-native\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings\nexport interface NativeProps extends ViewProps {\n opaque?: boolean;\n highBitDepth?: boolean;\n androidSurfaceType?: WithDefault<\n \"auto\" | \"SurfaceView\" | \"TextureView\",\n \"auto\"\n >;\n androidZOrderOnTop?: WithDefault<boolean, false>;\n pointerEvents?: WithDefault<\n \"auto\" | \"none\" | \"box-none\" | \"box-only\",\n \"auto\"\n >;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaView\");\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAwB,cAAc;;AAGrE;AACA;;AAeA;AACA,eAAeA,sBAAsB,CAAc,UAAU,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { ViewProps } from "react-native";
2
+ export interface NativeProps extends ViewProps {
3
+ opaque?: boolean;
4
+ highBitDepth?: boolean;
5
+ nativeID: string;
6
+ androidSurfaceType?: "auto" | "SurfaceView" | "TextureView";
7
+ androidZOrderOnTop?: boolean;
8
+ }
9
+ declare const SkiaViewNativeComponent: ({ nativeID, onLayout, opaque: _opaque, highBitDepth: _highBitDepth, androidSurfaceType: _androidSurfaceType, androidZOrderOnTop: _androidZOrderOnTop, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("../views/SkiaView.web").SkiaViewProps>;
10
+ export default SkiaViewNativeComponent;
@@ -0,0 +1,21 @@
1
+ import { createElement } from "react";
2
+ import { SkiaView } from "../views/SkiaView.web";
3
+ const SkiaViewNativeComponent = ({
4
+ nativeID,
5
+ onLayout,
6
+ // Surface settings, never reach the DOM
7
+ opaque: _opaque,
8
+ highBitDepth: _highBitDepth,
9
+ androidSurfaceType: _androidSurfaceType,
10
+ androidZOrderOnTop: _androidZOrderOnTop,
11
+ ...viewProps
12
+ }) => {
13
+ return /*#__PURE__*/createElement(SkiaView, {
14
+ nativeID,
15
+ onLayout,
16
+ ...viewProps
17
+ });
18
+ };
19
+ // eslint-disable-next-line import/no-default-export
20
+ export default SkiaViewNativeComponent;
21
+ //# sourceMappingURL=SkiaViewNativeComponent.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createElement","SkiaView","SkiaViewNativeComponent","nativeID","onLayout","opaque","_opaque","highBitDepth","_highBitDepth","androidSurfaceType","_androidSurfaceType","androidZOrderOnTop","_androidZOrderOnTop","viewProps"],"sources":["SkiaViewNativeComponent.web.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport { createElement } from \"react\";\n\nimport { SkiaView } from \"../views/SkiaView.web\";\n\nexport interface NativeProps extends ViewProps {\n opaque?: boolean;\n highBitDepth?: boolean;\n nativeID: string;\n androidSurfaceType?: \"auto\" | \"SurfaceView\" | \"TextureView\";\n androidZOrderOnTop?: boolean;\n}\n\nconst SkiaViewNativeComponent = ({\n nativeID,\n onLayout,\n // Surface settings, never reach the DOM\n opaque: _opaque,\n highBitDepth: _highBitDepth,\n androidSurfaceType: _androidSurfaceType,\n androidZOrderOnTop: _androidZOrderOnTop,\n ...viewProps\n}: NativeProps) => {\n return createElement(SkiaView, {\n nativeID,\n onLayout,\n ...viewProps,\n });\n};\n// eslint-disable-next-line import/no-default-export\nexport default SkiaViewNativeComponent;\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,OAAO;AAErC,SAASC,QAAQ,QAAQ,uBAAuB;AAUhD,MAAMC,uBAAuB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,QAAQ;EACR;EACAC,MAAM,EAAEC,OAAO;EACfC,YAAY,EAAEC,aAAa;EAC3BC,kBAAkB,EAAEC,mBAAmB;EACvCC,kBAAkB,EAAEC,mBAAmB;EACvC,GAAGC;AACQ,CAAC,KAAK;EACjB,oBAAOb,aAAa,CAACC,QAAQ,EAAE;IAC7BE,QAAQ;IACRC,QAAQ;IACR,GAAGS;EACL,CAAC,CAAC;AACJ,CAAC;AACD;AACA,eAAeX,uBAAuB","ignoreList":[]}
@@ -13,8 +13,7 @@ export interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {
13
13
  ref?: React.Ref<SkiaGraphiteViewRef>;
14
14
  }
15
15
  /**
16
- * A view presenting frames recorded with Skia Graphite. Requires the Graphite
17
- * backend (install-skia-graphite); with the default backend it renders
18
- * nothing. See {@link SkGraphiteContext}.
16
+ * A view whose frames are recorded from JavaScript, on any runtime, through
17
+ * the context of its ref. See {@link SkGraphiteContext}.
19
18
  */
20
- export declare const SkiaGraphiteView: ({ debug, opaque, highBitDepth, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
19
+ export declare const SkiaGraphiteView: ({ opaque, highBitDepth, android, ref, ...viewProps }: SkiaGraphiteViewProps) => React.JSX.Element;
@@ -1,17 +1,32 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useImperativeHandle, useMemo, useRef } from "react";
3
- import SkiaGraphiteViewNativeComponent from "../specs/SkiaGraphiteViewNativeComponent";
3
+ import SkiaViewNativeComponent from "../specs/SkiaViewNativeComponent";
4
+ import { Platform } from "../Platform";
4
5
  import { SkiaViewApi } from "./api";
6
+ import { androidNativeProps } from "./android";
5
7
  import { SkiaViewNativeId } from "./SkiaViewNativeId";
8
+ // The layout is known synchronously on the new architecture;
9
+ // getBoundingClientRect became stable in React Native 0.83. On the web the
10
+ // view measures itself (see SkiaView.web).
11
+ const measureLayout = view => {
12
+ if (Platform.OS === "web") {
13
+ return {
14
+ width: 0,
15
+ height: 0
16
+ };
17
+ }
18
+ const host = view;
19
+ return host.getBoundingClientRect ? host.getBoundingClientRect() : host.unstable_getBoundingClientRect();
20
+ };
21
+
6
22
  /**
7
- * A view presenting frames recorded with Skia Graphite. Requires the Graphite
8
- * backend (install-skia-graphite); with the default backend it renders
9
- * nothing. See {@link SkGraphiteContext}.
23
+ * A view whose frames are recorded from JavaScript, on any runtime, through
24
+ * the context of its ref. See {@link SkGraphiteContext}.
10
25
  */
11
26
  export const SkiaGraphiteView = ({
12
- debug = false,
13
27
  opaque = false,
14
28
  highBitDepth = false,
29
+ android,
15
30
  ref,
16
31
  ...viewProps
17
32
  }) => {
@@ -21,25 +36,21 @@ export const SkiaGraphiteView = ({
21
36
  getNativeId: () => nativeId,
22
37
  getContext: () => {
23
38
  assertSkiaViewApi();
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
39
  const view = viewRef.current;
26
40
  if (!view) {
27
41
  throw new Error("SkiaGraphiteView: getContext() was called before the view was mounted.");
28
42
  }
29
- // The layout is known synchronously on the new architecture;
30
- // getBoundingClientRect became stable in React Native 0.83.
31
- const size = "getBoundingClientRect" in view ? view.getBoundingClientRect() : view.unstable_getBoundingClientRect();
43
+ const size = measureLayout(view);
32
44
  return SkiaViewApi.makeGraphiteContext(nativeId, size.width, size.height, opaque, highBitDepth);
33
45
  }
34
46
  }), [nativeId, opaque, highBitDepth]);
35
- return /*#__PURE__*/React.createElement(SkiaGraphiteViewNativeComponent, _extends({
47
+ return /*#__PURE__*/React.createElement(SkiaViewNativeComponent, _extends({
36
48
  ref: viewRef,
37
49
  collapsable: false,
38
50
  nativeID: `${nativeId}`,
39
- debug: debug,
40
51
  opaque: opaque,
41
52
  highBitDepth: highBitDepth
42
- }, viewProps));
53
+ }, androidNativeProps(android), viewProps));
43
54
  };
44
55
  const assertSkiaViewApi = () => {
45
56
  if (SkiaViewApi === null || SkiaViewApi.makeGraphiteContext === null) {
@@ -1 +1 @@
1
- {"version":3,"names":["React","useImperativeHandle","useMemo","useRef","SkiaGraphiteViewNativeComponent","SkiaViewApi","SkiaViewNativeId","SkiaGraphiteView","debug","opaque","highBitDepth","ref","viewProps","nativeId","current","viewRef","getNativeId","getContext","assertSkiaViewApi","view","Error","size","getBoundingClientRect","unstable_getBoundingClientRect","makeGraphiteContext","width","height","createElement","_extends","collapsable","nativeID"],"sources":["SkiaGraphiteView.tsx"],"sourcesContent":["import React, { useImperativeHandle, useMemo, useRef } from \"react\";\n\nimport type { SkGraphiteContext } from \"../skia/types\";\nimport SkiaGraphiteViewNativeComponent from \"../specs/SkiaGraphiteViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaGraphiteViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nexport interface SkiaGraphiteViewRef {\n /**\n * The recording side of the view. Call it once the view is mounted. The\n * returned context can be captured into worklets and used from any runtime.\n */\n getContext(): SkGraphiteContext;\n getNativeId(): number;\n}\n\nexport interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {\n ref?: React.Ref<SkiaGraphiteViewRef>;\n}\n\n/**\n * A view presenting frames recorded with Skia Graphite. Requires the Graphite\n * backend (install-skia-graphite); with the default backend it renders\n * nothing. See {@link SkGraphiteContext}.\n */\nexport const SkiaGraphiteView = ({\n debug = false,\n opaque = false,\n highBitDepth = false,\n ref,\n ...viewProps\n}: SkiaGraphiteViewProps) => {\n const nativeId = useMemo(() => SkiaViewNativeId.current++, []);\n const viewRef =\n useRef<React.ComponentRef<typeof SkiaGraphiteViewNativeComponent>>(null);\n useImperativeHandle(\n ref,\n () => ({\n getNativeId: () => nativeId,\n getContext: () => {\n assertSkiaViewApi();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const view = viewRef.current as any;\n if (!view) {\n throw new Error(\n \"SkiaGraphiteView: getContext() was called before the view was mounted.\"\n );\n }\n // The layout is known synchronously on the new architecture;\n // getBoundingClientRect became stable in React Native 0.83.\n const size =\n \"getBoundingClientRect\" in view\n ? view.getBoundingClientRect()\n : view.unstable_getBoundingClientRect();\n return SkiaViewApi.makeGraphiteContext(\n nativeId,\n size.width,\n size.height,\n opaque,\n highBitDepth\n );\n },\n }),\n [nativeId, opaque, highBitDepth]\n );\n return (\n <SkiaGraphiteViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n highBitDepth={highBitDepth}\n {...viewProps}\n />\n );\n};\n\nconst assertSkiaViewApi = () => {\n if (SkiaViewApi === null || SkiaViewApi.makeGraphiteContext === null) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAGnE,OAAOC,+BAA+B,MAAM,0CAA0C;AAEtF,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAerD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,KAAK,GAAG,KAAK;EACbC,MAAM,GAAG,KAAK;EACdC,YAAY,GAAG,KAAK;EACpBC,GAAG;EACH,GAAGC;AACkB,CAAC,KAAK;EAC3B,MAAMC,QAA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Handle","useMemo","useRef","SkiaViewNativeComponent","Platform","SkiaViewApi","androidNativeProps","SkiaViewNativeId","measureLayout","view","OS","width","height","host","getBoundingClientRect","unstable_getBoundingClientRect","SkiaGraphiteView","opaque","highBitDepth","android","ref","viewProps","nativeId","current","viewRef","getNativeId","getContext","assertSkiaViewApi","Error","size","makeGraphiteContext","createElement","_extends","collapsable","nativeID"],"sources":["SkiaGraphiteView.tsx"],"sourcesContent":["import React, { useImperativeHandle, useMemo, useRef } from \"react\";\n\nimport type { SkGraphiteContext } from \"../skia/types\";\nimport SkiaViewNativeComponent from \"../specs/SkiaViewNativeComponent\";\nimport { Platform } from \"../Platform\";\n\nimport { SkiaViewApi } from \"./api\";\nimport { androidNativeProps } from \"./android\";\nimport type { SkiaGraphiteViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nexport interface SkiaGraphiteViewRef {\n /**\n * The recording side of the view. Call it once the view is mounted. The\n * returned context can be captured into worklets and used from any runtime.\n */\n getContext(): SkGraphiteContext;\n getNativeId(): number;\n}\n\nexport interface SkiaGraphiteViewProps extends SkiaGraphiteViewNativeProps {\n ref?: React.Ref<SkiaGraphiteViewRef>;\n}\n\n// The layout is known synchronously on the new architecture;\n// getBoundingClientRect became stable in React Native 0.83. On the web the\n// view measures itself (see SkiaView.web).\nconst measureLayout = (view: unknown) => {\n if (Platform.OS === \"web\") {\n return { width: 0, height: 0 };\n }\n const host = view as {\n getBoundingClientRect?: () => { width: number; height: number };\n unstable_getBoundingClientRect: () => { width: number; height: number };\n };\n return host.getBoundingClientRect\n ? host.getBoundingClientRect()\n : host.unstable_getBoundingClientRect();\n};\n\n/**\n * A view whose frames are recorded from JavaScript, on any runtime, through\n * the context of its ref. See {@link SkGraphiteContext}.\n */\nexport const SkiaGraphiteView = ({\n opaque = false,\n highBitDepth = false,\n android,\n ref,\n ...viewProps\n}: SkiaGraphiteViewProps) => {\n const nativeId = useMemo(() => SkiaViewNativeId.current++, []);\n const viewRef =\n useRef<React.ComponentRef<typeof SkiaViewNativeComponent>>(null);\n useImperativeHandle(\n ref,\n () => ({\n getNativeId: () => nativeId,\n getContext: () => {\n assertSkiaViewApi();\n const view = viewRef.current;\n if (!view) {\n throw new Error(\n \"SkiaGraphiteView: getContext() was called before the view was mounted.\"\n );\n }\n const size = measureLayout(view);\n return SkiaViewApi.makeGraphiteContext(\n nativeId,\n size.width,\n size.height,\n opaque,\n highBitDepth\n );\n },\n }),\n [nativeId, opaque, highBitDepth]\n );\n return (\n <SkiaViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n opaque={opaque}\n highBitDepth={highBitDepth}\n {...androidNativeProps(android)}\n {...viewProps}\n />\n );\n};\n\nconst assertSkiaViewApi = () => {\n if (SkiaViewApi === null || SkiaViewApi.makeGraphiteContext === null) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAGnE,OAAOC,uBAAuB,MAAM,kCAAkC;AACtE,SAASC,QAAQ,QAAQ,aAAa;AAEtC,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,SAASC,gBAAgB,QAAQ,oBAAoB;AAerD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,IAAa,IAAK;EACvC,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO;MAAEC,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;EAChC;EACA,MAAMC,IAAI,GAAGJ,IAGZ;EACD,OAAOI,IAAI,CAACC,qBAAqB,GAC7BD,IAAI,CAACC,qBAAqB,CAAC,CAAC,GAC5BD,IAAI,CAACE,8BAA8B,CAAC,CAAC;AAC3C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,MAAM,GAAG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@@ -3,8 +3,11 @@ import type { SkRect } from "../skia/types";
3
3
  import type { SkiaPictureViewNativeProps } from "./types";
4
4
  interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
5
5
  mode?: "default" | "continuous";
6
- androidWarmup?: boolean;
7
6
  }
7
+ /**
8
+ * A view showing a picture. The picture is handed to the native view, which
9
+ * records it once (and again on every redraw) for its surface.
10
+ */
8
11
  export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
9
12
  private requestId;
10
13
  constructor(props: SkiaPictureViewProps);
@@ -3,10 +3,14 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
4
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  import React from "react";
6
- import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
6
+ import SkiaViewNativeComponent from "../specs/SkiaViewNativeComponent";
7
7
  import { SkiaViewApi } from "./api";
8
+ import { androidNativeProps } from "./android";
8
9
  import { SkiaViewNativeId } from "./SkiaViewNativeId";
9
- const NativeSkiaPictureView = SkiaPictureViewNativeComponent;
10
+ /**
11
+ * A view showing a picture. The picture is handed to the native view, which
12
+ * records it once (and again on every redraw) for its surface.
13
+ */
10
14
  export class SkiaPictureView extends React.Component {
11
15
  constructor(props) {
12
16
  super(props);
@@ -66,21 +70,19 @@ export class SkiaPictureView extends React.Component {
66
70
  }
67
71
  render() {
68
72
  const {
69
- mode,
70
- debug = false,
73
+ mode: _mode,
74
+ picture: _picture,
71
75
  opaque = false,
72
76
  highBitDepth = false,
73
- androidWarmup = false,
77
+ android,
74
78
  ...viewProps
75
79
  } = this.props;
76
- return /*#__PURE__*/React.createElement(NativeSkiaPictureView, _extends({
80
+ return /*#__PURE__*/React.createElement(SkiaViewNativeComponent, _extends({
77
81
  collapsable: false,
78
82
  nativeID: `${this._nativeId}`,
79
- debug: debug,
80
83
  opaque: opaque,
81
- highBitDepth: highBitDepth,
82
- androidWarmup: androidWarmup
83
- }, viewProps));
84
+ highBitDepth: highBitDepth
85
+ }, androidNativeProps(android), viewProps));
84
86
  }
85
87
  }
86
88
  const assertSkiaViewApi = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["React","SkiaPictureViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","debug","opaque","highBitDepth","androidWarmup","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n androidWarmup?: boolean;\n}\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const {\n mode,\n debug = false,\n opaque = false,\n highBitDepth = false,\n androidWarmup = false,\n ...viewProps\n } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n opaque={opaque}\n highBitDepth={highBitDepth}\n androidWarmup={androidWarmup}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,qBAAqB,GAAGH,8BAA8B;AAO5D,OAAO,MAAMI,eAAe,SAASL,KAAK,CAACM,SAAS,CAAuB;EAGzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBA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MA,CAAA,EAAG;IACdT,iBAAiB,CAAC,CAAC;IACnBX,WAAW,CAAC0B,aAAa,CAAC,IAAI,CAAClB,SAAS,CAAC;EAC3C;EAEAmB,MAAMA,CAAA,EAAG;IACP,MAAM;MACJN,IAAI;MACJO,KAAK,GAAG,KAAK;MACbC,MAAM,GAAG,KAAK;MACdC,YAAY,GAAG,KAAK;MACpBC,aAAa,GAAG,KAAK;MACrB,GAAGC;IACL,CAAC,GAAG,IAAI,CAAC1B,KAAK;IACd,oBACER,KAAA,CAAAmC,aAAA,CAAC/B,qBAAqB,EAAAgC,QAAA;MACpBC,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAAC5B,SAAS,EAAG;MAC9BoB,KAAK,EAAEA,KAAM;MACbC,MAAM,EAAEA,MAAO;MACfC,YAAY,EAAEA,YAAa;MAC3BC,aAAa,EAAEA;IAAc,GACzBC,SAAS,CACd,CAAC;EAEN;AACF;AAEA,MAAMrB,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEX,WAAW,KAAK,IAAI,IACpBA,WAAW,CAACY,cAAc,KAAK,IAAI,IACnCZ,WAAW,CAAC0B,aAAa,KAAK,IAAI,IAClC1B,WAAW,CAACwB,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMa,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","SkiaViewNativeComponent","SkiaViewApi","androidNativeProps","SkiaViewNativeId","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","_mode","_picture","opaque","highBitDepth","android","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaViewNativeComponent from \"../specs/SkiaViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport { androidNativeProps } from \"./android\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\n/**\n * A view showing a picture. The picture is handed to the native view, which\n * records it once (and again on every redraw) for its surface.\n */\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const {\n mode: _mode,\n picture: _picture,\n opaque = false,\n highBitDepth = false,\n android,\n ...viewProps\n } = this.props;\n return (\n <SkiaViewNativeComponent\n collapsable={false}\n nativeID={`${this._nativeId}`}\n opaque={opaque}\n highBitDepth={highBitDepth}\n {...androidNativeProps(android)}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,uBAAuB,MAAM,kCAAkC;AAEtE,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,SAASC,gBAAgB,QAAQ,oBAAoB;AAMrD;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASL,KAAK,CAACM,SAAS,CAAuB;EAGzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHK,CAAC;IAAAA,eAAA;IAInB,IAAI,CAACC,SAAS,GAAGN,gBAAgB,CAACO,OAAO,EAAE;IAC3C,MAAM;MAAEC;IAAQ,CAAC,GAAGJ,KAAK;IACzB,IAAII,OAAO,EAAE;MACXC,iBAAiB,CAAC,CAAC;MACnBX,WAAW,CAACY,cAAc,CAAC,IAAI,CAACJ,SAAS,EAAE,SAAS,EAAEE,OAAO,CAAC;IAChE;IACA,IAAI,CAACG,IAAI,CAAC,CAAC;EACb;EAIA,IAAWC,QAAQA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACN,SAAS;EACvB;EAEAO,kBAAkBA,CAACC,SAA+B,EAAE;IAClD,MAAM;MAAEN;IAAQ,CAAC,GAAG,IAAI,CAACJ,KAAK;IAC9B,IAAII,OAAO,KAAKM,SAAS,CAACN,OAAO,EAAE;MACjCC,iBAAiB,CAAC,CAAC;MACnBX,WAAW,CAACY,cAAc,CAAC,IAAI,CAACJ,SAAS,EAAE,SAAS,EAAEE,OAAO,CAAC;IAChE;IACA,IAAI,CAACG,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IACpBA,WAAW,CAACY,cAAc,KAAK,IAAI,IACnCZ,WAAW,CAAC0B,aAAa,KAAK,IAAI,IAClC1B,WAAW,CAACwB,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMc,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { ViewProps } from "react-native";
3
+ import type { SkiaWebViewHandle } from "../specs/NativeSkiaModule.web";
4
+ export interface SkiaViewHandle extends SkiaWebViewHandle {
5
+ /** The canvas element, for Reanimated's measure(). */
6
+ readonly canvasRef: () => HTMLCanvasElement | null;
7
+ }
8
+ export interface SkiaViewProps extends ViewProps {
9
+ ref?: React.Ref<SkiaViewHandle>;
10
+ __destroyWebGLContextAfterRender?: boolean;
11
+ }
12
+ export declare const SkiaView: (props: SkiaViewProps) => React.JSX.Element;
@@ -9,12 +9,14 @@ import { Platform } from "../Platform";
9
9
  import { SkiaViewNativeId } from "./SkiaViewNativeId";
10
10
  import { useSkiaWebRenderer } from "./SkiaWebRenderer";
11
11
 
12
- // The web has no Graphite: a recording is an SkPicture, replayed onto the
13
- // view's WebGL surface by the same renderer as SkiaPictureView (with its
14
- // context-loss handling and the destroy-context-after-render mode). Frames
15
- // keep their native semantics, presented in submission order and never
16
- // dropped, with one difference: the surface starts cleared on every frame,
17
- // so a recording draws the whole frame rather than a delta.
12
+ // The web has no Graphite: the view paints pictures on a WebGL canvas (with
13
+ // context-loss recovery and the destroy-context-after-render mode). It shows
14
+ // one of two kinds of content. The picture of a <Canvas> or a
15
+ // <SkiaPictureView> is a whole frame: the latest one wins. The recordings
16
+ // submitted through the view's context (SkiaGraphiteView) keep their native
17
+ // semantics, presented in submission order and never dropped, with one
18
+ // difference: the surface starts cleared on every frame, so a recording draws
19
+ // the whole frame rather than a delta.
18
20
 
19
21
  /**
20
22
  * A frame recorded on the web. The view holds it while it is queued or on
@@ -99,12 +101,14 @@ class WebGraphiteContext {
99
101
  dispose() {}
100
102
  [Symbol.dispose]() {}
101
103
  }
102
- export const SkiaGraphiteView = props => {
104
+ export const SkiaView = props => {
103
105
  const {
104
106
  ref,
105
107
  onLayout
106
108
  } = props;
107
109
  const canvasRef = useRef(null);
110
+ // The picture of a <Canvas> or a <SkiaPictureView>: a whole frame.
111
+ const pictureRef = useRef(null);
108
112
  // Recordings submitted since the last frame, in order, and the frame on
109
113
  // screen, replayed when the surface is recreated.
110
114
  const queueRef = useRef([]);
@@ -113,9 +117,9 @@ export const SkiaGraphiteView = props => {
113
117
  const nativeId = useMemo(() => props.nativeID !== undefined ? Number(props.nativeID) : SkiaViewNativeId.current++, [props.nativeID]);
114
118
  const isStatic = props.__destroyWebGLContextAfterRender === true;
115
119
 
116
- // Presents what was submitted since the last frame. A frame that cannot be
117
- // painted yet (unmeasured canvas, lost context) stays queued for the next
118
- // opportunity.
120
+ // Presents the recordings submitted since the last frame. A frame that
121
+ // cannot be painted yet (unmeasured canvas, lost context) stays queued for
122
+ // the next opportunity.
119
123
  const present = useCallback(renderer => {
120
124
  const frame = queueRef.current;
121
125
  if (frame.length === 0) {
@@ -130,9 +134,14 @@ export const SkiaGraphiteView = props => {
130
134
  shownRef.current = frame;
131
135
  previous.forEach(recording => recording.release());
132
136
  }, []);
137
+
138
+ // Paints what the view holds: pending recordings first, else the picture,
139
+ // else the frame on screen again (the surface was recreated).
133
140
  const paint = useCallback(renderer => {
134
141
  if (queueRef.current.length > 0) {
135
142
  present(renderer);
143
+ } else if (pictureRef.current) {
144
+ renderer.draw([pictureRef.current]);
136
145
  } else if (shownRef.current.length > 0) {
137
146
  renderer.draw(shownRef.current.map(recording => recording.picture));
138
147
  }
@@ -141,25 +150,37 @@ export const SkiaGraphiteView = props => {
141
150
  paint,
142
151
  onLayout
143
152
  });
153
+
154
+ // Draws are flushed from a microtask rather than an animation frame: the
155
+ // browser composites once per frame either way, and painting right away
156
+ // keeps a frame produced inside an animation callback (the Reanimated
157
+ // mapper, a frame loop) from slipping to the next one. Deferring to the
158
+ // next animation frame would alternate between "flush pending in this
159
+ // frame" and "flush scheduled for the next frame", halving the effective
160
+ // frame rate. Without a renderer yet (an unmeasured canvas), the content
161
+ // stays held and is painted by the renderer once it exists, so it is
162
+ // never lost.
144
163
  const flush = useCallback(() => {
145
164
  flushScheduledRef.current = false;
146
165
  if (rendererRef.current) {
147
- present(rendererRef.current);
166
+ paint(rendererRef.current);
148
167
  }
149
- }, [present, rendererRef]);
150
-
151
- // Frames are presented from a microtask rather than an animation frame:
152
- // the browser composites once per frame either way, and painting right
153
- // away keeps a frame recorded inside an animation callback from slipping
154
- // to the next one (see SkiaPictureView.web).
155
- const submit = useCallback(recording => {
156
- recording.retain();
157
- queueRef.current.push(recording);
168
+ }, [paint, rendererRef]);
169
+ const redraw = useCallback(() => {
158
170
  if (!flushScheduledRef.current) {
159
171
  flushScheduledRef.current = true;
160
172
  queueMicrotask(flush);
161
173
  }
162
174
  }, [flush]);
175
+ const setPicture = useCallback(picture => {
176
+ pictureRef.current = picture;
177
+ redraw();
178
+ }, [redraw]);
179
+ const submit = useCallback(recording => {
180
+ recording.retain();
181
+ queueRef.current.push(recording);
182
+ redraw();
183
+ }, [redraw]);
163
184
  const getSize = useCallback(() => {
164
185
  var _canvasRef$current, _canvasRef$current2;
165
186
  return {
@@ -171,17 +192,23 @@ export const SkiaGraphiteView = props => {
171
192
  getSize,
172
193
  submit
173
194
  }), [getSize, submit]);
174
- const redraw = useCallback(() => {
175
- if (rendererRef.current) {
176
- paint(rendererRef.current);
177
- }
178
- }, [paint, rendererRef]);
179
195
  const makeImageSnapshot = useCallback(rect => {
180
- const frame = queueRef.current.length > 0 ? queueRef.current : shownRef.current;
181
- if (!rendererRef.current || frame.length === 0) {
196
+ const renderer = rendererRef.current;
197
+ if (!renderer) {
182
198
  return null;
183
199
  }
184
- return rendererRef.current.makeImageSnapshot(frame.map(recording => recording.picture), rect);
200
+ let frame;
201
+ if (queueRef.current.length > 0) {
202
+ frame = queueRef.current.map(recording => recording.picture);
203
+ } else if (pictureRef.current) {
204
+ frame = [pictureRef.current];
205
+ } else {
206
+ frame = shownRef.current.map(recording => recording.picture);
207
+ }
208
+ if (frame.length === 0) {
209
+ return null;
210
+ }
211
+ return renderer.makeImageSnapshot(frame, rect);
185
212
  }, [rendererRef]);
186
213
  const measure = useCallback(callback => {
187
214
  if (canvasRef.current) {
@@ -191,7 +218,11 @@ export const SkiaGraphiteView = props => {
191
218
  left: 0,
192
219
  top: 0
193
220
  };
194
- callback(rect.left - parentRect.left, rect.top - parentRect.top, rect.width, rect.height, rect.left + window.scrollX, rect.top + window.scrollY);
221
+ callback(
222
+ // x, y are relative to the parent
223
+ rect.left - parentRect.left, rect.top - parentRect.top, rect.width, rect.height,
224
+ // pageX, pageY are absolute screen coordinates
225
+ rect.left + window.scrollX, rect.top + window.scrollY);
195
226
  }
196
227
  }, []);
197
228
  const measureInWindow = useCallback(callback => {
@@ -200,13 +231,27 @@ export const SkiaGraphiteView = props => {
200
231
  callback(rect.left, rect.top, rect.width, rect.height);
201
232
  }
202
233
  }, []);
234
+
235
+ // No flush cancellation is needed on unmount: a microtask queued before
236
+ // unmount runs within the same task, and flush no-ops once the
237
+ // layout-effect cleanup has nulled rendererRef.
238
+
203
239
  useImperativeHandle(ref, () => ({
240
+ setPicture,
204
241
  getContext,
205
- getNativeId: () => nativeId
206
- }), [getContext, nativeId]);
242
+ getSize,
243
+ redraw,
244
+ makeImageSnapshot,
245
+ measure,
246
+ measureInWindow,
247
+ get canvasRef() {
248
+ return () => canvasRef.current;
249
+ }
250
+ }), [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow]);
207
251
  useEffect(() => {
208
252
  const api = global.SkiaViewApi;
209
253
  api.registerView(`${nativeId}`, {
254
+ setPicture,
210
255
  getContext,
211
256
  getSize,
212
257
  redraw,
@@ -215,9 +260,11 @@ export const SkiaGraphiteView = props => {
215
260
  measureInWindow
216
261
  });
217
262
  return () => {
263
+ // Views must be removed on unmount: the handle's closures capture the
264
+ // canvas element, so a stale entry retains the whole detached DOM tree.
218
265
  api.unregisterView(`${nativeId}`);
219
266
  };
220
- }, [getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
267
+ }, [setPicture, getContext, getSize, redraw, makeImageSnapshot, measure, measureInWindow, nativeId]);
221
268
 
222
269
  // Let go of the recordings the view holds.
223
270
  useEffect(() => () => {
@@ -227,9 +274,6 @@ export const SkiaGraphiteView = props => {
227
274
  shownRef.current = [];
228
275
  }, []);
229
276
  const {
230
- debug: _debug,
231
- opaque: _opaque,
232
- highBitDepth: _highBitDepth,
233
277
  ref: _ref,
234
278
  onLayout: _onLayout,
235
279
  nativeID: _nativeID,
@@ -251,4 +295,4 @@ export const SkiaGraphiteView = props => {
251
295
  }
252
296
  }));
253
297
  };
254
- //# sourceMappingURL=SkiaGraphiteView.web.js.map
298
+ //# sourceMappingURL=SkiaView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","JsiSkPictureRecorder","Platform","SkiaViewNativeId","useSkiaWebRenderer","WebGraphiteRecording","constructor","picture","_defineProperty","retain","holds","release","disposed","dispose","Symbol","WebGraphiteContext","target","width","getSize","height","beginRecording","recorder","Error","CanvasKit","PictureRecorder","x","y","finishRecording","finishRecordingAsPicture","submit","recording","SkiaView","props","ref","onLayout","canvasRef","pictureRef","queueRef","shownRef","flushScheduledRef","nativeId","nativeID","undefined","Number","current","isStatic","__destroyWebGLContextAfterRender","present","renderer","frame","length","draw","map","previous","forEach","paint","rendererRef","flush","redraw","queueMicrotask","setPicture","push","_canvasRef$current","_canvasRef$current2","clientWidth","clientHeight","getContext","makeImageSnapshot","rect","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","window","scrollX","scrollY","measureInWindow","api","global","SkiaViewApi","registerView","unregisterView","_ref","_onLayout","_nativeID","_isStatic","viewProps","createElement","View","_extends","key","style","display"],"sources":["SkiaView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nimport type {\n SkCanvas,\n SkGraphiteContext,\n SkGraphiteRecording,\n SkImage,\n SkPicture,\n SkRect,\n} from \"../skia/types\";\nimport { JsiSkPictureRecorder } from \"../skia/web/JsiSkPictureRecorder\";\nimport { Platform } from \"../Platform\";\nimport type {\n ISkiaViewApiWeb,\n SkiaWebViewHandle,\n} from \"../specs/NativeSkiaModule.web\";\n\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\nimport { useSkiaWebRenderer } from \"./SkiaWebRenderer\";\nimport type { Renderer, WebFrame } from \"./SkiaWebRenderer\";\n\n// The web has no Graphite: the view paints pictures on a WebGL canvas (with\n// context-loss recovery and the destroy-context-after-render mode). It shows\n// one of two kinds of content. The picture of a <Canvas> or a\n// <SkiaPictureView> is a whole frame: the latest one wins. The recordings\n// submitted through the view's context (SkiaGraphiteView) keep their native\n// semantics, presented in submission order and never dropped, with one\n// difference: the surface starts cleared on every frame, so a recording draws\n// the whole frame rather than a delta.\n\nexport interface SkiaViewHandle extends SkiaWebViewHandle {\n /** The canvas element, for Reanimated's measure(). */\n readonly canvasRef: () => HTMLCanvasElement | null;\n}\n\nexport interface SkiaViewProps extends ViewProps {\n ref?: React.Ref<SkiaViewHandle>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\n/**\n * A frame recorded on the web. The view holds it while it is queued or on\n * screen: disposing it then only marks it, the picture is deleted once the\n * view lets go of it.\n */\nclass WebGraphiteRecording implements SkGraphiteRecording {\n readonly __typename__ = \"GraphiteRecording\" as const;\n private holds = 0;\n private disposed = false;\n\n constructor(readonly picture: SkPicture) {}\n\n retain() {\n this.holds++;\n }\n\n release() {\n this.holds--;\n if (this.disposed && this.holds === 0) {\n this.picture.dispose();\n }\n }\n\n dispose() {\n if (this.disposed) {\n return;\n }\n this.disposed = true;\n if (this.holds === 0) {\n this.picture.dispose();\n }\n }\n\n [Symbol.dispose]() {\n this.dispose();\n }\n}\n\ninterface RecordingTarget {\n getSize(): { width: number; height: number };\n submit(recording: WebGraphiteRecording): void;\n}\n\nclass WebGraphiteContext implements SkGraphiteContext {\n readonly __typename__ = \"GraphiteContext\" as const;\n private recorder: JsiSkPictureRecorder | null = null;\n\n constructor(private readonly target: RecordingTarget) {}\n\n get width() {\n return this.target.getSize().width;\n }\n\n get height() {\n return this.target.getSize().height;\n }\n\n beginRecording(): SkCanvas {\n if (this.recorder) {\n throw new Error(\n \"SkiaGraphiteView: a recording is already open, call finishRecording() first.\"\n );\n }\n const { width, height } = this.target.getSize();\n if (width <= 0 || height <= 0) {\n throw new Error(\"SkiaGraphiteView: the view has no size yet.\");\n }\n this.recorder = new JsiSkPictureRecorder(\n CanvasKit,\n new CanvasKit.PictureRecorder()\n );\n return this.recorder.beginRecording({ x: 0, y: 0, width, height });\n }\n\n finishRecording(): SkGraphiteRecording {\n if (!this.recorder) {\n throw new Error(\n \"SkiaGraphiteView: no recording is open, call beginRecording() first.\"\n );\n }\n const picture = this.recorder.finishRecordingAsPicture();\n this.recorder.dispose();\n this.recorder = null;\n return new WebGraphiteRecording(picture);\n }\n\n submit(recording: SkGraphiteRecording) {\n if (!(recording instanceof WebGraphiteRecording)) {\n throw new Error(\n \"SkiaGraphiteView: submit() expects a recording from finishRecording().\"\n );\n }\n this.target.submit(recording);\n }\n\n dispose() {}\n\n [Symbol.dispose]() {}\n}\n\nexport const SkiaView = (props: SkiaViewProps) => {\n const { ref, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n // The picture of a <Canvas> or a <SkiaPictureView>: a whole frame.\n const pictureRef = useRef<SkPicture | null>(null);\n // Recordings submitted since the last frame, in order, and the frame on\n // screen, replayed when the surface is recreated.\n const queueRef = useRef<WebGraphiteRecording[]>([]);\n const shownRef = useRef<WebGraphiteRecording[]>([]);\n const flushScheduledRef = useRef(false);\n const nativeId = useMemo(\n () =>\n props.nativeID !== undefined\n ? Number(props.nativeID)\n : SkiaViewNativeId.current++,\n [props.nativeID]\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n // Presents the recordings submitted since the last frame. A frame that\n // cannot be painted yet (unmeasured canvas, lost context) stays queued for\n // the next opportunity.\n const present = useCallback((renderer: Renderer) => {\n const frame = queueRef.current;\n if (frame.length === 0) {\n return;\n }\n queueRef.current = [];\n if (!renderer.draw(frame.map((recording) => recording.picture))) {\n queueRef.current = frame;\n return;\n }\n const previous = shownRef.current;\n shownRef.current = frame;\n previous.forEach((recording) => recording.release());\n }, []);\n\n // Paints what the view holds: pending recordings first, else the picture,\n // else the frame on screen again (the surface was recreated).\n const paint = useCallback(\n (renderer: Renderer) => {\n if (queueRef.current.length > 0) {\n present(renderer);\n } else if (pictureRef.current) {\n renderer.draw([pictureRef.current]);\n } else if (shownRef.current.length > 0) {\n renderer.draw(shownRef.current.map((recording) => recording.picture));\n }\n },\n [present]\n );\n const rendererRef = useSkiaWebRenderer(canvasRef, isStatic, {\n paint,\n onLayout,\n });\n\n // Draws are flushed from a microtask rather than an animation frame: the\n // browser composites once per frame either way, and painting right away\n // keeps a frame produced inside an animation callback (the Reanimated\n // mapper, a frame loop) from slipping to the next one. Deferring to the\n // next animation frame would alternate between \"flush pending in this\n // frame\" and \"flush scheduled for the next frame\", halving the effective\n // frame rate. Without a renderer yet (an unmeasured canvas), the content\n // stays held and is painted by the renderer once it exists, so it is\n // never lost.\n const flush = useCallback(() => {\n flushScheduledRef.current = false;\n if (rendererRef.current) {\n paint(rendererRef.current);\n }\n }, [paint, rendererRef]);\n\n const redraw = useCallback(() => {\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flush);\n }\n }, [flush]);\n\n const setPicture = useCallback(\n (picture: SkPicture) => {\n pictureRef.current = picture;\n redraw();\n },\n [redraw]\n );\n\n const submit = useCallback(\n (recording: WebGraphiteRecording) => {\n recording.retain();\n queueRef.current.push(recording);\n redraw();\n },\n [redraw]\n );\n\n const getSize = useCallback(\n () => ({\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n }),\n []\n );\n\n const getContext = useCallback(\n (): SkGraphiteContext => new WebGraphiteContext({ getSize, submit }),\n [getSize, submit]\n );\n\n const makeImageSnapshot = useCallback(\n (rect?: SkRect): SkImage | null => {\n const renderer = rendererRef.current;\n if (!renderer) {\n return null;\n }\n let frame: WebFrame;\n if (queueRef.current.length > 0) {\n frame = queueRef.current.map((recording) => recording.picture);\n } else if (pictureRef.current) {\n frame = [pictureRef.current];\n } else {\n frame = shownRef.current.map((recording) => recording.picture);\n }\n if (frame.length === 0) {\n return null;\n }\n return renderer.makeImageSnapshot(frame, rect);\n },\n [rendererRef]\n );\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n callback(\n // x, y are relative to the parent\n rect.left - parentRect.left,\n rect.top - parentRect.top,\n rect.width,\n rect.height,\n // pageX, pageY are absolute screen coordinates\n rect.left + window.scrollX,\n rect.top + window.scrollY\n );\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n callback(rect.left, rect.top, rect.width, rect.height);\n }\n },\n []\n );\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flush no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n ]\n );\n\n useEffect(() => {\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(`${nativeId}`, {\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n });\n return () => {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n api.unregisterView(`${nativeId}`);\n };\n }, [\n setPicture,\n getContext,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n nativeId,\n ]);\n\n // Let go of the recordings the view holds.\n useEffect(\n () => () => {\n queueRef.current.forEach((recording) => recording.release());\n queueRef.current = [];\n shownRef.current.forEach((recording) => recording.release());\n shownRef.current = [];\n },\n []\n );\n\n const {\n ref: _ref,\n onLayout: _onLayout,\n nativeID: _nativeID,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View nativeID={`${nativeId}`} {...viewProps}>\n <canvas\n // A canvas element is bound to one context kind for life (WebGL for\n // the live renderer, 2D for the static one), so switching renderers\n // needs a fresh element.\n key={isStatic ? \"static\" : \"webgl\"}\n ref={canvasRef}\n style={{ display: \"block\", width: \"100%\", height: \"100%\" }}\n />\n </Platform.View>\n );\n};\n"],"mappings":";;;;AAAA;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAWd,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,QAAQ,QAAQ,aAAa;AAMtC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,kBAAkB,QAAQ,mBAAmB;;AAGtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,CAAgC;EAKxDC,WAAWA,CAAUC,OAAkB,EAAE;IAAA,KAApBA,OAAkB,GAAlBA,OAA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EAAAC,QAAA;IAACpD,QAAQ,EAAE,GAAGD,QAAQ;EAAG,GAAKkD,SAAS,gBACnD/F,KAAA,CAAAgG,aAAA;IACE;IACA;IACA;IACAG,GAAG,EAAEjD,QAAQ,GAAG,QAAQ,GAAG,OAAQ;IACnCZ,GAAG,EAAEE,SAAU;IACf4D,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE/E,KAAK,EAAE,MAAM;MAAEE,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
6
6
  import { useLayoutEffect, useRef } from "react";
7
7
  import { JsiSkSurface } from "../skia/web/JsiSkSurface";
8
8
 
9
- // The WebGL renderers behind the web views (SkiaPictureView, SkiaGraphiteView):
9
+ // The WebGL renderers behind the web view (SkiaView.web):
10
10
  // a <canvas> element, its WebGL context and the CanvasKit surface built on
11
11
  // it, with the context-loss handling and the "destroy the context after each
12
12
  // draw" mode that keeps a page under the browser's live-context limit.