react-native-windows 0.71.18 → 0.71.19

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 (49) hide show
  1. package/Directory.Build.props +0 -5
  2. package/Microsoft.ReactNative/IReactDispatcher.cpp +0 -4
  3. package/Microsoft.ReactNative/IReactDispatcher.h +0 -1
  4. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +4 -2
  5. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +11 -31
  6. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +2 -0
  7. package/Microsoft.ReactNative/Views/DevMenu.cpp +3 -3
  8. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +1 -1
  9. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +2103 -0
  10. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +73 -0
  11. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +12 -43
  12. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +6 -17
  13. package/Microsoft.ReactNative.Managed/packages.lock.json +8 -8
  14. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  15. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  16. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +1 -1
  17. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  18. package/PropertySheets/JSEngine.props +4 -4
  19. package/PropertySheets/React.Cpp.props +0 -1
  20. package/PropertySheets/Warnings.props +0 -6
  21. package/ReactCommon/ReactCommon.vcxproj +1 -53
  22. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +0 -36
  23. package/Shared/DevSupportManager.cpp +9 -2
  24. package/Shared/DevSupportManager.h +6 -2
  25. package/Shared/HermesRuntimeHolder.cpp +84 -344
  26. package/Shared/HermesRuntimeHolder.h +21 -32
  27. package/Shared/HermesSamplingProfiler.cpp +14 -66
  28. package/Shared/HermesSamplingProfiler.h +3 -5
  29. package/Shared/HermesShim.cpp +118 -0
  30. package/Shared/HermesShim.h +21 -0
  31. package/Shared/InspectorPackagerConnection.cpp +108 -62
  32. package/Shared/InspectorPackagerConnection.h +21 -9
  33. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +209 -0
  34. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +44 -0
  35. package/Shared/JSI/RuntimeHolder.h +2 -2
  36. package/Shared/JSI/ScriptStore.h +20 -18
  37. package/Shared/OInstance.cpp +33 -17
  38. package/Shared/Shared.vcxitems +8 -19
  39. package/Shared/Shared.vcxitems.filters +30 -23
  40. package/Shared/V8JSIRuntimeHolder.cpp +70 -0
  41. package/Shared/V8JSIRuntimeHolder.h +53 -0
  42. package/package.json +2 -2
  43. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
  44. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +0 -16
  45. package/ReactCommon/cgmanifest.json +0 -15
  46. package/Shared/JSI/V8RuntimeHolder.cpp +0 -262
  47. package/Shared/JSI/V8RuntimeHolder.h +0 -37
  48. package/Shared/SafeLoadLibrary.cpp +0 -41
  49. package/Shared/SafeLoadLibrary.h +0 -15
