rpg-engine 0.21.0 → 0.23.1

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 (165) hide show
  1. package/README.md +5 -5
  2. package/dist/campaign/create-campaign.d.ts +5 -0
  3. package/dist/campaign/create-campaign.js +40 -12
  4. package/dist/campaign/find-campaign.d.ts +5 -0
  5. package/dist/campaign/find-campaign.js +10 -5
  6. package/dist/campaign/host-files.d.ts +15 -4
  7. package/dist/campaign/host-files.js +134 -14
  8. package/dist/campaign/index.d.ts +4 -3
  9. package/dist/campaign/index.js +4 -3
  10. package/dist/campaign/port.d.ts +6 -0
  11. package/dist/campaign/port.js +24 -0
  12. package/dist/campaign/settings.d.ts +17 -0
  13. package/dist/campaign/settings.js +24 -1
  14. package/dist/cli/cli.js +33 -6
  15. package/dist/commands/config/config.js +15 -1
  16. package/dist/commands/config/dashboard.d.ts +4 -0
  17. package/dist/commands/config/dashboard.js +43 -7
  18. package/dist/commands/config/shown.js +4 -0
  19. package/dist/commands/config/words.d.ts +3 -1
  20. package/dist/commands/config/words.js +29 -2
  21. package/dist/commands/image.d.ts +3 -0
  22. package/dist/commands/image.js +31 -4
  23. package/dist/commands/import/import.d.ts +1 -1
  24. package/dist/commands/import/import.js +5 -0
  25. package/dist/commands/init.d.ts +2 -0
  26. package/dist/commands/init.js +21 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.js +27 -0
  29. package/dist/commands/package/theme.js +2 -1
  30. package/dist/commands/scene/scene.js +6 -1
  31. package/dist/commands/shared/books/adventures.d.ts +1 -0
  32. package/dist/commands/shared/books/adventures.js +1 -1
  33. package/dist/commands/shared/campaign/git.d.ts +25 -0
  34. package/dist/commands/shared/campaign/git.js +104 -0
  35. package/dist/commands/shared/campaign/images.js +5 -3
  36. package/dist/commands/shared/campaign/saves.js +5 -1
  37. package/dist/commands/shared/characters/voices.d.ts +2 -2
  38. package/dist/commands/shared/characters/voices.js +8 -5
  39. package/dist/commands/shared/packages/catalog.js +24 -5
  40. package/dist/commands/status.d.ts +1 -0
  41. package/dist/commands/status.js +8 -4
  42. package/dist/core/context.d.ts +17 -6
  43. package/dist/core/context.js +2 -1
  44. package/dist/core/version.d.ts +2 -0
  45. package/dist/core/version.js +5 -0
  46. package/dist/dashboard/guide/ar.md +12 -7
  47. package/dist/dashboard/guide/cs.md +11 -6
  48. package/dist/dashboard/guide/da.md +11 -6
  49. package/dist/dashboard/guide/de.md +13 -8
  50. package/dist/dashboard/guide/el.md +11 -6
  51. package/dist/dashboard/guide/en.md +10 -5
  52. package/dist/dashboard/guide/es.md +11 -6
  53. package/dist/dashboard/guide/fi.md +11 -6
  54. package/dist/dashboard/guide/fr.md +12 -7
  55. package/dist/dashboard/guide/he.md +11 -6
  56. package/dist/dashboard/guide/hi.md +11 -6
  57. package/dist/dashboard/guide/hu.md +11 -6
  58. package/dist/dashboard/guide/is.md +11 -6
  59. package/dist/dashboard/guide/it.md +42 -37
  60. package/dist/dashboard/guide/ja.md +12 -7
  61. package/dist/dashboard/guide/ko.md +11 -6
  62. package/dist/dashboard/guide/nb.md +12 -7
  63. package/dist/dashboard/guide/nl.md +13 -8
  64. package/dist/dashboard/guide/pl.md +11 -6
  65. package/dist/dashboard/guide/pt.md +11 -6
  66. package/dist/dashboard/guide/ro.md +11 -6
  67. package/dist/dashboard/guide/ru.md +12 -7
  68. package/dist/dashboard/guide/sv.md +11 -6
  69. package/dist/dashboard/guide/tr.md +12 -7
  70. package/dist/dashboard/guide/uk.md +12 -7
  71. package/dist/dashboard/guide/zh.md +11 -6
  72. package/dist/dashboard/i18n/ar.json +30 -2
  73. package/dist/dashboard/i18n/cs.json +30 -2
  74. package/dist/dashboard/i18n/da.json +30 -2
  75. package/dist/dashboard/i18n/de.json +30 -2
  76. package/dist/dashboard/i18n/el.json +30 -2
  77. package/dist/dashboard/i18n/es.json +30 -2
  78. package/dist/dashboard/i18n/fi.json +30 -2
  79. package/dist/dashboard/i18n/fr.json +30 -2
  80. package/dist/dashboard/i18n/he.json +30 -2
  81. package/dist/dashboard/i18n/hi.json +30 -2
  82. package/dist/dashboard/i18n/hu.json +30 -2
  83. package/dist/dashboard/i18n/is.json +30 -2
  84. package/dist/dashboard/i18n/it.json +30 -2
  85. package/dist/dashboard/i18n/ja.json +30 -2
  86. package/dist/dashboard/i18n/ko.json +30 -2
  87. package/dist/dashboard/i18n/nb.json +30 -2
  88. package/dist/dashboard/i18n/nl.json +30 -2
  89. package/dist/dashboard/i18n/pl.json +30 -2
  90. package/dist/dashboard/i18n/pt.json +30 -2
  91. package/dist/dashboard/i18n/ro.json +30 -2
  92. package/dist/dashboard/i18n/ru.json +30 -2
  93. package/dist/dashboard/i18n/sv.json +30 -2
  94. package/dist/dashboard/i18n/tr.json +30 -2
  95. package/dist/dashboard/i18n/uk.json +30 -2
  96. package/dist/dashboard/i18n/zh.json +30 -2
  97. package/dist/dashboard/packages/installed.js +2 -2
  98. package/dist/dashboard/packages/packages.js +1 -1
  99. package/dist/dashboard/parts/labels.js +7 -0
  100. package/dist/dashboard/settings/settings.js +45 -9
  101. package/dist/dashboard/shell/notices.js +1 -1
  102. package/dist/dashboard/shell/system-style.js +89 -5
  103. package/dist/dashboard/shell/tooltip.js +5 -4
  104. package/dist/dashboard/style.css +245 -84
  105. package/dist/git/git.d.ts +12 -0
  106. package/dist/git/git.js +175 -0
  107. package/dist/git/ignore.d.ts +2 -0
  108. package/dist/git/ignore.js +16 -0
  109. package/dist/git/index.d.ts +2 -0
  110. package/dist/git/index.js +2 -0
  111. package/dist/helpers/briefs.d.ts +4 -0
  112. package/dist/helpers/briefs.js +13 -0
  113. package/dist/helpers/chosen.d.ts +8 -4
  114. package/dist/helpers/chosen.js +38 -14
  115. package/dist/helpers/index.d.ts +3 -2
  116. package/dist/helpers/index.js +5 -3
  117. package/dist/helpers/opencode.d.ts +13 -0
  118. package/dist/helpers/opencode.js +202 -0
  119. package/dist/importer/index.d.ts +1 -1
  120. package/dist/importer/index.js +1 -1
  121. package/dist/instructions/index.d.ts +2 -2
  122. package/dist/instructions/index.js +3 -3
  123. package/dist/languages/pack.js +2 -1
  124. package/dist/server/approver.d.ts +4 -2
  125. package/dist/server/approver.js +27 -7
  126. package/dist/server/bell/antigravity.d.ts +10 -0
  127. package/dist/server/bell/antigravity.js +95 -0
  128. package/dist/server/bell/index.d.ts +2 -0
  129. package/dist/server/bell/index.js +2 -0
  130. package/dist/server/bell/listener.d.ts +43 -0
  131. package/dist/server/bell/listener.js +149 -0
  132. package/dist/server/dashboard/files.d.ts +3 -2
  133. package/dist/server/dashboard/files.js +44 -15
  134. package/dist/server/dashboard/index.d.ts +25 -3
  135. package/dist/server/dashboard/index.js +58 -23
  136. package/dist/server/dashboard/news.d.ts +5 -2
  137. package/dist/server/dashboard/news.js +82 -14
  138. package/dist/server/dashboard/ports.d.ts +17 -2
  139. package/dist/server/dashboard/ports.js +60 -4
  140. package/dist/server/mcp.d.ts +6 -4
  141. package/dist/server/mcp.js +66 -18
  142. package/dist/server/player-acts.d.ts +21 -1
  143. package/dist/server/player-acts.js +38 -2
  144. package/dist/server/route/front.d.ts +3 -0
  145. package/dist/server/route/front.js +97 -0
  146. package/dist/server/route/index.d.ts +3 -0
  147. package/dist/server/route/index.js +3 -0
  148. package/dist/server/route/notes.d.ts +8 -0
  149. package/dist/server/route/notes.js +50 -0
  150. package/dist/server/route/router.d.ts +31 -0
  151. package/dist/server/route/router.js +215 -0
  152. package/dist/themes/css.d.ts +1 -1
  153. package/dist/themes/css.js +101 -2
  154. package/dist/themes/index.d.ts +1 -1
  155. package/dist/themes/index.js +1 -1
  156. package/dist/themes/theme.d.ts +34 -3
  157. package/dist/themes/theme.js +176 -19
  158. package/instructions/core.md +1 -0
  159. package/instructions/dashboard-guide.md +1 -1
  160. package/instructions/start.md +1 -1
  161. package/instructions/voices-opencode.md +1 -0
  162. package/package.json +3 -2
  163. package/plugins/opencode.js +174 -0
  164. package/dist/server/bell-listener.d.ts +0 -9
  165. package/dist/server/bell-listener.js +0 -83
