@shopify/react-native-skia 1.2.3 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/cpp/jni/JniPlatformContext.cpp +23 -0
  3. package/android/cpp/jni/include/JniPlatformContext.h +2 -0
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +6 -0
  5. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +92 -0
  6. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +36 -0
  7. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +3 -3
  8. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +5 -0
  9. package/android/src/main/java/com/shopify/reactnative/skia/RNSkVideo.java +185 -0
  10. package/cpp/api/JsiSkApi.h +2 -0
  11. package/cpp/api/JsiVideo.h +87 -0
  12. package/cpp/rnskia/RNSkPlatformContext.h +3 -0
  13. package/cpp/rnskia/RNSkVideo.h +23 -0
  14. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
  15. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +6 -0
  16. package/ios/RNSkia-iOS/RNSkiOSVideo.h +40 -0
  17. package/ios/RNSkia-iOS/RNSkiOSVideo.mm +119 -0
  18. package/ios/RNSkia-iOS/RNSkiOSView.mm +37 -0
  19. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  20. package/lib/commonjs/external/reanimated/index.js +11 -0
  21. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  22. package/lib/commonjs/external/reanimated/useVideo.d.ts +12 -0
  23. package/lib/commonjs/external/reanimated/useVideo.js +105 -0
  24. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -0
  25. package/lib/commonjs/mock/index.js +2 -1
  26. package/lib/commonjs/mock/index.js.map +1 -1
  27. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  28. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  29. package/lib/commonjs/skia/types/Video/Video.d.ts +8 -0
  30. package/lib/commonjs/skia/types/Video/Video.js +6 -0
  31. package/lib/commonjs/skia/types/Video/Video.js.map +1 -0
  32. package/lib/commonjs/skia/types/Video/index.d.ts +1 -0
  33. package/lib/commonjs/skia/types/Video/index.js +17 -0
  34. package/lib/commonjs/skia/types/Video/index.js.map +1 -0
  35. package/lib/commonjs/skia/web/JsiSkia.js +4 -1
  36. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  37. package/lib/module/external/reanimated/index.d.ts +1 -0
  38. package/lib/module/external/reanimated/index.js +1 -0
  39. package/lib/module/external/reanimated/index.js.map +1 -1
  40. package/lib/module/external/reanimated/useVideo.d.ts +12 -0
  41. package/lib/module/external/reanimated/useVideo.js +97 -0
  42. package/lib/module/external/reanimated/useVideo.js.map +1 -0
  43. package/lib/module/mock/index.js +2 -1
  44. package/lib/module/mock/index.js.map +1 -1
  45. package/lib/module/skia/types/Skia.d.ts +2 -0
  46. package/lib/module/skia/types/Skia.js.map +1 -1
  47. package/lib/module/skia/types/Video/Video.d.ts +8 -0
  48. package/lib/module/skia/types/Video/Video.js +2 -0
  49. package/lib/module/skia/types/Video/Video.js.map +1 -0
  50. package/lib/module/skia/types/Video/index.d.ts +1 -0
  51. package/lib/module/skia/types/Video/index.js +2 -0
  52. package/lib/module/skia/types/Video/index.js.map +1 -0
  53. package/lib/module/skia/web/JsiSkia.js +4 -1
  54. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  55. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  56. package/lib/typescript/src/external/reanimated/useVideo.d.ts +12 -0
  57. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  58. package/lib/typescript/src/skia/types/Video/Video.d.ts +8 -0
  59. package/lib/typescript/src/skia/types/Video/index.d.ts +1 -0
  60. package/package.json +1 -1
  61. package/scripts/setup-canvaskit.js +1 -1
  62. package/src/external/reanimated/index.ts +1 -0
  63. package/src/external/reanimated/useVideo.ts +130 -0
  64. package/src/mock/index.ts +1 -0
  65. package/src/skia/types/Skia.ts +2 -0
  66. package/src/skia/types/Video/Video.ts +9 -0
  67. package/src/skia/types/Video/index.ts +1 -0
  68. package/src/skia/web/JsiSkia.ts +3 -0
