rpg-engine 0.19.1 → 0.21.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 (229) hide show
  1. package/README.md +9 -6
  2. package/dist/adventures/index.d.ts +1 -1
  3. package/dist/adventures/index.js +1 -1
  4. package/dist/adventures/source.d.ts +3 -0
  5. package/dist/adventures/source.js +11 -49
  6. package/dist/campaign/create-campaign.d.ts +1 -1
  7. package/dist/campaign/create-campaign.js +4 -3
  8. package/dist/campaign/find-campaign.d.ts +6 -0
  9. package/dist/campaign/find-campaign.js +7 -1
  10. package/dist/campaign/host-files.js +22 -0
  11. package/dist/campaign/index.d.ts +2 -2
  12. package/dist/campaign/index.js +2 -2
  13. package/dist/campaign/last-choices.d.ts +10 -4
  14. package/dist/campaign/last-choices.js +43 -17
  15. package/dist/campaign/settings.d.ts +10 -2
  16. package/dist/campaign/settings.js +32 -8
  17. package/dist/chats/chat.d.ts +33 -0
  18. package/dist/chats/chat.js +50 -0
  19. package/dist/chats/claude-code.d.ts +5 -0
  20. package/dist/chats/claude-code.js +39 -0
  21. package/dist/chats/codex.d.ts +3 -0
  22. package/dist/chats/codex.js +42 -0
  23. package/dist/chats/index.d.ts +5 -0
  24. package/dist/chats/index.js +12 -0
  25. package/dist/chats/keep.d.ts +10 -0
  26. package/dist/chats/keep.js +50 -0
  27. package/dist/chats/read.d.ts +8 -0
  28. package/dist/chats/read.js +46 -0
  29. package/dist/cli/cli.js +6 -1
  30. package/dist/cli/command-line.js +3 -2
  31. package/dist/commands/book.d.ts +36 -0
  32. package/dist/commands/book.js +129 -0
  33. package/dist/commands/chats.d.ts +38 -0
  34. package/dist/commands/chats.js +93 -0
  35. package/dist/commands/config/config.js +2 -2
  36. package/dist/commands/config/dashboard.d.ts +8 -1
  37. package/dist/commands/config/dashboard.js +70 -16
  38. package/dist/commands/config/words.d.ts +1 -1
  39. package/dist/commands/config/words.js +18 -5
  40. package/dist/commands/find.js +1 -1
  41. package/dist/commands/image.d.ts +14 -0
  42. package/dist/commands/image.js +100 -20
  43. package/dist/commands/index.js +4 -0
  44. package/dist/commands/init.js +3 -3
  45. package/dist/commands/package/data.d.ts +35 -0
  46. package/dist/commands/package/data.js +117 -0
  47. package/dist/commands/package/here.d.ts +7 -2
  48. package/dist/commands/package/here.js +23 -11
  49. package/dist/commands/package/install.js +14 -15
  50. package/dist/commands/package/language.d.ts +15 -0
  51. package/dist/commands/package/language.js +109 -0
  52. package/dist/commands/package/package.js +20 -10
  53. package/dist/commands/package/result.d.ts +19 -0
  54. package/dist/commands/package/theme.d.ts +13 -0
  55. package/dist/commands/package/theme.js +66 -0
  56. package/dist/commands/package/uninstall.d.ts +4 -1
  57. package/dist/commands/package/uninstall.js +29 -9
  58. package/dist/commands/scene/close.d.ts +2 -0
  59. package/dist/commands/scene/close.js +20 -2
  60. package/dist/commands/scene/result.d.ts +2 -0
  61. package/dist/commands/scene/scene.d.ts +2 -0
  62. package/dist/commands/shared/books/adventures.d.ts +0 -4
  63. package/dist/commands/shared/books/adventures.js +2 -31
  64. package/dist/commands/shared/books/words.js +3 -2
  65. package/dist/commands/shared/campaign/book.d.ts +42 -0
  66. package/dist/commands/shared/campaign/book.js +118 -0
  67. package/dist/commands/shared/campaign/chats.d.ts +11 -0
  68. package/dist/commands/shared/campaign/chats.js +29 -0
  69. package/dist/commands/shared/campaign/images.js +7 -1
  70. package/dist/commands/shared/campaign/mode.js +3 -1
  71. package/dist/commands/shared/campaign/saves.js +13 -5
  72. package/dist/commands/shared/campaign/world.js +2 -1
  73. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  74. package/dist/commands/shared/packages/catalog.js +98 -42
  75. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  76. package/dist/commands/shared/packages/unpacked.js +146 -0
  77. package/dist/commands/shared/sheet/sheet.d.ts +7 -0
  78. package/dist/commands/shared/sheet/sheet.js +27 -0
  79. package/dist/commands/status.d.ts +1 -0
  80. package/dist/commands/status.js +4 -0
  81. package/dist/commands/view/page.js +4 -3
  82. package/dist/commands/view/result.d.ts +2 -0
  83. package/dist/commands/view/view.d.ts +1 -0
  84. package/dist/commands/view/view.js +4 -0
  85. package/dist/core/archive.d.ts +13 -0
  86. package/dist/core/archive.js +76 -0
  87. package/dist/core/consents.d.ts +2 -2
  88. package/dist/core/consents.js +3 -3
  89. package/dist/core/context.d.ts +40 -2
  90. package/dist/core/context.js +1 -0
  91. package/dist/core/download.js +1 -1
  92. package/dist/core/store.d.ts +5 -1
  93. package/dist/core/store.js +15 -2
  94. package/dist/dashboard/acts/names.js +10 -5
  95. package/dist/dashboard/acts/sending.js +5 -2
  96. package/dist/dashboard/acts/sheet.js +66 -15
  97. package/dist/dashboard/api.js +27 -4
  98. package/dist/dashboard/app.js +9 -4
  99. package/dist/dashboard/guide/ar.md +16 -15
  100. package/dist/dashboard/guide/cs.md +15 -14
  101. package/dist/dashboard/guide/da.md +17 -16
  102. package/dist/dashboard/guide/de.md +17 -16
  103. package/dist/dashboard/guide/el.md +17 -16
  104. package/dist/dashboard/guide/en.md +14 -13
  105. package/dist/dashboard/guide/es.md +15 -14
  106. package/dist/dashboard/guide/fi.md +15 -14
  107. package/dist/dashboard/guide/fr.md +20 -19
  108. package/dist/dashboard/guide/he.md +15 -14
  109. package/dist/dashboard/guide/hi.md +15 -14
  110. package/dist/dashboard/guide/hu.md +19 -18
  111. package/dist/dashboard/guide/is.md +15 -14
  112. package/dist/dashboard/guide/it.md +18 -17
  113. package/dist/dashboard/guide/ja.md +15 -14
  114. package/dist/dashboard/guide/ko.md +16 -15
  115. package/dist/dashboard/guide/nb.md +17 -16
  116. package/dist/dashboard/guide/nl.md +15 -14
  117. package/dist/dashboard/guide/pl.md +16 -15
  118. package/dist/dashboard/guide/pt.md +16 -15
  119. package/dist/dashboard/guide/ro.md +15 -14
  120. package/dist/dashboard/guide/ru.md +16 -15
  121. package/dist/dashboard/guide/sv.md +15 -14
  122. package/dist/dashboard/guide/tr.md +18 -17
  123. package/dist/dashboard/guide/uk.md +19 -18
  124. package/dist/dashboard/guide/zh.md +16 -15
  125. package/dist/dashboard/i18n/ar.json +63 -9
  126. package/dist/dashboard/i18n/cs.json +63 -9
  127. package/dist/dashboard/i18n/da.json +63 -9
  128. package/dist/dashboard/i18n/de.json +63 -9
  129. package/dist/dashboard/i18n/el.json +63 -9
  130. package/dist/dashboard/i18n/es.json +63 -9
  131. package/dist/dashboard/i18n/fi.json +63 -9
  132. package/dist/dashboard/i18n/fr.json +63 -9
  133. package/dist/dashboard/i18n/he.json +63 -9
  134. package/dist/dashboard/i18n/hi.json +63 -9
  135. package/dist/dashboard/i18n/hu.json +63 -9
  136. package/dist/dashboard/i18n/is.json +63 -9
  137. package/dist/dashboard/i18n/it.json +64 -10
  138. package/dist/dashboard/i18n/ja.json +63 -9
  139. package/dist/dashboard/i18n/ko.json +63 -9
  140. package/dist/dashboard/i18n/nb.json +63 -9
  141. package/dist/dashboard/i18n/nl.json +63 -9
  142. package/dist/dashboard/i18n/pl.json +63 -9
  143. package/dist/dashboard/i18n/pt.json +63 -9
  144. package/dist/dashboard/i18n/ro.json +63 -9
  145. package/dist/dashboard/i18n/ru.json +63 -9
  146. package/dist/dashboard/i18n/sv.json +63 -9
  147. package/dist/dashboard/i18n/tr.json +63 -9
  148. package/dist/dashboard/i18n/uk.json +63 -9
  149. package/dist/dashboard/i18n/zh.json +63 -9
  150. package/dist/dashboard/journal/book.js +107 -0
  151. package/dist/dashboard/journal/journal.js +16 -12
  152. package/dist/dashboard/kit.js +1 -1
  153. package/dist/dashboard/packages/catalog.js +31 -14
  154. package/dist/dashboard/packages/engine.js +46 -2
  155. package/dist/dashboard/packages/installed.js +13 -0
  156. package/dist/dashboard/packages/outcomes.js +21 -0
  157. package/dist/dashboard/packages/packages.js +41 -18
  158. package/dist/dashboard/packages/rows.js +3 -1
  159. package/dist/dashboard/parts/icons.js +3 -0
  160. package/dist/dashboard/parts/labels.js +6 -0
  161. package/dist/dashboard/parts/picture.js +89 -0
  162. package/dist/dashboard/parts/refusals.js +8 -1
  163. package/dist/dashboard/parts/widgets.js +3 -2
  164. package/dist/dashboard/place/view.js +1 -1
  165. package/dist/dashboard/play/scene.js +8 -5
  166. package/dist/dashboard/settings/settings.js +32 -16
  167. package/dist/dashboard/settings/setup.js +5 -3
  168. package/dist/dashboard/sheet/party.js +5 -2
  169. package/dist/dashboard/sheet/sheet.js +10 -6
  170. package/dist/dashboard/shell/notices.js +2 -2
  171. package/dist/dashboard/shell/system-style.js +45 -12
  172. package/dist/dashboard/shell/tooltip.js +223 -0
  173. package/dist/dashboard/style.css +775 -261
  174. package/dist/dashboard/world/calendar.js +1 -1
  175. package/dist/dashboard/world/lore.js +5 -4
  176. package/dist/dashboard/world/place-card.js +2 -1
  177. package/dist/helpers/briefs.d.ts +5 -0
  178. package/dist/helpers/briefs.js +8 -0
  179. package/dist/helpers/chosen.d.ts +8 -2
  180. package/dist/helpers/chosen.js +110 -6
  181. package/dist/helpers/codex.js +2 -1
  182. package/dist/helpers/index.d.ts +2 -2
  183. package/dist/helpers/index.js +2 -2
  184. package/dist/images/images.d.ts +2 -0
  185. package/dist/images/images.js +16 -2
  186. package/dist/images/index.d.ts +1 -1
  187. package/dist/images/index.js +1 -1
  188. package/dist/languages/index.d.ts +1 -1
  189. package/dist/languages/index.js +1 -1
  190. package/dist/languages/pack.d.ts +4 -1
  191. package/dist/languages/pack.js +16 -5
  192. package/dist/packages/engine.d.ts +7 -0
  193. package/dist/packages/engine.js +32 -1
  194. package/dist/packages/index.d.ts +1 -1
  195. package/dist/packages/index.js +1 -1
  196. package/dist/server/approver.d.ts +6 -0
  197. package/dist/server/approver.js +28 -0
  198. package/dist/server/chats.d.ts +3 -0
  199. package/dist/server/chats.js +27 -0
  200. package/dist/server/dashboard/engine.d.ts +18 -0
  201. package/dist/server/dashboard/engine.js +31 -0
  202. package/dist/server/dashboard/files.d.ts +8 -1
  203. package/dist/server/dashboard/files.js +30 -10
  204. package/dist/server/dashboard/index.d.ts +3 -0
  205. package/dist/server/dashboard/index.js +10 -1
  206. package/dist/server/dashboard/news.js +36 -5
  207. package/dist/server/dashboard/pictures.d.ts +7 -0
  208. package/dist/server/dashboard/pictures.js +62 -0
  209. package/dist/server/dashboard/writes.d.ts +5 -3
  210. package/dist/server/dashboard/writes.js +45 -14
  211. package/dist/server/mcp.js +37 -6
  212. package/dist/server/player-acts.d.ts +7 -2
  213. package/dist/server/player-acts.js +10 -3
  214. package/dist/testing/index.js +1 -0
  215. package/dist/themes/index.d.ts +2 -1
  216. package/dist/themes/index.js +4 -2
  217. package/dist/themes/installed.d.ts +14 -0
  218. package/dist/themes/installed.js +28 -0
  219. package/dist/themes/theme.d.ts +7 -0
  220. package/dist/themes/theme.js +22 -0
  221. package/instructions/core.md +3 -3
  222. package/instructions/dashboard-guide.md +1 -0
  223. package/instructions/mentor-hints.md +1 -1
  224. package/instructions/mentor-tutorial.md +1 -1
  225. package/instructions/party.md +1 -1
  226. package/instructions/play.md +2 -2
  227. package/instructions/start.md +1 -1
  228. package/package.json +2 -2
  229. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -81,7 +81,7 @@ export function PlaceMap({ map, place, acting, picking, choosing, bare = false,
81
81
  box.scrollLeft = Math.max(0, x * shown - box.clientWidth / 2);
82
82
  }, [map.columns, map.rows, self?.at.column, self?.at.row]);
