@caisual/kit 0.21.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.
Files changed (44) hide show
  1. package/README.md +6 -9
  2. package/dist/host.d.ts +1 -0
  3. package/dist/host.js +169 -0
  4. package/dist/kit.js +2 -4
  5. package/dist/kit.js.map +4 -4
  6. package/dist/node.js +164 -409
  7. package/dist/runtime.js +212 -251
  8. package/dist/types/api.d.ts +1 -1
  9. package/dist/types/contracts/connessione.d.ts +1 -0
  10. package/dist/types/contracts/giornata.d.ts +1 -0
  11. package/dist/types/contracts/index.d.ts +3 -2
  12. package/dist/types/contracts/manifest.d.ts +6 -41
  13. package/dist/types/contracts/network-budget.d.ts +53 -0
  14. package/dist/types/contracts/versioni.d.ts +0 -1
  15. package/dist/types/crew/index.d.ts +4 -0
  16. package/dist/types/handshake.d.ts +0 -4
  17. package/dist/types/{overlay/host-bridge.d.ts → host/index.d.ts} +60 -37
  18. package/dist/types/index.d.ts +64 -50
  19. package/dist/types/node/index.d.ts +6 -23
  20. package/dist/types/protocollo.d.ts +1 -20
  21. package/dist/types/runtime/index.d.ts +4 -11
  22. package/dist/types/runtime/network-probe.d.ts +4 -0
  23. package/dist/types/server/index.d.ts +0 -10
  24. package/dist/types/stanza/nucleo.d.ts +8 -16
  25. package/dist/types/stanza/tipi.d.ts +4 -19
  26. package/dist/types/voce/index.d.ts +0 -1
  27. package/package.json +15 -17
  28. package/dist/overlay.d.ts +0 -1
  29. package/dist/overlay.js +0 -2157
  30. package/dist/overlay.js.map +0 -7
  31. package/dist/types/contracts/overlay.d.ts +0 -235
  32. package/dist/types/contracts/replay.d.ts +0 -83
  33. package/dist/types/overlay/bridge.d.ts +0 -3
  34. package/dist/types/overlay/i18n.d.ts +0 -128
  35. package/dist/types/overlay/index.d.ts +0 -9
  36. package/dist/types/overlay/locale.d.ts +0 -4
  37. package/dist/types/overlay/shortcut.d.ts +0 -4
  38. package/dist/types/overlay/styles.d.ts +0 -1
  39. package/dist/types/overlay/ui-model.d.ts +0 -53
  40. package/dist/types/overlay/ui.d.ts +0 -81
  41. package/dist/types/overlay/voice-panel.d.ts +0 -13
  42. package/dist/types/replay/index.d.ts +0 -65
  43. package/dist/types/session/index.d.ts +0 -49
  44. package/dist/types/session/resume.d.ts +0 -13
@@ -1,7 +1,7 @@
1
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' | 'uiLanguage'>;
4
+ player: Omit<Player, 'language'>;
5
5
  game: {
6
6
  slug: string;
7
7
  };
@@ -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,12 +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
10
  export * from './i18n.js';
11
+ export * from './giornata.js';
12
+ export * from './connessione.js';
12
13
  export * from './room-limits.js';
14
+ export * from './network-budget.js';
13
15
  export * from './player.js';
14
16
  export * from './match-result.js';
15
17
  export * from './immagine.js';
16
18
  export * from './versioni.js';
17
- export * from './replay.js';
18
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 risolviPresentazione(manifest: ManifestModalita & {
67
- name?: string;
68
- languages?: string[];
69
- language?: string;
70
- }, mode: string | null, language?: string): {
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,15 +71,11 @@ 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;
106
77
  modes: ManifestMode[];
107
78
  }
108
- export type GameManifest = Omit<Manifest, 'boards'>;
109
79
  export declare const AVVISO_ISOLATED = "isolated has no effect: games run inside the portal page, which is not cross-origin isolated";
110
80
  export declare function avvisiManifest(value: unknown): string[];
