Skip to main content
On this pageFunctions

Html

Functions

childAttributes

functionsource
/**
 * Captures the current boundary's dispatcher and wraps each attribute
 *  so handlers inside it route through that boundary's wrapping chain at
 *  event-fire time, even when the attribute is later spread into a
 *  parent's element in a different boundary.
 * 
 *  Blocks call this when publishing attribute groups to a consumer's
 *  `toView` slot callback:
 * 
 *  ```ts
 *  // Inside a BlockView running in the child's boundary:
 *  return viewInputs.toView({
 *    checkbox: childAttributes([
 *      h.OnClick(Toggled()),
 *      h.Role('checkbox'),
 *    ]),
 *    ...
 *  })
 *  ```
 * 
 *  Without this binding step the consumer's element constructor would
 *  process `h.OnClick(Toggled())` using the parent's dispatcher (because
 *  the consumer's `toView` runs in the parent's boundary), bypassing the
 *  Block's `toParentMessage`.
 */
<Attributes extends readonly Array<Attribute<unknown, unknown>>>(attributes: Attributes): readonly Array<Readonly<{
  __childAttribute: true
  attribute: ChildAttributeValue<AttributeRequirements<Attributes[number]>>
  boundaryMappers: readonly Array<(message: unknown) => unknown>
  dispatch: DispatchSync
  resolveMountDispatch: Readonly<{
    owner: MountRenderOwner
    resolve: () => DispatchSync
  }>
  resolveUnmount: (message: unknown) => () => void
}>>

createKeyedLazy

functionsource
/**
 * Creates a keyed memoization map for one view function rendered under many
 *  keys. Each key gets its own independent cache slot, compared exactly the way
 *  `createLazy` compares its single slot: on each render, only the keys whose
 *  function reference, dispatch, or arguments changed by reference are
 *  recomputed. For example: a list rendering one row view per item, a detail
 *  view rendering one entity per route, or one view function rendered at two
 *  call sites.
 * 
 *  Key by the identifier that already gives the rendered thing its DOM
 *  identity. A row keyed `todo.id` through `h.keyed` memoizes under `todo.id`;
 *  a detail page keyed `post.slug` memoizes under `post.slug`. Reusing that one
 *  identifier keeps the memo and the DOM invalidating together.
 * 
 *  Entries are never evicted, so keys are expected to be bounded, such as an
 *  entity registry, a route table, or a fixed set of call sites. A key drawn
 *  from something unbounded, such as a search query or a paged cursor, grows
 *  the map for the lifetime of the page. If that becomes the shape an app
 *  needs, the upgrade path is a variant that drops keys absent from the latest
 *  render pass, not a cap on this one.
 * 
 *  Like `createLazy`, each key's cached VNode must be rendered at a single
 *  position in the tree. If the same content needs to appear in multiple
 *  positions, give each position its own key.
 */
(): (key: PropertyKey, fn: (args: Args) => VNode | null, args: Args) => VNode | null

createLazy

functionsource
/**
 * Creates a memoization slot for a view function. On each render, if the
 *  function reference, dispatchers, Mount render owner, and all arguments are
 *  equal to the previous call and any tracked Block occurrences remain
 *  active, the cached VNode is returned without
 *  re-running the view function. Snabbdom's `patchVnode` short-circuits when
 *  it sees the same VNode reference, so both VNode construction and subtree
 *  diffing are skipped.
 * 
 *  Dispatchers and Mount render ownership are part of the cache key because
 *  event handlers and Mounts in the cached VNode close over the frame active
 *  when the VNode was built. Returning a VNode built under a different frame
 *  would silently misroute events or retain the wrong Mount lifecycle owner.
 * 
 *  The cached VNode must be rendered at a single position in the tree.
 *  Snabbdom tracks the real DOM through each VNode's mutable `.elm` field
 *  and assumes one VNode per position. Rendering the same cached VNode at
 *  two positions causes patches to collide and can duplicate or misplace
 *  DOM nodes. If the same content needs to appear in multiple positions,
 *  create one slot per position.
 */
(): (fn: (args: Args) => VNode | null, args: Args) => VNode | null

Types

Attribute

typesource
/**
 * Union of all HTML, SVG, and MathML attributes a virtual DOM element can carry.
 * 
 *  When a Block publishes attribute groups to a consumer's `toView`
 *  slot, those attributes are wrapped via childAttributes into
 *  ChildAttribute, a distinct type that carries the Block's
 *  own dispatcher. Element constructors accept the union
 *  `ReadonlyArray<Attribute<Message> | ChildAttribute>`, so consumers
 *  can spread published bundles directly into their own attribute
 *  arrays.
 */
