react-native-skia 3.0.4 → 3.0.5

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 (204) hide show
  1. package/android/CMakeLists.txt +0 -2
  2. package/android/cpp/jni/JniPlatformContext.cpp +0 -24
  3. package/android/cpp/jni/include/JniPlatformContext.h +0 -2
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -140
  5. package/android/src/main/java/com/reactnative/skia/PlatformContext.java +0 -5
  6. package/apple/RNSkApplePlatformContext.h +0 -10
  7. package/apple/RNSkApplePlatformContext.mm +0 -182
  8. package/cpp/api/JsiGPUTexture.h +48 -0
  9. package/cpp/api/JsiSkApi.h +1 -16
  10. package/cpp/api/JsiSkImage.h +0 -12
  11. package/cpp/api/JsiSkImageFactory.h +36 -57
  12. package/cpp/api/JsiSkSurface.h +3 -10
  13. package/cpp/api/JsiSkSurfaceFactory.h +13 -18
  14. package/cpp/rnskia/RNDawnContext.h +5 -113
  15. package/cpp/rnskia/RNDawnUtils.h +33 -0
  16. package/cpp/rnskia/RNSkPlatformContext.h +0 -54
  17. package/lib/commonjs/external/reanimated/index.d.ts +0 -1
  18. package/lib/commonjs/external/reanimated/index.js +0 -11
  19. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  20. package/lib/commonjs/mock/index.js +1 -2
  21. package/lib/commonjs/mock/index.js.map +1 -1
  22. package/lib/commonjs/skia/types/GPUTexture.d.ts +11 -0
  23. package/lib/commonjs/skia/types/GPUTexture.js +2 -0
  24. package/lib/commonjs/skia/types/GPUTexture.js.map +1 -0
  25. package/lib/commonjs/skia/types/Image/Image.d.ts +0 -10
  26. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  27. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +25 -48
  28. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  29. package/lib/commonjs/skia/types/Skia.d.ts +0 -4
  30. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  31. package/lib/commonjs/skia/types/Surface/Surface.d.ts +3 -14
  32. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  33. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  34. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  35. package/lib/commonjs/skia/types/index.d.ts +1 -2
  36. package/lib/commonjs/skia/types/index.js +11 -22
  37. package/lib/commonjs/skia/types/index.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkImage.d.ts +0 -1
  39. package/lib/commonjs/skia/web/JsiSkImage.js +0 -4
  40. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +4 -5
  42. package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -10
  43. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +0 -1
  45. package/lib/commonjs/skia/web/JsiSkSurface.js +0 -4
  46. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  47. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  48. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +1 -1
  49. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkia.js +0 -4
  51. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  52. package/lib/module/external/reanimated/index.d.ts +0 -1
  53. package/lib/module/external/reanimated/index.js +0 -1
  54. package/lib/module/external/reanimated/index.js.map +1 -1
  55. package/lib/module/mock/index.js +1 -2
  56. package/lib/module/mock/index.js.map +1 -1
  57. package/lib/module/skia/types/GPUTexture.d.ts +11 -0
  58. package/lib/module/skia/types/GPUTexture.js +2 -0
  59. package/lib/module/skia/types/GPUTexture.js.map +1 -0
  60. package/lib/module/skia/types/Image/Image.d.ts +0 -10
  61. package/lib/module/skia/types/Image/Image.js.map +1 -1
  62. package/lib/module/skia/types/Image/ImageFactory.d.ts +25 -48
  63. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  64. package/lib/module/skia/types/Skia.d.ts +0 -4
  65. package/lib/module/skia/types/Skia.js.map +1 -1
  66. package/lib/module/skia/types/Surface/Surface.d.ts +3 -14
  67. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  68. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  69. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  70. package/lib/module/skia/types/index.d.ts +1 -2
  71. package/lib/module/skia/types/index.js +1 -2
  72. package/lib/module/skia/types/index.js.map +1 -1
  73. package/lib/module/skia/web/JsiSkImage.d.ts +0 -1
  74. package/lib/module/skia/web/JsiSkImage.js +0 -4
  75. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkImageFactory.d.ts +4 -5
  77. package/lib/module/skia/web/JsiSkImageFactory.js +6 -10
  78. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkSurface.d.ts +0 -1
  80. package/lib/module/skia/web/JsiSkSurface.js +0 -4
  81. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  83. package/lib/module/skia/web/JsiSkSurfaceFactory.js +1 -1
  84. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  85. package/lib/module/skia/web/JsiSkia.js +0 -4
  86. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  87. package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
  88. package/lib/typescript/src/skia/types/GPUTexture.d.ts +11 -0
  89. package/lib/typescript/src/skia/types/Image/Image.d.ts +0 -10
  90. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +25 -48
  91. package/lib/typescript/src/skia/types/Skia.d.ts +0 -4
  92. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +3 -14
  93. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  94. package/lib/typescript/src/skia/types/index.d.ts +1 -2
  95. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +0 -1
  96. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +4 -5
  97. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +0 -1
  98. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  99. package/package.json +1 -1
  100. package/src/external/reanimated/index.ts +0 -1
  101. package/src/mock/index.ts +0 -1
  102. package/src/skia/types/GPUTexture.ts +9 -0
  103. package/src/skia/types/Image/Image.ts +0 -11
  104. package/src/skia/types/Image/ImageFactory.ts +25 -55
  105. package/src/skia/types/Skia.ts +0 -4
  106. package/src/skia/types/Surface/Surface.ts +3 -15
  107. package/src/skia/types/Surface/SurfaceFactory.ts +11 -9
  108. package/src/skia/types/index.ts +1 -2
  109. package/src/skia/web/JsiSkImage.ts +0 -5
  110. package/src/skia/web/JsiSkImageFactory.ts +16 -16
  111. package/src/skia/web/JsiSkSurface.ts +0 -5
  112. package/src/skia/web/JsiSkSurfaceFactory.ts +2 -2
  113. package/src/skia/web/JsiSkia.ts +0 -4
  114. package/android/cpp/rnskia-android/AHardwareBufferUtils.cpp +0 -31
  115. package/android/cpp/rnskia-android/AHardwareBufferUtils.h +0 -13
  116. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -200
  117. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +0 -44
  118. package/android/src/main/java/com/reactnative/skia/RNSkVideo.java +0 -320
  119. package/apple/RNSkAppleVideo.h +0 -78
  120. package/apple/RNSkAppleVideo.mm +0 -292
  121. package/cpp/api/JsiNativeBuffer.h +0 -56
  122. package/cpp/api/JsiTextureInfo.h +0 -53
  123. package/cpp/api/JsiVideo.h +0 -101
  124. package/cpp/rnskia/RNSkVideo.h +0 -31
  125. package/lib/commonjs/external/reanimated/useVideo.d.ts +0 -21
  126. package/lib/commonjs/external/reanimated/useVideo.js +0 -150
  127. package/lib/commonjs/external/reanimated/useVideo.js.map +0 -1
  128. package/lib/commonjs/external/reanimated/useVideoLoading.d.ts +0 -4
  129. package/lib/commonjs/external/reanimated/useVideoLoading.js +0 -40
  130. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +0 -1
  131. package/lib/commonjs/external/reanimated/useVideoLoading.web.d.ts +0 -4
  132. package/lib/commonjs/external/reanimated/useVideoLoading.web.js +0 -20
  133. package/lib/commonjs/external/reanimated/useVideoLoading.web.js.map +0 -1
  134. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  135. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +0 -15
  136. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
  137. package/lib/commonjs/skia/types/NativeBuffer/index.d.ts +0 -1
  138. package/lib/commonjs/skia/types/NativeBuffer/index.js +0 -17
  139. package/lib/commonjs/skia/types/NativeBuffer/index.js.map +0 -1
  140. package/lib/commonjs/skia/types/Video/Video.d.ts +0 -20
  141. package/lib/commonjs/skia/types/Video/Video.js +0 -6
  142. package/lib/commonjs/skia/types/Video/Video.js.map +0 -1
  143. package/lib/commonjs/skia/types/Video/index.d.ts +0 -1
  144. package/lib/commonjs/skia/types/Video/index.js +0 -17
  145. package/lib/commonjs/skia/types/Video/index.js.map +0 -1
  146. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  147. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js +0 -30
  148. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
  149. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  150. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +0 -48
  151. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
  152. package/lib/commonjs/skia/web/JsiVideo.d.ts +0 -28
  153. package/lib/commonjs/skia/web/JsiVideo.js +0 -96
  154. package/lib/commonjs/skia/web/JsiVideo.js.map +0 -1
  155. package/lib/module/external/reanimated/useVideo.d.ts +0 -21
  156. package/lib/module/external/reanimated/useVideo.js +0 -142
  157. package/lib/module/external/reanimated/useVideo.js.map +0 -1
  158. package/lib/module/external/reanimated/useVideoLoading.d.ts +0 -4
  159. package/lib/module/external/reanimated/useVideoLoading.js +0 -33
  160. package/lib/module/external/reanimated/useVideoLoading.js.map +0 -1
  161. package/lib/module/external/reanimated/useVideoLoading.web.d.ts +0 -4
  162. package/lib/module/external/reanimated/useVideoLoading.web.js +0 -13
  163. package/lib/module/external/reanimated/useVideoLoading.web.js.map +0 -1
  164. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  165. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +0 -5
  166. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
  167. package/lib/module/skia/types/NativeBuffer/index.d.ts +0 -1
  168. package/lib/module/skia/types/NativeBuffer/index.js +0 -2
  169. package/lib/module/skia/types/NativeBuffer/index.js.map +0 -1
  170. package/lib/module/skia/types/Video/Video.d.ts +0 -20
  171. package/lib/module/skia/types/Video/Video.js +0 -2
  172. package/lib/module/skia/types/Video/Video.js.map +0 -1
  173. package/lib/module/skia/types/Video/index.d.ts +0 -1
  174. package/lib/module/skia/types/Video/index.js +0 -2
  175. package/lib/module/skia/types/Video/index.js.map +0 -1
  176. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  177. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +0 -23
  178. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
  179. package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  180. package/lib/module/skia/web/JsiSkNativeBufferFactory.js +0 -41
  181. package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
  182. package/lib/module/skia/web/JsiVideo.d.ts +0 -28
  183. package/lib/module/skia/web/JsiVideo.js +0 -88
  184. package/lib/module/skia/web/JsiVideo.js.map +0 -1
  185. package/lib/typescript/src/external/reanimated/useVideo.d.ts +0 -21
  186. package/lib/typescript/src/external/reanimated/useVideoLoading.d.ts +0 -4
  187. package/lib/typescript/src/external/reanimated/useVideoLoading.web.d.ts +0 -4
  188. package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  189. package/lib/typescript/src/skia/types/NativeBuffer/index.d.ts +0 -1
  190. package/lib/typescript/src/skia/types/Video/Video.d.ts +0 -20
  191. package/lib/typescript/src/skia/types/Video/index.d.ts +0 -1
  192. package/lib/typescript/src/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  193. package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  194. package/lib/typescript/src/skia/web/JsiVideo.d.ts +0 -28
  195. package/src/external/reanimated/useVideo.ts +0 -161
  196. package/src/external/reanimated/useVideoLoading.ts +0 -39
  197. package/src/external/reanimated/useVideoLoading.web.ts +0 -17
  198. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +0 -52
  199. package/src/skia/types/NativeBuffer/index.ts +0 -1
  200. package/src/skia/types/Video/Video.ts +0 -19
  201. package/src/skia/types/Video/index.ts +0 -1
  202. package/src/skia/web/CanvasKitWebGLBufferImpl.ts +0 -25
  203. package/src/skia/web/JsiSkNativeBufferFactory.ts +0 -51
  204. package/src/skia/web/JsiVideo.ts +0 -113
