import AppKit @_spi(Fixtures) import CallsKit import SwiftUI /// The real full-window call, live, in a window off screen, for the /// portrait gate (test/browser/native-portrait.mjs): where each picture is /// placed, read back from the video views themselves (VideoPlacementProbe), /// not from a fixture. Opened by the `stage-open` command. @MainActor final class StagePreview { let window: NSWindow let view: NSHostingView init(call: Call, size: NSSize) { NSApplication.shared.setActivationPolicy(.prohibited) view = NSHostingView( rootView: AnyView( MacCallView(call: call, grid: false, style: .fullWindow, controlsShown: false, leave: {}, rejoin: {}) .environment(\.colorScheme, .dark))) window = NSWindow( contentRect: NSRect(x: -4000, y: -4000, width: size.width, height: size.height), styleMask: [.borderless], backing: .buffered, defer: false) window.isReleasedWhenClosed = false window.contentView = view window.orderFront(nil) } /// Every picture's placement, after a layout pass, as one JSON line. func placements() -> String { view.layoutSubtreeIfNeeded() let report: [String: Any] = [ "placements": VideoPlacementProbe.placements, "backdrops": VideoPlacementProbe.backdrops, ] guard let data = try? JSONSerialization.data(withJSONObject: report), let line = String(data: data, encoding: .utf8) else { return "{}" } return line } func resize(_ size: NSSize) { window.setContentSize(size) } }