type Attribute = {
  _tag: "Key"
  value: string
} | {
  _tag: "Class"
  value: string
} | {
  _tag: "Id"
  value: string
} | {
  _tag: "Title"
  value: string
} | {
  _tag: "Lang"
  value: string
} | {
  _tag: "Dir"
  value: string
} | {
  _tag: "Tabindex"
  value: number
} | {
  _tag: "Hidden"
  value: boolean
} | {
  _tag: "Contenteditable"
  value: string
} | {
  _tag: "Draggable"
  value: boolean
} | {
  _tag: "Accesskey"
  value: string
} | {
  _tag: "Translate"
  value: string
} | {
  _tag: "Inert"
  value: boolean
} | {
  _tag: "Popover"
  value: string
} | {
  _tag: "Popovertarget"
  value: string
} | {
  _tag: "Popovertargetaction"
  value: string
} | {
  _tag: "OnClick"
  message: Message
  options: ClickOptions
} | {
  _tag: "OnDoubleClick"
  message: Message
} | {
  _tag: "OnMouseDown"
  message: Message
} | {
  _tag: "OnMouseUp"
  message: Message
} | {
  _tag: "OnMouseEnter"
  message: Message
} | {
  _tag: "OnMouseLeave"
  message: Message
} | {
  _tag: "OnMouseOver"
  message: Message
} | {
  _tag: "OnMouseOut"
  message: Message
} | {
  _tag: "OnMouseMove"
  message: Message
} | {
  _tag: "OnPointerMove"
  f: (screenX: number, screenY: number, pointerType: string) => Option.Option<Message>
} | {
  _tag: "OnPointerLeave"
  f: (pointerType: string) => Option.Option<Message>
} | {
  _tag: "OnPointerDown"
  f: (pointerType: string, button: number, screenX: number, screenY: number, timeStamp: number, clientX: number, clientY: number, pointerId: number, target: EventTarget | null) => Option.Option<Message>
} | {
  _tag: "OnPointerUp"
  f: (screenX: number, screenY: number, pointerType: string, timeStamp: number) => Option.Option<Message>
} | {
  _tag: "OnKeyDown"
  f: (key: string, modifiers: KeyboardModifiers) => Message
} | {
  _tag: "OnKeyDownPreventDefault"
  f: (key: string, modifiers: KeyboardModifiers) => Option.Option<Message>
} | {
  _tag: "OnKeyDownSelf"
  f: (key: string, modifiers: KeyboardModifiers) => Message
} | {
  _tag: "OnKeyDownSelfPreventDefault"
  f: (key: string, modifiers: KeyboardModifiers) => Option.Option<Message>
} | {
  _tag: "OnKeyDownFocus"
  f: (key: string, modifiers: KeyboardModifiers) => Option.Option<Readonly<{
    focusSelector: string
    message: Message
  }>>
} | {
  _tag: "OnKeyUp"
  f: (key: string, modifiers: KeyboardModifiers) => Message
} | {
  _tag: "OnKeyUpPreventDefault"
  f: (key: string, modifiers: KeyboardModifiers) => Option.Option<Message>
} | {
  _tag: "OnKeyPress"
  f: (key: string, modifiers: KeyboardModifiers) => Message
} | {
  _tag: "OnFocus"
  message: Message
} | {
  _tag: "OnBlur"
  message: Message
} | {
  _tag: "OnFocusEnter"
  message: Message
} | {
  _tag: "OnFocusLeave"
  message: Message
} | {
  _tag: "OnInput"
  f: (value: string) => Message
} | {
  _tag: "OnChange"
  f: (value: string) => Message
} | {
  _tag: "OnBeforeInput"
  f: (inputType: string, data: Option.Option<string>) => Message
} | {
  _tag: "OnBeforeInputPreventDefault"
  f: (inputType: string, data: Option.Option<string>) => Option.Option<Message>
} | {
  _tag: "OnFileChange"
  f: (files: ReadonlyArray<File>) => Message
} | {
  _tag: "OnSubmit"
  message: Message
} | {
  _tag: "OnReset"
  message: Message
} | {
  _tag: "OnScroll"
  f: (scrollTop: number) => Message
} | {
  _tag: "OnWheel"
  message: Message
} | {
  _tag: "OnCopy"
  message: Message
} | {
  _tag: "OnCut"
  message: Message
} | {
  _tag: "OnPaste"
  message: Message
} | {
  _tag: "OnPastePreventDefault"
  f: (text: string) => Option.Option<Message>
} | {
  _tag: "OnCopyText"
  text: string
} | {
  _tag: "OnCutText"
  message: Message
  text: string
} | {
  _tag: "OnCancel"
  message: Message
} | {
  _tag: "OnCancelPreventDefault"
  maybeCustomEventMessage: Option.Option<Message>
} | {
  _tag: "OnToggle"
  f: (isOpen: boolean) => Message
} | {
  _tag: "OnContextMenu"
  message: Message
} | {
  _tag: "OnDragStart"
  message: Message
} | {
  _tag: "OnDrag"
  message: Message
} | {
  _tag: "OnDragEnd"
  message: Message
} | {
  _tag: "OnDragEnter"
  message: Message
} | {
  _tag: "OnDragLeave"
  message: Message
} | {
  _tag: "OnDragOver"
  message: Message
} | {
  _tag: "AllowDrop"
} | {
  _tag: "OnDrop"
  message: Message
} | {
  _tag: "OnDropFiles"
  f: (files: ReadonlyArray<File>) => Message
} | {
  _tag: "OnTouchStart"
  message: Message
} | {
  _tag: "OnTouchEnd"
  message: Message
} | {
  _tag: "OnTouchMove"
  message: Message
} | {
  _tag: "OnTouchCancel"
  message: Message
} | {
  _tag: "OnAnimationStart"
  message: Message
} | {
  _tag: "OnAnimationEnd"
  message: Message
} | {
  _tag: "OnAnimationIteration"
  message: Message
} | {
  _tag: "OnTransitionEnd"
  message: Message
} | {
  _tag: "OnLoad"
  message: Message
} | {
  _tag: "OnError"
  message: Message
} | {
  _tag: "OnPlay"
  message: Message
} | {
  _tag: "OnPause"
  message: Message
} | {
  _tag: "OnEnded"
  message: Message
} | {
  _tag: "OnTimeUpdate"
  message: Message
} | {
  _tag: "OnVolumeChange"
  message: Message
} | {
  _tag: "OnSelect"
  message: Message
} | {
  _tag: "Value"
  value: string
} | {
  _tag: "Checked"
  value: boolean
} | {
  _tag: "Selected"
  value: boolean
} | {
  _tag: "Open"
  value: boolean
} | {
  _tag: "Placeholder"
  value: string
} | {
  _tag: "Name"
  value: string
} | {
  _tag: "Disabled"
  value: boolean
} | {
  _tag: "Readonly"
  value: boolean
} | {
  _tag: "Required"
  value: boolean
} | {
  _tag: "Autofocus"
  value: boolean
} | {
  _tag: "Spellcheck"
  value: boolean
} | {
  _tag: "Autocorrect"
  value: string
} | {
  _tag: "Autocapitalize"
  value: string
} | {
  _tag: "InputMode"
  value: string
} | {
  _tag: "EnterKeyHint"
  value: string
} | {
  _tag: "Multiple"
  value: boolean
} | {
  _tag: "Type"
  value: string
} | {
  _tag: "Accept"
  value: string
} | {
  _tag: "Autocomplete"
  value: string
} | {
  _tag: "Pattern"
  value: string
} | {
  _tag: "Maxlength"
  value: number
} | {
  _tag: "Minlength"
  value: number
} | {
  _tag: "Size"
  value: number
} | {
  _tag: "Cols"
  value: number
} | {
  _tag: "Rows"
  value: number
} | {
  _tag: "Max"
  value: string
} | {
  _tag: "Min"
  value: string
} | {
  _tag: "Step"
  value: string
} | {
  _tag: "For"
  value: string
} | {
  _tag: "Href"
  value: string
} | {
  _tag: "Src"
  value: string
} | {
  _tag: "Alt"
  value: string
} | {
  _tag: "Target"
  value: string
} | {
  _tag: "Rel"
  value: string
} | {
  _tag: "Download"
  value: string
} | {
  _tag: "Action"
  value: string
} | {
  _tag: "Method"
  value: string
} | {
  _tag: "Enctype"
  value: string
} | {
  _tag: "Novalidate"
  value: boolean
} | {
  _tag: "Formaction"
  value: string
} | {
  _tag: "Formmethod"
  value: string
} | {
  _tag: "Formnovalidate"
  value: boolean
} | {
  _tag: "Formtarget"
  value: string
} | {
  _tag: "Formenctype"
  value: string
} | {
  _tag: "Colspan"
  value: number
} | {
  _tag: "Rowspan"
  value: number
} | {
  _tag: "Scope"
  value: string
} | {
  _tag: "Headers"
  value: string
} | {
  _tag: "Span"
  value: number
} | {
  _tag: "Start"
  value: number
} | {
  _tag: "Reversed"
  value: boolean
} | {
  _tag: "CiteAttr"
  value: string
} | {
  _tag: "Datetime"
  value: string
} | {
  _tag: "Wrap"
  value: string
} | {
  _tag: "List"
  value: string
} | {
  _tag: "FormAttr"
  value: string
} | {
  _tag: "LabelAttr"
  value: string
} | {
  _tag: "ContentAttr"
  value: string
} | {
  _tag: "Charset"
  value: string
} | {
  _tag: "HttpEquiv"
  value: string
} | {
  _tag: "Srcset"
  value: string
} | {
  _tag: "Sizes"
  value: string
} | {
  _tag: "Loading"
  value: string
} | {
  _tag: "Decoding"
  value: string
} | {
  _tag: "Fetchpriority"
  value: string
} | {
  _tag: "Crossorigin"
  value: string
} | {
  _tag: "Referrerpolicy"
  value: string
} | {
  _tag: "Integrity"
  value: string
} | {
  _tag: "Hreflang"
  value: string
} | {
  _tag: "Ping"
  value: string
} | {
  _tag: "Sandbox"
  value: string
} | {
  _tag: "Allow"
  value: string
} | {
  _tag: "Srcdoc"
  value: string
} | {
  _tag: "Autoplay"
  value: boolean
} | {
  _tag: "Controls"
  value: boolean
} | {
  _tag: "Loop"
  value: boolean
} | {
  _tag: "Muted"
  value: boolean
} | {
  _tag: "Poster"
  value: string
} | {
  _tag: "Preload"
  value: string
} | {
  _tag: "Playsinline"
  value: boolean
} | {
  _tag: "High"
  value: number
} | {
  _tag: "Low"
  value: number
} | {
  _tag: "Optimum"
  value: number
} | {
  _tag: "Usemap"
  value: string
} | {
  _tag: "Ismap"
  value: boolean
} | {
  _tag: "Role"
  value: string
} | {
  _tag: "AriaLabel"
  value: string
} | {
  _tag: "AriaLabelledBy"
  value: string
} | {
  _tag: "AriaDescribedBy"
  value: string
} | {
  _tag: "AriaHidden"
  value: boolean
} | {
  _tag: "AriaExpanded"
  value: boolean
} | {
  _tag: "AriaSelected"
  value: boolean
} | {
  _tag: "AriaChecked"
  value: boolean | "mixed"
} | {
  _tag: "AriaDisabled"
  value: boolean
} | {
  _tag: "AriaRequired"
  value: boolean
} | {
  _tag: "AriaInvalid"
  value: boolean
} | {
  _tag: "AriaLive"
  value: string
} | {
  _tag: "AriaControls"
  value: string
} | {
  _tag: "AriaCurrent"
  value: string
} | {
  _tag: "AriaOrientation"
  value: string
} | {
  _tag: "AriaPressed"
  value: string
} | {
  _tag: "AriaHasPopup"
  value: string
} | {
  _tag: "AriaActiveDescendant"
  value: string
} | {
  _tag: "AriaSort"
  value: string
} | {
  _tag: "AriaMultiSelectable"
  value: boolean
} | {
  _tag: "AriaModal"
  value: boolean
} | {
  _tag: "AriaBusy"
  value: boolean
} | {
  _tag: "AriaErrorMessage"
  value: string
} | {
  _tag: "AriaRoleDescription"
  value: string
} | {
  _tag: "AriaAtomic"
  value: boolean
} | {
  _tag: "AriaAutocomplete"
  value: string
} | {
  _tag: "AriaColcount"
  value: number
} | {
  _tag: "AriaColindex"
  value: number
} | {
  _tag: "AriaColspan"
  value: number
} | {
  _tag: "AriaDescription"
  value: string
} | {
  _tag: "AriaDetails"
  value: string
} | {
  _tag: "AriaFlowto"
  value: string
} | {
  _tag: "AriaKeyshortcuts"
  value: string
} | {
  _tag: "AriaLevel"
  value: number
} | {
  _tag: "AriaOwns"
  value: string
} | {
  _tag: "AriaPlaceholder"
  value: string
} | {
  _tag: "AriaPosinset"
  value: number
} | {
  _tag: "AriaReadonly"
  value: boolean
} | {
  _tag: "AriaRelevant"
  value: string
} | {
  _tag: "AriaRowcount"
  value: number
} | {
  _tag: "AriaRowindex"
  value: number
} | {
  _tag: "AriaRowspan"
  value: number
} | {
  _tag: "AriaSetsize"
  value: number
} | {
  _tag: "AriaValuemax"
  value: number
} | {
  _tag: "AriaValuemin"
  value: number
} | {
  _tag: "AriaValuenow"
  value: number
} | {
  _tag: "AriaValuetext"
  value: string
} | {
  _tag: "Attribute"
  key: string
  value: string
} | {
  _tag: "DataAttribute"
  key: string
  value: string
} | {
  _tag: "Style"
  value: Record<string, string>
} | {
  _tag: "InnerHTML"
  value: string
} | {
  _tag: "ViewBox"
  value: string
} | {
  _tag: "Xmlns"
  value: string
} | {
  _tag: "Fill"
  value: string
} | {
  _tag: "FillRule"
  value: string
} | {
  _tag: "ClipRule"
  value: string
} | {
  _tag: "Stroke"
  value: string
} | {
  _tag: "StrokeWidth"
  value: string
} | {
  _tag: "StrokeLinecap"
  value: string
} | {
  _tag: "StrokeLinejoin"
  value: string
} | {
  _tag: "D"
  value: string
} | {
  _tag: "Cx"
  value: string
} | {
  _tag: "Cy"
  value: string
} | {
  _tag: "R"
  value: string
} | {
  _tag: "X"
  value: string
} | {
  _tag: "Y"
  value: string
} | {
  _tag: "Width"
  value: string
} | {
  _tag: "Height"
  value: string
} | {
  _tag: "X1"
  value: string
} | {
  _tag: "Y1"
  value: string
} | {
  _tag: "X2"
  value: string
} | {
  _tag: "Y2"
  value: string
} | {
  _tag: "Points"
  value: string
} | {
  _tag: "Transform"
  value: string
} | {
  _tag: "Opacity"
  value: string
} | {
  _tag: "StrokeDasharray"
  value: string
} | {
  _tag: "StrokeDashoffset"
  value: string
} | {
  _tag: "Dx"
  value: string
} | {
  _tag: "Dy"
  value: string
} | {
  _tag: "Rotate"
  value: string
} | {
  _tag: "TextAnchor"
  value: string
} | {
  _tag: "DominantBaseline"
  value: string
} | {
  _tag: "AlignmentBaseline"
  value: string
} | {
  _tag: "BaselineShift"
  value: string
} | {
  _tag: "TextLength"
  value: string
} | {
  _tag: "LengthAdjust"
  value: string
} | {
  _tag: "FontFamily"
  value: string
} | {
  _tag: "FontSize"
  value: string
} | {
  _tag: "FontWeight"
  value: string
} | {
  _tag: "FontStyle"
  value: string
} | {
  _tag: "LetterSpacing"
  value: string
} | {
  _tag: "WordSpacing"
  value: string
} | {
  _tag: "TextDecoration"
  value: string
} | {
  _tag: "WritingMode"
  value: string
} | {
  _tag: "Rx"
  value: string
} | {
  _tag: "Ry"
  value: string
} | {
  _tag: "PathLength"
  value: string
} | {
  _tag: "FillOpacity"
  value: string
} | {
  _tag: "StrokeOpacity"
  value: string
} | {
  _tag: "StrokeMiterlimit"
  value: string
} | {
  _tag: "PaintOrder"
  value: string
} | {
  _tag: "VectorEffect"
  value: string
} | {
  _tag: "Color"
  value: string
} | {
  _tag: "Visibility"
  value: string
} | {
  _tag: "Display"
  value: string
} | {
  _tag: "Overflow"
  value: string
} | {
  _tag: "PointerEvents"
  value: string
} | {
  _tag: "Cursor"
  value: string
} | {
  _tag: "ShapeRendering"
  value: string
} | {
  _tag: "TextRendering"
  value: string
} | {
  _tag: "ImageRendering"
  value: string
} | {
  _tag: "ClipPath"
  value: string
} | {
  _tag: "Mask"
  value: string
} | {
  _tag: "Filter"
  value: string
} | {
  _tag: "ClipPathUnits"
  value: string
} | {
  _tag: "MaskUnits"
  value: string
} | {
  _tag: "MaskContentUnits"
  value: string
} | {
  _tag: "FilterUnits"
  value: string
} | {
  _tag: "PrimitiveUnits"
  value: string
} | {
  _tag: "Offset"
  value: string
} | {
  _tag: "StopColor"
  value: string
} | {
  _tag: "StopOpacity"
  value: string
} | {
  _tag: "GradientUnits"
  value: string
} | {
  _tag: "GradientTransform"
  value: string
} | {
  _tag: "SpreadMethod"
  value: string
} | {
  _tag: "Fx"
  value: string
} | {
  _tag: "Fy"
  value: string
} | {
  _tag: "Fr"
  value: string
} | {
  _tag: "PatternUnits"
  value: string
} | {
  _tag: "PatternContentUnits"
  value: string
} | {
  _tag: "PatternTransform"
  value: string
} | {
  _tag: "MarkerStart"
  value: string
} | {
  _tag: "MarkerMid"
  value: string
} | {
  _tag: "MarkerEnd"
  value: string
} | {
  _tag: "MarkerWidth"
  value: string
} | {
  _tag: "MarkerHeight"
  value: string
} | {
  _tag: "MarkerUnits"
  value: string
} | {
  _tag: "RefX"
  value: string
} | {
  _tag: "RefY"
  value: string
} | {
  _tag: "Orient"
  value: string
} | {
  _tag: "PreserveAspectRatio"
  value: string
} | {
  _tag: "Prop"
  key: string
  value: unknown
} | {
  _tag: "OnCustomEvent"
  f: (event: CustomEvent<unknown>) => Option.Option<Message>
  name: string
} | {
  _tag: "OnMount"
  action: MountAction<Message, unknown, never | AllowedMountRequirements>
} | {
  _tag: "OnUnmount"
  message: Message
}

