@react-native-windows/codegen 0.66.1 → 0.67.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.
Files changed (43) hide show
  1. package/CHANGELOG.json +204 -16
  2. package/CHANGELOG.md +99 -10
  3. package/lib-commonjs/Cli.d.ts +7 -0
  4. package/lib-commonjs/Cli.js +203 -0
  5. package/lib-commonjs/Cli.js.map +1 -0
  6. package/lib-commonjs/generators/AliasGen.d.ts +11 -0
  7. package/lib-commonjs/generators/AliasGen.js +72 -0
  8. package/lib-commonjs/generators/AliasGen.js.map +1 -0
  9. package/lib-commonjs/generators/AliasManaging.d.ts +15 -0
  10. package/lib-commonjs/generators/AliasManaging.js +49 -0
  11. package/lib-commonjs/generators/AliasManaging.js.map +1 -0
  12. package/lib-commonjs/generators/GenerateNM2.d.ts +11 -0
  13. package/lib-commonjs/generators/GenerateNM2.js +94 -0
  14. package/lib-commonjs/generators/GenerateNM2.js.map +1 -0
  15. package/lib-commonjs/generators/ObjectTypes.d.ts +8 -0
  16. package/lib-commonjs/generators/ObjectTypes.js +53 -0
  17. package/lib-commonjs/generators/ObjectTypes.js.map +1 -0
  18. package/lib-commonjs/generators/ParamTypes.d.ts +11 -0
  19. package/lib-commonjs/generators/ParamTypes.js +114 -0
  20. package/lib-commonjs/generators/ParamTypes.js.map +1 -0
  21. package/lib-commonjs/generators/ReturnTypes.d.ts +9 -0
  22. package/lib-commonjs/generators/ReturnTypes.js +63 -0
  23. package/lib-commonjs/generators/ReturnTypes.js.map +1 -0
  24. package/lib-commonjs/generators/ValidateConstants.d.ts +8 -0
  25. package/lib-commonjs/generators/ValidateConstants.js +38 -0
  26. package/lib-commonjs/generators/ValidateConstants.js.map +1 -0
  27. package/lib-commonjs/generators/ValidateMethods.d.ts +8 -0
  28. package/lib-commonjs/generators/ValidateMethods.js +70 -0
  29. package/lib-commonjs/generators/ValidateMethods.js.map +1 -0
  30. package/package.json +20 -10
  31. package/src/Cli.ts +23 -17
  32. package/src/generators/AliasGen.ts +105 -0
  33. package/src/generators/AliasManaging.ts +75 -0
  34. package/src/generators/GenerateNM2.ts +38 -122
  35. package/src/generators/ObjectTypes.ts +24 -39
  36. package/src/generators/ParamTypes.ts +144 -39
  37. package/src/generators/ReturnTypes.ts +29 -10
  38. package/src/generators/ValidateConstants.ts +50 -0
  39. package/src/generators/ValidateMethods.ts +135 -0
  40. package/.eslintrc.js +0 -4
  41. package/.vscode/launch.json +0 -23
  42. package/jest.config.js +0 -1
  43. package/tsconfig.json +0 -5
@@ -6,25 +6,17 @@
6
6
 
7
7
  'use strict';
8
8
 
9
+ import {NativeModuleBaseTypeAnnotation, Nullable} from 'react-native-tscodegen';
9
10
  import {
10
- NativeModuleBaseTypeAnnotation,
11
- NativeModuleObjectTypeAnnotation,
12
- NamedShape,
13
- Nullable,
14
- } from 'react-native-tscodegen';
11
+ AliasMap,
12
+ getAliasCppName,
13
+ getAnonymousAliasCppName,
14
+ } from './AliasManaging';
15
15
 
16
- let preferredModuleName: string = '';
17
-
18
- export function setPreferredModuleName(moduleName: string): void {
19
- preferredModuleName = moduleName;
20
- }
21
-
22
- export function getAliasCppName(typeName: string): string {
23
- return `${preferredModuleName}Spec_${typeName}`;
24
- }
25
-
26
- function translateField(
16
+ export function translateField(
27
17
  type: Nullable<NativeModuleBaseTypeAnnotation>,
18
+ aliases: AliasMap,
19
+ baseAliasName: string,
28
20
  ): string {
29
21
  // avoid: Property 'type' does not exist on type 'never'
30
22
  const returnType = type.type;
@@ -40,13 +32,19 @@ function translateField(
40
32
  case 'BooleanTypeAnnotation':
41
33
  return 'bool';
42
34
  case 'ArrayTypeAnnotation':
43
- // TODO: type.elementType
44
- return 'React::JSValueArray';
35
+ if (type.elementType) {
36
+ return `std::vector<${translateField(
37
+ type.elementType,
38
+ aliases,
39
+ `${baseAliasName}_element`,
40
+ )}>`;
41
+ } else {
42
+ return `React::JSValueArray`;
43
+ }
45
44
  case 'GenericObjectTypeAnnotation':
46
- return 'React::JSValueObject';
45
+ return 'React::JSValue';
47
46
  case 'ObjectTypeAnnotation':
48
- // TODO: we have more information here, and could create a more specific type
49
- return 'React::JSValueObject';
47
+ return getAnonymousAliasCppName(aliases, baseAliasName, type);
50
48
  case 'ReservedTypeAnnotation': {
51
49
  // avoid: Property 'name' does not exist on type 'never'
52
50
  const name = type.name;
@@ -61,25 +59,12 @@ function translateField(
61
59
  case 'TypeAliasTypeAnnotation':
62
60
  return getAliasCppName(type.name);
63
61
  case 'NullableTypeAnnotation':
64
- return `std::optional<${translateField(type.typeAnnotation)}>`;
62
+ return `std::optional<${translateField(
63
+ type.typeAnnotation,
64
+ aliases,
65
+ baseAliasName,
66
+ )}>`;
65
67
  default:
66
68
  throw new Error(`Unhandled type in translateReturnType: ${returnType}`);
67
69
  }
68
70
  }
69
-
70
- export function translateObjectBody(
71
- type: NativeModuleObjectTypeAnnotation,
72
- prefix: string,
73
- ) {
74
- return type.properties
75
- .map((prop: NamedShape<Nullable<NativeModuleBaseTypeAnnotation>>) => {
76
- let propType = prop.typeAnnotation;
77
- if (prop.optional && propType.type !== 'NullableTypeAnnotation') {
78
- propType = {type: 'NullableTypeAnnotation', typeAnnotation: propType};
79
- }
80
- const first = `${prefix}REACT_FIELD(${prop.name})`;
81
- const second = `${prefix}${translateField(propType)} ${prop.name};`;
82
- return `${first}\n${second}`;
83
- })
84
- .join('\n');
85
- }
@@ -11,19 +11,34 @@ import {
11
11
  NativeModuleParamTypeAnnotation,
12
12
  Nullable,
13
13
  } from 'react-native-tscodegen';
14
- import {getAliasCppName} from './ObjectTypes';
14
+ import {
15
+ AliasMap,
16
+ getAliasCppName,
17
+ getAnonymousAliasCppName,
18
+ } from './AliasManaging';
15
19
 
16
20
  type NativeModuleParamShape = NamedShape<
17
21
  Nullable<NativeModuleParamTypeAnnotation>
18
22
  >;
19
23
 
20
- function decorateType(type: string, forSpec: boolean): string {
21
- return forSpec ? type : `${type} &&`;
24
+ type ParamTarget = 'spec' | 'template' | 'callback-arg' | 'method-arg';
25
+
26
+ function decorateType(type: string, target: ParamTarget): string {
27
+ switch (target) {
28
+ case 'method-arg':
29
+ return `${type} &&`;
30
+ case 'callback-arg':
31
+ return `${type} const &`;
32
+ default:
33
+ return type;
34
+ }
22
35
  }
23
36
 
24
37
  function translateParam(
25
38
  param: NativeModuleParamTypeAnnotation,
26
- forSpec: boolean,
39
+ aliases: AliasMap,
40
+ baseAliasName: string,
41
+ target: ParamTarget,
27
42
  ): string {
28
43
  // avoid: Property 'type' does not exist on type 'never'
29
44
  const paramType = param.type;
@@ -39,21 +54,63 @@ function translateParam(
39
54
  case 'BooleanTypeAnnotation':
40
55
  return 'bool';
41
56
  case 'FunctionTypeAnnotation': {
42
- // TODO: type.params && type.returnTypeAnnotation
43
- if (forSpec) {
44
- return 'Callback<React::JSValue>';
45
- } else {
46
- return 'std::function<void(React::JSValue const &)> const &';
57
+ // TODO: type.returnTypeAnnotation
58
+ switch (target) {
59
+ case 'spec':
60
+ return `Callback<${param.params
61
+ .map((p: NativeModuleParamShape) =>
62
+ translateSpecFunctionParam(
63
+ p,
64
+ aliases,
65
+ `${baseAliasName}_${p.name}`,
66
+ ),
67
+ )
68
+ .join(', ')}>`;
69
+ case 'template':
70
+ return `std::function<void(${param.params
71
+ .map((p: NativeModuleParamShape) =>
72
+ translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`),
73
+ )
74
+ .join(', ')})>`;
75
+ default:
76
+ return `std::function<void(${param.params
77
+ .map((p: NativeModuleParamShape) =>
78
+ translateCallbackParam(p, aliases, `${baseAliasName}_${p.name}`),
79
+ )
80
+ .join(', ')})> const &`;
47
81
  }
48
82
  }
49
83
  case 'ArrayTypeAnnotation':
50
- // TODO: type.elementType
51
- return decorateType('React::JSValueArray', forSpec);
84
+ if (param.elementType) {
85
+ switch (target) {
86
+ case 'spec':
87
+ case 'template':
88
+ return `std::vector<${translateNullableParamType(
89
+ param.elementType,
90
+ aliases,
91
+ `${baseAliasName}_element`,
92
+ 'template',
93
+ 'template',
94
+ )}>`;
95
+ default:
96
+ return `std::vector<${translateNullableParamType(
97
+ param.elementType,
98
+ aliases,
99
+ `${baseAliasName}_element`,
100
+ 'template',
101
+ 'template',
102
+ )}> const &`;
103
+ }
104
+ } else {
105
+ return decorateType('React::JSValueArray', target);
106
+ }
52
107
  case 'GenericObjectTypeAnnotation':
53
- return decorateType('React::JSValueObject', forSpec);
108
+ return decorateType('React::JSValue', target);
54
109
  case 'ObjectTypeAnnotation':
55
- // TODO: we have more information here, and could create a more specific type
56
- return decorateType('React::JSValueObject', forSpec);
110
+ return decorateType(
111
+ getAnonymousAliasCppName(aliases, baseAliasName, param),
112
+ target,
113
+ );
57
114
  case 'ReservedTypeAnnotation': {
58
115
  // avoid: Property 'name' does not exist on type 'never'
59
116
  const name = param.name;
@@ -64,52 +121,100 @@ function translateParam(
64
121
  return 'double';
65
122
  }
66
123
  case 'TypeAliasTypeAnnotation':
67
- return decorateType(getAliasCppName(param.name), forSpec);
124
+ return decorateType(getAliasCppName(param.name), target);
68
125
  default:
69
126
  throw new Error(`Unhandled type in translateParam: ${paramType}`);
70
127
  }
71
128
  }
72
129
 
73
- function translateSpecFunctionParam(param: NativeModuleParamShape): string {
74
- switch (param.typeAnnotation.type) {
130
+ function translateNullableParamType(
131
+ paramType: Nullable<NativeModuleParamTypeAnnotation>,
132
+ aliases: AliasMap,
133
+ baseAliasName: string,
134
+ nullableTarget: ParamTarget,
135
+ target: ParamTarget,
136
+ ): string {
137
+ switch (paramType.type) {
75
138
  case 'NullableTypeAnnotation':
76
- // TODO: should be
77
- // return `std::optional<${translateParam(
78
- // param.typeAnnotation.typeAnnotation,
79
- // true,
80
- // )}>`;
81
- return translateParam(param.typeAnnotation.typeAnnotation, true);
139
+ return `std::optional<${translateParam(
140
+ paramType.typeAnnotation,
141
+ aliases,
142
+ baseAliasName,
143
+ nullableTarget,
144
+ )}>`;
82
145
  default:
83
- return translateParam(param.typeAnnotation, true);
146
+ return translateParam(paramType, aliases, baseAliasName, target);
84
147
  }
85
148
  }
86
149
 
87
- function translateFunctionParam(param: NativeModuleParamShape): string {
88
- switch (param.typeAnnotation.type) {
89
- case 'NullableTypeAnnotation':
90
- // TODO: should be
91
- // return `std::optional<${translateParam(
92
- // param.typeAnnotation.typeAnnotation,
93
- // false,
94
- // )}>`;
95
- return translateParam(param.typeAnnotation.typeAnnotation, false);
96
- default:
97
- return translateParam(param.typeAnnotation, false);
98
- }
150
+ function translateSpecFunctionParam(
151
+ param: NativeModuleParamShape,
152
+ aliases: AliasMap,
153
+ baseAliasName: string,
154
+ ): string {
155
+ return translateNullableParamType(
156
+ param.typeAnnotation,
157
+ aliases,
158
+ baseAliasName,
159
+ 'spec',
160
+ 'spec',
161
+ );
162
+ }
163
+
164
+ function translateCallbackParam(
165
+ param: NativeModuleParamShape,
166
+ aliases: AliasMap,
167
+ baseAliasName: string,
168
+ ): string {
169
+ return translateNullableParamType(
170
+ param.typeAnnotation,
171
+ aliases,
172
+ baseAliasName,
173
+ 'template',
174
+ 'callback-arg',
175
+ );
176
+ }
177
+
178
+ function translateFunctionParam(
179
+ param: NativeModuleParamShape,
180
+ aliases: AliasMap,
181
+ baseAliasName: string,
182
+ ): string {
183
+ return translateNullableParamType(
184
+ param.typeAnnotation,
185
+ aliases,
186
+ baseAliasName,
187
+ 'template',
188
+ 'method-arg',
189
+ );
99
190
  }
100
191
 
101
192
  export function translateSpecArgs(
102
193
  params: ReadonlyArray<NativeModuleParamShape>,
194
+ aliases: AliasMap,
195
+ baseAliasName: string,
103
196
  ) {
104
197
  return params.map(param => {
105
- const translatedParam = translateSpecFunctionParam(param);
198
+ const translatedParam = translateSpecFunctionParam(
199
+ param,
200
+ aliases,
201
+ `${baseAliasName}_${param.name}`,
202
+ );
106
203
  return `${translatedParam}`;
107
204
  });
108
205
  }
109
206
 
110
- export function translateArgs(params: ReadonlyArray<NativeModuleParamShape>) {
207
+ export function translateArgs(
208
+ params: ReadonlyArray<NativeModuleParamShape>,
209
+ aliases: AliasMap,
210
+ baseAliasName: string,
211
+ ) {
111
212
  return params.map(param => {
112
- const translatedParam = translateFunctionParam(param);
213
+ const translatedParam = translateFunctionParam(
214
+ param,
215
+ aliases,
216
+ `${baseAliasName}_${param.name}`,
217
+ );
113
218
  return `${translatedParam} ${param.name}`;
114
219
  });
115
220
  }
@@ -10,10 +10,16 @@ import {
10
10
  NativeModuleReturnTypeAnnotation,
11
11
  Nullable,
12
12
  } from 'react-native-tscodegen';
13
- import {getAliasCppName} from './ObjectTypes';
13
+ import {
14
+ AliasMap,
15
+ getAliasCppName,
16
+ getAnonymousAliasCppName,
17
+ } from './AliasManaging';
14
18
 
15
19
  function translateReturnType(
16
20
  type: Nullable<NativeModuleReturnTypeAnnotation>,
21
+ aliases: AliasMap,
22
+ baseAliasName: string,
17
23
  ): string {
18
24
  // avoid: Property 'type' does not exist on type 'never'
19
25
  const returnType = type.type;
@@ -32,13 +38,19 @@ function translateReturnType(
32
38
  case 'BooleanTypeAnnotation':
33
39
  return 'bool';
34
40
  case 'ArrayTypeAnnotation':
35
- // TODO: type.elementType
36
- return 'React::JSValueArray';
41
+ if (type.elementType) {
42
+ return `std::vector<${translateReturnType(
43
+ type.elementType,
44
+ aliases,
45
+ `${baseAliasName}_element`,
46
+ )}>`;
47
+ } else {
48
+ return 'React::JSValueArray';
49
+ }
37
50
  case 'GenericObjectTypeAnnotation':
38
- return 'React::JSValueObject';
51
+ return 'React::JSValue';
39
52
  case 'ObjectTypeAnnotation':
40
- // TODO: we have more information here, and could create a more specific type
41
- return 'React::JSValueObject';
53
+ return getAnonymousAliasCppName(aliases, baseAliasName, type);
42
54
  case 'ReservedTypeAnnotation': {
43
55
  // avoid: Property 'name' does not exist on type 'never'
44
56
  const name = type.name;
@@ -53,8 +65,11 @@ function translateReturnType(
53
65
  case 'TypeAliasTypeAnnotation':
54
66
  return getAliasCppName(type.name);
55
67
  case 'NullableTypeAnnotation':
56
- // TODO: should be `std::optional<${translateReturnType(type.typeAnnotation)}>`;
57
- return translateReturnType(type.typeAnnotation);
68
+ return `std::optional<${translateReturnType(
69
+ type.typeAnnotation,
70
+ aliases,
71
+ baseAliasName,
72
+ )}>`;
58
73
  default:
59
74
  throw new Error(`Unhandled type in translateReturnType: ${returnType}`);
60
75
  }
@@ -62,12 +77,16 @@ function translateReturnType(
62
77
 
63
78
  export function translateSpecReturnType(
64
79
  type: Nullable<NativeModuleReturnTypeAnnotation>,
80
+ aliases: AliasMap,
81
+ baseAliasName: string,
65
82
  ) {
66
- return translateReturnType(type);
83
+ return translateReturnType(type, aliases, `${baseAliasName}_returnType`);
67
84
  }
68
85
 
69
86
  export function translateImplReturnType(
70
87
  type: Nullable<NativeModuleReturnTypeAnnotation>,
88
+ aliases: AliasMap,
89
+ baseAliasName: string,
71
90
  ) {
72
- return translateReturnType(type);
91
+ return translateReturnType(type, aliases, `${baseAliasName}_returnType`);
73
92
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ import {NativeModuleSchema} from 'react-native-tscodegen';
10
+ import {AliasMap, getAnonymousAliasCppName} from './AliasManaging';
11
+
12
+ export function generateValidateConstants(
13
+ nativeModule: NativeModuleSchema,
14
+ aliases: AliasMap,
15
+ ): [string, string] | undefined {
16
+ const candidates = nativeModule.spec.properties.filter(
17
+ prop => prop.name === 'getConstants',
18
+ );
19
+ if (candidates.length === 0) {
20
+ return undefined;
21
+ }
22
+
23
+ const getConstant = candidates[0];
24
+ const funcType =
25
+ getConstant.typeAnnotation.type === 'NullableTypeAnnotation'
26
+ ? getConstant.typeAnnotation.typeAnnotation
27
+ : getConstant.typeAnnotation;
28
+ if (
29
+ funcType.params.length > 0 ||
30
+ funcType.returnTypeAnnotation.type !== 'ObjectTypeAnnotation'
31
+ ) {
32
+ return undefined;
33
+ }
34
+
35
+ const constantType = funcType.returnTypeAnnotation;
36
+ if (constantType.properties.length === 0) {
37
+ return undefined;
38
+ }
39
+
40
+ const cppName = getAnonymousAliasCppName(aliases, 'Constants', constantType);
41
+
42
+ return [
43
+ ` TypedConstant<${cppName}>{0},`,
44
+ ` REACT_SHOW_CONSTANT_SPEC_ERRORS(
45
+ 0,
46
+ "${cppName}",
47
+ " REACT_GET_CONSTANTS(GetConstants) ${cppName} GetConstants() noexcept {/*implementation*/}\\n"
48
+ " REACT_GET_CONSTANTS(GetConstants) static ${cppName} GetConstants() noexcept {/*implementation*/}\\n");`,
49
+ ];
50
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ import {
10
+ NativeModuleFunctionTypeAnnotation,
11
+ NativeModulePropertyShape,
12
+ NativeModuleSchema,
13
+ } from 'react-native-tscodegen';
14
+ import {AliasMap} from './AliasManaging';
15
+ import {translateArgs, translateSpecArgs} from './ParamTypes';
16
+ import {translateImplReturnType, translateSpecReturnType} from './ReturnTypes';
17
+
18
+ function isMethodSync(funcType: NativeModuleFunctionTypeAnnotation) {
19
+ return (
20
+ funcType.returnTypeAnnotation.type !== 'VoidTypeAnnotation' &&
21
+ funcType.returnTypeAnnotation.type !== 'PromiseTypeAnnotation'
22
+ );
23
+ }
24
+
25
+ function isMethodReturnPromise(funcType: NativeModuleFunctionTypeAnnotation) {
26
+ return funcType.returnTypeAnnotation.type === 'PromiseTypeAnnotation';
27
+ }
28
+
29
+ function getPossibleMethodSignatures(
30
+ prop: NativeModulePropertyShape,
31
+ funcType: NativeModuleFunctionTypeAnnotation,
32
+ aliases: AliasMap,
33
+ baseAliasName: string,
34
+ ): string[] {
35
+ const args = translateArgs(funcType.params, aliases, baseAliasName);
36
+ if (isMethodReturnPromise(funcType)) {
37
+ // TODO: type of the promise could be provided in the future
38
+ args.push('React::ReactPromise<React::JSValue> &&result');
39
+ }
40
+
41
+ // TODO: be much more exhastive on the possible method signatures that can be used..
42
+ const sig = `REACT_${isMethodSync(funcType) ? 'SYNC_' : ''}METHOD(${
43
+ prop.name
44
+ }) ${translateImplReturnType(
45
+ funcType.returnTypeAnnotation,
46
+ aliases,
47
+ baseAliasName,
48
+ )} ${prop.name}(${args.join(', ')}) noexcept { /* implementation */ }}`;
49
+
50
+ const staticsig = `REACT_${isMethodSync(funcType) ? 'SYNC_' : ''}METHOD(${
51
+ prop.name
52
+ }) static ${translateImplReturnType(
53
+ funcType.returnTypeAnnotation,
54
+ aliases,
55
+ baseAliasName,
56
+ )} ${prop.name}(${args.join(', ')}) noexcept { /* implementation */ }}`;
57
+
58
+ return [sig, staticsig];
59
+ }
60
+
61
+ function translatePossibleMethodSignatures(
62
+ prop: NativeModulePropertyShape,
63
+ funcType: NativeModuleFunctionTypeAnnotation,
64
+ aliases: AliasMap,
65
+ baseAliasName: string,
66
+ ): string {
67
+ return getPossibleMethodSignatures(prop, funcType, aliases, baseAliasName)
68
+ .map(sig => `" ${sig}\\n"`)
69
+ .join('\n ');
70
+ }
71
+
72
+ function renderProperties(
73
+ properties: ReadonlyArray<NativeModulePropertyShape>,
74
+ aliases: AliasMap,
75
+ tuple: boolean,
76
+ ): string {
77
+ // TODO: generate code for constants
78
+ return properties
79
+ .filter(prop => prop.name !== 'getConstants')
80
+ .map((prop, index) => {
81
+ // TODO: prop.optional === true
82
+ // TODO: prop.typeAnnotation.type === 'NullableTypeAnnotation'
83
+ const propAliasName = prop.name;
84
+ const funcType =
85
+ prop.typeAnnotation.type === 'NullableTypeAnnotation'
86
+ ? prop.typeAnnotation.typeAnnotation
87
+ : prop.typeAnnotation;
88
+
89
+ const traversedArgs = translateSpecArgs(
90
+ funcType.params,
91
+ aliases,
92
+ propAliasName,
93
+ );
94
+
95
+ const translatedReturnParam = translateSpecReturnType(
96
+ funcType.returnTypeAnnotation,
97
+ aliases,
98
+ propAliasName,
99
+ );
100
+
101
+ if (isMethodReturnPromise(funcType)) {
102
+ // TODO: type of the promise could be provided in the future
103
+ traversedArgs.push('Promise<React::JSValue>');
104
+ }
105
+
106
+ if (tuple) {
107
+ return ` ${
108
+ isMethodSync(funcType) ? 'Sync' : ''
109
+ }Method<${translatedReturnParam}(${traversedArgs.join(
110
+ ', ',
111
+ )}) noexcept>{${index}, L"${prop.name}"},`;
112
+ } else {
113
+ return ` REACT_SHOW_METHOD_SPEC_ERRORS(
114
+ ${index},
115
+ "${prop.name}",
116
+ ${translatePossibleMethodSignatures(
117
+ prop,
118
+ funcType,
119
+ aliases,
120
+ propAliasName,
121
+ )});`;
122
+ }
123
+ })
124
+ .join('\n');
125
+ }
126
+
127
+ export function generateValidateMethods(
128
+ nativeModule: NativeModuleSchema,
129
+ aliases: AliasMap,
130
+ ): [string, string] {
131
+ const properties = nativeModule.spec.properties;
132
+ const traversedProperties = renderProperties(properties, aliases, false);
133
+ const traversedPropertyTuples = renderProperties(properties, aliases, true);
134
+ return [traversedPropertyTuples, traversedProperties];
135
+ }
package/.eslintrc.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- extends: ['@rnw-scripts'],
3
- parserOptions: {tsconfigRootDir : __dirname},
4
- };
@@ -1,23 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "vscode-jest-tests",
9
- "type": "node",
10
- "request": "launch",
11
- "runtimeArgs": [
12
- "--inspect-brk",
13
- "../../node_modules/jest/bin/jest.js",
14
- "--runInBand",
15
- "--config",
16
- "../@rnw-scripts/jest-debug-config/jest.debug.config.js",
17
- ],
18
- "console": "integratedTerminal",
19
- "internalConsoleOptions": "neverOpen",
20
- "port": 9229,
21
- },
22
- ]
23
- }
package/jest.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('@rnw-scripts/jest-unittest-config');
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "@rnw-scripts/ts-config",
3
- "include": ["src"],
4
- "exclude": ["node_modules"]
5
- }