nitrogen 0.31.6 → 0.31.8
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/lib/syntax/kotlin/KotlinCxxBridgedType.js +1 -1
- package/lib/syntax/swift/SwiftCxxTypeHelper.js +5 -0
- package/lib/syntax/swift/SwiftFunction.js +6 -5
- package/lib/syntax/swift/SwiftHybridObject.js +3 -2
- package/lib/syntax/swift/SwiftHybridObjectBridge.js +6 -6
- package/lib/syntax/swift/SwiftStruct.js +8 -2
- package/package.json +2 -2
- package/src/syntax/kotlin/KotlinCxxBridgedType.ts +1 -1
- package/src/syntax/swift/SwiftCxxTypeHelper.ts +5 -0
- package/src/syntax/swift/SwiftFunction.ts +5 -4
- package/src/syntax/swift/SwiftHybridObject.ts +3 -4
- package/src/syntax/swift/SwiftHybridObjectBridge.ts +11 -7
- package/src/syntax/swift/SwiftStruct.ts +9 -2
|
@@ -131,6 +131,11 @@ void* NON_NULL get_${name}(${name} cppType) {
|
|
|
131
131
|
`.trim(),
|
|
132
132
|
requiredIncludes: [
|
|
133
133
|
...includes,
|
|
134
|
+
{
|
|
135
|
+
language: 'c++',
|
|
136
|
+
name: 'NitroModules/NitroDefines.hpp',
|
|
137
|
+
space: 'system',
|
|
138
|
+
},
|
|
134
139
|
{
|
|
135
140
|
language: 'c++',
|
|
136
141
|
// Swift umbrella header
|
|
@@ -26,15 +26,16 @@ let __result: ${functionType.returnType.getCode('swift')} = self.closure(${argsF
|
|
|
26
26
|
return ${returnType.parseFromSwiftToCpp('__result', 'swift')}
|
|
27
27
|
`.trim();
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const requiredImports = functionType
|
|
30
30
|
.getRequiredImports('swift')
|
|
31
|
-
.map((i) => `import ${i.name}`)
|
|
32
|
-
|
|
31
|
+
.map((i) => `import ${i.name}`);
|
|
32
|
+
requiredImports.push('import NitroModules');
|
|
33
|
+
const imports = requiredImports.filter(isNotDuplicate);
|
|
33
34
|
const code = `
|
|
34
35
|
${createFileMetadataString(`${swiftClassName}.swift`)}
|
|
35
36
|
|
|
36
|
-
import
|
|
37
|
-
${
|
|
37
|
+
import Foundation
|
|
38
|
+
${imports.join('\n')}
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Wraps a Swift \`${functionType.getCode('swift')}\` as a class.
|
|
@@ -52,8 +52,9 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr
|
|
|
52
52
|
return cxxWrapper
|
|
53
53
|
}
|
|
54
54
|
}`.trim());
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const requiredImports = extraImports.map((i) => `import ${i.name}`);
|
|
56
|
+
requiredImports.push('import NitroModules');
|
|
57
|
+
const imports = requiredImports.filter(isNotDuplicate);
|
|
57
58
|
const protocolCode = `
|
|
58
59
|
${createFileMetadataString(`${protocolName}.swift`)}
|
|
59
60
|
|
|
@@ -68,12 +68,12 @@ public override func getCxxPart() -> bridge.${baseBridge.specializationName} {
|
|
|
68
68
|
return bridge.${upcastBridge.funcName}(ownCxxPart)
|
|
69
69
|
}`.trim();
|
|
70
70
|
});
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
imports
|
|
71
|
+
const requiredImports = ['import NitroModules'];
|
|
72
|
+
requiredImports.push(...spec.properties
|
|
73
|
+
.flatMap((p) => p.getRequiredImports('swift'))
|
|
74
|
+
.map((i) => `import ${i.name}`));
|
|
75
|
+
requiredImports.push(...spec.methods.flatMap((m) => m.getRequiredImports('swift').map((i) => `import ${i.name}`)));
|
|
76
|
+
const imports = requiredImports.filter(isNotDuplicate);
|
|
77
77
|
const swiftCxxWrapperCode = `
|
|
78
78
|
${createFileMetadataString(`${name.HybridTSpecCxx}.swift`)}
|
|
79
79
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NitroConfig } from '../../config/NitroConfig.js';
|
|
2
2
|
import { indent } from '../../utils.js';
|
|
3
|
-
import { createFileMetadataString } from '../helpers.js';
|
|
3
|
+
import { createFileMetadataString, isNotDuplicate } from '../helpers.js';
|
|
4
4
|
import { Parameter } from '../Parameter.js';
|
|
5
5
|
import { StructType } from '../types/StructType.js';
|
|
6
6
|
import { SwiftCxxBridgedType } from './SwiftCxxBridgedType.js';
|
|
@@ -26,10 +26,16 @@ var ${p.escapedName}: ${p.getCode('swift')} {
|
|
|
26
26
|
`.trim();
|
|
27
27
|
})
|
|
28
28
|
.join('\n\n');
|
|
29
|
+
const requiredImports = struct
|
|
30
|
+
.getRequiredImports('swift')
|
|
31
|
+
.map((i) => `import ${i.name}`);
|
|
32
|
+
requiredImports.push('import NitroModules');
|
|
33
|
+
const imports = requiredImports.filter(isNotDuplicate);
|
|
29
34
|
const code = `
|
|
30
35
|
${createFileMetadataString(`${struct.structName}.swift`)}
|
|
31
36
|
|
|
32
|
-
import
|
|
37
|
+
import Foundation
|
|
38
|
+
${imports.join('\n')}
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
41
|
* Represents an instance of \`${struct.structName}\`, backed by a C++ struct.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitrogen",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.8",
|
|
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.
|
|
39
|
+
"react-native-nitro-modules": "^0.31.8",
|
|
40
40
|
"ts-morph": "^27.0.0",
|
|
41
41
|
"yargs": "^18.0.0",
|
|
42
42
|
"zod": "^4.0.5"
|
|
@@ -163,6 +163,11 @@ void* NON_NULL get_${name}(${name} cppType) {
|
|
|
163
163
|
`.trim(),
|
|
164
164
|
requiredIncludes: [
|
|
165
165
|
...includes,
|
|
166
|
+
{
|
|
167
|
+
language: 'c++',
|
|
168
|
+
name: 'NitroModules/NitroDefines.hpp',
|
|
169
|
+
space: 'system',
|
|
170
|
+
},
|
|
166
171
|
{
|
|
167
172
|
language: 'c++',
|
|
168
173
|
// Swift umbrella header
|
|
@@ -32,16 +32,17 @@ return ${returnType.parseFromSwiftToCpp('__result', 'swift')}
|
|
|
32
32
|
`.trim()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const requiredImports = functionType
|
|
36
36
|
.getRequiredImports('swift')
|
|
37
37
|
.map((i) => `import ${i.name}`)
|
|
38
|
-
|
|
38
|
+
requiredImports.push('import NitroModules')
|
|
39
|
+
const imports = requiredImports.filter(isNotDuplicate)
|
|
39
40
|
|
|
40
41
|
const code = `
|
|
41
42
|
${createFileMetadataString(`${swiftClassName}.swift`)}
|
|
42
43
|
|
|
43
|
-
import
|
|
44
|
-
${
|
|
44
|
+
import Foundation
|
|
45
|
+
${imports.join('\n')}
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Wraps a Swift \`${functionType.getCode('swift')}\` as a class.
|
|
@@ -63,10 +63,9 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr
|
|
|
63
63
|
}`.trim()
|
|
64
64
|
)
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
66
|
+
const requiredImports = extraImports.map((i) => `import ${i.name}`)
|
|
67
|
+
requiredImports.push('import NitroModules')
|
|
68
|
+
const imports = requiredImports.filter(isNotDuplicate)
|
|
70
69
|
|
|
71
70
|
const protocolCode = `
|
|
72
71
|
${createFileMetadataString(`${protocolName}.swift`)}
|
|
@@ -108,14 +108,18 @@ public override func getCxxPart() -> bridge.${baseBridge.specializationName} {
|
|
|
108
108
|
}`.trim()
|
|
109
109
|
})
|
|
110
110
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
...spec.properties
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const requiredImports = ['import NitroModules']
|
|
112
|
+
requiredImports.push(
|
|
113
|
+
...spec.properties
|
|
114
|
+
.flatMap((p) => p.getRequiredImports('swift'))
|
|
115
|
+
.map((i) => `import ${i.name}`)
|
|
116
|
+
)
|
|
117
|
+
requiredImports.push(
|
|
118
|
+
...spec.methods.flatMap((m) =>
|
|
119
|
+
m.getRequiredImports('swift').map((i) => `import ${i.name}`)
|
|
120
|
+
)
|
|
118
121
|
)
|
|
122
|
+
const imports = requiredImports.filter(isNotDuplicate)
|
|
119
123
|
|
|
120
124
|
const swiftCxxWrapperCode = `
|
|
121
125
|
${createFileMetadataString(`${name.HybridTSpecCxx}.swift`)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NitroConfig } from '../../config/NitroConfig.js'
|
|
2
2
|
import { indent } from '../../utils.js'
|
|
3
|
-
import { createFileMetadataString } from '../helpers.js'
|
|
3
|
+
import { createFileMetadataString, isNotDuplicate } from '../helpers.js'
|
|
4
4
|
import { Parameter } from '../Parameter.js'
|
|
5
5
|
import type { FileWithReferencedTypes } from '../SourceFile.js'
|
|
6
6
|
import { StructType } from '../types/StructType.js'
|
|
@@ -34,10 +34,17 @@ var ${p.escapedName}: ${p.getCode('swift')} {
|
|
|
34
34
|
})
|
|
35
35
|
.join('\n\n')
|
|
36
36
|
|
|
37
|
+
const requiredImports = struct
|
|
38
|
+
.getRequiredImports('swift')
|
|
39
|
+
.map((i) => `import ${i.name}`)
|
|
40
|
+
requiredImports.push('import NitroModules')
|
|
41
|
+
const imports = requiredImports.filter(isNotDuplicate)
|
|
42
|
+
|
|
37
43
|
const code = `
|
|
38
44
|
${createFileMetadataString(`${struct.structName}.swift`)}
|
|
39
45
|
|
|
40
|
-
import
|
|
46
|
+
import Foundation
|
|
47
|
+
${imports.join('\n')}
|
|
41
48
|
|
|
42
49
|
/**
|
|
43
50
|
* Represents an instance of \`${struct.structName}\`, backed by a C++ struct.
|