@serene-pub/core-catalog 0.6.0-pr-7 → 0.6.0-pr-8

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.
Files changed (230) hide show
  1. package/components/genres/story/authors-note/AuthorsNote.svelte +2 -1
  2. package/components/genres/story/authors-note/AuthorsNoteWidget.svelte +177 -58
  3. package/components/shared/WidgetBoundary.svelte +37 -0
  4. package/components/shared/actions/Actions.svelte +2 -1
  5. package/components/shared/actions/ActionsWidget.svelte +31 -38
  6. package/components/shared/album/Album.svelte +2 -1
  7. package/components/shared/album/AlbumWidget.svelte +1 -7
  8. package/components/shared/annex/Annex.svelte +2 -1
  9. package/components/shared/annex/AnnexWidget.svelte +1 -1
  10. package/components/shared/attendance/Attendance.svelte +2 -1
  11. package/components/shared/attendance/AttendanceWidget.svelte +5 -8
  12. package/components/shared/backdrop/Backdrop.svelte +2 -1
  13. package/components/shared/backdrop/BackdropWidget.svelte +28 -22
  14. package/components/shared/chronicle/Chronicle.svelte +2 -1
  15. package/components/shared/chronicle/ChronicleWidget.svelte +101 -59
  16. package/components/shared/composer/Composer.svelte +25 -0
  17. package/components/shared/composer/ComposerWidget.svelte +134 -0
  18. package/components/shared/composer/composer.ts +10 -0
  19. package/components/shared/composer/settings.ts +55 -0
  20. package/components/shared/composer/target.ts +60 -0
  21. package/components/shared/dialogue-box/DialogueBoxMount.svelte +25 -0
  22. package/components/shared/dialogue-box/DialogueBoxWidget.svelte +207 -0
  23. package/components/shared/dialogue-box/dialogue-box.ts +10 -0
  24. package/components/shared/dialogue-box/settings.ts +25 -0
  25. package/components/shared/lore-entries/LoreEntries.svelte +2 -1
  26. package/components/shared/lore-entries/LoreEntriesWidget.svelte +5 -6
  27. package/components/shared/messages/MessageControls.svelte +3 -2
  28. package/components/shared/messages/Messages.svelte +2 -1
  29. package/components/shared/messages/MessagesWidget.svelte +58 -183
  30. package/components/shared/messages/NextCharacterBlock.svelte +17 -17
  31. package/components/shared/messages/SceneDivider.svelte +18 -2
  32. package/components/shared/messages/SessionComposer.svelte +115 -105
  33. package/components/shared/messages/SessionContainer.svelte +2 -6
  34. package/components/shared/messages/SessionMessage.svelte +90 -26
  35. package/components/shared/messages/SpokenLine.svelte +12 -3
  36. package/components/shared/messages/StateProposalList.svelte +30 -20
  37. package/components/shared/messages/TurnLine.svelte +27 -23
  38. package/components/shared/messages/conversation.svelte.ts +53 -3
  39. package/components/shared/messages/readingPace.ts +101 -0
  40. package/components/shared/messages/sceneMarks.ts +54 -0
  41. package/components/shared/places/Places.svelte +2 -1
  42. package/components/shared/places/PlacesWidget.svelte +10 -13
  43. package/components/shared/routine-log/RoutineLog.svelte +2 -1
  44. package/components/shared/routine-log/RoutineLogWidget.svelte +0 -4
  45. package/components/shared/scene-portraits/ScenePortraits.svelte +2 -1
  46. package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +54 -32
  47. package/components/shared/session-runs/SessionRuns.svelte +26 -0
  48. package/components/shared/session-runs/SessionRunsWidget.svelte +266 -0
  49. package/components/shared/session-runs/session-runs.ts +11 -0
  50. package/components/shared/state/PieceCard.svelte +36 -25
  51. package/components/shared/state/SlotControl.svelte +18 -5
  52. package/components/shared/stats/Stats.svelte +2 -1
  53. package/components/shared/stats/StatsWidget.svelte +104 -72
  54. package/components/shared/turn-line/TurnLineMount.svelte +25 -0
  55. package/components/shared/turn-line/TurnLineWidget.svelte +25 -0
  56. package/components/shared/turn-line/settings.ts +31 -0
  57. package/components/shared/turn-line/turn-line.ts +10 -0
  58. package/components/shared/turn-order/TurnOrder.svelte +2 -1
  59. package/components/shared/turn-order/TurnOrderWidget.svelte +1 -6
  60. package/dist/components/actions.js +71 -88
  61. package/dist/components/actions.source.json +1 -1
  62. package/dist/components/album.js +39 -44
  63. package/dist/components/album.source.json +1 -1
  64. package/dist/components/annex.js +17 -8
  65. package/dist/components/annex.source.json +1 -1
  66. package/dist/components/attendance.js +39 -48
  67. package/dist/components/attendance.source.json +1 -1
  68. package/dist/components/authors-note.js +329 -162
  69. package/dist/components/authors-note.source.json +1 -1
  70. package/dist/components/backdrop.js +52 -55
  71. package/dist/components/backdrop.source.json +1 -1
  72. package/dist/components/chronicle.js +510 -428
  73. package/dist/components/chronicle.source.json +1 -1
  74. package/dist/components/composer.js +1604 -0
  75. package/dist/components/composer.source.json +1 -0
  76. package/dist/components/core-ui.json +1 -1
  77. package/dist/components/dialogue-box.js +373 -0
  78. package/dist/components/dialogue-box.source.json +1 -0
  79. package/dist/components/lore-entries.js +64 -61
  80. package/dist/components/lore-entries.source.json +1 -1
  81. package/dist/components/messages.js +1418 -8907
  82. package/dist/components/messages.source.json +1 -1
  83. package/dist/components/places.js +148 -160
  84. package/dist/components/places.source.json +1 -1
  85. package/dist/components/routine-log.js +30 -35
  86. package/dist/components/routine-log.source.json +1 -1
  87. package/dist/components/scene-portraits.js +118 -59
  88. package/dist/components/scene-portraits.source.json +1 -1
  89. package/dist/components/session-runs.js +581 -0
  90. package/dist/components/session-runs.source.json +1 -0
  91. package/dist/components/shared-2FMI3LEE.js +257 -0
  92. package/dist/components/{shared-W3XS5FEL.js → shared-5E4RQYRX.js} +3 -2
  93. package/dist/components/{shared-QXF5CJVN.js → shared-6S23SGJB.js} +1 -1
  94. package/dist/components/{shared-JPG5DQO7.js → shared-7SWDK5MC.js} +88 -17
  95. package/dist/components/{shared-YDS7HYL6.js → shared-ASZVJYPD.js} +2 -2
  96. package/dist/components/shared-BR2KXM25.js +1596 -0
  97. package/dist/components/{shared-BBF64YGL.js → shared-M7AYID43.js} +19 -13
  98. package/dist/components/{shared-BIWKZFUU.js → shared-N7FFW5TX.js} +3 -3
  99. package/dist/components/{shared-7VDIXYAL.js → shared-OVDOAXYZ.js} +1 -1
  100. package/dist/components/{shared-WV3QTKZT.js → shared-RQYMTMHF.js} +13 -9
  101. package/dist/components/{shared-XBDUENRA.js → shared-TNJZHTMT.js} +1 -1
  102. package/dist/components/shared-XJD6Y2OU.js +4215 -0
  103. package/dist/components/stats.js +828 -678
  104. package/dist/components/stats.source.json +1 -1
  105. package/dist/components/turn-line.js +584 -0
  106. package/dist/components/turn-line.source.json +1 -0
  107. package/dist/components/turn-order.js +62 -67
  108. package/dist/components/turn-order.source.json +1 -1
  109. package/dist/factories/turnOrder.d.ts +18 -2
  110. package/dist/factories/turnOrder.js +32 -6
  111. package/dist/functions/pieces.js +1 -0
  112. package/dist/functions/time.js +2 -0
  113. package/dist/genres/defaults.d.ts +20 -4
  114. package/dist/genres/defaults.js +42 -8
  115. package/dist/genres/dungeon-crawler/calls.d.ts +3 -1
  116. package/dist/genres/dungeon-crawler/calls.js +5 -0
  117. package/dist/genres/dungeon-crawler/create.d.ts +9 -6
  118. package/dist/genres/dungeon-crawler/create.js +18 -8
  119. package/dist/genres/dungeon-crawler/death.d.ts +13 -6
  120. package/dist/genres/dungeon-crawler/death.js +26 -12
  121. package/dist/genres/dungeon-crawler/index.d.ts +1 -0
  122. package/dist/genres/dungeon-crawler/index.js +1 -0
  123. package/dist/genres/dungeon-crawler/lore.d.ts +13 -12
  124. package/dist/genres/dungeon-crawler/lore.js +16 -25
  125. package/dist/genres/dungeon-crawler/names.d.ts +10 -3
  126. package/dist/genres/dungeon-crawler/names.js +10 -3
  127. package/dist/genres/dungeon-crawler/preamble.d.ts +5 -4
  128. package/dist/genres/dungeon-crawler/preamble.js +75 -33
  129. package/dist/genres/dungeon-crawler/respond.js +4 -2
  130. package/dist/genres/dungeon-crawler/rest.d.ts +8 -7
  131. package/dist/genres/dungeon-crawler/rest.js +34 -12
  132. package/dist/genres/dungeon-crawler/reveal.js +2 -2
  133. package/dist/genres/dungeon-crawler/roundScript.d.ts +2 -1
  134. package/dist/genres/dungeon-crawler/roundScript.js +23 -5
  135. package/dist/genres/dungeon-crawler/scripts.js +4 -5
  136. package/dist/genres/dungeon-crawler/shape.d.ts +16 -0
  137. package/dist/genres/dungeon-crawler/shape.js +5 -1
  138. package/dist/genres/dungeon-crawler/sheet.d.ts +20 -20
  139. package/dist/genres/dungeon-crawler/story.d.ts +26 -16
  140. package/dist/genres/dungeon-crawler/story.js +169 -43
  141. package/dist/genres/dungeon-crawler/storyScripts.d.ts +2 -2
  142. package/dist/genres/dungeon-crawler/storyScripts.js +27 -8
  143. package/dist/genres/dungeon-crawler/summarizeScene.d.ts +13 -0
  144. package/dist/genres/dungeon-crawler/summarizeScene.js +21 -0
  145. package/dist/genres/lair/create.js +2 -0
  146. package/dist/genres/lair/keeper.js +4 -2
  147. package/dist/genres/lair/scripts.js +8 -6
  148. package/dist/genres/story/ask.d.ts +4 -0
  149. package/dist/genres/story/ask.js +4 -0
  150. package/dist/genres/story/create.d.ts +0 -1
  151. package/dist/genres/story/create.js +15 -1
  152. package/dist/genres/story/index.d.ts +1 -1
  153. package/dist/genres/story/index.js +1 -1
  154. package/dist/genres/story/narrate.js +8 -0
  155. package/dist/genres/story/narrateCharacter.js +8 -0
  156. package/dist/genres/story/reckon.d.ts +5 -19
  157. package/dist/genres/story/reckon.js +13 -33
  158. package/dist/genres/story/reckoning.js +3 -0
  159. package/dist/genres/story/respond.js +17 -28
  160. package/dist/genres/story/sweep.d.ts +1 -1
  161. package/dist/genres/story/sweep.js +1 -1
  162. package/dist/genres/story/turnOrder.d.ts +8 -0
  163. package/dist/genres/story/turnOrder.js +10 -1
  164. package/dist/index.d.ts +3 -0
  165. package/dist/index.js +15 -1
  166. package/dist/loadouts.d.ts +1 -0
  167. package/dist/loadouts.js +17 -1
  168. package/dist/registry/entries.d.ts +2 -0
  169. package/dist/registry/entries.js +2 -0
  170. package/dist/registry/genres.d.ts +104 -5
  171. package/dist/registry/genres.js +276 -21
  172. package/dist/registry/hostState.d.ts +1 -2
  173. package/dist/registry/hostState.js +2 -4
  174. package/dist/registry/layouts.d.ts +141 -111
  175. package/dist/registry/layouts.js +302 -141
  176. package/dist/registry/slots.d.ts +4 -3
  177. package/dist/registry/slots.js +4 -3
  178. package/dist/registry/widgets.d.ts +12 -2
  179. package/dist/registry/widgets.js +247 -105
  180. package/dist/rulesets/vis-itineris/ruleset.js +8 -5
  181. package/dist/rulesets/wherewithal/ruleset.js +2 -1
  182. package/dist/seed/presets.js +8 -6
  183. package/dist/seed/prompts.js +24 -5
  184. package/dist/shared/annexField.js +23 -3
  185. package/dist/shared/illustrateScene.d.ts +1 -0
  186. package/dist/shared/illustrateScene.js +29 -1
  187. package/dist/shared/portrait.js +13 -4
  188. package/dist/shared/reckoning.d.ts +1 -1
  189. package/dist/shared/reckoning.js +23 -13
  190. package/dist/shared/roundTick.d.ts +20 -0
  191. package/dist/shared/roundTick.js +76 -0
  192. package/dist/shared/sceneBoundaries.d.ts +7 -0
  193. package/dist/shared/sceneBoundaries.js +61 -0
  194. package/dist/shared/sceneSummaries.d.ts +7 -0
  195. package/dist/shared/sceneSummaries.js +49 -0
  196. package/dist/shared/speechFields.js +4 -0
  197. package/dist/shared/summarize/character.d.ts +1 -1
  198. package/dist/shared/summarize/history.d.ts +1 -1
  199. package/dist/shared/summarize/scene.d.ts +1 -1
  200. package/dist/shared/summarize/summarizeScene.js +1 -0
  201. package/dist/shared/summarize/summarizeSpec.d.ts +1 -1
  202. package/dist/shared/summarize/world.d.ts +1 -1
  203. package/dist/shared/ui/attendance/index.d.ts +3 -2
  204. package/dist/shared/ui/attendance/index.js +3 -7
  205. package/dist/shared/ui/chronicle/index.d.ts +17 -0
  206. package/dist/shared/ui/chronicle/index.js +39 -19
  207. package/dist/shared/ui/conversation/formAnswer.d.ts +16 -2
  208. package/dist/shared/ui/conversation/formAnswer.js +23 -9
  209. package/dist/shared/ui/conversation/index.d.ts +1 -0
  210. package/dist/shared/ui/conversation/index.js +2 -0
  211. package/dist/shared/ui/conversation/itemValues.d.ts +16 -3
  212. package/dist/shared/ui/conversation/itemValues.js +15 -5
  213. package/dist/shared/ui/conversation/messageVerbState.d.ts +12 -2
  214. package/dist/shared/ui/conversation/messageVerbState.js +2 -1
  215. package/dist/shared/ui/conversation/readingPlace.d.ts +40 -0
  216. package/dist/shared/ui/conversation/readingPlace.js +119 -0
  217. package/dist/shared/ui/conversation/rewindStrip.d.ts +2 -0
  218. package/dist/shared/ui/conversation/rewindStrip.js +21 -1
  219. package/dist/shared/ui/conversation/storyDays.d.ts +7 -1
  220. package/dist/shared/ui/conversation/storyDays.js +8 -0
  221. package/dist/shared/ui/places/index.d.ts +3 -2
  222. package/dist/shared/ui/places/index.js +4 -5
  223. package/dist/shared/ui/scene-portraits/portraits.d.ts +50 -16
  224. package/dist/shared/ui/scene-portraits/portraits.js +84 -21
  225. package/dist/shared/ui/session-runs/index.d.ts +82 -0
  226. package/dist/shared/ui/session-runs/index.js +137 -0
  227. package/dist/shared/ui/session-state/stateView.d.ts +18 -5
  228. package/dist/shared/ui/session-state/stateView.js +29 -8
  229. package/package.json +12 -8
  230. /package/dist/components/{shared-4ME6NFDK.js → shared-LUIF6DW7.js} +0 -0
