react-native-unistyles 3.0.0-alpha.11 → 3.0.0-alpha.13

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.
@@ -22,7 +22,7 @@ struct JSI_EXPORT HostStyle : public jsi::HostObject {
22
22
  private:
23
23
  std::shared_ptr<StyleSheet> _styleSheet;
24
24
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
25
- std::vector<std::pair<std::string, std::string>> _variants{};
25
+ std::vector<std::pair<std::string, std::string>> _variants{};
26
26
  };
27
27
 
28
28
  }
@@ -25,17 +25,23 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
25
25
 
26
26
  return newRootShadowNode;
27
27
  }
28
-
28
+
29
+ unistylesRootNode->removeUnistylesMountTrait();
30
+
31
+ auto& registry = core::UnistylesRegistry::get();
29
32
  auto shadowLeafUpdates = this->getUnistylesUpdates();
30
33
 
31
34
  if (shadowLeafUpdates.size() == 0) {
32
35
  return newRootShadowNode;
33
36
  }
37
+
38
+ // this is required, otherwise we end up with old shadow tree in mount hook
39
+ registry.trafficController.stopUnistylesTraffic();
34
40
 
35
41
  auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
36
42
 
37
43
  return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
38
- this->_unistylesRuntime->getRuntime(),
44
+ *this->_rt,
39
45
  *rootNode,
40
46
  shadowLeafUpdates,
41
47
  affectedNodes
@@ -44,11 +50,10 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
44
50
 
45
51
  shadow::ShadowLeafUpdates core::UnistylesCommitHook::getUnistylesUpdates() {
46
52
  auto& registry = core::UnistylesRegistry::get();
47
- auto& rt = this->_unistylesRuntime->getRuntime();
48
53
  auto parser = parser::Parser(this->_unistylesRuntime);
49
- auto dependencyMap = registry.buildDependencyMap(rt);
54
+ auto dependencyMap = registry.buildDependencyMap(*this->_rt);
50
55
 
51
- parser.rebuildUnistylesInDependencyMap(rt, dependencyMap);
56
+ parser.rebuildUnistylesInDependencyMap(*this->_rt, dependencyMap);
52
57
 
53
58
  return parser.dependencyMapToShadowLeafUpdates(dependencyMap);
54
59
  }
@@ -5,14 +5,15 @@
5
5
  #include "HybridUnistylesRuntime.h"
6
6
  #include "Parser.h"
7
7
  #include "ShadowTreeManager.h"
8
+ #include "ShadowTrafficController.h"
8
9
 
9
10
  namespace margelo::nitro::unistyles::core {
10
11
 
11
12
  using namespace facebook::react;
12
13
 
13
14
  struct UnistylesCommitHook : public UIManagerCommitHook {
14
- UnistylesCommitHook(std::shared_ptr<UIManager> uiManager, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime)
15
- : _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
15
+ UnistylesCommitHook(std::shared_ptr<UIManager> uiManager, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, jsi::Runtime& rt)
16
+ : _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager}, _rt{&rt} {
16
17
  _uiManager->registerCommitHook(*this);
17
18
  }
18
19
 
@@ -27,6 +28,7 @@ struct UnistylesCommitHook : public UIManagerCommitHook {
27
28
  private:
28
29
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
29
30
  std::shared_ptr<UIManager> _uiManager;
31
+ jsi::Runtime* _rt;
30
32
  };
31
33
 
32
34
  }
@@ -12,29 +12,42 @@ void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &
12
12
  auto rootNode = std::const_pointer_cast<RootShadowNode>(rootShadowNode);
13
13
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(rootNode);
14
14
 
15
- // skip only unistyles commits
15
+ // if this is Unistyles commit, do nothing
16
16
  if (unistylesRootNode->hasUnistylesMountTrait()) {
17
17
  unistylesRootNode->removeUnistylesMountTrait();
18
18
 
19
19
  return;
20
20
  }
21
21
 
