|
|
@@ -22,7 +22,7 @@ final class IndeedWebKitPageFetcher: NSObject {
|
|
|
)
|
|
|
|
|
|
private var webView: WKWebView?
|
|
|
- /// Kept alive so WebKit completes loads off-screen (macOS often stalls without a window).
|
|
|
+ /// Invisible off-screen panel so WebKit can finish loads without ever appearing in the UI.
|
|
|
private var hostWindow: NSWindow?
|
|
|
private var continuation: CheckedContinuation<String, Error>?
|
|
|
private var timeoutTask: Task<Void, Never>?
|
|
|
@@ -60,16 +60,25 @@ final class IndeedWebKitPageFetcher: NSObject {
|
|
|
view.navigationDelegate = self
|
|
|
self.webView = view
|
|
|
|
|
|
- let window = NSWindow(
|
|
|
+ // Invisible non-activating panel: WebKit needs a window to finish loads on macOS,
|
|
|
+ // but a titled NSWindow was intermittently surfacing Indeed HTML over the app UI.
|
|
|
+ let panel = NSPanel(
|
|
|
contentRect: NSRect(x: -10_000, y: -10_000, width: 1280, height: 900),
|
|
|
- styleMask: [.titled, .closable],
|
|
|
+ styleMask: [.borderless, .nonactivatingPanel],
|
|
|
backing: .buffered,
|
|
|
defer: false
|
|
|
)
|
|
|
- window.isReleasedWhenClosed = false
|
|
|
- window.contentView = view
|
|
|
- window.orderBack(nil)
|
|
|
- self.hostWindow = window
|
|
|
+ panel.isReleasedWhenClosed = false
|
|
|
+ panel.alphaValue = 0
|
|
|
+ panel.ignoresMouseEvents = true
|
|
|
+ panel.hasShadow = false
|
|
|
+ panel.isOpaque = false
|
|
|
+ panel.backgroundColor = .clear
|
|
|
+ panel.collectionBehavior = [.transient, .ignoresCycle, .stationary, .fullScreenAuxiliary]
|
|
|
+ panel.hidesOnDeactivate = false
|
|
|
+ panel.contentView = view
|
|
|
+ panel.orderBack(nil)
|
|
|
+ self.hostWindow = panel
|
|
|
|
|
|
log.info("Loading Indeed page \(url.absoluteString, privacy: .public)")
|
|
|
|
|
|
@@ -91,6 +100,7 @@ final class IndeedWebKitPageFetcher: NSObject {
|
|
|
webView?.stopLoading()
|
|
|
hostWindow?.contentView = nil
|
|
|
hostWindow?.orderOut(nil)
|
|
|
+ hostWindow?.close()
|
|
|
hostWindow = nil
|
|
|
webView = nil
|
|
|
}
|