@@ -0,0 +1,97 @@
1
+ import { runOnUI, useSharedValue } from "react-native-reanimated";
2
+ import { useCallback, useEffect, useMemo } from "react";
3
+ import { Skia } from "../../skia/Skia";
4
+ import { Platform } from "../../Platform";
5
+ import Rea from "./ReanimatedProxy";
6
+ const defaultOptions = {
7
+ playbackSpeed: 1,
8
+ looping: true,
9
+ paused: false,
10
+ seek: null,
11
+ currentTime: 0
12
+ };
13
+ const useOption = value => {
14
+ "worklet";
15
+
16
+ // TODO: only create defaultValue is needed (via makeMutable)
17
+ const defaultValue = useSharedValue(Rea.isSharedValue(value) ? value.value : value);
18
+ return Rea.isSharedValue(value) ? value : defaultValue;
19
+ };
20
+ export const useVideo = (source, userOptions) => {
21
+ var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$currentT, _userOptions$playback;
22
+ const video = useMemo(() => source ? Skia.Video(source) : null, [source]);
23
+ const isPaused = useOption((_userOptions$paused = userOptions === null || userOptions === void 0 ? void 0 : userOptions.paused) !== null && _userOptions$paused !== void 0 ? _userOptions$paused : defaultOptions.paused);
24
+ const looping = useOption((_userOptions$looping = userOptions === null || userOptions === void 0 ? void 0 : userOptions.looping) !== null && _userOptions$looping !== void 0 ? _userOptions$looping : defaultOptions.looping);
25
+ const seek = useOption((_userOptions$seek = userOptions === null || userOptions === void 0 ? void 0 : userOptions.seek) !== null && _userOptions$seek !== void 0 ? _userOptions$seek : defaultOptions.seek);
26
+ const currentTime = useOption((_userOptions$currentT = userOptions === null || userOptions === void 0 ? void 0 : userOptions.currentTime) !== null && _userOptions$currentT !== void 0 ? _userOptions$currentT : defaultOptions.currentTime);
27
+ const playbackSpeed = useOption((_userOptions$playback = userOptions === null || userOptions === void 0 ? void 0 : userOptions.playbackSpeed) !== null && _userOptions$playback !== void 0 ? _userOptions$playback : defaultOptions.playbackSpeed);
28
+ const currentFrame = Rea.useSharedValue(null);
29
+ const lastTimestamp = Rea.useSharedValue(-1);
30
+ const startTimestamp = Rea.useSharedValue(-1);
31
+ const framerate = useMemo(() => video ? video.framerate() : -1, [video]);
32
+ const duration = useMemo(() => video ? video.duration() : -1, [video]);
33
+ const frameDuration = useMemo(() => framerate > 0 ? 1000 / framerate : -1, [framerate]);
34
+ const disposeVideo = useCallback(() => {
35
+ "worklet";
36
+
37
+ video === null || video === void 0 || video.dispose();
38
+ }, [video]);
39
+ Rea.useFrameCallback(frameInfo => {
40
+ if (!video) {
41
+ return;
42
+ }
43
+ if (seek.value !== null) {
44
+ video.seek(seek.value);
45
+ seek.value = null;
46
+ lastTimestamp.value = -1;
47
+ startTimestamp.value = -1;
48
+ }
49
+ if (isPaused.value && lastTimestamp.value !== -1) {
50
+ return;
51
+ }
52
+ const {
53
+ timestamp
54
+ } = frameInfo;
55
+
56
+ // Initialize start timestamp
57
+ if (startTimestamp.value === -1) {
58
+ startTimestamp.value = timestamp;
59
+ }
60
+
61
+ // Calculate the current time in the video
62
+ const currentTimestamp = timestamp - startTimestamp.value;
63
+ currentTime.value = currentTimestamp;
64
+
65
+ // Handle looping
66
+ if (currentTimestamp > duration && looping.value) {
67
+ video.seek(0);
68
+ startTimestamp.value = timestamp;
69
+ }
70
+
71
+ // Update frame only if the elapsed time since last update is greater than the frame duration
72
+ const currentFrameDuration = Math.floor(frameDuration / playbackSpeed.value);
73
+ const delta = Math.floor(timestamp - lastTimestamp.value);
74
+ if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {
75
+ const img = video.nextImage();
76
+ if (img) {
77
+ if (currentFrame.value) {
78
+ currentFrame.value.dispose();
79
+ }
80
+ if (Platform.OS === "android") {
81
+ currentFrame.value = img.makeNonTextureImage();
82
+ } else {
83
+ currentFrame.value = img;
84
+ }
85
+ }
86
+ lastTimestamp.value = timestamp;
87
+ }
88
+ });
89
+ useEffect(() => {
90
+ return () => {
91
+ // TODO: should video simply be a shared value instead?
92
+ runOnUI(disposeVideo)();
93
+ };
94
+ }, [disposeVideo, video]);
95
+ return currentFrame;
96
+ };
97
+ //# sourceMappingURL=useVideo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["runOnUI","useSharedValue","useCallback","useEffect","useMemo","Skia","Platform","Rea","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","isSharedValue","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$currentT","_userOptions$playback","video","Video","isPaused","currentFrame","lastTimestamp","startTimestamp","framerate","duration","frameDuration","disposeVideo","dispose","useFrameCallback","frameInfo","timestamp","currentTimestamp","currentFrameDuration","Math","floor","delta","img","nextImage","OS","makeNonTextureImage"],"sources":["useVideo.ts"],"sourcesContent":["import {\n runOnUI,\n useSharedValue,\n type FrameInfo,\n type SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\n\ntype Animated<T> = SharedValue<T> | T;\n\nexport interface PlaybackOptions {\n playbackSpeed: Animated<number>;\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n currentTime: Animated<number>;\n}\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const currentTime = useOption(\n userOptions?.currentTime ?? defaultOptions.currentTime\n );\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const startTimestamp = Rea.useSharedValue(-1);\n\n const framerate = useMemo(() => (video ? video.framerate() : -1), [video]);\n const duration = useMemo(() => (video ? video.duration() : -1), [video]);\n const frameDuration = useMemo(\n () => (framerate > 0 ? 1000 / framerate : -1),\n [framerate]\n );\n const disposeVideo = useCallback(() => {\n \"worklet\";\n video?.dispose();\n }, [video]);\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!video) {\n return;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n seek.value = null;\n lastTimestamp.value = -1;\n startTimestamp.value = -1;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n\n // Initialize start timestamp\n if (startTimestamp.value === -1) {\n startTimestamp.value = timestamp;\n }\n\n // Calculate the current time in the video\n const currentTimestamp = timestamp - startTimestamp.value;\n currentTime.value = currentTimestamp;\n\n // Handle looping\n if (currentTimestamp > duration && looping.value) {\n video.seek(0);\n startTimestamp.value = timestamp;\n }\n\n // Update frame only if the elapsed time since last update is greater than the frame duration\n const currentFrameDuration = Math.floor(\n frameDuration / playbackSpeed.value\n );\n const delta = Math.floor(timestamp - lastTimestamp.value);\n if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n if (Platform.OS === \"android\") {\n currentFrame.value = img.makeNonTextureImage();\n } else {\n currentFrame.value = img;\n }\n }\n lastTimestamp.value = timestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n runOnUI(disposeVideo)();\n };\n }, [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AAMI,GAAG,GAAGnB,KAAK,CAACoB,SAAS,CAAC,CAAC;MAC7B,IAAID,GAAG,EAAE;QACP,IAAIhB,YAAY,CAACd,KAAK,EAAE;UACtBc,YAAY,CAACd,KAAK,CAACqB,OAAO,CAAC,CAAC;QAC9B;QACA,IAAI9B,QAAQ,CAACyC,EAAE,KAAK,SAAS,EAAE;UAC7BlB,YAAY,CAACd,KAAK,GAAG8B,GAAG,CAACG,mBAAmB,CAAC,CAAC;QAChD,CAAC,MAAM;UACLnB,YAAY,CAACd,KAAK,GAAG8B,GAAG;QAC1B;MACF;MACAf,aAAa,CAACf,KAAK,GAAGwB,SAAS;IACjC;EACF,CAAC,CAAC;EAEFpC,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAH,OAAO,CAACmC,YAAY,CAAC,CAAC,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACA,YAAY,EAAET,KAAK,CAAC,CAAC;EAEzB,OAAOG,YAAY;AACrB,CAAC"}
@@ -46,7 +46,8 @@ export const Mock = CanvasKit => {
46
46
  useFonts: Noop,
47
47
  useTypeface: () => null,
48
48
  useImage: () => null,
49
- useSVG: () => null
49
+ useSVG: () => null,
50
+ useVideo: () => null
50
51
  };