BoundBlockConfig

typesource
/**
 * The render configuration produced by a registered child Binding's `embedView`
 * method. Its private scope evidence prevents unregistered child rendering.
 * The binding supplies the child's view, Message wrapper, and capability scope.
 * The parent supplies `slotId`, the child Model, and any declared `viewInputs`.
 * 
 * A `slotId` identifies one DOM placement within the current view boundary.
 * Give separately rendered placements different IDs, and use stable entity IDs
 * for lists. Duplicate IDs in one boundary fail before the tree is patched.
 * 
 * Top-level callbacks in `viewInputs`, such as `toView`, execute in the parent's
 * boundary so elements built by the parent dispatch its Messages. Nested
 * callbacks are rejected when the view builds; keep slot callbacks at the top
 * level.
 * 
 * OutMessages are handled by the registered binding's `outMessage` policy.
 * Parent update code calls its `fold` method or a registered Step.
 */
type BoundBlockConfig = BoundBlockFields<View, ParentMessage> & Readonly<{}>

BoundBlockConfigEvidence

typesource
/**
 * Static child render contract retained by a BoundBlockConfig's private
 * Binding scope.
 */
type BoundBlockConfigEvidence = Readonly<{
  config: BoundBlockFields<View, ParentMessage>
  mountRequirements: View["__blockMountRequirements"]
  parentMessage: ParentMessage
}>

