@react-native/codegen 0.82.0-nightly-20250720-8488eaece → 0.82.0-nightly-20250722-2c3a00b7b
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/generators/components/GenerateViewConfigJs.js.flow +3 -1
- package/lib/generators/modules/GenerateModuleCpp.js.flow +4 -4
- package/lib/generators/modules/GenerateModuleH.js.flow +8 -8
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +6 -6
- package/lib/generators/modules/GenerateModuleObjCpp/source/serializeModule.js.flow +12 -12
- package/lib/parsers/flow/parser.js.flow +10 -10
- package/lib/parsers/typescript/components/componentsUtils.js.flow +2 -2
- package/lib/parsers/typescript/parser.js.flow +15 -15
- package/package.json +1 -1
|
@@ -317,7 +317,9 @@ function buildViewConfig(
|
|
|
317
317
|
return directEvents;
|
|
318
318
|
}, []);
|
|
319
319
|
|
|
320
|
-
const properties
|
|
320
|
+
const properties: Array<
|
|
321
|
+
BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeSpreadElement,
|
|
322
|
+
> = [
|
|
321
323
|
t.objectProperty(
|
|
322
324
|
t.identifier('uiViewClassName'),
|
|
323
325
|
t.stringLiteral(componentName),
|
|
@@ -47,15 +47,15 @@ const HostFunctionTemplate = ({
|
|
|
47
47
|
isVoid
|
|
48
48
|
? `\n ${methodCall};`
|
|
49
49
|
: isNullable
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
? `\n auto result = ${methodCall};`
|
|
51
|
+
: ''
|
|
52
52
|
}
|
|
53
53
|
return ${
|
|
54
54
|
isVoid
|
|
55
55
|
? 'jsi::Value::undefined()'
|
|
56
56
|
: isNullable
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
? 'result ? jsi::Value(std::move(*result)) : jsi::Value::null()'
|
|
58
|
+
: methodCall
|
|
59
59
|
};
|
|
60
60
|
}`;
|
|
61
61
|
};
|
|
@@ -572,17 +572,17 @@ function translateEventEmitterToCpp(
|
|
|
572
572
|
${
|
|
573
573
|
isVoidTypeAnnotation ? '' : `template <typename ${templateName}> `
|
|
574
574
|
}void emit${toPascalCase(eventEmitter.name)}(${
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
575
|
+
isVoidTypeAnnotation
|
|
576
|
+
? ''
|
|
577
|
+
: `${isArray ? `std::vector<${templateName}>` : templateName} value`
|
|
578
|
+
}) {${
|
|
579
|
+
isVoidTypeAnnotation
|
|
580
|
+
? ''
|
|
581
|
+
: `
|
|
582
582
|
static_assert(bridging::supportsFromJs<${
|
|
583
583
|
isArray ? `std::vector<${templateName}>` : templateName
|
|
584
584
|
}, ${jsiType}>, "value cannnot be converted to ${jsiType}");`
|
|
585
|
-
|
|
585
|
+
}
|
|
586
586
|
static_cast<AsyncEventEmitter<${
|
|
587
587
|
isVoidTypeAnnotation ? '' : 'jsi::Value'
|
|
588
588
|
}>&>(*delegate_.eventEmitterMap_["${eventEmitter.name}"]).emit(${
|
|
@@ -84,10 +84,10 @@ function EventEmitterTemplate(
|
|
|
84
84
|
: ''
|
|
85
85
|
}) {
|
|
86
86
|
mEventEmitterCallback.invoke("${eventEmitter.name}"${
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation'
|
|
88
|
+
? ', value'
|
|
89
|
+
: ''
|
|
90
|
+
});
|
|
91
91
|
}`;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -113,8 +113,8 @@ function MethodTemplate(
|
|
|
113
113
|
const methodClosing = abstract
|
|
114
114
|
? ';'
|
|
115
115
|
: methodBody != null && methodBody.length > 0
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
? ` { ${methodBody} }`
|
|
117
|
+
: ' {}';
|
|
118
118
|
return ` ${methodJavaAnnotation}
|
|
119
119
|
public ${methodQualifier}${translatedReturnType} ${methodName}(${traversedArgs.join(
|
|
120
120
|
', ',
|
|
@@ -74,22 +74,22 @@ namespace facebook::react {
|
|
|
74
74
|
}),
|
|
75
75
|
)
|
|
76
76
|
.join('\n' + ' '.repeat(8))}${
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
eventEmitters.length > 0
|
|
78
|
+
? eventEmitters
|
|
79
|
+
.map(eventEmitter => {
|
|
80
|
+
return `
|
|
81
81
|
eventEmitterMap_["${eventEmitter.name}"] = std::make_shared<AsyncEventEmitter<id>>();`;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}${
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
})
|
|
83
|
+
.join('')
|
|
84
|
+
: ''
|
|
85
|
+
}${
|
|
86
|
+
eventEmitters.length > 0
|
|
87
|
+
? `
|
|
88
88
|
setEventEmitterCallback([&](const std::string &name, id value) {
|
|
89
89
|
static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
|
|
90
90
|
});`
|
|
91
|
-
|
|
92
|
-
}
|
|
91
|
+
: ''
|
|
92
|
+
}
|
|
93
93
|
}
|
|
94
94
|
} // namespace facebook::react`;
|
|
95
95
|
|
|
@@ -187,8 +187,8 @@ class FlowParser implements Parser {
|
|
|
187
187
|
typeAnnotation.type === 'EnumStringBody'
|
|
188
188
|
? 'StringTypeAnnotation'
|
|
189
189
|
: typeAnnotation.type === 'EnumNumberBody'
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
? 'NumberTypeAnnotation'
|
|
191
|
+
: null;
|
|
192
192
|
if (!enumMembersType) {
|
|
193
193
|
throw new Error(
|
|
194
194
|
`Unknown enum type annotation type. Got: ${typeAnnotation.type}. Expected: EnumStringBody or EnumNumberBody.`,
|
|
@@ -242,14 +242,14 @@ class FlowParser implements Parser {
|
|
|
242
242
|
value: member.init.value,
|
|
243
243
|
}
|
|
244
244
|
: typeof member.init?.value === 'string'
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
? {
|
|
246
|
+
type: 'StringLiteralTypeAnnotation',
|
|
247
|
+
value: member.init.value,
|
|
248
|
+
}
|
|
249
|
+
: {
|
|
250
|
+
type: 'StringLiteralTypeAnnotation',
|
|
251
|
+
value: member.id.name,
|
|
252
|
+
};
|
|
253
253
|
|
|
254
254
|
return {
|
|
255
255
|
name: member.id.name,
|
|
@@ -353,8 +353,8 @@ function setDefaultValue(
|
|
|
353
353
|
common.default = ((defaultValue === null
|
|
354
354
|
? null
|
|
355
355
|
: defaultValue
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
? defaultValue
|
|
357
|
+
: 0): number | null);
|
|
358
358
|
break;
|
|
359
359
|
case 'BooleanTypeAnnotation':
|
|
360
360
|
common.default = defaultValue === null ? null : !!defaultValue;
|
|
@@ -233,8 +233,8 @@ class TypeScriptParser implements Parser {
|
|
|
233
233
|
enumMembersType === 'StringTypeAnnotation'
|
|
234
234
|
? 'StringLiteral'
|
|
235
235
|
: enumMembersType === 'NumberTypeAnnotation'
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
? 'NumericLiteral'
|
|
237
|
+
: null;
|
|
238
238
|
|
|
239
239
|
typeAnnotation.members.forEach(member => {
|
|
240
240
|
const isNegative =
|
|
@@ -263,19 +263,19 @@ class TypeScriptParser implements Parser {
|
|
|
263
263
|
value: -1 * member.initializer?.argument?.value,
|
|
264
264
|
}
|
|
265
265
|
: typeof member.initializer?.value === 'number'
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
266
|
+
? {
|
|
267
|
+
type: 'NumberLiteralTypeAnnotation',
|
|
268
|
+
value: member.initializer?.value,
|
|
269
|
+
}
|
|
270
|
+
: typeof member.initializer?.value === 'string'
|
|
271
|
+
? {
|
|
272
|
+
type: 'StringLiteralTypeAnnotation',
|
|
273
|
+
value: member.initializer?.value,
|
|
274
|
+
}
|
|
275
|
+
: {
|
|
276
|
+
type: 'StringLiteralTypeAnnotation',
|
|
277
|
+
value: member.id.name,
|
|
278
|
+
};
|
|
279
279
|
|
|
280
280
|
return {
|
|
281
281
|
name: member.id.name,
|