tecs.host

Managed-call bridge between the Rust application host and Nupp game state.

This module keeps the embedding ABI scalar. Rust holds a managed Session handle and asks for one frame at a time. Records remain inside Nupp and no Lua stack layout or collector address becomes part of the host contract.

Translated platform input crosses on the nupp.host channel rather than through exports. The host pushes each observation on a tecs.input.* kind, and the session routes every kind to its input bus as the matching record below, whose fields are the pushed values in order. A route delivers at the start of the next frame, or while a frame is parked, and the session queues the platform event for the frame after it. The kinds are a compatibility surface between this module and the host.

Image residency commands cross the same channel the other way. A frame that queued uploads, releases or material maps asks the host to apply each one on a tecs.image.* call, in the order it queued them, and parks until the host answers from its loop. The answer completes the command in tecs.gfx.images, so the frame that queued an upload finishes with it resident or failed, and the packet the host extracts next already says so.

Module contents

Types

TypeKindDescription
CloseInputrecordA close request the host pushed on tecs.input.close.
FocusInputrecordA focus transition the host pushed on tecs.input.focus.
KeyInputrecordA keyboard transition the host pushed on tecs.input.key.
PointerButtonInputrecordA pointer button transition the host pushed on tecs.input.pointer-button.
PointerMoveInputrecordAn absolute pointer position and relative delta the host pushed on tecs.input.pointer-move.
ResizeInputrecordA size observation the host pushed on tecs.input.resize.
SessionrecordHost-owned state rooted by one Nupp managed handle.
TextInputrecordCommitted input-method text the host pushed on tecs.input.text.
TouchInputrecordOne finger's transition or movement the host pushed on tecs.input.touch.
WheelInputrecordNormalized wheel movement the host pushed on tecs.input.wheel.

Functions

FunctionKindDescription
applyWindowStatefunctionApplies a complete state acknowledgement after processing commands.
attachWindowfunctionAttaches the Rust-created window with a complete initial state.
captureResultfunctionDelivers one completed frame readback to its requester.
crashedfunctionReturns the first guarded application failure, if one exists.
createfunctionCreates one blank application session for the Rust host.
createWithPluginfunctionCreates an application session around a game-owned installation callback.
detachWindowfunctionDetaches the OS window after the host destroys it.
initfunctionStarts initialization and parks asynchronous startup work between host turns.
iteratefunctionStarts one frame or polls the frame already parked on asynchronous work.
newSessionfunctionCreates a configurable session without starting the application.
nextCapturefunctionConsumes the next explicit frame capture request.
nextModelUploadfunctionDrains one pending model upload for the native renderer.
nextWindowCommandfunctionReturns and consumes the next pending window command.
renderPacketfunctionExtracts the current renderable world into one versioned byte packet.
setSuspendedfunctionChanges whether host turns advance simulation.
shutdownfunctionRuns application shutdown once.
windowCommandFailedfunctionReports one rejected command to the game-facing window.

Values

ValueKindDescription
INPUT_ADDRESSvariableThe address every input route delivers at.

Types#

CloseInputrecord#

record CloseInput ...
@derive(events.Event)

A close request the host pushed on tecs.input.close.

Members

NameKindDescription
timestampfield
sequencefield

timestampfield#

timestamp: number

sequencefield#

sequence: integer

FocusInputrecord#

record FocusInput ...
@derive(events.Event)

A focus transition the host pushed on tecs.input.focus.

Members

NameKindDescription
focusedfield
timestampfield
sequencefield

focusedfield#

focused: boolean

timestampfield#

timestamp: number

sequencefield#

sequence: integer

KeyInputrecord#

record KeyInput ...
@derive(events.Event)

A keyboard transition the host pushed on tecs.input.key.

Members

NameKindDescription
downfield
physicalKeyfield
logicalKeyfield
textfield
modifiersfield
repeatedfield
timestampfield
sequencefield

downfield#

down: boolean

physicalKeyfield#

physicalKey: string

logicalKeyfield#

