import Foundation import XuqmFileSDK public struct XWebViewConfig: Sendable { public var url: String public var title: String public var hideToolbar: Bool public var hideStatusBar: Bool public var userAgent: String? public var injectedJavaScript: String? /// Native message handler name registered in WKUserContentController. /// H5 side calls `window.webkit.messageHandlers..postMessage(json)`. public var jsBridgeName: String /// Where intercepted WebView downloads are saved. public var downloadDestination: FileDownloadDestination /// Custom message callback — receives raw JSON string from H5 via jsBridgeName bridge. public var onMessage: (@Sendable (String) -> Void)? /// Called when the WebView container should close (xuqm.closeWebView JSBridge command). public var onClose: (@Sendable () -> Void)? /// Called on page load error. Receives a human-readable error description. public var onPageError: (@Sendable (String) -> Void)? /// Called as the page loads. Progress is 0–100. public var onProgressChanged: (@Sendable (Int) -> Void)? /// Called when the navigation stack changes. (canGoBack, canGoForward) public var onNavigationChanged: (@Sendable (Bool, Bool) -> Void)? public init( url: String = "", title: String = "", hideToolbar: Bool = false, hideStatusBar: Bool = false, userAgent: String? = nil, injectedJavaScript: String? = nil, jsBridgeName: String = "SZYX_APP", downloadDestination: FileDownloadDestination = .sandbox, onMessage: (@Sendable (String) -> Void)? = nil, onClose: (@Sendable () -> Void)? = nil, onPageError: (@Sendable (String) -> Void)? = nil, onProgressChanged: (@Sendable (Int) -> Void)? = nil, onNavigationChanged: (@Sendable (Bool, Bool) -> Void)? = nil ) { self.url = url self.title = title self.hideToolbar = hideToolbar self.hideStatusBar = hideStatusBar self.userAgent = userAgent self.injectedJavaScript = injectedJavaScript self.jsBridgeName = jsBridgeName self.downloadDestination = downloadDestination self.onMessage = onMessage self.onClose = onClose self.onPageError = onPageError self.onProgressChanged = onProgressChanged self.onNavigationChanged = onNavigationChanged } } public protocol XWebViewController: AnyObject { func canGoBack() -> Bool func canGoForward() -> Bool func currentUrl() -> String? func goBack() func goForward() func reload() func load(url: String) func postMessageToWeb(js: String) }