@caisual/kit 0.12.0 → 0.13.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 CHANGED
@@ -1,4 +1,4 @@
1
- // Caisual game kit v0.12.0
1
+ // Caisual game kit v0.13.0
2
2
 
3
3
  // ../contracts/src/slug.ts
4
4
  var NOMI_RISERVATI = [
@@ -801,6 +801,11 @@ async function probeDevice(globals, timeoutMs = 1500) {
801
801
  return { ...report, tier: deviceTier(report) };
802
802
  }
803
803
 
804
+ // ../contracts/src/versioni.ts
805
+ function numeroVersione(value) {
806
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
807
+ }
808
+
804
809
  // ../contracts/src/overlay.ts
805
810
  function overlayConfiguration(manifest, coverUrl = null, invite = null, iconUrl = null) {
806
811
  const validated = validaManifest(manifest);
@@ -913,6 +918,8 @@ function readMatchResult(value, playerIds) {
913
918
  // src/overlay/i18n.ts
914
919
  var languages = ["en", "it", "es", "fr", "de", "pt"];
915
920
  var words = {
921
+ gameUpdated: ["This game was updated", "Questo gioco \xE8 stato aggiornato", "Este juego se ha actualizado", "Ce jeu a \xE9t\xE9 mis \xE0 jour", "Dieses Spiel wurde aktualisiert", "Este jogo foi atualizado"],
922
+ reloadGame: ["Reload game", "Ricarica il gioco", "Recargar el juego", "Recharger le jeu", "Spiel neu laden", "Recarregar o jogo"],
916
923
  gameLanguages: ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo"],
917
924
  loading: ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando..."],
918
925
  loadingSlow: ["This game is taking longer than expected. You can wait a little longer or try again.", "Il gioco ci sta mettendo pi\xF9 del previsto. Puoi aspettare ancora un po\u2019 o riprovare.", "El juego est\xE1 tardando m\xE1s de lo esperado. Puedes esperar un poco m\xE1s o volver a intentarlo.", "Le jeu met plus de temps que pr\xE9vu. Vous pouvez patienter encore un peu ou r\xE9essayer.", "Das Spiel braucht l\xE4nger als erwartet. Du kannst noch etwas warten oder es erneut versuchen.", "O jogo est\xE1 demorando mais do que o esperado. Voc\xEA pode esperar mais um pouco ou tentar novamente."],
@@ -1067,8 +1074,8 @@ function createTextLoader(fetcher, language, pathname = "/") {
1067
1074
  }
1068
1075
 
1069
1076
  // src/errors.ts
1070
- function creaErrore(code, message) {
1071
- return Object.assign(new Error(message), { name: "CaisualError", code });
1077
+ function creaErrore(code, message, version = {}) {
1078
+ return Object.assign(new Error(message), { name: "CaisualError", code, ...version });
1072
1079
  }
1073
1080
  function erroreOffline() {
1074
1081
  return creaErrore("offline", "Caisual services are unavailable.");
@@ -1313,8 +1320,15 @@ function createSession(base, configuration = null, roomsAvailable = base.connect
1313
1320
  }
1314
1321
  }
1315
1322
  const direct = base.room;
1323
+ const stopVersionErrors = direct.onError((error) => {
1324
+ if (!standard || disposed) return;
1325
+ if (error.code === "version_mismatch") direct.reload();
1326
+ else if (error.code === "version_outdated") notify(errorListeners, { sessionId: current.kind === "idle" ? null : current.id, error });
1327
+ });
1316
1328
  const rooms = !standard ? direct : {
1317
1329
  invited: direct.invited,
1330
+ reload: () => direct.reload(),
1331
+ onError: (listener) => direct.onError(listener),
1318
1332
  create(options) {
1319
1333
  if (manifest && modalitaLocale(manifest, options.mode)) return Promise.reject(creaErrore("invalid_request", "Local modes cannot create rooms."));
1320
1334
  return run("attaching", options.mode, () => direct.create(options));
@@ -1527,6 +1541,7 @@ function createSession(base, configuration = null, roomsAvailable = base.connect
1527
1541
  }
1528
1542
  },
1529
1543
  dispose() {
1544
+ stopVersionErrors();
1530
1545
  cancel();
1531
1546
  detach(true);
1532
1547
  disposed = true;
@@ -1635,7 +1650,8 @@ async function leggiErrore(response) {
1635
1650
  }
1636
1651
  return creaErrore(
1637
1652
  typeof corpo.error?.code === "string" ? corpo.error.code : response.status === 401 ? "invalid_ticket" : "internal_error",
1638
- typeof corpo.error?.message === "string" ? corpo.error.message : `The request failed with status ${response.status}.`
1653
+ typeof corpo.error?.message === "string" ? corpo.error.message : `The request failed with status ${response.status}.`,
1654
+ { currentVersion: corpo.error?.currentVersion, roomVersion: corpo.error?.roomVersion }
1639
1655
  );
1640
1656
  }
1641
1657
  function creaRichiedente(origin, prefix, fetcher, biglietto) {
@@ -1840,7 +1856,7 @@ function attendiHandshake(finestra, appOrigin, timeoutMs = 3e3) {
1840
1856
  if (!eTipo(evento.data, "caisual:hello")) return;
1841
1857
  const dati = record2(evento.data);
1842
1858
  const porta = evento.ports[0];
1843
- if (typeof dati?.ticket !== "string" || porta === void 0) return;
1859
+ if (typeof dati?.ticket !== "string" || !numeroVersione(dati.n) || porta === void 0) return;
1844
1860
  porta.start();
1845
1861
  const overlay = normalizeOverlayHello(dati.overlay);
1846
1862
  const tags = (value) => Array.isArray(value) ? value.map(normalizeLanguage).filter((tag) => tag !== null) : void 0;
@@ -1851,6 +1867,7 @@ function attendiHandshake(finestra, appOrigin, timeoutMs = 3e3) {
1851
1867
  languagePreferences: tags(dati.languagePreferences),
1852
1868
  gameLanguages: tags(dati.gameLanguages),
1853
1869
  ticket: dati.ticket,
1870
+ n: dati.n,
1854
1871
  live: leggiOrigine(dati.live),
1855
1872
  invite: typeof dati.invite === "string" ? dati.invite : null,
1856
1873
  porta
@@ -2882,7 +2899,20 @@ function applicaPatch(state, value) {
2882
2899
  return { ok: true, state: risultato };
2883
2900
  }
2884
2901
  function creaApiLive(input) {
2885
- const richiesta = creaRichiedente(input.liveOrigin, "", input.fetcher, input.biglietto);
2902
+ const richiedi = creaRichiedente(input.liveOrigin, "", input.fetcher, input.biglietto);
2903
+ const richiesta = async (path, method, body, renew) => {
2904
+ try {
2905
+ return await richiedi(path, method, { ...record3(body), n: input.n }, renew);
2906
+ } catch (error) {
2907
+ if (error instanceof Error && "code" in error && ["version_outdated", "version_mismatch"].includes(String(error.code))) {
2908
+ const value = record3(body);
2909
+ const code = typeof value?.code === "string" ? value.code.toUpperCase().replace(/[\s-]/g, "") : void 0;
2910
+ const roomId = typeof value?.roomId === "string" ? value.roomId : void 0;
2911
+ input.onVersionError?.(error, error.code === "version_mismatch" ? { code, roomId, watch: path === "/rooms/watch" } : void 0);
2912
+ }
2913
+ throw error;
2914
+ }
2915
+ };
2886
2916
  async function ingresso(path, body, rinnova = false) {
2887
2917
  const value = await richiesta(path, "POST", body, rinnova);
2888
2918
  if (!ingressoValido(value)) {
@@ -3532,8 +3562,11 @@ var StanzaClient = class {
3532
3562
  this.segnalaStanza({ code: this.codice });
3533
3563
  }
3534
3564
  this.apri(ingresso.url);
3535
- } catch {
3536
- this.programmaRiconnessione();
3565
+ } catch (error) {
3566
+ if (error instanceof Error && "code" in error && ["version_mismatch", "version_outdated", "room_not_found"].includes(String(error.code))) {
3567
+ this.notifica(this.errorListeners, { code: String(error.code), message: error.message });
3568
+ this.termina(4004, String(error.code));
3569
+ } else this.programmaRiconnessione();
3537
3570
  }
3538
3571
  }
3539
3572
  fermaRiconnessione() {
@@ -3606,6 +3639,13 @@ var StanzaClient = class {
3606
3639
  function creaStanzeOffline(invited = null) {
3607
3640
  return {
3608
3641
  invited,
3642
+ reload() {
3643
+ if (typeof window !== "undefined") window.location.reload();
3644
+ },
3645
+ onError() {
3646
+ return () => {
3647
+ };
3648
+ },
3609
3649
  async create() {
3610
3650
  throw erroreOffline();
3611
3651
  },
@@ -3621,7 +3661,17 @@ function creaStanzeOffline(invited = null) {
3621
3661
  };
3622
3662
  }
3623
3663
  function creaGestoreStanze(input, invited) {
3624
- const api = creaApiLive(input);
3664
+ let reloadTarget;
3665
+ const errors = /* @__PURE__ */ new Set();
3666
+ const api = creaApiLive({ ...input, onVersionError(error, target) {
3667
+ reloadTarget = target;
3668
+ for (const listener of errors) {
3669
+ try {
3670
+ listener(error);
3671
+ } catch {
3672
+ }
3673
+ }
3674
+ } });
3625
3675
  let haSegnalato = false;
3626
3676
  let ultimoCodice = null;
3627
3677
  const segnalaStanza = (room) => {
@@ -3812,6 +3862,15 @@ function creaGestoreStanze(input, invited) {
3812
3862
  });
3813
3863
  return {
3814
3864
  invited,
3865
+ reload() {
3866
+ input.reload?.(reloadTarget);
3867
+ },
3868
+ onError(listener) {
3869
+ errors.add(listener);
3870
+ return () => {
3871
+ errors.delete(listener);
3872
+ };
3873
+ },
3815
3874
  async create(options) {
3816
3875
  return collega(await api.create(options.mode));
3817
3876
  },
@@ -3994,6 +4053,8 @@ async function connetti(input) {
3994
4053
  const scartoOrario = me.serverTime - (prima + dopo) / 2;
3995
4054
  const room = handshake.live === null ? creaStanzeOffline(handshake.invite) : creaGestoreStanze({
3996
4055
  appOrigin,
4056
+ n: handshake.n,
4057
+ reload: (target) => handshake.porta.postMessage({ type: "caisual:reload", target }),
3997
4058
  liveOrigin: handshake.live,
3998
4059
  fetcher: input.fetcher,
3999
4060
  biglietto: creaGestoreBiglietto(
package/dist/overlay.js CHANGED
@@ -803,8 +803,8 @@ function readMatchResult(value, playerIds) {
803
803
  }
804
804
 
805
805
  // src/errors.ts
806
- function creaErrore(code, message) {
807
- return Object.assign(new Error(message), { name: "CaisualError", code });
806
+ function creaErrore(code, message, version = {}) {
807
+ return Object.assign(new Error(message), { name: "CaisualError", code, ...version });
808
808
  }
809
809
 
810
810
  // src/overlay/host-bridge.ts
@@ -896,6 +896,13 @@ function creaPonteOspite(input) {
896
896
  });
897
897
  return;
898
898
  }
899
+ if (data2?.type === "caisual:reload") {
900
+ const target = record(data2.target);
901
+ const code = typeof target?.code === "string" && /^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{6}$/.test(target.code) ? target.code : void 0;
902
+ const roomId = typeof target?.roomId === "string" && /^g[1-9][0-9]*-[1-9][0-9]*\.[a-z0-9]{16}$/.test(target.roomId) ? target.roomId : void 0;
903
+ input.reload?.(code || roomId ? { code, roomId, watch: target?.watch === true } : void 0);
904
+ return;
905
+ }
899
906
  const room = stanzaDaMessaggio(data2);
900
907
  if (room !== void 0) {
901
908
  input.onRoom(room);
@@ -934,6 +941,7 @@ function creaPonteOspite(input) {
934
941
  currentPort.start();
935
942
  input.frame.contentWindow?.postMessage({
936
943
  type: "caisual:hello",
944
+ n: input.n,
937
945
  ticket: input.ticket,
938
946
  live: input.origineLive,
939
947
  invite: input.invite,
@@ -948,6 +956,12 @@ function creaPonteOspite(input) {
948
956
  input.frame.addEventListener?.("load", loaded);
949
957
  poll();
950
958
  return {
959
+ get watch() {
960
+ return input.watch === true;
961
+ },
962
+ reload() {
963
+ input.reload?.();
964
+ },
951
965
  get epoch() {
952
966
  return epoch;
953
967
  },
@@ -1159,6 +1173,8 @@ function createBoardController(input) {
1159
1173
  // src/overlay/i18n.ts
1160
1174
  var languages = ["en", "it", "es", "fr", "de", "pt"];
1161
1175
  var words = {
1176
+ gameUpdated: ["This game was updated", "Questo gioco \xE8 stato aggiornato", "Este juego se ha actualizado", "Ce jeu a \xE9t\xE9 mis \xE0 jour", "Dieses Spiel wurde aktualisiert", "Este jogo foi atualizado"],
1177
+ reloadGame: ["Reload game", "Ricarica il gioco", "Recargar el juego", "Recharger le jeu", "Spiel neu laden", "Recarregar o jogo"],
1162
1178
  gameLanguages: ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo"],
1163
1179
  loading: ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando..."],
1164
1180
  loadingSlow: ["This game is taking longer than expected. You can wait a little longer or try again.", "Il gioco ci sta mettendo pi\xF9 del previsto. Puoi aspettare ancora un po\u2019 o riprovare.", "El juego est\xE1 tardando m\xE1s de lo esperado. Puedes esperar un poco m\xE1s o volver a intentarlo.", "Le jeu met plus de temps que pr\xE9vu. Vous pouvez patienter encore un peu ou r\xE9essayer.", "Das Spiel braucht l\xE4nger als erwartet. Du kannst noch etwas warten oder es erneut versuchen.", "O jogo est\xE1 demorando mais do que o esperado. Voc\xEA pode esperar mais um pouco ou tentar novamente."],
@@ -1298,6 +1314,7 @@ function translator(language) {
1298
1314
  return (key, values = {}) => dictionary[key].replace(/\{(\w+)\}/g, (_all, name) => String(values[name] ?? ""));
1299
1315
  }
1300
1316
  function errorText(code) {
1317
+ if (code === "version_outdated") return "gameUpdated";
1301
1318
  if (code === "permission_denied") return "voiceDenied";
1302
1319
  if (code === "unsupported") return "voiceUnsupported";
1303
1320
  if (code === "voice_disabled") return "voiceUnavailable";
@@ -1715,7 +1732,7 @@ function mountOverlay(input) {
1715
1732
  const hasRooms = manifest.modes.some((mode) => mode.execution === "room" && risolviModalita(manifest, mode.id).players.max > 1);
1716
1733
  return `${input.configuration.iconUrl ? `<img class="game-icon game-icon-title" src="${escape(input.configuration.iconUrl)}" alt="" />` : ""}<h1>${escape(manifest.name)}</h1><p class="muted" data-game-languages>${t("gameLanguages")}: ${escape(manifestLanguages(manifest).join(" \xB7 "))}</p><label>${t("mode")}<select data-control="mode"${disabled()}>${manifest.modes.map((mode) => `<option value="${escape(mode.id)}"${mode.id === model.mode ? " selected" : ""}>${escape(risolviPresentazione(manifest, mode.id, input.language).label)}</option>`).join("")}</select></label>
1717
1734
  ${selected?.instructions ? `<p class="muted">${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}</p>` : ""}
1718
- ${input.configuration.invite && phase(session) === "home" ? button("join-invite", "joinInvite", ' class="primary"', !session?.ready) : ""}
1735
+ ${input.configuration.invite && phase(session) === "home" ? button("join-invite", input.bridge.watch ? "watch" : "joinInvite", ' class="primary"', !session?.ready) : ""}
1719
1736
  ${action ? button("play", action.friends ? "friendsPlay" : "play", ' class="primary"', !session?.ready) : ""}
1720
1737
  ${selected?.matchmaking ? button("match", "find", "", !selected.matchmaking.defaults || !session?.ready) : ""}
1721
1738
  ${session?.resume ? button("resume", "resume", "", !session.ready) + `<small>${escape(solo() || soloMode(session.resume.mode) ? "" : session.resume.code)}</small>` : ""}
@@ -1860,7 +1877,7 @@ function mountOverlay(input) {
1860
1877
  const label = current === "watching" ? t("watching") : room2?.connection === "reconnecting" ? t("reconnecting") : solo() ? "Caisual" : room2?.code ?? "Caisual";
1861
1878
  surface.innerHTML = current === "boot" ? "" : `<div class="pill" data-reserve><button type="button" data-action="menu" aria-label="${t("menu")}" aria-expanded="${!!panel}">C<span aria-hidden="true"><small>${escape(label)}</small></span></button>${voiceEligible(manifest, model.session) && model.session?.kind === "room" ? `<button type="button" class="voice-toggle" data-voice-toggle data-action="panel:voice"></button>` : ""}${invitations ? `<button type="button" data-action="panel:friends" aria-label="${t("friends")} (${invitations})">${invitations}</button>` : ""}</div>
1862
1879
  ${current === "ended" && !panel ? `<div class="ended" data-reserve role="region" aria-label="${t("ended")}">${resultBar()}${boards?.state.saving ? `<small role="status" data-saving>${t(boards.state.saving)}</small>` : ""}${canPlayAgain(model.session) ? button("again", "again", ' class="primary"') : model.session?.kind === "room" && room2?.status !== "finished" && !solo() ? `<small>${t("waitHost")}</small>` : ""}${rematchBar()}${Object.keys(manifest.boards).length ? button("panel:boards", "boards") : ""}${button("panel:home", "homeMenu")}</div>` : ""}
1863
- ${panel ? `<div class="backdrop${panel === "home" ? " home" : ""}"><section class="dialog${panel === "boards" || panel === "friends" ? " wide" : ""}" role="dialog" aria-modal="true" aria-labelledby="panel-title" tabindex="-1"><div class="top"><h2 id="panel-title">${title(panel)}</h2><button type="button" data-action="close" aria-label="${t("close")}">\xD7</button></div><div class="stack">${content(panel)}${model.error ? `<p class="error" role="alert" data-error>${t(errorText(model.error))}</p>` : ""}${model.session?.resumeError ? `<p class="error" role="alert">${t("saveFailed")}</p>` : ""}${model.notice ? `<p class="notice" role="status">${escape(model.notice)}</p>` : ""}</div></section></div>` : ""}`;
1880
+ ${panel ? `<div class="backdrop${panel === "home" ? " home" : ""}"><section class="dialog${panel === "boards" || panel === "friends" ? " wide" : ""}" role="dialog" aria-modal="true" aria-labelledby="panel-title" tabindex="-1"><div class="top"><h2 id="panel-title">${title(panel)}</h2><button type="button" data-action="close" aria-label="${t("close")}">\xD7</button></div><div class="stack">${content(panel)}${model.error ? `<p class="error" role="alert" data-error>${t(errorText(model.error))}</p>${model.error === "version_outdated" ? button("reload-game", "reloadGame", ' class="primary"') : ""}` : ""}${model.session?.resumeError ? `<p class="error" role="alert">${t("saveFailed")}</p>` : ""}${model.notice ? `<p class="notice" role="status">${escape(model.notice)}</p>` : ""}</div></section></div>` : ""}`;
1864
1881
  for (const element of surface.querySelectorAll(".pill,.backdrop,.ended")) element.style.pointerEvents = "auto";
1865
1882
  const backdrop = root.querySelector(".backdrop.home");
1866
1883
  if (backdrop && input.configuration.coverUrl) backdrop.style.backgroundImage = `linear-gradient(#0b151c99,#0b151cee),url(${JSON.stringify(input.configuration.coverUrl)})`;
@@ -1916,7 +1933,7 @@ function mountOverlay(input) {
1916
1933
  void perform("room.match", { mode: model.mode });
1917
1934
  break;
1918
1935
  case "join-invite":
1919
- if (input.configuration.invite) void perform("room.join", { code: input.configuration.invite });
1936
+ if (input.configuration.invite) void perform(input.bridge.watch ? "room.watch" : "room.join", { code: input.configuration.invite });
1920
1937
  break;
1921
1938
  case "resume":
1922
1939
  void perform("session.resume", {});
@@ -1969,6 +1986,9 @@ function mountOverlay(input) {
1969
1986
  case "exit-now":
1970
1987
  input.exit();
1971
1988
  break;
1989
+ case "reload-game":
1990
+ input.bridge.reload();
1991
+ break;
1972
1992
  case "reload":
1973
1993
  boot?.focus({ preventScroll: true });
1974
1994
  resetBootWait();
@@ -1,5 +1,6 @@
1
+ import { type VersioneGioco } from './versioni.js';
1
2
  export type DestinatarioBiglietto = 'portal' | 'live';
2
- export interface Biglietto {
3
+ export interface Biglietto extends VersioneGioco {
3
4
  sub: string;
4
5
  game: string;
5
6
  name: string;
@@ -8,7 +9,7 @@ export interface Biglietto {
8
9
  iat: number;
9
10
  exp: number;
10
11
  }
11
- export interface DatiBiglietto {
12
+ export interface DatiBiglietto extends VersioneGioco {
12
13
  sub: string;
13
14
  game: string;
14
15
  name: string;
@@ -13,3 +13,4 @@ export * from './room-limits.js';
13
13
  export * from './player.js';
14
14
  export * from './match-result.js';
15
15
  export * from './immagine.js';
16
+ export * from './versioni.js';
@@ -0,0 +1,18 @@
1
+ /** Il numero identifica gli artefatti del gioco, non il formato dei dati salvati. */
2
+ export interface VersioneGioco {
3
+ n: number;
4
+ }
5
+ export interface ErroreVersione {
6
+ currentVersion?: number;
7
+ roomVersion?: number;
8
+ }
9
+ export interface RicaricaGioco {
10
+ code?: string;
11
+ roomId?: string;
12
+ watch?: boolean;
13
+ }
14
+ export declare function numeroVersione(value: unknown): value is number;
15
+ export declare function analizzaRoomId(roomId: string): {
16
+ gameId: number;
17
+ n: number;
18
+ } | null;
@@ -1,6 +1,6 @@
1
1
  export type ErroreCaisual = Error & {
2
2
  code: string;
3
- };
4
- export declare function creaErrore(code: string, message: string): ErroreCaisual;
3
+ } & import('./contracts/index.js').ErroreVersione;
4
+ export declare function creaErrore(code: string, message: string, version?: import('./contracts/index.js').ErroreVersione): ErroreCaisual;
5
5
  export declare function erroreOffline(): ErroreCaisual;
6
6
  export declare function codiceErrore(valore: unknown): unknown;
@@ -1,4 +1,5 @@
1
1
  import { type OverlayHello } from './contracts/index.js';
2
+ import type { VersioneGioco } from './contracts/index.js';
2
3
  export interface GenitoreHandshake {
3
4
  postMessage(message: unknown, targetOrigin: string): void;
4
5
  }
@@ -9,7 +10,7 @@ export interface FinestraHandshakeKit extends GenitoreHandshake {
9
10
  setTimeout(handler: () => void, timeout: number): number;
10
11
  clearTimeout(id: number): void;
11
12
  }
12
- export interface EsitoHandshake {
13
+ export interface EsitoHandshake extends VersioneGioco {
13
14
  language?: string;
14
15
  uiLanguage?: string;
15
16
  languagePreferences?: string[];
@@ -184,6 +184,8 @@ export interface MatchOptions {
184
184
  }): void;
185
185
  }
186
186
  export interface Rooms {
187
+ reload(): void;
188
+ onError(listener: (error: import('./errors.js').ErroreCaisual) => void): () => void;
187
189
  readonly invited: string | null;
188
190
  create(options: {
189
191
  mode: string | null;
@@ -20,6 +20,9 @@ export interface HostBridgeInput {
20
20
  frame: FrameHandshake;
21
21
  origineGioco: string;
22
22
  origineLive: string;
23
+ n: number;
24
+ watch?: boolean;
25
+ reload?(target?: import('../contracts/index.js').RicaricaGioco): void;
23
26
  language?: string;
24
27
  languagePreferences?: readonly string[];
25
28
  invite: string | null;
@@ -39,6 +42,8 @@ export declare function stanzaDaMessaggio(value: unknown): {
39
42
  code: string;
40
43
  } | null | undefined;
41
44
  export declare function creaPonteOspite(input: HostBridgeInput): {
45
+ readonly watch: boolean;
46
+ reload(): void;
42
47
  readonly epoch: string | null;
43
48
  serverTime(): number | null;
44
49
  readonly state: OverlaySessionState | null;
@@ -46,7 +51,7 @@ export declare function creaPonteOspite(input: HostBridgeInput): {
46
51
  onShortcut(listener: () => void): () => void;
47
52
  onOpen(listener: (value: OverlayPanel) => void): () => void;
48
53
  onError(listener: (value: {
49
- sessionId: string;
54
+ sessionId: string | null;
50
55
  error: {
51
56
  code: string;
52
57
  message: string;
@@ -1,6 +1,8 @@
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 gameUpdated: readonly ["This game was updated", "Questo gioco è stato aggiornato", "Este juego se ha actualizado", "Ce jeu a été mis à jour", "Dieses Spiel wurde aktualisiert", "Este jogo foi atualizado"];
5
+ readonly reloadGame: readonly ["Reload game", "Ricarica il gioco", "Recargar el juego", "Recharger le jeu", "Spiel neu laden", "Recarregar o jogo"];
4
6
  readonly gameLanguages: readonly ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo"];
5
7
  readonly loading: readonly ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando..."];
6
8
  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."];
@@ -36,7 +36,7 @@ export declare function createSession(base: BaseConnection, configuration?: Over
36
36
  onState(listener: (value: OverlaySessionState) => void): () => void;
37
37
  onOpen(listener: (value: OverlayPanel) => void): () => void;
38
38
  onError(listener: (value: {
39
- sessionId: string;
39
+ sessionId: string | null;
40
40
  error: {
41
41
  code: string;
42
42
  message: string;
@@ -1,4 +1,5 @@
1
1
  import type { Rooms } from '../index.js';
2
+ import { type ErroreCaisual } from '../errors.js';
2
3
  import type { GestoreBiglietto } from '../handshake.js';
3
4
  import { type DipendenzeVoce } from '../voce/index.js';
4
5
  interface TimerStanza {
@@ -8,6 +9,9 @@ interface TimerStanza {
8
9
  clearInterval(id: number): void;
9
10
  }
10
11
  export interface DipendenzeStanze extends TimerStanza {
12
+ n: number;
13
+ reload?(target?: import('../contracts/index.js').RicaricaGioco): void;
14
+ onVersionError?(error: ErroreCaisual, target?: import('../contracts/index.js').RicaricaGioco): void;
11
15
  appOrigin: string;
12
16
  liveOrigin: string;
13
17
  fetcher: typeof fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caisual/kit",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Client and server kit for Caisual games",
5
5
  "type": "module",
6
6
  "files": [