@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.
Files changed (39) hide show
  1. package/android/build.gradle +15 -2
  2. package/cpp/rnskia/dom/base/JsiDependencyManager.h +47 -47
  3. package/cpp/rnskia/dom/base/JsiDomNode.h +6 -7
  4. package/cpp/rnskia/dom/base/NodePropsContainer.h +27 -3
  5. package/cpp/rnskia/dom/props/ColorProp.h +7 -0
  6. package/globalJestSetup.js +6 -0
  7. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +10 -9
  8. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +7 -3
  9. package/ios/RNSkia-iOS/SkiaManager.mm +3 -27
  10. package/jestSetup.js +2 -3
  11. package/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
  12. package/lib/commonjs/animation/functions/interpolateColors.js +3 -2
  13. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
  14. package/lib/commonjs/mock/index.d.ts +2 -15
  15. package/lib/commonjs/mock/index.js +37 -111
  16. package/lib/commonjs/mock/index.js.map +1 -1
  17. package/lib/commonjs/skia/types/Color.d.ts +1 -1
  18. package/lib/commonjs/skia/types/Color.js.map +1 -1
  19. package/lib/commonjs/skia/web/JsiSkColor.js +2 -0
  20. package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
  21. package/lib/module/animation/functions/interpolateColors.d.ts +1 -1
  22. package/lib/module/animation/functions/interpolateColors.js +3 -2
  23. package/lib/module/animation/functions/interpolateColors.js.map +1 -1
  24. package/lib/module/mock/index.d.ts +2 -15
  25. package/lib/module/mock/index.js +33 -96
  26. package/lib/module/mock/index.js.map +1 -1
  27. package/lib/module/skia/types/Color.d.ts +1 -1
  28. package/lib/module/skia/types/Color.js.map +1 -1
  29. package/lib/module/skia/web/JsiSkColor.js +2 -0
  30. package/lib/module/skia/web/JsiSkColor.js.map +1 -1
  31. package/lib/typescript/globalJestSetup.d.ts +2 -0
  32. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +1 -1
  33. package/lib/typescript/src/mock/index.d.ts +2 -15
  34. package/lib/typescript/src/skia/types/Color.d.ts +1 -1
  35. package/package.json +2 -1
  36. package/src/animation/functions/interpolateColors.ts +2 -1
  37. package/src/mock/index.ts +35 -99
  38. package/src/skia/types/Color.ts +1 -1
  39. package/src/skia/web/JsiSkColor.ts +2 -0