@@ -9,6 +9,7 @@
9
9
  import type { ComponentContext } from "@serene-pub/sdk/component"
10
10
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
11
11
  import AuthorsNoteWidget from "./AuthorsNoteWidget.svelte"
12
+ import WidgetBoundary from "../../../shared/WidgetBoundary.svelte"
12
13
  import { widgetRefFromComponent } from "../../../shared/widgetRef.svelte"
13
14
 
14
15
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -23,4 +24,4 @@
23
24
  )
24
25
  </script>
25
26
 
26
- <AuthorsNoteWidget />
27
+ <WidgetBoundary {ctx}><AuthorsNoteWidget /></WidgetBoundary>
@@ -19,6 +19,20 @@
19
19
  * re-read moves the saved snapshot and keeps what is being typed.
20
20
  * What goes wrong is said here, in this widget (R77) — never a toast.
21
21
  *
22
+ * 🚧 It also holds the session's **Scenario** (lay-B D13, 2026-11-05;
23
+ * owner ruling R5: Left's second tab is "scenario / author's note
24
+ * management"), above the note and shown whether or not the note is
25
+ * offered — a kind of session with no note is then the Scenario alone.
26
+ * `session-scenario` reads it and the viewer's right to change it (the
27
+ * session's owner), `set-session-scenario` saves it whole; it has its own
28
+ * Save / Discard and its own read and save lines, saved and read apart from
29
+ * the note, as the page writes them apart. No event says a scenario changed
30
+ * elsewhere, so it is asked once, on mount, and takes the save's answer.
31
+ *
32
+ * The depth and interval numbers and *Sent as* show only with the viewer's
33
+ * advanced controls on (`viewer.v1.advancedControls`); hidden, the stored
34
+ * values are still what Save sends.
35
+ *
22
36
  * The markup carries no look: its elements carry `authors-note.*` widget
