rpg-engine 0.15.0 → 0.16.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 (486) hide show
  1. package/dist/campaign/index.d.ts +1 -1
  2. package/dist/campaign/index.js +1 -1
  3. package/dist/campaign/settings.d.ts +6 -0
  4. package/dist/campaign/settings.js +22 -1
  5. package/dist/cli/cli.js +1 -1
  6. package/dist/cli/command-line.js +1 -1
  7. package/dist/commands/advance.d.ts +1 -1
  8. package/dist/commands/advance.js +6 -6
  9. package/dist/commands/ask.js +7 -7
  10. package/dist/commands/change/amounts.d.ts +32 -0
  11. package/dist/commands/change/amounts.js +150 -0
  12. package/dist/commands/change/change.d.ts +4 -54
  13. package/dist/commands/change/change.js +19 -749
  14. package/dist/commands/change/damage.d.ts +30 -0
  15. package/dist/commands/change/damage.js +73 -2
  16. package/dist/commands/change/dice.d.ts +34 -0
  17. package/dist/commands/change/dice.js +59 -0
  18. package/dist/commands/change/fields.d.ts +37 -0
  19. package/dist/commands/change/fields.js +156 -0
  20. package/dist/commands/change/holder.d.ts +48 -0
  21. package/dist/commands/change/holder.js +162 -0
  22. package/dist/commands/change/recipe-pace.js +1 -1
  23. package/dist/commands/change/recipe.d.ts +58 -0
  24. package/dist/commands/change/recipe.js +179 -0
  25. package/dist/commands/choices.js +3 -3
  26. package/dist/commands/config/config.d.ts +15 -0
  27. package/dist/commands/config/config.js +355 -0
  28. package/dist/commands/config/custom-levels.d.ts +7 -0
  29. package/dist/commands/config/custom-levels.js +32 -0
  30. package/dist/commands/{config.d.ts → config/dashboard.d.ts} +2 -24
  31. package/dist/commands/config/dashboard.js +171 -0
  32. package/dist/commands/config/entries.d.ts +17 -0
  33. package/dist/commands/config/entries.js +76 -0
  34. package/dist/commands/config/news.d.ts +7 -0
  35. package/dist/commands/config/news.js +88 -0
  36. package/dist/commands/config/shown.d.ts +9 -0
  37. package/dist/commands/config/shown.js +80 -0
  38. package/dist/commands/config/words.d.ts +27 -0
  39. package/dist/commands/config/words.js +204 -0
  40. package/dist/commands/effect.js +9 -9
  41. package/dist/commands/find.js +1 -1
  42. package/dist/commands/image.js +6 -6
  43. package/dist/commands/import/import.d.ts +0 -2
  44. package/dist/commands/import/import.js +45 -44
  45. package/dist/commands/import/run.js +1 -1
  46. package/dist/commands/index.js +3 -3
  47. package/dist/commands/init.js +2 -2
  48. package/dist/commands/install.js +1 -1
  49. package/dist/commands/instructions.js +6 -6
  50. package/dist/commands/mode.d.ts +2 -2
  51. package/dist/commands/mode.js +8 -8
  52. package/dist/commands/mood.js +4 -4
  53. package/dist/commands/move.js +10 -10
  54. package/dist/commands/package/consent.d.ts +11 -0
  55. package/dist/commands/package/consent.js +52 -0
  56. package/dist/commands/package/here.d.ts +51 -0
  57. package/dist/commands/package/here.js +128 -0
  58. package/dist/commands/package/install.d.ts +10 -0
  59. package/dist/commands/package/install.js +337 -0
  60. package/dist/commands/package/package.d.ts +18 -0
  61. package/dist/commands/package/package.js +236 -0
  62. package/dist/commands/package/result.d.ts +90 -0
  63. package/dist/commands/package/result.js +1 -0
  64. package/dist/commands/package/uninstall.d.ts +6 -0
  65. package/dist/commands/package/uninstall.js +70 -0
  66. package/dist/commands/rename.js +3 -3
  67. package/dist/commands/reveal.js +5 -5
  68. package/dist/commands/roll/roll.js +11 -9
  69. package/dist/commands/roll/tables.js +1 -1
  70. package/dist/commands/rules.d.ts +2 -2
  71. package/dist/commands/rules.js +3 -3
  72. package/dist/commands/save.d.ts +1 -1
  73. package/dist/commands/save.js +2 -2
  74. package/dist/commands/scene/close.d.ts +18 -0
  75. package/dist/commands/scene/close.js +179 -0
  76. package/dist/commands/scene/members.d.ts +14 -0
  77. package/dist/commands/scene/members.js +32 -0
  78. package/dist/commands/scene/open.d.ts +6 -0
  79. package/dist/commands/scene/open.js +298 -0
  80. package/dist/commands/scene/result.d.ts +98 -0
  81. package/dist/commands/scene/result.js +2 -0
  82. package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
  83. package/dist/commands/scene/scene.js +210 -0
  84. package/dist/commands/scene/turns.d.ts +18 -0
  85. package/dist/commands/scene/turns.js +229 -0
  86. package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +5 -3
  87. package/dist/commands/shared/{adventures.js → books/adventures.js} +23 -19
  88. package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
  89. package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
  90. package/dist/commands/shared/{library.js → books/library.js} +9 -9
  91. package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
  92. package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
  93. package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
  94. package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
  95. package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
  96. package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
  97. package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
  98. package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
  99. package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
  100. package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
  101. package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
  102. package/dist/commands/shared/{mode.js → campaign/mode.js} +24 -13
  103. package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
  104. package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
  105. package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
  106. package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
  107. package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
  108. package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
  109. package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +3 -3
  110. package/dist/commands/shared/{parts.js → campaign/parts.js} +3 -3
  111. package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
  112. package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
  113. package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
  114. package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
  115. package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
  116. package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
  117. package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
  118. package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
  119. package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
  120. package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
  121. package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
  122. package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
  123. package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
  124. package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
  125. package/dist/commands/shared/characters/orders.d.ts +4 -0
  126. package/dist/commands/shared/characters/orders.js +10 -0
  127. package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +2 -2
  128. package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +3 -3
  129. package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
  130. package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
  131. package/dist/commands/shared/examples.js +2 -2
  132. package/dist/commands/shared/packages/catalog.js +2 -2
  133. package/dist/commands/shared/packages/code.d.ts +1 -1
  134. package/dist/commands/shared/packages/code.js +8 -8
  135. package/dist/commands/shared/packages/extensions.d.ts +1 -1
  136. package/dist/commands/shared/packages/extensions.js +1 -1
  137. package/dist/commands/shared/packages/hooks.d.ts +1 -1
  138. package/dist/commands/shared/packages/hooks.js +1 -1
  139. package/dist/commands/shared/packages/widgets.d.ts +3 -3
  140. package/dist/commands/shared/packages/widgets.js +3 -3
  141. package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
  142. package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
  143. package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
  144. package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
  145. package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
  146. package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
  147. package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
  148. package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
  149. package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
  150. package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
  151. package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
  152. package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
  153. package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
  154. package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
  155. package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
  156. package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
  157. package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
  158. package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
  159. package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
  160. package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
  161. package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
  162. package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
  163. package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
  164. package/dist/commands/shared/{scene.js → scene/scene.js} +7 -7
  165. package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
  166. package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
  167. package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
  168. package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
  169. package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
  170. package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
  171. package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
  172. package/dist/commands/shared/sheet/effect-values.js +69 -0
  173. package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
  174. package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
  175. package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
  176. package/dist/commands/shared/sheet/formula-problems.js +140 -0
  177. package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
  178. package/dist/commands/shared/sheet/formula-scope.js +235 -0
  179. package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
  180. package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
  181. package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
  182. package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
  183. package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +5 -5
  184. package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
  185. package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
  186. package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
  187. package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
  188. package/dist/commands/shared/sheet/system-fields.js +45 -0
  189. package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
  190. package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
  191. package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
  192. package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
  193. package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
  194. package/dist/commands/shared/sheet/worked-out.js +291 -0
  195. package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
  196. package/dist/commands/shared/sheet/worked-text.js +55 -0
  197. package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
  198. package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
  199. package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
  200. package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
  201. package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
  202. package/dist/commands/shared/{events.js → time/events.js} +10 -13
  203. package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
  204. package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
  205. package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
  206. package/dist/commands/shared/{time.js → time/time.js} +6 -6
  207. package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
  208. package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
  209. package/dist/commands/show.d.ts +3 -0
  210. package/dist/commands/show.js +28 -9
  211. package/dist/commands/status.d.ts +2 -1
  212. package/dist/commands/status.js +28 -22
  213. package/dist/commands/thoughts.js +3 -3
  214. package/dist/commands/trade.js +8 -8
  215. package/dist/commands/translate.d.ts +1 -1
  216. package/dist/commands/translate.js +3 -3
  217. package/dist/commands/travel/open.d.ts +1 -1
  218. package/dist/commands/travel/open.js +2 -2
  219. package/dist/commands/travel/route.js +7 -6
  220. package/dist/commands/travel/travel.d.ts +1 -1
  221. package/dist/commands/travel/travel.js +8 -8
  222. package/dist/commands/validate.js +3 -3
  223. package/dist/commands/view/journal.d.ts +2 -2
  224. package/dist/commands/view/journal.js +2 -2
  225. package/dist/commands/view/map.d.ts +1 -1
  226. package/dist/commands/view/map.js +6 -6
  227. package/dist/commands/view/memory.d.ts +16 -0
  228. package/dist/commands/view/memory.js +90 -0
  229. package/dist/commands/view/page.d.ts +32 -0
  230. package/dist/commands/view/page.js +163 -0
  231. package/dist/commands/view/place.d.ts +7 -2
  232. package/dist/commands/view/place.js +30 -12
  233. package/dist/commands/view/result.d.ts +245 -0
  234. package/dist/commands/view/result.js +1 -0
  235. package/dist/commands/view/saves.d.ts +6 -0
  236. package/dist/commands/view/saves.js +53 -0
  237. package/dist/commands/view/story.d.ts +32 -0
  238. package/dist/commands/view/story.js +227 -0
  239. package/dist/commands/view/view.d.ts +26 -292
  240. package/dist/commands/view/view.js +26 -534
  241. package/dist/commands/view/world.d.ts +1 -1
  242. package/dist/commands/view/world.js +3 -3
  243. package/dist/commands/write/checks.d.ts +42 -0
  244. package/dist/commands/write/checks.js +291 -0
  245. package/dist/commands/write/here.d.ts +1 -1
  246. package/dist/commands/write/here.js +5 -5
  247. package/dist/commands/write/inheritance.d.ts +40 -0
  248. package/dist/commands/write/inheritance.js +189 -0
  249. package/dist/commands/write/input.d.ts +29 -0
  250. package/dist/commands/write/input.js +124 -0
  251. package/dist/commands/write/layer.d.ts +36 -0
  252. package/dist/commands/write/layer.js +48 -0
  253. package/dist/commands/write/notes.d.ts +22 -0
  254. package/dist/commands/write/notes.js +76 -0
  255. package/dist/commands/write/progression.d.ts +27 -0
  256. package/dist/commands/write/progression.js +175 -0
  257. package/dist/commands/write/write.d.ts +1 -0
  258. package/dist/commands/write/write.js +32 -816
  259. package/dist/core/files.d.ts +2 -0
  260. package/dist/core/files.js +7 -0
  261. package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
  262. package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
  263. package/dist/core/session-store.js +3 -3
  264. package/dist/core/store.d.ts +2 -2
  265. package/dist/core/store.js +18 -4
  266. package/dist/dashboard/acts/acts.js +1 -1
  267. package/dist/dashboard/acts/sending.js +110 -0
  268. package/dist/dashboard/acts/sheet.js +2 -2
  269. package/dist/dashboard/acts/strip.js +1 -1
  270. package/dist/dashboard/address.js +6 -0
  271. package/dist/dashboard/api.js +1 -1
  272. package/dist/dashboard/app.js +47 -171
  273. package/dist/dashboard/dice/roller.js +1 -1
  274. package/dist/dashboard/dice/sets.js +2 -2
  275. package/dist/dashboard/dice/stage.js +1 -1
  276. package/dist/dashboard/dice/tray.js +6 -6
  277. package/dist/dashboard/guide/ar.md +5 -3
  278. package/dist/dashboard/guide/cs.md +5 -3
  279. package/dist/dashboard/guide/da.md +5 -3
  280. package/dist/dashboard/guide/de.md +5 -3
  281. package/dist/dashboard/guide/el.md +5 -3
  282. package/dist/dashboard/guide/en.md +2 -0
  283. package/dist/dashboard/guide/es.md +4 -2
  284. package/dist/dashboard/guide/fi.md +5 -3
  285. package/dist/dashboard/guide/fr.md +4 -2
  286. package/dist/dashboard/guide/he.md +4 -2
  287. package/dist/dashboard/guide/hi.md +6 -4
  288. package/dist/dashboard/guide/hu.md +4 -2
  289. package/dist/dashboard/guide/is.md +5 -3
  290. package/dist/dashboard/guide/it.md +3 -1
  291. package/dist/dashboard/guide/ja.md +7 -5
  292. package/dist/dashboard/guide/ko.md +6 -4
  293. package/dist/dashboard/guide/nb.md +4 -2
  294. package/dist/dashboard/guide/nl.md +5 -3
  295. package/dist/dashboard/guide/pl.md +4 -2
  296. package/dist/dashboard/guide/pt.md +4 -2
  297. package/dist/dashboard/guide/ro.md +5 -3
  298. package/dist/dashboard/guide/ru.md +5 -3
  299. package/dist/dashboard/guide/sv.md +5 -3
  300. package/dist/dashboard/guide/tr.md +6 -4
  301. package/dist/dashboard/guide/uk.md +4 -2
  302. package/dist/dashboard/guide/zh.md +5 -3
  303. package/dist/dashboard/help/help.js +3 -3
  304. package/dist/dashboard/i18n/ar.json +4 -0
  305. package/dist/dashboard/i18n/cs.json +4 -0
  306. package/dist/dashboard/i18n/da.json +4 -0
  307. package/dist/dashboard/i18n/de.json +4 -0
  308. package/dist/dashboard/i18n/el.json +4 -0
  309. package/dist/dashboard/i18n/es.json +4 -0
  310. package/dist/dashboard/i18n/fi.json +4 -0
  311. package/dist/dashboard/i18n/fr.json +4 -0
  312. package/dist/dashboard/i18n/he.json +4 -0
  313. package/dist/dashboard/i18n/hi.json +4 -0
  314. package/dist/dashboard/i18n/hu.json +4 -0
  315. package/dist/dashboard/i18n/is.json +4 -0
  316. package/dist/dashboard/i18n/it.json +4 -0
  317. package/dist/dashboard/i18n/ja.json +5 -1
  318. package/dist/dashboard/i18n/ko.json +4 -0
  319. package/dist/dashboard/i18n/nb.json +4 -0
  320. package/dist/dashboard/i18n/nl.json +4 -0
  321. package/dist/dashboard/i18n/pl.json +4 -0
  322. package/dist/dashboard/i18n/pt.json +4 -0
  323. package/dist/dashboard/i18n/ro.json +4 -0
  324. package/dist/dashboard/i18n/ru.json +4 -0
  325. package/dist/dashboard/i18n/sv.json +4 -0
  326. package/dist/dashboard/i18n/tr.json +4 -0
  327. package/dist/dashboard/i18n/uk.json +4 -0
  328. package/dist/dashboard/i18n/zh.json +4 -0
  329. package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
  330. package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
  331. package/dist/dashboard/kit.js +3 -3
  332. package/dist/dashboard/packages/ask-card.js +3 -3
  333. package/dist/dashboard/packages/catalog.js +196 -0
  334. package/dist/dashboard/packages/engine.js +87 -0
  335. package/dist/dashboard/packages/installed.js +53 -0
  336. package/dist/dashboard/packages/library.js +97 -0
  337. package/dist/dashboard/packages/outcomes.js +45 -0
  338. package/dist/dashboard/packages/packages.js +20 -576
  339. package/dist/dashboard/packages/page-code.js +15 -2
  340. package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
  341. package/dist/dashboard/packages/rows.js +84 -0
  342. package/dist/dashboard/packages/share.js +44 -0
  343. package/dist/dashboard/packages/widgets.js +3 -3
  344. package/dist/dashboard/{card.js → parts/card.js} +1 -1
  345. package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
  346. package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
  347. package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
  348. package/dist/dashboard/{labels.js → parts/labels.js} +2 -1
  349. package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
  350. package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
  351. package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
  352. package/dist/dashboard/{refusals.js → parts/refusals.js} +1 -1
  353. package/dist/dashboard/{status.js → parts/status.js} +4 -4
  354. package/dist/dashboard/{widgets.js → parts/widgets.js} +2 -2
  355. package/dist/dashboard/place/key.js +24 -0
  356. package/dist/dashboard/place/paper.js +67 -0
  357. package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
  358. package/dist/dashboard/place/things.js +129 -0
  359. package/dist/dashboard/place/tokens.js +93 -0
  360. package/dist/dashboard/place/view.js +124 -0
  361. package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
  362. package/dist/dashboard/{asked.js → play/asked.js} +10 -10
  363. package/dist/dashboard/{choices.js → play/choices.js} +9 -9
  364. package/dist/dashboard/{requested.js → play/requested.js} +1 -1
  365. package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
  366. package/dist/dashboard/{scene.js → play/scene.js} +14 -14
  367. package/dist/dashboard/{turns.js → play/turns.js} +12 -12
  368. package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
  369. package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
  370. package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
  371. package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
  372. package/dist/dashboard/{setup.js → settings/setup.js} +5 -5
  373. package/dist/dashboard/{party.js → sheet/party.js} +8 -8
  374. package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
  375. package/dist/dashboard/{sheet.js → sheet/sheet.js} +17 -17
  376. package/dist/dashboard/{story.js → sheet/story.js} +3 -3
  377. package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
  378. package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
  379. package/dist/dashboard/{master.js → shell/master.js} +2 -2
  380. package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
  381. package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
  382. package/dist/dashboard/shell/shown.js +37 -0
  383. package/dist/dashboard/{table.js → shell/table.js} +2 -2
  384. package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
  385. package/dist/dashboard/{top.js → shell/top.js} +7 -7
  386. package/dist/dashboard/style.css +74 -3
  387. package/dist/dashboard/world/calendar.js +4 -4
  388. package/dist/dashboard/world/drawing.js +92 -0
  389. package/dist/dashboard/world/key.js +21 -0
  390. package/dist/dashboard/world/lore.js +5 -5
  391. package/dist/dashboard/world/map-card.js +186 -0
  392. package/dist/dashboard/world/place-card.js +39 -0
  393. package/dist/dashboard/world/places.js +29 -0
  394. package/dist/dashboard/world/world.js +9 -341
  395. package/dist/extensions/extension.d.ts +1 -1
  396. package/dist/extensions/extension.js +1 -1
  397. package/dist/images/images.js +12 -9
  398. package/dist/index.d.ts +1 -1
  399. package/dist/languages/index.d.ts +1 -1
  400. package/dist/languages/index.js +1 -1
  401. package/dist/packages/npm.js +1 -1
  402. package/dist/page.d.ts +2 -2
  403. package/dist/page.js +1 -1
  404. package/dist/pages/check.js +23 -1
  405. package/dist/pages/containers.d.ts +1 -1
  406. package/dist/pages/containers.js +1 -1
  407. package/dist/pages/index.d.ts +4 -2
  408. package/dist/pages/index.js +4 -2
  409. package/dist/pages/inheritance.d.ts +2 -2
  410. package/dist/pages/layers.d.ts +50 -0
  411. package/dist/pages/layers.js +97 -0
  412. package/dist/pages/rename-page.js +1 -1
  413. package/dist/pages/stacks/writes.js +48 -22
  414. package/dist/pages/standard-fields.d.ts +1 -1
  415. package/dist/pages/system-pages.d.ts +5 -3
  416. package/dist/pages/system-pages.js +16 -7
  417. package/dist/pages/world.d.ts +8 -1
  418. package/dist/pages/world.js +16 -4
  419. package/dist/pages/write-layer.d.ts +18 -0
  420. package/dist/pages/write-layer.js +108 -0
  421. package/dist/pages/write-page.d.ts +2 -2
  422. package/dist/pages/write-page.js +2 -2
  423. package/dist/rules/index.d.ts +1 -1
  424. package/dist/rules/index.js +1 -1
  425. package/dist/rules/search.d.ts +1 -1
  426. package/dist/rules/shown.d.ts +1 -1
  427. package/dist/server/dashboard/choices.js +3 -3
  428. package/dist/server/dashboard/files.js +5 -5
  429. package/dist/server/dashboard/index.d.ts +2 -2
  430. package/dist/server/dashboard/index.js +2 -2
  431. package/dist/server/dashboard/news.js +4 -3
  432. package/dist/server/dashboard/player.js +1 -1
  433. package/dist/server/dashboard/writes.js +9 -7
  434. package/dist/server/mcp.js +28 -13
  435. package/dist/systems/campaign-data.d.ts +15 -0
  436. package/dist/systems/campaign-data.js +85 -0
  437. package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
  438. package/dist/systems/{system-code.js → code.js} +2 -2
  439. package/dist/systems/game-system.d.ts +7 -61
  440. package/dist/systems/game-system.js +1 -984
  441. package/dist/systems/index.d.ts +6 -3
  442. package/dist/systems/index.js +6 -3
  443. package/dist/systems/installed.d.ts +31 -0
  444. package/dist/systems/installed.js +89 -0
  445. package/dist/systems/maps.d.ts +3 -0
  446. package/dist/systems/maps.js +9 -0
  447. package/dist/systems/read.d.ts +3 -0
  448. package/dist/systems/read.js +471 -0
  449. package/dist/systems/schema.d.ts +289 -0
  450. package/dist/systems/schema.js +243 -0
  451. package/dist/systems/settings.d.ts +19 -0
  452. package/dist/systems/settings.js +78 -0
  453. package/dist/systems/versions.d.ts +12 -0
  454. package/dist/systems/versions.js +52 -0
  455. package/dist/testing/index.js +1 -1
  456. package/instructions/import.md +1 -1
  457. package/instructions/play.md +1 -1
  458. package/package.json +1 -1
  459. package/dist/commands/config.js +0 -948
  460. package/dist/commands/package.d.ts +0 -143
  461. package/dist/commands/package.js +0 -785
  462. package/dist/commands/scene.js +0 -894
  463. package/dist/commands/shared/worked-out.js +0 -805
  464. package/dist/dashboard/place/map-view.js +0 -417
  465. /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
  466. /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
  467. /package/dist/core/{package-api.js → packages/api.js} +0 -0
  468. /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
  469. /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
  470. /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
  471. /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
  472. /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
  473. /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
  474. /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
  475. /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
  476. /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
  477. /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
  478. /package/dist/languages/{language-pack.js → pack.js} +0 -0
  479. /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
  480. /package/dist/pages/{page-file.js → file.js} +0 -0
  481. /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
  482. /package/dist/pages/{page-types.js → types.js} +0 -0
  483. /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
  484. /package/dist/rules/{rule-book.js → book.js} +0 -0
  485. /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
  486. /package/dist/systems/{system-folders.js → folders.js} +0 -0
