@react-native/codegen 0.72.3 → 0.72.5

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.
Files changed (71) hide show
  1. package/lib/CodegenSchema.d.ts +10 -10
  2. package/lib/CodegenSchema.js.flow +6 -1
  3. package/lib/SchemaValidator.d.ts +1 -1
  4. package/lib/generators/RNCodegen.d.ts +98 -0
  5. package/lib/generators/RNCodegen.js +33 -4
  6. package/lib/generators/RNCodegen.js.flow +35 -4
  7. package/lib/generators/components/ComponentsGeneratorUtils.js +2 -0
  8. package/lib/generators/components/ComponentsGeneratorUtils.js.flow +2 -0
  9. package/lib/generators/components/CppHelpers.js +2 -0
  10. package/lib/generators/components/CppHelpers.js.flow +2 -0
  11. package/lib/generators/components/GeneratePropsH.js +2 -0
  12. package/lib/generators/components/GeneratePropsH.js.flow +2 -0
  13. package/lib/generators/components/GeneratePropsJavaDelegate.js +2 -0
  14. package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +2 -0
  15. package/lib/generators/components/GeneratePropsJavaInterface.js +2 -0
  16. package/lib/generators/components/GeneratePropsJavaInterface.js.flow +2 -0
  17. package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +3 -1
  18. package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js +5 -0
  19. package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +6 -0
  20. package/lib/generators/components/GenerateViewConfigJs.js +1 -0
  21. package/lib/generators/components/GenerateViewConfigJs.js.flow +1 -0
  22. package/lib/generators/components/JavaHelpers.js +7 -0
  23. package/lib/generators/components/JavaHelpers.js.flow +8 -0
  24. package/lib/generators/components/__test_fixtures__/fixtures.js +29 -0
  25. package/lib/generators/components/__test_fixtures__/fixtures.js.flow +30 -0
  26. package/lib/generators/modules/GenerateModuleH.js +1 -1
  27. package/lib/generators/modules/GenerateModuleH.js.flow +1 -1
  28. package/lib/parsers/error-utils.js +9 -15
  29. package/lib/parsers/error-utils.js.flow +12 -15
  30. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +5 -1
  31. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +5 -1
  32. package/lib/parsers/flow/components/componentsUtils.js +4 -0
  33. package/lib/parsers/flow/components/componentsUtils.js.flow +4 -0
  34. package/lib/parsers/flow/components/index.js +18 -113
  35. package/lib/parsers/flow/components/index.js.flow +15 -46
  36. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +4 -4
  37. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +4 -4
  38. package/lib/parsers/flow/modules/index.js +41 -307
  39. package/lib/parsers/flow/modules/index.js.flow +18 -233
  40. package/lib/parsers/flow/parser.js +68 -12
  41. package/lib/parsers/flow/parser.js.flow +67 -3
  42. package/lib/parsers/parser.d.ts +2 -2
  43. package/lib/parsers/parser.js.flow +65 -3
  44. package/lib/parsers/parserMock.js +44 -0
  45. package/lib/parsers/parserMock.js.flow +52 -1
  46. package/lib/parsers/parsers-commons.js +361 -4
  47. package/lib/parsers/parsers-commons.js.flow +341 -4
  48. package/lib/parsers/parsers-primitives.js +119 -3
  49. package/lib/parsers/parsers-primitives.js.flow +128 -3
  50. package/lib/parsers/schema/index.d.ts +1 -1
  51. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +5 -1
  52. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +5 -1
  53. package/lib/parsers/typescript/components/componentsUtils.js +8 -0
  54. package/lib/parsers/typescript/components/componentsUtils.js.flow +8 -0
  55. package/lib/parsers/typescript/components/index.js +20 -115
  56. package/lib/parsers/typescript/components/index.js.flow +17 -48
  57. package/lib/parsers/typescript/modules/index.js +103 -421
  58. package/lib/parsers/typescript/modules/index.js.flow +84 -285
  59. package/lib/parsers/typescript/parser.js +69 -12
  60. package/lib/parsers/typescript/parser.js.flow +68 -3
  61. package/lib/parsers/utils.js +4 -0
  62. package/lib/parsers/utils.js.flow +3 -0
  63. package/package.json +11 -11
  64. package/lib/parsers/flow/Visitor.js +0 -37
  65. package/lib/parsers/flow/Visitor.js.flow +0 -41
  66. package/lib/parsers/flow/components/options.js +0 -72
  67. package/lib/parsers/flow/components/options.js.flow +0 -87
  68. package/lib/parsers/typescript/Visitor.js +0 -42
  69. package/lib/parsers/typescript/Visitor.js.flow +0 -47
  70. package/lib/parsers/typescript/components/options.js +0 -72
  71. package/lib/parsers/typescript/components/options.js.flow +0 -87
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.72.3",
3
+ "version": "0.72.5",
4
4
  "description": "⚛️ Code generation tools for React Native",
5
5
  "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen",
6
6
  "repository": {
@@ -19,21 +19,21 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@babel/parser": "^7.20.0",
22
- "flow-parser": "^0.185.0",
22
+ "flow-parser": "^0.206.0",
23
23
  "jscodeshift": "^0.14.0",
24
24
  "nullthrows": "^1.1.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@babel/core": "^7.20.0",
28
- "@babel/plugin-proposal-class-properties": "^7.0.0",
29
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
30
- "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
31
- "@babel/plugin-proposal-optional-chaining": "^7.0.0",
32
- "@babel/plugin-syntax-dynamic-import": "^7.0.0",
33
- "@babel/plugin-transform-async-to-generator": "^7.0.0",
34
- "@babel/plugin-transform-destructuring": "^7.0.0",
35
- "@babel/plugin-transform-flow-strip-types": "^7.0.0",
36
- "@babel/preset-env": "^7.14.0",
28
+ "@babel/plugin-proposal-class-properties": "^7.18.0",
29
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.0",
30
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.0",
31
+ "@babel/plugin-proposal-optional-chaining": "^7.20.0",
32
+ "@babel/plugin-syntax-dynamic-import": "^7.8.0",
33
+ "@babel/plugin-transform-async-to-generator": "^7.20.0",
34
+ "@babel/plugin-transform-destructuring": "^7.20.0",
35
+ "@babel/plugin-transform-flow-strip-types": "^7.20.0",
36
+ "@babel/preset-env": "^7.20.0",
37
37
  "chalk": "^4.0.0",
38
38
  "glob": "^7.1.1",
39
39
  "invariant": "^2.2.4",
@@ -1,37 +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
- InterfaceExtends(node) {
29
- if (node.id.name === 'TurboModule') {
30
- infoMap.isModule = true;
31
- }
32
- },
33
- };
34
- }
35
- module.exports = {
36
- Visitor,
37
- };
@@ -1,41 +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
- InterfaceExtends(node: $FlowFixMe) {
32
- if (node.id.name === 'TurboModule') {
33
- infoMap.isModule = true;
34
- }
35
- },
36
- };
37
- }
38
-
39
- module.exports = {
40
- Visitor,
41
- };
@@ -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] there's no flowtype for ASTs
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] there's no flowtype for ASTs
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
- };
@@ -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
- };