From 64a6d6a31ffaee0069eee00f75418cb5eafa9537 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Thu, 28 Mar 2024 10:25:24 -0400 Subject: [PATCH 1/4] Renames TM spec Using fully qualified platform name as module suffix helps with some integration with mobile TM codegen. --- vnext/overrides.json | 4 ++-- .../src-win/Libraries/Utilities/NativePlatformConstantsWin.js | 4 ++-- ...tformConstantsWin.js => NativePlatformConstantsWindows.js} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename vnext/src-win/src/private/specs/modules/{NativePlatformConstantsWin.js => NativePlatformConstantsWindows.js} (100%) diff --git a/vnext/overrides.json b/vnext/overrides.json index d8abe632d9d..9495f9a9641 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -514,9 +514,9 @@ }, { "type": "derived", - "file": "src-win/src/private/specs/modules/NativePlatformConstantsWin.js", + "file": "src-win/src/private/specs/modules/NativePlatformConstantsWindows.js", "baseFile": "packages/react-native/src/private/specs/modules/NativePlatformConstantsAndroid.js", "baseHash": "b4a125d9134f33aeaba9e06988e18cbb0b4e9e9c" } ] -} \ No newline at end of file +} diff --git a/vnext/src-win/Libraries/Utilities/NativePlatformConstantsWin.js b/vnext/src-win/Libraries/Utilities/NativePlatformConstantsWin.js index cfdc82d31f8..af5aef8d9e7 100644 --- a/vnext/src-win/Libraries/Utilities/NativePlatformConstantsWin.js +++ b/vnext/src-win/Libraries/Utilities/NativePlatformConstantsWin.js @@ -6,6 +6,6 @@ * @flow strict */ -export * from '../../src/private/specs/modules/NativePlatformConstantsWin'; -import NativePlatformConstantsWin from '../../src/private/specs/modules/NativePlatformConstantsWin'; +export * from '../../src/private/specs/modules/NativePlatformConstantsWindows'; +import NativePlatformConstantsWin from '../../src/private/specs/modules/NativePlatformConstantsWindows'; export default NativePlatformConstantsWin; diff --git a/vnext/src-win/src/private/specs/modules/NativePlatformConstantsWin.js b/vnext/src-win/src/private/specs/modules/NativePlatformConstantsWindows.js similarity index 100% rename from vnext/src-win/src/private/specs/modules/NativePlatformConstantsWin.js rename to vnext/src-win/src/private/specs/modules/NativePlatformConstantsWindows.js From 7aa5d3d1f781129ccc5d42205ef0f18c8718a697 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Thu, 28 Mar 2024 10:29:27 -0400 Subject: [PATCH 2/4] Change files --- ...ative-windows-9639090f-41d1-4491-bb9f-772765cb5824.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-9639090f-41d1-4491-bb9f-772765cb5824.json diff --git a/change/react-native-windows-9639090f-41d1-4491-bb9f-772765cb5824.json b/change/react-native-windows-9639090f-41d1-4491-bb9f-772765cb5824.json new file mode 100644 index 00000000000..c2e043591c1 --- /dev/null +++ b/change/react-native-windows-9639090f-41d1-4491-bb9f-772765cb5824.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Renames TM spec", + "packageName": "react-native-windows", + "email": "ericroz@meta.com", + "dependentChangeType": "patch" +} From 4c19c469fb3892afcbb83c27c6d5d96d9fb5b23e Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Fri, 29 Mar 2024 10:49:12 -0400 Subject: [PATCH 3/4] Fixup codegen files --- .../Modules/PlatformConstantsWinModule.cpp | 4 +- .../Modules/PlatformConstantsWinModule.h | 6 +- .../NativePlatformConstantsWinSpec.g.h | 81 ------------------- .../NativePlatformConstantsWindowsSpec.g.h | 81 +++++++++++++++++++ 4 files changed, 86 insertions(+), 86 deletions(-) delete mode 100644 vnext/codegen/NativePlatformConstantsWinSpec.g.h create mode 100644 vnext/codegen/NativePlatformConstantsWindowsSpec.g.h diff --git a/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp b/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp index cdbe4488b89..a9408ea91b5 100644 --- a/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp @@ -10,8 +10,8 @@ namespace Microsoft::ReactNative { -ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows PlatformConstants::GetConstants() noexcept { - ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows constants; +ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows PlatformConstants::GetConstants() noexcept { + ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows constants; // We don't currently treat Native code differently in a test environment constants.isTesting = false; diff --git a/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h b/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h index f8cbe7e2e5e..1d82ee908c2 100644 --- a/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h +++ b/vnext/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h @@ -2,17 +2,17 @@ // Licensed under the MIT License. #pragma once -#include "codegen/NativePlatformConstantsWinSpec.g.h" +#include "codegen/NativePlatformConstantsWindowsSpec.g.h" #include namespace Microsoft::ReactNative { REACT_MODULE(PlatformConstants) struct PlatformConstants { - using ModuleSpec = ReactNativeSpecs::PlatformConstantsWinSpec; + using ModuleSpec = ReactNativeSpecs::PlatformConstantsWindowsSpec; REACT_GET_CONSTANTS(GetConstants) - ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows GetConstants() noexcept; + ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows GetConstants() noexcept; }; } // namespace Microsoft::ReactNative diff --git a/vnext/codegen/NativePlatformConstantsWinSpec.g.h b/vnext/codegen/NativePlatformConstantsWinSpec.g.h deleted file mode 100644 index 8b991c7a120..00000000000 --- a/vnext/codegen/NativePlatformConstantsWinSpec.g.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* - * This file is auto-generated from a NativeModule spec file in js. - * - * This is a C++ Spec class that should be used with MakeTurboModuleProvider to register native modules - * in a way that also verifies at compile time that the native module matches the interface required - * by the TurboModule JS spec. - */ -#pragma once - -#include -#include - -namespace Microsoft::ReactNativeSpecs { - -struct PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion { - double major; - double minor; - double patch; - std::optional prerelease; -}; - -struct PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion { - double major; - double minor; - double patch; -}; - -struct PlatformConstantsWinSpec_PlatformConstantsWindows { - bool isTesting; - std::optional isDisableAnimations; - PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion reactNativeVersion; - PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion reactNativeWindowsVersion; - double osVersion; -}; - - -inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion*) noexcept { - winrt::Microsoft::ReactNative::FieldMap fieldMap { - {L"major", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion::major}, - {L"minor", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion::minor}, - {L"patch", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion::patch}, - {L"prerelease", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeVersion::prerelease}, - }; - return fieldMap; -} - -inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion*) noexcept { - winrt::Microsoft::ReactNative::FieldMap fieldMap { - {L"major", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion::major}, - {L"minor", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion::minor}, - {L"patch", &PlatformConstantsWinSpec_PlatformConstantsWindows_reactNativeWindowsVersion::patch}, - }; - return fieldMap; -} - -inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWinSpec_PlatformConstantsWindows*) noexcept { - winrt::Microsoft::ReactNative::FieldMap fieldMap { - {L"isTesting", &PlatformConstantsWinSpec_PlatformConstantsWindows::isTesting}, - {L"isDisableAnimations", &PlatformConstantsWinSpec_PlatformConstantsWindows::isDisableAnimations}, - {L"reactNativeVersion", &PlatformConstantsWinSpec_PlatformConstantsWindows::reactNativeVersion}, - {L"reactNativeWindowsVersion", &PlatformConstantsWinSpec_PlatformConstantsWindows::reactNativeWindowsVersion}, - {L"osVersion", &PlatformConstantsWinSpec_PlatformConstantsWindows::osVersion}, - }; - return fieldMap; -} - -struct PlatformConstantsWinSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { - static constexpr auto methods = std::tuple{ - - }; - - template - static constexpr void ValidateModule() noexcept { - constexpr auto methodCheckResults = CheckMethods(); - - - } -}; - -} // namespace Microsoft::ReactNativeSpecs diff --git a/vnext/codegen/NativePlatformConstantsWindowsSpec.g.h b/vnext/codegen/NativePlatformConstantsWindowsSpec.g.h new file mode 100644 index 00000000000..584f5d69187 --- /dev/null +++ b/vnext/codegen/NativePlatformConstantsWindowsSpec.g.h @@ -0,0 +1,81 @@ + +/* + * This file is auto-generated from a NativeModule spec file in js. + * + * This is a C++ Spec class that should be used with MakeTurboModuleProvider to register native modules + * in a way that also verifies at compile time that the native module matches the interface required + * by the TurboModule JS spec. + */ +#pragma once + +#include +#include + +namespace Microsoft::ReactNativeSpecs { + +struct PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion { + double major; + double minor; + double patch; + std::optional prerelease; +}; + +struct PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion { + double major; + double minor; + double patch; +}; + +struct PlatformConstantsWindowsSpec_PlatformConstantsWindows { + bool isTesting; + std::optional isDisableAnimations; + PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion reactNativeVersion; + PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion reactNativeWindowsVersion; + double osVersion; +}; + + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"major", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::major}, + {L"minor", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::minor}, + {L"patch", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::patch}, + {L"prerelease", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::prerelease}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"major", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::major}, + {L"minor", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::minor}, + {L"patch", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::patch}, + }; + return fieldMap; +} + +inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows*) noexcept { + winrt::Microsoft::ReactNative::FieldMap fieldMap { + {L"isTesting", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::isTesting}, + {L"isDisableAnimations", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::isDisableAnimations}, + {L"reactNativeVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::reactNativeVersion}, + {L"reactNativeWindowsVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::reactNativeWindowsVersion}, + {L"osVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::osVersion}, + }; + return fieldMap; +} + +struct PlatformConstantsWindowsSpec : winrt::Microsoft::ReactNative::TurboModuleSpec { + static constexpr auto methods = std::tuple{ + + }; + + template + static constexpr void ValidateModule() noexcept { + constexpr auto methodCheckResults = CheckMethods(); + + + } +}; + +} // namespace Microsoft::ReactNativeSpecs From f60f98d0a917b60b9d5842fe5fbed8e68cce60f5 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Fri, 29 Mar 2024 12:47:52 -0400 Subject: [PATCH 4/4] Adds output of yarn build --- vnext/codegen/rnwcoreJSI-generated.cpp | 8 ++++---- vnext/codegen/rnwcoreJSI.h | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vnext/codegen/rnwcoreJSI-generated.cpp b/vnext/codegen/rnwcoreJSI-generated.cpp index 5ea46f646fb..c6295d3ee77 100644 --- a/vnext/codegen/rnwcoreJSI-generated.cpp +++ b/vnext/codegen/rnwcoreJSI-generated.cpp @@ -1894,15 +1894,15 @@ NativePlatformConstantsIOSCxxSpecJSI::NativePlatformConstantsIOSCxxSpecJSI(std:: : TurboModule("PlatformConstants", jsInvoker) { methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsIOSCxxSpecJSI_getConstants}; } -static jsi::Value __hostFunction_NativePlatformConstantsWinCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getConstants( +static jsi::Value __hostFunction_NativePlatformConstantsWindowsCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getConstants( rt ); } -NativePlatformConstantsWinCxxSpecJSI::NativePlatformConstantsWinCxxSpecJSI(std::shared_ptr jsInvoker) +NativePlatformConstantsWindowsCxxSpecJSI::NativePlatformConstantsWindowsCxxSpecJSI(std::shared_ptr jsInvoker) : TurboModule("PlatformConstants", jsInvoker) { - methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsWinCxxSpecJSI_getConstants}; + methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsWindowsCxxSpecJSI_getConstants}; } static jsi::Value __hostFunction_NativePushNotificationManagerIOSCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getConstants( diff --git a/vnext/codegen/rnwcoreJSI.h b/vnext/codegen/rnwcoreJSI.h index 2d12abef8bd..f6706e795ab 100644 --- a/vnext/codegen/rnwcoreJSI.h +++ b/vnext/codegen/rnwcoreJSI.h @@ -7462,9 +7462,9 @@ struct PlatformConstantsPlatformConstantsWindowsBridging { } }; -class JSI_EXPORT NativePlatformConstantsWinCxxSpecJSI : public TurboModule { +class JSI_EXPORT NativePlatformConstantsWindowsCxxSpecJSI : public TurboModule { protected: - NativePlatformConstantsWinCxxSpecJSI(std::shared_ptr jsInvoker); + NativePlatformConstantsWindowsCxxSpecJSI(std::shared_ptr jsInvoker); public: virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; @@ -7472,7 +7472,7 @@ class JSI_EXPORT NativePlatformConstantsWinCxxSpecJSI : public TurboModule { }; template -class JSI_EXPORT NativePlatformConstantsWinCxxSpec : public TurboModule { +class JSI_EXPORT NativePlatformConstantsWindowsCxxSpec : public TurboModule { public: jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { return delegate_.get(rt, propName); @@ -7481,15 +7481,15 @@ class JSI_EXPORT NativePlatformConstantsWinCxxSpec : public TurboModule { static constexpr std::string_view kModuleName = "PlatformConstants"; protected: - NativePlatformConstantsWinCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativePlatformConstantsWinCxxSpec::kModuleName}, jsInvoker), + NativePlatformConstantsWindowsCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativePlatformConstantsWindowsCxxSpec::kModuleName}, jsInvoker), delegate_(reinterpret_cast(this), jsInvoker) {} private: - class Delegate : public NativePlatformConstantsWinCxxSpecJSI { + class Delegate : public NativePlatformConstantsWindowsCxxSpecJSI { public: Delegate(T *instance, std::shared_ptr jsInvoker) : - NativePlatformConstantsWinCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + NativePlatformConstantsWindowsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} jsi::Object getConstants(jsi::Runtime &rt) override { static_assert(