111
81
  export type EsitoManifest = {
@@ -116,14 +86,9 @@ export type EsitoManifest = {
116
86
  errori: string[];
117
87
  };
118
88
  export declare const TETTO_GIOCATORI = 24;
119
- export declare const MASSIMO_SPETTATORI = 100;
120
- export declare const RITARDO_SPETTATORI_MS = 3000;
121
- export declare const MASSIMO_CLASSIFICHE = 32;
122
- export declare function sorgenteClassifica(manifest: {
123
- boards?: Record<string, ManifestBoard>;
124
- }, board: string): 'client' | 'server';
125
89
  /**
126
90
  * Valida tutto il documento in un solo passaggio e restituisce tutti gli
127
91
  * errori. Un agente puo' cosi' correggere il file senza tentativi ripetuti.
128
92
  */
129
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 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
- watch?: boolean;
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,38 +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
- readonly epoch: string | null;
50
- serverTime(): number | null;
51
- readonly state: OverlaySessionState | null;
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
- 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;
63
100
  dispose(): void;
64
101
  };
65
102
  export type HostBridge = ReturnType<typeof creaPonteOspite>;
66
103
  export declare function avviaHandshake(input: HostBridgeInput): () => void;
67
- export declare function gameViewport(frame: HTMLIFrameElement): {
68
- left: number;
69
- top: number;
70
- right: number;
71
- bottom: number;
72
- scaleX: number;
73
- scaleY: number;
74
- };
75
- export declare function measureSafeArea(frame: HTMLIFrameElement, probe: HTMLElement): {
76
- top: number;
77
- right: number;
78
- bottom: number;
79
- left: number;
80
- };
@@ -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, QueuedScore } from './contracts/index.js';
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 { Session, GameSession, Overlay } from './session/index.js';
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;
@@ -65,12 +62,9 @@ export interface RoomInvite {
65
62
  url: string;
66
63
  }
