@caisual/kit 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -9
- package/dist/host.d.ts +1 -0
- package/dist/host.js +169 -0
- package/dist/kit.js +2 -4
- package/dist/kit.js.map +4 -4
- package/dist/node.js +182 -457
- package/dist/runtime.js +236 -299
- package/dist/types/api.d.ts +2 -9
- package/dist/types/contracts/connessione.d.ts +1 -0
- package/dist/types/contracts/giornata.d.ts +1 -0
- package/dist/types/contracts/index.d.ts +3 -3
- package/dist/types/contracts/manifest.d.ts +6 -40
- package/dist/types/contracts/network-budget.d.ts +53 -0
- package/dist/types/contracts/versioni.d.ts +0 -1
- package/dist/types/crew/index.d.ts +4 -0
- package/dist/types/handshake.d.ts +0 -4
- package/dist/types/{overlay/host-bridge.d.ts → host/index.d.ts} +60 -38
- package/dist/types/index.d.ts +64 -90
- package/dist/types/node/index.d.ts +6 -27
- package/dist/types/protocollo.d.ts +1 -20
- package/dist/types/runtime/index.d.ts +8 -15
- package/dist/types/runtime/network-probe.d.ts +4 -0
- package/dist/types/server/index.d.ts +0 -20
- package/dist/types/stanza/nucleo.d.ts +12 -17
- package/dist/types/stanza/tipi.d.ts +7 -23
- package/dist/types/voce/index.d.ts +0 -1
- package/package.json +16 -19
- package/dist/overlay.d.ts +0 -1
- package/dist/overlay.js +0 -2326
- package/dist/overlay.js.map +0 -7
- package/dist/types/contracts/overlay-boards.d.ts +0 -3
- package/dist/types/contracts/overlay.d.ts +0 -240
- package/dist/types/contracts/replay.d.ts +0 -83
- package/dist/types/overlay/boards.d.ts +0 -48
- package/dist/types/overlay/bridge.d.ts +0 -3
- package/dist/types/overlay/i18n.d.ts +0 -146
- package/dist/types/overlay/index.d.ts +0 -10
- package/dist/types/overlay/locale.d.ts +0 -4
- package/dist/types/overlay/shortcut.d.ts +0 -4
- package/dist/types/overlay/styles.d.ts +0 -1
- package/dist/types/overlay/ui-model.d.ts +0 -53
- package/dist/types/overlay/ui.d.ts +0 -83
- package/dist/types/overlay/voice-panel.d.ts +0 -13
- package/dist/types/replay/index.d.ts +0 -65
- package/dist/types/session/index.d.ts +0 -50
- package/dist/types/session/resume.d.ts +0 -13
package/dist/types/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonValue, Player, SaveInfo } from './index.js';
|
|
2
2
|
import type { GestoreBiglietto } from './handshake.js';
|
|
3
3
|
export interface RispostaMe {
|
|
4
|
-
player: Omit<Player, 'language'
|
|
4
|
+
player: Omit<Player, 'language'>;
|
|
5
5
|
game: {
|
|
6
6
|
slug: string;
|
|
7
7
|
};
|
|
@@ -16,11 +16,4 @@ export declare function creaClienteApi(appOrigin: string, fetcher: typeof fetch,
|
|
|
16
16
|
saveGet(key: string): Promise<JsonValue | null>;
|
|
17
17
|
saveRemove(key: string): Promise<void>;
|
|
18
18
|
saveList(): Promise<SaveInfo[]>;
|
|
19
|
-
boardSubmit(board: string, score: number, daily: boolean): Promise<BoardResult>;
|
|
20
|
-
boardTop(board: string, opzioni: {
|
|
21
|
-
day?: string;
|
|
22
|
-
daily?: boolean;
|
|
23
|
-
limit?: number;
|
|
24
|
-
guests?: boolean;
|
|
25
|
-
}): Promise<BoardTop>;
|
|
26
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ConnectionState = 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'ended' | 'closed' | 'replaced';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validDay(value: unknown): value is string;
|
|
@@ -7,13 +7,13 @@ export * from './server-wasm.js';
|
|
|
7
7
|
export * from './slug.js';
|
|
8
8
|
export * from './biglietto.js';
|
|
9
9
|
export * from './token-crew.js';
|
|
10
|
-
export * from './overlay.js';
|
|
11
|
-
export * from './overlay-boards.js';
|
|
12
10
|
export * from './i18n.js';
|
|
11
|
+
export * from './giornata.js';
|
|
12
|
+
export * from './connessione.js';
|
|
13
13
|
export * from './room-limits.js';
|
|
14
|
+
export * from './network-budget.js';
|
|
14
15
|
export * from './player.js';
|
|
15
16
|
export * from './match-result.js';
|
|
16
17
|
export * from './immagine.js';
|
|
17
18
|
export * from './versioni.js';
|
|
18
|
-
export * from './replay.js';
|
|
19
19
|
export * from './pubblicazione-limiti.js';
|
|
@@ -9,7 +9,6 @@ export interface ManifestPlayers {
|
|
|
9
9
|
max: number;
|
|
10
10
|
}
|
|
11
11
|
export interface ManifestRole {
|
|
12
|
-
label?: LocalizedText;
|
|
13
12
|
id: string;
|
|
14
13
|
min: number;
|
|
15
14
|
max?: number;
|
|
@@ -31,25 +30,7 @@ export interface ManifestRequires {
|
|
|
31
30
|
memoryMb: number | null;
|
|
32
31
|
performance: 'light' | 'medium' | 'heavy';
|
|
33
32
|
}
|
|
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
|
-
day?: 'submit' | 'start';
|
|
45
|
-
label?: LocalizedText;
|
|
46
|
-
periods?: BoardPeriod[];
|
|
47
|
-
source: 'client' | 'server';
|
|
48
|
-
}
|
|
49
33
|
export interface ManifestMode {
|
|
50
|
-
execution?: ModeExecution;
|
|
51
|
-
label?: LocalizedText;
|
|
52
|
-
instructions?: LocalizedText;
|
|
53
34
|
id: string;
|
|
54
35
|
players?: ManifestPlayers;
|
|
55
36
|
lobby?: boolean;
|
|
@@ -63,19 +44,12 @@ export type ManifestModalita = ModalitaRisolta & {
|
|
|
63
44
|
modes: ManifestMode[];
|
|
64
45
|
};
|
|
65
46
|
export declare function risolviModalita(manifest: ManifestModalita, mode: string | null): ModalitaRisolta;
|
|
66
|
-
export declare function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
execution: ModeExecution | null;
|
|
72
|
-
label: string;
|
|
73
|
-
instructions: string | null;
|
|
74
|
-
};
|
|
75
|
-
export declare function richiedeServer(manifest: Pick<Manifest, 'modes'>): boolean;
|
|
76
|
-
export declare function modalitaLocale(manifest: Pick<Manifest, 'modes'>, mode: string | null): boolean;
|
|
47
|
+
export declare function richiedeServer(manifest: ManifestModalita): boolean;
|
|
48
|
+
export declare function modalitaLocale(manifest: ManifestModalita, mode: string | null): boolean;
|
|
49
|
+
export declare const SINGLE_PLAYER_RULE = "Single player runs in the browser and never touches the server; a room exists only for two or more players.";
|
|
50
|
+
export declare const MODE_LOCAL_MESSAGE = "Single-player modes run in the browser and have no room.";
|
|
51
|
+
export declare const AVVISO_SERVER_INUTILE = "server.js is unnecessary: all modes run in the browser.";
|
|
77
52
|
export interface Manifest {
|
|
78
|
-
overlay?: ManifestOverlay | null;
|
|
79
53
|
manifest: 1;
|
|
80
54
|
id: string;
|
|
81
55
|
name: string;
|
|
@@ -97,9 +71,6 @@ export interface Manifest {
|
|
|
97
71
|
players: ManifestPlayers;
|
|
98
72
|
lobby: boolean;
|
|
99
73
|
persistent: boolean;
|
|
100
|
-
replays: boolean;
|
|
101
|
-
spectators: ManifestSpectators | null;
|
|
102
|
-
boards: Record<string, ManifestBoard>;
|
|
103
74
|
roles: ManifestRole[];
|
|
104
75
|
teams: ManifestTeams | null;
|
|
105
76
|
voice: Voice;
|
|
@@ -115,14 +86,9 @@ export type EsitoManifest = {
|
|
|
115
86
|
errori: string[];
|
|
116
87
|
};
|
|
117
88
|
export declare const TETTO_GIOCATORI = 24;
|
|
118
|
-
export declare const MASSIMO_SPETTATORI = 100;
|
|
119
|
-
export declare const RITARDO_SPETTATORI_MS = 3000;
|
|
120
|
-
export declare const MASSIMO_CLASSIFICHE = 32;
|
|
121
|
-
export declare function sorgenteClassifica(manifest: {
|
|
122
|
-
boards?: Record<string, ManifestBoard>;
|
|
123
|
-
}, board: string): 'client' | 'server';
|
|
124
89
|
/**
|
|
125
90
|
* Valida tutto il documento in un solo passaggio e restituisce tutti gli
|
|
126
91
|
* errori. Un agente puo' cosi' correggere il file senza tentativi ripetuti.
|
|
127
92
|
*/
|
|
128
93
|
export declare function validaManifest(valore: unknown): EsitoManifest;
|
|
94
|
+
export declare function validaManifestPubblicazione(valore: unknown): EsitoManifest;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const NETWORK_BUDGET: Readonly<{
|
|
2
|
+
recipientBytesPerSecond: 100000;
|
|
3
|
+
roomBytesPerSecond: 2000000;
|
|
4
|
+
warningRatio: 0.8;
|
|
5
|
+
windowMs: 5000;
|
|
6
|
+
blockingWindows: 3;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const NETWORK_GUIDANCE: string;
|
|
9
|
+
export interface NetworkMeasurement {
|
|
10
|
+
recipientBytesPerSecond: number;
|
|
11
|
+
roomBytesPerSecond: number;
|
|
12
|
+
}
|
|
13
|
+
export interface NetworkReport {
|
|
14
|
+
current: NetworkMeasurement;
|
|
15
|
+
peak: NetworkMeasurement;
|
|
16
|
+
consecutiveViolations: number;
|
|
17
|
+
blocked: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function networkLevel(measurement: NetworkMeasurement): 'ok' | 'warning' | 'exceeded';
|
|
20
|
+
export declare function networkMessage(measurement: NetworkMeasurement): string;
|
|
21
|
+
export declare class NetworkMeter {
|
|
22
|
+
private events;
|
|
23
|
+
private head;
|
|
24
|
+
private recipients;
|
|
25
|
+
private total;
|
|
26
|
+
private peak;
|
|
27
|
+
private checkAt;
|
|
28
|
+
private violations;
|
|
29
|
+
private blocked;
|
|
30
|
+
private encoder;
|
|
31
|
+
record(recipient: string, text: string, now?: number): void;
|
|
32
|
+
sample(now?: number): NetworkReport;
|
|
33
|
+
private rate;
|
|
34
|
+
private current;
|
|
35
|
+
private advance;
|
|
36
|
+
private expire;
|
|
37
|
+
}
|
|
38
|
+
export interface NetworkProbeResult {
|
|
39
|
+
modes: Array<NetworkMeasurement & {
|
|
40
|
+
mode: string | null;
|
|
41
|
+
players: number;
|
|
42
|
+
playing: boolean;
|
|
43
|
+
simulatedSeconds: number;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export interface NetworkProbeService {
|
|
47
|
+
measure(input: {
|
|
48
|
+
slug: string;
|
|
49
|
+
n: number;
|
|
50
|
+
server: string;
|
|
51
|
+
manifest: import('./manifest.ts').Manifest;
|
|
52
|
+
}): Promise<NetworkProbeResult>;
|
|
53
|
+
}
|
|
@@ -9,7 +9,6 @@ export interface ErroreVersione {
|
|
|
9
9
|
export interface RicaricaGioco {
|
|
10
10
|
code?: string;
|
|
11
11
|
roomId?: string;
|
|
12
|
-
watch?: boolean;
|
|
13
12
|
}
|
|
14
13
|
export declare function numeroVersione(value: unknown): value is number;
|
|
15
14
|
export declare function analizzaRoomId(roomId: string): {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Crew, Rooms } from '../index.js';
|
|
2
|
+
/** Senza sito (copia locale, sviluppo) gli amici non esistono: liste vuote e niente errori a sorpresa. */
|
|
3
|
+
export declare function creaCrewOffline(): Crew;
|
|
4
|
+
export declare function creaCrew(porta: MessagePort, slug: string | null, room: Rooms): Crew;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type OverlayHello } from './contracts/index.js';
|
|
2
1
|
import type { VersioneGioco } from './contracts/index.js';
|
|
3
2
|
export interface GenitoreHandshake {
|
|
4
3
|
postMessage(message: unknown, targetOrigin: string): void;
|
|
@@ -11,12 +10,9 @@ export interface FinestraHandshakeKit extends GenitoreHandshake {
|
|
|
11
10
|
clearTimeout(id: number): void;
|
|
12
11
|
}
|
|
13
12
|
export interface EsitoHandshake extends VersioneGioco {
|
|
14
|
-
replay?: string;
|
|
15
13
|
language?: string;
|
|
16
|
-
uiLanguage?: string;
|
|
17
14
|
languagePreferences?: string[];
|
|
18
15
|
gameLanguages?: string[];
|
|
19
|
-
overlay?: OverlayHello;
|
|
20
16
|
ticket: string;
|
|
21
17
|
live: string | null;
|
|
22
18
|
invite: string | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type OverlayConfiguration, type OverlayOperations, type OverlaySessionState, type QueuedScore, type OverlayPanel } from '../contracts/index.js';
|
|
2
1
|
export interface FinestraHandshake {
|
|
3
2
|
addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
4
3
|
removeEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
@@ -15,27 +14,78 @@ export interface FrameHandshake {
|
|
|
15
14
|
addEventListener?(type: 'load', listener: () => void): void;
|
|
16
15
|
removeEventListener?(type: 'load', listener: () => void): void;
|
|
17
16
|
}
|
|
17
|
+
/** Il ritorno nella stanza dopo un cambio di versione del gioco. */
|
|
18
|
+
export interface RitornoStanza {
|
|
19
|
+
code?: string;
|
|
20
|
+
roomId?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AmicoOspite {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
online: boolean;
|
|
26
|
+
game: {
|
|
27
|
+
slug: string;
|
|
28
|
+
name: string;
|
|
29
|
+
iconUrl: string;
|
|
30
|
+
} | null;
|
|
31
|
+
room: {
|
|
32
|
+
code: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}
|
|
35
|
+
export interface GruppoOspite {
|
|
36
|
+
id: string;
|
|
37
|
+
leader: string;
|
|
38
|
+
members: AmicoOspite[];
|
|
39
|
+
}
|
|
40
|
+
export interface StatoCrewOspite {
|
|
41
|
+
connected: boolean;
|
|
42
|
+
you: {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
} | null;
|
|
46
|
+
friends: AmicoOspite[];
|
|
47
|
+
party: GruppoOspite | null;
|
|
48
|
+
invites: Array<{
|
|
49
|
+
party: string;
|
|
50
|
+
from: {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
at: number;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
/** Amici e gruppo vivono nel sito: il ponte li inoltra al gioco senza copiarli. */
|
|
58
|
+
export interface CrewOspite {
|
|
59
|
+
getSnapshot(): StatoCrewOspite;
|
|
60
|
+
subscribe(listener: () => void): () => void;
|
|
61
|
+
party: {
|
|
62
|
+
create(): void;
|
|
63
|
+
invite(player: string): void;
|
|
64
|
+
accept(party: string): void;
|
|
65
|
+
decline(party: string): void;
|
|
66
|
+
leave(): void;
|
|
67
|
+
kick(player: string): void;
|
|
68
|
+
};
|
|
69
|
+
follow(slug: string, code: string): void;
|
|
70
|
+
}
|
|
18
71
|
export interface HostBridgeInput {
|
|
19
72
|
finestra: FinestraHandshake;
|
|
20
73
|
frame: FrameHandshake;
|
|
21
74
|
origineGioco: string;
|
|
22
75
|
origineLive: string;
|
|
23
76
|
n: number;
|
|
24
|
-
|
|
25
|
-
replay?: string | null;
|
|
26
|
-
reload?(target?: import('../contracts/index.js').RicaricaGioco): void;
|
|
77
|
+
reload?(target?: RitornoStanza): void;
|
|
27
78
|
language?: string;
|
|
28
79
|
languagePreferences?: readonly string[];
|
|
80
|
+
gameLanguages?: readonly string[];
|
|
29
81
|
invite: string | null;
|
|
30
82
|
ticket: string;
|
|
31
|
-
configuration?: OverlayConfiguration;
|
|
32
83
|
rinnova(aud: 'portal' | 'live'): Promise<string>;
|
|
33
84
|
onRoom(room: {
|
|
34
85
|
code: string;
|
|
35
86
|
} | null): void;
|
|
87
|
+
crew?: CrewOspite;
|
|
36
88
|
creaCanale?(): MessageChannel;
|
|
37
|
-
epoch?(): string;
|
|
38
|
-
requestTimeoutMs?: number;
|
|
39
89
|
}
|
|
40
90
|
export declare function eMessaggioReady(value: unknown): boolean;
|
|
41
91
|
export declare function eRichiestaBiglietto(value: unknown): boolean;
|
|
@@ -43,39 +93,11 @@ export declare function stanzaDaMessaggio(value: unknown): {
|
|
|
43
93
|
code: string;
|
|
44
94
|
} | null | undefined;
|
|
45
95
|
export declare function creaPonteOspite(input: HostBridgeInput): {
|
|
46
|
-
readonly replay: string | null;
|
|
47
|
-
readonly watch: boolean;
|
|
48
96
|
reload(): void;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
subscribe(listener: (value: OverlaySessionState | null) => void): () => void;
|
|
53
|
-
onShortcut(listener: () => void): () => void;
|
|
54
|
-
onOpen(listener: (value: OverlayPanel) => void): () => void;
|
|
55
|
-
onError(listener: (value: {
|
|
56
|
-
sessionId: string | null;
|
|
57
|
-
error: {
|
|
58
|
-
code: string;
|
|
59
|
-
message: string;
|
|
60
|
-
};
|
|
61
|
-
}) => void): () => void;
|
|
62
|
-
onScore(listener: (value: QueuedScore) => void): () => void;
|
|
63
|
-
request<K extends keyof OverlayOperations>(op: K, args: OverlayOperations[K]): Promise<void>;
|
|
97
|
+
/** Il gioco e' collegato: serve al sito per sapere se il ponte ha agganciato il documento. */
|
|
98
|
+
readonly collegato: boolean;
|
|
99
|
+
invia(message: unknown): void;
|
|
64
100
|
dispose(): void;
|
|
65
101
|
};
|
|
66
102
|
export type HostBridge = ReturnType<typeof creaPonteOspite>;
|
|
67
103
|
export declare function avviaHandshake(input: HostBridgeInput): () => void;
|
|
68
|
-
export declare function gameViewport(frame: HTMLIFrameElement): {
|
|
69
|
-
left: number;
|
|
70
|
-
top: number;
|
|
71
|
-
right: number;
|
|
72
|
-
bottom: number;
|
|
73
|
-
scaleX: number;
|
|
74
|
-
scaleY: number;
|
|
75
|
-
};
|
|
76
|
-
export declare function measureSafeArea(frame: HTMLIFrameElement, probe: HTMLElement): {
|
|
77
|
-
top: number;
|
|
78
|
-
right: number;
|
|
79
|
-
bottom: number;
|
|
80
|
-
left: number;
|
|
81
|
-
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,11 +2,9 @@ export type { DailyContext } from './daily.js';
|
|
|
2
2
|
export type { MatchResult } from './contracts/index.js';
|
|
3
3
|
import type { Text } from './text.js';
|
|
4
4
|
export type { Text } from './text.js';
|
|
5
|
-
import type { ConnectionState
|
|
6
|
-
import type { Session, Overlay } from './session/index.js';
|
|
5
|
+
import type { ConnectionState } from './contracts/index.js';
|
|
7
6
|
import type { RoomConfiguration } from './protocollo.js';
|
|
8
|
-
export type {
|
|
9
|
-
export type { ConnectionState, QueuedScore, OverlayView, OverlayPanel } from './contracts/index.js';
|
|
7
|
+
export type { ConnectionState } from './contracts/index.js';
|
|
10
8
|
import type { DeviceReport } from './contracts/index.js';
|
|
11
9
|
export type { DeviceReport } from './contracts/index.js';
|
|
12
10
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
@@ -14,7 +12,6 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
|
14
12
|
};
|
|
15
13
|
export interface Player {
|
|
16
14
|
language: string;
|
|
17
|
-
uiLanguage: string;
|
|
18
15
|
id: string;
|
|
19
16
|
name: string;
|
|
20
17
|
guest: boolean;
|
|
@@ -24,35 +21,6 @@ export interface SaveInfo {
|
|
|
24
21
|
bytes: number;
|
|
25
22
|
updatedAt: number;
|
|
26
23
|
}
|
|
27
|
-
export interface BoardEntry {
|
|
28
|
-
rank: number;
|
|
29
|
-
name: string;
|
|
30
|
-
score: number;
|
|
31
|
-
guest: boolean;
|
|
32
|
-
me: boolean;
|
|
33
|
-
verified: boolean;
|
|
34
|
-
}
|
|
35
|
-
export interface BoardTop {
|
|
36
|
-
day: string | null;
|
|
37
|
-
entries: BoardEntry[];
|
|
38
|
-
me: {
|
|
39
|
-
rank: number;
|
|
40
|
-
score: number;
|
|
41
|
-
verified: boolean;
|
|
42
|
-
} | null;
|
|
43
|
-
}
|
|
44
|
-
export type BoardResult = {
|
|
45
|
-
accepted: true;
|
|
46
|
-
best: number;
|
|
47
|
-
rank: number;
|
|
48
|
-
day: string | null;
|
|
49
|
-
verified: boolean;
|
|
50
|
-
};
|
|
51
|
-
export type BoardOffline = {
|
|
52
|
-
accepted: false;
|
|
53
|
-
reason: 'offline';
|
|
54
|
-
verified: false;
|
|
55
|
-
};
|
|
56
24
|
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
|
|
57
25
|
export interface RoomPlayer {
|
|
58
26
|
id: string;
|
|
@@ -94,12 +62,9 @@ export interface RoomInvite {
|
|
|
94
62
|
url: string;
|
|
95
63
|
}
|
|
96
64
|
export interface RoomMetadata {
|
|
97
|
-
replayId?: string | null;
|
|
98
65
|
rematch?: {
|
|
99
66
|
keepSetup: boolean;
|
|
100
|
-
autoStart: boolean;
|
|
101
67
|
} | null;
|
|
102
|
-
host: string | null;
|
|
103
68
|
mode: string | null;
|
|
104
69
|
countdownAt: number | null;
|
|
105
70
|
configuration: RoomConfiguration | null;
|
|
@@ -107,7 +72,6 @@ export interface RoomMetadata {
|
|
|
107
72
|
closedCode: number | null;
|
|
108
73
|
}
|
|
109
74
|
export interface Room {
|
|
110
|
-
readonly replay: boolean;
|
|
111
75
|
readonly role: string | null;
|
|
112
76
|
readonly mode: string | null;
|
|
113
77
|
readonly countdownAt: number | null;
|
|
@@ -124,16 +88,13 @@ export interface Room {
|
|
|
124
88
|
readonly status: RoomStatus;
|
|
125
89
|
readonly players: readonly RoomPlayer[];
|
|
126
90
|
readonly you: string;
|
|
127
|
-
readonly host: string | null;
|
|
128
91
|
readonly code: string;
|
|
129
92
|
readonly result: JsonValue;
|
|
130
93
|
readonly voice: Voice;
|
|
131
|
-
readonly queuedScores: readonly QueuedScore[];
|
|
132
94
|
onError(listener: (error: {
|
|
133
95
|
code: string;
|
|
134
96
|
message: string;
|
|
135
97
|
}) => void): () => void;
|
|
136
|
-
onScoreQueued(listener: (score: QueuedScore) => void): () => void;
|
|
137
98
|
requestRole(role: string): Promise<void>;
|
|
138
99
|
invite(): RoomInvite;
|
|
139
100
|
onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
|
|
@@ -145,39 +106,10 @@ export interface Room {
|
|
|
145
106
|
ready(ready: boolean): void;
|
|
146
107
|
setRole(role: string): void;
|
|
147
108
|
setTeam(team: number): void;
|
|
148
|
-
start(): void;
|
|
149
109
|
restart(): void;
|
|
150
110
|
leave(): void;
|
|
151
111
|
serverTime(): number;
|
|
152
112
|
}
|
|
153
|
-
export interface Spectate {
|
|
154
|
-
readonly replay: boolean;
|
|
155
|
-
readonly role: 'spectator';
|
|
156
|
-
readonly mode: string | null;
|
|
157
|
-
readonly countdownAt: number | null;
|
|
158
|
-
readonly connection: ConnectionState;
|
|
159
|
-
readonly metadata: RoomMetadata;
|
|
160
|
-
onMetadata(listener: (metadata: RoomMetadata) => void): () => void;
|
|
161
|
-
onConnection(listener: (state: ConnectionState) => void): () => void;
|
|
162
|
-
disconnect(): void;
|
|
163
|
-
readonly state: JsonValue;
|
|
164
|
-
readonly tick: number;
|
|
165
|
-
readonly tickRate: number;
|
|
166
|
-
readonly latency: number | null;
|
|
167
|
-
readonly seed: number;
|
|
168
|
-
readonly status: RoomStatus;
|
|
169
|
-
readonly players: readonly RoomPlayer[];
|
|
170
|
-
readonly host: string | null;
|
|
171
|
-
readonly code: string;
|
|
172
|
-
readonly result: JsonValue;
|
|
173
|
-
readonly delayMs: number;
|
|
174
|
-
onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
|
|
175
|
-
onPlayers(listener: (players: readonly RoomPlayer[]) => void): () => void;
|
|
176
|
-
onStatus(listener: (status: RoomStatus, result: JsonValue, at: number) => void): () => void;
|
|
177
|
-
onMessage(listener: (message: JsonValue) => void): () => void;
|
|
178
|
-
leave(): void;
|
|
179
|
-
serverTime(): number;
|
|
180
|
-
}
|
|
181
113
|
export interface MatchOptions {
|
|
182
114
|
mode: string;
|
|
183
115
|
key: Record<string, string | number>;
|
|
@@ -189,7 +121,6 @@ export interface MatchOptions {
|
|
|
189
121
|
}): void;
|
|
190
122
|
}
|
|
191
123
|
export interface Rooms {
|
|
192
|
-
readonly replay?: false;
|
|
193
124
|
reload(): void;
|
|
194
125
|
onError(listener: (error: import('./errors.js').ErroreCaisual) => void): () => void;
|
|
195
126
|
readonly invited: string | null;
|
|
@@ -197,16 +128,69 @@ export interface Rooms {
|
|
|
197
128
|
mode: string | null;
|
|
198
129
|
}): Promise<Room>;
|
|
199
130
|
join(code?: string): Promise<Room>;
|
|
200
|
-
watch(code: string): Promise<Spectate>;
|
|
201
131
|
match(options: MatchOptions): Promise<Room>;
|
|
202
132
|
}
|
|
203
|
-
export interface
|
|
204
|
-
|
|
133
|
+
export interface Friend {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
online: boolean;
|
|
137
|
+
game: {
|
|
138
|
+
slug: string;
|
|
139
|
+
name: string;
|
|
140
|
+
iconUrl: string;
|
|
141
|
+
} | null;
|
|
142
|
+
room: {
|
|
143
|
+
code: string;
|
|
144
|
+
} | null;
|
|
145
|
+
}
|
|
146
|
+
export interface Party {
|
|
147
|
+
id: string;
|
|
148
|
+
leader: string;
|
|
149
|
+
members: readonly Friend[];
|
|
150
|
+
}
|
|
151
|
+
export interface PartyInvite {
|
|
152
|
+
party: string;
|
|
153
|
+
from: {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
};
|
|
157
|
+
at: number;
|
|
158
|
+
}
|
|
159
|
+
export interface CrewState {
|
|
160
|
+
connected: boolean;
|
|
161
|
+
you: {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
} | null;
|
|
165
|
+
friends: readonly Friend[];
|
|
166
|
+
party: Party | null;
|
|
167
|
+
invites: readonly PartyInvite[];
|
|
168
|
+
}
|
|
169
|
+
export interface Crew {
|
|
170
|
+
/** Falso nella copia locale del gioco: liste vuote e niente amici. */
|
|
171
|
+
readonly available: boolean;
|
|
172
|
+
readonly connected: boolean;
|
|
173
|
+
readonly you: {
|
|
174
|
+
id: string;
|
|
175
|
+
name: string;
|
|
176
|
+
} | null;
|
|
177
|
+
readonly friends: readonly Friend[];
|
|
178
|
+
readonly party: Party | null;
|
|
179
|
+
readonly invites: readonly PartyInvite[];
|
|
180
|
+
onChange(listener: (state: CrewState) => void): () => void;
|
|
181
|
+
createParty(): void;
|
|
182
|
+
invite(playerId: string): void;
|
|
183
|
+
accept(partyId: string): void;
|
|
184
|
+
decline(partyId: string): void;
|
|
185
|
+
kick(playerId: string): void;
|
|
186
|
+
leave(): void;
|
|
187
|
+
/** Chiede al sito di aprire il gioco e la stanza dell'amico, anche se e' un altro gioco. */
|
|
188
|
+
follow(playerId: string): void;
|
|
189
|
+
/** Entra nella stanza dell'amico, se e' in questo gioco. */
|
|
190
|
+
join(playerId: string): Promise<Room>;
|
|
205
191
|
}
|
|
206
192
|
export interface CaisualConnection {
|
|
207
193
|
text(): Promise<Text>;
|
|
208
|
-
session: Session;
|
|
209
|
-
overlay: Overlay;
|
|
210
194
|
connected: boolean;
|
|
211
195
|
device: DeviceReport;
|
|
212
196
|
player: Player;
|
|
@@ -227,21 +211,11 @@ export interface CaisualConnection {
|
|
|
227
211
|
remove(key: string): Promise<void>;
|
|
228
212
|
list(): Promise<SaveInfo[]>;
|
|
229
213
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
daily?: boolean;
|
|
233
|
-
}): Promise<BoardResult | BoardOffline>;
|
|
234
|
-
top(board: string, options?: {
|
|
235
|
-
daily?: boolean;
|
|
236
|
-
day?: string;
|
|
237
|
-
limit?: number;
|
|
238
|
-
guests?: boolean;
|
|
239
|
-
}): Promise<BoardTop>;
|
|
240
|
-
};
|
|
241
|
-
room: Rooms | ReplayRooms;
|
|
214
|
+
room: Rooms;
|
|
215
|
+
crew: Crew;
|
|
242
216
|
}
|
|
243
|
-
export type BaseConnection = Omit<CaisualConnection, 'device' | '
|
|
244
|
-
player: Omit<Player, 'language'
|
|
217
|
+
export type BaseConnection = Omit<CaisualConnection, 'device' | 'text' | 'player' | 'crew'> & {
|
|
218
|
+
player: Omit<Player, 'language'>;
|
|
245
219
|
};
|
|
246
220
|
export interface Caisual {
|
|
247
221
|
connect(): Promise<CaisualConnection>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type NetworkReport } from '../contracts/index.js';
|
|
1
2
|
import type { IncomingMessage } from 'node:http';
|
|
2
3
|
import type { Duplex } from 'node:stream';
|
|
3
|
-
import type { GameDefinition, JsonValue, RoomStatus
|
|
4
|
+
import type { GameDefinition, JsonValue, RoomStatus } from '../server/index.js';
|
|
4
5
|
export interface NodeWebSocket {
|
|
5
6
|
on(event: 'message', listener: (message: string) => void): this;
|
|
6
7
|
on(event: 'close', listener: () => void): this;
|
|
@@ -21,13 +22,6 @@ export interface NodeRoomManifest {
|
|
|
21
22
|
};
|
|
22
23
|
lobby: boolean;
|
|
23
24
|
persistent?: boolean;
|
|
24
|
-
boards?: Record<string, {
|
|
25
|
-
source: 'client' | 'server';
|
|
26
|
-
day?: 'submit' | 'start';
|
|
27
|
-
}>;
|
|
28
|
-
spectators?: {
|
|
29
|
-
delayMs: number;
|
|
30
|
-
} | null;
|
|
31
25
|
roles: Array<{
|
|
32
26
|
id: string;
|
|
33
27
|
min: number;
|
|
@@ -39,7 +33,6 @@ export interface NodeRoomManifest {
|
|
|
39
33
|
} | null;
|
|
40
34
|
modes: Array<{
|
|
41
35
|
id: string;
|
|
42
|
-
execution?: 'local' | 'room';
|
|
43
36
|
players?: {
|
|
44
37
|
min: number;
|
|
45
38
|
max: number;
|
|
@@ -54,13 +47,9 @@ export type NodeRoomJoinResult = {
|
|
|
54
47
|
ok: false;
|
|
55
48
|
code: 'room_not_found' | 'room_full' | 'room_ended' | 'room_playing';
|
|
56
49
|
};
|
|
57
|
-
export type NodeRoomWatchResult = {
|
|
58
|
-
ok: true;
|
|
59
|
-
} | {
|
|
60
|
-
ok: false;
|
|
61
|
-
code: 'room_not_found' | 'room_ended' | 'spectators_disabled' | 'spectators_full';
|
|
62
|
-
};
|
|
63
50
|
export interface NodeRoomInfo {
|
|
51
|
+
origin: 'player' | 'matchmaking';
|
|
52
|
+
lobby: boolean;
|
|
64
53
|
roomId: string;
|
|
65
54
|
status: RoomStatus;
|
|
66
55
|
players: number;
|
|
@@ -68,14 +57,6 @@ export interface NodeRoomInfo {
|
|
|
68
57
|
mode: string | null;
|
|
69
58
|
}
|
|
70
59
|
export interface NodeRoomFlush {
|
|
71
|
-
scores: Array<{
|
|
72
|
-
playerId: string;
|
|
73
|
-
board: string;
|
|
74
|
-
score: number;
|
|
75
|
-
daily: boolean;
|
|
76
|
-
day?: string | null;
|
|
77
|
-
submittedAt?: number;
|
|
78
|
-
}>;
|
|
79
60
|
ended: {
|
|
80
61
|
result: JsonValue;
|
|
81
62
|
at: number;
|
|
@@ -84,15 +65,13 @@ export interface NodeRoomFlush {
|
|
|
84
65
|
export interface NodeRoomOptions {
|
|
85
66
|
storageFile?: string;
|
|
86
67
|
dailyDay?: string;
|
|
87
|
-
deposito?: SharedGameStore | null;
|
|
88
68
|
}
|
|
89
69
|
export interface NodeRoom {
|
|
90
|
-
|
|
70
|
+
network(): NetworkReport;
|
|
71
|
+
create(roomId: string, mode: string | null, creator: NodePlayerIdentity, origin?: 'player' | 'matchmaking'): Promise<boolean>;
|
|
91
72
|
info(): Promise<NodeRoomInfo | null>;
|
|
92
73
|
canJoin(identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
|
|
93
|
-
canWatch(): Promise<NodeRoomWatchResult>;
|
|
94
74
|
connect(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
|
|
95
|
-
watch(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomWatchResult>;
|
|
96
75
|
flush(): Promise<NodeRoomFlush>;
|
|
97
76
|
wake(): Promise<void>;
|
|
98
77
|
close(): Promise<void>;
|