Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add HostTargetMetadata with app name and device name for inspector page naming",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
12 changes: 8 additions & 4 deletions vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ HRESULT UiaNavigateHelper(
uint32_t index = children.Size() - 1;
do {
auto child = children.GetAt(index).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
if (uiaProvider = child->EnsureUiaProvider()) {
uiaProvider = child->EnsureUiaProvider();
if (uiaProvider) {
break;
}
} while (index-- != 0);
Expand All @@ -60,7 +61,8 @@ HRESULT UiaNavigateHelper(
uint32_t index = 0;
do {
auto child = children.GetAt(index).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
if (uiaProvider = child->EnsureUiaProvider()) {
uiaProvider = child->EnsureUiaProvider();
if (uiaProvider) {
break;
}
} while (++index != children.Size());
Expand All @@ -74,7 +76,8 @@ HRESULT UiaNavigateHelper(

while (++it != children.end()) {
auto nextchild = (*it).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
if (uiaProvider = nextchild->EnsureUiaProvider()) {
uiaProvider = nextchild->EnsureUiaProvider();
if (uiaProvider) {
break;
}
}
Expand All @@ -91,7 +94,8 @@ HRESULT UiaNavigateHelper(
do {
it--;
auto prevchild = (*it).as<winrt::Microsoft::ReactNative::implementation::ComponentView>();
if (uiaProvider = prevchild->EnsureUiaProvider()) {
uiaProvider = prevchild->EnsureUiaProvider();
if (uiaProvider) {
break;
}
} while (it != children.begin());
Expand Down
41 changes: 35 additions & 6 deletions vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,28 @@ class ReactInspectorHostTargetDelegate : public jsinspector_modern::HostTargetDe
ReactInspectorHostTargetDelegate(Mso::WeakPtr<ReactHost> &&reactHost) noexcept : m_reactHost(std::move(reactHost)) {}

jsinspector_modern::HostTargetMetadata getMetadata() override {
// TODO: (vmoroz) provide more info
return {
.integrationName = "React Native Windows (Host)",
};
jsinspector_modern::HostTargetMetadata metadata;
metadata.integrationName = "React Native Windows (Host)";
metadata.platform = "windows";

if (Mso::CntPtr<ReactHost> reactHost = m_reactHost.GetStrongPtr()) {
auto options = reactHost->Options();
if (!options.Identity.empty()) {
std::string identity = options.Identity;
size_t lastSlash = identity.find_last_of("\\/");
metadata.appDisplayName = (lastSlash != std::string::npos && lastSlash + 1 < identity.length())
? identity.substr(lastSlash + 1)
: identity;
}
}

wchar_t computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
if (GetComputerNameW(computerName, &size)) {
metadata.deviceName = winrt::to_string(computerName);
}

return metadata;
}

void onReload(jsinspector_modern::HostTargetDelegate::PageReloadRequest const &request) override {
Expand Down Expand Up @@ -589,9 +607,20 @@ void ReactHost::AddInspectorPage() noexcept {
jsinspector_modern::InspectorTargetCapabilities capabilities;
capabilities.nativePageReloads = true;
capabilities.prefersFuseboxFrontend = true;
// TODO: (vmoroz) improve the page name

auto metadata = m_inspectorHostTargetDelegate->getMetadata();
std::string pageName;
if (metadata.appDisplayName.has_value() && !metadata.appDisplayName.value().empty()) {
pageName = metadata.appDisplayName.value();
} else {
pageName = "React Native Windows (Experimental)";
}
if (metadata.deviceName.has_value() && !metadata.deviceName.value().empty()) {
pageName += " (" + metadata.deviceName.value() + ")";
}

inspectorPageId = jsinspector_modern::getInspectorInstance().addPage(
"React Native Windows (Experimental)",
pageName,
"Hermes",
[weakInspectorHostTarget =
std::weak_ptr(m_inspectorHostTarget)](std::unique_ptr<jsinspector_modern::IRemoteConnection> remote)
Expand Down
4 changes: 3 additions & 1 deletion vnext/Mso/src/dispatchQueue/queueService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ void QueueService::InvokeTask(
DispatchTask taskToInvoke{std::move(task)};
taskToInvoke.Get()->Invoke(); // Call Get()->Invoke instead of operator() to flatten call stack

while (taskToInvoke = context.TakeNextDeferredTask()) {
taskToInvoke = context.TakeNextDeferredTask();
while (taskToInvoke) {
taskToInvoke.Get()->Invoke();
taskToInvoke = context.TakeNextDeferredTask();
}
}

Expand Down
3 changes: 2 additions & 1 deletion vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ bool UISchedulerWinRT<TDispatcherTraits>::TryTakeTask(
--m_taskCount;
}

if (queue = m_queue.GetStrongPtr()) {
queue = m_queue.GetStrongPtr();
if (queue) {
return queue->TryDequeTask(task);
}

Expand Down
3 changes: 2 additions & 1 deletion vnext/Shared/Networking/OriginPolicyHttpFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ ResponseOperation OriginPolicyHttpFilter::SendRequestAsync(HttpRequestMessage co
if (originPolicy == OriginPolicy::CrossOriginResourceSharing) {
// If inner filter can AllowRedirect, disable for preflight.
winrt::impl::com_ref<IHttpBaseProtocolFilter> baseFilter;
if (baseFilter = m_innerFilter.try_as<IHttpBaseProtocolFilter>()) {
baseFilter = m_innerFilter.try_as<IHttpBaseProtocolFilter>();
if (baseFilter) {
baseFilter.AllowAutoRedirect(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

'use strict';

import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type {ViewProps} from 'react-native';
import {codegenNativeComponent} from 'react-native';
import type {HostComponent} from '../../../../../src/private/types/HostComponent';

type XamlHostProps = $ReadOnly<{|
Expand Down
Loading