Surface / foldkit-surface
Applications
Surface.application({ Model, Message }) creates an Application holding App.Model, App.Message, App.model (App.fields is a deprecated alias), App.owner, and App.surface. Passing initial and update as well creates a RunnableApplication for replicators, threading Command resource requirements into the type.
When update depends on values built from App.model (such as a Remote domain or placed Bundle), call App.runnable({ initial, update }) afterward rather than calling Surface.application a second time, keeping the same owner token across all references:
const Made = Surface.application({ Model, Message })
// …what the update needs, built over Made.model…
const App = Made.runnable({ initial, update })
// App.model is Made.model: one application.Message subsets
A subset selects typed variants of one application's Message union by constructor reference:
import { MessageSet } from 'foldkit-surface'
const TodoChanges = MessageSet.make(App, [Message.CreatedTodo, Message.ToggledTodo])
const SelectionChanges = MessageSet.make(App, [Message.SelectedTodo])
const AllChanges = MessageSet.union(TodoChanges, SelectionChanges)A subset carries its constructors, a pure codec for those variants, a tags set, and an includes guard. Passing constructors from another application or duplicate tags throws. foldkit-sync and foldkit-agent attach durability or agent-visibility policies onto these subsets.