38 lines
1.3 KiB
Swift
38 lines
1.3 KiB
Swift
/// The top-level entry point for a Portico application.
|
|
///
|
|
/// Conforming types declare a ``Scene`` body and an optional application
|
|
/// ID. The `@main` attribute on the concrete type triggers `static func main()`,
|
|
/// which delegates to ``PorticoRuntime/run(_:)``.
|
|
@MainActor public protocol App {
|
|
/// The type of scene representing the body of this app.
|
|
associatedtype Body: Scene
|
|
|
|
/// The top-level scene of the application, composed using ``SceneBuilder``.
|
|
@SceneBuilder var body: Body { get }
|
|
|
|
/// A reverse-DNS application identifier for GTK uniqueness.
|
|
///
|
|
/// Returns `nil` by default; override to enable single-instance behavior.
|
|
var applicationId: String? { get }
|
|
|
|
/// Initializes the application - required by the `App` protocol.
|
|
init()
|
|
|
|
/// Asynchronous teardown performed after the last window requests close and before exit.
|
|
///
|
|
/// Runs after every handler registered with ``ApplicationLifecycle/onShutdown(_:)``.
|
|
/// The default implementation does nothing.
|
|
func shutdown() async
|
|
|
|
}
|
|
|
|
public extension App {
|
|
/// Default - no application ID, no single-instance enforcement.
|
|
var applicationId: String? { nil }
|
|
|
|
/// Default - no teardown.
|
|
func shutdown() async {}
|
|
|
|
/// Boots the application via ``PorticoRuntime/run(_:)``.
|
|
static func main() { PorticoRuntime.run(Self()) }
|
|
}
|