83
83
  const drawn = (_jsxs(_Fragment, { children: [_jsx("path", { class: "lm-floor-fill", d: floor, "fill-rule": "evenodd" }), _jsx("g", { class: "lm-ground", "clip-path": "url(#lm-open)", children: open.filter((square) => groundKinds.includes(kindAt(map, square))).map((square) => _jsx(Ground, { kind: kindAt(map, square), x: X(square.column), y: Y(square.row), side: size, seed: square }, squareName(square))) }), _jsx("path", { class: "lm-grid", d: open.map((square) => `M${X(square.column)} ${Y(square.row)}h${size}v${size}h${-size}z`).join(""), "clip-path": "url(#lm-open)" }), open.filter((square) => featureAt(square)?.difficult).map((square) => _jsx(Corner, { x: X(square.column), y: Y(square.row), side: size }, squareName(square))), things.map((feature) => piecesOf(map, feature.symbol, feature.kind).map((piece) => (_jsxs("g", { class: `lm-thing ${feature.kind}`, children: [_jsx("title", { children: [featureName(feature), feature.blocks ? t("blocks") : "", feature.difficult ? t("difficult") : ""].filter((part) => part !== "").join(", ") }), _jsx(Thing, { kind: feature.kind, symbol: feature.symbol, x: X(piece.left), y: Y(piece.top), w: (piece.right - piece.left) * size, h: (piece.bottom - piece.top) * size, cells: piece.squares.map((square) => [X(square.column), Y(square.row)]) })] }, `${feature.symbol} ${piece.left} ${piece.top}`)))), _jsx("path", { class: "lm-shade", d: outline, "clip-path": "url(#lm-open)", filter: "url(#lm-blur)" })] }));
