react-native-windows 0.67.7 → 0.67.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +162 -0
- package/CHANGELOG.md +68 -8
- package/Chakra/ChakraHelpers.cpp +0 -1
- package/Directory.Build.props +4 -0
- package/Folly/Folly.vcxproj +4 -5
- package/Libraries/Network/RCTNetworkingWinShared.js +7 -0
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +2 -3
- package/Microsoft.ReactNative/IReactContext.cpp +17 -0
- package/Microsoft.ReactNative/IReactContext.h +2 -0
- package/Microsoft.ReactNative/IReactContext.idl +27 -0
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
- package/Microsoft.ReactNative/packages.config +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +26 -16
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +52 -0
- package/Microsoft.ReactNative.Cxx/NativeModules.h +2 -2
- package/Mso/src/dispatchQueue/threadPoolScheduler_win.cpp +96 -4
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/JSEngine.props +1 -1
- package/Scripts/OfficeReact.Win32.nuspec +1 -1
- package/Shared/BaseScriptStoreImpl.cpp +1 -1
- package/Shared/CppRuntimeOptions.h +50 -0
- package/Shared/CreateModules.h +20 -1
- package/Shared/InspectorPackagerConnection.cpp +7 -5
- package/Shared/InspectorPackagerConnection.h +2 -2
- package/Shared/JSI/ChakraApi.cpp +0 -1
- package/Shared/JSI/ChakraRuntime.cpp +0 -1
- package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +72 -2
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +3 -1
- package/Shared/Modules/BlobModule.cpp +376 -0
- package/Shared/Modules/BlobModule.h +153 -0
- package/Shared/Modules/CxxModuleUtilities.cpp +19 -0
- package/Shared/Modules/CxxModuleUtilities.h +23 -0
- package/Shared/Modules/FileReaderModule.cpp +156 -0
- package/Shared/Modules/FileReaderModule.h +54 -0
- package/Shared/Modules/HttpModule.cpp +201 -0
- package/Shared/Modules/HttpModule.h +60 -0
- package/Shared/Modules/IBlobPersistor.h +30 -0
- package/Shared/Modules/IHttpModuleProxy.h +30 -0
- package/Shared/Modules/IRequestBodyHandler.h +52 -0
- package/Shared/Modules/IResponseHandler.h +27 -0
- package/Shared/Modules/IUriHandler.h +37 -0
- package/Shared/Modules/IWebSocketModuleContentHandler.h +26 -0
- package/Shared/Modules/IWebSocketModuleProxy.h +22 -0
- package/Shared/Modules/NetworkingModule.cpp +1 -1
- package/Shared/Modules/WebSocketModule.cpp +97 -23
- package/Shared/Modules/WebSocketModule.h +35 -6
- package/Shared/Networking/IHttpResource.h +101 -0
- package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
- package/Shared/Networking/OriginPolicy.h +15 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +747 -0
- package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
- package/Shared/Networking/WinRTHttpResource.cpp +465 -0
- package/Shared/Networking/WinRTHttpResource.h +86 -0
- package/Shared/Networking/WinRTTypes.h +33 -0
- package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +31 -22
- package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
- package/Shared/OInstance.cpp +41 -4
- package/Shared/OInstance.h +8 -4
- package/Shared/RuntimeOptions.cpp +96 -15
- package/Shared/RuntimeOptions.h +32 -8
- package/Shared/Shared.vcxitems +28 -5
- package/Shared/Shared.vcxitems.filters +93 -15
- package/Shared/Utils/WinRTConversions.cpp +22 -0
- package/Shared/Utils/WinRTConversions.h +15 -0
- package/fmt/fmt.vcxproj +4 -5
- package/package.json +1 -1
- package/Shared/IHttpResource.h +0 -34
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
#include <Utilities.h>
|
|
7
7
|
#include <Utils/CppWinrtLessExceptions.h>
|
|
8
|
+
#include <Utils/WinRTConversions.h>
|
|
9
|
+
|
|
10
|
+
// MSO
|
|
11
|
+
#include <dispatchQueue/dispatchQueue.h>
|
|
8
12
|
|
|
9
13
|
// Windows API
|
|
10
14
|
#include <winrt/Windows.Foundation.Collections.h>
|
|
@@ -44,6 +48,7 @@ using winrt::Windows::Storage::Streams::IDataWriter;
|
|
|
44
48
|
using winrt::Windows::Storage::Streams::UnicodeEncoding;
|
|
45
49
|
|
|
46
50
|
namespace {
|
|
51
|
+
|
|
47
52
|
///
|
|
48
53
|
/// Implements an awaiter for Mso::DispatchQueue
|
|
49
54
|
///
|
|
@@ -72,20 +77,9 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept {
|
|
|
72
77
|
return awaitable{queue};
|
|
73
78
|
} // resume_in_queue
|
|
74
79
|
|
|
75
|
-
string HResultToString(hresult_error const &e) {
|
|
76
|
-
std::stringstream stream;
|
|
77
|
-
stream << "[0x" << std::hex << e.code() << "] " << winrt::to_string(e.message());
|
|
78
|
-
|
|
79
|
-
return stream.str();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
string HResultToString(hresult &&result) {
|
|
83
|
-
return HResultToString(hresult_error(std::move(result), hresult_error::from_abi));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
} // namespace
|
|
87
81
|
|
|
88
|
-
namespace Microsoft::React {
|
|
82
|
+
namespace Microsoft::React::Networking {
|
|
89
83
|
|
|
90
84
|
// private
|
|
91
85
|
WinRTWebSocketResource::WinRTWebSocketResource(
|
|
@@ -134,12 +128,12 @@ IAsyncAction WinRTWebSocketResource::PerformConnect(Uri &&uri) noexcept {
|
|
|
134
128
|
}
|
|
135
129
|
} else {
|
|
136
130
|
if (self->m_errorHandler) {
|
|
137
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Connection});
|
|
131
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Connection});
|
|
138
132
|
}
|
|
139
133
|
}
|
|
140
134
|
} catch (hresult_error const &e) {
|
|
141
135
|
if (self->m_errorHandler) {
|
|
142
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Connection});
|
|
136
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Connection});
|
|
143
137
|
}
|
|
144
138
|
}
|
|
145
139
|
|
|
@@ -180,12 +174,12 @@ fire_and_forget WinRTWebSocketResource::PerformPing() noexcept {
|
|
|
180
174
|
}
|
|
181
175
|
} else {
|
|
182
176
|
if (self->m_errorHandler) {
|
|
183
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Ping});
|
|
177
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Ping});
|
|
184
178
|
}
|
|
185
179
|
}
|
|
186
180
|
} catch (hresult_error const &e) {
|
|
187
181
|
if (self->m_errorHandler) {
|
|
188
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Ping});
|
|
182
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Ping});
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
185
|
}
|
|
@@ -246,7 +240,7 @@ fire_and_forget WinRTWebSocketResource::PerformWrite(string &&message, bool isBi
|
|
|
246
240
|
}
|
|
247
241
|
} else {
|
|
248
242
|
if (self->m_errorHandler) {
|
|
249
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Send});
|
|
243
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Send});
|
|
250
244
|
}
|
|
251
245
|
}
|
|
252
246
|
} catch (std::exception const &e) {
|
|
@@ -256,7 +250,7 @@ fire_and_forget WinRTWebSocketResource::PerformWrite(string &&message, bool isBi
|
|
|
256
250
|
} catch (hresult_error const &e) {
|
|
257
251
|
// TODO: Remove after fixing unit tests exceptions.
|
|
258
252
|
if (self->m_errorHandler) {
|
|
259
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Ping});
|
|
253
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Ping});
|
|
260
254
|
}
|
|
261
255
|
}
|
|
262
256
|
}
|
|
@@ -278,7 +272,7 @@ fire_and_forget WinRTWebSocketResource::PerformClose() noexcept {
|
|
|
278
272
|
}
|
|
279
273
|
} catch (hresult_error const &e) {
|
|
280
274
|
if (m_errorHandler) {
|
|
281
|
-
m_errorHandler({HResultToString(e), ErrorType::Close});
|
|
275
|
+
m_errorHandler({Utilities::HResultToString(e), ErrorType::Close});
|
|
282
276
|
}
|
|
283
277
|
}
|
|
284
278
|
|
|
@@ -322,7 +316,22 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
|
|
|
322
316
|
}
|
|
323
317
|
} catch (hresult_error const &e) {
|
|
324
318
|
if (self->m_errorHandler) {
|
|
325
|
-
|
|
319
|
+
string errorMessage;
|
|
320
|
+
ErrorType errorType;
|
|
321
|
+
// See
|
|
322
|
+
// https://docs.microsoft.com/uwp/api/windows.networking.sockets.messagewebsocketmessagereceivedeventargs.getdatareader?view=winrt-19041#remarks
|
|
323
|
+
if (e.code() == WININET_E_CONNECTION_ABORTED) {
|
|
324
|
+
errorMessage = "[0x80072EFE] Underlying TCP connection suddenly terminated";
|
|
325
|
+
errorType = ErrorType::Connection;
|
|
326
|
+
self->m_errorHandler({errorMessage, errorType});
|
|
327
|
+
|
|
328
|
+
// Note: We are not clear whether all read-related errors should close the socket.
|
|
329
|
+
self->Close(CloseCode::BadPayload, std::move(errorMessage));
|
|
330
|
+
} else {
|
|
331
|
+
errorMessage = Utilities::HResultToString(e);
|
|
332
|
+
errorType = ErrorType::Receive;
|
|
333
|
+
self->m_errorHandler({errorMessage, errorType});
|
|
334
|
+
}
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
337
|
});
|
|
@@ -346,7 +355,7 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
|
|
|
346
355
|
uri = Uri{winrt::to_hstring(url)};
|
|
347
356
|
} catch (hresult_error const &e) {
|
|
348
357
|
if (m_errorHandler) {
|
|
349
|
-
m_errorHandler({HResultToString(e), ErrorType::Connection});
|
|
358
|
+
m_errorHandler({Utilities::HResultToString(e), ErrorType::Connection});
|
|
350
359
|
}
|
|
351
360
|
|
|
352
361
|
// Abort - Mark connection as concluded.
|
|
@@ -414,4 +423,4 @@ void WinRTWebSocketResource::SetOnError(function<void(Error &&)> &&handler) noex
|
|
|
414
423
|
|
|
415
424
|
#pragma endregion IWebSocketResource
|
|
416
425
|
|
|
417
|
-
} // namespace Microsoft::React
|
|
426
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#include <IWebSocketResource.h>
|
|
7
6
|
#include <dispatchQueue/dispatchQueue.h>
|
|
8
7
|
#include <eventWaitHandle/eventWaitHandle.h>
|
|
9
8
|
#include <winrt/Windows.Networking.Sockets.h>
|
|
10
9
|
#include <winrt/Windows.Storage.Streams.h>
|
|
10
|
+
#include "IWebSocketResource.h"
|
|
11
11
|
|
|
12
12
|
// Standard Library
|
|
13
13
|
#include <future>
|
|
14
14
|
#include <mutex>
|
|
15
15
|
#include <queue>
|
|
16
16
|
|
|
17
|
-
namespace Microsoft::React {
|
|
17
|
+
namespace Microsoft::React::Networking {
|
|
18
18
|
|
|
19
19
|
class WinRTWebSocketResource : public IWebSocketResource, public std::enable_shared_from_this<WinRTWebSocketResource> {
|
|
20
20
|
winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
|
|
@@ -126,4 +126,4 @@ class WinRTWebSocketResource : public IWebSocketResource, public std::enable_sha
|
|
|
126
126
|
#pragma endregion IWebSocketResource
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
} // namespace Microsoft::React
|
|
129
|
+
} // namespace Microsoft::React::Networking
|
package/Shared/OInstance.cpp
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
#include <cxxreact/ModuleRegistry.h>
|
|
27
27
|
|
|
28
28
|
#include <Modules/ExceptionsManagerModule.h>
|
|
29
|
+
#include <Modules/HttpModule.h>
|
|
30
|
+
#include <Modules/NetworkingModule.h>
|
|
29
31
|
#include <Modules/PlatformConstantsModule.h>
|
|
30
32
|
#include <Modules/SourceCodeModule.h>
|
|
31
33
|
#include <Modules/StatusBarManagerModule.h>
|
|
@@ -35,11 +37,11 @@
|
|
|
35
37
|
#endif
|
|
36
38
|
|
|
37
39
|
#include <BatchingMessageQueueThread.h>
|
|
40
|
+
#include <CppRuntimeOptions.h>
|
|
38
41
|
#include <CreateModules.h>
|
|
39
42
|
#include <DevSettings.h>
|
|
40
43
|
#include <DevSupportManager.h>
|
|
41
44
|
#include <IReactRootView.h>
|
|
42
|
-
#include <RuntimeOptions.h>
|
|
43
45
|
#include <Shlwapi.h>
|
|
44
46
|
#include <WebSocketJSExecutorFactory.h>
|
|
45
47
|
#include <safeint.h>
|
|
@@ -145,6 +147,20 @@ using namespace facebook;
|
|
|
145
147
|
using namespace Microsoft::JSI;
|
|
146
148
|
|
|
147
149
|
using std::make_shared;
|
|
150
|
+
using winrt::Microsoft::ReactNative::ReactPropertyBagHelper;
|
|
151
|
+
|
|
152
|
+
namespace Microsoft::React {
|
|
153
|
+
|
|
154
|
+
/*extern*/ std::unique_ptr<facebook::xplat::module::CxxModule> CreateHttpModule(
|
|
155
|
+
winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept {
|
|
156
|
+
if (GetRuntimeOptionBool("Http.UseMonolithicModule")) {
|
|
157
|
+
return std::make_unique<NetworkingModule>();
|
|
158
|
+
} else {
|
|
159
|
+
return std::make_unique<HttpModule>(inspectableProperties);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
} // namespace Microsoft::React
|
|
148
164
|
|
|
149
165
|
namespace facebook {
|
|
150
166
|
namespace react {
|
|
@@ -610,12 +626,21 @@ InstanceImpl::~InstanceImpl() {
|
|
|
610
626
|
std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules(
|
|
611
627
|
std::shared_ptr<MessageQueueThread> nativeQueue) {
|
|
612
628
|
std::vector<std::unique_ptr<NativeModule>> modules;
|
|
629
|
+
auto transitionalProps{ReactPropertyBagHelper::CreatePropertyBag()};
|
|
613
630
|
|
|
614
631
|
modules.push_back(std::make_unique<CxxNativeModule>(
|
|
615
632
|
m_innerInstance,
|
|
616
|
-
|
|
617
|
-
[nativeQueue]() -> std::unique_ptr<xplat::module::CxxModule> {
|
|
618
|
-
return Microsoft::React::
|
|
633
|
+
Microsoft::React::GetHttpModuleName(),
|
|
634
|
+
[nativeQueue, transitionalProps]() -> std::unique_ptr<xplat::module::CxxModule> {
|
|
635
|
+
return Microsoft::React::CreateHttpModule(transitionalProps);
|
|
636
|
+
},
|
|
637
|
+
nativeQueue));
|
|
638
|
+
|
|
639
|
+
modules.push_back(std::make_unique<CxxNativeModule>(
|
|
640
|
+
m_innerInstance,
|
|
641
|
+
Microsoft::React::GetWebSocketModuleName(),
|
|
642
|
+
[nativeQueue, transitionalProps]() -> std::unique_ptr<xplat::module::CxxModule> {
|
|
643
|
+
return Microsoft::React::CreateWebSocketModule(transitionalProps);
|
|
619
644
|
},
|
|
620
645
|
nativeQueue));
|
|
621
646
|
|
|
@@ -677,6 +702,18 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
|
|
|
677
702
|
[]() { return std::make_unique<StatusBarManagerModule>(); },
|
|
678
703
|
nativeQueue));
|
|
679
704
|
|
|
705
|
+
modules.push_back(std::make_unique<CxxNativeModule>(
|
|
706
|
+
m_innerInstance,
|
|
707
|
+
Microsoft::React::GetBlobModuleName(),
|
|
708
|
+
[transitionalProps]() { return Microsoft::React::CreateBlobModule(transitionalProps); },
|
|
709
|
+
nativeQueue));
|
|
710
|
+
|
|
711
|
+
modules.push_back(std::make_unique<CxxNativeModule>(
|
|
712
|
+
m_innerInstance,
|
|
713
|
+
Microsoft::React::GetFileReaderModuleName(),
|
|
714
|
+
[transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); },
|
|
715
|
+
nativeQueue));
|
|
716
|
+
|
|
680
717
|
return modules;
|
|
681
718
|
}
|
|
682
719
|
|
package/Shared/OInstance.h
CHANGED
|
@@ -5,14 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
#pragma once
|
|
7
7
|
|
|
8
|
+
#include <ReactPropertyBag.h>
|
|
9
|
+
#include <TurboModuleManager.h>
|
|
10
|
+
#include "InstanceManager.h"
|
|
11
|
+
|
|
12
|
+
// React Native
|
|
13
|
+
#include <cxxreact/Instance.h>
|
|
14
|
+
|
|
15
|
+
// Standard Libriary
|
|
8
16
|
#include <memory>
|
|
9
17
|
#include <string>
|
|
10
18
|
#include <vector>
|
|
11
19
|
|
|
12
|
-
#include <TurboModuleManager.h>
|
|
13
|
-
#include <cxxreact/Instance.h>
|
|
14
|
-
#include "InstanceManager.h"
|
|
15
|
-
|
|
16
20
|
namespace facebook {
|
|
17
21
|
namespace react {
|
|
18
22
|
|
|
@@ -1,45 +1,126 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include <CppRuntimeOptions.h>
|
|
1
5
|
#include <RuntimeOptions.h>
|
|
2
6
|
|
|
7
|
+
// Standard Library
|
|
3
8
|
#include <mutex>
|
|
4
9
|
#include <unordered_map>
|
|
5
10
|
|
|
6
|
-
using std::lock_guard;
|
|
7
11
|
using std::mutex;
|
|
12
|
+
using std::scoped_lock;
|
|
8
13
|
using std::string;
|
|
9
14
|
|
|
10
15
|
namespace {
|
|
11
|
-
std::unordered_map<string, int32_t>
|
|
16
|
+
std::unordered_map<string, int32_t> g_runtimeOptionInts;
|
|
17
|
+
std::unordered_map<string, string> g_runtimeOptionStrings;
|
|
12
18
|
mutex g_runtimeOptionsMutex;
|
|
19
|
+
|
|
20
|
+
void __cdecl GetStringCallback(const char *buffer, size_t length, void *state) {
|
|
21
|
+
if (!buffer)
|
|
22
|
+
return;
|
|
23
|
+
|
|
24
|
+
*static_cast<char **>(state) = static_cast<char *>(malloc(length));
|
|
25
|
+
strncpy_s(*static_cast<char **>(state), length, buffer, length);
|
|
26
|
+
}
|
|
13
27
|
} // namespace
|
|
14
28
|
|
|
15
29
|
namespace Microsoft::React {
|
|
16
30
|
|
|
17
31
|
void __cdecl SetRuntimeOptionBool(string &&name, bool value) noexcept {
|
|
18
|
-
|
|
19
|
-
g_runtimeOptions.insert_or_assign(std::move(name), value ? 1 : 0);
|
|
32
|
+
MicrosoftReactSetRuntimeOptionBool(name.c_str(), value);
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
void __cdecl SetRuntimeOptionInt(string &&name, int32_t value) noexcept {
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
MicrosoftReactSetRuntimeOptionInt(name.c_str(), value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void __cdecl SetRuntimeOptionString(string &&name, string &&value) noexcept {
|
|
40
|
+
if (!value.empty())
|
|
41
|
+
MicrosoftReactSetRuntimeOptionString(std::move(name).c_str(), std::move(value).c_str());
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
const bool __cdecl GetRuntimeOptionBool(const string &name) noexcept {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
return MicrosoftReactGetRuntimeOptionBool(name.c_str());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const int32_t __cdecl GetRuntimeOptionInt(const string &name) noexcept {
|
|
49
|
+
return MicrosoftReactGetRuntimeOptionInt(name.c_str());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const string __cdecl GetRuntimeOptionString(const string &name) noexcept {
|
|
53
|
+
char *payload{nullptr};
|
|
54
|
+
MicrosoftReactGetRuntimeOptionString(name.c_str(), GetStringCallback, &payload);
|
|
55
|
+
|
|
56
|
+
if (!payload)
|
|
57
|
+
return string{};
|
|
58
|
+
|
|
59
|
+
return string{std::move(payload)};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
} // namespace Microsoft::React
|
|
63
|
+
|
|
64
|
+
void __cdecl MicrosoftReactSetRuntimeOptionBool(const char *name, bool value) noexcept {
|
|
65
|
+
if (!name)
|
|
66
|
+
return;
|
|
67
|
+
|
|
68
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
69
|
+
if (value)
|
|
70
|
+
g_runtimeOptionInts.insert_or_assign(name, 1);
|
|
71
|
+
else
|
|
72
|
+
g_runtimeOptionInts.erase(name);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void __cdecl MicrosoftReactSetRuntimeOptionInt(const char *name, int32_t value) noexcept {
|
|
76
|
+
if (!name)
|
|
77
|
+
return;
|
|
78
|
+
|
|
79
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
80
|
+
if (value)
|
|
81
|
+
g_runtimeOptionInts.insert_or_assign(name, value);
|
|
82
|
+
else
|
|
83
|
+
g_runtimeOptionInts.erase(name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void __cdecl MicrosoftReactSetRuntimeOptionString(const char *name, const char *value) noexcept {
|
|
87
|
+
if (!name)
|
|
88
|
+
return;
|
|
89
|
+
|
|
90
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
91
|
+
if (value)
|
|
92
|
+
g_runtimeOptionStrings.insert_or_assign(name, value);
|
|
93
|
+
else
|
|
94
|
+
g_runtimeOptionStrings.erase(name);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept {
|
|
98
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
99
|
+
auto itr = g_runtimeOptionInts.find(name);
|
|
100
|
+
if (itr != g_runtimeOptionInts.end())
|
|
101
|
+
return itr->second != 0;
|
|
32
102
|
|
|
33
103
|
return false;
|
|
34
104
|
}
|
|
35
105
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
auto itr =
|
|
39
|
-
if (itr !=
|
|
106
|
+
int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept {
|
|
107
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
108
|
+
auto itr = g_runtimeOptionInts.find(name);
|
|
109
|
+
if (itr != g_runtimeOptionInts.end())
|
|
40
110
|
return itr->second;
|
|
41
111
|
|
|
42
112
|
return 0;
|
|
43
113
|
}
|
|
44
114
|
|
|
45
|
-
|
|
115
|
+
void __cdecl MicrosoftReactGetRuntimeOptionString(
|
|
116
|
+
const char *name,
|
|
117
|
+
MicrosoftReactGetStringCallback callBack,
|
|
118
|
+
void *state) {
|
|
119
|
+
scoped_lock lock{g_runtimeOptionsMutex};
|
|
120
|
+
auto itr = g_runtimeOptionStrings.find(name);
|
|
121
|
+
if (itr != g_runtimeOptionStrings.cend()) {
|
|
122
|
+
callBack(itr->second.c_str(), itr->second.size() * sizeof(char) + 1 /*NULL termination*/, state);
|
|
123
|
+
} else {
|
|
124
|
+
callBack(nullptr, 0, state);
|
|
125
|
+
}
|
|
126
|
+
}
|
package/Shared/RuntimeOptions.h
CHANGED
|
@@ -3,34 +3,58 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
9
|
|
|
10
10
|
/// <summary>
|
|
11
11
|
/// Sets a global boolean value identified by an arbitrary string.
|
|
12
12
|
/// </summary>
|
|
13
13
|
/// <param name="name">Global key</param>
|
|
14
|
-
void __cdecl
|
|
14
|
+
void __cdecl MicrosoftReactSetRuntimeOptionBool(const char *name, bool value) noexcept;
|
|
15
15
|
|
|
16
16
|
/// <summary>
|
|
17
17
|
/// Sets a global signed integer value identified by an arbitrary string.
|
|
18
18
|
/// </summary>
|
|
19
19
|
/// <param name="name">Global boolean key</param>
|
|
20
|
-
void __cdecl
|
|
20
|
+
void __cdecl MicrosoftReactSetRuntimeOptionInt(const char *name, int32_t value) noexcept;
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Sets a global signed integer value identified by an arbitrary string.
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <param name="name">Global string key</param>
|
|
26
|
+
void __cdecl MicrosoftReactSetRuntimeOptionString(const char *name, const char *value) noexcept;
|
|
21
27
|
|
|
22
28
|
/// <summary>
|
|
23
29
|
/// Retrieves a global boolean value for the given key.
|
|
24
30
|
/// </summary>
|
|
25
31
|
/// <param name="name">Global boolean key</param>
|
|
26
32
|
/// <returns>Value stored for the given key, or false if the entry doesn't exist (default)</returns>
|
|
27
|
-
|
|
33
|
+
bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept;
|
|
28
34
|
|
|
29
35
|
/// <summary>
|
|
30
36
|
/// Retrieves a global boolean value for the given key.
|
|
31
37
|
/// </summary>
|
|
32
38
|
/// <param name="name">Global key</param>
|
|
33
39
|
/// <returns>Value stored for the given key, or 0 if the entry doesn't exist (default)</returns>
|
|
34
|
-
|
|
40
|
+
int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept;
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
/// <param name="buffer">String contents. nullptr if none found</param>
|
|
43
|
+
/// <param name="length">String length. 0 if none found</param>
|
|
44
|
+
/// <param name="state">Pointer used to pass or retrieve arbitrary data</param>
|
|
45
|
+
typedef void(__cdecl *MicrosoftReactGetStringCallback)(const char *buffer, size_t length, void *state);
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Retrieves a global string value for the given key.
|
|
49
|
+
/// </summary>
|
|
50
|
+
/// <param name="name">Global key</param>
|
|
51
|
+
/// <param name="callBack">Handler used to access the obtained string</param>
|
|
52
|
+
/// <param name="state">Arbitrary data to pass on to or retrieve from callBack</param>
|
|
53
|
+
void __cdecl MicrosoftReactGetRuntimeOptionString(
|
|
54
|
+
const char *name,
|
|
55
|
+
MicrosoftReactGetStringCallback callBack,
|
|
56
|
+
void *state);
|
|
57
|
+
|
|
58
|
+
#ifdef __cplusplus
|
|
59
|
+
}
|
|
60
|
+
#endif
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -45,13 +45,20 @@
|
|
|
45
45
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\AsyncStorageModuleWin32.cpp">
|
|
46
46
|
<ExcludedFromBuild Condition="'$(ApplicationType)' == ''">true</ExcludedFromBuild>
|
|
47
47
|
</ClCompile>
|
|
48
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\BlobModule.cpp" />
|
|
49
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\CxxModuleUtilities.cpp" />
|
|
48
50
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\ExceptionsManagerModule.cpp" />
|
|
51
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\FileReaderModule.cpp" />
|
|
52
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\HttpModule.cpp" />
|
|
49
53
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\I18nModule.cpp" />
|
|
50
54
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\NetworkingModule.cpp" />
|
|
51
55
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\PlatformConstantsModule.cpp" />
|
|
52
56
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\SourceCodeModule.cpp" />
|
|
53
57
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\StatusBarManagerModule.cpp" />
|
|
54
58
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\WebSocketModule.cpp" />
|
|
59
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Networking\OriginPolicyHttpFilter.cpp" />
|
|
60
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Networking\WinRTHttpResource.cpp" />
|
|
61
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Networking\WinRTWebSocketResource.cpp" />
|
|
55
62
|
<ClCompile Include="$(MSBuildThisFileDirectory)OInstance.cpp" />
|
|
56
63
|
<ClCompile Include="$(MSBuildThisFileDirectory)PackagerConnection.cpp" />
|
|
57
64
|
<ClCompile Include="$(MSBuildThisFileDirectory)RuntimeOptions.cpp" />
|
|
@@ -61,10 +68,10 @@
|
|
|
61
68
|
<ClCompile Include="$(MSBuildThisFileDirectory)tracing\tracing.cpp" />
|
|
62
69
|
<ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleManager.cpp" />
|
|
63
70
|
<ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp" />
|
|
71
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.cpp" />
|
|
64
72
|
<ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
|
|
65
73
|
<ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
|
|
66
74
|
</ClCompile>
|
|
67
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)WinRTWebSocketResource.cpp" />
|
|
68
75
|
</ItemGroup>
|
|
69
76
|
<ItemGroup>
|
|
70
77
|
<ClInclude Include="$(MSBuildThisFileDirectory)..\include\Shared\cdebug.h" />
|
|
@@ -73,6 +80,7 @@
|
|
|
73
80
|
<ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\AsyncStorageManager.h" />
|
|
74
81
|
<ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\FollyDynamicConverter.h" />
|
|
75
82
|
<ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\KeyValueStorage.h" />
|
|
83
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)CppRuntimeOptions.h" />
|
|
76
84
|
<ClInclude Include="$(MSBuildThisFileDirectory)HermesSamplingProfiler.h" />
|
|
77
85
|
<ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h" />
|
|
78
86
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\ByteArrayBuffer.h" />
|
|
@@ -83,7 +91,25 @@
|
|
|
83
91
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\NapiJsiV8RuntimeHolder.h" />
|
|
84
92
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\RuntimeHolder.h" />
|
|
85
93
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\ScriptStore.h" />
|
|
94
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h" />
|
|
95
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\CxxModuleUtilities.h" />
|
|
96
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\FileReaderModule.h" />
|
|
97
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IBlobPersistor.h" />
|
|
98
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IHttpModuleProxy.h" />
|
|
99
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IRequestBodyHandler.h" />
|
|
100
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IResponseHandler.h" />
|
|
101
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IUriHandler.h" />
|
|
102
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleContentHandler.h" />
|
|
103
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleProxy.h" />
|
|
104
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h" />
|
|
86
105
|
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\NetworkingModule.h" />
|
|
106
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\IHttpResource.h" />
|
|
107
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\IWebSocketResource.h" />
|
|
108
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\OriginPolicy.h" />
|
|
109
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\OriginPolicyHttpFilter.h" />
|
|
110
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTHttpResource.h" />
|
|
111
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTTypes.h" />
|
|
112
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTWebSocketResource.h" />
|
|
87
113
|
<ClInclude Include="$(MSBuildThisFileDirectory)RuntimeOptions.h" />
|
|
88
114
|
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\AsyncStorageModuleWin32.h" />
|
|
89
115
|
<ClInclude Include="$(MSBuildThisFileDirectory)AsyncStorage\StorageFileIO.h" />
|
|
@@ -98,12 +124,9 @@
|
|
|
98
124
|
<ClInclude Include="$(MSBuildThisFileDirectory)HermesRuntimeHolder.h" />
|
|
99
125
|
<ClInclude Include="$(MSBuildThisFileDirectory)InspectorPackagerConnection.h" />
|
|
100
126
|
<ClInclude Include="$(MSBuildThisFileDirectory)IDevSupportManager.h" />
|
|
101
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)IHttpResource.h" />
|
|
102
127
|
<ClInclude Include="$(MSBuildThisFileDirectory)InstanceManager.h" />
|
|
103
128
|
<ClInclude Include="$(MSBuildThisFileDirectory)IReactRootView.h" />
|
|
104
129
|
<ClInclude Include="$(MSBuildThisFileDirectory)IRedBoxHandler.h" />
|
|
105
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)IUIManager.h" />
|
|
106
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)IWebSocketResource.h" />
|
|
107
130
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSBigAbiString.h" />
|
|
108
131
|
<ClInclude Include="$(MSBuildThisFileDirectory)LayoutAnimation.h" />
|
|
109
132
|
<ClInclude Include="$(MSBuildThisFileDirectory)Logging.h" />
|
|
@@ -130,9 +153,9 @@
|
|
|
130
153
|
<ClInclude Include="$(MSBuildThisFileDirectory)TurboModuleRegistry.h" />
|
|
131
154
|
<ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
|
|
132
155
|
<ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
|
|
156
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
|
|
133
157
|
<ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
|
|
134
158
|
<ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
|
|
135
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)WinRTWebSocketResource.h" />
|
|
136
159
|
</ItemGroup>
|
|
137
160
|
<ItemGroup>
|
|
138
161
|
<None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp" />
|