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" +} 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 diff --git a/vnext/codegen/rnwcoreJSI-generated.cpp b/vnext/codegen/rnwcoreJSI-generated.cpp index 75d575959e6..f91c5cbcd62 100644 --- a/vnext/codegen/rnwcoreJSI-generated.cpp +++ b/vnext/codegen/rnwcoreJSI-generated.cpp @@ -1924,15 +1924,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 40276abfe17..0bea408f5e1 100644 --- a/vnext/codegen/rnwcoreJSI.h +++ b/vnext/codegen/rnwcoreJSI.h @@ -5677,9 +5677,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; @@ -5687,7 +5687,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); @@ -5696,15 +5696,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( diff --git a/vnext/overrides.json b/vnext/overrides.json index 9897a9402ee..ee364a1b92b 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -573,9 +573,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