nitrogen 0.35.1-beta.2 → 0.35.2

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/README.md CHANGED
@@ -25,4 +25,4 @@ npx nitrogen
25
25
 
26
26
  ## Usage
27
27
 
28
- See the [Nitrogen documentation](https://nitro.margelo.com/docs/nitrogen) for more information.
28
+ See the [Nitrogen documentation](https://nitro.margelo.com/docs/concepts/nitrogen) for more information.
@@ -46,6 +46,10 @@ public final func maybePrepareForRecycle() {
46
46
  guard let recyclable = __implementation as? any RecyclableView else { return }
47
47
  recyclable.prepareForRecycle()
48
48
  }
49
+ `.trim(), `
50
+ public final func onDropView() {
51
+ __implementation.onDropView()
52
+ }
49
53
  `.trim());
50
54
  }
51
55
  const hybridObject = new HybridObjectType(spec);
@@ -53,7 +53,7 @@ public class ${manager}: SimpleViewManager<View>() {
53
53
  }
54
54
 
55
55
  override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
56
- val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
56
+ val hybridView = getHybridView(view)
57
57
  ?: throw Error("Couldn't find view $view in local views table!")
58
58
 
59
59
  // 1. Update each prop individually
@@ -65,9 +65,15 @@ public class ${manager}: SimpleViewManager<View>() {
65
65
  return super.updateState(view, props, stateWrapper)
66
66
  }
67
67
 
68
+ override fun onDropViewInstance(view: View) {
69
+ val hybridView = getHybridView(view)
70
+ hybridView?.onDropView()
71
+ return super.onDropViewInstance(view)
72
+ }
73
+
68
74
  protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
69
75
  super.prepareToRecycleView(reactContext, view)
70
- val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
76
+ val hybridView = getHybridView(view)
71
77
  ?: return null
72
78
 
73
79
  @Suppress("USELESS_IS_CHECK")
@@ -81,6 +87,10 @@ public class ${manager}: SimpleViewManager<View>() {
81
87
  return null
82
88
  }
83
89
  }
90
+
91
+ private fun getHybridView(view: View): ${viewImplementation}? {
92
+ return view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
93
+ }
84
94
  }
85
95
  `.trim();
86
96
  const updaterKotlinCode = `
@@ -43,6 +43,13 @@ ${createFileMetadataString(`${component}.mm`)}
43
43
  #import "${HybridTSpecSwift}.hpp"
44
44
  #import "${getUmbrellaHeaderName()}"
45
45
 
46
+ #if __has_include(<cxxreact/ReactNativeVersion.h>)
47
+ #include <cxxreact/ReactNativeVersion.h>
48
+ #if REACT_NATIVE_VERSION_MINOR >= 82
49
+ #define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
50
+ #endif
51
+ #endif
52
+
46
53
  using namespace facebook;
47
54
  using namespace ${namespace};
48
55
  using namespace ${namespace}::views;
@@ -126,6 +133,14 @@ using namespace ${namespace}::views;
126
133
  swiftPart.maybePrepareForRecycle();
127
134
  }
128
135
 
136
+ #ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
137
+ - (void)invalidate {
138
+ ${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart();
139
+ swiftPart.onDropView();
140
+ [super invalidate];
141
+ }
142
+ #endif
143
+
129
144
  @end
130
145
  `;
131
146
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.35.1-beta.2",
3
+ "version": "0.35.2",
4
4
  "description": "The code-generator for react-native-nitro-modules.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "chalk": "^5.3.0",
38
- "react-native-nitro-modules": "^0.35.1-beta.2",
38
+ "react-native-nitro-modules": "^0.35.2",
39
39
  "ts-morph": "^27.0.0",
40
40
  "yargs": "^18.0.0",
41
41
  "zod": "^4.0.5"
@@ -69,6 +69,11 @@ public final func maybePrepareForRecycle() {
69
69
  guard let recyclable = __implementation as? any RecyclableView else { return }
70
70
  recyclable.prepareForRecycle()
71
71
  }
72
+ `.trim(),
73
+ `
74
+ public final func onDropView() {
75
+ __implementation.onDropView()
76
+ }
72
77
  `.trim()
73
78
  )
74
79
  }
@@ -75,7 +75,7 @@ public class ${manager}: SimpleViewManager<View>() {
75
75
  }
76
76
 
77
77
  override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
78
- val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
78
+ val hybridView = getHybridView(view)
79
79
  ?: throw Error("Couldn't find view $view in local views table!")
80
80
 
81
81
  // 1. Update each prop individually
@@ -87,9 +87,15 @@ public class ${manager}: SimpleViewManager<View>() {
87
87
  return super.updateState(view, props, stateWrapper)
88
88
  }
89
89
 
90
+ override fun onDropViewInstance(view: View) {
91
+ val hybridView = getHybridView(view)
92
+ hybridView?.onDropView()
93
+ return super.onDropViewInstance(view)
94
+ }
95
+
90
96
  protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
91
97
  super.prepareToRecycleView(reactContext, view)
92
- val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
98
+ val hybridView = getHybridView(view)
93
99
  ?: return null
94
100
 
95
101
  @Suppress("USELESS_IS_CHECK")
@@ -103,6 +109,10 @@ public class ${manager}: SimpleViewManager<View>() {
103
109
  return null
104
110
  }
105
111
  }
112
+
113
+ private fun getHybridView(view: View): ${viewImplementation}? {
114
+ return view.getTag(associated_hybrid_view_tag) as? ${viewImplementation}
115
+ }
106
116
  }
107
117
  `.trim()
108
118
 
@@ -67,6 +67,13 @@ ${createFileMetadataString(`${component}.mm`)}
67
67
  #import "${HybridTSpecSwift}.hpp"
68
68
  #import "${getUmbrellaHeaderName()}"
69
69
 
70
+ #if __has_include(<cxxreact/ReactNativeVersion.h>)
71
+ #include <cxxreact/ReactNativeVersion.h>
72
+ #if REACT_NATIVE_VERSION_MINOR >= 82
73
+ #define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
74
+ #endif
75
+ #endif
76
+
70
77
  using namespace facebook;
71
78
  using namespace ${namespace};
72
79
  using namespace ${namespace}::views;
@@ -150,6 +157,14 @@ using namespace ${namespace}::views;
150
157
  swiftPart.maybePrepareForRecycle();
151
158
  }
152
159
 
160
+ #ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
161
+ - (void)invalidate {
162
+ ${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart();
163
+ swiftPart.onDropView();
164
+ [super invalidate];
165
+ }
166
+ #endif
167
+
153
168
  @end
154
169
  `
155
170