react-native-windows 0.80.0 → 0.80.5

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.
Files changed (86) hide show
  1. package/Directory.Build.props +1 -1
  2. package/Microsoft.ReactNative/Fabric/Composition/DebuggerUIIsland.cpp +169 -0
  3. package/Microsoft.ReactNative/Fabric/Composition/DebuggerUIIsland.h +42 -0
  4. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -1
  5. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +60 -33
  6. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +68 -1
  7. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +9 -0
  8. package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +5 -37
  9. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -3
  10. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +6 -1
  11. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +14 -1
  12. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +0 -17
  13. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h +0 -3
  14. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +75 -24
  15. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +4 -25
  16. package/Microsoft.ReactNative/JsiApi.cpp +1 -1
  17. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -0
  18. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +3 -0
  19. package/Microsoft.ReactNative/ReactHost/DebuggerNotifications.h +54 -0
  20. package/Microsoft.ReactNative/ReactHost/React.h +11 -4
  21. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +195 -29
  22. package/Microsoft.ReactNative/ReactHost/ReactHost.h +22 -4
  23. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +24 -5
  24. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  25. package/Microsoft.ReactNative/ReactRootView.cpp +108 -0
  26. package/Microsoft.ReactNative/ReactRootView.h +6 -0
  27. package/Microsoft.ReactNative/Views/DevMenu.cpp +1 -1
  28. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -1
  29. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  30. package/PropertySheets/JSEngine.props +1 -1
  31. package/PropertySheets/React.Cpp.props +2 -2
  32. package/ReactCommon/ReactCommon.vcxproj +18 -1
  33. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +1 -1
  34. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +4 -4
  35. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +23 -9
  36. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +16 -0
  37. package/ReactCommon/cgmanifest.json +1 -1
  38. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -0
  39. package/Shared/DevServerHelper.h +13 -3
  40. package/Shared/DevSettings.h +7 -0
  41. package/Shared/DevSupportManager.cpp +79 -20
  42. package/Shared/DevSupportManager.h +7 -19
  43. package/Shared/Hermes/HermesRuntimeAgentDelegate.cpp +99 -0
  44. package/Shared/Hermes/HermesRuntimeAgentDelegate.h +81 -0
  45. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +263 -0
  46. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +77 -0
  47. package/Shared/HermesRuntimeHolder.cpp +29 -111
  48. package/Shared/HermesRuntimeHolder.h +214 -32
  49. package/Shared/IDevSupportManager.h +5 -2
  50. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.cpp +108 -0
  51. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.h +19 -0
  52. package/Shared/Inspector/ReactInspectorThread.h +18 -0
  53. package/Shared/JSI/RuntimeHolder.h +5 -2
  54. package/Shared/OInstance.cpp +44 -27
  55. package/Shared/Shared.vcxitems +27 -17
  56. package/Shared/Shared.vcxitems.filters +33 -15
  57. package/package.json +4 -4
  58. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +0 -79
  59. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.h +0 -51
  60. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +0 -50
  61. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.cpp +0 -41
  62. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.h +0 -127
  63. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.inc +0 -125
  64. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +0 -16
  65. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_win.cpp +0 -23
  66. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +0 -1054
  67. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +0 -145
  68. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +0 -372
  69. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +0 -797
  70. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +0 -1799
  71. package/Microsoft.ReactNative.Cxx/JSI/threadsafe.h +0 -79
  72. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +0 -3531
  73. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +0 -38
  74. package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +0 -614
  75. package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +0 -212
  76. package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +0 -199
  77. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +0 -78
  78. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +0 -196
  79. package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +0 -429
  80. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.cpp +0 -45
  81. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.h +0 -91
  82. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +0 -670
  83. package/Shared/InspectorPackagerConnection.cpp +0 -232
  84. package/Shared/InspectorPackagerConnection.h +0 -61
  85. /package/Shared/{HermesSamplingProfiler.cpp → Hermes/HermesSamplingProfiler.cpp} +0 -0
  86. /package/Shared/{HermesSamplingProfiler.h → Hermes/HermesSamplingProfiler.h} +0 -0