23
37
  * parts and the default widget stylesheet draws them (STYLE-GUIDE §6.16).
24
38
  */
@@ -34,6 +48,8 @@
34
48
  import { useWidgetContext } from "../../../shared/context"
35
49
 
36
50
  const widget = useWidgetContext()
51
+ /** 🚧 2026-11-10: the viewer's advanced controls switch; absent means shown. */
52
+ const advanced = $derived(widget?.current?.viewer?.v1?.advancedControls !== false)
37
53
  const t = (source: string): string => widget?.current?.t(source) ?? source
38
54
 
39
55
  /** What the page last answered. */
@@ -44,9 +60,18 @@
44
60
  let saveError = $state<string | null>(null)
45
61
  let saving = $state(false)
46
62
 
63
+ /** 🚧 The scenario, the same way: what the page last answered, the form's copy, its own lines. */
64
+ let scenarioAnswer = $state<{ scenario: string; canEdit: boolean } | null>(null)
65
+ let scenarioDraft = $state("")
66
+ let scenarioReadError = $state<string | null>(null)
67
+ let scenarioSaveError = $state<string | null>(null)
68
+ let scenarioSaving = $state(false)
69
+
47
70
  const saved = $derived(answer ? readAuthorsNote(answer.note) : AUTHORS_NOTE_DEFAULTS)
