Compare commits

...

9 Commits

Author SHA1 Message Date
NimBold 07e4a586a1 chore(release): bump version to 0.6.6 and update changelog 2026-06-10 02:17:43 +03:30
NimBold f93f0daef5 feat: show media format section with loading state while fetching 2026-06-10 01:53:58 +03:30
NimBold 3b4402def3 feat: cascading media format pickers 2026-06-10 01:47:53 +03:30
NimBold 62297f61ac fix: keychain prompts, AddDownloadsView dynamic sizing, and options format 2026-06-10 01:38:55 +03:30
NimBold 17dc080a20 fix: suppress keychain UI prompt, improve media format selector, overhaul update checker UI 2026-06-10 01:21:49 +03:30
NimBold 709f189f27 refactor: improve performance, UI components, and stability
- Add timeout to LocalExtensionServer to mitigate Slowloris
- Optimize media output resolution by checking explicit extensions
- Throttle progress updates to 4Hz
- Debounce download completion notifications
- Use native ProgressView in DownloadTable
- Group DownloadTable context menu items
- Fix drag & drop overwriting issue
- Fix focus rings on hidden keyboard shortcuts
2026-06-10 01:08:49 +03:30
NimBold ce9fb4a072 feat(security): implement keychain permission priming
Adds a modal sheet to explain why keychain access is needed before prompting the user after an app update.
2026-06-10 00:50:21 +03:30
NimBold b7380bea35 feat(settings): redesign integration pane and fix toast notification bugs 2026-06-09 13:40:07 +03:30
NimBold 0ec2213a4c feat: defer keychain access until explicitly granted 2026-06-09 12:47:49 +03:30
18 changed files with 790 additions and 510 deletions
+16
View File
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.6.6] - 2026-06-10
### New Features
- Add cascading media format pickers with inline loading states during metadata extraction.
- Redesign the Integration settings pane for a more modern experience.
- Overhaul the built-in update checker UI to integrate seamlessly into the settings.
### Improvements
- Implement keychain permission priming to defer secure access until explicitly granted, preventing unexpected macOS prompts.
- Optimize core UI components to significantly improve rendering performance and overall app stability.
### Fixes
- Fix layout and dynamic sizing bugs in the Add Downloads window.
- Fix formatting inconsistencies in media options selection.
- Fix toast notification rendering glitches.
## [0.6.5] - 2026-06-09
### Fixes
+7 -8
View File
@@ -43,14 +43,13 @@
## ✨ Features
-**Multi-Segmented Engine:** Ultra-fast parallel downloading powered by `aria2c`.
- 🪄 **Media Downloader:** Instantly extract high-quality audio and video formats (4K, 1080p, MP3) from sites like YouTube and Twitter, backed by bundled `yt-dlp` and `ffmpeg` engines.
- 🎨 **Premium Native UI:** Responsive, frosted-glass SwiftUI design tailor-made for Apple Silicon.
- 🌐 **Seamless Integration:** Send links directly from your browser with the Firelink Companion extension.
- 🎯 **Visual Chunk Map:** Monitor active segment connections and download progress in real time.
- 🗂️ **Smart Organization:** Auto-categorizes files into `Musics`, `Movies`, `Compressed`, and more.
- 🛡️ **Reliable & Secure:** Deep Keychain integration for authenticated downloads, zero-configuration setup, and automatic recovery.
- 🔄 **Native Updater:** Built-in seamless GitHub release checking for lightweight and transparent app updates without third-party frameworks.
-**Multi-Segmented Engine:** Ultra-fast parallel downloading powered by `aria2c` with configurable speed limits.
- 🪄 **Media Downloader:** Instantly extract high-quality media (4K, 1080p, MP3) with smart cascading format pickers, powered by bundled `yt-dlp` and `ffmpeg`.
- 🎨 **Premium Native UI:** A responsive, frosted-glass SwiftUI interface tailor-made for Apple Silicon, featuring a visual chunk map and dynamic progress tracking.
- 🌐 **Seamless Browser Integration:** Send downloads directly from your browser via the secure Firelink Companion extension.
- 🛡️ **Privacy & Security:** Zero-configuration setup with deferred Keychain integration ensures your credentials are kept safe and only accessed when strictly necessary.
- 🗂️ **Smart Organization:** Auto-categorizes incoming files and remembers your preferred download locations.
- 🔄 **Native Updater:** Built-in seamless GitHub release checking for lightweight and transparent app updates.
---
+205 -152
View File
@@ -32,25 +32,37 @@ struct AddDownloadsView: View {
var body: some View {
VStack(spacing: 0) {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
linkSection
optionsSection
advancedTransferSection
summarySection
previewSection
HStack(spacing: 0) {
// Left Column
VStack(spacing: 0) {
VStack(alignment: .leading, spacing: 16) {
linkSection
summarySection
previewSection
}
.padding(20)
}
.padding(12)
.frame(maxWidth: .infinity, maxHeight: .infinity)
Divider()
// Right Column
VStack(spacing: 0) {
Form {
optionsSection
advancedTransferSection
}
.formStyle(.grouped)
}
.frame(width: 320)
.background(Color(NSColor.controlBackgroundColor))
}
Divider()
actionBar
.padding(16)
.background(.background)
}
.frame(minWidth: 640, idealWidth: 680, minHeight: 620, idealHeight: 680)
.frame(minWidth: 720, idealWidth: 800, minHeight: 620, idealHeight: 680)
.sheet(isPresented: $showingDuplicates) {
DuplicateResolutionView(
conflicts: $conflictingDownloads,
@@ -107,7 +119,7 @@ struct AddDownloadsView: View {
.scrollContentBackground(.hidden)
.background(.quaternary.opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 8))
.frame(height: 72)
.frame(minHeight: 72, idealHeight: 100, maxHeight: 160)
HStack {
Text("\(pendingDownloads.count) valid link\(pendingDownloads.count == 1 ? "" : "s") detected")
@@ -125,95 +137,68 @@ struct AddDownloadsView: View {
}
private var optionsSection: some View {
Grid(alignment: .leading, horizontalSpacing: 12, verticalSpacing: 8) {
GridRow {
Label("Save Location", systemImage: "folder")
.font(.subheadline.weight(.semibold))
Toggle("Use one folder for all files", isOn: $overrideDestination)
Group {
if let firstMedia = pendingDownloads.first(where: { $0.isMedia }) {
mediaFormatSection(for: firstMedia)
}
GridRow {
Text("")
HStack(spacing: 8) {
TextField("Automatic by file type", text: $destinationPath)
.textFieldStyle(.roundedBorder)
.font(.system(.callout, design: .monospaced))
.disabled(!overrideDestination)
Button {
selectDestination()
} label: {
Label("Select...", systemImage: "folder.badge.plus")
Section("Save Location") {
Toggle("Use one folder for all files", isOn: $overrideDestination)
if overrideDestination {
HStack(spacing: 8) {
TextField("Automatic by file type", text: $destinationPath)
.textFieldStyle(.roundedBorder)
.font(.system(.callout, design: .monospaced))
Button {
selectDestination()
} label: {
Label("Select...", systemImage: "folder.badge.plus")
}
}
.disabled(!overrideDestination)
}
}
GridRow(alignment: .firstTextBaseline) {
Label("Queue", systemImage: "tray.full")
.font(.subheadline.weight(.semibold))
Picker("Queue", selection: $targetQueueID) {
Section("Queue") {
Picker("Target Queue", selection: $targetQueueID) {
ForEach(controller.queues) { queue in
Text(queue.name).tag(queue.id)
}
}
.labelsHidden()
.frame(maxWidth: 220, alignment: .leading)
}
GridRow(alignment: .firstTextBaseline) {
Label("Connections per File", systemImage: "point.3.connected.trianglepath.dotted")
.font(.subheadline.weight(.semibold))
Section("Transfer Settings") {
VStack(alignment: .leading, spacing: 4) {
Text("Connections per File")
HStack {
Slider(value: $connectionsPerServer, in: 1...16, step: 1)
.frame(width: 145)
Text("\(Int(connectionsPerServer)) segments")
Text("\(Int(connectionsPerServer))")
.monospacedDigit()
.frame(width: 98, alignment: .leading)
.frame(width: 24, alignment: .trailing)
}
}
Toggle("Limit speed per file", isOn: $speedLimitEnabled)
if speedLimitEnabled {
Stepper(
"\(speedLimitKiBPerSecond) KiB/s",
value: $speedLimitKiBPerSecond,
in: 1...10_485_760,
step: 128
)
}
}
GridRow(alignment: .firstTextBaseline) {
Label("Speed Limit per File", systemImage: "speedometer")
.font(.subheadline.weight(.semibold))
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 8) {
Toggle("Limit each file", isOn: $speedLimitEnabled)
.toggleStyle(.switch)
Stepper(
"\(speedLimitKiBPerSecond) KiB/s",
value: $speedLimitKiBPerSecond,
in: 1...10_485_760,
step: 128
)
.disabled(!speedLimitEnabled)
}
}
}
GridRow(alignment: .top) {
Label("Authorization", systemImage: "lock.shield")
.font(.subheadline.weight(.semibold))
.padding(.top, 4)
VStack(alignment: .leading, spacing: 8) {
Toggle("Use authorization", isOn: $useAuthorization)
.toggleStyle(.switch)
if useAuthorization {
HStack(spacing: 8) {
TextField("Username", text: $authUsername)
.textFieldStyle(.roundedBorder)
.frame(width: 145)
SecureField("Password", text: $authPassword)
.textFieldStyle(.roundedBorder)
.frame(width: 145)
}
Toggle("Save login for this website", isOn: $saveLogin)
.font(.caption)
.foregroundStyle(.secondary)
}
Section("Authorization") {
Toggle("Use authorization", isOn: $useAuthorization)
if useAuthorization {
TextField("Username", text: $authUsername)
.textFieldStyle(.roundedBorder)
SecureField("Password", text: $authPassword)
.textFieldStyle(.roundedBorder)
Toggle("Save login for this website", isOn: $saveLogin)
.font(.caption)
.foregroundStyle(.secondary)
}
}
}
@@ -261,36 +246,11 @@ struct AddDownloadsView: View {
}
TableColumn("Status") { $item in
if item.isMedia {
if !item.mediaOptions.isEmpty {
Menu {
ForEach(item.mediaOptions) { option in
Button {
item.selectedMediaOption = option
if let metadata = item.mediaMetadata {
let cleanTitle = FileClassifier.sanitizedFileName(metadata.title ?? "Media")
item.fileName = "\(cleanTitle).\(option.outputExtension)"
item.category = FileClassifier.category(forFileName: item.fileName)
}
} label: {
Text(option.name)
}
}
} label: {
Text(item.selectedMediaOption?.name ?? "Select Format")
.lineLimit(1)
}
.menuStyle(.borderlessButton)
.buttonStyle(.plain)
.fixedSize()
} else if case .loading = item.state {
HStack {
ProgressView().controlSize(.small)
Text("Checking")
}.foregroundStyle(.secondary)
} else {
MetadataStatusView(state: item.state)
}
if item.isMedia, case .loading = item.state {
HStack {
ProgressView().controlSize(.small)
Text("Checking")
}.foregroundStyle(.secondary)
} else {
MetadataStatusView(state: item.state)
}
@@ -340,62 +300,155 @@ struct AddDownloadsView: View {
}
}
private func updateMediaOption(for firstMedia: PendingDownload, newId: String) {
for index in pendingDownloads.indices where pendingDownloads[index].isMedia {
if let option = pendingDownloads[index].mediaOptions.first(where: { $0.id == newId }) {
pendingDownloads[index].selectedMediaOption = option
if let metadata = pendingDownloads[index].mediaMetadata {
let cleanTitle = FileClassifier.sanitizedFileName(metadata.title ?? "Media")
pendingDownloads[index].fileName = "\(cleanTitle).\(option.outputExtension)"
pendingDownloads[index].category = FileClassifier.category(forFileName: pendingDownloads[index].fileName)
}
}
}
}
@ViewBuilder
private func mediaFormatSection(for firstMedia: PendingDownload) -> some View {
Section {
if firstMedia.mediaOptions.isEmpty {
HStack(spacing: 8) {
if case .loading = firstMedia.state {
ProgressView().controlSize(.small)
Text("Fetching media options...")
.foregroundStyle(.secondary)
} else if case .failed(let error) = firstMedia.state {
Image(systemName: "exclamationmark.triangle.fill").foregroundStyle(.red)
Text("Failed to load options.")
.foregroundStyle(.secondary)
} else {
ProgressView().controlSize(.small)
Text("Waiting for metadata...")
.foregroundStyle(.secondary)
}
}
.padding(.vertical, 4)
} else {
let currentOption = firstMedia.selectedMediaOption ?? firstMedia.mediaOptions.first!
let availableTypes = Array(Set(firstMedia.mediaOptions.map(\.mediaType))).sorted(by: { $0.rawValue > $1.rawValue })
let optionsForType = firstMedia.mediaOptions.filter { $0.mediaType == currentOption.mediaType }
let availableFormats = Array(Set(optionsForType.map(\.containerName))).sorted()
let optionsForFormat = optionsForType.filter { $0.containerName == currentOption.containerName }
let availableQualities = Array(Set(optionsForFormat.map(\.qualityName))).sorted(by: {
if $0 == "Best" { return true }
if $1 == "Best" { return false }
return $0 > $1
})
Picker("Type", selection: Binding(
get: { currentOption.mediaType },
set: { newType in
if let firstOfNewType = firstMedia.mediaOptions.first(where: { $0.mediaType == newType }) {
updateMediaOption(for: firstMedia, newId: firstOfNewType.id)
}
}
)) {
ForEach(availableTypes, id: \.self) { type in
Text(type.rawValue).tag(type)
}
}
.pickerStyle(.segmented)
.padding(.bottom, 4)
Picker("Format", selection: Binding(
get: { currentOption.containerName },
set: { newFormat in
let matching = optionsForType.first(where: { $0.containerName == newFormat && $0.qualityName == currentOption.qualityName })
let fallback = optionsForType.first(where: { $0.containerName == newFormat })
if let newOption = matching ?? fallback {
updateMediaOption(for: firstMedia, newId: newOption.id)
}
}
)) {
ForEach(availableFormats, id: \.self) { format in
Text(format).tag(format)
}
}
if currentOption.mediaType == .video {
Picker("Quality", selection: Binding(
get: { currentOption.qualityName },
set: { newQuality in
if let newOption = optionsForFormat.first(where: { $0.qualityName == newQuality }) {
updateMediaOption(for: firstMedia, newId: newOption.id)
}
}
)) {
ForEach(availableQualities, id: \.self) { quality in
Text(quality).tag(quality)
}
}
} else {
Picker("Quality", selection: .constant("Best")) {
Text("Best").tag("Best")
}
.disabled(true)
}
} // End of else block
} header: {
Text("Media Format").foregroundStyle(.blue)
}
}
private var advancedTransferSection: some View {
DisclosureGroup(isExpanded: $showsAdvancedTransfer) {
Grid(alignment: .leading, horizontalSpacing: 12, verticalSpacing: 8) {
GridRow(alignment: .firstTextBaseline) {
Toggle("Checksum", isOn: $checksumEnabled)
.font(.subheadline.weight(.semibold))
HStack(spacing: 8) {
Section {
DisclosureGroup(isExpanded: $showsAdvancedTransfer) {
VStack(alignment: .leading, spacing: 12) {
Toggle("Verify Checksum", isOn: $checksumEnabled)
if checksumEnabled {
Picker("Algorithm", selection: $checksumAlgorithm) {
ForEach(ChecksumAlgorithm.allCases) { algorithm in
Text(algorithm.title).tag(algorithm)
}
}
.labelsHidden()
.frame(width: 130)
TextField("Expected digest", text: $checksumValue)
.textFieldStyle(.roundedBorder)
.font(.system(.callout, design: .monospaced))
}
.disabled(!checksumEnabled)
}
GridRow(alignment: .top) {
Label("Headers", systemImage: "text.quote")
.font(.subheadline.weight(.semibold))
TextEditor(text: $headerText)
.font(.system(.callout, design: .monospaced))
.scrollContentBackground(.hidden)
.background(.quaternary.opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 8))
.frame(minHeight: 48)
}
VStack(alignment: .leading, spacing: 4) {
Text("Headers")
TextEditor(text: $headerText)
.font(.system(.callout, design: .monospaced))
.scrollContentBackground(.hidden)
.background(.quaternary.opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 8))
.frame(minHeight: 48)
}
GridRow(alignment: .firstTextBaseline) {
Label("Cookies", systemImage: "circle.hexagongrid.circle")
.font(.subheadline.weight(.semibold))
TextField("name=value; other=value", text: $cookieText)
.textFieldStyle(.roundedBorder)
.font(.system(.callout, design: .monospaced))
}
VStack(alignment: .leading, spacing: 4) {
Text("Cookies")
TextField("name=value; other=value", text: $cookieText)
.textFieldStyle(.roundedBorder)
.font(.system(.callout, design: .monospaced))
}
GridRow(alignment: .top) {
Label("Mirrors", systemImage: "point.3.filled.connected.trianglepath.dotted")
.font(.subheadline.weight(.semibold))
TextEditor(text: $mirrorText)
.font(.system(.callout, design: .monospaced))
.scrollContentBackground(.hidden)
.background(.quaternary.opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 8))
.frame(minHeight: 48)
VStack(alignment: .leading, spacing: 4) {
Text("Mirrors")
TextEditor(text: $mirrorText)
.font(.system(.callout, design: .monospaced))
.scrollContentBackground(.hidden)
.background(.quaternary.opacity(0.35))
.clipShape(RoundedRectangle(cornerRadius: 8))
.frame(minHeight: 48)
}
}
.padding(.top, 8)
} label: {
Label("Advanced Transfer", systemImage: "slider.horizontal.3")
.font(.subheadline.weight(.semibold))
}
.padding(.top, 8)
} label: {
Label("Advanced Transfer", systemImage: "slider.horizontal.3")
.font(.subheadline.weight(.semibold))
}
}
+75 -6
View File
@@ -185,10 +185,18 @@ final class AppSettings: ObservableObject {
@Published var extensionPairingToken: String {
didSet {
KeychainCredentialStore.setExtensionToken(extensionPairingToken)
if isKeychainAccessGranted {
KeychainCredentialStore.setExtensionToken(extensionPairingToken)
}
}
}
@Published var isKeychainAccessGranted: Bool {
didSet { save() }
}
@Published var showKeychainPrimer = false
@Published var message = ""
private let defaults: UserDefaults
@@ -198,6 +206,7 @@ final class AppSettings: ObservableObject {
init(defaults: UserDefaults = .standard) {
self.defaults = defaults
let granted: Bool
if let data = defaults.data(forKey: storageKey),
let stored = try? JSONDecoder().decode(StoredSettings.self, from: data) {
appTheme = stored.appTheme ?? .system
@@ -211,6 +220,8 @@ final class AppSettings: ObservableObject {
siteLogins = stored.siteLogins
mediaCookieSource = stored.mediaCookieSource ?? .none
downloadDirectories = Self.decodeDirectories(stored.downloadDirectories)
granted = stored.isKeychainAccessGranted ?? false
isKeychainAccessGranted = granted
} else {
appTheme = .system
appFontSize = .standard
@@ -223,13 +234,37 @@ final class AppSettings: ObservableObject {
siteLogins = []
mediaCookieSource = .none
downloadDirectories = Self.defaultDirectories()
granted = false
isKeychainAccessGranted = granted
}
if let token = KeychainCredentialStore.extensionToken() {
extensionPairingToken = token
let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
let currentBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "unknown"
let fullVersion = "\(currentVersion).\(currentBuild)"
let lastVersion = defaults.string(forKey: "Firelink.lastLaunchedVersion")
defaults.set(fullVersion, forKey: "Firelink.lastLaunchedVersion")
var needsPrimer = false
if granted {
if let lastVersion, lastVersion != fullVersion {
needsPrimer = true
}
}
if granted {
if needsPrimer {
showKeychainPrimer = true
extensionPairingToken = ""
} else {
if let token = KeychainCredentialStore.extensionToken() {
extensionPairingToken = token
} else {
extensionPairingToken = Self.generateSecureToken()
// The didSet of extensionPairingToken will handle setting it in the keychain since isKeychainAccessGranted is true.
}
}
} else {
extensionPairingToken = Self.generateSecureToken()
KeychainCredentialStore.setExtensionToken(extensionPairingToken)
extensionPairingToken = ""
}
for category in DownloadCategory.allCases where downloadDirectories[category] == nil {
@@ -333,6 +368,38 @@ final class AppSettings: ObservableObject {
return DownloadCredentials(username: login.username, password: password)
}
func grantKeychainAccess() {
isKeychainAccessGranted = true
if let token = KeychainCredentialStore.extensionToken() {
extensionPairingToken = token
} else {
extensionPairingToken = Self.generateSecureToken()
}
}
func revokeKeychainAccess() {
KeychainCredentialStore.deleteExtensionToken()
for login in siteLogins {
KeychainCredentialStore.deletePassword(for: login.id)
}
siteLogins.removeAll()
extensionPairingToken = ""
isKeychainAccessGranted = false
}
func resolveKeychainPrimer(grantAccess: Bool) {
showKeychainPrimer = false
if grantAccess {
if let token = KeychainCredentialStore.extensionToken() {
extensionPairingToken = token
} else {
extensionPairingToken = Self.generateSecureToken()
}
} else {
isKeychainAccessGranted = false
}
}
private func save() {
let stored = StoredSettings(
appTheme: appTheme,
@@ -345,7 +412,8 @@ final class AppSettings: ObservableObject {
proxySettings: proxySettings.normalized,
downloadDirectories: Dictionary(uniqueKeysWithValues: downloadDirectories.map { ($0.key.rawValue, $0.value) }),
siteLogins: siteLogins,
mediaCookieSource: mediaCookieSource
mediaCookieSource: mediaCookieSource,
isKeychainAccessGranted: isKeychainAccessGranted
)
let defaults = self.defaults
let storageKey = self.storageKey
@@ -426,4 +494,5 @@ private struct StoredSettings: Codable {
var downloadDirectories: [String: String]
var siteLogins: [SiteLogin]
var mediaCookieSource: BrowserCookieSource?
var isKeychainAccessGranted: Bool?
}
+75 -2
View File
@@ -27,7 +27,12 @@ struct ContentView: View {
_ = provider.loadObject(ofClass: URL.self) { url, _ in
if let url = url {
DispatchQueue.main.async {
controller.pendingPasteboardText = url.absoluteString
let newText = url.absoluteString
if let existing = controller.pendingPasteboardText, !existing.isEmpty {
controller.pendingPasteboardText = existing + "\n" + newText
} else {
controller.pendingPasteboardText = newText
}
controller.pendingReferer = nil
openWindow(id: "add-downloads")
}
@@ -37,7 +42,11 @@ struct ContentView: View {
_ = provider.loadObject(ofClass: String.self) { text, _ in
if let text = text {
DispatchQueue.main.async {
controller.pendingPasteboardText = text
if let existing = controller.pendingPasteboardText, !existing.isEmpty {
controller.pendingPasteboardText = existing + "\n" + text
} else {
controller.pendingPasteboardText = text
}
controller.pendingReferer = nil
openWindow(id: "add-downloads")
}
@@ -47,6 +56,10 @@ struct ContentView: View {
}
return true
}
.sheet(isPresented: $settings.showKeychainPrimer) {
KeychainPrimerView()
.environmentObject(settings)
}
}
@ViewBuilder
@@ -142,18 +155,24 @@ struct ContentView: View {
}
.keyboardShortcut(.delete, modifiers: [])
.opacity(0)
.buttonStyle(.plain)
.focusable(false)
Button("") {
handlePaste(queueID: queueID)
}
.keyboardShortcut("v", modifiers: .command)
.opacity(0)
.buttonStyle(.plain)
.focusable(false)
Button("") {
selectAll(items: items)
}
.keyboardShortcut("a", modifiers: .command)
.opacity(0)
.buttonStyle(.plain)
.focusable(false)
Button("") {
if let item = selectedItems.first {
@@ -162,6 +181,8 @@ struct ContentView: View {
}
.keyboardShortcut(.return, modifiers: [])
.opacity(0)
.buttonStyle(.plain)
.focusable(false)
}
.confirmationDialog(
"Delete \(selection.count) Download\(selection.count == 1 ? "" : "s")",
@@ -243,3 +264,55 @@ struct ContentView: View {
}
}
}
struct KeychainPrimerView: View {
@EnvironmentObject private var settings: AppSettings
@Environment(\.dismiss) private var dismiss
var body: some View {
VStack(spacing: 24) {
Image(systemName: "lock.shield")
.resizable()
.scaledToFit()
.frame(width: 64, height: 64)
.foregroundStyle(settings.appTheme.theme.accent ?? Color.accentColor)
.padding(.top, 16)
VStack(spacing: 8) {
Text("Security Update")
.font(.title2)
.fontWeight(.semibold)
Text("Firelink has been updated. To keep your browser extension running smoothly and your site logins secure, please re-authorize access to your Mac's Keychain on the next prompt.")
.font(.body)
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
.padding(.horizontal)
}
VStack(spacing: 12) {
Button {
settings.resolveKeychainPrimer(grantAccess: true)
} label: {
Text("Grant Secure Access")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
Button {
settings.resolveKeychainPrimer(grantAccess: false)
} label: {
Text("Not Now")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderless)
.controlSize(.large)
}
.padding(.horizontal, 32)
.padding(.bottom, 16)
}
.padding(24)
.frame(width: 400)
}
}
+43 -8
View File
@@ -29,6 +29,9 @@ final class DownloadController: ObservableObject {
return supportDir.appendingPathComponent("Firelink").appendingPathComponent("downloads.json")
}()
private var saveTask: Task<Void, Never>?
private var pendingNotifications: [(title: String, body: String)] = []
private var notificationDebounceTask: Task<Void, Never>?
private var lastProgressUpdateTimes: [UUID: Date] = [:]
init(settings: AppSettings) {
self.settings = settings
@@ -230,6 +233,7 @@ final class DownloadController: ObservableObject {
}
func pause(_ item: DownloadItem) {
lastProgressUpdateTimes[item.id] = nil
activeHandles[item.id]?.cancel()
activeHandles[item.id] = nil
activeMediaHandles[item.id]?.cancel()
@@ -530,6 +534,11 @@ final class DownloadController: ObservableObject {
speedLimitKiBPerSecond: effectiveSpeedLimitKiBPerSecond(for: liveItem),
progress: { [weak self] progress in
Task { @MainActor in
let now = Date()
if let last = self?.lastProgressUpdateTimes[item.id], now.timeIntervalSince(last) < 0.25 {
return
}
self?.lastProgressUpdateTimes[item.id] = now
self?.update(item.id) {
guard $0.status == .downloading else { return }
$0.progress = progress.fraction
@@ -581,6 +590,11 @@ final class DownloadController: ObservableObject {
speedLimitKiBPerSecond: effectiveSpeedLimitKiBPerSecond(for: item),
progress: { [weak self] progress in
Task { @MainActor in
let now = Date()
if let last = self?.lastProgressUpdateTimes[item.id], now.timeIntervalSince(last) < 0.25 {
return
}
self?.lastProgressUpdateTimes[item.id] = now
self?.update(item.id) {
guard $0.status == .downloading else { return }
$0.progress = progress.fraction
@@ -1088,14 +1102,35 @@ final class DownloadController: ObservableObject {
}
private func showNotification(title: String, body: String) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { granted, _ in
guard granted else { return }
let content = UNMutableNotificationContent()
content.title = title
content.body = body
content.sound = .default
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
UNUserNotificationCenter.current().add(request)
pendingNotifications.append((title: title, body: body))
notificationDebounceTask?.cancel()
notificationDebounceTask = Task { @MainActor in
do {
try await Task.sleep(nanoseconds: 1_000_000_000)
guard !Task.isCancelled else { return }
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { [weak self] granted, _ in
guard granted, let self else { return }
Task { @MainActor in
let items = self.pendingNotifications
self.pendingNotifications.removeAll()
guard !items.isEmpty else { return }
let content = UNMutableNotificationContent()
if items.count == 1 {
content.title = items[0].title
content.body = items[0].body
} else {
content.title = "\(items.count) Downloads Completed"
content.body = "Multiple items have finished downloading."
}
content.sound = .default
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
UNUserNotificationCenter.current().add(request)
}
}
} catch {}
}
}
}
+35 -37
View File
@@ -104,6 +104,7 @@ struct DownloadTable: View {
.width(min: 100, ideal: 155)
}
.environment(\.defaultMinListRowHeight, settings.listRowDensity.minRowHeight)
.animation(.default, value: sortedItems)
.contextMenu(forSelectionType: DownloadItem.ID.self) { itemIDs in
rowContextMenu(for: itemIDs)
} primaryAction: { itemIDs in
@@ -202,33 +203,37 @@ struct DownloadTable: View {
Divider()
if targetItems.contains(where: { $0.status == .paused || $0.status == .failed || $0.status == .canceled }) {
Button {
for target in targetItems where target.status == .paused || target.status == .failed || target.status == .canceled {
controller.resume(target)
}
} label: {
Label("Start", systemImage: "play.fill")
}
}
Divider()
if targetItems.contains(where: { $0.status == .downloading || $0.status == .queued }) {
Button {
for target in targetItems where target.status == .downloading || target.status == .queued {
controller.pause(target)
Menu("Controls") {
if targetItems.contains(where: { $0.status == .paused || $0.status == .failed || $0.status == .canceled }) {
Button {
for target in targetItems where target.status == .paused || target.status == .failed || target.status == .canceled {
controller.resume(target)
}
} label: {
Label("Start", systemImage: "play.fill")
}
} label: {
Label("Stop", systemImage: "stop.fill")
}
}
if targetItems.contains(where: { $0.status == .completed || $0.status == .failed || $0.status == .canceled }) {
Button {
for target in targetItems where target.status == .completed || target.status == .failed || target.status == .canceled {
controller.redownload(target)
if targetItems.contains(where: { $0.status == .downloading || $0.status == .queued }) {
Button {
for target in targetItems where target.status == .downloading || target.status == .queued {
controller.pause(target)
}
} label: {
Label("Stop", systemImage: "stop.fill")
}
}
if targetItems.contains(where: { $0.status == .completed || $0.status == .failed || $0.status == .canceled }) {
Button {
for target in targetItems where target.status == .completed || target.status == .failed || target.status == .canceled {
controller.redownload(target)
}
} label: {
Label("Redownload", systemImage: "arrow.clockwise")
}
} label: {
Label("Redownload", systemImage: "arrow.clockwise")
}
}
@@ -306,22 +311,15 @@ struct DownloadTable: View {
.lineLimit(1)
.truncationMode(.tail)
} else {
GeometryReader { proxy in
ZStack {
RoundedRectangle(cornerRadius: 4)
.fill(Color.secondary.opacity(0.15))
RoundedRectangle(cornerRadius: 4)
.fill(statusColor(for: item.status))
.frame(width: max(0, proxy.size.width * item.progress))
.frame(maxWidth: .infinity, alignment: .leading)
Text(item.progress.formatted(.percent.precision(.fractionLength(0))))
.font(.system(size: 11, weight: .medium, design: .monospaced))
.foregroundColor(.primary)
}
HStack(spacing: 4) {
ProgressView(value: item.progress)
.progressViewStyle(.linear)
.tint(statusColor(for: item.status))
Text(item.progress.formatted(.percent.precision(.fractionLength(0))))
.font(.system(size: 11, weight: .medium, design: .monospaced))
.frame(width: 35, alignment: .trailing)
}
.frame(height: 16)
}
}
@@ -10,7 +10,8 @@ enum KeychainCredentialStore {
kSecAttrService as String: service,
kSecAttrAccount as String: id.uuidString,
kSecReturnData as String: true,
kSecMatchLimit as String: kSecMatchLimitOne
kSecMatchLimit as String: kSecMatchLimitOne,
kSecUseAuthenticationUI as String: kSecUseAuthenticationUIFail
]
var result: CFTypeRef?
@@ -57,7 +58,8 @@ enum KeychainCredentialStore {
kSecAttrService as String: extensionTokenService,
kSecAttrAccount as String: extensionTokenAccount,
kSecReturnData as String: true,
kSecMatchLimit as String: kSecMatchLimitOne
kSecMatchLimit as String: kSecMatchLimitOne,
kSecUseAuthenticationUI as String: kSecUseAuthenticationUIFail
]
var result: CFTypeRef?
+11 -3
View File
@@ -56,12 +56,17 @@ final class LocalExtensionServer: @unchecked Sendable {
private func handleConnection(_ connection: NWConnection) {
connection.start(queue: queue)
receiveRequest(from: connection, accumulatedData: Data())
let timeoutItem = DispatchWorkItem { [weak connection] in
connection?.cancel()
}
queue.asyncAfter(deadline: .now() + 5.0, execute: timeoutItem)
receiveRequest(from: connection, accumulatedData: Data(), timeoutItem: timeoutItem)
}
private func receiveRequest(from connection: NWConnection, accumulatedData: Data) {
private func receiveRequest(from connection: NWConnection, accumulatedData: Data, timeoutItem: DispatchWorkItem) {
connection.receive(minimumIncompleteLength: 1, maximumLength: 65536) { [weak self] data, _, isComplete, error in
guard let self else {
timeoutItem.cancel()
connection.cancel()
return
}
@@ -72,22 +77,25 @@ final class LocalExtensionServer: @unchecked Sendable {
}
guard error == nil, requestData.count <= Constants.maxRequestBytes else {
timeoutItem.cancel()
self.sendResponse(.payloadTooLarge, connection: connection, origin: nil)
return
}
if let request = HTTPRequest(data: requestData) {
timeoutItem.cancel()
let status = self.processRequest(request)
self.sendResponse(status, connection: connection, origin: request.header(named: "origin"))
return
}
if isComplete {
timeoutItem.cancel()
self.sendResponse(.badRequest, connection: connection, origin: nil)
return
}
self.receiveRequest(from: connection, accumulatedData: requestData)
self.receiveRequest(from: connection, accumulatedData: requestData, timeoutItem: timeoutItem)
}
}
+15 -13
View File
@@ -161,21 +161,23 @@ final class MediaDownloadEngine: @unchecked Sendable {
}
let baseName = expectedURL.deletingPathExtension().lastPathComponent
guard let contents = try? FileManager.default.contentsOfDirectory(
at: item.destinationDirectory,
includingPropertiesForKeys: [.contentModificationDateKey],
options: [.skipsHiddenFiles]
) else {
return expectedURL
let commonExtensions = ["mp4", "mkv", "webm", "mp3", "m4a", "opus", "m4v", "aac", "wav", "flac"]
var mostRecent: URL?
var mostRecentDate: Date = .distantPast
for ext in commonExtensions {
let candidate = item.destinationDirectory.appendingPathComponent("\(baseName).\(ext)")
if FileManager.default.fileExists(atPath: candidate.path) {
let date = (try? candidate.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast
if date >= mostRecentDate {
mostRecentDate = date
mostRecent = candidate
}
}
}
return contents
.filter { $0.deletingPathExtension().lastPathComponent == baseName }
.max { lhs, rhs in
let lhsDate = (try? lhs.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast
let rhsDate = (try? rhs.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast
return lhsDate < rhsDate
} ?? expectedURL
return mostRecent ?? expectedURL
}
private static func cleanErrorMessage(_ message: String, status: Int32) -> String {
+25 -4
View File
@@ -26,6 +26,11 @@ struct MediaMetadata: Decodable, Sendable, Equatable {
}
}
enum MediaType: String, Sendable, Equatable {
case video = "Video"
case audio = "Audio"
}
struct CleanFormatOption: Identifiable, Equatable, Sendable {
var id: String { name }
let name: String
@@ -35,6 +40,10 @@ struct CleanFormatOption: Identifiable, Equatable, Sendable {
let outputExtension: String
let detail: String
let estimatedBytes: Int64?
let mediaType: MediaType
let qualityName: String
let containerName: String
}
enum MediaExtractionEngine {
@@ -194,7 +203,10 @@ enum MediaExtractionEngine {
base: height == nil ? "Best available video" : "Up to \(qualityName)",
estimatedBytes: estimatedBytes
),
estimatedBytes: estimatedBytes
estimatedBytes: estimatedBytes,
mediaType: .video,
qualityName: qualityName,
containerName: containerName
))
}
}
@@ -208,7 +220,10 @@ enum MediaExtractionEngine {
symbol: "music.note",
outputExtension: "mp3",
detail: optionDetail(base: "Converted with ffmpeg", estimatedBytes: estimatedBytes),
estimatedBytes: estimatedBytes
estimatedBytes: estimatedBytes,
mediaType: .audio,
qualityName: "Best",
containerName: "MP3"
))
}
@@ -221,7 +236,10 @@ enum MediaExtractionEngine {
symbol: "waveform",
outputExtension: "m4a",
detail: optionDetail(base: "Prefer native M4A", estimatedBytes: estimatedBytes),
estimatedBytes: estimatedBytes
estimatedBytes: estimatedBytes,
mediaType: .audio,
qualityName: "Best",
containerName: "M4A"
))
}
@@ -234,7 +252,10 @@ enum MediaExtractionEngine {
symbol: "waveform",
outputExtension: "opus",
detail: optionDetail(base: "Efficient audio", estimatedBytes: estimatedBytes),
estimatedBytes: estimatedBytes
estimatedBytes: estimatedBytes,
mediaType: .audio,
qualityName: "Best",
containerName: "Opus"
))
}
+62 -145
View File
@@ -101,164 +101,81 @@ struct AboutSettingsPane: View {
@ViewBuilder
private var updateStatusView: some View {
switch updateChecker.state {
case .idle:
VStack(alignment: .leading, spacing: 12) {
updateHeader(
systemImage: "arrow.down.circle",
tint: .blue,
title: "Check for Updates",
subtitle: "Firelink checks GitHub Releases and opens the download page when a new version is available."
)
HStack(spacing: 12) {
Button {
updateChecker.checkForUpdates()
} label: {
Label("Check for Updates", systemImage: "arrow.clockwise")
}
.buttonStyle(.bordered)
Button {
NSWorkspace.shared.open(releasesURL)
} label: {
Label("Release Notes", systemImage: "doc.text")
}
}
}
case .checking:
HStack(spacing: 12) {
ProgressView()
.controlSize(.small)
VStack(alignment: .leading, spacing: 3) {
Text("Checking GitHub Releases")
HStack(alignment: .center) {
switch updateChecker.state {
case .idle:
VStack(alignment: .leading, spacing: 2) {
Text("Check for Updates")
.font(.headline)
Text("Looking for the latest stable Firelink release.")
Text("Firelink checks GitHub Releases for new versions.")
.font(.subheadline)
.foregroundStyle(.secondary)
}
}
case .updateAvailable(let update):
VStack(alignment: .leading, spacing: 12) {
updateHeader(
systemImage: "arrow.down.circle.fill",
tint: .green,
title: "Firelink \(update.version) Is Available",
subtitle: "You have Firelink \(appVersion). Download the new release from GitHub when you're ready."
)
releaseNotesDisclosure(for: update)
HStack(spacing: 12) {
Button {
NSWorkspace.shared.open(update.releaseURL)
} label: {
Label("Open GitHub Release", systemImage: "arrow.up.forward.app")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
Button {
updateChecker.checkForUpdates()
} label: {
Label("Check Again", systemImage: "arrow.clockwise")
}
.buttonStyle(.bordered)
Spacer()
Button("Check Now") {
updateChecker.checkForUpdates()
}
}
case .upToDate(let latestVersion, let localVersion):
VStack(alignment: .leading, spacing: 12) {
let subtitle = latestVersion == localVersion
? "Firelink \(localVersion) is the newest stable release."
: "Firelink \(localVersion) is newer than the latest stable GitHub release, \(latestVersion)."
updateHeader(
systemImage: "checkmark.seal.fill",
tint: .green,
title: "You're Up to Date",
subtitle: subtitle
)
HStack(spacing: 12) {
Button {
updateChecker.checkForUpdates()
} label: {
Label("Check Again", systemImage: "arrow.clockwise")
}
.buttonStyle(.bordered)
Button {
NSWorkspace.shared.open(releasesURL)
} label: {
Label("Release Notes", systemImage: "doc.text")
}
case .checking:
VStack(alignment: .leading, spacing: 2) {
Text("Checking for updates...")
.font(.headline)
Text("Connecting to GitHub...")
.font(.subheadline)
.foregroundStyle(.secondary)
}
}
Spacer()
ProgressView()
.controlSize(.small)
.padding(.trailing, 16)
case .failed(let message, let recovery):
VStack(alignment: .leading, spacing: 12) {
updateHeader(
systemImage: "exclamationmark.triangle.fill",
tint: .orange,
title: message,
subtitle: recovery
)
case .updateAvailable(let update):
VStack(alignment: .leading, spacing: 2) {
Text("Firelink \(update.version) is available!")
.font(.headline)
Text("You currently have version \(appVersion).")
.font(.subheadline)
.foregroundStyle(.secondary)
Link("View Release Notes", destination: update.releaseURL)
.font(.caption)
.padding(.top, 2)
}
Spacer()
Button("Download Update") {
NSWorkspace.shared.open(update.releaseURL)
}
.buttonStyle(.borderedProminent)
HStack(spacing: 12) {
Button {
updateChecker.checkForUpdates()
} label: {
Label("Check Again", systemImage: "arrow.clockwise")
}
.buttonStyle(.borderedProminent)
case .upToDate(let latestVersion, _):
VStack(alignment: .leading, spacing: 2) {
Text("Firelink is up to date")
.font(.headline)
Text("Version \(latestVersion) is the newest stable release.")
.font(.subheadline)
.foregroundStyle(.secondary)
}
Spacer()
Button("Check Again") {
updateChecker.checkForUpdates()
}
Button {
NSWorkspace.shared.open(releasesURL)
} label: {
Label("Open Releases", systemImage: "safari")
}
case .failed(let message, let recovery):
VStack(alignment: .leading, spacing: 2) {
Text(message)
.font(.headline)
Text(recovery)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(2)
}
Spacer()
Button("Try Again") {
updateChecker.checkForUpdates()
}
}
}
.padding(.vertical, 4)
}
private func updateHeader(systemImage: String, tint: Color, title: String, subtitle: String) -> some View {
HStack(alignment: .top, spacing: 12) {
Image(systemName: systemImage)
.font(.title2)
.foregroundStyle(tint)
.frame(width: 28)
VStack(alignment: .leading, spacing: 4) {
Text(title)
.font(.headline)
Text(subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
}
private func releaseNotesDisclosure(for update: AvailableReleaseUpdate) -> some View {
DisclosureGroup("What's New") {
ScrollView {
Text(releaseNotes(from: update.releaseNotes))
.font(.caption)
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
}
.frame(maxHeight: 180)
.padding(8)
.background(Color(NSColor.controlBackgroundColor))
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
}
}
private func releaseNotes(from markdown: String) -> AttributedString {
(try? AttributedString(markdown: markdown)) ?? AttributedString(markdown)
}
}
@@ -7,82 +7,94 @@ struct IntegrationSettingsPane: View {
@State private var showToast = false
var body: some View {
ScrollView {
VStack(spacing: 24) {
// Header
HStack(alignment: .center, spacing: 16) {
Image(systemName: "puzzlepiece.extension.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 48, height: 48)
.foregroundStyle(Color(nsColor: NSColor(red: 1.0, green: 0.44, blue: 0.22, alpha: 1.0)))
.accessibilityHidden(true)
VStack(spacing: 20) {
// Header
HStack(alignment: .center, spacing: 16) {
Image(systemName: "puzzlepiece.extension.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 40, height: 40)
.foregroundStyle(Color(nsColor: NSColor(red: 1.0, green: 0.44, blue: 0.22, alpha: 1.0)))
.accessibilityHidden(true)
VStack(alignment: .leading, spacing: 4) {
Text("Connect Browser Extension")
.font(.title.weight(.bold))
Text("Capture downloads directly from your browser in three easy steps.")
.foregroundStyle(.secondary)
.font(.body)
}
Spacer()
VStack(alignment: .leading, spacing: 4) {
Text("Connect Browser Extension")
.font(.title2.weight(.bold))
Text("Capture downloads directly from your browser in three easy steps.")
.foregroundStyle(.secondary)
.font(.subheadline)
}
.padding(.bottom, 8)
Spacer()
}
// Step 1: Copy Token
StepCardView(
stepNumber: 1,
title: "Copy Pairing Token",
description: "This secure token authorizes your browser extension.",
icon: "doc.on.clipboard.fill",
iconColor: .blue,
actionText: "Copy Token",
action: {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(settings.extensionPairingToken, forType: .string)
withAnimation {
showToast = true
}
},
secondaryActionText: "Regenerate",
secondaryAction: {
var bytes = [UInt8](repeating: 0, count: 32)
let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
settings.extensionPairingToken = status == errSecSuccess ? Data(bytes).base64EncodedString() : UUID().uuidString
}
)
KeychainAccessCard()
// Step 2: Get Extension
StepCardView(
stepNumber: 2,
title: "Get Extension",
description: "Install the Firelink Companion extension on your favorite browser.",
icon: "globe",
iconColor: .orange,
actionText: "Firefox Add-ons",
action: {
if let url = URL(string: "https://addons.mozilla.org/en-US/firefox/addon/firelink-companion/") {
NSWorkspace.shared.open(url)
if settings.isKeychainAccessGranted {
HStack(spacing: 12) {
// Step 1
CompactStepCardView(
stepNumber: 1,
title: "Copy Token",
description: "This secure token authorizes your browser extension.",
icon: "doc.on.clipboard.fill",
iconColor: .blue,
actionText: "Copy Token",
action: {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(settings.extensionPairingToken, forType: .string)
withAnimation {
showToast = true
}
},
secondaryActionText: "Regenerate",
secondaryAction: {
var bytes = [UInt8](repeating: 0, count: 32)
let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
settings.extensionPairingToken = status == errSecSuccess ? Data(bytes).base64EncodedString() : UUID().uuidString
}
},
secondaryActionText: "Releases",
secondaryAction: {
if let url = URL(string: "https://github.com/nimbold/Firelink-Extension/releases") {
NSWorkspace.shared.open(url)
}
}
)
)
// Step 3: Paste and Save
StepCardView(
stepNumber: 3,
title: "Paste & Connect",
description: "Click the Firelink icon in your browser's toolbar and paste the token into the App Pairing Token field.",
icon: "arrow.down.doc.fill",
iconColor: .green,
actionText: nil,
action: nil
)
Image(systemName: "chevron.right")
.font(.title3.weight(.bold))
.foregroundStyle(Color(nsColor: .tertiaryLabelColor))
// Step 2
CompactStepCardView(
stepNumber: 2,
title: "Get Extension",
description: "Install the Firelink Companion extension on your browser.",
icon: "globe",
iconColor: .orange,
actionText: "Firefox Add-ons",
action: {
if let url = URL(string: "https://addons.mozilla.org/en-US/firefox/addon/firelink-companion/") {
NSWorkspace.shared.open(url)
}
},
secondaryActionText: "Releases",
secondaryAction: {
if let url = URL(string: "https://github.com/nimbold/Firelink-Extension/releases") {
NSWorkspace.shared.open(url)
}
}
)
Image(systemName: "chevron.right")
.font(.title3.weight(.bold))
.foregroundStyle(Color(nsColor: .tertiaryLabelColor))
// Step 3
CompactStepCardView(
stepNumber: 3,
title: "Paste & Connect",
description: "Click the Firelink icon in your browser's toolbar and paste the token.",
icon: "arrow.down.doc.fill",
iconColor: .green,
actionText: nil,
action: nil
)
}
.fixedSize(horizontal: false, vertical: true)
Divider()
@@ -100,17 +112,16 @@ struct IntegrationSettingsPane: View {
}
}
.font(.footnote)
.padding(.top, 8)
}
.padding(32)
Spacer()
}
.padding(24)
.toast(isShowing: $showToast, message: "Token copied to clipboard!")
.background(Color(NSColor.windowBackgroundColor))
}
}
struct StepCardView: View {
struct CompactStepCardView: View {
let stepNumber: Int
let title: String
let description: String
@@ -122,83 +133,88 @@ struct StepCardView: View {
var secondaryAction: (() -> Void)? = nil
var body: some View {
HStack(spacing: 16) {
// Step Number Badge
ZStack {
Circle()
.fill(Color(nsColor: .controlBackgroundColor))
.frame(width: 32, height: 32)
.shadow(color: .black.opacity(0.1), radius: 2, y: 1)
Text("\(stepNumber)")
.font(.system(.headline, design: .rounded).weight(.bold))
.foregroundStyle(.primary)
}
// Icon
ZStack {
RoundedRectangle(cornerRadius: 12)
.fill(iconColor.opacity(0.15))
.frame(width: 48, height: 48)
Image(systemName: icon)
.font(.system(size: 24))
.foregroundStyle(iconColor)
VStack(spacing: 12) {
HStack(alignment: .top) {
// Step Number Badge
ZStack {
Circle()
.fill(Color(nsColor: .controlBackgroundColor))
.frame(width: 24, height: 24)
.shadow(color: .black.opacity(0.1), radius: 1, y: 1)
Text("\(stepNumber)")
.font(.system(.caption, design: .rounded).weight(.bold))
.foregroundStyle(.primary)
}
Spacer()
// Icon
ZStack {
RoundedRectangle(cornerRadius: 8)
.fill(iconColor.opacity(0.15))
.frame(width: 32, height: 32)
Image(systemName: icon)
.font(.system(size: 16))
.foregroundStyle(iconColor)
}
}
// Text Content
VStack(alignment: .leading, spacing: 4) {
Text(title)
.font(.headline)
.font(.subheadline.weight(.semibold))
.frame(maxWidth: .infinity, alignment: .leading)
Text(description)
.font(.subheadline)
.font(.caption)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
.fixedSize(horizontal: false, vertical: true)
}
Spacer()
Spacer(minLength: 8)
// Action Button
HStack(spacing: 8) {
VStack(spacing: 8) {
if let actionText = actionText, let action = action {
Button(action: action) {
Text(actionText)
.font(.caption.weight(.medium))
.frame(maxWidth: .infinity)
.padding(.vertical, 6)
.background(Color.accentColor)
.foregroundColor(.white)
.cornerRadius(6)
}
.buttonStyle(.plain)
}
if let secondaryActionText = secondaryActionText, let secondaryAction = secondaryAction {
Button(action: secondaryAction) {
Text(secondaryActionText)
.font(.subheadline.weight(.medium))
.padding(.horizontal, 16)
.padding(.vertical, 8)
.font(.caption.weight(.medium))
.frame(maxWidth: .infinity)
.padding(.vertical, 6)
.background(Color(nsColor: .controlBackgroundColor))
.foregroundColor(.primary)
.cornerRadius(8)
.cornerRadius(6)
.overlay(
RoundedRectangle(cornerRadius: 8)
RoundedRectangle(cornerRadius: 6)
.strokeBorder(Color(nsColor: .separatorColor).opacity(0.5), lineWidth: 1)
)
}
.buttonStyle(.plain)
}
if let actionText = actionText, let action = action {
Button(action: action) {
Text(actionText)
.font(.subheadline.weight(.medium))
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(Color.accentColor)
.foregroundColor(.white)
.cornerRadius(8)
}
.buttonStyle(.plain)
}
}
}
.padding(16)
.padding(12)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(
RoundedRectangle(cornerRadius: 16)
RoundedRectangle(cornerRadius: 12)
.fill(Color(nsColor: .controlBackgroundColor))
.shadow(color: .black.opacity(0.05), radius: 8, y: 2)
.shadow(color: .black.opacity(0.05), radius: 4, y: 1)
)
.overlay(
RoundedRectangle(cornerRadius: 16)
RoundedRectangle(cornerRadius: 12)
.strokeBorder(Color(nsColor: .separatorColor).opacity(0.5), lineWidth: 1)
)
}
@@ -0,0 +1,65 @@
import SwiftUI
struct KeychainAccessCard: View {
@EnvironmentObject private var settings: AppSettings
var body: some View {
HStack(spacing: 16) {
ZStack {
RoundedRectangle(cornerRadius: 10)
.fill(settings.isKeychainAccessGranted ? Color.green.opacity(0.15) : Color.blue.opacity(0.15))
.frame(width: 36, height: 36)
Image(systemName: settings.isKeychainAccessGranted ? "lock.open.fill" : "lock.fill")
.font(.system(size: 18))
.foregroundStyle(settings.isKeychainAccessGranted ? .green : .blue)
}
VStack(alignment: .leading, spacing: 2) {
Text("Keychain Access")
.font(.headline)
Text("Firelink needs Keychain access to securely store your browser extension pairing token.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
Spacer(minLength: 16)
if settings.isKeychainAccessGranted {
Label("Granted", systemImage: "checkmark.circle.fill")
.foregroundStyle(.green)
.font(.subheadline.weight(.medium))
Button(role: .destructive) {
settings.revokeKeychainAccess()
} label: {
Text("Revoke")
}
} else {
Button {
settings.grantKeychainAccess()
} label: {
Text("Grant Access")
.font(.subheadline.weight(.medium))
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Color.accentColor)
.foregroundColor(.white)
.cornerRadius(6)
}
.buttonStyle(.plain)
}
}
.padding(12)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color(nsColor: .controlBackgroundColor))
.shadow(color: .black.opacity(0.05), radius: 4, y: 1)
)
.overlay(
RoundedRectangle(cornerRadius: 12)
.strokeBorder(Color(nsColor: .separatorColor).opacity(0.5), lineWidth: 1)
)
}
}
@@ -9,7 +9,14 @@ struct SiteLoginsSettingsPane: View {
var body: some View {
Form {
Section(editingLoginID == nil ? "Add Login" : "Edit Login") {
Section {
KeychainAccessCard()
}
.listRowBackground(Color.clear)
.listRowInsets(EdgeInsets())
if settings.isKeychainAccessGranted {
Section(editingLoginID == nil ? "Add Login" : "Edit Login") {
TextField("URL Pattern (e.g., *.github.com)", text: $urlPattern)
TextField("Username", text: $username)
SecureField(editingLoginID == nil ? "Password" : "Password (leave blank to keep current)", text: $password)
@@ -71,6 +78,7 @@ struct SiteLoginsSettingsPane: View {
}
.frame(minHeight: 180)
}
}
}
}
.formStyle(.grouped)
@@ -26,11 +26,10 @@ struct ToastNotification: ViewModifier {
}
.zIndex(1)
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: isShowing)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation {
isShowing = false
}
.task {
try? await Task.sleep(nanoseconds: 2_000_000_000)
withAnimation {
isShowing = false
}
}
}
-1
View File
@@ -1 +0,0 @@