Skip to content

feat(ViewDocument): render validated read-only SwiftUI documents - #460

Open
kyleve wants to merge 5 commits into
mainfrom
feat/view-document
Open

kyleve wants to merge 5 commits into
mainfrom
feat/view-document

Conversation

@kyleve

@kyleve kyleve commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Posted by an AI agent on Kyle's behalf.

Summary

Add independent ViewDocument libraries for versioned, finite, read-only presentation: JSON in, SwiftUI out. They have no Broadway or Where dependency.

ViewDocumentCore owns Codable values, resource requirements, placement geometry, and validation. ViewDocumentUI prepares approved assets and renders text, shapes, images, finite groups, ordered modifiers, and transform animations.

Primary API

// The host supplies data, approved assets, resolved appearance, and activity/capture policy.
let validated = try ValidatedViewDocument.decode(data, resources: assets.resources, limits: .standard)
let prepared = try PreparedViewDocument(document: validated, assets: assets)
ViewDocumentView(
    prepared: prepared,
    appearance: appearance,
    policy: .init(purpose: .content, isActive: isVisible, motionIsStatic: capturesStaticMotion)
)

Pass the prepared value, host-resolved appearance, and explicit rendering policy to ViewDocumentView. Generic content preserves native text accessibility; decoration policy hides the complete tree from accessibility. Every document is noninteractive.

  • Portable paint supports RGBA, native semantic colors, gradients, bounded opacity, and bounded color mixing. Native palette references preserve appearance and contrast adaptation; hosts supply background levels and dimension scales.
  • Images support fit, clipped fill, and bounded tiling through a typed, prepared resource registry. Documents cannot load paths or URLs.
  • Host-relative placement separates artwork frames from finite per-edge paint bounds. Geometry respects RTL and reduces artwork/offsets together when a host reserves smaller gutters.
  • Motion supports finite or repeating transforms with an explicit static pose. Inactive content stops requesting animation and returns to that pose. SnapshotKit remains test-only; production rendering receives policy by injection.
  • Validation rejects unsupported operations, missing resources, duplicate IDs, nonfinite values, excessive bytes/nodes/depth/modifiers/animations, and cumulative transform amplification. Portable color expressions are bounded to eight levels.

There are no expressions, data iteration, action dispatch, bindings, or networking. Tiling repeats image pixels, not document nodes. Surface composition and reserved layout space belong to consumers.

Compatibility

ViewDocument's wire schema remains version 1. The new image, placement, and paint vocabulary is additive; unknown enum operations fail decoding. Where's separate theme schema is versioned by its consumer.

Review focus

Schema → Placement validation → Renderer → Paint regressions.

Independent reviews covered finite placement, RTL geometry, resource contracts, and paint recursion. Validation bounds nested modifiers, cumulative transform amplification, and color depth before rendering.

Follow decoding through validation and preparation into rendering. Check complexity budgets across nested modifiers and transforms, asset identity, image sizing, host-relative placement, accessibility, and animation endpoints.

Testing

  • ./test --all --review --no-generate: ViewDocumentCore’s 31 tests and ViewDocumentUI’s 9 tests passed in the full multi-bundle run.
  • ./test --skip-host-tests --no-generate --only WhereUISnapshotTests --only ViewDocumentUISnapshotTests --record never --review: both independent ViewDocument image entry points passed (light/dark and accessibility captures). Consumer failures and their focused corrections are documented in feat(WhereUI): unify JSON themes and add illustrated Halloween #462.
  • ./swiftformat --lint, architecture configuration/rule tests (29), and architecture lint passed.

The foundation has independent tests; it does not rely on Where to validate documents or resolve assets.

Stack

1/3. Broadway #461 adapts traits and composes surfaces; Where #462 supplies theme catalogs, native component roles, and illustrated Halloween content. This foundation alone does not change Where's selected theme.

@kyleve
kyleve added this pull request to stack #463 October 30, 2026 00:10
@kyleve kyleve changed the title feat(ViewDocument): render validated portable read-only view documents feat(ViewDocument): render validated read-only SwiftUI documents Oct 30, 2026
@kyleve
kyleve force-pushed the feat/view-document branch from 3c48b5e to 1eb7433 Compare October 30, 2026 00:25

@kyleve kyleve Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by an AI agent on Kyle's behalf.

Standalone ViewDocument content

Read-only text, shapes, and finite layout render without Broadway or Where. The iPhone 17 light fixture was revalidated at 59dc0d2dd94f; light/dark and accessibility captures passed. Static captures establish rendering, not live motion or spoken VoiceOver behavior.

Standalone ViewDocument content

Reject cumulative scale and authored lengths that can produce blank native
rendering even when each modifier is valid. Include ancestor transforms,
animation poses, padding, frames, group spacing, and effect extents.

Strengthen the dependency mutation tests with exact diagnostics and valid
neighboring imports. Document the conservative input-budget contract.

Validation: full ./test --all --review passed, including 21 Core tests,
four renderer tests, and all 29 architecture tests plus lint.
Keep artwork paint geometry separate from host layout. Add fit, clipped fill, and native tiling with resource and density validation. Split the existing image gate into light/dark and extended entry points without changing reference identities.
Keep portable colors symbolic, including opacity and native palette roles.
Supply background elevation through the host appearance contract and bound
host-relative artwork geometry before rendering.

Validation: ViewDocumentCore 31 tests and ViewDocumentUI 9 tests passed in
the full integration run. Standalone light/dark and accessibility captures,
formatting, and architecture checks passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant