@ksaa-nlp/gamehub-sdk 3.5.0 → 3.7.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 +7 -2
- package/SPEC.md +51 -7
- package/dist/gamehub-sdk.js +56 -2
- package/dist/gamehub-sdk.js.map +2 -2
- package/dist/src/constants.d.ts +8 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +8 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/main.d.ts +16 -2
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +22 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/session.d.ts +7 -1
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/session.js +53 -1
- package/dist/src/session.js.map +1 -1
- package/dist/types/session.d.ts +67 -2
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/word.d.ts +147 -0
- package/dist/types/word.d.ts.map +1 -0
- package/dist/types/word.js +15 -0
- package/dist/types/word.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,9 +152,14 @@ sdk.logEvent('used_powerup', { kind: 'extra_time' }); // analytics breadcrumb
|
|
|
152
152
|
|
|
153
153
|
// Let the player flag the current question — the host opens a report dialog
|
|
154
154
|
sdk.reportQuestion({ questionId: q.id, prompt: q.prompt });
|
|
155
|
+
|
|
156
|
+
// …or let the player pick which question to report from a dropdown
|
|
157
|
+
sdk.reportQuestion({
|
|
158
|
+
questions: quiz.map((q) => ({ questionId: q.id, prompt: q.prompt })),
|
|
159
|
+
});
|
|
155
160
|
```
|
|
156
161
|
|
|
157
|
-
All of these are fire-and-forget — they just `postMessage` to the parent window. `reportQuestion` asks the host to open its report dialog (the host collects the reason + optional message, plus name/email for guests, and submits it).
|
|
162
|
+
All of these are fire-and-forget — they just `postMessage` to the parent window. `reportQuestion` asks the host to open its report dialog (the host collects the reason + optional message, plus name/email for guests, and submits it). Pass `questions` instead of a single `questionId` to have the host render a dropdown so the player chooses which question to report.
|
|
158
163
|
|
|
159
164
|
## Pause/resume from the host
|
|
160
165
|
|
|
@@ -222,7 +227,7 @@ sdk.getQuestions({ difficulty, category, limit }); // Promise<Question[]>
|
|
|
222
227
|
sdk.notifyComplete(data?); // void
|
|
223
228
|
sdk.requestClose(); // void
|
|
224
229
|
sdk.logEvent(name, data?); // void
|
|
225
|
-
sdk.reportQuestion({ questionId
|
|
230
|
+
sdk.reportQuestion({ questionId?, prompt?, message?, questions? }); // void
|
|
226
231
|
|
|
227
232
|
// Context
|
|
228
233
|
sdk.getGameSlug(); // string | null
|
package/SPEC.md
CHANGED
|
@@ -26,7 +26,8 @@ The SDK is not coupled to any realtime transport. When the host attaches a multi
|
|
|
26
26
|
- Exchange a small set of `postMessage` envelopes with the host page (bootstrap, auth, ready, init, command).
|
|
27
27
|
- Hold a single in-memory session token and supply it to the GameHub REST API when submitting scores.
|
|
28
28
|
- Submit scores (`submitScore`, `submitMatchScore`) and league-match results (`submitMatchResult`).
|
|
29
|
-
- Fetch questions (`getQuestions`).
|
|
29
|
+
- Fetch questions (`getQuestions`) and words (`getWords`).
|
|
30
|
+
- Request the host's report dialog for a question (`reportQuestion`) or word (`reportWord`).
|
|
30
31
|
- Surface a bootstrap snapshot (`getBootstrap()`) including the opaque `multiplayer` block.
|
|
31
32
|
- Forward player-visible host commands (`pause`, `resume`) to optional `window.onGameHubPause` / `onGameHubResume` callbacks.
|
|
32
33
|
- Type definitions for authoring UGC server bundles (`./server` subpath, types-only at runtime).
|
|
@@ -55,15 +56,16 @@ The package is laid out flat under `src/` and `types/`. No subdirectories.
|
|
|
55
56
|
| `src/browser-entry.ts` | The only file with side effects on import. Used by the IIFE bundle to attach `window.GameHubSDK`. |
|
|
56
57
|
| `src/init.ts` | `detectEnvironment`, `autoInit`, `ensureInitialized`, `installHostMessageListener`. |
|
|
57
58
|
| `src/bridge.ts` | postMessage protocol: bootstrap parsing, request/response handlers, send helper. |
|
|
58
|
-
| `src/session.ts` | `startSession`, `submitScore`, `submitMatchScore`, `submitMatchResult`, `getQuestions`.
|
|
59
|
+
| `src/session.ts` | `startSession`, `submitScore`, `submitMatchScore`, `submitMatchResult`, `getQuestions`, `getWords`. |
|
|
59
60
|
| `src/match-context.ts` | `fetchMatchContext` (HTTP `/leagues/<id>/matches/<id>`). |
|
|
60
61
|
| `src/api-client.ts` | `apiRequest`: thin `fetch` wrapper that prefixes the API base and attaches the Bearer token. |
|
|
61
62
|
| `src/state.ts` | `SdkState` interface + the singleton `state` object. All mutable state lives here. |
|
|
62
|
-
| `src/constants.ts` | `SDK_VERSION`, `MESSAGE_PREFIX`, `PARENT_REQUEST_TIMEOUT_MS`, `QUESTIONS_LIMIT_CAP`.
|
|
63
|
+
| `src/constants.ts` | `SDK_VERSION`, `MESSAGE_PREFIX`, `PARENT_REQUEST_TIMEOUT_MS`, `QUESTIONS_LIMIT_CAP`, `WORDS_LIMIT_CAP`. |
|
|
63
64
|
| `src/utils.ts` | `isBrowser`, `warn`, `error`, `unwrapResult`, `readQueryParam`. |
|
|
64
65
|
| `types/api.ts` | `ApiResponse`, `ApiRequestOptions`. |
|
|
65
66
|
| `types/bootstrap.ts` | `BootstrapMultiplayer`, `BootstrapConfig`, `BootstrapData`. |
|
|
66
|
-
| `types/session.ts` | `Question`, `QuestionOptions`, `ScoreMetadata`, `EventData`, `GameCompleteData`, `StartSessionResult`, `SubmitScoreResult
|
|
67
|
+
| `types/session.ts` | `Question`, `QuestionOptions`, `ScoreMetadata`, `EventData`, `GameCompleteData`, `StartSessionResult`, `SubmitScoreResult`, `WordOptions`, `ReportWordData`, `ReportableWord` (re-exports `Word`). |
|
|
68
|
+
| `types/word.ts` | `Word` + sub-interfaces (`WordSense`, `WordForm`, `Lookup`, `Synset`, `FormRepresentation`, `DynamicProp`, …) — Words Bank feature. |
|
|
67
69
|
| `types/match.ts` | `MatchParticipantMember`, `MatchParticipant`, `MatchContext`, `MatchResultPayload`. |
|
|
68
70
|
| `src/server-entry.ts` | `./server` subpath. Types-only at runtime: `GuestModule`, `Ctx`, `PeerInfo`, `BroadcastOptions`, `EndMatchPayload`, `CreateOptions`. No imports from the browser SDK; safe for tooling that compiles the bundle on Node. |
|
|
69
71
|
| `src/server-dev-harness.ts` | `./server/dev` subpath. `runLocal(guest, opts)` returns a `LocalRoom` that simulates the colyseus host (`join`, `send`, `leave`, `advance`, etc.) and records every bridge call to `outbox`. Pure Node — does not import `isolated-vm` or anything browser. |
|
|
@@ -170,7 +172,8 @@ The SDK communicates with the host page through namespaced `postMessage` envelop
|
|
|
170
172
|
| SDK → host | `GAME_COMPLETE` | Fired by `sdk.notifyComplete(data?)`. Carries `data` verbatim. |
|
|
171
173
|
| SDK → host | `REQUEST_CLOSE` | Fired by `sdk.requestClose()`. Empty payload. |
|
|
172
174
|
| SDK → host | `LOG_EVENT` | Fired by `sdk.logEvent(name, data?)`. Carries `{ event, data }`. |
|
|
173
|
-
| SDK → host | `QUESTION_REPORT` | Fired by `sdk.reportQuestion(data)`. Carries `{ questionId
|
|
175
|
+
| SDK → host | `QUESTION_REPORT` | Fired by `sdk.reportQuestion(data)`. Carries `{ questionId?, prompt?, message?, questions? }`. With `questions` the host renders a question-picker dropdown; otherwise it reports the single `questionId`. |
|
|
176
|
+
| SDK → host | `WORD_REPORT` | Fired by `sdk.reportWord(data)` (Words Bank feature). Carries `{ wordId?, lemma?, message?, words? }`. Same picker/single semantics as `QUESTION_REPORT`, relabeled to lemma. |
|
|
174
177
|
| SDK → host | `API_REQUEST` | Asks the host to proxy a backend HTTP call. Carries `{ messageId, endpoint, method, body }`. See §6.6. |
|
|
175
178
|
| host → SDK | `API_RESPONSE` | Result of a proxied call. Carries `{ messageId, ok: boolean, result?: ApiResponse, error?: string }`. See §6.6. |
|
|
176
179
|
|
|
@@ -388,6 +391,43 @@ interface Question {
|
|
|
388
391
|
}
|
|
389
392
|
```
|
|
390
393
|
|
|
394
|
+
## 11bis. Words (Words Bank feature)
|
|
395
|
+
|
|
396
|
+
### 11bis.1 `getWords(options?)`
|
|
397
|
+
|
|
398
|
+
Mirrors `getQuestions`. Awaits `ensureInitialized()`; identifier is
|
|
399
|
+
`state.gameId || state.gameSlug` (returns `[]` if both null). Validates
|
|
400
|
+
`options.difficulty` and `options.limit` the same way (returns `[]` on
|
|
401
|
+
mismatch). GETs
|
|
402
|
+
`/games/<identifier>/words?limit=<n>&random=true[&gameId=…][&difficulty=…][&category=…][&tags=a,b][&profileId=…]`.
|
|
403
|
+
|
|
404
|
+
- `options.profileId` selects a game **profile** whose `wordPack` drives the
|
|
405
|
+
selection (the same profile that carries the question `pack`). Omitted →
|
|
406
|
+
bootstrap `profileId` → the game's `isDefault` profile.
|
|
407
|
+
- `options.tags` (a `string[]`) is sent comma-joined and ANDed (`$in`) on top of
|
|
408
|
+
the profile selection.
|
|
409
|
+
- `limit` is clamped to `WORDS_LIMIT_CAP` (**50**, lower than questions' 100
|
|
410
|
+
because a full-nested `Word` is heavier) and defaults to 50.
|
|
411
|
+
- Response shapes accepted: `Word[]` directly, `{ words: Word[] }`, else `[]`.
|
|
412
|
+
- Never throws — all failure modes resolve `[]`. No normalization (the runtime
|
|
413
|
+
route is a near-passthrough).
|
|
414
|
+
|
|
415
|
+
### 11bis.2 `Word` shape
|
|
416
|
+
|
|
417
|
+
The **full nested `PublicEntry` shape** (`lemma`, `senses[]`, `wordForms[]`,
|
|
418
|
+
`lemmaLanguage`, `relatedSenses[]`, …) plus exposed gamehub fields
|
|
419
|
+
`difficulty`/`category`/`tags`, with `_id` renamed to `id`. The embedded
|
|
420
|
+
reference objects (`Lookup`/`Synset`/`DynamicProperty`) reflect the
|
|
421
|
+
**audit-stripped** shape the server persists (no `_id`/`createdAt`/`isReviewed`/…).
|
|
422
|
+
Full field tables in `types/word.ts` and `specs/words-bank-feature.md` §3.
|
|
423
|
+
|
|
424
|
+
### 11bis.3 `reportWord(data)`
|
|
425
|
+
|
|
426
|
+
Mirrors `reportQuestion`: fires the `WORD_REPORT` postMessage with
|
|
427
|
+
`{ wordId?, lemma?, message?, words? }` for the host to render its
|
|
428
|
+
`ReportWordDialog`. No-ops outside the host iframe (the SDK never calls the
|
|
429
|
+
report endpoint itself). See §6.1.
|
|
430
|
+
|
|
391
431
|
## 12. Host command channel
|
|
392
432
|
|
|
393
433
|
`COMMAND` messages from the host dispatch to optional global handlers:
|
|
@@ -505,9 +545,13 @@ interface SdkState {
|
|
|
505
545
|
| `notifyComplete(data?)` | `void` | `GAME_COMPLETE` |
|
|
506
546
|
| `requestClose()` | `void` | `REQUEST_CLOSE` |
|
|
507
547
|
| `logEvent(eventName, eventData?)` | `void` | `LOG_EVENT { event: eventName, data: eventData }` |
|
|
508
|
-
| `reportQuestion(data)` | `void` | `QUESTION_REPORT { questionId
|
|
548
|
+
| `reportQuestion(data)` | `void` | `QUESTION_REPORT { questionId?, prompt?, message?, questions? }` |
|
|
549
|
+
|
|
550
|
+
`reportQuestion(data: ReportQuestionData)` asks the host to open its "report this question" dialog. The host owns the dialog (the SDK renders no DOM — see §19.3) and submits the report, collecting the reason, an optional message, and — for guests — name/email. Like the other host signals it no-ops outside an iframe.
|
|
509
551
|
|
|
510
|
-
|
|
552
|
+
Two modes:
|
|
553
|
+
- **Single question** — pass `questionId` (and optionally `prompt`). The dialog reports that one question.
|
|
554
|
+
- **Pick from a list** — pass `questions: ReportableQuestion[]` (each `{ questionId, prompt? }`). The host renders a dropdown so the player chooses which question to report; `questionId`, when also supplied, pre-selects an entry. The `questions` array is forwarded verbatim (each entry normalised to `{ questionId, prompt }`) on the `QUESTION_REPORT` envelope.
|
|
511
555
|
|
|
512
556
|
### 14.7 Read-only context
|
|
513
557
|
|
package/dist/gamehub-sdk.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
// src/constants.ts
|
|
4
|
-
var SDK_VERSION = "3.
|
|
4
|
+
var SDK_VERSION = "3.7.0";
|
|
5
5
|
var MESSAGE_PREFIX = "GAMEHUB_SDK";
|
|
6
6
|
var PARENT_REQUEST_TIMEOUT_MS = 2e3;
|
|
7
7
|
var HOST_API_TIMEOUT_MS = 15e3;
|
|
8
8
|
var QUESTIONS_LIMIT_CAP = 100;
|
|
9
|
+
var WORDS_LIMIT_CAP = 50;
|
|
9
10
|
|
|
10
11
|
// src/state.ts
|
|
11
12
|
var state = {
|
|
@@ -447,6 +448,41 @@
|
|
|
447
448
|
const answer = typeof q.answer === "number" ? String(q.answer) : q.answer;
|
|
448
449
|
return { ...q, answer };
|
|
449
450
|
}
|
|
451
|
+
async function getWords(options = {}) {
|
|
452
|
+
await ensureInitialized();
|
|
453
|
+
const gameIdentifier = state.gameId || state.gameSlug;
|
|
454
|
+
if (!gameIdentifier) return [];
|
|
455
|
+
const { difficulty, category, tags, limit } = options;
|
|
456
|
+
if (difficulty && !["easy", "medium", "hard"].includes(difficulty)) {
|
|
457
|
+
return [];
|
|
458
|
+
}
|
|
459
|
+
if (limit !== void 0 && (typeof limit !== "number" || limit < 1)) {
|
|
460
|
+
return [];
|
|
461
|
+
}
|
|
462
|
+
const profileId = options.profileId || state.bootstrapProfileId || "";
|
|
463
|
+
try {
|
|
464
|
+
const params = new URLSearchParams({
|
|
465
|
+
limit: String(Math.min(limit || WORDS_LIMIT_CAP, WORDS_LIMIT_CAP)),
|
|
466
|
+
random: "true"
|
|
467
|
+
});
|
|
468
|
+
if (state.gameId) params.set("gameId", state.gameId);
|
|
469
|
+
if (difficulty) params.set("difficulty", difficulty);
|
|
470
|
+
if (category) params.set("category", String(category));
|
|
471
|
+
if (Array.isArray(tags) && tags.length > 0) {
|
|
472
|
+
params.set("tags", tags.join(","));
|
|
473
|
+
}
|
|
474
|
+
if (profileId) params.set("profileId", profileId);
|
|
475
|
+
const result = await apiRequest(
|
|
476
|
+
"/games/" + encodeURIComponent(gameIdentifier) + "/words?" + params.toString(),
|
|
477
|
+
{ method: "GET" }
|
|
478
|
+
);
|
|
479
|
+
const data = unwrapResult(result);
|
|
480
|
+
const raw = Array.isArray(data) ? data : Array.isArray(data?.words) ? data.words : [];
|
|
481
|
+
return raw;
|
|
482
|
+
} catch {
|
|
483
|
+
return [];
|
|
484
|
+
}
|
|
485
|
+
}
|
|
450
486
|
|
|
451
487
|
// src/init.ts
|
|
452
488
|
var environmentDetected = false;
|
|
@@ -634,7 +670,22 @@
|
|
|
634
670
|
sendToParent("QUESTION_REPORT", {
|
|
635
671
|
questionId: data.questionId,
|
|
636
672
|
prompt: data.prompt,
|
|
637
|
-
message: data.message
|
|
673
|
+
message: data.message,
|
|
674
|
+
questions: Array.isArray(data.questions) ? data.questions.map((q) => ({
|
|
675
|
+
questionId: q.questionId,
|
|
676
|
+
prompt: q.prompt
|
|
677
|
+
})) : void 0
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
reportWord(data) {
|
|
681
|
+
sendToParent("WORD_REPORT", {
|
|
682
|
+
wordId: data.wordId,
|
|
683
|
+
lemma: data.lemma,
|
|
684
|
+
message: data.message,
|
|
685
|
+
words: Array.isArray(data.words) ? data.words.map((w) => ({
|
|
686
|
+
wordId: w.wordId,
|
|
687
|
+
lemma: w.lemma
|
|
688
|
+
})) : void 0
|
|
638
689
|
});
|
|
639
690
|
},
|
|
640
691
|
logEvent(eventName, eventData = {}) {
|
|
@@ -671,6 +722,9 @@
|
|
|
671
722
|
},
|
|
672
723
|
getQuestions(options = {}) {
|
|
673
724
|
return getQuestions(options);
|
|
725
|
+
},
|
|
726
|
+
getWords(options = {}) {
|
|
727
|
+
return getWords(options);
|
|
674
728
|
}
|
|
675
729
|
};
|
|
676
730
|
}
|
package/dist/gamehub-sdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/constants.ts", "../src/state.ts", "../src/utils.ts", "../src/bridge.ts", "../src/api-client.ts", "../src/session.ts", "../src/init.ts", "../src/match-context.ts", "../src/main.ts", "../src/browser-entry.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Bundle version reported by the SDK. Bumped at release time.\n */\nexport const SDK_VERSION = '3.5.0';\n\n/**\n * Prefix applied to every cross-origin postMessage the SDK emits and accepts.\n * Keeps our messages isolated from unrelated frames on the same page.\n */\nexport const MESSAGE_PREFIX = 'GAMEHUB_SDK';\n\n/** How long to wait for the host to reply to bootstrap/auth requests. */\nexport const PARENT_REQUEST_TIMEOUT_MS = 2000;\n\n/**\n * How long to wait for the host to proxy an HTTP API request back to the\n * SDK. Larger than {@link PARENT_REQUEST_TIMEOUT_MS} because this round-trip\n * includes the host's real network call to the GameHub backend.\n */\nexport const HOST_API_TIMEOUT_MS = 15000;\n\n/** Upper bound on questions returned per `getQuestions` call. */\nexport const QUESTIONS_LIMIT_CAP = 100;\n", "/**\n * Centralised mutable state for the SDK singleton.\n *\n * Everything here lives on a single `state` object so feature modules\n * can mutate it (`state.foo = bar`). ES modules don't allow reassigning\n * imported `let` bindings from the consumer side, so a single shared\n * object is the cleanest replacement for the namespace + `export let`\n * pattern used in earlier SDK versions.\n */\n\nimport type {\n BootstrapConfig,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nimport type { MatchContext } from '../types/match.js';\nimport type { StartSessionResult } from '../types/session.js';\n\nexport interface SdkState {\n // --- API endpoint resolution -------------------------------------------\n sdkOrigin: string;\n sdkPathPrefix: string;\n runtimeBasePath: string;\n apiBase: string;\n\n // --- Game / league context ---------------------------------------------\n gameSlug: string | null;\n sessionToken: string | null;\n authToken: string | null;\n leagueId: string | null;\n gameId: string | null;\n matchId: string | null;\n\n // --- Free-form bootstrap fields (display only) -------------------------\n bootstrapMode: string | null;\n bootstrapPlayerName: string | null;\n bootstrapPlayerCount: string | null;\n bootstrapTeamOneName: string | null;\n bootstrapTeamTwoName: string | null;\n /** Player's pre-start profile choice; default for `getQuestions`. */\n bootstrapProfileId: string | null;\n\n // --- Multiplayer bootstrap ---------------------------------------------\n // Opaque to the SDK \u2014 exposed verbatim on `getBootstrap().multiplayer`\n // for games to feed into their realtime client (e.g. `@colyseus/sdk`'s\n // `client.reconnect(...)`). The SDK does not open or manage the socket.\n bootstrapMultiplayer: BootstrapMultiplayer | null;\n bootstrapReceived: boolean;\n\n // --- Initialisation lifecycle ------------------------------------------\n isInitialized: boolean;\n isAutoInitializing: boolean;\n autoInitPromise: Promise<boolean> | null;\n bootstrapRequestPromise: Promise<BootstrapConfig | null> | null;\n parentOrigin: string | null;\n sessionStartPromise: Promise<StartSessionResult> | null;\n\n // --- League match context (HTTP) ---------------------------------------\n /** Cached league match context, loaded on demand. */\n matchContext: MatchContext | null;\n /** In-flight match-context fetch, deduped across callers. */\n matchContextPromise: Promise<MatchContext | null> | null;\n}\n\nexport const state: SdkState = {\n sdkOrigin: '',\n sdkPathPrefix: '',\n runtimeBasePath: '',\n apiBase: '',\n\n gameSlug: null,\n sessionToken: null,\n authToken: null,\n leagueId: null,\n gameId: null,\n matchId: null,\n\n bootstrapMode: null,\n bootstrapPlayerName: null,\n bootstrapPlayerCount: null,\n bootstrapTeamOneName: null,\n bootstrapTeamTwoName: null,\n bootstrapProfileId: null,\n\n bootstrapMultiplayer: null,\n bootstrapReceived: false,\n\n isInitialized: false,\n isAutoInitializing: false,\n autoInitPromise: null,\n bootstrapRequestPromise: null,\n parentOrigin: null,\n sessionStartPromise: null,\n\n matchContext: null,\n matchContextPromise: null,\n};\n", "import type { ApiResponse } from '../types/api.js';\n\n/**\n * True when running in a browser-like environment (has both `window` and\n * `document`). Used to short-circuit DOM-touching helpers so the package\n * can be imported under Node / Angular SSR without throwing.\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Logs with a consistent `[GameHubSDK]` prefix so host-page developers can\n * easily filter SDK messages in their console.\n */\nexport function warn(message: string, ...rest: any[]): void {\n console.warn('[GameHubSDK] ' + message, ...rest);\n}\n\nexport function error(message: string, ...rest: any[]): void {\n console.error('[GameHubSDK] ' + message, ...rest);\n}\n\n/**\n * Flattens the standard `{ success, data }` envelope returned by the\n * GameHub REST API down to the inner `data` payload. Returns the raw\n * response when the envelope shape doesn't apply.\n */\nexport function unwrapResult(result: ApiResponse | null | undefined): any {\n if (!result) return null;\n if (result.success && result.data) return result.data;\n return result;\n}\n\n/**\n * Safely read a query-string parameter, falling back to a regex scan when\n * URLSearchParams is unavailable (very old browsers / odd runtimes).\n */\nexport function readQueryParam(name: string): string | null {\n try {\n const params = new URLSearchParams(window.location.search);\n return params.get(name);\n } catch {\n const match = window.location.search.match(\n new RegExp('[?&]' + name + '=([^&]+)')\n );\n return match ? decodeURIComponent(match[1]) : null;\n }\n}\n", "/**\n * Cross-origin communication layer between the game iframe and its host page.\n *\n * Messages are namespaced with `MESSAGE_PREFIX` so we don't pick up\n * unrelated postMessage traffic. The host implements a small protocol:\n * - `BOOTSTRAP_REQUEST` \u21C4 `BOOTSTRAP` (initial config + multiplayer)\n * - `AUTH_REQUEST` \u21C4 `AUTH_RESPONSE` (refresh the bearer token)\n * - `READY` / `INIT` / `SESSION_STARTED` / `SCORE_SUBMITTED` / etc.\n * (one-way SDK \u2192 host signals)\n */\n\nimport { state } from './state.js';\nimport {\n MESSAGE_PREFIX,\n PARENT_REQUEST_TIMEOUT_MS,\n HOST_API_TIMEOUT_MS,\n} from './constants.js';\nimport { isBrowser } from './utils.js';\nimport type {\n BootstrapConfig,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nimport type { ApiResponse, ApiRequestOptions } from '../types/api.js';\n\nfunction trimToNullable(value: unknown): string | null | undefined {\n if (value === null) return null;\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n return trimmed ? trimmed : null;\n}\n\nfunction parseMultiplayer(\n value: BootstrapConfig['multiplayer']\n): BootstrapMultiplayer | null | undefined {\n if (value === null) return null;\n if (!value || typeof value !== 'object') return undefined;\n const { reservation, wsEndpoint } = value;\n if (\n !reservation ||\n typeof reservation !== 'object' ||\n typeof (reservation as { name?: unknown }).name !== 'string' ||\n typeof (reservation as { sessionId?: unknown }).sessionId !== 'string' ||\n typeof (reservation as { roomId?: unknown }).roomId !== 'string' ||\n typeof wsEndpoint !== 'string'\n ) {\n return undefined;\n }\n return {\n reservation,\n wsEndpoint: wsEndpoint.trim(),\n };\n}\n\n/**\n * Fold a {@link BootstrapConfig} from the host into internal state. Accepts\n * partial configs: only fields the host explicitly set (including explicit\n * `null`s used to clear a value) are applied.\n */\nexport function mergeBootstrapConfig(config: BootstrapConfig = {}): void {\n if (!config || typeof config !== 'object') return;\n\n const apply = (\n key: 'gameSlug' | 'authToken' | 'leagueId' | 'gameId' | 'matchId',\n raw: unknown\n ) => {\n const next = trimToNullable(raw);\n if (next === undefined) return;\n state[key] = next;\n };\n\n apply('gameSlug', config.gameSlug);\n apply('authToken', config.authToken);\n apply('leagueId', config.leagueId);\n apply('gameId', config.gameId);\n apply('matchId', config.matchId);\n\n const applyBootstrap = (\n key:\n | 'bootstrapMode'\n | 'bootstrapPlayerName'\n | 'bootstrapPlayerCount'\n | 'bootstrapTeamOneName'\n | 'bootstrapTeamTwoName'\n | 'bootstrapProfileId',\n raw: unknown\n ) => {\n const next = trimToNullable(raw);\n if (next === undefined) return;\n state[key] = next;\n };\n\n applyBootstrap('bootstrapMode', config.mode);\n applyBootstrap('bootstrapPlayerName', config.playerName);\n applyBootstrap('bootstrapPlayerCount', config.playerCount);\n applyBootstrap('bootstrapTeamOneName', config.teamOneName);\n applyBootstrap('bootstrapTeamTwoName', config.teamTwoName);\n applyBootstrap('bootstrapProfileId', config.profileId);\n\n const mp = parseMultiplayer(config.multiplayer);\n if (mp !== undefined) {\n state.bootstrapMultiplayer = mp;\n }\n}\n\nfunction snapshotBootstrap(): BootstrapConfig {\n return {\n gameSlug: state.gameSlug,\n authToken: state.authToken,\n leagueId: state.leagueId,\n gameId: state.gameId,\n matchId: state.matchId,\n mode: state.bootstrapMode,\n playerName: state.bootstrapPlayerName,\n playerCount: state.bootstrapPlayerCount,\n teamOneName: state.bootstrapTeamOneName,\n teamTwoName: state.bootstrapTeamTwoName,\n profileId: state.bootstrapProfileId,\n multiplayer: state.bootstrapMultiplayer,\n };\n}\n\n/**\n * Ask the host for its bootstrap payload. Resolves `null` if the game is\n * standalone (no parent) or the host doesn't reply within the timeout.\n *\n * Subsequent calls after a successful bootstrap short-circuit to the\n * cached state snapshot.\n */\nexport function requestBootstrapFromParent(): Promise<BootstrapConfig | null> {\n if (!isBrowser() || window.parent === window) {\n return Promise.resolve(null);\n }\n\n if (state.bootstrapReceived) {\n return Promise.resolve(snapshotBootstrap());\n }\n\n if (state.bootstrapRequestPromise) {\n return state.bootstrapRequestPromise;\n }\n\n state.bootstrapRequestPromise = new Promise<BootstrapConfig | null>(\n (resolve) => {\n const messageId = Date.now().toString();\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n event.data &&\n event.data.type === MESSAGE_PREFIX + '_BOOTSTRAP' &&\n event.data.payload\n ) {\n if (event.data.messageId && event.data.messageId !== messageId) {\n return;\n }\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n state.bootstrapReceived = true;\n mergeBootstrapConfig(event.data.payload);\n resolve(event.data.payload);\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_BOOTSTRAP_REQUEST',\n messageId,\n },\n '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n resolve(null);\n }, PARENT_REQUEST_TIMEOUT_MS);\n }\n ).finally(() => {\n state.bootstrapRequestPromise = null;\n });\n\n return state.bootstrapRequestPromise;\n}\n\n/**\n * Ask the host for a fresh auth token. The host may also use the response\n * to override league/match context \u2014 when it does, we prefer its values.\n */\nexport function getAuthTokenFromParent(): Promise<string | null> {\n return new Promise((resolve) => {\n if (!isBrowser() || window.parent === window) {\n resolve(null);\n return;\n }\n\n const messageId = Date.now().toString();\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n event.data &&\n event.data.type === MESSAGE_PREFIX + '_AUTH_RESPONSE' &&\n event.data.messageId === messageId\n ) {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n if (event.data.leagueId) state.leagueId = event.data.leagueId;\n if (event.data.gameId) state.gameId = event.data.gameId;\n if (event.data.matchId) state.matchId = event.data.matchId;\n resolve(event.data.token || null);\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n { type: MESSAGE_PREFIX + '_AUTH_REQUEST', messageId },\n '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n resolve(null);\n }, PARENT_REQUEST_TIMEOUT_MS);\n });\n}\n\n/** Monotonic counter so concurrent API proxy requests get distinct ids. */\nlet apiRequestSeq = 0;\n\n/**\n * Proxy an HTTP request to the GameHub backend through the host page.\n *\n * The host frame is same-origin with the GameHub API, so it performs the\n * real `fetch` and posts the parsed JSON envelope back. This keeps the SDK\n * (and the game it lives in) from ever issuing a cross-origin request to the\n * backend \u2014 which would otherwise fail CORS when the game is served from a\n * different domain than GameHub.\n *\n * The protocol mirrors the bootstrap/auth handshakes: a `messageId`-keyed\n * `API_REQUEST` is answered by exactly one `API_RESPONSE`. Resolves with the\n * parsed {@link ApiResponse}; rejects on host-reported failure or timeout so\n * the existing per-call `try/catch` degradation paths fire unchanged.\n */\nexport function requestApiFromParent(\n endpoint: string,\n options: ApiRequestOptions = {}\n): Promise<ApiResponse> {\n return new Promise<ApiResponse>((resolve, reject) => {\n if (!isBrowser() || window.parent === window) {\n reject(new Error('Host bridge unavailable: not running in an iframe'));\n return;\n }\n\n const messageId = 'api_' + Date.now().toString() + '_' + ++apiRequestSeq;\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n !event.data ||\n event.data.type !== MESSAGE_PREFIX + '_API_RESPONSE' ||\n event.data.messageId !== messageId\n ) {\n return;\n }\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n if (event.data.ok) {\n resolve((event.data.result ?? {}) as ApiResponse);\n } else {\n reject(new Error(event.data.error || 'Host API request failed'));\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_API_REQUEST',\n messageId,\n endpoint,\n method: options.method || 'GET',\n body: options.body ?? null,\n },\n state.parentOrigin || '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n reject(new Error('Host API request timed out'));\n }, HOST_API_TIMEOUT_MS);\n });\n}\n\n/**\n * Fire a namespaced message up to the host window. Silently no-ops when\n * we aren't inside an iframe.\n */\nexport function sendToParent(type: string, data: Record<string, any>): void {\n if (!isBrowser() || window.parent === window) return;\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_' + type,\n gameSlug: state.gameSlug,\n ...data,\n },\n state.parentOrigin || '*'\n );\n}\n", "import { state } from './state.js';\nimport { isBrowser } from './utils.js';\nimport { requestApiFromParent } from './bridge.js';\nimport type { ApiResponse, ApiRequestOptions } from '../types/api.js';\n\n/**\n * Performs a request against the GameHub REST API and parses the JSON\n * response.\n *\n * Transport is chosen by context:\n * - **Inside the host iframe** the request is proxied through the host via\n * postMessage ({@link requestApiFromParent}). The host is same-origin\n * with the GameHub backend, so the game never issues a cross-origin call\n * itself \u2014 this is what keeps the SDK CORS-free when the game is served\n * from a different domain than GameHub.\n * - **Standalone** (dev harness / a game served from the GameHub origin)\n * the SDK calls the backend directly, prefixing the configured API base\n * and attaching the Bearer auth token when available.\n *\n * Throws whatever the transport throws (host failure/timeout, or\n * `fetch`/`JSON.parse`) \u2014 callers decide whether to retry, fall back, or\n * surface the error to the host.\n */\nexport async function apiRequest(\n endpoint: string,\n options: ApiRequestOptions = {}\n): Promise<ApiResponse> {\n // When embedded, let the host (same-origin with the API) make the call.\n if (isBrowser() && window.parent !== window) {\n return requestApiFromParent(endpoint, options);\n }\n\n const url = state.apiBase + endpoint;\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...(options.headers || {}),\n };\n\n if (state.authToken) {\n headers.Authorization = 'Bearer ' + state.authToken;\n }\n\n const response = await fetch(url, {\n ...options,\n credentials: options.credentials || 'same-origin',\n headers,\n body: options.body ? JSON.stringify(options.body) : undefined,\n });\n\n return response.json();\n}\n", "import { state } from './state.js';\nimport { QUESTIONS_LIMIT_CAP } from './constants.js';\nimport { apiRequest } from './api-client.js';\nimport { unwrapResult } from './utils.js';\nimport { sendToParent } from './bridge.js';\nimport { ensureInitialized } from './init.js';\nimport type {\n Question,\n QuestionOptions,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n} from '../types/session.js';\nimport type { MatchResultPayload } from '../types/match.js';\n\n/**\n * Starts a new game session and caches the returned session token. Safe\n * to call multiple times \u2014 the cached token short-circuits subsequent\n * calls.\n *\n * Endpoint is selected from the active context:\n * - league + game + match \u2192 scoped match session\n * - league + game \u2192 scoped league session\n * - otherwise \u2192 standalone session (requires auth)\n */\nexport async function startSession(): Promise<StartSessionResult> {\n if (!state.gameSlug) return { success: false, error: 'Game slug not set' };\n\n const isLeagueMatchSession = Boolean(\n state.leagueId && state.gameId && state.matchId\n );\n if (!state.authToken && !isLeagueMatchSession) {\n return { success: false, error: 'User not authenticated' };\n }\n if (state.sessionToken) return { success: true, token: state.sessionToken };\n\n try {\n let endpoint = '/sessions/start';\n let body: Record<string, any> = { gameSlug: state.gameSlug };\n\n if (state.leagueId && state.gameId && state.matchId) {\n endpoint =\n '/leagues/' + state.leagueId + '/matches/' + state.matchId + '/session';\n body = { gameId: state.gameId };\n } else if (state.leagueId && state.gameId) {\n endpoint = '/leagues/' + state.leagueId + '/sessions';\n body = { gameId: state.gameId };\n }\n\n const result = await apiRequest(endpoint, {\n method: 'POST',\n body,\n });\n\n const data = unwrapResult(result);\n if (result.success || data?.token) {\n state.sessionToken = data?.token || result?.token || null;\n sendToParent('SESSION_STARTED', { token: state.sessionToken });\n return { success: true, token: state.sessionToken };\n }\n\n return {\n success: false,\n error: result.error?.message || 'Failed to start session',\n };\n } catch (err: any) {\n return { success: false, error: err.message };\n }\n}\n\n/**\n * Submit a score to the current session. If no session exists yet we try\n * to open one (re-using any in-flight start attempt).\n *\n * Multiplayer authority lives on the Colyseus server now \u2014 score\n * submission is no longer gated by a client-side host role. Games that\n * want only one peer to call this should make that decision based on\n * their room state (e.g. `room.state.hostPeerId === selfId`).\n */\nexport async function submitScore(\n score: number,\n meta: ScoreMetadata = {}\n): Promise<SubmitScoreResult> {\n await ensureInitialized();\n\n if (!state.isInitialized) {\n return {\n success: false,\n error: 'SDK could not initialize. Is game slug set?',\n };\n }\n\n if (!state.sessionToken) {\n if (state.sessionStartPromise) {\n await state.sessionStartPromise;\n } else {\n const sessionResult = await startSession();\n if (!sessionResult.success) {\n return {\n success: false,\n error: sessionResult.error || 'Could not start session',\n };\n }\n }\n }\n\n if (!state.sessionToken) {\n return {\n success: false,\n error: 'No active session. User may not be authenticated.',\n };\n }\n\n if (typeof score !== 'number' || score < 0) {\n return { success: false, error: 'Score must be a non-negative number' };\n }\n\n try {\n const result = await apiRequest('/sessions/submit', {\n method: 'POST',\n body: {\n token: state.sessionToken,\n score: Math.floor(score),\n meta,\n },\n });\n\n const data = unwrapResult(result);\n\n if (result.success || data?.accepted) {\n sendToParent('SCORE_SUBMITTED', {\n score,\n accepted: data?.accepted,\n timeTaken: data?.timeTaken,\n });\n return {\n success: true,\n accepted: data?.accepted,\n timeTaken: data?.timeTaken,\n };\n }\n\n return {\n success: false,\n error: result.error?.message || 'Score rejected',\n };\n } catch (err: any) {\n return { success: false, error: err.message };\n }\n}\n\n/**\n * Convenience wrapper that tags a score with the current league match\n * context. Fails early if there's no matchId \u2014 a plain `submitScore` is\n * the right call in that case.\n */\nexport async function submitMatchScore(\n score: number,\n meta: ScoreMetadata = {}\n): Promise<SubmitScoreResult> {\n if (!state.matchId) {\n return {\n success: false,\n error: 'No matchId found for this game session',\n };\n }\n\n return await submitScore(score, {\n ...(meta || {}),\n matchId: state.matchId,\n leagueId: state.leagueId || meta.leagueId,\n gameId: state.gameId || meta.gameId,\n });\n}\n\n/**\n * Submit a match result (winner, scores, etc.) with a zero placeholder\n * score \u2014 the server derives the real leaderboard entries from the result\n * payload.\n */\nexport async function submitMatchResult(\n result: MatchResultPayload = {}\n): Promise<SubmitScoreResult> {\n if (!result || typeof result !== 'object') {\n return { success: false, error: 'match result payload is required' };\n }\n\n return await submitMatchScore(0, { matchResult: result });\n}\n\n/**\n * Fetch questions for this game. Returns an empty array on any failure\n * or invalid input \u2014 callers can treat \"no questions\" as the degraded\n * state.\n */\nexport async function getQuestions(\n options: QuestionOptions = {}\n): Promise<Question[]> {\n await ensureInitialized();\n\n const gameIdentifier = state.gameId || state.gameSlug;\n if (!gameIdentifier) return [];\n\n const { difficulty, category, limit } = options;\n\n if (difficulty && !['easy', 'medium', 'hard'].includes(difficulty)) {\n return [];\n }\n\n if (limit !== undefined && (typeof limit !== 'number' || limit < 1)) {\n return [];\n }\n\n // Profile selection: explicit option wins, else the bootstrap-supplied\n // profileId (the player's pre-start picker choice). Omitted \u2192 resolver\n // falls back to the game's isDefault profile (identical to today).\n const profileId = options.profileId || state.bootstrapProfileId || '';\n\n try {\n const params = new URLSearchParams({\n limit: String(\n Math.min(limit || QUESTIONS_LIMIT_CAP, QUESTIONS_LIMIT_CAP)\n ),\n random: 'true',\n });\n if (state.gameId) params.set('gameId', state.gameId);\n if (difficulty) params.set('difficulty', difficulty);\n if (category) params.set('category', String(category));\n if (profileId) params.set('profileId', profileId);\n\n const result = await apiRequest(\n '/games/' +\n encodeURIComponent(gameIdentifier) +\n '/questions?' +\n params.toString(),\n { method: 'GET' }\n );\n\n const data = unwrapResult(result);\n const raw: unknown[] = Array.isArray(data)\n ? data\n : Array.isArray(data?.questions)\n ? data.questions\n : [];\n // The Mongoose `Question.answer` field allows numeric values for\n // numeric-answer questions. Coerce to string at the API boundary so\n // the canonical `Question.answer: string` invariant holds everywhere\n // downstream (offline games, UGC bundles, scoring code).\n return raw.map(normalizeQuestion);\n } catch {\n return [];\n }\n}\n\nfunction normalizeQuestion(raw: unknown): Question {\n const q = raw as Question & { answer: string | number };\n const answer = typeof q.answer === 'number' ? String(q.answer) : q.answer;\n return { ...q, answer };\n}\n", "/**\n * SDK discovery + auto-initialisation.\n *\n * Detects the API base URL (from the `<script>` tag or the page location)\n * and the active game slug, then exchanges a few postMessages with the\n * host to pick up an auth token and the bootstrap payload before opening\n * a session.\n *\n * The SDK is transport-agnostic: when the bootstrap carries a\n * `multiplayer` block, the values are exposed on\n * `sdk.getBootstrap().multiplayer` for the game to open its own realtime\n * connection (e.g. `new Client(wsEndpoint).reconnect(reconnectionToken)`\n * via `@colyseus/sdk`). The SDK never opens a socket itself.\n */\n\nimport { state } from './state.js';\nimport { MESSAGE_PREFIX } from './constants.js';\nimport { isBrowser, readQueryParam, warn, error as logError } from './utils.js';\nimport {\n mergeBootstrapConfig,\n requestBootstrapFromParent,\n getAuthTokenFromParent,\n sendToParent,\n} from './bridge.js';\nimport * as Session from './session.js';\n\nlet environmentDetected = false;\nlet hostListenerInstalled = false;\n\n/**\n * One-off environment detection. Should be called exactly once at SDK\n * boot time, before any other init function. Idempotent and safe to call\n * outside a browser (no-op).\n */\nexport function detectEnvironment(): void {\n if (!isBrowser() || environmentDetected) return;\n environmentDetected = true;\n state.sdkOrigin = window.location.origin;\n\n // Detect when the game is being served under /games/<slug>/ or\n // /uploaded-games/<slug>/ \u2014 used to infer the slug AND the mount point\n // (which the API base URL is built from).\n const runtimePathMatch = window.location.pathname.match(\n /^(.*)\\/(?:uploaded-games|games)\\/([a-z0-9-]+)(?:\\/|$)/i\n );\n let detectedSlug: string | null = null;\n if (runtimePathMatch) {\n state.runtimeBasePath = runtimePathMatch[1] || '';\n detectedSlug = runtimePathMatch[2] || null;\n }\n\n // Pull league/match context off the URL if present. The host may still\n // override these later via postMessage.\n state.leagueId = readQueryParam('leagueId');\n state.gameId = readQueryParam('gameId');\n state.matchId = readQueryParam('matchId');\n\n // Locate our own <script> tag so we can honour `data-game-slug` and\n // resolve the path prefix (needed when served from a subpath like /app).\n const scripts = document.getElementsByTagName('script');\n for (let i = 0; i < scripts.length; i++) {\n const src = scripts[i].src;\n if (!src.includes('gamehub-sdk.js')) continue;\n\n try {\n const parsedSrc = new URL(src, window.location.origin);\n state.sdkOrigin = parsedSrc.origin;\n const match = parsedSrc.pathname.match(/(.*)\\/sdk\\/gamehub-sdk\\.js$/);\n state.sdkPathPrefix = match ? match[1] || '' : '';\n } catch {\n const match = src.match(/(.*)\\/sdk\\/gamehub-sdk\\.js/);\n if (match) {\n const fallbackUrl = new URL(match[1], window.location.origin);\n state.sdkOrigin = fallbackUrl.origin;\n state.sdkPathPrefix = fallbackUrl.pathname || '';\n }\n }\n\n const slugAttr = scripts[i].getAttribute('data-game-slug');\n if (slugAttr) detectedSlug = slugAttr;\n break;\n }\n\n if (!detectedSlug) {\n const pathMatch = window.location.pathname.match(\n /\\/(?:uploaded-games|games)\\/([a-z0-9-]+)\\//i\n );\n if (pathMatch) detectedSlug = pathMatch[1];\n }\n\n const effectiveBasePath = state.sdkPathPrefix || state.runtimeBasePath || '';\n state.apiBase = state.sdkOrigin + effectiveBasePath + '/api';\n state.gameSlug = detectedSlug;\n}\n\n/**\n * Orchestrates the full SDK boot sequence:\n * 1. Request bootstrap config from the host (seeds slug + context).\n * 2. Exchange for an auth token if we don't already have one.\n * 3. Notify the host that we've booted.\n * 4. Open a session if we can, and reconnect to the Colyseus room when\n * the host gave us a `multiplayer` block.\n *\n * Safe to call multiple times \u2014 concurrent callers share a single promise.\n */\nexport async function autoInit(): Promise<boolean> {\n if (!isBrowser()) return false;\n if (state.isInitialized || state.isAutoInitializing) {\n return state.autoInitPromise as Promise<boolean>;\n }\n\n detectEnvironment();\n installHostMessageListener();\n\n state.isAutoInitializing = true;\n\n state.autoInitPromise = (async () => {\n try {\n await requestBootstrapFromParent();\n\n if (!state.gameSlug) {\n warn(\n 'Could not resolve game slug. Ensure the host page sends bootstrap config or serves the game under /games/{slug}.'\n );\n state.isAutoInitializing = false;\n return false;\n }\n\n if (!state.authToken) {\n state.authToken = await getAuthTokenFromParent();\n }\n state.isInitialized = true;\n state.isAutoInitializing = false;\n\n sendToParent('INIT', {\n slug: state.gameSlug,\n auto: true,\n });\n\n if (\n state.authToken ||\n (state.leagueId && state.gameId && state.matchId)\n ) {\n state.sessionStartPromise = Session.startSession();\n }\n\n return true;\n } catch (err) {\n logError('Auto-init failed:', err);\n state.isAutoInitializing = false;\n return false;\n }\n })();\n\n return state.autoInitPromise;\n}\n\n/**\n * Ensures init has at least started; callers `await` this before touching\n * any state that depends on bootstrap / auth having resolved.\n */\nexport async function ensureInitialized(): Promise<boolean> {\n if (state.isInitialized) return true;\n if (!isBrowser()) return false;\n if (state.autoInitPromise) return await state.autoInitPromise;\n return await autoInit();\n}\n\n/**\n * Wires up the ambient message listener the host uses to push updates\n * into the running SDK (fresh bootstrap, rotated auth, pause/resume).\n */\nexport function installHostMessageListener(): void {\n if (!isBrowser() || hostListenerInstalled) return;\n hostListenerInstalled = true;\n window.addEventListener('message', (event: MessageEvent) => {\n if (!event.data || !event.data.type) return;\n\n const type = event.data.type;\n\n if (type === MESSAGE_PREFIX + '_BOOTSTRAP' && event.data.payload) {\n state.parentOrigin = event.origin;\n state.bootstrapReceived = true;\n mergeBootstrapConfig(event.data.payload);\n }\n\n if (type === MESSAGE_PREFIX + '_SET_AUTH') {\n state.authToken = event.data.token;\n state.parentOrigin = event.origin;\n\n if (\n state.gameSlug &&\n !state.sessionToken &&\n !state.sessionStartPromise &&\n (state.authToken || (state.leagueId && state.gameId && state.matchId))\n ) {\n state.sessionStartPromise = Session.startSession();\n }\n }\n\n if (type === MESSAGE_PREFIX + '_COMMAND') {\n const command = event.data.command;\n const w = window as any;\n if (command === 'pause' && typeof w.onGameHubPause === 'function') {\n w.onGameHubPause();\n } else if (\n command === 'resume' &&\n typeof w.onGameHubResume === 'function'\n ) {\n w.onGameHubResume();\n }\n }\n });\n}\n", "import { state } from './state.js';\nimport { apiRequest } from './api-client.js';\nimport { unwrapResult } from './utils.js';\nimport type { MatchContext } from '../types/match.js';\n\n/**\n * Lazily load the match context for a league game. Results are cached on\n * `state.matchContext`; concurrent callers share a single in-flight request\n * via `state.matchContextPromise`.\n *\n * Resolves `null` when required context (league or match id) is missing, or\n * when the server returns an error \u2014 callers decide how to degrade.\n */\nexport async function fetchMatchContext(): Promise<MatchContext | null> {\n if (!state.leagueId || !state.matchId) return null;\n if (state.matchContext) return state.matchContext;\n if (state.matchContextPromise) return await state.matchContextPromise;\n\n state.matchContextPromise = apiRequest(\n '/leagues/' +\n encodeURIComponent(state.leagueId) +\n '/matches/' +\n encodeURIComponent(state.matchId),\n { method: 'GET' }\n )\n .then((result) => {\n const data = unwrapResult(result);\n if (result?.success && data) {\n state.matchContext = data as MatchContext;\n return state.matchContext;\n }\n return null;\n })\n .catch(() => null)\n .finally(() => {\n state.matchContextPromise = null;\n });\n\n return await state.matchContextPromise;\n}\n", "/**\n * Public SDK module entry. Exports `createSdk` (the factory) and every\n * public type.\n *\n * Importing this module has no side effects \u2014 it does not touch\n * `window`, `document`, or run any boot logic. For the legacy\n * `<script>`-tag distribution that auto-attaches `window.GameHubSDK`\n * and runs `autoInit()`, see `./browser-entry.ts`.\n *\n * The SDK is transport-agnostic. Games that need realtime multiplayer\n * read `sdk.getBootstrap().multiplayer` and open their own connection\n * (e.g. via `@colyseus/sdk`'s `client.reconnect(...)`).\n */\n\nimport { SDK_VERSION } from './constants.js';\nimport { state } from './state.js';\nimport { sendToParent } from './bridge.js';\nimport { ensureInitialized } from './init.js';\nimport { isBrowser } from './utils.js';\nimport * as Session from './session.js';\nimport * as MatchCtx from './match-context.js';\n\nimport type { BootstrapData } from '../types/bootstrap.js';\nimport type {\n EventData,\n GameCompleteData,\n Question,\n QuestionOptions,\n ReportQuestionData,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n} from '../types/session.js';\nimport type {\n MatchContext,\n MatchParticipant,\n MatchParticipantMember,\n MatchResultPayload,\n} from '../types/match.js';\n\n// Re-export public types so consumers can `import type { Sdk, ... } from\n// '@ksaa-nlp/gamehub-sdk'` without reaching into module subpaths.\nexport type { ApiRequestOptions, ApiResponse } from '../types/api.js';\nexport type {\n BootstrapConfig,\n BootstrapData,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nexport type {\n EventData,\n GameCompleteData,\n Question,\n QuestionOptions,\n ReportQuestionData,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n} from '../types/session.js';\nexport type {\n MatchContext,\n MatchParticipant,\n MatchParticipantMember,\n MatchResultPayload,\n} from '../types/match.js';\n\n/**\n * Public shape of `window.GameHubSDK` and the value returned by\n * `createSdk()`.\n *\n * Games that need realtime multiplayer read\n * `sdk.getBootstrap().multiplayer` and open their own socket \u2014 typically\n * via `new Client(wsEndpoint).reconnect(reconnectionToken)` from\n * `@colyseus/sdk`. The SDK itself has no realtime dependency.\n */\nexport interface Sdk {\n readonly version: string;\n\n /** @returns true after auto-init has resolved. */\n isInitialized(): boolean;\n /** @returns true when an auth token is currently known. */\n isAuthenticated(): boolean;\n /** @returns true when a live session token has been issued. */\n hasActiveSession(): boolean;\n\n /** Manually start a session (auto-init already attempts this). */\n startSession(): Promise<StartSessionResult>;\n\n /** Submit a final score for the current session. */\n submitScore(score: number, meta?: ScoreMetadata): Promise<SubmitScoreResult>;\n\n /** Submit a score attached to the active league match. */\n submitMatchScore(\n score: number,\n meta?: ScoreMetadata\n ): Promise<SubmitScoreResult>;\n\n /**\n * Submit a league-match result (winner, per-participant scores, etc.).\n * Use this instead of `submitMatchScore` for matches whose leaderboard\n * is derived from the result payload rather than a single score.\n */\n submitMatchResult(result?: MatchResultPayload): Promise<SubmitScoreResult>;\n\n /**\n * Fetch the league-match context for the current bootstrap (leagueId +\n * matchId). Memoised on first success; returns `null` outside a league\n * match context or on transport error.\n */\n getMatchContext(): Promise<MatchContext | null>;\n\n /** Tell the host the game has finished (shows completion UI). */\n notifyComplete(data?: GameCompleteData): void;\n\n /** Ask the host to close the game/iframe and return to the lobby. */\n requestClose(): void;\n\n /**\n * Ask the host to open the \"report this question\" dialog. The host collects\n * the reason, an optional message, and (for guests) name/email, then submits\n * the report to the platform. No-ops when the game runs outside the host\n * iframe.\n */\n reportQuestion(data: ReportQuestionData): void;\n\n /** Emit a custom analytics event to the host. */\n logEvent(eventName: string, eventData?: EventData): void;\n\n /** @returns the resolved game slug, or null if we never found one. */\n getGameSlug(): string | null;\n\n /** @returns whether the SDK is running inside an iframe. */\n isInIframe(): boolean;\n\n /** Awaitable barrier \u2014 resolves when the SDK has booted. */\n ready(): Promise<boolean>;\n\n /** @returns a snapshot of bootstrap-sourced state for debugging. */\n getBootstrap(): BootstrapData;\n\n /**\n * Fetch questions for quiz-style games. Returns [] on failure.\n * Pass `options.profileId` to select a game profile; if omitted, the\n * bootstrap-supplied `profileId` is used, else the game's default profile.\n */\n getQuestions(options?: QuestionOptions): Promise<Question[]>;\n}\n\n/**\n * Build the public API object. Methods are thin adapters that route to\n * the internal modules.\n */\nexport function createSdk(): Sdk {\n return {\n version: SDK_VERSION,\n\n isInitialized(): boolean {\n return state.isInitialized;\n },\n\n isAuthenticated(): boolean {\n return !!state.authToken;\n },\n\n hasActiveSession(): boolean {\n return !!state.sessionToken;\n },\n\n async startSession(): Promise<StartSessionResult> {\n await ensureInitialized();\n if (state.sessionStartPromise) return await state.sessionStartPromise;\n return await Session.startSession();\n },\n\n submitScore(\n score: number,\n meta: ScoreMetadata = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitScore(score, meta);\n },\n\n submitMatchScore(\n score: number,\n meta: ScoreMetadata = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitMatchScore(score, meta);\n },\n\n submitMatchResult(\n result: MatchResultPayload = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitMatchResult(result);\n },\n\n async getMatchContext(): Promise<MatchContext | null> {\n await ensureInitialized();\n return await MatchCtx.fetchMatchContext();\n },\n\n notifyComplete(data: GameCompleteData = {}): void {\n sendToParent('GAME_COMPLETE', data);\n },\n\n requestClose(): void {\n sendToParent('REQUEST_CLOSE', {});\n },\n\n reportQuestion(data: ReportQuestionData): void {\n sendToParent('QUESTION_REPORT', {\n questionId: data.questionId,\n prompt: data.prompt,\n message: data.message,\n });\n },\n\n logEvent(eventName: string, eventData: EventData = {}): void {\n sendToParent('LOG_EVENT', {\n event: eventName,\n data: eventData,\n });\n },\n\n getGameSlug(): string | null {\n return state.gameSlug;\n },\n\n isInIframe(): boolean {\n return isBrowser() && window.parent !== window;\n },\n\n async ready(): Promise<boolean> {\n return await ensureInitialized();\n },\n\n getBootstrap(): BootstrapData {\n return {\n gameSlug: state.gameSlug,\n authToken: state.authToken,\n leagueId: state.leagueId,\n gameId: state.gameId,\n matchId: state.matchId,\n mode: state.bootstrapMode,\n playerName: state.bootstrapPlayerName,\n playerCount: state.bootstrapPlayerCount,\n teamOneName: state.bootstrapTeamOneName,\n teamTwoName: state.bootstrapTeamTwoName,\n profileId: state.bootstrapProfileId,\n multiplayer: state.bootstrapMultiplayer,\n isBootstrapped: state.bootstrapReceived,\n };\n },\n\n getQuestions(options: QuestionOptions = {}): Promise<Question[]> {\n return Session.getQuestions(options);\n },\n };\n}\n", "/**\n * Script-tag entry point.\n *\n * Bundled into the legacy `gamehub-sdk.js` UMD/IIFE artifact that GameHub-\n * hosted games drop in via `<script src=\"gamehub-sdk.js\">`. Importing this\n * module (which a bundler does once when producing that artifact) attaches\n * `window.GameHubSDK`, wires up the host message listener, and runs the\n * auto-init handshake.\n *\n * This file is the ONLY place in the SDK that performs side effects on\n * load. Module / npm consumers import from `./main` instead, which is pure.\n */\n\nimport { SDK_VERSION } from './constants.js';\nimport { state } from './state.js';\nimport { sendToParent } from './bridge.js';\nimport {\n autoInit,\n detectEnvironment,\n installHostMessageListener,\n} from './init.js';\nimport { isBrowser } from './utils.js';\nimport { createSdk, type Sdk } from './main.js';\n\ndeclare global {\n interface Window {\n GameHubSDK?: Sdk;\n }\n}\n\n(function bootstrapSdk(): void {\n 'use strict';\n\n // Defensive: if a bundler accidentally pulls this entry into a non-browser\n // build, exit cleanly instead of throwing on `window.location.origin`.\n if (!isBrowser()) return;\n\n detectEnvironment();\n installHostMessageListener();\n\n const sdk = createSdk();\n window.GameHubSDK = sdk;\n\n // Announce presence to the host as soon as the script runs.\n if (window.parent !== window) {\n sendToParent('READY', { version: SDK_VERSION });\n }\n\n // Kick off auto-init if we have any signal we're embedded in GameHub:\n // either we detected a slug locally, or we're inside an iframe that might\n // feed us one. Waits for DOMContentLoaded so script tags declared after\n // us are available for the slug-detection scan.\n const hasBootSignal = !!state.gameSlug || window.parent !== window;\n if (!hasBootSignal) return;\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => {\n autoInit();\n });\n } else {\n autoInit();\n }\n})();\n"],
|
|
5
|
-
"mappings": ";;;AAGO,MAAM,cAAc;AAMpB,MAAM,iBAAiB;AAGvB,MAAM,4BAA4B;AAOlC,MAAM,sBAAsB;AAG5B,MAAM,sBAAsB;;;ACyC5B,MAAM,QAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,SAAS;AAAA,IAET,UAAU;AAAA,IACV,cAAc;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IAET,eAAe;AAAA,IACf,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,sBAAsB;AAAA,IACtB,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IAEpB,sBAAsB;AAAA,IACtB,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MAAM;AAAA,UACf,MAAM,MAAM;AAAA,UACZ,YAAY,MAAM;AAAA,UAClB,aAAa,MAAM;AAAA,UACnB,aAAa,MAAM;AAAA,UACnB,aAAa,MAAM;AAAA,UACnB,WAAW,MAAM;AAAA,UACjB,aAAa,MAAM;AAAA,UACnB,gBAAgB,MAAM;AAAA,QACxB;AAAA,MACF;AAAA,MAEA,aAAa,UAA2B,CAAC,GAAwB;AAC/D,eAAe,aAAa,OAAO;AAAA,MACrC;AAAA,IACF;AAAA,EACF;;;ACjOA,GAAC,SAAS,eAAqB;AAC7B;AAIA,QAAI,CAAC,UAAU,EAAG;AAElB,sBAAkB;AAClB,+BAA2B;AAE3B,UAAM,MAAM,UAAU;AACtB,WAAO,aAAa;AAGpB,QAAI,OAAO,WAAW,QAAQ;AAC5B,mBAAa,SAAS,EAAE,SAAS,YAAY,CAAC;AAAA,IAChD;AAMA,UAAM,gBAAgB,CAAC,CAAC,MAAM,YAAY,OAAO,WAAW;AAC5D,QAAI,CAAC,cAAe;AAEpB,QAAI,SAAS,eAAe,WAAW;AACrC,eAAS,iBAAiB,oBAAoB,MAAM;AAClD,iBAAS;AAAA,MACX,CAAC;AAAA,IACH,OAAO;AACL,eAAS;AAAA,IACX;AAAA,EACF,GAAG;",
|
|
4
|
+
"sourcesContent": ["/**\n * Bundle version reported by the SDK. Bumped at release time.\n */\nexport const SDK_VERSION = '3.7.0';\n\n/**\n * Prefix applied to every cross-origin postMessage the SDK emits and accepts.\n * Keeps our messages isolated from unrelated frames on the same page.\n */\nexport const MESSAGE_PREFIX = 'GAMEHUB_SDK';\n\n/** How long to wait for the host to reply to bootstrap/auth requests. */\nexport const PARENT_REQUEST_TIMEOUT_MS = 2000;\n\n/**\n * How long to wait for the host to proxy an HTTP API request back to the\n * SDK. Larger than {@link PARENT_REQUEST_TIMEOUT_MS} because this round-trip\n * includes the host's real network call to the GameHub backend.\n */\nexport const HOST_API_TIMEOUT_MS = 15000;\n\n/** Upper bound on questions returned per `getQuestions` call. */\nexport const QUESTIONS_LIMIT_CAP = 100;\n\n/**\n * Upper bound on words returned per `getWords` call. Set lower than\n * {@link QUESTIONS_LIMIT_CAP} because a full-nested `Word` (the whole\n * `PublicEntry` shape \u2014 senses/wordForms/relations) is much heavier than a\n * `Question`, so we bound the payload size more tightly.\n */\nexport const WORDS_LIMIT_CAP = 50;\n", "/**\n * Centralised mutable state for the SDK singleton.\n *\n * Everything here lives on a single `state` object so feature modules\n * can mutate it (`state.foo = bar`). ES modules don't allow reassigning\n * imported `let` bindings from the consumer side, so a single shared\n * object is the cleanest replacement for the namespace + `export let`\n * pattern used in earlier SDK versions.\n */\n\nimport type {\n BootstrapConfig,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nimport type { MatchContext } from '../types/match.js';\nimport type { StartSessionResult } from '../types/session.js';\n\nexport interface SdkState {\n // --- API endpoint resolution -------------------------------------------\n sdkOrigin: string;\n sdkPathPrefix: string;\n runtimeBasePath: string;\n apiBase: string;\n\n // --- Game / league context ---------------------------------------------\n gameSlug: string | null;\n sessionToken: string | null;\n authToken: string | null;\n leagueId: string | null;\n gameId: string | null;\n matchId: string | null;\n\n // --- Free-form bootstrap fields (display only) -------------------------\n bootstrapMode: string | null;\n bootstrapPlayerName: string | null;\n bootstrapPlayerCount: string | null;\n bootstrapTeamOneName: string | null;\n bootstrapTeamTwoName: string | null;\n /** Player's pre-start profile choice; default for `getQuestions`. */\n bootstrapProfileId: string | null;\n\n // --- Multiplayer bootstrap ---------------------------------------------\n // Opaque to the SDK \u2014 exposed verbatim on `getBootstrap().multiplayer`\n // for games to feed into their realtime client (e.g. `@colyseus/sdk`'s\n // `client.reconnect(...)`). The SDK does not open or manage the socket.\n bootstrapMultiplayer: BootstrapMultiplayer | null;\n bootstrapReceived: boolean;\n\n // --- Initialisation lifecycle ------------------------------------------\n isInitialized: boolean;\n isAutoInitializing: boolean;\n autoInitPromise: Promise<boolean> | null;\n bootstrapRequestPromise: Promise<BootstrapConfig | null> | null;\n parentOrigin: string | null;\n sessionStartPromise: Promise<StartSessionResult> | null;\n\n // --- League match context (HTTP) ---------------------------------------\n /** Cached league match context, loaded on demand. */\n matchContext: MatchContext | null;\n /** In-flight match-context fetch, deduped across callers. */\n matchContextPromise: Promise<MatchContext | null> | null;\n}\n\nexport const state: SdkState = {\n sdkOrigin: '',\n sdkPathPrefix: '',\n runtimeBasePath: '',\n apiBase: '',\n\n gameSlug: null,\n sessionToken: null,\n authToken: null,\n leagueId: null,\n gameId: null,\n matchId: null,\n\n bootstrapMode: null,\n bootstrapPlayerName: null,\n bootstrapPlayerCount: null,\n bootstrapTeamOneName: null,\n bootstrapTeamTwoName: null,\n bootstrapProfileId: null,\n\n bootstrapMultiplayer: null,\n bootstrapReceived: false,\n\n isInitialized: false,\n isAutoInitializing: false,\n autoInitPromise: null,\n bootstrapRequestPromise: null,\n parentOrigin: null,\n sessionStartPromise: null,\n\n matchContext: null,\n matchContextPromise: null,\n};\n", "import type { ApiResponse } from '../types/api.js';\n\n/**\n * True when running in a browser-like environment (has both `window` and\n * `document`). Used to short-circuit DOM-touching helpers so the package\n * can be imported under Node / Angular SSR without throwing.\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Logs with a consistent `[GameHubSDK]` prefix so host-page developers can\n * easily filter SDK messages in their console.\n */\nexport function warn(message: string, ...rest: any[]): void {\n console.warn('[GameHubSDK] ' + message, ...rest);\n}\n\nexport function error(message: string, ...rest: any[]): void {\n console.error('[GameHubSDK] ' + message, ...rest);\n}\n\n/**\n * Flattens the standard `{ success, data }` envelope returned by the\n * GameHub REST API down to the inner `data` payload. Returns the raw\n * response when the envelope shape doesn't apply.\n */\nexport function unwrapResult(result: ApiResponse | null | undefined): any {\n if (!result) return null;\n if (result.success && result.data) return result.data;\n return result;\n}\n\n/**\n * Safely read a query-string parameter, falling back to a regex scan when\n * URLSearchParams is unavailable (very old browsers / odd runtimes).\n */\nexport function readQueryParam(name: string): string | null {\n try {\n const params = new URLSearchParams(window.location.search);\n return params.get(name);\n } catch {\n const match = window.location.search.match(\n new RegExp('[?&]' + name + '=([^&]+)')\n );\n return match ? decodeURIComponent(match[1]) : null;\n }\n}\n", "/**\n * Cross-origin communication layer between the game iframe and its host page.\n *\n * Messages are namespaced with `MESSAGE_PREFIX` so we don't pick up\n * unrelated postMessage traffic. The host implements a small protocol:\n * - `BOOTSTRAP_REQUEST` \u21C4 `BOOTSTRAP` (initial config + multiplayer)\n * - `AUTH_REQUEST` \u21C4 `AUTH_RESPONSE` (refresh the bearer token)\n * - `READY` / `INIT` / `SESSION_STARTED` / `SCORE_SUBMITTED` / etc.\n * (one-way SDK \u2192 host signals)\n */\n\nimport { state } from './state.js';\nimport {\n MESSAGE_PREFIX,\n PARENT_REQUEST_TIMEOUT_MS,\n HOST_API_TIMEOUT_MS,\n} from './constants.js';\nimport { isBrowser } from './utils.js';\nimport type {\n BootstrapConfig,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nimport type { ApiResponse, ApiRequestOptions } from '../types/api.js';\n\nfunction trimToNullable(value: unknown): string | null | undefined {\n if (value === null) return null;\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n return trimmed ? trimmed : null;\n}\n\nfunction parseMultiplayer(\n value: BootstrapConfig['multiplayer']\n): BootstrapMultiplayer | null | undefined {\n if (value === null) return null;\n if (!value || typeof value !== 'object') return undefined;\n const { reservation, wsEndpoint } = value;\n if (\n !reservation ||\n typeof reservation !== 'object' ||\n typeof (reservation as { name?: unknown }).name !== 'string' ||\n typeof (reservation as { sessionId?: unknown }).sessionId !== 'string' ||\n typeof (reservation as { roomId?: unknown }).roomId !== 'string' ||\n typeof wsEndpoint !== 'string'\n ) {\n return undefined;\n }\n return {\n reservation,\n wsEndpoint: wsEndpoint.trim(),\n };\n}\n\n/**\n * Fold a {@link BootstrapConfig} from the host into internal state. Accepts\n * partial configs: only fields the host explicitly set (including explicit\n * `null`s used to clear a value) are applied.\n */\nexport function mergeBootstrapConfig(config: BootstrapConfig = {}): void {\n if (!config || typeof config !== 'object') return;\n\n const apply = (\n key: 'gameSlug' | 'authToken' | 'leagueId' | 'gameId' | 'matchId',\n raw: unknown\n ) => {\n const next = trimToNullable(raw);\n if (next === undefined) return;\n state[key] = next;\n };\n\n apply('gameSlug', config.gameSlug);\n apply('authToken', config.authToken);\n apply('leagueId', config.leagueId);\n apply('gameId', config.gameId);\n apply('matchId', config.matchId);\n\n const applyBootstrap = (\n key:\n | 'bootstrapMode'\n | 'bootstrapPlayerName'\n | 'bootstrapPlayerCount'\n | 'bootstrapTeamOneName'\n | 'bootstrapTeamTwoName'\n | 'bootstrapProfileId',\n raw: unknown\n ) => {\n const next = trimToNullable(raw);\n if (next === undefined) return;\n state[key] = next;\n };\n\n applyBootstrap('bootstrapMode', config.mode);\n applyBootstrap('bootstrapPlayerName', config.playerName);\n applyBootstrap('bootstrapPlayerCount', config.playerCount);\n applyBootstrap('bootstrapTeamOneName', config.teamOneName);\n applyBootstrap('bootstrapTeamTwoName', config.teamTwoName);\n applyBootstrap('bootstrapProfileId', config.profileId);\n\n const mp = parseMultiplayer(config.multiplayer);\n if (mp !== undefined) {\n state.bootstrapMultiplayer = mp;\n }\n}\n\nfunction snapshotBootstrap(): BootstrapConfig {\n return {\n gameSlug: state.gameSlug,\n authToken: state.authToken,\n leagueId: state.leagueId,\n gameId: state.gameId,\n matchId: state.matchId,\n mode: state.bootstrapMode,\n playerName: state.bootstrapPlayerName,\n playerCount: state.bootstrapPlayerCount,\n teamOneName: state.bootstrapTeamOneName,\n teamTwoName: state.bootstrapTeamTwoName,\n profileId: state.bootstrapProfileId,\n multiplayer: state.bootstrapMultiplayer,\n };\n}\n\n/**\n * Ask the host for its bootstrap payload. Resolves `null` if the game is\n * standalone (no parent) or the host doesn't reply within the timeout.\n *\n * Subsequent calls after a successful bootstrap short-circuit to the\n * cached state snapshot.\n */\nexport function requestBootstrapFromParent(): Promise<BootstrapConfig | null> {\n if (!isBrowser() || window.parent === window) {\n return Promise.resolve(null);\n }\n\n if (state.bootstrapReceived) {\n return Promise.resolve(snapshotBootstrap());\n }\n\n if (state.bootstrapRequestPromise) {\n return state.bootstrapRequestPromise;\n }\n\n state.bootstrapRequestPromise = new Promise<BootstrapConfig | null>(\n (resolve) => {\n const messageId = Date.now().toString();\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n event.data &&\n event.data.type === MESSAGE_PREFIX + '_BOOTSTRAP' &&\n event.data.payload\n ) {\n if (event.data.messageId && event.data.messageId !== messageId) {\n return;\n }\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n state.bootstrapReceived = true;\n mergeBootstrapConfig(event.data.payload);\n resolve(event.data.payload);\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_BOOTSTRAP_REQUEST',\n messageId,\n },\n '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n resolve(null);\n }, PARENT_REQUEST_TIMEOUT_MS);\n }\n ).finally(() => {\n state.bootstrapRequestPromise = null;\n });\n\n return state.bootstrapRequestPromise;\n}\n\n/**\n * Ask the host for a fresh auth token. The host may also use the response\n * to override league/match context \u2014 when it does, we prefer its values.\n */\nexport function getAuthTokenFromParent(): Promise<string | null> {\n return new Promise((resolve) => {\n if (!isBrowser() || window.parent === window) {\n resolve(null);\n return;\n }\n\n const messageId = Date.now().toString();\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n event.data &&\n event.data.type === MESSAGE_PREFIX + '_AUTH_RESPONSE' &&\n event.data.messageId === messageId\n ) {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n if (event.data.leagueId) state.leagueId = event.data.leagueId;\n if (event.data.gameId) state.gameId = event.data.gameId;\n if (event.data.matchId) state.matchId = event.data.matchId;\n resolve(event.data.token || null);\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n { type: MESSAGE_PREFIX + '_AUTH_REQUEST', messageId },\n '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n resolve(null);\n }, PARENT_REQUEST_TIMEOUT_MS);\n });\n}\n\n/** Monotonic counter so concurrent API proxy requests get distinct ids. */\nlet apiRequestSeq = 0;\n\n/**\n * Proxy an HTTP request to the GameHub backend through the host page.\n *\n * The host frame is same-origin with the GameHub API, so it performs the\n * real `fetch` and posts the parsed JSON envelope back. This keeps the SDK\n * (and the game it lives in) from ever issuing a cross-origin request to the\n * backend \u2014 which would otherwise fail CORS when the game is served from a\n * different domain than GameHub.\n *\n * The protocol mirrors the bootstrap/auth handshakes: a `messageId`-keyed\n * `API_REQUEST` is answered by exactly one `API_RESPONSE`. Resolves with the\n * parsed {@link ApiResponse}; rejects on host-reported failure or timeout so\n * the existing per-call `try/catch` degradation paths fire unchanged.\n */\nexport function requestApiFromParent(\n endpoint: string,\n options: ApiRequestOptions = {}\n): Promise<ApiResponse> {\n return new Promise<ApiResponse>((resolve, reject) => {\n if (!isBrowser() || window.parent === window) {\n reject(new Error('Host bridge unavailable: not running in an iframe'));\n return;\n }\n\n const messageId = 'api_' + Date.now().toString() + '_' + ++apiRequestSeq;\n let settled = false;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const handler = (event: MessageEvent) => {\n if (\n !event.data ||\n event.data.type !== MESSAGE_PREFIX + '_API_RESPONSE' ||\n event.data.messageId !== messageId\n ) {\n return;\n }\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n if (timeoutId) clearTimeout(timeoutId);\n state.parentOrigin = event.origin;\n if (event.data.ok) {\n resolve((event.data.result ?? {}) as ApiResponse);\n } else {\n reject(new Error(event.data.error || 'Host API request failed'));\n }\n };\n\n window.addEventListener('message', handler);\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_API_REQUEST',\n messageId,\n endpoint,\n method: options.method || 'GET',\n body: options.body ?? null,\n },\n state.parentOrigin || '*'\n );\n\n timeoutId = setTimeout(() => {\n if (settled) return;\n settled = true;\n window.removeEventListener('message', handler);\n reject(new Error('Host API request timed out'));\n }, HOST_API_TIMEOUT_MS);\n });\n}\n\n/**\n * Fire a namespaced message up to the host window. Silently no-ops when\n * we aren't inside an iframe.\n */\nexport function sendToParent(type: string, data: Record<string, any>): void {\n if (!isBrowser() || window.parent === window) return;\n window.parent.postMessage(\n {\n type: MESSAGE_PREFIX + '_' + type,\n gameSlug: state.gameSlug,\n ...data,\n },\n state.parentOrigin || '*'\n );\n}\n", "import { state } from './state.js';\nimport { isBrowser } from './utils.js';\nimport { requestApiFromParent } from './bridge.js';\nimport type { ApiResponse, ApiRequestOptions } from '../types/api.js';\n\n/**\n * Performs a request against the GameHub REST API and parses the JSON\n * response.\n *\n * Transport is chosen by context:\n * - **Inside the host iframe** the request is proxied through the host via\n * postMessage ({@link requestApiFromParent}). The host is same-origin\n * with the GameHub backend, so the game never issues a cross-origin call\n * itself \u2014 this is what keeps the SDK CORS-free when the game is served\n * from a different domain than GameHub.\n * - **Standalone** (dev harness / a game served from the GameHub origin)\n * the SDK calls the backend directly, prefixing the configured API base\n * and attaching the Bearer auth token when available.\n *\n * Throws whatever the transport throws (host failure/timeout, or\n * `fetch`/`JSON.parse`) \u2014 callers decide whether to retry, fall back, or\n * surface the error to the host.\n */\nexport async function apiRequest(\n endpoint: string,\n options: ApiRequestOptions = {}\n): Promise<ApiResponse> {\n // When embedded, let the host (same-origin with the API) make the call.\n if (isBrowser() && window.parent !== window) {\n return requestApiFromParent(endpoint, options);\n }\n\n const url = state.apiBase + endpoint;\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...(options.headers || {}),\n };\n\n if (state.authToken) {\n headers.Authorization = 'Bearer ' + state.authToken;\n }\n\n const response = await fetch(url, {\n ...options,\n credentials: options.credentials || 'same-origin',\n headers,\n body: options.body ? JSON.stringify(options.body) : undefined,\n });\n\n return response.json();\n}\n", "import { state } from './state.js';\nimport { QUESTIONS_LIMIT_CAP, WORDS_LIMIT_CAP } from './constants.js';\nimport { apiRequest } from './api-client.js';\nimport { unwrapResult } from './utils.js';\nimport { sendToParent } from './bridge.js';\nimport { ensureInitialized } from './init.js';\nimport type {\n Question,\n QuestionOptions,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n Word,\n WordOptions,\n} from '../types/session.js';\nimport type { MatchResultPayload } from '../types/match.js';\n\n/**\n * Starts a new game session and caches the returned session token. Safe\n * to call multiple times \u2014 the cached token short-circuits subsequent\n * calls.\n *\n * Endpoint is selected from the active context:\n * - league + game + match \u2192 scoped match session\n * - league + game \u2192 scoped league session\n * - otherwise \u2192 standalone session (requires auth)\n */\nexport async function startSession(): Promise<StartSessionResult> {\n if (!state.gameSlug) return { success: false, error: 'Game slug not set' };\n\n const isLeagueMatchSession = Boolean(\n state.leagueId && state.gameId && state.matchId\n );\n if (!state.authToken && !isLeagueMatchSession) {\n return { success: false, error: 'User not authenticated' };\n }\n if (state.sessionToken) return { success: true, token: state.sessionToken };\n\n try {\n let endpoint = '/sessions/start';\n let body: Record<string, any> = { gameSlug: state.gameSlug };\n\n if (state.leagueId && state.gameId && state.matchId) {\n endpoint =\n '/leagues/' + state.leagueId + '/matches/' + state.matchId + '/session';\n body = { gameId: state.gameId };\n } else if (state.leagueId && state.gameId) {\n endpoint = '/leagues/' + state.leagueId + '/sessions';\n body = { gameId: state.gameId };\n }\n\n const result = await apiRequest(endpoint, {\n method: 'POST',\n body,\n });\n\n const data = unwrapResult(result);\n if (result.success || data?.token) {\n state.sessionToken = data?.token || result?.token || null;\n sendToParent('SESSION_STARTED', { token: state.sessionToken });\n return { success: true, token: state.sessionToken };\n }\n\n return {\n success: false,\n error: result.error?.message || 'Failed to start session',\n };\n } catch (err: any) {\n return { success: false, error: err.message };\n }\n}\n\n/**\n * Submit a score to the current session. If no session exists yet we try\n * to open one (re-using any in-flight start attempt).\n *\n * Multiplayer authority lives on the Colyseus server now \u2014 score\n * submission is no longer gated by a client-side host role. Games that\n * want only one peer to call this should make that decision based on\n * their room state (e.g. `room.state.hostPeerId === selfId`).\n */\nexport async function submitScore(\n score: number,\n meta: ScoreMetadata = {}\n): Promise<SubmitScoreResult> {\n await ensureInitialized();\n\n if (!state.isInitialized) {\n return {\n success: false,\n error: 'SDK could not initialize. Is game slug set?',\n };\n }\n\n if (!state.sessionToken) {\n if (state.sessionStartPromise) {\n await state.sessionStartPromise;\n } else {\n const sessionResult = await startSession();\n if (!sessionResult.success) {\n return {\n success: false,\n error: sessionResult.error || 'Could not start session',\n };\n }\n }\n }\n\n if (!state.sessionToken) {\n return {\n success: false,\n error: 'No active session. User may not be authenticated.',\n };\n }\n\n if (typeof score !== 'number' || score < 0) {\n return { success: false, error: 'Score must be a non-negative number' };\n }\n\n try {\n const result = await apiRequest('/sessions/submit', {\n method: 'POST',\n body: {\n token: state.sessionToken,\n score: Math.floor(score),\n meta,\n },\n });\n\n const data = unwrapResult(result);\n\n if (result.success || data?.accepted) {\n sendToParent('SCORE_SUBMITTED', {\n score,\n accepted: data?.accepted,\n timeTaken: data?.timeTaken,\n });\n return {\n success: true,\n accepted: data?.accepted,\n timeTaken: data?.timeTaken,\n };\n }\n\n return {\n success: false,\n error: result.error?.message || 'Score rejected',\n };\n } catch (err: any) {\n return { success: false, error: err.message };\n }\n}\n\n/**\n * Convenience wrapper that tags a score with the current league match\n * context. Fails early if there's no matchId \u2014 a plain `submitScore` is\n * the right call in that case.\n */\nexport async function submitMatchScore(\n score: number,\n meta: ScoreMetadata = {}\n): Promise<SubmitScoreResult> {\n if (!state.matchId) {\n return {\n success: false,\n error: 'No matchId found for this game session',\n };\n }\n\n return await submitScore(score, {\n ...(meta || {}),\n matchId: state.matchId,\n leagueId: state.leagueId || meta.leagueId,\n gameId: state.gameId || meta.gameId,\n });\n}\n\n/**\n * Submit a match result (winner, scores, etc.) with a zero placeholder\n * score \u2014 the server derives the real leaderboard entries from the result\n * payload.\n */\nexport async function submitMatchResult(\n result: MatchResultPayload = {}\n): Promise<SubmitScoreResult> {\n if (!result || typeof result !== 'object') {\n return { success: false, error: 'match result payload is required' };\n }\n\n return await submitMatchScore(0, { matchResult: result });\n}\n\n/**\n * Fetch questions for this game. Returns an empty array on any failure\n * or invalid input \u2014 callers can treat \"no questions\" as the degraded\n * state.\n */\nexport async function getQuestions(\n options: QuestionOptions = {}\n): Promise<Question[]> {\n await ensureInitialized();\n\n const gameIdentifier = state.gameId || state.gameSlug;\n if (!gameIdentifier) return [];\n\n const { difficulty, category, limit } = options;\n\n if (difficulty && !['easy', 'medium', 'hard'].includes(difficulty)) {\n return [];\n }\n\n if (limit !== undefined && (typeof limit !== 'number' || limit < 1)) {\n return [];\n }\n\n // Profile selection: explicit option wins, else the bootstrap-supplied\n // profileId (the player's pre-start picker choice). Omitted \u2192 resolver\n // falls back to the game's isDefault profile (identical to today).\n const profileId = options.profileId || state.bootstrapProfileId || '';\n\n try {\n const params = new URLSearchParams({\n limit: String(\n Math.min(limit || QUESTIONS_LIMIT_CAP, QUESTIONS_LIMIT_CAP)\n ),\n random: 'true',\n });\n if (state.gameId) params.set('gameId', state.gameId);\n if (difficulty) params.set('difficulty', difficulty);\n if (category) params.set('category', String(category));\n if (profileId) params.set('profileId', profileId);\n\n const result = await apiRequest(\n '/games/' +\n encodeURIComponent(gameIdentifier) +\n '/questions?' +\n params.toString(),\n { method: 'GET' }\n );\n\n const data = unwrapResult(result);\n const raw: unknown[] = Array.isArray(data)\n ? data\n : Array.isArray(data?.questions)\n ? data.questions\n : [];\n // The Mongoose `Question.answer` field allows numeric values for\n // numeric-answer questions. Coerce to string at the API boundary so\n // the canonical `Question.answer: string` invariant holds everywhere\n // downstream (offline games, UGC bundles, scoring code).\n return raw.map(normalizeQuestion);\n } catch {\n return [];\n }\n}\n\nfunction normalizeQuestion(raw: unknown): Question {\n const q = raw as Question & { answer: string | number };\n const answer = typeof q.answer === 'number' ? String(q.answer) : q.answer;\n return { ...q, answer };\n}\n\n/**\n * Fetch words for this game (Words Bank feature). Mirrors {@link getQuestions}:\n * returns an empty array on any failure or invalid input. The served payload is\n * a near-passthrough of the gamehub `Word`, so no normalization is needed.\n */\nexport async function getWords(options: WordOptions = {}): Promise<Word[]> {\n await ensureInitialized();\n\n const gameIdentifier = state.gameId || state.gameSlug;\n if (!gameIdentifier) return [];\n\n const { difficulty, category, tags, limit } = options;\n\n if (difficulty && !['easy', 'medium', 'hard'].includes(difficulty)) {\n return [];\n }\n\n if (limit !== undefined && (typeof limit !== 'number' || limit < 1)) {\n return [];\n }\n\n // Profile selection: explicit option wins, else the bootstrap-supplied\n // profileId. Omitted \u2192 resolver falls back to the game's isDefault profile.\n const profileId = options.profileId || state.bootstrapProfileId || '';\n\n try {\n const params = new URLSearchParams({\n limit: String(Math.min(limit || WORDS_LIMIT_CAP, WORDS_LIMIT_CAP)),\n random: 'true',\n });\n if (state.gameId) params.set('gameId', state.gameId);\n if (difficulty) params.set('difficulty', difficulty);\n if (category) params.set('category', String(category));\n if (Array.isArray(tags) && tags.length > 0) {\n params.set('tags', tags.join(','));\n }\n if (profileId) params.set('profileId', profileId);\n\n const result = await apiRequest(\n '/games/' +\n encodeURIComponent(gameIdentifier) +\n '/words?' +\n params.toString(),\n { method: 'GET' }\n );\n\n const data = unwrapResult(result);\n const raw: unknown[] = Array.isArray(data)\n ? data\n : Array.isArray(data?.words)\n ? data.words\n : [];\n return raw as Word[];\n } catch {\n return [];\n }\n}\n", "/**\n * SDK discovery + auto-initialisation.\n *\n * Detects the API base URL (from the `<script>` tag or the page location)\n * and the active game slug, then exchanges a few postMessages with the\n * host to pick up an auth token and the bootstrap payload before opening\n * a session.\n *\n * The SDK is transport-agnostic: when the bootstrap carries a\n * `multiplayer` block, the values are exposed on\n * `sdk.getBootstrap().multiplayer` for the game to open its own realtime\n * connection (e.g. `new Client(wsEndpoint).reconnect(reconnectionToken)`\n * via `@colyseus/sdk`). The SDK never opens a socket itself.\n */\n\nimport { state } from './state.js';\nimport { MESSAGE_PREFIX } from './constants.js';\nimport { isBrowser, readQueryParam, warn, error as logError } from './utils.js';\nimport {\n mergeBootstrapConfig,\n requestBootstrapFromParent,\n getAuthTokenFromParent,\n sendToParent,\n} from './bridge.js';\nimport * as Session from './session.js';\n\nlet environmentDetected = false;\nlet hostListenerInstalled = false;\n\n/**\n * One-off environment detection. Should be called exactly once at SDK\n * boot time, before any other init function. Idempotent and safe to call\n * outside a browser (no-op).\n */\nexport function detectEnvironment(): void {\n if (!isBrowser() || environmentDetected) return;\n environmentDetected = true;\n state.sdkOrigin = window.location.origin;\n\n // Detect when the game is being served under /games/<slug>/ or\n // /uploaded-games/<slug>/ \u2014 used to infer the slug AND the mount point\n // (which the API base URL is built from).\n const runtimePathMatch = window.location.pathname.match(\n /^(.*)\\/(?:uploaded-games|games)\\/([a-z0-9-]+)(?:\\/|$)/i\n );\n let detectedSlug: string | null = null;\n if (runtimePathMatch) {\n state.runtimeBasePath = runtimePathMatch[1] || '';\n detectedSlug = runtimePathMatch[2] || null;\n }\n\n // Pull league/match context off the URL if present. The host may still\n // override these later via postMessage.\n state.leagueId = readQueryParam('leagueId');\n state.gameId = readQueryParam('gameId');\n state.matchId = readQueryParam('matchId');\n\n // Locate our own <script> tag so we can honour `data-game-slug` and\n // resolve the path prefix (needed when served from a subpath like /app).\n const scripts = document.getElementsByTagName('script');\n for (let i = 0; i < scripts.length; i++) {\n const src = scripts[i].src;\n if (!src.includes('gamehub-sdk.js')) continue;\n\n try {\n const parsedSrc = new URL(src, window.location.origin);\n state.sdkOrigin = parsedSrc.origin;\n const match = parsedSrc.pathname.match(/(.*)\\/sdk\\/gamehub-sdk\\.js$/);\n state.sdkPathPrefix = match ? match[1] || '' : '';\n } catch {\n const match = src.match(/(.*)\\/sdk\\/gamehub-sdk\\.js/);\n if (match) {\n const fallbackUrl = new URL(match[1], window.location.origin);\n state.sdkOrigin = fallbackUrl.origin;\n state.sdkPathPrefix = fallbackUrl.pathname || '';\n }\n }\n\n const slugAttr = scripts[i].getAttribute('data-game-slug');\n if (slugAttr) detectedSlug = slugAttr;\n break;\n }\n\n if (!detectedSlug) {\n const pathMatch = window.location.pathname.match(\n /\\/(?:uploaded-games|games)\\/([a-z0-9-]+)\\//i\n );\n if (pathMatch) detectedSlug = pathMatch[1];\n }\n\n const effectiveBasePath = state.sdkPathPrefix || state.runtimeBasePath || '';\n state.apiBase = state.sdkOrigin + effectiveBasePath + '/api';\n state.gameSlug = detectedSlug;\n}\n\n/**\n * Orchestrates the full SDK boot sequence:\n * 1. Request bootstrap config from the host (seeds slug + context).\n * 2. Exchange for an auth token if we don't already have one.\n * 3. Notify the host that we've booted.\n * 4. Open a session if we can, and reconnect to the Colyseus room when\n * the host gave us a `multiplayer` block.\n *\n * Safe to call multiple times \u2014 concurrent callers share a single promise.\n */\nexport async function autoInit(): Promise<boolean> {\n if (!isBrowser()) return false;\n if (state.isInitialized || state.isAutoInitializing) {\n return state.autoInitPromise as Promise<boolean>;\n }\n\n detectEnvironment();\n installHostMessageListener();\n\n state.isAutoInitializing = true;\n\n state.autoInitPromise = (async () => {\n try {\n await requestBootstrapFromParent();\n\n if (!state.gameSlug) {\n warn(\n 'Could not resolve game slug. Ensure the host page sends bootstrap config or serves the game under /games/{slug}.'\n );\n state.isAutoInitializing = false;\n return false;\n }\n\n if (!state.authToken) {\n state.authToken = await getAuthTokenFromParent();\n }\n state.isInitialized = true;\n state.isAutoInitializing = false;\n\n sendToParent('INIT', {\n slug: state.gameSlug,\n auto: true,\n });\n\n if (\n state.authToken ||\n (state.leagueId && state.gameId && state.matchId)\n ) {\n state.sessionStartPromise = Session.startSession();\n }\n\n return true;\n } catch (err) {\n logError('Auto-init failed:', err);\n state.isAutoInitializing = false;\n return false;\n }\n })();\n\n return state.autoInitPromise;\n}\n\n/**\n * Ensures init has at least started; callers `await` this before touching\n * any state that depends on bootstrap / auth having resolved.\n */\nexport async function ensureInitialized(): Promise<boolean> {\n if (state.isInitialized) return true;\n if (!isBrowser()) return false;\n if (state.autoInitPromise) return await state.autoInitPromise;\n return await autoInit();\n}\n\n/**\n * Wires up the ambient message listener the host uses to push updates\n * into the running SDK (fresh bootstrap, rotated auth, pause/resume).\n */\nexport function installHostMessageListener(): void {\n if (!isBrowser() || hostListenerInstalled) return;\n hostListenerInstalled = true;\n window.addEventListener('message', (event: MessageEvent) => {\n if (!event.data || !event.data.type) return;\n\n const type = event.data.type;\n\n if (type === MESSAGE_PREFIX + '_BOOTSTRAP' && event.data.payload) {\n state.parentOrigin = event.origin;\n state.bootstrapReceived = true;\n mergeBootstrapConfig(event.data.payload);\n }\n\n if (type === MESSAGE_PREFIX + '_SET_AUTH') {\n state.authToken = event.data.token;\n state.parentOrigin = event.origin;\n\n if (\n state.gameSlug &&\n !state.sessionToken &&\n !state.sessionStartPromise &&\n (state.authToken || (state.leagueId && state.gameId && state.matchId))\n ) {\n state.sessionStartPromise = Session.startSession();\n }\n }\n\n if (type === MESSAGE_PREFIX + '_COMMAND') {\n const command = event.data.command;\n const w = window as any;\n if (command === 'pause' && typeof w.onGameHubPause === 'function') {\n w.onGameHubPause();\n } else if (\n command === 'resume' &&\n typeof w.onGameHubResume === 'function'\n ) {\n w.onGameHubResume();\n }\n }\n });\n}\n", "import { state } from './state.js';\nimport { apiRequest } from './api-client.js';\nimport { unwrapResult } from './utils.js';\nimport type { MatchContext } from '../types/match.js';\n\n/**\n * Lazily load the match context for a league game. Results are cached on\n * `state.matchContext`; concurrent callers share a single in-flight request\n * via `state.matchContextPromise`.\n *\n * Resolves `null` when required context (league or match id) is missing, or\n * when the server returns an error \u2014 callers decide how to degrade.\n */\nexport async function fetchMatchContext(): Promise<MatchContext | null> {\n if (!state.leagueId || !state.matchId) return null;\n if (state.matchContext) return state.matchContext;\n if (state.matchContextPromise) return await state.matchContextPromise;\n\n state.matchContextPromise = apiRequest(\n '/leagues/' +\n encodeURIComponent(state.leagueId) +\n '/matches/' +\n encodeURIComponent(state.matchId),\n { method: 'GET' }\n )\n .then((result) => {\n const data = unwrapResult(result);\n if (result?.success && data) {\n state.matchContext = data as MatchContext;\n return state.matchContext;\n }\n return null;\n })\n .catch(() => null)\n .finally(() => {\n state.matchContextPromise = null;\n });\n\n return await state.matchContextPromise;\n}\n", "/**\n * Public SDK module entry. Exports `createSdk` (the factory) and every\n * public type.\n *\n * Importing this module has no side effects \u2014 it does not touch\n * `window`, `document`, or run any boot logic. For the legacy\n * `<script>`-tag distribution that auto-attaches `window.GameHubSDK`\n * and runs `autoInit()`, see `./browser-entry.ts`.\n *\n * The SDK is transport-agnostic. Games that need realtime multiplayer\n * read `sdk.getBootstrap().multiplayer` and open their own connection\n * (e.g. via `@colyseus/sdk`'s `client.reconnect(...)`).\n */\n\nimport { SDK_VERSION } from './constants.js';\nimport { state } from './state.js';\nimport { sendToParent } from './bridge.js';\nimport { ensureInitialized } from './init.js';\nimport { isBrowser } from './utils.js';\nimport * as Session from './session.js';\nimport * as MatchCtx from './match-context.js';\n\nimport type { BootstrapData } from '../types/bootstrap.js';\nimport type {\n EventData,\n GameCompleteData,\n Question,\n QuestionOptions,\n ReportQuestionData,\n ReportWordData,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n Word,\n WordOptions,\n} from '../types/session.js';\nimport type {\n MatchContext,\n MatchParticipant,\n MatchParticipantMember,\n MatchResultPayload,\n} from '../types/match.js';\n\n// Re-export public types so consumers can `import type { Sdk, ... } from\n// '@ksaa-nlp/gamehub-sdk'` without reaching into module subpaths.\nexport type { ApiRequestOptions, ApiResponse } from '../types/api.js';\nexport type {\n BootstrapConfig,\n BootstrapData,\n BootstrapMultiplayer,\n} from '../types/bootstrap.js';\nexport type {\n EventData,\n GameCompleteData,\n Question,\n QuestionDifficulty,\n QuestionOptions,\n ReportableQuestion,\n ReportableWord,\n ReportQuestionData,\n ReportWordData,\n ScoreMetadata,\n StartSessionResult,\n SubmitScoreResult,\n Word,\n WordDifficulty,\n WordOptions,\n} from '../types/session.js';\nexport type {\n FormRepresentation,\n Lookup,\n Synset,\n SynsetNameTranslation,\n DynamicProp,\n DynamicProperty,\n WordForm,\n WordSense,\n WordSenseExample,\n WordSenseTranslation,\n WordSenseRelation,\n WordMetaData,\n WordRelation,\n} from '../types/word.js';\nexport type {\n MatchContext,\n MatchParticipant,\n MatchParticipantMember,\n MatchResultPayload,\n} from '../types/match.js';\n\n/**\n * Public shape of `window.GameHubSDK` and the value returned by\n * `createSdk()`.\n *\n * Games that need realtime multiplayer read\n * `sdk.getBootstrap().multiplayer` and open their own socket \u2014 typically\n * via `new Client(wsEndpoint).reconnect(reconnectionToken)` from\n * `@colyseus/sdk`. The SDK itself has no realtime dependency.\n */\nexport interface Sdk {\n readonly version: string;\n\n /** @returns true after auto-init has resolved. */\n isInitialized(): boolean;\n /** @returns true when an auth token is currently known. */\n isAuthenticated(): boolean;\n /** @returns true when a live session token has been issued. */\n hasActiveSession(): boolean;\n\n /** Manually start a session (auto-init already attempts this). */\n startSession(): Promise<StartSessionResult>;\n\n /** Submit a final score for the current session. */\n submitScore(score: number, meta?: ScoreMetadata): Promise<SubmitScoreResult>;\n\n /** Submit a score attached to the active league match. */\n submitMatchScore(\n score: number,\n meta?: ScoreMetadata\n ): Promise<SubmitScoreResult>;\n\n /**\n * Submit a league-match result (winner, per-participant scores, etc.).\n * Use this instead of `submitMatchScore` for matches whose leaderboard\n * is derived from the result payload rather than a single score.\n */\n submitMatchResult(result?: MatchResultPayload): Promise<SubmitScoreResult>;\n\n /**\n * Fetch the league-match context for the current bootstrap (leagueId +\n * matchId). Memoised on first success; returns `null` outside a league\n * match context or on transport error.\n */\n getMatchContext(): Promise<MatchContext | null>;\n\n /** Tell the host the game has finished (shows completion UI). */\n notifyComplete(data?: GameCompleteData): void;\n\n /** Ask the host to close the game/iframe and return to the lobby. */\n requestClose(): void;\n\n /**\n * Ask the host to open the \"report this question\" dialog. The host collects\n * the reason, an optional message, and (for guests) name/email, then submits\n * the report to the platform. No-ops when the game runs outside the host\n * iframe.\n */\n reportQuestion(data: ReportQuestionData): void;\n\n /**\n * Ask the host to open the \"report this word\" dialog (Words Bank feature).\n * Mirrors {@link reportQuestion}: the host collects the reason, an optional\n * message, and (for guests) name/email, then submits the report. No-ops when\n * the game runs outside the host iframe.\n */\n reportWord(data: ReportWordData): void;\n\n /** Emit a custom analytics event to the host. */\n logEvent(eventName: string, eventData?: EventData): void;\n\n /** @returns the resolved game slug, or null if we never found one. */\n getGameSlug(): string | null;\n\n /** @returns whether the SDK is running inside an iframe. */\n isInIframe(): boolean;\n\n /** Awaitable barrier \u2014 resolves when the SDK has booted. */\n ready(): Promise<boolean>;\n\n /** @returns a snapshot of bootstrap-sourced state for debugging. */\n getBootstrap(): BootstrapData;\n\n /**\n * Fetch questions for quiz-style games. Returns [] on failure.\n * Pass `options.profileId` to select a game profile; if omitted, the\n * bootstrap-supplied `profileId` is used, else the game's default profile.\n */\n getQuestions(options?: QuestionOptions): Promise<Question[]>;\n\n /**\n * Fetch words from the words bank for this game (Words Bank feature). Returns\n * [] on failure. Profile selection works like {@link getQuestions} (the same\n * profile carries both the question and word selection).\n */\n getWords(options?: WordOptions): Promise<Word[]>;\n}\n\n/**\n * Build the public API object. Methods are thin adapters that route to\n * the internal modules.\n */\nexport function createSdk(): Sdk {\n return {\n version: SDK_VERSION,\n\n isInitialized(): boolean {\n return state.isInitialized;\n },\n\n isAuthenticated(): boolean {\n return !!state.authToken;\n },\n\n hasActiveSession(): boolean {\n return !!state.sessionToken;\n },\n\n async startSession(): Promise<StartSessionResult> {\n await ensureInitialized();\n if (state.sessionStartPromise) return await state.sessionStartPromise;\n return await Session.startSession();\n },\n\n submitScore(\n score: number,\n meta: ScoreMetadata = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitScore(score, meta);\n },\n\n submitMatchScore(\n score: number,\n meta: ScoreMetadata = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitMatchScore(score, meta);\n },\n\n submitMatchResult(\n result: MatchResultPayload = {}\n ): Promise<SubmitScoreResult> {\n return Session.submitMatchResult(result);\n },\n\n async getMatchContext(): Promise<MatchContext | null> {\n await ensureInitialized();\n return await MatchCtx.fetchMatchContext();\n },\n\n notifyComplete(data: GameCompleteData = {}): void {\n sendToParent('GAME_COMPLETE', data);\n },\n\n requestClose(): void {\n sendToParent('REQUEST_CLOSE', {});\n },\n\n reportQuestion(data: ReportQuestionData): void {\n sendToParent('QUESTION_REPORT', {\n questionId: data.questionId,\n prompt: data.prompt,\n message: data.message,\n questions: Array.isArray(data.questions)\n ? data.questions.map((q) => ({\n questionId: q.questionId,\n prompt: q.prompt,\n }))\n : undefined,\n });\n },\n\n reportWord(data: ReportWordData): void {\n sendToParent('WORD_REPORT', {\n wordId: data.wordId,\n lemma: data.lemma,\n message: data.message,\n words: Array.isArray(data.words)\n ? data.words.map((w) => ({\n wordId: w.wordId,\n lemma: w.lemma,\n }))\n : undefined,\n });\n },\n\n logEvent(eventName: string, eventData: EventData = {}): void {\n sendToParent('LOG_EVENT', {\n event: eventName,\n data: eventData,\n });\n },\n\n getGameSlug(): string | null {\n return state.gameSlug;\n },\n\n isInIframe(): boolean {\n return isBrowser() && window.parent !== window;\n },\n\n async ready(): Promise<boolean> {\n return await ensureInitialized();\n },\n\n getBootstrap(): BootstrapData {\n return {\n gameSlug: state.gameSlug,\n authToken: state.authToken,\n leagueId: state.leagueId,\n gameId: state.gameId,\n matchId: state.matchId,\n mode: state.bootstrapMode,\n playerName: state.bootstrapPlayerName,\n playerCount: state.bootstrapPlayerCount,\n teamOneName: state.bootstrapTeamOneName,\n teamTwoName: state.bootstrapTeamTwoName,\n profileId: state.bootstrapProfileId,\n multiplayer: state.bootstrapMultiplayer,\n isBootstrapped: state.bootstrapReceived,\n };\n },\n\n getQuestions(options: QuestionOptions = {}): Promise<Question[]> {\n return Session.getQuestions(options);\n },\n\n getWords(options: WordOptions = {}): Promise<Word[]> {\n return Session.getWords(options);\n },\n };\n}\n", "/**\n * Script-tag entry point.\n *\n * Bundled into the legacy `gamehub-sdk.js` UMD/IIFE artifact that GameHub-\n * hosted games drop in via `<script src=\"gamehub-sdk.js\">`. Importing this\n * module (which a bundler does once when producing that artifact) attaches\n * `window.GameHubSDK`, wires up the host message listener, and runs the\n * auto-init handshake.\n *\n * This file is the ONLY place in the SDK that performs side effects on\n * load. Module / npm consumers import from `./main` instead, which is pure.\n */\n\nimport { SDK_VERSION } from './constants.js';\nimport { state } from './state.js';\nimport { sendToParent } from './bridge.js';\nimport {\n autoInit,\n detectEnvironment,\n installHostMessageListener,\n} from './init.js';\nimport { isBrowser } from './utils.js';\nimport { createSdk, type Sdk } from './main.js';\n\ndeclare global {\n interface Window {\n GameHubSDK?: Sdk;\n }\n}\n\n(function bootstrapSdk(): void {\n 'use strict';\n\n // Defensive: if a bundler accidentally pulls this entry into a non-browser\n // build, exit cleanly instead of throwing on `window.location.origin`.\n if (!isBrowser()) return;\n\n detectEnvironment();\n installHostMessageListener();\n\n const sdk = createSdk();\n window.GameHubSDK = sdk;\n\n // Announce presence to the host as soon as the script runs.\n if (window.parent !== window) {\n sendToParent('READY', { version: SDK_VERSION });\n }\n\n // Kick off auto-init if we have any signal we're embedded in GameHub:\n // either we detected a slug locally, or we're inside an iframe that might\n // feed us one. Waits for DOMContentLoaded so script tags declared after\n // us are available for the slug-detection scan.\n const hasBootSignal = !!state.gameSlug || window.parent !== window;\n if (!hasBootSignal) return;\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => {\n autoInit();\n });\n } else {\n autoInit();\n }\n})();\n"],
|
|
5
|
+
"mappings": ";;;AAGO,MAAM,cAAc;AAMpB,MAAM,iBAAiB;AAGvB,MAAM,4BAA4B;AAOlC,MAAM,sBAAsB;AAG5B,MAAM,sBAAsB;AAQ5B,MAAM,kBAAkB;;;ACiCxB,MAAM,QAAkB;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,MAAM,UAAU;AACtB,WAAO,aAAa;AAGpB,QAAI,OAAO,WAAW,QAAQ;AAC5B,mBAAa,SAAS,EAAE,SAAS,YAAY,CAAC;AAAA,IAChD;AAMA,UAAM,gBAAgB,CAAC,CAAC,MAAM,YAAY,OAAO,WAAW;AAC5D,QAAI,CAAC,cAAe;AAEpB,QAAI,SAAS,eAAe,WAAW;AACrC,eAAS,iBAAiB,oBAAoB,MAAM;AAClD,iBAAS;AAAA,MACX,CAAC;AAAA,IACH,OAAO;AACL,eAAS;AAAA,IACX;AAAA,EACF,GAAG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bundle version reported by the SDK. Bumped at release time.
|
|
3
3
|
*/
|
|
4
|
-
export declare const SDK_VERSION = "3.
|
|
4
|
+
export declare const SDK_VERSION = "3.7.0";
|
|
5
5
|
/**
|
|
6
6
|
* Prefix applied to every cross-origin postMessage the SDK emits and accepts.
|
|
7
7
|
* Keeps our messages isolated from unrelated frames on the same page.
|
|
@@ -17,4 +17,11 @@ export declare const PARENT_REQUEST_TIMEOUT_MS = 2000;
|
|
|
17
17
|
export declare const HOST_API_TIMEOUT_MS = 15000;
|
|
18
18
|
/** Upper bound on questions returned per `getQuestions` call. */
|
|
19
19
|
export declare const QUESTIONS_LIMIT_CAP = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Upper bound on words returned per `getWords` call. Set lower than
|
|
22
|
+
* {@link QUESTIONS_LIMIT_CAP} because a full-nested `Word` (the whole
|
|
23
|
+
* `PublicEntry` shape — senses/wordForms/relations) is much heavier than a
|
|
24
|
+
* `Question`, so we bound the payload size more tightly.
|
|
25
|
+
*/
|
|
26
|
+
export declare const WORDS_LIMIT_CAP = 50;
|
|
20
27
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC"}
|
package/dist/src/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bundle version reported by the SDK. Bumped at release time.
|
|
3
3
|
*/
|
|
4
|
-
export const SDK_VERSION = '3.
|
|
4
|
+
export const SDK_VERSION = '3.7.0';
|
|
5
5
|
/**
|
|
6
6
|
* Prefix applied to every cross-origin postMessage the SDK emits and accepts.
|
|
7
7
|
* Keeps our messages isolated from unrelated frames on the same page.
|
|
@@ -17,4 +17,11 @@ export const PARENT_REQUEST_TIMEOUT_MS = 2000;
|
|
|
17
17
|
export const HOST_API_TIMEOUT_MS = 15000;
|
|
18
18
|
/** Upper bound on questions returned per `getQuestions` call. */
|
|
19
19
|
export const QUESTIONS_LIMIT_CAP = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Upper bound on words returned per `getWords` call. Set lower than
|
|
22
|
+
* {@link QUESTIONS_LIMIT_CAP} because a full-nested `Word` (the whole
|
|
23
|
+
* `PublicEntry` shape — senses/wordForms/relations) is much heavier than a
|
|
24
|
+
* `Question`, so we bound the payload size more tightly.
|
|
25
|
+
*/
|
|
26
|
+
export const WORDS_LIMIT_CAP = 50;
|
|
20
27
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,yEAAyE;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,yEAAyE;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC"}
|
package/dist/src/main.d.ts
CHANGED
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
* (e.g. via `@colyseus/sdk`'s `client.reconnect(...)`).
|
|
13
13
|
*/
|
|
14
14
|
import type { BootstrapData } from '../types/bootstrap.js';
|
|
15
|
-
import type { EventData, GameCompleteData, Question, QuestionOptions, ReportQuestionData, ScoreMetadata, StartSessionResult, SubmitScoreResult } from '../types/session.js';
|
|
15
|
+
import type { EventData, GameCompleteData, Question, QuestionOptions, ReportQuestionData, ReportWordData, ScoreMetadata, StartSessionResult, SubmitScoreResult, Word, WordOptions } from '../types/session.js';
|
|
16
16
|
import type { MatchContext, MatchResultPayload } from '../types/match.js';
|
|
17
17
|
export type { ApiRequestOptions, ApiResponse } from '../types/api.js';
|
|
18
18
|
export type { BootstrapConfig, BootstrapData, BootstrapMultiplayer, } from '../types/bootstrap.js';
|
|
19
|
-
export type { EventData, GameCompleteData, Question, QuestionOptions, ReportQuestionData, ScoreMetadata, StartSessionResult, SubmitScoreResult, } from '../types/session.js';
|
|
19
|
+
export type { EventData, GameCompleteData, Question, QuestionDifficulty, QuestionOptions, ReportableQuestion, ReportableWord, ReportQuestionData, ReportWordData, ScoreMetadata, StartSessionResult, SubmitScoreResult, Word, WordDifficulty, WordOptions, } from '../types/session.js';
|
|
20
|
+
export type { FormRepresentation, Lookup, Synset, SynsetNameTranslation, DynamicProp, DynamicProperty, WordForm, WordSense, WordSenseExample, WordSenseTranslation, WordSenseRelation, WordMetaData, WordRelation, } from '../types/word.js';
|
|
20
21
|
export type { MatchContext, MatchParticipant, MatchParticipantMember, MatchResultPayload, } from '../types/match.js';
|
|
21
22
|
/**
|
|
22
23
|
* Public shape of `window.GameHubSDK` and the value returned by
|
|
@@ -64,6 +65,13 @@ export interface Sdk {
|
|
|
64
65
|
* iframe.
|
|
65
66
|
*/
|
|
66
67
|
reportQuestion(data: ReportQuestionData): void;
|
|
68
|
+
/**
|
|
69
|
+
* Ask the host to open the "report this word" dialog (Words Bank feature).
|
|
70
|
+
* Mirrors {@link reportQuestion}: the host collects the reason, an optional
|
|
71
|
+
* message, and (for guests) name/email, then submits the report. No-ops when
|
|
72
|
+
* the game runs outside the host iframe.
|
|
73
|
+
*/
|
|
74
|
+
reportWord(data: ReportWordData): void;
|
|
67
75
|
/** Emit a custom analytics event to the host. */
|
|
68
76
|
logEvent(eventName: string, eventData?: EventData): void;
|
|
69
77
|
/** @returns the resolved game slug, or null if we never found one. */
|
|
@@ -80,6 +88,12 @@ export interface Sdk {
|
|
|
80
88
|
* bootstrap-supplied `profileId` is used, else the game's default profile.
|
|
81
89
|
*/
|
|
82
90
|
getQuestions(options?: QuestionOptions): Promise<Question[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch words from the words bank for this game (Words Bank feature). Returns
|
|
93
|
+
* [] on failure. Profile selection works like {@link getQuestions} (the same
|
|
94
|
+
* profile carries both the question and word selection).
|
|
95
|
+
*/
|
|
96
|
+
getWords(options?: WordOptions): Promise<Word[]>;
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Build the public API object. Methods are thin adapters that route to
|
package/dist/src/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAC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B,CAAC,CAAC;IAE9B;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE3E;;;;OAIG;IACH,eAAe,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAEhD,iEAAiE;IACjE,cAAc,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9C,qEAAqE;IACrE,YAAY,IAAI,IAAI,CAAC;IAErB;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE/C;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAEvC,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAEzD,sEAAsE;IACtE,WAAW,IAAI,MAAM,GAAG,IAAI,CAAC;IAE7B,4DAA4D;IAC5D,UAAU,IAAI,OAAO,CAAC;IAEtB,4DAA4D;IAC5D,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1B,oEAAoE;IACpE,YAAY,IAAI,aAAa,CAAC;IAE9B;;;;OAIG;IACH,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE7D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;CAClD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,GAAG,CAgI/B"}
|
package/dist/src/main.js
CHANGED
|
@@ -64,6 +64,25 @@ export function createSdk() {
|
|
|
64
64
|
questionId: data.questionId,
|
|
65
65
|
prompt: data.prompt,
|
|
66
66
|
message: data.message,
|
|
67
|
+
questions: Array.isArray(data.questions)
|
|
68
|
+
? data.questions.map((q) => ({
|
|
69
|
+
questionId: q.questionId,
|
|
70
|
+
prompt: q.prompt,
|
|
71
|
+
}))
|
|
72
|
+
: undefined,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
reportWord(data) {
|
|
76
|
+
sendToParent('WORD_REPORT', {
|
|
77
|
+
wordId: data.wordId,
|
|
78
|
+
lemma: data.lemma,
|
|
79
|
+
message: data.message,
|
|
80
|
+
words: Array.isArray(data.words)
|
|
81
|
+
? data.words.map((w) => ({
|
|
82
|
+
wordId: w.wordId,
|
|
83
|
+
lemma: w.lemma,
|
|
84
|
+
}))
|
|
85
|
+
: undefined,
|
|
67
86
|
});
|
|
68
87
|
},
|
|
69
88
|
logEvent(eventName, eventData = {}) {
|
|
@@ -101,6 +120,9 @@ export function createSdk() {
|
|
|
101
120
|
getQuestions(options = {}) {
|
|
102
121
|
return Session.getQuestions(options);
|
|
103
122
|
},
|
|
123
|
+
getWords(options = {}) {
|
|
124
|
+
return Session.getWords(options);
|
|
125
|
+
},
|
|
104
126
|
};
|
|
105
127
|
}
|
|
106
128
|
//# sourceMappingURL=main.js.map
|
package/dist/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;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WAAW,EAAE;gBACxB,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;QACL,CAAC;QAED,WAAW;YACT,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,CAAC;QAED,UAAU;YACR,OAAO,SAAS,EAAE,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,KAAK;YACT,OAAO,MAAM,iBAAiB,EAAE,CAAC;QACnC,CAAC;QAED,YAAY;YACV,OAAO;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK,CAAC,aAAa;gBACzB,UAAU,EAAE,KAAK,CAAC,mBAAmB;gBACrC,WAAW,EAAE,KAAK,CAAC,oBAAoB;gBACvC,WAAW,EAAE,KAAK,CAAC,oBAAoB;gBACvC,WAAW,EAAE,KAAK,CAAC,oBAAoB;gBACvC,SAAS,EAAE,KAAK,CAAC,kBAAkB;gBACnC,WAAW,EAAE,KAAK,CAAC,oBAAoB;gBACvC,cAAc,EAAE,KAAK,CAAC,iBAAiB;aACxC,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,UAA2B,EAAE;YACxC,OAAO,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,QAAQ,CAAC,UAAuB,EAAE;YAChC,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/src/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Question, QuestionOptions, ScoreMetadata, StartSessionResult, SubmitScoreResult } from '../types/session.js';
|
|
1
|
+
import type { Question, QuestionOptions, ScoreMetadata, StartSessionResult, SubmitScoreResult, Word, WordOptions } from '../types/session.js';
|
|
2
2
|
import type { MatchResultPayload } from '../types/match.js';
|
|
3
3
|
/**
|
|
4
4
|
* Starts a new game session and caches the returned session token. Safe
|
|
@@ -39,4 +39,10 @@ export declare function submitMatchResult(result?: MatchResultPayload): Promise<
|
|
|
39
39
|
* state.
|
|
40
40
|
*/
|
|
41
41
|
export declare function getQuestions(options?: QuestionOptions): Promise<Question[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Fetch words for this game (Words Bank feature). Mirrors {@link getQuestions}:
|
|
44
|
+
* returns an empty array on any failure or invalid input. The served payload is
|
|
45
|
+
* a near-passthrough of the gamehub `Word`, so no normalization is needed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getWords(options?: WordOptions): Promise<Word[]>;
|
|
42
48
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;;;;;;GASG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CA2ChE;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAmE5B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAc5B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,GAAE,kBAAuB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CAM5B;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAuDrB;AAQD;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAmDzE"}
|
package/dist/src/session.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { state } from './state.js';
|
|
2
|
-
import { QUESTIONS_LIMIT_CAP } from './constants.js';
|
|
2
|
+
import { QUESTIONS_LIMIT_CAP, WORDS_LIMIT_CAP } from './constants.js';
|
|
3
3
|
import { apiRequest } from './api-client.js';
|
|
4
4
|
import { unwrapResult } from './utils.js';
|
|
5
5
|
import { sendToParent } from './bridge.js';
|
|
@@ -214,4 +214,56 @@ function normalizeQuestion(raw) {
|
|
|
214
214
|
const answer = typeof q.answer === 'number' ? String(q.answer) : q.answer;
|
|
215
215
|
return { ...q, answer };
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Fetch words for this game (Words Bank feature). Mirrors {@link getQuestions}:
|
|
219
|
+
* returns an empty array on any failure or invalid input. The served payload is
|
|
220
|
+
* a near-passthrough of the gamehub `Word`, so no normalization is needed.
|
|
221
|
+
*/
|
|
222
|
+
export async function getWords(options = {}) {
|
|
223
|
+
await ensureInitialized();
|
|
224
|
+
const gameIdentifier = state.gameId || state.gameSlug;
|
|
225
|
+
if (!gameIdentifier)
|
|
226
|
+
return [];
|
|
227
|
+
const { difficulty, category, tags, limit } = options;
|
|
228
|
+
if (difficulty && !['easy', 'medium', 'hard'].includes(difficulty)) {
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
if (limit !== undefined && (typeof limit !== 'number' || limit < 1)) {
|
|
232
|
+
return [];
|
|
233
|
+
}
|
|
234
|
+
// Profile selection: explicit option wins, else the bootstrap-supplied
|
|
235
|
+
// profileId. Omitted → resolver falls back to the game's isDefault profile.
|
|
236
|
+
const profileId = options.profileId || state.bootstrapProfileId || '';
|
|
237
|
+
try {
|
|
238
|
+
const params = new URLSearchParams({
|
|
239
|
+
limit: String(Math.min(limit || WORDS_LIMIT_CAP, WORDS_LIMIT_CAP)),
|
|
240
|
+
random: 'true',
|
|
241
|
+
});
|
|
242
|
+
if (state.gameId)
|
|
243
|
+
params.set('gameId', state.gameId);
|
|
244
|
+
if (difficulty)
|
|
245
|
+
params.set('difficulty', difficulty);
|
|
246
|
+
if (category)
|
|
247
|
+
params.set('category', String(category));
|
|
248
|
+
if (Array.isArray(tags) && tags.length > 0) {
|
|
249
|
+
params.set('tags', tags.join(','));
|
|
250
|
+
}
|
|
251
|
+
if (profileId)
|
|
252
|
+
params.set('profileId', profileId);
|
|
253
|
+
const result = await apiRequest('/games/' +
|
|
254
|
+
encodeURIComponent(gameIdentifier) +
|
|
255
|
+
'/words?' +
|
|
256
|
+
params.toString(), { method: 'GET' });
|
|
257
|
+
const data = unwrapResult(result);
|
|
258
|
+
const raw = Array.isArray(data)
|
|
259
|
+
? data
|
|
260
|
+
: Array.isArray(data?.words)
|
|
261
|
+
? data.words
|
|
262
|
+
: [];
|
|
263
|
+
return raw;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
217
269
|
//# sourceMappingURL=session.js.map
|
package/dist/src/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MA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,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,MAAM,UAAU,CAC7B,SAAS;YACP,kBAAkB,CAAC,cAAc,CAAC;YAClC,SAAS;YACT,MAAM,CAAC,QAAQ,EAAE,EACnB,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;QAEF,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,GAAG,GAAc,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YACxC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,CAAC,KAAK;gBACZ,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,GAAa,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/types/session.d.ts
CHANGED
|
@@ -20,18 +20,41 @@ export interface EventData {
|
|
|
20
20
|
value?: number;
|
|
21
21
|
properties?: Record<string, any>;
|
|
22
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
|
+
}
|
|
23
33
|
/**
|
|
24
34
|
* Payload passed to `sdk.reportQuestion`. Identifies the question the player
|
|
25
35
|
* wants to flag; the host renders the report dialog and collects the reason,
|
|
26
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.
|
|
27
41
|
*/
|
|
28
42
|
export interface ReportQuestionData {
|
|
29
|
-
/**
|
|
30
|
-
|
|
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;
|
|
31
48
|
/** Optional prompt snapshot so the host dialog can show what's being reported. */
|
|
32
49
|
prompt?: string;
|
|
33
50
|
/** Optional message to pre-fill in the dialog. */
|
|
34
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[];
|
|
35
58
|
}
|
|
36
59
|
/** Options accepted by `sdk.getQuestions`. */
|
|
37
60
|
export interface QuestionOptions {
|
|
@@ -48,6 +71,48 @@ export interface QuestionOptions {
|
|
|
48
71
|
profileId?: string;
|
|
49
72
|
}
|
|
50
73
|
export type { Question, QuestionDifficulty } from './question.js';
|
|
74
|
+
/**
|
|
75
|
+
* A single word the host can offer in its report dialog's word picker.
|
|
76
|
+
* Supplied via {@link ReportWordData.words}.
|
|
77
|
+
*/
|
|
78
|
+
export interface ReportableWord {
|
|
79
|
+
/** The `id` of the word (as returned by `getWords`). */
|
|
80
|
+
wordId: string;
|
|
81
|
+
/** Optional lemma label shown for this option in the picker. */
|
|
82
|
+
lemma?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Payload passed to `sdk.reportWord`. Identifies the word the player wants to
|
|
86
|
+
* flag; the host renders the report dialog and collects the reason, optional
|
|
87
|
+
* message, and (for guests) name/email before submitting. Mirrors
|
|
88
|
+
* {@link ReportQuestionData}, relabeled to lemma.
|
|
89
|
+
*/
|
|
90
|
+
export interface ReportWordData {
|
|
91
|
+
/** The `id` of the word to report. May be omitted when `words` is supplied. */
|
|
92
|
+
wordId?: string;
|
|
93
|
+
/** Optional lemma snapshot so the host dialog can show what's being reported. */
|
|
94
|
+
lemma?: string;
|
|
95
|
+
/** Optional message to pre-fill in the dialog. */
|
|
96
|
+
message?: string;
|
|
97
|
+
/** Optional list of words for the host to render as a selectable dropdown. */
|
|
98
|
+
words?: ReportableWord[];
|
|
99
|
+
}
|
|
100
|
+
/** Options accepted by `sdk.getWords` (Words Bank feature). */
|
|
101
|
+
export interface WordOptions {
|
|
102
|
+
difficulty?: 'easy' | 'medium' | 'hard' | string;
|
|
103
|
+
category?: string | number;
|
|
104
|
+
/** Free-form selection tags; ANDed (`$in`) on top of the profile selection. */
|
|
105
|
+
tags?: string[];
|
|
106
|
+
limit?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Selects a game **profile** (its subdoc `_id`) on the gamehub side — the
|
|
109
|
+
* resolver returns the union of that profile's `wordPack` private/bank/fixed
|
|
110
|
+
* parts. Unknown/omitted falls back to the game's `isDefault` profile. Usually
|
|
111
|
+
* sourced from the SDK bootstrap payload.
|
|
112
|
+
*/
|
|
113
|
+
profileId?: string;
|
|
114
|
+
}
|
|
115
|
+
export type { Word, WordDifficulty } from './word.js';
|
|
51
116
|
/** Result returned by `startSession`. */
|
|
52
117
|
export interface StartSessionResult {
|
|
53
118
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
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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AS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEtD,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"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical word shape returned by `sdk.getWords()` (Words Bank feature).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the gamehub `Word` model (a full mirror of siwar's `PublicEntry`
|
|
5
|
+
* OpenAPI DTO) as served by the runtime route — a **near-passthrough** that
|
|
6
|
+
* renames `_id→id` and strips persistence/provenance fields
|
|
7
|
+
* (`scope`/`status`/`gameId`/`lexicalEntryId`/`lexiconId`/`lexiconName` +
|
|
8
|
+
* timestamps). The embedded reference objects ({@link Lookup}/{@link Synset}/
|
|
9
|
+
* {@link DynamicProperty}) reflect the **audit-stripped** shape the server
|
|
10
|
+
* persists (no `_id`/`createdAt`/`isReviewed`/… metadata), not the raw OpenAPI
|
|
11
|
+
* interface. Enum unions are typed as free strings (the bank does not enforce
|
|
12
|
+
* them).
|
|
13
|
+
*/
|
|
14
|
+
export type WordDifficulty = 'easy' | 'medium' | 'hard';
|
|
15
|
+
/** `FormRepresentation` / word-form representation — `{ form, phonetic, dialect, audio }`. */
|
|
16
|
+
export interface FormRepresentation {
|
|
17
|
+
form?: string;
|
|
18
|
+
phonetic?: string;
|
|
19
|
+
dialect?: string;
|
|
20
|
+
audio?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface WordSenseExample {
|
|
23
|
+
word?: string;
|
|
24
|
+
type?: string;
|
|
25
|
+
typeCode?: string;
|
|
26
|
+
source?: string;
|
|
27
|
+
audio?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WordSenseTranslation {
|
|
30
|
+
word?: string;
|
|
31
|
+
language?: string;
|
|
32
|
+
languageLabel?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WordSenseRelation {
|
|
35
|
+
type?: string;
|
|
36
|
+
related?: string;
|
|
37
|
+
entryLemmaOfRelated?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface SynsetNameTranslation {
|
|
40
|
+
text?: string;
|
|
41
|
+
languageCode?: string;
|
|
42
|
+
language?: string;
|
|
43
|
+
}
|
|
44
|
+
/** `Lookup` — audit-stripped. */
|
|
45
|
+
export interface Lookup {
|
|
46
|
+
label?: string;
|
|
47
|
+
code?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
categoryLabel?: string;
|
|
50
|
+
order?: number;
|
|
51
|
+
iconUrl?: string;
|
|
52
|
+
}
|
|
53
|
+
/** `Synset` — audit-stripped; `parent`/`lexicon` are shallow (unknown). */
|
|
54
|
+
export interface Synset {
|
|
55
|
+
name?: string;
|
|
56
|
+
nameTranslations?: SynsetNameTranslation[];
|
|
57
|
+
description?: string;
|
|
58
|
+
pos?: string;
|
|
59
|
+
parentCode?: string;
|
|
60
|
+
parent?: unknown;
|
|
61
|
+
ili?: string;
|
|
62
|
+
wordType?: string;
|
|
63
|
+
code?: string;
|
|
64
|
+
lexiconId?: string;
|
|
65
|
+
lexicon?: unknown;
|
|
66
|
+
}
|
|
67
|
+
/** `LexicalEntryDynamicProperty` — audit-stripped. */
|
|
68
|
+
export interface DynamicProperty {
|
|
69
|
+
name?: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
isRequired?: boolean;
|
|
73
|
+
dataType?: string;
|
|
74
|
+
isSearchable?: boolean;
|
|
75
|
+
isActive?: boolean;
|
|
76
|
+
path?: string;
|
|
77
|
+
dropDownList?: string[];
|
|
78
|
+
lexiconId?: string;
|
|
79
|
+
options?: unknown;
|
|
80
|
+
}
|
|
81
|
+
export interface DynamicProp {
|
|
82
|
+
dynamicPropertyId?: string;
|
|
83
|
+
property?: DynamicProperty;
|
|
84
|
+
value?: unknown;
|
|
85
|
+
}
|
|
86
|
+
export interface WordSense {
|
|
87
|
+
definition?: string;
|
|
88
|
+
translations?: WordSenseTranslation[];
|
|
89
|
+
contexts?: string[];
|
|
90
|
+
domains?: string[];
|
|
91
|
+
examples?: WordSenseExample[];
|
|
92
|
+
relations?: WordSenseRelation[];
|
|
93
|
+
image?: string;
|
|
94
|
+
imageGallery?: string[];
|
|
95
|
+
synset?: Synset;
|
|
96
|
+
level?: string;
|
|
97
|
+
transitivity?: string;
|
|
98
|
+
theme?: Lookup;
|
|
99
|
+
dynamicProps?: DynamicProp[];
|
|
100
|
+
}
|
|
101
|
+
export interface WordForm {
|
|
102
|
+
formRepresentations?: FormRepresentation[];
|
|
103
|
+
level?: number;
|
|
104
|
+
aspect?: string;
|
|
105
|
+
def?: string;
|
|
106
|
+
gender?: string;
|
|
107
|
+
isNasab?: boolean;
|
|
108
|
+
numberWordForm?: string;
|
|
109
|
+
person?: string;
|
|
110
|
+
isSmall?: boolean;
|
|
111
|
+
voice?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface WordMetaData {
|
|
114
|
+
longitude?: string;
|
|
115
|
+
latitude?: string;
|
|
116
|
+
periodDateFrom?: string;
|
|
117
|
+
periodDateTo?: string;
|
|
118
|
+
city?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface WordRelation {
|
|
121
|
+
type?: string;
|
|
122
|
+
relatedLexicalEntryId?: string;
|
|
123
|
+
Data?: unknown;
|
|
124
|
+
}
|
|
125
|
+
export interface Word {
|
|
126
|
+
id: string;
|
|
127
|
+
lemma: string;
|
|
128
|
+
lemmaType?: string;
|
|
129
|
+
lemmaAudio?: string;
|
|
130
|
+
pattern?: string;
|
|
131
|
+
pos?: string;
|
|
132
|
+
root?: string;
|
|
133
|
+
nonDiacriticsLemma?: string;
|
|
134
|
+
autoGeneratedRoot?: string;
|
|
135
|
+
senses?: WordSense[];
|
|
136
|
+
wordForms?: WordForm[];
|
|
137
|
+
lammaDetails?: FormRepresentation[];
|
|
138
|
+
lemmaLanguage?: Lookup;
|
|
139
|
+
metaData?: WordMetaData;
|
|
140
|
+
entryRelations?: WordRelation[];
|
|
141
|
+
dynamicProps?: DynamicProp[];
|
|
142
|
+
relatedSenses?: WordSense[];
|
|
143
|
+
difficulty?: WordDifficulty;
|
|
144
|
+
category?: string;
|
|
145
|
+
tags?: string[];
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=word.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word.d.ts","sourceRoot":"","sources":["../../types/word.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;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
2
|
+
* Canonical word shape returned by `sdk.getWords()` (Words Bank feature).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the gamehub `Word` model (a full mirror of siwar's `PublicEntry`
|
|
5
|
+
* OpenAPI DTO) as served by the runtime route — a **near-passthrough** that
|
|
6
|
+
* renames `_id→id` and strips persistence/provenance fields
|
|
7
|
+
* (`scope`/`status`/`gameId`/`lexicalEntryId`/`lexiconId`/`lexiconName` +
|
|
8
|
+
* timestamps). The embedded reference objects ({@link Lookup}/{@link Synset}/
|
|
9
|
+
* {@link DynamicProperty}) reflect the **audit-stripped** shape the server
|
|
10
|
+
* persists (no `_id`/`createdAt`/`isReviewed`/… metadata), not the raw OpenAPI
|
|
11
|
+
* interface. Enum unions are typed as free strings (the bank does not enforce
|
|
12
|
+
* them).
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=word.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"word.js","sourceRoot":"","sources":["../../types/word.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ksaa-nlp/gamehub-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
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",
|