收口原生网络查询边界

将 Expo 网络状态查询收口到 HostBridge network 模块

将 Tauri 网络状态查询收口到 HostBridge network 模块

同步原生壳结构门禁、架构文档和共享记忆
This commit is contained in:
2026-06-19 22:08:19 +08:00
parent 177c18ddcd
commit c0940bc790
11 changed files with 87 additions and 12 deletions
@@ -30,6 +30,14 @@ const hostBridgeNavigationSource = fs.readFileSync(
hostBridgeNavigationPath,
'utf8',
);
const hostBridgeNetworkPath = new URL(
'../src/host-bridge/network.ts',
import.meta.url,
);
const hostBridgeNetworkSource = fs.readFileSync(
hostBridgeNetworkPath,
'utf8',
);
const notificationsPath = new URL('../src/host-bridge/notifications.ts', import.meta.url);
const notificationsSource = fs.readFileSync(notificationsPath, 'utf8');
const protocolPath = new URL('../src/host-bridge/protocol.ts', import.meta.url);
@@ -96,6 +104,7 @@ const requiredMobileShellSourceModules = [
'host-bridge/files.ts',
'host-bridge/haptics.ts',
'host-bridge/navigation.ts',
'host-bridge/network.ts',
'host-bridge/notifications.ts',
'host-bridge/protocol.ts',
'host-bridge/scanner.ts',
@@ -1897,6 +1906,22 @@ if (!hostBridgeNavigationSource.includes('openMobileShellExternalNavigation(navi
);
}
if (
!dispatchSource.includes('getMobileHostBridgeNetworkStatus()') ||
dispatchSource.includes('../shell/network') ||
dispatchSource.includes('getMobileNetworkStatus()')
) {
throw new Error('mobile shell network HostBridge method must delegate to network module');
}
for (const snippet of [
'getMobileHostBridgeNetworkStatus',
'getMobileNetworkStatus()',
]) {
if (!hostBridgeNetworkSource.includes(snippet)) {
throw new Error(`mobile shell network module is missing ${snippet}`);
}
}
if (!shellAppSource.includes('openMobileShellExternalNavigation(Linking, request.url)')) {
throw new Error(
'mobile shell WebView external navigation must use the tested external navigation helper',
@@ -8,7 +8,6 @@ import {
type HostBridgeRequest,
normalizeHostBridgeLocalNotification,
} from '../../../../packages/shared/src/contracts/hostBridge';
import { getMobileNetworkStatus } from '../shell/network';
import { MOBILE_SHELL_HOST_VERSION } from '../shell/runtime';
import { resolveMobileHostCapabilities } from './capabilities';
import {
@@ -43,6 +42,7 @@ import {
openMobileHostBridgeNativePage,
reloadMobileHostBridgeWebView,
} from './navigation';
import { getMobileHostBridgeNetworkStatus } from './network';
let currentShareTarget: unknown = null;
let navigation: MobileHostBridgeNavigation | null = null;
@@ -117,7 +117,7 @@ export async function dispatchMobileHostBridgeRequest(
case 'app.reloadWebView':
return ok(request, reloadMobileHostBridgeWebView(navigation));
case 'network.status':
return ok(request, await getMobileNetworkStatus());
return ok(request, await getMobileHostBridgeNetworkStatus());
case 'clipboard.writeText':
return ok(request, await writeClipboard(request.payload));
case 'clipboard.readText':
@@ -0,0 +1,5 @@
import { getMobileNetworkStatus } from '../shell/network';
export function getMobileHostBridgeNetworkStatus() {
return getMobileNetworkStatus();
}