Mixins / foldkit-mixins-surface

SurfaceView

namespace · packages/mixins-surface/src/surfaceView.ts:10

export * as SurfaceView from './surfaceView.js'

Binds a Surface's projected Model and Message subset to a SlotView.

The renderer's input is the Surface's projected Model, so Style and Behavior contributions can only read what the Surface projects. Its builder is typed with the Surface's Message subset, so a Behavior cannot emit a Message the Surface does not expose. The returned value is an ordinary SlotView, so the core attach/pipe algebra applies unchanged.

In the guides

Members

SurfaceView.define

function · packages/mixins-surface/src/surfaceView.ts:14

function define<Root, Model, Message, Params, Slots_>(
  surface: Surface<Root, Model, Message, Params>,
  slots: Slots_,
  render: SlotViewRender<Slots_, Model, Message>,
  options?: {
    readonly name?: string
  },
): SlotView.SlotView<Slots_, Model, Message>

SurfaceView.describe

function · packages/mixins-surface/src/surfaceView.ts:119

function describe<Root, Model, Message, Params, Slots_>(
  surface: Surface<Root, Model, Message, Params>,
  params: Params,
  view: SlotView.SlotView<Slots_, Model, Message>,
): SurfaceViewDescription

One serializable description of a Surface and the SlotView that renders it: what it observes and may emit, and where Style/Behavior attach. No functions, so it can be committed, diffed, or handed to DevTools and agent tooling.

SurfaceView.inspect

function · packages/mixins-surface/src/surfaceView.ts:81

function inspect<Slots_, Model, Message>(
  view: SlotView.SlotView<Slots_, Model, Message>,
): SurfaceViewInspection

Serializable metadata for DevTools and docs: the published slots and the names of the attached Mixins, with no functions.

@deprecated

Use SlotView.describe, or SurfaceView.describe with a Surface: they add each attachment's requirements and contributions. This stays for one release.

SurfaceView.over

function · packages/mixins-surface/src/surfaceView.ts:29

function over<Root, Model, Message, Params, Slots_>(
  surface: Surface<Root, Model, Message, Params>,
  slots: Slots_,
): SlotView.Bound<Slots_, Model, Message>

SlotView.over with the input the Surface's projected Model and the Message universe the subset it exposes, both read from surface, so nothing is annotated. Its define names the view after the Surface unless told otherwise.

SurfaceView.render

function · packages/mixins-surface/src/surfaceView.ts:59

function render<Root, Model, Message, Params, Slots_>(
  view: SlotView.SlotView<Slots_, Model, Message>,
  surface: Surface<Root, Model, Message, Params>,
  params: Params,
  root: Root,
): Html

Renders a SlotView for surface's projection of root with an inert builder: no runtime, so handlers are built but never dispatched. For demos, tests, and static output.

SurfaceView.SurfaceViewDescription

interface · packages/mixins-surface/src/surfaceView.ts:98

interface SurfaceViewDescription {
  readonly name: string
  readonly observes: ReturnType<typeof Surface.inspect>['dependencies']
  readonly metadata: ReadonlyArray<MetadataSummary>
  readonly emits: ReadonlyArray<string>
  readonly slots: ViewDescription['slots']
  readonly conforms: ViewDescription['conforms']
  readonly attachments: ViewDescription['attachments']
  readonly findings: ViewDescription['findings']
  readonly mixins: ReadonlyArray<string>
}

SurfaceView.SurfaceViewInspection

interface · packages/mixins-surface/src/surfaceView.ts:66

interface SurfaceViewInspection {
  readonly name: string
  readonly slots: ReturnType<typeof Slots.describe>['slots']
  readonly mixins: ReadonlyArray<string>
}

SurfaceView.toMarkdown

function · packages/mixins-surface/src/surfaceView.ts:140

function toMarkdown(description: SurfaceViewDescription): string

Deterministic Markdown for a description; stable key order, no timestamps.

SurfaceView.toRenderer

function · packages/mixins-surface/src/surfaceView.ts:47

function toRenderer<Slots_, Model, Message>(
  view: SlotView.SlotView<Slots_, Model, Message>,
): Renderer<Model, Message>

Adapts a SlotView to a Surface renderer. Surface.view hands a renderer a ViewBuilder — the real builder with its MessageUniverse phantom removed — and this is the matching boundary cast, sound because the renderer only constructs the Surface's Message subset.