回读宿主运行态能力

HostBridge 启动时通过真实 host.getRuntime 回读并缓存宿主能力

主 App 订阅宿主能力变化并在回读后刷新能力入口

补充宿主 runtime 回读测试和 App 能力刷新测试

更新 Expo/Tauri 壳方案、HostBridge 协议文档和共享决策记录
This commit is contained in:
2026-06-18 01:02:58 +08:00
parent 38ed2227d3
commit 5c3b70caf1
8 changed files with 291 additions and 27 deletions

View File

@@ -27,6 +27,10 @@ import {
resolveAppTitleForSelectionStage,
syncAppTitle,
} from './services/appTitle';
import {
refreshNativeAppHostRuntime,
subscribeHostRuntimeChange,
} from './services/host-bridge/hostBridge';
import type { CustomWorldProfile } from './types';
const RpgRuntimeApp = lazy(async () => {
@@ -59,6 +63,7 @@ export default function App() {
const runtimeIntentTokenRef = useRef(0);
const [runtimeIntent, setRuntimeIntent] =
useState<RpgRuntimeAppIntent | null>(null);
const [, setHostRuntimeRevision] = useState(0);
const [isRuntimeActive, setIsRuntimeActive] = useState(() =>
isRpgRuntimeRoute(window.location.pathname),
);
@@ -76,6 +81,16 @@ export default function App() {
pushAppHistoryPath(resolvePathForSelectionStage(stage));
}, []);
useEffect(() => {
const unsubscribe = subscribeHostRuntimeChange(() => {
setHostRuntimeRevision((revision) => revision + 1);
});
void refreshNativeAppHostRuntime();
return unsubscribe;
}, []);
useEffect(() => {
const syncStageFromHistory = () => {
if (isRpgRuntimeRoute(window.location.pathname)) {