@react-native-windows/codegen 0.0.0-canary.4 → 0.0.0-canary.40

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 (52) hide show
  1. package/CHANGELOG.md +348 -4
  2. package/bin.js +0 -0
  3. package/lib-commonjs/Cli.d.ts +7 -0
  4. package/lib-commonjs/Cli.js +60 -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 +12 -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/GenerateTypeScript.d.ts +11 -0
  16. package/lib-commonjs/generators/GenerateTypeScript.js +166 -0
  17. package/lib-commonjs/generators/GenerateTypeScript.js.map +1 -0
  18. package/lib-commonjs/generators/ObjectTypes.d.ts +8 -0
  19. package/lib-commonjs/generators/ObjectTypes.js +53 -0
  20. package/lib-commonjs/generators/ObjectTypes.js.map +1 -0
  21. package/lib-commonjs/generators/ParamTypes.d.ts +11 -0
  22. package/lib-commonjs/generators/ParamTypes.js +114 -0
  23. package/lib-commonjs/generators/ParamTypes.js.map +1 -0
  24. package/lib-commonjs/generators/ReturnTypes.d.ts +9 -0
  25. package/lib-commonjs/generators/ReturnTypes.js +63 -0
  26. package/lib-commonjs/generators/ReturnTypes.js.map +1 -0
  27. package/lib-commonjs/generators/ValidateConstants.d.ts +8 -0
  28. package/lib-commonjs/generators/ValidateConstants.js +38 -0
  29. package/lib-commonjs/generators/ValidateConstants.js.map +1 -0
  30. package/lib-commonjs/generators/ValidateMethods.d.ts +8 -0
  31. package/lib-commonjs/generators/ValidateMethods.js +70 -0
  32. package/lib-commonjs/generators/ValidateMethods.js.map +1 -0
  33. package/lib-commonjs/index.d.ts +35 -0
  34. package/lib-commonjs/index.js +190 -0
  35. package/lib-commonjs/index.js.map +1 -0
  36. package/package.json +30 -16
  37. package/src/Cli.ts +26 -152
  38. package/src/generators/AliasGen.ts +105 -0
  39. package/src/generators/AliasManaging.ts +75 -0
  40. package/src/generators/GenerateNM2.ts +69 -297
  41. package/src/generators/GenerateTypeScript.ts +247 -0
  42. package/src/generators/ObjectTypes.ts +73 -0
  43. package/src/generators/ParamTypes.ts +220 -0
  44. package/src/generators/ReturnTypes.ts +92 -0
  45. package/src/generators/ValidateConstants.ts +50 -0
  46. package/src/generators/ValidateMethods.ts +135 -0
  47. package/src/index.ts +321 -0
  48. package/.eslintrc.js +0 -4
  49. package/.vscode/launch.json +0 -23
  50. package/CHANGELOG.json +0 -462
  51. package/jest.config.js +0 -1
  52. package/tsconfig.json +0 -5
package/CHANGELOG.md CHANGED
@@ -1,17 +1,361 @@
1
1
  # Change Log - @react-native-windows/codegen
2
2
 
3
- This log was last generated on Thu, 04 Mar 2021 05:04:36 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 18 Oct 2022 05:11:29 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.0.0-canary.4
7
+ ## 0.0.0-canary.40
8
8
 
9
- Thu, 04 Mar 2021 05:04:36 GMT
9
+ Tue, 18 Oct 2022 05:11:29 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Update yargs version used and patch y18n version 4.0.0 to 4.0.1 as used by detox of transitive dependencies to address https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-7774 (dannyvv@microsoft.com)
13
+ - Use newer react-native-codegen generators (30809111+acoates-ms@users.noreply.github.com)
14
14
 
