Skip to content

Commit 929099f

Browse files
andrewdacenkofacebook-github-bot
authored andcommitted
Move rncxx coremodules
Summary: Changelog: [Internal] Reviewed By: rshest Differential Revision: D72875329 fbshipit-source-id: 86578362f99210dbe8aa990991829760fa61daf8
1 parent 706b6e8 commit 929099f

File tree

6 files changed

+250
-0
lines changed

6 files changed

+250
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
8+
#include "AppStateModule.h"
9+
10+
namespace facebook::react {
11+
12+
AppStateConstants AppStateModule::getConstants(jsi::Runtime& /*rt*/) {
13+
// TODO: T160890586 Wire up AppState implementation to use real data
14+
return AppStateConstants{.initialAppState = ""};
15+
}
16+
17+
void AppStateModule::getCurrentAppState(
18+
jsi::Runtime& /*rt*/,
19+
const AsyncCallback<AppState>& /*success*/,
20+
jsi::Function /*error*/) {}
21+
22+
void AppStateModule::addListener(
23+
jsi::Runtime& /*rt*/,
24+
const std::string& /*eventName*/) {}
25+
26+
void AppStateModule::removeListeners(jsi::Runtime& /*rt*/, double /*count*/) {}
27+
28+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
8+
#pragma once
9+
10+
#include <FBReactNativeSpec/FBReactNativeSpecJSI.h>
11+
#include <memory>
12+
#include <string>
13+
14+
namespace facebook::react {
15+
16+
using AppStateConstants = NativeAppStateAppStateConstants<std::string>;
17+
18+
template <>
19+
struct Bridging<AppStateConstants>
20+
: NativeAppStateAppStateConstantsBridging<AppStateConstants> {};
21+
22+
using AppState = NativeAppStateAppState<std::string>;
23+
24+
template <>
25+
struct Bridging<AppState> : NativeAppStateAppStateBridging<AppState> {};
26+
27+
class AppStateModule : public NativeAppStateCxxSpec<AppStateModule> {
28+
public:
29+
explicit AppStateModule(std::shared_ptr<CallInvoker> jsInvoker)
30+
: NativeAppStateCxxSpec(jsInvoker) {}
31+
32+
AppStateConstants getConstants(jsi::Runtime& rt);
33+
34+
void getCurrentAppState(
35+
jsi::Runtime& rt,
36+
const AsyncCallback<AppState>& success,
37+
jsi::Function error);
38+
void addListener(jsi::Runtime& rt, const std::string& eventName);
39+
40+
void removeListeners(jsi::Runtime& rt, double count);
41+
};
42+
43+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
8+
#include "DeviceInfoModule.h"
9+
10+
namespace facebook::react {
11+
12+
DeviceInfoConstants DeviceInfoModule::getConstants(jsi::Runtime& /*rt*/) {
13+
// TODO: Wire this to come from the actual app
14+
// size (T161837708)
15+
return DeviceInfoConstants{
16+
.Dimensions =
17+
{.window =
18+
DisplayMetrics{
19+
1280,
20+
720,
21+
}},
22+
};
23+
}
24+
25+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
8+
#pragma once
9+
10+
#include <FBReactNativeSpec/FBReactNativeSpecJSI.h>
11+
#include <optional>
12+
13+
namespace facebook::react {
14+
15+
using DisplayMetrics =
16+
NativeDeviceInfoDisplayMetrics<double, double, double, double>;
17+
18+
using DisplayMetricsAndroid = NativeDeviceInfoDisplayMetricsAndroid<
19+
double,
20+
double,
21+
double,
22+
double,
23+
double>;
24+
25+
using DimensionsPayload = NativeDeviceInfoDimensionsPayload<
26+
std::optional<DisplayMetrics>,
27+
std::optional<DisplayMetrics>,
28+
std::optional<DisplayMetricsAndroid>,
29+
std::optional<DisplayMetricsAndroid>>;
30+
31+
using DeviceInfoConstants =
32+
NativeDeviceInfoDeviceInfoConstants<DimensionsPayload, std::optional<bool>>;
33+
34+
template <>
35+
struct Bridging<DisplayMetrics>
36+
: NativeDeviceInfoDisplayMetricsBridging<DisplayMetrics> {};
37+
38+
template <>
39+
struct Bridging<DisplayMetricsAndroid>
40+
: NativeDeviceInfoDisplayMetricsAndroidBridging<DisplayMetricsAndroid> {};
41+
42+
template <>
43+
struct Bridging<DimensionsPayload>
44+
: NativeDeviceInfoDimensionsPayloadBridging<DimensionsPayload> {};
45+
46+
template <>
47+
struct Bridging<DeviceInfoConstants>
48+
: NativeDeviceInfoDeviceInfoConstantsBridging<DeviceInfoConstants> {};
49+
50+
class DeviceInfoModule : public NativeDeviceInfoCxxSpec<DeviceInfoModule> {
51+
public:
52+
explicit DeviceInfoModule(std::shared_ptr<CallInvoker> jsInvoker)
53+
: NativeDeviceInfoCxxSpec(jsInvoker) {}
54+
55+
DeviceInfoConstants getConstants(jsi::Runtime& rt);
56+
};
57+
58+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
8+
#include "PlatformConstantsModule.h"
9+
10+
namespace facebook::react {
11+
12+
PlatformConstantsAndroid PlatformConstantsModule::getConstants(
13+
jsi::Runtime& /*rt*/) {
14+
return PlatformConstantsAndroid{
15+
.isTesting = false,
16+
.isDisableAnimations = false,
17+
.reactNativeVersion =
18+
{
19+
.major = 1000,
20+
.minor = 0,
21+
.patch = 0,
22+
.prerelease = std::nullopt,
23+
},
24+
.Version = 33, // Android 13 (API level 33)
25+
.Release = "",
26+
.Fingerprint = "",
27+
.Model = "",
28+
.ServerHost = "",
29+
.uiMode = "",
30+
.Brand = "",
31+
.Manufacturer = "",
32+
};
33+
}
34+
35+
} // namespace facebook::react
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
8+
#pragma once
9+
10+
#include <FBReactNativeSpec/FBReactNativeSpecJSI.h>
11+
#include <optional>
12+
13+
namespace facebook::react {
14+
15+
using ReactNativeVersionAndroid =
16+
NativePlatformConstantsAndroidReactNativeVersionAndroid<
17+
int,
18+
int,
19+
int,
20+
std::optional<int>>;
21+
22+
template <>
23+
struct Bridging<ReactNativeVersionAndroid>
24+
: NativePlatformConstantsAndroidReactNativeVersionAndroidBridging<
25+
ReactNativeVersionAndroid> {};
26+
27+
using PlatformConstantsAndroid =
28+
NativePlatformConstantsAndroidPlatformConstantsAndroid<
29+
bool,
30+
std::optional<bool>,
31+
ReactNativeVersionAndroid,
32+
int,
33+
std::string,
34+
std::string,
35+
std::string,
36+
std::string,
37+
std::optional<std::string>,
38+
std::string,
39+
std::string,
40+
std::string>;
41+
42+
template <>
43+
struct Bridging<PlatformConstantsAndroid>
44+
: NativePlatformConstantsAndroidPlatformConstantsAndroidBridging<
45+
PlatformConstantsAndroid> {};
46+
47+
// T159303412: [RN] Metro: Need support for new target platform
48+
class PlatformConstantsModule
49+
: public NativePlatformConstantsAndroidCxxSpec<PlatformConstantsModule> {
50+
public:
51+
explicit PlatformConstantsModule(std::shared_ptr<CallInvoker> jsInvoker)
52+
: NativePlatformConstantsAndroidCxxSpec(jsInvoker) {}
53+
54+
std::string getAndroidID(jsi::Runtime& /*rt*/) {
55+
return "";
56+
}
57+
58+
PlatformConstantsAndroid getConstants(jsi::Runtime& rt);
59+
};
60+
61+
} // namespace facebook::react

0 commit comments

Comments
 (0)