UICompressor is a Swift package for compressing repeated tree snapshots into a deduplicated node store plus lightweight snapshot references.
Add the package in Xcode with the repository URL, or in Package.swift:
dependencies: [
.package(url: "https://github.com/your-org/ui-compressor.git", from: "0.1.0")
]Then add "UICompressor" to your target dependencies.
import UICompressor
struct Node {
let role: String
let label: String?
let children: [Node]
}
let compressor = TreeCompressor(childAttribute: \Node.children) { node, extractor in
extractor.add(value: node.role, forKey: "role")
extractor.add(value: node.label, forKey: "label")
}
let compressed = compressor.compress(
rootNodes: [
RootNode(timestamp: 1, rootNode: Node(role: "window", label: nil, children: []))
]
)