@react-native/codegen 0.72.2 → 0.72.4
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 +10 -10
- package/lib/CodegenSchema.js.flow +6 -1
- package/lib/SchemaValidator.d.ts +1 -1
- package/lib/generators/RNCodegen.d.ts +98 -0
- package/lib/generators/RNCodegen.js +33 -4
- package/lib/generators/RNCodegen.js.flow +35 -4
- package/lib/generators/components/ComponentsGeneratorUtils.js +2 -0
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +2 -0
- package/lib/generators/components/CppHelpers.js +2 -0
- package/lib/generators/components/CppHelpers.js.flow +2 -0
- package/lib/generators/components/GeneratePropsH.js +2 -0
- package/lib/generators/components/GeneratePropsH.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js +2 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js +2 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +2 -0
- package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +3 -1
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +5 -0
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +6 -0
- package/lib/generators/components/GenerateViewConfigJs.js +1 -0
- package/lib/generators/components/GenerateViewConfigJs.js.flow +1 -0
- package/lib/generators/components/JavaHelpers.js +7 -0
- package/lib/generators/components/JavaHelpers.js.flow +8 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js +29 -0
- package/lib/generators/components/__test_fixtures__/fixtures.js.flow +30 -0
- package/lib/parsers/error-utils.js +50 -15
- package/lib/parsers/error-utils.js.flow +57 -15
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +5 -1
- package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +5 -1
- package/lib/parsers/flow/components/componentsUtils.js +4 -0
- package/lib/parsers/flow/components/componentsUtils.js.flow +4 -0
- package/lib/parsers/flow/components/index.js +27 -126
- package/lib/parsers/flow/components/index.js.flow +22 -52
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +4 -4
- package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +4 -4
- package/lib/parsers/flow/modules/index.js +41 -317
- package/lib/parsers/flow/modules/index.js.flow +19 -247
- package/lib/parsers/flow/parser.js +119 -12
- package/lib/parsers/flow/parser.js.flow +124 -3
- package/lib/parsers/flow/utils.js +0 -38
- package/lib/parsers/flow/utils.js.flow +0 -38
- package/lib/parsers/parser.d.ts +2 -2
- package/lib/parsers/parser.js.flow +84 -0
- package/lib/parsers/parserMock.js +58 -0
- package/lib/parsers/parserMock.js.flow +72 -0
- package/lib/parsers/parsers-commons.js +362 -5
- package/lib/parsers/parsers-commons.js.flow +351 -8
- package/lib/parsers/parsers-primitives.js +119 -3
- package/lib/parsers/parsers-primitives.js.flow +128 -3
- package/lib/parsers/schema/index.d.ts +1 -1
- package/lib/parsers/{typescript/components/schema.js.flow → schema.js.flow} +1 -1
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +5 -1
- package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +5 -1
- package/lib/parsers/typescript/components/componentsUtils.js +8 -0
- package/lib/parsers/typescript/components/componentsUtils.js.flow +8 -0
- package/lib/parsers/typescript/components/index.js +28 -127
- package/lib/parsers/typescript/components/index.js.flow +24 -54
- package/lib/parsers/typescript/modules/index.js +103 -434
- package/lib/parsers/typescript/modules/index.js.flow +85 -299
- package/lib/parsers/typescript/parser.js +113 -12
- package/lib/parsers/typescript/parser.js.flow +115 -3
- package/lib/parsers/typescript/utils.js +0 -31
- package/lib/parsers/typescript/utils.js.flow +0 -31
- package/lib/parsers/utils.js +4 -0
- package/lib/parsers/utils.js.flow +3 -0
- package/package.json +1 -1
- package/lib/parsers/flow/Visitor.js +0 -37
- package/lib/parsers/flow/Visitor.js.flow +0 -41
- package/lib/parsers/flow/components/options.js +0 -72
- package/lib/parsers/flow/components/options.js.flow +0 -87
- package/lib/parsers/flow/components/schema.js +0 -106
- package/lib/parsers/flow/components/schema.js.flow +0 -62
- package/lib/parsers/typescript/Visitor.js +0 -42
- package/lib/parsers/typescript/Visitor.js.flow +0 -47
- package/lib/parsers/typescript/components/options.js +0 -72
- package/lib/parsers/typescript/components/options.js.flow +0 -87
- /package/lib/parsers/{typescript/components/schema.js → schema.js} +0 -0
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const _require = require('../utils'),
|
|
14
|
-
isModuleRegistryCall = _require.isModuleRegistryCall;
|
|
15
|
-
function Visitor(infoMap) {
|
|
16
|
-
return {
|
|
17
|
-
CallExpression(node) {
|
|
18
|
-
if (
|
|
19
|
-
node.callee.type === 'Identifier' &&
|
|
20
|
-
node.callee.name === 'codegenNativeComponent'
|
|
21
|
-
) {
|
|
22
|
-
infoMap.isComponent = true;
|
|
23
|
-
}
|
|
24
|
-
if (isModuleRegistryCall(node)) {
|
|
25
|
-
infoMap.isModule = true;
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
TSInterfaceDeclaration(node) {
|
|
29
|
-
if (
|
|
30
|
-
Array.isArray(node.extends) &&
|
|
31
|
-
node.extends.some(
|
|
32
|
-
extension => extension.expression.name === 'TurboModule',
|
|
33
|
-
)
|
|
34
|
-
) {
|
|
35
|
-
infoMap.isModule = true;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
module.exports = {
|
|
41
|
-
Visitor,
|
|
42
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const {isModuleRegistryCall} = require('../utils');
|
|
14
|
-
|
|
15
|
-
function Visitor(infoMap: {isComponent: boolean, isModule: boolean}): {
|
|
16
|
-
[type: string]: (node: $FlowFixMe) => void,
|
|
17
|
-
} {
|
|
18
|
-
return {
|
|
19
|
-
CallExpression(node: $FlowFixMe) {
|
|
20
|
-
if (
|
|
21
|
-
node.callee.type === 'Identifier' &&
|
|
22
|
-
node.callee.name === 'codegenNativeComponent'
|
|
23
|
-
) {
|
|
24
|
-
infoMap.isComponent = true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isModuleRegistryCall(node)) {
|
|
28
|
-
infoMap.isModule = true;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
TSInterfaceDeclaration(node: $FlowFixMe) {
|
|
33
|
-
if (
|
|
34
|
-
Array.isArray(node.extends) &&
|
|
35
|
-
node.extends.some(
|
|
36
|
-
extension => extension.expression.name === 'TurboModule',
|
|
37
|
-
)
|
|
38
|
-
) {
|
|
39
|
-
infoMap.isModule = true;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = {
|
|
46
|
-
Visitor,
|
|
47
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
|
14
|
-
|
|
15
|
-
function getCommandOptions(commandOptionsExpression) {
|
|
16
|
-
if (commandOptionsExpression == null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
let foundOptions;
|
|
20
|
-
try {
|
|
21
|
-
foundOptions = commandOptionsExpression.properties.reduce(
|
|
22
|
-
(options, prop) => {
|
|
23
|
-
options[prop.key.name] = (
|
|
24
|
-
(prop && prop.value && prop.value.elements) ||
|
|
25
|
-
[]
|
|
26
|
-
).map(element => element && element.value);
|
|
27
|
-
return options;
|
|
28
|
-
},
|
|
29
|
-
{},
|
|
30
|
-
);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
'Failed to parse command options, please check that they are defined correctly',
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return foundOptions;
|
|
37
|
-
}
|
|
38
|
-
function getOptions(optionsExpression) {
|
|
39
|
-
if (!optionsExpression) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
let foundOptions;
|
|
43
|
-
try {
|
|
44
|
-
foundOptions = optionsExpression.properties.reduce((options, prop) => {
|
|
45
|
-
if (prop.value.type === 'ArrayExpression') {
|
|
46
|
-
options[prop.key.name] = prop.value.elements.map(
|
|
47
|
-
element => element.value,
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
options[prop.key.name] = prop.value.value;
|
|
51
|
-
}
|
|
52
|
-
return options;
|
|
53
|
-
}, {});
|
|
54
|
-
} catch (e) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
'Failed to parse codegen options, please check that they are defined correctly',
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
if (
|
|
60
|
-
foundOptions.paperComponentName &&
|
|
61
|
-
foundOptions.paperComponentNameDeprecated
|
|
62
|
-
) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated',
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return foundOptions;
|
|
68
|
-
}
|
|
69
|
-
module.exports = {
|
|
70
|
-
getCommandOptions,
|
|
71
|
-
getOptions,
|
|
72
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type {OptionsShape} from '../../../CodegenSchema.js';
|
|
14
|
-
|
|
15
|
-
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
|
16
|
-
type OptionsAST = Object;
|
|
17
|
-
|
|
18
|
-
export type CommandOptions = $ReadOnly<{
|
|
19
|
-
supportedCommands: $ReadOnlyArray<string>,
|
|
20
|
-
}>;
|
|
21
|
-
|
|
22
|
-
function getCommandOptions(
|
|
23
|
-
commandOptionsExpression: OptionsAST,
|
|
24
|
-
): ?CommandOptions {
|
|
25
|
-
if (commandOptionsExpression == null) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let foundOptions;
|
|
30
|
-
try {
|
|
31
|
-
foundOptions = commandOptionsExpression.properties.reduce(
|
|
32
|
-
(options, prop) => {
|
|
33
|
-
options[prop.key.name] = (
|
|
34
|
-
(prop && prop.value && prop.value.elements) ||
|
|
35
|
-
[]
|
|
36
|
-
).map(element => element && element.value);
|
|
37
|
-
return options;
|
|
38
|
-
},
|
|
39
|
-
{},
|
|
40
|
-
);
|
|
41
|
-
} catch (e) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
'Failed to parse command options, please check that they are defined correctly',
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return foundOptions;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getOptions(optionsExpression: OptionsAST): ?OptionsShape {
|
|
51
|
-
if (!optionsExpression) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
let foundOptions;
|
|
55
|
-
try {
|
|
56
|
-
foundOptions = optionsExpression.properties.reduce((options, prop) => {
|
|
57
|
-
if (prop.value.type === 'ArrayExpression') {
|
|
58
|
-
options[prop.key.name] = prop.value.elements.map(
|
|
59
|
-
element => element.value,
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
options[prop.key.name] = prop.value.value;
|
|
63
|
-
}
|
|
64
|
-
return options;
|
|
65
|
-
}, {});
|
|
66
|
-
} catch (e) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
'Failed to parse codegen options, please check that they are defined correctly',
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
foundOptions.paperComponentName &&
|
|
74
|
-
foundOptions.paperComponentNameDeprecated
|
|
75
|
-
) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated',
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return foundOptions;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = {
|
|
85
|
-
getCommandOptions,
|
|
86
|
-
getOptions,
|
|
87
|
-
};
|
|
File without changes
|