react-native-unistyles 3.0.0-alpha.30 → 3.0.0-alpha.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/cxx/core/UnistylesCommitHook.cpp +9 -11
  2. package/cxx/core/UnistylesCommitHook.h +1 -2
  3. package/cxx/core/UnistylesMountHook.cpp +5 -3
  4. package/cxx/core/UnistylesMountHook.h +2 -1
  5. package/cxx/core/UnistylesRegistry.cpp +23 -4
  6. package/cxx/core/UnistylesRegistry.h +1 -1
  7. package/cxx/hybridObjects/HybridStyleSheet.cpp +6 -14
  8. package/cxx/hybridObjects/HybridStyleSheet.h +0 -1
  9. package/cxx/parser/Parser.cpp +51 -13
  10. package/cxx/parser/Parser.h +2 -1
  11. package/cxx/shadowTree/ShadowLeafUpdate.h +2 -1
  12. package/cxx/shadowTree/ShadowTrafficController.h +48 -15
  13. package/cxx/shadowTree/ShadowTreeManager.cpp +5 -6
  14. package/cxx/shadowTree/ShadowTreeManager.h +1 -1
  15. package/ios/UnistylesModuleOnLoad.mm +1 -3
  16. package/lib/commonjs/common.js.map +1 -1
  17. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -2
  18. package/lib/commonjs/core/useTheme.js.map +1 -2
  19. package/lib/commonjs/global.js +2 -1
  20. package/lib/commonjs/global.js.map +1 -1
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/mq.js +4 -1
  23. package/lib/commonjs/mq.js.map +1 -2
  24. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +2 -1
  25. package/lib/commonjs/specs/NativePlatform/index.js.map +1 -1
  26. package/lib/commonjs/specs/ShadowRegistry/types.js +2 -1
  27. package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
  28. package/lib/commonjs/specs/StatusBar/index.js.map +1 -2
  29. package/lib/commonjs/types/accessibility.js +10 -10
  30. package/lib/commonjs/types/accessibility.js.map +2 -1
  31. package/lib/commonjs/types/core.js.map +1 -1
  32. package/lib/commonjs/types/index.js.map +1 -2
  33. package/lib/commonjs/web/convert/shadow.js +1 -5
  34. package/lib/commonjs/web/convert/types.js.map +1 -1
  35. package/lib/commonjs/web/index.js.map +1 -2
  36. package/lib/commonjs/web/registry.js +3 -1
  37. package/lib/commonjs/web/registry.js.map +1 -2
  38. package/lib/commonjs/web/runtime.js.map +1 -2
  39. package/lib/commonjs/web/state.js +5 -1
  40. package/lib/commonjs/web/state.js.map +1 -2
  41. package/lib/commonjs/web/utils/common.js +3 -1
  42. package/lib/commonjs/web/utils/common.js.map +1 -2
  43. package/lib/commonjs/web/utils/index.js.map +1 -1
  44. package/lib/commonjs/web/utils/unistyle.js.map +1 -2
  45. package/lib/module/common.js.map +1 -1
  46. package/lib/module/core/createUnistylesComponent.js +4 -3
  47. package/lib/module/core/createUnistylesComponent.js.map +1 -2
  48. package/lib/module/core/useBreakpoint.js.map +1 -1
  49. package/lib/module/core/useBreakpoint.native.js.map +1 -2
  50. package/lib/module/core/useTheme.native.js.map +1 -2
  51. package/lib/module/mq.js +4 -1
  52. package/lib/module/mq.js.map +1 -2
  53. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +5 -6
  54. package/lib/module/specs/NativePlatform/index.js.map +1 -1
  55. package/lib/module/specs/NavigtionBar/index.js.map +1 -2
  56. package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +2 -1
  57. package/lib/module/specs/ShadowRegistry/index.js.map +1 -2
  58. package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +2 -1
  59. package/lib/module/specs/StatusBar/index.js.map +1 -1
  60. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
  61. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -0
  62. package/lib/module/specs/UnistylesRuntime/index.js.map +2 -1
  63. package/lib/module/specs/index.web.js.map +1 -2
  64. package/lib/module/specs/types.js +10 -10
  65. package/lib/module/specs/types.js.map +2 -1
  66. package/lib/module/types/accessibility.js +10 -10
  67. package/lib/module/types/accessibility.js.map +1 -2
  68. package/lib/module/types/common.js +3 -1
  69. package/lib/module/types/common.js.map +1 -2
  70. package/lib/module/types/index.js.map +1 -2
  71. package/lib/module/types/stylesheet.js +2 -2
  72. package/lib/module/types/variants.js.map +1 -2
  73. package/lib/module/web/convert/boxShadow.js +1 -4
  74. package/lib/module/web/convert/boxShadow.js.map +2 -1
  75. package/lib/module/web/convert/index.js.map +1 -2
  76. package/lib/module/web/convert/shadow.js +5 -1
  77. package/lib/module/web/convert/textShadow.js +1 -4
  78. package/lib/module/web/convert/transform.js.map +2 -1
  79. package/lib/module/web/convert/types.js.map +1 -1
  80. package/lib/module/web/index.js +2 -1
  81. package/lib/module/web/index.js.map +1 -2
  82. package/lib/module/web/listener.js.map +1 -2
  83. package/lib/module/web/mock.js.map +1 -2
  84. package/lib/module/web/registry.js +1 -3
  85. package/lib/module/web/registry.js.map +2 -1
  86. package/lib/module/web/runtime.js.map +2 -1
  87. package/lib/module/web/shadowRegistry.js +1 -9
  88. package/lib/module/web/state.js +5 -1
  89. package/lib/module/web/state.js.map +1 -2
  90. package/lib/module/web/utils/common.js +1 -3
  91. package/lib/module/web/utils/common.js.map +2 -1
  92. package/lib/module/web/utils/index.js.map +1 -1
  93. package/lib/module/web/variants/getVariants.js.map +1 -2
  94. package/package.json +1 -1
