@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.
Files changed (77) 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/parsers/error-utils.js +50 -15
  27. package/lib/parsers/error-utils.js.flow +57 -15
  28. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +5 -1
  29. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +5 -1
  30. package/lib/parsers/flow/components/componentsUtils.js +4 -0
  31. package/lib/parsers/flow/components/componentsUtils.js.flow +4 -0
  32. package/lib/parsers/flow/components/index.js +27 -126
  33. package/lib/parsers/flow/components/index.js.flow +22 -52
  34. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js +4 -4
  35. package/lib/parsers/flow/modules/__test_fixtures__/fixtures.js.flow +4 -4
  36. package/lib/parsers/flow/modules/index.js +41 -317
  37. package/lib/parsers/flow/modules/index.js.flow +19 -247
  38. package/lib/parsers/flow/parser.js +119 -12
  39. package/lib/parsers/flow/parser.js.flow +124 -3
  40. package/lib/parsers/flow/utils.js +0 -38
  41. package/lib/parsers/flow/utils.js.flow +0 -38
  42. package/lib/parsers/parser.d.ts +2 -2
  43. package/lib/parsers/parser.js.flow +84 -0
  44. package/lib/parsers/parserMock.js +58 -0
  45. package/lib/parsers/parserMock.js.flow +72 -0
  46. package/lib/parsers/parsers-commons.js +362 -5
  47. package/lib/parsers/parsers-commons.js.flow +351 -8
  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/schema.js.flow → schema.js.flow} +1 -1
  52. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +5 -1
  53. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +5 -1
  54. package/lib/parsers/typescript/components/componentsUtils.js +8 -0
  55. package/lib/parsers/typescript/components/componentsUtils.js.flow +8 -0
  56. package/lib/parsers/typescript/components/index.js +28 -127
  57. package/lib/parsers/typescript/components/index.js.flow +24 -54
  58. package/lib/parsers/typescript/modules/index.js +103 -434
  59. package/lib/parsers/typescript/modules/index.js.flow +85 -299
  60. package/lib/parsers/typescript/parser.js +113 -12
  61. package/lib/parsers/typescript/parser.js.flow +115 -3
  62. package/lib/parsers/typescript/utils.js +0 -31
  63. package/lib/parsers/typescript/utils.js.flow +0 -31
  64. package/lib/parsers/utils.js +4 -0
  65. package/lib/parsers/utils.js.flow +3 -0
  66. package/package.json +1 -1
  67. package/lib/parsers/flow/Visitor.js +0 -37
  68. package/lib/parsers/flow/Visitor.js.flow +0 -41
  69. package/lib/parsers/flow/components/options.js +0 -72
  70. package/lib/parsers/flow/components/options.js.flow +0 -87
  71. package/lib/parsers/flow/components/schema.js +0 -106
  72. package/lib/parsers/flow/components/schema.js.flow +0 -62
  73. package/lib/parsers/typescript/Visitor.js +0 -42
  74. package/lib/parsers/typescript/Visitor.js.flow +0 -47
  75. package/lib/parsers/typescript/components/options.js +0 -72
  76. package/lib/parsers/typescript/components/options.js.flow +0 -87
  77. /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
- };