@caisual/kit 0.13.0 → 0.15.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/overlay.js CHANGED
@@ -180,7 +180,7 @@ function testoFacoltativo(value, key, max, path, errors) {
180
180
  }
181
181
  return text2.trim();
182
182
  };
183
- const text = value[key], field = `${path}.${key}`;
183
+ const text = value[key], field = path ? `${path}.${key}` : key;
184
184
  if (typeof text === "string") return check(text, field);
185
185
  const translations = oggetto(text);
186
186
  if (!translations || Object.keys(translations).length === 0) {
@@ -221,8 +221,7 @@ function validaManifest(valore) {
221
221
  else if (typeof dati.name === "string" && (name.trim() === "" || name.length > 60)) {
222
222
  errori.push("name: must contain 1-60 characters.");
223
223
  }
224
- const description = stringaDefault(dati, "description", "", errori);
225
- if (description.length > 500) errori.push("description: must be at most 500 characters.");
224
+ const description = dati.description === "" ? "" : testoFacoltativo(dati, "description", 500, "", errori) ?? "";
226
225
  const immagini = { cover: "", card: "", icon: "" };
227
226
  const usati = /* @__PURE__ */ new Set();
228
227
  for (const campo of ["cover", "card", "icon"]) {
@@ -277,6 +276,11 @@ function validaManifest(valore) {
277
276
  }
278
277
  if (!languages2.includes("en")) errori.push("languages: English is always required alongside the game's own languages.");
279
278
  const language = languages2[0] ?? legacyLanguage;
279
+ if (typeof description === "object") {
280
+ for (const tag of Object.keys(description)) {
281
+ if (!languages2.includes(tag)) errori.push(`description.${tag}: language must be declared in languages.`);
282
+ }
283
+ }
280
284
  if (dati.language !== void 0 && dati.languages !== void 0 && legacyLanguage.toLowerCase() !== language.toLowerCase()) {
281
285
  errori.push("language: must match the first entry in languages when both are present.");
282
286
  }
@@ -1113,11 +1117,11 @@ function createBoardController(input) {
1113
1117
  loading = false;
1114
1118
  if (matches() && saving !== "saved" && saving !== "bestAlready") {
1115
1119
  reads++;
1116
- if (reads < 4) {
1120
+ if (reads < 2) {
1117
1121
  saving = "saving";
1118
1122
  timer = later(() => {
1119
1123
  void refresh();
1120
- }, [800, 1600, 3200][reads - 1]);
1124
+ }, 1600);
1121
1125
  } else saving = "refreshHint";
1122
1126
  }
1123
1127
  notify();
@@ -1549,6 +1553,7 @@ function mountOverlay(input) {
1549
1553
  host.style.setProperty("--boot-accent", luminance > 0.179 ? accent : `color-mix(in srgb, ${accent}, #ffffff 70%)`);
1550
1554
  input.container.append(host);
1551
1555
  let model = initialUi(manifest), disposed = false, operation = 0, lastView = "", geometryFrame = 0;
1556
+ let inviteAfterCreate;
1552
1557
  let lastPhase = "", wasModal = false, copyFallback = null;
1553
1558
  let boot = null, bootTimer = 0, bootFadeTimer = 0;
1554
1559
  let voiceError = null, voicePending = null, voiceOperation = 0;
@@ -1729,8 +1734,9 @@ function mountOverlay(input) {
1729
1734
  }
1730
1735
  function home() {
1731
1736
  const selected = selectedMode(), action = primaryAction(manifest, model.mode), session = model.session;
1737
+ const description = resolveText(manifest.description, input.language, manifestLanguages(manifest)[0]);
1732
1738
  const hasRooms = manifest.modes.some((mode) => mode.execution === "room" && risolviModalita(manifest, mode.id).players.max > 1);
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>
1739
+ return `${input.configuration.iconUrl ? `<img class="game-icon game-icon-title" src="${escape(input.configuration.iconUrl)}" alt="" />` : ""}<h1>${escape(manifest.name)}</h1>${description ? `<p class="muted" data-game-description>${escape(description)}</p>` : ""}<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>
1734
1740
  ${selected?.instructions ? `<p class="muted">${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}</p>` : ""}
1735
1741
  ${input.configuration.invite && phase(session) === "home" ? button("join-invite", input.bridge.watch ? "watch" : "joinInvite", ' class="primary"', !session?.ready) : ""}
1736
1742
  ${action ? button("play", action.friends ? "friendsPlay" : "play", ' class="primary"', !session?.ready) : ""}
@@ -1967,11 +1973,12 @@ function mountOverlay(input) {
1967
1973
  if (model.session?.kind === "local") void perform("local.start", { mode: model.session.mode ?? model.mode });
1968
1974
  else if (model.session?.room?.status === "finished") void perform("room.restart", {});
1969
1975
  else if (solo()) void perform("room.create", { mode: model.session?.room?.mode ?? null });
1970
- else void perform("room.create", { mode: model.session?.room?.mode ?? null }, async () => {
1971
- setPanel("invite");
1972
- dispatch({ type: "notice", notice: t("newRoom") });
1973
- await copyInvite();
1974
- });
1976
+ else {
1977
+ inviteAfterCreate = roomCode();
1978
+ void perform("room.create", { mode: model.session?.room?.mode ?? null }).then(() => {
1979
+ if (model.error) inviteAfterCreate = void 0;
1980
+ });
1981
+ }
1975
1982
  break;
1976
1983
  }
1977
1984
  case "disconnect-exit":
@@ -2124,6 +2131,13 @@ function mountOverlay(input) {
2124
2131
  model = reduceUi(model, { type: "session", session });
2125
2132
  updateVoice();
2126
2133
  } else dispatch({ type: "session", session });
2134
+ const created = roomCode();
2135
+ if (inviteAfterCreate !== void 0 && created && created !== inviteAfterCreate) {
2136
+ inviteAfterCreate = void 0;
2137
+ setPanel("invite");
2138
+ dispatch({ type: "notice", notice: t("newRoom") });
2139
+ void copyInvite();
2140
+ }
2127
2141
  }));
2128
2142
  stops.push(input.bridge.onOpen((panel) => setPanel(panel)), input.bridge.onShortcut(toggle), input.bridge.onError(({ error }) => {
2129
2143
  if (!visiblePanel(model)) setPanel("room");