@@ -18,7 +18,7 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
18
18
  RootShadowNode::Unshared rootNode = newRootShadowNode;
19
19
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootShadowNode);
20
20
 
21
- // skip only unistyles commits
21
+ // this is Unistyles commit, we don't need to override it
22
22
  if (unistylesRootNode->hasUnistylesCommitTrait()) {
23
23
  unistylesRootNode->removeUnistylesCommitTrait();
24
24
  unistylesRootNode->addUnistylesMountTrait();
@@ -26,26 +26,24 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
26
26
  return newRootShadowNode;
27
27
  }
28
28
 
29
+ // this is React Native / Reanimated commit
30
+ // merge Unistyles updates before it completes
29
31
  auto& registry = core::UnistylesRegistry::get();
32
+ auto& shadowLeafUpdates = registry.trafficController.getUpdates();
30
33
 
31
- if (!registry.trafficController.hasUnistylesCommit()) {
32
- return newRootShadowNode;
33
- }
34
-
35
- auto& shadowLeafUpdates = registry.trafficController._unistylesUpdates;
36
-
34
+ // oops, not updates from Unistyles yet, skip it!
37
35
  if (shadowLeafUpdates.size() == 0) {
38
36
  return newRootShadowNode;
39
37
  }
40
38
 
41
- // this is required, otherwise we end up with old shadow tree in mount hook
42
- registry.trafficController.stopUnistylesTraffic();
39
+ auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
43
40
 
44
- auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates[_rt]);
41
+ registry.trafficController.stopUnistylesTraffic();
45
42
 
43
+ // we have few updates, so merge it
46
44
  return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
47
45
  *rootNode,
48
- shadowLeafUpdates[_rt],
46
+ shadowLeafUpdates,
49
47
  affectedNodes
50
48
  ));
51
49
  }
@@ -10,7 +10,7 @@ namespace margelo::nitro::unistyles::core {
10
10
  using namespace facebook::react;
11
11
 
12
12
  struct UnistylesCommitHook : public UIManagerCommitHook {
13
- UnistylesCommitHook(std::shared_ptr<UIManager> uiManager, jsi::Runtime& rt) : _uiManager{uiManager}, _rt{&rt} {
13
+ UnistylesCommitHook(std::shared_ptr<UIManager> uiManager) : _uiManager{uiManager} {
14
14
  _uiManager->registerCommitHook(*this);
15
15
  }
16
16
 
@@ -22,7 +22,6 @@ struct UnistylesCommitHook : public UIManagerCommitHook {
22
22
 
23
23
  private:
24
24
  std::shared_ptr<UIManager> _uiManager;
25
- jsi::Runtime* _rt;
26
25
  };
27
26
 
28
27
  }
@@ -18,9 +18,11 @@ void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &
18
18
  return;
19
19
  }
20
20
 
21
- // React Native commit did mount
21
+ // this is React Native or Reanimated commit
22
+ // one more time merge Unistyles changes
22
23
  auto& registry = core::UnistylesRegistry::get();
23
24
 
24
- // so, resume Unistyles commits
25
- registry.trafficController.resumeUnistylesTraffic();
25
+ if (!registry.trafficController.shouldStop()) {
26
+ shadow::ShadowTreeManager::updateShadowTree(*_rt);
27
+ }
26
28
  }
