react-native-windows 0.71.35 → 0.71.37

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 (48) 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 +23 -36
  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/DevSettings.h +3 -0
  22. package/Shared/DevSupportManager.cpp +9 -2
  23. package/Shared/DevSupportManager.h +6 -2
  24. package/Shared/HermesRuntimeHolder.cpp +84 -344
  25. package/Shared/HermesRuntimeHolder.h +21 -32
  26. package/Shared/HermesSamplingProfiler.cpp +14 -66
  27. package/Shared/HermesSamplingProfiler.h +3 -5
  28. package/Shared/HermesShim.cpp +118 -0
  29. package/Shared/HermesShim.h +21 -0
  30. package/Shared/InspectorPackagerConnection.cpp +108 -62
  31. package/Shared/InspectorPackagerConnection.h +21 -9
  32. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +209 -0
  33. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +44 -0
  34. package/Shared/JSI/RuntimeHolder.h +2 -2
  35. package/Shared/JSI/ScriptStore.h +20 -18
  36. package/Shared/OInstance.cpp +56 -41
  37. package/Shared/Shared.vcxitems +8 -19
  38. package/Shared/Shared.vcxitems.filters +30 -23
  39. package/Shared/V8JSIRuntimeHolder.cpp +70 -0
  40. package/Shared/V8JSIRuntimeHolder.h +53 -0
  41. package/package.json +2 -2
  42. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
  43. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +0 -16
  44. package/ReactCommon/cgmanifest.json +0 -15
  45. package/Shared/JSI/V8RuntimeHolder.cpp +0 -260
  46. package/Shared/JSI/V8RuntimeHolder.h +0 -37
  47. package/Shared/SafeLoadLibrary.cpp +0 -77
  48. package/Shared/SafeLoadLibrary.h +0 -19
@@ -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)
@@ -538,35 +554,34 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
538
554
  // If this code is enabled, we will have unused module instances.
539
555
  // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable.
540
556
  #if (defined(_MSC_VER) && !defined(WINRT))
541
- modules.push_back(std::make_unique<CxxNativeModule>(
542
- m_innerInstance,
543
- Microsoft::React::GetHttpModuleName(),
544
- [nativeQueue, transitionalProps]() -> std::unique_ptr<xplat::module::CxxModule> {
545
- return Microsoft::React::CreateHttpModule(transitionalProps);
546
- },
547
- nativeQueue));
548
-
549
- modules.push_back(std::make_unique<CxxNativeModule>(
550
- m_innerInstance,
551
- Microsoft::React::GetWebSocketModuleName(),
552
- [nativeQueue, transitionalProps]() -> std::unique_ptr<xplat::module::CxxModule> {
553
- return Microsoft::React::CreateWebSocketModule(transitionalProps);
554
- },
555
- nativeQueue));
556
-
557
- // Use in case the host app provides its a non-Blob-compatilbe HTTP module.
558
- if (!Microsoft::React::GetRuntimeOptionBool("Blob.DisableModule")) {
557
+ // Applications using the Windows ABI feature should loade the networking TurboModule variants instead.
558
+ if (!m_devSettings->omitNetworkingCxxModules) {
559
559
  modules.push_back(std::make_unique<CxxNativeModule>(
560
560
  m_innerInstance,
561
- Microsoft::React::GetBlobModuleName(),
562
- [transitionalProps]() { return Microsoft::React::CreateBlobModule(transitionalProps); },
561
+ Microsoft::React::GetWebSocketModuleName(),
562
+ [transitionalProps]() { return Microsoft::React::CreateWebSocketModule(transitionalProps); },
563
563
  nativeQueue));
564
564
 
565
- modules.push_back(std::make_unique<CxxNativeModule>(
566
- m_innerInstance,
567
- Microsoft::React::GetFileReaderModuleName(),
568
- [transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); },
569
- nativeQueue));
565
+ // Use in case the host app provides its a non-Blob-compatilbe HTTP module.
566
+ if (!Microsoft::React::GetRuntimeOptionBool("Blob.DisableModule")) {
567
+ modules.push_back(std::make_unique<CxxNativeModule>(
568
+ m_innerInstance,
569
+ Microsoft::React::GetHttpModuleName(),
570
+ [transitionalProps]() { return Microsoft::React::CreateHttpModule(transitionalProps); },
571
+ nativeQueue));
572
+
573
+ modules.push_back(std::make_unique<CxxNativeModule>(
574
+ m_innerInstance,
575
+ Microsoft::React::GetBlobModuleName(),
576
+ [transitionalProps]() { return Microsoft::React::CreateBlobModule(transitionalProps); },
577
+ nativeQueue));
578
+
579
+ modules.push_back(std::make_unique<CxxNativeModule>(
580
+ m_innerInstance,
581
+ Microsoft::React::GetFileReaderModuleName(),
582
+ [transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); },
583
+ nativeQueue));
584
+ }
570
585
  }
571
586
 
572
587
  modules.push_back(std::make_unique<CxxNativeModule>(
@@ -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>