Skip to content

Commit dc1089a

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Add ReactNativeVersion.h to react/utils (#58403)
Summary: Pull Request resolved: #58403 Changelog: [General][Added] - Added `ReactNativeVersion.h` to public `react/utils` module. Existing one inside private `cxxreact/bridge` module is now deprecated and still accessible when not opted in to `RN_STRICT_API`. Reviewed By: javache Differential Revision: D119163947
1 parent 1f20445 commit dc1089a

8 files changed

Lines changed: 51 additions & 28 deletions

File tree

packages/react-native/ReactCommon/cxxreact/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ target_link_libraries(react_cxxreact
2424
jsinspector
2525
logger
2626
react_cxxstableapi
27+
react_utils
2728
reactperflogger
2829
runtimeexecutor
2930
react_debug)
Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
1-
/**
1+
/*
22
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @generated by scripts/releases/set-version.js
86
*/
97

108
#pragma once
119

1210
#include <react/cxxstableapi/PrivateGuard.h>
1311

14-
#include <cstdint>
15-
#include <string_view>
16-
17-
#define REACT_NATIVE_VERSION_MAJOR 1000
18-
#define REACT_NATIVE_VERSION_MINOR 0
19-
#define REACT_NATIVE_VERSION_PATCH 0
20-
21-
namespace facebook::react {
12+
#warning "Deprecated: use <React/Utils.h> instead."
2213

23-
struct ReactNativeVersionType {
24-
int32_t Major = 1000;
25-
int32_t Minor = 0;
26-
int32_t Patch = 0;
27-
std::string_view Prerelease = "";
28-
};
14+
#pragma push_macro("RN_UMBRELLA_CONTEXT")
15+
#undef RN_UMBRELLA_CONTEXT
16+
#define RN_UMBRELLA_CONTEXT 1
2917

30-
constexpr ReactNativeVersionType ReactNativeVersion;
18+
#include <react/utils/ReactNativeVersion.h>
3119

32-
} // namespace facebook::react
20+
#undef RN_UMBRELLA_CONTEXT
21+
#pragma pop_macro("RN_UMBRELLA_CONTEXT")

packages/react-native/ReactCommon/react/utils/React/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <react/utils/MoveWrapper.h>
3535
#include <react/utils/OnScopeExit.h>
3636
#include <react/utils/PackTraits.h>
37+
#include <react/utils/ReactNativeVersion.h>
3738
#include <react/utils/RunLoopObserver.h>
3839
#include <react/utils/SharedFunction.h>
3940
#include <react/utils/SimpleThreadSafeCache.h>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @generated by scripts/releases/set-version.js
8+
*/
9+
10+
#pragma once
11+
12+
#include <react/cxxstableapi/UmbrellaGuard.h>
13+
14+
#include <cstdint>
15+
#include <string_view>
16+
17+
#define REACT_NATIVE_VERSION_MAJOR 1000
18+
#define REACT_NATIVE_VERSION_MINOR 0
19+
#define REACT_NATIVE_VERSION_PATCH 0
20+
21+
namespace facebook::react {
22+
23+
struct ReactNativeVersionType {
24+
int32_t Major = 1000;
25+
int32_t Minor = 0;
26+
int32_t Patch = 0;
27+
std::string_view Prerelease = "";
28+
};
29+
30+
constexpr ReactNativeVersionType ReactNativeVersion;
31+
32+
} // namespace facebook::react

scripts/releases/__tests__/__snapshots__/set-rn-artifacts-version-test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public object ReactNativeVersion {
117117
"
118118
`;
119119
120-
exports[`updateReactNativeArtifacts should set nightly version: packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h 1`] = `
120+
exports[`updateReactNativeArtifacts should set nightly version: packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h 1`] = `
121121
"/**
122122
* Copyright (c) Meta Platforms, Inc. and affiliates.
123123
*
@@ -129,7 +129,7 @@ exports[`updateReactNativeArtifacts should set nightly version: packages/react-n
129129
130130
#pragma once
131131
132-
#include <react/cxxstableapi/PrivateGuard.h>
132+
#include <react/cxxstableapi/UmbrellaGuard.h>
133133
134134
#include <cstdint>
135135
#include <string_view>
@@ -276,7 +276,7 @@ public object ReactNativeVersion {
276276
"
277277
`;
278278
279-
exports[`updateReactNativeArtifacts should set release version: packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h 1`] = `
279+
exports[`updateReactNativeArtifacts should set release version: packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h 1`] = `
280280
"/**
281281
* Copyright (c) Meta Platforms, Inc. and affiliates.
282282
*
@@ -288,7 +288,7 @@ exports[`updateReactNativeArtifacts should set release version: packages/react-n
288288
289289
#pragma once
290290
291-
#include <react/cxxstableapi/PrivateGuard.h>
291+
#include <react/cxxstableapi/UmbrellaGuard.h>
292292
293293
#include <cstdint>
294294
#include <string_view>

scripts/releases/__tests__/__snapshots__/set-version-test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ exports[`setVersion updates monorepo for nightly: set-version/packages/react-nat
6565

6666
exports[`setVersion updates monorepo for nightly: set-version/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt 1`] = `"[omitted]"`;
6767

68-
exports[`setVersion updates monorepo for nightly: set-version/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h 1`] = `"[omitted]"`;
68+
exports[`setVersion updates monorepo for nightly: set-version/packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h 1`] = `"[omitted]"`;
6969

7070
exports[`setVersion updates monorepo for nightly: set-version/packages/react-native/package.json 1`] = `
7171
"{
@@ -148,7 +148,7 @@ exports[`setVersion updates monorepo for release-candidate: set-version/packages
148148

149149
exports[`setVersion updates monorepo for release-candidate: set-version/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt 1`] = `"[omitted]"`;
150150

151-
exports[`setVersion updates monorepo for release-candidate: set-version/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h 1`] = `"[omitted]"`;
151+
exports[`setVersion updates monorepo for release-candidate: set-version/packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h 1`] = `"[omitted]"`;
152152

153153
exports[`setVersion updates monorepo for release-candidate: set-version/packages/react-native/package.json 1`] = `
154154
"{
@@ -231,7 +231,7 @@ exports[`setVersion updates monorepo for stable version: set-version/packages/re
231231

232232
exports[`setVersion updates monorepo for stable version: set-version/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt 1`] = `"[omitted]"`;
233233

234-
exports[`setVersion updates monorepo for stable version: set-version/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h 1`] = `"[omitted]"`;
234+
exports[`setVersion updates monorepo for stable version: set-version/packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h 1`] = `"[omitted]"`;
235235

236236
exports[`setVersion updates monorepo for stable version: set-version/packages/react-native/package.json 1`] = `
237237
"{

scripts/releases/set-rn-artifacts-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function updateSourceFiles(
104104
fs.writeFile(
105105
path.join(
106106
REPO_ROOT,
107-
'packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h',
107+
'packages/react-native/ReactCommon/react/utils/ReactNativeVersion.h',
108108
),
109109
require('./templates/ReactNativeVersion.h-template')(templateData),
110110
),

scripts/releases/templates/ReactNativeVersion.h-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = ({version} /*: {version: Version} */) /*: string */ => `/**
2323
2424
#pragma once
2525
26-
#include <react/cxxstableapi/PrivateGuard.h>
26+
#include <react/cxxstableapi/UmbrellaGuard.h>
2727
2828
#include <cstdint>
2929
#include <string_view>

0 commit comments

Comments
 (0)