logicalKey: string?

textfield#

text: string?

modifiersfield#

modifiers: integer

repeatedfield#

repeated: boolean

timestampfield#

timestamp: number

sequencefield#

sequence: integer

PointerButtonInputrecord#

record PointerButtonInput ...
@derive(events.Event)

A pointer button transition the host pushed on tecs.input.pointer-button.

Members

NameKindDescription
downfield
buttonfield
xfield
yfield
timestampfield
sequencefield

downfield#

down: boolean

buttonfield#

button: integer

xfield#

x: number

yfield#

y: number

timestampfield#

timestamp: number

sequencefield#

sequence: integer

PointerMoveInputrecord#

record PointerMoveInput ...
@derive(events.Event)

An absolute pointer position and relative delta the host pushed on tecs.input.pointer-move.

Members

NameKindDescription
xfield
yfield
dxfield
dyfield
timestampfield
sequencefield

xfield#

x: number

yfield#

y: number

dxfield#

dx: number

dyfield#

dy: number

timestampfield#

timestamp: number

sequencefield#

sequence: integer

ResizeInputrecord#

record ResizeInput ...
@derive(events.Event)

A size observation the host pushed on tecs.input.resize.

Members

NameKindDescription
scaleChangedfieldRead-only.
widthfield
heightfield
pixelWidthfield
pixelHeightfield
scaleFactorfield
timestampfield
sequencefield

scaleChangedfield#

scaleChanged: boolean

Read-only. Reports whether the scale factor changed rather than only the size.

widthfield#

width: integer

heightfield#

height: integer

pixelWidthfield#

pixelWidth: integer

pixelHeightfield#

pixelHeight: integer

scaleFactorfield#

scaleFactor: number

timestampfield#

timestamp: number

sequencefield#

sequence: integer

Sessionrecord#

record Session ...

Host-owned state rooted by one Nupp managed handle.

Members

NameKindDescription
appfield
inputfieldEngine-owned.
hostedfield
routesfield
eventsfield
commandsfield
commandIndexfield
pumpfield
extractorfield
viewsfield

appfield#

app: application.Application

inputfield#

input: events.MessageBus<integer>

Engine-owned. Receives the host's pushed input as the records above at INPUT_ADDRESS. Public so a test can emit on it in place of a host; game code should ignore it.

hostedfield#

hosted: boolean
@private

routesfield#

routes: {nupphost.Route}
@private

eventsfield#

events: {platformevents.Event}
@private

commandsfield#

commands: {window.Command}
@private

commandIndexfield#

commandIndex: integer
@private

pumpfield#

pump: hostpump.Pump
@private

extractorfield#

extractor: framepacket.Extractor
@private

viewsfield#

views: viewpacket.Collector
@private

TextInputrecord#

record TextInput ...
@derive(events.Event)

Committed input-method text the host pushed on tecs.input.text.

Members

NameKindDescription
textfield
timestampfield
sequencefield

textfield#

text: string

timestampfield#

timestamp: number

sequencefield#

sequence: integer

TouchInputrecord#

record TouchInput ...
@derive(events.Event)

One finger's transition or movement the host pushed on tecs.input.touch.

x and y are in the window's logical coordinates and normalX and normalY run from zero to one across the surface. touchDevice and finger are strings rather than numbers because both are 64-bit platform identities that a Lua number would round together.

Members

NameKindDescription
phasefieldRead-only.
touchDevicefield
fingerfield
xfield
yfield
normalXfield
normalYfield
pressurefield
dxfield
dyfield
timestampfield
sequencefield

phasefield#

phase: string

Read-only. Names one of fingerDown, fingerMotion, fingerUp or fingerCanceled.

touchDevicefield#

touchDevice: string

fingerfield#

finger: string

xfield#

x: number

yfield#

y: number

normalXfield#

normalX: number

normalYfield#

normalY: number

pressurefield#

pressure: number

dxfield#

dx: number

dyfield#

dy: number

timestampfield#

