@shopify/react-native-skia 0.1.210 → 0.1.211
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.
- package/cpp/api/JsiSkAnimatedImage.h +60 -0
- package/cpp/api/JsiSkAnimatedImageFactory.h +39 -0
- package/cpp/api/JsiSkApi.h +4 -0
- package/cpp/api/JsiSkImage.h +15 -23
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/commonjs/external/reanimated/moduleWrapper.js +11 -11
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/commonjs/skia/core/AnimatedImage.js +65 -0
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/core/index.d.ts +1 -0
- package/lib/commonjs/skia/core/index.js +13 -0
- package/lib/commonjs/skia/core/index.js.map +1 -1
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js +6 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js +6 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.js +32 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.js.map +1 -0
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +13 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImage.js +44 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js +32 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkia.js +3 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/module/external/reanimated/moduleWrapper.js +8 -11
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/module/skia/core/AnimatedImage.js +49 -0
- package/lib/module/skia/core/AnimatedImage.js.map +1 -0
- package/lib/module/skia/core/index.d.ts +1 -0
- package/lib/module/skia/core/index.js +1 -0
- package/lib/module/skia/core/index.js.map +1 -1
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.js +2 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js +2 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
- package/lib/module/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/module/skia/types/AnimatedImage/index.js +3 -0
- package/lib/module/skia/types/AnimatedImage/index.js.map +1 -0
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/module/skia/web/JsiSkAnimatedImage.js +33 -0
- package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.js +20 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkia.js +2 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/typescript/src/skia/core/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/typescript/src/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/typescript/src/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/package.json +1 -1
- package/src/external/reanimated/moduleWrapper.ts +9 -8
- package/src/skia/core/AnimatedImage.ts +63 -0
- package/src/skia/core/index.ts +1 -0
- package/src/skia/types/AnimatedImage/AnimatedImage.ts +29 -0
- package/src/skia/types/AnimatedImage/AnimatedImageFactory.ts +15 -0
- package/src/skia/types/AnimatedImage/index.ts +2 -0
- package/src/skia/types/Skia.ts +3 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkAnimatedImage.ts +35 -0
- package/src/skia/web/JsiSkAnimatedImageFactory.ts +27 -0
- package/src/skia/web/JsiSkia.ts +2 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <utility>
|
|
6
|
+
|
|
7
|
+
#include "JsiSkHostObjects.h"
|
|
8
|
+
|
|
9
|
+
#pragma clang diagnostic push
|
|
10
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
11
|
+
|
|
12
|
+
#include "JsiSkImage.h"
|
|
13
|
+
#include "SkBase64.h"
|
|
14
|
+
#include "SkStream.h"
|
|
15
|
+
#include "include/codec/SkEncodedImageFormat.h"
|
|
16
|
+
|
|
17
|
+
#include "include/android/SkAnimatedImage.h"
|
|
18
|
+
#include "include/codec/SkAndroidCodec.h"
|
|
19
|
+
|
|
20
|
+
#pragma clang diagnostic pop
|
|
21
|
+
|
|
22
|
+
#include <jsi/jsi.h>
|
|
23
|
+
|
|
24
|
+
namespace RNSkia {
|
|
25
|
+
|
|
26
|
+
namespace jsi = facebook::jsi;
|
|
27
|
+
|
|
28
|
+
class JsiSkAnimatedImage
|
|
29
|
+
: public JsiSkWrappingSkPtrHostObject<SkAnimatedImage> {
|
|
30
|
+
public:
|
|
31
|
+
// TODO-API: Properties?
|
|
32
|
+
JSI_HOST_FUNCTION(getCurrentFrame) {
|
|
33
|
+
auto image = getObject()->getCurrentFrame();
|
|
34
|
+
return jsi::Object::createFromHostObject(
|
|
35
|
+
runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
JSI_HOST_FUNCTION(currentFrameDuration) {
|
|
39
|
+
return static_cast<int>(getObject()->currentFrameDuration());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
JSI_HOST_FUNCTION(decodeNextFrame) {
|
|
43
|
+
return static_cast<int>(getObject()->decodeNextFrame());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
EXPORT_JSI_API_TYPENAME(JsiSkAnimatedImage, "AnimatedImage")
|
|
47
|
+
|
|
48
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkAnimatedImage, dispose),
|
|
49
|
+
JSI_EXPORT_FUNC(JsiSkAnimatedImage, getCurrentFrame),
|
|
50
|
+
JSI_EXPORT_FUNC(JsiSkAnimatedImage,
|
|
51
|
+
currentFrameDuration),
|
|
52
|
+
JSI_EXPORT_FUNC(JsiSkAnimatedImage, decodeNextFrame))
|
|
53
|
+
|
|
54
|
+
JsiSkAnimatedImage(std::shared_ptr<RNSkPlatformContext> context,
|
|
55
|
+
const sk_sp<SkAnimatedImage> image)
|
|
56
|
+
: JsiSkWrappingSkPtrHostObject<SkAnimatedImage>(std::move(context),
|
|
57
|
+
std::move(image)) {}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
} // namespace RNSkia
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <utility>
|
|
5
|
+
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include "JsiPromises.h"
|
|
9
|
+
#include "JsiSkAnimatedImage.h"
|
|
10
|
+
#include "JsiSkData.h"
|
|
11
|
+
#include "JsiSkHostObjects.h"
|
|
12
|
+
|
|
13
|
+
namespace RNSkia {
|
|
14
|
+
|
|
15
|
+
namespace jsi = facebook::jsi;
|
|
16
|
+
|
|
17
|
+
class JsiSkAnimatedImageFactory : public JsiSkHostObject {
|
|
18
|
+
public:
|
|
19
|
+
JSI_HOST_FUNCTION(MakeAnimatedImageFromEncoded) {
|
|
20
|
+
auto data = JsiSkData::fromValue(runtime, arguments[0]);
|
|
21
|
+
auto codec = SkAndroidCodec::MakeFromData(data);
|
|
22
|
+
auto image = SkAnimatedImage::Make(std::move(codec));
|
|
23
|
+
if (image == nullptr) {
|
|
24
|
+
return jsi::Value::null();
|
|
25
|
+
}
|
|
26
|
+
return jsi::Object::createFromHostObject(
|
|
27
|
+
runtime,
|
|
28
|
+
std::make_shared<JsiSkAnimatedImage>(getContext(), std::move(image)));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkAnimatedImageFactory,
|
|
32
|
+
MakeAnimatedImageFromEncoded))
|
|
33
|
+
|
|
34
|
+
explicit JsiSkAnimatedImageFactory(
|
|
35
|
+
std::shared_ptr<RNSkPlatformContext> context)
|
|
36
|
+
: JsiSkHostObject(std::move(context)) {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace RNSkia
|
package/cpp/api/JsiSkApi.h
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
#include "JsiSkHostObjects.h"
|
|
8
8
|
|
|
9
|
+
#include "JsiSkAnimatedImage.h"
|
|
10
|
+
#include "JsiSkAnimatedImageFactory.h"
|
|
9
11
|
#include "JsiSkColor.h"
|
|
10
12
|
#include "JsiSkColorFilter.h"
|
|
11
13
|
#include "JsiSkColorFilterFactory.h"
|
|
@@ -79,6 +81,8 @@ public:
|
|
|
79
81
|
installReadonlyProperty("SVG", std::make_shared<JsiSkSVGFactory>(context));
|
|
80
82
|
installReadonlyProperty("Image",
|
|
81
83
|
std::make_shared<JsiSkImageFactory>(context));
|
|
84
|
+
installReadonlyProperty(
|
|
85
|
+
"AnimatedImage", std::make_shared<JsiSkAnimatedImageFactory>(context));
|
|
82
86
|
installReadonlyProperty("Typeface",
|
|
83
87
|
std::make_shared<JsiSkTypefaceFactory>(context));
|
|
84
88
|
installReadonlyProperty("Data",
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -64,23 +64,32 @@ public:
|
|
|
64
64
|
std::make_shared<JsiSkShader>(getContext(), std::move(shader)));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
sk_sp<SkData> encodeImageData(const jsi::Value *arguments, size_t count) {
|
|
68
68
|
// Get optional parameters
|
|
69
69
|
auto format =
|
|
70
70
|
count >= 1 ? static_cast<SkEncodedImageFormat>(arguments[0].asNumber())
|
|
71
71
|
: SkEncodedImageFormat::kPNG;
|
|
72
|
-
auto quality = count == 2 ? arguments[1].asNumber() : 100.0;
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
auto quality = count == 2 ? arguments[1].asNumber() : 100.0;
|
|
74
|
+
auto image = getObject();
|
|
75
|
+
if (image->isTextureBacked()) {
|
|
76
|
+
image = image->makeNonTextureImage();
|
|
77
|
+
}
|
|
75
78
|
sk_sp<SkData> data;
|
|
76
79
|
if (format == SkEncodedImageFormat::kJPEG) {
|
|
77
80
|
SkJpegEncoder::Options options;
|
|
78
81
|
options.fQuality = quality;
|
|
79
|
-
data = SkJpegEncoder::Encode(nullptr,
|
|
82
|
+
data = SkJpegEncoder::Encode(nullptr, image.get(), options);
|
|
80
83
|
} else {
|
|
81
84
|
SkPngEncoder::Options options;
|
|
82
|
-
data = SkPngEncoder::Encode(nullptr,
|
|
85
|
+
data = SkPngEncoder::Encode(nullptr, image.get(), options);
|
|
83
86
|
}
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
JSI_HOST_FUNCTION(encodeToBytes) {
|
|
91
|
+
auto data = encodeImageData(arguments, count);
|
|
92
|
+
|
|
84
93
|
auto arrayCtor =
|
|
85
94
|
runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
|
|
86
95
|
size_t size = data->size();
|
|
@@ -99,25 +108,8 @@ public:
|
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
JSI_HOST_FUNCTION(encodeToBase64) {
|
|
102
|
-
|
|
103
|
-
auto format =
|
|
104
|
-
count >= 1 ? static_cast<SkEncodedImageFormat>(arguments[0].asNumber())
|
|
105
|
-
: SkEncodedImageFormat::kPNG;
|
|
111
|
+
auto data = encodeImageData(arguments, count);
|
|
106
112
|
|
|
107
|
-
auto quality = count == 2 ? arguments[1].asNumber() : 100.0;
|
|
108
|
-
auto image = getObject();
|
|
109
|
-
if (image->isTextureBacked()) {
|
|
110
|
-
image = image->makeNonTextureImage();
|
|
111
|
-
}
|
|
112
|
-
sk_sp<SkData> data;
|
|
113
|
-
if (format == SkEncodedImageFormat::kJPEG) {
|
|
114
|
-
SkJpegEncoder::Options options;
|
|
115
|
-
options.fQuality = quality;
|
|
116
|
-
data = SkJpegEncoder::Encode(nullptr, image.get(), options);
|
|
117
|
-
} else {
|
|
118
|
-
SkPngEncoder::Options options;
|
|
119
|
-
data = SkPngEncoder::Encode(nullptr, image.get(), options);
|
|
120
|
-
}
|
|
121
113
|
auto len = SkBase64::Encode(data->bytes(), data->size(), nullptr);
|
|
122
114
|
auto buffer = std::string(len, 0);
|
|
123
115
|
SkBase64::Encode(data->bytes(), data->size(),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { SharedValueType } from "../../renderer/processors/Animations";
|
|
2
2
|
export declare const HAS_REANIMATED2: boolean;
|
|
3
3
|
export declare const HAS_REANIMATED3: boolean;
|
|
4
|
+
export declare function throwOnMissingReanimated(): void;
|
|
4
5
|
export declare const useSharedValue: any;
|
|
6
|
+
export declare const useFrameCallback: (...args: any[]) => any;
|
|
5
7
|
export declare const startMapper: any;
|
|
6
8
|
export declare const stopMapper: any;
|
|
7
9
|
export declare const runOnJS: any;
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.stopMapper = exports.startMapper = exports.runOnJS = exports.isSharedValue = exports.HAS_REANIMATED3 = exports.HAS_REANIMATED2 = void 0;
|
|
7
|
+
exports.throwOnMissingReanimated = throwOnMissingReanimated;
|
|
8
|
+
exports.useSharedValue = exports.useFrameCallback = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = require("react");
|
|
9
11
|
|
|
10
|
-
var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4;
|
|
12
|
+
var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5;
|
|
11
13
|
|
|
12
14
|
// This one is needed for the deprecated useSharedValue function
|
|
13
15
|
// We can remove it once we remove the deprecation
|
|
14
|
-
|
|
15
|
-
let Reanimated2; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
|
|
16
|
+
let Reanimated2;
|
|
17
17
|
let Reanimated3;
|
|
18
18
|
let reanimatedVersion;
|
|
19
19
|
|
|
@@ -32,7 +32,7 @@ exports.HAS_REANIMATED2 = HAS_REANIMATED2;
|
|
|
32
32
|
const HAS_REANIMATED3 = !!Reanimated3;
|
|
33
33
|
exports.HAS_REANIMATED3 = HAS_REANIMATED3;
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function throwOnMissingReanimated() {
|
|
36
36
|
if (!HAS_REANIMATED2) {
|
|
37
37
|
throw new Error("Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
|
|
38
38
|
react-native-skia's integration layer API.");
|
|
@@ -43,8 +43,6 @@ function throwOnMissingReanimated3() {
|
|
|
43
43
|
if (!HAS_REANIMATED3) {
|
|
44
44
|
throw new Error(`Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
throwOnMissingReanimated2();
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || (value => (0, _react.useMemo)(() => ({
|
|
@@ -52,11 +50,13 @@ const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated ===
|
|
|
52
50
|
}), [value]));
|
|
53
51
|
|
|
54
52
|
exports.useSharedValue = useSharedValue;
|
|
55
|
-
const
|
|
53
|
+
const useFrameCallback = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useFrameCallback) || throwOnMissingReanimated;
|
|
54
|
+
exports.useFrameCallback = useFrameCallback;
|
|
55
|
+
const startMapper = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.startMapper) || throwOnMissingReanimated;
|
|
56
56
|
exports.startMapper = startMapper;
|
|
57
|
-
const stopMapper = ((
|
|
57
|
+
const stopMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.stopMapper) || throwOnMissingReanimated;
|
|
58
58
|
exports.stopMapper = stopMapper;
|
|
59
|
-
const runOnJS = ((
|
|
59
|
+
const runOnJS = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.runOnJS) || throwOnMissingReanimated;
|
|
60
60
|
exports.runOnJS = runOnJS;
|
|
61
61
|
|
|
62
62
|
const isSharedValue = value => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","
|
|
1
|
+
{"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","throwOnMissingReanimated3","useSharedValue","value","useMemo","useFrameCallback","startMapper","stopMapper","runOnJS","isSharedValue"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useMemo } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\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 =\n // eslint-disable-next-line import/extensions\n 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\nfunction throwOnMissingReanimated3() {\n if (!HAS_REANIMATED3) {\n throw new Error(\n `Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`\n );\n }\n}\n\nexport const useSharedValue =\n Reanimated2?.useSharedValue ||\n ((value: number) => useMemo(() => ({ value }), [value]));\nexport const useFrameCallback: (...args: any[]) => any =\n Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper = Reanimated2?.startMapper || throwOnMissingReanimated;\nexport const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated;\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const isSharedValue = <T>(\n value: unknown\n): value is SharedValueType<T> => {\n throwOnMissingReanimated3();\n return !!value && Reanimated3.isSharedValue(value);\n};\n"],"mappings":";;;;;;;;;AACA;;;;AAIA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GACf;EACAC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAFlD;;EAGA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CAXD,CAWE,OAAOM,CAAP,EAAU,CAAE;;AAEP,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;;AACA,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;;;AAEA,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;;AAED,SAASC,yBAAT,GAAqC;EACnC,IAAI,CAACH,eAAL,EAAsB;IACpB,MAAM,IAAIE,KAAJ,CACH,sBAAqBR,iBAAkB,sDADpC,CAAN;EAGD;AACF;;AAEM,MAAMU,cAAc,GACzB,gBAAAZ,WAAW,UAAX,kDAAaY,cAAb,MACEC,KAAD,IAAmB,IAAAC,cAAA,EAAQ,OAAO;EAAED;AAAF,CAAP,CAAR,EAA2B,CAACA,KAAD,CAA3B,CADpB,CADK;;;AAGA,MAAME,gBAAyC,GACpD,iBAAAf,WAAW,UAAX,oDAAae,gBAAb,KAAiCN,wBAD5B;;AAGA,MAAMO,WAAW,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,WAAb,KAA4BP,wBAAhD;;AACA,MAAMQ,UAAU,GAAG,iBAAAjB,WAAW,UAAX,oDAAaiB,UAAb,KAA2BR,wBAA9C;;AACA,MAAMS,OAAO,GAAG,iBAAAlB,WAAW,UAAX,oDAAakB,OAAb,KAAwBT,wBAAxC;;;AACA,MAAMU,aAAa,GACxBN,KAD2B,IAEK;EAChCF,yBAAyB;EACzB,OAAO,CAAC,CAACE,KAAF,IAAWZ,WAAW,CAACkB,aAAZ,CAA0BN,KAA1B,CAAlB;AACD,CALM"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DataSourceParam } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a Skia Animated Image object
|
|
4
|
+
* */
|
|
5
|
+
export declare const useAnimatedImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkAnimatedImage | null;
|
|
6
|
+
export declare const useAnimatedImageValue: (source: DataSourceParam) => any;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedImageValue = exports.useAnimatedImage = void 0;
|
|
7
|
+
|
|
8
|
+
var _moduleWrapper = require("../../external/reanimated/moduleWrapper");
|
|
9
|
+
|
|
10
|
+
var _Skia = require("../Skia");
|
|
11
|
+
|
|
12
|
+
var _Data = require("./Data");
|
|
13
|
+
|
|
14
|
+
const animatedImgFactory = _Skia.Skia.AnimatedImage.MakeAnimatedImageFromEncoded.bind(_Skia.Skia.AnimatedImage);
|
|
15
|
+
/**
|
|
16
|
+
* Returns a Skia Animated Image object
|
|
17
|
+
* */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const useAnimatedImage = (source, onError) => (0, _Data.useRawData)(source, animatedImgFactory, onError);
|
|
21
|
+
|
|
22
|
+
exports.useAnimatedImage = useAnimatedImage;
|
|
23
|
+
const DEFAULT_FRAME_DURATION = 60;
|
|
24
|
+
|
|
25
|
+
const useAnimatedImageValue = source => {
|
|
26
|
+
(0, _moduleWrapper.throwOnMissingReanimated)();
|
|
27
|
+
const currentFrame = (0, _moduleWrapper.useSharedValue)(null);
|
|
28
|
+
const lastTimestamp = (0, _moduleWrapper.useSharedValue)(0);
|
|
29
|
+
const animatedImage = useAnimatedImage(source, err => {
|
|
30
|
+
console.error(err);
|
|
31
|
+
throw new Error(`Could not load animated image - got '${err.message}'`);
|
|
32
|
+
});
|
|
33
|
+
const frameDuration = (animatedImage === null || animatedImage === void 0 ? void 0 : animatedImage.currentFrameDuration()) || DEFAULT_FRAME_DURATION; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
|
|
35
|
+
(0, _moduleWrapper.useFrameCallback)(frameInfo => {
|
|
36
|
+
if (!animatedImage) {
|
|
37
|
+
currentFrame.value = null;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
timestamp
|
|
43
|
+
} = frameInfo;
|
|
44
|
+
const elapsed = timestamp - lastTimestamp.value; // Check if it's time to switch frames based on GIF frame duration
|
|
45
|
+
|
|
46
|
+
if (elapsed < frameDuration) {
|
|
47
|
+
return;
|
|
48
|
+
} // Update the current frame
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
animatedImage.decodeNextFrame();
|
|
52
|
+
|
|
53
|
+
if (currentFrame.value) {
|
|
54
|
+
currentFrame.value.dispose();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
currentFrame.value = animatedImage.getCurrentFrame(); // Update the last timestamp
|
|
58
|
+
|
|
59
|
+
lastTimestamp.value = timestamp; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, true);
|
|
61
|
+
return currentFrame;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.useAnimatedImageValue = useAnimatedImageValue;
|
|
65
|
+
//# sourceMappingURL=AnimatedImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["animatedImgFactory","Skia","AnimatedImage","MakeAnimatedImageFromEncoded","bind","useAnimatedImage","source","onError","useRawData","DEFAULT_FRAME_DURATION","useAnimatedImageValue","throwOnMissingReanimated","currentFrame","useSharedValue","lastTimestamp","animatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","useFrameCallback","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame"],"sources":["AnimatedImage.ts"],"sourcesContent":["import {\n throwOnMissingReanimated,\n useFrameCallback,\n useSharedValue,\n} from \"../../external/reanimated/moduleWrapper\";\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst animatedImgFactory = Skia.AnimatedImage.MakeAnimatedImageFromEncoded.bind(\n Skia.AnimatedImage\n);\n\n/**\n * Returns a Skia Animated Image object\n * */\nexport const useAnimatedImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, animatedImgFactory, onError);\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (source: DataSourceParam) => {\n throwOnMissingReanimated();\n const currentFrame = useSharedValue(null);\n const lastTimestamp = useSharedValue(0);\n const animatedImage = useAnimatedImage(source, (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n });\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n useFrameCallback((frameInfo: any) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, true);\n return currentFrame;\n};\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAGA;;AAEA,MAAMA,kBAAkB,GAAGC,UAAA,CAAKC,aAAL,CAAmBC,4BAAnB,CAAgDC,IAAhD,CACzBH,UAAA,CAAKC,aADoB,CAA3B;AAIA;AACA;AACA;;;AACO,MAAMG,gBAAgB,GAAG,CAC9BC,MAD8B,EAE9BC,OAF8B,KAG3B,IAAAC,gBAAA,EAAWF,MAAX,EAAmBN,kBAAnB,EAAuCO,OAAvC,CAHE;;;AAKP,MAAME,sBAAsB,GAAG,EAA/B;;AAEO,MAAMC,qBAAqB,GAAIJ,MAAD,IAA6B;EAChE,IAAAK,uCAAA;EACA,MAAMC,YAAY,GAAG,IAAAC,6BAAA,EAAe,IAAf,CAArB;EACA,MAAMC,aAAa,GAAG,IAAAD,6BAAA,EAAe,CAAf,CAAtB;EACA,MAAME,aAAa,GAAGV,gBAAgB,CAACC,MAAD,EAAUU,GAAD,IAAS;IACtDC,OAAO,CAACC,KAAR,CAAcF,GAAd;IACA,MAAM,IAAIG,KAAJ,CAAW,wCAAuCH,GAAG,CAACI,OAAQ,GAA9D,CAAN;EACD,CAHqC,CAAtC;EAIA,MAAMC,aAAa,GACjB,CAAAN,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEO,oBAAf,OAAyCb,sBAD3C,CARgE,CAWhE;;EACA,IAAAc,+BAAA,EAAkBC,SAAD,IAAoB;IACnC,IAAI,CAACT,aAAL,EAAoB;MAClBH,YAAY,CAACa,KAAb,GAAqB,IAArB;MACA;IACD;;IAED,MAAM;MAAEC;IAAF,IAAgBF,SAAtB;IACA,MAAMG,OAAO,GAAGD,SAAS,GAAGZ,aAAa,CAACW,KAA1C,CAPmC,CASnC;;IACA,IAAIE,OAAO,GAAGN,aAAd,EAA6B;MAC3B;IACD,CAZkC,CAcnC;;;IACAN,aAAa,CAACa,eAAd;;IACA,IAAIhB,YAAY,CAACa,KAAjB,EAAwB;MACtBb,YAAY,CAACa,KAAb,CAAmBI,OAAnB;IACD;;IACDjB,YAAY,CAACa,KAAb,GAAqBV,aAAa,CAACe,eAAd,EAArB,CAnBmC,CAqBnC;;IACAhB,aAAa,CAACW,KAAd,GAAsBC,SAAtB,CAtBmC,CAuBnC;EACD,CAxBD,EAwBG,IAxBH;EAyBA,OAAOd,YAAP;AACD,CAtCM"}
|
|
@@ -56,6 +56,19 @@ Object.keys(_Image).forEach(function (key) {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
var _AnimatedImage = require("./AnimatedImage");
|
|
60
|
+
|
|
61
|
+
Object.keys(_AnimatedImage).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _AnimatedImage[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return _AnimatedImage[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
59
72
|
var _Picture = require("./Picture");
|
|
60
73
|
|
|
61
74
|
Object.keys(_Picture).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Data\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Image\";\nexport * from \"./Picture\";\nexport * from \"./SVG\";\nexport * from \"./Vector\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./Matrix\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Data\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./Picture\";\nexport * from \"./SVG\";\nexport * from \"./Vector\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./Matrix\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SkJSIInstance } from "../JsiInstance";
|
|
2
|
+
import type { SkImage } from "../Image";
|
|
3
|
+
export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
|
|
4
|
+
/**
|
|
5
|
+
* Decode the next frame.
|
|
6
|
+
*
|
|
7
|
+
* If the animation is on the last frame or has hit an error, returns
|
|
8
|
+
* kFinished (-1).
|
|
9
|
+
*/
|
|
10
|
+
decodeNextFrame(): number;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current frame as an SkImage. The SkImage will not change
|
|
13
|
+
* after it has been returned.
|
|
14
|
+
* If there is no current frame, null will be returned.
|
|
15
|
+
*/
|
|
16
|
+
getCurrentFrame(): SkImage | null;
|
|
17
|
+
/**
|
|
18
|
+
* How long to display the current frame.
|
|
19
|
+
*
|
|
20
|
+
* Useful for the first frame, for which decodeNextFrame is called
|
|
21
|
+
* internally.
|
|
22
|
+
*/
|
|
23
|
+
currentFrameDuration(): number;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["AnimatedImage.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkImage } from \"../Image\";\n\nexport interface SkAnimatedImage extends SkJSIInstance<\"AnimatedImage\"> {\n /**\n * Decode the next frame.\n *\n * If the animation is on the last frame or has hit an error, returns\n * kFinished (-1).\n */\n decodeNextFrame(): number;\n\n /**\n * Returns the current frame as an SkImage. The SkImage will not change\n * after it has been returned.\n * If there is no current frame, null will be returned.\n */\n getCurrentFrame(): SkImage | null;\n\n /**\n * How long to display the current frame.\n *\n * Useful for the first frame, for which decodeNextFrame is called\n * internally.\n */\n currentFrameDuration(): number;\n\n // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SkData } from "../Data";
|
|
2
|
+
import type { SkAnimatedImage } from "./AnimatedImage";
|
|
3
|
+
export interface AnimatedImageFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Decodes the given bytes into an animated image. Returns null if the bytes were invalid.
|
|
6
|
+
* The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.
|
|
7
|
+
*
|
|
8
|
+
* The returned AnimatedImage will be "pointing to" the first frame, i.e. currentFrameDuration
|
|
9
|
+
* and makeImageAtCurrentFrame will be referring to the first frame.
|
|
10
|
+
* @param encoded
|
|
11
|
+
*/
|
|
12
|
+
MakeAnimatedImageFromEncoded: (encoded: SkData) => SkAnimatedImage | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["AnimatedImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\n\nimport type { SkAnimatedImage } from \"./AnimatedImage\";\n\nexport interface AnimatedImageFactory {\n /**\n * Decodes the given bytes into an animated image. Returns null if the bytes were invalid.\n * The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.\n *\n * The returned AnimatedImage will be \"pointing to\" the first frame, i.e. currentFrameDuration\n * and makeImageAtCurrentFrame will be referring to the first frame.\n * @param encoded\n */\n MakeAnimatedImageFromEncoded: (encoded: SkData) => SkAnimatedImage | null;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _AnimatedImage = require("./AnimatedImage");
|
|
8
|
+
|
|
9
|
+
Object.keys(_AnimatedImage).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _AnimatedImage[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _AnimatedImage[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _AnimatedImageFactory = require("./AnimatedImageFactory");
|
|
21
|
+
|
|
22
|
+
Object.keys(_AnimatedImageFactory).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _AnimatedImageFactory[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _AnimatedImageFactory[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./AnimatedImage\";\nexport * from \"./AnimatedImageFactory\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -24,6 +24,7 @@ import type { SkContourMeasureIter } from "./ContourMeasure";
|
|
|
24
24
|
import type { PictureFactory, SkPictureRecorder } from "./Picture";
|
|
25
25
|
import type { Color, SkColor } from "./Color";
|
|
26
26
|
import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
|
|
27
|
+
import type { AnimatedImageFactory } from "./AnimatedImage";
|
|
27
28
|
/**
|
|
28
29
|
* Declares the interface for the native Skia API
|
|
29
30
|
*/
|
|
@@ -63,6 +64,7 @@ export interface Skia {
|
|
|
63
64
|
MakeVertices(mode: VertexMode, positions: SkPoint[], textureCoordinates?: SkPoint[] | null, colors?: SkColor[], indices?: number[] | null, isVolatile?: boolean): SkVertices;
|
|
64
65
|
Data: DataFactory;
|
|
65
66
|
Image: ImageFactory;
|
|
67
|
+
AnimatedImage: AnimatedImageFactory;
|
|
66
68
|
SVG: SVGFactory;
|
|
67
69
|
TextBlob: TextBlobFactory;
|
|
68
70
|
Surface: SurfaceFactory;
|
|
@@ -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 { 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\";\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) => SkRect;\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 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 SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\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 { 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\";\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) => SkRect;\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 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}\n"],"mappings":""}
|
|
@@ -108,6 +108,19 @@ Object.keys(_Image).forEach(function (key) {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
+
var _AnimatedImage = require("./AnimatedImage");
|
|
112
|
+
|
|
113
|
+
Object.keys(_AnimatedImage).forEach(function (key) {
|
|
114
|
+
if (key === "default" || key === "__esModule") return;
|
|
115
|
+
if (key in exports && exports[key] === _AnimatedImage[key]) return;
|
|
116
|
+
Object.defineProperty(exports, key, {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () {
|
|
119
|
+
return _AnimatedImage[key];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
111
124
|
var _ColorFilter = require("./ColorFilter");
|
|
112
125
|
|
|
113
126
|
Object.keys(_ColorFilter).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AnimatedImage, CanvasKit } from "canvaskit-wasm";
|
|
2
|
+
import type { SkAnimatedImage } from "../types/AnimatedImage";
|
|
3
|
+
import { HostObject } from "./Host";
|
|
4
|
+
import { JsiSkImage } from "./JsiSkImage";
|
|
5
|
+
export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "AnimatedImage"> implements SkAnimatedImage {
|
|
6
|
+
constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
|
|
7
|
+
decodeNextFrame(): number;
|
|
8
|
+
currentFrameDuration(): number;
|
|
9
|
+
getCurrentFrame(): JsiSkImage | null;
|
|
10
|
+
dispose: () => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JsiSkAnimatedImage = void 0;
|
|
7
|
+
|
|
8
|
+
var _Host = require("./Host");
|
|
9
|
+
|
|
10
|
+
var _JsiSkImage = require("./JsiSkImage");
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
class JsiSkAnimatedImage extends _Host.HostObject {
|
|
15
|
+
constructor(CanvasKit, ref) {
|
|
16
|
+
super(CanvasKit, ref, "AnimatedImage");
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "dispose", () => {
|
|
19
|
+
this.ref.delete();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
decodeNextFrame() {
|
|
24
|
+
return this.ref.decodeNextFrame();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
currentFrameDuration() {
|
|
28
|
+
return this.ref.currentFrameDuration();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getCurrentFrame() {
|
|
32
|
+
const image = this.ref.makeImageAtCurrentFrame();
|
|
33
|
+
|
|
34
|
+
if (image === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return new _JsiSkImage.JsiSkImage(this.CanvasKit, image);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.JsiSkAnimatedImage = JsiSkAnimatedImage;
|
|
44
|
+
//# sourceMappingURL=JsiSkAnimatedImage.js.map
|