@@ -1,88 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import { CanvasKitWebGLBufferImpl } from "./CanvasKitWebGLBufferImpl";
5
- import { JsiSkImageFactory } from "./JsiSkImageFactory";
6
- import { throwNotImplementedOnRNWeb } from "./Host";
7
- export const createVideo = async (CanvasKit, url) => {
8
- const video = document.createElement("video");
9
- return new Promise((resolve, reject) => {
10
- video.src = url;
11
- video.style.display = "none";
12
- video.crossOrigin = "anonymous";
13
- video.volume = 0;
14
- video.addEventListener("loadedmetadata", () => {
15
- document.body.appendChild(video);
16
- resolve(new JsiVideo(new JsiSkImageFactory(CanvasKit), video));
17
- });
18
- video.addEventListener("error", () => {
19
- reject(new Error(`Failed to load video from URL: ${url}`));
20
- });
21
- });
22
- };
23
- export class JsiVideo {
24
- constructor(ImageFactory, videoElement) {
25
- this.ImageFactory = ImageFactory;
26
- this.videoElement = videoElement;
27
- _defineProperty(this, "__typename__", "Video");
28
- _defineProperty(this, "webglBuffer", null);
29
- document.body.appendChild(this.videoElement);
30
- }
31
- duration() {
32
- return this.videoElement.duration * 1000;
33
- }
34
- framerate() {
35
- return throwNotImplementedOnRNWeb();
36
- }
37
- currentTime() {
38
- return this.videoElement.currentTime * 1000;
39
- }
40
- setSurface(surface) {
41
- // If we have the surface, we can use the WebGL buffer which is slightly faster
42
- // This is because WebGL cannot be shared across contextes.
43
- // This can be removed with WebGPU
44
- this.webglBuffer = new CanvasKitWebGLBufferImpl(surface, this.videoElement);
45
- }
46
- nextImage() {
47
- return this.ImageFactory.MakeImageFromNativeBuffer(this.webglBuffer ? this.webglBuffer : this.videoElement);
48
- }
49
- seek(time) {
50
- if (isNaN(time)) {
51
- throw new Error(`Invalid time: ${time}`);
52
- }
53
- this.videoElement.currentTime = time / 1000;
54
- }
55
- rotation() {
56
- return 0;
57
- }
58
- size() {
59
- return {
60
- width: this.videoElement.videoWidth,
61
- height: this.videoElement.videoHeight
62
- };
63
- }
64
- pause() {
65
- this.videoElement.pause();
66
- }
67
- play() {
68
- this.videoElement.play();
69
- }
70
- setVolume(volume) {
71
- this.videoElement.volume = volume;
72
- }
73
- setLooping(looping) {
74
- this.videoElement.loop = looping;
75
- }
76
- isPlaying() {
77
- return !this.videoElement.paused && !this.videoElement.ended;
78
- }
79
- [Symbol.dispose]() {
80
- if (this.videoElement.parentNode) {
81
- this.videoElement.parentNode.removeChild(this.videoElement);
82
- }
83
- }
84
- dispose() {
85
- this[Symbol.dispose]();
86
- }
87
- }
88
- //# sourceMappingURL=JsiVideo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CanvasKitWebGLBufferImpl","JsiSkImageFactory","throwNotImplementedOnRNWeb","createVideo","CanvasKit","url","video","document","createElement","Promise","resolve","reject","src","style","display","crossOrigin","volume","addEventListener","body","appendChild","JsiVideo","Error","constructor","ImageFactory","videoElement","_defineProperty","duration","framerate","currentTime","setSurface","surface","webglBuffer","nextImage","MakeImageFromNativeBuffer","seek","time","isNaN","rotation","size","width","videoWidth","height","videoHeight","pause","play","setVolume","setLooping","looping","loop","isPlaying","paused","ended","Symbol","dispose","parentNode","removeChild"],"sources":["JsiVideo.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { CanvasKitWebGLBuffer, Video, ImageFactory } from \"../types\";\n\nimport { CanvasKitWebGLBufferImpl } from \"./CanvasKitWebGLBufferImpl\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { throwNotImplementedOnRNWeb } from \"./Host\";\n\nexport const createVideo = async (\n CanvasKit: CanvasKit,\n url: string\n): Promise<Video> => {\n const video = document.createElement(\"video\");\n return new Promise((resolve, reject) => {\n video.src = url;\n video.style.display = \"none\";\n video.crossOrigin = \"anonymous\";\n video.volume = 0;\n video.addEventListener(\"loadedmetadata\", () => {\n document.body.appendChild(video);\n resolve(new JsiVideo(new JsiSkImageFactory(CanvasKit), video));\n });\n video.addEventListener(\"error\", () => {\n reject(new Error(`Failed to load video from URL: ${url}`));\n });\n });\n};\n\nexport class JsiVideo implements Video {\n __typename__ = \"Video\" as const;\n\n private webglBuffer: CanvasKitWebGLBuffer | null = null;\n\n constructor(\n private ImageFactory: ImageFactory,\n private videoElement: HTMLVideoElement\n ) {\n document.body.appendChild(this.videoElement);\n }\n\n duration() {\n return this.videoElement.duration * 1000;\n }\n\n framerate(): number {\n return throwNotImplementedOnRNWeb<number>();\n }\n\n currentTime() {\n return this.videoElement.currentTime * 1000;\n }\n\n setSurface(surface: Surface) {\n // If we have the surface, we can use the WebGL buffer which is slightly faster\n // This is because WebGL cannot be shared across contextes.\n // This can be removed with WebGPU\n this.webglBuffer = new CanvasKitWebGLBufferImpl(surface, this.videoElement);\n }\n\n nextImage() {\n return this.ImageFactory.MakeImageFromNativeBuffer(\n this.webglBuffer ? this.webglBuffer : this.videoElement\n );\n }\n\n seek(time: number) {\n if (isNaN(time)) {\n throw new Error(`Invalid time: ${time}`);\n }\n this.videoElement.currentTime = time / 1000;\n }\n\n rotation() {\n return 0 as const;\n }\n\n size() {\n return {\n width: this.videoElement.videoWidth,\n height: this.videoElement.videoHeight,\n };\n }\n\n pause() {\n this.videoElement.pause();\n }\n\n play() {\n this.videoElement.play();\n }\n\n setVolume(volume: number) {\n this.videoElement.volume = volume;\n }\n\n setLooping(looping: boolean) {\n this.videoElement.loop = looping;\n }\n\n isPlaying() {\n return !this.videoElement.paused && !this.videoElement.ended;\n }\n\n [Symbol.dispose]() {\n if (this.videoElement.parentNode) {\n this.videoElement.parentNode.removeChild(this.videoElement);\n }\n }\n\n dispose() {\n this[Symbol.dispose]();\n }\n}\n"],"mappings":";;;AAIA,SAASA,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,0BAA0B,QAAQ,QAAQ;AAEnD,OAAO,MAAMC,WAAW,GAAG,MAAAA,CACzBC,SAAoB,EACpBC,GAAW,KACQ;EACnB,MAAMC,KAAK,GAAGC,QAAQ,CA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E;MAChC,IAAI,CAAC9B,YAAY,CAAC8B,UAAU,CAACC,WAAW,CAAC,IAAI,CAAC/B,YAAY,CAAC;IAC7D;EACF;EAEA6B,OAAOA,CAAA,EAAG;IACR,IAAI,CAACD,MAAM,CAACC,OAAO,CAAC,CAAC,CAAC;EACxB;AACF","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
- import type { SkImage } from "../../skia/types";
3
- type MaybeAnimated<T> = SharedValue<T> | T;
4
- interface PlaybackOptions {
5
- looping: MaybeAnimated<boolean>;
6
- paused: MaybeAnimated<boolean>;
7
- seek: MaybeAnimated<number | null>;
8
- volume: MaybeAnimated<number>;
9
- }
10
- export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => {
11
- currentFrame: SharedValue<SkImage | null>;
12
- currentTime: SharedValue<number>;
13
- duration: number;
14
- framerate: number;
15
- rotation: import("../../skia/types").VideoRotation;
16
- size: {
17
- width: number;
18
- height: number;
19
- };
20
- };
21
- export {};
@@ -1,4 +0,0 @@
1
- import type { Video } from "../../skia/types";
2
- type VideoSource = string | null;
3
- export declare const useVideoLoading: (source: VideoSource) => Video | null;
4
- export {};
@@ -1,4 +0,0 @@
1
- import type { Video } from "../../skia/types";
2
- type VideoSource = string | null;
3
- export declare const useVideoLoading: (source: VideoSource) => Video | null;
4
- export {};
@@ -1,29 +0,0 @@
1
- import type { SkImage } from "../Image";
2
- export declare abstract class CanvasKitWebGLBuffer {
3
- }
4
- export type NativeBuffer<T extends bigint | ArrayBuffer | CanvasImageSource | CanvasKitWebGLBuffer | unknown = unknown> = T;
5
- export type NativeBufferAddr = NativeBuffer<bigint>;
6
- export type NativeBufferWeb = NativeBuffer<CanvasImageSource>;
7
- export type NativeBufferNode = NativeBuffer<ArrayBuffer>;
8
- export declare const isNativeBufferAddr: (buffer: NativeBuffer) => buffer is NativeBufferAddr;
9
- export declare const isNativeBufferWeb: (buffer: NativeBuffer) => buffer is NativeBufferWeb;
10
- export declare const isNativeBufferNode: (buffer: NativeBuffer) => buffer is NativeBufferNode;
11
- export interface NativeBufferFactory {
12
- /**
13
- * Copy pixels to a native buffer.
14
- */
15
- MakeFromImage: (image: SkImage) => NativeBuffer;
16
- /**
17
- * Create a native buffer of the given size filled with a procedural test
18
- * pattern (RGB gradient + diagonal stripes), entirely on the CPU. Useful for
19
- * examples and tests that need a buffer to feed into
20
- * `GPUDevice.importExternalTexture` without a camera/video source. Release it
21
- * with `Release`.
22
- */
23
- MakeTestBuffer: (width: number, height: number) => NativeBuffer;
24
- /**
25
- * Release a native buffer that was created with `MakeFromImage` or
26
- * `MakeTestBuffer`.
27
- */
28
- Release: (nativeBuffer: NativeBuffer) => void;
29
- }
@@ -1 +0,0 @@
1
- export * from "./NativeBufferFactory";
@@ -1,20 +0,0 @@
1
- import type { SkImage } from "../Image";
2
- import type { SkJSIInstance } from "../JsiInstance";
3
- export type VideoRotation = 0 | 90 | 180 | 270;
4
- export interface Video extends SkJSIInstance<"Video"> {
5
- duration(): number;
6
- framerate(): number;
7
- currentTime(): number;
8
- nextImage(): SkImage | null;
9
- seek(time: number): void;
10
- rotation(): VideoRotation;
11
- size(): {
12
- width: number;
13
- height: number;
14
- };
15
- pause(): void;
16
- play(): void;
17
- setVolume(volume: number): void;
18
- setLooping(looping: boolean): void;
19
- isPlaying(): boolean;
20
- }
@@ -1 +0,0 @@
1
- export * from "./Video";
@@ -1,9 +0,0 @@
1
- import type { Surface, TextureSource, Image } from "canvaskit-wasm";
2
- import { CanvasKitWebGLBuffer } from "../types";
3
- export declare class CanvasKitWebGLBufferImpl extends CanvasKitWebGLBuffer {
4
- surface: Surface;
5
- private source;
6
- image: Image | null;
7
- constructor(surface: Surface, source: TextureSource);
8
- toImage(): Image;
9
- }
@@ -1,9 +0,0 @@
1
- import type { CanvasKit } from "canvaskit-wasm";
2
- import type { NativeBuffer, NativeBufferFactory, SkImage } from "../types";
3
- import { Host } from "./Host";
4
- export declare class JsiSkNativeBufferFactory extends Host implements NativeBufferFactory {
5
- constructor(CanvasKit: CanvasKit);
6
- MakeFromImage(image: SkImage): NativeBuffer;
7
- MakeTestBuffer(width: number, height: number): NativeBuffer;
8
- Release(_nativeBuffer: NativeBuffer): void;
9
- }
@@ -1,28 +0,0 @@
1
- import type { CanvasKit, Surface } from "canvaskit-wasm";
2
- import type { Video, ImageFactory } from "../types";
3
- export declare const createVideo: (CanvasKit: CanvasKit, url: string) => Promise<Video>;
4
- export declare class JsiVideo implements Video {
5
- private ImageFactory;
6
- private videoElement;
7
- __typename__: "Video";
8
- private webglBuffer;
9
- constructor(ImageFactory: ImageFactory, videoElement: HTMLVideoElement);
10
- duration(): number;
11
- framerate(): number;
12
- currentTime(): number;
13
- setSurface(surface: Surface): void;
14
- nextImage(): import("../types").SkImage;
15
- seek(time: number): void;
16
- rotation(): 0;
17
- size(): {
18
- width: number;
19
- height: number;
20
- };
21
- pause(): void;
22
- play(): void;
23
- setVolume(volume: number): void;
24
- setLooping(looping: boolean): void;
25
- isPlaying(): boolean;
26
- [Symbol.dispose](): void;
27
- dispose(): void;
28
- }
@@ -1,161 +0,0 @@
1
- import type { SharedValue, FrameInfo } from "react-native-reanimated";
2
- import { useEffect, useMemo } from "react";
3
-
4
- import type { SkImage, Video } from "../../skia/types";
5
- import { Platform } from "../../Platform";
6
-
7
- import Rea from "./ReanimatedProxy";
8
- import { useVideoLoading } from "./useVideoLoading";
9
-
10
- type MaybeAnimated<T> = SharedValue<T> | T;
11
-
12
- interface PlaybackOptions {
13
- looping: MaybeAnimated<boolean>;
14
- paused: MaybeAnimated<boolean>;
15
- seek: MaybeAnimated<number | null>;
16
- volume: MaybeAnimated<number>;
17
- }
18
-
19
- const copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {
20
- "worklet";
21
- // on android we need to copy the texture before it's invalidated
22
- if (Platform.OS === "android") {
23
- const tex = currentFrame.value;
24
- if (tex) {
25
- const copy = tex.makeNonTextureImage();
26
- if (copy) {
27
- currentFrame.value = copy;
28
- tex.dispose();
29
- }
30
- // If copy fails, keep the original frame rather than showing black
31
- }
32
- }
33
- };
34
-
35
- const setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {
36
- "worklet";
37
- const img = video.nextImage();
38
- if (img) {
39
- currentFrame.value?.dispose();
40
- currentFrame.value = img;
41
- copyFrameOnAndroid(currentFrame);
42
- }
43
- };
44
-
45
- const defaultOptions = {
46
- looping: true,
47
- paused: false,
48
- seek: null,
49
- volume: 0,
50
- };
51
-
52
- const useOption = <T>(value: MaybeAnimated<T>) => {
53
- "worklet";
54
- const defaultValue = Rea.useSharedValue(
55
- Rea.isSharedValue(value) ? value.value : value
56
- );
57
- return Rea.isSharedValue(value)
58
- ? (value as SharedValue<T>)
59
- : (defaultValue as SharedValue<T>);
60
- };
61
-
62
- const disposeVideo = (video: Video | null) => {
63
- "worklet";
64
- video?.dispose();
65
- };
66
-
67
- export const useVideo = (
68
- source: string | null,
69
- userOptions?: Partial<PlaybackOptions>
70
- ) => {
71
- const video = useVideoLoading(source);
72
- const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);
73
- const looping = useOption(userOptions?.looping ?? defaultOptions.looping);
74
- const seek = useOption(userOptions?.seek ?? defaultOptions.seek);
75
- const volume = useOption(userOptions?.volume ?? defaultOptions.volume);
76
- const currentFrame = Rea.useSharedValue<null | SkImage>(null);
77
- const currentTime = Rea.useSharedValue(0);
78
- const duration = useMemo(() => video?.duration() ?? 0, [video]);
79
- const framerate = useMemo(
80
- () => (Platform.OS === "web" ? -1 : (video?.framerate() ?? 0)),
81
- [video]
82
- );
83
- const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);
84
- const rotation = useMemo(() => video?.rotation() ?? 0, [video]);
85
-
86
- // Handle pause/play state changes
87
- Rea.useAnimatedReaction(
88
- () => isPaused.value,
89
- (paused) => {
90
- if (paused) {
91
- video?.pause();
92
- } else {
93
- video?.play();
94
- }
95
- }
96
- );
97
-
98
- // Handle seek
99
- Rea.useAnimatedReaction(
100
- () => seek.value,
101
- (value) => {
102
- if (value !== null) {
103
- video?.seek(value);
104
- seek.value = null;
105
- }
106
- }
107
- );
108
-
109
- // Handle volume changes
110
- Rea.useAnimatedReaction(
111
- () => volume.value,
112
- (value) => {
113
- video?.setVolume(value);
114
- }
115
- );
116
-
117
- // Handle looping changes
118
- Rea.useAnimatedReaction(
119
- () => looping.value,
120
- (value) => {
121
- video?.setLooping(value);
122
- }
123
- );
124
-
125
- // Frame callback - simplified since native handles frame timing
126
- Rea.useFrameCallback((_frameInfo: FrameInfo) => {
127
- "worklet";
128
- if (!video) {
129
- return;
130
- }
131
- // Update current time from native player
132
- currentTime.value = video.currentTime();
133
- // Get the latest frame (native handles timing via CADisplayLink/etc)
134
- setFrame(video, currentFrame);
135
- });
136
-
137
- // Apply initial state when video becomes available
138
- useEffect(() => {
139
- if (video) {
140
- video.setLooping(looping.value);
141
- video.setVolume(volume.value);
142
- if (isPaused.value) {
143
- video.pause();
144
- } else {
145
- video.play();
146
- }
147
- }
148
- return () => {
149
- Rea.runOnUI(disposeVideo)(video);
150
- };
151
- }, [video, isPaused, looping, volume]);
152
-
153
- return {
154
- currentFrame,
155
- currentTime,
156
- duration,
157
- framerate,
158
- rotation,
159
- size,
160
- };
161
- };
@@ -1,39 +0,0 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- import type { WorkletRuntime } from "react-native-reanimated";
3
-
4
- import type { Video } from "../../skia/types";
5
- import { Skia } from "../../skia";
6
-
7
- import Rea from "./ReanimatedProxy";
8
-
9
- // Created lazily: accessing the proxy at module scope would require
10
- // react-native-reanimated as soon as the package is imported, and would spawn
11
- // the runtime even for apps that never load a video.
12
- let runtime: WorkletRuntime | undefined;
13
- const getRuntime = () => {
14
- if (runtime === undefined) {
15
- runtime = Rea.createWorkletRuntime("video-metadata-runtime");
16
- }
17
- return runtime;
18
- };
19
-
20
- type VideoSource = string | null;
21
-
22
- export const useVideoLoading = (source: VideoSource) => {
23
- const { runOnJS } = Rea;
24
- const [video, setVideo] = useState<Video | null>(null);
25
- const cb = useCallback(
26
- (src: string) => {
27
- "worklet";
28
- const vid = Skia.Video(src) as Video;
29
- runOnJS(setVideo)(vid);
30
- },
31
- [runOnJS]
32
- );
33
- useEffect(() => {
34
- if (source) {
35
- Rea.runOnRuntime(getRuntime(), cb)(source);
36
- }
37
- }, [cb, source]);
38
- return video;
39
- };
@@ -1,17 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- import type { Video } from "../../skia/types";
4
- import { Skia } from "../../skia";
5
-
6
- type VideoSource = string | null;
7
-
8
- export const useVideoLoading = (source: VideoSource) => {
9
- const [video, setVideo] = useState<Video | null>(null);
10
- useEffect(() => {
11
- if (source) {
12
- const vid = Skia.Video(source) as Promise<Video>;
13
- vid.then((v) => setVideo(v));
14
- }
15
- }, [source]);
16
- return video;
17
- };
@@ -1,52 +0,0 @@
1
- import type { SkImage } from "../Image";
2
-
3
- export abstract class CanvasKitWebGLBuffer {}
4
-
5
- export type NativeBuffer<
6
- T extends
7
- bigint | ArrayBuffer | CanvasImageSource | CanvasKitWebGLBuffer | unknown =
8
- unknown,
9
- > = T;
10
-
11
- export type NativeBufferAddr = NativeBuffer<bigint>;
12
- export type NativeBufferWeb = NativeBuffer<CanvasImageSource>;
13
- export type NativeBufferNode = NativeBuffer<ArrayBuffer>;
14
-
15
- export const isNativeBufferAddr = (
16
- buffer: NativeBuffer
17
- ): buffer is NativeBufferAddr => buffer instanceof BigInt;
18
- export const isNativeBufferWeb = (
19
- buffer: NativeBuffer
20
- ): buffer is NativeBufferWeb =>
21
- buffer instanceof HTMLVideoElement ||
22
- buffer instanceof HTMLCanvasElement ||
23
- buffer instanceof ImageBitmap ||
24
- buffer instanceof OffscreenCanvas ||
25
- (typeof VideoFrame !== "undefined" && buffer instanceof VideoFrame) ||
26
- buffer instanceof HTMLImageElement ||
27
- buffer instanceof SVGImageElement ||
28
- buffer instanceof CanvasKitWebGLBuffer;
29
-
30
- export const isNativeBufferNode = (
31
- buffer: NativeBuffer
32
- ): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;
33
-
34
- export interface NativeBufferFactory {
35
- /**
36
- * Copy pixels to a native buffer.
37
- */
38
- MakeFromImage: (image: SkImage) => NativeBuffer;
39
- /**
40
- * Create a native buffer of the given size filled with a procedural test
41
- * pattern (RGB gradient + diagonal stripes), entirely on the CPU. Useful for
42
- * examples and tests that need a buffer to feed into
43
- * `GPUDevice.importExternalTexture` without a camera/video source. Release it
44
- * with `Release`.
45
- */
46
- MakeTestBuffer: (width: number, height: number) => NativeBuffer;
47
- /**
48
- * Release a native buffer that was created with `MakeFromImage` or
49
- * `MakeTestBuffer`.
50
- */
51
- Release: (nativeBuffer: NativeBuffer) => void;
52
- }
@@ -1 +0,0 @@
1
- export * from "./NativeBufferFactory";
@@ -1,19 +0,0 @@
1
- import type { SkImage } from "../Image";
2
- import type { SkJSIInstance } from "../JsiInstance";
3
-
4
- export type VideoRotation = 0 | 90 | 180 | 270;
5
-
6
- export interface Video extends SkJSIInstance<"Video"> {
7
- duration(): number;
8
- framerate(): number;
9
- currentTime(): number;
10
- nextImage(): SkImage | null;
11
- seek(time: number): void;
12
- rotation(): VideoRotation;
13
- size(): { width: number; height: number };
14
- pause(): void;
15
- play(): void;
16
- setVolume(volume: number): void;
17
- setLooping(looping: boolean): void;
18
- isPlaying(): boolean;
19
- }
@@ -1 +0,0 @@
1
- export * from "./Video";
@@ -1,25 +0,0 @@
1
- import type { Surface, TextureSource, Image } from "canvaskit-wasm";
2
-
3
- import { CanvasKitWebGLBuffer } from "../types";
4
-
5
- export class CanvasKitWebGLBufferImpl extends CanvasKitWebGLBuffer {
6
- public image: Image | null = null;
7
-
8
- constructor(
9
- public surface: Surface,
10
- private source: TextureSource
11
- ) {
12
- super();
13
- }
14
-
15
- toImage() {
16
- if (this.image === null) {
17
- this.image = this.surface.makeImageFromTextureSource(this.source);
18
- }
19
- if (this.image === null) {
20
- throw new Error("Failed to create image from texture source");
21
- }
22
- this.surface.updateTextureFromSource(this.image, this.source);
23
- return this.image;
24
- }
25
- }
@@ -1,51 +0,0 @@
1
- import type { CanvasKit } from "canvaskit-wasm";
2
-
3
- import type { NativeBuffer, NativeBufferFactory, SkImage } from "../types";
4
-
5
- import { Host } from "./Host";
6
-
7
- export class JsiSkNativeBufferFactory
8
- extends Host
9
- implements NativeBufferFactory
10
- {
11
- constructor(CanvasKit: CanvasKit) {
12
- super(CanvasKit);
13
- }
14
-
15
- MakeFromImage(image: SkImage): NativeBuffer {
16
- const info = image.getImageInfo();
17
- const uint8ClampedArray = new Uint8ClampedArray(image.readPixels()!);
18
- const imageData = new ImageData(uint8ClampedArray, info.width, info.height);
19
- const canvas = new OffscreenCanvas(info.width, info.height);
20
- const ctx = canvas.getContext("2d");
21
- if (!ctx) {
22
- throw new Error("Failed to get 2d context from canvas");
23
- }
24
- ctx.putImageData(imageData, 0, 0);
25
- return canvas;
26
- }
27
-
28
- MakeTestBuffer(width: number, height: number): NativeBuffer {
29
- const pixels = new Uint8ClampedArray(width * height * 4);
30
- for (let y = 0; y < height; y++) {
31
- for (let x = 0; x < width; x++) {
32
- const i = (y * width + x) * 4;
33
- pixels[i + 0] = Math.floor((x * 255) / Math.max(width - 1, 1));
34
- pixels[i + 1] = Math.floor((y * 255) / Math.max(height - 1, 1));
35
- pixels[i + 2] = (x + y) & 0x20 ? 220 : 30;
36
- pixels[i + 3] = 0xff;
37
- }
38
- }
39
- const canvas = new OffscreenCanvas(width, height);
40
- const ctx = canvas.getContext("2d");
41
- if (!ctx) {
42
- throw new Error("Failed to get 2d context from canvas");
43
- }
44
- ctx.putImageData(new ImageData(pixels, width, height), 0, 0);
45
- return canvas;
46
- }
47
-
48
- Release(_nativeBuffer: NativeBuffer) {
49
- // it's a noop on Web
50
- }
51
- }