react-native 0.84.0-nightly-20251115-e08abbcb9 → 0.84.0-nightly-20251116-d52b9d2f8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/jsi/jsi/jsi.h +6 -0
- package/ReactCommon/jsinspector-modern/tracing/TracingCategory.h +10 -5
- package/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h +0 -1
- package/ReactCommon/react/renderer/components/image/ImageProps.cpp +2 -2
- package/ReactCommon/react/renderer/components/image/ImageProps.h +2 -2
- package/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp +9 -2
- package/ReactCommon/react/renderer/imagemanager/platform/android/react/renderer/imagemanager/ImageRequestParams.h +9 -4
- package/ReactCommon/react/renderer/imagemanager/platform/android/react/renderer/imagemanager/conversions.h +8 -4
- package/package.json +9 -9
- package/sdks/hermes-engine/version.properties +1 -1
- package/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.cpp +0 -212
- package/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h +0 -40
|
@@ -29,7 +29,7 @@ export default class ReactNativeVersion {
|
|
|
29
29
|
static major: number = 0;
|
|
30
30
|
static minor: number = 84;
|
|
31
31
|
static patch: number = 0;
|
|
32
|
-
static prerelease: string | null = 'nightly-
|
|
32
|
+
static prerelease: string | null = 'nightly-20251116-d52b9d2f8';
|
|
33
33
|
|
|
34
34
|
static getVersionString(): string {
|
|
35
35
|
return `${this.major}.${this.minor}.${this.patch}${this.prerelease != null ? `-${this.prerelease}` : ''}`;
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -24,7 +24,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
|
|
|
24
24
|
RCTVersionMajor: @(0),
|
|
25
25
|
RCTVersionMinor: @(84),
|
|
26
26
|
RCTVersionPatch: @(0),
|
|
27
|
-
RCTVersionPrerelease: @"nightly-
|
|
27
|
+
RCTVersionPrerelease: @"nightly-20251116-d52b9d2f8",
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
return __rnVersion;
|
|
@@ -22,7 +22,7 @@ constexpr struct {
|
|
|
22
22
|
int32_t Major = 0;
|
|
23
23
|
int32_t Minor = 84;
|
|
24
24
|
int32_t Patch = 0;
|
|
25
|
-
std::string_view Prerelease = "nightly-
|
|
25
|
+
std::string_view Prerelease = "nightly-20251116-d52b9d2f8";
|
|
26
26
|
} ReactNativeVersion;
|
|
27
27
|
|
|
28
28
|
} // namespace facebook::react
|
|
@@ -252,6 +252,12 @@ class JSI_EXPORT NativeState {
|
|
|
252
252
|
virtual ~NativeState();
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
+
// JSI_UNSTABLE gates features that will be released with a Hermes version in
|
|
256
|
+
// the future. Until released, these features may be subject to change. After
|
|
257
|
+
// release, these features will be moved out of JSI_UNSTABLE and become frozen.
|
|
258
|
+
#ifdef JSI_UNSTABLE
|
|
259
|
+
#endif // JSI_UNSTABLE
|
|
260
|
+
|
|
255
261
|
/// Represents a JS runtime. Movable, but not copyable. Note that
|
|
256
262
|
/// this object may not be thread-aware, but cannot be used safely from
|
|
257
263
|
/// multiple threads at once. The application is responsible for
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
namespace facebook::react::jsinspector_modern::tracing {
|
|
17
17
|
|
|
18
18
|
enum class Category {
|
|
19
|
-
HiddenTimeline, /* disabled-by-default-devtools.timeline
|
|
20
|
-
JavaScriptSampling, /* disabled-by-default-v8.cpu_profiler
|
|
21
|
-
RuntimeExecution, /* v8.execute
|
|
22
|
-
Timeline, /* devtools.timeline
|
|
23
|
-
UserTiming, /* blink.user_timing
|
|
19
|
+
HiddenTimeline, /* disabled-by-default-devtools.timeline */
|
|
20
|
+
JavaScriptSampling, /* disabled-by-default-v8.cpu_profiler */
|
|
21
|
+
RuntimeExecution, /* v8.execute */
|
|
22
|
+
Timeline, /* devtools.timeline */
|
|
23
|
+
UserTiming, /* blink.user_timing */
|
|
24
|
+
Screenshot, /* disabled-by-default-devtools.screenshot */
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
inline std::string tracingCategoryToString(const Category &category)
|
|
@@ -36,6 +37,8 @@ inline std::string tracingCategoryToString(const Category &category)
|
|
|
36
37
|
return "disabled-by-default-v8.cpu_profiler";
|
|
37
38
|
case Category::RuntimeExecution:
|
|
38
39
|
return "v8.execute";
|
|
40
|
+
case Category::Screenshot:
|
|
41
|
+
return "disabled-by-default-devtools.screenshot";
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -51,6 +54,8 @@ inline std::optional<Category> getTracingCategoryFromString(const std::string &s
|
|
|
51
54
|
return Category::JavaScriptSampling;
|
|
52
55
|
} else if (str == "v8.execute") {
|
|
53
56
|
return Category::RuntimeExecution;
|
|
57
|
+
} else if (str == "disabled-by-default-devtools.screenshot") {
|
|
58
|
+
return Category::RuntimeExecution;
|
|
54
59
|
} else {
|
|
55
60
|
return std::nullopt;
|
|
56
61
|
}
|
|
@@ -98,7 +98,7 @@ ImageProps::ImageProps(
|
|
|
98
98
|
rawProps,
|
|
99
99
|
"resizeMethod",
|
|
100
100
|
sourceProps.resizeMethod,
|
|
101
|
-
{})),
|
|
101
|
+
{"auto"})),
|
|
102
102
|
resizeMultiplier(
|
|
103
103
|
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
104
104
|
? sourceProps.resizeMultiplier
|
|
@@ -107,7 +107,7 @@ ImageProps::ImageProps(
|
|
|
107
107
|
rawProps,
|
|
108
108
|
"resizeMultiplier",
|
|
109
109
|
sourceProps.resizeMultiplier,
|
|
110
|
-
|
|
110
|
+
1)),
|
|
111
111
|
shouldNotifyLoadEvents(
|
|
112
112
|
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
113
113
|
? sourceProps.shouldNotifyLoadEvents
|
|
@@ -33,8 +33,8 @@ class ImageProps final : public ViewProps {
|
|
|
33
33
|
EdgeInsets capInsets{};
|
|
34
34
|
SharedColor tintColor{};
|
|
35
35
|
std::string internal_analyticTag{};
|
|
36
|
-
std::string resizeMethod{};
|
|
37
|
-
Float resizeMultiplier{};
|
|
36
|
+
std::string resizeMethod{"auto"};
|
|
37
|
+
Float resizeMultiplier{1.f};
|
|
38
38
|
bool shouldNotifyLoadEvents{};
|
|
39
39
|
SharedColor overlayColor{};
|
|
40
40
|
Float fadeDuration{};
|
|
@@ -65,7 +65,12 @@ void ImageShadowNode::updateStateIfNeeded() {
|
|
|
65
65
|
imageProps.fadeDuration,
|
|
66
66
|
imageProps.progressiveRenderingEnabled,
|
|
67
67
|
imageProps.loadingIndicatorSource,
|
|
68
|
-
imageProps.internal_analyticTag
|
|
68
|
+
imageProps.internal_analyticTag,
|
|
69
|
+
Size{
|
|
70
|
+
.width =
|
|
71
|
+
layoutMetrics_.frame.size.width * layoutMetrics_.pointScaleFactor,
|
|
72
|
+
.height = layoutMetrics_.frame.size.height *
|
|
73
|
+
layoutMetrics_.pointScaleFactor}
|
|
69
74
|
#endif
|
|
70
75
|
);
|
|
71
76
|
|
|
@@ -85,7 +90,9 @@ void ImageShadowNode::updateStateIfNeeded() {
|
|
|
85
90
|
(uri.starts_with("content://") || uri.starts_with("file://")));
|
|
86
91
|
// If we would resize but have no dimensions, skip creating the request
|
|
87
92
|
if (shouldResize &&
|
|
88
|
-
(newImageSource.size.width == 0 || newImageSource.size.height == 0
|
|
93
|
+
(newImageSource.size.width == 0 || newImageSource.size.height == 0 ||
|
|
94
|
+
layoutMetrics_.frame.size.width == 0 ||
|
|
95
|
+
layoutMetrics_.frame.size.height == 0)) {
|
|
89
96
|
// Keep the old state - don't create a new image request
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
@@ -30,7 +30,8 @@ class ImageRequestParams {
|
|
|
30
30
|
Float fadeDuration,
|
|
31
31
|
bool progressiveRenderingEnabled,
|
|
32
32
|
ImageSource loadingIndicatorSource,
|
|
33
|
-
std::string analyticTag
|
|
33
|
+
std::string analyticTag,
|
|
34
|
+
Size size)
|
|
34
35
|
: blurRadius(blurRadius),
|
|
35
36
|
defaultSource(std::move(defaultSource)),
|
|
36
37
|
resizeMode(resizeMode),
|
|
@@ -42,7 +43,8 @@ class ImageRequestParams {
|
|
|
42
43
|
fadeDuration(fadeDuration),
|
|
43
44
|
progressiveRenderingEnabled(progressiveRenderingEnabled),
|
|
44
45
|
loadingIndicatorSource(std::move(loadingIndicatorSource)),
|
|
45
|
-
analyticTag(std::move(analyticTag))
|
|
46
|
+
analyticTag(std::move(analyticTag)),
|
|
47
|
+
size(size)
|
|
46
48
|
{
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -58,6 +60,7 @@ class ImageRequestParams {
|
|
|
58
60
|
bool progressiveRenderingEnabled{};
|
|
59
61
|
ImageSource loadingIndicatorSource{};
|
|
60
62
|
std::string analyticTag{};
|
|
63
|
+
Size size{};
|
|
61
64
|
|
|
62
65
|
bool operator==(const ImageRequestParams &rhs) const
|
|
63
66
|
{
|
|
@@ -73,7 +76,8 @@ class ImageRequestParams {
|
|
|
73
76
|
this->fadeDuration,
|
|
74
77
|
this->progressiveRenderingEnabled,
|
|
75
78
|
this->loadingIndicatorSource,
|
|
76
|
-
this->analyticTag
|
|
79
|
+
this->analyticTag,
|
|
80
|
+
this->size) ==
|
|
77
81
|
std::tie(
|
|
78
82
|
rhs.blurRadius,
|
|
79
83
|
rhs.defaultSource,
|
|
@@ -86,7 +90,8 @@ class ImageRequestParams {
|
|
|
86
90
|
rhs.fadeDuration,
|
|
87
91
|
rhs.progressiveRenderingEnabled,
|
|
88
92
|
rhs.loadingIndicatorSource,
|
|
89
|
-
rhs.analyticTag
|
|
93
|
+
rhs.analyticTag,
|
|
94
|
+
rhs.size);
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
bool operator!=(const ImageRequestParams &rhs) const
|
|
@@ -24,8 +24,8 @@ constexpr MapBuffer::Key IS_KEY_DEFAULT_SRC = 1;
|
|
|
24
24
|
constexpr MapBuffer::Key IS_KEY_RESIZE_MODE = 2;
|
|
25
25
|
constexpr MapBuffer::Key IS_KEY_RESIZE_METHOD = 3;
|
|
26
26
|
constexpr MapBuffer::Key IS_KEY_BLUR_RADIUS = 4;
|
|
27
|
-
constexpr MapBuffer::Key
|
|
28
|
-
constexpr MapBuffer::Key
|
|
27
|
+
constexpr MapBuffer::Key IS_KEY_IMAGE_WIDTH = 5;
|
|
28
|
+
constexpr MapBuffer::Key IS_KEY_IMAGE_HEIGHT = 6;
|
|
29
29
|
constexpr MapBuffer::Key IS_KEY_RESIZE_MULTIPLIER = 7;
|
|
30
30
|
constexpr MapBuffer::Key IS_KEY_SHOULD_NOTIFY_LOAD_EVENTS = 8;
|
|
31
31
|
constexpr MapBuffer::Key IS_KEY_OVERLAY_COLOR = 9;
|
|
@@ -35,16 +35,20 @@ constexpr MapBuffer::Key IS_KEY_PROGRESSIVE_RENDERING_ENABLED = 12;
|
|
|
35
35
|
constexpr MapBuffer::Key IS_KEY_LOADING_INDICATOR_SRC = 13;
|
|
36
36
|
constexpr MapBuffer::Key IS_KEY_ANALYTIC_TAG = 14;
|
|
37
37
|
constexpr MapBuffer::Key IS_KEY_TAG = 15;
|
|
38
|
+
constexpr MapBuffer::Key IS_KEY_VIEW_WIDTH = 16;
|
|
39
|
+
constexpr MapBuffer::Key IS_KEY_VIEW_HEIGHT = 17;
|
|
38
40
|
|
|
39
41
|
inline void serializeImageSource(MapBufferBuilder &builder, const ImageSource &imageSource)
|
|
40
42
|
{
|
|
41
43
|
builder.putString(IS_KEY_URI, imageSource.uri);
|
|
42
|
-
builder.putInt(
|
|
43
|
-
builder.putInt(
|
|
44
|
+
builder.putInt(IS_KEY_IMAGE_WIDTH, static_cast<int32_t>(imageSource.size.width));
|
|
45
|
+
builder.putInt(IS_KEY_IMAGE_HEIGHT, static_cast<int32_t>(imageSource.size.height));
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
inline void serializeImageRequestParams(MapBufferBuilder &builder, const ImageRequestParams &imageRequestParams)
|
|
47
49
|
{
|
|
50
|
+
builder.putInt(IS_KEY_VIEW_WIDTH, static_cast<int32_t>(imageRequestParams.size.width));
|
|
51
|
+
builder.putInt(IS_KEY_VIEW_HEIGHT, static_cast<int32_t>(imageRequestParams.size.height));
|
|
48
52
|
builder.putString(IS_KEY_DEFAULT_SRC, imageRequestParams.defaultSource.uri);
|
|
49
53
|
builder.putInt(IS_KEY_RESIZE_MODE, to_underlying(imageRequestParams.resizeMode));
|
|
50
54
|
builder.putString(IS_KEY_RESIZE_METHOD, imageRequestParams.resizeMethod);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native",
|
|
3
|
-
"version": "0.84.0-nightly-
|
|
3
|
+
"version": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
4
4
|
"description": "A framework for building native apps using React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -160,13 +160,13 @@
|
|
|
160
160
|
},
|
|
161
161
|
"dependencies": {
|
|
162
162
|
"@jest/create-cache-key-function": "^29.7.0",
|
|
163
|
-
"@react-native/assets-registry": "0.84.0-nightly-
|
|
164
|
-
"@react-native/codegen": "0.84.0-nightly-
|
|
165
|
-
"@react-native/community-cli-plugin": "0.84.0-nightly-
|
|
166
|
-
"@react-native/gradle-plugin": "0.84.0-nightly-
|
|
167
|
-
"@react-native/js-polyfills": "0.84.0-nightly-
|
|
168
|
-
"@react-native/normalize-colors": "0.84.0-nightly-
|
|
169
|
-
"@react-native/virtualized-lists": "0.84.0-nightly-
|
|
163
|
+
"@react-native/assets-registry": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
164
|
+
"@react-native/codegen": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
165
|
+
"@react-native/community-cli-plugin": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
166
|
+
"@react-native/gradle-plugin": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
167
|
+
"@react-native/js-polyfills": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
168
|
+
"@react-native/normalize-colors": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
169
|
+
"@react-native/virtualized-lists": "0.84.0-nightly-20251116-d52b9d2f8",
|
|
170
170
|
"abort-controller": "^3.0.0",
|
|
171
171
|
"anser": "^1.4.9",
|
|
172
172
|
"ansi-regex": "^5.0.0",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"commander": "^12.0.0",
|
|
177
177
|
"flow-enums-runtime": "^0.0.6",
|
|
178
178
|
"glob": "^7.1.1",
|
|
179
|
-
"hermes-compiler": "0.14.0-commitly-
|
|
179
|
+
"hermes-compiler": "0.14.0-commitly-202511160156-8b7dd3e16",
|
|
180
180
|
"invariant": "^2.2.4",
|
|
181
181
|
"jest-environment-node": "^29.7.0",
|
|
182
182
|
"memoize-one": "^5.0.0",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
HERMES_VERSION_NAME=0.14.0-commitly-
|
|
1
|
+
HERMES_VERSION_NAME=0.14.0-commitly-202511160156-8b7dd3e16
|
|
2
2
|
HERMES_V1_VERSION_NAME=250829098.0.3
|
|
@@ -1,212 +0,0 @@
|
|
|
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 "TurboCxxModule.h"
|
|
9
|
-
|
|
10
|
-
#include <vector>
|
|
11
|
-
|
|
12
|
-
#include <ReactCommon/TurboModuleUtils.h>
|
|
13
|
-
#include <glog/logging.h>
|
|
14
|
-
#include <jsi/JSIDynamic.h>
|
|
15
|
-
|
|
16
|
-
using namespace facebook;
|
|
17
|
-
using namespace facebook::xplat::module;
|
|
18
|
-
|
|
19
|
-
namespace facebook::react {
|
|
20
|
-
|
|
21
|
-
namespace {
|
|
22
|
-
CxxModule::Callback makeTurboCxxModuleCallback(
|
|
23
|
-
std::weak_ptr<CallbackWrapper> weakWrapper) {
|
|
24
|
-
return [weakWrapper, wrapperWasCalled = false](
|
|
25
|
-
const std::vector<folly::dynamic>& args) mutable {
|
|
26
|
-
if (wrapperWasCalled) {
|
|
27
|
-
LOG(FATAL) << "callback arg cannot be called more than once";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
auto strongWrapper = weakWrapper.lock();
|
|
31
|
-
if (!strongWrapper) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
strongWrapper->jsInvoker().invokeAsync(
|
|
36
|
-
[weakWrapper, args](jsi::Runtime& rt) {
|
|
37
|
-
auto strongWrapper2 = weakWrapper.lock();
|
|
38
|
-
if (!strongWrapper2) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
std::vector<jsi::Value> innerArgs;
|
|
43
|
-
innerArgs.reserve(args.size());
|
|
44
|
-
for (auto& a : args) {
|
|
45
|
-
innerArgs.push_back(jsi::valueFromDynamic(rt, a));
|
|
46
|
-
}
|
|
47
|
-
strongWrapper2->callback().call(
|
|
48
|
-
rt, (const jsi::Value*)innerArgs.data(), innerArgs.size());
|
|
49
|
-
|
|
50
|
-
strongWrapper2->destroy();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
wrapperWasCalled = true;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
} // namespace
|
|
57
|
-
|
|
58
|
-
TurboCxxModule::TurboCxxModule(
|
|
59
|
-
std::unique_ptr<CxxModule> cxxModule,
|
|
60
|
-
std::shared_ptr<CallInvoker> jsInvoker)
|
|
61
|
-
: TurboModule(cxxModule->getName(), std::move(jsInvoker)),
|
|
62
|
-
cxxMethods_(cxxModule->getMethods()),
|
|
63
|
-
cxxModule_(std::move(cxxModule)) {}
|
|
64
|
-
|
|
65
|
-
jsi::Value TurboCxxModule::create(
|
|
66
|
-
jsi::Runtime& runtime,
|
|
67
|
-
const jsi::PropNameID& propName) {
|
|
68
|
-
std::string propNameUtf8 = propName.utf8(runtime);
|
|
69
|
-
|
|
70
|
-
if (propNameUtf8 == "getConstants") {
|
|
71
|
-
// This is special cased because `getConstants()` is already a part of
|
|
72
|
-
// CxxModule.
|
|
73
|
-
return jsi::Function::createFromHostFunction(
|
|
74
|
-
runtime,
|
|
75
|
-
propName,
|
|
76
|
-
0,
|
|
77
|
-
[this](
|
|
78
|
-
jsi::Runtime& rt,
|
|
79
|
-
const jsi::Value& /*thisVal*/,
|
|
80
|
-
const jsi::Value* /*args*/,
|
|
81
|
-
size_t /*count*/) {
|
|
82
|
-
jsi::Object result(rt);
|
|
83
|
-
auto constants = cxxModule_->getConstants();
|
|
84
|
-
for (auto& pair : constants) {
|
|
85
|
-
result.setProperty(
|
|
86
|
-
rt, pair.first.c_str(), jsi::valueFromDynamic(rt, pair.second));
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
for (auto& method : cxxMethods_) {
|
|
92
|
-
if (method.name == propNameUtf8) {
|
|
93
|
-
return jsi::Function::createFromHostFunction(
|
|
94
|
-
runtime,
|
|
95
|
-
propName,
|
|
96
|
-
0,
|
|
97
|
-
[this, propNameUtf8](
|
|
98
|
-
jsi::Runtime& rt,
|
|
99
|
-
const jsi::Value& /*thisVal*/,
|
|
100
|
-
const jsi::Value* args,
|
|
101
|
-
size_t count) {
|
|
102
|
-
return invokeMethod(rt, propNameUtf8, args, count);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return jsi::Value::undefined();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
std::vector<jsi::PropNameID> TurboCxxModule::getPropertyNames(
|
|
112
|
-
jsi::Runtime& runtime) {
|
|
113
|
-
std::vector<jsi::PropNameID> result;
|
|
114
|
-
result.reserve(cxxMethods_.size() + 1);
|
|
115
|
-
result.push_back(jsi::PropNameID::forUtf8(runtime, "getConstants"));
|
|
116
|
-
for (auto& cxxMethod : cxxMethods_) {
|
|
117
|
-
result.push_back(jsi::PropNameID::forUtf8(runtime, cxxMethod.name));
|
|
118
|
-
}
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
jsi::Value TurboCxxModule::invokeMethod(
|
|
123
|
-
jsi::Runtime& runtime,
|
|
124
|
-
const std::string& methodName,
|
|
125
|
-
const jsi::Value* args,
|
|
126
|
-
size_t count) {
|
|
127
|
-
auto it = cxxMethods_.begin();
|
|
128
|
-
for (; it != cxxMethods_.end(); it++) {
|
|
129
|
-
auto method = *it;
|
|
130
|
-
if (method.name == methodName) {
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (it == cxxMethods_.end()) {
|
|
136
|
-
throw std::runtime_error(
|
|
137
|
-
"Function '" + methodName + "' cannot be found on cxxmodule: " + name_);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
auto method = *it;
|
|
141
|
-
|
|
142
|
-
if (method.syncFunc) {
|
|
143
|
-
auto innerArgs = folly::dynamic::array();
|
|
144
|
-
for (size_t i = 0; i < count; i++) {
|
|
145
|
-
innerArgs.push_back(jsi::dynamicFromValue(runtime, args[i]));
|
|
146
|
-
}
|
|
147
|
-
return jsi::valueFromDynamic(
|
|
148
|
-
runtime, method.syncFunc(std::move(innerArgs)));
|
|
149
|
-
} else if (method.func && !method.isPromise) {
|
|
150
|
-
// Async method.
|
|
151
|
-
CxxModule::Callback first;
|
|
152
|
-
CxxModule::Callback second;
|
|
153
|
-
|
|
154
|
-
if (count < method.callbacks) {
|
|
155
|
-
throw std::invalid_argument(
|
|
156
|
-
"Expected " + std::to_string(method.callbacks) +
|
|
157
|
-
" callbacks, but only " + std::to_string(count) +
|
|
158
|
-
" parameters provided");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (method.callbacks == 1) {
|
|
162
|
-
auto wrapper = CallbackWrapper::createWeak(
|
|
163
|
-
args[count - 1].getObject(runtime).getFunction(runtime),
|
|
164
|
-
runtime,
|
|
165
|
-
jsInvoker_);
|
|
166
|
-
first = makeTurboCxxModuleCallback(wrapper);
|
|
167
|
-
} else if (method.callbacks == 2) {
|
|
168
|
-
auto wrapper1 = CallbackWrapper::createWeak(
|
|
169
|
-
args[count - 2].getObject(runtime).getFunction(runtime),
|
|
170
|
-
runtime,
|
|
171
|
-
jsInvoker_);
|
|
172
|
-
auto wrapper2 = CallbackWrapper::createWeak(
|
|
173
|
-
args[count - 1].getObject(runtime).getFunction(runtime),
|
|
174
|
-
runtime,
|
|
175
|
-
jsInvoker_);
|
|
176
|
-
first = makeTurboCxxModuleCallback(wrapper1);
|
|
177
|
-
second = makeTurboCxxModuleCallback(wrapper2);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
auto innerArgs = folly::dynamic::array();
|
|
181
|
-
for (size_t i = 0; i < count - method.callbacks; i++) {
|
|
182
|
-
innerArgs.push_back(jsi::dynamicFromValue(runtime, args[i]));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
method.func(std::move(innerArgs), first, second);
|
|
186
|
-
} else if (method.isPromise) {
|
|
187
|
-
return createPromiseAsJSIValue(
|
|
188
|
-
runtime,
|
|
189
|
-
[method, args, count, this](
|
|
190
|
-
jsi::Runtime& rt, std::shared_ptr<Promise> promise) {
|
|
191
|
-
auto resolveWrapper = CallbackWrapper::createWeak(
|
|
192
|
-
promise->resolve_.getFunction(rt), rt, jsInvoker_);
|
|
193
|
-
auto rejectWrapper = CallbackWrapper::createWeak(
|
|
194
|
-
promise->reject_.getFunction(rt), rt, jsInvoker_);
|
|
195
|
-
CxxModule::Callback resolve =
|
|
196
|
-
makeTurboCxxModuleCallback(resolveWrapper);
|
|
197
|
-
CxxModule::Callback reject =
|
|
198
|
-
makeTurboCxxModuleCallback(rejectWrapper);
|
|
199
|
-
|
|
200
|
-
auto innerArgs = folly::dynamic::array();
|
|
201
|
-
for (size_t i = 0; i < count; i++) {
|
|
202
|
-
innerArgs.push_back(jsi::dynamicFromValue(rt, args[i]));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
method.func(std::move(innerArgs), resolve, reject);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return jsi::Value::undefined();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
} // namespace facebook::react
|
|
@@ -1,40 +0,0 @@
|
|
|
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 <memory>
|
|
11
|
-
#include <vector>
|
|
12
|
-
|
|
13
|
-
#include <cxxreact/CxxModule.h>
|
|
14
|
-
|
|
15
|
-
#include "TurboModule.h"
|
|
16
|
-
|
|
17
|
-
namespace facebook::react {
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A helper class to convert the legacy CxxModule instance to a TurboModule
|
|
21
|
-
* instance. This should be used only for migration purpose (to TurboModule),
|
|
22
|
-
* since it's not very performant due to a lot of back-and-forth value
|
|
23
|
-
* conversions between folly::dynamic and jsi::Value.
|
|
24
|
-
*/
|
|
25
|
-
class JSI_EXPORT TurboCxxModule : public TurboModule {
|
|
26
|
-
public:
|
|
27
|
-
TurboCxxModule(std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule, std::shared_ptr<CallInvoker> jsInvoker);
|
|
28
|
-
|
|
29
|
-
facebook::jsi::Value create(facebook::jsi::Runtime &runtime, const facebook::jsi::PropNameID &propName) override;
|
|
30
|
-
|
|
31
|
-
std::vector<facebook::jsi::PropNameID> getPropertyNames(facebook::jsi::Runtime &runtime) override;
|
|
32
|
-
|
|
33
|
-
jsi::Value invokeMethod(jsi::Runtime &runtime, const std::string &methodName, const jsi::Value *args, size_t count);
|
|
34
|
-
|
|
35
|
-
private:
|
|
36
|
-
std::vector<facebook::xplat::module::CxxModule::Method> cxxMethods_;
|
|
37
|
-
std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule_;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
} // namespace facebook::react
|