react-native-windows 0.68.16 → 0.68.17

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.
@@ -19,8 +19,12 @@
19
19
 
20
20
  namespace Microsoft::ReactNative {
21
21
 
22
+ using winrt::Microsoft::ReactNative::ReactPropertyBag;
23
+
22
24
  namespace {
23
25
 
26
+ using winrt::Microsoft::ReactNative::ReactPropertyId;
27
+
24
28
  bool HasPackageIdentity() noexcept {
25
29
  static const bool hasPackageIdentity = []() noexcept {
26
30
  auto packageStatics = winrt::get_activation_factory<winrt::Windows::ApplicationModel::IPackageStatics>(
@@ -35,6 +39,13 @@ bool HasPackageIdentity() noexcept {
35
39
  return hasPackageIdentity;
36
40
  }
37
41
 
42
+ ReactPropertyId<bool> HttpUseMonolithicModuleProperty() noexcept {
43
+ static ReactPropertyId<bool> propId{
44
+ L"ReactNative.Http"
45
+ L"UseMonolithicModule"};
46
+ return propId;
47
+ }
48
+
38
49
  } // namespace
39
50
 
40
51
  std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
@@ -50,11 +61,25 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
50
61
  [props = context->Properties()]() { return Microsoft::React::CreateHttpModule(props); },
51
62
  jsMessageQueue);
52
63
 
64
+ if (!ReactPropertyBag(context->Properties()).Get(HttpUseMonolithicModuleProperty())) {
65
+ modules.emplace_back(
66
+ Microsoft::React::GetBlobModuleName(),
67
+ [props = context->Properties()]() { return Microsoft::React::CreateBlobModule(props); },
68
+ batchingUIMessageQueue);
69
+
70
+ modules.emplace_back(
71
+ Microsoft::React::GetFileReaderModuleName(),
72
+ [props = context->Properties()]() { return Microsoft::React::CreateFileReaderModule(props); },
73
+ batchingUIMessageQueue);
74
+ }
75
+
53
76
  modules.emplace_back(
54
77
  "Timing",
55
78
  [batchingUIMessageQueue]() { return facebook::react::CreateTimingModule(batchingUIMessageQueue); },
56
79
  batchingUIMessageQueue);
57
80
 
81
+ // Note: `context` is moved to remove the reference from the current scope.
82
+ // This should either be the last usage of `context`, or the std::move call should happen later in this method.
58
83
  modules.emplace_back(
59
84
  NativeAnimatedModule::name,
60
85
  [context = std::move(context)]() mutable { return std::make_unique<NativeAnimatedModule>(std::move(context)); },
@@ -43,7 +43,6 @@
43
43
  #include <winrt/Windows.Storage.Streams.h>
44
44
  #include <winrt/Windows.UI.ViewManagement.Core.h>
45
45
  #include <winrt/Windows.UI.ViewManagement.h>
46
- #include <winrt/Windows.Web.Http.Filters.h>
47
46
  #include <winrt/Windows.Web.Http.Headers.h>
48
47
 
49
48
  #include "Base/CxxReactIncludes.h"
@@ -24,6 +24,11 @@
24
24
  "Microsoft.SourceLink.Common": "1.0.0"
25
25
  }
26
26
  },
27
+ "boost": {
28
+ "type": "Transitive",
29
+ "resolved": "1.76.0",
30
+ "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
31
+ },
27
32
  "Microsoft.Build.Tasks.Git": {
28
33
  "type": "Transitive",
29
34
  "resolved": "1.0.0",
@@ -60,14 +65,34 @@
60
65
  "resolved": "1.0.0",
61
66
  "contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
62
67
  },
68
+ "Microsoft.UI.Xaml": {
69
+ "type": "Transitive",
70
+ "resolved": "2.7.0",
71
+ "contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
72
+ },
73
+ "Microsoft.Windows.CppWinRT": {
74
+ "type": "Transitive",
75
+ "resolved": "2.0.211028.7",
76
+ "contentHash": "JBGI0c3WLoU6aYJRy9Qo0MLDQfObEp+d4nrhR95iyzf7+HOgjRunHDp/6eGFREd7xq3OI1mll9ecJrMfzBvlyg=="
77
+ },
78
+ "Microsoft.Windows.SDK.BuildTools": {
79
+ "type": "Transitive",
80
+ "resolved": "10.0.22000.194",
81
+ "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
82
+ },
63
83
  "NETStandard.Library": {
64
84
  "type": "Transitive",
65
85
  "resolved": "2.0.3",
66
- "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
86
+ "contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==",
67
87
  "dependencies": {
68
88
  "Microsoft.NETCore.Platforms": "1.1.0"
69
89
  }
70
90
  },
91
+ "ReactNative.Hermes.Windows": {
92
+ "type": "Transitive",
93
+ "resolved": "0.11.0-ms.6",
94
+ "contentHash": "WAVLsSZBV4p/3hNC3W67su7xu3f/ZMSKxu0ON7g2GaKRbkJmH0Qyif1IlzcJwtvR48kuOdfgPu7Bgtz3AY+gqg=="
95
+ },
71
96
  "runtime.win10-arm.Microsoft.Net.Native.Compiler": {
72
97
  "type": "Transitive",
73
98
  "resolved": "2.2.7-rel-27913-00",
@@ -135,8 +160,38 @@
135
160
  "resolved": "2.2.9",
136
161
  "contentHash": "qF6RRZKaflI+LR1YODNyWYjq5YoX8IJ2wx5y8O+AW2xO+1t/Q6Mm+jQ38zJbWnmXbrcOqUYofn7Y3/KC6lTLBQ=="
137
162
  },
138
- "microsoft.reactnative": {
163
+ "common": {
139
164
  "type": "Project"
165
+ },
166
+ "fmt": {
167
+ "type": "Project"
168
+ },
169
+ "folly": {
170
+ "type": "Project",
171
+ "dependencies": {
172
+ "boost": "1.76.0",
173
+ "fmt": "1.0.0"
174
+ }
175
+ },
176
+ "microsoft.reactnative": {
177
+ "type": "Project",
178
+ "dependencies": {
179
+ "Common": "1.0.0",
180
+ "Folly": "1.0.0",
181
+ "Microsoft.UI.Xaml": "2.7.0",
182
+ "Microsoft.Windows.CppWinRT": "2.0.211028.7",
183
+ "Microsoft.Windows.SDK.BuildTools": "10.0.22000.194",
184
+ "ReactCommon": "1.0.0",
185
+ "ReactNative.Hermes.Windows": "0.11.0-ms.6",
186
+ "boost": "1.76.0"
187
+ }
188
+ },
189
+ "reactcommon": {
190
+ "type": "Project",
191
+ "dependencies": {
192
+ "Folly": "1.0.0",
193
+ "boost": "1.76.0"
194
+ }
140
195
  }
141
196
  },
142
197
  "UAP,Version=v10.0.16299/win10-arm": {
@@ -10,10 +10,10 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.68.16</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.68.17</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>68</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>16</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>17</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
18
  </PropertyGroup>
19
19
  </Project>
@@ -139,7 +139,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
139
139
  auto size = blob[sizeKey].getInt();
140
140
  auto socketID = jsArgAsInt(args, 1);
141
141
 
142
- winrt::array_view<uint8_t> data;
142
+ winrt::array_view<uint8_t const> data;
143
143
  try {
144
144
  data = persistor->ResolveMessage(std::move(blobId), offset, size);
145
145
  } catch (const std::exception &e) {
@@ -169,7 +169,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
169
169
  auto type = part[typeKey].asString();
170
170
  if (blobKey == type) {
171
171
  auto blob = part[dataKey];
172
- winrt::array_view<uint8_t> bufferPart;
172
+ winrt::array_view<uint8_t const> bufferPart;
173
173
  try {
174
174
  bufferPart = persistor->ResolveMessage(
175
175
  blob[blobIdKey].asString(), blob[offsetKey].asInt(), blob[sizeKey].asInt());
@@ -216,7 +216,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
216
216
 
217
217
  #pragma region IBlobPersistor
218
218
 
219
- winrt::array_view<uint8_t> MemoryBlobPersistor::ResolveMessage(string &&blobId, int64_t offset, int64_t size) {
219
+ winrt::array_view<uint8_t const> MemoryBlobPersistor::ResolveMessage(string &&blobId, int64_t offset, int64_t size) {
220
220
  if (size < 1)
221
221
  return {};
222
222
 
@@ -233,7 +233,7 @@ winrt::array_view<uint8_t> MemoryBlobPersistor::ResolveMessage(string &&blobId,
233
233
  if (endBound > bytes.size() || offset >= static_cast<int64_t>(bytes.size()) || offset < 0)
234
234
  throw std::out_of_range("Offset or size out of range");
235
235
 
236
- return winrt::array_view<uint8_t>(bytes.data() + offset, bytes.data() + endBound);
236
+ return winrt::array_view<uint8_t const>(bytes.data() + offset, bytes.data() + endBound);
237
237
  }
238
238
 
239
239
  void MemoryBlobPersistor::RemoveMessage(string &&blobId) noexcept {
@@ -30,7 +30,7 @@ class MemoryBlobPersistor final : public IBlobPersistor {
30
30
  public:
31
31
  #pragma region IBlobPersistor
32
32
 
33
- winrt::array_view<uint8_t> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) override;
33
+ winrt::array_view<uint8_t const> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) override;
34
34
 
35
35
  void RemoveMessage(std::string &&blobId) noexcept override;
36
36
 
@@ -71,7 +71,7 @@ std::vector<module::CxxModule::Method> FileReaderModule::getMethods() {
71
71
  auto offset = blob["offset"].asInt();
72
72
  auto size = blob["size"].asInt();
73
73
 
74
- winrt::array_view<uint8_t> bytes;
74
+ winrt::array_view<uint8_t const> bytes;
75
75
  try {
76
76
  bytes = blobPersistor->ResolveMessage(std::move(blobId), offset, size);
77
77
  } catch (const std::exception &e) {
@@ -116,7 +116,7 @@ std::vector<module::CxxModule::Method> FileReaderModule::getMethods() {
116
116
  auto offset = blob["offset"].asInt();
117
117
  auto size = blob["size"].asInt();
118
118
 
119
- winrt::array_view<uint8_t> bytes;
119
+ winrt::array_view<uint8_t const> bytes;
120
120
  try {
121
121
  bytes = blobPersistor->ResolveMessage(std::move(blobId), offset, size);
122
122
  } catch (const std::exception &e) {
@@ -72,9 +72,11 @@ static void SetUpHttpResource(
72
72
  };
73
73
  resource->SetOnData(std::move(onDataDynamic));
74
74
 
75
- resource->SetOnError([weakReactInstance](int64_t requestId, string &&message) {
75
+ resource->SetOnError([weakReactInstance](int64_t requestId, string &&message, bool isTimeout) {
76
76
  dynamic args = dynamic::array(requestId, std::move(message));
77
- // TODO: isTimeout errorArgs.push_back(true);
77
+ if (isTimeout) {
78
+ args.push_back(true);
79
+ }
78
80
 
79
81
  SendEvent(weakReactInstance, completedResponse, std::move(args));
80
82
  });
@@ -106,90 +108,90 @@ std::map<string, dynamic> HttpModule::getConstants() {
106
108
  }
107
109
 
108
110
  // clang-format off
109
- std::vector<facebook::xplat::module::CxxModule::Method> HttpModule::getMethods() {
111
+ std::vector<facebook::xplat::module::CxxModule::Method> HttpModule::getMethods() {
110
112
 
111
- return
112
- {
113
+ return
113
114
  {
114
- "sendRequest",
115
- [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args, Callback cxxCallback)
116
115
  {
117
- auto holder = weakHolder.lock();
118
- if (!holder) {
119
- return;
120
- }
121
-
122
- auto resource = holder->Module->m_resource;
123
- if (!holder->Module->m_isResourceSetup)
116
+ "sendRequest",
117
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args, Callback cxxCallback)
124
118
  {
125
- SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
126
- holder->Module->m_isResourceSetup = true;
127
- }
119
+ auto holder = weakHolder.lock();
120
+ if (!holder) {
121
+ return;
122
+ }
128
123
 
129
- auto params = facebook::xplat::jsArgAsObject(args, 0);
130
- IHttpResource::Headers headers;
131
- for (auto& header : params["headers"].items()) {
132
- headers.emplace(header.first.getString(), header.second.getString());
133
- }
124
+ auto resource = holder->Module->m_resource;
125
+ if (!holder->Module->m_isResourceSetup)
126
+ {
127
+ SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
128
+ holder->Module->m_isResourceSetup = true;
129
+ }
134
130
 
135
- resource->SendRequest(
136
- params["method"].asString(),
137
- params["url"].asString(),
138
- params["requestId"].asInt(),
139
- std::move(headers),
140
- std::move(params["data"]),
141
- params["responseType"].asString(),
142
- params["incrementalUpdates"].asBool(),
143
- static_cast<int64_t>(params["timeout"].asDouble()),
144
- params["withCredentials"].asBool(),
145
- [cxxCallback = std::move(cxxCallback)](int64_t requestId) {
146
- cxxCallback({requestId});
131
+ auto params = facebook::xplat::jsArgAsObject(args, 0);
132
+ IHttpResource::Headers headers;
133
+ for (auto& header : params["headers"].items()) {
134
+ headers.emplace(header.first.getString(), header.second.getString());
147
135
  }
148
- );
149
- }
150
- },
151
- {
152
- "abortRequest",
153
- [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
136
+
137
+ resource->SendRequest(
138
+ params["method"].asString(),
139
+ params["url"].asString(),
140
+ params["requestId"].asInt(),
141
+ std::move(headers),
142
+ std::move(params["data"]),
143
+ params["responseType"].asString(),
144
+ params["incrementalUpdates"].asBool(),
145
+ static_cast<int64_t>(params["timeout"].asDouble()),
146
+ params["withCredentials"].asBool(),
147
+ [cxxCallback = std::move(cxxCallback)](int64_t requestId) {
148
+ cxxCallback({requestId});
149
+ }
150
+ );
151
+ }
152
+ },
154
153
  {
155
- auto holder = weakHolder.lock();
156
- if (!holder)
154
+ "abortRequest",
155
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
157
156
  {
158
- return;
159
- }
157
+ auto holder = weakHolder.lock();
158
+ if (!holder)
159
+ {
160
+ return;
161
+ }
160
162
 
161
- auto resource = holder->Module->m_resource;
162
- if (!holder->Module->m_isResourceSetup)
163
- {
164
- SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
165
- holder->Module->m_isResourceSetup = true;
166
- }
163
+ auto resource = holder->Module->m_resource;
164
+ if (!holder->Module->m_isResourceSetup)
165
+ {
166
+ SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
167
+ holder->Module->m_isResourceSetup = true;
168
+ }
167
169
 
168
- resource->AbortRequest(facebook::xplat::jsArgAsInt(args, 0));
169
- }
170
- },
171
- {
172
- "clearCookies",
173
- [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
170
+ resource->AbortRequest(facebook::xplat::jsArgAsInt(args, 0));
171
+ }
172
+ },
174
173
  {
175
- auto holder = weakHolder.lock();
176
- if (!holder)
174
+ "clearCookies",
175
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
177
176
  {
178
- return;
179
- }
177
+ auto holder = weakHolder.lock();
178
+ if (!holder)
179
+ {
180
+ return;
181
+ }
180
182
 
181
- auto resource = holder->Module->m_resource;
182
- if (!holder->Module->m_isResourceSetup)
183
- {
184
- SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
185
- holder->Module->m_isResourceSetup = true;
186
- }
183
+ auto resource = holder->Module->m_resource;
184
+ if (!holder->Module->m_isResourceSetup)
185
+ {
186
+ SetUpHttpResource(resource, holder->Module->getInstance(), holder->Module->m_inspectableProperties);
187
+ holder->Module->m_isResourceSetup = true;
188
+ }
187
189
 
188
- resource->ClearCookies();
190
+ resource->ClearCookies();
191
+ }
189
192
  }
190
- }
191
- };
192
- }
193
+ };
194
+ }
193
195
  // clang-format on
194
196
 
195
197
  #pragma endregion CxxModule
@@ -18,7 +18,7 @@ struct IBlobPersistor {
18
18
  /// When an entry for blobId cannot be found.
19
19
  /// </exception>
20
20
  ///
21
- virtual winrt::array_view<uint8_t> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) = 0;
21
+ virtual winrt::array_view<uint8_t const> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) = 0;
22
22
 
23
23
  virtual void RemoveMessage(std::string &&blobId) noexcept = 0;
24
24
 
@@ -187,23 +187,23 @@ std::map<string, dynamic> WebSocketModule::getConstants() {
187
187
  }
188
188
 
189
189
  // clang-format off
190
- std::vector<facebook::xplat::module::CxxModule::Method> WebSocketModule::getMethods()
191
- {
192
- return
190
+ std::vector<facebook::xplat::module::CxxModule::Method> WebSocketModule::getMethods()
193
191
  {
192
+ return
194
193
  {
195
- "connect",
196
- [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& url, dynamic protocols, dynamic options, int64_t id
197
194
  {
198
- IWebSocketResource::Protocols protocols;
199
- dynamic protocolsDynamic = jsArgAsDynamic(args, 1);
200
- if (!protocolsDynamic.empty())
195
+ "connect",
196
+ [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& url, dynamic protocols, dynamic options, int64_t id
201
197
  {
202
- for (const auto& protocol : protocolsDynamic)
198
+ IWebSocketResource::Protocols protocols;
199
+ dynamic protocolsDynamic = jsArgAsDynamic(args, 1);
200
+ if (!protocolsDynamic.empty())
203
201
  {
204
- protocols.push_back(protocol.getString());
202
+ for (const auto& protocol : protocolsDynamic)
203
+ {
204
+ protocols.push_back(protocol.getString());
205
+ }
205
206
  }
206
- }
207
207
 
208
208
  IWebSocketResource::Options options;
209
209
  dynamic optionsDynamic = jsArgAsDynamic(args, 2);
@@ -216,79 +216,79 @@ std::vector<facebook::xplat::module::CxxModule::Method> WebSocketModule::getMeth
216
216
  }
217
217
  }
218
218
 
219
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 3), jsArgAsString(args, 0), weakState);
220
- if (auto sharedWs = weakWs.lock())
221
- {
222
- sharedWs->Connect(jsArgAsString(args, 0), protocols, options);
223
- }
224
- }
225
- },
226
- {
227
- "close",
228
- [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // [int64_t code, string reason,] int64_t id
229
- {
230
- // See react-native\Libraries\WebSocket\WebSocket.js:_close
231
- if (args.size() == 3) // WebSocketModule.close(statusCode, closeReason, this._socketId);
232
- {
233
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 2), {}, weakState);
219
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 3), jsArgAsString(args, 0), weakState);
234
220
  if (auto sharedWs = weakWs.lock())
235
221
  {
236
- sharedWs->Close(static_cast<IWebSocketResource::CloseCode>(jsArgAsInt(args, 0)), jsArgAsString(args, 1));
222
+ sharedWs->Connect(jsArgAsString(args, 0), protocols, options);
237
223
  }
238
224
  }
239
- else if (args.size() == 1) // WebSocketModule.close(this._socketId);
225
+ },
226
+ {
227
+ "close",
228
+ [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // [int64_t code, string reason,] int64_t id
240
229
  {
241
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 0), {}, weakState);
242
- if (auto sharedWs = weakWs.lock())
230
+ // See react-native\Libraries\WebSocket\WebSocket.js:_close
231
+ if (args.size() == 3) // WebSocketModule.close(statusCode, closeReason, this._socketId);
243
232
  {
244
- sharedWs->Close(IWebSocketResource::CloseCode::Normal, {});
233
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 2), {}, weakState);
234
+ if (auto sharedWs = weakWs.lock())
235
+ {
236
+ sharedWs->Close(static_cast<IWebSocketResource::CloseCode>(jsArgAsInt(args, 0)), jsArgAsString(args, 1));
237
+ }
245
238
  }
246
- }
247
- else
248
- {
249
- auto state = weakState.lock();
250
- if (state && state->Module) {
251
- auto errorObj = dynamic::object("id", -1)("message", "Incorrect number of parameters");
252
- SendEvent(state->Module->getInstance(), "websocketFailed", std::move(errorObj));
239
+ else if (args.size() == 1) // WebSocketModule.close(this._socketId);
240
+ {
241
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 0), {}, weakState);
242
+ if (auto sharedWs = weakWs.lock())
243
+ {
244
+ sharedWs->Close(IWebSocketResource::CloseCode::Normal, {});
245
+ }
246
+ }
247
+ else
248
+ {
249
+ auto state = weakState.lock();
250
+ if (state && state->Module) {
251
+ auto errorObj = dynamic::object("id", -1)("message", "Incorrect number of parameters");
252
+ SendEvent(state->Module->getInstance(), "websocketFailed", std::move(errorObj));
253
+ }
253
254
  }
254
255
  }
255
- }
256
- },
257
- {
258
- "send",
259
- [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& message, int64_t id
256
+ },
260
257
  {
261
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 1), {}, weakState);
262
- if (auto sharedWs = weakWs.lock())
258
+ "send",
259
+ [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& message, int64_t id
263
260
  {
264
- sharedWs->Send(jsArgAsString(args, 0));
261
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 1), {}, weakState);
262
+ if (auto sharedWs = weakWs.lock())
263
+ {
264
+ sharedWs->Send(jsArgAsString(args, 0));
265
+ }
265
266
  }
266
- }
267
- },
268
- {
269
- "sendBinary",
270
- [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& base64String, int64_t id
267
+ },
271
268
  {
272
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 1), {}, weakState);
273
- if (auto sharedWs = weakWs.lock())
269
+ "sendBinary",
270
+ [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // const string& base64String, int64_t id
274
271
  {
275
- sharedWs->SendBinary(jsArgAsString(args, 0));
272
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 1), {}, weakState);
273
+ if (auto sharedWs = weakWs.lock())
274
+ {
275
+ sharedWs->SendBinary(jsArgAsString(args, 0));
276
+ }
276
277
  }
