nitrogen 0.2.23 → 0.29.4

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.
Files changed (333) hide show
  1. package/README.md +15 -109
  2. package/lib/Logger.d.ts +10 -0
  3. package/lib/Logger.js +56 -0
  4. package/lib/autolinking/Autolinking.d.ts +8 -0
  5. package/lib/autolinking/Autolinking.js +1 -0
  6. package/lib/autolinking/android/createCMakeExtension.d.ts +6 -0
  7. package/lib/autolinking/android/createCMakeExtension.js +106 -0
  8. package/lib/autolinking/android/createGradleExtension.d.ts +5 -0
  9. package/lib/autolinking/android/createGradleExtension.js +36 -0
  10. package/lib/autolinking/android/createHybridObjectInitializer.d.ts +2 -0
  11. package/lib/autolinking/android/createHybridObjectInitializer.js +159 -0
  12. package/lib/autolinking/createAndroidAutolinking.d.ts +11 -0
  13. package/lib/autolinking/createAndroidAutolinking.js +13 -0
  14. package/lib/autolinking/createIOSAutolinking.d.ts +5 -0
  15. package/lib/autolinking/createIOSAutolinking.js +19 -0
  16. package/lib/autolinking/ios/createHybridObjectInitializer.d.ts +9 -0
  17. package/lib/autolinking/ios/createHybridObjectInitializer.js +97 -0
  18. package/lib/autolinking/ios/createPodspecRubyExtension.d.ts +5 -0
  19. package/lib/autolinking/ios/createPodspecRubyExtension.js +69 -0
  20. package/lib/autolinking/ios/createSwiftCxxBridge.d.ts +2 -0
  21. package/lib/autolinking/ios/createSwiftCxxBridge.js +117 -0
  22. package/lib/autolinking/ios/createSwiftUmbrellaHeader.d.ts +3 -0
  23. package/lib/autolinking/ios/createSwiftUmbrellaHeader.js +74 -0
  24. package/lib/config/NitroConfig.d.ts +52 -0
  25. package/lib/config/NitroConfig.js +112 -0
  26. package/lib/config/NitroUserConfig.d.ts +22 -0
  27. package/lib/config/NitroUserConfig.js +88 -0
  28. package/lib/config/getConfig.d.ts +2 -0
  29. package/lib/config/getConfig.js +84 -0
  30. package/lib/createGitAttributes.d.ts +1 -0
  31. package/lib/createGitAttributes.js +11 -0
  32. package/lib/createPlatformSpec.d.ts +4 -0
  33. package/lib/createPlatformSpec.js +127 -0
  34. package/lib/getFiles.d.ts +1 -0
  35. package/lib/getFiles.js +28 -0
  36. package/lib/getPlatformSpecs.d.ts +17 -0
  37. package/lib/getPlatformSpecs.js +153 -0
  38. package/lib/index.d.ts +2 -0
  39. package/lib/index.js +113 -10
  40. package/lib/init.d.ts +1 -0
  41. package/lib/init.js +123 -0
  42. package/lib/nitrogen.d.ts +11 -0
  43. package/lib/nitrogen.js +165 -0
  44. package/lib/prettifyDirectory.d.ts +1 -0
  45. package/lib/prettifyDirectory.js +27 -0
  46. package/lib/syntax/BridgedType.d.ts +41 -0
  47. package/lib/syntax/BridgedType.js +1 -0
  48. package/lib/syntax/CodeNode.d.ts +23 -0
  49. package/lib/syntax/CodeNode.js +1 -0
  50. package/lib/syntax/HybridObjectSpec.d.ts +13 -0
  51. package/lib/syntax/HybridObjectSpec.js +1 -0
  52. package/lib/syntax/Method.d.ts +41 -0
  53. package/lib/syntax/Method.js +108 -0
  54. package/lib/syntax/Parameter.d.ts +15 -0
  55. package/lib/syntax/Parameter.js +65 -0
  56. package/lib/syntax/Property.d.ts +50 -0
  57. package/lib/syntax/Property.js +147 -0
  58. package/lib/syntax/SourceFile.d.ts +70 -0
  59. package/lib/syntax/SourceFile.js +7 -0
  60. package/lib/syntax/c++/CppEnum.d.ts +6 -0
  61. package/lib/syntax/c++/CppEnum.js +110 -0
  62. package/lib/syntax/c++/CppHybridObject.d.ts +3 -0
  63. package/lib/syntax/c++/CppHybridObject.js +146 -0
  64. package/lib/syntax/c++/CppHybridObjectRegistration.d.ts +17 -0
  65. package/lib/syntax/c++/CppHybridObjectRegistration.js +18 -0
  66. package/lib/syntax/c++/CppStruct.d.ts +3 -0
  67. package/lib/syntax/c++/CppStruct.js +108 -0
  68. package/lib/syntax/c++/CppUnion.d.ts +6 -0
  69. package/lib/syntax/c++/CppUnion.js +88 -0
  70. package/lib/syntax/c++/getForwardDeclaration.d.ts +3 -0
  71. package/lib/syntax/c++/getForwardDeclaration.js +14 -0
  72. package/lib/syntax/c++/includeNitroHeader.d.ts +7 -0
  73. package/lib/syntax/c++/includeNitroHeader.js +34 -0
  74. package/lib/syntax/createType.d.ts +15 -0
  75. package/lib/syntax/createType.js +303 -0
  76. package/lib/syntax/getAllTypes.d.ts +3 -0
  77. package/lib/syntax/getAllTypes.js +11 -0
  78. package/lib/syntax/getCustomTypeConfig.d.ts +8 -0
  79. package/lib/syntax/getCustomTypeConfig.js +53 -0
  80. package/lib/syntax/getHybridObjectName.d.ts +36 -0
  81. package/lib/syntax/getHybridObjectName.js +10 -0
  82. package/lib/syntax/getInterfaceProperties.d.ts +4 -0
  83. package/lib/syntax/getInterfaceProperties.js +9 -0
  84. package/lib/syntax/getReferencedTypes.d.ts +2 -0
  85. package/lib/syntax/getReferencedTypes.js +47 -0
  86. package/lib/syntax/helpers.d.ts +13 -0
  87. package/lib/syntax/helpers.js +53 -0
  88. package/lib/syntax/isCoreType.d.ts +9 -0
  89. package/lib/syntax/isCoreType.js +47 -0
  90. package/lib/syntax/kotlin/FbjniHybridObject.d.ts +3 -0
  91. package/lib/syntax/kotlin/FbjniHybridObject.js +261 -0
  92. package/lib/syntax/kotlin/JNINativeRegistrations.d.ts +8 -0
  93. package/lib/syntax/kotlin/JNINativeRegistrations.js +7 -0
  94. package/lib/syntax/kotlin/KotlinBoxedPrimitive.d.ts +7 -0
  95. package/lib/syntax/kotlin/KotlinBoxedPrimitive.js +17 -0
  96. package/lib/syntax/kotlin/KotlinCxxBridgedType.d.ts +19 -0
  97. package/lib/syntax/kotlin/KotlinCxxBridgedType.js +893 -0
  98. package/lib/syntax/kotlin/KotlinEnum.d.ts +3 -0
  99. package/lib/syntax/kotlin/KotlinEnum.js +113 -0
  100. package/lib/syntax/kotlin/KotlinFunction.d.ts +3 -0
  101. package/lib/syntax/kotlin/KotlinFunction.js +256 -0
  102. package/lib/syntax/kotlin/KotlinHybridObject.d.ts +3 -0
  103. package/lib/syntax/kotlin/KotlinHybridObject.js +177 -0
  104. package/lib/syntax/kotlin/KotlinHybridObjectRegistration.d.ts +17 -0
  105. package/lib/syntax/kotlin/KotlinHybridObjectRegistration.js +26 -0
  106. package/lib/syntax/kotlin/KotlinStruct.d.ts +3 -0
  107. package/lib/syntax/kotlin/KotlinStruct.js +172 -0
  108. package/lib/syntax/kotlin/KotlinVariant.d.ts +3 -0
  109. package/lib/syntax/kotlin/KotlinVariant.js +191 -0
  110. package/lib/syntax/swift/SwiftCxxBridgedType.d.ts +21 -0
  111. package/lib/syntax/swift/SwiftCxxBridgedType.js +819 -0
  112. package/lib/syntax/swift/SwiftCxxTypeHelper.d.ts +17 -0
  113. package/lib/syntax/swift/SwiftCxxTypeHelper.js +613 -0
  114. package/lib/syntax/swift/SwiftEnum.d.ts +3 -0
  115. package/lib/syntax/swift/SwiftEnum.js +52 -0
  116. package/lib/syntax/swift/SwiftFunction.d.ts +3 -0
  117. package/lib/syntax/swift/SwiftFunction.js +83 -0
  118. package/lib/syntax/swift/SwiftHybridObject.d.ts +3 -0
  119. package/lib/syntax/swift/SwiftHybridObject.js +103 -0
  120. package/lib/syntax/swift/SwiftHybridObjectBridge.d.ts +11 -0
  121. package/lib/syntax/swift/SwiftHybridObjectBridge.js +451 -0
  122. package/lib/syntax/swift/SwiftHybridObjectRegistration.d.ts +19 -0
  123. package/lib/syntax/swift/SwiftHybridObjectRegistration.js +42 -0
  124. package/lib/syntax/swift/SwiftStruct.d.ts +3 -0
  125. package/lib/syntax/swift/SwiftStruct.js +75 -0
  126. package/lib/syntax/swift/SwiftVariant.d.ts +3 -0
  127. package/lib/syntax/swift/SwiftVariant.js +58 -0
  128. package/lib/syntax/types/ArrayBufferType.d.ts +10 -0
  129. package/lib/syntax/types/ArrayBufferType.js +37 -0
  130. package/lib/syntax/types/ArrayType.d.ts +12 -0
  131. package/lib/syntax/types/ArrayType.js +52 -0
  132. package/lib/syntax/types/BigIntType.d.ts +10 -0
  133. package/lib/syntax/types/BigIntType.js +27 -0
  134. package/lib/syntax/types/BooleanType.d.ts +10 -0
  135. package/lib/syntax/types/BooleanType.js +27 -0
  136. package/lib/syntax/types/CustomType.d.ts +14 -0
  137. package/lib/syntax/types/CustomType.js +36 -0
  138. package/lib/syntax/types/DateType.d.ts +10 -0
  139. package/lib/syntax/types/DateType.js +35 -0
  140. package/lib/syntax/types/EnumType.d.ts +23 -0
  141. package/lib/syntax/types/EnumType.js +101 -0
  142. package/lib/syntax/types/ErrorType.d.ts +11 -0
  143. package/lib/syntax/types/ErrorType.js +37 -0
  144. package/lib/syntax/types/FunctionType.d.ts +29 -0
  145. package/lib/syntax/types/FunctionType.js +147 -0
  146. package/lib/syntax/types/HybridObjectBaseType.d.ts +11 -0
  147. package/lib/syntax/types/HybridObjectBaseType.js +38 -0
  148. package/lib/syntax/types/HybridObjectType.d.ts +23 -0
  149. package/lib/syntax/types/HybridObjectType.js +131 -0
  150. package/lib/syntax/types/MapType.d.ts +10 -0
  151. package/lib/syntax/types/MapType.js +37 -0
  152. package/lib/syntax/types/NamedWrappingType.d.ts +14 -0
  153. package/lib/syntax/types/NamedWrappingType.js +27 -0
  154. package/lib/syntax/types/NullType.d.ts +10 -0
  155. package/lib/syntax/types/NullType.js +23 -0
  156. package/lib/syntax/types/NumberType.d.ts +10 -0
  157. package/lib/syntax/types/NumberType.js +27 -0
  158. package/lib/syntax/types/OptionalType.d.ts +13 -0
  159. package/lib/syntax/types/OptionalType.js +59 -0
  160. package/lib/syntax/types/PromiseType.d.ts +16 -0
  161. package/lib/syntax/types/PromiseType.js +62 -0
  162. package/lib/syntax/types/RecordType.d.ts +13 -0
  163. package/lib/syntax/types/RecordType.js +47 -0
  164. package/lib/syntax/types/ResultWrappingType.d.ts +13 -0
  165. package/lib/syntax/types/ResultWrappingType.js +44 -0
  166. package/lib/syntax/types/StringType.d.ts +10 -0
  167. package/lib/syntax/types/StringType.js +35 -0
  168. package/lib/syntax/types/StructType.d.ts +14 -0
  169. package/lib/syntax/types/StructType.js +61 -0
  170. package/lib/syntax/types/TupleType.d.ts +12 -0
  171. package/lib/syntax/types/TupleType.js +39 -0
  172. package/lib/syntax/types/Type.d.ts +55 -0
  173. package/lib/syntax/types/Type.js +1 -0
  174. package/lib/syntax/types/VariantType.d.ts +19 -0
  175. package/lib/syntax/types/VariantType.js +75 -0
  176. package/lib/syntax/types/VoidType.d.ts +10 -0
  177. package/lib/syntax/types/VoidType.js +27 -0
  178. package/lib/syntax/types/getTypeAs.d.ts +2 -0
  179. package/lib/syntax/types/getTypeAs.js +12 -0
  180. package/lib/utils.d.ts +22 -0
  181. package/lib/utils.js +126 -0
  182. package/lib/views/CppHybridViewComponent.d.ts +14 -0
  183. package/lib/views/CppHybridViewComponent.js +254 -0
  184. package/lib/views/createHostComponentJs.d.ts +3 -0
  185. package/lib/views/createHostComponentJs.js +27 -0
  186. package/lib/views/kotlin/KotlinHybridViewManager.d.ts +3 -0
  187. package/lib/views/kotlin/KotlinHybridViewManager.js +229 -0
  188. package/lib/views/swift/SwiftHybridViewManager.d.ts +3 -0
  189. package/lib/views/swift/SwiftHybridViewManager.js +131 -0
  190. package/lib/writeFile.d.ts +5 -0
  191. package/lib/writeFile.js +19 -0
  192. package/package.json +58 -29
  193. package/src/Logger.ts +63 -0
  194. package/src/autolinking/Autolinking.ts +9 -0
  195. package/src/autolinking/android/createCMakeExtension.ts +123 -0
  196. package/src/autolinking/android/createGradleExtension.ts +43 -0
  197. package/src/autolinking/android/createHybridObjectInitializer.ts +174 -0
  198. package/src/autolinking/createAndroidAutolinking.ts +28 -0
  199. package/src/autolinking/createIOSAutolinking.ts +24 -0
  200. package/src/autolinking/ios/createHybridObjectInitializer.ts +112 -0
  201. package/src/autolinking/ios/createPodspecRubyExtension.ts +76 -0
  202. package/src/autolinking/ios/createSwiftCxxBridge.ts +137 -0
  203. package/src/autolinking/ios/createSwiftUmbrellaHeader.ts +90 -0
  204. package/src/config/NitroConfig.ts +139 -0
  205. package/src/config/NitroUserConfig.ts +105 -0
  206. package/src/config/getConfig.ts +91 -0
  207. package/src/createGitAttributes.ts +15 -0
  208. package/src/createPlatformSpec.ts +176 -0
  209. package/src/getFiles.ts +31 -0
  210. package/src/getPlatformSpecs.ts +202 -0
  211. package/src/index.ts +146 -0
  212. package/src/init.ts +186 -0
  213. package/src/nitrogen.ts +246 -0
  214. package/src/prettifyDirectory.ts +32 -0
  215. package/src/syntax/BridgedType.ts +59 -0
  216. package/src/syntax/CodeNode.ts +24 -0
  217. package/src/syntax/HybridObjectSpec.ts +14 -0
  218. package/src/syntax/Method.ts +154 -0
  219. package/src/syntax/Parameter.ts +81 -0
  220. package/src/syntax/Property.ts +203 -0
  221. package/src/syntax/SourceFile.ts +80 -0
  222. package/src/syntax/c++/CppEnum.ts +128 -0
  223. package/src/syntax/c++/CppHybridObject.ts +165 -0
  224. package/src/syntax/c++/CppHybridObjectRegistration.ts +39 -0
  225. package/src/syntax/c++/CppStruct.ts +129 -0
  226. package/src/syntax/c++/CppUnion.ts +105 -0
  227. package/src/syntax/c++/getForwardDeclaration.ts +19 -0
  228. package/src/syntax/c++/includeNitroHeader.ts +40 -0
  229. package/src/syntax/createType.ts +365 -0
  230. package/src/syntax/getAllTypes.ts +18 -0
  231. package/src/syntax/getCustomTypeConfig.ts +71 -0
  232. package/src/syntax/getHybridObjectName.ts +48 -0
  233. package/src/syntax/getInterfaceProperties.ts +21 -0
  234. package/src/syntax/getReferencedTypes.ts +57 -0
  235. package/src/syntax/helpers.ts +79 -0
  236. package/src/syntax/isCoreType.ts +60 -0
  237. package/src/syntax/kotlin/FbjniHybridObject.ts +313 -0
  238. package/src/syntax/kotlin/JNINativeRegistrations.ts +19 -0
  239. package/src/syntax/kotlin/KotlinBoxedPrimitive.ts +19 -0
  240. package/src/syntax/kotlin/KotlinCxxBridgedType.ts +942 -0
  241. package/src/syntax/kotlin/KotlinEnum.ts +130 -0
  242. package/src/syntax/kotlin/KotlinFunction.ts +277 -0
  243. package/src/syntax/kotlin/KotlinHybridObject.ts +205 -0
  244. package/src/syntax/kotlin/KotlinHybridObjectRegistration.ts +51 -0
  245. package/src/syntax/kotlin/KotlinStruct.ts +198 -0
  246. package/src/syntax/kotlin/KotlinVariant.ts +212 -0
  247. package/src/syntax/swift/SwiftCxxBridgedType.ts +874 -0
  248. package/src/syntax/swift/SwiftCxxTypeHelper.ts +674 -0
  249. package/src/syntax/swift/SwiftEnum.ts +65 -0
  250. package/src/syntax/swift/SwiftFunction.ts +91 -0
  251. package/src/syntax/swift/SwiftHybridObject.ts +121 -0
  252. package/src/syntax/swift/SwiftHybridObjectBridge.ts +522 -0
  253. package/src/syntax/swift/SwiftHybridObjectRegistration.ts +75 -0
  254. package/src/syntax/swift/SwiftStruct.ts +85 -0
  255. package/src/syntax/swift/SwiftVariant.ts +67 -0
  256. package/src/syntax/types/ArrayBufferType.ts +49 -0
  257. package/src/syntax/types/ArrayType.ts +62 -0
  258. package/src/syntax/types/BigIntType.ts +35 -0
  259. package/src/syntax/types/BooleanType.ts +35 -0
  260. package/src/syntax/types/CustomType.ts +47 -0
  261. package/src/syntax/types/DateType.ts +43 -0
  262. package/src/syntax/types/EnumType.ts +130 -0
  263. package/src/syntax/types/ErrorType.ts +44 -0
  264. package/src/syntax/types/FunctionType.ts +167 -0
  265. package/src/syntax/types/HybridObjectBaseType.ts +54 -0
  266. package/src/syntax/types/HybridObjectType.ts +198 -0
  267. package/src/syntax/types/MapType.ts +49 -0
  268. package/src/syntax/types/NamedWrappingType.ts +33 -0
  269. package/src/syntax/types/NullType.ts +30 -0
  270. package/src/syntax/types/NumberType.ts +34 -0
  271. package/src/syntax/types/OptionalType.ts +66 -0
  272. package/src/syntax/types/PromiseType.ts +72 -0
  273. package/src/syntax/types/RecordType.ts +56 -0
  274. package/src/syntax/types/ResultWrappingType.ts +53 -0
  275. package/src/syntax/types/StringType.ts +44 -0
  276. package/src/syntax/types/StructType.ts +83 -0
  277. package/src/syntax/types/TupleType.ts +53 -0
  278. package/src/syntax/types/Type.ts +82 -0
  279. package/src/syntax/types/VariantType.ts +92 -0
  280. package/src/syntax/types/VoidType.ts +34 -0
  281. package/src/syntax/types/getTypeAs.ts +15 -0
  282. package/src/utils.ts +162 -0
  283. package/src/views/CppHybridViewComponent.ts +301 -0
  284. package/src/views/createHostComponentJs.ts +34 -0
  285. package/src/views/kotlin/KotlinHybridViewManager.ts +258 -0
  286. package/src/views/swift/SwiftHybridViewManager.ts +153 -0
  287. package/src/writeFile.ts +27 -0
  288. package/.jshintignore +0 -6
  289. package/.jshintrc +0 -3
  290. package/.npmignore +0 -3
  291. package/.travis.yml +0 -13
  292. package/LICENSE +0 -13
  293. package/browser/nitrogen-min.js +0 -3
  294. package/browser/nitrogen.js +0 -6369
  295. package/lib/apiKey.js +0 -67
  296. package/lib/blob.js +0 -57
  297. package/lib/commandManager.js +0 -350
  298. package/lib/device.js +0 -19
  299. package/lib/memoryStore.js +0 -24
  300. package/lib/message.js +0 -298
  301. package/lib/permission.js +0 -121
  302. package/lib/principal.js +0 -330
  303. package/lib/service.js +0 -349
  304. package/lib/session.js +0 -494
  305. package/lib/user.js +0 -20
  306. package/publish +0 -2
  307. package/scripts/build-documentation +0 -4
  308. package/scripts/build-module +0 -27
  309. package/scripts/module.js +0 -12
  310. package/scripts/postamble.js +0 -1
  311. package/scripts/preamble.js +0 -2
  312. package/scripts/run-test-server +0 -9
  313. package/test/config.js +0 -12
  314. package/test/fixtures/images/image.jpg +0 -0
  315. package/test/fixtures/images/motion0.jpg +0 -0
  316. package/test/fixtures/images/motion1.jpg +0 -0
  317. package/test/fixtures/images/motion2.jpg +0 -0
  318. package/test/fixtures/index.js +0 -76
  319. package/test/main.js +0 -5
  320. package/test/memoryStore.js +0 -22
  321. package/test/mocha.opts +0 -3
  322. package/test/units/apiKey.js +0 -46
  323. package/test/units/blob.js +0 -35
  324. package/test/units/commandManager.js +0 -67
  325. package/test/units/device.js +0 -26
  326. package/test/units/heartbeat.js +0 -28
  327. package/test/units/message.js +0 -79
  328. package/test/units/permissions.js +0 -43
  329. package/test/units/principal.js +0 -116
  330. package/test/units/service.js +0 -92
  331. package/test/units/session.js +0 -97
  332. package/test/units/user.js +0 -48
  333. package/yuidoc.json +0 -8
