react-native-windows 0.71.26 → 0.71.27

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 (47) 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.Cxx/JSI/NodeApiJsiRuntime.cpp +2103 -0
  9. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +73 -0
  10. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +12 -43
  11. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +6 -17
  12. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  13. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  14. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +1 -1
  15. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  16. package/PropertySheets/JSEngine.props +4 -4
  17. package/PropertySheets/React.Cpp.props +0 -1
  18. package/PropertySheets/Warnings.props +0 -6
  19. package/ReactCommon/ReactCommon.vcxproj +1 -53
  20. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +0 -36
  21. package/Shared/DevSupportManager.cpp +9 -2
  22. package/Shared/DevSupportManager.h +6 -2
  23. package/Shared/HermesRuntimeHolder.cpp +84 -344
  24. package/Shared/HermesRuntimeHolder.h +21 -32
  25. package/Shared/HermesSamplingProfiler.cpp +14 -66
  26. package/Shared/HermesSamplingProfiler.h +3 -5
  27. package/Shared/HermesShim.cpp +118 -0
  28. package/Shared/HermesShim.h +21 -0
  29. package/Shared/InspectorPackagerConnection.cpp +108 -62
  30. package/Shared/InspectorPackagerConnection.h +21 -9
  31. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +209 -0
  32. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +44 -0
  33. package/Shared/JSI/RuntimeHolder.h +2 -2
  34. package/Shared/JSI/ScriptStore.h +20 -18
  35. package/Shared/OInstance.cpp +32 -16
  36. package/Shared/Shared.vcxitems +8 -19
  37. package/Shared/Shared.vcxitems.filters +30 -23
  38. package/Shared/V8JSIRuntimeHolder.cpp +70 -0
  39. package/Shared/V8JSIRuntimeHolder.h +53 -0
  40. package/package.json +2 -2
  41. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
  42. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +0 -16
  43. package/ReactCommon/cgmanifest.json +0 -15
  44. package/Shared/JSI/V8RuntimeHolder.cpp +0 -260
  45. package/Shared/JSI/V8RuntimeHolder.h +0 -37
  46. package/Shared/SafeLoadLibrary.cpp +0 -41
  47. 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
@@ -51,11 +51,13 @@
51
51
  #include "HermesRuntimeHolder.h"
52
52
 
53
53
  #if defined(USE_V8)
54
- #include <JSI/V8RuntimeHolder.h>
54
+ #include <JSI/NapiJsiV8RuntimeHolder.h>
55
+
56
+ #include "BaseScriptStoreImpl.h"
57
+ #include "V8JSIRuntimeHolder.h"
55
58
  #endif
56
59
  #include <ReactCommon/CallInvoker.h>
57
60
  #include <ReactCommon/TurboModuleBinding.h>
58
- #include "BaseScriptStoreImpl.h"
59
61
  #include "ChakraRuntimeHolder.h"
60
62
 
61
63
  #include <tracing/tracing.h>
