rpg-engine 0.5.0 → 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 (218) hide show
  1. package/dist/campaign/settings.d.ts +1 -0
  2. package/dist/campaign/settings.js +6 -5
  3. package/dist/command-line.js +12 -5
  4. package/dist/commands/advance.js +1 -1
  5. package/dist/commands/ask.d.ts +1 -1
  6. package/dist/commands/ask.js +66 -24
  7. package/dist/commands/change.js +28 -17
  8. package/dist/commands/config.d.ts +1 -1
  9. package/dist/commands/config.js +67 -21
  10. package/dist/commands/effect.js +42 -23
  11. package/dist/commands/find.js +1 -1
  12. package/dist/commands/game-adventures.js +2 -2
  13. package/dist/commands/game-catalog.d.ts +13 -0
  14. package/dist/commands/game-catalog.js +26 -2
  15. package/dist/commands/game-checks.js +23 -21
  16. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  17. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  18. package/dist/commands/game-effects.d.ts +12 -4
  19. package/dist/commands/game-effects.js +21 -13
  20. package/dist/commands/game-examples.d.ts +22 -0
  21. package/dist/commands/game-examples.js +72 -0
  22. package/dist/commands/game-extension-list.d.ts +31 -3
  23. package/dist/commands/game-extension-list.js +83 -7
  24. package/dist/commands/game-images.d.ts +1 -1
  25. package/dist/commands/game-images.js +3 -2
  26. package/dist/commands/game-library.d.ts +3 -0
  27. package/dist/commands/game-library.js +2 -2
  28. package/dist/commands/game-mode.js +1 -1
  29. package/dist/commands/game-package-code.d.ts +87 -0
  30. package/dist/commands/game-package-code.js +648 -0
  31. package/dist/commands/game-package-hooks.d.ts +37 -0
  32. package/dist/commands/game-package-hooks.js +116 -0
  33. package/dist/commands/game-recipes.js +2 -2
  34. package/dist/commands/game-reminders.d.ts +5 -2
  35. package/dist/commands/game-reminders.js +7 -4
  36. package/dist/commands/game-rules.d.ts +4 -1
  37. package/dist/commands/game-rules.js +7 -1
  38. package/dist/commands/game-upkeep.js +3 -3
  39. package/dist/commands/game-view-place.d.ts +8 -20
  40. package/dist/commands/game-view-place.js +16 -35
  41. package/dist/commands/game-widgets.d.ts +39 -10
  42. package/dist/commands/game-widgets.js +138 -35
  43. package/dist/commands/game-world.d.ts +17 -0
  44. package/dist/commands/game-world.js +70 -12
  45. package/dist/commands/image.js +1 -1
  46. package/dist/commands/init.js +2 -2
  47. package/dist/commands/mode.d.ts +1 -1
  48. package/dist/commands/package.d.ts +8 -0
  49. package/dist/commands/package.js +81 -24
  50. package/dist/commands/progression.d.ts +2 -0
  51. package/dist/commands/progression.js +7 -2
  52. package/dist/commands/roll.d.ts +2 -0
  53. package/dist/commands/roll.js +50 -24
  54. package/dist/commands/rules.js +6 -4
  55. package/dist/commands/scene.d.ts +1 -1
  56. package/dist/commands/scene.js +13 -10
  57. package/dist/commands/sheet.js +10 -1
  58. package/dist/commands/status.d.ts +1 -0
  59. package/dist/commands/status.js +14 -4
  60. package/dist/commands/trade.js +6 -4
  61. package/dist/commands/translate.js +2 -2
  62. package/dist/commands/travel.js +1 -1
  63. package/dist/commands/validate.js +2 -2
  64. package/dist/commands/view.d.ts +8 -4
  65. package/dist/commands/view.js +7 -6
  66. package/dist/commands/worked-out.js +11 -5
  67. package/dist/commands/write.d.ts +8 -1
  68. package/dist/commands/write.js +84 -25
  69. package/dist/core/command-reference.js +3 -2
  70. package/dist/core/consents.d.ts +18 -0
  71. package/dist/core/consents.js +93 -0
  72. package/dist/core/context.d.ts +51 -29
  73. package/dist/core/context.js +3 -1
  74. package/dist/core/examples.d.ts +25 -0
  75. package/dist/core/examples.js +19 -0
  76. package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
  77. package/dist/core/package-declarations.d.ts +102 -0
  78. package/dist/core/package-declarations.js +81 -0
  79. package/dist/core/registry.d.ts +2 -0
  80. package/dist/core/text.d.ts +5 -0
  81. package/dist/core/text.js +12 -0
  82. package/dist/dashboard/acts.js +31 -24
  83. package/dist/dashboard/address.js +4 -1
  84. package/dist/dashboard/api.js +54 -0
  85. package/dist/dashboard/app.js +140 -96
  86. package/dist/dashboard/ask-card.js +76 -25
  87. package/dist/dashboard/asked-dice.js +57 -0
  88. package/dist/dashboard/dice/tray.js +3 -3
  89. package/dist/dashboard/extension-widgets.js +104 -10
  90. package/dist/dashboard/i18n/ar.json +25 -29
  91. package/dist/dashboard/i18n/cs.json +25 -29
  92. package/dist/dashboard/i18n/da.json +25 -29
  93. package/dist/dashboard/i18n/de.json +25 -29
  94. package/dist/dashboard/i18n/el.json +25 -29
  95. package/dist/dashboard/i18n/es.json +25 -29
  96. package/dist/dashboard/i18n/fi.json +25 -29
  97. package/dist/dashboard/i18n/fr.json +25 -29
  98. package/dist/dashboard/i18n/he.json +25 -29
  99. package/dist/dashboard/i18n/hi.json +25 -29
  100. package/dist/dashboard/i18n/hu.json +25 -29
  101. package/dist/dashboard/i18n/is.json +25 -29
  102. package/dist/dashboard/i18n/it.json +25 -29
  103. package/dist/dashboard/i18n/ja.json +25 -29
  104. package/dist/dashboard/i18n/ko.json +25 -29
  105. package/dist/dashboard/i18n/nb.json +25 -29
  106. package/dist/dashboard/i18n/nl.json +25 -29
  107. package/dist/dashboard/i18n/pl.json +25 -29
  108. package/dist/dashboard/i18n/pt.json +25 -29
  109. package/dist/dashboard/i18n/ro.json +25 -29
  110. package/dist/dashboard/i18n/ru.json +25 -29
  111. package/dist/dashboard/i18n/sv.json +25 -29
  112. package/dist/dashboard/i18n/tr.json +25 -29
  113. package/dist/dashboard/i18n/uk.json +25 -29
  114. package/dist/dashboard/i18n/zh.json +25 -29
  115. package/dist/dashboard/icons.js +4 -1
  116. package/dist/dashboard/kit.js +35 -0
  117. package/dist/dashboard/labels.js +1 -0
  118. package/dist/dashboard/pack-card.js +7 -2
  119. package/dist/dashboard/package-page.js +50 -0
  120. package/dist/dashboard/packages.js +172 -23
  121. package/dist/dashboard/page-code.js +248 -0
  122. package/dist/dashboard/party.js +13 -14
  123. package/dist/dashboard/people.js +4 -0
  124. package/dist/dashboard/person-panel.js +110 -0
  125. package/dist/dashboard/place-map-view.js +11 -6
  126. package/dist/dashboard/scene.js +12 -9
  127. package/dist/dashboard/settings.js +55 -9
  128. package/dist/dashboard/sheet.js +21 -13
  129. package/dist/dashboard/status.js +69 -15
  130. package/dist/dashboard/style.css +592 -825
  131. package/dist/dashboard/top.js +75 -25
  132. package/dist/dashboard/turns.js +34 -13
  133. package/dist/dashboard/widgets.js +9 -2
  134. package/dist/dashboard-server.js +189 -10
  135. package/dist/dice/roll-dice.js +1 -1
  136. package/dist/effects/effect.d.ts +7 -4
  137. package/dist/effects/effect.js +12 -9
  138. package/dist/extensions/engine.d.ts +4 -0
  139. package/dist/extensions/engine.js +74 -0
  140. package/dist/extensions/extension.d.ts +25 -37
  141. package/dist/extensions/extension.js +26 -48
  142. package/dist/extensions/index.d.ts +3 -2
  143. package/dist/extensions/index.js +4 -1
  144. package/dist/extensions/packages.d.ts +6 -0
  145. package/dist/extensions/packages.js +100 -11
  146. package/dist/index.d.ts +1 -3
  147. package/dist/mcp-server.js +51 -14
  148. package/dist/page-words.d.ts +4 -0
  149. package/dist/page-words.js +4 -4
  150. package/dist/page.d.ts +218 -0
  151. package/dist/page.js +2 -0
  152. package/dist/pages/load.d.ts +7 -1
  153. package/dist/pages/load.js +10 -5
  154. package/dist/pages/page-file.js +1 -1
  155. package/dist/pages/stack-writes.js +5 -4
  156. package/dist/pages/world.d.ts +8 -0
  157. package/dist/pages/world.js +9 -2
  158. package/dist/systems/game-system.d.ts +52 -26
  159. package/dist/systems/game-system.js +141 -42
  160. package/dist/systems/index.d.ts +3 -3
  161. package/dist/systems/index.js +3 -3
  162. package/dist/systems/system-code.d.ts +29 -88
  163. package/dist/systems/system-code.js +68 -23
  164. package/dist/systems/words.d.ts +2 -0
  165. package/dist/systems/words.js +11 -0
  166. package/dist/testing.d.ts +20 -5
  167. package/dist/testing.js +49 -14
  168. package/instructions/combat.md +2 -2
  169. package/instructions/core.md +2 -2
  170. package/instructions/dashboard.md +1 -1
  171. package/instructions/mentor-tutorial.md +1 -1
  172. package/instructions/play.md +2 -2
  173. package/instructions/setup.md +1 -1
  174. package/package.json +9 -1
  175. package/systems/5e/LICENSE.md +13 -3
  176. package/systems/5e/dist/dying.js +83 -16
  177. package/systems/5e/dist/index.js +2 -2
  178. package/systems/5e/dist/page-style.js +634 -0
  179. package/systems/5e/dist/page.js +166 -0
  180. package/systems/5e/dist/shown.js +23 -0
  181. package/systems/5e/instructions/combat.md +1 -0
  182. package/systems/5e/package.json +4 -2
  183. package/systems/5e/system.yaml +35 -7
  184. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  185. package/systems/5e/words/ar.yaml +30 -0
  186. package/systems/5e/words/cs.yaml +30 -0
  187. package/systems/5e/words/da.yaml +30 -0
  188. package/systems/5e/words/de.yaml +30 -0
  189. package/systems/5e/words/el.yaml +30 -0
  190. package/systems/5e/words/es.yaml +30 -0
  191. package/systems/5e/words/fi.yaml +30 -0
  192. package/systems/5e/words/fr.yaml +30 -0
  193. package/systems/5e/words/he.yaml +30 -0
  194. package/systems/5e/words/hi.yaml +30 -0
  195. package/systems/5e/words/hu.yaml +30 -0
  196. package/systems/5e/words/is.yaml +30 -0
  197. package/systems/5e/words/it.yaml +30 -0
  198. package/systems/5e/words/ja.yaml +30 -0
  199. package/systems/5e/words/ko.yaml +30 -0
  200. package/systems/5e/words/nb.yaml +30 -0
  201. package/systems/5e/words/nl.yaml +30 -0
  202. package/systems/5e/words/pl.yaml +30 -0
  203. package/systems/5e/words/pt.yaml +30 -0
  204. package/systems/5e/words/ro.yaml +30 -0
  205. package/systems/5e/words/ru.yaml +30 -0
  206. package/systems/5e/words/sv.yaml +30 -0
  207. package/systems/5e/words/tr.yaml +30 -0
  208. package/systems/5e/words/uk.yaml +30 -0
  209. package/systems/5e/words/zh.yaml +30 -0
  210. package/dist/commands/game-extensions.d.ts +0 -34
  211. package/dist/commands/game-extensions.js +0 -407
  212. package/dist/commands/game-system-code.d.ts +0 -33
  213. package/dist/commands/game-system-code.js +0 -188
  214. package/dist/dashboard/death-save.js +0 -67
  215. package/dist/dashboard/dying.js +0 -46
  216. package/dist/dashboard/save-outcome.js +0 -42
  217. package/dist/dashboard/spend.js +0 -115
  218. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { useContext } from "preact/hooks";
