rpg-engine 0.9.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.
Files changed (115) hide show
  1. package/dist/adventures/source.js +6 -5
  2. package/dist/commands/find.d.ts +1 -0
  3. package/dist/commands/find.js +3 -2
  4. package/dist/commands/package.d.ts +3 -3
  5. package/dist/commands/package.js +72 -35
  6. package/dist/commands/rules.js +4 -2
  7. package/dist/commands/shared/adventures.js +20 -11
  8. package/dist/commands/shared/library.js +13 -5
  9. package/dist/commands/shared/packages/catalog.d.ts +2 -0
  10. package/dist/commands/shared/packages/catalog.js +1 -0
  11. package/dist/commands/shared/rules.js +29 -5
  12. package/dist/commands/view/place.d.ts +2 -0
  13. package/dist/commands/view/place.js +8 -2
  14. package/dist/core/context.d.ts +2 -0
  15. package/dist/core/refusal.d.ts +12 -0
  16. package/dist/core/refusal.js +17 -0
  17. package/dist/dashboard/api.js +37 -81
  18. package/dist/dashboard/app.js +10 -3
  19. package/dist/dashboard/asked.js +6 -3
  20. package/dist/dashboard/assets/master.svg +1 -2
  21. package/dist/dashboard/card.js +1 -1
  22. package/dist/dashboard/dice/load.js +6 -1
  23. package/dist/dashboard/dice/throw.js +5 -1
  24. package/dist/dashboard/dice/tray.js +5 -1
  25. package/dist/dashboard/footer.js +2 -2
  26. package/dist/dashboard/game-words.js +32 -32
  27. package/dist/dashboard/guide/ar.md +5 -5
  28. package/dist/dashboard/guide/cs.md +7 -7
  29. package/dist/dashboard/guide/da.md +5 -5
  30. package/dist/dashboard/guide/de.md +5 -5
  31. package/dist/dashboard/guide/el.md +7 -7
  32. package/dist/dashboard/guide/en.md +2 -2
  33. package/dist/dashboard/guide/es.md +6 -6
  34. package/dist/dashboard/guide/fi.md +5 -5
  35. package/dist/dashboard/guide/fr.md +6 -6
  36. package/dist/dashboard/guide/he.md +7 -7
  37. package/dist/dashboard/guide/hi.md +6 -6
  38. package/dist/dashboard/guide/hu.md +7 -7
  39. package/dist/dashboard/guide/is.md +7 -7
  40. package/dist/dashboard/guide/it.md +5 -5
  41. package/dist/dashboard/guide/ja.md +7 -7
  42. package/dist/dashboard/guide/ko.md +9 -9
  43. package/dist/dashboard/guide/nb.md +6 -6
  44. package/dist/dashboard/guide/nl.md +7 -7
  45. package/dist/dashboard/guide/pl.md +7 -7
  46. package/dist/dashboard/guide/pt.md +5 -5
  47. package/dist/dashboard/guide/ro.md +8 -8
  48. package/dist/dashboard/guide/ru.md +7 -7
  49. package/dist/dashboard/guide/sv.md +6 -6
  50. package/dist/dashboard/guide/tr.md +8 -8
  51. package/dist/dashboard/guide/uk.md +6 -6
  52. package/dist/dashboard/guide/zh.md +8 -8
  53. package/dist/dashboard/help/blocks.js +6 -0
  54. package/dist/dashboard/help/help.js +15 -3
  55. package/dist/dashboard/help/markdown.js +2 -1
  56. package/dist/dashboard/i18n/ar.json +53 -1
  57. package/dist/dashboard/i18n/cs.json +53 -1
  58. package/dist/dashboard/i18n/da.json +53 -1
  59. package/dist/dashboard/i18n/de.json +53 -1
  60. package/dist/dashboard/i18n/el.json +53 -1
  61. package/dist/dashboard/i18n/es.json +53 -1
  62. package/dist/dashboard/i18n/fi.json +53 -1
  63. package/dist/dashboard/i18n/fr.json +53 -1
  64. package/dist/dashboard/i18n/he.json +53 -1
  65. package/dist/dashboard/i18n/hi.json +53 -1
  66. package/dist/dashboard/i18n/hu.json +53 -1
  67. package/dist/dashboard/i18n/is.json +53 -1
  68. package/dist/dashboard/i18n/it.json +56 -4
  69. package/dist/dashboard/i18n/ja.json +53 -1
  70. package/dist/dashboard/i18n/ko.json +53 -1
  71. package/dist/dashboard/i18n/nb.json +53 -1
  72. package/dist/dashboard/i18n/nl.json +53 -1
  73. package/dist/dashboard/i18n/pl.json +53 -1
  74. package/dist/dashboard/i18n/pt.json +53 -1
  75. package/dist/dashboard/i18n/ro.json +53 -1
  76. package/dist/dashboard/i18n/ru.json +53 -1
  77. package/dist/dashboard/i18n/sv.json +53 -1
  78. package/dist/dashboard/i18n/tr.json +53 -1
  79. package/dist/dashboard/i18n/uk.json +53 -1
  80. package/dist/dashboard/i18n/zh.json +53 -1
  81. package/dist/dashboard/icons.js +2 -2
  82. package/dist/dashboard/journal.js +9 -4
  83. package/dist/dashboard/labels.js +5 -4
  84. package/dist/dashboard/language-choice.js +3 -3
  85. package/dist/dashboard/markdown.js +11 -4
  86. package/dist/dashboard/notes.js +4 -2
  87. package/dist/dashboard/notices.js +2 -2
  88. package/dist/dashboard/packages/ask-card.js +1 -1
  89. package/dist/dashboard/packages/packages.js +14 -10
  90. package/dist/dashboard/packages/page-code.js +11 -3
  91. package/dist/dashboard/packages/widgets.js +5 -5
  92. package/dist/dashboard/pages.js +3 -3
  93. package/dist/dashboard/place/map-sheet.js +4 -3
  94. package/dist/dashboard/place/map-view.js +17 -5
  95. package/dist/dashboard/refusals.js +61 -0
  96. package/dist/dashboard/rolls.js +3 -3
  97. package/dist/dashboard/settings.js +19 -5
  98. package/dist/dashboard/sheet.js +26 -7
  99. package/dist/dashboard/status.js +19 -13
  100. package/dist/dashboard/style.css +113 -16
  101. package/dist/dashboard/text.js +6 -2
  102. package/dist/dashboard/top.js +7 -9
  103. package/dist/dashboard/turns.js +7 -2
  104. package/dist/dashboard/world/lore.js +16 -15
  105. package/dist/dashboard/world/map.js +43 -1
  106. package/dist/dashboard/world/world.js +50 -15
  107. package/dist/extensions/extension.js +4 -1
  108. package/dist/packages/npm.js +4 -2
  109. package/dist/packages/tarball.js +8 -4
  110. package/dist/rules/rule-book.d.ts +2 -0
  111. package/dist/rules/search.d.ts +4 -1
  112. package/dist/rules/search.js +8 -2
  113. package/dist/server/dashboard/writes.js +22 -13
  114. package/dist/systems/system-code.js +5 -0
  115. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { unzipSync, zipSync } from "fflate";
2
2
  import { relative, sep } from "node:path";
3
3
  import { archivePathParts, refuseTwice } from "../core/archive-paths.js";
4
4
  import { filesIn } from "../core/files.js";
5
+ import { Refusal } from "../core/refusal.js";
5
6
  import { files } from "../core/store.js";
6
7
  import { manifestFileName, readManifest, writeManifest } from "./manifest.js";
7
8
  /** The folders an adventure has, as a campaign has them (D-372). */
@@ -34,7 +35,7 @@ export function readAdventureZip(bytes, label) {
34
35
  });
35
36
  }
36
37
  catch (error) {
37
- throw new Error(`${label} is not a .zip that reads: ${error instanceof Error ? error.message : String(error)}. Nothing changed.`);
38
+ throw new Refusal(`${label} is not a .zip that reads: ${error instanceof Error ? error.message : String(error)}. Nothing changed.`, "archive-unread", { name: label });
38
39
  }
39
40
  const named = Object.entries(read).filter(([name]) => !/[\\/]$/.test(name)).map(([name, data]) => [utf8Name(label, name), data]);
40
41
  return adventureOf(label, named);
@@ -66,7 +67,7 @@ function utf8Name(label, name) {
66
67
  }
67
68
  }
68
69
  if (/[\u0080-\u009f]/.test(name)) {
69
- throw new Error(`${label} names a file with accents not written in UTF-8 (${name}): make the zip again with 7-Zip, or Compress-Archive in PowerShell. Nothing changed.`);
70
+ throw new Refusal(`${label} names a file with accents not written in UTF-8 (${name}): make the zip again with 7-Zip, or Compress-Archive in PowerShell. Nothing changed.`, "archive-accents", { name: label });
70
71
  }
71
72
  return name.normalize("NFC");
72
73
  }
@@ -80,7 +81,7 @@ function adventureOf(label, entries) {
80
81
  const inner = !atTop && tops.size === 1 ? checked.map(([parts, data]) => [parts.slice(1), data]).filter(([parts]) => parts.length > 0) : checked;
81
82
  const manifest = inner.find(([parts]) => parts.length === 1 && parts[0].toLowerCase() === manifestFileName);
82
83
  if (manifest === undefined) {
83
- throw new Error(`${label} has no ${manifestFileName} at its top: it is not an adventure. A document or a folder of notes is imported by the master, who writes its pages. Nothing changed.`);
84
+ throw new Refusal(`${label} has no ${manifestFileName} at its top: it is not an adventure. A document or a folder of notes is imported by the master, who writes its pages. Nothing changed.`, "not-adventure", { name: label });
84
85
  }
85
86
  const held = {};
86
87
  const ignored = new Set();
@@ -98,8 +99,8 @@ function adventureOf(label, entries) {
98
99
  continue;
99
100
  }
100
101
  if (!allowed[folder].test(path)) {
101
- throw new Error(`${label} holds ${path}, and ${folder}/ holds only ${folder === "images" ? "pictures in .png, .jpg, .webp or .svg" : "markdown files"}: it is refused whole. `
102
- + "Take it out, or convert it, and give it again.");
102
+ throw new Refusal(`${label} holds ${path}, and ${folder}/ holds only ${folder === "images" ? "pictures in .png, .jpg, .webp or .svg" : "markdown files"}: it is refused whole. `
103
+ + "Take it out, or convert it, and give it again.", "adventure-file", { name: label, file: path });
103
104
  }
104
105
  held[[folder, ...parts.slice(1)].join("/")] = data;
105
106
  }