277
- }
278
- },
279
- {
280
- "ping",
281
- [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // int64_t id
278
+ },
282
279
  {
283
- weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 0), {}, weakState);
284
- if (auto sharedWs = weakWs.lock())
280
+ "ping",
281
+ [weakState = weak_ptr<SharedState>(m_sharedState)](dynamic args) // int64_t id
285
282
  {
286
- sharedWs->Ping();
283
+ weak_ptr weakWs = GetOrCreateWebSocket(jsArgAsInt(args, 0), {}, weakState);
284
+ if (auto sharedWs = weakWs.lock())
285
+ {
286
+ sharedWs->Ping();
287
+ }
287
288
  }
288
289
  }
289
- }
290
- };
291
- } // getMethods
290
+ };
291
+ } // getMethods
292
292
  // clang-format on
293
293
 
294
294
  #pragma endregion WebSocketModule
@@ -71,6 +71,7 @@ struct IHttpResource {
71
71
  /// </param>
72
72
  /// <param name="timeout">
73
73
  /// Request timeout in miliseconds.
74
+ /// Note: A value of 0 means no timeout. The resource will await the response indefinitely.
74
75
  /// </param>
75
76
  /// <param name="withCredentials">
76
77
  /// Allow including credentials in request.
@@ -95,7 +96,7 @@ struct IHttpResource {
95
96
  virtual void SetOnData(std::function<void(int64_t requestId, std::string &&responseData)> &&handler) noexcept = 0;
96
97
  virtual void SetOnData(std::function<void(int64_t requestId, folly::dynamic &&responseData)> &&handler) noexcept = 0;
97
98
  virtual void SetOnError(
98
- std::function<void(int64_t requestId, std::string &&errorMessage /*, bool isTimeout*/)> &&handler) noexcept = 0;
99
+ std::function<void(int64_t requestId, std::string &&errorMessage, bool isTimeout)> &&handler) noexcept = 0;
99
100
  };