@@ -9,7 +9,7 @@ namespace margelo::nitro::unistyles::core {
9
9
  using namespace facebook::react;
10
10
 
11
11
  struct UnistylesMountHook : public UIManagerMountHook {
12
- UnistylesMountHook(std::shared_ptr<UIManager> uiManager) : _uiManager{uiManager} {
12
+ UnistylesMountHook(std::shared_ptr<UIManager> uiManager, jsi::Runtime& rt) : _uiManager{uiManager}, _rt{&rt} {
13
13
  _uiManager->registerMountHook(*this);
14
14
  }
15
15
 
@@ -19,6 +19,7 @@ struct UnistylesMountHook : public UIManagerMountHook {
19
19
 
20
20
  private:
21
21
  std::shared_ptr<UIManager> _uiManager;
22
+ jsi::Runtime* _rt;
22
23
  };
23
24
 
24
25
  }
@@ -1,5 +1,6 @@
1
1
  #include "UnistylesRegistry.h"
2
2
  #include "UnistylesState.h"
3
+ #include "Parser.h"
3
4
 
4
5
  using namespace margelo::nitro::unistyles;
5
6
  using namespace facebook;
@@ -74,16 +75,29 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
74
75
  Variants& variants,
75
76
  std::vector<folly::dynamic>& arguments
76
77
  ) {
78
+ auto parser = parser::Parser(nullptr);
79
+ shadow::ShadowLeafUpdates updates;
80
+
77
81
  if (!this->_shadowRegistry[&rt].contains(shadowNodeFamily)) {
78
82
  this->_shadowRegistry[&rt][shadowNodeFamily] = {};
79
83
  }
80
84
 
81
85
  std::for_each(unistyles.begin(), unistyles.end(), [&, this](Unistyle::Shared unistyle){
82
86
  this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
87
+
88
+ // add or update node for shadow leaf updates
89
+ // dynamic functions are parsed later
90
+ if (unistyle->type == UnistyleType::Object) {
91
+ updates[shadowNodeFamily] = parser.parseUnistyleToShadowTreeStyles(rt, unistyle);
92
+ }
83
93
  });
94
+
95
+ this->trafficController.setUpdates(updates);
96
+ this->trafficController.resumeUnistylesTraffic();
84
97
  }
85
98
 
86
99
  void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily) {
100
+ this->trafficController.removeFromUpdates(shadowNodeFamily);
87
101
  this->_shadowRegistry[&rt].erase(shadowNodeFamily);
88
102
  }
89
103
 
@@ -134,16 +148,21 @@ core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt
134
148
  return dependencyMap;
135
149
  }
136
150
 
137
- core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt) {
138
- DependencyMap dependencyMap;
151
+ // called from proxied function only, we don't know host
152
+ // so we need to rebuild all instances as they may have different variants
153
+ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle) {
154
+ shadow::ShadowLeafUpdates updates;
155
+ auto parser = parser::Parser(nullptr);
139
156
 
140
157
  for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
141
158
  for (const auto& unistyleData : unistyles) {
142
- dependencyMap[family].emplace_back(unistyleData);
159
+ if (unistyleData->unistyle == unistyle) {
160
+ updates[family] = parser.parseStylesToShadowTreeStyles(rt, {unistyleData});
161
+ }
143
162
  }
144
163
  }
145
164
 
146
- return dependencyMap;
165
+ this->trafficController.setUpdates(updates);
147
166
  }
148
167
 
149
168
  std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyleSheetsToRefresh(jsi::Runtime& rt, bool themeDidChange, bool runtimeDidChange) {
@@ -42,7 +42,7 @@ struct UnistylesRegistry: public StyleSheetRegistry {
42
42
  std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
43
43
  DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
44
44
  Unistyle::Shared findUnistyleFromKey(jsi::Runtime& rt, std::string styleKey, int tag);
45
- DependencyMap buildDependencyMap(jsi::Runtime& rt);
45
+ void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle);
46
46
  shadow::ShadowTrafficController trafficController{};
47
47
 
48
48
  private:
@@ -230,8 +230,8 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
230
230
  }
231
231
 
232
232
  void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
233
- this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager, rt);
234
- this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager);
233
+ this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
234
+ this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, rt);
235
235
  }
236
236
 
237
237
  void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> unistylesDependencies) {
@@ -273,14 +273,10 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
273
273
  }
