锁定桌面壳启动宿主上下文
补全桌面主窗口 release 入口宿主上下文字段断言 增加桌面壳配置检查对主窗口宿主上下文测试的反查 同步原生壳方案文档和共享决策记录
This commit is contained in:
@@ -2546,6 +2546,15 @@ const requiredRustHostSnippets = [
|
||||
'.find(|window| window.label == DESKTOP_MAIN_WINDOW_LABEL)',
|
||||
'tauri::Error::WindowNotFound',
|
||||
'desktop_main_window_config(app)?',
|
||||
'desktop_main_window_config_uses_labeled_main_window',
|
||||
'path.starts_with("index.html?")',
|
||||
'path.contains("clientRuntime=native_app")',
|
||||
'path.contains("clientType=native_app")',
|
||||
'path.contains("hostShell=tauri_desktop")',
|
||||
'path.contains("hostPlatform=")',
|
||||
'path.contains(&format!("hostVersion={}", env!("CARGO_PKG_VERSION")))',
|
||||
'path.contains("bridgeVersion=")',
|
||||
'path.contains("hostCapabilities=")',
|
||||
'should_allow_desktop_webview_navigation',
|
||||
'desktop_external_navigation_url',
|
||||
'open_normalized_desktop_external_url',
|
||||
|
||||
@@ -147,7 +147,12 @@ mod tests {
|
||||
let path = path.to_string_lossy();
|
||||
assert!(path.starts_with("index.html?"));
|
||||
assert!(path.contains("clientRuntime=native_app"));
|
||||
assert!(path.contains("clientType=native_app"));
|
||||
assert!(path.contains("hostShell=tauri_desktop"));
|
||||
assert!(path.contains("hostPlatform="));
|
||||
assert!(path.contains(&format!("hostVersion={}", env!("CARGO_PKG_VERSION"))));
|
||||
assert!(path.contains("bridgeVersion="));
|
||||
assert!(path.contains("hostCapabilities="));
|
||||
}
|
||||
other => panic!("unexpected main window url {other:?}"),
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@
|
||||
- 2026-06-20 桌面 HostBridge replay 内部失败边界:Tauri `HostBridgeReplayState` 的 cache lock、slot lock 和 condvar wait 异常不得 panic,也不得把 Rust 内部错误细节回传给 H5;桌面壳只写 `desktop host bridge replay failed for ...` stderr 观测日志,并统一返回 `host_error: desktop host bridge request failed`。桌面配置检查反查 `reserve(...)` 的 `Result` 出口、稳定错误响应和 poison lock 单测。
|
||||
- 2026-06-20 移动 HostBridge runtime 能力回包边界:Expo `host.getRuntime` 回包里的 `capabilities` 必须直接等于共享契约 `HOST_BRIDGE_EXPO_MOBILE_BASE_CAPABILITIES` 或 `HOST_BRIDGE_EXPO_MOBILE_IOS_CAPABILITIES`,并使用与 `platform` 字段一致的归一平台值选择 profile;移动壳 runtime 单测和配置检查反查精确 profile 断言,避免 H5 实际消费的能力回包与入口 URL 能力 query 或共享 profile 分叉。
|
||||
- 2026-06-20 移动 production bundle 宿主上下文边界:`apps/mobile-shell/scripts/check-expo-export.mjs` 必须读取 iOS / Android Metro export bundle,确认可分发 bundle 包含共享生产 H5 URL、`native_app`、`expo_mobile`、`hostCapabilities`、`hostVersion` 和 `bridgeVersion`,且不包含本机开发 H5 URL;移动壳配置检查反查 export smoke 的这些 token,避免生产 bundle 丢失宿主上下文或混入本机入口。
|
||||
- 2026-06-20 桌面 release 主窗口宿主上下文边界:Tauri release 配置只保留基础 `index.html`,Rust app 装配层必须在主窗口启动配置单测里断言补齐 `clientRuntime`、`clientType`、`hostShell`、`hostPlatform`、`hostVersion`、`bridgeVersion` 和 `hostCapabilities`;桌面单端配置检查反查这些断言存在,避免首屏 H5 丢失桌面壳运行态 query 后只靠 runtime 回读补救。
|
||||
- 2026-06-20 移动壳协议 helper 单测边界:`apps/mobile-shell/src/host-bridge/protocol.test.ts` 直接覆盖 Expo 移动壳 HostBridge JSON 解析、envelope 和 request id 校验、未知 method 拒绝、ok / failure 响应包装、unsupported / invalid_request 错误构造,以及 native helper 错误归一时只透传共享错误码与字符串 message,不泄露非法错误码、nativeStack 或其它私有字段;根级 `npm run check:native-shells` 会把该测试文件列入移动桥接层结构清单,避免协议边界只靠完整 bridge 流程间接覆盖。
|
||||
- 2026-06-20 移动扫码 overlay 单测边界:`apps/mobile-shell/src/shell/QrScannerOverlay.test.tsx` 直接覆盖移动扫码 overlay 的相机权限请求、二维码扫码成功、权限拒绝失败和关闭取消;单端配置检查会反查该组件测试存在,根级 `npm run check:native-shells` 会把该测试文件列入移动 shell 层结构清单,避免扫码 UI 容器只靠 `ShellApp.test.tsx` 的完整 HostBridge 流程间接覆盖。
|
||||
- 2026-06-18 HostBridge method 白名单跨壳门禁:`packages/shared/src/contracts/hostBridge.ts` 的 `HOST_BRIDGE_METHODS` 是唯一协议来源;Expo 壳 HostBridge 分发不得处理共享契约外 method,Tauri 壳 Rust `HOST_BRIDGE_METHODS` 必须与共享契约逐项一致。新增宿主 method 必须先更新共享契约,再落两端壳实现或明确 unsupported。
|
||||
|
||||
@@ -461,6 +461,8 @@ GameBridge 禁止:
|
||||
|
||||
2026-06-18 追加:桌面壳 release / dev 在 `tauri.conf.json` 中只保留基础入口 `index.html` 和 `http://127.0.0.1:3000/`,由 Rust `shell/url.rs` 统一补写 `clientRuntime=native_app`、`hostShell=tauri_desktop`、`hostVersion`、`bridgeVersion` 和真实 `hostCapabilities`。`hostVersion` 必须与 Tauri `tauri.conf.json`、Node package 和 Cargo package 版本一致,`host.getRuntime` 回包继续使用 `env!("CARGO_PKG_VERSION")`;配置检查会拒绝在 Tauri 配置里重新手写宿主上下文,避免桌面包升级或能力变化时 H5 首屏上下文与 runtime 回读不一致。
|
||||
|
||||
2026-06-20 追加:桌面壳主窗口启动配置单测必须覆盖 release `index.html` 入口补写后的完整宿主上下文,至少包含 `clientRuntime=native_app`、`clientType=native_app`、`hostShell=tauri_desktop`、`hostPlatform`、`hostVersion`、`bridgeVersion` 和 `hostCapabilities`。`apps/desktop-shell/scripts/check-config.mjs` 会反查这些断言存在,避免只保留基础入口检查而遗漏首屏 H5 进入桌面壳运行态所需的 query 字段。
|
||||
|
||||
2026-06-18 追加:桌面壳静态 Tauri 配置不再写入 `hostPlatform` 或其它宿主上下文 query。Rust `setup` 手动创建主窗口前会把基础入口归一为当前 `macos` / `windows` / `linux` 平台和完整宿主上下文,保证 H5 首屏 query 与 `host.getRuntime` 回读的平台一致;不通过第二实例参数、外部 deep link 或 H5 自报值覆盖该平台字段。
|
||||
|
||||
2026-06-18 追加:桌面壳主 WebView 增加顶层导航边界。打包资产 URL 和 `https://app.genarrative.world` 同源 H5 route 可以继续留在主窗口;外域 `http:` / `https:`、`mailto:`、`tel:` 导航和 `window.open` 请求只交给系统 opener 后阻止留壳;`javascript:`、`file:` 等危险协议直接阻断。该规则不新增 HostBridge capability,也不开放 opener 插件 JS guest API,避免外域页面停留在带 `host_bridge_request` 权限的主 WebView 内。
|
||||
|
||||
Reference in New Issue
Block a user