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,6 +1,6 @@
1
1
  // The files of a folder and of the folders inside it, listed one folder at a time: listing a whole tree at once looks at every file again on Windows (D-194).
2
2
  import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
3
- import { basename, join, relative, resolve, sep } from "node:path";
3
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
4
4
  /** The full paths of `folder` and of the folders inside it, however deep; none when there is no such folder. */
5
5
  export function foldersIn(folder) {
6
6
  const folders = existsSync(folder) && statSync(folder).isDirectory() ? [folder] : [];
@@ -26,7 +26,13 @@ export function filesIn(folder, keep) {
26
26
  }
27
27
  }
28
28
  }
29
- return files;
29
+ return files.sort(fileOrder);
30
+ }
31
+ /** The order of a folder's files, the same on every system: those nearer the folder first, then by path, as Windows lists them, case aside. */
32
+ export function fileOrder(first, second) {
33
+ const depth = (path) => path.split(sep).length;
34
+ const [one, other] = [first.toUpperCase(), second.toUpperCase()];
35
+ return depth(first) - depth(second) || (one < other ? -1 : one > other ? 1 : first < second ? -1 : first > second ? 1 : 0);
30
36
  }
31
37
  /**
32
38
  * The folders of the packages in these folders of npm's, in their scopes' folders too (@rpgengine/weather), links to folders included, as npm links a package
@@ -37,33 +43,24 @@ export function packageFoldersIn(folders) {
37
43
  return folders.filter((folder) => existsSync(folder)).flatMap((folder) => {
38
44
  const chosen = chosenPackages(folder);
39
45
  const found = children(folder).flatMap((child) => (basename(child).startsWith("@") ? children(child) : [child]));
40
- // Only the packages the player installed: one npm brought as another's dependency is never theirs to use (D-485).
41
- return chosen === undefined ? found : found.filter((child) => chosen.has(relative(folder, child).split(sep).join("/")));
46
+ const named = (child) => relative(folder, child).split(sep).join("/");
47
+ // Only the packages the player installed: one npm brought as another's dependency is never theirs to use (D-485). In npm's folder a package is
48
+ // where its name puts it: one whose package.json names another, as an alias that says it is ours, is no package at all.
49
+ const fits = (child) => basename(folder) !== "node_modules" || [undefined, named(child)].includes(manifestName(child));
50
+ return found.filter((child) => (chosen === undefined || chosen.has(named(child))) && fits(child));
42
51
  });
43
52
  }
44
53
  /**
45
- * The packages the player installed in a folder of npm's, as the package.json beside it lists them; undefined where there is none, as for the engine's own
46
- * systems or a test's folder.
54
+ * A path by the folders it really is in, through any link on the way, as Node resolves a module; one not there yet by the real path of the folder it would be
55
+ * in, as /var is /private/var on macOS.
47
56
  */
48
- function chosenPackages(folder) {
49
- if (basename(folder) !== "node_modules") {
50
- return undefined;
51
- }
52
- try {
53
- const read = JSON.parse(readFileSync(join(folder, "..", "package.json"), "utf8"));
54
- return read.dependencies === undefined ? undefined : new Set(Object.keys(read.dependencies));
55
- }
56
- catch {
57
- return undefined;
58
- }
59
- }
60
- /** A path by the folders it really is in, through any link on the way, as Node resolves a module; as given when it is not there. */
61
57
  export function realPath(path) {
62
58
  try {
63
59
  return realpathSync(path);
64
60
  }
65
61
  catch {
66
- return path;
62
+ const folder = dirname(path);
63
+ return folder === path ? path : join(realPath(folder), basename(path));
67
64
  }
68
65
  }
