rpg-engine 0.4.1 → 0.6.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 (231) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/settings.d.ts +1 -0
  3. package/dist/campaign/settings.js +6 -5
  4. package/dist/command-line.js +12 -5
  5. package/dist/commands/advance.js +1 -1
  6. package/dist/commands/ask.d.ts +37 -2
  7. package/dist/commands/ask.js +106 -35
  8. package/dist/commands/change.js +28 -17
  9. package/dist/commands/config.d.ts +1 -1
  10. package/dist/commands/config.js +69 -21
  11. package/dist/commands/effect.js +42 -23
  12. package/dist/commands/find.js +1 -1
  13. package/dist/commands/game-adventures.js +2 -2
  14. package/dist/commands/game-catalog.d.ts +13 -0
  15. package/dist/commands/game-catalog.js +26 -2
  16. package/dist/commands/game-checks.js +23 -21
  17. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  18. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  19. package/dist/commands/game-effects.d.ts +12 -4
  20. package/dist/commands/game-effects.js +21 -13
  21. package/dist/commands/game-examples.d.ts +22 -0
  22. package/dist/commands/game-examples.js +72 -0
  23. package/dist/commands/game-extension-list.d.ts +31 -3
  24. package/dist/commands/game-extension-list.js +94 -6
  25. package/dist/commands/game-images.d.ts +1 -1
  26. package/dist/commands/game-images.js +3 -2
  27. package/dist/commands/game-library.d.ts +3 -0
  28. package/dist/commands/game-library.js +2 -2
  29. package/dist/commands/game-mode.js +1 -1
  30. package/dist/commands/game-package-code.d.ts +87 -0
  31. package/dist/commands/game-package-code.js +648 -0
  32. package/dist/commands/game-package-hooks.d.ts +37 -0
  33. package/dist/commands/game-package-hooks.js +116 -0
  34. package/dist/commands/game-recipes.js +2 -2
  35. package/dist/commands/game-reminders.d.ts +5 -2
  36. package/dist/commands/game-reminders.js +7 -4
  37. package/dist/commands/game-rules.d.ts +4 -1
  38. package/dist/commands/game-rules.js +7 -1
  39. package/dist/commands/game-upkeep.js +3 -3
  40. package/dist/commands/game-view-place.d.ts +8 -20
  41. package/dist/commands/game-view-place.js +16 -35
  42. package/dist/commands/game-widgets.d.ts +42 -8
  43. package/dist/commands/game-widgets.js +182 -31
  44. package/dist/commands/game-world.d.ts +32 -3
  45. package/dist/commands/game-world.js +113 -24
  46. package/dist/commands/image.js +1 -1
  47. package/dist/commands/init.js +2 -2
  48. package/dist/commands/mode.d.ts +1 -1
  49. package/dist/commands/package.d.ts +15 -1
  50. package/dist/commands/package.js +96 -24
  51. package/dist/commands/progression.d.ts +2 -0
  52. package/dist/commands/progression.js +7 -2
  53. package/dist/commands/roll.d.ts +2 -0
  54. package/dist/commands/roll.js +50 -24
  55. package/dist/commands/rules.js +6 -4
  56. package/dist/commands/scene.d.ts +2 -2
  57. package/dist/commands/scene.js +13 -10
  58. package/dist/commands/sheet.js +10 -1
  59. package/dist/commands/status.d.ts +1 -0
  60. package/dist/commands/status.js +14 -4
  61. package/dist/commands/trade.js +6 -4
  62. package/dist/commands/translate.js +2 -2
  63. package/dist/commands/travel.js +1 -1
  64. package/dist/commands/validate.js +2 -2
  65. package/dist/commands/view.d.ts +12 -4
  66. package/dist/commands/view.js +11 -8
  67. package/dist/commands/worked-out.js +11 -5
  68. package/dist/commands/write.d.ts +8 -1
  69. package/dist/commands/write.js +84 -25
  70. package/dist/core/command-reference.js +3 -2
  71. package/dist/core/consents.d.ts +18 -0
  72. package/dist/core/consents.js +93 -0
  73. package/dist/core/context.d.ts +68 -27
  74. package/dist/core/context.js +3 -1
  75. package/dist/core/examples.d.ts +25 -0
  76. package/dist/core/examples.js +19 -0
  77. package/dist/core/files.d.ts +2 -0
  78. package/dist/core/files.js +10 -1
  79. package/dist/core/package-api.d.ts +388 -0
  80. package/dist/core/package-declarations.d.ts +102 -0
  81. package/dist/core/package-declarations.js +81 -0
  82. package/dist/core/registry.d.ts +4 -0
  83. package/dist/core/text.d.ts +5 -0
  84. package/dist/core/text.js +12 -0
  85. package/dist/dashboard/acts.js +31 -24
  86. package/dist/dashboard/address.js +4 -1
  87. package/dist/dashboard/api.js +65 -3
  88. package/dist/dashboard/app.js +222 -98
  89. package/dist/dashboard/ask-card.js +169 -0
  90. package/dist/dashboard/asked-dice.js +57 -0
  91. package/dist/dashboard/dice/tray.js +6 -4
  92. package/dist/dashboard/extension-widgets.js +136 -16
  93. package/dist/dashboard/faces.js +6 -4
  94. package/dist/dashboard/help.js +10 -3
  95. package/dist/dashboard/i18n/ar.json +34 -29
  96. package/dist/dashboard/i18n/cs.json +34 -29
  97. package/dist/dashboard/i18n/da.json +34 -29
  98. package/dist/dashboard/i18n/de.json +34 -29
  99. package/dist/dashboard/i18n/el.json +34 -29
  100. package/dist/dashboard/i18n/es.json +34 -29
  101. package/dist/dashboard/i18n/fi.json +34 -29
  102. package/dist/dashboard/i18n/fr.json +34 -29
  103. package/dist/dashboard/i18n/he.json +34 -29
  104. package/dist/dashboard/i18n/hi.json +34 -29
  105. package/dist/dashboard/i18n/hu.json +34 -29
  106. package/dist/dashboard/i18n/is.json +34 -29
  107. package/dist/dashboard/i18n/it.json +34 -29
  108. package/dist/dashboard/i18n/ja.json +34 -29
  109. package/dist/dashboard/i18n/ko.json +34 -29
  110. package/dist/dashboard/i18n/nb.json +34 -29
  111. package/dist/dashboard/i18n/nl.json +34 -29
  112. package/dist/dashboard/i18n/pl.json +34 -29
  113. package/dist/dashboard/i18n/pt.json +34 -29
  114. package/dist/dashboard/i18n/ro.json +34 -29
  115. package/dist/dashboard/i18n/ru.json +34 -29
  116. package/dist/dashboard/i18n/sv.json +34 -29
  117. package/dist/dashboard/i18n/tr.json +34 -29
  118. package/dist/dashboard/i18n/uk.json +34 -29
  119. package/dist/dashboard/i18n/zh.json +34 -29
  120. package/dist/dashboard/icons.js +4 -1
  121. package/dist/dashboard/kit.js +35 -0
  122. package/dist/dashboard/labels.js +1 -0
  123. package/dist/dashboard/pack-card.js +97 -0
  124. package/dist/dashboard/package-page.js +50 -0
  125. package/dist/dashboard/packages.js +180 -24
  126. package/dist/dashboard/page-code.js +248 -0
  127. package/dist/dashboard/party.js +13 -14
  128. package/dist/dashboard/people.js +4 -0
  129. package/dist/dashboard/person-panel.js +110 -0
  130. package/dist/dashboard/place-map-view.js +11 -6
  131. package/dist/dashboard/rolls.js +2 -2
  132. package/dist/dashboard/scene.js +12 -9
  133. package/dist/dashboard/settings.js +55 -9
  134. package/dist/dashboard/sheet.js +21 -13
  135. package/dist/dashboard/status.js +69 -15
  136. package/dist/dashboard/style.css +859 -574
  137. package/dist/dashboard/top.js +75 -25
  138. package/dist/dashboard/turns.js +34 -13
  139. package/dist/dashboard/widgets.js +9 -2
  140. package/dist/dashboard-server.js +246 -11
  141. package/dist/dice/roll-dice.js +1 -1
  142. package/dist/effects/effect.d.ts +7 -4
  143. package/dist/effects/effect.js +12 -9
  144. package/dist/extensions/engine.d.ts +4 -0
  145. package/dist/extensions/engine.js +74 -0
  146. package/dist/extensions/extension.d.ts +28 -33
  147. package/dist/extensions/extension.js +37 -46
  148. package/dist/extensions/index.d.ts +4 -3
  149. package/dist/extensions/index.js +5 -2
  150. package/dist/extensions/packages.d.ts +14 -0
  151. package/dist/extensions/packages.js +148 -12
  152. package/dist/extensions/words.d.ts +2 -1
  153. package/dist/extensions/words.js +5 -4
  154. package/dist/index.d.ts +1 -3
  155. package/dist/mcp-server.js +52 -15
  156. package/dist/page-words.d.ts +4 -0
  157. package/dist/page-words.js +4 -4
  158. package/dist/page.d.ts +218 -0
  159. package/dist/page.js +2 -0
  160. package/dist/pages/index.d.ts +1 -1
  161. package/dist/pages/index.js +1 -1
  162. package/dist/pages/load.d.ts +7 -1
  163. package/dist/pages/load.js +10 -5
  164. package/dist/pages/page-file.js +1 -1
  165. package/dist/pages/stack-writes.js +5 -4
  166. package/dist/pages/standard-fields.d.ts +2 -0
  167. package/dist/pages/standard-fields.js +8 -1
  168. package/dist/pages/world.d.ts +8 -0
  169. package/dist/pages/world.js +9 -2
  170. package/dist/systems/game-system.d.ts +61 -30
  171. package/dist/systems/game-system.js +159 -50
  172. package/dist/systems/index.d.ts +3 -3
  173. package/dist/systems/index.js +3 -3
  174. package/dist/systems/system-code.d.ts +29 -88
  175. package/dist/systems/system-code.js +68 -23
  176. package/dist/systems/words.d.ts +2 -0
  177. package/dist/systems/words.js +11 -0
  178. package/dist/testing.d.ts +76 -0
  179. package/dist/testing.js +197 -0
  180. package/instructions/combat.md +2 -2
  181. package/instructions/core.md +2 -2
  182. package/instructions/dashboard.md +1 -1
  183. package/instructions/mentor-tutorial.md +1 -1
  184. package/instructions/play.md +2 -2
  185. package/instructions/setup.md +1 -1
  186. package/package.json +15 -2
  187. package/systems/5e/LICENSE.md +13 -3
  188. package/systems/5e/dist/dying.js +83 -16
  189. package/systems/5e/dist/index.js +2 -2
  190. package/systems/5e/dist/page-style.js +634 -0
  191. package/systems/5e/dist/page.js +166 -0
  192. package/systems/5e/dist/shown.js +23 -0
  193. package/systems/5e/instructions/combat.md +1 -0
  194. package/systems/5e/package.json +4 -2
  195. package/systems/5e/system.yaml +35 -7
  196. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  197. package/systems/5e/words/ar.yaml +30 -0
  198. package/systems/5e/words/cs.yaml +30 -0
  199. package/systems/5e/words/da.yaml +30 -0
  200. package/systems/5e/words/de.yaml +30 -0
  201. package/systems/5e/words/el.yaml +30 -0
  202. package/systems/5e/words/es.yaml +30 -0
  203. package/systems/5e/words/fi.yaml +30 -0
  204. package/systems/5e/words/fr.yaml +30 -0
  205. package/systems/5e/words/he.yaml +30 -0
  206. package/systems/5e/words/hi.yaml +30 -0
  207. package/systems/5e/words/hu.yaml +30 -0
  208. package/systems/5e/words/is.yaml +30 -0
  209. package/systems/5e/words/it.yaml +30 -0
  210. package/systems/5e/words/ja.yaml +30 -0
  211. package/systems/5e/words/ko.yaml +30 -0
  212. package/systems/5e/words/nb.yaml +30 -0
  213. package/systems/5e/words/nl.yaml +30 -0
  214. package/systems/5e/words/pl.yaml +30 -0
  215. package/systems/5e/words/pt.yaml +30 -0
  216. package/systems/5e/words/ro.yaml +30 -0
  217. package/systems/5e/words/ru.yaml +30 -0
  218. package/systems/5e/words/sv.yaml +30 -0
  219. package/systems/5e/words/tr.yaml +30 -0
  220. package/systems/5e/words/uk.yaml +30 -0
  221. package/systems/5e/words/zh.yaml +30 -0
  222. package/dist/commands/game-extensions.d.ts +0 -34
  223. package/dist/commands/game-extensions.js +0 -182
  224. package/dist/commands/game-system-code.d.ts +0 -25
  225. package/dist/commands/game-system-code.js +0 -172
  226. package/dist/dashboard/death-save.js +0 -67
  227. package/dist/dashboard/dying.js +0 -46
  228. package/dist/dashboard/save-outcome.js +0 -42
  229. package/dist/dashboard/spend.js +0 -115
  230. package/dist/extensions/api.d.ts +0 -155
  231. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -1,26 +1,42 @@
