SlotView is the structural equivalent of a Surface: a pure Foldkit view
that publishes typed Slots and lets Mixins attach without forking it. It
owns no state and runs no Effects. Attached Mixins are resolved into
ordinary Foldkit attributes per slot, using the view's own h so Message
capability masking is preserved.
Slots, an input and a Message universe named once. Its define, behavior
and parts are SlotView.define, Behavior.forSlots and SlotView.parts
with all three fixed, so nothing passed to them needs an annotation. A
Behavior factory takes one where it takes the slots.
Message has no anchor but the render callback's builder, so it is inferred
from an explicit h: HtmlBuilder<Message> annotation on that parameter.
Without one it resolves to unknown, and the first error appears later and
elsewhere — an invariance mismatch at Style.attach/Behavior.attach that
does not name the missing annotation. forMessages<Message>() fixes the
Message universe up front instead, and leaves h contextually typed.
The view as a serializable value: its slots, and each attachment in order
with, per slot, what it requires, what it supplies and the classes and
Mounts it contributes. A contribution that is a function of the input reads
'unknown': it is not called. A description is a function of one view value;
attaching or detaching returns another view and leaves this one's alone.
The view without the attachment named name. Returns a new view; the
original is unchanged. Refused (mixins:unknown-attachment,
mixins:ambiguous-attachment) unless the view holds exactly one by that
name, and by A11y.conform's check when the view was conformed to a
pattern the attachment helped meet.
Binds the view constructors to one Message universe, so the render callback
no longer has to annotate h to pin it. Input is still inferred from the
callback's own input annotation.
Example
ts
const Field = SlotView.forMessages<Message>().define( FieldSlots,(input:FieldInput, slots, h)=> h.input(slots.input.attrs([h.OnInput(value => Message.ChangedValue({ value }))])),)
Foldkit's inertHtml typed for a Message universe, for rendering a view
outside a runtime (tests, demos, static description). inertHtml is
HtmlBuilder<never>, and the builder is invariant in Message, so this is
the one cast: sound outside a runtime render, where no handler is ever
dispatched. Inside one it is the same builder every view is given, so its
handlers would reach the frame's update: use the view's own h there.
functionisBound<Slots,Input,Message>( value:Slots|Bound<Slots,Input,Message>,): value isBound<Slots,Input,Message>functionisBound(value:unknown): value isBound<unknown,unknown,unknown>
Whether a factory was handed a Bound rather than bare slots. Asked of
Slots | Bound<Slots, Input, Message>, each branch keeps its own type.
One piece of an assembled view, drawn from its own selection of the view's
input: the keys it names in reads, and nothing else. It is drawn again
only when one of those values changed, by identity.
What a region reads: the Model paths it depends on and how its value is
read from the root. A foldkit-surfaceProjection is one, as built from
the application's field references (Projection.struct({ cart:
App.model.cart })), so the paths are the ones the references declare.
A region: part of a SlotView's drawing that is given only what reads
reads, and drawn again only when that changed. While every path reads
depends on holds the value it held, the region does not read at all and
Foldkit reuses its last drawing without diffing it; when one changed and
the read gives the same fields as before, it is reused too. What reads no
path of its own (a Remote read, alone or in a Projection.struct) is read
on every render, and the region drawn again when that gives other fields.
Like a Slot's lazy item, it is drawn again when a Mixin gives the Slots
it used something different, and drawn afresh where there is no runtime
frame.
draw reads only its value, so the region cannot read what it is not
drawn again for. A region drawn inside another region or item is drawn in
place, and the outer one every time.
Example
ts
const Header = SlotView.region( Projection.struct({cart: App.model.cart }),({ cart }, slots:SlotView.SlotBuilders<typeof Page.slots,Message>, h:HtmlBuilder<Message>)=> h.header(slots.header.attrs(), [`${cart.length} in the cart`]),)// In the page's render: Header(model, slots, h)
What input makes each slot hold: class tokens, style property names,
attribute names, event names and Mount names, each with the attachment that
gave it. It reports no attribute value, style value or Mount args (a password
in Value is the input's, and an attribute carries it), but class tokens are
reported as given, so a class built from input text surfaces it. It runs no
Mount: a handler is built
with the inert builder and never called, and a contribution is called with
input, as a render would. Where resolve would throw, the conflict is a
finding. The view's own base attributes are not drawn, so a clash with one
is not reported here.
A view over published Slots. Provides is what its attachments supply, as
`${slot}/${obligation}` names, which A11y.conform checks; a view
defined bare supplies nothing.
A transform that takes an attachment away or puts another in its place. The
view it makes supplies nothing at the type level, a Style taken or not: the
type holds no attachment's name, and what one took may still be supplied by
another, so subtracting it would refuse what is met. A11y.conform's
run-time check is made again instead.