feat(native): also emit canonical Swift colour tokens #64

Merged
peterswimm merged 1 commit from feat/native-swift-emit into main 2026-07-25 18:21:29 +00:00
Owner

What

Completes the Swift side of the native token emitter (recommendation #1). native.py now also emits dist/rituals/udg_tokens.swift — the same canonical colour maps as udg_tokens.dart, as Swift [String: UInt32] literals:

public let udgColorLightHex: [String: UInt32] = [
    "brandPrimary": 0xFFC05734,
    "accentWarning": 0xFFEE0000,
    ...
]
public let udgColorDarkHex: [String: UInt32] = [ ... ]

No separate udg.swift-key needed — Swift keys are camelCase, identical to udg.dart-key. swiftc -parse confirms valid Swift.

Generated + gated

  • Wired into the existing native.py build/check (byte-drift gate), same as the Dart output.
  • The sync-manifest declares a swift-colors source-inject consumer (apps/rituals-macos/Design/UDGColors.swift) — an optional compile-time alternative to the macOS runtime JSON manifest.

Why no sibling change is required

The macOS app's Swift colours already track canonical at runtime — it reads a JSON manifest that the Flutter export.dart builds from the (now-canonical, post-#189) Dart maps. And its few hardcoded Color(argbHex:) constants don't drift (align-check reports them clean). So this PR gives Swift a first-class generated canonical source + gate, without forcing a runtime→compile-time refactor on the app.

Testing

swiftc -parse valid · just check green (native check covers the Swift file) · pytest 132 passed · yamllint clean.

Remaining (documented, not built)

The full multi-tier udg_tokens.json manifest (borders/spaces/types/breakpoints/…) — colour is done for both Dart and Swift; the non-colour tiers are the last native follow-up.

## What Completes the **Swift** side of the native token emitter (recommendation #1). `native.py` now also emits **`dist/rituals/udg_tokens.swift`** — the same canonical colour maps as `udg_tokens.dart`, as Swift `[String: UInt32]` literals: ```swift public let udgColorLightHex: [String: UInt32] = [ "brandPrimary": 0xFFC05734, "accentWarning": 0xFFEE0000, ... ] public let udgColorDarkHex: [String: UInt32] = [ ... ] ``` **No separate `udg.swift-key` needed** — Swift keys are camelCase, identical to `udg.dart-key`. `swiftc -parse` confirms valid Swift. ## Generated + gated - Wired into the existing `native.py` build/check (byte-drift gate), same as the Dart output. - The sync-manifest declares a `swift-colors` source-inject consumer (`apps/rituals-macos/Design/UDGColors.swift`) — an **optional compile-time alternative** to the macOS runtime JSON manifest. ## Why no sibling change is required The macOS app's Swift colours already track canonical **at runtime** — it reads a JSON manifest that the Flutter `export.dart` builds from the (now-canonical, post-#189) Dart maps. And its few hardcoded `Color(argbHex:)` constants don't drift (`align-check` reports them clean). So this PR gives Swift a **first-class generated canonical source + gate**, without forcing a runtime→compile-time refactor on the app. ## Testing `swiftc -parse` valid · `just check` green (native check covers the Swift file) · `pytest` 132 passed · `yamllint` clean. ## Remaining (documented, not built) The full multi-tier `udg_tokens.json` manifest (borders/spaces/types/breakpoints/…) — colour is done for both Dart and Swift; the non-colour tiers are the last native follow-up.
feat(native): also emit canonical Swift colour tokens
All checks were successful
UDG dist drift gate / dist/ matches dtcg + udg sources (pull_request) Successful in 20s
Test Generator / lint-workflows (pull_request) Successful in 24s
Security Scans / Gitleaks secret scan (pull_request) Successful in 24s
Test Generator / lint-prose (pull_request) Successful in 25s
Security Scans / Trivy filesystem scan (pull_request) Successful in 29s
Test Generator / test (pull_request) Successful in 3m14s
e1451f47a0
Extend native.py to emit dist/rituals/udg_tokens.swift — the same canonical colour
maps as udg_tokens.dart, as Swift `[String: UInt32]` literals. Swift keys are
camelCase, identical to udg.dart-key, so Swift needs no separate `udg.swift-key`.
`swiftc -parse` confirms valid Swift.

Wired into the existing native build/check gate (byte-drift, like the Dart output);
the sync-manifest declares a `swift-colors` source-inject consumer
(apps/rituals-macos/Design/UDGColors.swift) — an optional compile-time alternative
to the macOS runtime JSON manifest.

Completes the Swift side of the native emitter (recommendation #1). Note: the app's
Swift colours already track canonical at runtime via the Dart export → JSON, and
its hardcoded Color(argbHex:) constants don't drift (align-check clean), so no
sibling change is required — this gives Swift a first-class generated canonical
source and gate. just check green · pytest 132/132 · yamllint clean.
peterswimm deleted branch feat/native-swift-emit 2026-07-25 18:21:29 +00:00
Sign in to join this conversation.
No description provided.