react-native-unistyles 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/android/build.gradle +12 -1
- package/android/src/main/cxx/NativeUnistylesModule.cpp +8 -4
- package/android/src/main/cxx/NativeUnistylesModule.h +5 -1
- package/components/native/ActivityIndicator/package.json +1 -1
- package/cxx/common/UnistylesConstants.h +1 -0
- package/cxx/converters/TransformOriginConverter.cpp +106 -0
- package/cxx/core/StyleSheetRegistry.cpp +9 -9
- package/cxx/core/StyleSheetRegistry.h +3 -3
- package/cxx/core/UnistyleWrapper.h +13 -1
- package/cxx/core/UnistylesRegistry.cpp +102 -18
- package/cxx/core/UnistylesRegistry.h +42 -5
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +124 -4
- package/cxx/hybridObjects/HybridShadowRegistry.h +20 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +20 -12
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +11 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +4 -2
- package/cxx/parser/Parser.cpp +29 -1
- package/cxx/parser/Parser.h +1 -0
- package/cxx/shadowTree/NativeProps.h +46 -2
- package/cxx/shadowTree/ShadowTrafficController.h +4 -0
- package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +339 -0
- package/cxx/shadowTree/ShadowTreeDiagnostics.h +18 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +7 -1
- package/cxx/shadowTree/ShadowTreeManager.h +1 -1
- package/diagnostics/package.json +6 -0
- package/ios/UnistylesModuleOnLoad.mm +9 -3
- package/lib/commonjs/components/native/ActivityIndicator.native.js +10 -0
- package/lib/commonjs/components/native/ActivityIndicator.native.js.map +1 -0
- package/lib/commonjs/components/native/NativeText.js +6 -0
- package/lib/commonjs/components/native/NativeText.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.native.js +17 -1
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.js +6 -0
- package/lib/commonjs/components/native/NativeView.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.native.js +22 -3
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +7 -3
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/TouchableHighlight.native.js +10 -0
- package/lib/commonjs/components/native/TouchableHighlight.native.js.map +1 -0
- package/lib/commonjs/core/createUnistylesActivityIndicator.js +41 -0
- package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -0
- package/lib/commonjs/core/createUnistylesElement.js +59 -14
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js +58 -0
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -0
- package/lib/commonjs/core/index.js +14 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/diagnostics/index.js +13 -0
- package/lib/commonjs/diagnostics/index.js.map +1 -0
- package/lib/commonjs/diagnostics/types.js +2 -0
- package/lib/commonjs/diagnostics/types.js.map +1 -0
- package/lib/commonjs/diagnostics/verify.js +19 -0
- package/lib/commonjs/diagnostics/verify.js.map +1 -0
- package/lib/commonjs/diagnostics/verify.native.js +12 -0
- package/lib/commonjs/diagnostics/verify.native.js.map +1 -0
- package/lib/commonjs/index.js +38 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +41 -0
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +8 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +97 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +5 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +3 -0
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.native.js +6 -0
- package/lib/module/components/native/ActivityIndicator.native.js.map +1 -0
- package/lib/module/components/native/NativeText.js +1 -1
- package/lib/module/components/native/NativeText.js.map +1 -1
- package/lib/module/components/native/NativeText.native.js +15 -1
- package/lib/module/components/native/NativeText.native.js.map +1 -1
- package/lib/module/components/native/NativeView.js +1 -0
- package/lib/module/components/native/NativeView.js.map +1 -1
- package/lib/module/components/native/NativeView.native.js +19 -2
- package/lib/module/components/native/NativeView.native.js.map +1 -1
- package/lib/module/components/native/Pressable.js +7 -3
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/TouchableHighlight.native.js +6 -0
- package/lib/module/components/native/TouchableHighlight.native.js.map +1 -0
- package/lib/module/core/createUnistylesActivityIndicator.js +35 -0
- package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -0
- package/lib/module/core/createUnistylesElement.js +58 -13
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesTouchableHighlight.js +52 -0
- package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/diagnostics/index.js +5 -0
- package/lib/module/diagnostics/index.js.map +1 -0
- package/lib/module/diagnostics/types.js +2 -0
- package/lib/module/diagnostics/types.js.map +1 -0
- package/lib/module/diagnostics/verify.js +14 -0
- package/lib/module/diagnostics/verify.js.map +1 -0
- package/lib/module/diagnostics/verify.native.js +8 -0
- package/lib/module/diagnostics/verify.native.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +41 -0
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +9 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +97 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +6 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/web/registry.js +3 -0
- package/lib/module/web/registry.js.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.native.d.ts +2 -0
- package/lib/typescript/src/components/native/ActivityIndicator.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeText.d.ts +1 -1
- package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeView.d.ts +1 -0
- package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeView.native.d.ts +2 -2
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.native.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableHighlight.native.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts +3 -0
- package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts +3 -0
- package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/useUnistyles.d.ts +1 -1
- package/lib/typescript/src/diagnostics/index.d.ts +3 -0
- package/lib/typescript/src/diagnostics/index.d.ts.map +1 -0
- package/lib/typescript/src/diagnostics/types.d.ts +19 -0
- package/lib/typescript/src/diagnostics/types.d.ts.map +1 -0
- package/lib/typescript/src/diagnostics/verify.d.ts +3 -0
- package/lib/typescript/src/diagnostics/verify.d.ts.map +1 -0
- package/lib/typescript/src/diagnostics/verify.native.d.ts +3 -0
- package/lib/typescript/src/diagnostics/verify.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +5 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +3 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +4 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +2 -2
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +3 -3
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/package.json +9 -1
- package/plugin/index.d.ts +4 -4
- package/plugin/index.js +21 -5
- package/src/components/native/ActivityIndicator.native.tsx +5 -0
- package/src/components/native/NativeText.native.tsx +18 -1
- package/src/components/native/NativeText.tsx +1 -1
- package/src/components/native/NativeView.native.tsx +22 -2
- package/src/components/native/NativeView.tsx +2 -0
- package/src/components/native/Pressable.tsx +8 -3
- package/src/components/native/TouchableHighlight.native.tsx +5 -0
- package/src/core/createUnistylesActivityIndicator.tsx +47 -0
- package/src/core/createUnistylesElement.tsx +45 -14
- package/src/core/createUnistylesTouchableHighlight.tsx +69 -0
- package/src/core/index.ts +2 -0
- package/src/diagnostics/index.ts +3 -0
- package/src/diagnostics/types.ts +25 -0
- package/src/diagnostics/verify.native.ts +7 -0
- package/src/diagnostics/verify.ts +13 -0
- package/src/index.ts +4 -1
- package/src/mocks.ts +41 -0
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +7 -1
- package/src/specs/ShadowRegistry/index.ts +128 -1
- package/src/specs/ShadowRegistry/types.ts +3 -0
- package/src/specs/StyleSheet/index.ts +10 -2
- package/src/specs/UnistylesRuntime/index.ts +7 -2
- package/src/types/breakpoints.ts +5 -3
- package/src/types/stylesheet.ts +3 -3
- package/src/web/registry.ts +3 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
#include "ShadowTreeDiagnostics.h"
|
|
2
|
+
|
|
3
|
+
#include <array>
|
|
4
|
+
#include <cstdio>
|
|
5
|
+
#include <folly/Conv.h>
|
|
6
|
+
#include <react/renderer/components/image/ImageProps.h>
|
|
7
|
+
// ParagraphProps is platform specific and not exposed by the Android prefab
|
|
8
|
+
#if __has_include(<react/renderer/components/text/BaseParagraphProps.h>)
|
|
9
|
+
#include <react/renderer/components/text/BaseParagraphProps.h>
|
|
10
|
+
#define UNISTYLES_HAS_BASE_PARAGRAPH_PROPS 1
|
|
11
|
+
#else
|
|
12
|
+
#define UNISTYLES_HAS_BASE_PARAGRAPH_PROPS 0
|
|
13
|
+
#endif
|
|
14
|
+
#include <react/renderer/components/text/TextProps.h>
|
|
15
|
+
#include <react/renderer/components/view/BaseViewProps.h>
|
|
16
|
+
#include <react/renderer/uimanager/UIManagerBinding.h>
|
|
17
|
+
#include <string_view>
|
|
18
|
+
#include "Parser.h"
|
|
19
|
+
#include "UnistylesRegistry.h"
|
|
20
|
+
|
|
21
|
+
using namespace margelo::nitro::unistyles;
|
|
22
|
+
using namespace facebook::react;
|
|
23
|
+
|
|
24
|
+
namespace {
|
|
25
|
+
|
|
26
|
+
struct PropDifference {
|
|
27
|
+
std::string prop;
|
|
28
|
+
std::string expected;
|
|
29
|
+
std::string actual;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
struct Mismatch {
|
|
33
|
+
Tag tag;
|
|
34
|
+
std::string component;
|
|
35
|
+
std::string styleKey;
|
|
36
|
+
PropDifference difference;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
template <typename P>
|
|
40
|
+
using VerifiedProps = std::vector<std::pair<const char*, std::string (*)(const P&)>>;
|
|
41
|
+
|
|
42
|
+
// SharedColor::toString exists since React Native 0.83, same format
|
|
43
|
+
std::string serialize(const SharedColor& color) {
|
|
44
|
+
if (!color) {
|
|
45
|
+
return "undefined";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
auto components = colorComponentsFromColor(color);
|
|
49
|
+
std::array<char, 64> buffer{};
|
|
50
|
+
|
|
51
|
+
std::snprintf(
|
|
52
|
+
buffer.data(),
|
|
53
|
+
buffer.size(),
|
|
54
|
+
"rgba(%.0f, %.0f, %.0f, %g)",
|
|
55
|
+
components.red * 255.f,
|
|
56
|
+
components.green * 255.f,
|
|
57
|
+
components.blue * 255.f,
|
|
58
|
+
components.alpha
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return buffer.data();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
std::string serialize(Float value) {
|
|
65
|
+
return folly::to<std::string>(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
std::string serialize(const std::optional<FontWeight>& fontWeight) {
|
|
69
|
+
return fontWeight ? std::to_string(static_cast<int>(*fontWeight)) : "undefined";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
RectangleEdges<SharedColor> borderColors(const BaseViewProps& props) {
|
|
73
|
+
return props.borderColors.resolve(false, {});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// theme dependent props, add new ones here
|
|
77
|
+
const VerifiedProps<BaseViewProps> viewProps{
|
|
78
|
+
{"backgroundColor", [](const BaseViewProps& props) { return serialize(props.backgroundColor); }},
|
|
79
|
+
{"borderLeftColor", [](const BaseViewProps& props) { return serialize(borderColors(props).left); }},
|
|
80
|
+
{"borderTopColor", [](const BaseViewProps& props) { return serialize(borderColors(props).top); }},
|
|
81
|
+
{"borderRightColor", [](const BaseViewProps& props) { return serialize(borderColors(props).right); }},
|
|
82
|
+
{"borderBottomColor", [](const BaseViewProps& props) { return serialize(borderColors(props).bottom); }},
|
|
83
|
+
{"opacity", [](const BaseViewProps& props) { return serialize(props.opacity); }},
|
|
84
|
+
{"shadowColor", [](const BaseViewProps& props) { return serialize(props.shadowColor); }},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const VerifiedProps<BaseTextProps> textProps{
|
|
88
|
+
{"color", [](const BaseTextProps& props) { return serialize(props.textAttributes.foregroundColor); }},
|
|
89
|
+
{"textBackgroundColor", [](const BaseTextProps& props) { return serialize(props.textAttributes.backgroundColor); }},
|
|
90
|
+
{"fontSize", [](const BaseTextProps& props) { return serialize(props.textAttributes.fontSize); }},
|
|
91
|
+
{"fontWeight", [](const BaseTextProps& props) { return serialize(props.textAttributes.fontWeight); }},
|
|
92
|
+
{"textDecorationColor", [](const BaseTextProps& props) { return serialize(props.textAttributes.textDecorationColor); }},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const VerifiedProps<ImageProps> imageProps{
|
|
96
|
+
{"tintColor", [](const ImageProps& props) { return serialize(props.tintColor); }},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
template <typename P>
|
|
100
|
+
void diff(const VerifiedProps<P>& verifiedProps, const P& expected, const P& actual, std::vector<PropDifference>& differences) {
|
|
101
|
+
for (const auto& [name, read] : verifiedProps) {
|
|
102
|
+
auto expectedValue = read(expected);
|
|
103
|
+
auto actualValue = read(actual);
|
|
104
|
+
|
|
105
|
+
if (expectedValue != actualValue) {
|
|
106
|
+
differences.push_back({name, std::move(expectedValue), std::move(actualValue)});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const BaseTextProps* asTextProps(std::string_view componentName, const Props& props) {
|
|
112
|
+
#if UNISTYLES_HAS_BASE_PARAGRAPH_PROPS
|
|
113
|
+
if (componentName == "Paragraph") {
|
|
114
|
+
return &static_cast<const BaseParagraphProps&>(props);
|
|
115
|
+
}
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
if (componentName == "Text") {
|
|
119
|
+
return &static_cast<const TextProps&>(props);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return nullptr;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
std::vector<PropDifference> diffVerifiedProps(const ShadowNode& shadowNode, const Props& expected) {
|
|
126
|
+
const auto& actual = *shadowNode.getProps();
|
|
127
|
+
const std::string_view componentName = shadowNode.getComponentName();
|
|
128
|
+
std::vector<PropDifference> differences;
|
|
129
|
+
|
|
130
|
+
if (shadowNode.getTraits().check(ShadowNodeTraits::Trait::ViewKind)) {
|
|
131
|
+
diff(viewProps, static_cast<const BaseViewProps&>(expected), static_cast<const BaseViewProps&>(actual), differences);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (const auto* expectedText = asTextProps(componentName, expected)) {
|
|
135
|
+
diff(textProps, *expectedText, *asTextProps(componentName, actual), differences);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (componentName == "Image") {
|
|
139
|
+
diff(imageProps, static_cast<const ImageProps&>(expected), static_cast<const ImageProps&>(actual), differences);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return differences;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// current revision of every surface
|
|
146
|
+
std::unordered_map<SurfaceId, std::shared_ptr<const RootShadowNode>> getCommittedRoots(const UIManager& uiManager) {
|
|
147
|
+
std::unordered_map<SurfaceId, std::shared_ptr<const RootShadowNode>> roots;
|
|
148
|
+
|
|
149
|
+
uiManager.getShadowTreeRegistry().enumerate([&roots](const ShadowTree& shadowTree, bool&) {
|
|
150
|
+
roots.emplace(shadowTree.getSurfaceId(), shadowTree.getCurrentRevision().rootShadowNode);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return roots;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// nullptr when the family is not part of the committed tree
|
|
157
|
+
std::shared_ptr<const ShadowNode> findCommittedNode(
|
|
158
|
+
const std::unordered_map<SurfaceId, std::shared_ptr<const RootShadowNode>>& roots,
|
|
159
|
+
const ShadowNodeFamily& family
|
|
160
|
+
) {
|
|
161
|
+
const auto rootIt = roots.find(family.getSurfaceId());
|
|
162
|
+
|
|
163
|
+
if (rootIt == roots.end() || !rootIt->second) {
|
|
164
|
+
return nullptr;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
auto ancestors = family.getAncestors(*rootIt->second);
|
|
168
|
+
|
|
169
|
+
if (ancestors.empty()) {
|
|
170
|
+
return nullptr;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const auto& [parent, index] = ancestors.back();
|
|
174
|
+
|
|
175
|
+
return parent.get().getChildren().at(index);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// rebuilds a copy of every UnistyleData, so the registry and shared parsed styles stay untouched
|
|
179
|
+
folly::dynamic getExpectedProps(
|
|
180
|
+
jsi::Runtime& rt,
|
|
181
|
+
parser::Parser& parser,
|
|
182
|
+
const std::vector<std::shared_ptr<core::UnistyleData>>& unistyles
|
|
183
|
+
) {
|
|
184
|
+
std::vector<std::shared_ptr<core::UnistyleData>> expectedUnistyles;
|
|
185
|
+
// prop name -> set last by an inline style
|
|
186
|
+
std::unordered_map<std::string, bool> propOwners;
|
|
187
|
+
|
|
188
|
+
expectedUnistyles.reserve(unistyles.size());
|
|
189
|
+
|
|
190
|
+
for (const auto& unistyleData : unistyles) {
|
|
191
|
+
auto arguments = unistyleData->dynamicFunctionMetadata.value_or(std::vector<folly::dynamic>{});
|
|
192
|
+
auto expectedData = std::make_shared<core::UnistyleData>(
|
|
193
|
+
unistyleData->unistyle,
|
|
194
|
+
unistyleData->variants,
|
|
195
|
+
arguments,
|
|
196
|
+
unistyleData->scopedTheme
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// inline styles don't depend on the theme, React (or an animation) owns the props they set last
|
|
200
|
+
if (unistyleData->unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
|
|
201
|
+
if (unistyleData->parsedStyle.has_value()) {
|
|
202
|
+
helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&propOwners](const std::string& propName, jsi::Value&) {
|
|
203
|
+
propOwners[propName] = true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (expectedData->scopedTheme.has_value()) {
|
|
211
|
+
jsi::Value scopedStyleSheet = jsi::Value::undefined();
|
|
212
|
+
|
|
213
|
+
parser.rebuildUnistyleWithScopedTheme(rt, scopedStyleSheet, expectedData);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// static StyleSheets have no scoped version
|
|
217
|
+
if (!expectedData->parsedStyle.has_value()) {
|
|
218
|
+
parser.rebuildUnistyleWithVariants(rt, expectedData);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (expectedData->parsedStyle.has_value()) {
|
|
222
|
+
helpers::enumerateJSIObject(rt, expectedData->parsedStyle.value(), [&propOwners](const std::string& propName, jsi::Value&) {
|
|
223
|
+
propOwners[propName] = false;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
expectedUnistyles.emplace_back(std::move(expectedData));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
auto expectedProps = parser.parseStylesToShadowTreeStyles(rt, expectedUnistyles);
|
|
231
|
+
|
|
232
|
+
for (const auto& [propName, isOwnedByInlineStyle] : propOwners) {
|
|
233
|
+
if (isOwnedByInlineStyle) {
|
|
234
|
+
expectedProps.erase(propName);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return expectedProps;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
jsi::Value shadow::ShadowTreeDiagnostics::verify(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime) {
|
|
244
|
+
auto& registry = core::UnistylesRegistry::get();
|
|
245
|
+
auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
|
|
246
|
+
auto snapshot = registry.getLinkedFamiliesSnapshot();
|
|
247
|
+
auto roots = getCommittedRoots(uiManager);
|
|
248
|
+
auto parser = parser::Parser(unistylesRuntime);
|
|
249
|
+
|
|
250
|
+
double checked = 0;
|
|
251
|
+
double detached = 0;
|
|
252
|
+
double suspended = 0;
|
|
253
|
+
double orphans = 0;
|
|
254
|
+
std::vector<Mismatch> mismatches;
|
|
255
|
+
std::vector<std::string> errors;
|
|
256
|
+
|
|
257
|
+
for (const auto& linkedFamily : snapshot) {
|
|
258
|
+
const auto& family = *linkedFamily.family;
|
|
259
|
+
|
|
260
|
+
// React Native dropped it, eg. unmounted while frozen
|
|
261
|
+
if (linkedFamily.isOwnedOnlyByUnistyles) {
|
|
262
|
+
orphans++;
|
|
263
|
+
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// hidden by Suspense or a frozen screen, it gets fresh styles when restored
|
|
268
|
+
if (linkedFamily.isSuspended) {
|
|
269
|
+
suspended++;
|
|
270
|
+
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
auto committed = findCommittedNode(roots, family);
|
|
275
|
+
|
|
276
|
+
if (!committed) {
|
|
277
|
+
detached++;
|
|
278
|
+
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
checked++;
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
auto expectedRawProps = getExpectedProps(rt, parser, linkedFamily.unistyles);
|
|
286
|
+
PropsParserContext propsParserContext{committed->getSurfaceId(), *committed->getContextContainer()};
|
|
287
|
+
auto expectedProps = committed->getComponentDescriptor().cloneProps(
|
|
288
|
+
propsParserContext,
|
|
289
|
+
committed->getProps(),
|
|
290
|
+
RawProps(expectedRawProps)
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
for (auto& difference : diffVerifiedProps(*committed, *expectedProps)) {
|
|
294
|
+
mismatches.push_back({
|
|
295
|
+
family.getTag(),
|
|
296
|
+
committed->getComponentName(),
|
|
297
|
+
linkedFamily.unistyles.empty() ? "" : linkedFamily.unistyles.back()->unistyle->styleKey,
|
|
298
|
+
std::move(difference)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
} catch (const std::exception& error) {
|
|
302
|
+
errors.emplace_back("tag " + std::to_string(family.getTag()) + ": " + error.what());
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
auto jsMismatches = jsi::Array(rt, mismatches.size());
|
|
307
|
+
|
|
308
|
+
for (size_t i = 0; i < mismatches.size(); i++) {
|
|
309
|
+
auto& mismatch = mismatches[i];
|
|
310
|
+
auto jsMismatch = jsi::Object(rt);
|
|
311
|
+
|
|
312
|
+
jsMismatch.setProperty(rt, "tag", static_cast<double>(mismatch.tag));
|
|
313
|
+
jsMismatch.setProperty(rt, "component", jsi::String::createFromUtf8(rt, mismatch.component));
|
|
314
|
+
jsMismatch.setProperty(rt, "styleKey", jsi::String::createFromUtf8(rt, mismatch.styleKey));
|
|
315
|
+
jsMismatch.setProperty(rt, "prop", jsi::String::createFromUtf8(rt, mismatch.difference.prop));
|
|
316
|
+
jsMismatch.setProperty(rt, "expected", jsi::String::createFromUtf8(rt, mismatch.difference.expected));
|
|
317
|
+
jsMismatch.setProperty(rt, "actual", jsi::String::createFromUtf8(rt, mismatch.difference.actual));
|
|
318
|
+
jsMismatches.setValueAtIndex(rt, i, std::move(jsMismatch));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
auto jsErrors = jsi::Array(rt, errors.size());
|
|
322
|
+
|
|
323
|
+
for (size_t i = 0; i < errors.size(); i++) {
|
|
324
|
+
jsErrors.setValueAtIndex(rt, i, jsi::String::createFromUtf8(rt, errors[i]));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
auto report = jsi::Object(rt);
|
|
328
|
+
|
|
329
|
+
report.setProperty(rt, "linked", static_cast<double>(snapshot.size()));
|
|
330
|
+
report.setProperty(rt, "checked", checked);
|
|
331
|
+
report.setProperty(rt, "detached", detached);
|
|
332
|
+
report.setProperty(rt, "suspended", suspended);
|
|
333
|
+
report.setProperty(rt, "orphans", orphans);
|
|
334
|
+
report.setProperty(rt, "pendingUpdates", static_cast<double>(registry.getPendingUpdatesCount()));
|
|
335
|
+
report.setProperty(rt, "mismatches", std::move(jsMismatches));
|
|
336
|
+
report.setProperty(rt, "errors", std::move(jsErrors));
|
|
337
|
+
|
|
338
|
+
return report;
|
|
339
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include "HybridUnistylesRuntime.h"
|
|
6
|
+
|
|
7
|
+
namespace margelo::nitro::unistyles::shadow {
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
// Diagnostics for tests (react-native-unistyles/diagnostics), never commits anything
|
|
12
|
+
struct ShadowTreeDiagnostics {
|
|
13
|
+
// rebuilds styles of every linked node with its own arguments, variants and current theme,
|
|
14
|
+
// and compares them with props committed to the shadow tree
|
|
15
|
+
static jsi::Value verify(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -4,12 +4,13 @@ using namespace margelo::nitro::unistyles;
|
|
|
4
4
|
using namespace facebook::react;
|
|
5
5
|
using namespace facebook;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
std::vector<Tag> shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
|
|
8
8
|
auto& registry = core::UnistylesRegistry::get();
|
|
9
9
|
|
|
10
10
|
// updates pin their families, so raw pointers stay valid during the commit
|
|
11
11
|
// declared outside of the lock, so the last pin is released after unlocking
|
|
12
12
|
PinnedShadowLeafUpdates updates;
|
|
13
|
+
std::vector<Tag> committedTags;
|
|
13
14
|
|
|
14
15
|
registry.trafficController.withLock([&](){
|
|
15
16
|
updates = registry.trafficController.takeUpdates();
|
|
@@ -20,13 +21,18 @@ void shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
|
|
|
20
21
|
|
|
21
22
|
std::unordered_map<Tag, folly::dynamic> tagToProps;
|
|
22
23
|
|
|
24
|
+
committedTags.reserve(updates.size());
|
|
25
|
+
|
|
23
26
|
for (const auto& [family, update] : updates) {
|
|
24
27
|
auto safeProps = update.props.isObject() ? update.props : folly::dynamic::object();
|
|
25
28
|
|
|
26
29
|
tagToProps.insert({family->getTag(), safeProps});
|
|
30
|
+
committedTags.push_back(family->getTag());
|
|
27
31
|
shadow::mergeNativeProps(family, safeProps);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
UIManagerBinding::getBinding(rt)->getUIManager().updateShadowTree(std::move(tagToProps));
|
|
31
35
|
});
|
|
36
|
+
|
|
37
|
+
return committedTags;
|
|
32
38
|
}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
using namespace margelo::nitro;
|
|
8
8
|
|
|
9
|
-
@implementation UnistylesModule
|
|
9
|
+
@implementation UnistylesModule {
|
|
10
|
+
uint64_t _generation;
|
|
11
|
+
}
|
|
10
12
|
|
|
11
13
|
RCT_EXPORT_MODULE(Unistyles)
|
|
12
14
|
|
|
@@ -16,6 +18,9 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
|
16
18
|
|
|
17
19
|
- (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt callInvoker:(const std::shared_ptr<facebook::react::CallInvoker> &)callInvoker {
|
|
18
20
|
// function is called on: first init and every live reload
|
|
21
|
+
// newest runtime owns the registry, previous runtime's state is kept until it releases ownership
|
|
22
|
+
_generation = core::UnistylesRegistry::get().takeOwnership();
|
|
23
|
+
|
|
19
24
|
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
|
20
25
|
auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
|
|
21
26
|
|
|
@@ -34,7 +39,7 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
auto nativePlatform = Unistyles::NativePlatform::create().getCxxPart();
|
|
37
|
-
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, runOnJSThread);
|
|
42
|
+
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, runOnJSThread, _generation);
|
|
38
43
|
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
|
|
39
44
|
|
|
40
45
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
|
@@ -53,7 +58,8 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
- (void)invalidate {
|
|
56
|
-
|
|
61
|
+
// releases this runtime's state, also when a newer runtime already replaced it
|
|
62
|
+
core::UnistylesRegistry::get().releaseOwnership(_generation);
|
|
57
63
|
|
|
58
64
|
[super invalidate];
|
|
59
65
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ActivityIndicator = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _core = require("../../core");
|
|
9
|
+
const ActivityIndicator = exports.ActivityIndicator = (0, _core.createUnistylesActivityIndicator)(_reactNative.ActivityIndicator);
|
|
10
|
+
//# sourceMappingURL=ActivityIndicator.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_core","ActivityIndicator","exports","createUnistylesActivityIndicator","NativeActivityIndicator"],"sourceRoot":"../../../../src","sources":["components/native/ActivityIndicator.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,sCAAgC,EAACC,8BAAuB,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "NativeText", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Text.Text;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "Text", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Text","require"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Text","require"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.tsx"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -5,10 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.NativeText = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var ReactNative = _interopRequireWildcard(require("react-native"));
|
|
8
9
|
var _core = require("../../core");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const RN = ReactNative;
|
|
12
|
+
const resolveRCTText = () => {
|
|
13
|
+
// RN 0.83+ re-exports the host component, which at runtime is the 'RCTText' string itself
|
|
14
|
+
if (typeof RN.unstable_NativeText === 'string') {
|
|
15
|
+
return RN.unstable_NativeText;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// older RN has no public handle on it, but reading Text evaluates the very same module
|
|
19
|
+
if (!RN.Text) {
|
|
20
|
+
throw new Error('Unistyles 🦄: react-native did not expose Text, unable to render NativeText');
|
|
21
|
+
}
|
|
22
|
+
return 'RCTText';
|
|
23
|
+
};
|
|
24
|
+
|
|
9
25
|
// credits to @hirbod
|
|
10
26
|
const LeanText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
11
|
-
return /*#__PURE__*/(0, _react.createElement)(
|
|
27
|
+
return /*#__PURE__*/(0, _react.createElement)(resolveRCTText(), {
|
|
12
28
|
...props,
|
|
13
29
|
ref
|
|
14
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_core","LeanText","forwardRef","props","ref","createElement","displayName","NativeText","exports","createUnistylesElement"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.native.tsx"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_react","require","ReactNative","_interopRequireWildcard","_core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RN","resolveRCTText","unstable_NativeText","Text","Error","LeanText","forwardRef","props","ref","createElement","displayName","NativeText","exports","createUnistylesElement"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.native.tsx"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAAmD,SAAAE,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEnD,MAAMkB,EAAE,GAAGtB,WAAqE;AAEhF,MAAMuB,cAAc,GAAGA,CAAA,KAAM;EACzB;EACA,IAAI,OAAOD,EAAE,CAACE,mBAAmB,KAAK,QAAQ,EAAE;IAC5C,OAAOF,EAAE,CAACE,mBAAmB;EACjC;;EAEA;EACA,IAAI,CAACF,EAAE,CAACG,IAAI,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,6EAA6E,CAAC;EAClG;EAEA,OAAO,SAAS;AACpB,CAAC;;AAED;AACA,MAAMC,QAAQ,gBAAG,IAAAC,iBAAU,EAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACxC,oBAAO,IAAAC,oBAAa,EAACR,cAAc,CAAC,CAAC,EAAE;IAAE,GAAGM,KAAK;IAAEC;EAAI,CAAC,CAAC;AAC7D,CAAC,CAA6B;AAE9BH,QAAQ,CAACK,WAAW,GAAG,SAAS;AAEzB,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAAE,4BAAsB,EAACR,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "NativeView", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _View.View;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
exports.default = void 0;
|
|
7
13
|
var _View = require("./View");
|
|
8
14
|
var _default = exports.default = _View.View;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_View","require","_default","exports","default","View"],"sourceRoot":"../../../../src","sources":["components/native/NativeView.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_View","require","_default","exports","default","View"],"sourceRoot":"../../../../src","sources":["components/native/NativeView.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAA6B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAIdC,UAAI","ignoreList":[]}
|
|
@@ -3,18 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.NativeView = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var ReactNative = _interopRequireWildcard(require("react-native"));
|
|
8
9
|
var _core = require("../../core");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const RN = ReactNative;
|
|
12
|
+
const resolveRCTView = () => {
|
|
13
|
+
// RN 0.83+ re-exports the host component, which at runtime is the 'RCTView' string itself
|
|
14
|
+
if (typeof RN.unstable_NativeView === 'string') {
|
|
15
|
+
return RN.unstable_NativeView;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// older RN has no public handle on it, but reading View evaluates the very same module
|
|
19
|
+
if (!RN.View) {
|
|
20
|
+
throw new Error('Unistyles 🦄: react-native did not expose View, unable to render NativeView');
|
|
21
|
+
}
|
|
22
|
+
return 'RCTView';
|
|
23
|
+
};
|
|
24
|
+
|
|
9
25
|
// credits to @hirbod
|
|
10
26
|
const LeanView = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
11
|
-
return /*#__PURE__*/(0, _react.createElement)(
|
|
27
|
+
return /*#__PURE__*/(0, _react.createElement)(resolveRCTView(), {
|
|
12
28
|
...props,
|
|
13
29
|
ref
|
|
14
30
|
});
|
|
15
31
|
});
|
|
16
32
|
LeanView.displayName = 'RCTView';
|
|
17
33
|
|
|
34
|
+
// named export matches unstable_NativeView from react-native
|
|
35
|
+
const NativeView = exports.NativeView = (0, _core.createUnistylesElement)(LeanView);
|
|
36
|
+
|
|
18
37
|
// this will match default export from react-native
|
|
19
|
-
var _default = exports.default =
|
|
38
|
+
var _default = exports.default = NativeView;
|
|
20
39
|
//# sourceMappingURL=NativeView.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_core","LeanView","forwardRef","props","ref","createElement","displayName","
|
|
1
|
+
{"version":3,"names":["_react","require","ReactNative","_interopRequireWildcard","_core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RN","resolveRCTView","unstable_NativeView","View","Error","LeanView","forwardRef","props","ref","createElement","displayName","NativeView","exports","createUnistylesElement","_default"],"sourceRoot":"../../../../src","sources":["components/native/NativeView.native.tsx"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAAmD,SAAAE,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEnD,MAAMkB,EAAE,GAAGtB,WAAqE;AAEhF,MAAMuB,cAAc,GAAGA,CAAA,KAAM;EACzB;EACA,IAAI,OAAOD,EAAE,CAACE,mBAAmB,KAAK,QAAQ,EAAE;IAC5C,OAAOF,EAAE,CAACE,mBAAmB;EACjC;;EAEA;EACA,IAAI,CAACF,EAAE,CAACG,IAAI,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,6EAA6E,CAAC;EAClG;EAEA,OAAO,SAAS;AACpB,CAAC;;AAED;AACA,MAAMC,QAAQ,gBAAG,IAAAC,iBAAU,EAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACxC,oBAAO,IAAAC,oBAAa,EAACR,cAAc,CAAC,CAAC,EAAE;IAAE,GAAGM,KAAK;IAAEC;EAAI,CAAC,CAAC;AAC7D,CAAC,CAA6B;AAE9BH,QAAQ,CAACK,WAAW,GAAG,SAAS;;AAEhC;AACO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAAE,4BAAsB,EAACR,QAAQ,CAAC;;AAE1D;AAAA,IAAAS,QAAA,GAAAF,OAAA,CAAArB,OAAA,GACeoB,UAAU","ignoreList":[]}
|
|
@@ -23,9 +23,13 @@ const Pressable = exports.Pressable = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
23
23
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
24
24
|
...props,
|
|
25
25
|
ref: (0, _utils.isServer)() ? undefined : ref => {
|
|
26
|
+
if (!ref) {
|
|
27
|
+
// @ts-expect-error hidden from TS
|
|
28
|
+
_specs.UnistylesShadowRegistry.remove(storedRef, classNames?.[0].hash);
|
|
29
|
+
}
|
|
26
30
|
storedRef = ref;
|
|
27
31
|
// @ts-expect-error hidden from TS
|
|
28
|
-
_specs.UnistylesShadowRegistry.add(storedRef, classNames?.hash);
|
|
32
|
+
_specs.UnistylesShadowRegistry.add(storedRef, classNames?.[0].hash);
|
|
29
33
|
if (typeof forwardedRef === 'function') {
|
|
30
34
|
return forwardedRef(ref);
|
|
31
35
|
}
|
|
@@ -39,10 +43,10 @@ const Pressable = exports.Pressable = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
39
43
|
_specs.UnistylesShadowRegistry.setScopedTheme(scopedTheme);
|
|
40
44
|
|
|
41
45
|
// @ts-expect-error hidden from TS
|
|
42
|
-
_specs.UnistylesShadowRegistry.remove(storedRef, classNames?.hash);
|
|
46
|
+
_specs.UnistylesShadowRegistry.remove(storedRef, classNames?.[0].hash);
|
|
43
47
|
classNames = (0, _core.getClassName)(styleResult);
|
|
44
48
|
// @ts-expect-error hidden from TS
|
|
45
|
-
_specs.UnistylesShadowRegistry.add(storedRef, classNames?.hash);
|
|
49
|
+
_specs.UnistylesShadowRegistry.add(storedRef, classNames?.[0].hash);
|
|
46
50
|
_specs.UnistylesShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
47
51
|
return classNames;
|
|
48
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_core","_specs","_utils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Pressable","exports","forwardRef","style","props","forwardedRef","scopedTheme","UnistylesShadowRegistry","getScopedTheme","storedRef","classNames","undefined","jsx","ref","isServer","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_core","_specs","_utils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Pressable","exports","forwardRef","style","props","forwardedRef","scopedTheme","UnistylesShadowRegistry","getScopedTheme","storedRef","classNames","undefined","jsx","ref","isServer","remove","hash","add","current","state","styleResult","previousScopedTheme","setScopedTheme","getClassName"],"sourceRoot":"../../../../src","sources":["components/native/Pressable.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TouchableHighlight = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _core = require("../../core");
|
|
9
|
+
const TouchableHighlight = exports.TouchableHighlight = (0, _core.createUnistylesTouchableHighlight)(_reactNative.TouchableHighlight);
|
|
10
|
+
//# sourceMappingURL=TouchableHighlight.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_core","TouchableHighlight","exports","createUnistylesTouchableHighlight","NativeTouchableHighlight"],"sourceRoot":"../../../../src","sources":["components/native/TouchableHighlight.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAAE,uCAAiC,EAACC,+BAAwB,CAAC","ignoreList":[]}
|