22
+ // this is React Native commit
23
+ auto& registry = core::UnistylesRegistry::get();
24
+
25
+ registry.trafficController.resumeUnistylesTraffic();
26
+
27
+ // this will prevent crash when re-rendering view
28
+ // as Unistyles has nothing to commit yet, but dependency map
29
+ // will build all the shadow nodes
30
+ if (!registry.trafficController.hasUnistylesCommit()) {
31
+ return;
32
+ }
33
+
34
+ registry.trafficController.setHasUnistylesCommit(false);
35
+
22
36
  auto shadowLeafUpdates = this->getUnistylesUpdates();
23
37
 
24
38
  if (shadowLeafUpdates.size() == 0) {
25
39
  return;
26
40
  }
27
41
 
28
- shadow::ShadowTreeManager::updateShadowTree(this->_unistylesRuntime->getRuntime(), shadowLeafUpdates);
42
+ shadow::ShadowTreeManager::updateShadowTree(*this->_rt, shadowLeafUpdates);
29
43
  }
30
44
 
31
45
  shadow::ShadowLeafUpdates core::UnistylesMountHook::getUnistylesUpdates() {
32
46
  auto& registry = core::UnistylesRegistry::get();
33
- auto& rt = this->_unistylesRuntime->getRuntime();
34
47
  auto parser = parser::Parser(this->_unistylesRuntime);
35
- auto dependencyMap = registry.buildDependencyMap(rt);
48
+ auto dependencyMap = registry.buildDependencyMap(*this->_rt);
36
49
 
37
- parser.rebuildUnistylesInDependencyMap(rt, dependencyMap);
50
+ parser.rebuildUnistylesInDependencyMap(*this->_rt, dependencyMap);
38
51
 
39
52
  return parser.dependencyMapToShadowLeafUpdates(dependencyMap);
40
53
  }
@@ -11,8 +11,8 @@ namespace margelo::nitro::unistyles::core {
11
11
  using namespace facebook::react;
12
12
 
13
13
  struct UnistylesMountHook : public UIManagerMountHook {
14
- UnistylesMountHook(std::shared_ptr<UIManager> uiManager, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime)
15
- : _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
14
+ UnistylesMountHook(std::shared_ptr<UIManager> uiManager, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, jsi::Runtime& rt)
15
+ : _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager}, _rt{&rt} {
16
16
  _uiManager->registerMountHook(*this);
17
17
  }
18
18
 
@@ -23,6 +23,7 @@ struct UnistylesMountHook : public UIManagerMountHook {
23
23
  shadow::ShadowLeafUpdates getUnistylesUpdates();
24
24
 
25
25
  private:
26
+ jsi::Runtime* _rt;
26
27
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
27
28
  std::shared_ptr<UIManager> _uiManager;
28
29
  };
@@ -72,26 +72,31 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
72
72
  }
73
73
 
74
74
  void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
75
+ jsi::Runtime& rt,
75
76
  const ShadowNodeFamily* shadowNodeFamily,
76
77
  const core::Unistyle::Shared unistyle,
77
78
  Variants& variants,
78
79
  std::vector<folly::dynamic>& arguments
