import SwiftUI import WebKit // 把 EngineController 持有的离屏 WKWebView 桥进 SwiftUI 视图树(保持存活)。无可见 UI // 用途——引擎由 controller 经 JS 桥驱动(见 ios/PLAN.md arch A)。 struct EngineWebView: UIViewRepresentable { let controller: EngineController // 会话源:在构建 WebView(注入 __CDROP_BOOT__)之前确定性接好。冷启动重开时,本视图的 // makeUIView 可能先于 AppRoot.onAppear 跑——若那时 controller.auth 仍为 nil,boot 注入 // session:null → 引擎报「missing injected session」整个 boot 死(#11)。故在此同步接好。 let auth: AuthManager func makeUIView(context: Context) -> WKWebView { controller.auth = auth return controller.makeWebView() } func updateUIView(_ uiView: WKWebView, context: Context) { // 无需更新。 } }