@ksaa-nlp/gamehub-sdk 0.9.0 → 3.5.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/README.md +154 -374
- package/SPEC.md +865 -0
- package/dist/gamehub-sdk.js +164 -1191
- package/dist/gamehub-sdk.js.map +3 -3
- package/dist/src/api-client.d.ts +15 -5
- package/dist/src/api-client.d.ts.map +1 -1
- package/dist/src/api-client.js +21 -5
- package/dist/src/api-client.js.map +1 -1
- package/dist/src/bridge.d.ts +31 -14
- package/dist/src/bridge.d.ts.map +1 -1
- package/dist/src/bridge.js +148 -159
- package/dist/src/bridge.js.map +1 -1
- package/dist/src/constants.d.ts +8 -6
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +8 -6
- package/dist/src/constants.js.map +1 -1
- package/dist/src/init.d.ts +18 -12
- package/dist/src/init.d.ts.map +1 -1
- package/dist/src/init.js +23 -156
- package/dist/src/init.js.map +1 -1
- package/dist/src/main.d.ts +45 -85
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +27 -52
- package/dist/src/main.js.map +1 -1
- package/dist/src/match-context.d.ts.map +1 -1
- package/dist/src/match-context.js +0 -14
- package/dist/src/match-context.js.map +1 -1
- package/dist/src/server-dev-harness.d.ts +85 -0
- package/dist/src/server-dev-harness.d.ts.map +1 -0
- package/dist/src/server-dev-harness.js +233 -0
- package/dist/src/server-dev-harness.js.map +1 -0
- package/dist/src/server-entry.d.ts +127 -0
- package/dist/src/server-entry.d.ts.map +1 -0
- package/dist/src/server-entry.js +26 -0
- package/dist/src/server-entry.js.map +1 -0
- package/dist/src/session.d.ts +16 -9
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/session.js +38 -27
- package/dist/src/session.js.map +1 -1
- package/dist/src/state.d.ts +17 -55
- package/dist/src/state.d.ts.map +1 -1
- package/dist/src/state.js +13 -32
- package/dist/src/state.js.map +1 -1
- package/dist/src/utils.d.ts +3 -14
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +3 -31
- package/dist/src/utils.js.map +1 -1
- package/dist/types/bootstrap.d.ts +56 -36
- package/dist/types/bootstrap.d.ts.map +1 -1
- package/dist/types/question.d.ts +36 -0
- package/dist/types/question.d.ts.map +1 -0
- package/dist/types/question.js +21 -0
- package/dist/types/question.js.map +1 -0
- package/dist/types/session.d.ts +23 -20
- package/dist/types/session.d.ts.map +1 -1
- package/package.json +14 -4
- package/CHANGELOG.md +0 -545
- package/MIGRATION.md +0 -322
- package/dist/src/multiplayer-match.d.ts +0 -42
- package/dist/src/multiplayer-match.d.ts.map +0 -1
- package/dist/src/multiplayer-match.js +0 -551
- package/dist/src/multiplayer-match.js.map +0 -1
- package/dist/src/multiplayer.d.ts +0 -96
- package/dist/src/multiplayer.d.ts.map +0 -1
- package/dist/src/multiplayer.js +0 -536
- package/dist/src/multiplayer.js.map +0 -1
- package/dist/types/multiplayer-match.d.ts +0 -204
- package/dist/types/multiplayer-match.d.ts.map +0 -1
- package/dist/types/multiplayer-match.js +0 -15
- package/dist/types/multiplayer-match.js.map +0 -1
- package/dist/types/multiplayer.d.ts +0 -194
- package/dist/types/multiplayer.d.ts.map +0 -1
- package/dist/types/multiplayer.js +0 -2
- package/dist/types/multiplayer.js.map +0 -1
package/dist/types/session.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { MatchResultPayload } from './match.js';
|
|
2
1
|
/**
|
|
3
2
|
* Optional metadata attached to a score submission.
|
|
4
3
|
*/
|
|
5
4
|
export interface ScoreMetadata {
|
|
6
|
-
matchResult?: MatchResultPayload;
|
|
7
5
|
level?: number;
|
|
8
6
|
duration?: number;
|
|
9
7
|
custom?: Record<string, any>;
|
|
@@ -22,40 +20,45 @@ export interface EventData {
|
|
|
22
20
|
value?: number;
|
|
23
21
|
properties?: Record<string, any>;
|
|
24
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Payload passed to `sdk.reportQuestion`. Identifies the question the player
|
|
25
|
+
* wants to flag; the host renders the report dialog and collects the reason,
|
|
26
|
+
* optional message, and (for guests) name/email before submitting.
|
|
27
|
+
*/
|
|
28
|
+
export interface ReportQuestionData {
|
|
29
|
+
/** The `id` of the question to report (as returned by `getQuestions`). */
|
|
30
|
+
questionId: string;
|
|
31
|
+
/** Optional prompt snapshot so the host dialog can show what's being reported. */
|
|
32
|
+
prompt?: string;
|
|
33
|
+
/** Optional message to pre-fill in the dialog. */
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
25
36
|
/** Options accepted by `sdk.getQuestions`. */
|
|
26
37
|
export interface QuestionOptions {
|
|
27
38
|
difficulty?: 'easy' | 'medium' | 'hard' | string;
|
|
28
39
|
category?: string | number;
|
|
29
40
|
limit?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Selects a game **profile** (its subdoc `_id`) on the gamehub side — the
|
|
43
|
+
* resolver returns the union of that profile's private/bank/fixed parts. An
|
|
44
|
+
* unknown/omitted value falls back to the game's `isDefault` profile, so the
|
|
45
|
+
* default behaviour is identical to today. Usually sourced from the SDK
|
|
46
|
+
* bootstrap payload (the player's pre-start picker choice).
|
|
47
|
+
*/
|
|
48
|
+
profileId?: string;
|
|
30
49
|
}
|
|
31
|
-
|
|
32
|
-
export interface Question {
|
|
33
|
-
id: string;
|
|
34
|
-
difficulty?: 'easy' | 'medium' | 'hard' | string;
|
|
35
|
-
category?: string;
|
|
36
|
-
prompt: string;
|
|
37
|
-
choices: string[];
|
|
38
|
-
answer: string | number;
|
|
39
|
-
explanation?: string;
|
|
40
|
-
points: number;
|
|
41
|
-
}
|
|
50
|
+
export type { Question, QuestionDifficulty } from './question.js';
|
|
42
51
|
/** Result returned by `startSession`. */
|
|
43
52
|
export interface StartSessionResult {
|
|
44
53
|
success: boolean;
|
|
45
54
|
token?: string | null;
|
|
46
55
|
error?: string;
|
|
47
56
|
}
|
|
48
|
-
/** Result returned by `submitScore
|
|
57
|
+
/** Result returned by `submitScore`. */
|
|
49
58
|
export interface SubmitScoreResult {
|
|
50
59
|
success: boolean;
|
|
51
60
|
accepted?: boolean;
|
|
52
61
|
timeTaken?: number;
|
|
53
62
|
error?: string;
|
|
54
|
-
/**
|
|
55
|
-
* `true` when the SDK intentionally skipped the network call (e.g. the
|
|
56
|
-
* current peer is not the host in an online match, or is a view-only
|
|
57
|
-
* guest). Treat this as "not-an-error" — the host will submit instead.
|
|
58
|
-
*/
|
|
59
|
-
skipped?: boolean;
|
|
60
63
|
}
|
|
61
64
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../types/session.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../types/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,uCAAuC;AACvC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElE,yCAAyC;AACzC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ksaa-nlp/gamehub-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "ESM SDK that lets GameHub-hosted games talk to the platform (auth, sessions, scores,
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "ESM SDK that lets GameHub-hosted games talk to the platform (auth, sessions, scores, bootstrap pipeline). Includes types and a Node-only dev harness for authoring UGC server bundles (`./server`, `./server/dev`). Transport-agnostic — games open their own realtime connection (e.g. via @colyseus/sdk).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/main.js",
|
|
7
7
|
"module": "./dist/src/main.js",
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"import": "./dist/src/browser-entry.js",
|
|
18
18
|
"default": "./dist/src/browser-entry.js"
|
|
19
19
|
},
|
|
20
|
+
"./server": {
|
|
21
|
+
"types": "./dist/src/server-entry.d.ts",
|
|
22
|
+
"import": "./dist/src/server-entry.js",
|
|
23
|
+
"default": "./dist/src/server-entry.js"
|
|
24
|
+
},
|
|
25
|
+
"./server/dev": {
|
|
26
|
+
"types": "./dist/src/server-dev-harness.d.ts",
|
|
27
|
+
"import": "./dist/src/server-dev-harness.js",
|
|
28
|
+
"default": "./dist/src/server-dev-harness.js"
|
|
29
|
+
},
|
|
20
30
|
"./gamehub-sdk.js": "./dist/gamehub-sdk.js",
|
|
21
31
|
"./package.json": "./package.json"
|
|
22
32
|
},
|
|
@@ -27,10 +37,10 @@
|
|
|
27
37
|
"files": [
|
|
28
38
|
"dist/**/*",
|
|
29
39
|
"README.md",
|
|
30
|
-
"
|
|
31
|
-
"MIGRATION.md"
|
|
40
|
+
"SPEC.md"
|
|
32
41
|
],
|
|
33
42
|
"scripts": {
|
|
43
|
+
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,json}\"",
|
|
34
44
|
"build:tsc": "tsc -p ./tsconfig.json",
|
|
35
45
|
"build:bundle": "esbuild src/browser-entry.ts --bundle --format=iife --platform=browser --target=es2020 --outfile=dist/gamehub-sdk.js --sourcemap",
|
|
36
46
|
"build": "npm run build:tsc && npm run build:bundle",
|