react-native-windows 0.71.38 → 0.71.40
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/Microsoft.ReactNative/ReactHost/React.h +3 -0
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +16 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +14 -2
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/OInstance.cpp +19 -1
- package/Shared/Shared.vcxitems +4 -0
- package/Shared/Shared.vcxitems.filters +2 -0
- package/Shared/V8JSIRuntimeHolder.cpp +71 -0
- package/Shared/V8JSIRuntimeHolder.h +56 -0
- package/package.json +1 -1
|
@@ -275,6 +275,9 @@ struct ReactOptions {
|
|
|
275
275
|
winrt::Microsoft::ReactNative::IReactPropertyBag const &properties,
|
|
276
276
|
JSIEngine value) noexcept;
|
|
277
277
|
|
|
278
|
+
bool JsiEngineV8NodeApi() const noexcept;
|
|
279
|
+
static bool JsiEngineV8NodeApi(winrt::Microsoft::ReactNative::IReactPropertyBag const &properties) noexcept;
|
|
280
|
+
|
|
278
281
|
//! Enable live reload to load the source bundle from the React Native packager.
|
|
279
282
|
//! When the file is saved, the packager will trigger reloading.
|
|
280
283
|
void SetUseLiveReload(bool enable) noexcept;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#include "ReactHost.h"
|
|
5
5
|
#include <Future/FutureWait.h>
|
|
6
|
+
#include <ReactPropertyBag.h>
|
|
6
7
|
#include <winrt/Windows.Foundation.h>
|
|
7
8
|
|
|
8
9
|
namespace Mso::React {
|
|
@@ -35,6 +36,12 @@ winrt::Microsoft::ReactNative::IReactPropertyName JSIEngineProperty() noexcept {
|
|
|
35
36
|
return propName;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
winrt::Microsoft::ReactNative::ReactPropertyId<bool> JSIEngineV8NodeApiProperty() noexcept {
|
|
40
|
+
static winrt::Microsoft::ReactNative::ReactPropertyId<bool> propId{
|
|
41
|
+
L"ReactNative.ReactOptions", L"JSIEngineV8NodeApi"};
|
|
42
|
+
return propId;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
winrt::Microsoft::ReactNative::IReactPropertyName LiveReloadEnabledProperty() noexcept {
|
|
39
46
|
static winrt::Microsoft::ReactNative::IReactPropertyName propName =
|
|
40
47
|
winrt::Microsoft::ReactNative::ReactPropertyBagHelper::GetName(
|
|
@@ -137,6 +144,15 @@ void ReactOptions::SetJsiEngine(JSIEngine value) noexcept {
|
|
|
137
144
|
properties.Set(JSIEngineProperty(), winrt::box_value(static_cast<uint32_t>(value)));
|
|
138
145
|
}
|
|
139
146
|
|
|
147
|
+
/*static*/ bool ReactOptions::JsiEngineV8NodeApi(
|
|
148
|
+
winrt::Microsoft::ReactNative::IReactPropertyBag const &properties) noexcept {
|
|
149
|
+
return winrt::Microsoft::ReactNative::ReactPropertyBag(properties).Get(JSIEngineV8NodeApiProperty()).value_or(false);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
bool ReactOptions::JsiEngineV8NodeApi() const noexcept {
|
|
153
|
+
return JsiEngineV8NodeApi(Properties);
|
|
154
|
+
}
|
|
155
|
+
|
|
140
156
|
/*static*/ void ReactOptions::SetUseFastRefresh(
|
|
141
157
|
winrt::Microsoft::ReactNative::IReactPropertyBag const &properties,
|
|
142
158
|
bool value) noexcept {
|
|
@@ -68,7 +68,9 @@
|
|
|
68
68
|
|
|
69
69
|
#if defined(USE_V8)
|
|
70
70
|
#include <winrt/Windows.Storage.h>
|
|
71
|
+
#include "BaseScriptStoreImpl.h"
|
|
71
72
|
#include "JSI/V8RuntimeHolder.h"
|
|
73
|
+
#include "V8JSIRuntimeHolder.h"
|
|
72
74
|
#endif // USE_V8
|
|
73
75
|
|
|
74
76
|
#include "RedBox.h"
|
|
@@ -509,8 +511,18 @@ void ReactInstanceWin::Initialize() noexcept {
|
|
|
509
511
|
enableMultiThreadSupport = Microsoft::ReactNative::IsFabricEnabled(m_reactContext->Properties());
|
|
510
512
|
#endif // USE_FABRIC
|
|
511
513
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
+
if (m_options.JsiEngineV8NodeApi()) {
|
|
515
|
+
devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::ReactNative::V8RuntimeHolder>(
|
|
516
|
+
devSettings, m_jsMessageThread.Load(), std::move(preparedScriptStore), enableMultiThreadSupport);
|
|
517
|
+
} else {
|
|
518
|
+
devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
|
|
519
|
+
devSettings,
|
|
520
|
+
m_jsMessageThread.Load(),
|
|
521
|
+
std::move(scriptStore),
|
|
522
|
+
std::move(preparedScriptStore),
|
|
523
|
+
enableMultiThreadSupport);
|
|
524
|
+
}
|
|
525
|
+
|
|
514
526
|
break;
|
|
515
527
|
}
|
|
516
528
|
#endif // USE_V8
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.71.
|
|
13
|
+
<ReactNativeWindowsVersion>0.71.40</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>71</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>40</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>75b42021dbf4734610a01134b86399210b2b62ed</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
package/Shared/OInstance.cpp
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
#if defined(USE_V8)
|
|
54
54
|
#include <JSI/V8RuntimeHolder.h>
|
|
55
|
+
#include "V8JSIRuntimeHolder.h"
|
|
55
56
|
#endif
|
|
56
57
|
#include <ReactCommon/CallInvoker.h>
|
|
57
58
|
#include <ReactCommon/TurboModuleBinding.h>
|
|
@@ -319,7 +320,24 @@ InstanceImpl::InstanceImpl(
|
|
|
319
320
|
m_devSettings, m_jsThread, std::move(preparedScriptStore));
|
|
320
321
|
break;
|
|
321
322
|
}
|
|
322
|
-
case JSIEngineOverride::V8:
|
|
323
|
+
case JSIEngineOverride::V8: {
|
|
324
|
+
#if defined(USE_V8)
|
|
325
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
|
|
326
|
+
|
|
327
|
+
wchar_t tempPath[MAX_PATH];
|
|
328
|
+
if (GetTempPathW(MAX_PATH, tempPath)) {
|
|
329
|
+
preparedScriptStore =
|
|
330
|
+
std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
m_devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
|
|
334
|
+
m_devSettings, m_jsThread, nullptr, std::move(preparedScriptStore), /*multithreading*/ false);
|
|
335
|
+
break;
|
|
336
|
+
#else
|
|
337
|
+
assert(false); // V8 is not available in this build, fallthrough
|
|
338
|
+
[[fallthrough]];
|
|
339
|
+
#endif
|
|
340
|
+
}
|
|
323
341
|
case JSIEngineOverride::V8NodeApi: {
|
|
324
342
|
#if defined(USE_V8)
|
|
325
343
|
std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -74,6 +74,9 @@
|
|
|
74
74
|
<ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleManager.cpp" />
|
|
75
75
|
<ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp" />
|
|
76
76
|
<ClCompile Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.cpp" />
|
|
77
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
|
|
78
|
+
<ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
|
|
79
|
+
</ClCompile>
|
|
77
80
|
</ItemGroup>
|
|
78
81
|
<ItemGroup>
|
|
79
82
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\include\Shared\cdebug.h" />
|
|
@@ -165,6 +168,7 @@
|
|
|
165
168
|
<ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
|
|
166
169
|
<ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
|
|
167
170
|
<ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
|
|
171
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
|
|
168
172
|
<ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
|
|
169
173
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />
|
|
170
174
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
|
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
<ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp" />
|
|
158
158
|
<ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp" />
|
|
159
159
|
<ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
|
|
160
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp" />
|
|
160
161
|
</ItemGroup>
|
|
161
162
|
<ItemGroup>
|
|
162
163
|
<Filter Include="Source Files">
|
|
@@ -485,6 +486,7 @@
|
|
|
485
486
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
|
|
486
487
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
|
|
487
488
|
<ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
|
|
489
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
|
|
488
490
|
</ItemGroup>
|
|
489
491
|
<ItemGroup>
|
|
490
492
|
<None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "pch.h"
|
|
5
|
+
|
|
6
|
+
#include <V8JsiRuntime.h>
|
|
7
|
+
#include "V8JSIRuntimeHolder.h"
|
|
8
|
+
|
|
9
|
+
#include <atomic>
|
|
10
|
+
#include <queue>
|
|
11
|
+
|
|
12
|
+
using namespace facebook;
|
|
13
|
+
using namespace facebook::react;
|
|
14
|
+
|
|
15
|
+
namespace facebook {
|
|
16
|
+
namespace react {
|
|
17
|
+
|
|
18
|
+
class TaskRunnerAdapter : public v8runtime::JSITaskRunner {
|
|
19
|
+
public:
|
|
20
|
+
TaskRunnerAdapter(std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) : jsQueue_(std::move(jsQueue)) {}
|
|
21
|
+
|
|
22
|
+
void postTask(std::unique_ptr<v8runtime::JSITask> task) override {
|
|
23
|
+
std::shared_ptr<v8runtime::JSITask> shared_task(task.release());
|
|
24
|
+
jsQueue_->runOnQueue([shared_task2 = std::move(shared_task)]() { shared_task2->run(); });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
TaskRunnerAdapter(const TaskRunnerAdapter &) = delete;
|
|
29
|
+
TaskRunnerAdapter &operator=(const TaskRunnerAdapter &) = delete;
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue_;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
facebook::react::JSIEngineOverride V8JSIRuntimeHolder::getRuntimeType() noexcept {
|
|
35
|
+
return facebook::react::JSIEngineOverride::V8;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
std::shared_ptr<facebook::jsi::Runtime> V8JSIRuntimeHolder::getRuntime() noexcept {
|
|
39
|
+
std::call_once(once_flag_, [this]() { initRuntime(); });
|
|
40
|
+
|
|
41
|
+
if (!runtime_)
|
|
42
|
+
std::terminate();
|
|
43
|
+
|
|
44
|
+
// V8JsiRuntime is not thread safe as of now.
|
|
45
|
+
if (own_thread_id_ != std::this_thread::get_id())
|
|
46
|
+
std::terminate();
|
|
47
|
+
|
|
48
|
+
return runtime_;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void V8JSIRuntimeHolder::initRuntime() noexcept {
|
|
52
|
+
v8runtime::V8RuntimeArgs args{};
|
|
53
|
+
|
|
54
|
+
if (debuggerPort_ > 0)
|
|
55
|
+
args.inspectorPort = debuggerPort_;
|
|
56
|
+
|
|
57
|
+
args.flags.enableInspector = useDirectDebugger_;
|
|
58
|
+
args.flags.waitForDebugger = debuggerBreakOnNextLine_;
|
|
59
|
+
args.debuggerRuntimeName = debuggerRuntimeName_;
|
|
60
|
+
|
|
61
|
+
args.foreground_task_runner = std::make_shared<TaskRunnerAdapter>(jsQueue_);
|
|
62
|
+
args.preparedScriptStore = std::move(preparedScriptStore_);
|
|
63
|
+
args.flags.enableMultiThread = enableMultiThreadingSupport_;
|
|
64
|
+
|
|
65
|
+
runtime_ = v8runtime::makeV8Runtime(std::move(args));
|
|
66
|
+
|
|
67
|
+
own_thread_id_ = std::this_thread::get_id();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
} // namespace react
|
|
71
|
+
} // namespace facebook
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include <DevSettings.h>
|
|
7
|
+
|
|
8
|
+
#include <JSI/RuntimeHolder.h>
|
|
9
|
+
#include <JSI/ScriptStore.h>
|
|
10
|
+
|
|
11
|
+
#include <Logging.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook {
|
|
14
|
+
namespace react {
|
|
15
|
+
|
|
16
|
+
class V8JSIRuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
|
|
17
|
+
public:
|
|
18
|
+
std::shared_ptr<facebook::jsi::Runtime> getRuntime() noexcept override;
|
|
19
|
+
facebook::react::JSIEngineOverride getRuntimeType() noexcept override;
|
|
20
|
+
|
|
21
|
+
V8JSIRuntimeHolder(
|
|
22
|
+
std::shared_ptr<facebook::react::DevSettings> devSettings,
|
|
23
|
+
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
|
|
24
|
+
std::unique_ptr<facebook::jsi::ScriptStore> &&scriptStore,
|
|
25
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> &&preparedScriptStore,
|
|
26
|
+
bool enableMultiThreadingSupport) noexcept
|
|
27
|
+
: useDirectDebugger_(devSettings->useDirectDebugger),
|
|
28
|
+
debuggerBreakOnNextLine_(devSettings->debuggerBreakOnNextLine),
|
|
29
|
+
debuggerPort_(devSettings->debuggerPort),
|
|
30
|
+
debuggerRuntimeName_(devSettings->debuggerRuntimeName),
|
|
31
|
+
jsQueue_(std::move(jsQueue)),
|
|
32
|
+
scriptStore_(std::move(scriptStore)),
|
|
33
|
+
preparedScriptStore_(std::move(preparedScriptStore)),
|
|
34
|
+
enableMultiThreadingSupport_(enableMultiThreadingSupport) {}
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
void initRuntime() noexcept;
|
|
38
|
+
|
|
39
|
+
std::shared_ptr<facebook::jsi::Runtime> runtime_;
|
|
40
|
+
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue_;
|
|
41
|
+
|
|
42
|
+
std::unique_ptr<facebook::jsi::ScriptStore> scriptStore_;
|
|
43
|
+
std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore_;
|
|
44
|
+
|
|
45
|
+
std::once_flag once_flag_;
|
|
46
|
+
std::thread::id own_thread_id_;
|
|
47
|
+
|
|
48
|
+
uint16_t debuggerPort_;
|
|
49
|
+
bool useDirectDebugger_;
|
|
50
|
+
bool debuggerBreakOnNextLine_;
|
|
51
|
+
std::string debuggerRuntimeName_;
|
|
52
|
+
bool enableMultiThreadingSupport_;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace react
|
|
56
|
+
} // namespace facebook
|