@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,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@serene-pub/core-catalog/album` — the plain-TypeScript half of core's
|
|
3
|
+
* Album widget (PLAN-core-widgets W2): its settings, and the one reading it
|
|
4
|
+
* draws — every picture on the session's lines, newest first, each with
|
|
5
|
+
* where it came from and who showed it when. The widget's Svelte source
|
|
6
|
+
* lives in `components/shared/album/` and ships built
|
|
7
|
+
* (`dist/components/album.js`); a host imports only this half, which carries
|
|
8
|
+
* no Svelte runtime.
|
|
9
|
+
*
|
|
10
|
+
* **What it reads** is the log (`messages.v1`): each row's `core:image`
|
|
11
|
+
* parts, the step's shown revision only, in the order the media strip
|
|
12
|
+
* under the line draws them (`mediaStripItems`). A part with no usable
|
|
13
|
+
* `assetId` is no file anyone can fetch and is left out, as the strip
|
|
14
|
+
* leaves it out. A hidden row's pictures are not drawn. A file part
|
|
15
|
+
* (`core:file`) is not a picture and is the strip's alone.
|
|
16
|
+
*
|
|
17
|
+
* **Where a picture came from** is the row's: a person's line (`role:
|
|
18
|
+
* 'user'`) holds what they **attached**; any other line holds what a run
|
|
19
|
+
* **generated** — image generation, or an outlet that attached its bytes.
|
|
20
|
+
* The part itself names no origin today (`mediaPartFor` writes the same
|
|
21
|
+
* part for all three writers). A line's sprite is not a part — the line
|
|
22
|
+
* records its set and label, the picture is the character's — so the album
|
|
23
|
+
* never draws one.
|
|
24
|
+
*
|
|
25
|
+
* ⚠ Not a **gallery** (a character's or persona's own image set), not the
|
|
26
|
+
* **media strip** (one message's files, under its card) and not the
|
|
27
|
+
* **Media** collection (every file a person stored).
|
|
28
|
+
*
|
|
29
|
+
* Every sentence is English source handed through the widget's `t`, so the
|
|
30
|
+
* same words speak the viewer's language natively or in a worker.
|
|
31
|
+
*
|
|
32
|
+
* 🚧 Provisional with the widget.
|
|
33
|
+
*/
|
|
34
|
+
import { parseChannel } from '@serene-pub/sdk';
|
|
35
|
+
/** @experimental */
|
|
36
|
+
export const ALBUM_DEFAULTS = Object.freeze({
|
|
37
|
+
source: 'all',
|
|
38
|
+
tile: 'medium',
|
|
39
|
+
arrangement: 'grid',
|
|
40
|
+
channel: '',
|
|
41
|
+
});
|
|
42
|
+
const oneOf = (v, of, fallback) => typeof v === 'string' && of.includes(v) ? v : fallback;
|
|
43
|
+
/** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
|
|
44
|
+
export function readAlbumSettings(raw) {
|
|
45
|
+
const v = raw ?? {};
|
|
46
|
+
return {
|
|
47
|
+
source: oneOf(v.source, ['all', 'attached', 'generated'], ALBUM_DEFAULTS.source),
|
|
48
|
+
tile: oneOf(v.tile, ['small', 'medium', 'large'], ALBUM_DEFAULTS.tile),
|
|
49
|
+
arrangement: oneOf(v.arrangement, ['grid', 'latest'], ALBUM_DEFAULTS.arrangement),
|
|
50
|
+
channel: typeof v.channel === 'string' ? v.channel.trim() : ALBUM_DEFAULTS.channel,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The address of one representation (`/media/{id}`, plus `?v=` for a derived one) — the media strip's. @experimental */
|
|
54
|
+
export function albumSrc(assetId, variant) {
|
|
55
|
+
return variant ? `/media/${assetId}?v=${variant}` : `/media/${assetId}`;
|
|
56
|
+
}
|
|
57
|
+
const text = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
58
|
+
const count = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : null;
|
|
59
|
+
/** A `date` column carries the day only; a time of day needs a timestamp. */
|
|
60
|
+
const DAY_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
61
|
+
/**
|
|
62
|
+
* The clock beside a line's name, as the line draws it (`SessionMessage`):
|
|
63
|
+
* `createdAt` unless it is a day-only date, then `updatedAt`.
|
|
64
|
+
*/
|
|
65
|
+
function lineTime(row, locale) {
|
|
66
|
+
const created = row.createdAt;
|
|
67
|
+
const stamp = typeof created === 'string' && DAY_ONLY.test(created)
|
|
68
|
+
? (row.updatedAt ?? created)
|
|
69
|
+
: (created ?? row.updatedAt);
|
|
70
|
+
if (!stamp)
|
|
71
|
+
return '';
|
|
72
|
+
const at = stamp instanceof Date ? stamp : new Date(stamp);
|
|
73
|
+
if (Number.isNaN(at.getTime()))
|
|
74
|
+
return '';
|
|
75
|
+
try {
|
|
76
|
+
return at.toLocaleTimeString(locale || [], { hour: 'numeric', minute: '2-digit' });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return at.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** A row's pictures, the shown revision of each step, in the strip's order. */
|
|
83
|
+
function imagesOf(row) {
|
|
84
|
+
const parts = Array.isArray(row.parts) ? row.parts : [];
|
|
85
|
+
if (!parts.length)
|
|
86
|
+
return [];
|
|
87
|
+
const active = row.activeRevisions ?? {};
|
|
88
|
+
return parts
|
|
89
|
+
.filter((p) => p?.type === 'core:image' &&
|
|
90
|
+
p.revision === (active[String(p.step)] ?? 0) &&
|
|
91
|
+
count(p.data?.assetId) !== null)
|
|
92
|
+
.sort((a, b) => a.step - b.step || a.ordinal - b.ordinal);
|
|
93
|
+
}
|
|
94
|
+
/** The row's channel slug: `main` when unset, a lane's slug for `slug:n`. */
|
|
95
|
+
const slugOf = (channel) => parseChannel(channel).slug;
|
|
96
|
+
/**
|
|
97
|
+
* The album: every picture on `rows` (the log, in its order) the settings
|
|
98
|
+
* let through, **newest line first**, a line's own pictures in the strip's
|
|
99
|
+
* order. `channel`, set, keeps one channel's lines — its every lane — as a
|
|
100
|
+
* Messages copy's `channel` claims one; empty keeps every channel. `source`
|
|
101
|
+
* keeps the attached or the generated alone.
|
|
102
|
+
* @experimental
|
|
103
|
+
*/
|
|
104
|
+
export function albumItems(rows, settings, options = {}) {
|
|
105
|
+
if (!rows?.length)
|
|
106
|
+
return [];
|
|
107
|
+
const t = options.t ?? ((s) => s);
|
|
108
|
+
const claim = settings.channel ? slugOf(settings.channel) : null;
|
|
109
|
+
const out = [];
|
|
110
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
111
|
+
const row = rows[i];
|
|
112
|
+
if (!row || typeof row !== 'object' || row.isHidden)
|
|
113
|
+
continue;
|
|
114
|
+
if (claim !== null && slugOf(row.channel) !== claim)
|
|
115
|
+
continue;
|
|
116
|
+
const origin = row.role === 'user' ? 'attached' : 'generated';
|
|
117
|
+
if (settings.source !== 'all' && settings.source !== origin)
|
|
118
|
+
continue;
|
|
119
|
+
const images = imagesOf(row);
|
|
120
|
+
if (!images.length)
|
|
121
|
+
continue;
|
|
122
|
+
const speaker = text(row.speakerLabel) ?? '';
|
|
123
|
+
const time = lineTime(row, options.locale);
|
|
124
|
+
const caption = [speaker, time].filter(Boolean).join(' · ');
|
|
125
|
+
for (const p of images) {
|
|
126
|
+
const d = (p.data ?? {});
|
|
127
|
+
out.push({
|
|
128
|
+
partId: p.id,
|
|
129
|
+
messageId: row.id,
|
|
130
|
+
assetId: d.assetId,
|
|
131
|
+
label: text(d.alt) ?? text(d.filename) ?? text(d.name) ?? t('Image'),
|
|
132
|
+
origin,
|
|
133
|
+
speaker,
|
|
134
|
+
time,
|
|
135
|
+
caption,
|
|
136
|
+
width: count(d.width),
|
|
137
|
+
height: count(d.height),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The `view-image` request for opening picture `index` of `items` (the
|
|
145
|
+
* album as drawn, in display order, less any whose file is gone): the
|
|
146
|
+
* picture itself, full size, and every other as the lightbox's pages,
|
|
147
|
+
* captioned by their names as the media strip captions them.
|
|
148
|
+
* @experimental
|
|
149
|
+
*/
|
|
150
|
+
export function albumViewImageParams(items, index) {
|
|
151
|
+
const srcs = items.map((i) => albumSrc(i.assetId));
|
|
152
|
+
return {
|
|
153
|
+
src: srcs[index],
|
|
154
|
+
gallery: { srcs, index, captions: items.map((i) => i.label) },
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** What the album says when it has nothing to draw, by `source`. @experimental */
|
|
158
|
+
export const ALBUM_EMPTY = Object.freeze({
|
|
159
|
+
all: 'Nothing has been attached or generated in this session yet.',
|
|
160
|
+
attached: 'Nothing has been attached in this session yet.',
|
|
161
|
+
generated: 'Nothing has been generated in this session yet.',
|
|
162
|
+
});
|
|
163
|
+
/** A tile's name for a reader: *Open attached image cat.png, Wren · 9:41 PM, 2 of 7*. @experimental */
|
|
164
|
+
export function albumOpenLabel(item, at, total, t = (s) => s) {
|
|
165
|
+
const head = item.origin === 'attached' ? t('Open attached image') : t('Open generated image');
|
|
166
|
+
const parts = [`${head} ${item.label}`];
|
|
167
|
+
if (item.caption)
|
|
168
|
+
parts.push(item.caption);
|
|
169
|
+
if (total > 1)
|
|
170
|
+
parts.push(`${at + 1} of ${total}`);
|
|
171
|
+
return parts.join(', ');
|
|
172
|
+
}
|
|
173
|
+
/** The origin glyph's words, for its `title`. @experimental */
|
|
174
|
+
export const ALBUM_ORIGIN_NAMES = Object.freeze({
|
|
175
|
+
attached: 'Attached',
|
|
176
|
+
generated: 'Generated',
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@serene-pub/core-catalog/annex` — the plain-TypeScript half of core's
|
|
3
|
+
* Annex widget (PLAN-core-widgets W9): its settings, what it knows of one
|
|
4
|
+
* declared annex field, and the one view it draws — one annex key, by its
|
|
5
|
+
* label, in the shape it was declared in. The widget's Svelte source lives
|
|
6
|
+
* in `components/shared/annex/` and ships built (`dist/components/annex.js`);
|
|
7
|
+
* a host imports only this half, which carries no Svelte runtime.
|
|
8
|
+
*
|
|
9
|
+
* **The key** is `<owner>.<key>`, the way a template reads it
|
|
10
|
+
* (`annex.<owner>.<key>`): `core.retake-quietly`, a plugin's
|
|
11
|
+
* `acme.dice.last-roll`. A field's key is a kebab token with no dot
|
|
12
|
+
* (`ANNEX_FIELD_KEY`), so the last dot splits, whatever the owner's slug.
|
|
13
|
+
*
|
|
14
|
+
* **What it draws** is the viewer's own view of the annex (`annex.v1`) — the
|
|
15
|
+
* values whose `see` audience holds for them, never the annex itself. Text
|
|
16
|
+
* is prose; a number, a switch or a choice is one label/value row; a list is
|
|
17
|
+
* chips; an object is a row per member. The declared shape decides when the
|
|
18
|
+
* widget is handed one; otherwise the stored value's own form does.
|
|
19
|
+
*
|
|
20
|
+
* **What it knows of the field** is what the host lists (`actions.v1`): a
|
|
21
|
+
* field a person may set is one action at the `widget` venue
|
|
22
|
+
* (`<owner>:annex#<key>`), named by the field's label and judged for the
|
|
23
|
+
* viewer (`canAct`) — so the label and *may I edit* are the host's, never
|
|
24
|
+
* worked out here. A field nobody may set reaches no listing, and is titled
|
|
25
|
+
* by its key. ⚠ Neither the declared shape nor the `see` verdict reaches a
|
|
26
|
+
* widget today; `AnnexWidgetField` takes both, for a host that hands them.
|
|
27
|
+
*
|
|
28
|
+
* **Edit** is the Session data list's: a text field the viewer may set,
|
|
29
|
+
* saved by pressing its ready-made action with `{ value }` — the same door,
|
|
30
|
+
* the same write.
|
|
31
|
+
*
|
|
32
|
+
* 🚧 Provisional with the widget.
|
|
33
|
+
*/
|
|
34
|
+
import { type ActionsV1, type AnnexV1, type FieldDecl, type I18n, type ViewerV1 } from '@serene-pub/sdk';
|
|
35
|
+
/** A translation: English source in, the viewer's words out. @experimental */
|
|
36
|
+
export type AnnexWidgetT = (source: string) => string;
|
|
37
|
+
/** The widget's settings, complete — the declared defaults wherever an instance has none. @experimental */
|
|
38
|
+
export interface AnnexWidgetSettings {
|
|
39
|
+
/** The annex key it draws, `<owner>.<key>`; `''` until one is picked. */
|
|
40
|
+
key: string;
|
|
41
|
+
/** Draw the field's label above its value. */
|
|
42
|
+
showLabel: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** @experimental */
|
|
45
|
+
export declare const ANNEX_WIDGET_DEFAULTS: AnnexWidgetSettings;
|
|
46
|
+
/** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
|
|
47
|
+
export declare function readAnnexWidgetSettings(raw: Record<string, unknown> | undefined): AnnexWidgetSettings;
|
|
48
|
+
/**
|
|
49
|
+
* `<owner>.<key>` taken apart at its last dot — null for anything that is
|
|
50
|
+
* not one (no dot, an empty owner, a key that is not a kebab token).
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseAnnexWidgetKey(raw: string | undefined): {
|
|
54
|
+
owner: string;
|
|
55
|
+
key: string;
|
|
56
|
+
} | null;
|
|
57
|
+
/**
|
|
58
|
+
* What the widget knows of one declared annex field. Each fact is optional
|
|
59
|
+
* because each has its own source, and the widget draws what it is given:
|
|
60
|
+
* the label and `canAct` come from the host's listing
|
|
61
|
+
* ({@link annexWidgetFieldsFrom}); `shape` and `canSee` from a host that
|
|
62
|
+
* hands the declaration (none does yet).
|
|
63
|
+
* @experimental
|
|
64
|
+
*/
|
|
65
|
+
export interface AnnexWidgetField {
|
|
66
|
+
owner: string;
|
|
67
|
+
key: string;
|
|
68
|
+
label?: I18n;
|
|
69
|
+
/** The declared shape — what the value is drawn as. Absent: the value's own form. */
|
|
70
|
+
shape?: FieldDecl;
|
|
71
|
+
/** The host's verdict on the field's `act` audience for this viewer. */
|
|
72
|
+
canAct?: boolean;
|
|
73
|
+
/** The host's verdict on the field's `see` audience for this viewer. */
|
|
74
|
+
canSee?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The annex fields the host lists for this viewer: each settable field it may
|
|
78
|
+
* set is one action at the `widget` venue whose spec slug is `<owner>:annex`,
|
|
79
|
+
* its key the field's, its name the field's label. Disabled for this session
|
|
80
|
+
* (`enabled: false`) or not the viewer's to press (`canAct: false`), it is
|
|
81
|
+
* known but not settable.
|
|
82
|
+
* @experimental
|
|
83
|
+
*/
|
|
84
|
+
export declare function annexWidgetFieldsFrom(actions: ActionsV1 | undefined): AnnexWidgetField[];
|
|
85
|
+
/** One label/value row. @experimental */
|
|
86
|
+
export interface AnnexWidgetRow {
|
|
87
|
+
/** The member's key — the row's key; the field's own key for a one-row value. */
|
|
88
|
+
key: string;
|
|
89
|
+
label: string;
|
|
90
|
+
text: string;
|
|
91
|
+
}
|
|
92
|
+
/** How the value is drawn. @experimental */
|
|
93
|
+
export type AnnexWidgetDrawn = {
|
|
94
|
+
as: 'prose';
|
|
95
|
+
text: string;
|
|
96
|
+
} | {
|
|
97
|
+
as: 'rows';
|
|
98
|
+
rows: AnnexWidgetRow[];
|
|
99
|
+
} | {
|
|
100
|
+
as: 'chips';
|
|
101
|
+
chips: string[];
|
|
102
|
+
};
|
|
103
|
+
/** The three things the widget says instead of a value. @experimental */
|
|
104
|
+
export type AnnexWidgetEmptyState = 'pick' | 'unwritten' | 'hidden';
|
|
105
|
+
/** Each empty state's line, English source. @experimental */
|
|
106
|
+
export declare const ANNEX_WIDGET_EMPTY: Readonly<Record<AnnexWidgetEmptyState, string>>;
|
|
107
|
+
/** The widget's one view. @experimental */
|
|
108
|
+
export type AnnexWidgetView = {
|
|
109
|
+
state: AnnexWidgetEmptyState;
|
|
110
|
+
/** The field's label, its key without one; *Annex* with no key picked. */
|
|
111
|
+
title: string;
|
|
112
|
+
empty: string;
|
|
113
|
+
/** `<owner>:annex#<key>` — what a Save presses. Null with no key picked. */
|
|
114
|
+
identity: string | null;
|
|
115
|
+
/** May the viewer write the first value here (the Session data list's Edit). */
|
|
116
|
+
canEdit: boolean;
|
|
117
|
+
/** The editor's starting text. */
|
|
118
|
+
draft: string;
|
|
119
|
+
} | {
|
|
120
|
+
state: 'value';
|
|
121
|
+
title: string;
|
|
122
|
+
/** The declared shape's type, else the value's own form (`text`, `integer`, `list`, …). */
|
|
123
|
+
shape: string;
|
|
124
|
+
drawn: AnnexWidgetDrawn;
|
|
125
|
+
value: unknown;
|
|
126
|
+
identity: string;
|
|
127
|
+
canEdit: boolean;
|
|
128
|
+
draft: string;
|
|
129
|
+
};
|
|
130
|
+
/** What `annexWidgetView` reads. @experimental */
|
|
131
|
+
export interface AnnexWidgetInputs {
|
|
132
|
+
/** `annex.v1` — the viewer's view of the annex. */
|
|
133
|
+
annex: AnnexV1 | undefined;
|
|
134
|
+
/** What the widget knows of the declared fields ({@link annexWidgetFieldsFrom}). */
|
|
135
|
+
fields: readonly AnnexWidgetField[];
|
|
136
|
+
/** The `key` setting, `<owner>.<key>`. */
|
|
137
|
+
key: string;
|
|
138
|
+
viewer: ViewerV1 | undefined;
|
|
139
|
+
/** `locale.v1`, for a label's and a member's own words. */
|
|
140
|
+
locale?: string;
|
|
141
|
+
t?: AnnexWidgetT;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Draw one annex key: an empty state, each one line and never silent, or the
|
|
145
|
+
* value in its shape, with the Session data list's Edit where the viewer may
|
|
146
|
+
* set it.
|
|
147
|
+
*
|
|
148
|
+
* - no key, or not `<owner>.<key>` → *Pick a key in settings*, titled *Annex*;
|
|
149
|
+
* - in the viewer's view → the value;
|
|
150
|
+
* - not in it, and the host says the viewer may not see it → *You can't
|
|
151
|
+
* see this*;
|
|
152
|
+
* - otherwise → *Nothing written yet*. ⚠ A key the viewer may not see is
|
|
153
|
+
* absent from their view exactly as an unwritten one is, so without the
|
|
154
|
+
* host's `see` verdict the two read alike.
|
|
155
|
+
*
|
|
156
|
+
* **Edit** needs all three: the host lists the field as the viewer's to set
|
|
157
|
+
* (`canAct`), the viewer holds no guest seat, and the field is text — by its
|
|
158
|
+
* declared shape, else by the stored value's form (the Session data list's
|
|
159
|
+
* rule, `annexEditsAsText`).
|
|
160
|
+
* @experimental
|
|
161
|
+
*/
|
|
162
|
+
export declare function annexWidgetView(inputs: AnnexWidgetInputs): AnnexWidgetView;
|
|
163
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@serene-pub/core-catalog/annex` — the plain-TypeScript half of core's
|
|
3
|
+
* Annex widget (PLAN-core-widgets W9): its settings, what it knows of one
|
|
4
|
+
* declared annex field, and the one view it draws — one annex key, by its
|
|
5
|
+
* label, in the shape it was declared in. The widget's Svelte source lives
|
|
6
|
+
* in `components/shared/annex/` and ships built (`dist/components/annex.js`);
|
|
7
|
+
* a host imports only this half, which carries no Svelte runtime.
|
|
8
|
+
*
|
|
9
|
+
* **The key** is `<owner>.<key>`, the way a template reads it
|
|
10
|
+
* (`annex.<owner>.<key>`): `core.retake-quietly`, a plugin's
|
|
11
|
+
* `acme.dice.last-roll`. A field's key is a kebab token with no dot
|
|
12
|
+
* (`ANNEX_FIELD_KEY`), so the last dot splits, whatever the owner's slug.
|
|
13
|
+
*
|
|
14
|
+
* **What it draws** is the viewer's own view of the annex (`annex.v1`) — the
|
|
15
|
+
* values whose `see` audience holds for them, never the annex itself. Text
|
|
16
|
+
* is prose; a number, a switch or a choice is one label/value row; a list is
|
|
17
|
+
* chips; an object is a row per member. The declared shape decides when the
|
|
18
|
+
* widget is handed one; otherwise the stored value's own form does.
|
|
19
|
+
*
|
|
20
|
+
* **What it knows of the field** is what the host lists (`actions.v1`): a
|
|
21
|
+
* field a person may set is one action at the `widget` venue
|
|
22
|
+
* (`<owner>:annex#<key>`), named by the field's label and judged for the
|
|
23
|
+
* viewer (`canAct`) — so the label and *may I edit* are the host's, never
|
|
24
|
+
* worked out here. A field nobody may set reaches no listing, and is titled
|
|
25
|
+
* by its key. ⚠ Neither the declared shape nor the `see` verdict reaches a
|
|
26
|
+
* widget today; `AnnexWidgetField` takes both, for a host that hands them.
|
|
27
|
+
*
|
|
28
|
+
* **Edit** is the Session data list's: a text field the viewer may set,
|
|
29
|
+
* saved by pressing its ready-made action with `{ value }` — the same door,
|
|
30
|
+
* the same write.
|
|
31
|
+
*
|
|
32
|
+
* 🚧 Provisional with the widget.
|
|
33
|
+
*/
|
|
34
|
+
import { ANNEX_FIELD_KEY, ANNEX_FIELD_SLUG_SUFFIX, annexFieldAction, i18nText, } from '@serene-pub/sdk';
|
|
35
|
+
/** @experimental */
|
|
36
|
+
export const ANNEX_WIDGET_DEFAULTS = Object.freeze({
|
|
37
|
+
key: '',
|
|
38
|
+
showLabel: false,
|
|
39
|
+
});
|
|
40
|
+
/** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
|
|
41
|
+
export function readAnnexWidgetSettings(raw) {
|
|
42
|
+
const v = raw ?? {};
|
|
43
|
+
return {
|
|
44
|
+
key: typeof v.key === 'string' ? v.key.trim() : ANNEX_WIDGET_DEFAULTS.key,
|
|
45
|
+
showLabel: typeof v.showLabel === 'boolean' ? v.showLabel : ANNEX_WIDGET_DEFAULTS.showLabel,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `<owner>.<key>` taken apart at its last dot — null for anything that is
|
|
50
|
+
* not one (no dot, an empty owner, a key that is not a kebab token).
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
53
|
+
export function parseAnnexWidgetKey(raw) {
|
|
54
|
+
const s = (raw ?? '').trim();
|
|
55
|
+
const at = s.lastIndexOf('.');
|
|
56
|
+
if (at <= 0)
|
|
57
|
+
return null;
|
|
58
|
+
const owner = s.slice(0, at);
|
|
59
|
+
const key = s.slice(at + 1);
|
|
60
|
+
if (!ANNEX_FIELD_KEY.test(key) || owner.includes('#') || /\s/.test(owner))
|
|
61
|
+
return null;
|
|
62
|
+
return { owner, key };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The annex fields the host lists for this viewer: each settable field it may
|
|
66
|
+
* set is one action at the `widget` venue whose spec slug is `<owner>:annex`,
|
|
67
|
+
* its key the field's, its name the field's label. Disabled for this session
|
|
68
|
+
* (`enabled: false`) or not the viewer's to press (`canAct: false`), it is
|
|
69
|
+
* known but not settable.
|
|
70
|
+
* @experimental
|
|
71
|
+
*/
|
|
72
|
+
export function annexWidgetFieldsFrom(actions) {
|
|
73
|
+
const out = [];
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
const venue = actions?.widget;
|
|
76
|
+
for (const a of [...(venue?.primary ?? []), ...(venue?.overflow ?? [])]) {
|
|
77
|
+
const slug = a.specSlug ?? '';
|
|
78
|
+
if (!slug.endsWith(ANNEX_FIELD_SLUG_SUFFIX) ||
|
|
79
|
+
slug.length <= ANNEX_FIELD_SLUG_SUFFIX.length)
|
|
80
|
+
continue;
|
|
81
|
+
const owner = slug.slice(0, -ANNEX_FIELD_SLUG_SUFFIX.length);
|
|
82
|
+
const id = `${owner}.${a.key}`;
|
|
83
|
+
if (seen.has(id))
|
|
84
|
+
continue;
|
|
85
|
+
seen.add(id);
|
|
86
|
+
out.push({
|
|
87
|
+
owner,
|
|
88
|
+
key: a.key,
|
|
89
|
+
...(a.name ? { label: a.name } : {}),
|
|
90
|
+
canAct: !!a.canAct && a.enabled !== false,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
/** Each empty state's line, English source. @experimental */
|
|
96
|
+
export const ANNEX_WIDGET_EMPTY = Object.freeze({
|
|
97
|
+
pick: 'Pick a key in settings',
|
|
98
|
+
unwritten: 'Nothing written yet',
|
|
99
|
+
hidden: "You can't see this",
|
|
100
|
+
});
|
|
101
|
+
const humanise = (s) => s
|
|
102
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
103
|
+
.replace(/[_-]+/g, ' ')
|
|
104
|
+
.replace(/^./, (c) => c.toUpperCase());
|
|
105
|
+
/** The value's own form, when no declaration says: what it would be declared as. @internal */
|
|
106
|
+
function typeOfValue(value) {
|
|
107
|
+
if (typeof value === 'string')
|
|
108
|
+
return 'text';
|
|
109
|
+
if (typeof value === 'number')
|
|
110
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
111
|
+
if (typeof value === 'boolean')
|
|
112
|
+
return 'boolean';
|
|
113
|
+
if (Array.isArray(value))
|
|
114
|
+
return 'list';
|
|
115
|
+
if (value && typeof value === 'object')
|
|
116
|
+
return 'object';
|
|
117
|
+
return 'text';
|
|
118
|
+
}
|
|
119
|
+
/** Nothing written: absent, null, blank text, an empty list or object. @internal */
|
|
120
|
+
function isBlank(value) {
|
|
121
|
+
if (value === undefined || value === null)
|
|
122
|
+
return true;
|
|
123
|
+
if (typeof value === 'string')
|
|
124
|
+
return !value.trim();
|
|
125
|
+
if (Array.isArray(value))
|
|
126
|
+
return value.length === 0;
|
|
127
|
+
if (typeof value === 'object')
|
|
128
|
+
return Object.keys(value).length === 0;
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
/** One scalar in the viewer's words, by its declaration where there is one. @internal */
|
|
132
|
+
function textOf(value, shape, locale, t) {
|
|
133
|
+
if (value === undefined || value === null)
|
|
134
|
+
return '—';
|
|
135
|
+
if (shape?.type === 'enum' && typeof value === 'string') {
|
|
136
|
+
const member = shape.members?.find((m) => m.key === value);
|
|
137
|
+
return i18nText(member?.label, locale) ?? humanise(value);
|
|
138
|
+
}
|
|
139
|
+
if (typeof value === 'boolean')
|
|
140
|
+
return value ? t('Yes') : t('No');
|
|
141
|
+
if (typeof value === 'number') {
|
|
142
|
+
try {
|
|
143
|
+
return new Intl.NumberFormat(locale).format(value);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return String(value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (typeof value === 'string')
|
|
150
|
+
return value;
|
|
151
|
+
if (Array.isArray(value))
|
|
152
|
+
return value.map((v) => textOf(v, shape?.item, locale, t)).join(', ');
|
|
153
|
+
try {
|
|
154
|
+
return JSON.stringify(value);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return String(value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** The value drawn by its shape. @internal */
|
|
161
|
+
function drawnOf(value, type, shape, label, key, locale, t) {
|
|
162
|
+
switch (type) {
|
|
163
|
+
case 'text':
|
|
164
|
+
case 'string':
|
|
165
|
+
return {
|
|
166
|
+
as: 'prose',
|
|
167
|
+
text: typeof value === 'string' ? value : textOf(value, undefined, locale, t),
|
|
168
|
+
};
|
|
169
|
+
case 'list':
|
|
170
|
+
case 'string[]':
|
|
171
|
+
if (Array.isArray(value))
|
|
172
|
+
return {
|
|
173
|
+
as: 'chips',
|
|
174
|
+
chips: value.map((v) => textOf(v, type === 'list' ? shape?.item : undefined, locale, t)),
|
|
175
|
+
};
|
|
176
|
+
break;
|
|
177
|
+
case 'object':
|
|
178
|
+
case 'share':
|
|
179
|
+
case 'perMember':
|
|
180
|
+
case 'strengths': {
|
|
181
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
182
|
+
break;
|
|
183
|
+
const v = value;
|
|
184
|
+
// Declared members in their declared order, then whatever else is stored.
|
|
185
|
+
const declared = type === 'object'
|
|
186
|
+
? Object.entries(shape?.fields ?? {}).map(([k, d]) => ({
|
|
187
|
+
key: k,
|
|
188
|
+
label: d.label,
|
|
189
|
+
shape: d,
|
|
190
|
+
}))
|
|
191
|
+
: (shape?.members ?? []).map((m) => ({ key: m.key, label: m.label }));
|
|
192
|
+
const keys = [
|
|
193
|
+
...declared.map((d) => d.key),
|
|
194
|
+
...Object.keys(v).filter((k) => !declared.some((d) => d.key === k)),
|
|
195
|
+
];
|
|
196
|
+
return {
|
|
197
|
+
as: 'rows',
|
|
198
|
+
rows: keys
|
|
199
|
+
.filter((k) => v[k] !== undefined)
|
|
200
|
+
.map((k) => {
|
|
201
|
+
const d = declared.find((x) => x.key === k);
|
|
202
|
+
return {
|
|
203
|
+
key: k,
|
|
204
|
+
label: i18nText(d?.label, locale) ?? humanise(k),
|
|
205
|
+
text: textOf(v[k], d?.shape, locale, t),
|
|
206
|
+
};
|
|
207
|
+
}),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (type === 'text' || type === 'string')
|
|
212
|
+
return { as: 'prose', text: textOf(value, shape, locale, t) };
|
|
213
|
+
return { as: 'rows', rows: [{ key, label, text: textOf(value, shape, locale, t) }] };
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Draw one annex key: an empty state, each one line and never silent, or the
|
|
217
|
+
* value in its shape, with the Session data list's Edit where the viewer may
|
|
218
|
+
* set it.
|
|
219
|
+
*
|
|
220
|
+
* - no key, or not `<owner>.<key>` → *Pick a key in settings*, titled *Annex*;
|
|
221
|
+
* - in the viewer's view → the value;
|
|
222
|
+
* - not in it, and the host says the viewer may not see it → *You can't
|
|
223
|
+
* see this*;
|
|
224
|
+
* - otherwise → *Nothing written yet*. ⚠ A key the viewer may not see is
|
|
225
|
+
* absent from their view exactly as an unwritten one is, so without the
|
|
226
|
+
* host's `see` verdict the two read alike.
|
|
227
|
+
*
|
|
228
|
+
* **Edit** needs all three: the host lists the field as the viewer's to set
|
|
229
|
+
* (`canAct`), the viewer holds no guest seat, and the field is text — by its
|
|
230
|
+
* declared shape, else by the stored value's form (the Session data list's
|
|
231
|
+
* rule, `annexEditsAsText`).
|
|
232
|
+
* @experimental
|
|
233
|
+
*/
|
|
234
|
+
export function annexWidgetView(inputs) {
|
|
235
|
+
const t = inputs.t ?? ((s) => s);
|
|
236
|
+
const locale = inputs.locale ?? 'en';
|
|
237
|
+
const parsed = parseAnnexWidgetKey(inputs.key);
|
|
238
|
+
if (!parsed)
|
|
239
|
+
return {
|
|
240
|
+
state: 'pick',
|
|
241
|
+
title: t('Annex'),
|
|
242
|
+
empty: t(ANNEX_WIDGET_EMPTY.pick),
|
|
243
|
+
identity: null,
|
|
244
|
+
canEdit: false,
|
|
245
|
+
draft: '',
|
|
246
|
+
};
|
|
247
|
+
const { owner, key } = parsed;
|
|
248
|
+
const field = inputs.fields.find((f) => f.owner === owner && f.key === key);
|
|
249
|
+
const title = i18nText(field?.label, locale) || key;
|
|
250
|
+
const identity = annexFieldAction(owner, key);
|
|
251
|
+
const doc = inputs.annex?.[owner];
|
|
252
|
+
const value = doc && typeof doc === 'object' ? doc[key] : undefined;
|
|
253
|
+
const blank = isBlank(value);
|
|
254
|
+
const type = field?.shape?.type ?? (blank ? undefined : typeOfValue(value));
|
|
255
|
+
const canEdit = !!field?.canAct && !inputs.viewer?.isGuest && (type === 'text' || type === 'string');
|
|
256
|
+
const draft = typeof value === 'string' ? value : '';
|
|
257
|
+
if (blank) {
|
|
258
|
+
const state = field?.canSee === false && value === undefined ? 'hidden' : 'unwritten';
|
|
259
|
+
return { state, title, empty: t(ANNEX_WIDGET_EMPTY[state]), identity, canEdit, draft };
|
|
260
|
+
}
|
|
261
|
+
const shapeType = type ?? 'text';
|
|
262
|
+
return {
|
|
263
|
+
state: 'value',
|
|
264
|
+
title,
|
|
265
|
+
shape: shapeType,
|
|
266
|
+
drawn: drawnOf(value, shapeType, field?.shape, title, key, locale, t),
|
|
267
|
+
value,
|
|
268
|
+
identity,
|
|
269
|
+
canEdit,
|
|
270
|
+
draft,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=index.js.map
|