@@ -306,32 +308,46 @@ InstanceImpl::InstanceImpl(
306
308
  } else {
307
309
  assert(m_devSettings->jsiEngineOverride != JSIEngineOverride::Default);
308
310
  switch (m_devSettings->jsiEngineOverride) {
309
- case JSIEngineOverride::Hermes: {
310
- std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
311
+ case JSIEngineOverride::Hermes:
312
+ m_devSettings->jsiRuntimeHolder = std::make_shared<HermesRuntimeHolder>(m_devSettings, m_jsThread);
313
+ break;
314
+ case JSIEngineOverride::V8: {
315
+ #if defined(USE_V8)
316
+ std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
317
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
311
318
 
312
- wchar_t tempPath[MAX_PATH];
313
- if (GetTempPathW(MAX_PATH, tempPath)) {
314
- preparedScriptStore =
315
- std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
319
+ char tempPath[MAX_PATH];
320
+ if (GetTempPathA(MAX_PATH, tempPath)) {
321
+ preparedScriptStore = std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(tempPath);
316
322
  }
317
323
 
318
- m_devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::ReactNative::HermesRuntimeHolder>(
319
- m_devSettings, m_jsThread, std::move(preparedScriptStore));
324
+ m_devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
325
+ m_devSettings, m_jsThread, std::move(scriptStore), std::move(preparedScriptStore));
320
326
  break;
327
+ #else
328
+ assert(false); // V8 is not available in this build, fallthrough
329
+ [[fallthrough]];
330
+ #endif
321
331
  }
322
- case JSIEngineOverride::V8:
323
332
  case JSIEngineOverride::V8NodeApi: {
324
333
  #if defined(USE_V8)
325
- std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
334
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
326
335
 
327
336
  wchar_t tempPath[MAX_PATH];
328
- if (GetTempPathW(MAX_PATH, tempPath)) {
337
+ if (GetTempPathW(static_cast<DWORD>(std::size(tempPath)), tempPath)) {
329
338
  preparedScriptStore =
330
- std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
339
+ std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
340
+ }
341
+
342
+ if (!preparedScriptStore) {
343
+ if (m_devSettings->errorCallback)
344
+ m_devSettings->errorCallback("Could not initialize prepared script store");
345
+
346
+ break;
331
347
  }
332
348
 
333
- m_devSettings->jsiRuntimeHolder = make_shared<Microsoft::ReactNative::V8RuntimeHolder>(
334
- m_devSettings, m_jsThread, std::move(preparedScriptStore), false);
349
+ m_devSettings->jsiRuntimeHolder = make_shared<NapiJsiV8RuntimeHolder>(
350
+ m_devSettings, m_jsThread, nullptr /*scriptStore*/, std::move(preparedScriptStore));
335
351
  break;
336
352
  #else
337
353
  if (m_devSettings->errorCallback)
@@ -29,13 +29,14 @@
29
29
  <ClCompile Include="$(MSBuildThisFileDirectory)Hasher.cpp" />
30
30
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp" />
31
31
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp" />
32
+ <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp" />
32
33
  <ClCompile Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.cpp" />
33
34
  <ClCompile Include="$(MSBuildThisFileDirectory)InstanceManager.cpp" />
34
35
  <ClCompile Include="$(MSBuildThisFileDirectory)JSBigAbiString.cpp" />
35
36
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraApi.cpp" />
36
37
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraJsiRuntime_edgemode.cpp" />
37
38
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.cpp" />
38
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp">
39
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.cpp">
39
40
  <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
40
41
  </ClCompile>
41
42
  <ClCompile Include="$(MSBuildThisFileDirectory)LayoutAnimation.cpp" />
@@ -66,7 +67,6 @@
66
67
  <ClCompile Include="$(MSBuildThisFileDirectory)OInstance.cpp" />
67
68
  <ClCompile Include="$(MSBuildThisFileDirectory)PackagerConnection.cpp" />
68
69
  <ClCompile Include="$(MSBuildThisFileDirectory)RuntimeOptions.cpp" />
69
- <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
70
70
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\BatchingQueueThread.cpp" />
71
71
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageDispatchQueue.cpp" />
72
72
  <ClCompile Include="$(MSBuildThisFileDirectory)Threading\MessageQueueThreadFactory.cpp" />
@@ -74,10 +74,12 @@
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" />
80
- <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
81
83
  <ClInclude Include="$(MSBuildThisFileDirectory)AbiSafe.h" />
82
84
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorageModule.h" />
83
85
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\AsyncStorageManager.h" />
@@ -86,6 +88,7 @@
86
88
  <ClInclude Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.h" />
87
89
  <ClInclude Include="$(MSBuildThisFileDirectory)CppRuntimeOptions.h" />
88
90
  <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h" />
91
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h" />
89
92
  <ClInclude Include="$(MSBuildThisFileDirectory)IBlobPersistor.h" />
90
93
  <ClInclude Include="$(MSBuildThisFileDirectory)IFileReaderResource.h" />
91
94
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ByteArrayBuffer.h" />
@@ -93,7 +96,7 @@
93
96
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntime.h" />
94
97
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeArgs.h" />
95
98
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ChakraRuntimeFactory.h" />
96
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
99
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h" />
97
100
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\RuntimeHolder.h" />
98
101
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\ScriptStore.h" />
99
102
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h" />
@@ -150,7 +153,6 @@
150
153
  <ClInclude Include="$(MSBuildThisFileDirectory)NativeModuleProvider.h" />
151
154
  <ClInclude Include="$(MSBuildThisFileDirectory)OInstance.h" />
152
155
  <ClInclude Include="$(MSBuildThisFileDirectory)Pch\pch.h" />
153
- <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
154
156
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNode.h" />
155
157
  <ClInclude Include="$(MSBuildThisFileDirectory)ShadowNodeRegistry.h" />
156
158
  <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
@@ -165,6 +167,7 @@
165
167
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
166
168
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
167
169
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
170
+ <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
168
171
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
169
172
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />
170
173
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
@@ -311,18 +314,4 @@
311
314
  <SubType>Code</SubType>
312
315
  </ClCompile>
313
316
  </ItemGroup>
314
- <ItemGroup>
315
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
316
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
317
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp">
318
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
319
- </ClCompile>
320
- </ItemGroup>
321
- <ItemGroup Condition="'$(UseV8)' == 'true'">
322
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.h" />
323
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.inc" />
324
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\V8Api.cpp">
325
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
326
- </ClCompile>
327
- </ItemGroup>
328
317
  </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>
@@ -148,15 +163,6 @@
148
163
  <ClCompile Include="$(MSBuildThisFileDirectory)Networking\DefaultBlobResource.cpp">
149
164
  <Filter>Source Files\Networking</Filter>
150
165
  </ClCompile>
151
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.cpp">
152
- <Filter>Hermes</Filter>
153
- </ClCompile>
154
- <ClCompile Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.cpp">
155
- <Filter>Hermes</Filter>
156
- </ClCompile>
157
- <ClCompile Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.cpp" />
158
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp" />
159
- <ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
160
166
  </ItemGroup>
161
167
  <ItemGroup>
162
168
  <Filter Include="Source Files">
@@ -216,9 +222,6 @@
216
222
  <Filter Include="Source Files\Networking">
217
223
  <UniqueIdentifier>{71196e04-aca0-48d6-99e4-f418c957b50f}</UniqueIdentifier>
218
224
  </Filter>
219
- <Filter Include="Hermes">
220
- <UniqueIdentifier>{b32590e6-ae3d-4388-ab98-767345ce38c9}</UniqueIdentifier>
221
- </Filter>
222
225
  </ItemGroup>
223
226
  <ItemGroup>
224
227
  <ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\StorageFileIO.h">
@@ -284,6 +287,9 @@
284
287
  <ClInclude Include="$(MSBuildThisFileDirectory)DevSettings.h">
285
288
  <Filter>Header Files</Filter>
286
289
  </ClInclude>
290
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
291
+ <Filter>Header Files</Filter>
292
+ </ClInclude>
287
293
  <ClInclude Include="$(MSBuildThisFileDirectory)IDevSupportManager.h">
288
294
  <Filter>Header Files</Filter>
289
295
  </ClInclude>
@@ -335,6 +341,9 @@
335
341
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h">
336
342
  <Filter>Header Files</Filter>
337
343
  </ClInclude>
344
+ <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h">
345
+ <Filter>Header Files</Filter>
346
+ </ClInclude>
338
347
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h">
339
348
  <Filter>Header Files</Filter>
340
349
  </ClInclude>
@@ -390,6 +399,15 @@
390
399
  <ClInclude Include="$(MSBuildThisFileDirectory)tracing\tracing.h">
391
400
  <Filter>Header Files\tracing</Filter>
392
401
  </ClInclude>
402
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h">
403
+ <Filter>Header Files\JSI</Filter>
404
+ </ClInclude>
405
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
406
+ <Filter>Header Files</Filter>
407
+ </ClInclude>
408
+ <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h">
409
+ <Filter>Header Files</Filter>
410
+ </ClInclude>
393
411
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h">
394
412
  <Filter>Header Files\Modules</Filter>
395
413
  </ClInclude>
@@ -474,17 +492,6 @@
474
492
  <ClInclude Include="$(MSBuildThisFileDirectory)IBlobPersistor.h">
475
493
  <Filter>Header Files</Filter>
476
494
  </ClInclude>
477
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h">
478
- <Filter>Hermes</Filter>
479
- </ClInclude>
480
- <ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h">
481
- <Filter>Hermes</Filter>
482
- </ClInclude>
483
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
484
- <ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.inc" />
485
- <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\JsiApi.h" />
486
- <ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
487
- <ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
488
495
  </ItemGroup>
489
496
  <ItemGroup>
490
497
  <None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">