rpg-engine 0.7.0 → 0.8.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 (393) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.js +13 -13
  4. package/dist/campaign/create-campaign.js +10 -1
  5. package/dist/campaign/host-files.d.ts +2 -1
  6. package/dist/campaign/host-files.js +11 -11
  7. package/dist/campaign/index.d.ts +1 -1
  8. package/dist/campaign/index.js +1 -1
  9. package/dist/campaign/settings.d.ts +55 -64
  10. package/dist/campaign/settings.js +171 -174
  11. package/dist/{cli.js → cli/cli.js} +3 -3
  12. package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
  13. package/dist/{command-line.js → cli/command-line.js} +21 -20
  14. package/dist/commands/advance.d.ts +1 -1
  15. package/dist/commands/advance.js +7 -7
  16. package/dist/commands/ask.d.ts +1 -8
  17. package/dist/commands/ask.js +16 -29
  18. package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
  19. package/dist/commands/{change.js → change/change.js} +46 -52
  20. package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
  21. package/dist/commands/{game-damage.js → change/damage.js} +3 -3
  22. package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
  23. package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
  24. package/dist/commands/config.d.ts +4 -4
  25. package/dist/commands/config.js +142 -138
  26. package/dist/commands/effect.d.ts +1 -1
  27. package/dist/commands/effect.js +11 -12
  28. package/dist/commands/find.d.ts +4 -4
  29. package/dist/commands/find.js +2 -2
  30. package/dist/commands/image.js +6 -6
  31. package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
  32. package/dist/commands/{import.js → import/import.js} +101 -101
  33. package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
  34. package/dist/commands/{game-import.js → import/run.js} +13 -12
  35. package/dist/commands/index.js +7 -7
  36. package/dist/commands/init.js +3 -3
  37. package/dist/commands/install.js +1 -1
  38. package/dist/commands/instructions.js +6 -6
  39. package/dist/commands/mode.d.ts +2 -2
  40. package/dist/commands/mode.js +8 -8
  41. package/dist/commands/mood.js +4 -4
  42. package/dist/commands/move.js +13 -20
  43. package/dist/commands/package.d.ts +2 -2
  44. package/dist/commands/package.js +138 -93
  45. package/dist/commands/rename.js +3 -3
  46. package/dist/commands/reveal.js +29 -18
  47. package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
  48. package/dist/commands/{roll.js → roll/roll.js} +69 -69
  49. package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
  50. package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
  51. package/dist/commands/rules.d.ts +2 -2
  52. package/dist/commands/rules.js +3 -3
  53. package/dist/commands/save.d.ts +1 -1
  54. package/dist/commands/save.js +18 -18
  55. package/dist/commands/scene.d.ts +4 -4
  56. package/dist/commands/scene.js +31 -28
  57. package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
  58. package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
  59. package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
  60. package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
  61. package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
  62. package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
  63. package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
  64. package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
  65. package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
  66. package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
  67. package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
  68. package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
  69. package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
  70. package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
  71. package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
  72. package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
  73. package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
  74. package/dist/commands/{game-events.js → shared/events.js} +20 -22
  75. package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
  76. package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
  77. package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
  78. package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
  79. package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
  80. package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
  81. package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
  82. package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
  83. package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
  84. package/dist/commands/{game-images.js → shared/images.js} +7 -6
  85. package/dist/commands/shared/inputs.d.ts +9 -0
  86. package/dist/commands/shared/inputs.js +12 -0
  87. package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
  88. package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
  89. package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
  90. package/dist/commands/{game-knowledge.js → shared/knowledge.js} +42 -42
  91. package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
  92. package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
  93. package/dist/commands/{game-library.js → shared/library.js} +70 -50
  94. package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
  95. package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
  96. package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
  97. package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
  98. package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
  99. package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
  100. package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
  101. package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
  102. package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
  103. package/dist/commands/{game-money.js → shared/money.js} +4 -4
  104. package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
  105. package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
  106. package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
  107. package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
  108. package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
  109. package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
  110. package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
  111. package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
  112. package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
  113. package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
  114. package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
  115. package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
  116. package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
  117. package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
  118. package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
  119. package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
  120. package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
  121. package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
  122. package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
  123. package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
  124. package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
  125. package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
  126. package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
  127. package/dist/commands/{parts.js → shared/parts.js} +4 -4
  128. package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
  129. package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
  130. package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
  131. package/dist/commands/{problems.js → shared/problems.js} +21 -22
  132. package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
  133. package/dist/commands/{progression.js → shared/progression.js} +4 -4
  134. package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
  135. package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
  136. package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
  137. package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
  138. package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
  139. package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
  140. package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
  141. package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
  142. package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +2 -2
  143. package/dist/commands/{game-rules.js → shared/rules.js} +4 -4
  144. package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
  145. package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
  146. package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
  147. package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
  148. package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
  149. package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
  150. package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
  151. package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
  152. package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
  153. package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
  154. package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
  155. package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
  156. package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
  157. package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
  158. package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
  159. package/dist/commands/{game-time.js → shared/time.js} +6 -6
  160. package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
  161. package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
  162. package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
  163. package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
  164. package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
  165. package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
  166. package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
  167. package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
  168. package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
  169. package/dist/commands/{game-world.js → shared/world.js} +72 -76
  170. package/dist/commands/show.d.ts +1 -1
  171. package/dist/commands/show.js +32 -17
  172. package/dist/commands/status.d.ts +1 -1
  173. package/dist/commands/status.js +28 -28
  174. package/dist/commands/thoughts.js +3 -3
  175. package/dist/commands/trade.js +9 -10
  176. package/dist/commands/translate.d.ts +1 -1
  177. package/dist/commands/translate.js +3 -3
  178. package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
  179. package/dist/commands/{game-open.js → travel/open.js} +4 -5
  180. package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
  181. package/dist/commands/{route.js → travel/route.js} +9 -10
  182. package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
  183. package/dist/commands/{travel.js → travel/travel.js} +19 -21
  184. package/dist/commands/validate.js +5 -5
  185. package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
  186. package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
  187. package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
  188. package/dist/commands/{game-view-map.js → view/map.js} +15 -16
  189. package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
  190. package/dist/commands/{game-view-place.js → view/place.js} +108 -108
  191. package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
  192. package/dist/commands/{view.js → view/view.js} +35 -35
  193. package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
  194. package/dist/commands/{game-view-world.js → view/world.js} +7 -7
  195. package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
  196. package/dist/commands/{game-here.js → write/here.js} +18 -12
  197. package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
  198. package/dist/commands/{write.js → write/write.js} +44 -41
  199. package/dist/confirm/confirm.d.ts +2 -0
  200. package/dist/confirm/confirm.js +15 -5
  201. package/dist/core/consents.d.ts +3 -2
  202. package/dist/core/consents.js +43 -4
  203. package/dist/core/context.d.ts +8 -6
  204. package/dist/core/context.js +4 -2
  205. package/dist/core/download.js +16 -5
  206. package/dist/core/files.d.ts +6 -1
  207. package/dist/core/files.js +47 -21
  208. package/dist/core/formula.d.ts +7 -2
  209. package/dist/core/formula.js +63 -66
  210. package/dist/core/instruction-parts.js +1 -1
  211. package/dist/core/mood.d.ts +0 -1
  212. package/dist/core/mood.js +3 -3
  213. package/dist/core/package-api.d.ts +11 -0
  214. package/dist/core/package-api.js +2 -1
  215. package/dist/core/package-declarations.d.ts +9 -9
  216. package/dist/core/package-declarations.js +3 -3
  217. package/dist/core/process-mark.d.ts +8 -0
  218. package/dist/core/process-mark.js +72 -0
  219. package/dist/core/registry.d.ts +5 -0
  220. package/dist/core/registry.js +10 -0
  221. package/dist/core/session-store.d.ts +0 -1
  222. package/dist/core/session-store.js +11 -14
  223. package/dist/core/store.d.ts +4 -0
  224. package/dist/core/store.js +29 -8
  225. package/dist/core/text.d.ts +4 -0
  226. package/dist/core/text.js +11 -2
  227. package/dist/core/yaml-file.js +2 -2
  228. package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
  229. package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
  230. package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
  231. package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
  232. package/dist/dashboard/app.js +13 -13
  233. package/dist/dashboard/asked.js +1 -1
  234. package/dist/dashboard/dice/burn.js +1 -1
  235. package/dist/dashboard/dice/stage.js +1 -1
  236. package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
  237. package/dist/dashboard/{help.js → help/help.js} +6 -6
  238. package/dist/dashboard/journal.js +1 -1
  239. package/dist/dashboard/kit.js +6 -5
  240. package/dist/dashboard/labels.js +7 -3
  241. package/dist/dashboard/markdown.js +1 -1
  242. package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
  243. package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
  244. package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
  245. package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
  246. package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
  247. package/dist/dashboard/party.js +1 -1
  248. package/dist/dashboard/person-panel.js +2 -13
  249. package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
  250. package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
  251. package/dist/dashboard/scene.js +4 -4
  252. package/dist/dashboard/settings.js +1 -1
  253. package/dist/dashboard/sheet.js +3 -3
  254. package/dist/dashboard/top.js +2 -2
  255. package/dist/dashboard/turns.js +2 -2
  256. package/dist/dashboard/widgets.js +1 -1
  257. package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
  258. package/dist/dashboard/{lore.js → world/known.js} +1 -1
  259. package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
  260. package/dist/dashboard/{world-map.js → world/map.js} +1 -1
  261. package/dist/dashboard/{world.js → world/world.js} +14 -14
  262. package/dist/dice/evaluate.js +1 -1
  263. package/dist/dice/index.d.ts +2 -2
  264. package/dist/dice/index.js +2 -2
  265. package/dist/dice/notation.d.ts +2 -0
  266. package/dist/dice/notation.js +22 -4
  267. package/dist/documents/markup.js +2 -2
  268. package/dist/documents/read.js +29 -13
  269. package/dist/effects/effect.js +2 -5
  270. package/dist/extensions/extension.js +6 -8
  271. package/dist/extensions/index.d.ts +1 -4
  272. package/dist/extensions/index.js +1 -4
  273. package/dist/extensions/words.js +2 -1
  274. package/dist/{pictures → helpers}/briefs.js +17 -14
  275. package/dist/{pictures → helpers}/claude.js +8 -18
  276. package/dist/{pictures → helpers}/codex.js +3 -15
  277. package/dist/helpers/index.d.ts +7 -0
  278. package/dist/helpers/index.js +9 -0
  279. package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
  280. package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
  281. package/dist/images/images.js +7 -5
  282. package/dist/images/index.d.ts +1 -1
  283. package/dist/images/index.js +1 -1
  284. package/dist/importer/index.d.ts +1 -1
  285. package/dist/importer/index.js +1 -1
  286. package/dist/importer/work.d.ts +0 -2
  287. package/dist/importer/work.js +9 -30
  288. package/dist/instructions/index.d.ts +2 -0
  289. package/dist/instructions/index.js +10 -0
  290. package/dist/languages/index.d.ts +1 -1
  291. package/dist/languages/index.js +1 -1
  292. package/dist/languages/language-pack.js +15 -3
  293. package/dist/library/books.js +29 -83
  294. package/dist/{extensions → packages}/engine.d.ts +1 -1
  295. package/dist/{extensions → packages}/engine.js +1 -1
  296. package/dist/packages/index.d.ts +3 -0
  297. package/dist/packages/index.js +4 -0
  298. package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
  299. package/dist/{extensions/packages.js → packages/npm.js} +74 -45
  300. package/dist/page.d.ts +9 -11
  301. package/dist/page.js +1 -2
  302. package/dist/pages/check.js +31 -40
  303. package/dist/pages/containers.js +20 -20
  304. package/dist/pages/environment.js +15 -15
  305. package/dist/pages/index.d.ts +9 -9
  306. package/dist/pages/index.js +9 -9
  307. package/dist/pages/inheritance.d.ts +2 -1
  308. package/dist/pages/inheritance.js +24 -24
  309. package/dist/pages/load.js +7 -7
  310. package/dist/pages/maps.d.ts +20 -0
  311. package/dist/pages/maps.js +51 -1
  312. package/dist/pages/markdown.d.ts +2 -0
  313. package/dist/pages/markdown.js +110 -79
  314. package/dist/pages/page-file.d.ts +2 -1
  315. package/dist/pages/page-file.js +31 -29
  316. package/dist/pages/rename-page.d.ts +4 -1
  317. package/dist/pages/rename-page.js +7 -3
  318. package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
  319. package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
  320. package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
  321. package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
  322. package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
  323. package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
  324. package/dist/pages/system-pages.js +15 -15
  325. package/dist/pages/world.js +25 -19
  326. package/dist/pages/write-page.js +35 -34
  327. package/dist/player-notes/index.d.ts +1 -1
  328. package/dist/player-notes/index.js +1 -1
  329. package/dist/rules/page-search.js +3 -4
  330. package/dist/rules/rule-book.js +1 -1
  331. package/dist/rules/search.js +21 -21
  332. package/dist/rules/shown.js +1 -3
  333. package/dist/saves/saves.d.ts +2 -2
  334. package/dist/saves/saves.js +15 -3
  335. package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
  336. package/dist/server/dashboard/files.d.ts +59 -0
  337. package/dist/server/dashboard/files.js +326 -0
  338. package/dist/server/dashboard/index.d.ts +114 -0
  339. package/dist/server/dashboard/index.js +419 -0
  340. package/dist/server/dashboard/news.d.ts +39 -0
  341. package/dist/server/dashboard/news.js +390 -0
  342. package/dist/server/dashboard/player.d.ts +48 -0
  343. package/dist/server/dashboard/player.js +242 -0
  344. package/dist/server/dashboard/ports.d.ts +10 -0
  345. package/dist/server/dashboard/ports.js +15 -0
  346. package/dist/server/dashboard/writes.d.ts +58 -0
  347. package/dist/server/dashboard/writes.js +492 -0
  348. package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
  349. package/dist/{mcp-server.js → server/mcp.js} +57 -42
  350. package/dist/systems/game-system.d.ts +5 -3
  351. package/dist/systems/game-system.js +178 -149
  352. package/dist/systems/index.d.ts +1 -1
  353. package/dist/systems/index.js +1 -1
  354. package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
  355. package/dist/{testing.js → testing/index.js} +32 -18
  356. package/dist/{system-checks.js → testing/system-checks.js} +18 -12
  357. package/dist/themes/theme.d.ts +3 -3
  358. package/dist/themes/theme.js +14 -14
  359. package/dist/time/calendar.js +5 -2
  360. package/dist/triggers/trigger.js +5 -8
  361. package/instructions/dashboard-guide.md +2 -1
  362. package/instructions/play.md +1 -1
  363. package/package.json +5 -5
  364. package/dist/commands/game-maps.d.ts +0 -20
  365. package/dist/commands/game-maps.js +0 -51
  366. package/dist/dashboard-server.d.ts +0 -47
  367. package/dist/dashboard-server.js +0 -1830
  368. package/dist/pictures/index.d.ts +0 -7
  369. package/dist/pictures/index.js +0 -9
  370. /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
  371. /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
  372. /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
  373. /package/dist/commands/{notes.js → shared/notes.js} +0 -0
  374. /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
  375. /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
  376. /package/dist/dashboard/{people.js → packages/people.js} +0 -0
  377. /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
  378. /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
  379. /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
  380. /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
  381. /package/dist/{pictures → helpers}/chosen.js +0 -0
  382. /package/dist/{pictures → helpers}/claude.d.ts +0 -0
  383. /package/dist/{pictures → helpers}/codex.d.ts +0 -0
  384. /package/dist/{pictures → helpers}/stop.d.ts +0 -0
  385. /package/dist/{pictures → helpers}/stop.js +0 -0
  386. /package/dist/{pictures → helpers}/svg.d.ts +0 -0
  387. /package/dist/{pictures → helpers}/svg.js +0 -0
  388. /package/dist/{extensions → packages}/tarball.d.ts +0 -0
  389. /package/dist/{extensions → packages}/tarball.js +0 -0
  390. /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
  391. /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
  392. /package/dist/{player-acts.js → server/player-acts.js} +0 -0
  393. /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
