@react-native-windows/codegen 0.73.0-preview.1 → 0.74.0-preview.1

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.
@@ -1,75 +1,75 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- 'use strict';
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.translateField = exports.translateFieldOrReturnType = void 0;
9
- const AliasManaging_1 = require("./AliasManaging");
10
- function translateUnionReturnType(type, options) {
11
- const memberType = type.memberType;
12
- switch (type.memberType) {
13
- case 'StringTypeAnnotation':
14
- return options.cppStringType;
15
- case 'NumberTypeAnnotation':
16
- return 'double';
17
- case 'ObjectTypeAnnotation':
18
- return '::React::JSValue';
19
- default:
20
- throw new Error(`Unknown enum/union member type in translateReturnType: ${memberType}`);
21
- }
22
- }
23
- function translateFieldOrReturnType(type, aliases, baseAliasName, callerName, options) {
24
- // avoid: Property 'type' does not exist on type 'never'
25
- const returnType = type.type;
26
- switch (type.type) {
27
- case 'StringTypeAnnotation':
28
- return options.cppStringType;
29
- case 'NumberTypeAnnotation':
30
- case 'FloatTypeAnnotation':
31
- case 'DoubleTypeAnnotation':
32
- return 'double';
33
- case 'Int32TypeAnnotation':
34
- return 'int';
35
- case 'BooleanTypeAnnotation':
36
- return 'bool';
37
- case 'ArrayTypeAnnotation':
38
- if (type.elementType) {
39
- return `std::vector<${translateFieldOrReturnType(type.elementType, aliases, `${baseAliasName}_element`, callerName, options)}>`;
40
- }
41
- else {
42
- return `::React::JSValueArray`;
43
- }
44
- case 'GenericObjectTypeAnnotation':
45
- return '::React::JSValue';
46
- case 'ObjectTypeAnnotation':
47
- return (0, AliasManaging_1.getAnonymousAliasCppName)(aliases, baseAliasName, type);
48
- case 'ReservedTypeAnnotation': {
49
- // avoid: Property 'name' does not exist on type 'never'
50
- const name = type.name;
51
- // (#6597)
52
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
- if (name !== 'RootTag')
54
- throw new Error(`Unknown reserved function: ${name} in ${callerName}`);
55
- return 'double';
56
- }
57
- case 'TypeAliasTypeAnnotation':
58
- return (0, AliasManaging_1.getAliasCppName)(type.name);
59
- case 'NullableTypeAnnotation':
60
- return `std::optional<${translateFieldOrReturnType(type.typeAnnotation, aliases, baseAliasName, callerName, options)}>`;
61
- case 'MixedTypeAnnotation':
62
- return '';
63
- case 'EnumDeclaration':
64
- case 'UnionTypeAnnotation':
65
- return translateUnionReturnType(type, options);
66
- default:
67
- throw new Error(`Unhandled type in ${callerName}: ${returnType}`);
68
- }
69
- }
70
- exports.translateFieldOrReturnType = translateFieldOrReturnType;
71
- function translateField(type, aliases, baseAliasName, options) {
72
- return translateFieldOrReturnType(type, aliases, baseAliasName, 'translateField', options);
73
- }
74
- exports.translateField = translateField;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ 'use strict';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.translateField = exports.translateFieldOrReturnType = void 0;
9
+ const AliasManaging_1 = require("./AliasManaging");
10
+ function translateUnionReturnType(type, options) {
11
+ const memberType = type.memberType;
12
+ switch (type.memberType) {
13
+ case 'StringTypeAnnotation':
14
+ return options.cppStringType;
15
+ case 'NumberTypeAnnotation':
16
+ return 'double';
17
+ case 'ObjectTypeAnnotation':
18
+ return '::React::JSValue';
19
+ default:
20
+ throw new Error(`Unknown enum/union member type in translateReturnType: ${memberType}`);
21
+ }
22
+ }
23
+ function translateFieldOrReturnType(type, aliases, baseAliasName, callerName, options) {
24
+ // avoid: Property 'type' does not exist on type 'never'
25
+ const returnType = type.type;
26
+ switch (type.type) {
27
+ case 'StringTypeAnnotation':
28
+ return options.cppStringType;
29
+ case 'NumberTypeAnnotation':
30
+ case 'FloatTypeAnnotation':
31
+ case 'DoubleTypeAnnotation':
32
+ return 'double';
33
+ case 'Int32TypeAnnotation':
34
+ return 'int';
35
+ case 'BooleanTypeAnnotation':
36
+ return 'bool';
37
+ case 'ArrayTypeAnnotation':
38
+ if (type.elementType) {
39
+ return `std::vector<${translateFieldOrReturnType(type.elementType, aliases, `${baseAliasName}_element`, callerName, options)}>`;
40
+ }
41
+ else {
42
+ return `::React::JSValueArray`;
43
+ }
44
+ case 'GenericObjectTypeAnnotation':
45
+ return '::React::JSValue';
46
+ case 'ObjectTypeAnnotation':
47
+ return (0, AliasManaging_1.getAnonymousAliasCppName)(aliases, baseAliasName, type);
48
+ case 'ReservedTypeAnnotation': {
49
+ // avoid: Property 'name' does not exist on type 'never'
50
+ const name = type.name;
51
+ // (#6597)
52
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
+ if (name !== 'RootTag')
54
+ throw new Error(`Unknown reserved function: ${name} in ${callerName}`);
55
+ return 'double';
56
+ }
57
+ case 'TypeAliasTypeAnnotation':
58
+ return (0, AliasManaging_1.getAliasCppName)(type.name);
59
+ case 'NullableTypeAnnotation':
60
+ return `std::optional<${translateFieldOrReturnType(type.typeAnnotation, aliases, baseAliasName, callerName, options)}>`;
61
+ case 'MixedTypeAnnotation':
62
+ return '';
63
+ case 'EnumDeclaration':
64
+ case 'UnionTypeAnnotation':
65
+ return translateUnionReturnType(type, options);
66
+ default:
67
+ throw new Error(`Unhandled type in ${callerName}: ${returnType}`);
68
+ }
69
+ }
70
+ exports.translateFieldOrReturnType = translateFieldOrReturnType;
71
+ function translateField(type, aliases, baseAliasName, options) {
72
+ return translateFieldOrReturnType(type, aliases, baseAliasName, 'translateField', options);
73
+ }
74
+ exports.translateField = translateField;
75
75
  //# sourceMappingURL=ObjectTypes.js.map