@@ -1,54 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ // The Packages section (D-485, D-486, D-488), in three tabs: Installed first, what is here by kind: the game system, the campaign's adventures with its own
3
+ // export last, the extensions with whether the campaign uses each, the languages; its tab counts the updates and marks what the campaign lacks. Then Add: one
4
+ // card to add a package: the catalog of what npm and GitHub offer first, always open, then a link, an npm name, a folder or a file. Then Library: the folders
5
+ // of the player's books for this campaign alone (D-491 (13)). One work at a time; one not ours with code, or a folder added to the library, waits for the
6
+ // player's yes in a window of their computer, said in every tab.
2
7
  import { useEffect, useRef, useState } from "preact/hooks";
3
8
  import { sectionAddress } from "../address.js";
4
- import { addFile, addSource, changeLibrary, changePackage, exportCampaign, readCatalog, readEngine, readLibrary, readPackages, updateEngine, } from "../api.js";
5
- import { CardHead, useMedia } from "../card.js";
6
- import { gameDateLabel, sinceDateLabel } from "../game-words.js";
7
- import { Icon, iconPath } from "../icons.js";
8
- import { phraseLabel, systemNameLabel, systemTitleLabel } from "../labels.js";
9
- import { languageName } from "../languages.js";
10
- import { PageHead } from "../pages.js";
11
- import { Confirm } from "../saves.js";
12
- import { Command } from "../settings.js";
13
- import { PageTabs } from "../tabs.js";
14
- import { arrowStep, foldedText, isolated, pageDirection, pageLocale, t } from "../text.js";
15
- import { OwnPageLinks } from "./package-page.js";
16
- // The engine's own name, never translated.
17
- const engineName = "RPG Engine";
18
- // Where the engine installed from this page is kept while the chat goes on with the one before it: in this tab, through a reload.
19
- const updatedKey = "rpg-engine-updated";
20
- /** The engine installed from this page in this tab, if any. */
21
- function keptUpdate() {
22
- try {
23
- const kept = JSON.parse(sessionStorage.getItem(updatedKey) ?? "null");
24
- return kept !== null && typeof kept.to === "string" && typeof kept.from === "string" ? { from: kept.from, to: kept.to, restart: kept.restart === "app" ? "app" : "chat" } : undefined;
25
- }
26
- catch {
27
- return undefined;
28
- }
29
- }
30
- function keepUpdate(updated) {
31
- try {
32
- if (updated === undefined) {
33
- sessionStorage.removeItem(updatedKey);
34
- }
35
- else {
36
- sessionStorage.setItem(updatedKey, JSON.stringify(updated));
37
- }
38
- }
39
- catch {
40
- // A browser that keeps nothing says it until the page is drawn again.
41
- }
42
- }
43
- /** The focus to the engine's card: its Update, else its title. */
44
- function focusEngine() {
45
- const target = document.getElementById("engine-update") ?? document.getElementById("packages-engine");
46
- target?.focus({ preventScroll: true });
47
- target?.scrollIntoView({ block: "center" });
48
- }
49
- // The rows of the catalog shown before "Show more": fewer on a phone, where the installed come after it.
50
- const shownWide = 5;
51
- const shownNarrow = 3;
9
+ import { addFile, addSource, changeLibrary, changePackage, readCatalog, readEngine, readLibrary, readPackages, updateEngine, } from "../api.js";
10
+ import { CardHead } from "../parts/card.js";
11
+ import { Icon, iconPath } from "../parts/icons.js";
12
+ import { phraseLabel } from "../parts/labels.js";
13
+ import { Confirm } from "../settings/saves.js";
14
+ import { PageHead } from "../shell/pages.js";
15
+ import { PageTabs } from "../shell/tabs.js";
16
+ import { t } from "../text.js";
17
+ import { AddField, CatalogList, entryOf, entryTitle, newerOf, updateCount } from "./catalog.js";
18
+ import { EngineCard, engineName, focusEngine, keepUpdate, keptUpdate, NeedsEngine } from "./engine.js";
19
+ import { AdventureRow, ExtensionRow, LanguageRow, languageTitle, MissingRow, SystemRow } from "./installed.js";
20
+ import { libraryReading, LibraryTab } from "./library.js";
21
+ import { addedText, doneText, failure, uninstallText } from "./outcomes.js";
22
+ import { CardSaid, SaidNote, WorkNote } from "./rows.js";
23
+ import { ShareCampaign } from "./share.js";
52
24
  export function PackagesPage({ version, tab }) {
53
25
  const [view, setView] = useState();
54
26
  const [problem, setProblem] = useState();
@@ -245,97 +217,6 @@ export function PackagesPage({ version, tab }) {
245
217
  ? add(`extension:${extension.package}`, extension.package)
246
218
  : change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => (_jsx(LanguageRow, { language: language, newer: newerOf(language.package, "language", catalog.read), needs: needs(entryOf(language.package, "language", catalog.read)?.newer), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void change(`language:${language.code}`, "update", language.package, languageTitle(language)), onUninstall: () => setAsking({ kind: "uninstall", what: "language", name: languageTitle(language), target: language.package, at: `language:${language.code}` }) }, language.package))) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
247
219
  }