51
52
  };
52
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkApi","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,aAAa;;AAEtC;AACA,MAAMC,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAE5C,OAAO,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5CC,MAAM,CAACC,OAAO,GAAGV,QAAQ,CAACQ,SAAS,CAAC;EACpC,MAAMG,IAAI,GAAGF,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLC,IAAI;IACJ,GAAGC,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B;IACAC,MAAM,EAAEZ,IAAI;IACZ;IACAa,QAAQ,EAAEX,SAAS;IACnBY,gBAAgB,EAAEZ,SAAS;IAC3Ba,eAAe,EAAEf,IAAI;IACrBgB,SAAS,EAAEd,SAAS;IACpBe,OAAO,EAAEf,SAAS;IAClBgB,SAAS,EAAEhB,SAAS;IACpBiB,aAAa,EAAEjB,SAAS;IACxBkB,cAAc,EAAEpB,IAAI;IACpB;IACAqB,QAAQ,EAAEjB,eAAe;IACzBkB,oBAAoB,EAAElB,eAAe;IACrCmB,iBAAiB,EAAEnB,eAAe;IAClCoB,eAAe,EAAEpB,eAAe;IAChCqB,0BAA0B,EAAErB,eAAe;IAC3CsB,gBAAgB,EAAEtB,eAAe;IACjCuB,cAAc,EAAEvB,eAAe;IAC/BwB,cAAc,EAAExB,eAAe;IAC/ByB,aAAa,EAAEzB,eAAe;IAC9B0B,SAAS,EAAE1B,eAAe;IAC1B2B,UAAU,EAAE/B,IAAI;IAChBgC,OAAO,EAAEhC,IAAI;IACbiC,OAAO,EAAEA,CAAA,KAAMvB,IAAI,CAACwB,IAAI,CAACjC,SAAS,EAAE,CAAC,CAAC;IACtCkC,QAAQ,EAAEnC,IAAI;IACdoC,WAAW,EAAEA,CAAA,KAAM,IAAI;IACvBC,QAAQ,EAAEA,CAAA,KAAM,IAAI;IACpBC,MAAM,EAAEA,CAAA,KAAM;EAChB,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["JsiSkApi","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,aAAa;;AAEtC;AACA,MAAMC,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAA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AAI;IACvBC,QAAQ,EAAEA,CAAA,KAAM,IAAI;IACpBC,MAAM,EAAEA,CAAA,KAAM,IAAI;IAClBC,QAAQ,EAAEA,CAAA,KAAM;EAClB,CAAC;AACH,CAAC"}
@@ -26,6 +26,7 @@ import type { Color, SkColor } from "./Color";
26
26
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
27
27
  import type { AnimatedImageFactory } from "./AnimatedImage";