@@ -45,14 +45,14 @@ export function MissingRow({ name, state, onInstall }) {
45
45
  * A theme installed on this computer (D-574): its name, its version and GitHub's newer one, and whether this page shows it now; one that fails a check, in red
46
46
  * with why, which Settings does not offer.
47
47
  */
48
- export function ThemeRow({ theme, newer, shown, fresh, state, onUpdate, onUninstall }) {
48
+ export function ThemeRow({ theme, newer, needs, shown, fresh, state, onUpdate, onUninstall }) {
49
49
  const name = _jsx("bdi", { children: theme.name });
50
50
  const problems = theme.problems ?? [];
51
51
  const uninstall = _jsx(UninstallButton, { name: theme.name, busy: state.busy, onClick: onUninstall });
52
52
  if (problems.length > 0) {
53
53
  return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not pass the page's checks: Settings does not offer it.") }), meta: _jsxs(_Fragment, { children: [theme.version !== undefined && `${theme.version} · `, _jsx("bdi", { class: "package-why", children: problems[0] })] }), row: `theme:${theme.id}`, fresh: fresh, actions: uninstall, children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
54
54
  }
55
- return (_jsxs(PackageRow, { tile: "theme", name: name, meta: (theme.version !== undefined || newer !== undefined || shown) && (_jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: theme.version, newer: newer }), shown && `${theme.version !== undefined || newer !== undefined ? " · " : ""}${t("the style of this page")}`] })), row: `theme:${theme.id}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: theme.name, version: newer, busy: state.busy, onClick: onUpdate }), uninstall] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
55
+ return (_jsxs(PackageRow, { tile: "theme", name: name, meta: (theme.version !== undefined || newer !== undefined || shown) && (_jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: theme.version, newer: newer }), shown && `${theme.version !== undefined || newer !== undefined ? " · " : ""}${t("the style of this page")}`] })), needs: needs, row: `theme:${theme.id}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: theme.name, version: newer, busy: state.busy, onClick: onUpdate }), uninstall] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
56
56
  }
