Browser; server clients
Who is playing
@silicon-jungle/inkwell-sdk/presenceRead current player counts, public participant profiles and the viewer’s friends playing this game.
Exact source · npm package · Reference version 0.0.8
API at a glance
presence.get(): Promise<Presence>get(): Promise<Presence>normalisePresence(value): Presencecontext.presence.get(): Promise<BackendPresence>createServerPresence(request)
The result contains total, guestCount, players and friends. It is a snapshot, not a subscription or matchmaking service; it can change immediately.
Treat playerId as an opaque routing identity, never an authentication credential or global account ID. This is not access to the viewer’s whole contact list.
Outside the host frame or after a five-second timeout, returns an empty snapshot.
The backend reads its current game’s live room, not backend connection count. It returns total, guestCount and up to 50 public profiles, with no viewer-specific friends. Unavailable or malformed upstream data fails instead of claiming zero players. Browser friends are capped at 10.
All exported symbols
BackendPresencePresencePresentFriendPresentPlayercreateServerPresencegetnormalisePresencepresence
Exact TypeScript API
Generated from the SDK source, including input options, return values, public types and overloads. Relative imports below are links between SDK source modules, not additional package subpaths. Only the entrypoints listed in the reference index are supported import paths.
import type { GameServiceRequest } from './game-services.js';
export type PresentPlayer = {
playerId: string;
username: string | null;
displayName: string;
avatarUrl: string | null;
isGuest: boolean;
};
export type PresentFriend = {
username: string;
displayName: string | null;
avatarUrl: string | null;
};
export type Presence = {
total: number;
guestCount: number;
players: PresentPlayer[];
/** Signed-in friends of the current player who are in this game. */
friends: PresentFriend[];
};
export declare function normalisePresence(value: unknown): Presence;
/** Returns a current game-presence snapshot, capped at 50 safe player profiles. */
export declare function get(): Promise<Presence>;
export declare const presence: Readonly<{
get: typeof get;
}>;
/** Current game's online roster; no viewer-specific friends or account credentials. */
export type BackendPresence = Pick<Presence, 'total' | 'guestCount' | 'players'>;
export declare function createServerPresence(request: GameServiceRequest): Readonly<{
get: () => Promise<BackendPresence>;
}>;
Supporting internal type declarations
These clarify types referenced by the generated signatures; do not import these internal paths directly.
game-services.d.ts
export declare class GameServiceError extends Error {
readonly status: number;
readonly code: string;
constructor(message: string, status?: number, code?: string);
}
export type GameServiceRequest = <T>(service: string, request: Record<string, unknown>) => Promise<T>;
export declare const requestGameService: GameServiceRequest;
/** Server-only adapter. Credentials must never be bundled into browser games. */
export declare function createGameServiceRequest(options: {
baseUrl: string;
token: string;
fetch?: typeof fetch;
}): GameServiceRequest;
protocol.d.ts
export declare const SDK_SOURCE: "inkwell-sdk";
export declare const SDK_VERSION: 1;
export type InkwellMessageType = "ready" | "loading.progress" | "loading.error" | "session.complete" | "analytics.track" | "assets.progress" | "player.get" | "presence.get" | "performance.sample" | "backend.connect" | "backend.fetch";
export type InkwellMessage = {
source: typeof SDK_SOURCE;
version: typeof SDK_VERSION;
type: InkwellMessageType;
payload?: Record<string, unknown>;
sentAt: number;
};
export declare function parentOrigin(): string | null;
export declare function requestId(): string;
export declare function emit(type: InkwellMessageType, payload?: Record<string, unknown>): boolean;