3
+ import { Drawn, Text } from "./extension-widgets.js";
4
+ import { NotationIcons } from "./icons.js";
5
+ import { sideOf, Token } from "./party.js";
6
+ import { PeopleContext } from "./people.js";
7
+ export { Choices } from "./ask-card.js";
8
+ export { Text, Track, Value, Who } from "./extension-widgets.js";
9
+ export { cardPages } from "./page-code.js";
10
+ /** A button of words, as the page's: gold for the one main action, quiet for a secondary one, danger for one that loses something. */
11
+ export function Button({ children, onClick, kind, disabled, tip }) {
12
+ return (_jsx("button", { type: "button", class: kind === undefined ? "button" : `button ${kind}`, "aria-disabled": disabled === true ? "true" : undefined, "data-tip": tip, onClick: () => disabled !== true && onClick(), children: children }));
13
+ }
14
+ /** A button of an icon, named by its words, which its tooltip shows. */
15
+ export function IconButton({ path, label, onClick }) {
16
+ return (_jsx("button", { type: "button", class: "icon-button", "aria-label": label, "data-tip": label, onClick: onClick, children: _jsx(Drawn, { path: path, kind: "icon" }) }));
17
+ }
18
+ /** An icon, a path on a grid of 24 stroked in the accent as the page's own. */
19
+ export function Icon({ path }) {
20
+ return _jsx(Drawn, { path: path, kind: "icon" });
21
+ }
22
+ /** The dice of a notation as the page draws them, as a d20 for 1d20+5. */
23
+ export function Dice({ notation }) {
24
+ return _jsx(NotationIcons, { notation: notation });
25
+ }
26
+ /** Things of a list, as the page's chips. */
27
+ export function Chips({ items }) {
28
+ return (_jsx("ul", { class: "chips", children: items.map((item, index) => (_jsx("li", { dir: "auto", children: _jsx(Text, { text: item }) }, index))) }));
29
+ }
30
+ /** Someone's portrait as the page draws it, the party and those at the place known by name, else their initials; large as in a sheet. */
31
+ export function Portrait({ name, large }) {
32
+ const person = useContext(PeopleContext).find((one) => one.name === name) ?? { name, role: "other" };
33
+ const side = sideOf(person.role);
34
+ return _jsx(Token, { member: person, large: large === true, ...(side === undefined ? {} : { side }) });
35
+ }
@@ -185,6 +185,7 @@ export function settingLabel(name) {
185
185
  lethality: t("Lethality"),
186
186
  saves: t("Saves"),
187
187
  rigor: t("Rigor"),
188
+ ruleset: t("Ruleset"),
188
189
  mentor: t("Mentor"),
189
190
  learned: t("Learned"),
190
191
  prose: t("Prose"),
@@ -13,7 +13,8 @@ export function nextPackCard(before, now, gone) {
13
13
  return card?.coming === true && kept !== undefined ? { card: kept } : {};
14
14
  }
15
15
  const sent = kept?.asked?.id === asked.id && kept.sent !== undefined ? { sent: kept.sent } : {};
16
- return { card: { widget: card.widget, key: card.key, shows: card.shows, title: kept?.title ?? asked.question, asked, ...sent } };
16
+ const rolled = kept?.rolled === undefined ? {} : { rolled: kept.rolled };
17
+ return { card: { widget: card.widget, key: card.key, shows: card.shows, title: kept?.title ?? asked.question, asked, ...sent, ...rolled } };
17
18
  }
18
19
  const ended = now.card;
19
20
  // The call over with nothing for its card to show, as a roll turned down before its first die: the card goes.