57
57
  /** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
58
58
  export function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
@@ -223,7 +223,7 @@ export function PackagesPage({ version, tab, item, layers = [], sceneOpen = fals
223
223
  ? add(`extension:${extension.package}`, extension.package)
224
224
  : 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-themes", children: [_jsx(CardHead, { icon: iconPath("theme"), title: _jsx("h3", { id: "packages-themes", tabIndex: -1, children: t("Themes") }), ...(themes.length === 0 ? {} : { note: String(themes.length) }) }), _jsxs("div", { class: "card-body package-body", children: [themes.length === 0 && _jsx("p", { class: "package-note", children: t("None: a theme changes the page's colours, faces and pictures, in every campaign; you find them in Add, in the catalog.") }), themes.length > 0 && (_jsxs(_Fragment, { children: [_jsx("ul", { class: "package-list", children: themes.map((theme) => {
225
225
  const entry = themeEntryOf(theme, catalog.read);
226
- return (_jsx(ThemeRow, { theme: theme, newer: newerVersion(entry), shown: theme.id === themeShown, fresh: fresh.includes(`theme:${theme.id}`), state: rowState(`theme:${theme.id}`), onUpdate: () => void update(`theme:${theme.id}`, theme.id, theme.name, entry), onUninstall: () => setAsking({ kind: "uninstall", what: "theme", name: theme.name, target: `theme:${theme.id}`, at: `theme:${theme.id}` }) }, theme.id));
226
+ return (_jsx(ThemeRow, { theme: theme, newer: newerVersion(entry), needs: needs(entry?.newer), shown: theme.id === themeShown, fresh: fresh.includes(`theme:${theme.id}`), state: rowState(`theme:${theme.id}`), onUpdate: () => void update(`theme:${theme.id}`, theme.id, theme.name, entry), onUninstall: () => setAsking({ kind: "uninstall", what: "theme", name: theme.name, target: `theme:${theme.id}`, at: `theme:${theme.id}` }) }, theme.id));
227
227
  }) }), _jsx("p", { class: "package-note", children: t("You choose one in Settings, under Game style.") })] })), _jsx(CardSaid, { said: said, at: "themes" })] })] }), _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) => {
228
228
  const entry = languageEntryOf(language, catalog.read);
229
229
  return (_jsx(LanguageRow, { language: language, newer: newerVersion(entry), needs: needs(entry?.newer), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void update(`language:${language.code}`, language.package, languageTitle(language), entry), onUninstall: () => setAsking({
@@ -236,6 +236,9 @@ export function settingLabel(name) {
236
236
  veils: t("Veils"),
237
237
  orders: t("Standing orders"),
238
238
  language: t("Language"),
239
+ git: t("Automatic commits"),
240
+ "git-saves": t("Saves in the repository"),
241
+ "git-sessions": t("Chats in the repository"),
239
242
  companions: t("Companions"),
240
243
  preparation: t("Preparation"),
241
244
  length: t("Length"),
@@ -329,6 +332,10 @@ export function valueLabel(value) {
329
332
  master: t("The master"),
330
333
  important: t("Main characters"),
331
334
  always: t("Everyone"),
335
+ commit: t("Commit"),
336
+ push: t("Commit and push"),
337
+ out: t("Left out"),
338
+ in: t("Included"),
332
339
  "behind the screen": t("Behind the screen"),
333
340
  "in view": t("In view"),
334
341
  stops: t("Stops"),
@@ -24,6 +24,12 @@ const groups = [
24
24
  { names: ["lines", "veils"] },
25
25
  { names: ["orders"] },
26
26
  { names: ["pictures", "pictures-by", "language"] },
27
+ // Only where the campaign's folder is a git repository (D-576).
28
+ // What a public repository would show of the player (D-576).
29
+ {
30
+ names: ["git", "git-saves", "git-sessions"],
31
+ note: () => t("Keep the repository private. It holds the log of your sessions and your user's name on this computer; with the chats in, everything you wrote to the master too."),
32
+ },
27
33
  ];
28
34
  /** The Settings section; with `several` player characters, what a value means says so where it speaks of one character (D-480 (2)). */
