Browser
Offline stats and achievements
@silicon-jungle/inkwell-sdk/offlineOpt in to host-owned cached reads and a bounded write queue for supported player game services.
Exact source · npm package · Reference version 0.0.8
API at a glance
offline.enable(): Promise<OfflineStatus>offline.disable(): Promise<OfflineStatus>offline.status(): Promise<OfflineStatus>offline.flush(): Promise<{ pending: number; failures: number }>createOffline(request?)QueuedGameWrite, CachedGameRead, OfflineStatus
This is not an offline game downloader, service worker or general database. It does not queue arbitrary backend HTTP calls, chat or leaderboards.
Handle queued results and report failures after flush. The queue is associated with the authenticated account and game on the platform origin, not an immutable game-build origin.
Server authorization and current policies are checked on replay. Do not award irreversible rewards just because a client queued an operation.
All exported symbols
CachedGameReadOfflineStatusQueuedGameWritecreateOfflineoffline
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 QueuedGameWrite = {
queued: true;
requestId: string;
};
export type CachedGameRead = {
offline?: boolean;
cachedAt?: number;
pendingWrites?: number;
};
export type OfflineStatus = {
enabled: boolean;
pending: number;
failures: {
id: string;
error: string;
at: number;
}[];
};
/** Opt-in browser save queue stored by the host, never by an untrusted game origin. */
export declare function createOffline(request?: GameServiceRequest): Readonly<{
enable: () => Promise<OfflineStatus>;
disable: () => Promise<OfflineStatus>;
status: () => Promise<OfflineStatus>;
flush: () => Promise<{
pending: number;
failures: number;
}>;
}>;
export declare const offline: Readonly<{
enable: () => Promise<OfflineStatus>;
disable: () => Promise<OfflineStatus>;
status: () => Promise<OfflineStatus>;
flush: () => Promise<{
pending: number;
failures: number;
}>;
}>;
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;