@@ -23,7 +24,8 @@ export function nextPackCard(before, now, gone) {
23
24
  if (ended?.ended === true && ended.shows !== undefined && !gone.has(ended.key)) {
24
25
  const kept = before?.key === ended.key ? before : undefined;
25
26
  const title = kept?.title === undefined ? {} : { title: kept.title };
26
- return { card: { widget: ended.widget, key: ended.key, shows: ended.shows, ...title, ...(kept?.asked === undefined ? {} : { asked: kept.asked }), ended: true } };
27
+ const rolled = kept?.rolled === undefined ? {} : { rolled: kept.rolled };
28
+ return { card: { widget: ended.widget, key: ended.key, shows: ended.shows, ...title, ...(kept?.asked === undefined ? {} : { asked: kept.asked }), ...rolled, ended: true } };
27
29
  }
28
30
  // Its question gone with no button of it pressed, as answered in words or taken back by the master: the card goes, and what the call leaves stays away.
29
31
  if (before !== undefined && before.ended !== true) {
@@ -42,6 +44,9 @@ export function cardLayout(shows) {
42
44
  if ("lead" in part) {
43
45
  layout.lead ??= part;
44
46
  }
47
+ else if ("who" in part) {
48
+ layout.who ??= part;
49
+ }
45
50
  else if ("track" in part) {
46
51
  layout.places[part.track.stage ?? "center"].push(part.track);
47
52
  }
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ // A package's own pages (D-511): at #/pkg/<package>/<name>, the page's head with its title and icon, its whole inside drawn by the package's page code; and the
3
+ // links to them in the package's row of Packages, by their titles.
4
+ import { useContext, useEffect, useRef } from "preact/hooks";
5
+ import { sectionAddress } from "./address.js";
6
+ import { Drawn, WidgetsContext } from "./extension-widgets.js";
7
+ import { Icon } from "./icons.js";
8
+ import { codeOfModule, ExtensionRoot, ModulesContext, ownPageIn, pagePropsOf, usePageModule, useWidgetData } from "./page-code.js";
9
+ // Whether the player moved in the page since it loaded: a package's page opened then takes the focus to its title.
10
+ let moved = false;
11
+ if (typeof window !== "undefined") {
12
+ window.addEventListener("hashchange", () => {
13
+ moved = true;
14
+ }, { once: true });
15
+ }
16
+ /**
17
+ * A package's page by its package and name, once its module came; the focus on its title as it opens. Nothing while its module comes or has no such page;
18
+ * a module that did not load says so in the page, with its error and whose it is.
19
+ */
20
+ export function PackagePage({ name, page }) {
21
+ const module = useContext(ModulesContext).find((one) => one.package === name);
22
+ const owner = module === undefined ? undefined : codeOfModule(module);
23
+ const loaded = usePageModule(owner);
24
+ const title = useRef(null);
25
+ const found = page === undefined ? undefined : ownPageIn(loaded, page);
26
+ const own = found instanceof Error ? undefined : found;
27
+ const data = useWidgetData(module?.package ?? "", own?.widget, undefined, useContext(WidgetsContext));
28
+ // Opened from the page, as by a tab or a menu, the focus goes to its title; loaded by its address, the focus stays at the page's start, as any page's,
29
+ // and its title has no ring.
30
+ useEffect(() => {
31
+ if (moved) {
32
+ title.current?.focus({ preventScroll: true });
33
+ }
34
+ }, [own === undefined, name, page]);
35
+ if (owner === undefined || page === undefined || found === undefined) {
36
+ return null;
37
+ }
38
+ const Drawing = own?.draw;
39
+ return (_jsxs("section", { class: "page-stack package-page", "aria-labelledby": "package-page-title", children: [_jsxs("div", { class: "page-head", children: [_jsx("span", { class: "page-mark", children: own?.icon === undefined ? _jsx(Icon, { name: "packages" }) : _jsx(Drawn, { path: own.icon, kind: "icon" }) }), _jsx("h2", { id: "package-page-title", ref: title, tabIndex: -1, dir: "auto", children: own?.title ?? page })] }), _jsx(ExtensionRoot, { widget: owner, loaded: loaded, kind: "ext-page", draw: () => (Drawing === undefined ? null : _jsx(Drawing, { ...pagePropsOf(owner), name: page, ...(data === undefined ? {} : { data }) })) })] }));
40
+ }
41
+ /** The links to a package's own pages, by their titles, after the meta of its row in Packages; nothing for a package without any. */
42
+ export function OwnPageLinks({ name }) {
43
+ const module = useContext(ModulesContext).find((one) => one.package === name);
44
+ return module === undefined ? null : _jsx(ModulePageLinks, { module: module });
45
+ }
46
+ function ModulePageLinks({ module }) {
47
+ const loaded = usePageModule(codeOfModule(module));
48
+ const pages = loaded === undefined || loaded instanceof Error ? [] : Object.entries(loaded.pages ?? {});
49
+ return (_jsx(_Fragment, { children: pages.map(([page, own]) => (_jsxs("span", { children: [_jsx("span", { class: "package-report-gap", children: " · " }), _jsx("a", { class: "package-report", href: sectionAddress("pkg", module.package, page), dir: "auto", children: own.title })] }, page))) }));
50
+ }
@@ -1,17 +1,51 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "preact/hooks";
3
3
  import { sectionAddress } from "./address.js";
4
- import { addFile, addSource, changeLibrary, changePackage, exportCampaign, readCatalog, readLibrary, readPackages, } from "./api.js";
4
+ import { addFile, addSource, changeLibrary, changePackage, exportCampaign, readCatalog, readEngine, readLibrary, readPackages, updateEngine, } from "./api.js";
5
5
  import { CardHead, useMedia } from "./card.js";
6
6
  import { gameDateLabel, sinceDateLabel } from "./game-words.js";
7
7
  import { Icon, iconPath } from "./icons.js";
8
8
  import { phraseLabel, systemTitleLabel } from "./labels.js";
9
9
  import { languageName } from "./languages.js";
10
+ import { OwnPageLinks } from "./package-page.js";
10
11
  import { PageHead } from "./pages.js";
11
12
  import { Confirm } from "./saves.js";
12
13
  import { Command } from "./settings.js";
13
14
  import { PageTabs } from "./tabs.js";
14
15
  import { arrowStep, foldedText, isolated, pageDirection, t } from "./text.js";
16
+ // The engine's own name, never translated.
17
+ const engineName = "RPG Engine";
18
+ // Where the engine installed from this page is kept while the chat goes on with the one before it: in this tab, through a reload.
19
+ const updatedKey = "rpg-engine-updated";
20
+ /** The engine installed from this page in this tab, if any. */
21
+ function keptUpdate() {
22
+ try {
23
+ const kept = JSON.parse(sessionStorage.getItem(updatedKey) ?? "null");
24
+ return kept !== null && typeof kept.to === "string" && typeof kept.from === "string" ? { from: kept.from, to: kept.to, restart: kept.restart === "app" ? "app" : "chat" } : undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
30
+ function keepUpdate(updated) {
31
+ try {
32
+ if (updated === undefined) {
33
+ sessionStorage.removeItem(updatedKey);
34
+ }
35
+ else {
36
+ sessionStorage.setItem(updatedKey, JSON.stringify(updated));
37
+ }
38
+ }
39
+ catch {
40
+ // A browser that keeps nothing says it until the page is drawn again.
41
+ }
42
+ }
43
+ /** The focus to the engine's card: its Update, else its title. */
44
+ function focusEngine() {
45
+ const target = document.getElementById("engine-update") ?? document.getElementById("packages-engine");
46
+ target?.focus({ preventScroll: true });
47
+ target?.scrollIntoView({ block: "center" });
48
+ }
15
49
  // The rows of the catalog shown before "Show more": fewer on a phone, where the installed come after it.
16
50
  const shownWide = 5;
17
51
  const shownNarrow = 3;
@@ -33,6 +67,10 @@ export function PackagesPage({ version, tab }) {
33
67
  const [library, setLibrary] = useState();
34
68
  const [libraryProblem, setLibraryProblem] = useState();
35
69
  const libraryBusy = library?.entries.some((entry) => entry.reading > 0) ?? false;
70
+ const [engine, setEngine] = useState({ asking: true });
71
+ const [updated, setUpdated] = useState(keptUpdate);
72
+ // Asked from a row whose package needs a newer engine: the focus goes to the engine's card once Installed shows.
73
+ const toEngine = useRef(false);
36
74
  // Only the last reading counts, as after a change made here and the one the game sends.
37
75
  const read = () => {
38
76
  const reading = ++reads.current;
@@ -55,9 +93,21 @@ export function PackagesPage({ version, tab }) {
55
93
  setLibraryProblem(undefined);
56
94
  }, (error) => setLibraryProblem(error instanceof Error ? error.message : String(error)));
57
95
  };
96
+ // The engine and npm's latest, once: npm is asked each time. Only the game's own server has it; elsewhere its card is not shown.
97
+ const askEngine = () => {
98
+ void readEngine().then((read) => {
99
+ setEngine({ asking: false, ...(read === undefined ? { hidden: true } : { read }) });
100
+ // A new chat brought the engine installed here: the way to it is said no more.
101
+ if (read !== undefined && read.version === updated?.to) {
102
+ keepUpdate(undefined);
103
+ setUpdated(undefined);
104
+ }
105
+ }, () => setEngine({ asking: false, hidden: true }));
106
+ };
58
107
  useEffect(read, [version]);
59
108
  useEffect(readShelves, [version]);
60
109
  useEffect(() => askCatalog(false), []);
110
+ useEffect(askEngine, []);
61
111
  // While books are being read in their own process, their counts are read again now and then.
62
112
  useEffect(() => {
63
113
  if (!libraryBusy) {
@@ -77,6 +127,11 @@ export function PackagesPage({ version, tab }) {
77
127
  // Seen from Add, what was added gets the focus among the installed: its new row, else its card.
78
128
  useEffect(() => {
79
129
  const kind = seeing.current;
130
+ if (shownTab === "installed" && toEngine.current) {
131
+ toEngine.current = false;
132
+ focusEngine();
133
+ return;
134
+ }
80
135
  if (shownTab !== "installed" || kind === undefined) {
81
136
  return;
82
137
  }
@@ -94,6 +149,15 @@ export function PackagesPage({ version, tab }) {
94
149
  seeing.current = kind;
95
150
  choose("installed");
96
151
  };
152
+ // From a package that needs a newer engine, to the engine's card, in Installed.
153
+ const goEngine = () => {
154
+ if (shownTab === "installed") {
155
+ focusEngine();
156
+ return;
157
+ }
158
+ toEngine.current = true;
159
+ choose("installed");
160
+ };
97
161
  const rowState = (at) => ({ ...(work?.at === at ? { work } : {}), ...(said?.at === at ? { said } : {}), busy, ...(tabOf(at) === "add" ? { onSee: see } : {}) });
98
162
  /** One change, from where it was asked: the work shown there while it lasts, then what came of it; what is here read again, and the catalog when it changed. */
99
163
  const run = async (at, action, name, call, done, after) => {
@@ -114,6 +178,36 @@ export function PackagesPage({ version, tab }) {
114
178
  askCatalog(true);
115
179
  }
116
180
  };
181
+ /**
182
+ * npm's latest engine installed, as it was installed: the work said in its card while it lasts; then how a new chat, or the app opened again, takes it, kept
183
+ * in this tab until the engine the page is served by is that one.
184
+ */
185
+ const updateTheEngine = async () => {
186
+ const from = engine.read?.version;
187
+ if (busy || from === undefined) {
188
+ return;
189
+ }
190
+ setSaid(undefined);
191
+ setSending({ name: "rpg-engine", action: "engine", phase: "working", at: "engine" });
192
+ const outcome = await updateEngine();
193
+ setSending(undefined);
194
+ if (outcome.done) {
195
+ const done = { from, to: outcome.version, restart: outcome.restart };
196
+ keepUpdate(done);
197
+ setUpdated({ ...done, now: true });
198
+ }
199
+ else {
200
+ setSaid({
201
+ at: "engine",
202
+ problem: true,
203
+ ...(outcome.code === "busy"
204
+ ? { text: t("One package at a time: wait for the one under way, then try again.") }
205
+ : { text: t("RPG Engine was not updated."), why: outcome.error }),
206
+ });
207
+ askEngine();
208
+ }
209
+ read();
210
+ };
117
211
  const add = (at, source) => run(at, "add", source, () => addSource(source), addedText);
118
212
  const addTheFile = (file) => run("add", "add", file.name, () => addFile(file), addedText);
119
213
  const change = (at, action, name, label, after) => run(at, action, name, () => changePackage(action, name), () => doneText(action, label), after);
@@ -135,7 +229,10 @@ export function PackagesPage({ version, tab }) {
135
229
  const systems = view?.systems ?? [];
136
230
  const adventures = view?.adventures ?? [];
137
231
  const languages = view?.languages ?? [];
138
- const updates = view === undefined ? 0 : updateCount(view, catalog.read);
232
+ // The engine npm has that this page may install: one more update on the Installed tab, and the way for a package that needs it.
233
+ const engineNew = engine.read?.update === true && engine.read.install === "global" && updated === undefined ? engine.read.latest : undefined;
234
+ const updates = (view === undefined ? 0 : updateCount(view, catalog.read)) + (engineNew === undefined ? 0 : 1);
235
+ const needs = (newer) => newer === undefined ? null : _jsx(NeedsEngine, { newer: newer, canUpdate: engineNew !== undefined, onGo: goEngine });
139
236
  const missing = view?.missing.length ?? 0;
140
237
  const away = library?.entries.filter((entry) => !entry.onComputer).length ?? 0;
141
238
  const elsewhere = work !== undefined && tabOf(work.at) !== shownTab ? work : undefined;
@@ -144,9 +241,9 @@ export function PackagesPage({ version, tab }) {
144
241
  { key: "installed", name: t("Installed"), label: [t("Installed"), ...marksText(updates, missing)].join(", "), marks: _jsx(TabMarks, { updates: updates, missing: missing }) },
145
242
  { key: "add", name: t("Add") },
146
243
  { key: "library", name: t("Library"), label: [t("Library"), ...marksText(0, away)].join(", "), marks: _jsx(TabMarks, { updates: 0, missing: away }) },
147
- ] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void change(`catalog:${entry.source}`, "update", entry.source, entryTitle(entry)), onRetry: () => askCatalog(true) }), _jsx(AddField, { state: rowState("add"), onAdd: (source) => void add("add", source), onFile: (file) => void addTheFile(file) })] }) })), shownTab === "installed" && (_jsxs(_Fragment, { children: [_jsxs("section", { class: "card", "aria-labelledby": "packages-systems", children: [_jsx(CardHead, { icon: iconPath("dice"), title: _jsx("h3", { id: "packages-systems", tabIndex: -1, children: t("Game system") }) }), _jsxs("div", { class: "card-body package-body", children: [_jsx("ul", { class: "package-list", children: systems.map((system) => (_jsx(SystemRow, { system: system, newer: system.package === undefined ? undefined : newerOf(system.package, "system", catalog.read), fresh: fresh.includes(`system:${system.name}`), state: rowState(`system:${system.name}`), onUpdate: (target) => void change(`system:${system.name}`, "update", target, system.name), onUninstall: (target) => setAsking({ kind: "uninstall", what: "system", name: system.name, target, at: `system:${system.name}` }) }, system.name))) }), _jsx(CardSaid, { said: said, at: "systems" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-adventures", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "packages-adventures", tabIndex: -1, children: t("Adventures") }), ...(adventures.length === 0 ? {} : { note: String(adventures.length) }) }), _jsxs("div", { class: "card-body package-body", children: [adventures.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add one in Add, from the catalog, a .zip or a link.") }), adventures.length > 0 && (_jsx("ul", { class: "package-list", children: adventures.map((adventure) => (_jsx(AdventureRow, { adventure: adventure, fresh: fresh.includes(`adventure:${adventure.title}`), state: rowState(`adventure:${adventure.title}`), onTakeOut: () => setAsking({ kind: "adventure", title: adventure.title }) }, adventure.title))) })), _jsx(CardSaid, { said: said, at: "adventures" }), _jsx(ShareCampaign, {})] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-extensions", children: [_jsx(CardHead, { icon: iconPath("packages"), title: _jsx("h3", { id: "packages-extensions", tabIndex: -1, children: t("Extensions") }), ...(view.installed.length + view.missing.length === 0 ? {} : { note: t("{count} in use", { count: usedCount(view) }) }) }), _jsxs("div", { class: "card-body package-body", children: [view.installed.length + view.missing.length === 0 && _jsx("p", { class: "package-note", children: t("None: an extension adds rules and tools to the game; you find them in Add, in the catalog.") }), view.installed.length + view.missing.length > 0 && (_jsxs("ul", { class: "package-list", children: [view.installed.map((extension) => (_jsx(ExtensionRow, { extension: extension, newer: newerOf(extension.package, "extension", catalog.read), fresh: fresh.includes(`extension:${extension.package}`), state: rowState(`extension:${extension.package}`), onUse: (use) => void (use
244
+ ] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), needs: (entry) => needs(entry.newer), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void change(`catalog:${entry.source}`, "update", entry.source, entryTitle(entry)), onRetry: () => askCatalog(true) }), _jsx(AddField, { state: rowState("add"), onAdd: (source) => void add("add", source), onFile: (file) => void addTheFile(file) })] }) })), shownTab === "installed" && (_jsxs(_Fragment, { children: [!engine.hidden && _jsx(EngineCard, { engine: engine.read, updated: updated, newer: engineNew, state: rowState("engine"), onUpdate: () => void updateTheEngine() }), _jsxs("section", { class: "card", "aria-labelledby": "packages-systems", children: [_jsx(CardHead, { icon: iconPath("dice"), title: _jsx("h3", { id: "packages-systems", tabIndex: -1, children: t("Game system") }) }), _jsxs("div", { class: "card-body package-body", children: [_jsx("ul", { class: "package-list", children: systems.map((system) => (_jsx(SystemRow, { system: system, newer: system.package === undefined ? undefined : newerOf(system.package, "system", catalog.read), needs: system.package === undefined ? null : needs(entryOf(system.package, "system", catalog.read)?.newer), fresh: fresh.includes(`system:${system.name}`), state: rowState(`system:${system.name}`), onUpdate: (target) => void change(`system:${system.name}`, "update", target, system.name), onUninstall: (target) => setAsking({ kind: "uninstall", what: "system", name: system.name, target, at: `system:${system.name}` }) }, system.name))) }), _jsx(CardSaid, { said: said, at: "systems" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-adventures", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "packages-adventures", tabIndex: -1, children: t("Adventures") }), ...(adventures.length === 0 ? {} : { note: String(adventures.length) }) }), _jsxs("div", { class: "card-body package-body", children: [adventures.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add one in Add, from the catalog, a .zip or a link.") }), adventures.length > 0 && (_jsx("ul", { class: "package-list", children: adventures.map((adventure) => (_jsx(AdventureRow, { adventure: adventure, fresh: fresh.includes(`adventure:${adventure.title}`), state: rowState(`adventure:${adventure.title}`), onTakeOut: () => setAsking({ kind: "adventure", title: adventure.title }) }, adventure.title))) })), _jsx(CardSaid, { said: said, at: "adventures" }), _jsx(ShareCampaign, {})] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-extensions", children: [_jsx(CardHead, { icon: iconPath("packages"), title: _jsx("h3", { id: "packages-extensions", tabIndex: -1, children: t("Extensions") }), ...(view.installed.length + view.missing.length === 0 ? {} : { note: t("{count} in use", { count: usedCount(view) }) }) }), _jsxs("div", { class: "card-body package-body", children: [view.installed.length + view.missing.length === 0 && _jsx("p", { class: "package-note", children: t("None: an extension adds rules and tools to the game; you find them in Add, in the catalog.") }), view.installed.length + view.missing.length > 0 && (_jsxs("ul", { class: "package-list", children: [view.installed.map((extension) => (_jsx(ExtensionRow, { extension: extension, newer: newerOf(extension.package, "extension", catalog.read), needs: needs(entryOf(extension.package, "extension", catalog.read)?.newer), fresh: fresh.includes(`extension:${extension.package}`), state: rowState(`extension:${extension.package}`), onUse: (use) => void (use
148
245
  ? add(`extension:${extension.package}`, extension.package)
149
- : change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => (_jsx(LanguageRow, { language: language, newer: newerOf(language.package, "language", catalog.read), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void change(`language:${language.code}`, "update", language.package, languageTitle(language)), onUninstall: () => setAsking({ kind: "uninstall", what: "language", name: languageTitle(language), target: language.package, at: `language:${language.code}` }) }, language.package))) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
246
+ : change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => (_jsx(LanguageRow, { language: language, newer: newerOf(language.package, "language", catalog.read), needs: needs(entryOf(language.package, "language", catalog.read)?.newer), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void change(`language:${language.code}`, "update", language.package, languageTitle(language)), onUninstall: () => setAsking({ kind: "uninstall", what: "language", name: languageTitle(language), target: language.package, at: `language:${language.code}` }) }, language.package))) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
150
247
  }
151
248
  // How often the library is read again while its books are being read, for their counts.
152
249
  const libraryReading = 5000;
@@ -237,7 +334,7 @@ function LibraryField({ state, onAdd }) {
237
334
  return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
238
335
  event.preventDefault();
239
336
  submit();
240
- }, children: [_jsx("label", { class: "package-label", for: "library-path", children: t("A folder or a book of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "library-path", dir: "ltr", type: "text", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 1000, value: path, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "library-path-about", placeholder: "D:\\Books\\5e", onInput: (event) => setPath(event.currentTarget.value) }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": state.busy, children: [_jsx(Icon, { name: "plus" }), t("Add")] })] }), _jsxs("p", { class: "package-note", id: "library-path-about", children: [t("Write or paste its full path: the browser does not give a folder's. Your computer asks your yes in a window, once, and nothing in the folder is ever changed."), " ", t("Text, or PDFs whose text can be selected, read best; a scanned PDF is read from the pictures of its pages, on Windows only, in a few minutes.")] }), empty && state.work === undefined && _jsx("p", { class: "package-said problem", role: "status", children: t("Write the path of a folder or a book first.") }), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
337
+ }, children: [_jsx("label", { class: "package-label", for: "library-path", children: t("A folder or a book of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "library-path", dir: "ltr", type: "text", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 1000, value: path, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "library-path-about", placeholder: "D:\\Books\\RPG", onInput: (event) => setPath(event.currentTarget.value) }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": state.busy, children: [_jsx(Icon, { name: "plus" }), t("Add")] })] }), _jsxs("p", { class: "package-note", id: "library-path-about", children: [t("Write or paste its full path: the browser does not give a folder's. Your computer asks your yes in a window, once, and nothing in the folder is ever changed."), " ", t("Text, or PDFs whose text can be selected, read best; a scanned PDF is read from the pictures of its pages, on Windows only, in a few minutes.")] }), empty && state.work === undefined && _jsx("p", { class: "package-said problem", role: "status", children: t("Write the path of a folder or a book first.") }), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
241
338
  }
242
339
  /** On the Installed tab, what asks for the player: the updates npm has, with their count, and a mark when the campaign lists what this computer lacks. */
243
340
  function TabMarks({ updates, missing }) {
@@ -293,7 +390,7 @@ function AddField({ state, onAdd, onFile }) {
293
390
  * The catalog (D-486), always open: a search, chips for the kinds with how many each has, wrapping on a phone; the first rows, five or three on a phone, then
294
391
  * the others on asking. A source that does not answer is said in the page's words, with its own under them.
295
392
  */
296
- function CatalogList({ catalog, view, state, onAdd, onUpdate, onRetry }) {
393
+ function CatalogList({ catalog, view, state, needs, onAdd, onUpdate, onRetry }) {
297
394
  const [kind, setKind] = useState("all");
298
395
  const [query, setQuery] = useState("");
299
396
  const [all, setAll] = useState(false);
@@ -327,7 +424,7 @@ function CatalogList({ catalog, view, state, onAdd, onUpdate, onRetry }) {
327
424
  }
328
425
  };
329
426
  const chip = (one, count) => (_jsxs("button", { type: "button", "aria-pressed": chosen === one, tabIndex: chosen === one ? 0 : -1, onClick: () => setKind(one), children: [one === "all" ? t("All") : kindsLabel(one), _jsx("span", { class: "package-count", children: count })] }, one));
330
- return (_jsxs("div", { class: "package-catalog", children: [_jsxs("div", { class: "package-catalog-head", children: [_jsx("h4", { class: "eyebrow package-sub", id: "package-catalog-title", children: t("Catalog") }), entries.length > 0 && (_jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: query, placeholder: t("Search"), "aria-label": t("Search the catalog"), onInput: (event) => setQuery(event.currentTarget.value) })] }))] }), kinds.length > 1 && (_jsxs("div", { class: "filter-chips", role: "group", "aria-label": t("Kind"), ref: chips, onKeyDown: chipKey, children: [chip("all", found.length), kinds.map((one) => chip(one, found.filter((entry) => entry.kind === one).length))] })), (failed.npm !== undefined || failed.github !== undefined) && _jsx(CatalogAway, { failed: failed, asking: catalog.asking, onRetry: onRetry }), catalog.asking && catalog.read === undefined && catalog.error === undefined && _jsx("p", { class: "package-note", role: "status", children: t("Asking npm and GitHub…") }), !catalog.asking && entries.length === 0 && failed.npm === undefined && failed.github === undefined && _jsx("p", { class: "package-note", children: t("Nothing to add for now.") }), entries.length > 0 && shown.length === 0 && _jsx("p", { class: "package-note", children: t("Nothing matches “{query}”.", { query: query.trim() }) }), visible.length > 0 && (_jsx("ul", { class: "package-list", ref: list, "aria-labelledby": "package-catalog-title", children: visible.map((entry) => (_jsx(CatalogRow, { entry: entry, named: chosen === "all", view: view, state: state(entry), onAdd: () => onAdd(entry), onUpdate: () => onUpdate(entry) }, `${entry.kind}:${entry.source}`))) })), shown.length > visible.length && (_jsxs("button", { type: "button", class: "package-show", onClick: showAll, children: [t("Show the other {count}", { count: shown.length - visible.length }), _jsx(Icon, { name: "more" })] }))] }));
427
+ return (_jsxs("div", { class: "package-catalog", children: [_jsxs("div", { class: "package-catalog-head", children: [_jsx("h4", { class: "eyebrow package-sub", id: "package-catalog-title", children: t("Catalog") }), entries.length > 0 && (_jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: query, placeholder: t("Search"), "aria-label": t("Search the catalog"), onInput: (event) => setQuery(event.currentTarget.value) })] }))] }), kinds.length > 1 && (_jsxs("div", { class: "filter-chips", role: "group", "aria-label": t("Kind"), ref: chips, onKeyDown: chipKey, children: [chip("all", found.length), kinds.map((one) => chip(one, found.filter((entry) => entry.kind === one).length))] })), (failed.npm !== undefined || failed.github !== undefined) && _jsx(CatalogAway, { failed: failed, asking: catalog.asking, onRetry: onRetry }), catalog.asking && catalog.read === undefined && catalog.error === undefined && _jsx("p", { class: "package-note", role: "status", children: t("Asking npm and GitHub…") }), !catalog.asking && entries.length === 0 && failed.npm === undefined && failed.github === undefined && _jsx("p", { class: "package-note", children: t("Nothing to add for now.") }), entries.length > 0 && shown.length === 0 && _jsx("p", { class: "package-note", children: t("Nothing matches “{query}”.", { query: query.trim() }) }), visible.length > 0 && (_jsx("ul", { class: "package-list", ref: list, "aria-labelledby": "package-catalog-title", children: visible.map((entry) => (_jsx(CatalogRow, { entry: entry, named: chosen === "all", view: view, state: state(entry), needs: needs(entry), onAdd: () => onAdd(entry), onUpdate: () => onUpdate(entry) }, `${entry.kind}:${entry.source}`))) })), shown.length > visible.length && (_jsxs("button", { type: "button", class: "package-show", onClick: showAll, children: [t("Show the other {count}", { count: shown.length - visible.length }), _jsx(Icon, { name: "more" })] }))] }));
331
428
  }
