SurfaceConnection
The provider-side client an embedded surface (or a modal body) receives, returned by
connectSurface. It is the surface-scoped counterpart to Platform: the surface reads
its params, renders, reports its height, and re-renders on onParams — all brokered through the
shell like any channel.
Properties
Section titled “Properties”channelId
Section titled “channelId”readonly channelId: string;This surface’s channel id.
readonly modal: { open: Promise<T | null>;};Open a shell-brokered modal whose body is one of this app’s own surfaces.
open()
Section titled “open()”open<T>(opts): Promise<T | null>;Open the modal; resolves with the body’s result, or null if dismissed.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<T | null>
params
Section titled “params”readonly params: unknown;The params the host (or modal opener) passed; re-read on SurfaceConnection.onParams.
session
Section titled “session”readonly session: Session;The current user snapshot. See Session.
readonly state: StateClient;App-scoped shared state across this app’s frames (e.g. a modal body driving a draft the parent reflects). See StateClient.
surfaceName
Section titled “surfaceName”readonly surfaceName: string;The surface name this entrypoint was loaded as.
telemetry
Section titled “telemetry”readonly telemetry: { error: void; event: void; timing: void;};Structured telemetry, correlated to the active trace.
error()
Section titled “error()”error(name, data?): void;Record a named error.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
event()
Section titled “event()”event(name, data?): void;Record a named event.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
timing()
Section titled “timing()”timing(name, data?): void;Record a named timing measurement.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
readonly theme: ThemeInfo;The active theme. See ThemeInfo.
Methods
Section titled “Methods”activate()
Section titled “activate()”activate(el): void;Convenience for the standard surface bring-up: after one animation frame — so custom elements
such as the <ds-*> design-system components have upgraded and the first measured height is the
final one — SurfaceConnection.observe el and then call SurfaceConnection.ready.
Call it once from your framework’s post-render hook (Angular afterNextRender, React useEffect)
with the surface’s root element; it replaces the hand-rolled observe + ready (+ rAF) every surface
otherwise repeats.
Parameters
Section titled “Parameters”HTMLElement
Returns
Section titled “Returns”void
close()
Section titled “close()”close(result?): void;When this surface IS a modal body, close it and resolve the opener with result.
Parameters
Section titled “Parameters”result?
Section titled “result?”unknown
Returns
Section titled “Returns”void
disconnect()
Section titled “disconnect()”disconnect(): void;Detach all listeners and timers for this surface.
Returns
Section titled “Returns”void
getRoles()
Section titled “getRoles()”getRoles(): string[];Advisory roles for show/hide; the surface’s backend is the real gate.
Returns
Section titled “Returns”string[]
hasRole()
Section titled “hasRole()”hasRole(role): boolean;Whether the advisory roles include role; for affordances only, never enforcement.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
log( level, message, fields?): void;Emit a correlated log line.
Parameters
Section titled “Parameters”message
Section titled “message”string
fields?
Section titled “fields?”Record<string, unknown>
Returns
Section titled “Returns”void
observe()
Section titled “observe()”observe(el): void;Track an element’s size so the shell keeps the surface’s iframe sized to its content.
Parameters
Section titled “Parameters”HTMLElement
Returns
Section titled “Returns”void
onParams()
Section titled “onParams()”onParams(handler): () => void;Subscribe to the host re-parameterising this surface; returns an unsubscribe function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(params) => void
Returns
Section titled “Returns”() => void
onRefresh()
Section titled “onRefresh()”onRefresh(handler): () => void;React to a refresh nudge (e.g. a dashboard widget’s refresh button) — re-fetch with the CURRENT params, no param change. Returns an unsubscribe function.
Parameters
Section titled “Parameters”handler
Section titled “handler”() => void
Returns
Section titled “Returns”() => void
onThemeChange()
Section titled “onThemeChange()”onThemeChange(handler): () => void;Subscribe to theme changes; returns an unsubscribe function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(theme) => void
Returns
Section titled “Returns”() => void
ready()
Section titled “ready()”ready(): void;Signal the surface has rendered + wired its handlers (releases the shell barrier); pair with SurfaceConnection.observe for correct sizing.
Returns
Section titled “Returns”void
reportHeight()
Section titled “reportHeight()”reportHeight(height): void;Report a one-off height in pixels (use instead of, or alongside, SurfaceConnection.observe).
Parameters
Section titled “Parameters”height
Section titled “height”number
Returns
Section titled “Returns”void
span()
Section titled “span()”span(name): SpanHandle;Open a timing span. See SpanHandle.
Parameters
Section titled “Parameters”string