fancy new browser
1import SwiftUI
2import AppKit
3import MereKit
4
5/// Hosts the engine's native NSView inside SwiftUI.
6/// Works identically for WebKit and Chromium tabs.
7public struct WebContentView: NSViewRepresentable {
8
9 let content: any WebContent
10
11 public init(content: any WebContent) {
12 self.content = content
13 }
14
15 public func makeNSView(context: Context) -> NSView {
16 let container = NSView()
17 container.wantsLayer = true
18 content.attachHostView(container)
19 return container
20 }
21
22 public func updateNSView(_ nsView: NSView, context: Context) {}
23
24 public static func dismantleNSView(_ nsView: NSView, coordinator: ()) {
25 // WebContent.close() is called by the Tab when removed from WindowViewModel
26 }
27}