274
274
 
275
275
  parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, dependentStyleSheets);
276
-
277
- this->notifyJSListeners(dependencies);
278
-
279
- // this is required, otherwise shadow tree will ignore Unistyles commit
280
- registry.trafficController.setHasUnistylesCommit(true);
281
276
  parser.rebuildShadowLeafUpdates(dependencyMap);
282
-
283
- shadow::ShadowTreeManager::updateShadowTree(rt, registry.trafficController._unistylesUpdates[&rt]);
277
+
278
+ this->notifyJSListeners(dependencies);
279
+ shadow::ShadowTreeManager::updateShadowTree(rt);
284
280
  });
285
281
  }
286
282
 
@@ -304,12 +300,8 @@ void HybridStyleSheet::onImeChange() {
304
300
  }
305
301
 
306
302
  parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, {});
307
-
308
- // this is required, otherwise shadow tree will ignore Unistyles commit
309
- registry.trafficController.setHasUnistylesCommit(true);
310
303
  parser.rebuildShadowLeafUpdates(dependencyMap);
311
-
312
- shadow::ShadowTreeManager::updateShadowTree(rt, registry.trafficController._unistylesUpdates[&rt]);
304
+ shadow::ShadowTreeManager::updateShadowTree(rt);
313
305
  });
314
306
  }
315
307
 
@@ -9,7 +9,6 @@
9
9
  #include "Constants.h"
10
10
  #include "Breakpoints.h"
11
11
  #include "Parser.h"
12
- #include "ShadowTreeManager.h"
13
12
  #include "UnistylesCommitHook.h"
14
13
  #include "UnistylesMountHook.h"
15
14
 
@@ -120,23 +120,33 @@ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, Dependenc
120
120
  auto& unistyle = unistyleData->unistyle;
121
121
 
122
122
  // for RN styles or inline styles, compute styles only once
123
- if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY.c_str() && !unistyleData->parsedStyle.has_value()) {
124
- unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
123
+ if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY.c_str()) {
124
+ if (!unistyleData->parsedStyle.has_value()) {
125
+ unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
125
126
 
126
- if (!parsedUnistyles.contains(unistyle)) {
127
- parsedUnistyles.emplace(unistyle, true);
127
+ if (!parsedUnistyles.contains(unistyle)) {
128
+ parsedUnistyles.emplace(unistyle, true);
129
+ }
128
130
  }
129
131
 
130
132
  continue;
131
133
  }
132
134
 
135
+ // reference Unistyles StyleSheet as we may mix them for one style
136
+ auto unistyleStyleSheet = unistyle->parent;
137
+
138
+ // we may hit now other StyleSheets that are referenced from affected nodes
139
+ if (unistyleStyleSheet != nullptr && !parsedStyleSheets.contains(unistyleStyleSheet)) {
140
+ parsedStyleSheets.emplace(unistyleStyleSheet, this->unwrapStyleSheet(rt, unistyleStyleSheet));
141
+ }
142
+
133
143
  // StyleSheet might have styles that are not affected
134
- if (!parsedStyleSheets[styleSheet].asObject(rt).hasProperty(rt, unistyle->styleKey.c_str())) {
144
+ if (!parsedStyleSheets[unistyleStyleSheet].asObject(rt).hasProperty(rt, unistyle->styleKey.c_str())) {
135
145
  continue;
136
146
  }
137
147
 
138
- unistyle->rawValue = parsedStyleSheets[styleSheet].asObject(rt).getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
139
- this->rebuildUnistyle(rt, styleSheet, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
148
+ unistyle->rawValue = parsedStyleSheets[unistyleStyleSheet].asObject(rt).getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
149
+ this->rebuildUnistyle(rt, unistyleStyleSheet, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
140
150
  unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
141
151
 
142
152
  if (!parsedUnistyles.contains(unistyle)) {
@@ -207,7 +217,10 @@ void parser::Parser::rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap
207
217
  updates.emplace(shadowNode, std::move(rawProps));
208
218
  }
209
219
 
210
- registry.trafficController._unistylesUpdates[&rt] = std::move(updates);
220
+ registry.trafficController.setUpdates(updates);
221
+
222
+ // this is required, we need to indicate that there are new changes
223
+ registry.trafficController.resumeUnistylesTraffic();
211
224
  }
212
225
 
213
226
  // first level of StyleSheet, we can expect here different properties than on second level
@@ -359,6 +372,11 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
359
372
 
360
373
  helpers::defineHiddenProperty(rt, style, helpers::STYLE_DEPENDENCIES, helpers::dependenciesToJSIArray(rt, unistyle->dependencies));
361
374
 
375
+ // update shadow leaf updates to indicate newest changes
376
+ auto& registry = core::UnistylesRegistry::get();
377
+
378
+ registry.shadowLeafUpdateFromUnistyle(rt, unistyle);
379
+
362
380
  return style;
363
381
  });
364
382
  }
