nitrogen 0.31.9 → 0.31.10

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.
@@ -152,6 +152,9 @@ auto __result = method(${jniParamsForward.join(', ')});
152
152
  return ${bridgedReturn.parseFromKotlinToCpp('__result', 'c++', false)};
153
153
  `.trim();
154
154
  }
155
+ const fbjniReturnType = functionType.returnType.kind === 'hybrid-object'
156
+ ? bridgedReturn.asJniReferenceType('global')
157
+ : bridgedReturn.asJniReferenceType('local');
155
158
  const bridged = new KotlinCxxBridgedType(functionType);
156
159
  const imports = bridged
157
160
  .getRequiredImports('c++')
@@ -201,7 +204,7 @@ namespace ${cxxNamespace} {
201
204
  /**
202
205
  * Invokes the C++ \`std::function<...>\` this \`J${name}_cxx\` instance holds.
203
206
  */
204
- ${bridgedReturn.asJniReferenceType('local')} invoke_cxx(${cppParams.join(', ')}) {
207
+ ${fbjniReturnType} invoke_cxx(${cppParams.join(', ')}) {
205
208
  ${indent(cppCallBody, ' ')}
206
209
  }
207
210
 
@@ -10,15 +10,6 @@ export function createKotlinStruct(structType) {
10
10
  name: p.escapedName,
11
11
  type: new KotlinCxxBridgedType(p),
12
12
  }));
13
- // const parameters = structType.properties
14
- // .map((p) =>
15
- // `
16
- // @DoNotStrip
17
- // @Keep
18
- // val ${p.escapedName}: ${p.getCode('kotlin')}
19
- // `.trim()
20
- // )
21
- // .join(',\n')
22
13
  const properties = bridgedProperties
23
14
  .map(({ name, type }) => {
24
15
  return `
@@ -26,8 +26,8 @@ var ${p.escapedName}: ${p.getCode('swift')} {
26
26
  `.trim();
27
27
  })
28
28
  .join('\n\n');
29
- const requiredImports = struct
30
- .getRequiredImports('swift')
29
+ const requiredImports = struct.properties
30
+ .flatMap((p) => p.getRequiredImports('swift'))
31
31
  .map((i) => `import ${i.name}`);
32
32
  requiredImports.push('import NitroModules');
33
33
  const imports = requiredImports.filter(isNotDuplicate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.31.9",
3
+ "version": "0.31.10",
4
4
  "description": "The code-generator for react-native-nitro-modules.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "chalk": "^5.3.0",
39
- "react-native-nitro-modules": "^0.31.9",
39
+ "react-native-nitro-modules": "^0.31.10",
40
40
  "ts-morph": "^27.0.0",
41
41
  "yargs": "^18.0.0",
42
42
  "zod": "^4.0.5"
@@ -170,6 +170,11 @@ return ${bridgedReturn.parseFromKotlinToCpp('__result', 'c++', false)};
170
170
  `.trim()
171
171
  }
172
172
 
173
+ const fbjniReturnType =
174
+ functionType.returnType.kind === 'hybrid-object'
175
+ ? bridgedReturn.asJniReferenceType('global')
176
+ : bridgedReturn.asJniReferenceType('local')
177
+
173
178
  const bridged = new KotlinCxxBridgedType(functionType)
174
179
  const imports = bridged
175
180
  .getRequiredImports('c++')
@@ -220,7 +225,7 @@ namespace ${cxxNamespace} {
220
225
  /**
221
226
  * Invokes the C++ \`std::function<...>\` this \`J${name}_cxx\` instance holds.
222
227
  */
223
- ${bridgedReturn.asJniReferenceType('local')} invoke_cxx(${cppParams.join(', ')}) {
228
+ ${fbjniReturnType} invoke_cxx(${cppParams.join(', ')}) {
224
229
  ${indent(cppCallBody, ' ')}
225
230
  }
226
231
 
@@ -19,15 +19,6 @@ export function createKotlinStruct(structType: StructType): SourceFile[] {
19
19
  name: p.escapedName,
20
20
  type: new KotlinCxxBridgedType(p),
21
21
  }))
22
- // const parameters = structType.properties
23
- // .map((p) =>
24
- // `
25
- // @DoNotStrip
26
- // @Keep
27
- // val ${p.escapedName}: ${p.getCode('kotlin')}
28
- // `.trim()
29
- // )
30
- // .join(',\n')
31
22
  const properties = bridgedProperties
32
23
  .map(({ name, type }) => {
33
24
  return `
@@ -34,8 +34,8 @@ var ${p.escapedName}: ${p.getCode('swift')} {
34
34
  })
35
35
  .join('\n\n')
36
36
 
37
- const requiredImports = struct
38
- .getRequiredImports('swift')
37
+ const requiredImports = struct.properties
38
+ .flatMap((p) => p.getRequiredImports('swift'))
39
39
  .map((i) => `import ${i.name}`)
40
40
  requiredImports.push('import NitroModules')
41
41
  const imports = requiredImports.filter(isNotDuplicate)