@ksaa-nlp/gamehub-sdk 0.1.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +294 -0
- package/MIGRATION.md +322 -0
- package/README.md +121 -182
- package/dist/gamehub-sdk.js +1202 -1670
- package/dist/gamehub-sdk.js.map +7 -0
- package/dist/src/api-client.d.ts +11 -0
- package/dist/src/api-client.d.ts.map +1 -0
- package/dist/src/api-client.js +27 -0
- package/dist/src/api-client.js.map +1 -0
- package/dist/src/bridge.d.ts +35 -0
- package/dist/src/bridge.d.ts.map +1 -0
- package/dist/src/bridge.js +280 -0
- package/dist/src/bridge.js.map +1 -0
- package/dist/src/browser-entry.d.ts +19 -0
- package/dist/src/browser-entry.d.ts.map +1 -0
- package/dist/src/browser-entry.js +49 -0
- package/dist/src/browser-entry.js.map +1 -0
- package/dist/src/constants.d.ts +18 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +18 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/init.d.ts +36 -0
- package/dist/src/init.d.ts.map +1 -0
- package/dist/src/init.js +317 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/main.d.ts +101 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/main.js +126 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/match-context.d.ts +11 -0
- package/dist/src/match-context.d.ts.map +1 -0
- package/dist/src/match-context.js +51 -0
- package/dist/src/match-context.js.map +1 -0
- package/dist/src/multiplayer.d.ts +82 -0
- package/dist/src/multiplayer.d.ts.map +1 -0
- package/dist/src/multiplayer.js +461 -0
- package/dist/src/multiplayer.js.map +1 -0
- package/dist/src/session.d.ts +35 -0
- package/dist/src/session.d.ts.map +1 -0
- package/dist/src/session.js +206 -0
- package/dist/src/session.js.map +1 -0
- package/dist/src/state.d.ts +71 -0
- package/dist/src/state.d.ts.map +1 -0
- package/dist/src/state.js +55 -0
- package/dist/src/state.js.map +1 -0
- package/dist/src/utils.d.ts +36 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +73 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/types/api.d.ts +21 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +2 -0
- package/dist/types/api.js.map +1 -0
- package/{types/bootstrap.ts → dist/types/bootstrap.d.ts} +26 -29
- package/dist/types/bootstrap.d.ts.map +1 -0
- package/dist/types/bootstrap.js +2 -0
- package/dist/types/bootstrap.js.map +1 -0
- package/dist/types/match.d.ts +37 -0
- package/dist/types/match.d.ts.map +1 -0
- package/dist/types/match.js +2 -0
- package/dist/types/match.js.map +1 -0
- package/dist/types/multiplayer.d.ts +138 -0
- package/dist/types/multiplayer.d.ts.map +1 -0
- package/dist/types/multiplayer.js +2 -0
- package/dist/types/multiplayer.js.map +1 -0
- package/{types/session.ts → dist/types/session.d.ts} +24 -30
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +2 -0
- package/dist/types/session.js.map +1 -0
- package/package.json +34 -18
- package/dist/gamehub-sdk.d.ts +0 -694
- package/dist/index.d.ts +0 -56
- package/dist/index.mjs +0 -6
- package/scripts/emit-module-entry.mjs +0 -96
- package/src/api-client.ts +0 -33
- package/src/bridge.ts +0 -312
- package/src/constants.ts +0 -24
- package/src/init.ts +0 -335
- package/src/main.ts +0 -287
- package/src/match-context.ts +0 -52
- package/src/multiplayer.ts +0 -525
- package/src/session.ts +0 -240
- package/src/state.ts +0 -78
- package/src/utils.ts +0 -68
- package/tsconfig.json +0 -33
- package/types/api.ts +0 -21
- package/types/match.ts +0 -41
- package/types/multiplayer.ts +0 -118
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script-tag entry point.
|
|
3
|
+
*
|
|
4
|
+
* Bundled into the legacy `gamehub-sdk.js` UMD/IIFE artifact that GameHub-
|
|
5
|
+
* hosted games drop in via `<script src="gamehub-sdk.js">`. Importing this
|
|
6
|
+
* module (which a bundler does once when producing that artifact) attaches
|
|
7
|
+
* `window.GameHubSDK`, wires up the host message listener, and runs the
|
|
8
|
+
* auto-init handshake.
|
|
9
|
+
*
|
|
10
|
+
* This file is the ONLY place in the SDK that performs side effects on
|
|
11
|
+
* load. Module / npm consumers import from `./main` instead, which is pure.
|
|
12
|
+
*/
|
|
13
|
+
import { type Sdk } from './main.js';
|
|
14
|
+
declare global {
|
|
15
|
+
interface Window {
|
|
16
|
+
GameHubSDK?: Sdk;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=browser-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-entry.d.ts","sourceRoot":"","sources":["../../src/browser-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,CAAC,EAAE,GAAG,CAAC;KAClB;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script-tag entry point.
|
|
3
|
+
*
|
|
4
|
+
* Bundled into the legacy `gamehub-sdk.js` UMD/IIFE artifact that GameHub-
|
|
5
|
+
* hosted games drop in via `<script src="gamehub-sdk.js">`. Importing this
|
|
6
|
+
* module (which a bundler does once when producing that artifact) attaches
|
|
7
|
+
* `window.GameHubSDK`, wires up the host message listener, and runs the
|
|
8
|
+
* auto-init handshake.
|
|
9
|
+
*
|
|
10
|
+
* This file is the ONLY place in the SDK that performs side effects on
|
|
11
|
+
* load. Module / npm consumers import from `./main` instead, which is pure.
|
|
12
|
+
*/
|
|
13
|
+
import { SDK_VERSION } from './constants.js';
|
|
14
|
+
import { state } from './state.js';
|
|
15
|
+
import { sendToParent } from './bridge.js';
|
|
16
|
+
import { autoInit, detectEnvironment, installHostMessageListener, } from './init.js';
|
|
17
|
+
import { isBrowser } from './utils.js';
|
|
18
|
+
import { createSdk } from './main.js';
|
|
19
|
+
(function bootstrapSdk() {
|
|
20
|
+
'use strict';
|
|
21
|
+
// Defensive: if a bundler accidentally pulls this entry into a non-browser
|
|
22
|
+
// build, exit cleanly instead of throwing on `window.location.origin`.
|
|
23
|
+
if (!isBrowser())
|
|
24
|
+
return;
|
|
25
|
+
detectEnvironment();
|
|
26
|
+
installHostMessageListener();
|
|
27
|
+
const sdk = createSdk();
|
|
28
|
+
window.GameHubSDK = sdk;
|
|
29
|
+
// Announce presence to the host as soon as the script runs.
|
|
30
|
+
if (window.parent !== window) {
|
|
31
|
+
sendToParent('READY', { version: SDK_VERSION });
|
|
32
|
+
}
|
|
33
|
+
// Kick off auto-init if we have any signal we're embedded in GameHub:
|
|
34
|
+
// either we detected a slug locally, or we're inside an iframe that might
|
|
35
|
+
// feed us one. Waits for DOMContentLoaded so script tags declared after
|
|
36
|
+
// us are available for the slug-detection scan.
|
|
37
|
+
const hasBootSignal = !!state.gameSlug || window.parent !== window;
|
|
38
|
+
if (!hasBootSignal)
|
|
39
|
+
return;
|
|
40
|
+
if (document.readyState === 'loading') {
|
|
41
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
42
|
+
autoInit();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
autoInit();
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
//# sourceMappingURL=browser-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-entry.js","sourceRoot":"","sources":["../../src/browser-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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,EACL,QAAQ,EACR,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAY,MAAM,WAAW,CAAC;AAQhD,CAAC,SAAS,YAAY;IACpB,YAAY,CAAC;IAEb,2EAA2E;IAC3E,uEAAuE;IACvE,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO;IAEzB,iBAAiB,EAAE,CAAC;IACpB,0BAA0B,EAAE,CAAC;IAE7B,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC;IAExB,4DAA4D;IAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,YAAY,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,sEAAsE;IACtE,0EAA0E;IAC1E,wEAAwE;IACxE,gDAAgD;IAChD,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;IACnE,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACtC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;YACjD,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle version reported by the SDK. Bumped at release time.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
5
|
+
/**
|
|
6
|
+
* Prefix applied to every cross-origin postMessage the SDK emits and accepts.
|
|
7
|
+
* Keeps our messages isolated from unrelated frames on the same page.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MESSAGE_PREFIX = "GAMEHUB_SDK";
|
|
10
|
+
/** How long to wait for the host to reply to bootstrap/auth requests. */
|
|
11
|
+
export declare const PARENT_REQUEST_TIMEOUT_MS = 2000;
|
|
12
|
+
/** Maximum number of WebSocket reconnect attempts before giving up. */
|
|
13
|
+
export declare const MP_MAX_RECONNECT_ATTEMPTS = 5;
|
|
14
|
+
/** Hard cap on reconnect backoff. */
|
|
15
|
+
export declare const MP_MAX_RECONNECT_DELAY_MS = 10000;
|
|
16
|
+
/** Upper bound used when the caller doesn't pass an explicit limit. */
|
|
17
|
+
export declare const QUESTIONS_LIMIT_CAP = 100;
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +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,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,qCAAqC;AACrC,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle version reported by the SDK. Bumped at release time.
|
|
3
|
+
*/
|
|
4
|
+
export const SDK_VERSION = '0.5.0';
|
|
5
|
+
/**
|
|
6
|
+
* Prefix applied to every cross-origin postMessage the SDK emits and accepts.
|
|
7
|
+
* Keeps our messages isolated from unrelated frames on the same page.
|
|
8
|
+
*/
|
|
9
|
+
export const MESSAGE_PREFIX = 'GAMEHUB_SDK';
|
|
10
|
+
/** How long to wait for the host to reply to bootstrap/auth requests. */
|
|
11
|
+
export const PARENT_REQUEST_TIMEOUT_MS = 2000;
|
|
12
|
+
/** Maximum number of WebSocket reconnect attempts before giving up. */
|
|
13
|
+
export const MP_MAX_RECONNECT_ATTEMPTS = 5;
|
|
14
|
+
/** Hard cap on reconnect backoff. */
|
|
15
|
+
export const MP_MAX_RECONNECT_DELAY_MS = 10000;
|
|
16
|
+
/** Upper bound used when the caller doesn't pass an explicit limit. */
|
|
17
|
+
export const QUESTIONS_LIMIT_CAP = 100;
|
|
18
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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,uEAAuE;AACvE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,qCAAqC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAM,CAAC;AAEhD,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK discovery + auto-initialisation.
|
|
3
|
+
*
|
|
4
|
+
* Detects the API base URL (from the `<script>` tag or the page location),
|
|
5
|
+
* the active game slug, and the league/match context from the URL. Then
|
|
6
|
+
* exchanges a few postMessages with the host to pick up an auth token and the
|
|
7
|
+
* full bootstrap payload before opening a session and auto-joining any
|
|
8
|
+
* pending multiplayer room.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* One-off environment detection. Should be called exactly once at SDK boot
|
|
12
|
+
* time, before any other Init function. Must run in a browser — calling it
|
|
13
|
+
* server-side is a no-op. Idempotent: subsequent calls return immediately.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectEnvironment(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Orchestrates the full SDK boot sequence:
|
|
18
|
+
* 1. Request bootstrap config from the host (seeds slug + context).
|
|
19
|
+
* 2. Exchange for an auth token if we don't already have one.
|
|
20
|
+
* 3. Notify the host that we've booted, then fetch match context.
|
|
21
|
+
* 4. Open a session if we can, and auto-join any pending multiplayer room.
|
|
22
|
+
*
|
|
23
|
+
* Safe to call multiple times — concurrent callers share a single promise.
|
|
24
|
+
*/
|
|
25
|
+
export declare function autoInit(): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Ensures init has at least started; callers `await` this before touching
|
|
28
|
+
* any state that depends on bootstrap / auth having resolved.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureInitialized(): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Wires up the ambient message listener the host uses to push updates into
|
|
33
|
+
* the running SDK (fresh bootstrap, rotated auth, pause/resume commands).
|
|
34
|
+
*/
|
|
35
|
+
export declare function installHostMessageListener(): void;
|
|
36
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwBH;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAiExC;AA6HD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAyDjD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAK1D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CA6CjD"}
|
package/dist/src/init.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK discovery + auto-initialisation.
|
|
3
|
+
*
|
|
4
|
+
* Detects the API base URL (from the `<script>` tag or the page location),
|
|
5
|
+
* the active game slug, and the league/match context from the URL. Then
|
|
6
|
+
* exchanges a few postMessages with the host to pick up an auth token and the
|
|
7
|
+
* full bootstrap payload before opening a session and auto-joining any
|
|
8
|
+
* pending multiplayer room.
|
|
9
|
+
*/
|
|
10
|
+
import { state } from './state.js';
|
|
11
|
+
import { MESSAGE_PREFIX } from './constants.js';
|
|
12
|
+
import { isBrowser, readQueryParam, readCsvQueryParam, warn, error as logError, } from './utils.js';
|
|
13
|
+
import { mergeBootstrapConfig, requestBootstrapFromParent, getAuthTokenFromParent, sendToParent, } from './bridge.js';
|
|
14
|
+
import * as Multiplayer from './multiplayer.js';
|
|
15
|
+
import * as MatchCtx from './match-context.js';
|
|
16
|
+
import * as Session from './session.js';
|
|
17
|
+
let environmentDetected = false;
|
|
18
|
+
let hostListenerInstalled = false;
|
|
19
|
+
/**
|
|
20
|
+
* One-off environment detection. Should be called exactly once at SDK boot
|
|
21
|
+
* time, before any other Init function. Must run in a browser — calling it
|
|
22
|
+
* server-side is a no-op. Idempotent: subsequent calls return immediately.
|
|
23
|
+
*/
|
|
24
|
+
export function detectEnvironment() {
|
|
25
|
+
if (!isBrowser() || environmentDetected)
|
|
26
|
+
return;
|
|
27
|
+
environmentDetected = true;
|
|
28
|
+
state.sdkOrigin = window.location.origin;
|
|
29
|
+
// Detect when the game is being served under /games/<slug>/ or
|
|
30
|
+
// /uploaded-games/<slug>/ — this lets us infer both the slug and the
|
|
31
|
+
// mount point (which we use to build the API base URL).
|
|
32
|
+
const runtimePathMatch = window.location.pathname.match(/^(.*)\/(?:uploaded-games|games)\/([a-z0-9-]+)(?:\/|$)/i);
|
|
33
|
+
let detectedSlug = null;
|
|
34
|
+
if (runtimePathMatch) {
|
|
35
|
+
state.runtimeBasePath = runtimePathMatch[1] || '';
|
|
36
|
+
detectedSlug = runtimePathMatch[2] || null;
|
|
37
|
+
}
|
|
38
|
+
// Pull league/match context off the URL if present. The host may still
|
|
39
|
+
// override these later via postMessage.
|
|
40
|
+
state.leagueId = readQueryParam('leagueId');
|
|
41
|
+
state.gameId = readQueryParam('gameId');
|
|
42
|
+
state.matchId = readQueryParam('matchId');
|
|
43
|
+
state.participant1Id = readQueryParam('participant1Id');
|
|
44
|
+
state.participant2Id = readQueryParam('participant2Id');
|
|
45
|
+
state.participant1MemberIds = readCsvQueryParam('participant1MemberIds');
|
|
46
|
+
state.participant2MemberIds = readCsvQueryParam('participant2MemberIds');
|
|
47
|
+
// Locate our own <script> tag so we can honour `data-game-slug` and
|
|
48
|
+
// resolve the path prefix (needed when served from a subpath like /app).
|
|
49
|
+
const scripts = document.getElementsByTagName('script');
|
|
50
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
51
|
+
const src = scripts[i].src;
|
|
52
|
+
if (!src.includes('gamehub-sdk.js'))
|
|
53
|
+
continue;
|
|
54
|
+
try {
|
|
55
|
+
const parsedSrc = new URL(src, window.location.origin);
|
|
56
|
+
state.sdkOrigin = parsedSrc.origin;
|
|
57
|
+
const match = parsedSrc.pathname.match(/(.*)\/sdk\/gamehub-sdk\.js$/);
|
|
58
|
+
state.sdkPathPrefix = match ? match[1] || '' : '';
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
const match = src.match(/(.*)\/sdk\/gamehub-sdk\.js/);
|
|
62
|
+
if (match) {
|
|
63
|
+
const fallbackUrl = new URL(match[1], window.location.origin);
|
|
64
|
+
state.sdkOrigin = fallbackUrl.origin;
|
|
65
|
+
state.sdkPathPrefix = fallbackUrl.pathname || '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const slugAttr = scripts[i].getAttribute('data-game-slug');
|
|
69
|
+
if (slugAttr)
|
|
70
|
+
detectedSlug = slugAttr;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
// Final fallback: look for a games slug in the path even if we didn't
|
|
74
|
+
// match the full pattern earlier.
|
|
75
|
+
if (!detectedSlug) {
|
|
76
|
+
const pathMatch = window.location.pathname.match(/\/(?:uploaded-games|games)\/([a-z0-9-]+)\//i);
|
|
77
|
+
if (pathMatch)
|
|
78
|
+
detectedSlug = pathMatch[1];
|
|
79
|
+
}
|
|
80
|
+
const effectiveBasePath = state.sdkPathPrefix || state.runtimeBasePath || '';
|
|
81
|
+
state.apiBase = state.sdkOrigin + effectiveBasePath + '/api';
|
|
82
|
+
state.gameSlug = detectedSlug;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns the share ID we should auto-join on boot, if any. Bootstrap takes
|
|
86
|
+
* priority over URL params so hosts can override a stale link.
|
|
87
|
+
*/
|
|
88
|
+
function getPendingShareId() {
|
|
89
|
+
if (state.bootstrapShareId)
|
|
90
|
+
return state.bootstrapShareId;
|
|
91
|
+
return readQueryParam('mp');
|
|
92
|
+
}
|
|
93
|
+
/** Same as {@link getPendingShareId} but for room codes. */
|
|
94
|
+
function getPendingRoomCode() {
|
|
95
|
+
if (state.bootstrapRoomCode)
|
|
96
|
+
return state.bootstrapRoomCode;
|
|
97
|
+
const roomCode = readQueryParam('roomCode');
|
|
98
|
+
return roomCode ? roomCode.trim().toUpperCase() : null;
|
|
99
|
+
}
|
|
100
|
+
function getPendingRoomRole() {
|
|
101
|
+
if (state.bootstrapRoomRole)
|
|
102
|
+
return state.bootstrapRoomRole;
|
|
103
|
+
const role = readQueryParam('roomRole');
|
|
104
|
+
return role ? role.trim() : null;
|
|
105
|
+
}
|
|
106
|
+
function getPendingRoomToken() {
|
|
107
|
+
if (state.bootstrapRoomToken)
|
|
108
|
+
return state.bootstrapRoomToken;
|
|
109
|
+
const roomToken = readQueryParam('roomToken');
|
|
110
|
+
return roomToken ? roomToken.trim() : null;
|
|
111
|
+
}
|
|
112
|
+
function getPendingWsUrl() {
|
|
113
|
+
if (state.bootstrapWsUrl)
|
|
114
|
+
return state.bootstrapWsUrl;
|
|
115
|
+
const wsUrl = readQueryParam('wsUrl');
|
|
116
|
+
return wsUrl ? wsUrl.trim() : null;
|
|
117
|
+
}
|
|
118
|
+
/** Same as {@link getPendingShareId} but for the host-preferred display name. */
|
|
119
|
+
function getPendingPlayerName() {
|
|
120
|
+
if (state.bootstrapPlayerName)
|
|
121
|
+
return state.bootstrapPlayerName;
|
|
122
|
+
const playerName = readQueryParam('playerName');
|
|
123
|
+
return playerName ? playerName.trim() : undefined;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the peerId for "this player" — bootstrap wins over the URL so the
|
|
127
|
+
* host can correct a stale link. Populated opportunistically so games know
|
|
128
|
+
* their assigned peerId before the multiplayer WS has joined.
|
|
129
|
+
*/
|
|
130
|
+
function seedPeerIdFromUrl() {
|
|
131
|
+
if (state.bootstrapPeerId)
|
|
132
|
+
return;
|
|
133
|
+
const fromUrl = readQueryParam('peerId');
|
|
134
|
+
if (fromUrl)
|
|
135
|
+
state.bootstrapPeerId = fromUrl.trim();
|
|
136
|
+
}
|
|
137
|
+
function resumePendingRoomFromBootstrap() {
|
|
138
|
+
const roomCode = getPendingRoomCode();
|
|
139
|
+
const roomToken = getPendingRoomToken();
|
|
140
|
+
const wsUrl = getPendingWsUrl();
|
|
141
|
+
const peerId = state.bootstrapPeerId ||
|
|
142
|
+
readQueryParam('peerId')?.trim() ||
|
|
143
|
+
null;
|
|
144
|
+
if (!state.gameSlug || !roomCode || !roomToken || !wsUrl || !peerId) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const role = getPendingRoomRole() || 'player';
|
|
148
|
+
state.mpViewerOverride = role === 'viewer';
|
|
149
|
+
state.mpRoom = {
|
|
150
|
+
roomCode,
|
|
151
|
+
shareId: state.bootstrapShareId || '',
|
|
152
|
+
peerId,
|
|
153
|
+
role,
|
|
154
|
+
gameSlug: state.gameSlug,
|
|
155
|
+
roomToken,
|
|
156
|
+
wsUrl,
|
|
157
|
+
};
|
|
158
|
+
state.mpLastJoinRequest = {
|
|
159
|
+
roomCode,
|
|
160
|
+
roomToken,
|
|
161
|
+
wsUrl,
|
|
162
|
+
gameSlug: state.gameSlug,
|
|
163
|
+
peerId,
|
|
164
|
+
};
|
|
165
|
+
Multiplayer.connect(state.mpLastJoinRequest);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
async function autoJoinPendingShare() {
|
|
169
|
+
const shareId = getPendingShareId();
|
|
170
|
+
if (!shareId)
|
|
171
|
+
return;
|
|
172
|
+
if (state.lastAutoJoinShareId === shareId)
|
|
173
|
+
return;
|
|
174
|
+
try {
|
|
175
|
+
state.lastAutoJoinShareId = shareId;
|
|
176
|
+
await Multiplayer.joinRoomByLink(shareId, {
|
|
177
|
+
displayName: getPendingPlayerName(),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
state.lastAutoJoinShareId = null;
|
|
182
|
+
warn('Auto join by link failed: ' + (err?.message || err));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function autoJoinPendingRoomCode() {
|
|
186
|
+
const roomCode = getPendingRoomCode();
|
|
187
|
+
if (!roomCode)
|
|
188
|
+
return;
|
|
189
|
+
if (state.lastAutoJoinRoomCode === roomCode)
|
|
190
|
+
return;
|
|
191
|
+
try {
|
|
192
|
+
state.lastAutoJoinRoomCode = roomCode;
|
|
193
|
+
if (resumePendingRoomFromBootstrap()) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
await Multiplayer.joinRoom(roomCode, {
|
|
197
|
+
displayName: getPendingPlayerName(),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
state.lastAutoJoinRoomCode = null;
|
|
202
|
+
warn('Auto join by room code failed: ' + (err?.message || err));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Orchestrates the full SDK boot sequence:
|
|
207
|
+
* 1. Request bootstrap config from the host (seeds slug + context).
|
|
208
|
+
* 2. Exchange for an auth token if we don't already have one.
|
|
209
|
+
* 3. Notify the host that we've booted, then fetch match context.
|
|
210
|
+
* 4. Open a session if we can, and auto-join any pending multiplayer room.
|
|
211
|
+
*
|
|
212
|
+
* Safe to call multiple times — concurrent callers share a single promise.
|
|
213
|
+
*/
|
|
214
|
+
export async function autoInit() {
|
|
215
|
+
if (!isBrowser())
|
|
216
|
+
return false;
|
|
217
|
+
if (state.isInitialized || state.isAutoInitializing)
|
|
218
|
+
return state.autoInitPromise;
|
|
219
|
+
// Module consumers (e.g. Angular services) call `createSdk()` directly
|
|
220
|
+
// without going through the script-tag entry, so they may not have run
|
|
221
|
+
// these themselves. Both functions are idempotent — safe to call again
|
|
222
|
+
// when the script-tag entry has already invoked them.
|
|
223
|
+
detectEnvironment();
|
|
224
|
+
installHostMessageListener();
|
|
225
|
+
state.isAutoInitializing = true;
|
|
226
|
+
state.autoInitPromise = (async () => {
|
|
227
|
+
try {
|
|
228
|
+
await requestBootstrapFromParent();
|
|
229
|
+
seedPeerIdFromUrl();
|
|
230
|
+
if (!state.gameSlug) {
|
|
231
|
+
warn('Could not resolve game slug. Ensure the host page sends bootstrap config or serves the game under /games/{slug}.');
|
|
232
|
+
state.isAutoInitializing = false;
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
if (!state.authToken) {
|
|
236
|
+
state.authToken = await getAuthTokenFromParent();
|
|
237
|
+
}
|
|
238
|
+
state.isInitialized = true;
|
|
239
|
+
state.isAutoInitializing = false;
|
|
240
|
+
sendToParent('INIT', {
|
|
241
|
+
slug: state.gameSlug,
|
|
242
|
+
auto: true,
|
|
243
|
+
});
|
|
244
|
+
await MatchCtx.fetchMatchContext();
|
|
245
|
+
if (state.authToken ||
|
|
246
|
+
(state.leagueId && state.gameId && state.matchId)) {
|
|
247
|
+
state.sessionStartPromise = Session.startSession();
|
|
248
|
+
}
|
|
249
|
+
await autoJoinPendingShare();
|
|
250
|
+
await autoJoinPendingRoomCode();
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
logError('Auto-init failed:', err);
|
|
255
|
+
state.isAutoInitializing = false;
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
})();
|
|
259
|
+
return state.autoInitPromise;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Ensures init has at least started; callers `await` this before touching
|
|
263
|
+
* any state that depends on bootstrap / auth having resolved.
|
|
264
|
+
*/
|
|
265
|
+
export async function ensureInitialized() {
|
|
266
|
+
if (state.isInitialized)
|
|
267
|
+
return true;
|
|
268
|
+
if (!isBrowser())
|
|
269
|
+
return false;
|
|
270
|
+
if (state.autoInitPromise)
|
|
271
|
+
return await state.autoInitPromise;
|
|
272
|
+
return await autoInit();
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Wires up the ambient message listener the host uses to push updates into
|
|
276
|
+
* the running SDK (fresh bootstrap, rotated auth, pause/resume commands).
|
|
277
|
+
*/
|
|
278
|
+
export function installHostMessageListener() {
|
|
279
|
+
if (!isBrowser() || hostListenerInstalled)
|
|
280
|
+
return;
|
|
281
|
+
hostListenerInstalled = true;
|
|
282
|
+
window.addEventListener('message', (event) => {
|
|
283
|
+
if (!event.data || !event.data.type)
|
|
284
|
+
return;
|
|
285
|
+
const type = event.data.type;
|
|
286
|
+
if (type === MESSAGE_PREFIX + '_BOOTSTRAP' && event.data.payload) {
|
|
287
|
+
state.parentOrigin = event.origin;
|
|
288
|
+
state.bootstrapReceived = true;
|
|
289
|
+
mergeBootstrapConfig(event.data.payload);
|
|
290
|
+
if (state.isInitialized && state.bootstrapShareId && !state.mpRoom) {
|
|
291
|
+
autoJoinPendingShare();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (type === MESSAGE_PREFIX + '_SET_AUTH') {
|
|
295
|
+
state.authToken = event.data.token;
|
|
296
|
+
state.parentOrigin = event.origin;
|
|
297
|
+
if (state.gameSlug &&
|
|
298
|
+
!state.sessionToken &&
|
|
299
|
+
!state.sessionStartPromise &&
|
|
300
|
+
(state.authToken || (state.leagueId && state.gameId && state.matchId))) {
|
|
301
|
+
state.sessionStartPromise = Session.startSession();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (type === MESSAGE_PREFIX + '_COMMAND') {
|
|
305
|
+
const command = event.data.command;
|
|
306
|
+
const w = window;
|
|
307
|
+
if (command === 'pause' && typeof w.onGameHubPause === 'function') {
|
|
308
|
+
w.onGameHubPause();
|
|
309
|
+
}
|
|
310
|
+
else if (command === 'resume' &&
|
|
311
|
+
typeof w.onGameHubResume === 'function') {
|
|
312
|
+
w.onGameHubResume();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,KAAK,IAAI,QAAQ,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,qBAAqB,GAAG,KAAK,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC,SAAS,EAAE,IAAI,mBAAmB;QAAE,OAAO;IAChD,mBAAmB,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,MAA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 -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public SDK module entry. Exports `createSdk` (the factory) and every
|
|
3
|
+
* public type. Importing this module has no side effects — it does not
|
|
4
|
+
* touch `window`, `document`, or run any boot logic.
|
|
5
|
+
*
|
|
6
|
+
* For the legacy `<script>`-tag distribution that auto-attaches
|
|
7
|
+
* `window.GameHubSDK` and runs `autoInit()`, see `./browser-entry.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import type { BootstrapData } from '../types/bootstrap.js';
|
|
10
|
+
import type { MatchContext, MatchResultPayload } from '../types/match.js';
|
|
11
|
+
import type { CreateRoomResult, JoinOptions, JoinRoomResult, MpEventHandler, Peer, RoomInfo, RoomOptions, SendOptions } from '../types/multiplayer.js';
|
|
12
|
+
import type { EventData, GameCompleteData, Question, QuestionOptions, ScoreMetadata, StartSessionResult, SubmitScoreResult } from '../types/session.js';
|
|
13
|
+
export type { ApiRequestOptions, ApiResponse } from '../types/api.js';
|
|
14
|
+
export type { BootstrapConfig, BootstrapData, BootstrapRoom, } from '../types/bootstrap.js';
|
|
15
|
+
export type { MatchContext, MatchParticipant, MatchParticipantMember, MatchResultPayload, } from '../types/match.js';
|
|
16
|
+
export type { CreateRoomResult, JoinInfo, JoinOptions, JoinRoomResult, MpEventHandler, MpJoinRequest, MpMessage, MpRoom, Peer, RoomInfo, RoomOptions, SendOptions, } from '../types/multiplayer.js';
|
|
17
|
+
export type { EventData, GameCompleteData, Question, QuestionOptions, ScoreMetadata, StartSessionResult, SubmitScoreResult, } from '../types/session.js';
|
|
18
|
+
/**
|
|
19
|
+
* Shape of `window.GameHubSDK`. Documented separately from the
|
|
20
|
+
* implementation so the public API is easy to scan.
|
|
21
|
+
*/
|
|
22
|
+
export interface Sdk {
|
|
23
|
+
readonly version: string;
|
|
24
|
+
/** @returns true after auto-init has successfully resolved. */
|
|
25
|
+
isInitialized(): boolean;
|
|
26
|
+
/** @returns true when an auth token is currently known. */
|
|
27
|
+
isAuthenticated(): boolean;
|
|
28
|
+
/** @returns true when a live session token has been issued. */
|
|
29
|
+
hasActiveSession(): boolean;
|
|
30
|
+
/** Manually start a session (auto-init already attempts this). */
|
|
31
|
+
startSession(): Promise<StartSessionResult>;
|
|
32
|
+
/** Submit a final score for the current session. */
|
|
33
|
+
submitScore(score: number, meta?: ScoreMetadata): Promise<SubmitScoreResult>;
|
|
34
|
+
/** Submit a score attached to the active league match. */
|
|
35
|
+
submitMatchScore(score: number, meta?: ScoreMetadata): Promise<SubmitScoreResult>;
|
|
36
|
+
/** Submit a full match result (winner, scores, etc.). */
|
|
37
|
+
submitMatchResult(result?: MatchResultPayload): Promise<SubmitScoreResult>;
|
|
38
|
+
/** Signal the host that the game is ready to begin another round. */
|
|
39
|
+
playAgain(): Promise<{
|
|
40
|
+
success: boolean;
|
|
41
|
+
token: string | null;
|
|
42
|
+
}>;
|
|
43
|
+
/** Tell the host the game has finished (shows completion UI). */
|
|
44
|
+
notifyComplete(data?: GameCompleteData): void;
|
|
45
|
+
/** Ask the host to close the game/iframe and return to the lobby. */
|
|
46
|
+
requestClose(): void;
|
|
47
|
+
/** Emit a custom analytics event to the host. */
|
|
48
|
+
logEvent(eventName: string, eventData?: EventData): void;
|
|
49
|
+
/** @returns the resolved game slug, or null if we never found one. */
|
|
50
|
+
getGameSlug(): string | null;
|
|
51
|
+
/** @returns whether the SDK is running inside an iframe. */
|
|
52
|
+
isInIframe(): boolean;
|
|
53
|
+
/** Awaitable barrier — resolves when the SDK has booted. */
|
|
54
|
+
ready(): Promise<boolean>;
|
|
55
|
+
/** @returns a snapshot of bootstrap-sourced state for debugging. */
|
|
56
|
+
getBootstrap(): BootstrapData;
|
|
57
|
+
/** Fetch the match context (lazy; cached after first success). */
|
|
58
|
+
getMatchContext(): Promise<MatchContext | null>;
|
|
59
|
+
/** Fetch questions for quiz-style games. Returns [] on failure. */
|
|
60
|
+
getQuestions(options?: QuestionOptions): Promise<Question[]>;
|
|
61
|
+
/** Multiplayer sub-API. */
|
|
62
|
+
multiplayer: {
|
|
63
|
+
createRoom(options?: RoomOptions): Promise<CreateRoomResult>;
|
|
64
|
+
joinRoom(roomCode: string, options?: JoinOptions): Promise<JoinRoomResult>;
|
|
65
|
+
joinRoomByLink(link: string, options?: JoinOptions): Promise<JoinRoomResult>;
|
|
66
|
+
leaveRoom(reason?: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Send a custom event to every peer in the room. Blocked for viewers.
|
|
69
|
+
* Pass `{ retain: true, retainKey }` (host only on the server side) to
|
|
70
|
+
* pin the latest frame so peers joining/reconnecting later receive it
|
|
71
|
+
* before live traffic.
|
|
72
|
+
*/
|
|
73
|
+
send(eventName: string, payload?: Record<string, any>, options?: SendOptions): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Host-only send. No-ops for guests and viewers. Use this for
|
|
76
|
+
* authoritative state updates (grid shuffles, turn changes, round end).
|
|
77
|
+
* Pair with `{ retain: true, retainKey }` to make the latest snapshot
|
|
78
|
+
* automatically replay to late joiners and reconnecting peers.
|
|
79
|
+
*/
|
|
80
|
+
broadcast(eventName: string, payload?: Record<string, any>, options?: SendOptions): boolean;
|
|
81
|
+
on(eventName: string, handler: MpEventHandler): () => void;
|
|
82
|
+
getRoom(): RoomInfo | null;
|
|
83
|
+
getPeers(): Peer[];
|
|
84
|
+
isConnected(): boolean;
|
|
85
|
+
/** @returns the peer's role (`host`, `player`, `viewer`) or null. */
|
|
86
|
+
getRole(): string | null;
|
|
87
|
+
/** @returns true if this peer is the authoritative host. */
|
|
88
|
+
isHost(): boolean;
|
|
89
|
+
/** @returns true if this peer joined as a view-only guest. */
|
|
90
|
+
isViewer(): boolean;
|
|
91
|
+
/** @returns the peerId of the local player (self), or null. */
|
|
92
|
+
selfId(): string | null;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Assemble the public API object. Methods are thin adapters that route to
|
|
97
|
+
* the internal modules — keeping the surface area small and the internals
|
|
98
|
+
* freely refactorable.
|
|
99
|
+
*/
|
|
100
|
+
export declare function createSdk(): Sdk;
|
|
101
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAI7B,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtE,YAAY,EACV,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,SAAS,EACT,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,+DAA+D;IAC/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