timestamp: number

sequencefield#

sequence: integer

WheelInputrecord#

record WheelInput ...
@derive(events.Event)

Normalized wheel movement the host pushed on tecs.input.wheel.

Members

NameKindDescription
wheelXfield
wheelYfield
ticksXfield
ticksYfield
xfield
yfield
timestampfield
sequencefield

wheelXfield#

wheelX: number

wheelYfield#

wheelY: number

ticksXfield#

ticksX: integer

ticksYfield#

ticksY: integer

xfield#

x: number

yfield#

y: number

timestampfield#

timestamp: number

sequencefield#

sequence: integer

Functions#

applyWindowStatefunction#

function applyWindowState(exclusive session: Session, id: integer, title: string, width: integer, height: integer, pixelWidth: integer, pixelHeight: integer, scaleFactor: number, x: integer, y: integer, focused: boolean, visible: boolean, minimized: boolean, maximized: boolean, fullscreen: boolean, occluded: boolean, resizable: boolean, cursorVisible: boolean, cursorGrab: string): nil

Applies a complete state acknowledgement after processing commands.

Arguments

NameTypeDescription
exclusive sessionSession
idinteger
titlestring
widthinteger
heightinteger
pixelWidthinteger
pixelHeightinteger
scaleFactornumber
xinteger
yinteger
focusedboolean
visibleboolean
minimizedboolean
maximizedboolean
fullscreenboolean
occludedboolean
resizableboolean
cursorVisibleboolean
cursorGrabstring

Returns

TypeDescription
nil

attachWindowfunction#

function attachWindow(exclusive session: Session, id: integer, title: string, width: integer, height: integer, pixelWidth: integer, pixelHeight: integer, scaleFactor: number, x: integer, y: integer, focused: boolean, visible: boolean, minimized: boolean, maximized: boolean, fullscreen: boolean, occluded: boolean, resizable: boolean, cursorVisible: boolean, cursorGrab: string): nil

Attaches the Rust-created window with a complete initial state.

Arguments

NameTypeDescription
exclusive sessionSession
idinteger
titlestring
widthinteger
heightinteger
pixelWidthinteger
pixelHeightinteger
scaleFactornumber
xinteger
yinteger
focusedboolean
visibleboolean
minimizedboolean
maximizedboolean
fullscreenboolean
occludedboolean
resizableboolean
cursorVisibleboolean
cursorGrabstring

Returns

TypeDescription
nil

captureResultfunction#

function captureResult(exclusive session: Session, id: integer, width: integer, height: integer, rgba: string, png: string, reason: string?): nil

Delivers one completed frame readback to its requester.

Arguments

NameTypeDescription
exclusive sessionSession
idinteger
widthinteger
heightinteger
rgbastring
pngstring
reasonstring?

Returns

TypeDescription
nil

crashedfunction#

function crashed(borrows session: Session): string?

Returns the first guarded application failure, if one exists.

Arguments

NameTypeDescription
borrows sessionSession

Returns

TypeDescription
string?

createfunction#

function create(title: string?, width: integer?, height: integer?, debug: boolean?, maxFrames: integer?): Session

Creates one blank application session for the Rust host.

Arguments

NameTypeDescription
titlestring?

the desktop title, defaulting to tecs

widthinteger?

the positive initial logical width, defaulting to 1280

heightinteger?

the positive initial logical height, defaulting to 720

debugboolean?

whether guarded application failures may be cleared

maxFramesinteger?

an optional positive frame limit for host smoke runs

Returns

TypeDescription
Session

the session the embedding host keeps as a managed handle

createWithPluginfunction#

function createWithPlugin(plugin: application.Plugin, title: string?, width: integer?, height: integer?, debug: boolean?, maxFrames: integer?): Session

Creates an application session around a game-owned installation callback.

A game component exports a function with the managed create signature and delegates here with its statically imported plugin. Rust selects that export with --entry, so the host never dynamically requires game code.

Arguments

NameTypeDescription
pluginapplication.Plugin