332
429
  /** npm or GitHub away, or both: the rest is added all the same; the engine's words under the page's, and Try again. */
333
430
  function CatalogAway({ failed, asking, onRetry }) {
@@ -344,7 +441,7 @@ function CatalogAway({ failed, asking, onRetry }) {
344
441
  * A row of the catalog (D-486 (4)): its tile, its title with its kind in All and whose it is, a line of what it is, its facts; then what can be done: add it,
345
442
  * with "…" when a window will ask the player's yes; update it; download a game system for a new campaign; or where it is already.
346
443
  */
347
- function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
444
+ function CatalogRow({ entry, named, view, state, needs, onAdd, onUpdate }) {
348
445
  const here = hereState(entry, view);
349
446
  const asksYes = !entry.verified && entry.code;
350
447
  const facts = [
@@ -360,7 +457,7 @@ function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
360
457
  ? (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), `${isolated(entry.installed)} ${pageDirection() === "rtl" ? "←" : "→"} ${isolated(entry.version)}`] }))
361
458
  : entry.version;
362
459
  const action = (word, label, icon, onClick, accent = false) => (_jsxs("button", { type: "button", class: accent ? "button package-button accent" : "button package-button", "aria-label": label, "aria-disabled": state.busy, onClick: () => !state.busy && onClick(), children: [_jsx(Icon, { name: icon }), word] }));
