Skip to content

Commit 91192a3

Browse files
Yajur-Groversharath2727acoates-mschiaramooneyjonthysell
authored
[0.75] Cherry-pick Fabric changes (#13948)
* Introduce ReactNativeAppBuilder (#13368) * Introduce ReactNativeAppBuilder.idl * yarn format fix * Change files * Address feedback * Add a fabric check for ReactNativeAppBuilder * yarn format * Update reactnativeappbuilder (#13467) * Build reactnativeappbuilder * Setup reactnativewin32 app * Fix dispatcherqueue issue * Change files * Cleanup * Address feedback * Address feedback2 * Fix pipeline error * Fix pipeline errors * Address feedback * [Fabric] Fix crash when running inspect (#13592) * [Fabric] Fix crash when running inspect * Change files * fix * [Fabric] LogBox should destroy its window on instance shutdown (#13675) * [Fabric] LogBox should destroy its window on instance shutdown * Change files * format * [Fabric] Add FocusNavigationDirection and allow overriding of default command handling (#13857) * [Fabric] Add FocusNavigationDirection and allow overriding of default command handling * Change files * revert packages.lock * [Fabric] LayoutDirection and FontSizeMultiplier support (#13866) * [Fabric] LayoutDirection and FontSizeMultiplier support * Change files * Missed a few places not setting LayoutDirection * fix crash on logbox * Fix textinput caret * fix * RichEdit has to be told its multiline before we can set a multiline string * Update SampleAppFabric to use ReactNativeAppBuilder (#13382) * Update SampleAppFabric to use ReactNativeAppBuilder * Yarn format fix * Address feedback to keep BUNDLE and DEBUG * Yarn format * Change files * Setup the DebugBundlePath when loading from metro * fix typo * [Fabric] Enable ScrollView touch scrolling (#13664) * [Fabric] Enable ScrolView touch scrolling * Change files * format * typo * [Fabric] Add Support for accessibilityActions and onAccessibilityAction (#13674) * Add Implementation for accessibilityActions * Add activate action * Format * Change files * Use a legacy native module binding that always returns null in bridgeless mode (#13905) * Use a legacy native module binding that always returns null in bridgeless mode * Change files * format * SampleTurboModule only works as a turbomodule, so do not install it when using web debugger (#13911) * SampleTurboModule only works as a turbomodule, so do not install it when using web debugger * Change files * fix * Implement the SampleTurboModule module (#13541) This PR provides a proper implementation of the `SampleTurboModule` module and removes the proxy code in `TurboModuleManager` which instead substituted the old `SampleTurboCxxModule` module. - New feature (non-breaking change which adds functionality) The APIs of `SampleTurboModule` are starting to deviate from the older `SampleTurboCxxModule`, specifically the addition of new `EventEmitter` members. So it's time we had a "real" implementation of `SampleTurboModule`. Closes #13531 See above. N/A Verified tests still pass and the new module is being called. Should this change be included in the release notes: _yes_ Implement the SampleTurboModule module * fix previous merge * fix bad merge * fix more typos * update snapshots --------- Co-authored-by: Sharath Manchala <[email protected]> Co-authored-by: Andrew Coates <[email protected]> Co-authored-by: Chiara Mooney <[email protected]> Co-authored-by: Jon Thysell <[email protected]>
1 parent ac7ecfa commit 91192a3

File tree

81 files changed

+1459
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1459
-683
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Add FocusNavigationDirection and allow overriding of default command handling",
4+
"packageName": "@react-native-windows/codegen",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Fix crash when running inspect",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] LogBox should destroy its window on instance shutdown",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Use a legacy native module binding that always returns null in bridgeless mode",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Add FocusNavigationDirection and allow overriding of default command handling",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Enable ScrollView touch scrolling",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Implement SampleTurboModule",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "SampleTurboModule only works as a turbomodule, so do not install it when using web debugger",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Update SampleAppFabric to use ReactNativeAppBuilder",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Introduce ReactNativeAppBuilder.idl",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Add Implementation for accessibilityActions",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Setup reactnativewin32 app",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] LayoutDirection and FontSizeMultiplier support",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/@react-native-windows/codegen/src/generators/GenerateComponentWindows.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,28 +334,27 @@ export function createComponentGenerator({
334334
}).join('\n\n') : '';
335335

