react-native-windows 0.71.41 → 0.71.43
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/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Modules/BlobCollector.cpp +21 -0
- package/Shared/Modules/BlobCollector.h +23 -0
- package/Shared/Modules/BlobModule.cpp +19 -0
- package/Shared/Modules/WebSocketModule.cpp +37 -8
- package/Shared/Modules/WebSocketTurboModule.h +19 -0
- package/Shared/Shared.vcxitems +2 -0
- package/Shared/Shared.vcxitems.filters +6 -0
- package/package.json +1 -1
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.71.
|
|
13
|
+
<ReactNativeWindowsVersion>0.71.43</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>71</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>43</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>ce7c2173ac7e384b20fc619e653484e621d742e5</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "BlobCollector.h"
|
|
5
|
+
|
|
6
|
+
using std::string;
|
|
7
|
+
|
|
8
|
+
namespace Microsoft::React {
|
|
9
|
+
|
|
10
|
+
using Networking::IBlobResource;
|
|
11
|
+
|
|
12
|
+
BlobCollector::BlobCollector(string blobId, std::shared_ptr<IBlobResource> resource) noexcept
|
|
13
|
+
: m_blobId{blobId}, m_weakResource{std::weak_ptr<IBlobResource>(resource)} {}
|
|
14
|
+
|
|
15
|
+
BlobCollector::~BlobCollector() noexcept {
|
|
16
|
+
if (auto rc = m_weakResource.lock()) {
|
|
17
|
+
rc->Release(std::move(m_blobId));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace Microsoft::React
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include <Networking/IBlobResource.h>
|
|
7
|
+
|
|
8
|
+
// JSI
|
|
9
|
+
#include <jsi/jsi.h>
|
|
10
|
+
|
|
11
|
+
namespace Microsoft::React {
|
|
12
|
+
|
|
13
|
+
class JSI_EXPORT BlobCollector : public facebook::jsi::HostObject {
|
|
14
|
+
std::string m_blobId;
|
|
15
|
+
std::weak_ptr<Networking::IBlobResource> m_weakResource;
|
|
16
|
+
|
|
17
|
+
public:
|
|
18
|
+
BlobCollector(std::string blobId, std::shared_ptr<Networking::IBlobResource> resource) noexcept;
|
|
19
|
+
|
|
20
|
+
~BlobCollector() noexcept;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace Microsoft::React
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
#include "BlobModule.h"
|
|
5
5
|
|
|
6
6
|
#include <CreateModules.h>
|
|
7
|
+
#include <JSI/JsiApiContext.h>
|
|
7
8
|
#include <Modules/CxxModuleUtilities.h>
|
|
9
|
+
#include "BlobCollector.h"
|
|
8
10
|
|
|
9
11
|
// React Native
|
|
10
12
|
#include <cxxreact/JsArgumentHelpers.h>
|
|
@@ -38,6 +40,23 @@ void BlobTurboModule::Initialize(msrn::ReactContext const &reactContext) noexcep
|
|
|
38
40
|
m_resource->Callbacks().OnError = [&reactContext](string &&errorText) {
|
|
39
41
|
Modules::SendEvent(reactContext, L"blobFailed", {errorText});
|
|
40
42
|
};
|
|
43
|
+
|
|
44
|
+
namespace jsi = facebook::jsi;
|
|
45
|
+
msrn::ExecuteJsi(reactContext, [resource = m_resource](jsi::Runtime &runtime) {
|
|
46
|
+
runtime.global().setProperty(
|
|
47
|
+
runtime,
|
|
48
|
+
"__blobCollectorProvider",
|
|
49
|
+
jsi::Function::createFromHostFunction(
|
|
50
|
+
runtime,
|
|
51
|
+
jsi::PropNameID::forAscii(runtime, "__blobCollectorProvider"),
|
|
52
|
+
1,
|
|
53
|
+
[resource](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
|
|
54
|
+
auto blobId = args[0].asString(rt).utf8(rt);
|
|
55
|
+
auto collector = std::make_shared<BlobCollector>(blobId, resource);
|
|
56
|
+
|
|
57
|
+
return jsi::Object::createFromHostObject(rt, collector);
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
ReactNativeSpecs::BlobModuleSpec_Constants BlobTurboModule::GetConstants() noexcept {
|
|
@@ -52,6 +52,9 @@ using Microsoft::React::Networking::IWebSocketResource;
|
|
|
52
52
|
|
|
53
53
|
constexpr char s_moduleName[] = "WebSocketModule";
|
|
54
54
|
constexpr wchar_t s_moduleNameW[] = L"WebSocketModule";
|
|
55
|
+
constexpr wchar_t s_proxyNameW[] = L"WebSocketModule.Proxy";
|
|
56
|
+
constexpr wchar_t s_sharedStateNameW[] = L"WebSocketModule.SharedState";
|
|
57
|
+
constexpr wchar_t s_contentHandlerNameW[] = L"BlobModule.ContentHandler";
|
|
55
58
|
|
|
56
59
|
msrn::ReactModuleProvider s_moduleProvider = msrn::MakeTurboModuleProvider<Microsoft::React::WebSocketTurboModule>();
|
|
57
60
|
|
|
@@ -119,7 +122,7 @@ GetOrCreateWebSocket(int64_t id, string &&url, weak_ptr<WebSocketModule::SharedS
|
|
|
119
122
|
auto args = msrn::JSValueObject{{"id", id}, {"type", isBinary ? "binary" : "text"}};
|
|
120
123
|
shared_ptr<Microsoft::React::IWebSocketModuleContentHandler> contentHandler;
|
|
121
124
|
auto propId = ReactPropertyId<ReactNonAbiValue<weak_ptr<Microsoft::React::IWebSocketModuleContentHandler>>>{
|
|
122
|
-
|
|
125
|
+
s_contentHandlerNameW};
|
|
123
126
|
if (auto prop = propBag.Get(propId))
|
|
124
127
|
contentHandler = prop.Value().lock();
|
|
125
128
|
|
|
@@ -171,11 +174,11 @@ WebSocketModule::WebSocketModule(winrt::Windows::Foundation::IInspectable const
|
|
|
171
174
|
|
|
172
175
|
auto propBag = ReactPropertyBag{m_sharedState->InspectableProps.try_as<IReactPropertyBag>()};
|
|
173
176
|
|
|
174
|
-
auto proxyPropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<IWebSocketModuleProxy>>>{
|
|
177
|
+
auto proxyPropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<IWebSocketModuleProxy>>>{s_proxyNameW};
|
|
175
178
|
auto proxy = weak_ptr<IWebSocketModuleProxy>{m_proxy};
|
|
176
179
|
propBag.Set(proxyPropId, std::move(proxy));
|
|
177
180
|
|
|
178
|
-
auto statePropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<SharedState>>>{
|
|
181
|
+
auto statePropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<SharedState>>>{s_sharedStateNameW};
|
|
179
182
|
auto state = weak_ptr<SharedState>{m_sharedState};
|
|
180
183
|
propBag.Set(statePropId, std::move(state));
|
|
181
184
|
}
|
|
@@ -309,10 +312,9 @@ vector<facebook::xplat::module::CxxModule::Method> WebSocketModule::getMethods()
|
|
|
309
312
|
WebSocketModuleProxy::WebSocketModuleProxy(IInspectable const &inspectableProperties) noexcept
|
|
310
313
|
: m_inspectableProps{inspectableProperties} {}
|
|
311
314
|
|
|
312
|
-
void WebSocketModuleProxy::SendBinary(
|
|
315
|
+
void WebSocketModuleProxy::SendBinary(string &&base64String, int64_t id) noexcept /*override*/ {
|
|
313
316
|
auto propBag = ReactPropertyBag{m_inspectableProps.try_as<IReactPropertyBag>()};
|
|
314
|
-
auto sharedPropId =
|
|
315
|
-
ReactPropertyId<ReactNonAbiValue<weak_ptr<WebSocketModule::SharedState>>>{L"WebSocketModule.SharedState"};
|
|
317
|
+
auto sharedPropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<WebSocketModule::SharedState>>>{s_sharedStateNameW};
|
|
316
318
|
auto state = propBag.Get(sharedPropId).Value();
|
|
317
319
|
|
|
318
320
|
weak_ptr weakWs = GetOrCreateWebSocket(id, {}, std::move(state));
|
|
@@ -353,8 +355,7 @@ shared_ptr<IWebSocketResource> WebSocketTurboModule::CreateResource(int64_t id,
|
|
|
353
355
|
rc->SetOnMessage([id, context = m_context](size_t length, const string &message, bool isBinary) {
|
|
354
356
|
auto args = msrn::JSValueObject{{"id", id}, {"type", isBinary ? "binary" : "text"}};
|
|
355
357
|
shared_ptr<IWebSocketModuleContentHandler> contentHandler;
|
|
356
|
-
auto propId =
|
|
357
|
-
ReactPropertyId<ReactNonAbiValue<weak_ptr<IWebSocketModuleContentHandler>>>{L"BlobModule.ContentHandler"};
|
|
358
|
+
auto propId = ReactPropertyId<ReactNonAbiValue<weak_ptr<IWebSocketModuleContentHandler>>>{s_contentHandlerNameW};
|
|
358
359
|
auto propBag = context.Properties();
|
|
359
360
|
if (auto prop = propBag.Get(propId))
|
|
360
361
|
contentHandler = prop.Value().lock();
|
|
@@ -396,6 +397,11 @@ shared_ptr<IWebSocketResource> WebSocketTurboModule::CreateResource(int64_t id,
|
|
|
396
397
|
|
|
397
398
|
void WebSocketTurboModule::Initialize(msrn::ReactContext const &reactContext) noexcept {
|
|
398
399
|
m_context = reactContext.Handle();
|
|
400
|
+
m_proxy = std::make_shared<WebSocketTurboModuleProxy>(m_resourceMap);
|
|
401
|
+
|
|
402
|
+
auto proxyPropId = ReactPropertyId<ReactNonAbiValue<weak_ptr<IWebSocketModuleProxy>>>{s_proxyNameW};
|
|
403
|
+
auto proxy = weak_ptr<IWebSocketModuleProxy>{m_proxy};
|
|
404
|
+
m_context.Properties().Set(proxyPropId, std::move(proxy));
|
|
399
405
|
}
|
|
400
406
|
|
|
401
407
|
void WebSocketTurboModule::Connect(
|
|
@@ -487,6 +493,29 @@ void WebSocketTurboModule::RemoveListeners(double /*count*/) noexcept {}
|
|
|
487
493
|
|
|
488
494
|
#pragma endregion WebSocketTurboModule
|
|
489
495
|
|
|
496
|
+
#pragma region WebSocketTurboModuleProxy
|
|
497
|
+
|
|
498
|
+
WebSocketTurboModuleProxy::WebSocketTurboModuleProxy(
|
|
499
|
+
std::unordered_map<double, shared_ptr<IWebSocketResource>> &resourceMap) noexcept
|
|
500
|
+
: m_resourceMap{resourceMap} {}
|
|
501
|
+
|
|
502
|
+
#pragma endregion WebSocketTurboModuleProxy
|
|
503
|
+
|
|
504
|
+
void WebSocketTurboModuleProxy::SendBinary(string &&base64String, int64_t id) noexcept /*override*/
|
|
505
|
+
{
|
|
506
|
+
auto rcItr = m_resourceMap.find(static_cast<double>(id));
|
|
507
|
+
if (rcItr == m_resourceMap.cend()) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
weak_ptr<IWebSocketResource> weakRc = (*rcItr).second;
|
|
512
|
+
if (auto rc = weakRc.lock()) {
|
|
513
|
+
rc->SendBinary(std::move(base64String));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
#pragma region WebSocketTurboModule
|
|
518
|
+
|
|
490
519
|
/*extern*/ const char *GetWebSocketModuleName() noexcept {
|
|
491
520
|
return s_moduleName;
|
|
492
521
|
}
|
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
namespace Microsoft::React {
|
|
12
12
|
|
|
13
|
+
class WebSocketTurboModuleProxy final : public IWebSocketModuleProxy {
|
|
14
|
+
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> &m_resourceMap;
|
|
15
|
+
|
|
16
|
+
public:
|
|
17
|
+
WebSocketTurboModuleProxy(
|
|
18
|
+
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> &resourceMap) noexcept;
|
|
19
|
+
|
|
20
|
+
#pragma region IWebSocketModuleProxy
|
|
21
|
+
|
|
22
|
+
void SendBinary(std::string &&base64String, int64_t id) noexcept override;
|
|
23
|
+
|
|
24
|
+
#pragma endregion
|
|
25
|
+
};
|
|
26
|
+
|
|
13
27
|
REACT_MODULE(WebSocketTurboModule, L"WebSocketModule")
|
|
14
28
|
struct WebSocketTurboModule {
|
|
15
29
|
using ModuleSpec = ReactNativeSpecs::WebSocketModuleSpec;
|
|
@@ -47,6 +61,11 @@ struct WebSocketTurboModule {
|
|
|
47
61
|
|
|
48
62
|
winrt::Microsoft::ReactNative::ReactContext m_context;
|
|
49
63
|
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> m_resourceMap;
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// Exposes a subset of the module's methods.
|
|
67
|
+
/// </summary>
|
|
68
|
+
std::shared_ptr<IWebSocketModuleProxy> m_proxy;
|
|
50
69
|
};
|
|
51
70
|
|
|
52
71
|
} // namespace Microsoft::React
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\AsyncStorageModuleWin32.cpp">
|
|
46
46
|
<ExcludedFromBuild Condition="'$(ApplicationType)' == ''">true</ExcludedFromBuild>
|
|
47
47
|
</ClCompile>
|
|
48
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\BlobCollector.cpp" />
|
|
48
49
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\BlobModule.cpp" />
|
|
49
50
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\CxxModuleUtilities.cpp" />
|
|
50
51
|
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\ExceptionsManagerModule.cpp" />
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
|
|
100
101
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\RuntimeHolder.h" />
|
|
101
102
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\ScriptStore.h" />
|
|
103
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobCollector.h" />
|
|
102
104
|
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h" />
|
|
103
105
|
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\CxxModuleUtilities.h" />
|
|
104
106
|
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\FileReaderModule.h" />
|
|
@@ -158,6 +158,9 @@
|
|
|
158
158
|
<ClCompile Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.cpp" />
|
|
159
159
|
<ClCompile Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.cpp" />
|
|
160
160
|
<ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp" />
|
|
161
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)Modules\BlobCollector.cpp">
|
|
162
|
+
<Filter>Source Files\Modules</Filter>
|
|
163
|
+
</ClCompile>
|
|
161
164
|
</ItemGroup>
|
|
162
165
|
<ItemGroup>
|
|
163
166
|
<Filter Include="Source Files">
|
|
@@ -487,6 +490,9 @@
|
|
|
487
490
|
<ClInclude Include="$(MSBuildThisFileDirectory)JSI\V8RuntimeHolder.h" />
|
|
488
491
|
<ClInclude Include="$(MSBuildThisFileDirectory)SafeLoadLibrary.h" />
|
|
489
492
|
<ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
|
|
493
|
+
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobCollector.h">
|
|
494
|
+
<Filter>Header Files\Modules</Filter>
|
|
495
|
+
</ClInclude>
|
|
490
496
|
</ItemGroup>
|
|
491
497
|
<ItemGroup>
|
|
492
498
|
<None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">
|