react-native-unistyles 3.0.0-alpha.1 → 3.0.0-alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- package/Unistyles.podspec +33 -0
- package/cxx/common/Constants.h +1 -0
- package/cxx/common/Helpers.h +92 -0
- package/cxx/core/HostStyle.cpp +18 -12
- package/cxx/core/HostStyle.h +3 -0
- package/cxx/core/StyleSheet.h +0 -1
- package/cxx/core/StyleSheetRegistry.cpp +10 -13
- package/cxx/core/StyleSheetRegistry.h +4 -4
- package/cxx/core/Unistyle.h +0 -6
- package/cxx/core/UnistyleData.h +23 -0
- package/cxx/core/UnistyleWrapper.h +6 -6
- package/cxx/core/UnistylesCommitHook.cpp +8 -7
- package/cxx/core/UnistylesCommitHook.h +6 -1
- package/cxx/core/UnistylesCommitShadowNode.h +13 -0
- package/cxx/core/UnistylesMountHook.cpp +40 -0
- package/cxx/core/UnistylesMountHook.h +30 -0
- package/cxx/core/UnistylesRegistry.cpp +42 -56
- package/cxx/core/UnistylesRegistry.h +10 -8
- package/cxx/core/UnistylesState.cpp +4 -4
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +8 -1
- package/cxx/hybridObjects/HybridStyleSheet.cpp +35 -39
- package/cxx/hybridObjects/HybridStyleSheet.h +9 -6
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +34 -15
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
- package/cxx/parser/Parser.cpp +65 -137
- package/cxx/parser/Parser.h +8 -14
- package/ios/UnistylesModuleOnLoad.h +2 -0
- package/ios/UnistylesModuleOnLoad.mm +8 -1
- package/lib/commonjs/specs/NavigtionBar/index.js +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +1 -1
- package/lib/commonjs/web/convert/boxShadow.js +77 -0
- package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/breakpoint.js +25 -0
- package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +76 -0
- package/lib/commonjs/web/convert/index.js.map +1 -0
- package/lib/commonjs/web/convert/module.d.js +2 -0
- package/lib/commonjs/web/convert/module.d.js.map +1 -0
- package/lib/commonjs/web/convert/shadow.js +68 -0
- package/lib/commonjs/web/convert/shadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +89 -0
- package/lib/commonjs/web/convert/style.js.map +1 -0
- package/lib/commonjs/web/convert/textShadow.js +73 -0
- package/lib/commonjs/web/convert/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/transform.js +72 -0
- package/lib/commonjs/web/convert/transform.js.map +1 -0
- package/lib/commonjs/web/convert/types.js +9 -0
- package/lib/commonjs/web/convert/types.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +55 -0
- package/lib/commonjs/web/convert/utils.js.map +1 -0
- package/lib/commonjs/web/create.js +89 -0
- package/lib/commonjs/web/create.js.map +1 -0
- package/lib/commonjs/web/index.js +51 -0
- package/lib/commonjs/web/index.js.map +1 -0
- package/lib/commonjs/web/listener/index.js +13 -0
- package/lib/commonjs/web/listener/index.js.map +1 -0
- package/lib/commonjs/web/listener/listener.js +36 -0
- package/lib/commonjs/web/listener/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +37 -0
- package/lib/commonjs/web/mock.js.map +1 -0
- package/lib/commonjs/web/mq.js +23 -0
- package/lib/commonjs/web/mq.js.map +1 -0
- package/lib/commonjs/web/pseudo.js +11 -0
- package/lib/commonjs/web/pseudo.js.map +1 -0
- package/lib/commonjs/web/registry.js +37 -0
- package/lib/commonjs/web/registry.js.map +1 -0
- package/lib/commonjs/web/runtime.js +164 -0
- package/lib/commonjs/web/runtime.js.map +1 -0
- package/lib/commonjs/web/state.js +121 -0
- package/lib/commonjs/web/state.js.map +1 -0
- package/lib/commonjs/web/utils.js +78 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/commonjs/web/variants/getVariants.js +39 -0
- package/lib/commonjs/web/variants/getVariants.js.map +1 -0
- package/lib/commonjs/web/variants/index.js +28 -0
- package/lib/commonjs/web/variants/index.js.map +1 -0
- package/lib/commonjs/web/variants/useVariants.js +75 -0
- package/lib/commonjs/web/variants/useVariants.js.map +1 -0
- package/lib/module/specs/NavigtionBar/index.js +1 -1
- package/lib/module/specs/NavigtionBar/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +2 -2
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.web.js +1 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/web/convert/boxShadow.js +72 -0
- package/lib/module/web/convert/boxShadow.js.map +1 -0
- package/lib/module/web/convert/breakpoint.js +20 -0
- package/lib/module/web/convert/breakpoint.js.map +1 -0
- package/lib/module/web/convert/index.js +71 -0
- package/lib/module/web/convert/index.js.map +1 -0
- package/lib/module/web/convert/module.d.js +2 -0
- package/lib/module/web/convert/module.d.js.map +1 -0
- package/lib/module/web/convert/shadow.js +63 -0
- package/lib/module/web/convert/shadow.js.map +1 -0
- package/lib/module/web/convert/style.js +84 -0
- package/lib/module/web/convert/style.js.map +1 -0
- package/lib/module/web/convert/textShadow.js +68 -0
- package/lib/module/web/convert/textShadow.js.map +1 -0
- package/lib/module/web/convert/transform.js +67 -0
- package/lib/module/web/convert/transform.js.map +1 -0
- package/lib/module/web/convert/types.js +5 -0
- package/lib/module/web/convert/types.js.map +1 -0
- package/lib/module/web/convert/utils.js +43 -0
- package/lib/module/web/convert/utils.js.map +1 -0
- package/lib/module/web/create.js +84 -0
- package/lib/module/web/create.js.map +1 -0
- package/lib/module/web/index.js +24 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/listener/index.js +4 -0
- package/lib/module/web/listener/index.js.map +1 -0
- package/lib/module/web/listener/listener.js +31 -0
- package/lib/module/web/listener/listener.js.map +1 -0
- package/lib/module/web/mock.js +33 -0
- package/lib/module/web/mock.js.map +1 -0
- package/lib/module/web/mq.js +17 -0
- package/lib/module/web/mq.js.map +1 -0
- package/lib/module/web/pseudo.js +6 -0
- package/lib/module/web/pseudo.js.map +1 -0
- package/lib/module/web/registry.js +33 -0
- package/lib/module/web/registry.js.map +1 -0
- package/lib/module/web/runtime.js +160 -0
- package/lib/module/web/runtime.js.map +1 -0
- package/lib/module/web/state.js +117 -0
- package/lib/module/web/state.js.map +1 -0
- package/lib/module/web/utils.js +65 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/module/web/variants/getVariants.js +34 -0
- package/lib/module/web/variants/getVariants.js.map +1 -0
- package/lib/module/web/variants/index.js +5 -0
- package/lib/module/web/variants/index.js.map +1 -0
- package/lib/module/web/variants/useVariants.js +70 -0
- package/lib/module/web/variants/useVariants.js.map +1 -0
- package/lib/typescript/example/App.d.ts.map +1 -1
- package/lib/typescript/example/Typography.d.ts +12 -0
- package/lib/typescript/example/Typography.d.ts.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +1 -1
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/create.d.ts +11 -11
- package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
- package/lib/typescript/{web → src/web}/index.d.ts +12 -12
- package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
- package/lib/typescript/src/web/mock.d.ts.map +1 -0
- package/lib/typescript/src/web/mq.d.ts.map +1 -0
- package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
- package/lib/typescript/src/web/runtime.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/state.d.ts +4 -4
- package/lib/typescript/src/web/state.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
- package/lib/typescript/src/web/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/index.d.ts +3 -0
- package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
- package/package.json +2 -2
- package/plugin/__tests__/dependencies.spec.js +181 -103
- package/plugin/__tests__/ref.spec.js +335 -156
- package/plugin/__tests__/stylesheet.spec.js +148 -55
- package/plugin/index.js +31 -21
- package/plugin/ref.js +43 -11
- package/plugin/style.js +13 -24
- package/plugin/stylesheet.js +44 -1
- package/plugin/variants.js +33 -0
- package/src/specs/NavigtionBar/index.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +4 -4
- package/src/specs/StatusBar/index.ts +1 -1
- package/src/specs/StyleSheet/index.ts +3 -1
- package/src/specs/UnistylesRuntime/index.ts +1 -1
- package/src/specs/index.web.ts +1 -1
- package/src/types/stylesheet.ts +1 -1
- package/{web → src/web}/convert/breakpoint.ts +1 -1
- package/{web → src/web}/convert/index.ts +1 -1
- package/{web → src/web}/convert/types.ts +1 -1
- package/{web → src/web}/create.ts +36 -33
- package/{web → src/web}/listener/listener.ts +1 -1
- package/{web → src/web}/mock.ts +2 -2
- package/{web → src/web}/registry.ts +1 -1
- package/{web → src/web}/runtime.ts +4 -4
- package/{web → src/web}/state.ts +5 -5
- package/{web → src/web}/utils.ts +5 -5
- package/src/web/variants/getVariants.ts +42 -0
- package/src/web/variants/index.ts +2 -0
- package/{web → src/web/variants}/useVariants.ts +24 -44
- package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/web/convert/index.d.ts.map +0 -1
- package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/style.d.ts.map +0 -1
- package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/web/convert/types.d.ts.map +0 -1
- package/lib/typescript/web/convert/utils.d.ts.map +0 -1
- package/lib/typescript/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/web/mock.d.ts.map +0 -1
- package/lib/typescript/web/mq.d.ts.map +0 -1
- package/lib/typescript/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/web/registry.d.ts.map +0 -1
- package/lib/typescript/web/runtime.d.ts.map +0 -1
- package/lib/typescript/web/state.d.ts.map +0 -1
- package/lib/typescript/web/useVariants.d.ts +0 -3
- package/lib/typescript/web/useVariants.d.ts.map +0 -1
- package/lib/typescript/web/utils.d.ts.map +0 -1
- /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
- /package/{web → src/web}/convert/boxShadow.ts +0 -0
- /package/{web → src/web}/convert/module.d.ts +0 -0
- /package/{web → src/web}/convert/shadow.ts +0 -0
- /package/{web → src/web}/convert/style.ts +0 -0
- /package/{web → src/web}/convert/textShadow.ts +0 -0
- /package/{web → src/web}/convert/transform.ts +0 -0
- /package/{web → src/web}/convert/utils.ts +0 -0
- /package/{web → src/web}/index.ts +0 -0
- /package/{web → src/web}/listener/index.ts +0 -0
- /package/{web → src/web}/mq.ts +0 -0
- /package/{web → src/web}/pseudo.ts +0 -0
package/cxx/parser/Parser.cpp
CHANGED
@@ -11,7 +11,7 @@ void parser::Parser::buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet
|
|
11
11
|
jsi::Object unwrappedStyleSheet = this->unwrapStyleSheet(rt, styleSheet);
|
12
12
|
|
13
13
|
helpers::enumerateJSIObject(rt, unwrappedStyleSheet, [&](const std::string& styleKey, jsi::Value& propertyValue){
|
14
|
-
helpers::assertThat(rt, propertyValue.isObject(), "
|
14
|
+
helpers::assertThat(rt, propertyValue.isObject(), "Unistyles: Style with name '" + styleKey + "' is not a function or object.");
|
15
15
|
|
16
16
|
jsi::Object styleValue = propertyValue.asObject(rt);
|
17
17
|
|
@@ -68,14 +68,14 @@ jsi::Object parser::Parser::unwrapStyleSheet(jsi::Runtime& rt, std::shared_ptr<S
|
|
68
68
|
void parser::Parser::parseUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet) {
|
69
69
|
for (const auto& [_, unistyle] : styleSheet->unistyles) {
|
70
70
|
if (unistyle->type == core::UnistyleType::Object) {
|
71
|
-
auto result = this->parseFirstLevel(rt, unistyle,
|
71
|
+
auto result = this->parseFirstLevel(rt, unistyle, std::nullopt);
|
72
72
|
|
73
73
|
unistyle->parsedStyle = std::move(result);
|
74
74
|
unistyle->seal();
|
75
75
|
}
|
76
76
|
|
77
77
|
if (unistyle->type == core::UnistyleType::DynamicFunction) {
|
78
|
-
auto hostFn = this->createDynamicFunctionProxy(rt, unistyle
|
78
|
+
auto hostFn = this->createDynamicFunctionProxy(rt, unistyle);
|
79
79
|
auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
|
80
80
|
|
81
81
|
// defer parsing dynamic functions
|
@@ -85,57 +85,60 @@ void parser::Parser::parseUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet
|
|
85
85
|
}
|
86
86
|
|
87
87
|
// rebuild all unistyles in StyleSheet that depends on variants
|
88
|
-
void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet) {
|
88
|
+
void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Variants& variants) {
|
89
89
|
for (const auto& [_, unistyle] : styleSheet->unistyles) {
|
90
90
|
if (!unistyle->dependsOn(UnistyleDependency::VARIANTS)) {
|
91
91
|
continue;
|
92
92
|
}
|
93
93
|
|
94
|
-
|
94
|
+
// todo skip dynamic functions
|
95
|
+
this->rebuildUnistyle(rt, styleSheet, unistyle, variants, std::nullopt);
|
95
96
|
}
|
96
97
|
}
|
97
98
|
|
98
99
|
// rebuild all unistyles that are affected by platform event
|
99
100
|
void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap) {
|
100
|
-
for (
|
101
|
+
for (auto& [styleSheet, map] : dependencyMap) {
|
101
102
|
jsi::Object unwrappedStyleSheet = this->unwrapStyleSheet(rt, styleSheet);
|
102
103
|
|
103
|
-
for (
|
104
|
-
for (
|
104
|
+
for (auto& [shadowNode, unistyles] : map) {
|
105
|
+
for (auto& unistyleData : unistyles) {
|
106
|
+
auto& unistyle = unistyleData->unistyle;
|
107
|
+
|
105
108
|
// StyleSheet might have styles that are not affected
|
106
109
|
if (!unwrappedStyleSheet.hasProperty(rt, unistyle->styleKey.c_str())) {
|
107
110
|
continue;
|
108
111
|
}
|
109
112
|
|
110
113
|
unistyle->rawValue = unwrappedStyleSheet.getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
|
111
|
-
this->rebuildUnistyle(rt, styleSheet, unistyle);
|
114
|
+
this->rebuildUnistyle(rt, styleSheet, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
|
115
|
+
unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
|
112
116
|
}
|
113
117
|
}
|
114
118
|
}
|
115
119
|
}
|
116
120
|
|
117
121
|
// rebuild single unistyle
|
118
|
-
void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle) {
|
122
|
+
void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>> metadata) {
|
119
123
|
if (unistyle->type == core::UnistyleType::Object) {
|
120
|
-
auto result = this->parseFirstLevel(rt, unistyle,
|
124
|
+
auto result = this->parseFirstLevel(rt, unistyle, variants);
|
121
125
|
|
122
126
|
unistyle->parsedStyle = std::move(result);
|
123
127
|
}
|
124
128
|
|
125
129
|
// for functions we need to call memoized function
|
126
130
|
// with last know arguments and parse it with new theme and mini runtime
|
127
|
-
if (unistyle->type == core::UnistyleType::DynamicFunction) {
|
131
|
+
if (unistyle->type == core::UnistyleType::DynamicFunction && metadata.has_value()) {
|
128
132
|
auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
|
129
|
-
auto maybeMetadata = unistyleFn->dynamicFunctionMetadata;
|
130
|
-
|
131
|
-
helpers::assertThat(rt, maybeMetadata.has_value(), "Your dynamic function '" + unistyleFn->styleKey + "' has no metadata and can't be processed.");
|
132
133
|
|
133
134
|
// convert arguments to jsi::Value
|
134
|
-
auto
|
135
|
+
auto dynamicFunctionMetadata = metadata.value();
|
135
136
|
std::vector<jsi::Value> args{};
|
136
137
|
|
137
|
-
|
138
|
-
|
138
|
+
args.reserve(dynamicFunctionMetadata.size());
|
139
|
+
|
140
|
+
for (int i = 0; i < dynamicFunctionMetadata.size(); i++) {
|
141
|
+
folly::dynamic& arg = dynamicFunctionMetadata.at(i);
|
139
142
|
|
140
143
|
args.emplace_back(jsi::valueFromDynamic(rt, arg));
|
141
144
|
}
|
@@ -143,22 +146,25 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
|
|
143
146
|
const jsi::Value *argStart = args.data();
|
144
147
|
|
145
148
|
// call cached function with memoized arguments
|
146
|
-
auto functionResult = unistyleFn->
|
149
|
+
auto functionResult = unistyleFn->rawValue
|
150
|
+
.asFunction(rt)
|
151
|
+
.callAsConstructor(rt, argStart, dynamicFunctionMetadata.size())
|
152
|
+
.asObject(rt);
|
147
153
|
|
148
154
|
unistyleFn->unprocessedValue = std::move(functionResult);
|
149
|
-
unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn,
|
155
|
+
unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
|
150
156
|
}
|
151
157
|
}
|
152
158
|
|
153
159
|
// convert dependency map to shadow tree updates
|
154
|
-
shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(DependencyMap& dependencyMap) {
|
160
|
+
shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(core::DependencyMap& dependencyMap) {
|
155
161
|
shadow::ShadowLeafUpdates updates;
|
156
162
|
auto& rt = this->_unistylesRuntime->getRuntime();
|
157
163
|
|
158
164
|
for (const auto& [styleSheet, map] : dependencyMap) {
|
159
165
|
for (const auto& [shadowNode, unistyles] : map) {
|
160
|
-
for (const auto&
|
161
|
-
auto rawProps = this->parseStylesToShadowTreeStyles(rt,
|
166
|
+
for (const auto& unistyleData : unistyles) {
|
167
|
+
auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyleData->parsedStyle.value());
|
162
168
|
|
163
169
|
if (updates.contains(shadowNode)) {
|
164
170
|
updates[shadowNode].emplace_back(std::move(rawProps));
|
@@ -174,63 +180,9 @@ shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(Depen
|
|
174
180
|
return updates;
|
175
181
|
}
|
176
182
|
|
177
|
-
// convert jsi::Value arguments to folly::dynamic
|
178
|
-
std::vector<folly::dynamic> parser::Parser::parseDynamicFunctionArguments(jsi::Runtime& rt, size_t count, const jsi::Value* arguments) {
|
179
|
-
std::vector<folly::dynamic> parsedArgument{};
|
180
|
-
|
181
|
-
for (size_t i = 0; i < count; i++) {
|
182
|
-
auto& arg = arguments[i];
|
183
|
-
|
184
|
-
if (arg.isBool()) {
|
185
|
-
parsedArgument.push_back(folly::dynamic(arg.asBool()));
|
186
|
-
|
187
|
-
continue;
|
188
|
-
}
|
189
|
-
|
190
|
-
if (arg.isNumber()) {
|
191
|
-
parsedArgument.push_back(folly::dynamic(arg.asNumber()));
|
192
|
-
|
193
|
-
continue;
|
194
|
-
}
|
195
|
-
|
196
|
-
if (arg.isString()) {
|
197
|
-
parsedArgument.push_back(folly::dynamic(arg.asString(rt).utf8(rt)));
|
198
|
-
|
199
|
-
continue;
|
200
|
-
}
|
201
|
-
|
202
|
-
if (arg.isUndefined()) {
|
203
|
-
parsedArgument.push_back(folly::dynamic());
|
204
|
-
|
205
|
-
continue;
|
206
|
-
}
|
207
|
-
|
208
|
-
if (arg.isNull()) {
|
209
|
-
parsedArgument.push_back(folly::dynamic(nullptr));
|
210
|
-
|
211
|
-
continue;
|
212
|
-
}
|
213
|
-
|
214
|
-
if (!arg.isObject()) {
|
215
|
-
continue;;
|
216
|
-
}
|
217
|
-
|
218
|
-
auto argObj = arg.asObject(rt);
|
219
|
-
|
220
|
-
// allow arrays and objects too
|
221
|
-
if (!argObj.isFunction(rt) && !argObj.isArrayBuffer(rt)) {
|
222
|
-
parsedArgument.push_back(jsi::dynamicFromValue(rt, arg));
|
223
|
-
|
224
|
-
continue;
|
225
|
-
}
|
226
|
-
}
|
227
|
-
|
228
|
-
return parsedArgument;
|
229
|
-
}
|
230
|
-
|
231
183
|
// first level of StyleSheet, we can expect here different properties than on second level
|
232
184
|
// eg. variants, compoundVariants, mq, breakpoints etc.
|
233
|
-
jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, Variants
|
185
|
+
jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants) {
|
234
186
|
// for objects - we simply operate on them
|
235
187
|
// for functions we need to work on the unprocessed result (object)
|
236
188
|
auto& style = unistyle->type == core::UnistyleType::Object
|
@@ -312,20 +264,16 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
|
|
312
264
|
|
313
265
|
parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), this->parseSecondLevel(rt, unistyle, valueFromBreakpoint));
|
314
266
|
});
|
315
|
-
|
316
|
-
if (shouldParseVariants) {
|
317
|
-
unistyle->addDependency(UnistyleDependency::VARIANTS);
|
318
|
-
}
|
319
267
|
|
320
|
-
if (shouldParseVariants && !variants.empty()) {
|
268
|
+
if (shouldParseVariants && variants.has_value() && !variants.value().empty()) {
|
321
269
|
auto propertyValueObject = style.getProperty(rt, "variants").asObject(rt);
|
322
|
-
auto parsedVariant = this->parseVariants(rt, unistyle, propertyValueObject, variants);
|
270
|
+
auto parsedVariant = this->parseVariants(rt, unistyle, propertyValueObject, variants.value());
|
323
271
|
|
324
272
|
helpers::mergeJSIObjects(rt, parsedStyle, parsedVariant);
|
325
273
|
|
326
274
|
if (shouldParseCompoundVariants) {
|
327
275
|
auto compoundVariants = style.getProperty(rt, "compoundVariants").asObject(rt);
|
328
|
-
auto parsedCompoundVariants = this->parseCompoundVariants(rt, unistyle, compoundVariants, variants);
|
276
|
+
auto parsedCompoundVariants = this->parseCompoundVariants(rt, unistyle, compoundVariants, variants.value());
|
329
277
|
|
330
278
|
helpers::mergeJSIObjects(rt, parsedStyle, parsedCompoundVariants);
|
331
279
|
}
|
@@ -335,29 +283,32 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
|
|
335
283
|
}
|
336
284
|
|
337
285
|
// function replaces original user dynamic function with additional logic to memoize arguments
|
338
|
-
jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unistyle::Shared unistyle
|
286
|
+
jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unistyle::Shared unistyle) {
|
339
287
|
auto unistylesRuntime = this->_unistylesRuntime;
|
340
288
|
|
341
289
|
return jsi::Function::createFromHostFunction(
|
342
290
|
rt,
|
343
291
|
jsi::PropNameID::forUtf8(rt, unistyle->styleKey),
|
344
292
|
1,
|
345
|
-
[this, unistylesRuntime, unistyle
|
293
|
+
[this, unistylesRuntime, unistyle](jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
|
346
294
|
auto thisObject = thisVal.asObject(rt);
|
347
295
|
auto parser = parser::Parser(unistylesRuntime);
|
348
|
-
|
296
|
+
|
349
297
|
// call user function
|
350
298
|
auto result = unistyle->rawValue.asFunction(rt).call(rt, args, count);
|
351
299
|
|
352
300
|
// memoize metadata to call it later
|
353
301
|
auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
|
354
302
|
|
355
|
-
unistyleFn->dynamicFunctionMetadata = core::DynamicFunctionMetadata{
|
356
|
-
count,
|
357
|
-
this->parseDynamicFunctionArguments(rt, count, args)
|
358
|
-
};
|
359
|
-
|
360
303
|
unistyleFn->unprocessedValue = jsi::Value(rt, result).asObject(rt);
|
304
|
+
|
305
|
+
jsi::Value rawVariants = thisObject.hasProperty(rt, helpers::STYLE_VARIANTS.c_str())
|
306
|
+
? thisObject.getProperty(rt, helpers::STYLE_VARIANTS.c_str())
|
307
|
+
: jsi::Value::undefined();
|
308
|
+
std::optional<Variants> variants = rawVariants.isUndefined()
|
309
|
+
? std::nullopt
|
310
|
+
: std::optional<Variants>(helpers::variantsToPairs(rt, rawVariants.asObject(rt)));
|
311
|
+
|
361
312
|
unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
|
362
313
|
unistyleFn->seal();
|
363
314
|
|
@@ -367,9 +318,11 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
|
|
367
318
|
|
368
319
|
// function convert babel generated dependencies to C++ dependencies
|
369
320
|
std::vector<UnistyleDependency> parser::Parser::parseDependencies(jsi::Runtime &rt, jsi::Object&& dependencies) {
|
370
|
-
helpers::assertThat(rt, dependencies.isArray(rt), "
|
321
|
+
helpers::assertThat(rt, dependencies.isArray(rt), "Unistyles: Babel transform is invalid - unexpected type for dependencies.");
|
371
322
|
|
372
|
-
std::vector<UnistyleDependency> parsedDependencies;
|
323
|
+
std::vector<UnistyleDependency> parsedDependencies{};
|
324
|
+
|
325
|
+
parsedDependencies.reserve(5);
|
373
326
|
|
374
327
|
helpers::iterateJSIArray(rt, dependencies.asArray(rt), [&](size_t i, jsi::Value& value){
|
375
328
|
auto dependency = static_cast<UnistyleDependency>(value.asNumber());
|
@@ -388,6 +341,8 @@ jsi::Value parser::Parser::parseTransforms(jsi::Runtime& rt, Unistyle::Shared un
|
|
388
341
|
|
389
342
|
std::vector<jsi::Value> parsedTransforms{};
|
390
343
|
|
344
|
+
parsedTransforms.reserve(2);
|
345
|
+
|
391
346
|
helpers::iterateJSIArray(rt, obj.asArray(rt), [&](size_t i, jsi::Value& value){
|
392
347
|
if (!value.isObject()) {
|
393
348
|
return;
|
@@ -434,7 +389,7 @@ jsi::Value parser::Parser::getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::S
|
|
434
389
|
auto propertyName = propertyNames.getValueAtIndex(rt, i).asString(rt).utf8(rt);
|
435
390
|
auto propertyValue = obj.getProperty(rt, propertyName.c_str());
|
436
391
|
auto mq = core::UnistylesMQ{propertyName};
|
437
|
-
|
392
|
+
|
438
393
|
if (mq.isMQ()) {
|
439
394
|
unistyle->addDependency(UnistyleDependency::BREAKPOINTS);
|
440
395
|
}
|
@@ -447,11 +402,11 @@ jsi::Value parser::Parser::getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::S
|
|
447
402
|
|
448
403
|
// check orientation breakpoints if user didn't register own breakpoint
|
449
404
|
bool hasOrientationBreakpoint = obj.hasProperty(rt, currentOrientation);
|
450
|
-
|
405
|
+
|
451
406
|
if (hasOrientationBreakpoint) {
|
452
407
|
unistyle->addDependency(UnistyleDependency::BREAKPOINTS);
|
453
408
|
}
|
454
|
-
|
409
|
+
|
455
410
|
if (!hasBreakpoints && hasOrientationBreakpoint) {
|
456
411
|
return obj.getProperty(rt, currentOrientation);
|
457
412
|
}
|
@@ -459,7 +414,7 @@ jsi::Value parser::Parser::getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::S
|
|
459
414
|
if (!currentBreakpoint.has_value()) {
|
460
415
|
return jsi::Value::undefined();
|
461
416
|
}
|
462
|
-
|
417
|
+
|
463
418
|
unistyle->addDependency(UnistyleDependency::BREAKPOINTS);
|
464
419
|
|
465
420
|
// if you're still here it means that there is no
|
@@ -505,7 +460,7 @@ jsi::Object parser::Parser::parseVariants(jsi::Runtime& rt, Unistyle::Shared uni
|
|
505
460
|
: std::nullopt;
|
506
461
|
|
507
462
|
// we've got a match, but we need to check some condition
|
508
|
-
auto styles = this->getStylesForVariant(rt, groupValue.asObject(rt), selectedVariant);
|
463
|
+
auto styles = this->getStylesForVariant(rt, groupName, groupValue.asObject(rt), selectedVariant, variants);
|
509
464
|
|
510
465
|
// oops, invalid variant
|
511
466
|
if (styles.isUndefined() || !styles.isObject()) {
|
@@ -521,13 +476,19 @@ jsi::Object parser::Parser::parseVariants(jsi::Runtime& rt, Unistyle::Shared uni
|
|
521
476
|
}
|
522
477
|
|
523
478
|
// helpers function to support 'default' variants
|
524
|
-
jsi::Value parser::Parser::getStylesForVariant(jsi::Runtime& rt, jsi::Object&& groupValue, std::optional<std::string> selectedVariant) {
|
479
|
+
jsi::Value parser::Parser::getStylesForVariant(jsi::Runtime& rt, const std::string groupName, jsi::Object&& groupValue, std::optional<std::string> selectedVariant, Variants& variants) {
|
525
480
|
// if there is no value, let's try 'default'
|
526
481
|
auto selectedVariantKey = selectedVariant.has_value()
|
527
482
|
? selectedVariant.value().c_str()
|
528
483
|
: "default";
|
484
|
+
auto hasKey = groupValue.hasProperty(rt, selectedVariantKey);
|
529
485
|
|
530
|
-
if (
|
486
|
+
if (hasKey && !selectedVariant.has_value()) {
|
487
|
+
// add 'default' selection to variants map
|
488
|
+
variants.emplace_back(groupName, selectedVariantKey);
|
489
|
+
}
|
490
|
+
|
491
|
+
if (hasKey) {
|
531
492
|
return groupValue.getProperty(rt, selectedVariantKey);
|
532
493
|
}
|
533
494
|
|
@@ -567,22 +528,12 @@ bool parser::Parser::shouldApplyCompoundVariants(jsi::Runtime& rt, const Variant
|
|
567
528
|
return false;
|
568
529
|
}
|
569
530
|
|
570
|
-
jsi::Array propertyNames = compoundVariant.getPropertyNames(rt);
|
571
|
-
size_t length = propertyNames.size(rt);
|
572
|
-
size_t allConditions = compoundVariant.hasProperty(rt, "styles")
|
573
|
-
? length - 1
|
574
|
-
: length;
|
575
|
-
|
576
|
-
if (allConditions != variants.size()) {
|
577
|
-
return false;
|
578
|
-
}
|
579
|
-
|
580
531
|
for (auto it = variants.cbegin(); it != variants.cend(); ++it) {
|
581
532
|
auto variantKey = it->first;
|
582
533
|
auto variantValue = it->second;
|
583
534
|
|
584
535
|
if (!compoundVariant.hasProperty(rt, variantKey.c_str())) {
|
585
|
-
|
536
|
+
continue;
|
586
537
|
}
|
587
538
|
|
588
539
|
auto property = compoundVariant.getProperty(rt, variantKey.c_str());
|
@@ -666,31 +617,8 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
666
617
|
return parsedStyle;
|
667
618
|
}
|
668
619
|
|
669
|
-
// helpers function that convert variants from JS to C++ variants
|
670
|
-
Variants parser::Parser::variantsToPairs(jsi::Runtime& rt, jsi::Object&& variants) {
|
671
|
-
Variants pairs{};
|
672
|
-
|
673
|
-
helpers::enumerateJSIObject(rt, variants, [&](const std::string& variantName, jsi::Value& variantValue){
|
674
|
-
if (variantValue.isUndefined() || variantValue.isNull()) {
|
675
|
-
return;
|
676
|
-
}
|
677
|
-
|
678
|
-
if (variantValue.isBool()) {
|
679
|
-
pairs.emplace_back(std::make_pair(variantName, variantValue.asBool() ? "true" : "false"));
|
680
|
-
|
681
|
-
return;
|
682
|
-
}
|
683
|
-
|
684
|
-
if (variantValue.isString()) {
|
685
|
-
pairs.emplace_back(std::make_pair(variantName, variantValue.asString(rt).utf8(rt)));
|
686
|
-
}
|
687
|
-
});
|
688
|
-
|
689
|
-
return pairs;
|
690
|
-
}
|
691
|
-
|
692
620
|
// convert jsi::Object to RawValue with int colors
|
693
|
-
RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, jsi::Object& styles) {
|
621
|
+
RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const jsi::Object& styles) {
|
694
622
|
jsi::Object convertedStyles = jsi::Object(rt);
|
695
623
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
696
624
|
|
package/cxx/parser/Parser.h
CHANGED
@@ -17,36 +17,30 @@ using namespace facebook;
|
|
17
17
|
using namespace margelo::nitro::unistyles::core;
|
18
18
|
|
19
19
|
using Variants = std::vector<std::pair<std::string, std::string>>;
|
20
|
-
using DependencyMap = std::unordered_map<
|
21
|
-
std::shared_ptr<core::StyleSheet>,
|
22
|
-
std::unordered_map<const ShadowNodeFamily*, std::vector<core::Unistyle::Shared>>
|
23
|
-
>;
|
24
20
|
|
25
21
|
struct Parser {
|
26
22
|
Parser(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime): _unistylesRuntime{unistylesRuntime} {}
|
27
23
|
|
28
24
|
void buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
|
29
25
|
void parseUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
|
30
|
-
|
31
|
-
void
|
32
|
-
|
33
|
-
shadow::ShadowLeafUpdates dependencyMapToShadowLeafUpdates(DependencyMap& dependencyMap);
|
26
|
+
void rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Variants& variants);
|
27
|
+
void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap);
|
28
|
+
shadow::ShadowLeafUpdates dependencyMapToShadowLeafUpdates(core::DependencyMap& dependencyMap);
|
34
29
|
|
35
30
|
private:
|
36
|
-
void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle);
|
31
|
+
void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>>);
|
37
32
|
jsi::Object unwrapStyleSheet(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
|
38
|
-
jsi::Object parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, Variants
|
33
|
+
jsi::Object parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants);
|
39
34
|
jsi::Value parseSecondLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& nestedObject);
|
40
|
-
jsi::Function createDynamicFunctionProxy(jsi::Runtime& rt, Unistyle::Shared unistyle
|
41
|
-
std::vector<folly::dynamic> parseDynamicFunctionArguments(jsi::Runtime& rt, size_t count, const jsi::Value* arguments);
|
35
|
+
jsi::Function createDynamicFunctionProxy(jsi::Runtime& rt, Unistyle::Shared unistyle);
|
42
36
|
std::vector<UnistyleDependency> parseDependencies(jsi::Runtime &rt, jsi::Object&& dependencies);
|
43
37
|
jsi::Value parseTransforms(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
44
38
|
jsi::Value getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
45
39
|
jsi::Object parseVariants(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj, Variants& variants);
|
46
|
-
jsi::Value getStylesForVariant(jsi::Runtime& rt, jsi::Object&& groupValue, std::optional<std::string> selectedVariant);
|
40
|
+
jsi::Value getStylesForVariant(jsi::Runtime& rt, const std::string groupName, jsi::Object&& groupValue, std::optional<std::string> selectedVariant, Variants& variants);
|
47
41
|
jsi::Object parseCompoundVariants(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj, Variants& variants);
|
48
42
|
bool shouldApplyCompoundVariants(jsi::Runtime& rt, const Variants& variants, jsi::Object& compoundVariant);
|
49
|
-
RawProps parseStylesToShadowTreeStyles(jsi::Runtime& rt, jsi::Object& parsedStyles);
|
43
|
+
RawProps parseStylesToShadowTreeStyles(jsi::Runtime& rt, const jsi::Object& parsedStyles);
|
50
44
|
bool isColor(const std::string& propertyName);
|
51
45
|
|
52
46
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
@@ -3,6 +3,8 @@
|
|
3
3
|
#import <React/RCTEventEmitter.h>
|
4
4
|
#import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
|
5
5
|
#import "TurboUnistyles/TurboUnistyles.h"
|
6
|
+
#import <React/RCTSurfacePresenter.h>
|
7
|
+
#import <React/RCTScheduler.h>
|
6
8
|
|
7
9
|
@interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec>
|
8
10
|
@end
|
@@ -10,10 +10,16 @@ using namespace margelo::nitro;
|
|
10
10
|
|
11
11
|
RCT_EXPORT_MODULE(Unistyles)
|
12
12
|
|
13
|
+
__weak RCTSurfacePresenter* _surfacePresenter;
|
14
|
+
|
13
15
|
+ (BOOL)requiresMainQueueSetup {
|
14
16
|
return YES;
|
15
17
|
}
|
16
18
|
|
19
|
+
- (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter {
|
20
|
+
_surfacePresenter = surfacePresenter;
|
21
|
+
}
|
22
|
+
|
17
23
|
- (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt {
|
18
24
|
// function is called on: first init and every live reload
|
19
25
|
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
@@ -31,7 +37,8 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
31
37
|
- (void)createHybrids:(jsi::Runtime&)rt {
|
32
38
|
auto nativePlatform = Unistyles::NativePlatform::create();
|
33
39
|
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt);
|
34
|
-
auto
|
40
|
+
auto uiManager = [_surfacePresenter scheduler].uiManager;
|
41
|
+
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime, uiManager);
|
35
42
|
|
36
43
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
37
44
|
return unistylesRuntime;
|
@@ -9,7 +9,7 @@ const attachNavigationBarJSMethods = hybridObject => {
|
|
9
9
|
const privateHybrid = hybridObject;
|
10
10
|
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
11
11
|
hybridObject.setBackgroundColor = color => {
|
12
|
-
const parsedColor = (0, _reactNative.processColor)(color);
|
12
|
+
const parsedColor = (0, _reactNative.processColor)(color) ?? 0;
|
13
13
|
privateHybrid._setBackgroundColor(parsedColor);
|
14
14
|
};
|
15
15
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","attachNavigationBarJSMethods","hybridObject","privateHybrid","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/NavigtionBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASO,MAAMC,4BAA4B,GAAIC,YAAoC,IAAK;EAClF,MAAMC,aAAa,GAAGD,YAA6C;EAEnEC,aAAa,CAACC,mBAAmB,GAAGF,YAAY,CAACG,kBAAkB;EACnEH,YAAY,CAACG,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC;
|
1
|
+
{"version":3,"names":["_reactNative","require","attachNavigationBarJSMethods","hybridObject","privateHybrid","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/NavigtionBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASO,MAAMC,4BAA4B,GAAIC,YAAoC,IAAK;EAClF,MAAMC,aAAa,GAAGD,YAA6C;EAEnEC,aAAa,CAACC,mBAAmB,GAAGF,YAAY,CAACG,kBAAkB;EACnEH,YAAY,CAACG,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CH,aAAa,CAACC,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAAR,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
@@ -14,11 +14,11 @@ const findShadowNodeForHandle = handle => {
|
|
14
14
|
}
|
15
15
|
return node;
|
16
16
|
};
|
17
|
-
HybridShadowRegistry.add = (handle, style) => {
|
17
|
+
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
18
18
|
if (!handle || !style?.__unid) {
|
19
19
|
return;
|
20
20
|
}
|
21
|
-
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style);
|
21
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
22
22
|
};
|
23
23
|
HybridShadowRegistry.remove = (handle, style) => {
|
24
24
|
if (!handle || !style?.__unid) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","__unid","link","remove","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,KAAK;
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","__unid","link","remove","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAf,oBAAoB,CAACgB,IAAI,CAACb,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDd,oBAAoB,CAACiB,MAAM,GAAG,CAACb,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAf,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
|
@@ -25,7 +25,7 @@ const attachStatusBarJSMethods = hybridObject => {
|
|
25
25
|
};
|
26
26
|
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
27
27
|
hybridObject.setBackgroundColor = color => {
|
28
|
-
const parsedColor = (0, _reactNative.processColor)(color);
|
28
|
+
const parsedColor = (0, _reactNative.processColor)(color) ?? 0;
|
29
29
|
privateHybrid._setBackgroundColor(parsedColor);
|
30
30
|
};
|
31
31
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_types","attachStatusBarJSMethods","hybridObject","setStyle","style","animated","StatusBarStyle","Light","NativeStatusBar","setBarStyle","Dark","Default","privateHybrid","_setHidden","setHidden","isHidden","animation","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/StatusBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAYO,MAAME,wBAAwB,GAAIC,YAAgC,IAAK;EAC1EA,YAAY,CAACC,QAAQ,GAAG,CAACC,KAAqB,EAAEC,QAAkB,KAAK;IACnE,QAAQD,KAAK;MACT,KAAKE,qBAAc,CAACC,KAAK;QACrB,OAAOC,sBAAe,CAACC,WAAW,CAAC,eAAe,EAAEJ,QAAQ,CAAC;MACjE,KAAKC,qBAAc,CAACI,IAAI;QACpB,OAAOF,sBAAe,CAACC,WAAW,CAAC,cAAc,EAAEJ,QAAQ,CAAC;MAChE,KAAKC,qBAAc,CAACK,OAAO;QACvB,OAAOH,sBAAe,CAACC,WAAW,CAAC,SAAS,EAAEJ,QAAQ,CAAC;IAC/D;EACJ,CAAC;EAED,MAAMO,aAAa,GAAGV,YAAyC;EAE/DU,aAAa,CAACC,UAAU,GAAGX,YAAY,CAACY,SAAS;EACjDZ,YAAY,CAACY,SAAS,GAAG,CAACC,QAAiB,EAAEC,SAAoC,KAAK;IAClFR,sBAAe,CAACM,SAAS,CAACC,QAAQ,EAAEC,SAAS,CAAC;IAC9CJ,aAAa,CAACC,UAAU,CAACE,QAAQ,CAAC;EACtC,CAAC;EAEDH,aAAa,CAACK,mBAAmB,GAAGf,YAAY,CAACgB,kBAAkB;EACnEhB,YAAY,CAACgB,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC;
|
1
|
+
{"version":3,"names":["_reactNative","require","_types","attachStatusBarJSMethods","hybridObject","setStyle","style","animated","StatusBarStyle","Light","NativeStatusBar","setBarStyle","Dark","Default","privateHybrid","_setHidden","setHidden","isHidden","animation","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/StatusBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAYO,MAAME,wBAAwB,GAAIC,YAAgC,IAAK;EAC1EA,YAAY,CAACC,QAAQ,GAAG,CAACC,KAAqB,EAAEC,QAAkB,KAAK;IACnE,QAAQD,KAAK;MACT,KAAKE,qBAAc,CAACC,KAAK;QACrB,OAAOC,sBAAe,CAACC,WAAW,CAAC,eAAe,EAAEJ,QAAQ,CAAC;MACjE,KAAKC,qBAAc,CAACI,IAAI;QACpB,OAAOF,sBAAe,CAACC,WAAW,CAAC,cAAc,EAAEJ,QAAQ,CAAC;MAChE,KAAKC,qBAAc,CAACK,OAAO;QACvB,OAAOH,sBAAe,CAACC,WAAW,CAAC,SAAS,EAAEJ,QAAQ,CAAC;IAC/D;EACJ,CAAC;EAED,MAAMO,aAAa,GAAGV,YAAyC;EAE/DU,aAAa,CAACC,UAAU,GAAGX,YAAY,CAACY,SAAS;EACjDZ,YAAY,CAACY,SAAS,GAAG,CAACC,QAAiB,EAAEC,SAAoC,KAAK;IAClFR,sBAAe,CAACM,SAAS,CAACC,QAAQ,EAAEC,SAAS,CAAC;IAC9CJ,aAAa,CAACC,UAAU,CAACE,QAAQ,CAAC;EACtC,CAAC;EAEDH,aAAa,CAACK,mBAAmB,GAAGf,YAAY,CAACgB,kBAAkB;EACnEhB,YAAY,CAACgB,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CP,aAAa,CAACK,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAArB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","_reactNative","HybridUnistylesStyleSheet","NitroModules","createHybridObject","absoluteFillObject","NativeStyleSheet","absoluteFill","flatten","compose","jsMethods","processColor","StyleSheet","exports"],"sourceRoot":"../../../../src","sources":["specs/StyleSheet/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA+BA,MAAME,yBAAyB,GAAGC,qCAAY,CACzCC,kBAAkB,CAAsB,qBAAqB,CAAC;AAEnEF,yBAAyB,CAACG,kBAAkB,GAAGC,uBAAgB,CAACD,kBAAkB;AAClFH,yBAAyB,CAACK,YAAY,GAAGD,uBAAgB,CAACC,YAAY;AACtEL,yBAAyB,CAACM,OAAO,GAAGF,uBAAgB,CAACE,OAAO;AAC5DN,yBAAyB,CAACO,OAAO,GAAGH,uBAAgB,CAACG,OAAO;AAC5DP,yBAAyB,CAACQ,SAAS,GAAG;EAClCC,YAAY,EAAZA;AACJ,CAAC;
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","_reactNative","HybridUnistylesStyleSheet","NitroModules","createHybridObject","absoluteFillObject","NativeStyleSheet","absoluteFill","flatten","compose","jsMethods","processColor","StyleSheet","exports"],"sourceRoot":"../../../../src","sources":["specs/StyleSheet/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA+BA,MAAME,yBAAyB,GAAGC,qCAAY,CACzCC,kBAAkB,CAAsB,qBAAqB,CAAC;AAEnEF,yBAAyB,CAACG,kBAAkB,GAAGC,uBAAgB,CAACD,kBAAkB;AAClFH,yBAAyB,CAACK,YAAY,GAAGD,uBAAgB,CAACC,YAAY;AACtEL,yBAAyB,CAACM,OAAO,GAAGF,uBAAgB,CAACE,OAAO;AAC5DN,yBAAyB,CAACO,OAAO,GAAGH,uBAAgB,CAACG,OAAO;AAC5DP,yBAAyB,CAACQ,SAAS,GAAG;EAClCC,YAAY,EAAZA;AACJ,CAAC;AAIM,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGV,yBAAsE","ignoreList":[]}
|
@@ -14,7 +14,7 @@ HybridUnistylesRuntime.statusBar = HybridUnistylesRuntime.createHybridStatusBar(
|
|
14
14
|
HybridUnistylesRuntime.navigationBar = HybridUnistylesRuntime.createHybridNavigationBar();
|
15
15
|
HybridUnistylesRuntime._setRootViewBackgroundColor = HybridUnistylesRuntime.setRootViewBackgroundColor;
|
16
16
|
HybridUnistylesRuntime.setRootViewBackgroundColor = color => {
|
17
|
-
const parsedColor = (0, _reactNative.processColor)(color);
|
17
|
+
const parsedColor = (0, _reactNative.processColor)(color) ?? 0;
|
18
18
|
HybridUnistylesRuntime._setRootViewBackgroundColor(parsedColor);
|
19
19
|
};
|
20
20
|
if (_common.isIOS) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_reactNativeNitroModules","_StatusBar","_NavigtionBar","_common","HybridUnistylesRuntime","NitroModules","createHybridObject","statusBar","createHybridStatusBar","navigationBar","createHybridNavigationBar","_setRootViewBackgroundColor","setRootViewBackgroundColor","color","parsedColor","processColor","isIOS","setImmersiveMode","isEnabled","setHidden","attachStatusBarJSMethods","attachNavigationBarJSMethods","Runtime","exports"],"sourceRoot":"../../../../src","sources":["specs/UnistylesRuntime/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAgCA,MAAMK,sBAAsB,GAAGC,qCAAY,CACtCC,kBAAkB,CAA0B,kBAAkB,CAAC;AAEpEF,sBAAsB,CAACG,SAAS,GAAGH,sBAAsB,CAACI,qBAAqB,CAAC,CAAC;AACjFJ,sBAAsB,CAACK,aAAa,GAAGL,sBAAsB,CAACM,yBAAyB,CAAC,CAAC;AACzFN,sBAAsB,CAACO,2BAA2B,GAAGP,sBAAsB,CAACQ,0BAA0B;AAEtGR,sBAAsB,CAACQ,0BAA0B,GAAIC,KAAc,IAAK;EACpE,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC;
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeNitroModules","_StatusBar","_NavigtionBar","_common","HybridUnistylesRuntime","NitroModules","createHybridObject","statusBar","createHybridStatusBar","navigationBar","createHybridNavigationBar","_setRootViewBackgroundColor","setRootViewBackgroundColor","color","parsedColor","processColor","isIOS","setImmersiveMode","isEnabled","setHidden","attachStatusBarJSMethods","attachNavigationBarJSMethods","Runtime","exports"],"sourceRoot":"../../../../src","sources":["specs/UnistylesRuntime/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAgCA,MAAMK,sBAAsB,GAAGC,qCAAY,CACtCC,kBAAkB,CAA0B,kBAAkB,CAAC;AAEpEF,sBAAsB,CAACG,SAAS,GAAGH,sBAAsB,CAACI,qBAAqB,CAAC,CAAC;AACjFJ,sBAAsB,CAACK,aAAa,GAAGL,sBAAsB,CAACM,yBAAyB,CAAC,CAAC;AACzFN,sBAAsB,CAACO,2BAA2B,GAAGP,sBAAsB,CAACQ,0BAA0B;AAEtGR,sBAAsB,CAACQ,0BAA0B,GAAIC,KAAc,IAAK;EACpE,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;EAE5CT,sBAAsB,CAACO,2BAA2B,CAACG,WAAqB,CAAC;AAC7E,CAAC;AAED,IAAIE,aAAK,EAAE;EACPZ,sBAAsB,CAACa,gBAAgB,GAAIC,SAAkB,IAAKd,sBAAsB,CAACG,SAAS,CAACY,SAAS,CAACD,SAAS,EAAE,MAAM,CAAC;AACnI;AAEA,IAAAE,mCAAwB,EAAChB,sBAAsB,CAACG,SAAS,CAAC;AAC1D,IAAAc,0CAA4B,EAACjB,sBAAsB,CAACK,aAAa,CAAC;AAE3D,MAAMa,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGlB,sBAA0C","ignoreList":[]}
|
@@ -7,7 +7,7 @@ var _exportNames = {
|
|
7
7
|
getSSRUnistyles: true
|
8
8
|
};
|
9
9
|
exports.getSSRUnistyles = void 0;
|
10
|
-
var _web = require("
|
10
|
+
var _web = require("../web");
|
11
11
|
Object.keys(_web).forEach(function (key) {
|
12
12
|
if (key === "default" || key === "__esModule") return;
|
13
13
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|