@react-native/codegen 0.87.0-nightly-20260602-23ce90bd3 → 0.87.0-nightly-20260605-87184c8fb
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/CodegenSchema.js.flow +8 -8
- package/lib/generators/ReservedPrimitiveTypes.js.flow +84 -79
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +5 -5
- package/lib/parsers/errors.js.flow +1 -1
- package/lib/parsers/flow/components/componentsUtils.js.flow +2 -2
- package/lib/parsers/parsers-commons.js.flow +2 -2
- package/package.json +1 -1
|
@@ -72,14 +72,14 @@ export type ArrayBufferTypeAnnotation = Readonly<{
|
|
|
72
72
|
type: 'ArrayBufferTypeAnnotation',
|
|
73
73
|
}>;
|
|
74
74
|
|
|
75
|
-
export type ObjectTypeAnnotation
|
|
75
|
+
export type ObjectTypeAnnotation<out T> = Readonly<{
|
|
76
76
|
type: 'ObjectTypeAnnotation',
|
|
77
77
|
properties: ReadonlyArray<NamedShape<T>>,
|
|
78
78
|
// metadata for objects that generated from interfaces
|
|
79
79
|
baseTypes?: ReadonlyArray<string>,
|
|
80
80
|
}>;
|
|
81
81
|
|
|
82
|
-
export type UnionTypeAnnotation
|
|
82
|
+
export type UnionTypeAnnotation<out T> = Readonly<{
|
|
83
83
|
type: 'UnionTypeAnnotation',
|
|
84
84
|
types: ReadonlyArray<T>,
|
|
85
85
|
}>;
|
|
@@ -93,13 +93,13 @@ export type EventEmitterTypeAnnotation = Readonly<{
|
|
|
93
93
|
typeAnnotation: NativeModuleEventEmitterTypeAnnotation | $FlowFixMe,
|
|
94
94
|
}>;
|
|
95
95
|
|
|
96
|
-
type FunctionTypeAnnotation
|
|
96
|
+
type FunctionTypeAnnotation<out P, out R> = Readonly<{
|
|
97
97
|
type: 'FunctionTypeAnnotation',
|
|
98
98
|
params: ReadonlyArray<NamedShape<P>>,
|
|
99
99
|
returnTypeAnnotation: R,
|
|
100
100
|
}>;
|
|
101
101
|
|
|
102
|
-
export type NamedShape
|
|
102
|
+
export type NamedShape<out T> = Readonly<{
|
|
103
103
|
name: string,
|
|
104
104
|
optional: boolean,
|
|
105
105
|
typeAnnotation: T,
|
|
@@ -195,7 +195,7 @@ export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
|
|
|
195
195
|
| MixedTypeAnnotation,
|
|
196
196
|
>;
|
|
197
197
|
|
|
198
|
-
export type ArrayTypeAnnotation
|
|
198
|
+
export type ArrayTypeAnnotation<out T> = Readonly<{
|
|
199
199
|
type: 'ArrayTypeAnnotation',
|
|
200
200
|
elementType: T,
|
|
201
201
|
}>;
|
|
@@ -269,11 +269,11 @@ export type ReservedTypeAnnotation = Readonly<{
|
|
|
269
269
|
/**
|
|
270
270
|
* NativeModule Types
|
|
271
271
|
*/
|
|
272
|
-
export type Nullable
|
|
272
|
+
export type Nullable<out T extends NativeModuleTypeAnnotation> =
|
|
273
273
|
| NullableTypeAnnotation<T>
|
|
274
274
|
| T;
|
|
275
275
|
|
|
276
|
-
export type NullableTypeAnnotation
|
|
276
|
+
export type NullableTypeAnnotation<out T extends NativeModuleTypeAnnotation> =
|
|
277
277
|
Readonly<{
|
|
278
278
|
type: 'NullableTypeAnnotation',
|
|
279
279
|
typeAnnotation: T,
|
|
@@ -321,7 +321,7 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
|
|
|
321
321
|
>;
|
|
322
322
|
|
|
323
323
|
export type NativeModuleArrayTypeAnnotation<
|
|
324
|
-
|
|
324
|
+
out T extends Nullable<NativeModuleBaseTypeAnnotation>,
|
|
325
325
|
> = ArrayTypeAnnotation<
|
|
326
326
|
| T
|
|
327
327
|
/**
|
|
@@ -28,99 +28,104 @@ export type ReservedPrimitiveName =
|
|
|
28
28
|
| 'DimensionPrimitive';
|
|
29
29
|
|
|
30
30
|
type CppTypeInfo = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
readonly typeName: string,
|
|
32
|
+
readonly localIncludes: ReadonlyArray<string>,
|
|
33
|
+
readonly conversionIncludes: ReadonlyArray<string>,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
type JavaImportInfo = {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
readonly interfaceImports: ReadonlyArray<string>,
|
|
38
|
+
readonly delegateImports: ReadonlyArray<string>,
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
type ReservedTypeMapping = {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
readonly cpp: CppTypeInfo,
|
|
43
|
+
readonly java: JavaImportInfo,
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const RESERVED_TYPES: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} =
|
|
47
|
+
{
|
|
48
|
+
ColorPrimitive: {
|
|
49
|
+
cpp: {
|
|
50
|
+
typeName: 'SharedColor',
|
|
51
|
+
localIncludes: ['#include <react/renderer/graphics/Color.h>'],
|
|
52
|
+
conversionIncludes: [],
|
|
53
|
+
},
|
|
54
|
+
java: {
|
|
55
|
+
interfaceImports: [],
|
|
56
|
+
delegateImports: [
|
|
57
|
+
'import com.facebook.react.bridge.ColorPropConverter;',
|
|
58
|
+
],
|
|
59
|
+
},
|
|
52
60
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
ImageSourcePrimitive: {
|
|
62
|
+
cpp: {
|
|
63
|
+
typeName: 'ImageSource',
|
|
64
|
+
localIncludes: ['#include <react/renderer/imagemanager/primitives.h>'],
|
|
65
|
+
conversionIncludes: [
|
|
66
|
+
'#include <react/renderer/components/image/conversions.h>',
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
java: {
|
|
70
|
+
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
71
|
+
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
72
|
+
},
|
|
56
73
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
ImageRequestPrimitive: {
|
|
75
|
+
cpp: {
|
|
76
|
+
typeName: 'ImageRequest',
|
|
77
|
+
localIncludes: [
|
|
78
|
+
'#include <react/renderer/imagemanager/ImageRequest.h>',
|
|
79
|
+
],
|
|
80
|
+
conversionIncludes: [],
|
|
81
|
+
},
|
|
82
|
+
java: {
|
|
83
|
+
// ImageRequestPrimitive is not used in Java component props
|
|
84
|
+
interfaceImports: [],
|
|
85
|
+
delegateImports: [],
|
|
86
|
+
},
|
|
65
87
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
PointPrimitive: {
|
|
89
|
+
cpp: {
|
|
90
|
+
typeName: 'Point',
|
|
91
|
+
localIncludes: ['#include <react/renderer/graphics/Point.h>'],
|
|
92
|
+
conversionIncludes: [],
|
|
93
|
+
},
|
|
94
|
+
java: {
|
|
95
|
+
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
96
|
+
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
97
|
+
},
|
|
69
98
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
EdgeInsetsPrimitive: {
|
|
100
|
+
cpp: {
|
|
101
|
+
typeName: 'EdgeInsets',
|
|
102
|
+
localIncludes: ['#include <react/renderer/graphics/RectangleEdges.h>'],
|
|
103
|
+
conversionIncludes: [],
|
|
104
|
+
},
|
|
105
|
+
java: {
|
|
106
|
+
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
107
|
+
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
108
|
+
},
|
|
76
109
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
DimensionPrimitive: {
|
|
111
|
+
cpp: {
|
|
112
|
+
typeName: 'YGValue',
|
|
113
|
+
localIncludes: [
|
|
114
|
+
'#include <yoga/Yoga.h>',
|
|
115
|
+
'#include <react/renderer/core/graphicsConversions.h>',
|
|
116
|
+
],
|
|
117
|
+
conversionIncludes: [
|
|
118
|
+
'#include <react/renderer/components/view/conversions.h>',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
java: {
|
|
122
|
+
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
|
|
123
|
+
delegateImports: [
|
|
124
|
+
'import com.facebook.react.bridge.DimensionPropConverter;',
|
|
125
|
+
],
|
|
126
|
+
},
|
|
81
127
|
},
|
|
82
|
-
}
|
|
83
|
-
PointPrimitive: {
|
|
84
|
-
cpp: {
|
|
85
|
-
typeName: 'Point',
|
|
86
|
-
localIncludes: ['#include <react/renderer/graphics/Point.h>'],
|
|
87
|
-
conversionIncludes: [],
|
|
88
|
-
},
|
|
89
|
-
java: {
|
|
90
|
-
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
91
|
-
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
EdgeInsetsPrimitive: {
|
|
95
|
-
cpp: {
|
|
96
|
-
typeName: 'EdgeInsets',
|
|
97
|
-
localIncludes: ['#include <react/renderer/graphics/RectangleEdges.h>'],
|
|
98
|
-
conversionIncludes: [],
|
|
99
|
-
},
|
|
100
|
-
java: {
|
|
101
|
-
interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
102
|
-
delegateImports: ['import com.facebook.react.bridge.ReadableMap;'],
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
DimensionPrimitive: {
|
|
106
|
-
cpp: {
|
|
107
|
-
typeName: 'YGValue',
|
|
108
|
-
localIncludes: [
|
|
109
|
-
'#include <yoga/Yoga.h>',
|
|
110
|
-
'#include <react/renderer/core/graphicsConversions.h>',
|
|
111
|
-
],
|
|
112
|
-
conversionIncludes: [
|
|
113
|
-
'#include <react/renderer/components/view/conversions.h>',
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
java: {
|
|
117
|
-
interfaceImports: ['import com.facebook.yoga.YogaValue;'],
|
|
118
|
-
delegateImports: [
|
|
119
|
-
'import com.facebook.react.bridge.DimensionPropConverter;',
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
128
|
+
};
|
|
124
129
|
|
|
125
130
|
function getCppTypeForReservedPrimitive(name: ReservedPrimitiveName): string {
|
|
126
131
|
return RESERVED_TYPES[name].cpp.typeName;
|
|
@@ -49,13 +49,13 @@ function getNativeTypeFromAnnotation(
|
|
|
49
49
|
| ObjectTypeAnnotation<PropTypeAnnotation>
|
|
50
50
|
| ReservedPropTypeAnnotation
|
|
51
51
|
| {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
readonly default: string,
|
|
53
|
+
readonly options: ReadonlyArray<string>,
|
|
54
|
+
readonly type: 'StringEnumTypeAnnotation',
|
|
55
55
|
}
|
|
56
56
|
| {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
|
|
58
|
+
readonly type: 'ArrayTypeAnnotation',
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
nameParts: ReadonlyArray<string>,
|
|
@@ -128,7 +128,7 @@ class UnsupportedModulePropertyParserError extends ParserError {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
class UnsupportedTypeAnnotationParserError extends ParserError {
|
|
131
|
-
|
|
131
|
+
readonly typeAnnotationType: string;
|
|
132
132
|
constructor(
|
|
133
133
|
nativeModuleName: string,
|
|
134
134
|
typeAnnotation: $FlowFixMe,
|
|
@@ -17,7 +17,7 @@ const {verifyPropNotAlreadyDefined} = require('../../parsers-commons');
|
|
|
17
17
|
const {getValueFromTypes} = require('../utils.js');
|
|
18
18
|
|
|
19
19
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
20
|
-
function getTypeAnnotationForArray
|
|
20
|
+
function getTypeAnnotationForArray<out T>(
|
|
21
21
|
name: string,
|
|
22
22
|
typeAnnotation: $FlowFixMe,
|
|
23
23
|
defaultValue: $FlowFixMe | null,
|
|
@@ -219,7 +219,7 @@ function flattenProperties(
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
222
|
-
function getTypeAnnotation
|
|
222
|
+
function getTypeAnnotation<out T>(
|
|
223
223
|
name: string,
|
|
224
224
|
annotation: $FlowFixMe | ASTNode,
|
|
225
225
|
defaultValue: $FlowFixMe | null,
|
|
@@ -107,7 +107,7 @@ function wrapModuleSchema(
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
110
|
-
function unwrapNullable
|
|
110
|
+
function unwrapNullable<out T extends NativeModuleTypeAnnotation>(
|
|
111
111
|
x: Nullable<T>,
|
|
112
112
|
): [T, boolean] {
|
|
113
113
|
if (x.type === 'NullableTypeAnnotation') {
|
|
@@ -118,7 +118,7 @@ function unwrapNullable<+T extends NativeModuleTypeAnnotation>(
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
121
|
-
function wrapNullable
|
|
121
|
+
function wrapNullable<out T extends NativeModuleTypeAnnotation>(
|
|
122
122
|
nullable: boolean,
|
|
123
123
|
typeAnnotation: T,
|
|
124
124
|
): Nullable<T> {
|