Skip to content

Commit 572b374

Browse files
committed
Enable Blob module in UWP (microsoft#10187)
* Update packages.lock.json * Update packages.lock.json * Add Shared project to ReactUWPTestApp solution * RNTesterApp.csproj formatting * Enable Blob module in UWP * Change files * Update packages.lock.json * Use context property bag for runtime options in MSRN * Remove unused options header * Revert ReactUWPTestApp.sln * Update packages.lock.json * Update packages.lock.json * Use namespace in monolith HTTP module property
1 parent d6c1318 commit 572b374

3 files changed

Lines changed: 569 additions & 522 deletions

File tree

packages/e2e-test-app/windows/RNTesterApp/RNTesterApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props')" />
146146
</ImportGroup>
147147
<ItemGroup>
148-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
148+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
149149
<Version>6.2.9</Version>
150150
</PackageReference>
151151
<PackageReference Include="XamlTreeDump">
@@ -165,4 +165,4 @@
165165
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props'))" />
166166
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.targets'))" />
167167
</Target>
168-
</Project>
168+
</Project>

vnext/Microsoft.ReactNative/Base/CoreNativeModules.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919

2020
namespace Microsoft::ReactNative {
2121

22+
using winrt::Microsoft::ReactNative::ReactPropertyBag;
23+
2224
namespace {
2325

26+
using winrt::Microsoft::ReactNative::ReactPropertyId;
27+
2428
bool HasPackageIdentity() noexcept {
2529
static const bool hasPackageIdentity = []() noexcept {
2630
auto packageStatics = winrt::get_activation_factory<winrt::Windows::ApplicationModel::IPackageStatics>(
@@ -35,6 +39,13 @@ bool HasPackageIdentity() noexcept {
3539
return hasPackageIdentity;
3640
}
3741

42+
ReactPropertyId<bool> HttpUseMonolithicModuleProperty() noexcept {
43+
static ReactPropertyId<bool> propId{
44+
L"ReactNative.Http"
45+
L"UseMonolithicModule"};
46+
return propId;
47+
}
48+
3849
} // namespace
3950

4051
std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
@@ -50,11 +61,25 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
5061
[props = context->Properties()]() { return Microsoft::React::CreateHttpModule(props); },
5162
jsMessageQueue);
5263

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+
5376
modules.emplace_back(
5477
"Timing",
5578
[batchingUIMessageQueue]() { return facebook::react::CreateTimingModule(batchingUIMessageQueue); },
5679
batchingUIMessageQueue);
5780

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.
5883
modules.emplace_back(
5984
NativeAnimatedModule::name,
6085
[context = std::move(context)]() mutable { return std::make_unique<NativeAnimatedModule>(std::move(context)); },

0 commit comments

Comments
 (0)