@serene-pub/core-catalog 0.6.0-pr-2 → 0.6.0-pr-5
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/README.md +21 -1
- package/components/{sessions → genres/chat}/authors-note/AuthorsNote.svelte +1 -1
- package/components/{sessions → genres/chat}/authors-note/AuthorsNoteWidget.svelte +1 -1
- package/components/{sessions/world-state/WorldState.svelte → shared/actions/Actions.svelte} +5 -5
- package/components/shared/actions/ActionsWidget.svelte +118 -0
- package/components/shared/actions/actions.ts +11 -0
- package/components/shared/album/Album.svelte +24 -0
- package/components/shared/album/AlbumWidget.svelte +163 -0
- package/components/shared/album/album.ts +10 -0
- package/components/shared/annex/Annex.svelte +24 -0
- package/components/shared/annex/AnnexWidget.svelte +151 -0
- package/components/shared/annex/annex.ts +10 -0
- package/components/shared/attendance/Attendance.svelte +24 -0
- package/components/shared/attendance/AttendanceWidget.svelte +136 -0
- package/components/shared/attendance/attendance.ts +12 -0
- package/components/shared/backdrop/Backdrop.svelte +24 -0
- package/components/shared/backdrop/BackdropWidget.svelte +345 -0
- package/components/shared/backdrop/backdrop.ts +10 -0
- package/components/shared/chronicle/Chronicle.svelte +36 -0
- package/components/shared/chronicle/ChronicleWidget.svelte +569 -0
- package/components/shared/chronicle/chronicle.ts +11 -0
- package/components/{sessions → shared}/lore-entries/LoreEntries.svelte +1 -1
- package/components/{sessions → shared}/lore-entries/LoreEntriesWidget.svelte +3 -3
- package/components/shared/map-canvas/MapCanvas.svelte +171 -0
- package/components/shared/map-canvas/index.ts +390 -0
- package/components/{sessions → shared}/messages/MessageComposer.svelte +1 -1
- package/components/{sessions → shared}/messages/MessageControls.svelte +42 -0
- package/components/{sessions → shared}/messages/MessageStateLedger.svelte +19 -8
- package/components/{sessions → shared}/messages/Messages.svelte +1 -1
- package/components/{sessions → shared}/messages/MessagesWidget.svelte +126 -40
- package/components/{sessions → shared}/messages/NextCharacterBlock.svelte +17 -14
- package/components/shared/messages/SceneCueChip.svelte +82 -0
- package/components/shared/messages/SceneDivider.svelte +399 -0
- package/components/{sessions → shared}/messages/SessionComposer.svelte +33 -9
- package/components/shared/messages/SessionContainer.svelte +651 -0
- package/components/{sessions → shared}/messages/SessionMessage.svelte +52 -7
- package/components/shared/messages/TurnLine.svelte +254 -0
- package/components/{sessions → shared}/messages/conversation.svelte.ts +191 -2
- package/components/shared/messages/sceneMarks.ts +397 -0
- package/components/shared/places/Places.svelte +24 -0
- package/components/shared/places/PlacesWidget.svelte +290 -0
- package/components/shared/places/places.ts +11 -0
- package/components/{sessions → shared}/scene-portraits/ScenePortraits.svelte +1 -1
- package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +404 -0
- package/components/{sessions → shared}/state/SlotControl.svelte +9 -1
- package/components/{sessions → shared}/stats/Stats.svelte +1 -1
- package/components/shared/stats/StatsWidget.svelte +350 -0
- package/components/{sessions → shared}/stats/stats.ts +3 -2
- package/components/shared/turn-order/TurnOrder.svelte +24 -0
- package/components/shared/turn-order/TurnOrderWidget.svelte +167 -0
- package/components/shared/turn-order/turn-order.ts +11 -0
- package/components/{sessions/shared → shared}/widgetRef.svelte.ts +9 -2
- package/components/shared/world-state/WorldState.svelte +33 -0
- package/components/shared/world-state/world-state.ts +10 -0
- package/components/tsconfig.json +2 -2
- package/dist/components/actions.js +294 -0
- package/dist/components/actions.source.json +1 -0
- package/dist/components/album.js +386 -0
- package/dist/components/album.source.json +1 -0
- package/dist/components/annex.js +457 -0
- package/dist/components/annex.source.json +1 -0
- package/dist/components/attendance.js +353 -0
- package/dist/components/attendance.source.json +1 -0
- package/dist/components/authors-note.js +5 -5
- package/dist/components/authors-note.source.json +1 -1
- package/dist/components/backdrop.js +561 -0
- package/dist/components/backdrop.source.json +1 -0
- package/dist/components/chronicle.js +1141 -0
- package/dist/components/chronicle.source.json +1 -0
- package/dist/components/core-ui.json +1 -1
- package/dist/components/lore-entries.js +5 -5
- package/dist/components/lore-entries.source.json +1 -1
- package/dist/components/messages.js +3014 -2489
- package/dist/components/messages.source.json +1 -1
- package/dist/components/places.js +1133 -0
- package/dist/components/places.source.json +1 -0
- package/dist/components/scene-portraits.js +514 -345
- package/dist/components/scene-portraits.source.json +1 -1
- package/dist/components/shared-3K7SOGH7.js +16 -0
- package/dist/components/shared-452PIS46.js +156 -0
- package/dist/components/shared-GEDAMORM.js +45 -0
- package/dist/components/{shared-TCQZXBE3.js → shared-GXTL5G2H.js} +4 -3
- package/dist/components/shared-ITSLBJB5.js +478 -0
- package/dist/components/shared-NK7QSVMU.js +400 -0
- package/dist/components/shared-TDWKI2QV.js +58 -0
- package/dist/components/{shared-UAQVMZZK.js → shared-XBPH6USH.js} +586 -18
- package/dist/components/{shared-AINANAIA.js → shared-XISPHAKY.js} +502 -98
- package/dist/components/stats.js +8 -208
- package/dist/components/stats.source.json +1 -1
- package/dist/components/turn-order.js +461 -0
- package/dist/components/turn-order.source.json +1 -0
- package/dist/components/world-state.js +14 -202
- package/dist/components/world-state.source.json +1 -1
- package/dist/{answerForm.d.ts → factories/answerForm.d.ts} +4 -30
- package/dist/{answerForm.js → factories/answerForm.js} +10 -39
- package/dist/factories/once.d.ts +7 -0
- package/dist/factories/once.js +9 -0
- package/dist/{turnOrder.d.ts → factories/turnOrder.d.ts} +0 -22
- package/dist/{turnOrder.js → factories/turnOrder.js} +4 -104
- package/dist/genres/adventure/advanceTime.d.ts +18 -0
- package/dist/genres/adventure/advanceTime.js +24 -0
- package/dist/genres/adventure/answer.d.ts +23 -0
- package/dist/genres/adventure/answer.js +59 -0
- package/dist/genres/adventure/answerForm.d.ts +9 -0
- package/dist/genres/adventure/answerForm.js +11 -0
- package/dist/genres/adventure/ask.d.ts +73 -0
- package/dist/genres/adventure/ask.js +157 -0
- package/dist/genres/adventure/create.d.ts +36 -0
- package/dist/genres/adventure/create.js +62 -0
- package/dist/genres/adventure/illustrateScene.d.ts +7 -0
- package/dist/genres/adventure/illustrateScene.js +19 -0
- package/dist/genres/adventure/index.d.ts +45 -0
- package/dist/genres/adventure/index.js +45 -0
- package/dist/genres/adventure/keeperAction.d.ts +43 -0
- package/dist/genres/adventure/keeperAction.js +217 -0
- package/dist/genres/adventure/look.d.ts +45 -0
- package/dist/genres/adventure/look.js +209 -0
- package/dist/{adventure.d.ts → genres/adventure/respond.d.ts} +74 -65
- package/dist/{adventure.js → genres/adventure/respond.js} +125 -65
- package/dist/genres/adventure/rest.d.ts +10 -0
- package/dist/genres/adventure/rest.js +16 -0
- package/dist/genres/adventure/summarizeScene.d.ts +7 -0
- package/dist/genres/adventure/summarizeScene.js +14 -0
- package/dist/genres/adventure/turnOrder.d.ts +10 -0
- package/dist/genres/adventure/turnOrder.js +27 -0
- package/dist/genres/chat/advanceTime.d.ts +7 -0
- package/dist/genres/chat/advanceTime.js +17 -0
- package/dist/genres/chat/answerForm.d.ts +9 -0
- package/dist/genres/chat/answerForm.js +11 -0
- package/dist/genres/chat/create.d.ts +7 -0
- package/dist/{createChat.js → genres/chat/create.js} +6 -6
- package/dist/genres/chat/generateImage.d.ts +7 -0
- package/dist/{generateImage.js → genres/chat/generateImage.js} +26 -22
- package/dist/genres/chat/illustrateScene.d.ts +8 -0
- package/dist/genres/chat/illustrateScene.js +19 -0
- package/dist/genres/chat/index.d.ts +18 -0
- package/dist/genres/chat/index.js +19 -0
- package/dist/{narrate.d.ts → genres/chat/narrate.d.ts} +3 -3
- package/dist/{narrate.js → genres/chat/narrate.js} +37 -12
- package/dist/{narrateCharacter.d.ts → genres/chat/narrateCharacter.d.ts} +2 -2
- package/dist/{narrateCharacter.js → genres/chat/narrateCharacter.js} +39 -17
- package/dist/genres/chat/respond.d.ts +25 -0
- package/dist/{respond.js → genres/chat/respond.js} +91 -23
- package/dist/genres/chat/summarizeScene.d.ts +7 -0
- package/dist/genres/chat/summarizeScene.js +14 -0
- package/dist/genres/chat/turnOrder.d.ts +9 -0
- package/dist/genres/chat/turnOrder.js +28 -0
- package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.d.ts +1 -1
- package/dist/genres/guide/answerForm.d.ts +9 -0
- package/dist/genres/guide/answerForm.js +11 -0
- package/dist/genres/guide/create.d.ts +24 -0
- package/dist/genres/guide/create.js +58 -0
- package/dist/genres/guide/index.d.ts +10 -0
- package/dist/genres/guide/index.js +10 -0
- package/dist/{guide.d.ts → genres/guide/respond.d.ts} +1 -20
- package/dist/{guide.js → genres/guide/respond.js} +32 -61
- package/dist/genres/guide/summarizeScene.d.ts +7 -0
- package/dist/genres/guide/summarizeScene.js +14 -0
- package/dist/genres/guide/turnOrder.d.ts +10 -0
- package/dist/genres/guide/turnOrder.js +27 -0
- package/dist/genres/index.d.ts +14 -0
- package/dist/genres/index.js +41 -0
- package/dist/genres/lair/advanceTime.d.ts +7 -0
- package/dist/genres/lair/advanceTime.js +17 -0
- package/dist/genres/lair/answerForm.d.ts +17 -0
- package/dist/genres/lair/answerForm.js +19 -0
- package/dist/genres/lair/buildRoom.d.ts +64 -0
- package/dist/genres/lair/buildRoom.js +244 -0
- package/dist/genres/lair/castellanAction.d.ts +27 -0
- package/dist/genres/lair/castellanAction.js +177 -0
- package/dist/genres/lair/create.d.ts +28 -0
- package/dist/genres/lair/create.js +69 -0
- package/dist/genres/lair/fileRoom.d.ts +53 -0
- package/dist/genres/lair/fileRoom.js +288 -0
- package/dist/genres/lair/index.d.ts +62 -0
- package/dist/genres/lair/index.js +63 -0
- package/dist/genres/lair/nudge.d.ts +25 -0
- package/dist/genres/lair/nudge.js +78 -0
- package/dist/{lair.d.ts → genres/lair/respond.d.ts} +46 -59
- package/dist/{lair.js → genres/lair/respond.js} +55 -76
- package/dist/genres/lair/reveal.d.ts +10 -0
- package/dist/genres/lair/reveal.js +18 -0
- package/dist/genres/lair/roomAnswer.d.ts +86 -0
- package/dist/genres/lair/roomAnswer.js +378 -0
- package/dist/genres/lair/summarizeScene.d.ts +39 -0
- package/dist/genres/lair/summarizeScene.js +51 -0
- package/dist/genres/lair/trap.d.ts +11 -0
- package/dist/genres/lair/trap.js +24 -0
- package/dist/genres/lair/turnOrder.d.ts +9 -0
- package/dist/genres/lair/turnOrder.js +36 -0
- package/dist/genres/lair/whisper.d.ts +35 -0
- package/dist/genres/lair/whisper.js +90 -0
- package/dist/index.d.ts +52 -29
- package/dist/index.js +192 -86
- package/dist/loadouts.d.ts +37 -0
- package/dist/loadouts.js +105 -0
- package/dist/{entries.d.ts → registry/entries.d.ts} +1 -1
- package/dist/{genres.js → registry/genres.js} +40 -6
- package/dist/{ui/sessions → registry}/layouts.d.ts +41 -27
- package/dist/{ui/sessions → registry}/layouts.js +90 -49
- package/dist/{ui/sessions → registry}/widgets.d.ts +22 -0
- package/dist/registry/widgets.js +1294 -0
- package/dist/{presets.js → seed/presets.js} +28 -13
- package/dist/{prompts.d.ts → seed/prompts.d.ts} +10 -5
- package/dist/{prompts.js → seed/prompts.js} +225 -176
- package/dist/{annexField.d.ts → shared/annexField.d.ts} +12 -8
- package/dist/{annexField.js → shared/annexField.js} +16 -15
- package/dist/shared/builtins/branch.d.ts +8 -0
- package/dist/shared/builtins/branch.js +13 -0
- package/dist/{builtins.d.ts → shared/builtins/builtIn.d.ts} +16 -21
- package/dist/{builtins.js → shared/builtins/builtIn.js} +3 -37
- package/dist/shared/builtins/delete.d.ts +8 -0
- package/dist/shared/builtins/delete.js +13 -0
- package/dist/shared/builtins/edit.d.ts +8 -0
- package/dist/shared/builtins/edit.js +13 -0
- package/dist/shared/builtins/hide.d.ts +8 -0
- package/dist/shared/builtins/hide.js +13 -0
- package/dist/shared/builtins/index.d.ts +11 -0
- package/dist/shared/builtins/index.js +11 -0
- package/dist/shared/builtins/swipe.d.ts +8 -0
- package/dist/shared/builtins/swipe.js +17 -0
- package/dist/shared/describeLikeness.d.ts +14 -0
- package/dist/shared/describeLikeness.js +65 -0
- package/dist/shared/illustrateScene.d.ts +28 -0
- package/dist/shared/illustrateScene.js +181 -0
- package/dist/shared/portrait.d.ts +21 -0
- package/dist/shared/portrait.js +101 -0
- package/dist/shared/spriteFill.d.ts +14 -0
- package/dist/shared/spriteFill.js +107 -0
- package/dist/shared/sprites.d.ts +34 -0
- package/dist/shared/sprites.js +98 -0
- package/dist/shared/summarize/character.d.ts +9 -0
- package/dist/shared/summarize/character.js +10 -0
- package/dist/shared/summarize/history.d.ts +9 -0
- package/dist/shared/summarize/history.js +10 -0
- package/dist/shared/summarize/index.d.ts +12 -0
- package/dist/shared/summarize/index.js +12 -0
- package/dist/shared/summarize/scene.d.ts +38 -0
- package/dist/shared/summarize/scene.js +42 -0
- package/dist/shared/summarize/sceneIds.d.ts +17 -0
- package/dist/shared/summarize/sceneIds.js +17 -0
- package/dist/shared/summarize/summarizeScene.d.ts +113 -0
- package/dist/shared/summarize/summarizeScene.js +234 -0
- package/dist/shared/summarize/summarizeSpec.d.ts +54 -0
- package/dist/{summarize.js → shared/summarize/summarizeSpec.js} +23 -53
- package/dist/shared/summarize/world.d.ts +8 -0
- package/dist/shared/summarize/world.js +9 -0
- package/dist/shared/timePasses.d.ts +56 -0
- package/dist/shared/timePasses.js +86 -0
- package/dist/{toolLoop.d.ts → shared/toolLoop.d.ts} +25 -3
- package/dist/{toolLoop.js → shared/toolLoop.js} +70 -14
- package/dist/shared/ui/actions/index.d.ts +117 -0
- package/dist/shared/ui/actions/index.js +154 -0
- package/dist/shared/ui/album/index.d.ts +115 -0
- package/dist/shared/ui/album/index.js +178 -0
- package/dist/shared/ui/annex/index.d.ts +163 -0
- package/dist/shared/ui/annex/index.js +273 -0
- package/dist/shared/ui/attendance/index.d.ts +97 -0
- package/dist/shared/ui/attendance/index.js +89 -0
- package/dist/shared/ui/backdrop/index.d.ts +78 -0
- package/dist/shared/ui/backdrop/index.js +98 -0
- package/dist/shared/ui/chronicle/index.d.ts +230 -0
- package/dist/shared/ui/chronicle/index.js +249 -0
- package/dist/shared/ui/conversation/dossier.d.ts +33 -0
- package/dist/shared/ui/conversation/dossier.js +31 -0
- package/dist/{ui/sessions → shared/ui}/conversation/index.d.ts +2 -1
- package/dist/{ui/sessions → shared/ui}/conversation/index.js +3 -1
- package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.d.ts +1 -1
- package/dist/shared/ui/conversation/storyDays.d.ts +21 -0
- package/dist/shared/ui/conversation/storyDays.js +23 -0
- package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.js +1 -1
- package/dist/{ui/sessions → shared/ui}/lore-entries/index.d.ts +2 -2
- package/dist/shared/ui/places/index.d.ts +148 -0
- package/dist/shared/ui/places/index.js +249 -0
- package/dist/{ui/sessions → shared/ui}/scene-portraits/index.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/scene-portraits/index.js +1 -1
- package/dist/shared/ui/scene-portraits/portraits.d.ts +191 -0
- package/dist/shared/ui/scene-portraits/portraits.js +223 -0
- package/dist/shared/ui/session-state/index.d.ts +16 -0
- package/dist/shared/ui/session-state/index.js +16 -0
- package/dist/{ui/sessions → shared/ui}/session-state/shapes.d.ts +2 -2
- package/dist/shared/ui/session-state/stateView.d.ts +249 -0
- package/dist/shared/ui/session-state/stateView.js +247 -0
- package/dist/shared/ui/turn-order/index.d.ts +146 -0
- package/dist/shared/ui/turn-order/index.js +257 -0
- package/dist/{ui/sessions → shared/ui}/widgetContext.d.ts +19 -10
- package/package.json +69 -30
- package/components/sessions/messages/SessionContainer.svelte +0 -459
- package/components/sessions/scene-portraits/ScenePortraitsWidget.svelte +0 -249
- package/components/sessions/stats/StatsWidget.svelte +0 -112
- package/components/sessions/world-state/WorldStateWidget.svelte +0 -112
- package/components/sessions/world-state/world-state.ts +0 -10
- package/dist/adventureActions.d.ts +0 -169
- package/dist/adventureActions.js +0 -599
- package/dist/createChat.d.ts +0 -7
- package/dist/generateImage.d.ts +0 -7
- package/dist/lairActions.d.ts +0 -296
- package/dist/lairActions.js +0 -1287
- package/dist/respond.d.ts +0 -24
- package/dist/sprites.d.ts +0 -24
- package/dist/sprites.js +0 -102
- package/dist/summarize.d.ts +0 -76
- package/dist/ui/sessions/conversation/dossier.d.ts +0 -328
- package/dist/ui/sessions/conversation/dossier.js +0 -31
- package/dist/ui/sessions/scene-portraits/portraits.d.ts +0 -95
- package/dist/ui/sessions/scene-portraits/portraits.js +0 -115
- package/dist/ui/sessions/session-state/index.d.ts +0 -15
- package/dist/ui/sessions/session-state/index.js +0 -15
- package/dist/ui/sessions/session-state/stateView.d.ts +0 -155
- package/dist/ui/sessions/session-state/stateView.js +0 -141
- package/dist/ui/sessions/widgets.js +0 -567
- package/components/{sessions → genres/chat}/authors-note/authors-note.ts +0 -0
- package/components/{sessions/shared → shared}/context.ts +0 -0
- package/components/{sessions → shared}/lore-entries/lore-entries.ts +0 -0
- package/components/{sessions → shared}/messages/MessageBlocksView.svelte +0 -0
- package/components/{sessions → shared}/messages/MessageMediaStrip.svelte +0 -0
- package/components/{sessions → shared}/messages/MessagePartsView.svelte +0 -0
- package/components/{sessions → shared}/messages/StateProposalList.svelte +0 -0
- package/components/{sessions → shared}/messages/mediaStrip.ts +0 -0
- package/components/{sessions → shared}/messages/messages.ts +0 -0
- package/components/{sessions → shared}/scene-portraits/StatBars.svelte +0 -0
- package/components/{sessions → shared}/scene-portraits/scene-portraits.ts +0 -0
- package/components/{sessions → shared}/state/entryFinder.ts +0 -0
- package/components/{sessions → shared}/state/slotWriter.svelte.ts +0 -0
- package/dist/components/{shared-RJDGOAVC.js → shared-FTRGUE7G.js} +78 -78
- /package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.js +0 -0
- /package/dist/{entries.js → registry/entries.js} +0 -0
- /package/dist/{genres.d.ts → registry/genres.d.ts} +0 -0
- /package/dist/{slots.d.ts → registry/slots.d.ts} +0 -0
- /package/dist/{slots.js → registry/slots.js} +0 -0
- /package/dist/{statShapes.d.ts → registry/statShapes.d.ts} +0 -0
- /package/dist/{statShapes.js → registry/statShapes.js} +0 -0
- /package/dist/{guideMascotImage.d.ts → seed/guideMascotImage.d.ts} +0 -0
- /package/dist/{guideMascotImage.js → seed/guideMascotImage.js} +0 -0
- /package/dist/{presets.d.ts → seed/presets.d.ts} +0 -0
- /package/dist/{graphBuild.d.ts → shared/graphBuild.d.ts} +0 -0
- /package/dist/{graphBuild.js → shared/graphBuild.js} +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/text.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/text.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/lore-entries/index.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/barMath.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/barMath.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/shapes.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/widgetContext.js +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Core's **map canvas** (PLAN-core-widgets §3.6, W4): squares joined by
|
|
4
|
+
* arrows, laid out by `layoutMap` (`./index.ts`, its own layered layout —
|
|
5
|
+
* see there why not elkjs). A shared control, not a widget: Places draws
|
|
6
|
+
* its map with it, and Dungeon Crawler's `crawl-map` will.
|
|
7
|
+
*
|
|
8
|
+
* - **Squares** are buttons, tinted by `data-tint`, the place where the
|
|
9
|
+
* scene is ringed (`map-canvas.here`), the faces of who stands there on
|
|
10
|
+
* them (`map-canvas.face`). A press, or **Tab** to one and **Enter**,
|
|
11
|
+
* hands its id to `onPick`; the focus order is the layout's — ring by
|
|
12
|
+
* ring, left to right, then the squares nothing joins.
|
|
13
|
+
* - **Edges** are drawn lines with an arrowhead at the far end, and at
|
|
14
|
+
* both when they read both ways (`data-both`); a **stub** is a short
|
|
15
|
+
* line out of one square toward somewhere not drawn.
|
|
16
|
+
* - **Pan** is the viewport's own scroll; **zoom** is the three buttons
|
|
17
|
+
* above it (out, back to 100%, in).
|
|
18
|
+
*
|
|
19
|
+
* The markup carries no look (STYLE-GUIDE §6.16): only `map-canvas.*`
|
|
20
|
+
* parts and the positions as custom properties (`--sp-map-*`), which the
|
|
21
|
+
* skin (`widgets.css` §map-canvas) places and sizes by. The host mirrors
|
|
22
|
+
* no SVG, so lines and arrowheads are the skin's boxes.
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
MAP_NODE_H,
|
|
26
|
+
MAP_NODE_W,
|
|
27
|
+
layoutMap,
|
|
28
|
+
nextMapZoom,
|
|
29
|
+
type MapCanvasEdge,
|
|
30
|
+
type MapCanvasNode
|
|
31
|
+
} from "./index"
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
nodes,
|
|
35
|
+
edges,
|
|
36
|
+
selected = null,
|
|
37
|
+
onPick,
|
|
38
|
+
label = "Map",
|
|
39
|
+
t = (source: string) => source
|
|
40
|
+
}: {
|
|
41
|
+
nodes: readonly MapCanvasNode[]
|
|
42
|
+
edges: readonly MapCanvasEdge[]
|
|
43
|
+
/** The square shown as picked; null when none is. */
|
|
44
|
+
selected?: string | null
|
|
45
|
+
/** A square was pressed. */
|
|
46
|
+
onPick?: (nodeId: string) => void
|
|
47
|
+
/** What the map is called to a screen reader. */
|
|
48
|
+
label?: string
|
|
49
|
+
/** The widget's translation: English source in, the viewer's words out. */
|
|
50
|
+
t?: (source: string) => string
|
|
51
|
+
} = $props()
|
|
52
|
+
|
|
53
|
+
const layout = $derived(layoutMap(nodes, edges))
|
|
54
|
+
let zoom = $state(1)
|
|
55
|
+
|
|
56
|
+
/** A tint key, as the skin keys it: 0–5, or none. */
|
|
57
|
+
const tintOf = (tint: number | null | undefined) =>
|
|
58
|
+
typeof tint === "number" && Number.isInteger(tint) && tint >= 0 ? String(tint % 6) : undefined
|
|
59
|
+
|
|
60
|
+
const place = (x: number, y: number) => `--sp-map-x: ${x}; --sp-map-y: ${y}`
|
|
61
|
+
const line = (e: { x: number; y: number; len: number; angle: number }) =>
|
|
62
|
+
`${place(e.x, e.y)}; --sp-map-len: ${e.len}; --sp-map-angle: ${e.angle}`
|
|
63
|
+
|
|
64
|
+
/** The square, said: its name, then whether the scene is there, then its description. */
|
|
65
|
+
function said(n: MapCanvasNode): string {
|
|
66
|
+
const parts = [n.label]
|
|
67
|
+
if (n.here) parts.push(t("here"))
|
|
68
|
+
if (n.description) parts.push(n.description)
|
|
69
|
+
return parts.join(", ")
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<div data-widget-part="map-canvas.root" role="group" aria-label={label}>
|
|
74
|
+
<div data-widget-part="map-canvas.controls toolbar">
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
data-widget-part="map-canvas.zoom"
|
|
78
|
+
data-zoom="out"
|
|
79
|
+
aria-label={t("Zoom out")}
|
|
80
|
+
title={t("Zoom out")}
|
|
81
|
+
disabled={nextMapZoom(zoom, "out") === zoom}
|
|
82
|
+
onclick={() => (zoom = nextMapZoom(zoom, "out"))}
|
|
83
|
+
>
|
|
84
|
+
<sp-icon name="zoom-out" size="14"></sp-icon>
|
|
85
|
+
</button>
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
data-widget-part="map-canvas.zoom"
|
|
89
|
+
data-zoom="reset"
|
|
90
|
+
aria-label={t("Zoom to 100%")}
|
|
91
|
+
title={t("Zoom to 100%")}
|
|
92
|
+
onclick={() => (zoom = 1)}
|
|
93
|
+
>
|
|
94
|
+
{Math.round(zoom * 100)}%
|
|
95
|
+
</button>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
data-widget-part="map-canvas.zoom"
|
|
99
|
+
data-zoom="in"
|
|
100
|
+
aria-label={t("Zoom in")}
|
|
101
|
+
title={t("Zoom in")}
|
|
102
|
+
disabled={nextMapZoom(zoom, "in") === zoom}
|
|
103
|
+
onclick={() => (zoom = nextMapZoom(zoom, "in"))}
|
|
104
|
+
>
|
|
105
|
+
<sp-icon name="zoom-in" size="14"></sp-icon>
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
<div data-widget-part="map-canvas.viewport">
|
|
109
|
+
<div
|
|
110
|
+
data-widget-part="map-canvas.surface"
|
|
111
|
+
style="--sp-map-w: {layout.width}; --sp-map-h: {layout.height}; --sp-map-zoom: {zoom}; --sp-map-node-w: {MAP_NODE_W}; --sp-map-node-h: {MAP_NODE_H}"
|
|
112
|
+
>
|
|
113
|
+
<div data-widget-part="map-canvas.plane">
|
|
114
|
+
{#each layout.edges as e (e.id)}
|
|
115
|
+
{#if e.stub}
|
|
116
|
+
<div
|
|
117
|
+
data-widget-part="map-canvas.stub"
|
|
118
|
+
data-edge-id={e.id}
|
|
119
|
+
aria-hidden="true"
|
|
120
|
+
style={line(e)}
|
|
121
|
+
></div>
|
|
122
|
+
{:else}
|
|
123
|
+
<div
|
|
124
|
+
data-widget-part="map-canvas.edge"
|
|
125
|
+
data-edge-id={e.id}
|
|
126
|
+
data-both={e.bidirectional ? "" : undefined}
|
|
127
|
+
aria-hidden="true"
|
|
128
|
+
style={line(e)}
|
|
129
|
+
></div>
|
|
130
|
+
{/if}
|
|
131
|
+
{#if e.label}
|
|
132
|
+
<span
|
|
133
|
+
data-widget-part="map-canvas.label"
|
|
134
|
+
data-edge-id={e.id}
|
|
135
|
+
aria-hidden="true"
|
|
136
|
+
style={place(e.labelX, e.labelY)}>{e.label}</span
|
|
137
|
+
>
|
|
138
|
+
{/if}
|
|
139
|
+
{/each}
|
|
140
|
+
{#each layout.nodes as n (n.id)}
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
data-widget-part="map-canvas.node"
|
|
144
|
+
data-node-id={n.id}
|
|
145
|
+
data-tint={tintOf(n.tint)}
|
|
146
|
+
data-here={n.here ? "" : undefined}
|
|
147
|
+
aria-pressed={selected === n.id}
|
|
148
|
+
aria-label={said(n)}
|
|
149
|
+
title={n.label}
|
|
150
|
+
style={place(n.x, n.y)}
|
|
151
|
+
onclick={() => onPick?.(n.id)}
|
|
152
|
+
>
|
|
153
|
+
{#if n.here}
|
|
154
|
+
<span data-widget-part="map-canvas.here" aria-hidden="true"></span>
|
|
155
|
+
{/if}
|
|
156
|
+
<span data-widget-part="map-canvas.label">{n.label}</span>
|
|
157
|
+
{#if n.faces?.length}
|
|
158
|
+
<span data-widget-part="map-canvas.faces" aria-hidden="true">
|
|
159
|
+
{#each n.faces as f (f.ref)}
|
|
160
|
+
<span data-widget-part="map-canvas.face" title={f.name}>
|
|
161
|
+
<sp-avatar ref={f.ref} size="sm"></sp-avatar>
|
|
162
|
+
</span>
|
|
163
|
+
{/each}
|
|
164
|
+
</span>
|
|
165
|
+
{/if}
|
|
166
|
+
</button>
|
|
167
|
+
{/each}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's **map canvas** (PLAN-core-widgets §3.6, W4, 2026-10-11) — the pure
|
|
3
|
+
* half: nodes and edges in, positions out. One renderer for core's map-like
|
|
4
|
+
* widgets — Places (W4) today, Dungeon Crawler's `crawl-map` (W5) when that
|
|
5
|
+
* genre lands — drawn by `MapCanvas.svelte` beside this file. It is a shared
|
|
6
|
+
* control, not a widget: it has no declaration and is imported by the
|
|
7
|
+
* widgets that draw a map.
|
|
8
|
+
*
|
|
9
|
+
* ⚠ Not the lorebook's **Places lens** (the app's own graph canvas): core's
|
|
10
|
+
* components run in the page's UI worker and cannot import the app's
|
|
11
|
+
* Svelte. Two map canvases is a known cost; the lens may adopt this one
|
|
12
|
+
* later, not the reverse.
|
|
13
|
+
*
|
|
14
|
+
* **The layout is its own, not elkjs.** The plan chose elkjs (Q5); it cannot
|
|
15
|
+
* run here. A component's worker carries Remote DOM's DOM polyfill, whose
|
|
16
|
+
* `window` is not the global scope, and elkjs' compiled core reads
|
|
17
|
+
* `window.Math` (and, with no `document`, takes over the worker's
|
|
18
|
+
* `onmessage`); its 1.6 MB would also ride in every clone, and an in-app
|
|
19
|
+
* clone may not import it at all (`COMPONENT_IMPORTS`). So the layout is a
|
|
20
|
+
* small layered one, deterministic for the same input:
|
|
21
|
+
*
|
|
22
|
+
* 1. Each connected group of nodes is laid out in **rings outward** from its
|
|
23
|
+
* root — the node marked `here` when the group holds it, else the one
|
|
24
|
+
* with the most edges (the first such, in input order) — by how many
|
|
25
|
+
* edges away each node is, whichever way the edges run (a map is walked
|
|
26
|
+
* both ways; an arrow says which way a way reads).
|
|
27
|
+
* 2. Within a ring, nodes are ordered by where their neighbours in the ring
|
|
28
|
+
* before stand (then the ring after, then before again), ties kept in
|
|
29
|
+
* the order they were reached.
|
|
30
|
+
* 3. Groups stand side by side in input order of their first node; nodes
|
|
31
|
+
* with no edge at all stand in rows beneath.
|
|
32
|
+
*
|
|
33
|
+
* Edges run centre to centre, cut at each square's border so an arrowhead
|
|
34
|
+
* touches it; two edges between one pair are drawn apart. An edge whose far
|
|
35
|
+
* end is no node, or one marked `stub`, is a **stub**: a short line out of
|
|
36
|
+
* its node, toward somewhere not drawn (an unseen room's way).
|
|
37
|
+
*
|
|
38
|
+
* The markup draws with plain elements and custom properties only (the host
|
|
39
|
+
* mirrors no SVG): a square is placed by `--sp-map-x` / `--sp-map-y`, an
|
|
40
|
+
* edge by its start, length and angle (`--sp-map-len`, `--sp-map-angle`).
|
|
41
|
+
*
|
|
42
|
+
* 🚧 Provisional with W4; W5 may grow it (a stub's own direction, fuses).
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/** A square on the map. @experimental */
|
|
46
|
+
export interface MapCanvasNode {
|
|
47
|
+
/** Unique among the nodes; what `onPick` hands back. */
|
|
48
|
+
id: string
|
|
49
|
+
/** The name written on the square. */
|
|
50
|
+
label: string
|
|
51
|
+
/** A tint key (0–5) the skin colours the square by; null or absent is untinted. */
|
|
52
|
+
tint?: number | null
|
|
53
|
+
/** Faces drawn on the square — who stands there — by participant reference (`character:3`). */
|
|
54
|
+
faces?: readonly { ref: string; name: string }[]
|
|
55
|
+
/** Where the scene is: ringed. */
|
|
56
|
+
here?: boolean
|
|
57
|
+
/** Read after the label by a screen reader (who is here, the category). */
|
|
58
|
+
description?: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A line between two squares, or a stub out of one. @experimental */
|
|
62
|
+
export interface MapCanvasEdge {
|
|
63
|
+
/** Unique among the edges. */
|
|
64
|
+
id: string
|
|
65
|
+
from: string
|
|
66
|
+
/** The far node; one that is no node's id draws a stub out of `from`. */
|
|
67
|
+
to: string
|
|
68
|
+
/** Reads from both ends: an arrowhead at each. */
|
|
69
|
+
bidirectional?: boolean
|
|
70
|
+
/** Written at the line's middle; absent or empty writes nothing. */
|
|
71
|
+
label?: string | null
|
|
72
|
+
/** A way to somewhere not drawn: a short line out of `from` only. */
|
|
73
|
+
stub?: boolean
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A square as placed: its top-left corner and size, its centre, its ring. @experimental */
|
|
77
|
+
export interface PlacedMapNode extends MapCanvasNode {
|
|
78
|
+
x: number
|
|
79
|
+
y: number
|
|
80
|
+
w: number
|
|
81
|
+
h: number
|
|
82
|
+
/** Which ring of its group it stands in (0 is the root's); -1 for a node with no edge. */
|
|
83
|
+
ring: number
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A line as placed: where it starts, how long it runs and at what angle (degrees, clockwise from east). @experimental */
|
|
87
|
+
export interface PlacedMapEdge {
|
|
88
|
+
id: string
|
|
89
|
+
from: string
|
|
90
|
+
to: string
|
|
91
|
+
x: number
|
|
92
|
+
y: number
|
|
93
|
+
len: number
|
|
94
|
+
angle: number
|
|
95
|
+
bidirectional: boolean
|
|
96
|
+
stub: boolean
|
|
97
|
+
label: string | null
|
|
98
|
+
/** Where its label sits: the line's middle. */
|
|
99
|
+
labelX: number
|
|
100
|
+
labelY: number
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The whole drawing: nodes in focus order (ring by ring, left to right; then the unjoined), edges, its size. @experimental */
|
|
104
|
+
export interface MapLayout {
|
|
105
|
+
nodes: PlacedMapNode[]
|
|
106
|
+
edges: PlacedMapEdge[]
|
|
107
|
+
width: number
|
|
108
|
+
height: number
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A square's size and the gaps between them, in the plane's pixels. @experimental */
|
|
112
|
+
export const MAP_NODE_W = 120
|
|
113
|
+
/** @experimental */
|
|
114
|
+
export const MAP_NODE_H = 48
|
|
115
|
+
/** @experimental */
|
|
116
|
+
export const MAP_GAP_X = 36
|
|
117
|
+
/** @experimental */
|
|
118
|
+
export const MAP_GAP_Y = 52
|
|
119
|
+
/** @experimental */
|
|
120
|
+
export const MAP_PAD = 16
|
|
121
|
+
/** How far a stub runs out of its square. @experimental */
|
|
122
|
+
export const MAP_STUB_LEN = 26
|
|
123
|
+
/** How far apart two lines between one pair are drawn. @experimental */
|
|
124
|
+
export const MAP_PARALLEL_GAP = 6
|
|
125
|
+
|
|
126
|
+
/** The zoom steps the canvas offers, smallest first; 1 is the plane's own size. @experimental */
|
|
127
|
+
export const MAP_ZOOMS: readonly number[] = Object.freeze([0.5, 0.75, 1, 1.25, 1.5, 2])
|
|
128
|
+
|
|
129
|
+
const round = (n: number) => Math.round(n * 10) / 10
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Lay the map out: every node placed, every edge between two placed nodes
|
|
133
|
+
* cut to their borders, every stub drawn out of its node. Pure and
|
|
134
|
+
* deterministic: the same nodes and edges in the same order lay out the
|
|
135
|
+
* same. A duplicate node id keeps its first; an edge from a node that is not
|
|
136
|
+
* there, or from a node to itself, draws nothing.
|
|
137
|
+
* @experimental
|
|
138
|
+
*/
|
|
139
|
+
export function layoutMap(
|
|
140
|
+
nodes: readonly MapCanvasNode[],
|
|
141
|
+
edges: readonly MapCanvasEdge[],
|
|
142
|
+
): MapLayout {
|
|
143
|
+
const order = new Map<string, number>()
|
|
144
|
+
const list: MapCanvasNode[] = []
|
|
145
|
+
for (const n of nodes)
|
|
146
|
+
if (!order.has(n.id)) {
|
|
147
|
+
order.set(n.id, list.length)
|
|
148
|
+
list.push(n)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const joins = edges.filter(
|
|
152
|
+
(e) => !e.stub && e.from !== e.to && order.has(e.from) && order.has(e.to),
|
|
153
|
+
)
|
|
154
|
+
const stubs = edges.filter((e) => order.has(e.from) && (e.stub || !order.has(e.to)))
|
|
155
|
+
|
|
156
|
+
// Neighbours, either way, each once, in input order.
|
|
157
|
+
const adj = new Map<string, string[]>(list.map((n) => [n.id, []]))
|
|
158
|
+
for (const e of joins) {
|
|
159
|
+
const a = adj.get(e.from)!
|
|
160
|
+
const b = adj.get(e.to)!
|
|
161
|
+
if (!a.includes(e.to)) a.push(e.to)
|
|
162
|
+
if (!b.includes(e.from)) b.push(e.from)
|
|
163
|
+
}
|
|
164
|
+
for (const ns of adj.values()) ns.sort((p, q) => order.get(p)! - order.get(q)!)
|
|
165
|
+
|
|
166
|
+
// Groups, each in rings from its root.
|
|
167
|
+
const seen = new Set<string>()
|
|
168
|
+
const groups: string[][][] = []
|
|
169
|
+
const loners: MapCanvasNode[] = []
|
|
170
|
+
for (const start of list) {
|
|
171
|
+
if (seen.has(start.id)) continue
|
|
172
|
+
if (!adj.get(start.id)!.length) {
|
|
173
|
+
seen.add(start.id)
|
|
174
|
+
loners.push(start)
|
|
175
|
+
continue
|
|
176
|
+
}
|
|
177
|
+
// The group's members, to choose its root.
|
|
178
|
+
const members: string[] = []
|
|
179
|
+
const stack = [start.id]
|
|
180
|
+
const inGroup = new Set([start.id])
|
|
181
|
+
while (stack.length) {
|
|
182
|
+
const id = stack.shift()!
|
|
183
|
+
members.push(id)
|
|
184
|
+
for (const nb of adj.get(id)!)
|
|
185
|
+
if (!inGroup.has(nb)) {
|
|
186
|
+
inGroup.add(nb)
|
|
187
|
+
stack.push(nb)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
members.sort((p, q) => order.get(p)! - order.get(q)!)
|
|
191
|
+
const here = members.find((id) => list[order.get(id)!]!.here)
|
|
192
|
+
const root =
|
|
193
|
+
here ??
|
|
194
|
+
members.reduce(
|
|
195
|
+
(best, id) => (adj.get(id)!.length > adj.get(best)!.length ? id : best),
|
|
196
|
+
members[0]!,
|
|
197
|
+
)
|
|
198
|
+
const rings: string[][] = []
|
|
199
|
+
const ringOf = new Map<string, number>([[root, 0]])
|
|
200
|
+
const queue = [root]
|
|
201
|
+
while (queue.length) {
|
|
202
|
+
const id = queue.shift()!
|
|
203
|
+
const r = ringOf.get(id)!
|
|
204
|
+
;(rings[r] ??= []).push(id)
|
|
205
|
+
for (const nb of adj.get(id)!)
|
|
206
|
+
if (!ringOf.has(nb)) {
|
|
207
|
+
ringOf.set(nb, r + 1)
|
|
208
|
+
queue.push(nb)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const id of members) seen.add(id)
|
|
212
|
+
groups.push(orderRings(rings, adj))
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Place each group: rings top to bottom, each centred on the widest.
|
|
216
|
+
const placed = new Map<string, PlacedMapNode>()
|
|
217
|
+
const focus: string[] = []
|
|
218
|
+
const stepX = MAP_NODE_W + MAP_GAP_X
|
|
219
|
+
const stepY = MAP_NODE_H + MAP_GAP_Y
|
|
220
|
+
let left = MAP_PAD
|
|
221
|
+
let bottom = MAP_PAD
|
|
222
|
+
for (const rings of groups) {
|
|
223
|
+
const widest = Math.max(...rings.map((r) => r.length))
|
|
224
|
+
const groupW = widest * stepX - MAP_GAP_X
|
|
225
|
+
rings.forEach((ring, r) => {
|
|
226
|
+
const ringW = ring.length * stepX - MAP_GAP_X
|
|
227
|
+
const x0 = left + (groupW - ringW) / 2
|
|
228
|
+
ring.forEach((id, i) => {
|
|
229
|
+
const node = list[order.get(id)!]!
|
|
230
|
+
const p: PlacedMapNode = {
|
|
231
|
+
...node,
|
|
232
|
+
x: round(x0 + i * stepX),
|
|
233
|
+
y: round(MAP_PAD + r * stepY),
|
|
234
|
+
w: MAP_NODE_W,
|
|
235
|
+
h: MAP_NODE_H,
|
|
236
|
+
ring: r,
|
|
237
|
+
}
|
|
238
|
+
placed.set(id, p)
|
|
239
|
+
focus.push(id)
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
bottom = Math.max(bottom, MAP_PAD + rings.length * stepY - MAP_GAP_Y)
|
|
243
|
+
left += groupW + 2 * MAP_GAP_X
|
|
244
|
+
}
|
|
245
|
+
let width = groups.length ? left - 2 * MAP_GAP_X + MAP_PAD : MAP_PAD * 2
|
|
246
|
+
|
|
247
|
+
// The unjoined, in rows beneath: as many to a row as the groups are wide (at least four).
|
|
248
|
+
if (loners.length) {
|
|
249
|
+
const fit = Math.floor((width - 2 * MAP_PAD + MAP_GAP_X) / stepX)
|
|
250
|
+
const perRow = Math.max(Math.min(loners.length, 4), fit)
|
|
251
|
+
const top = groups.length ? bottom + MAP_GAP_Y : MAP_PAD
|
|
252
|
+
loners.forEach((node, i) => {
|
|
253
|
+
const p: PlacedMapNode = {
|
|
254
|
+
...node,
|
|
255
|
+
x: round(MAP_PAD + (i % perRow) * stepX),
|
|
256
|
+
y: round(top + Math.floor(i / perRow) * stepY),
|
|
257
|
+
w: MAP_NODE_W,
|
|
258
|
+
h: MAP_NODE_H,
|
|
259
|
+
ring: -1,
|
|
260
|
+
}
|
|
261
|
+
placed.set(node.id, p)
|
|
262
|
+
focus.push(node.id)
|
|
263
|
+
})
|
|
264
|
+
bottom = top + Math.ceil(loners.length / perRow) * stepY - MAP_GAP_Y
|
|
265
|
+
width = Math.max(width, MAP_PAD * 2 + Math.min(loners.length, perRow) * stepX - MAP_GAP_X)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Lines: centre to centre, cut at the borders; a pair's several drawn apart.
|
|
269
|
+
const pairKey = (e: MapCanvasEdge) => [e.from, e.to].sort().join('\u0000')
|
|
270
|
+
const pairs = new Map<string, MapCanvasEdge[]>()
|
|
271
|
+
for (const e of joins) pairs.set(pairKey(e), [...(pairs.get(pairKey(e)) ?? []), e])
|
|
272
|
+
const out: PlacedMapEdge[] = []
|
|
273
|
+
for (const e of joins) {
|
|
274
|
+
const a = placed.get(e.from)!
|
|
275
|
+
const b = placed.get(e.to)!
|
|
276
|
+
const ax = a.x + a.w / 2
|
|
277
|
+
const ay = a.y + a.h / 2
|
|
278
|
+
const bx = b.x + b.w / 2
|
|
279
|
+
const by = b.y + b.h / 2
|
|
280
|
+
const dx = bx - ax
|
|
281
|
+
const dy = by - ay
|
|
282
|
+
const dist = Math.hypot(dx, dy)
|
|
283
|
+
if (dist === 0) continue
|
|
284
|
+
const ux = dx / dist
|
|
285
|
+
const uy = dy / dist
|
|
286
|
+
// Several lines between one pair, side by side (the pair's own order).
|
|
287
|
+
const mates = pairs.get(pairKey(e))!
|
|
288
|
+
const k = mates.indexOf(e)
|
|
289
|
+
// One perpendicular for the pair whichever way each runs, so two lines never cross.
|
|
290
|
+
const sign = e.from < e.to ? 1 : -1
|
|
291
|
+
const shift = (k - (mates.length - 1) / 2) * MAP_PARALLEL_GAP * sign
|
|
292
|
+
const ox = -uy * shift
|
|
293
|
+
const oy = ux * shift
|
|
294
|
+
const cutA = borderCut(a.w / 2, a.h / 2, ux, uy)
|
|
295
|
+
const cutB = borderCut(b.w / 2, b.h / 2, ux, uy)
|
|
296
|
+
const len = dist - cutA - cutB
|
|
297
|
+
if (len <= 0) continue
|
|
298
|
+
const x = ax + ux * cutA + ox
|
|
299
|
+
const y = ay + uy * cutA + oy
|
|
300
|
+
out.push({
|
|
301
|
+
id: e.id,
|
|
302
|
+
from: e.from,
|
|
303
|
+
to: e.to,
|
|
304
|
+
x: round(x),
|
|
305
|
+
y: round(y),
|
|
306
|
+
len: round(len),
|
|
307
|
+
angle: round((Math.atan2(dy, dx) * 180) / Math.PI),
|
|
308
|
+
bidirectional: !!e.bidirectional,
|
|
309
|
+
stub: false,
|
|
310
|
+
label: e.label?.trim() ? e.label.trim() : null,
|
|
311
|
+
labelX: round(x + (ux * len) / 2),
|
|
312
|
+
labelY: round(y + (uy * len) / 2),
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Stubs: out of the square's lower border, fanned when there are several.
|
|
317
|
+
const stubsOf = new Map<string, MapCanvasEdge[]>()
|
|
318
|
+
for (const e of stubs) stubsOf.set(e.from, [...(stubsOf.get(e.from) ?? []), e])
|
|
319
|
+
for (const [from, mine] of stubsOf) {
|
|
320
|
+
const a = placed.get(from)!
|
|
321
|
+
mine.forEach((e, k) => {
|
|
322
|
+
const angle = 90 + (k - (mine.length - 1) / 2) * 30
|
|
323
|
+
const ux = Math.cos((angle * Math.PI) / 180)
|
|
324
|
+
const uy = Math.sin((angle * Math.PI) / 180)
|
|
325
|
+
const cut = borderCut(a.w / 2, a.h / 2, ux, uy)
|
|
326
|
+
const x = a.x + a.w / 2 + ux * cut
|
|
327
|
+
const y = a.y + a.h / 2 + uy * cut
|
|
328
|
+
out.push({
|
|
329
|
+
id: e.id,
|
|
330
|
+
from: e.from,
|
|
331
|
+
to: e.to,
|
|
332
|
+
x: round(x),
|
|
333
|
+
y: round(y),
|
|
334
|
+
len: MAP_STUB_LEN,
|
|
335
|
+
angle: round(angle),
|
|
336
|
+
bidirectional: !!e.bidirectional,
|
|
337
|
+
stub: true,
|
|
338
|
+
label: e.label?.trim() ? e.label.trim() : null,
|
|
339
|
+
labelX: round(x + (ux * MAP_STUB_LEN) / 2),
|
|
340
|
+
labelY: round(y + (uy * MAP_STUB_LEN) / 2),
|
|
341
|
+
})
|
|
342
|
+
})
|
|
343
|
+
bottom = Math.max(bottom, a.y + a.h + MAP_STUB_LEN)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
nodes: focus.map((id) => placed.get(id)!),
|
|
348
|
+
edges: out,
|
|
349
|
+
width: round(width),
|
|
350
|
+
height: round(bottom + MAP_PAD),
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** How far from a box's centre a ray along (ux, uy) leaves it. */
|
|
355
|
+
function borderCut(hw: number, hh: number, ux: number, uy: number): number {
|
|
356
|
+
const tx = ux === 0 ? Number.POSITIVE_INFINITY : hw / Math.abs(ux)
|
|
357
|
+
const ty = uy === 0 ? Number.POSITIVE_INFINITY : hh / Math.abs(uy)
|
|
358
|
+
return Math.min(tx, ty)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Order each ring by where its neighbours stand in the ring before (then the
|
|
363
|
+
* ring after, then before again) — fewer crossings — keeping the order nodes
|
|
364
|
+
* were reached where it ties. Stable, so deterministic.
|
|
365
|
+
*/
|
|
366
|
+
function orderRings(rings: string[][], adj: ReadonlyMap<string, readonly string[]>): string[][] {
|
|
367
|
+
const out = rings.map((r) => [...r])
|
|
368
|
+
const sweep = (r: number, by: number) => {
|
|
369
|
+
const pos = new Map(out[by]!.map((id, i) => [id, i]))
|
|
370
|
+
const keyed = out[r]!.map((id, i) => {
|
|
371
|
+
const near = adj
|
|
372
|
+
.get(id)!
|
|
373
|
+
.filter((nb) => pos.has(nb))
|
|
374
|
+
.map((nb) => pos.get(nb)!)
|
|
375
|
+
return { id, i, key: near.length ? near.reduce((s, v) => s + v, 0) / near.length : i }
|
|
376
|
+
})
|
|
377
|
+
keyed.sort((p, q) => p.key - q.key || p.i - q.i)
|
|
378
|
+
out[r] = keyed.map((k) => k.id)
|
|
379
|
+
}
|
|
380
|
+
for (let r = 1; r < out.length; r++) sweep(r, r - 1)
|
|
381
|
+
for (let r = out.length - 2; r >= 0; r--) sweep(r, r + 1)
|
|
382
|
+
for (let r = 1; r < out.length; r++) sweep(r, r - 1)
|
|
383
|
+
return out
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** The next zoom step in or out from `zoom`, or `zoom` itself at either end. @experimental */
|
|
387
|
+
export function nextMapZoom(zoom: number, way: 'in' | 'out'): number {
|
|
388
|
+
if (way === 'in') return MAP_ZOOMS.find((z) => z > zoom + 1e-9) ?? zoom
|
|
389
|
+
return [...MAP_ZOOMS].reverse().find((z) => z < zoom - 1e-9) ?? zoom
|
|
390
|
+
}
|
|
@@ -145,6 +145,17 @@
|
|
|
145
145
|
const noteIdOf = (a: WidgetAction) =>
|
|
146
146
|
`msg-${msg.id}-note-${actionIdentity(a).replace(/[^a-z0-9-]/g, "-")}`
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* 🚧 *Start scene here* / *End scene here* (PROPOSAL-live-scenes §7): the
|
|
150
|
+
* scene boundaries this line may take — none unless the viewer may place
|
|
151
|
+
* them (the dossier's `sceneBoundaries`), and only where the host would
|
|
152
|
+
* accept them (`boundaryOffer`), so nothing is offered then refused. A
|
|
153
|
+
* line being written takes neither.
|
|
154
|
+
*/
|
|
155
|
+
const boundaries = $derived(
|
|
156
|
+
msg.isGenerating ? { start: false, end: null } : conv.scenes.offer(msg)
|
|
157
|
+
)
|
|
158
|
+
|
|
148
159
|
/**
|
|
149
160
|
* "Inspect run" (R55: administrators only): the host finds the run that
|
|
150
161
|
* wrote this reply and opens the inspector (`inspect-run`), or says there
|
|
@@ -240,6 +251,37 @@
|
|
|
240
251
|
<span>Select for summary</span>
|
|
241
252
|
</button>
|
|
242
253
|
{/if}
|
|
254
|
+
{#if boundaries.start}
|
|
255
|
+
<button
|
|
256
|
+
data-widget-part="messages.scene-start messages.message-option"
|
|
257
|
+
title="Start a scene at this line; an open scene ends at the line before"
|
|
258
|
+
aria-disabled={conv.scenes.busy}
|
|
259
|
+
onclick={(e) => {
|
|
260
|
+
if (conv.scenes.busy) return e.preventDefault()
|
|
261
|
+
closeMenu()
|
|
262
|
+
void conv.scenes.startAt(msg)
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
<sp-icon name="flag" size="16"></sp-icon>
|
|
266
|
+
<span>Start scene here</span>
|
|
267
|
+
</button>
|
|
268
|
+
{/if}
|
|
269
|
+
{#if boundaries.end !== null}
|
|
270
|
+
{@const sceneId = boundaries.end}
|
|
271
|
+
<button
|
|
272
|
+
data-widget-part="messages.scene-end messages.message-option"
|
|
273
|
+
title="End the open scene at this line; the next one begins after it (Automatic) or is suggested there (Suggested)"
|
|
274
|
+
aria-disabled={conv.scenes.busy}
|
|
275
|
+
onclick={(e) => {
|
|
276
|
+
if (conv.scenes.busy) return e.preventDefault()
|
|
277
|
+
closeMenu()
|
|
278
|
+
void conv.scenes.endAt(sceneId, msg)
|
|
279
|
+
}}
|
|
280
|
+
>
|
|
281
|
+
<sp-icon name="flag-off" size="16"></sp-icon>
|
|
282
|
+
<span>End scene here</span>
|
|
283
|
+
</button>
|
|
284
|
+
{/if}
|
|
243
285
|
{#if canChangeSprite}
|
|
244
286
|
<button
|
|
245
287
|
data-widget-part="messages.message-option"
|
|
@@ -12,28 +12,39 @@
|
|
|
12
12
|
* rather than in a queue somewhere else because the sentence that justifies a
|
|
13
13
|
* change is the one above them; **Review** opens the same rows for the whole
|
|
14
14
|
* session, for when they have scrolled away.
|
|
15
|
+
*
|
|
16
|
+
* 🚧 `head` (live scenes §15 G13): the conversation's **ledger head**
|
|
17
|
+
* instead — the clock moves made before the session had a single line
|
|
18
|
+
* (`state.head`), drawn above the first message. Lines only: nothing
|
|
19
|
+
* waits on a line that does not exist.
|
|
15
20
|
*/
|
|
16
21
|
import StateProposalList from "./StateProposalList.svelte"
|
|
17
22
|
import { useConversation } from "./conversation.svelte"
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
let { messageId }: Props = $props()
|
|
24
|
+
type Props = { messageId: number; head?: false } | { messageId?: undefined; head: true }
|
|
25
|
+
let { messageId, head = false }: Props = $props()
|
|
23
26
|
|
|
24
27
|
// What this line changed and what waits on it: the page's projection of
|
|
25
28
|
// the session state (C0b), read off the conversation.
|
|
26
29
|
const conv = useConversation()
|
|
27
|
-
let groups = $derived(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
let groups = $derived(
|
|
31
|
+
head
|
|
32
|
+
? (conv.dossier?.state.head ?? [])
|
|
33
|
+
: (conv.dossier?.state.ledgers[messageId as number] ?? [])
|
|
34
|
+
)
|
|
35
|
+
let pending = $derived(head ? [] : (conv.dossier?.state.pending[messageId as number] ?? []))
|
|
36
|
+
let waiting = $derived(head ? [] : (conv.dossier?.state.waiting ?? []))
|
|
30
37
|
let reviewOpen = $state(false)
|
|
31
38
|
</script>
|
|
32
39
|
|
|
33
40
|
<!-- The ledger's parts (`messages.ledger*`, `messages.proposal*`; STYLE-GUIDE
|
|
34
41
|
§6.16): no look here; the default widget stylesheet draws them. -->
|
|
35
42
|
{#if groups.length || pending.length}
|
|
36
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
data-widget-part="messages.ledger"
|
|
45
|
+
data-ledger-message={head ? undefined : messageId}
|
|
46
|
+
data-ledger-head={head ? "" : undefined}
|
|
47
|
+
>
|
|
37
48
|
{#each groups as group (group.ownerKey)}
|
|
38
49
|
<p data-widget-part="messages.ledger-line" data-owner-key={group.ownerKey}>
|
|
39
50
|
<span data-widget-part="messages.ledger-owner">{group.ownerLabel}</span>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { ComponentContext } from "@serene-pub/sdk/component"
|
|
9
9
|
import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/conversation"
|
|
10
10
|
import MessagesWidget from "./MessagesWidget.svelte"
|
|
11
|
-
import { widgetRefFromComponent } from "../
|
|
11
|
+
import { widgetRefFromComponent } from "../widgetRef.svelte"
|
|
12
12
|
|
|
13
13
|
let { ctx }: { ctx: ComponentContext } = $props()
|
|
14
14
|
|