react-native-windows 0.80.1 → 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 (83) 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/UriImageManager.cpp +5 -3
  9. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +6 -1
  10. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +14 -1
  11. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +75 -24
  12. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +4 -25
  13. package/Microsoft.ReactNative/JsiApi.cpp +1 -1
  14. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -0
  15. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +3 -0
  16. package/Microsoft.ReactNative/ReactHost/DebuggerNotifications.h +54 -0
  17. package/Microsoft.ReactNative/ReactHost/React.h +11 -4
  18. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +195 -29
  19. package/Microsoft.ReactNative/ReactHost/ReactHost.h +22 -4
  20. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +24 -5
  21. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  22. package/Microsoft.ReactNative/ReactRootView.cpp +108 -0
  23. package/Microsoft.ReactNative/ReactRootView.h +6 -0
  24. package/Microsoft.ReactNative/Views/DevMenu.cpp +1 -1
  25. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -1
  26. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  27. package/PropertySheets/JSEngine.props +1 -1
  28. package/PropertySheets/React.Cpp.props +2 -2
  29. package/ReactCommon/ReactCommon.vcxproj +18 -1
  30. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +1 -1
  31. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +4 -4
  32. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +23 -9
  33. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +16 -0
  34. package/ReactCommon/cgmanifest.json +1 -1
  35. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -0
  36. package/Shared/DevServerHelper.h +13 -3
  37. package/Shared/DevSettings.h +7 -0
  38. package/Shared/DevSupportManager.cpp +79 -20
  39. package/Shared/DevSupportManager.h +7 -19
  40. package/Shared/Hermes/HermesRuntimeAgentDelegate.cpp +99 -0
  41. package/Shared/Hermes/HermesRuntimeAgentDelegate.h +81 -0
  42. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +263 -0
  43. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +77 -0
  44. package/Shared/HermesRuntimeHolder.cpp +29 -111
  45. package/Shared/HermesRuntimeHolder.h +214 -32
  46. package/Shared/IDevSupportManager.h +5 -2
  47. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.cpp +108 -0
  48. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.h +19 -0
  49. package/Shared/Inspector/ReactInspectorThread.h +18 -0
  50. package/Shared/JSI/RuntimeHolder.h +5 -2
  51. package/Shared/OInstance.cpp +44 -27
  52. package/Shared/Shared.vcxitems +27 -17
  53. package/Shared/Shared.vcxitems.filters +33 -15
  54. package/package.json +4 -4
  55. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +0 -79
  56. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.h +0 -51
  57. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +0 -50
  58. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.cpp +0 -41
  59. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.h +0 -127
  60. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.inc +0 -125
  61. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +0 -16
  62. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_win.cpp +0 -23
  63. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +0 -1054
  64. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +0 -145
  65. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +0 -372
  66. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +0 -797
  67. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +0 -1799
  68. package/Microsoft.ReactNative.Cxx/JSI/threadsafe.h +0 -79
  69. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +0 -3531
  70. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +0 -38
  71. package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +0 -614
  72. package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +0 -212
  73. package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +0 -199
  74. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +0 -78
  75. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +0 -196
  76. package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +0 -429
  77. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.cpp +0 -45
  78. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.h +0 -91
  79. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +0 -670
  80. package/Shared/InspectorPackagerConnection.cpp +0 -232
  81. package/Shared/InspectorPackagerConnection.h +0 -61
  82. /package/Shared/{HermesSamplingProfiler.cpp → Hermes/HermesSamplingProfiler.cpp} +0 -0
  83. /package/Shared/{HermesSamplingProfiler.h → Hermes/HermesSamplingProfiler.h} +0 -0
