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
| Type | Kind | Description |
|---|---|---|
CloseInput | record | A close request the host pushed on tecs.input.close. |
FocusInput | record | A focus transition the host pushed on tecs.input.focus. |
KeyInput | record | A keyboard transition the host pushed on tecs.input.key. |
PointerButtonInput | record | A pointer button transition the host pushed on tecs.input.pointer-button. |
PointerMoveInput | record | An absolute pointer position and relative delta the host pushed on tecs.input.pointer-move. |
ResizeInput | record | A size observation the host pushed on tecs.input.resize. |
Session | record | Host-owned state rooted by one Nupp managed handle. |
TextInput | record | Committed input-method text the host pushed on tecs.input.text. |
TouchInput | record | One finger's transition or movement the host pushed on tecs.input.touch. |
WheelInput | record | Normalized wheel movement the host pushed on tecs.input.wheel. |
Functions
| Function | Kind | Description |
|---|---|---|
applyWindowState | function | Applies a complete state acknowledgement after processing commands. |
attachWindow | function | Attaches the Rust-created window with a complete initial state. |
captureResult | function | Delivers one completed frame readback to its requester. |
crashed | function | Returns the first guarded application failure, if one exists. |
create | function | Creates one blank application session for the Rust host. |
createWithPlugin | function | Creates an application session around a game-owned installation callback. |
detachWindow | function | Detaches the OS window after the host destroys it. |
init | function | Starts initialization and parks asynchronous startup work between host turns. |
iterate | function | Starts one frame or polls the frame already parked on asynchronous work. |
newSession | function | Creates a configurable session without starting the application. |
nextCapture | function | Consumes the next explicit frame capture request. |
nextModelUpload | function | Drains one pending model upload for the native renderer. |
nextWindowCommand | function | Returns and consumes the next pending window command. |
renderPacket | function | Extracts the current renderable world into one versioned byte packet. |
setSuspended | function | Changes whether host turns advance simulation. |
shutdown | function | Runs application shutdown once. |
windowCommandFailed | function | Reports one rejected command to the game-facing window. |
Values
| Value | Kind | Description |
|---|---|---|
INPUT_ADDRESS | variable | The address every input route delivers at. |
Types#
CloseInputrecord#
record CloseInput ...A close request the host pushed on tecs.input.close.
timestampfield#
timestamp: numbersequencefield#
sequence: integerFocusInputrecord#
record FocusInput ...A focus transition the host pushed on tecs.input.focus.
focusedfield#
focused: booleantimestampfield#
timestamp: numbersequencefield#
sequence: integerKeyInputrecord#
record KeyInput ...A keyboard transition the host pushed on tecs.input.key.
Members
| Name | Kind | Description |
|---|---|---|
down | field | |
physicalKey | field | |
logicalKey | field | |
text | field | |
modifiers | field | |
repeated | field | |
timestamp | field | |
sequence | field |
downfield#
down: booleanphysicalKeyfield#
physicalKey: stringlogicalKeyfield#
logicalKey: string?modifiersfield#
modifiers: integerrepeatedfield#
repeated: booleantimestampfield#
timestamp: numbersequencefield#
sequence: integerPointerButtonInputrecord#
record PointerButtonInput ...A pointer button transition the host pushed on tecs.input.pointer-button.
downfield#
down: booleanbuttonfield#
button: integerxfield#
x: numberyfield#
y: numbertimestampfield#
timestamp: numbersequencefield#
sequence: integerPointerMoveInputrecord#
record PointerMoveInput ...An absolute pointer position and relative delta the host pushed on tecs.input.pointer-move.
xfield#
x: numberyfield#
y: numberdxfield#
dx: numberdyfield#
dy: numbertimestampfield#
timestamp: numbersequencefield#
sequence: integerResizeInputrecord#
record ResizeInput ...A size observation the host pushed on tecs.input.resize.
Members
| Name | Kind | Description |
|---|---|---|
scaleChanged | field | Read-only. |
width | field | |
height | field | |
pixelWidth | field | |
pixelHeight | field | |
scaleFactor | field | |
timestamp | field | |
sequence | field |
scaleChangedfield#
scaleChanged: booleanRead-only. Reports whether the scale factor changed rather than only the size.
widthfield#
width: integerheightfield#
height: integerpixelWidthfield#
pixelWidth: integerpixelHeightfield#
pixelHeight: integerscaleFactorfield#
scaleFactor: numbertimestampfield#
timestamp: numbersequencefield#
sequence: integerSessionrecord#
record Session ...Host-owned state rooted by one Nupp managed handle.
Members
| Name | Kind | Description |
|---|---|---|
app | field | |
input | field | Engine-owned. |
hosted | field | |
routes | field | |
events | field | |
commands | field | |
commandIndex | field | |
pump | field | |
extractor | field | |
views | field |
appfield#
app: application.Applicationinputfield#
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.
TextInputrecord#
record TextInput ...Committed input-method text the host pushed on tecs.input.text.
timestampfield#
timestamp: numbersequencefield#
sequence: integerTouchInputrecord#
record TouchInput ...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
| Name | Kind | Description |
|---|---|---|
phase | field | Read-only. |
touchDevice | field | |
finger | field | |
x | field | |
y | field | |
normalX | field | |
normalY | field | |
pressure | field | |
dx | field | |
dy | field | |
timestamp | field | |
sequence | field |
phasefield#
phase: stringRead-only. Names one of fingerDown, fingerMotion, fingerUp or fingerCanceled.
touchDevicefield#
touchDevice: stringfingerfield#
finger: stringxfield#
x: numberyfield#
y: numbernormalXfield#
normalX: numbernormalYfield#
normalY: numberpressurefield#
pressure: numberdxfield#
dx: numberdyfield#
dy: numbertimestampfield#
timestamp: numbersequencefield#
sequence: integerWheelInputrecord#
record WheelInput ...Normalized wheel movement the host pushed on tecs.input.wheel.
Members
| Name | Kind | Description |
|---|---|---|
wheelX | field | |
wheelY | field | |
ticksX | field | |
ticksY | field | |
x | field | |
y | field | |
timestamp | field | |
sequence | field |
wheelXfield#
wheelX: numberwheelYfield#
wheelY: numberticksXfield#
ticksX: integerticksYfield#
ticksY: integerxfield#
x: numberyfield#
y: numbertimestampfield#
timestamp: numbersequencefield#
sequence: integerFunctions#
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): nilApplies a complete state acknowledgement after processing commands.
Arguments
| Name | Type | Description |
|---|---|---|
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 |
Returns
| Type | Description |
|---|---|
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): nilAttaches the Rust-created window with a complete initial state.
Arguments
| Name | Type | Description |
|---|---|---|
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 |
Returns
| Type | Description |
|---|---|
nil |
captureResultfunction#
function captureResult(exclusive session: Session, id: integer, width: integer, height: integer, rgba: string, png: string, reason: string?): nilDelivers one completed frame readback to its requester.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session | |
id | integer | |
width | integer | |
height | integer | |
rgba | string | |
png | string | |
reason | string? |
Returns
| Type | Description |
|---|---|
nil |
crashedfunction#
function crashed(borrows session: Session): string?Returns the first guarded application failure, if one exists.
Arguments
| Name | Type | Description |
|---|---|---|
borrows session | Session |
Returns
| Type | Description |
|---|---|
string? |
createfunction#
function create(title: string?, width: integer?, height: integer?, debug: boolean?, maxFrames: integer?): SessionCreates one blank application session for the Rust host.
Arguments
| Name | Type | Description |
|---|---|---|
title | string? | the desktop title, defaulting to |
width | integer? | the positive initial logical width, defaulting to 1280 |
height | integer? | the positive initial logical height, defaulting to 720 |
debug | boolean? | whether guarded application failures may be cleared |
maxFrames | integer? | an optional positive frame limit for host smoke runs |
Returns
| Type | Description |
|---|---|
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?): SessionCreates 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
| Name | Type | Description |
|---|---|---|
plugin | application.Plugin | the game installation callback |
title | string? | the desktop title, defaulting to |
width | integer? | the positive initial logical width, defaulting to 1280 |
height | integer? | the positive initial logical height, defaulting to 720 |
debug | boolean? | whether guarded application failures may be cleared |
maxFrames | integer? | an optional positive frame limit for host smoke runs |
Returns
| Type | Description |
|---|---|
Session | the session the embedding host keeps as a managed handle |
detachWindowfunction#
function detachWindow(exclusive session: Session): nilDetaches the OS window after the host destroys it.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session |
Returns
| Type | Description |
|---|---|
nil |
initfunction#
function init(exclusive session: Session): booleanStarts initialization and parks asynchronous startup work between host turns.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session | the application session to initialize. |
Returns
| Type | Description |
|---|---|
boolean | true while the host may continue driving startup or diagnostics. |
iteratefunction#
function iterate(exclusive session: Session, dt: number): hostpump.StateStarts one frame or polls the frame already parked on asynchronous work.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session | |
dt | number |
Returns
| Type | Description |
|---|---|
hostpump.State |
|
newSessionfunction#
function newSession(config: application.Config?): SessionCreates 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
| Name | Type | Description |
|---|---|---|
config | application.Config? | the application settings, including world timing and optional MCP port. |
Returns
| Type | Description |
|---|---|
Session | the session a component's constructor gives the Rust host. |
Raises
| Type | Condition |
|---|---|
string | when application configuration is invalid. |
nextCapturefunction#
function nextCapture(exclusive session: Session): integerConsumes the next explicit frame capture request.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session |
Returns
| Type | Description |
|---|---|
integer |
nextModelUploadfunction#
function nextModelUpload(): integer, stringDrains one pending model upload for the native renderer.
Returns
| Type | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
exclusive session | Session |
Returns
| Type | Description |
|---|---|
string? | |
integer? | |
string? | |
number? | |
number? | |
boolean? |
renderPacketfunction#
function renderPacket(exclusive session: Session, residentRevision: integer?): stringExtracts 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
| Name | Type | Description |
|---|---|---|
exclusive session | Session | |
residentRevision | integer? | The host's resident instance generation, or nil for an independent full snapshot. |
Returns
| Type | Description |
|---|---|
string | the packet consumed by the Rust renderer after a completed frame |
setSuspendedfunction#
function setSuspended(exclusive session: Session, suspended: boolean): nilChanges whether host turns advance simulation.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session | |
suspended | boolean |
Returns
| Type | Description |
|---|---|
nil |
shutdownfunction#
function shutdown(exclusive session: Session): booleanRuns application shutdown once.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session |
Returns
| Type | Description |
|---|---|
boolean |
windowCommandFailedfunction#
function windowCommandFailed(exclusive session: Session, serial: integer, reason: string): nilReports one rejected command to the game-facing window.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive session | Session | |
serial | integer | |
reason | string |
Returns
| Type | Description |
|---|---|
nil |
Values#
INPUT_ADDRESSvariable#
const INPUT_ADDRESS: integerThe address every input route delivers at. The host drives one window.