@serene-pub/core-catalog 0.6.0-pr-8 → 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/shared/chronicle/ChronicleWidget.svelte +127 -57
- package/components/shared/composer/ComposerWidget.svelte +17 -5
- package/components/shared/composer/settings.ts +6 -2
- package/components/shared/composer/target.ts +19 -0
- package/components/shared/dialogue-box/DialogueBoxWidget.svelte +2 -2
- package/components/shared/lore-entries/LoreEntriesWidget.svelte +39 -35
- package/components/shared/messages/MessageBlocksView.svelte +1 -1
- package/components/shared/messages/MessageControls.svelte +21 -4
- package/components/shared/messages/MessagesWidget.svelte +24 -8
- package/components/shared/messages/NextCharacterBlock.svelte +18 -3
- package/components/shared/messages/SceneDivider.svelte +22 -12
- package/components/shared/messages/SessionComposer.svelte +67 -22
- package/components/shared/messages/SessionContainer.svelte +87 -32
- package/components/shared/messages/SessionMessage.svelte +68 -29
- package/components/shared/messages/SpokenLine.svelte +45 -13
- package/components/shared/messages/TurnLine.svelte +233 -45
- package/components/shared/messages/conversation.svelte.ts +30 -2
- package/components/shared/messages/rowFacts.ts +44 -0
- package/components/shared/messages/spokenLine.ts +63 -14
- package/components/shared/places/PlacesWidget.svelte +32 -20
- package/components/shared/routine-log/routineLog.ts +5 -21
- package/components/shared/session-runs/SessionRunsWidget.svelte +16 -12
- package/dist/components/actions.js +5 -5
- package/dist/components/actions.source.json +1 -1
- package/dist/components/album.js +1 -1
- package/dist/components/album.source.json +1 -1
- package/dist/components/annex.js +1 -1
- package/dist/components/annex.source.json +1 -1
- package/dist/components/attendance.js +1 -1
- package/dist/components/attendance.source.json +1 -1
- package/dist/components/authors-note.js +1 -1
- package/dist/components/authors-note.source.json +1 -1
- package/dist/components/backdrop.js +3 -3
- package/dist/components/backdrop.source.json +1 -1
- package/dist/components/chronicle.js +641 -484
- package/dist/components/chronicle.source.json +1 -1
- package/dist/components/composer.js +188 -153
- package/dist/components/composer.source.json +1 -1
- package/dist/components/core-ui.json +1 -1
- package/dist/components/dialogue-box.js +11 -11
- package/dist/components/dialogue-box.source.json +1 -1
- package/dist/components/lore-entries.js +101 -92
- package/dist/components/lore-entries.source.json +1 -1
- package/dist/components/messages.js +351 -275
- package/dist/components/messages.source.json +1 -1
- package/dist/components/places.js +237 -202
- package/dist/components/places.source.json +1 -1
- package/dist/components/routine-log.js +6 -17
- package/dist/components/routine-log.source.json +1 -1
- package/dist/components/scene-portraits.js +4 -4
- package/dist/components/scene-portraits.source.json +1 -1
- package/dist/components/session-runs.js +118 -211
- package/dist/components/session-runs.source.json +1 -1
- package/dist/components/{shared-OVDOAXYZ.js → shared-47J4TNSF.js} +1 -1
- package/dist/components/{shared-ASZVJYPD.js → shared-EFMMT76D.js} +56 -3
- package/dist/components/{shared-N7FFW5TX.js → shared-FOVKPMSK.js} +3 -3
- package/dist/components/{shared-7SWDK5MC.js → shared-HEAKNNZB.js} +4 -0
- package/dist/components/shared-JXP6SHKF.js +159 -0
- package/dist/components/{shared-TNJZHTMT.js → shared-JXYPKSTQ.js} +1 -1
- package/dist/components/{shared-2FMI3LEE.js → shared-KJIOSSE3.js} +2 -2
- package/dist/components/{shared-RQYMTMHF.js → shared-KLURQFWI.js} +2 -2
- package/dist/components/{shared-BR2KXM25.js → shared-MHCNUDUT.js} +96 -12
- package/dist/components/{shared-6S23SGJB.js → shared-NICRJ4Z2.js} +1 -1
- package/dist/components/{shared-M7AYID43.js → shared-W2BBJCNE.js} +7 -7
- package/dist/components/{shared-XJD6Y2OU.js → shared-YYYXFDZU.js} +387 -248
- package/dist/components/stats.js +5 -5
- package/dist/components/stats.source.json +1 -1
- package/dist/components/turn-line.js +384 -112
- package/dist/components/turn-line.source.json +1 -1
- package/dist/components/turn-order.js +4 -4
- 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 +84 -107
- package/dist/factories/turnOrder.js +89 -131
- 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 +8 -2
- package/dist/genres/defaults.js +51 -27
- package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
- package/dist/genres/dungeon-crawler/journal.js +1 -1
- package/dist/genres/dungeon-crawler/rest.js +5 -3
- package/dist/genres/dungeon-crawler/story.d.ts +2 -1
- package/dist/genres/dungeon-crawler/story.js +7 -4
- package/dist/genres/dungeon-crawler/storyScripts.js +85 -9
- 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/fileCurrentRoom.js +13 -10
- package/dist/genres/lair/fileRoom.js +4 -3
- package/dist/genres/lair/keeper.js +2 -0
- 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/turnOrder.d.ts +3 -2
- package/dist/genres/lair/turnOrder.js +45 -16
- package/dist/genres/story/create.d.ts +1 -0
- package/dist/genres/story/create.js +1 -0
- package/dist/genres/story/reckon.js +43 -10
- package/dist/genres/story/turnOrder.d.ts +13 -3
- package/dist/genres/story/turnOrder.js +79 -22
- package/dist/index.js +8 -8
- package/dist/primers/ninth-mile.d.ts +3 -4
- package/dist/registry/entries.js +16 -5
- package/dist/registry/genres.d.ts +61 -54
- package/dist/registry/genres.js +123 -106
- package/dist/registry/widgets.js +12 -1
- package/dist/seed/presets.js +11 -7
- package/dist/seed/scripts.js +3 -0
- package/dist/shared/lore.d.ts +13 -0
- package/dist/shared/lore.js +37 -1
- package/dist/shared/reckoning.d.ts +7 -1
- package/dist/shared/reckoning.js +24 -17
- package/dist/shared/sceneBoundaries.js +7 -6
- package/dist/shared/speakMessage.d.ts +9 -2
- package/dist/shared/speakMessage.js +32 -9
- package/dist/shared/ui/chronicle/index.d.ts +7 -2
- package/dist/shared/ui/chronicle/index.js +21 -12
- package/dist/shared/ui/conversation/index.d.ts +1 -0
- package/dist/shared/ui/conversation/index.js +2 -0
- package/dist/shared/ui/conversation/messageVerbState.d.ts +5 -0
- package/dist/shared/ui/conversation/messageVerbState.js +3 -3
- package/dist/shared/ui/conversation/rewindStrip.d.ts +11 -4
- package/dist/shared/ui/conversation/rewindStrip.js +9 -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/tableChannel.d.ts +8 -11
- package/dist/shared/ui/conversation/tableChannel.js +8 -9
- 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/session-runs/index.d.ts +9 -1
- package/dist/shared/ui/session-runs/index.js +20 -14
- package/dist/shared/ui/turn-order/index.d.ts +0 -9
- package/dist/shared/ui/turn-order/index.js +1 -2
- package/package.json +8 -8
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
import { mediaSrc, mediaStripItems, viewImageParams } from "./mediaStrip"
|
|
16
16
|
import MessageStateLedger from "./MessageStateLedger.svelte"
|
|
17
17
|
import SpokenLine from "./SpokenLine.svelte"
|
|
18
|
-
import { isSpeaking, readAloudOf,
|
|
18
|
+
import { isSpeaking, readAloudOf, playlistOf, spokenAudioItems, spokenOf, spokenPendingOf, spokenPlaybackOf } from "./spokenLine"
|
|
19
19
|
import { useWidgetContext } from "../context"
|
|
20
20
|
import { isDiceLine, staleOf, storyDayText, storyTimeText } from "@serene-pub/core-catalog/conversation"
|
|
21
21
|
import { formatStoryTimeAs, storyTimePartsOf } from "@serene-pub/core-catalog/session-state"
|
|
22
22
|
import { messageStoryTime, type StoryTimeSpelling } from "./sceneMarks"
|
|
23
23
|
import { untrack } from "svelte"
|
|
24
|
+
import { composerSendShownOf } from "../composer/target"
|
|
24
25
|
import { useConversation } from "./conversation.svelte"
|
|
25
26
|
import type { MessageV1, WidgetAction } from "@serene-pub/sdk/component"
|
|
26
27
|
|
|
@@ -59,11 +60,19 @@
|
|
|
59
60
|
const conv = useConversation()
|
|
60
61
|
const line = $derived(conv.line(msg.id))
|
|
61
62
|
const allMessages = $derived(conv.ctx.messages.v1)
|
|
62
|
-
const hasGeneratingMessage = $derived(
|
|
63
|
+
const hasGeneratingMessage = $derived(conv.anyGenerating)
|
|
64
|
+
/**
|
|
65
|
+
* One Stop for a reply: the composer offers it for the newest row while
|
|
66
|
+
* it shows Send, so that row draws none of its own. An older row still
|
|
67
|
+
* generating keeps its pill; so does any row when Send is hidden, no
|
|
68
|
+
* composer follows this log, or the host has not said (a missing answer
|
|
69
|
+
* reads as not shown).
|
|
70
|
+
*/
|
|
71
|
+
const composerStops = $derived(isLastMessage && composerSendShownOf(conv.dossier) === true)
|
|
63
72
|
const extendRefusal = $derived(conv.dossier?.extendRefusal)
|
|
64
73
|
const isSummarizationMode = $derived(conv.select.active)
|
|
65
74
|
const isSelected = $derived(conv.select.ids.has(msg.id))
|
|
66
|
-
const scened = $derived(conv.
|
|
75
|
+
const scened = $derived(conv.isScened(msg.id))
|
|
67
76
|
|
|
68
77
|
/**
|
|
69
78
|
* The unified widget envelope (PLAN 25, ruled 2026-08-30). Present at the
|
|
@@ -122,7 +131,7 @@
|
|
|
122
131
|
conv.ctx.action(fn, m.id, payload, action, blockId)
|
|
123
132
|
}
|
|
124
133
|
|
|
125
|
-
const messageCount = $derived(
|
|
134
|
+
const messageCount = $derived(conv.messageCount)
|
|
126
135
|
|
|
127
136
|
/**
|
|
128
137
|
* The face beside this line (DESIGN-sprites §7). With the messages widget's
|
|
@@ -209,7 +218,9 @@
|
|
|
209
218
|
* `data-msg-dice-line` is what the widget stylesheet and a pack key the
|
|
210
219
|
* look off. ⚠ Not a table line, which is drawn in no voice.
|
|
211
220
|
*/
|
|
212
|
-
|
|
221
|
+
// `isDiceLine` only ever finds the row this line answers: hand it that one.
|
|
222
|
+
const diceAsked = $derived(conv.rowById(Number(msg.metadata?.answersForm?.messageId)))
|
|
223
|
+
const diceLine = $derived(!tableLine && isDiceLine(msg as never, (diceAsked ? [diceAsked] : []) as never))
|
|
213
224
|
/** Only the content cell is drawn: a folio's paragraph, or a table line. */
|
|
214
225
|
const contentOnly = $derived(folio || tableLine)
|
|
215
226
|
// Two independent classifications the style packs (sessionLayout skins) key
|
|
@@ -257,6 +268,9 @@
|
|
|
257
268
|
* open to the item rule alone.
|
|
258
269
|
*/
|
|
259
270
|
const swipeWhen = $derived.by(() => {
|
|
271
|
+
// 🚧 A run that holds re-runs greys the arrow with its sentence, as the verb is.
|
|
272
|
+
const waitFor = conv.dossier?.rerunWaitsFor
|
|
273
|
+
if (waitFor) return [true, waitFor] as const
|
|
260
274
|
const listed = [
|
|
261
275
|
...(venueActions?.primary ?? []),
|
|
262
276
|
...(venueActions?.overflow ?? [])
|
|
@@ -322,12 +336,22 @@
|
|
|
322
336
|
/** A `date` column carries the day only; a time of day needs a timestamp. */
|
|
323
337
|
const DAY_ONLY = /^\d{4}-\d{2}-\d{2}$/
|
|
324
338
|
|
|
339
|
+
/** The forward arrow's name on a reply with one version: a swipe keeps the version it leaves. */
|
|
340
|
+
const LONE_SWIPE_TITLE = "Write another version; this one is kept"
|
|
341
|
+
|
|
325
342
|
/**
|
|
326
|
-
* The line's real time, in the reader's own locale.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
343
|
+
* The line's real time, in the reader's own locale. A reply reads the
|
|
344
|
+
* `replyWrittenAt` stamp its last finishing write left in the metadata;
|
|
345
|
+
* a row without one (an older reply, any non-reply) reads `createdAt`,
|
|
346
|
+
* which is a day-precision `date` column on this row (20 §5), so a value
|
|
347
|
+
* with no time of day in it reads `updatedAt`, which is a timestamp.
|
|
329
348
|
*/
|
|
330
349
|
const realAt = $derived.by((): Date | null => {
|
|
350
|
+
const written = msg.metadata?.replyWrittenAt
|
|
351
|
+
if (typeof written === "string") {
|
|
352
|
+
const w = new Date(written)
|
|
353
|
+
if (!Number.isNaN(w.getTime())) return w
|
|
354
|
+
}
|
|
331
355
|
const created: unknown = msg.createdAt
|
|
332
356
|
const stamp =
|
|
333
357
|
typeof created === "string" && DAY_ONLY.test(created)
|
|
@@ -412,6 +436,7 @@
|
|
|
412
436
|
canRerun,
|
|
413
437
|
// 🚧 A kept turn's row the host would refuse to delete (★9).
|
|
414
438
|
canDelete: line.deletable ?? true,
|
|
439
|
+
waitFor: conv.dossier?.rerunWaitsFor,
|
|
415
440
|
extendRefusal,
|
|
416
441
|
speechReason: speechReason
|
|
417
442
|
}, (a) => SPEAK_VERB_KEYS.includes(verbKeyOf(a)))
|
|
@@ -471,12 +496,16 @@
|
|
|
471
496
|
// leaves that one file out (a gone file reads "Not spoken yet" there,
|
|
472
497
|
// never a broken player).
|
|
473
498
|
const spoken = $derived(spokenOf(msg.metadata))
|
|
474
|
-
const
|
|
499
|
+
const spokenItems = $derived(spoken ? spokenAudioItems(allMediaItems, spoken) : [])
|
|
500
|
+
/** The take's first file: what the line's key, Say it again and a gone file read. */
|
|
501
|
+
const spokenAudio = $derived(spokenItems[0] ?? null)
|
|
475
502
|
// A speak run in flight (`metadata.spoken.pending`) mounts the spoken line
|
|
476
503
|
// even before the line has audio: it reads *Speaking…* with a Stop.
|
|
477
504
|
const spokenPending = $derived(spokenPendingOf(msg.metadata))
|
|
478
505
|
const mediaItems = $derived(
|
|
479
|
-
|
|
506
|
+
spokenItems.length
|
|
507
|
+
? allMediaItems.filter((i) => !spokenItems.some((s) => s.partId === i.partId))
|
|
508
|
+
: allMediaItems
|
|
480
509
|
)
|
|
481
510
|
/**
|
|
482
511
|
* The speak verbs the message venue lists — `core:spec/speak-message`'s
|
|
@@ -540,6 +569,7 @@
|
|
|
540
569
|
/** What the ⋮ menu's speech group and ⋮ › Speech need, passed as one object rather than recomputed there. */
|
|
541
570
|
const speechForMenu = $derived({
|
|
542
571
|
src: hasAudio && spokenAudio ? mediaSrc(spokenAudio.assetId) : null,
|
|
572
|
+
playlist: hasAudio ? playlistOf(spokenItems) : null,
|
|
543
573
|
hasAudio,
|
|
544
574
|
// The line has a take on file (whatever the viewer's playback): Read aloud reads Say it again.
|
|
545
575
|
sayItAgain: !!spokenAudio && spokenAudio.partId !== goneSpokenPart,
|
|
@@ -789,11 +819,13 @@
|
|
|
789
819
|
<button
|
|
790
820
|
data-widget-part="messages.message-swipe-previous messages.message-icon-button"
|
|
791
821
|
aria-label="Previous swipe"
|
|
822
|
+
title={conv.dossier?.rerunWaitsFor ? `Previous swipe — ${conv.dossier.rerunWaitsFor}` : undefined}
|
|
792
823
|
onclick={() => conv.swipe(msg, "left")}
|
|
793
824
|
disabled={conv.edit.id !== null ||
|
|
794
825
|
!swipes!.currentIdx ||
|
|
795
826
|
swipes!.history.length <= 1 ||
|
|
796
827
|
msg.isGenerating ||
|
|
828
|
+
!!conv.dossier?.rerunWaitsFor ||
|
|
797
829
|
!canRerun}
|
|
798
830
|
>
|
|
799
831
|
<sp-icon name="chevron-left" size="14"></sp-icon>
|
|
@@ -807,8 +839,12 @@
|
|
|
807
839
|
{/if}
|
|
808
840
|
<button
|
|
809
841
|
data-widget-part="messages.message-swipe-next messages.message-icon-button"
|
|
810
|
-
aria-label="Next swipe"
|
|
811
|
-
title={swipeWhen[1]
|
|
842
|
+
aria-label={hasSwipeHistory ? "Next swipe" : LONE_SWIPE_TITLE}
|
|
843
|
+
title={swipeWhen[1]
|
|
844
|
+
? `Next swipe — ${swipeWhen[1]}`
|
|
845
|
+
: hasSwipeHistory
|
|
846
|
+
? undefined
|
|
847
|
+
: LONE_SWIPE_TITLE}
|
|
812
848
|
onclick={() => conv.swipe(msg, "right")}
|
|
813
849
|
disabled={conv.edit.id !== null || swipeWhen[0] || !canRerun}
|
|
814
850
|
>
|
|
@@ -952,7 +988,7 @@
|
|
|
952
988
|
{/snippet}
|
|
953
989
|
|
|
954
990
|
{#snippet stopButton()}
|
|
955
|
-
{#if msg.isGenerating}
|
|
991
|
+
{#if msg.isGenerating && !composerStops}
|
|
956
992
|
<button
|
|
957
993
|
data-widget-part="messages.message-stop"
|
|
958
994
|
onclick={() => conv.invoke("stop", msg)}
|
|
@@ -1118,19 +1154,19 @@
|
|
|
1118
1154
|
</span>
|
|
1119
1155
|
</p>
|
|
1120
1156
|
<!--
|
|
1157
|
+
An administrator reads which connection failed and what
|
|
1158
|
+
it said in Inspect run, in the reply's ⋮ menu; a line
|
|
1159
|
+
Inspect run is not offered on (no character, not the
|
|
1160
|
+
Narrator) keeps that detail here.
|
|
1161
|
+
|
|
1121
1162
|
Presence IS permission. `error.connection` is connection
|
|
1122
1163
|
identity, and the server removes that key from every
|
|
1123
1164
|
payload a non-admin receives (connections/visibility.ts),
|
|
1124
|
-
so
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
The sentence above names no connection by construction,
|
|
1129
|
-
which is what lets it be stored and shown to anybody; this
|
|
1130
|
-
is where an administrator gets back the half it left out —
|
|
1131
|
-
which connection, and what the service actually said.
|
|
1165
|
+
so rendering it whenever it arrives shows it only to
|
|
1166
|
+
administrators — no role check here to drift out of step
|
|
1167
|
+
with the one on the server.
|
|
1132
1168
|
-->
|
|
1133
|
-
{#if msg.error.connection?.name || msg.error.connection?.detail}
|
|
1169
|
+
{#if !msg.characterId && !msg.isNarratorResponse && (msg.error.connection?.name || msg.error.connection?.detail)}
|
|
1134
1170
|
<p data-widget-part="messages.message-error-detail">
|
|
1135
1171
|
{[
|
|
1136
1172
|
msg.error.connection.name,
|
|
@@ -1146,12 +1182,15 @@
|
|
|
1146
1182
|
<!-- 🚧 Where the genre retakes a whole turn (Dungeon Crawler), the
|
|
1147
1183
|
row's press regenerates the turn and says so (the 100-turn
|
|
1148
1184
|
walk, B7: a Retry the genre then refused). -->
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1185
|
+
<!-- Absent unless the viewer may rerun this line (`rerunnable`); a line with no verdict keeps it. -->
|
|
1186
|
+
{#if line.rerunnable !== false}
|
|
1187
|
+
<button
|
|
1188
|
+
data-widget-part="messages.message-retry"
|
|
1189
|
+
onclick={() => conv.invoke("retry", msg)}
|
|
1190
|
+
>
|
|
1191
|
+
{retakes ? "Regenerate" : "Retry"}
|
|
1192
|
+
</button>
|
|
1193
|
+
{/if}
|
|
1155
1194
|
</div>
|
|
1156
1195
|
</div>
|
|
1157
1196
|
{:else if isEditing}
|
|
@@ -1258,7 +1297,7 @@
|
|
|
1258
1297
|
pending={spokenPending}
|
|
1259
1298
|
liveRunIds={conv.dossier?.liveRunIds}
|
|
1260
1299
|
onStop={stopSpoken}
|
|
1261
|
-
|
|
1300
|
+
items={spokenItems}
|
|
1262
1301
|
onGone={(partId) => (goneSpokenPart = partId)}
|
|
1263
1302
|
playing={conv.speech.isPlaying(msg.id, "line")}
|
|
1264
1303
|
take={conv.speech.take(msg.id, "line")}
|
|
@@ -11,18 +11,24 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The player is the browser's own (`<audio controls>`): a component runs
|
|
13
13
|
* in the UI worker and speaks to the page in attributes and events only,
|
|
14
|
-
* so it cannot call `play()`.
|
|
14
|
+
* so it cannot call `play()`. A line of several files is still ONE element:
|
|
15
|
+
* it carries `playlist` (the files' app URLs, in play order) and no `src`,
|
|
16
|
+
* and the page moves it from file to file, so a small *2 of 3* names the
|
|
17
|
+
* file playing. A single file keeps `src`. Hence:
|
|
15
18
|
*
|
|
16
19
|
* - **Autoplay** is the `autoplay` attribute (core's alone), decided ONCE
|
|
17
|
-
* per audio part: under *Make and play*, the NEWEST line's audio, spoken
|
|
20
|
+
* per line (its first audio part): under *Make and play*, the NEWEST line's audio, spoken
|
|
18
21
|
* since this page opened and still fresh — never an older line, never
|
|
19
22
|
* on page load. A Dialogue box's shown line may too (`atReadingPlace`).
|
|
20
23
|
* A browser that refuses a sound nobody asked for leaves
|
|
21
24
|
* the player waiting; its own play button is right there.
|
|
22
25
|
* - **The playhead** arrives as the host `audio` events (1.7: `play`,
|
|
23
26
|
* `pause`, `ended`, `timeupdate` with `{ currentTime, duration, paused }`,
|
|
24
|
-
* seconds
|
|
25
|
-
*
|
|
27
|
+
* seconds; on a playlist element also `playlistIndex`, `playlistLength`).
|
|
28
|
+
* They drive the state glyph, the clock (of the file playing) and the
|
|
29
|
+
* **caption**: the words of the cue playing now, read off the recorded cue
|
|
30
|
+
* map's spans of that file. A file that cannot load is skipped by the page
|
|
31
|
+
* and said once; every file failing reads *Not spoken yet*.
|
|
26
32
|
* - **Speaking…** (speech follow-ups A4): while the line's speak run is live
|
|
27
33
|
* (`metadata.spoken.pending`, a run id) the line reads *Speaking…* with a
|
|
28
34
|
* small **Stop** that raises `onStop(runId)` — the host cancels that run. The
|
|
@@ -31,15 +37,19 @@
|
|
|
31
37
|
* (the `at` of the new record is what freshness reads, not the marker).
|
|
32
38
|
*/
|
|
33
39
|
import type { SpokenMeta } from '@serene-pub/sdk/component'
|
|
40
|
+
import { SvelteSet } from 'svelte/reactivity'
|
|
34
41
|
import { mediaSrc, type MediaStripItem } from './mediaStrip'
|
|
35
42
|
import {
|
|
36
43
|
cueCaptionAt,
|
|
44
|
+
fileCountLabel,
|
|
45
|
+
fileCountSr,
|
|
37
46
|
formatClock,
|
|
38
47
|
isFresh,
|
|
39
48
|
isOwnVoice,
|
|
40
49
|
isSpeaking,
|
|
41
50
|
moodOf,
|
|
42
51
|
playbackOf,
|
|
52
|
+
playlistOf,
|
|
43
53
|
spokenAsLine,
|
|
44
54
|
spokenSinceLoad,
|
|
45
55
|
voiceNameOf,
|
|
@@ -56,8 +66,8 @@
|
|
|
56
66
|
liveRunIds?: readonly string[]
|
|
57
67
|
/** Stop was pressed: the host cancels this run. */
|
|
58
68
|
onStop?: (runId: string) => void
|
|
59
|
-
/** The line's
|
|
60
|
-
|
|
69
|
+
/** The line's spoken files in play order; empty while it has none. */
|
|
70
|
+
items: readonly MediaStripItem[]
|
|
61
71
|
/** The newest line of the log. */
|
|
62
72
|
isLastMessage: boolean
|
|
63
73
|
/** The session's Read aloud setting. */
|
|
@@ -93,7 +103,7 @@
|
|
|
93
103
|
pending = null,
|
|
94
104
|
liveRunIds,
|
|
95
105
|
onStop,
|
|
96
|
-
|
|
106
|
+
items,
|
|
97
107
|
isLastMessage,
|
|
98
108
|
readAloud,
|
|
99
109
|
spokenPlayback = 'auto',
|
|
@@ -141,9 +151,22 @@
|
|
|
141
151
|
failedPart = partId
|
|
142
152
|
onGone?.(partId)
|
|
143
153
|
}
|
|
144
|
-
|
|
154
|
+
/** `partId:index` of each file of a playlist that failed to load. */
|
|
155
|
+
const failedFiles = new SvelteSet<string>()
|
|
156
|
+
const item = $derived(items[0] ?? null)
|
|
157
|
+
const playlist = $derived(playlistOf(items))
|
|
158
|
+
const src = $derived(item && !playlist ? mediaSrc(item.assetId) : null)
|
|
145
159
|
const gone = $derived(!item || failedPart === item.partId)
|
|
146
|
-
|
|
160
|
+
const someFailed = $derived(!!item && !!playlist && items.some((_, i) => failedFiles.has(`${item.partId}:${i}`)))
|
|
161
|
+
function failFile(e: Event) {
|
|
162
|
+
if (!item) return
|
|
163
|
+
if (!playlist) return fail(item.partId)
|
|
164
|
+
const index = playbackOf((e as CustomEvent).detail)?.playlistIndex
|
|
165
|
+
if (index === undefined || index >= items.length) return
|
|
166
|
+
failedFiles.add(`${item.partId}:${index}`)
|
|
167
|
+
if (items.every((_, i) => failedFiles.has(`${item.partId}:${i}`))) fail(item.partId)
|
|
168
|
+
}
|
|
169
|
+
// Only the FIRST element of a line may autoplay: a Stop re-key (take > 0) never does.
|
|
147
170
|
const autoplay = $derived(item && spoken && !speaking && take === 0 ? decide(item.partId) : false)
|
|
148
171
|
|
|
149
172
|
/** The last thing the player said about itself, with the part it said it for. */
|
|
@@ -151,13 +174,16 @@
|
|
|
151
174
|
const playback = $derived(item && heard && heard.part === item.partId ? heard : null)
|
|
152
175
|
const playing = $derived(!!playback && !playback.ended && !playback.at.paused)
|
|
153
176
|
const menuPlaying = $derived(!!menuAt && !menuAt.paused)
|
|
177
|
+
const fileIndex = $derived(menuPlaying && menuAt ? (menuAt.playlistIndex ?? 0) : (playback?.at.playlistIndex ?? 0))
|
|
154
178
|
const caption = $derived(
|
|
155
179
|
spoken && menuPlaying && menuAt
|
|
156
|
-
? cueCaptionAt(spoken.cueMap, menuAt.currentTime)
|
|
180
|
+
? cueCaptionAt(spoken.cueMap, menuAt.currentTime, menuAt.playlistIndex ?? 0)
|
|
157
181
|
: spoken && playing && playback
|
|
158
|
-
? cueCaptionAt(spoken.cueMap, playback.at.currentTime)
|
|
182
|
+
? cueCaptionAt(spoken.cueMap, playback.at.currentTime, playback.at.playlistIndex ?? 0)
|
|
159
183
|
: null,
|
|
160
184
|
)
|
|
185
|
+
const count = $derived(fileCountLabel(fileIndex, items.length))
|
|
186
|
+
const countSr = $derived(fileCountSr(fileIndex, items.length))
|
|
161
187
|
const clock = $derived(
|
|
162
188
|
playback && playback.at.duration > 0
|
|
163
189
|
? `${formatClock(playback.ended ? playback.at.duration : playback.at.currentTime)} / ${formatClock(playback.at.duration)}`
|
|
@@ -171,6 +197,8 @@
|
|
|
171
197
|
}
|
|
172
198
|
/** The host `audio`'s `playing` attribute (1.8): present while the conversation says so. */
|
|
173
199
|
const playAttr = $derived(shouldPlay ? { playing: '' } : {})
|
|
200
|
+
/** A line of several files: `playlist` and no `src`. */
|
|
201
|
+
const playlistAttr = $derived(playlist ? { playlist } : {})
|
|
174
202
|
/** The player's events, spread on whichever `<audio>` is drawn. */
|
|
175
203
|
const listeners = {
|
|
176
204
|
onplay: (e: Event) => hear(e),
|
|
@@ -227,7 +255,8 @@
|
|
|
227
255
|
{...playAttr}
|
|
228
256
|
preload="auto"
|
|
229
257
|
{src}
|
|
230
|
-
|
|
258
|
+
{...playlistAttr}
|
|
259
|
+
onerror={failFile}
|
|
231
260
|
{...listeners}
|
|
232
261
|
></audio>
|
|
233
262
|
{:else}
|
|
@@ -238,12 +267,14 @@
|
|
|
238
267
|
{...playAttr}
|
|
239
268
|
preload="metadata"
|
|
240
269
|
{src}
|
|
241
|
-
|
|
270
|
+
{...playlistAttr}
|
|
271
|
+
onerror={failFile}
|
|
242
272
|
{...listeners}
|
|
243
273
|
></audio>
|
|
244
274
|
{/if}
|
|
245
275
|
{/key}
|
|
246
276
|
{#if clock}<span data-widget-part="messages.spoken-time">{clock}</span>{/if}
|
|
277
|
+
{#if count}<span data-widget-part="messages.spoken-count"><span aria-hidden="true">{count}</span><span data-widget-part="messages.spoken-sr">{countSr}</span></span>{/if}
|
|
247
278
|
<span data-widget-part="messages.spoken-voice" title={asLine}>
|
|
248
279
|
{#if ownFace}
|
|
249
280
|
<img data-widget-part="messages.spoken-face" src={ownFace} alt="" />
|
|
@@ -277,6 +308,7 @@
|
|
|
277
308
|
</sp-menu-item>
|
|
278
309
|
</sp-menu>
|
|
279
310
|
{/if}
|
|
311
|
+
{#if someFailed}<p data-widget-part="messages.spoken-skipped">A part of this line could not be played.</p>{/if}
|
|
280
312
|
{#if caption}<p data-widget-part="messages.spoken-caption" aria-hidden="true">{caption}</p>{/if}
|
|
281
313
|
{/if}
|
|
282
314
|
</div>
|