Skip to content

Open source CapCut alternative.

TypeScript

Compile debug overlay only in debug builds

David Le20a763166153
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swift
index 2e0c3a98..b1217a5a 100644
--- a/apps/Donkey/Package.swift
+++ b/apps/Donkey/Package.swift
@@ -46,6 +46,9 @@ let package = Package(
.process("Resources/local-app-finder-profiles.json"),
.copy("Resources/BuiltInSkills")
],
+ swiftSettings: [
+ .define("DONKEY_DEBUG_OVERLAY", .when(configuration: .debug))
+ ],
linkerSettings: [
.linkedLibrary("sqlite3")
]
@@ -55,6 +58,9 @@ let package = Package(
dependencies: [
"DonkeyContracts",
"DonkeyRuntime"
+ ],
+ swiftSettings: [
+ .define("DONKEY_DEBUG_OVERLAY", .when(configuration: .debug))
]
),
.target(
@@ -79,6 +85,9 @@ let package = Package(
.copy("Resources/donkey-app-icon.png"),
.copy("Resources/google-continue-dark-rounded.png"),
.copy("Resources/theme.json")
+ ],
+ swiftSettings: [
+ .define("DONKEY_DEBUG_OVERLAY", .when(configuration: .debug))
]
),
.executableTarget(
diff --git a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
index 3f9c4b0d..b026c7cc 100644
--- a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
+++ b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
@@ -9,7 +9,9 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
private var loginWindowController: DonkeyLoginWindowController?
private var permissionSetupController: MacPermissionSetupWindowController?
private var overlayController: UserQueryOverlayController?
+ #if DONKEY_DEBUG_OVERLAY
private var debugInspectionCoordinator: DebugUIInspectionCoordinator?
+ #endif
private var runtimeOnboardingController: LocalRuntimeOnboardingWindowController?
func applicationDidFinishLaunching(_ notification: Notification) {
@@ -68,7 +70,9 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
andEventID: AEEventID(kAEGetURL)
)
overlayController?.stop()
+ #if DONKEY_DEBUG_OVERLAY
debugInspectionCoordinator?.stop()
+ #endif
}
private func showLoginWindow() {
@@ -114,9 +118,11 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
overlayController = controller
controller.show()
+ #if DONKEY_DEBUG_OVERLAY
let debugInspectionCoordinator = DebugUIInspectionCoordinator()
self.debugInspectionCoordinator = debugInspectionCoordinator
debugInspectionCoordinator.start()
+ #endif
let runtimeOnboardingController = LocalRuntimeOnboardingWindowController()
self.runtimeOnboardingController = runtimeOnboardingController
diff --git a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
index effe3ef2..79ecfa50 100644
--- a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
+++ b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
import AppKit
import CryptoKit
import DonkeyAI
@@ -884,3 +886,5 @@ private struct DebugUICompressedImage: Sendable {
var contentType: String
var pixelSize: HotLoopSize
}
+
+#endif
diff --git a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionOverlayController.swift b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionOverlayController.swift
index c8a263b7..924d6c38 100644
--- a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionOverlayController.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
import AppKit
import DonkeyContracts
import DonkeyRuntime
@@ -348,3 +350,5 @@ private final class DebugUIInspectionRootView: NSView {
nil
}
}
+
+#endif
diff --git a/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionFrameFusion.swift b/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionFrameFusion.swift
index 24756fb9..c4ee51e3 100644
--- a/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionFrameFusion.swift
+++ b/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionFrameFusion.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
import DonkeyContracts
import Foundation
@@ -127,3 +129,5 @@ public enum DebugUIInspectionFrameFusion {
.joined(separator: " ")
}
}
+
+#endif
diff --git a/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionHostedAdapter.swift b/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionHostedAdapter.swift
index 45e6a25d..fda22656 100644
--- a/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionHostedAdapter.swift
+++ b/apps/Donkey/Sources/DonkeyAI/DebugUIInspectionHostedAdapter.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
import DonkeyContracts
import Foundation
@@ -388,3 +390,5 @@ private struct RawDebugUICoordinateSpace: Decodable {
var width: Double
var height: Double
}
+
+#endif
diff --git a/apps/Donkey/Sources/DonkeyAI/ScreenshotParseDebugUIOverlayMapper.swift b/apps/Donkey/Sources/DonkeyAI/ScreenshotParseDebugUIOverlayMapper.swift
index b97009bc..173859d7 100644
--- a/apps/Donkey/Sources/DonkeyAI/ScreenshotParseDebugUIOverlayMapper.swift
+++ b/apps/Donkey/Sources/DonkeyAI/ScreenshotParseDebugUIOverlayMapper.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
import DonkeyContracts
import DonkeyRuntime
import Foundation
@@ -229,3 +231,5 @@ public enum ScreenshotParseDebugUIOverlayMapper {
}
}
}
+
+#endif
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIAccessibilityInspectionService.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIAccessibilityInspectionService.swift
index 7c7bb883..5860cd76 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIAccessibilityInspectionService.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIAccessibilityInspectionService.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
@preconcurrency import AppKit
import CoreGraphics
import CryptoKit
@@ -1209,3 +1211,5 @@ private extension LocalUIElementDetectionTrace {
return area > 0 && overlap / area >= 0.72
}
}
+
+#endif
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIInspectionRuntime.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIInspectionRuntime.swift
index 23662b54..950e04f5 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIInspectionRuntime.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalUIElementDetection/DebugUIInspectionRuntime.swift
@@ -1,3 +1,5 @@
+#if DONKEY_DEBUG_OVERLAY
+
@preconcurrency import AppKit
import CoreGraphics
import CryptoKit
@@ -843,3 +845,5 @@ protocol DebugUIScreenCapturing: Sendable {
}
extension DebugUIScreenCaptureService: DebugUIScreenCapturing {}
+
+#endif