@shopify/react-native-skia 1.3.2 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/jni/JniPlatformContext.cpp +4 -3
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +59 -1
- package/android/cpp/rnskia-android/RNSkAndroidVideo.h +4 -0
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkVideo.java +80 -7
- package/cpp/api/JsiVideo.h +32 -7
- package/cpp/rnskia/RNSkVideo.h +4 -0
- package/ios/RNSkia-iOS/RNSkiOSVideo.h +13 -4
- package/ios/RNSkia-iOS/RNSkiOSVideo.mm +65 -67
- package/lib/commonjs/dom/nodes/datatypes/Fitting.js +42 -30
- package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideo.d.ts +16 -4
- package/lib/commonjs/external/reanimated/useVideo.js +92 -17
- package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideoLoading.d.ts +4 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.js +27 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.web.d.ts +4 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.web.js +20 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.web.js.map +1 -0
- package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +2 -10
- package/lib/commonjs/renderer/components/shapes/FitBox.js +32 -3
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/skia/core/Matrix.js +5 -1
- package/lib/commonjs/skia/core/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.js +2 -0
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +4 -2
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -1
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Video/Video.d.ts +9 -1
- package/lib/commonjs/skia/types/Video/Video.js.map +1 -1
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js +30 -0
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +8 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +2 -3
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiVideo.d.ts +24 -0
- package/lib/commonjs/skia/web/JsiVideo.js +83 -0
- package/lib/commonjs/skia/web/JsiVideo.js.map +1 -0
- package/lib/commonjs/views/SkiaDomView.js +2 -0
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.js +2 -0
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaJSDomView.js +2 -0
- package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Fitting.js +41 -29
- package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/module/external/reanimated/useVideo.d.ts +16 -4
- package/lib/module/external/reanimated/useVideo.js +92 -17
- package/lib/module/external/reanimated/useVideo.js.map +1 -1
- package/lib/module/external/reanimated/useVideoLoading.d.ts +4 -0
- package/lib/module/external/reanimated/useVideoLoading.js +20 -0
- package/lib/module/external/reanimated/useVideoLoading.js.map +1 -0
- package/lib/module/external/reanimated/useVideoLoading.web.d.ts +4 -0
- package/lib/module/external/reanimated/useVideoLoading.web.js +13 -0
- package/lib/module/external/reanimated/useVideoLoading.web.js.map +1 -0
- package/lib/module/renderer/components/shapes/FitBox.d.ts +2 -10
- package/lib/module/renderer/components/shapes/FitBox.js +32 -3
- package/lib/module/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/module/skia/core/Matrix.js +5 -1
- package/lib/module/skia/core/Matrix.js.map +1 -1
- package/lib/module/skia/types/Matrix.js +2 -0
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +2 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -1
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Video/Video.d.ts +9 -1
- package/lib/module/skia/types/Video/Video.js.map +1 -1
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +23 -0
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +9 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +2 -3
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/skia/web/JsiVideo.d.ts +24 -0
- package/lib/module/skia/web/JsiVideo.js +75 -0
- package/lib/module/skia/web/JsiVideo.js.map +1 -0
- package/lib/module/views/SkiaDomView.js +2 -0
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.js +2 -0
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaJSDomView.js +2 -0
- package/lib/module/views/SkiaJSDomView.js.map +1 -1
- package/lib/typescript/src/external/reanimated/useVideo.d.ts +16 -4
- package/lib/typescript/src/external/reanimated/useVideoLoading.d.ts +4 -0
- package/lib/typescript/src/external/reanimated/useVideoLoading.web.d.ts +4 -0
- package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +2 -10
- package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -1
- package/lib/typescript/src/skia/types/Video/Video.d.ts +9 -1
- package/lib/typescript/src/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiVideo.d.ts +24 -0
- package/package.json +1 -1
- package/src/dom/nodes/datatypes/Fitting.ts +28 -21
- package/src/external/reanimated/useVideo.ts +108 -31
- package/src/external/reanimated/useVideoLoading.ts +28 -0
- package/src/external/reanimated/useVideoLoading.web.ts +17 -0
- package/src/renderer/components/shapes/FitBox.tsx +38 -4
- package/src/skia/core/Matrix.ts +4 -2
- package/src/skia/types/Matrix.ts +1 -0
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +10 -2
- package/src/skia/types/Skia.ts +1 -1
- package/src/skia/types/Video/Video.ts +7 -1
- package/src/skia/web/CanvasKitWebGLBufferImpl.ts +22 -0
- package/src/skia/web/JsiSkImageFactory.ts +16 -3
- package/src/skia/web/JsiSkia.ts +2 -3
- package/src/skia/web/JsiVideo.ts +96 -0
- package/src/views/SkiaDomView.tsx +4 -0
- package/src/views/SkiaDomView.web.tsx +4 -0
- package/src/views/SkiaJSDomView.tsx +4 -0
- package/lib/commonjs/external/reanimated/video.d.ts +0 -16
- package/lib/commonjs/external/reanimated/video.js +0 -54
- package/lib/commonjs/external/reanimated/video.js.map +0 -1
- package/lib/module/external/reanimated/video.d.ts +0 -16
- package/lib/module/external/reanimated/video.js +0 -46
- package/lib/module/external/reanimated/video.js.map +0 -1
- package/lib/typescript/src/external/reanimated/video.d.ts +0 -16
- package/src/external/reanimated/video.ts +0 -82
@@ -1,46 +0,0 @@
|
|
1
|
-
import { Platform } from "../../Platform";
|
2
|
-
export const setFrame = (video, currentFrame) => {
|
3
|
-
"worklet";
|
4
|
-
|
5
|
-
const img = video.nextImage();
|
6
|
-
if (img) {
|
7
|
-
if (currentFrame.value) {
|
8
|
-
currentFrame.value.dispose();
|
9
|
-
}
|
10
|
-
if (Platform.OS === "android") {
|
11
|
-
currentFrame.value = img.makeNonTextureImage();
|
12
|
-
} else {
|
13
|
-
currentFrame.value = img;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
};
|
17
|
-
export const processVideoState = (video, duration, framerate, currentTimestamp, options, currentTime, currentFrame, lastTimestamp, seek) => {
|
18
|
-
"worklet";
|
19
|
-
|
20
|
-
if (!video) {
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
if (options.paused) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
const delta = currentTimestamp - lastTimestamp.value;
|
27
|
-
const frameDuration = 1000 / framerate;
|
28
|
-
const currentFrameDuration = Math.floor(frameDuration / options.playbackSpeed);
|
29
|
-
if (currentTime.value + delta >= duration && options.looping) {
|
30
|
-
seek.value = 0;
|
31
|
-
}
|
32
|
-
if (seek.value !== null) {
|
33
|
-
video.seek(seek.value);
|
34
|
-
currentTime.value = seek.value;
|
35
|
-
setFrame(video, currentFrame);
|
36
|
-
lastTimestamp.value = currentTimestamp;
|
37
|
-
seek.value = null;
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
if (delta >= currentFrameDuration) {
|
41
|
-
setFrame(video, currentFrame);
|
42
|
-
currentTime.value += delta;
|
43
|
-
lastTimestamp.value = currentTimestamp;
|
44
|
-
}
|
45
|
-
};
|
46
|
-
//# sourceMappingURL=video.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["Platform","setFrame","video","currentFrame","img","nextImage","value","dispose","OS","makeNonTextureImage","processVideoState","duration","framerate","currentTimestamp","options","currentTime","lastTimestamp","seek","paused","delta","frameDuration","currentFrameDuration","Math","floor","playbackSpeed","looping"],"sources":["video.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nexport type 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}\n\ntype Materialized<T> = {\n [K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];\n};\n\nexport type MaterializedPlaybackOptions = Materialized<\n Omit<PlaybackOptions, \"seek\">\n>;\n\nexport const setFrame = (\n video: Video,\n currentFrame: SharedValue<SkImage | null>\n) => {\n \"worklet\";\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};\n\nexport const processVideoState = (\n video: Video | null,\n duration: number,\n framerate: number,\n currentTimestamp: number,\n options: Materialized<Omit<PlaybackOptions, \"seek\">>,\n currentTime: SharedValue<number>,\n currentFrame: SharedValue<SkImage | null>,\n lastTimestamp: SharedValue<number>,\n seek: SharedValue<number | null>\n) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (options.paused) {\n return;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(\n frameDuration / options.playbackSpeed\n );\n if (currentTime.value + delta >= duration && options.looping) {\n seek.value = 0;\n }\n if (seek.value !== null) {\n video.seek(seek.value);\n currentTime.value = seek.value;\n setFrame(video, currentFrame);\n lastTimestamp.value = currentTimestamp;\n seek.value = null;\n return;\n }\n\n if (delta >= currentFrameDuration) {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n};\n"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,gBAAgB;AAmBzC,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,KAAY,EACZC,YAAyC,KACtC;EACH,SAAS;;EACT,MAAMC,GAAG,GAAGF,KAAK,CAACG,SAAS,CAAC,CAAC;EAC7B,IAAID,GAAG,EAAE;IACP,IAAID,Y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,KAAK,EAAEC,YAAY,CAAC;IAC7BY,WAAW,CAACT,KAAK,IAAIa,KAAK;IAC1BH,aAAa,CAACV,KAAK,GAAGO,gBAAgB;EACxC;AACF,CAAC"}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { SharedValue } from "react-native-reanimated";
|
2
|
-
import type { SkImage, Video } from "../../skia/types";
|
3
|
-
export 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
|
-
}
|
10
|
-
type Materialized<T> = {
|
11
|
-
[K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
|
12
|
-
};
|
13
|
-
export type MaterializedPlaybackOptions = Materialized<Omit<PlaybackOptions, "seek">>;
|
14
|
-
export declare const setFrame: (video: Video, currentFrame: SharedValue<SkImage | null>) => void;
|
15
|
-
export declare const processVideoState: (video: Video | null, duration: number, framerate: number, currentTimestamp: number, options: Materialized<Omit<PlaybackOptions, "seek">>, currentTime: SharedValue<number>, currentFrame: SharedValue<SkImage | null>, lastTimestamp: SharedValue<number>, seek: SharedValue<number | null>) => void;
|
16
|
-
export {};
|
@@ -1,82 +0,0 @@
|
|
1
|
-
import type { SharedValue } from "react-native-reanimated";
|
2
|
-
|
3
|
-
import type { SkImage, Video } from "../../skia/types";
|
4
|
-
import { Platform } from "../../Platform";
|
5
|
-
|
6
|
-
export type Animated<T> = SharedValue<T> | T;
|
7
|
-
|
8
|
-
export interface PlaybackOptions {
|
9
|
-
playbackSpeed: Animated<number>;
|
10
|
-
looping: Animated<boolean>;
|
11
|
-
paused: Animated<boolean>;
|
12
|
-
seek: Animated<number | null>;
|
13
|
-
}
|
14
|
-
|
15
|
-
type Materialized<T> = {
|
16
|
-
[K in keyof T]: T[K] extends Animated<infer U> ? U : T[K];
|
17
|
-
};
|
18
|
-
|
19
|
-
export type MaterializedPlaybackOptions = Materialized<
|
20
|
-
Omit<PlaybackOptions, "seek">
|
21
|
-
>;
|
22
|
-
|
23
|
-
export const setFrame = (
|
24
|
-
video: Video,
|
25
|
-
currentFrame: SharedValue<SkImage | null>
|
26
|
-
) => {
|
27
|
-
"worklet";
|
28
|
-
const img = video.nextImage();
|
29
|
-
if (img) {
|
30
|
-
if (currentFrame.value) {
|
31
|
-
currentFrame.value.dispose();
|
32
|
-
}
|
33
|
-
if (Platform.OS === "android") {
|
34
|
-
currentFrame.value = img.makeNonTextureImage();
|
35
|
-
} else {
|
36
|
-
currentFrame.value = img;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
};
|
40
|
-
|
41
|
-
export const processVideoState = (
|
42
|
-
video: Video | null,
|
43
|
-
duration: number,
|
44
|
-
framerate: number,
|
45
|
-
currentTimestamp: number,
|
46
|
-
options: Materialized<Omit<PlaybackOptions, "seek">>,
|
47
|
-
currentTime: SharedValue<number>,
|
48
|
-
currentFrame: SharedValue<SkImage | null>,
|
49
|
-
lastTimestamp: SharedValue<number>,
|
50
|
-
seek: SharedValue<number | null>
|
51
|
-
) => {
|
52
|
-
"worklet";
|
53
|
-
if (!video) {
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
if (options.paused) {
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
const delta = currentTimestamp - lastTimestamp.value;
|
60
|
-
|
61
|
-
const frameDuration = 1000 / framerate;
|
62
|
-
const currentFrameDuration = Math.floor(
|
63
|
-
frameDuration / options.playbackSpeed
|
64
|
-
);
|
65
|
-
if (currentTime.value + delta >= duration && options.looping) {
|
66
|
-
seek.value = 0;
|
67
|
-
}
|
68
|
-
if (seek.value !== null) {
|
69
|
-
video.seek(seek.value);
|
70
|
-
currentTime.value = seek.value;
|
71
|
-
setFrame(video, currentFrame);
|
72
|
-
lastTimestamp.value = currentTimestamp;
|
73
|
-
seek.value = null;
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
|
77
|
-
if (delta >= currentFrameDuration) {
|
78
|
-
setFrame(video, currentFrame);
|
79
|
-
currentTime.value += delta;
|
80
|
-
lastTimestamp.value = currentTimestamp;
|
81
|
-
}
|
82
|
-
};
|