react-native-windows 0.71.24 → 0.71.25
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 +5 -0
- package/Libraries/Network/RCTNetworking.windows.js +10 -16
- package/Microsoft.ReactNative/IReactDispatcher.cpp +4 -0
- package/Microsoft.ReactNative/IReactDispatcher.h +1 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +3 -7
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -7
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +43 -21
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +0 -2
- package/Microsoft.ReactNative/Views/DevMenu.cpp +3 -3
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +16 -0
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +43 -12
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +17 -6
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +4 -4
- package/PropertySheets/React.Cpp.props +3 -3
- package/PropertySheets/Warnings.props +6 -0
- package/ReactCommon/ReactCommon.vcxproj +53 -1
- package/ReactCommon/cgmanifest.json +15 -0
- package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +36 -0
- package/Shared/BaseFileReaderResource.cpp +95 -0
- package/Shared/BaseFileReaderResource.h +41 -0
- package/Shared/CreateModules.h +27 -5
- package/Shared/DevSupportManager.cpp +2 -9
- package/Shared/DevSupportManager.h +2 -6
- package/Shared/HermesRuntimeHolder.cpp +344 -84
- package/Shared/HermesRuntimeHolder.h +32 -21
- package/Shared/HermesSamplingProfiler.cpp +66 -14
- package/Shared/HermesSamplingProfiler.h +5 -3
- package/Shared/IFileReaderResource.h +36 -0
- package/Shared/InspectorPackagerConnection.cpp +62 -108
- package/Shared/InspectorPackagerConnection.h +9 -21
- package/Shared/JSI/RuntimeHolder.h +2 -2
- package/Shared/JSI/ScriptStore.h +18 -20
- package/Shared/JSI/V8RuntimeHolder.cpp +260 -0
- package/Shared/JSI/V8RuntimeHolder.h +37 -0
- package/Shared/Modules/BlobModule.cpp +93 -298
- package/Shared/Modules/BlobModule.h +25 -91
- package/Shared/Modules/CxxModuleUtilities.cpp +32 -0
- package/Shared/Modules/CxxModuleUtilities.h +17 -0
- package/Shared/Modules/FileReaderModule.cpp +118 -51
- package/Shared/Modules/FileReaderModule.h +27 -1
- package/Shared/Modules/HttpModule.cpp +133 -9
- package/Shared/Modules/HttpModule.h +33 -0
- package/Shared/Modules/IRequestBodyHandler.h +6 -4
- package/Shared/Modules/IResponseHandler.h +3 -3
- package/Shared/Modules/IUriHandler.h +3 -3
- package/Shared/Modules/IWebSocketModuleContentHandler.h +6 -4
- package/Shared/Modules/WebSocketModule.cpp +190 -7
- package/Shared/Modules/WebSocketTurboModule.h +52 -0
- package/Shared/Networking/DefaultBlobResource.cpp +323 -0
- package/Shared/Networking/DefaultBlobResource.h +133 -0
- package/Shared/Networking/IBlobResource.h +56 -0
- package/Shared/Networking/IHttpResource.h +6 -5
- package/Shared/Networking/WinRTHttpResource.cpp +40 -32
- package/Shared/Networking/WinRTHttpResource.h +4 -3
- package/Shared/Networking/WinRTTypes.h +3 -3
- package/Shared/OInstance.cpp +17 -33
- package/Shared/SafeLoadLibrary.cpp +41 -0
- package/Shared/SafeLoadLibrary.h +15 -0
- package/Shared/Shared.vcxitems +27 -9
- package/Shared/Shared.vcxitems.filters +47 -33
- package/package.json +2 -2
- package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +0 -59
- package/Microsoft.ReactNative/Base/CoreNativeModules.h +0 -30
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +0 -2103
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +0 -73
- package/Shared/HermesShim.cpp +0 -118
- package/Shared/HermesShim.h +0 -21
- package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +0 -209
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +0 -44
- package/Shared/V8JSIRuntimeHolder.cpp +0 -70
- package/Shared/V8JSIRuntimeHolder.h +0 -53
- /package/Shared/{Modules/IBlobPersistor.h → IBlobPersistor.h} +0 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "V8RuntimeHolder.h"
|
|
5
|
+
#include <ApiLoaders/V8Api.h>
|
|
6
|
+
#include <NodeApiJsiRuntime.h>
|
|
7
|
+
#include <crash/verifyElseCrash.h>
|
|
8
|
+
#include "SafeLoadLibrary.h"
|
|
9
|
+
|
|
10
|
+
using namespace Microsoft::NodeApiJsi;
|
|
11
|
+
|
|
12
|
+
#define CRASH_ON_ERROR(result) VerifyElseCrash(result == napi_ok);
|
|
13
|
+
|
|
14
|
+
namespace Microsoft::ReactNative {
|
|
15
|
+
namespace {
|
|
16
|
+
|
|
17
|
+
class V8FuncResolver : public IFuncResolver {
|
|
18
|
+
public:
|
|
19
|
+
V8FuncResolver() : libHandle_(SafeLoadLibrary(L"v8jsi.dll")) {}
|
|
20
|
+
|
|
21
|
+
FuncPtr getFuncPtr(const char *funcName) override {
|
|
22
|
+
return reinterpret_cast<FuncPtr>(GetProcAddress(libHandle_, funcName));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
HMODULE libHandle_;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
V8Api &initV8Api() noexcept {
|
|
30
|
+
static V8FuncResolver funcResolver;
|
|
31
|
+
static V8Api s_v8Api(&funcResolver);
|
|
32
|
+
V8Api::setCurrent(&s_v8Api);
|
|
33
|
+
return s_v8Api;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
V8Api &getV8Api() noexcept {
|
|
37
|
+
static V8Api &s_v8Api = initV8Api();
|
|
38
|
+
return s_v8Api;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class V8Task {
|
|
42
|
+
public:
|
|
43
|
+
V8Task(void *taskData, jsr_task_run_cb taskRunCallback, jsr_data_delete_cb taskDataDeleteCallback, void *deleterData)
|
|
44
|
+
: taskData_(taskData),
|
|
45
|
+
taskRunCallback_(taskRunCallback),
|
|
46
|
+
taskDataDeleteCallback_(taskDataDeleteCallback),
|
|
47
|
+
deleterData_(deleterData) {}
|
|
48
|
+
|
|
49
|
+
V8Task(const V8Task &other) = delete;
|
|
50
|
+
V8Task &operator=(const V8Task &other) = delete;
|
|
51
|
+
|
|
52
|
+
~V8Task() {
|
|
53
|
+
if (taskDataDeleteCallback_ != nullptr) {
|
|
54
|
+
taskDataDeleteCallback_(taskData_, deleterData_);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void Run() const {
|
|
59
|
+
if (taskRunCallback_ != nullptr) {
|
|
60
|
+
taskRunCallback_(taskData_);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
void *taskData_;
|
|
66
|
+
jsr_task_run_cb taskRunCallback_;
|
|
67
|
+
jsr_data_delete_cb taskDataDeleteCallback_;
|
|
68
|
+
void *deleterData_;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
class V8TaskRunner {
|
|
72
|
+
public:
|
|
73
|
+
static void Create(jsr_config config, std::shared_ptr<facebook::react::MessageQueueThread> queue) {
|
|
74
|
+
CRASH_ON_ERROR(
|
|
75
|
+
getV8Api().jsr_config_set_task_runner(config, new V8TaskRunner(std::move(queue)), &PostTask, &Delete, nullptr));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private:
|
|
79
|
+
V8TaskRunner(std::shared_ptr<facebook::react::MessageQueueThread> queue) : queue_(std::move(queue)) {}
|
|
80
|
+
|
|
81
|
+
static void NAPI_CDECL PostTask(
|
|
82
|
+
void *taskRunnerData,
|
|
83
|
+
void *taskData,
|
|
84
|
+
jsr_task_run_cb taskRunCallback,
|
|
85
|
+
jsr_data_delete_cb taskDataDeleteCallback,
|
|
86
|
+
void *deleterData) {
|
|
87
|
+
auto task = std::make_shared<V8Task>(taskData, taskRunCallback, taskDataDeleteCallback, deleterData);
|
|
88
|
+
reinterpret_cast<V8TaskRunner *>(taskRunnerData)->queue_->runOnQueue([task = std::move(task)] { task->Run(); });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static void NAPI_CDECL Delete(void *taskRunner, void * /*deleterData*/) {
|
|
92
|
+
delete reinterpret_cast<V8TaskRunner *>(taskRunner);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
std::shared_ptr<facebook::react::MessageQueueThread> queue_;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
struct V8JsiBuffer : facebook::jsi::Buffer {
|
|
100
|
+
static std::shared_ptr<const facebook::jsi::Buffer>
|
|
101
|
+
Create(const uint8_t *buffer, size_t bufferSize, jsr_data_delete_cb bufferDeleteCallback, void *deleterData) {
|
|
102
|
+
return std::shared_ptr<const facebook::jsi::Buffer>(
|
|
103
|
+
new V8JsiBuffer(buffer, bufferSize, bufferDeleteCallback, deleterData));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
V8JsiBuffer(
|
|
107
|
+
const uint8_t *buffer,
|
|
108
|
+
size_t bufferSize,
|
|
109
|
+
jsr_data_delete_cb bufferDeleteCallback,
|
|
110
|
+
void *deleterData) noexcept
|
|
111
|
+
: buffer_(buffer),
|
|
112
|
+
bufferSize_(bufferSize),
|
|
113
|
+
bufferDeleteCallback_(bufferDeleteCallback),
|
|
114
|
+
deleterData_(deleterData) {}
|
|
115
|
+
|
|
116
|
+
~V8JsiBuffer() override {
|
|
117
|
+
if (bufferDeleteCallback_) {
|
|
118
|
+
bufferDeleteCallback_(const_cast<uint8_t *>(buffer_), deleterData_);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const uint8_t *data() const override {
|
|
123
|
+
return buffer_;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
size_t size() const override {
|
|
127
|
+
return bufferSize_;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private:
|
|
131
|
+
const uint8_t *buffer_;
|
|
132
|
+
size_t bufferSize_;
|
|
133
|
+
jsr_data_delete_cb bufferDeleteCallback_;
|
|
134
|
+
void *deleterData_;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
class V8ScriptCache {
|
|
138
|
+
public:
|
|
139
|
+
static void Create(jsr_config config, std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore) {
|
|
140
|
+
CRASH_ON_ERROR(getV8Api().jsr_config_set_script_cache(
|
|
141
|
+
config, new V8ScriptCache(std::move(scriptStore)), &LoadScript, &StoreScript, &Delete, nullptr));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private:
|
|
145
|
+
V8ScriptCache(std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore)
|
|
146
|
+
: scriptStore_(std::move(scriptStore)) {}
|
|
147
|
+
|
|
148
|
+
static void NAPI_CDECL LoadScript(
|
|
149
|
+
void *scriptCache,
|
|
150
|
+
const char *sourceUrl,
|
|
151
|
+
uint64_t sourceHash,
|
|
152
|
+
const char *runtimeName,
|
|
153
|
+
uint64_t runtimeVersion,
|
|
154
|
+
const char *cacheTag,
|
|
155
|
+
const uint8_t **buffer,
|
|
156
|
+
size_t *bufferSize,
|
|
157
|
+
jsr_data_delete_cb *bufferDeleteCallback,
|
|
158
|
+
void **deleterData) {
|
|
159
|
+
auto &scriptStore = reinterpret_cast<V8ScriptCache *>(scriptCache)->scriptStore_;
|
|
160
|
+
std::shared_ptr<const facebook::jsi::Buffer> preparedScript = scriptStore->tryGetPreparedScript(
|
|
161
|
+
facebook::jsi::ScriptSignature{sourceUrl, sourceHash},
|
|
162
|
+
facebook::jsi::JSRuntimeSignature{runtimeName, runtimeVersion},
|
|
163
|
+
cacheTag);
|
|
164
|
+
if (preparedScript) {
|
|
165
|
+
*buffer = preparedScript->data();
|
|
166
|
+
*bufferSize = preparedScript->size();
|
|
167
|
+
*bufferDeleteCallback = [](void * /*data*/, void *deleterData) noexcept {
|
|
168
|
+
delete reinterpret_cast<std::shared_ptr<const facebook::jsi::Buffer> *>(deleterData);
|
|
169
|
+
};
|
|
170
|
+
*deleterData = new std::shared_ptr<const facebook::jsi::Buffer>(std::move(preparedScript));
|
|
171
|
+
} else {
|
|
172
|
+
*buffer = nullptr;
|
|
173
|
+
*bufferSize = 0;
|
|
174
|
+
*bufferDeleteCallback = nullptr;
|
|
175
|
+
*deleterData = nullptr;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static void NAPI_CDECL StoreScript(
|
|
180
|
+
void *scriptCache,
|
|
181
|
+
const char *sourceUrl,
|
|
182
|
+
uint64_t sourceHash,
|
|
183
|
+
const char *runtimeName,
|
|
184
|
+
uint64_t runtimeVersion,
|
|
185
|
+
const char *cacheTag,
|
|
186
|
+
const uint8_t *buffer,
|
|
187
|
+
size_t bufferSize,
|
|
188
|
+
jsr_data_delete_cb bufferDeleteCallback,
|
|
189
|
+
void *deleterData) {
|
|
190
|
+
auto &scriptStore = reinterpret_cast<V8ScriptCache *>(scriptCache)->scriptStore_;
|
|
191
|
+
scriptStore->persistPreparedScript(
|
|
192
|
+
V8JsiBuffer::Create(buffer, bufferSize, bufferDeleteCallback, deleterData),
|
|
193
|
+
facebook::jsi::ScriptSignature{sourceUrl, sourceHash},
|
|
194
|
+
facebook::jsi::JSRuntimeSignature{runtimeName, runtimeVersion},
|
|
195
|
+
cacheTag);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static void NAPI_CDECL Delete(void *scriptCache, void * /*deleterData*/) {
|
|
199
|
+
delete reinterpret_cast<V8ScriptCache *>(scriptCache);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private:
|
|
203
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore_;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
} // namespace
|
|
207
|
+
|
|
208
|
+
V8RuntimeHolder::V8RuntimeHolder(
|
|
209
|
+
std::shared_ptr<facebook::react::DevSettings> devSettings,
|
|
210
|
+
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
|
|
211
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore,
|
|
212
|
+
bool enableMultiThreadingSupport) noexcept
|
|
213
|
+
: m_weakDevSettings(devSettings),
|
|
214
|
+
m_jsQueue(std::move(jsQueue)),
|
|
215
|
+
m_preparedScriptStore(std::move(preparedScriptStore)),
|
|
216
|
+
m_enableMultiThreadingSupport(enableMultiThreadingSupport) {}
|
|
217
|
+
|
|
218
|
+
void V8RuntimeHolder::initRuntime() noexcept {
|
|
219
|
+
std::shared_ptr<facebook::react::DevSettings> devSettings = m_weakDevSettings.lock();
|
|
220
|
+
VerifyElseCrash(devSettings);
|
|
221
|
+
|
|
222
|
+
V8Api &api = getV8Api();
|
|
223
|
+
V8Api::setCurrent(&api);
|
|
224
|
+
jsr_config config{};
|
|
225
|
+
CRASH_ON_ERROR(api.jsr_create_config(&config));
|
|
226
|
+
CRASH_ON_ERROR(api.jsr_config_enable_inspector(config, devSettings->useDirectDebugger));
|
|
227
|
+
CRASH_ON_ERROR(api.jsr_config_set_inspector_runtime_name(config, devSettings->debuggerRuntimeName.c_str()));
|
|
228
|
+
CRASH_ON_ERROR(api.jsr_config_set_inspector_port(config, devSettings->debuggerPort));
|
|
229
|
+
CRASH_ON_ERROR(api.jsr_config_set_inspector_break_on_start(config, devSettings->debuggerBreakOnNextLine));
|
|
230
|
+
CRASH_ON_ERROR(api.v8_config_enable_multithreading(config, m_enableMultiThreadingSupport));
|
|
231
|
+
|
|
232
|
+
if (m_jsQueue) {
|
|
233
|
+
V8TaskRunner::Create(config, m_jsQueue);
|
|
234
|
+
}
|
|
235
|
+
if (m_preparedScriptStore) {
|
|
236
|
+
V8ScriptCache::Create(config, m_preparedScriptStore);
|
|
237
|
+
}
|
|
238
|
+
jsr_runtime runtime{};
|
|
239
|
+
CRASH_ON_ERROR(api.jsr_create_runtime(config, &runtime));
|
|
240
|
+
CRASH_ON_ERROR(api.jsr_delete_config(config));
|
|
241
|
+
|
|
242
|
+
napi_env env{};
|
|
243
|
+
CRASH_ON_ERROR(api.jsr_runtime_get_node_api_env(runtime, &env));
|
|
244
|
+
|
|
245
|
+
m_jsiRuntime =
|
|
246
|
+
makeNodeApiJsiRuntime(env, &api, [runtime]() { CRASH_ON_ERROR(V8Api::current()->jsr_delete_runtime(runtime)); });
|
|
247
|
+
m_ownThreadId = std::this_thread::get_id();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
facebook::react::JSIEngineOverride V8RuntimeHolder::getRuntimeType() noexcept {
|
|
251
|
+
return facebook::react::JSIEngineOverride::V8NodeApi;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
std::shared_ptr<facebook::jsi::Runtime> V8RuntimeHolder::getRuntime() noexcept {
|
|
255
|
+
std::call_once(m_onceFlag, [this]() { initRuntime(); });
|
|
256
|
+
VerifyElseCrash(m_jsiRuntime);
|
|
257
|
+
return m_jsiRuntime;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "RuntimeHolder.h"
|
|
7
|
+
#include "ScriptStore.h"
|
|
8
|
+
|
|
9
|
+
#include <cxxreact/MessageQueueThread.h>
|
|
10
|
+
|
|
11
|
+
namespace Microsoft::ReactNative {
|
|
12
|
+
|
|
13
|
+
class V8RuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
|
|
14
|
+
public: // RuntimeHolderLazyInit implementation.
|
|
15
|
+
std::shared_ptr<facebook::jsi::Runtime> getRuntime() noexcept override;
|
|
16
|
+
facebook::react::JSIEngineOverride getRuntimeType() noexcept override;
|
|
17
|
+
|
|
18
|
+
V8RuntimeHolder(
|
|
19
|
+
std::shared_ptr<facebook::react::DevSettings> devSettings,
|
|
20
|
+
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
|
|
21
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore,
|
|
22
|
+
bool enableMultiThreadingSupport) noexcept;
|
|
23
|
+
|
|
24
|
+
private:
|
|
25
|
+
void initRuntime() noexcept;
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
std::shared_ptr<facebook::jsi::Runtime> m_jsiRuntime;
|
|
29
|
+
std::once_flag m_onceFlag{};
|
|
30
|
+
std::thread::id m_ownThreadId{};
|
|
31
|
+
std::weak_ptr<facebook::react::DevSettings> m_weakDevSettings;
|
|
32
|
+
std::shared_ptr<facebook::react::MessageQueueThread> m_jsQueue;
|
|
33
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> m_preparedScriptStore;
|
|
34
|
+
bool m_enableMultiThreadingSupport;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace Microsoft::ReactNative
|