@react-native/codegen 0.82.0-nightly-20250712-8083cb4ab → 0.82.0-nightly-20250714-79ca9036d
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,81 +33,65 @@ 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: ${extendClasses}>: ViewManagerWithGeneratedInterface {
|
|
41
41
|
${methods}
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
|
-
function addNullable(imports) {
|
|
45
|
-
imports.add('import androidx.annotation.Nullable;');
|
|
46
|
-
}
|
|
47
44
|
function getJavaValueForProp(prop, imports) {
|
|
48
45
|
const typeAnnotation = prop.typeAnnotation;
|
|
49
46
|
switch (typeAnnotation.type) {
|
|
50
47
|
case 'BooleanTypeAnnotation':
|
|
51
48
|
if (typeAnnotation.default === null) {
|
|
52
|
-
|
|
53
|
-
return '@Nullable Boolean value';
|
|
49
|
+
return 'value: Boolean?';
|
|
54
50
|
} else {
|
|
55
|
-
return '
|
|
51
|
+
return 'value: Boolean';
|
|
56
52
|
}
|
|
57
53
|
case 'StringTypeAnnotation':
|
|
58
|
-
|
|
59
|
-
return '@Nullable String value';
|
|
54
|
+
return 'value: String?';
|
|
60
55
|
case 'Int32TypeAnnotation':
|
|
61
|
-
return '
|
|
56
|
+
return 'value: Int';
|
|
62
57
|
case 'DoubleTypeAnnotation':
|
|
63
|
-
return '
|
|
58
|
+
return 'value: Double';
|
|
64
59
|
case 'FloatTypeAnnotation':
|
|
65
60
|
if (typeAnnotation.default === null) {
|
|
66
|
-
|
|
67
|
-
return '@Nullable Float value';
|
|
61
|
+
return 'value: Float?';
|
|
68
62
|
} else {
|
|
69
|
-
return '
|
|
63
|
+
return 'value: Float';
|
|
70
64
|
}
|
|
71
65
|
case 'ReservedPropTypeAnnotation':
|
|
72
66
|
switch (typeAnnotation.name) {
|
|
73
67
|
case 'ColorPrimitive':
|
|
74
|
-
|
|
75
|
-
return '@Nullable Integer value';
|
|
68
|
+
return 'value: Int?';
|
|
76
69
|
case 'ImageSourcePrimitive':
|
|
77
|
-
|
|
78
|
-
return '@Nullable ReadableMap value';
|
|
70
|
+
return 'value: ReadableMap?';
|
|
79
71
|
case 'ImageRequestPrimitive':
|
|
80
|
-
|
|
81
|
-
return '@Nullable ReadableMap value';
|
|
72
|
+
return 'value: ReadableMap?';
|
|
82
73
|
case 'PointPrimitive':
|
|
83
|
-
|
|
84
|
-
return '@Nullable ReadableMap value';
|
|
74
|
+
return 'value: ReadableMap?';
|
|
85
75
|
case 'EdgeInsetsPrimitive':
|
|
86
|
-
|
|
87
|
-
return '@Nullable ReadableMap value';
|
|
76
|
+
return 'value: ReadableMap?';
|
|
88
77
|
case 'DimensionPrimitive':
|
|
89
|
-
|
|
90
|
-
return '@Nullable YogaValue value';
|
|
78
|
+
return 'value: YogaValue?';
|
|
91
79
|
default:
|
|
92
80
|
typeAnnotation.name;
|
|
93
81
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
94
82
|
}
|
|
95
83
|
case 'ArrayTypeAnnotation': {
|
|
96
|
-
|
|
97
|
-
return '@Nullable ReadableArray value';
|
|
84
|
+
return 'value: ReadableArray?';
|
|
98
85
|
}
|
|
99
86
|
case 'ObjectTypeAnnotation': {
|
|
100
|
-
|
|
101
|
-
return '@Nullable ReadableMap value';
|
|
87
|
+
return 'value: ReadableMap?';
|
|
102
88
|
}
|
|
103
89
|
case 'StringEnumTypeAnnotation':
|
|
104
|
-
|
|
105
|
-
return '@Nullable String value';
|
|
90
|
+
return 'value: String?';
|
|
106
91
|
case 'Int32EnumTypeAnnotation':
|
|
107
|
-
|
|
108
|
-
return '@Nullable Integer value';
|
|
92
|
+
return 'value: Int?';
|
|
109
93
|
case 'MixedTypeAnnotation':
|
|
110
|
-
return 'Dynamic
|
|
94
|
+
return 'value: Dynamic';
|
|
111
95
|
default:
|
|
112
96
|
typeAnnotation;
|
|
113
97
|
throw new Error('Received invalid typeAnnotation');
|
|
@@ -119,9 +103,9 @@ function generatePropsString(component, imports) {
|
|
|
119
103
|
}
|
|
120
104
|
return component.props
|
|
121
105
|
.map(prop => {
|
|
122
|
-
return `
|
|
106
|
+
return `public fun set${toSafeJavaString(
|
|
123
107
|
prop.name,
|
|
124
|
-
)}(T
|
|
108
|
+
)}(view: T, ${getJavaValueForProp(prop, imports)}): Unit`;
|
|
125
109
|
})
|
|
126
110
|
.join('\n' + ' ');
|
|
127
111
|
}
|
|
@@ -131,19 +115,19 @@ function getCommandArgJavaType(param) {
|
|
|
131
115
|
case 'ReservedTypeAnnotation':
|
|
132
116
|
switch (typeAnnotation.name) {
|
|
133
117
|
case 'RootTag':
|
|
134
|
-
return '
|
|
118
|
+
return 'Double';
|
|
135
119
|
default:
|
|
136
120
|
typeAnnotation.name;
|
|
137
121
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
138
122
|
}
|
|
139
123
|
case 'BooleanTypeAnnotation':
|
|
140
|
-
return '
|
|
124
|
+
return 'Boolean';
|
|
141
125
|
case 'DoubleTypeAnnotation':
|
|
142
|
-
return '
|
|
126
|
+
return 'Double';
|
|
143
127
|
case 'FloatTypeAnnotation':
|
|
144
|
-
return '
|
|
128
|
+
return 'Float';
|
|
145
129
|
case 'Int32TypeAnnotation':
|
|
146
|
-
return '
|
|
130
|
+
return 'Int';
|
|
147
131
|
case 'StringTypeAnnotation':
|
|
148
132
|
return 'String';
|
|
149
133
|
case 'ArrayTypeAnnotation':
|
|
@@ -155,10 +139,10 @@ function getCommandArgJavaType(param) {
|
|
|
155
139
|
}
|
|
156
140
|
function getCommandArguments(command, componentName) {
|
|
157
141
|
return [
|
|
158
|
-
'T
|
|
142
|
+
'view: T',
|
|
159
143
|
...command.typeAnnotation.params.map(param => {
|
|
160
144
|
const commandArgJavaType = getCommandArgJavaType(param);
|
|
161
|
-
return `${
|
|
145
|
+
return `${param.name}: ${commandArgJavaType}`;
|
|
162
146
|
}),
|
|
163
147
|
].join(', ');
|
|
164
148
|
}
|
|
@@ -166,10 +150,10 @@ function generateCommandsString(component, componentName) {
|
|
|
166
150
|
return component.commands
|
|
167
151
|
.map(command => {
|
|
168
152
|
const safeJavaName = toSafeJavaString(command.name, false);
|
|
169
|
-
return `
|
|
153
|
+
return `public fun ${safeJavaName}(${getCommandArguments(
|
|
170
154
|
command,
|
|
171
155
|
componentName,
|
|
172
|
-
)})
|
|
156
|
+
)}): Unit`;
|
|
173
157
|
})
|
|
174
158
|
.join('\n' + ' ');
|
|
175
159
|
}
|
|
@@ -243,7 +227,7 @@ module.exports = {
|
|
|
243
227
|
.join('\n' + ' ')
|
|
244
228
|
.trimRight(),
|
|
245
229
|
});
|
|
246
|
-
files.set(`${outputDir}/${className}.
|
|
230
|
+
files.set(`${outputDir}/${className}.kt`, replacedTemplate);
|
|
247
231
|
});
|
|
248
232
|
});
|
|
249
233
|
return files;
|
|
@@ -48,19 +48,15 @@ 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: ${extendClasses}>: 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
|
-
|
|
64
60
|
function getJavaValueForProp(
|
|
65
61
|
prop: NamedShape<PropTypeAnnotation>,
|
|
66
62
|
imports: Set<string>,
|
|
@@ -70,65 +66,52 @@ function getJavaValueForProp(
|
|
|
70
66
|
switch (typeAnnotation.type) {
|
|
71
67
|
case 'BooleanTypeAnnotation':
|
|
72
68
|
if (typeAnnotation.default === null) {
|
|
73
|
-
|
|
74
|
-
return '@Nullable Boolean value';
|
|
69
|
+
return 'value: Boolean?';
|
|
75
70
|
} else {
|
|
76
|
-
return '
|
|
71
|
+
return 'value: Boolean';
|
|
77
72
|
}
|
|
78
73
|
case 'StringTypeAnnotation':
|
|
79
|
-
|
|
80
|
-
return '@Nullable String value';
|
|
74
|
+
return 'value: String?';
|
|
81
75
|
case 'Int32TypeAnnotation':
|
|
82
|
-
return '
|
|
76
|
+
return 'value: Int';
|
|
83
77
|
case 'DoubleTypeAnnotation':
|
|
84
|
-
return '
|
|
78
|
+
return 'value: Double';
|
|
85
79
|
case 'FloatTypeAnnotation':
|
|
86
80
|
if (typeAnnotation.default === null) {
|
|
87
|
-
|
|
88
|
-
return '@Nullable Float value';
|
|
81
|
+
return 'value: Float?';
|
|
89
82
|
} else {
|
|
90
|
-
return '
|
|
83
|
+
return 'value: Float';
|
|
91
84
|
}
|
|
92
85
|
case 'ReservedPropTypeAnnotation':
|
|
93
86
|
switch (typeAnnotation.name) {
|
|
94
87
|
case 'ColorPrimitive':
|
|
95
|
-
|
|
96
|
-
return '@Nullable Integer value';
|
|
88
|
+
return 'value: Int?';
|
|
97
89
|
case 'ImageSourcePrimitive':
|
|
98
|
-
|
|
99
|
-
return '@Nullable ReadableMap value';
|
|
90
|
+
return 'value: ReadableMap?';
|
|
100
91
|
case 'ImageRequestPrimitive':
|
|
101
|
-
|
|
102
|
-
return '@Nullable ReadableMap value';
|
|
92
|
+
return 'value: ReadableMap?';
|
|
103
93
|
case 'PointPrimitive':
|
|
104
|
-
|
|
105
|
-
return '@Nullable ReadableMap value';
|
|
94
|
+
return 'value: ReadableMap?';
|
|
106
95
|
case 'EdgeInsetsPrimitive':
|
|
107
|
-
|
|
108
|
-
return '@Nullable ReadableMap value';
|
|
96
|
+
return 'value: ReadableMap?';
|
|
109
97
|
case 'DimensionPrimitive':
|
|
110
|
-
|
|
111
|
-
return '@Nullable YogaValue value';
|
|
98
|
+
return 'value: YogaValue?';
|
|
112
99
|
default:
|
|
113
100
|
(typeAnnotation.name: empty);
|
|
114
101
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
115
102
|
}
|
|
116
103
|
case 'ArrayTypeAnnotation': {
|
|
117
|
-
|
|
118
|
-
return '@Nullable ReadableArray value';
|
|
104
|
+
return 'value: ReadableArray?';
|
|
119
105
|
}
|
|
120
106
|
case 'ObjectTypeAnnotation': {
|
|
121
|
-
|
|
122
|
-
return '@Nullable ReadableMap value';
|
|
107
|
+
return 'value: ReadableMap?';
|
|
123
108
|
}
|
|
124
109
|
case 'StringEnumTypeAnnotation':
|
|
125
|
-
|
|
126
|
-
return '@Nullable String value';
|
|
110
|
+
return 'value: String?';
|
|
127
111
|
case 'Int32EnumTypeAnnotation':
|
|
128
|
-
|
|
129
|
-
return '@Nullable Integer value';
|
|
112
|
+
return 'value: Int?';
|
|
130
113
|
case 'MixedTypeAnnotation':
|
|
131
|
-
return 'Dynamic
|
|
114
|
+
return 'value: Dynamic';
|
|
132
115
|
default:
|
|
133
116
|
(typeAnnotation: empty);
|
|
134
117
|
throw new Error('Received invalid typeAnnotation');
|
|
@@ -142,9 +125,9 @@ function generatePropsString(component: ComponentShape, imports: Set<string>) {
|
|
|
142
125
|
|
|
143
126
|
return component.props
|
|
144
127
|
.map(prop => {
|
|
145
|
-
return `
|
|
128
|
+
return `public fun set${toSafeJavaString(
|
|
146
129
|
prop.name,
|
|
147
|
-
)}(T
|
|
130
|
+
)}(view: T, ${getJavaValueForProp(prop, imports)}): Unit`;
|
|
148
131
|
})
|
|
149
132
|
.join('\n' + ' ');
|
|
150
133
|
}
|
|
@@ -156,19 +139,19 @@ function getCommandArgJavaType(param: NamedShape<CommandParamTypeAnnotation>) {
|
|
|
156
139
|
case 'ReservedTypeAnnotation':
|
|
157
140
|
switch (typeAnnotation.name) {
|
|
158
141
|
case 'RootTag':
|
|
159
|
-
return '
|
|
142
|
+
return 'Double';
|
|
160
143
|
default:
|
|
161
144
|
(typeAnnotation.name: empty);
|
|
162
145
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
163
146
|
}
|
|
164
147
|
case 'BooleanTypeAnnotation':
|
|
165
|
-
return '
|
|
148
|
+
return 'Boolean';
|
|
166
149
|
case 'DoubleTypeAnnotation':
|
|
167
|
-
return '
|
|
150
|
+
return 'Double';
|
|
168
151
|
case 'FloatTypeAnnotation':
|
|
169
|
-
return '
|
|
152
|
+
return 'Float';
|
|
170
153
|
case 'Int32TypeAnnotation':
|
|
171
|
-
return '
|
|
154
|
+
return 'Int';
|
|
172
155
|
case 'StringTypeAnnotation':
|
|
173
156
|
return 'String';
|
|
174
157
|
case 'ArrayTypeAnnotation':
|
|
@@ -184,11 +167,11 @@ function getCommandArguments(
|
|
|
184
167
|
componentName: string,
|
|
185
168
|
): string {
|
|
186
169
|
return [
|
|
187
|
-
'T
|
|
170
|
+
'view: T',
|
|
188
171
|
...command.typeAnnotation.params.map(param => {
|
|
189
172
|
const commandArgJavaType = getCommandArgJavaType(param);
|
|
190
173
|
|
|
191
|
-
return `${
|
|
174
|
+
return `${param.name}: ${commandArgJavaType}`;
|
|
192
175
|
}),
|
|
193
176
|
].join(', ');
|
|
194
177
|
}
|
|
@@ -201,10 +184,10 @@ function generateCommandsString(
|
|
|
201
184
|
.map(command => {
|
|
202
185
|
const safeJavaName = toSafeJavaString(command.name, false);
|
|
203
186
|
|
|
204
|
-
return `
|
|
187
|
+
return `public fun ${safeJavaName}(${getCommandArguments(
|
|
205
188
|
command,
|
|
206
189
|
componentName,
|
|
207
|
-
)})
|
|
190
|
+
)}): Unit`;
|
|
208
191
|
})
|
|
209
192
|
.join('\n' + ' ');
|
|
210
193
|
}
|
|
@@ -287,7 +270,7 @@ module.exports = {
|
|
|
287
270
|
.trimRight(),
|
|
288
271
|
});
|
|
289
272
|
|
|
290
|
-
files.set(`${outputDir}/${className}.
|
|
273
|
+
files.set(`${outputDir}/${className}.kt`, replacedTemplate);
|
|
291
274
|
});
|
|
292
275
|
});
|
|
293
276
|
|