react-native-unistyles 3.2.1 → 3.2.3

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.
@@ -61,34 +61,31 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
61
61
  void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
62
62
  jsi::Runtime& rt,
63
63
  const ShadowNodeFamily* shadowNodeFamily,
64
- std::vector<std::shared_ptr<UnistyleData>>& unistylesData
64
+ std::vector<std::shared_ptr<UnistyleData>>& unistylesData,
65
+ std::optional<folly::dynamic> initialScopedUpdate
65
66
  ) {
66
- this->trafficController.withLock([this, &rt, &unistylesData, shadowNodeFamily](){
67
+ this->trafficController.withLock([this, &rt, &unistylesData, shadowNodeFamily, &initialScopedUpdate](){
67
68
  // Clear suspension state if this family was previously suspended
68
69
  if (_suspendedFamilies.erase(shadowNodeFamily) > 0) {
69
70
  auto* mutableFamily = const_cast<ShadowNodeFamily*>(shadowNodeFamily);
70
71
  mutableFamily->nativeProps_DEPRECATED.reset();
72
+ // Clear old registry entries to prevent stale UnistyleData accumulation
73
+ this->_shadowRegistry.erase(shadowNodeFamily);
74
+ // Remove any stale traffic controller entry (e.g. from a theme change during suspension)
75
+ this->trafficController.removeShadowNode(shadowNodeFamily);
71
76
  }
72
77
 
73
- shadow::ShadowLeafUpdates updates;
74
- auto parser = parser::Parser(nullptr);
75
-
76
78
  std::for_each(unistylesData.begin(), unistylesData.end(), [this, shadowNodeFamily](std::shared_ptr<UnistyleData> unistyleData){
77
79
  this->_shadowRegistry[shadowNodeFamily].emplace_back(unistyleData);
78
80
  });
79
81
 
80
- updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
81
-
82
- auto* mutableFamily = const_cast<ShadowNodeFamily*>(shadowNodeFamily);
82
+ // Required for scoped themes to apply on initial mount
83
+ if (initialScopedUpdate.has_value()) {
84
+ shadow::ShadowLeafUpdates updates;
83
85
 
84
- if (mutableFamily->nativeProps_DEPRECATED) {
85
- mutableFamily->nativeProps_DEPRECATED->update(updates[shadowNodeFamily]);
86
- } else {
87
- mutableFamily->nativeProps_DEPRECATED = std::make_unique<folly::dynamic>(updates[shadowNodeFamily]);
86
+ updates.emplace(shadowNodeFamily, std::move(*initialScopedUpdate));
87
+ this->trafficController.setUpdates(updates);
88
88
  }
89
-
90
- this->trafficController.setUpdates(updates);
91
- this->trafficController.resumeUnistylesTraffic();
92
89
  });
93
90
  }
94
91
 
@@ -40,7 +40,7 @@ struct UnistylesRegistry: public StyleSheetRegistry {
40
40
  UnistylesState& getState();
41
41
  void createState();
42
42
  std::vector<std::shared_ptr<core::StyleSheet>> getStyleSheetsToRefresh(std::vector<UnistyleDependency>& unistylesDependencies);
43
- void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>& unistylesData);
43
+ void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>& unistylesData, std::optional<folly::dynamic> initialScopedUpdate = std::nullopt);
44
44
  void unlinkShadowNodeWithUnistyles(const ShadowNodeFamily*);
45
45
  void suspendShadowNode(const ShadowNodeFamily*);
46
46
  bool isSuspended(const ShadowNodeFamily*) const noexcept;
@@ -13,10 +13,13 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
13
13
  auto& registry = core::UnistylesRegistry::get();
14
14
 
15
15
  // this is special case for Animated, and prevents appending same unistyles to node
16
- registry.removeDuplicatedUnistyles(&shadowNodeWrapper->getFamily(), unistyleWrappers);
16
+ // skip for suspended families - they need a full re-link with fresh UnistyleData
17
+ if (!registry.isSuspended(&shadowNodeWrapper->getFamily())) {
18
+ registry.removeDuplicatedUnistyles(&shadowNodeWrapper->getFamily(), unistyleWrappers);
17
19
 
18
- if (unistyleWrappers.empty()) {
19
- return jsi::Value::undefined();
20
+ if (unistyleWrappers.empty()) {
21
+ return jsi::Value::undefined();
22
+ }
20
23
  }
21
24
 
22
25
  for (size_t i = 0; i < unistyleWrappers.size(); i++) {
@@ -91,10 +94,17 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
91
94
  unistylesData.emplace_back(unistyleData);
92
95
  }
93
96
 
97
+ std::optional<folly::dynamic> initialScopedUpdate;
98
+
99
+ if (scopedTheme.has_value()) {
100
+ initialScopedUpdate = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
101
+ }
102
+
94
103
  registry.linkShadowNodeWithUnistyle(
95
104
  rt,
96
105
  &shadowNodeWrapper->getFamily(),
97
- unistylesData
106
+ unistylesData,
107
+ std::move(initialScopedUpdate)
98
108
  );
99
109
 
100
110
  return jsi::Value::undefined();
@@ -56,5 +56,7 @@ def add_nitrogen_files(spec)
56
56
  "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
57
  # Enables stricter modular headers
58
58
  "DEFINES_MODULE" => "YES",
59
+ # Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
60
+ "SWIFT_INSTALL_OBJC_HEADER" => "NO",
59
61
  })
60
62
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin ./src/__tests__",
@@ -145,13 +145,13 @@
145
145
  "@babel/plugin-syntax-jsx": "7.28.6",
146
146
  "@babel/runtime": "7.28.6",
147
147
  "@react-native/babel-preset": "0.83.2",
148
- "nitrogen": "0.35.2",
148
+ "nitrogen": "0.35.4",
149
149
  "oxfmt": "0.35.0",
150
150
  "oxlint": "1.50.0",
151
151
  "react": "19.2.0",
152
152
  "react-native": "0.83.2",
153
153
  "react-native-builder-bob": "0.40.18",
154
- "react-native-nitro-modules": "0.35.2",
154
+ "react-native-nitro-modules": "0.35.4",
155
155
  "react-native-reanimated": "4.2.2",
156
156
  "react-native-web": "0.21.2",
157
157
  "typescript": "5.9.3"