363
- return (_jsxs(PackageRow, { tile: kindIcon[entry.kind], tone: entry.kind === "adventure" ? "cover" : undefined, name: entryTitle(entry), badges: _jsxs(_Fragment, { children: [named && _jsx("span", { class: "package-kind", children: kindLabel(entry.kind) }), _jsx(Trust, { verified: entry.verified, code: entry.code, author: entry.author })] }), about: entry.description === undefined || entry.kind === "adventure" ? entry.description : phraseLabel(entry.description), meta: (version !== undefined || facts.length > 0) && (_jsxs(_Fragment, { children: [version, version !== undefined && facts.length > 0 && " · ", facts.map(isolated).join(" · ")] })), focusable: true, actions: entry.update && entry.kind !== "adventure"
460
+ return (_jsxs(PackageRow, { tile: kindIcon[entry.kind], tone: entry.kind === "adventure" ? "cover" : undefined, name: entryTitle(entry), badges: _jsxs(_Fragment, { children: [named && _jsx("span", { class: "package-kind", children: kindLabel(entry.kind) }), _jsx(Trust, { verified: entry.verified, code: entry.code, author: entry.author })] }), about: entry.description === undefined || entry.kind === "adventure" ? entry.description : phraseLabel(entry.description), meta: (version !== undefined || facts.length > 0) && (_jsxs(_Fragment, { children: [version, version !== undefined && facts.length > 0 && " · ", facts.map(isolated).join(" · ")] })), needs: needs, focusable: true, actions: entry.update && entry.kind !== "adventure"
364
461
  ? action(t("Update"), t("Update {name} to {version}", { name: entryTitle(entry), version: entry.version ?? "" }), "update", onUpdate, true)
365
462
  : here === "used" || (here === "here" && entry.kind !== "extension")
366
463
  ? (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), entry.kind === "adventure" || entry.kind === "extension" ? t("In the campaign") : t("On this computer")] }))
@@ -368,13 +465,60 @@ function CatalogRow({ entry, named, view, state, onAdd, onUpdate }) {
368
465
  ? action(t("Download"), t("Download {name}", { name: entryTitle(entry) }), "download", onAdd)
369
466
  : action(asksYes ? t("Add…") : t("Add"), t("Add {name}", { name: entryTitle(entry) }), "plus", onAdd), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said, onSee: state.onSee })] }));
370
467
  }
468
+ /**
469
+ * RPG Engine itself (D-515 (3)), first among the installed: its version and npm's newer one, with Update when npm installed it globally; installed another way,
470
+ * why the page does not update it; once updated, how a new chat, or the app opened again, brings it, as the chat and this page go on with this one.
471
+ */
472
+ function EngineCard({ engine, updated, newer, state, onUpdate }) {
473
+ const folder = engine?.folder ?? "";
474
+ const why = engine === undefined
475
+ ? t("Asking npm for the newest version…")
476
+ : engine.install === "link"
477
+ ? t("Installed with npm link from {folder}, for its development: update it there, with git pull and npm run build.", { folder })
478
+ : engine.install === "other"
479
+ ? t("Installed another way, in {folder}: update it the way you installed it.", { folder })
480
+ : engine.failed !== undefined
481
+ ? t("npm does not answer: a newer version cannot be checked now.")
482
+ : undefined;
483
+ // A newer one this page does not install is still said, by its version.
484
+ const shownNewer = updated === undefined && engine?.update === true ? engine.latest : undefined;
485
+ return (_jsxs("section", { class: "card", "aria-labelledby": "packages-engine", children: [_jsx(CardHead, { icon: iconPath("engine"), title: _jsx("h3", { id: "packages-engine", tabIndex: -1, children: t("Engine") }) }), _jsx("div", { class: "card-body package-body", children: _jsx("ul", { class: "package-list", children: _jsxs(PackageRow, { tile: "engine", name: engineName, about: t("What runs the game: the master's tools and this page."), meta: engine !== undefined && _jsx(VersionMeta, { version: engine.version, newer: shownNewer }), needs: why === undefined ? undefined : _jsx("span", { class: "package-needs", children: why }), actions: newer !== undefined
486
+ ? _jsx(UpdateButton, { id: "engine-update", name: engineName, version: newer, busy: state.busy, onClick: onUpdate })
487
+ : engine?.update === false && engine.install === "global" && updated === undefined && (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), t("Up to date")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said }), updated !== undefined && _jsx(RestartNote, { updated: updated })] }) }) })] }));
488
+ }
489
+ /**
490
+ * The engine installed, and how the master comes to use it, in the player's words: this chat goes on with the one it started with; a new chat, or the app
491
+ * opened again, takes the new one, and this page is read again after it, never by itself, as the running game would serve it the new one's files.
492
+ */
493
+ function RestartNote({ updated }) {
494
+ const note = useRef(null);
495
+ // Just updated, the focus Update had comes here; kept from before a reload, it stays where the page puts it.
496
+ useEffect(() => {
497
+ if (updated.now) {
498
+ note.current?.focus({ preventScroll: true });
499
+ note.current?.scrollIntoView({ block: "nearest" });
500
+ }
501
+ }, []);
502
+ const steps = updated.restart === "app"
503
+ ? [t("Quit the app you play in completely, not just its window, then open it again."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")]
504
+ : [t("Close this chat."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")];
505
+ return (_jsxs("div", { ref: note, class: "package-said package-restart", role: "status", tabIndex: -1, children: [_jsx("p", { children: `✓ ${t("RPG Engine {version} is installed.", { version: updated.to })}` }), _jsx("p", { children: t("The master goes on with {version} in this chat. To play with {next}:", { version: updated.from, next: updated.to }) }), _jsx("ol", { children: steps.map((step) => _jsx("li", { children: step }, step)) })] }));
506
+ }
507
+ /**
508
+ * What a package's latest needs of the engine (D-515 (2)), under its meta: which version of it, and the way to the engine's card, to update it first; the
509
+ * version offered meanwhile is the newest this engine reads.
510
+ */
511
+ function NeedsEngine({ newer, canUpdate, onGo }) {
512
+ const { version, engine } = newer;
513
+ return (_jsxs("span", { class: "package-needs", children: [_jsx("span", { children: engine === undefined ? t("Version {version} needs a newer RPG Engine.", { version }) : t("Version {version} needs RPG Engine {engine}.", { version, engine }) }), _jsxs("button", { type: "button", class: "package-see", onClick: onGo, children: [canUpdate ? t("Update RPG Engine first") : t("See RPG Engine"), _jsx(Icon, { name: "fold" })] })] }));
514
+ }
371
515
  /**
372
516
  * A game system here: the campaign's, chosen in its setup and locked; another, for a new campaign, which can go off this computer when npm installed it; npm's
373
517
  * newer version, to update it.
374
518
  */
375
- function SystemRow({ system, newer, fresh, state, onUpdate, onUninstall }) {
519
+ function SystemRow({ system, newer, needs, fresh, state, onUpdate, onUninstall }) {
376
520
  const target = system.package ?? system.name;
377
- return (_jsxs(PackageRow, { tile: "dice", tone: system.used ? undefined : "dim", name: _jsx("span", { class: "system-chip", children: system.name }), badges: _jsx(Trust, { verified: system.verified, code: system.code }), about: systemTitleLabel(system.title), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: system.version, newer: newer }), _jsx(ReportLink, { issues: system.issues, name: system.name, after: system.version !== undefined || newer !== undefined })] }), row: `system:${system.name}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: system.name, version: newer, busy: state.busy, onClick: () => onUpdate(target) }), system.used
521
+ return (_jsxs(PackageRow, { tile: "dice", tone: system.used ? undefined : "dim", name: _jsx("span", { class: "system-chip", children: system.name }), badges: _jsx(Trust, { verified: system.verified, code: system.code }), about: systemTitleLabel(system.title), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: system.version, newer: newer }), _jsx(ReportLink, { issues: system.issues, name: system.name, after: system.version !== undefined || newer !== undefined }), _jsx(OwnPageLinks, { name: system.package })] }), needs: needs, row: `system:${system.name}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: system.name, version: newer, busy: state.busy, onClick: () => onUpdate(target) }), system.used
378
522
  ? (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("In use · chosen in the setup")] }))
