@live-game/sdk
v0.5.0
Published
Live Game SDK for game and control iframe integrations.
Readme
@live-game/sdk
SDK for Live Game iframe apps and control panels.
Production and local integration both use the host-injected SDK. createMockSDK() is a deterministic unit-test double; it does not generate random traffic.
Version 0.5.0 adds injectable deterministic mocks and complete event types. The former ./utils subpath is removed; use the documented package entry points. The host communication protocol remains apiVersion: 1.0, and runtime capability availability is determined by the host and manifest permissions.
import { createSDK } from "@live-game/sdk";
import { useGameState, useGameConfig, sendCmd } from "@live-game/sdk/react";Common control-panel flow:
const sdk = createSDK();
const config = await sdk.config.get();
await sdk.config.update({ ...config, duration: 180 });
await sdk.command.send({ type: "next_round" });Publish game state for control panels:
await sdk.state.publish({ round: 2, status: "playing" });Deterministic test flow:
const sdk = createMockSDK({ permissions: ["events.comment", "command"] });
sdk.emit("comment", { content: "苹果" });
await sdk.command.send({ type: "start" });
expect(sdk.calls[0].method).toBe("command.send");
sdk.dispose();