@caisual/kit 0.13.0 → 0.14.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.13.0
1
+ // Caisual game kit v0.14.0
2
2
 
3
3
  // ../contracts/src/slug.ts
4
4
  var NOMI_RISERVATI = [
@@ -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
  }
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
  }
@@ -1729,8 +1733,9 @@ function mountOverlay(input) {
1729
1733
  }
1730
1734
  function home() {
1731
1735
  const selected = selectedMode(), action = primaryAction(manifest, model.mode), session = model.session;
1736
+ const description = resolveText(manifest.description, input.language, manifestLanguages(manifest)[0]);
1732
1737
  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>
1738
+ 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
1739
  ${selected?.instructions ? `<p class="muted">${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}</p>` : ""}
1735
1740
  ${input.configuration.invite && phase(session) === "home" ? button("join-invite", input.bridge.watch ? "watch" : "joinInvite", ' class="primary"', !session?.ready) : ""}
1736
1741
  ${action ? button("play", action.friends ? "friendsPlay" : "play", ' class="primary"', !session?.ready) : ""}
@@ -79,7 +79,7 @@ export interface Manifest {
79
79
  manifest: 1;
80
80
  id: string;
81
81
  name: string;
82
- description: string;
82
+ description: LocalizedText;
83
83
  cover: string;
84
84
  card: string;
85
85
  icon: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caisual/kit",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Client and server kit for Caisual games",
5
5
  "type": "module",
6
6
  "files": [