@@ -0,0 +1,131 @@
1
+ import { createViewComponentShadowNodeFiles, getViewComponentNames, } from '../CppHybridViewComponent.js';
2
+ import { createFileMetadataString, escapeCppName, } from '../../syntax/helpers.js';
3
+ import { getUmbrellaHeaderName } from '../../autolinking/ios/createSwiftUmbrellaHeader.js';
4
+ import { getHybridObjectName } from '../../syntax/getHybridObjectName.js';
5
+ import { getHybridObjectConstructorCall } from '../../syntax/swift/SwiftHybridObjectRegistration.js';
6
+ import { indent } from '../../utils.js';
7
+ import { SwiftCxxBridgedType } from '../../syntax/swift/SwiftCxxBridgedType.js';
8
+ export function createSwiftHybridViewManager(spec) {
9
+ const cppFiles = createViewComponentShadowNodeFiles(spec);
10
+ const namespace = spec.config.getCxxNamespace('c++');
11
+ const swiftNamespace = spec.config.getIosModuleName();
12
+ const { HybridTSpec, HybridTSpecSwift, HybridTSpecCxx } = getHybridObjectName(spec.name);
13
+ const { component, descriptorClassName, propsClassName } = getViewComponentNames(spec);
14
+ const autolinking = spec.config.getAutolinkedHybridObjects();
15
+ const viewImplementation = autolinking[spec.name]?.swift;
16
+ if (viewImplementation == null) {
17
+ throw new Error(`Cannot create Swift HybridView ViewManager for ${spec.name} - it is not autolinked in nitro.json!`);
18
+ }
19
+ const propAssignments = spec.properties.map((p) => {
20
+ const name = escapeCppName(p.name);
21
+ const setter = p.getSetterName('swift');
22
+ const bridge = new SwiftCxxBridgedType(p.type, false);
23
+ const parse = bridge.parseFromCppToSwift(`newViewProps.${name}.value`, 'c++');
24
+ return `
25
+ // ${p.jsSignature}
26
+ if (newViewProps.${name}.isDirty) {
27
+ swiftPart.${setter}(${indent(parse, ' ')});
28
+ newViewProps.${name}.isDirty = false;
29
+ }
30
+ `.trim();
31
+ });
32
+ const mmFile = `
33
+ ${createFileMetadataString(`${component}.mm`)}
34
+
35
+ #import "${component}.hpp"
36
+ #import <memory>
37
+ #import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
38
+ #import <React/RCTViewComponentView.h>
39
+ #import <React/RCTComponentViewFactory.h>
40
+ #import <React/UIView+ComponentViewProtocol.h>
41
+ #import <NitroModules/NitroDefines.hpp>
42
+ #import <UIKit/UIKit.h>
43
+
44
+ #import "${HybridTSpecSwift}.hpp"
45
+ #import "${getUmbrellaHeaderName()}"
46
+
47
+ using namespace facebook;
48
+ using namespace ${namespace};
49
+ using namespace ${namespace}::views;
50
+
51
+ /**
52
+ * Represents the React Native View holder for the Nitro "${spec.name}" HybridView.
53
+ */
54
+ @interface ${component}: RCTViewComponentView
55
+ @end
56
+
57
+ @implementation ${component} {
58
+ std::shared_ptr<${HybridTSpecSwift}> _hybridView;
59
+ }
60
+
61
+ + (void) load {
62
+ [super load];
63
+ [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[${component} class]];
64
+ }
65
+
66
+ + (react::ComponentDescriptorProvider) componentDescriptorProvider {
67
+ return react::concreteComponentDescriptorProvider<${descriptorClassName}>();
68
+ }
69
+
70
+ - (instancetype) init {
71
+ if (self = [super init]) {
72
+ std::shared_ptr<${HybridTSpec}> hybridView = ${getHybridObjectConstructorCall(spec.name)}
73
+ _hybridView = std::dynamic_pointer_cast<${HybridTSpecSwift}>(hybridView);
74
+ [self updateView];
75
+ }
76
+ return self;
77
+ }
78
+
79
+ - (void) updateView {
80
+ // 1. Get Swift part
81
+ ${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart();
82
+
83
+ // 2. Get UIView*
84
+ void* viewUnsafe = swiftPart.getView();
85
+ UIView* view = (__bridge_transfer UIView*) viewUnsafe;
86
+
87
+ // 3. Update RCTViewComponentView's [contentView]
88
+ [self setContentView:view];
89
+ }
90
+
91
+ - (void) updateProps:(const std::shared_ptr<const react::Props>&)props
92
+ oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
93
+ // 1. Downcast props
94
+ const auto& newViewPropsConst = *std::static_pointer_cast<${propsClassName} const>(props);
95
+ auto& newViewProps = const_cast<${propsClassName}&>(newViewPropsConst);
96
+ ${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart();
97
+
98
+ // 2. Update each prop individually
99
+ swiftPart.beforeUpdate();
100
+
101
+ ${indent(propAssignments.join('\n'), ' ')}
102
+
103
+ swiftPart.afterUpdate();
104
+
105
+ // 3. Update hybridRef if it changed
106
+ if (newViewProps.hybridRef.isDirty) {
107
+ // hybridRef changed - call it with new this
108
+ const auto& maybeFunc = newViewProps.hybridRef.value;
109
+ if (maybeFunc.has_value()) {
110
+ maybeFunc.value()(_hybridView);
111
+ }
112
+ newViewProps.hybridRef.isDirty = false;
113
+ }
114
+
115
+ // 4. Continue in base class
116
+ [super updateProps:props oldProps:oldProps];
117
+ }
118
+
119
+ @end
120
+ `;
121
+ return [
122
+ ...cppFiles,
123
+ {
124
+ content: mmFile,
125
+ language: 'c++',
126
+ name: `${component}.mm`,
127
+ platform: 'ios',
128
+ subdirectory: ['views'],
129
+ },
130
+ ];
131
+ }
@@ -0,0 +1,5 @@
1
+ import type { SourceFile } from './syntax/SourceFile.js';
2
+ /**
3
+ * Writes the given file to disk and returns it's actual path.
4
+ */
5
+ export declare function writeFile(basePath: string, file: SourceFile): Promise<string>;
@@ -0,0 +1,19 @@
1
+ import path from 'path';
2
+ import { promises as fs } from 'fs';
3
+ import { capitalizeName } from './utils.js';
4
+ import chalk from 'chalk';
5
+ import { Logger } from './Logger.js';
6
+ /**
7
+ * Writes the given file to disk and returns it's actual path.
8
+ */
9
+ export async function writeFile(basePath, file) {
10
+ const filepath = path.join(basePath, ...file.subdirectory, file.name);
11
+ const language = capitalizeName(file.language);
12
+ Logger.debug(` ${chalk.dim(language)}: Creating ${file.name}...`);
13
+ const dir = path.dirname(filepath);
14
+ // Create directory if it doesn't exist yet
15
+ await fs.mkdir(dir, { recursive: true });
16
+ // Write file
17
+ await fs.writeFile(filepath, file.content.trim() + '\n', 'utf8');
18
+ return filepath;
19
+ }
package/package.json CHANGED
@@ -1,40 +1,69 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "homepage": "https://github.com/nitrogenjs/client",
4
- "author": "Tim Park <timfpark@gmail.com>",
5
- "licenses": [
6
- {
7
- "type": "Apache",
8
- "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
9
- }
3
+ "version": "0.29.4",
4
+ "description": "The code-generator for react-native-nitro-modules.",
5
+ "main": "lib/index",
6
+ "types": "lib/index.d.ts",
7
+ "source": "src/index",
8
+ "type": "module",
9
+ "files": [
10
+ "lib",
11
+ "src",
12
+ "README.md"
10
13
  ],
11
- "main": "./lib",
14
+ "bin": "./lib/index.js",
12
15
  "repository": {
13
16
  "type": "git",
14
- "url": "https://github.com/nitrogenjs/client.git"
17
+ "url": "git+https://github.com/mrousavy/nitro.git"
15
18
  },
16
- "version": "0.2.23",
17
- "dependencies": {
18
- "async": "~0.2.10",
19
- "request": "~2.36.0",
20
- "socket.io-client": "~0.9.16"
19
+ "author": "Marc Rousavy <me@mrousavy.com> (https://github.com/mrousavy)",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/mrousavy/nitro/issues"
21
23
  },
22
- "devDependencies": {
23
- "nitrogen-browser-request": "~0.3.2",
24
- "mocha": "~1.17.1",
25
- "uglify-js": "~2.4.13",
26
- "jsdox": "~0.2.6"
24
+ "homepage": "https://github.com/mrousavy/nitro#readme",
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "scripts": {
29
- "test": "mocha",
30
- "postpublish": "scripts/build-documentation"
29
+ "postinstall": "bun build || exit 0;",
30
+ "build": "bun tsc",
31
+ "start": "tsc && node lib/index.js",
32
+ "typecheck": "tsc --noEmit",
33
+ "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
34
+ "lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
35
+ "release": "release-it"
36
+ },
37
+ "dependencies": {
38
+ "chalk": "^5.3.0",
39
+ "react-native-nitro-modules": "^0.29.4",
40
+ "ts-morph": "^25.0.0",
41
+ "yargs": "^17.7.2",
42
+ "zod": "^4.0.5"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^22.8.4"
31
46
  },
32
- "keywords": [
33
- "devices",
34
- "iot",
35
- "nitrogen",
36
- "pi",
37
- "raspberry",
38
- "raspberry pi"
39
- ]
47
+ "release-it": {
48
+ "npm": {
49
+ "publish": true
50
+ },
51
+ "git": false,
52
+ "github": {
53
+ "release": false
54
+ },
55
+ "hooks": {
56
+ "before:init": "bun typecheck && bun lint",
57
+ "after:bump": "bun run build"
58
+ },
59
+ "plugins": {
60
+ "@release-it/bumper": {
61
+ "out": {
62
+ "file": "package.json",
63
+ "path": "dependencies.react-native-nitro-modules",
64
+ "versionPrefix": "^"
65
+ }
66
+ }
67
+ }
68
+ }
40
69
  }
package/src/Logger.ts ADDED
@@ -0,0 +1,63 @@
1
+ export type LogLevel = 'debug' | 'info' | 'warning' | 'error'
2
+ const levelMap = {
3
+ debug: 0,
4
+ info: 1,
5
+ warning: 2,
6
+ error: 3,
7
+ } as const
8
+ let currentLogLevel: LogLevel = 'info'
9
+
10
+ export function isValidLogLevel(level: unknown): level is LogLevel {
11
+ // @ts-expect-error
12
+ return typeof levelMap[level] === 'number'
13
+ }
14
+
15
+ export function setLogLevel(level: LogLevel) {
16
+ currentLogLevel = level
17
+ }
18
+
19
+ function isAtLeast(level: LogLevel): boolean {
20
+ return levelMap[level] >= levelMap[currentLogLevel]
21
+ }
22
+
23
+ let indentation = 0
24
+
25
+ function getIndentation(): string {
26
+ let string = ''
27
+ for (let i = 0; i < indentation; i++) {
28
+ string += ' '
29
+ }
30
+ return string
31
+ }
32
+
33
+ export const Logger = {
34
+ withIndented(callback: () => void) {
35
+ try {
36
+ indentation++
37
+ callback()
38
+ } finally {
39
+ indentation--
40
+ }
41
+ },
42
+
43
+ debug(message: string, ...extra: unknown[]) {
44
+ if (isAtLeast('debug')) {
45
+ console.debug(getIndentation() + message, ...extra)
46
+ }
47
+ },
48
+ info(message: string, ...extra: unknown[]) {
49
+ if (isAtLeast('info')) {
50
+ console.info(getIndentation() + message, ...extra)
51
+ }
52
+ },
53
+ warn(message: string, ...extra: unknown[]) {
54
+ if (isAtLeast('warning')) {
55
+ console.warn(getIndentation() + message, ...extra)
56
+ }
57
+ },
58
+ error(message: string, ...extra: unknown[]) {
59
+ if (isAtLeast('error')) {
60
+ console.error(getIndentation() + message, ...extra)
61
+ }
62
+ },
63
+ }
@@ -0,0 +1,9 @@
1
+ import type { Platform } from '../getPlatformSpecs.js'
2
+ import type { SourceFile } from '../syntax/SourceFile.js'
3
+
4
+ type AutolinkingFile = Omit<SourceFile, 'language'>
5
+
6
+ export interface Autolinking {
7
+ platform: Platform
8
+ sourceFiles: AutolinkingFile[]
9
+ }
@@ -0,0 +1,123 @@
1
+ import { NitroConfig } from '../../config/NitroConfig.js'
2
+ import { indent, toLowerCamelCase, toUnixPath } from '../../utils.js'
3
+ import {
4
+ createFileMetadataString,
5
+ getRelativeDirectory,
6
+ getRelativeDirectoryGenerated,
7
+ isCppFile,
8
+ isNotDuplicate,
9
+ } from '../../syntax/helpers.js'
10
+ import type { SourceFile } from '../../syntax/SourceFile.js'
11
+
12
+ export interface CMakeFile extends Omit<SourceFile, 'language'> {
13
+ language: 'cmake'
14
+ }
15
+
16
+ export function getBuildingWithGeneratedCmakeDefinition(): string {
17
+ const moduleName = NitroConfig.current.getAndroidCxxLibName()
18
+ const upper = toLowerCamelCase(moduleName).toUpperCase()
19
+ return `BUILDING_${upper}_WITH_GENERATED_CMAKE_PROJECT`
20
+ }
21
+
22
+ export function createCMakeExtension(files: SourceFile[]): CMakeFile {
23
+ const name = NitroConfig.current.getAndroidCxxLibName()
24
+ const sharedFiles = files
25
+ .filter((f) => f.platform === 'shared' && isCppFile(f))
26
+ .map((f) => getRelativeDirectory(f))
27
+ .map((p) => toUnixPath(p))
28
+ .filter(isNotDuplicate)
29
+ const androidFiles = files
30
+ .filter((f) => f.platform === 'android' && isCppFile(f))
31
+ .map((f) => getRelativeDirectory(f))
32
+ .map((p) => toUnixPath(p))
33
+ .filter(isNotDuplicate)
34
+ const autolinkingFilePath = getRelativeDirectoryGenerated(
35
+ 'android',
36
+ `${name}OnLoad.cpp`
37
+ )
38
+ const autolinkingFile = toUnixPath(autolinkingFilePath)
39
+ const buildingWithDefinition = getBuildingWithGeneratedCmakeDefinition()
40
+
41
+ const code = `
42
+ ${createFileMetadataString(`${name}+autolinking.cmake`, '#')}
43
+
44
+ # This is a CMake file that adds all files generated by Nitrogen
45
+ # to the current CMake project.
46
+ #
47
+ # To use it, add this to your CMakeLists.txt:
48
+ # \`\`\`cmake
49
+ # include(\${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/${name}+autolinking.cmake)
50
+ # \`\`\`
51
+
52
+ # Add all headers that were generated by Nitrogen
53
+ include_directories(
54
+ "../nitrogen/generated/shared/c++"
55
+ "../nitrogen/generated/android/c++"
56
+ "../nitrogen/generated/android/"
57
+ )
58
+
59
+ # Add all .cpp sources that were generated by Nitrogen
60
+ target_sources(
61
+ # CMake project name (Android C++ library name)
62
+ ${name} PRIVATE
63
+ # Autolinking Setup
64
+ ${autolinkingFile}
65
+ # Shared Nitrogen C++ sources
66
+ ${indent(sharedFiles.join('\n'), ' ')}
67
+ # Android-specific Nitrogen C++ sources
68
+ ${indent(androidFiles.join('\n'), ' ')}
69
+ )
70
+
71
+ # Define a flag to check if we are building properly
72
+ add_definitions(-D${buildingWithDefinition})
73
+
74
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
75
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
76
+ target_compile_definitions(
77
+ ${name} PRIVATE
78
+ -DFOLLY_NO_CONFIG=1
79
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
80
+ -DFOLLY_USE_LIBCPP=1
81
+ -DFOLLY_CFG_NO_COROUTINES=1
82
+ -DFOLLY_MOBILE=1
83
+ -DFOLLY_HAVE_RECVMMSG=1
84
+ -DFOLLY_HAVE_PTHREAD=1
85
+ # Once we target android-23 above, we can comment
86
+ # the following line. NDK uses GNU style stderror_r() after API 23.
87
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
88
+ )
89
+
90
+ # Add all libraries required by the generated specs
91
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
92
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
93
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
94
+
95
+ # Link all libraries together
96
+ target_link_libraries(
97
+ ${name}
98
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
99
+ ReactAndroid::jsi # <-- RN: JSI
100
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
101
+ )
102
+
103
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
104
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
105
+ target_link_libraries(
106
+ ${name}
107
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
108
+ )
109
+ else()
110
+ target_link_libraries(
111
+ ${name}
112
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
113
+ )
114
+ endif()
115
+ `.trim()
116
+ return {
117
+ content: code,
118
+ language: 'cmake',
119
+ name: `${name}+autolinking.cmake`,
120
+ platform: 'android',
121
+ subdirectory: [],
122
+ }
123
+ }
@@ -0,0 +1,43 @@
1
+ import { NitroConfig } from '../../config/NitroConfig.js'
2
+ import { createFileMetadataString } from '../../syntax/helpers.js'
3
+ import type { SourceFile } from '../../syntax/SourceFile.js'
4
+
5
+ export interface GradleFile extends Omit<SourceFile, 'language'> {
6
+ language: 'gradle'
7
+ }
8
+
9
+ export function createGradleExtension(): GradleFile {
10
+ const name = NitroConfig.current.getAndroidCxxLibName()
11
+
12
+ const code = `
13
+ ${createFileMetadataString(`${name}+autolinking.gradle`)}
14
+
15
+ /// This is a Gradle file that adds all files generated by Nitrogen
16
+ /// to the current Gradle project.
17
+ ///
18
+ /// To use it, add this to your build.gradle:
19
+ /// \`\`\`gradle
20
+ /// apply from: '../nitrogen/generated/android/${name}+autolinking.gradle'
21
+ /// \`\`\`
22
+
23
+ logger.warn("[NitroModules] 🔥 ${name} is boosted by nitro!")
24
+
25
+ android {
26
+ sourceSets {
27
+ main {
28
+ java.srcDirs += [
29
+ // Nitrogen files
30
+ "\${project.projectDir}/../nitrogen/generated/android/kotlin"
31
+ ]
32
+ }
33
+ }
34
+ }
35
+ `.trim()
36
+ return {
37
+ content: code,
38
+ language: 'gradle',
39
+ name: `${name}+autolinking.gradle`,
40
+ platform: 'android',
41
+ subdirectory: [],
42
+ }
43
+ }
@@ -0,0 +1,174 @@
1
+ import { NitroConfig } from '../../config/NitroConfig.js'
2
+ import { createCppHybridObjectRegistration } from '../../syntax/c++/CppHybridObjectRegistration.js'
3
+ import { includeHeader } from '../../syntax/c++/includeNitroHeader.js'
4
+ import {
5
+ createFileMetadataString,
6
+ isNotDuplicate,
7
+ } from '../../syntax/helpers.js'
8
+ import { getJNINativeRegistrations } from '../../syntax/kotlin/JNINativeRegistrations.js'
9
+ import { createJNIHybridObjectRegistration } from '../../syntax/kotlin/KotlinHybridObjectRegistration.js'
10
+ import type { SourceFile, SourceImport } from '../../syntax/SourceFile.js'
11
+ import { indent } from '../../utils.js'
12
+ import { getBuildingWithGeneratedCmakeDefinition } from './createCMakeExtension.js'
13
+
14
+ export function createHybridObjectIntializer(): SourceFile[] {
15
+ const cxxNamespace = NitroConfig.current.getCxxNamespace('c++')
16
+ const cppLibName = NitroConfig.current.getAndroidCxxLibName()
17
+ const javaNamespace = NitroConfig.current.getAndroidPackage('java/kotlin')
18
+ const autolinkingClassName = `${NitroConfig.current.getAndroidCxxLibName()}OnLoad`
19
+
20
+ const jniRegistrations = getJNINativeRegistrations()
21
+ .map((r) => `${r.namespace}::${r.className}::registerNatives();`)
22
+ .filter(isNotDuplicate)
23
+
24
+ const autolinkedHybridObjects =
25
+ NitroConfig.current.getAutolinkedHybridObjects()
26
+
27
+ const cppHybridObjectImports: SourceImport[] = []
28
+ const cppRegistrations: string[] = []
29
+ for (const hybridObjectName of Object.keys(autolinkedHybridObjects)) {
30
+ const config = autolinkedHybridObjects[hybridObjectName]
31
+
32
+ if (config?.cpp != null) {
33
+ // Autolink a C++ HybridObject!
34
+ const { cppCode, requiredImports } = createCppHybridObjectRegistration({
35
+ hybridObjectName: hybridObjectName,
36
+ cppClassName: config.cpp,
37
+ })
38
+ cppHybridObjectImports.push(...requiredImports)
39
+ cppRegistrations.push(cppCode)
40
+ }
41
+ if (config?.kotlin != null) {
42
+ // Autolink a Kotlin HybridObject through JNI/C++!
43
+ const { cppCode, requiredImports } = createJNIHybridObjectRegistration({
44
+ hybridObjectName: hybridObjectName,
45
+ jniClassName: config.kotlin,
46
+ })
47
+ cppHybridObjectImports.push(...requiredImports)
48
+ cppRegistrations.push(cppCode)
49
+ }
50
+ }
51
+
52
+ const buildingWithDefinition = getBuildingWithGeneratedCmakeDefinition()
53
+
54
+ const includes = [
55
+ ...getJNINativeRegistrations().map((r) => includeHeader(r.import)),
56
+ ...cppHybridObjectImports.map((i) => includeHeader(i)),
57
+ ]
58
+ .filter(isNotDuplicate)
59
+ .join('\n')
60
+
61
+ const hppCode = `
62
+ ${createFileMetadataString(`${autolinkingClassName}.hpp`)}
63
+
64
+ #include <jni.h>
65
+ #include <NitroModules/NitroDefines.hpp>
66
+
67
+ namespace ${cxxNamespace} {
68
+
69
+ /**
70
+ * Initializes the native (C++) part of ${cppLibName}, and autolinks all Hybrid Objects.
71
+ * Call this in your \`JNI_OnLoad\` function (probably inside \`cpp-adapter.cpp\`).
72
+ * Example:
73
+ * \`\`\`cpp (cpp-adapter.cpp)
74
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
75
+ * return ${cxxNamespace}::initialize(vm);
76
+ * }
77
+ * \`\`\`
78
+ */
79
+ int initialize(JavaVM* vm);
80
+
81
+ } // namespace ${cxxNamespace}
82
+
83
+ `
84
+ const cppCode = `
85
+ ${createFileMetadataString(`${autolinkingClassName}.cpp`)}
86
+
87
+ #ifndef ${buildingWithDefinition}
88
+ #error ${autolinkingClassName}.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
89
+ #endif
90
+
91
+ #include "${autolinkingClassName}.hpp"
92
+
93
+ #include <jni.h>
94
+ #include <fbjni/fbjni.h>
95
+ #include <NitroModules/HybridObjectRegistry.hpp>
96
+
97
+ ${includes}
98
+
99
+ namespace ${cxxNamespace} {
100
+
101
+ int initialize(JavaVM* vm) {
102
+ using namespace margelo::nitro;
103
+ using namespace ${cxxNamespace};
104
+ using namespace facebook;
105
+
106
+ return facebook::jni::initialize(vm, [] {
107
+ // Register native JNI methods
108
+ ${indent(jniRegistrations.join('\n'), ' ')}
109
+
110
+ // Register Nitro Hybrid Objects
111
+ ${indent(cppRegistrations.join('\n'), ' ')}
112
+ });
113
+ }
114
+
115
+ } // namespace ${cxxNamespace}
116
+ `.trim()
117
+
118
+ const kotlinCode = `
119
+ ${createFileMetadataString(`${autolinkingClassName}.kt`)}
120
+
121
+ package ${javaNamespace}
122
+
123
+ import android.util.Log
124
+
125
+ internal class ${autolinkingClassName} {
126
+ companion object {
127
+ private const val TAG = "${autolinkingClassName}"
128
+ private var didLoad = false
129
+ /**
130
+ * Initializes the native part of "${cppLibName}".
131
+ * This method is idempotent and can be called more than once.
132
+ */
133
+ @JvmStatic
134
+ fun initializeNative() {
135
+ if (didLoad) return
136
+ try {
137
+ Log.i(TAG, "Loading ${cppLibName} C++ library...")
138
+ System.loadLibrary("${cppLibName}")
139
+ Log.i(TAG, "Successfully loaded ${cppLibName} C++ library!")
140
+ didLoad = true
141
+ } catch (e: Error) {
142
+ Log.e(TAG, "Failed to load ${cppLibName} C++ library! Is it properly installed and linked? " +
143
+ "Is the name correct? (see \`CMakeLists.txt\`, at \`add_library(...)\`)", e)
144
+ throw e
145
+ }
146
+ }
147
+ }
148
+ }
149
+ `.trim()
150
+
151
+ return [
152
+ {
153
+ content: hppCode,
154
+ language: 'c++',
155
+ name: `${autolinkingClassName}.hpp`,
156
+ platform: 'android',
157
+ subdirectory: [],
158
+ },
159
+ {
160
+ content: cppCode,
161
+ language: 'c++',
162
+ name: `${autolinkingClassName}.cpp`,
163
+ platform: 'android',
164
+ subdirectory: [],
165
+ },
166
+ {
167
+ content: kotlinCode,
168
+ language: 'kotlin',
169
+ name: `${autolinkingClassName}.kt`,
170
+ platform: 'android',
171
+ subdirectory: ['kotlin', ...javaNamespace.split('.')],
172
+ },
173
+ ]
174
+ }