69
66
  /**
@@ -77,14 +74,33 @@ export function installedFromFolder(folder) {
77
74
  if (lstatSync(folder).isSymbolicLink()) {
78
75
  return true;
79
76
  }
77
+ if (at < 0) {
78
+ return false;
79
+ }
80
80
  const read = JSON.parse(readFileSync(join(parts.slice(0, at).join(sep), "package.json"), "utf8"));
81
- const spec = at < 0 ? undefined : read.dependencies?.[parts.slice(at + 1).join("/")];
81
+ const spec = read.dependencies?.[parts.slice(at + 1).join("/")];
82
82
  return typeof spec === "string" && /^(file|link):/.test(spec);
83
83
  }
84
84
  catch {
85
85
  return false;
86
86
  }
87
87
  }
88
+ /**
89
+ * The packages the player installed in a folder of npm's, as the package.json beside it lists them; undefined where there is none, as for the engine's own
90
+ * systems or a test's folder.
91
+ */
92
+ function chosenPackages(folder) {
93
+ if (basename(folder) !== "node_modules") {
94
+ return undefined;
95
+ }
96
+ try {
97
+ const read = JSON.parse(readFileSync(join(folder, "..", "package.json"), "utf8"));
98
+ return read.dependencies === undefined ? undefined : new Set(Object.keys(read.dependencies));
99
+ }
100
+ catch {
101
+ return undefined;
102
+ }
103
+ }
88
104
  function isLinkedFolder(path) {
89
105
  try {
90
106
  return lstatSync(path).isSymbolicLink() && statSync(path).isDirectory();
@@ -93,3 +109,13 @@ function isLinkedFolder(path) {
93
109
  return false;
94
110
  }
95
111
  }
112
+ /** The name a package's package.json gives itself; undefined when it gives none that reads. */
113
+ function manifestName(folder) {
114
+ try {
115
+ const read = JSON.parse(readFileSync(join(folder, "package.json"), "utf8"));
116
+ return typeof read.name === "string" ? read.name : undefined;
117
+ }
118
+ catch {
119
+ return undefined;
120
+ }
121
+ }
@@ -114,7 +114,7 @@ export interface RollFormula {
114
114
  words?: string;
115
115
  }
116
116
  /** One of the dice a roll may begin with (D-235): dice as written, a number, as an unarmed strike's 1, or a field that holds dice, as a monk's martial-arts. */
117
- export type DiceChoice = {
117
+ type DiceChoice = {
118
118
  dice: string;
119
119
  } | {
120
120
  number: number;
@@ -154,7 +154,12 @@ export declare function tablesRead(formula: Formula): string[];
154
154
  export declare function tableOf(rows: Record<string, number>): Table;
155
155
  /** The names of the items of a list field, as has, count and item read them (FOR-2): a link as the page or the section it names, without the number after a name. */
156
156
  export declare function listItemNames(value: unknown): string[];
157
- /** The items of a list field with the number after each name, such as Fighter and 3 for [[Fighter]] 3 (FOR-2); a single value is a list of one. */
157
+ /**
158
+ * The items of a list field, each with its name and the number after it, if any, such as Fighter and 3 for [[Fighter]] 3 (FOR-2). A link reads as the page
159
+ * it names, or as its section, as a feature [[Cleric#Channel Divinity]] does. A value in parentheses after the name is not part of it, and gives the number it
160
+ * begins with when no number follows the name: Channel Divinity (2/rest) is Channel Divinity with 2, Bardic Inspiration (d8) has none (D-220). A single value
161
+ * is a list of one.
162
+ */
158
163
  export declare function listItems(value: unknown): {
159
164
  name: string;
160
165
  number?: number;
@@ -102,49 +102,6 @@ export function diceFields(roll) {
102
102
  }
103
103
  // 1d8, d6, 2d6: dice as a roll writes them.
104
104
  const dicePattern = /^(\d*)d(\d+)$/i;
105
- /** What dice roll on average, as 4.5 for 1d8. */
106
- function diceAverage(dice) {
107
- const [, count, faces] = dicePattern.exec(dice) ?? [];
108
- return (count === "" || count === undefined ? 1 : Number(count)) * (Number(faces) + 1) / 2;
109
- }
110
- /** The dice a roll formula begins with, and how much of its text they take: 1d8, or dice(…) with dice, numbers and fields (D-235); undefined for none. */
111
- function openingDice(text) {
112
- const written = /^\s*(\d*d\d+)\b/i.exec(text);
113
- if (written !== null) {
114
- return { choices: [{ dice: written[1] }], length: written[0].length };
115
- }
116
- const call = /^\s*dice\s*\(([^()]*)\)/i.exec(text);
117
- if (call === null && /^\s*dice\s*\(/i.test(text)) {
118
- throw new Error(`"${text}" is not a formula: dice() holds only dice, numbers and fields, between commas, such as dice(1d6, martial-arts).`);
119
- }
120
- if (call === null) {
121
- return undefined;
122
- }
123
- const choices = call[1].split(",").map((part) => {
124
- const choice = part.trim();
125
- namePattern.lastIndex = 0;
126
- const name = namePattern.exec(choice);
127
- if (dicePattern.test(choice)) {
128
- return { dice: choice };
129
- }
130
- if (/^\d+$/.test(choice)) {
131
- return { number: Number(choice) };
132
- }
133
- if (name !== null && name[0] === choice) {
134
- return { field: choice };
135
- }
136
- throw new Error(`"${text}" is not a formula: dice, a number or a field that holds dice was expected in dice() at "${choice}", such as dice(1d6, martial-arts).`);
137
- });
138
- return { choices, length: call[0].length };
139
- }
140
- function tryFormula(text) {
141
- try {
142
- return parseFormula(text);
143
- }
144
- catch {
145
- return undefined;
146
- }
147
- }
148
105
  /** A formula given as a number or as text, as system.yaml writes it. */
149
106
  export function formulaOf(value) {
150
107
  return typeof value === "number" ? { kind: "number", value } : parseFormula(value);
@@ -168,7 +125,7 @@ export function contributingReads(formula, scope, worked) {
168
125
  const name = "field" in read ? read.field : read.list;
169
126
  // Tried in several ways: a value halved and rounded down moves only on one side of it.
170
127
  const probes = "field" in read ? [read.value + 1, read.value - 1, 0, read.value + 10] : [[]];
171
- return probes.some((probe) => workOut(formula, { field: (field) => (comparableText(field) === comparableText(name) ? probe : scope.field(field)), table: scope.table }).value !== worked.value);
128
+ return probes.some((probe) => workOut(formula, { ...scope, field: (field) => (comparableText(field) === comparableText(name) ? probe : scope.field(field)) }).value !== worked.value);
172
129
  });
173
130
  }
174
131
  /** The fields a formula reads, lists included, each once and in order: what it comes from. */
@@ -215,11 +172,26 @@ export function tableOf(rows) {
215
172
  }
216
173
  /** The names of the items of a list field, as has, count and item read them (FOR-2): a link as the page or the section it names, without the number after a name. */
217
174
  export function listItemNames(value) {
218
- return itemsOf(value).map((item) => item.name);
175
+ return listItems(value).map((item) => item.name);
219
176
  }
220
- /** The items of a list field with the number after each name, such as Fighter and 3 for [[Fighter]] 3 (FOR-2); a single value is a list of one. */
177
+ /**
178
+ * The items of a list field, each with its name and the number after it, if any, such as Fighter and 3 for [[Fighter]] 3 (FOR-2). A link reads as the page
179
+ * it names, or as its section, as a feature [[Cleric#Channel Divinity]] does. A value in parentheses after the name is not part of it, and gives the number it
180
+ * begins with when no number follows the name: Channel Divinity (2/rest) is Channel Divinity with 2, Bardic Inspiration (d8) has none (D-220). A single value
181
+ * is a list of one.
182
+ */
221
183
  export function listItems(value) {
222
- return itemsOf(value);
184
+ const values = value === undefined || value === null ? [] : Array.isArray(value) ? value : [value];
185
+ return values.map((item) => {
186
+ const text = String(item).trim();
187
+ const match = itemPattern.exec(text);
188
+ const valued = match === null ? valuePattern.exec(text) : null;
189
+ const written = (match !== null ? match[1] : valued !== null ? valued[1] : text).trim();
190
+ const link = linkPattern.exec(written);
191
+ const name = link === null ? written : (link[2] ?? linkTargetName(link[1])).trim();
192
+ const inside = valued === null ? null : /^\s*([+-]?\d+)/.exec(valued[2]);
193
+ return { name, number: match !== null ? Number(match[2]) : inside === null ? undefined : Number(inside[1]) };
194
+ });
223
195
  }
224
196
  /** A factor as an effect gives it (FOR-5): 2, 0.5, 1/2 or ½; undefined for anything else. */
225
197
  export function factorOf(value) {
@@ -243,6 +215,49 @@ export function numberOf(value) {
243
215
  const match = /^\s*([+-]?\d+(?:\.\d+)?)\s*(?:\/\s*\d+\s*|\p{L}{1,3}\.?\s*(?:\([^()]*\)\s*)?)?$/u.exec(value);
244
216
  return match === null ? undefined : Number(match[1]);
245
217
  }
218
+ /** What dice roll on average, as 4.5 for 1d8. */
219
+ function diceAverage(dice) {
220
+ const [, count, faces] = dicePattern.exec(dice) ?? [];
221
+ return (count === "" || count === undefined ? 1 : Number(count)) * (Number(faces) + 1) / 2;
222
+ }
223
+ /** The dice a roll formula begins with, and how much of its text they take: 1d8, or dice(…) with dice, numbers and fields (D-235); undefined for none. */
224
+ function openingDice(text) {
225
+ const written = /^\s*(\d*d\d+)\b/i.exec(text);
226
+ if (written !== null) {
227
+ return { choices: [{ dice: written[1] }], length: written[0].length };
228
+ }
229
+ const call = /^\s*dice\s*\(([^()]*)\)/i.exec(text);
230
+ if (call === null && /^\s*dice\s*\(/i.test(text)) {
231
+ throw new Error(`"${text}" is not a formula: dice() holds only dice, numbers and fields, between commas, such as dice(1d6, martial-arts).`);
232
+ }
233
+ if (call === null) {
234
+ return undefined;
235
+ }
236
+ const choices = call[1].split(",").map((part) => {
237
+ const choice = part.trim();
238
+ namePattern.lastIndex = 0;
239
+ const name = namePattern.exec(choice);
240
+ if (dicePattern.test(choice)) {
241
+ return { dice: choice };
242
+ }
243
+ if (/^\d+$/.test(choice)) {
244
+ return { number: Number(choice) };
245
+ }
246
+ if (name !== null && name[0] === choice) {
247
+ return { field: choice };
248
+ }
249
+ throw new Error(`"${text}" is not a formula: dice, a number or a field that holds dice was expected in dice() at "${choice}", such as dice(1d6, martial-arts).`);
250
+ });
251
+ return { choices, length: call[0].length };
252
+ }
253
+ function tryFormula(text) {
254
+ try {
255
+ return parseFormula(text);
256
+ }
257
+ catch {
258
+ return undefined;
259
+ }
260
+ }
246
261
  function evaluate(formula, scope, reads) {
247
262
  switch (formula.kind) {
248
263
  case "number":
@@ -365,7 +380,7 @@ function listValue(formula, scope, reads) {
365
380
  }
366
381
  // sum(classes, hit-die = d10): only the items whose page has that value in that field (D-215).
367
382
  const where = formula.where;
368
- const items = itemsOf(raw).filter((item) => {
383
+ const items = listItems(raw).filter((item) => {
369
384
  const fields = where === undefined ? undefined : scope.page?.(item.name);
370
385
  const value = fields === undefined || where === undefined ? undefined : valueNamed(fields, where.field);
371
386
  return where === undefined || (value !== undefined && comparableText(String(value).trim()) === comparableText(where.value));
@@ -384,24 +399,6 @@ function listValue(formula, scope, reads) {
384
399
  reads.push(formula.item === undefined ? { list: formula.list, value, ...filter, ...counted } : { list: formula.list, item: formula.item, value });
385
400
  return value;
386
401
  }
387
- /**
388
- * The items of a list field, each with its name and the number after it, if any. A link reads as the page it names, or as its section, as a feature
389
- * [[Cleric#Channel Divinity]] does. A value in parentheses after the name is not part of it, and gives the number it begins with when no number follows the
390
- * name: Channel Divinity (2/rest) is Channel Divinity with 2, Bardic Inspiration (d8) has none (D-220). A single value is a list of one.
391
- */
392
- function itemsOf(value) {
393
- const values = value === undefined || value === null ? [] : Array.isArray(value) ? value : [value];
394
- return values.map((item) => {
395
- const text = String(item).trim();
396
- const match = itemPattern.exec(text);
397
- const valued = match === null ? valuePattern.exec(text) : null;
398
- const written = (match !== null ? match[1] : valued !== null ? valued[1] : text).trim();
399
- const link = linkPattern.exec(written);
400
- const name = link === null ? written : (link[2] ?? linkTargetName(link[1])).trim();
401
- const inside = valued === null ? null : /^\s*([+-]?\d+)/.exec(valued[2]);
402
- return { name, number: match !== null ? Number(match[2]) : inside === null ? undefined : Number(inside[1]) };
403
- });
404
- }
405
402
  function unique(names) {
406
403
  return names.filter((name, index) => names.findIndex((other) => comparableText(other) === comparableText(name)) === index);
407
404
  }
@@ -15,7 +15,7 @@ export function readParts(folder, owner) {
15
15
  }
16
16
  /** A part from its file: the text after its frontmatter, which says only whether it takes the place of the core's part, replace: true (D-121). */
17
17
  function partOf(file, owner, path) {
18
- const text = file.replace(/^/, "").replace(/\r\n/g, "\n");
18
+ const text = file.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
19
19
  const frontmatter = text.match(/^---\n([\s\S]*?)\n---(?:\n|$)/);
20
20
  let settings;
21
21
  try {
@@ -1,6 +1,5 @@
1
1
  /** Every mood, the neutral one first. */
2
2
  export declare const moods: readonly ["neutral", "happy", "delighted", "curious", "focused", "determined", "worried", "surprised", "afraid", "sad", "angry", "disgusted", "mischievous"];
3
3
  export type Mood = (typeof moods)[number];
4
- export declare function isMood(value: unknown): value is Mood;
5
4
  /** The mood a value holds, as a page's field or state.yaml writes it; neutral for anything else. */
6
5
  export declare function readMood(value: unknown): Mood;
package/dist/core/mood.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // The moods of the master and of the characters (MOOD-1, D-305): one closed list for both, since the dashboard draws each; neutral is no mood at all.
2
2
  /** Every mood, the neutral one first. */
3
3
  export const moods = ["neutral", "happy", "delighted", "curious", "focused", "determined", "worried", "surprised", "afraid", "sad", "angry", "disgusted", "mischievous"];
4
- export function isMood(value) {
5
- return typeof value === "string" && moods.includes(value);
6
- }
7
4
  /** The mood a value holds, as a page's field or state.yaml writes it; neutral for anything else. */
8
5
  export function readMood(value) {
9
6
  const written = typeof value === "string" ? value.trim().toLowerCase() : value;
10
7
  return isMood(written) ? written : "neutral";
11
8
  }
9
+ function isMood(value) {
10
+ return typeof value === "string" && moods.includes(value);
11
+ }
@@ -157,6 +157,8 @@ export interface GamePage {
157
157
  } | undefined;
158
158
  /** Whether an effect is on it, such as a condition. */
159
159
  has(effect: string): boolean;
160
+ /** Whether it carries a thing by this name, in its inventory or inside what it carries, a copy of it by its base too, the names compared as sameName does. */
161
+ carries(thing: string): boolean;
160
162
  /** A formula of the game system worked out on it, as has(skills, stealth) * proficiency; undefined when it has no value. It throws when it does not read. */
161
163
  formula(text: string): number | undefined;
162
164
  }
@@ -386,3 +388,12 @@ export type WidgetPart = {
386
388
  image: string;
387
389
  alt: WidgetText;
388
390
  };
391
+ /** The room a figure takes on a wide screen, as its extension.yaml or system.yaml declares it; on a phone it shrinks to the width there is, keeping its shape. */
392
+ export interface FigureSize {
393
+ width: number;
394
+ height: number;
395
+ mirror?: boolean;
396
+ }
397
+ /** The pages of the dashboard a package's card or widget stands in, after their own cards (D-502, D-511): the Scene, the sheet, the World and the Journal. */
398
+ export declare const cardPages: readonly ["scene", "sheet", "world", "journal"];
399
+ export type CardPage = (typeof cardPages)[number];
@@ -1 +1,2 @@
1
- export {};
1
+ /** The pages of the dashboard a package's card or widget stands in, after their own cards (D-502, D-511): the Scene, the sheet, the World and the Journal. */
2
+ export const cardPages = ["scene", "sheet", "world", "journal"];
@@ -1,13 +1,13 @@
1
1
  import { z } from "zod";
2
- import { type CardPage, type FigureSize } from "../page.ts";
2
+ import { type CardPage, type FigureSize } from "./package-api.ts";
3
3
  export type { CardPage, FigureSize };
4
4
  /**
5
5
  * The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
6
6
  * system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
7
7
  * additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
8
- * knowledge of a game system (sheet-knowledge).
8
+ * knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states.
9
9
  */
10
- export declare const packageApi = 6;
10
+ export declare const packageApi = 7;
11
11
  /**
12
12
  * Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
13
13
  * npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
@@ -18,7 +18,7 @@ export declare const ourSystems: readonly {
18
18
  title: string;
19
19
  }[];
20
20
  /** The kinds of package whose API is read. */
21
- export type ApiKind = "extension" | "system";
21
+ type ApiKind = "extension" | "system";
22
22
  /** Whether this rpg-engine reads a package of this kind made for this version of the API: from the kind's first up to its own. */
23
23
  export declare function readsApi(api: number | undefined, kind: ApiKind): boolean;
24
24
  /** What a package made for a newer API asks of the player, said where it is refused. */
@@ -47,16 +47,16 @@ declare const widgetSchema: z.ZodObject<{
47
47
  title: z.ZodString;
48
48
  icon: z.ZodOptional<z.ZodString>;
49
49
  place: z.ZodEnum<{
50
- page: "page";
51
50
  top: "top";
52
51
  side: "side";
52
+ page: "page";
53
53
  person: "person";
54
54
  card: "card";
55
55
  }>;
56
56
  page: z.ZodOptional<z.ZodEnum<{
57
- world: "world";
58
57
  scene: "scene";
59
58
  sheet: "sheet";
59
+ world: "world";
60
60
  journal: "journal";
61
61
  }>>;
62
62
  order: z.ZodOptional<z.ZodInt>;
@@ -68,16 +68,16 @@ export declare const packagePartsShape: {
68
68
  title: z.ZodString;
69
69
  icon: z.ZodOptional<z.ZodString>;
70
70
  place: z.ZodEnum<{
71
- page: "page";
72
71
  top: "top";
73
72
  side: "side";
73
+ page: "page";
74
74
  person: "person";
75
75
  card: "card";
76
76
  }>;
77
77
  page: z.ZodOptional<z.ZodEnum<{
78
- world: "world";
79
78
  scene: "scene";
80
79
  sheet: "sheet";
80
+ world: "world";
81
81
  journal: "journal";
82
82
  }>>;
83
83
  order: z.ZodOptional<z.ZodInt>;
@@ -89,7 +89,7 @@ export declare const packagePartsShape: {
89
89
  }, z.core.$strict>>>;
90
90
  };
91
91
  /** A package's icons, widgets and figures, as its file declares them. */
92
- export interface DeclaredParts {
92
+ interface DeclaredParts {
93
93
  icons?: Record<string, string>;
94
94
  widgets?: Record<string, z.infer<typeof widgetSchema>>;
95
95
  figures?: Record<string, FigureSize>;
@@ -1,14 +1,14 @@
1
1
  // What every package for rpg-engine declares alike, an extension in extension.yaml and a game system in system.yaml (D-502, D-510, D-514): the version of the
2
2
  // API it is made for, and its icons, widgets and figures, with the same limits.
3
3
  import { z } from "zod";
4
- import { cardPages } from "../page.js";
4
+ import { cardPages } from "./package-api.js";
5
5
  /**
6
6
  * The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
7
7
  * system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
8
8
  * additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
9
- * knowledge of a game system (sheet-knowledge).
9
+ * knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states.
10
10
  */
11
- export const packageApi = 6;
11
+ export const packageApi = 7;
12
12
  /**
13
13
  * Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
14
14
  * npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
@@ -0,0 +1,8 @@
1
+ /** Takes the mark for this process: true once it holds it, as it may already; false while another live process does. */
2
+ export declare function claimMark(file: string): boolean;
3
+ /** The live process that holds the mark, this one included; undefined when none does. */
4
+ export declare function markHolder(file: string): number | undefined;
5
+ /** Lets the mark go, when this process holds it. */
6
+ export declare function releaseMark(file: string): void;
7
+ /** Whether a process of this computer is still running. */
8
+ export declare function isAlive(pid: number): boolean;
@@ -0,0 +1,72 @@
1
+ // The mark of the process that does a piece of work alone, as reading the library or running an import (LIB-3): one process takes it at a time, and a mark
2
+ // left by a process that is gone is taken over.
3
+ import { linkSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { dirname } from "node:path";
5
+ /** Takes the mark for this process: true once it holds it, as it may already; false while another live process does. */
6
+ export function claimMark(file) {
7
+ mkdirSync(dirname(file), { recursive: true });
8
+ // The mark is written whole beside it, then linked in place at once: never seen empty, and only one process links it.
9
+ const own = `${file}.${process.pid}`;
10
+ writeFileSync(own, String(process.pid));
11
+ try {
12
+ for (let attempt = 0; attempt < 2; attempt++) {
13
+ try {
14
+ linkSync(own, file);
15
+ return true;
16
+ }
17
+ catch (error) {
18
+ if (!["EEXIST", "EPERM"].includes(error.code ?? "")) {
19
+ throw error;
20
+ }
21
+ }
22
+ const holder = markHolder(file);
23
+ if (holder !== undefined) {
24
+ return holder === process.pid;
25
+ }
26
+ // A mark left by a process that is gone, taken away once, and only while it is still that one: another process may have just put its own.
27
+ dropStaleMark(file);
28
+ }
29
+ return false;
30
+ }
31
+ finally {
32
+ rmSync(own, { force: true });
33
+ }
34
+ }
35
+ /** The live process that holds the mark, this one included; undefined when none does. */
36
+ export function markHolder(file) {
37
+ let holder;
38
+ try {
39
+ holder = Number(readFileSync(file, "utf8"));
40
+ }
41
+ catch {
42
+ return undefined;
43
+ }
44
+ return Number.isInteger(holder) && holder > 0 && isAlive(holder) ? holder : undefined;
45
+ }
46
+ /** Lets the mark go, when this process holds it. */
47
+ export function releaseMark(file) {
48
+ if (markHolder(file) === process.pid) {
49
+ rmSync(file, { force: true });
50
+ }
51
+ }
52
+ /** Whether a process of this computer is still running. */
53
+ export function isAlive(pid) {
54
+ try {
55
+ process.kill(pid, 0);
56
+ return true;
57
+ }
58
+ catch (error) {
59
+ return error.code === "EPERM";
60
+ }
61
+ }
62
+ function dropStaleMark(file) {
63
+ try {
64
+ const stale = readFileSync(file, "utf8");
65
+ if (!isAlive(Number(stale)) && readFileSync(file, "utf8") === stale) {
66
+ rmSync(file, { force: true });
67
+ }
68
+ }
69
+ catch {
70
+ // Gone already, or taken away by another process at the same time.
71
+ }
72
+ }
@@ -27,6 +27,11 @@ export interface Command<Schema extends z.ZodObject = z.ZodObject, Result = unkn
27
27
  format(result: Result): string;
28
28
  }
29
29
  export declare function defineCommand<Schema extends z.ZodObject, Result>(command: Command<Schema, Result>): Command<Schema, Result>;
30
+ /**
31
+ * What keeps a field of a command's input from being given on the command line: one named no-x, read as turning x off, or json, read as answering in JSON
32
+ * (review of 25 and 28 October); undefined for any other. A positional is never an option, so json is its name freely.
33
+ */
34
+ export declare function commandLineFieldProblem(command: string, name: string, positional: boolean): string | undefined;
30
35
  /** Whether a field of a command's input is a flag, true or false, as --hidden. */
31
36
  export declare function isBoolean(field: z.ZodType): boolean;
32
37
  /** A list option can be given more than once, as in --set a=1 --set b=2; a field that also takes an object, through MCP, is a list here. */
@@ -3,6 +3,16 @@ export function defineCommand(command) {
3
3
  // Each call reads and writes through a store of its own, which reads each file once, or through the session's that the MCP server keeps (D-137).
4
4
  return { ...command, run: (input, context) => withFiles(context.files ?? new FileStore(context.systemFolders), () => command.run(input, context)) };
5
5
  }
6
+ /**
7
+ * What keeps a field of a command's input from being given on the command line: one named no-x, read as turning x off, or json, read as answering in JSON
8
+ * (review of 25 and 28 October); undefined for any other. A positional is never an option, so json is its name freely.
9
+ */
10
+ export function commandLineFieldProblem(command, name, positional) {
11
+ if (name.startsWith("no-")) {
12
+ return `${command} has a field named ${name}, and none may start with no-, which the command line reads as turning ${name.slice(3)} off: rename it.`;
13
+ }
14
+ return name === "json" && !positional ? `${command} has a field named json, which the command line reads as answering in JSON: rename it.` : undefined;
15
+ }
6
16
  /** Whether a field of a command's input is a flag, true or false, as --hidden. */
7
17
  export function isBoolean(field) {
8
18
  return baseType(field) === "boolean";
@@ -24,7 +24,6 @@ export declare class SessionStore extends FileStore {
24
24
  private checkAll;
25
25
  private unwatchable;
26
26
  private changes;
27
- private wrote;
28
27
  private readonly outside;
29
28
  private beforeOutside;
30
29
  /** `systemFolders` hold the game systems, kept for the whole session; `watchFolder` is Node's watcher, unless a test gives its own. */