react-native-windows 0.74.2 → 0.74.4
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/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +161 -13
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.h +8 -11
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +2 -2
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +1 -1
- package/Microsoft.ReactNative/IReactPackageBuilderFabric.idl +5 -0
- package/Microsoft.ReactNative/ReactHost/React.h +7 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +7 -0
- package/Microsoft.ReactNative/ReactNativeHost.cpp +8 -0
- package/Microsoft.ReactNative/ReactPackageBuilder.cpp +8 -0
- package/Microsoft.ReactNative/ReactPackageBuilder.h +6 -0
- package/Microsoft.ReactNative/UriImageManager.idl +0 -10
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +1 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/Shared/HermesRuntimeHolder.cpp +8 -0
- package/Shared/Shared.vcxitems +0 -5
- package/package.json +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager_emptyimpl.cpp +0 -16
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
#include "UriImageManager.h"
|
|
6
6
|
|
|
7
7
|
#include "Composition.ImageSource.g.h"
|
|
8
|
-
#include
|
|
8
|
+
#include <AutoDraw.h>
|
|
9
9
|
#include <ReactPropertyBag.h>
|
|
10
|
+
#include <d2d1_3.h>
|
|
11
|
+
#include <shcore.h>
|
|
12
|
+
#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
|
|
13
|
+
#include <winrt/Windows.Security.Cryptography.h>
|
|
14
|
+
#include <winrt/Windows.Storage.Streams.h>
|
|
10
15
|
|
|
11
16
|
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
12
17
|
|
|
@@ -39,27 +44,170 @@ winrt::Microsoft::ReactNative::Composition::ImageSource MakeImageSource(
|
|
|
39
44
|
return winrt::make<ImageSource>(source);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
/**
|
|
48
|
+
* This ImageHandler will handle uri types with svgxaml base64 encoded data
|
|
49
|
+
*
|
|
50
|
+
* <Image
|
|
51
|
+
* style={{width: 400, height: 200}}
|
|
52
|
+
* source={{uri:
|
|
53
|
+
* 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4gPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSI+PHBhdGggZD0iTTEzLjEyNSAwSDBWMTMuMTI1SDEzLjEyNVYwWiIgZmlsbD0iI0YyNTAyMiI+PC9wYXRoPjxwYXRoIGQ9Ik0yOCAwSDE0Ljg3NVYxMy4xMjVIMjhWMFoiIGZpbGw9IiM3RkJBMDAiPjwvcGF0aD48cGF0aCBkPSJNMTMuMTI1IDE0Ljg3NUgwVjI4SDEzLjEyNVYxNC44NzVaIiBmaWxsPSIjMDBBNEVGIj48L3BhdGg+PHBhdGggZD0iTTI4IDE0Ljg3NUgxNC44NzVWMjhIMjhWMTQuODc1WiIgZmlsbD0iI0ZGQjkwMCI+PC9wYXRoPjwvc3ZnPiA='}}
|
|
54
|
+
* />
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
struct SvgDataImageHandler : winrt::implements<
|
|
58
|
+
SvgDataImageHandler,
|
|
59
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IUriBrushProvider,
|
|
60
|
+
winrt::Microsoft::ReactNative::Composition::IUriImageProvider> {
|
|
61
|
+
bool CanLoadImageUri(winrt::Microsoft::ReactNative::IReactContext context, winrt::Windows::Foundation::Uri uri) {
|
|
62
|
+
return uri.SchemeName() == L"data" && std::wstring_view(uri.Path()).starts_with(L"image/svg+xml;base64,");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
winrt::Windows::Foundation::IAsyncOperation<winrt::Microsoft::ReactNative::Composition::Experimental::UriBrushFactory>
|
|
66
|
+
GetSourceAsync(
|
|
67
|
+
const winrt::Microsoft::ReactNative::IReactContext &context,
|
|
68
|
+
const winrt::Microsoft::ReactNative::Composition::ImageSource &imageSource) {
|
|
69
|
+
auto path = winrt::to_string(imageSource.Uri().Path());
|
|
70
|
+
auto size = imageSource.Size();
|
|
71
|
+
auto scale = imageSource.Scale();
|
|
72
|
+
|
|
73
|
+
size_t start = path.find(',');
|
|
74
|
+
if (start == std::string::npos || start + 1 > path.length())
|
|
75
|
+
co_return nullptr;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
co_await winrt::resume_background();
|
|
79
|
+
|
|
80
|
+
std::string_view base64String(path.c_str() + start + 1, path.length() - start - 1);
|
|
81
|
+
auto buffer = winrt::Windows::Security::Cryptography::CryptographicBuffer::DecodeFromBase64String(
|
|
82
|
+
winrt::to_hstring(base64String));
|
|
83
|
+
|
|
84
|
+
winrt::Windows::Storage::Streams::InMemoryRandomAccessStream memoryStream;
|
|
85
|
+
co_await memoryStream.WriteAsync(buffer);
|
|
86
|
+
memoryStream.Seek(0);
|
|
87
|
+
|
|
88
|
+
co_return
|
|
89
|
+
[memoryStream, size, scale](
|
|
90
|
+
const winrt::Microsoft::ReactNative::IReactContext &reactContext,
|
|
91
|
+
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compositionContext)
|
|
92
|
+
-> winrt::Microsoft::ReactNative::Composition::Experimental::IBrush {
|
|
93
|
+
auto drawingBrush = compositionContext.CreateDrawingSurfaceBrush(
|
|
94
|
+
size,
|
|
95
|
+
winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized,
|
|
96
|
+
winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
|
|
97
|
+
POINT pt;
|
|
98
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingBrush, 1.0, &pt);
|
|
99
|
+
auto renderTarget = autoDraw.GetRenderTarget();
|
|
100
|
+
|
|
101
|
+
winrt::com_ptr<ID2D1DeviceContext5> deviceContext5;
|
|
102
|
+
winrt::check_hresult(renderTarget->QueryInterface(IID_ID2D1DeviceContext5, deviceContext5.put_void()));
|
|
103
|
+
|
|
104
|
+
winrt::com_ptr<IStream> nativeStream;
|
|
105
|
+
|
|
106
|
+
winrt::check_hresult(CreateStreamOverRandomAccessStream(
|
|
107
|
+
memoryStream.as<::IUnknown>().get(), IID_PPV_ARGS(nativeStream.put())));
|
|
108
|
+
|
|
109
|
+
winrt::com_ptr<ID2D1SvgDocument> svgDocument;
|
|
110
|
+
if (FAILED(deviceContext5->CreateSvgDocument(
|
|
111
|
+
nativeStream.get(), {size.Width, size.Height}, svgDocument.put()))) {
|
|
112
|
+
return nullptr;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
D2D1::Matrix3x2F originalTransform;
|
|
116
|
+
D2D1::Matrix3x2F translationTransform =
|
|
117
|
+
D2D1::Matrix3x2F::Translation(static_cast<float>(pt.x), static_cast<float>(pt.y));
|
|
118
|
+
|
|
119
|
+
renderTarget->GetTransform(&originalTransform);
|
|
120
|
+
translationTransform = originalTransform * translationTransform;
|
|
121
|
+
|
|
122
|
+
renderTarget->SetTransform(translationTransform);
|
|
123
|
+
|
|
124
|
+
deviceContext5->DrawSvgDocument(svgDocument.get());
|
|
125
|
+
|
|
126
|
+
renderTarget->SetTransform(originalTransform);
|
|
127
|
+
|
|
128
|
+
return drawingBrush;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
} catch (winrt::hresult_error const &) {
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
co_return nullptr;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* This ImageHandler will handle uri types of base64 encoded data
|
|
140
|
+
*
|
|
141
|
+
* <Image
|
|
142
|
+
* style={{width: 400, height: 200}}
|
|
143
|
+
* source={{uri:
|
|
144
|
+
* 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg=='}}
|
|
145
|
+
* />
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
148
|
+
struct DataImageHandler : winrt::implements<
|
|
149
|
+
DataImageHandler,
|
|
150
|
+
winrt::Microsoft::ReactNative::Composition::IUriImageStreamProvider,
|
|
151
|
+
winrt::Microsoft::ReactNative::Composition::IUriImageProvider> {
|
|
152
|
+
bool CanLoadImageUri(winrt::Microsoft::ReactNative::IReactContext context, winrt::Windows::Foundation::Uri uri) {
|
|
153
|
+
return uri.SchemeName() == L"data";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::Streams::IRandomAccessStream> GetSourceAsync(
|
|
157
|
+
const winrt::Microsoft::ReactNative::IReactContext &context,
|
|
158
|
+
const winrt::Microsoft::ReactNative::Composition::ImageSource &imageSource) {
|
|
159
|
+
auto path = winrt::to_string(imageSource.Uri().Path());
|
|
160
|
+
|
|
161
|
+
size_t start = path.find(',');
|
|
162
|
+
if (start == std::string::npos || start + 1 > path.length())
|
|
163
|
+
co_return nullptr;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
co_await winrt::resume_background();
|
|
167
|
+
|
|
168
|
+
std::string_view base64String(path.c_str() + start + 1, path.length() - start - 1);
|
|
169
|
+
auto buffer = winrt::Windows::Security::Cryptography::CryptographicBuffer::DecodeFromBase64String(
|
|
170
|
+
winrt::to_hstring(base64String));
|
|
171
|
+
|
|
172
|
+
winrt::Windows::Storage::Streams::InMemoryRandomAccessStream memoryStream;
|
|
173
|
+
co_await memoryStream.WriteAsync(buffer);
|
|
174
|
+
memoryStream.Seek(0);
|
|
175
|
+
|
|
176
|
+
co_return memoryStream;
|
|
177
|
+
} catch (winrt::hresult_error const &) {
|
|
178
|
+
// Base64 decode failed
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
co_return nullptr;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
static const ReactPropertyId<ReactNonAbiValue<std::shared_ptr<UriImageManager>>> &UriImageManagerPropertyId() noexcept {
|
|
186
|
+
static const ReactPropertyId<ReactNonAbiValue<std::shared_ptr<UriImageManager>>> prop{
|
|
44
187
|
L"ReactNative", L"UriImageManager"};
|
|
45
188
|
return prop;
|
|
46
189
|
}
|
|
47
190
|
|
|
48
|
-
|
|
191
|
+
UriImageManager::UriImageManager() {
|
|
192
|
+
m_providers.push_back(winrt::make<SvgDataImageHandler>());
|
|
193
|
+
m_providers.push_back(winrt::make<DataImageHandler>());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
void UriImageManager::Install(
|
|
197
|
+
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties,
|
|
198
|
+
const std::shared_ptr<UriImageManager> &manager) noexcept {
|
|
199
|
+
properties.Set(UriImageManagerPropertyId(), manager);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
std::shared_ptr<UriImageManager> UriImageManager::Get(
|
|
49
203
|
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept {
|
|
50
|
-
|
|
51
|
-
winrt::Microsoft::ReactNative::ReactPropertyBag(properties).GetOrCreate(UriImageManagerPropertyId(), []() {
|
|
52
|
-
return winrt::make_self<UriImageManager>();
|
|
53
|
-
});
|
|
54
|
-
return uriImageManager.Value();
|
|
204
|
+
return winrt::Microsoft::ReactNative::ReactPropertyBag(properties).Get(UriImageManagerPropertyId()).Value();
|
|
55
205
|
}
|
|
56
206
|
|
|
57
|
-
void UriImageManager::AddUriImageProvider(
|
|
58
|
-
const winrt::Microsoft::ReactNative::IReactPropertyBag &properties,
|
|
59
|
-
const IUriImageProvider &provider) {
|
|
207
|
+
void UriImageManager::AddUriImageProvider(const IUriImageProvider &provider) {
|
|
60
208
|
if (!provider)
|
|
61
209
|
winrt::throw_hresult(E_INVALIDARG);
|
|
62
|
-
|
|
210
|
+
m_providers.push_back(provider);
|
|
63
211
|
}
|
|
64
212
|
|
|
65
213
|
IUriImageProvider UriImageManager::TryGetUriImageProvider(
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
|
-
#include "Composition.UriImageManager.g.h"
|
|
6
5
|
|
|
7
6
|
#include <ReactPropertyBag.h>
|
|
8
7
|
#include <Utils/ImageUtils.h>
|
|
@@ -11,14 +10,16 @@
|
|
|
11
10
|
|
|
12
11
|
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
13
12
|
|
|
14
|
-
struct UriImageManager
|
|
15
|
-
UriImageManager()
|
|
13
|
+
struct UriImageManager {
|
|
14
|
+
UriImageManager();
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const winrt::Microsoft::ReactNative::IReactPropertyBag &properties,
|
|
19
|
-
const IUriImageProvider &provider);
|
|
16
|
+
void AddUriImageProvider(const IUriImageProvider &provider);
|
|
20
17
|
|
|
21
|
-
static
|
|
18
|
+
static void Install(
|
|
19
|
+
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties,
|
|
20
|
+
const std::shared_ptr<UriImageManager> &manager) noexcept;
|
|
21
|
+
|
|
22
|
+
static std::shared_ptr<UriImageManager> Get(
|
|
22
23
|
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept;
|
|
23
24
|
|
|
24
25
|
IUriImageProvider TryGetUriImageProvider(
|
|
@@ -33,7 +34,3 @@ winrt::Microsoft::ReactNative::Composition::ImageSource MakeImageSource(
|
|
|
33
34
|
const facebook::react::ImageSource &source) noexcept;
|
|
34
35
|
|
|
35
36
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
36
|
-
|
|
37
|
-
namespace winrt::Microsoft::ReactNative::Composition::factory_implementation {
|
|
38
|
-
struct UriImageManager : UriImageManagerT<UriImageManager, implementation::UriImageManager> {};
|
|
39
|
-
} // namespace winrt::Microsoft::ReactNative::Composition::factory_implementation
|
|
@@ -19,8 +19,8 @@ namespace Microsoft::ReactNative {
|
|
|
19
19
|
|
|
20
20
|
WindowsImageManager::WindowsImageManager(winrt::Microsoft::ReactNative::ReactContext reactContext)
|
|
21
21
|
: m_reactContext(reactContext) {
|
|
22
|
-
m_uriImageManager =
|
|
23
|
-
reactContext.Properties());
|
|
22
|
+
m_uriImageManager =
|
|
23
|
+
winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager::Get(reactContext.Properties());
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
winrt::com_ptr<IWICBitmapSource> wicBitmapSourceFromStream(
|
|
@@ -19,7 +19,7 @@ struct WindowsImageManager {
|
|
|
19
19
|
|
|
20
20
|
private:
|
|
21
21
|
winrt::Microsoft::ReactNative::ReactContext m_reactContext;
|
|
22
|
-
|
|
22
|
+
std::shared_ptr<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager> m_uriImageManager;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
} // namespace Microsoft::ReactNative
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
import "IReactViewComponentBuilder.idl";
|
|
5
|
+
import "UriImageManager.idl";
|
|
5
6
|
|
|
6
7
|
#include "DocString.h"
|
|
7
8
|
|
|
@@ -18,6 +19,10 @@ namespace Microsoft.ReactNative
|
|
|
18
19
|
{
|
|
19
20
|
DOC_STRING("Registers a custom native view component.")
|
|
20
21
|
void AddViewComponent(String componentName, ReactViewComponentProvider componentProvider);
|
|
22
|
+
|
|
23
|
+
DOC_STRING(
|
|
24
|
+
"Ability to load images using custom Uri protocol handlers. The provider should implement @Composition.IUriImageStreamProvider or @Composition.Experimental.IUriBrushProvider.")
|
|
25
|
+
void AddUriImageProvider(Microsoft.ReactNative.Composition.IUriImageProvider provider);
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
} // namespace Microsoft.ReactNative
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
#include <ViewManagerProvider.h>
|
|
33
33
|
#include <winrt/Microsoft.ReactNative.h>
|
|
34
34
|
|
|
35
|
+
#ifdef USE_FABRIC
|
|
36
|
+
#include <Fabric/Composition/UriImageManager.h>
|
|
37
|
+
#endif
|
|
38
|
+
|
|
35
39
|
namespace Mso::React {
|
|
36
40
|
|
|
37
41
|
// Forward declarations
|
|
@@ -182,6 +186,9 @@ struct ReactOptions {
|
|
|
182
186
|
std::shared_ptr<NativeModuleProvider2> ModuleProvider;
|
|
183
187
|
std::shared_ptr<ViewManagerProvider2> ViewManagerProvider;
|
|
184
188
|
std::shared_ptr<winrt::Microsoft::ReactNative::TurboModulesProvider> TurboModuleProvider;
|
|
189
|
+
#ifdef USE_FABRIC
|
|
190
|
+
std::shared_ptr<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager> UriImageManager;
|
|
191
|
+
#endif
|
|
185
192
|
|
|
186
193
|
//! Identity of the SDX. Must uniquely describe the SDX across the installed product.
|
|
187
194
|
std::string Identity;
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
#include "Unicode.h"
|
|
53
53
|
|
|
54
54
|
#ifdef USE_FABRIC
|
|
55
|
+
#include <Fabric/Composition/UriImageManager.h>
|
|
55
56
|
#include <Fabric/FabricUIManagerModule.h>
|
|
56
57
|
#include <Fabric/ReactNativeConfigProperties.h>
|
|
57
58
|
#include <Fabric/WindowsComponentDescriptorRegistry.h>
|
|
@@ -570,6 +571,8 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
|
|
|
570
571
|
});
|
|
571
572
|
|
|
572
573
|
InitDevMenu();
|
|
574
|
+
winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager::Install(
|
|
575
|
+
ReactPropertyBag(m_reactContext->Properties()), m_options.UriImageManager);
|
|
573
576
|
|
|
574
577
|
m_uiQueue->Post([this, weakThis = Mso::WeakPtr{this}]() noexcept {
|
|
575
578
|
// Objects that must be created on the UI thread
|
|
@@ -726,6 +729,10 @@ void ReactInstanceWin::InitializeWithBridge() noexcept {
|
|
|
726
729
|
#endif
|
|
727
730
|
|
|
728
731
|
InitDevMenu();
|
|
732
|
+
#ifdef USE_FABRIC
|
|
733
|
+
winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager::Install(
|
|
734
|
+
ReactPropertyBag(m_reactContext->Properties()), m_options.UriImageManager);
|
|
735
|
+
#endif
|
|
729
736
|
|
|
730
737
|
m_uiQueue->Post([this, weakThis = Mso::WeakPtr{this}]() noexcept {
|
|
731
738
|
// Objects that must be created on the UI thread
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
#ifdef USE_FABRIC
|
|
18
18
|
#include <Fabric/WindowsComponentDescriptorRegistry.h>
|
|
19
|
+
#include <ReactPackageBuilder.h>
|
|
19
20
|
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
20
21
|
#endif
|
|
21
22
|
|
|
@@ -93,6 +94,8 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
|
|
|
93
94
|
auto turboModulesProvider = std::make_shared<TurboModulesProvider>();
|
|
94
95
|
|
|
95
96
|
#ifdef USE_FABRIC
|
|
97
|
+
auto uriImageManager =
|
|
98
|
+
std::make_shared<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager>();
|
|
96
99
|
auto componentregistry = std::make_shared<::Microsoft::ReactNative::WindowsComponentDescriptorRegistry>();
|
|
97
100
|
auto componentDescriptorRegistry = std::make_shared<facebook::react::ComponentDescriptorProviderRegistry>();
|
|
98
101
|
|
|
@@ -108,6 +111,7 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
|
|
|
108
111
|
turboModulesProvider,
|
|
109
112
|
#ifdef USE_FABRIC
|
|
110
113
|
componentregistry,
|
|
114
|
+
uriImageManager,
|
|
111
115
|
#endif
|
|
112
116
|
m_instanceSettings.UseWebDebugger());
|
|
113
117
|
|
|
@@ -164,6 +168,10 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
|
|
|
164
168
|
#endif
|
|
165
169
|
reactOptions.TurboModuleProvider = turboModulesProvider;
|
|
166
170
|
|
|
171
|
+
#ifdef USE_FABRIC
|
|
172
|
+
reactOptions.UriImageManager = uriImageManager;
|
|
173
|
+
#endif
|
|
174
|
+
|
|
167
175
|
reactOptions.OnInstanceCreated = [](Mso::CntPtr<Mso::React::IReactContext> &&context) {
|
|
168
176
|
auto notifications = context->Notifications();
|
|
169
177
|
ReactInstanceSettings::RaiseInstanceCreated(
|
|
@@ -22,6 +22,7 @@ ReactPackageBuilder::ReactPackageBuilder(
|
|
|
22
22
|
std::shared_ptr<TurboModulesProvider> const &turboModulesProvider,
|
|
23
23
|
#ifdef USE_FABRIC
|
|
24
24
|
std::shared_ptr<::Microsoft::ReactNative::WindowsComponentDescriptorRegistry> const &componentRegistry,
|
|
25
|
+
std::shared_ptr<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager> const &uriImageManager,
|
|
25
26
|
#endif
|
|
26
27
|
bool isWebDebugging) noexcept
|
|
27
28
|
: m_modulesProvider{modulesProvider},
|
|
@@ -31,6 +32,7 @@ ReactPackageBuilder::ReactPackageBuilder(
|
|
|
31
32
|
m_turboModulesProvider{turboModulesProvider},
|
|
32
33
|
#ifdef USE_FABRIC
|
|
33
34
|
m_componentRegistry{componentRegistry},
|
|
35
|
+
m_uriImageManager{uriImageManager},
|
|
34
36
|
#endif
|
|
35
37
|
|
|
36
38
|
m_isWebDebugging{isWebDebugging} {
|
|
@@ -63,5 +65,11 @@ void ReactPackageBuilder::AddViewComponent(
|
|
|
63
65
|
ReactViewComponentProvider const &viewComponentProvider) noexcept {
|
|
64
66
|
m_componentRegistry->Add(componentName, viewComponentProvider);
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
void ReactPackageBuilder::AddUriImageProvider(
|
|
70
|
+
const winrt::Microsoft::ReactNative::Composition::IUriImageProvider &provider) noexcept {
|
|
71
|
+
m_uriImageManager->AddUriImageProvider(provider);
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
#endif
|
|
67
75
|
} // namespace winrt::Microsoft::ReactNative
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
#endif
|
|
10
10
|
#include "winrt/Microsoft.ReactNative.h"
|
|
11
11
|
#ifdef USE_FABRIC
|
|
12
|
+
#include <Fabric/Composition/UriImageManager.h>
|
|
12
13
|
#include <Fabric/WindowsComponentDescriptorRegistry.h>
|
|
14
|
+
#include "winrt/Microsoft.ReactNative.Composition.h"
|
|
13
15
|
#endif
|
|
14
16
|
|
|
15
17
|
namespace winrt::Microsoft::ReactNative {
|
|
@@ -30,6 +32,8 @@ struct ReactPackageBuilder : winrt::implements<
|
|
|
30
32
|
std::shared_ptr<TurboModulesProvider> const &turboModulesProvider,
|
|
31
33
|
#ifdef USE_FABRIC
|
|
32
34
|
std::shared_ptr<::Microsoft::ReactNative::WindowsComponentDescriptorRegistry> const &componentRegistry,
|
|
35
|
+
std::shared_ptr<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager> const
|
|
36
|
+
&uriImageManager,
|
|
33
37
|
#endif
|
|
34
38
|
bool isWebDebugging) noexcept;
|
|
35
39
|
|
|
@@ -43,6 +47,7 @@ struct ReactPackageBuilder : winrt::implements<
|
|
|
43
47
|
#ifdef USE_FABRIC
|
|
44
48
|
// IReactPackageBuilderFabric
|
|
45
49
|
void AddViewComponent(winrt::hstring componentName, ReactViewComponentProvider const &viewComponentProvider) noexcept;
|
|
50
|
+
void AddUriImageProvider(const winrt::Microsoft::ReactNative::Composition::IUriImageProvider &provider) noexcept;
|
|
46
51
|
#endif // USE_FABRIC
|
|
47
52
|
|
|
48
53
|
private:
|
|
@@ -54,6 +59,7 @@ struct ReactPackageBuilder : winrt::implements<
|
|
|
54
59
|
|
|
55
60
|
#ifdef USE_FABRIC
|
|
56
61
|
std::shared_ptr<::Microsoft::ReactNative::WindowsComponentDescriptorRegistry> m_componentRegistry;
|
|
62
|
+
std::shared_ptr<winrt::Microsoft::ReactNative::Composition::implementation::UriImageManager> m_uriImageManager;
|
|
57
63
|
#endif
|
|
58
64
|
|
|
59
65
|
const bool m_isWebDebugging;
|
|
@@ -72,14 +72,4 @@ namespace Microsoft.ReactNative.Composition
|
|
|
72
72
|
Windows.Foundation.IAsyncOperation<UriBrushFactory> GetSourceAsync(Microsoft.ReactNative.IReactContext context, Microsoft.ReactNative.Composition.ImageSource imageSource);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
[default_interface]
|
|
77
|
-
[webhosthidden]
|
|
78
|
-
[experimental]
|
|
79
|
-
DOC_STRING(
|
|
80
|
-
"Ability to load images using custom Uri protocol handlers. The provider should implement @IUriImageStreamProvider or @Experimental.IUriBrushProvider")
|
|
81
|
-
runtimeclass UriImageManager
|
|
82
|
-
{
|
|
83
|
-
static void AddUriImageProvider(Microsoft.ReactNative.IReactPropertyBag properties, IUriImageProvider provider);
|
|
84
|
-
}
|
|
85
75
|
} // namespace Microsoft.ReactNative.Composition
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.74.
|
|
13
|
+
<ReactNativeWindowsVersion>0.74.4</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>4</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>785c8734e6b203a669bd504846488c89ed5352aa</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<!-- Enabling this will (1) Include hermes glues in the Microsoft.ReactNative binaries AND (2) Make hermes the default engine -->
|
|
7
7
|
<UseHermes Condition="'$(UseHermes)' == ''">true</UseHermes>
|
|
8
8
|
<!-- This will be true if (1) the client want to use hermes by setting UseHermes to true OR (2) We are building for UWP where dynamic switching is enabled -->
|
|
9
|
-
<HermesVersion Condition="'$(HermesVersion)' == ''">0.1.
|
|
9
|
+
<HermesVersion Condition="'$(HermesVersion)' == ''">0.1.21</HermesVersion>
|
|
10
10
|
<HermesPackage Condition="'$(HermesPackage)' == '' And Exists('$(PkgMicrosoft_JavaScript_Hermes)')">$(PkgMicrosoft_JavaScript_Hermes)</HermesPackage>
|
|
11
11
|
<HermesPackage Condition="'$(HermesPackage)' == ''">$(NuGetPackageRoot)\Microsoft.JavaScript.Hermes\$(HermesVersion)</HermesPackage>
|
|
12
12
|
<EnableHermesInspectorInReleaseFlavor Condition="'$(EnableHermesInspectorInReleaseFlavor)' == ''">false</EnableHermesInspectorInReleaseFlavor>
|
|
@@ -291,6 +291,10 @@ void NAPI_CDECL removeInspectorPage(int32_t pageId) noexcept {
|
|
|
291
291
|
|
|
292
292
|
} // namespace
|
|
293
293
|
|
|
294
|
+
//==============================================================================
|
|
295
|
+
// HermesRuntimeHolder implementation
|
|
296
|
+
//==============================================================================
|
|
297
|
+
|
|
294
298
|
HermesRuntimeHolder::HermesRuntimeHolder(
|
|
295
299
|
std::shared_ptr<facebook::react::DevSettings> devSettings,
|
|
296
300
|
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
|
|
@@ -393,6 +397,10 @@ void HermesRuntimeHolder::removeFromProfiling() const noexcept {
|
|
|
393
397
|
CRASH_ON_ERROR(getHermesApi().hermes_sampling_profiler_dump_to_file(fileName.c_str()));
|
|
394
398
|
}
|
|
395
399
|
|
|
400
|
+
//==============================================================================
|
|
401
|
+
// HermesJSRuntime implementation
|
|
402
|
+
//==============================================================================
|
|
403
|
+
|
|
396
404
|
HermesJSRuntime::HermesJSRuntime(std::shared_ptr<Microsoft::JSI::RuntimeHolderLazyInit> hermesRuntimeHolder)
|
|
397
405
|
: m_holder(std::move(hermesRuntimeHolder)) {}
|
|
398
406
|
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -89,11 +89,6 @@
|
|
|
89
89
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\UriImageManager.idl</DependentUpon>
|
|
90
90
|
<SubType>Code</SubType>
|
|
91
91
|
</ClCompile>
|
|
92
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UriImageManager_emptyimpl.cpp">
|
|
93
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' != 'true'">true</ExcludedFromBuild>
|
|
94
|
-
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\UriImageManager.idl</DependentUpon>
|
|
95
|
-
<SubType>Code</SubType>
|
|
96
|
-
</ClCompile>
|
|
97
92
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionViewComponentView.cpp">
|
|
98
93
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
99
94
|
</ClCompile>
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
#include "pch.h"
|
|
5
|
-
|
|
6
|
-
#include "UriImageManager.h"
|
|
7
|
-
|
|
8
|
-
#include "Composition.UriImageManager.g.cpp"
|
|
9
|
-
|
|
10
|
-
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
11
|
-
|
|
12
|
-
void UriImageManager::AddUriImageProvider(
|
|
13
|
-
const winrt::Microsoft::ReactNative::IReactPropertyBag &,
|
|
14
|
-
const IUriImageProvider &) {}
|
|
15
|
-
|
|
16
|
-
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|