@seekprotocol/game 0.0.0-stage → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@seekprotocol/game",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "GameKit: the bridge between a minigame and the Seek app.",
5
+ "author": {
6
+ "name": "Seek Protocol",
7
+ "url": "https://www.seekprotocol.ai/en"
8
+ },
9
+ "homepage": "https://www.seekprotocol.ai/en",
10
+ "keywords": [
11
+ "seek",
12
+ "seekprotocol",
13
+ "quests",
14
+ "games"
15
+ ],
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "main": "index.js",
19
+ "types": "index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "default": "./index.js"
24
+ }
25
+ }
26
+ }
package/perf.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ export interface PerfWindow {
2
+ requestAnimationFrame?: (fn: (t: number) => void) => number;
3
+ cancelAnimationFrame?: (id: number) => void;
4
+ performance?: {
5
+ now(): number;
6
+ memory?: {
7
+ usedJSHeapSize?: number;
8
+ };
9
+ };
10
+ document?: {
11
+ hidden?: boolean;
12
+ };
13
+ }
14
+ export interface PerfSample {
15
+ fps?: number;
16
+ jank?: number;
17
+ heap_mb?: number;
18
+ }
19
+ export interface PerfSampler {
20
+ sample(): PerfSample;
21
+ sinceLoad(): number | undefined;
22
+ stop(): void;
23
+ }
24
+ export declare const JANK_FRAME_MS = 50;
25
+ export declare function createPerfSampler(win: PerfWindow): PerfSampler;
package/protocol.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ export declare const PROTOCOL: "seek-game";
2
+ export declare const PROTOCOL_VERSION: 1;
3
+ export declare const BRIDGE_VERSION = "0.1.0";
4
+ export declare const MAX_MESSAGE_BYTES: number;
5
+ export declare const STORAGE_MAX_BYTES: number;
6
+ export declare const STORAGE_KEY: RegExp;
7
+ export declare const TRACK_EVENT: RegExp;
8
+ export declare const TRACK_PROP_KEY: RegExp;
9
+ export declare const TRACK_MAX_PROPS = 8;
10
+ export declare const TRACK_MAX_STRING = 64;
11
+ export declare const MAX_TOKEN_LENGTH = 4096;
12
+ export declare const PROXY_ORIGIN = "https://api.play.seekprotocol.ai";
13
+ export declare const DEFAULT_HOST_ORIGINS: readonly string[];
14
+ export type GameRequestType = "ready" | "finish" | "storage.get" | "storage.set" | "storage.remove" | "track" | "heartbeat" | "diagnostics";
15
+ export type HostEventType = "pause" | "resume" | "exit";
16
+ export interface GameRequest {
17
+ seek: typeof PROTOCOL;
18
+ v: typeof PROTOCOL_VERSION;
19
+ id: string;
20
+ type: GameRequestType;
21
+ payload: unknown;
22
+ }
23
+ export interface HostReply {
24
+ seek: typeof PROTOCOL;
25
+ v: typeof PROTOCOL_VERSION;
26
+ re: string;
27
+ ok: boolean;
28
+ payload?: unknown;
29
+ error?: {
30
+ code: string;
31
+ message: string;
32
+ };
33
+ }
34
+ export interface HostEvent {
35
+ seek: typeof PROTOCOL;
36
+ v: typeof PROTOCOL_VERSION;
37
+ event: HostEventType;
38
+ }
39
+ export interface ReadyPayload {
40
+ token: string;
41
+ transport?: "proxy" | "host";
42
+ }
43
+ export interface LaunchInfo {
44
+ runId: string;
45
+ seed: number;
46
+ lang: string;
47
+ sub: string;
48
+ game: string;
49
+ version: string;
50
+ expiresAt: number;
51
+ }
52
+ export declare const utf8Bytes: (s: string) => number;
53
+ export declare function jsonBytes(value: unknown): number;
54
+ export declare function isJsonValue(v: unknown, depth?: number): boolean;
55
+ export declare const storageKeyProblem: (key: unknown) => string | null;
56
+ export type TrackProps = Record<string, string | number | boolean>;
57
+ export declare function trackProblem(event: unknown, props: unknown): string | null;
58
+ export declare function finishProblem(r: unknown): string | null;
59
+ export declare function parseHostMessage(data: unknown): HostReply | HostEvent | null;
60
+ export declare function parseGameRequest(data: unknown): GameRequest | null;
61
+ export declare function decodeLaunchToken(token: unknown): LaunchInfo | null;