收口移动运行时桥接边界
将 Expo host.getRuntime 回包组装收口到 runtime 模块 让移动 dispatch 只委托运行时请求 同步移动壳结构门禁、架构文档和共享记忆
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
import * as Linking from 'expo-linking';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import {
|
||||
HOST_BRIDGE_VERSION,
|
||||
type HostBridgeRequest,
|
||||
} from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import { MOBILE_SHELL_HOST_VERSION } from '../shell/runtime';
|
||||
import { resolveMobileHostCapabilities } from './capabilities';
|
||||
import { type HostBridgeRequest } from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import {
|
||||
captureImageFile,
|
||||
exportAudioFile,
|
||||
@@ -43,6 +37,7 @@ import {
|
||||
reloadMobileHostBridgeWebView,
|
||||
} from './navigation';
|
||||
import { getMobileHostBridgeNetworkStatus } from './network';
|
||||
import { getMobileHostBridgeRuntime } from './runtime';
|
||||
|
||||
let navigation: MobileHostBridgeNavigation | null = null;
|
||||
|
||||
@@ -52,27 +47,12 @@ export function configureMobileHostBridgeNavigation(
|
||||
navigation = nextNavigation;
|
||||
}
|
||||
|
||||
function getMobileRuntimePlatform() {
|
||||
return Platform.OS === 'ios' ? 'ios' : 'android';
|
||||
}
|
||||
|
||||
function getRuntime() {
|
||||
const platform = getMobileRuntimePlatform();
|
||||
return {
|
||||
shell: 'expo_mobile',
|
||||
platform,
|
||||
hostVersion: MOBILE_SHELL_HOST_VERSION,
|
||||
bridgeVersion: HOST_BRIDGE_VERSION,
|
||||
capabilities: resolveMobileHostCapabilities(platform),
|
||||
};
|
||||
}
|
||||
|
||||
export async function dispatchMobileHostBridgeRequest(
|
||||
request: HostBridgeRequest,
|
||||
) {
|
||||
switch (request.method) {
|
||||
case 'host.getRuntime':
|
||||
return ok(request, getRuntime());
|
||||
return ok(request, getMobileHostBridgeRuntime());
|
||||
case 'appearance.getColorScheme':
|
||||
return ok(request, getMobileAppearanceColorScheme());
|
||||
case 'app.openExternalUrl':
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import {
|
||||
HOST_BRIDGE_VERSION,
|
||||
type HostBridgeRuntimeResult,
|
||||
} from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import { MOBILE_SHELL_HOST_VERSION } from '../shell/runtime';
|
||||
import { resolveMobileHostCapabilities } from './capabilities';
|
||||
|
||||
export function getMobileRuntimePlatform() {
|
||||
return Platform.OS === 'ios' ? 'ios' : 'android';
|
||||
}
|
||||
|
||||
export function getMobileHostBridgeRuntime(): HostBridgeRuntimeResult {
|
||||
const platform = getMobileRuntimePlatform();
|
||||
return {
|
||||
shell: 'expo_mobile',
|
||||
platform,
|
||||
hostVersion: MOBILE_SHELL_HOST_VERSION,
|
||||
bridgeVersion: HOST_BRIDGE_VERSION,
|
||||
capabilities: resolveMobileHostCapabilities(platform),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user