29
35
  export function SettingsView({ version, several = false }) {
@@ -59,7 +65,10 @@ export function SettingsView({ version, several = false }) {
59
65
  ...group.names.flatMap((name) => settings.filter((setting) => setting.name === name)),
60
66
  ...(group.system ? settings.filter((setting) => !known.has(setting.name)) : []),
61
67
  ];
62
- return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: groupTitle(index) }), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.names[0]));
68
+ if (shown.length === 0) {
69
+ return null;
70
+ }
71
+ return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: groupTitle(index) }), group.note !== undefined && (_jsxs("div", { class: "settings-group-note setting-note fix", children: [_jsx(Icon, { name: "lock" }), _jsx("p", { children: group.note() })] })), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.names[0]));
63
72
  }), _jsx(WidgetSettings, { onChange: change }), _jsx(PageSettings, {})] }));
64
73
  }
65
74
  /**
@@ -69,10 +78,19 @@ export function SettingsView({ version, several = false }) {
69
78
  function meansText(setting, value, means, several) {
70
79
  return several && setting === "saves" && value === "checkpoint" ? t("if they all die, or if the table chooses it when one dies: back to the end of the last scene") : t(means);
71
80
  }
72
- /** Why a setting counts for nothing now, as the prose while an author is written (D-395); undefined for one that counts. */
81
+ /**
82
+ * Why a setting counts for nothing now, as the prose while an author is written (D-395), or what goes into the repository while the engine commits nothing
83
+ * (D-576); undefined for one that counts. Its values stay to choose, for when it counts again.
84
+ */
73
85
  function offBy(setting, settings) {
74
- const author = settings.find((one) => one.name === "author")?.value;
75
- return setting.name === "prose" && author !== undefined ? t("The author you wrote takes its place: this counts again once you clear the author.") : undefined;
86
+ const valueOf = (name) => settings.find((one) => one.name === name)?.value;
87
+ if (setting.name === "prose" && valueOf("author") !== undefined) {
88
+ return t("The author you wrote takes its place: this counts again once you clear the author.");
89
+ }
90
+ if ((setting.name === "git-saves" || setting.name === "git-sessions") && valueOf("git") === "off") {
91
+ return t("Counts only with automatic commits: while they are off, the engine puts nothing into the repository.");
92
+ }
93
+ return undefined;
76
94
  }
