@react-native/codegen 0.75.0-nightly-20240409-881c0bc89 → 0.75.0-nightly-20240411-46b6453eb

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.
@@ -41,11 +41,14 @@ namespace facebook::react {
41
41
  };
42
42
  } // namespace facebook::react`;
43
43
  const HeaderFileTemplate = ({
44
+ headerFileName,
44
45
  moduleDeclarations,
45
46
  structInlineMethods,
46
47
  assumeNonnull,
47
- }) =>
48
- `/**
48
+ }) => {
49
+ const headerFileNameWithNoExt = headerFileName.replace(/\.h$/, '');
50
+ return (
51
+ `/**
49
52
  * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
50
53
  *
51
54
  * Do not edit this file as changes may cause incorrect behavior and will be lost
@@ -61,6 +64,11 @@ const HeaderFileTemplate = ({
61
64
  #ifndef __cplusplus
62
65
  #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
63
66
  #endif
67
+
68
+ // Avoid multiple includes of ${headerFileNameWithNoExt} symbols
69
+ #ifndef ${headerFileNameWithNoExt}_H
70
+ #define ${headerFileNameWithNoExt}_H
71
+
64
72
  #import <Foundation/Foundation.h>
65
73
  #import <RCTRequired/RCTRequired.h>
66
74
  #import <RCTTypeSafety/RCTConvertHelpers.h>
@@ -73,11 +81,15 @@ const HeaderFileTemplate = ({
73
81
  #import <vector>
74
82
 
75
83
  ` +
76
- (assumeNonnull ? '\nNS_ASSUME_NONNULL_BEGIN\n' : '') +
77
- moduleDeclarations +
78
- '\n' +
79
- structInlineMethods +
80
- (assumeNonnull ? '\nNS_ASSUME_NONNULL_END\n' : '\n');
84
+ (assumeNonnull ? '\nNS_ASSUME_NONNULL_BEGIN\n' : '') +
85
+ moduleDeclarations +
86
+ '\n' +
87
+ structInlineMethods +
88
+ (assumeNonnull ? '\nNS_ASSUME_NONNULL_END\n' : '\n') +
89
+ `#endif // ${headerFileNameWithNoExt}_H` +
90
+ '\n'
91
+ );
92
+ };
81
93
  const SourceFileTemplate = ({headerFileName, moduleImplementations}) => `/**
82
94
  * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
83
95
  *
@@ -166,6 +178,7 @@ module.exports = {
166
178
  }
167
179
  const headerFileName = `${libraryName}.h`;
168
180
  const headerFile = HeaderFileTemplate({
181
+ headerFileName,
169
182
  moduleDeclarations: moduleDeclarations.join('\n'),
170
183
  structInlineMethods: structInlineMethods.join('\n'),
171
184
  assumeNonnull,
@@ -46,15 +46,20 @@ namespace facebook::react {
46
46
  } // namespace facebook::react`;
47
47
 
48
48
  const HeaderFileTemplate = ({
49
+ headerFileName,
49
50
  moduleDeclarations,
50
51
  structInlineMethods,
51
52
  assumeNonnull,
52
53
  }: $ReadOnly<{
54
+ headerFileName: string,
53
55
  moduleDeclarations: string,
54
56
  structInlineMethods: string,
55
57
  assumeNonnull: boolean,
56
- }>) =>
57
- `/**
58
+ }>) => {
59
+ const headerFileNameWithNoExt = headerFileName.replace(/\.h$/, '');
60
+
61
+ return (
62
+ `/**
58
63
  * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
59
64
  *
60
65
  * Do not edit this file as changes may cause incorrect behavior and will be lost
@@ -70,6 +75,11 @@ const HeaderFileTemplate = ({
70
75
  #ifndef __cplusplus
71
76
  #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
72
77
  #endif
78
+
79
+ // Avoid multiple includes of ${headerFileNameWithNoExt} symbols
80
+ #ifndef ${headerFileNameWithNoExt}_H
81
+ #define ${headerFileNameWithNoExt}_H
82
+
73
83
  #import <Foundation/Foundation.h>
74
84
  #import <RCTRequired/RCTRequired.h>
75
85
  #import <RCTTypeSafety/RCTConvertHelpers.h>
@@ -82,11 +92,15 @@ const HeaderFileTemplate = ({
82
92
  #import <vector>
83
93
 
84
94
  ` +
85
- (assumeNonnull ? '\nNS_ASSUME_NONNULL_BEGIN\n' : '') +
86
- moduleDeclarations +
87
- '\n' +
88
- structInlineMethods +
89
- (assumeNonnull ? '\nNS_ASSUME_NONNULL_END\n' : '\n');
95
+ (assumeNonnull ? '\nNS_ASSUME_NONNULL_BEGIN\n' : '') +
96
+ moduleDeclarations +
97
+ '\n' +
98
+ structInlineMethods +
99
+ (assumeNonnull ? '\nNS_ASSUME_NONNULL_END\n' : '\n') +
100
+ `#endif // ${headerFileNameWithNoExt}_H` +
101
+ '\n'
102
+ );
103
+ };
90
104
 
91
105
  const SourceFileTemplate = ({
92
106
  headerFileName,
@@ -197,6 +211,7 @@ module.exports = {
197
211
 
198
212
  const headerFileName = `${libraryName}.h`;
199
213
  const headerFile = HeaderFileTemplate({
214
+ headerFileName,
200
215
  moduleDeclarations: moduleDeclarations.join('\n'),
201
216
  structInlineMethods: structInlineMethods.join('\n'),
202
217
  assumeNonnull,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.75.0-nightly-20240409-881c0bc89",
3
+ "version": "0.75.0-nightly-20240411-46b6453eb",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {