@caisual/kit 0.21.0 → 0.23.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 +12 -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 +193 -427
  7. package/dist/runtime.js +241 -269
  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 +7 -50
  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 +66 -57
  19. package/dist/types/node/index.d.ts +5 -25
  20. package/dist/types/protocollo.d.ts +2 -21
  21. package/dist/types/runtime/index.d.ts +3 -13
  22. package/dist/types/runtime/network-probe.d.ts +4 -0
  23. package/dist/types/server/index.d.ts +1 -11
  24. package/dist/types/stanza/nucleo.d.ts +8 -16
  25. package/dist/types/stanza/tipi.d.ts +3 -21
  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;
@@ -18,11 +17,6 @@ export interface ManifestTeams {
18
17
  min: number;
19
18
  max: number;
20
19
  }
21
- export interface ManifestMatchmaking {
22
- defaults?: Record<string, string | number>;
23
- key: string[];
24
- timeoutMs: number;
25
- }
26
20
  export interface ManifestRequires {
27
21
  webgl2: boolean;
28
22
  webgpu: boolean;
@@ -31,51 +25,24 @@ export interface ManifestRequires {
31
25
  memoryMb: number | null;
32
26
  performance: 'light' | 'medium' | 'heavy';
33
27
  }
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
28
  export interface ManifestMode {
50
- execution?: ModeExecution;
51
- label?: LocalizedText;
52
- instructions?: LocalizedText;
53
29
  id: string;
54
30
  players?: ManifestPlayers;
55
- lobby?: boolean;
56
- matchmaking?: ManifestMatchmaking;
31
+ matchmaking?: boolean;
57
32
  }
58
33
  export interface ModalitaRisolta {
59
34
  players: ManifestPlayers;
60
- lobby: boolean;
61
35
  }
62
36
  export type ManifestModalita = ModalitaRisolta & {
63
37
  modes: ManifestMode[];
64
38
  };
65
39
  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;
40
+ export declare function richiedeServer(manifest: ManifestModalita): boolean;
41
+ export declare function modalitaLocale(manifest: ManifestModalita, mode: string | null): boolean;
42
+ 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.";
43
+ export declare const MODE_LOCAL_MESSAGE = "Single-player modes run in the browser and have no room.";
44
+ export declare const AVVISO_SERVER_INUTILE = "server.js is unnecessary: all modes run in the browser.";
77
45
  export interface Manifest {
78
- overlay?: ManifestOverlay | null;
79
46
  manifest: 1;
80
47
  id: string;
81
48
  name: string;
@@ -95,17 +62,12 @@ export interface Manifest {
95
62
  network: string[];
96
63
  requires: ManifestRequires;
97
64
  players: ManifestPlayers;
98
- lobby: boolean;
99
65
  persistent: boolean;
100
- replays: boolean;
101
- spectators: ManifestSpectators | null;
102
- boards: Record<string, ManifestBoard>;
103
66
  roles: ManifestRole[];
104
67
  teams: ManifestTeams | null;
105
68
  voice: Voice;
106
69
  modes: ManifestMode[];
107
70
  }
108
- export type GameManifest = Omit<Manifest, 'boards'>;
109
71
  export declare const AVVISO_ISOLATED = "isolated has no effect: games run inside the portal page, which is not cross-origin isolated";
110
72
  export declare function avvisiManifest(value: unknown): string[];
111
73
  export type EsitoManifest = {
@@ -116,14 +78,9 @@ export type EsitoManifest = {
116
78
  errori: string[];
117
79
  };
118
80
  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
81
  /**
126
82
  * Valida tutto il documento in un solo passaggio e restituisce tutti gli
127
83
  * errori. Un agente puo' cosi' correggere il file senza tentativi ripetuti.
128
84
  */
129
85
  export declare function validaManifest(valore: unknown): EsitoManifest;
86
+ 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;
@@ -24,7 +21,7 @@ export interface SaveInfo {
24
21
  bytes: number;
25
22
  updatedAt: number;
26
23
  }
27
- export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
24
+ export type RoomStatus = 'waiting' | 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
28
25
  export interface RoomPlayer {
29
26
  id: string;
30
27
  name: string;
@@ -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;
@@ -92,19 +85,17 @@ export interface Room {
92
85
  readonly tickRate: number;
93
86
  readonly latency: number | null;
94
87
  readonly seed: number;
88
+ readonly origin: 'player' | 'matchmaking';
95
89
  readonly status: RoomStatus;
96
90
  readonly players: readonly RoomPlayer[];
97
91
  readonly you: string;
98
- readonly host: string | null;
99
92
  readonly code: string;
100
93
  readonly result: JsonValue;
101
94
  readonly voice: Voice;
102
- readonly queuedScores: readonly QueuedScore[];
103
95
  onError(listener: (error: {
104
96
  code: string;
105
97
  message: string;
106
98
  }) => void): () => void;
107
- onScoreQueued(listener: (score: QueuedScore) => void): () => void;
108
99
  requestRole(role: string): Promise<void>;
109
100
  invite(): RoomInvite;
110
101
  onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
@@ -116,51 +107,15 @@ export interface Room {
116
107
  ready(ready: boolean): void;
117
108
  setRole(role: string): void;
118
109
  setTeam(team: number): void;
119
- start(): void;
120
110
  restart(): void;
121
111
  leave(): void;
122
112
  serverTime(): number;
123
113
  }
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
114
  export interface MatchOptions {
153
115
  mode: string;
154
- key: Record<string, string | number>;
155
116
  signal?: AbortSignal;
156
- onWaiting?(waiting: {
157
- players: number;
158
- min: number;
159
- max: number;
160
- }): void;
161
117
  }
162
118
  export interface Rooms {
163
- readonly replay?: false;
164
119
  reload(): void;
165
120
  onError(listener: (error: import('./errors.js').ErroreCaisual) => void): () => void;
166
121
  readonly invited: string | null;
@@ -168,16 +123,69 @@ export interface Rooms {
168
123
  mode: string | null;
169
124
  }): Promise<Room>;
170
125
  join(code?: string): Promise<Room>;
171
- watch(code: string): Promise<Spectate>;
172
126
  match(options: MatchOptions): Promise<Room>;
173
127
  }
174
- export interface ReplayRooms extends Omit<Rooms, 'replay'>, Spectate {
175
- readonly replay: true;
128
+ export interface Friend {
129
+ id: string;
130
+ name: string;
131
+ online: boolean;
132
+ game: {
133
+ slug: string;
134
+ name: string;
135
+ iconUrl: string;
136
+ } | null;
137
+ room: {
138
+ code: string;
139
+ } | null;
140
+ }
141
+ export interface Party {
142
+ id: string;
143
+ leader: string;
144
+ members: readonly Friend[];
145
+ }
146
+ export interface PartyInvite {
147
+ party: string;
148
+ from: {
149
+ id: string;
150
+ name: string;
151
+ };
152
+ at: number;
153
+ }
154
+ export interface CrewState {
155
+ connected: boolean;
156
+ you: {
157
+ id: string;
158
+ name: string;
159
+ } | null;
160
+ friends: readonly Friend[];
161
+ party: Party | null;
162
+ invites: readonly PartyInvite[];
163
+ }
164
+ export interface Crew {
165
+ /** Falso nella copia locale del gioco: liste vuote e niente amici. */
166
+ readonly available: boolean;
167
+ readonly connected: boolean;
168
+ readonly you: {
169
+ id: string;
170
+ name: string;
171
+ } | null;
172
+ readonly friends: readonly Friend[];
173
+ readonly party: Party | null;
174
+ readonly invites: readonly PartyInvite[];
175
+ onChange(listener: (state: CrewState) => void): () => void;
176
+ createParty(): void;
177
+ invite(playerId: string): void;
178
+ accept(partyId: string): void;
179
+ decline(partyId: string): void;
180
+ kick(playerId: string): void;
181
+ leave(): void;
182
+ /** Chiede al sito di aprire il gioco e la stanza dell'amico, anche se e' un altro gioco. */
183
+ follow(playerId: string): void;
184
+ /** Entra nella stanza dell'amico, se e' in questo gioco. */
185
+ join(playerId: string): Promise<Room>;
176
186
  }
177
187
  export interface CaisualConnection {
178
188
  text(): Promise<Text>;
179
- session: Session;
180
- overlay: Overlay;
181
189
  connected: boolean;
182
190
  device: DeviceReport;
183
191
  player: Player;
@@ -198,10 +206,11 @@ export interface CaisualConnection {
198
206
  remove(key: string): Promise<void>;
199
207
  list(): Promise<SaveInfo[]>;
200
208
  };
201
- room: Rooms | ReplayRooms;
209
+ room: Rooms;
210
+ crew: Crew;
202
211
  }
203
- export type BaseConnection = Omit<CaisualConnection, 'device' | 'session' | 'overlay' | 'text' | 'player'> & {
204
- player: Omit<Player, 'language' | 'uiLanguage'>;
212
+ export type BaseConnection = Omit<CaisualConnection, 'device' | 'text' | 'player' | 'crew'> & {
213
+ player: Omit<Player, 'language'>;
205
214
  };
206
215
  export interface Caisual {
207
216
  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;
@@ -19,11 +20,7 @@ export interface NodeRoomManifest {
19
20
  min: number;
20
21
  max: number;
21
22
  };
22
- lobby: boolean;
23
23
  persistent?: boolean;
24
- spectators?: {
25
- delayMs: number;
26
- } | null;
27
24
  roles: Array<{
28
25
  id: string;
29
26
  min: number;
@@ -35,12 +32,10 @@ export interface NodeRoomManifest {
35
32
  } | null;
36
33
  modes: Array<{
37
34
  id: string;
38
- execution?: 'local' | 'room';
39
35
  players?: {
40
36
  min: number;
41
37
  max: number;
42
38
  };
43
- lobby?: boolean;
44
39
  }>;
45
40
  voice?: 'none' | 'room' | 'team' | 'proximity';
46
41
  }
@@ -50,13 +45,8 @@ export type NodeRoomJoinResult = {
50
45
  ok: false;
51
46
  code: 'room_not_found' | 'room_full' | 'room_ended' | 'room_playing';
52
47
  };
53
- export type NodeRoomWatchResult = {
54
- ok: true;
55
- } | {
56
- ok: false;
57
- code: 'room_not_found' | 'room_ended' | 'spectators_disabled' | 'spectators_full';
58
- };
59
48
  export interface NodeRoomInfo {
49
+ origin: 'player' | 'matchmaking';
60
50
  roomId: string;
61
51
  status: RoomStatus;
62
52
  players: number;
@@ -64,14 +54,6 @@ export interface NodeRoomInfo {
64
54
  mode: string | null;
65
55
  }
66
56
  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
57
  ended: {
76
58
  result: JsonValue;
77
59
  at: number;
@@ -80,15 +62,13 @@ export interface NodeRoomFlush {
80
62
  export interface NodeRoomOptions {
81
63
  storageFile?: string;
82
64
  dailyDay?: string;
83
- deposito?: SharedGameStore | null;
84
65
  }
85
66
  export interface NodeRoom {
86
- create(roomId: string, mode: string | null, creator: NodePlayerIdentity): Promise<boolean>;
67
+ network(): NetworkReport;
68
+ create(roomId: string, mode: string | null, creator: NodePlayerIdentity, origin?: 'player' | 'matchmaking'): Promise<boolean>;
87
69
  info(): Promise<NodeRoomInfo | null>;
88
70
  canJoin(identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
89
- canWatch(): Promise<NodeRoomWatchResult>;
90
71
  connect(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomJoinResult>;
91
- watch(socket: NodeWebSocket, identity: NodePlayerIdentity): Promise<NodeRoomWatchResult>;
92
72
  flush(): Promise<NodeRoomFlush>;
93
73
  wake(): Promise<void>;
94
74
  close(): Promise<void>;