rpg-engine 0.14.1 → 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 (493) hide show
  1. package/dist/campaign/index.d.ts +1 -1
  2. package/dist/campaign/index.js +1 -1
  3. package/dist/campaign/last-choices.js +1 -1
  4. package/dist/campaign/settings.d.ts +25 -5
  5. package/dist/campaign/settings.js +38 -9
  6. package/dist/cli/cli.js +1 -1
  7. package/dist/cli/command-line.js +1 -1
  8. package/dist/commands/advance.d.ts +1 -1
  9. package/dist/commands/advance.js +6 -6
  10. package/dist/commands/ask.js +7 -7
  11. package/dist/commands/change/amounts.d.ts +32 -0
  12. package/dist/commands/change/amounts.js +150 -0
  13. package/dist/commands/change/change.d.ts +4 -54
  14. package/dist/commands/change/change.js +19 -749
  15. package/dist/commands/change/damage.d.ts +30 -0
  16. package/dist/commands/change/damage.js +73 -2
  17. package/dist/commands/change/dice.d.ts +34 -0
  18. package/dist/commands/change/dice.js +59 -0
  19. package/dist/commands/change/fields.d.ts +37 -0
  20. package/dist/commands/change/fields.js +156 -0
  21. package/dist/commands/change/holder.d.ts +48 -0
  22. package/dist/commands/change/holder.js +162 -0
  23. package/dist/commands/change/recipe-pace.js +1 -1
  24. package/dist/commands/change/recipe.d.ts +58 -0
  25. package/dist/commands/change/recipe.js +179 -0
  26. package/dist/commands/choices.js +3 -3
  27. package/dist/commands/config/config.d.ts +15 -0
  28. package/dist/commands/config/config.js +355 -0
  29. package/dist/commands/config/custom-levels.d.ts +7 -0
  30. package/dist/commands/config/custom-levels.js +32 -0
  31. package/dist/commands/{config.d.ts → config/dashboard.d.ts} +4 -26
  32. package/dist/commands/config/dashboard.js +171 -0
  33. package/dist/commands/config/entries.d.ts +17 -0
  34. package/dist/commands/config/entries.js +76 -0
  35. package/dist/commands/config/news.d.ts +7 -0
  36. package/dist/commands/config/news.js +88 -0
  37. package/dist/commands/config/shown.d.ts +9 -0
  38. package/dist/commands/config/shown.js +80 -0
  39. package/dist/commands/config/words.d.ts +27 -0
  40. package/dist/commands/config/words.js +204 -0
  41. package/dist/commands/effect.js +9 -9
  42. package/dist/commands/find.d.ts +4 -4
  43. package/dist/commands/find.js +1 -1
  44. package/dist/commands/image.js +6 -6
  45. package/dist/commands/import/import.d.ts +0 -2
  46. package/dist/commands/import/import.js +45 -44
  47. package/dist/commands/import/run.js +1 -1
  48. package/dist/commands/index.js +3 -3
  49. package/dist/commands/init.js +2 -2
  50. package/dist/commands/install.js +1 -1
  51. package/dist/commands/instructions.js +17 -6
  52. package/dist/commands/mode.d.ts +2 -2
  53. package/dist/commands/mode.js +17 -9
  54. package/dist/commands/mood.js +4 -4
  55. package/dist/commands/move.js +10 -10
  56. package/dist/commands/package/consent.d.ts +11 -0
  57. package/dist/commands/package/consent.js +52 -0
  58. package/dist/commands/package/here.d.ts +51 -0
  59. package/dist/commands/package/here.js +128 -0
  60. package/dist/commands/package/install.d.ts +10 -0
  61. package/dist/commands/package/install.js +337 -0
  62. package/dist/commands/package/package.d.ts +18 -0
  63. package/dist/commands/package/package.js +236 -0
  64. package/dist/commands/package/result.d.ts +90 -0
  65. package/dist/commands/package/result.js +1 -0
  66. package/dist/commands/package/uninstall.d.ts +6 -0
  67. package/dist/commands/package/uninstall.js +70 -0
  68. package/dist/commands/rename.js +3 -3
  69. package/dist/commands/reveal.js +5 -5
  70. package/dist/commands/roll/roll.js +11 -9
  71. package/dist/commands/roll/tables.js +1 -1
  72. package/dist/commands/rules.d.ts +2 -2
  73. package/dist/commands/rules.js +3 -3
  74. package/dist/commands/save.d.ts +1 -1
  75. package/dist/commands/save.js +2 -2
  76. package/dist/commands/scene/close.d.ts +18 -0
  77. package/dist/commands/scene/close.js +179 -0
  78. package/dist/commands/scene/members.d.ts +14 -0
  79. package/dist/commands/scene/members.js +32 -0
  80. package/dist/commands/scene/open.d.ts +6 -0
  81. package/dist/commands/scene/open.js +298 -0
  82. package/dist/commands/scene/result.d.ts +98 -0
  83. package/dist/commands/scene/result.js +2 -0
  84. package/dist/commands/{scene.d.ts → scene/scene.d.ts} +10 -36
  85. package/dist/commands/scene/scene.js +210 -0
  86. package/dist/commands/scene/turns.d.ts +18 -0
  87. package/dist/commands/scene/turns.js +229 -0
  88. package/dist/commands/shared/{adventures.d.ts → books/adventures.d.ts} +5 -3
  89. package/dist/commands/shared/{adventures.js → books/adventures.js} +23 -19
  90. package/dist/commands/shared/{library-reader.js → books/library-reader.js} +3 -3
  91. package/dist/commands/shared/{library.d.ts → books/library.d.ts} +2 -2
  92. package/dist/commands/shared/{library.js → books/library.js} +9 -9
  93. package/dist/commands/shared/{rules.d.ts → books/rules.d.ts} +2 -2
  94. package/dist/commands/shared/{rules.js → books/rules.js} +5 -5
  95. package/dist/commands/shared/{system-texts.d.ts → books/system-texts.d.ts} +2 -2
  96. package/dist/commands/shared/{system-texts.js → books/system-texts.js} +9 -8
  97. package/dist/commands/shared/{page-words.d.ts → books/words.d.ts} +2 -2
  98. package/dist/commands/shared/{page-words.js → books/words.js} +4 -4
  99. package/dist/commands/shared/{checks.d.ts → campaign/checks.d.ts} +3 -3
  100. package/dist/commands/shared/{checks.js → campaign/checks.js} +7 -7
  101. package/dist/commands/shared/{images.d.ts → campaign/images.d.ts} +3 -3
  102. package/dist/commands/shared/{images.js → campaign/images.js} +5 -5
  103. package/dist/commands/shared/{mode.d.ts → campaign/mode.d.ts} +4 -4
  104. package/dist/commands/shared/{mode.js → campaign/mode.js} +28 -13
  105. package/dist/commands/shared/{money.d.ts → campaign/money.d.ts} +3 -3
  106. package/dist/commands/shared/{money.js → campaign/money.js} +2 -2
  107. package/dist/commands/shared/{offers.d.ts → campaign/offers.d.ts} +3 -3
  108. package/dist/commands/shared/{offers.js → campaign/offers.js} +3 -3
  109. package/dist/commands/shared/{outside.d.ts → campaign/outside.d.ts} +3 -3
  110. package/dist/commands/shared/{outside.js → campaign/outside.js} +7 -7
  111. package/dist/commands/shared/{parts.d.ts → campaign/parts.d.ts} +10 -3
  112. package/dist/commands/shared/{parts.js → campaign/parts.js} +26 -3
  113. package/dist/commands/shared/{problems.d.ts → campaign/problems.d.ts} +3 -3
  114. package/dist/commands/shared/{problems.js → campaign/problems.js} +17 -17
  115. package/dist/commands/shared/{quests.d.ts → campaign/quests.d.ts} +4 -4
  116. package/dist/commands/shared/{quests.js → campaign/quests.js} +6 -6
  117. package/dist/commands/shared/{saves.d.ts → campaign/saves.d.ts} +4 -4
  118. package/dist/commands/shared/{saves.js → campaign/saves.js} +10 -10
  119. package/dist/commands/shared/{theme.d.ts → campaign/theme.d.ts} +3 -3
  120. package/dist/commands/shared/{theme.js → campaign/theme.js} +1 -1
  121. package/dist/commands/shared/{world.d.ts → campaign/world.d.ts} +5 -5
  122. package/dist/commands/shared/{world.js → campaign/world.js} +17 -14
  123. package/dist/commands/shared/{knowledge.d.ts → characters/knowledge.d.ts} +3 -3
  124. package/dist/commands/shared/{knowledge.js → characters/knowledge.js} +4 -4
  125. package/dist/commands/shared/{moods.d.ts → characters/moods.d.ts} +3 -3
  126. package/dist/commands/shared/{moods.js → characters/moods.js} +3 -3
  127. package/dist/commands/shared/characters/orders.d.ts +4 -0
  128. package/dist/commands/shared/characters/orders.js +10 -0
  129. package/dist/commands/shared/{thoughts.d.ts → characters/thoughts.d.ts} +2 -2
  130. package/dist/commands/shared/{thoughts.js → characters/thoughts.js} +3 -3
  131. package/dist/commands/shared/{voices.d.ts → characters/voices.d.ts} +1 -1
  132. package/dist/commands/shared/{voices.js → characters/voices.js} +2 -2
  133. package/dist/commands/shared/examples.js +2 -2
  134. package/dist/commands/shared/packages/catalog.js +2 -2
  135. package/dist/commands/shared/packages/code.d.ts +1 -1
  136. package/dist/commands/shared/packages/code.js +8 -8
  137. package/dist/commands/shared/packages/extensions.d.ts +1 -1
  138. package/dist/commands/shared/packages/extensions.js +1 -1
  139. package/dist/commands/shared/packages/hooks.d.ts +1 -1
  140. package/dist/commands/shared/packages/hooks.js +1 -1
  141. package/dist/commands/shared/packages/widgets.d.ts +3 -3
  142. package/dist/commands/shared/packages/widgets.js +3 -3
  143. package/dist/commands/shared/{environment.d.ts → places/environment.d.ts} +1 -1
  144. package/dist/commands/shared/{environment.js → places/environment.js} +4 -4
  145. package/dist/commands/shared/{grid-moves.d.ts → places/grid-moves.d.ts} +4 -4
  146. package/dist/commands/shared/{grid-moves.js → places/grid-moves.js} +8 -7
  147. package/dist/commands/shared/{grids.d.ts → places/grids.d.ts} +4 -4
  148. package/dist/commands/shared/{grids.js → places/grids.js} +6 -6
  149. package/dist/commands/shared/{journey.d.ts → places/journey.d.ts} +3 -3
  150. package/dist/commands/shared/{journey.js → places/journey.js} +6 -6
  151. package/dist/commands/shared/{moves.d.ts → places/moves.d.ts} +2 -2
  152. package/dist/commands/shared/{moves.js → places/moves.js} +4 -4
  153. package/dist/commands/shared/{positions.d.ts → places/positions.d.ts} +2 -2
  154. package/dist/commands/shared/{positions.js → places/positions.js} +4 -4
  155. package/dist/commands/shared/{roads.d.ts → places/roads.d.ts} +5 -5
  156. package/dist/commands/shared/{roads.js → places/roads.js} +6 -6
  157. package/dist/commands/shared/{effects.d.ts → scene/effects.d.ts} +7 -7
  158. package/dist/commands/shared/{effects.js → scene/effects.js} +10 -10
  159. package/dist/commands/shared/{loot.d.ts → scene/loot.d.ts} +2 -2
  160. package/dist/commands/shared/{loot.js → scene/loot.js} +3 -3
  161. package/dist/commands/shared/{master-rolls.d.ts → scene/master-rolls.d.ts} +2 -2
  162. package/dist/commands/shared/{master-rolls.js → scene/master-rolls.js} +5 -5
  163. package/dist/commands/shared/{reminders.d.ts → scene/reminders.d.ts} +4 -4
  164. package/dist/commands/shared/{reminders.js → scene/reminders.js} +4 -4
  165. package/dist/commands/shared/{scene.d.ts → scene/scene.d.ts} +3 -3
  166. package/dist/commands/shared/{scene.js → scene/scene.js} +7 -7
  167. package/dist/commands/shared/{bonds.d.ts → sheet/bonds.d.ts} +3 -3
  168. package/dist/commands/shared/{bonds.js → sheet/bonds.js} +2 -2
  169. package/dist/commands/shared/{page-counters.d.ts → sheet/counters.d.ts} +3 -3
  170. package/dist/commands/shared/{page-counters.js → sheet/counters.js} +5 -5
  171. package/dist/commands/shared/{effect-layer.d.ts → sheet/effect-layer.d.ts} +2 -2
  172. package/dist/commands/shared/{effect-layer.js → sheet/effect-layer.js} +9 -6
  173. package/dist/commands/shared/sheet/effect-values.d.ts +9 -0
  174. package/dist/commands/shared/sheet/effect-values.js +69 -0
  175. package/dist/commands/shared/{experience.d.ts → sheet/experience.d.ts} +3 -3
  176. package/dist/commands/shared/{experience.js → sheet/experience.js} +5 -5
  177. package/dist/commands/shared/sheet/formula-problems.d.ts +8 -0
  178. package/dist/commands/shared/sheet/formula-problems.js +140 -0
  179. package/dist/commands/shared/sheet/formula-scope.d.ts +32 -0
  180. package/dist/commands/shared/sheet/formula-scope.js +235 -0
  181. package/dist/commands/shared/{limits.d.ts → sheet/limits.d.ts} +3 -3
  182. package/dist/commands/shared/{limits.js → sheet/limits.js} +5 -4
  183. package/dist/commands/shared/{progression.d.ts → sheet/progression.d.ts} +2 -2
  184. package/dist/commands/shared/{progression.js → sheet/progression.js} +4 -4
  185. package/dist/commands/shared/{sheet.d.ts → sheet/sheet.d.ts} +5 -5
  186. package/dist/commands/shared/{sheet.js → sheet/sheet.js} +11 -7
  187. package/dist/commands/shared/{stacks.d.ts → sheet/stacks.d.ts} +2 -2
  188. package/dist/commands/shared/{stacks.js → sheet/stacks.js} +4 -4
  189. package/dist/commands/shared/sheet/system-fields.d.ts +21 -0
  190. package/dist/commands/shared/sheet/system-fields.js +45 -0
  191. package/dist/commands/shared/{thresholds.d.ts → sheet/thresholds.d.ts} +1 -1
  192. package/dist/commands/shared/{thresholds.js → sheet/thresholds.js} +4 -4
  193. package/dist/commands/shared/{turn-uses.d.ts → sheet/turn-uses.d.ts} +3 -3
  194. package/dist/commands/shared/{turn-uses.js → sheet/turn-uses.js} +4 -3
  195. package/dist/commands/shared/{worked-out.d.ts → sheet/worked-out.d.ts} +11 -46
  196. package/dist/commands/shared/sheet/worked-out.js +291 -0
  197. package/dist/commands/shared/sheet/worked-text.d.ts +14 -0
  198. package/dist/commands/shared/sheet/worked-text.js +55 -0
  199. package/dist/commands/shared/{advance.d.ts → time/advance.d.ts} +3 -3
  200. package/dist/commands/shared/{advance.js → time/advance.js} +11 -11
  201. package/dist/commands/shared/{dice-pool.d.ts → time/dice-pool.d.ts} +3 -3
  202. package/dist/commands/shared/{dice-pool.js → time/dice-pool.js} +11 -11
  203. package/dist/commands/shared/{events.d.ts → time/events.d.ts} +5 -5
  204. package/dist/commands/shared/{events.js → time/events.js} +10 -13
  205. package/dist/commands/shared/{recipes.d.ts → time/recipes.d.ts} +3 -3
  206. package/dist/commands/shared/{recipes.js → time/recipes.js} +6 -5
  207. package/dist/commands/shared/{time.d.ts → time/time.d.ts} +4 -4
  208. package/dist/commands/shared/{time.js → time/time.js} +6 -6
  209. package/dist/commands/shared/{upkeep.d.ts → time/upkeep.d.ts} +3 -3
  210. package/dist/commands/shared/{upkeep.js → time/upkeep.js} +14 -13
  211. package/dist/commands/show.d.ts +4 -1
  212. package/dist/commands/show.js +28 -9
  213. package/dist/commands/status.d.ts +2 -1
  214. package/dist/commands/status.js +34 -23
  215. package/dist/commands/thoughts.js +3 -3
  216. package/dist/commands/trade.js +8 -8
  217. package/dist/commands/translate.d.ts +1 -1
  218. package/dist/commands/translate.js +3 -3
  219. package/dist/commands/travel/open.d.ts +1 -1
  220. package/dist/commands/travel/open.js +2 -2
  221. package/dist/commands/travel/route.js +7 -6
  222. package/dist/commands/travel/travel.d.ts +1 -1
  223. package/dist/commands/travel/travel.js +8 -8
  224. package/dist/commands/validate.js +3 -3
  225. package/dist/commands/view/journal.d.ts +2 -2
  226. package/dist/commands/view/journal.js +2 -2
  227. package/dist/commands/view/map.d.ts +1 -1
  228. package/dist/commands/view/map.js +6 -6
  229. package/dist/commands/view/memory.d.ts +16 -0
  230. package/dist/commands/view/memory.js +90 -0
  231. package/dist/commands/view/page.d.ts +32 -0
  232. package/dist/commands/view/page.js +163 -0
  233. package/dist/commands/view/place.d.ts +7 -2
  234. package/dist/commands/view/place.js +30 -12
  235. package/dist/commands/view/result.d.ts +245 -0
  236. package/dist/commands/view/result.js +1 -0
  237. package/dist/commands/view/saves.d.ts +6 -0
  238. package/dist/commands/view/saves.js +53 -0
  239. package/dist/commands/view/story.d.ts +32 -0
  240. package/dist/commands/view/story.js +227 -0
  241. package/dist/commands/view/view.d.ts +26 -292
  242. package/dist/commands/view/view.js +26 -534
  243. package/dist/commands/view/world.d.ts +1 -1
  244. package/dist/commands/view/world.js +3 -3
  245. package/dist/commands/write/checks.d.ts +42 -0
  246. package/dist/commands/write/checks.js +291 -0
  247. package/dist/commands/write/here.d.ts +1 -1
  248. package/dist/commands/write/here.js +5 -5
  249. package/dist/commands/write/inheritance.d.ts +40 -0
  250. package/dist/commands/write/inheritance.js +189 -0
  251. package/dist/commands/write/input.d.ts +29 -0
  252. package/dist/commands/write/input.js +124 -0
  253. package/dist/commands/write/layer.d.ts +36 -0
  254. package/dist/commands/write/layer.js +48 -0
  255. package/dist/commands/write/notes.d.ts +22 -0
  256. package/dist/commands/write/notes.js +76 -0
  257. package/dist/commands/write/progression.d.ts +27 -0
  258. package/dist/commands/write/progression.js +175 -0
  259. package/dist/commands/write/write.d.ts +2 -1
  260. package/dist/commands/write/write.js +33 -817
  261. package/dist/core/files.d.ts +2 -0
  262. package/dist/core/files.js +7 -0
  263. package/dist/core/{package-declarations.d.ts → packages/declarations.d.ts} +1 -1
  264. package/dist/core/{package-declarations.js → packages/declarations.js} +1 -1
  265. package/dist/core/session-store.js +3 -3
  266. package/dist/core/store.d.ts +2 -2
  267. package/dist/core/store.js +18 -4
  268. package/dist/dashboard/acts/acts.js +1 -1
  269. package/dist/dashboard/acts/sending.js +110 -0
  270. package/dist/dashboard/acts/sheet.js +2 -2
  271. package/dist/dashboard/acts/strip.js +1 -1
  272. package/dist/dashboard/address.js +6 -0
  273. package/dist/dashboard/api.js +1 -1
  274. package/dist/dashboard/app.js +47 -171
  275. package/dist/dashboard/dice/roller.js +1 -1
  276. package/dist/dashboard/dice/sets.js +2 -2
  277. package/dist/dashboard/dice/stage.js +1 -1
  278. package/dist/dashboard/dice/tray.js +6 -6
  279. package/dist/dashboard/guide/ar.md +9 -4
  280. package/dist/dashboard/guide/cs.md +10 -5
  281. package/dist/dashboard/guide/da.md +9 -4
  282. package/dist/dashboard/guide/de.md +9 -4
  283. package/dist/dashboard/guide/el.md +10 -5
  284. package/dist/dashboard/guide/en.md +7 -2
  285. package/dist/dashboard/guide/es.md +9 -4
  286. package/dist/dashboard/guide/fi.md +9 -4
  287. package/dist/dashboard/guide/fr.md +9 -4
  288. package/dist/dashboard/guide/he.md +9 -4
  289. package/dist/dashboard/guide/hi.md +10 -5
  290. package/dist/dashboard/guide/hu.md +10 -5
  291. package/dist/dashboard/guide/is.md +9 -4
  292. package/dist/dashboard/guide/it.md +9 -4
  293. package/dist/dashboard/guide/ja.md +12 -7
  294. package/dist/dashboard/guide/ko.md +11 -6
  295. package/dist/dashboard/guide/nb.md +9 -4
  296. package/dist/dashboard/guide/nl.md +10 -5
  297. package/dist/dashboard/guide/pl.md +9 -4
  298. package/dist/dashboard/guide/pt.md +9 -4
  299. package/dist/dashboard/guide/ro.md +9 -4
  300. package/dist/dashboard/guide/ru.md +9 -4
  301. package/dist/dashboard/guide/sv.md +9 -4
  302. package/dist/dashboard/guide/tr.md +11 -6
  303. package/dist/dashboard/guide/uk.md +9 -4
  304. package/dist/dashboard/guide/zh.md +9 -4
  305. package/dist/dashboard/help/help.js +3 -3
  306. package/dist/dashboard/i18n/ar.json +20 -0
  307. package/dist/dashboard/i18n/cs.json +20 -0
  308. package/dist/dashboard/i18n/da.json +20 -0
  309. package/dist/dashboard/i18n/de.json +20 -0
  310. package/dist/dashboard/i18n/el.json +20 -0
  311. package/dist/dashboard/i18n/es.json +20 -0
  312. package/dist/dashboard/i18n/fi.json +20 -0
  313. package/dist/dashboard/i18n/fr.json +20 -0
  314. package/dist/dashboard/i18n/he.json +20 -0
  315. package/dist/dashboard/i18n/hi.json +20 -0
  316. package/dist/dashboard/i18n/hu.json +20 -0
  317. package/dist/dashboard/i18n/is.json +20 -0
  318. package/dist/dashboard/i18n/it.json +20 -0
  319. package/dist/dashboard/i18n/ja.json +21 -1
  320. package/dist/dashboard/i18n/ko.json +20 -0
  321. package/dist/dashboard/i18n/nb.json +20 -0
  322. package/dist/dashboard/i18n/nl.json +20 -0
  323. package/dist/dashboard/i18n/pl.json +20 -0
  324. package/dist/dashboard/i18n/pt.json +20 -0
  325. package/dist/dashboard/i18n/ro.json +20 -0
  326. package/dist/dashboard/i18n/ru.json +20 -0
  327. package/dist/dashboard/i18n/sv.json +20 -0
  328. package/dist/dashboard/i18n/tr.json +20 -0
  329. package/dist/dashboard/i18n/uk.json +20 -0
  330. package/dist/dashboard/i18n/zh.json +20 -0
  331. package/dist/dashboard/{journal.js → journal/journal.js} +16 -16
  332. package/dist/dashboard/{notes.js → journal/notes.js} +4 -4
  333. package/dist/dashboard/kit.js +3 -3
  334. package/dist/dashboard/packages/ask-card.js +3 -3
  335. package/dist/dashboard/packages/catalog.js +196 -0
  336. package/dist/dashboard/packages/engine.js +87 -0
  337. package/dist/dashboard/packages/installed.js +53 -0
  338. package/dist/dashboard/packages/library.js +97 -0
  339. package/dist/dashboard/packages/outcomes.js +45 -0
  340. package/dist/dashboard/packages/packages.js +20 -576
  341. package/dist/dashboard/packages/page-code.js +15 -2
  342. package/dist/dashboard/packages/{package-page.js → page.js} +12 -5
  343. package/dist/dashboard/packages/rows.js +84 -0
  344. package/dist/dashboard/packages/share.js +44 -0
  345. package/dist/dashboard/packages/widgets.js +3 -3
  346. package/dist/dashboard/{card.js → parts/card.js} +1 -1
  347. package/dist/dashboard/{faces.js → parts/faces.js} +5 -5
  348. package/dist/dashboard/{game-words.js → parts/game-words.js} +1 -1
  349. package/dist/dashboard/{icons.js → parts/icons.js} +1 -1
  350. package/dist/dashboard/{labels.js → parts/labels.js} +8 -1
  351. package/dist/dashboard/{map-symbols.js → parts/map-symbols.js} +1 -1
  352. package/dist/dashboard/{markdown.js → parts/markdown.js} +2 -2
  353. package/dist/dashboard/{mood.js → parts/mood.js} +1 -1
  354. package/dist/dashboard/{refusals.js → parts/refusals.js} +1 -1
  355. package/dist/dashboard/{status.js → parts/status.js} +4 -4
  356. package/dist/dashboard/{widgets.js → parts/widgets.js} +2 -2
  357. package/dist/dashboard/place/key.js +24 -0
  358. package/dist/dashboard/place/paper.js +67 -0
  359. package/dist/dashboard/place/{map-sheet.js → sheet.js} +2 -2
  360. package/dist/dashboard/place/things.js +129 -0
  361. package/dist/dashboard/place/tokens.js +93 -0
  362. package/dist/dashboard/place/view.js +124 -0
  363. package/dist/dashboard/{asked-dice.js → play/asked-dice.js} +3 -3
  364. package/dist/dashboard/{asked.js → play/asked.js} +10 -10
  365. package/dist/dashboard/{choices.js → play/choices.js} +9 -9
  366. package/dist/dashboard/{requested.js → play/requested.js} +1 -1
  367. package/dist/dashboard/{rolls.js → play/rolls.js} +9 -9
  368. package/dist/dashboard/{scene.js → play/scene.js} +14 -14
  369. package/dist/dashboard/{turns.js → play/turns.js} +12 -12
  370. package/dist/dashboard/{language-choice.js → settings/language-choice.js} +1 -1
  371. package/dist/dashboard/{languages.js → settings/languages.js} +1 -1
  372. package/dist/dashboard/{saves.js → settings/saves.js} +8 -8
  373. package/dist/dashboard/{settings.js → settings/settings.js} +17 -15
  374. package/dist/dashboard/{setup.js → settings/setup.js} +6 -6
  375. package/dist/dashboard/{party.js → sheet/party.js} +8 -8
  376. package/dist/dashboard/{person-panel.js → sheet/person-panel.js} +4 -4
  377. package/dist/dashboard/{sheet.js → sheet/sheet.js} +17 -17
  378. package/dist/dashboard/{story.js → sheet/story.js} +3 -3
  379. package/dist/dashboard/{columns.js → shell/columns.js} +1 -1
  380. package/dist/dashboard/{footer.js → shell/footer.js} +3 -3
  381. package/dist/dashboard/{master.js → shell/master.js} +2 -2
  382. package/dist/dashboard/{notices.js → shell/notices.js} +3 -3
  383. package/dist/dashboard/{pages.js → shell/pages.js} +5 -5
  384. package/dist/dashboard/shell/shown.js +37 -0
  385. package/dist/dashboard/{table.js → shell/table.js} +2 -2
  386. package/dist/dashboard/{tabs.js → shell/tabs.js} +2 -2
  387. package/dist/dashboard/{top.js → shell/top.js} +7 -7
  388. package/dist/dashboard/style.css +90 -9
  389. package/dist/dashboard/world/calendar.js +4 -4
  390. package/dist/dashboard/world/drawing.js +92 -0
  391. package/dist/dashboard/world/key.js +21 -0
  392. package/dist/dashboard/world/lore.js +5 -5
  393. package/dist/dashboard/world/map-card.js +186 -0
  394. package/dist/dashboard/world/place-card.js +39 -0
  395. package/dist/dashboard/world/places.js +29 -0
  396. package/dist/dashboard/world/world.js +9 -341
  397. package/dist/extensions/extension.d.ts +1 -1
  398. package/dist/extensions/extension.js +1 -1
  399. package/dist/images/images.js +12 -9
  400. package/dist/index.d.ts +1 -1
  401. package/dist/languages/index.d.ts +1 -1
  402. package/dist/languages/index.js +1 -1
  403. package/dist/library/books.js +2 -0
  404. package/dist/packages/npm.js +1 -1
  405. package/dist/page.d.ts +2 -2
  406. package/dist/page.js +1 -1
  407. package/dist/pages/check.js +23 -1
  408. package/dist/pages/containers.d.ts +1 -1
  409. package/dist/pages/containers.js +1 -1
  410. package/dist/pages/index.d.ts +4 -2
  411. package/dist/pages/index.js +4 -2
  412. package/dist/pages/inheritance.d.ts +2 -2
  413. package/dist/pages/layers.d.ts +50 -0
  414. package/dist/pages/layers.js +97 -0
  415. package/dist/pages/rename-page.js +1 -1
  416. package/dist/pages/stacks/writes.js +48 -22
  417. package/dist/pages/standard-fields.d.ts +1 -1
  418. package/dist/pages/system-pages.d.ts +5 -3
  419. package/dist/pages/system-pages.js +16 -7
  420. package/dist/pages/world.d.ts +8 -1
  421. package/dist/pages/world.js +16 -4
  422. package/dist/pages/write-layer.d.ts +18 -0
  423. package/dist/pages/write-layer.js +108 -0
  424. package/dist/pages/write-page.d.ts +2 -2
  425. package/dist/pages/write-page.js +2 -2
  426. package/dist/rules/index.d.ts +1 -1
  427. package/dist/rules/index.js +1 -1
  428. package/dist/rules/search.d.ts +1 -1
  429. package/dist/rules/shown.d.ts +1 -1
  430. package/dist/server/dashboard/choices.js +3 -3
  431. package/dist/server/dashboard/files.js +5 -5
  432. package/dist/server/dashboard/index.d.ts +2 -2
  433. package/dist/server/dashboard/index.js +2 -2
  434. package/dist/server/dashboard/news.js +4 -3
  435. package/dist/server/dashboard/player.js +1 -1
  436. package/dist/server/dashboard/writes.js +10 -8
  437. package/dist/server/mcp.js +28 -13
  438. package/dist/systems/campaign-data.d.ts +15 -0
  439. package/dist/systems/campaign-data.js +85 -0
  440. package/dist/systems/{system-code.d.ts → code.d.ts} +1 -1
  441. package/dist/systems/{system-code.js → code.js} +2 -2
  442. package/dist/systems/game-system.d.ts +7 -61
  443. package/dist/systems/game-system.js +1 -984
  444. package/dist/systems/index.d.ts +6 -3
  445. package/dist/systems/index.js +6 -3
  446. package/dist/systems/installed.d.ts +31 -0
  447. package/dist/systems/installed.js +89 -0
  448. package/dist/systems/maps.d.ts +3 -0
  449. package/dist/systems/maps.js +9 -0
  450. package/dist/systems/read.d.ts +3 -0
  451. package/dist/systems/read.js +471 -0
  452. package/dist/systems/schema.d.ts +289 -0
  453. package/dist/systems/schema.js +243 -0
  454. package/dist/systems/settings.d.ts +19 -0
  455. package/dist/systems/settings.js +78 -0
  456. package/dist/systems/versions.d.ts +12 -0
  457. package/dist/systems/versions.js +52 -0
  458. package/dist/testing/index.js +1 -1
  459. package/instructions/import.md +1 -1
  460. package/instructions/length-a-few-sessions.md +1 -0
  461. package/instructions/length-one-evening.md +1 -0
  462. package/instructions/play.md +1 -1
  463. package/instructions/session-zero.md +1 -1
  464. package/instructions/setup.md +1 -1
  465. package/package.json +1 -1
  466. package/dist/commands/config.js +0 -917
  467. package/dist/commands/package.d.ts +0 -143
  468. package/dist/commands/package.js +0 -785
  469. package/dist/commands/scene.js +0 -894
  470. package/dist/commands/shared/worked-out.js +0 -805
  471. package/dist/dashboard/place/map-view.js +0 -417
  472. /package/dist/commands/shared/{library-reader.d.ts → books/library-reader.d.ts} +0 -0
  473. /package/dist/core/{package-api.d.ts → packages/api.d.ts} +0 -0
  474. /package/dist/core/{package-api.js → packages/api.js} +0 -0
  475. /package/dist/dashboard/{coins.js → parts/coins.js} +0 -0
  476. /package/dist/dashboard/{glass.js → parts/glass.js} +0 -0
  477. /package/dist/dashboard/{layout.js → parts/layout.js} +0 -0
  478. /package/dist/dashboard/{mood-faces.js → parts/mood-faces.js} +0 -0
  479. /package/dist/dashboard/{free-rolls.js → play/free-rolls.js} +0 -0
  480. /package/dist/dashboard/{reactions.js → play/reactions.js} +0 -0
  481. /package/dist/dashboard/{prefs.js → shell/prefs.js} +0 -0
  482. /package/dist/dashboard/{system-style.js → shell/system-style.js} +0 -0
  483. /package/dist/dashboard/{theme.js → shell/theme.js} +0 -0
  484. /package/dist/languages/{language-pack.d.ts → pack.d.ts} +0 -0
  485. /package/dist/languages/{language-pack.js → pack.js} +0 -0
  486. /package/dist/pages/{page-file.d.ts → file.d.ts} +0 -0
  487. /package/dist/pages/{page-file.js → file.js} +0 -0
  488. /package/dist/pages/{page-types.d.ts → types.d.ts} +0 -0
  489. /package/dist/pages/{page-types.js → types.js} +0 -0
  490. /package/dist/rules/{rule-book.d.ts → book.d.ts} +0 -0
  491. /package/dist/rules/{rule-book.js → book.js} +0 -0
  492. /package/dist/systems/{system-folders.d.ts → folders.d.ts} +0 -0
  493. /package/dist/systems/{system-folders.js → folders.js} +0 -0