BoundBlockFields

typesource
/**
 * Portable child render fields shared by Binding inputs and embedded render
 * evidence.
 */
type BoundBlockFields = Readonly<{
  model: View["__blockModel"]
  slotId: string
  toParentMessage: (message: View["__blockMessage"]) => ParentMessage
  view: View
}> & Parameters<View> extends [unknown, infer ViewInputs, unknown]
  ? Readonly<{
    viewInputs: ViewInputs
  }>
  : Readonly<{
    viewInputs: never
  }>

ChildAttribute

typesource
/**
 * An attribute carrying a handler that dispatches through a Block
 *  boundary's wrapping chain. Published by Blocks (typically Foldkit's
 *  `Ui.*` components) for a parent to spread into its own element
 *  attribute arrays. The parent does not know or care which child
 *  produced these; the runtime routes each handler through the
 *  originating Block's wrap chain at event-fire time.
 * 
 *  `resolveUnmount` snapshots the boundary's wrapping chain at the time the
 *  group was published (child boundary alive) so `OnUnmount` can dispatch a
 *  root message after the boundary has been torn down. `boundaryMappers`
 *  snapshots the `toParentMessage` lifts (innermost first) for the Scene test
 *  harness. Groups containing `OnMount` also carry `resolveMountDispatch`,
 *  which binds the Mount to the acquiring render's dispatch owner while
 *  following that owner's current live wrappers.
 * 
 *  Created via childAttributes. Element constructors accept
 *  `ChildAttribute` alongside `Attribute<Message>` in their attribute
 *  arrays.
 */
