@react-native/codegen 0.82.0-nightly-20250715-7f224941b → 0.82.0-nightly-20250720-8488eaece
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.
|
@@ -33,65 +33,81 @@ const FileTemplate = ({
|
|
|
33
33
|
* ${'@'}generated by codegen project: GeneratePropsJavaInterface.js
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
package ${packageName}
|
|
36
|
+
package ${packageName};
|
|
37
37
|
|
|
38
38
|
${imports}
|
|
39
39
|
|
|
40
|
-
public interface ${className}<T
|
|
40
|
+
public interface ${className}<T extends ${extendClasses}> extends ViewManagerWithGeneratedInterface {
|
|
41
41
|
${methods}
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
|
+
function addNullable(imports) {
|
|
45
|
+
imports.add('import androidx.annotation.Nullable;');
|
|
46
|
+
}
|
|
44
47
|
function getJavaValueForProp(prop, imports) {
|
|
45
48
|
const typeAnnotation = prop.typeAnnotation;
|
|
46
49
|
switch (typeAnnotation.type) {
|
|
47
50
|
case 'BooleanTypeAnnotation':
|
|
48
51
|
if (typeAnnotation.default === null) {
|
|
49
|
-
|
|
52
|
+
addNullable(imports);
|
|
53
|
+
return '@Nullable Boolean value';
|
|
50
54
|
} else {
|
|
51
|
-
return 'value
|
|
55
|
+
return 'boolean value';
|
|
52
56
|
}
|
|
53
57
|
case 'StringTypeAnnotation':
|
|
54
|
-
|
|
58
|
+
addNullable(imports);
|
|
59
|
+
return '@Nullable String value';
|
|
55
60
|
case 'Int32TypeAnnotation':
|
|
56
|
-
return 'value
|
|
61
|
+
return 'int value';
|
|
57
62
|
case 'DoubleTypeAnnotation':
|
|
58
|
-
return 'value
|
|
63
|
+
return 'double value';
|
|
59
64
|
case 'FloatTypeAnnotation':
|
|
60
65
|
if (typeAnnotation.default === null) {
|
|
61
|
-
|
|
66
|
+
addNullable(imports);
|
|
67
|
+
return '@Nullable Float value';
|
|
62
68
|
} else {
|
|
63
|
-
return 'value
|
|
69
|
+
return 'float value';
|
|
64
70
|
}
|
|
65
71
|
case 'ReservedPropTypeAnnotation':
|
|
66
72
|
switch (typeAnnotation.name) {
|
|
67
73
|
case 'ColorPrimitive':
|
|
68
|
-
|
|
74
|
+
addNullable(imports);
|
|
75
|
+
return '@Nullable Integer value';
|
|
69
76
|
case 'ImageSourcePrimitive':
|
|
70
|
-
|
|
77
|
+
addNullable(imports);
|
|
78
|
+
return '@Nullable ReadableMap value';
|
|
71
79
|
case 'ImageRequestPrimitive':
|
|
72
|
-
|
|
80
|
+
addNullable(imports);
|
|
81
|
+
return '@Nullable ReadableMap value';
|
|
73
82
|
case 'PointPrimitive':
|
|
74
|
-
|
|
83
|
+
addNullable(imports);
|
|
84
|
+
return '@Nullable ReadableMap value';
|
|
75
85
|
case 'EdgeInsetsPrimitive':
|
|
76
|
-
|
|
86
|
+
addNullable(imports);
|
|
87
|
+
return '@Nullable ReadableMap value';
|
|
77
88
|
case 'DimensionPrimitive':
|
|
78
|
-
|
|
89
|
+
addNullable(imports);
|
|
90
|
+
return '@Nullable YogaValue value';
|
|
79
91
|
default:
|
|
80
92
|
typeAnnotation.name;
|
|
81
93
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
82
94
|
}
|
|
83
95
|
case 'ArrayTypeAnnotation': {
|
|
84
|
-
|
|
96
|
+
addNullable(imports);
|
|
97
|
+
return '@Nullable ReadableArray value';
|
|
85
98
|
}
|
|
86
99
|
case 'ObjectTypeAnnotation': {
|
|
87
|
-
|
|
100
|
+
addNullable(imports);
|
|
101
|
+
return '@Nullable ReadableMap value';
|
|
88
102
|
}
|
|
89
103
|
case 'StringEnumTypeAnnotation':
|
|
90
|
-
|
|
104
|
+
addNullable(imports);
|
|
105
|
+
return '@Nullable String value';
|
|
91
106
|
case 'Int32EnumTypeAnnotation':
|
|
92
|
-
|
|
107
|
+
addNullable(imports);
|
|
108
|
+
return '@Nullable Integer value';
|
|
93
109
|
case 'MixedTypeAnnotation':
|
|
94
|
-
return 'value
|
|
110
|
+
return 'Dynamic value';
|
|
95
111
|
default:
|
|
96
112
|
typeAnnotation;
|
|
97
113
|
throw new Error('Received invalid typeAnnotation');
|
|
@@ -103,9 +119,9 @@ function generatePropsString(component, imports) {
|
|
|
103
119
|
}
|
|
104
120
|
return component.props
|
|
105
121
|
.map(prop => {
|
|
106
|
-
return `
|
|
122
|
+
return `void set${toSafeJavaString(
|
|
107
123
|
prop.name,
|
|
108
|
-
)}(view
|
|
124
|
+
)}(T view, ${getJavaValueForProp(prop, imports)});`;
|
|
109
125
|
})
|
|
110
126
|
.join('\n' + ' ');
|
|
111
127
|
}
|
|
@@ -115,19 +131,19 @@ function getCommandArgJavaType(param) {
|
|
|
115
131
|
case 'ReservedTypeAnnotation':
|
|
116
132
|
switch (typeAnnotation.name) {
|
|
117
133
|
case 'RootTag':
|
|
118
|
-
return '
|
|
134
|
+
return 'double';
|
|
119
135
|
default:
|
|
120
136
|
typeAnnotation.name;
|
|
121
137
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
122
138
|
}
|
|
123
139
|
case 'BooleanTypeAnnotation':
|
|
124
|
-
return '
|
|
140
|
+
return 'boolean';
|
|
125
141
|
case 'DoubleTypeAnnotation':
|
|
126
|
-
return '
|
|
142
|
+
return 'double';
|
|
127
143
|
case 'FloatTypeAnnotation':
|
|
128
|
-
return '
|
|
144
|
+
return 'float';
|
|
129
145
|
case 'Int32TypeAnnotation':
|
|
130
|
-
return '
|
|
146
|
+
return 'int';
|
|
131
147
|
case 'StringTypeAnnotation':
|
|
132
148
|
return 'String';
|
|
133
149
|
case 'ArrayTypeAnnotation':
|
|
@@ -139,10 +155,10 @@ function getCommandArgJavaType(param) {
|
|
|
139
155
|
}
|
|
140
156
|
function getCommandArguments(command, componentName) {
|
|
141
157
|
return [
|
|
142
|
-
'view
|
|
158
|
+
'T view',
|
|
143
159
|
...command.typeAnnotation.params.map(param => {
|
|
144
160
|
const commandArgJavaType = getCommandArgJavaType(param);
|
|
145
|
-
return `${
|
|
161
|
+
return `${commandArgJavaType} ${param.name}`;
|
|
146
162
|
}),
|
|
147
163
|
].join(', ');
|
|
148
164
|
}
|
|
@@ -150,10 +166,10 @@ function generateCommandsString(component, componentName) {
|
|
|
150
166
|
return component.commands
|
|
151
167
|
.map(command => {
|
|
152
168
|
const safeJavaName = toSafeJavaString(command.name, false);
|
|
153
|
-
return `
|
|
169
|
+
return `void ${safeJavaName}(${getCommandArguments(
|
|
154
170
|
command,
|
|
155
171
|
componentName,
|
|
156
|
-
)})
|
|
172
|
+
)});`;
|
|
157
173
|
})
|
|
158
174
|
.join('\n' + ' ');
|
|
159
175
|
}
|
|
@@ -227,7 +243,7 @@ module.exports = {
|
|
|
227
243
|
.join('\n' + ' ')
|
|
228
244
|
.trimRight(),
|
|
229
245
|
});
|
|
230
|
-
files.set(`${outputDir}/${className}.
|
|
246
|
+
files.set(`${outputDir}/${className}.java`, replacedTemplate);
|
|
231
247
|
});
|
|
232
248
|
});
|
|
233
249
|
return files;
|
|
@@ -48,15 +48,19 @@ const FileTemplate = ({
|
|
|
48
48
|
* ${'@'}generated by codegen project: GeneratePropsJavaInterface.js
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
-
package ${packageName}
|
|
51
|
+
package ${packageName};
|
|
52
52
|
|
|
53
53
|
${imports}
|
|
54
54
|
|
|
55
|
-
public interface ${className}<T
|
|
55
|
+
public interface ${className}<T extends ${extendClasses}> extends ViewManagerWithGeneratedInterface {
|
|
56
56
|
${methods}
|
|
57
57
|
}
|
|
58
58
|
`;
|
|
59
59
|
|
|
60
|
+
function addNullable(imports: Set<string>) {
|
|
61
|
+
imports.add('import androidx.annotation.Nullable;');
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
function getJavaValueForProp(
|
|
61
65
|
prop: NamedShape<PropTypeAnnotation>,
|
|
62
66
|
imports: Set<string>,
|
|
@@ -66,52 +70,65 @@ function getJavaValueForProp(
|
|
|
66
70
|
switch (typeAnnotation.type) {
|
|
67
71
|
case 'BooleanTypeAnnotation':
|
|
68
72
|
if (typeAnnotation.default === null) {
|
|
69
|
-
|
|
73
|
+
addNullable(imports);
|
|
74
|
+
return '@Nullable Boolean value';
|
|
70
75
|
} else {
|
|
71
|
-
return 'value
|
|
76
|
+
return 'boolean value';
|
|
72
77
|
}
|
|
73
78
|
case 'StringTypeAnnotation':
|
|
74
|
-
|
|
79
|
+
addNullable(imports);
|
|
80
|
+
return '@Nullable String value';
|
|
75
81
|
case 'Int32TypeAnnotation':
|
|
76
|
-
return 'value
|
|
82
|
+
return 'int value';
|
|
77
83
|
case 'DoubleTypeAnnotation':
|
|
78
|
-
return 'value
|
|
84
|
+
return 'double value';
|
|
79
85
|
case 'FloatTypeAnnotation':
|
|
80
86
|
if (typeAnnotation.default === null) {
|
|
81
|
-
|
|
87
|
+
addNullable(imports);
|
|
88
|
+
return '@Nullable Float value';
|
|
82
89
|
} else {
|
|
83
|
-
return 'value
|
|
90
|
+
return 'float value';
|
|
84
91
|
}
|
|
85
92
|
case 'ReservedPropTypeAnnotation':
|
|
86
93
|
switch (typeAnnotation.name) {
|
|
87
94
|
case 'ColorPrimitive':
|
|
88
|
-
|
|
95
|
+
addNullable(imports);
|
|
96
|
+
return '@Nullable Integer value';
|
|
89
97
|
case 'ImageSourcePrimitive':
|
|
90
|
-
|
|
98
|
+
addNullable(imports);
|
|
99
|
+
return '@Nullable ReadableMap value';
|
|
91
100
|
case 'ImageRequestPrimitive':
|
|
92
|
-
|
|
101
|
+
addNullable(imports);
|
|
102
|
+
return '@Nullable ReadableMap value';
|
|
93
103
|
case 'PointPrimitive':
|
|
94
|
-
|
|
104
|
+
addNullable(imports);
|
|
105
|
+
return '@Nullable ReadableMap value';
|
|
95
106
|
case 'EdgeInsetsPrimitive':
|
|
96
|
-
|
|
107
|
+
addNullable(imports);
|
|
108
|
+
return '@Nullable ReadableMap value';
|
|
97
109
|
case 'DimensionPrimitive':
|
|
98
|
-
|
|
110
|
+
addNullable(imports);
|
|
111
|
+
return '@Nullable YogaValue value';
|
|
99
112
|
default:
|
|
100
113
|
(typeAnnotation.name: empty);
|
|
101
114
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
102
115
|
}
|
|
103
116
|
case 'ArrayTypeAnnotation': {
|
|
104
|
-
|
|
117
|
+
addNullable(imports);
|
|
118
|
+
return '@Nullable ReadableArray value';
|
|
105
119
|
}
|
|
106
120
|
case 'ObjectTypeAnnotation': {
|
|
107
|
-
|
|
121
|
+
addNullable(imports);
|
|
122
|
+
return '@Nullable ReadableMap value';
|
|
108
123
|
}
|
|
109
124
|
case 'StringEnumTypeAnnotation':
|
|
110
|
-
|
|
125
|
+
addNullable(imports);
|
|
126
|
+
return '@Nullable String value';
|
|
111
127
|
case 'Int32EnumTypeAnnotation':
|
|
112
|
-
|
|
128
|
+
addNullable(imports);
|
|
129
|
+
return '@Nullable Integer value';
|
|
113
130
|
case 'MixedTypeAnnotation':
|
|
114
|
-
return 'value
|
|
131
|
+
return 'Dynamic value';
|
|
115
132
|
default:
|
|
116
133
|
(typeAnnotation: empty);
|
|
117
134
|
throw new Error('Received invalid typeAnnotation');
|
|
@@ -125,9 +142,9 @@ function generatePropsString(component: ComponentShape, imports: Set<string>) {
|
|
|
125
142
|
|
|
126
143
|
return component.props
|
|
127
144
|
.map(prop => {
|
|
128
|
-
return `
|
|
145
|
+
return `void set${toSafeJavaString(
|
|
129
146
|
prop.name,
|
|
130
|
-
)}(view
|
|
147
|
+
)}(T view, ${getJavaValueForProp(prop, imports)});`;
|
|
131
148
|
})
|
|
132
149
|
.join('\n' + ' ');
|
|
133
150
|
}
|
|
@@ -139,19 +156,19 @@ function getCommandArgJavaType(param: NamedShape<CommandParamTypeAnnotation>) {
|
|
|
139
156
|
case 'ReservedTypeAnnotation':
|
|
140
157
|
switch (typeAnnotation.name) {
|
|
141
158
|
case 'RootTag':
|
|
142
|
-
return '
|
|
159
|
+
return 'double';
|
|
143
160
|
default:
|
|
144
161
|
(typeAnnotation.name: empty);
|
|
145
162
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
146
163
|
}
|
|
147
164
|
case 'BooleanTypeAnnotation':
|
|
148
|
-
return '
|
|
165
|
+
return 'boolean';
|
|
149
166
|
case 'DoubleTypeAnnotation':
|
|
150
|
-
return '
|
|
167
|
+
return 'double';
|
|
151
168
|
case 'FloatTypeAnnotation':
|
|
152
|
-
return '
|
|
169
|
+
return 'float';
|
|
153
170
|
case 'Int32TypeAnnotation':
|
|
154
|
-
return '
|
|
171
|
+
return 'int';
|
|
155
172
|
case 'StringTypeAnnotation':
|
|
156
173
|
return 'String';
|
|
157
174
|
case 'ArrayTypeAnnotation':
|
|
@@ -167,11 +184,11 @@ function getCommandArguments(
|
|
|
167
184
|
componentName: string,
|
|
168
185
|
): string {
|
|
169
186
|
return [
|
|
170
|
-
'view
|
|
187
|
+
'T view',
|
|
171
188
|
...command.typeAnnotation.params.map(param => {
|
|
172
189
|
const commandArgJavaType = getCommandArgJavaType(param);
|
|
173
190
|
|
|
174
|
-
return `${
|
|
191
|
+
return `${commandArgJavaType} ${param.name}`;
|
|
175
192
|
}),
|
|
176
193
|
].join(', ');
|
|
177
194
|
}
|
|
@@ -184,10 +201,10 @@ function generateCommandsString(
|
|
|
184
201
|
.map(command => {
|
|
185
202
|
const safeJavaName = toSafeJavaString(command.name, false);
|
|
186
203
|
|
|
187
|
-
return `
|
|
204
|
+
return `void ${safeJavaName}(${getCommandArguments(
|
|
188
205
|
command,
|
|
189
206
|
componentName,
|
|
190
|
-
)})
|
|
207
|
+
)});`;
|
|
191
208
|
})
|
|
192
209
|
.join('\n' + ' ');
|
|
193
210
|
}
|
|
@@ -270,7 +287,7 @@ module.exports = {
|
|
|
270
287
|
.trimRight(),
|
|
271
288
|
});
|
|
272
289
|
|
|
273
|
-
files.set(`${outputDir}/${className}.
|
|
290
|
+
files.set(`${outputDir}/${className}.java`, replacedTemplate);
|
|
274
291
|
});
|
|
275
292
|
});
|
|
276
293
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/codegen",
|
|
3
|
-
"version": "0.82.0-nightly-
|
|
3
|
+
"version": "0.82.0-nightly-20250720-8488eaece",
|
|
4
4
|
"description": "Code generation tools for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"bugs": "https://github.com/facebook/react-native/issues",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">= 20.19.4"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "yarn clean && node scripts/build.js --verbose",
|