@@ -4,21 +4,21 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
4
4
  // small beside the page, or in Scene and Combat on a narrow screen; the story by its scenes, as chapters, the last first, each with what the diary tells of it; the companions'
5
5
  // diaries (D-497); and the player's own notes.
6
6
  import { useEffect, useRef, useState } from "preact/hooks";
7
- import { sectionAddress } from "./address.js";
8
- import { pictureAddress, readJournal } from "./api.js";
9
- import { CardHeader, useOpen } from "./card.js";
10
- import { byDateLabel, factLabel, gameDateLabel } from "./game-words.js";
11
- import { Icon, iconPath } from "./icons.js";
12
- import { fieldLabel, phraseLabel, sceneTypeLabel } from "./labels.js";
13
- import { endedQuests, followedQuests, keptFollowed } from "./layout.js";
14
- import { placeKinds } from "./map-symbols.js";
15
- import { knowersOf, Markdown } from "./markdown.js";
7
+ import { sectionAddress } from "../address.js";
8
+ import { pictureAddress, readJournal } from "../api.js";
9
+ import { WidgetCards } from "../packages/widgets.js";
10
+ import { CardHeader, useOpen } from "../parts/card.js";
11
+ import { byDateLabel, factLabel, gameDateLabel } from "../parts/game-words.js";
12
+ import { Icon, iconPath } from "../parts/icons.js";
13
+ import { fieldLabel, phraseLabel, sceneTypeLabel } from "../parts/labels.js";
14
+ import { endedQuests, followedQuests, keptFollowed } from "../parts/layout.js";
15
+ import { placeKinds } from "../parts/map-symbols.js";
16
+ import { knowersOf, Markdown } from "../parts/markdown.js";
17
+ import { PageHead } from "../shell/pages.js";
18
+ import { useChoice, useKeptText } from "../shell/prefs.js";
19
+ import { PageTabs } from "../shell/tabs.js";
20
+ import { arrowStep, t } from "../text.js";
16
21
  import { Notes } from "./notes.js";
