mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-27 00:12:35 +02:00
feat(ios): Swift templates for StateServer + DebugOverlay v2 + structural Release guard
StateServer is loopback-only (::1 + 127.0.0.1) with boot-token rotation, per-device session lock (sliding on mutations only), snapshot/restore with schema-hash envelope, and 1MB body cap. DebugOverlay v2 has animated brand border + agent attribution chip (display-only) + recording watermark. Package.swift enforces structural Release-build exclusion via .when(configuration: .debug). Includes Tailscale ACL example doc.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// AUTO-GENERATED from gstack/ios-qa/templates/DebugBridgeWiring.swift.template
|
||||
//
|
||||
// Wiring snippet for the app's @main entry. Users paste this into their
|
||||
// App.swift inside the `init()` of the SwiftUI App struct, gated by
|
||||
// #if DEBUG. The wiring is intentionally tiny; everything heavy lives in
|
||||
// the DebugBridge target.
|
||||
|
||||
#if DEBUG
|
||||
import DebugBridge
|
||||
|
||||
@MainActor
|
||||
func startGstackDebugBridge(appState: AppState) {
|
||||
// Read --recording flag from launch arguments
|
||||
let recording = ProcessInfo.processInfo.arguments.contains("--gstack-recording")
|
||||
|
||||
// Install accessibility + screenshot + mutation bridges before starting
|
||||
// the server so the first authenticated request can use them.
|
||||
ElementsBridge.resolver = { AccessibilityScanner.snapshot() }
|
||||
ScreenshotBridge.resolver = { SnapshotCapture.capturePNG() }
|
||||
MutationBridge.resolver = { op, payload in
|
||||
MutationDispatcher.shared.run(op: op, payload: payload)
|
||||
}
|
||||
|
||||
DebugBridgeManager.shared.start(appState: appState, recording: recording)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Example usage in the app's @main entry (paste this into App.swift):
|
||||
//
|
||||
// @main
|
||||
// struct MyApp: App {
|
||||
// @State private var appState = MyAppState()
|
||||
//
|
||||
// init() {
|
||||
// #if DEBUG
|
||||
// startGstackDebugBridge(appState: appState)
|
||||
// #endif
|
||||
// }
|
||||
//
|
||||
// var body: some Scene {
|
||||
// WindowGroup { ContentView() }
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user