@caisual/kit 0.8.0 → 0.10.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/dist/kit.js +407 -45
- package/dist/node.js +230 -69
- package/dist/overlay.js +260 -32
- package/dist/runtime.js +179 -39
- package/dist/server.js +2 -0
- package/dist/types/api.d.ts +1 -1
- package/dist/types/contracts/i18n.d.ts +12 -0
- package/dist/types/contracts/index.d.ts +3 -0
- package/dist/types/contracts/manifest.d.ts +10 -5
- package/dist/types/contracts/overlay.d.ts +9 -1
- package/dist/types/contracts/player.d.ts +1 -0
- package/dist/types/contracts/room-limits.d.ts +13 -0
- package/dist/types/handshake.d.ts +4 -0
- package/dist/types/index.d.ts +16 -2
- package/dist/types/kit.d.ts +2 -0
- package/dist/types/node/index.d.ts +1 -0
- package/dist/types/overlay/host-bridge.d.ts +16 -0
- package/dist/types/overlay/i18n.d.ts +6 -0
- package/dist/types/overlay/index.d.ts +1 -0
- package/dist/types/overlay/styles.d.ts +1 -1
- package/dist/types/overlay/ui.d.ts +1 -1
- package/dist/types/protocollo.d.ts +5 -0
- package/dist/types/runtime/index.d.ts +2 -1
- package/dist/types/server/index.d.ts +6 -2
- package/dist/types/stanza/nucleo.d.ts +5 -2
- package/dist/types/stanza/tipi.d.ts +2 -0
- package/dist/types/text.d.ts +2 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Text } from './text.js';
|
|
2
|
+
export type { Text } from './text.js';
|
|
1
3
|
import type { ConnectionState, QueuedScore } from './contracts/index.js';
|
|
2
4
|
import type { Session, Overlay } from './session/index.js';
|
|
3
5
|
import type { RoomConfiguration } from './protocollo.js';
|
|
@@ -9,6 +11,8 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
|
9
11
|
[key: string]: JsonValue;
|
|
10
12
|
};
|
|
11
13
|
export interface Player {
|
|
14
|
+
language: string;
|
|
15
|
+
uiLanguage: string;
|
|
12
16
|
id: string;
|
|
13
17
|
name: string;
|
|
14
18
|
guest: boolean;
|
|
@@ -47,7 +51,7 @@ export type BoardOffline = {
|
|
|
47
51
|
reason: 'offline';
|
|
48
52
|
verified: false;
|
|
49
53
|
};
|
|
50
|
-
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'ended';
|
|
54
|
+
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
|
|
51
55
|
export interface RoomPlayer {
|
|
52
56
|
id: string;
|
|
53
57
|
name: string;
|
|
@@ -105,6 +109,8 @@ export interface Room {
|
|
|
105
109
|
disconnect(): void;
|
|
106
110
|
readonly state: JsonValue;
|
|
107
111
|
readonly tick: number;
|
|
112
|
+
readonly tickRate: number;
|
|
113
|
+
readonly latency: number | null;
|
|
108
114
|
readonly seed: number;
|
|
109
115
|
readonly status: RoomStatus;
|
|
110
116
|
readonly players: readonly RoomPlayer[];
|
|
@@ -126,10 +132,12 @@ export interface Room {
|
|
|
126
132
|
onStatus(listener: (status: RoomStatus, result: JsonValue, at: number) => void): () => void;
|
|
127
133
|
onMessage(listener: (message: JsonValue) => void): () => void;
|
|
128
134
|
send(message: JsonValue): void;
|
|
135
|
+
input(value: JsonValue): void;
|
|
129
136
|
ready(ready: boolean): void;
|
|
130
137
|
setRole(role: string): void;
|
|
131
138
|
setTeam(team: number): void;
|
|
132
139
|
start(): void;
|
|
140
|
+
restart(): void;
|
|
133
141
|
leave(): void;
|
|
134
142
|
serverTime(): number;
|
|
135
143
|
}
|
|
@@ -143,6 +151,8 @@ export interface Spectate {
|
|
|
143
151
|
disconnect(): void;
|
|
144
152
|
readonly state: JsonValue;
|
|
145
153
|
readonly tick: number;
|
|
154
|
+
readonly tickRate: number;
|
|
155
|
+
readonly latency: number | null;
|
|
146
156
|
readonly seed: number;
|
|
147
157
|
readonly status: RoomStatus;
|
|
148
158
|
readonly players: readonly RoomPlayer[];
|
|
@@ -177,6 +187,7 @@ export interface Rooms {
|
|
|
177
187
|
match(options: MatchOptions): Promise<Room>;
|
|
178
188
|
}
|
|
179
189
|
export interface CaisualConnection {
|
|
190
|
+
text(): Promise<Text>;
|
|
180
191
|
session: Session;
|
|
181
192
|
overlay: Overlay;
|
|
182
193
|
connected: boolean;
|
|
@@ -186,6 +197,7 @@ export interface CaisualConnection {
|
|
|
186
197
|
day: string;
|
|
187
198
|
seed: number;
|
|
188
199
|
random(): number;
|
|
200
|
+
rng(): () => number;
|
|
189
201
|
};
|
|
190
202
|
time: {
|
|
191
203
|
now(): number;
|
|
@@ -209,7 +221,9 @@ export interface CaisualConnection {
|
|
|
209
221
|
};
|
|
210
222
|
room: Rooms;
|
|
211
223
|
}
|
|
212
|
-
export type BaseConnection = Omit<CaisualConnection, 'device' | 'session' | 'overlay'
|
|
224
|
+
export type BaseConnection = Omit<CaisualConnection, 'device' | 'session' | 'overlay' | 'text' | 'player'> & {
|
|
225
|
+
player: Omit<Player, 'language' | 'uiLanguage'>;
|
|
226
|
+
};
|
|
213
227
|
export interface Caisual {
|
|
214
228
|
connect(): Promise<CaisualConnection>;
|
|
215
229
|
}
|
package/dist/types/kit.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface HostBridgeInput {
|
|
|
20
20
|
frame: FrameHandshake;
|
|
21
21
|
origineGioco: string;
|
|
22
22
|
origineLive: string;
|
|
23
|
+
language?: string;
|
|
24
|
+
languagePreferences?: readonly string[];
|
|
23
25
|
invite: string | null;
|
|
24
26
|
ticket: string;
|
|
25
27
|
configuration?: OverlayConfiguration;
|
|
@@ -56,3 +58,17 @@ export declare function creaPonteOspite(input: HostBridgeInput): {
|
|
|
56
58
|
};
|
|
57
59
|
export type HostBridge = ReturnType<typeof creaPonteOspite>;
|
|
58
60
|
export declare function avviaHandshake(input: HostBridgeInput): () => void;
|
|
61
|
+
export declare function gameViewport(frame: HTMLIFrameElement): {
|
|
62
|
+
left: number;
|
|
63
|
+
top: number;
|
|
64
|
+
right: number;
|
|
65
|
+
bottom: number;
|
|
66
|
+
scaleX: number;
|
|
67
|
+
scaleY: number;
|
|
68
|
+
};
|
|
69
|
+
export declare function measureSafeArea(frame: HTMLIFrameElement, probe: HTMLElement): {
|
|
70
|
+
top: number;
|
|
71
|
+
right: number;
|
|
72
|
+
bottom: number;
|
|
73
|
+
left: number;
|
|
74
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare const languages: readonly ['en', 'it', 'es', 'fr', 'de', 'pt'];
|
|
2
2
|
export type OverlayLanguage = typeof languages[number];
|
|
3
3
|
declare const words: {
|
|
4
|
+
readonly gameLanguages: readonly ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo"];
|
|
4
5
|
readonly loading: readonly ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando..."];
|
|
6
|
+
readonly loadingSlow: readonly ["This game is taking longer than expected. You can wait a little longer or try again.", "Il gioco ci sta mettendo più del previsto. Puoi aspettare ancora un po’ o riprovare.", "El juego está tardando más de lo esperado. Puedes esperar un poco más o volver a intentarlo.", "Le jeu met plus de temps que prévu. Vous pouvez patienter encore un peu ou réessayer.", "Das Spiel braucht länger als erwartet. Du kannst noch etwas warten oder es erneut versuchen.", "O jogo está demorando mais do que o esperado. Você pode esperar mais um pouco ou tentar novamente."];
|
|
5
7
|
readonly home: readonly ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar"];
|
|
8
|
+
readonly homeMenu: readonly ["Menu", "Menu", "Menú", "Menu", "Menü", "Menu"];
|
|
6
9
|
readonly mode: readonly ["Mode", "Modalità", "Modo", "Mode", "Modus", "Modo"];
|
|
7
10
|
readonly play: readonly ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar"];
|
|
8
11
|
readonly friendsPlay: readonly ["Play with friends", "Gioca con amici", "Jugar con amigos", "Jouer entre amis", "Mit Freunden spielen", "Jogar com amigos"];
|
|
@@ -38,6 +41,8 @@ declare const words: {
|
|
|
38
41
|
readonly starting: readonly ["Starting in", "Si inizia tra", "Empieza en", "Début dans", "Start in", "Começa em"];
|
|
39
42
|
readonly playing: readonly ["Playing", "In partita", "Jugando", "En jeu", "Im Spiel", "Jogando"];
|
|
40
43
|
readonly ended: readonly ["Game finished", "Partita conclusa", "Partida terminada", "Partie terminée", "Spiel beendet", "Partida encerrada"];
|
|
44
|
+
readonly rematchReady: readonly ["{n}/{max} ready", "{n}/{max} pronti", "{n}/{max} listos", "{n}/{max} prêts", "{n}/{max} bereit", "{n}/{max} prontos"];
|
|
45
|
+
readonly rematchStart: readonly ["Start rematch", "Avvia rivincita", "Iniciar revancha", "Lancer la revanche", "Revanche starten", "Iniciar revanche"];
|
|
41
46
|
readonly again: readonly ["Play again", "Gioca ancora", "Jugar de nuevo", "Rejouer", "Erneut spielen", "Jogar novamente"];
|
|
42
47
|
readonly newRoom: readonly ["New room. Share the new invite.", "Nuova stanza. Condividi il nuovo invito.", "Nueva sala. Comparte la invitación.", "Nouvelle salle. Partagez le lien.", "Neuer Raum. Neue Einladung teilen.", "Nova sala. Compartilhe o convite."];
|
|
43
48
|
readonly watching: readonly ["Watching", "In osservazione", "Observando", "Spectateur", "Zuschauen", "Assistindo"];
|
|
@@ -117,6 +122,7 @@ export type TextKey = keyof typeof words;
|
|
|
117
122
|
export type Dictionary = Record<TextKey, string>;
|
|
118
123
|
export declare const dictionaries: Record<OverlayLanguage, Dictionary>;
|
|
119
124
|
export declare function overlayLanguage(raw: string | null | undefined): OverlayLanguage;
|
|
125
|
+
export declare function overlayLocale(raw: string | null | undefined): string;
|
|
120
126
|
export declare function translator(language: string): (key: TextKey, values?: Record<string, string | number>) => string;
|
|
121
127
|
export declare function errorText(code: string): TextKey;
|
|
122
128
|
export {};
|
|
@@ -7,3 +7,4 @@ export type { MountOverlayInput, OverlayCrew, CrewSnapshot } from './ui.js';
|
|
|
7
7
|
export type { BoardReader, BoardQuery, BoardData } from './boards.js';
|
|
8
8
|
export { overlayLanguage } from './i18n.js';
|
|
9
9
|
export { styles as overlayStyles } from './styles.js';
|
|
10
|
+
export { overlayLocale } from './i18n.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const styles = "\n:host{all:initial;position:fixed;inset:0;z-index:10000;pointer-events:none;font:15px/1.45 system-ui,sans-serif;color:#f4f4f1;color-scheme:dark;--accent:#a8efc5}\n[data-layout],[data-surface],.sr{pointer-events:none}*{box-sizing:border-box}button,input,select{font:inherit}button,a,input,select{touch-action:manipulation}button,select,input{border:1px solid #ffffff30;background:#25292b;color:inherit;border-radius:12px;min-height:44px;padding:10px 14px}button{cursor:pointer}button:disabled{opacity:.45;cursor:default}button:hover:not(:disabled){background:#343b3a}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid var(--accent);outline-offset:3px}a{color:var(--accent)}.primary{background:var(--accent);color:var(--accent-ink,#11221b);border-color:transparent;font-weight:700}.primary:hover:not(:disabled){filter:brightness(1.1);background:var(--accent)}.quiet{background:transparent}label{display:grid;gap:6px;text-align:left}select,input{width:100%;min-width:0}h1,h2,p{margin:0}h1{font-size:clamp(26px,5vw,42px);line-height:1.1;letter-spacing:-.035em}h2{font-size:20px}small,.muted{color:#bdc5c1}.stack{display:grid;gap:16px}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.row>*{flex:0 1 auto}.row .grow,.grow{flex:1}.split{display:grid;grid-template-columns:1fr 1fr;gap:10px}.pill{position:absolute;top:max(10px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));display:flex;height:44px;border:1px solid #ffffff35;border-radius:24px;background:#171e20eF;box-shadow:0 4px 20px #0004;pointer-events:auto;overflow:hidden}.pill button{border:0;border-radius:0;padding:8px 13px;background:transparent}.pill
|
|
1
|
+
export declare const styles = "\n.safe-area-probe{position:fixed;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)}\n:host{all:initial;position:fixed;inset:0;z-index:10000;pointer-events:none;font:15px/1.45 system-ui,sans-serif;color:#f4f4f1;color-scheme:dark;--accent:#a8efc5}\n[data-layout],[data-surface],.sr{pointer-events:none}*{box-sizing:border-box}button,input,select{font:inherit}button,a,input,select{touch-action:manipulation}button,select,input{border:1px solid #ffffff30;background:#25292b;color:inherit;border-radius:12px;min-height:44px;padding:10px 14px}button{cursor:pointer}button:disabled{opacity:.45;cursor:default}button:hover:not(:disabled){background:#343b3a}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid var(--accent);outline-offset:3px}a{color:var(--accent)}.primary{background:var(--accent);color:var(--accent-ink,#11221b);border-color:transparent;font-weight:700}.primary:hover:not(:disabled){filter:brightness(1.1);background:var(--accent)}.quiet{background:transparent}label{display:grid;gap:6px;text-align:left}select,input{width:100%;min-width:0}h1,h2,p{margin:0}h1{font-size:clamp(26px,5vw,42px);line-height:1.1;letter-spacing:-.035em}h2{font-size:20px}small,.muted{color:#bdc5c1}.stack{display:grid;gap:16px}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.row>*{flex:0 1 auto}.row .grow,.grow{flex:1}.split{display:grid;grid-template-columns:1fr 1fr;gap:10px}.pill{position:absolute;top:max(10px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));display:flex;height:44px;border:1px solid #ffffff35;border-radius:24px;background:#171e20eF;box-shadow:0 4px 20px #0004;pointer-events:auto;overflow:hidden}.pill button{border:0;border-radius:0;padding:8px 13px;background:transparent}.pill button:focus-visible{outline-offset:-4px}.pill small{margin-left:8px}.backdrop{position:absolute;inset:0;background:#0b151ce8;backdrop-filter:blur(10px);pointer-events:auto;display:grid;place-items:center;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));overflow:auto}.backdrop.home{background-color:#142127;background-size:cover;background-position:center}.dialog{position:relative;width:min(100%,540px);max-height:100%;overflow:auto;overscroll-behavior:contain;background:#141b1df5;border:1px solid #ffffff25;border-radius:22px;padding:24px;box-shadow:0 20px 80px #0005}.dialog.wide{width:min(100%,700px)}.top{display:flex;align-items:center;gap:12px;margin-bottom:18px}.top h2{flex:1}.tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid #ffffff25;padding-bottom:12px}.tabs button{min-height:36px;padding:6px 10px}.tabs [aria-current=true]{border-color:var(--accent)}.roster{list-style:none;padding:0;margin:0;display:grid;gap:8px;max-height:32dvh;overflow:auto}.roster li{display:flex;align-items:center;gap:8px;padding:10px;background:#ffffff08;border-radius:10px}.roster .name{flex:1;overflow-wrap:anywhere}.badge{border:1px solid #ffffff30;border-radius:6px;padding:2px 6px;font-size:12px}.code{font-size:24px;letter-spacing:.13em;font-variant-numeric:tabular-nums}.notice,.error{border-radius:10px;padding:10px;background:#a8efc514;overflow-wrap:anywhere}.error{background:#ff8b7720;color:#ffd2c9}.countdown{font-size:88px;line-height:1;text-align:center;font-variant-numeric:tabular-nums}.ended{position:absolute;bottom:max(12px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);max-width:calc(100% - 24px);width:max-content;background:#171e20f5;pointer-events:auto;border:1px solid #ffffff30;border-radius:16px;padding:10px;display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap}.ended [data-rematch-players]{max-width:100%;max-height:3.2em;overflow:auto;overflow-wrap:anywhere}.ended strong{padding:0 8px}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.table-wrap{overflow:auto;max-height:38dvh}table{width:100%;border-collapse:collapse;text-align:left}th,td{padding:9px 6px;border-bottom:1px solid #ffffff20}td:nth-child(3){text-align:right}td small{display:block}.self{background:#ffffff0a}.checkbox{display:flex;align-items:center;gap:8px;font-size:13px}.checkbox input{width:18px;min-height:18px}.full{width:100%}\n[hidden]{display:none!important}.voice-peers{list-style:none;margin:0;padding:0;display:grid;gap:10px}.voice-peers li{border:1px solid #ffffff25;border-radius:12px;padding:12px;display:grid;gap:8px}.voice-peers [data-speaking=true]{border-color:var(--accent)}.voice-peers input{width:100%;accent-color:var(--accent);padding:0}.voice-peers label{font-size:13px}.pill .voice-toggle{width:44px;padding:8px}.voice-toggle[data-voice-state=on][data-muted=false]{color:var(--accent)}\n.boot{position:absolute;inset:0;z-index:2;isolation:isolate;display:grid;place-items:center;overflow:auto;overscroll-behavior:contain;padding:max(100px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(48px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));background:#0b151c;opacity:1;transition:opacity .4s ease;pointer-events:auto;outline:none}\n.boot::before,.boot::after{content:\"\";position:fixed;inset:0;pointer-events:none;z-index:-1}.boot::before{background:radial-gradient(ellipse at 50% 38%,color-mix(in srgb,var(--accent),transparent 80%),transparent 65%)}.boot::after{background:radial-gradient(ellipse at 50% 38%,#0b151c20,#0b151cd9 85%),linear-gradient(#0b151c66,#0b151cbf)}\n.boot-cover{position:fixed;inset:0;z-index:-2;width:100%;height:100%;object-fit:cover;filter:blur(20px);transform:scale(1.08);opacity:.65;pointer-events:none}\n.boot-brand{position:absolute;top:max(28px,env(safe-area-inset-top));left:max(32px,env(safe-area-inset-left));display:flex;align-items:center;gap:10px;font-size:14px;font-weight:650;letter-spacing:.02em;color:#f4f4f1b3}.boot-brand span{display:grid;place-items:center;width:36px;height:36px;border:1px solid #ffffff25;border-radius:12px;background:#171e20af;box-shadow:0 4px 20px #0004;color:var(--boot-accent);font-size:20px;font-weight:800}\n.boot-content{width:min(100%,900px);text-align:center;display:grid;justify-items:center;gap:24px}.boot h1{max-width:16ch;font-size:clamp(44px,8vw,108px);font-weight:800;line-height:1.04;letter-spacing:-.05em;overflow-wrap:anywhere;text-wrap:balance;color:var(--boot-accent);text-shadow:0 20px 80px #0005}\n.boot-progress{width:112px;height:3px;border-radius:12px;background:#ffffff20;overflow:hidden;margin-top:12px}.boot-progress span{display:block;width:44%;height:100%;border-radius:inherit;background:var(--boot-accent);animation:boot-progress 1.8s ease-in-out infinite}.boot-status{max-width:42ch;min-height:3em;font-size:14px;line-height:1.5;color:#d3dad6;text-wrap:balance}.boot-recovery{min-height:44px}.boot-recovery .row{justify-content:center}.boot-leaving{opacity:0;pointer-events:none}\n@keyframes boot-progress{0%{transform:translateX(-110%)}100%{transform:translateX(340%)}}\n@media(max-width:480px){.dialog{padding:18px;border-radius:18px}.split{grid-template-columns:1fr 1fr;gap:8px}.tabs{gap:4px}.tabs button{font-size:13px;padding:6px 8px}.pill button:focus-visible{outline-offset:-4px}.pill small{display:none}.ended{gap:6px}.ended strong{font-size:13px}.ended button{padding:8px 10px;font-size:13px}.roster{max-height:28dvh}}\n@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto}.boot{transition:none}.boot-progress span{animation:none;transform:translateX(65%)}}\n";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OverlayConfiguration } from '../contracts/index.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type HostBridge } from './host-bridge.js';
|
|
3
3
|
import { type BoardReader } from './boards.js';
|
|
4
4
|
export interface CrewPerson {
|
|
5
5
|
id: string;
|
|
@@ -41,6 +41,7 @@ export interface RoomConfiguration {
|
|
|
41
41
|
requestRole: boolean;
|
|
42
42
|
}
|
|
43
43
|
export interface StanzaProtocollo {
|
|
44
|
+
result?: JsonValue;
|
|
44
45
|
countdownAt?: number | null;
|
|
45
46
|
configuration?: RoomConfiguration;
|
|
46
47
|
id: string;
|
|
@@ -187,6 +188,8 @@ export type MessaggioClientStanza = MessaggioClientVoce | {
|
|
|
187
188
|
team: number;
|
|
188
189
|
} | {
|
|
189
190
|
t: 'start';
|
|
191
|
+
} | {
|
|
192
|
+
t: 'restart';
|
|
190
193
|
} | {
|
|
191
194
|
t: 'msg';
|
|
192
195
|
seq: number;
|
|
@@ -226,12 +229,14 @@ export type MessaggioServerStanza = {
|
|
|
226
229
|
host?: string | null;
|
|
227
230
|
} | {
|
|
228
231
|
t: 'state';
|
|
232
|
+
tickRate?: number;
|
|
229
233
|
tick: number;
|
|
230
234
|
serverTime: number;
|
|
231
235
|
base: number;
|
|
232
236
|
patch: OperazioneDiff[];
|
|
233
237
|
} | {
|
|
234
238
|
t: 'snapshot';
|
|
239
|
+
tickRate?: number;
|
|
235
240
|
tick: number;
|
|
236
241
|
serverTime: number;
|
|
237
242
|
state: JsonValue;
|
|
@@ -96,8 +96,9 @@ export interface FacetStanza {
|
|
|
96
96
|
puoEntrare(identita: IdentitaGiocatore): Promise<EsitoIngresso>;
|
|
97
97
|
puoAscoltare(listener: string, speakers: string[]): Promise<EsitoAscolto[]>;
|
|
98
98
|
entra(identita: IdentitaGiocatore, connessione: string): Promise<Esito>;
|
|
99
|
-
ricevi(connessione: string, testo: string): Promise<Esito>;
|
|
99
|
+
ricevi(connessione: string, testo: string, limiteVerificato?: boolean): Promise<Esito>;
|
|
100
100
|
disconnetti(connessione: string): Promise<Esito>;
|
|
101
|
+
riconciliaConnessioni(connessioni: string[]): Promise<Esito>;
|
|
101
102
|
tick(): Promise<Esito>;
|
|
102
103
|
sveglia(): Promise<Esito>;
|
|
103
104
|
flush(): Promise<EsitoFlush>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
2
2
|
[key: string]: JsonValue;
|
|
3
3
|
};
|
|
4
|
-
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'ended';
|
|
4
|
+
export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'finished' | 'ended';
|
|
5
5
|
export type VoiceMode = 'none' | 'room' | 'team' | 'proximity';
|
|
6
6
|
export type LeaveReason = 'left' | 'timeout' | 'kicked';
|
|
7
7
|
export interface SharedGameStore {
|
|
@@ -35,7 +35,9 @@ export interface Room<State extends JsonValue = JsonValue> {
|
|
|
35
35
|
kick(player: Player | string): void;
|
|
36
36
|
setRole(player: Player | string, role: string): void;
|
|
37
37
|
setTeam(player: Player | string, team: number): void;
|
|
38
|
-
end(result: JsonValue
|
|
38
|
+
end(result: JsonValue, options?: {
|
|
39
|
+
rematch?: boolean;
|
|
40
|
+
}): void;
|
|
39
41
|
save(key: string, value: JsonValue): Promise<void>;
|
|
40
42
|
load(key: string): Promise<JsonValue | null>;
|
|
41
43
|
readonly shared: SharedGameStore;
|
|
@@ -61,8 +63,10 @@ export interface Room<State extends JsonValue = JsonValue> {
|
|
|
61
63
|
export interface GameDefinition<State extends JsonValue = JsonValue> {
|
|
62
64
|
tickRate: number;
|
|
63
65
|
onCreate?(room: Room<State>): void | Promise<void>;
|
|
66
|
+
onRestart?(room: Room<State>): void | Promise<void>;
|
|
64
67
|
onStart?(room: Room<State>): void | Promise<void>;
|
|
65
68
|
onJoin?(room: Room<State>, player: Player): void | Promise<void>;
|
|
69
|
+
onConnection?(room: Room<State>, player: Player, connected: boolean): void | Promise<void>;
|
|
66
70
|
onLeave?(room: Room<State>, player: Player, reason: LeaveReason): void | Promise<void>;
|
|
67
71
|
onRoleRequest?(room: Room<State>, player: Player, role: string): void | Promise<void>;
|
|
68
72
|
onMessage?(room: Room<State>, player: Player, message: JsonValue): void | Promise<void>;
|
|
@@ -14,6 +14,7 @@ export declare class NucleoStanza {
|
|
|
14
14
|
private fineRichiesta;
|
|
15
15
|
private applicandoAzioni;
|
|
16
16
|
private ultimoStatoOsservato;
|
|
17
|
+
private tickRateSincronizzato;
|
|
17
18
|
private voceDaPersistire;
|
|
18
19
|
private constructor();
|
|
19
20
|
static apri(definizione: unknown, manifest: ManifestStanza, adattatore: AdattatoreStanza): Promise<NucleoStanza>;
|
|
@@ -30,11 +31,11 @@ export declare class NucleoStanza {
|
|
|
30
31
|
puoEntrare(identity: IdentitaGiocatore): EsitoIngresso;
|
|
31
32
|
entra(identity: IdentitaGiocatore, connessione: string): Promise<EsitoIngresso>;
|
|
32
33
|
disconnetti(connessione: string): Promise<void>;
|
|
33
|
-
ricevi(connessione: string, frame: string): Promise<void>;
|
|
34
|
+
ricevi(connessione: string, frame: string, limiteVerificato?: boolean): Promise<void>;
|
|
34
35
|
eseguiTick(): Promise<void>;
|
|
35
36
|
sveglia(): Promise<void>;
|
|
36
37
|
flush(): Promise<EsitoFlush>;
|
|
37
|
-
|
|
38
|
+
riconciliaConnessioni(): Promise<void>;
|
|
38
39
|
private ruoloAutomatico;
|
|
39
40
|
private squadraAutomatica;
|
|
40
41
|
private inLobby;
|
|
@@ -44,6 +45,7 @@ export declare class NucleoStanza {
|
|
|
44
45
|
private impostaSquadraDalServer;
|
|
45
46
|
private giocatorePerModificaDalServer;
|
|
46
47
|
private erroreMinimi;
|
|
48
|
+
private rivincita;
|
|
47
49
|
private avviaCountdown;
|
|
48
50
|
private verificaCountdown;
|
|
49
51
|
private messaggioErrato;
|
|
@@ -52,6 +54,7 @@ export declare class NucleoStanza {
|
|
|
52
54
|
private assegnaHost;
|
|
53
55
|
private eseguiTimer;
|
|
54
56
|
private pianifica;
|
|
57
|
+
private giornata;
|
|
55
58
|
private accodaPunteggio;
|
|
56
59
|
private richiediFine;
|
|
57
60
|
private salva;
|
|
@@ -43,6 +43,7 @@ export interface AdattatoreStanza {
|
|
|
43
43
|
chiudi(connessione: string, codice: number, motivo: string): void;
|
|
44
44
|
connessioniAttive(): readonly string[];
|
|
45
45
|
ora(): number;
|
|
46
|
+
giorno?(ora: number): string;
|
|
46
47
|
misuraCpu(): number;
|
|
47
48
|
rivediVoce(): void;
|
|
48
49
|
programmaTick(intervalloMs: number | null): void;
|
|
@@ -95,6 +96,7 @@ export interface StatoPersistito {
|
|
|
95
96
|
hostId: string | null;
|
|
96
97
|
result: JsonValue | null;
|
|
97
98
|
resultAt: number | null;
|
|
99
|
+
rivincitaFinoA?: number | null;
|
|
98
100
|
countdownAt: number | null;
|
|
99
101
|
timer: TimerPersistito[];
|
|
100
102
|
prossimoTimerId: number;
|