@@ -272,11 +272,24 @@ task extractJNIFiles {
272
272
  extractJNIFiles.mustRunAfter extractAARHeaders
273
273
 
274
274
  if (ENABLE_PREFAB) {
275
- // Package everything with the original file structure
275
+ // Package all the cpp code in a flattened directory structure
276
276
  task prepareHeaders(type: Copy) {
277
- from('./cpp')
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
- for (const auto &propMapping :
68
- node->getPropsContainer()->getMappedProperties()) {
69
- auto key = propMapping.first;
70
- auto jsValue = nextProps.getProperty(runtime, key);
71
- JsiValue nativeValue(runtime, jsValue);
72
-
73
- if (isAnimatedValue(nativeValue)) {
74
- // Handle Skia Animation Values
75
- auto animatedValue = getAnimatedValue(nativeValue);
76
- auto unsubscribe = animatedValue->addListener(
77
- [animatedValue, propMapping](jsi::Runtime &runtime) {
78
- // Get value from animation value
79
- auto nextJsValue = animatedValue->getCurrent(runtime);
80
- // Update all props that listens to this animation value
81
- for (auto &prop : propMapping.second) {
82
- prop->updateValue(runtime, nextJsValue);
83
- }
84
- });
85
-
86
- // Save unsubscribe methods
87
- unsubscribers.push_back(std::make_pair(animatedValue, unsubscribe));
88
-
89
- } else if (isSelector(nativeValue)) {
90
- // Handle Skia Animation Value Selectors
91
- auto animatedValue = std::dynamic_pointer_cast<RNSkReadonlyValue>(
92
- nativeValue.getValue(PropNameValue).getAsHostObject());
93
-
94
- auto selector = 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.second) {
106
- prop->updateValue(runtime, selectedJsValue);
107
- }
108
- });
109
-
110
- // Save unsubscribe methods
111
- unsubscribers.push_back(std::make_pair(animatedValue, unsubscribe));
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
- auto mappedProps = _propsContainer->getMappedProperties();
102
- auto propMapIt = mappedProps.find(JsiPropId::get(propName));
103
- if (propMapIt != mappedProps.end()) {
104
- for (auto &prop : propMapIt->second) {
105
- prop->updateValue(runtime, propValue);
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
- Returns a list of mappings betwen property names and property objects
44
+ Enumerate all mapped properties
45
45
  */
46
- const std::map<PropId, std::vector<NodeProp *>> &getMappedProperties() {
47
- return _mappedProperties;
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 {
@@ -0,0 +1,6 @@
1
+ module.exports = async () => {
2
+ const {
3
+ LoadSkiaWeb,
4
+ } = require("@shopify/react-native-skia/lib/commonjs/web/LoadSkiaWeb");
5
+ await LoadSkiaWeb();
6
+ };
@@ -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
- jsi::Runtime *runtime, std::shared_ptr<react::CallInvoker> callInvoker,
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
- std::function<void(std::function<void()>)> _dispatchMainThread;
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
- _dispatchMainThread(func);
66
+ dispatch_async(dispatch_get_main_queue(), ^{
67
+ func();
68
+ });
67
69
  }
68
70
 
69
- sk_sp<SkImage> RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t tag) {
70
- return _takeViewScreenshot(tag);
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>(jsRuntime, callInvoker,
65
- _platformContext);
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,5 +1,4 @@
1
1
  /* globals jest */
2
- jest.mock(
3
- "@shopify/react-native-skia",
4
- () => require("@shopify/react-native-skia/lib/commonjs/mock").Mock
2
+ jest.mock("@shopify/react-native-skia", () =>
3
+ require("@shopify/react-native-skia/lib/commonjs/mock").Mock(global.CanvasKit)
5
4
  );
@@ -1,3 +1,3 @@
1
1
  import type { Color } from "../../skia";
2
- export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) => Float32Array;
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
- return new Float32Array([r, g, b, a]);
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","Float32Array","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2","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 return new Float32Array([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;EAMA,OAAO,IAAII,YAAJ,CAAiB,CAACP,CAAD,EAAII,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA/BD;;AAiCO,MAAME,iBAAiB,GAAG,CAC/BX,KAD+B,EAE/BC,UAF+B,EAG/BW,YAH+B,KAI5B;EACH;;EACA,MAAMV,WAAW,GAAGU,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQC,UAAA,CAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;EACA,OAAOd,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CARM;;;;AAUA,MAAMc,SAAS,GAAG,CAAChB,KAAD,EAAgBiB,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,IAAIR,YAAJ,CAAiB,CACtB,IAAAW,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CADsB,EAEtB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAFsB,EAGtB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAHsB,EAItB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CAVM"}
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,CAA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CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CAVM"}
@@ -1,15 +1,2 @@
1
- import type { Skia as SkiaApi } from "../skia/types";
2
- import type * as SkiaExports from "../skia";
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.vec = exports.Skia = exports.Mock = void 0;
6
+ exports.Mock = void 0;
7
7
 
8
- var Values = _interopRequireWildcard(require("../values/web"));
8
+ var _web = require("../skia/web");
9
9
 
10
- var ValuesHooks = _interopRequireWildcard(require("../values/hooks"));
10
+ var _web2 = require("../values/web");
11
11
 
12
- var _selector = require("../values/selector");
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const Noop = () => undefined;
13
14
 
14
- var BaseSkia = _interopRequireWildcard(require("../skia/types"));
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
- exports.vec = vec;
57
- const Mock = {
58
- // SkiaExports
59
- // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
60
- Skia,
61
- ...BaseSkia,
62
- // 2. Hooks
63
- useRawData: Noop,
64
- useData: Noop,
65
- useFont: Noop,
66
- useTypeface: Noop,
67
- useImage: Noop,
68
- useSVG: Noop,
69
- createPicture: Noop,
70
- // 3. Point/Rect/Transform utilities
71
- vec,
72
- rect: (x, y, width, height) => ({
73
- x,
74
- y,
75
- width,
76
- height
77
- }),
78
- rrect: (r, rx, ry) => ({
79
- rect: r,
80
- rx,
81
- ry
82
- }),
83
- point: vec,
84
- add: (a, b) => vec(a.x + b.x, a.y + b.y),
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":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration","makeImageFromView"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n makeImageFromView: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IA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B,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D,IA5Df;EA6DJ8D,iBAAiB,EAAE9D;AA7Df,CANC"}
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":""}