react-native-windows 0.78.4 → 0.78.6
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/Directory.Build.props +6 -4
- package/Folly/Folly.vcxproj +46 -6
- package/Folly/Folly.vcxproj.filters +16 -4
- package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +26 -18
- package/Folly/TEMP_UntilFollyUpdate/Conv.cpp +1205 -0
- package/Folly/TEMP_UntilFollyUpdate/chrono/Hardware.h +155 -0
- package/Folly/TEMP_UntilFollyUpdate/concurrency/CacheLocality.cpp +633 -0
- package/Folly/TEMP_UntilFollyUpdate/{dynamic-inl.h → json/dynamic-inl.h} +3 -4
- package/Folly/TEMP_UntilFollyUpdate/{json.cpp → json/json.cpp} +14 -10
- package/Folly/TEMP_UntilFollyUpdate/lang/SafeAssert.h +7 -14
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +6 -6
- package/Folly/ThreadNameStub.cpp +10 -0
- package/Folly/cgmanifest.json +11 -1
- package/Libraries/Components/View/View.windows.js +107 -56
- package/Libraries/Components/View/ViewAccessibility.d.ts +60 -1
- package/Libraries/Image/Image.windows.js +42 -21
- package/Libraries/Modal/Modal.d.ts +7 -0
- package/Libraries/Modal/Modal.windows.js +7 -1
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +3 -0
- package/Libraries/Text/Text.d.ts +18 -0
- package/Microsoft.ReactNative/AsynchronousEventBeat.cpp +4 -25
- package/Microsoft.ReactNative/AsynchronousEventBeat.h +0 -3
- package/Microsoft.ReactNative/Base/FollyIncludes.h +1 -0
- package/Microsoft.ReactNative/CallInvoker.cpp +42 -0
- package/Microsoft.ReactNative/CallInvoker.h +34 -0
- package/Microsoft.ReactNative/{JSDispatcherWriter.cpp → CallInvokerWriter.cpp} +35 -47
- package/Microsoft.ReactNative/CallInvokerWriter.h +74 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +0 -5
- package/Microsoft.ReactNative/CompositionSwitcher.idl +7 -0
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +12 -2
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.cpp +100 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.h +31 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +77 -11
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +43 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +7 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +86 -56
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +0 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +0 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +118 -63
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -8
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +16 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +34 -11
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +133 -135
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +9 -6
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +46 -49
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +6 -1
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +13 -8
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +146 -25
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +14 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +160 -12
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +6 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.cpp +47 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.h +15 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +6 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +7 -9
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +40 -36
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +68 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +11 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +70 -13
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +10 -2
- package/Microsoft.ReactNative/Fabric/ImageManager.cpp +5 -5
- package/Microsoft.ReactNative/Fabric/ImageRequestParams.cpp +26 -0
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +47 -8
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +10 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/CompositionAccessibilityProps.h +67 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +22 -4
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +15 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +20 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/MouseEvent.h +20 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +247 -45
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +15 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.cpp +39 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.h +54 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +126 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +73 -0
- package/Microsoft.ReactNative/IReactContext.cpp +17 -0
- package/Microsoft.ReactNative/IReactContext.h +1 -0
- package/Microsoft.ReactNative/IReactContext.idl +18 -1
- package/Microsoft.ReactNative/IReactDispatcher.idl +1 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.cpp +12 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.h +2 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.idl +8 -0
- package/Microsoft.ReactNative/JsiApi.cpp +10 -2
- package/Microsoft.ReactNative/JsiApi.h +1 -0
- package/Microsoft.ReactNative/JsiApi.idl +1 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -3
- package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +2 -3
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +7 -12
- package/Microsoft.ReactNative/Modules/Animated/AnimationDriver.cpp +2 -1
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedModule.cpp +4 -8
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +6 -8
- package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +6 -15
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +13 -24
- package/Microsoft.ReactNative/QuirkSettings.cpp +0 -16
- package/Microsoft.ReactNative/QuirkSettings.h +0 -3
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +11 -1
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +78 -68
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -2
- package/Microsoft.ReactNative/ReactInstanceSettings.cpp +12 -0
- package/Microsoft.ReactNative/ReactInstanceSettings.h +2 -0
- package/Microsoft.ReactNative/ReactInstanceSettings.idl +6 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -0
- package/Microsoft.ReactNative/ReactSupport.cpp +44 -11
- package/Microsoft.ReactNative/RedBox.cpp +30 -1
- package/Microsoft.ReactNative/SchedulerSettings.cpp +4 -4
- package/Microsoft.ReactNative/SchedulerSettings.h +1 -1
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +30 -12
- package/Microsoft.ReactNative/Utils/ImageUtils.h +1 -0
- package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +37 -31
- package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +1 -0
- package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +2 -0
- package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +94 -27
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +27 -6
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.cpp +45 -11
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h +6 -0
- package/Microsoft.ReactNative.Cxx/JSI/decorator.h +220 -0
- package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +28 -0
- package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +6 -0
- package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +241 -4
- package/Microsoft.ReactNative.Cxx/JSI/jsi.h +207 -19
- package/Microsoft.ReactNative.Cxx/JSValue.cpp +19 -3
- package/Microsoft.ReactNative.Cxx/JSValue.h +15 -7
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
- package/Microsoft.ReactNative.Cxx/NativeModules.h +60 -2
- package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +1267 -614
- package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +4 -2
- package/Microsoft.ReactNative.Cxx/ReactContext.h +7 -0
- package/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +11 -13
- package/Microsoft.ReactNative.Cxx/TurboModuleProvider.h +2 -3
- package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +81 -20
- package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +47 -2
- package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +13 -0
- package/Microsoft.ReactNative.Cxx/stubs/glog/logging.h +1 -1
- package/Microsoft.ReactNative.Managed/ReactContext.cs +3 -1
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/React.Cpp.props +2 -1
- package/PropertySheets/WebView2.props +1 -1
- package/PropertySheets/WinUI.props +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +429 -0
- package/ReactCommon/cgmanifest.json +1 -1
- package/Shared/HermesRuntimeHolder.cpp +6 -0
- package/Shared/JSI/ChakraRuntime.cpp +4 -0
- package/Shared/JSI/ChakraRuntime.h +2 -0
- package/Shared/Modules/BlobModule.cpp +14 -16
- package/Shared/Modules/BlobModule.h +3 -1
- package/Shared/Networking/WinRTWebSocketResource.cpp +82 -101
- package/Shared/Networking/WinRTWebSocketResource.h +91 -7
- package/Shared/Shared.vcxitems +11 -7
- package/Shared/Shared.vcxitems.filters +6 -1
- package/Shared/TurboModuleManager.cpp +0 -15
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +6 -6
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +6 -6
- package/codegen/react/components/rnwcore/InputAccessory.g.h +6 -6
- package/codegen/react/components/rnwcore/ModalHostView.g.h +11 -7
- package/codegen/react/components/rnwcore/Props.cpp +2 -1
- package/codegen/react/components/rnwcore/Props.h +1 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +6 -6
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +6 -6
- package/codegen/react/components/rnwcore/Switch.g.h +6 -6
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +6 -6
- package/index.windows.js +4 -2
- package/package.json +3 -4
- package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
- package/stubs/glog/logging.h +1 -1
- package/Microsoft.ReactNative/JSDispatcherWriter.h +0 -47
- package/Microsoft.ReactNative/SynchronousEventBeat.cpp +0 -51
- package/Microsoft.ReactNative/SynchronousEventBeat.h +0 -31
|
@@ -0,0 +1,429 @@
|
|
|
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 "JsErrorHandler.h"
|
|
9
|
+
#include <cxxreact/ErrorUtils.h>
|
|
10
|
+
#include <glog/logging.h>
|
|
11
|
+
#include <react/bridging/Bridging.h>
|
|
12
|
+
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include "StackTraceParser.h"
|
|
15
|
+
|
|
16
|
+
using namespace facebook;
|
|
17
|
+
|
|
18
|
+
namespace {
|
|
19
|
+
std::string quote(const std::string& view) {
|
|
20
|
+
return "\"" + view + "\"";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
int nextExceptionId() {
|
|
24
|
+
static int exceptionId = 0;
|
|
25
|
+
return exceptionId++;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
bool isLooselyNull(const jsi::Value& value) {
|
|
29
|
+
return value.isNull() || value.isUndefined();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
bool isEqualTo(
|
|
33
|
+
jsi::Runtime& runtime,
|
|
34
|
+
const jsi::Value& value,
|
|
35
|
+
const std::string& str) {
|
|
36
|
+
return jsi::Value::strictEquals(
|
|
37
|
+
runtime, value, jsi::String::createFromUtf8(runtime, str));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::string stringifyToCpp(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
41
|
+
return value.toString(runtime).utf8(runtime);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
bool isTruthy(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
45
|
+
auto Boolean = runtime.global().getPropertyAsFunction(runtime, "Boolean");
|
|
46
|
+
return Boolean.call(runtime, value).getBool();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void objectAssign(
|
|
50
|
+
jsi::Runtime& runtime,
|
|
51
|
+
jsi::Object& target,
|
|
52
|
+
const jsi::Object& value) {
|
|
53
|
+
auto Object = runtime.global().getPropertyAsObject(runtime, "Object");
|
|
54
|
+
auto assign = Object.getPropertyAsFunction(runtime, "assign");
|
|
55
|
+
assign.callWithThis(runtime, Object, target, value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
jsi::Object wrapInErrorIfNecessary(
|
|
59
|
+
jsi::Runtime& runtime,
|
|
60
|
+
const jsi::Value& value) {
|
|
61
|
+
auto Error = runtime.global().getPropertyAsFunction(runtime, "Error");
|
|
62
|
+
auto isError =
|
|
63
|
+
value.isObject() && value.asObject(runtime).instanceOf(runtime, Error);
|
|
64
|
+
auto error = isError
|
|
65
|
+
? value.getObject(runtime)
|
|
66
|
+
: Error.callAsConstructor(runtime, value).getObject(runtime);
|
|
67
|
+
return error;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class SetFalseOnDestruct {
|
|
71
|
+
std::shared_ptr<bool> _value;
|
|
72
|
+
|
|
73
|
+
public:
|
|
74
|
+
SetFalseOnDestruct(const SetFalseOnDestruct&) = delete;
|
|
75
|
+
SetFalseOnDestruct& operator=(const SetFalseOnDestruct&) = delete;
|
|
76
|
+
SetFalseOnDestruct(SetFalseOnDestruct&&) = delete;
|
|
77
|
+
SetFalseOnDestruct& operator=(SetFalseOnDestruct&&) = delete;
|
|
78
|
+
explicit SetFalseOnDestruct(std::shared_ptr<bool> value)
|
|
79
|
+
: _value(std::move(value)) {}
|
|
80
|
+
~SetFalseOnDestruct() {
|
|
81
|
+
*_value = false;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
void logErrorWhileReporting(
|
|
86
|
+
std::string message,
|
|
87
|
+
jsi::JSError& error,
|
|
88
|
+
jsi::JSError& originalError) {
|
|
89
|
+
LOG(ERROR) << "JsErrorHandler::" << message << std::endl
|
|
90
|
+
<< "Js error message: " << error.getMessage() << std::endl
|
|
91
|
+
<< "Original js error message: " << originalError.getMessage()
|
|
92
|
+
<< std::endl;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
jsi::Value getBundleMetadata(jsi::Runtime& runtime, jsi::JSError& error) {
|
|
96
|
+
auto jsGetBundleMetadataValue =
|
|
97
|
+
runtime.global().getProperty(runtime, "__getBundleMetadata");
|
|
98
|
+
|
|
99
|
+
if (!jsGetBundleMetadataValue.isObject() ||
|
|
100
|
+
!jsGetBundleMetadataValue.asObject(runtime).isFunction(runtime)) {
|
|
101
|
+
return jsi::Value::null();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
auto jsGetBundleMetadataValueFn =
|
|
105
|
+
jsGetBundleMetadataValue.asObject(runtime).asFunction(runtime);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
auto bundleMetadataValue = jsGetBundleMetadataValueFn.call(runtime);
|
|
109
|
+
if (bundleMetadataValue.isObject()) {
|
|
110
|
+
return bundleMetadataValue;
|
|
111
|
+
}
|
|
112
|
+
return bundleMetadataValue;
|
|
113
|
+
} catch (jsi::JSError& ex) {
|
|
114
|
+
logErrorWhileReporting(
|
|
115
|
+
"getBundleMetadata(): Error raised while calling __getBundleMetadata(). Returning null.",
|
|
116
|
+
ex,
|
|
117
|
+
error);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return jsi::Value::null();
|
|
121
|
+
}
|
|
122
|
+
} // namespace
|
|
123
|
+
|
|
124
|
+
namespace facebook::react {
|
|
125
|
+
|
|
126
|
+
template <>
|
|
127
|
+
struct Bridging<JsErrorHandler::ProcessedError::StackFrame> {
|
|
128
|
+
static jsi::Value toJs(
|
|
129
|
+
jsi::Runtime& runtime,
|
|
130
|
+
const JsErrorHandler::ProcessedError::StackFrame& frame) {
|
|
131
|
+
auto stackFrame = jsi::Object(runtime);
|
|
132
|
+
auto file = bridging::toJs(runtime, frame.file, nullptr);
|
|
133
|
+
auto lineNumber = bridging::toJs(runtime, frame.lineNumber, nullptr);
|
|
134
|
+
auto column = bridging::toJs(runtime, frame.column, nullptr);
|
|
135
|
+
|
|
136
|
+
stackFrame.setProperty(runtime, "file", file);
|
|
137
|
+
stackFrame.setProperty(runtime, "methodName", frame.methodName);
|
|
138
|
+
stackFrame.setProperty(runtime, "lineNumber", lineNumber);
|
|
139
|
+
stackFrame.setProperty(runtime, "column", column);
|
|
140
|
+
return stackFrame;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
template <>
|
|
145
|
+
struct Bridging<JsErrorHandler::ProcessedError> {
|
|
146
|
+
static jsi::Value toJs(
|
|
147
|
+
jsi::Runtime& runtime,
|
|
148
|
+
const JsErrorHandler::ProcessedError& error) {
|
|
149
|
+
auto data = jsi::Object(runtime);
|
|
150
|
+
data.setProperty(runtime, "message", error.message);
|
|
151
|
+
data.setProperty(
|
|
152
|
+
runtime,
|
|
153
|
+
"originalMessage",
|
|
154
|
+
bridging::toJs(runtime, error.originalMessage, nullptr));
|
|
155
|
+
data.setProperty(
|
|
156
|
+
runtime, "name", bridging::toJs(runtime, error.name, nullptr));
|
|
157
|
+
data.setProperty(
|
|
158
|
+
runtime,
|
|
159
|
+
"componentStack",
|
|
160
|
+
bridging::toJs(runtime, error.componentStack, nullptr));
|
|
161
|
+
|
|
162
|
+
auto stack = jsi::Array(runtime, error.stack.size());
|
|
163
|
+
for (size_t i = 0; i < error.stack.size(); i++) {
|
|
164
|
+
auto& frame = error.stack[i];
|
|
165
|
+
stack.setValueAtIndex(runtime, i, bridging::toJs(runtime, frame));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
data.setProperty(runtime, "stack", stack);
|
|
169
|
+
data.setProperty(runtime, "id", error.id);
|
|
170
|
+
data.setProperty(runtime, "isFatal", error.isFatal);
|
|
171
|
+
data.setProperty(runtime, "extraData", error.extraData);
|
|
172
|
+
return data;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
std::ostream& operator<<(
|
|
177
|
+
std::ostream& os,
|
|
178
|
+
const JsErrorHandler::ProcessedError::StackFrame& frame) {
|
|
179
|
+
auto file = frame.file ? quote(*frame.file) : "nil";
|
|
180
|
+
auto methodName = quote(frame.methodName);
|
|
181
|
+
auto lineNumber =
|
|
182
|
+
frame.lineNumber ? std::to_string(*frame.lineNumber) : "nil";
|
|
183
|
+
auto column = frame.column ? std::to_string(*frame.column) : "nil";
|
|
184
|
+
|
|
185
|
+
os << "StackFrame { .file = " << file << ", .methodName = " << methodName
|
|
186
|
+
<< ", .lineNumber = " << lineNumber << ", .column = " << column << " }";
|
|
187
|
+
return os;
|
|
188
|
+
}
|
|
189
|
+
std::ostream& operator<<(
|
|
190
|
+
std::ostream& os,
|
|
191
|
+
const JsErrorHandler::ProcessedError& error) {
|
|
192
|
+
auto message = quote(error.message);
|
|
193
|
+
auto originalMessage =
|
|
194
|
+
error.originalMessage ? quote(*error.originalMessage) : "nil";
|
|
195
|
+
auto name = error.name ? quote(*error.name) : "nil";
|
|
196
|
+
auto componentStack =
|
|
197
|
+
error.componentStack ? quote(*error.componentStack) : "nil";
|
|
198
|
+
auto id = std::to_string(error.id);
|
|
199
|
+
auto isFatal = std::to_string(static_cast<int>(error.isFatal));
|
|
200
|
+
auto extraData = "jsi::Object{ <omitted> } ";
|
|
201
|
+
|
|
202
|
+
os << "ProcessedError {\n"
|
|
203
|
+
<< " .message = " << message << "\n"
|
|
204
|
+
<< " .originalMessage = " << originalMessage << "\n"
|
|
205
|
+
<< " .name = " << name << "\n"
|
|
206
|
+
<< " .componentStack = " << componentStack << "\n"
|
|
207
|
+
<< " .stack = [\n";
|
|
208
|
+
|
|
209
|
+
for (const auto& frame : error.stack) {
|
|
210
|
+
os << " " << frame << ", \n";
|
|
211
|
+
}
|
|
212
|
+
os << " ]\n"
|
|
213
|
+
<< " .id = " << id << "\n"
|
|
214
|
+
<< " .isFatal " << isFatal << "\n"
|
|
215
|
+
<< " .extraData = " << extraData << "\n"
|
|
216
|
+
<< "}";
|
|
217
|
+
return os;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
JsErrorHandler::JsErrorHandler(JsErrorHandler::OnJsError onJsError)
|
|
221
|
+
: _onJsError(std::move(onJsError)),
|
|
222
|
+
_inErrorHandler(std::make_shared<bool>(false)){
|
|
223
|
+
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
JsErrorHandler::~JsErrorHandler() {}
|
|
227
|
+
|
|
228
|
+
void JsErrorHandler::handleError(
|
|
229
|
+
jsi::Runtime& runtime,
|
|
230
|
+
jsi::JSError& error,
|
|
231
|
+
bool isFatal,
|
|
232
|
+
bool logToConsole) {
|
|
233
|
+
// TODO: Current error parsing works and is stable. Can investigate using
|
|
234
|
+
// REGEX_HERMES to get additional Hermes data, though it requires JS setup
|
|
235
|
+
|
|
236
|
+
if (!ReactNativeFeatureFlags::useAlwaysAvailableJSErrorHandling() &&
|
|
237
|
+
_isRuntimeReady) {
|
|
238
|
+
try {
|
|
239
|
+
handleJSError(runtime, error, isFatal);
|
|
240
|
+
return;
|
|
241
|
+
} catch (jsi::JSError& ex) {
|
|
242
|
+
logErrorWhileReporting(
|
|
243
|
+
"handleError(): Error raised while reporting using js pipeline. Using c++ pipeline instead.",
|
|
244
|
+
ex,
|
|
245
|
+
error);
|
|
246
|
+
|
|
247
|
+
// Re-try reporting using the c++ pipeline
|
|
248
|
+
_hasHandledFatalError = false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
handleErrorWithCppPipeline(runtime, error, isFatal, logToConsole);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
void JsErrorHandler::handleErrorWithCppPipeline(
|
|
256
|
+
jsi::Runtime& runtime,
|
|
257
|
+
jsi::JSError& error,
|
|
258
|
+
bool isFatal,
|
|
259
|
+
bool logToConsole) {
|
|
260
|
+
*_inErrorHandler = true;
|
|
261
|
+
SetFalseOnDestruct temp{_inErrorHandler};
|
|
262
|
+
|
|
263
|
+
auto message = error.getMessage();
|
|
264
|
+
auto errorObj = wrapInErrorIfNecessary(runtime, error.value());
|
|
265
|
+
auto componentStackValue = errorObj.getProperty(runtime, "componentStack");
|
|
266
|
+
if (!isLooselyNull(componentStackValue)) {
|
|
267
|
+
message += "\n" + stringifyToCpp(runtime, componentStackValue);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
auto nameValue = errorObj.getProperty(runtime, "name");
|
|
271
|
+
auto name = (isLooselyNull(nameValue) || isEqualTo(runtime, nameValue, ""))
|
|
272
|
+
? std::nullopt
|
|
273
|
+
: std::optional(stringifyToCpp(runtime, nameValue));
|
|
274
|
+
|
|
275
|
+
if (name && !message.starts_with(*name + ": ")) {
|
|
276
|
+
message = *name + ": " + message;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
auto jsEngineValue = errorObj.getProperty(runtime, "jsEngine");
|
|
280
|
+
|
|
281
|
+
if (!isLooselyNull(jsEngineValue)) {
|
|
282
|
+
message += ", js engine: " + stringifyToCpp(runtime, jsEngineValue);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
auto extraDataKey = jsi::PropNameID::forUtf8(runtime, "RN$ErrorExtraDataKey");
|
|
286
|
+
auto extraDataValue = errorObj.getProperty(runtime, extraDataKey);
|
|
287
|
+
|
|
288
|
+
auto extraData = jsi::Object(runtime);
|
|
289
|
+
if (extraDataValue.isObject()) {
|
|
290
|
+
objectAssign(runtime, extraData, extraDataValue.asObject(runtime));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
auto isDEV =
|
|
294
|
+
isTruthy(runtime, runtime.global().getProperty(runtime, "__DEV__"));
|
|
295
|
+
|
|
296
|
+
extraData.setProperty(runtime, "jsEngine", jsEngineValue);
|
|
297
|
+
extraData.setProperty(runtime, "rawStack", error.getStack());
|
|
298
|
+
extraData.setProperty(runtime, "__DEV__", isDEV);
|
|
299
|
+
extraData.setProperty(
|
|
300
|
+
runtime, "bundleMetadata", getBundleMetadata(runtime, error));
|
|
301
|
+
|
|
302
|
+
auto cause = errorObj.getProperty(runtime, "cause");
|
|
303
|
+
if (cause.isObject()) {
|
|
304
|
+
auto causeObj = cause.asObject(runtime);
|
|
305
|
+
// TODO: Consider just forwarding all properties. For now, just forward the
|
|
306
|
+
// stack properties to maintain symmetry with js pipeline
|
|
307
|
+
auto stackSymbols = causeObj.getProperty(runtime, "stackSymbols");
|
|
308
|
+
extraData.setProperty(runtime, "stackSymbols", stackSymbols);
|
|
309
|
+
|
|
310
|
+
auto stackReturnAddresses =
|
|
311
|
+
causeObj.getProperty(runtime, "stackReturnAddresses");
|
|
312
|
+
extraData.setProperty(
|
|
313
|
+
runtime, "stackReturnAddresses", stackReturnAddresses);
|
|
314
|
+
|
|
315
|
+
auto stackElements = causeObj.getProperty(runtime, "stackElements");
|
|
316
|
+
extraData.setProperty(runtime, "stackElements", stackElements);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
auto originalMessage = message == error.getMessage()
|
|
320
|
+
? std::nullopt
|
|
321
|
+
: std::optional(error.getMessage());
|
|
322
|
+
|
|
323
|
+
auto componentStack = !componentStackValue.isString()
|
|
324
|
+
? std::nullopt
|
|
325
|
+
: std::optional(componentStackValue.asString(runtime).utf8(runtime));
|
|
326
|
+
|
|
327
|
+
auto isHermes = runtime.global().hasProperty(runtime, "HermesInternal");
|
|
328
|
+
auto stackFrames = StackTraceParser::parse(isHermes, error.getStack());
|
|
329
|
+
|
|
330
|
+
auto id = nextExceptionId();
|
|
331
|
+
|
|
332
|
+
ProcessedError processedError = {
|
|
333
|
+
.message =
|
|
334
|
+
_isRuntimeReady ? message : ("[runtime not ready]: " + message),
|
|
335
|
+
.originalMessage = originalMessage,
|
|
336
|
+
.name = name,
|
|
337
|
+
.componentStack = componentStack,
|
|
338
|
+
.stack = stackFrames,
|
|
339
|
+
.id = id,
|
|
340
|
+
.isFatal = isFatal,
|
|
341
|
+
.extraData = std::move(extraData),
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
auto data = bridging::toJs(runtime, processedError).asObject(runtime);
|
|
345
|
+
|
|
346
|
+
auto isComponentError =
|
|
347
|
+
isTruthy(runtime, errorObj.getProperty(runtime, "isComponentError"));
|
|
348
|
+
data.setProperty(runtime, "isComponentError", isComponentError);
|
|
349
|
+
|
|
350
|
+
if (logToConsole && runtime.global().hasProperty(runtime, "console")) { // [Windows] Added hasProperty check
|
|
351
|
+
auto console = runtime.global().getPropertyAsObject(runtime, "console");
|
|
352
|
+
auto errorFn = console.getPropertyAsFunction(runtime, "error");
|
|
353
|
+
auto finalMessage =
|
|
354
|
+
jsi::String::createFromUtf8(runtime, processedError.message);
|
|
355
|
+
errorFn.callWithThis(runtime, console, finalMessage);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
std::shared_ptr<bool> shouldPreventDefault = std::make_shared<bool>(false);
|
|
359
|
+
auto preventDefault = jsi::Function::createFromHostFunction(
|
|
360
|
+
runtime,
|
|
361
|
+
jsi::PropNameID::forAscii(runtime, "preventDefault"),
|
|
362
|
+
0,
|
|
363
|
+
[shouldPreventDefault](
|
|
364
|
+
jsi::Runtime& /*rt*/,
|
|
365
|
+
const jsi::Value& /*thisVal*/,
|
|
366
|
+
const jsi::Value* /*args*/,
|
|
367
|
+
size_t /*count*/) {
|
|
368
|
+
*shouldPreventDefault = true;
|
|
369
|
+
return jsi::Value::undefined();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
data.setProperty(runtime, "preventDefault", preventDefault);
|
|
373
|
+
|
|
374
|
+
for (auto& errorListener : _errorListeners) {
|
|
375
|
+
try {
|
|
376
|
+
errorListener(runtime, jsi::Value(runtime, data));
|
|
377
|
+
} catch (jsi::JSError& ex) {
|
|
378
|
+
logErrorWhileReporting(
|
|
379
|
+
"handleErrorWithCppPipeline(): Error raised inside an error listener. Executing next listener.",
|
|
380
|
+
ex,
|
|
381
|
+
error);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (*shouldPreventDefault) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
auto errorType = errorObj.getProperty(runtime, "type");
|
|
390
|
+
auto isWarn = isEqualTo(runtime, errorType, "warn");
|
|
391
|
+
|
|
392
|
+
if (isFatal || !isWarn) {
|
|
393
|
+
if (isFatal) {
|
|
394
|
+
if (_hasHandledFatalError) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
_hasHandledFatalError = true;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
_onJsError(runtime, processedError);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
void JsErrorHandler::registerErrorListener(
|
|
405
|
+
const std::function<void(jsi::Runtime&, jsi::Value)>& errorListener) {
|
|
406
|
+
_errorListeners.push_back(errorListener);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
bool JsErrorHandler::hasHandledFatalError() {
|
|
410
|
+
return _hasHandledFatalError;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
void JsErrorHandler::setRuntimeReady() {
|
|
414
|
+
_isRuntimeReady = true;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
bool JsErrorHandler::isRuntimeReady() {
|
|
418
|
+
return _isRuntimeReady;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
void JsErrorHandler::notifyOfFatalError() {
|
|
422
|
+
_hasHandledFatalError = true;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
bool JsErrorHandler::inErrorHandler() {
|
|
426
|
+
return *_inErrorHandler;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
} // namespace facebook::react
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <cxxreact/TraceSection.h>
|
|
13
13
|
#include <jsinspector-modern/ConsoleMessage.h>
|
|
14
14
|
#include <jsinspector-modern/InspectorInterfaces.h>
|
|
15
|
+
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
|
15
16
|
#include <mutex>
|
|
16
17
|
#include "SafeLoadLibrary.h"
|
|
17
18
|
|
|
@@ -324,6 +325,11 @@ void HermesRuntimeHolder::initRuntime() noexcept {
|
|
|
324
325
|
CRASH_ON_ERROR(api.jsr_config_set_inspector_runtime_name(config, devSettings->debuggerRuntimeName.c_str()));
|
|
325
326
|
CRASH_ON_ERROR(api.jsr_config_set_inspector_port(config, devSettings->debuggerPort));
|
|
326
327
|
CRASH_ON_ERROR(api.jsr_config_set_inspector_break_on_start(config, devSettings->debuggerBreakOnNextLine));
|
|
328
|
+
CRASH_ON_ERROR(api.jsr_config_set_explicit_microtasks(
|
|
329
|
+
config,
|
|
330
|
+
facebook::react::ReactNativeFeatureFlags::enableBridgelessArchitecture() &&
|
|
331
|
+
!facebook::react::ReactNativeFeatureFlags::disableEventLoopOnBridgeless()));
|
|
332
|
+
|
|
327
333
|
if (m_jsQueue) {
|
|
328
334
|
HermesTaskRunner::Create(config, m_jsQueue);
|
|
329
335
|
}
|
|
@@ -278,6 +278,10 @@ bool ChakraRuntime::drainMicrotasks(int /*maxMicrotasksHint*/) {
|
|
|
278
278
|
return true;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
void ChakraRuntime::queueMicrotask(const facebook::jsi::Function &) {
|
|
282
|
+
throw facebook::jsi::JSINativeException("Not implemented");
|
|
283
|
+
}
|
|
284
|
+
|
|
281
285
|
facebook::jsi::Object ChakraRuntime::global() {
|
|
282
286
|
return MakePointer<facebook::jsi::Object>(GetGlobalObject());
|
|
283
287
|
}
|
|
@@ -38,6 +38,8 @@ class ChakraRuntime : public facebook::jsi::Runtime, public ChakraApi, ChakraApi
|
|
|
38
38
|
|
|
39
39
|
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
|
|
40
40
|
|
|
41
|
+
void queueMicrotask(const facebook::jsi::Function &callback) override;
|
|
42
|
+
|
|
41
43
|
facebook::jsi::Object global() override;
|
|
42
44
|
|
|
43
45
|
std::string description() override;
|
|
@@ -35,28 +35,26 @@ namespace Microsoft::React {
|
|
|
35
35
|
|
|
36
36
|
#pragma region BlobTurboModule
|
|
37
37
|
|
|
38
|
-
void BlobTurboModule::Initialize(msrn::ReactContext const &reactContext) noexcept {
|
|
38
|
+
void BlobTurboModule::Initialize(msrn::ReactContext const &reactContext, facebook::jsi::Runtime &runtime) noexcept {
|
|
39
39
|
m_resource = IBlobResource::Make(reactContext.Properties().Handle());
|
|
40
40
|
m_resource->Callbacks().OnError = [&reactContext](string &&errorText) {
|
|
41
41
|
Modules::SendEvent(reactContext, L"blobFailed", {errorText});
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
namespace jsi = facebook::jsi;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
[
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}));
|
|
59
|
-
});
|
|
45
|
+
runtime.global().setProperty(
|
|
46
|
+
runtime,
|
|
47
|
+
"__blobCollectorProvider",
|
|
48
|
+
jsi::Function::createFromHostFunction(
|
|
49
|
+
runtime,
|
|
50
|
+
jsi::PropNameID::forAscii(runtime, "__blobCollectorProvider"),
|
|
51
|
+
1,
|
|
52
|
+
[resource = m_resource](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
|
|
53
|
+
auto blobId = args[0].asString(rt).utf8(rt);
|
|
54
|
+
auto collector = std::make_shared<BlobCollector>(blobId, resource);
|
|
55
|
+
|
|
56
|
+
return jsi::Object::createFromHostObject(rt, collector);
|
|
57
|
+
}));
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
ReactNativeSpecs::BlobModuleSpec_Constants BlobTurboModule::GetConstants() noexcept {
|
|
@@ -24,7 +24,9 @@ struct BlobTurboModule {
|
|
|
24
24
|
using ModuleSpec = ReactNativeSpecs::BlobModuleSpec;
|
|
25
25
|
|
|
26
26
|
REACT_INIT(Initialize)
|
|
27
|
-
void Initialize(
|
|
27
|
+
void Initialize(
|
|
28
|
+
winrt::Microsoft::ReactNative::ReactContext const &reactContext,
|
|
29
|
+
facebook::jsi::Runtime &runtime) noexcept;
|
|
28
30
|
|
|
29
31
|
REACT_GET_CONSTANTS(GetConstants)
|
|
30
32
|
ReactNativeSpecs::BlobModuleSpec_Constants GetConstants() noexcept;
|