248
- // How often the library is read again while its books are being read, for their counts.
249
- const libraryReading = 5000;
250
- /**
251
- * This computer's library (D-491 (13)): said first to be added once to the computer and turned on in each campaign, as packages are, with how many this one
252
- * uses; its folders, each with its books read, being read and skipped, whether this campaign uses it, and the bin; then the field that adds a folder or a book.
253
- */
254
- function LibraryTab({ view, problem, state, onAdd, onUse, onForget }) {
255
- const entries = view?.entries ?? [];
256
- const used = entries.filter((entry) => entry.used && entry.onComputer).length;
257
- // A folder by its name; by its path when another has the same name.
258
- const label = (entry) => (entries.filter((other) => shelfName(other.path) === shelfName(entry.path)).length > 1 ? entry.path : shelfName(entry.path));
259
- return (_jsxs("section", { class: "card", "aria-labelledby": "packages-library", children: [_jsx(CardHead, { icon: iconPath("library"), title: _jsx("h3", { id: "packages-library", tabIndex: -1, children: t("Your books") }), ...(entries.length === 0 ? {} : { note: t("{count} in this campaign", { count: used }) }) }), _jsxs("div", { class: "card-body package-body", children: [_jsxs("p", { class: "library-scope", children: [_jsx(Icon, { name: "info" }), _jsxs("span", { children: [_jsx("strong", { children: t("Added once to this computer.") }), " ", t("Each campaign then turns on its own; the master searches them after the game system, citing the book and the page.")] })] }), problem !== undefined && _jsx("p", { class: "package-said problem", role: "alert", children: problem }), view !== undefined && entries.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add the folder of your manuals.") }), entries.length > 0 && (_jsx("ul", { class: "package-list", children: entries.map((entry) => (_jsx(LibraryRow, { entry: entry, label: label(entry), state: state(`library:${entry.path}`), onUse: (use) => onUse(entry.path, use, !entry.onComputer), onForget: () => onForget(entry.path, label(entry)) }, entry.path))) })), _jsx(LibraryField, { state: state("library"), onAdd: onAdd })] })] }));
260
- }
261
- /**
262
- * A folder or a book of the library: its name, its path under it, what is read of it, what was skipped with the engine's words; whether this campaign uses it,
263
- * as a switch, and the bin that takes it off this computer. One the campaign lists and the computer has not, in red, with Add and Take out of this campaign.
264
- */
265
- function LibraryRow({ entry, label, state, onUse, onForget }) {
266
- const path = (_jsx("bdi", { dir: "ltr", class: "library-path", children: breakablePath(entry.path) }));
267
- const name = _jsx("bdi", { children: shelfName(entry.path) });
268
- if (!entry.onComputer) {
269
- return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsxs(_Fragment, { children: [path, _jsx("span", { class: "package-red", children: t("Not on this computer: the master does not search it until you add it again.") })] }), row: `library:${entry.path}`, actions: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Add {path} again", { path: label }), "aria-disabled": state.busy, onClick: () => !state.busy && onUse(true), children: [_jsx(Icon, { name: "plus" }), t("Add")] }), _jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Take {name} out of this campaign", { name: label }), "aria-disabled": state.busy, onClick: () => !state.busy && onUse(false), children: [_jsx(Icon, { name: "minus" }), t("Take out of this campaign")] })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
270
- }
271
- return (_jsxs(PackageRow, { tile: "folder", tone: entry.missing ? "dim" : undefined, name: name, about: path, meta: libraryMeta(entry), row: `library:${entry.path}`, actions: _jsxs(_Fragment, { children: [_jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: entry.used, "aria-label": t("{path}: in this campaign", { path: label }), "aria-disabled": state.busy, onClick: (event) => {
272
- event.preventDefault();
273
- if (!state.busy) {
274
- onUse(!entry.used);
275
- }
276
- } }), t("In this campaign")] }), _jsx("button", { type: "button", class: "icon-button package-bin tip-left", "aria-label": t("Take {path} off this computer…", { path: label }), "data-tip": t("Take off this computer…"), "aria-disabled": state.busy, onClick: () => !state.busy && onForget(), children: _jsx(Icon, { name: "clear" }) })] }), children: [entry.skipped.length > 0 && (_jsx("ul", { class: "library-skipped", children: entry.skipped.map((one) => (_jsxs("li", { children: [_jsx("bdi", { children: one.name }), ": ", skippedText(one.kind)] }, one.name))) })), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
277
- }
278
- /** Why a book was skipped, in the player's words, with what to do. */
279
- function skippedText(kind) {
280
- const texts = {
281
- password: t("it asks for a password to open: save a copy without one."),
282
- drm: t("it is locked by DRM, which RPG Engine never opens."),
283
- stuck: t("it stopped the reader twice: too big or damaged, or kept busy by another program. Close that program, or save the file again."),
284
- denied: t("this computer does not let it be read: check who may open it."),
285
- broken: t("it does not read: the file is damaged, or is not what its name says."),
286
- };
287
- return texts[kind];
288
- }
289
- /** The name a folder or a book of the library goes by: its last part, without a book's kind; a disk's whole path. */
290
- function shelfName(path) {
291
- const last = path.replace(/[\\/]+$/, "").split(/[\\/]/).at(-1) ?? "";
292
- return last === "" || /^[a-z]:$/i.test(last) ? path : last.replace(/\.(md|txt|pdf|docx|odt|epub|html?)$/i, "");
293
- }
294
- /** What is read of a folder of the library, in the page's words: its books read and being read, those skipped, or that it is not there now, or holds too many. */
295
- function libraryMeta(entry) {
296
- if (entry.missing) {
297
- return t("Not there now, as a disk taken out: its books stay known for when it is back.");
298
- }
299
- return [
300
- entry.books === 1 ? t("1 book read") : t("{count} books read", { count: entry.books }),
301
- entry.reading === 0 ? "" : entry.reading === 1 ? t("1 being read") : t("{count} being read", { count: entry.reading }),
302
- entry.skipped.length === 0 ? "" : entry.skipped.length === 1 ? t("1 skipped") : t("{count} skipped", { count: entry.skipped.length }),
303
- entry.crowded ? t("more than 300 documents: only the first are read; give the folder of this game's books") : "",
304
- ].filter((part) => part !== "").join(" · ");
305
- }
306
- /** A path that goes to a new line after its separators, as words do, and is copied as it is. */
307
- function breakablePath(path) {
308
- return path.split(/(?<=[\\/])/).flatMap((part, index) => (index === 0 ? [part] : [_jsx("wbr", {}, index), part]));
309
- }
310
- /**
311
- * The field that adds to the library: a folder or a book written by hand, as the browser gives no folder's path; what to give it, and that the computer asks the
312
- * player's yes and never changes the folder. It empties once added.
313
- */
314
- function LibraryField({ state, onAdd }) {
315
- const [path, setPath] = useState("");
316
- const [empty, setEmpty] = useState(false);
317
- const sent = useRef(undefined);
318
- useEffect(() => {
319
- if (state.said?.problem === false && sent.current === path) {
320
- setPath("");
321
- }
322
- }, [state.said]);
323
- const submit = () => {
324
- const given = path.trim().replace(/^"(.*)"$/, "$1");
325
- if (state.busy) {
326
- return;
327
- }
328
- setEmpty(given === "");
329
- if (given !== "") {
330
- sent.current = path;
331
- onAdd(given);
332
- }
333
- };
334
- return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
335
- event.preventDefault();
336
- submit();
337
- }, children: [_jsx("label", { class: "package-label", for: "library-path", children: t("A folder or a book of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "library-path", dir: "ltr", type: "text", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 1000, value: path, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "library-path-about", placeholder: "D:\\Books\\RPG", onInput: (event) => setPath(event.currentTarget.value) }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": state.busy, children: [_jsx(Icon, { name: "plus" }), t("Add")] })] }), _jsxs("p", { class: "package-note", id: "library-path-about", children: [t("Write or paste its full path: the browser does not give a folder's. Your computer asks your yes in a window, once, and nothing in the folder is ever changed."), " ", t("Text, or PDFs whose text can be selected, read best; a scanned PDF is read from the pictures of its pages, on Windows only, in a few minutes.")] }), empty && state.work === undefined && _jsx("p", { class: "package-said problem", role: "status", children: t("Write the path of a folder or a book first.") }), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
338
- }
339
220
  /** On the Installed tab, what asks for the player: the updates npm has, with their count, and a mark when the campaign lists what this computer lacks. */
340
221
  function TabMarks({ updates, missing }) {
341
222
  const [updatesText, missingText] = [updates > 0 ? marksText(updates, 0)[0] : "", missing > 0 ? marksText(0, missing)[0] : ""];
@@ -348,369 +229,6 @@ function marksText(updates, missing) {
348
229
  missing === 0 ? "" : missing === 1 ? t("1 missing on this computer") : t("{count} missing on this computer", { count: missing }),
349
230
  ].filter((one) => one !== "");
350
231
  }
351
- /**
352
- * The one field that adds (D-485 (1)): a link, a GitHub repository's too, an npm name or a folder written by hand, as the browser gives no folder's path; or a
353
- * file. The field keeps the focus and what was written while the work goes; it empties once added.
354
- */
355
- function AddField({ state, onAdd, onFile }) {
356
- const [source, setSource] = useState("");
357
- const [empty, setEmpty] = useState(false);
358
- const picker = useRef(null);
359
- const sent = useRef(undefined);
360
- // Added: the field is ready for the next one.
361
- useEffect(() => {
362
- if (state.said?.problem === false && sent.current === source) {
363
- setSource("");
364
- }
365
- }, [state.said]);
366
- const submit = () => {
367
- // A path copied with its quotes, as the file manager copies it, without them; an address copied without its scheme, as github.com/someone/an-adventure, as https.
368
- const given = source.trim().replace(/^"(.*)"$/, "$1").replace(/^(?=[\w-]+(?:\.[\w-]+)+\/)/, "https://");
369
- if (state.busy) {
370
- return;
371
- }
372
- setEmpty(given === "");
373
- if (given !== "") {
374
- sent.current = source;
375
- onAdd(given);
376
- }
377
- };
378
- return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
379
- event.preventDefault();
380
- submit();
381
- }, children: [_jsx("label", { class: "package-label", for: "package-source", children: t("From a link, an npm name or a folder of this computer") }), _jsxs("div", { class: "package-add-line", children: [_jsx("input", { id: "package-source", dir: "auto", type: "text", inputMode: "url", enterKeyHint: "go", autocomplete: "off", spellcheck: false, maxLength: 2000, value: source, readOnly: state.work !== undefined, "aria-invalid": state.said?.problem === true || empty, "aria-describedby": "package-source-about", placeholder: t("github.com/someone/an-adventure"), onInput: (event) => setSource(event.currentTarget.value) }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": state.busy, children: [_jsx(Icon, { name: "plus" }), t("Add")] }), _jsxs("button", { type: "button", class: "button package-button", "aria-disabled": state.busy, onClick: () => !state.busy && picker.current?.click(), children: [_jsx(Icon, { name: "file" }), t("From a file…")] }), _jsx("input", { ref: picker, type: "file", accept: ".zip,.tgz,.gz,application/zip,application/gzip", hidden: true, onChange: (event) => {
382
- const file = event.currentTarget.files?.[0];
383
- event.currentTarget.value = "";
384
- if (file !== undefined) {
385
- onFile(file);
386
- }
387
- } })] }), _jsx("p", { class: "package-note", id: "package-source-about", children: t("It tells the kind by itself: a game system, an adventure, an extension or a language. A file is a .zip or a .tgz.") }), empty && state.work === undefined && _jsx("p", { class: "package-said problem", role: "status", children: t("Write a link, an npm name or a folder first.") }), _jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said, onSee: state.onSee })] }));
388
- }
389
- /**
390
- * The catalog (D-486), always open: a search, chips for the kinds with how many each has, wrapping on a phone; the first rows, five or three on a phone, then
391
- * the others on asking. A source that does not answer is said in the page's words, with its own under them.
392
- */
393
- function CatalogList({ catalog, view, state, needs, onAdd, onUpdate, onRetry }) {
394
- const [kind, setKind] = useState("all");
395
- const [query, setQuery] = useState("");
396
- const [all, setAll] = useState(false);
397
- const narrow = useMedia("(max-width: 600px)");
398
- const list = useRef(null);
399
- const chips = useRef(null);
400
- const limit = narrow ? shownNarrow : shownWide;
401
- const entries = catalog.read?.entries ?? [];
402
- const found = entries.filter((entry) => matchesQuery(entry, query));
403
- const kinds = kindOrder.filter((one) => entries.some((entry) => entry.kind === one));
404
- const chosen = kinds.includes(kind) ? kind : "all";
405
- const shown = found.filter((entry) => chosen === "all" || entry.kind === chosen);
406
- // A row past the first ones stays in view while it is worked on or says what happened, as after a reload.
407
- const visible = all ? shown : shown.filter((entry, index) => index < limit || state(entry).work !== undefined || state(entry).said !== undefined);
408
- const failed = catalog.error === undefined ? catalog.read?.failed ?? {} : { npm: catalog.error, github: catalog.error };
409
- // The rows asked for come after those shown: the focus goes to the first of them.
410
- const showAll = () => {
411
- setAll(true);
412
- requestAnimationFrame(() => list.current?.children[limit]?.focus());
413
- };
414
- // The chips are one stop of Tab; the arrows go along them, as the page reads.
415
- const chipKey = (event) => {
416
- const buttons = [...chips.current?.querySelectorAll("button") ?? []];
417
- const at = buttons.indexOf(event.target);
418
- const step = arrowStep(event.key, true);
419
- const to = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : step === 0 ? -1 : (at + step + buttons.length) % buttons.length;
420
- if (to >= 0) {
421
- event.preventDefault();
422
- buttons[to]?.focus();
423
- buttons[to]?.click();
424
- }
425
- };
426
- const chip = (one, count) => (_jsxs("button", { type: "button", "aria-pressed": chosen === one, tabIndex: chosen === one ? 0 : -1, onClick: () => setKind(one), children: [one === "all" ? t("All") : kindsLabel(one), _jsx("span", { class: "package-count", children: count })] }, one));
427
- return (_jsxs("div", { class: "package-catalog", children: [_jsxs("div", { class: "package-catalog-head", children: [_jsx("h4", { class: "eyebrow package-sub", id: "package-catalog-title", children: t("Catalog") }), entries.length > 0 && (_jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: query, placeholder: t("Search"), "aria-label": t("Search the catalog"), onInput: (event) => setQuery(event.currentTarget.value) })] }))] }), kinds.length > 1 && (_jsxs("div", { class: "filter-chips", role: "group", "aria-label": t("Kind"), ref: chips, onKeyDown: chipKey, children: [chip("all", found.length), kinds.map((one) => chip(one, found.filter((entry) => entry.kind === one).length))] })), (failed.npm !== undefined || failed.github !== undefined) && _jsx(CatalogAway, { failed: failed, asking: catalog.asking, onRetry: onRetry }), catalog.asking && catalog.read === undefined && catalog.error === undefined && _jsx("p", { class: "package-note", role: "status", children: t("Asking npm and GitHub…") }), !catalog.asking && entries.length === 0 && failed.npm === undefined && failed.github === undefined && _jsx("p", { class: "package-note", children: t("Nothing to add for now.") }), entries.length > 0 && shown.length === 0 && _jsx("p", { class: "package-note", children: t("Nothing matches “{query}”.", { query: query.trim() }) }), visible.length > 0 && (_jsx("ul", { class: "package-list", ref: list, "aria-labelledby": "package-catalog-title", children: visible.map((entry) => (_jsx(CatalogRow, { entry: entry, named: chosen === "all", view: view, state: state(entry), needs: needs(entry), onAdd: () => onAdd(entry), onUpdate: () => onUpdate(entry) }, `${entry.kind}:${entry.source}`))) })), shown.length > visible.length && (_jsxs("button", { type: "button", class: "package-show", onClick: showAll, children: [t("Show the other {count}", { count: shown.length - visible.length }), _jsx(Icon, { name: "more" })] }))] }));
428
- }
429
- /** npm or GitHub away, or both: the rest is added all the same; the engine's words under the page's, and Try again. */
430
- function CatalogAway({ failed, asking, onRetry }) {
431
- const both = failed.npm !== undefined && failed.github !== undefined;
432
- const [headline, line] = both
433
- ? [t("The catalog does not answer."), t("A file, a link or a folder can be added all the same.")]
434
- : failed.npm !== undefined
435
- ? [t("npm does not answer."), t("Game systems, extensions and languages come from npm: a file, a link or a folder can be added all the same.")]
436
- : [t("GitHub does not answer."), t("The catalog's adventures come from GitHub: a .zip or a link can be added all the same.")];
437
- const why = [...new Set([failed.npm, failed.github].filter((one) => one !== undefined))];
438
- return (_jsxs("div", { class: "package-offline", role: "status", children: [_jsx(Icon, { name: "offline" }), _jsxs("div", { children: [_jsxs("p", { children: [_jsx("strong", { children: headline }), " ", line] }), why.map((one) => (_jsx("p", { class: "package-why", children: _jsx("bdi", { children: one }) }, one))), _jsxs("button", { type: "button", class: "button package-button", "aria-disabled": asking, onClick: () => !asking && onRetry(), children: [_jsx(Icon, { name: "update" }), t("Try again")] })] })] }));
439
- }
440
- /**
441
- * A row of the catalog (D-486 (4)): its tile, its title with its kind in All and whose it is, a line of what it is, its facts; then what can be done: add it,
442
- * with "…" when a window will ask the player's yes; update it; download a game system for a new campaign; or where it is already.
443
- */
444
- function CatalogRow({ entry, named, view, state, needs, onAdd, onUpdate }) {
445
- const here = hereState(entry, view);
446
- const asksYes = !entry.verified && entry.code;
447
- // An extension made for another game system than the campaign's says so in the place of Add: it would be refused once downloaded (D-548).
448
- const elsewhere = entry.kind === "extension" && entry.system !== undefined && view.system !== null && foldedText(entry.system) !== foldedText(view.system.name);
449
- const facts = [
450
- entry.author !== undefined && !entry.verified && !entry.code ? t("by {author}", { author: entry.author }) : "",
451
- entry.levels === undefined ? "" : levelsText(entry.levels),
452
- entry.length ?? "",
453
- entry.language === undefined ? "" : languageName(entry.language, pageLanguage()) ?? entry.language,
454
- entry.stars === undefined || entry.stars === 0 ? "" : `★ ${entry.stars}`,
455
- asksYes ? t("has code: asks your yes") : "",
456
- entry.kind === "system" && here === "none" && view.system !== null ? t("for a new campaign: this one stays in {system}", { system: systemNameLabel(view.system.name) }) : "",
457
- ].filter((fact) => fact !== "");
458
- const version = entry.update && entry.installed !== undefined && entry.version !== undefined
459
- ? (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), `${isolated(entry.installed)} ${pageDirection() === "rtl" ? "←" : "→"} ${isolated(entry.version)}`] }))
460
- : entry.version;
461
- const action = (word, label, icon, onClick, accent = false) => (_jsxs("button", { type: "button", class: accent ? "button package-button accent" : "button package-button", "aria-label": label, "aria-disabled": state.busy, onClick: () => !state.busy && onClick(), children: [_jsx(Icon, { name: icon }), word] }));
462
- return (_jsxs(PackageRow, { tile: kindIcon[entry.kind], tone: entry.kind === "adventure" ? "cover" : undefined, name: entryTitle(entry), badges: _jsxs(_Fragment, { children: [named && _jsx("span", { class: "package-kind", children: kindLabel(entry.kind) }), _jsx(Trust, { verified: entry.verified, code: entry.code, author: entry.author })] }), about: entry.description === undefined || entry.kind === "adventure" ? entry.description : phraseLabel(entry.description), meta: (version !== undefined || facts.length > 0) && (_jsxs(_Fragment, { children: [version, version !== undefined && facts.length > 0 && " · ", facts.map(isolated).join(" · ")] })), needs: needs, focusable: true, actions: entry.update && entry.kind !== "adventure"
463
- ? action(t("Update"), t("Update {name} to {version}", { name: entryTitle(entry), version: entry.version ?? "" }), "update", onUpdate, true)
464
- : here === "used" || (here === "here" && entry.kind !== "extension")
465
- ? (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), entry.kind === "adventure" || entry.kind === "extension" ? t("In the campaign") : t("On this computer")] }))
466
- : elsewhere && here === "none"
467
- ? (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "lock" }), t("for {system}: this campaign plays {campaign}", { system: entry.system ?? "", campaign: view.system === null ? "" : systemNameLabel(view.system.name) })] }))
468
- : entry.kind === "system" && here === "none"
469
- ? action(t("Download"), t("Download {name}", { name: entryTitle(entry) }), "download", onAdd)
470
- : action(asksYes ? t("Add…") : t("Add"), t("Add {name}", { name: entryTitle(entry) }), "plus", onAdd), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said, onSee: state.onSee })] }));
471
- }
472
- /**
473
- * RPG Engine itself (D-515 (3)), first among the installed: its version and npm's newer one, with Update when npm installed it globally; installed another way,
474
- * why the page does not update it; once updated, how a new chat, or the app opened again, brings it, as the chat and this page go on with this one.
475
- */
476
- function EngineCard({ engine, updated, newer, state, onUpdate }) {
477
- const folder = engine?.folder ?? "";
478
- const why = engine === undefined
479
- ? t("Asking npm for the newest version…")
480
- : engine.install === "link"
481
- ? t("Installed with npm link from {folder}, for its development: update it there, with git pull and npm run build.", { folder })
482
- : engine.install === "other"
483
- ? t("Installed another way, in {folder}: update it the way you installed it.", { folder })
484
- : engine.failed !== undefined
485
- ? t("npm does not answer: a newer version cannot be checked now.")
486
- : undefined;
487
- // A newer one this page does not install is still said, by its version.
488
- const shownNewer = updated === undefined && engine?.update === true ? engine.latest : undefined;
489
- return (_jsxs("section", { class: "card", "aria-labelledby": "packages-engine", children: [_jsx(CardHead, { icon: iconPath("engine"), title: _jsx("h3", { id: "packages-engine", tabIndex: -1, children: t("Engine") }) }), _jsx("div", { class: "card-body package-body", children: _jsx("ul", { class: "package-list", children: _jsxs(PackageRow, { tile: "engine", name: engineName, about: t("What runs the game: the master's tools and this page."), meta: engine !== undefined && _jsx(VersionMeta, { version: engine.version, newer: shownNewer }), needs: why === undefined ? undefined : _jsx("span", { class: "package-needs", children: why }), actions: newer !== undefined
490
- ? _jsx(UpdateButton, { id: "engine-update", name: engineName, version: newer, busy: state.busy, onClick: onUpdate })
491
- : engine?.update === false && engine.install === "global" && updated === undefined && (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), t("Up to date")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said }), updated !== undefined && _jsx(RestartNote, { updated: updated })] }) }) })] }));
492
- }
493
- /**
494
- * The engine installed, and how the master comes to use it, in the player's words: this chat goes on with the one it started with; a new chat, or the app
495
- * opened again, takes the new one, and this page is read again after it, never by itself, as the running game would serve it the new one's files.
496
- */
497
- function RestartNote({ updated }) {
498
- const note = useRef(null);
499
- // Just updated, the focus Update had comes here; kept from before a reload, it stays where the page puts it.
500
- useEffect(() => {
501
- if (updated.now) {
502
- note.current?.focus({ preventScroll: true });
503
- note.current?.scrollIntoView({ block: "nearest" });
504
- }
505
- }, []);
506
- const steps = updated.restart === "app"
507
- ? [t("Quit the app you play in completely, not just its window, then open it again."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")]
508
- : [t("Close this chat."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")];
509
- return (_jsxs("div", { ref: note, class: "package-said package-restart", role: "status", tabIndex: -1, children: [_jsx("p", { children: `✓ ${t("RPG Engine {version} is installed.", { version: updated.to })}` }), _jsx("p", { children: t("The master goes on with {version} in this chat. To play with {next}:", { version: updated.from, next: updated.to }) }), _jsx("ol", { children: steps.map((step) => _jsx("li", { children: step }, step)) })] }));
510
- }
511
- /**
512
- * What a package's latest needs of the engine (D-515 (2)), under its meta: which version of it, and the way to the engine's card, to update it first; the
513
- * version offered meanwhile is the newest this engine reads.
514
- */
515
- function NeedsEngine({ newer, canUpdate, onGo }) {
516
- const { version, engine } = newer;
517
- return (_jsxs("span", { class: "package-needs", children: [_jsx("span", { children: engine === undefined ? t("Version {version} needs a newer RPG Engine.", { version }) : t("Version {version} needs RPG Engine {engine}.", { version, engine }) }), _jsxs("button", { type: "button", class: "package-see", onClick: onGo, children: [canUpdate ? t("Update RPG Engine first") : t("See RPG Engine"), _jsx(Icon, { name: "fold" })] })] }));
518
- }
519
- /**
520
- * A game system here: the campaign's, chosen in its setup and locked; another, for a new campaign, which can go off this computer when npm installed it; npm's
521
- * newer version, to update it.
522
- */
523
- function SystemRow({ system, newer, needs, fresh, state, onUpdate, onUninstall }) {
524
- const target = system.package ?? system.name;
525
- return (_jsxs(PackageRow, { tile: "dice", tone: system.used ? undefined : "dim", name: _jsx("span", { class: "system-chip", children: system.name }), badges: _jsx(Trust, { verified: system.verified, code: system.code }), about: systemTitleLabel(system.title), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: system.version, newer: newer }), _jsx(ReportLink, { issues: system.issues, name: system.name, after: system.version !== undefined || newer !== undefined }), _jsx(OwnPageLinks, { name: system.package })] }), needs: needs, row: `system:${system.name}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: system.name, version: newer, busy: state.busy, onClick: () => onUpdate(target) }), system.used
526
- ? (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("In use · chosen in the setup")] }))
527
- : (_jsxs(_Fragment, { children: [_jsx("span", { class: "package-quiet", children: t("Not in this campaign") }), system.package !== undefined && _jsx(UninstallButton, { name: system.name, busy: state.busy, onClick: () => onUninstall(target) })] }))] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
528
- }
529
- /** An adventure of the campaign: the day it came in on and its version; taken out while the story has not touched it, else part of the story. */
530
- function AdventureRow({ adventure, fresh, state, onTakeOut }) {
531
- const since = adventure.since === undefined ? undefined : sinceDateLabel(adventure.since);
532
- return (_jsxs(PackageRow, { tile: "world", tone: "cover", name: adventure.title, meta: since === undefined ? adventure.version : _jsx("span", { title: gameDateLabel(adventure.since ?? ""), children: `${since} · ${adventure.version}` }), row: `adventure:${adventure.title}`, fresh: fresh, actions: adventure.removable
533
- ? (_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Take {name} out of the campaign…", { name: adventure.title }), "aria-disabled": state.busy, onClick: () => !state.busy && onTakeOut(), children: [_jsx(Icon, { name: "minus" }), t("Take out…")] }))
534
- : (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("Part of the story")] })), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
535
- }
536
- /** An extension here: whose it is, what it is, its version and npm's newer one; whether the campaign uses it, as a switch; one that does not read, in red. */
537
- function ExtensionRow({ extension, newer, needs, fresh, state, onUse, onUpdate, onUninstall }) {
538
- const name = phraseLabel(extension.name);
539
- if ("broken" in extension) {
540
- return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not read: install it again.") }), meta: _jsxs(_Fragment, { children: [_jsx("bdi", { class: "package-why", children: extension.broken }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true })] }), actions: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name} again", { name }), "aria-disabled": state.busy, onClick: () => !state.busy && onUpdate(), children: [_jsx(Icon, { name: "update" }), t("Install it again")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
541
- }
542
- return (_jsxs(PackageRow, { tile: "packages", name: name, badges: _jsx(Trust, { verified: extension.verified, code: false }), about: `${phraseLabel(extension.about.replace(/\.$/, ""))}.`, meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: extension.version, newer: newer }), _jsx(ReportLink, { issues: extension.issues, name: name, after: true }), _jsx(OwnPageLinks, { name: extension.package })] }), needs: needs, row: `extension:${extension.package}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsxs("label", { class: "package-use", children: [_jsx("input", { type: "checkbox", role: "switch", checked: extension.used, "aria-label": t("{name}: in use", { name }), "aria-disabled": state.busy, onClick: (event) => {
543
- event.preventDefault();
544
- if (!state.busy) {
545
- onUse(!extension.used);
546
- }
547
- } }), t("In use")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
548
- }
549
- /** An extension the campaign lists and this computer lacks: in red, with Install. */
550
- function MissingRow({ name, state, onInstall }) {
551
- const shown = phraseLabel(name.replace(/^@[^/]+\//, ""));
552
- return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: shown, about: _jsx("span", { class: "package-red", children: t("Missing on this computer: the master does not use it until you install it.") }), actions: _jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name}", { name: shown }), "aria-disabled": state.busy, onClick: () => !state.busy && onInstall(), children: [_jsx(Icon, { name: "download" }), t("Install")] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
553
- }
554
- /** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
555
- function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
556
- const page = pageLanguage().toLowerCase().split("-")[0] === language.code.toLowerCase().split("-")[0];
557
- const name = languageTitle(language);
558
- return (_jsxs(PackageRow, { tile: "language", name: name, badges: _jsx(Trust, { verified: language.verified, code: false }), meta: _jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: language.version, newer: newer }), page && ` · ${t("the language of this page")}`, _jsx(ReportLink, { issues: language.issues, name: name, after: true })] }), needs: needs, row: `language:${language.code}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: name, version: newer, busy: state.busy, onClick: onUpdate }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
559
- }
560
- /** A row of the page: the tile, the words, what can be done at the end; under them, the work going on and what happened. */
561
- function PackageRow({ tile, tone, name, badges, about, meta, needs, actions, focusable, row, fresh, children }) {
562
- return (_jsxs("li", { class: fresh ? "package-row fresh" : "package-row", ...(focusable || fresh ? { tabIndex: -1 } : {}), ...(row === undefined ? {} : { "data-row": row }), children: [_jsx("span", { class: tone === undefined ? "package-tile" : `package-tile ${tone}`, "aria-hidden": "true", children: _jsx(Icon, { name: tile }) }), _jsxs("span", { class: "package-text", children: [_jsxs("span", { class: "package-name", children: [_jsx("strong", { class: "package-title", children: name }), badges] }), about !== undefined && about !== "" && _jsx("span", { class: "package-about", children: typeof about === "string" ? _jsx("bdi", { children: about }) : about }), meta !== undefined && meta !== false && _jsx("span", { class: "package-meta", children: meta }), needs] }), actions !== undefined && _jsx("span", { class: "package-actions", children: actions }), children] }));
563
- }
564
- /** Whose a package is: ours, a shield with its tick; someone else's with code, in red with the shield's mark and the word, never the colour alone. */
565
- function Trust({ verified, code, author }) {
566
- if (verified) {
567
- return (_jsxs("span", { class: "package-trust", children: [_jsx(Icon, { name: "verified" }), t("Verified")] }));
568
- }
569
- // Someone else's without code is only text and pictures: who wrote it is said with its facts.
570
- if (!code && author !== undefined) {
571
- return null;
572
- }
573
- return (_jsxs("span", { class: code ? "package-trust risky" : "package-trust", children: [_jsx(Icon, { name: "unverified" }), author === undefined ? t("Someone else's") : t("Someone else's · {author}", { author })] }));
574
- }
575
- /** A version here, and npm's newer one. */
576
- function VersionMeta({ version, newer }) {
577
- return (_jsxs(_Fragment, { children: [version, version !== undefined && newer !== undefined && " · ", newer !== undefined && (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), t("new {version}", { version: newer })] }))] }));
578
- }
579
- /** Where the package's problems are reported, as its package.json says: after what its meta says before it, on a line of its own on a phone; nothing when it says nowhere. */
580
- export function ReportLink({ issues, name, after }) {
581
- if (issues === undefined) {
582
- return null;
583
- }
584
- return (_jsxs(_Fragment, { children: [after && _jsx("span", { class: "package-report-gap", children: " · " }), _jsx("a", { class: "package-report", href: issues, target: "_blank", rel: "noreferrer", "aria-label": t("Report a problem with {name}", { name }), children: t("Report a problem") })] }));
585
- }
586
- /** Update, for a row npm has a newer version of. */
587
- function UpdateButton({ id, name, version, busy, onClick }) {
588
- return (_jsxs("button", { type: "button", id: id, class: "button package-button accent", "aria-label": t("Update {name} to {version}", { name, version }), "aria-disabled": busy, onClick: () => !busy && onClick(), children: [_jsx(Icon, { name: "update" }), t("Update")] }));
589
- }
590
- /** The bin that takes a package off this computer, after asking. */
591
- function UninstallButton({ name, busy, onClick }) {
592
- return (_jsx("button", { type: "button", class: "icon-button package-bin tip-left", "aria-label": t("Uninstall {name} from this computer…", { name }), "data-tip": t("Uninstall from this computer…"), "aria-disabled": busy, onClick: () => !busy && onClick(), children: _jsx(Icon, { name: "clear" }) }));
593
- }
594
- /** The work under way here: a bar and what is done, or the window where the player's yes is asked, which may hide behind the browser (D-478). */
595
- function WorkNote({ work, whose }) {
596
- if (work === undefined) {
597
- return null;
598
- }
599
- // Said in the tab other than its row's: with whose work it is.
600
- const named = whose === undefined ? null : _jsx("span", { class: "package-whose", children: whose });
601
- if (work.phase === "yes") {
602
- return (_jsxs("div", { class: "package-window", role: "status", children: [_jsx(Icon, { name: "window" }), _jsxs("span", { children: [named, _jsx("strong", { children: t("Answer in the window of your computer.") }), " ", work.action === "library"
603
- ? t("It asks whether RPG Engine may read the documents of that folder. Can't see it? It is behind the browser.")
604
- : t("It asks whether code that RPG Engine did not publish may run here. Can't see it? It is behind the browser.")] })] }));
605
- }
606
- return (_jsxs("div", { class: "package-progress", role: "status", children: [_jsx("span", { class: "package-bar", "aria-hidden": "true" }), _jsxs("span", { children: [named, _jsx("strong", { children: workingText(work.action) }), " ", t("You can go to another page: it goes on by itself.")] })] }));
607
- }
608
- /** What happened, where it happened: the page's words, the engine's under them, and the terminal's command when no window opens here. */
609
- function SaidNote({ said, focus, onSee }) {
610
- const note = useRef(null);
611
- useEffect(() => {
612
- if (focus && said !== undefined) {
613
- note.current?.focus({ preventScroll: true });
614
- note.current?.scrollIntoView({ block: "nearest" });
615
- }
616
- }, [said, focus]);
617
- return said === undefined ? null : (_jsxs("div", { ref: note, class: said.problem ? "package-said problem" : "package-said", role: "status", ...(focus ? { tabIndex: -1 } : {}), children: [_jsx("p", { children: said.text }), said.why !== undefined && (_jsx("p", { class: "package-why", children: _jsx("bdi", { children: said.why }) })), said.command !== undefined && _jsx(Command, { text: said.command }), said.added !== undefined && onSee !== undefined && (_jsxs("button", { type: "button", class: "package-see", onClick: () => said.added !== undefined && onSee(said.added), children: [t("See it in Installed"), _jsx(Icon, { name: "fold" })] }))] }));
618
- }
619
- /** What happened to a row that went from its card: said at the card's foot, with the focus, which the row's button had. */
620
- function CardSaid({ said, at }) {
621
- return said?.at === at ? _jsx(SaidNote, { said: said, focus: true }) : null;
622
- }
623
- /**
624
- * The campaign shared as an adventure (D-483), the last row of Adventures (D-486): Export… opens who wrote it and its licence, each optional, and whose it is
625
- * to share; then the link to download it.
626
- */
627
- function ShareCampaign() {
628
- const [open, setOpen] = useState(false);
629
- const [author, setAuthor] = useState("");
630
- const [license, setLicense] = useState("");
631
- const [exporting, setExporting] = useState(false);
632
- const [made, setMade] = useState();
633
- const ready = useRef(null);
634
- const first = useRef(null);
635
- useEffect(() => {
636
- if (made !== undefined && "download" in made) {
637
- ready.current?.focus();
638
- }
639
- }, [made]);
640
- // The button stays where the focus is while the export goes: a second press waits for the first.
641
- const share = async () => {
642
- if (exporting) {
643
- return;
644
- }
645
- setExporting(true);
646
- setMade(undefined);
647
- const credits = { ...(author.trim() === "" ? {} : { author: author.trim() }), ...(license.trim() === "" ? {} : { license: license.trim() }) };
648
- setMade(await exportCampaign(credits));
649
- setExporting(false);
650
- };
651
- return (_jsxs("div", { class: "package-export", children: [_jsx("span", { class: "package-tile plain", "aria-hidden": "true", children: _jsx(Icon, { name: "share" }) }), _jsxs("span", { class: "package-text", children: [_jsx("strong", { class: "package-title", id: "package-export-title", children: t("This campaign, as an adventure") }), _jsx("span", { class: "package-about", children: t("The world as it was at the start, without the player characters: a .zip to give to others.") })] }), _jsx("span", { class: "package-actions", children: _jsxs("button", { type: "button", class: "button package-button", "aria-expanded": open, "aria-controls": "package-credits", onClick: () => {
652
- setOpen(!open);
653
- if (!open) {
654
- requestAnimationFrame(() => first.current?.focus());
655
- }
656
- }, children: [_jsx(Icon, { name: "share" }), t("Export…")] }) }), open && (_jsxs("form", { class: "package-credits", id: "package-credits", "aria-labelledby": "package-export-title", onSubmit: (event) => {
657
- event.preventDefault();
658
- void share();
659
- }, children: [_jsxs("label", { children: [_jsx("span", { children: t("Author") }), _jsx("input", { ref: first, type: "text", value: author, maxLength: 200, placeholder: t("Optional"), autocomplete: "name", onInput: (event) => setAuthor(event.currentTarget.value) })] }), _jsxs("label", { children: [_jsx("span", { children: t("Licence") }), _jsx("input", { type: "text", value: license, maxLength: 200, list: "package-licences", placeholder: t("Optional"), "aria-describedby": "package-license-about", onInput: (event) => setLicense(event.currentTarget.value) })] }), _jsxs("datalist", { id: "package-licences", children: [_jsx("option", { value: "CC BY 4.0" }), _jsx("option", { value: "CC BY-SA 4.0" }), _jsx("option", { value: "CC0 1.0" })] }), _jsx("p", { class: "package-why", id: "package-license-about", children: t("Without a licence, all rights are reserved.") }), _jsxs("p", { class: "package-rights", children: [_jsx(Icon, { name: "licence" }), t("Share it only if you have the right to: a world taken from a book or from someone else's adventure is not yours to give.")] }), _jsxs("button", { type: "submit", class: "button package-button", "aria-disabled": exporting, children: [_jsx(Icon, { name: "share" }), exporting ? t("Exporting…") : t("Export")] }), made !== undefined && "download" in made && (_jsxs("p", { class: "package-said package-ready", role: "status", children: [_jsx("span", { children: `✓ ${t("{file} is ready.", { file: made.file })}` }), _jsxs("a", { ref: ready, class: "button gold package-button", href: made.download, download: made.file, children: [_jsx(Icon, { name: "download" }), t("Download")] })] })), made !== undefined && "error" in made && _jsx("p", { class: "package-said problem", role: "status", children: made.error })] }))] }));
660
- }
661
- // The kinds in the order of the chips, each with its tile.
662
- const kindOrder = ["system", "adventure", "extension", "language"];
663
- const kindIcon = { system: "dice", adventure: "world", extension: "packages", language: "language" };
664
- /** A kind, for one package. */
665
- function kindLabel(kind) {
666
- const labels = { system: t("System"), adventure: t("Adventure"), extension: t("Extension"), language: t("Language") };
667
- return labels[kind];
668
- }
669
- /** A kind, for its chip. */
670
- function kindsLabel(kind) {
671
- const labels = { system: t("Systems"), adventure: t("Adventures"), extension: t("Extensions"), language: t("Languages") };
672
- return labels[kind];
673
- }
674
- /** Whether an entry matches what the player searched: by its title, what it is or who wrote it, case and accents aside. */
675
- function matchesQuery(entry, query) {
676
- const wanted = foldedText(query.trim());
677
- return wanted === "" || [entry.title, entry.description ?? "", entry.author ?? ""].some((text) => foldedText(text).includes(wanted));
678
- }
679
- /** Where a catalog's package is here: in the campaign, only on this computer, or not here. */
680
- function hereState(entry, view) {
681
- if (entry.installed === undefined) {
682
- return "none";
683
- }
684
- if (entry.kind === "adventure") {
685
- return "used";
686
- }
687
- if (entry.kind !== "extension") {
688
- return "here";
689
- }
690
- const extension = view.installed.find((one) => samePackage(entry, one.package));
691
- return extension !== undefined && !("broken" in extension) && extension.used ? "used" : "here";
692
- }
693
- /** Whether a catalog's entry is this package: ours by its name alone, another's by its npm name. */
694
- function samePackage(entry, name) {
695
- const source = entry.source.replace(/^npm:/, "");
696
- return name === source || name === `@rpgengine/${source}`;
697
- }
698
- /** npm's newer version of a package here, as the catalog says it. */
699
- function newerOf(name, kind, catalog) {
700
- const entry = entryOf(name, kind, catalog);
701
- return entry?.update === true ? entry.version : undefined;
702
- }
703
- /** A package here as the catalog has it. */
704
- function entryOf(name, kind, catalog) {
705
- return catalog?.entries.find((one) => one.kind === kind && samePackage(one, name));
706
- }
707
- /** How many packages here npm has a newer version of: the count on the Installed tab. */
708
- function updateCount(view, catalog) {
709
- const systems = (view.systems ?? []).filter((one) => one.package !== undefined && newerOf(one.package, "system", catalog) !== undefined);
710
- const extensions = view.installed.filter((one) => newerOf(one.package, "extension", catalog) !== undefined);
711
- const languages = (view.languages ?? []).filter((one) => newerOf(one.package, "language", catalog) !== undefined);
712
- return systems.length + extensions.length + languages.length;
713
- }
714
232
  /** The rows among the installed by their keys, as the page names where a change was made. */
715
233
  function rowKeys(view) {
716
234
  return [
@@ -762,77 +280,3 @@ function workPlace(work, view, catalog) {
762
280
  ? `catalog:${entry.source}`
763
281
  : "add";
764
282
  }
765
- /** What went wrong, in the page's words, with the engine's under them: the no, a computer with no window for the yes, the work of another package. */
766
- function failure(at, action, name, outcome) {
767
- if (outcome.code === "declined") {
768
- return { at, problem: true, text: t("You said no: nothing changed.") };
769
- }
770
- if (outcome.code === "no-window") {
771
- const command = action === "library" ? `rpg config library --add "${name}"` : `rpg package install ${/\s/.test(name) ? `"${name}"` : name}`;
772
- return { at, problem: true, text: t("No window for your yes opens on this computer: add it from your terminal, in the campaign's folder."), command };
773
- }
774
- if (outcome.code === "busy") {
775
- return { at, problem: true, text: action === "library" ? t("One change at a time: wait for the one under way, then try again.") : t("One package at a time: wait for the one under way, then try again.") };
776
- }
777
- return { at, problem: true, text: action === "add" ? t("Nothing was added.") : t("Nothing changed."), why: outcome.error };
778
- }
779
- /** What an addition did, by the kind the engine recognized. */
780
- function addedText(kind) {
781
- const texts = {
782
- adventure: t("The adventure is in the campaign: the master brings it into the story when you want it."),
783
- extension: t("The extension is in the campaign: it counts from now on."),
784
- system: t("The game system is on this computer, for a new campaign."),
785
- language: t("The language is on this computer, for every campaign."),
786
- };
787
- return kind === undefined ? t("Done.") : texts[kind];
788
- }
789
- /** What a change did, once done. */
790
- function doneText(action, name) {
791
- const texts = {
792
- update: t("{name} is updated.", { name }),
793
- remove: t("{name} is out of the campaign: it stays on this computer.", { name }),
794
- uninstall: t("{name} is off this computer.", { name }),
795
- };
796
- return texts[action];
797
- }
798
- /** What the server is doing, in words. */
799
- function workingText(action) {
800
- const texts = {
801
- add: t("Adding…"),
802
- update: t("Updating…"),
803
- remove: t("Taking it out of the campaign…"),
804
- uninstall: t("Uninstalling…"),
805
- library: t("Changing the library…"),
806
- engine: t("Updating RPG Engine…"),
807
- };
808
- return texts[action];
809
- }
810
- /** What uninstalling does, by kind. */
811
- function uninstallText(what) {
812
- if (what === "system") {
813
- return _jsx("p", { children: t("It goes off this computer: a new campaign can no longer choose it. This campaign does not change.") });
814
- }
815
- if (what === "language") {
816
- return _jsx("p", { children: t("It goes off this computer: the dashboard goes back to its own words in this language.") });
817
- }
818
- return (_jsxs(_Fragment, { children: [_jsx("p", { children: t("It goes off this computer, and out of this campaign. Another campaign that uses it asks to install it again.") }), _jsx("p", { class: "confirm-note", children: t("What it wrote in the campaign stays, and comes back if you install it again.") })] }));
819
- }
820
- /** An adventure's levels: one, or from one to another. */
821
- function levelsText(levels) {
822
- return levels.includes("-") ? t("levels {levels}", { levels: levels.replace("-", "–") }) : t("level {level}", { level: levels });
823
- }
824
- /** A language package's name in the page's language, else its own. */
825
- function languageTitle(language) {
826
- return phraseLabel(languageName(language.code, pageLanguage()) ?? language.name);
827
- }
828
- /** A catalog's title: an adventure's as its author wrote it; an npm package's name with its first letter a capital, as the rows of what is here. */
829
- function entryTitle(entry) {
830
- // A language by its code, as lang-de: named in the page's language.
831
- const code = entry.kind === "language" ? /^(?:lang-)?([a-z]{2,3}(?:-[a-z0-9]+)?)$/i.exec(entry.title)?.[1] : undefined;
832
- const language = code === undefined ? undefined : languageName(code, pageLanguage());
833
- return entry.kind === "adventure" ? entry.title : phraseLabel(language ?? entry.title);
834
- }
835
- /** The language this page is written in. */
836
- function pageLanguage() {
837
- return pageLocale();
838
- }