@shopify/react-native-skia 0.1.166 → 0.1.167
Sign up to get free protection for your applications and to get access to all the features.
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +0 -5
- package/cpp/api/JsiSkPath.h +20 -3
- package/cpp/rnskia/dom/nodes/JsiBoxNode.h +4 -12
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +30 -9
- package/cpp/rnskia/dom/props/ImageProps.h +9 -6
- package/cpp/rnskia/dom/props/PointProp.h +4 -13
- package/cpp/rnskia/dom/props/PointsProp.h +1 -7
- package/cpp/rnskia/dom/props/RRectProp.h +53 -0
- package/cpp/rnskia/dom/props/RadiusProp.h +7 -9
- package/cpp/rnskia/dom/props/TransformProp.h +2 -2
- package/lib/commonjs/dom/nodes/datatypes/Transform.js +0 -3
- package/lib/commonjs/dom/nodes/datatypes/Transform.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +8 -39
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
- package/lib/commonjs/renderer/Reconciler.js +64 -0
- package/lib/commonjs/renderer/Reconciler.js.map +1 -0
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +7 -0
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js +14 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Transform.js +0 -3
- package/lib/module/dom/nodes/datatypes/Transform.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/renderer/Canvas.js +7 -33
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DrawingContext.js.map +1 -1
- package/lib/module/renderer/Reconciler.js +48 -0
- package/lib/module/renderer/Reconciler.js.map +1 -0
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +7 -0
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +14 -1
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +1 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +4 -7
- package/lib/typescript/src/renderer/DrawingContext.d.ts +2 -5
- package/lib/typescript/src/renderer/Reconciler.d.ts +13 -0
- package/lib/typescript/src/skia/types/Path/Path.d.ts +13 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
- package/package.json +1 -1
- package/src/dom/nodes/datatypes/Transform.ts +0 -2
- package/src/dom/nodes/paint/Shaders.ts +1 -1
- package/src/renderer/Canvas.tsx +12 -61
- package/src/renderer/DrawingContext.ts +2 -6
- package/src/renderer/Reconciler.tsx +66 -0
- package/src/skia/types/Path/Path.ts +14 -0
- package/src/skia/web/JsiSkPath.ts +10 -0
- package/src/skia/web/JsiSkRRect.ts +13 -2
- package/src/skia/web/JsiSkia.ts +1 -4
@@ -32,11 +32,6 @@ public abstract class SkiaBaseView extends ReactViewGroup implements TextureView
|
|
32
32
|
|
33
33
|
@Override
|
34
34
|
public boolean onTouchEvent(MotionEvent ev) {
|
35
|
-
// We do not accept the touch event if this view is not supposed to receive it.
|
36
|
-
if (!PointerEvents.canBeTouchTarget(getPointerEvents())) {
|
37
|
-
return false;
|
38
|
-
}
|
39
|
-
|
40
35
|
// https://developer.android.com/training/gestures/multi
|
41
36
|
int action = ev.getActionMasked();
|
42
37
|
|
package/cpp/api/JsiSkPath.h
CHANGED
@@ -41,6 +41,23 @@ public:
|
|
41
41
|
return jsi::String::createFromUtf8(runtime, "Path");
|
42
42
|
}
|
43
43
|
|
44
|
+
JSI_HOST_FUNCTION(addPath) {
|
45
|
+
auto src = JsiSkPath::fromValue(runtime, arguments[0]);
|
46
|
+
auto matrix =
|
47
|
+
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
48
|
+
? JsiSkMatrix::fromValue(runtime, arguments[1])
|
49
|
+
: nullptr;
|
50
|
+
auto mode = count > 2 && arguments[2].asBool()
|
51
|
+
? SkPath::kExtend_AddPathMode
|
52
|
+
: SkPath::kAppend_AddPathMode;
|
53
|
+
if (matrix == nullptr) {
|
54
|
+
getObject()->addPath(*src, mode);
|
55
|
+
} else {
|
56
|
+
getObject()->addPath(*src, *matrix, mode);
|
57
|
+
}
|
58
|
+
return thisValue.getObject(runtime);
|
59
|
+
}
|
60
|
+
|
44
61
|
JSI_HOST_FUNCTION(addArc) {
|
45
62
|
auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
|
46
63
|
auto start = arguments[1].asNumber();
|
@@ -512,9 +529,9 @@ public:
|
|
512
529
|
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPath, __typename__))
|
513
530
|
|
514
531
|
JSI_EXPORT_FUNCTIONS(
|
515
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
516
|
-
JSI_EXPORT_FUNC(JsiSkPath,
|
517
|
-
JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
532
|
+
JSI_EXPORT_FUNC(JsiSkPath, addPath), JSI_EXPORT_FUNC(JsiSkPath, addArc),
|
533
|
+
JSI_EXPORT_FUNC(JsiSkPath, addOval), JSI_EXPORT_FUNC(JsiSkPath, addPoly),
|
534
|
+
JSI_EXPORT_FUNC(JsiSkPath, addRect), JSI_EXPORT_FUNC(JsiSkPath, addRRect),
|
518
535
|
JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
|
519
536
|
JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
|
520
537
|
JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
|
@@ -15,15 +15,8 @@ public:
|
|
15
15
|
|
16
16
|
protected:
|
17
17
|
void renderNode(DrawingContext *context) override {
|
18
|
-
// Verify
|
19
|
-
if (!_rrectProp->isSet() && !_rectProp->isSet()) {
|
20
|
-
throw std::runtime_error("The box property must be set on the Box node.");
|
21
|
-
}
|
22
|
-
|
23
18
|
// Get rect - we'll try to end up with an rrect:
|
24
|
-
auto box =
|
25
|
-
? *_rrectProp->getDerivedValue()
|
26
|
-
: SkRRect::MakeRectXY(*_rectProp->getDerivedValue(), 0, 0);
|
19
|
+
auto box = *_boxProp->getDerivedValue();
|
27
20
|
|
28
21
|
// Get shadows
|
29
22
|
std::vector<std::shared_ptr<JsiBoxShadowNode>> shadows;
|
@@ -76,8 +69,8 @@ protected:
|
|
76
69
|
|
77
70
|
void defineProperties(NodePropsContainer *container) override {
|
78
71
|
JsiDomRenderNode::defineProperties(container);
|
79
|
-
|
80
|
-
|
72
|
+
_boxProp = container->defineProperty<BoxProps>("box");
|
73
|
+
_boxProp->require();
|
81
74
|
}
|
82
75
|
|
83
76
|
private:
|
@@ -95,8 +88,7 @@ private:
|
|
95
88
|
return inflate(box, -dx, -dy, tx, ty);
|
96
89
|
}
|
97
90
|
|
98
|
-
|
99
|
-
RectProp *_rectProp;
|
91
|
+
BoxProps *_boxProp;
|
100
92
|
};
|
101
93
|
|
102
94
|
} // namespace RNSkia
|
@@ -67,9 +67,22 @@ protected:
|
|
67
67
|
}
|
68
68
|
auto uniforms =
|
69
69
|
_uniformsProp->isSet() ? _uniformsProp->getDerivedValue() : nullptr;
|
70
|
-
|
70
|
+
|
71
|
+
SkMatrix lm;
|
72
|
+
auto tm =
|
71
73
|
_transformProp->isSet() ? _transformProp->getDerivedValue() : nullptr;
|
72
74
|
|
75
|
+
if (tm != nullptr) {
|
76
|
+
if (_originProp->isSet()) {
|
77
|
+
auto tr = _originProp->getDerivedValue();
|
78
|
+
lm.preTranslate(tr->x(), tr->y());
|
79
|
+
lm.preConcat(*tm);
|
80
|
+
lm.preTranslate(-tr->x(), -tr->y());
|
81
|
+
} else {
|
82
|
+
lm.preConcat(*tm);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
73
86
|
// get all children that are shader nodes
|
74
87
|
std::vector<sk_sp<SkShader>> children;
|
75
88
|
children.reserve(getChildren().size());
|
@@ -82,8 +95,7 @@ protected:
|
|
82
95
|
|
83
96
|
// Update shader
|
84
97
|
setShader(context, source->getObject()->makeShader(
|
85
|
-
uniforms, children.data(), children.size(),
|
86
|
-
localMatrix.get()));
|
98
|
+
uniforms, children.data(), children.size(), &lm));
|
87
99
|
}
|
88
100
|
}
|
89
101
|
|
@@ -93,6 +105,7 @@ protected:
|
|
93
105
|
_uniformsProp =
|
94
106
|
container->defineProperty<UniformsProp>("uniforms", _sourceProp);
|
95
107
|
_transformProp = container->defineProperty<TransformProp>("transform");
|
108
|
+
_originProp = container->defineProperty<PointProp>("origin");
|
96
109
|
|
97
110
|
_sourceProp->require();
|
98
111
|
}
|
@@ -101,6 +114,7 @@ private:
|
|
101
114
|
NodeProp *_sourceProp;
|
102
115
|
UniformsProp *_uniformsProp;
|
103
116
|
TransformProp *_transformProp;
|
117
|
+
PointProp *_originProp;
|
104
118
|
};
|
105
119
|
|
106
120
|
class JsiImageShaderNode : public JsiBaseShaderNode,
|
@@ -114,9 +128,8 @@ protected:
|
|
114
128
|
if (isChanged(context)) {
|
115
129
|
auto image = _imageProps->getImage();
|
116
130
|
auto rect = _imageProps->getRect();
|
117
|
-
auto lm =
|
118
|
-
|
119
|
-
: nullptr;
|
131
|
+
auto lm =
|
132
|
+
_transformProp->isSet() ? _transformProp->getDerivedValue() : nullptr;
|
120
133
|
|
121
134
|
if (rect != nullptr && lm != nullptr) {
|
122
135
|
auto rc = _imageProps->getDerivedValue();
|
@@ -127,9 +140,15 @@ protected:
|
|
127
140
|
// matrix to be translated and scaled more and more for each render
|
128
141
|
// even thought the matrix prop did not change.
|
129
142
|
_matrix.reset();
|
130
|
-
_matrix.preConcat(
|
131
|
-
|
132
|
-
|
143
|
+
_matrix.preConcat(m3);
|
144
|
+
if (_originProp->isSet()) {
|
145
|
+
auto tr = _originProp->getDerivedValue();
|
146
|
+
_matrix.preTranslate(tr->x(), tr->y());
|
147
|
+
_matrix.preConcat(*lm);
|
148
|
+
_matrix.preTranslate(-tr->x(), -tr->y());
|
149
|
+
} else {
|
150
|
+
_matrix.preConcat(*lm);
|
151
|
+
}
|
133
152
|
}
|
134
153
|
}
|
135
154
|
|
@@ -154,6 +173,7 @@ protected:
|
|
154
173
|
|
155
174
|
_imageProps = container->defineProperty<ImageProps>();
|
156
175
|
_transformProp = container->defineProperty<TransformProp>("transform");
|
176
|
+
_originProp = container->defineProperty<PointProp>("origin");
|
157
177
|
|
158
178
|
_txProp->require();
|
159
179
|
_tyProp->require();
|
@@ -201,6 +221,7 @@ private:
|
|
201
221
|
NodeProp *_mipmapModeProp;
|
202
222
|
ImageProps *_imageProps;
|
203
223
|
TransformProp *_transformProp;
|
224
|
+
PointProp *_originProp;
|
204
225
|
};
|
205
226
|
|
206
227
|
class JsiColorShaderNode : public JsiBaseShaderNode,
|
@@ -78,12 +78,15 @@ public:
|
|
78
78
|
return _rectProp->getDerivedValue();
|
79
79
|
}
|
80
80
|
|
81
|
-
|
82
|
-
auto
|
83
|
-
auto
|
84
|
-
auto
|
85
|
-
auto
|
86
|
-
|
81
|
+
SkMatrix rect2rect(SkRect src, SkRect dst) {
|
82
|
+
auto sx = dst.width() / src.width();
|
83
|
+
auto sy = dst.height() / src.height();
|
84
|
+
auto tx = dst.x() - src.x() * sx;
|
85
|
+
auto ty = dst.y() - src.y() * sy;
|
86
|
+
SkMatrix m3;
|
87
|
+
m3.preTranslate(tx, ty);
|
88
|
+
m3.preScale(sx, sy);
|
89
|
+
return m3;
|
87
90
|
}
|
88
91
|
|
89
92
|
private:
|
@@ -17,7 +17,6 @@ namespace RNSkia {
|
|
17
17
|
|
18
18
|
static PropId PropNameX = JsiPropId::get("x");
|
19
19
|
static PropId PropNameY = JsiPropId::get("y");
|
20
|
-
static SkPoint EmptyPoint = SkPoint::Make(-1, -1);
|
21
20
|
|
22
21
|
class PointProp : public DerivedProp<SkPoint> {
|
23
22
|
public:
|
@@ -26,9 +25,9 @@ public:
|
|
26
25
|
}
|
27
26
|
|
28
27
|
void updateDerivedValue() override {
|
29
|
-
|
30
|
-
|
31
|
-
setDerivedValue(std::move(
|
28
|
+
if (_pointProp->isSet()) {
|
29
|
+
// Check for JsiSkRect and JsiSkPoint
|
30
|
+
setDerivedValue(std::move(processValue(_pointProp->value())));
|
32
31
|
} else {
|
33
32
|
setDerivedValue(nullptr);
|
34
33
|
}
|
@@ -54,15 +53,7 @@ public:
|
|
54
53
|
auto y = value.getValue(PropNameY);
|
55
54
|
return SkPoint::Make(x.getAsNumber(), y.getAsNumber());
|
56
55
|
}
|
57
|
-
|
58
|
-
}
|
59
|
-
|
60
|
-
static SkPoint processProperty(NodeProp *prop) {
|
61
|
-
if (prop->isSet()) {
|
62
|
-
// Check for JsiSkRect and JsiSkPoint
|
63
|
-
return processValue(prop->value());
|
64
|
-
}
|
65
|
-
return EmptyPoint;
|
56
|
+
throw std::runtime_error("Expected point value.");
|
66
57
|
}
|
67
58
|
|
68
59
|
private:
|
@@ -62,13 +62,7 @@ public:
|
|
62
62
|
points.reserve(pointsArray.size());
|
63
63
|
for (size_t i = 0; i < pointsArray.size(); ++i) {
|
64
64
|
auto p = pointsArray[i];
|
65
|
-
|
66
|
-
if (point != EmptyPoint) {
|
67
|
-
points.push_back(point);
|
68
|
-
} else {
|
69
|
-
throw std::runtime_error(
|
70
|
-
"Expected array of points for points property.");
|
71
|
-
}
|
65
|
+
points.push_back(PointProp::processValue(p));
|
72
66
|
}
|
73
67
|
setDerivedValue(std::move(points));
|
74
68
|
} else {
|
@@ -131,4 +131,57 @@ private:
|
|
131
131
|
RRectProp *_rectProp;
|
132
132
|
RRectPropFromProps *_rectPropFromProps;
|
133
133
|
};
|
134
|
+
|
135
|
+
/**
|
136
|
+
Reads rect props from either a given property or from the property object
|
137
|
+
itself.
|
138
|
+
*/
|
139
|
+
class BoxProps : public DerivedProp<SkRRect> {
|
140
|
+
public:
|
141
|
+
explicit BoxProps(PropId name) : DerivedProp<SkRRect>() {
|
142
|
+
_boxProp = addProperty(std::make_shared<NodeProp>(name));
|
143
|
+
}
|
144
|
+
|
145
|
+
void updateDerivedValue() override {
|
146
|
+
if (_boxProp->value().getType() == PropType::HostObject) {
|
147
|
+
auto rectPtr = std::dynamic_pointer_cast<JsiSkRect>(
|
148
|
+
_boxProp->value().getAsHostObject());
|
149
|
+
auto rrectPtr = std::dynamic_pointer_cast<JsiSkRRect>(
|
150
|
+
_boxProp->value().getAsHostObject());
|
151
|
+
// 1. box is SkRect
|
152
|
+
if (rectPtr != nullptr) {
|
153
|
+
auto rect = rectPtr->getObject();
|
154
|
+
setDerivedValue(SkRRect::MakeRect(*rect));
|
155
|
+
// 2. box is SkRRect
|
156
|
+
} else if (rrectPtr != nullptr) {
|
157
|
+
setDerivedValue(rrectPtr->getObject());
|
158
|
+
}
|
159
|
+
} else if (_boxProp->value().getType() == PropType::Object) {
|
160
|
+
if (_boxProp->value().hasValue(PropNameRect)) {
|
161
|
+
// 3. box is { rect: { x, y, width, height }, rx, ry }
|
162
|
+
auto rectProp = _boxProp->value().getValue(PropNameRect);
|
163
|
+
auto x = rectProp.getValue(PropNameX).getAsNumber();
|
164
|
+
auto y = rectProp.getValue(PropNameY).getAsNumber();
|
165
|
+
auto width = rectProp.getValue(PropNameWidth).getAsNumber();
|
166
|
+
auto height = rectProp.getValue(PropNameHeight).getAsNumber();
|
167
|
+
auto rx = _boxProp->value().getValue(PropNameRx).getAsNumber();
|
168
|
+
auto ry = _boxProp->value().getValue(PropNameRy).getAsNumber();
|
169
|
+
setDerivedValue(
|
170
|
+
SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, width, height), rx, ry));
|
171
|
+
} else {
|
172
|
+
// 4. box is { x, y, width, height }
|
173
|
+
auto x = _boxProp->value().getValue(PropNameX).getAsNumber();
|
174
|
+
auto y = _boxProp->value().getValue(PropNameY).getAsNumber();
|
175
|
+
auto width = _boxProp->value().getValue(PropNameWidth).getAsNumber();
|
176
|
+
auto height = _boxProp->value().getValue(PropNameHeight).getAsNumber();
|
177
|
+
setDerivedValue(
|
178
|
+
SkRRect::MakeRect(SkRect::MakeXYWH(x, y, width, height)));
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
private:
|
184
|
+
NodeProp *_boxProp;
|
185
|
+
};
|
186
|
+
|
134
187
|
} // namespace RNSkia
|
@@ -17,26 +17,24 @@ namespace RNSkia {
|
|
17
17
|
class RadiusProp : public DerivedProp<SkPoint> {
|
18
18
|
public:
|
19
19
|
explicit RadiusProp(PropId name) : DerivedProp<SkPoint>() {
|
20
|
-
_pointProp = addProperty(std::make_shared<PointProp>(name));
|
21
20
|
_radiusProp = addProperty(std::make_shared<NodeProp>(name));
|
22
21
|
}
|
23
22
|
|
24
23
|
void updateDerivedValue() override {
|
25
|
-
if (_pointProp->isSet()) {
|
26
|
-
setDerivedValue(_pointProp->getDerivedValue());
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
|
30
24
|
if (_radiusProp->isSet()) {
|
31
|
-
|
32
|
-
|
25
|
+
// Check for simple number:
|
26
|
+
if (_radiusProp->value().getType() == PropType::Number) {
|
27
|
+
setDerivedValue(SkPoint::Make(_radiusProp->value().getAsNumber(),
|
28
|
+
_radiusProp->value().getAsNumber()));
|
29
|
+
} else {
|
30
|
+
setDerivedValue(PointProp::processValue(_radiusProp->value()));
|
31
|
+
}
|
33
32
|
} else {
|
34
33
|
setDerivedValue(nullptr);
|
35
34
|
}
|
36
35
|
}
|
37
36
|
|
38
37
|
private:
|
39
|
-
PointProp *_pointProp;
|
40
38
|
NodeProp *_radiusProp;
|
41
39
|
};
|
42
40
|
|
@@ -54,9 +54,9 @@ public:
|
|
54
54
|
} else if (key == PropNameScaleY) {
|
55
55
|
m->preScale(1, value);
|
56
56
|
} else if (key == PropNameSkewX) {
|
57
|
-
m->
|
57
|
+
m->preSkew(value, 0);
|
58
58
|
} else if (key == PropNameSkewY) {
|
59
|
-
m->
|
59
|
+
m->preSkew(0, value);
|
60
60
|
} else if (key == PropNameRotate || key == PropNameRotateZ) {
|
61
61
|
m->preRotate(SkRadiansToDegrees(value));
|
62
62
|
} else {
|
@@ -20,12 +20,9 @@ const processTransformProps = (m3, props) => {
|
|
20
20
|
m3.concat(matrix);
|
21
21
|
m3.translate(-origin.x, -origin.y);
|
22
22
|
} else {
|
23
|
-
m3.identity();
|
24
23
|
m3.concat(matrix);
|
25
24
|
}
|
26
25
|
} else if (transform) {
|
27
|
-
m3.identity();
|
28
|
-
|
29
26
|
if (origin) {
|
30
27
|
m3.translate(origin.x, origin.y);
|
31
28
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["processTransformProps","m3","props","transform","origin","matrix","translate","x","y","concat","
|
1
|
+
{"version":3,"names":["processTransformProps","m3","props","transform","origin","matrix","translate","x","y","concat","processTransform"],"sources":["Transform.ts"],"sourcesContent":["import type { TransformProps } from \"../../types\";\nimport type { SkMatrix } from \"../../../skia/types\";\nimport { processTransform } from \"../../../skia/types\";\n\nexport const processTransformProps = (m3: SkMatrix, props: TransformProps) => {\n const { transform, origin, matrix } = props;\n if (matrix) {\n if (origin) {\n m3.translate(origin.x, origin.y);\n m3.concat(matrix);\n m3.translate(-origin.x, -origin.y);\n } else {\n m3.concat(matrix);\n }\n } else if (transform) {\n if (origin) {\n m3.translate(origin.x, origin.y);\n }\n processTransform(m3, transform);\n if (origin) {\n m3.translate(-origin.x, -origin.y);\n }\n }\n};\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,qBAAqB,GAAG,CAACC,EAAD,EAAeC,KAAf,KAAyC;EAC5E,MAAM;IAAEC,SAAF;IAAaC,MAAb;IAAqBC;EAArB,IAAgCH,KAAtC;;EACA,IAAIG,MAAJ,EAAY;IACV,IAAID,MAAJ,EAAY;MACVH,EAAE,CAACK,SAAH,CAAaF,MAAM,CAACG,CAApB,EAAuBH,MAAM,CAACI,CAA9B;MACAP,EAAE,CAACQ,MAAH,CAAUJ,MAAV;MACAJ,EAAE,CAACK,SAAH,CAAa,CAACF,MAAM,CAACG,CAArB,EAAwB,CAACH,MAAM,CAACI,CAAhC;IACD,CAJD,MAIO;MACLP,EAAE,CAACQ,MAAH,CAAUJ,MAAV;IACD;EACF,CARD,MAQO,IAAIF,SAAJ,EAAe;IACpB,IAAIC,MAAJ,EAAY;MACVH,EAAE,CAACK,SAAH,CAAaF,MAAM,CAACG,CAApB,EAAuBH,MAAM,CAACI,CAA9B;IACD;;IACD,IAAAE,uBAAA,EAAiBT,EAAjB,EAAqBE,SAArB;;IACA,IAAIC,MAAJ,EAAY;MACVH,EAAE,CAACK,SAAH,CAAa,CAACF,MAAM,CAACG,CAArB,EAAwB,CAACH,MAAM,CAACI,CAAhC;IACD;EACF;AACF,CAnBM"}
|
@@ -73,8 +73,8 @@ class ImageShaderNode extends ShaderDeclaration {
|
|
73
73
|
}
|
74
74
|
|
75
75
|
const lm = this.Skia.Matrix();
|
76
|
-
(0, _datatypes.processTransformProps)(lm, imageShaderProps);
|
77
76
|
lm.concat(m3);
|
77
|
+
(0, _datatypes.processTransformProps)(lm, imageShaderProps);
|
78
78
|
return image.makeShaderOptions(_types.TileMode[(0, _datatypes.enumKey)(tx)], _types.TileMode[(0, _datatypes.enumKey)(ty)], _types.FilterMode[(0, _datatypes.enumKey)(fm)], _types.MipmapMode[(0, _datatypes.enumKey)(mm)], lm);
|
79
79
|
}
|
80
80
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","materialize","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","makeShaderWithChildren","processUniforms","children","filter","child","isShader","map","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { SkShader } from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<\n P,\n SkShader\n> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n materialize() {\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n return source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n this.children()\n .filter(\n (child): child is JsiDeclarationNode<unknown, SkShader> =>\n child instanceof JsiDeclarationNode && child.isShader()\n )\n .map((child) => child.materialize()),\n m3\n );\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n materialize() {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n processTransformProps(lm, imageShaderProps);\n lm.concat(m3);\n return image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n materialize() {\n const { color } = this.props;\n return this.Skia.Shader.MakeColor(this.Skia.Color(color));\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n materialize() {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n materialize() {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n materialize() {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n materialize() {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,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
|
+
{"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","materialize","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","makeShaderWithChildren","processUniforms","children","filter","child","isShader","map","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { SkShader } from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<\n P,\n SkShader\n> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n materialize() {\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n return source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n this.children()\n .filter(\n (child): child is JsiDeclarationNode<unknown, SkShader> =>\n child instanceof JsiDeclarationNode && child.isShader()\n )\n .map((child) => child.materialize()),\n m3\n );\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n materialize() {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n return image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n materialize() {\n const { color } = this.props;\n return this.Skia.Shader.MakeColor(this.Skia.Color(color));\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n materialize() {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n return this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n materialize() {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n materialize() {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n materialize() {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n materialize() {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n return this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAQA;;AAYA;;AACA;;AASO,MAAeA,iBAAf,SAA4CC,wBAA5C,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWG,uBAAA,CAAgBC,MAA3B,EAAmCH,IAAnC,EAAyCC,KAAzC;EACD;;AAHD;;;;AAMK,MAAMG,UAAN,SAAyBR,iBAAzB,CAAwD;EAC7DE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAuC;IAChD,MAAMF,GAAN,EAAWM,gBAAA,CAASF,MAApB,EAA4BF,KAA5B;EACD;;EAEDK,WAAW,GAAG;IACZ,MAAM;MAAEC,MAAF;MAAUC,QAAV;MAAoB,GAAGC;IAAvB,IAAqC,KAAKR,KAAhD;IACA,MAAMS,EAAE,GAAG,KAAKC,IAAL,CAAUC,MAAV,EAAX;IACA,IAAAC,gCAAA,EAAsBH,EAAtB,EAA0BD,SAA1B;IACA,OAAOF,MAAM,CAACO,sBAAP,CACL,IAAAC,sBAAA,EAAgBR,MAAhB,EAAwBC,QAAxB,CADK,EAEL,KAAKQ,QAAL,GACGC,MADH,CAEKC,KAAD,IACEA,KAAK,YAAYrB,wBAAjB,IAAuCqB,KAAK,CAACC,QAAN,EAH7C,EAKGC,GALH,CAKQF,KAAD,IAAWA,KAAK,CAACZ,WAAN,EALlB,CAFK,EAQLI,EARK,CAAP;EAUD;;AAnB4D;;;;AAsBxD,MAAMW,eAAN,SAA8BzB,iBAA9B,CAAkE;EACvEE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAA4C;IACrD,MAAMF,GAAN,EAAWM,gBAAA,CAASiB,WAApB,EAAiCrB,KAAjC;EACD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AGLlB,GAHK,EAILmB,IAJK,EAKLlB,MALK,EAMLC,SANK,EAOLC,IAPK,EAQLC,WARK,EASLC,KATK,CAAP;EAWD;;AApB8F"}
|
@@ -3,23 +3,15 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useCanvasRef = exports.
|
6
|
+
exports.useCanvasRef = exports.Canvas = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
-
var _reactReconciler = _interopRequireDefault(require("react-reconciler"));
|
11
|
-
|
12
10
|
var _views = require("../views");
|
13
11
|
|
14
12
|
var _Skia = require("../skia/Skia");
|
15
13
|
|
16
|
-
var
|
17
|
-
|
18
|
-
var _Container = require("./Container");
|
19
|
-
|
20
|
-
var _DependencyManager = require("./DependencyManager");
|
21
|
-
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
var _Reconciler = require("./Reconciler");
|
23
15
|
|
24
16
|
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); }
|
25
17
|
|
@@ -27,27 +19,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
27
19
|
|
28
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
29
21
|
|
30
|
-
const skiaReconciler = (0, _reactReconciler.default)(_HostConfig.skHostConfig);
|
31
|
-
exports.skiaReconciler = skiaReconciler;
|
32
|
-
skiaReconciler.injectIntoDevTools({
|
33
|
-
bundleType: 1,
|
34
|
-
version: "0.0.1",
|
35
|
-
rendererPackageName: "react-native-skia"
|
36
|
-
});
|
37
|
-
|
38
|
-
const render = (element, root, container) => {
|
39
|
-
skiaReconciler.updateContainer(element, root, null, () => {
|
40
|
-
(0, _HostConfig.debug)("updateContainer");
|
41
|
-
container.depMgr.update();
|
42
|
-
});
|
43
|
-
};
|
44
|
-
|
45
22
|
const useCanvasRef = () => (0, _react.useRef)(null);
|
46
23
|
|
47
24
|
exports.useCanvasRef = useCanvasRef;
|
48
|
-
|
49
|
-
const createDependencyManager = registerValues => global.SkiaDomApi && global.SkiaDomApi.DependencyManager ? global.SkiaDomApi.DependencyManager(registerValues) : new _DependencyManager.DependencyManager(registerValues);
|
50
|
-
|
51
25
|
const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
52
26
|
let {
|
53
27
|
children,
|
@@ -72,25 +46,20 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
|
72
46
|
|
73
47
|
return ref.current.registerValues(values);
|
74
48
|
}, [ref]);
|
75
|
-
const
|
76
|
-
return new _Container.Container(_Skia.Skia, createDependencyManager(registerValues), redraw);
|
77
|
-
}, [redraw, registerValues]);
|
78
|
-
const root = (0, _react.useMemo)(() => skiaReconciler.createContainer(container, 0, null, true, null, "", console.error, null), [container]); // Render effect
|
49
|
+
const root = (0, _react.useMemo)(() => new _Reconciler.SkiaRoot(_Skia.Skia, registerValues, redraw), [redraw, registerValues]); // Render effect
|
79
50
|
|
80
51
|
(0, _react.useEffect)(() => {
|
81
|
-
render(children
|
82
|
-
}, [children, root, redraw
|
52
|
+
root.render(children);
|
53
|
+
}, [children, root, redraw]);
|
83
54
|
(0, _react.useEffect)(() => {
|
84
55
|
return () => {
|
85
|
-
|
86
|
-
container.depMgr.remove();
|
87
|
-
});
|
56
|
+
root.unmount();
|
88
57
|
};
|
89
|
-
}, [
|
58
|
+
}, [root]);
|
90
59
|
return /*#__PURE__*/_react.default.createElement(_views.SkiaDomView, _extends({
|
91
60
|
ref: ref,
|
92
61
|
style: style,
|
93
|
-
root:
|
62
|
+
root: root.dom,
|
94
63
|
onTouch: onTouch,
|
95
64
|
onSize: onSize,
|
96
65
|
mode: mode,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["useCanvasRef","useRef","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","current","registerValues","values","Error","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","dom","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw),\n [redraw, registerValues]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAcA;;AACA;;AAIA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;AAQA,MAAMC,MAAM,gBAAG,IAAAC,iBAAA,EACpB,OAEEC,YAFF,KAGK;EAAA,IAFH;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,IAA1B;IAAgCC,OAAhC;IAAyCC,MAAzC;IAAiD,GAAGC;EAApD,CAEG;EACH,MAAMC,QAAQ,GAAGZ,YAAY,EAA7B;EACA,MAAMa,GAAG,GAAGC,eAAe,CAACV,YAAD,EAAeQ,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAG,IAAAC,kBAAA,EAAY,MAAM;IAAA;;IAC/B,qBAAAJ,QAAQ,CAACK,OAAT,wEAAkBF,MAAlB;EACD,CAFc,EAEZ,CAACH,QAAD,CAFY,CAAf;EAIA,MAAMM,cAAc,GAAG,IAAAF,kBAAA,EACpBG,MAAD,IAAuC;IACrC,IAAIN,GAAG,CAACI,OAAJ,KAAgB,IAApB,EAA0B;MACxB,MAAM,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AG,CAACI,OAAJ,GAAca,SAAS,CAACb,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACY,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"names":[],"sources":["DrawingContext.ts"],"sourcesContent":["import type { DrawingInfo } from \"../views\";\nimport type { Skia } from \"../skia/types\";\nimport type { DrawingContext as DOMDrawingContext } from \"../dom/types\";\n\nexport interface DrawingContext\n extends Omit<DrawingInfo, \"touches\">,\n DOMDrawingContext {\n Skia: Skia;\n}\n"],"mappings":""}
|