@shopify/react-native-skia 1.2.0 → 1.2.2

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 (182) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +3 -3
  2. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +13 -8
  3. package/cpp/api/JsiNativeBuffer.h +43 -0
  4. package/cpp/api/JsiSkApi.h +3 -3
  5. package/cpp/api/JsiSkImageFactory.h +3 -3
  6. package/cpp/rnskia/RNSkPlatformContext.h +5 -5
  7. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +3 -3
  8. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +70 -93
  9. package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.h +119 -0
  10. package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +332 -0
  11. package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.h +2 -1
  12. package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +27 -6
  13. package/lib/commonjs/external/ModuleProxy.d.ts +10 -0
  14. package/lib/commonjs/external/ModuleProxy.js +36 -0
  15. package/lib/commonjs/external/ModuleProxy.js.map +1 -0
  16. package/lib/commonjs/external/reanimated/ReanimatedProxy.d.ts +3 -0
  17. package/lib/commonjs/external/reanimated/ReanimatedProxy.js +18 -0
  18. package/lib/commonjs/external/reanimated/ReanimatedProxy.js.map +1 -0
  19. package/lib/commonjs/external/reanimated/buffers.js +9 -6
  20. package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
  21. package/lib/commonjs/external/reanimated/interpolators.js +8 -7
  22. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  23. package/lib/commonjs/external/reanimated/renderHelpers.js +27 -11
  24. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  25. package/lib/commonjs/external/reanimated/textures.js +4 -3
  26. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  27. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +6 -6
  28. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  29. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +6 -5
  30. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  31. package/lib/commonjs/renderer/Offscreen.js +1 -5
  32. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  33. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +8 -15
  34. package/lib/commonjs/skia/types/Image/ImageFactory.js +1 -10
  35. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  36. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +18 -0
  37. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +13 -0
  38. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -0
  39. package/lib/commonjs/skia/types/NativeBuffer/index.d.ts +1 -0
  40. package/lib/commonjs/skia/types/NativeBuffer/index.js +17 -0
  41. package/lib/commonjs/skia/types/NativeBuffer/index.js.map +1 -0
  42. package/lib/commonjs/skia/types/Skia.d.ts +2 -2
  43. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  44. package/lib/commonjs/skia/types/index.d.ts +1 -1
  45. package/lib/commonjs/skia/types/index.js +4 -4
  46. package/lib/commonjs/skia/types/index.js.map +1 -1
  47. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +3 -2
  48. package/lib/commonjs/skia/web/JsiSkImageFactory.js +18 -2
  49. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +8 -0
  51. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +29 -0
  52. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +1 -0
  53. package/lib/commonjs/skia/web/JsiSkia.js +2 -2
  54. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  55. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +0 -2
  56. package/lib/commonjs/specs/NativeSkiaModule.web.js +0 -8
  57. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  58. package/lib/module/external/ModuleProxy.d.ts +10 -0
  59. package/lib/module/external/ModuleProxy.js +28 -0
  60. package/lib/module/external/ModuleProxy.js.map +1 -0
  61. package/lib/module/external/reanimated/ReanimatedProxy.d.ts +3 -0
  62. package/lib/module/external/reanimated/ReanimatedProxy.js +12 -0
  63. package/lib/module/external/reanimated/ReanimatedProxy.js.map +1 -0
  64. package/lib/module/external/reanimated/buffers.js +8 -6
  65. package/lib/module/external/reanimated/buffers.js.map +1 -1
  66. package/lib/module/external/reanimated/interpolators.js +7 -7
  67. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  68. package/lib/module/external/reanimated/renderHelpers.js +26 -11
  69. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  70. package/lib/module/external/reanimated/textures.js +3 -3
  71. package/lib/module/external/reanimated/textures.js.map +1 -1
  72. package/lib/module/external/reanimated/useAnimatedImageValue.js +5 -6
  73. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  74. package/lib/module/external/reanimated/useDerivedValueOnJS.js +5 -5
  75. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  76. package/lib/module/renderer/Offscreen.js +1 -5
  77. package/lib/module/renderer/Offscreen.js.map +1 -1
  78. package/lib/module/skia/types/Image/ImageFactory.d.ts +8 -15
  79. package/lib/module/skia/types/Image/ImageFactory.js +1 -10
  80. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  81. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +18 -0
  82. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +4 -0
  83. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -0
  84. package/lib/module/skia/types/NativeBuffer/index.d.ts +1 -0
  85. package/lib/module/skia/types/NativeBuffer/index.js +2 -0
  86. package/lib/module/skia/types/NativeBuffer/index.js.map +1 -0
  87. package/lib/module/skia/types/Skia.d.ts +2 -2
  88. package/lib/module/skia/types/Skia.js.map +1 -1
  89. package/lib/module/skia/types/index.d.ts +1 -1
  90. package/lib/module/skia/types/index.js +1 -1
  91. package/lib/module/skia/types/index.js.map +1 -1
  92. package/lib/module/skia/web/JsiSkImageFactory.d.ts +3 -2
  93. package/lib/module/skia/web/JsiSkImageFactory.js +18 -2
  94. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  95. package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +8 -0
  96. package/lib/module/skia/web/JsiSkNativeBufferFactory.js +22 -0
  97. package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +1 -0
  98. package/lib/module/skia/web/JsiSkia.js +2 -2
  99. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  100. package/lib/module/specs/NativeSkiaModule.web.d.ts +0 -2
  101. package/lib/module/specs/NativeSkiaModule.web.js +0 -3
  102. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  103. package/lib/typescript/src/external/ModuleProxy.d.ts +10 -0
  104. package/lib/typescript/src/external/reanimated/ReanimatedProxy.d.ts +3 -0
  105. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +8 -15
  106. package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +18 -0
  107. package/lib/typescript/src/skia/types/NativeBuffer/index.d.ts +1 -0
  108. package/lib/typescript/src/skia/types/Skia.d.ts +2 -2
  109. package/lib/typescript/src/skia/types/index.d.ts +1 -1
  110. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +3 -2
  111. package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +8 -0
  112. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +0 -2
  113. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  114. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  115. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  116. package/libs/ios/libskottie.xcframework/Info.plist +5 -5
  117. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  118. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  119. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  120. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  121. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  122. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  123. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  124. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  125. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  126. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  127. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  128. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  129. package/package.json +1 -1
  130. package/src/external/ModuleProxy.ts +30 -0
  131. package/src/external/reanimated/ReanimatedProxy.ts +18 -0
  132. package/src/external/reanimated/buffers.ts +7 -6
  133. package/src/external/reanimated/interpolators.ts +7 -12
  134. package/src/external/reanimated/renderHelpers.ts +31 -18
  135. package/src/external/reanimated/textures.tsx +3 -3
  136. package/src/external/reanimated/useAnimatedImageValue.ts +5 -10
  137. package/src/external/reanimated/useDerivedValueOnJS.ts +5 -10
  138. package/src/renderer/Offscreen.tsx +1 -7
  139. package/src/skia/types/Image/ImageFactory.ts +7 -23
  140. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +38 -0
  141. package/src/skia/types/NativeBuffer/index.ts +1 -0
  142. package/src/skia/types/Skia.ts +2 -2
  143. package/src/skia/types/index.ts +1 -1
  144. package/src/skia/web/JsiSkImageFactory.ts +28 -6
  145. package/src/skia/web/JsiSkNativeBufferFactory.ts +35 -0
  146. package/src/skia/web/JsiSkia.ts +2 -2
  147. package/src/specs/NativeSkiaModule.web.ts +0 -4
  148. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDrawViewManagerDelegate.java +0 -34
  149. package/cpp/api/JsiPlatformBuffer.h +0 -51
  150. package/cpp/skia/include/gpu/GrBackendDrawableInfo.h +0 -9
  151. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +0 -15
  152. package/lib/commonjs/external/reanimated/moduleWrapper.js +0 -46
  153. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +0 -1
  154. package/lib/commonjs/skia/types/PlatformBuffer/PlatformBufferFactory.d.ts +0 -12
  155. package/lib/commonjs/skia/types/PlatformBuffer/PlatformBufferFactory.js +0 -6
  156. package/lib/commonjs/skia/types/PlatformBuffer/PlatformBufferFactory.js.map +0 -1
  157. package/lib/commonjs/skia/types/PlatformBuffer/index.d.ts +0 -1
  158. package/lib/commonjs/skia/types/PlatformBuffer/index.js +0 -17
  159. package/lib/commonjs/skia/types/PlatformBuffer/index.js.map +0 -1
  160. package/lib/commonjs/skia/web/JsiSkPlatformBufferFactory.d.ts +0 -8
  161. package/lib/commonjs/skia/web/JsiSkPlatformBufferFactory.js +0 -20
  162. package/lib/commonjs/skia/web/JsiSkPlatformBufferFactory.js.map +0 -1
  163. package/lib/module/external/reanimated/moduleWrapper.d.ts +0 -15
  164. package/lib/module/external/reanimated/moduleWrapper.js +0 -37
  165. package/lib/module/external/reanimated/moduleWrapper.js.map +0 -1
  166. package/lib/module/skia/types/PlatformBuffer/PlatformBufferFactory.d.ts +0 -12
  167. package/lib/module/skia/types/PlatformBuffer/PlatformBufferFactory.js +0 -2
  168. package/lib/module/skia/types/PlatformBuffer/PlatformBufferFactory.js.map +0 -1
  169. package/lib/module/skia/types/PlatformBuffer/index.d.ts +0 -1
  170. package/lib/module/skia/types/PlatformBuffer/index.js +0 -2
  171. package/lib/module/skia/types/PlatformBuffer/index.js.map +0 -1
  172. package/lib/module/skia/web/JsiSkPlatformBufferFactory.d.ts +0 -8
  173. package/lib/module/skia/web/JsiSkPlatformBufferFactory.js +0 -13
  174. package/lib/module/skia/web/JsiSkPlatformBufferFactory.js.map +0 -1
  175. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +0 -15
  176. package/lib/typescript/src/skia/types/PlatformBuffer/PlatformBufferFactory.d.ts +0 -12
  177. package/lib/typescript/src/skia/types/PlatformBuffer/index.d.ts +0 -1
  178. package/lib/typescript/src/skia/web/JsiSkPlatformBufferFactory.d.ts +0 -8
  179. package/src/external/reanimated/moduleWrapper.ts +0 -83
  180. package/src/skia/types/PlatformBuffer/PlatformBufferFactory.ts +0 -14
  181. package/src/skia/types/PlatformBuffer/index.ts +0 -1
  182. package/src/skia/web/JsiSkPlatformBufferFactory.ts +0 -22