100
101
 
101
102
  } // namespace Microsoft::React::Networking
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <winrt/Windows.Foundation.h>
7
+ #include <winrt/Windows.Web.Http.h>
8
+ #include <winrt/base.h>
9
+
10
+ namespace Microsoft::React::Networking {
11
+
12
+ struct IRedirectEventSource : winrt::implements<IRedirectEventSource, winrt::Windows::Foundation::IInspectable> {
13
+ virtual bool OnRedirecting(
14
+ winrt::Windows::Web::Http::HttpRequestMessage const &request,
15
+ winrt::Windows::Web::Http::HttpResponseMessage const &response) noexcept = 0;
16
+ };
17
+
18
+ } // namespace Microsoft::React::Networking
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <winrt/Windows.Foundation.Collections.h>
7
+ #include <winrt/Windows.Foundation.h>
8
+ #include <winrt/Windows.Web.Http.h>
9
+
10
+ namespace Microsoft::React::Networking {
11
+
12
+ struct IWinRTHttpRequestFactory {
13
+ virtual ~IWinRTHttpRequestFactory() noexcept {}
14
+
15
+ virtual winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Web::Http::HttpRequestMessage> CreateRequest(
16
+ winrt::Windows::Web::Http::HttpMethod &&method,
17
+ winrt::Windows::Foundation::Uri &&uri,
18
+ winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Windows::Foundation::IInspectable>
19
+ props) noexcept = 0;
20
+ };
21
+
22
+ } // namespace Microsoft::React::Networking