67
64
  export interface RoomMetadata {
68
- replayId?: string | null;
69
65
  rematch?: {
70
66
  keepSetup: boolean;
71
- autoStart: boolean;
72
67
  } | null;
73
- host: string | null;
74
68
  mode: string | null;
75
69
  countdownAt: number | null;
76
70
  configuration: RoomConfiguration | null;
@@ -78,7 +72,6 @@ export interface RoomMetadata {
78
72
  closedCode: number | null;
79
73
  }
80
74
  export interface Room {
81
- readonly replay: boolean;
82
75
  readonly role: string | null;
83
76
  readonly mode: string | null;
84
77
  readonly countdownAt: number | null;
@@ -95,16 +88,13 @@ export interface Room {
95
88
  readonly status: RoomStatus;
96
89
  readonly players: readonly RoomPlayer[];
97
90
  readonly you: string;
98
- readonly host: string | null;
99
91
  readonly code: string;
100
92
  readonly result: JsonValue;
101
93
  readonly voice: Voice;
102
- readonly queuedScores: readonly QueuedScore[];
103
94
  onError(listener: (error: {
104
95
  code: string;
105
96
  message: string;
106
97
  }) => void): () => void;
107
- onScoreQueued(listener: (score: QueuedScore) => void): () => void;
108
98
  requestRole(role: string): Promise<void>;
109
99
  invite(): RoomInvite;
110
100
  onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
@@ -116,39 +106,10 @@ export interface Room {
116
106
  ready(ready: boolean): void;
117
107
  setRole(role: string): void;
118
108
  setTeam(team: number): void;
119
- start(): void;
120
109
  restart(): void;
121
110
  leave(): void;
122
111
  serverTime(): number;
123
112
  }
124
- export interface Spectate {
125
- readonly replay: boolean;
126
- readonly role: 'spectator';
127
- readonly mode: string | null;
128
- readonly countdownAt: number | null;
129
- readonly connection: ConnectionState;
130
- readonly metadata: RoomMetadata;
131
- onMetadata(listener: (metadata: RoomMetadata) => void): () => void;
132
- onConnection(listener: (state: ConnectionState) => void): () => void;
133
- disconnect(): void;
134
- readonly state: JsonValue;
135
- readonly tick: number;
136
- readonly tickRate: number;
137
- readonly latency: number | null;
138
- readonly seed: number;
139
- readonly status: RoomStatus;
140
- readonly players: readonly RoomPlayer[];
141
- readonly host: string | null;
142
- readonly code: string;
143
- readonly result: JsonValue;
144
- readonly delayMs: number;
145
- onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
146
- onPlayers(listener: (players: readonly RoomPlayer[]) => void): () => void;
147
- onStatus(listener: (status: RoomStatus, result: JsonValue, at: number) => void): () => void;
148
- onMessage(listener: (message: JsonValue) => void): () => void;
149
- leave(): void;
150
- serverTime(): number;
151
- }
152
113
  export interface MatchOptions {
153
114
  mode: string;
154
115
  key: Record<string, string | number>;
@@ -160,7 +121,6 @@ export interface MatchOptions {
160
121
  }): void;
161
122
  }
162
123
  export interface Rooms {
163
- readonly replay?: false;
164
124
  reload(): void;
165
125
  onError(listener: (error: import('./errors.js').ErroreCaisual) => void): () => void;
166
126
  readonly invited: string | null;
@@ -168,16 +128,69 @@ export interface Rooms {
168
128
  mode: string | null;
169
129
  }): Promise<Room>;
170
130
  join(code?: string): Promise<Room>;
171
- watch(code: string): Promise<Spectate>;
172
131
  match(options: MatchOptions): Promise<Room>;
173
132
  }
174
- export interface ReplayRooms extends Omit<Rooms, 'replay'>, Spectate {
175
- readonly replay: true;
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>;
176
191
  }
177
192
  export interface CaisualConnection {
178
193
  text(): Promise<Text>;
179
- session: Session;
180
- overlay: Overlay;
181
194
  connected: boolean;
182
195
  device: DeviceReport;
183
196
  player: Player;
@@ -198,10 +211,11 @@ export interface CaisualConnection {
198
211
  remove(key: string): Promise<void>;
199
212
  list(): Promise<SaveInfo[]>;
200
213
  };
201
- room: Rooms | ReplayRooms;
214
+ room: Rooms;
215
+ crew: Crew;
202
216
  }
203
- export type BaseConnection = Omit<CaisualConnection, 'device' | 'session' | 'overlay' | 'text' | 'player'> & {
204
- player: Omit<Player, 'language' | 'uiLanguage'>;
217
+ export type BaseConnection = Omit<CaisualConnection, 'device' | 'text' | 'player' | 'crew'> & {
218
+ player: Omit<Player, 'language'>;
205
219
  };
206
220
  export interface Caisual {
207
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, SharedGameStore } from '../server/index.js';
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,9 +22,6 @@ export interface NodeRoomManifest {
21
22
  };
22
23
  lobby: boolean;
23
24
  persistent?: boolean;
24
- spectators?: {
25
- delayMs: number;
26
- } | null;
27
25
  roles: Array<{
28
26
  id: string;
29
27
  min: number;
@@ -35,7 +33,6 @@ export interface NodeRoomManifest {
35
33
  } | null;
36
34
  modes: Array<{
37
35
  id: string;
38
- execution?: 'local' | 'room';
39
36
  players?: {
40
37
  min: number;
41
38
  max: number;
@@ -50,13 +47,9 @@ export type NodeRoomJoinResult = {
50
47
  ok: false;
51
48
  code: 'room_not_found' | 'room_full' | 'room_ended' | 'room_playing';
52
49
  };
53
- export type NodeRoomWatchResult = {
54
- ok: true;
55
- } | {
56
- ok: false;
57
- code: 'room_not_found' | 'room_ended' | 'spectators_disabled' | 'spectators_full';
58
- };
59
50
  export interface NodeRoomInfo {
51
+ origin: 'player' | 'matchmaking';
52
+ lobby: boolean;
60
53
  roomId: string;
61
54
  status: RoomStatus;
62
55
  players: number;
@@ -64,14 +57,6 @@ export interface NodeRoomInfo {
64
57
  mode: string | null;
65
58
  }
66
59
  export interface NodeRoomFlush {
67
- scores: Array<{
68
- playerId: string;
69
- board: string;
70
- score: number;
71
- daily: boolean;
72
- day?: string | null;
73
- submittedAt?: number;
74
- }>;
75
60
  ended: {
76
61
  result: JsonValue;
77
62
  at: number;
@@ -80,15 +65,13 @@ export interface NodeRoomFlush {
80
65
  export interface NodeRoomOptions {
81
66
  storageFile?: string;
82
67
  dailyDay?: string;
83
- deposito?: SharedGameStore | null;
84
68
  }
85
69
  export interface NodeRoom {
86
- create(roomId: string, mode: string | null, creator: NodePlayerIdentity): Promise<boolean>;
70
+ network(): NetworkReport;
71
+ create(roomId: string, mode: string | null, creator: NodePlayerIdentity, origin?: 'player' | 'matchmaking'): Promise<boolean>;
87
72
  info(): Promise<NodeRoomInfo | null>;
88
73
  canJoin(identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
89
- canWatch(): Promise<NodeRoomWatchResult>;
90
74
  connect(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
91
- watch(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomWatchResult>;
92
75
  flush(): Promise<NodeRoomFlush>;
93
76
  wake(): Promise<void>;
94
77
  close(): Promise<void>;
@@ -1,4 +1,3 @@
1
- import type { QueuedScore } from './contracts/index.js';
2
1
  import type { JsonValue, RoomStatus } from './server/index.js';
3
2
  export type PercorsoDiff = Array<string | number>;
4
3
  export type OperazioneDiff = {
@@ -43,7 +42,6 @@ export interface RoomConfiguration {
43
42
  export interface StanzaProtocollo {
44
43
  rematch?: {
45
44
  keepSetup: boolean;
46
- autoStart: boolean;
47
45
  } | null;
48
46
  result?: JsonValue;
49
47
  countdownAt?: number | null;
@@ -55,8 +53,8 @@ export interface StanzaProtocollo {
55
53
  tick: number;
56
54
  tickRate: number;
57
55
  serverTime: number;
58
- host: string | null;
59
56
  }
57
+ /** Istantanea di sola lettura della stanza: stato, giocatori e metadati in un colpo. */
60
58
  export interface FotografiaStanza {
61
59
  room: StanzaProtocollo;
62
60
  players: GiocatoreProtocollo[];
@@ -190,8 +188,6 @@ export type MessaggioClientStanza = MessaggioClientVoce | {
190
188
  } | {
191
189
  t: 'team';
192
190
  team: number;
193
- } | {
194
- t: 'start';
195
191
  } | {
196
192
  t: 'restart';
197
193
  } | {
@@ -207,9 +203,6 @@ export type MessaggioClientStanza = MessaggioClientVoce | {
207
203
  t: 'leave';
208
204
  };
209
205
  export type MessaggioServerStanza = {
210
- t: 'replay-ready';
211
- id: string;
212
- } | {
213
206
  t: 'welcome';
214
207
  you: string;
215
208
  room: StanzaProtocollo;
@@ -218,26 +211,20 @@ export type MessaggioServerStanza = {
218
211
  } | {
219
212
  t: 'players';
220
213
  players: GiocatoreProtocollo[];
221
- host?: string | null;
222
214
  } | {
223
215
  t: 'role-result';
224
216
  r: number;
225
217
  ok: boolean;
226
218
  code: string | null;
227
- } | {
228
- t: 'score-queued';
229
- score: QueuedScore;
230
219
  } | {
231
220
  t: 'status';
232
221
  rematch?: {
233
222
  keepSetup: boolean;
234
- autoStart: boolean;
235
223
  } | null;
236
224
  status: RoomStatus;
237
225
  at: number;
238
226
  result: JsonValue;
239
227
  countdownAt?: number | null;
240
- host?: string | null;
241
228
  } | {
242
229
  t: 'state';
243
230
  tickRate?: number;
@@ -265,9 +252,3 @@ export type MessaggioServerStanza = {
265
252
  } | {
266
253
  t: 'flush';
267
254
  } | MessaggioServerVoce;
268
- export type MessaggioServerSpettatore = ({
269
- t: 'watching';
270
- delayMs: number;
271
- } & FotografiaStanza) | Extract<MessaggioServerStanza, {
272
- t: 'replay-ready' | 'players' | 'status' | 'state' | 'snapshot' | 'msg' | 'error' | 'pong';
273
- }>;