Skip to content

SWU Simulator SDKTypeScript client for the simulator engine

Namespaced HTTP resources, ergonomic match sessions, generated protocol types, and runtime validation from the Rust server contract.

Quick Start

bash
pnpm add @my-swu/simulator-client
ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Use card ids; see /guide/card-ids for what each number means. const
premierHostDeck
= {
leader
: 46102, // Leia Organa - Someone Who Loves You
base
: 308, // Echo Base
cards
:
Array
.
from
({
length
: 50 }, () => 45), // Alliance X-Wing
} const
hostAccess
= await
simulatorClient
.
matches
.
create
({
// Fixed seed keeps this quick start reproducible.
seed
: 7,
format
: 'premier',
hostDeck
:
premierHostDeck
,
}) // Session state keeps private access out of renderable state. const
matchSession
=
simulatorClient
.
session
.
create
(
hostAccess
)
await
matchSession
.
connect
()
matchSession
.
on
('snapshot',
matchSnapshot
=> {
// Snapshots are the UI source of truth.
console
.
log
('prompt:',
matchSnapshot
.
prompt
)
})
matchSession
.
ready
()

Next steps:

Released under the MIT License.