@@ -1,13 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
- // A package's widget on someone of the party (D-514, D-516). One that says their state (its chip) is drawn as a panel, as the 5e's death saves (D-461):
3
- // its good counts on the start side as circles, its bad ones on the end side as squares, its lead's word between them with the package's figure over it,
4
- // tinted by the lead's tone, greyed when dead by its rules; large under the name and in the card at hand, one line in a row of the turns, small in the
5
- // party's strip; with one side only, the word beside it, the two in the middle. Any other is a small card of its package among the boxes of values under the
6
- // name, as the rerolls of a lock.
7
- import { useContext } from "preact/hooks";
8
- import { Figure, textOf, Value, WidgetsContext } from "./extension-widgets.js";
9
2
  import { statusIcons } from "./icons.js";
10
- import { usePageModule } from "./page-code.js";
3
+ import { usePageModule } from "./packages/page-code.js";
4
+ import { Figure, textOf, Value } from "./packages/widgets.js";
11
5
  import { numberText, t } from "./text.js";
12
6
  /** The widgets on someone of the party that say their state (a `chip`) and draw it, in their order: each the panel of A (D-516). */
13
7
  export function personShown(widgets, name) {
@@ -21,11 +15,6 @@ export function personBoxes(widgets, name) {
21
15
  export function saysState({ widget, shows }) {
22
16
  return shows.chip !== undefined && widget.own.place === "person";
23
17
  }
24
- /** The widgets on someone of the party, from the page's widgets as last read: their panels and their boxes. */
25
- export function usePerson(name) {
26
- const widgets = useContext(WidgetsContext);
27
- return { panels: personShown(widgets, name), boxes: personBoxes(widgets, name) };
28
- }
29
18
  /**
30
19
  * A package's widget on someone as boxes of the line under their name, as the sheet's own values (D-516): a count with its label, its marks or its number; a
31
20
  * lead under the widget's title, its words and value; each value under its label.
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  // Where the player's character goes when the master asks (D-332, ASK-11): the map of the place over the whole page, its squares at least 44 px, those the
3
3
  // character can still reach in gold; a square touched is chosen, then sent. A square can also be written, such as E4, from the keyboard.
4
4
  import { useEffect, useRef, useState } from "preact/hooks";
5
- import { Icon } from "./icons.js";
6
- import { PlaceMap } from "./place-map-view.js";
7
- import { isStandable, squareOf } from "./place-map.js";
8
- import { t } from "./text.js";
5
+ import { Icon } from "../icons.js";
6
+ import { t } from "../text.js";
7
+ import { PlaceMap } from "./map-view.js";
8
+ import { isStandable, squareOf } from "./map.js";
9
9
  export function MapSheet({ map, place, question, onPick, onClose }) {
10
10
  const [selected, setSelected] = useState();
11
11
  const [typed, setTyped] = useState("");
@@ -5,17 +5,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
5
5
  // is where in words, the map's twin.
6
6
  import { Fragment } from "preact";
7
7
  import { useContext, useEffect, useRef, useState } from "preact/hooks";
8
- import { TalkName, usePlayerActs } from "./act-names.js";
9
- import { CardHead } from "./card.js";
10
- import { WidgetsContext } from "./extension-widgets.js";
11
- import { Glass, GlassDefs } from "./glass.js";
12
- import { iconPath } from "./icons.js";
13
- import { strangerLabel } from "./labels.js";
14
- import { sideIcons, sideOf } from "./party.js";
15
- import { columnName, exitSide, floorLoops, groundKinds, isSolid, isStandable, isWalled, kindAt, nextTo, piecesOf, squareName, squareOf, symbolAt, tracedLoop } from "./place-map.js";
16
- import { conditionsPref, tokenSymbolsPref, useChoice, usePref } from "./prefs.js";
17
- import { personState, statusMarks, statusWords } from "./status.js";
18
- import { t } from "./text.js";
8
+ import { TalkName, usePlayerActs } from "../acts/names.js";
9
+ import { CardHead } from "../card.js";
10
+ import { Glass, GlassDefs } from "../glass.js";
11
+ import { iconPath } from "../icons.js";
12
+ import { strangerLabel } from "../labels.js";
13
+ import { WidgetsContext } from "../packages/widgets.js";
14
+ import { sideIcons, sideOf } from "../party.js";
15
+ import { conditionsPref, tokenSymbolsPref, useChoice, usePref } from "../prefs.js";
16
+ import { personState, statusMarks, statusWords } from "../status.js";
17
+ import { t } from "../text.js";
18
+ import { columnName, exitSide, floorLoops, groundKinds, isSolid, isStandable, isWalled, kindAt, nextTo, piecesOf, squareName, squareOf, symbolAt, tracedLoop } from "./map.js";
19
19
  // How wide a square is drawn, in pixels.
20
20
  const size = 40;
21
21
  // The order of who is where under the map.
@@ -2,21 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
2
2
  // The Scene section (D-309, VIEW-6, D-444): where the party is, its picture with the places around it, its name, what holds there and its text; the open
3
3
  // scene and who is in it; outside a scene who is there of those the character knows; the map. While the scene goes by turns, the turns first.
4
4
  import { useContext, useEffect, useRef, useState } from "preact/hooks";
5
- import { TalkName } from "./act-names.js";
5
+ import { TalkName } from "./acts/names.js";
6
6
  import { sectionAddress } from "./address.js";
7
- import { WidgetCards, WidgetsContext } from "./extension-widgets.js";
8
7
  import { effectLabel, sinceDateLabel, terrainLabel } from "./game-words.js";
9
8
  import { cardIcons, Icon } from "./icons.js";
10
9
  import { phraseLabel, sceneTypeLabel, strangerLabel } from "./labels.js";
11
10
  import { biomeLabel, biomes } from "./map-symbols.js";
12
11
  import { InlineText, knowersOf, Markdown } from "./markdown.js";
12
+ import { WidgetCards, WidgetsContext } from "./packages/widgets.js";
13
13
  import { sideOf, Token } from "./party.js";
14
- import { PlaceMap } from "./place-map-view.js";
14
+ import { PlaceMap } from "./place/map-view.js";
15
15
  import { Card } from "./sheet.js";
16
16
  import { downTint, personState, StatusPip } from "./status.js";
17
17
  import { foldedText, t } from "./text.js";
18
18
  import { CharacterCard, hasTurns, TurnBand, TurnsCard } from "./turns.js";
19
- import { BiomeSwatch } from "./world.js";
19
+ import { BiomeSwatch } from "./world/world.js";
20
20
  // How long the band takes to come in or go out, the style sheet's --short, as the master's question folds.
21
21
  const bandTime = 250;
22
22
  /**
@@ -3,11 +3,11 @@ import { useContext, useEffect, useRef, useState } from "preact/hooks";
3
3
  import { sectionLabel } from "./address.js";
4
4
  import { changeSetting, readSettings } from "./api.js";
5
5
  import { coinDesignPref, coinDesigns, coinLook, coinMetals, coinPref, diceEdgesPref, diceLook, diceSetPref, diceSets, texturePath } from "./dice/sets.js";
6
- import { WidgetsContext } from "./extension-widgets.js";
7
6
  import { CoinFace } from "./faces.js";
8
7
  import { DieSwatch, Icon } from "./icons.js";
9
8
  import { phraseLabel, settingLabel, valueLabel } from "./labels.js";
10
9
  import { LanguageChoice, languageLine } from "./language-choice.js";
10
+ import { WidgetsContext } from "./packages/widgets.js";
11
11
  import { PageHead } from "./pages.js";
12
12
  import { byHandPref, conditionsPref, readChoice, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange, writeChoice } from "./prefs.js";
13
13
  import { Confirm } from "./saves.js";
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { useContext, useEffect, useId, useRef, useState } from "preact/hooks";
3
- import { ActName, usePlayerActs } from "./act-names.js";
4
- import { itemVerbs } from "./acts.js";
3
+ import { itemVerbs } from "./acts/acts.js";
4
+ import { ActName, usePlayerActs } from "./acts/names.js";
5
5
  import { readExplanations } from "./api.js";
6
6
  import { CardHeader, useOpen } from "./card.js";
7
7
  import { FixedColumns } from "./columns.js";
8
- import { WidgetCards, WidgetsContext } from "./extension-widgets.js";
9
8
  import { besideLabel, memberPlaceLabel } from "./game-words.js";
10
9
  import { cardIcons, DieIcon, Icon } from "./icons.js";
11
10
  import { fieldLabel, groupLabels, phraseLabel, readableIds, rollLabel, shownNotation, shownText } from "./labels.js";
12
11
  import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "./layout.js";
13
12
  import { knowersOf, Markdown, plainLine } from "./markdown.js";
14
13
  import { MoodFace, moodLabel } from "./mood.js";
14
+ import { WidgetCards, WidgetsContext } from "./packages/widgets.js";
15
15
  import { MemberToken } from "./party.js";
16
16
  import { PersonBoxes, personBoxes, personFields, PersonPanel, personShown } from "./person-panel.js";
17
17
  import { requestedRow, useRequested } from "./requested.js";
@@ -7,11 +7,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
7
7
  import { Fragment } from "preact";
8
8
  import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
9
9
  import { menuPages, packagePages, sectionAddress, sectionLabel, sections } from "./address.js";
10
- import { Drawn, WidgetChips } from "./extension-widgets.js";
11
10
  import { calendarDayLabel, gameDateLabel } from "./game-words.js";
12
11
  import { Icon } from "./icons.js";
13
12
  import { Master } from "./master.js";
14
- import { ownKey } from "./page-code.js";
13
+ import { ownKey } from "./packages/page-code.js";
14
+ import { Drawn, WidgetChips } from "./packages/widgets.js";
15
15
  import { usePrefChange } from "./prefs.js";
16
16
  import { t } from "./text.js";
17
17
  import { pickTheme, shownTheme } from "./theme.js";
@@ -4,12 +4,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
4
4
  // strip that lights up on their turn, their counter, the party's as numbers and a foe's in words, their state as icons, what they keep, the death saves at 0;
5
5
  // and the player's character's card, the fields and groups of its sheet the system names. The page never decides a rule: it shows.
6
6
  import { useContext, useEffect, useRef } from "preact/hooks";
7
- import { TalkName } from "./act-names.js";
7
+ import { TalkName } from "./acts/names.js";
8
8
  import { CardHead, CardHeader, useOpen } from "./card.js";
9
- import { WidgetsContext } from "./extension-widgets.js";
10
9
  import { Icon, iconPath } from "./icons.js";
11
10
  import { fieldLabel, itemLabel, phraseLabel, shownText, strangerLabel } from "./labels.js";
12
11
  import { stripCounter } from "./layout.js";
12
+ import { WidgetsContext } from "./packages/widgets.js";
13
13
  import { sideOf, Token } from "./party.js";
14
14
  import { PersonPanel, personShown } from "./person-panel.js";
15
15
  import { SheetAtHand } from "./sheet.js";
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  // The widgets of a value (D-273, D-284): pips, a bar, a track centred on zero, a number's progress, chips or a list of sentences; each says its value in words
3
3
  // for a screen reader.
4
- import { ActName, usePlayerActs } from "./act-names.js";
4
+ import { ActName, usePlayerActs } from "./acts/names.js";
5
5
  import { Coins } from "./coins.js";
6
6
  import { besideLabel, burnsLabel, effectEndLabel, effectLabel, effectName } from "./game-words.js";
7
7
  import { itemLabel, shownText } from "./labels.js";
@@ -4,13 +4,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
4
4
  // the story lit, the scenes and deadlines marked, and the day chosen with what it holds, its scenes with their place leading to the Journal. Without a
5
5
  // calendar start, the days of the story in the same rows, by their number.
6
6
  import { useEffect, useRef, useState } from "preact/hooks";
7
- import { sectionAddress } from "./address.js";
8
- import { calendarDateOf, dayMarks, monthAt, monthOffsetOf, storyDays } from "./calendar.js";
9
- import { CardHead, useMedia } from "./card.js";
10
- import { calendarDayLabel, calendarMonthLabel, gameDateLabel, seasonLabel } from "./game-words.js";
11
- import { Icon, iconPath } from "./icons.js";
12
- import { Deadline } from "./journal.js";
13
- import { arrowStep, capitalized, isolated, listText, t } from "./text.js";
7
+ import { sectionAddress } from "../address.js";
8
+ import { CardHead, useMedia } from "../card.js";
9
+ import { calendarDayLabel, calendarMonthLabel, gameDateLabel, seasonLabel } from "../game-words.js";
10
+ import { Icon, iconPath } from "../icons.js";
11
+ import { Deadline } from "../journal.js";
12
+ import { arrowStep, capitalized, isolated, listText, t } from "../text.js";
13
+ import { calendarDateOf, dayMarks, monthAt, monthOffsetOf, storyDays } from "./days.js";
14
14
  export function CalendarTab({ calendar }) {
15
15
  const narrow = useMedia("(max-width: 600px)");
16
16
  const row = narrow ? 5 : 10;
@@ -1,4 +1,4 @@
1
- import { foldedText } from "./text.js";
1
+ import { foldedText } from "../text.js";
2
2
  /** The groups of the lore, in the order the list shows them: people, places, factions, creatures, items, tales and events, then the rest. */
3
3
  const loreGroups = ["people", "places", "factions", "creatures", "items", "tales", "other"];
4
4
  /** The group a page belongs to, by its type. */
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "preact/hooks";
3
- import { sectionAddress } from "./address.js";
4
- import { pictureAddress, readView } from "./api.js";
5
- import { useMedia } from "./card.js";
6
- import { Icon } from "./icons.js";
7
- import { documentLook, foundLore, groupedLore, knownTo, loreGroupOf } from "./lore.js";
8
- import { placeKindLabel, placeKinds } from "./map-symbols.js";
9
- import { knowersOf, Markdown, plainLine } from "./markdown.js";
10
- import { Token } from "./party.js";
11
- import { arrowStep, capitalized, foldedText, t } from "./text.js";
3
+ import { sectionAddress } from "../address.js";
4
+ import { pictureAddress, readView } from "../api.js";
5
+ import { useMedia } from "../card.js";
6
+ import { Icon } from "../icons.js";
7
+ import { placeKindLabel, placeKinds } from "../map-symbols.js";
8
+ import { knowersOf, Markdown, plainLine } from "../markdown.js";
9
+ import { Token } from "../party.js";
10
+ import { arrowStep, capitalized, foldedText, t } from "../text.js";
11
+ import { documentLook, foundLore, groupedLore, knownTo, loreGroupOf } from "./known.js";
12
12
  // From this width the reader stands beside the list.
13
13
  const wide = "(min-width: 900px)";
14
14
  /**
@@ -1,4 +1,4 @@
1
- import { numberText, t } from "./text.js";
1
+ import { numberText, t } from "../text.js";
2
2
  // How each kind of way wanders.
3
3
  const wander = {
4
4
  river: { share: 0.09, most: 1.6, bend: 7 },
@@ -4,20 +4,20 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
4
4
  // wheel, touch and the keys; a place opens its card. The page draws only what view gives with map and world (VIEW-7, VIEW-11): a place the character does not
5
5
  // know never reaches it.
6
6
  import { useEffect, useMemo, useRef, useState } from "preact/hooks";
7
- import { sectionAddress } from "./address.js";
8
- import { pictureAddress, readMap, readView, readWorld } from "./api.js";
9
- import { WidgetCards } from "./extension-widgets.js";
10
- import { fromLabel, terrainLabel } from "./game-words.js";
11
- import { Glass, GlassDefs } from "./glass.js";
12
- import { Icon } from "./icons.js";
13
- import { biomeLabel, biomes, placeKindLabel, placeKinds, symbolRadius } from "./map-symbols.js";
14
- import { plainLine } from "./markdown.js";
15
- import { PageHead } from "./pages.js";
16
- import { PageTabs } from "./tabs.js";
17
- import { t } from "./text.js";
18
- import { CalendarTab } from "./world-calendar.js";
19
- import { DocumentsTab, LoreTab } from "./world-lore.js";
20
- import { clampScale, fading, fitView, hexCorners, hexesOf, lengthText, liftedOf, mapLayout, mapNameOf, mapPart, marksOf, nameRun, nameShares, pathOf, placeAreaLabels, placeLabels, regionEdges, riverOutline, scaleBar, trailCourse, waterOf, wayShapes, waysOf, zoomedView, } from "./world-map.js";
7
+ import { sectionAddress } from "../address.js";
8
+ import { pictureAddress, readMap, readView, readWorld } from "../api.js";
9
+ import { fromLabel, terrainLabel } from "../game-words.js";
10
+ import { Glass, GlassDefs } from "../glass.js";
11
+ import { Icon } from "../icons.js";
12
+ import { biomeLabel, biomes, placeKindLabel, placeKinds, symbolRadius } from "../map-symbols.js";
13
+ import { plainLine } from "../markdown.js";
14
+ import { WidgetCards } from "../packages/widgets.js";
15
+ import { PageHead } from "../pages.js";
16
+ import { PageTabs } from "../tabs.js";
17
+ import { t } from "../text.js";
18
+ import { CalendarTab } from "./calendar.js";
19
+ import { DocumentsTab, LoreTab } from "./lore.js";
20
+ import { clampScale, fading, fitView, hexCorners, hexesOf, lengthText, liftedOf, mapLayout, mapNameOf, mapPart, marksOf, nameRun, nameShares, pathOf, placeAreaLabels, placeLabels, regionEdges, riverOutline, scaleBar, trailCourse, waterOf, wayShapes, waysOf, zoomedView, } from "./map.js";
21
21
  // How wide the map shows around the party at first on a phone, in km; how much a step of the zoom and of the keys moves.
22
22
  const phoneSpan = 46;
23
23
  const zoomStep = 1.5;
@@ -49,7 +49,7 @@ function rollDiceTerm(term, nextFace) {
49
49
  let lastFace = die.value;
50
50
  while (matches(term.explode.condition, lastFace)) {
51
51
  if (++explosionCount > maxExplosions) {
52
- throw new DiceError("Too many explosions in a single roll.");
52
+ throw new DiceError("Too many explosions in a single roll: explode on fewer faces, such as 1d10!>=10.");
53
53
  }
54
54
  lastFace = nextFace(term.sides);
55
55
  if (term.explode.compound) {
@@ -1,6 +1,6 @@
1
1
  export { type CoinSide, coinSides, type CoinToss, mostCoins, tossCoins } from "./coins.ts";
2
- export { DiceError, parseNotation } from "./notation.ts";
3
- export { askOracle, type OracleAnswer, oracleOdds, oracleResult } from "./oracle.ts";
2
+ export { DiceError, diceProblem, parseNotation } from "./notation.ts";
3
+ export { askOracle, type OracleAnswer, oracleResult } from "./oracle.ts";
4
4
  export { createProof, fingerprint, sha256 } from "./proof.ts";
5
5
  export { type DiceRoll, type FaceSource, rollDice, type ThrownDie } from "./roll-dice.ts";
6
6
  export { type RandomTable, readRandomTable, rollOnTable, type TableRoll, type TableRow } from "./tables.ts";
@@ -1,7 +1,7 @@
1
1
  // Dice for any game: notation, digital or physical faces, proofs for hidden rolls, random tables, a yes/no oracle, coins. Depends on nothing else in rpg-engine.
2
2
  export { coinSides, mostCoins, tossCoins } from "./coins.js";
3
- export { DiceError, parseNotation } from "./notation.js";
4
- export { askOracle, oracleOdds, oracleResult } from "./oracle.js";
3
+ export { DiceError, diceProblem, parseNotation } from "./notation.js";
4
+ export { askOracle, oracleResult } from "./oracle.js";
5
5
  export { createProof, fingerprint, sha256 } from "./proof.js";
6
6
  export { rollDice } from "./roll-dice.js";
7
7
  export { readRandomTable, rollOnTable } from "./tables.js";
@@ -36,6 +36,8 @@ export type Term = DiceTerm | ConstantTerm;
36
36
  /** A dice error the user or the AI can fix: its message says how. */
37
37
  export declare class DiceError extends Error {
38
38
  }
39
+ /** What keeps a text from reading as dice to roll, as parseNotation says it; a text of no dice, as a number alone, is no roll either. Undefined when it reads. */
40
+ export declare function diceProblem(text: string): string | undefined;
39
41
  /** Reads a notation valid for any game, such as `1d20+5`, `2d20kh1`, `4d6dl1`, `2d6ro<=2`, `1d6!`, `6d10>=8`, `4dF`, `d%`. */
40
42
  export declare function parseNotation(notation: string): Term[];
41
43
  /** How many dice the roll needs at least, before rerolls and explosions. */
@@ -4,16 +4,31 @@ export class DiceError extends Error {
4
4
  const maxTerms = 20;
5
5
  const maxDice = 100;
6
6
  const maxSides = 1000;
7
+ const maxConstant = 1_000_000;
8
+ // What a notation that does not read is told, for any game: the shapes it takes.
9
+ const notationForm = "write dice as 1d20+5, 2d20kh1, 4d6dl1, 2d6ro<=2, 1d6!, 6d10>=8, 4dF or d%";
7
10
  const conditionPattern = /^(<=|>=|<|>|=)(\d+)/;
11
+ /** What keeps a text from reading as dice to roll, as parseNotation says it; a text of no dice, as a number alone, is no roll either. Undefined when it reads. */
12
+ export function diceProblem(text) {
13
+ try {
14
+ return parseNotation(text).some((term) => term.kind === "dice") ? undefined : `${text} holds no dice.`;
15
+ }
16
+ catch (error) {
17
+ if (error instanceof DiceError) {
18
+ return error.message;
19
+ }
20
+ throw error;
21
+ }
22
+ }
8
23
  /** Reads a notation valid for any game, such as `1d20+5`, `2d20kh1`, `4d6dl1`, `2d6ro<=2`, `1d6!`, `6d10>=8`, `4dF`, `d%`. */
9
24
  export function parseNotation(notation) {
10
25
  const compact = notation.replace(/\s+/g, "");
11
26
  if (compact === "") {
12
- throw new DiceError("The dice notation is empty.");
27
+ throw new DiceError(`The dice notation is empty: ${notationForm}.`);
13
28
  }
14
29
  const signedTerms = compact.match(/[+-]?[^+-]+/g) ?? [];
15
30
  if (signedTerms.join("") !== compact) {
16
- throw new DiceError(`Cannot read "${notation}".`);
31
+ throw new DiceError(`Cannot read "${notation}": ${notationForm}.`);
17
32
  }
18
33
  if (signedTerms.length > maxTerms) {
19
34
  throw new DiceError(`Too many terms in "${notation}" (at most ${maxTerms}).`);
@@ -42,11 +57,14 @@ function parseTerm(signedTerm, notation) {
42
57
  const sign = signedTerm.startsWith("-") ? -1 : 1;
43
58
  const termText = signedTerm.replace(/^[+-]/, "");
44
59
  if (/^\d+$/.test(termText)) {
60
+ if (Number(termText) > maxConstant) {
61
+ throw new DiceError(`"${termText}": a number added to the dice is ${maxConstant} at most.`);
62
+ }
45
63
  return { kind: "constant", sign, value: Number(termText) };
46
64
  }
47
65
  const match = /^(\d*)d(\d+|%|F)(.*)$/i.exec(termText);
48
66
  if (!match) {
49
- throw new DiceError(`Cannot read "${termText}" in "${notation}".`);
67
+ throw new DiceError(`Cannot read "${termText}" in "${notation}": ${notationForm}.`);
50
68
  }
51
69
  const [, countText, sidesText, modifiers] = match;
52
70
  const count = countText === "" ? 1 : Number(countText);
@@ -111,7 +129,7 @@ function parseModifiers(modifiers, term, termText) {
111
129
  term.success = toCondition(match[1], match[2]);
112
130
  }
113
131
  else {
114
- throw new DiceError(`"${termText}": unknown modifier "${remaining}".`);
132
+ throw new DiceError(`"${termText}": unknown modifier "${remaining}": ${notationForm}.`);
115
133
  }
116
134
  remaining = remaining.slice(match[0].length);
117
135
  }
@@ -104,11 +104,11 @@ export function rtfText(rtf) {
104
104
  function paragraphs(text) {
105
105
  return text
106
106
  .split(/\n\s*\n/)
107
- .map((block) => block.replace(/[ \t ]+/g, " ").replace(/ *\n */g, "\n").trim())
107
+ .map((block) => block.replace(/[ \t\u00a0]+/g, " ").replace(/ *\n */g, "\n").trim())
108
108
  .filter((block) => block !== "")
109
109
  .join("\n\n");
110
110
  }
111
- const named = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " ", mdash: "—", ndash: "–", hellip: "…", lsquo: "‘", rsquo: "’", ldquo: "“", rdquo: "”" };
111
+ const named = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\u00a0", mdash: "—", ndash: "–", hellip: "…", lsquo: "‘", rsquo: "’", ldquo: "“", rdquo: "”" };
112
112
  function entities(text) {
113
113
  return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (whole, name) => {
114
114
  if (name.startsWith("#")) {
@@ -2,12 +2,17 @@ import { unzipSync } from "fflate";
2
2
  import { createHash } from "node:crypto";
3
3
  import { readdirSync, readFileSync, statSync } from "node:fs";
4
4
  import { basename, extname, join, posix, relative, resolve } from "node:path";
5
+ import { textSize } from "../core/text.js";
5
6
  import { htmlText, openDocumentText, pictureMark, rtfText, wordText } from "./markup.js";
6
7
  import { pngOf } from "./png.js";
7
8
  /** The kinds of file a document may be, by their extension. */
8
9
  export const documentKinds = [".pdf", ".docx", ".odt", ".epub", ".html", ".htm", ".xhtml", ".rtf", ".txt", ".md"];
9
10
  /** The most pictures a document gives, and the longest side of each. */
10
11
  const mostPictures = 300;
12
+ // What a .docx, .odt or .epub may unpack to, its text and pictures alone, as an adventure (ADV-1): never a file of zeros that fills the memory.
13
+ const largestUnpacked = 512 * 1024 * 1024;
14
+ // The files of a packed document the reader uses: its XML, relations, chapters and pictures.
15
+ const unpackedKinds = /\.(?:xml|rels|opf|xhtml|html?|ncx|png|jpe?g|webp|svg)$/i;
11
16
  const longestSide = 1600;
12
17
  // Smaller pictures are ornaments, letters or icons; a picture on more pages than this is a page's decoration.
13
18
  const smallestSide = 160;
@@ -197,7 +202,7 @@ function readText(kind, bytes, file, name) {
197
202
  const parts = [];
198
203
  let words = 0;
199
204
  for (const block of blocks.filter((one) => one.trim() !== "").flatMap(pageSized)) {
200
- const count = sizeOf(block);
205
+ const count = textSize(block);
201
206
  if (parts.length === 0 || words + count > partWords) {
202
207
  parts.push({ label: "", text: block });
203
208
  words = count;
@@ -241,14 +246,9 @@ function lockOf(kind, bytes) {
241
246
  ? "is locked by DRM"
242
247
  : undefined;
243
248
  }
244
- /** How long a text is, in words: a Chinese, Japanese or Korean letter counts as one, as a model reads it; else about six letters a word. */
245
- function sizeOf(text) {
246
- const letters = text.match(/[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af]/gu)?.length ?? 0;
247
- return Math.max(text.split(/\s+/).filter((word) => word !== "").length + letters, Math.ceil(text.length / 6));
248
- }
249
249
  // A block longer than a page, as a text with a line for each paragraph or with no spaces, cut by its lines, then by its length.
250
250
  function pageSized(block) {
251
- if (sizeOf(block) <= partWords) {
251
+ if (textSize(block) <= partWords) {
252
252
  return [block];
253
253
  }
254
254
  const lines = block.split("\n");
@@ -256,7 +256,7 @@ function pageSized(block) {
256
256
  const cut = [];
257
257
  for (const line of lines) {
258
258
  const last = cut.at(-1);
259
- if (last !== undefined && sizeOf(`${last}\n${line}`) <= partWords) {
259
+ if (last !== undefined && textSize(`${last}\n${line}`) <= partWords) {
260
260
  cut[cut.length - 1] = `${last}\n${line}`;
261
261
  }
262
262
  else {
@@ -266,7 +266,7 @@ function pageSized(block) {
266
266
  return cut.flatMap(pageSized);
267
267
  }
268
268
  // A block of one line is cut by its length: as many letters as make a page by sizeOf.
269
- const letters = Math.max(1, Math.floor((block.length * partWords) / sizeOf(block)));
269
+ const letters = Math.max(1, Math.floor((block.length * partWords) / textSize(block)));
270
270
  return Array.from({ length: Math.ceil(block.length / letters) }, (_, index) => block.slice(index * letters, (index + 1) * letters));
271
271
  }
272
272
  // A text file in UTF-8, or in UTF-16 by its mark, or else in the Windows encoding older editors wrote.
@@ -285,12 +285,12 @@ function decoded(bytes) {
285
285
  }
286
286
  }
287
287
  function fromPlain(kind, bytes) {
288
- const text = decoded(bytes).replace(/^/, "").replace(/\r\n?/g, "\n");
288
+ const text = decoded(bytes).replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
289
289
  return { text: kind === ".rtf" ? rtfText(text) : kind === ".txt" || kind === ".md" ? text.trim() : htmlText(text), files: {} };
290
290
  }
291
291
  // A Word document: its text from word/document.xml, its pictures by the ids its relations give them.
292
292
  function fromWord(bytes) {
293
- const zip = unzipSync(bytes);
293
+ const zip = unpacked(bytes);
294
294
  const xml = textOf(zip, "word/document.xml");
295
295
  if (xml === undefined) {
296
296
  throw new Error("This .docx has no word/document.xml: it is no Word document, or it is damaged. Save it again from the program that made it.");
@@ -315,7 +315,7 @@ function fromWord(bytes) {
315
315
  return { text, files };
316
316
  }
317
317
  function fromOpenDocument(bytes) {
318
- const zip = unzipSync(bytes);
318
+ const zip = unpacked(bytes);
319
319
  const xml = textOf(zip, "content.xml");
320
320
  if (xml === undefined) {
321
321
  throw new Error("This .odt has no content.xml: it is no OpenDocument text, or it is damaged. Save it again from the program that made it.");
@@ -324,7 +324,7 @@ function fromOpenDocument(bytes) {
324
324
  }
325
325
  // An EPUB: its chapters in the order of its spine, its pictures by their path in the book.
326
326
  function fromEpub(bytes) {
327
- const zip = unzipSync(bytes);
327
+ const zip = unpacked(bytes);
328
328
  const root = /full-path="([^"]+)"/.exec(textOf(zip, "META-INF/container.xml") ?? "")?.[1];
329
329
  const opf = root === undefined ? undefined : textOf(zip, root);
330
330
  if (root === undefined || opf === undefined) {
@@ -344,6 +344,22 @@ function fromEpub(bytes) {
344
344
  .join("\n\n");
345
345
  return { text, files: zip };
346
346
  }
347
+ /** A packed document's files that the reader uses, unpacked up to a size; it throws, saying what to do, past it. */
348
+ function unpacked(bytes) {
349
+ let declared = 0;
350
+ return unzipSync(bytes, {
351
+ filter: (file) => {
352
+ if (!unpackedKinds.test(file.name)) {
353
+ return false;
354
+ }
355
+ declared += file.originalSize;
356
+ if (declared > largestUnpacked) {
357
+ throw new Error(`This document unpacks to more than ${largestUnpacked / 1024 / 1024} MB of text and pictures: save it again without its largest pictures, or as a PDF.`);
358
+ }
359
+ return true;
360
+ },
361
+ });
362
+ }
347
363
  // A path an EPUB writes encoded, as it is when it is not: a % in a file's name.
348
364
  function uriDecoded(path) {
349
365
  try {
@@ -40,7 +40,7 @@ export function readEffects(value) {
40
40
  if ("problem" in read) {
41
41
  return read;
42
42
  }
43
- if (effects.some((effect) => sameName(effect.name, read.effect.name))) {
43
+ if (effects.some((effect) => sameWord(effect.name, read.effect.name))) {
44
44
  return { problem: `The effect ${read.effect.name} is written twice: keep one.` };
45
45
  }
46
46
  effects.push(read.effect);
@@ -87,7 +87,7 @@ export function endsAtTurn(end, round, turn, order) {
87
87
  if (round !== end.round) {
88
88
  return round > end.round;
89
89
  }
90
- return sameName(turn, end.turn) || !order.some((name) => sameName(name, end.turn));
90
+ return sameWord(turn, end.turn) || !order.some((name) => sameWord(name, end.turn));
91
91
  }
92
92
  function withEnd(effect, endText) {
93
93
  const text = endText.trim();
@@ -121,6 +121,3 @@ function asLine(item) {
121
121
  function pageName(text) {
122
122
  return text.trim().replace(/^\[\[(.*?)(?:\|.*)?\]\]$/, "$1").trim();
123
123
  }
124
- function sameName(first, second) {
125
- return comparableText(first.trim()) === comparableText(second.trim());
126
- }
@@ -5,7 +5,7 @@ import { installedFromFolder, packageFoldersIn, realPath } from "../core/files.j
5
5
  import { readParts } from "../core/instruction-parts.js";
6
6
  import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
7
7
  import { files, isInside } from "../core/store.js";
8
- import { comparableText } from "../core/text.js";
8
+ import { comparableText, wordCount } from "../core/text.js";
9
9
  import { readYamlValues } from "../core/yaml-file.js";
10
10
  /** The file that makes a folder an extension of rpg-engine (D-427). */
11
11
  export const extensionFileName = "extension.yaml";
@@ -57,8 +57,9 @@ export function installedExtensions(folders) {
57
57
  }
58
58
  /** The installed extension of this package, as npm or campaign.yaml names it, or by its name alone (weather); undefined when none is. It throws when it does not read. */
59
59
  export function findExtension(folders, wanted) {
60
- const named = (candidate) => candidate === wanted.trim() || comparableText(shortName(candidate)) === comparableText(wanted.trim());
61
- const found = installedExtensions(folders).find((candidate) => named(candidate.package));
60
+ // A package's whole name first: another's skies is never taken for @rpgengine/skies, nor the other way.
61
+ const installed = installedExtensions(folders);
62
+ const found = installed.find((candidate) => candidate.package === wanted.trim()) ?? installed.find((candidate) => comparableText(shortName(candidate.package)) === comparableText(wanted.trim()));
62
63
  return found === undefined ? undefined : readExtension(found.folder);
63
64
  }
64
65
  /** An extension from its folder: its package.json and its extension.yaml, refused with what is wrong (D-427). */
@@ -90,9 +91,9 @@ export function readExtension(folder) {
90
91
  const parts = readParts(folder, owner);
91
92
  // What the master reads of it in every chat, kept short (D-441).
92
93
  const long = [["about", about, aboutWords], ...Object.entries(parts).map(([name, part]) => [`instructions/${name}.md`, part.text, partWords])]
93
- .find(([, text, most]) => words(text) > most);
94
+ .find(([, text, most]) => wordCount(text) > most);
94
95
  if (long !== undefined) {
95
- throw new Error(`${owner} cannot be used, because its ${long[0]} has ${words(long[1])} words, and ${long[2]} at most are read.`);
96
+ throw new Error(`${owner} cannot be used, because its ${long[0]} has ${wordCount(long[1])} words, and ${long[2]} at most are read.`);
96
97
  }
97
98
  return {
98
99
  kind: "extension",
@@ -137,6 +138,3 @@ function readJson(path) {
137
138
  return undefined;
138
139
  }
139
140
  }
140
- function words(text) {
141
- return text.split(/\s+/).filter((word) => word !== "").length;
142
- }
@@ -1,6 +1,3 @@
1
1
  export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.ts";
2
- export { npmEngine } from "./engine.ts";
3
- export { type CodePackage, type Extension, extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames, type SystemAdditions } from "./extension.ts";
4
- export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.ts";
5
- export { isTarball } from "./tarball.ts";
2
+ export { type CodePackage, type Extension, findExtension, installedExtensions, readExtension, shortName, type SystemAdditions } from "./extension.ts";
6
3
  export { type ExtensionWords, extensionWords, wordIn } from "./words.ts";
@@ -1,7 +1,4 @@
1
1
  // The extensions installed beside the engine (D-427, D-428): which they are and what each declares. Depends on nothing else in rpg-engine.
2
2
  export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.js";
3
- export { npmEngine } from "./engine.js";
4
- export { extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames } from "./extension.js";
5
- export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.js";
6
- export { isTarball } from "./tarball.js";
3
+ export { findExtension, installedExtensions, readExtension, shortName } from "./extension.js";
7
4
  export { extensionWords, wordIn } from "./words.js";
@@ -34,7 +34,8 @@ export function wordIn(words, text) {
34
34
  }
35
35
  const first = text.charAt(0);
36
36
  const other = first === first.toLowerCase() ? first.toUpperCase() : first.toLowerCase();
37
- const found = list[`${other}${text.slice(1)}`];
37
+ const key = `${other}${text.slice(1)}`;
38
+ const found = Object.hasOwn(list, key) ? list[key] : undefined;
38
39
  if (found === undefined) {
39
40
  return text;
40
41
  }