379
523
  : (_jsxs(_Fragment, { children: [_jsx("span", { class: "package-quiet", children: t("Not in this campaign") }), system.package !== undefined && _jsx(UninstallButton, { name: system.name, busy: state.busy, onClick: () => onUninstall(target) })] }))] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
380
524
  }
@@ -386,12 +530,12 @@ function AdventureRow({ adventure, fresh, state, onTakeOut }) {
386
530
  : (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("Part of the story")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
387
531
  }
388
532
  /** An extension here: whose it is, what it is, its version and npm's newer one; whether the campaign uses it, as a switch; one that does not read, in red. */
389
- function ExtensionRow({ extension, newer, fresh, state, onUse, onUpdate, onUninstall }) {
533
+ function ExtensionRow({ extension, newer, needs, fresh, state, onUse, onUpdate, onUninstall }) {
390
534
  const name = phraseLabel(extension.name);
391
535
  if ("broken" in extension) {
392
536
  return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not read: install it again.") }), meta: _jsxs(_Fragment, { children: [_jsx("bdi", { class: "package-why", children: extension.broken }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true })] }), actions: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name} again", { name }), "aria-disabled": state.busy, onClick: () => !state.busy && onUpdate(), children: [_jsx(Icon, { name: "update" }), t("Install it again")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
393
537
  }
394
- return (_jsxs(PackageRow, { tile: "packages", name: name, badges: _jsx(Trust, { verified: extension.verified, code: false }), about: `${phraseLabel(extension.about.replace(/\.$/, ""))}.`, meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: extension.version, newer: newer }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true })] }), row: `extension:${extension.package}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: extension.used, "aria-label": t("{name}: in use", { name }), "aria-disabled": state.busy, onClick: (event) => {
538
+ return (_jsxs(PackageRow, { tile: "packages", name: name, badges: _jsx(Trust, { verified: extension.verified, code: false }), about: `${phraseLabel(extension.about.replace(/\.$/, ""))}.`, meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: extension.version, newer: newer }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true }), _jsx(OwnPageLinks, { name: extension.package })] }), needs: needs, row: `extension:${extension.package}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: extension.used, "aria-label": t("{name}: in use", { name }), "aria-disabled": state.busy, onClick: (event) => {
395
539
  event.preventDefault();
396
540
  if (!state.busy) {
397
541
  onUse(!extension.used);
@@ -404,14 +548,14 @@ function MissingRow({ name, state, onInstall }) {
404
548
  return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: shown, about: _jsx("span", { class: "package-red", children: t("Missing on this computer: the master does not use it until you install it.") }), actions: _jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name}", { name: shown }), "aria-disabled": state.busy, onClick: () => !state.busy && onInstall(), children: [_jsx(Icon, { name: "download" }), t("Install")] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
405
549
  }
406
550
  /** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
407
- function LanguageRow({ language, newer, fresh, state, onUpdate, onUninstall }) {
551
+ function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
408
552
  const page = pageLanguage().toLowerCase().split("-")[0] === language.code.toLowerCase().split("-")[0];
409
553
  const name = languageTitle(language);
410
- return (_jsxs(PackageRow, { tile: "language", name: name, badges: _jsx(Trust, { verified: language.verified, code: false }), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: language.version, newer: newer }), page && ` · ${t("the language of this page")}`, _jsx(ReportLink, { issues: language.issues, name: name, after: true })] }), row: `language:${language.code}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
554
+ return (_jsxs(PackageRow, { tile: "language", name: name, badges: _jsx(Trust, { verified: language.verified, code: false }), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: language.version, newer: newer }), page && ` · ${t("the language of this page")}`, _jsx(ReportLink, { issues: language.issues, name: name, after: true })] }), needs: needs, row: `language:${language.code}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
411
555
  }
412
556
  /** A row of the page: the tile, the words, what can be done at the end; under them, the work going on and what happened. */
413
- function PackageRow({ tile, tone, name, badges, about, meta, actions, focusable, row, fresh, children }) {
414
- return (_jsxs("li", { class: fresh ? "package-row fresh" : "package-row", ...(focusable || fresh ? { tabIndex: -1 } : {}), ...(row === undefined ? {} : { "data-row": row }), children: [_jsx("span", { class: tone === undefined ? "package-tile" : `package-tile ${tone}`, "aria-hidden": "true", children: _jsx(Icon, { name: tile }) }), _jsxs("span", { class: "package-text", children: [_jsxs("span", { class: "package-name", children: [_jsx("strong", { class: "package-title", children: name }), badges] }), about !== undefined && about !== "" && _jsx("span", { class: "package-about", children: typeof about === "string" ? _jsx("bdi", { children: about }) : about }), meta !== undefined && meta !== false && _jsx("span", { class: "package-meta", children: meta })] }), actions !== undefined && _jsx("span", { class: "package-actions", children: actions }), children] }));
557
+ function PackageRow({ tile, tone, name, badges, about, meta, needs, actions, focusable, row, fresh, children }) {
558
+ return (_jsxs("li", { class: fresh ? "package-row fresh" : "package-row", ...(focusable || fresh ? { tabIndex: -1 } : {}), ...(row === undefined ? {} : { "data-row": row }), children: [_jsx("span", { class: tone === undefined ? "package-tile" : `package-tile ${tone}`, "aria-hidden": "true", children: _jsx(Icon, { name: tile }) }), _jsxs("span", { class: "package-text", children: [_jsxs("span", { class: "package-name", children: [_jsx("strong", { class: "package-title", children: name }), badges] }), about !== undefined && about !== "" && _jsx("span", { class: "package-about", children: typeof about === "string" ? _jsx("bdi", { children: about }) : about }), meta !== undefined && meta !== false && _jsx("span", { class: "package-meta", children: meta }), needs] }), actions !== undefined && _jsx("span", { class: "package-actions", children: actions }), children] }));
415
559
  }
416
560
  /** Whose a package is: ours, a shield with its tick; someone else's with code, in red with the shield's mark and the word, never the colour alone. */
417
561
  function Trust({ verified, code, author }) {
@@ -436,8 +580,8 @@ export function ReportLink({ issues, name, after }) {
436
580
  return (_jsxs(_Fragment, { children: [after && _jsx("span", { class: "package-report-gap", children: " · " }), _jsx("a", { class: "package-report", href: issues, target: "_blank", rel: "noreferrer", "aria-label": t("Report a problem with {name}", { name }), children: t("Report a problem") })] }));
437
581
  }
438
582
  /** Update, for a row npm has a newer version of. */
439
- function UpdateButton({ name, version, busy, onClick }) {
440
- return (_jsxs("button", { type: "button", class: "button package-button accent", "aria-label": t("Update {name} to {version}", { name, version }), "aria-disabled": busy, onClick: () => !busy && onClick(), children: [_jsx(Icon, { name: "update" }), t("Update")] }));
583
+ function UpdateButton({ id, name, version, busy, onClick }) {
584
+ return (_jsxs("button", { type: "button", id: id, class: "button package-button accent", "aria-label": t("Update {name} to {version}", { name, version }), "aria-disabled": busy, onClick: () => !busy && onClick(), children: [_jsx(Icon, { name: "update" }), t("Update")] }));
441
585
  }
442
586
  /** The bin that takes a package off this computer, after asking. */
443
587
  function UninstallButton({ name, busy, onClick }) {
@@ -549,9 +693,13 @@ function samePackage(entry, name) {
549
693
  }
550
694
  /** npm's newer version of a package here, as the catalog says it. */
551
695
  function newerOf(name, kind, catalog) {
552
- const entry = catalog?.entries.find((one) => one.kind === kind && samePackage(one, name));
696
+ const entry = entryOf(name, kind, catalog);
553
697
  return entry?.update === true ? entry.version : undefined;
554
698
  }
699
+ /** A package here as the catalog has it. */
700
+ function entryOf(name, kind, catalog) {
701
+ return catalog?.entries.find((one) => one.kind === kind && samePackage(one, name));
702
+ }
555
703
  /** How many packages here npm has a newer version of: the count on the Installed tab. */
556
704
  function updateCount(view, catalog) {
557
705
  const systems = (view.systems ?? []).filter((one) => one.package !== undefined && newerOf(one.package, "system", catalog) !== undefined);
@@ -571,7 +719,7 @@ function rowKeys(view) {
571
719
  /** Whose a work is, said away from its row: a catalog's package by its title, else as it was asked. */
572
720
  function workTitle(work, catalog) {
573
721
  const entry = catalog?.entries.find((one) => `catalog:${one.source}` === work.at);
574
- return entry === undefined ? work.name.replace(/^npm:/, "") : entryTitle(entry);
722
+ return work.action === "engine" ? engineName : entry === undefined ? work.name.replace(/^npm:/, "") : entryTitle(entry);
575
723
  }
576
724
  /** The tab of a place of the page: the field and the catalog are Add's, the library's field and folders the Library's, the rest Installed's. */
577
725
  function tabOf(at) {
@@ -592,8 +740,8 @@ function workPlace(work, view, catalog) {
592
740
  const system = view.systems?.find((one) => same(one.name, one.package));
593
741
  const language = view.languages?.find((one) => same(one.code, one.package));
594
742
  const entry = catalog?.entries.find((one) => same(one.source));
595
- if (work.action === "library") {
596
- return "library";
743
+ if (work.action === "library" || work.action === "engine") {
744
+ return work.action;
597
745
  }
598
746
  if (work.action === "add") {
599
747
  return entry !== undefined ? `catalog:${entry.source}` : extension !== undefined ? `extension:${extension}` : "add";
@@ -651,6 +799,7 @@ function workingText(action) {
651
799
  remove: t("Taking it out of the campaign…"),
652
800
  uninstall: t("Uninstalling…"),
653
801
  library: t("Changing the library…"),
802
+ engine: t("Updating RPG Engine…"),
654
803
  };
655
804
  return texts[action];
656
805
  }