@react-native/codegen 0.72.1 → 0.72.3
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.d.ts +348 -0
- package/lib/CodegenSchema.js.flow +31 -3
- package/lib/SchemaValidator.d.ts +11 -0
- package/lib/cli/combine/combine-js-to-schema.js +8 -8
- package/lib/cli/combine/combine-js-to-schema.js.flow +8 -7
- package/lib/cli/parser/parser.js +8 -15
- package/lib/cli/parser/parser.js.flow +8 -14
- package/lib/generators/Utils.js +16 -0
- package/lib/generators/Utils.js.flow +20 -0
- package/lib/generators/__test_fixtures__/fixtures.js +2 -1
- package/lib/generators/__test_fixtures__/fixtures.js.flow +2 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js +10 -1
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +12 -2
- package/lib/generators/components/CppHelpers.js +8 -15
- package/lib/generators/components/CppHelpers.js.flow +8 -19
- package/lib/generators/components/GenerateEventEmitterCpp.js +7 -3
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +7 -3
- package/lib/generators/components/GenerateEventEmitterH.js +2 -2
- package/lib/generators/components/GenerateEventEmitterH.js.flow +1 -2
- package/lib/generators/components/GeneratePropsH.js +3 -4
- package/lib/generators/components/GeneratePropsH.js.flow +2 -4
- package/lib/generators/components/GeneratePropsJavaDelegate.js +2 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js +3 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +3 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +8 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +12 -0
- package/lib/generators/components/GenerateTests.js +3 -2
- package/lib/generators/components/GenerateTests.js.flow +3 -1
- package/lib/generators/components/GenerateViewConfigJs.js +5 -2
- package/lib/generators/components/GenerateViewConfigJs.js.flow +5 -2
- package/lib/generators/components/JavaHelpers.js +9 -0
- package/lib/generators/components/JavaHelpers.js.flow +12 -1
- package/lib/generators/components/__test_fixtures__/fixtures.js +41 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +42 -0
- package/lib/generators/modules/GenerateModuleCpp.js +9 -4
- package/lib/generators/modules/GenerateModuleCpp.js.flow +11 -3
- package/lib/generators/modules/GenerateModuleH.js +185 -33
- package/lib/generators/modules/GenerateModuleH.js.flow +203 -25
- package/lib/generators/modules/GenerateModuleJavaSpec.js +2 -2
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleJniCpp.js +2 -2
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +5 -5
- package/lib/generators/modules/GenerateModuleObjCpp/index.js +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +2 -2
- package/lib/generators/modules/Utils.js +4 -0
- package/lib/generators/modules/Utils.js.flow +6 -0
- package/lib/generators/modules/__test_fixtures__/fixtures.js +152 -10
- package/lib/generators/modules/__test_fixtures__/fixtures.js.flow +152 -10
- package/lib/parsers/error-utils.js +42 -19
- package/lib/parsers/error-utils.js.flow +46 -19
- package/lib/parsers/errors.d.ts +10 -0
- package/lib/parsers/errors.js +9 -29
- package/lib/parsers/errors.js.flow +2 -20
- package/lib/parsers/flow/Visitor.js +37 -0
- package/lib/parsers/flow/Visitor.js.flow +41 -0
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +20 -2
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +20 -2
- package/lib/parsers/flow/components/commands.js +3 -0
- package/lib/parsers/flow/components/commands.js.flow +2 -1
- package/lib/parsers/flow/components/componentsUtils.js +10 -0
- package/lib/parsers/flow/components/componentsUtils.js.flow +11 -1
- package/lib/parsers/flow/components/events.js.flow +1 -1
- package/lib/parsers/flow/components/extends.js.flow +1 -1
- package/lib/parsers/flow/components/index.js +16 -20
- package/lib/parsers/flow/components/index.js.flow +8 -7
- package/lib/parsers/flow/components/options.js.flow +1 -1
- package/lib/parsers/flow/components/props.js.flow +1 -1
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js +54 -0
- package/lib/parsers/flow/modules/__test_fixtures__/failures.js.flow +56 -0
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +64 -1
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +66 -1
- package/lib/parsers/flow/modules/index.js +112 -48
- package/lib/parsers/flow/modules/index.js.flow +115 -44
- package/lib/parsers/flow/parser.d.ts +10 -0
- package/lib/parsers/flow/parser.js +173 -32
- package/lib/parsers/flow/parser.js.flow +201 -24
- package/lib/parsers/flow/utils.js +33 -57
- package/lib/parsers/flow/utils.js.flow +37 -60
- package/lib/parsers/parser.d.ts +17 -0
- package/lib/parsers/parser.js.flow +124 -17
- package/lib/parsers/parserMock.js +101 -30
- package/lib/parsers/parserMock.js.flow +139 -24
- package/lib/parsers/parsers-commons.js +121 -119
- package/lib/parsers/parsers-commons.js.flow +136 -131
- package/lib/parsers/parsers-primitives.js +75 -12
- package/lib/parsers/parsers-primitives.js.flow +92 -13
- package/lib/parsers/schema/index.d.ts +10 -0
- package/lib/parsers/{typescript/components/schema.js.flow → schema.js.flow} +1 -1
- package/lib/parsers/typescript/Visitor.js +42 -0
- package/lib/parsers/typescript/Visitor.js.flow +47 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +22 -0
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +22 -0
- package/lib/parsers/typescript/components/commands.js +3 -0
- package/lib/parsers/typescript/components/commands.js.flow +2 -1
- package/lib/parsers/typescript/components/componentsUtils.js +5 -0
- package/lib/parsers/typescript/components/componentsUtils.js.flow +6 -1
- package/lib/parsers/typescript/components/events.js.flow +1 -1
- package/lib/parsers/typescript/components/extends.js.flow +1 -1
- package/lib/parsers/typescript/components/index.js +15 -19
- package/lib/parsers/typescript/components/index.js.flow +8 -7
- package/lib/parsers/typescript/components/options.js.flow +1 -1
- package/lib/parsers/typescript/components/props.js.flow +1 -1
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js +52 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/failures.js.flow +54 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js +142 -0
- package/lib/parsers/typescript/modules/__test_fixtures__/fixtures.js.flow +146 -0
- package/lib/parsers/typescript/modules/index.js +276 -110
- package/lib/parsers/typescript/modules/index.js.flow +237 -68
- package/lib/parsers/typescript/parser.d.ts +10 -0
- package/lib/parsers/typescript/parser.js +175 -25
- package/lib/parsers/typescript/parser.js.flow +184 -26
- package/lib/parsers/typescript/utils.js +40 -51
- package/lib/parsers/typescript/utils.js.flow +44 -55
- package/lib/parsers/utils.js +0 -125
- package/lib/parsers/utils.js.flow +3 -70
- package/package.json +4 -1
- package/lib/parsers/flow/components/schema.js +0 -106
- package/lib/parsers/flow/components/schema.js.flow +0 -62
- package/lib/parsers/flow/index.js +0 -80
- package/lib/parsers/flow/index.js.flow +0 -85
- package/lib/parsers/typescript/index.js +0 -85
- package/lib/parsers/typescript/index.js.flow +0 -94
- /package/lib/parsers/{typescript/components/schema.js → schema.js} +0 -0
|
@@ -207,7 +207,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
207
207
|
|
|
208
208
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
209
209
|
import type {ImageSource} from 'ImageSource';
|
|
210
|
-
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
210
|
+
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
211
211
|
import type {ViewProps} from 'ViewPropTypes';
|
|
212
212
|
import type {HostComponent} from 'react-native';
|
|
213
213
|
|
|
@@ -307,6 +307,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
307
307
|
insets_optional_key?: EdgeInsetsValue,
|
|
308
308
|
insets_optional_value: ?EdgeInsetsValue,
|
|
309
309
|
insets_optional_both?: ?EdgeInsetsValue,
|
|
310
|
+
|
|
311
|
+
// DimensionValue props
|
|
312
|
+
dimension_required: DimensionValue,
|
|
313
|
+
dimension_optional_key?: DimensionValue,
|
|
314
|
+
dimension_optional_value: ?DimensionValue,
|
|
315
|
+
dimension_optional_both?: ?DimensionValue,
|
|
310
316
|
|}>;
|
|
311
317
|
|
|
312
318
|
export default (codegenNativeComponent<ModuleProps, Options>(
|
|
@@ -330,7 +336,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
330
336
|
|
|
331
337
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
332
338
|
import type {ImageSource} from 'ImageSource';
|
|
333
|
-
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
339
|
+
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
334
340
|
import type {ViewProps} from 'ViewPropTypes';
|
|
335
341
|
import type {HostComponent} from 'react-native';
|
|
336
342
|
|
|
@@ -405,6 +411,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
405
411
|
array_insets_optional_value: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
406
412
|
array_insets_optional_both?: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
407
413
|
|
|
414
|
+
// DimensionValue props
|
|
415
|
+
array_dimension_required: $ReadOnlyArray<DimensionValue>,
|
|
416
|
+
array_dimension_optional_key?: $ReadOnlyArray<DimensionValue>,
|
|
417
|
+
array_dimension_optional_value: ?$ReadOnlyArray<DimensionValue>,
|
|
418
|
+
array_dimension_optional_both?: ?$ReadOnlyArray<DimensionValue>,
|
|
419
|
+
|
|
408
420
|
// Object props
|
|
409
421
|
array_object_required: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
410
422
|
array_object_optional_key?: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
@@ -545,6 +557,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
545
557
|
insets_optional_value: $ReadOnly<{|prop: ?EdgeInsetsValue|}>,
|
|
546
558
|
insets_optional_both: $ReadOnly<{|prop?: ?EdgeInsetsValue|}>,
|
|
547
559
|
|
|
560
|
+
// DimensionValue props
|
|
561
|
+
dimension_required: $ReadOnly<{|prop: DimensionValue|}>,
|
|
562
|
+
dimension_optional_key: $ReadOnly<{|prop?: DimensionValue|}>,
|
|
563
|
+
dimension_optional_value: $ReadOnly<{|prop: ?DimensionValue|}>,
|
|
564
|
+
dimension_optional_both: $ReadOnly<{|prop?: ?DimensionValue|}>,
|
|
565
|
+
|
|
548
566
|
// Nested object props
|
|
549
567
|
object_required: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
550
568
|
object_optional_key?: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
@@ -211,7 +211,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
211
211
|
|
|
212
212
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
213
213
|
import type {ImageSource} from 'ImageSource';
|
|
214
|
-
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
214
|
+
import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
215
215
|
import type {ViewProps} from 'ViewPropTypes';
|
|
216
216
|
import type {HostComponent} from 'react-native';
|
|
217
217
|
|
|
@@ -311,6 +311,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
311
311
|
insets_optional_key?: EdgeInsetsValue,
|
|
312
312
|
insets_optional_value: ?EdgeInsetsValue,
|
|
313
313
|
insets_optional_both?: ?EdgeInsetsValue,
|
|
314
|
+
|
|
315
|
+
// DimensionValue props
|
|
316
|
+
dimension_required: DimensionValue,
|
|
317
|
+
dimension_optional_key?: DimensionValue,
|
|
318
|
+
dimension_optional_value: ?DimensionValue,
|
|
319
|
+
dimension_optional_both?: ?DimensionValue,
|
|
314
320
|
|}>;
|
|
315
321
|
|
|
316
322
|
export default (codegenNativeComponent<ModuleProps, Options>(
|
|
@@ -335,7 +341,7 @@ const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
335
341
|
|
|
336
342
|
import type {Int32, Double, Float, WithDefault} from 'CodegenTypes';
|
|
337
343
|
import type {ImageSource} from 'ImageSource';
|
|
338
|
-
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue} from 'StyleSheetTypes';
|
|
344
|
+
import type {ColorValue, PointValue, ProcessColorValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes';
|
|
339
345
|
import type {ViewProps} from 'ViewPropTypes';
|
|
340
346
|
import type {HostComponent} from 'react-native';
|
|
341
347
|
|
|
@@ -410,6 +416,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
410
416
|
array_insets_optional_value: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
411
417
|
array_insets_optional_both?: ?$ReadOnlyArray<EdgeInsetsValue>,
|
|
412
418
|
|
|
419
|
+
// DimensionValue props
|
|
420
|
+
array_dimension_required: $ReadOnlyArray<DimensionValue>,
|
|
421
|
+
array_dimension_optional_key?: $ReadOnlyArray<DimensionValue>,
|
|
422
|
+
array_dimension_optional_value: ?$ReadOnlyArray<DimensionValue>,
|
|
423
|
+
array_dimension_optional_both?: ?$ReadOnlyArray<DimensionValue>,
|
|
424
|
+
|
|
413
425
|
// Object props
|
|
414
426
|
array_object_required: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
415
427
|
array_object_optional_key?: $ReadOnlyArray<$ReadOnly<{| prop: string |}>>,
|
|
@@ -551,6 +563,12 @@ type ModuleProps = $ReadOnly<{|
|
|
|
551
563
|
insets_optional_value: $ReadOnly<{|prop: ?EdgeInsetsValue|}>,
|
|
552
564
|
insets_optional_both: $ReadOnly<{|prop?: ?EdgeInsetsValue|}>,
|
|
553
565
|
|
|
566
|
+
// DimensionValue props
|
|
567
|
+
dimension_required: $ReadOnly<{|prop: DimensionValue|}>,
|
|
568
|
+
dimension_optional_key: $ReadOnly<{|prop?: DimensionValue|}>,
|
|
569
|
+
dimension_optional_value: $ReadOnly<{|prop: ?DimensionValue|}>,
|
|
570
|
+
dimension_optional_both: $ReadOnly<{|prop?: ?DimensionValue|}>,
|
|
571
|
+
|
|
554
572
|
// Nested object props
|
|
555
573
|
object_required: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
556
574
|
object_optional_key?: $ReadOnly<{|prop: $ReadOnly<{nestedProp: string}>|}>,
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
const _require = require('../utils.js'),
|
|
14
14
|
getValueFromTypes = _require.getValueFromTypes;
|
|
15
|
+
|
|
16
|
+
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
17
|
+
|
|
15
18
|
function buildCommandSchema(property, types) {
|
|
16
19
|
const name = property.key.name;
|
|
17
20
|
const optional = property.optional;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -18,6 +18,7 @@ import type {TypeDeclarationMap} from '../../utils';
|
|
|
18
18
|
|
|
19
19
|
const {getValueFromTypes} = require('../utils.js');
|
|
20
20
|
|
|
21
|
+
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
21
22
|
type EventTypeAST = Object;
|
|
22
23
|
|
|
23
24
|
function buildCommandSchema(property: EventTypeAST, types: TypeDeclarationMap) {
|
|
@@ -109,6 +109,11 @@ function getTypeAnnotationForArray(
|
|
|
109
109
|
type: 'ReservedPropTypeAnnotation',
|
|
110
110
|
name: 'EdgeInsetsPrimitive',
|
|
111
111
|
};
|
|
112
|
+
case 'DimensionValue':
|
|
113
|
+
return {
|
|
114
|
+
type: 'ReservedPropTypeAnnotation',
|
|
115
|
+
name: 'DimensionPrimitive',
|
|
116
|
+
};
|
|
112
117
|
case 'Stringish':
|
|
113
118
|
return {
|
|
114
119
|
type: 'StringTypeAnnotation',
|
|
@@ -274,6 +279,11 @@ function getTypeAnnotation(
|
|
|
274
279
|
type: 'ReservedPropTypeAnnotation',
|
|
275
280
|
name: 'EdgeInsetsPrimitive',
|
|
276
281
|
};
|
|
282
|
+
case 'DimensionValue':
|
|
283
|
+
return {
|
|
284
|
+
type: 'ReservedPropTypeAnnotation',
|
|
285
|
+
name: 'DimensionPrimitive',
|
|
286
|
+
};
|
|
277
287
|
case 'Int32':
|
|
278
288
|
return {
|
|
279
289
|
type: 'Int32TypeAnnotation',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -123,6 +123,11 @@ function getTypeAnnotationForArray<+T>(
|
|
|
123
123
|
type: 'ReservedPropTypeAnnotation',
|
|
124
124
|
name: 'EdgeInsetsPrimitive',
|
|
125
125
|
};
|
|
126
|
+
case 'DimensionValue':
|
|
127
|
+
return {
|
|
128
|
+
type: 'ReservedPropTypeAnnotation',
|
|
129
|
+
name: 'DimensionPrimitive',
|
|
130
|
+
};
|
|
126
131
|
case 'Stringish':
|
|
127
132
|
return {
|
|
128
133
|
type: 'StringTypeAnnotation',
|
|
@@ -303,6 +308,11 @@ function getTypeAnnotation<+T>(
|
|
|
303
308
|
type: 'ReservedPropTypeAnnotation',
|
|
304
309
|
name: 'EdgeInsetsPrimitive',
|
|
305
310
|
};
|
|
311
|
+
case 'DimensionValue':
|
|
312
|
+
return {
|
|
313
|
+
type: 'ReservedPropTypeAnnotation',
|
|
314
|
+
name: 'DimensionPrimitive',
|
|
315
|
+
};
|
|
306
316
|
case 'Int32':
|
|
307
317
|
return {
|
|
308
318
|
type: 'Int32TypeAnnotation',
|
|
@@ -72,22 +72,20 @@ function _toPrimitive(input, hint) {
|
|
|
72
72
|
}
|
|
73
73
|
return (hint === 'string' ? String : Number)(input);
|
|
74
74
|
}
|
|
75
|
-
const _require = require('
|
|
76
|
-
|
|
77
|
-
const _require2 = require('./
|
|
78
|
-
|
|
79
|
-
const _require3 = require('./
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const _require6 = require('./
|
|
88
|
-
|
|
89
|
-
const _require7 = require('./componentsUtils.js'),
|
|
90
|
-
getProperties = _require7.getProperties;
|
|
75
|
+
const _require = require('./commands'),
|
|
76
|
+
getCommands = _require.getCommands;
|
|
77
|
+
const _require2 = require('./events'),
|
|
78
|
+
getEvents = _require2.getEvents;
|
|
79
|
+
const _require3 = require('./extends'),
|
|
80
|
+
getExtendsProps = _require3.getExtendsProps,
|
|
81
|
+
removeKnownExtends = _require3.removeKnownExtends;
|
|
82
|
+
const _require4 = require('./options'),
|
|
83
|
+
getCommandOptions = _require4.getCommandOptions,
|
|
84
|
+
getOptions = _require4.getOptions;
|
|
85
|
+
const _require5 = require('./props'),
|
|
86
|
+
getProps = _require5.getProps;
|
|
87
|
+
const _require6 = require('./componentsUtils.js'),
|
|
88
|
+
getProperties = _require6.getProperties;
|
|
91
89
|
|
|
92
90
|
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
93
91
|
* LTI update could not be added via codemod */
|
|
@@ -229,16 +227,14 @@ function getCommandProperties(
|
|
|
229
227
|
}
|
|
230
228
|
|
|
231
229
|
// $FlowFixMe[signature-verification-failure] there's no flowtype for AST
|
|
232
|
-
|
|
233
|
-
* LTI update could not be added via codemod */
|
|
234
|
-
function buildComponentSchema(ast) {
|
|
230
|
+
function buildComponentSchema(ast, parser) {
|
|
235
231
|
const _findComponentConfig = findComponentConfig(ast),
|
|
236
232
|
componentName = _findComponentConfig.componentName,
|
|
237
233
|
propsTypeName = _findComponentConfig.propsTypeName,
|
|
238
234
|
commandTypeName = _findComponentConfig.commandTypeName,
|
|
239
235
|
commandOptionsExpression = _findComponentConfig.commandOptionsExpression,
|
|
240
236
|
optionsExpression = _findComponentConfig.optionsExpression;
|
|
241
|
-
const types = getTypes(ast);
|
|
237
|
+
const types = parser.getTypes(ast);
|
|
242
238
|
const propProperties = getProperties(propsTypeName, types);
|
|
243
239
|
const commandOptions = getCommandOptions(commandOptionsExpression);
|
|
244
240
|
const commandProperties = getCommandProperties(
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
import type {Parser} from '../../parser';
|
|
12
13
|
import type {TypeDeclarationMap} from '../../utils';
|
|
13
14
|
import type {CommandOptions} from './options';
|
|
14
|
-
import type {ComponentSchemaBuilderConfig} from '
|
|
15
|
+
import type {ComponentSchemaBuilderConfig} from '../../schema.js';
|
|
15
16
|
|
|
16
|
-
const {getTypes} = require('../utils');
|
|
17
17
|
const {getCommands} = require('./commands');
|
|
18
18
|
const {getEvents} = require('./events');
|
|
19
19
|
const {getExtendsProps, removeKnownExtends} = require('./extends');
|
|
@@ -180,9 +180,10 @@ function getCommandProperties(
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// $FlowFixMe[signature-verification-failure] there's no flowtype for AST
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
function buildComponentSchema(
|
|
184
|
+
ast: $FlowFixMe,
|
|
185
|
+
parser: Parser,
|
|
186
|
+
): ComponentSchemaBuilderConfig {
|
|
186
187
|
const {
|
|
187
188
|
componentName,
|
|
188
189
|
propsTypeName,
|
|
@@ -191,7 +192,7 @@ function buildComponentSchema(ast): ComponentSchemaBuilderConfig {
|
|
|
191
192
|
optionsExpression,
|
|
192
193
|
} = findComponentConfig(ast);
|
|
193
194
|
|
|
194
|
-
const types = getTypes(ast);
|
|
195
|
+
const types = parser.getTypes(ast);
|
|
195
196
|
|
|
196
197
|
const propProperties = getProperties(propsTypeName, types);
|
|
197
198
|
const commandOptions = getCommandOptions(commandOptionsExpression);
|
|
@@ -202,6 +202,58 @@ export interface Spec2 extends TurboModule {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
|
|
205
|
+
`;
|
|
206
|
+
const EMPTY_ENUM_NATIVE_MODULE = `
|
|
207
|
+
/**
|
|
208
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
209
|
+
*
|
|
210
|
+
* This source code is licensed under the MIT license found in the
|
|
211
|
+
* LICENSE file in the root directory of this source tree.
|
|
212
|
+
*
|
|
213
|
+
* @flow strict-local
|
|
214
|
+
* @format
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
'use strict';
|
|
218
|
+
|
|
219
|
+
import type {TurboModule} from '../RCTExport';
|
|
220
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
221
|
+
|
|
222
|
+
export enum SomeEnum {
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface Spec extends TurboModule {
|
|
226
|
+
+getEnums: (a: SomeEnum) => string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('EmptyEnumNativeModule');
|
|
230
|
+
`;
|
|
231
|
+
const MIXED_VALUES_ENUM_NATIVE_MODULE = `
|
|
232
|
+
/**
|
|
233
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
234
|
+
*
|
|
235
|
+
* This source code is licensed under the MIT license found in the
|
|
236
|
+
* LICENSE file in the root directory of this source tree.
|
|
237
|
+
*
|
|
238
|
+
* @flow strict-local
|
|
239
|
+
* @format
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
'use strict';
|
|
243
|
+
|
|
244
|
+
import type {TurboModule} from '../RCTExport';
|
|
245
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
246
|
+
|
|
247
|
+
export enum SomeEnum {
|
|
248
|
+
NUM = 1,
|
|
249
|
+
STR = 'str',
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface Spec extends TurboModule {
|
|
253
|
+
+getEnums: (a: SomeEnum) => string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('MixedValuesEnumNativeModule');
|
|
205
257
|
`;
|
|
206
258
|
module.exports = {
|
|
207
259
|
NATIVE_MODULES_WITH_READ_ONLY_OBJECT_NO_TYPE_FOR_CONTENT,
|
|
@@ -212,4 +264,6 @@ module.exports = {
|
|
|
212
264
|
TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT,
|
|
213
265
|
NATIVE_MODULES_WITH_NOT_ONLY_METHODS,
|
|
214
266
|
TWO_NATIVE_EXTENDING_TURBO_MODULE,
|
|
267
|
+
EMPTY_ENUM_NATIVE_MODULE,
|
|
268
|
+
MIXED_VALUES_ENUM_NATIVE_MODULE,
|
|
215
269
|
};
|
|
@@ -211,6 +211,60 @@ export interface Spec2 extends TurboModule {
|
|
|
211
211
|
|
|
212
212
|
`;
|
|
213
213
|
|
|
214
|
+
const EMPTY_ENUM_NATIVE_MODULE = `
|
|
215
|
+
/**
|
|
216
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
217
|
+
*
|
|
218
|
+
* This source code is licensed under the MIT license found in the
|
|
219
|
+
* LICENSE file in the root directory of this source tree.
|
|
220
|
+
*
|
|
221
|
+
* @flow strict-local
|
|
222
|
+
* @format
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
'use strict';
|
|
226
|
+
|
|
227
|
+
import type {TurboModule} from '../RCTExport';
|
|
228
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
229
|
+
|
|
230
|
+
export enum SomeEnum {
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface Spec extends TurboModule {
|
|
234
|
+
+getEnums: (a: SomeEnum) => string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('EmptyEnumNativeModule');
|
|
238
|
+
`;
|
|
239
|
+
|
|
240
|
+
const MIXED_VALUES_ENUM_NATIVE_MODULE = `
|
|
241
|
+
/**
|
|
242
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
243
|
+
*
|
|
244
|
+
* This source code is licensed under the MIT license found in the
|
|
245
|
+
* LICENSE file in the root directory of this source tree.
|
|
246
|
+
*
|
|
247
|
+
* @flow strict-local
|
|
248
|
+
* @format
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
'use strict';
|
|
252
|
+
|
|
253
|
+
import type {TurboModule} from '../RCTExport';
|
|
254
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
255
|
+
|
|
256
|
+
export enum SomeEnum {
|
|
257
|
+
NUM = 1,
|
|
258
|
+
STR = 'str',
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface Spec extends TurboModule {
|
|
262
|
+
+getEnums: (a: SomeEnum) => string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('MixedValuesEnumNativeModule');
|
|
266
|
+
`;
|
|
267
|
+
|
|
214
268
|
module.exports = {
|
|
215
269
|
NATIVE_MODULES_WITH_READ_ONLY_OBJECT_NO_TYPE_FOR_CONTENT,
|
|
216
270
|
NATIVE_MODULES_WITH_UNNAMED_PARAMS,
|
|
@@ -220,4 +274,6 @@ module.exports = {
|
|
|
220
274
|
TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT,
|
|
221
275
|
NATIVE_MODULES_WITH_NOT_ONLY_METHODS,
|
|
222
276
|
TWO_NATIVE_EXTENDING_TURBO_MODULE,
|
|
277
|
+
EMPTY_ENUM_NATIVE_MODULE,
|
|
278
|
+
MIXED_VALUES_ENUM_NATIVE_MODULE,
|
|
223
279
|
};
|
|
@@ -278,6 +278,66 @@ export interface Spec extends TurboModule {
|
|
|
278
278
|
|
|
279
279
|
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
280
280
|
|
|
281
|
+
`;
|
|
282
|
+
const NATIVE_MODULE_WITH_PARTIALS = `
|
|
283
|
+
/**
|
|
284
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
285
|
+
*
|
|
286
|
+
* This source code is licensed under the MIT license found in the
|
|
287
|
+
* LICENSE file in the root directory of this source tree.
|
|
288
|
+
*
|
|
289
|
+
* @flow strict-local
|
|
290
|
+
* @format
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
'use strict';
|
|
294
|
+
|
|
295
|
+
import type {TurboModule} from '../RCTExport';
|
|
296
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
297
|
+
|
|
298
|
+
export type SomeObj = {|
|
|
299
|
+
a: string,
|
|
300
|
+
b?: boolean,
|
|
301
|
+
|};
|
|
302
|
+
|
|
303
|
+
export interface Spec extends TurboModule {
|
|
304
|
+
+getSomeObj: () => SomeObj;
|
|
305
|
+
+getPartialSomeObj: () => $Partial<SomeObj>;
|
|
306
|
+
+getSomeObjFromPartialSomeObj: (value: $Partial<SomeObj>) => SomeObj;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
310
|
+
|
|
311
|
+
`;
|
|
312
|
+
const NATIVE_MODULE_WITH_PARTIALS_COMPLEX = `
|
|
313
|
+
/**
|
|
314
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
315
|
+
*
|
|
316
|
+
* This source code is licensed under the MIT license found in the
|
|
317
|
+
* LICENSE file in the root directory of this source tree.
|
|
318
|
+
*
|
|
319
|
+
* @flow strict-local
|
|
320
|
+
* @format
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
'use strict';
|
|
324
|
+
|
|
325
|
+
import type {TurboModule} from '../RCTExport';
|
|
326
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
327
|
+
|
|
328
|
+
export type SomeObj = {|
|
|
329
|
+
a: string,
|
|
330
|
+
b?: boolean,
|
|
331
|
+
|};
|
|
332
|
+
|
|
333
|
+
export type PartialSomeObj = $Partial<SomeObj>;
|
|
334
|
+
|
|
335
|
+
export interface Spec extends TurboModule {
|
|
336
|
+
+getPartialPartial: (value1: $Partial<SomeObj>, value2: PartialSomeObj) => SomeObj
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
340
|
+
|
|
281
341
|
`;
|
|
282
342
|
const NATIVE_MODULE_WITH_ROOT_TAG = `
|
|
283
343
|
/**
|
|
@@ -690,7 +750,8 @@ export interface Spec extends TurboModule {
|
|
|
690
750
|
returnObjectArray(): Promise<Array<Object>>;
|
|
691
751
|
returnNullableNumber(): Promise<number | null>;
|
|
692
752
|
returnEmpty(): Promise<empty>;
|
|
693
|
-
|
|
753
|
+
returnUnsupportedIndex(): Promise<{ [string]: 'authorized' | 'denied' | 'undetermined' | true | false }>;
|
|
754
|
+
returnSupportedIndex(): Promise<{ [string]: CustomObject }>;
|
|
694
755
|
returnEnum() : Promise<Season>;
|
|
695
756
|
returnObject() : Promise<CustomObject>;
|
|
696
757
|
}
|
|
@@ -708,6 +769,8 @@ module.exports = {
|
|
|
708
769
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY,
|
|
709
770
|
NATIVE_MODULE_WITH_SIMPLE_OBJECT,
|
|
710
771
|
NATIVE_MODULE_WITH_UNSAFE_OBJECT,
|
|
772
|
+
NATIVE_MODULE_WITH_PARTIALS,
|
|
773
|
+
NATIVE_MODULE_WITH_PARTIALS_COMPLEX,
|
|
711
774
|
NATIVE_MODULE_WITH_ROOT_TAG,
|
|
712
775
|
NATIVE_MODULE_WITH_NULLABLE_PARAM,
|
|
713
776
|
NATIVE_MODULE_WITH_BASIC_ARRAY,
|
|
@@ -288,6 +288,68 @@ export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
|
288
288
|
|
|
289
289
|
`;
|
|
290
290
|
|
|
291
|
+
const NATIVE_MODULE_WITH_PARTIALS = `
|
|
292
|
+
/**
|
|
293
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
294
|
+
*
|
|
295
|
+
* This source code is licensed under the MIT license found in the
|
|
296
|
+
* LICENSE file in the root directory of this source tree.
|
|
297
|
+
*
|
|
298
|
+
* @flow strict-local
|
|
299
|
+
* @format
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
'use strict';
|
|
303
|
+
|
|
304
|
+
import type {TurboModule} from '../RCTExport';
|
|
305
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
306
|
+
|
|
307
|
+
export type SomeObj = {|
|
|
308
|
+
a: string,
|
|
309
|
+
b?: boolean,
|
|
310
|
+
|};
|
|
311
|
+
|
|
312
|
+
export interface Spec extends TurboModule {
|
|
313
|
+
+getSomeObj: () => SomeObj;
|
|
314
|
+
+getPartialSomeObj: () => $Partial<SomeObj>;
|
|
315
|
+
+getSomeObjFromPartialSomeObj: (value: $Partial<SomeObj>) => SomeObj;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
319
|
+
|
|
320
|
+
`;
|
|
321
|
+
|
|
322
|
+
const NATIVE_MODULE_WITH_PARTIALS_COMPLEX = `
|
|
323
|
+
/**
|
|
324
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
325
|
+
*
|
|
326
|
+
* This source code is licensed under the MIT license found in the
|
|
327
|
+
* LICENSE file in the root directory of this source tree.
|
|
328
|
+
*
|
|
329
|
+
* @flow strict-local
|
|
330
|
+
* @format
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
'use strict';
|
|
334
|
+
|
|
335
|
+
import type {TurboModule} from '../RCTExport';
|
|
336
|
+
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
|
337
|
+
|
|
338
|
+
export type SomeObj = {|
|
|
339
|
+
a: string,
|
|
340
|
+
b?: boolean,
|
|
341
|
+
|};
|
|
342
|
+
|
|
343
|
+
export type PartialSomeObj = $Partial<SomeObj>;
|
|
344
|
+
|
|
345
|
+
export interface Spec extends TurboModule {
|
|
346
|
+
+getPartialPartial: (value1: $Partial<SomeObj>, value2: PartialSomeObj) => SomeObj
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
|
350
|
+
|
|
351
|
+
`;
|
|
352
|
+
|
|
291
353
|
const NATIVE_MODULE_WITH_ROOT_TAG = `
|
|
292
354
|
/**
|
|
293
355
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -712,7 +774,8 @@ export interface Spec extends TurboModule {
|
|
|
712
774
|
returnObjectArray(): Promise<Array<Object>>;
|
|
713
775
|
returnNullableNumber(): Promise<number | null>;
|
|
714
776
|
returnEmpty(): Promise<empty>;
|
|
715
|
-
|
|
777
|
+
returnUnsupportedIndex(): Promise<{ [string]: 'authorized' | 'denied' | 'undetermined' | true | false }>;
|
|
778
|
+
returnSupportedIndex(): Promise<{ [string]: CustomObject }>;
|
|
716
779
|
returnEnum() : Promise<Season>;
|
|
717
780
|
returnObject() : Promise<CustomObject>;
|
|
718
781
|
}
|
|
@@ -731,6 +794,8 @@ module.exports = {
|
|
|
731
794
|
NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY,
|
|
732
795
|
NATIVE_MODULE_WITH_SIMPLE_OBJECT,
|
|
733
796
|
NATIVE_MODULE_WITH_UNSAFE_OBJECT,
|
|
797
|
+
NATIVE_MODULE_WITH_PARTIALS,
|
|
798
|
+
NATIVE_MODULE_WITH_PARTIALS_COMPLEX,
|
|
734
799
|
NATIVE_MODULE_WITH_ROOT_TAG,
|
|
735
800
|
NATIVE_MODULE_WITH_NULLABLE_PARAM,
|
|
736
801
|
NATIVE_MODULE_WITH_BASIC_ARRAY,
|