84
- return (_jsxs("section", { class: "lm", "aria-labelledby": "lm-title", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "lm-title", children: t("Map") }), note: place }), _jsx("div", { ref: frame, class: picking === undefined && choosing === undefined ? "lm-frame" : "lm-frame panned", style: { "--map-width": String(width) }, children: _jsxs("svg", { ref: svg, class: `lm-svg lm-look-${map.ground}`, viewBox: `0 0 ${width} ${height}`, ...(picking === undefined && choosing === undefined ? {} : { width: width * 1.2 }), role: "img", "aria-label": t("Map of {place}", { place }), children: [_jsxs("defs", { children: [_jsx(Patterns, {}), _jsx(GlassDefs, { prefix: "lm" }), _jsxs("radialGradient", { id: "lm-hostile-glow", children: [_jsx("stop", { offset: "0.75", "stop-color": "#c8321f", "stop-opacity": "0.3" }), _jsx("stop", { offset: "1", "stop-color": "#c8321f", "stop-opacity": "0" })] }), _jsx("clipPath", { id: "lm-open", children: _jsx("path", { d: floor, "clip-rule": "evenodd" }) }), !walled && (_jsx("mask", { id: "lm-fade", maskUnits: "userSpaceOnUse", x: 0, y: 0, width: width, height: height, children: _jsx("rect", { x: X(0) + size * 0.35, y: Y(0) + size * 0.35, width: map.columns * size - size * 0.7, height: map.rows * size - size * 0.7, fill: "#fff", filter: "url(#lm-soft)" }) })), standing.map((one, index) => (_jsx("clipPath", { id: `lm-token-${index}`, children: _jsx("circle", { cx: middle(one)[0], cy: middle(one)[1], r: size * (one.side ?? 1) * 0.43 }) }, index)))] }), _jsx("rect", { class: "lm-paper", width: width, height: height }), _jsx("g", { class: "lm-walls", children: squares.filter((square) => ["wall", "rock", "window"].includes(kindAt(map, square)) && nearRoom(square)).map((square) => (_jsxs(Fragment, { children: [_jsx("rect", { class: "lm-wall-under", x: X(square.column), y: Y(square.row), width: size, height: size }), _jsx("rect", { class: `lm-wall ${kindAt(map, square)}`, x: X(square.column), y: Y(square.row), width: size, height: size })] }, squareName(square)))) }), walled ? drawn : _jsx("g", { mask: "url(#lm-fade)", children: drawn }), reach.length > 0 && (_jsx("g", { class: "lm-out", "aria-hidden": "true", "clip-path": "url(#lm-open)", children: open.filter((square) => !reach.some((near) => near.column === square.column && near.row === square.row)).map((square) => (_jsx("rect", { x: X(square.column), y: Y(square.row), width: size, height: size }, squareName(square)))) })), _jsx("path", { class: "lm-outline", d: outline, filter: "url(#lm-ink)" }), squares.filter((square) => ["door", "open-door", "secret-door"].includes(kindAt(map, square))).map((square) => (_jsx(Door, { kind: kindAt(map, square), name: featureAt(square)?.name ?? "door", square: square, map: map, x: X(square.column), y: Y(square.row) }, squareName(square)))), map.exits.map((exit, index) => {
84
+ return (_jsxs("section", { class: bare ? "lm bare" : "lm", ...(bare ? { "aria-label": `${t("Map")}: ${place}` } : { "aria-labelledby": "lm-title" }), children: [!bare && _jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "lm-title", children: t("Map") }), note: place }), _jsx("div", { ref: frame, class: picking === undefined && choosing === undefined ? "lm-frame" : "lm-frame panned", style: { "--map-width": String(width) }, children: _jsxs("svg", { ref: svg, class: `lm-svg lm-look-${map.ground}`, viewBox: `0 0 ${width} ${height}`, ...(picking === undefined && choosing === undefined ? {} : { width: width * 1.2 }), role: "img", "aria-label": t("Map of {place}", { place }), children: [_jsxs("defs", { children: [_jsx(Patterns, {}), _jsx(GlassDefs, { prefix: "lm" }), _jsxs("radialGradient", { id: "lm-hostile-glow", children: [_jsx("stop", { offset: "0.75", "stop-color": "#c8321f", "stop-opacity": "0.3" }), _jsx("stop", { offset: "1", "stop-color": "#c8321f", "stop-opacity": "0" })] }), _jsx("clipPath", { id: "lm-open", children: _jsx("path", { d: floor, "clip-rule": "evenodd" }) }), !walled && (_jsx("mask", { id: "lm-fade", maskUnits: "userSpaceOnUse", x: 0, y: 0, width: width, height: height, children: _jsx("rect", { x: X(0) + size * 0.35, y: Y(0) + size * 0.35, width: map.columns * size - size * 0.7, height: map.rows * size - size * 0.7, fill: "#fff", filter: "url(#lm-soft)" }) })), standing.map((one, index) => (_jsx("clipPath", { id: `lm-token-${index}`, children: _jsx("circle", { cx: middle(one)[0], cy: middle(one)[1], r: size * (one.side ?? 1) * 0.43 }) }, index)))] }), _jsx("rect", { class: "lm-paper", width: width, height: height }), _jsx("g", { class: "lm-walls", children: squares.filter((square) => ["wall", "rock", "window"].includes(kindAt(map, square)) && nearRoom(square)).map((square) => (_jsxs(Fragment, { children: [_jsx("rect", { class: "lm-wall-under", x: X(square.column), y: Y(square.row), width: size, height: size }), _jsx("rect", { class: `lm-wall ${kindAt(map, square)}`, x: X(square.column), y: Y(square.row), width: size, height: size })] }, squareName(square)))) }), walled ? drawn : _jsx("g", { mask: "url(#lm-fade)", children: drawn }), reach.length > 0 && (_jsx("g", { class: "lm-out", "aria-hidden": "true", "clip-path": "url(#lm-open)", children: open.filter((square) => !reach.some((near) => near.column === square.column && near.row === square.row)).map((square) => (_jsx("rect", { x: X(square.column), y: Y(square.row), width: size, height: size }, squareName(square)))) })), _jsx("path", { class: "lm-outline", d: outline, filter: "url(#lm-ink)" }), squares.filter((square) => ["door", "open-door", "secret-door"].includes(kindAt(map, square))).map((square) => (_jsx(Door, { kind: kindAt(map, square), name: featureAt(square)?.name ?? "door", square: square, map: map, x: X(square.column), y: Y(square.row) }, squareName(square)))), map.exits.map((exit, index) => {
85
85
  const square = squareOf(exit.square);
86
86
  return square === undefined ? null : _jsx(Exit, { side: sides[index], to: exit.to, x: X(square.column) + size / 2, y: Y(square.row) + size / 2, letters: Math.max(13, 12 / scale) }, exit.square);
87
87
  }), _jsxs("g", { class: "lm-coordinates", "font-size": letters, children: [Array.from({ length: map.columns }, (_, column) => _jsx("text", { x: X(column) + size / 2, y: top - 10, "text-anchor": "middle", children: columnName(column) }, `c${column}`)), Array.from({ length: map.rows }, (_, row) => _jsx("text", { x: left - 10, y: Y(row) + size / 2, "text-anchor": "end", "dominant-baseline": "middle", children: row + 1 }, `r${row}`))] }), _jsx("g", { class: "lm-tokens", children: standing.map((one, index) => {
@@ -1,6 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
- // The Scene section (D-309, VIEW-6, D-444): where the party is, its picture with the places around it, its name, what holds there and its text; the open
3
- // scene and who is in it; outside a scene who is there of those the character knows; the map. While the scene goes by turns, the turns first.
4
2
  import { useContext, useEffect, useRef, useState } from "preact/hooks";
5
3
  import { TalkName } from "../acts/names.js";
6
4
  import { sectionAddress } from "../address.js";
@@ -10,6 +8,7 @@ import { cardIcons, Icon } from "../parts/icons.js";
10
8
  import { phraseLabel, sceneTypeLabel, strangerLabel } from "../parts/labels.js";
11
9
  import { biomeLabel, biomes } from "../parts/map-symbols.js";
12
10
  import { InlineText, knowersOf, Markdown } from "../parts/markdown.js";
11
+ import { PictureButton, PictureSpot } from "../parts/picture.js";
13
12
  import { downTint, personState, StatusPip } from "../parts/status.js";
14
13
  import { PlaceMap } from "../place/view.js";
15
14
  import { sideOf, Token } from "../sheet/party.js";
@@ -108,8 +107,8 @@ function PlaceBand({ place, fold }) {
108
107
  const link = placeLinks(place);
109
108
  const caption = (_jsxs("div", { class: "place-caption", children: [place.within.length > 0 && (_jsx("ol", { class: "place-path", "aria-label": t("Within"), children: place.within.map((name) => _jsx("li", { children: name }, name)) })), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name, link: link }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), fold && text !== "" && _jsx(DescriptionToggle, { open: fold.open, controls: "place-band-text", onToggle: fold.onToggle })] }));
110
109
  return place.image === undefined
111
- ? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers })] }))
112
- : (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }) }))] }));
110
+ ? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx(PictureSpot, { page: place.name, has: false, class: "place-disc-spot", children: _jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers })] }))
111
+ : (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot picture-host", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption, _jsx(PictureButton, { page: place.name, has: true, icon: true })] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }) }))] }));
113
112
  }
