收口移动外链桥接系统调用
将 Expo app.openExternalUrl 的 Linking 调用收口到 navigation 模块 让移动 dispatch 只委托外链请求载荷 同步移动壳配置门禁和共享记忆
This commit is contained in:
@@ -1668,7 +1668,7 @@ if (
|
||||
'const externalUrlPayload = normalizeHostBridgeExternalUrlPayload(',
|
||||
) ||
|
||||
!hostBridgeNavigationSource.includes(
|
||||
'openMobileShellExternalNavigation(navigator, externalUrlPayload.url)',
|
||||
'openMobileShellExternalNavigation(Linking, externalUrlPayload.url)',
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
@@ -1928,9 +1928,11 @@ for (const snippet of [
|
||||
}
|
||||
|
||||
if (
|
||||
!dispatchSource.includes('openMobileHostBridgeExternalUrl(Linking, request.payload)') ||
|
||||
!dispatchSource.includes('openMobileHostBridgeExternalUrl(request.payload)') ||
|
||||
!dispatchSource.includes('openMobileHostBridgeNativePage(navigation, request.payload)') ||
|
||||
!dispatchSource.includes('reloadMobileHostBridgeWebView(navigation)') ||
|
||||
dispatchSource.includes("from 'expo-linking'") ||
|
||||
dispatchSource.includes('Linking.') ||
|
||||
dispatchSource.includes('openMobileShellExternalNavigation') ||
|
||||
dispatchSource.includes('resolveMobileShellWebViewUrl') ||
|
||||
dispatchSource.includes('normalizeHostBridgeExternalUrlPayload') ||
|
||||
@@ -1940,7 +1942,8 @@ if (
|
||||
}
|
||||
for (const snippet of [
|
||||
'openMobileHostBridgeExternalUrl',
|
||||
'openMobileShellExternalNavigation(navigator, externalUrlPayload.url)',
|
||||
"import * as Linking from 'expo-linking'",
|
||||
'openMobileShellExternalNavigation(Linking, externalUrlPayload.url)',
|
||||
'normalizeHostBridgeExternalUrlPayload',
|
||||
'openMobileHostBridgeNativePage',
|
||||
'resolveMobileShellWebViewUrl',
|
||||
@@ -1952,7 +1955,7 @@ for (const snippet of [
|
||||
}
|
||||
}
|
||||
|
||||
if (!hostBridgeNavigationSource.includes('openMobileShellExternalNavigation(navigator, externalUrlPayload.url)')) {
|
||||
if (!hostBridgeNavigationSource.includes('openMobileShellExternalNavigation(Linking, externalUrlPayload.url)')) {
|
||||
throw new Error(
|
||||
'mobile shell HostBridge external URL flow must use the shared external navigation helper',
|
||||
);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import * as Linking from 'expo-linking';
|
||||
|
||||
import { type HostBridgeRequest } from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import {
|
||||
captureImageFile,
|
||||
@@ -56,10 +54,7 @@ export async function dispatchMobileHostBridgeRequest(
|
||||
case 'appearance.getColorScheme':
|
||||
return ok(request, getMobileAppearanceColorScheme());
|
||||
case 'app.openExternalUrl':
|
||||
return ok(
|
||||
request,
|
||||
await openMobileHostBridgeExternalUrl(Linking, request.payload),
|
||||
);
|
||||
return ok(request, await openMobileHostBridgeExternalUrl(request.payload));
|
||||
case 'app.reloadWebView':
|
||||
return ok(request, reloadMobileHostBridgeWebView(navigation));
|
||||
case 'network.status':
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import * as Linking from 'expo-linking';
|
||||
|
||||
import {
|
||||
type HostBridgeError,
|
||||
type NavigateNativePagePayload,
|
||||
@@ -17,7 +19,6 @@ import {
|
||||
} from './protocol';
|
||||
|
||||
export async function openMobileHostBridgeExternalUrl(
|
||||
navigator: MobileShellExternalNavigator,
|
||||
payload: unknown,
|
||||
) {
|
||||
const externalUrlPayload = normalizeHostBridgeExternalUrlPayload(
|
||||
@@ -28,7 +29,7 @@ export async function openMobileHostBridgeExternalUrl(
|
||||
}
|
||||
|
||||
if (
|
||||
!(await openMobileShellExternalNavigation(navigator, externalUrlPayload.url))
|
||||
!(await openMobileShellExternalNavigation(Linking, externalUrlPayload.url))
|
||||
) {
|
||||
throw {
|
||||
code: 'host_error',
|
||||
|
||||
Reference in New Issue
Block a user