@shopify/react-native-skia 0.1.155 → 0.1.157
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/jni/JniLoad.cpp +5 -5
- package/android/cpp/jni/JniPlatformContext.cpp +107 -119
- package/android/cpp/jni/JniSkiaManager.cpp +18 -20
- package/android/cpp/jni/include/JniPlatformContext.h +41 -45
- package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
- package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
- package/android/cpp/jni/include/JniSkiaManager.h +51 -53
- package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
- package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
- package/cpp/api/JsiSkApi.h +66 -62
- package/cpp/api/JsiSkCanvas.h +38 -30
- package/cpp/api/JsiSkColor.h +58 -56
- package/cpp/api/JsiSkColorFilter.h +5 -3
- package/cpp/api/JsiSkColorFilterFactory.h +23 -21
- package/cpp/api/JsiSkContourMeasure.h +74 -85
- package/cpp/api/JsiSkContourMeasureIter.h +68 -75
- package/cpp/api/JsiSkData.h +16 -22
- package/cpp/api/JsiSkDataFactory.h +86 -79
- package/cpp/api/JsiSkFont.h +286 -311
- package/cpp/api/JsiSkHostObjects.h +15 -16
- package/cpp/api/JsiSkImage.h +107 -103
- package/cpp/api/JsiSkImageFactory.h +34 -36
- package/cpp/api/JsiSkImageFilter.h +5 -3
- package/cpp/api/JsiSkImageFilterFactory.h +71 -68
- package/cpp/api/JsiSkImageInfo.h +41 -38
- package/cpp/api/JsiSkMaskFilter.h +5 -3
- package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
- package/cpp/api/JsiSkMatrix.h +26 -36
- package/cpp/api/JsiSkPaint.h +20 -13
- package/cpp/api/JsiSkPath.h +70 -85
- package/cpp/api/JsiSkPathEffect.h +5 -3
- package/cpp/api/JsiSkPathEffectFactory.h +33 -28
- package/cpp/api/JsiSkPathFactory.h +68 -67
- package/cpp/api/JsiSkPicture.h +28 -22
- package/cpp/api/JsiSkPictureFactory.h +13 -12
- package/cpp/api/JsiSkPictureRecorder.h +21 -19
- package/cpp/api/JsiSkPoint.h +6 -8
- package/cpp/api/JsiSkRRect.h +11 -7
- package/cpp/api/JsiSkRSXform.h +82 -85
- package/cpp/api/JsiSkRect.h +9 -9
- package/cpp/api/JsiSkRuntimeEffect.h +182 -186
- package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
- package/cpp/api/JsiSkSVG.h +4 -5
- package/cpp/api/JsiSkSVGFactory.h +28 -27
- package/cpp/api/JsiSkShader.h +3 -2
- package/cpp/api/JsiSkShaderFactory.h +37 -25
- package/cpp/api/JsiSkSurface.h +44 -40
- package/cpp/api/JsiSkSurfaceFactory.h +22 -22
- package/cpp/api/JsiSkTextBlob.h +28 -31
- package/cpp/api/JsiSkTextBlobFactory.h +88 -87
- package/cpp/api/JsiSkTypeface.h +6 -5
- package/cpp/api/JsiSkTypefaceFactory.h +22 -21
- package/cpp/api/JsiSkVertices.h +137 -124
- package/cpp/api/third_party/CSSColorParser.cpp +161 -174
- package/cpp/api/third_party/CSSColorParser.h +172 -96
- package/cpp/jsi/JsiHostObject.cpp +11 -9
- package/cpp/jsi/JsiHostObject.h +31 -24
- package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
- package/cpp/jsi/JsiValueWrapper.h +52 -54
- package/cpp/rnskia/RNSkAnimation.h +26 -29
- package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
- package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
- package/cpp/rnskia/RNSkInfoParameter.h +12 -12
- package/cpp/rnskia/RNSkJsView.cpp +82 -81
- package/cpp/rnskia/RNSkJsView.h +45 -41
- package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
- package/cpp/rnskia/RNSkManager.cpp +8 -7
- package/cpp/rnskia/RNSkManager.h +8 -6
- package/cpp/rnskia/RNSkPictureView.h +44 -37
- package/cpp/rnskia/RNSkPlatformContext.h +39 -28
- package/cpp/rnskia/RNSkValueApi.h +33 -34
- package/cpp/rnskia/RNSkView.h +108 -93
- package/cpp/rnskia/values/RNSkClockValue.h +63 -64
- package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
- package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
- package/cpp/rnskia/values/RNSkValue.h +38 -40
- package/cpp/utils/RNSkLog.h +9 -7
- package/cpp/utils/RNSkMeasureTime.h +7 -7
- package/cpp/utils/RNSkTimingInfo.h +27 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
- package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
- package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
- package/lib/commonjs/dom/types/NodeType.js +1 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +1 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.js +3 -0
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +10 -1
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +19 -4
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +6 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +3 -2
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +6 -3
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/module/animation/spring/runSpring.js +1 -1
- package/lib/module/animation/spring/runSpring.js.map +1 -1
- package/lib/module/animation/spring/useSpring.js +1 -1
- package/lib/module/animation/spring/useSpring.js.map +1 -1
- package/lib/module/animation/timing/createTiming.js +6 -2
- package/lib/module/animation/timing/createTiming.js.map +1 -1
- package/lib/module/animation/timing/functions/getResolvedParams.js +10 -6
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -1
- package/lib/module/animation/timing/useTiming.js +3 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +6 -1
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/LayerNode.js +32 -0
- package/lib/module/dom/nodes/LayerNode.js.map +1 -0
- package/lib/module/dom/nodes/datatypes/Gradient.js +2 -2
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +4 -2
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/NodeType.js +1 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/mock/index.js +10 -6
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +1 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/HostComponents.js +3 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +9 -1
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/components/Group.js +16 -3
- package/lib/module/renderer/components/Group.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +7 -1
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/skia/core/Vector.js +1 -1
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -1
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +2 -2
- package/lib/module/values/web/RNSkAnimation.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +3 -1
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +2 -2
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.js +4 -2
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/useTouchHandler.js +6 -6
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/module/web/WithSkiaWeb.js +1 -1
- package/lib/module/web/WithSkiaWeb.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
- package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
- package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
- package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
- package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
- package/lib/typescript/src/views/SkiaView.d.ts +3 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +42 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libsksg.xcframework/Info.plist +42 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +14 -6
- package/src/dom/nodes/JsiSkDOM.ts +5 -0
- package/src/dom/nodes/LayerNode.ts +35 -0
- package/src/dom/types/NodeType.ts +1 -0
- package/src/dom/types/SkDOM.ts +1 -0
- package/src/renderer/Canvas.tsx +11 -1
- package/src/renderer/HostComponents.ts +3 -0
- package/src/renderer/HostConfig.ts +8 -1
- package/src/renderer/components/Group.tsx +16 -3
- package/src/renderer/components/Paint.tsx +7 -1
- package/src/views/SkiaPictureView.tsx +2 -3
- package/src/views/SkiaView.tsx +2 -2
@@ -24,111 +24,187 @@
|
|
24
24
|
|
25
25
|
#pragma once
|
26
26
|
|
27
|
+
#include <algorithm>
|
28
|
+
#include <cmath>
|
27
29
|
#include <cstdint>
|
28
|
-
#include <vector>
|
29
30
|
#include <sstream>
|
30
|
-
#include <algorithm>
|
31
31
|
#include <string>
|
32
|
-
#include <
|
32
|
+
#include <vector>
|
33
33
|
|
34
34
|
namespace CSSColorParser {
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
36
|
+
struct Color {
|
37
|
+
inline Color() {}
|
38
|
+
inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_)
|
39
|
+
: r(r_), g(g_), b(b_), a(a_ > 1 ? 1
|
40
|
+
: a_ < 0 ? 0
|
41
|
+
: a_) {}
|
42
|
+
unsigned char r = 0, g = 0, b = 0;
|
43
|
+
float a = -1.0f;
|
44
|
+
};
|
45
45
|
|
46
|
-
|
46
|
+
struct NamedColor {
|
47
|
+
const char *const name;
|
48
|
+
const Color color;
|
49
|
+
};
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
51
|
+
const NamedColor namedColors[] = {{"transparent", {0, 0, 0, 0}},
|
52
|
+
{"aliceblue", {240, 248, 255, 1}},
|
53
|
+
{"antiquewhite", {250, 235, 215, 1}},
|
54
|
+
{"aqua", {0, 255, 255, 1}},
|
55
|
+
{"aquamarine", {127, 255, 212, 1}},
|
56
|
+
{"azure", {240, 255, 255, 1}},
|
57
|
+
{"beige", {245, 245, 220, 1}},
|
58
|
+
{"bisque", {255, 228, 196, 1}},
|
59
|
+
{"black", {0, 0, 0, 1}},
|
60
|
+
{"blanchedalmond", {255, 235, 205, 1}},
|
61
|
+
{"blue", {0, 0, 255, 1}},
|
62
|
+
{"blueviolet", {138, 43, 226, 1}},
|
63
|
+
{"brown", {165, 42, 42, 1}},
|
64
|
+
{"burlywood", {222, 184, 135, 1}},
|
65
|
+
{"cadetblue", {95, 158, 160, 1}},
|
66
|
+
{"chartreuse", {127, 255, 0, 1}},
|
67
|
+
{"chocolate", {210, 105, 30, 1}},
|
68
|
+
{"coral", {255, 127, 80, 1}},
|
69
|
+
{"cornflowerblue", {100, 149, 237, 1}},
|
70
|
+
{"cornsilk", {255, 248, 220, 1}},
|
71
|
+
{"crimson", {220, 20, 60, 1}},
|
72
|
+
{"cyan", {0, 255, 255, 1}},
|
73
|
+
{"darkblue", {0, 0, 139, 1}},
|
74
|
+
{"darkcyan", {0, 139, 139, 1}},
|
75
|
+
{"darkgoldenrod", {184, 134, 11, 1}},
|
76
|
+
{"darkgray", {169, 169, 169, 1}},
|
77
|
+
{"darkgreen", {0, 100, 0, 1}},
|
78
|
+
{"darkgrey", {169, 169, 169, 1}},
|
79
|
+
{"darkkhaki", {189, 183, 107, 1}},
|
80
|
+
{"darkmagenta", {139, 0, 139, 1}},
|
81
|
+
{"darkolivegreen", {85, 107, 47, 1}},
|
82
|
+
{"darkorange", {255, 140, 0, 1}},
|
83
|
+
{"darkorchid", {153, 50, 204, 1}},
|
84
|
+
{"darkred", {139, 0, 0, 1}},
|
85
|
+
{"darksalmon", {233, 150, 122, 1}},
|
86
|
+
{"darkseagreen", {143, 188, 143, 1}},
|
87
|
+
{"darkslateblue", {72, 61, 139, 1}},
|
88
|
+
{"darkslategray", {47, 79, 79, 1}},
|
89
|
+
{"darkslategrey", {47, 79, 79, 1}},
|
90
|
+
{"darkturquoise", {0, 206, 209, 1}},
|
91
|
+
{"darkviolet", {148, 0, 211, 1}},
|
92
|
+
{"deeppink", {255, 20, 147, 1}},
|
93
|
+
{"deepskyblue", {0, 191, 255, 1}},
|
94
|
+
{"dimgray", {105, 105, 105, 1}},
|
95
|
+
{"dimgrey", {105, 105, 105, 1}},
|
96
|
+
{"dodgerblue", {30, 144, 255, 1}},
|
97
|
+
{"firebrick", {178, 34, 34, 1}},
|
98
|
+
{"floralwhite", {255, 250, 240, 1}},
|
99
|
+
{"forestgreen", {34, 139, 34, 1}},
|
100
|
+
{"fuchsia", {255, 0, 255, 1}},
|
101
|
+
{"gainsboro", {220, 220, 220, 1}},
|
102
|
+
{"ghostwhite", {248, 248, 255, 1}},
|
103
|
+
{"gold", {255, 215, 0, 1}},
|
104
|
+
{"goldenrod", {218, 165, 32, 1}},
|
105
|
+
{"gray", {128, 128, 128, 1}},
|
106
|
+
{"green", {0, 128, 0, 1}},
|
107
|
+
{"greenyellow", {173, 255, 47, 1}},
|
108
|
+
{"grey", {128, 128, 128, 1}},
|
109
|
+
{"honeydew", {240, 255, 240, 1}},
|
110
|
+
{"hotpink", {255, 105, 180, 1}},
|
111
|
+
{"indianred", {205, 92, 92, 1}},
|
112
|
+
{"indigo", {75, 0, 130, 1}},
|
113
|
+
{"ivory", {255, 255, 240, 1}},
|
114
|
+
{"khaki", {240, 230, 140, 1}},
|
115
|
+
{"lavender", {230, 230, 250, 1}},
|
116
|
+
{"lavenderblush", {255, 240, 245, 1}},
|
117
|
+
{"lawngreen", {124, 252, 0, 1}},
|
118
|
+
{"lemonchiffon", {255, 250, 205, 1}},
|
119
|
+
{"lightblue", {173, 216, 230, 1}},
|
120
|
+
{"lightcoral", {240, 128, 128, 1}},
|
121
|
+
{"lightcyan", {224, 255, 255, 1}},
|
122
|
+
{"lightgoldenrodyellow", {250, 250, 210, 1}},
|
123
|
+
{"lightgray", {211, 211, 211, 1}},
|
124
|
+
{"lightgreen", {144, 238, 144, 1}},
|
125
|
+
{"lightgrey", {211, 211, 211, 1}},
|
126
|
+
{"lightpink", {255, 182, 193, 1}},
|
127
|
+
{"lightsalmon", {255, 160, 122, 1}},
|
128
|
+
{"lightseagreen", {32, 178, 170, 1}},
|
129
|
+
{"lightskyblue", {135, 206, 250, 1}},
|
130
|
+
{"lightslategray", {119, 136, 153, 1}},
|
131
|
+
{"lightslategrey", {119, 136, 153, 1}},
|
132
|
+
{"lightsteelblue", {176, 196, 222, 1}},
|
133
|
+
{"lightyellow", {255, 255, 224, 1}},
|
134
|
+
{"lime", {0, 255, 0, 1}},
|
135
|
+
{"limegreen", {50, 205, 50, 1}},
|
136
|
+
{"linen", {250, 240, 230, 1}},
|
137
|
+
{"magenta", {255, 0, 255, 1}},
|
138
|
+
{"maroon", {128, 0, 0, 1}},
|
139
|
+
{"mediumaquamarine", {102, 205, 170, 1}},
|
140
|
+
{"mediumblue", {0, 0, 205, 1}},
|
141
|
+
{"mediumorchid", {186, 85, 211, 1}},
|
142
|
+
{"mediumpurple", {147, 112, 219, 1}},
|
143
|
+
{"mediumseagreen", {60, 179, 113, 1}},
|
144
|
+
{"mediumslateblue", {123, 104, 238, 1}},
|
145
|
+
{"mediumspringgreen", {0, 250, 154, 1}},
|
146
|
+
{"mediumturquoise", {72, 209, 204, 1}},
|
147
|
+
{"mediumvioletred", {199, 21, 133, 1}},
|
148
|
+
{"midnightblue", {25, 25, 112, 1}},
|
149
|
+
{"mintcream", {245, 255, 250, 1}},
|
150
|
+
{"mistyrose", {255, 228, 225, 1}},
|
151
|
+
{"moccasin", {255, 228, 181, 1}},
|
152
|
+
{"navajowhite", {255, 222, 173, 1}},
|
153
|
+
{"navy", {0, 0, 128, 1}},
|
154
|
+
{"oldlace", {253, 245, 230, 1}},
|
155
|
+
{"olive", {128, 128, 0, 1}},
|
156
|
+
{"olivedrab", {107, 142, 35, 1}},
|
157
|
+
{"orange", {255, 165, 0, 1}},
|
158
|
+
{"orangered", {255, 69, 0, 1}},
|
159
|
+
{"orchid", {218, 112, 214, 1}},
|
160
|
+
{"palegoldenrod", {238, 232, 170, 1}},
|
161
|
+
{"palegreen", {152, 251, 152, 1}},
|
162
|
+
{"paleturquoise", {175, 238, 238, 1}},
|
163
|
+
{"palevioletred", {219, 112, 147, 1}},
|
164
|
+
{"papayawhip", {255, 239, 213, 1}},
|
165
|
+
{"peachpuff", {255, 218, 185, 1}},
|
166
|
+
{"peru", {205, 133, 63, 1}},
|
167
|
+
{"pink", {255, 192, 203, 1}},
|
168
|
+
{"plum", {221, 160, 221, 1}},
|
169
|
+
{"powderblue", {176, 224, 230, 1}},
|
170
|
+
{"purple", {128, 0, 128, 1}},
|
171
|
+
{"red", {255, 0, 0, 1}},
|
172
|
+
{"rosybrown", {188, 143, 143, 1}},
|
173
|
+
{"royalblue", {65, 105, 225, 1}},
|
174
|
+
{"saddlebrown", {139, 69, 19, 1}},
|
175
|
+
{"salmon", {250, 128, 114, 1}},
|
176
|
+
{"sandybrown", {244, 164, 96, 1}},
|
177
|
+
{"seagreen", {46, 139, 87, 1}},
|
178
|
+
{"seashell", {255, 245, 238, 1}},
|
179
|
+
{"sienna", {160, 82, 45, 1}},
|
180
|
+
{"silver", {192, 192, 192, 1}},
|
181
|
+
{"skyblue", {135, 206, 235, 1}},
|
182
|
+
{"slateblue", {106, 90, 205, 1}},
|
183
|
+
{"slategray", {112, 128, 144, 1}},
|
184
|
+
{"slategrey", {112, 128, 144, 1}},
|
185
|
+
{"snow", {255, 250, 250, 1}},
|
186
|
+
{"springgreen", {0, 255, 127, 1}},
|
187
|
+
{"steelblue", {70, 130, 180, 1}},
|
188
|
+
{"tan", {210, 180, 140, 1}},
|
189
|
+
{"teal", {0, 128, 128, 1}},
|
190
|
+
{"thistle", {216, 191, 216, 1}},
|
191
|
+
{"tomato", {255, 99, 71, 1}},
|
192
|
+
{"turquoise", {64, 224, 208, 1}},
|
193
|
+
{"violet", {238, 130, 238, 1}},
|
194
|
+
{"wheat", {245, 222, 179, 1}},
|
195
|
+
{"white", {255, 255, 255, 1}},
|
196
|
+
{"whitesmoke", {245, 245, 245, 1}},
|
197
|
+
{"yellow", {255, 255, 0, 1}},
|
198
|
+
{"yellowgreen", {154, 205, 50, 1}}};
|
124
199
|
|
125
|
-
|
126
|
-
|
127
|
-
|
200
|
+
inline bool operator==(const Color &lhs, const Color &rhs) {
|
201
|
+
return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b &&
|
202
|
+
::fabs(lhs.a - rhs.a) < 0.0001f;
|
203
|
+
}
|
128
204
|
|
129
|
-
|
130
|
-
|
131
|
-
|
205
|
+
inline bool operator!=(const Color &lhs, const Color &rhs) {
|
206
|
+
return !(lhs == rhs);
|
207
|
+
}
|
132
208
|
|
133
|
-
|
209
|
+
Color parse(const std::string &css_str);
|
134
210
|
} // namespace CSSColorParser
|
@@ -33,7 +33,7 @@ JsiHostObject::~JsiHostObject() {
|
|
33
33
|
|
34
34
|
void JsiHostObject::set(jsi::Runtime &rt, const jsi::PropNameID &name,
|
35
35
|
const jsi::Value &value) {
|
36
|
-
|
36
|
+
|
37
37
|
auto nameVal = name.utf8(rt);
|
38
38
|
auto nameStr = nameVal.c_str();
|
39
39
|
|
@@ -56,7 +56,7 @@ jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
|
|
56
56
|
const jsi::PropNameID &name) {
|
57
57
|
auto nameVal = name.utf8(runtime);
|
58
58
|
auto nameStr = nameVal.c_str();
|
59
|
-
|
59
|
+
|
60
60
|
// Check the static getters map
|
61
61
|
const JsiPropertyGettersMap &getters = getExportedPropertyGettersMap();
|
62
62
|
auto getter = getters.find(nameStr);
|
@@ -86,9 +86,10 @@ jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
|
|
86
86
|
const JsiFunctionMap &funcs = getExportedFunctionMap();
|
87
87
|
auto func = funcs.find(nameStr);
|
88
88
|
if (func != funcs.end()) {
|
89
|
-
auto dispatcher =
|
90
|
-
|
91
|
-
|
89
|
+
auto dispatcher =
|
90
|
+
std::bind(func->second, reinterpret_cast<JsiHostObject *>(this),
|
91
|
+
std::placeholders::_1, std::placeholders::_2,
|
92
|
+
std::placeholders::_3, std::placeholders::_4);
|
92
93
|
|
93
94
|
// Add to cache
|
94
95
|
currentCache->emplace(nameStr, std::make_unique<jsi::Function>(
|
@@ -115,16 +116,17 @@ jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
|
|
115
116
|
std::vector<jsi::PropNameID>
|
116
117
|
JsiHostObject::getPropertyNames(jsi::Runtime &runtime) {
|
117
118
|
// statically exported functions
|
118
|
-
const auto&
|
119
|
+
const auto &funcs = getExportedFunctionMap();
|
119
120
|
|
120
121
|
// Statically exported property getters
|
121
|
-
const auto&
|
122
|
+
const auto &getters = getExportedPropertyGettersMap();
|
122
123
|
|
123
124
|
// Statically exported property setters
|
124
|
-
const auto&
|
125
|
+
const auto &setters = getExportedPropertySettersMap();
|
125
126
|
|
126
127
|
std::vector<jsi::PropNameID> propNames;
|
127
|
-
propNames.reserve(funcs.size() + getters.size() + setters.size() +
|
128
|
+
propNames.reserve(funcs.size() + getters.size() + setters.size() +
|
129
|
+
_funcMap.size() + _propMap.size());
|
128
130
|
|
129
131
|
for (auto it = funcs.cbegin(); it != funcs.cend(); ++it) {
|
130
132
|
propNames.push_back(jsi::PropNameID::forAscii(runtime, it->first));
|
package/cpp/jsi/JsiHostObject.h
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
#include <jsi/jsi.h>
|
4
4
|
|
5
5
|
#include <functional>
|
6
|
-
#include <unordered_map>
|
7
6
|
#include <memory>
|
8
7
|
#include <string>
|
8
|
+
#include <unordered_map>
|
9
|
+
#include <vector>
|
9
10
|
|
10
11
|
#define STR_CAT_NX(A, B) A##B
|
11
12
|
#define STR_CAT(A, B) STR_CAT_NX(A, B)
|
@@ -44,7 +45,7 @@
|
|
44
45
|
*/
|
45
46
|
#define JSI_EXPORT_FUNC(CLASS, FUNCTION) \
|
46
47
|
{ \
|
47
|
-
#FUNCTION, (jsi::Value(JsiHostObject::*)(
|
48
|
+
#FUNCTION, (jsi::Value(JsiHostObject::*)( \
|
48
49
|
jsi::Runtime & runtime, const jsi::Value &thisValue, \
|
49
50
|
const jsi::Value *arguments, size_t)) & \
|
50
51
|
CLASS::FUNCTION \
|
@@ -54,8 +55,8 @@
|
|
54
55
|
* Creates a JSI export functions statement
|
55
56
|
*/
|
56
57
|
#define JSI_EXPORT_FUNCTIONS(...) \
|
57
|
-
const JsiFunctionMap &getExportedFunctionMap() override {
|
58
|
-
static JsiFunctionMap map = {__VA_ARGS__};
|
58
|
+
const RNJsi::JsiFunctionMap &getExportedFunctionMap() override { \
|
59
|
+
static RNJsi::JsiFunctionMap map = {__VA_ARGS__}; \
|
59
60
|
return map; \
|
60
61
|
}
|
61
62
|
|
@@ -64,7 +65,7 @@
|
|
64
65
|
*/
|
65
66
|
#define JSI_EXPORT_PROP_GET(CLASS, FUNCTION) \
|
66
67
|
{ \
|
67
|
-
#FUNCTION, (jsi::Value(JsiHostObject::*)(jsi::Runtime & runtime)) &
|
68
|
+
#FUNCTION, (jsi::Value(JsiHostObject::*)(jsi::Runtime & runtime)) & \
|
68
69
|
CLASS::STR_CAT(STR_GET, FUNCTION) \
|
69
70
|
}
|
70
71
|
|
@@ -72,17 +73,18 @@
|
|
72
73
|
* Creates a JSI export getters statement
|
73
74
|
*/
|
74
75
|
#define JSI_EXPORT_PROPERTY_GETTERS(...) \
|
75
|
-
const JsiPropertyGettersMap &getExportedPropertyGettersMap()
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
const RNJsi::JsiPropertyGettersMap &getExportedPropertyGettersMap() \
|
77
|
+
override { \
|
78
|
+
static RNJsi::JsiPropertyGettersMap map = {__VA_ARGS__}; \
|
79
|
+
return map; \
|
80
|
+
}
|
79
81
|
|
80
82
|
/**
|
81
83
|
* Creates a JSI export setter declaration
|
82
84
|
*/
|
83
85
|
#define JSI_EXPORT_PROP_SET(CLASS, FUNCTION) \
|
84
86
|
{ \
|
85
|
-
#FUNCTION,
|
87
|
+
#FUNCTION, \
|
86
88
|
(void(JsiHostObject::*)(jsi::Runtime & runtime, const jsi::Value &)) & \
|
87
89
|
CLASS::STR_CAT(STR_SET, FUNCTION) \
|
88
90
|
}
|
@@ -91,14 +93,15 @@
|
|
91
93
|
* Creates a JSI export setters statement
|
92
94
|
*/
|
93
95
|
#define JSI_EXPORT_PROPERTY_SETTERS(...) \
|
94
|
-
const JsiPropertySettersMap &getExportedPropertySettersMap()
|
95
|
-
|
96
|
+
const RNJsi::JsiPropertySettersMap &getExportedPropertySettersMap() \
|
97
|
+
override { \
|
98
|
+
static RNJsi::JsiPropertySettersMap map = {__VA_ARGS__}; \
|
96
99
|
return map; \
|
97
100
|
}
|
98
101
|
|
99
102
|
namespace RNJsi {
|
100
103
|
|
101
|
-
|
104
|
+
namespace jsi = facebook::jsi;
|
102
105
|
|
103
106
|
using JsPropertyType = struct {
|
104
107
|
std::function<jsi::Value(jsi::Runtime &)> get;
|
@@ -107,14 +110,18 @@ using JsPropertyType = struct {
|
|
107
110
|
|
108
111
|
class JsiHostObject;
|
109
112
|
|
110
|
-
using JsiFunctionMap =
|
111
|
-
|
113
|
+
using JsiFunctionMap =
|
114
|
+
std::unordered_map<std::string, jsi::Value (JsiHostObject::*)(
|
115
|
+
jsi::Runtime &, const jsi::Value &,
|
116
|
+
const jsi::Value *, size_t)>;
|
112
117
|
|
113
|
-
using JsiPropertyGettersMap =
|
114
|
-
|
118
|
+
using JsiPropertyGettersMap =
|
119
|
+
std::unordered_map<std::string,
|
120
|
+
jsi::Value (JsiHostObject::*)(jsi::Runtime &)>;
|
115
121
|
|
116
|
-
using JsiPropertySettersMap =
|
117
|
-
|
122
|
+
using JsiPropertySettersMap =
|
123
|
+
std::unordered_map<std::string, void (JsiHostObject::*)(
|
124
|
+
jsi::Runtime &, const jsi::Value &)>;
|
118
125
|
|
119
126
|
using JsiHostFunctionCache =
|
120
127
|
std::unordered_map<std::string, std::unique_ptr<jsi::Function>>;
|
@@ -134,10 +141,10 @@ protected:
|
|
134
141
|
/**
|
135
142
|
Override to return map of name/functions
|
136
143
|
*/
|
137
|
-
virtual const JsiFunctionMap &getExportedFunctionMap() {
|
138
|
-
static const JsiFunctionMap empty;
|
144
|
+
virtual const RNJsi::JsiFunctionMap &getExportedFunctionMap() {
|
145
|
+
static const RNJsi::JsiFunctionMap empty;
|
139
146
|
return empty;
|
140
|
-
}
|
147
|
+
}
|
141
148
|
|
142
149
|
/**
|
143
150
|
Override to get property getters map of name/functions
|
@@ -145,7 +152,7 @@ protected:
|
|
145
152
|
virtual const JsiPropertyGettersMap &getExportedPropertyGettersMap() {
|
146
153
|
static const JsiPropertyGettersMap empty;
|
147
154
|
return empty;
|
148
|
-
}
|
155
|
+
}
|
149
156
|
|
150
157
|
/**
|
151
158
|
Override to get property setters map of name/functions
|
@@ -153,7 +160,7 @@ protected:
|
|
153
160
|
virtual const JsiPropertySettersMap &getExportedPropertySettersMap() {
|
154
161
|
static const JsiPropertySettersMap empty;
|
155
162
|
return empty;
|
156
|
-
}
|
163
|
+
}
|
157
164
|
|
158
165
|
/**
|
159
166
|
* Overridden jsi::HostObject set property method
|