Files
Genarrative/apps/mobile-shell/src/host-bridge/runtime.ts
T
kdletters 65b9125d22 收口移动运行时响应边界
将 Expo host.getRuntime 成功响应包装收口到 runtime 模块

让移动 dispatch 只委托运行时请求

同步移动壳配置门禁和共享记忆
2026-06-20 01:55:58 +08:00

30 lines
911 B
TypeScript

import { Platform } from 'react-native';
import {
HOST_BRIDGE_VERSION,
type HostBridgeRequest,
type HostBridgeRuntimeResult,
} from '../../../../packages/shared/src/contracts/hostBridge';
import { MOBILE_SHELL_HOST_VERSION } from '../shell/runtime';
import { resolveMobileHostCapabilities } from './capabilities';
import { ok } from './protocol';
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),
};
}
export function getMobileHostBridgeRuntimeResponse(request: HostBridgeRequest) {
return ok(request, getMobileHostBridgeRuntime());
}