From 048f0ee9e89fcc163bd6f8e4aad3a59335de74a0 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:18 -0500 Subject: [PATCH 1/6] Depended on AppRuntime's RuntimeFormatting --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index ac7bbe9..88ea614 100644 --- a/Package.swift +++ b/Package.swift @@ -167,7 +167,7 @@ let package = Package( .target(name: "CLinuxHost"), .target( name: "LinuxHostApp", - dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "CLinuxHost", runtime("CRuntime"), + dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "CLinuxHost", runtime("CRuntime"), runtime("RuntimeFormatting"), .product(name: "CacaoSDL", package: "Cacao")], swiftSettings: host ), @@ -189,7 +189,7 @@ let package = Package( // doesn't build Cacao. .target( name: "LinuxPackager", - dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", runtime("DynamicUI"), + dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", runtime("RuntimeFormatting"), runtime("DynamicUI"), .product(name: "Crypto", package: "swift-crypto")] ), .executableTarget( From 560c90538417ced7c26fa184f5f14cdf221fb317 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:18 -0500 Subject: [PATCH 2/6] Registered date and number formatting in the host --- Sources/LinuxHostApp/HostApp.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/LinuxHostApp/HostApp.swift b/Sources/LinuxHostApp/HostApp.swift index 0888cc5..dd434de 100644 --- a/Sources/LinuxHostApp/HostApp.swift +++ b/Sources/LinuxHostApp/HostApp.swift @@ -8,6 +8,7 @@ import LinuxCoreModel import LinuxGraphics import LinuxWebKit import LinuxUI +import RuntimeFormatting /// The app's `main` (`Plan.md` §4): finds the app's bundle, checks and /// prepares the app, calls `rt_main`, and runs Cacao's main loop with a @@ -26,11 +27,12 @@ import LinuxUI public enum HostApp { /// Every module this host has: the SwiftUI player (DarwinUI, on Cacao), - /// Bluetooth, GL surfaces and web pages, which the player shows, and - /// the app's files, settings and model stores. + /// Bluetooth, GL surfaces and web pages, which the player shows, the + /// app's files, settings and model stores, and AppRuntime's date and + /// number formatting over Swift Foundation. public static let modules: [any HostModule.Type] = [ DarwinUI.self, LinuxBluetooth.self, LinuxGraphics.self, LinuxWebKit.self, LinuxFiles.self, LinuxDefaults.self, - LinuxModelStore.self, + LinuxModelStore.self, HostFormattingModule.self, ] /// The window's title: the app's name. From 27704f734f8c2ffe0b3e99ea621acb9a0331759c Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:19 -0500 Subject: [PATCH 3/6] Listed formatting among the host's contracts --- Sources/LinuxPackager/Validator.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/LinuxPackager/Validator.swift b/Sources/LinuxPackager/Validator.swift index 313d471..2c7ecc3 100644 --- a/Sources/LinuxPackager/Validator.swift +++ b/Sources/LinuxPackager/Validator.swift @@ -7,16 +7,17 @@ import LinuxWebKit import LinuxHost import DynamicUI import RuntimeABI +import RuntimeFormatting /// What this host implements: the built-ins and its modules' contracts. public enum HostContracts { /// The modules `linux-app-host` registers (`HostApp.modules`): the /// player's contracts, without building the player, Bluetooth, - /// graphics, web views, files, settings and model stores. + /// graphics, web views, files, settings, model stores and formatting. nonisolated(unsafe) public static let modules: [any HostModule.Type] = [ PlayerContracts.self, LinuxBluetooth.self, LinuxGraphics.self, LinuxWebKit.self, LinuxFiles.self, LinuxDefaults.self, - LinuxModelStore.self, + LinuxModelStore.self, HostFormattingModule.self, ] public static var provided: [String: ContractDescriptor] { From c728b4cb6ef83a9b3ad8e21d7caf673251b2f999 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:19 -0500 Subject: [PATCH 4/6] Tested that an app that formats validates --- Tests/LinuxPackagerTests/PackagerTests.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/LinuxPackagerTests/PackagerTests.swift b/Tests/LinuxPackagerTests/PackagerTests.swift index 1d67bf9..96147c0 100644 --- a/Tests/LinuxPackagerTests/PackagerTests.swift +++ b/Tests/LinuxPackagerTests/PackagerTests.swift @@ -45,6 +45,17 @@ import Testing #expect(lenient.filter { $0.severity == .error }.count == 1, "the wrong kind is still an error") } + /// AppRuntime's `RuntimeFormatting`, which the host registers as it is. + @Test func formattingIsImplemented() throws { + let fixture = try Fixture(contracts: [ + ("org.pureswift.ui.Renderer", 1, "contract"), + ("org.pureswift.formatting.Locale", 1, "contract"), + ("org.pureswift.formatting.NumberFormat", 1, "contract"), + ("org.pureswift.formatting.DateFormat", 1, "contract"), + ]) + #expect(try diagnostics(fixture).isEmpty) + } + @Test func newerABIsAndBadNames() throws { let messages = try diagnostics(Fixture(identifier: "nodots", executable: "../Demo", abi: 99)).map(\.message) #expect(messages.contains { $0.contains("rt ABI 99") }) From 1fb2dae717986dad39b185a043fdd77987946ab6 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:19 -0500 Subject: [PATCH 5/6] Documented formatting over Swift Foundation --- Documentation/Plan.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/Plan.md b/Documentation/Plan.md index 8d2ae19..96ea49e 100644 --- a/Documentation/Plan.md +++ b/Documentation/Plan.md @@ -46,7 +46,7 @@ AppRuntime's contracts. | arm64 and x86_64 Linux with glibc (Debian 13, Ubuntu 24.04+) | armv7, musl | | Native slices linked into the host | wasm2c (AppRuntime's shim, as on Darwin); WasmKit for development | | Wayland and X11 through SDL3; a headless driver for tests | Multiple windows | -| `Renderer`, `BluetoothCentral` and friends, GL surfaces, web views, files, settings, the built-ins | Location (GeoClue), Device (UPower, sysfs), Networking (libcurl), Formatting (ICU), Motion (iio-sensor-proxy), NFC (neard) | +| `Renderer`, `BluetoothCentral` and friends, GL surfaces, web views, files, settings, model stores, date and number formatting, the built-ins | Location (GeoClue), Device (UPower, sysfs), Networking (libcurl), Motion (iio-sensor-proxy), NFC (neard) | ## 2. Process model @@ -100,6 +100,16 @@ The package depends on AppRuntime without its `GuestExports` trait, like DarwinAppRuntime, so the slice's `rt_dispatch` and `rt_finalize` are the only ones linked (`HostRuntime.md` §8 in DarwinAppRuntime). +Some contracts need nothing of Linux's own, and AppRuntime has them for +every host written in Swift; this host registers them as they are: + +- **Formatting** (`DynamicFormatting`): AppRuntime's `RuntimeFormatting`, + `LocaleInfo`, `NumberFormat` and `DateFormat` over Swift Foundation, + which formats with ICU, so a guest doesn't link it. Foundation on Linux + doesn't read the POSIX environment for the user's locale, so + `RuntimeFormatting` does: `LC_ALL`, else `LANG`, and `LANGUAGE` for the + preferred languages. The time zone is `TZ`, else the system's. + ## 4. Startup 1. Read the app's keys (`RTABIVersion`, `RTContracts`, `RTCapabilities`, @@ -385,8 +395,9 @@ SQLite one, CoreModel-SQLite, with SQLite compiled in, so a device needs no later Flatpak and AppImage, whose manifests carry the capabilities (`--system-talk-name=org.bluez` for `bluetooth`). 3. **More contracts**: Location (GeoClue2), Device (UPower, sysfs), - Networking (libcurl or AsyncHTTPClient), Formatting (ICU), Motion - (iio-sensor-proxy), NFC (neard). + Networking (libcurl or AsyncHTTPClient), Motion (iio-sensor-proxy), + NFC (neard). Formatting is done: AppRuntime's `RuntimeFormatting` + (§3). 4. **Player**: what DarwinUI and Cacao add: Cacao's AT-SPI bridge, input replay for end-to-end tests. From 02d59fd4f9002032fb367661326fc01d77ad46b2 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 18 Nov 2026 03:10:19 -0500 Subject: [PATCH 6/6] Said the host registers formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7920db1..4760fc9 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ added to its database between launches: | `LinuxGraphics` | `Surface`: GLES 2.0 drawn in EGL pbuffers, loaded at run time, and read back into the player's `GLSurface` view ([plan](Documentation/Plan.md) §7) | | `LinuxWebKit` | `WebContent`: WPE WebKit pages, loaded at run time, drawn into shared memory and shown by the player's `WebView` view ([plan](Documentation/Plan.md) §8) | | `LinuxCoreModel` | `LinuxModelStore`: the app's CoreModel stores in SQLite, through AppRuntime's `HostModelStore` and CoreModel-SQLite ([plan](Documentation/Plan.md) §9) | -| `LinuxHostApp`, `linux-app-host` | The app's `main`: the host, and Cacao's window and loop | +| `LinuxHostApp`, `linux-app-host` | The app's `main`: the host, and Cacao's window and loop. It also registers AppRuntime's `RuntimeFormatting`, dates and numbers over Swift Foundation ([plan](Documentation/Plan.md) §3) | | `LinuxPackager`, `linux-app` | The packager: validation, the host build, wasm2c, the install tree, PortMaster ports | ## Building