17
- import { WidgetCards } from "./packages/widgets.js";
18
- import { PageHead } from "./pages.js";
19
- import { useChoice, useKeptText } from "./prefs.js";
20
- import { PageTabs } from "./tabs.js";
21
- import { arrowStep, t } from "./text.js";
22
22
  // The tab the player last chose, kept in this browser.
23
23
  const tabChoice = { key: "rpg-engine.journal-tab", initial: "quests", values: ["quests", "story", "companions", "notes"] };
24
24
  /** The Journal: the tab the player last chose, or the one the address says, as #/journal/story, and a chapter in the story, as #/journal/story/3. */
@@ -126,7 +126,7 @@ function TrackedQuest({ quest, onUnfollow }) {
126
126
  const next = quest.goals.find((goal) => !goal.done);
127
127
  const id = `tracked-${quest.name.replace(/[^\p{L}\p{N}]+/gu, "-")}`;
128
128
  const kind = quest.main ? t("Main") : t("Side quest");
129
- return (_jsxs("li", { class: open ? "tracked open" : "tracked", children: [_jsx("span", { class: "tracked-mark", role: "img", "aria-label": kind, "data-tip": kind, children: _jsx("svg", { class: quest.main ? "main" : undefined, viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: questFlag }) }) }), _jsxs("button", { type: "button", class: "tracked-what", "aria-expanded": open, "aria-controls": id, onClick: toggle, children: [_jsx("span", { class: "followed-name", children: quest.name }), !open && next !== undefined && _jsx("span", { class: "followed-next", dir: "auto", children: plainText(next.text) })] }), _jsxs("span", { class: "tracked-time", children: [quest.clock !== undefined && _jsx(ClockTip, { clock: quest.clock }), quest.deadline !== undefined && _jsx(Deadline, { deadline: quest.deadline })] }), open && (_jsxs("div", { class: "tracked-more", id: id, children: [_jsx(Goals, { quest: quest }), _jsx("button", { type: "button", class: "tracked-unfollow", onClick: onUnfollow, children: t("Stop following") })] }))] }));
129
+ return (_jsxs("li", { class: open ? "tracked open" : "tracked", children: [_jsx("span", { class: "tracked-mark", role: "img", "aria-label": kind, "data-tip": kind, children: _jsx("svg", { class: quest.main ? "main" : undefined, viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: questFlag }) }) }), _jsxs("button", { type: "button", class: "tracked-what", "aria-expanded": open, "aria-controls": id, onClick: toggle, children: [_jsx("span", { class: "followed-name", children: quest.name }), !open && next !== undefined && _jsx("span", { class: "followed-next", dir: "auto", title: plainText(next.text), children: plainText(next.text) })] }), _jsxs("span", { class: "tracked-time", children: [quest.clock !== undefined && _jsx(ClockTip, { clock: quest.clock }), quest.deadline !== undefined && _jsx(Deadline, { deadline: quest.deadline })] }), open && (_jsxs("div", { class: "tracked-more", id: id, children: [_jsx(Goals, { quest: quest }), _jsx("button", { type: "button", class: "tracked-unfollow", onClick: onUnfollow, children: t("Stop following") })] }))] }));
130
130
  }
