Open source CapCut alternative.
TypeScript
fix(app): give the dev app its own Cut engine port so it coexists with release [rebuild]
David Lec4039b190acb
diff --git a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCutEngineSupervisor.swift b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCutEngineSupervisor.swiftindex 80896553..f8cd6326 100644--- a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCutEngineSupervisor.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCutEngineSupervisor.swift@@ -16,8 +16,17 @@ import Foundation////// Cut is free and standalone, so the engine runs regardless of Donkey sign-in state.public final class DonkeyCutEngineSupervisor: @unchecked Sendable {- /// The port the Cut client probes (see the site's engine discovery).- private static let port = 41417+ /// The loopback port this build's engine binds, probes, and evicts stale engines on. The dev+ /// app sets DonkeyCutEnginePort in its Info.plist (scripts/run-donkey-dev.sh) so its engine+ /// and a release engine coexist instead of killing each other; the release build omits the+ /// key and takes the default, which matches the hosted client's target (DEFAULT_ENGINE_PORT+ /// in site/src/cut/lib/ports.ts).+ private static let port: Int = {+ let raw = Bundle.main.object(forInfoDictionaryKey: "DonkeyCutEnginePort")+ if let n = raw as? Int { return n }+ if let s = raw as? String, let n = Int(s) { return n }+ return 41417+ }()/// All mutable state is confined to this queue.private let queue = DispatchQueue(label: "donkey.cut-engine-supervisor")@@ -129,6 +138,7 @@ public final class DonkeyCutEngineSupervisor: @unchecked Sendable {var environment = DonkeyCommandBackends.shellEnvironment()environment["DONKEY_CUT_ENGINE"] = "1"environment["DONKEY_CUT_VERSION"] = Self.appVersion+ environment["DONKEY_CUT_PORT"] = String(Self.port)environment["DONKEY_CUT_PARENT_PID"] = String(ProcessInfo.processInfo.processIdentifier)if let tools = DonkeyCommandBackends.bundledToolsDirectory {environment["DONKEY_CUT_TOOLS_DIR"] = tools.pathdiff --git a/scripts/run-donkey-dev.sh b/scripts/run-donkey-dev.shindex 6e318bf8..4fbbf395 100755--- a/scripts/run-donkey-dev.sh+++ b/scripts/run-donkey-dev.sh@@ -21,6 +21,10 @@ FRAMEWORKS_DIR="$CONTENTS_DIR/Frameworks"APP_ICON_SOURCE="$APP_DIR/Sources/Donkey/Resources/Donkey.icns"APP_ICONSET_SOURCE="$APP_DIR/Sources/Donkey/Resources/Donkey.iconset"AUTH_CALLBACK_SCHEME="${DONKEY_AUTH_CALLBACK_SCHEME:-donkey-dev}"+# The dev engine binds its own loopback port (baked into the dev Info.plist below,+# read by DonkeyCutEngineSupervisor) so it coexists with an installed release's+# engine on 41417 instead of the two supervisors killing each other's engine.+DEV_CUT_ENGINE_PORT="${DONKEY_DEV_CUT_ENGINE_PORT:-41418}"LAUNCH_APP="${DONKEY_LAUNCH_APP:-1}"LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"SITE_PID=""@@ -409,6 +413,8 @@ write_info_plist() {<true/><key>DonkeyWebBaseURL</key><string>$escaped_web_base_url</string>+ <key>DonkeyCutEnginePort</key>+ <integer>$DEV_CUT_ENGINE_PORT</integer><key>DonkeyAuthCallbackScheme</key><string>$escaped_callback_scheme</string><key>DonkeyDevOverlayConfigPath</key>@@ -485,11 +491,11 @@ create_debug_app_bundle() {# Build and stage the Donkey Cut engine so the app supervises a current copy — no separate# manual build step. Non-fatal: a Cut build hiccup shouldn't block Donkey dev (the app just- # runs without Cut). Set DONKEY_BUILD_CUT_ENGINE=0 to skip.+ # runs without Cut).cut_engine_arch="$(uname -m)"[ "$cut_engine_arch" = "x86_64" ] && cut_engine_arch="x64"cut_engine="$ROOT_DIR/site/dist/cut-engine/donkey-cut-engine-$cut_engine_arch"- if [ "${DONKEY_BUILD_CUT_ENGINE:-1}" != "0" ] && [ -d "$ROOT_DIR/site" ]; then+ if [ -d "$ROOT_DIR/site" ]; thenecho "Building Donkey Cut engine..."bash "$ROOT_DIR/site/scripts/build-cut-engine.sh" ||echo "Warning: Cut engine build failed; running Donkey without Cut." >&2