79
80
  ) {
80
- if (!this->_shadowRegistry.contains(shadowNodeFamily)) {
81
- this->_shadowRegistry[shadowNodeFamily] = {};
81
+ if (!this->_shadowRegistry[&rt].contains(shadowNodeFamily)) {
82
+ this->_shadowRegistry[&rt][shadowNodeFamily] = {};
82
83
  }
83
84
 
84
- this->_shadowRegistry[shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
85
+ this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
85
86
  }
86
87
 
87
- void core::UnistylesRegistry::unlinkShadowNodeWithUnistyle(const ShadowNodeFamily* shadowNodeFamily, const core::Unistyle::Shared unistyle) {
88
- auto& unistylesVec = this->_shadowRegistry[shadowNodeFamily];
88
+ void core::UnistylesRegistry::unlinkShadowNodeWithUnistyle(
89
+ jsi::Runtime& rt,
90
+ const ShadowNodeFamily* shadowNodeFamily,
91
+ const core::Unistyle::Shared unistyle
92
+ ) {
93
+ auto& unistylesVec = this->_shadowRegistry[&rt][shadowNodeFamily];
89
94
  auto it = std::find_if(unistylesVec.begin(), unistylesVec.end(), [unistyle](std::shared_ptr<UnistyleData> unistyleData){
90
95
  return unistyleData->unistyle == unistyle;
91
96
  });
92
97
 
93
98
  if (it != unistylesVec.end()) {
94
- this->_shadowRegistry[shadowNodeFamily].erase(it);
99
+ this->_shadowRegistry[&rt][shadowNodeFamily].erase(it);
95
100
  }
96
101
  }
97
102
 
@@ -104,8 +109,8 @@ std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Ru
104
109
  core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps) {
105
110
  DependencyMap dependencyMap;
106
111
  std::set<UnistyleDependency> uniqueDependencies(deps.begin(), deps.end());
107
-
108
- for (const auto& [family, unistyles] : this->_shadowRegistry) {
112
+
113
+ for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
109
114
  for (const auto& unistyleData : unistyles) {
110
115
  bool hasAnyOfDependencies = std::any_of(
111
116
  unistyleData->unistyle->dependencies.begin(),
@@ -114,28 +119,28 @@ core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt
114
119
  return std::find(uniqueDependencies.begin(), uniqueDependencies.end(), dep) != uniqueDependencies.end();
115
120
  }
116
121
  );
117
-
122
+
118
123
  if (!hasAnyOfDependencies) {
119
124
  continue;
120
125
  }
121
-
126
+
122
127
  // we need to take in count all unistyles from the shadowNode
123
128
  // as user might be using spreads and not all of them may have dependencies
124
129
  for (const auto& unistyleData : unistyles) {
125
130
  dependencyMap[family].emplace_back(unistyleData);
126
131
  }
127
-
132
+
128
133
  break;
129
134
  }
130
135
  }
131
-
136
+
132
137
  return dependencyMap;
133
138
  }
134
139
 
135
140
  core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt) {
136
141
  DependencyMap dependencyMap;
137
-
138
- for (const auto& [family, unistyles] : this->_shadowRegistry) {
142
+
143
+ for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
139
144
  for (const auto& unistyleData : unistyles) {
140
145
  dependencyMap[family].emplace_back(unistyleData);
141
146
  }
@@ -11,6 +11,7 @@
11
11
  #include "StyleSheet.h"
12
12
  #include "Unistyle.h"
13
13
  #include "UnistyleData.h"
14
+ #include "ShadowTrafficController.h"
14
15
 
15
16
  namespace margelo::nitro::unistyles::core {
16
17
 
@@ -35,18 +36,19 @@ struct UnistylesRegistry: public StyleSheetRegistry {
35
36
 
36
37
  UnistylesState& getState(jsi::Runtime& rt);
37
38
  void createState(jsi::Runtime& rt);
38
- void linkShadowNodeWithUnistyle(const ShadowNodeFamily*, const core::Unistyle::Shared, Variants& variants, std::vector<folly::dynamic>&);
39
- void unlinkShadowNodeWithUnistyle(const ShadowNodeFamily*, const core::Unistyle::Shared);
39
+ void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, const core::Unistyle::Shared, Variants& variants, std::vector<folly::dynamic>&);
40
+ void unlinkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, const core::Unistyle::Shared);
40
41
  std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
41
42
  DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
42
43
  DependencyMap buildDependencyMap(jsi::Runtime& rt);
43
-
44
+ shadow::ShadowTrafficController trafficController{};
45
+
44
46
  private:
45
47
  UnistylesRegistry() = default;
46
48
 
47
49
  std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
48
50
  std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
49
- std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>> _shadowRegistry{};
51
+ std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
50
52
  };
51
53
 
52
54
  UnistylesRegistry& UnistylesRegistry::get() {
@@ -91,5 +91,5 @@ int core::UnistylesState::parseColor(jsi::Value& maybeColor) {
91
91
  // we must convert it to uint32_t first, otherwise color will be broken
92
92
  uint32_t color = this->_processColorFn.get()->call(*_rt, maybeColor.asString(*_rt)).asNumber();
93
93
 
94
- return color;
94
+ return color ? color : 0;
95
95
  }
@@ -14,7 +14,7 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
14
14
 
15
15
  auto& registry = core::UnistylesRegistry::get();
16
16
 
17
- registry.linkShadowNodeWithUnistyle(&shadowNodeWrapper->getFamily(), unistyleWrapper, variants, arguments);
17
+ registry.linkShadowNodeWithUnistyle(rt, &shadowNodeWrapper->getFamily(), unistyleWrapper, variants, arguments);
18
18
 
19
19
  return jsi::Value::undefined();
20
20
  }
@@ -27,7 +27,7 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
27
27
 
28
28
  auto& registry = core::UnistylesRegistry::get();
29
29
 
30
- registry.unlinkShadowNodeWithUnistyle(&shadowNodeWrapper->getFamily(), unistyleWrapper);
30
+ registry.unlinkShadowNodeWithUnistyle(rt, &shadowNodeWrapper->getFamily(), unistyleWrapper);
31
31
 
32
32
  return jsi::Value::undefined();
33
33
  }