77
95
  /**
78
96
  * One setting: its name and what it is, its values to choose from, a list's items to add and take off, the player's own words, or the language; what the chosen
@@ -350,7 +368,7 @@ export function Command({ text }) {
350
368
  /**
351
369
  * Under the theme, the game's style, when the campaign's system has one, a theme or a page style (D-528), or this computer has themes installed (D-574): the
352
370
  * game's, each installed theme by its name, or the page's, kept in this browser for that system; the game's left out when its theme does not pass the check
353
- * of legibility, which the page's then says.
371
+ * of legibility, which the page's then says. Under it, for a theme shown with a style sheet of its own, whether the page adds it.
354
372
  */
355
373
  function gameStyleRows() {
356
374
  const style = gameStyle();
@@ -370,7 +388,9 @@ function gameStyleRows() {
370
388
  ...style.themes.map((one) => ({ value: installedStyle(one.id), label: one.name })),
371
389
  { value: "page", label: t("The page's"), ...refusedMeans },
372
390
  ];
373
- return [{
391
+ const own = style.ownStyle;
392
+ return [
393
+ {
374
394
  key: "game-style",
375
395
  name: t("Game style"),
376
396
  about,
@@ -382,7 +402,22 @@ function gameStyleRows() {
382
402
  },
383
403
  // The names of the installed themes go under the row's, with room for them.
384
404
  ...(installed ? { under: true } : {}),
385
- }];
405
+ },
406
+ // The own style sheet of the theme shown, which the page adds unchecked: off, the theme keeps its colours, faces and pictures (D-575).
407
+ ...(own === undefined ? [] : [{
408
+ key: "theme-style",
409
+ name: t("Theme's own style"),
410
+ about: t("what the theme adds to the page's look beyond its colours, faces and pictures; the page does not check it, so it may read less well"),
411
+ // Settings never take it, whatever it does: this switch stays in reach.
412
+ note: t("Settings never show it, so you can always turn it off here."),
413
+ options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }],
414
+ value: readChoice(own),
415
+ pick: (value) => {
416
+ writeChoice(own, value);
417
+ applyGameStyle();
418
+ },
419
+ }]),
420
+ ];
386
421
  }