@@ -4,11 +4,7 @@ import { type FrameInfo, type SharedValue } from "react-native-reanimated";
4
4
  import { useAnimatedImage } from "../../skia/core/AnimatedImage";
5
5
  import type { DataSourceParam, SkImage } from "../../skia/types";
6
6
 
7
- import {
8
- throwOnMissingReanimated,
9
- useFrameCallback,
10
- useSharedValue,
11
- } from "./moduleWrapper";
7
+ import Rea from "./ReanimatedProxy";
12
8
 
13
9
  const DEFAULT_FRAME_DURATION = 60;
14
10
 
@@ -16,11 +12,10 @@ export const useAnimatedImageValue = (
16
12
  source: DataSourceParam,
17
13
  paused?: SharedValue<boolean>
18
14
  ) => {
19
- throwOnMissingReanimated();
20
- const defaultPaused = useSharedValue(false);
15
+ const defaultPaused = Rea.useSharedValue(false);
21
16
  const isPaused = paused ?? defaultPaused;
22
- const currentFrame = useSharedValue<null | SkImage>(null);
23
- const lastTimestamp = useSharedValue(-1);
17
+ const currentFrame = Rea.useSharedValue<null | SkImage>(null);
18
+ const lastTimestamp = Rea.useSharedValue(-1);
24
19
  const animatedImage = useAnimatedImage(
25
20
  source,
26
21
  (err) => {
@@ -32,7 +27,7 @@ export const useAnimatedImageValue = (
32
27
  const frameDuration =
33
28
  animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;
34
29
 
35
- useFrameCallback((frameInfo: FrameInfo) => {
30
+ Rea.useFrameCallback((frameInfo: FrameInfo) => {
36
31
  if (!animatedImage) {
37
32
  currentFrame.value = null;
38
33
  return;
@@ -1,11 +1,6 @@
1
1
  import { useEffect, useMemo } from "react";
2
2
 
3
- import {
4
- useSharedValue,
5
- runOnJS,
6
- startMapper,
7
- stopMapper,
8
- } from "./moduleWrapper";
3
+ import Rea from "./ReanimatedProxy";
9
4
 
10
5
  export const useDerivedValueOnJS = (
11
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -13,13 +8,13 @@ export const useDerivedValueOnJS = (
13
8
  deps: unknown[]
14
9
  ) => {
15
10
  const init = useMemo(() => fn(), [fn]);
16
- const value = useSharedValue(init);
11
+ const value = Rea.useSharedValue(init);
17
12
  useEffect(() => {
18
- const mapperId = startMapper(() => {
13
+ const mapperId = Rea.startMapper(() => {
19
14
  "worklet";
20
- runOnJS(fn)();
15
+ Rea.runOnJS(fn)();
21
16
  }, deps);
22
- return () => stopMapper(mapperId);
17
+ return () => Rea.stopMapper(mapperId);
23
18
  }, [deps, fn]);
24
19
  return value;
25
20
  };
@@ -32,16 +32,10 @@ export const drawAsImage = (element: ReactElement, size: SkSize) => {
32
32
  return drawAsImageFromPicture(drawAsPicture(element), size);
33
33
  };
34
34
 
35
- // TODO: We're not sure yet why PixelRatio is not needed here.
36
- const pd = 1;
37
35
  export const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {
38
36
  "worklet";
39
- const surface = Skia.Surface.MakeOffscreen(
40
- size.width * pd,
41
- size.height * pd
42
- )!;
37
+ const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;
43
38
  const canvas = surface.getCanvas();
44
- canvas.scale(pd, pd);
45
39
  canvas.drawPicture(picture);
46
40
  surface.flush();
47
41
  const image = surface.makeImageSnapshot();
@@ -1,4 +1,5 @@
1
1
  import type { SkData } from "../Data";
2
+ import type { NativeBuffer } from "../NativeBuffer";
2
3
 
3
4
  import type { SkImage } from "./Image";
4
5
 
@@ -27,24 +28,6 @@ export enum ColorType {
27
28
  RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
28
29
  RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word
29
30
  RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word
30
-
31
- // The following 6 colortypes are just for reading from - not for rendering to
32
- R8G8_unorm, // pixel with a uint8_t for red and green
33
-
34
- A16_float, // pixel with a half float for alpha
35
- R16G16_float, // pixel with a half float for red and green
36
-
37
- A16_unorm, // pixel with a little endian uint16_t for alpha
38
- R16G16_unorm, // pixel with a little endian uint16_t for red and green
39
- R16G16B16A16_unorm, // pixel with a little endian uint16_t for red, green, blue, and alpha
40
-
41
- SRGBA_8888,
42
- R8_unorm,
43
-
44
- // The `kN32_SkColorType` is platform dependent in the original enum,
45
- // and TypeScript doesn't support conditional compilation natively.
46
- // You might need to handle it differently based on your use case.
47
- N32_SkColorType, // either BGRA_8888 or RGBA_8888 based on the platform
48
31
  }
49
32
 
50
33
  export interface ImageInfo {
@@ -70,19 +53,20 @@ export interface ImageFactory {
70
53
  MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
71
54
 
72
55
  /**
73
- * Return an Image backed by the given native platform buffer.
56
+ * Return an Image backed by a given native buffer.
74
57
  * The platform buffer must be a valid owning reference.
75
58
  *
76
- * This API is used by [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
59
+ * For instance, this API is used by
60
+ * [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
77
61
  * to render a Skia Camera preview.
78
62
  *
79
63
  * - On Android; This is an `AHardwareBuffer*`
80
- * - On iOS, this is a `CMSampleBufferRef`
81
- * @param platformBuffer A strong `uintptr_t` pointer to the native platform buffer
64
+ * - On iOS, this is a `CVPixelBufferRef`
65
+ * @param nativeBuffer A strong `uintptr_t` pointer to the native platform buffer
82
66
  * @throws Throws an error if the Image could not be created, for example when the given
83
67
  * platform buffer is invalid.
84
68
  */
85
- MakeImageFromPlatformBuffer: (platformBuffer: bigint) => SkImage;
69
+ MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;
86
70
 
87
71
  /**
88
72
  * Returns an image that will be a screenshot of the view represented by
@@ -0,0 +1,38 @@
1
+ import type { SkImage } from "../Image";
2
+
3
+ export type NativeBuffer<
4
+ T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown
5
+ > = T;
6
+
7
+ export type NativeBufferAddr = NativeBuffer<bigint>;
8
+ export type NativeBufferWeb = NativeBuffer<CanvasImageSource>;
9
+ export type NativeBufferNode = NativeBuffer<ArrayBuffer>;
10
+
11
+ export const isNativeBufferAddr = (
12
+ buffer: NativeBuffer
13
+ ): buffer is NativeBufferAddr => buffer instanceof BigInt;
14
+ export const isNativeBufferWeb = (
15
+ buffer: NativeBuffer
16
+ ): buffer is NativeBufferWeb =>
17
+ buffer instanceof HTMLVideoElement ||
18
+ buffer instanceof HTMLCanvasElement ||
19
+ buffer instanceof ImageBitmap ||
20
+ buffer instanceof OffscreenCanvas ||
21
+ buffer instanceof VideoFrame ||
22
+ buffer instanceof HTMLImageElement ||
23
+ buffer instanceof SVGImageElement;
24
+
25
+ export const isNativeBufferNode = (
26
+ buffer: NativeBuffer
27
+ ): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;
28
+
29
+ export interface NativeBufferFactory {
30
+ /**
31
+ * Copy pixels to a native buffer.
32
+ */
33
+ MakeFromImage: (image: SkImage) => NativeBuffer;
34
+ /**
35
+ * Release a platform buffer that was created with `MakeFromImage`.
36
+ */
37
+ Release: (platformBuffer: NativeBuffer) => void;
38
+ }
@@ -0,0 +1 @@
1
+ export * from "./NativeBufferFactory";
@@ -30,7 +30,7 @@ import type { Color, SkColor } from "./Color";
30
30
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
31
31
  import type { AnimatedImageFactory } from "./AnimatedImage";
32
32
  import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
33
- import type { PlatformBufferFactory } from "./PlatformBuffer";
33
+ import type { NativeBufferFactory } from "./NativeBuffer";
34
34
 
35
35
  /**
36
36
  * Declares the interface for the native Skia API
@@ -95,5 +95,5 @@ export interface Skia {
95
95
  TextBlob: TextBlobFactory;
96
96
  Surface: SurfaceFactory;
97
97
  ParagraphBuilder: ParagraphBuilderFactory;
98
- PlatformBuffer: PlatformBufferFactory;
98
+ NativeBuffer: NativeBufferFactory;
99
99
  }
@@ -29,4 +29,4 @@ export * from "./TextBlob";
29
29
  export * from "./Size";
30
30
  export * from "./Paragraph";
31
31
  export * from "./Matrix4";
32
- export * from "./PlatformBuffer";
32
+ export * from "./NativeBuffer";
@@ -1,16 +1,18 @@
1
- import type { CanvasKit } from "canvaskit-wasm";
1
+ import type { CanvasKit, Image } from "canvaskit-wasm";
2
2
 
3
+ import { isNativeBufferWeb } from "../types";
3
4
  import type {
4
5
  SkData,
5
6
  ImageInfo,
6
7
  SkImage,
7
- PlatformBuffer,
8
+ NativeBuffer,
8
9
  ImageFactory,
9
10
  } from "../types";
10
11
 
11
12
  import { Host, getEnum } from "./Host";
12
13
  import { JsiSkImage } from "./JsiSkImage";
13
14
  import { JsiSkData } from "./JsiSkData";
15
+ import type { JsiSkSurface } from "./JsiSkSurface";
14
16
 
15
17
  export class JsiSkImageFactory extends Host implements ImageFactory {
16
18
  constructor(CanvasKit: CanvasKit) {
@@ -24,10 +26,30 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
24
26
  return Promise.resolve(null);
25
27
  }
26
28
 
27
- MakeImageFromPlatformBuffer(_platformBuffer: PlatformBuffer): SkImage {
28
- throw new Error(
29
- "MakeImageFromPlatformBuffer() is only available on iOS and Android!"
30
- );
29
+ MakeImageFromNativeBuffer(
30
+ buffer: NativeBuffer,
31
+ surface?: JsiSkSurface,
32
+ image?: JsiSkImage
33
+ ) {
34
+ if (!isNativeBufferWeb(buffer)) {
35
+ throw new Error("Invalid NativeBuffer");
36
+ }
37
+ if (!surface) {
38
+ // TODO: this is way to slow
39
+ const img = this.CanvasKit.MakeImageFromCanvasImageSource(buffer);
40
+ return new JsiSkImage(this.CanvasKit, img);
41
+ } else if (!image) {
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ const img = (surface as any).makeImageFromTextureSource(buffer) as Image;
44
+ return new JsiSkImage(this.CanvasKit, img);
45
+ } else {
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ const img = (surface as any).updateTextureFromSource(
48
+ image,
49
+ buffer
50
+ ) as Image;
51
+ return new JsiSkImage(this.CanvasKit, img);
52
+ }
31
53
  }
32
54
 
33
55
  MakeImageFromEncoded(encoded: SkData) {
@@ -0,0 +1,35 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+
3
+ import {
4
+ type NativeBuffer,
5
+ type NativeBufferFactory,
6
+ type SkImage,
7
+ } from "../types";
8
+
9
+ import { Host } from "./Host";
10
+
11
+ export class JsiSkNativeBufferFactory
12
+ extends Host
13
+ implements NativeBufferFactory
14
+ {
15
+ constructor(CanvasKit: CanvasKit) {
16
+ super(CanvasKit);
17
+ }
18
+
19
+ MakeFromImage(image: SkImage): NativeBuffer {
20
+ const info = image.getImageInfo();
21
+ const uint8ClampedArray = new Uint8ClampedArray(image.readPixels()!);
22
+ const imageData = new ImageData(uint8ClampedArray, info.width, info.height);
23
+ const canvas = new OffscreenCanvas(info.width, info.height);
24
+ const ctx = canvas.getContext("2d");
25
+ if (!ctx) {
26
+ throw new Error("Failed to get 2d context from canvas");
27
+ }
28
+ ctx.putImageData(imageData, 0, 0);
29
+ return canvas;
30
+ }
31
+
32
+ Release(_platformBuffer: NativeBuffer) {
33
+ // it's a noop on Web
34
+ }
35
+ }
@@ -41,7 +41,7 @@ import { JsiSkTypefaceFontProviderFactory } from "./JsiSkTypefaceFontProviderFac
41
41
  import { JsiSkFontMgrFactory } from "./JsiSkFontMgrFactory";
42
42
  import { JsiSkAnimatedImageFactory } from "./JsiSkAnimatedImageFactory";
43
43
  import { JsiSkParagraphBuilderFactory } from "./JsiSkParagraphBuilderFactory";
44
- import { JsiSkPlatformBufferFactory } from "./JsiSkPlatformBufferFactory";
44
+ import { JsiSkNativeBufferFactory } from "./JsiSkNativeBufferFactory";
45
45
 
46
46
  export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
47
47
  Point: (x: number, y: number) =>
@@ -126,5 +126,5 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
126
126
  TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),
127
127
  FontMgr: new JsiSkFontMgrFactory(CanvasKit),
128
128
  ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),
129
- PlatformBuffer: new JsiSkPlatformBufferFactory(CanvasKit),
129
+ NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),
130
130
  });
@@ -1,4 +0,0 @@
1
- import { throwOnMissingReanimated } from "../external/reanimated/moduleWrapper";
2
-
3
- // eslint-disable-next-line import/no-default-export
4
- export default throwOnMissingReanimated;
@@ -1,34 +0,0 @@
1
- /**
2
- * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior and will be lost
5
- * once the code is regenerated.
6
- *
7
- * @generated by codegen project: GeneratePropsJavaDelegate.js
8
- */
9
-
10
- package com.facebook.react.viewmanagers;
11
-
12
- import android.view.View;
13
- import androidx.annotation.Nullable;
14
- import com.facebook.react.uimanager.BaseViewManagerDelegate;
15
- import com.facebook.react.uimanager.BaseViewManagerInterface;
16
-
17
- public class SkiaDrawViewManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & SkiaDrawViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
18
- public SkiaDrawViewManagerDelegate(U viewManager) {
19
- super(viewManager);
20
- }
21
- @Override
22
- public void setProperty(T view, String propName, @Nullable Object value) {
23
- switch (propName) {
24
- case "mode":
25
- mViewManager.setMode(view, value == null ? null : (String) value);
26
- break;
27
- case "debug":
28
- mViewManager.setDebug(view, value == null ? false : (boolean) value);
29
- break;
30
- default:
31
- super.setProperty(view, propName, value);
32
- }
33
- }
34
- }
@@ -1,51 +0,0 @@
1
- #pragma once
2
-
3
- #include <memory>
4
- #include <utility>
5
-
6
- #include <jsi/jsi.h>
7
-
8
- #include "JsiSkImage.h"
9
-
10
- namespace RNSkia {
11
-
12
- namespace jsi = facebook::jsi;
13
-
14
- /**
15
- Implementation of the ParagraphBuilderFactory for making ParagraphBuilder JSI
16
- object
17
- */
18
- class JsiPlatformBufferFactory : public JsiSkHostObject {
19
- public:
20
- JSI_HOST_FUNCTION(MakeFromImage) {
21
- auto image = JsiSkImage::fromValue(runtime, arguments[0]);
22
- image->makeNonTextureImage();
23
-
24
- uint64_t pointer = getContext()->makePlatformBuffer(image);
25
- jsi::HostFunctionType deleteFunc =
26
- [=](jsi::Runtime &runtime, const jsi::Value &thisArg,
27
- const jsi::Value *args, size_t count) -> jsi::Value {
28
- getContext()->releasePlatformBuffer(pointer);
29
- return jsi::Value::undefined();
30
- };
31
- return jsi::BigInt::fromUint64(runtime, pointer);
32
- }
33
-
34
- JSI_HOST_FUNCTION(Release) {
35
-
36
- jsi::BigInt pointer = arguments[0].asBigInt(runtime);
37
- const uintptr_t platformBufferPointer = pointer.asUint64(runtime);
38
-
39
- getContext()->releasePlatformBuffer(platformBufferPointer);
40
- return jsi::Value::undefined();
41
- }
42
-
43
- JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiPlatformBufferFactory, Release),
44
- JSI_EXPORT_FUNC(JsiPlatformBufferFactory, MakeFromImage))
45
-
46
- explicit JsiPlatformBufferFactory(
47
- std::shared_ptr<RNSkPlatformContext> context)
48
- : JsiSkHostObject(std::move(context)) {}
49
- };
50
-
51
- } // namespace RNSkia
@@ -1,9 +0,0 @@
1
- /*
2
- * Copyright 2018 Google Inc.
3
- *
4
- * Use of this source code is governed by a BSD-style license that can be
5
- * found in the LICENSE file.
6
- */
7
-
8
- // TODO(kjlubick) delete after Chrome (and Android?) are migrated.
9
- #include "include/gpu/ganesh/vk/GrBackendDrawableInfo.h"
@@ -1,15 +0,0 @@
1
- import type { DependencyList } from "react";
2
- import type { DerivedValue, FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
3
- export declare const HAS_REANIMATED2: boolean;
4
- export declare const HAS_REANIMATED3: boolean;
5
- export declare function throwOnMissingReanimated(): void;
6
- export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
7
- export declare const useDerivedValue: <T>(processor: () => T, dependencies?: DependencyList) => DerivedValue<T>;
8
- export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
9
- export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
10
- export declare const stopMapper: (mapperID: number) => void;
11
- export declare const runOnJS: any;
12
- export declare const runOnUI: any;
13
- export declare const makeMutable: <T>(val: T) => SharedValue<T>;
14
- export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
15
- export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stopMapper = exports.startMapper = exports.runOnUI = exports.runOnJS = exports.makeMutable = exports.isSharedValue = exports.HAS_REANIMATED3 = exports.HAS_REANIMATED2 = void 0;
7
- exports.throwOnMissingReanimated = throwOnMissingReanimated;
8
- exports.useSharedValue = exports.useFrameCallback = exports.useDerivedValue = exports.useAnimatedReaction = void 0;
9
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8, _Reanimated9;
10
- /* eslint-disable @typescript-eslint/no-explicit-any */
11
-
12
- // This one is needed for the deprecated useSharedValue function
13
- // We can remove it once we remove the deprecation
14
-
15
- let Reanimated2;
16
- let Reanimated3;
17
- let reanimatedVersion;
18
- try {
19
- Reanimated2 = require("react-native-reanimated");
20
- reanimatedVersion = require("react-native-reanimated/package.json").version;
21
- if (reanimatedVersion && (reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))) {
22
- Reanimated3 = Reanimated2;
23
- }
24
- } catch (e) {}
25
- const HAS_REANIMATED2 = exports.HAS_REANIMATED2 = !!Reanimated2;
26
- const HAS_REANIMATED3 = exports.HAS_REANIMATED3 = !!Reanimated3;
27
- function throwOnMissingReanimated() {
28
- if (!HAS_REANIMATED2) {
29
- throw new Error("Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
30
- react-native-skia's integration layer API.");
31
- }
32
- }
33
- const useSharedValue = exports.useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || throwOnMissingReanimated;
34
- const useDerivedValue = exports.useDerivedValue = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useDerivedValue) || throwOnMissingReanimated;
35
- const useFrameCallback = exports.useFrameCallback = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.useFrameCallback) || throwOnMissingReanimated;
36
- const startMapper = exports.startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.startMapper) || throwOnMissingReanimated;
37
- const stopMapper = exports.stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
38
- const runOnJS = exports.runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
39
- const runOnUI = exports.runOnUI = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.runOnUI) || throwOnMissingReanimated;
40
- const makeMutable = exports.makeMutable = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.makeMutable) || throwOnMissingReanimated;
41
- const useAnimatedReaction = exports.useAnimatedReaction = ((_Reanimated9 = Reanimated2) === null || _Reanimated9 === void 0 ? void 0 : _Reanimated9.useAnimatedReaction) || throwOnMissingReanimated;
42
- const isSharedValue = value => {
43
- return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
44
- };
45
- exports.isSharedValue = isSharedValue;
46
- //# sourceMappingURL=moduleWrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","exports","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","_Reanimated","useDerivedValue","_Reanimated2","useFrameCallback","_Reanimated3","startMapper","_Reanimated4","stopMapper","_Reanimated5","runOnJS","_Reanimated6","runOnUI","_Reanimated7","makeMutable","_Reanimated8","useAnimatedReaction","_Reanimated9","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\nexport const makeMutable: <T>(val: T) => SharedValue<T> =\n Reanimated2?.makeMutable || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AASA;AACA;;AAEA,IAAIA,WAAgB;AAEpB,IAAIC,WAAgB;AACpB,IAAIC,iBAAyB;AAE7B,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAyB,CAAC;EAChDD,iBAAiB,GAAGC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EAC3E,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,WAAW,GAAGD,WAAW;EAC3B;AACF,CAAC,CAAC,OAAOM,CAAC,EAAE,CAAC;AAEN,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,CAAC,CAACP,WAAW;AACrC,MAAMS,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,CAAC,CAACR,WAAW;AAErC,SAASS,wBAAwBA,CAAA,EAAG;EACzC,IAAI,CAACH,eAAe,EAAE;IACpB,MAAM,IAAII,KAAK,CACb;AACN,iDACI,CAAC;EACH;AACF;AAEO,MAAMC,cAGM,GAAAJ,OAAA,CAAAI,cAAA,GAAG,EAAAC,WAAA,GAAAb,WAAW,cAAAa,WAAA,uBAAXA,WAAA,CAAaD,cAAc,KAAIF,wBAAwB;AAEtE,MAAMI,eAGO,GAAAN,OAAA,CAAAM,eAAA,GAAG,EAAAC,YAAA,GAAAf,WAAW,cAAAe,YAAA,uBAAXA,YAAA,CAAaD,eAAe,KAAIJ,wBAAwB;AAExE,MAAMM,gBAGK,GAAAR,OAAA,CAAAQ,gBAAA,GAAG,EAAAC,YAAA,GAAAjB,WAAW,cAAAiB,YAAA,uBAAXA,YAAA,CAAaD,gBAAgB,KAAIN,wBAAwB;AAEvE,MAAMQ,WAIF,GAAAV,OAAA,CAAAU,WAAA,GAAG,EAAAC,YAAA,GAAAnB,WAAW,cAAAmB,YAAA,uBAAXA,YAAA,CAAaD,WAAW,KAAIR,wBAAwB;AAE3D,MAAMU,UAAsC,GAAAZ,OAAA,CAAAY,UAAA,GACjD,EAAAC,YAAA,GAAArB,WAAW,cAAAqB,YAAA,uBAAXA,YAAA,CAAaD,UAAU,KAAIV,wBAAwB;AAE9C,MAAMY,OAAO,GAAAd,OAAA,CAAAc,OAAA,GAAG,EAAAC,YAAA,GAAAvB,WAAW,cAAAuB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAIZ,wBAAwB;AAChE,MAAMc,OAAO,GAAAhB,OAAA,CAAAgB,OAAA,GAAG,EAAAC,YAAA,GAAAzB,WAAW,cAAAyB,YAAA,uBAAXA,YAAA,CAAaD,OAAO,KAAId,wBAAwB;AAChE,MAAMgB,WAA0C,GAAAlB,OAAA,CAAAkB,WAAA,GACrD,EAAAC,YAAA,GAAA3B,WAAW,cAAA2B,YAAA,uBAAXA,YAAA,CAAaD,WAAW,KAAIhB,wBAAwB;AAE/C,MAAMkB,mBAIJ,GAAApB,OAAA,CAAAoB,mBAAA,GAAG,EAAAC,YAAA,GAAA7B,WAAW,cAAA6B,YAAA,uBAAXA,YAAA,CAAaD,mBAAmB,KAAIlB,wBAAwB;AAEjE,MAAMoB,aAAa,GAAOC,KAAc,IAA8B;EAC3E,OACE,CAAC,CAACA,KAAK,KACN9B,WAAW,GACRA,WAAW,CAAC6B,aAAa,CAACC,KAAK,CAAC,GAC/BA,KAAK,CAASA,KAAK,KAAKC,SAAS,CAAC;AAE3C,CAAC;AAACxB,OAAA,CAAAsB,aAAA,GAAAA,aAAA"}
@@ -1,12 +0,0 @@
1
- import type { SkImage } from "../Image";
2
- export type PlatformBuffer = bigint;
3
- export interface PlatformBufferFactory {
4
- /**
5
- * Copy pixels to a platform buffer. (for testing purposes)
6
- */
7
- MakeFromImage: (image: SkImage) => PlatformBuffer;
8
- /**
9
- * Release a platform buffer that was created with `MakeFromImage`.
10
- */
11
- Release: (platformBuffer: PlatformBuffer) => void;
12
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=PlatformBufferFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PlatformBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type PlatformBuffer = bigint;\n\nexport interface PlatformBufferFactory {\n /**\n * Copy pixels to a platform buffer. (for testing purposes)\n */\n MakeFromImage: (image: SkImage) => PlatformBuffer;\n /**\n * Release a platform buffer that was created with `MakeFromImage`.\n */\n Release: (platformBuffer: PlatformBuffer) => void;\n}\n"],"mappings":""}
@@ -1 +0,0 @@
1
- export * from "./PlatformBufferFactory";
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _PlatformBufferFactory = require("./PlatformBufferFactory");
7
- Object.keys(_PlatformBufferFactory).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _PlatformBufferFactory[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _PlatformBufferFactory[key];
14
- }
15
- });
16
- });
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_PlatformBufferFactory","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./PlatformBufferFactory\";\n"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
@@ -1,8 +0,0 @@
1
- import type { CanvasKit } from "canvaskit-wasm";
2
- import type { PlatformBuffer, PlatformBufferFactory, SkImage } from "../types";
3
- import { Host } from "./Host";
4
- export declare class JsiSkPlatformBufferFactory extends Host implements PlatformBufferFactory {
5
- constructor(CanvasKit: CanvasKit);
6
- MakeFromImage(_image: SkImage): PlatformBuffer;
7
- Release(_platformBuffer: PlatformBuffer): void;
8
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.JsiSkPlatformBufferFactory = void 0;
7
- var _Host = require("./Host");
8
- class JsiSkPlatformBufferFactory extends _Host.Host {
9
- constructor(CanvasKit) {
10
- super(CanvasKit);
11
- }
12
- MakeFromImage(_image) {
13
- throw new _Host.NotImplementedOnRNWeb();
14
- }
15
- Release(_platformBuffer) {
16
- throw new _Host.NotImplementedOnRNWeb();
17
- }
18
- }
19
- exports.JsiSkPlatformBufferFactory = JsiSkPlatformBufferFactory;
20
- //# sourceMappingURL=JsiSkPlatformBufferFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_Host","require","JsiSkPlatformBufferFactory","Host","constructor","CanvasKit","MakeFromImage","_image","NotImplementedOnRNWeb","Release","_platformBuffer","exports"],"sources":["JsiSkPlatformBufferFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { PlatformBuffer, PlatformBufferFactory, SkImage } from \"../types\";\n\nimport { Host, NotImplementedOnRNWeb } from \"./Host\";\n\nexport class JsiSkPlatformBufferFactory\n extends Host\n implements PlatformBufferFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromImage(_image: SkImage): PlatformBuffer {\n throw new NotImplementedOnRNWeb();\n }\n\n Release(_platformBuffer: PlatformBuffer) {\n throw new NotImplementedOnRNWeb();\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,0BAA0B,SAC7BC,UAAI,CAEd;EACEC,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,aAAaA,CAACC,MAAe,EAAkB;IAC7C,MAAM,IAAIC,2BAAqB,CAAC,CAAC;EACnC;EAEAC,OAAOA,CAACC,eAA+B,EAAE;IACvC,MAAM,IAAIF,2BAAqB,CAAC,CAAC;EACnC;AACF;AAACG,OAAA,CAAAT,0BAAA,GAAAA,0BAAA"}
@@ -1,15 +0,0 @@
1
- import type { DependencyList } from "react";
2
- import type { DerivedValue, FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
3
- export declare const HAS_REANIMATED2: boolean;
4
- export declare const HAS_REANIMATED3: boolean;
5
- export declare function throwOnMissingReanimated(): void;
6
- export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
7
- export declare const useDerivedValue: <T>(processor: () => T, dependencies?: DependencyList) => DerivedValue<T>;
8
- export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
9
- export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
10
- export declare const stopMapper: (mapperID: number) => void;
11
- export declare const runOnJS: any;
12
- export declare const runOnUI: any;
13
- export declare const makeMutable: <T>(val: T) => SharedValue<T>;
14
- export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
15
- export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
@@ -1,37 +0,0 @@
1
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8, _Reanimated9;
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
-
4
- // This one is needed for the deprecated useSharedValue function
5
- // We can remove it once we remove the deprecation
6
-
7
- let Reanimated2;
8
- let Reanimated3;
9
- let reanimatedVersion;
10
- try {
11
- Reanimated2 = require("react-native-reanimated");
12
- reanimatedVersion = require("react-native-reanimated/package.json").version;
13
- if (reanimatedVersion && (reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))) {
14
- Reanimated3 = Reanimated2;
15
- }
16
- } catch (e) {}
17
- export const HAS_REANIMATED2 = !!Reanimated2;
18
- export const HAS_REANIMATED3 = !!Reanimated3;
19
- export function throwOnMissingReanimated() {
20
- if (!HAS_REANIMATED2) {
21
- throw new Error("Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
22
- react-native-skia's integration layer API.");
23
- }
24
- }
25
- export const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || throwOnMissingReanimated;
26
- export const useDerivedValue = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useDerivedValue) || throwOnMissingReanimated;
27
- export const useFrameCallback = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.useFrameCallback) || throwOnMissingReanimated;
28
- export const startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.startMapper) || throwOnMissingReanimated;
29
- export const stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
30
- export const runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
31
- export const runOnUI = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.runOnUI) || throwOnMissingReanimated;
32
- export const makeMutable = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.makeMutable) || throwOnMissingReanimated;
33
- export const useAnimatedReaction = ((_Reanimated9 = Reanimated2) === null || _Reanimated9 === void 0 ? void 0 : _Reanimated9.useAnimatedReaction) || throwOnMissingReanimated;
34
- export const isSharedValue = value => {
35
- return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
36
- };
37
- //# sourceMappingURL=moduleWrapper.js.map