react-native-unistyles 3.3.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 +26 -10
- 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 +226 -54
- package/cxx/core/UnistylesRegistry.h +64 -7
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +128 -11
- 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 +30 -3
- package/cxx/parser/Parser.h +1 -0
- package/cxx/shadowTree/NativeProps.h +88 -0
- package/cxx/shadowTree/ShadowLeafUpdate.h +8 -0
- package/cxx/shadowTree/ShadowTrafficController.h +18 -35
- package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +339 -0
- package/cxx/shadowTree/ShadowTreeDiagnostics.h +18 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +14 -148
- package/cxx/shadowTree/ShadowTreeManager.h +2 -6
- 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/Animated.js +2 -0
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- 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 +9 -3
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +2 -0
- package/lib/commonjs/components/native/Pressable.native.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/convert/object/boxShadow.js +2 -2
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/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/Animated.js +3 -0
- package/lib/module/components/native/Animated.js.map +1 -1
- 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 +9 -3
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +2 -0
- package/lib/module/components/native/Pressable.native.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/convert/object/boxShadow.js +2 -2
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/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/Animated.d.ts +16 -36
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- 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 +4 -2
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts +5 -2
- package/lib/typescript/src/components/native/Pressable.native.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/core.d.ts +7 -2
- package/lib/typescript/src/types/core.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/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +2 -0
- package/package.json +35 -26
- 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/Animated.tsx +18 -1
- 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.native.tsx +10 -2
- package/src/components/native/Pressable.tsx +15 -4
- 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/core.ts +7 -28
- package/src/types/stylesheet.ts +3 -3
- package/src/web/convert/object/boxShadow.ts +2 -2
- package/src/web/index.ts +2 -1
- 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,169 +4,35 @@ using namespace margelo::nitro::unistyles;
|
|
|
4
4
|
using namespace facebook::react;
|
|
5
5
|
using namespace facebook;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
void shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
|
|
7
|
+
std::vector<Tag> shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
|
|
10
8
|
auto& registry = core::UnistylesRegistry::get();
|
|
11
9
|
|
|
10
|
+
// updates pin their families, so raw pointers stay valid during the commit
|
|
11
|
+
// declared outside of the lock, so the last pin is released after unlocking
|
|
12
|
+
PinnedShadowLeafUpdates updates;
|
|
13
|
+
std::vector<Tag> committedTags;
|
|
14
|
+
|
|
12
15
|
registry.trafficController.withLock([&](){
|
|
13
|
-
|
|
16
|
+
updates = registry.trafficController.takeUpdates();
|
|
14
17
|
|
|
15
18
|
if (updates.empty()) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
#if REACT_NATIVE_VERSION_MINOR >= 81
|
|
20
22
|
std::unordered_map<Tag, folly::dynamic> tagToProps;
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
auto safeProps = props.isObject() ? props : folly::dynamic::object();
|
|
24
|
+
committedTags.reserve(updates.size());
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
for (const auto& [family, update] : updates) {
|
|
27
|
+
auto safeProps = update.props.isObject() ? update.props : folly::dynamic::object();
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mutableFamily->nativeProps_DEPRECATED->update(safeProps);
|
|
31
|
-
} else {
|
|
32
|
-
mutableFamily->nativeProps_DEPRECATED = std::make_unique<folly::dynamic>(safeProps);
|
|
33
|
-
}
|
|
29
|
+
tagToProps.insert({family->getTag(), safeProps});
|
|
30
|
+
committedTags.push_back(family->getTag());
|
|
31
|
+
shadow::mergeNativeProps(family, safeProps);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
UIManagerBinding::getBinding(rt)->getUIManager().updateShadowTree(std::move(tagToProps));
|
|
37
|
-
#else
|
|
38
|
-
const auto& shadowTreeRegistry = UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry();
|
|
39
|
-
|
|
40
|
-
shadowTreeRegistry.enumerate([&updates](const ShadowTree& shadowTree, bool& stop){
|
|
41
|
-
// we could iterate via updates and create multiple commits
|
|
42
|
-
// but it can cause performance issues for hundreds of nodes
|
|
43
|
-
// so let's mutate Shadow Tree in single transaction
|
|
44
|
-
auto transaction = [&updates](const RootShadowNode& oldRootShadowNode) {
|
|
45
|
-
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
|
|
46
|
-
|
|
47
|
-
for (const auto& [family, props] : updates) {
|
|
48
|
-
// Merge props to fix glitches caused by REA updates
|
|
49
|
-
auto* mutableFamily = const_cast<ShadowNodeFamily*>(family);
|
|
50
|
-
auto safeProps = props.isObject() ? props : folly::dynamic::object();
|
|
51
|
-
|
|
52
|
-
if (mutableFamily->nativeProps_DEPRECATED && mutableFamily->nativeProps_DEPRECATED->isObject()) {
|
|
53
|
-
mutableFamily->nativeProps_DEPRECATED->update(safeProps);
|
|
54
|
-
} else {
|
|
55
|
-
mutableFamily->nativeProps_DEPRECATED = std::make_unique<folly::dynamic>(safeProps);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
|
60
|
-
oldRootShadowNode,
|
|
61
|
-
updates,
|
|
62
|
-
affectedNodes
|
|
63
|
-
));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// commit once!
|
|
67
|
-
// CommitOptions:
|
|
68
|
-
// enableStateReconciliation: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates
|
|
69
|
-
// mountSynchronously: must be true as this is update from C++ not React
|
|
70
|
-
shadowTree.commit(transaction, {false, true});
|
|
71
|
-
|
|
72
|
-
// for now we're assuming single surface, can be improved in the future
|
|
73
|
-
// stop = true means stop enumerating next shadow tree
|
|
74
|
-
// so in other words first shadow tree is our desired tree
|
|
75
|
-
stop = true;
|
|
76
|
-
});
|
|
77
|
-
#endif
|
|
78
35
|
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// based on Reanimated algorithm
|
|
82
|
-
// For each affected family we're gathering affected nodes (their indexes)
|
|
83
|
-
// Example:
|
|
84
|
-
// A
|
|
85
|
-
// / \
|
|
86
|
-
// B C
|
|
87
|
-
// / \
|
|
88
|
-
// D E*
|
|
89
|
-
// / \
|
|
90
|
-
// F G
|
|
91
|
-
//
|
|
92
|
-
// For ShadowFamily E* we will get:
|
|
93
|
-
//[
|
|
94
|
-
// 0 - because B is a first children of A,
|
|
95
|
-
// 1 - because E is a second children of B
|
|
96
|
-
//]
|
|
97
|
-
// A, B and E are affected now
|
|
98
|
-
AffectedNodes shadow::ShadowTreeManager::findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates) {
|
|
99
|
-
AffectedNodes affectedNodes;
|
|
100
|
-
|
|
101
|
-
for (const auto& [family, _] : updates) {
|
|
102
|
-
auto familyAncestors = family->getAncestors(rootNode);
|
|
103
|
-
|
|
104
|
-
for (auto it = familyAncestors.rbegin(); it != familyAncestors.rend(); ++it) {
|
|
105
|
-
const auto& [parentNode, index] = *it;
|
|
106
|
-
const auto parentFamily = &parentNode.get().getFamily();
|
|
107
|
-
auto [setIt, inserted] = affectedNodes.try_emplace(parentFamily, std::unordered_set<int>{});
|
|
108
|
-
|
|
109
|
-
setIt->second.insert(index);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
36
|
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
Props::Shared shadow::ShadowTreeManager::computeUpdatedProps(const ShadowNode &shadowNode, ShadowLeafUpdates& updates) {
|
|
117
|
-
const auto family = &shadowNode.getFamily();
|
|
118
|
-
const auto rawPropsIt = updates.find(family);
|
|
119
|
-
|
|
120
|
-
if (rawPropsIt == updates.end()) {
|
|
121
|
-
return ShadowNodeFragment::propsPlaceholder();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
|
125
|
-
const auto& props = shadowNode.getProps();
|
|
126
|
-
|
|
127
|
-
PropsParserContext propsParserContext{
|
|
128
|
-
shadowNode.getSurfaceId(),
|
|
129
|
-
*shadowNode.getContextContainer()
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
folly::dynamic newProps = rawPropsIt->second == nullptr
|
|
133
|
-
? folly::dynamic::object()
|
|
134
|
-
: rawPropsIt->second;
|
|
135
|
-
|
|
136
|
-
return componentDescriptor.cloneProps(
|
|
137
|
-
propsParserContext,
|
|
138
|
-
props,
|
|
139
|
-
RawProps(newProps)
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// based on Reanimated algorithm
|
|
144
|
-
// clone affected nodes recursively, inject props and commit tree
|
|
145
|
-
std::shared_ptr<ShadowNode> shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode &shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes) {
|
|
146
|
-
const auto family = &shadowNode.getFamily();
|
|
147
|
-
const auto childrenIt = affectedNodes.find(family);
|
|
148
|
-
|
|
149
|
-
// Only copy children if we need to update them
|
|
150
|
-
std::shared_ptr<std::vector<std::shared_ptr<const ShadowNode>>> childrenPtr;
|
|
151
|
-
const auto& originalChildren = shadowNode.getChildren();
|
|
152
|
-
|
|
153
|
-
if (childrenIt != affectedNodes.end()) {
|
|
154
|
-
auto children = originalChildren;
|
|
155
|
-
|
|
156
|
-
for (const auto index : childrenIt->second) {
|
|
157
|
-
children[index] = cloneShadowTree(*children[index], updates, affectedNodes);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
childrenPtr = std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(std::move(children));
|
|
161
|
-
} else {
|
|
162
|
-
childrenPtr = std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(originalChildren);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
Props::Shared updatedProps = computeUpdatedProps(shadowNode, updates);
|
|
166
|
-
|
|
167
|
-
return shadowNode.clone({
|
|
168
|
-
.props = updatedProps,
|
|
169
|
-
.children = childrenPtr,
|
|
170
|
-
.state = shadowNode.getState()
|
|
171
|
-
});
|
|
37
|
+
return committedTags;
|
|
172
38
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <react/renderer/uimanager/UIManager.h>
|
|
6
6
|
#include <ranges>
|
|
7
7
|
#include "ShadowLeafUpdate.h"
|
|
8
|
+
#include "NativeProps.h"
|
|
8
9
|
#include "UnistylesRegistry.h"
|
|
9
10
|
#include <cxxreact/ReactNativeVersion.h>
|
|
10
11
|
|
|
@@ -13,13 +14,8 @@ namespace margelo::nitro::unistyles::shadow {
|
|
|
13
14
|
using namespace facebook::react;
|
|
14
15
|
using namespace facebook;
|
|
15
16
|
|
|
16
|
-
using AffectedNodes = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;
|
|
17
|
-
|
|
18
17
|
struct ShadowTreeManager {
|
|
19
|
-
static
|
|
20
|
-
static AffectedNodes findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates);
|
|
21
|
-
static std::shared_ptr<ShadowNode> cloneShadowTree(const ShadowNode& shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes);
|
|
22
|
-
static Props::Shared computeUpdatedProps(const ShadowNode &shadowNode, ShadowLeafUpdates& updates);
|
|
18
|
+
static std::vector<Tag> updateShadowTree(jsi::Runtime& rt);
|
|
23
19
|
};
|
|
24
20
|
|
|
25
21
|
}
|
|
@@ -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":[]}
|
|
@@ -11,6 +11,8 @@ var _ScrollView = require("./ScrollView");
|
|
|
11
11
|
var _SectionList = require("./SectionList");
|
|
12
12
|
var _Text = require("./Text");
|
|
13
13
|
var _View = require("./View");
|
|
14
|
+
// explicit type keeps emitted declarations portable (RN 0.87+ Strict TypeScript API references private paths)
|
|
15
|
+
|
|
14
16
|
const Animated = exports.Animated = {
|
|
15
17
|
..._reactNative.Animated,
|
|
16
18
|
View: _reactNative.Animated.createAnimatedComponent(_View.View),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_FlatList","_Image","_ScrollView","_SectionList","_Text","_View","Animated","exports","RNAnimated","View","createAnimatedComponent","Text","FlatList","Image","ScrollView","SectionList"],"sourceRoot":"../../../../src","sources":["components/native/Animated.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_FlatList","_Image","_ScrollView","_SectionList","_Text","_View","Animated","exports","RNAnimated","View","createAnimatedComponent","Text","FlatList","Image","ScrollView","SectionList"],"sourceRoot":"../../../../src","sources":["components/native/Animated.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAMA;;AAaO,MAAMO,QAA2B,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACvC,GAAGE,qBAAU;EACbC,IAAI,EAAED,qBAAU,CAACE,uBAAuB,CAACD,UAAI,CAAC;EAC9CE,IAAI,EAAEH,qBAAU,CAACE,uBAAuB,CAACC,UAAI,CAAC;EAC9CC,QAAQ,EAAEJ,qBAAU,CAACE,uBAAuB,CAACE,kBAAQ,CAAC;EACtDC,KAAK,EAAEL,qBAAU,CAACE,uBAAuB,CAACG,YAAK,CAAC;EAChDC,UAAU,EAAEN,qBAAU,CAACE,uBAAuB,CAACI,sBAAU,CAAC;EAC1DC,WAAW,EAAEP,qBAAU,CAACE,uBAAuB,CAACK,wBAAW;AAC/D,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":[]}
|