114
113
  /**
115
114
  * One thing that holds there: an entry of the environment as its name and value, as light dim, the biome and the terrain the engine reads in the page's language;
@@ -157,7 +156,7 @@ function People({ people }) {
157
156
  };
158
157
  return (_jsx("ul", { class: "present", children: people.map((person, index) => (_jsxs("li", { class: person.role === "other" && index > 0 && people[index - 1].role !== "other" ? "after-party" : undefined, children: [person.stranger && person.image === undefined
159
158
  ? (_jsxs("span", { class: ["token stranger", letterOf(person.name) === undefined ? "" : "numbered", person.hostile === true ? "hostile" : ""].filter((name) => name !== "").join(" "), "aria-hidden": "true", children: [letterOf(person.name) ?? _jsx(Icon, { name: "stranger" }), _jsx(StatusPip, { status: { ...person, party: false } })] }))
160
- : (_jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status: statusOf(person), dying: downTint(statusOf(person)), number: person.stranger ? letterOf(person.name) : undefined })), person.role === "pc"
159
+ : (_jsx(PersonPicture, { person: person, children: _jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status: statusOf(person), dying: downTint(statusOf(person)), number: person.stranger ? letterOf(person.name) : undefined }) })), person.role === "pc"
161
160
  ? _jsx(PersonName, { person: person })
162
161
  : (_jsx(TalkName, { name: person.stranger ? strangerLabel(person.name) : person.name, children: _jsx(PersonName, { person: person }) }))] }, `${person.name} ${index}`))) }));
163
162
  }
@@ -169,3 +168,7 @@ function PersonName({ person }) {
169
168
  function letterOf(name) {
170
169
  return /^creature ([A-Z])$/.exec(name)?.[1];
171
170
  }
171
+ /** Someone's token with the control for a picture of the player's own, but a stranger's: what stands for them is no page the player sees. */
172
+ function PersonPicture({ person, children }) {
173
+ return person.stranger === true ? _jsx(_Fragment, { children: children }) : _jsx(PictureSpot, { page: person.name, has: person.image !== undefined, children: children });
174
+ }
@@ -9,7 +9,7 @@ import { DieSwatch, Icon } from "../parts/icons.js";
9
9
  import { customLabel, itemLabel, leveledItemLabel, phraseLabel, rateParts, settingLabel, valueLabel } from "../parts/labels.js";
10
10
  import { PageHead } from "../shell/pages.js";
11
11
  import { byHandPref, conditionsPref, readChoice, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange, writeChoice } from "../shell/prefs.js";
12
- import { applyGameStyle, gameStyle, systemStylePref } from "../shell/system-style.js";
12
+ import { applyGameStyle, gameStyle, installedStyle, systemStylePref } from "../shell/system-style.js";
13
13
  import { pickTheme, shownTheme } from "../shell/theme.js";
14
14
  import { arrowStep, t } from "../text.js";
15
15
  import { LanguageChoice, languageLine } from "./language-choice.js";
@@ -23,7 +23,7 @@ const groups = [
23
23
  { names: ["dice", "master-rolls", "units"], system: true },
24
24
  { names: ["lines", "veils"] },
25
25
  { names: ["orders"] },
26
- { names: ["pictures", "language"] },
26
+ { names: ["pictures", "pictures-by", "language"] },
27
27
  ];
28
28
  /** The Settings section; with `several` player characters, what a value means says so where it speaks of one character (D-480 (2)). */
29
29
  export function SettingsView({ version, several = false }) {
@@ -159,8 +159,14 @@ function writtenLabel(setting, value) {
159
159
  const rate = setting === "between-sessions" ? rateParts(value) : undefined;
160
160
  return rate === undefined ? valueLabel(value) : t("{game} every {real}", rate);
161
161
  }
162
- /** What a value the page does not offer means: a rate of the time between sessions as the others say it, or that it reads as none (D-133); undefined for another setting's. */
162
+ /**
163
+ * What a value the page does not offer means: a rate of the time between sessions as the others say it, or that it reads as none (D-133); an image tool of
164
+ * the master's that makes the pictures (D-572); undefined for another setting's.
165
+ */
163
166
  function writtenMeans(setting, value) {
167
+ if (setting === "pictures-by") {
168
+ return t("the master makes them with {tool}", { tool: value });
169
+ }
164
170
  if (setting !== "between-sessions") {
165
171
  return undefined;
166
172
  }
@@ -299,9 +305,9 @@ function TextSetting({ setting, label, onChange }) {
299
305
  field.current?.focus();
300
306
  }, children: t("Clear") }))] })] }));
301
307
  }
302
- /** What the player should know of a setting on this computer, as how to have pictures: its lines, its steps in order, and the commands to copy. */
308
+ /** What the player should know of a setting on this computer, as how to have pictures: its lines, its steps in order, the commands to copy, and a line after. */
303
309
  function SettingNote({ note }) {
304
- const blocks = noteBlocks(t(note.text));
310
+ const blocks = [...noteBlocks(t(note.text, note.values)), ...(note.also ?? []).map((line) => t(line, note.values))];
305
311
  return (_jsxs("div", { class: note.fix ? "setting-note fix" : "setting-note", children: [_jsx(Icon, { name: "info" }), _jsx("div", { class: "setting-note-text", children: blocks.map((block, index) => typeof block === "string" ? _jsx("p", { children: withCommands(block) }, index) : (_jsx("ol", { children: block.map((step) => _jsx("li", { children: withCommands(step) }, step)) }, index))) })] }));
306
312
  }
307
313
  /** A note's lines, those numbered as steps together. */
@@ -342,30 +348,40 @@ export function Command({ text }) {
342
348
  return (_jsxs("span", { class: "setting-command", children: [_jsx("code", { children: text.split(" ").flatMap((word, index) => [index === 0 ? "" : " ", _jsx("span", { class: "command-word", children: word }, index)]) }), _jsx("button", { type: "button", class: "setting-copy", "aria-label": t("Copy {command}", { command: text }), onClick: () => void copy(), children: copied ? t("Copied") : t("Copy") })] }));
343
349
  }