336336

337-
const commandHandler = hasAnyCommands ? `void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, winrt::hstring commandName, const winrt::Microsoft::ReactNative::IJSValueReader &args) noexcept {
338-
args;
337+
const commandHandler = hasAnyCommands ? `void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
339338
auto userData = view.UserData().as<TUserData>();
339+
auto commandName = args.CommandName();
340340
${componentShape.commands.map(command => {
341341
const commaSeparatedCommandArgs = command.typeAnnotation.params.map(param => param.name).join(', ');
342342
return ` if (commandName == L"${command.name}") {
343343
${command.typeAnnotation.params.length !== 0 ? ` ${command.typeAnnotation.params.map(param => {
344344
const commandArgType = translateCommandParamType(param.typeAnnotation, commandAliases, `${componentName}_${command.name}`, cppCodegenOptions);
345345
return `${(param.optional && !commandArgType.alreadySupportsOptionalOrHasDefault) ? `std::optional<${commandArgType.type}>` : commandArgType.type} ${param.name};`;
346346
}).join('\n')}
347-
winrt::Microsoft::ReactNative::ReadArgs(args, ${commaSeparatedCommandArgs});` : ''}
347+
winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), ${commaSeparatedCommandArgs});` : ''}
348348
userData->Handle${capitalizeFirstLetter(command.name)}Command(${commaSeparatedCommandArgs});
349349
return;
350350
}`
351351
}).join('\n\n')}
352352
}` : '';
353353

354354
const registerCommandHandler = hasAnyCommands ? ` builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
355-
winrt::hstring commandName,
356-
const winrt::Microsoft::ReactNative::IJSValueReader &args) noexcept {
355+
const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
357356
auto userData = view.UserData().as<TUserData>();
358-
userData->HandleCommand(view, commandName, args);
357+
userData->HandleCommand(view, args);
359358
});` : '';
360359

361360
const baseType = baseStructTemplate

packages/e2e-test-app-fabric/test/__snapshots__/TextInputComponentTest.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ exports[`TextInput Tests Text have cursorColor 1`] = `
379379
"Brush Type": "ColorBrush",
380380
"Color": "rgba(0, 128, 0, 255)",
381381
},
382-
"Offset": "83, 133, 0",
382+
"Offset": "83, 5, 0",
383383
"Opacity": 0,
384384
"Size": "1, 19",
385385
"Visual Type": "SpriteVisual",
@@ -1612,7 +1612,7 @@ exports[`TextInput Tests TextInputs can clear on submit 1`] = `
16121612
"Brush Type": "ColorBrush",
16131613
"Color": "rgba(0, 0, 0, 255)",
16141614
},
1615-
"Offset": "5, 133, 0",
1615+
"Offset": "5, 5, 0",
16161616
"Opacity": 0,
16171617
"Size": "1, 19",
16181618
"Visual Type": "SpriteVisual",

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric/RNTesterApp-Fabric.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void UpdateRootViewSizeToAppWindow(
5151
if (window.Presenter().as<winrt::Microsoft::UI::Windowing::OverlappedPresenter>().State() !=
5252
winrt::Microsoft::UI::Windowing::OverlappedPresenterState::Minimized) {
5353
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
54+
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
5455
constraints.MaximumSize = constraints.MinimumSize = size;
5556
rootView.Arrange(constraints, {0, 0});
5657
}

packages/playground/windows/playground-composition/Playground-Composition.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct WindowData {
128128
winrt::Microsoft::ReactNative::ReactInstanceSettings m_instanceSettings{nullptr};
129129
bool m_useLiftedComposition{true};
130130
bool m_sizeToContent{false};
131+
bool m_forceRTL{false};
131132
winrt::Windows::UI::Composition::Desktop::DesktopWindowTarget m_target{nullptr};
132133
LONG m_height{0};
133134
LONG m_width{0};
@@ -252,14 +253,18 @@ struct WindowData {
252253
m_bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
253254
g_liftedCompositor, winrt::Microsoft::UI::GetWindowIdFromWindow(hwnd));
254255

256+
if (m_forceRTL) {
257+
m_bridge.LayoutDirectionOverride(winrt::Microsoft::UI::Content::ContentLayoutDirection::RightToLeft);
258+
}
259+
255260
auto appContent = m_compRootView.Island();
256261

257262
m_bridge.Connect(appContent);
258263
m_bridge.Show();
259264

260265
m_compRootView.ScaleFactor(ScaleFactor(hwnd));
261266
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
262-
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight;
267+
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
263268
constraints.MaximumSize =
264269
constraints.MinimumSize = {m_width / ScaleFactor(hwnd), m_height / ScaleFactor(hwnd)};
265270

@@ -324,6 +329,7 @@ struct WindowData {
324329
SystemCompositionContextHelper::CreateVisual(root));
325330
m_compRootView.ScaleFactor(ScaleFactor(hwnd));
326331
winrt::Microsoft::ReactNative::LayoutConstraints contraints;
332+
contraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
327333
contraints.MaximumSize =
328334
contraints.MinimumSize = {m_width / ScaleFactor(hwnd), m_height / ScaleFactor(hwnd)};
329335
m_compRootView.Arrange(contraints, {0, 0});
@@ -368,15 +374,25 @@ struct WindowData {
368374
OutputDebugStringA("Instance Unload completed\n");
369375

370376
uidispatch.Post([&]() {
371-
m_bridge.Close();
372-
m_bridge = nullptr;
377+
if (m_bridge) {
378+
m_bridge.Close();
379+
m_bridge = nullptr;
380+
}
373381
});
374382
assert(asyncStatus == winrt::Windows::Foundation::AsyncStatus::Completed);
375383
});
376384
m_compRootView = nullptr;
377385
m_instanceSettings = nullptr;
378386
m_host = nullptr;
379387
} break;
388+
case IDM_TOGGLE_LAYOUT_DIRECTION: {
389+
if (m_bridge) {
390+
m_bridge.LayoutDirectionOverride(
391+
(m_forceRTL) ? winrt::Microsoft::UI::Content::ContentLayoutDirection::LeftToRight
392+
: winrt::Microsoft::UI::Content::ContentLayoutDirection::RightToLeft);
393+
}
394+
m_forceRTL = !m_forceRTL;
395+
}
380396
}
381397

