luminate/Sources/Luminate/Luminate.swift

70 lines
2.2 KiB
Swift

//
// Luminate.swift
//
// Copyright 2026 Brendan Szymanski <hello@bscubed.dev>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
import Foundation
import LuminateCore
import LuminateServices
import LuminateStore
import LuminateUI
import Portico
/// The Luminate application entry point.
///
/// Owns the process-wide Jellyfin client and publishes it to the whole view tree; preferences
/// install themselves through `Preferences.bootstrap(_:)`.
@main
struct Luminate: App {
var applicationId: String? { AppInfo.identifier }
private let jellyfin: JellyfinClient
private let sessionBinder: ClientSessionBinder
init() {
LogBootstrap.bootstrap()
Preferences.bootstrap(PreferenceBackend.open())
jellyfin = JellyfinClient(
configuration: JellyfinClientConfiguration(
serverURL: Preferences.shared[.serverURL],
accessToken: Preferences.shared[.accessToken]
)
)
sessionBinder = ClientSessionBinder(client: jellyfin)
}
var body: some Scene {
ApplicationWindow { _ in
RootView()
.environment(\.client, jellyfin)
}
}
}
/// The root of the window's view tree.
///
/// Reads the injected client and a preference so a launch proves both resolve end to end.
private struct RootView: View {
@Environment(\.client) private var jellyfinClient
@Preference(.serverURL) private var serverURL: URL?
var body: some View {
Label { serverURL?.absoluteString ?? "No server configured" }
}
}