From 7ef38a17e96e4166385109eba5028cb0c18cca07 Mon Sep 17 00:00:00 2001 From: "Zihan Chen (MSFT)" <53799235+ZihanChen-MSFT@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:58:14 -0700 Subject: [PATCH] @rnw/codegen generates GetStructInfo instead of REACT_STRUCT (#11982) * #include * Separate custom types and reflection in template * Generate GetStructInfo function instead of REACT_STRUCT * ... * Update generated files * Change files * ... --- ...-d60f5561-6aee-4491-b99d-4ad85808ea29.json | 7 + ...-bf4e7dbc-e73d-4f1d-b87e-63f8edfe3eeb.json | 7 + .../codegen/src/generators/AliasGen.ts | 58 ++- .../codegen/src/generators/GenerateNM2.ts | 10 +- .../codegen/NativeMyModuleSpec.g.h | 16 +- .../packages.lock.json | 62 +-- .../packages.lock.json | 62 +-- .../GenerateViewConfigJs.js | 484 ++++++++++++++++++ vnext/babel-plugin-codegen/index.js | 192 +++++++ vnext/codegen/NativeAccessibilityInfoSpec.g.h | 3 +- .../NativeAccessibilityManagerSpec.g.h | 43 +- .../codegen/NativeActionSheetManagerSpec.g.h | 68 ++- vnext/codegen/NativeAlertManagerSpec.g.h | 30 +- vnext/codegen/NativeAnimatedModuleSpec.g.h | 23 +- .../codegen/NativeAnimatedTurboModuleSpec.g.h | 23 +- .../NativeAnimationsDebugModuleSpec.g.h | 3 +- vnext/codegen/NativeAppStateSpec.g.h | 21 +- vnext/codegen/NativeAppThemeSpec.g.h | 37 +- vnext/codegen/NativeAppearanceSpec.g.h | 3 +- vnext/codegen/NativeBlobModuleSpec.g.h | 14 +- vnext/codegen/NativeBugReportingSpec.g.h | 3 +- vnext/codegen/NativeClipboardSpec.g.h | 3 +- vnext/codegen/NativeDevLoadingViewSpec.g.h | 3 +- vnext/codegen/NativeDevMenuSpec.g.h | 3 +- vnext/codegen/NativeDevSettingsSpec.g.h | 3 +- .../NativeDevSplitBundleLoaderSpec.g.h | 3 +- .../NativeDevToolsSettingsManagerSpec.g.h | 3 +- .../codegen/NativeDeviceEventManagerSpec.g.h | 3 +- vnext/codegen/NativeDeviceInfoSpec.g.h | 61 ++- .../NativeDialogManagerAndroidSpec.g.h | 41 +- .../NativeDialogManagerWindowsSpec.g.h | 45 +- vnext/codegen/NativeExceptionsManagerSpec.g.h | 43 +- vnext/codegen/NativeFileReaderModuleSpec.g.h | 3 +- vnext/codegen/NativeFrameRateLoggerSpec.g.h | 14 +- .../NativeHeadlessJsTaskSupportSpec.g.h | 3 +- vnext/codegen/NativeI18nManagerSpec.g.h | 16 +- vnext/codegen/NativeImageEditorSpec.g.h | 53 +- .../codegen/NativeImageLoaderAndroidSpec.g.h | 25 +- vnext/codegen/NativeImageLoaderIOSSpec.g.h | 14 +- vnext/codegen/NativeImageStoreAndroidSpec.g.h | 3 +- vnext/codegen/NativeImageStoreIOSSpec.g.h | 21 +- vnext/codegen/NativeIntentAndroidSpec.g.h | 3 +- vnext/codegen/NativeJSCHeapCaptureSpec.g.h | 3 +- .../codegen/NativeJSCSamplingProfilerSpec.g.h | 3 +- vnext/codegen/NativeKeyboardObserverSpec.g.h | 3 +- vnext/codegen/NativeLinkingManagerSpec.g.h | 3 +- vnext/codegen/NativeLogBoxSpec.g.h | 3 +- vnext/codegen/NativeModalManagerSpec.g.h | 3 +- vnext/codegen/NativeNetworkingAndroidSpec.g.h | 3 +- vnext/codegen/NativeNetworkingIOSSpec.g.h | 26 +- .../codegen/NativePerformanceObserverSpec.g.h | 35 +- vnext/codegen/NativePerformanceSpec.g.h | 18 +- .../codegen/NativePermissionsAndroidSpec.g.h | 3 +- .../NativePlatformConstantsAndroidSpec.g.h | 47 +- .../NativePlatformConstantsIOSSpec.g.h | 37 +- .../NativePlatformConstantsWinSpec.g.h | 31 +- .../NativePushNotificationManagerIOSSpec.g.h | 56 +- vnext/codegen/NativeRedBoxSpec.g.h | 3 +- vnext/codegen/NativeSampleTurboModuleSpec.g.h | 16 +- vnext/codegen/NativeSegmentFetcherSpec.g.h | 3 +- vnext/codegen/NativeSettingsManagerSpec.g.h | 12 +- vnext/codegen/NativeShareModuleSpec.g.h | 23 +- vnext/codegen/NativeSoundManagerSpec.g.h | 3 +- vnext/codegen/NativeSourceCodeSpec.g.h | 12 +- .../NativeStatusBarManagerAndroidSpec.g.h | 14 +- .../codegen/NativeStatusBarManagerIOSSpec.g.h | 23 +- vnext/codegen/NativeTimingSpec.g.h | 3 +- vnext/codegen/NativeToastAndroidSpec.g.h | 20 +- vnext/codegen/NativeUIManagerSpec.g.h | 3 +- vnext/codegen/NativeVibrationSpec.g.h | 3 +- vnext/codegen/NativeWebSocketModuleSpec.g.h | 12 +- 71 files changed, 1503 insertions(+), 456 deletions(-) create mode 100644 change/@react-native-windows-codegen-d60f5561-6aee-4491-b99d-4ad85808ea29.json create mode 100644 change/react-native-windows-bf4e7dbc-e73d-4f1d-b87e-63f8edfe3eeb.json create mode 100644 vnext/babel-plugin-codegen/GenerateViewConfigJs.js create mode 100644 vnext/babel-plugin-codegen/index.js diff --git a/change/@react-native-windows-codegen-d60f5561-6aee-4491-b99d-4ad85808ea29.json b/change/@react-native-windows-codegen-d60f5561-6aee-4491-b99d-4ad85808ea29.json new file mode 100644 index 00000000000..fcba623dcd7 --- /dev/null +++ b/change/@react-native-windows-codegen-d60f5561-6aee-4491-b99d-4ad85808ea29.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "@rnw/codegen generates GetStructInfo instead of REACT_STRUCT", + "packageName": "@react-native-windows/codegen", + "email": "53799235+ZihanChen-MSFT@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-bf4e7dbc-e73d-4f1d-b87e-63f8edfe3eeb.json b/change/react-native-windows-bf4e7dbc-e73d-4f1d-b87e-63f8edfe3eeb.json new file mode 100644 index 00000000000..bb4c8e94063 --- /dev/null +++ b/change/react-native-windows-bf4e7dbc-e73d-4f1d-b87e-63f8edfe3eeb.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "@rnw/codegen generates GetStructInfo instead of REACT_STRUCT", + "packageName": "react-native-windows", + "email": "53799235+ZihanChen-MSFT@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/packages/@react-native-windows/codegen/src/generators/AliasGen.ts b/packages/@react-native-windows/codegen/src/generators/AliasGen.ts index db4f23b81f4..9c1d9412b0d 100644 --- a/packages/@react-native-windows/codegen/src/generators/AliasGen.ts +++ b/packages/@react-native-windows/codegen/src/generators/AliasGen.ts @@ -15,7 +15,7 @@ import type { import {AliasMap, getAliasCppName} from './AliasManaging'; import {CppCodegenOptions, translateField} from './ObjectTypes'; -function translateObjectBody( +function translateObjectMembersDefinition( type: NativeModuleObjectTypeAnnotation, aliases: AliasMap, baseAliasName: string, @@ -28,14 +28,24 @@ function translateObjectBody( if (prop.optional && propType.type !== 'NullableTypeAnnotation') { propType = {type: 'NullableTypeAnnotation', typeAnnotation: propType}; } - const first = `${prefix}REACT_FIELD(${prop.name})`; - const second = `${prefix}${translateField( + return `${prefix}${translateField( propType, aliases, `${baseAliasName}_${prop.name}`, options, )} ${prop.name};`; - return `${first}\n${second}`; + }) + .join('\n'); +} + +function translateObjectMembersReflection( + type: NativeModuleObjectTypeAnnotation, + aliasCppName: string, + prefix: string, +) { + return type.properties + .map((prop: NamedShape>) => { + return `${prefix}{L"${prop.name}", &${aliasCppName}::${prop.name}},`; }) .join('\n'); } @@ -50,8 +60,13 @@ export function createAliasMap(nativeModuleAliases: { return aliases; } +interface AliasCode { + definition: string; + reflection: string; +} + interface AliasCodeMap { - [name: string]: string; + [name: string]: AliasCode; } function generateSingleAlias( @@ -60,13 +75,28 @@ function generateSingleAlias( aliasCode: AliasCodeMap, options: CppCodegenOptions, ): void { + const aliasCppName = getAliasCppName(aliasName); const aliasType = aliases.types[aliasName]; - aliasCode[aliasName] = ` -REACT_STRUCT(${getAliasCppName(aliasName)}) -struct ${getAliasCppName(aliasName)} { -${translateObjectBody(aliasType, aliases, aliasName, ' ', options)} + const definition = ` +struct ${aliasCppName} { +${translateObjectMembersDefinition( + aliasType, + aliases, + aliasName, + ' ', + options, +)} }; `; + const reflection = ` +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(${aliasCppName}*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { +${translateObjectMembersReflection(aliasType, aliasCppName, ' ')} + }; + return fieldMap; +} +`; + aliasCode[aliasName] = {definition, reflection}; } function generateNestedAliasesInCorrectOrder( @@ -103,15 +133,17 @@ function generateNestedAliasesInCorrectOrder( export function generateAliases( aliases: AliasMap, options: CppCodegenOptions, -): string { +): [string, string] { const aliasCode: AliasCodeMap = {}; const aliasOrder: string[] = []; generateNestedAliasesInCorrectOrder(aliases, aliasCode, aliasOrder, options); // aliasOrder now has the correct order of C++ struct code - let traversedAliasedStructs = ''; + let customTypes = ''; + let customReflection = ''; for (const aliasName of aliasOrder) { - traversedAliasedStructs = `${traversedAliasedStructs}${aliasCode[aliasName]}`; + customTypes = `${customTypes}${aliasCode[aliasName].definition}`; + customReflection = `${customReflection}${aliasCode[aliasName].reflection}`; } - return traversedAliasedStructs; + return [customTypes, customReflection]; } diff --git a/packages/@react-native-windows/codegen/src/generators/GenerateNM2.ts b/packages/@react-native-windows/codegen/src/generators/GenerateNM2.ts index 787e63bb07c..a46fa1c4208 100644 --- a/packages/@react-native-windows/codegen/src/generators/GenerateNM2.ts +++ b/packages/@react-native-windows/codegen/src/generators/GenerateNM2.ts @@ -27,11 +27,12 @@ const moduleTemplate = ` */ #pragma once -#include "NativeModules.h" +#include #include namespace ::_NAMESPACE_:: { -::_MODULE_ALIASED_STRUCTS_:: +::_MODULE_CUSTPM_TYPES_:: +::_MODULE_CUSTPM_TYPES_REFLECTION_:: struct ::_MODULE_NAME_::Spec : winrt::Microsoft::ReactNative::TurboModuleSpec { ::_MODULE_MEMBERS_TUPLES_:: @@ -105,14 +106,15 @@ ${errors}`; } // generate code for structs - const traversedAliasedStructs = generateAliases(aliases, { + const [customTypes, customReflection] = generateAliases(aliases, { cppStringType, }); files.set( `Native${preferredModuleName}Spec.g.h`, moduleTemplate - .replace(/::_MODULE_ALIASED_STRUCTS_::/g, traversedAliasedStructs) + .replace(/::_MODULE_CUSTPM_TYPES_::/g, customTypes) + .replace(/::_MODULE_CUSTPM_TYPES_REFLECTION_::/g, customReflection) .replace(/::_MODULE_MEMBERS_TUPLES_::/g, tuples.substring(1)) .replace(/::_MODULE_MEMBERS_CHECKS_::/g, checks.substring(1)) .replace(/::_MODULE_MEMBERS_ERRORS_::/g, errors) diff --git a/packages/sample-apps/codegen/NativeMyModuleSpec.g.h b/packages/sample-apps/codegen/NativeMyModuleSpec.g.h index 4202a2512df..4dfd5f7fdcd 100644 --- a/packages/sample-apps/codegen/NativeMyModuleSpec.g.h +++ b/packages/sample-apps/codegen/NativeMyModuleSpec.g.h @@ -8,21 +8,27 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace SampleLibraryCodegen { -REACT_STRUCT(MyModuleSpec_Constants) struct MyModuleSpec_Constants { - REACT_FIELD(const1) bool const1; - REACT_FIELD(const2) double const2; - REACT_FIELD(const3) std::string const3; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(MyModuleSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"const1", &MyModuleSpec_Constants::const1}, + {L"const2", &MyModuleSpec_Constants::const2}, + {L"const3", &MyModuleSpec_Constants::const3}, + }; + return fieldMap; +} + struct MyModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json b/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json index af953654219..0506087b160 100644 --- a/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Managed.IntegrationTests/packages.lock.json @@ -26,6 +26,15 @@ "NETStandard.Library": "2.0.3" } }, + "Microsoft.UI.Xaml": { + "type": "Direct", + "requested": "[2.8.0, )", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, "MSTest.TestAdapter": { "type": "Direct", "requested": "[2.2.10, )", @@ -44,16 +53,6 @@ "resolved": "13.0.1", "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, - "boost": { - "type": "Transitive", - "resolved": "1.76.0", - "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" - }, - "Microsoft.JavaScript.Hermes": { - "type": "Transitive", - "resolved": "0.1.15", - "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ==" - }, "Microsoft.Net.Native.Compiler": { "type": "Transitive", "resolved": "2.2.7-rel-27913-00", @@ -78,35 +77,22 @@ "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "2.1.0", - "contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ==" + "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" }, "Microsoft.NETCore.Targets": { "type": "Transitive", "resolved": "1.0.1", "contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==" }, - "Microsoft.UI.Xaml": { - "type": "Transitive", - "resolved": "2.8.0", - "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", - "dependencies": { - "Microsoft.Web.WebView2": "1.0.1264.42" - } - }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, - "Microsoft.Windows.SDK.BuildTools": { - "type": "Transitive", - "resolved": "10.0.22000.194", - "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg==" - }, "NETStandard.Library": { "type": "Transitive", "resolved": "2.0.3", - "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", "dependencies": { "Microsoft.NETCore.Platforms": "1.1.0" } @@ -250,7 +236,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1" @@ -306,7 +292,6 @@ "folly": { "type": "Project", "dependencies": { - "boost": "[1.76.0, )", "fmt": "[1.0.0, )" } }, @@ -315,11 +300,7 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "Microsoft.JavaScript.Hermes": "[0.1.15, )", - "Microsoft.UI.Xaml": "[2.8.0, )", - "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )", - "ReactCommon": "[1.0.0, )", - "boost": "[1.76.0, )" + "ReactCommon": "[1.0.0, )" } }, "microsoft.reactnative.managed": { @@ -332,8 +313,7 @@ "reactcommon": { "type": "Project", "dependencies": { - "Folly": "[1.0.0, )", - "boost": "[1.76.0, )" + "Folly": "[1.0.0, )" } } }, @@ -483,7 +463,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -702,7 +682,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -933,7 +913,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1142,7 +1122,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1361,7 +1341,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1570,7 +1550,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1789,7 +1769,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", diff --git a/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json b/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json index af953654219..0506087b160 100644 --- a/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json @@ -26,6 +26,15 @@ "NETStandard.Library": "2.0.3" } }, + "Microsoft.UI.Xaml": { + "type": "Direct", + "requested": "[2.8.0, )", + "resolved": "2.8.0", + "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.1264.42" + } + }, "MSTest.TestAdapter": { "type": "Direct", "requested": "[2.2.10, )", @@ -44,16 +53,6 @@ "resolved": "13.0.1", "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, - "boost": { - "type": "Transitive", - "resolved": "1.76.0", - "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA==" - }, - "Microsoft.JavaScript.Hermes": { - "type": "Transitive", - "resolved": "0.1.15", - "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ==" - }, "Microsoft.Net.Native.Compiler": { "type": "Transitive", "resolved": "2.2.7-rel-27913-00", @@ -78,35 +77,22 @@ "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "2.1.0", - "contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ==" + "contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==" }, "Microsoft.NETCore.Targets": { "type": "Transitive", "resolved": "1.0.1", "contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==" }, - "Microsoft.UI.Xaml": { - "type": "Transitive", - "resolved": "2.8.0", - "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", - "dependencies": { - "Microsoft.Web.WebView2": "1.0.1264.42" - } - }, "Microsoft.Web.WebView2": { "type": "Transitive", "resolved": "1.0.1264.42", "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" }, - "Microsoft.Windows.SDK.BuildTools": { - "type": "Transitive", - "resolved": "10.0.22000.194", - "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg==" - }, "NETStandard.Library": { "type": "Transitive", "resolved": "2.0.3", - "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==", + "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", "dependencies": { "Microsoft.NETCore.Platforms": "1.1.0" } @@ -250,7 +236,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1" @@ -306,7 +292,6 @@ "folly": { "type": "Project", "dependencies": { - "boost": "[1.76.0, )", "fmt": "[1.0.0, )" } }, @@ -315,11 +300,7 @@ "dependencies": { "Common": "[1.0.0, )", "Folly": "[1.0.0, )", - "Microsoft.JavaScript.Hermes": "[0.1.15, )", - "Microsoft.UI.Xaml": "[2.8.0, )", - "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )", - "ReactCommon": "[1.0.0, )", - "boost": "[1.76.0, )" + "ReactCommon": "[1.0.0, )" } }, "microsoft.reactnative.managed": { @@ -332,8 +313,7 @@ "reactcommon": { "type": "Project", "dependencies": { - "Folly": "[1.0.0, )", - "boost": "[1.76.0, )" + "Folly": "[1.0.0, )" } } }, @@ -483,7 +463,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -702,7 +682,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -933,7 +913,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1142,7 +1122,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1361,7 +1341,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1570,7 +1550,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", @@ -1789,7 +1769,7 @@ "System.Runtime": { "type": "Transitive", "resolved": "4.1.0", - "contentHash": "SwXraLtIWEZwfE/jOT+WFtP/tsX2KhIdgRQt330CQckx/pbRk7e/Aigak2hFjgdkRmdmVXz6lwkDXcdtj913Bg==", + "contentHash": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1", "Microsoft.NETCore.Targets": "1.0.1", diff --git a/vnext/babel-plugin-codegen/GenerateViewConfigJs.js b/vnext/babel-plugin-codegen/GenerateViewConfigJs.js new file mode 100644 index 00000000000..00c1fffcf27 --- /dev/null +++ b/vnext/babel-plugin-codegen/GenerateViewConfigJs.js @@ -0,0 +1,484 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * //[Win: Removed flow types throughout whole file] + * @format + */ + +'use strict'; +import type { + PropTypeAnnotation, + EventTypeShape, + ComponentShape, +} from '../../CodegenSchema'; + +const j = require('jscodeshift'); + +// File path -> contents + +const FileTemplate = ({ + imports, + componentConfig, +}: { + imports: string, + componentConfig: string, +}) => ` +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * ${'@'}generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +${imports} + +${componentConfig} +`; + +// We use this to add to a set. Need to make sure we aren't importing +// this multiple times. +const UIMANAGER_IMPORT = 'const {UIManager} = require("react-native")'; + +function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) { + switch (typeAnnotation.type) { + case 'BooleanTypeAnnotation': + case 'StringTypeAnnotation': + case 'Int32TypeAnnotation': + case 'DoubleTypeAnnotation': + case 'FloatTypeAnnotation': + case 'ObjectTypeAnnotation': + case 'StringEnumTypeAnnotation': + case 'Int32EnumTypeAnnotation': + return j.literal(true); + case 'ReservedPropTypeAnnotation': + switch (typeAnnotation.name) { + case 'ColorPrimitive': + return j.template + .expression`{ process: require('react-native/Libraries/StyleSheet/processColor') }`; + case 'ImageSourcePrimitive': + return j.template + .expression`{ process: require('react-native/Libraries/Image/resolveAssetSource') }`; + case 'ImageRequestPrimitive': + throw new Error('ImageRequest should not be used in props'); + case 'PointPrimitive': + return j.template + .expression`{ diff: require('react-native/Libraries/Utilities/differ/pointsDiffer') }`; + case 'EdgeInsetsPrimitive': + return j.template + .expression`{ diff: require('react-native/Libraries/Utilities/differ/insetsDiffer') }`; + default: + typeAnnotation.name; + throw new Error( + `Received unknown native typeAnnotation: "${typeAnnotation.name}"`, + ); + } + case 'ArrayTypeAnnotation': + if (typeAnnotation.elementType.type === 'ReservedPropTypeAnnotation') { + switch (typeAnnotation.elementType.name) { + case 'ColorPrimitive': + return j.template + .expression`{ process: require('react-native/Libraries/StyleSheet/processColorArray') }`; + case 'ImageSourcePrimitive': + return j.literal(true); + case 'PointPrimitive': + return j.literal(true); + default: + throw new Error( + `Received unknown array native typeAnnotation: "${typeAnnotation.elementType.name}"`, + ); + } + } + return j.literal(true); + default: + typeAnnotation; + throw new Error( + `Received unknown typeAnnotation: "${typeAnnotation.type}"`, + ); + } +} + +const ComponentTemplate = ({ + componentName, + paperComponentName, + paperComponentNameDeprecated, +}: { + componentName: string, + paperComponentName: ?string, + paperComponentNameDeprecated: ?string, +}) => { + const nativeComponentName = paperComponentName ?? componentName; + + return ` +let nativeComponentName = '${nativeComponentName}'; +${ + paperComponentNameDeprecated != null + ? DeprecatedComponentNameCheckTemplate({ + componentName, + paperComponentNameDeprecated, + }) + : '' +} + +export const __INTERNAL_VIEW_CONFIG = VIEW_CONFIG; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +`.trim(); +}; + +// Check whether the native component exists in the app binary. +// Old getViewManagerConfig() checks for the existance of the native Paper view manager. Not available in Bridgeless. +// New hasViewManagerConfig() queries Fabric’s native component registry directly. +const DeprecatedComponentNameCheckTemplate = ({ + componentName, + paperComponentNameDeprecated, +}: { + componentName: string, + paperComponentNameDeprecated: string, +}) => + ` +if (UIManager.hasViewManagerConfig('${componentName}')) { + nativeComponentName = '${componentName}'; +} else if (UIManager.hasViewManagerConfig('${paperComponentNameDeprecated}')) { + nativeComponentName = '${paperComponentNameDeprecated}'; +} else { + throw new Error('Failed to find native component for either "${componentName}" or "${paperComponentNameDeprecated}"'); +} +`.trim(); + +// Replicates the behavior of RCTNormalizeInputEventName in RCTEventDispatcher.m +function normalizeInputEventName(name: string) { + if (name.startsWith('on')) { + return name.replace(/^on/, 'top'); + } else if (!name.startsWith('top')) { + return `top${name[0].toUpperCase()}${name.slice(1)}`; + } + + return name; +} + +// Replicates the behavior of viewConfig in RCTComponentData.m +function getValidAttributesForEvents( + events: $ReadOnlyArray, + imports: Set, +) { + imports.add( + "const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');", + ); + + const validAttributes = j.objectExpression( + events.map(eventType => { + return j.property('init', j.identifier(eventType.name), j.literal(true)); + }), + ); + + return j.callExpression(j.identifier('ConditionallyIgnoredEventHandlers'), [ + validAttributes, + ]); +} + +function generateBubblingEventInfo( + event: EventTypeShape, + nameOveride: void | string, +) { + return j.property( + 'init', + j.identifier(nameOveride || normalizeInputEventName(event.name)), + j.objectExpression([ + j.property( + 'init', + j.identifier('phasedRegistrationNames'), + j.objectExpression([ + j.property( + 'init', + j.identifier('captured'), + j.literal(`${event.name}Capture`), + ), + j.property('init', j.identifier('bubbled'), j.literal(event.name)), + ]), + ), + ]), + ); +} + +function generateDirectEventInfo( + event: EventTypeShape, + nameOveride: void | string, +) { + return j.property( + 'init', + j.identifier(nameOveride || normalizeInputEventName(event.name)), + j.objectExpression([ + j.property( + 'init', + j.identifier('registrationName'), + j.literal(event.name), + ), + ]), + ); +} + +function buildViewConfig( + schema: SchemaType, + componentName: string, + component: ComponentShape, + imports: Set, +) { + const componentProps = component.props; + const componentEvents = component.events; + + component.extendsProps.forEach(extendProps => { + switch (extendProps.type) { + case 'ReactNativeBuiltInType': + switch (extendProps.knownTypeName) { + case 'ReactNativeCoreViewProps': + // [Win: applied https://github.com/facebook/react-native/pull/29230 (and updated after merge conflicts 😢) + imports.add( + "const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');", + ); + // Win] + + return; + default: + extendProps.knownTypeName; + throw new Error('Invalid knownTypeName'); + } + default: + extendProps.type; + throw new Error('Invalid extended type'); + } + }); + + const validAttributes = j.objectExpression([ + ...componentProps.map(schemaProp => { + return j.property( + 'init', + j.identifier(schemaProp.name), + getReactDiffProcessValue(schemaProp.typeAnnotation), + ); + }), + ...(componentEvents.length > 0 + ? [ + j.spreadProperty( + getValidAttributesForEvents(componentEvents, imports), + ), + ] + : []), + ]); + + const bubblingEventNames = component.events + .filter(event => event.bubblingType === 'bubble') + .reduce((bubblingEvents, event) => { + // We add in the deprecated paper name so that it is in the view config. + // This means either the old event name or the new event name can fire + // and be sent to the listener until the old top level name is removed. + if (event.paperTopLevelNameDeprecated) { + bubblingEvents.push( + generateBubblingEventInfo(event, event.paperTopLevelNameDeprecated), + ); + } else { + bubblingEvents.push(generateBubblingEventInfo(event)); + } + return bubblingEvents; + }, []); + + const bubblingEvents = + bubblingEventNames.length > 0 + ? j.property( + 'init', + j.identifier('bubblingEventTypes'), + j.objectExpression(bubblingEventNames), + ) + : null; + + const directEventNames = component.events + .filter(event => event.bubblingType === 'direct') + .reduce((directEvents, event) => { + // We add in the deprecated paper name so that it is in the view config. + // This means either the old event name or the new event name can fire + // and be sent to the listener until the old top level name is removed. + if (event.paperTopLevelNameDeprecated) { + directEvents.push( + generateDirectEventInfo(event, event.paperTopLevelNameDeprecated), + ); + } else { + directEvents.push(generateDirectEventInfo(event)); + } + return directEvents; + }, []); + + const directEvents = + directEventNames.length > 0 + ? j.property( + 'init', + j.identifier('directEventTypes'), + j.objectExpression(directEventNames), + ) + : null; + + const properties = [ + j.property( + 'init', + j.identifier('uiViewClassName'), + j.literal(componentName), + ), + bubblingEvents, + directEvents, + j.property('init', j.identifier('validAttributes'), validAttributes), + ].filter(Boolean); + + return j.objectExpression(properties); +} + +function buildCommands( + schema: SchemaType, + componentName: string, + component: ComponentShape, + imports: Set, +) { + const commands = component.commands; + + if (commands.length === 0) { + return null; + } + + imports.add( + 'const {dispatchCommand} = require("react-native/Libraries/ReactNative/RendererProxy");', + ); + + const properties = commands.map(command => { + const commandName = command.name; + const params = command.typeAnnotation.params; + + const commandNameLiteral = j.literal(commandName); + const commandNameIdentifier = j.identifier(commandName); + const arrayParams = j.arrayExpression( + params.map(param => { + return j.identifier(param.name); + }), + ); + + const expression = j.template + .expression`dispatchCommand(ref, ${commandNameLiteral}, ${arrayParams})`; + + const functionParams = params.map(param => { + return j.identifier(param.name); + }); + + const property = j.property( + 'init', + commandNameIdentifier, + j.functionExpression( + null, + [j.identifier('ref'), ...functionParams], + j.blockStatement([j.expressionStatement(expression)]), + ), + ); + property.method = true; + + return property; + }); + + return j.exportNamedDeclaration( + j.variableDeclaration('const', [ + j.variableDeclarator( + j.identifier('Commands'), + j.objectExpression(properties), + ), + ]), + ); +} + +module.exports = { + generate(libraryName, schema) { + try { + const fileName = `${libraryName}NativeViewConfig.js`; + const imports = new Set(); + + const moduleResults = Object.keys(schema.modules) + .map(moduleName => { + const module = schema.modules[moduleName]; + if (module.type !== 'Component') { + return; + } + + const {components} = module; + + return Object.keys(components) + .map((componentName: string) => { + const component = components[componentName]; + + if (component.paperComponentNameDeprecated) { + imports.add(UIMANAGER_IMPORT); + } + + const replacedTemplate = ComponentTemplate({ + componentName, + paperComponentName: component.paperComponentName, + paperComponentNameDeprecated: + component.paperComponentNameDeprecated, + }); + + const replacedSourceRoot = j.withParser('flow')(replacedTemplate); + + const paperComponentName = + component.paperComponentName ?? componentName; + + replacedSourceRoot + .find(j.Identifier, { + name: 'VIEW_CONFIG', + }) + .replaceWith( + buildViewConfig( + schema, + paperComponentName, + component, + imports, + ), + ); + + const commands = buildCommands( + schema, + paperComponentName, + component, + imports, + ); + if (commands) { + replacedSourceRoot + .find(j.ExportDefaultDeclaration) + .insertAfter(j(commands).toSource()); + } + + const replacedSource = replacedSourceRoot.toSource({ + quote: 'single', + trailingComma: true, + }); + + return replacedSource; + }) + .join('\n\n'); + }) + .filter(Boolean) + .join('\n\n'); + + const replacedTemplate = FileTemplate({ + componentConfig: moduleResults, + imports: Array.from(imports).sort().join('\n'), + }); + + return new Map([[fileName, replacedTemplate]]); + } catch (error) { + console.error(`\nError parsing schema for ${libraryName}\n`); + console.error(JSON.stringify(schema)); + throw error; + } + }, +}; diff --git a/vnext/babel-plugin-codegen/index.js b/vnext/babel-plugin-codegen/index.js new file mode 100644 index 00000000000..10d2dedcc25 --- /dev/null +++ b/vnext/babel-plugin-codegen/index.js @@ -0,0 +1,192 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +'use strict'; + +let flowParser, typeScriptParser, RNCodegen; + +try { + flowParser = require('react-native-codegen/src/parsers/flow'); + typeScriptParser = require('react-native-codegen/src/parsers/typescript'); + RNCodegen = require('react-native-codegen/src/generators/RNCodegen'); +} catch (e) { + // Fallback to lib when source doesn't exit (e.g. when installed as a dev dependency) + flowParser = require('react-native-codegen/lib/parsers/flow'); + typeScriptParser = require('react-native-codegen/lib/parsers/typescript'); + RNCodegen = require('react-native-codegen/lib/generators/RNCodegen'); +} + +// [Win - changes to use local react-native-codegen from tscodegen, which has the flow types removed +flowParser = require('../../../node_modules/react-native-tscodegen/lib/rncodegen/src/parsers/flow'); +RNCodegen = { + generateViewConfig: ({libraryName, schema}) => { + // schemaValidator.validate(schema); + const result = require('./GenerateViewConfigJs') + .generate(libraryName, schema) + .values() + .next(); + + if (typeof result.value !== 'string') { + throw new Error(`Failed to generate view config for ${libraryName}`); + } + + return result.value; + }, +}; +// Win] + +const {basename} = require('path'); + +function parse(filename, code) { + if (filename.endsWith('js')) { + return flowParser.parseString(code); + } + + if (filename.endsWith('ts')) { + return typeScriptParser.parseString(code); + } + + throw new Error( + `Unable to parse file '${filename}'. Unsupported filename extension.`, + ); +} + +function generateViewConfig(filename, code) { + const schema = parseFile(filename, code); + + const libraryName = basename(filename).replace( + /NativeComponent\.(js|ts)$/, + '', + ); + return RNCodegen.generateViewConfig({ + schema, + libraryName, + }); +} + +function isCodegenDeclaration(declaration) { + if (!declaration) { + return false; + } + + if ( + declaration.left && + declaration.left.left && + declaration.left.left.name === 'codegenNativeComponent' + ) { + return true; + } else if ( + declaration.callee && + declaration.callee.name && + declaration.callee.name === 'codegenNativeComponent' + ) { + return true; + } else if ( + declaration.type === 'TypeCastExpression' && + declaration.expression && + declaration.expression.callee && + declaration.expression.callee.name && + declaration.expression.callee.name === 'codegenNativeComponent' + ) { + return true; + } + + return false; +} + +module.exports = function ({parse, types: t}) { + return { + pre(state) { + this.code = state.code; + this.filename = state.opts.filename; + this.defaultExport = null; + this.commandsExport = null; + this.codeInserted = false; + }, + visitor: { + ExportNamedDeclaration(path) { + if (this.codeInserted) { + return; + } + + if ( + path.node.declaration && + path.node.declaration.declarations && + path.node.declaration.declarations[0] + ) { + const firstDeclaration = path.node.declaration.declarations[0]; + + if (firstDeclaration.type === 'VariableDeclarator') { + if ( + firstDeclaration.init && + firstDeclaration.init.type === 'CallExpression' && + firstDeclaration.init.callee.type === 'Identifier' && + firstDeclaration.init.callee.name === 'codegenNativeCommands' + ) { + if ( + firstDeclaration.id.type === 'Identifier' && + firstDeclaration.id.name !== 'Commands' + ) { + throw path.buildCodeFrameError( + "Native commands must be exported with the name 'Commands'", + ); + } + this.commandsExport = path; + return; + } else { + if (firstDeclaration.id.name === 'Commands') { + throw path.buildCodeFrameError( + "'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.", + ); + } + } + } + } else if (path.node.specifiers && path.node.specifiers.length > 0) { + path.node.specifiers.forEach(specifier => { + if ( + specifier.type === 'ExportSpecifier' && + specifier.local.type === 'Identifier' && + specifier.local.name === 'Commands' + ) { + throw path.buildCodeFrameError( + "'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.", + ); + } + }); + } + }, + ExportDefaultDeclaration(path, state) { + if (isCodegenDeclaration(path.node.declaration)) { + this.defaultExport = path; + } + }, + + Program: { + exit(path) { + if (this.defaultExport) { + const viewConfig = generateViewConfig(this.filename, this.code); + this.defaultExport.replaceWithMultiple( + // [Win adding filename param see: https://github.com/facebook/react-native/pull/29230 + parse(viewConfig, { + babelrc: false, + browserslistConfigFile: false, + configFile: false, + filename: this.filename, + }).program.body, // Win] + ); + if (this.commandsExport != null) { + this.commandsExport.remove(); + } + this.codeInserted = true; + } + }, + }, + }, + }; +}; diff --git a/vnext/codegen/NativeAccessibilityInfoSpec.g.h b/vnext/codegen/NativeAccessibilityInfoSpec.g.h index a104cc8da40..80f13150aef 100644 --- a/vnext/codegen/NativeAccessibilityInfoSpec.g.h +++ b/vnext/codegen/NativeAccessibilityInfoSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct AccessibilityInfoSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"isReduceMotionEnabled"}, diff --git a/vnext/codegen/NativeAccessibilityManagerSpec.g.h b/vnext/codegen/NativeAccessibilityManagerSpec.g.h index ddc35ab0b8a..55ef094c8e6 100644 --- a/vnext/codegen/NativeAccessibilityManagerSpec.g.h +++ b/vnext/codegen/NativeAccessibilityManagerSpec.g.h @@ -8,45 +8,56 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers) struct AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers { - REACT_FIELD(extraSmall) std::optional extraSmall; - REACT_FIELD(small) std::optional small; - REACT_FIELD(medium) std::optional medium; - REACT_FIELD(large) std::optional large; - REACT_FIELD(extraLarge) std::optional extraLarge; - REACT_FIELD(extraExtraLarge) std::optional extraExtraLarge; - REACT_FIELD(extraExtraExtraLarge) std::optional extraExtraExtraLarge; - REACT_FIELD(accessibilityMedium) std::optional accessibilityMedium; - REACT_FIELD(accessibilityLarge) std::optional accessibilityLarge; - REACT_FIELD(accessibilityExtraLarge) std::optional accessibilityExtraLarge; - REACT_FIELD(accessibilityExtraExtraLarge) std::optional accessibilityExtraExtraLarge; - REACT_FIELD(accessibilityExtraExtraExtraLarge) std::optional accessibilityExtraExtraExtraLarge; }; -REACT_STRUCT(AccessibilityManagerSpec_announceForAccessibilityWithOptions_options) struct AccessibilityManagerSpec_announceForAccessibilityWithOptions_options { - REACT_FIELD(queue) std::optional queue; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"extraSmall", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::extraSmall}, + {L"small", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::small}, + {L"medium", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::medium}, + {L"large", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::large}, + {L"extraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::extraLarge}, + {L"extraExtraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::extraExtraLarge}, + {L"extraExtraExtraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::extraExtraExtraLarge}, + {L"accessibilityMedium", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::accessibilityMedium}, + {L"accessibilityLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::accessibilityLarge}, + {L"accessibilityExtraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::accessibilityExtraLarge}, + {L"accessibilityExtraExtraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::accessibilityExtraExtraLarge}, + {L"accessibilityExtraExtraExtraLarge", &AccessibilityManagerSpec_setAccessibilityContentSizeMultipliers_JSMultipliers::accessibilityExtraExtraExtraLarge}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AccessibilityManagerSpec_announceForAccessibilityWithOptions_options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"queue", &AccessibilityManagerSpec_announceForAccessibilityWithOptions_options::queue}, + }; + return fieldMap; +} + struct AccessibilityManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, Callback<::React::JSValue>) noexcept>{0, L"getCurrentBoldTextState"}, diff --git a/vnext/codegen/NativeActionSheetManagerSpec.g.h b/vnext/codegen/NativeActionSheetManagerSpec.g.h index 9310093b3d5..ad0de284b85 100644 --- a/vnext/codegen/NativeActionSheetManagerSpec.g.h +++ b/vnext/codegen/NativeActionSheetManagerSpec.g.h @@ -8,67 +8,83 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ActionSheetManagerSpec_showActionSheetWithOptions_options) struct ActionSheetManagerSpec_showActionSheetWithOptions_options { - REACT_FIELD(title) std::optional title; - REACT_FIELD(message) std::optional message; - REACT_FIELD(options) std::optional> options; - REACT_FIELD(destructiveButtonIndices) std::optional> destructiveButtonIndices; - REACT_FIELD(cancelButtonIndex) std::optional cancelButtonIndex; - REACT_FIELD(anchor) std::optional anchor; - REACT_FIELD(tintColor) std::optional tintColor; - REACT_FIELD(cancelButtonTintColor) std::optional cancelButtonTintColor; - REACT_FIELD(userInterfaceStyle) std::optional userInterfaceStyle; - REACT_FIELD(disabledButtonIndices) std::optional> disabledButtonIndices; }; -REACT_STRUCT(ActionSheetManagerSpec_showShareActionSheetWithOptions_options) struct ActionSheetManagerSpec_showShareActionSheetWithOptions_options { - REACT_FIELD(message) std::optional message; - REACT_FIELD(url) std::optional url; - REACT_FIELD(subject) std::optional subject; - REACT_FIELD(anchor) std::optional anchor; - REACT_FIELD(tintColor) std::optional tintColor; - REACT_FIELD(cancelButtonTintColor) std::optional cancelButtonTintColor; - REACT_FIELD(excludedActivityTypes) std::optional> excludedActivityTypes; - REACT_FIELD(userInterfaceStyle) std::optional userInterfaceStyle; }; -REACT_STRUCT(ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error) struct ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error { - REACT_FIELD(domain) std::string domain; - REACT_FIELD(code) std::string code; - REACT_FIELD(userInfo) std::optional<::React::JSValue> userInfo; - REACT_FIELD(message) std::string message; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ActionSheetManagerSpec_showActionSheetWithOptions_options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"title", &ActionSheetManagerSpec_showActionSheetWithOptions_options::title}, + {L"message", &ActionSheetManagerSpec_showActionSheetWithOptions_options::message}, + {L"options", &ActionSheetManagerSpec_showActionSheetWithOptions_options::options}, + {L"destructiveButtonIndices", &ActionSheetManagerSpec_showActionSheetWithOptions_options::destructiveButtonIndices}, + {L"cancelButtonIndex", &ActionSheetManagerSpec_showActionSheetWithOptions_options::cancelButtonIndex}, + {L"anchor", &ActionSheetManagerSpec_showActionSheetWithOptions_options::anchor}, + {L"tintColor", &ActionSheetManagerSpec_showActionSheetWithOptions_options::tintColor}, + {L"cancelButtonTintColor", &ActionSheetManagerSpec_showActionSheetWithOptions_options::cancelButtonTintColor}, + {L"userInterfaceStyle", &ActionSheetManagerSpec_showActionSheetWithOptions_options::userInterfaceStyle}, + {L"disabledButtonIndices", &ActionSheetManagerSpec_showActionSheetWithOptions_options::disabledButtonIndices}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ActionSheetManagerSpec_showShareActionSheetWithOptions_options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"message", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::message}, + {L"url", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::url}, + {L"subject", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::subject}, + {L"anchor", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::anchor}, + {L"tintColor", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::tintColor}, + {L"cancelButtonTintColor", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::cancelButtonTintColor}, + {L"excludedActivityTypes", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::excludedActivityTypes}, + {L"userInterfaceStyle", &ActionSheetManagerSpec_showShareActionSheetWithOptions_options::userInterfaceStyle}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"domain", &ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error::domain}, + {L"code", &ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error::code}, + {L"userInfo", &ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error::userInfo}, + {L"message", &ActionSheetManagerSpec_showShareActionSheetWithOptions_failureCallback_error::message}, + }; + return fieldMap; +} + struct ActionSheetManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"showActionSheetWithOptions"}, diff --git a/vnext/codegen/NativeAlertManagerSpec.g.h b/vnext/codegen/NativeAlertManagerSpec.g.h index cd38204380c..3ba84201993 100644 --- a/vnext/codegen/NativeAlertManagerSpec.g.h +++ b/vnext/codegen/NativeAlertManagerSpec.g.h @@ -8,35 +8,41 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AlertManagerSpec_Args) struct AlertManagerSpec_Args { - REACT_FIELD(title) std::optional title; - REACT_FIELD(message) std::optional message; - REACT_FIELD(buttons) std::optional> buttons; - REACT_FIELD(type) std::optional type; - REACT_FIELD(defaultValue) std::optional defaultValue; - REACT_FIELD(cancelButtonKey) std::optional cancelButtonKey; - REACT_FIELD(destructiveButtonKey) std::optional destructiveButtonKey; - REACT_FIELD(preferredButtonKey) std::optional preferredButtonKey; - REACT_FIELD(keyboardType) std::optional keyboardType; - REACT_FIELD(userInterfaceStyle) std::optional userInterfaceStyle; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AlertManagerSpec_Args*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"title", &AlertManagerSpec_Args::title}, + {L"message", &AlertManagerSpec_Args::message}, + {L"buttons", &AlertManagerSpec_Args::buttons}, + {L"type", &AlertManagerSpec_Args::type}, + {L"defaultValue", &AlertManagerSpec_Args::defaultValue}, + {L"cancelButtonKey", &AlertManagerSpec_Args::cancelButtonKey}, + {L"destructiveButtonKey", &AlertManagerSpec_Args::destructiveButtonKey}, + {L"preferredButtonKey", &AlertManagerSpec_Args::preferredButtonKey}, + {L"keyboardType", &AlertManagerSpec_Args::keyboardType}, + {L"userInterfaceStyle", &AlertManagerSpec_Args::userInterfaceStyle}, + }; + return fieldMap; +} + struct AlertManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"alertWithArgs"}, diff --git a/vnext/codegen/NativeAnimatedModuleSpec.g.h b/vnext/codegen/NativeAnimatedModuleSpec.g.h index 60521437791..18d403ed195 100644 --- a/vnext/codegen/NativeAnimatedModuleSpec.g.h +++ b/vnext/codegen/NativeAnimatedModuleSpec.g.h @@ -8,25 +8,36 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AnimatedModuleSpec_EndResult) struct AnimatedModuleSpec_EndResult { - REACT_FIELD(finished) bool finished; }; -REACT_STRUCT(AnimatedModuleSpec_EventMapping) struct AnimatedModuleSpec_EventMapping { - REACT_FIELD(nativeEventPath) std::vector nativeEventPath; - REACT_FIELD(animatedValueTag) std::optional animatedValueTag; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AnimatedModuleSpec_EndResult*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"finished", &AnimatedModuleSpec_EndResult::finished}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AnimatedModuleSpec_EventMapping*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"nativeEventPath", &AnimatedModuleSpec_EventMapping::nativeEventPath}, + {L"animatedValueTag", &AnimatedModuleSpec_EventMapping::animatedValueTag}, + }; + return fieldMap; +} + struct AnimatedModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"startOperationBatch"}, diff --git a/vnext/codegen/NativeAnimatedTurboModuleSpec.g.h b/vnext/codegen/NativeAnimatedTurboModuleSpec.g.h index 9114dce72f4..b6ee425a6c9 100644 --- a/vnext/codegen/NativeAnimatedTurboModuleSpec.g.h +++ b/vnext/codegen/NativeAnimatedTurboModuleSpec.g.h @@ -8,25 +8,36 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AnimatedTurboModuleSpec_EndResult) struct AnimatedTurboModuleSpec_EndResult { - REACT_FIELD(finished) bool finished; }; -REACT_STRUCT(AnimatedTurboModuleSpec_EventMapping) struct AnimatedTurboModuleSpec_EventMapping { - REACT_FIELD(nativeEventPath) std::vector nativeEventPath; - REACT_FIELD(animatedValueTag) std::optional animatedValueTag; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AnimatedTurboModuleSpec_EndResult*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"finished", &AnimatedTurboModuleSpec_EndResult::finished}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AnimatedTurboModuleSpec_EventMapping*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"nativeEventPath", &AnimatedTurboModuleSpec_EventMapping::nativeEventPath}, + {L"animatedValueTag", &AnimatedTurboModuleSpec_EventMapping::animatedValueTag}, + }; + return fieldMap; +} + struct AnimatedTurboModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"startOperationBatch"}, diff --git a/vnext/codegen/NativeAnimationsDebugModuleSpec.g.h b/vnext/codegen/NativeAnimationsDebugModuleSpec.g.h index 7fe36e84b95..3a4904084c5 100644 --- a/vnext/codegen/NativeAnimationsDebugModuleSpec.g.h +++ b/vnext/codegen/NativeAnimationsDebugModuleSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct AnimationsDebugModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"startRecordingFps"}, diff --git a/vnext/codegen/NativeAppStateSpec.g.h b/vnext/codegen/NativeAppStateSpec.g.h index 5746a24e877..7c0fd79b858 100644 --- a/vnext/codegen/NativeAppStateSpec.g.h +++ b/vnext/codegen/NativeAppStateSpec.g.h @@ -8,23 +8,34 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AppStateSpec_getCurrentAppState_success_appState) struct AppStateSpec_getCurrentAppState_success_appState { - REACT_FIELD(app_state) std::string app_state; }; -REACT_STRUCT(AppStateSpec_Constants) struct AppStateSpec_Constants { - REACT_FIELD(initialAppState) std::string initialAppState; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AppStateSpec_getCurrentAppState_success_appState*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"app_state", &AppStateSpec_getCurrentAppState_success_appState::app_state}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AppStateSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"initialAppState", &AppStateSpec_Constants::initialAppState}, + }; + return fieldMap; +} + struct AppStateSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeAppThemeSpec.g.h b/vnext/codegen/NativeAppThemeSpec.g.h index 8f3672e5982..8f1f6a6b285 100644 --- a/vnext/codegen/NativeAppThemeSpec.g.h +++ b/vnext/codegen/NativeAppThemeSpec.g.h @@ -8,39 +8,50 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(AppThemeSpec_HighContrastColors) struct AppThemeSpec_HighContrastColors { - REACT_FIELD(ButtonFaceColor) std::string ButtonFaceColor; - REACT_FIELD(ButtonTextColor) std::string ButtonTextColor; - REACT_FIELD(GrayTextColor) std::string GrayTextColor; - REACT_FIELD(HighlightColor) std::string HighlightColor; - REACT_FIELD(HighlightTextColor) std::string HighlightTextColor; - REACT_FIELD(HotlightColor) std::string HotlightColor; - REACT_FIELD(WindowColor) std::string WindowColor; - REACT_FIELD(WindowTextColor) std::string WindowTextColor; }; -REACT_STRUCT(AppThemeSpec_AppThemeData) struct AppThemeSpec_AppThemeData { - REACT_FIELD(isHighContrast) bool isHighContrast; - REACT_FIELD(highContrastColors) AppThemeSpec_HighContrastColors highContrastColors; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AppThemeSpec_HighContrastColors*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"ButtonFaceColor", &AppThemeSpec_HighContrastColors::ButtonFaceColor}, + {L"ButtonTextColor", &AppThemeSpec_HighContrastColors::ButtonTextColor}, + {L"GrayTextColor", &AppThemeSpec_HighContrastColors::GrayTextColor}, + {L"HighlightColor", &AppThemeSpec_HighContrastColors::HighlightColor}, + {L"HighlightTextColor", &AppThemeSpec_HighContrastColors::HighlightTextColor}, + {L"HotlightColor", &AppThemeSpec_HighContrastColors::HotlightColor}, + {L"WindowColor", &AppThemeSpec_HighContrastColors::WindowColor}, + {L"WindowTextColor", &AppThemeSpec_HighContrastColors::WindowTextColor}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(AppThemeSpec_AppThemeData*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isHighContrast", &AppThemeSpec_AppThemeData::isHighContrast}, + {L"highContrastColors", &AppThemeSpec_AppThemeData::highContrastColors}, + }; + return fieldMap; +} + struct AppThemeSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ diff --git a/vnext/codegen/NativeAppearanceSpec.g.h b/vnext/codegen/NativeAppearanceSpec.g.h index 3dd71ad7cbd..4c8cf8fc6ce 100644 --- a/vnext/codegen/NativeAppearanceSpec.g.h +++ b/vnext/codegen/NativeAppearanceSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct AppearanceSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ SyncMethod() noexcept>{0, L"getColorScheme"}, diff --git a/vnext/codegen/NativeBlobModuleSpec.g.h b/vnext/codegen/NativeBlobModuleSpec.g.h index 09d926e4178..09924810019 100644 --- a/vnext/codegen/NativeBlobModuleSpec.g.h +++ b/vnext/codegen/NativeBlobModuleSpec.g.h @@ -8,19 +8,25 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(BlobModuleSpec_Constants) struct BlobModuleSpec_Constants { - REACT_FIELD(BLOB_URI_SCHEME) std::optional BLOB_URI_SCHEME; - REACT_FIELD(BLOB_URI_HOST) std::optional BLOB_URI_HOST; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(BlobModuleSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"BLOB_URI_SCHEME", &BlobModuleSpec_Constants::BLOB_URI_SCHEME}, + {L"BLOB_URI_HOST", &BlobModuleSpec_Constants::BLOB_URI_HOST}, + }; + return fieldMap; +} + struct BlobModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeBugReportingSpec.g.h b/vnext/codegen/NativeBugReportingSpec.g.h index 5097feae83e..2849799b5ae 100644 --- a/vnext/codegen/NativeBugReportingSpec.g.h +++ b/vnext/codegen/NativeBugReportingSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct BugReportingSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"startReportAProblemFlow"}, diff --git a/vnext/codegen/NativeClipboardSpec.g.h b/vnext/codegen/NativeClipboardSpec.g.h index d5d6e286e5d..75499fbe14a 100644 --- a/vnext/codegen/NativeClipboardSpec.g.h +++ b/vnext/codegen/NativeClipboardSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct ClipboardSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"getString"}, diff --git a/vnext/codegen/NativeDevLoadingViewSpec.g.h b/vnext/codegen/NativeDevLoadingViewSpec.g.h index f4831087231..2d28a64103a 100644 --- a/vnext/codegen/NativeDevLoadingViewSpec.g.h +++ b/vnext/codegen/NativeDevLoadingViewSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DevLoadingViewSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, std::optional) noexcept>{0, L"showMessage"}, diff --git a/vnext/codegen/NativeDevMenuSpec.g.h b/vnext/codegen/NativeDevMenuSpec.g.h index 683a4279ee7..6aee622bf0a 100644 --- a/vnext/codegen/NativeDevMenuSpec.g.h +++ b/vnext/codegen/NativeDevMenuSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DevMenuSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"show"}, diff --git a/vnext/codegen/NativeDevSettingsSpec.g.h b/vnext/codegen/NativeDevSettingsSpec.g.h index 899b800d1ce..1798509a837 100644 --- a/vnext/codegen/NativeDevSettingsSpec.g.h +++ b/vnext/codegen/NativeDevSettingsSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DevSettingsSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"reload"}, diff --git a/vnext/codegen/NativeDevSplitBundleLoaderSpec.g.h b/vnext/codegen/NativeDevSplitBundleLoaderSpec.g.h index 6e54d10cd5c..11dccfb950e 100644 --- a/vnext/codegen/NativeDevSplitBundleLoaderSpec.g.h +++ b/vnext/codegen/NativeDevSplitBundleLoaderSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DevSplitBundleLoaderSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"loadBundle"}, diff --git a/vnext/codegen/NativeDevToolsSettingsManagerSpec.g.h b/vnext/codegen/NativeDevToolsSettingsManagerSpec.g.h index 1bc1485ac89..bd96ca414a2 100644 --- a/vnext/codegen/NativeDevToolsSettingsManagerSpec.g.h +++ b/vnext/codegen/NativeDevToolsSettingsManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DevToolsSettingsManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"setConsolePatchSettings"}, diff --git a/vnext/codegen/NativeDeviceEventManagerSpec.g.h b/vnext/codegen/NativeDeviceEventManagerSpec.g.h index 6997b9163a9..ad195caae47 100644 --- a/vnext/codegen/NativeDeviceEventManagerSpec.g.h +++ b/vnext/codegen/NativeDeviceEventManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct DeviceEventManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"invokeDefaultBackPressHandler"}, diff --git a/vnext/codegen/NativeDeviceInfoSpec.g.h b/vnext/codegen/NativeDeviceInfoSpec.g.h index f5f9c525679..582120602a8 100644 --- a/vnext/codegen/NativeDeviceInfoSpec.g.h +++ b/vnext/codegen/NativeDeviceInfoSpec.g.h @@ -8,57 +8,78 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(DeviceInfoSpec_DisplayMetrics) struct DeviceInfoSpec_DisplayMetrics { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; - REACT_FIELD(scale) double scale; - REACT_FIELD(fontScale) double fontScale; }; -REACT_STRUCT(DeviceInfoSpec_DisplayMetricsAndroid) struct DeviceInfoSpec_DisplayMetricsAndroid { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; - REACT_FIELD(scale) double scale; - REACT_FIELD(fontScale) double fontScale; - REACT_FIELD(densityDpi) double densityDpi; }; -REACT_STRUCT(DeviceInfoSpec_DimensionsPayload) struct DeviceInfoSpec_DimensionsPayload { - REACT_FIELD(window) std::optional window; - REACT_FIELD(screen) std::optional screen; - REACT_FIELD(windowPhysicalPixels) std::optional windowPhysicalPixels; - REACT_FIELD(screenPhysicalPixels) std::optional screenPhysicalPixels; }; -REACT_STRUCT(DeviceInfoSpec_Constants) struct DeviceInfoSpec_Constants { - REACT_FIELD(Dimensions) DeviceInfoSpec_DimensionsPayload Dimensions; - REACT_FIELD(isIPhoneX_deprecated) std::optional isIPhoneX_deprecated; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DeviceInfoSpec_DisplayMetrics*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &DeviceInfoSpec_DisplayMetrics::width}, + {L"height", &DeviceInfoSpec_DisplayMetrics::height}, + {L"scale", &DeviceInfoSpec_DisplayMetrics::scale}, + {L"fontScale", &DeviceInfoSpec_DisplayMetrics::fontScale}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DeviceInfoSpec_DisplayMetricsAndroid*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &DeviceInfoSpec_DisplayMetricsAndroid::width}, + {L"height", &DeviceInfoSpec_DisplayMetricsAndroid::height}, + {L"scale", &DeviceInfoSpec_DisplayMetricsAndroid::scale}, + {L"fontScale", &DeviceInfoSpec_DisplayMetricsAndroid::fontScale}, + {L"densityDpi", &DeviceInfoSpec_DisplayMetricsAndroid::densityDpi}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DeviceInfoSpec_DimensionsPayload*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"window", &DeviceInfoSpec_DimensionsPayload::window}, + {L"screen", &DeviceInfoSpec_DimensionsPayload::screen}, + {L"windowPhysicalPixels", &DeviceInfoSpec_DimensionsPayload::windowPhysicalPixels}, + {L"screenPhysicalPixels", &DeviceInfoSpec_DimensionsPayload::screenPhysicalPixels}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DeviceInfoSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"Dimensions", &DeviceInfoSpec_Constants::Dimensions}, + {L"isIPhoneX_deprecated", &DeviceInfoSpec_Constants::isIPhoneX_deprecated}, + }; + return fieldMap; +} + struct DeviceInfoSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeDialogManagerAndroidSpec.g.h b/vnext/codegen/NativeDialogManagerAndroidSpec.g.h index c835736770d..b56332c14f3 100644 --- a/vnext/codegen/NativeDialogManagerAndroidSpec.g.h +++ b/vnext/codegen/NativeDialogManagerAndroidSpec.g.h @@ -8,43 +8,54 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(DialogManagerAndroidSpec_DialogOptions) struct DialogManagerAndroidSpec_DialogOptions { - REACT_FIELD(title) std::optional title; - REACT_FIELD(message) std::optional message; - REACT_FIELD(buttonPositive) std::optional buttonPositive; - REACT_FIELD(buttonNegative) std::optional buttonNegative; - REACT_FIELD(buttonNeutral) std::optional buttonNeutral; - REACT_FIELD(items) std::optional> items; - REACT_FIELD(cancelable) std::optional cancelable; }; -REACT_STRUCT(DialogManagerAndroidSpec_Constants) struct DialogManagerAndroidSpec_Constants { - REACT_FIELD(buttonClicked) std::string buttonClicked; - REACT_FIELD(dismissed) std::string dismissed; - REACT_FIELD(buttonPositive) double buttonPositive; - REACT_FIELD(buttonNegative) double buttonNegative; - REACT_FIELD(buttonNeutral) double buttonNeutral; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DialogManagerAndroidSpec_DialogOptions*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"title", &DialogManagerAndroidSpec_DialogOptions::title}, + {L"message", &DialogManagerAndroidSpec_DialogOptions::message}, + {L"buttonPositive", &DialogManagerAndroidSpec_DialogOptions::buttonPositive}, + {L"buttonNegative", &DialogManagerAndroidSpec_DialogOptions::buttonNegative}, + {L"buttonNeutral", &DialogManagerAndroidSpec_DialogOptions::buttonNeutral}, + {L"items", &DialogManagerAndroidSpec_DialogOptions::items}, + {L"cancelable", &DialogManagerAndroidSpec_DialogOptions::cancelable}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DialogManagerAndroidSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"buttonClicked", &DialogManagerAndroidSpec_Constants::buttonClicked}, + {L"dismissed", &DialogManagerAndroidSpec_Constants::dismissed}, + {L"buttonPositive", &DialogManagerAndroidSpec_Constants::buttonPositive}, + {L"buttonNegative", &DialogManagerAndroidSpec_Constants::buttonNegative}, + {L"buttonNeutral", &DialogManagerAndroidSpec_Constants::buttonNeutral}, + }; + return fieldMap; +} + struct DialogManagerAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeDialogManagerWindowsSpec.g.h b/vnext/codegen/NativeDialogManagerWindowsSpec.g.h index e796796a3c6..3766224bbf7 100644 --- a/vnext/codegen/NativeDialogManagerWindowsSpec.g.h +++ b/vnext/codegen/NativeDialogManagerWindowsSpec.g.h @@ -8,47 +8,58 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(DialogManagerWindowsSpec_DialogOptions) struct DialogManagerWindowsSpec_DialogOptions { - REACT_FIELD(title) std::optional title; - REACT_FIELD(message) std::optional message; - REACT_FIELD(buttonPositive) std::optional buttonPositive; - REACT_FIELD(buttonNegative) std::optional buttonNegative; - REACT_FIELD(buttonNeutral) std::optional buttonNeutral; - REACT_FIELD(items) std::optional> items; - REACT_FIELD(cancelable) std::optional cancelable; - REACT_FIELD(defaultButton) std::optional defaultButton; - REACT_FIELD(rootTag) std::optional rootTag; }; -REACT_STRUCT(DialogManagerWindowsSpec_Constants) struct DialogManagerWindowsSpec_Constants { - REACT_FIELD(buttonClicked) std::string buttonClicked; - REACT_FIELD(dismissed) std::string dismissed; - REACT_FIELD(buttonPositive) int buttonPositive; - REACT_FIELD(buttonNegative) int buttonNegative; - REACT_FIELD(buttonNeutral) int buttonNeutral; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DialogManagerWindowsSpec_DialogOptions*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"title", &DialogManagerWindowsSpec_DialogOptions::title}, + {L"message", &DialogManagerWindowsSpec_DialogOptions::message}, + {L"buttonPositive", &DialogManagerWindowsSpec_DialogOptions::buttonPositive}, + {L"buttonNegative", &DialogManagerWindowsSpec_DialogOptions::buttonNegative}, + {L"buttonNeutral", &DialogManagerWindowsSpec_DialogOptions::buttonNeutral}, + {L"items", &DialogManagerWindowsSpec_DialogOptions::items}, + {L"cancelable", &DialogManagerWindowsSpec_DialogOptions::cancelable}, + {L"defaultButton", &DialogManagerWindowsSpec_DialogOptions::defaultButton}, + {L"rootTag", &DialogManagerWindowsSpec_DialogOptions::rootTag}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(DialogManagerWindowsSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"buttonClicked", &DialogManagerWindowsSpec_Constants::buttonClicked}, + {L"dismissed", &DialogManagerWindowsSpec_Constants::dismissed}, + {L"buttonPositive", &DialogManagerWindowsSpec_Constants::buttonPositive}, + {L"buttonNegative", &DialogManagerWindowsSpec_Constants::buttonNegative}, + {L"buttonNeutral", &DialogManagerWindowsSpec_Constants::buttonNeutral}, + }; + return fieldMap; +} + struct DialogManagerWindowsSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeExceptionsManagerSpec.g.h b/vnext/codegen/NativeExceptionsManagerSpec.g.h index 9178d9aa189..b3391117069 100644 --- a/vnext/codegen/NativeExceptionsManagerSpec.g.h +++ b/vnext/codegen/NativeExceptionsManagerSpec.g.h @@ -8,45 +8,56 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ExceptionsManagerSpec_StackFrame) struct ExceptionsManagerSpec_StackFrame { - REACT_FIELD(column) std::optional column; - REACT_FIELD(file) std::optional file; - REACT_FIELD(lineNumber) std::optional lineNumber; - REACT_FIELD(methodName) std::string methodName; - REACT_FIELD(collapse) std::optional collapse; }; -REACT_STRUCT(ExceptionsManagerSpec_ExceptionData) struct ExceptionsManagerSpec_ExceptionData { - REACT_FIELD(message) std::string message; - REACT_FIELD(originalMessage) std::optional originalMessage; - REACT_FIELD(name) std::optional name; - REACT_FIELD(componentStack) std::optional componentStack; - REACT_FIELD(stack) std::vector stack; - REACT_FIELD(id) double id; - REACT_FIELD(isFatal) bool isFatal; - REACT_FIELD(extraData) std::optional<::React::JSValue> extraData; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ExceptionsManagerSpec_StackFrame*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"column", &ExceptionsManagerSpec_StackFrame::column}, + {L"file", &ExceptionsManagerSpec_StackFrame::file}, + {L"lineNumber", &ExceptionsManagerSpec_StackFrame::lineNumber}, + {L"methodName", &ExceptionsManagerSpec_StackFrame::methodName}, + {L"collapse", &ExceptionsManagerSpec_StackFrame::collapse}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ExceptionsManagerSpec_ExceptionData*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"message", &ExceptionsManagerSpec_ExceptionData::message}, + {L"originalMessage", &ExceptionsManagerSpec_ExceptionData::originalMessage}, + {L"name", &ExceptionsManagerSpec_ExceptionData::name}, + {L"componentStack", &ExceptionsManagerSpec_ExceptionData::componentStack}, + {L"stack", &ExceptionsManagerSpec_ExceptionData::stack}, + {L"id", &ExceptionsManagerSpec_ExceptionData::id}, + {L"isFatal", &ExceptionsManagerSpec_ExceptionData::isFatal}, + {L"extraData", &ExceptionsManagerSpec_ExceptionData::extraData}, + }; + return fieldMap; +} + struct ExceptionsManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, double) noexcept>{0, L"reportFatalException"}, diff --git a/vnext/codegen/NativeFileReaderModuleSpec.g.h b/vnext/codegen/NativeFileReaderModuleSpec.g.h index bdbc036dc1c..fc6c2db899b 100644 --- a/vnext/codegen/NativeFileReaderModuleSpec.g.h +++ b/vnext/codegen/NativeFileReaderModuleSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct FileReaderModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"readAsDataURL"}, diff --git a/vnext/codegen/NativeFrameRateLoggerSpec.g.h b/vnext/codegen/NativeFrameRateLoggerSpec.g.h index d2a0b2a814d..d4890796e7c 100644 --- a/vnext/codegen/NativeFrameRateLoggerSpec.g.h +++ b/vnext/codegen/NativeFrameRateLoggerSpec.g.h @@ -8,19 +8,25 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(FrameRateLoggerSpec_setGlobalOptions_options) struct FrameRateLoggerSpec_setGlobalOptions_options { - REACT_FIELD(debug) std::optional debug; - REACT_FIELD(reportStackTraces) std::optional reportStackTraces; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(FrameRateLoggerSpec_setGlobalOptions_options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"debug", &FrameRateLoggerSpec_setGlobalOptions_options::debug}, + {L"reportStackTraces", &FrameRateLoggerSpec_setGlobalOptions_options::reportStackTraces}, + }; + return fieldMap; +} + struct FrameRateLoggerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"setGlobalOptions"}, diff --git a/vnext/codegen/NativeHeadlessJsTaskSupportSpec.g.h b/vnext/codegen/NativeHeadlessJsTaskSupportSpec.g.h index 90b0bf1ab72..ffb77541dde 100644 --- a/vnext/codegen/NativeHeadlessJsTaskSupportSpec.g.h +++ b/vnext/codegen/NativeHeadlessJsTaskSupportSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct HeadlessJsTaskSupportSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"notifyTaskFinished"}, diff --git a/vnext/codegen/NativeI18nManagerSpec.g.h b/vnext/codegen/NativeI18nManagerSpec.g.h index 522d7cb931b..b7808b55fc2 100644 --- a/vnext/codegen/NativeI18nManagerSpec.g.h +++ b/vnext/codegen/NativeI18nManagerSpec.g.h @@ -8,21 +8,27 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(I18nManagerSpec_Constants) struct I18nManagerSpec_Constants { - REACT_FIELD(isRTL) bool isRTL; - REACT_FIELD(doLeftAndRightSwapInRTL) bool doLeftAndRightSwapInRTL; - REACT_FIELD(localeIdentifier) std::optional localeIdentifier; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(I18nManagerSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isRTL", &I18nManagerSpec_Constants::isRTL}, + {L"doLeftAndRightSwapInRTL", &I18nManagerSpec_Constants::doLeftAndRightSwapInRTL}, + {L"localeIdentifier", &I18nManagerSpec_Constants::localeIdentifier}, + }; + return fieldMap; +} + struct I18nManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeImageEditorSpec.g.h b/vnext/codegen/NativeImageEditorSpec.g.h index 00ceb95c161..f2ae68f7d1f 100644 --- a/vnext/codegen/NativeImageEditorSpec.g.h +++ b/vnext/codegen/NativeImageEditorSpec.g.h @@ -8,49 +8,70 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ImageEditorSpec_Options_offset) struct ImageEditorSpec_Options_offset { - REACT_FIELD(x) double x; - REACT_FIELD(y) double y; }; -REACT_STRUCT(ImageEditorSpec_Options_size) struct ImageEditorSpec_Options_size { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; }; -REACT_STRUCT(ImageEditorSpec_Options_displaySize) struct ImageEditorSpec_Options_displaySize { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; }; -REACT_STRUCT(ImageEditorSpec_Options) struct ImageEditorSpec_Options { - REACT_FIELD(offset) ImageEditorSpec_Options_offset offset; - REACT_FIELD(size) ImageEditorSpec_Options_size size; - REACT_FIELD(displaySize) std::optional displaySize; - REACT_FIELD(resizeMode) std::optional resizeMode; - REACT_FIELD(allowExternalStorage) std::optional allowExternalStorage; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageEditorSpec_Options_offset*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"x", &ImageEditorSpec_Options_offset::x}, + {L"y", &ImageEditorSpec_Options_offset::y}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageEditorSpec_Options_size*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &ImageEditorSpec_Options_size::width}, + {L"height", &ImageEditorSpec_Options_size::height}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageEditorSpec_Options_displaySize*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &ImageEditorSpec_Options_displaySize::width}, + {L"height", &ImageEditorSpec_Options_displaySize::height}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageEditorSpec_Options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"offset", &ImageEditorSpec_Options::offset}, + {L"size", &ImageEditorSpec_Options::size}, + {L"displaySize", &ImageEditorSpec_Options::displaySize}, + {L"resizeMode", &ImageEditorSpec_Options::resizeMode}, + {L"allowExternalStorage", &ImageEditorSpec_Options::allowExternalStorage}, + }; + return fieldMap; +} + struct ImageEditorSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, Callback) noexcept>{0, L"cropImage"}, diff --git a/vnext/codegen/NativeImageLoaderAndroidSpec.g.h b/vnext/codegen/NativeImageLoaderAndroidSpec.g.h index c2eb4e59ca6..113f7b3545e 100644 --- a/vnext/codegen/NativeImageLoaderAndroidSpec.g.h +++ b/vnext/codegen/NativeImageLoaderAndroidSpec.g.h @@ -8,27 +8,38 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ImageLoaderAndroidSpec_getSize_returnType) struct ImageLoaderAndroidSpec_getSize_returnType { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; }; -REACT_STRUCT(ImageLoaderAndroidSpec_getSizeWithHeaders_returnType) struct ImageLoaderAndroidSpec_getSizeWithHeaders_returnType { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageLoaderAndroidSpec_getSize_returnType*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &ImageLoaderAndroidSpec_getSize_returnType::width}, + {L"height", &ImageLoaderAndroidSpec_getSize_returnType::height}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageLoaderAndroidSpec_getSizeWithHeaders_returnType*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &ImageLoaderAndroidSpec_getSizeWithHeaders_returnType::width}, + {L"height", &ImageLoaderAndroidSpec_getSizeWithHeaders_returnType::height}, + }; + return fieldMap; +} + struct ImageLoaderAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"abortRequest"}, diff --git a/vnext/codegen/NativeImageLoaderIOSSpec.g.h b/vnext/codegen/NativeImageLoaderIOSSpec.g.h index b5cea76832a..bbdd315456b 100644 --- a/vnext/codegen/NativeImageLoaderIOSSpec.g.h +++ b/vnext/codegen/NativeImageLoaderIOSSpec.g.h @@ -8,19 +8,25 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ImageLoaderIOSSpec_getSizeWithHeaders_returnType) struct ImageLoaderIOSSpec_getSizeWithHeaders_returnType { - REACT_FIELD(width) double width; - REACT_FIELD(height) double height; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageLoaderIOSSpec_getSizeWithHeaders_returnType*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"width", &ImageLoaderIOSSpec_getSizeWithHeaders_returnType::width}, + {L"height", &ImageLoaderIOSSpec_getSizeWithHeaders_returnType::height}, + }; + return fieldMap; +} + struct ImageLoaderIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method>) noexcept>{0, L"getSize"}, diff --git a/vnext/codegen/NativeImageStoreAndroidSpec.g.h b/vnext/codegen/NativeImageStoreAndroidSpec.g.h index 39996630d12..e4e33f4aea8 100644 --- a/vnext/codegen/NativeImageStoreAndroidSpec.g.h +++ b/vnext/codegen/NativeImageStoreAndroidSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct ImageStoreAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, Callback) noexcept>{0, L"getBase64ForTag"}, diff --git a/vnext/codegen/NativeImageStoreIOSSpec.g.h b/vnext/codegen/NativeImageStoreIOSSpec.g.h index bab500ba238..8d18990eaa6 100644 --- a/vnext/codegen/NativeImageStoreIOSSpec.g.h +++ b/vnext/codegen/NativeImageStoreIOSSpec.g.h @@ -8,23 +8,34 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ImageStoreIOSSpec_getBase64ForTag_errorCallback_error) struct ImageStoreIOSSpec_getBase64ForTag_errorCallback_error { - REACT_FIELD(message) std::string message; }; -REACT_STRUCT(ImageStoreIOSSpec_addImageFromBase64_errorCallback_error) struct ImageStoreIOSSpec_addImageFromBase64_errorCallback_error { - REACT_FIELD(message) std::string message; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageStoreIOSSpec_getBase64ForTag_errorCallback_error*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"message", &ImageStoreIOSSpec_getBase64ForTag_errorCallback_error::message}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ImageStoreIOSSpec_addImageFromBase64_errorCallback_error*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"message", &ImageStoreIOSSpec_addImageFromBase64_errorCallback_error::message}, + }; + return fieldMap; +} + struct ImageStoreIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, Callback) noexcept>{0, L"getBase64ForTag"}, diff --git a/vnext/codegen/NativeIntentAndroidSpec.g.h b/vnext/codegen/NativeIntentAndroidSpec.g.h index e37e59cfb85..8d313fd3e95 100644 --- a/vnext/codegen/NativeIntentAndroidSpec.g.h +++ b/vnext/codegen/NativeIntentAndroidSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct IntentAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"getInitialURL"}, diff --git a/vnext/codegen/NativeJSCHeapCaptureSpec.g.h b/vnext/codegen/NativeJSCHeapCaptureSpec.g.h index c0d370ec4b0..1462a337d6e 100644 --- a/vnext/codegen/NativeJSCHeapCaptureSpec.g.h +++ b/vnext/codegen/NativeJSCHeapCaptureSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct JSCHeapCaptureSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"captureComplete"}, diff --git a/vnext/codegen/NativeJSCSamplingProfilerSpec.g.h b/vnext/codegen/NativeJSCSamplingProfilerSpec.g.h index 444d664a7ef..0e2191c3f0d 100644 --- a/vnext/codegen/NativeJSCSamplingProfilerSpec.g.h +++ b/vnext/codegen/NativeJSCSamplingProfilerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct JSCSamplingProfilerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method, std::optional) noexcept>{0, L"operationComplete"}, diff --git a/vnext/codegen/NativeKeyboardObserverSpec.g.h b/vnext/codegen/NativeKeyboardObserverSpec.g.h index 26bfb42c20a..08627689213 100644 --- a/vnext/codegen/NativeKeyboardObserverSpec.g.h +++ b/vnext/codegen/NativeKeyboardObserverSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct KeyboardObserverSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"addListener"}, diff --git a/vnext/codegen/NativeLinkingManagerSpec.g.h b/vnext/codegen/NativeLinkingManagerSpec.g.h index fddc1ded0f6..82ec7a071bc 100644 --- a/vnext/codegen/NativeLinkingManagerSpec.g.h +++ b/vnext/codegen/NativeLinkingManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct LinkingManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"getInitialURL"}, diff --git a/vnext/codegen/NativeLogBoxSpec.g.h b/vnext/codegen/NativeLogBoxSpec.g.h index 2ef1e8da26d..f833fca6175 100644 --- a/vnext/codegen/NativeLogBoxSpec.g.h +++ b/vnext/codegen/NativeLogBoxSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct LogBoxSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"show"}, diff --git a/vnext/codegen/NativeModalManagerSpec.g.h b/vnext/codegen/NativeModalManagerSpec.g.h index 02e69912073..e88abaa1d27 100644 --- a/vnext/codegen/NativeModalManagerSpec.g.h +++ b/vnext/codegen/NativeModalManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct ModalManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"addListener"}, diff --git a/vnext/codegen/NativeNetworkingAndroidSpec.g.h b/vnext/codegen/NativeNetworkingAndroidSpec.g.h index dc9326dd441..53bb429b9cc 100644 --- a/vnext/codegen/NativeNetworkingAndroidSpec.g.h +++ b/vnext/codegen/NativeNetworkingAndroidSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct NetworkingAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"sendRequest"}, diff --git a/vnext/codegen/NativeNetworkingIOSSpec.g.h b/vnext/codegen/NativeNetworkingIOSSpec.g.h index 860e95ff923..11c7e9bbe22 100644 --- a/vnext/codegen/NativeNetworkingIOSSpec.g.h +++ b/vnext/codegen/NativeNetworkingIOSSpec.g.h @@ -8,31 +8,37 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(NetworkingIOSSpec_sendRequest_query) struct NetworkingIOSSpec_sendRequest_query { - REACT_FIELD(method) std::string method; - REACT_FIELD(url) std::string url; - REACT_FIELD(data) ::React::JSValue data; - REACT_FIELD(headers) ::React::JSValue headers; - REACT_FIELD(responseType) std::string responseType; - REACT_FIELD(incrementalUpdates) bool incrementalUpdates; - REACT_FIELD(timeout) double timeout; - REACT_FIELD(withCredentials) bool withCredentials; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(NetworkingIOSSpec_sendRequest_query*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"method", &NetworkingIOSSpec_sendRequest_query::method}, + {L"url", &NetworkingIOSSpec_sendRequest_query::url}, + {L"data", &NetworkingIOSSpec_sendRequest_query::data}, + {L"headers", &NetworkingIOSSpec_sendRequest_query::headers}, + {L"responseType", &NetworkingIOSSpec_sendRequest_query::responseType}, + {L"incrementalUpdates", &NetworkingIOSSpec_sendRequest_query::incrementalUpdates}, + {L"timeout", &NetworkingIOSSpec_sendRequest_query::timeout}, + {L"withCredentials", &NetworkingIOSSpec_sendRequest_query::withCredentials}, + }; + return fieldMap; +} + struct NetworkingIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"sendRequest"}, diff --git a/vnext/codegen/NativePerformanceObserverSpec.g.h b/vnext/codegen/NativePerformanceObserverSpec.g.h index 3be2946ca1e..743915bfc13 100644 --- a/vnext/codegen/NativePerformanceObserverSpec.g.h +++ b/vnext/codegen/NativePerformanceObserverSpec.g.h @@ -8,37 +8,48 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PerformanceObserverSpec_RawPerformanceEntry) struct PerformanceObserverSpec_RawPerformanceEntry { - REACT_FIELD(name) std::string name; - REACT_FIELD(entryType) double entryType; - REACT_FIELD(startTime) double startTime; - REACT_FIELD(duration) double duration; - REACT_FIELD(processingStart) std::optional processingStart; - REACT_FIELD(processingEnd) std::optional processingEnd; - REACT_FIELD(interactionId) std::optional interactionId; }; -REACT_STRUCT(PerformanceObserverSpec_GetPendingEntriesResult) struct PerformanceObserverSpec_GetPendingEntriesResult { - REACT_FIELD(entries) std::vector entries; - REACT_FIELD(droppedEntriesCount) double droppedEntriesCount; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PerformanceObserverSpec_RawPerformanceEntry*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"name", &PerformanceObserverSpec_RawPerformanceEntry::name}, + {L"entryType", &PerformanceObserverSpec_RawPerformanceEntry::entryType}, + {L"startTime", &PerformanceObserverSpec_RawPerformanceEntry::startTime}, + {L"duration", &PerformanceObserverSpec_RawPerformanceEntry::duration}, + {L"processingStart", &PerformanceObserverSpec_RawPerformanceEntry::processingStart}, + {L"processingEnd", &PerformanceObserverSpec_RawPerformanceEntry::processingEnd}, + {L"interactionId", &PerformanceObserverSpec_RawPerformanceEntry::interactionId}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PerformanceObserverSpec_GetPendingEntriesResult*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"entries", &PerformanceObserverSpec_GetPendingEntriesResult::entries}, + {L"droppedEntriesCount", &PerformanceObserverSpec_GetPendingEntriesResult::droppedEntriesCount}, + }; + return fieldMap; +} + struct PerformanceObserverSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"startReporting"}, diff --git a/vnext/codegen/NativePerformanceSpec.g.h b/vnext/codegen/NativePerformanceSpec.g.h index d2eec1dfcb1..73363653147 100644 --- a/vnext/codegen/NativePerformanceSpec.g.h +++ b/vnext/codegen/NativePerformanceSpec.g.h @@ -8,23 +8,29 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PerformanceSpec_ReactNativeStartupTiming) struct PerformanceSpec_ReactNativeStartupTiming { - REACT_FIELD(startTime) double startTime; - REACT_FIELD(endTime) double endTime; - REACT_FIELD(executeJavaScriptBundleEntryPointStart) double executeJavaScriptBundleEntryPointStart; - REACT_FIELD(executeJavaScriptBundleEntryPointEnd) double executeJavaScriptBundleEntryPointEnd; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PerformanceSpec_ReactNativeStartupTiming*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"startTime", &PerformanceSpec_ReactNativeStartupTiming::startTime}, + {L"endTime", &PerformanceSpec_ReactNativeStartupTiming::endTime}, + {L"executeJavaScriptBundleEntryPointStart", &PerformanceSpec_ReactNativeStartupTiming::executeJavaScriptBundleEntryPointStart}, + {L"executeJavaScriptBundleEntryPointEnd", &PerformanceSpec_ReactNativeStartupTiming::executeJavaScriptBundleEntryPointEnd}, + }; + return fieldMap; +} + struct PerformanceSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"mark"}, diff --git a/vnext/codegen/NativePermissionsAndroidSpec.g.h b/vnext/codegen/NativePermissionsAndroidSpec.g.h index e403401d38b..e74f83dfb98 100644 --- a/vnext/codegen/NativePermissionsAndroidSpec.g.h +++ b/vnext/codegen/NativePermissionsAndroidSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct PermissionsAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"checkPermission"}, diff --git a/vnext/codegen/NativePlatformConstantsAndroidSpec.g.h b/vnext/codegen/NativePlatformConstantsAndroidSpec.g.h index 8a0f3e0add4..d9302e48a25 100644 --- a/vnext/codegen/NativePlatformConstantsAndroidSpec.g.h +++ b/vnext/codegen/NativePlatformConstantsAndroidSpec.g.h @@ -8,49 +8,60 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PlatformConstantsAndroidSpec_Constants_reactNativeVersion) struct PlatformConstantsAndroidSpec_Constants_reactNativeVersion { - REACT_FIELD(major) double major; - REACT_FIELD(minor) double minor; - REACT_FIELD(patch) double patch; - REACT_FIELD(prerelease) std::optional prerelease; }; -REACT_STRUCT(PlatformConstantsAndroidSpec_Constants) struct PlatformConstantsAndroidSpec_Constants { - REACT_FIELD(isTesting) bool isTesting; - REACT_FIELD(reactNativeVersion) PlatformConstantsAndroidSpec_Constants_reactNativeVersion reactNativeVersion; - REACT_FIELD(Version) double Version; - REACT_FIELD(Release) std::string Release; - REACT_FIELD(Serial) std::string Serial; - REACT_FIELD(Fingerprint) std::string Fingerprint; - REACT_FIELD(Model) std::string Model; - REACT_FIELD(ServerHost) std::optional ServerHost; - REACT_FIELD(uiMode) std::string uiMode; - REACT_FIELD(Brand) std::string Brand; - REACT_FIELD(Manufacturer) std::string Manufacturer; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsAndroidSpec_Constants_reactNativeVersion*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"major", &PlatformConstantsAndroidSpec_Constants_reactNativeVersion::major}, + {L"minor", &PlatformConstantsAndroidSpec_Constants_reactNativeVersion::minor}, + {L"patch", &PlatformConstantsAndroidSpec_Constants_reactNativeVersion::patch}, + {L"prerelease", &PlatformConstantsAndroidSpec_Constants_reactNativeVersion::prerelease}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsAndroidSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isTesting", &PlatformConstantsAndroidSpec_Constants::isTesting}, + {L"reactNativeVersion", &PlatformConstantsAndroidSpec_Constants::reactNativeVersion}, + {L"Version", &PlatformConstantsAndroidSpec_Constants::Version}, + {L"Release", &PlatformConstantsAndroidSpec_Constants::Release}, + {L"Serial", &PlatformConstantsAndroidSpec_Constants::Serial}, + {L"Fingerprint", &PlatformConstantsAndroidSpec_Constants::Fingerprint}, + {L"Model", &PlatformConstantsAndroidSpec_Constants::Model}, + {L"ServerHost", &PlatformConstantsAndroidSpec_Constants::ServerHost}, + {L"uiMode", &PlatformConstantsAndroidSpec_Constants::uiMode}, + {L"Brand", &PlatformConstantsAndroidSpec_Constants::Brand}, + {L"Manufacturer", &PlatformConstantsAndroidSpec_Constants::Manufacturer}, + }; + return fieldMap; +} + struct PlatformConstantsAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativePlatformConstantsIOSSpec.g.h b/vnext/codegen/NativePlatformConstantsIOSSpec.g.h index 63821a51497..440f1c49ce4 100644 --- a/vnext/codegen/NativePlatformConstantsIOSSpec.g.h +++ b/vnext/codegen/NativePlatformConstantsIOSSpec.g.h @@ -8,39 +8,50 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PlatformConstantsIOSSpec_Constants_reactNativeVersion) struct PlatformConstantsIOSSpec_Constants_reactNativeVersion { - REACT_FIELD(major) double major; - REACT_FIELD(minor) double minor; - REACT_FIELD(patch) double patch; - REACT_FIELD(prerelease) std::optional prerelease; }; -REACT_STRUCT(PlatformConstantsIOSSpec_Constants) struct PlatformConstantsIOSSpec_Constants { - REACT_FIELD(isTesting) bool isTesting; - REACT_FIELD(reactNativeVersion) PlatformConstantsIOSSpec_Constants_reactNativeVersion reactNativeVersion; - REACT_FIELD(forceTouchAvailable) bool forceTouchAvailable; - REACT_FIELD(osVersion) std::string osVersion; - REACT_FIELD(systemName) std::string systemName; - REACT_FIELD(interfaceIdiom) std::string interfaceIdiom; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsIOSSpec_Constants_reactNativeVersion*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"major", &PlatformConstantsIOSSpec_Constants_reactNativeVersion::major}, + {L"minor", &PlatformConstantsIOSSpec_Constants_reactNativeVersion::minor}, + {L"patch", &PlatformConstantsIOSSpec_Constants_reactNativeVersion::patch}, + {L"prerelease", &PlatformConstantsIOSSpec_Constants_reactNativeVersion::prerelease}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsIOSSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isTesting", &PlatformConstantsIOSSpec_Constants::isTesting}, + {L"reactNativeVersion", &PlatformConstantsIOSSpec_Constants::reactNativeVersion}, + {L"forceTouchAvailable", &PlatformConstantsIOSSpec_Constants::forceTouchAvailable}, + {L"osVersion", &PlatformConstantsIOSSpec_Constants::osVersion}, + {L"systemName", &PlatformConstantsIOSSpec_Constants::systemName}, + {L"interfaceIdiom", &PlatformConstantsIOSSpec_Constants::interfaceIdiom}, + }; + return fieldMap; +} + struct PlatformConstantsIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativePlatformConstantsWinSpec.g.h b/vnext/codegen/NativePlatformConstantsWinSpec.g.h index 9e373856068..0b0f9885a80 100644 --- a/vnext/codegen/NativePlatformConstantsWinSpec.g.h +++ b/vnext/codegen/NativePlatformConstantsWinSpec.g.h @@ -8,33 +8,44 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PlatformConstantsWinSpec_Constants_reactNativeVersion) struct PlatformConstantsWinSpec_Constants_reactNativeVersion { - REACT_FIELD(major) double major; - REACT_FIELD(minor) double minor; - REACT_FIELD(patch) double patch; - REACT_FIELD(prerelease) std::optional prerelease; }; -REACT_STRUCT(PlatformConstantsWinSpec_Constants) struct PlatformConstantsWinSpec_Constants { - REACT_FIELD(isTesting) bool isTesting; - REACT_FIELD(reactNativeVersion) PlatformConstantsWinSpec_Constants_reactNativeVersion reactNativeVersion; - REACT_FIELD(osVersion) double osVersion; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWinSpec_Constants_reactNativeVersion*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"major", &PlatformConstantsWinSpec_Constants_reactNativeVersion::major}, + {L"minor", &PlatformConstantsWinSpec_Constants_reactNativeVersion::minor}, + {L"patch", &PlatformConstantsWinSpec_Constants_reactNativeVersion::patch}, + {L"prerelease", &PlatformConstantsWinSpec_Constants_reactNativeVersion::prerelease}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWinSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isTesting", &PlatformConstantsWinSpec_Constants::isTesting}, + {L"reactNativeVersion", &PlatformConstantsWinSpec_Constants::reactNativeVersion}, + {L"osVersion", &PlatformConstantsWinSpec_Constants::osVersion}, + }; + return fieldMap; +} + struct PlatformConstantsWinSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativePushNotificationManagerIOSSpec.g.h b/vnext/codegen/NativePushNotificationManagerIOSSpec.g.h index c0205e7a39a..f774b363828 100644 --- a/vnext/codegen/NativePushNotificationManagerIOSSpec.g.h +++ b/vnext/codegen/NativePushNotificationManagerIOSSpec.g.h @@ -8,55 +8,71 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(PushNotificationManagerIOSSpec_Permissions) struct PushNotificationManagerIOSSpec_Permissions { - REACT_FIELD(alert) bool alert; - REACT_FIELD(badge) bool badge; - REACT_FIELD(sound) bool sound; }; -REACT_STRUCT(PushNotificationManagerIOSSpec_Notification) struct PushNotificationManagerIOSSpec_Notification { - REACT_FIELD(alertTitle) std::optional alertTitle; - REACT_FIELD(fireDate) std::optional fireDate; - REACT_FIELD(alertBody) std::optional alertBody; - REACT_FIELD(alertAction) std::optional alertAction; - REACT_FIELD(userInfo) std::optional<::React::JSValue> userInfo; - REACT_FIELD(category) std::optional category; - REACT_FIELD(repeatInterval) std::optional repeatInterval; - REACT_FIELD(applicationIconBadgeNumber) std::optional applicationIconBadgeNumber; - REACT_FIELD(isSilent) std::optional isSilent; - REACT_FIELD(soundName) std::optional soundName; }; -REACT_STRUCT(PushNotificationManagerIOSSpec_requestPermissions_permission) struct PushNotificationManagerIOSSpec_requestPermissions_permission { - REACT_FIELD(alert) bool alert; - REACT_FIELD(badge) bool badge; - REACT_FIELD(sound) bool sound; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PushNotificationManagerIOSSpec_Permissions*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"alert", &PushNotificationManagerIOSSpec_Permissions::alert}, + {L"badge", &PushNotificationManagerIOSSpec_Permissions::badge}, + {L"sound", &PushNotificationManagerIOSSpec_Permissions::sound}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PushNotificationManagerIOSSpec_Notification*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"alertTitle", &PushNotificationManagerIOSSpec_Notification::alertTitle}, + {L"fireDate", &PushNotificationManagerIOSSpec_Notification::fireDate}, + {L"alertBody", &PushNotificationManagerIOSSpec_Notification::alertBody}, + {L"alertAction", &PushNotificationManagerIOSSpec_Notification::alertAction}, + {L"userInfo", &PushNotificationManagerIOSSpec_Notification::userInfo}, + {L"category", &PushNotificationManagerIOSSpec_Notification::category}, + {L"repeatInterval", &PushNotificationManagerIOSSpec_Notification::repeatInterval}, + {L"applicationIconBadgeNumber", &PushNotificationManagerIOSSpec_Notification::applicationIconBadgeNumber}, + {L"isSilent", &PushNotificationManagerIOSSpec_Notification::isSilent}, + {L"soundName", &PushNotificationManagerIOSSpec_Notification::soundName}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PushNotificationManagerIOSSpec_requestPermissions_permission*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"alert", &PushNotificationManagerIOSSpec_requestPermissions_permission::alert}, + {L"badge", &PushNotificationManagerIOSSpec_requestPermissions_permission::badge}, + {L"sound", &PushNotificationManagerIOSSpec_requestPermissions_permission::sound}, + }; + return fieldMap; +} + struct PushNotificationManagerIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"onFinishRemoteNotification"}, diff --git a/vnext/codegen/NativeRedBoxSpec.g.h b/vnext/codegen/NativeRedBoxSpec.g.h index e2eca8c3fe2..c6ef7c88d3b 100644 --- a/vnext/codegen/NativeRedBoxSpec.g.h +++ b/vnext/codegen/NativeRedBoxSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct RedBoxSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"setExtraData"}, diff --git a/vnext/codegen/NativeSampleTurboModuleSpec.g.h b/vnext/codegen/NativeSampleTurboModuleSpec.g.h index 2315a9e157d..8e3bb04d554 100644 --- a/vnext/codegen/NativeSampleTurboModuleSpec.g.h +++ b/vnext/codegen/NativeSampleTurboModuleSpec.g.h @@ -8,21 +8,27 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(SampleTurboModuleSpec_Constants) struct SampleTurboModuleSpec_Constants { - REACT_FIELD(const1) bool const1; - REACT_FIELD(const2) double const2; - REACT_FIELD(const3) std::string const3; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(SampleTurboModuleSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"const1", &SampleTurboModuleSpec_Constants::const1}, + {L"const2", &SampleTurboModuleSpec_Constants::const2}, + {L"const3", &SampleTurboModuleSpec_Constants::const3}, + }; + return fieldMap; +} + struct SampleTurboModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeSegmentFetcherSpec.g.h b/vnext/codegen/NativeSegmentFetcherSpec.g.h index 3c69bf330ab..da91959a07b 100644 --- a/vnext/codegen/NativeSegmentFetcherSpec.g.h +++ b/vnext/codegen/NativeSegmentFetcherSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct SegmentFetcherSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method>) noexcept>{0, L"fetchSegment"}, diff --git a/vnext/codegen/NativeSettingsManagerSpec.g.h b/vnext/codegen/NativeSettingsManagerSpec.g.h index ba3647cc225..ef1fdcee8b7 100644 --- a/vnext/codegen/NativeSettingsManagerSpec.g.h +++ b/vnext/codegen/NativeSettingsManagerSpec.g.h @@ -8,17 +8,23 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(SettingsManagerSpec_Constants) struct SettingsManagerSpec_Constants { - REACT_FIELD(settings) ::React::JSValue settings; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(SettingsManagerSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"settings", &SettingsManagerSpec_Constants::settings}, + }; + return fieldMap; +} + struct SettingsManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeShareModuleSpec.g.h b/vnext/codegen/NativeShareModuleSpec.g.h index 16de5b544e0..e464e8ef122 100644 --- a/vnext/codegen/NativeShareModuleSpec.g.h +++ b/vnext/codegen/NativeShareModuleSpec.g.h @@ -8,25 +8,36 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ShareModuleSpec_share_content) struct ShareModuleSpec_share_content { - REACT_FIELD(title) std::optional title; - REACT_FIELD(message) std::optional message; }; -REACT_STRUCT(ShareModuleSpec_share_returnType) struct ShareModuleSpec_share_returnType { - REACT_FIELD(action) std::string action; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ShareModuleSpec_share_content*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"title", &ShareModuleSpec_share_content::title}, + {L"message", &ShareModuleSpec_share_content::message}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ShareModuleSpec_share_returnType*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"action", &ShareModuleSpec_share_returnType::action}, + }; + return fieldMap; +} + struct ShareModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method) noexcept>{0, L"share"}, diff --git a/vnext/codegen/NativeSoundManagerSpec.g.h b/vnext/codegen/NativeSoundManagerSpec.g.h index b0d5e61ef95..bda018e0562 100644 --- a/vnext/codegen/NativeSoundManagerSpec.g.h +++ b/vnext/codegen/NativeSoundManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct SoundManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"playTouchSound"}, diff --git a/vnext/codegen/NativeSourceCodeSpec.g.h b/vnext/codegen/NativeSourceCodeSpec.g.h index 0888ca01499..13f67a3ebad 100644 --- a/vnext/codegen/NativeSourceCodeSpec.g.h +++ b/vnext/codegen/NativeSourceCodeSpec.g.h @@ -8,17 +8,23 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(SourceCodeSpec_Constants) struct SourceCodeSpec_Constants { - REACT_FIELD(scriptURL) std::string scriptURL; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(SourceCodeSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"scriptURL", &SourceCodeSpec_Constants::scriptURL}, + }; + return fieldMap; +} + struct SourceCodeSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeStatusBarManagerAndroidSpec.g.h b/vnext/codegen/NativeStatusBarManagerAndroidSpec.g.h index bd6988fa7a1..5e88242e4e3 100644 --- a/vnext/codegen/NativeStatusBarManagerAndroidSpec.g.h +++ b/vnext/codegen/NativeStatusBarManagerAndroidSpec.g.h @@ -8,19 +8,25 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(StatusBarManagerAndroidSpec_Constants) struct StatusBarManagerAndroidSpec_Constants { - REACT_FIELD(HEIGHT) double HEIGHT; - REACT_FIELD(DEFAULT_BACKGROUND_COLOR) double DEFAULT_BACKGROUND_COLOR; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(StatusBarManagerAndroidSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"HEIGHT", &StatusBarManagerAndroidSpec_Constants::HEIGHT}, + {L"DEFAULT_BACKGROUND_COLOR", &StatusBarManagerAndroidSpec_Constants::DEFAULT_BACKGROUND_COLOR}, + }; + return fieldMap; +} + struct StatusBarManagerAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeStatusBarManagerIOSSpec.g.h b/vnext/codegen/NativeStatusBarManagerIOSSpec.g.h index d3a74293ac0..fc91d65d92f 100644 --- a/vnext/codegen/NativeStatusBarManagerIOSSpec.g.h +++ b/vnext/codegen/NativeStatusBarManagerIOSSpec.g.h @@ -8,25 +8,36 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(StatusBarManagerIOSSpec_getHeight_callback_result) struct StatusBarManagerIOSSpec_getHeight_callback_result { - REACT_FIELD(height) double height; }; -REACT_STRUCT(StatusBarManagerIOSSpec_Constants) struct StatusBarManagerIOSSpec_Constants { - REACT_FIELD(HEIGHT) double HEIGHT; - REACT_FIELD(DEFAULT_BACKGROUND_COLOR) std::optional DEFAULT_BACKGROUND_COLOR; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(StatusBarManagerIOSSpec_getHeight_callback_result*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"height", &StatusBarManagerIOSSpec_getHeight_callback_result::height}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(StatusBarManagerIOSSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"HEIGHT", &StatusBarManagerIOSSpec_Constants::HEIGHT}, + {L"DEFAULT_BACKGROUND_COLOR", &StatusBarManagerIOSSpec_Constants::DEFAULT_BACKGROUND_COLOR}, + }; + return fieldMap; +} + struct StatusBarManagerIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeTimingSpec.g.h b/vnext/codegen/NativeTimingSpec.g.h index 38d0604886a..9e13a81d129 100644 --- a/vnext/codegen/NativeTimingSpec.g.h +++ b/vnext/codegen/NativeTimingSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct TimingSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"createTimer"}, diff --git a/vnext/codegen/NativeToastAndroidSpec.g.h b/vnext/codegen/NativeToastAndroidSpec.g.h index 7f0e74e33c1..ddc51e3e8bb 100644 --- a/vnext/codegen/NativeToastAndroidSpec.g.h +++ b/vnext/codegen/NativeToastAndroidSpec.g.h @@ -8,25 +8,31 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(ToastAndroidSpec_Constants) struct ToastAndroidSpec_Constants { - REACT_FIELD(SHORT) double SHORT; - REACT_FIELD(LONG) double LONG; - REACT_FIELD(TOP) double TOP; - REACT_FIELD(BOTTOM) double BOTTOM; - REACT_FIELD(CENTER) double CENTER; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(ToastAndroidSpec_Constants*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"SHORT", &ToastAndroidSpec_Constants::SHORT}, + {L"LONG", &ToastAndroidSpec_Constants::LONG}, + {L"TOP", &ToastAndroidSpec_Constants::TOP}, + {L"BOTTOM", &ToastAndroidSpec_Constants::BOTTOM}, + {L"CENTER", &ToastAndroidSpec_Constants::CENTER}, + }; + return fieldMap; +} + struct ToastAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto constants = std::tuple{ TypedConstant{0}, diff --git a/vnext/codegen/NativeUIManagerSpec.g.h b/vnext/codegen/NativeUIManagerSpec.g.h index 8358c0d03de..b463b8bf5a9 100644 --- a/vnext/codegen/NativeUIManagerSpec.g.h +++ b/vnext/codegen/NativeUIManagerSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct UIManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ SyncMethod<::React::JSValue(std::string) noexcept>{0, L"getConstantsForViewManager"}, diff --git a/vnext/codegen/NativeVibrationSpec.g.h b/vnext/codegen/NativeVibrationSpec.g.h index 44123f4e211..41b7edd44ab 100644 --- a/vnext/codegen/NativeVibrationSpec.g.h +++ b/vnext/codegen/NativeVibrationSpec.g.h @@ -8,11 +8,12 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { + struct VibrationSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method{0, L"vibrate"}, diff --git a/vnext/codegen/NativeWebSocketModuleSpec.g.h b/vnext/codegen/NativeWebSocketModuleSpec.g.h index 992184c2372..a73f9ddb8f0 100644 --- a/vnext/codegen/NativeWebSocketModuleSpec.g.h +++ b/vnext/codegen/NativeWebSocketModuleSpec.g.h @@ -8,17 +8,23 @@ */ #pragma once -#include "NativeModules.h" +#include #include namespace Microsoft::ReactNativeSpecs { -REACT_STRUCT(WebSocketModuleSpec_connect_options) struct WebSocketModuleSpec_connect_options { - REACT_FIELD(headers) std::optional<::React::JSValue> headers; }; + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(WebSocketModuleSpec_connect_options*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"headers", &WebSocketModuleSpec_connect_options::headers}, + }; + return fieldMap; +} + struct WebSocketModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { static constexpr auto methods = std::tuple{ Method>, WebSocketModuleSpec_connect_options, double) noexcept>{0, L"connect"},