344
350
  /**
345
- * Under the theme, the game's style, when the campaign's system has one, a theme or a page style (D-528): its own or the page's, kept in this browser for that
346
- * system; the page's alone when its theme does not pass the check of legibility.
351
+ * 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
+ * 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.
347
354
  */
348
355
  function gameStyleRows() {
349
356
  const style = gameStyle();
350
- if (style.system === undefined || (!style.shows && !style.refused)) {
357
+ const installed = style.themes.length > 0;
358
+ if (style.system === undefined || (!style.shows && !style.refused && !installed)) {
351
359
  return [];
352
360
  }
353
361
  const choice = systemStylePref(style.system);
354
- const name = t("Game style");
355
- if (!style.shows) {
356
- const means = t("This game's style does not pass the page's check of legibility: the page keeps its own.");
357
- return [{ key: "game-style", name, about: t("the colours, faces and pictures of the game system"), options: [{ value: "page", label: t("The page's"), means }], value: "page", pick: () => undefined }];
358
- }
362
+ const refusedMeans = style.refused && !style.shows ? { means: t("This game's style does not pass the page's check of legibility: the page keeps its own.") } : {};
363
+ const about = !installed
364
+ ? style.name === undefined ? t("the colours, faces and pictures of the game system") : t("the colours, faces and pictures of {name}, from the game system", { name: style.name })
365
+ : style.shows
366
+ ? t("the colours, faces and pictures: the game system's, a theme you installed, or the page's own")
367
+ : t("the colours, faces and pictures: a theme you installed, or the page's own");
368
+ const options = [
369
+ ...(style.shows ? [{ value: "game", label: t("The game's") }] : []),
370
+ ...style.themes.map((one) => ({ value: installedStyle(one.id), label: one.name })),
371
+ { value: "page", label: t("The page's"), ...refusedMeans },
372
+ ];
359
373
  return [{
360
374
  key: "game-style",
361
- name,
362
- about: style.name === undefined ? t("the colours, faces and pictures of the game system") : t("the colours, faces and pictures of {name}, from the game system", { name: style.name }),
363
- options: [{ value: "game", label: t("The game's") }, { value: "page", label: t("The page's") }],
375
+ name: t("Game style"),
376
+ about,
377
+ options,
364
378
  value: readChoice(choice),
365
379
  pick: (value) => {
366
380
  writeChoice(choice, value);
367
381
  applyGameStyle();
368
382
  },
383
+ // The names of the installed themes go under the row's, with room for them.
384
+ ...(installed ? { under: true } : {}),
369
385
  }];
370
386
  }
371
387
  /** A name as a part of an element's id, without spaces: "dice sound" is dice-sound. */
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
5
5
  import { useEffect, useRef, useState } from "preact/hooks";
6
6
  import { changeSetting, readSetup, sendSetupWord } from "../api.js";
7
7
  import { Icon } from "../parts/icons.js";
8
- import { phraseLabel, settingLabel, valueLabel } from "../parts/labels.js";
8
+ import { phraseLabel, settingLabel, systemNameLabel, valueLabel } from "../parts/labels.js";
9
9
  import { Master } from "../shell/master.js";
10
10
  import { arrowStep, t } from "../text.js";
11
11
  // The steps of a campaign before play (MOD-1).
@@ -71,7 +71,7 @@ function Question({ question, count, left, focus, onBack, onNext, onLeave, onTou
71
71
  const resting = useRef(undefined);
72
72
  const heading = useRef(null);
73
73
  const value = picked ?? question.value;
74
- const title = question.question === undefined ? settingLabel(question.name) : t(question.question);
74
+ const title = question.question === undefined ? settingLabel(question.name) : t(question.question, question.game === undefined ? {} : { game: systemNameLabel(question.game) });
75
75
  const id = `setup-${question.name.replace(/[^a-z0-9]+/gi, "-")}`;
76
76
  const isList = lists.has(question.name);
77
77
  const open = value === undefined && question.items === undefined && !left;
@@ -122,7 +122,9 @@ function Choices({ question, value, labelledBy, onPick }) {
122
122
  onPick(choices[next].value, true);
123
123
  buttons[next]?.focus();
124
124
  };
125
- return (_jsx("div", { class: "setup-choices", role: "radiogroup", "aria-labelledby": labelledBy, onKeyDown: move, children: choices.map((choice, index) => (_jsxs("button", { type: "button", role: "radio", "aria-checked": value === choice.value, tabIndex: index === stop ? 0 : -1, class: "setup-choice", onClick: () => onPick(choice.value, false), children: [_jsxs("strong", { children: [choice.label === undefined ? valueLabel(choice.value) : phraseLabel(t(choice.label)), choice.value === question.suggested && _jsx("span", { class: "setup-suggested", children: choice.value === question.last ? t("Like last time") : t("Suggested") })] }), choice.means !== undefined && _jsx("span", { children: phraseLabel(t(choice.means)) })] }, choice.value))) }));
125
+ return (_jsx("div", { class: "setup-choices", role: "radiogroup", "aria-labelledby": labelledBy, onKeyDown: move, children: choices.map((choice, index) => (_jsxs("button", { type: "button", role: "radio", "aria-checked": value === choice.value, tabIndex: index === stop ? 0 : -1, class: "setup-choice", onClick: () => onPick(choice.value, false), children: [_jsxs("strong", { children: [choice.label === undefined ? valueLabel(choice.value) : phraseLabel(t(choice.label)), choice.value === question.last
126
+ ? _jsx("span", { class: "setup-last", children: t("Like last time") })
127
+ : choice.value === question.suggested && _jsx("span", { class: "setup-suggested", children: t("Suggested") })] }), choice.means !== undefined && _jsx("span", { children: phraseLabel(t(choice.means)) })] }, choice.value))) }));
126
128
  }
127
129
  /** A list of the setup, lines or veils: its items to take off, a field to add one, and None for a player who wants none. */
128
130
  function ListQuestion({ question, onTouch, onProblem }) {
@@ -38,9 +38,12 @@ export function PartyStrip({ party, chosen, scene, waiting = new Map() }) {
38
38
  : counter && _jsx(Bar, { value: counter, label: fieldLabel(counter.field) }), _jsx(Effects, { effects: besideWord(member.effects, status.person), most: 2 })] }, member.name));
39
39
  }) }));
40
40
  }
41
- /** A party member's token with the pip of their state (D-419), in the strip and the sheet's band; never in the rolls. Their class in its tooltip (D-409). */
41
+ /**
42
+ * A party member's token with the pip of their state (D-419), in the strip and the sheet's band; never in the rolls. Their class in its tooltip in the strip
43
+ * (D-409); none on the sheet's band, large, which writes name and class beside it and has the picture's control on its rim.
44
+ */
42
45
  export function MemberToken({ member, large, status, choices }) {
43
- return (_jsxs("span", { class: "token-holder", "data-tip": member.headline === undefined ? undefined : `${member.name} · ${member.headline}`, children: [_jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: downTint(status) }), choices === true && (_jsx("span", { class: "choices-pip", "aria-hidden": "true", children: _jsx(Icon, { name: "up" }) }))] }));
46
+ return (_jsxs("span", { class: "token-holder", "data-tip": member.headline === undefined || large === true ? undefined : `${member.name} · ${member.headline}`, children: [_jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: downTint(status) }), choices === true && (_jsx("span", { class: "choices-pip", "aria-hidden": "true", children: _jsx(Icon, { name: "up" }) }))] }));
44
47
  }
45
48
  /** The side of one of the party by their role; anyone else has none. */