type ChildAttribute = Readonly<{
  __childAttribute: true
  attribute: ChildAttributeValue<RequiredMountRequirements>
  boundaryMappers: ReadonlyArray<(message: unknown) => unknown>
  dispatch: DispatchSync
  resolveMountDispatch: MountDispatchResolver
  resolveUnmount: (message: unknown) => () => void
}>

DispatchSync

typesource
/**
 * Synchronous Message dispatcher provided to view-time element constructors.
 * The optional guard suppresses dispatch after its captured occurrence is no
 * longer current.
 */
type DispatchSync = (message: unknown, isCurrent?: () => boolean) => void

Document

typesource
/**
 * The complete output of a page-owning view. The runtime patches `body` into
 *  the application container, writes `title` to `document.title`, and manages
 *  the optional document metadata.
 * 
 *  Supplied `lang` and `dir` values are written to the `<html>` element. An
 *  omitted value leaves the current attribute unchanged, including a value
 *  from the served HTML or an earlier render. Drive both fields from the Model
 *  when the application can switch languages at runtime.
 * 
 *  `canonical` has no address-bar default. Derive it from the typed route in
 *  the Model, where the application can decide which route and query values
 *  identify the page. If the view never supplies it, the runtime leaves a
 *  served `<link rel="canonical">` unchanged or keeps the document without one.
 * 
 *  Before the client first writes `canonical` or `ogUrl`, it records the value
 *  already present on the corresponding element. A later omission restores
 *  that value, or removes the element if the runtime created it. During
 *  hydration, the recorded value may be metadata rendered for the initial
 *  route. `ogUrl` can be supplied independently; when omitted alongside an
 *  explicit `canonical`, it uses that canonical.
 * 
 *  Server rendering returns only the canonical supplied by the view. It
 *  returns `ogUrl` when supplied or falls back to an explicit canonical.
 * 
 *  This is the return type of a `makeApplication` view. An application embedded
 *  at a node should use `makeElement`; its view returns `Html` and never changes
 *  the `<head>` or `<html>` element.
 */