131
131
  /** A quest's clock, small, with its name and count as its tooltip. */
132
132
  function ClockTip({ clock }) {
@@ -136,7 +136,7 @@ function ClockTip({ clock }) {
136
136
  /** One followed quest as a strip, on a narrow screen: its star, which stops following it, its picture, its name and next goal leading to the Journal, its clock and time left. */
137
137
  function FollowedStrip({ quest, onUnfollow }) {
138
138
  const next = quest.goals.find((goal) => !goal.done);
139
- return (_jsxs("div", { class: "followed", children: [_jsx("button", { type: "button", class: "followed-star on", "aria-label": t("Follow {quest}", { quest: quest.name }), "aria-pressed": true, onClick: onUnfollow, children: _jsx(Star, {}) }), _jsx(QuestFace, { quest: quest, small: true }), _jsxs("a", { class: "followed-what", href: sectionAddress("journal"), children: [_jsx("span", { class: "followed-name", children: quest.name }), next !== undefined && _jsx("span", { class: "followed-next", dir: "auto", children: plainText(next.text) })] }), quest.clock !== undefined && _jsx(ClockFace, { clock: quest.clock, small: true }), quest.deadline !== undefined && _jsx(Deadline, { deadline: quest.deadline })] }));
139
+ return (_jsxs("div", { class: "followed", children: [_jsx("button", { type: "button", class: "followed-star on", "aria-label": t("Follow {quest}", { quest: quest.name }), "aria-pressed": true, onClick: onUnfollow, children: _jsx(Star, {}) }), _jsx(QuestFace, { quest: quest, small: true }), _jsxs("a", { class: "followed-what", href: sectionAddress("journal"), children: [_jsx("span", { class: "followed-name", children: quest.name }), next !== undefined && _jsx("span", { class: "followed-next", dir: "auto", title: plainText(next.text), children: plainText(next.text) })] }), quest.clock !== undefined && _jsx(ClockFace, { clock: quest.clock, small: true }), quest.deadline !== undefined && _jsx(Deadline, { deadline: quest.deadline })] }));
140
140
  }
141
141
  /** A quest's goals, done ones ticked; a failed quest's undone ones marked missed. */
142
142
  function Goals({ quest }) {
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
2
2
  // The player's notes (D-371), a tab of the Journal: free notes, a title and a text each, saved by themselves as the player writes, kept outside the game; one may
3
3
  // be shared with the master, who hears it at their next call, and taken back until then (D-381).
4
4
  import { useEffect, useRef, useState } from "preact/hooks";
5
- import { readNotes, sendNote } from "./api.js";
6
- import { Icon } from "./icons.js";
7
- import { realTimeLabel } from "./labels.js";
8
- import { t } from "./text.js";
5
+ import { readNotes, sendNote } from "../api.js";
6
+ import { Icon } from "../parts/icons.js";
7
+ import { realTimeLabel } from "../parts/labels.js";
8
+ import { t } from "../text.js";
9
9
  // How long the page waits after the last key before it saves a note, in milliseconds.
10
10
  const savePause = 800;
11
11
  export function Notes({ version }) {
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { useContext } from "preact/hooks";
3
- import { NotationIcons } from "./icons.js";
4
3
  import { PeopleContext } from "./packages/people.js";
5
4
  import { Drawn, Text } from "./packages/widgets.js";
6
- import { sideOf, Token } from "./party.js";
7
- export { statusIcons } from "./icons.js";
5
+ import { NotationIcons } from "./parts/icons.js";
6
+ import { sideOf, Token } from "./sheet/party.js";
8
7
  export { Choices } from "./packages/ask-card.js";
9
8
  export { cardPages } from "./packages/page-code.js";
10
9
  export { Text, Track, Value, Who } from "./packages/widgets.js";
10
+ export { statusIcons } from "./parts/icons.js";
11
11
  /** A button of words, as the page's: gold for the one main action, quiet for a secondary one, danger for one that loses something. */
12
12
  export function Button({ children, onClick, kind, disabled, tip }) {
13
13
  return (_jsx("button", { type: "button", class: kind === undefined ? "button" : `button ${kind}`, "aria-disabled": disabled === true ? "true" : undefined, "data-tip": tip, onClick: () => disabled !== true && onClick(), children: children }));
@@ -4,10 +4,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
4
4
  // asks for, and the rule; once the dice have spoken, the outcome where the buttons were. Its extension's page code may draw the middle's figure, or the
5
5
  // whole inside, the frame staying the page's (D-510). What the dice changed moves once they land; the card stays until the player closes it.
6
6
  import { useEffect, useRef, useState } from "preact/hooks";
7
- import { Icon, NotationIcons } from "../icons.js";
8
- import { checkOf, fieldLabel } from "../labels.js";
7
+ import { Icon, NotationIcons } from "../parts/icons.js";
8
+ import { checkOf, fieldLabel } from "../parts/labels.js";
9
+ import { turnWords } from "../play/turns.js";
9
10
  import { t } from "../text.js";
10
- import { turnWords } from "../turns.js";
11
11
  import { cardLayout, labelKey, trackChanges } from "./card.js";
12
12
  import { deepQuery, ExtensionRoot, figureSize, pagePropsOf, usePageModule } from "./page-code.js";
13
13
  import { Drawn, OwnerContext, Part, Text, textOf, Track, Who } from "./widgets.js";
@@ -0,0 +1,196 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
+ import { useMedia } from "../parts/card.js";
4
+ import { Icon } from "../parts/icons.js";
5
+ import { phraseLabel, systemNameLabel } from "../parts/labels.js";
6
+ import { languageName } from "../settings/languages.js";
7
+ import { arrowStep, foldedText, isolated, pageDirection, t } from "../text.js";
8
+ import { PackageRow, pageLanguage, SaidNote, Trust, WorkNote } from "./rows.js";
9
+ // The rows of the catalog shown before "Show more": fewer on a phone, where the installed come after it.
10
+ const shownWide = 5;
11
+ const shownNarrow = 3;
12
+ /**
13
+ * 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
14
+ * file. The field keeps the focus and what was written while the work goes; it empties once added.
15
+ */
16
+ export function AddField({ state, onAdd, onFile }) {
17
+ const [source, setSource] = useState("");
18
+ const [empty, setEmpty] = useState(false);
19
+ const picker = useRef(null);
20
+ const sent = useRef(undefined);
21
+ // Added: the field is ready for the next one.
22
+ useEffect(() => {
23
+ if (state.said?.problem === false && sent.current === source) {
24
+ setSource("");
25
+ }
26
+ }, [state.said]);
27
+ const submit = () => {
28
+ // 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.
29
+ const given = source.trim().replace(/^"(.*)"$/, "$1").replace(/^(?=[\w-]+(?:\.[\w-]+)+\/)/, "https://");
30
+ if (state.busy) {
31
+ return;
32
+ }
33
+ setEmpty(given === "");
34
+ if (given !== "") {
35
+ sent.current = source;
36
+ onAdd(given);
37
+ }
38
+ };
39
+ return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
40
+ event.preventDefault();
41
+ submit();
42
+ }, 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) => {
43
+ const file = event.currentTarget.files?.[0];
44
+ event.currentTarget.value = "";
45
+ if (file !== undefined) {
46
+ onFile(file);
47
+ }
48
+ } })] }), _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 })] }));
49
+ }
50
+ /**
51
+ * 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
52
+ * the others on asking. A source that does not answer is said in the page's words, with its own under them.
53
+ */
54
+ export function CatalogList({ catalog, view, state, needs, onAdd, onUpdate, onRetry }) {
55
+ const [kind, setKind] = useState("all");
56
+ const [query, setQuery] = useState("");
57
+ const [all, setAll] = useState(false);
58
+ const narrow = useMedia("(max-width: 600px)");
59
+ const list = useRef(null);
60
+ const chips = useRef(null);
61
+ const limit = narrow ? shownNarrow : shownWide;
62
+ const entries = catalog.read?.entries ?? [];
63
+ const found = entries.filter((entry) => matchesQuery(entry, query));
64
+ const kinds = kindOrder.filter((one) => entries.some((entry) => entry.kind === one));
65
+ const chosen = kinds.includes(kind) ? kind : "all";
66
+ const shown = found.filter((entry) => chosen === "all" || entry.kind === chosen);
67
+ // A row past the first ones stays in view while it is worked on or says what happened, as after a reload.
68
+ const visible = all ? shown : shown.filter((entry, index) => index < limit || state(entry).work !== undefined || state(entry).said !== undefined);
69
+ const failed = catalog.error === undefined ? catalog.read?.failed ?? {} : { npm: catalog.error, github: catalog.error };
70
+ // The rows asked for come after those shown: the focus goes to the first of them.
71
+ const showAll = () => {
72
+ setAll(true);
73
+ requestAnimationFrame(() => list.current?.children[limit]?.focus());
74
+ };
75
+ // The chips are one stop of Tab; the arrows go along them, as the page reads.
76
+ const chipKey = (event) => {
77
+ const buttons = [...chips.current?.querySelectorAll("button") ?? []];
78
+ const at = buttons.indexOf(event.target);
79
+ const step = arrowStep(event.key, true);
80
+ const to = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : step === 0 ? -1 : (at + step + buttons.length) % buttons.length;
81
+ if (to >= 0) {
82
+ event.preventDefault();
83
+ buttons[to]?.focus();
84
+ buttons[to]?.click();
85
+ }
86
+ };
87
+ 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));
88
+ 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" })] }))] }));
89
+ }
90
+ /** npm's newer version of a package here, as the catalog says it. */
91
+ export function newerOf(name, kind, catalog) {
92
+ const entry = entryOf(name, kind, catalog);
93
+ return entry?.update === true ? entry.version : undefined;
94
+ }
95
+ /** A package here as the catalog has it. */
96
+ export function entryOf(name, kind, catalog) {
97
+ return catalog?.entries.find((one) => one.kind === kind && samePackage(one, name));
98
+ }
99
+ /** How many packages here npm has a newer version of: the count on the Installed tab. */
100
+ export function updateCount(view, catalog) {
101
+ const systems = (view.systems ?? []).filter((one) => one.package !== undefined && newerOf(one.package, "system", catalog) !== undefined);
102
+ const extensions = view.installed.filter((one) => newerOf(one.package, "extension", catalog) !== undefined);
103
+ const languages = (view.languages ?? []).filter((one) => newerOf(one.package, "language", catalog) !== undefined);
104
+ return systems.length + extensions.length + languages.length;
105
+ }
106
+ /** 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. */
107
+ export function entryTitle(entry) {
108
+ // A language by its code, as lang-de: named in the page's language.
109
+ const code = entry.kind === "language" ? /^(?:lang-)?([a-z]{2,3}(?:-[a-z0-9]+)?)$/i.exec(entry.title)?.[1] : undefined;
110
+ const language = code === undefined ? undefined : languageName(code, pageLanguage());
111
+ return entry.kind === "adventure" ? entry.title : phraseLabel(language ?? entry.title);
112
+ }
113
+ /** npm or GitHub away, or both: the rest is added all the same; the engine's words under the page's, and Try again. */
114
+ function CatalogAway({ failed, asking, onRetry }) {
115
+ const both = failed.npm !== undefined && failed.github !== undefined;
116
+ const [headline, line] = both
117
+ ? [t("The catalog does not answer."), t("A file, a link or a folder can be added all the same.")]
118
+ : failed.npm !== undefined
119
+ ? [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.")]
120
+ : [t("GitHub does not answer."), t("The catalog's adventures come from GitHub: a .zip or a link can be added all the same.")];
121
+ const why = [...new Set([failed.npm, failed.github].filter((one) => one !== undefined))];
122
+ 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")] })] })] }));
123
+ }
124
+ /**
125
+ * 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,
126
+ * 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.
127
+ */
128
+ function CatalogRow({ entry, named, view, state, needs, onAdd, onUpdate }) {
129
+ const here = hereState(entry, view);
130
+ const asksYes = !entry.verified && entry.code;
131
+ // 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).
132
+ const elsewhere = entry.kind === "extension" && entry.system !== undefined && view.system !== null && foldedText(entry.system) !== foldedText(view.system.name);
133
+ const facts = [
134
+ entry.author !== undefined && !entry.verified && !entry.code ? t("by {author}", { author: entry.author }) : "",
135
+ entry.levels === undefined ? "" : levelsText(entry.levels),
136
+ entry.length ?? "",
137
+ entry.language === undefined ? "" : languageName(entry.language, pageLanguage()) ?? entry.language,
138
+ entry.stars === undefined || entry.stars === 0 ? "" : `★ ${entry.stars}`,
139
+ asksYes ? t("has code: asks your yes") : "",
140
+ entry.kind === "system" && here === "none" && view.system !== null ? t("for a new campaign: this one stays in {system}", { system: systemNameLabel(view.system.name) }) : "",
141
+ ].filter((fact) => fact !== "");
142
+ const version = entry.update && entry.installed !== undefined && entry.version !== undefined
143
+ ? (_jsxs("span", { class: "package-update", children: [_jsx(Icon, { name: "update" }), `${isolated(entry.installed)} ${pageDirection() === "rtl" ? "←" : "→"} ${isolated(entry.version)}`] }))
144
+ : entry.version;
145
+ 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] }));
146
+ 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"
147
+ ? action(t("Update"), t("Update {name} to {version}", { name: entryTitle(entry), version: entry.version ?? "" }), "update", onUpdate, true)
148
+ : here === "used" || (here === "here" && entry.kind !== "extension")
149
+ ? (_jsxs("span", { class: "package-here", children: [_jsx(Icon, { name: "check" }), entry.kind === "adventure" || entry.kind === "extension" ? t("In the campaign") : t("On this computer")] }))
150
+ : elsewhere && here === "none"
151
+ ? (_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) })] }))
152
+ : entry.kind === "system" && here === "none"
153
+ ? action(t("Download"), t("Download {name}", { name: entryTitle(entry) }), "download", onAdd)
154
+ : 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 })] }));
155
+ }
156
+ // The kinds in the order of the chips, each with its tile.
157
+ const kindOrder = ["system", "adventure", "extension", "language"];
158
+ const kindIcon = { system: "dice", adventure: "world", extension: "packages", language: "language" };
159
+ /** A kind, for one package. */
160
+ function kindLabel(kind) {
161
+ const labels = { system: t("System"), adventure: t("Adventure"), extension: t("Extension"), language: t("Language") };
162
+ return labels[kind];
163
+ }
164
+ /** A kind, for its chip. */
165
+ function kindsLabel(kind) {
166
+ const labels = { system: t("Systems"), adventure: t("Adventures"), extension: t("Extensions"), language: t("Languages") };
167
+ return labels[kind];
168
+ }
169
+ /** Whether an entry matches what the player searched: by its title, what it is or who wrote it, case and accents aside. */
170
+ function matchesQuery(entry, query) {
171
+ const wanted = foldedText(query.trim());
172
+ return wanted === "" || [entry.title, entry.description ?? "", entry.author ?? ""].some((text) => foldedText(text).includes(wanted));
173
+ }
174
+ /** Where a catalog's package is here: in the campaign, only on this computer, or not here. */
175
+ function hereState(entry, view) {
176
+ if (entry.installed === undefined) {
177
+ return "none";
178
+ }
179
+ if (entry.kind === "adventure") {
180
+ return "used";
181
+ }
182
+ if (entry.kind !== "extension") {
183
+ return "here";
184
+ }
185
+ const extension = view.installed.find((one) => samePackage(entry, one.package));
186
+ return extension !== undefined && !("broken" in extension) && extension.used ? "used" : "here";
187
+ }
188
+ /** Whether a catalog's entry is this package: ours by its name alone, another's by its npm name. */
189
+ function samePackage(entry, name) {
190
+ const source = entry.source.replace(/^npm:/, "");
191
+ return name === source || name === `@rpgengine/${source}`;
192
+ }
193
+ /** An adventure's levels: one, or from one to another. */
194
+ function levelsText(levels) {
195
+ return levels.includes("-") ? t("levels {levels}", { levels: levels.replace("-", "–") }) : t("level {level}", { level: levels });
196
+ }
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ // RPG Engine itself on the Packages page: its card, how a new chat takes the version installed, and what a package's latest needs of it.
3
+ import { useEffect, useRef } from "preact/hooks";
4
+ import { CardHead } from "../parts/card.js";
5
+ import { Icon, iconPath } from "../parts/icons.js";
6
+ import { t } from "../text.js";
7
+ import { PackageRow, SaidNote, UpdateButton, VersionMeta, WorkNote } from "./rows.js";
8
+ // The engine's own name, never translated.
9
+ export const engineName = "RPG Engine";
10
+ // 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.
11
+ const updatedKey = "rpg-engine-updated";
12
+ /** The engine installed from this page in this tab, if any. */
13
+ export function keptUpdate() {
14
+ try {
15
+ const kept = JSON.parse(sessionStorage.getItem(updatedKey) ?? "null");
16
+ return kept !== null && typeof kept.to === "string" && typeof kept.from === "string" ? { from: kept.from, to: kept.to, restart: kept.restart === "app" ? "app" : "chat" } : undefined;
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ }
22
+ export function keepUpdate(updated) {
23
+ try {
24
+ if (updated === undefined) {
25
+ sessionStorage.removeItem(updatedKey);
26
+ }
27
+ else {
28
+ sessionStorage.setItem(updatedKey, JSON.stringify(updated));
29
+ }
30
+ }
31
+ catch {
32
+ // A browser that keeps nothing says it until the page is drawn again.
33
+ }
34
+ }
35
+ /** The focus to the engine's card: its Update, else its title. */
36
+ export function focusEngine() {
37
+ const target = document.getElementById("engine-update") ?? document.getElementById("packages-engine");
38
+ target?.focus({ preventScroll: true });
39
+ target?.scrollIntoView({ block: "center" });
40
+ }
41
+ /**
42
+ * 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,
43
+ * 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.
44
+ */
45
+ export function EngineCard({ engine, updated, newer, state, onUpdate }) {
46
+ const folder = engine?.folder ?? "";
47
+ const why = engine === undefined
48
+ ? t("Asking npm for the newest version…")
49
+ : engine.install === "link"
50
+ ? t("Installed with npm link from {folder}, for its development: update it there, with git pull and npm run build.", { folder })
51
+ : engine.install === "other"
52
+ ? t("Installed another way, in {folder}: update it the way you installed it.", { folder })
53
+ : engine.failed !== undefined
54
+ ? t("npm does not answer: a newer version cannot be checked now.")
55
+ : undefined;
56
+ // A newer one this page does not install is still said, by its version.
57
+ const shownNewer = updated === undefined && engine?.update === true ? engine.latest : undefined;
58
+ 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
59
+ ? _jsx(UpdateButton, { id: "engine-update", name: engineName, version: newer, busy: state.busy, onClick: onUpdate })
60
+ : 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 })] }) }) })] }));
61
+ }
62
+ /**
63
+ * 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
64
+ * version offered meanwhile is the newest this engine reads.
65
+ */
66
+ export function NeedsEngine({ newer, canUpdate, onGo }) {
67
+ const { version, engine } = newer;
68
+ 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" })] })] }));
69
+ }
70
+ /**
71
+ * 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
72
+ * 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.
73
+ */
74
+ function RestartNote({ updated }) {
75
+ const note = useRef(null);
76
+ // Just updated, the focus Update had comes here; kept from before a reload, it stays where the page puts it.
77
+ useEffect(() => {
78
+ if (updated.now) {
79
+ note.current?.focus({ preventScroll: true });
80
+ note.current?.scrollIntoView({ block: "nearest" });
81
+ }
82
+ }, []);
83
+ const steps = updated.restart === "app"
84
+ ? [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.")]
85
+ : [t("Close this chat."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")];
86
+ 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)) })] }));
87
+ }
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { gameDateLabel, sinceDateLabel } from "../parts/game-words.js";
3
+ import { Icon } from "../parts/icons.js";
4
+ import { phraseLabel, systemTitleLabel } from "../parts/labels.js";
5
+ import { languageName } from "../settings/languages.js";
6
+ import { t } from "../text.js";
7
+ import { OwnPageLinks } from "./page.js";
8
+ import { PackageRow, pageLanguage, ReportLink, SaidNote, Trust, UninstallButton, UpdateButton, VersionMeta, WorkNote } from "./rows.js";
9
+ /**
10
+ * 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
11
+ * newer version, to update it.
12
+ */
13
+ export function SystemRow({ system, newer, needs, fresh, state, onUpdate, onUninstall }) {
14
+ const target = system.package ?? system.name;
15
+ 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
16
+ ? (_jsxs("span", { class: "package-lock", children: [_jsx(Icon, { name: "lock" }), t("In use · chosen in the setup")] }))
17
+ : (_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 })] }));
18
+ }
19
+ /** 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. */
20
+ export function AdventureRow({ adventure, fresh, state, onTakeOut }) {
21
+ const since = adventure.since === undefined ? undefined : sinceDateLabel(adventure.since);
22
+ 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
23
+ ? (_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…")] }))
24
+ : (_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 })] }));
25
+ }
26
+ /** 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. */
27
+ export function ExtensionRow({ extension, newer, needs, fresh, state, onUse, onUpdate, onUninstall }) {
28
+ const name = phraseLabel(extension.name);
29
+ if ("broken" in extension) {
30
+ 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 })] }));
31
+ }
32
+ 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) => {
33
+ event.preventDefault();
34
+ if (!state.busy) {
35
+ onUse(!extension.used);
36
+ }
37
+ } }), t("In use")] }), _jsx(UninstallButton, { name: name, busy: state.busy, onClick: onUninstall })] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
38
+ }
39
+ /** An extension the campaign lists and this computer lacks: in red, with Install. */
40
+ export function MissingRow({ name, state, onInstall }) {
41
+ const shown = phraseLabel(name.replace(/^@[^/]+\//, ""));
42
+ 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 })] }));
43
+ }
44
+ /** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
45
+ export function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
46
+ const page = pageLanguage().toLowerCase().split("-")[0] === language.code.toLowerCase().split("-")[0];
47
+ const name = languageTitle(language);
48
+ 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 })] }));
49
+ }
50
+ /** A language package's name in the page's language, else its own. */
51
+ export function languageTitle(language) {
52
+ return phraseLabel(languageName(language.code, pageLanguage()) ?? language.name);
53
+ }
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
+ import { CardHead } from "../parts/card.js";
4
+ import { Icon, iconPath } from "../parts/icons.js";
5
+ import { t } from "../text.js";
6
+ import { PackageRow, SaidNote, WorkNote } from "./rows.js";
7
+ // How often the library is read again while its books are being read, for their counts.
8
+ export const libraryReading = 5000;
9
+ /**
10
+ * 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
11
+ * 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.
12
+ */
13
+ export function LibraryTab({ view, problem, state, onAdd, onUse, onForget }) {
14
+ const entries = view?.entries ?? [];
15
+ const used = entries.filter((entry) => entry.used && entry.onComputer).length;
16
+ // A folder by its name; by its path when another has the same name.
17
+ const label = (entry) => (entries.filter((other) => shelfName(other.path) === shelfName(entry.path)).length > 1 ? entry.path : shelfName(entry.path));
18
+ 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 })] })] }));
19
+ }
20
+ /**
21
+ * 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,
22
+ * 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.
23
+ */
24
+ function LibraryRow({ entry, label, state, onUse, onForget }) {
25
+ const path = (_jsx("bdi", { dir: "ltr", class: "library-path", children: breakablePath(entry.path) }));
26
+ const name = _jsx("bdi", { children: shelfName(entry.path) });
27
+ if (!entry.onComputer) {
28
+ 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 })] }));
29
+ }
30
+ 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) => {
31
+ event.preventDefault();
32
+ if (!state.busy) {
33
+ onUse(!entry.used);
34
+ }
35
+ } }), 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 })] }));
36
+ }
37
+ /** Why a book was skipped, in the player's words, with what to do. */
38
+ function skippedText(kind) {
39
+ const texts = {
40
+ password: t("it asks for a password to open: save a copy without one."),
41
+ drm: t("it is locked by DRM, which RPG Engine never opens."),
42
+ 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."),
43
+ denied: t("this computer does not let it be read: check who may open it."),
44
+ broken: t("it does not read: the file is damaged, or is not what its name says."),
45
+ };
46
+ return texts[kind];
47
+ }
48
+ /** 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. */
49
+ function shelfName(path) {
50
+ const last = path.replace(/[\\/]+$/, "").split(/[\\/]/).at(-1) ?? "";
51
+ return last === "" || /^[a-z]:$/i.test(last) ? path : last.replace(/\.(md|txt|pdf|docx|odt|epub|html?)$/i, "");
52
+ }
53
+ /** 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. */
54
+ function libraryMeta(entry) {
55
+ if (entry.missing) {
56
+ return t("Not there now, as a disk taken out: its books stay known for when it is back.");
57
+ }
58
+ return [
59
+ entry.books === 1 ? t("1 book read") : t("{count} books read", { count: entry.books }),
60
+ entry.reading === 0 ? "" : entry.reading === 1 ? t("1 being read") : t("{count} being read", { count: entry.reading }),
61
+ entry.skipped.length === 0 ? "" : entry.skipped.length === 1 ? t("1 skipped") : t("{count} skipped", { count: entry.skipped.length }),
62
+ entry.crowded ? t("more than 300 documents: only the first are read; give the folder of this game's books") : "",
63
+ ].filter((part) => part !== "").join(" · ");
64
+ }
65
+ /** A path that goes to a new line after its separators, as words do, and is copied as it is. */
66
+ function breakablePath(path) {
67
+ return path.split(/(?<=[\\/])/).flatMap((part, index) => (index === 0 ? [part] : [_jsx("wbr", {}, index), part]));
68
+ }
69
+ /**
70
+ * 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
71
+ * player's yes and never changes the folder. It empties once added.
72
+ */
73
+ function LibraryField({ state, onAdd }) {
74
+ const [path, setPath] = useState("");
75
+ const [empty, setEmpty] = useState(false);
76
+ const sent = useRef(undefined);
77
+ useEffect(() => {
78
+ if (state.said?.problem === false && sent.current === path) {
79
+ setPath("");
80
+ }
81
+ }, [state.said]);
82
+ const submit = () => {
83
+ const given = path.trim().replace(/^"(.*)"$/, "$1");
84
+ if (state.busy) {
85
+ return;
86
+ }
87
+ setEmpty(given === "");
88
+ if (given !== "") {
89
+ sent.current = path;
90
+ onAdd(given);
91
+ }
92
+ };
93
+ return (_jsxs("form", { class: "package-add", noValidate: true, onSubmit: (event) => {
94
+ event.preventDefault();
95
+ submit();
96
+ }, 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 })] }));
97
+ }