387
422
  /** A name as a part of an element's id, without spaces: "dice sound" is dice-sound. */
388
423
  function idOf(name) {
@@ -481,7 +516,8 @@ function PageSettings() {
481
516
  return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: t("This page") }), _jsx("p", { class: "setting-about", children: t("Kept in this browser alone.") }), rows.map((row) => {
482
517
  const id = `page-${row.key}`;
483
518
  const chosen = row.options.find((option) => option.value === row.value);
484
- return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: chosen?.means === undefined ? `${id}-about` : `${id}-about ${id}-means`, options: row.options, value: row.value, onPick: row.pick }), chosen?.means !== undefined && (_jsx("div", { class: "setting-after", children: _jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] }) }))] }, row.key));
519
+ const described = [`${id}-about`, ...(chosen?.means === undefined ? [] : [`${id}-means`]), ...(row.note === undefined ? [] : [`${id}-note`])].join(" ");
520
+ return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: described, options: row.options, value: row.value, onPick: row.pick }), (chosen?.means !== undefined || row.note !== undefined) && (_jsxs("div", { class: "setting-after", children: [chosen?.means !== undefined && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] })), row.note !== undefined && _jsx("p", { class: "setting-means", id: `${id}-note`, children: row.note })] }))] }, row.key));
485
521
  })] }));
486
522
  }
487
523
  /**
@@ -557,7 +593,7 @@ function Segmented({ label, described, options, value, onPick }) {
557
593
  }
558
594
  /** A group of the campaign's settings by its place, in the page's language. */
559
595
  function groupTitle(index) {
560
- return [t("The game"), t("Learning the game"), t("The master's style"), t("Dice and measures"), t("Limits"), t("Your companions"), t("Pictures and language")][index] ?? "";
596
+ return [t("The game"), t("Learning the game"), t("The master's style"), t("Dice and measures"), t("Limits"), t("Your companions"), t("Pictures and language"), t("Git")][index] ?? "";
561
597
  }
562
598
  /** What a list's field suggests, as an example. */
563
599
  function exampleOf(name) {
@@ -45,7 +45,7 @@ export function gameNotices(problems, textsTranslating) {
45
45
  ...(translation?.state === "translating" ? [{ kind: "info", text: t("This computer is translating the page into {language}: until then it stays in English.", { language }) }] : []),
46
46
  ...(translation?.state === "unable" ? [{ kind: "info", text: t("The page stays in English: Codex or Claude Code would translate it into {language} on this computer.", { language }) }] : []),
47
47
  ...(textsTranslating !== undefined
48
- ? [{ kind: "info", text: t("With your account, Codex or Claude Code is translating the game's rules into {language}: until then they stay in English.", { language: textsLanguage }) }]
48
+ ? [{ kind: "info", text: t("With your account, Codex, Claude Code or OpenCode is translating the game's rules into {language}: until then they stay in English.", { language: textsLanguage }) }]
49
49
  : []),
50
50
  ];
51
51
  }
@@ -1,3 +1,7 @@
1
+ // The game's style on the page (D-528, D-574): the theme of the campaign's system, its CSS of custom properties in the layer theme, its icons, and the free
2
+ // style sheet of the system's page module over the page's; or a theme installed on this computer, its CSS and icons alone; or the page's own. This browser
3
+ // remembers the choice for each system. A theme's own style sheet comes last, in the layer theme-style, while the player keeps it on, for each theme (D-575).
4
+ import { readAddress } from "../address.js";
1
5
  import { readChoice } from "./prefs.js";
2
6
  /** The event that tells the page the game's style changed: what draws an icon draws it again. */
3
7
  export const gameStyleChanged = "rpg-engine:game-style";
@@ -17,9 +21,20 @@ export function systemStylePref(system) {
17
21
  values: [...(shows ? ["game"] : []), ...(theme.themes ?? []).map((one) => installedStyle(one.id)), "page"],
18
22
  };