@@ -1,12 +1,12 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import type { NamedShape, NativeModuleParamTypeAnnotation, Nullable } from '@react-native/codegen/lib/CodegenSchema';
7
- import { AliasMap } from './AliasManaging';
8
- import type { CppCodegenOptions } from './ObjectTypes';
9
- type NativeModuleParamShape = NamedShape<Nullable<NativeModuleParamTypeAnnotation>>;
10
- export declare function translateSpecArgs(params: ReadonlyArray<NativeModuleParamShape>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string[];
11
- export declare function translateArgs(params: ReadonlyArray<NativeModuleParamShape>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string[];
12
- export {};
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NamedShape, NativeModuleParamTypeAnnotation, Nullable } from '@react-native/codegen/lib/CodegenSchema';
7
+ import { AliasMap } from './AliasManaging';
8
+ import type { CppCodegenOptions } from './ObjectTypes';
9
+ type NativeModuleParamShape = NamedShape<Nullable<NativeModuleParamTypeAnnotation>>;
10
+ export declare function translateSpecArgs(params: ReadonlyArray<NativeModuleParamShape>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string[];
11
+ export declare function translateArgs(params: ReadonlyArray<NativeModuleParamShape>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string[];
12
+ export {};
@@ -1,137 +1,137 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- 'use strict';
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.translateArgs = exports.translateSpecArgs = void 0;
9
- const AliasManaging_1 = require("./AliasManaging");
10
- function decorateType(type, target) {
11
- switch (target) {
12
- case 'method-arg':
13
- return `${type} &&`;
14
- case 'callback-arg':
15
- return `${type} const &`;
16
- default:
17
- return type;
18
- }
19
- }
20
- function translateUnionReturnType(type, target, options) {
21
- const memberType = type.memberType;
22
- switch (type.memberType) {
23
- case 'StringTypeAnnotation':
24
- return options.cppStringType;
25
- case 'NumberTypeAnnotation':
26
- return 'double';
27
- case 'ObjectTypeAnnotation':
28
- return decorateType('::React::JSValue', target);
29
- default:
30
- throw new Error(`Unknown enum/union member type in translateReturnType: ${memberType}`);
31
- }
32
- }
33
- function translateFunction(param, aliases, baseAliasName, target, options) {
34
- // TODO: type.returnTypeAnnotation
35
- switch (target) {
36
- case 'spec':
37
- return `Callback<${param.params
38
- .map((p) => translateSpecFunctionParam(p, aliases, `${baseAliasName}_${p.name}`, options))
39
- .join(', ')}>`;
40
- case 'template':
41
- return `std::function<void(${param.params
42
- .map((p) => translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`, options))
43
- .join(', ')})>`;
44
- default:
45
- return `std::function<void(${param.params
46
- .map((p) => translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`, options))
47
- .join(', ')})> const &`;
48
- }
49
- }
50
- function translateArray(param, aliases, baseAliasName, target, options) {
51
- if (param.elementType) {
52
- switch (target) {
53
- case 'spec':
54
- case 'template':
55
- return `std::vector<${translateNullableParamType(param.elementType, aliases, `${baseAliasName}_element`, 'template', 'template', options)}>`;
56
- default:
57
- return `std::vector<${translateNullableParamType(param.elementType, aliases, `${baseAliasName}_element`, 'template', 'template', options)}> const &`;
58
- }
59
- }
60
- else {
61
- return decorateType('::React::JSValueArray', target);
62
- }
63
- }
64
- function translateParam(param, aliases, baseAliasName, target, options) {
65
- // avoid: Property 'type' does not exist on type 'never'
66
- const paramType = param.type;
67
- switch (param.type) {
68
- case 'StringTypeAnnotation':
69
- return options.cppStringType;
70
- case 'NumberTypeAnnotation':
71
- case 'FloatTypeAnnotation':
72
- case 'DoubleTypeAnnotation':
73
- return 'double';
74
- case 'Int32TypeAnnotation':
75
- return 'int';
76
- case 'BooleanTypeAnnotation':
77
- return 'bool';
78
- case 'FunctionTypeAnnotation':
79
- return translateFunction(param, aliases, baseAliasName, target, options);
80
- case 'ArrayTypeAnnotation':
81
- return translateArray(param, aliases, baseAliasName, target, options);
82
- case 'GenericObjectTypeAnnotation':
83
- return decorateType('::React::JSValue', target);
84
- case 'ObjectTypeAnnotation':
85
- return decorateType((0, AliasManaging_1.getAnonymousAliasCppName)(aliases, baseAliasName, param), target);
86
- case 'ReservedTypeAnnotation': {
87
- // avoid: Property 'name' does not exist on type 'never'
88
- const name = param.name;
89
- // (#6597)
90
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
91
- if (name !== 'RootTag')
92
- throw new Error(`Unknown reserved function: ${name} in translateParam`);
93
- return 'double';
94
- }
95
- case 'TypeAliasTypeAnnotation':
96
- return decorateType((0, AliasManaging_1.getAliasCppName)(param.name), target);
97
- case 'MixedTypeAnnotation':
98
- return '';
99
- case 'EnumDeclaration':
100
- case 'UnionTypeAnnotation':
101
- return translateUnionReturnType(param, target, options);
102
- default:
103
- throw new Error(`Unhandled type in translateParam: ${paramType}`);
104
- }
105
- }
106
- function translateNullableParamType(paramType, aliases, baseAliasName, nullableTarget, target, options) {
107
- switch (paramType.type) {
108
- case 'NullableTypeAnnotation':
109
- return `std::optional<${translateParam(paramType.typeAnnotation, aliases, baseAliasName, nullableTarget, options)}>`;
110
- default:
111
- return translateParam(paramType, aliases, baseAliasName, target, options);
112
- }
113
- }
114
- function translateSpecFunctionParam(param, aliases, baseAliasName, options) {
115
- return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'spec', 'spec', options);
116
- }
117
- function translateCallbackParam(param, aliases, baseAliasName, options) {
118
- return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'template', 'callback-arg', options);
119
- }
120
- function translateFunctionParam(param, aliases, baseAliasName, options) {
121
- return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'template', 'method-arg', options);
122
- }
123
- function translateSpecArgs(params, aliases, baseAliasName, options) {
124
- return params.map(param => {
125
- const translatedParam = translateSpecFunctionParam(param, aliases, `${baseAliasName}_${param.name}`, options);
126
- return `${translatedParam}`;
127
- });
128
- }
129
- exports.translateSpecArgs = translateSpecArgs;
130
- function translateArgs(params, aliases, baseAliasName, options) {
131
- return params.map(param => {
132
- const translatedParam = translateFunctionParam(param, aliases, `${baseAliasName}_${param.name}`, options);
133
- return `${translatedParam} ${param.name}`;
134
- });
135
- }
136
- exports.translateArgs = translateArgs;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ 'use strict';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.translateArgs = exports.translateSpecArgs = void 0;
9
+ const AliasManaging_1 = require("./AliasManaging");
10
+ function decorateType(type, target) {
11
+ switch (target) {
12
+ case 'method-arg':
13
+ return `${type} &&`;
14
+ case 'callback-arg':
15
+ return `${type} const &`;
16
+ default:
17
+ return type;
18
+ }
19
+ }
20
+ function translateUnionReturnType(type, target, options) {
21
+ const memberType = type.memberType;
22
+ switch (type.memberType) {
23
+ case 'StringTypeAnnotation':
24
+ return options.cppStringType;
25
+ case 'NumberTypeAnnotation':
26
+ return 'double';
27
+ case 'ObjectTypeAnnotation':
28
+ return decorateType('::React::JSValue', target);
29
+ default:
30
+ throw new Error(`Unknown enum/union member type in translateReturnType: ${memberType}`);
31
+ }
32
+ }
33
+ function translateFunction(param, aliases, baseAliasName, target, options) {
34
+ // TODO: type.returnTypeAnnotation
35
+ switch (target) {
36
+ case 'spec':
37
+ return `Callback<${param.params
38
+ .map((p) => translateSpecFunctionParam(p, aliases, `${baseAliasName}_${p.name}`, options))
39
+ .join(', ')}>`;
40
+ case 'template':
41
+ return `std::function<void(${param.params
42
+ .map((p) => translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`, options))
43
+ .join(', ')})>`;
44
+ default:
45
+ return `std::function<void(${param.params
46
+ .map((p) => translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`, options))
47
+ .join(', ')})> const &`;
48
+ }
49
+ }
50
+ function translateArray(param, aliases, baseAliasName, target, options) {
51
+ if (param.elementType) {
52
+ switch (target) {
53
+ case 'spec':
54
+ case 'template':
55
+ return `std::vector<${translateNullableParamType(param.elementType, aliases, `${baseAliasName}_element`, 'template', 'template', options)}>`;
56
+ default:
57
+ return `std::vector<${translateNullableParamType(param.elementType, aliases, `${baseAliasName}_element`, 'template', 'template', options)}> const &`;
58
+ }
59
+ }
60
+ else {
61
+ return decorateType('::React::JSValueArray', target);
62
+ }
63
+ }
64
+ function translateParam(param, aliases, baseAliasName, target, options) {
65
+ // avoid: Property 'type' does not exist on type 'never'
66
+ const paramType = param.type;
67
+ switch (param.type) {
68
+ case 'StringTypeAnnotation':
69
+ return options.cppStringType;
70
+ case 'NumberTypeAnnotation':
71
+ case 'FloatTypeAnnotation':
72
+ case 'DoubleTypeAnnotation':
73
+ return 'double';
74
+ case 'Int32TypeAnnotation':
75
+ return 'int';
76
+ case 'BooleanTypeAnnotation':
77
+ return 'bool';
78
+ case 'FunctionTypeAnnotation':
79
+ return translateFunction(param, aliases, baseAliasName, target, options);
80
+ case 'ArrayTypeAnnotation':
81
+ return translateArray(param, aliases, baseAliasName, target, options);
82
+ case 'GenericObjectTypeAnnotation':
83
+ return decorateType('::React::JSValue', target);
84
+ case 'ObjectTypeAnnotation':
85
+ return decorateType((0, AliasManaging_1.getAnonymousAliasCppName)(aliases, baseAliasName, param), target);
86
+ case 'ReservedTypeAnnotation': {
87
+ // avoid: Property 'name' does not exist on type 'never'
88
+ const name = param.name;
89
+ // (#6597)
90
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
91
+ if (name !== 'RootTag')
92
+ throw new Error(`Unknown reserved function: ${name} in translateParam`);
93
+ return 'double';
94
+ }
95
+ case 'TypeAliasTypeAnnotation':
96
+ return decorateType((0, AliasManaging_1.getAliasCppName)(param.name), target);
97
+ case 'MixedTypeAnnotation':
98
+ return '';
99
+ case 'EnumDeclaration':
100
+ case 'UnionTypeAnnotation':
101
+ return translateUnionReturnType(param, target, options);
102
+ default:
103
+ throw new Error(`Unhandled type in translateParam: ${paramType}`);
104
+ }
105
+ }
106
+ function translateNullableParamType(paramType, aliases, baseAliasName, nullableTarget, target, options) {
107
+ switch (paramType.type) {
108
+ case 'NullableTypeAnnotation':
109
+ return `std::optional<${translateParam(paramType.typeAnnotation, aliases, baseAliasName, nullableTarget, options)}>`;
110
+ default:
111
+ return translateParam(paramType, aliases, baseAliasName, target, options);
112
+ }
113
+ }
114
+ function translateSpecFunctionParam(param, aliases, baseAliasName, options) {
115
+ return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'spec', 'spec', options);
116
+ }
117
+ function translateCallbackParam(param, aliases, baseAliasName, options) {
118
+ return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'template', 'callback-arg', options);
119
+ }
120
+ function translateFunctionParam(param, aliases, baseAliasName, options) {
121
+ return translateNullableParamType(param.typeAnnotation, aliases, baseAliasName, 'template', 'method-arg', options);
122
+ }
123
+ function translateSpecArgs(params, aliases, baseAliasName, options) {
124
+ return params.map(param => {
125
+ const translatedParam = translateSpecFunctionParam(param, aliases, `${baseAliasName}_${param.name}`, options);
126
+ return `${translatedParam}`;
127
+ });
128
+ }
129
+ exports.translateSpecArgs = translateSpecArgs;
130
+ function translateArgs(params, aliases, baseAliasName, options) {
131
+ return params.map(param => {
132
+ const translatedParam = translateFunctionParam(param, aliases, `${baseAliasName}_${param.name}`, options);
133
+ return `${translatedParam} ${param.name}`;
134
+ });
135
+ }
136
+ exports.translateArgs = translateArgs;
137
137
  //# sourceMappingURL=ParamTypes.js.map