@@ -35,6 +35,8 @@ jsi::Value HybridStyleSheet::create(jsi::Runtime& rt, const jsi::Value &thisVal,
35
35
  auto style = std::make_shared<core::HostStyle>(registeredStyleSheet, this->_unistylesRuntime);
36
36
  auto styleHostObject = jsi::Object::createFromHostObject(rt, style);
37
37
 
38
+ registry.trafficController.setHasUnistylesCommit(true);
39
+
38
40
  return styleHostObject;
39
41
  }
40
42
 
@@ -72,6 +74,7 @@ jsi::Value HybridStyleSheet::configure(jsi::Runtime &rt, const jsi::Value &thisV
72
74
 
73
75
  verifyAndSelectTheme(rt);
74
76
  loadExternalMethods(thisVal, rt);
77
+ registerHooks(rt);
75
78
 
76
79
  return jsi::Value::undefined();
77
80
  }
@@ -239,3 +242,8 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
239
242
 
240
243
  shadow::ShadowTreeManager::updateShadowTree(rt, shadowLeafUpdates);
241
244
  }
245
+
246
+ void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
247
+ this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager, this->_unistylesRuntime, rt);
248
+ this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, this->_unistylesRuntime, rt);
249
+ }
@@ -18,9 +18,7 @@ using namespace facebook::react;
18
18
 
19
19
  struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
20
20
  HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, std::shared_ptr<UIManager> uiManager)
21
- : HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {
22
- this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(uiManager, unistylesRuntime);
23
- this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(uiManager, unistylesRuntime);
21
+ : HybridObject(TAG), _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
24
22
  this->_unistylesRuntime->registerPlatformListener(
25
23
  std::bind(&HybridStyleSheet::onPlatformDependenciesChange, this, std::placeholders::_1)
26
24
  );
@@ -54,11 +52,13 @@ private:
54
52
  void verifyAndSelectTheme(jsi::Runtime &rt);
55
53
  void setThemeFromColorScheme(jsi::Runtime& rt);
56
54
  void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
55
+ void registerHooks(jsi::Runtime& rt);
57
56
  void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
58
57
 
59
58
  double __unid = -1;
60
59
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
61
60
  std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
62
61
  std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
62
+ std::shared_ptr<UIManager> _uiManager;
63
63
  };
64
64
 
@@ -192,7 +192,7 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
192
192
  obj.setProperty(rt, "rtl", JSIConverter<bool>::toJSI(rt, miniRuntime.rtl));