1
1
  import { type InstructionPart } from "../core/instruction-parts.ts";
2
+ import { type DeclaredWidget, type FigureSize } from "../core/package-declarations.ts";
2
3
  /** The file that makes a folder an extension of rpg-engine (D-427). */
3
4
  export declare const extensionFileName = "extension.yaml";
5
+ /** What an extension may add to the campaign's game system in extension.yaml, written as campaign.yaml writes it (CAM-2, D-505). */
6
+ export declare const systemAdditionNames: readonly ["fields", "tables", "computed", "counters", "recipes", "values", "condition-icons"];
7
+ /** What an extension adds to the game system, by key, as extension.yaml writes it: the system checks it when it is read with it (CAM-3). */
8
+ export type SystemAdditions = Partial<Record<(typeof systemAdditionNames)[number], Record<string, unknown>>>;
4
9
  /**
5
- * The version of the API an extension's code is given (api.ts), which its package.json names: 2 added the widgets (D-502). A package made for this one or an
6
- * older one is read; one made for a newer one is refused, as an older rpg-engine refuses this one's.
10
+ * A package that brings its code to a campaign (D-513, D-514): one of its extensions, or its game system; the same contract and the same parts, the kind
11
+ * deciding only its role.
7
12
  */
8
- export declare const extensionApi = 2;
9
- /** Whether this rpg-engine reads a package made for this version of the API: from 1 up to its own. */
10
- export declare function readsApi(api: number | undefined): boolean;
11
- /** An installed extension (D-28, D-427, D-428): an npm package with an extension.yaml, its parts of the instructions and, when it has some, its code. */
12
- export interface Extension {
13
+ export interface CodePackage {
14
+ kind: "extension" | "system";
13
15
  /** The package's name, as npm and campaign.yaml write it: @rpgengine/weather. */
14
16
  package: string;
15
- /** The name its commands start with: the package's without its scope, weather (D-63). */
17
+ /** The name its commands and widgets start with (D-63): an extension's package's without its scope, weather; a system's as the campaign plays it, 5e. */
16
18
  name: string;
17
19
  version: string;
18
20
  folder: string;
19
21
  title: string;
20
- /** The line the master reads in the list of extensions (D-28). */
21
- about: string;
22
22
  /** The language its texts are written in, as a code such as en. */
23
23
  language: string;
24
+ /** Its icons by name, each the path of an SVG drawn on 24 by 24, as the dashboard strokes it (D-502). */
25
+ icons: Record<string, string>;
26
+ /** Its widgets on the dashboard, in the order written, each where it puts itself (D-502). */
27
+ widgets: DeclaredWidget[];
28
+ /** The file of its code for the dashboard's page, when it has some: the module whose default export draws its figures (D-510). */
29
+ page?: string;
30
+ /** The figures its page code draws, by name, with the room each takes on a wide screen; mirror, turned right to left, as it holds no words (D-510). */
31
+ figures: Record<string, FigureSize>;
32
+ /** Installed from a folder of this computer, which npm links: never verified, whatever its name (D-428). */
33
+ linked: boolean;
34
+ }
35
+ /** An installed extension (D-28, D-427, D-428): an npm package with an extension.yaml, its parts of the instructions and, when it has some, its code. */
36
+ export interface Extension extends CodePackage {
37
+ kind: "extension";
38
+ /** The line the master reads in the list of extensions (D-28). */
39
+ about: string;
24
40
  attribution?: string;
25
41
  /** The game system it needs, when it needs one (D-163). */
26
42
  needs: {
@@ -28,33 +44,12 @@ export interface Extension {
28
44
  };
29
45
  /** Its months in place of the core's, as extension.yaml writes them: the time module reads them (TIM-8). */
30
46
  calendar?: unknown;
31
- /** Its icons by name, each the path of an SVG drawn on 24 by 24, as the dashboard strokes it (D-502). */
32
- icons: Record<string, string>;
33
- /** Its widgets on the dashboard, in the order written, each where it puts itself (D-502). */
34
- widgets: DeclaredWidget[];
47
+ /** What it adds to the game system, under the campaign's own additions (CAM-2). */
48
+ adds: SystemAdditions;
35
49
  /** Its parts of the master's instructions, by name (D-121). */
36
50
  parts: Record<string, InstructionPart>;
37
51
  /** The file of its code, when it has some: the module whose default export gives its commands (D-428). */
38
52
  code?: string;
39
- /** Installed from a folder of this computer, which npm links: never verified, whatever its name (D-428). */
40
- linked: boolean;
41
- }
42
- /** The places of the dashboard a widget may stand in (D-502): a chip in the top, a card in the table's column beside the rolls, or a card in a page. */
43
- export declare const widgetPlaces: readonly ["top", "side", "page"];
44
- /** The pages a widget's card may stand in: the Scene, the sheet, the World and the Journal. */
45
- export declare const widgetPages: readonly ["scene", "sheet", "world", "journal"];
46
- export type WidgetPlace = (typeof widgetPlaces)[number];
47
- export type WidgetPage = (typeof widgetPages)[number];
48
- /** A widget as extension.yaml declares it (D-502): its name, which its code's hook has, its title, its icon, and where it stands, among the cards in order. */
49
- export interface DeclaredWidget {
50
- name: string;
51
- title: string;
52
- icon?: string;
53
- place: WidgetPlace;
54
- /** The page of a card that stands in one. */
55
- page?: WidgetPage;
56
- /** Its order among the cards of its place, the lowest first. */
57
- order: number;
58
53
  }
59
54
  /** The extensions installed in these folders, each a package folder, or a scope's folder of them as npm keeps them (@rpgengine/weather); the first by a name wins. */
60
55
  export declare function installedExtensions(folders: string[]): {
@@ -1,9 +1,10 @@
1
1
  import { existsSync } from "node:fs";
2
- import { join } from "node:path";
2
+ import { join, resolve } from "node:path";
3
3
  import { z } from "zod";
4
- import { installedFromFolder, packageFoldersIn } from "../core/files.js";
4
+ import { installedFromFolder, packageFoldersIn, realPath } from "../core/files.js";
5
5
  import { readParts } from "../core/instruction-parts.js";
6
- import { files } from "../core/store.js";
6
+ import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
7
+ import { files, isInside } from "../core/store.js";
7
8
  import { comparableText } from "../core/text.js";
8
9
  import { readYamlValues } from "../core/yaml-file.js";
9
10
  /** The file that makes a folder an extension of rpg-engine (D-427). */
@@ -11,34 +12,10 @@ export const extensionFileName = "extension.yaml";
11
12
  // The longest about and part of the instructions an extension may give, in words (D-441).
12
13
  const aboutWords = 40;
13
14
  const partWords = 400;
14
- /**
15
- * The version of the API an extension's code is given (api.ts), which its package.json names: 2 added the widgets (D-502). A package made for this one or an
16
- * older one is read; one made for a newer one is refused, as an older rpg-engine refuses this one's.
17
- */
18
- export const extensionApi = 2;
19
- /** Whether this rpg-engine reads a package made for this version of the API: from 1 up to its own. */
20
- export function readsApi(api) {
21
- return api !== undefined && Number.isInteger(api) && api >= 1 && api <= extensionApi;
22
- }
23
- /** The places of the dashboard a widget may stand in (D-502): a chip in the top, a card in the table's column beside the rolls, or a card in a page. */
24
- export const widgetPlaces = ["top", "side", "page"];
25
- /** The pages a widget's card may stand in: the Scene, the sheet, the World and the Journal. */
26
- export const widgetPages = ["scene", "sheet", "world", "journal"];
27
- // How many icons and widgets an extension may declare, and the longest path of an icon.
28
- const mostIcons = 40;
29
- const mostWidgets = 8;
30
- const longestPath = 4000;
31
- /** A name of an icon or a widget, as weather or sky-rain. */
32
- const ownName = z.string().regex(/^[a-z][a-z0-9-]*$/, "use lowercase letters, digits and hyphens, as sky-rain");
33
- const widgetSchema = z.object({
34
- title: z.string().trim().min(1).max(40),
35
- icon: ownName.optional(),
36
- place: z.enum(widgetPlaces, { error: `a widget's place is ${widgetPlaces.join(", ")}` }),
37
- page: z.enum(widgetPages, { error: `a card's page is ${widgetPages.join(", ")}` }).optional(),
38
- order: z.int().min(-100).max(100).optional(),
39
- }).strict().refine((widget) => (widget.place === "page") === (widget.page !== undefined), {
40
- error: "a widget in place page names its page (scene, sheet, world or journal), and only one in a page does",
41
- });
15
+ /** What an extension may add to the campaign's game system in extension.yaml, written as campaign.yaml writes it (CAM-2, D-505). */
16
+ export const systemAdditionNames = ["fields", "tables", "computed", "counters", "recipes", "values", "condition-icons"];
17
+ /** An addition to the game system, which the system checks as it reads it (CAM-3). */
18
+ const addition = z.record(z.string(), z.unknown(), { error: "give it as a map by name, as campaign.yaml does" }).optional();
42
19
  const extensionSchema = z.object({
43
20
  title: z.string().trim().min(1),
44
21
  about: z.string().trim().min(1),
@@ -46,16 +23,18 @@ const extensionSchema = z.object({
46
23
  attribution: z.string().trim().min(1).optional(),
47
24
  needs: z.object({ system: z.string().trim().min(1).optional() }).strict().optional(),
48
25
  calendar: z.unknown().optional(),
49
- icons: z.record(ownName, z.string().max(longestPath).regex(/^[MmLlHhVvCcSsQqTtAaZz\d\s,.+-]+$/, "an icon is the path of an SVG, as M4 12h16")).optional(),
50
- widgets: z.record(ownName, widgetSchema).optional(),
26
+ ...packagePartsShape,
27
+ fields: addition,
28
+ tables: addition,
29
+ computed: addition,
30
+ counters: addition,
31
+ recipes: addition,
32
+ values: addition,
33
+ // The drawings of effects by their names, over the system's (D-516).
34
+ "condition-icons": addition,
51
35
  }).strict().superRefine((declared, check) => {
52
- const icons = Object.keys(declared.icons ?? {});
53
- const widgets = Object.entries(declared.widgets ?? {});
54
- if (icons.length > mostIcons || widgets.length > mostWidgets) {
55
- check.addIssue({ code: "custom", message: `an extension declares at most ${mostIcons} icons and ${mostWidgets} widgets` });
56
- }
57
- for (const [name, widget] of widgets.filter(([, widget]) => widget.icon !== undefined && !icons.includes(widget.icon))) {
58
- check.addIssue({ code: "custom", path: ["widgets", name, "icon"], message: `the icon ${widget.icon ?? ""} is not among the icons: add it there` });
36
+ for (const issue of packagePartsIssues(declared, "an extension")) {
37
+ check.addIssue({ code: "custom", ...issue });
59
38
  }
60
39
  });
61
40
  const packageSchema = z.object({
@@ -63,7 +42,7 @@ const packageSchema = z.object({
63
42
  version: z.string().min(1),
64
43
  main: z.string().min(1).optional(),
65
44
  // What says it is a package for rpg-engine, of which kind, and for which version of the API (D-439).
66
- "rpg-engine": z.object({ kind: z.string(), api: z.number().optional() }).optional(),
45
+ "rpg-engine": z.object({ kind: z.string(), api: z.number().optional(), page: z.string().min(1).optional() }).optional(),
67
46
  });
68
47
  /** The extensions installed in these folders, each a package folder, or a scope's folder of them as npm keeps them (@rpgengine/weather); the first by a name wins. */
69
48
  export function installedExtensions(folders) {
@@ -91,15 +70,23 @@ export function readExtension(folder) {
91
70
  }
92
71
  const owner = `The extension ${manifest.data.name}`;
93
72
  const marker = manifest.data["rpg-engine"];
94
- if (marker?.kind !== "extension" || !readsApi(marker.api)) {
95
- const made = marker?.kind !== "extension" ? 'its package.json does not say "rpg-engine": {"kind": "extension"}' : `it is made for the extension API ${marker.api ?? "none"}`;
96
- throw new Error(`${owner} cannot be used, because ${made}; this rpg-engine reads the API 1 to ${extensionApi}: install a version of it made for these.`);
73
+ if (marker?.kind !== "extension") {
74
+ throw new Error(`${owner} cannot be used, because its package.json does not say "rpg-engine": {"kind": "extension"}: install a version of it made for rpg-engine.`);
75
+ }
76
+ const unread = apiProblem(marker.api, "extension");
77
+ if (unread !== undefined) {
78
+ throw new Error(`${owner} cannot be used, because ${unread}.`);
97
79
  }
98
80
  const declared = extensionSchema.safeParse(readYamlValues(where(extensionFileName), "what the extension is, such as title: ..."));
99
81
  if (!declared.success) {
100
82
  throw new Error(`${owner} cannot be read, because its ${extensionFileName} is not valid: ${z.prettifyError(declared.error).replace(/\s+/g, " ")}`);
101
83
  }
102
- const { title, about, language, attribution, needs, calendar, icons, widgets } = declared.data;
84
+ const { title, about, language, attribution, needs, calendar, icons, widgets, figures } = declared.data;
85
+ // Its page code is a file of its own, by real paths, links included (D-510).
86
+ if (marker.page !== undefined && !isInside(realPath(folder), realPath(resolve(folder, marker.page)))) {
87
+ throw new Error(`${owner} cannot be used, because its page, ${marker.page}, is not inside its package: name a file of its own, such as dist/page.js.`);
88
+ }
89
+ const adds = Object.fromEntries(systemAdditionNames.flatMap((key) => (declared.data[key] === undefined ? [] : [[key, declared.data[key]]])));
103
90
  const parts = readParts(folder, owner);
104
91
  // What the master reads of it in every chat, kept short (D-441).
105
92
  const long = [["about", about, aboutWords], ...Object.entries(parts).map(([name, part]) => [`instructions/${name}.md`, part.text, partWords])]
@@ -108,6 +95,7 @@ export function readExtension(folder) {
108
95
  throw new Error(`${owner} cannot be used, because its ${long[0]} has ${words(long[1])} words, and ${long[2]} at most are read.`);
109
96
  }
110
97
  return {
98
+ kind: "extension",
111
99
  package: manifest.data.name,
112
100
  name: shortName(manifest.data.name),
113
101
  version: manifest.data.version,
@@ -118,10 +106,13 @@ export function readExtension(folder) {
118
106
  ...(attribution === undefined ? {} : { attribution }),
119
107
  needs: needs ?? {},
120
108
  ...(calendar === undefined ? {} : { calendar }),
109
+ adds,
121
110
  icons: icons ?? {},
122
- widgets: Object.entries(widgets ?? {}).map(([name, widget]) => ({ name, ...widget, order: widget.order ?? 0 })),
111
+ widgets: declaredWidgets(widgets),
123
112
  parts,
124
113
  ...(manifest.data.main === undefined ? {} : { code: where(manifest.data.main) }),
114
+ ...(marker.page === undefined ? {} : { page: where(marker.page) }),
115
+ figures: figures ?? {},
125
116
  linked: installedFromFolder(folder),
126
117
  };
127
118
  }
@@ -1,5 +1,6 @@
1
- export type { CalendarDay, ExtensionCode, ExtensionCommand, ExtensionEntry, ExtensionKit, Game, GameMoment, GameView, TimePassage, Widget, WidgetPart, WidgetText, WidgetValue } from "./api.ts";
2
- export { type DeclaredWidget, type Extension, extensionApi, extensionFileName, findExtension, installedExtensions, readExtension, readsApi, shortName, type WidgetPage, widgetPages, type WidgetPlace, widgetPlaces } from "./extension.ts";
3
- export { isLocalSpec, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.ts";
1
+ export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.ts";
2
+ export { npmEngine } from "./engine.ts";
3
+ export { type CodePackage, type Extension, extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames, type SystemAdditions } from "./extension.ts";
4
+ export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.ts";
4
5
  export { isTarball } from "./tarball.ts";
5
6
  export { type ExtensionWords, extensionWords, wordIn } from "./words.ts";
@@ -1,4 +1,7 @@
1
- export { extensionApi, extensionFileName, findExtension, installedExtensions, readExtension, readsApi, shortName, widgetPages, widgetPlaces } from "./extension.js";
2
- export { isLocalSpec, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.js";
1
+ // The extensions installed beside the engine (D-427, D-428): which they are and what each declares. Depends on nothing else in rpg-engine.
2
+ export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.js";
3
+ export { npmEngine } from "./engine.js";
4
+ export { extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames } from "./extension.js";
5
+ export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.js";
3
6
  export { isTarball } from "./tarball.js";
4
7
  export { extensionWords, wordIn } from "./words.js";
@@ -18,3 +18,17 @@ export declare function npmPackages(folder: string, run?: (args: string) => Prom
18
18
  export declare function isLocalSpec(spec: string): boolean;
19
19
  /** Whether an installed package is ours, verified: in our scope and installed from npm, never from a folder, which anyone can name so (D-428, D-441). */
20
20
  export declare function isVerified(name: string, linked: boolean): boolean;
21
+ /**
22
+ * Where a package takes reports of its problems, by its package.json: its `bugs` page, else the issues of its repository on GitHub; undefined when it says
23
+ * neither, or not over https.
24
+ */
25
+ export declare function issuesPage(manifest: {
26
+ bugs?: unknown;
27
+ repository?: unknown;
28
+ }): string | undefined;
29
+ /** The code npm's JSON error gives, as ENOTCACHED; undefined when it wrote none. */
30
+ export declare function npmErrorCode(ran: NpmRun): string | undefined;
31
+ /** What npm said went wrong: its JSON error, with --json, else the last line it wrote that is not the pointer to its log. */
32
+ export declare function npmError(ran: NpmRun): string;
33
+ /** Runs npm with these arguments, in a folder of no campaign, stopped with all it started after a while. */
34
+ export declare function runNpm(args: string): Promise<NpmRun>;
@@ -1,12 +1,15 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { cpSync, existsSync, readdirSync, readFileSync, renameSync, rmSync } from "node:fs";
2
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { isAbsolute, join, resolve } from "node:path";
5
+ import { ourScope } from "../core/consents.js";
6
+ import { packageApi, readsApi } from "../core/package-declarations.js";
7
+ import { isNewerVersion } from "../core/version.js";
5
8
  import { isTarball, tarballText, unpackTarball } from "./tarball.js";
6
9
  /** The keyword of the packages for rpg-engine on npm, by which they are found (D-439). */
7
10
  export const packageKeyword = "rpg-engine-package";
8
11
  /** The npm scope of the packages we publish, the verified ones (D-428, D-441). */
9
- export const verifiedScope = "@rpgengine/";
12
+ export const verifiedScope = ourScope;
10
13
  const registry = "https://registry.npmjs.org";
11
14
  // Where the packages given as a .tgz are unpacked, in the packages' folder (D-452).
12
15
  const localFolder = "local";
@@ -22,12 +25,12 @@ const installOptions = "--install-links=true --ignore-scripts --save-exact --no-
22
25
  * npm on this computer, installing in this folder (D-436): never globally, never running a package's scripts, always linking a folder (D-441 tells a package
23
26
  * from a folder by its link). Its registry is read directly; `run` runs npm, a fake in tests.
24
27
  */
25
- export function npmPackages(folder, run = npm) {
28
+ export function npmPackages(folder, run = runNpm) {
26
29
  // What each .tgz said of itself when it was described, before the player's yes: the file installed must still say the same.
27
30
  const described = new Map();
28
31
  return {
29
32
  describe: async (spec) => {
30
- const read = isLocalSpec(spec) ? localPackage(spec) : await registryPackage(spec);
33
+ const read = isLocalSpec(spec) ? localPackage(spec) : await registryPackage(spec).then((found) => ("unreachable" in found ? cachedPackage(spec, run) : found));
31
34
  if (isLocalSpec(spec) && !("failed" in read)) {
32
35
  described.set(resolve(spec), `${read.name}@${read.version}`);
33
36
  }
@@ -38,8 +41,17 @@ export function npmPackages(folder, run = npm) {
38
41
  if (isLocalSpec(spec)) {
39
42
  return await installCopy(folder, spec, described.get(resolve(spec)), run);
40
43
  }
41
- const ran = await run(`install --prefix ${quotedFolder(folder)} ${isLocalSpec(spec) ? quotedFolder(spec) : checkedSpec(spec)} ${installOptions}`);
42
- return ran.code === 0 ? undefined : `npm said: ${npmError(ran)}`;
44
+ // What npm installed of the same version goes aside first, as it would keep it whatever it holds now: the files are npm's (D-510).
45
+ const named = spec.replace(/(?<=.)@[^@/]*$/, "");
46
+ const aside = join(folder, "aside", ...named.split("/"));
47
+ mkdirSync(join(aside, ".."), { recursive: true });
48
+ // Without the registry, from what npm keeps of it on this computer (D-452).
49
+ const install = async () => {
50
+ const ran = await run(`install --prefix ${quotedFolder(folder)} ${checkedSpec(spec)} ${installOptions}`);
51
+ return ran.code !== 0 && isUnreachable(ran) ? await run(`install --prefix ${quotedFolder(folder)} ${checkedSpec(spec)} ${installOptions} --offline`) : ran;
52
+ };
53
+ const ran = await installedAside(join(folder, "node_modules", ...named.split("/")), aside, install);
54
+ return ran.code === 0 ? undefined : npmErrorCode(ran) === "ENOTCACHED" ? offlineAdvice(named) : `npm said: ${npmError(ran)}`;
43
55
  },
44
56
  uninstall: async (name) => {
45
57
  const ran = await run(`uninstall --prefix ${quotedFolder(folder)} ${checkedSpec(name)} --ignore-scripts --no-audit --no-fund --json --loglevel=error`);
@@ -80,17 +92,123 @@ export function isLocalSpec(spec) {
80
92
  export function isVerified(name, linked) {
81
93
  return name.startsWith(verifiedScope) && !linked;
82
94
  }
83
- /** What npm's registry says of a package, at a version or its latest, with what its package.json says for rpg-engine. */
95
+ /**
96
+ * Where a package takes reports of its problems, by its package.json: its `bugs` page, else the issues of its repository on GitHub; undefined when it says
97
+ * neither, or not over https.
98
+ */
99
+ export function issuesPage(manifest) {
100
+ const bugs = httpsLink(typeof manifest.bugs === "string" ? manifest.bugs : fieldOf(manifest.bugs, "url"));
101
+ if (bugs !== undefined) {
102
+ return bugs;
103
+ }
104
+ const repository = typeof manifest.repository === "string" ? manifest.repository : fieldOf(manifest.repository, "url");
105
+ const github = repository === undefined ? null : githubRepository.exec(repository.trim());
106
+ return github === null ? undefined : `https://github.com/${github[1]}/${github[2]}/issues`;
107
+ }
108
+ // A repository on GitHub as package.json may write it: a git, https or ssh address, github:owner/name, or owner/name alone, which npm reads as GitHub's.
109
+ const githubRepository = /^(?:(?:git\+)?(?:https?|git|ssh):\/\/(?:[^@/]+@)?github\.com[/:]|git@github\.com:|github:)?([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?(?:#.*)?$/i;
110
+ /** A field of an object read from JSON, when it is a string. */
111
+ function fieldOf(value, field) {
112
+ const read = typeof value === "object" && value !== null ? value[field] : undefined;
113
+ return typeof read === "string" ? read : undefined;
114
+ }
115
+ /** A link over https, as a page may open it; undefined for anything else. */
116
+ function httpsLink(text) {
117
+ try {
118
+ return text !== undefined && new URL(text).protocol === "https:" ? new URL(text).href : undefined;
119
+ }
120
+ catch {
121
+ return undefined;
122
+ }
123
+ }
124
+ /**
125
+ * What npm says of a package when its registry does not answer here: by npm itself, which reaches it through the proxy it is told of, else from what it keeps
126
+ * of it on this computer (D-452); with the two ways to have it when it has nothing.
127
+ */
128
+ async function cachedPackage(spec, run) {
129
+ const online = await run(`view ${checkedSpec(spec)} --json --loglevel=error`);
130
+ const ran = online.code !== 0 && isUnreachable(online) ? await run(`view ${checkedSpec(spec)} --json --offline --loglevel=error`) : online;
131
+ if (ran.code !== 0) {
132
+ const code = npmErrorCode(ran);
133
+ return code === "E404" ? { failed: `npm has no package ${spec}`, missing: true } : { failed: code === "ENOTCACHED" || isUnreachable(ran) ? offlineAdvice(spec) : `npm said: ${npmError(ran)}` };
134
+ }
135
+ try {
136
+ // A version range gives a list, its newest last.
137
+ const read = JSON.parse(ran.out);
138
+ const manifest = Array.isArray(read) ? read.at(-1) : read;
139
+ return manifest?.name === undefined ? { failed: `npm has no package ${spec}`, missing: true } : infoOf(manifest);
140
+ }
141
+ catch {
142
+ return { failed: `npm said of ${spec} what does not read: ${ran.out.slice(0, 200)}` };
143
+ }
144
+ }
145
+ /** What to do when npm can reach neither its registry nor a copy of the package on this computer (D-452): connect once, or give it as a file or a folder. */
146
+ function offlineAdvice(spec) {
147
+ const name = spec.replace(/(?<=.)@[^@/]*$/, "");
148
+ const file = `${name.replace(/^@/, "").replace("/", "-")}-<version>.tgz`;
149
+ return `npm cannot reach its registry from this computer, and has no copy of ${name} from before: connect the computer to the internet once and install it again, `
150
+ + `or give the package as a .tgz file or a folder of this computer, such as package install D:/Downloads/${file}`;
151
+ }
152
+ // What npm says when it cannot reach its registry, by the codes of Node and of npm's fetch.
153
+ const unreachableCodes = new Set(["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ETIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ENETUNREACH", "ENETDOWN", "ERR_SOCKET_TIMEOUT"]);
154
+ /** Whether npm failed because it could not reach its registry, rather than for what it was asked. */
155
+ function isUnreachable(ran) {
156
+ return unreachableCodes.has(npmErrorCode(ran) ?? "") || /FetchError|network|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ETIMEDOUT/i.test(npmError(ran));
157
+ }
158
+ /** The code npm's JSON error gives, as ENOTCACHED; undefined when it wrote none. */
159
+ export function npmErrorCode(ran) {
160
+ try {
161
+ return JSON.parse(ran.out).error?.code;
162
+ }
163
+ catch {
164
+ return undefined;
165
+ }
166
+ }
167
+ /** What npm's registry says of a package, at a version or its latest, with what its package.json says for rpg-engine; unreachable when it does not answer. */
84
168
  async function registryPackage(spec) {
85
169
  const checked = checkedSpec(spec);
86
170
  const at = checked.lastIndexOf("@");
87
171
  const [name, version] = at > 0 ? [checked.slice(0, at), checked.slice(at + 1)] : [checked, "latest"];
88
172
  try {
89
173
  const read = await json(`${registry}/${name.replace("/", "%2f")}/${version}`);
90
- return read === undefined ? { failed: `npm has no package ${spec}`, missing: true } : infoOf(read);
174
+ if (read === undefined) {
175
+ return { failed: `npm has no package ${spec}`, missing: true };
176
+ }
177
+ // Asked by its name alone, the newest version this engine reads, with the newer one and the engine it needs (D-515 (2)).
178
+ const info = infoOf(read);
179
+ return at > 0 || !madeForNewer(info) ? info : await readableVersion(name, info);
91
180
  }
92
181
  catch (error) {
93
- return { failed: `npm's registry could not be reached: ${error instanceof Error ? error.message : String(error)}` };
182
+ return { failed: `npm's registry could not be reached: ${error instanceof Error ? error.message : String(error)}`, unreachable: true };
183
+ }
184
+ }
185
+ /** Whether a package is an extension or a game system made for a newer API than this engine reads (D-515). */
186
+ function madeForNewer(info) {
187
+ return (info.kind === "extension" || info.kind === "system") && info.api !== undefined && info.api > packageApi;
188
+ }
189
+ /**
190
+ * The newest version of a package this engine reads, beside its latest, which needs a newer engine (D-515 (2)): with that one and the first rpg-engine on npm
191
+ * that reads it. The latest alone when no version reads, which is then refused.
192
+ */
193
+ async function readableVersion(name, latest) {
194
+ const all = await json(`${registry}/${name.replace("/", "%2f")}`);
195
+ const kind = latest.kind === "system" ? "system" : "extension";
196
+ const readable = Object.values(all?.versions ?? {}).map(infoOf).filter((one) => !one.version.includes("-") && readsApi(one.api, kind));
197
+ const newest = readable.reduce((best, one) => (best === undefined || isNewerVersion(one.version, best.version) ? one : best), undefined);
198
+ const engine = await engineReading(latest.api ?? 0);
199
+ const newer = { version: latest.version, ...(engine === undefined ? {} : { engine }) };
200
+ return newest === undefined ? latest : { ...newest, newer };
201
+ }
202
+ /** The first version of rpg-engine on npm that reads a package made for this API, as its package.json says; undefined when none does yet, or npm does not say. */
203
+ async function engineReading(api) {
204
+ try {
205
+ const all = await json(`${registry}/rpg-engine`);
206
+ const reads = (one) => typeof one["rpg-engine"]?.api === "number" && one["rpg-engine"].api >= api;
207
+ const reading = Object.values(all?.versions ?? {}).filter((one) => typeof one.version === "string" && !one.version.includes("-") && reads(one));
208
+ return reading.reduce((first, one) => (first === undefined || isNewerVersion(first, one.version ?? "") ? one.version : first), undefined);
209
+ }
210
+ catch {
211
+ return undefined;
94
212
  }
95
213
  }
96
214
  /** What a package's folder or .tgz says of it, by its package.json: a .tgz's name must be one npm takes, as it becomes a folder's. */
@@ -156,7 +274,11 @@ async function installCopy(folder, spec, expected, run) {
156
274
  renameSync(target, before);
157
275
  }
158
276
  renameSync(staged, target);
159
- const ran = await run(`install --prefix ${quotedFolder(folder)} ${quotedFolder(target)} ${installOptions}`);
277
+ // npm keeps what it installed of the same version, so the copy it installed goes aside first: what runs is the one just given.
278
+ const installed = join(folder, "node_modules", read.name);
279
+ const aside = `${target}.installed`;
280
+ rmSync(aside, { recursive: true, force: true });
281
+ const ran = await installedAside(installed, aside, () => run(`install --prefix ${quotedFolder(folder)} ${quotedFolder(target)} ${installOptions}`));
160
282
  if (ran.code === 0) {
161
283
  rmSync(before, { recursive: true, force: true });
162
284
  return undefined;
@@ -167,6 +289,20 @@ async function installCopy(folder, spec, expected, run) {
167
289
  }
168
290
  return `npm said: ${npmError(ran)}`;
169
291
  }
292
+ /** Runs npm with what it installed moved aside, taken away when npm succeeds and put back when it fails. */
293
+ async function installedAside(installed, aside, install) {
294
+ const moved = existsSync(installed);
295
+ if (moved) {
296
+ renameSync(installed, aside);
297
+ }
298
+ const ran = await install();
299
+ if (moved && ran.code !== 0) {
300
+ rmSync(installed, { recursive: true, force: true });
301
+ renameSync(aside, installed);
302
+ }
303
+ rmSync(aside, { recursive: true, force: true });
304
+ return ran;
305
+ }
170
306
  function infoOf(read) {
171
307
  const marker = read["rpg-engine"];
172
308
  return {
@@ -211,7 +347,7 @@ function quotedFolder(folder) {
211
347
  return `"${path}"`;
212
348
  }
213
349
  /** What npm said went wrong: its JSON error, with --json, else the last line it wrote that is not the pointer to its log. */
214
- function npmError(ran) {
350
+ export function npmError(ran) {
215
351
  try {
216
352
  const read = JSON.parse(ran.out);
217
353
  if (read.error?.summary !== undefined) {
@@ -225,7 +361,7 @@ function npmError(ran) {
225
361
  return lines.at(-1) ?? "nothing";
226
362
  }
227
363
  /** Runs npm with these arguments, in a folder of no campaign, stopped with all it started after a while. */
228
- function npm(args) {
364
+ export function runNpm(args) {
229
365
  return new Promise((done) => {
230
366
  const child = spawn(`npm ${args}`, { shell: true, windowsHide: true, cwd: tmpdir(), env: { ...process.env, NoDefaultCurrentDirectoryInExePath: "1" }, stdio: ["ignore", "pipe", "pipe"] });
231
367
  let [out, errors] = ["", ""];
@@ -1,7 +1,8 @@
1
- /** An extension's words in one language: its title and about, and its other words and phrases by the text its code writes. */
1
+ /** An extension's words in one language: its title and about, the names of the fields it adds to the game system, and its other words and phrases by the text its code writes. */
2
2
  export interface ExtensionWords {
3
3
  title?: string;
4
4
  about?: string;
5
+ fields?: Record<string, string>;
5
6
  words: Record<string, string>;
6
7
  }
7
8
  /** The words of the extension in this folder for a language, or for its base language (pt for pt-BR); undefined when it has none in it. It throws when they do not read. */
@@ -1,5 +1,5 @@
1
1
  // An extension's words in the languages it ships (D-502): beside its extension.yaml, words/<code>.yaml gives its title and its line in the Packages page, and
2
- // any word or phrase its widgets write, by the English as its code writes it. The core hands them on: a word the list lacks stays as written.
2
+ // the names of the fields it adds to the game system, and any word or phrase its widgets write, by the English as its code writes it. The core hands them on: a word the list lacks stays as written.
3
3
  import { join } from "node:path";
4
4
  import { z } from "zod";
5
5
  import { files } from "../core/store.js";
@@ -7,8 +7,9 @@ import { readYamlValues } from "../core/yaml-file.js";
7
7
  const wordsSchema = z.object({
8
8
  title: z.string().trim().min(1).optional(),
9
9
  about: z.string().trim().min(1).optional(),
10
+ fields: z.record(z.string().min(1), z.string().min(1)).optional(),
10
11
  words: z.record(z.string().min(1), z.string().min(1)).optional(),
11
- }, { error: "write its title, its about and its words, each word from the text the code writes to the language's own, such as {words: {Weather: Meteo}}" }).strict();
12
+ }, { error: "write its title, its about, the names of its fields and its words, each from the text the code writes to the language's own, such as {words: {Weather: Meteo}}" }).strict();
12
13
  /** The words of the extension in this folder for a language, or for its base language (pt for pt-BR); undefined when it has none in it. It throws when they do not read. */
13
14
  export function extensionWords(folder, language) {
14
15
  const file = [language, language.split("-")[0]].map((code) => join(folder, "words", `${code.toLowerCase()}.yaml`)).find((path) => files().exists(path));
@@ -19,8 +20,8 @@ export function extensionWords(folder, language) {
19
20
  if (!parsed.success) {
20
21
  throw new Error(`The words of the extension in ${file} cannot be read: ${parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}. Fix the file.`);
21
22
  }
22
- const { title, about, words = {} } = parsed.data;
23
- return { ...(title === undefined ? {} : { title }), ...(about === undefined ? {} : { about }), words };
23
+ const { title, about, fields, words = {} } = parsed.data;
24
+ return { ...(title === undefined ? {} : { title }), ...(about === undefined ? {} : { about }), ...(fields === undefined ? {} : { fields }), words };
24
25
  }
25
26
  /**
26
27
  * A text in the words' language: the whole text as the list gives it, else with its first letter's case aside, the translation's first letter taken to the
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { getVersion } from "./core/version.ts";
2
- export type { SaveAsked } from "./core/context.ts";
3
- export type { CalendarDay, ExtensionCode, ExtensionCommand, ExtensionEntry, ExtensionKit, Game, GameMoment, GameView, TimePassage, Widget, WidgetPart, WidgetText, WidgetValue } from "./extensions/index.ts";
4
- export type { CounterChange, RollMade, SystemEntry, SystemGame, SystemHooks, SystemPage, SystemReader } from "./systems/index.ts";
2
+ export type { Asked, AskedRoll, Asking, AskingQuestion, ButtonWords, CalendarDay, CardTint, CounterChange, DieTone, Game, GameMoment, GamePage, GameView, PackageCode, PackageCommand, PackageEntry, PackageKit, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./core/package-api.ts";