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,18 +4,18 @@ import { appendLogEntry } from "../core/log.js";
4
4
  import { defineCommand } from "../core/registry.js";
5
5
  import { closedSquare, featureAt, firstOpenSquare, readSquare, squareName } from "../grid/index.js";
6
6
  import { canHold, isInParty, kindNamed, locate, pageNamed, pagesWithName, pageTypeNames, parsePageReference, stackName, writePage } from "../pages/index.js";
7
- import { surroundings, surroundingsChange } from "./shared/environment.js";
8
- import { moveFacts } from "./shared/grid-moves.js";
9
- import { atEntries, atEntry, clearCopies, offMapNote, placeGrid, standing } from "./shared/grids.js";
10
- import { picturesNote } from "./shared/images.js";
7
+ import { picturesNote } from "./shared/campaign/images.js";
8
+ import { campaignSystem, campaignWorld, missingSystemHint } from "./shared/campaign/world.js";
11
9
  import { textList, textsOf, wholeNumber } from "./shared/inputs.js";
12
- import { movePages } from "./shared/moves.js";
13
10
  import { shortList, skippedPagesNote } from "./shared/notes.js";
14
- import { measuresOf, roadsOf, sameSpot, stopOf } from "./shared/roads.js";
15
- import { copyName, readOpenScene, scenePlace, updateScene } from "./shared/scene.js";
16
- import { heldStack, stackMoveSteps, writeStacks } from "./shared/stacks.js";
17
- import { newDatedLogEntry } from "./shared/time.js";
18
- import { campaignSystem, campaignWorld, missingSystemHint } from "./shared/world.js";
11
+ import { surroundings, surroundingsChange } from "./shared/places/environment.js";
12
+ import { moveFacts } from "./shared/places/grid-moves.js";
13
+ import { atEntries, atEntry, clearCopies, offMapNote, placeGrid, standing } from "./shared/places/grids.js";
14
+ import { movePages } from "./shared/places/moves.js";
15
+ import { measuresOf, roadsOf, sameSpot, stopOf } from "./shared/places/roads.js";
16
+ import { copyName, readOpenScene, scenePlace, updateScene } from "./shared/scene/scene.js";
17
+ import { heldStack, stackMoveSteps, writeStacks } from "./shared/sheet/stacks.js";
18
+ import { newDatedLogEntry } from "./shared/time/time.js";
19
19
  export const move = defineCommand({
20
20
  name: "move",
21
21
  description: "Move characters, items or places into a place, a character's inventory or an item. "
@@ -0,0 +1,11 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import { Refusal } from "../../core/refusal.ts";
3
+ /** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
4
+ export declare class YesRefused extends Refusal {
5
+ constructor(message: string, code: "declined" | "no-window", values?: Record<string, string>);
6
+ }
7
+ /**
8
+ * The player's own yes to a package not ours (D-441, D-478), where the master cannot give it with its own tools: the host's form first, never the dashboard's
9
+ * page, whose click a local program can forge; else a window of their operating system; else none, and it throws.
10
+ */
11
+ export declare function playerYes(context: Context, name: string, pack: string, local: boolean, holds?: string, replaces?: string): Promise<void>;
@@ -0,0 +1,52 @@
1
+ // The player's own yes to a package not ours (D-441, D-478)
2
+ import { plainText } from "../../confirm/index.js";
3
+ import { Refusal } from "../../core/refusal.js";
4
+ import { isTarball } from "../../packages/index.js";
5
+ /** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
6
+ export class YesRefused extends Refusal {
7
+ constructor(message, code, values = {}) {
8
+ super(message, code, values);
9
+ }
10
+ }
11
+ /**
12
+ * The player's own yes to a package not ours (D-441, D-478), where the master cannot give it with its own tools: the host's form first, never the dashboard's
13
+ * page, whose click a local program can forge; else a window of their operating system; else none, and it throws.
14
+ */
15
+ export async function playerYes(context, name, pack, local, holds = "", replaces = "") {
16
+ // A no in a window holds for the package npm describes, however it was written, until the server starts again (D-510).
17
+ if (context.declined?.has(pack) === true) {
18
+ throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined", { name: pack });
19
+ }
20
+ // Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510). The package's own words cut short, so
21
+ // that a window, which shows so much at most, never loses the warning to them.
22
+ const clean = (text, most) => plainText(text.replace(/\s+/g, " "), most);
23
+ [name, holds] = [clean(name, 120), holds.trim() === "" ? "" : ` ${clean(holds, 160)}`];
24
+ const from = context.actor === "player" ? "the dashboard" : context.host === undefined ? "the command line" : "the chat";
25
+ const can = "Its code runs on this computer with your permissions, and in the dashboard, where it can see the whole campaign, its secrets included, and press buttons and speak to the master for you.";
26
+ const warning = local
27
+ ? `Not verified by RPG Engine: ${name}${holds}, ${isTarball(name) ? "a file" : "a folder"} of this computer, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.${replaces}`
28
+ : `Not verified by RPG Engine: ${name}, from npm, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.`;
29
+ const question = `Install ${name}? ${warning}`;
30
+ const title = "A package not ours";
31
+ const answer = context.player === undefined ? "unavailable" : await context.player.choose(question, title, ["Install it, at my risk", "Do not install it"], context.signal);
32
+ if (answer === 0) {
33
+ return;
34
+ }
35
+ if (answer === 1 || (typeof answer === "object" && answer !== null)) {
36
+ throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
37
+ }
38
+ // Closed without an answer is no yes, never a reason to ask again some other way.
39
+ if (answer === undefined) {
40
+ throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined", { name });
41
+ }
42
+ const window = context.confirm === undefined ? "none" : await context.confirm.ask(title, question, context.signal);
43
+ if (window === "yes") {
44
+ return;
45
+ }
46
+ if (window === "no") {
47
+ context.declined?.add(pack);
48
+ throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
49
+ }
50
+ throw new YesRefused(`${warning} Only the player can say yes to it, in the host's form or in a window of their computer, and neither can be shown here (no desktop, as over SSH; `
51
+ + `on Linux zenity or kdialog shows it): install it where one can be. Nothing changed.`, "no-window");
52
+ }
@@ -0,0 +1,51 @@
1
+ import { type Context } from "../../core/context.ts";
2
+ import { type Extension } from "../../extensions/index.ts";
3
+ /** A game system on this computer (D-485): shipped with the engine, or a package npm installed; the campaign plays one, chosen in its setup. */
4
+ export interface InstalledSystem {
5
+ name: string;
6
+ title: string;
7
+ version?: string;
8
+ package?: string;
9
+ verified: boolean;
10
+ used: boolean;
11
+ /** Whether it brings code, which runs from the next start of the game's server. */
12
+ code: boolean;
13
+ /** Where its problems are reported, as its package.json says: the engine's own for those shipped with it. */
14
+ issues?: string;
15
+ }
16
+ /** A language package on this computer (D-485 (3)), for every campaign: one for each language. */
17
+ export interface InstalledLanguage {
18
+ code: string;
19
+ name: string;
20
+ package: string;
21
+ version: string;
22
+ verified: boolean;
23
+ /** Where its problems are reported, as its package.json says. */
24
+ issues?: string;
25
+ }
26
+ /** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
27
+ export declare function isInstalledPackage(context: Context, name: string): boolean;
28
+ /** The game systems on this computer, those shipped with the engine first, with the package each came in when npm installed it (D-485). */
29
+ export declare function systemsHere(root: string, context: Context): InstalledSystem[];
30
+ /** The language packages on this computer, one for each language (D-485 (3)). */
31
+ export declare function languagesHere(context: Context): InstalledLanguage[];
32
+ /** Whether a game system by this name is on this computer; one whose system.yaml does not read is there too, and validate says why. */
33
+ export declare function isSystemHere(context: Context, name: string): boolean;
34
+ /** The folder npm installed a package in, among the extensions' folders; undefined when it is not there. */
35
+ export declare function installedExtensionFolder(context: Context, name: string): string | undefined;
36
+ /** The installed extension of this package, when it reads; undefined when it is missing or broken. */
37
+ export declare function usable(context: Context, name: string): Extension | undefined;
38
+ /** The extension npm installed by this whole name, or why it is none: not there under that name, or not read, with what is wrong. */
39
+ export declare function installedAs(context: Context, name: string): {
40
+ extension: Extension;
41
+ } | {
42
+ unread: string;
43
+ } | {
44
+ missing: true;
45
+ };
46
+ /** Why a system npm installed is not among those that read: its system.yaml does not, or it has none. */
47
+ export declare function unreadSystemWhy(folder: string | undefined, name: string): string;
48
+ /** Where the package in this folder takes reports of its problems, as its package.json says; nothing when it says none or has none that reads. */
49
+ export declare function issuesOf(folder: string): {
50
+ issues?: string;
51
+ };
@@ -0,0 +1,128 @@
1
+ // What is on this computer: the game systems, languages and extensions npm installed, and where each takes reports of its problems
2
+ import { join } from "node:path";
3
+ import { readTextSetting } from "../../campaign/index.js";
4
+ import { engineSystemsFolder } from "../../core/context.js";
5
+ import { installedFromFolder } from "../../core/files.js";
6
+ import { files, isInside } from "../../core/store.js";
7
+ import { comparableText } from "../../core/text.js";
8
+ import { findExtension, installedExtensions, readExtension, shortName } from "../../extensions/index.js";
9
+ import { installedLanguages } from "../../languages/index.js";
10
+ import { isPackageName, issuesPage, isVerified, verifiedScope } from "../../packages/index.js";
11
+ import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder, systemWords } from "../../systems/index.js";
12
+ /** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
13
+ export function isInstalledPackage(context, name) {
14
+ const asked = name.startsWith("npm:") ? name.slice(4) : name.startsWith("@") ? name : `${verifiedScope}${name}`;
15
+ // An npm name only, never a path that climbs to npm's own folder (D-510).
16
+ return [asked, name].some((one) => isPackageName(one) && installedExtensionFolder(context, one) !== undefined);
17
+ }
18
+ /** The game systems on this computer, those shipped with the engine first, with the package each came in when npm installed it (D-485). */
19
+ export function systemsHere(root, context) {
20
+ const plays = readTextSetting(root, "system") ?? "";
21
+ const language = readTextSetting(root, "language");
22
+ const folders = systemFolders(context.systemFolders);
23
+ return readableSystems(context.systemFolders).map((system) => {
24
+ const manifest = packageOf(folders.find((one) => one.name === system.name)?.folder ?? system.folder);
25
+ // The engine's own have no package of their own here; one npm installed is ours only by our scope, and never from a folder (D-441).
26
+ const shipped = isInside(engineSystemsFolder, system.folder);
27
+ const linked = installedFromFolder(system.folder);
28
+ return {
29
+ name: system.name,
30
+ title: language === undefined ? system.title : titleIn(system.folder, system.title, language),
31
+ ...(manifest === undefined ? {} : { version: manifest.version }),
32
+ ...(manifest === undefined || shipped ? {} : { package: manifest.name }),
33
+ verified: shipped || (manifest !== undefined && isVerified(manifest.name, linked)),
34
+ used: comparableText(system.name) === comparableText(plays),
35
+ code: systemHasCode(system.folder),
36
+ // The engine's own are reported where the engine is: its package.json is in the folder above its systems.
37
+ ...issuesOf(shipped ? join(engineSystemsFolder, "..") : system.folder),
38
+ };
39
+ });
40
+ }
41
+ /** The language packages on this computer, one for each language (D-485 (3)). */
42
+ export function languagesHere(context) {
43
+ return installedLanguages(context.extensionFolders ?? []).map((pack) => ({
44
+ code: pack.code,
45
+ name: pack.name,
46
+ package: pack.package,
47
+ version: pack.version,
48
+ verified: isVerified(pack.package, installedFromFolder(pack.folder)),
49
+ ...issuesOf(pack.folder),
50
+ }));
51
+ }
52
+ /** Whether a game system by this name is on this computer; one whose system.yaml does not read is there too, and validate says why. */
53
+ export function isSystemHere(context, name) {
54
+ try {
55
+ return findSystem(context.systemFolders, name) !== undefined;
56
+ }
57
+ catch {
58
+ return true;
59
+ }
60
+ }
61
+ /** The folder npm installed a package in, among the extensions' folders; undefined when it is not there. */
62
+ export function installedExtensionFolder(context, name) {
63
+ return (context.extensionFolders ?? []).map((folder) => join(folder, ...name.split("/"))).find((folder) => files().exists(join(folder, "package.json")));
64
+ }
65
+ /** The installed extension of this package, when it reads; undefined when it is missing or broken. */
66
+ export function usable(context, name) {
67
+ try {
68
+ return findExtension(context.extensionFolders ?? [], name);
69
+ }
70
+ catch {
71
+ return undefined;
72
+ }
73
+ }
74
+ /** The extension npm installed by this whole name, or why it is none: not there under that name, or not read, with what is wrong. */
75
+ export function installedAs(context, name) {
76
+ const found = installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name);
77
+ if (found === undefined) {
78
+ return { missing: true };
79
+ }
80
+ try {
81
+ return { extension: readExtension(found.folder) };
82
+ }
83
+ catch (error) {
84
+ return { unread: error instanceof Error ? error.message : String(error) };
85
+ }
86
+ }
87
+ /** Why a system npm installed is not among those that read: its system.yaml does not, or it has none. */
88
+ export function unreadSystemWhy(folder, name) {
89
+ if (folder === undefined || !files().exists(join(folder, "system.yaml"))) {
90
+ return "it has no system.yaml: it is no game system";
91
+ }
92
+ try {
93
+ systemInFolder(folder, shortName(name).replace(/^system-/, ""));
94
+ return "it does not read as a game system";
95
+ }
96
+ catch (error) {
97
+ return `its system.yaml does not read: ${error instanceof Error ? error.message : String(error)}`;
98
+ }
99
+ }
100
+ /** A system's title in the campaign's language, as its own words give it; as it is where they do not, or do not read. */
101
+ function titleIn(folder, title, language) {
102
+ try {
103
+ return systemWords(folder, language)?.words[title] ?? title;
104
+ }
105
+ catch {
106
+ return title;
107
+ }
108
+ }
109
+ /** Where the package in this folder takes reports of its problems, as its package.json says; nothing when it says none or has none that reads. */
110
+ export function issuesOf(folder) {
111
+ try {
112
+ const issues = issuesPage(JSON.parse(files().text(join(folder, "package.json")) ?? ""));
113
+ return issues === undefined ? {} : { issues };
114
+ }
115
+ catch {
116
+ return {};
117
+ }
118
+ }
119
+ /** The name and the version a package.json in this folder gives; undefined when it has none that reads. */
120
+ function packageOf(folder) {
121
+ try {
122
+ const read = JSON.parse(files().text(join(folder, "package.json")) ?? "");
123
+ return typeof read.name === "string" && typeof read.version === "string" ? { name: read.name, version: read.version } : undefined;
124
+ }
125
+ catch {
126
+ return undefined;
127
+ }
128
+ }
@@ -0,0 +1,10 @@
1
+ import type { Context } from "../../core/context.ts";
2
+ import type { PackageResult } from "./result.ts";
3
+ /**
4
+ * Installs the game system the campaign in this context's folder plays, when it is one of ours that is not on this computer, as package install does, from
5
+ * npm's cache when the registry does not answer, then loads its code (SYS-10, D-514 (3)); once for each system, as `tried` keeps them. The line that says
6
+ * so to the master, or why it could not; undefined when there is no campaign or nothing to install, and for a system not ours, which asks the player's yes.
7
+ */
8
+ export declare function installCampaignSystem(context: Context, tried: Set<string>): Promise<string | undefined>;
9
+ /** Installs a package on this computer and adds it to the campaign (D-27, D-428, D-441): ours, or another once the player wants it; an extension, for this game. */
10
+ export declare function installed(root: string, context: Context, name: string): Promise<PackageResult>;
@@ -0,0 +1,337 @@
1
+ // Installs a package, an extension, a game system or a language, and checks what npm put there; and the system a campaign plays when this computer lacks it
2
+ import { join } from "node:path";
3
+ import { changeExtensions, findCampaign, readTextSetting } from "../../campaign/index.js";
4
+ import { neutralExamples } from "../../core/examples.js";
5
+ import { appendLogEntry } from "../../core/log.js";
6
+ import { apiProblem, ourSystems, packageApi } from "../../core/packages/declarations.js";
7
+ import { Refusal } from "../../core/refusal.js";
8
+ import { files, FileStore, withFiles } from "../../core/store.js";
9
+ import { comparableText } from "../../core/text.js";
10
+ import { recordConsent, shortName } from "../../extensions/index.js";
11
+ import { installedLanguages, languagePackProblems, readLanguagePack } from "../../languages/index.js";
12
+ import { isLocalSpec, isVerified, verifiedScope } from "../../packages/index.js";
13
+ import { campaignMode } from "../shared/campaign/mode.js";
14
+ import { campaignWorld } from "../shared/campaign/world.js";
15
+ import { campaignExamples } from "../shared/examples.js";
16
+ import { loadCampaignCode, loadNewSystemCode, packageCommandNames, packagesInstalled } from "../shared/packages/code.js";
17
+ import { listedExtensions, runsCode } from "../shared/packages/extensions.js";
18
+ import { newDatedLogEntry } from "../shared/time/time.js";
19
+ import { playerYes } from "./consent.js";
20
+ import { installedAs, installedExtensionFolder, isSystemHere, languagesHere, systemsHere, unreadSystemWhy, usable } from "./here.js";
21
+ /**
22
+ * Installs the game system the campaign in this context's folder plays, when it is one of ours that is not on this computer, as package install does, from
23
+ * npm's cache when the registry does not answer, then loads its code (SYS-10, D-514 (3)); once for each system, as `tried` keeps them. The line that says
24
+ * so to the master, or why it could not; undefined when there is no campaign or nothing to install, and for a system not ours, which asks the player's yes.
25
+ */
26
+ export async function installCampaignSystem(context, tried) {
27
+ const packages = context.packages;
28
+ return packages === undefined ? undefined : await withFiles(context.files ?? new FileStore(context.systemFolders), async () => {
29
+ const root = findCampaign(context.folder);
30
+ const name = root === undefined ? undefined : readTextSetting(root, "system");
31
+ const ours = name === undefined ? undefined : ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
32
+ // Each system is looked for once: one here stays, as package uninstall keeps the one the campaign plays.
33
+ if (root === undefined || ours === undefined || tried.has(ours.name)) {
34
+ return undefined;
35
+ }
36
+ tried.add(ours.name);
37
+ if (isSystemHere(context, ours.name)) {
38
+ return undefined;
39
+ }
40
+ let result;
41
+ try {
42
+ // As package install, which loads the code of the system the campaign plays.
43
+ result = await installed(root, context, ours.package);
44
+ }
45
+ catch (error) {
46
+ // npm's why, without what package install adds for the master, and without its period: the master tells the player, and the player chooses (D-514 (3)).
47
+ const why = (error instanceof Error ? error.message : String(error)).replace(/^\S+ could not be installed: /, "").replace(/\s*Nothing changed[^.]*\.$/, "").replace(/\.$/, "");
48
+ return `The campaign's game system, ${ours.name}, is not on this computer, and could not be installed: ${why}. Tell the player off-game, in brackets and in a table's words, `
49
+ + `that this computer lacks the ${ours.name} rules and could not download them: once it is online, you install them with package install ${ours.name}, no yes needed. `
50
+ + "Until then you play without its pages and the sheet's worked-out numbers, or wait, as the player chooses.";
51
+ }
52
+ const version = result.kind === "system-installed" && result.system.version !== undefined ? ` ${result.system.version}` : "";
53
+ return `The campaign's game system, ${ours.name}, was not on this computer: RPG Engine installed it, ${ours.package}${version}, one of its own. Its pages and rules are there from now.`
54
+ + namesNote(root, context, ours.name);
55
+ });
56
+ }
57
+ /** Installs a package on this computer and adds it to the campaign (D-27, D-428, D-441): ours, or another once the player wants it; an extension, for this game. */
58
+ export async function installed(root, context, name) {
59
+ const packages = context.packages;
60
+ if (packages === undefined) {
61
+ throw new Error("Packages are installed only by the game's server or the command line, which reach npm.");
62
+ }
63
+ // A name alone is one of ours: weather is @rpgengine/weather, never a stranger's of that name, which is given as npm:weather; or our game system's, as 5e
64
+ // is @rpgengine/system-5e (D-513).
65
+ const [first, second] = name.startsWith("npm:") ? [name.slice(4)] : isLocalSpec(name) || name.startsWith("@") ? [name] : ourNames(name);
66
+ const tried = await packages.describe(first);
67
+ const other = second !== undefined && "failed" in tried && tried.missing === true ? await packages.describe(second) : undefined;
68
+ const [asked, described] = second !== undefined && other !== undefined && !("failed" in other && other.missing === true) ? [second, other] : [first, tried];
69
+ if ("failed" in described) {
70
+ const message = `${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`;
71
+ throw isLocalSpec(asked)
72
+ ? new Refusal(message, "not-on-computer", { name })
73
+ : described.missing === true
74
+ ? new Refusal(message, "not-found", { name })
75
+ : new Refusal(message, "npm-failed", { name, why: described.failed });
76
+ }
77
+ // npm is given the version described, which the player's yes was for: by its name alone, npm would keep the exact version it saved before.
78
+ const spec = isLocalSpec(asked) ? asked : `${described.name}@${described.version}`;
79
+ if (described.kind === "system") {
80
+ return await systemInstalled(root, context, spec, name, described);
81
+ }
82
+ if (described.kind === "language") {
83
+ return await languageInstalled(root, context, spec, described);
84
+ }
85
+ if (described.kind !== "extension") {
86
+ throw described.kind === undefined
87
+ ? new Refusal(`${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed.`, "not-ours", { name: described.name })
88
+ : new Refusal(`${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed.`, "other-kind", {
89
+ name: described.name,
90
+ });
91
+ }
92
+ const unread = apiProblem(described.api, "extension");
93
+ if (unread !== undefined) {
94
+ throw apiRefusal(described, unread);
95
+ }
96
+ const local = isLocalSpec(spec);
97
+ const before = usable(context, described.name);
98
+ if (!isVerified(described.name, local)) {
99
+ // A file or a folder says what it holds, and when it takes the place of a copy from npm, which is one for the whole computer (D-452).
100
+ const holds = local ? ` (${described.name} ${described.version}${described.author === undefined ? "" : `, by ${described.author}`})` : "";
101
+ const replaces = local && before !== undefined && !before.linked ? ` It takes the place of ${before.package} ${before.version} from npm, in every campaign on this computer.` : "";
102
+ await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, holds, replaces);
103
+ }
104
+ // A copy from a file or a folder never stands for the one npm has: asked by its name, npm's comes back.
105
+ // Another's whose code may not run is installed again before its yes is kept: the yes goes to npm's files, never to files changed since (D-478, D-510).
106
+ const reinstall = before === undefined || before.version !== described.version || local || before.linked || (!isVerified(described.name, local) && !runsCode(before));
107
+ if (reinstall) {
108
+ const why = await packages.install(spec);
109
+ if (why !== undefined) {
110
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed in the campaign.`, "install-failed", { name: described.name, why });
111
+ }
112
+ // npm wrote there: what the call read of those folders is read again, and the code anew.
113
+ (context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
114
+ packagesInstalled();
115
+ }
116
+ // By its whole name: another's skies is not ours, nor ours another's.
117
+ const installed = installedAs(context, described.name);
118
+ const extension = "extension" in installed ? installed.extension : undefined;
119
+ // What npm installed is not what the player said yes to, or no extension: it goes off this computer again, and never runs.
120
+ if (extension === undefined || extension.version !== described.version) {
121
+ await packages.uninstall(described.name);
122
+ (context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
123
+ const why = extension !== undefined
124
+ ? `it is the version ${extension.version}, not the ${described.version} the player said yes to`
125
+ : "unread" in installed
126
+ ? `its extension does not read: ${installed.unread}`
127
+ : "no extension of that name is where npm put it";
128
+ throw new Refusal(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`, "taken-off", {
129
+ name: described.name,
130
+ why,
131
+ });
132
+ }
133
+ // The player's yes holds for this version and these files, on this computer: its code runs on the server and in the page (D-478, D-510).
134
+ if (!isVerified(described.name, local) && !extension.linked) {
135
+ recordConsent(extension.folder, extension.package, extension.version);
136
+ }
137
+ const system = readTextSetting(root, "system");
138
+ if (extension.needs.system !== undefined && comparableText(extension.needs.system) !== comparableText(system ?? "")) {
139
+ throw new Refusal(`${extension.name} is installed on this computer, but it is for the game system ${extension.needs.system}, and the campaign plays ${system ?? "none"}: the campaign does not use it.`, "other-system", { name: extension.name, system: extension.needs.system, plays: system ?? "" });
140
+ }
141
+ // Its state, widgets and pictures go by its name, which the system's would share (D-514).
142
+ if (comparableText(extension.name) === comparableText(system ?? "")) {
143
+ throw new Refusal(`${extension.name} is installed on this computer, but it has the name of the game system the campaign plays: the campaign does not use it. Nothing changed in the campaign.`, "system-name", { name: extension.name });
144
+ }
145
+ const others = Object.keys(listedExtensions(root)).filter((other) => other !== extension.package && shortName(other) === extension.name);
146
+ if (others.length > 0) {
147
+ throw new Refusal(`The campaign uses ${others[0]}, with the same name, ${extension.name}: take it away with package remove ${others[0]} first. Nothing changed in the campaign.`, "same-name", {
148
+ name: extension.name,
149
+ other: others[0],
150
+ });
151
+ }
152
+ // Its code is checked before the campaign lists it: a package that would not work is never added.
153
+ const commands = runsCode(extension)
154
+ ? await packageCommandNames(extension, context).catch((error) => {
155
+ const why = error instanceof Error ? error.message : String(error);
156
+ throw new Refusal(`The code of ${extension.package} cannot be used: ${why}. Nothing changed in the campaign.`, "code-broken", { name: extension.package, why });
157
+ })
158
+ : [];
159
+ const listedBefore = listedExtensions(root);
160
+ const already = listedBefore[extension.package] === extension.version && !reinstall;
161
+ const verified = isVerified(extension.package, extension.linked);
162
+ if (listedBefore[extension.package] !== extension.version) {
163
+ changeExtensions(root, { ...listedBefore, [extension.package]: extension.version });
164
+ appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: extension.package, version: extension.version, verified }));
165
+ }
166
+ // The campaign's code anew, the new one's included: their hooks are called at the next change, never skipped (D-514).
167
+ await loadCampaignCode(context);
168
+ return {
169
+ kind: "installed",
170
+ extension,
171
+ verified,
172
+ commands,
173
+ codeLeftOut: (extension.code !== undefined || extension.page !== undefined) && !runsCode(extension),
174
+ already,
175
+ ...modePart(root, context, extension),
176
+ tools: toolsNote(context),
177
+ };
178
+ }
179
+ /** The npm names of ours a name alone may be, with its version if given: an extension's, then a game system's; a system of the engine's list first (D-513). */
180
+ function ourNames(name) {
181
+ const names = [`${verifiedScope}${name}`, `${verifiedScope}system-${name}`];
182
+ const bare = name.replace(/(?<=.)@[^@/]*$/, "");
183
+ return ourSystems.some((system) => comparableText(system.name) === comparableText(bare)) ? [names[1], names[0]] : names;
184
+ }
185
+ /**
186
+ * Installs a game system on this computer (D-485), for a new campaign: the campaign keeps the one its setup chose. One not ours only with the player's yes,
187
+ * as an extension (D-441, D-478); a system that does not read is no system, whatever npm installed.
188
+ */
189
+ async function systemInstalled(root, context, spec, name, described) {
190
+ const local = isLocalSpec(spec);
191
+ const named = shortName(described.name).replace(/^system-/, "");
192
+ const unread = apiProblem(described.api, "system");
193
+ if (unread !== undefined) {
194
+ throw apiRefusal(described, unread);
195
+ }
196
+ const taken = systemsHere(root, context).find((one) => comparableText(one.name) === comparableText(named) && one.package !== described.name);
197
+ if (taken !== undefined) {
198
+ throw new Refusal(`There is already a game system named ${taken.name} on this computer${taken.package === undefined ? ", the engine's own" : `, from ${taken.package}`}: ${described.name} would take its name. Nothing changed.`, "system-taken", { name: described.name, system: taken.name });
199
+ }
200
+ if (!isVerified(described.name, local)) {
201
+ await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, local ? ` (${described.name} ${described.version})` : "");
202
+ }
203
+ const why = await context.packages.install(spec);
204
+ if (why !== undefined) {
205
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
206
+ }
207
+ [...context.systemFolders, ...(context.extensionFolders ?? [])].forEach((folder) => files().refresh(folder));
208
+ const installed = installedExtensionFolder(context, described.name);
209
+ // The player's yes holds for this version and these files: its code runs at the next start of the game's server (D-478, D-511).
210
+ if (!isVerified(described.name, local) && !local && installed !== undefined) {
211
+ recordConsent(installed, described.name, described.version);
212
+ }
213
+ const system = systemsHere(root, context).find((one) => one.package === described.name);
214
+ if (system === undefined) {
215
+ throw new Refusal(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`, "system-unread", {
216
+ name: described.name,
217
+ });
218
+ }
219
+ appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: system.verified, kind: "system" }));
220
+ const plays = readTextSetting(root, "system");
221
+ const loaded = system.used && system.code ? await loadedNow(context, system.name) : undefined;
222
+ return { kind: "system-installed", system, ...(plays === undefined ? {} : { plays }), ...(loaded === undefined ? {} : { loaded }) };
223
+ }
224
+ /** The code of the system the campaign plays, installed now, loaded at once when the process has none of it yet, as config system does (D-513 (1)). */
225
+ async function loadedNow(context, name) {
226
+ // A version the process has already loaded runs until it starts again.
227
+ const code = context.systemCode;
228
+ if (code === undefined || Object.hasOwn(code, name)) {
229
+ return undefined;
230
+ }
231
+ await loadNewSystemCode(context);
232
+ const loaded = code[name];
233
+ return loaded === undefined ? undefined : "code" in loaded ? { runs: true } : { why: "refused" in loaded ? `it ${loaded.refused}` : loaded.problem };
234
+ }
235
+ /**
236
+ * Installs a language package on this computer (D-485 (3)): texts the dashboard shows, never code, so no yes is asked; refused, and taken off again, when its
237
+ * phrases lose a {name} or turn the order of a text. It takes the place of another package of the same language.
238
+ */
239
+ async function languageInstalled(root, context, spec, described) {
240
+ if (described.code === true || described.dependencies === true) {
241
+ throw new Refusal(`${described.name} says it is a language, and brings code or needs other packages: a language package is texts only. Nothing changed.`, "language-code", {
242
+ name: described.name,
243
+ });
244
+ }
245
+ const before = installedLanguages(context.extensionFolders ?? []);
246
+ const packages = context.packages;
247
+ const why = await packages.install(spec);
248
+ if (why !== undefined) {
249
+ throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
250
+ }
251
+ (context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
252
+ const folder = installedExtensionFolder(context, described.name);
253
+ let checked;
254
+ let pack;
255
+ try {
256
+ pack = readLanguagePack(folder ?? "");
257
+ checked = languagePackProblems(pack, Object.keys(pagePhrases(context)));
258
+ }
259
+ catch (error) {
260
+ checked = { problems: [error instanceof Error ? error.message : String(error)], missing: 0 };
261
+ pack = { package: described.name, version: described.version, folder: folder ?? "", code: "", name: described.name };
262
+ }
263
+ if (checked.problems.length > 0) {
264
+ await packages.uninstall(described.name);
265
+ // An update refused leaves the version that was there before.
266
+ const earlier = before.find((one) => one.package === described.name);
267
+ const back = earlier === undefined || isLocalSpec(spec) ? undefined : await packages.install(`${earlier.package}@${earlier.version}`).then((why) => (why === undefined ? earlier.version : undefined));
268
+ (context.extensionFolders ?? []).forEach((one) => files().refresh(one));
269
+ const why = checked.problems.join("; ");
270
+ const message = `${described.name} cannot be used: ${why}. ${back === undefined ? "It was taken off this computer." : `Version ${back} stays.`}`;
271
+ throw back === undefined ? new Refusal(message, "language-refused", { name: described.name, why }) : new Refusal(message, "language-kept", { name: described.name, why, version: back });
272
+ }
273
+ // One language, one package: the one before for the same code goes (D-485 (3)).
274
+ const replaced = before.find((one) => one.code.toLowerCase() === pack.code.toLowerCase() && one.package !== described.name);
275
+ if (replaced !== undefined) {
276
+ await packages.uninstall(replaced.package);
277
+ (context.extensionFolders ?? []).forEach((one) => files().refresh(one));
278
+ }
279
+ const language = languagesHere(context).find((one) => one.package === described.name);
280
+ appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: language.verified, kind: "language" }));
281
+ return { kind: "language-installed", language, ...(replaced === undefined ? {} : { replaced: replaced.package }), missing: checked.missing };
282
+ }
283
+ /**
284
+ * The names of a system just installed in the chat, which the host's list of tools may not have yet (D-518): its counter, its rest and its coins, those that
285
+ * are not the neutral ones; nothing when it names none of them.
286
+ */
287
+ function namesNote(root, context, system) {
288
+ let examples;
289
+ try {
290
+ examples = campaignExamples(root, context);
291
+ }
292
+ catch {
293
+ return "";
294
+ }
295
+ const own = (name) => (examples[name] === neutralExamples[name] ? undefined : examples[name]);
296
+ const coins = [own("coin"), own("smallCoin")].filter((coin) => coin !== undefined).join(" and ");
297
+ const counter = own("counter");
298
+ const names = [counter === undefined ? undefined : `${counter} for damage`, own("rest"), coins === "" ? undefined : coins].filter((name) => name !== undefined);
299
+ return names.length === 0 ? "" : ` The commands' descriptions may keep neutral examples until a new chat: in ${system} use its own names, such as ${names.join(", ")}.`;
300
+ }
301
+ /** The dashboard's phrases, by their English, as its curated Italian lists them all; none where the built page is not here. */
302
+ function pagePhrases(context) {
303
+ try {
304
+ return JSON.parse(files().text(join(context.pageFolder ?? "", "i18n", "it.json")) ?? "{}");
305
+ }
306
+ catch {
307
+ return {};
308
+ }
309
+ }
310
+ /** A package made for an API this engine does not read: one newer than the engine, which an update of the engine reads, or one older, which a newer version of it fixes. */
311
+ function apiRefusal(described, unread) {
312
+ const newer = described.api !== undefined && described.api > packageApi;
313
+ return new Refusal(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`, newer ? "engine-too-old" : "package-too-old", {
314
+ name: described.name,
315
+ version: described.version,
316
+ });
317
+ }
318
+ /** The extension's part of the instructions for the mode the campaign is in, which the chat going on has not been given. */
319
+ function modePart(root, context, extension) {
320
+ const mode = campaignMode(root, campaignWorld(root, context)).replace(" ", "-");
321
+ const part = extension.parts[mode]?.text;
322
+ return part === undefined ? {} : { part };
323
+ }
324
+ /** When the master can call the new commands: on the command line at once; in a chat, as the app in use hears new tools. */
325
+ function toolsNote(context) {
326
+ const host = context.host?.() ?? "";
327
+ if (context.host === undefined) {
328
+ return "";
329
+ }
330
+ if (/codex/i.test(host)) {
331
+ return "Codex sees them only once it is closed and opened again: tell the player.";
332
+ }
333
+ if (/claude-ai|claude desktop/i.test(host)) {
334
+ return "This app sees them only once it is closed and opened again: tell the player.";
335
+ }
336
+ return "They are yours from the player's next message.";
337
+ }