react-native-unistyles 3.0.0-alpha.19 → 3.0.0-alpha.20
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/cxx/common/Constants.h +1 -0
- package/cxx/common/Helpers.h +7 -7
- package/cxx/core/HostStyle.cpp +1 -1
- package/cxx/core/HostStyle.h +1 -0
- package/cxx/core/StyleSheet.h +0 -1
- package/cxx/core/UnistyleWrapper.h +77 -9
- package/cxx/core/UnistylesRegistry.cpp +14 -13
- package/cxx/core/UnistylesRegistry.h +3 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -5
- package/cxx/parser/Parser.cpp +10 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js +3 -35
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/createUnistylesComponent.js +2 -2
- package/lib/commonjs/web/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/web/listener/listenToDependencies.js +2 -3
- package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -1
- package/lib/commonjs/web/registry.js +22 -0
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -2
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +3 -35
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/createUnistylesComponent.js +2 -2
- package/lib/module/web/createUnistylesComponent.js.map +1 -1
- package/lib/module/web/listener/listenToDependencies.js +2 -3
- package/lib/module/web/listener/listenToDependencies.js.map +1 -1
- package/lib/module/web/registry.js +22 -0
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +1 -2
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/typescript/example/App.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +3 -0
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/__tests__/dependencies.spec.js +5 -5
- package/plugin/__tests__/ref.spec.js +119 -41
- package/plugin/__tests__/stylesheet.spec.js +9 -9
- package/plugin/index.js +12 -1
- package/plugin/ref.js +20 -31
- package/plugin/style.js +33 -6
- package/src/specs/ShadowRegistry/index.ts +4 -38
- package/src/web/createUnistylesComponent.tsx +2 -4
- package/src/web/listener/listenToDependencies.ts +2 -7
- package/src/web/registry.ts +32 -0
- package/src/web/shadowRegistry.ts +1 -4
package/cxx/common/Constants.h
CHANGED
@@ -7,5 +7,6 @@ static const std::string ADD_VARIANTS_FN = "useVariants";
|
|
7
7
|
static const std::string STYLE_DEPENDENCIES = "uni__dependencies";
|
8
8
|
static const std::string STYLE_VARIANTS = "uni__variants";
|
9
9
|
static const std::string WEB_STYLE_KEY = "_web";
|
10
|
+
static const std::string EXOTIC_STYLE_KEY = "_exotic";
|
10
11
|
|
11
12
|
}
|
package/cxx/common/Helpers.h
CHANGED
@@ -20,11 +20,11 @@ inline void assertThat(jsi::Runtime& rt, bool condition, const std::string& mess
|
|
20
20
|
inline void enumerateJSIObject(jsi::Runtime& rt, const jsi::Object& obj, std::function<void(const std::string& propertyName, jsi::Value& propertyValue)> callback) {
|
21
21
|
jsi::Array propertyNames = obj.getPropertyNames(rt);
|
22
22
|
size_t length = propertyNames.size(rt);
|
23
|
-
|
23
|
+
|
24
24
|
for (size_t i = 0; i < length; i++) {
|
25
25
|
auto propertyName = propertyNames.getValueAtIndex(rt, i).asString(rt).utf8(rt);
|
26
26
|
auto propertyValue = obj.getProperty(rt, propertyName.c_str());
|
27
|
-
|
27
|
+
|
28
28
|
callback(propertyName, propertyValue);
|
29
29
|
}
|
30
30
|
}
|
@@ -32,15 +32,15 @@ inline void enumerateJSIObject(jsi::Runtime& rt, const jsi::Object& obj, std::fu
|
|
32
32
|
template<typename PropertyType>
|
33
33
|
inline bool vecContainsKeys(std::vector<PropertyType>& vec, std::vector<PropertyType>&& keys) {
|
34
34
|
std::unordered_set<PropertyType> availableKeys(keys.begin(), keys.end());
|
35
|
-
|
35
|
+
|
36
36
|
for (const auto& key : vec) {
|
37
37
|
availableKeys.erase(key);
|
38
|
-
|
38
|
+
|
39
39
|
if (availableKeys.empty()) {
|
40
40
|
return true;
|
41
41
|
}
|
42
42
|
}
|
43
|
-
|
43
|
+
|
44
44
|
return false;
|
45
45
|
}
|
46
46
|
|
@@ -118,11 +118,11 @@ inline Variants variantsToPairs(jsi::Runtime& rt, jsi::Object&& variants) {
|
|
118
118
|
|
119
119
|
inline jsi::Object variantsToValue(jsi::Runtime& rt, Variants& variants) {
|
120
120
|
jsi::Object rawVariants = jsi::Object(rt);
|
121
|
-
|
121
|
+
|
122
122
|
std::for_each(variants.begin(), variants.end(), [&](std::pair<std::string, std::string>& pair){
|
123
123
|
rawVariants.setProperty(rt, pair.first.c_str(), jsi::String::createFromUtf8(rt, pair.second));
|
124
124
|
});
|
125
|
-
|
125
|
+
|
126
126
|
return rawVariants;
|
127
127
|
}
|
128
128
|
|
package/cxx/core/HostStyle.cpp
CHANGED
@@ -28,7 +28,7 @@ jsi::Value HostStyle::get(jsi::Runtime& rt, const jsi::PropNameID& propNameId) {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
if (this->_styleSheet->unistyles.contains(propertyName)) {
|
31
|
-
return valueFromUnistyle(rt, this->_styleSheet->unistyles[propertyName]);
|
31
|
+
return valueFromUnistyle(rt, this->_styleSheet->unistyles[propertyName], this->_styleSheet->tag);
|
32
32
|
}
|
33
33
|
|
34
34
|
if (propertyName == helpers::STYLE_VARIANTS) {
|
package/cxx/core/HostStyle.h
CHANGED
package/cxx/core/StyleSheet.h
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#include <jsi/jsi.h>
|
4
4
|
#include "Unistyle.h"
|
5
|
+
#include "UnistylesRegistry.h"
|
5
6
|
#include "Helpers.h"
|
6
7
|
#include "Constants.h"
|
7
8
|
|
@@ -16,23 +17,90 @@ struct UnistyleWrapper: public jsi::NativeState {
|
|
16
17
|
Unistyle::Shared unistyle;
|
17
18
|
};
|
18
19
|
|
19
|
-
inline static
|
20
|
-
|
20
|
+
inline static std::string generateStyleKey(std::string& key, int tag) {
|
21
|
+
return std::string("__unid_").append(std::to_string(tag)).append("_").append(key).c_str();
|
22
|
+
}
|
23
|
+
|
24
|
+
inline static Unistyle::Shared unistyleFromKey(jsi::Runtime& rt, const std::string& key) {
|
25
|
+
std::string prefix = "__unid_";
|
26
|
+
|
27
|
+
if (key.substr(0, prefix.length()) != prefix) {
|
28
|
+
return nullptr;
|
29
|
+
}
|
30
|
+
|
31
|
+
std::string remaining = key.substr(prefix.length());
|
32
|
+
|
33
|
+
size_t underscorePos = remaining.find('_');
|
34
|
+
|
35
|
+
if (underscorePos == std::string::npos) {
|
21
36
|
return nullptr;
|
22
37
|
}
|
23
38
|
|
24
|
-
|
39
|
+
std::string tagStr = remaining.substr(0, underscorePos);
|
40
|
+
|
41
|
+
auto& registry = UnistylesRegistry::get();
|
42
|
+
auto tag = std::stoi(tagStr);
|
43
|
+
auto styleKey = remaining.substr(underscorePos + 1);
|
44
|
+
|
45
|
+
return registry.findUnistyleFromKey(rt, styleKey, tag);
|
46
|
+
}
|
47
|
+
|
48
|
+
inline static Unistyle::Shared unistyleFromStaticStyleSheet(jsi::Runtime& rt, jsi::Object& value) {
|
49
|
+
auto exoticUnistyle = std::make_shared<Unistyle>(
|
50
|
+
UnistyleType::Object,
|
51
|
+
helpers::EXOTIC_STYLE_KEY,
|
52
|
+
value,
|
53
|
+
nullptr
|
54
|
+
);
|
55
|
+
|
56
|
+
exoticUnistyle->seal();
|
57
|
+
|
58
|
+
return exoticUnistyle;
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
inline static std::vector<Unistyle::Shared> unistylesFromNonExistentNativeState(jsi::Runtime& rt, jsi::Object& value) {
|
63
|
+
std::vector<Unistyle::Shared> foundUnistyles{};
|
64
|
+
|
65
|
+
helpers::enumerateJSIObject(rt, value, [&](const std::string& key, jsi::Value& value){
|
66
|
+
auto maybeUnistyle = unistyleFromKey(rt, key);
|
67
|
+
|
68
|
+
if (maybeUnistyle != nullptr) {
|
69
|
+
foundUnistyles.emplace_back(maybeUnistyle);
|
70
|
+
}
|
71
|
+
});
|
72
|
+
|
73
|
+
if (foundUnistyles.size() == 0) {
|
74
|
+
return {unistyleFromStaticStyleSheet(rt, value)};
|
75
|
+
}
|
76
|
+
|
77
|
+
return foundUnistyles;
|
25
78
|
}
|
26
79
|
|
27
|
-
inline static
|
80
|
+
inline static std::vector<Unistyle::Shared> unistyleFromValue(jsi::Runtime& rt, const jsi::Value& value) {
|
81
|
+
if (value.isNull()) {
|
82
|
+
return {};
|
83
|
+
}
|
84
|
+
|
85
|
+
auto obj = value.getObject(rt);
|
86
|
+
|
87
|
+
// possible if user used React Native styles or inline styles or did spread styles
|
88
|
+
if (!obj.hasNativeState(rt)) {
|
89
|
+
return unistylesFromNonExistentNativeState(rt, obj);
|
90
|
+
}
|
91
|
+
|
92
|
+
return {value.getObject(rt).getNativeState<UnistyleWrapper>(rt)->unistyle};
|
93
|
+
}
|
94
|
+
|
95
|
+
inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, int tag) {
|
28
96
|
auto wrappedUnistyle = std::make_shared<UnistyleWrapper>(unistyle);
|
29
97
|
|
30
98
|
if (unistyle->type == UnistyleType::Object) {
|
31
99
|
jsi::Object obj = jsi::Object(rt);
|
32
|
-
|
100
|
+
|
33
101
|
obj.setNativeState(rt, std::move(wrappedUnistyle));
|
34
|
-
|
35
|
-
|
102
|
+
obj.setProperty(rt, std::string("__unid_").append(std::to_string(tag)).append("_").append(unistyle->styleKey).c_str(), jsi::Value::undefined());
|
103
|
+
|
36
104
|
helpers::mergeJSIObjects(rt, obj, unistyle->parsedStyle.value());
|
37
105
|
|
38
106
|
return obj;
|
@@ -42,8 +110,8 @@ inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, Unistyle::Shared un
|
|
42
110
|
auto hostFn = jsi::Value(rt, unistyleFn->proxiedFunction.value()).asObject(rt).asFunction(rt);
|
43
111
|
|
44
112
|
hostFn.setNativeState(rt, std::move(wrappedUnistyle));
|
45
|
-
|
46
|
-
|
113
|
+
hostFn.setProperty(rt, std::string("__unid_").append(std::to_string(tag)).append("_").append(unistyleFn->styleKey).c_str(), jsi::Value::undefined());
|
114
|
+
|
47
115
|
return std::move(hostFn);
|
48
116
|
}
|
49
117
|
|
@@ -74,7 +74,7 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
|
|
74
74
|
void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
75
75
|
jsi::Runtime& rt,
|
76
76
|
const ShadowNodeFamily* shadowNodeFamily,
|
77
|
-
|
77
|
+
std::vector<core::Unistyle::Shared>& unistyles,
|
78
78
|
Variants& variants,
|
79
79
|
std::vector<folly::dynamic>& arguments
|
80
80
|
) {
|
@@ -82,22 +82,23 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
|
82
82
|
this->_shadowRegistry[&rt][shadowNodeFamily] = {};
|
83
83
|
}
|
84
84
|
|
85
|
-
|
85
|
+
std::for_each(unistyles.begin(), unistyles.end(), [&, this](Unistyle::Shared unistyle){
|
86
|
+
this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
|
87
|
+
});
|
86
88
|
}
|
87
89
|
|
88
|
-
void core::UnistylesRegistry::
|
89
|
-
|
90
|
-
|
91
|
-
const core::Unistyle::Shared unistyle
|
92
|
-
) {
|
93
|
-
auto& unistylesVec = this->_shadowRegistry[&rt][shadowNodeFamily];
|
94
|
-
auto it = std::find_if(unistylesVec.begin(), unistylesVec.end(), [unistyle](std::shared_ptr<UnistyleData> unistyleData){
|
95
|
-
return unistyleData->unistyle == unistyle;
|
96
|
-
});
|
90
|
+
void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily) {
|
91
|
+
this->_shadowRegistry[&rt][shadowNodeFamily].clear();
|
92
|
+
}
|
97
93
|
|
98
|
-
|
99
|
-
|
94
|
+
core::Unistyle::Shared core::UnistylesRegistry::findUnistyleFromKey(jsi::Runtime& rt, std::string styleKey, int tag) {
|
95
|
+
auto targetStyleSheet = this->_styleSheetRegistry[&rt][tag];
|
96
|
+
|
97
|
+
if (targetStyleSheet == nullptr) {
|
98
|
+
return nullptr;
|
100
99
|
}
|
100
|
+
|
101
|
+
return targetStyleSheet.get()->unistyles[styleKey];
|
101
102
|
}
|
102
103
|
|
103
104
|
std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Runtime& rt, int unid, core::StyleSheetType type, jsi::Object&& rawValue) {
|
@@ -36,10 +36,11 @@ struct UnistylesRegistry: public StyleSheetRegistry {
|
|
36
36
|
|
37
37
|
UnistylesState& getState(jsi::Runtime& rt);
|
38
38
|
void createState(jsi::Runtime& rt);
|
39
|
-
void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*,
|
40
|
-
void
|
39
|
+
void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<core::Unistyle::Shared>& unistyles, Variants& variants, std::vector<folly::dynamic>&);
|
40
|
+
void unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily*);
|
41
41
|
std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
|
42
42
|
DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
|
43
|
+
Unistyle::Shared findUnistyleFromKey(jsi::Runtime& rt, std::string styleKey, int tag);
|
43
44
|
DependencyMap buildDependencyMap(jsi::Runtime& rt);
|
44
45
|
shadow::ShadowTrafficController trafficController{};
|
45
46
|
|
@@ -7,27 +7,26 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
|
|
7
7
|
helpers::assertThat(rt, count == 4, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 4 arguments.");
|
8
8
|
|
9
9
|
ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
|
10
|
-
core::Unistyle::Shared
|
10
|
+
std::vector<core::Unistyle::Shared> unistyleWrappers = core::unistyleFromValue(rt, args[1]);
|
11
11
|
core::Variants variants = helpers::variantsToPairs(rt, args[2].asObject(rt));
|
12
12
|
auto rawArguments = args[3].asObject(rt).asArray(rt);
|
13
13
|
std::vector<folly::dynamic> arguments = helpers::parseDynamicFunctionArguments(rt, rawArguments);
|
14
14
|
|
15
15
|
auto& registry = core::UnistylesRegistry::get();
|
16
16
|
|
17
|
-
registry.linkShadowNodeWithUnistyle(rt, &shadowNodeWrapper->getFamily(),
|
17
|
+
registry.linkShadowNodeWithUnistyle(rt, &shadowNodeWrapper->getFamily(), unistyleWrappers, variants, arguments);
|
18
18
|
|
19
19
|
return jsi::Value::undefined();
|
20
20
|
}
|
21
21
|
|
22
22
|
jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
23
|
-
helpers::assertThat(rt, count ==
|
23
|
+
helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1 arguments.");
|
24
24
|
|
25
25
|
ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
|
26
|
-
core::Unistyle::Shared unistyleWrapper = core::unistyleFromValue(rt, args[1]);
|
27
26
|
|
28
27
|
auto& registry = core::UnistylesRegistry::get();
|
29
28
|
|
30
|
-
registry.
|
29
|
+
registry.unlinkShadowNodeWithUnistyles(rt, &shadowNodeWrapper->getFamily());
|
31
30
|
|
32
31
|
return jsi::Value::undefined();
|
33
32
|
}
|
package/cxx/parser/Parser.cpp
CHANGED
@@ -105,13 +105,21 @@ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, Dependenc
|
|
105
105
|
for (auto& [shadowNode, unistyles] : dependencyMap) {
|
106
106
|
auto styleSheet = unistyles.begin()->get()->unistyle->parent;
|
107
107
|
|
108
|
-
|
108
|
+
// stylesheet may be optional for exotic unistyles
|
109
|
+
if (styleSheet != nullptr && !parsedStyleSheets.contains(styleSheet)) {
|
109
110
|
parsedStyleSheets.emplace(styleSheet, this->unwrapStyleSheet(rt, styleSheet));
|
110
111
|
}
|
111
112
|
|
112
113
|
for (auto& unistyleData : unistyles) {
|
113
114
|
auto& unistyle = unistyleData->unistyle;
|
114
115
|
|
116
|
+
// for RN styles or inline styles, compute styles only once
|
117
|
+
if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY.c_str() && !unistyleData->parsedStyle.has_value()) {
|
118
|
+
unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
|
119
|
+
|
120
|
+
continue;
|
121
|
+
}
|
122
|
+
|
115
123
|
// StyleSheet might have styles that are not affected
|
116
124
|
if (!parsedStyleSheets[styleSheet].asObject(rt).hasProperty(rt, unistyle->styleKey.c_str())) {
|
117
125
|
continue;
|
@@ -625,7 +633,7 @@ RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const s
|
|
625
633
|
// todo this something happens with large dataset, debug it
|
626
634
|
continue;
|
627
635
|
}
|
628
|
-
|
636
|
+
|
629
637
|
helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
|
630
638
|
if (this->isColor(propertyName)) {
|
631
639
|
return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
|
@@ -19,45 +19,13 @@ HybridShadowRegistry.add = (handle, style, variants, args) => {
|
|
19
19
|
if (!handle || !style) {
|
20
20
|
return;
|
21
21
|
}
|
22
|
-
|
23
|
-
// at this point unistyle can be only object or dynamic function
|
24
|
-
if (typeof style !== 'object' && typeof style !== 'function') {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
if (!style.__unid) {
|
28
|
-
console.warn(`Unistyles: Style is not bound!
|
29
|
-
|
30
|
-
Potential reasons:
|
31
|
-
a) You created a new Expo or React Native project that references StyleSheet from React Native
|
32
|
-
b) You used the spread operator on a Unistyle style outside of a JSX component
|
33
|
-
c) You're mixing StyleSheet styles from React Native with Unistyles
|
34
|
-
|
35
|
-
a) For new projects
|
36
|
-
If you're using a freshly generated project, replace StyleSheet imports from React Native with Unistyles:
|
37
|
-
|
38
|
-
- import { StyleSheet } from 'react-native'
|
39
|
-
+ import { StyleSheet } from 'react-native-unistyles'
|
40
|
-
|
41
|
-
b) Merging styles
|
42
|
-
If you need to merge styles, do it within the style prop of your JSX component:
|
43
|
-
|
44
|
-
style={{...styles.container, ...styles.otherProp}}
|
45
|
-
or
|
46
|
-
style={[styles.container, styles.otherProp]}
|
47
|
-
|
48
|
-
Copying a Unistyle style outside of a JSX element will remove its internal C++ state, leading to unexpected behavior.
|
49
|
-
|
50
|
-
c) Mixing styles
|
51
|
-
If you're mixing React Native and Unistyle StyleSheet styles, move your static styles into Unistyles to avoid conflicts.\n`);
|
52
|
-
return;
|
53
|
-
}
|
54
22
|
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
55
23
|
};
|
56
|
-
HybridShadowRegistry.remove =
|
57
|
-
if (!handle
|
24
|
+
HybridShadowRegistry.remove = handle => {
|
25
|
+
if (!handle) {
|
58
26
|
return;
|
59
27
|
}
|
60
|
-
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle)
|
28
|
+
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
|
61
29
|
};
|
62
30
|
const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = HybridShadowRegistry;
|
63
31
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","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;EACA,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAE;IACnB;EACJ;EAEAZ,oBAAoB,CAACe,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDd,oBAAoB,CAACgB,MAAM,GAAGZ,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAJ,oBAAoB,CAACiB,MAAM,CAACd,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQM,MAAMc,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGlB,oBAA4D","ignoreList":[]}
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.createUnistylesComponent = void 0;
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
8
8
|
var _utils = require("./utils");
|
9
|
-
var _runtime = require("./runtime");
|
10
9
|
var _variants = require("./variants");
|
11
10
|
var _listener = require("./listener");
|
11
|
+
var _registry = require("./registry");
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
@@ -23,7 +23,7 @@ const getStyles = value => {
|
|
23
23
|
__uni__args = [],
|
24
24
|
__uni__variants
|
25
25
|
}) => {
|
26
|
-
const newComputedStylesheet =
|
26
|
+
const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
|
27
27
|
const style = newComputedStylesheet[__uni__key];
|
28
28
|
const resultHidden = typeof style === 'function' ? style(...__uni__args) : style;
|
29
29
|
const result = (0, _utils.extractHiddenProperties)(resultHidden);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_utils","
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_variants","_listener","_registry","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getStyles","value","secrets","extractSecrets","length","undefined","reduce","acc","__uni__stylesheet","__uni__key","__uni__args","__uni__variants","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","style","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","resultWithVariants","createUnistylesComponent","Component","props","passedStyles","setStyle","useState","useEffect","newStyles","dependencies","dispose","UnistylesListener","addListeners","jsx","exports"],"sourceRoot":"../../../src","sources":["web/createUnistylesComponent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAA8C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAA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
|
5
5
|
});
|
6
6
|
exports.listenToDependencies = void 0;
|
7
7
|
var _listener = require("./listener");
|
8
|
-
var _runtime = require("../runtime");
|
9
8
|
var _utils = require("../utils");
|
10
9
|
var _registry = require("../registry");
|
11
10
|
const listenToDependencies = ({
|
@@ -15,7 +14,7 @@ const listenToDependencies = ({
|
|
15
14
|
args = [],
|
16
15
|
stylesheet
|
17
16
|
}) => {
|
18
|
-
const newComputedStylesheet =
|
17
|
+
const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(stylesheet);
|
19
18
|
const _value = (0, _utils.keyInObject)(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined;
|
20
19
|
if (!_value) {
|
21
20
|
return;
|
@@ -26,7 +25,7 @@ const listenToDependencies = ({
|
|
26
25
|
return;
|
27
26
|
}
|
28
27
|
return _listener.UnistylesListener.addListeners(dependencies, () => {
|
29
|
-
const newComputedStylesheet =
|
28
|
+
const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(stylesheet);
|
30
29
|
if (!(0, _utils.keyInObject)(newComputedStylesheet, key)) {
|
31
30
|
return;
|
32
31
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_listener","require","
|
1
|
+
{"version":3,"names":["_listener","require","_utils","_registry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","_value","keyInObject","undefined","value","dependencies","length","UnistylesListener","addListeners","result","updateStyles","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAUO,MAAMG,oBAAoB,GAAGA,CAAC;EAAEC,GAAG;EAAEC,SAAS;EAAEC,SAAS;EAAEC,IAAI,GAAG,EAAE;EAAEC;AAAsC,CAAC,KAAK;EACrH,MAAMC,qBAAqB,GAAGC,2BAAiB,CAACC,qBAAqB,CAACH,UAAU,CAAC;EACjF,MAAMI,MAAM,GAAG,IAAAC,kBAAW,EAACJ,qBAAqB,EAAEL,GAAG,CAAC,GAAGK,qBAAqB,CAACL,GAAG,CAAC,GAAGU,SAAS;EAE/F,IAAI,CAACF,MAAM,EAAE;IACT;EACJ;EAEA,MAAMG,KAAK,GAAG,OAAOH,MAAM,KAAK,UAAU,GAAGA,MAAM,CAAC,GAAGL,IAAI,CAAC,GAAGK,MAAM;EACrE,MAAMI,YAAY,GAAI,mBAAmB,IAAID,KAAK,GAAGA,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAgC;EAElH,IAAIC,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3B;EACJ;EAEA,OAAOC,2BAAiB,CAACC,YAAY,CAACH,YAAY,EAAE,MAAM;IACtD,MAAMP,qBAAqB,GAAGC,2BAAiB,CAACC,qBAAqB,CAACH,UAAU,CAAC;IAEjF,IAAI,CAAC,IAAAK,kBAAW,EAACJ,qBAAqB,EAAEL,GAAG,CAAC,EAAE;MAC1C;IACJ;IAEA,MAAMW,KAAK,GAAGN,qBAAqB,CAACL,GAAG,CAAE;IACzC,MAAMgB,MAAM,GAAG,OAAOL,KAAK,KAAK,UAAU,GACpCA,KAAK,CAAC,GAAGR,IAAI,CAAC,GACdQ,KAAK;IAEXL,2BAAiB,CAACW,YAAY,CAACf,SAAS,EAAEc,MAAM,EAAEf,SAAS,CAAC;EAChE,CAAC,CAAC;AACN,CAAC;AAAAiB,OAAA,CAAAnB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
@@ -6,7 +6,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.UnistylesRegistry = void 0;
|
7
7
|
var _typestyle = require("typestyle");
|
8
8
|
var _convert = require("./convert");
|
9
|
+
var _runtime = require("./runtime");
|
10
|
+
var _utils = require("./utils");
|
11
|
+
var _listener = require("./listener");
|
9
12
|
class UnistylesRegistryBuilder {
|
13
|
+
stylesheets = new Map();
|
14
|
+
getComputedStylesheet = stylesheet => {
|
15
|
+
if (typeof stylesheet !== 'function') {
|
16
|
+
return stylesheet;
|
17
|
+
}
|
18
|
+
const computedStylesheet = this.stylesheets.get(stylesheet);
|
19
|
+
if (computedStylesheet) {
|
20
|
+
return computedStylesheet;
|
21
|
+
}
|
22
|
+
const createdStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
|
23
|
+
// @ts-expect-error uni__dependencies is hidden
|
24
|
+
const dependencies = Object.values(createdStylesheet).flatMap(value => (0, _utils.keyInObject)(value, 'uni__dependencies') ? value.uni__dependencies : []);
|
25
|
+
_listener.UnistylesListener.addListeners(dependencies, () => {
|
26
|
+
const newComputedStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
|
27
|
+
this.stylesheets.set(stylesheet, newComputedStylesheet);
|
28
|
+
});
|
29
|
+
this.stylesheets.set(stylesheet, createdStylesheet);
|
30
|
+
return createdStylesheet;
|
31
|
+
};
|
10
32
|
createStyles = (stylesheet, key) => {
|
11
33
|
const unistyles = (0, _typestyle.createTypeStyle)();
|
12
34
|
const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_typestyle","require","_convert","UnistylesRegistryBuilder","
|
1
|
+
{"version":3,"names":["_typestyle","require","_convert","_runtime","_utils","_listener","UnistylesRegistryBuilder","stylesheets","Map","getComputedStylesheet","stylesheet","computedStylesheet","get","createdStylesheet","UnistylesRuntime","theme","miniRuntime","dependencies","Object","values","flatMap","value","keyInObject","uni__dependencies","UnistylesListener","addListeners","newComputedStylesheet","set","createStyles","key","unistyles","createTypeStyle","typestyleStylesheet","convertToTypeStyle","className","style","$debugName","Math","random","toString","slice","updateStyles","reinit","cssRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC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BAAkB,EAACvB,UAAU,CAAC;IAE1D,MAAMwB,SAAS,GAAGJ,SAAS,CAACK,KAAK,CAAC;MAC9BC,UAAU,EAAE,GAAGP,GAAG,IAAIQ,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC;IAC9D,CAAC,EAAER,mBAAmB,CAAC;IAEvB,OAAO;MACHE,SAAS;MACTJ;IACJ,CAAC;EACL,CAAC;EAEDW,YAAY,GAAGA,CAACX,SAAoB,EAAEpB,UAA2B,EAAEwB,SAAiB,KAAK;IACrF,MAAMF,mBAAmB,GAAG,IAAAC,2BAAkB,EAACvB,UAAU,CAAC;IAE1DoB,SAAS,CAACY,MAAM,CAAC,CAAC;IAClBZ,SAAS,CAACa,OAAO,CAAC,IAAIT,SAAS,EAAE,EAAEF,mBAAmB,CAAC;EAC3D,CAAC;AACL;AAEO,MAAMY,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAItC,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.UnistylesShadowRegistry = void 0;
|
7
7
|
var _listener = require("./listener");
|
8
8
|
var _registry = require("./registry");
|
9
|
-
var _runtime = require("./runtime");
|
10
9
|
var _utils = require("./utils");
|
11
10
|
var _variants2 = require("./variants");
|
12
11
|
class UnistylesShadowRegistryBuilder {
|
@@ -66,7 +65,7 @@ class UnistylesShadowRegistryBuilder {
|
|
66
65
|
__uni__variants,
|
67
66
|
__uni__args = []
|
68
67
|
} = secret;
|
69
|
-
const newComputedStylesheet =
|
68
|
+
const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
|
70
69
|
const style = newComputedStylesheet[__uni__key];
|
71
70
|
const args = _args ?? __uni__args;
|
72
71
|
const resultHidden = typeof style === 'function' ? style(...args) : style;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_listener","require","_registry","
|
1
|
+
{"version":3,"names":["_listener","require","_registry","_utils","_variants2","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","webUnistylesMap","createDoubleMap","disposeMap","stylesMap","add","ref","_style","_variants","_args","Array","isArray","forEach","style","Object","keys","some","key","startsWith","secrets","extractSecrets","__uni__refs","isInDocument","remove","HTMLElement","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","args","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","length","resultWithVariants","storedWebUnistyle","get","webUnistyle","createStyles","set","listenToDependencies","stylesheet","className","unistyles","styleTag","document","createElement","additionalClasses","_web","_classNames","classList","setStylesTarget","head","appendChild","updateStyles","delete","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAMA,MAAMI,8BAA8B,CAAC;EACjC;EACAC,IAAI,GAAG,yBAAyB;EAChCC,MAAM,GAAG,KAAK;EACdC,MAAM,GAAGA,CAAA,KAAM,IAAI;EACnBC,QAAQ,GAAGA,CAAA,KAAM,yBAAyB;EAC1CC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;EAClB;;EAEiBC,eAAe,GAAG,IAAAC,sBAAe,EAAmC,CAAC;EACrEC,UAAU,GAAG,IAAAD,sBAAe,EAAgD,CAAC;EAC7EE,SAAS,GAAG,IAAAF,sBAAe,EAAwC,CAAC;EAErFG,GAAG,GAAGA,CAACC,GAAQ,EAAEC,MAA6B,EAAEC,SAA+B,EAAEC,KAAkB,KAAK;IACpG;IACA,IAAI,CAACF,MAAM,EAAE;MACT;IACJ;;IAEA;IACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;MACv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CAAC","ignoreList":[]}
|
@@ -15,45 +15,13 @@ HybridShadowRegistry.add = (handle, style, variants, args) => {
|
|
15
15
|
if (!handle || !style) {
|
16
16
|
return;
|
17
17
|
}
|
18
|
-
|
19
|
-
// at this point unistyle can be only object or dynamic function
|
20
|
-
if (typeof style !== 'object' && typeof style !== 'function') {
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
if (!style.__unid) {
|
24
|
-
console.warn(`Unistyles: Style is not bound!
|
25
|
-
|
26
|
-
Potential reasons:
|
27
|
-
a) You created a new Expo or React Native project that references StyleSheet from React Native
|
28
|
-
b) You used the spread operator on a Unistyle style outside of a JSX component
|
29
|
-
c) You're mixing StyleSheet styles from React Native with Unistyles
|
30
|
-
|
31
|
-
a) For new projects
|
32
|
-
If you're using a freshly generated project, replace StyleSheet imports from React Native with Unistyles:
|
33
|
-
|
34
|
-
- import { StyleSheet } from 'react-native'
|
35
|
-
+ import { StyleSheet } from 'react-native-unistyles'
|
36
|
-
|
37
|
-
b) Merging styles
|
38
|
-
If you need to merge styles, do it within the style prop of your JSX component:
|
39
|
-
|
40
|
-
style={{...styles.container, ...styles.otherProp}}
|
41
|
-
or
|
42
|
-
style={[styles.container, styles.otherProp]}
|
43
|
-
|
44
|
-
Copying a Unistyle style outside of a JSX element will remove its internal C++ state, leading to unexpected behavior.
|
45
|
-
|
46
|
-
c) Mixing styles
|
47
|
-
If you're mixing React Native and Unistyle StyleSheet styles, move your static styles into Unistyles to avoid conflicts.\n`);
|
48
|
-
return;
|
49
|
-
}
|
50
18
|
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
51
19
|
};
|
52
|
-
HybridShadowRegistry.remove =
|
53
|
-
if (!handle
|
20
|
+
HybridShadowRegistry.remove = handle => {
|
21
|
+
if (!handle) {
|
54
22
|
return;
|
55
23
|
}
|
56
|
-
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle)
|
24
|
+
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
|
57
25
|
};
|
58
26
|
export const UnistylesShadowRegistry = HybridShadowRegistry;
|
59
27
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","
|
1
|
+
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,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;AAEDJ,oBAAoB,CAACU,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D;EACA,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAE;IACnB;EACJ;EAEAX,oBAAoB,CAACc,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDb,oBAAoB,CAACe,MAAM,GAAGZ,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAH,oBAAoB,CAACgB,MAAM,CAACd,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQD,OAAO,MAAMc,uBAAuB,GAAGjB,oBAA4D","ignoreList":[]}
|