@@ -723,15 +741,15 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
723
741
  return parsedStyle;
724
742
  }
725
743
 
726
- // convert unistyles to RawValue with int colors
727
- RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
744
+ // convert unistyles to folly with int colors
745
+ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
728
746
  jsi::Object convertedStyles = jsi::Object(rt);
729
747
  auto& state = core::UnistylesRegistry::get().getState(rt);
730
748
 
731
749
  for (const auto& unistyleData : unistyles) {
750
+ // this can happen for exotic stylesheets
732
751
  if (!unistyleData->parsedStyle.has_value()) {
733
- // todo this something happens with large dataset, debug it
734
- continue;
752
+ return nullptr;
735
753
  }
736
754
 
737
755
  helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
@@ -743,7 +761,27 @@ RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const s
743
761
  });
744
762
  }
745
763
 
746
- return RawProps(rt, std::move(convertedStyles));
764
+ return jsi::dynamicFromValue(rt, std::move(convertedStyles));
765
+ }
766
+
767
+ folly::dynamic parser::Parser::parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle) {
768
+ jsi::Object convertedStyles = jsi::Object(rt);
769
+ auto& state = core::UnistylesRegistry::get().getState(rt);
770
+
771
+ // can happen for exotic styles
772
+ if (!unistyle->parsedStyle.has_value()) {
773
+ return nullptr;
774
+ }
775
+
776
+ helpers::enumerateJSIObject(rt, unistyle->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
777
+ if (this->isColor(propertyName)) {
778
+ return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
779
+ }
780
+
781
+ convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
782
+ });
783
+
784
+ return jsi::dynamicFromValue(rt, std::move(convertedStyles));
747
785
  }
748
786
 
749
787
  // check is styleKey contains color
@@ -26,6 +26,8 @@ struct Parser {
26
26
  void rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Variants& variants);
27
27
  void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>> styleSheets);
28
28
  void rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap);
29
+ folly::dynamic parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle);
30
+ folly::dynamic parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles);
29
31
 
30
32
  private:
31
33
  void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>>);
@@ -42,7 +44,6 @@ private:
42
44
  jsi::Value getStylesForVariant(jsi::Runtime& rt, const std::string groupName, jsi::Object&& groupValue, std::optional<std::string> selectedVariant, Variants& variants);
43
45
  jsi::Object parseCompoundVariants(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj, Variants& variants);
44
46
  bool shouldApplyCompoundVariants(jsi::Runtime& rt, const Variants& variants, jsi::Object& compoundVariant);
45
- RawProps parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles);
46
47
  bool isColor(const std::string& propertyName);
47
48
 
48
49
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <folly/dynamic.h>
4
5
  #include <react/renderer/uimanager/UIManager.h>
5
6
 