type Document = Readonly<{
  body: Html
  canonical: string
  dir: TextDirection
  lang: string
  ogUrl: string
  title: string
}>

Html

typesource
/**
 * A virtual DOM element. Constructed synchronously by the element factories
 *  on HtmlBuilder. The runtime patches a `VNode` (or `null` to
 *  render nothing) into the application container.
 */
type Html = VNode | null

HtmlBuilder

typesource
/**
 * The typed Html builder a view builds DOM with: all HTML, SVG, and MathML
 * element constructors, attribute constructors, a `keyed` helper for keyed
 * elements, `empty` for rendering nothing, and `block` for embedding a
 * child Block.
 * 
 * A builder cannot be constructed by application code. The runtime supplies
 * it to each view alongside the model, typed by the Message universe of the
 * frame that view renders in: the app's Message for the root view, the
 * Block's own Message inside a view authored through its Composition's
 * `view` method. Used in the frame that supplied it, a handler built with it
 * carries exactly the Messages that frame's dispatcher can route, so a Message
 * from another universe (the classic case: a shared helper building an
 * app-level Message inside a Block) is a compile error at the handler call
 * site.
 * 
 * The type scopes where a builder is obtained, not where it is used. Carrying
 * one into another frame, by storing it or handing the builder itself to a
 * child through `viewInputs`, still compiles and still builds handlers that
 * frame cannot route. Thread `h` as a parameter; never store it.
 * 
 * Pass `h` along as an ordinary parameter when extracting view helpers; a
 * memoized helper receives it through the `createLazy` args array. When a
 * child must render markup that belongs to an ancestor, the ancestor passes a
 * renderer that already closed over its own builder, not the builder, so the
 * handlers resolve in the ancestor's boundary. Where no builder is in scope
 * at all, typically module scope, use inertHtml.
 */
