Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

Engine manifests can ship hidden. A manifest's new channel field decides who sees it: none for everyone, "beta" for installs that get beta builds, "preview" only where the previewEngines key is set (no UI: defaults write app.highball.Highball previewEngines -bool true). An unknown channel stays hidden. The app filters its known engines through this rule, and a game recipe pinned to an engine this install does not see is not offered at all, so the game page and Play stay as they were instead of asking for a Highball update no update would satisfy. Every engine players have today carries no channel, which a test checks. First use: the native arm64 engine line for Microsoft Flight Simulator 2024, which ships in preview until its beta. 524 tests pass on the M4.

Gauthier Piarrette97cdcf5abe19
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index aa52405..e059b4f 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -388,6 +388,12 @@ final class AppState {
func fixRecipe(for item: LibraryItem) -> HighballKit.Recipe? {
guard let entry = gameDB.entry(for: item),
let recipe = Self.recipe(entry.id), recipe.kind == .game else { return nil }
+ // A recipe pinned to an engine this install does not see (a line still in preview) is not
+ // offered: the game page and Play stay as they were before the recipe existed.
+ let defaults = UserDefaults.standard
+ if EngineChannels.hidesPin(recipe.engine, bundled: Self.bundledManifests,
+ beta: defaults.bool(forKey: UpdateChannels.betaDefaultsKey),
+ preview: defaults.bool(forKey: EngineChannels.previewDefaultsKey)) { return nil }
return recipe
}
@@ -2769,10 +2775,20 @@ final class AppState {
?? repoRoot?.appending(path: "spike/engine-manifest.json")
}
- /// Every engine manifest the app ships: the default one plus `engines/*.json` (previous
- /// engines kept for rollback, candidates offered in Advanced). A bottle can move to any of
+ /// Every engine manifest this install may see: the bundled ones minus those whose channel it
+ /// does not get (EngineChannels; a preview line ships hidden). A bottle can move to any of
/// them; one that is not installed downloads first.
static var knownManifests: [EngineManifest] {
+ let defaults = UserDefaults.standard
+ let beta = defaults.bool(forKey: UpdateChannels.betaDefaultsKey)
+ let preview = defaults.bool(forKey: EngineChannels.previewDefaultsKey)
+ return bundledManifests.filter { EngineChannels.visible(channel: $0.channel, beta: beta, preview: preview) }
+ }
+
+ /// Every engine manifest the app ships, visible or not: the default one plus
+ /// `engines/*.json` (previous engines kept for rollback, candidates offered in Advanced,
+ /// lines still in preview).
+ static var bundledManifests: [EngineManifest] {
var urls: [URL] = []
if let m = bundledManifest { urls.append(m) }
if let dir = Bundle.main.resourceURL?.appending(path: "engines"),
diff --git a/Sources/HighballKit/EngineChannels.swift b/Sources/HighballKit/EngineChannels.swift
new file mode 100644
index 0000000..dfef827
--- /dev/null
+++ b/Sources/HighballKit/EngineChannels.swift
@@ -0,0 +1,31 @@
+import Foundation
+
+/// Which bundled engine manifests an install may see. Manifests ship inside the app, so an engine
+/// line that is still being proven (the native arm64 line, first for Microsoft Flight Simulator 2024)
+/// ships with a `channel`: "preview" shows it only where the preview key is set, "beta" also to
+/// installs that get beta builds, and no channel shows it to everyone. Opening a line to players is
+/// then a data change. An unknown channel stays hidden, so a typo cannot hand an engine to everyone.
+public enum EngineChannels {
+ public static let preview = "preview"
+ public static let beta = "beta"
+ /// The UserDefaults key that shows preview engines. No UI on purpose:
+ /// `defaults write app.highball.Highball previewEngines -bool true`.
+ public static let previewDefaultsKey = "previewEngines"
+
+ public static func visible(channel: String?, beta: Bool, preview: Bool) -> Bool {
+ switch channel {
+ case nil: return true
+ case Self.beta?: return beta || preview
+ default: return preview
+ }
+ }
+
+ /// Whether a recipe's engine pin names a bundled engine this install may not see. Such a recipe
+ /// is not offered at all: without this, Play would find the pin missing from the visible engines
+ /// and tell the player to update Highball, though no update would show it either. A pin no
+ /// bundled manifest carries is not hidden; that case keeps its own "update Highball" answer.
+ public static func hidesPin(_ pin: String?, bundled: [EngineManifest], beta: Bool, preview: Bool) -> Bool {
+ guard let pin, let manifest = bundled.first(where: { $0.id == pin }) else { return false }
+ return !visible(channel: manifest.channel, beta: beta, preview: preview)
+ }
+}
diff --git a/Sources/HighballKit/Manifest.swift b/Sources/HighballKit/Manifest.swift
index 2ef0959..04f7ed9 100644
--- a/Sources/HighballKit/Manifest.swift
+++ b/Sources/HighballKit/Manifest.swift
@@ -63,6 +63,10 @@ public struct EngineManifest: Codable, Sendable, Identifiable {
}
public var requires: [String]?
public var notes: [String]?
+ /// Who may see this engine (EngineChannels): nil for everyone, "beta" for installs that get
+ /// beta builds, "preview" only where the preview key is set. An engine line still being proven
+ /// ships in the app this way, and opening it to players is a change to this field.
+ public var channel: String?
// MARK: Architecture
diff --git a/Tests/HighballKitTests/EngineChannelsTests.swift b/Tests/HighballKitTests/EngineChannelsTests.swift
new file mode 100644
index 0000000..1dc1cf4
--- /dev/null
+++ b/Tests/HighballKitTests/EngineChannelsTests.swift
@@ -0,0 +1,57 @@
+import XCTest
+@testable import HighballKit
+
+/// The gate in front of engine lines that ship hidden. A wrong answer here would either hand a
+/// preview engine to every player or hide it from the people testing it.
+final class EngineChannelsTests: XCTestCase {
+ private var repo: URL {
+ URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ }
+
+ private func manifest(id: String, channel: String?) throws -> EngineManifest {
+ var json: [String: Any] = ["id": id, "displayName": id, "arch": "arm64", "minMacOS": "26.5", "components": [String: Any]()]
+ if let channel { json["channel"] = channel }
+ return try JSONDecoder().decode(EngineManifest.self, from: JSONSerialization.data(withJSONObject: json))
+ }
+
+ func testNoChannelIsForEveryone() {
+ XCTAssertTrue(EngineChannels.visible(channel: nil, beta: false, preview: false))
+ }
+
+ func testBetaNeedsBetaBuildsOrThePreviewKey() {
+ XCTAssertFalse(EngineChannels.visible(channel: "beta", beta: false, preview: false))
+ XCTAssertTrue(EngineChannels.visible(channel: "beta", beta: true, preview: false))
+ XCTAssertTrue(EngineChannels.visible(channel: "beta", beta: false, preview: true))
+ }
+
+ func testPreviewNeedsThePreviewKeyEvenWithBetaBuilds() {
+ XCTAssertFalse(EngineChannels.visible(channel: "preview", beta: true, preview: false))
+ XCTAssertTrue(EngineChannels.visible(channel: "preview", beta: false, preview: true))
+ }
+
+ func testAnUnknownChannelStaysHidden() {
+ XCTAssertFalse(EngineChannels.visible(channel: "previw", beta: true, preview: false))
+ XCTAssertTrue(EngineChannels.visible(channel: "previw", beta: false, preview: true))
+ }
+
+ func testARecipePinnedToAHiddenEngineIsHiddenAndOthersAreNot() throws {
+ let bundled = [try manifest(id: "arm64-line-r1", channel: "preview"), try manifest(id: "x64-line-r9", channel: nil)]
+ XCTAssertTrue(EngineChannels.hidesPin("arm64-line-r1", bundled: bundled, beta: true, preview: false))
+ XCTAssertFalse(EngineChannels.hidesPin("arm64-line-r1", bundled: bundled, beta: false, preview: true))
+ XCTAssertFalse(EngineChannels.hidesPin("x64-line-r9", bundled: bundled, beta: false, preview: false))
+ XCTAssertFalse(EngineChannels.hidesPin(nil, bundled: bundled, beta: false, preview: false))
+ // A pin no bundled manifest carries keeps its own answer (Play asks for a Highball update).
+ XCTAssertFalse(EngineChannels.hidesPin("x64-line-r10", bundled: bundled, beta: false, preview: false))
+ }
+
+ func testEveryEngineThePlayersHaveTodayHasNoChannel() throws {
+ let dir = repo.appending(path: "spike/engines")
+ let files = try FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil)
+ .filter { $0.pathExtension == "json" } + [repo.appending(path: "spike/engine-manifest.json")]
+ for file in files {
+ let m = try EngineManifest.load(from: file)
+ if m.isNativeARM64 { continue }
+ XCTAssertNil(m.channel, "\(m.id) is an Intel engine players already have; a channel would hide it from them")
+ }
+ }
+}