rpg-engine 0.7.0 → 0.9.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.
- package/dist/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.js +13 -13
- package/dist/campaign/create-campaign.js +10 -1
- package/dist/campaign/host-files.d.ts +2 -1
- package/dist/campaign/host-files.js +11 -11
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +55 -64
- package/dist/campaign/settings.js +171 -174
- package/dist/{cli.js → cli/cli.js} +3 -3
- package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
- package/dist/{command-line.js → cli/command-line.js} +21 -20
- package/dist/commands/advance.d.ts +1 -1
- package/dist/commands/advance.js +7 -7
- package/dist/commands/ask.d.ts +1 -8
- package/dist/commands/ask.js +16 -29
- package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
- package/dist/commands/{change.js → change/change.js} +46 -52
- package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
- package/dist/commands/{game-damage.js → change/damage.js} +3 -3
- package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
- package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
- package/dist/commands/config.d.ts +4 -4
- package/dist/commands/config.js +142 -138
- package/dist/commands/effect.d.ts +1 -1
- package/dist/commands/effect.js +11 -12
- package/dist/commands/find.d.ts +4 -4
- package/dist/commands/find.js +2 -2
- package/dist/commands/image.js +6 -6
- package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
- package/dist/commands/{import.js → import/import.js} +101 -101
- package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
- package/dist/commands/{game-import.js → import/run.js} +13 -12
- package/dist/commands/index.js +7 -7
- package/dist/commands/init.js +3 -3
- package/dist/commands/install.js +1 -1
- package/dist/commands/instructions.js +6 -6
- package/dist/commands/mode.d.ts +2 -2
- package/dist/commands/mode.js +8 -8
- package/dist/commands/mood.js +4 -4
- package/dist/commands/move.js +13 -20
- package/dist/commands/package.d.ts +2 -2
- package/dist/commands/package.js +138 -93
- package/dist/commands/rename.js +3 -3
- package/dist/commands/reveal.js +29 -18
- package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
- package/dist/commands/{roll.js → roll/roll.js} +69 -69
- package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
- package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
- package/dist/commands/rules.d.ts +2 -2
- package/dist/commands/rules.js +17 -9
- package/dist/commands/save.d.ts +1 -1
- package/dist/commands/save.js +18 -18
- package/dist/commands/scene.d.ts +4 -4
- package/dist/commands/scene.js +31 -28
- package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
- package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
- package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
- package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
- package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
- package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
- package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
- package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
- package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
- package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
- package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
- package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
- package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
- package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
- package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
- package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
- package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
- package/dist/commands/{game-events.js → shared/events.js} +20 -22
- package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
- package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
- package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
- package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
- package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
- package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
- package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
- package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
- package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
- package/dist/commands/{game-images.js → shared/images.js} +7 -6
- package/dist/commands/shared/inputs.d.ts +9 -0
- package/dist/commands/shared/inputs.js +12 -0
- package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
- package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
- package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
- package/dist/commands/{game-knowledge.js → shared/knowledge.js} +56 -44
- package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
- package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
- package/dist/commands/{game-library.js → shared/library.js} +70 -50
- package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
- package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
- package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
- package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
- package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
- package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
- package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
- package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
- package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
- package/dist/commands/{game-money.js → shared/money.js} +4 -4
- package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
- package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
- package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
- package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
- package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
- package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
- package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
- package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
- package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
- package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
- package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
- package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
- package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
- package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
- package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
- package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
- package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
- package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
- package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
- package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
- package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
- package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
- package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
- package/dist/commands/{parts.js → shared/parts.js} +4 -4
- package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
- package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
- package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
- package/dist/commands/{problems.js → shared/problems.js} +21 -22
- package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
- package/dist/commands/{progression.js → shared/progression.js} +4 -4
- package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
- package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
- package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
- package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
- package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
- package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
- package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
- package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
- package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +13 -5
- package/dist/commands/shared/rules.js +66 -0
- package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
- package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
- package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
- package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
- package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
- package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
- package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
- package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
- package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
- package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
- package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
- package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
- package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
- package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
- package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
- package/dist/commands/{game-time.js → shared/time.js} +6 -6
- package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
- package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
- package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
- package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
- package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
- package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
- package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
- package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
- package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
- package/dist/commands/{game-world.js → shared/world.js} +72 -76
- package/dist/commands/show.d.ts +4 -1
- package/dist/commands/show.js +36 -18
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.js +28 -28
- package/dist/commands/thoughts.js +3 -3
- package/dist/commands/trade.js +9 -10
- package/dist/commands/translate.d.ts +1 -1
- package/dist/commands/translate.js +3 -3
- package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
- package/dist/commands/{game-open.js → travel/open.js} +4 -5
- package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
- package/dist/commands/{route.js → travel/route.js} +9 -10
- package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
- package/dist/commands/{travel.js → travel/travel.js} +19 -21
- package/dist/commands/validate.js +5 -5
- package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
- package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
- package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
- package/dist/commands/{game-view-map.js → view/map.js} +15 -16
- package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
- package/dist/commands/{game-view-place.js → view/place.js} +108 -108
- package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
- package/dist/commands/{view.js → view/view.js} +41 -36
- package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
- package/dist/commands/{game-view-world.js → view/world.js} +7 -7
- package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
- package/dist/commands/{game-here.js → write/here.js} +18 -12
- package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
- package/dist/commands/{write.js → write/write.js} +44 -41
- package/dist/confirm/confirm.d.ts +2 -0
- package/dist/confirm/confirm.js +15 -5
- package/dist/core/consents.d.ts +3 -2
- package/dist/core/consents.js +43 -4
- package/dist/core/context.d.ts +8 -6
- package/dist/core/context.js +4 -2
- package/dist/core/download.js +16 -5
- package/dist/core/files.d.ts +8 -1
- package/dist/core/files.js +53 -21
- package/dist/core/formula.d.ts +7 -2
- package/dist/core/formula.js +63 -66
- package/dist/core/instruction-parts.js +1 -1
- package/dist/core/mood.d.ts +0 -1
- package/dist/core/mood.js +3 -3
- package/dist/core/package-api.d.ts +11 -0
- package/dist/core/package-api.js +2 -1
- package/dist/core/package-declarations.d.ts +9 -9
- package/dist/core/package-declarations.js +3 -3
- package/dist/core/process-mark.d.ts +8 -0
- package/dist/core/process-mark.js +72 -0
- package/dist/core/registry.d.ts +5 -0
- package/dist/core/registry.js +10 -0
- package/dist/core/session-store.d.ts +0 -1
- package/dist/core/session-store.js +11 -14
- package/dist/core/store.d.ts +4 -0
- package/dist/core/store.js +29 -8
- package/dist/core/text.d.ts +4 -0
- package/dist/core/text.js +11 -2
- package/dist/core/yaml-file.js +2 -2
- package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
- package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
- package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
- package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
- package/dist/dashboard/app.js +13 -13
- package/dist/dashboard/asked.js +1 -1
- package/dist/dashboard/dice/burn.js +1 -1
- package/dist/dashboard/dice/stage.js +1 -1
- package/dist/dashboard/game-words.js +4 -4
- package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
- package/dist/dashboard/{help.js → help/help.js} +6 -6
- package/dist/dashboard/journal.js +1 -1
- package/dist/dashboard/kit.js +6 -5
- package/dist/dashboard/labels.js +7 -3
- package/dist/dashboard/markdown.js +1 -1
- package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
- package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
- package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
- package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
- package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
- package/dist/dashboard/party.js +1 -1
- package/dist/dashboard/person-panel.js +2 -13
- package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
- package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
- package/dist/dashboard/scene.js +4 -4
- package/dist/dashboard/settings.js +1 -1
- package/dist/dashboard/sheet.js +4 -4
- package/dist/dashboard/text.js +6 -0
- package/dist/dashboard/top.js +2 -2
- package/dist/dashboard/turns.js +2 -2
- package/dist/dashboard/widgets.js +1 -1
- package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
- package/dist/dashboard/{lore.js → world/known.js} +1 -1
- package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
- package/dist/dashboard/{world-map.js → world/map.js} +1 -1
- package/dist/dashboard/{world.js → world/world.js} +14 -14
- package/dist/dice/evaluate.js +1 -1
- package/dist/dice/index.d.ts +2 -2
- package/dist/dice/index.js +2 -2
- package/dist/dice/notation.d.ts +2 -0
- package/dist/dice/notation.js +22 -4
- package/dist/documents/markup.js +2 -2
- package/dist/documents/read.js +29 -13
- package/dist/effects/effect.js +2 -5
- package/dist/extensions/extension.js +6 -8
- package/dist/extensions/index.d.ts +1 -4
- package/dist/extensions/index.js +1 -4
- package/dist/extensions/words.js +2 -1
- package/dist/{pictures → helpers}/briefs.js +17 -14
- package/dist/{pictures → helpers}/claude.js +8 -18
- package/dist/{pictures → helpers}/codex.js +3 -15
- package/dist/helpers/index.d.ts +7 -0
- package/dist/helpers/index.js +9 -0
- package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
- package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
- package/dist/images/images.js +7 -5
- package/dist/images/index.d.ts +1 -1
- package/dist/images/index.js +1 -1
- package/dist/importer/index.d.ts +1 -1
- package/dist/importer/index.js +1 -1
- package/dist/importer/work.d.ts +0 -2
- package/dist/importer/work.js +9 -30
- package/dist/instructions/index.d.ts +2 -0
- package/dist/instructions/index.js +10 -0
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/language-pack.js +15 -3
- package/dist/library/books.js +29 -83
- package/dist/{extensions → packages}/engine.d.ts +1 -1
- package/dist/{extensions → packages}/engine.js +1 -1
- package/dist/packages/index.d.ts +3 -0
- package/dist/packages/index.js +4 -0
- package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
- package/dist/{extensions/packages.js → packages/npm.js} +74 -45
- package/dist/page.d.ts +9 -11
- package/dist/page.js +1 -2
- package/dist/pages/check.js +31 -40
- package/dist/pages/containers.js +20 -20
- package/dist/pages/environment.js +15 -15
- package/dist/pages/index.d.ts +9 -9
- package/dist/pages/index.js +9 -9
- package/dist/pages/inheritance.d.ts +2 -1
- package/dist/pages/inheritance.js +24 -24
- package/dist/pages/load.js +7 -7
- package/dist/pages/maps.d.ts +20 -0
- package/dist/pages/maps.js +51 -1
- package/dist/pages/markdown.d.ts +2 -0
- package/dist/pages/markdown.js +110 -79
- package/dist/pages/page-file.d.ts +2 -1
- package/dist/pages/page-file.js +31 -29
- package/dist/pages/rename-page.d.ts +4 -1
- package/dist/pages/rename-page.js +7 -3
- package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
- package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
- package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
- package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
- package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
- package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
- package/dist/pages/system-pages.js +15 -15
- package/dist/pages/world.d.ts +4 -0
- package/dist/pages/world.js +52 -20
- package/dist/pages/write-page.js +35 -34
- package/dist/player-notes/index.d.ts +1 -1
- package/dist/player-notes/index.js +1 -1
- package/dist/rules/page-search.js +3 -4
- package/dist/rules/rule-book.js +1 -1
- package/dist/rules/search.js +21 -21
- package/dist/rules/shown.js +1 -3
- package/dist/saves/saves.d.ts +2 -2
- package/dist/saves/saves.js +15 -3
- package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
- package/dist/server/dashboard/files.d.ts +59 -0
- package/dist/server/dashboard/files.js +326 -0
- package/dist/server/dashboard/index.d.ts +114 -0
- package/dist/server/dashboard/index.js +419 -0
- package/dist/server/dashboard/news.d.ts +39 -0
- package/dist/server/dashboard/news.js +390 -0
- package/dist/server/dashboard/player.d.ts +48 -0
- package/dist/server/dashboard/player.js +242 -0
- package/dist/server/dashboard/ports.d.ts +10 -0
- package/dist/server/dashboard/ports.js +15 -0
- package/dist/server/dashboard/writes.d.ts +58 -0
- package/dist/server/dashboard/writes.js +492 -0
- package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
- package/dist/{mcp-server.js → server/mcp.js} +57 -42
- package/dist/systems/game-system.d.ts +5 -3
- package/dist/systems/game-system.js +178 -149
- package/dist/systems/index.d.ts +1 -1
- package/dist/systems/index.js +1 -1
- package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
- package/dist/{testing.js → testing/index.js} +32 -18
- package/dist/{system-checks.js → testing/system-checks.js} +18 -12
- package/dist/themes/theme.d.ts +3 -3
- package/dist/themes/theme.js +14 -14
- package/dist/time/calendar.js +5 -2
- package/dist/triggers/trigger.js +5 -8
- package/instructions/dashboard-guide.md +2 -1
- package/instructions/play.md +1 -1
- package/package.json +5 -5
- package/dist/commands/game-maps.d.ts +0 -20
- package/dist/commands/game-maps.js +0 -51
- package/dist/commands/game-rules.js +0 -36
- package/dist/dashboard-server.d.ts +0 -47
- package/dist/dashboard-server.js +0 -1830
- package/dist/pictures/index.d.ts +0 -7
- package/dist/pictures/index.js +0 -9
- /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
- /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
- /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
- /package/dist/commands/{notes.js → shared/notes.js} +0 -0
- /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
- /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
- /package/dist/dashboard/{people.js → packages/people.js} +0 -0
- /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
- /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
- /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
- /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
- /package/dist/{pictures → helpers}/chosen.js +0 -0
- /package/dist/{pictures → helpers}/claude.d.ts +0 -0
- /package/dist/{pictures → helpers}/codex.d.ts +0 -0
- /package/dist/{pictures → helpers}/stop.d.ts +0 -0
- /package/dist/{pictures → helpers}/stop.js +0 -0
- /package/dist/{pictures → helpers}/svg.d.ts +0 -0
- /package/dist/{pictures → helpers}/svg.js +0 -0
- /package/dist/{extensions → packages}/tarball.d.ts +0 -0
- /package/dist/{extensions → packages}/tarball.js +0 -0
- /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
- /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
- /package/dist/{player-acts.js → server/player-acts.js} +0 -0
- /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
package/dist/rules/rule-book.js
CHANGED
|
@@ -21,7 +21,7 @@ export function bookTitles(sections) {
|
|
|
21
21
|
* A byte order mark and the properties at the top (---) are not text; code blocks and %% comments hold no titles.
|
|
22
22
|
*/
|
|
23
23
|
export function ruleSections(text, file, source) {
|
|
24
|
-
const content = withoutProperties(text.replace(
|
|
24
|
+
const content = withoutProperties(text.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n"));
|
|
25
25
|
const markers = markersOf(content);
|
|
26
26
|
const firstStart = markers[0]?.start ?? content.length;
|
|
27
27
|
if (content.slice(0, firstStart).trim() !== "") {
|
package/dist/rules/search.js
CHANGED
|
@@ -39,10 +39,6 @@ export function isTitled(section, text) {
|
|
|
39
39
|
}
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
-
/** The titles a text gives, as in "Combat › Grappling" (› > or / between them), without the stop that may end one. */
|
|
43
|
-
function titlesIn(text) {
|
|
44
|
-
return text.split(/\s*[›>/]\s*/).map((title) => title.trim().replace(/[.:]$/, "")).filter((title) => title !== "");
|
|
45
|
-
}
|
|
46
42
|
/** Whether a text holds every word of a search, as search compares words: what finds a precedent. */
|
|
47
43
|
export function hasAllWords(text, search) {
|
|
48
44
|
const words = searchWords(text);
|
|
@@ -52,23 +48,6 @@ export function hasAllWords(text, search) {
|
|
|
52
48
|
export function searchWords(text) {
|
|
53
49
|
return comparableText(text).match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
54
50
|
}
|
|
55
|
-
/** The words of a section's title, of the titles above it and of its own text, each once: cut once for each section, which never changes (D-194). */
|
|
56
|
-
function wordsOf(section) {
|
|
57
|
-
let words = wordsBySection.get(section);
|
|
58
|
-
if (words === undefined) {
|
|
59
|
-
const distinct = (text) => [...new Set(searchWords(text))];
|
|
60
|
-
words = { title: distinct(section.path.at(-1) ?? ""), above: distinct(section.path.slice(0, -1).join(" ")), text: distinct(section.ownText) };
|
|
61
|
-
wordsBySection.set(section, words);
|
|
62
|
-
}
|
|
63
|
-
return words;
|
|
64
|
-
}
|
|
65
|
-
const wordsBySection = new WeakMap();
|
|
66
|
-
// A form of a word may change this many of its last letters, and must keep at least the first four (all of a shorter word).
|
|
67
|
-
const formLetters = 3;
|
|
68
|
-
const stemLetters = 4;
|
|
69
|
-
function hasForm(words, searched) {
|
|
70
|
-
return words.some((word) => sameWord(searched, word));
|
|
71
|
-
}
|
|
72
51
|
/**
|
|
73
52
|
* Whether a word of a text is a form of a word searched (RUL-4): the two differ at most in their last three letters, and share at least the first four, or all of a shorter word.
|
|
74
53
|
* Grapple finds grappled and grappling, rest finds resting but not restrained, concentration not conceal; two letters find only themselves.
|
|
@@ -86,6 +65,27 @@ export function sameWord(searched, word) {
|
|
|
86
65
|
const doubledInSearched = common > 0 && searched[common] === searched[common - 1] ? 1 : 0;
|
|
87
66
|
return word.length - common <= formLetters + doubledInWord && common >= Math.max(Math.min(searched.length, stemLetters), searched.length - formLetters - doubledInSearched);
|
|
88
67
|
}
|
|
68
|
+
/** The titles a text gives, as in "Combat › Grappling" (› > or / between them), without the stop that may end one. */
|
|
69
|
+
function titlesIn(text) {
|
|
70
|
+
return text.split(/\s*[›>/]\s*/).map((title) => title.trim().replace(/[.:]$/, "")).filter((title) => title !== "");
|
|
71
|
+
}
|
|
72
|
+
/** The words of a section's title, of the titles above it and of its own text, each once: cut once for each section, which never changes (D-194). */
|
|
73
|
+
function wordsOf(section) {
|
|
74
|
+
let words = wordsBySection.get(section);
|
|
75
|
+
if (words === undefined) {
|
|
76
|
+
const distinct = (text) => [...new Set(searchWords(text))];
|
|
77
|
+
words = { title: distinct(section.path.at(-1) ?? ""), above: distinct(section.path.slice(0, -1).join(" ")), text: distinct(section.ownText) };
|
|
78
|
+
wordsBySection.set(section, words);
|
|
79
|
+
}
|
|
80
|
+
return words;
|
|
81
|
+
}
|
|
82
|
+
const wordsBySection = new WeakMap();
|
|
83
|
+
// A form of a word may change this many of its last letters, and must keep at least the first four (all of a shorter word).
|
|
84
|
+
const formLetters = 3;
|
|
85
|
+
const stemLetters = 4;
|
|
86
|
+
function hasForm(words, searched) {
|
|
87
|
+
return words.some((word) => sameWord(searched, word));
|
|
88
|
+
}
|
|
89
89
|
/** How much of a search a section holds: the weight of each word it has, and again for each word in its title (half for the titles above it). */
|
|
90
90
|
function scoreOf(entry, searched, weights) {
|
|
91
91
|
let score = 0;
|
package/dist/rules/shown.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wordCount } from "../core/text.js";
|
|
1
2
|
// Sections shown whole when the text names none of them; the others are only named.
|
|
2
3
|
const wholeFound = 3;
|
|
3
4
|
/**
|
|
@@ -39,6 +40,3 @@ function holds(outer, inner) {
|
|
|
39
40
|
return outer.source === inner.source && outer.file === inner.file && outer.path.length <= inner.path.length && outer.path.every((title, index) => inner.path[index] === title)
|
|
40
41
|
&& outer.text.includes(inner.text);
|
|
41
42
|
}
|
|
42
|
-
function wordCount(text) {
|
|
43
|
-
return text.split(/\s+/).filter((word) => word !== "").length;
|
|
44
|
-
}
|
package/dist/saves/saves.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export interface Save {
|
|
|
6
6
|
}
|
|
7
7
|
/** A zip of files, given by their paths inside it with forward slashes, such as world/characters/Kira.md. */
|
|
8
8
|
export declare function packFiles(files: Record<string, Uint8Array>): Uint8Array;
|
|
9
|
-
/** The files a zip holds, by their paths inside it; folders are left out. */
|
|
10
|
-
export declare function unpackFiles(zip: Uint8Array): Record<string, Uint8Array>;
|
|
9
|
+
/** The files a zip holds, by their paths inside it; folders are left out. It throws before unpacking a zip that would weigh more than `most` bytes. */
|
|
10
|
+
export declare function unpackFiles(zip: Uint8Array, most?: number): Record<string, Uint8Array>;
|
|
11
11
|
/** The file name of a save: its number, then the game date and the label it has, such as "003 - day 2, 06.10 - Scontro all'ossario.zip". */
|
|
12
12
|
export declare function saveFileName(number: number, parts: (string | undefined)[]): string;
|
|
13
13
|
/** The saves among the names of the files of a folder, in the order of their numbers; other files are left out. */
|
package/dist/saves/saves.js
CHANGED
|
@@ -5,13 +5,25 @@ const saveFilePattern = /^(\d{3,}) - (.+)\.zip$/;
|
|
|
5
5
|
const notInFileNames = /[\\/:*?"<>|\u0000-\u0008\u000e-\u001f]/g;
|
|
6
6
|
// The longest label a file name takes, in characters, never cutting one in two.
|
|
7
7
|
const longestLabel = 120;
|
|
8
|
+
// The most a save unpacks to: a campaign's pages and pictures, never the memory of the computer.
|
|
9
|
+
const largestSave = 1024 * 1024 * 1024;
|
|
8
10
|
/** A zip of files, given by their paths inside it with forward slashes, such as world/characters/Kira.md. */
|
|
9
11
|
export function packFiles(files) {
|
|
10
12
|
return zipSync(files, { level: 6 });
|
|
11
13
|
}
|
|
12
|
-
/** The files a zip holds, by their paths inside it; folders are left out. */
|
|
13
|
-
export function unpackFiles(zip) {
|
|
14
|
-
|
|
14
|
+
/** The files a zip holds, by their paths inside it; folders are left out. It throws before unpacking a zip that would weigh more than `most` bytes. */
|
|
15
|
+
export function unpackFiles(zip, most = largestSave) {
|
|
16
|
+
let declared = 0;
|
|
17
|
+
const read = unzipSync(zip, {
|
|
18
|
+
filter: (file) => {
|
|
19
|
+
declared += file.originalSize;
|
|
20
|
+
if (declared > most) {
|
|
21
|
+
throw new Error(`it unpacks to more than ${Math.round(most / 1024 / 1024)} MB, more than a save may`);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return Object.fromEntries(Object.entries(read).filter(([path]) => !path.endsWith("/")));
|
|
15
27
|
}
|
|
16
28
|
/** The file name of a save: its number, then the game date and the label it has, such as "003 - day 2, 06.10 - Scontro all'ossario.zip". */
|
|
17
29
|
export function saveFileName(number, parts) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Claude Code's doorbell for the player's sentences on the dashboard (D-495): `rpg --listen`, the Stop hook init writes, waits at the dashboard of its own
|
|
2
2
|
// chat and, when the player says a sentence, tells the chat to call status. It never carries the sentence, which reaches the master in that call.
|
|
3
3
|
import { get } from "node:http";
|
|
4
|
-
import { findCampaign } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { findCampaign } from "../campaign/index.js";
|
|
5
|
+
import { samePath } from "../library/index.js";
|
|
6
|
+
import { campaignPorts } from "./dashboard/ports.js";
|
|
7
7
|
/** What the chat hears from the doorbell: never the player's words, only where to read them. */
|
|
8
8
|
export const bellLine = "The player acted on the dashboard: call status to read what they did.";
|
|
9
9
|
/** Reads the hook's input, waits for the doorbell, and ends the process as Claude Code's asyncRewake reads it: 2 with the line to wake the chat, else 0. */
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type PageModule } from "../../commands/shared/packages/extensions.ts";
|
|
3
|
+
import type { Served } from "./index.ts";
|
|
4
|
+
export declare const themeAddress = "/theme";
|
|
5
|
+
export declare const builtPage: string;
|
|
6
|
+
export declare const pagePolicy: string;
|
|
7
|
+
export declare const pageHtml: string;
|
|
8
|
+
export declare const mostSaid = 500;
|
|
9
|
+
export declare const securityHeaders: {
|
|
10
|
+
"X-Content-Type-Options": string;
|
|
11
|
+
"Referrer-Policy": string;
|
|
12
|
+
"Content-Security-Policy": string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A language package's phrases over those the page ships, or its Guide, for a language one is installed for (D-485 (3)); false where none is, and the
|
|
16
|
+
* page's own file is sent.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sendPacked(path: string, response: ServerResponse, served: Served): boolean;
|
|
19
|
+
/** A file of the built page, by its path in the address: only a script, a style sheet or a picture inside its folder, such as its logo. */
|
|
20
|
+
export declare function pageFile(folder: string, path: string): string | undefined;
|
|
21
|
+
/** A module the page imports from a package, as a file of the package; undefined for another name, or when the package is missing. */
|
|
22
|
+
export declare function vendorModule(name: string): string | undefined;
|
|
23
|
+
/** A script, a style sheet or a picture of the page, as it is on the disk. */
|
|
24
|
+
export declare function sendFile(file: string | undefined, path: string, request: IncomingMessage, response: ServerResponse, served: Served): void;
|
|
25
|
+
/**
|
|
26
|
+
* A file of a package's page code (D-510, D-511), at pkg/<package>/<version>/<path>: only of the campaign's system or one of its extensions, at the version
|
|
27
|
+
* installed, whose code runs, and only beside its page module, by real paths, links included; a script, a style sheet or a picture. Undefined for anything else.
|
|
28
|
+
*/
|
|
29
|
+
export declare function packagePageFile(path: string, served: Served): string | undefined;
|
|
30
|
+
/** The page modules of the campaign's packages whose code runs: its system's and its extensions'. */
|
|
31
|
+
export declare function pageModulesOf(root: string, served: Served): PageModule[];
|
|
32
|
+
/**
|
|
33
|
+
* The theme of the campaign's game system (D-528): its CSS of custom properties, its icons and its name, which the page uses while the player keeps the game's
|
|
34
|
+
* style on; refused when it does not pass its checks, which validate says; the system's name alone when it names none.
|
|
35
|
+
*/
|
|
36
|
+
export declare function themeNow(response: ServerResponse, served: Served): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face
|
|
39
|
+
* or a picture. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sendThemeFile(name: string, query: URLSearchParams, request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* A picture of the campaign or of its game system, by the name of its file (D-267): only a file an images folder has, looked for by name, never by a path. It
|
|
44
|
+
* runs nothing, even an SVG opened by itself.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sendImage(name: string, request: IncomingMessage, response: ServerResponse, served: Served): void;
|
|
47
|
+
/**
|
|
48
|
+
* The page's words in a language the package does not ship (D-406): what this computer has translated so far, and whether it is translating them, with the
|
|
49
|
+
* game system's; the phrases the page lacks now, sent to go first.
|
|
50
|
+
*/
|
|
51
|
+
export declare function pageWords(request: IncomingMessage, response: ServerResponse, served: Served, url: URL): Promise<void>;
|
|
52
|
+
/** A request's body as bytes, up to `most`; undefined when it is more. */
|
|
53
|
+
export declare function readBytes(request: IncomingMessage, most: number): Promise<Uint8Array | undefined>;
|
|
54
|
+
/** A request's body as JSON, up to `most` characters; undefined when it is more, or no JSON. */
|
|
55
|
+
export declare function readBody(request: IncomingMessage, most?: number): Promise<unknown>;
|
|
56
|
+
export declare function sendJson(response: ServerResponse, status: number, body: unknown): void;
|
|
57
|
+
export declare function send(response: ServerResponse, status: number, type: string, body: string, policy?: string): void;
|
|
58
|
+
/** A part of an address as written, without its percent signs; undefined when they do not decode. */
|
|
59
|
+
export declare function decoded(part: string): string | undefined;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// What the dashboard serves: its page, the modules it imports from packages, a package's page code, the theme's files, the pictures and the page's words,
|
|
2
|
+
// each only from its own folder; and what every route of the server uses to read a request and to send its answer.
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, extname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { findCampaign } from "../../campaign/index.js";
|
|
9
|
+
import { imageFolders } from "../../commands/shared/images.js";
|
|
10
|
+
import { campaignPackages } from "../../commands/shared/packages/code.js";
|
|
11
|
+
import { campaignPageModules } from "../../commands/shared/packages/extensions.js";
|
|
12
|
+
import { campaignTheme } from "../../commands/shared/theme.js";
|
|
13
|
+
import { campaignSystem } from "../../commands/shared/world.js";
|
|
14
|
+
import { realPath } from "../../core/files.js";
|
|
15
|
+
import { files, isInside, withFiles } from "../../core/store.js";
|
|
16
|
+
import { findHiddenImage, findImage } from "../../images/index.js";
|
|
17
|
+
import { languagePackFor, packGuide, packPhrases } from "../../languages/index.js";
|
|
18
|
+
import { drawnOrnament, themeCss, themeFile } from "../../themes/index.js";
|
|
19
|
+
const imageTypes = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".svg": "image/svg+xml" };
|
|
20
|
+
const pageTypes = {
|
|
21
|
+
".js": "text/javascript; charset=utf-8",
|
|
22
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
23
|
+
".css": "text/css; charset=utf-8",
|
|
24
|
+
".svg": "image/svg+xml",
|
|
25
|
+
".png": "image/png",
|
|
26
|
+
".jpg": "image/jpeg",
|
|
27
|
+
".glb": "model/gltf-binary",
|
|
28
|
+
".json": "application/json; charset=utf-8",
|
|
29
|
+
".md": "text/markdown; charset=utf-8",
|
|
30
|
+
".wav": "audio/wav",
|
|
31
|
+
};
|
|
32
|
+
// Where the page finds the theme's files, and what they may be: faces and pictures.
|
|
33
|
+
export const themeAddress = "/theme";
|
|
34
|
+
const themeTypes = { ...imageTypes, ".woff2": "font/woff2", ".woff": "font/woff", ".ttf": "font/ttf", ".otf": "font/otf" };
|
|
35
|
+
// A picture runs nothing, even an SVG opened by itself.
|
|
36
|
+
const picturePolicy = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
|
37
|
+
// From src/ and from dist/ alike, the built page is in dist/dashboard, one level up.
|
|
38
|
+
export const builtPage = fileURLToPath(new URL("../../../dist/dashboard/", import.meta.url));
|
|
39
|
+
// The modules the page imports from packages, by the names the import map gives them: a package, and a file in it. three.module.js imports three.core.js
|
|
40
|
+
// beside it; three's loader of the dice's models imports two of its utilities beside it; the room the metal dice mirror is three's too; Rapier's module
|
|
41
|
+
// moves the dice.
|
|
42
|
+
const vendorModules = {
|
|
43
|
+
"preact.js": ["preact", "dist/preact.module.js"],
|
|
44
|
+
"hooks.js": ["preact", "hooks/dist/hooks.module.js"],
|
|
45
|
+
"jsx-runtime.js": ["preact", "jsx-runtime/dist/jsxRuntime.module.js"],
|
|
46
|
+
"three.module.js": ["three", "build/three.module.js"],
|
|
47
|
+
"three.core.js": ["three", "build/three.core.js"],
|
|
48
|
+
"three/addons/loaders/GLTFLoader.js": ["three", "examples/jsm/loaders/GLTFLoader.js"],
|
|
49
|
+
"three/addons/utils/BufferGeometryUtils.js": ["three", "examples/jsm/utils/BufferGeometryUtils.js"],
|
|
50
|
+
"three/addons/utils/SkeletonUtils.js": ["three", "examples/jsm/utils/SkeletonUtils.js"],
|
|
51
|
+
"three/addons/environments/RoomEnvironment.js": ["three", "examples/jsm/environments/RoomEnvironment.js"],
|
|
52
|
+
"rapier.mjs": ["@dimforge/rapier3d-compat", "dist/rapier.mjs"],
|
|
53
|
+
};
|
|
54
|
+
const importMap = JSON.stringify({
|
|
55
|
+
imports: {
|
|
56
|
+
"preact": "/vendor/preact.js",
|
|
57
|
+
"preact/hooks": "/vendor/hooks.js",
|
|
58
|
+
"preact/jsx-runtime": "/vendor/jsx-runtime.js",
|
|
59
|
+
"three": "/vendor/three.module.js",
|
|
60
|
+
"three/addons/": "/vendor/three/addons/",
|
|
61
|
+
"@dimforge/rapier3d-compat": "/vendor/rapier.mjs",
|
|
62
|
+
// The kit the extensions' page code is drawn with (D-510).
|
|
63
|
+
"rpg-engine/page": "/kit.js",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
// The page runs only its own files and the import map written in it, known by its hash; and the physics of the dice, which Rapier's module carries as
|
|
67
|
+
// WebAssembly and compiles.
|
|
68
|
+
export const pagePolicy = `default-src 'self'; script-src 'self' 'wasm-unsafe-eval' 'sha256-${createHash("sha256").update(importMap).digest("base64")}'; base-uri 'none'; form-action 'none'`;
|
|
69
|
+
export const pageHtml = [
|
|
70
|
+
"<!doctype html>",
|
|
71
|
+
'<html lang="en">',
|
|
72
|
+
'<meta charset="utf-8">',
|
|
73
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
74
|
+
'<meta name="color-scheme" content="light dark">',
|
|
75
|
+
"<title>RPG Engine</title>",
|
|
76
|
+
'<link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">',
|
|
77
|
+
'<link rel="icon" href="/assets/icon-32.png" sizes="32x32">',
|
|
78
|
+
'<link rel="apple-touch-icon" href="/assets/icon-180.png">',
|
|
79
|
+
'<link rel="stylesheet" href="/style.css">',
|
|
80
|
+
`<script type="importmap">${importMap}</script>`,
|
|
81
|
+
'<script type="module" src="/app.js"></script>',
|
|
82
|
+
'<div id="app"></div>',
|
|
83
|
+
"",
|
|
84
|
+
].join("\n");
|
|
85
|
+
// How many characters the player's own words may have, in place of a button (ASK-10).
|
|
86
|
+
export const mostSaid = 500;
|
|
87
|
+
export const securityHeaders = { "X-Content-Type-Options": "nosniff", "Referrer-Policy": "no-referrer", "Content-Security-Policy": "default-src 'self'" };
|
|
88
|
+
/**
|
|
89
|
+
* A language package's phrases over those the page ships, or its Guide, for a language one is installed for (D-485 (3)); false where none is, and the
|
|
90
|
+
* page's own file is sent.
|
|
91
|
+
*/
|
|
92
|
+
export function sendPacked(path, response, served) {
|
|
93
|
+
const match = /^\/(i18n|guide)\/([a-z]{2,3}(?:-[a-z0-9]{2,8})*)\.(json|md)$/i.exec(path);
|
|
94
|
+
const pack = match === null ? undefined : languagePackFor(served.context.extensionFolders ?? [], match[2]);
|
|
95
|
+
if (match === null || pack === undefined) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (match[1] === "i18n") {
|
|
99
|
+
const shipped = JSON.parse(files().text(join(served.page, "i18n", `${match[2]}.json`)) ?? "{}");
|
|
100
|
+
sendJson(response, 200, { ...shipped, ...packPhrases(pack) });
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
const guide = packGuide(pack);
|
|
104
|
+
if (guide === undefined) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
send(response, 200, "text/markdown; charset=utf-8", guide);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/** A file of the built page, by its path in the address: only a script, a style sheet or a picture inside its folder, such as its logo. */
|
|
111
|
+
export function pageFile(folder, path) {
|
|
112
|
+
const relative = decoded(path);
|
|
113
|
+
const file = relative === undefined ? undefined : resolve(folder, `.${relative}`);
|
|
114
|
+
return file !== undefined && isInside(folder, file) && pageTypes[extname(file)] !== undefined ? file : undefined;
|
|
115
|
+
}
|
|
116
|
+
/** A module the page imports from a package, as a file of the package; undefined for another name, or when the package is missing. */
|
|
117
|
+
export function vendorModule(name) {
|
|
118
|
+
const module = vendorModules[name];
|
|
119
|
+
try {
|
|
120
|
+
// The package's folder, from where its main file is: node_modules/<package>.
|
|
121
|
+
const main = module === undefined ? undefined : createRequire(import.meta.url).resolve(module[0]);
|
|
122
|
+
const folder = main === undefined || module === undefined ? undefined : main.slice(0, main.lastIndexOf(join("node_modules", module[0])) + join("node_modules", module[0]).length);
|
|
123
|
+
return folder === undefined || module === undefined ? undefined : join(folder, module[1]);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** A script, a style sheet or a picture of the page, as it is on the disk. */
|
|
130
|
+
export function sendFile(file, path, request, response, served) {
|
|
131
|
+
const type = file === undefined ? undefined : pageTypes[extname(file)];
|
|
132
|
+
const bytes = file === undefined ? undefined : withFiles(served.session, () => files().bytes(file));
|
|
133
|
+
if (bytes === undefined || type === undefined) {
|
|
134
|
+
send(response, 404, "text/plain; charset=utf-8", `Nothing at ${path}.`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
sendTagged(request, response, bytes, { "Content-Type": type, "Content-Security-Policy": type.startsWith("image/") ? picturePolicy : securityHeaders["Content-Security-Policy"] });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A file of a package's page code (D-510, D-511), at pkg/<package>/<version>/<path>: only of the campaign's system or one of its extensions, at the version
|
|
141
|
+
* installed, whose code runs, and only beside its page module, by real paths, links included; a script, a style sheet or a picture. Undefined for anything else.
|
|
142
|
+
*/
|
|
143
|
+
export function packagePageFile(path, served) {
|
|
144
|
+
const parts = path.split("/").map(decoded);
|
|
145
|
+
if (parts.some((part) => part === undefined)) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const [name, version, ...rest] = parts;
|
|
149
|
+
const root = findCampaign(served.context.folder);
|
|
150
|
+
const module = root === undefined ? undefined : withFiles(served.session, () => pageModulesOf(root, served).find((one) => one.package === name && one.version === version));
|
|
151
|
+
if (module === undefined || rest.length === 0 || ![".js", ".mjs", ".css", ".svg"].includes(extname(rest.at(-1) ?? ""))) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
const folder = realPath(dirname(module.file));
|
|
155
|
+
const file = realPath(resolve(folder, ...rest));
|
|
156
|
+
return isInside(folder, file) ? file : undefined;
|
|
157
|
+
}
|
|
158
|
+
/** The page modules of the campaign's packages whose code runs: its system's and its extensions'. */
|
|
159
|
+
export function pageModulesOf(root, served) {
|
|
160
|
+
return campaignPageModules(root, served.context, campaignSystem(root, served.context));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The theme of the campaign's game system (D-528): its CSS of custom properties, its icons and its name, which the page uses while the player keeps the game's
|
|
164
|
+
* style on; refused when it does not pass its checks, which validate says; the system's name alone when it names none.
|
|
165
|
+
*/
|
|
166
|
+
export async function themeNow(response, served) {
|
|
167
|
+
const root = findCampaign(served.context.folder);
|
|
168
|
+
await served.session.ready();
|
|
169
|
+
const system = root === undefined ? undefined : withFiles(served.session, () => campaignSystem(root, served.context));
|
|
170
|
+
const reading = root === undefined ? undefined : withFiles(served.session, () => campaignTheme(root, served.context));
|
|
171
|
+
if (system === undefined) {
|
|
172
|
+
sendJson(response, 200, {});
|
|
173
|
+
}
|
|
174
|
+
else if (reading === undefined) {
|
|
175
|
+
// No theme, but the system's name, which keeps the player's switch of its page style, if its page module gives one.
|
|
176
|
+
sendJson(response, 200, { system: system.name });
|
|
177
|
+
}
|
|
178
|
+
else if (reading.theme === undefined) {
|
|
179
|
+
sendJson(response, 200, { system: reading.system, refused: true });
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
sendJson(response, 200, { system: reading.system, name: reading.theme.name, css: themeCss(reading.theme, themeAddress), icons: reading.theme.icons });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face
|
|
187
|
+
* or a picture. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored.
|
|
188
|
+
*/
|
|
189
|
+
export async function sendThemeFile(name, query, request, response, served) {
|
|
190
|
+
const root = findCampaign(served.context.folder);
|
|
191
|
+
await served.session.ready();
|
|
192
|
+
const folder = root === undefined ? undefined : withFiles(served.session, () => campaignTheme(root, served.context))?.theme?.folder;
|
|
193
|
+
const given = decoded(name);
|
|
194
|
+
const file = folder === undefined || given === undefined ? undefined : themeFile(folder, given);
|
|
195
|
+
const type = file === undefined ? undefined : themeTypes[extname(file).toLowerCase()];
|
|
196
|
+
if (file === undefined || type === undefined) {
|
|
197
|
+
send(response, 404, "text/plain; charset=utf-8", `Nothing at ${themeAddress}/${name}.`);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const ink = query.get("ink");
|
|
201
|
+
const tinted = type === imageTypes[".svg"] && ink !== null && /^#[0-9a-f]{6}$/i.test(ink);
|
|
202
|
+
const bytes = withFiles(served.session, () => (tinted ? Buffer.from(drawnOrnament(files().text(file) ?? "", ink, query.has("mirrored"))) : files().bytes(file)));
|
|
203
|
+
if (bytes === undefined) {
|
|
204
|
+
send(response, 404, "text/plain; charset=utf-8", `Nothing at ${themeAddress}/${name}.`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
sendTagged(request, response, bytes, { "Content-Type": type, "Content-Security-Policy": type.startsWith("image/") ? picturePolicy : securityHeaders["Content-Security-Policy"] });
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A picture of the campaign or of its game system, by the name of its file (D-267): only a file an images folder has, looked for by name, never by a path. It
|
|
211
|
+
* runs nothing, even an SVG opened by itself.
|
|
212
|
+
*/
|
|
213
|
+
export function sendImage(name, request, response, served) {
|
|
214
|
+
// A package's own, which its widgets show, at an address of its own, ext/<package>/<file>, never mistaken for the campaign's (D-502, D-514).
|
|
215
|
+
const [, extensionName, extensionFile] = /^ext\/([^/]+)\/([^/]+)$/.exec(name) ?? [];
|
|
216
|
+
const fileName = decoded(extensionFile ?? name);
|
|
217
|
+
const ownerName = extensionName === undefined ? undefined : decoded(extensionName);
|
|
218
|
+
const file = fileName === undefined || /[\\/]/.test(fileName) ? undefined : withFiles(served.session, () => {
|
|
219
|
+
const root = findCampaign(served.context.folder);
|
|
220
|
+
if (root === undefined) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
if (extensionName !== undefined) {
|
|
224
|
+
const owner = campaignPackages(root, served.context).find((extension) => extension.name === ownerName);
|
|
225
|
+
return owner === undefined ? undefined : findImage([owner.folder], fileName);
|
|
226
|
+
}
|
|
227
|
+
// A stranger's picture comes by a name of its bytes, from the campaign's own (D-420).
|
|
228
|
+
return findImage(imageFolders(root, served.context), fileName) ?? findHiddenImage([root], fileName);
|
|
229
|
+
});
|
|
230
|
+
const type = file === undefined ? undefined : imageTypes[extname(file).toLowerCase()];
|
|
231
|
+
const bytes = file === undefined ? undefined : withFiles(served.session, () => files().bytes(file));
|
|
232
|
+
if (bytes === undefined || type === undefined) {
|
|
233
|
+
send(response, 404, "text/plain; charset=utf-8", `There is no picture ${fileName ?? name}.`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// The page asks for a picture by its name and when it last changed (D-277): a new address when it changes, and the same one comes back as not modified on a reload.
|
|
237
|
+
sendTagged(request, response, bytes, { "Content-Type": type, "Content-Security-Policy": picturePolicy });
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The page's words in a language the package does not ship (D-406): what this computer has translated so far, and whether it is translating them, with the
|
|
241
|
+
* game system's; the phrases the page lacks now, sent to go first.
|
|
242
|
+
*/
|
|
243
|
+
export async function pageWords(request, response, served, url) {
|
|
244
|
+
const code = /^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i;
|
|
245
|
+
if (request.method === "POST") {
|
|
246
|
+
const parsed = z.object({ language: z.string().regex(code), first: z.array(z.string().max(500)).max(1000) }).strict().safeParse(await readBody(request, 64_000));
|
|
247
|
+
if (!parsed.success) {
|
|
248
|
+
sendJson(response, 400, { error: "Send the language and the phrases the page lacks now, { language, first }." });
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
served.words.ask(parsed.data.language.toLowerCase(), parsed.data.first);
|
|
252
|
+
sendJson(response, 202, {});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const language = url.searchParams.get("language") ?? "";
|
|
256
|
+
if (!code.test(language)) {
|
|
257
|
+
sendJson(response, 400, { error: "Give the language by its code, such as vi or pt-BR." });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const system = withFiles(served.session, () => {
|
|
261
|
+
const root = findCampaign(served.context.folder);
|
|
262
|
+
const found = root === undefined ? undefined : campaignSystem(root, served.context);
|
|
263
|
+
return found === undefined ? undefined : { name: found.name, folder: found.folder };
|
|
264
|
+
});
|
|
265
|
+
sendJson(response, 200, served.words.read(language.toLowerCase(), system));
|
|
266
|
+
}
|
|
267
|
+
/** A request's body as bytes, up to `most`; undefined when it is more. */
|
|
268
|
+
export async function readBytes(request, most) {
|
|
269
|
+
const chunks = [];
|
|
270
|
+
let size = 0;
|
|
271
|
+
for await (const chunk of request) {
|
|
272
|
+
size += chunk.length;
|
|
273
|
+
if (size > most) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
chunks.push(chunk);
|
|
277
|
+
}
|
|
278
|
+
return Buffer.concat(chunks);
|
|
279
|
+
}
|
|
280
|
+
/** A request's body as JSON, up to `most` characters; undefined when it is more, or no JSON. */
|
|
281
|
+
export async function readBody(request, most = 4096) {
|
|
282
|
+
let text = "";
|
|
283
|
+
// Whole characters, never a letter cut in two between the pieces of a long body.
|
|
284
|
+
request.setEncoding("utf8");
|
|
285
|
+
for await (const chunk of request) {
|
|
286
|
+
text += String(chunk);
|
|
287
|
+
if (text.length > most) {
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
return JSON.parse(text);
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
export function sendJson(response, status, body) {
|
|
299
|
+
send(response, status, "application/json; charset=utf-8", JSON.stringify(body));
|
|
300
|
+
}
|
|
301
|
+
export function send(response, status, type, body, policy = securityHeaders["Content-Security-Policy"]) {
|
|
302
|
+
if (response.headersSent) {
|
|
303
|
+
response.end();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
response.writeHead(status, { ...securityHeaders, "Content-Security-Policy": policy, "Content-Type": type, "Cache-Control": "no-store" }).end(body);
|
|
307
|
+
}
|
|
308
|
+
/** A part of an address as written, without its percent signs; undefined when they do not decode. */
|
|
309
|
+
export function decoded(part) {
|
|
310
|
+
try {
|
|
311
|
+
return decodeURIComponent(part);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/** Bytes with a tag of what they hold, read again at each load: the same bytes come back as not modified, as three.js and the dice after the first load. */
|
|
318
|
+
function sendTagged(request, response, bytes, headers) {
|
|
319
|
+
const tag = `"${createHash("sha1").update(bytes).digest("base64url")}"`;
|
|
320
|
+
const all = { ...securityHeaders, ...headers, "Cache-Control": "no-cache", "ETag": tag };
|
|
321
|
+
if (request.headers["if-none-match"] === tag) {
|
|
322
|
+
response.writeHead(304, all).end();
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
response.writeHead(200, all).end(request.method === "HEAD" ? undefined : bytes);
|
|
326
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type ServerResponse } from "node:http";
|
|
2
|
+
import type { PlayerSetting } from "../../commands/config.ts";
|
|
3
|
+
import type { Catalog } from "../../commands/shared/packages/catalog.ts";
|
|
4
|
+
import { type PageTranslator } from "../../commands/shared/page-words.ts";
|
|
5
|
+
import type { Context, Player } from "../../core/context.ts";
|
|
6
|
+
import type { SessionStore } from "../../core/session-store.ts";
|
|
7
|
+
import { type Acts } from "../player-acts.ts";
|
|
8
|
+
import { type Asked, type ShownCard } from "./player.ts";
|
|
9
|
+
import { type PackageAction, type PackagePhase } from "./writes.ts";
|
|
10
|
+
export { campaignPorts, dashboardPorts } from "./ports.ts";
|
|
11
|
+
/** A dashboard that is running: its link, and how to stop it. */
|
|
12
|
+
export interface Dashboard {
|
|
13
|
+
url: string;
|
|
14
|
+
/** The player through the page: ask's buttons, while a page is open (D-279). */
|
|
15
|
+
player: Player;
|
|
16
|
+
/**
|
|
17
|
+
* What the player did on the page since it was last taken, for the master's next call: the saves, in order (D-359), then each setting as it is now against
|
|
18
|
+
* how it was (D-341); and what gives it back when that call never answers.
|
|
19
|
+
*/
|
|
20
|
+
news(told?: Set<string>): {
|
|
21
|
+
lines: string[];
|
|
22
|
+
restore(): void;
|
|
23
|
+
};
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/** Where the dashboard listens, and the page it serves. */
|
|
27
|
+
export interface DashboardOptions {
|
|
28
|
+
/** The ports to try, in turn (D-272). */
|
|
29
|
+
ports?: number[];
|
|
30
|
+
/** The folder of the built page: dist/dashboard. */
|
|
31
|
+
page?: string;
|
|
32
|
+
/** How long a question waits for a page to come back, after the last one closed: a few seconds; less in the tests. */
|
|
33
|
+
pageReturn?: number;
|
|
34
|
+
/** How long a question waits on pages that no one sees, before it goes to the form or to words (D-455); less in the tests. */
|
|
35
|
+
pageHidden?: number;
|
|
36
|
+
/** Codex's queue for the player's sentences (D-495): Codex's own command, else a fake in the tests. */
|
|
37
|
+
queue?: CodexQueue;
|
|
38
|
+
}
|
|
39
|
+
/** Codex's queue: whether this computer has the command, and a message queued in a thread, as the player's own (D-495). */
|
|
40
|
+
export interface CodexQueue {
|
|
41
|
+
ready(): boolean;
|
|
42
|
+
send(thread: string, text: string): Promise<boolean>;
|
|
43
|
+
}
|
|
44
|
+
/** Serves the dashboard of the campaign of context.folder, on 127.0.0.1 only, at the first of the ports that is free; undefined when none is. */
|
|
45
|
+
export declare function startDashboard(context: Context, session: SessionStore, options?: DashboardOptions): Promise<Dashboard | undefined>;
|
|
46
|
+
/** What the server keeps while it runs, shared by the files beside it: the pages open, the question asked, what the master has not heard yet. */
|
|
47
|
+
export interface Served {
|
|
48
|
+
port: number;
|
|
49
|
+
context: Context;
|
|
50
|
+
session: SessionStore;
|
|
51
|
+
/** The folder of the built page. */
|
|
52
|
+
page: string;
|
|
53
|
+
/** The pages open, which wait for notices. */
|
|
54
|
+
pages: Set<ServerResponse>;
|
|
55
|
+
/** What the master asks the player now, waiting for a click on the page (D-279). */
|
|
56
|
+
asked?: Asked;
|
|
57
|
+
/** The card of a package's question as its call left it, after the last dice, until another question comes (D-507). */
|
|
58
|
+
card?: ShownCard;
|
|
59
|
+
/** How long a question waits for a page to come back, after the last one closed. */
|
|
60
|
+
pageReturn: number;
|
|
61
|
+
/** Each setting the player changed on the page since the master's last call, as it was before the first of those changes (D-341). */
|
|
62
|
+
changed: Map<string, PlayerSetting>;
|
|
63
|
+
/** What the player did with the saves on the page since the master's last call, in order (D-359). */
|
|
64
|
+
events: string[];
|
|
65
|
+
/** The setup's choices the player left to the master on the page, shown so until the master makes them (D-370). */
|
|
66
|
+
left: Set<string>;
|
|
67
|
+
/** The stories the player proposed for their characters, by name, each with the page's opening text then: waiting until the master writes it (D-386). */
|
|
68
|
+
stories: Map<string, {
|
|
69
|
+
text: string;
|
|
70
|
+
before: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** The notes the player shared and the master has not heard yet, by id, with what the master will hear: until then the player may take one back (D-381). */
|
|
73
|
+
shared: Map<string, string>;
|
|
74
|
+
/** The wait for a page to come back, since the last one closed: a page that opens ends it. */
|
|
75
|
+
returning?: NodeJS.Timeout;
|
|
76
|
+
/** How long a question waits on pages that no one sees, before it goes to the form or to words (D-455). */
|
|
77
|
+
pageHidden: number;
|
|
78
|
+
/** Each open page's own id, as it gives it when it listens. */
|
|
79
|
+
pageIds: Map<ServerResponse, string>;
|
|
80
|
+
/** Whether each page, by its id, is seen now: on the screen, not in a tab or a window behind (D-455). */
|
|
81
|
+
seen: Map<string, boolean>;
|
|
82
|
+
/** The wait of a question on pages that no one sees: a page seen again ends it. */
|
|
83
|
+
hiding?: NodeJS.Timeout;
|
|
84
|
+
/** Tells the pages that something changed, once for changes that come together. */
|
|
85
|
+
notify(): void;
|
|
86
|
+
/** The page in a language the package does not ship, translated on the fly (D-406). */
|
|
87
|
+
words: PageTranslator;
|
|
88
|
+
/** The package the player is adding, updating or taking away on the page, while npm works (D-475): one at a time. */
|
|
89
|
+
packageWork?: {
|
|
90
|
+
name: string;
|
|
91
|
+
action: PackageAction;
|
|
92
|
+
phase: PackagePhase;
|
|
93
|
+
};
|
|
94
|
+
/** The packages the player said no to in a window of their computer, asked from the page: never asked again in this session (D-510). */
|
|
95
|
+
declined: Set<string>;
|
|
96
|
+
/** What the page may add, as npm and GitHub said it last, and when (D-486). */
|
|
97
|
+
catalog?: {
|
|
98
|
+
at: number;
|
|
99
|
+
catalog: Catalog;
|
|
100
|
+
};
|
|
101
|
+
/** The player's sentences said on the page, waiting for the master or heard lately (D-495). */
|
|
102
|
+
acts: Acts;
|
|
103
|
+
/** The doorbell of Claude Code's hook, waiting for a sentence; and whether one ever came, so that this chat has one (D-495). */
|
|
104
|
+
bell?: ServerResponse;
|
|
105
|
+
belled?: boolean;
|
|
106
|
+
/** Codex's queue, and the sentences being put in it now (D-495). */
|
|
107
|
+
queue: CodexQueue;
|
|
108
|
+
queueing?: Promise<void>;
|
|
109
|
+
/** Codex refused a sentence once: the others wait for the master's next call (D-495). */
|
|
110
|
+
queueBroken?: boolean;
|
|
111
|
+
/** The problems of the campaign's files the page last showed the player, and how many the master was told of (playtest 05). */
|
|
112
|
+
problemsShown?: number;
|
|
113
|
+
problemsTold?: number;
|
|
114
|
+
}
|