Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add Platform.constants.Release on Windows",
"packageName": "react-native-windows",
"email": "vivekjm77@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@
#include <VersionHelpers.h>
#include <cxxreact/ReactNativeVersion.h>
#include <winrt/Windows.Foundation.Metadata.h>
#include <winrt/Windows.System.Profile.h>

namespace Microsoft::ReactNative {

static std::string GetReleaseVersion() noexcept {
try {
const auto versionInfo = winrt::Windows::System::Profile::AnalyticsInfo::VersionInfo();
const auto version = std::stoull(winrt::to_string(versionInfo.DeviceFamilyVersion()));
return std::to_string((version & 0xFFFF000000000000ULL) >> 48) + "." +
std::to_string((version & 0x0000FFFF00000000ULL) >> 32) + "." +
std::to_string((version & 0x00000000FFFF0000ULL) >> 16) + "." +
std::to_string(version & 0x000000000000FFFFULL);
} catch (...) {
return "";
}
}

ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows PlatformConstants::GetConstants() noexcept {
ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows constants;

Expand Down Expand Up @@ -43,6 +57,8 @@ ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows Platform
}
}

constants.Release = GetReleaseVersion();

return constants;
}

Expand Down
1 change: 1 addition & 0 deletions vnext/src-win/Libraries/Utilities/Platform.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Platform: PlatformType = {
patch: number,
},
osVersion: number,
Release: string,
} {
// $FlowFixMe[object-this-reference]
if (this.__constants == null) {
Expand Down
1 change: 1 addition & 0 deletions vnext/src-win/Libraries/Utilities/PlatformTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type WindowsPlatform = {
patch: number,
},
osVersion: number,
Release: string,
},
// $FlowFixMe[unsafe-getters-setters]
get isTesting(): boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type PlatformConstantsWindows = {|
patch: number,
|},
osVersion: number,
Release: string,
|};

export interface Spec extends TurboModule {
Expand Down