48
71
  const dirty = $derived(answer ? authorsNoteDirty(draft, saved) : false)
49
72
  const canEdit = $derived(answer?.canEdit === true)
73
+ const scenarioDirty = $derived(scenarioAnswer ? scenarioDraft !== scenarioAnswer.scenario : false)
74
+ const scenarioCanEdit = $derived(scenarioAnswer?.canEdit === true)
50
75
  const lastLine = $derived(answer ? authorsNoteLastReplyLine(answer.lastReply, t) : null)
51
76
 
52
77
  const reason = (e: unknown) => (e instanceof Error ? e.message : String(e))
@@ -81,6 +106,29 @@
81
106
 
82
107
  $effect(() => untrack(() => ask()))
83
108
 
109
+ /** The scenario is asked once, on mount: nothing tells this widget it changed elsewhere. */
110
+ let scenarioAsked = 0
111
+ function askScenario() {
112
+ const ctx = untrack(() => widget?.current)
113
+ if (!ctx) return
114
+ const ticket = ++scenarioAsked
115
+ ctx.request("session-scenario", {}).then(
116
+ (res) => {
117
+ if (ticket !== scenarioAsked) return
118
+ scenarioReadError = null
119
+ const wasDirty = scenarioAnswer ? scenarioDraft !== scenarioAnswer.scenario : false
120
+ scenarioAnswer = res
121
+ if (!wasDirty) scenarioDraft = res.scenario
122
+ },
123
+ (e) => {
124
+ if (ticket !== scenarioAsked) return
125
+ scenarioReadError = reason(e)
126
+ }
127
+ )
128
+ }
129
+
130
+ $effect(() => untrack(() => askScenario()))
131
+
84
132
  // A reply finished: what it did with the note is on its receipt now.