15
+ ## 0.0.0-canary.39
16
+
17
+ Sat, 15 Oct 2022 05:12:00 GMT
18
+
19
+ ### Changes
20
+
21
+ - Bump @react-native-windows/fs to v0.0.0-canary.7
22
+
23
+ ## 0.0.0-canary.38
24
+
25
+ Fri, 07 Oct 2022 05:11:46 GMT
26
+
27
+ ### Changes
28
+
29
+ - Remove extra paren in codegen output (30809111+acoates-ms@users.noreply.github.com)
30
+
31
+ ## 0.0.0-canary.37
32
+
33
+ Wed, 05 Oct 2022 05:13:46 GMT
34
+
35
+ ### Changes
36
+
37
+ - Use react-native-codegen from rn, instead of from react-native-tscodegen (30809111+acoates-ms@users.noreply.github.com)
38
+ - integrate 7/29/22 (tatianakapos@microsoft.com)
39
+ - Bump @react-native-windows/fs to v0.0.0-canary.6
40
+ - Bump @rnw-scripts/eslint-config to v1.1.14
41
+ - Bump @rnw-scripts/jest-unittest-config to v1.3.0
42
+ - Bump @rnw-scripts/just-task to v2.2.6
43
+
44
+ ## 0.0.0-canary.36
45
+
46
+ Tue, 27 Sep 2022 05:11:30 GMT
47
+
48
+ ### Changes
49
+
50
+ - Export functionality to allow cli to use it (30809111+acoates-ms@users.noreply.github.com)
51
+
52
+ ## 0.0.0-canary.35
53
+
54
+ Sat, 04 Jun 2022 05:10:05 GMT
55
+
56
+ ### Changes
57
+
58
+ - Bump @react-native-windows/fs to v0.0.0-canary.5
59
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.8
60
+ - Bump @rnw-scripts/just-task to v2.2.5
61
+
62
+ ## 0.0.0-canary.34
63
+
64
+ Thu, 12 May 2022 05:09:43 GMT
65
+
66
+ ### Changes
67
+
68
+ - Build/dependency fixes (ngerlem@microsoft.com)
69
+ - Bump @react-native-windows/fs to v0.0.0-canary.4
70
+ - Bump @rnw-scripts/eslint-config to v1.1.13
71
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.7
72
+ - Bump @rnw-scripts/just-task to v2.2.4
73
+
74
+ ## 0.0.0-canary.33
75
+
76
+ Wed, 11 May 2022 05:08:51 GMT
77
+
78
+ ### Changes
79
+
80
+ - Add --methodonly to RNW/codegen (53799235+ZihanChen-MSFT@users.noreply.github.com)
81
+
82
+ ## 0.0.0-canary.32
83
+
84
+ Wed, 27 Apr 2022 05:10:23 GMT
85
+
86
+ ### Changes
87
+
88
+ - Merge (34109996+chiaramooney@users.noreply.github.com)
89
+ - Bump @react-native-windows/fs to v0.0.0-canary.3
90
+ - Bump @rnw-scripts/eslint-config to v1.1.12
91
+
92
+ ## 0.0.0-canary.31
93
+
94
+ Mon, 25 Apr 2022 22:50:30 GMT
95
+
96
+ ### Changes
97
+
98
+ - Update globby of @react-native-windows/codegen to remove glob-parent 3.x dependency (dannyvv@microsoft.com)
99
+
100
+ ## 0.0.0-canary.30
101
+
102
+ Tue, 12 Apr 2022 05:10:38 GMT
103
+
104
+ ### Changes
105
+
106
+ - Fix Overrides (34109996+chiaramooney@users.noreply.github.com)
107
+ - Bump @react-native-windows/fs to v0.0.0-canary.2
108
+
109
+ ## 0.0.0-canary.29
110
+
111
+ Fri, 01 Apr 2022 05:09:56 GMT
112
+
113
+ ### Changes
114
+
115
+ - Fix publish after promotion to preview (ngerlem@microsoft.com)
116
+ - Bump @react-native-windows/fs to v0.0.0-canary.1
117
+
118
+ ## 0.0.0-canary.28
119
+
120
+ Wed, 09 Mar 2022 06:09:07 GMT
121
+
122
+ ### Changes
123
+
124
+ - Fix turbo module codegen to generate correct import statement and registration (53799235+ZihanChen-MSFT@users.noreply.github.com)
125
+
126
+ ## 0.0.0-canary.27
127
+
128
+ Fri, 04 Mar 2022 06:09:13 GMT
129
+
130
+ ### Changes
131
+
132
+ - Generate fabric eventemitter.cpp (acoates@microsoft.com)
133
+
134
+ ## 0.0.0-canary.26
135
+
136
+ Thu, 24 Feb 2022 06:07:47 GMT
137
+
138
+ ### Changes
139
+
140
+ - Add TypeScript turbo module definition as new codegen traget (53799235+ZihanChen-MSFT@users.noreply.github.com)
141
+
142
+ ## 0.0.0-canary.25
143
+
144
+ Wed, 09 Feb 2022 06:09:36 GMT
145
+
146
+ ### Changes
147
+
148
+ - Bump minimum Node version to 14 (jthysell@microsoft.com)
149
+ - Bump @react-native-windows/fs to v1.0.2
150
+ - Bump @rnw-scripts/eslint-config to v1.1.11
151
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.6
152
+ - Bump @rnw-scripts/just-task to v2.2.3
153
+ - Bump @rnw-scripts/ts-config to v2.0.2
154
+
155
+ ## 0.0.0-canary.24
156
+
157
+ Tue, 08 Feb 2022 18:21:23 GMT
158
+
159
+ ### Changes
160
+
161
+ - Fix TurboModule codegen document (53799235+ZihanChen-MSFT@users.noreply.github.com)
162
+
163
+ ## 0.0.0-canary.23
164
+
165
+ Sat, 29 Jan 2022 06:08:58 GMT
166
+
167
+ ### Changes
168
+
169
+ - Add document for turbo module codegen (53799235+ZihanChen-MSFT@users.noreply.github.com)
170
+
171
+ ## 0.0.0-canary.22
172
+
173
+ Fri, 03 Dec 2021 06:12:10 GMT
174
+
175
+ ### Changes
176
+
177
+ - Integrate 11/11 (34109996+chiaramooney@users.noreply.github.com)
178
+ - Bump @react-native-windows/fs to v1.0.1
179
+ - Bump @rnw-scripts/eslint-config to v1.1.10
180
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.5
181
+ - Bump @rnw-scripts/just-task to v2.2.2
182
+
183
+ ## 0.0.0-canary.21
184
+
185
+ Thu, 18 Nov 2021 06:11:20 GMT
186
+
187
+ ### Changes
188
+
189
+ - Use '@react-native-windows/fs' (ngerlem@microsoft.com)
190
+ - Bump @react-native-windows/fs to v1.0.0
191
+ - Bump @rnw-scripts/eslint-config to v1.1.9
192
+
193
+ ## 0.0.0-canary.20
194
+
195
+ Thu, 04 Nov 2021 05:07:29 GMT
196
+
197
+ ### Changes
198
+
199
+ - Codegen prints `::React::JSValue` instead of `React::JSValue` (53799235+ZihanChen-MSFT@users.noreply.github.com)
200
+
201
+ ## 0.0.0-canary.20
202
+
203
+ Thu, 04 Nov 2021 05:07:08 GMT
204
+
205
+ ### Changes
206
+
207
+ - Codegen prints `::React::JSValue` instead of `React::JSValue` (53799235+ZihanChen-MSFT@users.noreply.github.com)
208
+
209
+ ## 0.0.0-canary.19
210
+
211
+ Sat, 23 Oct 2021 05:06:49 GMT
212
+
213
+ ### Changes
214
+
215
+ - Only generate component files if a component is specified (30809111+acoates-ms@users.noreply.github.com)
216
+
217
+ ## 0.0.0-canary.18
218
+
219
+ Fri, 22 Oct 2021 05:06:46 GMT
220
+
221
+ ### Changes
222
+
223
+ - Built files not included in published package (30809111+acoates-ms@users.noreply.github.com)
224
+
225
+ ## 0.0.0-canary.17
226
+
227
+ Thu, 21 Oct 2021 05:08:01 GMT
228
+
229
+ ### Changes
230
+
231
+ - Update to typescript 4 (30809111+acoates-ms@users.noreply.github.com)
232
+
233
+ ## 0.0.0-canary.16
234
+
235
+ Wed, 29 Sep 2021 05:06:54 GMT
236
+
237
+ ### Changes
238
+
239
+ - Check constants in generated turbo module specs (53799235+ZihanChen-MSFT@users.noreply.github.com)
240
+
241
+ ## 0.0.0-canary.15
242
+
243
+ Wed, 15 Sep 2021 05:07:04 GMT
244
+
245
+ ### Changes
246
+
247
+ - Generate anonymous objects in correct order for turbo module (53799235+ZihanChen-MSFT@users.noreply.github.com)
248
+
249
+ ## 0.0.0-canary.14
250
+
251
+ Fri, 10 Sep 2021 05:07:31 GMT
252
+
253
+ ### Changes
254
+
255
+ - Generate `std::vector<T>` for array types in turbo modules (53799235+ZihanChen-MSFT@users.noreply.github.com)
256
+
257
+ ## 0.0.0-canary.13
258
+
259
+ Thu, 09 Sep 2021 05:07:46 GMT
260
+
261
+ ### Changes
262
+
263
+ - Bump to 0.66-based react-native-tscodegen (ngerlem@microsoft.com)
264
+ - Generate nullable type for turbo module (53799235+ZihanChen-MSFT@users.noreply.github.com)
265
+
266
+ ## 0.0.0-canary.12
267
+
268
+ Wed, 08 Sep 2021 05:08:53 GMT
269
+
270
+ ### Patches
271
+
272
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.4 (ngerlem@microsoft.com)
273
+ - Bump @rnw-scripts/just-task to v2.2.1 (ngerlem@microsoft.com)
274
+ - Bump @rnw-scripts/ts-config to v2.0.1 (ngerlem@microsoft.com)
275
+ - Bump @rnw-scripts/eslint-config to v1.1.8 (ngerlem@microsoft.com)
276
+
277
+ ### Changes
278
+
279
+ - Set consistent node requirements on our packages (ngerlem@microsoft.com)
280
+ - Match Alert module with NativeDialogManagerWindowsSpec.h (53799235+ZihanChen-MSFT@users.noreply.github.com)
281
+
282
+ ## 0.0.0-canary.11
283
+
284
+ Fri, 03 Sep 2021 05:06:04 GMT
285
+
286
+ ### Changes
287
+
288
+ - Generate aliased struct for turbo module (53799235+ZihanChen-MSFT@users.noreply.github.com)
289
+
290
+ ## 0.0.0-canary.10
291
+
292
+ Thu, 05 Aug 2021 05:07:20 GMT
293
+
294
+ ### Changes
295
+
296
+ - Do not write codegen files if the contents have not changed, as this breaks incremental builds (30809111+acoates-ms@users.noreply.github.com)
297
+
298
+ ## 0.0.0-canary.9
299
+
300
+ Fri, 11 Jun 2021 05:08:55 GMT
301
+
302
+ ### Patches
303
+
304
+ - Bump @rnw-scripts/just-task to v2.2.0 (ngerlem@microsoft.com)
305
+
306
+ ## 0.0.0-canary.8
307
+
308
+ Wed, 09 Jun 2021 05:10:07 GMT
309
+
310
+ ### Patches
311
+
312
+ - Bump @rnw-scripts/just-task to v2.1.3 (igklemen@microsoft.com)
313
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.3 (igklemen@microsoft.com)
314
+
315
+ ## 0.0.0-canary.7
316
+
317
+ Thu, 03 Jun 2021 05:09:47 GMT
318
+
319
+ ### Patches
320
+
321
+ - Bump @rnw-scripts/just-task to v2.1.2 (ngerlem@microsoft.com)
322
+ - Bump @rnw-scripts/ts-config to v2.0.0 (ngerlem@microsoft.com)
323
+ - Bump @rnw-scripts/eslint-config to v1.1.7 (ngerlem@microsoft.com)
324
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.2 (ngerlem@microsoft.com)
325
+
326
+ ### Changes
327
+
328
+ - Enable esModuleInterop Repo Wide (ngerlem@microsoft.com)
329
+
330
+ ## 0.0.0-canary.6
331
+
332
+ Fri, 21 May 2021 05:17:18 GMT
333
+
334
+ ### Patches
335
+
336
+ - Bump @rnw-scripts/just-task to v2.1.1 (ngerlem@microsoft.com)
337
+ - Bump @rnw-scripts/jest-unittest-config to v1.2.1 (ngerlem@microsoft.com)
338
+
339
+ ### Changes
340
+
341
+ - Integrate Apr 28 (base of 0.65) Nightly RN Build (ngerlem@microsoft.com)
342
+
343
+ ## 0.0.0-canary.5
344
+
345
+ Thu, 13 May 2021 05:11:48 GMT
346
+
347
+ ### Changes
348
+
349
+ - Hook up view component codegen (30809111+acoates-ms@users.noreply.github.com)
350
+
351
+ ## 0.0.0-canary.4
352
+
353
+ Thu, 04 Mar 2021 05:05:53 GMT
354
+
355
+ ### Changes
356
+
357
+ - Update yargs version used and patch y18n version 4.0.0 to 4.0.1 as used by detox of transitive dependencies to address https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-7774 (dannyvv@microsoft.com)
358
+
15
359
  ## 0.0.0-canary.3