382398
return 0;
@@ -397,7 +413,7 @@ struct WindowData {
397413
winrt::Windows::Foundation::Size size{m_width / ScaleFactor(hwnd), m_height / ScaleFactor(hwnd)};
398414
if (!IsIconic(hwnd)) {
399415
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
400-
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight;
416+
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
401417
constraints.MinimumSize = constraints.MaximumSize = size;
402418
if (m_sizeToContent) {
403419
ApplyConstraintsForContentSizedWindow(constraints);

packages/playground/windows/playground-composition/Playground-Composition.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ BEGIN
5858
MENUITEM "&New Window\tCtrl+N", IDM_NEWWINDOW
5959
MENUITEM "&Refresh\tF5", IDM_REFRESH
6060
MENUITEM "&Unload", IDM_UNLOAD
61+
MENUITEM "Toggle Layout &Direction", IDM_TOGGLE_LAYOUT_DIRECTION
6162
MENUITEM SEPARATOR
6263
MENUITEM "&Settings...\tAlt+S", IDM_SETTINGS
6364
MENUITEM SEPARATOR

packages/playground/windows/playground-composition/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define IDC_JSENGINELABEL 111
2626
#define IDC_SIZETOCONTENT 112
2727
#define IDM_UNLOAD 113
28+
#define IDM_TOGGLE_LAYOUT_DIRECTION 114
2829
#define IDI_ICON1 1008
2930

3031
// Next default values for new objects

0 commit comments

Comments
 (0)