@react-native-windows/codegen 0.0.0-canary.116 → 0.0.0-canary.117
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 +14 -6
- package/lib-commonjs/generators/ObjectTypes.d.ts +2 -2
- package/lib-commonjs/generators/ObjectTypes.js.map +1 -1
- package/lib-commonjs/generators/PropObjectTypes.js +4 -13
- package/lib-commonjs/generators/PropObjectTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/generators/ObjectTypes.ts +2 -2
- package/src/generators/PropObjectTypes.ts +4 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
# Change Log - @react-native-windows/codegen
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Thu, 23 Jan 2025 06:24:03 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.0.0-canary.
|
|
7
|
+
## 0.0.0-canary.117
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Thu, 23 Jan 2025 06:24:03 GMT
|
|
10
10
|
|
|
11
11
|
### Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
- Bump @rnw-scripts/eslint-config to v1.2.32
|
|
15
|
-
- Bump @rnw-scripts/just-task to v2.3.49
|
|
13
|
+
- Initial integrate (yajurgrover24@gmail.com)
|
|
16
14
|
|
|
15
|
+
## 0.0.0-canary.116
|
|
16
|
+
|
|
17
|
+
Sat, 11 Jan 2025 06:30:40 GMT
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
|
|
21
|
+
- Bump @react-native-windows/fs to v0.0.0-canary.61
|
|
22
|
+
- Bump @rnw-scripts/eslint-config to v1.2.32
|
|
23
|
+
- Bump @rnw-scripts/just-task to v2.3.49
|
|
24
|
+
|
|
17
25
|
## 0.0.0-canary.115
|
|
18
26
|
|
|
19
27
|
Fri, 10 Jan 2025 06:23:19 GMT
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
|
-
import type { NativeModuleBaseTypeAnnotation, NativeModuleStringTypeAnnotation, NativeModuleFunctionTypeAnnotation, NativeModuleStringLiteralTypeAnnotation,
|
|
6
|
+
import type { NativeModuleBaseTypeAnnotation, NativeModuleStringTypeAnnotation, NativeModuleFunctionTypeAnnotation, NativeModuleStringLiteralTypeAnnotation, StringLiteralUnionTypeAnnotation, UnsafeAnyTypeAnnotation, Nullable } from '@react-native/codegen/lib/CodegenSchema';
|
|
7
7
|
import { AliasMap } from './AliasManaging';
|
|
8
8
|
export type CppStringTypes = 'std::string' | 'std::wstring';
|
|
9
9
|
export interface CppCodegenOptions {
|
|
10
10
|
cppStringType: CppStringTypes;
|
|
11
11
|
}
|
|
12
|
-
export declare function translateFieldOrReturnType(type: Nullable<NativeModuleBaseTypeAnnotation | NativeModuleStringTypeAnnotation | NativeModuleFunctionTypeAnnotation | NativeModuleStringLiteralTypeAnnotation |
|
|
12
|
+
export declare function translateFieldOrReturnType(type: Nullable<NativeModuleBaseTypeAnnotation | NativeModuleStringTypeAnnotation | NativeModuleFunctionTypeAnnotation | NativeModuleStringLiteralTypeAnnotation | StringLiteralUnionTypeAnnotation> | UnsafeAnyTypeAnnotation, aliases: AliasMap, baseAliasName: string, callerName: 'translateField' | 'translateReturnType', options: CppCodegenOptions): string;
|
|
13
13
|
export declare function translateField(type: Nullable<NativeModuleBaseTypeAnnotation>, aliases: AliasMap, baseAliasName: string, options: CppCodegenOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTypes.js","sourceRoot":"","sources":["../../src/generators/ObjectTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,CAAC;;;AAab,mDAIyB;AAQzB,SAAS,wBAAwB,CAC/B,IAAmE,EACnE,OAA0B;IAE1B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wBAAwB,CAAC,CAAC;YAC7B,wDAAwD;YACxD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,UAAU;YACV,uEAAuE;YACvE,IAAI,IAAI,KAAK,SAAS;gBACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,OAAO,UAAU,EAAE,CAAC,CAAC;YACzE,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,yBAAyB;YAC5B,OAAO,IAAA,+BAAe,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,KAAK,wBAAwB;YAC3B,OAAO,iBAAiB,0BAA0B,CAChD,IAAI,CAAC,cAAc,EACnB,OAAO,EACP,aAAa,EACb,UAAU,EACV,OAAO,CACR,GAAG,CAAC;QACP,KAAK,wBAAwB,CAAC;QAC9B,KAAK,qBAAqB;YACxB,OAAO,EAAE,CAAC;QACZ,KAAK,iBAAiB,CAAC;QACvB,KAAK,qBAAqB;YACxB,OAAO,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjD,KAAK,mBAAmB;YACtB,OAAO,mBAAmB,CAAC;QAC7B;YACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,KAAK,UAAU,EAAE,CAAC,CAAC;KACrE;AACH,CAAC;AA5ED,gEA4EC;AAED,SAAgB,cAAc,CAC5B,IAA8C,EAC9C,OAAiB,EACjB,aAAqB,EACrB,OAA0B;IAE1B,OAAO,0BAA0B,CAC/B,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,OAAO,CACR,CAAC;AACJ,CAAC;AAbD,wCAaC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n'use strict';\n\nimport type {\n NativeModuleEnumDeclaration,\n NativeModuleBaseTypeAnnotation,\n NativeModuleUnionTypeAnnotation,\n NativeModuleStringTypeAnnotation,\n NativeModuleFunctionTypeAnnotation,\n NativeModuleStringLiteralTypeAnnotation,\n
|
|
1
|
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format\n */\n\n'use strict';\n\nimport type {\n NativeModuleEnumDeclaration,\n NativeModuleBaseTypeAnnotation,\n NativeModuleUnionTypeAnnotation,\n NativeModuleStringTypeAnnotation,\n NativeModuleFunctionTypeAnnotation,\n NativeModuleStringLiteralTypeAnnotation,\n StringLiteralUnionTypeAnnotation,\n UnsafeAnyTypeAnnotation,\n Nullable,\n} from '@react-native/codegen/lib/CodegenSchema';\nimport {\n AliasMap,\n getAliasCppName,\n getAnonymousAliasCppName,\n} from './AliasManaging';\n\nexport type CppStringTypes = 'std::string' | 'std::wstring';\n\nexport interface CppCodegenOptions {\n cppStringType: CppStringTypes;\n}\n\nfunction translateUnionReturnType(\n type: NativeModuleEnumDeclaration | NativeModuleUnionTypeAnnotation,\n options: CppCodegenOptions,\n): string {\n const memberType = type.memberType;\n switch (type.memberType) {\n case 'StringTypeAnnotation':\n return options.cppStringType;\n case 'NumberTypeAnnotation':\n return 'double';\n case 'ObjectTypeAnnotation':\n return '::React::JSValue';\n default:\n throw new Error(\n `Unknown enum/union member type in translateReturnType: ${memberType}`,\n );\n }\n}\n\n// eslint-disable-next-line complexity\nexport function translateFieldOrReturnType(\n type:\n | Nullable<\n | NativeModuleBaseTypeAnnotation\n | NativeModuleStringTypeAnnotation\n | NativeModuleFunctionTypeAnnotation\n | NativeModuleStringLiteralTypeAnnotation\n | StringLiteralUnionTypeAnnotation\n >\n | UnsafeAnyTypeAnnotation,\n aliases: AliasMap,\n baseAliasName: string,\n callerName: 'translateField' | 'translateReturnType',\n options: CppCodegenOptions,\n): string {\n // avoid: Property 'type' does not exist on type 'never'\n const returnType = type.type;\n switch (type.type) {\n case 'StringTypeAnnotation':\n case 'StringLiteralTypeAnnotation':\n case 'StringLiteralUnionTypeAnnotation':\n return options.cppStringType;\n case 'NumberTypeAnnotation':\n case 'FloatTypeAnnotation':\n case 'DoubleTypeAnnotation':\n return 'double';\n case 'Int32TypeAnnotation':\n return 'int';\n case 'BooleanTypeAnnotation':\n return 'bool';\n case 'ArrayTypeAnnotation':\n if (type.elementType.type !== 'AnyTypeAnnotation') {\n return `std::vector<${translateFieldOrReturnType(\n type.elementType,\n aliases,\n `${baseAliasName}_element`,\n callerName,\n options,\n )}>`;\n } else {\n return `::React::JSValueArray`;\n }\n case 'GenericObjectTypeAnnotation':\n return '::React::JSValue';\n case 'ObjectTypeAnnotation':\n return getAnonymousAliasCppName(aliases, baseAliasName, type);\n case 'ReservedTypeAnnotation': {\n // avoid: Property 'name' does not exist on type 'never'\n const name = type.name;\n // (#6597)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (name !== 'RootTag')\n throw new Error(`Unknown reserved function: ${name} in ${callerName}`);\n return 'double';\n }\n case 'TypeAliasTypeAnnotation':\n return getAliasCppName(type.name);\n case 'NullableTypeAnnotation':\n return `std::optional<${translateFieldOrReturnType(\n type.typeAnnotation,\n aliases,\n baseAliasName,\n callerName,\n options,\n )}>`;\n case 'FunctionTypeAnnotation':\n case 'MixedTypeAnnotation':\n return '';\n case 'EnumDeclaration':\n case 'UnionTypeAnnotation':\n return translateUnionReturnType(type, options);\n case 'AnyTypeAnnotation':\n return '::React::JSValue?';\n default:\n throw new Error(`Unhandled type in ${callerName}: ${returnType}`);\n }\n}\n\nexport function translateField(\n type: Nullable<NativeModuleBaseTypeAnnotation>,\n aliases: AliasMap,\n baseAliasName: string,\n options: CppCodegenOptions,\n): string {\n return translateFieldOrReturnType(\n type,\n aliases,\n baseAliasName,\n 'translateField',\n options,\n );\n}\n"]}
|
|
@@ -131,7 +131,7 @@ function translateComponentEventType(type, aliases, baseAliasName, options) {
|
|
|
131
131
|
case 'ObjectTypeAnnotation':
|
|
132
132
|
arrayTemplateArg = translateComponentEventType(type.elementType, aliases, baseAliasName, options).type;
|
|
133
133
|
break;
|
|
134
|
-
case '
|
|
134
|
+
case 'StringLiteralUnionTypeAnnotation':
|
|
135
135
|
arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string
|
|
136
136
|
break;
|
|
137
137
|
default:
|
|
@@ -145,7 +145,7 @@ function translateComponentEventType(type, aliases, baseAliasName, options) {
|
|
|
145
145
|
case 'MixedTypeAnnotation': {
|
|
146
146
|
return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };
|
|
147
147
|
}
|
|
148
|
-
case '
|
|
148
|
+
case 'StringLiteralUnionTypeAnnotation':
|
|
149
149
|
return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing a string
|
|
150
150
|
default:
|
|
151
151
|
throw new Error(`Unhandled type: ${type.type}`);
|
|
@@ -183,19 +183,10 @@ function translateCommandParamType(type, aliases, baseAliasName, options) {
|
|
|
183
183
|
case 'StringTypeAnnotation':
|
|
184
184
|
arrayTemplateArg = options.cppStringType;
|
|
185
185
|
break;
|
|
186
|
-
case '
|
|
187
|
-
|
|
188
|
-
arrayTemplateArg = `std::vector<${innerType.type}>`;
|
|
189
|
-
break;
|
|
190
|
-
case 'ReservedPropTypeAnnotation':
|
|
186
|
+
case 'MixedTypeAnnotation':
|
|
187
|
+
// TODO - not sure what exact value to be used here
|
|
191
188
|
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';
|
|
192
189
|
break;
|
|
193
|
-
case 'ObjectTypeAnnotation':
|
|
194
|
-
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValueObject'; // TODO - better typing
|
|
195
|
-
break;
|
|
196
|
-
case 'StringEnumTypeAnnotation':
|
|
197
|
-
arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string
|
|
198
|
-
break;
|
|
199
190
|
case 'GenericTypeAnnotation': // TODO verify schema - Getting this type when running codegen on all the built in types
|
|
200
191
|
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';
|
|
201
192
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropObjectTypes.js","sourceRoot":"","sources":["../../src/generators/PropObjectTypes.ts"],"names":[],"mappings":";;;AAEA,mDA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G,yBAAyB,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;wBAC/F,gBAAgB,GAAG,eAAe,SAAS,CAAC,IAAI,GAAG,CAAC;wBACpD,MAAM;oBACR,KAAK,4BAA4B;wBAC/B,gBAAgB,GAAG,wCAAwC,CAAC;wBAC5D,MAAM;oBACR,KAAK,sBAAsB;wBACzB,gBAAgB,GAAG,8CAA8C,CAAC,CAAC,uBAAuB;wBAC1F,MAAM;oBACR,KAAK,0BAA0B;wBAC7B,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,8DAA8D;wBACxG,MAAM;oBACR,KAAK,uBAA8B,EAAE,wFAAwF;wBAC3H,gBAAgB,GAAG,wCAAwC,CAAC;wBAC5D,MAAM;oBACR;wBACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,IAAI,CAAC,WAAmB,CAAC,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBACvH;gBAED,OAAO,EAAE,IAAI,EAAE,eAAe,gBAAgB,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;aACxE;QACH,KAAK,wBAAwB;YAC3B,IAAK,IAAI,CAAC,IAAY,KAAK,SAAS,EAAE;gBACpC,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;aAClE;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAC/C;YACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,IAAY,CAAC,IAAI,EAAE,CAAC,CAAC;KAC5D;AACH,CAAC;AAhED,8DAgEC","sourcesContent":["import type { PropTypeAnnotation, ObjectTypeAnnotation, EventTypeAnnotation, CommandParamTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';\nimport type { CppCodegenOptions } from './ObjectTypes';\nimport {\n AliasMap,\n getAnonymousAliasCppName,\n} from './AliasManaging';\n\n\n// eslint-disable-next-line complexity\nexport function translateComponentPropsFieldType(type: PropTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<PropTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: type.default ? `{${type.default}}` : '', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'ArrayTypeAnnotation':\n\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'ArrayTypeAnnotation':\n const innerType = translateComponentPropsFieldType(type.elementType, aliases, baseAliasName, options);\n arrayTemplateArg = `std::vector<${innerType.type}>`;\n break;\n case 'ObjectTypeAnnotation':\n arrayTemplateArg = translateComponentPropsFieldType(type.elementType, aliases, baseAliasName, options).type;\n break;\n case 'ReservedPropTypeAnnotation':\n switch (type.elementType.name) {\n case 'ColorPrimitive':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::Color';\n break;\n case 'DimensionPrimitive':\n case 'EdgeInsetsPrimitive':\n case 'ImageRequestPrimitive':\n case 'ImageSourcePrimitive':\n case 'PointPrimitive':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue'; // TODO - better handling for these types than JSValue\n break;\n default:\n throw new Error(`Unhandled ReservedPropTypeAnnotation type: ${type.elementType.name}`);\n }\n break;\n case 'StringEnumTypeAnnotation':\n arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string\n break;\n default:\n throw new Error(`Unhandled type: ${type.type}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '' };\n case 'ReservedPropTypeAnnotation':\n switch (type.name) {\n case 'ColorPrimitive':\n return { type: 'winrt::Microsoft::ReactNative::Color', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n case 'DimensionPrimitive':\n case 'EdgeInsetsPrimitive':\n case 'ImageRequestPrimitive':\n case 'ImageSourcePrimitive':\n case 'PointPrimitive':\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true }; // TODO - better handling for these types than JSValue\n default:\n throw new Error(`Unhandled ReservedPropTypeAnnotation type: ${type.name}`);\n }\n case 'ObjectTypeAnnotation': {\n return { type: getAnonymousAliasCppName<ObjectTypeAnnotation<PropTypeAnnotation>>(aliases, baseAliasName, type), initializer: '' };\n }\n case 'MixedTypeAnnotation':\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n case 'Int32EnumTypeAnnotation':\n return { type: 'int32_t', initializer: '' }; // TODO - better enum type handling than just passing a string\n case 'StringEnumTypeAnnotation':\n return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing an int\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}\n\nexport function translateComponentEventType(type: EventTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<EventTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: '' };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: '{}' };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: '{}' };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: '{}' };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: '{}' };\n case 'ArrayTypeAnnotation':\n {\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'ArrayTypeAnnotation':\n const innerType = translateComponentEventType(type.elementType, aliases, baseAliasName, options);\n arrayTemplateArg = `std::vector<${innerType.type}>`;\n break;\n case 'MixedTypeAnnotation':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n case 'ObjectTypeAnnotation':\n arrayTemplateArg = translateComponentEventType(type.elementType, aliases, baseAliasName, options).type;\n break;\n case 'StringEnumTypeAnnotation':\n arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string\n break;\n default:\n throw new Error(`Unhandled type: ${type.type}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '{}' };\n }\n case 'ObjectTypeAnnotation': {\n return { type: getAnonymousAliasCppName<ObjectTypeAnnotation<EventTypeAnnotation>>(aliases, baseAliasName, type), initializer: '' };\n }\n case 'MixedTypeAnnotation': {\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n }\n case 'StringEnumTypeAnnotation':\n return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing a string\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}\n\n\nexport function translateCommandParamType(type: CommandParamTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<CommandParamTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: '' };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: '{}' };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: '{}' };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: '{}' };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: '{}' };\n case 'ArrayTypeAnnotation':\n {\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'ArrayTypeAnnotation':\n const innerType = translateCommandParamType(type.elementType, aliases, baseAliasName, options);\n arrayTemplateArg = `std::vector<${innerType.type}>`;\n break;\n case 'ReservedPropTypeAnnotation':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n case 'ObjectTypeAnnotation':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValueObject'; // TODO - better typing\n break;\n case 'StringEnumTypeAnnotation':\n arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string\n break;\n case 'GenericTypeAnnotation' as any: // TODO verify schema - Getting this type when running codegen on all the built in types\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n default:\n throw new Error(`Unhandled type: ${(type.elementType as any).type} - ${JSON.stringify(type.elementType, null, 2)}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '{}' };\n }\n case 'ReservedTypeAnnotation': \n if ((type.name as any) !== 'RootTag') {\n throw new Error(`Unhandled ReservedTypeAnnotation: ${type.name}`)\n }\n return { type: 'bool', initializer: '{-1}' };\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"PropObjectTypes.js","sourceRoot":"","sources":["../../src/generators/PropObjectTypes.ts"],"names":[],"mappings":";;;AAEA,mDAGyB;AAGzB,sCAAsC;AACtC,SAAgB,gCAAgC,CAAC,IAAwB,EACvE,OAA2D,EAC3D,aAAqB,EACrB,OAA0B;IAC1B,QAAQ,IAAI,CAAC,IAAI,EAAE;QACjB,KAAK,sBAAsB;YACzB,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,mCAAmC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpJ,KAAK,qBAAqB;YACxB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,mCAAmC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACxI,KAAK,sBAAsB;YACzB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,mCAAmC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,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I,EAAE;oBAC7B,KAAK,uBAAuB;wBAC1B,gBAAgB,GAAG,MAAM,CAAC;wBAC1B,MAAM;oBACR,KAAK,sBAAsB;wBACzB,gBAAgB,GAAG,QAAQ,CAAC;wBAC5B,MAAM;oBACR,KAAK,qBAAqB;wBACxB,gBAAgB,GAAG,OAAO,CAAC;wBAC3B,MAAM;oBACR,KAAK,qBAAqB;wBACxB,gBAAgB,GAAG,SAAS,CAAC;wBAC7B,MAAM;oBACR,KAAK,sBAAsB;wBACzB,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;wBACzC,MAAM;oBACR,KAAK,qBAAqB;wBACxB,mDAAmD;wBACnD,gBAAgB,GAAG,wCAAwC,CAAC;wBAC5D,MAAM;oBACR,KAAK,uBAA8B,EAAE,wFAAwF;wBAC3H,gBAAgB,GAAG,wCAAwC,CAAC;wBAC5D,MAAM;oBACR;wBACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,IAAI,CAAC,WAAmB,CAAC,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBACvH;gBAED,OAAO,EAAE,IAAI,EAAE,eAAe,gBAAgB,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;aACxE;QACH,KAAK,wBAAwB;YAC3B,IAAK,IAAI,CAAC,IAAY,KAAK,SAAS,EAAE;gBACpC,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;aAClE;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAC/C;YACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,IAAY,CAAC,IAAI,EAAE,CAAC,CAAC;KAC5D;AACH,CAAC;AAvDD,8DAuDC","sourcesContent":["import type { PropTypeAnnotation, ObjectTypeAnnotation, EventTypeAnnotation, CommandParamTypeAnnotation } from '@react-native/codegen/lib/CodegenSchema';\nimport type { CppCodegenOptions } from './ObjectTypes';\nimport {\n AliasMap,\n getAnonymousAliasCppName,\n} from './AliasManaging';\n\n\n// eslint-disable-next-line complexity\nexport function translateComponentPropsFieldType(type: PropTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<PropTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: type.default ? `{${type.default}}` : '', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };\n case 'ArrayTypeAnnotation':\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'ArrayTypeAnnotation':\n const innerType = translateComponentPropsFieldType(type.elementType, aliases, baseAliasName, options);\n arrayTemplateArg = `std::vector<${innerType.type}>`;\n break;\n case 'ObjectTypeAnnotation':\n arrayTemplateArg = translateComponentPropsFieldType(type.elementType, aliases, baseAliasName, options).type;\n break;\n case 'ReservedPropTypeAnnotation':\n switch (type.elementType.name) {\n case 'ColorPrimitive':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::Color';\n break;\n case 'DimensionPrimitive':\n case 'EdgeInsetsPrimitive':\n case 'ImageRequestPrimitive':\n case 'ImageSourcePrimitive':\n case 'PointPrimitive':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue'; // TODO - better handling for these types than JSValue\n break;\n default:\n throw new Error(`Unhandled ReservedPropTypeAnnotation type: ${type.elementType.name}`);\n }\n break;\n case 'StringEnumTypeAnnotation':\n arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string\n break;\n default:\n throw new Error(`Unhandled type: ${type.type}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '' };\n case 'ReservedPropTypeAnnotation':\n switch (type.name) {\n case 'ColorPrimitive':\n return { type: 'winrt::Microsoft::ReactNative::Color', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n case 'DimensionPrimitive':\n case 'EdgeInsetsPrimitive':\n case 'ImageRequestPrimitive':\n case 'ImageSourcePrimitive':\n case 'PointPrimitive':\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true }; // TODO - better handling for these types than JSValue\n default:\n throw new Error(`Unhandled ReservedPropTypeAnnotation type: ${type.name}`);\n }\n case 'ObjectTypeAnnotation': {\n return { type: getAnonymousAliasCppName<ObjectTypeAnnotation<PropTypeAnnotation>>(aliases, baseAliasName, type), initializer: '' };\n }\n case 'MixedTypeAnnotation':\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n case 'Int32EnumTypeAnnotation':\n return { type: 'int32_t', initializer: '' }; // TODO - better enum type handling than just passing a string\n case 'StringEnumTypeAnnotation':\n return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing an int\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}\n\nexport function translateComponentEventType(type: EventTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<EventTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: '' };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: '{}' };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: '{}' };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: '{}' };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: '{}' };\n case 'ArrayTypeAnnotation':\n {\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'ArrayTypeAnnotation':\n const innerType = translateComponentEventType(type.elementType, aliases, baseAliasName, options);\n arrayTemplateArg = `std::vector<${innerType.type}>`;\n break;\n case 'MixedTypeAnnotation':\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n case 'ObjectTypeAnnotation':\n arrayTemplateArg = translateComponentEventType(type.elementType, aliases, baseAliasName, options).type;\n break;\n case 'StringLiteralUnionTypeAnnotation':\n arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string\n break;\n default:\n throw new Error(`Unhandled type: ${type.type}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '{}' };\n }\n case 'ObjectTypeAnnotation': {\n return { type: getAnonymousAliasCppName<ObjectTypeAnnotation<EventTypeAnnotation>>(aliases, baseAliasName, type), initializer: '' };\n }\n case 'MixedTypeAnnotation': {\n return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };\n }\n case 'StringLiteralUnionTypeAnnotation':\n return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing a string\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}\n\n\nexport function translateCommandParamType(type: CommandParamTypeAnnotation,\n aliases: AliasMap<ObjectTypeAnnotation<CommandParamTypeAnnotation>>,\n baseAliasName: string,\n options: CppCodegenOptions): { type: string, initializer: string, alreadySupportsOptionalOrHasDefault?: boolean } {\n switch (type.type) {\n case 'StringTypeAnnotation':\n return { type: options.cppStringType, initializer: '' };\n case 'FloatTypeAnnotation':\n return { type: 'float', initializer: '{}' };\n case 'DoubleTypeAnnotation':\n return { type: 'double', initializer: '{}' };\n case 'Int32TypeAnnotation':\n return { type: 'int32_t', initializer: '{}' };\n case 'BooleanTypeAnnotation':\n return { type: 'bool', initializer: '{}' };\n case 'ArrayTypeAnnotation':\n {\n let arrayTemplateArg = '';\n switch (type.elementType.type) {\n case 'BooleanTypeAnnotation':\n arrayTemplateArg = 'bool';\n break;\n case 'DoubleTypeAnnotation':\n arrayTemplateArg = 'double';\n break;\n case 'FloatTypeAnnotation':\n arrayTemplateArg = 'float';\n break;\n case 'Int32TypeAnnotation':\n arrayTemplateArg = 'int32_t';\n break;\n case 'StringTypeAnnotation':\n arrayTemplateArg = options.cppStringType;\n break;\n case 'MixedTypeAnnotation':\n // TODO - not sure what exact value to be used here\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n case 'GenericTypeAnnotation' as any: // TODO verify schema - Getting this type when running codegen on all the built in types\n arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';\n break;\n default:\n throw new Error(`Unhandled type: ${(type.elementType as any).type} - ${JSON.stringify(type.elementType, null, 2)}`);\n }\n\n return { type: `std::vector<${arrayTemplateArg}>`, initializer: '{}' };\n }\n case 'ReservedTypeAnnotation': \n if ((type.name as any) !== 'RootTag') {\n throw new Error(`Unhandled ReservedTypeAnnotation: ${type.name}`)\n }\n return { type: 'bool', initializer: '{-1}' };\n default:\n throw new Error(`Unhandled type: ${(type as any).type}`);\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
NativeModuleStringTypeAnnotation,
|
|
14
14
|
NativeModuleFunctionTypeAnnotation,
|
|
15
15
|
NativeModuleStringLiteralTypeAnnotation,
|
|
16
|
-
|
|
16
|
+
StringLiteralUnionTypeAnnotation,
|
|
17
17
|
UnsafeAnyTypeAnnotation,
|
|
18
18
|
Nullable,
|
|
19
19
|
} from '@react-native/codegen/lib/CodegenSchema';
|
|
@@ -56,7 +56,7 @@ export function translateFieldOrReturnType(
|
|
|
56
56
|
| NativeModuleStringTypeAnnotation
|
|
57
57
|
| NativeModuleFunctionTypeAnnotation
|
|
58
58
|
| NativeModuleStringLiteralTypeAnnotation
|
|
59
|
-
|
|
|
59
|
+
| StringLiteralUnionTypeAnnotation
|
|
60
60
|
>
|
|
61
61
|
| UnsafeAnyTypeAnnotation,
|
|
62
62
|
aliases: AliasMap,
|
|
@@ -23,7 +23,6 @@ export function translateComponentPropsFieldType(type: PropTypeAnnotation,
|
|
|
23
23
|
case 'BooleanTypeAnnotation':
|
|
24
24
|
return { type: 'bool', initializer: type.default ? `{${type.default}}` : '{}', alreadySupportsOptionalOrHasDefault: !!type.default };
|
|
25
25
|
case 'ArrayTypeAnnotation':
|
|
26
|
-
|
|
27
26
|
let arrayTemplateArg = '';
|
|
28
27
|
switch (type.elementType.type) {
|
|
29
28
|
case 'BooleanTypeAnnotation':
|
|
@@ -143,7 +142,7 @@ export function translateComponentEventType(type: EventTypeAnnotation,
|
|
|
143
142
|
case 'ObjectTypeAnnotation':
|
|
144
143
|
arrayTemplateArg = translateComponentEventType(type.elementType, aliases, baseAliasName, options).type;
|
|
145
144
|
break;
|
|
146
|
-
case '
|
|
145
|
+
case 'StringLiteralUnionTypeAnnotation':
|
|
147
146
|
arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string
|
|
148
147
|
break;
|
|
149
148
|
default:
|
|
@@ -158,7 +157,7 @@ export function translateComponentEventType(type: EventTypeAnnotation,
|
|
|
158
157
|
case 'MixedTypeAnnotation': {
|
|
159
158
|
return { type: 'winrt::Microsoft::ReactNative::JSValue', initializer: '{nullptr}', alreadySupportsOptionalOrHasDefault: true };
|
|
160
159
|
}
|
|
161
|
-
case '
|
|
160
|
+
case 'StringLiteralUnionTypeAnnotation':
|
|
162
161
|
return { type: options.cppStringType, initializer: '' }; // TODO - better enum type handling than just passing a string
|
|
163
162
|
default:
|
|
164
163
|
throw new Error(`Unhandled type: ${(type as any).type}`);
|
|
@@ -200,19 +199,10 @@ export function translateCommandParamType(type: CommandParamTypeAnnotation,
|
|
|
200
199
|
case 'StringTypeAnnotation':
|
|
201
200
|
arrayTemplateArg = options.cppStringType;
|
|
202
201
|
break;
|
|
203
|
-
case '
|
|
204
|
-
|
|
205
|
-
arrayTemplateArg = `std::vector<${innerType.type}>`;
|
|
206
|
-
break;
|
|
207
|
-
case 'ReservedPropTypeAnnotation':
|
|
202
|
+
case 'MixedTypeAnnotation':
|
|
203
|
+
// TODO - not sure what exact value to be used here
|
|
208
204
|
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';
|
|
209
205
|
break;
|
|
210
|
-
case 'ObjectTypeAnnotation':
|
|
211
|
-
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValueObject'; // TODO - better typing
|
|
212
|
-
break;
|
|
213
|
-
case 'StringEnumTypeAnnotation':
|
|
214
|
-
arrayTemplateArg = options.cppStringType; // TODO - better enum type handling than just passing a string
|
|
215
|
-
break;
|
|
216
206
|
case 'GenericTypeAnnotation' as any: // TODO verify schema - Getting this type when running codegen on all the built in types
|
|
217
207
|
arrayTemplateArg = 'winrt::Microsoft::ReactNative::JSValue';
|
|
218
208
|
break;
|