Skip to content

Commit

Permalink
feat: add custom sparkle updater
Browse files Browse the repository at this point in the history
upstreamed from branch `refactor/rewrite`, f41ccb7

Co-authored-by: Josh <[email protected]>
  • Loading branch information
vapidinfinity and JoshuaBrest committed Nov 15, 2024
1 parent aadb167 commit 7f9ea3d
Show file tree
Hide file tree
Showing 20 changed files with 1,425 additions and 34 deletions.
71 changes: 68 additions & 3 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@
6A496A732C1AF75B00FD637B /* Game.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A496A722C1AF75600FD637B /* Game.swift */; };
6A541C362CE6FB0400AD8A98 /* SetupWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6A541C352CE6FB0400AD8A98 /* SetupWindow.xib */; };
6A541C382CE6FBC600AD8A98 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6A541C372CE6FBC600AD8A98 /* MainMenu.xib */; };
6A541C3A2CE6FFD900AD8A98 /* SparkleUpdateControllerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C392CE6FFD900AD8A98 /* SparkleUpdateControllerModel.swift */; };
6A541C3C2CE7001000AD8A98 /* BundleIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C3B2CE7001000AD8A98 /* BundleIconView.swift */; };
6A541C3E2CE7001300AD8A98 /* RichAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C3D2CE7001300AD8A98 /* RichAlertView.swift */; };
6A541C472CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C452CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift */; };
6A541C482CE700CF00AD8A98 /* SparkleUpdaterExtractingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C422CE700CF00AD8A98 /* SparkleUpdaterExtractingView.swift */; };
6A541C492CE700CF00AD8A98 /* SparkleUpdaterPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C402CE700CF00AD8A98 /* SparkleUpdaterPreviewView.swift */; };
6A541C4A2CE700CF00AD8A98 /* SparkleUpdaterInstallingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C432CE700CF00AD8A98 /* SparkleUpdaterInstallingView.swift */; };
6A541C4B2CE700CF00AD8A98 /* SparkleUpdaterCheckingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C3F2CE700CF00AD8A98 /* SparkleUpdaterCheckingView.swift */; };
6A541C4C2CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C442CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift */; };
6A541C4D2CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A541C412CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift */; };
6A541C502CE7013800AD8A98 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 6A541C4F2CE7013800AD8A98 /* MarkdownUI */; };
6A71D3D92BFD01AB00A2C74D /* legendary in Resources */ = {isa = PBXBuildFile; fileRef = 6A71D3D82BFD01AB00A2C74D /* legendary */; };
6A71D3DD2BFD024D00A2C74D /* Auth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A71D3DC2BFD024D00A2C74D /* Auth.swift */; };
6A7A81162B77093600D19E32 /* ColorfulX in Frameworks */ = {isa = PBXBuildFile; productRef = 6A7A81152B77093600D19E32 /* ColorfulX */; };
Expand Down Expand Up @@ -219,6 +230,16 @@
6A496A722C1AF75600FD637B /* Game.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Game.swift; sourceTree = "<group>"; };
6A541C352CE6FB0400AD8A98 /* SetupWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SetupWindow.xib; sourceTree = "<group>"; };
6A541C372CE6FBC600AD8A98 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
6A541C392CE6FFD900AD8A98 /* SparkleUpdateControllerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdateControllerModel.swift; sourceTree = "<group>"; };
6A541C3B2CE7001000AD8A98 /* BundleIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleIconView.swift; sourceTree = "<group>"; };
6A541C3D2CE7001300AD8A98 /* RichAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RichAlertView.swift; sourceTree = "<group>"; };
6A541C3F2CE700CF00AD8A98 /* SparkleUpdaterCheckingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterCheckingView.swift; sourceTree = "<group>"; };
6A541C402CE700CF00AD8A98 /* SparkleUpdaterPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterPreviewView.swift; sourceTree = "<group>"; };
6A541C412CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterDownloadingView.swift; sourceTree = "<group>"; };
6A541C422CE700CF00AD8A98 /* SparkleUpdaterExtractingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterExtractingView.swift; sourceTree = "<group>"; };
6A541C432CE700CF00AD8A98 /* SparkleUpdaterInstallingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterInstallingView.swift; sourceTree = "<group>"; };
6A541C442CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterFinishView.swift; sourceTree = "<group>"; };
6A541C452CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleUpdaterSheetViewModifier.swift; sourceTree = "<group>"; };
6A71D3D82BFD01AB00A2C74D /* legendary */ = {isa = PBXFileReference; lastKnownFileType = folder; path = legendary; sourceTree = "<group>"; };
6A71D3DC2BFD024D00A2C74D /* Auth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
6A9FE1152CDEED7200C36058 /* WhatsNewCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNewCollection.swift; sourceTree = "<group>"; };
Expand All @@ -239,6 +260,7 @@
buildActionMask = 2147483647;
files = (
6A22B12A2CE6ECDC0055D837 /* BLAKE3 in Frameworks */,
6A541C502CE7013800AD8A98 /* MarkdownUI in Frameworks */,
6AC742DD2B9314AB000EA1B2 /* SwordRPC in Frameworks */,
6A7A81162B77093600D19E32 /* ColorfulX in Frameworks */,
6A2961052CE1DD6200917E90 /* FirebaseCore in Frameworks */,
Expand Down Expand Up @@ -283,13 +305,15 @@
6A22B12D2CE6ED2F0055D837 /* PersistentState */,
6A22B12E2CE6ED2F0055D837 /* AppLoggerModel.swift */,
6A22B12F2CE6ED2F0055D837 /* EngineInstallerModel.swift */,
6A541C392CE6FFD900AD8A98 /* SparkleUpdateControllerModel.swift */,
);
path = Models;
sourceTree = "<group>";
};
6A22B13E2CE6EE280055D837 /* Onboarding */ = {
isa = PBXGroup;
children = (
6A22B13D2CE6EE280055D837 /* OnboardingView.swift */,
6A22B1352CE6EE280055D837 /* OnboardingIntroStepView.swift */,
6A22B1362CE6EE280055D837 /* OnboardingEpicGamesLoginStepView.swift */,
6A22B1372CE6EE280055D837 /* OnboardingEpicGamesWelcomeStepView.swift */,
Expand All @@ -298,7 +322,6 @@
6A22B13A2CE6EE280055D837 /* OnboardingEngineTermsStepView.swift */,
6A22B13B2CE6EE280055D837 /* OnboardingEngineConfigStepView.swift */,
6A22B13C2CE6EE280055D837 /* OnboardingEngineInstallationStepView.swift */,
6A22B13D2CE6EE280055D837 /* OnboardingView.swift */,
);
path = Onboarding;
sourceTree = "<group>";
Expand Down Expand Up @@ -442,6 +465,7 @@
6A22B13E2CE6EE280055D837 /* Onboarding */,
6A2934D62BFCFAFD0035CE4B /* ContentView.swift */,
6A2C39912CE4EF9600B303AE /* Components */,
6A541C462CE700CF00AD8A98 /* SparkleUpdater */,
6A2934DA2BFCFAFD0035CE4B /* Navigation */,
6A2934EC2BFCFAFD0035CE4B /* Unified */,
6A2C39932CE4F01C00B303AE /* Legacy */,
Expand Down Expand Up @@ -483,6 +507,8 @@
isa = PBXGroup;
children = (
6A2C39902CE4EF9600B303AE /* ColorfulBackgroundView.swift */,
6A541C3B2CE7001000AD8A98 /* BundleIconView.swift */,
6A541C3D2CE7001300AD8A98 /* RichAlertView.swift */,
);
path = Components;
sourceTree = "<group>";
Expand All @@ -495,6 +521,20 @@
path = Legacy;
sourceTree = "<group>";
};
6A541C462CE700CF00AD8A98 /* SparkleUpdater */ = {
isa = PBXGroup;
children = (
6A541C3F2CE700CF00AD8A98 /* SparkleUpdaterCheckingView.swift */,
6A541C402CE700CF00AD8A98 /* SparkleUpdaterPreviewView.swift */,
6A541C412CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift */,
6A541C422CE700CF00AD8A98 /* SparkleUpdaterExtractingView.swift */,
6A541C432CE700CF00AD8A98 /* SparkleUpdaterInstallingView.swift */,
6A541C442CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift */,
6A541C452CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift */,
);
path = SparkleUpdater;
sourceTree = "<group>";
};
6A91FEC02C2BFB8100D9F153 /* Models */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -619,6 +659,7 @@
6A2961042CE1DD6200917E90 /* FirebaseCore */,
6A2961062CE1DD6200917E90 /* FirebaseCrashlytics */,
6A22B1292CE6ECDC0055D837 /* BLAKE3 */,
6A541C4F2CE7013800AD8A98 /* MarkdownUI */,
);
productName = Mythic;
productReference = 6AB474952AACBBE900AB9C63 /* Mythic.app */;
Expand Down Expand Up @@ -660,6 +701,7 @@
6AA1744D2CD5CC290035B081 /* XCRemoteSwiftPackageReference "WhatsNewKit" */,
6A2961012CE1DD6200917E90 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
6A22B1282CE6ECDC0055D837 /* XCRemoteSwiftPackageReference "blake3-swift" */,
6A541C4E2CE7013800AD8A98 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
);
productRefGroup = 6AB474962AACBBE900AB9C63 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -745,6 +787,13 @@
6A29353A2BFCFAFD0035CE4B /* Task.swift in Sources */,
6A2935592BFCFAFD0035CE4B /* ContainerCreationView.swift in Sources */,
6A2960FE2CE1017900917E90 /* NSApplication.swift in Sources */,
6A541C472CE700CF00AD8A98 /* SparkleUpdaterSheetViewModifier.swift in Sources */,
6A541C482CE700CF00AD8A98 /* SparkleUpdaterExtractingView.swift in Sources */,
6A541C492CE700CF00AD8A98 /* SparkleUpdaterPreviewView.swift in Sources */,
6A541C4A2CE700CF00AD8A98 /* SparkleUpdaterInstallingView.swift in Sources */,
6A541C4B2CE700CF00AD8A98 /* SparkleUpdaterCheckingView.swift in Sources */,
6A541C4C2CE700CF00AD8A98 /* SparkleUpdaterFinishView.swift in Sources */,
6A541C4D2CE700CF00AD8A98 /* SparkleUpdaterDownloadingView.swift in Sources */,
6A448E102CC4BC55001E9F47 /* GameCardVM.swift in Sources */,
6A2935562BFCFAFD0035CE4B /* GameCard.swift in Sources */,
6A2935622BFCFAFD0035CE4B /* NotImplementedView.swift in Sources */,
Expand Down Expand Up @@ -793,14 +842,17 @@
6AF495F42CE4EF1300C251EA /* HubWindowController.swift in Sources */,
6AF495F52CE4EF1300C251EA /* SetupWindowController.swift in Sources */,
6A2935632BFCFAFD0035CE4B /* WebView.swift in Sources */,
6A541C3E2CE7001300AD8A98 /* RichAlertView.swift in Sources */,
6AAD47152CE6513F00B08564 /* DirectoriesUtility.swift in Sources */,
6A2935582BFCFAFD0035CE4B /* SubscriptedTextView.swift in Sources */,
6A2935542BFCFAFD0035CE4B /* SupportView.swift in Sources */,
6A29354E2BFCFAFD0035CE4B /* ContainersView.swift in Sources */,
6A2935412BFCFAFD0035CE4B /* WineInterface.swift in Sources */,
6A541C3A2CE6FFD900AD8A98 /* SparkleUpdateControllerModel.swift in Sources */,
6A2935362BFCFAFD0035CE4B /* Color.swift in Sources */,
6A2935512BFCFAFD0035CE4B /* ContentView.swift in Sources */,
6A29353E2BFCFAFD0035CE4B /* LegendaryInterfaceExt.swift in Sources */,
6A541C3C2CE7001000AD8A98 /* BundleIconView.swift in Sources */,
6A71D3DD2BFD024D00A2C74D /* Auth.swift in Sources */,
6A29354B2BFCFAFD0035CE4B /* LocalImport.swift in Sources */,
6A2960FC2CE0ED0D00917E90 /* EpicWebAuthView.swift in Sources */,
Expand Down Expand Up @@ -969,7 +1021,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3478;
CURRENT_PROJECT_VERSION = 3480;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
Expand Down Expand Up @@ -1017,7 +1069,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3478;
CURRENT_PROJECT_VERSION = 3480;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
Expand Down Expand Up @@ -1118,6 +1170,14 @@
minimumVersion = 0.9.17;
};
};
6A541C4E2CE7013800AD8A98 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.4.1;
};
};
6A7A81142B77093600D19E32 /* XCRemoteSwiftPackageReference "ColorfulX" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Lakr233/ColorfulX";
Expand Down Expand Up @@ -1204,6 +1264,11 @@
package = 6A371B572AE7DFBF0054BF7A /* XCRemoteSwiftPackageReference "ZIPFoundation" */;
productName = ZIPFoundation;
};
6A541C4F2CE7013800AD8A98 /* MarkdownUI */ = {
isa = XCSwiftPackageProductDependency;
package = 6A541C4E2CE7013800AD8A98 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */;
productName = MarkdownUI;
};
6A7A81152B77093600D19E32 /* ColorfulX */ = {
isa = XCSwiftPackageProductDependency;
package = 6A7A81142B77093600D19E32 /* XCRemoteSwiftPackageReference "ColorfulX" */;
Expand Down
7 changes: 5 additions & 2 deletions Mythic/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import Foundation
import AppKit
import Combine
import SemanticVersion

public class AppDelegate: NSObject, NSApplicationDelegate {
public static let shared = AppDelegate()

public static let bundleIdentifier = Bundle.main.bundleIdentifier ?? "Mythic"
public static let applicationVersion = SemanticVersion(Bundle.main.infoDictionary?["CFBundleShortVersionString"]
as? String ?? "0.0.0") ?? .init(0, 0, 0)
public static let applicationBundleName = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "Application"

private let logger = AppLoggerModel(category: AppDelegate.self)
Expand All @@ -33,9 +36,9 @@ public class AppDelegate: NSObject, NSApplicationDelegate {
}

/// Listen for events
private func listenEvents() {
@MainActor private func listenEvents() {
// Flush old cancellables
let _ = cancellables.map({ $0.cancel() })
cancellables.forEach({ $0.cancel() })
cancellables.removeAll()

// Listen for onboarding state changes
Expand Down
3 changes: 2 additions & 1 deletion Mythic/App/AppMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ public class AppMenuController {
}

@objc private func checkForUpdates() {
// todo
let sparkle = SparkleUpdateControllerModel.shared
sparkle.checkForUpdates(userInitiated: true)
}

@objc private func restartOnboarding() {
Expand Down
78 changes: 78 additions & 0 deletions Mythic/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9234,6 +9234,9 @@
}
}
}
},
"common.cancel" : {

},
"common.finish" : {

Expand Down Expand Up @@ -27193,6 +27196,9 @@
},
"onboardingEpicGamesLoginStepView.description" : {

},
"onboardingEpicGamesLoginStepView.epicGamesSignin" : {

},
"onboardingEpicGamesLoginStepView.failure.invalidCode" : {

Expand All @@ -27202,6 +27208,9 @@
},
"onboardingEpicGamesLoginStepView.failure.unknownError" : {

},
"onboardingEpicGamesLoginStepView.loading" : {

},
"onboardingEpicGamesLoginStepView.title" : {

Expand Down Expand Up @@ -34474,6 +34483,75 @@
}
}
}
},
"sparkleUpdaterCheckingView.description" : {

},
"sparkleUpdaterCheckingView.title" : {

},
"sparkleUpdaterDownloadingView.bytesDownloaded" : {

},
"sparkleUpdaterDownloadingView.bytesOfBytes" : {

},
"sparkleUpdaterDownloadingView.bytesOfBytesEta" : {

},
"sparkleUpdaterDownloadingView.description" : {

},
"sparkleUpdaterDownloadingView.title" : {

},
"sparkleUpdaterExtractingView.description" : {

},
"sparkleUpdaterExtractingView.title" : {

},
"sparkleUpdaterFinishView.description" : {

},
"sparkleUpdaterFinishView.relaunchNow" : {

},
"sparkleUpdaterFinishView.title" : {

},
"sparkleUpdaterFinishView.updateOnClose" : {

},
"sparkleUpdaterInstallingView.description" : {

},
"sparkleUpdaterInstallingView.title" : {

},
"sparkleUpdaterPreviewView.description" : {

},
"sparkleUpdaterPreviewView.dismiss" : {

},
"sparkleUpdaterPreviewView.noReleaseNotes" : {

},
"sparkleUpdaterPreviewView.releaseNotes" : {

},
"sparkleUpdaterPreviewView.update" : {

},
"sparkleUpdaterSheetViewModifier.error.title" : {

},
"sparkleUpdaterSheetViewModifier.noUpdateAvailable.description" : {

},
"sparkleUpdaterSheetViewModifier.noUpdateAvailable.title" : {

},
"Stable" : {
"comment" : "Within the context of Mythic Engine",
Expand Down
2 changes: 1 addition & 1 deletion Mythic/Models/AppLoggerModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct AppLoggerModel {

#if DEBUG
private func log(_ message: String, level: LogLevel) {
if level.rawValue <= Self.logLevel.rawValue { return }
if level.rawValue < Self.logLevel.rawValue { return }
switch level {
case .debug:
print("\u{1b}[0;1;34m[🐞DEBUG \(self.category)]\u{1b}[0;34m \(message)\u{1b}[0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import Foundation

public struct AppSettingsPersistentStateModel: StorablePersistentStateModel.State {
/// Shared instance.
public static let shared: StorablePersistentStateModel.Store<Self> = .init()
@MainActor public static let shared: StorablePersistentStateModel.Store<Self> = .init()

public typealias RootType = AppSettings
public static var persistentStateStoreName: String = "AppSettings"
public static let persistentStateStoreName = "AppSettings"

public static func defaultValue() -> AppSettings {
.init()
}
Expand Down
Loading

0 comments on commit 7f9ea3d

Please sign in to comment.