@@ -18,6 +18,7 @@ export declare const find: import("../core/registry.ts").Command<z.ZodObject<{
18
18
  system: string | undefined;
19
19
  systemMatches: {
20
20
  page: string;
21
+ title: string | undefined;
21
22
  type: "place" | "quest" | "creature" | "item" | "character" | "faction" | "event" | "topic" | undefined;
22
23
  excerpt: string | undefined;
23
24
  }[];
@@ -25,14 +25,15 @@ export const find = defineCommand({
25
25
  // The game system's pages are found by name only, and listed only for a text: there may be hundreds (SYS-3).
26
26
  const withText = (input.text?.trim() ?? "") !== "";
27
27
  const system = searchSystemPages(world, input);
28
- const listed = withText ? system.slice(0, listedSystemPages).map(({ page, excerpt }) => ({ page: page.name, type: page.type, excerpt })) : [];
28
+ const listed = withText ? system.slice(0, listedSystemPages).map(({ page, excerpt }) => ({ page: page.name, title: page.title, type: page.type, excerpt })) : [];
29
29
  const byName = system.slice(listed.length).filter((match) => match.excerpt === undefined).length;
30
30
  const systemFound = { system: world.system?.name, systemMatches: listed, systemMore: system.length - listed.length, systemMoreByName: byName, withText, type: input.type };
31
31
  return { matches, ...systemFound, language: foreignSystemLanguage(world), searchHint: systemSearchHint(world).trim(), problems: world.problems };
32
32
  },
33
33
  format(result) {
34
34
  const lines = result.matches.map((match) => `${match.page} (${match.type ?? "free page"})${match.excerpt === undefined ? "" : `: ${match.excerpt}`}`);
35
- const system = result.systemMatches.map((match) => `${match.page} (${match.type ?? "page"}, system ${result.system ?? ""})${match.excerpt === undefined ? "" : `: ${match.excerpt}`}`);
35
+ // A page's name in the campaign's language beside it, where the system has it (D-542): Hooded Lantern «Lanterna schermabile».
36
+ const system = result.systemMatches.map((match) => `${match.page}${match.title === undefined ? "" : ` «${match.title}»`} (${match.type ?? "page"}, system ${result.system ?? ""})${match.excerpt === undefined ? "" : `: ${match.excerpt}`}`);
36
37
  const found = [...lines, ...system];
37
38
  const note = systemNote(result, lines.length > 0);
38
39
  // A name said in play and never written is no page: the player who remembers it is right (D-266).
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { type Context } from "../core/context.ts";
3
+ import { Refusal } from "../core/refusal.ts";
3
4
  import { type Extension } from "../extensions/index.ts";
4
5
  import { type AdventureExported, type AdventureInstalled } from "./shared/adventures.ts";
5
6
  type PackageResult = {
@@ -74,9 +75,8 @@ type Installed = {
74
75
  issues?: string;
75
76
  };
76
77
  /** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
77
- export declare class YesRefused extends Error {
78
- readonly code: "declined" | "no-window";
79
- constructor(message: string, code: "declined" | "no-window");
78
+ export declare class YesRefused extends Refusal {
79
+ constructor(message: string, code: "declined" | "no-window", values?: Record<string, string>);
80
80
  }
81
81
  /** A game system on this computer (D-485): shipped with the engine, or a package npm installed; the campaign plays one, chosen in its setup. */
82
82
  export interface InstalledSystem {
@@ -6,7 +6,8 @@ import { engineSystemsFolder } from "../core/context.js";
6
6
  import { neutralExamples } from "../core/examples.js";
7
7
  import { installedFromFolder } from "../core/files.js";
8
8
  import { appendLogEntry } from "../core/log.js";
9
- import { apiProblem, ourSystems, readsApi } from "../core/package-declarations.js";
9
+ import { apiProblem, ourSystems, packageApi, readsApi } from "../core/package-declarations.js";
10
+ import { Refusal } from "../core/refusal.js";
10
11
  import { defineCommand } from "../core/registry.js";
11
12
  import { files, FileStore, isInside, withFiles } from "../core/store.js";
12
13
  import { comparableText } from "../core/text.js";
@@ -14,7 +15,7 @@ import { isNewerVersion } from "../core/version.js";
14
15
  import { dropConsent, findExtension, installedExtensions, readExtension, recordConsent, shortName } from "../extensions/index.js";
15
16
  import { installedLanguages, languagePackProblems, readLanguagePack } from "../languages/index.js";
16
17
  import { isLocalSpec, isPackageName, issuesPage, isTarball, isVerified, verifiedScope } from "../packages/index.js";
17
- import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder } from "../systems/index.js";
18
+ import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder, systemWords } from "../systems/index.js";
18
19
  import { exportAdventure, installAdventure, installedAdventures, isAdventureSpec, readAdventureSpec, removeAdventure, storyTouching } from "./shared/adventures.js";
19
20
  import { campaignExamples } from "./shared/examples.js";
20
21
  import { campaignMode } from "./shared/mode.js";
@@ -23,11 +24,9 @@ import { listedExtensions, runsCode } from "./shared/packages/extensions.js";
23
24
  import { newDatedLogEntry } from "./shared/time.js";
24
25
  import { campaignWorld } from "./shared/world.js";
25
26
  /** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
26
- export class YesRefused extends Error {
27
- code;
28
- constructor(message, code) {
29
- super(message);
30
- this.code = code;
27
+ export class YesRefused extends Refusal {
28
+ constructor(message, code, values = {}) {
29
+ super(message, code, values);
31
30
  }
32
31
  }
33
32
  export const packageCommand = defineCommand({
@@ -285,7 +284,12 @@ async function installed(root, context, name) {
285
284
  const other = second !== undefined && "failed" in tried && tried.missing === true ? await packages.describe(second) : undefined;
286
285
  const [asked, described] = second !== undefined && other !== undefined && !("failed" in other && other.missing === true) ? [second, other] : [first, tried];
287
286
  if ("failed" in described) {
288
- throw new Error(`${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`);
287
+ const message = `${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`;
288
+ throw isLocalSpec(asked)
289
+ ? new Refusal(message, "not-on-computer", { name })
290
+ : described.missing === true
291
+ ? new Refusal(message, "not-found", { name })
292
+ : new Refusal(message, "npm-failed", { name, why: described.failed });
289
293
  }
290
294
  // npm is given the version described, which the player's yes was for: by its name alone, npm would keep the exact version it saved before.
291
295
  const spec = isLocalSpec(asked) ? asked : `${described.name}@${described.version}`;
@@ -296,13 +300,15 @@ async function installed(root, context, name) {
296
300
  return await languageInstalled(root, context, spec, described);
297
301
  }
298
302
  if (described.kind !== "extension") {
299
- throw new Error(described.kind === undefined
300
- ? `${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed.`
301
- : `${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed.`);
303
+ throw described.kind === undefined
304
+ ? new Refusal(`${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed.`, "not-ours", { name: described.name })
305
+ : new Refusal(`${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed.`, "other-kind", {
306
+ name: described.name,
307
+ });
302
308
  }
303
309
  const unread = apiProblem(described.api, "extension");
304
310
  if (unread !== undefined) {
305
- throw new Error(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`);
311
+ throw apiRefusal(described, unread);
306
312
  }
307
313
  const local = isLocalSpec(spec);
308
314
  const before = usable(context, described.name);
@@ -318,7 +324,7 @@ async function installed(root, context, name) {
318
324
  if (reinstall) {
319
325
  const why = await packages.install(spec);
320
326
  if (why !== undefined) {
321
- throw new Error(`${described.name} could not be installed: ${why}. Nothing changed in the campaign.`);
327
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed in the campaign.`, "install-failed", { name: described.name, why });
322
328
  }
323
329
  // npm wrote there: what the call read of those folders is read again, and the code anew.
324
330
  (context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
@@ -336,7 +342,10 @@ async function installed(root, context, name) {
336
342
  : "unread" in installed
337
343
  ? `its extension does not read: ${installed.unread}`
338
344
  : "no extension of that name is where npm put it";
339
- throw new Error(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`);
345
+ throw new Refusal(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`, "taken-off", {
346
+ name: described.name,
347
+ why,
348
+ });
340
349
  }
341
350
  // The player's yes holds for this version and these files, on this computer: its code runs on the server and in the page (D-478, D-510).
342
351
  if (!isVerified(described.name, local) && !extension.linked) {
@@ -344,20 +353,24 @@ async function installed(root, context, name) {
344
353
  }
345
354
  const system = readTextSetting(root, "system");
346
355
  if (extension.needs.system !== undefined && comparableText(extension.needs.system) !== comparableText(system ?? "")) {
347
- throw new Error(`${extension.name} is installed on this computer, but it is for the game system ${extension.needs.system}, and the campaign plays ${system ?? "none"}: the campaign does not use it.`);
356
+ throw new Refusal(`${extension.name} is installed on this computer, but it is for the game system ${extension.needs.system}, and the campaign plays ${system ?? "none"}: the campaign does not use it.`, "other-system", { name: extension.name, system: extension.needs.system, plays: system ?? "" });
348
357
  }
349
358
  // Its state, widgets and pictures go by its name, which the system's would share (D-514).
350
359
  if (comparableText(extension.name) === comparableText(system ?? "")) {
351
- throw new Error(`${extension.name} is installed on this computer, but it has the name of the game system the campaign plays: the campaign does not use it. Nothing changed in the campaign.`);
360
+ throw new Refusal(`${extension.name} is installed on this computer, but it has the name of the game system the campaign plays: the campaign does not use it. Nothing changed in the campaign.`, "system-name", { name: extension.name });
352
361
  }
353
362
  const others = Object.keys(listedExtensions(root)).filter((other) => other !== extension.package && shortName(other) === extension.name);
354
363
  if (others.length > 0) {
355
- throw new Error(`The campaign uses ${others[0]}, with the same name, ${extension.name}: take it away with package remove ${others[0]} first. Nothing changed in the campaign.`);
364
+ throw new Refusal(`The campaign uses ${others[0]}, with the same name, ${extension.name}: take it away with package remove ${others[0]} first. Nothing changed in the campaign.`, "same-name", {
365
+ name: extension.name,
366
+ other: others[0],
367
+ });
356
368
  }
357
369
  // Its code is checked before the campaign lists it: a package that would not work is never added.
358
370
  const commands = runsCode(extension)
359
371
  ? await packageCommandNames(extension, context).catch((error) => {
360
- throw new Error(`The code of ${extension.package} cannot be used: ${error instanceof Error ? error.message : String(error)}. Nothing changed in the campaign.`);
372
+ const why = error instanceof Error ? error.message : String(error);
373
+ throw new Refusal(`The code of ${extension.package} cannot be used: ${why}. Nothing changed in the campaign.`, "code-broken", { name: extension.package, why });
361
374
  })
362
375
  : [];
363
376
  const listedBefore = listedExtensions(root);
@@ -389,18 +402,18 @@ async function systemInstalled(root, context, spec, name, described) {
389
402
  const named = shortName(described.name).replace(/^system-/, "");
390
403
  const unread = apiProblem(described.api, "system");
391
404
  if (unread !== undefined) {
392
- throw new Error(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`);
405
+ throw apiRefusal(described, unread);
393
406
  }
394
407
  const taken = systemsHere(root, context).find((one) => comparableText(one.name) === comparableText(named) && one.package !== described.name);
395
408
  if (taken !== undefined) {
396
- throw new Error(`There is already a game system named ${taken.name} on this computer${taken.package === undefined ? ", the engine's own" : `, from ${taken.package}`}: ${described.name} would take its name. Nothing changed.`);
409
+ throw new Refusal(`There is already a game system named ${taken.name} on this computer${taken.package === undefined ? ", the engine's own" : `, from ${taken.package}`}: ${described.name} would take its name. Nothing changed.`, "system-taken", { name: described.name, system: taken.name });
397
410
  }
398
411
  if (!isVerified(described.name, local)) {
399
412
  await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, local ? ` (${described.name} ${described.version})` : "");
400
413
  }
401
414
  const why = await context.packages.install(spec);
402
415
  if (why !== undefined) {
403
- throw new Error(`${described.name} could not be installed: ${why}. Nothing changed.`);
416
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
404
417
  }
405
418
  [...context.systemFolders, ...(context.extensionFolders ?? [])].forEach((folder) => files().refresh(folder));
406
419
  const installed = installedExtensionFolder(context, described.name);
@@ -410,7 +423,9 @@ async function systemInstalled(root, context, spec, name, described) {
410
423
  }
411
424
  const system = systemsHere(root, context).find((one) => one.package === described.name);
412
425
  if (system === undefined) {
413
- throw new Error(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`);
426
+ throw new Refusal(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`, "system-unread", {
427
+ name: described.name,
428
+ });
414
429
  }
415
430
  appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: system.verified, kind: "system" }));
416
431
  const plays = readTextSetting(root, "system");
@@ -435,6 +450,7 @@ function codeText(loaded) {
435
450
  /** The game systems on this computer, those shipped with the engine first, with the package each came in when npm installed it (D-485). */
436
451
  function systemsHere(root, context) {
437
452
  const plays = readTextSetting(root, "system") ?? "";
453
+ const language = readTextSetting(root, "language");
438
454
  const folders = systemFolders(context.systemFolders);
439
455
  return readableSystems(context.systemFolders).map((system) => {
440
456
  const manifest = packageOf(folders.find((one) => one.name === system.name)?.folder ?? system.folder);
@@ -443,7 +459,7 @@ function systemsHere(root, context) {
443
459
  const linked = installedFromFolder(system.folder);
444
460
  return {
445
461
  name: system.name,
446
- title: system.title,
462
+ title: language === undefined ? system.title : titleIn(system.folder, system.title, language),
447
463
  ...(manifest === undefined ? {} : { version: manifest.version }),
448
464
  ...(manifest === undefined || shipped ? {} : { package: manifest.name }),
449
465
  verified: shipped || (manifest !== undefined && isVerified(manifest.name, linked)),
@@ -454,6 +470,15 @@ function systemsHere(root, context) {
454
470
  };
455
471
  });
456
472
  }
473
+ /** A system's title in the campaign's language, as its own words give it; as it is where they do not, or do not read. */
474
+ function titleIn(folder, title, language) {
475
+ try {
476
+ return systemWords(folder, language)?.words[title] ?? title;
477
+ }
478
+ catch {
479
+ return title;
480
+ }
481
+ }
457
482
  /** Where the package in this folder takes reports of its problems, as its package.json says; nothing when it says none or has none that reads. */
458
483
  function issuesOf(folder) {
459
484
  try {
@@ -480,13 +505,15 @@ function packageOf(folder) {
480
505
  */
481
506
  async function languageInstalled(root, context, spec, described) {
482
507
  if (described.code === true || described.dependencies === true) {
483
- throw new Error(`${described.name} says it is a language, and brings code or needs other packages: a language package is texts only. Nothing changed.`);
508
+ throw new Refusal(`${described.name} says it is a language, and brings code or needs other packages: a language package is texts only. Nothing changed.`, "language-code", {
509
+ name: described.name,
510
+ });
484
511
  }
485
512
  const before = installedLanguages(context.extensionFolders ?? []);
486
513
  const packages = context.packages;
487
514
  const why = await packages.install(spec);
488
515
  if (why !== undefined) {
489
- throw new Error(`${described.name} could not be installed: ${why}. Nothing changed.`);
516
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
490
517
  }
491
518
  (context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
492
519
  const folder = installedExtensionFolder(context, described.name);
@@ -506,7 +533,9 @@ async function languageInstalled(root, context, spec, described) {
506
533
  const earlier = before.find((one) => one.package === described.name);
507
534
  const back = earlier === undefined || isLocalSpec(spec) ? undefined : await packages.install(`${earlier.package}@${earlier.version}`).then((why) => (why === undefined ? earlier.version : undefined));
508
535
  (context.extensionFolders ?? []).forEach((one) => files().refresh(one));
509
- throw new Error(`${described.name} cannot be used: ${checked.problems.join("; ")}. ${back === undefined ? "It was taken off this computer." : `Version ${back} stays.`}`);
536
+ const why = checked.problems.join("; ");
537
+ const message = `${described.name} cannot be used: ${why}. ${back === undefined ? "It was taken off this computer." : `Version ${back} stays.`}`;
538
+ throw back === undefined ? new Refusal(message, "language-refused", { name: described.name, why }) : new Refusal(message, "language-kept", { name: described.name, why, version: back });
510
539
  }
511
540
  // One language, one package: the one before for the same code goes (D-485 (3)).
512
541
  const replaced = before.find((one) => one.code.toLowerCase() === pack.code.toLowerCase() && one.package !== described.name);
@@ -576,7 +605,7 @@ function pagePhrases(context) {
576
605
  async function playerYes(context, name, pack, local, holds = "", replaces = "") {
577
606
  // A no in a window holds for the package npm describes, however it was written, until the server starts again (D-510).
578
607
  if (context.declined?.has(pack) === true) {
579
- throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined");
608
+ throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined", { name: pack });
580
609
  }
581
610
  // Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510). The package's own words cut short, so
582
611
  // that a window, which shows so much at most, never loses the warning to them.
@@ -594,11 +623,11 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
594
623
  return;
595
624
  }
596
625
  if (answer === 1 || (typeof answer === "object" && answer !== null)) {
597
- throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined");
626
+ throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
598
627
  }
599
628
  // Closed without an answer is no yes, never a reason to ask again some other way.
600
629
  if (answer === undefined) {
601
- throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined");
630
+ throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined", { name });
602
631
  }
603
632
  const window = context.confirm === undefined ? "none" : await context.confirm.ask(title, question, context.signal);
604
633
  if (window === "yes") {
@@ -606,11 +635,19 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
606
635
  }
607
636
  if (window === "no") {
608
637
  context.declined?.add(pack);
609
- throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined");
638
+ throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
610
639
  }
611
640
  throw new YesRefused(`${warning} Only the player can say yes to it, in the host's form or in a window of their computer, and neither can be shown here (no desktop, as over SSH; `
612
641
  + `on Linux zenity or kdialog shows it): install it where one can be. Nothing changed.`, "no-window");
613
642
  }
643
+ /** A package made for an API this engine does not read: one newer than the engine, which an update of the engine reads, or one older, which a newer version of it fixes. */
644
+ function apiRefusal(described, unread) {
645
+ const newer = described.api !== undefined && described.api > packageApi;
646
+ return new Refusal(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`, newer ? "engine-too-old" : "package-too-old", {
647
+ name: described.name,
648
+ version: described.version,
649
+ });
650
+ }
614
651
  /** The installed extension of this package, when it reads; undefined when it is missing or broken. */
615
652
  function usable(context, name) {
616
653
  try {
@@ -672,7 +709,7 @@ function removed(root, context, name) {
672
709
  const found = Object.keys(listed).find((candidate) => candidate === name || comparableText(shortName(candidate)) === comparableText(name));
673
710
  if (found === undefined) {
674
711
  const names = Object.keys(listed).map(shortName);
675
- throw new Error(`The campaign does not use ${name}${names.length === 0 ? ": it uses no package" : `; it uses ${names.join(", ")}`}. Nothing changed.`);
712
+ throw new Refusal(`The campaign does not use ${name}${names.length === 0 ? ": it uses no package" : `; it uses ${names.join(", ")}`}. Nothing changed.`, "not-used", { name });
676
713
  }
677
714
  const rest = Object.fromEntries(Object.entries(listed).filter(([candidate]) => candidate !== found));
678
715
  changeExtensions(root, rest);
@@ -684,7 +721,7 @@ async function uninstalled(root, context, name) {
684
721
  const packages = context.packages;
685
722
  const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === name || comparableText(one.name) === comparableText(name)));
686
723
  if (system?.used === true) {
687
- throw new Error(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`);
724
+ throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
688
725
  }
689
726
  const other = system?.package ?? languagesHere(context).find((one) => one.package === name || comparableText(one.code) === comparableText(name))?.package;
690
727
  const found = other === undefined
@@ -695,13 +732,13 @@ async function uninstalled(root, context, name) {
695
732
  if (found === undefined && packages !== undefined && isPackageName(npmName) && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0)) {
696
733
  const why = await packages.uninstall(npmName);
697
734
  if (why !== undefined) {
698
- throw new Error(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`);
735
+ throw new Refusal(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`, "uninstall-failed", { name: npmName, why });
699
736
  }
700
737
  return { kind: "uninstalled", name: npmName, wasUsed: false, extension: false };
701
738
  }
702
739
  if (found === undefined) {
703
740
  const here = installedExtensions(context.extensionFolders ?? []).map((one) => shortName(one.package));
704
- throw new Error(`${name} is not on this computer${here.length === 0 ? ": no package is" : `; these are: ${here.join(", ")}`}. Nothing changed.`);
741
+ throw new Refusal(`${name} is not on this computer${here.length === 0 ? ": no package is" : `; these are: ${here.join(", ")}`}. Nothing changed.`, "not-here", { name });
705
742
  }
706
743
  if (packages === undefined) {
707
744
  throw new Error("Packages are uninstalled only by the game's server or the command line, which reach npm.");
@@ -709,7 +746,7 @@ async function uninstalled(root, context, name) {
709
746
  const folder = installedExtensionFolder(context, found.package);
710
747
  const why = await packages.uninstall(found.package);
711
748
  if (why !== undefined) {
712
- throw new Error(`${found.package} could not be uninstalled: ${why}. Nothing changed.`);
749
+ throw new Refusal(`${found.package} could not be uninstalled: ${why}. Nothing changed.`, "uninstall-failed", { name: found.package, why });
713
750
  }
714
751
  // Off this computer, its yes goes with it: installed again, it is asked again.
715
752
  if (folder !== undefined) {
@@ -4,7 +4,7 @@ import { houseRulesFolderName, readListSetting, readTextSetting, requireCampaign
4
4
  import { defineCommand } from "../core/registry.js";
5
5
  import { comparableText } from "../core/text.js";
6
6
  import { findPage, pageFileNamed, pageNamed as pageWithName, sectionTitles } from "../pages/index.js";
7
- import { bookTitles, findRules, hasAllWords, readRuleBook, shownRules } from "../rules/index.js";
7
+ import { bookTitles, findRules, hasAllWords, isTitled, readRuleBook, shownRules } from "../rules/index.js";
8
8
  import { systemContentFolders } from "../systems/index.js";
9
9
  import { libraryAnswer, libraryLines, systemWordsNamed } from "./shared/library.js";
10
10
  import { disagreementAdvice, hasTranslatedRules, houseRules, precedentRule, systemRuleBook } from "./shared/rules.js";
@@ -62,7 +62,9 @@ export const rules = defineCommand({
62
62
  const systemNames = ownNames.map((one) => one.named);
63
63
  // A name answers for the system only when its words are the whole search: tiro per colpire is no question about Archery, Tiro.
64
64
  const answering = ownNames.filter((one) => one.whole).map((one) => one.named);
65
- const found = findRules([...house, ...book], [text, ...systemNames].join(" "));
65
+ // A text that is a section's title reads that section, by its own title or the one it has in the system's language (D-542).
66
+ const titled = [...house, ...book].some((section) => isTitled(section, text));
67
+ const found = findRules([...house, ...book], titled ? text : [text, ...systemNames].join(" "));
66
68
  const houseAnswer = answerOf(found.filter((finding) => finding.section.source === houseRules), budget);
67
69
  const systemAnswer = answerOf(found.filter((finding) => finding.section.source !== houseRules), budget - houseAnswer.used);
68
70
  const shownTitles = withEnglishTitles([...houseAnswer.shown, ...systemAnswer.shown].map((shown) => shown.path.at(-1) ?? ""), translated ? campaignSystemWords(root, context) : undefined);
@@ -5,6 +5,7 @@ import { parse, parseDocument, stringify, visit } from "yaml";
5
5
  import { adventureFolderName, adventureTarget, isAdventureFolder, largestAdventure, manifestLine, packAdventure, readAdventureFolder, readAdventureZip } from "../../adventures/index.js";
6
6
  import { houseRulesFolderName, readSettings } from "../../campaign/index.js";
7
7
  import { appendLogEntry, readLog } from "../../core/log.js";
8
+ import { Refusal } from "../../core/refusal.js";
8
9
  import { files } from "../../core/store.js";
9
10
  import { comparableText, linkTargetName } from "../../core/text.js";
10
11
  import { isNewerVersion } from "../../core/version.js";
@@ -27,7 +28,7 @@ const documentPattern = /\.(pdf|docx?|odt|rtf|txt|md|epub)$/i;
27
28
  /** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
28
29
  export function isAdventureSpec(spec) {
29
30
  if (documentPattern.test(spec)) {
30
- throw new Error(`${spec} is a document, not a package: make an adventure from it with import; package install takes only what has adventure.yaml. Nothing changed.`);
31
+ throw new Refusal(`${spec} is a document, not a package: make an adventure from it with import; package install takes only what has adventure.yaml. Nothing changed.`, "document", { name: spec });
31
32
  }
32
33
  return /\.zip$/i.test(spec) || /^https:\/\//i.test(spec) || isAdventureFolder(resolve(spec));
33
34
  }
@@ -45,7 +46,7 @@ export async function readAdventureSpec(spec, context) {
45
46
  if (/\.zip$/i.test(spec)) {
46
47
  const bytes = files().bytes(path);
47
48
  if (bytes === undefined) {
48
- throw new Error(`There is no file ${path}: give the path of the adventure's .zip. Nothing changed.`);
49
+ throw new Refusal(`There is no file ${path}: give the path of the adventure's .zip. Nothing changed.`, "not-on-computer", { name: path });
49
50
  }
50
51
  return readAdventureZip(bytes, basename(path));
51
52
  }
@@ -61,13 +62,18 @@ export function installAdventure(root, context, adventure, from) {
61
62
  const there = installedAdventures(root).find((one) => comparableText(one.title) === comparableText(manifest.title));
62
63
  if (there !== undefined) {
63
64
  if (there.version !== manifest.version) {
64
- throw new Error(`The campaign has ${manifest.title} ${there.version}: a played adventure is not updated. Nothing changed.`);
65
+ throw new Refusal(`The campaign has ${manifest.title} ${there.version}: a played adventure is not updated. Nothing changed.`, "adventure-played", {
66
+ name: manifest.title,
67
+ version: there.version,
68
+ });
65
69
  }
66
70
  return { ...describe(root, context, adventure, there.shift, [], []), already: true };
67
71
  }
68
72
  const stopped = installMark(root);
69
73
  if (stopped !== undefined && comparableText(stopped.title) !== comparableText(manifest.title)) {
70
- throw new Error(`The install of ${stopped.title} stopped halfway: finish it first with package install ${stopped.from}. Nothing changed.`);
74
+ throw new Refusal(`The install of ${stopped.title} stopped halfway: finish it first with package install ${stopped.from}. Nothing changed.`, "adventure-halfway", {
75
+ name: stopped.title,
76
+ });
71
77
  }
72
78
  checkNeeds(root, context, manifest);
73
79
  const shift = stopped?.shift ?? Math.max(0, (readPresent(root).date?.day ?? 1) - 1);
@@ -75,8 +81,8 @@ export function installAdventure(root, context, adventure, from) {
75
81
  if (plan.problems.length > 0) {
76
82
  const listed = plan.problems.slice(0, 10).join("; ");
77
83
  const more = plan.problems.length > 10 ? `; and ${plan.problems.length - 10} more` : "";
78
- throw new Error(`${manifest.title} cannot be installed: ${listed}${more}. Rename the adventure's pages in its folder, or the campaign's with rename if the player has not met them, `
79
- + "and install it again. Nothing changed.");
84
+ throw new Refusal(`${manifest.title} cannot be installed: ${listed}${more}. Rename the adventure's pages in its folder, or the campaign's with rename if the player has not met them, `
85
+ + "and install it again. Nothing changed.", "adventure-names", { name: manifest.title, names: `${listed}${more}` });
80
86
  }
81
87
  const mark = join(root, installMarkName);
82
88
  files().write(mark, stringify({ title: manifest.title, shift, from }));
@@ -91,7 +97,7 @@ export function installAdventure(root, context, adventure, from) {
91
97
  export function removeAdventure(root, context, adventure) {
92
98
  const touching = storyTouching(root, adventure);
93
99
  if (touching !== undefined) {
94
- throw new Error(`${adventure.title} is part of the story now: the log names its pages${touching.date === undefined ? "" : ` on ${touching.date}`}. It stays; nothing changed.`);
100
+ throw new Refusal(`${adventure.title} is part of the story now: the log names its pages${touching.date === undefined ? "" : ` on ${touching.date}`}. It stays; nothing changed.`, "adventure-in-story", { name: adventure.title });
95
101
  }
96
102
  // A file already gone, by hand or by a remove that stopped, is no reason to stop.
97
103
  for (const path of adventure.files.map((one) => join(root, ...one.split("/"))).filter((one) => files().exists(one))) {
@@ -194,16 +200,19 @@ function adventuresOfLog(log) {
194
200
  function checkNeeds(root, context, manifest) {
195
201
  const settings = readSettings(root);
196
202
  if (manifest.needs.system !== undefined && comparableText(manifest.needs.system) !== comparableText(settings.system ?? "")) {
197
- throw new Error(`${manifest.title} is for the game system ${manifest.needs.system}, and the campaign plays ${settings.system ?? "none yet"}: it cannot be installed here. Nothing changed.`);
203
+ throw new Refusal(`${manifest.title} is for the game system ${manifest.needs.system}, and the campaign plays ${settings.system ?? "none yet"}: it cannot be installed here. Nothing changed.`, "other-system", { name: manifest.title, system: manifest.needs.system, plays: settings.system ?? "" });
198
204
  }
199
205
  const listed = listedExtensions(root);
200
206
  for (const [name, lowest] of Object.entries(manifest.needs.extensions)) {
201
207
  const found = Object.keys(listed).find((one) => one === name || comparableText(shortName(one)) === comparableText(shortName(name)));
202
208
  if (found === undefined) {
203
- throw new Error(`${manifest.title} needs the extension ${name}: install it with package install ${shortName(name)} first. Nothing changed.`);
209
+ throw new Refusal(`${manifest.title} needs the extension ${name}: install it with package install ${shortName(name)} first. Nothing changed.`, "adventure-needs", {
210
+ name: manifest.title,
211
+ needs: shortName(name),
212
+ });
204
213
  }
205
214
  if (isNewerVersion(lowest, listed[found])) {
206
- throw new Error(`${manifest.title} needs ${name} ${lowest} or later, and the campaign has ${listed[found]}: install the newer with package install ${shortName(name)}. Nothing changed.`);
215
+ throw new Refusal(`${manifest.title} needs ${name} ${lowest} or later, and the campaign has ${listed[found]}: install the newer with package install ${shortName(name)}. Nothing changed.`, "adventure-needs-newer", { name: manifest.title, needs: shortName(name), version: lowest, has: listed[found] });
207
216
  }
208
217
  }
209
218
  if (manifest.levels !== undefined && campaignSystem(root, context)?.progression?.level === undefined) {
@@ -320,7 +329,7 @@ function startingFiles(root, context) {
320
329
  }
321
330
  const played = readLog(root).some((entry) => entry.type === "scene-opened") || campaignMode(root, campaignWorld(root, context)) === "play";
322
331
  if (played) {
323
- throw new Error("The campaign has been played, and has no save of its start: what it is now goes on as a save of the whole game, not as an adventure. Nothing was written.");
332
+ throw new Refusal("The campaign has been played, and has no save of its start: what it is now goes on as a save of the whole game, not as an adventure. Nothing was written.", "export-played");
324
333
  }
325
334
  const held = {};
326
335
  const log = files().bytes(join(root, "log.jsonl"));
@@ -2,6 +2,7 @@
2
2
  // finds in the books, after the game system's rules.
3
3
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
4
4
  import { campaignFileName, findCampaign, readListSetting, readTextSetting } from "../../campaign/index.js";
5
+ import { Refusal } from "../../core/refusal.js";
5
6
  import { comparableText } from "../../core/text.js";
6
7
  import { documentAt, documentKinds } from "../../documents/index.js";
7
8
  import { dropUnlisted, foldersIn, isWithin, libraryFolders, libraryReader, libraryState, mostBooks, samePath, saveLibraryFolders } from "../../library/index.js";
@@ -31,18 +32,23 @@ export async function libraryAdditions(root, context, given) {
31
32
  for (const entry of entries) {
32
33
  const found = documentAt(entry);
33
34
  if (found === undefined) {
34
- throw new Error(`There is no ${entry}: give the full path of a folder of the player's books, or of a book. Nothing changed.`);
35
+ throw new Refusal(`There is no ${entry}: give the full path of a folder of the player's books, or of a book. Nothing changed.`, "not-on-computer", { name: entry });
35
36
  }
36
37
  if (found === "file" && !documentKinds.some((kind) => entry.toLowerCase().endsWith(kind))) {
37
- throw new Error(`${basename(entry)} is no book the engine reads: give a ${documentKinds.join(", ")} file, or a folder of them. Nothing changed.`);
38
+ throw new Refusal(`${basename(entry)} is no book the engine reads: give a ${documentKinds.join(", ")} file, or a folder of them. Nothing changed.`, "not-a-book", {
39
+ name: basename(entry),
40
+ kinds: documentKinds.join(", "),
41
+ });
38
42
  }
39
43
  // A book is looked for from its folder: a file is no folder to hold a campaign.yaml, and Linux says so.
40
44
  const campaign = findCampaign(found === "file" ? dirname(entry) : entry);
41
45
  if (campaign !== undefined) {
42
- throw new Error(`${entry} is inside the campaign in ${campaign}: the library is the player's own books, outside every campaign. Nothing changed.`);
46
+ throw new Refusal(`${entry} is inside the campaign in ${campaign}: the library is the player's own books, outside every campaign. Nothing changed.`, "books-in-campaign", {
47
+ name: entry,
48
+ });
43
49
  }
44
50
  if (found === "folder" && context.bookIndex !== undefined && libraryState(context.bookIndex, [entry], libraryScope).crowded.length > 0) {
45
- throw new Error(`${entry} holds more than ${mostBooks} documents, and a shelf of a game's books has from 5 to 50: give the folder inside it with this game's books${insideOf(context, entry)}. Nothing changed.`);
51
+ throw new Refusal(`${entry} holds more than ${mostBooks} documents, and a shelf of a game's books has from 5 to 50: give the folder inside it with this game's books${insideOf(context, entry)}. Nothing changed.`, "books-crowded", { name: entry, count: String(mostBooks) });
46
52
  }
47
53
  }
48
54
  const index = context.bookIndex;
@@ -390,7 +396,9 @@ function onlyOne(items) {
390
396
  function libraryPath(context, given) {
391
397
  const entry = unquoted(given);
392
398
  if (!isAbsolute(entry) && context.terminal !== true) {
393
- throw new Error(`${entry} is no full path: give the whole path of a folder of the player's books, or of a book, from its drive or its root. Nothing changed.`);
399
+ throw new Refusal(`${entry} is no full path: give the whole path of a folder of the player's books, or of a book, from its drive or its root. Nothing changed.`, "not-full-path", {
400
+ name: entry,
401
+ });
394
402
  }
395
403
  return resolve(context.folder, entry);
396
404
  }
@@ -21,6 +21,8 @@ export interface CatalogEntry {
21
21
  version: string;
22
22
  engine?: string;
23
23
  };
24
+ /** The game system an extension is made for, as its package.json says (D-548). */
25
+ system?: string;
24
26
  /** An adventure's levels, length and language, as its adventure.yaml says. */
25
27
  levels?: string;
26
28
  length?: string;
@@ -69,6 +69,7 @@ function npmEntry(found, installed) {
69
69
  ...(installed === undefined ? {} : { installed }),
70
70
  update: installed !== undefined && isNewerVersion(found.version, installed),
71
71
  ...(found.newer === undefined ? {} : { newer: found.newer }),
72
+ ...(found.kind === "extension" && found.system !== undefined ? { system: found.system } : {}),
72
73
  };
73
74
  }
74
75
  /** The version of this npm package installed here: an extension's, or a game system's. */