@ksaa-nlp/gamehub-react-native-sdk 0.0.0-stage → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +272 -2
- package/SPEC.md +265 -0
- package/dist/src/api-client.d.ts +7 -0
- package/dist/src/api-client.d.ts.map +1 -0
- package/dist/src/api-client.js +123 -0
- package/dist/src/api-client.js.map +1 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +45 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/content.d.ts +7 -0
- package/dist/src/content.d.ts.map +1 -0
- package/dist/src/content.js +70 -0
- package/dist/src/content.js.map +1 -0
- package/dist/src/host-events.d.ts +7 -0
- package/dist/src/host-events.d.ts.map +1 -0
- package/dist/src/host-events.js +20 -0
- package/dist/src/host-events.js.map +1 -0
- package/dist/src/identity.d.ts +10 -0
- package/dist/src/identity.d.ts.map +1 -0
- package/dist/src/identity.js +27 -0
- package/dist/src/identity.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +54 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/launch.d.ts +16 -0
- package/dist/src/launch.d.ts.map +1 -0
- package/dist/src/launch.js +115 -0
- package/dist/src/launch.js.map +1 -0
- package/dist/src/lobby-request.d.ts +4 -0
- package/dist/src/lobby-request.d.ts.map +1 -0
- package/dist/src/lobby-request.js +46 -0
- package/dist/src/lobby-request.js.map +1 -0
- package/dist/src/lobby.d.ts +33 -0
- package/dist/src/lobby.d.ts.map +1 -0
- package/dist/src/lobby.js +308 -0
- package/dist/src/lobby.js.map +1 -0
- package/dist/src/match-context.d.ts +10 -0
- package/dist/src/match-context.d.ts.map +1 -0
- package/dist/src/match-context.js +41 -0
- package/dist/src/match-context.js.map +1 -0
- package/dist/src/multiplayer-client.d.ts +27 -0
- package/dist/src/multiplayer-client.d.ts.map +1 -0
- package/dist/src/multiplayer-client.js +163 -0
- package/dist/src/multiplayer-client.js.map +1 -0
- package/dist/src/multiplayer-react.d.ts +4 -0
- package/dist/src/multiplayer-react.d.ts.map +1 -0
- package/dist/src/multiplayer-react.js +8 -0
- package/dist/src/multiplayer-react.js.map +1 -0
- package/dist/src/multiplayer-storage.d.ts +22 -0
- package/dist/src/multiplayer-storage.d.ts.map +1 -0
- package/dist/src/multiplayer-storage.js +65 -0
- package/dist/src/multiplayer-storage.js.map +1 -0
- package/dist/src/multiplayer-types.d.ts +54 -0
- package/dist/src/multiplayer-types.d.ts.map +1 -0
- package/dist/src/multiplayer-types.js +2 -0
- package/dist/src/multiplayer-types.js.map +1 -0
- package/dist/src/multiplayer.d.ts +5 -0
- package/dist/src/multiplayer.d.ts.map +1 -0
- package/dist/src/multiplayer.js +4 -0
- package/dist/src/multiplayer.js.map +1 -0
- package/dist/src/react.d.ts +11 -0
- package/dist/src/react.d.ts.map +1 -0
- package/dist/src/react.js +20 -0
- package/dist/src/react.js.map +1 -0
- package/dist/src/score.d.ts +9 -0
- package/dist/src/score.d.ts.map +1 -0
- package/dist/src/score.js +168 -0
- package/dist/src/score.js.map +1 -0
- package/dist/src/session-view.d.ts +4 -0
- package/dist/src/session-view.d.ts.map +1 -0
- package/dist/src/session-view.js +276 -0
- package/dist/src/session-view.js.map +1 -0
- package/dist/src/session.d.ts +10 -0
- package/dist/src/session.d.ts.map +1 -0
- package/dist/src/session.js +142 -0
- package/dist/src/session.js.map +1 -0
- package/dist/src/settings.d.ts +4 -0
- package/dist/src/settings.d.ts.map +1 -0
- package/dist/src/settings.js +40 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/types.d.ts +125 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +5 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +16 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/vendor/colyseus-schemas/clock.d.ts +15 -0
- package/dist/vendor/colyseus-schemas/clock.js +67 -0
- package/dist/vendor/colyseus-schemas/common.d.ts +35 -0
- package/dist/vendor/colyseus-schemas/common.js +15 -0
- package/dist/vendor/colyseus-schemas/multiplayer.d.ts +8 -0
- package/dist/vendor/colyseus-schemas/multiplayer.js +26 -0
- package/dist/vendor/colyseus-schemas/ugc.d.ts +53 -0
- package/dist/vendor/colyseus-schemas/ugc.js +124 -0
- package/dist/vendor/gamehub-multiplayer-contracts/index.d.ts +200 -0
- package/dist/vendor/gamehub-multiplayer-contracts/index.js +289 -0
- package/dist/vendor/match.d.ts +37 -0
- package/dist/vendor/match.d.ts.map +1 -0
- package/dist/vendor/match.js +2 -0
- package/dist/vendor/match.js.map +1 -0
- package/dist/vendor/multiplayer-client.d.ts +50 -0
- package/dist/vendor/multiplayer-client.d.ts.map +1 -0
- package/dist/vendor/multiplayer-client.js +268 -0
- package/dist/vendor/multiplayer-client.js.map +1 -0
- package/dist/vendor/multiplayer-session.d.ts +82 -0
- package/dist/vendor/multiplayer-session.d.ts.map +1 -0
- package/dist/vendor/multiplayer-session.js +2 -0
- package/dist/vendor/multiplayer-session.js.map +1 -0
- package/dist/vendor/question.d.ts +35 -0
- package/dist/vendor/question.d.ts.map +1 -0
- package/dist/vendor/question.js +20 -0
- package/dist/vendor/question.js.map +1 -0
- package/dist/vendor/session.d.ts +158 -0
- package/dist/vendor/session.d.ts.map +1 -0
- package/dist/vendor/session.js +2 -0
- package/dist/vendor/session.js.map +1 -0
- package/dist/vendor/word.d.ts +147 -0
- package/dist/vendor/word.d.ts.map +1 -0
- package/dist/vendor/word.js +15 -0
- package/dist/vendor/word.js.map +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { record } from './utils.js';
|
|
2
|
+
/** Direct native HTTP transport: bounded requests, envelopes and identity fencing. */
|
|
3
|
+
export function createApiClient(config, identity) {
|
|
4
|
+
const { base, fetcher, timeoutMs } = config;
|
|
5
|
+
async function request(path, generation, body, resumeToken) {
|
|
6
|
+
if (!identity.isCurrent(generation))
|
|
7
|
+
return {
|
|
8
|
+
success: false,
|
|
9
|
+
error: { code: 'IDENTITY_CHANGED', message: 'Authentication changed' },
|
|
10
|
+
};
|
|
11
|
+
const capturedToken = identity.token;
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
let timer;
|
|
14
|
+
try {
|
|
15
|
+
const result = await Promise.race([
|
|
16
|
+
(async () => {
|
|
17
|
+
const response = await fetcher(base + path, {
|
|
18
|
+
method: body === undefined ? 'GET' : 'POST',
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
...(capturedToken
|
|
22
|
+
? { Authorization: `Bearer ${capturedToken}` }
|
|
23
|
+
: {}),
|
|
24
|
+
...(resumeToken ? { 'x-gamehub-resume': resumeToken } : {}),
|
|
25
|
+
},
|
|
26
|
+
signal: controller.signal,
|
|
27
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
28
|
+
});
|
|
29
|
+
const json = await response.json();
|
|
30
|
+
const envelope = record(json);
|
|
31
|
+
if (!envelope || typeof envelope.success !== 'boolean') {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
error: {
|
|
35
|
+
code: 'MALFORMED_RESPONSE',
|
|
36
|
+
message: 'Invalid API response',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (!response.ok && envelope.success) {
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
error: {
|
|
44
|
+
code: `HTTP_${response.status}`,
|
|
45
|
+
message: 'HTTP request failed',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (envelope.success)
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
data: envelope.data,
|
|
53
|
+
...(typeof envelope.token === 'string'
|
|
54
|
+
? { token: envelope.token }
|
|
55
|
+
: {}),
|
|
56
|
+
};
|
|
57
|
+
// Validate the untrusted error fields before exposing typed results.
|
|
58
|
+
const error = record(envelope.error);
|
|
59
|
+
const details = record(error?.details);
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
error: {
|
|
63
|
+
code: typeof error?.code === 'string' ? error.code : 'SERVER_ERROR',
|
|
64
|
+
message: typeof error?.message === 'string'
|
|
65
|
+
? error.message
|
|
66
|
+
: 'Request failed',
|
|
67
|
+
...(typeof error?.retryable === 'boolean'
|
|
68
|
+
? { retryable: error.retryable }
|
|
69
|
+
: {}),
|
|
70
|
+
...(details
|
|
71
|
+
? {
|
|
72
|
+
details: {
|
|
73
|
+
...(details.terminal === true ? { terminal: true } : {}),
|
|
74
|
+
...(typeof details.sessionStatus === 'string'
|
|
75
|
+
? { sessionStatus: details.sessionStatus }
|
|
76
|
+
: {}),
|
|
77
|
+
...(typeof details.retryAfterMs === 'number'
|
|
78
|
+
? { retryAfterMs: details.retryAfterMs }
|
|
79
|
+
: {}),
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
})(),
|
|
86
|
+
new Promise((resolve) => {
|
|
87
|
+
timer = setTimeout(() => {
|
|
88
|
+
resolve({
|
|
89
|
+
success: false,
|
|
90
|
+
error: { code: 'REQUEST_TIMEOUT', message: 'Request timed out' },
|
|
91
|
+
});
|
|
92
|
+
controller.abort();
|
|
93
|
+
}, timeoutMs);
|
|
94
|
+
}),
|
|
95
|
+
]);
|
|
96
|
+
return identity.isCurrent(generation)
|
|
97
|
+
? result
|
|
98
|
+
: {
|
|
99
|
+
success: false,
|
|
100
|
+
error: {
|
|
101
|
+
code: 'IDENTITY_CHANGED',
|
|
102
|
+
message: 'Authentication changed',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
error: {
|
|
110
|
+
code: identity.isCurrent(generation)
|
|
111
|
+
? 'TRANSPORT_ERROR'
|
|
112
|
+
: 'IDENTITY_CHANGED',
|
|
113
|
+
message: 'Request failed',
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return request;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/api-client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAC7B,MAAoB,EACpB,QAAwB;IAExB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC5C,KAAK,UAAU,OAAO,CACpB,IAAY,EACZ,UAAkB,EAClB,IAAc,EACd,WAAoB;QAEpB,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC;YACjC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAwB,EAAE;aACvE,CAAC;QACJ,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC;QACrC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,IAAI,KAAgD,CAAC;QACrD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAChC,CAAC,KAAK,IAA0B,EAAE;oBAChC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE;wBAC1C,MAAM,EA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CAAC,CAAC,EAAE,CAAC;qCACR;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;yBACR;qBACF,CAAC;gBACJ,CAAC,CAAC,EAAE;gBACJ,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,EAAE;oBACnC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;wBACtB,OAAO,CAAC;4BACN,OAAO,EAAE,KAAK;4BACd,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAmB,EAAE;yBACjE,CAAC,CAAC;wBACH,UAAU,CAAC,KAAK,EAAE,CAAC;oBACrB,CAAC,EAAE,SAAS,CAAC,CAAC;gBAChB,CAAC,CAAC;aACH,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC;gBACnC,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE;wBACL,IAAI,EAAE,kBAAkB;wBACxB,OAAO,EAAE,wBAAwB;qBAClC;iBACF,CAAC;QACR,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC;wBAClC,CAAC,CAAC,iBAAiB;wBACnB,CAAC,CAAC,kBAAkB;oBACtB,OAAO,EAAE,gBAAgB;iBAC1B;aACF,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NativeSdkOptions } from './types.js';
|
|
2
|
+
/** Validate fixed game/HTTP configuration without starting network activity. */
|
|
3
|
+
export declare function resolveConfig(options: NativeSdkOptions): {
|
|
4
|
+
base: string;
|
|
5
|
+
gameSlug: string;
|
|
6
|
+
gameId: string | undefined;
|
|
7
|
+
leagueId: string | undefined;
|
|
8
|
+
matchId: string | undefined;
|
|
9
|
+
profileId: string | undefined;
|
|
10
|
+
onHostEvent: ((event: import("./types.js").NativeHostEvent) => void) | undefined;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
fetcher: typeof fetch;
|
|
13
|
+
};
|
|
14
|
+
export type NativeConfig = ReturnType<typeof resolveConfig>;
|
|
15
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoBnD,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB;;;;;;;;;;EAoCtD;AACD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { REQUEST_TIMEOUT_MS } from './constants.js';
|
|
2
|
+
function apiRoot(value) {
|
|
3
|
+
const url = new URL(value);
|
|
4
|
+
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
5
|
+
if ((url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) ||
|
|
6
|
+
url.username ||
|
|
7
|
+
url.password ||
|
|
8
|
+
url.search ||
|
|
9
|
+
url.hash) {
|
|
10
|
+
throw new TypeError('apiBaseUrl must use HTTPS (HTTP loopback is allowed), without credentials, query or hash');
|
|
11
|
+
}
|
|
12
|
+
return url.href.replace(/\/+$/, '');
|
|
13
|
+
}
|
|
14
|
+
/** Validate fixed game/HTTP configuration without starting network activity. */
|
|
15
|
+
export function resolveConfig(options) {
|
|
16
|
+
const base = apiRoot(options.apiBaseUrl);
|
|
17
|
+
const { gameSlug, gameId, leagueId, matchId, profileId, onHostEvent } = options;
|
|
18
|
+
if (typeof gameSlug !== 'string' || !gameSlug.trim())
|
|
19
|
+
throw new TypeError('gameSlug is required');
|
|
20
|
+
for (const value of [gameId, leagueId, matchId, profileId]) {
|
|
21
|
+
if (value !== undefined && (typeof value !== 'string' || !value.trim()))
|
|
22
|
+
throw new TypeError('Context IDs must be nonempty strings');
|
|
23
|
+
}
|
|
24
|
+
if ((leagueId && !gameId) || (matchId && !leagueId))
|
|
25
|
+
throw new TypeError('League context requires gameId; match context requires leagueId');
|
|
26
|
+
const timeoutMs = options.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
27
|
+
if (!Number.isFinite(timeoutMs) ||
|
|
28
|
+
timeoutMs <= 0 ||
|
|
29
|
+
timeoutMs > 2147483647)
|
|
30
|
+
throw new TypeError('Invalid requestTimeoutMs');
|
|
31
|
+
const fetcher = options.fetch ??
|
|
32
|
+
((...args) => globalThis.fetch(...args));
|
|
33
|
+
return {
|
|
34
|
+
base,
|
|
35
|
+
gameSlug,
|
|
36
|
+
gameId,
|
|
37
|
+
leagueId,
|
|
38
|
+
matchId,
|
|
39
|
+
profileId,
|
|
40
|
+
onHostEvent,
|
|
41
|
+
timeoutMs,
|
|
42
|
+
fetcher,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5E,IACE,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,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IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAClD,MAAM,OAAO,GACX,OAAO,CAAC,KAAK;QACb,CAAC,CAAC,GAAG,IAA8B,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAErE,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,OAAO;QACP,SAAS;QACT,WAAW;QACX,SAAS;QACT,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Package version and bounded defaults shared by native feature modules. */
|
|
2
|
+
export declare const SDK_VERSION = "1.1.1";
|
|
3
|
+
export declare const REQUEST_TIMEOUT_MS = 15000;
|
|
4
|
+
export declare const QUESTIONS_LIMIT_CAP = 100;
|
|
5
|
+
export declare const WORDS_LIMIT_CAP = 50;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Package version and bounded defaults shared by native feature modules. */
|
|
2
|
+
export const SDK_VERSION = '1.1.1';
|
|
3
|
+
export const REQUEST_TIMEOUT_MS = 15000;
|
|
4
|
+
export const QUESTIONS_LIMIT_CAP = 100;
|
|
5
|
+
export const WORDS_LIMIT_CAP = 50;
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAM,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NativeSdk } from './types.js';
|
|
2
|
+
import type { NativeConfig } from './config.js';
|
|
3
|
+
import type { NativeIdentity } from './identity.js';
|
|
4
|
+
import type { ApiRequest } from './api-client.js';
|
|
5
|
+
/** Question/word queries, profile selection, bounds and answer normalization. */
|
|
6
|
+
export declare function createContent(config: NativeConfig, identity: NativeIdentity, request: ApiRequest): Pick<NativeSdk, 'getQuestions' | 'getWords'>;
|
|
7
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAKV,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,UAAU,GAClB,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,UAAU,CAAC,CAoE9C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { QUESTIONS_LIMIT_CAP, WORDS_LIMIT_CAP } from './constants.js';
|
|
2
|
+
import { record } from './utils.js';
|
|
3
|
+
/** Question/word queries, profile selection, bounds and answer normalization. */
|
|
4
|
+
export function createContent(config, identity, request) {
|
|
5
|
+
const { gameSlug, gameId, profileId } = config;
|
|
6
|
+
async function content(kind, query) {
|
|
7
|
+
const generation = identity.generation;
|
|
8
|
+
try {
|
|
9
|
+
const { difficulty, category, limit, tags } = query;
|
|
10
|
+
if (difficulty && !['easy', 'medium', 'hard'].includes(difficulty))
|
|
11
|
+
return [];
|
|
12
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1))
|
|
13
|
+
return [];
|
|
14
|
+
if (tags !== undefined &&
|
|
15
|
+
(!Array.isArray(tags) || tags.some((tag) => typeof tag !== 'string')))
|
|
16
|
+
return [];
|
|
17
|
+
const cap = kind === 'questions' ? QUESTIONS_LIMIT_CAP : WORDS_LIMIT_CAP;
|
|
18
|
+
const params = new URLSearchParams({
|
|
19
|
+
random: 'true',
|
|
20
|
+
limit: String(Math.min(limit ?? cap, cap)),
|
|
21
|
+
});
|
|
22
|
+
if (gameId)
|
|
23
|
+
params.set('gameId', gameId);
|
|
24
|
+
if (difficulty)
|
|
25
|
+
params.set('difficulty', difficulty);
|
|
26
|
+
if (category !== undefined && category !== '')
|
|
27
|
+
params.set('category', String(category));
|
|
28
|
+
if (query.profileId || profileId)
|
|
29
|
+
params.set('profileId', query.profileId || profileId);
|
|
30
|
+
if (tags?.length)
|
|
31
|
+
params.set('tags', tags.join(','));
|
|
32
|
+
const response = await request(`/games/${encodeURIComponent(gameSlug)}/${kind}?${params}`, generation);
|
|
33
|
+
if (!response.success || !identity.isCurrent(generation))
|
|
34
|
+
return [];
|
|
35
|
+
const data = response.data;
|
|
36
|
+
const values = Array.isArray(data) ? data : record(data)?.[kind];
|
|
37
|
+
return Array.isArray(values) ? values : [];
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
async getQuestions(query = {}) {
|
|
45
|
+
const generation = identity.generation;
|
|
46
|
+
const values = await content('questions', query);
|
|
47
|
+
if (!identity.isCurrent(generation))
|
|
48
|
+
return [];
|
|
49
|
+
return values.flatMap((value) => {
|
|
50
|
+
const question = record(value);
|
|
51
|
+
if (!question || !['string', 'number'].includes(typeof question.answer))
|
|
52
|
+
return [];
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
...question,
|
|
56
|
+
answer: String(question.answer),
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
async getWords(query = {}) {
|
|
62
|
+
const generation = identity.generation;
|
|
63
|
+
const values = await content('words', query);
|
|
64
|
+
return identity.isCurrent(generation)
|
|
65
|
+
? values.filter((value) => record(value) !== null)
|
|
66
|
+
: [];
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/content.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAC3B,MAAoB,EACpB,QAAwB,EACxB,OAAmB;IAEnB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC/C,KAAK,UAAU,OAAO,CACpB,IAA2B,EAC3B,KAAkB;QAElB,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YACpD,IAAI,UAAU,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChE,OAAO,EAAE,CAAC;YACZ,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,C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QAAQ,CAAC,UAAU,CAAC;YACvC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC7C,OAAO,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC;gBACnC,CAAC,CAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAY;gBAC9D,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NativeHostEvent, NativeSdk, NativeSdkOptions } from './types.js';
|
|
2
|
+
/** Local app callbacks for UI/telemetry; consumer exceptions never escape. */
|
|
3
|
+
export declare function createHostEvents(onHostEvent: NativeSdkOptions['onHostEvent']): {
|
|
4
|
+
emit: (event: NativeHostEvent) => void;
|
|
5
|
+
methods: Pick<NativeSdk, "notifyComplete" | "requestClose" | "reportQuestion" | "reportWord" | "logEvent">;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=host-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-events.d.ts","sourceRoot":"","sources":["../../src/host-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/E,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC;kBACtD,eAAe,KAAG,IAAI;;EAyB5C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Local app callbacks for UI/telemetry; consumer exceptions never escape. */
|
|
2
|
+
export function createHostEvents(onHostEvent) {
|
|
3
|
+
function emit(event) {
|
|
4
|
+
try {
|
|
5
|
+
onHostEvent?.(event);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
/* Consumer UI must not change request outcomes. */
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const methods = {
|
|
12
|
+
notifyComplete: (data = {}) => emit({ type: 'GAME_COMPLETE', payload: data }),
|
|
13
|
+
requestClose: () => emit({ type: 'REQUEST_CLOSE', payload: {} }),
|
|
14
|
+
reportQuestion: (data) => emit({ type: 'QUESTION_REPORT', payload: data }),
|
|
15
|
+
reportWord: (data) => emit({ type: 'WORD_REPORT', payload: data }),
|
|
16
|
+
logEvent: (eventName, eventData = {}) => emit({ type: 'EVENT', payload: { eventName, eventData } }),
|
|
17
|
+
};
|
|
18
|
+
return { emit, methods };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=host-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-events.js","sourceRoot":"","sources":["../../src/host-events.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,WAA4C;IAC3E,SAAS,IAAI,CAAC,KAAsB;QAClC,IAAI,CAAC;YACH,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,mDAAmD;QACrD,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAOT;QACF,cAAc,EAAE,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,CAC5B,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAChD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAChE,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC1E,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAClE,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,CACtC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC;KAC7D,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Per-client token and generation. Async work must recheck before publishing. */
|
|
2
|
+
export declare class NativeIdentity {
|
|
3
|
+
token: string | null;
|
|
4
|
+
generation: number;
|
|
5
|
+
constructor(token: string | null | undefined);
|
|
6
|
+
isCurrent: (generation: number) => boolean;
|
|
7
|
+
invalidate(): void;
|
|
8
|
+
setToken(value: string | null): boolean;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAOA,kFAAkF;AAClF,qBAAa,cAAc;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,SAAK;gBAEH,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAG5C,SAAS,GAAI,YAAY,MAAM,aAAoC;IACnE,UAAU,IAAI,IAAI;IAGlB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;CAOxC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function tokenValue(value) {
|
|
2
|
+
if (value === null || value === undefined || value === '')
|
|
3
|
+
return null;
|
|
4
|
+
if (typeof value !== 'string' || /[\r\n]/.test(value))
|
|
5
|
+
throw new TypeError('Invalid authToken');
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
/** Per-client token and generation. Async work must recheck before publishing. */
|
|
9
|
+
export class NativeIdentity {
|
|
10
|
+
constructor(token) {
|
|
11
|
+
this.generation = 0;
|
|
12
|
+
this.isCurrent = (generation) => generation === this.generation;
|
|
13
|
+
this.token = tokenValue(token);
|
|
14
|
+
}
|
|
15
|
+
invalidate() {
|
|
16
|
+
++this.generation;
|
|
17
|
+
}
|
|
18
|
+
setToken(value) {
|
|
19
|
+
const next = tokenValue(value);
|
|
20
|
+
if (next === this.token)
|
|
21
|
+
return false;
|
|
22
|
+
this.token = next;
|
|
23
|
+
this.invalidate();
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,KAAgC;IAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACvE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kFAAkF;AAClF,MAAM,OAAO,cAAc;IAIzB,YAAY,KAAgC;QAF5C,eAAU,GAAG,CAAC,CAAC;QAKf,cAAS,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC;QAFjE,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,UAAU;QACR,EAAE,IAAI,CAAC,UAAU,CAAC;IACpB,CAAC;IACD,QAAQ,CAAC,KAAoB;QAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NativeSdk, NativeSdkOptions } from './types.js';
|
|
2
|
+
export type * from './types.js';
|
|
3
|
+
export { SDK_VERSION } from './constants.js';
|
|
4
|
+
/** Compose isolated feature owners. Configuration performs no network calls. */
|
|
5
|
+
export declare function createSdk(options: NativeSdkOptions): NativeSdk;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAY9D,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAiD9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SDK_VERSION } from './constants.js';
|
|
2
|
+
import { resolveConfig } from './config.js';
|
|
3
|
+
import { NativeIdentity } from './identity.js';
|
|
4
|
+
import { createApiClient } from './api-client.js';
|
|
5
|
+
import { createSession } from './session.js';
|
|
6
|
+
import { createMatchContext } from './match-context.js';
|
|
7
|
+
import { createContent } from './content.js';
|
|
8
|
+
import { createSettings } from './settings.js';
|
|
9
|
+
import { createHostEvents } from './host-events.js';
|
|
10
|
+
import { NativeLobby } from './lobby.js';
|
|
11
|
+
export { SDK_VERSION } from './constants.js';
|
|
12
|
+
/** Compose isolated feature owners. Configuration performs no network calls. */
|
|
13
|
+
export function createSdk(options) {
|
|
14
|
+
const config = resolveConfig(options);
|
|
15
|
+
const identity = new NativeIdentity(options.authToken);
|
|
16
|
+
const events = createHostEvents(config.onHostEvent);
|
|
17
|
+
const settings = createSettings(options.settings);
|
|
18
|
+
const request = createApiClient(config, identity);
|
|
19
|
+
const session = createSession(config, identity, request, events.emit, () => lobby.owns());
|
|
20
|
+
const matchContext = createMatchContext(config, identity, request);
|
|
21
|
+
const content = createContent(config, identity, request);
|
|
22
|
+
function clearIdentityState() {
|
|
23
|
+
session.reset();
|
|
24
|
+
matchContext.reset();
|
|
25
|
+
}
|
|
26
|
+
const lobby = new NativeLobby(options.multiplayer, config.gameSlug, config.profileId, (path, body, resumeToken) => request(path, identity.generation, body, resumeToken), () => {
|
|
27
|
+
identity.invalidate();
|
|
28
|
+
clearIdentityState();
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
version: SDK_VERSION,
|
|
32
|
+
getGameSlug: () => config.gameSlug,
|
|
33
|
+
isInitialized: () => true,
|
|
34
|
+
ready: async () => true,
|
|
35
|
+
isAuthenticated: () => Boolean(identity.token),
|
|
36
|
+
setAuthToken(value) {
|
|
37
|
+
if (!identity.setToken(value))
|
|
38
|
+
return;
|
|
39
|
+
clearIdentityState();
|
|
40
|
+
lobby.reset();
|
|
41
|
+
},
|
|
42
|
+
requestMultiplayerSession: lobby.request,
|
|
43
|
+
onMultiplayerSessionChange: lobby.subscribe,
|
|
44
|
+
getMultiplayerSession: lobby.snapshot,
|
|
45
|
+
getMultiplayerLaunch: lobby.launch,
|
|
46
|
+
requestMultiplayerLaunch: lobby.requestLaunch,
|
|
47
|
+
...session.methods,
|
|
48
|
+
getMatchContext: matchContext.getMatchContext,
|
|
49
|
+
...content,
|
|
50
|
+
...settings,
|
|
51
|
+
...events.methods,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,E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ome, type LaunchReference } from '#multiplayer-contracts';
|
|
2
|
+
import type { ApiResponse, NativeMultiplayerOptions } from './types.js';
|
|
3
|
+
export type LobbyTransport = (path: string, body: unknown, resumeToken?: string) => Promise<ApiResponse>;
|
|
4
|
+
/** Bound launch reservation requests; no sockets, polling or credential persistence. */
|
|
5
|
+
export declare class NativeLaunch {
|
|
6
|
+
private readonly config;
|
|
7
|
+
private readonly slug;
|
|
8
|
+
private readonly transport;
|
|
9
|
+
private readonly currentLaunch;
|
|
10
|
+
private readonly getGeneration;
|
|
11
|
+
private launching;
|
|
12
|
+
constructor(config: NativeMultiplayerOptions | undefined, slug: string, transport: LobbyTransport, currentLaunch: () => LaunchReference | null, getGeneration: () => number);
|
|
13
|
+
reset(): void;
|
|
14
|
+
request: () => Promise<LaunchOutcome>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=launch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAGxE,MAAM,MAAM,cAAc,GAAG,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B,wFAAwF;AACxF,qBAAa,YAAY;IAGrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC,OAAO,CAAC,SAAS,CAAuC;gBAErC,MAAM,EAAE,wBAAwB,GAAG,SAAS,EAC5C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,EACzB,aAAa,EAAE,MAAM,eAAe,GAAG,IAAI,EAC3C,aAAa,EAAE,MAAM,MAAM;IAE9C,KAAK,IAAI,IAAI;IAGb,OAAO,QAAO,OAAO,CAAC,aAAa,CAAC,CAkIlC;CACH"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ERROR_CODES, isLaunchOutcome, normalizeError, } from '#multiplayer-contracts';
|
|
2
|
+
import { freeze } from './utils.js';
|
|
3
|
+
/** Bound launch reservation requests; no sockets, polling or credential persistence. */
|
|
4
|
+
export class NativeLaunch {
|
|
5
|
+
constructor(config, slug, transport, currentLaunch, getGeneration) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
this.slug = slug;
|
|
8
|
+
this.transport = transport;
|
|
9
|
+
this.currentLaunch = currentLaunch;
|
|
10
|
+
this.getGeneration = getGeneration;
|
|
11
|
+
this.launching = null;
|
|
12
|
+
this.request = () => {
|
|
13
|
+
const fail = (code, message, retryable = false) => ({
|
|
14
|
+
status: retryable ? 'recoverable' : 'terminal',
|
|
15
|
+
error: { code, message, retryable },
|
|
16
|
+
});
|
|
17
|
+
if (!this.config)
|
|
18
|
+
return Promise.resolve(fail('PROTOCOL_UNSUPPORTED', 'Configure native multiplayer first'));
|
|
19
|
+
const launch = this.currentLaunch();
|
|
20
|
+
if (!launch)
|
|
21
|
+
return Promise.resolve(fail('STALE_ATTEMPT', 'No current round'));
|
|
22
|
+
if (this.launching)
|
|
23
|
+
return this.launching;
|
|
24
|
+
const generation = this.getGeneration();
|
|
25
|
+
const config = this.config;
|
|
26
|
+
const task = Promise.resolve()
|
|
27
|
+
.then(async () => {
|
|
28
|
+
const before = this.currentLaunch();
|
|
29
|
+
if (generation !== this.getGeneration() ||
|
|
30
|
+
!before ||
|
|
31
|
+
[
|
|
32
|
+
'multiplayerSessionId',
|
|
33
|
+
'roundId',
|
|
34
|
+
'attemptId',
|
|
35
|
+
'seatId',
|
|
36
|
+
'hostInstanceId',
|
|
37
|
+
].some((k) => before[k] !==
|
|
38
|
+
launch[k]))
|
|
39
|
+
return fail('STALE_ATTEMPT', 'Launch context changed');
|
|
40
|
+
let response;
|
|
41
|
+
try {
|
|
42
|
+
response = await this.transport(`/multiplayer/sessions/${encodeURIComponent(launch.multiplayerSessionId)}/launch`, {
|
|
43
|
+
gameSlug: this.slug,
|
|
44
|
+
hostInstanceId: config.hostInstanceId,
|
|
45
|
+
roundId: launch.roundId,
|
|
46
|
+
}, config.resumeToken);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return fail('UNAVAILABLE', 'Launch unavailable', true);
|
|
50
|
+
}
|
|
51
|
+
const current = this.currentLaunch();
|
|
52
|
+
if (generation !== this.getGeneration() ||
|
|
53
|
+
!current ||
|
|
54
|
+
[
|
|
55
|
+
'multiplayerSessionId',
|
|
56
|
+
'roundId',
|
|
57
|
+
'attemptId',
|
|
58
|
+
'seatId',
|
|
59
|
+
'hostInstanceId',
|
|
60
|
+
].some((k) => current[k] !==
|
|
61
|
+
launch[k]))
|
|
62
|
+
return fail('STALE_ATTEMPT', 'Launch context changed');
|
|
63
|
+
if (!response.success) {
|
|
64
|
+
const e = response.error;
|
|
65
|
+
if (e?.code &&
|
|
66
|
+
ERROR_CODES.includes(e.code))
|
|
67
|
+
return fail(e.code, e.message ?? e.code, e.retryable ?? normalizeError(e).retryable);
|
|
68
|
+
return fail('UNAVAILABLE', 'Launch unavailable', true);
|
|
69
|
+
}
|
|
70
|
+
const outcome = response.data;
|
|
71
|
+
if (!isLaunchOutcome(outcome))
|
|
72
|
+
return fail('PROTOCOL_UNSUPPORTED', 'Invalid launch response');
|
|
73
|
+
if (outcome.status === 'reserved' &&
|
|
74
|
+
(outcome.expiresAt <= Date.now() ||
|
|
75
|
+
[
|
|
76
|
+
'multiplayerSessionId',
|
|
77
|
+
'roundId',
|
|
78
|
+
'attemptId',
|
|
79
|
+
'seatId',
|
|
80
|
+
'hostInstanceId',
|
|
81
|
+
'gameUrl',
|
|
82
|
+
'scoreAuthority',
|
|
83
|
+
].some((k) => outcome.launch[k] !==
|
|
84
|
+
launch[k])))
|
|
85
|
+
return fail('STALE_ATTEMPT', 'Stale or unbound reservation');
|
|
86
|
+
return freeze(JSON.parse(JSON.stringify(outcome)));
|
|
87
|
+
})
|
|
88
|
+
.finally(() => {
|
|
89
|
+
if (this.launching === task)
|
|
90
|
+
this.launching = null;
|
|
91
|
+
})
|
|
92
|
+
.then((outcome) => {
|
|
93
|
+
const current = this.currentLaunch();
|
|
94
|
+
if (generation !== this.getGeneration() ||
|
|
95
|
+
!current ||
|
|
96
|
+
[
|
|
97
|
+
'multiplayerSessionId',
|
|
98
|
+
'roundId',
|
|
99
|
+
'attemptId',
|
|
100
|
+
'seatId',
|
|
101
|
+
'hostInstanceId',
|
|
102
|
+
].some((k) => current[k] !==
|
|
103
|
+
launch[k]))
|
|
104
|
+
return fail('STALE_ATTEMPT', 'Launch context changed');
|
|
105
|
+
return outcome;
|
|
106
|
+
});
|
|
107
|
+
this.launching = task;
|
|
108
|
+
return task;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
reset() {
|
|
112
|
+
this.launching = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,GAIf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAQpC,wFAAwF;AACxF,MAAM,OAAO,YAAY;IAEvB,YACmB,MAA4C,EAC5C,IAAY,EACZ,SAAyB,EACzB,aAA2C,EAC3C,aAA2B;QAJ3B,WAAM,GAAN,MAAM,CAAsC;QAC5C,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAA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C,MAAM,CAAC,CAA0B,CAAC,CACrC;oBAED,OAAO,IAAI,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC,CAAC;YACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IAtIC,CAAC;IACJ,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CAoIF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MultiplayerSessionRequest } from './types.js';
|
|
2
|
+
/** Validate game-owned lobby inputs; authority fields are supplied by the SDK. */
|
|
3
|
+
export declare function validRequest(value: unknown): value is MultiplayerSessionRequest;
|
|
4
|
+
//# sourceMappingURL=lobby-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lobby-request.d.ts","sourceRoot":"","sources":["../../src/lobby-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,kFAAkF;AAClF,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,yBAAyB,CA+CpC"}
|