type HtmlBuilder = MessageUniverse<Message> & MountRequirementsUniverse<AllowedMountRequirements> & HtmlElements<Message, AllowedMountRequirements> & HtmlAttributes<Message, AllowedMountRequirements> & Readonly<{
  block: (config: CheckedBlockConfig<Config, Message, AllowedMountRequirements>) => Html
  empty: null
  keyed: KeyedFunction<Message, AllowedMountRequirements>
}>

KeyboardModifiers

typesource
/** Modifier key state extracted from a `KeyboardEvent`. */
type KeyboardModifiers = Readonly<{
  altKey: boolean
  ctrlKey: boolean
  metaKey: boolean
  shiftKey: boolean
}>

MountRenderOwner

typesource
/**
 * Identifies whether a Mount was acquired by the live view or a historical
 * test replay.
 */
type MountRenderOwner = "Live" | "Replay"

TagName

typesource
/** Union of all valid HTML, SVG, and MathML tag names. */
type TagName = "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "meta" | "meter" | "nav" | "noscript" | "object" | "ol" | "optgroup" | "option" | "output" | "p" | "picture" | "portal" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "search" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "svg" | "switch" | "symbol" | "text" | "textPath" | "tspan" | "use" | "view" | "annotation" | "annotation-xml" | "math" | "maction" | "menclose" | "merror" | "mfenced" | "mfrac" | "mglyph" | "mi" | "mlabeledtr" | "mlongdiv" | "mmultiscripts" | "mn" | "mo" | "mover" | "mpadded" | "mphantom" | "mprescripts" | "mroot" | "mrow" | "ms" | "mscarries" | "mscarry" | "msgroup" | "msline" | "mspace" | "msqrt" | "msrow" | "mstack" | "mstyle" | "msub" | "msubsup" | "msup" | "mtable" | "mtd" | "mtext" | "mtr" | "munder" | "munderover" | "semantics"