28
28
  import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
29
+ import type { Video } from "./Video";
29
30
  import type { NativeBufferFactory } from "./NativeBuffer";
30
31
  /**
31
32
  * Declares the interface for the native Skia API
@@ -72,5 +73,6 @@ export interface Skia {
72
73
  TextBlob: TextBlobFactory;
73
74
  Surface: SurfaceFactory;
74
75
  ParagraphBuilder: ParagraphBuilderFactory;
76
+ Video: (url: string) => Video;
75
77
  NativeBuffer: NativeBufferFactory;
76
78
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n NativeBuffer: NativeBufferFactory;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Video: (url: string) => Video;\n NativeBuffer: NativeBufferFactory;\n}\n"],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { SkImage } from "../Image";
2
+ import type { SkJSIInstance } from "../JsiInstance";
3
+ export interface Video extends SkJSIInstance<"Video"> {
4
+ duration(): number;
5
+ framerate(): number;
6
+ nextImage(): SkImage | null;
7
+ seek(time: number): void;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n}\n"],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from "./Video";
@@ -0,0 +1,2 @@
1
+ export * from "./Video";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Video\";\n"],"mappings":"AAAA,cAAc,SAAS"}
@@ -74,6 +74,9 @@ export const JsiSkApi = CanvasKit => ({
74
74
  TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),
75
75
  FontMgr: new JsiSkFontMgrFactory(CanvasKit),
76
76
  ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),
77
- NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit)
77
+ NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),
78
+ Video: _localUri => {
79
+ throw new Error("Not implemented on React Native Web");
80
+ }
78
81
  });
79
82
  //# sourceMappingURL=JsiSkia.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkTypefaceFontProviderFactory","JsiSkFontMgrFactory","JsiSkAnimatedImageFactory","JsiSkParagraphBuilderFactory","JsiSkNativeBufferFactory","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","RSXformFromRadians","scale","r","px","py","s","Math","sin","c","cos","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","AnimatedImage","SVG","TextBlob","XYWHRect","width","height","Surface","TypefaceFontProvider","FontMgr","ParagraphBuilder","NativeBuffer"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\nimport { JsiSkTypefaceFontProviderFactory } from \"./JsiSkTypefaceFontProviderFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkAnimatedImageFactory } from \"./JsiSkAnimatedImageFactory\";\nimport { JsiSkParagraphBuilderFactory } from \"./JsiSkParagraphBuilderFactory\";\nimport { JsiSkNativeBufferFactory } from \"./JsiSkNativeBufferFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n RSXformFromRadians: (\n scale: number,\n r: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => {\n const s = Math.sin(r) * scale;\n const c = Math.cos(r) * scale;\n return new JsiSkRSXform(\n CanvasKit,\n Float32Array.of(c, s, tx - c * px + s * py, ty - s * px - c * py)\n );\n },\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),\n NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,iBAAiB,QA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,CAACM,SAAS,CAAC;EACrEgE,OAAO,EAAE,IAAIrE,mBAAmB,CAACK,SAAS,CAAC;EAC3CiE,gBAAgB,EAAE,IAAIpE,4BAA4B,CAACG,SAAS,CAAC;EAC7DkE,YAAY,EAAE,IAAIpE,wBAAwB,CAACE,SAAS;AACtD,CAAC,CAAC"}
1
+ {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkTypefaceFontProviderFactory","JsiSkFontMgrFactory","JsiSkAnimatedImageFactory","JsiSkParagraphBuilderFactory","JsiSkNativeBufferFactory","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","RSXformFromRadians","scale","r","px","py","s","Math","sin","c","cos","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","AnimatedImage","SVG","TextBlob","XYWHRect","width","height","Surface","TypefaceFontProvider","FontMgr","ParagraphBuilder","NativeBuffer","Video","_localUri"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\nimport { JsiSkTypefaceFontProviderFactory } from \"./JsiSkTypefaceFontProviderFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkAnimatedImageFactory } from \"./JsiSkAnimatedImageFactory\";\nimport { JsiSkParagraphBuilderFactory } from \"./JsiSkParagraphBuilderFactory\";\nimport { JsiSkNativeBufferFactory } from \"./JsiSkNativeBufferFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n RSXformFromRadians: (\n scale: number,\n r: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => {\n const s = Math.sin(r) * scale;\n const c = Math.cos(r) * scale;\n return new JsiSkRSXform(\n CanvasKit,\n Float32Array.of(c, s, tx - c * px + s * py, ty - s * px - c * py)\n );\n },\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),\n NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),\n Video: (_localUri: string) => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n});\n"],"mappings":"AAYA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,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,QAAQ,EAAEA,CAACzD,CAAS,EAAEC,CAAS,EAAEyD,KAAa,EAAEC,MAAc,KAAK;IACjE,OAAO,IAAI5F,SAAS,CAAC+B,SAAS,EAAEA,SAAS,CAAC2D,QAAQ,CAACzD,CAAC,EAAEC,CAAC,EAAEyD,KAAK,EAAEC,MAAM,CAAC,CAAC;EAC1E,CAAC;EACDC,OAAO,EAAE,IAAI3F,mBAAmB,CAAC6B,SAAS,CAAC;EAC3C+D,oBAAoB,EAAE,IAAIrE,gCAAgC,CAACM,SAAS,CAAC;EACrEgE,OAAO,EAAE,IAAIrE,mBAAmB,CAACK,SAAS,CAAC;EAC3CiE,gBAAgB,EAAE,IAAIpE,4BAA4B,CAACG,SAAS,CAAC;EAC7DkE,YAAY,EAAE,IAAIpE,wBAAwB,CAACE,SAAS,CAAC;EACrDmE,KAAK,EAAGC,SAAiB,IAAK;IAC5B,MAAM,IAAI5D,KAAK,CAAC,qCAAqC,CAAC;EACxD;AACF,CAAC,CAAC"}
@@ -4,3 +4,4 @@ export * from "./renderHelpers";
4
4
  export * from "./interpolators";
5
5
  export * from "./textures";
6
6
  export * from "./buffers";
7
+ export * from "./useVideo";
@@ -0,0 +1,12 @@
1
+ import { type SharedValue } from "react-native-reanimated";
2
+ import type { SkImage } from "../../skia/types";
3
+ type Animated<T> = SharedValue<T> | T;
4
+ export interface PlaybackOptions {
5
+ playbackSpeed: Animated<number>;
6
+ looping: Animated<boolean>;
7
+ paused: Animated<boolean>;
8
+ seek: Animated<number | null>;
9
+ currentTime: Animated<number>;
10
+ }
11
+ export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => SharedValue<SkImage | null>;
12
+ export {};
@@ -26,6 +26,7 @@ import type { Color, SkColor } from "./Color";
26
26
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
27
27
  import type { AnimatedImageFactory } from "./AnimatedImage";
28
28
  import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
29
+ import type { Video } from "./Video";
29
30
  import type { NativeBufferFactory } from "./NativeBuffer";
30
31
  /**
31
32
  * Declares the interface for the native Skia API
@@ -72,5 +73,6 @@ export interface Skia {
72
73
  TextBlob: TextBlobFactory;
73
74
  Surface: SurfaceFactory;
74
75
  ParagraphBuilder: ParagraphBuilderFactory;
76
+ Video: (url: string) => Video;
75
77
  NativeBuffer: NativeBufferFactory;
76
78
  }
@@ -0,0 +1,8 @@
1
+ import type { SkImage } from "../Image";
2
+ import type { SkJSIInstance } from "../JsiInstance";
3
+ export interface Video extends SkJSIInstance<"Video"> {
4
+ duration(): number;
5
+ framerate(): number;
6
+ nextImage(): SkImage | null;
7
+ seek(time: number): void;
8
+ }
@@ -0,0 +1 @@
1
+ export * from "./Video";
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "1.2.3",
10
+ "version": "1.3.1",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "react-native": "src/index.ts",
@@ -73,7 +73,7 @@ function getWasmFilePath() {
73
73
 
74
74
  function getOutputFilePath(isAnExpoProjectWithMetro) {
75
75
  // Default to using `web` public path.
76
- const publicFolder = path.resolve(args[0] || (isAnExpoProjectWithMetro) ? "public" : "web/static/js");
76
+ const publicFolder = path.resolve(args[0] || ((isAnExpoProjectWithMetro) ? "public" : "web/static/js"));
77
77
  const publicLocation = "./canvaskit.wasm";
78
78
  const output = path.join(publicFolder, publicLocation);
79
79
 
@@ -4,3 +4,4 @@ export * from "./renderHelpers";
4
4
  export * from "./interpolators";
5
5
  export * from "./textures";
6
6
  export * from "./buffers";
7
+ export * from "./useVideo";
@@ -0,0 +1,130 @@
1
+ import {
2
+ runOnUI,
3
+ useSharedValue,
4
+ type FrameInfo,
5
+ type SharedValue,
6
+ } from "react-native-reanimated";
7
+ import { useCallback, useEffect, useMemo } from "react";
8
+
9
+ import { Skia } from "../../skia/Skia";
10
+ import type { SkImage } from "../../skia/types";
11
+ import { Platform } from "../../Platform";
12
+
13
+ import Rea from "./ReanimatedProxy";
14
+
15
+ type Animated<T> = SharedValue<T> | T;
16
+
17
+ export interface PlaybackOptions {
18
+ playbackSpeed: Animated<number>;
19
+ looping: Animated<boolean>;
20
+ paused: Animated<boolean>;
21
+ seek: Animated<number | null>;
22
+ currentTime: Animated<number>;
23
+ }
24
+
25
+ const defaultOptions = {
26
+ playbackSpeed: 1,
27
+ looping: true,
28
+ paused: false,
29
+ seek: null,
30
+ currentTime: 0,
31
+ };
32
+
33
+ const useOption = <T>(value: Animated<T>) => {
34
+ "worklet";
35
+ // TODO: only create defaultValue is needed (via makeMutable)
36
+ const defaultValue = useSharedValue(
37
+ Rea.isSharedValue(value) ? value.value : value
38
+ );
39
+ return Rea.isSharedValue(value) ? value : defaultValue;
40
+ };
41
+
42
+ export const useVideo = (
43
+ source: string | null,
44
+ userOptions?: Partial<PlaybackOptions>
45
+ ) => {
46
+ const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);
47
+ const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);
48
+ const looping = useOption(userOptions?.looping ?? defaultOptions.looping);
49
+ const seek = useOption(userOptions?.seek ?? defaultOptions.seek);
50
+ const currentTime = useOption(
51
+ userOptions?.currentTime ?? defaultOptions.currentTime
52
+ );
53
+ const playbackSpeed = useOption(
54
+ userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed
55
+ );
56
+ const currentFrame = Rea.useSharedValue<null | SkImage>(null);
57
+ const lastTimestamp = Rea.useSharedValue(-1);
58
+ const startTimestamp = Rea.useSharedValue(-1);
59
+
60
+ const framerate = useMemo(() => (video ? video.framerate() : -1), [video]);
61
+ const duration = useMemo(() => (video ? video.duration() : -1), [video]);
62
+ const frameDuration = useMemo(
63
+ () => (framerate > 0 ? 1000 / framerate : -1),
64
+ [framerate]
65
+ );
66
+ const disposeVideo = useCallback(() => {
67
+ "worklet";
68
+ video?.dispose();
69
+ }, [video]);
70
+
71
+ Rea.useFrameCallback((frameInfo: FrameInfo) => {
72
+ if (!video) {
73
+ return;
74
+ }
75
+ if (seek.value !== null) {
76
+ video.seek(seek.value);
77
+ seek.value = null;
78
+ lastTimestamp.value = -1;
79
+ startTimestamp.value = -1;
80
+ }
81
+ if (isPaused.value && lastTimestamp.value !== -1) {
82
+ return;
83
+ }
84
+ const { timestamp } = frameInfo;
85
+
86
+ // Initialize start timestamp
87
+ if (startTimestamp.value === -1) {
88
+ startTimestamp.value = timestamp;
89
+ }
90
+
91
+ // Calculate the current time in the video
92
+ const currentTimestamp = timestamp - startTimestamp.value;
93
+ currentTime.value = currentTimestamp;
94
+
95
+ // Handle looping
96
+ if (currentTimestamp > duration && looping.value) {
97
+ video.seek(0);
98
+ startTimestamp.value = timestamp;
99
+ }
100
+
101
+ // Update frame only if the elapsed time since last update is greater than the frame duration
102
+ const currentFrameDuration = Math.floor(
103
+ frameDuration / playbackSpeed.value
104
+ );
105
+ const delta = Math.floor(timestamp - lastTimestamp.value);
106
+ if (lastTimestamp.value === -1 || delta >= currentFrameDuration) {
107
+ const img = video.nextImage();
108
+ if (img) {
109
+ if (currentFrame.value) {
110
+ currentFrame.value.dispose();
111
+ }
112
+ if (Platform.OS === "android") {
113
+ currentFrame.value = img.makeNonTextureImage();
114
+ } else {
115
+ currentFrame.value = img;
116
+ }
117
+ }
118
+ lastTimestamp.value = timestamp;
119
+ }
120
+ });
121
+
122
+ useEffect(() => {
123
+ return () => {
124
+ // TODO: should video simply be a shared value instead?
125
+ runOnUI(disposeVideo)();
126
+ };
127
+ }, [disposeVideo, video]);
128
+
129
+ return currentFrame;
130
+ };
package/src/mock/index.ts CHANGED
@@ -46,5 +46,6 @@ export const Mock = (CanvasKit: CanvasKit) => {
46
46
  useTypeface: () => null,
47
47
  useImage: () => null,
48
48
  useSVG: () => null,
49
+ useVideo: () => null,
49
50
  };
50
51
  };
@@ -30,6 +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 { Video } from "./Video";
33
34
  import type { NativeBufferFactory } from "./NativeBuffer";
34
35
 
35
36
  /**
@@ -95,5 +96,6 @@ export interface Skia {
95
96
  TextBlob: TextBlobFactory;
96
97
  Surface: SurfaceFactory;
97
98
  ParagraphBuilder: ParagraphBuilderFactory;
99
+ Video: (url: string) => Video;
98
100
  NativeBuffer: NativeBufferFactory;
99
101
  }
@@ -0,0 +1,9 @@
1
+ import type { SkImage } from "../Image";
2
+ import type { SkJSIInstance } from "../JsiInstance";
3
+
4
+ export interface Video extends SkJSIInstance<"Video"> {
5
+ duration(): number;
6
+ framerate(): number;
7
+ nextImage(): SkImage | null;
8
+ seek(time: number): void;
9
+ }
@@ -0,0 +1 @@
1
+ export * from "./Video";
@@ -127,4 +127,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
127
127
  FontMgr: new JsiSkFontMgrFactory(CanvasKit),
128
128
  ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),
129
129
  NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),
130
+ Video: (_localUri: string) => {
131
+ throw new Error("Not implemented on React Native Web");
132
+ },
130
133
  });