BotHost
Defined in: packages/core/src/host/index.ts:29
Shared host operations for node-based bot platforms.
The renderer only needs node mutation, events and a commit boundary. Each platform supplies a commit implementation that serializes its tree.
Implements
Section titled “Implements”Host<BotNode>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BotHost(
options):BotHost
Defined in: packages/core/src/host/index.ts:49
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”BotHost
Properties
Section titled “Properties”container
Section titled “container”
readonlycontainer:BotNode
Defined in: packages/core/src/host/index.ts:30
controlled
Section titled “controlled”
readonlycontrolled:ReadonlySet<string>
Defined in: packages/core/src/host/index.ts:32
Implementation of
Section titled “Implementation of”Renderer.Host.controlled
elements
Section titled “elements”
readonlyelements: readonlystring[]
Defined in: packages/core/src/host/index.ts:31
Implementation of
Section titled “Implementation of”Renderer.Host.elements
platform
Section titled “platform”
readonlyplatform:string
Defined in: packages/core/src/host/index.ts:35
The platform this host serializes for, such as discord or slack.
runsMounts
Section titled “runsMounts”
readonlyrunsMounts:true=true
Defined in: packages/core/src/host/index.ts:33
Implementation of
Section titled “Implementation of”Renderer.Host.runsMounts
Accessors
Section titled “Accessors”commits
Section titled “commits”Get Signature
Section titled “Get Signature”get commits():
number
Defined in: packages/core/src/host/index.ts:45
How many commits this host has completed.
Returns
Section titled “Returns”number
session
Section titled “session”Get Signature
Section titled “Get Signature”get session():
HostSession|null
Defined in: packages/core/src/host/index.ts:62
The session whose id and version are stamped onto interaction ids.
Returns
Section titled “Returns”HostSession | null
Methods
Section titled “Methods”createContainer()
Section titled “createContainer()”createContainer():
BotNode
Defined in: packages/core/src/host/index.ts:180
Returns
Section titled “Returns”createElement()
Section titled “createElement()”createElement(
tag):BotNode
Defined in: packages/core/src/host/index.ts:170
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Renderer.Host.createElement
createText()
Section titled “createText()”createText(
text):BotNode
Defined in: packages/core/src/host/index.ts:174
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Renderer.Host.createText
freeze()
Section titled “freeze()”freeze(
nodes?):void
Defined in: packages/core/src/host/index.ts:126
Marks every interactive node disabled, so a painted copy shows the state without offering controls that cannot route to a live root.
Parameters
Section titled “Parameters”nodes?
Section titled “nodes?”readonly BotNode[] = ...
Returns
Section titled “Returns”void
insertBefore()
Section titled “insertBefore()”insertBefore(
parent,node,ref):void
Defined in: packages/core/src/host/index.ts:220
Parameters
Section titled “Parameters”parent
Section titled “parent”BotNode | undefined
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.insertBefore
nextOf()
Section titled “nextOf()”nextOf(
node):BotNode|undefined
Defined in: packages/core/src/host/index.ts:232
Parameters
Section titled “Parameters”Returns
Section titled “Returns”BotNode | undefined
Implementation of
Section titled “Implementation of”Renderer.Host.nextOf
nodes()
Section titled “nodes()”nodes(): readonly
BotNode[]
Defined in: packages/core/src/host/index.ts:166
Every node in document order.
Hosts walk the tree several times per commit (ids, routing, serialization). Taking one list and passing it to the other steps keeps those walks in sync and avoids re-traversing the whole tree for each concern.
Returns
Section titled “Returns”readonly BotNode[]
parentOf()
Section titled “parentOf()”parentOf(
node):BotNode|undefined
Defined in: packages/core/src/host/index.ts:228
The node’s parent, or undefined once it’s removed. instanceAt relies on this.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”BotNode | undefined
Implementation of
Section titled “Implementation of”Renderer.Host.parentOf
prepareInteractionIds()
Section titled “prepareInteractionIds()”prepareInteractionIds(
nodes?):string|undefined
Defined in: packages/core/src/host/index.ts:87
Assigns every interactive node its platform-facing custom id.
Without a session the id keeps the old host-generated value. With one, auto ids are document-order ordinals and explicit ids keep the author’s text as the key, both wrapped with the session and its current version. A restored tree therefore produces the same ids as the state it shows.
Returns a message when an id exceeds the platform limit. Callers surface that message as a target failure instead of throwing from the renderer.
Parameters
Section titled “Parameters”nodes?
Section titled “nodes?”readonly BotNode[] = ...
Returns
Section titled “Returns”string | undefined
remove()
Section titled “remove()”remove(
node):void
Defined in: packages/core/src/host/index.ts:224
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.remove
setAttr()
Section titled “setAttr()”setAttr(
node,name,value,_previous?):void
Defined in: packages/core/src/host/index.ts:188
Sets an attribute of node, or removes it when value is undefined.
previous is the value the renderer takes the attribute to hold before
the call: the one it last set, or the one hydration read from the node,
and undefined when it holds none.
Parameters
Section titled “Parameters”string
string | undefined
_previous?
Section titled “_previous?”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.setAttr
setEvents()
Section titled “setEvents()”setEvents(
node,handlers,dispatch,options):void
Defined in: packages/core/src/host/index.ts:239
Parameters
Section titled “Parameters”handlers
Section titled “handlers”Readonly<Record<string, View.Handler<unknown, any>>>
dispatch
Section titled “dispatch”Dispatch
options
Section titled “options”Readonly<Record<string, View.EventOptions>>
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.setEvents
setProp()
Section titled “setProp()”setProp(
node,name,value):void
Defined in: packages/core/src/host/index.ts:204
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.setProp
setSession()
Section titled “setSession()”setSession(
session):void
Defined in: packages/core/src/host/index.ts:67
Binds the host to a resumable message session.
Parameters
Section titled “Parameters”session
Section titled “session”HostSession | null
Returns
Section titled “Returns”void
setSessionVersion()
Section titled “setSessionVersion()”setSessionVersion(
version):void
Defined in: packages/core/src/host/index.ts:72
Advances the version used by the next commit.
Parameters
Section titled “Parameters”version
Section titled “version”number
Returns
Section titled “Returns”void
setText()
Section titled “setText()”setText(
node,text):void
Defined in: packages/core/src/host/index.ts:184
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Renderer.Host.setText
waitForCommit()
Section titled “waitForCommit()”waitForCommit(
after,timeoutMs?):Effect<void>
Defined in: packages/core/src/host/index.ts:146
Waits until a commit after after has run, or the timeout elapses.
Parameters
Section titled “Parameters”number
timeoutMs?
Section titled “timeoutMs?”number = 100
Returns
Section titled “Returns”Effect<void>