@jgengine/ws 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,53 @@ Agents building on the published SDK can also read this programmatically:
11
11
  same data as typed values, so an updater can diff its installed version against
12
12
  the latest and surface the migration steps.
13
13
 
14
+ ## 0.8.0
15
+
16
+ Transport-agnostic multiplayer (socket.io, WebRTC p2p, LAN/Fly adapters) plus grid/voxel
17
+ and puzzle primitives, HUD-only presentation, cumulative leveling, and a round of
18
+ controller/camera/sensor additions. **Breaking:** the `gameui` component kit moved out of
19
+ `@jgengine/react` onto the shadcn registry.
20
+
21
+ ### Migrate
22
+
23
+ - Bump every `@jgengine/*` dependency to `^0.8.0` (the eight packages version in lockstep).
24
+ - Additive only, except for `gameui` — every other 0.7.0 API is unchanged; opt into any of the below by importing it directly.
25
+ - **Breaking:** replace any `@jgengine/react/gameui` import with the equivalent registry component (`npx shadcn@latest add https://jgengine.com/r/<name>.json`), and swap `GameUiThemeProvider` for `--jg-*` CSS variables on a wrapper element. `GameIcon` and friends moved to `@jgengine/react/gameIcons`.
26
+ - `leveling({ thresholdMode: 'cumulative' })` is opt-in; the default `perLevel` behavior is unchanged.
27
+ - `defineGame.physics.gravity`/`jumpVelocity` are now read by the built-in kinematics controller every frame — if a game already set them expecting a no-op, jump/fall now actually reflects them; omit both to keep the previous defaults.
28
+
29
+ ### Added
30
+
31
+ - Cumulative leveling — `leveling({ thresholdMode: 'cumulative' })` tracks xp as a lifetime total that resolves upward across levels and clamps at the max-level threshold once capped (#12).
32
+ - Direction-aware pool depletion — `EffectSystem.canReceive(instanceId, effect, magnitude?)` takes an optional signed magnitude; negative checks the opposite direction and returns `pools-depleted` only when every stat in the receive order is already at max, so heals reach fully-depleted targets (#168).
33
+ - Puzzle primitives — `puzzle/cellGrid` (uniform-cell boards: line-clear, match-3 cascade, run detection) and `puzzle/fallingPiece` (rotation-state shapes, ghost drop, lock delay, classic gravity/level/score curves) for Tetris/match-3 games (#166).
34
+ - Voxel field — `world/voxelField` (`createVoxelField`, chunked block lattice, neighbors/exposedFaces, 3D DDA raycast, dirty-tracked `chunkVersion`) for voxel games and instanced renderers; assert on `field.summary()` the way environment worlds assert on `summarizeEnvironment` (#166).
35
+ - `defineGame` games may omit `assets` (an empty catalog is injected); `PlayableGame.presentation: 'hud'` mounts no 3D canvas/camera/pointer for board/card/menu games; an `environment()` world auto-renders as the shell's backdrop when `PlayableGame.environment` is unset (#166).
36
+ - Declared-action intent board — `turn/intent` `createIntentBoard` for one-turn-ahead intents (Slay-the-Spire style): declare/peek/all/consume/clear (#168).
37
+ - `turnLoop` lifecycle hooks — `config.onTurnStart`/`onTurnEnd` fire on every `advanceTurn()`; `ctx.game.turn.loop(id, config)` lazily creates/returns a notify-wrapped `TurnLoop` so every mutation (`advanceTurn`/`advancePhase`/`advanceRound`/`spend`/`gain`/`refill`/`setOrder`/...) auto-bumps `ctx.version()` with no manual wiring (#163/#168).
38
+ - `ctx.game.store` — a reactive per-game keyed store (`set`/`delete`/`get`/`has`/`subscribe`/`mapSnapshot`/`arraySnapshot`) plus `@jgengine/react`'s `useGameStore` selector hook, replacing hand-rolled module-level stores for ad-hoc reactive game state; `ctx.game.cards.pile(id, config?)` lazily creates/returns a notify-wrapped `CardPile` the same way; `createCardPile` gained an `onChange` hook for headless use; `CommandDefinition.apply` may return void for side-effect-only commands (#163).
39
+ - Camera — `sideScroll` rig (fixed lateral follow for 2.5D platformers/beat-'em-ups), a `none` rig (no camera mounted; pairs with `PlayableGame.presentation: 'hud'`), `rts.pan: false` (static backdrop camera: no pan/edge-scroll/rotate/zoom, still re-centers on the follow target), and the `observer` rig now defaults to the local player when `bind` is unset (#167).
40
+ - Sensors + session — `sensor/concealment` (`colorDistance`/`concealmentScore`/`createConcealmentSensor`), `sensor/freezeMonitor` (`createFreezeMonitor`), `session/roles` (`assignRoles`); `createRoundState`'s `RoundConfig.teams` accepts per-team roles and an optional `winCondition` that `evaluate()` checks each tick, and takes an optional `phaseOrder` for arbitrary named phase cycles (`concludeRound`/`evaluate` settle only while the current phase is neither the first nor the last entry) (#151).
41
+ - Appearance replication — presence rows carry an optional per-slot appearance channel (cosmetic ids, hex tints, model keys) alongside pose, riding the existing pose message with no protocol bump; wire `ctx.player.cosmetics.get(userId)` into the outgoing pose (#151).
42
+ - `ctx.input` — a per-frame held-action snapshot (`publish(held)`/`isDown(action)`/`held()`) without bumping `ctx.version()`; action bindings gained `repeatMs` (repeat-fire while held); every command resolved from a bound action now carries `aim`; `pointer.secondaryCommand` runs a command on right-click off the same raycast as move/ping (#164).
43
+ - Object spatial queries + entity patching — `ctx.scene.object.at`/`inBox`/`raycast`/`raycastAll` over unit-box objects; `ctx.scene.entity.update(id, patch)` for name/position/rotation/role/movement/behaviors/meta; per-instance `renderObject`/`objectStyles` overrides; `pointerService.worldHitCenter()` + pointer-lock center-ray aiming (#165).
44
+ - Controller movement config — `PlayerMovementConfig` (`mode`: free/axis/grid, `axis`, `cellSize`, `collideObjects`, `beforeCommit` pre-commit hook) for the shell-driven walk controller; `defineGame.physics.gravity`/`jumpVelocity` are honored by the built-in walk controller (distinct from the standalone `physics/physicsWorld` rigid-body sim); `ctx.player.motion.impulse`/`setVerticalVelocity`/`setY`/`takePending` (`MotionIntents`); `entity.spawnPoseOf`/`resetToSpawn`/`resetAllToSpawn` (#162).
45
+ - Model material/animation + paint — `ModelConfig.tint`/`metalness`/`roughness`/`animation` (GLTF clip playback, paused pose holds); `PointerHit.uv` + `pointerService.sampleSurface()` for material-aware picking; `ctx.scene.entity.paint` runtime paint layer, auto-rendered via a per-instance canvas texture with no per-game wiring; remote-player appearance tint recolors the shell's default capsule (#151).
46
+ - **Transport pipe seam** (`@jgengine/ws/pipe`) — `createWsBackend` runs over any bidirectional string channel, not just a raw `WebSocket`: `TransportPipe`/`TransportPipeHandlers`/`TransportPipeFactory`, with `webSocketPipe(url, webSocketFactory?)` as the default. `createWsBackend({ userId, url?, pipe? })` — `url` stays the common case, `pipe` opens the seam to socket.io, WebRTC, and in-process loopback below.
47
+ - **Browser-safe authoritative host** — `createGameHost` and `memoryPersistence` moved from `@jgengine/node` to `@jgengine/ws/host` (zero Node dependencies; `@jgengine/node` re-exports both unchanged from `@jgengine/node/host` / `@jgengine/node/persistence`, so existing imports keep working). `@jgengine/ws/hostRouter`'s `createHostRouter({ host, authenticate?, poseRules?, positionHistoryMs?, chatRateLimit?, chatHistoryLimit?, chatMaxBodyLength?, now? })` extracts the ws wire-protocol session logic out of `createGameWsServer` into a transport-agnostic `HostRouter` (`connect(transport) → { handleRaw, close }`, `rewind`, `close`); `@jgengine/node`'s `createGameWsServer` is now a thin binding of this router onto the `ws` npm package, same public API. `loopbackPipe(router): TransportPipeFactory` connects a `createWsBackend` straight into an in-process router.
48
+ - **Socket.IO transport** — `@jgengine/ws/socketIoPipe` (`SocketIoLikeSocket` structural type, `socketIoPipe(socket)`, `createSocketIoBackend({ socket, userId, … })`) and `@jgengine/node/socketIoServer` (`attachGameSocketIoServer({ io, host, …router options }): { rewind, close }`, structural `SocketIoLikeServer`/`SocketIoLikeServerSocket`) ride the existing ws JSON protocol over socket.io's `send`/`message` frames — no socket.io dependency in either package's types. New `socketIo({ topology?, url? })` adapter in `@jgengine/core/runtime/adapter`.
49
+ - **WebRTC peer-to-peer** (`@jgengine/ws/peer`) — one browser tab hosts, authoritatively, with no server process. `createPeerHost({ userId, host?, runtimes?, persistence?, tickMs?, router?, rtc? })` runs a `GameHost` + `HostRouter` in the host tab (`backend` is the host player's own loopback connection, `accept(offerCode) → Promise<answerCode>` per guest); `createPeerGuest({ userId, token?, rtc? })` offers/connects from the joining side. `encodePeerSignal`/`decodePeerSignal` turn SDP into copy-pasteable base64url codes for manual cross-machine signaling; `broadcastChannelSignaling(room)` automates it for same-origin multi-tab play, with `announcePeerHost`/`joinPeerSession` wiring host/guest to a `PeerSignaling` in one call. New `p2p({ topology?, room? })` adapter (topology defaults `"private"`).
50
+ - **LAN adapter + Fly sugar** — `lan({ topology?, port?, path? })` in `@jgengine/core/runtime/adapter` resolves through `@jgengine/shell/multiplayer`'s `resolveShellMultiplayer` to `ws(s)://<page hostname>:<port ?? 8080><path ?? /ws>` derived from `window.location`, so any browser on the LAN auto-connects to whichever machine served the page — no URL configuration. `fly({ app, topology?, path? })` is `ws` sugar for a Fly.io deploy: resolves to `wss://<app>.fly.dev<path ?? "/ws">`. `apps/dev`'s Vite server now listens on the network (`server: { host: true }`) and exposes `?p2p=host` / `?p2p=join` query params wired through the new `resolvePeerShellMultiplayer({ gameId, role, room?, userId?, feedActions? })`.
51
+ - `ws()` (`@jgengine/core/runtime/adapter`) gained an optional `url` field, carried through by `resolveShellMultiplayer` (`args.url ?? adapter.url ?? default`).
52
+
53
+ ### Removed
54
+
55
+ - **The `gameui` component kit** (`@jgengine/react/gameui`) — the themed HUD kit (bars, slots, feedback, meters, panels, screens, reticles, icons) and its `GameUiThemeProvider`/`useGameUiTheme` theming have been removed. **Breaking** for anyone importing `@jgengine/react/gameui` (or its subpaths/barrel). The components now ship as installable shadcn registry items at `https://jgengine.com/r/<name>.json` (`npx shadcn@latest add https://jgengine.com/r/<name>.json`), styled with Tailwind + `--jg-*` CSS variables instead of a theme object. The icon catalog (`GameIcon`, `iconForAction`, `iconForItemId`, `isGameIconName`, `GameIconName`) moved to `@jgengine/react/gameIcons`. To theme, set the `--jg-*` variables on a wrapper element (the registry's `jg-theme` presets mirror the old `ember`/`synthwave`/`fieldkit` palettes) instead of wrapping in `GameUiThemeProvider`.
56
+
57
+ ### Docs
58
+
59
+ - Added [CREDITS.md](CREDITS.md) crediting [achrefelouafi](https://github.com/achrefelouafi) for the MIT Three.js reference projects behind the procedural building, water, rain, and snow renderers, with links from the root, `@jgengine/core`, and `@jgengine/shell` READMEs.
60
+
14
61
  ## 0.7.0
15
62
 
16
63
  The engine-gaps release — 22 system-level additions across turn/tactics, cards & boards,
@@ -2,9 +2,13 @@ import { type PoseSyncTuning } from "@jgengine/core/multiplayer/poseSyncGate";
2
2
  import type { GameBackend, JoinServerResult } from "@jgengine/core/runtime/transport";
3
3
  import type { SessionAttributes } from "@jgengine/core/runtime/hostPersistence";
4
4
  import type { MatchFilter, SessionListing } from "@jgengine/core/multiplayer/matchmaking";
5
- import { type WsPose, type WsPresenceRow } from "./protocol.js";
5
+ import type { ChatSendOutcome, ChatSync } from "@jgengine/core/multiplayer/chatContract";
6
+ import type { VoiceTransport } from "@jgengine/core/multiplayer/voiceContract";
7
+ import { type WsChatMessage, type WsPose, type WsPresenceRow, type WsVoiceParticipant } from "./protocol.js";
8
+ import { type TransportPipeFactory } from "./pipe.js";
6
9
  export type WsBackendOptions = {
7
- url: string;
10
+ url?: string;
11
+ pipe?: TransportPipeFactory;
8
12
  userId: string;
9
13
  token?: string;
10
14
  webSocketFactory?: (url: string) => WebSocket;
@@ -14,8 +18,19 @@ export type WsBackendOptions = {
14
18
  };
15
19
  export type WsPresenceSync = {
16
20
  subscribe: (serverId: string, onChange: (rows: WsPresenceRow[]) => void) => () => void;
21
+ /** `pose.appearance`, when provided, is forwarded to the host as-is and surfaces on every subscriber's presence row for that user. */
17
22
  syncPose: (serverId: string, pose: WsPose) => void;
18
23
  };
24
+ export type WsChatSync = {
25
+ subscribe: (serverId: string, channelId: string, onChange: (messages: WsChatMessage[]) => void) => () => void;
26
+ send: (serverId: string, channelId: string, body: string) => Promise<ChatSendOutcome>;
27
+ };
28
+ export type WsVoiceSync = {
29
+ subscribe: (serverId: string, channelId: string, onChange: (participants: WsVoiceParticipant[]) => void) => () => void;
30
+ join: (serverId: string, channelId: string, streamId?: string) => Promise<void>;
31
+ leave: (serverId: string, channelId: string) => Promise<void>;
32
+ publish: (serverId: string, channelId: string, streamId: string) => Promise<void>;
33
+ };
19
34
  export type WsBackend = GameBackend & {
20
35
  pushFeedEntry: (args: {
21
36
  serverId: string;
@@ -36,6 +51,10 @@ export type WsBackend = GameBackend & {
36
51
  attributes?: SessionAttributes;
37
52
  }) => Promise<JoinServerResult>;
38
53
  presenceSync: WsPresenceSync;
54
+ chatSync: WsChatSync;
55
+ chatSyncFor: (serverId: string) => ChatSync;
56
+ voiceSync: WsVoiceSync;
57
+ voiceTransportFor: (serverId: string) => VoiceTransport;
39
58
  close: () => void;
40
59
  };
41
60
  export declare function createWsBackend(options: WsBackendOptions): WsBackend;
@@ -1,6 +1,6 @@
1
1
  import { createPoseSyncGate } from "@jgengine/core/multiplayer/poseSyncGate";
2
2
  import { decodeWsServerMessage, encodeWsMessage, subscriptionKey, } from "./protocol.js";
3
- const WS_READY_STATE_OPEN = 1;
3
+ import { webSocketPipe } from "./pipe.js";
4
4
  const DEFAULT_POSE_TUNING = {
5
5
  minIntervalMs: 100,
6
6
  heartbeatMs: 5_000,
@@ -11,8 +11,15 @@ const DEFAULT_POSE_TUNING = {
11
11
  export function createWsBackend(options) {
12
12
  const now = options.now ?? Date.now;
13
13
  const reconnectDelayMs = options.reconnectDelayMs ?? 1_000;
14
- const webSocketFactory = options.webSocketFactory ?? ((url) => new WebSocket(url));
15
- let socket = null;
14
+ const pipeFactory = options.pipe ??
15
+ (() => {
16
+ const url = options.url;
17
+ if (url === undefined)
18
+ throw new Error("WsBackendOptions requires url or pipe");
19
+ return webSocketPipe(url, options.webSocketFactory);
20
+ })();
21
+ let pipe = null;
22
+ let open = false;
16
23
  let ready = null;
17
24
  let closed = false;
18
25
  let nextId = 1;
@@ -25,12 +32,12 @@ export function createWsBackend(options) {
25
32
  pending.clear();
26
33
  };
27
34
  const rawSend = (message) => {
28
- if (socket === null || socket.readyState !== WS_READY_STATE_OPEN)
35
+ if (pipe === null || !open)
29
36
  return;
30
- socket.send(encodeWsMessage(message));
37
+ pipe.send(encodeWsMessage(message));
31
38
  };
32
39
  const handleMessage = (raw) => {
33
- const message = decodeWsServerMessage(typeof raw === "string" ? raw : String(raw));
40
+ const message = decodeWsServerMessage(raw);
34
41
  if (message === null)
35
42
  return;
36
43
  if (message.t === "reply") {
@@ -46,7 +53,9 @@ export function createWsBackend(options) {
46
53
  }
47
54
  return;
48
55
  }
49
- const key = subscriptionKey(message.channel, message.serverId, message.channel === "feed" ? message.action : undefined);
56
+ const key = subscriptionKey(message.channel, message.serverId, message.channel === "feed" || message.channel === "chat" || message.channel === "voice"
57
+ ? message.action
58
+ : undefined);
50
59
  const subscription = subscriptions.get(key);
51
60
  if (subscription === undefined)
52
61
  return;
@@ -62,41 +71,43 @@ export function createWsBackend(options) {
62
71
  if (ready !== null)
63
72
  return ready;
64
73
  ready = new Promise((resolve, reject) => {
65
- const nextSocket = webSocketFactory(options.url);
66
- socket = nextSocket;
67
- nextSocket.onopen = () => {
68
- const id = nextId++;
69
- pending.set(id, {
70
- resolve: () => {
71
- for (const subscription of subscriptions.values()) {
72
- rawSend({
73
- v: 1,
74
- t: "subscribe",
75
- id: nextId++,
76
- channel: subscription.channel,
77
- serverId: subscription.serverId,
78
- action: subscription.action,
79
- });
80
- }
81
- resolve();
82
- },
83
- reject,
84
- });
85
- nextSocket.send(encodeWsMessage({ v: 1, t: "hello", id, userId: options.userId, token: options.token }));
86
- };
87
- nextSocket.onmessage = (event) => handleMessage(event.data);
88
- nextSocket.onclose = () => {
89
- failPending("Connection closed");
90
- socket = null;
91
- ready = null;
92
- reject(new Error("Connection closed"));
93
- if (!closed && subscriptions.size > 0) {
94
- setTimeout(() => {
95
- if (!closed)
96
- void connect().catch(() => undefined);
97
- }, reconnectDelayMs);
98
- }
99
- };
74
+ pipe = pipeFactory({
75
+ onOpen: () => {
76
+ open = true;
77
+ const id = nextId++;
78
+ pending.set(id, {
79
+ resolve: () => {
80
+ for (const subscription of subscriptions.values()) {
81
+ rawSend({
82
+ v: 1,
83
+ t: "subscribe",
84
+ id: nextId++,
85
+ channel: subscription.channel,
86
+ serverId: subscription.serverId,
87
+ action: subscription.action,
88
+ });
89
+ }
90
+ resolve();
91
+ },
92
+ reject,
93
+ });
94
+ rawSend({ v: 1, t: "hello", id, userId: options.userId, token: options.token });
95
+ },
96
+ onMessage: handleMessage,
97
+ onClose: () => {
98
+ open = false;
99
+ failPending("Connection closed");
100
+ pipe = null;
101
+ ready = null;
102
+ reject(new Error("Connection closed"));
103
+ if (!closed && subscriptions.size > 0) {
104
+ setTimeout(() => {
105
+ if (!closed)
106
+ void connect().catch(() => undefined);
107
+ }, reconnectDelayMs);
108
+ }
109
+ },
110
+ });
100
111
  });
101
112
  return ready;
102
113
  };
@@ -120,6 +131,7 @@ export function createWsBackend(options) {
120
131
  return result;
121
132
  },
122
133
  async leaveServer(args) {
134
+ poseGates.delete(args.serverId);
123
135
  await request((id) => ({ v: 1, t: "leave", id, serverId: args.serverId }));
124
136
  },
125
137
  async runCommand(args) {
@@ -191,10 +203,50 @@ export function createWsBackend(options) {
191
203
  .catch(() => undefined);
192
204
  },
193
205
  };
206
+ const chatSync = {
207
+ subscribe(serverId, channelId, onChange) {
208
+ return addSubscription("chat", serverId, channelId, (data) => onChange(data));
209
+ },
210
+ async send(serverId, channelId, body) {
211
+ try {
212
+ await request((id) => ({ v: 1, t: "chatSend", id, serverId, channelId, body }));
213
+ return { ok: true };
214
+ }
215
+ catch (error) {
216
+ return { ok: false, reason: error instanceof Error ? error.message : "Transport error" };
217
+ }
218
+ },
219
+ };
220
+ const voiceSync = {
221
+ subscribe(serverId, channelId, onChange) {
222
+ return addSubscription("voice", serverId, channelId, (data) => onChange(data));
223
+ },
224
+ async join(serverId, channelId, streamId) {
225
+ await request((id) => ({ v: 1, t: "voiceJoin", id, serverId, channelId, streamId }));
226
+ },
227
+ async leave(serverId, channelId) {
228
+ await request((id) => ({ v: 1, t: "voiceLeave", id, serverId, channelId }));
229
+ },
230
+ async publish(serverId, channelId, streamId) {
231
+ await request((id) => ({ v: 1, t: "voicePublish", id, serverId, channelId, streamId }));
232
+ },
233
+ };
194
234
  return {
195
235
  transport,
196
236
  feeds,
197
237
  presenceSync,
238
+ chatSync,
239
+ chatSyncFor: (serverId) => ({
240
+ subscribe: (channelId, onChange) => chatSync.subscribe(serverId, channelId, onChange),
241
+ send: (channelId, body) => chatSync.send(serverId, channelId, body),
242
+ }),
243
+ voiceSync,
244
+ voiceTransportFor: (serverId) => ({
245
+ join: (channelId, streamId) => voiceSync.join(serverId, channelId, streamId),
246
+ leave: (channelId) => voiceSync.leave(serverId, channelId),
247
+ publish: (channelId, streamId) => voiceSync.publish(serverId, channelId, streamId),
248
+ subscribers: (channelId, onChange) => voiceSync.subscribe(serverId, channelId, onChange),
249
+ }),
198
250
  async pushFeedEntry(args) {
199
251
  await request((id) => ({
200
252
  v: 1,
@@ -239,8 +291,9 @@ export function createWsBackend(options) {
239
291
  close: () => {
240
292
  closed = true;
241
293
  failPending("Backend closed");
242
- socket?.close();
243
- socket = null;
294
+ pipe?.close();
295
+ pipe = null;
296
+ open = false;
244
297
  ready = null;
245
298
  },
246
299
  };
package/dist/host.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import type { GameRuntime } from "@jgengine/core/runtime/gameRuntime";
2
+ import type { HostPersistence, ServerListing, SessionAttributes } from "@jgengine/core/runtime/hostPersistence";
3
+ import type { MatchFilter, SessionListing } from "@jgengine/core/multiplayer/matchmaking";
4
+ import type { GameRuntimePlayerView, GameRuntimeServerView, JoinServerResult, TransportRunCommandResult } from "@jgengine/core/runtime/transport";
5
+ export type HostChangeEvent = {
6
+ type: "server";
7
+ serverId: string;
8
+ } | {
9
+ type: "player";
10
+ serverId: string;
11
+ userId: string;
12
+ } | {
13
+ type: "feed";
14
+ serverId: string;
15
+ action: string;
16
+ };
17
+ export type GameHostOptions = {
18
+ runtimes?: GameRuntime[];
19
+ persistence: HostPersistence;
20
+ tickMs?: number;
21
+ slotsPerServer?: number;
22
+ now?: () => number;
23
+ createServerId?: () => string;
24
+ };
25
+ export type GameHost = {
26
+ joinServer: (args: {
27
+ userId: string;
28
+ gameId: string;
29
+ serverId?: string;
30
+ attributes?: SessionAttributes;
31
+ }) => Promise<JoinServerResult>;
32
+ browseServers: (args: {
33
+ gameId: string;
34
+ filter?: MatchFilter;
35
+ limit?: number;
36
+ }) => Promise<SessionListing[]>;
37
+ joinByCode: (args: {
38
+ userId: string;
39
+ gameId: string;
40
+ code: string;
41
+ }) => Promise<JoinServerResult | null>;
42
+ leaveServer: (args: {
43
+ userId: string;
44
+ serverId: string;
45
+ }) => Promise<void>;
46
+ runCommand: (args: {
47
+ userId: string;
48
+ serverId: string;
49
+ command: string;
50
+ input: unknown;
51
+ }) => Promise<TransportRunCommandResult>;
52
+ getServerView: (args: {
53
+ userId: string;
54
+ serverId: string;
55
+ }) => Promise<GameRuntimeServerView | null>;
56
+ getPlayerView: (args: {
57
+ userId: string;
58
+ serverId: string;
59
+ }) => Promise<GameRuntimePlayerView | null>;
60
+ getFeed: (args: {
61
+ userId: string;
62
+ serverId: string;
63
+ action: string;
64
+ }) => Promise<unknown[]>;
65
+ pushFeedEntry: (args: {
66
+ userId: string;
67
+ serverId: string;
68
+ action: string;
69
+ entry: unknown;
70
+ }) => Promise<void>;
71
+ listOpenServers: (args: {
72
+ gameId: string;
73
+ limit?: number;
74
+ }) => Promise<ServerListing[]>;
75
+ tickOnce: () => Promise<{
76
+ ticked: number;
77
+ saved: number;
78
+ }>;
79
+ flushAll: () => Promise<number>;
80
+ start: () => void;
81
+ stop: () => Promise<void>;
82
+ subscribe: (listener: (event: HostChangeEvent) => void) => () => void;
83
+ };
84
+ export declare function createGameHost(options: GameHostOptions): GameHost;
85
+ export declare function memoryPersistence(now?: () => number): HostPersistence;