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/pages/index.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ export { applyMove, type MovePlan, MoveStopped, planLeave, planMove, type StackC
|
|
|
3
3
|
export { changedEnvironment, environmentAt, type EnvironmentEntry, formatEnvironmentEntry, placesAround, readEnvironment } from "./environment.ts";
|
|
4
4
|
export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, type Inherited, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.ts";
|
|
5
5
|
export { carriedWeight, type LoadRule, weightUnit } from "./load.ts";
|
|
6
|
-
export { type MapField,
|
|
7
|
-
export { everyGoalTicked, firstTable, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts,
|
|
6
|
+
export { type MapField, mapKey, mapOf, mapProblems, type PlaceMap, readMapField, sameFrame } from "./maps.ts";
|
|
7
|
+
export { everyGoalTicked, firstTable, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.ts";
|
|
8
8
|
export { changedFields, type FieldChange, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.ts";
|
|
9
9
|
export { type PageType, pageTypeNames, worldFolderName } from "./page-types.ts";
|
|
10
|
-
export { formatPosition, type Position,
|
|
10
|
+
export { formatPosition, type Position, readPosition } from "./positions.ts";
|
|
11
11
|
export { applyRename, planRename, type Renamed, renamedLinks, type RenamePlan } from "./rename-page.ts";
|
|
12
|
-
export { readStops, type Stops
|
|
13
|
-
export { countedText, entryOfKind, type EntryReading,
|
|
14
|
-
export {
|
|
15
|
-
export { canHold, containerFieldOf,
|
|
16
|
-
export { alwaysInList,
|
|
17
|
-
export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage,
|
|
12
|
+
export { readStops, type Stops } from "./roads.ts";
|
|
13
|
+
export { countedText, entryOfKind, type EntryReading, readEntry, withStackCount } from "./stacks/entry.ts";
|
|
14
|
+
export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, type HeldStack, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, type Stack, stackName, stacksOf } from "./stacks/kinds.ts";
|
|
15
|
+
export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.ts";
|
|
16
|
+
export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.ts";
|
|
17
|
+
export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, withPage, type World, } from "./world.ts";
|
|
18
18
|
export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";
|
package/dist/pages/index.js
CHANGED
|
@@ -4,16 +4,16 @@ export { applyMove, MoveStopped, planLeave, planMove } from "./containers.js";
|
|
|
4
4
|
export { changedEnvironment, environmentAt, formatEnvironmentEntry, placesAround, readEnvironment } from "./environment.js";
|
|
5
5
|
export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.js";
|
|
6
6
|
export { carriedWeight, weightUnit } from "./load.js";
|
|
7
|
-
export {
|
|
8
|
-
export { everyGoalTicked, firstTable, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts,
|
|
7
|
+
export { mapKey, mapOf, mapProblems, readMapField, sameFrame } from "./maps.js";
|
|
8
|
+
export { everyGoalTicked, firstTable, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.js";
|
|
9
9
|
export { changedFields, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.js";
|
|
10
10
|
export { pageTypeNames, worldFolderName } from "./page-types.js";
|
|
11
|
-
export { formatPosition,
|
|
11
|
+
export { formatPosition, readPosition } from "./positions.js";
|
|
12
12
|
export { applyRename, planRename, renamedLinks } from "./rename-page.js";
|
|
13
|
-
export { readStops
|
|
14
|
-
export { countedText, entryOfKind,
|
|
15
|
-
export {
|
|
16
|
-
export { canHold, containerFieldOf,
|
|
17
|
-
export { alwaysInList,
|
|
18
|
-
export { backlinks, bonusPages, concernsPlayer, createWorld, findPage,
|
|
13
|
+
export { readStops } from "./roads.js";
|
|
14
|
+
export { countedText, entryOfKind, readEntry, withStackCount } from "./stacks/entry.js";
|
|
15
|
+
export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, stackName, stacksOf } from "./stacks/kinds.js";
|
|
16
|
+
export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.js";
|
|
17
|
+
export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.js";
|
|
18
|
+
export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, pageFileNamed, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, systemPageNamed, textsIn, validHoldersOf, withPage, } from "./world.js";
|
|
19
19
|
export { checkFieldChange, writePage } from "./write-page.js";
|
|
@@ -2,7 +2,7 @@ import type { FieldChange } from "./page-file.ts";
|
|
|
2
2
|
import type { PageType } from "./page-types.ts";
|
|
3
3
|
import { type Page, type World } from "./world.ts";
|
|
4
4
|
/** A field and its value as a page writes it. */
|
|
5
|
-
|
|
5
|
+
interface FieldValue {
|
|
6
6
|
name: string;
|
|
7
7
|
value: unknown;
|
|
8
8
|
}
|
|
@@ -78,3 +78,4 @@ export declare function newBaseProblem(world: World, page: {
|
|
|
78
78
|
name: string;
|
|
79
79
|
type?: PageType;
|
|
80
80
|
}, link: string): string | undefined;
|
|
81
|
+
export {};
|
|
@@ -48,30 +48,6 @@ export function inheritedByBase(world, page) {
|
|
|
48
48
|
return Object.keys(own).length > 0 || parts.length > 0 || introduction !== "" ? [{ base, fields: own, introduction, parts }] : [];
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Whether the part at `index` is a heading with no text of its own whose subsections are none of them `kept`, as when the page writes them all itself: it has nothing
|
|
53
|
-
* left to show (INH-13, D-169), such as the Actions of a creature whose one action the page rewrote.
|
|
54
|
-
*/
|
|
55
|
-
function emptyHeading(parts, index, kept) {
|
|
56
|
-
const level = headingLevel(parts[index].text);
|
|
57
|
-
if (level === undefined || parts[index].text.split("\n").slice(1).some((line) => line.trim() !== "")) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
for (const next of parts.slice(index + 1)) {
|
|
61
|
-
// A secret has no level: it belongs to the section it is in.
|
|
62
|
-
if ((headingLevel(next.text) ?? Number.POSITIVE_INFINITY) <= level) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
if (kept.has(next)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
/** The level of the heading a part starts with, 2 for "## Actions"; undefined for a secret. */
|
|
72
|
-
function headingLevel(text) {
|
|
73
|
-
return /^(#{1,6})[ \t]/.exec(text)?.[1].length;
|
|
74
|
-
}
|
|
75
51
|
/** Whether a page writes a field with the very value it would read from its bases, and in no other case: that is no difference, and the page does not keep it (INH-9, D-125). */
|
|
76
52
|
export function sameAsBase(world, page, field) {
|
|
77
53
|
const base = baseValue(world, page, field);
|
|
@@ -235,6 +211,30 @@ export function newBaseProblem(world, page, link) {
|
|
|
235
211
|
const back = names.findIndex((linked) => comparableText(linked) === comparableText(page.name));
|
|
236
212
|
return back === -1 ? undefined : `${page.name} cannot derive from ${target.name}: the chain would come back to it (${[page.name, ...names.slice(0, back), page.name].join(" › ")}).`;
|
|
237
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Whether the part at `index` is a heading with no text of its own whose subsections are none of them `kept`, as when the page writes them all itself: it has nothing
|
|
216
|
+
* left to show (INH-13, D-169), such as the Actions of a creature whose one action the page rewrote.
|
|
217
|
+
*/
|
|
218
|
+
function emptyHeading(parts, index, kept) {
|
|
219
|
+
const level = headingLevel(parts[index].text);
|
|
220
|
+
if (level === undefined || parts[index].text.split("\n").slice(1).some((line) => line.trim() !== "")) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
for (const next of parts.slice(index + 1)) {
|
|
224
|
+
// A secret has no level: it belongs to the section it is in.
|
|
225
|
+
if ((headingLevel(next.text) ?? Number.POSITIVE_INFINITY) <= level) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (kept.has(next)) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
/** The level of the heading a part starts with, 2 for "## Actions"; undefined for a secret. */
|
|
235
|
+
function headingLevel(text) {
|
|
236
|
+
return /^(#{1,6})[ \t]/.exec(text)?.[1].length;
|
|
237
|
+
}
|
|
238
238
|
/** The pages deriving from a page for which nothing nearer holds what `holds` looks for: neither they nor a base between them and the page. */
|
|
239
239
|
function followers(world, page, holds) {
|
|
240
240
|
return derivedPages(world, page).filter((derived) => {
|
package/dist/pages/load.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// What a character carries weighs (D-432, LOAD-1): its stacks by their bundle, its items with what they hold, and its coins.
|
|
2
2
|
import { valueNamed } from "../core/text.js";
|
|
3
3
|
import { inheritedFields } from "./inheritance.js";
|
|
4
|
-
import { readEntry } from "./
|
|
5
|
-
import { entryKind, entryPage, stacksOf } from "./stacks.js";
|
|
4
|
+
import { readEntry } from "./stacks/entry.js";
|
|
5
|
+
import { entryKind, entryPage, stacksOf } from "./stacks/kinds.js";
|
|
6
6
|
import { containerFieldOf } from "./standard-fields.js";
|
|
7
7
|
import { textsIn, validHoldersOf } from "./world.js";
|
|
8
8
|
/** The weight a holder carries, coins included (LOAD-1). */
|
|
@@ -14,6 +14,11 @@ export function weightUnit(world, field) {
|
|
|
14
14
|
const written = (world.system?.pages ?? []).map((page) => page.fields[field]).find((value) => typeof value === "string" && /\p{L}/u.test(value));
|
|
15
15
|
return typeof written === "string" ? /(\p{L}[\p{L}.]*)\s*$/u.exec(written)?.[1] : undefined;
|
|
16
16
|
}
|
|
17
|
+
/** How many pieces one of a kind holds, by the field the system declares for its bundle: 1 for a kind not sold by the bundle (STK-2). */
|
|
18
|
+
export function bundleOf(field, kind) {
|
|
19
|
+
const pieces = field === undefined ? Number.NaN : Number(valueNamed(kind.fields, field));
|
|
20
|
+
return Number.isSafeInteger(pieces) && pieces > 1 ? pieces : 1;
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
23
|
* The weight a holder carries (LOAD-1): each stack by its pieces, at its kind's weight over its bundle; each item at its own weight or its base's, and what it
|
|
19
24
|
* holds, unless the system's weightless field is true on it, as on a Bag of Holding.
|
|
@@ -63,11 +68,6 @@ function coinsWeight(fields, perUnit) {
|
|
|
63
68
|
const coins = typeof money === "string" ? [...money.matchAll(/(\d{1,3}(?:,\d{3})+|\d+)\s*\p{L}+/gu)].reduce((total, match) => total + Number(match[1].replace(/,/g, "")), 0) : 0;
|
|
64
69
|
return perUnit === undefined ? 0 : coins / perUnit;
|
|
65
70
|
}
|
|
66
|
-
/** How many pieces one of a kind holds, by the field the system declares for its bundle: 1 for a kind not sold by the bundle (STK-2). */
|
|
67
|
-
export function bundleOf(field, kind) {
|
|
68
|
-
const pieces = field === undefined ? Number.NaN : Number(valueNamed(kind.fields, field));
|
|
69
|
-
return Number.isSafeInteger(pieces) && pieces > 1 ? pieces : 1;
|
|
70
|
-
}
|
|
71
71
|
/** Whether a field is true, as YAML reads it or as text written by hand. */
|
|
72
72
|
function isTrue(value) {
|
|
73
73
|
return value === true || (typeof value === "string" && value.trim().toLowerCase() === "true");
|
package/dist/pages/maps.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Problem } from "../core/problem.ts";
|
|
2
|
+
import { type Page, type World } from "./world.ts";
|
|
1
3
|
/** How a place holds its map: with coordinates of its own, or with those of another place's map, under it or as its mirror. */
|
|
2
4
|
export type MapField = {
|
|
3
5
|
how: "own";
|
|
@@ -9,3 +11,21 @@ export type MapField = {
|
|
|
9
11
|
export declare const mapHelp = "own, for coordinates of its own, or under [[Place]] or mirror of [[Place]], for those of that place's map";
|
|
10
12
|
/** A place's map field as written (POS-8): own, under [[Place]] or mirror of [[Place]]; undefined for anything else. */
|
|
11
13
|
export declare function readMapField(value: unknown): MapField | undefined;
|
|
14
|
+
/** A map: the place that holds it, none for the main map; the key of its coordinates; and, when it shares another map's, how and with which place's map. */
|
|
15
|
+
export interface PlaceMap {
|
|
16
|
+
root?: Page;
|
|
17
|
+
/** The root whose coordinates the map uses, by its file; "" for the main map's. */
|
|
18
|
+
frame: string;
|
|
19
|
+
aligned?: {
|
|
20
|
+
how: "under" | "mirror";
|
|
21
|
+
of: Page;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The map a page is on (POS-8): that of the nearest place of its chain, itself first, that holds one; else the main map. */
|
|
25
|
+
export declare function mapOf(world: World, page: Page): PlaceMap;
|
|
26
|
+
/** Which map a page is on, as a key: the file of the place that holds it, "" for the main map. Regions, terrain and the places near hold on one map (POS-6). */
|
|
27
|
+
export declare function mapKey(world: World, page: Page): string;
|
|
28
|
+
/** Whether two pages share their coordinates (POS-2, POS-4): positions are given and stops placed between them. */
|
|
29
|
+
export declare function sameFrame(world: World, first: Page, second: Page): boolean;
|
|
30
|
+
/** The places whose map field does not read, or names a place that is not there (POS-8). */
|
|
31
|
+
export declare function mapProblems(world: World): Problem[];
|
package/dist/pages/maps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { locate, pagesWithName } from "./world.js";
|
|
2
2
|
/** How the map field is written, for messages. */
|
|
3
3
|
export const mapHelp = "own, for coordinates of its own, or under [[Place]] or mirror of [[Place]], for those of that place's map";
|
|
4
4
|
/** A place's map field as written (POS-8): own, under [[Place]] or mirror of [[Place]]; undefined for anything else. */
|
|
@@ -12,3 +12,53 @@ export function readMapField(value) {
|
|
|
12
12
|
const match = /^\s*(under|mirror of)\s+\[\[([^\]|#]+)(?:[|#][^\]]*)?\]\]\s*$/i.exec(value);
|
|
13
13
|
return match === null ? undefined : { how: match[1].toLowerCase() === "under" ? "under" : "mirror", of: match[2].trim() };
|
|
14
14
|
}
|
|
15
|
+
/** The map a page is on (POS-8): that of the nearest place of its chain, itself first, that holds one; else the main map. */
|
|
16
|
+
export function mapOf(world, page) {
|
|
17
|
+
let byPage = known.get(world);
|
|
18
|
+
if (byPage === undefined) {
|
|
19
|
+
byPage = new Map();
|
|
20
|
+
known.set(world, byPage);
|
|
21
|
+
}
|
|
22
|
+
let map = byPage.get(page.path);
|
|
23
|
+
if (map === undefined) {
|
|
24
|
+
const root = rootOf(world, page);
|
|
25
|
+
map = root === undefined ? { frame: "" } : rootMap(world, root, new Set());
|
|
26
|
+
byPage.set(page.path, map);
|
|
27
|
+
}
|
|
28
|
+
return map;
|
|
29
|
+
}
|
|
30
|
+
/** Which map a page is on, as a key: the file of the place that holds it, "" for the main map. Regions, terrain and the places near hold on one map (POS-6). */
|
|
31
|
+
export function mapKey(world, page) {
|
|
32
|
+
return mapOf(world, page).root?.path ?? "";
|
|
33
|
+
}
|
|
34
|
+
/** Whether two pages share their coordinates (POS-2, POS-4): positions are given and stops placed between them. */
|
|
35
|
+
export function sameFrame(world, first, second) {
|
|
36
|
+
return mapOf(world, first).frame === mapOf(world, second).frame;
|
|
37
|
+
}
|
|
38
|
+
/** The places whose map field does not read, or names a place that is not there (POS-8). */
|
|
39
|
+
export function mapProblems(world) {
|
|
40
|
+
return world.pages.filter((page) => page.type === "place" && page.system === undefined && page.fields.map !== undefined).flatMap((page) => {
|
|
41
|
+
const field = readMapField(page.fields.map);
|
|
42
|
+
if (field === undefined || field.how === "own" || pagesWithName(world, field.of)[0]?.type === "place") {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return [{ path: page.path, message: `${page.name}'s map is ${field.how === "under" ? "under" : "the mirror of"} ${field.of}, which is no place.`, fix: `write ${page.name}, set map to own, or name a place of the map it shares` }];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const known = new WeakMap();
|
|
49
|
+
/** The nearest place of a page's chain, itself first, that holds a map. */
|
|
50
|
+
function rootOf(world, page) {
|
|
51
|
+
return [page, ...locate(world, page).chain].find((holder) => holder.type === "place" && holder.system === undefined && readMapField(holder.fields.map) !== undefined);
|
|
52
|
+
}
|
|
53
|
+
/** The map a place holds: its own coordinates, or those of the map of the place it is under or mirrors; a broken or circular alignment keeps its own. */
|
|
54
|
+
function rootMap(world, root, seen) {
|
|
55
|
+
const field = readMapField(root.fields.map);
|
|
56
|
+
const of = field === undefined || field.how === "own" ? undefined : pagesWithName(world, field.of)[0];
|
|
57
|
+
if (field === undefined || field.how === "own" || of === undefined || seen.has(root.path)) {
|
|
58
|
+
return { root, frame: root.path };
|
|
59
|
+
}
|
|
60
|
+
seen.add(root.path);
|
|
61
|
+
const target = rootOf(world, of);
|
|
62
|
+
const frame = target === undefined ? "" : target === root ? root.path : rootMap(world, target, seen).frame;
|
|
63
|
+
return { root, frame, aligned: { how: field.how, of } };
|
|
64
|
+
}
|
package/dist/pages/markdown.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export declare function goalsIn(text: string): {
|
|
|
60
60
|
* code blocks and attachments, as ![[map.png]], stay as written.
|
|
61
61
|
*/
|
|
62
62
|
export declare function withLinksAsWords(text: string, keep: (link: Link) => boolean): string;
|
|
63
|
+
/** A text with `change` made to its prose alone: never in code, fenced or inline, nor in %% comments %%, as links are read (LNK-2). */
|
|
64
|
+
export declare function inProse(text: string, change: (prose: string) => string): string;
|
|
63
65
|
/** A text without its fenced blocks, as a map or code, which say nothing as prose. */
|
|
64
66
|
export declare function withoutFencedBlocks(text: string): string;
|
|
65
67
|
/**
|
package/dist/pages/markdown.js
CHANGED
|
@@ -16,6 +16,8 @@ const wordedLinkPattern = /!?\[\[([^\]|#^]+)(?:#([^\]|^]*))?(?:\^[^\]|]*)?(?:\|(
|
|
|
16
16
|
const goalPattern = /^[ \t>]*[-*+][ \t]+\[([ xX])\]/;
|
|
17
17
|
// The row of dashes under a table's header, as |---|:--:| or --- | ---.
|
|
18
18
|
const tableDividerPattern = /^\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?$/;
|
|
19
|
+
// The files a link may name besides a page, as Obsidian embeds them: pictures, sounds, videos, documents.
|
|
20
|
+
const attachmentExtensions = new Set(["png", "jpg", "jpeg", "webp", "svg", "gif", "bmp", "avif", "pdf", "mp3", "wav", "m4a", "ogg", "flac", "mp4", "webm", "mov", "mkv", "canvas", "base"]);
|
|
19
21
|
/** The titles of the sections in a markdown text. Read once for each text: rules looks through every page's (RUL-6). */
|
|
20
22
|
export function sectionTitles(text) {
|
|
21
23
|
return rememberedTitles(text);
|
|
@@ -121,89 +123,10 @@ export function links(text) {
|
|
|
121
123
|
const rememberedLinks = rememberedByText((text) => {
|
|
122
124
|
return lineViews(text.split("\n")).flatMap((view) => [...view.prose.matchAll(linkPattern)].filter((match) => !isAttachment(match[1])).map((match) => linkOf(match[1], match[2])));
|
|
123
125
|
}, 20_000);
|
|
124
|
-
/** Whether a link's target is a file of another kind, as ![[map.png]]: an attachment, not a page. */
|
|
125
|
-
function isAttachment(target) {
|
|
126
|
-
return /\.(?!md$)[a-z0-9]+$/i.test(target.trim());
|
|
127
|
-
}
|
|
128
126
|
/** Removes the blank lines at the start and the white space at the end. */
|
|
129
127
|
export function trimBlankLines(text) {
|
|
130
128
|
return text.replace(/^(?:[ \t]*\n)+/, "").trimEnd();
|
|
131
129
|
}
|
|
132
|
-
/** The new text of a range: added to the old one, or in its place, keeping the secret blocks that the new text does not write again. */
|
|
133
|
-
function newContent(lines, range, newText, mode) {
|
|
134
|
-
if (mode === "append") {
|
|
135
|
-
return joinBlocks(lines.slice(range.start, range.end).join("\n"), newText);
|
|
136
|
-
}
|
|
137
|
-
const rewritten = secretNames(newText).map(comparableText);
|
|
138
|
-
const kept = secretsWithin(lines, range).filter((secret) => !rewritten.includes(comparableText(secret.title)));
|
|
139
|
-
return joinBlocks(newText, ...kept.map((secret) => lines.slice(secret.start, secret.end).join("\n")));
|
|
140
|
-
}
|
|
141
|
-
/** Removes a section with its own text; one with subsections or secrets is refused, so that nothing ends up elsewhere or is lost. */
|
|
142
|
-
function removeSection(lines, title, own) {
|
|
143
|
-
if (findSection(lines, title, "whole")?.end !== own.end) {
|
|
144
|
-
throw new Error(`"${title}" has subsections: remove them first, then the section.`);
|
|
145
|
-
}
|
|
146
|
-
const [secret] = secretsWithin(lines, { start: own.start + 1, end: own.end });
|
|
147
|
-
if (secret !== undefined) {
|
|
148
|
-
throw new Error(`"${title}" holds the secret "${secret.title}": remove or move it first, then the section.`);
|
|
149
|
-
}
|
|
150
|
-
return joinBlocks(lines.slice(0, own.start).join("\n"), lines.slice(own.end).join("\n"));
|
|
151
|
-
}
|
|
152
|
-
/** Text as the quoted lines of a secret block. */
|
|
153
|
-
function quoteLines(text) {
|
|
154
|
-
return trimBlankLines(text).split("\n").map((line) => (line === "" ? ">" : `> ${line}`));
|
|
155
|
-
}
|
|
156
|
-
function joinBlocks(...blocks) {
|
|
157
|
-
return blocks.map(trimBlankLines).filter((block) => block !== "").join("\n\n");
|
|
158
|
-
}
|
|
159
|
-
/** The lines of a section: the whole of it, or only its own text, up to its first subsection. */
|
|
160
|
-
function findSection(lines, title, scope) {
|
|
161
|
-
const headings = headingsOf(lines);
|
|
162
|
-
const index = headings.findIndex((heading) => comparableText(heading.title) === comparableText(title.trim()));
|
|
163
|
-
if (index === -1) {
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
const heading = headings[index];
|
|
167
|
-
const next = headings.slice(index + 1).find((other) => scope === "own" || other.level <= heading.level);
|
|
168
|
-
return { start: heading.line, end: next?.line ?? lines.length };
|
|
169
|
-
}
|
|
170
|
-
function secretsWithin(lines, range) {
|
|
171
|
-
return secretsOf(lines).filter((secret) => secret.start >= range.start && secret.start < range.end);
|
|
172
|
-
}
|
|
173
|
-
function findSecret(lines, title) {
|
|
174
|
-
return secretsOf(lines).find((secret) => comparableText(secret.title) === comparableText(title.trim()));
|
|
175
|
-
}
|
|
176
|
-
function topHeadingLevel(lines) {
|
|
177
|
-
const levels = headingsOf(lines).map((heading) => heading.level);
|
|
178
|
-
return levels.length > 0 ? Math.min(...levels) : 2;
|
|
179
|
-
}
|
|
180
|
-
function headingsOf(lines) {
|
|
181
|
-
const views = lineViews(lines);
|
|
182
|
-
const headings = [];
|
|
183
|
-
lines.forEach((line, index) => {
|
|
184
|
-
const match = isProse(views[index]) ? headingPattern.exec(line) : null;
|
|
185
|
-
if (match) {
|
|
186
|
-
headings.push({ line: index, level: match[1].length, title: match[2].trim() });
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return headings;
|
|
190
|
-
}
|
|
191
|
-
/** The secret blocks: a `> [!secret] Name` line and the quoted lines after it. */
|
|
192
|
-
function secretsOf(lines) {
|
|
193
|
-
const views = lineViews(lines);
|
|
194
|
-
const secrets = [];
|
|
195
|
-
lines.forEach((line, index) => {
|
|
196
|
-
const match = isProse(views[index]) ? secretPattern.exec(line) : null;
|
|
197
|
-
if (match) {
|
|
198
|
-
let end = index + 1;
|
|
199
|
-
while (end < lines.length && quotePattern.test(lines[end]) && !secretPattern.test(lines[end])) {
|
|
200
|
-
end++;
|
|
201
|
-
}
|
|
202
|
-
secrets.push({ start: index, end, title: match[1] });
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
return secrets;
|
|
206
|
-
}
|
|
207
130
|
/** A text without its comments, as Obsidian shows it in reading view: what lies between %% marks, also across lines, and HTML comments; code stays as it is (LNK-2). */
|
|
208
131
|
export function withoutComments(text) {
|
|
209
132
|
const lines = text.split("\n");
|
|
@@ -249,6 +172,12 @@ export function withLinksAsWords(text, keep) {
|
|
|
249
172
|
return words?.trim() || linkTargetName(target);
|
|
250
173
|
})).join("\n");
|
|
251
174
|
}
|
|
175
|
+
/** A text with `change` made to its prose alone: never in code, fenced or inline, nor in %% comments %%, as links are read (LNK-2). */
|
|
176
|
+
export function inProse(text, change) {
|
|
177
|
+
const lines = text.split("\n");
|
|
178
|
+
const views = lineViews(lines);
|
|
179
|
+
return lines.map((line, index) => (views[index].code ? line : changedOutside(line, views[index].commented, change))).join("\n");
|
|
180
|
+
}
|
|
252
181
|
/** A text without its fenced blocks, as a map or code, which say nothing as prose. */
|
|
253
182
|
export function withoutFencedBlocks(text) {
|
|
254
183
|
const lines = text.split("\n");
|
|
@@ -282,6 +211,86 @@ export function everyGoalTicked(text) {
|
|
|
282
211
|
const marks = lines.flatMap((line, index) => (isProse(views[index]) ? (goalPattern.exec(line)?.slice(1) ?? []) : []));
|
|
283
212
|
return marks.length > 0 && marks.every((mark) => mark !== " ");
|
|
284
213
|
}
|
|
214
|
+
/** Whether a link's target is a file of another kind, as ![[map.png]]: an attachment, not a page, which may have a dot in its name, as Lettera n.7 (LNK-1). */
|
|
215
|
+
function isAttachment(target) {
|
|
216
|
+
const extension = /\.([a-z0-9]+)$/i.exec(target.trim())?.[1]?.toLowerCase();
|
|
217
|
+
return extension !== undefined && attachmentExtensions.has(extension);
|
|
218
|
+
}
|
|
219
|
+
/** The new text of a range: added to the old one, or in its place, keeping the secret blocks that the new text does not write again. */
|
|
220
|
+
function newContent(lines, range, newText, mode) {
|
|
221
|
+
if (mode === "append") {
|
|
222
|
+
return joinBlocks(lines.slice(range.start, range.end).join("\n"), newText);
|
|
223
|
+
}
|
|
224
|
+
const rewritten = secretNames(newText).map(comparableText);
|
|
225
|
+
const kept = secretsWithin(lines, range).filter((secret) => !rewritten.includes(comparableText(secret.title)));
|
|
226
|
+
return joinBlocks(newText, ...kept.map((secret) => lines.slice(secret.start, secret.end).join("\n")));
|
|
227
|
+
}
|
|
228
|
+
/** Removes a section with its own text; one with subsections or secrets is refused, so that nothing ends up elsewhere or is lost. */
|
|
229
|
+
function removeSection(lines, title, own) {
|
|
230
|
+
if (findSection(lines, title, "whole")?.end !== own.end) {
|
|
231
|
+
throw new Error(`"${title}" has subsections: remove them first, then the section.`);
|
|
232
|
+
}
|
|
233
|
+
const [secret] = secretsWithin(lines, { start: own.start + 1, end: own.end });
|
|
234
|
+
if (secret !== undefined) {
|
|
235
|
+
throw new Error(`"${title}" holds the secret "${secret.title}": remove or move it first, then the section.`);
|
|
236
|
+
}
|
|
237
|
+
return joinBlocks(lines.slice(0, own.start).join("\n"), lines.slice(own.end).join("\n"));
|
|
238
|
+
}
|
|
239
|
+
/** Text as the quoted lines of a secret block. */
|
|
240
|
+
function quoteLines(text) {
|
|
241
|
+
return trimBlankLines(text).split("\n").map((line) => (line === "" ? ">" : `> ${line}`));
|
|
242
|
+
}
|
|
243
|
+
function joinBlocks(...blocks) {
|
|
244
|
+
return blocks.map(trimBlankLines).filter((block) => block !== "").join("\n\n");
|
|
245
|
+
}
|
|
246
|
+
/** The lines of a section: the whole of it, or only its own text, up to its first subsection. */
|
|
247
|
+
function findSection(lines, title, scope) {
|
|
248
|
+
const headings = headingsOf(lines);
|
|
249
|
+
const index = headings.findIndex((heading) => comparableText(heading.title) === comparableText(title.trim()));
|
|
250
|
+
if (index === -1) {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
const heading = headings[index];
|
|
254
|
+
const next = headings.slice(index + 1).find((other) => scope === "own" || other.level <= heading.level);
|
|
255
|
+
return { start: heading.line, end: next?.line ?? lines.length };
|
|
256
|
+
}
|
|
257
|
+
function secretsWithin(lines, range) {
|
|
258
|
+
return secretsOf(lines).filter((secret) => secret.start >= range.start && secret.start < range.end);
|
|
259
|
+
}
|
|
260
|
+
function findSecret(lines, title) {
|
|
261
|
+
return secretsOf(lines).find((secret) => comparableText(secret.title) === comparableText(title.trim()));
|
|
262
|
+
}
|
|
263
|
+
function topHeadingLevel(lines) {
|
|
264
|
+
const levels = headingsOf(lines).map((heading) => heading.level);
|
|
265
|
+
return levels.length > 0 ? Math.min(...levels) : 2;
|
|
266
|
+
}
|
|
267
|
+
function headingsOf(lines) {
|
|
268
|
+
const views = lineViews(lines);
|
|
269
|
+
const headings = [];
|
|
270
|
+
lines.forEach((line, index) => {
|
|
271
|
+
const match = isProse(views[index]) ? headingPattern.exec(line) : null;
|
|
272
|
+
if (match) {
|
|
273
|
+
headings.push({ line: index, level: match[1].length, title: match[2].trim() });
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
return headings;
|
|
277
|
+
}
|
|
278
|
+
/** The secret blocks: a `> [!secret] Name` line and the quoted lines after it. */
|
|
279
|
+
function secretsOf(lines) {
|
|
280
|
+
const views = lineViews(lines);
|
|
281
|
+
const secrets = [];
|
|
282
|
+
lines.forEach((line, index) => {
|
|
283
|
+
const match = isProse(views[index]) ? secretPattern.exec(line) : null;
|
|
284
|
+
if (match) {
|
|
285
|
+
let end = index + 1;
|
|
286
|
+
while (end < lines.length && quotePattern.test(lines[end]) && !secretPattern.test(lines[end])) {
|
|
287
|
+
end++;
|
|
288
|
+
}
|
|
289
|
+
secrets.push({ start: index, end, title: match[1] });
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return secrets;
|
|
293
|
+
}
|
|
285
294
|
/**
|
|
286
295
|
* Each line as links and titles read it (LNK-2): whether it is code, a fence or a line of a block, which only a fence of the same character, at least as long and
|
|
287
296
|
* with nothing after it, closes; whether it begins inside a %% comment, which may span lines; and its prose, without inline code and comments.
|
|
@@ -305,6 +314,28 @@ function lineViews(lines) {
|
|
|
305
314
|
return { code: false, commented, prose: parts.filter((_, index) => (index % 2 === 0) === !commented).join("") };
|
|
306
315
|
});
|
|
307
316
|
}
|
|
317
|
+
/** A line with `change` made outside its inline code and its comments, as lineViews reads it; begun inside a comment when `commented`. */
|
|
318
|
+
function changedOutside(line, commented, change) {
|
|
319
|
+
const parts = [];
|
|
320
|
+
let inside = commented;
|
|
321
|
+
let at = 0;
|
|
322
|
+
const outsideCode = (piece) => {
|
|
323
|
+
piece.split("%%").forEach((part, index) => {
|
|
324
|
+
if (index > 0) {
|
|
325
|
+
parts.push("%%");
|
|
326
|
+
inside = !inside;
|
|
327
|
+
}
|
|
328
|
+
parts.push(inside ? part : change(part));
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
for (const code of line.matchAll(inlineCodePattern)) {
|
|
332
|
+
outsideCode(line.slice(at, code.index));
|
|
333
|
+
parts.push(code[0]);
|
|
334
|
+
at = code.index + code[0].length;
|
|
335
|
+
}
|
|
336
|
+
outsideCode(line.slice(at));
|
|
337
|
+
return parts.join("");
|
|
338
|
+
}
|
|
308
339
|
/** The cells of a table's row, without the pipes at its ends; a pipe written \| stays in its cell, as in [[Page\|words]], and loses its backslash. */
|
|
309
340
|
function tableCells(row) {
|
|
310
341
|
const inner = row.trim().replace(/^\|/, "").replace(/(?<!\\)\|$/, "");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** A page file: its YAML frontmatter, if any, and its markdown text. */
|
|
2
|
-
|
|
2
|
+
interface PageFile {
|
|
3
3
|
frontmatter?: string;
|
|
4
4
|
body: string;
|
|
5
5
|
}
|
|
@@ -26,3 +26,4 @@ export declare function readFieldValue(text: string): unknown;
|
|
|
26
26
|
export declare function linkListItems(text: string): string[] | undefined;
|
|
27
27
|
/** Whether a value holds a list inside a list, which a field cannot hold. */
|
|
28
28
|
export declare function holdsNestedList(value: unknown): boolean;
|
|
29
|
+
export {};
|
package/dist/pages/page-file.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Document, isMap, isScalar, isSeq, parseDocument, stringify } from "yaml";
|
|
2
2
|
import { comparableText } from "../core/text.js";
|
|
3
3
|
import { links, trimBlankLines } from "./markdown.js";
|
|
4
|
-
import { readEntry } from "./
|
|
4
|
+
import { readEntry } from "./stacks/entry.js";
|
|
5
5
|
import { isEmptyField } from "./standard-fields.js";
|
|
6
6
|
const singleLink = /^\[\[[^\]]+\]\]$/;
|
|
7
7
|
// Links separated by commas, each with a number after it or none: [[A]], [[B]] or, for classes with their levels, [[Fighter]] 3, [[Wizard]] 2.
|
|
@@ -13,7 +13,7 @@ const yamlStyle = { flowCollectionPadding: false, lineWidth: 0 };
|
|
|
13
13
|
// A value that appears twice, such as the same list read from two fields, is written twice: never as an anchor and an alias, which is no list.
|
|
14
14
|
const nodeOptions = { aliasDuplicateObjects: false };
|
|
15
15
|
export function splitPageFile(text) {
|
|
16
|
-
const lines = text.replace(
|
|
16
|
+
const lines = text.replace(/^\uFEFF/, "").replaceAll("\r\n", "\n").split("\n");
|
|
17
17
|
const end = isSeparator(lines[0]) ? lines.findIndex((line, index) => index > 0 && isSeparator(line)) : -1;
|
|
18
18
|
if (end === -1) {
|
|
19
19
|
return { body: trimBlankLines(lines.join("\n")) };
|
|
@@ -54,21 +54,6 @@ export function changedFields(fields, change) {
|
|
|
54
54
|
applyChange(document, change);
|
|
55
55
|
return (document.toJS() ?? {});
|
|
56
56
|
}
|
|
57
|
-
function applyChange(document, change) {
|
|
58
|
-
for (const [name, value] of Object.entries(change.set ?? {})) {
|
|
59
|
-
// As a node, so that items can be added to or removed from it in the same change.
|
|
60
|
-
document.set(name, document.createNode(value, nodeOptions));
|
|
61
|
-
}
|
|
62
|
-
for (const name of change.unset ?? []) {
|
|
63
|
-
document.delete(name);
|
|
64
|
-
}
|
|
65
|
-
for (const [name, values] of Object.entries(change.add ?? {})) {
|
|
66
|
-
addToList(document, name, values);
|
|
67
|
-
}
|
|
68
|
-
for (const [name, values] of Object.entries(change.remove ?? {})) {
|
|
69
|
-
removeFromList(document, name, values);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
57
|
/** Fields written as YAML, to show them. */
|
|
73
58
|
export function formatFields(fields) {
|
|
74
59
|
return stringify(fields, yamlStyle).trimEnd();
|
|
@@ -102,16 +87,43 @@ export function linkListItems(text) {
|
|
|
102
87
|
const value = text.trim();
|
|
103
88
|
return linkList.test(value) ? [...value.matchAll(linkItem)].map((match) => match[0]) : undefined;
|
|
104
89
|
}
|
|
90
|
+
/** Whether a value holds a list inside a list, which a field cannot hold. */
|
|
91
|
+
export function holdsNestedList(value) {
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
return value.some((item) => Array.isArray(item) || holdsNestedList(item));
|
|
94
|
+
}
|
|
95
|
+
if (value !== null && typeof value === "object") {
|
|
96
|
+
return Object.values(value).some(holdsNestedList);
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
function applyChange(document, change) {
|
|
101
|
+
for (const [name, value] of Object.entries(change.set ?? {})) {
|
|
102
|
+
// As a node, so that items can be added to or removed from it in the same change.
|
|
103
|
+
document.set(name, document.createNode(value, nodeOptions));
|
|
104
|
+
}
|
|
105
|
+
for (const name of change.unset ?? []) {
|
|
106
|
+
document.delete(name);
|
|
107
|
+
}
|
|
108
|
+
for (const [name, values] of Object.entries(change.add ?? {})) {
|
|
109
|
+
addToList(document, name, values);
|
|
110
|
+
}
|
|
111
|
+
for (const [name, values] of Object.entries(change.remove ?? {})) {
|
|
112
|
+
removeFromList(document, name, values);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
105
115
|
function addToList(document, name, values) {
|
|
106
116
|
const list = document.get(name);
|
|
117
|
+
// Each value once, however it is written, as [[A]] and [[a]]: the new ones among themselves too.
|
|
118
|
+
const added = values.filter((value, index) => !values.slice(0, index).some((before) => sameValue(before, value)));
|
|
107
119
|
if (isEmptyField(list)) {
|
|
108
|
-
document.set(name,
|
|
120
|
+
document.set(name, added);
|
|
109
121
|
return;
|
|
110
122
|
}
|
|
111
123
|
if (!isSeq(list)) {
|
|
112
124
|
throw new Error(`"${name}" is not a list, so nothing can be added to it.`);
|
|
113
125
|
}
|
|
114
|
-
for (const value of
|
|
126
|
+
for (const value of added.filter((candidate) => !list.items.some((item) => sameValue(item, candidate)))) {
|
|
115
127
|
list.add(document.createNode(value, nodeOptions));
|
|
116
128
|
}
|
|
117
129
|
}
|
|
@@ -155,16 +167,6 @@ function sameLink(first, second) {
|
|
|
155
167
|
const [other] = links(second);
|
|
156
168
|
return one !== undefined && other !== undefined && comparableText(one.page) === comparableText(other.page) && comparableText(one.section ?? "") === comparableText(other.section ?? "");
|
|
157
169
|
}
|
|
158
|
-
/** Whether a value holds a list inside a list, which a field cannot hold. */
|
|
159
|
-
export function holdsNestedList(value) {
|
|
160
|
-
if (Array.isArray(value)) {
|
|
161
|
-
return value.some((item) => Array.isArray(item) || holdsNestedList(item));
|
|
162
|
-
}
|
|
163
|
-
if (value !== null && typeof value === "object") {
|
|
164
|
-
return Object.values(value).some(holdsNestedList);
|
|
165
|
-
}
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
170
|
function parseFrontmatter(frontmatter, path) {
|
|
169
171
|
const document = parseDocument(frontmatter);
|
|
170
172
|
if (document.errors.length > 0) {
|
|
@@ -32,7 +32,10 @@ export declare function planRename(world: World, page: Page, to: string): Rename
|
|
|
32
32
|
* and is finished by planning it again. A change of case alone is the same file on Windows and macOS: the links first, then the file anew.
|
|
33
33
|
*/
|
|
34
34
|
export declare function applyRename(plan: RenamePlan): void;
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* A text with its links to a page renamed, [[Lupa]], [[Lupa#Morso]] and [[Lupa|la lupa]] alike, in any case, never in code or in a comment, where there are no
|
|
37
|
+
* links (LNK-2); and how many it renamed.
|
|
38
|
+
*/
|
|
36
39
|
export declare function renamedLinks(text: string, from: string, to: string): {
|
|
37
40
|
renamed: string;
|
|
38
41
|
count: number;
|