19
23
  }
20
- /** The game's style as last read, for Settings: its system and its theme's name; whether it has anything to show, or its theme was refused; the themes installed. */
24
+ /**
25
+ * The game's style as last read, for Settings: its system and its theme's name; whether it has anything to show, or its theme was refused; the themes
26
+ * installed; and the choice that keeps the own style sheet of the theme shown on, when it has one.
27
+ */
21
28
  export function gameStyle() {
22
- return { system: theme.system, name: theme.name, shows: gameShows(), refused: theme.refused === true, themes: (theme.themes ?? []).map(({ id, name }) => ({ id, name })) };
29
+ const own = shownOwnStyle();
30
+ return {
31
+ system: theme.system,
32
+ name: theme.name,
33
+ shows: gameShows(),
34
+ refused: theme.refused === true,
35
+ themes: (theme.themes ?? []).map(({ id, name }) => ({ id, name })),
36
+ ...(own === undefined ? {} : { ownStyle: own.choice }),
37
+ };
23
38
  }
24
39
  /** The installed theme the page shows for the campaign's system, by its id; undefined when it shows the game's style or its own. */
25
40
  export function shownInstalledTheme() {
@@ -50,8 +65,9 @@ export function applyGameStyle() {
50
65
  themeSheet.replaceSync(style.installed?.css ?? (style.game ? theme.css ?? "" : ""));
51
66
  // The free style of the system's page module goes with its own theme alone: never under another's colours.
52
67
  freeSheet.replaceSync(style.game ? freeStyle ?? "" : "");
53
- const others = document.adoptedStyleSheets.filter((sheet) => sheet !== themeSheet && sheet !== freeSheet);
54
- document.adoptedStyleSheets = [...others, themeSheet, freeSheet];
68
+ adopt();
69
+ watchAddress();
70
+ showOwnStyle();
55
71
  document.querySelectorAll(".title-too-wide").forEach((title) => title.classList.remove("title-too-wide"));
56
72
  watchTitles();
57
73
  fitTitles();
@@ -61,6 +77,72 @@ let theme = {};
61
77
  let freeStyle;
62
78
  let themeSheet;
63
79
  let freeSheet;
80
+ // The link to the own style sheet of the theme shown, and its address.
81
+ let ownLink;
82
+ let ownAddress;
83
+ /** The page's sheets of the game's style, after the page's own: the theme's custom properties, the system's free style. */
84
+ function adopt() {
85
+ const ours = [themeSheet, freeSheet].filter((sheet) => sheet !== undefined);
86
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets.filter((sheet) => !ours.includes(sheet)), ...ours];
87
+ }
88
+ /** The own style sheet of the theme shown, when it has one: its address, and the choice that keeps it on, by the theme. */
89
+ function shownOwnStyle() {
90
+ const style = chosen();
91
+ const address = style.installed?.style ?? (style.game ? theme.style : undefined);
92
+ const key = style.installed?.id ?? `game.${theme.system ?? ""}`;
93
+ return address === undefined ? undefined : { address, choice: { key: `rpg-engine.theme-style.${key}`, initial: "on", values: ["on", "off"] } };
94
+ }
95
+ /**
96
+ * Shows a theme's own style sheet, from its address, or none: a link to the server's sheet of one line that imports it into the layer theme-style, so that
97
+ * no brace of it closes that layer and its url() come from its folder. The new one shows before the old goes; one that fails is asked again at the next change.
98
+ */
99
+ function takeOwnStyle(address) {
100
+ if (address === ownAddress) {
101
+ return;
102
+ }
103
+ ownAddress = address;
104
+ const gone = ownLink;
105
+ ownLink = undefined;
106
+ if (address === undefined) {
107
+ gone?.remove();
108
+ return;
109
+ }
110
+ const link = document.createElement("link");
111
+ link.rel = "stylesheet";
112
+ link.href = address;
113
+ link.addEventListener("load", () => {
114
+ gone?.remove();
115
+ fitTitles();
116
+ });
117
+ link.addEventListener("error", () => {
118
+ gone?.remove();
119
+ if (ownLink === link) {
120
+ link.remove();
121
+ ownLink = undefined;
122
+ ownAddress = undefined;
123
+ }
124
+ });
125
+ ownLink = link;
126
+ document.head.append(link);
127
+ }
128
+ /** Whether the page shows Settings, which never take a theme's own style sheet: whatever it does, the switch that turns it off stays in reach. */
129
+ function inSettings() {
130
+ return readAddress(window.location.hash).section === "settings";
131
+ }
132
+ /** Takes the own style sheet off on the way into Settings, and back on the way out. */
133
+ function watchAddress() {
134
+ if (watchingAddress) {
135
+ return;
136
+ }
137
+ watchingAddress = true;
138
+ window.addEventListener("hashchange", showOwnStyle);
139
+ }
140
+ /** Shows the own style sheet of the theme shown while the player keeps it on, out of Settings. */
141
+ function showOwnStyle() {
142
+ const own = shownOwnStyle();
143
+ takeOwnStyle(own !== undefined && readChoice(own.choice) === "on" && !inSettings() ? own.address : undefined);
144
+ }
145
+ let watchingAddress = false;
64
146
  let watching = false;
65
147
  let fitting = false;
66
148
  // The card titles the theme's face may make too wide, and the campaign's name.
@@ -109,7 +191,9 @@ function fitTitles() {
109
191
  fitting = false;
110
192
  for (const title of document.querySelectorAll(titles)) {
111
193
  const head = title.closest("summary, .card-head") ?? title;
112
- if (!title.classList.contains("title-too-wide") && (title.scrollWidth > title.clientWidth + 1 || head.scrollWidth > head.clientWidth + 1)) {
194
+ // The campaign's name is cut by its link, not by its title.
195
+ const cut = title.querySelector(":scope > .title-home") ?? title;
196
+ if (!title.classList.contains("title-too-wide") && (cut.scrollWidth > cut.clientWidth + 1 || head.scrollWidth > head.clientWidth + 1)) {
113
197
  title.classList.add("title-too-wide");
114
198
  }
115
199
  }
@@ -171,8 +171,9 @@ function place() {
171
171
  const left = side === "start" ? startLeft : box.left + box.width / 2 - width / 2;
172
172
  const top = side === "start" ? box.top + box.height / 2 - height / 2 : side === "above" ? box.top - gap - height : box.bottom + gap;
173
173
  tip.dataset.side = side;
174
- tip.style.setProperty("--tip-left", `${Math.round(within(left, margin, windowWidth - margin - width))}px`);
175
- tip.style.setProperty("--tip-top", `${Math.round(within(top, margin, windowHeight - margin - height))}px`);
174
+ // Inline and !important, as no style sheet's rule outweighs them, a theme's own either (D-575).
175
+ tip.style.setProperty("left", `${Math.round(within(left, margin, windowWidth - margin - width))}px`, "important");
176
+ tip.style.setProperty("top", `${Math.round(within(top, margin, windowHeight - margin - height))}px`, "important");
176
177
  }
177
178
  function askedSide(element) {
178
179
  return element.classList.contains("tip-left") ? "start" : element.classList.contains("tip-below") ? "below" : "above";
@@ -215,9 +216,9 @@ function closeLayer(element) {
215
216
  function supportsPopover(element) {
216
217
  return typeof element.showPopover === "function";
217
218
  }
218
- // The moment a pointer rests on a control before its tip shows: the page's --wait.
219
+ // The moment a pointer rests on a control before its tip shows: the page's --wait, never more than a second, whatever a theme's own sheet says (D-575).
219
220
  function waitTime() {
220
221
  const value = getComputedStyle(document.documentElement).getPropertyValue("--wait").trim();
221
222
  const time = Number.parseFloat(value);
222
- return Number.isNaN(time) ? 500 : value.endsWith("ms") ? time : time * 1000;
223
+ return Number.isNaN(time) ? 500 : Math.min(Math.max(value.endsWith("ms") ? time : time * 1000, 0), 1000);
223
224
  }