@@ -1,212 +0,0 @@
1
- #ifndef SRC_JS_NATIVE_API_TYPES_H_
2
- #define SRC_JS_NATIVE_API_TYPES_H_
3
-
4
- // This file needs to be compatible with C compilers.
5
- // This is a public include file, and these includes have essentially
6
- // became part of it's API.
7
- #include <stddef.h> // NOLINT(modernize-deprecated-headers)
8
- #include <stdint.h> // NOLINT(modernize-deprecated-headers)
9
-
10
- // TODO: (vmoroz) NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT is not part of this
11
- // Node-API file. It is here temporary to enable compilation. Remove it after
12
- // updating tests.
13
- #define NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT
14
-
15
- #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
16
- typedef uint16_t char16_t;
17
- #endif
18
-
19
- #ifndef NAPI_CDECL
20
- #ifdef _WIN32
21
- #define NAPI_CDECL __cdecl
22
- #else
23
- #define NAPI_CDECL
24
- #endif
25
- #endif
26
-
27
- // JSVM API types are all opaque pointers for ABI stability
28
- // typedef undefined structs instead of void* for compile time type safety
29
- typedef struct napi_env__* napi_env;
30
-
31
- // We need to mark APIs which can be called during garbage collection (GC),
32
- // meaning that they do not affect the state of the JS engine, and can
33
- // therefore be called synchronously from a finalizer that itself runs
34
- // synchronously during GC. Such APIs can receive either a `napi_env` or a
35
- // `node_api_nogc_env` as their first parameter, because we should be able to
36
- // also call them during normal, non-garbage-collecting operations, whereas
37
- // APIs that affect the state of the JS engine can only receive a `napi_env` as
38
- // their first parameter, because we must not call them during GC. In lieu of
39
- // inheritance, we use the properties of the const qualifier to accomplish
40
- // this, because both a const and a non-const value can be passed to an API
41
- // expecting a const value, but only a non-const value can be passed to an API
42
- // expecting a non-const value.
43
- //
44
- // In conjunction with appropriate CFLAGS to warn us if we're passing a const
45
- // (nogc) environment into an API that expects a non-const environment, and the
46
- // definition of nogc finalizer function pointer types below, which receive a
47
- // nogc environment as their first parameter, and can thus only call nogc APIs
48
- // (unless the user explicitly casts the environment), we achieve the ability
49
- // to ensure at compile time that we do not call APIs that affect the state of
50
- // the JS engine from a synchronous (nogc) finalizer.
51
- #if !defined(NAPI_EXPERIMENTAL) || \
52
- (defined(NAPI_EXPERIMENTAL) && \
53
- defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT))
54
- typedef struct napi_env__* node_api_nogc_env;
55
- #else
56
- typedef const struct napi_env__* node_api_nogc_env;
57
- #endif
58
-
59
- typedef struct napi_value__* napi_value;
60
- typedef struct napi_ref__* napi_ref;
61
- typedef struct napi_handle_scope__* napi_handle_scope;
62
- typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
63
- typedef struct napi_callback_info__* napi_callback_info;
64
- typedef struct napi_deferred__* napi_deferred;
65
-
66
- typedef enum {
67
- napi_default = 0,
68
- napi_writable = 1 << 0,
69
- napi_enumerable = 1 << 1,
70
- napi_configurable = 1 << 2,
71
-
72
- // Used with napi_define_class to distinguish static properties
73
- // from instance properties. Ignored by napi_define_properties.
74
- napi_static = 1 << 10,
75
-
76
- #if NAPI_VERSION >= 8
77
- // Default for class methods.
78
- napi_default_method = napi_writable | napi_configurable,
79
-
80
- // Default for object properties, like in JS obj[prop].
81
- napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable,
82
- #endif // NAPI_VERSION >= 8
83
- } napi_property_attributes;
84
-
85
- typedef enum {
86
- // ES6 types (corresponds to typeof)
87
- napi_undefined,
88
- napi_null,
89
- napi_boolean,
90
- napi_number,
91
- napi_string,
92
- napi_symbol,
93
- napi_object,
94
- napi_function,
95
- napi_external,
96
- napi_bigint,
97
- } napi_valuetype;
98
-
99
- typedef enum {
100
- napi_int8_array,
101
- napi_uint8_array,
102
- napi_uint8_clamped_array,
103
- napi_int16_array,
104
- napi_uint16_array,
105
- napi_int32_array,
106
- napi_uint32_array,
107
- napi_float32_array,
108
- napi_float64_array,
109
- napi_bigint64_array,
110
- napi_biguint64_array,
111
- } napi_typedarray_type;
112
-
113
- typedef enum {
114
- napi_ok,
115
- napi_invalid_arg,
116
- napi_object_expected,
117
- napi_string_expected,
118
- napi_name_expected,
119
- napi_function_expected,
120
- napi_number_expected,
121
- napi_boolean_expected,
122
- napi_array_expected,
123
- napi_generic_failure,
124
- napi_pending_exception,
125
- napi_cancelled,
126
- napi_escape_called_twice,
127
- napi_handle_scope_mismatch,
128
- napi_callback_scope_mismatch,
129
- napi_queue_full,
130
- napi_closing,
131
- napi_bigint_expected,
132
- napi_date_expected,
133
- napi_arraybuffer_expected,
134
- napi_detachable_arraybuffer_expected,
135
- napi_would_deadlock, // unused
136
- napi_no_external_buffers_allowed,
137
- napi_cannot_run_js,
138
- } napi_status;
139
- // Note: when adding a new enum value to `napi_status`, please also update
140
- // * `const int last_status` in the definition of `napi_get_last_error_info()'
141
- // in file js_native_api_v8.cc.
142
- // * `const char* error_messages[]` in file js_native_api_v8.cc with a brief
143
- // message explaining the error.
144
- // * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
145
- // added value(s).
146
-
147
- typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
148
- napi_callback_info info);
149
- typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
150
- void* finalize_data,
151
- void* finalize_hint);
152
-
153
- #if !defined(NAPI_EXPERIMENTAL) || \
154
- (defined(NAPI_EXPERIMENTAL) && \
155
- defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT))
156
- typedef napi_finalize node_api_nogc_finalize;
157
- #else
158
- typedef void(NAPI_CDECL* node_api_nogc_finalize)(node_api_nogc_env env,
159
- void* finalize_data,
160
- void* finalize_hint);
161
- #endif
162
-
163
- typedef struct {
164
- // One of utf8name or name should be NULL.
165
- const char* utf8name;
166
- napi_value name;
167
-
168
- napi_callback method;
169
- napi_callback getter;
170
- napi_callback setter;
171
- napi_value value;
172
-
173
- napi_property_attributes attributes;
174
- void* data;
175
- } napi_property_descriptor;
176
-
177
- typedef struct {
178
- const char* error_message;
179
- void* engine_reserved;
180
- uint32_t engine_error_code;
181
- napi_status error_code;
182
- } napi_extended_error_info;
183
-
184
- #if NAPI_VERSION >= 6
185
- typedef enum {
186
- napi_key_include_prototypes,
187
- napi_key_own_only
188
- } napi_key_collection_mode;
189
-
190
- typedef enum {
191
- napi_key_all_properties = 0,
192
- napi_key_writable = 1,
193
- napi_key_enumerable = 1 << 1,
194
- napi_key_configurable = 1 << 2,
195
- napi_key_skip_strings = 1 << 3,
196
- napi_key_skip_symbols = 1 << 4
197
- } napi_key_filter;
198
-
199
- typedef enum {
200
- napi_key_keep_numbers,
201
- napi_key_numbers_to_strings
202
- } napi_key_conversion;
203
- #endif // NAPI_VERSION >= 6
204
-
205
- #if NAPI_VERSION >= 8
206
- typedef struct {
207
- uint64_t lower;
208
- uint64_t upper;
209
- } napi_type_tag;
210
- #endif // NAPI_VERSION >= 8
211
-
212
- #endif // SRC_JS_NATIVE_API_TYPES_H_
@@ -1,199 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
-
4
- #ifndef SRC_JS_RUNTIME_API_H_
5
- #define SRC_JS_RUNTIME_API_H_
6
-
7
- #include "js_native_api.h"
8
-
9
- //
10
- // Node-API extensions required for JavaScript engine hosting.
11
- //
12
- // It is a very early version of the APIs which we consider to be experimental.
13
- // These APIs are not stable yet and are subject to change while we continue
14
- // their development. After some time we will stabilize the APIs and make them
15
- // "officially stable".
16
- //
17
-
18
- #define JSR_API NAPI_EXTERN napi_status NAPI_CDECL
19
-
20
- EXTERN_C_START
21
-
22
- typedef struct jsr_runtime_s* jsr_runtime;
23
- typedef struct jsr_config_s* jsr_config;
24
- typedef struct jsr_prepared_script_s* jsr_prepared_script;
25
- typedef struct jsr_napi_env_scope_s* jsr_napi_env_scope;
26
-
27
- typedef void(NAPI_CDECL* jsr_data_delete_cb)(void* data, void* deleter_data);
28
-
29
- //=============================================================================
30
- // jsr_runtime
31
- //=============================================================================
32
-
33
- JSR_API jsr_create_runtime(jsr_config config, jsr_runtime* runtime);
34
- JSR_API jsr_delete_runtime(jsr_runtime runtime);
35
- JSR_API jsr_runtime_get_node_api_env(jsr_runtime runtime, napi_env* env);
36
-
37
- //=============================================================================
38
- // jsr_config
39
- //=============================================================================
40
-
41
- JSR_API jsr_create_config(jsr_config* config);
42
- JSR_API jsr_delete_config(jsr_config config);
43
-
44
- JSR_API jsr_config_enable_inspector(jsr_config config, bool value);
45
- JSR_API jsr_config_set_inspector_runtime_name(jsr_config config,
46
- const char* name);
47
- JSR_API jsr_config_set_inspector_port(jsr_config config, uint16_t port);
48
- JSR_API jsr_config_set_inspector_break_on_start(jsr_config config, bool value);
49
-
50
- JSR_API jsr_config_enable_gc_api(jsr_config config, bool value);
51
-
52
- JSR_API jsr_config_set_explicit_microtasks(jsr_config config, bool value);
53
-
54
- //=============================================================================
55
- // jsr_config task runner
56
- //=============================================================================
57
-
58
- // A callback to run task
59
- typedef void(NAPI_CDECL* jsr_task_run_cb)(void* task_data);
60
-
61
- // A callback to post task to the task runner
62
- typedef void(NAPI_CDECL* jsr_task_runner_post_task_cb)(
63
- void* task_runner_data,
64
- void* task_data,
65
- jsr_task_run_cb task_run_cb,
66
- jsr_data_delete_cb task_data_delete_cb,
67
- void* deleter_data);
68
-
69
- JSR_API jsr_config_set_task_runner(
70
- jsr_config config,
71
- void* task_runner_data,
72
- jsr_task_runner_post_task_cb task_runner_post_task_cb,
73
- jsr_data_delete_cb task_runner_data_delete_cb,
74
- void* deleter_data);
75
-
76
- //=============================================================================
77
- // jsr_config script cache
78
- //=============================================================================
79
-
80
- typedef void(NAPI_CDECL* jsr_script_cache_load_cb)(
81
- void* script_cache_data,
82
- const char* source_url,
83
- uint64_t source_hash,
84
- const char* runtime_name,
85
- uint64_t runtime_version,
86
- const char* cache_tag,
87
- const uint8_t** buffer,
88
- size_t* buffer_size,
89
- jsr_data_delete_cb* buffer_delete_cb,
90
- void** deleter_data);
91
-
92
- typedef void(NAPI_CDECL* jsr_script_cache_store_cb)(
93
- void* script_cache_data,
94
- const char* source_url,
95
- uint64_t source_hash,
96
- const char* runtime_name,
97
- uint64_t runtime_version,
98
- const char* cache_tag,
99
- const uint8_t* buffer,
100
- size_t buffer_size,
101
- jsr_data_delete_cb buffer_delete_cb,
102
- void* deleter_data);
103
-
104
- JSR_API jsr_config_set_script_cache(
105
- jsr_config config,
106
- void* script_cache_data,
107
- jsr_script_cache_load_cb script_cache_load_cb,
108
- jsr_script_cache_store_cb script_cache_store_cb,
109
- jsr_data_delete_cb script_cache_data_delete_cb,
110
- void* deleter_data);
111
-
112
- //=============================================================================
113
- // napi_env scope
114
- //=============================================================================
115
-
116
- // Opens the napi_env scope in the current thread.
117
- // Calling Node-API functions without the opened scope may cause a failure.
118
- // The scope must be closed by the jsr_close_napi_env_scope call.
119
- JSR_API jsr_open_napi_env_scope(napi_env env, jsr_napi_env_scope* scope);
120
-
121
- // Closes the napi_env scope in the current thread. It must match to the
122
- // jsr_open_napi_env_scope call.
123
- JSR_API jsr_close_napi_env_scope(napi_env env, jsr_napi_env_scope scope);
124
-
125
- //=============================================================================
126
- // Additional functions to implement JSI
127
- //=============================================================================
128
-
129
- // To implement JSI description()
130
- JSR_API jsr_get_description(napi_env env, const char** result);
131
-
132
- // To implement JSI queueMicrotask()
133
- JSR_API jsr_queue_microtask(napi_env env, napi_value callback);
134
-
135
- // To implement JSI drainMicrotasks()
136
- JSR_API
137
- jsr_drain_microtasks(napi_env env, int32_t max_count_hint, bool* result);
138
-
139
- // To implement JSI isInspectable()
140
- JSR_API jsr_is_inspectable(napi_env env, bool* result);
141
-
142
- //=============================================================================
143
- // Script preparing and running.
144
- //
145
- // Script is usually converted to byte code, or in other words - prepared - for
146
- // execution. Then, we can run the prepared script.
147
- //=============================================================================
148
-
149
- // Run script with source URL.
150
- JSR_API jsr_run_script(napi_env env,
151
- napi_value source,
152
- const char* source_url,
153
- napi_value* result);
154
-
155
- // Prepare the script for running.
156
- JSR_API jsr_create_prepared_script(napi_env env,
157
- const uint8_t* script_data,
158
- size_t script_length,
159
- jsr_data_delete_cb script_delete_cb,
160
- void* deleter_data,
161
- const char* source_url,
162
- jsr_prepared_script* result);
163
-
164
- // Delete the prepared script.
165
- JSR_API jsr_delete_prepared_script(napi_env env,
166
- jsr_prepared_script prepared_script);
167
-
168
- // Run the prepared script.
169
- JSR_API jsr_prepared_script_run(napi_env env,
170
- jsr_prepared_script prepared_script,
171
- napi_value* result);
172
-
173
- //=============================================================================
174
- // Functions to support unit tests.
175
- //=============================================================================
176
-
177
- // Provides a hint to run garbage collection.
178
- // It is typically used for unit tests.
179
- // It requires enabling GC by calling jsr_config_enable_gc_api.
180
- JSR_API jsr_collect_garbage(napi_env env);
181
-
182
- // Checks if the environment has an unhandled promise rejection.
183
- JSR_API jsr_has_unhandled_promise_rejection(napi_env env, bool* result);
184
-
185
- // Gets and clears the last unhandled promise rejection.
186
- JSR_API jsr_get_and_clear_last_unhandled_promise_rejection(napi_env env,
187
- napi_value* result);
188
-
189
- // Create new napi_env for the runtime.
190
- JSR_API jsr_create_node_api_env(napi_env root_env,
191
- int32_t api_version,
192
- napi_env* env);
193
-
194
- // Run task in the environment context.
195
- JSR_API jsr_run_task(napi_env env, jsr_task_run_cb task_cb, void* data);
196
-
197
- EXTERN_C_END
198
-
199
- #endif // !SRC_JS_RUNTIME_API_H_
@@ -1,78 +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 "JSExecutor.h"
9
-
10
- #include "RAMBundleRegistry.h"
11
-
12
- #include <jsinspector-modern/ReactCdp.h>
13
- #include <jsinspector-modern/tracing/InstanceTracingProfile.h>
14
- #include <react/timing/primitives.h>
15
-
16
- #include <array>
17
- #include <chrono>
18
-
19
- namespace facebook::react {
20
-
21
- std::string JSExecutor::getSyntheticBundlePath(
22
- uint32_t bundleId,
23
- const std::string& bundlePath) {
24
- if (bundleId == RAMBundleRegistry::MAIN_BUNDLE_ID) {
25
- return bundlePath;
26
- }
27
-
28
- std::array<char, 32> buffer{};
29
- std::snprintf(buffer.data(), buffer.size(), "seg-%u.js", bundleId);
30
- return buffer.data();
31
- }
32
-
33
- double JSExecutor::performanceNow() {
34
- return chronoToDOMHighResTimeStamp(std::chrono::steady_clock::now());
35
- }
36
-
37
- void JSExecutor::addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message){
38
- return;
39
- }
40
-
41
- bool JSExecutor::supportsConsole() const {
42
- return false;
43
- }
44
-
45
- std::unique_ptr<facebook::react::jsinspector_modern::StackTrace> JSExecutor::captureStackTrace(
46
- facebook::jsi::Runtime &runtime,
47
- size_t framesToSkip) {
48
- return std::make_unique<facebook::react::jsinspector_modern::StackTrace>();
49
- }
50
-
51
- void JSExecutor::enableSamplingProfiler() {
52
- return; // [Windows TODO: stubbed implementation #14700]
53
- }
54
-
55
- void JSExecutor::disableSamplingProfiler() {
56
- return; // [Windows TODO: stubbed implementation #14700]
57
- }
58
-
59
- facebook::react::jsinspector_modern::tracing::RuntimeSamplingProfile JSExecutor::collectSamplingProfile() {
60
- return facebook::react::jsinspector_modern::tracing::RuntimeSamplingProfile(
61
- "stubbed_impl", {}); // [Windows TODO: stubbed implementation #14700]
62
- }
63
-
64
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate>
65
- JSExecutor::createAgentDelegate(
66
- jsinspector_modern::FrontendChannel frontendChannel,
67
- jsinspector_modern::SessionState& sessionState,
68
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate::ExportedState>,
69
- const jsinspector_modern::ExecutionContextDescription&
70
- executionContextDescription,
71
- RuntimeExecutor runtimeExecutor) {
72
- (void)executionContextDescription;
73
- (void)runtimeExecutor;
74
- return std::make_unique<jsinspector_modern::FallbackRuntimeAgentDelegate>(
75
- std::move(frontendChannel), sessionState, getDescription());
76
- }
77
-
78
- } // namespace facebook::react
@@ -1,196 +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 <string>
12
-
13
- #include <cxxreact/NativeModule.h>
14
- #include <folly/dynamic.h>
15
- #include <jsinspector-modern/InspectorInterfaces.h>
16
- #include <jsinspector-modern/FallbackRuntimeAgentDelegate.h>
17
- #include <jsinspector-modern/ReactCdp.h>
18
- #include <jsinspector-modern/ConsoleMessage.h>
19
- #include <jsinspector-modern/StackTrace.h>
20
-
21
- #ifndef RN_EXPORT
22
- #define RN_EXPORT __attribute__((visibility("default")))
23
- #endif
24
-
25
- namespace facebook::react {
26
-
27
- class JSBigString;
28
- class JSExecutor;
29
- class JSModulesUnbundle;
30
- class MessageQueueThread;
31
- class ModuleRegistry;
32
- class RAMBundleRegistry;
33
-
34
- // This interface describes the delegate interface required by
35
- // Executor implementations to call from JS into native code.
36
- class ExecutorDelegate {
37
- public:
38
- virtual ~ExecutorDelegate() {}
39
-
40
- virtual std::shared_ptr<ModuleRegistry> getModuleRegistry() = 0;
41
-
42
- virtual void callNativeModules(
43
- JSExecutor& executor,
44
- folly::dynamic&& calls,
45
- bool isEndOfBatch) = 0;
46
- virtual MethodCallResult callSerializableNativeHook(
47
- JSExecutor& executor,
48
- unsigned int moduleId,
49
- unsigned int methodId,
50
- folly::dynamic&& args) = 0;
51
- };
52
-
53
- class JSExecutorFactory {
54
- public:
55
- virtual std::unique_ptr<JSExecutor> createJSExecutor(
56
- std::shared_ptr<ExecutorDelegate> delegate,
57
- std::shared_ptr<MessageQueueThread> jsQueue) = 0;
58
- virtual ~JSExecutorFactory() {}
59
- };
60
-
61
- class RN_EXPORT JSExecutor : public jsinspector_modern::RuntimeTargetDelegate {
62
- public:
63
- /**
64
- * Prepares the JS runtime for React Native by installing global variables.
65
- * Called once before any JS is evaluated.
66
- */
67
- virtual void initializeRuntime() = 0;
68
- /**
69
- * Execute an application script bundle in the JS context.
70
- */
71
- virtual void loadBundle(
72
- std::unique_ptr<const JSBigString> script,
73
- std::string sourceURL) = 0;
74
-
75
- /**
76
- * Add an application "RAM" bundle registry
77
- */
78
- virtual void setBundleRegistry(
79
- std::unique_ptr<RAMBundleRegistry> bundleRegistry) = 0;
80
-
81
- /**
82
- * Register a file path for an additional "RAM" bundle
83
- */
84
- virtual void registerBundle(
85
- uint32_t bundleId,
86
- const std::string& bundlePath) = 0;
87
-
88
- /**
89
- * Executes BatchedBridge.callFunctionReturnFlushedQueue with the module ID,
90
- * method ID and optional additional arguments in JS. The executor is
91
- * responsible for using Bridge->callNativeModules to invoke any necessary
92
- * native modules methods.
93
- */
94
- virtual void callFunction(
95
- const std::string& moduleId,
96
- const std::string& methodId,
97
- const folly::dynamic& arguments) = 0;
98
-
99
- /**
100
- * Executes BatchedBridge.invokeCallbackAndReturnFlushedQueue with the cbID,
101
- * and optional additional arguments in JS and returns the next queue. The
102
- * executor is responsible for using Bridge->callNativeModules to invoke any
103
- * necessary native modules methods.
104
- */
105
- virtual void invokeCallback(
106
- const double callbackId,
107
- const folly::dynamic& arguments) = 0;
108
-
109
- virtual void setGlobalVariable(
110
- std::string propName,
111
- std::unique_ptr<const JSBigString> jsonValue) = 0;
112
-
113
- virtual void* getJavaScriptContext() {
114
- return nullptr;
115
- }
116
-
117
- /**
118
- * Returns whether or not the underlying executor supports debugging via the
119
- * Chrome remote debugging protocol. If true, the executor should also
120
- * override the \c createAgentDelegate method.
121
- */
122
- virtual bool isInspectable() {
123
- return false;
124
- }
125
-
126
- /**
127
- * The description is displayed in the dev menu, if there is one in
128
- * this build. There is a default, but if this method returns a
129
- * non-empty string, it will be used instead.
130
- */
131
- virtual std::string getDescription() = 0;
132
-
133
- virtual void handleMemoryPressure([[maybe_unused]] int pressureLevel) {}
134
-
135
- virtual void destroy() {}
136
- virtual ~JSExecutor() override {}
137
-
138
- virtual void flush() {}
139
-
140
- static std::string getSyntheticBundlePath(
141
- uint32_t bundleId,
142
- const std::string& bundlePath);
143
-
144
- static double performanceNow();
145
-
146
- virtual void addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message);
147
-
148
- virtual bool supportsConsole() const;
149
-
150
- /**
151
- * \returns an opaque representation of a stack trace. This may be passed back
152
- * to the `RuntimeTargetDelegate` as part of `addConsoleMessage` or other APIs
153
- * that report stack traces.
154
- * \param framesToSkip The number of call frames to skip. The first call frame
155
- * is the topmost (current) frame on the Runtime's call stack, which will
156
- * typically be the (native) JSI HostFunction that called this method.
157
- * \note The method is called on the JS thread, and receives a valid reference
158
- * to the current \c jsi::Runtime. The callee MAY use its own intrinsic
159
- * Runtime reference, if it has one, without checking it for equivalence with
160
- * the one provided here.
161
- */
162
- std::unique_ptr<jsinspector_modern::StackTrace> captureStackTrace(
163
- jsi::Runtime& runtime,
164
- size_t framesToSkip = 0) override;
165
-
166
-
167
- /**
168
- * Start sampling profiler.
169
- */
170
- virtual void enableSamplingProfiler() override;
171
-
172
- /**
173
- * Stop sampling profiler.
174
- */
175
- virtual void disableSamplingProfiler() override;
176
-
177
- /**
178
- * Return recorded sampling profile for the previous sampling session.
179
- */
180
- virtual facebook::react::jsinspector_modern::tracing::RuntimeSamplingProfile collectSamplingProfile() override;
181
-
182
- /**
183
- * Create a RuntimeAgentDelegate that can be used to debug the JS VM instance.
184
- */
185
- virtual std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate>
186
- createAgentDelegate(
187
- jsinspector_modern::FrontendChannel frontendChannel,
188
- jsinspector_modern::SessionState& sessionState,
189
- std::unique_ptr<jsinspector_modern::RuntimeAgentDelegate::ExportedState>
190
- previouslyExportedState,
191
- const jsinspector_modern::ExecutionContextDescription&
192
- executionContextDescription,
193
- RuntimeExecutor runtimeExecutor) override;
194
- };
195
-
196
- } // namespace facebook::react