react-native-windows 0.0.0-canary.591 → 0.0.0-canary.593
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/CompositionHelpers.h +0 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +7 -5
- package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +17 -3
- package/Microsoft.ReactNative/Modules/Animated/ValueAnimatedNode.h +1 -0
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +9 -0
- package/Microsoft.ReactNative/ReactCoreInjection.cpp +16 -0
- package/Microsoft.ReactNative/ReactCoreInjection.h +3 -0
- package/Microsoft.ReactNative/ReactCoreInjection.idl +3 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +26 -3
- package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -32
- package/Microsoft.ReactNative/Utils/Helpers.h +0 -8
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +2 -1
- package/Microsoft.ReactNative/Views/KeyboardEventHandler.cpp +1 -0
- package/Microsoft.ReactNative/Views/PopupViewManager.cpp +1 -0
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +34 -1
- package/Microsoft.ReactNative/XamlHelper.cpp +36 -0
- package/Microsoft.ReactNative/XamlHelper.h +27 -0
- package/PropertySheets/Generated/PackageVersion.g.props +1 -1
- package/Shared/Composition/CompositionSwitcher.interop.h +1 -0
- package/Shared/Shared.vcxitems +1 -0
- package/Shared/Shared.vcxitems.filters +1 -0
- package/package.json +2 -2
|
@@ -548,7 +548,6 @@
|
|
|
548
548
|
<SubType>Code</SubType>
|
|
549
549
|
</ClCompile>
|
|
550
550
|
<ClCompile Include="Utils\AccessibilityUtils.cpp" />
|
|
551
|
-
<ClCompile Include="Utils\Helpers.cpp" />
|
|
552
551
|
<ClCompile Include="Utils\LocalBundleReader.cpp" />
|
|
553
552
|
<ClCompile Include="Utils\ResourceBrushUtils.cpp" />
|
|
554
553
|
<ClCompile Include="Utils\UwpPreparedScriptStore.cpp" />
|
|
@@ -272,9 +272,6 @@
|
|
|
272
272
|
<ClCompile Include="Utils\AccessibilityUtils.cpp">
|
|
273
273
|
<Filter>Utils</Filter>
|
|
274
274
|
</ClCompile>
|
|
275
|
-
<ClCompile Include="Utils\Helpers.cpp">
|
|
276
|
-
<Filter>Utils</Filter>
|
|
277
|
-
</ClCompile>
|
|
278
275
|
<ClCompile Include="Utils\LocalBundleReader.cpp">
|
|
279
276
|
<Filter>Utils</Filter>
|
|
280
277
|
</ClCompile>
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
#include "FrameAnimationDriver.h"
|
|
19
19
|
#include "SpringAnimationDriver.h"
|
|
20
20
|
|
|
21
|
+
#include <ReactCoreInjection.h>
|
|
21
22
|
#include "AnimatedNodeType.h"
|
|
22
23
|
#include "AnimationType.h"
|
|
23
24
|
#include "FacadeType.h"
|
|
24
25
|
|
|
25
|
-
#include <Modules/NativeUIManager.h>
|
|
26
|
-
#include <Modules/PaperUIManagerModule.h>
|
|
27
26
|
#include <Windows.Foundation.h>
|
|
28
27
|
#include <queue>
|
|
29
28
|
|
|
@@ -51,9 +50,13 @@ comp::Compositor NativeAnimatedNodeManager::Compositor() const noexcept {
|
|
|
51
50
|
compositionContext);
|
|
52
51
|
}
|
|
53
52
|
#endif
|
|
53
|
+
#ifndef CORE_ABI
|
|
54
54
|
// TODO: Islands - need to get the XamlView associated with this animation in order to
|
|
55
55
|
// use the compositor Microsoft::ReactNative::GetCompositor(xamlView)
|
|
56
56
|
return Microsoft::ReactNative::GetCompositor();
|
|
57
|
+
#else
|
|
58
|
+
return nullptr;
|
|
59
|
+
#endif
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
void NativeAnimatedNodeManager::CreateAnimatedNode(
|
|
@@ -460,9 +463,8 @@ void NativeAnimatedNodeManager::AddDelayedPropsNode(
|
|
|
460
463
|
#endif
|
|
461
464
|
m_delayedPropsNodes.push_back(propsNodeTag);
|
|
462
465
|
if (m_delayedPropsNodes.size() <= 1) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
+
winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::PostToUIBatchingQueue(
|
|
467
|
+
m_context.Handle(), [this]() { ProcessDelayedPropsNodes(); });
|
|
466
468
|
}
|
|
467
469
|
}
|
|
468
470
|
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
#include "pch.h"
|
|
5
5
|
|
|
6
|
+
#ifndef CORE_ABI
|
|
6
7
|
#include <Modules/NativeUIManager.h>
|
|
7
8
|
#include <Modules/PaperUIManagerModule.h>
|
|
9
|
+
#endif
|
|
10
|
+
|
|
8
11
|
#include <Utils/Helpers.h>
|
|
9
12
|
#include <Views/ShadowNodeBase.h>
|
|
10
13
|
#include <Views/XamlFeatures.h>
|
|
@@ -318,16 +321,19 @@ void PropsAnimatedNode::MakeAnimation(int64_t valueNodeTag, FacadeType facadeTyp
|
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
Microsoft::ReactNative::ShadowNodeBase *PropsAnimatedNode::GetShadowNodeBase() {
|
|
324
|
+
#ifndef CORE_ABI
|
|
321
325
|
if (const auto uiManager = Microsoft::ReactNative::GetNativeUIManager(m_context).lock()) {
|
|
322
326
|
if (const auto nativeUIManagerHost = uiManager->getHost()) {
|
|
323
327
|
return static_cast<Microsoft::ReactNative::ShadowNodeBase *>(
|
|
324
328
|
nativeUIManagerHost->FindShadowNodeForTag(m_connectedViewTag));
|
|
325
329
|
}
|
|
326
330
|
}
|
|
331
|
+
#endif
|
|
327
332
|
return nullptr;
|
|
328
333
|
}
|
|
329
334
|
|
|
330
335
|
xaml::UIElement PropsAnimatedNode::GetUIElement() {
|
|
336
|
+
#ifndef CORE_ABI
|
|
331
337
|
if (IsRS5OrHigher()) {
|
|
332
338
|
if (const auto shadowNodeBase = GetShadowNodeBase()) {
|
|
333
339
|
if (const auto shadowNodeView = shadowNodeBase->GetView()) {
|
|
@@ -335,15 +341,18 @@ xaml::UIElement PropsAnimatedNode::GetUIElement() {
|
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
}
|
|
344
|
+
#endif
|
|
338
345
|
return nullptr;
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
void PropsAnimatedNode::CommitProps() {
|
|
349
|
+
#ifndef CORE_ABI
|
|
342
350
|
if (const auto node = GetShadowNodeBase()) {
|
|
343
351
|
if (!node->m_zombie) {
|
|
344
352
|
node->updateProperties(m_props);
|
|
345
353
|
}
|
|
346
354
|
}
|
|
355
|
+
#endif
|
|
347
356
|
}
|
|
348
357
|
|
|
349
358
|
PropsAnimatedNode::AnimationView PropsAnimatedNode::GetAnimationView() {
|
|
@@ -355,7 +364,8 @@ PropsAnimatedNode::AnimationView PropsAnimatedNode::GetAnimationView() {
|
|
|
355
364
|
return {nullptr, std::static_pointer_cast<CompositionBaseComponentView>(componentView)};
|
|
356
365
|
}
|
|
357
366
|
}
|
|
358
|
-
#endif
|
|
367
|
+
#endif // USE_FABRIC
|
|
368
|
+
#ifndef CORE_ABI
|
|
359
369
|
if (IsRS5OrHigher()) {
|
|
360
370
|
if (const auto shadowNodeBase = GetShadowNodeBase()) {
|
|
361
371
|
if (const auto shadowNodeView = shadowNodeBase->GetView()) {
|
|
@@ -367,6 +377,7 @@ PropsAnimatedNode::AnimationView PropsAnimatedNode::GetAnimationView() {
|
|
|
367
377
|
}
|
|
368
378
|
}
|
|
369
379
|
}
|
|
380
|
+
#endif // CORE_ABI
|
|
370
381
|
|
|
371
382
|
#ifdef USE_FABRIC
|
|
372
383
|
return {nullptr, nullptr};
|
|
@@ -404,13 +415,16 @@ void PropsAnimatedNode::StartAnimation(
|
|
|
404
415
|
}
|
|
405
416
|
|
|
406
417
|
comp::CompositionPropertySet PropsAnimatedNode::EnsureCenterPointPropertySet(const AnimationView &view) noexcept {
|
|
418
|
+
#ifndef CORE_ABI
|
|
407
419
|
if (view.m_element) {
|
|
408
420
|
return GetShadowNodeBase()->EnsureTransformPS();
|
|
421
|
+
}
|
|
422
|
+
#endif
|
|
409
423
|
#ifdef USE_FABRIC
|
|
410
|
-
|
|
424
|
+
if (view.m_componentView) {
|
|
411
425
|
return view.m_componentView->EnsureCenterPointPropertySet();
|
|
412
|
-
#endif
|
|
413
426
|
}
|
|
427
|
+
#endif
|
|
414
428
|
return nullptr;
|
|
415
429
|
}
|
|
416
430
|
|
|
@@ -626,6 +626,15 @@ static void StyleYogaNode(
|
|
|
626
626
|
YGValue result = YGValueOrDefault(value, YGValue{YGUndefined, YGUnitPoint} /*default*/, shadowNode, key);
|
|
627
627
|
|
|
628
628
|
SetYogaUnitValueHelper(yogaNode, result, YGNodeStyleSetMaxHeight, YGNodeStyleSetMaxHeightPercent);
|
|
629
|
+
} else if (key == "rowGap") {
|
|
630
|
+
float result = NumberOrDefault(value, 0.0f /*default*/);
|
|
631
|
+
YGNodeStyleSetGap(yogaNode, YGGutterRow, result);
|
|
632
|
+
} else if (key == "columnGap") {
|
|
633
|
+
float result = NumberOrDefault(value, 0.0f /*default*/);
|
|
634
|
+
YGNodeStyleSetGap(yogaNode, YGGutterColumn, result);
|
|
635
|
+
} else if (key == "gap") {
|
|
636
|
+
float result = NumberOrDefault(value, 0.0f /*default*/);
|
|
637
|
+
YGNodeStyleSetGap(yogaNode, YGGutterAll, result);
|
|
629
638
|
} else if (key == "margin") {
|
|
630
639
|
YGValue result = YGValueOrDefault(value, YGValue{YGUndefined, YGUnitPoint} /*default*/, shadowNode, key);
|
|
631
640
|
|
|
@@ -80,6 +80,22 @@ ReactCoreInjection::PostToUIBatchingQueueProperty() noexcept {
|
|
|
80
80
|
postFn(callback);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
ReactPropertyId<winrt::hstring> PlatformNameOverrideProperty() noexcept {
|
|
84
|
+
static ReactPropertyId<winrt::hstring> prop{L"ReactNative.Injection", L"PlatformNameOverride"};
|
|
85
|
+
return prop;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/*static*/ void ReactCoreInjection::SetPlatformNameOverride(
|
|
89
|
+
IReactPropertyBag const &properties,
|
|
90
|
+
winrt::hstring const &platformName) noexcept {
|
|
91
|
+
ReactNative::ReactPropertyBag(properties).Set(PlatformNameOverrideProperty(), platformName);
|
|
92
|
+
}
|
|
93
|
+
/*static*/ std::string ReactCoreInjection::GetPlatformName(IReactPropertyBag const &properties) noexcept {
|
|
94
|
+
return winrt::to_string(ReactNative::ReactPropertyBag(properties)
|
|
95
|
+
.Get(PlatformNameOverrideProperty())
|
|
96
|
+
.value_or(winrt::to_hstring(STRING(RN_PLATFORM))));
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
ReactViewHost::ReactViewHost(
|
|
84
100
|
const ReactNative::ReactNativeHost &host,
|
|
85
101
|
Mso::React::IReactViewHost &viewHost,
|
|
@@ -46,6 +46,9 @@ struct ReactCoreInjection : ReactCoreInjectionT<ReactCoreInjection> {
|
|
|
46
46
|
static void PostToUIBatchingQueue(
|
|
47
47
|
ReactNative::IReactContext context,
|
|
48
48
|
ReactNative::ReactDispatcherCallback callback) noexcept;
|
|
49
|
+
|
|
50
|
+
static void SetPlatformNameOverride(IReactPropertyBag const &properties, winrt::hstring const &platformName) noexcept;
|
|
51
|
+
static std::string GetPlatformName(IReactPropertyBag const &properties) noexcept;
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
struct ReactViewHost : public winrt::implements<ReactViewHost, IReactViewHost> {
|
|
@@ -89,6 +89,9 @@ DOC_STRING("Settings per each IReactViewHost associated with an IReactHost insta
|
|
|
89
89
|
|
|
90
90
|
DOC_STRING("Post something to the main UI dispatcher using the batching queue")
|
|
91
91
|
static void PostToUIBatchingQueue(IReactContext context, ReactDispatcherCallback callback);
|
|
92
|
+
|
|
93
|
+
DOC_STRING("Override platform name. This will change the platform used when requesting bundles from metro. Default: \"windows\"")
|
|
94
|
+
static void SetPlatformNameOverride(IReactPropertyBag properties, String platformName);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
|
|
@@ -42,16 +42,24 @@
|
|
|
42
42
|
#ifndef CORE_ABI
|
|
43
43
|
#include "Modules/AccessibilityInfoModule.h"
|
|
44
44
|
#include "Modules/AlertModule.h"
|
|
45
|
+
#endif
|
|
46
|
+
#if !defined(CORE_ABI) || defined(USE_FABRIC)
|
|
45
47
|
#include "Modules/Animated/NativeAnimatedModule.h"
|
|
48
|
+
#endif
|
|
49
|
+
#ifndef CORE_ABI
|
|
46
50
|
#include "Modules/AppStateModule.h"
|
|
47
51
|
#include "Modules/AppThemeModuleUwp.h"
|
|
48
52
|
#include "Modules/ClipboardModule.h"
|
|
49
53
|
#endif
|
|
50
54
|
#include "Modules/DevSettingsModule.h"
|
|
51
55
|
#ifndef CORE_ABI
|
|
52
|
-
#include <Modules/ImageViewManagerModule.h>
|
|
53
56
|
#include "Modules/DeviceInfoModule.h"
|
|
54
57
|
#include "Modules/I18nManagerModule.h"
|
|
58
|
+
#endif
|
|
59
|
+
#if !defined(CORE_ABI) || defined(USE_FABRIC)
|
|
60
|
+
#include <Modules/ImageViewManagerModule.h>
|
|
61
|
+
#endif
|
|
62
|
+
#ifndef CORE_ABI
|
|
55
63
|
#include "Modules/LinkingManagerModule.h"
|
|
56
64
|
#include "Modules/LogBoxModule.h"
|
|
57
65
|
#include "Modules/NativeUIManager.h"
|
|
@@ -78,6 +86,7 @@
|
|
|
78
86
|
#include <tuple>
|
|
79
87
|
#include "ChakraRuntimeHolder.h"
|
|
80
88
|
|
|
89
|
+
#include <Utils/Helpers.h>
|
|
81
90
|
#include "CrashManager.h"
|
|
82
91
|
#include "JsiApi.h"
|
|
83
92
|
#include "ReactCoreInjection.h"
|
|
@@ -355,6 +364,17 @@ void ReactInstanceWin::LoadModules(
|
|
|
355
364
|
registerTurboModule(
|
|
356
365
|
L"NativeAnimatedModule",
|
|
357
366
|
winrt::Microsoft::ReactNative::MakeModuleProvider<::Microsoft::ReactNative::NativeAnimatedModule>());
|
|
367
|
+
|
|
368
|
+
#elif defined(CORE_ABI) && defined(USE_FABRIC)
|
|
369
|
+
if (Microsoft::ReactNative::IsFabricEnabled(m_reactContext->Properties())) {
|
|
370
|
+
registerTurboModule(
|
|
371
|
+
L"ImageLoader",
|
|
372
|
+
winrt::Microsoft::ReactNative::MakeTurboModuleProvider<::Microsoft::ReactNative::ImageLoader>());
|
|
373
|
+
|
|
374
|
+
registerTurboModule(
|
|
375
|
+
L"NativeAnimatedModule",
|
|
376
|
+
winrt::Microsoft::ReactNative::MakeModuleProvider<::Microsoft::ReactNative::NativeAnimatedModule>());
|
|
377
|
+
}
|
|
358
378
|
#endif
|
|
359
379
|
|
|
360
380
|
registerTurboModule(
|
|
@@ -421,7 +441,9 @@ void ReactInstanceWin::Initialize() noexcept {
|
|
|
421
441
|
devSettings->useWebDebugger = m_useWebDebugger;
|
|
422
442
|
devSettings->useFastRefresh = m_isFastReloadEnabled;
|
|
423
443
|
devSettings->bundleRootPath = BundleRootPath();
|
|
424
|
-
|
|
444
|
+
devSettings->platformName =
|
|
445
|
+
winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetPlatformName(
|
|
446
|
+
strongThis->m_reactContext->Properties());
|
|
425
447
|
devSettings->waitingForDebuggerCallback = GetWaitingForDebuggerCallback();
|
|
426
448
|
devSettings->debuggerAttachCallback = GetDebuggerAttachCallback();
|
|
427
449
|
|
|
@@ -541,7 +563,8 @@ void ReactInstanceWin::Initialize() noexcept {
|
|
|
541
563
|
|
|
542
564
|
if (UseDeveloperSupport() && State() != ReactInstanceState::HasError) {
|
|
543
565
|
folly::dynamic params = folly::dynamic::array(
|
|
544
|
-
|
|
566
|
+
winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetPlatformName(
|
|
567
|
+
m_reactContext->Properties()),
|
|
545
568
|
DebugBundlePath(),
|
|
546
569
|
SourceBundleHost(),
|
|
547
570
|
SourceBundlePort(),
|
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
#include "pch.h"
|
|
5
5
|
|
|
6
|
-
#include <Modules/NativeUIManager.h>
|
|
7
|
-
#include <UI.Xaml.Media.h>
|
|
8
6
|
#include <Utils/Helpers.h>
|
|
9
7
|
#include <winrt/Windows.Foundation.Metadata.h>
|
|
10
8
|
|
|
11
|
-
#include <Modules/PaperUIManagerModule.h>
|
|
12
9
|
#include <appmodel.h>
|
|
13
10
|
#include <processthreadsapi.h>
|
|
14
11
|
|
|
@@ -24,35 +21,6 @@ using namespace Windows::Foundation::Metadata;
|
|
|
24
21
|
|
|
25
22
|
namespace Microsoft::ReactNative {
|
|
26
23
|
|
|
27
|
-
// Not only react-native, native modules could set tag too for controls.
|
|
28
|
-
// For example, to identify an clicked item, customer may add tag in
|
|
29
|
-
// NavigationView since content for the two NavigationViewItem are empty.
|
|
30
|
-
//
|
|
31
|
-
// <NavigationView>
|
|
32
|
-
// <NavigationViewItem Icon="Accept" Tag="1" />
|
|
33
|
-
// <NavigationViewItem Icon="Accept" Tag="2" />
|
|
34
|
-
// </NavigationView>
|
|
35
|
-
// Instead of deduce view id directly from FrameworkElement.Tag, this do
|
|
36
|
-
// additional check by uimanager.
|
|
37
|
-
ReactId getViewId(const Mso::React::IReactContext &context, xaml::FrameworkElement const &fe) {
|
|
38
|
-
ReactId reactId{};
|
|
39
|
-
if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(context).lock()) {
|
|
40
|
-
if (auto peer = uiManager->reactPeerOrContainerFrom(fe)) {
|
|
41
|
-
reactId.isValid = true;
|
|
42
|
-
reactId.tag = Microsoft::ReactNative::GetTag(peer);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return reactId;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
std::int32_t CountOpenPopups() {
|
|
49
|
-
// TODO: Use VisualTreeHelper::GetOpenPopupsFromXamlRoot when running against
|
|
50
|
-
// RS6
|
|
51
|
-
winrt::Windows::Foundation::Collections::IVectorView<xaml::Controls::Primitives::Popup> popups =
|
|
52
|
-
xaml::Media::VisualTreeHelper::GetOpenPopups(xaml::Window::Current());
|
|
53
|
-
return (int32_t)popups.Size();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
24
|
template <uint16_t APIVersion>
|
|
57
25
|
bool IsAPIContractVxAvailable() {
|
|
58
26
|
static bool isAPIContractVxAvailableInitialized = false;
|
|
@@ -12,19 +12,11 @@ namespace Microsoft::ReactNative {
|
|
|
12
12
|
|
|
13
13
|
using namespace std;
|
|
14
14
|
|
|
15
|
-
struct ReactId {
|
|
16
|
-
int64_t tag{0};
|
|
17
|
-
bool isValid{false};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
15
|
template <typename T>
|
|
21
16
|
inline T asEnum(winrt::Microsoft::ReactNative::JSValue const &obj) {
|
|
22
17
|
return static_cast<T>(obj.AsInt64());
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
ReactId getViewId(const Mso::React::IReactContext &context, xaml::FrameworkElement const &fe);
|
|
26
|
-
std::int32_t CountOpenPopups();
|
|
27
|
-
|
|
28
20
|
bool IsRS3OrHigher();
|
|
29
21
|
bool IsRS4OrHigher();
|
|
30
22
|
bool IsRS5OrHigher();
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#include <UI.Xaml.Media.h>
|
|
18
18
|
#include <Utils/Helpers.h>
|
|
19
19
|
#include <Utils/PropertyHandlerUtils.h>
|
|
20
|
+
#include <XamlHelper.h>
|
|
20
21
|
|
|
21
22
|
#ifdef USE_WINUI3
|
|
22
23
|
namespace winrt::Microsoft::UI::Xaml::Controls::Primitives {
|
|
@@ -122,7 +123,7 @@ class FlyoutShadowNode : public ShadowNodeBase {
|
|
|
122
123
|
winrt::Popup GetFlyoutParentPopup() const;
|
|
123
124
|
winrt::FlyoutPresenter GetFlyoutPresenter() const;
|
|
124
125
|
void OnShowFlyout();
|
|
125
|
-
void LogErrorAndClose(const string &error);
|
|
126
|
+
void LogErrorAndClose(const std::string &error);
|
|
126
127
|
xaml::FrameworkElement m_targetElement = nullptr;
|
|
127
128
|
winrt::Flyout m_flyout = nullptr;
|
|
128
129
|
bool m_isLightDismissEnabled = true;
|
|
@@ -718,9 +718,42 @@ void TextInputShadowNode::SetText(const winrt::Microsoft::ReactNative::JSValue &
|
|
|
718
718
|
auto oldValue = textBox.Text();
|
|
719
719
|
auto newValue = asHstring(text);
|
|
720
720
|
if (oldValue != newValue) {
|
|
721
|
-
textBox.
|
|
721
|
+
if (!textBox.IsReadOnly()) {
|
|
722
|
+
uint32_t diffStartIndex = 0;
|
|
723
|
+
uint32_t diffEndIndex = 0;
|
|
724
|
+
// Replacing the entire string with the new value resets the text history.
|
|
725
|
+
// Generally speaking, this is undesirable. To mitigate this issue, we can
|
|
726
|
+
// replace text using the XAML TextBox::SelectedText property, which retains
|
|
727
|
+
// undo / redo history. To do so, we use a simple algorithm that finds a
|
|
728
|
+
// single diff in the values:
|
|
729
|
+
// 1. Find first character that mismatches iterating forwards
|
|
730
|
+
while (diffStartIndex < oldValue.size() && diffStartIndex < newValue.size() &&
|
|
731
|
+
oldValue[diffStartIndex] == newValue[diffStartIndex]) {
|
|
732
|
+
diffStartIndex++;
|
|
733
|
+
}
|
|
734
|
+
// 2. Find last character the mismatches beyond the first mismatch iterating backwards
|
|
735
|
+
while (diffEndIndex < oldValue.size() - diffStartIndex && diffEndIndex < newValue.size() - diffStartIndex &&
|
|
736
|
+
oldValue[oldValue.size() - diffEndIndex - 1] == newValue[newValue.size() - diffEndIndex - 1]) {
|
|
737
|
+
diffEndIndex++;
|
|
738
|
+
}
|
|
739
|
+
// 3. Select the range between the start and end index in the "old value"
|
|
740
|
+
textBox.SelectionStart(diffStartIndex);
|
|
741
|
+
textBox.SelectionLength(oldValue.size() - diffStartIndex - diffEndIndex);
|
|
742
|
+
// 4. Replace the selected text with the range between start and end index in the "new value"
|
|
743
|
+
// Copies the substring view into a new winrt::hstring due to occasional crash
|
|
744
|
+
winrt::hstring replacementValue{
|
|
745
|
+
std::wstring_view{newValue}.substr(diffStartIndex, newValue.size() - diffStartIndex - diffEndIndex)};
|
|
746
|
+
textBox.SelectedText(replacementValue);
|
|
747
|
+
} else {
|
|
748
|
+
textBox.Text(newValue);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// Update selection based on the following algorithm:
|
|
752
|
+
// 1. If the new value is the same length as the old value, retain the selection state (start and length)
|
|
753
|
+
// 2. Else set the selection start to the end of the string
|
|
722
754
|
if (oldValue.size() == newValue.size()) {
|
|
723
755
|
textBox.SelectionStart(oldCursor);
|
|
756
|
+
textBox.SelectionLength(oldSelectionLength);
|
|
724
757
|
} else {
|
|
725
758
|
textBox.SelectionStart(newValue.size());
|
|
726
759
|
}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
#include "XamlHelper.h"
|
|
6
6
|
#include "XamlHelper.g.cpp"
|
|
7
7
|
|
|
8
|
+
#include <Modules/NativeUIManager.h>
|
|
9
|
+
#include <Modules/PaperUIManagerModule.h>
|
|
10
|
+
#include <UI.Xaml.Media.h>
|
|
8
11
|
#include <Utils/ValueUtils.h>
|
|
9
12
|
#include "DynamicWriter.h"
|
|
10
13
|
#include "XamlView.h"
|
|
@@ -40,3 +43,36 @@ folly::dynamic XamlHelper::GetFollyDynamicFromValueProvider(JSValueArgWriter con
|
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
46
|
+
|
|
47
|
+
namespace Microsoft::ReactNative {
|
|
48
|
+
|
|
49
|
+
// Not only react-native, native modules could set tag too for controls.
|
|
50
|
+
// For example, to identify an clicked item, customer may add tag in
|
|
51
|
+
// NavigationView since content for the two NavigationViewItem are empty.
|
|
52
|
+
//
|
|
53
|
+
// <NavigationView>
|
|
54
|
+
// <NavigationViewItem Icon="Accept" Tag="1" />
|
|
55
|
+
// <NavigationViewItem Icon="Accept" Tag="2" />
|
|
56
|
+
// </NavigationView>
|
|
57
|
+
// Instead of deduce view id directly from FrameworkElement.Tag, this do
|
|
58
|
+
// additional check by uimanager.
|
|
59
|
+
ReactId getViewId(const Mso::React::IReactContext &context, xaml::FrameworkElement const &fe) {
|
|
60
|
+
ReactId reactId{};
|
|
61
|
+
if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(context).lock()) {
|
|
62
|
+
if (auto peer = uiManager->reactPeerOrContainerFrom(fe)) {
|
|
63
|
+
reactId.isValid = true;
|
|
64
|
+
reactId.tag = Microsoft::ReactNative::GetTag(peer);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return reactId;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
std::int32_t CountOpenPopups() {
|
|
71
|
+
// TODO: Use VisualTreeHelper::GetOpenPopupsFromXamlRoot when running against
|
|
72
|
+
// RS6
|
|
73
|
+
winrt::Windows::Foundation::Collections::IVectorView<xaml::Controls::Primitives::Popup> popups =
|
|
74
|
+
xaml::Media::VisualTreeHelper::GetOpenPopups(xaml::Window::Current());
|
|
75
|
+
return (int32_t)popups.Size();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
#include "XamlHelper.g.h"
|
|
6
6
|
#include "Base/FollyIncludes.h"
|
|
7
7
|
|
|
8
|
+
namespace Mso::React {
|
|
9
|
+
struct IReactContext;
|
|
10
|
+
} // namespace Mso::React
|
|
11
|
+
|
|
8
12
|
namespace winrt::Microsoft::ReactNative::implementation {
|
|
9
13
|
|
|
10
14
|
struct XamlHelper : XamlHelperT<XamlHelper> {
|
|
@@ -25,3 +29,26 @@ struct XamlHelper : XamlHelperT<XamlHelper> {
|
|
|
25
29
|
namespace winrt::Microsoft::ReactNative::factory_implementation {
|
|
26
30
|
struct XamlHelper : XamlHelperT<XamlHelper, implementation::XamlHelper> {};
|
|
27
31
|
} // namespace winrt::Microsoft::ReactNative::factory_implementation
|
|
32
|
+
|
|
33
|
+
namespace Microsoft::ReactNative {
|
|
34
|
+
|
|
35
|
+
struct ReactId {
|
|
36
|
+
int64_t tag{0};
|
|
37
|
+
bool isValid{false};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Not only react-native, native modules could set tag too for controls.
|
|
41
|
+
// For example, to identify an clicked item, customer may add tag in
|
|
42
|
+
// NavigationView since content for the two NavigationViewItem are empty.
|
|
43
|
+
//
|
|
44
|
+
// <NavigationView>
|
|
45
|
+
// <NavigationViewItem Icon="Accept" Tag="1" />
|
|
46
|
+
// <NavigationViewItem Icon="Accept" Tag="2" />
|
|
47
|
+
// </NavigationView>
|
|
48
|
+
// Instead of deduce view id directly from FrameworkElement.Tag, this do
|
|
49
|
+
// additional check by uimanager.
|
|
50
|
+
ReactId getViewId(const Mso::React::IReactContext &context, xaml::FrameworkElement const &fe);
|
|
51
|
+
|
|
52
|
+
std::int32_t CountOpenPopups();
|
|
53
|
+
|
|
54
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.0.0-canary.
|
|
13
|
+
<ReactNativeWindowsVersion>0.0.0-canary.593</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
<ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
|
|
164
164
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />
|
|
165
165
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
|
|
166
|
+
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\Helpers.cpp" />
|
|
166
167
|
</ItemGroup>
|
|
167
168
|
<ItemGroup>
|
|
168
169
|
<None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp" />
|
|
@@ -156,6 +156,7 @@
|
|
|
156
156
|
<Filter>Source Files\Modules</Filter>
|
|
157
157
|
</ClCompile>
|
|
158
158
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ImageUtils.cpp" />
|
|
159
|
+
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\Helpers.cpp" />
|
|
159
160
|
</ItemGroup>
|
|
160
161
|
<ItemGroup>
|
|
161
162
|
<Filter Include="Source Files">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.593",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"prettier": "^2.4.1",
|
|
79
79
|
"react": "18.2.0",
|
|
80
80
|
"react-native": "0.0.0-20221120-2051-81e441ae8",
|
|
81
|
-
"react-native-platform-override": "^1.8.
|
|
81
|
+
"react-native-platform-override": "^1.8.4",
|
|
82
82
|
"react-refresh": "^0.4.0",
|
|
83
83
|
"typescript": "^4.4.4"
|
|
84
84
|
},
|