@ksaa-nlp/gamehub-sdk 0.9.0 → 3.6.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 +158 -373
- package/SPEC.md +869 -0
- package/dist/gamehub-sdk.js +168 -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 +33 -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 +46 -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,68 @@ export interface EventData {
|
|
|
22
20
|
value?: number;
|
|
23
21
|
properties?: Record<string, any>;
|
|
24
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A single question the host can offer in its report dialog's question
|
|
25
|
+
* picker. Supplied via {@link ReportQuestionData.questions}.
|
|
26
|
+
*/
|
|
27
|
+
export interface ReportableQuestion {
|
|
28
|
+
/** The `id` of the question (as returned by `getQuestions`). */
|
|
29
|
+
questionId: string;
|
|
30
|
+
/** Optional prompt label shown for this option in the picker. */
|
|
31
|
+
prompt?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Payload passed to `sdk.reportQuestion`. Identifies the question the player
|
|
35
|
+
* wants to flag; the host renders the report dialog and collects the reason,
|
|
36
|
+
* optional message, and (for guests) name/email before submitting.
|
|
37
|
+
*
|
|
38
|
+
* For a single question, pass `questionId` (and optionally `prompt`). To let
|
|
39
|
+
* the player pick which question to report, pass `questions` — the host renders
|
|
40
|
+
* a dropdown of them; `questionId` then acts as the pre-selected option.
|
|
41
|
+
*/
|
|
42
|
+
export interface ReportQuestionData {
|
|
43
|
+
/**
|
|
44
|
+
* The `id` of the question to report (as returned by `getQuestions`). May be
|
|
45
|
+
* omitted when `questions` is supplied, in which case it pre-selects an entry.
|
|
46
|
+
*/
|
|
47
|
+
questionId?: string;
|
|
48
|
+
/** Optional prompt snapshot so the host dialog can show what's being reported. */
|
|
49
|
+
prompt?: string;
|
|
50
|
+
/** Optional message to pre-fill in the dialog. */
|
|
51
|
+
message?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Optional list of questions for the host to render as a selectable dropdown,
|
|
54
|
+
* letting the player choose which question to report. When omitted, the dialog
|
|
55
|
+
* reports the single `questionId`.
|
|
56
|
+
*/
|
|
57
|
+
questions?: ReportableQuestion[];
|
|
58
|
+
}
|
|
25
59
|
/** Options accepted by `sdk.getQuestions`. */
|
|
26
60
|
export interface QuestionOptions {
|
|
27
61
|
difficulty?: 'easy' | 'medium' | 'hard' | string;
|
|
28
62
|
category?: string | number;
|
|
29
63
|
limit?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Selects a game **profile** (its subdoc `_id`) on the gamehub side — the
|
|
66
|
+
* resolver returns the union of that profile's private/bank/fixed parts. An
|
|
67
|
+
* unknown/omitted value falls back to the game's `isDefault` profile, so the
|
|
68
|
+
* default behaviour is identical to today. Usually sourced from the SDK
|
|
69
|
+
* bootstrap payload (the player's pre-start picker choice).
|
|
70
|
+
*/
|
|
71
|
+
profileId?: string;
|
|
30
72
|
}
|
|
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
|
-
}
|
|
73
|
+
export type { Question, QuestionDifficulty } from './question.js';
|
|
42
74
|
/** Result returned by `startSession`. */
|
|
43
75
|
export interface StartSessionResult {
|
|
44
76
|
success: boolean;
|
|
45
77
|
token?: string | null;
|
|
46
78
|
error?: string;
|
|
47
79
|
}
|
|
48
|
-
/** Result returned by `submitScore
|
|
80
|
+
/** Result returned by `submitScore`. */
|
|
49
81
|
export interface SubmitScoreResult {
|
|
50
82
|
success: boolean;
|
|
51
83
|
accepted?: boolean;
|
|
52
84
|
timeTaken?: number;
|
|
53
85
|
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
86
|
}
|
|
61
87
|
//# 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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AAY,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.6.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",
|