@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,3 +1,4 @@
1
+ export { measureNetwork } from './network-probe.js';
1
2
  import type { FotografiaStanza } from '../protocollo.js';
2
3
  import type { GameDefinition, JsonValue, RoomStatus } from '../server/index.js';
3
4
  export interface RoomManifest {
@@ -8,7 +9,6 @@ export interface RoomManifest {
8
9
  };
9
10
  lobby: boolean;
10
11
  persistent?: boolean;
11
- replays?: boolean;
12
12
  roles: Array<{
13
13
  id: string;
14
14
  min: number;
@@ -20,7 +20,6 @@ export interface RoomManifest {
20
20
  } | null;
21
21
  modes: Array<{
22
22
  id: string;
23
- execution?: 'local' | 'room';
24
23
  players?: {
25
24
  min: number;
26
25
  max: number;
@@ -39,7 +38,6 @@ export interface Esito {
39
38
  connessione: string;
40
39
  testo: string;
41
40
  }>;
42
- pubblici: string[];
43
41
  chiusure: Array<{
44
42
  connessione: string;
45
43
  codice: number;
@@ -52,6 +50,8 @@ export interface Esito {
52
50
  voceRivedi: boolean;
53
51
  }
54
52
  export interface InfoStanza {
53
+ origin: 'player' | 'matchmaking';
54
+ lobby: boolean;
55
55
  roomId: string;
56
56
  status: RoomStatus;
57
57
  players: number;
@@ -72,14 +72,6 @@ export type EsitoAscolto = {
72
72
  reason: 'mode' | 'unknown' | 'team' | 'gain';
73
73
  };
74
74
  export interface EsitoFlush {
75
- scores: Array<{
76
- playerId: string;
77
- board: string;
78
- score: number;
79
- daily: boolean;
80
- day?: string | null;
81
- submittedAt?: number;
82
- }>;
83
75
  ended: {
84
76
  result: JsonValue;
85
77
  at: number;
@@ -89,6 +81,7 @@ export interface FacetStanza {
89
81
  crea(input: {
90
82
  mode: string | null;
91
83
  creator: IdentitaGiocatore;
84
+ origin?: 'player' | 'matchmaking';
92
85
  }): Promise<Esito & {
93
86
  ok: boolean;
94
87
  }>;
@@ -0,0 +1,4 @@
1
+ import { type NetworkProbeResult } from '../contracts/index.js';
2
+ import type { GameDefinition } from '../server/index.js';
3
+ import type { ManifestStanza } from '../stanza/tipi.js';
4
+ export declare function measureNetwork(definition: GameDefinition, manifest: ManifestStanza): Promise<NetworkProbeResult>;
@@ -4,18 +4,10 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
4
4
  };
5
5
  export type RematchOptions = boolean | {
6
6
  keepSetup?: boolean;
7
- autoStart?: boolean;
8
7
  };
9
8
  export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
10
9
  export type VoiceMode = 'none' | 'room' | 'team' | 'proximity';
11
10
  export type LeaveReason = 'left' | 'timeout' | 'kicked';
12
- export interface SharedGameStore {
13
- get(key: string): Promise<JsonValue | null>;
14
- set(key: string, value: JsonValue): Promise<void>;
15
- delete(key: string): Promise<void>;
16
- list(prefix?: string): Promise<string[]>;
17
- increment(key: string, amount?: number): Promise<number>;
18
- }
19
11
  export interface Player {
20
12
  readonly id: string;
21
13
  readonly name: string;
@@ -34,7 +26,6 @@ export interface Room<State extends JsonValue = JsonValue> {
34
26
  readonly result: JsonValue | null;
35
27
  state: State;
36
28
  readonly players: readonly Player[];
37
- readonly host: Player | null;
38
29
  broadcast(message: JsonValue): void;
39
30
  send(player: Player | string, message: JsonValue): void;
40
31
  kick(player: Player | string): void;
@@ -45,7 +36,6 @@ export interface Room<State extends JsonValue = JsonValue> {
45
36
  }): void;
46
37
  save(key: string, value: JsonValue): Promise<void>;
47
38
  load(key: string): Promise<JsonValue | null>;
48
- readonly shared: SharedGameStore;
49
39
  schedule(milliseconds: number, handler: string, payload: JsonValue): void;
50
40
  readonly daily: {
51
41
  readonly day: string;
@@ -1,6 +1,6 @@
1
1
  import { type Player } from '../server/index.js';
2
2
  import type { FotografiaStanza } from '../protocollo.js';
3
- import type { AdattatoreStanza, EsitoAscolto, EsitoFlush, EsitoIngresso, IdentitaGiocatore, InfoStanza, ManifestStanza } from './tipi.js';
3
+ import type { AdattatoreStanza, EsitoAscolto, EsitoFlush, EsitoIngresso, IdentitaGiocatore, InfoStanza, ManifestStanza, StatoPersistito } from './tipi.js';
4
4
  export declare class NucleoStanza {
5
5
  private readonly definizione;
6
6
  private readonly manifest;
@@ -8,7 +8,6 @@ export declare class NucleoStanza {
8
8
  private dati;
9
9
  private readonly room;
10
10
  private readonly frequenza;
11
- private frequenzaDeposito;
12
11
  private readonly kickRichiesti;
13
12
  private readonly voceGuadagniCambiati;
14
13
  private fineRichiesta;
@@ -22,7 +21,7 @@ export declare class NucleoStanza {
22
21
  private richiediDati;
23
22
  private stanzaTerminata;
24
23
  get esiste(): boolean;
25
- crea(id: string, mode: string | null, _creator: IdentitaGiocatore): Promise<boolean>;
24
+ crea(id: string, mode: string | null, _creator: IdentitaGiocatore, origin?: StatoPersistito['origin']): Promise<boolean>;
26
25
  private get configurazione();
27
26
  info(playerId?: string): InfoStanza | null;
28
27
  fotografia(): FotografiaStanza | null;
@@ -52,12 +51,15 @@ export declare class NucleoStanza {
52
51
  private rivincita;
53
52
  private prontiRivincita;
54
53
  private avviaRivincita;
55
- private avviaCountdown;
56
- private verificaCountdown;
54
+ /**
55
+ * Nessuno ospita e nessuno preme "inizia": appena tutti i connessi sono pronti e i
56
+ * minimi di giocatori, ruoli e squadre sono rispettati parte il countdown; se la
57
+ * condizione cade durante il countdown si torna in lobby.
58
+ */
59
+ private rivalutaAvvio;
57
60
  private messaggioErrato;
58
61
  private chiudiConnessione;
59
62
  private rimuoviGiocatore;
60
- private assegnaHost;
61
63
  private eseguiTimer;
62
64
  private pianifica;
63
65
  private giornata;
@@ -65,15 +67,6 @@ export declare class NucleoStanza {
65
67
  private richiediFine;
66
68
  private salva;
67
69
  private caricaSave;
68
- private verificaChiaveDeposito;
69
- private verificaPrefissoDeposito;
70
- private contaOperazioneDeposito;
71
- private usaDeposito;
72
- private leggiDeposito;
73
- private scriviDeposito;
74
- private eliminaDeposito;
75
- private elencaDeposito;
76
- private incrementaDeposito;
77
70
  private messaggioCreatore;
78
71
  private broadcastCreatore;
79
72
  private inviaCreatore;
@@ -85,7 +78,6 @@ export declare class NucleoStanza {
85
78
  private inviaGiocatori;
86
79
  private inviaStatus;
87
80
  private inviaDiff;
88
- private iniziaReplay;
89
81
  private inviaSnapshotTutti;
90
82
  private chiama;
91
83
  private applicaAzioni;
@@ -1,4 +1,4 @@
1
- import type { JsonValue, RoomStatus, SharedGameStore } from '../server/index.js';
1
+ import type { JsonValue, RoomStatus } from '../server/index.js';
2
2
  import type { MessaggioServerStanza } from '../protocollo.js';
3
3
  export interface ManifestStanza {
4
4
  id: string;
@@ -8,7 +8,6 @@ export interface ManifestStanza {
8
8
  };
9
9
  lobby: boolean;
10
10
  persistent?: boolean;
11
- replays?: boolean;
12
11
  roles: Array<{
13
12
  id: string;
14
13
  min: number;
@@ -20,7 +19,6 @@ export interface ManifestStanza {
20
19
  } | null;
21
20
  modes: Array<{
22
21
  id: string;
23
- execution?: 'local' | 'room';
24
22
  players?: {
25
23
  min: number;
26
24
  max: number;
@@ -35,13 +33,9 @@ export interface ArchivioStanza {
35
33
  delete(key: string): Promise<void>;
36
34
  list(prefix?: string): Promise<Map<string, unknown>>;
37
35
  }
38
- export type DepositoCondiviso = SharedGameStore;
39
36
  export interface AdattatoreStanza {
40
37
  readonly storage: ArchivioStanza;
41
- readonly deposito: DepositoCondiviso | null;
42
38
  invia(connessione: string, messaggio: MessaggioServerStanza): void;
43
- inizioReplay?(fotografia: import('../protocollo.js').FotografiaStanza): void;
44
- pubblica(messaggio: MessaggioServerStanza): void;
45
39
  chiudi(connessione: string, codice: number, motivo: string): void;
46
40
  connessioniAttive(): readonly string[];
47
41
  ora(): number;
@@ -72,20 +66,13 @@ export interface TimerPersistito {
72
66
  handler: string;
73
67
  payload: JsonValue;
74
68
  }
75
- export interface PunteggioPersistito {
76
- playerId: string;
77
- board: string;
78
- score: number;
79
- daily: boolean;
80
- day?: string | null;
81
- submittedAt?: number;
82
- }
83
69
  export interface FinePersistita {
84
70
  result: JsonValue;
85
71
  at: number;
86
72
  }
87
73
  export interface StatoPersistito {
88
74
  versione: 1;
75
+ origin: 'player' | 'matchmaking';
89
76
  id: string;
90
77
  mode: string | null;
91
78
  status: RoomStatus;
@@ -95,13 +82,11 @@ export interface StatoPersistito {
95
82
  ultimoCambioStatoAt: number;
96
83
  state: JsonValue;
97
84
  giocatori: GiocatorePersistito[];
98
- hostId: string | null;
99
85
  result: JsonValue | null;
100
86
  resultAt: number | null;
101
87
  daily?: import('../daily.js').DailyContext;
102
88
  rivincita?: {
103
89
  keepSetup: boolean;
104
- autoStart: boolean;
105
90
  } | null;
106
91
  prontiPrecedenti?: string[];
107
92
  countdownRivincita?: boolean;
@@ -109,7 +94,6 @@ export interface StatoPersistito {
109
94
  countdownAt: number | null;
110
95
  timer: TimerPersistito[];
111
96
  prossimoTimerId: number;
112
- punteggi: PunteggioPersistito[];
113
97
  fineInCoda: FinePersistita | null;
114
98
  flushInAttesa?: EsitoFlush & {
115
99
  id: string;
@@ -135,6 +119,8 @@ export type EsitoAscolto = {
135
119
  reason: 'mode' | 'unknown' | 'team' | 'gain';
136
120
  };
137
121
  export interface InfoStanza {
122
+ origin: 'player' | 'matchmaking';
123
+ lobby: boolean;
138
124
  roomId: string;
139
125
  status: RoomStatus;
140
126
  players: number;
@@ -143,6 +129,5 @@ export interface InfoStanza {
143
129
  member: boolean;
144
130
  }
145
131
  export interface EsitoFlush {
146
- scores: PunteggioPersistito[];
147
132
  ended: FinePersistita | null;
148
133
  }
@@ -82,7 +82,6 @@ export declare class VoceClient implements Voice {
82
82
  socketDisconnesso(): void;
83
83
  socketRiconnesso(): void;
84
84
  termina(): void;
85
- private scegliMic;
86
85
  private verificaIngresso;
87
86
  private entra;
88
87
  private entraSfu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caisual/kit",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Client and server kit for Caisual games",
5
5
  "license": "MIT",
6
6
  "homepage": "https://caisual.com",
@@ -24,9 +24,8 @@
24
24
  "dist/runtime.d.ts",
25
25
  "dist/node.js",
26
26
  "dist/node.d.ts",
27
- "dist/overlay.js",
28
- "dist/overlay.js.map",
29
- "dist/overlay.d.ts",
27
+ "dist/host.js",
28
+ "dist/host.d.ts",
30
29
  "dist/types"
31
30
  ],
32
31
  "exports": {
@@ -50,25 +49,24 @@
50
49
  "import": "./dist/node.js",
51
50
  "default": "./dist/node.js"
52
51
  },
53
- "./overlay": {
54
- "types": "./dist/overlay.d.ts",
55
- "import": "./dist/overlay.js",
56
- "default": "./dist/overlay.js"
52
+ "./host": {
53
+ "types": "./dist/host.d.ts",
54
+ "import": "./dist/host.js",
55
+ "default": "./dist/host.js"
57
56
  }
58
57
  },
59
58
  "types": "./dist/kit.d.ts",
60
- "scripts": {
61
- "build": "node build.mjs",
62
- "prepack": "pnpm build",
63
- "typecheck": "tsc --noEmit && tsc -p tsconfig.node.json --noEmit",
64
- "test": "node verifica-dist.mjs && vitest run && WRANGLER_LOG_PATH=/tmp/caisual-kit-wrangler.log vitest run --config vitest.workers.config.ts"
65
- },
66
59
  "devDependencies": {
67
- "@caisual/contracts": "workspace:*",
68
60
  "@cloudflare/vitest-pool-workers": "^0.20.3",
69
61
  "@types/node": "^26.2.0",
70
62
  "esbuild": "^0.28.1",
71
63
  "typescript": "^7.0.2",
72
- "vitest": "^4.1.10"
64
+ "vitest": "^4.1.10",
65
+ "@caisual/contracts": "0.0.0"
66
+ },
67
+ "scripts": {
68
+ "build": "node build.mjs",
69
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.node.json --noEmit",
70
+ "test": "node verifica-dist.mjs && vitest run && WRANGLER_LOG_PATH=/tmp/caisual-kit-wrangler.log vitest run --config vitest.workers.config.ts"
73
71
  }
74
- }
72
+ }
package/dist/overlay.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './types/overlay/index.js';