@react-native/codegen 0.89.0-rc.0 → 0.90.0-nightly-20261106-cd45f309e
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/CppHelpers.js +2 -2
- package/lib/generators/components/CppHelpers.js.flow +2 -2
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +2 -2
- package/lib/generators/components/GeneratePropsH.js +11 -6
- package/lib/generators/components/GeneratePropsH.js.flow +9 -2
- package/lib/parsers/parsers-commons.js.flow +1 -1
- package/lib/parsers/utils.js.flow +1 -1
- package/package.json +1 -1
|
@@ -132,13 +132,13 @@ function convertDefaultTypeToString(componentName, prop, fromBuilder = false) {
|
|
|
132
132
|
return String(typeAnnotation.default);
|
|
133
133
|
case 'DoubleTypeAnnotation':
|
|
134
134
|
const defaultDoubleVal = typeAnnotation.default;
|
|
135
|
-
return parseInt(defaultDoubleVal, 10) === defaultDoubleVal ? typeAnnotation.default.toFixed(1) : String(typeAnnotation.default);
|
|
135
|
+
return parseInt(String(defaultDoubleVal), 10) === defaultDoubleVal ? typeAnnotation.default.toFixed(1) : String(typeAnnotation.default);
|
|
136
136
|
case 'FloatTypeAnnotation':
|
|
137
137
|
const defaultFloatVal = typeAnnotation.default;
|
|
138
138
|
if (defaultFloatVal == null) {
|
|
139
139
|
return '';
|
|
140
140
|
}
|
|
141
|
-
return parseInt(defaultFloatVal, 10) === defaultFloatVal ? defaultFloatVal.toFixed(1) : String(typeAnnotation.default);
|
|
141
|
+
return parseInt(String(defaultFloatVal), 10) === defaultFloatVal ? defaultFloatVal.toFixed(1) : String(typeAnnotation.default);
|
|
142
142
|
case 'ReservedPropTypeAnnotation':
|
|
143
143
|
switch (typeAnnotation.name) {
|
|
144
144
|
case 'ColorPrimitive':
|
|
@@ -215,7 +215,7 @@ function convertDefaultTypeToString(
|
|
|
215
215
|
return String(typeAnnotation.default);
|
|
216
216
|
case 'DoubleTypeAnnotation':
|
|
217
217
|
const defaultDoubleVal = typeAnnotation.default;
|
|
218
|
-
return parseInt(defaultDoubleVal, 10) === defaultDoubleVal
|
|
218
|
+
return parseInt(String(defaultDoubleVal), 10) === defaultDoubleVal
|
|
219
219
|
? typeAnnotation.default.toFixed(1)
|
|
220
220
|
: String(typeAnnotation.default);
|
|
221
221
|
case 'FloatTypeAnnotation':
|
|
@@ -223,7 +223,7 @@ function convertDefaultTypeToString(
|
|
|
223
223
|
if (defaultFloatVal == null) {
|
|
224
224
|
return '';
|
|
225
225
|
}
|
|
226
|
-
return parseInt(defaultFloatVal, 10) === defaultFloatVal
|
|
226
|
+
return parseInt(String(defaultFloatVal), 10) === defaultFloatVal
|
|
227
227
|
? defaultFloatVal.toFixed(1)
|
|
228
228
|
: String(typeAnnotation.default);
|
|
229
229
|
case 'ReservedPropTypeAnnotation':
|
|
@@ -101,7 +101,7 @@ function generateSetter(
|
|
|
101
101
|
propertyName: string,
|
|
102
102
|
propertyParts: ReadonlyArray<string>,
|
|
103
103
|
usingEvent: boolean,
|
|
104
|
-
valueMapper: string => string = value => value,
|
|
104
|
+
valueMapper: (v: string) => string = value => value,
|
|
105
105
|
) {
|
|
106
106
|
const eventChain = usingEvent
|
|
107
107
|
? `event.${[...propertyParts, propertyName].join('.')}`
|
|
@@ -141,7 +141,7 @@ function setValueAtIndex(
|
|
|
141
141
|
propertyName: string,
|
|
142
142
|
indexVariable: string,
|
|
143
143
|
loopLocalVariable: string,
|
|
144
|
-
mappingFunction: string => string = value => value,
|
|
144
|
+
mappingFunction: (v: string) => string = value => value,
|
|
145
145
|
) {
|
|
146
146
|
return `${propertyName}.setValueAtIndex(runtime, ${indexVariable}++, ${mappingFunction(
|
|
147
147
|
loopLocalVariable,
|
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
getNativeTypeFromAnnotation
|
|
10
10
|
} = require('./ComponentsGeneratorUtils.js');
|
|
11
11
|
const {
|
|
12
|
+
convertDefaultTypeToString,
|
|
12
13
|
generateStructName,
|
|
13
14
|
getDefaultInitializerString,
|
|
14
15
|
getEnumMaskName,
|
|
@@ -73,14 +74,15 @@ const EnumTemplate = ({
|
|
|
73
74
|
enumName,
|
|
74
75
|
values,
|
|
75
76
|
fromCases,
|
|
76
|
-
toCases
|
|
77
|
+
toCases,
|
|
78
|
+
defaultValue
|
|
77
79
|
}) => `
|
|
78
80
|
enum class ${enumName} { ${values} };
|
|
79
81
|
|
|
80
82
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ${enumName} &result) {
|
|
81
83
|
auto string = (std::string)value;
|
|
82
84
|
${fromCases}
|
|
83
|
-
|
|
85
|
+
result = ${defaultValue};
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
static inline std::string toString(const ${enumName} &value) {
|
|
@@ -102,7 +104,8 @@ const IntEnumTemplate = ({
|
|
|
102
104
|
values,
|
|
103
105
|
fromCases,
|
|
104
106
|
toCases,
|
|
105
|
-
toDynamicCases
|
|
107
|
+
toDynamicCases,
|
|
108
|
+
defaultValue
|
|
106
109
|
}) => `
|
|
107
110
|
enum class ${enumName} { ${values} };
|
|
108
111
|
|
|
@@ -111,7 +114,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
111
114
|
auto integerValue = (int)value;
|
|
112
115
|
switch (integerValue) {${fromCases}
|
|
113
116
|
default:
|
|
114
|
-
|
|
117
|
+
result = ${defaultValue};
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -302,7 +305,8 @@ function generateStringEnum(componentName, prop) {
|
|
|
302
305
|
enumName,
|
|
303
306
|
values: values.map(toSafeCppString).join(', '),
|
|
304
307
|
fromCases: fromCases,
|
|
305
|
-
toCases: toCases
|
|
308
|
+
toCases: toCases,
|
|
309
|
+
defaultValue: convertDefaultTypeToString(componentName, prop)
|
|
306
310
|
});
|
|
307
311
|
}
|
|
308
312
|
return '';
|
|
@@ -324,7 +328,8 @@ function generateIntEnum(componentName, prop) {
|
|
|
324
328
|
values: valueVariables,
|
|
325
329
|
fromCases,
|
|
326
330
|
toCases,
|
|
327
|
-
toDynamicCases
|
|
331
|
+
toDynamicCases,
|
|
332
|
+
defaultValue: convertDefaultTypeToString(componentName, prop)
|
|
328
333
|
});
|
|
329
334
|
}
|
|
330
335
|
return '';
|
|
@@ -23,6 +23,7 @@ const {
|
|
|
23
23
|
getNativeTypeFromAnnotation,
|
|
24
24
|
} = require('./ComponentsGeneratorUtils.js');
|
|
25
25
|
const {
|
|
26
|
+
convertDefaultTypeToString,
|
|
26
27
|
generateStructName,
|
|
27
28
|
getDefaultInitializerString,
|
|
28
29
|
getEnumMaskName,
|
|
@@ -106,11 +107,13 @@ const EnumTemplate = ({
|
|
|
106
107
|
values,
|
|
107
108
|
fromCases,
|
|
108
109
|
toCases,
|
|
110
|
+
defaultValue,
|
|
109
111
|
}: {
|
|
110
112
|
enumName: string,
|
|
111
113
|
values: string,
|
|
112
114
|
fromCases: string,
|
|
113
115
|
toCases: string,
|
|
116
|
+
defaultValue: string,
|
|
114
117
|
}) =>
|
|
115
118
|
`
|
|
116
119
|
enum class ${enumName} { ${values} };
|
|
@@ -118,7 +121,7 @@ enum class ${enumName} { ${values} };
|
|
|
118
121
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ${enumName} &result) {
|
|
119
122
|
auto string = (std::string)value;
|
|
120
123
|
${fromCases}
|
|
121
|
-
|
|
124
|
+
result = ${defaultValue};
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
static inline std::string toString(const ${enumName} &value) {
|
|
@@ -142,12 +145,14 @@ const IntEnumTemplate = ({
|
|
|
142
145
|
fromCases,
|
|
143
146
|
toCases,
|
|
144
147
|
toDynamicCases,
|
|
148
|
+
defaultValue,
|
|
145
149
|
}: {
|
|
146
150
|
enumName: string,
|
|
147
151
|
values: string,
|
|
148
152
|
fromCases: string,
|
|
149
153
|
toCases: string,
|
|
150
154
|
toDynamicCases: string,
|
|
155
|
+
defaultValue: string,
|
|
151
156
|
}) =>
|
|
152
157
|
`
|
|
153
158
|
enum class ${enumName} { ${values} };
|
|
@@ -157,7 +162,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
157
162
|
auto integerValue = (int)value;
|
|
158
163
|
switch (integerValue) {${fromCases}
|
|
159
164
|
default:
|
|
160
|
-
|
|
165
|
+
result = ${defaultValue};
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
|
|
@@ -419,6 +424,7 @@ function generateStringEnum(
|
|
|
419
424
|
values: values.map(toSafeCppString).join(', '),
|
|
420
425
|
fromCases: fromCases,
|
|
421
426
|
toCases: toCases,
|
|
427
|
+
defaultValue: convertDefaultTypeToString(componentName, prop),
|
|
422
428
|
});
|
|
423
429
|
}
|
|
424
430
|
|
|
@@ -474,6 +480,7 @@ function generateIntEnum(
|
|
|
474
480
|
fromCases,
|
|
475
481
|
toCases,
|
|
476
482
|
toDynamicCases,
|
|
483
|
+
defaultValue: convertDefaultTypeToString(componentName, prop),
|
|
477
484
|
});
|
|
478
485
|
}
|
|
479
486
|
|
|
@@ -649,7 +649,7 @@ function buildSchema(
|
|
|
649
649
|
parser: Parser,
|
|
650
650
|
translateTypeAnnotation: $FlowFixMe,
|
|
651
651
|
) => NativeModuleSchema,
|
|
652
|
-
Visitor: ({isComponent: boolean, isModule: boolean}) => {
|
|
652
|
+
Visitor: (v: {isComponent: boolean, isModule: boolean}) => {
|
|
653
653
|
[type: string]: (node: $FlowFixMe) => void,
|
|
654
654
|
},
|
|
655
655
|
parser: Parser,
|
|
@@ -137,7 +137,7 @@ function visit(
|
|
|
137
137
|
function getConfigType(
|
|
138
138
|
// TODO(T71778680): Flow-type this node.
|
|
139
139
|
ast: $FlowFixMe,
|
|
140
|
-
Visitor: ({isComponent: boolean, isModule: boolean}) => {
|
|
140
|
+
Visitor: (v: {isComponent: boolean, isModule: boolean}) => {
|
|
141
141
|
[type: string]: (node: $FlowFixMe) => void,
|
|
142
142
|
},
|
|
143
143
|
): 'module' | 'component' | 'none' {
|