@react-native-windows/codegen 0.73.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,26 +1,116 @@
1
1
  # Change Log - @react-native-windows/codegen
2
2
 
3
- This log was last generated on Fri, 08 Dec 2023 00:25:03 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 08 Apr 2024 15:15:22 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.73.0
7
+ ## 0.74.0-preview.1
8
8
 
9
- Fri, 08 Dec 2023 00:25:03 GMT
9
+ Mon, 08 Apr 2024 15:15:22 GMT
10
10
 
11
- ### Patches
11
+ ### Changes
12
12
 
13
- - Promote 0.73 to latest (tatianakapos@microsoft.com)
14
- - Bump @react-native-windows/fs to v0.73.0
13
+ - Promote 0.74 to preview (tatianakapos@microsoft.com)
14
+ - Bump @react-native-windows/fs to v0.74.0-preview.1
15
15
 
16
- ## 0.73.0-preview.1
16
+ ## 0.0.0-canary.81
17
17
 
18
- Tue, 17 Oct 2023 22:26:52 GMT
18
+ Sat, 23 Mar 2024 05:17:01 GMT
19
19
 
20
20
  ### Changes
21
21
 
22
- - Promote 0.73 to preview (tatianakapos@microsoft.com)
23
- - Bump @react-native-windows/fs to v0.73.0-preview.1
22
+ - Bump @react-native-windows/fs to v0.0.0-canary.38
23
+ - Bump @rnw-scripts/eslint-config to v1.2.9
24
+ - Bump @rnw-scripts/just-task to v2.3.25
25
+
26
+ ## 0.0.0-canary.80
27
+
28
+ Thu, 07 Mar 2024 06:16:47 GMT
29
+
30
+ ### Changes
31
+
32
+ - Integrate 1/26 (34109996+chiaramooney@users.noreply.github.com)
33
+ - Bump @react-native-windows/fs to v0.0.0-canary.37
34
+ - Bump @rnw-scripts/eslint-config to v1.2.8
35
+ - Bump @rnw-scripts/just-task to v2.3.24
36
+
37
+ ## 0.0.0-canary.79
38
+
39
+ Fri, 01 Mar 2024 06:18:16 GMT
40
+
41
+ ### Changes
42
+
43
+ - Bump @react-native-windows/fs to v0.0.0-canary.36
44
+ - Bump @rnw-scripts/eslint-config to v1.2.7
45
+ - Bump @rnw-scripts/just-task to v2.3.23
46
+
47
+ ## 0.0.0-canary.78
48
+
49
+ Tue, 27 Feb 2024 06:17:59 GMT
50
+
51
+ ### Changes
52
+
53
+ - Update rn-integrate script to more aggressively update align dependencies (30809111+acoates-ms@users.noreply.github.com)
54
+ - Bump @react-native-windows/fs to v0.0.0-canary.35
55
+ - Bump @rnw-scripts/eslint-config to v1.2.6
56
+ - Bump @rnw-scripts/jest-unittest-config to v1.5.8
57
+ - Bump @rnw-scripts/just-task to v2.3.22
58
+
59
+ ## 0.0.0-canary.77
60
+
61
+ Sat, 24 Feb 2024 06:17:16 GMT
62
+
63
+ ### Changes
64
+
65
+ - Migrate src directory to src-win (34109996+chiaramooney@users.noreply.github.com)
66
+ - Bump @react-native-windows/fs to v0.0.0-canary.34
67
+ - Bump @rnw-scripts/just-task to v2.3.21
68
+
69
+ ## 0.0.0-canary.76
70
+
71
+ Thu, 15 Feb 2024 06:18:15 GMT
72
+
73
+ ### Changes
74
+
75
+ - Bump @react-native-windows/fs to v0.0.0-canary.33
76
+ - Bump @rnw-scripts/just-task to v2.3.20
77
+
78
+ ## 0.0.0-canary.75
79
+
80
+ Wed, 14 Feb 2024 06:16:55 GMT
81
+
82
+ ### Changes
83
+
84
+ - Bump @react-native-windows/fs to v0.0.0-canary.32
85
+ - Bump @rnw-scripts/eslint-config to v1.2.5
86
+ - Bump @rnw-scripts/jest-unittest-config to v1.5.7
87
+ - Bump @rnw-scripts/just-task to v2.3.19
88
+
89
+ ## 0.0.0-canary.74
90
+
91
+ Fri, 09 Feb 2024 21:11:18 GMT
92
+
93
+ ### Changes
94
+
95
+ - Bump @react-native-windows/fs to v0.0.0-canary.31
96
+
97
+ ## 0.0.0-canary.73
98
+
99
+ Thu, 08 Feb 2024 06:13:52 GMT
100
+
101
+ ### Changes
102
+
103
+ - Integration up to 01/02/24 (email not defined)
104
+
105
+ ## 0.0.0-canary.72
106
+
107
+ Sat, 21 Oct 2023 05:16:09 GMT
108
+
109
+ ### Changes
110
+
111
+ - Bump @react-native-windows/fs to v0.0.0-canary.30
112
+ - Bump @rnw-scripts/eslint-config to v1.2.4
113
+ - Bump @rnw-scripts/just-task to v2.3.18
24
114
 
25
115
  ## 0.0.0-canary.71
26
116
 
@@ -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 {};
@@ -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