@@ -0,0 +1,209 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "NapiJsiV8RuntimeHolder.h"
5
+
6
+ using namespace facebook::jsi;
7
+ using namespace facebook::react;
8
+
9
+ using std::shared_ptr;
10
+ using std::unique_ptr;
11
+
12
+ namespace Microsoft::JSI {
13
+
14
+ class NapiTask {
15
+ public:
16
+ NapiTask(void *task, v8_task_run_cb onTaskRun, v8_task_release_cb onTaskRelease)
17
+ : task_(task), onTaskRun_(onTaskRun), onTaskRelease_(onTaskRelease) {}
18
+
19
+ NapiTask(NapiTask &&other)
20
+ : task_(std::exchange(other.task_, nullptr)),
21
+ onTaskRun_(std::exchange(other.onTaskRun_, nullptr)),
22
+ onTaskRelease_(std::exchange(other.onTaskRelease_, nullptr)) {}
23
+
24
+ NapiTask &operator=(NapiTask &&other) {
25
+ if (this != &other) {
26
+ NapiTask taskToDelete(std::move(*this));
27
+ task_ = std::exchange(other.task_, nullptr);
28
+ onTaskRun_ = std::exchange(other.onTaskRun_, nullptr);
29
+ onTaskRelease_ = std::exchange(other.onTaskRelease_, nullptr);
30
+ }
31
+ return *this;
32
+ }
33
+
34
+ NapiTask(const NapiTask &other) = delete;
35
+ NapiTask &operator=(const NapiTask &other) = delete;
36
+
37
+ ~NapiTask() {
38
+ if (task_ != nullptr) {
39
+ onTaskRelease_(task_);
40
+ }
41
+ }
42
+
43
+ void Run() const {
44
+ if (task_ != nullptr) {
45
+ onTaskRun_(task_);
46
+ }
47
+ }
48
+
49
+ private:
50
+ void *task_;
51
+ v8_task_run_cb onTaskRun_;
52
+ v8_task_release_cb onTaskRelease_;
53
+ };
54
+
55
+ class NapiTaskRunner {
56
+ public:
57
+ NapiTaskRunner(std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) : m_jsQueue(std::move(jsQueue)) {}
58
+
59
+ static v8_task_runner_t Create(std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) {
60
+ NapiTaskRunner *taskRunner = new NapiTaskRunner(std::move(jsQueue));
61
+ return v8_create_task_runner(reinterpret_cast<void *>(taskRunner), &PostTask, &Release);
62
+ }
63
+
64
+ private:
65
+ static void __cdecl PostTask(
66
+ void *taskRunner,
67
+ void *task,
68
+ v8_task_run_cb onTaskRun,
69
+ v8_task_release_cb onTaskRelease) {
70
+ auto napiTask = std::make_shared<NapiTask>(task, onTaskRun, onTaskRelease);
71
+ reinterpret_cast<NapiTaskRunner *>(taskRunner)->m_jsQueue->runOnQueue([napiTask = std::move(napiTask)] {
72
+ napiTask->Run();
73
+ });
74
+ }
75
+
76
+ static void __cdecl Release(void *taskRunner) {
77
+ delete reinterpret_cast<NapiTaskRunner *>(taskRunner);
78
+ }
79
+
80
+ private:
81
+ std::shared_ptr<facebook::react::MessageQueueThread> m_jsQueue;
82
+ };
83
+
84
+ NapiJsiV8RuntimeHolder::NapiJsiV8RuntimeHolder(
85
+ shared_ptr<DevSettings> devSettings,
86
+ shared_ptr<MessageQueueThread> jsQueue,
87
+ unique_ptr<ScriptStore> &&scriptStore,
88
+ unique_ptr<PreparedScriptStore> &&preparedScriptStore) noexcept
89
+ : m_useDirectDebugger{devSettings->useDirectDebugger},
90
+ m_debuggerBreakOnNextLine{devSettings->debuggerBreakOnNextLine},
91
+ m_debuggerPort{devSettings->debuggerPort},
92
+ m_debuggerRuntimeName{devSettings->debuggerRuntimeName},
93
+ m_jsQueue{jsQueue},
94
+ m_scriptStore{std::move(scriptStore)},
95
+ m_preparedScriptStore{std::move(preparedScriptStore)} {}
96
+
97
+ void NapiJsiV8RuntimeHolder::InitRuntime() noexcept {
98
+ napi_ext_env_settings settings{};
99
+ settings.this_size = sizeof(settings);
100
+ if (m_debuggerPort > 0)
101
+ settings.inspector_port = m_debuggerPort;
102
+
103
+ settings.flags.enable_inspector = m_useDirectDebugger;
104
+ settings.flags.wait_for_debugger = m_debuggerBreakOnNextLine;
105
+ // TODO: args.debuggerRuntimeName = debuggerRuntimeName_;
106
+ settings.foreground_task_runner = NapiTaskRunner::Create(m_jsQueue);
107
+
108
+ napi_ext_script_cache scriptCache = InitScriptCache(std::move(m_preparedScriptStore));
109
+ settings.script_cache = &scriptCache;
110
+
111
+ napi_env env{};
112
+ napi_ext_create_env(&settings, &env);
113
+ // Associate environment to holder.
114
+ napi_set_instance_data(env, this, nullptr /*finalize_cb*/, nullptr /*finalize_hint*/);
115
+
116
+ m_runtime = MakeNodeApiJsiRuntime(env);
117
+ m_ownThreadId = std::this_thread::get_id();
118
+ }
119
+
120
+ struct NodeApiJsiBuffer : facebook::jsi::Buffer {
121
+ static std::shared_ptr<const facebook::jsi::Buffer> CreateJsiBuffer(const napi_ext_buffer *buffer) {
122
+ if (buffer && buffer->data) {
123
+ return std::shared_ptr<const facebook::jsi::Buffer>(new NodeApiJsiBuffer(buffer));
124
+ } else {
125
+ return {};
126
+ }
127
+ }
128
+
129
+ NodeApiJsiBuffer(const napi_ext_buffer *buffer) noexcept : buffer_(*buffer) {}
130
+
131
+ ~NodeApiJsiBuffer() override {
132
+ if (buffer_.buffer_object.finalize_cb) {
133
+ buffer_.buffer_object.finalize_cb(nullptr, buffer_.buffer_object.data, buffer_.buffer_object.finalize_hint);
134
+ }
135
+ }
136
+
137
+ const uint8_t *data() const override {
138
+ return buffer_.data;
139
+ }
140
+
141
+ size_t size() const override {
142
+ return buffer_.byte_size;
143
+ }
144
+
145
+ private:
146
+ napi_ext_buffer buffer_;
147
+ };
148
+
149
+ napi_ext_script_cache NapiJsiV8RuntimeHolder::InitScriptCache(
150
+ unique_ptr<PreparedScriptStore> &&preparedScriptStore) noexcept {
151
+ napi_ext_script_cache scriptCache{};
152
+ scriptCache.cache_object = NativeObjectWrapper<unique_ptr<PreparedScriptStore>>::Wrap(std::move(preparedScriptStore));
153
+ scriptCache.load_cached_script = [](napi_env env,
154
+ napi_ext_script_cache *script_cache,
155
+ napi_ext_cached_script_metadata *script_metadata,
156
+ napi_ext_buffer *result) -> napi_status {
157
+ PreparedScriptStore *scriptStore = reinterpret_cast<PreparedScriptStore *>(script_cache->cache_object.data);
158
+ std::shared_ptr<const facebook::jsi::Buffer> buffer = scriptStore->tryGetPreparedScript(
159
+ ScriptSignature{script_metadata->source_url, script_metadata->source_hash},
160
+ JSRuntimeSignature{script_metadata->runtime_name, script_metadata->runtime_version},
161
+ script_metadata->tag);
162
+ if (buffer) {
163
+ result->buffer_object = NativeObjectWrapper<std::shared_ptr<const facebook::jsi::Buffer>>::Wrap(
164
+ std::shared_ptr<const facebook::jsi::Buffer>{buffer});
165
+ result->data = buffer->data();
166
+ result->byte_size = buffer->size();
167
+ } else {
168
+ *result = napi_ext_buffer{};
169
+ }
170
+ return napi_ok;
171
+ };
172
+ scriptCache.store_cached_script = [](napi_env env,
173
+ napi_ext_script_cache *script_cache,
174
+ napi_ext_cached_script_metadata *script_metadata,
175
+ const napi_ext_buffer *buffer) -> napi_status {
176
+ PreparedScriptStore *scriptStore = reinterpret_cast<PreparedScriptStore *>(script_cache->cache_object.data);
177
+ scriptStore->persistPreparedScript(
178
+ NodeApiJsiBuffer::CreateJsiBuffer(buffer),
179
+ ScriptSignature{script_metadata->source_url, script_metadata->source_hash},
180
+ JSRuntimeSignature{script_metadata->runtime_name, script_metadata->runtime_version},
181
+ script_metadata->tag);
182
+ return napi_ok;
183
+ };
184
+ return scriptCache;
185
+ }
186
+
187
+ #pragma region Microsoft::JSI::RuntimeHolderLazyInit
188
+
189
+ facebook::react::JSIEngineOverride NapiJsiV8RuntimeHolder::getRuntimeType() noexcept {
190
+ return facebook::react::JSIEngineOverride::V8NodeApi;
191
+ }
192
+
193
+ shared_ptr<Runtime> NapiJsiV8RuntimeHolder::getRuntime() noexcept /*override*/
194
+ {
195
+ std::call_once(m_onceFlag, [this]() { InitRuntime(); });
196
+
197
+ if (!m_runtime)
198
+ std::terminate();
199
+
200
+ // V8 NapiJsiRuntime is not known to be thread safe.
201
+ if (m_ownThreadId != std::this_thread::get_id())
202
+ __fastfail(FAST_FAIL_INVALID_THREAD);
203
+
204
+ return m_runtime;
205
+ }
206
+
207
+ #pragma endregion Microsoft::JSI::RuntimeHolderLazyInit
208
+
209
+ } // namespace Microsoft::JSI
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <DevSettings.h>
7
+ #include <JSI/NodeApiJsiRuntime.h>
8
+ #include "RuntimeHolder.h"
9
+ #include "ScriptStore.h"
10
+
11
+ namespace Microsoft::JSI {
12
+
13
+ class NapiJsiV8RuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
14
+ public:
15
+ std::shared_ptr<facebook::jsi::Runtime> getRuntime() noexcept override;
16
+ facebook::react::JSIEngineOverride getRuntimeType() noexcept override;
17
+
18
+ NapiJsiV8RuntimeHolder(
19
+ std::shared_ptr<facebook::react::DevSettings> devSettings,
20
+ std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
21
+ std::unique_ptr<facebook::jsi::ScriptStore> &&scriptStore,
22
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> &&preparedScriptStore) noexcept;
23
+
24
+ private:
25
+ void InitRuntime() noexcept;
26
+ napi_ext_script_cache InitScriptCache(
27
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> &&preparedScriptStore) noexcept;
28
+
29
+ std::shared_ptr<facebook::jsi::Runtime> m_runtime;
30
+ std::shared_ptr<facebook::react::MessageQueueThread> m_jsQueue;
31
+
32
+ std::unique_ptr<facebook::jsi::ScriptStore> m_scriptStore;
33
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> m_preparedScriptStore;
34
+
35
+ std::once_flag m_onceFlag;
36
+ std::thread::id m_ownThreadId;
37
+
38
+ uint16_t m_debuggerPort;
39
+ bool m_useDirectDebugger{false};
40
+ bool m_debuggerBreakOnNextLine{false};
41
+ std::string m_debuggerRuntimeName;
42
+ };
43
+
44
+ } // namespace Microsoft::JSI
@@ -11,7 +11,7 @@ namespace Microsoft::JSI {
11
11
  // a. lazily create a JSI Runtime on the first call to getRuntime
12
12
  // b. subsequent calls to getRuntime should return the Runtime created in (a)
13
13
 
14
- // Note: all calls to getRuntime() should happen on the same thread unless you are sure that
14
+ // Note :: All calls to getRuntime() should happen on the same thread unless you are sure that
15
15
  // the underlying Runtime instance is thread safe.
16
16
 
17
17
  struct RuntimeHolderLazyInit {
@@ -21,7 +21,7 @@ struct RuntimeHolderLazyInit {
21
21
  virtual void teardown() noexcept {};
22
22
 
23
23
  // You can call this when a crash happens to attempt recording additional data
24
- // The fileDescriptor supplied is a raw file stream an implementation might write JSON to.
24
+ // The fd supplied is a raw file stream an implementation might write JSON to
25
25
  virtual void crashHandler(int fileDescriptor) noexcept {};
26
26
  };
27
27
 
@@ -5,11 +5,12 @@
5
5
  #include <jsi/jsi.h>
6
6
  #include <memory>
7
7
 
8
- namespace facebook::jsi {
8
+ namespace facebook {
9
+ namespace jsi {
9
10
 
10
- // Integer type as it's persist friendly.
11
- using ScriptVersion_t = uint64_t; // It should be std::optional<uint64_t> once we have c++17 available everywhere.
12
- // Until then, 0 implies versioning not available.
11
+ // Integer type as it's persist friently.
12
+ using ScriptVersion_t = uint64_t; // It shouldbe std::optional<uint64_t> once we have c++17 available everywhere. Until
13
+ // then, 0 implies versioning not available.
13
14
  using JSRuntimeVersion_t = uint64_t; // 0 implies version can't be computed. We assert whenever that happens.
14
15
 
15
16
  struct VersionedBuffer {
@@ -29,14 +30,14 @@ struct JSRuntimeSignature {
29
30
 
30
31
  // Most JSI::Runtime implementation offer some form of prepared JavaScript which offers better performance
31
32
  // characteristics when loading comparing to plain JavaScript. Embedders can provide an instance of this interface
32
- // (through JSI::Runtime implementation's factory method), to enable persistence of the prepared script
33
- // and retrieval on subsequent evaluation of a script.
33
+ // (through JSI::Runtime implementation's factory method), to enable persistance of the prepared script and retrieval on
34
+ // subsequent evaluation of a script.
34
35
  struct PreparedScriptStore {
35
36
  virtual ~PreparedScriptStore() = default;
36
37
 
37
- // Try to retrieve the prepared JavaScript for a given combination of script & runtime.
38
- // scriptSignature : JavaScript URL and version
39
- // RuntimeSignature : JavaScript engine type and version
38
+ // Try to retrieve the prepared javascript for a given combination of script & runtime.
39
+ // scriptSignature : Javascript url and version
40
+ // RuntimeSignature : Javascript engine type and version
40
41
  // prepareTag : Custom tag to uniquely identify JS engine specific preparation schemes. It is usually useful while
41
42
  // experimentation and can be null. It is possible that no prepared script is available for a given script & runtime
42
43
  // signature. This method should null if so
@@ -46,12 +47,12 @@ struct PreparedScriptStore {
46
47
  const char *prepareTag // Optional tag. For e.g. eagerly evaluated vs lazy cache.
47
48
  ) noexcept = 0;
48
49
 
49
- // Persist the prepared JavaScript for a given combination of script & runtime.
50
- // scriptSignature : JavaScript URL and version
51
- // RuntimeSignature : JavaScript engine type and version
50
+ // Persist the perpared javascript for a given combination of script & runtime.
51
+ // scriptSignature : Javascript url and version
52
+ // RuntimeSignature : Javascript engine type and version
52
53
  // prepareTag : Custom tag to uniquely identify JS engine specific preparation schemes. It is usually useful while
53
54
  // experimentation and can be null. It is possible that no prepared script is available for a given script & runtime
54
- // signature. This method should null if so Any failure in persistence should be identified during the subsequent
55
+ // signature. This method should null if so Any failure in persistance should be identified during the subsequent
55
56
  // retrieval through the integrity mechanism which must be put into the storage.
56
57
  virtual void persistPreparedScript(
57
58
  std::shared_ptr<const facebook::jsi::Buffer> preparedScript,
@@ -62,16 +63,17 @@ struct PreparedScriptStore {
62
63
  };
63
64
 
64
65
  // JSI::Runtime implementation must be provided an instance on this interface to enable version sensitive capabilities
65
- // such as usage of prepared JavaScript script. Alternatively, this entity can be used to directly provide the
66
- // JavaScript buffer and rich meta data to the JSI::Runtime instance.
66
+ // such as usage of pre-prepared javascript script. Alternatively, this entity can be used to directly provide the
67
+ // Javascript buffer and rich metadata to the JSI::Runtime instance.
67
68
  struct ScriptStore {
68
69
  virtual ~ScriptStore() = default;
69
70
 
70
- // Return the JavaScript buffer and version corresponding to a given URL.
71
+ // Return the Javascript buffer and version corresponding to a given url.
71
72
  virtual VersionedBuffer getVersionedScript(const std::string &url) noexcept = 0;
72
73
 
73
- // Return the version of the JavaScript buffer corresponding to a given URL.
74
+ // Return the version of the Javascript buffer corresponding to a given url.
74
75
  virtual ScriptVersion_t getScriptVersion(const std::string &url) noexcept = 0;
75
76
  };
76
77
 
77
- } // namespace facebook::jsi
78
+ } // namespace jsi
79
+ } // namespace facebook
@@ -52,11 +52,13 @@
52
52
  #include "HermesRuntimeHolder.h"
53
53
 
54
54
  #if defined(USE_V8)
55
- #include <JSI/V8RuntimeHolder.h>
55
+ #include <JSI/NapiJsiV8RuntimeHolder.h>
56
+
57
+ #include "BaseScriptStoreImpl.h"
58
+ #include "V8JSIRuntimeHolder.h"
56
59
  #endif
57
60
  #include <ReactCommon/CallInvoker.h>
58
61
  #include <ReactCommon/TurboModuleBinding.h>
59
- #include "BaseScriptStoreImpl.h"
60
62
  #include "ChakraRuntimeHolder.h"
61
63
 
62
64
  #include <tracing/tracing.h>
@@ -316,32 +318,46 @@ InstanceImpl::InstanceImpl(
316
318
  } else {
317
319
  assert(m_devSettings->jsiEngineOverride != JSIEngineOverride::Default);
318
320
  switch (m_devSettings->jsiEngineOverride) {
319
- case JSIEngineOverride::Hermes: {
320
- std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
321
+ case JSIEngineOverride::Hermes:
322
+ m_devSettings->jsiRuntimeHolder = std::make_shared<HermesRuntimeHolder>(m_devSettings, m_jsThread);
323
+ break;
324
+ case JSIEngineOverride::V8: {
325
+ #if defined(USE_V8)
326
+ std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
327
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
321
328
 
322
- wchar_t tempPath[MAX_PATH];
323
- if (GetTempPathW(MAX_PATH, tempPath)) {
324
- preparedScriptStore =
325
- std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
329
+ char tempPath[MAX_PATH];
330
+ if (GetTempPathA(MAX_PATH, tempPath)) {
331
+ preparedScriptStore = std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(tempPath);
326
332
  }
327
333
 
328
- m_devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::ReactNative::HermesRuntimeHolder>(
329
- m_devSettings, m_jsThread, std::move(preparedScriptStore));
334
+ m_devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
335
+ m_devSettings, m_jsThread, std::move(scriptStore), std::move(preparedScriptStore));
330
336
  break;
337
+ #else
338
+ assert(false); // V8 is not available in this build, fallthrough
339
+ [[fallthrough]];
340
+ #endif
331
341
  }
332
- case JSIEngineOverride::V8:
333
342
  case JSIEngineOverride::V8NodeApi: {
334
343
  #if defined(USE_V8)
335
- std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
344
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
336
345
 
337
346
  wchar_t tempPath[MAX_PATH];
338
- if (GetTempPathW(MAX_PATH, tempPath)) {
347
+ if (GetTempPathW(static_cast<DWORD>(std::size(tempPath)), tempPath)) {
339
348
  preparedScriptStore =
340
- std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
349
+ std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
350
+ }
351
+
352
+ if (!preparedScriptStore) {
353
+ if (m_devSettings->errorCallback)
354
+ m_devSettings->errorCallback("Could not initialize prepared script store");
355
+
356
+ break;
341
357
  }
342
358
 
343
- m_devSettings->jsiRuntimeHolder = make_shared<Microsoft::ReactNative::V8RuntimeHolder>(
344
- m_devSettings, m_jsThread, std::move(preparedScriptStore), false);
359
+ m_devSettings->jsiRuntimeHolder = make_shared<NapiJsiV8RuntimeHolder>(
360
+ m_devSettings, m_jsThread, nullptr /*scriptStore*/, std::move(preparedScriptStore));
345
361
  break;
346
362
  #else
347
363
  if (m_devSettings->errorCallback)
@@ -621,7 +637,7 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
621
637
  nativeQueue));
622
638
 
623
639
  // These modules are instantiated separately in MSRN (Universal Windows).
624
- // When there are module name collisions, the last one registered is used.
640
+ // When there are module name colisions, the last one registered is used.
625
641
  // If this code is enabled, we will have unused module instances.
626
642
  // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable.
627
643
  #if (defined(_MSC_VER) && !defined(WINRT))
@@ -27,13 +27,14 @@
27
27
  <ClCompile Include="$(MSBuildThisFileDirectory)Executors\WebSocketJSExecutorFactory.cpp" />
28
28
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp" />
29
29
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp" />
30
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp" />
30
31
  <ClCompile Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.cpp" />
31
32
  <ClCompile Include="$(MSBuildThisFileDirectory)InstanceManager.cpp" />
32
33
  <ClCompile Include="$(MSBuildThisFileDirectory)JSBigAbiString.cpp" />
33
34
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraApi.cpp" />
34
35
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraJsiRuntime_edgemode.cpp" />
35
36
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.cpp" />
36
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp">
37
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.cpp">
37
38
  <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
38
39
  </ClCompile>
39
40
  <ClCompile Include="$(MSBuildThisFileDirectory)LayoutAnimation.cpp" />
@@ -63,7 +64,6 @@
63
64
  <ClCompile Include="$(MSBuildThisFileDirectory)OInstance.cpp" />
64
65
  <ClCompile Include="$(MSBuildThisFileDirectory)PackagerConnection.cpp" />
65
66
  <ClCompile Include="$(MSBuildThisFileDirectory)RuntimeOptions.cpp" />
66
- <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
67
67
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\BatchingQueueThread.cpp" />
68
68
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageDispatchQueue.cpp" />
69
69
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageQueueThreadFactory.cpp" />
@@ -71,10 +71,12 @@
71
71
  <ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleManager.cpp" />
72
72
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp" />
73
73
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.cpp" />
74
+ <ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
75
+ <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
76
+ </ClCompile>
74
77
  </ItemGroup>
75
78
  <ItemGroup>
76
79
  <ClInclude Include="$(MSBuildThisFileDirectory)..\include\Shared\cdebug.h" />
77
- <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
78
80
  <ClInclude Include="$(MSBuildThisFileDirectory)AbiSafe.h" />
79
81
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorageModule.h" />
80
82
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\AsyncStorageManager.h" />
@@ -82,12 +84,13 @@
82
84
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\KeyValueStorage.h" />
83
85
  <ClInclude Include="$(MSBuildThisFileDirectory)CppRuntimeOptions.h" />
84
86
  <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h" />
87
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h" />
85
88
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ByteArrayBuffer.h" />
86
89
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraApi.h" />
87
90
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.h" />
88
91
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeArgs.h" />
89
92
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeFactory.h" />
90
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
93
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h" />
91
94
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\RuntimeHolder.h" />
92
95
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ScriptStore.h" />
93
96
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h" />
@@ -142,7 +145,6 @@
142
145
  <ClInclude Include="$(MSBuildThisFileDirectory)NativeModuleProvider.h" />
143
146
  <ClInclude Include="$(MSBuildThisFileDirectory)OInstance.h" />
144
147
  <ClInclude Include="$(MSBuildThisFileDirectory)Pch\pch.h" />
145
- <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
146
148
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNode.h" />
147
149
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNodeRegistry.h" />
148
150
  <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
@@ -157,6 +159,7 @@
157
159
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
158
160
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
159
161
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
162
+ <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
160
163
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
161
164
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />
162
165
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
@@ -303,18 +306,4 @@
303
306
  <SubType>Code</SubType>
304
307
  </ClCompile>
305
308
  </ItemGroup>
306
- <ItemGroup>
307
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
308
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
309
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp">
310
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
311
- </ClCompile>
312
- </ItemGroup>
313
- <ItemGroup Condition="'$(UseV8)' == 'true'">
314
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.h" />
315
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.inc" />
316
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.cpp">
317
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
318
- </ClCompile>
319
- </ItemGroup>
320
309
  </Project>
@@ -43,6 +43,9 @@
43
43
  <ClCompile Include="$(MSBuildThisFileDirectory)CxxMessageQueue.cpp">
44
44
  <Filter>Source Files</Filter>
45
45
  </ClCompile>
46
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp">
47
+ <Filter>Source Files</Filter>
48
+ </ClCompile>
46
49
  <ClCompile Include="$(MSBuildThisFileDirectory)JSBigAbiString.cpp">
47
50
  <Filter>Source Files</Filter>
48
51
  </ClCompile>
@@ -55,6 +58,9 @@
55
58
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp">
56
59
  <Filter>Source Files</Filter>
57
60
  </ClCompile>
61
+ <ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
62
+ <Filter>Source Files</Filter>
63
+ </ClCompile>
58
64
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\AsyncStorageModuleWin32.cpp">
59
65
  <Filter>Source Files\Modules</Filter>
60
66
  </ClCompile>
@@ -112,6 +118,15 @@
112
118
  <ClCompile Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.cpp">
113
119
  <Filter>Source Files</Filter>
114
120
  </ClCompile>
121
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.cpp">
122
+ <Filter>Source Files\JSI</Filter>
123
+ </ClCompile>
124
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp">
125
+ <Filter>Source Files</Filter>
126
+ </ClCompile>
127
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp">
128
+ <Filter>Source Files</Filter>
129
+ </ClCompile>
115
130
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\HttpModule.cpp">
116
131
  <Filter>Source Files\Modules</Filter>
117
132
  </ClCompile>
@@ -141,15 +156,6 @@
141
156
  <Filter>Source Files\Modules</Filter>
142
157
  </ClCompile>
143
158
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
144
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp">
145
- <Filter>Hermes</Filter>
146
- </ClCompile>
147
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp">
148
- <Filter>Hermes</Filter>
149
- </ClCompile>
150
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp" />
151
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp" />
152
- <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
153
159
  </ItemGroup>
154
160
  <ItemGroup>
155
161
  <Filter Include="Source Files">
@@ -209,9 +215,6 @@
209
215
  <Filter Include="Source Files\Networking">
210
216
  <UniqueIdentifier>{71196e04-aca0-48d6-99e4-f418c957b50f}</UniqueIdentifier>
211
217
  </Filter>
212
- <Filter Include="Hermes">
213
- <UniqueIdentifier>{b32590e6-ae3d-4388-ab98-767345ce38c9}</UniqueIdentifier>
214
- </Filter>
215
218
  </ItemGroup>
216
219
  <ItemGroup>
217
220
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\StorageFileIO.h">
@@ -277,6 +280,9 @@
277
280
  <ClInclude Include="$(MSBuildThisFileDirectory)DevSettings.h">
278
281
  <Filter>Header Files</Filter>
279
282
  </ClInclude>
283
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
284
+ <Filter>Header Files</Filter>
285
+ </ClInclude>
280
286
  <ClInclude Include="$(MSBuildThisFileDirectory)IDevSupportManager.h">
281
287
  <Filter>Header Files</Filter>
282
288
  </ClInclude>
@@ -328,6 +334,9 @@
328
334
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h">
329
335
  <Filter>Header Files</Filter>
330
336
  </ClInclude>
337
+ <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h">
338
+ <Filter>Header Files</Filter>
339
+ </ClInclude>
331
340
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h">
332
341
  <Filter>Header Files</Filter>
333
342
  </ClInclude>
@@ -383,6 +392,15 @@
383
392
  <ClInclude Include="$(MSBuildThisFileDirectory)tracing\tracing.h">
384
393
  <Filter>Header Files\tracing</Filter>
385
394
  </ClInclude>
395
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h">
396
+ <Filter>Header Files\JSI</Filter>
397
+ </ClInclude>
398
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
399
+ <Filter>Header Files</Filter>
400
+ </ClInclude>
401
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h">
402
+ <Filter>Header Files</Filter>
403
+ </ClInclude>
386
404
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h">
387
405
  <Filter>Header Files\Modules</Filter>
388
406
  </ClInclude>
@@ -452,17 +470,6 @@
452
470
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleContentHandler.h">
453
471
  <Filter>Header Files\Modules</Filter>
454
472
  </ClInclude>
455
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
456
- <Filter>Hermes</Filter>
457
- </ClInclude>
458
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
459
- <Filter>Hermes</Filter>
460
- </ClInclude>
461
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
462
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
463
- <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
464
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
465
- <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
466
473
  </ItemGroup>
467
474
  <ItemGroup>
468
475
  <None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">