46
49
  export function sideOf(role) {
@@ -12,6 +12,7 @@ import { fieldLabel, groupLabels, itemLabel, phraseLabel, readableIds, rollLabel
12
12
  import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "../parts/layout.js";
13
13
  import { knowersOf, Markdown, plainLine } from "../parts/markdown.js";
14
14
  import { MoodFace, moodLabel } from "../parts/mood.js";
15
+ import { PictureSpot } from "../parts/picture.js";
15
16
  import { besideWord, memberStatus } from "../parts/status.js";
16
17
  import { Effects, ProgressBar, ValueDrawing } from "../parts/widgets.js";
17
18
  import { ChoicesNotice } from "../play/choices.js";
@@ -37,7 +38,7 @@ export function MemberSheet({ member, headline, layered, sheet, cards, text, kno
37
38
  const shownApart = personFields([...person, ...boxes]);
38
39
  // The player character's story has its own card: the rest of the page's text is its description (D-386).
39
40
  const described = story !== undefined && story.trim() !== "" && text.startsWith(story) ? text.slice(story.length).trimStart() : text;
40
- return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(MemberToken, { member: member, large: true, status: status }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
41
+ return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(PictureSpot, { page: member.name, has: member.image !== undefined, children: _jsx(MemberToken, { member: member, large: true, status: status }) }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
41
42
  ? (_jsxs("p", { class: "headline", children: [headline, headline !== undefined && headline !== "" && member.mood !== undefined && " · ", member.mood !== undefined && (_jsxs("span", { class: "mood-word", children: [_jsx(MoodFace, { mood: member.mood }), moodLabel(member.mood)] }))] }))
42
43
  : null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] })), layered === true && _jsx(ChangedLine, {})] })] }), choices.map((set) => _jsx(ChoicesNotice, { set: set }, set.id)), person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id)), _jsx(ValueLine, { values: member.counters.filter((value) => !shownApart.has(value.field)), fields: fields, boxes: boxes }), _jsx(Effects, { effects: besideWord(member.effects, status.person) })] }), _jsxs("div", { class: "sheet-body", children: [rail.length > 0 && _jsx("div", { class: "rail", children: rail.map(group) }), _jsxs("div", { class: "sheet-main", children: [_jsx(FixedColumns, { cards: others.map((shown) => ({ key: shown.name, node: group(shown) })) }), _jsxs("div", { class: "wide-cards", children: [story !== undefined && (_jsxs(Card, { name: backstoryCard, title: t("Backstory"), icon: cardIcons.backstory, layout: "lore", preview: plainLine(story) ?? t("Not written yet"), children: [story.trim() !== "" && _jsx(Markdown, { text: story }), _jsx(StoryBox, { story: story, who: member.name })] })), described.trim() !== "" && (_jsx(Card, { name: descriptionCard, title: t("Description"), icon: cardIcons.description, layout: "lore", preview: plainLine(described), children: _jsx(Markdown, { text: described, secretKnowers: knowersOf(knownBy) }) }))] }), _jsx(WidgetCards, { place: "page", page: "sheet", who: member.name, view: member })] })] })] }));
43
44
  }
@@ -231,21 +232,24 @@ function ItemsTable({ group, fields }) {
231
232
  }
232
233
  const name = itemName(item.item);
233
234
  const bonds = (item.bonds ?? []).map((list) => fieldLabel(list, fields));
234
- const said = [
235
+ const parts = [
235
236
  item.inside === undefined ? undefined : t("in {container}", { container: itemName(item.inside) }),
236
237
  item.equipped === true ? t("Equipped") : undefined,
237
238
  ...bonds,
238
- ].filter((part) => part !== undefined).map((part) => `, ${part}`).join("");
239
+ ].filter((part) => part !== undefined);
240
+ const said = parts.map((part) => `, ${part}`).join("");
241
+ // What the thing's card says under its name: how many, where it is, whether equipped.
242
+ const facts = [...(count(item) === "" ? [] : [`×${count(item)}`]), ...parts];
239
243
  const words = (_jsxs(_Fragment, { children: [marked && _jsx(ItemPicture, { image: item.image, equipped: item.equipped === true }), _jsx("span", { children: name }), count(item) !== "" && _jsx("span", { class: "item-count", children: ` (${count(item)})` }), bonds.length > 0 && (_jsx("span", { class: "item-bond", "data-tip": bonds.join(", "), "aria-hidden": "true", children: _jsx(Icon, { name: "bond" }) })), said !== "" && _jsx("span", { class: "visually-hidden", children: said })] }));
240
244
  // The campaign changed its page of the game system (D-564): an asterisk after its name, outside what acts.
241
245
  const changed = item.layered === true && _jsx(ChangedMark, {});
242
- // The name acts, when the system names a verb for it; a container's opens and closes what it holds (D-495).
246
+ // The name opens the thing's card, with its verbs when the system names some; a container's opens and closes what it holds (D-495).
243
247
  const verbs = holds(index) ? undefined : itemVerbs(acts?.actions, item);
244
248
  return (_jsxs("tr", { class: item.depth === undefined ? undefined : "inside", children: [_jsxs("th", { scope: "row", class: holds(index) ? "holds" : undefined, style: item.depth === undefined ? undefined : { "--depth": item.depth }, children: [holds(index)
245
249
  ? (_jsxs("button", { type: "button", class: "fold", "aria-expanded": !closed.has(key(index)), onClick: () => toggle(index), children: [_jsx(Icon, { name: "fold" }), words] }))
246
- : verbs === undefined
250
+ : acts === undefined
247
251
  ? words
248
- : _jsx(ActName, { verbs: verbs, item: name, said: `${count(item) === "" ? "" : ` (${count(item)})`}${said}`, children: words }), changed] }), !carried && item.values.map((value) => _jsx("td", { class: widgetOf(value) === "text" ? undefined : "num", children: shownText(value.text, value.kind) }, value.field))] }, key(index)));
252
+ : (_jsx(ActName, { verbs: verbs ?? [], item: name, page: item.item, facts: facts, ...(item.document === true ? { document: true } : {}), said: `${count(item) === "" ? "" : ` (${count(item)})`}${said}`, children: words })), changed] }), !carried && item.values.map((value) => _jsx("td", { class: widgetOf(value) === "text" ? undefined : "num", children: shownText(value.text, value.kind) }, value.field))] }, key(index)));
249
253
  }) })] }));
250
254
  }
251
255
  /** A thing's picture, one colour as the words beside it, gold when equipped: the game's drawing of its kind as a mask, or the page's own of any thing. */
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { Icon } from "../parts/icons.js";
3
3
  import { languageName } from "../settings/languages.js";
4
4
  import { pageLocale, pageTranslation, t } from "../text.js";
5
5
  export function Notices({ notices }) {
6
6
  return notices.length === 0 ? null : (_jsx("div", { class: "notices", children: notices.map((notice) => {
7
7
  // The role on the words alone, always the same node: a count beside them is read where it is, never heard at each step.
8
- return (_jsxs("p", { class: `notice ${notice.kind}`, children: [_jsx(Icon, { name: notice.kind === "info" ? "info" : "alert" }), _jsx("span", { role: notice.kind === "problem" ? "alert" : "status", children: notice.text }), notice.count !== undefined && (_jsxs(_Fragment, { children: [_jsx("span", { class: "count", dir: "ltr", children: `${notice.count.done}/${notice.count.of}` }), _jsx("span", { class: "bar", "aria-hidden": "true", style: { "--done": `${Math.round((100 * notice.count.done) / Math.max(notice.count.of, 1))}%` } })] }))] }, notice.key ?? notice.text));
8
+ return (_jsxs("p", { class: `notice ${notice.kind}`, children: [_jsx(Icon, { name: notice.kind === "info" ? "info" : "alert" }), _jsxs("span", { class: "notice-words", children: [_jsx("span", { role: notice.kind === "problem" ? "alert" : "status", children: notice.text }), notice.link !== undefined && _jsx("a", { class: "notice-link", href: notice.link.href, children: notice.link.text })] }), notice.count !== undefined && (_jsxs(_Fragment, { children: [_jsx("span", { class: "count", dir: "ltr", children: `${notice.count.done}/${notice.count.of}` }), _jsx("span", { class: "bar", "aria-hidden": "true", style: { "--done": `${Math.round((100 * notice.count.done) / Math.max(notice.count.of, 1))}%` } })] })), notice.hide !== undefined && (_jsx("button", { type: "button", class: "icon-button notice-hide tip-left", "aria-label": notice.hide.label, "data-tip": notice.hide.label, onClick: notice.hide.onHide, children: _jsx(Icon, { name: "close" }) }))] }, notice.key ?? notice.text));
9
9
  }) }));
10
10
  }
