@caisual/kit 0.5.0 → 0.10.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/dist/kit.d.ts +2 -175
- package/dist/kit.js +1808 -76
- package/dist/node.d.ts +1 -88
- package/dist/node.js +354 -96
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.js +2074 -0
- package/dist/runtime.d.ts +1 -111
- package/dist/runtime.js +335 -67
- package/dist/server.d.ts +1 -71
- package/dist/server.js +3 -0
- package/dist/types/api.d.ts +25 -0
- package/dist/types/contracts/biglietto.d.ts +24 -0
- package/dist/types/contracts/device.d.ts +66 -0
- package/dist/types/contracts/firma.d.ts +21 -0
- package/dist/types/contracts/i18n.d.ts +12 -0
- package/dist/types/contracts/index.d.ts +13 -0
- package/dist/types/contracts/keys.d.ts +59 -0
- package/dist/types/contracts/manifest.d.ts +123 -0
- package/dist/types/contracts/overlay-boards.d.ts +3 -0
- package/dist/types/contracts/overlay.d.ts +223 -0
- package/dist/types/contracts/player.d.ts +1 -0
- package/dist/types/contracts/room-limits.d.ts +13 -0
- package/dist/types/contracts/runtime.d.ts +70 -0
- package/dist/types/contracts/server-js.d.ts +11 -0
- package/dist/types/contracts/slug.d.ts +5 -0
- package/dist/types/contracts/token-crew.d.ts +21 -0
- package/dist/types/daily.d.ts +3 -0
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/handshake.d.ts +30 -0
- package/dist/types/http.d.ts +3 -0
- package/dist/types/index.d.ts +231 -0
- package/dist/types/kit.d.ts +28 -0
- package/dist/types/node/index.d.ts +97 -0
- package/dist/types/node/websocket.d.ts +29 -0
- package/dist/types/overlay/boards.d.ts +48 -0
- package/dist/types/overlay/bridge.d.ts +3 -0
- package/dist/types/overlay/host-bridge.d.ts +74 -0
- package/dist/types/overlay/i18n.d.ts +128 -0
- package/dist/types/overlay/index.d.ts +10 -0
- package/dist/types/overlay/shortcut.d.ts +4 -0
- package/dist/types/overlay/styles.d.ts +1 -0
- package/dist/types/overlay/ui-model.d.ts +45 -0
- package/dist/types/overlay/ui.d.ts +80 -0
- package/dist/types/overlay/voice-panel.d.ts +13 -0
- package/dist/types/protocollo.d.ts +262 -0
- package/dist/types/runtime/index.d.ts +128 -0
- package/dist/types/server/index.d.ts +76 -0
- package/dist/types/session/index.d.ts +49 -0
- package/dist/types/session/resume.d.ts +13 -0
- package/dist/types/standalone.d.ts +14 -0
- package/dist/types/stanza/index.d.ts +3 -0
- package/dist/types/stanza/json.d.ts +18 -0
- package/dist/types/stanza/nucleo.d.ts +100 -0
- package/dist/types/stanza/tipi.d.ts +136 -0
- package/dist/types/stanza-client/index.d.ts +24 -0
- package/dist/types/text.d.ts +2 -0
- package/dist/types/voce/index.d.ts +124 -0
- package/package.json +10 -2
package/dist/server.d.ts
CHANGED
|
@@ -1,71 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
[key: string]: JsonValue;
|
|
3
|
-
};
|
|
4
|
-
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'ended';
|
|
5
|
-
export type VoiceMode = 'none' | 'room' | 'team' | 'proximity';
|
|
6
|
-
export type LeaveReason = 'left' | 'timeout' | 'kicked';
|
|
7
|
-
export interface SharedGameStore {
|
|
8
|
-
get(key: string): Promise<JsonValue | null>;
|
|
9
|
-
set(key: string, value: JsonValue): Promise<void>;
|
|
10
|
-
delete(key: string): Promise<void>;
|
|
11
|
-
list(prefix?: string): Promise<string[]>;
|
|
12
|
-
increment(key: string, amount?: number): Promise<number>;
|
|
13
|
-
}
|
|
14
|
-
export interface Player {
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly guest: boolean;
|
|
18
|
-
readonly role: string | null;
|
|
19
|
-
readonly team: number | null;
|
|
20
|
-
readonly connected: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface Room<State extends JsonValue = JsonValue> {
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly seed: number;
|
|
25
|
-
readonly mode: string | null;
|
|
26
|
-
readonly status: RoomStatus;
|
|
27
|
-
readonly tick: number;
|
|
28
|
-
readonly tickRate: number;
|
|
29
|
-
readonly result: JsonValue | null;
|
|
30
|
-
state: State;
|
|
31
|
-
readonly players: readonly Player[];
|
|
32
|
-
readonly host: Player | null;
|
|
33
|
-
broadcast(message: JsonValue): void;
|
|
34
|
-
send(player: Player | string, message: JsonValue): void;
|
|
35
|
-
kick(player: Player | string): void;
|
|
36
|
-
setRole(player: Player | string, role: string): void;
|
|
37
|
-
setTeam(player: Player | string, team: number): void;
|
|
38
|
-
end(result: JsonValue): void;
|
|
39
|
-
save(key: string, value: JsonValue): Promise<void>;
|
|
40
|
-
load(key: string): Promise<JsonValue | null>;
|
|
41
|
-
readonly shared: SharedGameStore;
|
|
42
|
-
schedule(milliseconds: number, handler: string, payload: JsonValue): void;
|
|
43
|
-
readonly board: {
|
|
44
|
-
submit(player: Player | string, board: string, score: number, options?: {
|
|
45
|
-
daily?: boolean;
|
|
46
|
-
}): void;
|
|
47
|
-
};
|
|
48
|
-
readonly daily: {
|
|
49
|
-
readonly day: string;
|
|
50
|
-
readonly seed: number;
|
|
51
|
-
};
|
|
52
|
-
readonly time: {
|
|
53
|
-
now(): number;
|
|
54
|
-
};
|
|
55
|
-
readonly voice: {
|
|
56
|
-
readonly mode: VoiceMode;
|
|
57
|
-
setGain(listener: Player | string, speaker: Player | string, gain: number): void;
|
|
58
|
-
setProximity(a: Player | string, b: Player | string, gain: number): void;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export interface GameDefinition<State extends JsonValue = JsonValue> {
|
|
62
|
-
tickRate: number;
|
|
63
|
-
onCreate?(room: Room<State>): void | Promise<void>;
|
|
64
|
-
onStart?(room: Room<State>): void | Promise<void>;
|
|
65
|
-
onJoin?(room: Room<State>, player: Player): void | Promise<void>;
|
|
66
|
-
onLeave?(room: Room<State>, player: Player, reason: LeaveReason): void | Promise<void>;
|
|
67
|
-
onMessage?(room: Room<State>, player: Player, message: JsonValue): void | Promise<void>;
|
|
68
|
-
onTick?(room: Room<State>, deltaSeconds: number): void | Promise<void>;
|
|
69
|
-
onEnd?(room: Room<State>): void | Promise<void>;
|
|
70
|
-
}
|
|
71
|
-
export declare function defineGame<State extends JsonValue = JsonValue, const Definition extends GameDefinition<State> = GameDefinition<State>>(definition: Definition): Definition;
|
|
1
|
+
export * from './types/server/index.js';
|
package/dist/server.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BoardResult, BoardTop, JsonValue, Player, SaveInfo } from './index.js';
|
|
2
|
+
import type { GestoreBiglietto } from './handshake.js';
|
|
3
|
+
export interface RispostaMe {
|
|
4
|
+
player: Omit<Player, 'language' | 'uiLanguage'>;
|
|
5
|
+
game: {
|
|
6
|
+
slug: string;
|
|
7
|
+
};
|
|
8
|
+
day: string;
|
|
9
|
+
seed: number;
|
|
10
|
+
serverTime: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function creaClienteApi(appOrigin: string, fetcher: typeof fetch, biglietto: GestoreBiglietto): {
|
|
13
|
+
me: () => Promise<RispostaMe>;
|
|
14
|
+
saveSet: (key: string, value: JsonValue) => Promise<SaveInfo>;
|
|
15
|
+
saveGet(key: string): Promise<JsonValue | null>;
|
|
16
|
+
saveRemove(key: string): Promise<void>;
|
|
17
|
+
saveList(): Promise<SaveInfo[]>;
|
|
18
|
+
boardSubmit(board: string, score: number, daily: boolean): Promise<BoardResult>;
|
|
19
|
+
boardTop(board: string, opzioni: {
|
|
20
|
+
day?: string;
|
|
21
|
+
daily?: boolean;
|
|
22
|
+
limit?: number;
|
|
23
|
+
guests?: boolean;
|
|
24
|
+
}): Promise<BoardTop>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type DestinatarioBiglietto = 'portal' | 'live';
|
|
2
|
+
export interface Biglietto {
|
|
3
|
+
sub: string;
|
|
4
|
+
game: string;
|
|
5
|
+
name: string;
|
|
6
|
+
guest: boolean;
|
|
7
|
+
aud: DestinatarioBiglietto;
|
|
8
|
+
iat: number;
|
|
9
|
+
exp: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DatiBiglietto {
|
|
12
|
+
sub: string;
|
|
13
|
+
game: string;
|
|
14
|
+
name: string;
|
|
15
|
+
guest: boolean;
|
|
16
|
+
aud: DestinatarioBiglietto;
|
|
17
|
+
}
|
|
18
|
+
export declare function firmaBiglietto(dati: DatiBiglietto, secret: string, now?: Date): Promise<string>;
|
|
19
|
+
/** Restituisce null senza distinguere quale controllo ha rifiutato il gettone. */
|
|
20
|
+
export declare function verificaBiglietto(token: string, secret: string, atteso: {
|
|
21
|
+
aud: DestinatarioBiglietto;
|
|
22
|
+
game: string;
|
|
23
|
+
now?: Date;
|
|
24
|
+
}): Promise<Biglietto | null>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ManifestRequires } from './manifest.js';
|
|
2
|
+
interface ProbeWebGlContext {
|
|
3
|
+
getExtension(name: string): {
|
|
4
|
+
loseContext(): void;
|
|
5
|
+
} | null;
|
|
6
|
+
}
|
|
7
|
+
interface ProbeCanvas {
|
|
8
|
+
getContext(name: string, options?: {
|
|
9
|
+
failIfMajorPerformanceCaveat?: boolean;
|
|
10
|
+
}): ProbeWebGlContext | null;
|
|
11
|
+
}
|
|
12
|
+
interface ProbeGpuDevice {
|
|
13
|
+
destroy?: () => void;
|
|
14
|
+
}
|
|
15
|
+
interface ProbeGpuAdapter {
|
|
16
|
+
requestDevice(): Promise<ProbeGpuDevice>;
|
|
17
|
+
}
|
|
18
|
+
interface ProbeGpu {
|
|
19
|
+
requestAdapter(): Promise<ProbeGpuAdapter | null>;
|
|
20
|
+
}
|
|
21
|
+
interface ProbeWebAssembly {
|
|
22
|
+
validate(bytes: Uint8Array): boolean;
|
|
23
|
+
Memory: new (descriptor: {
|
|
24
|
+
initial: number;
|
|
25
|
+
maximum: number;
|
|
26
|
+
shared: boolean;
|
|
27
|
+
}) => unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface ProbeGlobals {
|
|
30
|
+
document: {
|
|
31
|
+
createElement(name: 'canvas'): ProbeCanvas;
|
|
32
|
+
};
|
|
33
|
+
navigator: {
|
|
34
|
+
gpu?: ProbeGpu;
|
|
35
|
+
deviceMemory?: number;
|
|
36
|
+
hardwareConcurrency?: number;
|
|
37
|
+
userAgentData?: {
|
|
38
|
+
mobile?: boolean;
|
|
39
|
+
};
|
|
40
|
+
userAgent?: string;
|
|
41
|
+
};
|
|
42
|
+
WebAssembly: ProbeWebAssembly;
|
|
43
|
+
crossOriginIsolated: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface DeviceReport {
|
|
46
|
+
webgl2: boolean;
|
|
47
|
+
webgpu: boolean;
|
|
48
|
+
wasm: boolean;
|
|
49
|
+
threads: boolean;
|
|
50
|
+
isolated: boolean;
|
|
51
|
+
gpu: 'hardware' | 'software' | 'none';
|
|
52
|
+
memoryMb: number | null;
|
|
53
|
+
cores: number | null;
|
|
54
|
+
mobile: boolean;
|
|
55
|
+
tier: 'low' | 'mid' | 'high';
|
|
56
|
+
}
|
|
57
|
+
export type CompatibilityLevel = 'ok' | 'slow' | 'unsupported';
|
|
58
|
+
export interface CompatibilityVerdict {
|
|
59
|
+
level: CompatibilityLevel;
|
|
60
|
+
missing: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare function deviceTier(report: Omit<DeviceReport, 'tier'>): DeviceReport['tier'];
|
|
63
|
+
export declare function checkCompatibility(requires: ManifestRequires, report: DeviceReport): CompatibilityVerdict;
|
|
64
|
+
export declare function requiresAnything(requires: ManifestRequires): boolean;
|
|
65
|
+
export declare function probeDevice(globals?: Partial<ProbeGlobals>, timeoutMs?: number): Promise<DeviceReport>;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firma HMAC e codifiche del formato JWT compatto, condivise dai gettoni del portale.
|
|
3
|
+
*
|
|
4
|
+
* Il biglietto di gioco e il gettone della crew hanno campi diversi ma lo stesso
|
|
5
|
+
* involucro: tenerlo in un posto solo evita che i due si allontanino nei dettagli
|
|
6
|
+
* (padding, confronto a tempo costante, intestazione).
|
|
7
|
+
*/
|
|
8
|
+
export declare const HEADER_JWT: {
|
|
9
|
+
readonly alg: 'HS256';
|
|
10
|
+
readonly typ: 'JWT';
|
|
11
|
+
};
|
|
12
|
+
/** Base64url senza padding, la codifica richiesta dal formato del biglietto. */
|
|
13
|
+
export declare function base64UrlEncode(bytes: Uint8Array): string;
|
|
14
|
+
export declare function base64UrlDecode(value: string): Uint8Array;
|
|
15
|
+
export declare function timingSafeEqualStrings(a: string, b: string): boolean;
|
|
16
|
+
export declare function firmaHmac(secret: string, value: string): Promise<string>;
|
|
17
|
+
export declare function codificaJwt(value: unknown): string;
|
|
18
|
+
export declare function oggetto(value: unknown): Record<string, unknown> | null;
|
|
19
|
+
/** Verifica la firma e decodifica; null se il gettone non ha la forma JWT attesa. */
|
|
20
|
+
export declare function apriJwt(token: string, secret: string): Promise<Record<string, unknown> | null>;
|
|
21
|
+
export declare function firmaJwt(payload: unknown, secret: string): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LocalizedText = string | Record<string, string>;
|
|
2
|
+
export type TextDictionary = Record<string, string>;
|
|
3
|
+
export declare function normalizeLanguage(value: unknown): string | null;
|
|
4
|
+
export declare function manifestLanguages(manifest: {
|
|
5
|
+
languages?: string[];
|
|
6
|
+
language?: string;
|
|
7
|
+
}): string[];
|
|
8
|
+
export declare function languageFallbacks(language: string, defaultLanguage?: string): string[];
|
|
9
|
+
export declare function resolveGameLanguage(preferences: readonly string[], languages?: readonly string[]): string;
|
|
10
|
+
export declare function resolveText(value: LocalizedText | undefined, language: string, defaultLanguage?: string, key?: string): string;
|
|
11
|
+
export declare function isTextDictionary(value: unknown): value is TextDictionary;
|
|
12
|
+
export declare function loadGameTexts(language: string, defaultLanguage: string, read: (language: string) => Promise<unknown>): Promise<TextDictionary>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './keys.js';
|
|
2
|
+
export * from './manifest.js';
|
|
3
|
+
export * from './device.js';
|
|
4
|
+
export * from './runtime.js';
|
|
5
|
+
export * from './server-js.js';
|
|
6
|
+
export * from './slug.js';
|
|
7
|
+
export * from './biglietto.js';
|
|
8
|
+
export * from './token-crew.js';
|
|
9
|
+
export * from './overlay.js';
|
|
10
|
+
export * from './overlay-boards.js';
|
|
11
|
+
export * from './i18n.js';
|
|
12
|
+
export * from './room-limits.js';
|
|
13
|
+
export * from './player.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Costruttori condivisi delle chiavi degli artefatti di gioco. */
|
|
2
|
+
/** Numero progressivo della versione dentro un gioco. */
|
|
3
|
+
export type VersionNumber = number & {
|
|
4
|
+
readonly __brand: 'VersionNumber';
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* ## Perche' gli artefatti stanno in un bucket PRIVATO e separato
|
|
8
|
+
*
|
|
9
|
+
* Il bucket `caisual`, servito pubblicamente da `assets.caisual.com`, deve
|
|
10
|
+
* continuare a ospitare gli asset storici citati con URL assoluti dai giochi.
|
|
11
|
+
* L'HTML giocabile invece sta nel bucket privato `caisual-games`, accessibile
|
|
12
|
+
* soltanto tramite i binding dei nostri Worker.
|
|
13
|
+
*
|
|
14
|
+
* Pubblicare anche l'HTML su `assets.caisual.com` permetterebbe di aprirlo
|
|
15
|
+
* senza passare da `play`. Basterebbe cambiare hostname per aggirare la
|
|
16
|
+
* trasformazione di runtime, la CSP, `frame-ancestors` e la Permissions-Policy.
|
|
17
|
+
* Il bucket separato rende obbligatorio il passaggio dal Worker che applica
|
|
18
|
+
* queste difese.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* ## Perche' lo slug sta DENTRO la chiave
|
|
22
|
+
*
|
|
23
|
+
* Il sottodominio da solo non isola gli oggetti. Se la chiave contenesse solo
|
|
24
|
+
* il numero di versione, questo URL potrebbe servire codice di un altro gioco
|
|
25
|
+
* dentro l'origine della vittima:
|
|
26
|
+
*
|
|
27
|
+
* https://vittima.caisual.app/rt/v1/<n-di-un-altro-gioco>/index.html
|
|
28
|
+
*
|
|
29
|
+
* Con `games/<slug>/<n>/...`, `play` prende lo slug dall'hostname e cerca solo
|
|
30
|
+
* sotto quel prefisso. I file dell'attaccante non esistono quindi nell'origine
|
|
31
|
+
* della vittima. Lo slug non cambia e la lapide ne impedisce il riuso, percio'
|
|
32
|
+
* la chiave resta stabile quanto l'id numerico.
|
|
33
|
+
*/
|
|
34
|
+
/** Prefisso di tutto cio' che appartiene a uno slug. */
|
|
35
|
+
export declare function gamePrefix(slug: string): string;
|
|
36
|
+
/** Prefisso immutabile di una versione progressiva. */
|
|
37
|
+
export declare function gameVersionPrefix(slug: string, n: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Chiave di un file relativo dentro una versione.
|
|
40
|
+
* `path` deve essere gia' passato da `normalizeAssetPath`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function versionFileKey(slug: string, n: number, path: string): string;
|
|
43
|
+
export declare function artifactKey(slug: string, n: number): string;
|
|
44
|
+
export declare function coverKey(slug: string, n: number): string;
|
|
45
|
+
/** Manifest immutabile che descrive la versione servita da play. */
|
|
46
|
+
export declare function manifestKey(slug: string, n: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* Normalizza il path richiesto dentro una versione e lo decodifica.
|
|
49
|
+
*
|
|
50
|
+
* La decodifica serve sia ai nomi con spazi o caratteri non ASCII, che il
|
|
51
|
+
* browser invia percent-encoded, sia alla sicurezza: la risalita va controllata
|
|
52
|
+
* DOPO la decodifica, altrimenti `%2e%2e` supererebbe il controllo.
|
|
53
|
+
*
|
|
54
|
+
* I segmenti vuoti vengono collassati invece di essere rifiutati. Il server
|
|
55
|
+
* storico faceva lo stesso e i giochi sono immutabili, quindi un riferimento
|
|
56
|
+
* come `src="assets//sprite.png"` deve continuare a funzionare. La cache usa la
|
|
57
|
+
* chiave normalizzata e non crea due copie per i doppi slash.
|
|
58
|
+
*/
|
|
59
|
+
export declare function normalizeAssetPath(rawPath: string): string | null;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { type LocalizedText } from './i18n.js';
|
|
2
|
+
export type Platform = 'desktop' | 'mobile' | 'both';
|
|
3
|
+
export type Orientation = 'landscape' | 'portrait';
|
|
4
|
+
export type Input = 'keyboard' | 'mouse' | 'touch' | 'gamepad';
|
|
5
|
+
export type Visibility = 'public' | 'unlisted';
|
|
6
|
+
export type Voice = 'none' | 'room' | 'team' | 'proximity';
|
|
7
|
+
export interface ManifestPlayers {
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ManifestRole {
|
|
12
|
+
label?: LocalizedText;
|
|
13
|
+
id: string;
|
|
14
|
+
min: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ManifestTeams {
|
|
18
|
+
min: number;
|
|
19
|
+
max: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ManifestMatchmaking {
|
|
22
|
+
defaults?: Record<string, string | number>;
|
|
23
|
+
key: string[];
|
|
24
|
+
timeoutMs: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ManifestRequires {
|
|
27
|
+
webgl2: boolean;
|
|
28
|
+
webgpu: boolean;
|
|
29
|
+
wasm: boolean;
|
|
30
|
+
threads: boolean;
|
|
31
|
+
memoryMb: number | null;
|
|
32
|
+
performance: 'light' | 'medium' | 'heavy';
|
|
33
|
+
}
|
|
34
|
+
export interface ManifestSpectators {
|
|
35
|
+
delayMs: number;
|
|
36
|
+
}
|
|
37
|
+
export type BoardPeriod = 'daily' | 'all-time';
|
|
38
|
+
export type ModeExecution = 'local' | 'room';
|
|
39
|
+
export interface ManifestOverlay {
|
|
40
|
+
version: 1;
|
|
41
|
+
accent?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ManifestBoard {
|
|
44
|
+
label?: LocalizedText;
|
|
45
|
+
periods?: BoardPeriod[];
|
|
46
|
+
source: 'client' | 'server';
|
|
47
|
+
}
|
|
48
|
+
export interface ManifestMode {
|
|
49
|
+
execution?: ModeExecution;
|
|
50
|
+
label?: LocalizedText;
|
|
51
|
+
instructions?: LocalizedText;
|
|
52
|
+
id: string;
|
|
53
|
+
players?: ManifestPlayers;
|
|
54
|
+
lobby?: boolean;
|
|
55
|
+
matchmaking?: ManifestMatchmaking;
|
|
56
|
+
}
|
|
57
|
+
export interface ModalitaRisolta {
|
|
58
|
+
players: ManifestPlayers;
|
|
59
|
+
lobby: boolean;
|
|
60
|
+
}
|
|
61
|
+
export type ManifestModalita = ModalitaRisolta & {
|
|
62
|
+
modes: ManifestMode[];
|
|
63
|
+
};
|
|
64
|
+
export declare function risolviModalita(manifest: ManifestModalita, mode: string | null): ModalitaRisolta;
|
|
65
|
+
export declare function risolviPresentazione(manifest: ManifestModalita & {
|
|
66
|
+
name?: string;
|
|
67
|
+
languages?: string[];
|
|
68
|
+
language?: string;
|
|
69
|
+
}, mode: string | null, language?: string): {
|
|
70
|
+
execution: ModeExecution | null;
|
|
71
|
+
label: string;
|
|
72
|
+
instructions: string | null;
|
|
73
|
+
};
|
|
74
|
+
export declare function richiedeServer(manifest: Pick<Manifest, 'modes'>): boolean;
|
|
75
|
+
export declare function modalitaLocale(manifest: Pick<Manifest, 'modes'>, mode: string | null): boolean;
|
|
76
|
+
export interface Manifest {
|
|
77
|
+
overlay?: ManifestOverlay | null;
|
|
78
|
+
manifest: 1;
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
cover: string | null;
|
|
83
|
+
screenshots: string[];
|
|
84
|
+
tags: string[];
|
|
85
|
+
languages: string[];
|
|
86
|
+
/** @deprecated Usa languages; il primo elemento e' il default. */
|
|
87
|
+
language: string;
|
|
88
|
+
platform: Platform;
|
|
89
|
+
orientation: Orientation;
|
|
90
|
+
input: Input[];
|
|
91
|
+
visibility: Visibility;
|
|
92
|
+
network: string[];
|
|
93
|
+
isolated: boolean;
|
|
94
|
+
requires: ManifestRequires;
|
|
95
|
+
players: ManifestPlayers;
|
|
96
|
+
lobby: boolean;
|
|
97
|
+
persistent: boolean;
|
|
98
|
+
spectators: ManifestSpectators | null;
|
|
99
|
+
boards: Record<string, ManifestBoard>;
|
|
100
|
+
roles: ManifestRole[];
|
|
101
|
+
teams: ManifestTeams | null;
|
|
102
|
+
voice: Voice;
|
|
103
|
+
modes: ManifestMode[];
|
|
104
|
+
}
|
|
105
|
+
export type EsitoManifest = {
|
|
106
|
+
ok: true;
|
|
107
|
+
manifest: Manifest;
|
|
108
|
+
} | {
|
|
109
|
+
ok: false;
|
|
110
|
+
errori: string[];
|
|
111
|
+
};
|
|
112
|
+
export declare const TETTO_GIOCATORI = 24;
|
|
113
|
+
export declare const MASSIMO_SPETTATORI = 100;
|
|
114
|
+
export declare const RITARDO_SPETTATORI_MS = 3000;
|
|
115
|
+
export declare const MASSIMO_CLASSIFICHE = 32;
|
|
116
|
+
export declare function sorgenteClassifica(manifest: {
|
|
117
|
+
boards?: Record<string, ManifestBoard>;
|
|
118
|
+
}, board: string): 'client' | 'server';
|
|
119
|
+
/**
|
|
120
|
+
* Valida tutto il documento in un solo passaggio e restituisce tutti gli
|
|
121
|
+
* errori. Un agente puo' cosi' correggere il file senza tentativi ripetuti.
|
|
122
|
+
*/
|
|
123
|
+
export declare function validaManifest(valore: unknown): EsitoManifest;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Manifest } from './manifest.js';
|
|
2
|
+
export declare function overlayBoardError(manifest: Manifest, board: string, params: URLSearchParams): string | null;
|
|
3
|
+
export declare function overlayReadOrigin(origin: string | null, site: string | null, expected: string): boolean;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { type Manifest } from './manifest.js';
|
|
2
|
+
export declare const OVERLAY_VERSION: 1;
|
|
3
|
+
export declare const OVERLAY_PANELS: readonly ['home', 'room', 'invite', 'friends', 'voice', 'boards'];
|
|
4
|
+
export type OverlayPanel = typeof OVERLAY_PANELS[number];
|
|
5
|
+
export type ConnectionState = 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'ended' | 'closed' | 'replaced';
|
|
6
|
+
export interface ReservedRect {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SafeArea {
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
left: number;
|
|
17
|
+
}
|
|
18
|
+
export interface OverlayView {
|
|
19
|
+
inputBlocked: boolean;
|
|
20
|
+
reservedRects: ReservedRect[];
|
|
21
|
+
safeArea?: SafeArea;
|
|
22
|
+
shortcutEnabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface OverlayConfiguration {
|
|
25
|
+
manifest: Manifest;
|
|
26
|
+
coverUrl: string | null;
|
|
27
|
+
invite: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface OverlayCapabilities {
|
|
30
|
+
local: boolean;
|
|
31
|
+
rooms: boolean;
|
|
32
|
+
overlay: boolean;
|
|
33
|
+
requestRole: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface OverlayPlayer {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
guest: boolean;
|
|
39
|
+
role: string | null;
|
|
40
|
+
team: number | null;
|
|
41
|
+
ready: boolean;
|
|
42
|
+
connected: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface QueuedScore {
|
|
45
|
+
board: string;
|
|
46
|
+
player: string;
|
|
47
|
+
score: number;
|
|
48
|
+
day: string | null;
|
|
49
|
+
submittedAt: number;
|
|
50
|
+
}
|
|
51
|
+
export interface SessionResume {
|
|
52
|
+
version: 1;
|
|
53
|
+
code: string;
|
|
54
|
+
mode: string | null;
|
|
55
|
+
updatedAt: number;
|
|
56
|
+
}
|
|
57
|
+
export interface OverlayRoom {
|
|
58
|
+
code: string;
|
|
59
|
+
mode: string | null;
|
|
60
|
+
status: 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
|
|
61
|
+
host: string | null;
|
|
62
|
+
you: string | null;
|
|
63
|
+
players: OverlayPlayer[];
|
|
64
|
+
countdownAt: number | null;
|
|
65
|
+
connection: ConnectionState;
|
|
66
|
+
closedCode: number | null;
|
|
67
|
+
limits: {
|
|
68
|
+
min: number;
|
|
69
|
+
max: number;
|
|
70
|
+
};
|
|
71
|
+
lobby: boolean;
|
|
72
|
+
persistent: boolean;
|
|
73
|
+
delayMs: number | null;
|
|
74
|
+
requestRole: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface OverlayVoicePeer {
|
|
77
|
+
id: string;
|
|
78
|
+
mic: boolean;
|
|
79
|
+
muted: boolean;
|
|
80
|
+
speaking: boolean;
|
|
81
|
+
volume: number;
|
|
82
|
+
}
|
|
83
|
+
export interface OverlayVoice {
|
|
84
|
+
mode: 'room' | 'team' | 'proximity';
|
|
85
|
+
state: 'off' | 'joining' | 'on' | 'reconnecting';
|
|
86
|
+
mic: boolean;
|
|
87
|
+
muted: boolean;
|
|
88
|
+
speaking: boolean;
|
|
89
|
+
peers: OverlayVoicePeer[];
|
|
90
|
+
}
|
|
91
|
+
export interface OverlaySessionState {
|
|
92
|
+
kind: 'boot' | 'home' | 'attaching' | 'matching' | 'local' | 'room' | 'watch';
|
|
93
|
+
id: string | null;
|
|
94
|
+
mode: string | null;
|
|
95
|
+
localStatus: 'playing' | 'ended' | null;
|
|
96
|
+
ready: boolean;
|
|
97
|
+
capabilities: OverlayCapabilities;
|
|
98
|
+
room: OverlayRoom | null;
|
|
99
|
+
waiting: {
|
|
100
|
+
players: number;
|
|
101
|
+
min: number;
|
|
102
|
+
max: number;
|
|
103
|
+
} | null;
|
|
104
|
+
resume: SessionResume | null;
|
|
105
|
+
resumeError: boolean;
|
|
106
|
+
voice?: OverlayVoice | null;
|
|
107
|
+
}
|
|
108
|
+
export interface OverlayOperations {
|
|
109
|
+
'local.start': {
|
|
110
|
+
mode: string;
|
|
111
|
+
};
|
|
112
|
+
'room.create': {
|
|
113
|
+
mode: string | null;
|
|
114
|
+
};
|
|
115
|
+
'room.join': {
|
|
116
|
+
code?: string;
|
|
117
|
+
};
|
|
118
|
+
'room.watch': {
|
|
119
|
+
code: string;
|
|
120
|
+
};
|
|
121
|
+
'room.match': {
|
|
122
|
+
mode: string;
|
|
123
|
+
key?: Record<string, string | number>;
|
|
124
|
+
};
|
|
125
|
+
'room.ready': {
|
|
126
|
+
ready: boolean;
|
|
127
|
+
};
|
|
128
|
+
'room.role': {
|
|
129
|
+
role: string;
|
|
130
|
+
};
|
|
131
|
+
'room.requestRole': {
|
|
132
|
+
role: string;
|
|
133
|
+
};
|
|
134
|
+
'room.team': {
|
|
135
|
+
team: number;
|
|
136
|
+
};
|
|
137
|
+
'room.start': Record<string, never>;
|
|
138
|
+
'room.restart': Record<string, never>;
|
|
139
|
+
'session.cancel': Record<string, never>;
|
|
140
|
+
'session.leave': Record<string, never>;
|
|
141
|
+
'session.disconnect': Record<string, never>;
|
|
142
|
+
'session.resume': Record<string, never>;
|
|
143
|
+
'overlay.view': OverlayView;
|
|
144
|
+
'voice.join': Record<string, never>;
|
|
145
|
+
'voice.mute': {
|
|
146
|
+
muted: boolean;
|
|
147
|
+
};
|
|
148
|
+
'voice.leave': Record<string, never>;
|
|
149
|
+
'voice.setVolume': {
|
|
150
|
+
playerId: string;
|
|
151
|
+
volume: number;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export type OverlayRequest = {
|
|
155
|
+
[K in keyof OverlayOperations]: {
|
|
156
|
+
type: 'caisual:overlay';
|
|
157
|
+
v: 1;
|
|
158
|
+
epoch: string;
|
|
159
|
+
requestId: string;
|
|
160
|
+
sessionId?: string | null;
|
|
161
|
+
op: K;
|
|
162
|
+
args: OverlayOperations[K];
|
|
163
|
+
};
|
|
164
|
+
}[keyof OverlayOperations];
|
|
165
|
+
export type OverlayResponse = {
|
|
166
|
+
type: 'caisual:overlay-response';
|
|
167
|
+
v: 1;
|
|
168
|
+
epoch: string;
|
|
169
|
+
requestId: string;
|
|
170
|
+
} & ({
|
|
171
|
+
ok: true;
|
|
172
|
+
} | {
|
|
173
|
+
ok: false;
|
|
174
|
+
error: {
|
|
175
|
+
code: string;
|
|
176
|
+
message: string;
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
export type OverlayEvent = {
|
|
180
|
+
type: 'caisual:overlay-state';
|
|
181
|
+
v: 1;
|
|
182
|
+
epoch: string;
|
|
183
|
+
seq: number;
|
|
184
|
+
serverTime: number;
|
|
185
|
+
state: OverlaySessionState;
|
|
186
|
+
} | {
|
|
187
|
+
type: 'caisual:overlay-shortcut';
|
|
188
|
+
v: 1;
|
|
189
|
+
epoch: string;
|
|
190
|
+
} | {
|
|
191
|
+
type: 'caisual:overlay-open';
|
|
192
|
+
v: 1;
|
|
193
|
+
epoch: string;
|
|
194
|
+
panel: OverlayPanel;
|
|
195
|
+
} | {
|
|
196
|
+
type: 'caisual:overlay-error';
|
|
197
|
+
v: 1;
|
|
198
|
+
epoch: string;
|
|
199
|
+
sessionId: string;
|
|
200
|
+
error: {
|
|
201
|
+
code: string;
|
|
202
|
+
message: string;
|
|
203
|
+
};
|
|
204
|
+
} | {
|
|
205
|
+
type: 'caisual:overlay-score';
|
|
206
|
+
v: 1;
|
|
207
|
+
epoch: string;
|
|
208
|
+
score: QueuedScore;
|
|
209
|
+
};
|
|
210
|
+
export interface OverlayHello {
|
|
211
|
+
v: 1;
|
|
212
|
+
epoch: string;
|
|
213
|
+
configuration: OverlayConfiguration;
|
|
214
|
+
}
|
|
215
|
+
export declare function overlayConfiguration(manifest: Manifest, coverUrl?: string | null, invite?: string | null): OverlayConfiguration;
|
|
216
|
+
export declare function record(value: unknown): Record<string, unknown> | null;
|
|
217
|
+
export declare function validOverlayHello(value: unknown): value is OverlayHello;
|
|
218
|
+
export declare function normalizeOverlayHello(value: unknown): OverlayHello | null;
|
|
219
|
+
export declare function validOverlayView(value: unknown): value is OverlayView;
|
|
220
|
+
export declare function validOverlayRequest(value: unknown): value is OverlayRequest;
|
|
221
|
+
export declare function validBoardDay(value: unknown): value is string;
|
|
222
|
+
export declare function validOverlaySessionState(value: unknown): value is OverlaySessionState;
|
|
223
|
+
export declare function validOverlayVoice(value: unknown): value is OverlayVoice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function guestName(id: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MESSAGGI_GIOCO_AL_SECONDO = 20;
|
|
2
|
+
export declare const MESSAGGI_SERVIZIO_AL_SECONDO = 20;
|
|
3
|
+
export type EsitoLimiteMessaggi = {
|
|
4
|
+
accetta: boolean;
|
|
5
|
+
avvisa: boolean;
|
|
6
|
+
chiudi: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class LimiteMessaggiStanza {
|
|
9
|
+
private readonly connessioni;
|
|
10
|
+
delete(connessione: string): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
controlla(connessione: string, gioco: boolean, ora: number): EsitoLimiteMessaggi;
|
|
13
|
+
}
|