2026-01-27 14:12:17 -06:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
final class CanvasFileWatcher: @unchecked Sendable {
|
2026-02-15 20:07:12 +00:00
|
|
|
private let watcher: CoalescingFSEventsWatcher
|
2026-01-27 14:12:17 -06:00
|
|
|
|
|
|
|
|
init(url: URL, onChange: @escaping () -> Void) {
|
2026-02-15 20:07:12 +00:00
|
|
|
self.watcher = CoalescingFSEventsWatcher(
|
|
|
|
|
paths: [url.path],
|
|
|
|
|
queueLabel: "ai.openclaw.canvaswatcher",
|
|
|
|
|
onChange: onChange)
|
2026-01-27 14:12:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deinit {
|
|
|
|
|
self.stop()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func start() {
|
2026-02-15 20:07:12 +00:00
|
|
|
self.watcher.start()
|
2026-01-27 14:12:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func stop() {
|
2026-02-15 20:07:12 +00:00
|
|
|
self.watcher.stop()
|
2026-01-27 14:12:17 -06:00
|
|
|
}
|
|
|
|
|
}
|