@react-native-windows/codegen 0.73.1 → 0.74.0
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.
- package/CHANGELOG.md +104 -14
- package/lib-commonjs/Cli.d.ts +7 -7
- package/lib-commonjs/Cli.js +91 -91
- package/lib-commonjs/generators/AliasGen.d.ts +12 -12
- package/lib-commonjs/generators/AliasGen.js +76 -76
- package/lib-commonjs/generators/AliasManaging.d.ts +15 -15
- package/lib-commonjs/generators/AliasManaging.js +48 -48
- package/lib-commonjs/generators/GenerateNM2.d.ts +15 -15
- package/lib-commonjs/generators/GenerateNM2.js +80 -80
- package/lib-commonjs/generators/GenerateTypeScript.d.ts +11 -11
- package/lib-commonjs/generators/GenerateTypeScript.js +145 -145
- package/lib-commonjs/generators/ObjectTypes.d.ts +13 -13
- package/lib-commonjs/generators/ObjectTypes.js +74 -74
- package/lib-commonjs/generators/ParamTypes.d.ts +12 -12
- package/lib-commonjs/generators/ParamTypes.js +136 -136
- package/lib-commonjs/generators/ReturnTypes.d.ts +10 -10
- package/lib-commonjs/generators/ReturnTypes.js +28 -28
- package/lib-commonjs/generators/ValidateConstants.d.ts +8 -8
- package/lib-commonjs/generators/ValidateConstants.js +33 -33
- package/lib-commonjs/generators/ValidateMethods.d.ts +9 -9
- package/lib-commonjs/generators/ValidateMethods.js +71 -71
- package/lib-commonjs/index.d.ts +37 -37
- package/lib-commonjs/index.js +223 -223
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,35 +1,125 @@
|
|
|
1
1
|
# Change Log - @react-native-windows/codegen
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 27 Apr 2024 21:15:11 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.
|
|
7
|
+
## 0.74.0
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Sat, 27 Apr 2024 21:15:11 GMT
|
|
10
10
|
|
|
11
11
|
### Patches
|
|
12
12
|
|
|
13
|
-
- Promote 0.
|
|
14
|
-
- Bump @react-native-windows/fs to v0.
|
|
13
|
+
- Promote 0.74 to latest (tatianakapos@microsoft.com)
|
|
14
|
+
- Bump @react-native-windows/fs to v0.74.0
|
|
15
15
|
|
|
16
|
-
## 0.
|
|
16
|
+
## 0.74.0-preview.1
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Mon, 08 Apr 2024 15:16:48 GMT
|
|
19
19
|
|
|
20
|
-
###
|
|
20
|
+
### Changes
|
|
21
|
+
|
|
22
|
+
- Promote 0.74 to preview (tatianakapos@microsoft.com)
|
|
23
|
+
- Bump @react-native-windows/fs to v0.74.0-preview.1
|
|
24
|
+
|
|
25
|
+
## 0.0.0-canary.81
|
|
26
|
+
|
|
27
|
+
Sat, 23 Mar 2024 05:17:01 GMT
|
|
28
|
+
|
|
29
|
+
### Changes
|
|
30
|
+
|
|
31
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.38
|
|
32
|
+
- Bump @rnw-scripts/eslint-config to v1.2.9
|
|
33
|
+
- Bump @rnw-scripts/just-task to v2.3.25
|
|
34
|
+
|
|
35
|
+
## 0.0.0-canary.80
|
|
36
|
+
|
|
37
|
+
Thu, 07 Mar 2024 06:16:47 GMT
|
|
38
|
+
|
|
39
|
+
### Changes
|
|
40
|
+
|
|
41
|
+
- Integrate 1/26 (34109996+chiaramooney@users.noreply.github.com)
|
|
42
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.37
|
|
43
|
+
- Bump @rnw-scripts/eslint-config to v1.2.8
|
|
44
|
+
- Bump @rnw-scripts/just-task to v2.3.24
|
|
45
|
+
|
|
46
|
+
## 0.0.0-canary.79
|
|
47
|
+
|
|
48
|
+
Fri, 01 Mar 2024 06:18:16 GMT
|
|
49
|
+
|
|
50
|
+
### Changes
|
|
51
|
+
|
|
52
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.36
|
|
53
|
+
- Bump @rnw-scripts/eslint-config to v1.2.7
|
|
54
|
+
- Bump @rnw-scripts/just-task to v2.3.23
|
|
55
|
+
|
|
56
|
+
## 0.0.0-canary.78
|
|
57
|
+
|
|
58
|
+
Tue, 27 Feb 2024 06:17:59 GMT
|
|
59
|
+
|
|
60
|
+
### Changes
|
|
61
|
+
|
|
62
|
+
- Update rn-integrate script to more aggressively update align dependencies (30809111+acoates-ms@users.noreply.github.com)
|
|
63
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.35
|
|
64
|
+
- Bump @rnw-scripts/eslint-config to v1.2.6
|
|
65
|
+
- Bump @rnw-scripts/jest-unittest-config to v1.5.8
|
|
66
|
+
- Bump @rnw-scripts/just-task to v2.3.22
|
|
67
|
+
|
|
68
|
+
## 0.0.0-canary.77
|
|
69
|
+
|
|
70
|
+
Sat, 24 Feb 2024 06:17:16 GMT
|
|
71
|
+
|
|
72
|
+
### Changes
|
|
73
|
+
|
|
74
|
+
- Migrate src directory to src-win (34109996+chiaramooney@users.noreply.github.com)
|
|
75
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.34
|
|
76
|
+
- Bump @rnw-scripts/just-task to v2.3.21
|
|
77
|
+
|
|
78
|
+
## 0.0.0-canary.76
|
|
79
|
+
|
|
80
|
+
Thu, 15 Feb 2024 06:18:15 GMT
|
|
81
|
+
|
|
82
|
+
### Changes
|
|
83
|
+
|
|
84
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.33
|
|
85
|
+
- Bump @rnw-scripts/just-task to v2.3.20
|
|
86
|
+
|
|
87
|
+
## 0.0.0-canary.75
|
|
88
|
+
|
|
89
|
+
Wed, 14 Feb 2024 06:16:55 GMT
|
|
90
|
+
|
|
91
|
+
### Changes
|
|
92
|
+
|
|
93
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.32
|
|
94
|
+
- Bump @rnw-scripts/eslint-config to v1.2.5
|
|
95
|
+
- Bump @rnw-scripts/jest-unittest-config to v1.5.7
|
|
96
|
+
- Bump @rnw-scripts/just-task to v2.3.19
|
|
97
|
+
|
|
98
|
+
## 0.0.0-canary.74
|
|
99
|
+
|
|
100
|
+
Fri, 09 Feb 2024 21:11:18 GMT
|
|
101
|
+
|
|
102
|
+
### Changes
|
|
103
|
+
|
|
104
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.31
|
|
105
|
+
|
|
106
|
+
## 0.0.0-canary.73
|
|
107
|
+
|
|
108
|
+
Thu, 08 Feb 2024 06:13:52 GMT
|
|
109
|
+
|
|
110
|
+
### Changes
|
|
21
111
|
|
|
22
|
-
-
|
|
23
|
-
- Bump @react-native-windows/fs to v0.73.0
|
|
112
|
+
- Integration up to 01/02/24 (email not defined)
|
|
24
113
|
|
|
25
|
-
## 0.
|
|
114
|
+
## 0.0.0-canary.72
|
|
26
115
|
|
|
27
|
-
|
|
116
|
+
Sat, 21 Oct 2023 05:16:09 GMT
|
|
28
117
|
|
|
29
118
|
### Changes
|
|
30
119
|
|
|
31
|
-
-
|
|
32
|
-
- Bump @
|
|
120
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.30
|
|
121
|
+
- Bump @rnw-scripts/eslint-config to v1.2.4
|
|
122
|
+
- Bump @rnw-scripts/just-task to v2.3.18
|
|
33
123
|
|
|
34
124
|
## 0.0.0-canary.71
|
|
35
125
|
|
package/lib-commonjs/Cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
package/lib-commonjs/Cli.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
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
|
-
modulesTypeScriptTypes: {
|
|
25
|
-
type: 'boolean',
|
|
26
|
-
describe: 'generate turbo module definition files in TypeScript',
|
|
27
|
-
default: false,
|
|
28
|
-
},
|
|
29
|
-
modulesCxx: {
|
|
30
|
-
type: 'boolean',
|
|
31
|
-
describe: 'generate C++ JSI turbo module spec files',
|
|
32
|
-
default: false,
|
|
33
|
-
},
|
|
34
|
-
modulesWindows: {
|
|
35
|
-
type: 'boolean',
|
|
36
|
-
describe: 'generate turbo module spec files for REACT_MODULE',
|
|
37
|
-
default: false,
|
|
38
|
-
},
|
|
39
|
-
methodOnly: {
|
|
40
|
-
type: 'boolean',
|
|
41
|
-
describe: 'generate only method metadata in C++ turbo module spec',
|
|
42
|
-
default: false,
|
|
43
|
-
},
|
|
44
|
-
outputDirectory: {
|
|
45
|
-
type: 'string',
|
|
46
|
-
describe: 'output directory',
|
|
47
|
-
default: 'codegen',
|
|
48
|
-
},
|
|
49
|
-
test: {
|
|
50
|
-
type: 'boolean',
|
|
51
|
-
describe: 'Verify that the generated output is unchanged',
|
|
52
|
-
default: false,
|
|
53
|
-
},
|
|
54
|
-
namespace: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
describe: 'C++/C# Namespace to put generated native modules in',
|
|
57
|
-
default: 'MyNamespace',
|
|
58
|
-
},
|
|
59
|
-
libraryName: {
|
|
60
|
-
type: 'string',
|
|
61
|
-
required: true,
|
|
62
|
-
describe: 'Used for part of the path generated within the codegen dir',
|
|
63
|
-
},
|
|
64
|
-
cppStringType: {
|
|
65
|
-
choices: ['std::string', 'std::wstring'],
|
|
66
|
-
describe: 'C++ string type in generated code, should be "std::string" or "std::wstring"',
|
|
67
|
-
default: 'std::string',
|
|
68
|
-
},
|
|
69
|
-
separateDataTypes: {
|
|
70
|
-
type: 'boolean',
|
|
71
|
-
describe: 'generate data types in a separate file',
|
|
72
|
-
default: false,
|
|
73
|
-
},
|
|
74
|
-
}).argv;
|
|
75
|
-
if ((argv.file && argv.files) || (!argv.file && !argv.files)) {
|
|
76
|
-
console.error('You must specify either --file or --files.');
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
if (argv.cppStringType !== 'std::string' &&
|
|
80
|
-
argv.cppStringType !== 'std::wstring') {
|
|
81
|
-
console.error('cppStringType should be "std::string" or "std::wstring".');
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
// type casting is necessary here because
|
|
85
|
-
// cppStringType does not become union of string literals
|
|
86
|
-
// until yargs.options get improved in the future
|
|
87
|
-
const changesNecessary = (0, index_1.runCodeGen)(argv);
|
|
88
|
-
if (argv.test && changesNecessary) {
|
|
89
|
-
console.error('There is a change in the output of codegen. Rerun "react-native codegen-windows" to regenerate.');
|
|
90
|
-
process.exit(2);
|
|
91
|
-
}
|
|
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
|
+
modulesTypeScriptTypes: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
describe: 'generate turbo module definition files in TypeScript',
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
modulesCxx: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
describe: 'generate C++ JSI turbo module spec files',
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
modulesWindows: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
describe: 'generate turbo module spec files for REACT_MODULE',
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
methodOnly: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
describe: 'generate only method metadata in C++ turbo module spec',
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
outputDirectory: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
describe: 'output directory',
|
|
47
|
+
default: 'codegen',
|
|
48
|
+
},
|
|
49
|
+
test: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
describe: 'Verify that the generated output is unchanged',
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
namespace: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
describe: 'C++/C# Namespace to put generated native modules in',
|
|
57
|
+
default: 'MyNamespace',
|
|
58
|
+
},
|
|
59
|
+
libraryName: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
required: true,
|
|
62
|
+
describe: 'Used for part of the path generated within the codegen dir',
|
|
63
|
+
},
|
|
64
|
+
cppStringType: {
|
|
65
|
+
choices: ['std::string', 'std::wstring'],
|
|
66
|
+
describe: 'C++ string type in generated code, should be "std::string" or "std::wstring"',
|
|
67
|
+
default: 'std::string',
|
|
68
|
+
},
|
|
69
|
+
separateDataTypes: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
describe: 'generate data types in a separate file',
|
|
72
|
+
default: false,
|
|
73
|
+
},
|
|
74
|
+
}).argv;
|
|
75
|
+
if ((argv.file && argv.files) || (!argv.file && !argv.files)) {
|
|
76
|
+
console.error('You must specify either --file or --files.');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
if (argv.cppStringType !== 'std::string' &&
|
|
80
|
+
argv.cppStringType !== 'std::wstring') {
|
|
81
|
+
console.error('cppStringType should be "std::string" or "std::wstring".');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
// type casting is necessary here because
|
|
85
|
+
// cppStringType does not become union of string literals
|
|
86
|
+
// until yargs.options get improved in the future
|
|
87
|
+
const changesNecessary = (0, index_1.runCodeGen)(argv);
|
|
88
|
+
if (argv.test && changesNecessary) {
|
|
89
|
+
console.error('There is a change in the output of codegen. Rerun "react-native codegen-windows" to regenerate.');
|
|
90
|
+
process.exit(2);
|
|
91
|
+
}
|
|
92
92
|
//# sourceMappingURL=Cli.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import type { NativeModuleObjectTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';
|
|
7
|
-
import { AliasMap } from './AliasManaging';
|
|
8
|
-
import { CppCodegenOptions } from './ObjectTypes';
|
|
9
|
-
export declare function createAliasMap(nativeModuleAliases: {
|
|
10
|
-
[name: string]: NativeModuleObjectTypeAnnotation;
|
|
11
|
-
}): AliasMap;
|
|
12
|
-
export declare function generateAliases(aliases: AliasMap, options: CppCodegenOptions): [string, string];
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import type { NativeModuleObjectTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';
|
|
7
|
+
import { AliasMap } from './AliasManaging';
|
|
8
|
+
import { CppCodegenOptions } from './ObjectTypes';
|
|
9
|
+
export declare function createAliasMap(nativeModuleAliases: {
|
|
10
|
+
[name: string]: NativeModuleObjectTypeAnnotation;
|
|
11
|
+
}): AliasMap;
|
|
12
|
+
export declare function generateAliases(aliases: AliasMap, options: CppCodegenOptions): [string, string];
|
|
@@ -1,47 +1,47 @@
|
|
|
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 translateObjectMembersDefinition(type, aliases, baseAliasName, prefix, options) {
|
|
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
|
-
return `${prefix}${(0, ObjectTypes_1.translateField)(propType, aliases, `${baseAliasName}_${prop.name}`, options)} ${prop.name};`;
|
|
19
|
-
})
|
|
20
|
-
.join('\n');
|
|
21
|
-
}
|
|
22
|
-
function translateObjectMembersReflection(type, aliasCppName, prefix) {
|
|
23
|
-
return type.properties
|
|
24
|
-
.map((prop) => {
|
|
25
|
-
return `${prefix}{L"${prop.name}", &${aliasCppName}::${prop.name}},`;
|
|
26
|
-
})
|
|
27
|
-
.join('\n');
|
|
28
|
-
}
|
|
29
|
-
function createAliasMap(nativeModuleAliases) {
|
|
30
|
-
const aliases = { types: {}, jobs: Object.keys(nativeModuleAliases) };
|
|
31
|
-
for (const aliasName of aliases.jobs) {
|
|
32
|
-
aliases.types[aliasName] = nativeModuleAliases[aliasName];
|
|
33
|
-
}
|
|
34
|
-
return aliases;
|
|
35
|
-
}
|
|
36
|
-
exports.createAliasMap = createAliasMap;
|
|
37
|
-
function generateSingleAlias(aliases, aliasName, aliasCode, options) {
|
|
38
|
-
const aliasCppName = (0, AliasManaging_1.getAliasCppName)(aliasName);
|
|
39
|
-
const aliasType = aliases.types[aliasName];
|
|
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 translateObjectMembersDefinition(type, aliases, baseAliasName, prefix, options) {
|
|
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
|
+
return `${prefix}${(0, ObjectTypes_1.translateField)(propType, aliases, `${baseAliasName}_${prop.name}`, options)} ${prop.name};`;
|
|
19
|
+
})
|
|
20
|
+
.join('\n');
|
|
21
|
+
}
|
|
22
|
+
function translateObjectMembersReflection(type, aliasCppName, prefix) {
|
|
23
|
+
return type.properties
|
|
24
|
+
.map((prop) => {
|
|
25
|
+
return `${prefix}{L"${prop.name}", &${aliasCppName}::${prop.name}},`;
|
|
26
|
+
})
|
|
27
|
+
.join('\n');
|
|
28
|
+
}
|
|
29
|
+
function createAliasMap(nativeModuleAliases) {
|
|
30
|
+
const aliases = { types: {}, jobs: Object.keys(nativeModuleAliases) };
|
|
31
|
+
for (const aliasName of aliases.jobs) {
|
|
32
|
+
aliases.types[aliasName] = nativeModuleAliases[aliasName];
|
|
33
|
+
}
|
|
34
|
+
return aliases;
|
|
35
|
+
}
|
|
36
|
+
exports.createAliasMap = createAliasMap;
|
|
37
|
+
function generateSingleAlias(aliases, aliasName, aliasCode, options) {
|
|
38
|
+
const aliasCppName = (0, AliasManaging_1.getAliasCppName)(aliasName);
|
|
39
|
+
const aliasType = aliases.types[aliasName];
|
|
40
40
|
const definition = `
|
|
41
41
|
struct ${aliasCppName} {
|
|
42
42
|
${translateObjectMembersDefinition(aliasType, aliases, aliasName, ' ', options)}
|
|
43
43
|
};
|
|
44
|
-
`;
|
|
44
|
+
`;
|
|
45
45
|
const reflection = `
|
|
46
46
|
inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(${aliasCppName}*) noexcept {
|
|
47
47
|
winrt::Microsoft::ReactNative::FieldMap fieldMap {
|
|
@@ -49,40 +49,40 @@ ${translateObjectMembersReflection(aliasType, aliasCppName, ' ')}
|
|
|
49
49
|
};
|
|
50
50
|
return fieldMap;
|
|
51
51
|
}
|
|
52
|
-
`;
|
|
53
|
-
aliasCode[aliasName] = { definition, reflection };
|
|
54
|
-
}
|
|
55
|
-
function generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options) {
|
|
56
|
-
// retrieve and clean all ungenerated aliases
|
|
57
|
-
const jobs = aliases.jobs;
|
|
58
|
-
aliases.jobs = [];
|
|
59
|
-
// generate each one in its found order
|
|
60
|
-
for (const aliasName of jobs) {
|
|
61
|
-
// generate a new struct and all fields will be examined
|
|
62
|
-
// new anonymous objects could be found
|
|
63
|
-
// they will be stored in aliases.jobs
|
|
64
|
-
generateSingleAlias(aliases, aliasName, aliasCode, options);
|
|
65
|
-
// nested C++ structs must be put before the current C++ struct
|
|
66
|
-
// as they will be used in the current C++ struct
|
|
67
|
-
// the order will be perfectly and easily ensured by doing this recursively
|
|
68
|
-
generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options);
|
|
69
|
-
// all referenced C++ structs are generated
|
|
70
|
-
// put the current one following them
|
|
71
|
-
aliasOrder.push(aliasName);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function generateAliases(aliases, options) {
|
|
75
|
-
const aliasCode = {};
|
|
76
|
-
const aliasOrder = [];
|
|
77
|
-
generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options);
|
|
78
|
-
// aliasOrder now has the correct order of C++ struct code
|
|
79
|
-
let customTypes = '';
|
|
80
|
-
let customReflection = '';
|
|
81
|
-
for (const aliasName of aliasOrder) {
|
|
82
|
-
customTypes = `${customTypes}${aliasCode[aliasName].definition}`;
|
|
83
|
-
customReflection = `${customReflection}${aliasCode[aliasName].reflection}`;
|
|
84
|
-
}
|
|
85
|
-
return [customTypes, customReflection];
|
|
86
|
-
}
|
|
87
|
-
exports.generateAliases = generateAliases;
|
|
52
|
+
`;
|
|
53
|
+
aliasCode[aliasName] = { definition, reflection };
|
|
54
|
+
}
|
|
55
|
+
function generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options) {
|
|
56
|
+
// retrieve and clean all ungenerated aliases
|
|
57
|
+
const jobs = aliases.jobs;
|
|
58
|
+
aliases.jobs = [];
|
|
59
|
+
// generate each one in its found order
|
|
60
|
+
for (const aliasName of jobs) {
|
|
61
|
+
// generate a new struct and all fields will be examined
|
|
62
|
+
// new anonymous objects could be found
|
|
63
|
+
// they will be stored in aliases.jobs
|
|
64
|
+
generateSingleAlias(aliases, aliasName, aliasCode, options);
|
|
65
|
+
// nested C++ structs must be put before the current C++ struct
|
|
66
|
+
// as they will be used in the current C++ struct
|
|
67
|
+
// the order will be perfectly and easily ensured by doing this recursively
|
|
68
|
+
generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options);
|
|
69
|
+
// all referenced C++ structs are generated
|
|
70
|
+
// put the current one following them
|
|
71
|
+
aliasOrder.push(aliasName);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function generateAliases(aliases, options) {
|
|
75
|
+
const aliasCode = {};
|
|
76
|
+
const aliasOrder = [];
|
|
77
|
+
generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options);
|
|
78
|
+
// aliasOrder now has the correct order of C++ struct code
|
|
79
|
+
let customTypes = '';
|
|
80
|
+
let customReflection = '';
|
|
81
|
+
for (const aliasName of aliasOrder) {
|
|
82
|
+
customTypes = `${customTypes}${aliasCode[aliasName].definition}`;
|
|
83
|
+
customReflection = `${customReflection}${aliasCode[aliasName].reflection}`;
|
|
84
|
+
}
|
|
85
|
+
return [customTypes, customReflection];
|
|
86
|
+
}
|
|
87
|
+
exports.generateAliases = generateAliases;
|
|
88
88
|
//# sourceMappingURL=AliasGen.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import type { NativeModuleObjectTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';
|
|
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;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import type { NativeModuleObjectTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';
|
|
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;
|
|
@@ -1,49 +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 recordAnonymousAlias(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(recordAnonymousAlias(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(recordAnonymousAlias(aliases, `${baseAliasName}${index}`, extended));
|
|
47
|
-
}
|
|
48
|
-
exports.getAnonymousAliasCppName = getAnonymousAliasCppName;
|
|
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 recordAnonymousAlias(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(recordAnonymousAlias(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(recordAnonymousAlias(aliases, `${baseAliasName}${index}`, extended));
|
|
47
|
+
}
|
|
48
|
+
exports.getAnonymousAliasCppName = getAnonymousAliasCppName;
|
|
49
49
|
//# sourceMappingURL=AliasManaging.js.map
|