11
11
  /** What the page says of an import under way (D-491 (11)): what it is doing, and how far; nothing without one. */
@@ -1,19 +1,36 @@
1
1
  import { readChoice } from "./prefs.js";
2
2
  /** The event that tells the page the game's style changed: what draws an icon draws it again. */
3
3
  export const gameStyleChanged = "rpg-engine:game-style";
4
- /** Whether the page shows the game's style, by system: the game's, or the page's own. */
4
+ /** The value of the choice that shows an installed theme, by its id. */
5
+ export function installedStyle(id) {
6
+ return `theme:${id}`;
7
+ }
8
+ /**
9
+ * Which style the page shows, by system: the game's, while it has one to show; an installed theme, while it is installed; or the page's own. One no longer
10
+ * offered goes back to the first: the game's, else the page's.
11
+ */
5
12
  export function systemStylePref(system) {
6
- return { key: `rpg-engine.game-style.${system}`, initial: "game", values: ["game", "page"] };
13
+ const shows = gameShows();
14
+ return {
15
+ key: `rpg-engine.game-style.${system}`,
16
+ initial: shows ? "game" : "page",
17
+ values: [...(shows ? ["game"] : []), ...(theme.themes ?? []).map((one) => installedStyle(one.id)), "page"],
18
+ };
7
19
  }
8
- /** 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. */
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. */
9
21
  export function gameStyle() {
10
- return { system: theme.system, name: theme.name, shows: theme.css !== undefined || freeStyle !== undefined, refused: theme.refused === true };
22
+ return { system: theme.system, name: theme.name, shows: gameShows(), refused: theme.refused === true, themes: (theme.themes ?? []).map(({ id, name }) => ({ id, name })) };
23
+ }
24
+ /** 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
+ export function shownInstalledTheme() {
26
+ return chosen().installed?.id;
11
27
  }
12
- /** The lines of an icon the game's style draws anew, while it is on; undefined for the page's own. */
28
+ /** The lines of an icon the style shown draws anew; undefined for the page's own. */
13
29
  export function themedIcon(name) {
14
- return styleOn() ? theme.icons?.[name] : undefined;
30
+ const style = chosen();
31
+ return style.installed !== undefined ? style.installed.icons[name] : style.game ? theme.icons?.[name] : undefined;
15
32
  }
16
- /** Takes the theme of the campaign's system as read, and the free style sheet of its page module; the page shows them while the game's style is on. */
33
+ /** Takes the theme of the campaign's system as read, with the themes installed, and the free style sheet of its page module; the page shows the one chosen. */
17
34
  export function takeSystemStyle(read, pageStyle) {
18
35
  const same = JSON.stringify(read) === JSON.stringify(theme) && pageStyle === freeStyle;
19
36
  theme = read;
@@ -22,16 +39,17 @@ export function takeSystemStyle(read, pageStyle) {
22
39
  applyGameStyle();
23
40
  }
24
41
  }
