From 5dc8d66f3ce546be1226e9a78d7e6677a0b21976 Mon Sep 17 00:00:00 2001 From: nimbold <11913706+nimbold@users.noreply.github.com> Date: Wed, 3 Jun 2026 22:53:54 +0330 Subject: [PATCH] refactor(extension): remove xpi generation and installation - Switch to copying Firefox extension directory into app bundle Resources - Remove 'Install to Firefox' button and multi-browser selection logic - Update Integrations tab to instruct users to load via about:debugging - Map 'Show Extension Folder in Finder' to the bundled extension source directory --- Scripts/create_app_bundle.sh | 5 +- Sources/Firelink/SettingsView.swift | 93 +++-------------------------- 2 files changed, 12 insertions(+), 86 deletions(-) diff --git a/Scripts/create_app_bundle.sh b/Scripts/create_app_bundle.sh index 19e2b41..7d85e31 100755 --- a/Scripts/create_app_bundle.sh +++ b/Scripts/create_app_bundle.sh @@ -22,7 +22,10 @@ cp "$ROOT_DIR/Resources/$ICON_NAME.icns" "$RESOURCES_DIR/$ICON_NAME.icns" cp "$ROOT_DIR/Sources/Firelink/Assets.xcassets/MenuBarIcon.imageset/MenuBarIconTemplate.png" "$RESOURCES_DIR/MenuBarIconTemplate.png" echo "Packaging Firefox extension..." -(cd "$ROOT_DIR/Extensions/Firefox" && zip -r -q "$RESOURCES_DIR/firelink.xpi" . -x "*.DS_Store") +cp -r "$ROOT_DIR/Extensions/Firefox" "$RESOURCES_DIR/FirefoxExtension" +# Also remove .DS_Store if any +find "$RESOURCES_DIR/FirefoxExtension" -name ".DS_Store" -delete + ARIA2C_PATH=$(which aria2c || true) if [[ -n "$ARIA2C_PATH" && -x "$ARIA2C_PATH" ]]; then diff --git a/Sources/Firelink/SettingsView.swift b/Sources/Firelink/SettingsView.swift index 9309019..55bb4c0 100644 --- a/Sources/Firelink/SettingsView.swift +++ b/Sources/Firelink/SettingsView.swift @@ -670,10 +670,6 @@ private struct PowerSettingsPane: View { } private struct IntegrationSettingsPane: View { - @State private var isInstalling = false - @State private var firefoxApps: [URL] = [] - @State private var showAppPicker = false - var body: some View { Form { Section { @@ -695,33 +691,14 @@ private struct IntegrationSettingsPane: View { } Section { - HStack { - Button { - handleInstallClick() - } label: { - Label("Install to Firefox", systemImage: "puzzlepiece.extension.fill") - } - .buttonStyle(.borderedProminent) - .disabled(isInstalling) - .confirmationDialog("Select Firefox Edition", isPresented: $showAppPicker, titleVisibility: .visible) { - ForEach(firefoxApps, id: \.self) { appURL in - Button(appURL.deletingPathExtension().lastPathComponent) { - installExtension(with: appURL) - } - } - Button("Cancel", role: .cancel) {} - } message: { - Text("Multiple Firefox installations were found. Which one would you like to install the extension to?") - } - - Button { - showExtensionInFinder() - } label: { - Label("Show in Finder", systemImage: "folder") - } + Button { + showExtensionInFinder() + } label: { + Label("Show Extension Folder in Finder", systemImage: "folder.fill") } + .buttonStyle(.borderedProminent) - Text("Note: Mozilla strictly enforces add-on signing. Standard Firefox and Beta will block unsigned extensions. You must either use Firefox Developer Edition/Nightly (with xpinstall.signatures.required set to false) or load it temporarily via about:debugging.") + Text("Because the extension is not yet published to the Mozilla Add-on store, you must load it manually. Open Firefox, go to 'about:debugging', click 'This Firefox', select 'Load Temporary Add-on', and choose the manifest.json file from the folder above.") .font(.caption) .foregroundStyle(.secondary) } @@ -736,62 +713,8 @@ private struct IntegrationSettingsPane: View { } private func showExtensionInFinder() { - guard let xpiURL = Bundle.main.url(forResource: "firelink", withExtension: "xpi") else { return } - NSWorkspace.shared.activateFileViewerSelecting([xpiURL]) - } - - private func handleInstallClick() { - let apps = findFirefoxApps() - if apps.isEmpty { - // Fallback to default macOS open behavior - installExtension(with: nil) - } else if apps.count == 1 { - installExtension(with: apps[0]) - } else { - firefoxApps = apps.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) - showAppPicker = true - } - } - - private func findFirefoxApps() -> [URL] { - let directories = [ - URL(fileURLWithPath: "/Applications"), - URL(fileURLWithPath: NSHomeDirectory() + "/Applications") - ] - - var apps: [URL] = [] - for dir in directories { - if let urls = try? FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil) { - for url in urls where url.pathExtension == "app" && url.lastPathComponent.lowercased().contains("firefox") { - apps.append(url) - } - } - } - return apps - } - - private func installExtension(with appURL: URL?) { - guard let xpiURL = Bundle.main.url(forResource: "firelink", withExtension: "xpi") else { - print("Failed to find firelink.xpi in app bundle.") - return - } - - isInstalling = true - Task { - do { - let process = Process() - process.executableURL = URL(fileURLWithPath: "/usr/bin/open") - if let appURL { - process.arguments = ["-a", appURL.path, xpiURL.path] - } else { - process.arguments = [xpiURL.path] // Default open - } - try process.run() - process.waitUntilExit() - } catch { - print("Failed to launch Firefox to install extension: \(error)") - } - isInstalling = false + if let folderURL = Bundle.main.url(forResource: "FirefoxExtension", withExtension: nil) { + NSWorkspace.shared.activateFileViewerSelecting([folderURL]) } } }