@shopify/react-native-skia 0.1.186 → 0.1.188
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/android/build.gradle +15 -2
- package/cpp/rnskia/dom/base/JsiDependencyManager.h +47 -47
- package/cpp/rnskia/dom/base/JsiDomNode.h +6 -7
- package/cpp/rnskia/dom/base/NodePropsContainer.h +27 -3
- package/cpp/rnskia/dom/props/ColorProp.h +7 -0
- package/globalJestSetup.js +6 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +10 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +7 -3
- package/ios/RNSkia-iOS/SkiaManager.mm +3 -27
- package/jestSetup.js +2 -3
- package/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolateColors.js +3 -2
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
- package/lib/commonjs/mock/index.d.ts +2 -15
- package/lib/commonjs/mock/index.js +37 -111
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/types/Color.d.ts +1 -1
- package/lib/commonjs/skia/types/Color.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColor.js +2 -0
- package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
- package/lib/module/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/module/animation/functions/interpolateColors.js +3 -2
- package/lib/module/animation/functions/interpolateColors.js.map +1 -1
- package/lib/module/mock/index.d.ts +2 -15
- package/lib/module/mock/index.js +33 -96
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/types/Color.d.ts +1 -1
- package/lib/module/skia/types/Color.js.map +1 -1
- package/lib/module/skia/web/JsiSkColor.js +2 -0
- package/lib/module/skia/web/JsiSkColor.js.map +1 -1
- package/lib/typescript/globalJestSetup.d.ts +2 -0
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/typescript/src/mock/index.d.ts +2 -15
- package/lib/typescript/src/skia/types/Color.d.ts +1 -1
- package/package.json +2 -1
- package/src/animation/functions/interpolateColors.ts +2 -1
- package/src/mock/index.ts +35 -99
- package/src/skia/types/Color.ts +1 -1
- package/src/skia/web/JsiSkColor.ts +2 -0
package/android/build.gradle
CHANGED
@@ -272,11 +272,24 @@ task extractJNIFiles {
|
|
272
272
|
extractJNIFiles.mustRunAfter extractAARHeaders
|
273
273
|
|
274
274
|
if (ENABLE_PREFAB) {
|
275
|
-
// Package
|
275
|
+
// Package all the cpp code in a flattened directory structure
|
276
276
|
task prepareHeaders(type: Copy) {
|
277
|
-
from(
|
277
|
+
from("./cpp")
|
278
278
|
into "${project.buildDir}/headers/rnskia/"
|
279
279
|
includeEmptyDirs = false
|
280
|
+
include "**/*.h"
|
281
|
+
eachFile {
|
282
|
+
String path = it.path
|
283
|
+
|
284
|
+
// Skip flattening third_party dir
|
285
|
+
if (path.contains("api/third_party")) {
|
286
|
+
path = path.substring("api/".length())
|
287
|
+
} else {
|
288
|
+
// flatten anything else
|
289
|
+
path = path.substring(path.lastIndexOf("/") + 1)
|
290
|
+
}
|
291
|
+
it.path = path
|
292
|
+
}
|
280
293
|
}
|
281
294
|
preBuild.dependsOn(prepareHeaders)
|
282
295
|
}
|
@@ -64,53 +64,53 @@ public:
|
|
64
64
|
|
65
65
|
// Enumerate registered keys for the given node to only handle known
|
66
66
|
// properties
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
67
|
+
node->getPropsContainer()->enumerateMappedProps(
|
68
|
+
[&](const PropId key, const std::vector<NodeProp *> &propMapping) {
|
69
|
+
auto jsValue = nextProps.getProperty(runtime, key);
|
70
|
+
JsiValue nativeValue(runtime, jsValue);
|
71
|
+
|
72
|
+
if (isAnimatedValue(nativeValue)) {
|
73
|
+
// Handle Skia Animation Values
|
74
|
+
auto animatedValue = getAnimatedValue(nativeValue);
|
75
|
+
auto unsubscribe = animatedValue->addListener(
|
76
|
+
[animatedValue, propMapping](jsi::Runtime &runtime) {
|
77
|
+
// Get value from animation value
|
78
|
+
auto nextJsValue = animatedValue->getCurrent(runtime);
|
79
|
+
// Update all props that listens to this animation value
|
80
|
+
for (auto &prop : propMapping) {
|
81
|
+
prop->updateValue(runtime, nextJsValue);
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
85
|
+
// Save unsubscribe methods
|
86
|
+
unsubscribers.push_back(std::make_pair(animatedValue, unsubscribe));
|
87
|
+
|
88
|
+
} else if (isSelector(nativeValue)) {
|
89
|
+
// Handle Skia Animation Value Selectors
|
90
|
+
auto animatedValue = std::dynamic_pointer_cast<RNSkReadonlyValue>(
|
91
|
+
nativeValue.getValue(PropNameValue).getAsHostObject());
|
92
|
+
|
93
|
+
auto selector =
|
94
|
+
nativeValue.getValue(PropNameSelector).getAsFunction();
|
95
|
+
// Add subscription to animated value in selector
|
96
|
+
auto unsubscribe = animatedValue->addListener(
|
97
|
+
[nativeValue, propMapping, selector = std::move(selector),
|
98
|
+
animatedValue](jsi::Runtime &runtime) {
|
99
|
+
// Get value from animation value
|
100
|
+
jsi::Value jsValue = animatedValue->getCurrent(runtime);
|
101
|
+
// Call selector to transform new value
|
102
|
+
auto selectedJsValue =
|
103
|
+
selector(runtime, jsi::Value::null(), &jsValue, 1);
|
104
|
+
// Update all props that listens to this animation value
|
105
|
+
for (auto &prop : propMapping) {
|
106
|
+
prop->updateValue(runtime, selectedJsValue);
|
107
|
+
}
|
108
|
+
});
|
109
|
+
|
110
|
+
// Save unsubscribe methods
|
111
|
+
unsubscribers.push_back(std::make_pair(animatedValue, unsubscribe));
|
112
|
+
}
|
113
|
+
});
|
114
114
|
|
115
115
|
// Now let's store the subscription info
|
116
116
|
_subscriptions.emplace(node.get(), unsubscribers);
|
@@ -98,13 +98,12 @@ public:
|
|
98
98
|
auto propName = arguments[0].asString(runtime).utf8(runtime);
|
99
99
|
const jsi::Value &propValue = arguments[1];
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
}
|
101
|
+
// Enumerate all props with this name and update. The
|
102
|
+
// enumerateMappedPropsByName function is thread safe and locks props so it
|
103
|
+
// can be called from all threads.
|
104
|
+
_propsContainer->enumerateMappedPropsByName(propName, [&](NodeProp *prop) {
|
105
|
+
prop->updateValue(runtime, propValue);
|
106
|
+
});
|
108
107
|
|
109
108
|
return jsi::Value::undefined();
|
110
109
|
}
|
@@ -41,10 +41,30 @@ public:
|
|
41
41
|
}
|
42
42
|
|
43
43
|
/**
|
44
|
-
|
44
|
+
Enumerate all mapped properties
|
45
45
|
*/
|
46
|
-
|
47
|
-
|
46
|
+
void enumerateMappedProps(
|
47
|
+
const std::function<void(const PropId name,
|
48
|
+
const std::vector<NodeProp *>)> &callback) {
|
49
|
+
std::lock_guard<std::mutex> lock(_mappedPropsLock);
|
50
|
+
for (auto &props : _mappedProperties) {
|
51
|
+
callback(props.first, props.second);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
Enumerates a named property instances from the mapped properties list
|
57
|
+
*/
|
58
|
+
void
|
59
|
+
enumerateMappedPropsByName(const std::string &name,
|
60
|
+
const std::function<void(NodeProp *)> &callback) {
|
61
|
+
std::lock_guard<std::mutex> lock(_mappedPropsLock);
|
62
|
+
auto propMapIt = _mappedProperties.find(JsiPropId::get(name));
|
63
|
+
if (propMapIt != _mappedProperties.end()) {
|
64
|
+
for (auto &prop : propMapIt->second) {
|
65
|
+
callback(prop);
|
66
|
+
}
|
67
|
+
}
|
48
68
|
}
|
49
69
|
|
50
70
|
/**
|
@@ -75,6 +95,7 @@ public:
|
|
75
95
|
Clears all props and data from the container
|
76
96
|
*/
|
77
97
|
void dispose() {
|
98
|
+
std::lock_guard<std::mutex> lock(_mappedPropsLock);
|
78
99
|
_properties.clear();
|
79
100
|
_mappedProperties.clear();
|
80
101
|
}
|
@@ -83,6 +104,8 @@ public:
|
|
83
104
|
Called when the React / JS side sets properties on a node
|
84
105
|
*/
|
85
106
|
void setProps(jsi::Runtime &runtime, const jsi::Value &maybePropsObject) {
|
107
|
+
std::lock_guard<std::mutex> lock(_mappedPropsLock);
|
108
|
+
|
86
109
|
// Clear property mapping
|
87
110
|
_mappedProperties.clear();
|
88
111
|
|
@@ -129,6 +152,7 @@ private:
|
|
129
152
|
std::vector<std::shared_ptr<BaseNodeProp>> _properties;
|
130
153
|
std::map<PropId, std::vector<NodeProp *>> _mappedProperties;
|
131
154
|
PropId _type;
|
155
|
+
std::mutex _mappedPropsLock;
|
132
156
|
};
|
133
157
|
|
134
158
|
} // namespace RNSkia
|
@@ -42,6 +42,13 @@ public:
|
|
42
42
|
return SkColorSetARGB(a.getAsNumber() * 255.0f, r.getAsNumber() * 255.0f,
|
43
43
|
g.getAsNumber() * 255.0f, b.getAsNumber() * 255.0f);
|
44
44
|
|
45
|
+
} else if (color.getType() == PropType::Array) {
|
46
|
+
auto r = color.getAsArray().at(0);
|
47
|
+
auto g = color.getAsArray().at(1);
|
48
|
+
auto b = color.getAsArray().at(2);
|
49
|
+
auto a = color.getAsArray().at(3);
|
50
|
+
return SkColorSetARGB(a.getAsNumber() * 255.0f, r.getAsNumber() * 255.0f,
|
51
|
+
g.getAsNumber() * 255.0f, b.getAsNumber() * 255.0f);
|
45
52
|
} else if (color.getType() == PropType::Number) {
|
46
53
|
return static_cast<SkColor>(color.getAsNumber());
|
47
54
|
} else {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#import <React/RCTBridge+Private.h>
|
3
4
|
#import <React/RCTBridge.h>
|
5
|
+
#import <ReactCommon/RCTTurboModule.h>
|
4
6
|
|
5
7
|
#include <functional>
|
6
8
|
#include <memory>
|
@@ -8,6 +10,7 @@
|
|
8
10
|
|
9
11
|
#include "DisplayLink.h"
|
10
12
|
#include "RNSkPlatformContext.h"
|
13
|
+
#include "ViewScreenshotService.h"
|
11
14
|
|
12
15
|
#include <jsi/jsi.h>
|
13
16
|
|
@@ -27,13 +30,8 @@ static void handleNotification(CFNotificationCenterRef center, void *observer,
|
|
27
30
|
|
28
31
|
class RNSkiOSPlatformContext : public RNSkPlatformContext {
|
29
32
|
public:
|
30
|
-
RNSkiOSPlatformContext(
|
31
|
-
|
32
|
-
std::function<void(std::function<void()>)> dispatchMainThread,
|
33
|
-
std::function<sk_sp<SkImage>(size_t viewTag)> takeViewScreenshot)
|
34
|
-
: _dispatchMainThread(dispatchMainThread),
|
35
|
-
_takeViewScreenshot(takeViewScreenshot),
|
36
|
-
RNSkPlatformContext(runtime, callInvoker,
|
33
|
+
RNSkiOSPlatformContext(jsi::Runtime *runtime, RCTBridge *bridge)
|
34
|
+
: RNSkPlatformContext(runtime, bridge.jsCallInvoker,
|
37
35
|
[[UIScreen mainScreen] scale]) {
|
38
36
|
|
39
37
|
// We need to make sure we invalidate when modules are freed
|
@@ -41,6 +39,10 @@ public:
|
|
41
39
|
CFNotificationCenterGetLocalCenter(), this, &handleNotification,
|
42
40
|
(__bridge CFStringRef)RCTBridgeWillInvalidateModulesNotification, NULL,
|
43
41
|
CFNotificationSuspensionBehaviorDeliverImmediately);
|
42
|
+
|
43
|
+
// Create screenshot manager
|
44
|
+
_screenshotService =
|
45
|
+
[[ViewScreenshotService alloc] initWithUiManager:bridge.uiManager];
|
44
46
|
}
|
45
47
|
|
46
48
|
~RNSkiOSPlatformContext() {
|
@@ -70,8 +72,7 @@ public:
|
|
70
72
|
|
71
73
|
private:
|
72
74
|
DisplayLink *_displayLink;
|
73
|
-
|
74
|
-
std::function<sk_sp<SkImage>(size_t viewTag)> _takeViewScreenshot;
|
75
|
+
ViewScreenshotService *_screenshotService;
|
75
76
|
};
|
76
77
|
|
77
78
|
static void handleNotification(CFNotificationCenterRef center, void *observer,
|
@@ -63,11 +63,15 @@ sk_sp<SkSurface> RNSkiOSPlatformContext::makeOffscreenSurface(int width,
|
|
63
63
|
}
|
64
64
|
|
65
65
|
void RNSkiOSPlatformContext::runOnMainThread(std::function<void()> func) {
|
66
|
-
|
66
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
67
|
+
func();
|
68
|
+
});
|
67
69
|
}
|
68
70
|
|
69
|
-
sk_sp<SkImage>
|
70
|
-
|
71
|
+
sk_sp<SkImage>
|
72
|
+
RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
|
73
|
+
return [_screenshotService
|
74
|
+
screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
|
71
75
|
}
|
72
76
|
|
73
77
|
void RNSkiOSPlatformContext::startDrawLoop() {
|
@@ -9,12 +9,9 @@
|
|
9
9
|
#import <ReactCommon/RCTTurboModule.h>
|
10
10
|
|
11
11
|
#import "RNSkiOSPlatformContext.h"
|
12
|
-
#import "ViewScreenshotService.h"
|
13
12
|
|
14
13
|
@implementation SkiaManager {
|
15
14
|
std::shared_ptr<RNSkia::RNSkManager> _skManager;
|
16
|
-
std::shared_ptr<RNSkia::RNSkiOSPlatformContext> _platformContext;
|
17
|
-
ViewScreenshotService *_screenshot;
|
18
15
|
__weak RCTBridge *weakBridge;
|
19
16
|
}
|
20
17
|
|
@@ -27,7 +24,6 @@
|
|
27
24
|
_skManager->invalidate();
|
28
25
|
}
|
29
26
|
_skManager = nullptr;
|
30
|
-
_platformContext = nullptr;
|
31
27
|
}
|
32
28
|
|
33
29
|
- (instancetype)initWithBridge:(RCTBridge *)bridge {
|
@@ -36,33 +32,13 @@
|
|
36
32
|
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
|
37
33
|
if (cxxBridge.runtime) {
|
38
34
|
|
39
|
-
auto callInvoker = bridge.jsCallInvoker;
|
40
35
|
facebook::jsi::Runtime *jsRuntime =
|
41
36
|
(facebook::jsi::Runtime *)cxxBridge.runtime;
|
42
37
|
|
43
|
-
// Create screenshot manager
|
44
|
-
_screenshot =
|
45
|
-
[[ViewScreenshotService alloc] initWithUiManager:bridge.uiManager];
|
46
|
-
|
47
|
-
auto takeScreenshot = [self](size_t viewTag) {
|
48
|
-
return [_screenshot
|
49
|
-
screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
|
50
|
-
};
|
51
|
-
|
52
|
-
auto dispatchOnMainThread = [self](std::function<void()> fp) {
|
53
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
54
|
-
fp();
|
55
|
-
});
|
56
|
-
};
|
57
|
-
|
58
|
-
// Create platform context
|
59
|
-
_platformContext = std::make_shared<RNSkia::RNSkiOSPlatformContext>(
|
60
|
-
jsRuntime, callInvoker, std::move(dispatchOnMainThread),
|
61
|
-
std::move(takeScreenshot));
|
62
|
-
|
63
38
|
// Create the RNSkiaManager (cross platform)
|
64
|
-
_skManager = std::make_shared<RNSkia::RNSkManager>(
|
65
|
-
|
39
|
+
_skManager = std::make_shared<RNSkia::RNSkManager>(
|
40
|
+
jsRuntime, bridge.jsCallInvoker,
|
41
|
+
std::make_shared<RNSkia::RNSkiOSPlatformContext>(jsRuntime, bridge));
|
66
42
|
}
|
67
43
|
}
|
68
44
|
return self;
|
package/jestSetup.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { Color } from "../../skia";
|
2
|
-
export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) =>
|
2
|
+
export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) => number[];
|
3
3
|
export declare const mixColors: (value: number, x: Color, y: Color) => Float32Array;
|
@@ -17,8 +17,9 @@ const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
|
17
17
|
const r = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[0]), "clamp");
|
18
18
|
const g = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[1]), "clamp");
|
19
19
|
const b = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[2]), "clamp");
|
20
|
-
const a = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[3]), "clamp");
|
21
|
-
|
20
|
+
const a = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[3]), "clamp"); // TODO: once Float32Array are supported in the reanimated integration we can switch there
|
21
|
+
|
22
|
+
return [r, g, b, a];
|
22
23
|
};
|
23
24
|
|
24
25
|
const interpolateColors = (value, inputRange, _outputRange) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["interpolateColorsRGB","value","inputRange","outputRange","r","interpolate","map","c","g","b","a","
|
1
|
+
{"version":3,"names":["interpolateColorsRGB","value","inputRange","outputRange","r","interpolate","map","c","g","b","a","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2","Float32Array","mix"],"sources":["interpolateColors.ts"],"sourcesContent":["import { mix } from \"../../renderer/processors/math\";\nimport type { Color, SkColor } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n \"worklet\";\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n // TODO: once Float32Array are supported in the reanimated integration we can switch there\n return [r, g, b, a];\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n \"worklet\";\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n \"worklet\";\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA,MAAMA,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;EACH;;EACA,MAAMC,CAAC,GAAG,IAAAC,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMC,CAAC,GAAG,IAAAH,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAME,CAAC,GAAG,IAAAJ,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMG,CAAC,GAAG,IAAAL,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV,CApBG,CA0BH;;EACA,OAAO,CAACH,CAAD,EAAII,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAP;AACD,CAhCD;;AAkCO,MAAMC,iBAAiB,GAAG,CAC/BV,KAD+B,EAE/BC,UAF+B,EAG/BU,YAH+B,KAI5B;EACH;;EACA,MAAMT,WAAW,GAAGS,YAAY,CAACN,GAAb,CAAkBO,EAAD,IAAQC,UAAA,CAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;EACA,OAAOb,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CARM;;;;AAUA,MAAMa,SAAS,GAAG,CAACf,KAAD,EAAgBgB,CAAhB,EAA0BC,CAA1B,KAAuC;EAC9D;;EACA,MAAMC,EAAE,GAAGL,UAAA,CAAKC,KAAL,CAAWE,CAAX,CAAX;;EACA,MAAMG,EAAE,GAAGN,UAAA,CAAKC,KAAL,CAAWG,CAAX,CAAX;;EACA,OAAO,IAAIG,YAAJ,CAAiB,CACtB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CADsB,EAEtB,IAAAE,SAAA,EAAIrB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAFsB,EAGtB,IAAAE,SAAA,EAAIrB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAHsB,EAItB,IAAAE,SAAA,EAAIrB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CAVM"}
|
@@ -1,15 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
import type * as ValueExports from "../values";
|
4
|
-
import type * as AnimationExports from "../animation";
|
5
|
-
import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
|
6
|
-
export declare const Skia: SkiaApi;
|
7
|
-
export declare const vec: (x?: number, y?: number) => {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
};
|
11
|
-
export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
|
12
|
-
createDrawing: () => any;
|
13
|
-
createDeclaration: () => any;
|
14
|
-
ShaderLib: typeof ShaderLib;
|
15
|
-
};
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
export declare const Mock: (CanvasKit: CanvasKit) => any;
|
@@ -3,123 +3,49 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.Mock = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _web = require("../skia/web");
|
9
9
|
|
10
|
-
var
|
10
|
+
var _web2 = require("../values/web");
|
11
11
|
|
12
|
-
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
|
+
const Noop = () => undefined;
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
var timingFunctions = _interopRequireWildcard(require("../animation/timing"));
|
17
|
-
|
18
|
-
var springFunctions = _interopRequireWildcard(require("../animation/spring"));
|
19
|
-
|
20
|
-
var decayFunctions = _interopRequireWildcard(require("../animation/decay"));
|
21
|
-
|
22
|
-
var interpolateFn = _interopRequireWildcard(require("../animation/functions/interpolate"));
|
23
|
-
|
24
|
-
var interpolatePathFn = _interopRequireWildcard(require("../animation/functions/interpolatePaths"));
|
25
|
-
|
26
|
-
var interpolateVectorFn = _interopRequireWildcard(require("../animation/functions/interpolateVector"));
|
27
|
-
|
28
|
-
var _ShaderLib = require("../renderer/components/shaders/ShaderLib");
|
29
|
-
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
31
|
-
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
33
|
-
|
34
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
35
|
-
class Stub {
|
36
|
-
constructor() {
|
37
|
-
return new Proxy(() => {}, {
|
38
|
-
get: () => new Stub(),
|
39
|
-
apply: () => new Stub(),
|
40
|
-
set: () => true
|
41
|
-
});
|
42
|
-
}
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
const Noop = () => {};
|
47
|
-
|
48
|
-
const Skia = new Stub();
|
49
|
-
exports.Skia = Skia;
|
50
|
-
|
51
|
-
const vec = (x, y) => ({
|
52
|
-
x: x ?? 0,
|
53
|
-
y: y ?? x ?? 0
|
15
|
+
const NoopValue = () => ({
|
16
|
+
current: 0
|
54
17
|
});
|
55
18
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
sub: (a, b) => vec(a.x - b.x, a.y - b.y),
|
86
|
-
neg: a => vec(-a.x, -a.y),
|
87
|
-
dist: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
|
88
|
-
translate: _ref => {
|
89
|
-
let {
|
90
|
-
x,
|
91
|
-
y
|
92
|
-
} = _ref;
|
93
|
-
return [{
|
94
|
-
translateX: x
|
95
|
-
}, {
|
96
|
-
translateY: y
|
97
|
-
}];
|
98
|
-
},
|
99
|
-
bounds: Noop,
|
100
|
-
topLeft: Noop,
|
101
|
-
topRight: Noop,
|
102
|
-
bottomLeft: Noop,
|
103
|
-
bottomRight: Noop,
|
104
|
-
center: Noop,
|
105
|
-
processTransform2d: Noop,
|
106
|
-
// ValueExports
|
107
|
-
...Values,
|
108
|
-
...ValuesHooks,
|
109
|
-
Selector: _selector.Selector,
|
110
|
-
// Animations
|
111
|
-
...timingFunctions,
|
112
|
-
...springFunctions,
|
113
|
-
...decayFunctions,
|
114
|
-
...interpolateFn,
|
115
|
-
...interpolatePathFn,
|
116
|
-
...interpolateVectorFn,
|
117
|
-
interpolateColors: (_value, _inputRange, _outputRange) => Float32Array.of(0, 0, 0, 0),
|
118
|
-
mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
|
119
|
-
ShaderLib: _ShaderLib.ShaderLib,
|
120
|
-
createDrawing: Noop,
|
121
|
-
createDeclaration: Noop,
|
122
|
-
makeImageFromView: Noop
|
19
|
+
const Mock = CanvasKit => {
|
20
|
+
global.SkiaApi = (0, _web.JsiSkApi)(CanvasKit);
|
21
|
+
global.SkiaValueApi = _web2.ValueApi;
|
22
|
+
const Skia = global.SkiaApi;
|
23
|
+
return {
|
24
|
+
Skia,
|
25
|
+
...require("../renderer/components"),
|
26
|
+
...require("../skia"),
|
27
|
+
...require("../values"),
|
28
|
+
...require("../animation"),
|
29
|
+
...require("../dom/types"),
|
30
|
+
...require("../dom/nodes"),
|
31
|
+
// We could use the real Canvas if we mock the SkiaView component for node
|
32
|
+
Canvas: Noop,
|
33
|
+
useValue: NoopValue,
|
34
|
+
useComputedValue: NoopValue,
|
35
|
+
useTouchHandler: Noop,
|
36
|
+
useTiming: NoopValue,
|
37
|
+
useLoop: NoopValue,
|
38
|
+
useSpring: NoopValue,
|
39
|
+
useClockValue: NoopValue,
|
40
|
+
useValueEffect: Noop,
|
41
|
+
useRawData: Noop,
|
42
|
+
useData: Noop,
|
43
|
+
useFont: () => Skia.Font(undefined, 0),
|
44
|
+
useTypeface: () => null,
|
45
|
+
useImage: () => null,
|
46
|
+
useSVG: () => null
|
47
|
+
};
|
123
48
|
};
|
49
|
+
|
124
50
|
exports.Mock = Mock;
|
125
51
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["Noop","undefined","NoopValue","current","Mock","CanvasKit","global","SkiaApi","JsiSkApi","SkiaValueApi","ValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\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 useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEA;AACA,MAAMA,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AAEO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiB,IAAAC,aAAA,EAASH,SAAT,CAAjB;EACAC,MAAM,CAACG,YAAP,GAAsBC,cAAtB;EACA,MAAMC,IAAI,GAAGL,MAAM,CAACC,OAApB;EACA,OAAO;IACLI,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEb,IATH;IAULc,QAAQ,EAAEZ,SAVL;IAWLa,gBAAgB,EAAEb,SAXb;IAYLc,eAAe,EAAEhB,IAZZ;IAaLiB,SAAS,EAAEf,SAbN;IAcLgB,OAAO,EAAEhB,SAdJ;IAeLiB,SAAS,EAAEjB,SAfN;IAgBLkB,aAAa,EAAElB,SAhBV;IAiBLmB,cAAc,EAAErB,IAjBX;IAkBLsB,UAAU,EAAEtB,IAlBP;IAmBLuB,OAAO,EAAEvB,IAnBJ;IAoBLwB,OAAO,EAAE,MAAMb,IAAI,CAACc,IAAL,CAAUxB,SAAV,EAAqB,CAArB,CApBV;IAqBLyB,WAAW,EAAE,MAAM,IArBd;IAsBLC,QAAQ,EAAE,MAAM,IAtBX;IAuBLC,MAAM,EAAE,MAAM;EAvBT,CAAP;AAyBD,CA7BM"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare type SkColor = Float32Array;
|
2
|
-
export declare type Color = string | Float32Array | number;
|
2
|
+
export declare type Color = string | Float32Array | number | number[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Color.ts"],"sourcesContent":["// This is the JSI color\nexport type SkColor = Float32Array;\n// Input colors can be string, number or Float32Array\nexport type Color = string | Float32Array | number;\n"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sources":["Color.ts"],"sourcesContent":["// This is the JSI color\nexport type SkColor = Float32Array;\n// Input colors can be string, number or Float32Array\nexport type Color = string | Float32Array | number | number[];\n"],"mappings":""}
|