193
193
  obj.setProperty(rt, "statusBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.statusBar));
194
194
  obj.setProperty(rt, "navigationBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.navigationBar));
195
-
195
+
196
196
  return obj;
197
197
  }
198
198
 
@@ -531,7 +531,9 @@ bool parser::Parser::shouldApplyCompoundVariants(jsi::Runtime& rt, const Variant
531
531
  auto property = compoundVariant.getProperty(rt, variantKey.c_str());
532
532
  auto propertyName = property.isBool()
533
533
  ? (property.asBool() ? "true" : "false")
534
- : property.asString(rt).utf8(rt);
534
+ : property.isString()
535
+ ? property.asString(rt).utf8(rt)
536
+ : "";
535
537
 
536
538
  if (propertyName != variantValue) {
537
539
  return false;
@@ -0,0 +1,33 @@
1
+ #pragma once
2
+
3
+ namespace margelo::nitro::unistyles::shadow {
4
+
5
+ // Like a traffic officer managing a jam, this struct ensures everything
6
+ // is synchronized within a set timeframe, controlling flow and preventing chaos.
7
+ struct ShadowTrafficController {
8
+ inline bool hasUnistylesCommit() {
9
+ return _hasCommit;
10
+ }
11
+
12
+ inline void setHasUnistylesCommit(bool hasCommit) {
13
+ this->_hasCommit = hasCommit;
14
+ }
15
+
16
+ inline bool shouldStop() {
17
+ return !_canCommit;
18
+ }
19
+
20
+ inline void stopUnistylesTraffic() {
21
+ this->_canCommit = false;
22
+ }
23
+
24
+ inline void resumeUnistylesTraffic() {
25
+ this->_canCommit = true;
26
+ }
27
+
28
+ private:
29
+ bool _hasCommit = false;
30
+ bool _canCommit = false;
31
+ };
32
+
33
+ }
@@ -9,6 +9,13 @@ using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered
9
9
  void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, shadow::ShadowLeafUpdates& updates) {
10
10
  auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
11
11
  const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
12
+ auto& registry = core::UnistylesRegistry::get();
13
+
14
+ if (registry.trafficController.shouldStop()) {
15
+ registry.trafficController.setHasUnistylesCommit(true);
16
+
17
+ return;
18
+ }
12
19
 
13
20
  shadowTreeRegistry.enumerate([&updates, &rt](const ShadowTree& shadowTree, bool& stop){
14
21
  // we could iterate via updates and create multiple commits
@@ -6,6 +6,7 @@
6
6
  #include <ranges>
7
7
  #include "ShadowLeafUpdate.h"
8
8
  #include "UnistylesCommitShadowNode.h"
9
+ #include "UnistylesRegistry.h"
9
10
 
10
11
  namespace margelo::nitro::unistyles::shadow {
11
12
 
@@ -15,7 +15,7 @@ const findShadowNodeForHandle = handle => {
15
15
  return node;
16
16
  };
17
17
  HybridShadowRegistry.add = (handle, style, variants, args) => {
18
- if (!handle) {
18
+ if (!handle || typeof style !== 'object') {
19
19
  return;
20
20
  }
21
21
  HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","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,EAAE;IACT;EACJ;EAEAJ,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,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAjB,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","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,OAAOQ,KAAK,KAAK,QAAQ,EAAE;IACtC;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,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAjB,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
@@ -11,7 +11,7 @@ const findShadowNodeForHandle = handle => {
11
11
  return node;
12
12
  };
13
13
  HybridShadowRegistry.add = (handle, style, variants, args) => {
14
- if (!handle) {
14
+ if (!handle || typeof style !== 'object') {
15
15
  return;
16
16
  }
17
17
  HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","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,IAAI,CAACV,MAAM,EAAE;IACT;EACJ;EAEAH,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,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAhB,oBAAoB,CAACiB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQD,OAAO,MAAMO,uBAAuB,GAAGlB,oBAA4D","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","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,IAAI,CAACV,MAAM,IAAI,OAAOQ,KAAK,KAAK,QAAQ,EAAE;IACtC;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,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAhB,oBAAoB,CAACiB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQD,OAAO,MAAMO,uBAAuB,GAAGlB,oBAA4D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../example/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,aAAa,CAAA;AAGpB,eAAO,MAAM,GAAG,yBAWf,CAAA"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../example/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,aAAa,CAAA;AAGpB,eAAO,MAAM,GAAG,yBAcf,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.11",
3
+ "version": "3.0.0-alpha.13",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -27,7 +27,7 @@ const findShadowNodeForHandle = (handle: ViewHandle) => {
27
27
  }
28
28
 
29
29
  HybridShadowRegistry.add = (handle, style, variants, args) => {
30
- if (!handle) {
30
+ if (!handle || typeof style !== 'object') {
31
31
  return
32
32
  }
33
33