@@ -1,10 +1,10 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import type { NativeModuleReturnTypeAnnotation, Nullable } from '@react-native/codegen/lib/CodegenSchema';
7
- import { AliasMap } from './AliasManaging';
8
- import { CppCodegenOptions } from './ObjectTypes';
9
- export declare function translateSpecReturnType(type: Nullable<NativeModuleReturnTypeAnnotation>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string;
10
- export declare function translateImplReturnType(type: Nullable<NativeModuleReturnTypeAnnotation>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NativeModuleReturnTypeAnnotation, Nullable } from '@react-native/codegen/lib/CodegenSchema';
7
+ import { AliasMap } from './AliasManaging';
8
+ import { CppCodegenOptions } from './ObjectTypes';
9
+ export declare function translateSpecReturnType(type: Nullable<NativeModuleReturnTypeAnnotation>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string;
10
+ export declare function translateImplReturnType(type: Nullable<NativeModuleReturnTypeAnnotation>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string;
@@ -1,29 +1,29 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- 'use strict';
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.translateImplReturnType = exports.translateSpecReturnType = void 0;
9
- const ObjectTypes_1 = require("./ObjectTypes");
10
- function translateReturnType(type, aliases, baseAliasName, options) {
11
- switch (type.type) {
12
- case 'VoidTypeAnnotation':
13
- case 'PromiseTypeAnnotation':
14
- return 'void';
15
- case 'NullableTypeAnnotation':
16
- return `std::optional<${translateReturnType(type.typeAnnotation, aliases, baseAliasName, options)}>`;
17
- default:
18
- return (0, ObjectTypes_1.translateFieldOrReturnType)(type, aliases, baseAliasName, 'translateReturnType', options);
19
- }
20
- }
21
- function translateSpecReturnType(type, aliases, baseAliasName, options) {
22
- return translateReturnType(type, aliases, `${baseAliasName}_returnType`, options);
23
- }
24
- exports.translateSpecReturnType = translateSpecReturnType;
25
- function translateImplReturnType(type, aliases, baseAliasName, options) {
26
- return translateReturnType(type, aliases, `${baseAliasName}_returnType`, options);
27
- }
28
- exports.translateImplReturnType = translateImplReturnType;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ 'use strict';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.translateImplReturnType = exports.translateSpecReturnType = void 0;
9
+ const ObjectTypes_1 = require("./ObjectTypes");
10
+ function translateReturnType(type, aliases, baseAliasName, options) {
11
+ switch (type.type) {
12
+ case 'VoidTypeAnnotation':
13
+ case 'PromiseTypeAnnotation':
14
+ return 'void';
15
+ case 'NullableTypeAnnotation':
16
+ return `std::optional<${translateReturnType(type.typeAnnotation, aliases, baseAliasName, options)}>`;
17
+ default:
18
+ return (0, ObjectTypes_1.translateFieldOrReturnType)(type, aliases, baseAliasName, 'translateReturnType', options);
19
+ }
20
+ }
21
+ function translateSpecReturnType(type, aliases, baseAliasName, options) {
22
+ return translateReturnType(type, aliases, `${baseAliasName}_returnType`, options);
23
+ }
24
+ exports.translateSpecReturnType = translateSpecReturnType;
25
+ function translateImplReturnType(type, aliases, baseAliasName, options) {
26
+ return translateReturnType(type, aliases, `${baseAliasName}_returnType`, options);
27
+ }
28
+ exports.translateImplReturnType = translateImplReturnType;
29
29
  //# sourceMappingURL=ReturnTypes.js.map
@@ -1,8 +1,8 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import type { NativeModuleSchema } from '@react-native/codegen/lib/CodegenSchema';
7
- import { AliasMap } from './AliasManaging';
8
- export declare function generateValidateConstants(nativeModule: NativeModuleSchema, aliases: AliasMap): [string, string] | undefined;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NativeModuleSchema } from '@react-native/codegen/lib/CodegenSchema';
7
+ import { AliasMap } from './AliasManaging';
8
+ export declare function generateValidateConstants(nativeModule: NativeModuleSchema, aliases: AliasMap): [string, string] | undefined;
@@ -1,38 +1,38 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- 'use strict';
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.generateValidateConstants = void 0;
9
- const AliasManaging_1 = require("./AliasManaging");
10
- function generateValidateConstants(nativeModule, aliases) {
11
- const candidates = nativeModule.spec.properties.filter(prop => prop.name === 'getConstants');
12
- if (candidates.length === 0) {
13
- return undefined;
14
- }
15
- const getConstant = candidates[0];
16
- const funcType = getConstant.typeAnnotation.type === 'NullableTypeAnnotation'
17
- ? getConstant.typeAnnotation.typeAnnotation
18
- : getConstant.typeAnnotation;
19
- if (funcType.params.length > 0 ||
20
- funcType.returnTypeAnnotation.type !== 'ObjectTypeAnnotation') {
21
- return undefined;
22
- }
23
- const constantType = funcType.returnTypeAnnotation;
24
- if (constantType.properties.length === 0) {
25
- return undefined;
26
- }
27
- const cppName = (0, AliasManaging_1.getAnonymousAliasCppName)(aliases, 'Constants', constantType);
28
- return [
29
- ` TypedConstant<${cppName}>{0},`,
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ 'use strict';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.generateValidateConstants = void 0;
9
+ const AliasManaging_1 = require("./AliasManaging");
10
+ function generateValidateConstants(nativeModule, aliases) {
11
+ const candidates = nativeModule.spec.properties.filter(prop => prop.name === 'getConstants');
12
+ if (candidates.length === 0) {
13
+ return undefined;
14
+ }
15
+ const getConstant = candidates[0];
16
+ const funcType = getConstant.typeAnnotation.type === 'NullableTypeAnnotation'
17
+ ? getConstant.typeAnnotation.typeAnnotation
18
+ : getConstant.typeAnnotation;
19
+ if (funcType.params.length > 0 ||
20
+ funcType.returnTypeAnnotation.type !== 'ObjectTypeAnnotation') {
21
+ return undefined;
22
+ }
23
+ const constantType = funcType.returnTypeAnnotation;
24
+ if (constantType.properties.length === 0) {
25
+ return undefined;
26
+ }
27
+ const cppName = (0, AliasManaging_1.getAnonymousAliasCppName)(aliases, 'Constants', constantType);
28
+ return [
29
+ ` TypedConstant<${cppName}>{0},`,
30
30
  ` REACT_SHOW_CONSTANT_SPEC_ERRORS(
31
31
  0,
32
32
  "${cppName}",
33
33
  " REACT_GET_CONSTANTS(GetConstants) ${cppName} GetConstants() noexcept {/*implementation*/}\\n"
34
- " REACT_GET_CONSTANTS(GetConstants) static ${cppName} GetConstants() noexcept {/*implementation*/}\\n");`,
35
- ];
36
- }
37
- exports.generateValidateConstants = generateValidateConstants;
34
+ " REACT_GET_CONSTANTS(GetConstants) static ${cppName} GetConstants() noexcept {/*implementation*/}\\n");`,
35
+ ];
36
+ }
37
+ exports.generateValidateConstants = generateValidateConstants;
38
38
  //# sourceMappingURL=ValidateConstants.js.map
@@ -1,9 +1,9 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import type { NativeModuleSchema } from '@react-native/codegen/lib/CodegenSchema';
7
- import { AliasMap } from './AliasManaging';
8
- import type { CppCodegenOptions } from './ObjectTypes';
9
- export declare function generateValidateMethods(nativeModule: NativeModuleSchema, aliases: AliasMap, options: CppCodegenOptions): [string, string];
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NativeModuleSchema } from '@react-native/codegen/lib/CodegenSchema';
7
+ import { AliasMap } from './AliasManaging';
8
+ import type { CppCodegenOptions } from './ObjectTypes';
9
+ export declare function generateValidateMethods(nativeModule: NativeModuleSchema, aliases: AliasMap, options: CppCodegenOptions): [string, string];