@caisual/kit 0.4.0 → 0.8.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 (54) hide show
  1. package/dist/kit.d.ts +2 -157
  2. package/dist/kit.js +1539 -59
  3. package/dist/node.d.ts +1 -77
  4. package/dist/node.js +341 -42
  5. package/dist/overlay.d.ts +1 -0
  6. package/dist/overlay.js +1846 -0
  7. package/dist/runtime.d.ts +1 -108
  8. package/dist/runtime.js +191 -41
  9. package/dist/server.d.ts +1 -71
  10. package/dist/server.js +1 -0
  11. package/dist/types/api.d.ts +25 -0
  12. package/dist/types/contracts/biglietto.d.ts +24 -0
  13. package/dist/types/contracts/device.d.ts +66 -0
  14. package/dist/types/contracts/firma.d.ts +21 -0
  15. package/dist/types/contracts/index.d.ts +10 -0
  16. package/dist/types/contracts/keys.d.ts +59 -0
  17. package/dist/types/contracts/manifest.d.ts +118 -0
  18. package/dist/types/contracts/overlay-boards.d.ts +3 -0
  19. package/dist/types/contracts/overlay.d.ts +215 -0
  20. package/dist/types/contracts/runtime.d.ts +70 -0
  21. package/dist/types/contracts/server-js.d.ts +11 -0
  22. package/dist/types/contracts/slug.d.ts +5 -0
  23. package/dist/types/contracts/token-crew.d.ts +21 -0
  24. package/dist/types/daily.d.ts +3 -0
  25. package/dist/types/errors.d.ts +6 -0
  26. package/dist/types/handshake.d.ts +26 -0
  27. package/dist/types/http.d.ts +3 -0
  28. package/dist/types/index.d.ts +217 -0
  29. package/dist/types/kit.d.ts +26 -0
  30. package/dist/types/node/index.d.ts +96 -0
  31. package/dist/types/node/websocket.d.ts +29 -0
  32. package/dist/types/overlay/boards.d.ts +48 -0
  33. package/dist/types/overlay/bridge.d.ts +3 -0
  34. package/dist/types/overlay/host-bridge.d.ts +58 -0
  35. package/dist/types/overlay/i18n.d.ts +122 -0
  36. package/dist/types/overlay/index.d.ts +9 -0
  37. package/dist/types/overlay/shortcut.d.ts +4 -0
  38. package/dist/types/overlay/styles.d.ts +1 -0
  39. package/dist/types/overlay/ui-model.d.ts +45 -0
  40. package/dist/types/overlay/ui.d.ts +80 -0
  41. package/dist/types/overlay/voice-panel.d.ts +13 -0
  42. package/dist/types/protocollo.d.ts +257 -0
  43. package/dist/types/runtime/index.d.ts +127 -0
  44. package/dist/types/server/index.d.ts +72 -0
  45. package/dist/types/session/index.d.ts +49 -0
  46. package/dist/types/session/resume.d.ts +13 -0
  47. package/dist/types/standalone.d.ts +14 -0
  48. package/dist/types/stanza/index.d.ts +3 -0
  49. package/dist/types/stanza/json.d.ts +18 -0
  50. package/dist/types/stanza/nucleo.d.ts +97 -0
  51. package/dist/types/stanza/tipi.d.ts +134 -0
  52. package/dist/types/stanza-client/index.d.ts +24 -0
  53. package/dist/types/voce/index.d.ts +124 -0
  54. package/package.json +10 -2
@@ -0,0 +1,97 @@
1
+ import { type Player } from '../server/index.js';
2
+ import type { FotografiaStanza } from '../protocollo.js';
3
+ import type { AdattatoreStanza, EsitoAscolto, EsitoFlush, EsitoIngresso, IdentitaGiocatore, InfoStanza, ManifestStanza } from './tipi.js';
4
+ export declare class NucleoStanza {
5
+ private readonly definizione;
6
+ private readonly manifest;
7
+ private readonly adattatore;
8
+ private dati;
9
+ private readonly room;
10
+ private readonly frequenza;
11
+ private frequenzaDeposito;
12
+ private readonly kickRichiesti;
13
+ private readonly voceGuadagniCambiati;
14
+ private fineRichiesta;
15
+ private applicandoAzioni;
16
+ private ultimoStatoOsservato;
17
+ private voceDaPersistire;
18
+ private constructor();
19
+ static apri(definizione: unknown, manifest: ManifestStanza, adattatore: AdattatoreStanza): Promise<NucleoStanza>;
20
+ private static verificaManifest;
21
+ private richiediDati;
22
+ private stanzaTerminata;
23
+ get esiste(): boolean;
24
+ crea(id: string, mode: string | null, _creator: IdentitaGiocatore): Promise<boolean>;
25
+ private get configurazione();
26
+ info(playerId?: string): InfoStanza | null;
27
+ fotografia(): FotografiaStanza | null;
28
+ giocatoreConnesso(connessione: string): Player | null;
29
+ puoAscoltare(listener: string, speakers: string[]): EsitoAscolto[];
30
+ puoEntrare(identity: IdentitaGiocatore): EsitoIngresso;
31
+ entra(identity: IdentitaGiocatore, connessione: string): Promise<EsitoIngresso>;
32
+ disconnetti(connessione: string): Promise<void>;
33
+ ricevi(connessione: string, frame: string): Promise<void>;
34
+ eseguiTick(): Promise<void>;
35
+ sveglia(): Promise<void>;
36
+ flush(): Promise<EsitoFlush>;
37
+ private riconciliaConnessioni;
38
+ private ruoloAutomatico;
39
+ private squadraAutomatica;
40
+ private inLobby;
41
+ private cambiaRuolo;
42
+ private cambiaSquadra;
43
+ private impostaRuoloDalServer;
44
+ private impostaSquadraDalServer;
45
+ private giocatorePerModificaDalServer;
46
+ private erroreMinimi;
47
+ private avviaCountdown;
48
+ private verificaCountdown;
49
+ private messaggioErrato;
50
+ private chiudiConnessione;
51
+ private rimuoviGiocatore;
52
+ private assegnaHost;
53
+ private eseguiTimer;
54
+ private pianifica;
55
+ private accodaPunteggio;
56
+ private richiediFine;
57
+ private salva;
58
+ private caricaSave;
59
+ private verificaChiaveDeposito;
60
+ private verificaPrefissoDeposito;
61
+ private contaOperazioneDeposito;
62
+ private usaDeposito;
63
+ private leggiDeposito;
64
+ private scriviDeposito;
65
+ private eliminaDeposito;
66
+ private elencaDeposito;
67
+ private incrementaDeposito;
68
+ private broadcastCreatore;
69
+ private inviaCreatore;
70
+ private broadcast;
71
+ private inviaErrore;
72
+ private giocatoriProtocollo;
73
+ private inviaWelcome;
74
+ private stanzaProtocollo;
75
+ private inviaGiocatori;
76
+ private inviaStatus;
77
+ private inviaDiff;
78
+ private inviaSnapshotTutti;
79
+ private chiama;
80
+ private applicaAzioni;
81
+ private concludiEvento;
82
+ private verificaStato;
83
+ private impostaGuadagno;
84
+ private salvaGuadagno;
85
+ private creaCambiVoce;
86
+ private rivediVoce;
87
+ private inviaGuadagniCambiati;
88
+ private pulisciGuadagni;
89
+ private terminaPerStato;
90
+ private terminaInterna;
91
+ private registraCpu;
92
+ private persisti;
93
+ private persistiEProgramma;
94
+ private serveTick;
95
+ private terminaSeInattiva;
96
+ private aggiornaProgrammazione;
97
+ }
@@ -0,0 +1,134 @@
1
+ import type { JsonValue, RoomStatus, SharedGameStore } from '../server/index.js';
2
+ import type { MessaggioServerStanza } from '../protocollo.js';
3
+ export interface ManifestStanza {
4
+ id: string;
5
+ players: {
6
+ min: number;
7
+ max: number;
8
+ };
9
+ lobby: boolean;
10
+ persistent?: boolean;
11
+ roles: Array<{
12
+ id: string;
13
+ min: number;
14
+ max?: number;
15
+ }>;
16
+ teams: {
17
+ min: number;
18
+ max: number;
19
+ } | null;
20
+ modes: Array<{
21
+ id: string;
22
+ execution?: 'local' | 'room';
23
+ players?: {
24
+ min: number;
25
+ max: number;
26
+ };
27
+ lobby?: boolean;
28
+ }>;
29
+ voice?: 'none' | 'room' | 'team' | 'proximity';
30
+ }
31
+ export interface ArchivioStanza {
32
+ get<T>(key: string): Promise<T | undefined>;
33
+ put(key: string, value: unknown): Promise<void>;
34
+ delete(key: string): Promise<void>;
35
+ list(prefix?: string): Promise<Map<string, unknown>>;
36
+ }
37
+ export type DepositoCondiviso = SharedGameStore;
38
+ export interface AdattatoreStanza {
39
+ readonly storage: ArchivioStanza;
40
+ readonly deposito: DepositoCondiviso | null;
41
+ invia(connessione: string, messaggio: MessaggioServerStanza): void;
42
+ pubblica(messaggio: MessaggioServerStanza): void;
43
+ chiudi(connessione: string, codice: number, motivo: string): void;
44
+ connessioniAttive(): readonly string[];
45
+ ora(): number;
46
+ misuraCpu(): number;
47
+ rivediVoce(): void;
48
+ programmaTick(intervalloMs: number | null): void;
49
+ programmaSveglia(ora: number | null): Promise<void>;
50
+ }
51
+ export interface IdentitaGiocatore {
52
+ id: string;
53
+ name: string;
54
+ guest: boolean;
55
+ }
56
+ export interface GiocatorePersistito extends IdentitaGiocatore {
57
+ role: string | null;
58
+ team: number | null;
59
+ ready: boolean;
60
+ connected: boolean;
61
+ entratoAt: number;
62
+ graziaFinoA: number | null;
63
+ connessione: string | null;
64
+ seq: number;
65
+ }
66
+ export interface TimerPersistito {
67
+ id: number;
68
+ at: number;
69
+ handler: string;
70
+ payload: JsonValue;
71
+ }
72
+ export interface PunteggioPersistito {
73
+ playerId: string;
74
+ board: string;
75
+ score: number;
76
+ daily: boolean;
77
+ day?: string | null;
78
+ submittedAt?: number;
79
+ }
80
+ export interface FinePersistita {
81
+ result: JsonValue;
82
+ at: number;
83
+ }
84
+ export interface StatoPersistito {
85
+ versione: 1;
86
+ id: string;
87
+ mode: string | null;
88
+ status: RoomStatus;
89
+ tick: number;
90
+ tickRate: number;
91
+ ultimoInputAt: number;
92
+ ultimoCambioStatoAt: number;
93
+ state: JsonValue;
94
+ giocatori: GiocatorePersistito[];
95
+ hostId: string | null;
96
+ result: JsonValue | null;
97
+ resultAt: number | null;
98
+ countdownAt: number | null;
99
+ timer: TimerPersistito[];
100
+ prossimoTimerId: number;
101
+ punteggi: PunteggioPersistito[];
102
+ fineInCoda: FinePersistita | null;
103
+ vuotaDa: number | null;
104
+ cancellaDopoFlush: boolean;
105
+ tickSincronizzato: number;
106
+ statoSincronizzato: JsonValue;
107
+ durateCpu: number[];
108
+ cpuOltreCento: number;
109
+ voceGuadagni?: Record<string, Record<string, number>>;
110
+ }
111
+ export type EsitoIngresso = {
112
+ ok: true;
113
+ } | {
114
+ ok: false;
115
+ code: 'room_not_found' | 'room_full' | 'room_ended' | 'room_playing';
116
+ };
117
+ export type EsitoAscolto = {
118
+ ok: true;
119
+ } | {
120
+ ok: false;
121
+ reason: 'mode' | 'unknown' | 'team' | 'gain';
122
+ };
123
+ export interface InfoStanza {
124
+ roomId: string;
125
+ status: RoomStatus;
126
+ players: number;
127
+ max: number;
128
+ mode: string | null;
129
+ member: boolean;
130
+ }
131
+ export interface EsitoFlush {
132
+ scores: PunteggioPersistito[];
133
+ ended: FinePersistita | null;
134
+ }
@@ -0,0 +1,24 @@
1
+ import type { Rooms } from '../index.js';
2
+ import type { GestoreBiglietto } from '../handshake.js';
3
+ import { type DipendenzeVoce } from '../voce/index.js';
4
+ interface TimerStanza {
5
+ setTimeout(handler: () => void, timeout: number): number;
6
+ clearTimeout(id: number): void;
7
+ setInterval(handler: () => void, timeout: number): number;
8
+ clearInterval(id: number): void;
9
+ }
10
+ export interface DipendenzeStanze extends TimerStanza {
11
+ appOrigin: string;
12
+ liveOrigin: string;
13
+ fetcher: typeof fetch;
14
+ biglietto: GestoreBiglietto;
15
+ apriSocket(url: string): WebSocket;
16
+ ora(): number;
17
+ voce?: DipendenzeVoce;
18
+ segnalaStanza?(room: {
19
+ code: string;
20
+ } | null): void;
21
+ }
22
+ export declare function creaStanzeOffline(invited?: string | null): Rooms;
23
+ export declare function creaGestoreStanze(input: DipendenzeStanze, invited: string | null): Rooms;
24
+ export {};
@@ -0,0 +1,124 @@
1
+ import type { RoomPlayer, Voice, VoiceMode, VoicePeer, VoiceState } from '../index.js';
2
+ import type { MessaggioClientVoce, MessaggioServerVoce } from '../protocollo.js';
3
+ export interface DipendenzeVoce {
4
+ creaPeerConnection(configuration?: RTCConfiguration): RTCPeerConnection;
5
+ getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
6
+ creaAudioContext(): AudioContext;
7
+ creaAudioElement(): HTMLAudioElement;
8
+ creaMediaStream(tracks: MediaStreamTrack[]): MediaStream;
9
+ ora(): number;
10
+ setTimeout(handler: () => void, timeout: number): number;
11
+ clearTimeout(id: number): void;
12
+ setInterval(handler: () => void, timeout: number): number;
13
+ clearInterval(id: number): void;
14
+ }
15
+ export interface ContestoVoce {
16
+ invia(message: MessaggioClientVoce): void;
17
+ connessa(): boolean;
18
+ you(): string;
19
+ giocatori(): readonly RoomPlayer[];
20
+ rosterPronto(): void;
21
+ }
22
+ export declare class VoceClient implements Voice {
23
+ private readonly contesto;
24
+ private modeCorrente;
25
+ private stateCorrente;
26
+ private mutedCorrente;
27
+ private speakingCorrente;
28
+ private roster;
29
+ private readonly gains;
30
+ private readonly volumi;
31
+ private readonly speakingPeers;
32
+ private readonly ultimoAudio;
33
+ private readonly zeroDa;
34
+ private readonly timerZero;
35
+ private readonly ascoltatoriPeers;
36
+ private readonly ascoltatoriState;
37
+ private readonly richieste;
38
+ private readonly riproduzioni;
39
+ private readonly sfuAttive;
40
+ private readonly midGiocatori;
41
+ private readonly negati;
42
+ private readonly mesh;
43
+ private dipendenze;
44
+ private stream;
45
+ private tracciaMic;
46
+ private audioContext;
47
+ private analyser;
48
+ private peerSfu;
49
+ private sessioneSfu;
50
+ private connessioneSfuAttesa;
51
+ private trasporto;
52
+ private intervalloAudio;
53
+ private timerConnessione;
54
+ private cancellaAttesaConnessione;
55
+ private timerRiconnessione;
56
+ private ultimoAudioMic;
57
+ private sequenzaRichieste;
58
+ private generazione;
59
+ private tentativoRiconnessione;
60
+ private desiderata;
61
+ private micDesiderato;
62
+ private promessaIngresso;
63
+ private negoziazione;
64
+ constructor(contesto: ContestoVoce, timer: Pick<DipendenzeVoce, 'ora' | 'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval'>, dipendenze?: DipendenzeVoce);
65
+ get mode(): VoiceMode;
66
+ get state(): VoiceState;
67
+ get mic(): boolean;
68
+ get muted(): boolean;
69
+ get speaking(): boolean;
70
+ get peers(): readonly VoicePeer[];
71
+ join(options?: {
72
+ mic?: boolean;
73
+ }): Promise<void>;
74
+ private completaIngresso;
75
+ leave(): void;
76
+ mute(muted?: boolean): void;
77
+ setVolume(playerId: string, volume: number): void;
78
+ onPeers(listener: (peers: readonly VoicePeer[]) => void): () => void;
79
+ onState(listener: (state: VoiceState) => void): () => void;
80
+ ricevi(message: MessaggioServerVoce): void;
81
+ giocatoriCambiati(): void;
82
+ socketDisconnesso(): void;
83
+ socketRiconnesso(): void;
84
+ termina(): void;
85
+ private scegliMic;
86
+ private verificaIngresso;
87
+ private entra;
88
+ private entraSfu;
89
+ private attendiConnessione;
90
+ private accodaRiconciliazione;
91
+ private riconciliaSfu;
92
+ private riconciliaMesh;
93
+ private creaMesh;
94
+ private offriMesh;
95
+ private riceviSegnale;
96
+ private inviaSegnale;
97
+ private peerDesiderati;
98
+ private publisherDesiderati;
99
+ private aggiornaZero;
100
+ private collegaTraccia;
101
+ private scollegaTraccia;
102
+ private aggiornaGuadagno;
103
+ private preparaAnalizzatore;
104
+ private avviaMisuraAudio;
105
+ private misuraAudio;
106
+ private livelloAnalizzatore;
107
+ private copiaPeers;
108
+ private pulisciPeerAssenti;
109
+ private osservaCaduta;
110
+ private avviaRiconnessione;
111
+ private programmaRiconnessione;
112
+ private fermaRiconnessione;
113
+ private chiudiRisorse;
114
+ private richiedi;
115
+ private rifiutaRichieste;
116
+ private aggiornaState;
117
+ private notificaPeers;
118
+ private controllaGenerazione;
119
+ private richiediDipendenze;
120
+ private richiediMic;
121
+ private richiediAudioContext;
122
+ private permessoNegato;
123
+ private mappaErrore;
124
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caisual/kit",
3
- "version": "0.4.0",
3
+ "version": "0.8.0",
4
4
  "description": "Client and server kit for Caisual games",
5
5
  "type": "module",
6
6
  "files": [
@@ -11,7 +11,10 @@
11
11
  "dist/runtime.js",
12
12
  "dist/runtime.d.ts",
13
13
  "dist/node.js",
14
- "dist/node.d.ts"
14
+ "dist/node.d.ts",
15
+ "dist/overlay.js",
16
+ "dist/overlay.d.ts",
17
+ "dist/types"
15
18
  ],
16
19
  "exports": {
17
20
  ".": {
@@ -33,6 +36,11 @@
33
36
  "types": "./dist/node.d.ts",
34
37
  "import": "./dist/node.js",
35
38
  "default": "./dist/node.js"
39
+ },
40
+ "./overlay": {
41
+ "types": "./dist/overlay.d.ts",
42
+ "import": "./dist/overlay.js",
43
+ "default": "./dist/overlay.js"
36
44
  }
37
45
  },
38
46
  "types": "./dist/kit.d.ts",