85
133
  $effect(() =>
86
134
  untrack(() =>
@@ -124,27 +172,96 @@
124
172
  saveError = null
125
173
  }
126
174
 
175
+ async function saveScenario() {
176
+ const ctx = untrack(() => widget?.current)
177
+ if (!ctx || !scenarioCanEdit || !scenarioDirty || scenarioSaving) return
178
+ scenarioSaving = true
179
+ scenarioSaveError = null
180
+ try {
181
+ const now = await ctx.request("set-session-scenario", { scenario: scenarioDraft })
182
+ // The saved row is what the page answered; the form is clean against it.
183
+ scenarioAnswer = now
184
+ scenarioDraft = now.scenario
185
+ } catch (e) {
186
+ scenarioSaveError = t("Not saved: {reason}").replace("{reason}", reason(e))
187
+ } finally {
188
+ scenarioSaving = false
189
+ }
190
+ }
191
+
192
+ function discardScenario() {
193
+ scenarioDraft = scenarioAnswer?.scenario ?? ""
194
+ scenarioSaveError = null
195
+ }
196
+
127
197
  const setNumber = (key: "depth" | "interval", raw: string) => {
128
198
  const n = raw.trim() === "" ? NaN : Number(raw)
129
199
  draft = { ...draft, [key]: Number.isFinite(n) ? n : draft[key] }
130
200
  }
131
201
  </script>
132
202
 
133
- <div data-widget-part="authors-note.root" data-widget="authors-note" data-dirty={dirty ? "" : undefined}>
203
+ <div
204
+ data-widget-part="authors-note.root"
205
+ data-widget="authors-note"
206
+ data-dirty={dirty || scenarioDirty ? "" : undefined}
207
+ >
208
+ <section data-widget-part="authors-note.scenario">
209
+ {#if scenarioReadError}
210
+ <p data-widget-part="authors-note.alert" role="alert">
211
+ {t("Could not read the scenario: {reason}").replace("{reason}", scenarioReadError)}
212
+ </p>
213
+ {/if}
214
+ {#if scenarioAnswer}
215
+ {#if !scenarioCanEdit}
216
+ <p data-widget-part="authors-note.note">
217
+ {t("Only the session's owner can change the scenario.")}
218
+ </p>
219
+ {/if}
220
+ <label data-widget-part="authors-note.field">
221
+ <span data-widget-part="authors-note.label label">{t("Scenario")}</span>
222
+ <textarea
223
+ data-widget-part="authors-note.scenario-text"
224
+ rows="4"
225
+ placeholder={t("Describe the session scenario, setting, or context (optional)")}
226
+ disabled={!scenarioCanEdit}
227
+ value={scenarioDraft}
228
+ oninput={(e) => (scenarioDraft = e.currentTarget.value)}
229
+ ></textarea>
230
+ </label>
231
+ {#if scenarioSaveError}
232
+ <p data-widget-part="authors-note.alert" role="alert">{scenarioSaveError}</p>
233
+ {/if}
234
+ {#if scenarioCanEdit}
235
+ <div data-widget-part="authors-note.actions toolbar">
236
+ {#if scenarioDirty}
237
+ <span data-widget-part="authors-note.unsaved">{t("Unsaved changes")}</span>
238
+ <button
239
+ type="button"
240
+ data-widget-part="authors-note.discard"
241
+ disabled={scenarioSaving}
242
+ onclick={discardScenario}
243
+ >
244
+ {t("Discard")}
245
+ </button>
246
+ {/if}
247
+ <button
248
+ type="button"
249
+ data-widget-part="authors-note.save"
250
+ disabled={!scenarioDirty || scenarioSaving}
251
+ onclick={saveScenario}
252
+ >
253
+ {scenarioSaving ? t("Saving…") : t("Save")}
254
+ </button>
255
+ </div>
256
+ {/if}
257
+ {/if}
258
+ </section>
134
259
  {#if readError}
135
260
  <p data-widget-part="authors-note.alert" role="alert">
136
261
  {t("Could not read the author's note: {reason}").replace("{reason}", readError)}
137
262
  </p>
138
263
  {/if}
139
- {#if !answer}
140
- {#if !readError}
141
- <p data-widget-part="authors-note.note">{t("Reading the author's note…")}</p>
142
- {/if}
143
- {:else if !answer.offered}
144
- <p data-widget-part="authors-note.note">
145
- {t("This kind of session has no author's note.")}
146
- </p>
147
- {:else}
264
+ {#if answer?.offered}
148
265
  {#if !canEdit}
149
266
  <p data-widget-part="authors-note.note">
150
267
  {t("Only the session's owner can change the author's note.")}
@@ -161,55 +278,57 @@
161
278
  oninput={(e) => (draft = { ...draft, text: e.currentTarget.value })}
162
279
  ></textarea>
163
280
  </label>
164
- <div data-widget-part="authors-note.numbers">
165
- <label data-widget-part="authors-note.field">
166
- <span data-widget-part="authors-note.label label">{t("Messages from the end")}</span>
167
- <input
168
- type="number"
169
- data-widget-part="authors-note.number"
170
- min="0"
171
- step="1"
172
- disabled={!canEdit}
173
- value={String(draft.depth)}
174
- oninput={(e) => setNumber("depth", e.currentTarget.value)}
175
- />
176
- </label>
177
- <label data-widget-part="authors-note.field">
178
- <span data-widget-part="authors-note.label label">{t("Every how many replies")}</span>
179
- <input
180
- type="number"
181
- data-widget-part="authors-note.number"
182
- min="1"
183
- step="1"
184
- disabled={!canEdit}
185
- value={String(draft.interval)}
186
- oninput={(e) => setNumber("interval", e.currentTarget.value)}
187
- />
188
- </label>
189
- </div>
190
- <p data-widget-part="authors-note.help">
191
- {t("0 messages puts it right before the reply. Every 1 reply adds it each time.")}
192
- </p>
193
- <sp-accordion data-widget-part="authors-note.advanced">
194
- <sp-accordion-item value="advanced" heading={t("Advanced")} level="4">
195
- <span data-widget-part="authors-note.role">
196
- <sp-combobox
197
- data-widget-part="authors-note.role-field"
198
- label={t("Sent as")}
199
- value={draft.role}
281
+ {#if advanced}
282
+ <div data-widget-part="authors-note.numbers">
283
+ <label data-widget-part="authors-note.field">
284
+ <span data-widget-part="authors-note.label label">{t("Messages from the end")}</span>
285
+ <input
286
+ type="number"
287
+ data-widget-part="authors-note.number"
288
+ min="0"
289
+ step="1"
200
290
  disabled={!canEdit}
201
- onchange={(e: CustomEvent<{ value: string }>) => {
202
- const next = AUTHORS_NOTE_ROLES.find((r) => r.value === e.detail.value)
203
- if (next) draft = { ...draft, role: next.value }
204
- }}
205
- >
206
- {#each AUTHORS_NOTE_ROLES as r (r.value)}
207
- <sp-option value={r.value}>{t(r.label)}</sp-option>
208
- {/each}
209
- </sp-combobox>
210
- </span>
211
- </sp-accordion-item>
212
- </sp-accordion>
291
+ value={String(draft.depth)}
292
+ oninput={(e) => setNumber("depth", e.currentTarget.value)}
293
+ />
294
+ </label>
295
+ <label data-widget-part="authors-note.field">
296
+ <span data-widget-part="authors-note.label label">{t("Every how many replies")}</span>
297
+ <input
298
+ type="number"
299
+ data-widget-part="authors-note.number"
300
+ min="1"
301
+ step="1"
302
+ disabled={!canEdit}
303
+ value={String(draft.interval)}
304
+ oninput={(e) => setNumber("interval", e.currentTarget.value)}
305
+ />
306
+ </label>
307
+ </div>
308
+ <p data-widget-part="authors-note.help">
309
+ {t("0 messages puts it right before the reply. Every 1 reply adds it each time.")}
310
+ </p>
311
+ <sp-accordion data-widget-part="authors-note.advanced">
312
+ <sp-accordion-item value="advanced" heading={t("Advanced")} level="4">
313
+ <span data-widget-part="authors-note.role">
314
+ <sp-combobox
315
+ data-widget-part="authors-note.role-field"
316
+ label={t("Sent as")}
317
+ value={draft.role}
318
+ disabled={!canEdit}
319
+ onchange={(e: CustomEvent<{ value: string }>) => {
320
+ const next = AUTHORS_NOTE_ROLES.find((r) => r.value === e.detail.value)
321
+ if (next) draft = { ...draft, role: next.value }
322
+ }}
323
+ >
324
+ {#each AUTHORS_NOTE_ROLES as r (r.value)}
325
+ <sp-option value={r.value}>{t(r.label)}</sp-option>
326
+ {/each}
327
+ </sp-combobox>
328
+ </span>
329
+ </sp-accordion-item>
330
+ </sp-accordion>
331
+ {/if}
213
332
  {#if saveError}
214
333
  <p data-widget-part="authors-note.alert" role="alert">{saveError}</p>
215
334
  {/if}
@@ -0,0 +1,37 @@
1
+ <script lang="ts">
2
+ /**
3
+ * The one boundary every core widget host draws its widget inside.
4
+ *
5
+ * Why (playtest item 15): a widget whose Svelte render threw after mount
6
+ * went blank with nothing on screen — the worker reports a throw at mount
7
+ * and in a handler, not one in a render. Here the throw is caught, said to
8
+ * the page as a fatal report over the widget port (the page answers with
9
+ * its own "This widget stopped" overlay), and one plain sentence is drawn.
10
+ *
11
+ * A handler's throw is not this boundary's: the worker reports it.
12
+ */
13
+ import type { Snippet } from "svelte"
14
+ import type { ComponentContext } from "@serene-pub/sdk/component"
15
+
16
+ let { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()
17
+
18
+ function report(error: unknown) {
19
+ const message = error instanceof Error ? error.message : String(error)
20
+ const where =
21
+ error instanceof Error && error.stack
22
+ ? "\n" + error.stack.split("\n").slice(1, 7).join("\n")
23
+ : ""
24
+ try {
25
+ ctx.error(message + where, true)
26
+ } catch {
27
+ // A closed port has nobody to tell.
28
+ }
29
+ }
30
+ </script>
31
+
32
+ <svelte:boundary onerror={report}>
33
+ {@render children()}
34
+ {#snippet failed()}
35
+ <p role="alert">This widget stopped and can't show anything.</p>
36
+ {/snippet}
37
+ </svelte:boundary>
@@ -7,6 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import ActionsWidget from "./ActionsWidget.svelte"
10
+ import WidgetBoundary from "../WidgetBoundary.svelte"
10
11
  import { widgetRefFromComponent } from "../widgetRef.svelte"
11
12
 
12
13
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -21,4 +22,4 @@
21
22
  )
22
23
  </script>
23
24
 
24
- <ActionsWidget />
25
+ <WidgetBoundary {ctx}><ActionsWidget /></WidgetBoundary>
@@ -76,43 +76,36 @@
76
76
  <p data-widget-part="actions.alert" role="alert">{refusal}</p>
77
77
  {/if}
78
78
 
79
- {#if view.empty}
80
- <div data-widget-part="actions.empty empty" role="status">
81
- <sp-icon name="mouse-pointer-click" size="20"></sp-icon>
82
- <span>{view.empty}</span>
79
+ {#each view.groups as group (group.key)}
80
+ <div
81
+ data-widget-part="actions.group"
82
+ data-group={group.key}
83
+ role="group"
84
+ aria-labelledby={`actions-${uid}-${group.key}`}
85
+ >
86
+ <p data-widget-part="actions.group-head" id={`actions-${uid}-${group.key}`}>{group.title}</p>
87
+ {#each group.buttons as button (button.identity)}
88
+ <button
89
+ type="button"
90
+ data-widget-part="actions.button"
91
+ data-identity={button.identity}
92
+ data-new={button.isNew ? "" : undefined}
93
+ aria-disabled={button.disabled ? "true" : undefined}
94
+ aria-describedby={button.reason ? `actions-${uid}-reason-${idOf(button.identity)}` : undefined}
95
+ title={button.title}
96
+ onclick={() => press(button)}
97
+ >
98
+ <sp-icon name={button.icon} size="16"></sp-icon>
99
+ <span>{button.name}</span>
100
+ {#if button.reason}
101
+ <span
102
+ data-widget-part="actions.reason"
103
+ id={`actions-${uid}-reason-${idOf(button.identity)}`}
104
+ aria-hidden="true">{button.reason}</span
105
+ >
106
+ {/if}
107
+ </button>
108
+ {/each}
83
109
  </div>
84
- {:else}
85
- {#each view.groups as group (group.key)}
86
- <div
87
- data-widget-part="actions.group"
88
- data-group={group.key}
89
- role="group"
90
- aria-labelledby={`actions-${uid}-${group.key}`}
91
- >
92
- <p data-widget-part="actions.group-head" id={`actions-${uid}-${group.key}`}>{group.title}</p>
93
- {#each group.buttons as button (button.identity)}
94
- <button
95
- type="button"
96
- data-widget-part="actions.button"
97
- data-identity={button.identity}
98
- data-new={button.isNew ? "" : undefined}
99
- aria-disabled={button.disabled ? "true" : undefined}
100
- aria-describedby={button.reason ? `actions-${uid}-reason-${idOf(button.identity)}` : undefined}
101
- title={button.title}
102
- onclick={() => press(button)}
103
- >
104
- <sp-icon name={button.icon} size="16"></sp-icon>
105
- <span>{button.name}</span>
106
- {#if button.reason}
107
- <span
108
- data-widget-part="actions.reason"
109
- id={`actions-${uid}-reason-${idOf(button.identity)}`}
110
- aria-hidden="true">{button.reason}</span
111
- >
112
- {/if}
113
- </button>
114
- {/each}
115
- </div>
116
- {/each}
117
- {/if}
110
+ {/each}
118
111
  </div>
@@ -7,6 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import AlbumWidget from "./AlbumWidget.svelte"
10
+ import WidgetBoundary from "../WidgetBoundary.svelte"
10
11
  import { widgetRefFromComponent } from "../widgetRef.svelte"
11
12
 
12
13
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -21,4 +22,4 @@
21
22
  )
22
23
  </script>
23
24
 
24
- <AlbumWidget />
25
+ <WidgetBoundary {ctx}><AlbumWidget /></WidgetBoundary>
@@ -24,7 +24,6 @@
24
24
  */
25
25
  import { SvelteSet } from "svelte/reactivity"
26
26
  import {
27
- ALBUM_EMPTY,
28
27
  ALBUM_ORIGIN_NAMES,
29
28
  albumItems,
30
29
  albumOpenLabel,
@@ -132,12 +131,7 @@
132
131
  <p data-widget-part="album.alert" role="alert">{refusal}</p>
133
132
  {/if}
134
133
 
135
- {#if !items.length}
136
- <div data-widget-part="album.empty empty" role="status">
137
- <sp-icon name="book-image" size="20"></sp-icon>
138
- <span>{t(ALBUM_EMPTY[settings.source])}</span>
139
- </div>
140
- {:else}
134
+ {#if items.length}
141
135
  <p data-widget-part="album.toolbar toolbar">{count}</p>
142
136
  {#if latest}
143
137
  {#if lead}
@@ -7,6 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import AnnexWidget from "./AnnexWidget.svelte"
10
+ import WidgetBoundary from "../WidgetBoundary.svelte"
10
11
  import { widgetRefFromComponent } from "../widgetRef.svelte"
11
12
 
12
13
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -21,4 +22,4 @@
21
22
  )
22
23
  </script>
23
24
 
24
- <AnnexWidget />
25
+ <WidgetBoundary {ctx}><AnnexWidget /></WidgetBoundary>
@@ -144,7 +144,7 @@
144
144
  </dl>
145
145
  {/if}
146
146
  </div>
147
- {:else}
147
+ {:else if view.state === "hidden" || view.state === "pick"}
148
148
  <div data-widget-part="annex.empty empty" role="status">
149
149
  <sp-icon name="clipboard-list" size="20"></sp-icon>
150
150
  <span>{view.empty}</span>
@@ -7,6 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import AttendanceWidget from "./AttendanceWidget.svelte"
10
+ import WidgetBoundary from "../WidgetBoundary.svelte"
10
11
  import { widgetRefFromComponent } from "../widgetRef.svelte"
11
12
 
12
13
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -21,4 +22,4 @@
21
22
  )
22
23
  </script>
23
24
 
24
- <AttendanceWidget />
25
+ <WidgetBoundary {ctx}><AttendanceWidget /></WidgetBoundary>
@@ -109,19 +109,16 @@
109
109
  <p data-widget-part="attendance.alert" role="alert">{refusal}</p>
110
110
  {/if}
111
111
 
112
- <section data-widget-part="attendance.group" data-group="here" aria-label={t("Here")}>
113
- <h3 data-widget-part="attendance.group-head">{t("Here")}</h3>
114
- {#if view.here.length}
112
+ {#if view.here.length}
113
+ <section data-widget-part="attendance.group" data-group="here" aria-label={t("Here")}>
114
+ <h3 data-widget-part="attendance.group-head">{t("Here")}</h3>
115
115
  <ul data-widget-part="attendance.list list">
116
116
  {#each view.here as person (person.key)}
117
117
  {@render personRow(person, "here")}
118
118
  {/each}
119
119
  </ul>
120
- {/if}
121
- {#if view.alone}
122
- <p data-widget-part="attendance.empty empty" role="status">{view.alone}</p>
123
- {/if}
124
- </section>
120
+ </section>
121
+ {/if}
125
122
 
126
123
  {#if view.away.length}
127
124
  <section data-widget-part="attendance.group" data-group="away" aria-label={t("Away")}>
@@ -7,6 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import BackdropWidget from "./BackdropWidget.svelte"
10
+ import WidgetBoundary from "../WidgetBoundary.svelte"
10
11
  import { widgetRefFromComponent } from "../widgetRef.svelte"
11
12
 
12
13
  let { ctx }: { ctx: ComponentContext } = $props()
@@ -21,4 +22,4 @@
21
22
  )
22
23
  </script>
23
24
 
24
- <BackdropWidget />
25
+ <WidgetBoundary {ctx}><BackdropWidget /></WidgetBoundary>
@@ -36,7 +36,6 @@
36
36
  */
37
37
  import { untrack } from "svelte"
38
38
  import {
39
- BACKDROP_EMPTY,
40
39
  BACKDROP_ILLUSTRATE_PAYLOAD,
41
40
  backdropOf,
42
41
  illustrateActionOf,
@@ -87,11 +86,11 @@
87
86
  }
88
87
 
89
88
  let choosing = $state(false)
90
- /** Whose gallery the chooser shows, by character id. */
91
- let memberId = $state<number | null>(null)
92
- let galleries = $state<Record<number, GalleryPages>>({})
89
+ /** Whose gallery the chooser shows, by the member's `ref`. */
90
+ let memberId = $state<string | null>(null)
91
+ let galleries = $state<Record<string, GalleryPages>>({})
93
92
  /** Members whose next page is on its way — not state: nothing draws it. */
94
- const asking = new Set<number>()
93
+ const asking = new Set<string>()
95
94
 
96
95
  const isImage = (v: unknown): v is GalleryImage =>
97
96
  !!v &&
@@ -99,15 +98,27 @@
99
98
  typeof (v as GalleryImage).ref === "string" &&
100
99
  typeof (v as GalleryImage).src === "string"
101
100
 
102
- async function nextPage(characterId: number): Promise<void> {
103
- const held = untrack(() => galleries[characterId])
104
- if (asking.has(characterId) || held?.done) return
105
- asking.add(characterId)
101
+ /** Who `character-images` is asked about: the card when the member has one, else its cast member. */
102
+ const nameOf = (m: {
103
+ cardId?: number | null
104
+ castMemberId?: number | null
105
+ characterId: number
106
+ }): { characterId: number } | { castMemberId: number } =>
107
+ m.cardId === null && m.castMemberId != null
108
+ ? { castMemberId: m.castMemberId }
109
+ : { characterId: m.cardId ?? m.characterId }
110
+
111
+ async function nextPage(key: string): Promise<void> {
112
+ const m = untrack(() => members.find((x) => x.ref === key))
113
+ if (!m) return
114
+ const held = untrack(() => galleries[key])
115
+ if (asking.has(key) || held?.done) return
116
+ asking.add(key)
106
117
  const keep = held?.images ?? []
107
118
  let pages: GalleryPages
108
119
  try {
109
120
  const res = (await w?.current.request("character-images", {
110
- characterId,
121
+ ...nameOf(m),
111
122
  ...(held?.next ? { cursor: held.next } : {})
112
123
  })) as { images?: unknown[]; nextCursor?: string } | undefined
113
124
  const images = (Array.isArray(res?.images) ? res.images : []).filter(isImage)
@@ -116,9 +127,9 @@
116
127
  } catch (e) {
117
128
  pages = { images: keep, next: null, done: true, error: messageOf(e) }
118
129
  } finally {
119
- asking.delete(characterId)
130
+ asking.delete(key)
120
131
  }
121
- galleries = { ...untrack(() => galleries), [characterId]: pages }
132
+ galleries = { ...untrack(() => galleries), [key]: pages }
122
133
  }
123
134
 
124
135
  /* ── From this session: its generated pictures, by `session-images` ── */
@@ -148,7 +159,7 @@
148
159
  sessionPages = pages
149
160
  }
150
161
 
151
- function pickMember(id: number) {
162
+ function pickMember(id: string) {
152
163
  memberId = id
153
164
  if (!untrack(() => galleries[id])) void nextPage(id)
154
165
  }
@@ -156,14 +167,14 @@
156
167
  function openChooser() {
157
168
  choosing = true
158
169
  error = null
159
- const first = untrack(() => memberId ?? members[0]?.characterId ?? null)
170
+ const first = untrack(() => memberId ?? (members[0] ? members[0].ref : null))
160
171
  if (first !== null) pickMember(first)
161
172
  // Asked afresh each time: a Scene may have drawn one since.
162
173
  sessionPages = null
163
174
  void nextSessionPage()
164
175
  }
165
176
 
166
- const member = $derived(members.find((m) => m.characterId === memberId) ?? null)
177
+ const member = $derived(members.find((m) => m.ref === memberId) ?? null)
167
178
  const pages = $derived(memberId !== null ? galleries[memberId] : undefined)
168
179
 
169
180
  /** Draw the scene as the backdrop: the Scene action, placement `backdrop`. */
@@ -242,9 +253,9 @@
242
253
  {#each members as m (m.ref)}
243
254
  <button
244
255
  type="button"
245
- aria-pressed={m.characterId === memberId}
256
+ aria-pressed={m.ref === memberId}
246
257
  data-widget-part="backdrop.member"
247
- onclick={() => pickMember(m.characterId)}
258
+ onclick={() => pickMember(m.ref)}
248
259
  >
249
260
  {m.name}
250
261
  </button>
@@ -312,11 +323,6 @@
312
323
  {/if}
313
324
  </section>
314
325
  </section>
315
- {:else if !backdrop}
316
- <div data-widget-part="backdrop.empty empty" role="status">
317
- <sp-icon name="mountain-snow" size="20"></sp-icon>
318
- <span>{t(BACKDROP_EMPTY)}</span>
319
- </div>
320
326
  {/if}
321
327
 
322
328
  {#if mayChange && !choosing}