TextareaAttribute

typesource
/**
 * An attribute accepted by textarea builders. Textarea content must use
 *  `h.Value`; innerHTML does not keep the live value tracking the Model after
 *  the field is dirty.
 */
type TextareaAttribute = Exclude<Attribute<Message, AllowedMountRequirements>, Readonly<{
  _tag: "InnerHTML"
}>>

Interfaces

VNode

interfacesource
/**
 * Virtual DOM node rendered by Foldkit's Html builders. Fields are populated
 * and updated by the renderer; application views normally construct VNodes
 * through element functions on an Html builder.
 */
interface VNode {
  children: Array<string | VNode> | undefined
  data: VNodeData<Props> | undefined
  elm: Node | undefined
  identity: string
  key: PropertyKey | undefined
  sel: string | undefined
  text: string | undefined
}

Constants

ClickOptions

constsource
/**
 * Declarative controls for an `OnClick` handler. Omitted
 *  fields keep the browser default, allow the click to bubble, and leave focus
 *  unchanged.
 */
const ClickOptions: Struct<{
  defaultAction: optional<Literals<readonly ["Allow", "Prevent"]>>
  focusSelector: optional<String>
  propagation: optional<Literals<readonly ["Bubble", "Stop"]>>
}>

DefaultAction

constsource
/**
 * Whether an event handler leaves the browser's default action in place or
 *  prevents it synchronously.
 */
const DefaultAction: Literals<readonly ["Allow", "Prevent"]>

EventPropagation

constsource
/**
 * Whether an event continues through its DOM propagation path or stops after
 *  the handlers on its current element have run.
 */
const EventPropagation: Literals<readonly ["Bubble", "Stop"]>

TextDirection

constsource
/**
 * Text direction for the document root, applied to `dir` on the `<html>`
 *  element. `Auto` defers to the browser's first-strong-character heuristic.
 */
const TextDirection: Literals<readonly ["Ltr", "Rtl", "Auto"]>

inertHtml

constsource
/**
 * Builder whose Message universe is empty. Its Message type is `never`, so
 * every event-handler constructor is uncallable and nothing built with it can
 * dispatch a Message. Elements, attributes, and keying behave exactly as they
 * do on any other builder, and the markup itself is free to vary with runtime
 * data. Inert describes what the result can do, not how it is computed.
 * 
 * Inert to Foldkit's dispatch, not to the browser. A raw DOM attribute still
 * does whatever the browser makes of it, which is exactly how the default
 * crash view gets a working reload button:
 * `h.Attribute('onclick', 'location.reload()')`. What `never` rules out is a
 * Message reaching `update`, not every possible behavior.
 * 
 * Use it where no builder is in scope, which in practice means module scope
 * and the frameless renders the framework performs itself:
 * 
 * ```ts
 * import { inertHtml as ih } from 'foldkit/html'
 * 
 * const PagefindBody = ih.DataAttribute('pagefind-body', '')
 * ```
 * 
 * Attributes it produces are `Attribute<never>`, so they flow into any
 * Message universe by covariance. That makes it the right builder for
 * library code emitting handler-free attribute bundles for arbitrary apps.
 * 
 * Inside a view, use the view's own `h` parameter. A view already holds a
 * builder, and reaching past it for this one is the habit that made a
 * caller-chosen Message type possible in the first place.
 */
const inertHtml: HtmlBuilder<never>