@serene-pub/core-catalog 0.6.0-pr-7 → 0.6.0-pr-9
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 +1 -1
- package/components/genres/story/authors-note/AuthorsNote.svelte +2 -1
- package/components/genres/story/authors-note/AuthorsNoteWidget.svelte +177 -58
- package/components/shared/WidgetBoundary.svelte +37 -0
- package/components/shared/actions/Actions.svelte +2 -1
- package/components/shared/actions/ActionsWidget.svelte +31 -38
- package/components/shared/album/Album.svelte +2 -1
- package/components/shared/album/AlbumWidget.svelte +1 -7
- package/components/shared/annex/Annex.svelte +2 -1
- package/components/shared/annex/AnnexWidget.svelte +1 -1
- package/components/shared/attendance/Attendance.svelte +2 -1
- package/components/shared/attendance/AttendanceWidget.svelte +5 -8
- package/components/shared/backdrop/Backdrop.svelte +2 -1
- package/components/shared/backdrop/BackdropWidget.svelte +28 -22
- package/components/shared/chronicle/Chronicle.svelte +2 -1
- package/components/shared/chronicle/ChronicleWidget.svelte +211 -99
- package/components/shared/composer/Composer.svelte +25 -0
- package/components/shared/composer/ComposerWidget.svelte +146 -0
- package/components/shared/composer/composer.ts +10 -0
- package/components/shared/composer/settings.ts +59 -0
- package/components/shared/composer/target.ts +79 -0
- package/components/shared/dialogue-box/DialogueBoxMount.svelte +25 -0
- package/components/shared/dialogue-box/DialogueBoxWidget.svelte +207 -0
- package/components/shared/dialogue-box/dialogue-box.ts +10 -0
- package/components/shared/dialogue-box/settings.ts +25 -0
- package/components/shared/lore-entries/LoreEntries.svelte +2 -1
- package/components/shared/lore-entries/LoreEntriesWidget.svelte +44 -41
- package/components/shared/messages/MessageBlocksView.svelte +1 -1
- package/components/shared/messages/MessageControls.svelte +23 -5
- package/components/shared/messages/Messages.svelte +2 -1
- package/components/shared/messages/MessagesWidget.svelte +82 -191
- package/components/shared/messages/NextCharacterBlock.svelte +35 -20
- package/components/shared/messages/SceneDivider.svelte +40 -14
- package/components/shared/messages/SessionComposer.svelte +178 -123
- package/components/shared/messages/SessionContainer.svelte +89 -38
- package/components/shared/messages/SessionMessage.svelte +157 -54
- package/components/shared/messages/SpokenLine.svelte +57 -16
- package/components/shared/messages/StateProposalList.svelte +30 -20
- package/components/shared/messages/TurnLine.svelte +258 -66
- package/components/shared/messages/conversation.svelte.ts +83 -5
- package/components/shared/messages/readingPace.ts +101 -0
- package/components/shared/messages/rowFacts.ts +44 -0
- package/components/shared/messages/sceneMarks.ts +54 -0
- package/components/shared/messages/spokenLine.ts +63 -14
- package/components/shared/places/Places.svelte +2 -1
- package/components/shared/places/PlacesWidget.svelte +42 -33
- package/components/shared/routine-log/RoutineLog.svelte +2 -1
- package/components/shared/routine-log/RoutineLogWidget.svelte +0 -4
- package/components/shared/routine-log/routineLog.ts +5 -21
- package/components/shared/scene-portraits/ScenePortraits.svelte +2 -1
- package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +54 -32
- package/components/shared/session-runs/SessionRuns.svelte +26 -0
- package/components/shared/session-runs/SessionRunsWidget.svelte +270 -0
- package/components/shared/session-runs/session-runs.ts +11 -0
- package/components/shared/state/PieceCard.svelte +36 -25
- package/components/shared/state/SlotControl.svelte +18 -5
- package/components/shared/stats/Stats.svelte +2 -1
- package/components/shared/stats/StatsWidget.svelte +104 -72
- package/components/shared/turn-line/TurnLineMount.svelte +25 -0
- package/components/shared/turn-line/TurnLineWidget.svelte +25 -0
- package/components/shared/turn-line/settings.ts +31 -0
- package/components/shared/turn-line/turn-line.ts +10 -0
- package/components/shared/turn-order/TurnOrder.svelte +2 -1
- package/components/shared/turn-order/TurnOrderWidget.svelte +1 -6
- package/dist/components/actions.js +71 -88
- package/dist/components/actions.source.json +1 -1
- package/dist/components/album.js +39 -44
- package/dist/components/album.source.json +1 -1
- package/dist/components/annex.js +17 -8
- package/dist/components/annex.source.json +1 -1
- package/dist/components/attendance.js +39 -48
- package/dist/components/attendance.source.json +1 -1
- package/dist/components/authors-note.js +329 -162
- package/dist/components/authors-note.source.json +1 -1
- package/dist/components/backdrop.js +52 -55
- package/dist/components/backdrop.source.json +1 -1
- package/dist/components/chronicle.js +798 -559
- package/dist/components/chronicle.source.json +1 -1
- package/dist/components/composer.js +1639 -0
- package/dist/components/composer.source.json +1 -0
- package/dist/components/core-ui.json +1 -1
- package/dist/components/dialogue-box.js +373 -0
- package/dist/components/dialogue-box.source.json +1 -0
- package/dist/components/lore-entries.js +134 -122
- package/dist/components/lore-entries.source.json +1 -1
- package/dist/components/messages.js +1517 -8930
- package/dist/components/messages.source.json +1 -1
- package/dist/components/places.js +267 -244
- package/dist/components/places.source.json +1 -1
- package/dist/components/routine-log.js +35 -51
- package/dist/components/routine-log.source.json +1 -1
- package/dist/components/scene-portraits.js +118 -59
- package/dist/components/scene-portraits.source.json +1 -1
- package/dist/components/session-runs.js +488 -0
- package/dist/components/session-runs.source.json +1 -0
- package/dist/components/{shared-7VDIXYAL.js → shared-47J4TNSF.js} +1 -1
- package/dist/components/{shared-W3XS5FEL.js → shared-5E4RQYRX.js} +3 -2
- package/dist/components/{shared-YDS7HYL6.js → shared-EFMMT76D.js} +57 -4
- package/dist/components/{shared-BIWKZFUU.js → shared-FOVKPMSK.js} +3 -3
- package/dist/components/{shared-JPG5DQO7.js → shared-HEAKNNZB.js} +92 -17
- package/dist/components/shared-JXP6SHKF.js +159 -0
- package/dist/components/{shared-XBDUENRA.js → shared-JXYPKSTQ.js} +1 -1
- package/dist/components/shared-KJIOSSE3.js +257 -0
- package/dist/components/{shared-WV3QTKZT.js → shared-KLURQFWI.js} +13 -9
- package/dist/components/shared-MHCNUDUT.js +1680 -0
- package/dist/components/{shared-QXF5CJVN.js → shared-NICRJ4Z2.js} +1 -1
- package/dist/components/{shared-BBF64YGL.js → shared-W2BBJCNE.js} +22 -16
- package/dist/components/shared-YYYXFDZU.js +4354 -0
- package/dist/components/stats.js +828 -678
- package/dist/components/stats.source.json +1 -1
- package/dist/components/turn-line.js +856 -0
- package/dist/components/turn-line.source.json +1 -0
- package/dist/components/turn-order.js +62 -67
- package/dist/components/turn-order.source.json +1 -1
- package/dist/factories/answerForm.d.ts +6 -0
- package/dist/factories/answerForm.js +104 -96
- package/dist/factories/turnOrder.d.ts +98 -105
- package/dist/factories/turnOrder.js +120 -136
- package/dist/functions/pieces.js +1 -0
- package/dist/functions/time.js +2 -0
- package/dist/genres/chat/create.js +2 -0
- package/dist/genres/chat/memory.js +64 -43
- package/dist/genres/chat/respond.d.ts +7 -6
- package/dist/genres/chat/respond.js +13 -4
- package/dist/genres/chat/turnOrder.d.ts +2 -2
- package/dist/genres/chat/turnOrder.js +28 -12
- package/dist/genres/defaults.d.ts +28 -6
- package/dist/genres/defaults.js +84 -26
- package/dist/genres/dungeon-crawler/calls.d.ts +3 -1
- package/dist/genres/dungeon-crawler/calls.js +5 -0
- package/dist/genres/dungeon-crawler/create.d.ts +9 -6
- package/dist/genres/dungeon-crawler/create.js +18 -8
- package/dist/genres/dungeon-crawler/death.d.ts +13 -6
- package/dist/genres/dungeon-crawler/death.js +26 -12
- package/dist/genres/dungeon-crawler/index.d.ts +1 -0
- package/dist/genres/dungeon-crawler/index.js +1 -0
- package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
- package/dist/genres/dungeon-crawler/journal.js +1 -1
- package/dist/genres/dungeon-crawler/lore.d.ts +13 -12
- package/dist/genres/dungeon-crawler/lore.js +16 -25
- package/dist/genres/dungeon-crawler/names.d.ts +10 -3
- package/dist/genres/dungeon-crawler/names.js +10 -3
- package/dist/genres/dungeon-crawler/preamble.d.ts +5 -4
- package/dist/genres/dungeon-crawler/preamble.js +75 -33
- package/dist/genres/dungeon-crawler/respond.js +4 -2
- package/dist/genres/dungeon-crawler/rest.d.ts +8 -7
- package/dist/genres/dungeon-crawler/rest.js +39 -15
- package/dist/genres/dungeon-crawler/reveal.js +2 -2
- package/dist/genres/dungeon-crawler/roundScript.d.ts +2 -1
- package/dist/genres/dungeon-crawler/roundScript.js +23 -5
- package/dist/genres/dungeon-crawler/scripts.js +4 -5
- package/dist/genres/dungeon-crawler/shape.d.ts +16 -0
- package/dist/genres/dungeon-crawler/shape.js +5 -1
- package/dist/genres/dungeon-crawler/sheet.d.ts +20 -20
- package/dist/genres/dungeon-crawler/story.d.ts +27 -16
- package/dist/genres/dungeon-crawler/story.js +175 -46
- package/dist/genres/dungeon-crawler/storyScripts.d.ts +2 -2
- package/dist/genres/dungeon-crawler/storyScripts.js +109 -14
- package/dist/genres/dungeon-crawler/summarizeScene.d.ts +13 -0
- package/dist/genres/dungeon-crawler/summarizeScene.js +21 -0
- package/dist/genres/dungeon-crawler/turnOrder.d.ts +8 -9
- package/dist/genres/dungeon-crawler/turnOrder.js +33 -23
- package/dist/genres/guide/create.js +2 -0
- package/dist/genres/guide/turnOrder.d.ts +3 -3
- package/dist/genres/guide/turnOrder.js +29 -13
- package/dist/genres/lair/answerForm.js +4 -1
- package/dist/genres/lair/buildRoom.js +4 -3
- package/dist/genres/lair/castellanAction.js +160 -154
- package/dist/genres/lair/create.js +2 -0
- package/dist/genres/lair/fileCurrentRoom.js +13 -10
- package/dist/genres/lair/fileRoom.js +4 -3
- package/dist/genres/lair/keeper.js +6 -2
- package/dist/genres/lair/names.d.ts +2 -0
- package/dist/genres/lair/names.js +2 -0
- package/dist/genres/lair/reply.js +16 -6
- package/dist/genres/lair/roomAnswer.js +4 -3
- package/dist/genres/lair/scratchpad.js +9 -7
- package/dist/genres/lair/scripts.js +8 -6
- package/dist/genres/lair/turnOrder.d.ts +3 -2
- package/dist/genres/lair/turnOrder.js +45 -16
- package/dist/genres/story/ask.d.ts +4 -0
- package/dist/genres/story/ask.js +4 -0
- package/dist/genres/story/create.js +15 -0
- package/dist/genres/story/index.d.ts +1 -1
- package/dist/genres/story/index.js +1 -1
- package/dist/genres/story/narrate.js +8 -0
- package/dist/genres/story/narrateCharacter.js +8 -0
- package/dist/genres/story/reckon.d.ts +5 -19
- package/dist/genres/story/reckon.js +53 -40
- package/dist/genres/story/reckoning.js +3 -0
- package/dist/genres/story/respond.js +17 -28
- package/dist/genres/story/sweep.d.ts +1 -1
- package/dist/genres/story/sweep.js +1 -1
- package/dist/genres/story/turnOrder.d.ts +21 -3
- package/dist/genres/story/turnOrder.js +87 -21
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -9
- package/dist/loadouts.d.ts +1 -0
- package/dist/loadouts.js +17 -1
- package/dist/primers/ninth-mile.d.ts +3 -4
- package/dist/registry/entries.d.ts +2 -0
- package/dist/registry/entries.js +18 -5
- package/dist/registry/genres.d.ts +146 -40
- package/dist/registry/genres.js +373 -101
- package/dist/registry/hostState.d.ts +1 -2
- package/dist/registry/hostState.js +2 -4
- package/dist/registry/layouts.d.ts +141 -111
- package/dist/registry/layouts.js +302 -141
- package/dist/registry/slots.d.ts +4 -3
- package/dist/registry/slots.js +4 -3
- package/dist/registry/widgets.d.ts +12 -2
- package/dist/registry/widgets.js +259 -106
- package/dist/rulesets/vis-itineris/ruleset.js +8 -5
- package/dist/rulesets/wherewithal/ruleset.js +2 -1
- package/dist/seed/presets.js +15 -9
- package/dist/seed/prompts.js +24 -5
- package/dist/seed/scripts.js +3 -0
- package/dist/shared/annexField.js +23 -3
- package/dist/shared/illustrateScene.d.ts +1 -0
- package/dist/shared/illustrateScene.js +29 -1
- package/dist/shared/lore.d.ts +13 -0
- package/dist/shared/lore.js +37 -1
- package/dist/shared/portrait.js +13 -4
- package/dist/shared/reckoning.d.ts +8 -2
- package/dist/shared/reckoning.js +47 -30
- package/dist/shared/roundTick.d.ts +20 -0
- package/dist/shared/roundTick.js +76 -0
- package/dist/shared/sceneBoundaries.d.ts +7 -0
- package/dist/shared/sceneBoundaries.js +62 -0
- package/dist/shared/sceneSummaries.d.ts +7 -0
- package/dist/shared/sceneSummaries.js +49 -0
- package/dist/shared/speakMessage.d.ts +9 -2
- package/dist/shared/speakMessage.js +32 -9
- package/dist/shared/speechFields.js +4 -0
- package/dist/shared/summarize/character.d.ts +1 -1
- package/dist/shared/summarize/history.d.ts +1 -1
- package/dist/shared/summarize/scene.d.ts +1 -1
- package/dist/shared/summarize/summarizeScene.js +1 -0
- package/dist/shared/summarize/summarizeSpec.d.ts +1 -1
- package/dist/shared/summarize/world.d.ts +1 -1
- package/dist/shared/ui/attendance/index.d.ts +3 -2
- package/dist/shared/ui/attendance/index.js +3 -7
- package/dist/shared/ui/chronicle/index.d.ts +24 -2
- package/dist/shared/ui/chronicle/index.js +58 -29
- package/dist/shared/ui/conversation/formAnswer.d.ts +16 -2
- package/dist/shared/ui/conversation/formAnswer.js +23 -9
- package/dist/shared/ui/conversation/index.d.ts +2 -0
- package/dist/shared/ui/conversation/index.js +4 -0
- package/dist/shared/ui/conversation/itemValues.d.ts +16 -3
- package/dist/shared/ui/conversation/itemValues.js +15 -5
- package/dist/shared/ui/conversation/messageVerbState.d.ts +17 -2
- package/dist/shared/ui/conversation/messageVerbState.js +5 -4
- package/dist/shared/ui/conversation/readingPlace.d.ts +40 -0
- package/dist/shared/ui/conversation/readingPlace.js +119 -0
- package/dist/shared/ui/conversation/rewindStrip.d.ts +13 -4
- package/dist/shared/ui/conversation/rewindStrip.js +29 -7
- package/dist/shared/ui/conversation/runsInProgress.d.ts +30 -0
- package/dist/shared/ui/conversation/runsInProgress.js +47 -0
- package/dist/shared/ui/conversation/storyDays.d.ts +7 -1
- package/dist/shared/ui/conversation/storyDays.js +8 -0
- package/dist/shared/ui/conversation/tableChannel.d.ts +8 -11
- package/dist/shared/ui/conversation/tableChannel.js +8 -9
- package/dist/shared/ui/places/index.d.ts +3 -2
- package/dist/shared/ui/places/index.js +4 -5
- package/dist/shared/ui/routine-log/index.d.ts +3 -0
- package/dist/shared/ui/routine-log/index.js +22 -0
- package/dist/shared/ui/scene-portraits/portraits.d.ts +50 -16
- package/dist/shared/ui/scene-portraits/portraits.js +84 -21
- package/dist/shared/ui/session-runs/index.d.ts +90 -0
- package/dist/shared/ui/session-runs/index.js +143 -0
- package/dist/shared/ui/session-state/stateView.d.ts +18 -5
- package/dist/shared/ui/session-state/stateView.js +29 -8
- package/dist/shared/ui/turn-order/index.d.ts +0 -9
- package/dist/shared/ui/turn-order/index.js +1 -2
- package/package.json +12 -8
- /package/dist/components/{shared-4ME6NFDK.js → shared-LUIF6DW7.js} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The `composer` widget's component (owner R8 2026-11-05, PLAN-session-
|
|
4
|
+
* layout-simplify D7/D8): the field you write into, the persona you write
|
|
5
|
+
* as, the actions, the rewind note and the read-only banner — split from
|
|
6
|
+
* the log. It owns a conversation of its own that follows the Messages
|
|
7
|
+
* copy it writes for (`followTarget`): same dossier, and the lane that
|
|
8
|
+
* copy shows. Its settings come off the widget context; the Line width
|
|
9
|
+
* and presentation it is drawn with are the target's, off the dossier.
|
|
10
|
+
*/
|
|
11
|
+
import { rewindStripState, channelTabsOf } from "@serene-pub/core-catalog/conversation"
|
|
12
|
+
import { useWidgetContext } from "../context"
|
|
13
|
+
import SessionComposer from "../messages/SessionComposer.svelte"
|
|
14
|
+
import { createConversation, setConversation } from "../messages/conversation.svelte"
|
|
15
|
+
import { readComposerSettings } from "./settings"
|
|
16
|
+
import { composerTargetOf } from "./target"
|
|
17
|
+
|
|
18
|
+
const ctx = useWidgetContext()
|
|
19
|
+
const conversation = ctx ? setConversation(createConversation(ctx, { followTarget: true })) : null
|
|
20
|
+
|
|
21
|
+
const fields = $derived(composerTargetOf(conversation?.dossier))
|
|
22
|
+
const target = $derived(fields.target)
|
|
23
|
+
/**
|
|
24
|
+
* Where a line goes, named: the host's label, except the default channel
|
|
25
|
+
* (`main`, the story's own log) with no label declared, which reads *the
|
|
26
|
+
* story* rather than a title-cased slug.
|
|
27
|
+
*/
|
|
28
|
+
const writingTo = $derived.by(() => {
|
|
29
|
+
const w = fields.writingTo
|
|
30
|
+
if (!w) return null
|
|
31
|
+
// The default channel's slug (`DEFAULT_CHANNEL` in the SDK).
|
|
32
|
+
const slug = w.channel.split(":")[0]
|
|
33
|
+
return slug === "main" && !conversation?.dossier?.composer?.channelLabels?.[slug]
|
|
34
|
+
? { ...w, label: conversation!.t("the story") }
|
|
35
|
+
: w
|
|
36
|
+
})
|
|
37
|
+
/**
|
|
38
|
+
* Folio's rule, the target's: its presentation when the host says it, else
|
|
39
|
+
* what its channel IS (`channelRole`). No target: the primary log's.
|
|
40
|
+
*/
|
|
41
|
+
const folio = $derived(
|
|
42
|
+
!target
|
|
43
|
+
? false
|
|
44
|
+
: target.presentation
|
|
45
|
+
? target.presentation === "folio"
|
|
46
|
+
: !!conversation && conversation.channelRole(target.channel) === "folio"
|
|
47
|
+
)
|
|
48
|
+
const settings = $derived(
|
|
49
|
+
readComposerSettings(ctx?.current.settings.v1 as Record<string, unknown> | undefined, folio)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The composer this lane is written with: the copy's `composer`, or — on a
|
|
54
|
+
* tab other than the first — its `otherTabsComposer` when it says one (the
|
|
55
|
+
* Lair's Sanctum pill).
|
|
56
|
+
*/
|
|
57
|
+
const composerSkin = $derived.by(() => {
|
|
58
|
+
const tabs = channelTabsOf(conversation?.channels)
|
|
59
|
+
return tabs.length > 1 && conversation?.lane.current !== tabs[0] && settings.otherTabsComposer !== "same"
|
|
60
|
+
? settings.otherTabsComposer
|
|
61
|
+
: settings.composerSkin
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 🚧 **Back · Forward** (RF fix 5, owner ruling 2026-10-23): the note while
|
|
66
|
+
* the session is rewound, where the target shows the story (`main`), with
|
|
67
|
+
* Forward beside it for the owner. The host says how many turns are ahead
|
|
68
|
+
* and why a press would be refused (`dossier.rewind`); nothing presses
|
|
69
|
+
* while a reply is being written. The two presses themselves are the
|
|
70
|
+
* session header's, which reads the same state through `rewindStripState`.
|
|
71
|
+
*/
|
|
72
|
+
const generating = $derived(
|
|
73
|
+
((conversation?.ctx.messages.v1 ?? []) as Array<{ isGenerating?: boolean }>).some((m) => m.isGenerating)
|
|
74
|
+
)
|
|
75
|
+
const rewind = $derived(
|
|
76
|
+
rewindStripState({
|
|
77
|
+
rewind: conversation?.rewind.state,
|
|
78
|
+
isOwner: !!conversation?.dossier?.isOwner,
|
|
79
|
+
generating,
|
|
80
|
+
story: !target || target.channel === "main" || target.channel.startsWith("main:")
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<!-- The widget's parts (`composer.*`, STYLE-GUIDE §6.16): no look here; the
|
|
86
|
+
default widget stylesheet draws them. ⏳ Each also carries its old
|
|
87
|
+
`messages.*` name, so a style pack written for the old widget keeps
|
|
88
|
+
working. The root is the compose block itself and never fills the panel's
|
|
89
|
+
height: the host measures its content. -->
|
|
90
|
+
{#if conversation && !conversation.noLane}
|
|
91
|
+
{@const dossier = conversation.dossier}
|
|
92
|
+
<div
|
|
93
|
+
data-widget-part="composer.root messages.compose composer.compose"
|
|
94
|
+
data-composer-skin={composerSkin}
|
|
95
|
+
data-line-width={target?.lineWidth ?? "full"}
|
|
96
|
+
data-presentation={target?.presentation}
|
|
97
|
+
>
|
|
98
|
+
<div data-widget-part="messages.compose-area composer.compose-area">
|
|
99
|
+
{#if dossier?.readOnly}
|
|
100
|
+
<!-- Read-only (19 §6, ruled): the mode disappeared, the history
|
|
101
|
+
stays, nothing starts a new turn — and the server refuses
|
|
102
|
+
independently at every generation choke, so this banner is
|
|
103
|
+
honesty, not the lock. -->
|
|
104
|
+
<div data-widget-part="messages.read-only composer.read-only" role="status">
|
|
105
|
+
<sp-icon name="lock" size="20" data-widget-part="messages.read-only-icon composer.read-only-icon"></sp-icon>
|
|
106
|
+
<div data-widget-part="messages.read-only-text composer.read-only-text">
|
|
107
|
+
<p data-widget-part="messages.read-only-title composer.read-only-title">This session is read-only: its genre is not available (not installed, or switched off).</p>
|
|
108
|
+
<p>
|
|
109
|
+
Messages are safe to read; new turns resume when the genre is available again.
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
{:else}
|
|
114
|
+
{#if writingTo}
|
|
115
|
+
<!-- The target panel shows a tab that is not a Messages tab: say
|
|
116
|
+
where a line goes. -->
|
|
117
|
+
<p data-widget-part="composer.writing-to" role="status">
|
|
118
|
+
{conversation.t("Writing to {label}").replace("{label}", writingTo.label)}
|
|
119
|
+
</p>
|
|
120
|
+
{/if}
|
|
121
|
+
{#if rewind.replaceText}
|
|
122
|
+
<!-- 🚧 While rewound (RF fix 5): a new line replaces the turns
|
|
123
|
+
ahead — said before it is written, with Forward beside it
|
|
124
|
+
for the owner. -->
|
|
125
|
+
<p data-widget-part="messages.rewind-replace composer.rewind-replace" role="status">
|
|
126
|
+
<sp-icon name="undo-2" size="14" data-widget-part="messages.rewind-replace-icon composer.rewind-replace-icon"></sp-icon>
|
|
127
|
+
<span data-widget-part="messages.rewind-replace-text composer.rewind-replace-text">{rewind.replaceText}</span>
|
|
128
|
+
{#if conversation.dossier?.isOwner}
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
data-widget-part="messages.rewind-replace-forward composer.rewind-replace-forward"
|
|
132
|
+
title={rewind.forward.reason ? `Forward — ${rewind.forward.reason}` : "Forward — bring the next turn back"}
|
|
133
|
+
aria-disabled={rewind.forward.disabled}
|
|
134
|
+
onclick={(e) => (rewind.forward.disabled ? e.preventDefault() : conversation.rewind.forward())}
|
|
135
|
+
>
|
|
136
|
+
<span>Forward</span>
|
|
137
|
+
<sp-icon name="redo-2" size="14"></sp-icon>
|
|
138
|
+
</button>
|
|
139
|
+
{/if}
|
|
140
|
+
</p>
|
|
141
|
+
{/if}
|
|
142
|
+
<SessionComposer {composerSkin} showActions={settings.showActions} showSend={settings.showSend} />
|
|
143
|
+
{/if}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's `composer` component (owner R8 2026-11-05): the field you write
|
|
3
|
+
* into, split from the log. `npm run build` compiles it with the CLI's
|
|
4
|
+
* component bundler to `dist/components/composer.js`, the module the app
|
|
5
|
+
* serves at `/core-ui/composer`.
|
|
6
|
+
*/
|
|
7
|
+
import { svelteComponent } from '@serene-pub/component-client/svelte'
|
|
8
|
+
import Composer from './Composer.svelte'
|
|
9
|
+
|
|
10
|
+
export default svelteComponent(Composer)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `composer` widget's settings (owner R8 2026-11-05: they were the
|
|
3
|
+
* `messages` widget's, moved verbatim), read the way the `messages` reader
|
|
4
|
+
* read them: every value present, the declared default wherever the instance
|
|
5
|
+
* has no deviation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** How the composer's field is drawn. */
|
|
9
|
+
export type ComposerSkin = "classic" | "minimal" | "writer" | "quill"
|
|
10
|
+
|
|
11
|
+
export interface ComposerSettings {
|
|
12
|
+
composerSkin: ComposerSkin
|
|
13
|
+
/**
|
|
14
|
+
* 🚧 The composer while a tab other than the first is shown
|
|
15
|
+
* (`otherTabsComposer`, lair fix 2), or `same` — `composerSkin`.
|
|
16
|
+
*/
|
|
17
|
+
otherTabsComposer: ComposerSkin | "same"
|
|
18
|
+
showActions: boolean
|
|
19
|
+
/** 🚧 Draw Send and Stop; at the compact width they always show. */
|
|
20
|
+
showSend: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The declared defaults (`CORE_WIDGETS`, the `composer` entry). */
|
|
24
|
+
export const COMPOSER_DEFAULTS: ComposerSettings = {
|
|
25
|
+
composerSkin: "classic",
|
|
26
|
+
otherTabsComposer: "same",
|
|
27
|
+
showActions: true,
|
|
28
|
+
showSend: true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function pickEnum<T extends string>(raw: unknown, of: readonly T[], fallback: T): T {
|
|
32
|
+
return typeof raw === "string" && (of as readonly string[]).includes(raw) ? (raw as T) : fallback
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Read one settings payload. `folio` is whether the target Messages copy
|
|
37
|
+
* reads as Folio: then a copy whose `composer` is the declared default
|
|
38
|
+
* (`classic`) writes with the page line (`quill`). Settings arrive complete,
|
|
39
|
+
* so `classic` cannot say "chosen"; a Folio copy that wants the card back
|
|
40
|
+
* cannot have it, which is the price of a manuscript's page line.
|
|
41
|
+
*/
|
|
42
|
+
export function readComposerSettings(
|
|
43
|
+
raw: Record<string, unknown> | undefined,
|
|
44
|
+
folio: boolean
|
|
45
|
+
): ComposerSettings {
|
|
46
|
+
const v = raw ?? {}
|
|
47
|
+
const d = COMPOSER_DEFAULTS
|
|
48
|
+
const skin = pickEnum<ComposerSkin>(v.composer, ["classic", "minimal", "writer", "quill"], d.composerSkin)
|
|
49
|
+
return {
|
|
50
|
+
composerSkin: folio && skin === d.composerSkin ? "quill" : skin,
|
|
51
|
+
otherTabsComposer: pickEnum(
|
|
52
|
+
v.otherTabsComposer,
|
|
53
|
+
["same", "classic", "minimal", "writer", "quill"],
|
|
54
|
+
d.otherTabsComposer
|
|
55
|
+
),
|
|
56
|
+
showActions: typeof v.showActions === "boolean" ? v.showActions : d.showActions,
|
|
57
|
+
showSend: typeof v.showSend === "boolean" ? v.showSend : d.showSend
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Messages copy a Composer or Turn line belongs to (owner R8 2026-11-05:
|
|
3
|
+
* the composer and the turn line are widgets beside the log, not parts of it).
|
|
4
|
+
*
|
|
5
|
+
* The host gives each the same `session:full` dossier as its TARGET Messages
|
|
6
|
+
* copy — its `composer.channels` narrowed the same way — and says which
|
|
7
|
+
* channel that copy last showed (`show-channel`) under `dossier.composer`.
|
|
8
|
+
* Those two fields are not yet in the SDK's `ConversationComposerV1`, so they
|
|
9
|
+
* are read here, structurally, in ONE place; nothing else touches the shape.
|
|
10
|
+
*/
|
|
11
|
+
import type { SessionDossierV1 } from "@serene-pub/sdk/component"
|
|
12
|
+
|
|
13
|
+
export type TargetLineWidth = "column" | "full" | "comfortable"
|
|
14
|
+
export type TargetPresentation = "rows" | "folio"
|
|
15
|
+
|
|
16
|
+
/** The Messages copy this Composer / Turn line writes beside. */
|
|
17
|
+
export interface ComposerTarget {
|
|
18
|
+
/** The target Messages instance id (`messages`, `messages#sanctum`). */
|
|
19
|
+
instance: string
|
|
20
|
+
/** The channel that copy shows, canonical. */
|
|
21
|
+
channel: string
|
|
22
|
+
/** That channel's label in the viewer's language. */
|
|
23
|
+
label: string
|
|
24
|
+
/** The target's Line width, when the host says it. */
|
|
25
|
+
lineWidth?: TargetLineWidth
|
|
26
|
+
/** The target's effective presentation, when the host says it. */
|
|
27
|
+
presentation?: TargetPresentation
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ComposerTargetFields {
|
|
31
|
+
/** Absent: no target resolved — the first writable channel is the lane. */
|
|
32
|
+
target: ComposerTarget | null
|
|
33
|
+
/** Set when the target panel shows a tab that is not a Messages tab. */
|
|
34
|
+
writingTo: { channel: string; label: string } | null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const str = (v: unknown): v is string => typeof v === "string" && v !== ""
|
|
38
|
+
|
|
39
|
+
/** Read `dossier.composer.target` and `.writingTo`; both null when the host sends none. */
|
|
40
|
+
export function composerTargetOf(dossier: unknown): ComposerTargetFields {
|
|
41
|
+
const composer = (dossier as { composer?: Record<string, unknown> } | null | undefined)?.composer
|
|
42
|
+
const t = composer?.target as Record<string, unknown> | null | undefined
|
|
43
|
+
const w = composer?.writingTo as Record<string, unknown> | null | undefined
|
|
44
|
+
const target: ComposerTarget | null =
|
|
45
|
+
t && str(t.instance) && str(t.channel)
|
|
46
|
+
? {
|
|
47
|
+
instance: t.instance,
|
|
48
|
+
channel: t.channel,
|
|
49
|
+
label: typeof t.label === "string" ? t.label : t.channel,
|
|
50
|
+
...(t.lineWidth === "column" || t.lineWidth === "full" || t.lineWidth === "comfortable"
|
|
51
|
+
? { lineWidth: t.lineWidth }
|
|
52
|
+
: {}),
|
|
53
|
+
...(t.presentation === "rows" || t.presentation === "folio"
|
|
54
|
+
? { presentation: t.presentation }
|
|
55
|
+
: {})
|
|
56
|
+
}
|
|
57
|
+
: null
|
|
58
|
+
const writingTo =
|
|
59
|
+
w && str(w.channel) ? { channel: w.channel, label: typeof w.label === "string" && w.label ? w.label : w.channel } : null
|
|
60
|
+
return { target, writingTo }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 🚧 Whether the Composer beside this Turn line draws Send (`dossier.composer.sendShown`,
|
|
65
|
+
* the host's answer from the layout). `undefined` when the host says nothing: read as shown.
|
|
66
|
+
*/
|
|
67
|
+
export function composerSendShownOf(dossier: SessionDossierV1 | null | undefined): boolean | undefined {
|
|
68
|
+
return dossier?.composer?.sendShown
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 🚧 Whether Send is shown: the one rule the Composer and the Turn line both read.
|
|
73
|
+
* At the compact (phone) width Enter writes a new line and only the button sends,
|
|
74
|
+
* so Send shows whatever the setting says; otherwise the setting, absent read as
|
|
75
|
+
* shown. @experimental
|
|
76
|
+
*/
|
|
77
|
+
export function composerSendShown(setting: boolean | undefined, tier: string | undefined): boolean {
|
|
78
|
+
return tier === "compact" || setting !== false
|
|
79
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Core's dialogue-box widget as a remote component: the component context,
|
|
4
|
+
* as the native widget context, around `DialogueBoxWidget`.
|
|
5
|
+
*/
|
|
6
|
+
import { setContext, untrack } from "svelte"
|
|
7
|
+
import type { ComponentContext } from "@serene-pub/sdk/component"
|
|
8
|
+
import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/conversation"
|
|
9
|
+
import DialogueBoxWidget from "./DialogueBoxWidget.svelte"
|
|
10
|
+
import WidgetBoundary from "../WidgetBoundary.svelte"
|
|
11
|
+
import { widgetRefFromComponent } from "../widgetRef.svelte"
|
|
12
|
+
|
|
13
|
+
let { ctx }: { ctx: ComponentContext } = $props()
|
|
14
|
+
|
|
15
|
+
// The context is the mount's, handed once: its sections move, it does not.
|
|
16
|
+
setContext(
|
|
17
|
+
WIDGET_CONTEXT_KEY,
|
|
18
|
+
widgetRefFromComponent(
|
|
19
|
+
untrack(() => ctx),
|
|
20
|
+
{ id: "dialogue-box", instanceId: "dialogue-box", title: "Dialogue box" }
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<WidgetBoundary {ctx}><DialogueBoxWidget /></WidgetBoundary>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The `dialogue-box` widget's component (PLAN-visual-novel-layout §1): the
|
|
4
|
+
* one line being read — the newest, until the reader holds on an older one —
|
|
5
|
+
* with a bar under it that says what waits and moves on (**Next line**, or by
|
|
6
|
+
* itself when `autoRead` is on). It owns the reading place and the pace of
|
|
7
|
+
* reading, both client-only and never stored. It does not own the log
|
|
8
|
+
* (Messages), writing (the Composer), who speaks next, or speech (the speak
|
|
9
|
+
* step and the spoken line); it draws the line with the log's own row and
|
|
10
|
+
* only reads what the voice is doing. No look here: parts only.
|
|
11
|
+
*/
|
|
12
|
+
import { untrack } from "svelte"
|
|
13
|
+
import type { MessageV1 } from "@serene-pub/sdk/component"
|
|
14
|
+
import {
|
|
15
|
+
nextLinePlace,
|
|
16
|
+
queuedSummary,
|
|
17
|
+
queuedText,
|
|
18
|
+
settlePlace
|
|
19
|
+
} from "@serene-pub/core-catalog/conversation"
|
|
20
|
+
import { useWidgetContext } from "../context"
|
|
21
|
+
import SessionMessage from "../messages/SessionMessage.svelte"
|
|
22
|
+
import { createConversation, setConversation } from "../messages/conversation.svelte"
|
|
23
|
+
import { laneOf } from "../messages/sceneMarks"
|
|
24
|
+
import { mediaStripItems } from "../messages/mediaStrip"
|
|
25
|
+
import {
|
|
26
|
+
isSpeaking,
|
|
27
|
+
readAloudOf,
|
|
28
|
+
spokenAudioItems,
|
|
29
|
+
spokenOf,
|
|
30
|
+
spokenPendingOf,
|
|
31
|
+
spokenPlaybackOf
|
|
32
|
+
} from "../messages/spokenLine"
|
|
33
|
+
import {
|
|
34
|
+
heardAfter,
|
|
35
|
+
lineSpeechPhase,
|
|
36
|
+
readOnState,
|
|
37
|
+
readingTimeMs,
|
|
38
|
+
type HeardPlayback,
|
|
39
|
+
type LineSpeechPhase
|
|
40
|
+
} from "../messages/readingPace"
|
|
41
|
+
import { readDialogueBoxSettings } from "./settings"
|
|
42
|
+
|
|
43
|
+
const ctx = useWidgetContext()
|
|
44
|
+
const conversation = ctx ? setConversation(createConversation(ctx, { noSelection: true })) : null
|
|
45
|
+
const settings = $derived(readDialogueBoxSettings(ctx?.current.settings.v1 as Record<string, unknown> | undefined))
|
|
46
|
+
|
|
47
|
+
// The main channel's rows only (plan §1.2).
|
|
48
|
+
const rows = $derived(conversation ? conversation.rows.filter((m) => laneOf(m.channel) === "main") : [])
|
|
49
|
+
const ownId = $derived(conversation?.dossier?.ownNewestMessageId ?? null)
|
|
50
|
+
|
|
51
|
+
// The reading place: client-only, per mount, never stored.
|
|
52
|
+
let place = $state<number | null>(null)
|
|
53
|
+
$effect(() => {
|
|
54
|
+
const r = rows
|
|
55
|
+
const own = ownId
|
|
56
|
+
const was = untrack(() => place)
|
|
57
|
+
const next = settlePlace(r, was, own)
|
|
58
|
+
if (next !== was) place = next
|
|
59
|
+
})
|
|
60
|
+
function nextLine() {
|
|
61
|
+
place = nextLinePlace(rows, place, ownId)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const shown = $derived(rows.find((r) => r.id === place) ?? null)
|
|
65
|
+
const shownIndex = $derived(shown ? rows.indexOf(shown) : -1)
|
|
66
|
+
const isNewest = $derived(shown !== null && shownIndex === rows.length - 1)
|
|
67
|
+
|
|
68
|
+
// The host's `show-line`: the place when it is behind the newest row, else null.
|
|
69
|
+
const shownLine = $derived(place !== null && rows.length > 0 && place !== rows[rows.length - 1]!.id ? place : null)
|
|
70
|
+
let sent: number | null | undefined = undefined
|
|
71
|
+
$effect(() => {
|
|
72
|
+
const v = shownLine
|
|
73
|
+
if (v === sent) return
|
|
74
|
+
sent = v
|
|
75
|
+
void conversation?.request("show-line", { messageId: v })
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// The queue: what waits after the place.
|
|
79
|
+
const summary = $derived(
|
|
80
|
+
queuedSummary(rows, place, (r) => conversation?.line(r.id).speaker.name || (r as MessageV1).speakerLabel || null)
|
|
81
|
+
)
|
|
82
|
+
const queued = $derived(summary.lines > 0 || summary.writing !== null)
|
|
83
|
+
const queuedLabel = $derived(queuedText(summary))
|
|
84
|
+
|
|
85
|
+
// Speech facts, from the log's own helpers.
|
|
86
|
+
const dossier = $derived(conversation?.dossier ?? null)
|
|
87
|
+
const spoken = $derived(shown ? spokenOf(shown.metadata) : null)
|
|
88
|
+
const hasAudio = $derived(
|
|
89
|
+
!!shown && !!spoken && spokenAudioItems(mediaStripItems(shown.parts, shown.activeRevisions ?? { "0": 0 }), spoken).length > 0
|
|
90
|
+
)
|
|
91
|
+
const pendingRaw = $derived(shown ? spokenPendingOf(shown.metadata) : null)
|
|
92
|
+
|
|
93
|
+
// Per-line facts, reset whenever the place moves to another line.
|
|
94
|
+
let track = $state({
|
|
95
|
+
id: null as number | null,
|
|
96
|
+
shownAt: 0,
|
|
97
|
+
timerFrom: 0,
|
|
98
|
+
settledAt: null as number | null,
|
|
99
|
+
audioSeenAt: null as number | null,
|
|
100
|
+
heard: "none" as HeardPlayback,
|
|
101
|
+
seenLive: null as string | null
|
|
102
|
+
})
|
|
103
|
+
$effect(() => {
|
|
104
|
+
const p = place
|
|
105
|
+
const s = shown
|
|
106
|
+
const audio = hasAudio
|
|
107
|
+
const raw = pendingRaw
|
|
108
|
+
const live = conversation?.dossier?.liveRunIds
|
|
109
|
+
untrack(() => {
|
|
110
|
+
if (track.id !== p) {
|
|
111
|
+
const t = Date.now()
|
|
112
|
+
track = { id: p, shownAt: t, timerFrom: t, settledAt: null, audioSeenAt: null, heard: "none", seenLive: null }
|
|
113
|
+
}
|
|
114
|
+
if (s && !s.isGenerating && track.settledAt === null) track.settledAt = Date.now()
|
|
115
|
+
if (audio && track.audioSeenAt === null) track.audioSeenAt = Date.now()
|
|
116
|
+
if (raw && live?.includes(raw.runId)) track.seenLive = raw.runId
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
const pending = $derived(isSpeaking(pendingRaw, dossier?.liveRunIds, track.seenLive) ? pendingRaw : null)
|
|
120
|
+
|
|
121
|
+
// The line's player speaks to the page in bubbling events (play, pause, ended).
|
|
122
|
+
function hear(e: Event) {
|
|
123
|
+
track.heard = heardAfter(track.heard, e.type as "play" | "pause" | "ended")
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Read on by itself.
|
|
127
|
+
let held = $state(false)
|
|
128
|
+
let now = $state(Date.now())
|
|
129
|
+
$effect(() => {
|
|
130
|
+
if (!settings.autoRead || !queued || held) return
|
|
131
|
+
now = Date.now()
|
|
132
|
+
const t = setInterval(() => (now = Date.now()), 200)
|
|
133
|
+
return () => clearInterval(t)
|
|
134
|
+
})
|
|
135
|
+
const phase = $derived(
|
|
136
|
+
lineSpeechPhase({
|
|
137
|
+
readAloud: readAloudOf(dossier),
|
|
138
|
+
playback: spokenPlaybackOf(dossier),
|
|
139
|
+
canSpeak: dossier?.speech?.canSpeak !== false,
|
|
140
|
+
pendingAt: pending?.at ?? null,
|
|
141
|
+
hasAudio,
|
|
142
|
+
audioSeenAt: track.audioSeenAt,
|
|
143
|
+
heard: track.heard,
|
|
144
|
+
settledAt: track.settledAt,
|
|
145
|
+
now
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
// Only once the per-line facts are this line's: a step is never judged on the last line's `ended`.
|
|
149
|
+
const readOn = $derived(
|
|
150
|
+
settings.autoRead && track.id === place
|
|
151
|
+
? readOnState({
|
|
152
|
+
phase,
|
|
153
|
+
queued,
|
|
154
|
+
held,
|
|
155
|
+
timerFrom: track.timerFrom,
|
|
156
|
+
settledAt: track.settledAt,
|
|
157
|
+
readingMs: readingTimeMs(shown?.content ?? "", settings.readingSpeed),
|
|
158
|
+
now
|
|
159
|
+
})
|
|
160
|
+
: { due: false, timer: null }
|
|
161
|
+
)
|
|
162
|
+
// A voice that was expected and never started: the reading timer starts now, so its bar always fills (owner R4).
|
|
163
|
+
let lastPhase: LineSpeechPhase = "none"
|
|
164
|
+
$effect(() => {
|
|
165
|
+
const ph = phase
|
|
166
|
+
untrack(() => {
|
|
167
|
+
if (ph === "blocked" && lastPhase !== "blocked" && lastPhase !== "none" && track.id === place) {
|
|
168
|
+
track.timerFrom = Date.now()
|
|
169
|
+
}
|
|
170
|
+
lastPhase = ph
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
$effect(() => {
|
|
174
|
+
if (readOn.due) untrack(() => nextLine())
|
|
175
|
+
})
|
|
176
|
+
function togglePause() {
|
|
177
|
+
if (held) track.timerFrom = Date.now()
|
|
178
|
+
held = !held
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// The slide-in hook: every line after the first this mount drew arrives.
|
|
182
|
+
let firstId: number | null = null
|
|
183
|
+
const arrive = $derived.by(() => {
|
|
184
|
+
if (!shown) return false
|
|
185
|
+
if (firstId === null) firstId = shown.id
|
|
186
|
+
return shown.id !== firstId
|
|
187
|
+
})
|
|
188
|
+
</script>
|
|
189
|
+
|
|
190
|
+
<!-- The widget's parts (`dialogue-box.*`, STYLE-GUIDE §6.16): no look here. -->
|
|
191
|
+
{#if conversation && !conversation.noLane && conversation.dossier && shown}
|
|
192
|
+
<div data-widget-part="dialogue-box.root">
|
|
193
|
+
{#key shown.id}
|
|
194
|
+
<div data-widget-part="dialogue-box.line" data-arrive={arrive ? "" : undefined} onplay={hear} onpause={hear} onended={hear}>
|
|
195
|
+
<SessionMessage msg={shown} index={shownIndex} isLastMessage={isNewest} place={{ n: shownIndex + 1, of: rows.length }} atReadingPlace />
|
|
196
|
+
</div>
|
|
197
|
+
{/key}
|
|
198
|
+
{#if queued}
|
|
199
|
+
<div data-widget-part="dialogue-box.bar">
|
|
200
|
+
{#if queuedLabel}<span data-widget-part="dialogue-box.queued" role="status">{queuedLabel}</span>{/if}
|
|
201
|
+
{#if readOn.timer}<sp-progress data-widget-part="dialogue-box.progress" value={readOn.timer.elapsed} max={readOn.timer.total} label="Time until the next line"></sp-progress>{/if}
|
|
202
|
+
{#if settings.autoRead}<button type="button" data-widget-part="dialogue-box.pause" aria-pressed={held} onclick={togglePause}>Pause</button>{/if}
|
|
203
|
+
<button type="button" data-widget-part="dialogue-box.next" onclick={nextLine}>Next line</button>
|
|
204
|
+
</div>
|
|
205
|
+
{/if}
|
|
206
|
+
</div>
|
|
207
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's `dialogue-box` component (PLAN-visual-novel-layout): the one line
|
|
3
|
+
* being read, with the reading bar under it. `npm run build` compiles it with
|
|
4
|
+
* the CLI's component bundler to `dist/components/dialogue-box.js`, the module
|
|
5
|
+
* the app serves at `/core-ui/dialogue-box`.
|
|
6
|
+
*/
|
|
7
|
+
import { svelteComponent } from '@serene-pub/component-client/svelte'
|
|
8
|
+
import DialogueBoxMount from './DialogueBoxMount.svelte'
|
|
9
|
+
|
|
10
|
+
export default svelteComponent(DialogueBoxMount)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `dialogue-box` widget's two settings (PLAN-visual-novel-layout §1.3):
|
|
3
|
+
* whether the box reads on by itself, and how fast it reads a line without a voice.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface DialogueBoxSettings {
|
|
7
|
+
autoRead: boolean
|
|
8
|
+
readingSpeed: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The declared defaults (`CORE_WIDGETS`, the `dialogue-box` entry). */
|
|
12
|
+
export const DIALOGUE_BOX_DEFAULTS: DialogueBoxSettings = { autoRead: false, readingSpeed: 220 }
|
|
13
|
+
|
|
14
|
+
export function readDialogueBoxSettings(
|
|
15
|
+
raw: Record<string, unknown> | undefined,
|
|
16
|
+
): DialogueBoxSettings {
|
|
17
|
+
const v = raw ?? {}
|
|
18
|
+
return {
|
|
19
|
+
autoRead: v.autoRead === true,
|
|
20
|
+
readingSpeed:
|
|
21
|
+
typeof v.readingSpeed === 'number' && Number.isFinite(v.readingSpeed)
|
|
22
|
+
? Math.min(600, Math.max(80, Math.round(v.readingSpeed)))
|
|
23
|
+
: DIALOGUE_BOX_DEFAULTS.readingSpeed,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import type { ComponentContext } from "@serene-pub/sdk/component"
|
|
13
13
|
import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
|
|
14
14
|
import LoreEntriesWidget from "./LoreEntriesWidget.svelte"
|
|
15
|
+
import WidgetBoundary from "../WidgetBoundary.svelte"
|
|
15
16
|
import { widgetRefFromComponent } from "../widgetRef.svelte"
|
|
16
17
|
|
|
17
18
|
let { ctx }: { ctx: ComponentContext } = $props()
|
|
@@ -33,4 +34,4 @@
|
|
|
33
34
|
)
|
|
34
35
|
</script>
|
|
35
36
|
|
|
36
|
-
<LoreEntriesWidget ready={settled}
|
|
37
|
+
<WidgetBoundary {ctx}><LoreEntriesWidget ready={settled} /></WidgetBoundary>
|