-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Expand file tree
/
Copy pathDebugBridgeManager.swift
More file actions
53 lines (44 loc) · 1.94 KB
/
Copy pathDebugBridgeManager.swift
File metadata and controls
53 lines (44 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// AUTO-GENERATED from gstack/ios-qa/templates/DebugBridgeManager.swift.template
//
// Bootstraps StateServer on app launch. Lives in DebugBridgeCore (no UIKit
// dependency). The DebugOverlay install is wired separately by the consuming
// app — it lives in DebugBridgeUI which depends on DebugBridgeCore (not the
// other way around). Everything is #if DEBUG-gated; this file does not exist
// in Release builds.
#if DEBUG
import Foundation
@MainActor
public final class DebugBridgeManager {
public static let shared = DebugBridgeManager()
public func start(appState: AppState) {
// 1. Register the canonical AppState struct + accessor wiring.
// AppStateAccessor.register(_:) is generated by gen-accessors-tool.
AppStateAccessor.register(appState)
// 2. Boot the StateServer.
StateServer.shared.start()
// 3. The consuming app installs the UI bridges + overlay separately,
// from DebugBridgeUI, via:
//
// #if canImport(UIKit)
// DebugBridgeUIWiring.installAll()
// #endif
//
// See Bridges.swift.template (`DebugBridgeUIWiring.installAll()`),
// which wires ElementsBridgeImpl / ScreenshotBridgeImpl /
// MutationBridgeImpl and installs the overlay window.
}
}
// Placeholder. gen-accessors-tool emits the real `AppStateAccessor` enum next
// to the app's canonical state struct. Apps that haven't run codegen get a
// stub that registers no accessors (snapshot is empty, restore returns
// missing-key for every key).
@MainActor
public enum AppStateAccessor {
public static var register: (Any) -> Void = { _ in }
}
// Apps declare their canonical state struct; codegen reads it and emits
// AppStateAccessor.register. The app's struct must be `@Observable` and
// must hold all snapshot-eligible state in `@Snapshotable`-marked fields.
@MainActor
public protocol AppState: AnyObject {}
#endif // DEBUG