the game installation callback

titlestring?

the desktop title, defaulting to tecs

widthinteger?

the positive initial logical width, defaulting to 1280

heightinteger?

the positive initial logical height, defaulting to 720

debugboolean?

whether guarded application failures may be cleared

maxFramesinteger?

an optional positive frame limit for host smoke runs

Returns

TypeDescription
Session

the session the embedding host keeps as a managed handle

detachWindowfunction#

function detachWindow(exclusive session: Session): nil

Detaches the OS window after the host destroys it.

Arguments

NameTypeDescription
exclusive sessionSession

Returns

TypeDescription
nil

initfunction#

function init(exclusive session: Session): boolean

Starts initialization and parks asynchronous startup work between host turns.

Arguments

NameTypeDescription
exclusive sessionSession

the application session to initialize.

Returns

TypeDescription
boolean

true while the host may continue driving startup or diagnostics.

iteratefunction#

function iterate(exclusive session: Session, dt: number): hostpump.State

Starts one frame or polls the frame already parked on asynchronous work.

Arguments

NameTypeDescription
exclusive sessionSession
dtnumber

Returns

TypeDescription
hostpump.State

parked, continue, or stopped

newSessionfunction#

function newSession(config: application.Config?): Session

Creates a configurable session without starting the application.

Under an embedding host the session routes the host's tecs.input.* pushes to its input bus. Without one, as in a test, nothing is routed and input arrives only by emitting on that bus.

Arguments

NameTypeDescription
configapplication.Config?

the application settings, including world timing and optional MCP port.

Returns

TypeDescription
Session

the session a component's constructor gives the Rust host.

Raises

TypeCondition
string

when application configuration is invalid.

nextCapturefunction#

function nextCapture(exclusive session: Session): integer

Consumes the next explicit frame capture request.

Arguments

NameTypeDescription
exclusive sessionSession

Returns

TypeDescription
integer

nextModelUploadfunction#

function nextModelUpload(): integer, string

Drains one pending model upload for the native renderer.

Returns

TypeDescription
integer

The model ID and geometry packet, or zero and an empty string.

string

nextWindowCommandfunction#

function nextWindowCommand(exclusive session: Session): string?, integer?, string?, number?, number?, boolean?

Returns and consumes the next pending window command.

The result is a scalar tagged tuple for the managed embedding ABI. text carries a title or cursor mode, x and y carry size or position, and flag carries a boolean setter. Fields unused by a kind are nil.

Arguments

NameTypeDescription
exclusive sessionSession

Returns

TypeDescription
string?
integer?
string?
number?
number?
boolean?

renderPacketfunction#

function renderPacket(exclusive session: Session, residentRevision: integer?): string

Extracts the current renderable world into one versioned byte packet.

The viewport is the window's physical drawable size rather than its logical size, because the camera projects into target pixels and the swapchain the packet is drawn into is that size on every display.

Arguments

NameTypeDescription
exclusive sessionSession
residentRevisioninteger?

The host's resident instance generation, or nil for an independent full snapshot.

Returns

TypeDescription
string

the packet consumed by the Rust renderer after a completed frame

setSuspendedfunction#

function setSuspended(exclusive session: Session, suspended: boolean): nil

Changes whether host turns advance simulation.

Arguments

NameTypeDescription
exclusive sessionSession
suspendedboolean

Returns

TypeDescription
nil

shutdownfunction#

function shutdown(exclusive session: Session): boolean

Runs application shutdown once.

Arguments

NameTypeDescription
exclusive sessionSession

Returns

TypeDescription
boolean

windowCommandFailedfunction#

function windowCommandFailed(exclusive session: Session, serial: integer, reason: string): nil

Reports one rejected command to the game-facing window.

Arguments

NameTypeDescription
exclusive sessionSession
serialinteger
reasonstring

Returns

TypeDescription
nil

Values#

INPUT_ADDRESSvariable#

const INPUT_ADDRESS: integer

The address every input route delivers at. The host drives one window.