25
- /** Shows the game's style or the page's own, as the player keeps it for the campaign's system: after a change of that choice, or of what the system gives. */
42
+ /** Shows the style the player keeps for the campaign's system: after a change of that choice, or of what the system and this computer give. */
26
43
  export function applyGameStyle() {
27
44
  if (typeof document === "undefined") {
28
45
  return;
29
46
  }
30
- const on = styleOn();
47
+ const style = chosen();
31
48
  themeSheet ??= new CSSStyleSheet();
32
49
  freeSheet ??= new CSSStyleSheet();
33
- themeSheet.replaceSync(on ? theme.css ?? "" : "");
34
- freeSheet.replaceSync(on ? freeStyle ?? "" : "");
50
+ themeSheet.replaceSync(style.installed?.css ?? (style.game ? theme.css ?? "" : ""));
51
+ // The free style of the system's page module goes with its own theme alone: never under another's colours.
52
+ freeSheet.replaceSync(style.game ? freeStyle ?? "" : "");
35
53
  const others = document.adoptedStyleSheets.filter((sheet) => sheet !== themeSheet && sheet !== freeSheet);
36
54
  document.adoptedStyleSheets = [...others, themeSheet, freeSheet];
37
55
  document.querySelectorAll(".title-too-wide").forEach((title) => title.classList.remove("title-too-wide"));
@@ -47,8 +65,23 @@ let watching = false;
47
65
  let fitting = false;
48
66
  // The card titles the theme's face may make too wide, and the campaign's name.
49
67
  const titles = ":is(summary, .card-head) :is(h2, h3, .rolls-title), .titles h1";
68
+ /** Whether the game's own style has anything to show: its theme, or the free style of its page module. */
69
+ function gameShows() {
70
+ return theme.css !== undefined || freeStyle !== undefined;
71
+ }
72
+ /** The style the player keeps for the campaign's system: the game's, an installed theme, or neither, the page's own. */
73
+ function chosen() {
74
+ if (theme.system === undefined) {
75
+ return { game: false };
76
+ }
77
+ const value = readChoice(systemStylePref(theme.system));
78
+ const installed = theme.themes?.find((one) => installedStyle(one.id) === value);
79
+ return installed === undefined ? { game: value === "game" } : { game: false, installed };
80
+ }
81
+ /** Whether a style other than the page's own is on, whose faces may make a title too wide. */
50
82
  function styleOn() {
51
- return theme.system !== undefined && gameStyle().shows && readChoice(systemStylePref(theme.system)) === "game";
83
+ const style = chosen();
84
+ return style.game || style.installed !== undefined;
52
85
  }
53
86
  /**
54
87
  * Each title the theme's face makes wider than its card goes back to the text's face, that title alone (D-528 (4)): measured as the page changes, as its
@@ -0,0 +1,223 @@
1
+ // The page's one tooltip (T-228): what a control's `data-tip` says, shown in the top layer over every card, list and dialog, so that no box that scrolls or
2
+ // clips cuts it, and placed beside its control inside the window. After a moment under a pointer, at once when the keyboard reaches it, never at a touch;
3
+ // Escape or a press hides it. It is for the eye: what it says is already the control's name for a screen reader. It reaches into the packages' shadow roots.
4
+ // How far from its control, and from the window's edges.
5
+ const gap = 8;
6
+ const margin = 8;
7
+ // Moving from one tip to the next within this time shows the next at once.
8
+ const followTime = 300;
9
+ let tip;
10
+ // Whose tip shows, or waits for its moment, and how it was reached.
11
+ let target;
12
+ let reachedBy;
13
+ let timer;
14
+ // A control pressed or dismissed with Escape shows no tip until the pointer leaves it.
15
+ let quiet;
16
+ let hiddenAt = 0;
17
+ const watcher = typeof MutationObserver === "undefined" ? undefined : new MutationObserver(() => follow());
18
+ /** Starts the page's tooltips, once, at the page's start. */
19
+ export function startTooltips() {
20
+ document.addEventListener("pointerover", onPointerOver, true);
21
+ document.addEventListener("pointerout", onPointerOut, true);
22
+ document.addEventListener("pointerdown", onPress, true);
23
+ document.addEventListener("focusin", onFocusIn, true);
24
+ document.addEventListener("focusout", onFocusOut, true);
25
+ document.addEventListener("keydown", onKey, true);
26
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
27
+ window.addEventListener("resize", onScroll, { passive: true });
28
+ }
29
+ function onPointerOver(event) {
30
+ if (event.pointerType === "touch") {
31
+ return;
32
+ }
33
+ const found = tipped(event.composedPath());
34
+ if (found !== quiet) {
35
+ quiet = undefined;
36
+ }
37
+ if (found === undefined || found === quiet) {
38
+ if (reachedBy !== "focus") {
39
+ hide();
40
+ }
41
+ return;
42
+ }
43
+ if (found !== target || reachedBy !== "pointer") {
44
+ const shownNow = tip?.classList.contains("shown") === true || performance.now() - hiddenAt < followTime;
45
+ wait(found, shownNow ? 0 : waitTime());
46
+ }
47
+ }
48
+ // The pointer leaving the window.
49
+ function onPointerOut(event) {
50
+ if (event.relatedTarget === null && reachedBy === "pointer") {
51
+ hide();
52
+ }
53
+ }
54
+ function onPress(event) {
55
+ const found = tipped(event.composedPath());
56
+ if (found !== undefined) {
57
+ quiet = found;
58
+ }
59
+ hide();
60
+ }
61
+ function onFocusIn(event) {
62
+ const focused = event.composedPath()[0];
63
+ if (focused instanceof Element && hasTip(focused) && focused !== quiet && focused.matches(":focus-visible")) {
64
+ show(focused, "focus");
65
+ }
66
+ else if (reachedBy === "focus") {
67
+ hide();
68
+ }
69
+ }
70
+ function onFocusOut(event) {
71
+ // Dismissed with Escape, it shows again when the keyboard comes back to it.
72
+ if (quiet === event.composedPath()[0]) {
73
+ quiet = undefined;
74
+ }
75
+ if (reachedBy === "focus") {
76
+ hide();
77
+ }
78
+ }
79
+ // Escape hides the tip shown (WCAG 1.4.13), and lets the key go on to what else it closes.
80
+ function onKey(event) {
81
+ if (event.key === "Escape" && target !== undefined) {
82
+ quiet = target;
83
+ hide();
84
+ }
85
+ }
86
+ // The tip follows its control as the page or a list scrolls, and goes with it out of sight; the pointer, left behind, shows the next as it goes over it.
87
+ function onScroll() {
88
+ place();
89
+ }
90
+ /** The nearest control with a tip along an event's path, across shadow roots. */
91
+ function tipped(path) {
92
+ return path.find((step) => step instanceof Element && hasTip(step));
93
+ }
94
+ function hasTip(element) {
95
+ return (element.getAttribute("data-tip") ?? "") !== "";
96
+ }
97
+ function wait(element, time) {
98
+ clearTimeout(timer);
99
+ if (time === 0) {
100
+ show(element, "pointer");
101
+ return;
102
+ }
103
+ hide();
104
+ target = element;
105
+ reachedBy = "pointer";
106
+ timer = setTimeout(() => show(element, "pointer"), time);
107
+ }
108
+ function show(element, how) {
109
+ clearTimeout(timer);
110
+ const shown = tipElement();
111
+ target = element;
112
+ reachedBy = how;
113
+ shown.textContent = element.getAttribute("data-tip");
114
+ shown.dir = getComputedStyle(element).direction === "rtl" ? "rtl" : "ltr";
115
+ watcher?.disconnect();
116
+ watcher?.observe(element, { attributes: true, attributeFilter: ["data-tip"] });
117
+ // Shown again, so that it stands over a dialog opened since; its side and state set before, as showing it reads its style, which it comes from.
118
+ if (shown.classList.contains("shown")) {
119
+ closeLayer(shown);
120
+ }
121
+ shown.dataset.side = askedSide(element);
122
+ shown.classList.add("shown");
123
+ openLayer(shown);
124
+ place();
125
+ }
126
+ function hide() {
127
+ clearTimeout(timer);
128
+ watcher?.disconnect();
129
+ target = undefined;
130
+ reachedBy = undefined;
131
+ if (tip?.classList.contains("shown") === true) {
132
+ tip.classList.remove("shown");
133
+ closeLayer(tip);
134
+ hiddenAt = performance.now();
135
+ }
136
+ }
137
+ // Its control's words changed while it shows, as a picture's while it is sent; or went.
138
+ function follow() {
139
+ if (target === undefined || tip === undefined) {
140
+ return;
141
+ }
142
+ if (!hasTip(target)) {
143
+ hide();
144
+ return;
145
+ }
146
+ tip.textContent = target.getAttribute("data-tip");
147
+ place();
148
+ }
149
+ /** Over its control, or under it (`.tip-below`), or on its start side (`.tip-left`), as asked; where there is no room, the other way; inside the window. */
150
+ function place() {
151
+ if (target === undefined || tip === undefined || !tip.classList.contains("shown")) {
152
+ return;
153
+ }
154
+ const box = target.getBoundingClientRect();
155
+ const windowWidth = document.documentElement.clientWidth;
156
+ const windowHeight = window.innerHeight;
157
+ // Its control gone, or scrolled out of sight.
158
+ if (!target.isConnected || (box.width === 0 && box.height === 0) || box.bottom < 0 || box.top > windowHeight) {
159
+ hide();
160
+ return;
161
+ }
162
+ const width = tip.offsetWidth;
163
+ const height = tip.offsetHeight;
164
+ const rtl = tip.dir === "rtl";
165
+ const asked = askedSide(target);
166
+ const startLeft = rtl ? box.right + gap : box.left - gap - width;
167
+ const roomAbove = box.top - gap - height >= margin;
168
+ const roomBelow = box.bottom + gap + height <= windowHeight - margin;
169
+ const roomStart = startLeft >= margin && startLeft + width <= windowWidth - margin;
170
+ const side = asked === "start" && roomStart ? "start" : asked === "below" ? (roomBelow || !roomAbove ? "below" : "above") : roomAbove || !roomBelow ? "above" : "below";
171
+ const left = side === "start" ? startLeft : box.left + box.width / 2 - width / 2;
172
+ const top = side === "start" ? box.top + box.height / 2 - height / 2 : side === "above" ? box.top - gap - height : box.bottom + gap;
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`);
176
+ }
177
+ function askedSide(element) {
178
+ return element.classList.contains("tip-left") ? "start" : element.classList.contains("tip-below") ? "below" : "above";
179
+ }
180
+ function within(value, low, high) {
181
+ return Math.max(low, Math.min(value, high));
182
+ }
183
+ // The one tip of the page, made at its first need, hidden from a screen reader: the control says it already.
184
+ function tipElement() {
185
+ if (tip === undefined) {
186
+ tip = document.createElement("div");
187
+ tip.className = "page-tip";
188
+ tip.setAttribute("aria-hidden", "true");
189
+ if (supportsPopover(tip)) {
190
+ tip.popover = "manual";
191
+ }
192
+ else {
193
+ tip.hidden = true;
194
+ }
195
+ document.body.append(tip);
196
+ }
197
+ return tip;
198
+ }
199
+ function openLayer(element) {
200
+ if (supportsPopover(element)) {
201
+ element.showPopover();
202
+ }
203
+ else {
204
+ element.hidden = false;
205
+ }
206
+ }
207
+ function closeLayer(element) {
208
+ if (!supportsPopover(element)) {
209
+ element.hidden = true;
210
+ }
211
+ else if (element.matches(":popover-open")) {
212
+ element.hidePopover();
213
+ }
214
+ }
215
+ function supportsPopover(element) {
216
+ return typeof element.showPopover === "function";
217
+ }
218
+ // The moment a pointer rests on a control before its tip shows: the page's --wait.
219
+ function waitTime() {
220
+ const value = getComputedStyle(document.documentElement).getPropertyValue("--wait").trim();
221
+ const time = Number.parseFloat(value);
222
+ return Number.isNaN(time) ? 500 : value.endsWith("ms") ? time : time * 1000;
223
+ }