6
7
  namespace margelo::nitro::unistyles::shadow {
@@ -8,6 +9,6 @@ namespace margelo::nitro::unistyles::shadow {
8
9
  using namespace facebook;
9
10
  using namespace facebook::react;
10
11
 
11
- using ShadowLeafUpdates = std::unordered_map<const ShadowNodeFamily*, RawProps>;
12
+ using ShadowLeafUpdates = std::unordered_map<const ShadowNodeFamily*, folly::dynamic>;
12
13
 
13
14
  }
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #import "mutex"
3
4
  #import "ShadowLeafUpdate.h"
4
5
 
5
6
  namespace margelo::nitro::unistyles::shadow {
@@ -7,31 +8,63 @@ namespace margelo::nitro::unistyles::shadow {
7
8
  // Like a traffic officer managing a jam, this struct ensures everything
8
9
  // is synchronized within a set timeframe, controlling flow and preventing chaos.
9
10
  struct ShadowTrafficController {
10
- inline bool hasUnistylesCommit() {
11
- return _hasCommit;
12
- }
13
-
14
- inline void setHasUnistylesCommit(bool hasCommit) {
15
- this->_hasCommit = hasCommit;
16
- }
17
-
18
11
  inline bool shouldStop() {
19
12
  return !_canCommit;
20
13
  }
21
-
14
+
22
15
  inline void stopUnistylesTraffic() {
16
+ std::lock_guard<std::mutex> lock(_mutex);
17
+
23
18
  this->_canCommit = false;
24
19
  }
25
-
20
+
26
21
  inline void resumeUnistylesTraffic() {
22
+ std::lock_guard<std::mutex> lock(_mutex);
23
+
27
24
  this->_canCommit = true;
28
25
  }
29
-
30
- std::unordered_map<jsi::Runtime*, shadow::ShadowLeafUpdates> _unistylesUpdates{};
31
-
26
+
27
+ inline shadow::ShadowLeafUpdates& getUpdates() {
28
+ std::lock_guard<std::mutex> lock(_mutex);
29
+
30
+ return _unistylesUpdates;
31
+ }
32
+
33
+ inline void setUpdates(shadow::ShadowLeafUpdates& newUpdates) {
34
+ std::lock_guard<std::mutex> lock(_mutex);
35
+
36
+ auto& targetUpdates = _unistylesUpdates;
37
+
38
+ // this is important as overriding updates may skip some interim changes
39
+ // Unistyles emits different events so this will make sure that everything is synced
40
+ std::for_each(newUpdates.begin(), newUpdates.end(), [&targetUpdates](auto& pair){
41
+ if (targetUpdates.contains(pair.first)) {
42
+ targetUpdates[pair.first] = std::move(pair.second);
43
+
44
+ return;
45
+ }
46
+
47
+ targetUpdates.emplace(pair.first, std::move(pair.second));
48
+ });
49
+ }
50
+
51
+ inline void removeFromUpdates(const ShadowNodeFamily* family) {
52
+ auto it = std::find_if(_unistylesUpdates.begin(), _unistylesUpdates.end(), [family](auto& pair){
53
+ return family == pair.first;
54
+ });
55
+
56
+ if (it != _unistylesUpdates.end()) {
57
+ _unistylesUpdates.erase(it);
58
+ }
59
+ }
60
+
32
61
  private:
33
- bool _hasCommit = false;
34
- bool _canCommit = false;
62
+ std::atomic<bool> _canCommit = false;
63
+ shadow::ShadowLeafUpdates _unistylesUpdates{};
64
+
65
+ // this struct should be accessed in thread-safe manner. Otherwise shadow tree updates
66
+ // from different threads will break it
67
+ std::mutex _mutex;
35
68
  };
36
69
 
37
70
  }
@@ -6,14 +6,13 @@ using namespace facebook;
6
6
 
7
7
  using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered_set<int>>;
8
8
 
9
- void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, shadow::ShadowLeafUpdates& updates) {
9
+ void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt) {
10
+ auto& registry = core::UnistylesRegistry::get();
10
11
  auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
11
12
  const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
12
- auto& registry = core::UnistylesRegistry::get();
13
-
14
- if (registry.trafficController.shouldStop()) {
15
- registry.trafficController.setHasUnistylesCommit(true);
13
+ auto updates = registry.trafficController.getUpdates();
16
14
 
15
+ if (updates.size() == 0) {
17
16
  return;
18
17
  }
19
18
 
@@ -29,7 +28,7 @@ void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, sha
29
28
  affectedNodes
30
29
  ));
31
30
 
32
- // set unistyles commit trait
31
+ // set unistyles trait
33
32
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootNode);
34
33
 
35
34
  unistylesRootNode->addUnistylesCommitTrait();
@@ -16,7 +16,7 @@ using namespace facebook;
16
16
  using AffectedNodes = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;
17
17
 
18
18
  struct ShadowTreeManager {
19
- static void updateShadowTree(jsi::Runtime& rt, shadow::ShadowLeafUpdates& updates);
19
+ static void updateShadowTree(jsi::Runtime& rt);
20
20
  static AffectedNodes findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates);
21
21
  static ShadowNode::Unshared cloneShadowTree(const ShadowNode &shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes);
22
22
  };
@@ -26,8 +26,6 @@ __weak RCTSurfacePresenter* _surfacePresenter;
26
26
  // check if this is live reload, if so let's replace UnistylesRuntime with new runtime
27
27
  auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
28
28
 