16
360
 
17
361
  Thu, 11 Feb 2021 05:08:29 GMT
package/bin.js CHANGED
File without changes
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const yargs_1 = __importDefault(require("yargs"));
13
+ const index_1 = require("./index");
14
+ const argv = yargs_1.default.options({
15
+ file: {
16
+ type: 'string',
17
+ describe: 'file which contains spec',
18
+ },
19
+ files: {
20
+ type: 'string',
21
+ array: true,
22
+ describe: 'glob patterns for files which contains specs',
23
+ },
24
+ ts: {
25
+ type: 'boolean',
26
+ describe: 'generate turbo module definition files in TypeScript',
27
+ default: false,
28
+ },
29
+ methodonly: {
30
+ type: 'boolean',
31
+ describe: 'generate only method metadata in C++ turbo module spec',
32
+ default: false,
33
+ },
34
+ outdir: {
35
+ type: 'string',
36
+ describe: 'output directory',
37
+ default: 'codegen',
38
+ },
39
+ test: {
40
+ type: 'boolean',
41
+ describe: 'Verify that the generated output is unchanged',
42
+ default: false,
43
+ },
44
+ namespace: {
45
+ type: 'string',
46
+ describe: 'C++/C# Namespace to put generated native modules in',
47
+ default: 'MyNamespace',
48
+ },
49
+ libraryName: {
50
+ type: 'string',
51
+ required: true,
52
+ describe: 'Used for part of the path generated within the codegen dir',
53
+ },
54
+ }).argv;
55
+ if ((argv.file && argv.files) || (!argv.file && !argv.files)) {
56
+ console.error('You must specify either --file or --files.');
57
+ process.exit(1);
58
+ }
59
+ (0, index_1.runCodeGen)(argv);
60
+ //# sourceMappingURL=Cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli.js","sourceRoot":"","sources":["../src/Cli.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAEH,kDAA0B;AAC1B,mCAAmC;AAEnC,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,0BAA0B;KACrC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,8CAA8C;KACzD;IACD,EAAE,EAAE;QACF,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,sDAAsD;QAChE,OAAO,EAAE,KAAK;KACf;IACD,UAAU,EAAE;QACV,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,wDAAwD;QAClE,OAAO,EAAE,KAAK;KACf;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,SAAS;KACnB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,+CAA+C;QACzD,OAAO,EAAE,KAAK;KACf;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,qDAAqD;QAC/D,OAAO,EAAE,aAAa;KACvB;IACD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,4DAA4D;KACvE;CACF,CAAC,CAAC,IAAI,CAAC;AAER,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;IAC5D,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport yargs from 'yargs';\nimport {runCodeGen} from './index';\n\nconst argv = yargs.options({\n file: {\n type: 'string',\n describe: 'file which contains spec',\n },\n files: {\n type: 'string',\n array: true,\n describe: 'glob patterns for files which contains specs',\n },\n ts: {\n type: 'boolean',\n describe: 'generate turbo module definition files in TypeScript',\n default: false,\n },\n methodonly: {\n type: 'boolean',\n describe: 'generate only method metadata in C++ turbo module spec',\n default: false,\n },\n outdir: {\n type: 'string',\n describe: 'output directory',\n default: 'codegen',\n },\n test: {\n type: 'boolean',\n describe: 'Verify that the generated output is unchanged',\n default: false,\n },\n namespace: {\n type: 'string',\n describe: 'C++/C# Namespace to put generated native modules in',\n default: 'MyNamespace',\n },\n libraryName: {\n type: 'string',\n required: true,\n describe: 'Used for part of the path generated within the codegen dir',\n },\n}).argv;\n\nif ((argv.file && argv.files) || (!argv.file && !argv.files)) {\n console.error('You must specify either --file or --files.');\n process.exit(1);\n}\n\nrunCodeGen(argv);\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NativeModuleObjectTypeAnnotation } from 'react-native-tscodegen';
7
+ import { AliasMap } from './AliasManaging';
8
+ export declare function createAliasMap(nativeModuleAliases: {
9
+ [name: string]: NativeModuleObjectTypeAnnotation;
10
+ }): AliasMap;
11
+ export declare function generateAliases(aliases: AliasMap): string;
@@ -0,0 +1,72 @@
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.generateAliases = exports.createAliasMap = void 0;
9
+ const AliasManaging_1 = require("./AliasManaging");
10
+ const ObjectTypes_1 = require("./ObjectTypes");
11
+ function translateObjectBody(type, aliases, baseAliasName, prefix) {
12
+ return type.properties
13
+ .map((prop) => {
14
+ let propType = prop.typeAnnotation;
15
+ if (prop.optional && propType.type !== 'NullableTypeAnnotation') {
16
+ propType = { type: 'NullableTypeAnnotation', typeAnnotation: propType };
17
+ }
18
+ const first = `${prefix}REACT_FIELD(${prop.name})`;
19
+ const second = `${prefix}${(0, ObjectTypes_1.translateField)(propType, aliases, `${baseAliasName}_${prop.name}`)} ${prop.name};`;
20
+ return `${first}\n${second}`;
21
+ })
22
+ .join('\n');
23
+ }
24
+ function createAliasMap(nativeModuleAliases) {
25
+ const aliases = { types: {}, jobs: Object.keys(nativeModuleAliases) };
26
+ for (const aliasName of aliases.jobs) {
27
+ aliases.types[aliasName] = nativeModuleAliases[aliasName];
28
+ }
29
+ return aliases;
30
+ }
31
+ exports.createAliasMap = createAliasMap;
32
+ function generateSingleAlias(aliases, aliasName, aliasCode) {
33
+ const aliasType = aliases.types[aliasName];
34
+ aliasCode[aliasName] = `
35
+ REACT_STRUCT(${(0, AliasManaging_1.getAliasCppName)(aliasName)})
36
+ struct ${(0, AliasManaging_1.getAliasCppName)(aliasName)} {
37
+ ${translateObjectBody(aliasType, aliases, aliasName, ' ')}
38
+ };
39
+ `;
40
+ }
41
+ function generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder) {
42
+ // retrieve and clean all ungenerated aliases
43
+ const jobs = aliases.jobs;
44
+ aliases.jobs = [];
45
+ // generate each one in its found order
46
+ for (const aliasName of jobs) {
47
+ // generate a new struct and all fields will be examined
48
+ // new anonymous objects could be found
49
+ // they will be stored in aliases.jobs
50
+ generateSingleAlias(aliases, aliasName, aliasCode);
51
+ // nested C++ structs must be put before the current C++ struct
52
+ // as they will be used in the current C++ struct
53
+ // the order will be perfectly and easily ensured by doing this recursively
54
+ generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder);
55
+ // all referenced C++ structs are generated
56
+ // put the current one following them
57
+ aliasOrder.push(aliasName);
58
+ }
59
+ }
60
+ function generateAliases(aliases) {
61
+ const aliasCode = {};
62
+ const aliasOrder = [];
63
+ generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder);
64
+ // aliasOrder now has the correct order of C++ struct code
65
+ let traversedAliasedStructs = '';
66
+ for (const aliasName of aliasOrder) {
67
+ traversedAliasedStructs = `${traversedAliasedStructs}${aliasCode[aliasName]}`;
68
+ }
69
+ return traversedAliasedStructs;
70
+ }
71
+ exports.generateAliases = generateAliases;
72
+ //# sourceMappingURL=AliasGen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AliasGen.js","sourceRoot":"","sources":["../../src/generators/AliasGen.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n'use strict';\n\nimport type {\n NativeModuleBaseTypeAnnotation,\n NativeModuleObjectTypeAnnotation,\n NamedShape,\n Nullable,\n} from 'react-native-tscodegen';\nimport {AliasMap, getAliasCppName} from './AliasManaging';\nimport {translateField} from './ObjectTypes';\n\nfunction translateObjectBody(\n type: NativeModuleObjectTypeAnnotation,\n aliases: AliasMap,\n baseAliasName: string,\n prefix: string,\n) {\n return type.properties\n .map((prop: NamedShape<Nullable<NativeModuleBaseTypeAnnotation>>) => {\n let propType = prop.typeAnnotation;\n if (prop.optional && propType.type !== 'NullableTypeAnnotation') {\n propType = {type: 'NullableTypeAnnotation', typeAnnotation: propType};\n }\n const first = `${prefix}REACT_FIELD(${prop.name})`;\n const second = `${prefix}${translateField(\n propType,\n aliases,\n `${baseAliasName}_${prop.name}`,\n )} ${prop.name};`;\n return `${first}\\n${second}`;\n })\n .join('\\n');\n}\n\nexport function createAliasMap(nativeModuleAliases: {\n [name: string]: NativeModuleObjectTypeAnnotation;\n}): AliasMap {\n const aliases: AliasMap = {types: {}, jobs: Object.keys(nativeModuleAliases)};\n for (const aliasName of aliases.jobs) {\n aliases.types[aliasName] = nativeModuleAliases[aliasName];\n }\n return aliases;\n}\n\ninterface AliasCodeMap {\n [name: string]: string;\n}\n\nfunction generateSingleAlias(\n aliases: AliasMap,\n aliasName: string,\n aliasCode: AliasCodeMap,\n): void {\n const aliasType = <NativeModuleObjectTypeAnnotation>aliases.types[aliasName];\n aliasCode[aliasName] = `\nREACT_STRUCT(${getAliasCppName(aliasName)})\nstruct ${getAliasCppName(aliasName)} {\n${translateObjectBody(aliasType, aliases, aliasName, ' ')}\n};\n`;\n}\n\nfunction generateNestedAliasesInCorrectOrder(\n aliases: AliasMap,\n aliasCode: AliasCodeMap,\n aliasOrder: string[],\n): void {\n // retrieve and clean all ungenerated aliases\n const jobs = aliases.jobs;\n aliases.jobs = [];\n\n // generate each one in its found order\n for (const aliasName of jobs) {\n // generate a new struct and all fields will be examined\n // new anonymous objects could be found\n // they will be stored in aliases.jobs\n generateSingleAlias(aliases, aliasName, aliasCode);\n // nested C++ structs must be put before the current C++ struct\n // as they will be used in the current C++ struct\n // the order will be perfectly and easily ensured by doing this recursively\n generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder);\n // all referenced C++ structs are generated\n // put the current one following them\n aliasOrder.push(aliasName);\n }\n}\n\nexport function generateAliases(aliases: AliasMap): string {\n const aliasCode: AliasCodeMap = {};\n const aliasOrder: string[] = [];\n generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder);\n\n // aliasOrder now has the correct order of C++ struct code\n let traversedAliasedStructs = '';\n for (const aliasName of aliasOrder) {\n traversedAliasedStructs = `${traversedAliasedStructs}${aliasCode[aliasName]}`;\n }\n return traversedAliasedStructs;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { NativeModuleObjectTypeAnnotation } from 'react-native-tscodegen';
7
+ export declare function setPreferredModuleName(moduleName: string): void;
8
+ export declare function getAliasCppName(typeName: string): string;
9
+ export interface AliasMap {
10
+ types: {
11
+ [name: string]: NativeModuleObjectTypeAnnotation | undefined;
12
+ };
13
+ jobs: string[];
14
+ }
15
+ export declare function getAnonymousAliasCppName(aliases: AliasMap, baseAliasName: string, objectType: NativeModuleObjectTypeAnnotation): string;
@@ -0,0 +1,49 @@
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.getAnonymousAliasCppName = exports.getAliasCppName = exports.setPreferredModuleName = void 0;
9
+ let preferredModuleName = '';
10
+ function setPreferredModuleName(moduleName) {
11
+ preferredModuleName = moduleName;
12
+ }
13
+ exports.setPreferredModuleName = setPreferredModuleName;
14
+ function getAliasCppName(typeName) {
15
+ return `${preferredModuleName}Spec_${typeName}`;
16
+ }
17
+ exports.getAliasCppName = getAliasCppName;
18
+ const ExtendedObjectKey = '$RNW-TURBOMODULE-ALIAS';
19
+ function recordAnonymouseAlias(aliases, baseAliasName, extended) {
20
+ extended[ExtendedObjectKey] = baseAliasName;
21
+ aliases.types[baseAliasName] = extended;
22
+ aliases.jobs.push(baseAliasName);
23
+ return baseAliasName;
24
+ }
25
+ function getAnonymousAliasCppName(aliases, baseAliasName, objectType) {
26
+ // someone found an anonymous object literal type
27
+ // if the ExtendedObjectKey flag has been set
28
+ // then it is a known one
29
+ // this happens because method signatures are generate twice in spec and error messages
30
+ const extended = objectType;
31
+ const key = extended[ExtendedObjectKey];
32
+ if (key !== undefined) {
33
+ return getAliasCppName(key);
34
+ }
35
+ // if the ExtendedObjectKey flag has not been set
36
+ // it means it is a unknown one
37
+ // associate the name with this object literal type and return
38
+ if (aliases.types[baseAliasName] === undefined) {
39
+ return getAliasCppName(recordAnonymouseAlias(aliases, baseAliasName, extended));
40
+ }
41
+ // sometimes names could be anonymous
42
+ let index = 2;
43
+ while (aliases.types[`${baseAliasName}${index}`] !== undefined) {
44
+ index++;
45
+ }
46
+ return getAliasCppName(recordAnonymouseAlias(aliases, `${baseAliasName}${index}`, extended));
47
+ }
48
+ exports.getAnonymousAliasCppName = getAnonymousAliasCppName;
49
+ //# sourceMappingURL=AliasManaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AliasManaging.js","sourceRoot":"","sources":["../../src/generators/AliasManaging.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,CAAC;;;AAIb,IAAI,mBAAmB,GAAW,EAAE,CAAC;AAErC,SAAgB,sBAAsB,CAAC,UAAkB;IACvD,mBAAmB,GAAG,UAAU,CAAC;AACnC,CAAC;AAFD,wDAEC;AAED,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,GAAG,mBAAmB,QAAQ,QAAQ,EAAE,CAAC;AAClD,CAAC;AAFD,0CAEC;AAOD,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAKnD,SAAS,qBAAqB,CAC5B,OAAiB,EACjB,aAAqB,EACrB,QAAwB;IAExB,QAAQ,CAAC,iBAAiB,CAAC,GAAG,aAAa,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAgB,wBAAwB,CACtC,OAAiB,EACjB,aAAqB,EACrB,UAA4C;IAE5C,iDAAiD;IACjD,6CAA6C;IAC7C,yBAAyB;IACzB,uFAAuF;IACvF,MAAM,QAAQ,GAAmB,UAAU,CAAC;IAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACxC,IAAI,GAAG,KAAK,SAAS,EAAE;QACrB,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;KAC7B;IAED,iDAAiD;IACjD,+BAA+B;IAC/B,8DAA8D;IAC9D,IAAI,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,SAAS,EAAE;QAC9C,OAAO,eAAe,CACpB,qBAAqB,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,CACxD,CAAC;KACH;IAED,qCAAqC;IACrC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,aAAa,GAAG,KAAK,EAAE,CAAC,KAAK,SAAS,EAAE;QAC9D,KAAK,EAAE,CAAC;KACT;IAED,OAAO,eAAe,CACpB,qBAAqB,CAAC,OAAO,EAAE,GAAG,aAAa,GAAG,KAAK,EAAE,EAAE,QAAQ,CAAC,CACrE,CAAC;AACJ,CAAC;AAjCD,4DAiCC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n'use strict';\n\nimport type {NativeModuleObjectTypeAnnotation} from 'react-native-tscodegen';\n\nlet preferredModuleName: string = '';\n\nexport function setPreferredModuleName(moduleName: string): void {\n preferredModuleName = moduleName;\n}\n\nexport function getAliasCppName(typeName: string): string {\n return `${preferredModuleName}Spec_${typeName}`;\n}\n\nexport interface AliasMap {\n types: {[name: string]: NativeModuleObjectTypeAnnotation | undefined};\n jobs: string[];\n}\n\nconst ExtendedObjectKey = '$RNW-TURBOMODULE-ALIAS';\ninterface ExtendedObject extends NativeModuleObjectTypeAnnotation {\n '$RNW-TURBOMODULE-ALIAS'?: string;\n}\n\nfunction recordAnonymouseAlias(\n aliases: AliasMap,\n baseAliasName: string,\n extended: ExtendedObject,\n): string {\n extended[ExtendedObjectKey] = baseAliasName;\n aliases.types[baseAliasName] = extended;\n aliases.jobs.push(baseAliasName);\n return baseAliasName;\n}\n\nexport function getAnonymousAliasCppName(\n aliases: AliasMap,\n baseAliasName: string,\n objectType: NativeModuleObjectTypeAnnotation,\n): string {\n // someone found an anonymous object literal type\n // if the ExtendedObjectKey flag has been set\n // then it is a known one\n // this happens because method signatures are generate twice in spec and error messages\n const extended = <ExtendedObject>objectType;\n const key = extended[ExtendedObjectKey];\n if (key !== undefined) {\n return getAliasCppName(key);\n }\n\n // if the ExtendedObjectKey flag has not been set\n // it means it is a unknown one\n // associate the name with this object literal type and return\n if (aliases.types[baseAliasName] === undefined) {\n return getAliasCppName(\n recordAnonymouseAlias(aliases, baseAliasName, extended),\n );\n }\n\n // sometimes names could be anonymous\n let index = 2;\n while (aliases.types[`${baseAliasName}${index}`] !== undefined) {\n index++;\n }\n\n return getAliasCppName(\n recordAnonymouseAlias(aliases, `${baseAliasName}${index}`, extended),\n );\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { SchemaType } from 'react-native-tscodegen';
7
+ declare type FilesOutput = Map<string, string>;
8
+ export declare function createNM2Generator({ namespace, methodonly, }: {
9
+ namespace: string;
10
+ methodonly: boolean;
11
+ }): (_libraryName: string, schema: SchemaType, _moduleSpecName: string) => FilesOutput;
12
+ export {};