@@ -1,429 +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 "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
@@ -1,45 +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 "JSRuntimeFactory.h"
9
- #include <jsinspector-modern/ConsoleMessage.h>
10
- #include <jsinspector-modern/FallbackRuntimeAgentDelegate.h>
11
-
12
- namespace facebook::react {
13
-
14
- jsi::Runtime& JSIRuntimeHolder::getRuntime() noexcept {
15
- return *runtime_;
16
- }
17
-
18
- JSIRuntimeHolder::JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime)
19
- : runtime_(std::move(runtime)) {
20
- assert(runtime_ != nullptr);
21
- }
22
-
23
- void JSIRuntimeHolder::addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message) {
24
- return;
25
- }
26
-
27
- bool JSIRuntimeHolder::supportsConsole() const{
28
- return false;
29
- }
30
-
31
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate>
32
- JSIRuntimeHolder::createAgentDelegate(
33
- jsinspector_modern::FrontendChannel frontendChannel,
34
- jsinspector_modern::SessionState& sessionState,
35
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate::ExportedState>,
36
- const jsinspector_modern::ExecutionContextDescription&
37
- executionContextDescription,
38
- RuntimeExecutor runtimeExecutor) {
39
- (void)executionContextDescription;
40
- (void)runtimeExecutor;
41
- return std::make_unique<jsinspector_modern::FallbackRuntimeAgentDelegate>(
42
- std::move(frontendChannel), sessionState, runtime_->description());
43
- }
44
-
45
- } // namespace facebook::react
@@ -1,91 +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
- #ifdef __cplusplus
11
-
12
- #include <ReactCommon/RuntimeExecutor.h>
13
- #include <cxxreact/MessageQueueThread.h>
14
- #include <jsinspector-modern/ConsoleMessage.h>
15
- #include <jsi/jsi.h>
16
- #include <jsinspector-modern/ReactCdp.h>
17
-
18
-
19
- namespace facebook::react {
20
-
21
- /**
22
- * An interface that represents an instance of a JS VM
23
- */
24
- class JSRuntime : public jsinspector_modern::RuntimeTargetDelegate {
25
- public:
26
- virtual jsi::Runtime& getRuntime() noexcept = 0;
27
-
28
- virtual ~JSRuntime() = default;
29
-
30
- /**
31
- * Get a reference to the \c RuntimeTargetDelegate owned (or implemented) by
32
- * this JSRuntime. This reference must remain valid for the duration of the
33
- * JSRuntime's lifetime.
34
- */
35
- // virtual jsinspector_modern::RuntimeTargetDelegate& getRuntimeTargetDelegate();
36
-
37
- /**
38
- * Run initialize work that must happen on the runtime's JS thread. Used for
39
- * initializing TLS and registering profiling.
40
- *
41
- * TODO T194671568 Move the runtime constructor to the JsThread
42
- */
43
- virtual void unstable_initializeOnJsThread() {}
44
-
45
- private:
46
- /**
47
- * Initialized by \c getRuntimeTargetDelegate if not overridden, and then
48
- * never changes.
49
- */
50
- std::optional<jsinspector_modern::FallbackRuntimeTargetDelegate>
51
- runtimeTargetDelegate_;
52
- };
53
-
54
- /**
55
- * Interface for a class that creates instances of a JS VM
56
- */
57
- class JSRuntimeFactory {
58
- public:
59
- virtual std::unique_ptr<JSRuntime> createJSRuntime(
60
- std::shared_ptr<MessageQueueThread> msgQueueThread) noexcept = 0;
61
-
62
- virtual ~JSRuntimeFactory() = default;
63
- };
64
-
65
- /**
66
- * Utility class for creating a JSRuntime from a uniquely owned jsi::Runtime.
67
- */
68
- class JSIRuntimeHolder : public JSRuntime {
69
- public:
70
- jsi::Runtime& getRuntime() noexcept override;
71
- void addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message) override;
72
- bool supportsConsole() const override;
73
-
74
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate> createAgentDelegate(
75
- jsinspector_modern::FrontendChannel frontendChannel,
76
- jsinspector_modern::SessionState& sessionState,
77
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate::ExportedState>
78
- previouslyExportedState,
79
- const jsinspector_modern::ExecutionContextDescription&
80
- executionContextDescription,
81
- RuntimeExecutor runtimeExecutor) override;
82
-
83
- explicit JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime);
84
-
85
- private:
86
- std::unique_ptr<jsi::Runtime> runtime_;
87
- };
88
-
89
- } // namespace facebook::react
90
-
91
- #endif // __cplusplus