29
- auto& registry = core::UnistylesRegistry::get();
30
-
31
29
  if (hasUnistylesRuntime) {
32
30
  HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesRuntime");
33
31
  HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesStyleSheet");
@@ -40,7 +38,7 @@ __weak RCTSurfacePresenter* _surfacePresenter;
40
38
  - (void)createHybrids:(jsi::Runtime&)rt {
41
39
  auto runOnJSThread = ([executor = _runtimeExecutor](std::function<void(jsi::Runtime& rt)> &&callback) {
42
40
  __block auto objcCallback = callback;
43
-
41
+
44
42
  [executor execute:^(jsi::Runtime& rt){
45
43
  objcCallback(rt);
46
44
  }];
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","isWeb","exports","Platform","OS","isIOS","isAndroid"],"sourceRoot":"../../src","sources":["common.js"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAGE,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAH,OAAA,CAAAG,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAJ,OAAA,CAAAI,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","isWeb","exports","Platform","OS","isIOS","isAndroid"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAGE,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAH,OAAA,CAAAG,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAJ,OAAA,CAAAI,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS","ignoreList":[]}
@@ -1,2 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","forEach","key","assign","React","createElement","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA4E,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GA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E,GAAGuB;IAAY,CAAC,CAAC;EAC7D,CAAC;AACL,CAAC;AAACO,OAAA,CAAA/B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
2
- AA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","forEach","key","assign","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAqG,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,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,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBA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,YAAY,CAACO,IAAI,CAACC,UAAU,IAAIA,UAAU,IAAI,CAAC,CAAC,KAAK,CAACP,qBAAqB,IAAIA,qBAAqB,CAACM,IAAI,CAACC,UAAU,IAAIA,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;UAC3Ib,KAAK,CAACc,SAAS,IAAIA,SAAS,GAAG,CAAC,CAAC;QACrC;MACJ,CAAC,CAAC;MAEF,OAAO,MAAM;QACTZ,oBAAoB,CAAC,CAAC;MAC1B,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,MAAMa,WAAW,GAAG;MAAE,GAAGtB,QAAQ,CAACE,KAAK;IAAE,CAAsB;IAE/DZ,MAAM,CAACiC,IAAI,CAACtB,KAAK,CAAC,CAACuB,OAAO,CAACC,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIH,WAAW,EAAE;QACpBA,WAAW,CAACG,GAAG,CAAC,GAAGnC,MAAM,CAACoC,MAAM,CAACzB,KAAK,CAACwB,GAAG,CAAC,EAAEH,WAAW,CAACG,GAAG,CAAC,CAAC;QAE9D;MACJ;MAEAH,WAAW,CAACG,GAAG,CAAC,GAAGxB,KAAK,CAACwB,GAAG,CAAC;IACjC,CAAC,CAAC;IAEF,oBAAO,IAAAhD,WAAA,CAAAkD,GAAA,EAAC5B,SAAS;MAAA,GAAKuB;IAAW,CAAG,CAAC;EACzC,CAAC;AACL,CAAC;AAAAM,OAAA,CAAA9B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1,2 +1 @@
1
- {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACO,MAAMI,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAC/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,KAAK,CAAC,EAAE,MAAMT,QAAQ,CAACE,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpI,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAON,KAAK;AAChB,CAAC;AAACW,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
2
-
1
+ {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAGO,MAAMI,QAAQ,GAAGA,CAAA,KAAsB;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,KAAK,CAAC,EAAE,MAAMT,QAAQ,CAACE,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEpI,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAON,KAAK;AAChB,CAAC;AAAAW,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- //# sourceMappingURL=global.js.map_esModule", {
2
+
3
+ Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
6
  //# sourceMappingURL=global.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.js"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_specs","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_core"],"sourceRoot":"../../src","sources":["index.js"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAd,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_specs","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_core"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAb,OAAA;AAEA,IAAAc,KAAA,GAAAd,OAAA","ignoreList":[]}
@@ -11,6 +11,7 @@ const getMQValue = value => {
11
11
  if (value === null) {
12
12
  return 0;
13
13
  }
14
+
14
15
  // todo take it from js
15
16
  const breakpoints = {
16
17
  xs: 0,
@@ -19,9 +20,11 @@ const getMQValue = value => {
19
20
  lg: 800,
20
21
  xl: 1200
21
22
  };
23
+
22
24
  // @ts-ignore
23
25
  return breakpoints[value] ?? 0;
24
26
  };
27
+
25
28
  /**
26
29
  * Utility to create cross-platform media queries
27
30
  * @returns - JavaScript symbol to be used in your stylesheet
@@ -42,4 +45,4 @@ const mq = exports.mq = {
42
45
  }
43
46
  })
44
47
  };
45
- //# sourceMappingURL=mq.js.mapmap
48
+ //# sourceMappingURL=mq.js.map
@@ -1,2 +1 @@
1
- {"version":3,"names":["getMQValue","value","breakpoints","xs","sm","md","lg","xl","mq","exports","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../src","sources":["mq.js"],"mappings":";;;;;;AAAA,MAAMA,UAAU,GAAIC,KAAK,IAAK;EAC1B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;I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KZ,UAAU,CAACa,IAAI,CAAC,OAAOb,UAAU,CAACgB,IAAI,CAAC,KAAKhB,UAAU,CAACiB,IAAI,CAAC;IACjI;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
2
- gnoreList":[]}
1
+ {"version":3,"names":["getMQValue","value","breakpoints","xs","sm","md","lg","xl","mq","exports","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../src","sources":["mq.ts"],"mappings":";;;;;;AAsBA,MAAMA,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;;EAEA;EACA,MAAMC,WAAW,GAAG;IAChBC,EAAE,EAAE,CAAC;IACLC,EAAE,EAAE,GAAG;IACPC,EAAE,EAAE,GAAG;IACPC,EAAE,EAAE,GAAG;IACPC,EAAE,EAAE;EACR,CAAC;;EAED;EACA,OAAOL,WAAW,CAACD,KAAK,CAAC,IAAI,CAAC;AAClC,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMO,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAM,MAAMd,UAAU,CAACY,IAAI,CAAC,KAAKZ,UAAU,CAACa,IAAI,CAAC,GAAyB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAM,MAAMd,UAAU,CAACgB,IAAI,CAAC,KAAKhB,UAAU,CAACiB,IAAI,CAAC;EACnH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACzD,MAAMd,UAAU,CAACY,IAAI,CAAC,KAAKZ,UAAU,CAACa,IAAI,CAAC,OAAOb,UAAU,CAACgB,IAAI,CAAC,KAAKhB,UAAU,CAACiB,IAAI,CAAC;IAChG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACxD,MAAMd,UAAU,CAACY,IAAI,CAAC,KAAKZ,UAAU,CAACa,IAAI,CAAC,OAAOb,UAAU,CAACgB,IAAI,CAAC,KAAKhB,UAAU,CAACiB,IAAI,CAAC;IAChG;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1 +1,2 @@
1
- {"version":3,"names":["require","UnistyleDependency","exports"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/NativePlatform.nitro.js"],"mappings":";;;;;;AAAAA,OAAA;AACO,IAAIC,kBAAkB;AAC7B,CAAC,UAAUA,kBAAkB,EAAE;EAC3BA,kBAAkB,CAACA,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO;EAC7DA,kBAAkB,CAACA,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW;EACrEA,kBAAkB,CAACA,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,gBAAgB;EAC/EA,kBAAkB,CAACA,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;EACzEA,kBAAkB,CAACA,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;EACnEA,kBAAkB,CAACA,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;EACzEA,kBAAkB,CAACA,kBAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY;EACvEA,kBAAkB,CAACA,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;EACzEA,kBAAkB,CAACA,kBAAkB,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;EACzFA,kBAAkB,CAACA,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;EAC/DA,kBAAkB,CAACA,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,GAAG,YAAY;EACxEA,kBAAkB,CAACA,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW;EACtEA,kBAAkB,CAACA,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW;EACtEA,kBAAkB,CAACA,kBAAkB,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,eAAe;EAC9EA,kBAAkB,CAACA,kBAAkB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK;AAC9D,CAAC,EAAEA,kBAAkB,KAAAC,OAAA,CAAAD,kBAAA,GAAKA,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["UnistyleDependency","exports"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/NativePlatform.nitro.ts"],"mappings":";;;;;;IAMYA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OAgC9B;AACA","ignoreList":[]}
2
+ ,CAAC,GAAG,YAAY;EACvEA,kBAAkB,CAACA,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;EACzEA,kBAAkB,CAACA,kBAAkB,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;EACzFA,kBAAkB,CAACA,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;EAC/DA,kBAAkB,CAACA,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,GAAG,YAAY;EACxEA,kBAAkB,CAACA,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW;EACtEA,kBAAkB,CAACA,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW;EACtEA,kBAAkB,CAACA,kBAAkB,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,eAAe;EAC9EA,kBAAkB,CAACA,kBAAkB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK;AAC9D,CAAC,EAAEA,kBAAkB,KAAAC,OAAA,CAAAD,kBAAA,GAAKA,kBAAkB,GAAG,CAAC,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_NativePlatform","require"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/index.js"],"mappings":";;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_NativePlatform","require"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/index.ts"],"mappings":";;;;;;;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- //# sourceMappingURL=types.js.map__esModule", {
2
+
3
+ Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
6
  //# sourceMappingURL=types.js.map