@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.
Files changed (147) hide show
  1. package/README.md +1 -1
  2. package/components/shared/chronicle/ChronicleWidget.svelte +127 -57
  3. package/components/shared/composer/ComposerWidget.svelte +17 -5
  4. package/components/shared/composer/settings.ts +6 -2
  5. package/components/shared/composer/target.ts +19 -0
  6. package/components/shared/dialogue-box/DialogueBoxWidget.svelte +2 -2
  7. package/components/shared/lore-entries/LoreEntriesWidget.svelte +39 -35
  8. package/components/shared/messages/MessageBlocksView.svelte +1 -1
  9. package/components/shared/messages/MessageControls.svelte +21 -4
  10. package/components/shared/messages/MessagesWidget.svelte +24 -8
  11. package/components/shared/messages/NextCharacterBlock.svelte +18 -3
  12. package/components/shared/messages/SceneDivider.svelte +22 -12
  13. package/components/shared/messages/SessionComposer.svelte +67 -22
  14. package/components/shared/messages/SessionContainer.svelte +87 -32
  15. package/components/shared/messages/SessionMessage.svelte +68 -29
  16. package/components/shared/messages/SpokenLine.svelte +45 -13
  17. package/components/shared/messages/TurnLine.svelte +233 -45
  18. package/components/shared/messages/conversation.svelte.ts +30 -2
  19. package/components/shared/messages/rowFacts.ts +44 -0
  20. package/components/shared/messages/spokenLine.ts +63 -14
  21. package/components/shared/places/PlacesWidget.svelte +32 -20
  22. package/components/shared/routine-log/routineLog.ts +5 -21
  23. package/components/shared/session-runs/SessionRunsWidget.svelte +16 -12
  24. package/dist/components/actions.js +5 -5
  25. package/dist/components/actions.source.json +1 -1
  26. package/dist/components/album.js +1 -1
  27. package/dist/components/album.source.json +1 -1
  28. package/dist/components/annex.js +1 -1
  29. package/dist/components/annex.source.json +1 -1
  30. package/dist/components/attendance.js +1 -1
  31. package/dist/components/attendance.source.json +1 -1
  32. package/dist/components/authors-note.js +1 -1
  33. package/dist/components/authors-note.source.json +1 -1
  34. package/dist/components/backdrop.js +3 -3
  35. package/dist/components/backdrop.source.json +1 -1
  36. package/dist/components/chronicle.js +641 -484
  37. package/dist/components/chronicle.source.json +1 -1
  38. package/dist/components/composer.js +188 -153
  39. package/dist/components/composer.source.json +1 -1
  40. package/dist/components/core-ui.json +1 -1
  41. package/dist/components/dialogue-box.js +11 -11
  42. package/dist/components/dialogue-box.source.json +1 -1
  43. package/dist/components/lore-entries.js +101 -92
  44. package/dist/components/lore-entries.source.json +1 -1
  45. package/dist/components/messages.js +351 -275
  46. package/dist/components/messages.source.json +1 -1
  47. package/dist/components/places.js +237 -202
  48. package/dist/components/places.source.json +1 -1
  49. package/dist/components/routine-log.js +6 -17
  50. package/dist/components/routine-log.source.json +1 -1
  51. package/dist/components/scene-portraits.js +4 -4
  52. package/dist/components/scene-portraits.source.json +1 -1
  53. package/dist/components/session-runs.js +118 -211
  54. package/dist/components/session-runs.source.json +1 -1
  55. package/dist/components/{shared-OVDOAXYZ.js → shared-47J4TNSF.js} +1 -1
  56. package/dist/components/{shared-ASZVJYPD.js → shared-EFMMT76D.js} +56 -3
  57. package/dist/components/{shared-N7FFW5TX.js → shared-FOVKPMSK.js} +3 -3
  58. package/dist/components/{shared-7SWDK5MC.js → shared-HEAKNNZB.js} +4 -0
  59. package/dist/components/shared-JXP6SHKF.js +159 -0
  60. package/dist/components/{shared-TNJZHTMT.js → shared-JXYPKSTQ.js} +1 -1
  61. package/dist/components/{shared-2FMI3LEE.js → shared-KJIOSSE3.js} +2 -2
  62. package/dist/components/{shared-RQYMTMHF.js → shared-KLURQFWI.js} +2 -2
  63. package/dist/components/{shared-BR2KXM25.js → shared-MHCNUDUT.js} +96 -12
  64. package/dist/components/{shared-6S23SGJB.js → shared-NICRJ4Z2.js} +1 -1
  65. package/dist/components/{shared-M7AYID43.js → shared-W2BBJCNE.js} +7 -7
  66. package/dist/components/{shared-XJD6Y2OU.js → shared-YYYXFDZU.js} +387 -248
  67. package/dist/components/stats.js +5 -5
  68. package/dist/components/stats.source.json +1 -1
  69. package/dist/components/turn-line.js +384 -112
  70. package/dist/components/turn-line.source.json +1 -1
  71. package/dist/components/turn-order.js +4 -4
  72. package/dist/components/turn-order.source.json +1 -1
  73. package/dist/factories/answerForm.d.ts +6 -0
  74. package/dist/factories/answerForm.js +104 -96
  75. package/dist/factories/turnOrder.d.ts +84 -107
  76. package/dist/factories/turnOrder.js +89 -131
  77. package/dist/genres/chat/create.js +2 -0
  78. package/dist/genres/chat/memory.js +64 -43
  79. package/dist/genres/chat/respond.d.ts +7 -6
  80. package/dist/genres/chat/respond.js +13 -4
  81. package/dist/genres/chat/turnOrder.d.ts +2 -2
  82. package/dist/genres/chat/turnOrder.js +28 -12
  83. package/dist/genres/defaults.d.ts +8 -2
  84. package/dist/genres/defaults.js +51 -27
  85. package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
  86. package/dist/genres/dungeon-crawler/journal.js +1 -1
  87. package/dist/genres/dungeon-crawler/rest.js +5 -3
  88. package/dist/genres/dungeon-crawler/story.d.ts +2 -1
  89. package/dist/genres/dungeon-crawler/story.js +7 -4
  90. package/dist/genres/dungeon-crawler/storyScripts.js +85 -9
  91. package/dist/genres/dungeon-crawler/turnOrder.d.ts +8 -9
  92. package/dist/genres/dungeon-crawler/turnOrder.js +33 -23
  93. package/dist/genres/guide/create.js +2 -0
  94. package/dist/genres/guide/turnOrder.d.ts +3 -3
  95. package/dist/genres/guide/turnOrder.js +29 -13
  96. package/dist/genres/lair/answerForm.js +4 -1
  97. package/dist/genres/lair/buildRoom.js +4 -3
  98. package/dist/genres/lair/castellanAction.js +160 -154
  99. package/dist/genres/lair/fileCurrentRoom.js +13 -10
  100. package/dist/genres/lair/fileRoom.js +4 -3
  101. package/dist/genres/lair/keeper.js +2 -0
  102. package/dist/genres/lair/names.d.ts +2 -0
  103. package/dist/genres/lair/names.js +2 -0
  104. package/dist/genres/lair/reply.js +16 -6
  105. package/dist/genres/lair/roomAnswer.js +4 -3
  106. package/dist/genres/lair/scratchpad.js +9 -7
  107. package/dist/genres/lair/turnOrder.d.ts +3 -2
  108. package/dist/genres/lair/turnOrder.js +45 -16
  109. package/dist/genres/story/create.d.ts +1 -0
  110. package/dist/genres/story/create.js +1 -0
  111. package/dist/genres/story/reckon.js +43 -10
  112. package/dist/genres/story/turnOrder.d.ts +13 -3
  113. package/dist/genres/story/turnOrder.js +79 -22
  114. package/dist/index.js +8 -8
  115. package/dist/primers/ninth-mile.d.ts +3 -4
  116. package/dist/registry/entries.js +16 -5
  117. package/dist/registry/genres.d.ts +61 -54
  118. package/dist/registry/genres.js +123 -106
  119. package/dist/registry/widgets.js +12 -1
  120. package/dist/seed/presets.js +11 -7
  121. package/dist/seed/scripts.js +3 -0
  122. package/dist/shared/lore.d.ts +13 -0
  123. package/dist/shared/lore.js +37 -1
  124. package/dist/shared/reckoning.d.ts +7 -1
  125. package/dist/shared/reckoning.js +24 -17
  126. package/dist/shared/sceneBoundaries.js +7 -6
  127. package/dist/shared/speakMessage.d.ts +9 -2
  128. package/dist/shared/speakMessage.js +32 -9
  129. package/dist/shared/ui/chronicle/index.d.ts +7 -2
  130. package/dist/shared/ui/chronicle/index.js +21 -12
  131. package/dist/shared/ui/conversation/index.d.ts +1 -0
  132. package/dist/shared/ui/conversation/index.js +2 -0
  133. package/dist/shared/ui/conversation/messageVerbState.d.ts +5 -0
  134. package/dist/shared/ui/conversation/messageVerbState.js +3 -3
  135. package/dist/shared/ui/conversation/rewindStrip.d.ts +11 -4
  136. package/dist/shared/ui/conversation/rewindStrip.js +9 -7
  137. package/dist/shared/ui/conversation/runsInProgress.d.ts +30 -0
  138. package/dist/shared/ui/conversation/runsInProgress.js +47 -0
  139. package/dist/shared/ui/conversation/tableChannel.d.ts +8 -11
  140. package/dist/shared/ui/conversation/tableChannel.js +8 -9
  141. package/dist/shared/ui/routine-log/index.d.ts +3 -0
  142. package/dist/shared/ui/routine-log/index.js +22 -0
  143. package/dist/shared/ui/session-runs/index.d.ts +9 -1
  144. package/dist/shared/ui/session-runs/index.js +20 -14
  145. package/dist/shared/ui/turn-order/index.d.ts +0 -9
  146. package/dist/shared/ui/turn-order/index.js +1 -2
  147. package/package.json +8 -8
@@ -50,6 +50,8 @@
50
50
  const settings = $derived(
51
51
  readPlacesSettings(widget?.current?.settings?.v1)
52
52
  )
53
+ /** The session's notes are the owner's: a guest reads the places and opens none. */
54
+ const canOpen = $derived(widget?.current?.viewer?.v1?.isGuest !== true)
53
55
  const section = $derived(widget?.current?.scope("session:state"))
54
56
  /** The host said this copy does not hold `session:state`: who stands where will never come. */
55
57
  const stateNotGranted = $derived(scopeNotGranted(widget?.current, "session:state"))
@@ -142,6 +144,16 @@
142
144
  const names = (faces: { name: string }[]) => faces.map((f) => f.name).join(", ")
143
145
  </script>
144
146
 
147
+ {#snippet rowBody(r: (typeof view.rows)[number])}
148
+ <span data-widget-part="places.name">{r.name}</span>
149
+ {#if r.here}
150
+ <span data-widget-part="places.here chip">{t("Here")}</span>
151
+ {/if}
152
+ {#if r.category}
153
+ <span data-widget-part="places.category chip" data-tint={r.tint ?? undefined}>{r.category}</span>
154
+ {/if}
155
+ {/snippet}
156
+
145
157
  <div data-widget-part="places.root" data-widget="places" data-state={view.state} data-view={mode}>
146
158
  {#if alert}
147
159
  <p data-widget-part="places.alert" role="alert">{alert}</p>
@@ -173,20 +185,18 @@
173
185
  data-tint={r.tint ?? undefined}
174
186
  data-here={r.here ? "" : undefined}
175
187
  >
176
- <button
177
- type="button"
178
- data-widget-part="places.row-open"
179
- title={t("Open in lorebook")}
180
- onclick={() => openEntry(r.id)}
181
- >
182
- <span data-widget-part="places.name">{r.name}</span>
183
- {#if r.here}
184
- <span data-widget-part="places.here chip">{t("Here")}</span>
185
- {/if}
186
- {#if r.category}
187
- <span data-widget-part="places.category chip" data-tint={r.tint ?? undefined}>{r.category}</span>
188
- {/if}
189
- </button>
188
+ {#if canOpen}
189
+ <button
190
+ type="button"
191
+ data-widget-part="places.row-open"
192
+ title={t("Open in lorebook")}
193
+ onclick={() => openEntry(r.id)}
194
+ >
195
+ {@render rowBody(r)}
196
+ </button>
197
+ {:else}
198
+ <span data-widget-part="places.row-open">{@render rowBody(r)}</span>
199
+ {/if}
190
200
  {#if r.present.length}
191
201
  <span
192
202
  data-widget-part="places.present"
@@ -271,12 +281,14 @@
271
281
  {/each}
272
282
  </dl>
273
283
  {/if}
274
- <div data-widget-part="places.detail-actions toolbar">
275
- <button type="button" data-widget-part="places.open" onclick={() => openEntry(detail.id)}>
276
- <sp-icon name="external-link" size="14"></sp-icon>
277
- {t("Open entry")}
278
- </button>
279
- </div>
284
+ {#if canOpen}
285
+ <div data-widget-part="places.detail-actions toolbar">
286
+ <button type="button" data-widget-part="places.open" onclick={() => openEntry(detail.id)}>
287
+ <sp-icon name="external-link" size="14"></sp-icon>
288
+ {t("Open entry")}
289
+ </button>
290
+ </div>
291
+ {/if}
280
292
  </section>
281
293
  {/if}
282
294
  {/if}
@@ -7,6 +7,7 @@
7
7
  * host.
8
8
  */
9
9
  import type { RoutineLogEntryV1, RoutineLogV1 } from '@serene-pub/sdk/component'
10
+ import { routineLogOutcomeWords } from '@serene-pub/core-catalog/session-runs'
10
11
 
11
12
  /** The widget's settings, defaults filled. */
12
13
  export interface RoutineLogSettings {
@@ -23,14 +24,6 @@ export function readRoutineLogSettings(raw: unknown): RoutineLogSettings {
23
24
  return { limit, skipped: typeof r.skipped === 'boolean' ? r.skipped : ROUTINE_LOG_DEFAULTS.skipped }
24
25
  }
25
26
 
26
- const OUTCOME: Record<RoutineLogEntryV1['kind'], string> = {
27
- ran: 'Ran',
28
- skipped: 'Skipped',
29
- paused: 'Paused',
30
- failed: 'Failed',
31
- stopped: 'Stopped',
32
- }
33
-
34
27
  /** "1 entry", "2 messages" — what a run wrote, counted by kind. */
35
28
  export function wroteWords(wrote: RoutineLogEntryV1['wrote']): string {
36
29
  const counts = new Map<string, number>()
@@ -61,7 +54,7 @@ export interface RoutineLogLine {
61
54
  runId: string
62
55
  name: string
63
56
  kind: RoutineLogEntryV1['kind']
64
- /** "Ran", "Skipped: already waiting", "Paused after 12 runs in a row". */
57
+ /** "Ran", "Skipped: already waiting", "Paused after 12 runs in a row", or a note's own sentence. */
65
58
  outcome: string
66
59
  /** "wrote 2 entries" — a run's, when it wrote anything. */
67
60
  wrote: string | null
@@ -69,15 +62,6 @@ export interface RoutineLogLine {
69
62
  runNow: boolean
70
63
  }
71
64
 
72
- /** A reason that is already its own sentence ("Skipped: …", "Paused …") is the outcome. */
73
- function outcomeOf(e: RoutineLogEntryV1): string {
74
- const base = OUTCOME[e.kind] ?? e.kind
75
- const reason = e.reason?.trim()
76
- if (!reason) return base
77
- if (/^(skipped|paused)\b/i.test(reason)) return reason
78
- return `${base}: ${reason}`
79
- }
80
-
81
65
  export interface RoutineLogView {
82
66
  /** The runs since anyone last played — "while you were away". */
83
67
  away: RoutineLogLine[]
@@ -87,15 +71,15 @@ export interface RoutineLogView {
87
71
  empty: string | null
88
72
  }
89
73
 
90
- /** The answer, split around the last time anyone played, skipped lines kept or not. */
74
+ /** The answer, split around the last time anyone played; skipped and paused lines follow Show skipped, a note always shows. */
91
75
  export function routineLogView(answer: RoutineLogV1 | null, settings: RoutineLogSettings, now: number): RoutineLogView {
92
76
  if (!answer) return { away: [], earlier: [], empty: null }
93
- const entries = answer.entries.filter((e) => settings.skipped || e.kind === 'ran' || e.kind === 'failed' || e.kind === 'stopped')
77
+ const entries = answer.entries.filter((e) => settings.skipped || e.kind === 'ran' || e.kind === 'failed' || e.kind === 'stopped' || e.kind === 'remarked')
94
78
  const line = (e: RoutineLogEntryV1): RoutineLogLine => ({
95
79
  runId: e.runId,
96
80
  name: e.name,
97
81
  kind: e.kind,
98
- outcome: outcomeOf(e),
82
+ outcome: routineLogOutcomeWords(e.kind, e.reason),
99
83
  wrote: e.kind === 'ran' && e.wrote.length ? `wrote ${wroteWords(e.wrote)}` : null,
100
84
  when: agoWords(e.endedAt || e.startedAt, now),
101
85
  runNow: !!e.runNow,
@@ -164,7 +164,7 @@
164
164
  {@const listId = `session-run-steps-${run.runId}`}
165
165
  <li
166
166
  data-widget-part="session-runs.entry row"
167
- data-outcome={run.outcome}
167
+ data-outcome={run.routineKind ? undefined : run.outcome}
168
168
  data-preview={run.preview ? "" : undefined}
169
169
  data-open={isOpen ? "" : undefined}
170
170
  data-depth={run.depth > 0 ? run.depth : undefined}
@@ -176,7 +176,9 @@
176
176
  {/if}
177
177
  <span data-widget-part="session-runs.started-by">{startedBy(run, sourceOf(run.runId))}</span>
178
178
  <span data-widget-part="session-runs.when">{t(run.when)}</span>
179
- <span data-widget-part="session-runs.duration">{t(run.duration)}</span>
179
+ {#if run.duration}
180
+ <span data-widget-part="session-runs.duration">{t(run.duration)}</span>
181
+ {/if}
180
182
  {#if run.tokens}
181
183
  <span data-widget-part="session-runs.tokens">{t(run.tokens)}</span>
182
184
  {/if}
@@ -184,16 +186,18 @@
184
186
  <span data-widget-part="session-runs.stopped-at">{run.stoppedAt}</span>
185
187
  {/if}
186
188
  <span data-widget-part="session-runs.actions">
187
- <button
188
- type="button"
189
- data-widget-part="session-runs.steps-toggle"
190
- aria-expanded={isOpen}
191
- aria-controls={listId}
192
- onclick={() => toggleSteps(run)}
193
- >
194
- <sp-icon name="list-tree" size="12"></sp-icon>
195
- {t("Steps")}
196
- </button>
189
+ {#if !run.routineKind}
190
+ <button
191
+ type="button"
192
+ data-widget-part="session-runs.steps-toggle"
193
+ aria-expanded={isOpen}
194
+ aria-controls={listId}
195
+ onclick={() => toggleSteps(run)}
196
+ >
197
+ <sp-icon name="list-tree" size="12"></sp-icon>
198
+ {t("Steps")}
199
+ </button>
200
+ {/if}
197
201
  <button
198
202
  type="button"
199
203
  data-widget-part="session-runs.inspect"
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  paletteRowState,
3
3
  statusTextIn
4
- } from "./shared-M7AYID43.js";
5
- import "./shared-TNJZHTMT.js";
6
- import "./shared-6S23SGJB.js";
4
+ } from "./shared-W2BBJCNE.js";
5
+ import "./shared-JXYPKSTQ.js";
6
+ import "./shared-NICRJ4Z2.js";
7
7
  import "./shared-5E4RQYRX.js";
8
- import "./shared-ASZVJYPD.js";
8
+ import "./shared-EFMMT76D.js";
9
9
  import "./shared-LUIF6DW7.js";
10
10
  import {
11
11
  WIDGET_CONTEXT_KEY,
@@ -37,7 +37,7 @@ import {
37
37
  user_derived,
38
38
  user_effect,
39
39
  widgetRefFromComponent
40
- } from "./shared-7SWDK5MC.js";
40
+ } from "./shared-HEAKNNZB.js";
41
41
 
42
42
  // dist/shared/ui/actions/index.js
43
43
  var ACTIONS_GROUP_ORDER = Object.freeze([
@@ -1 +1 @@
1
- {"slug":"actions","framework":"svelte","entry":"shared/actions/actions.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/actions/Actions.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Actions widget as a remote component (W8): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport ActionsWidget from \"./ActionsWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"actions\", instanceId: \"actions\", title: \"Actions\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><ActionsWidget /></WidgetBoundary>\n","shared/actions/ActionsWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Actions (PLAN-core-widgets W8): what can I do right now — the session's\n\t * listed actions (`actions.v1`) as real buttons, each with its icon and\n\t * name, grouped from fields the listing carries: the turn controls, then\n\t * the genre's own, then the ones added to it (`actionsView`, the plain\n\t * half; this only draws it).\n\t *\n\t * A press is `invoke(identity)` — the same door the composer's chips\n\t * take, so a core verb reaches the page's own handler and an action that\n\t * collects text or recipients opens the page's collect modal before it\n\t * fires. A greyed action is greyed, not disabled: `aria-disabled` keeps it\n\t * in the tab order, its reason is its `title` and its description\n\t * (`actions.reason`), and the click is guarded — as the chips do.\n\t *\n\t * Drawing a newcomer is meeting it: the widget shows every action at\n\t * once, as opening **More** does in the composer, so the identities it\n\t * draws wearing the *new* mark are told to the page (`actions-seen`),\n\t * once each.\n\t *\n\t * ⚠ `showWaiting` (the questions waiting on the viewer) is declared and\n\t * not drawn: no section this widget reads carries a session's open forms.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part`, the size rides on the root's `data-size`, a\n\t * newcomer on its button's `data-new`, and the default widget stylesheet\n\t * draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { actionsView, readActionsSettings, type ActionsButtonView } from \"@serene-pub/core-catalog/actions\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadActionsSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tactionsView({\n\t\t\tactions: widget?.current.actions?.v1,\n\t\t\tsettings,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** An element id from an action's identity (`core#advance` → `core-advance`). */\n\tconst idOf = (identity: string): string => identity.replace(/[^a-zA-Z0-9-]/g, \"-\")\n\n\t/** The newcomers already told to the page — each once. */\n\tconst met = new Set<string>()\n\t$effect(() => {\n\t\tconst fresh = view.fresh.filter((k) => !met.has(k))\n\t\tif (!fresh.length) return\n\t\tfor (const k of fresh) met.add(k)\n\t\tvoid widget?.current.request(\"actions-seen\", { keys: fresh })?.catch(() => {})\n\t})\n\n\t/** Why the last press did not go through, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tfunction press(button: ActionsButtonView): void {\n\t\tif (button.disabled) return\n\t\trefusal = null\n\t\ttry {\n\t\t\twidget?.current.invoke(button.identity)\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n<div data-widget-part=\"actions.root\" data-size={settings.size}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"actions.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#each view.groups as group (group.key)}\n\t\t<div\n\t\t\tdata-widget-part=\"actions.group\"\n\t\t\tdata-group={group.key}\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={`actions-${uid}-${group.key}`}\n\t\t>\n\t\t\t<p data-widget-part=\"actions.group-head\" id={`actions-${uid}-${group.key}`}>{group.title}</p>\n\t\t\t{#each group.buttons as button (button.identity)}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"actions.button\"\n\t\t\t\t\tdata-identity={button.identity}\n\t\t\t\t\tdata-new={button.isNew ? \"\" : undefined}\n\t\t\t\t\taria-disabled={button.disabled ? \"true\" : undefined}\n\t\t\t\t\taria-describedby={button.reason ? `actions-${uid}-reason-${idOf(button.identity)}` : undefined}\n\t\t\t\t\ttitle={button.title}\n\t\t\t\t\tonclick={() => press(button)}\n\t\t\t\t>\n\t\t\t\t\t<sp-icon name={button.icon} size=\"16\"></sp-icon>\n\t\t\t\t\t<span>{button.name}</span>\n\t\t\t\t\t{#if button.reason}\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-widget-part=\"actions.reason\"\n\t\t\t\t\t\t\tid={`actions-${uid}-reason-${idOf(button.identity)}`}\n\t\t\t\t\t\t\taria-hidden=\"true\">{button.reason}</span\n\t\t\t\t\t\t>\n\t\t\t\t\t{/if}\n\t\t\t\t</button>\n\t\t\t{/each}\n\t\t</div>\n\t{/each}\n</div>\n","shared/actions/actions.ts":"/**\n * Core's `actions` component (PLAN-core-widgets W8): the session's actions as\n * buttons — the turn controls, the genre's own, the added ones — as the\n * page's UI worker runs it. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/actions.js`, the module the app\n * serves at `/core-ui/actions`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Actions from './Actions.svelte'\n\nexport default svelteComponent(Actions)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"ff0806304b059862e95bd914b200f09001a33c837b111c334bfa6987b6f307cf","catalogVersion":"0.6.0-pr-8"}
1
+ {"slug":"actions","framework":"svelte","entry":"shared/actions/actions.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/actions/Actions.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Actions widget as a remote component (W8): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport ActionsWidget from \"./ActionsWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"actions\", instanceId: \"actions\", title: \"Actions\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><ActionsWidget /></WidgetBoundary>\n","shared/actions/ActionsWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Actions (PLAN-core-widgets W8): what can I do right now — the session's\n\t * listed actions (`actions.v1`) as real buttons, each with its icon and\n\t * name, grouped from fields the listing carries: the turn controls, then\n\t * the genre's own, then the ones added to it (`actionsView`, the plain\n\t * half; this only draws it).\n\t *\n\t * A press is `invoke(identity)` — the same door the composer's chips\n\t * take, so a core verb reaches the page's own handler and an action that\n\t * collects text or recipients opens the page's collect modal before it\n\t * fires. A greyed action is greyed, not disabled: `aria-disabled` keeps it\n\t * in the tab order, its reason is its `title` and its description\n\t * (`actions.reason`), and the click is guarded — as the chips do.\n\t *\n\t * Drawing a newcomer is meeting it: the widget shows every action at\n\t * once, as opening **More** does in the composer, so the identities it\n\t * draws wearing the *new* mark are told to the page (`actions-seen`),\n\t * once each.\n\t *\n\t * ⚠ `showWaiting` (the questions waiting on the viewer) is declared and\n\t * not drawn: no section this widget reads carries a session's open forms.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part`, the size rides on the root's `data-size`, a\n\t * newcomer on its button's `data-new`, and the default widget stylesheet\n\t * draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { actionsView, readActionsSettings, type ActionsButtonView } from \"@serene-pub/core-catalog/actions\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadActionsSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tactionsView({\n\t\t\tactions: widget?.current.actions?.v1,\n\t\t\tsettings,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** An element id from an action's identity (`core#advance` → `core-advance`). */\n\tconst idOf = (identity: string): string => identity.replace(/[^a-zA-Z0-9-]/g, \"-\")\n\n\t/** The newcomers already told to the page — each once. */\n\tconst met = new Set<string>()\n\t$effect(() => {\n\t\tconst fresh = view.fresh.filter((k) => !met.has(k))\n\t\tif (!fresh.length) return\n\t\tfor (const k of fresh) met.add(k)\n\t\tvoid widget?.current.request(\"actions-seen\", { keys: fresh })?.catch(() => {})\n\t})\n\n\t/** Why the last press did not go through, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tfunction press(button: ActionsButtonView): void {\n\t\tif (button.disabled) return\n\t\trefusal = null\n\t\ttry {\n\t\t\twidget?.current.invoke(button.identity)\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n<div data-widget-part=\"actions.root\" data-size={settings.size}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"actions.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#each view.groups as group (group.key)}\n\t\t<div\n\t\t\tdata-widget-part=\"actions.group\"\n\t\t\tdata-group={group.key}\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={`actions-${uid}-${group.key}`}\n\t\t>\n\t\t\t<p data-widget-part=\"actions.group-head\" id={`actions-${uid}-${group.key}`}>{group.title}</p>\n\t\t\t{#each group.buttons as button (button.identity)}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"actions.button\"\n\t\t\t\t\tdata-identity={button.identity}\n\t\t\t\t\tdata-new={button.isNew ? \"\" : undefined}\n\t\t\t\t\taria-disabled={button.disabled ? \"true\" : undefined}\n\t\t\t\t\taria-describedby={button.reason ? `actions-${uid}-reason-${idOf(button.identity)}` : undefined}\n\t\t\t\t\ttitle={button.title}\n\t\t\t\t\tonclick={() => press(button)}\n\t\t\t\t>\n\t\t\t\t\t<sp-icon name={button.icon} size=\"16\"></sp-icon>\n\t\t\t\t\t<span>{button.name}</span>\n\t\t\t\t\t{#if button.reason}\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-widget-part=\"actions.reason\"\n\t\t\t\t\t\t\tid={`actions-${uid}-reason-${idOf(button.identity)}`}\n\t\t\t\t\t\t\taria-hidden=\"true\">{button.reason}</span\n\t\t\t\t\t\t>\n\t\t\t\t\t{/if}\n\t\t\t\t</button>\n\t\t\t{/each}\n\t\t</div>\n\t{/each}\n</div>\n","shared/actions/actions.ts":"/**\n * Core's `actions` component (PLAN-core-widgets W8): the session's actions as\n * buttons — the turn controls, the genre's own, the added ones — as the\n * page's UI worker runs it. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/actions.js`, the module the app\n * serves at `/core-ui/actions`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Actions from './Actions.svelte'\n\nexport default svelteComponent(Actions)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"ff0806304b059862e95bd914b200f09001a33c837b111c334bfa6987b6f307cf","catalogVersion":"0.6.0-pr-9"}
@@ -32,7 +32,7 @@ import {
32
32
  useWidgetContext,
33
33
  user_derived,
34
34
  widgetRefFromComponent
35
- } from "./shared-7SWDK5MC.js";
35
+ } from "./shared-HEAKNNZB.js";
36
36
 
37
37
  // dist/shared/ui/album/index.js
38
38
  var ALBUM_DEFAULTS = Object.freeze({
@@ -1 +1 @@
1
- {"slug":"album","framework":"svelte","entry":"shared/album/album.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/album/Album.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Album widget as a remote component (W2): the component context,\n\t * as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AlbumWidget from \"./AlbumWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"album\", instanceId: \"album\", title: \"Album\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AlbumWidget /></WidgetBoundary>\n","shared/album/AlbumWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Album (PLAN-core-widgets W2): what has this session shown me — every\n\t * picture on its lines (`messages.v1` parts), newest line first, as\n\t * square tiles. Each tile wears a corner glyph for where it came from —\n\t * a paperclip for what a person attached, sparkles for what a run\n\t * generated — and names who showed it and when on hover or focus. A\n\t * press opens the page's lightbox (`view-image`) on that picture, with\n\t * the whole album as its pages in the order drawn. Everything it shows is\n\t * worked out in the plain half (`albumItems`); this only draws it.\n\t *\n\t * `arrangement: latest` draws the newest picture large (the `fitted`\n\t * representation) and the rest as a thumbnail strip, so an illustrated\n\t * scene can sit beside the log as it is generated.\n\t *\n\t * A picture whose file is gone (deleted from the Media panel) raises\n\t * `error` and is drawn as *File no longer available*, never a broken\n\t * image, and leaves the lightbox's pages — the media strip's rule.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`album.tile`, …), the settings ride on the root's\n\t * `data-tile` and `data-arrangement`, a tile's origin on `data-origin`,\n\t * and the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { SvelteSet } from \"svelte/reactivity\"\n\timport {\n\t\tALBUM_ORIGIN_NAMES,\n\t\talbumItems,\n\t\talbumOpenLabel,\n\t\talbumSrc,\n\t\talbumViewImageParams,\n\t\treadAlbumSettings,\n\t\ttype AlbumItem\n\t} from \"@serene-pub/core-catalog/album\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\tconst settings = $derived(\n\t\treadAlbumSettings(widget?.current.settings?.v1)\n\t)\n\tconst items = $derived(\n\t\talbumItems(widget?.current.messages?.v1, settings, {\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Pictures whose file failed to load, by part id. */\n\tconst missing = new SvelteSet<number>()\n\t/** What the lightbox pages through: every picture still there, in the order drawn. */\n\tconst openable = $derived(items.filter((i) => !missing.has(i.partId)))\n\n\tconst latest = $derived(settings.arrangement === \"latest\")\n\tconst lead = $derived(items[0])\n\tconst rest = $derived(items.slice(1))\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function open(item: AlbumItem): Promise<void> {\n\t\tconst index = openable.findIndex((i) => i.partId === item.partId)\n\t\tif (index < 0) return\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait widget?.current.request(\"view-image\", albumViewImageParams(openable, index))\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n\n\tfunction label(item: AlbumItem): string {\n\t\tconst at = openable.findIndex((i) => i.partId === item.partId)\n\t\treturn albumOpenLabel(item, at, openable.length, t)\n\t}\n\n\tconst count = $derived(\n\t\titems.length === 1 ? t(\"1 picture\") : `${items.length} ${t(\"pictures\")}`\n\t)\n</script>\n\n{#snippet tile(item: AlbumItem, big: boolean)}\n\t{#if missing.has(item.partId)}\n\t\t<div\n\t\t\tdata-widget-part=\"album.tile\"\n\t\t\tdata-origin={item.origin}\n\t\t\tdata-missing=\"\"\n\t\t\trole=\"img\"\n\t\t\taria-label={`${item.label}: ${t(\"File no longer available\")}`}\n\t\t>\n\t\t\t<sp-icon name=\"image-off\" size=\"20\"></sp-icon>\n\t\t\t<span>{t(\"File no longer available\")}</span>\n\t\t</div>\n\t{:else}\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"album.tile\"\n\t\t\tdata-origin={item.origin}\n\t\t\tdata-part-id={item.partId}\n\t\t\tdata-message-id={item.messageId}\n\t\t\taria-label={label(item)}\n\t\t\tonclick={() => open(item)}\n\t\t>\n\t\t\t<img\n\t\t\t\tsrc={albumSrc(item.assetId, big ? \"fitted\" : \"thumb\")}\n\t\t\t\talt=\"\"\n\t\t\t\tloading=\"lazy\"\n\t\t\t\tdecoding=\"async\"\n\t\t\t\tonerror={() => missing.add(item.partId)}\n\t\t\t/>\n\t\t\t<span data-widget-part=\"album.origin\" title={t(ALBUM_ORIGIN_NAMES[item.origin])} aria-hidden=\"true\">\n\t\t\t\t<sp-icon name={item.origin === \"attached\" ? \"paperclip\" : \"sparkles\"} size=\"12\"></sp-icon>\n\t\t\t</span>\n\t\t\t{#if item.caption}\n\t\t\t\t<span data-widget-part=\"album.caption\" aria-hidden=\"true\">{item.caption}</span>\n\t\t\t{/if}\n\t\t</button>\n\t{/if}\n{/snippet}\n\n<div\n\tdata-widget-part=\"album.root\"\n\tdata-tile={settings.tile}\n\tdata-arrangement={settings.arrangement}\n\tdata-source={settings.source}\n\trole=\"group\"\n\taria-label={t(\"Album\")}\n>\n\t{#if refusal}\n\t\t<p data-widget-part=\"album.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if items.length}\n\t\t<p data-widget-part=\"album.toolbar toolbar\">{count}</p>\n\t\t{#if latest}\n\t\t\t{#if lead}\n\t\t\t\t<div data-widget-part=\"album.latest\">\n\t\t\t\t\t{@render tile(lead, true)}\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t\t{#if rest.length}\n\t\t\t\t<ul data-widget-part=\"album.strip list\">\n\t\t\t\t\t{#each rest as item (item.partId)}\n\t\t\t\t\t\t<li>{@render tile(item, false)}</li>\n\t\t\t\t\t{/each}\n\t\t\t\t</ul>\n\t\t\t{/if}\n\t\t{:else}\n\t\t\t<ul data-widget-part=\"album.grid list\">\n\t\t\t\t{#each items as item (item.partId)}\n\t\t\t\t\t<li>{@render tile(item, false)}</li>\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t{/if}\n\t{/if}\n</div>\n","shared/album/album.ts":"/**\n * Core's `album` component (PLAN-core-widgets W2): every picture on the\n * session's lines, newest first, as the page's UI worker runs it. `npm run\n * build` compiles it with the CLI's component bundler to\n * `dist/components/album.js`, the module the app serves at `/core-ui/album`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Album from './Album.svelte'\n\nexport default svelteComponent(Album)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"c35bb2832eccdb5fd796b79ff931782e9afe9ee7b588742ad0877b261ba8e152","catalogVersion":"0.6.0-pr-8"}
1
+ {"slug":"album","framework":"svelte","entry":"shared/album/album.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/album/Album.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Album widget as a remote component (W2): the component context,\n\t * as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AlbumWidget from \"./AlbumWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"album\", instanceId: \"album\", title: \"Album\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AlbumWidget /></WidgetBoundary>\n","shared/album/AlbumWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Album (PLAN-core-widgets W2): what has this session shown me — every\n\t * picture on its lines (`messages.v1` parts), newest line first, as\n\t * square tiles. Each tile wears a corner glyph for where it came from —\n\t * a paperclip for what a person attached, sparkles for what a run\n\t * generated — and names who showed it and when on hover or focus. A\n\t * press opens the page's lightbox (`view-image`) on that picture, with\n\t * the whole album as its pages in the order drawn. Everything it shows is\n\t * worked out in the plain half (`albumItems`); this only draws it.\n\t *\n\t * `arrangement: latest` draws the newest picture large (the `fitted`\n\t * representation) and the rest as a thumbnail strip, so an illustrated\n\t * scene can sit beside the log as it is generated.\n\t *\n\t * A picture whose file is gone (deleted from the Media panel) raises\n\t * `error` and is drawn as *File no longer available*, never a broken\n\t * image, and leaves the lightbox's pages — the media strip's rule.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`album.tile`, …), the settings ride on the root's\n\t * `data-tile` and `data-arrangement`, a tile's origin on `data-origin`,\n\t * and the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { SvelteSet } from \"svelte/reactivity\"\n\timport {\n\t\tALBUM_ORIGIN_NAMES,\n\t\talbumItems,\n\t\talbumOpenLabel,\n\t\talbumSrc,\n\t\talbumViewImageParams,\n\t\treadAlbumSettings,\n\t\ttype AlbumItem\n\t} from \"@serene-pub/core-catalog/album\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\tconst settings = $derived(\n\t\treadAlbumSettings(widget?.current.settings?.v1)\n\t)\n\tconst items = $derived(\n\t\talbumItems(widget?.current.messages?.v1, settings, {\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Pictures whose file failed to load, by part id. */\n\tconst missing = new SvelteSet<number>()\n\t/** What the lightbox pages through: every picture still there, in the order drawn. */\n\tconst openable = $derived(items.filter((i) => !missing.has(i.partId)))\n\n\tconst latest = $derived(settings.arrangement === \"latest\")\n\tconst lead = $derived(items[0])\n\tconst rest = $derived(items.slice(1))\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function open(item: AlbumItem): Promise<void> {\n\t\tconst index = openable.findIndex((i) => i.partId === item.partId)\n\t\tif (index < 0) return\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait widget?.current.request(\"view-image\", albumViewImageParams(openable, index))\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n\n\tfunction label(item: AlbumItem): string {\n\t\tconst at = openable.findIndex((i) => i.partId === item.partId)\n\t\treturn albumOpenLabel(item, at, openable.length, t)\n\t}\n\n\tconst count = $derived(\n\t\titems.length === 1 ? t(\"1 picture\") : `${items.length} ${t(\"pictures\")}`\n\t)\n</script>\n\n{#snippet tile(item: AlbumItem, big: boolean)}\n\t{#if missing.has(item.partId)}\n\t\t<div\n\t\t\tdata-widget-part=\"album.tile\"\n\t\t\tdata-origin={item.origin}\n\t\t\tdata-missing=\"\"\n\t\t\trole=\"img\"\n\t\t\taria-label={`${item.label}: ${t(\"File no longer available\")}`}\n\t\t>\n\t\t\t<sp-icon name=\"image-off\" size=\"20\"></sp-icon>\n\t\t\t<span>{t(\"File no longer available\")}</span>\n\t\t</div>\n\t{:else}\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"album.tile\"\n\t\t\tdata-origin={item.origin}\n\t\t\tdata-part-id={item.partId}\n\t\t\tdata-message-id={item.messageId}\n\t\t\taria-label={label(item)}\n\t\t\tonclick={() => open(item)}\n\t\t>\n\t\t\t<img\n\t\t\t\tsrc={albumSrc(item.assetId, big ? \"fitted\" : \"thumb\")}\n\t\t\t\talt=\"\"\n\t\t\t\tloading=\"lazy\"\n\t\t\t\tdecoding=\"async\"\n\t\t\t\tonerror={() => missing.add(item.partId)}\n\t\t\t/>\n\t\t\t<span data-widget-part=\"album.origin\" title={t(ALBUM_ORIGIN_NAMES[item.origin])} aria-hidden=\"true\">\n\t\t\t\t<sp-icon name={item.origin === \"attached\" ? \"paperclip\" : \"sparkles\"} size=\"12\"></sp-icon>\n\t\t\t</span>\n\t\t\t{#if item.caption}\n\t\t\t\t<span data-widget-part=\"album.caption\" aria-hidden=\"true\">{item.caption}</span>\n\t\t\t{/if}\n\t\t</button>\n\t{/if}\n{/snippet}\n\n<div\n\tdata-widget-part=\"album.root\"\n\tdata-tile={settings.tile}\n\tdata-arrangement={settings.arrangement}\n\tdata-source={settings.source}\n\trole=\"group\"\n\taria-label={t(\"Album\")}\n>\n\t{#if refusal}\n\t\t<p data-widget-part=\"album.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if items.length}\n\t\t<p data-widget-part=\"album.toolbar toolbar\">{count}</p>\n\t\t{#if latest}\n\t\t\t{#if lead}\n\t\t\t\t<div data-widget-part=\"album.latest\">\n\t\t\t\t\t{@render tile(lead, true)}\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t\t{#if rest.length}\n\t\t\t\t<ul data-widget-part=\"album.strip list\">\n\t\t\t\t\t{#each rest as item (item.partId)}\n\t\t\t\t\t\t<li>{@render tile(item, false)}</li>\n\t\t\t\t\t{/each}\n\t\t\t\t</ul>\n\t\t\t{/if}\n\t\t{:else}\n\t\t\t<ul data-widget-part=\"album.grid list\">\n\t\t\t\t{#each items as item (item.partId)}\n\t\t\t\t\t<li>{@render tile(item, false)}</li>\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t{/if}\n\t{/if}\n</div>\n","shared/album/album.ts":"/**\n * Core's `album` component (PLAN-core-widgets W2): every picture on the\n * session's lines, newest first, as the page's UI worker runs it. `npm run\n * build` compiles it with the CLI's component bundler to\n * `dist/components/album.js`, the module the app serves at `/core-ui/album`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Album from './Album.svelte'\n\nexport default svelteComponent(Album)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"c35bb2832eccdb5fd796b79ff931782e9afe9ee7b588742ad0877b261ba8e152","catalogVersion":"0.6.0-pr-9"}
@@ -34,7 +34,7 @@ import {
34
34
  user_derived,
35
35
  user_effect,
36
36
  widgetRefFromComponent
37
- } from "./shared-7SWDK5MC.js";
37
+ } from "./shared-HEAKNNZB.js";
38
38
 
39
39
  // ../sdk/dist/annexFields.js
40
40
  var ANNEX_FIELD_KEY = /^[a-z][a-z0-9-]*$/;
@@ -1 +1 @@
1
- {"slug":"annex","framework":"svelte","entry":"shared/annex/annex.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/annex/Annex.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Annex widget as a remote component (W9): the component context,\n\t * as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AnnexWidget from \"./AnnexWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"annex\", instanceId: \"annex\", title: \"Annex\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AnnexWidget /></WidgetBoundary>\n","shared/annex/AnnexWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Annex (PLAN-core-widgets W9): what the pipeline knows that I may see —\n\t * one declared annex key, by its label, from the viewer's own view of the\n\t * annex (`annex.v1`). Text is prose, a number or a choice one row, a list\n\t * chips, an object a row per member. Everything it shows is worked out in\n\t * the plain half (`annexWidgetView`); this only draws it.\n\t *\n\t * Never silent: with no key picked, nothing written, or nothing the\n\t * viewer may see, it says which, in one line.\n\t *\n\t * **Edit** is the Session data list's: a text field the host lists as the\n\t * viewer's to set gets an Edit button, which opens the text in place;\n\t * Save presses the field's ready-made action (`<owner>:annex#<key>`) with\n\t * `{ value }` — the same door and the same write. The new value comes\n\t * back through `annex.v1`; a refusal is the page's to say.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`annex.prose`, `annex.row row`, …), the state and\n\t * the drawn shape ride on the root's `data-state` and `data-shape`, and\n\t * the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport {\n\t\tannexWidgetFieldsFrom,\n\t\tannexWidgetView,\n\t\treadAnnexWidgetSettings\n\t} from \"@serene-pub/core-catalog/annex\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadAnnexWidgetSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tannexWidgetView({\n\t\t\tannex: widget?.current.annex?.v1,\n\t\t\tfields: annexWidgetFieldsFrom(widget?.current.actions?.v1),\n\t\t\tkey: settings.key,\n\t\t\tviewer: widget?.current.viewer?.v1,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** The editor, open, and its text. */\n\tlet editing = $state(false)\n\tlet draft = $state(\"\")\n\t/** Why the last Save did not go through, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\t// Another key picked: an open editor was for the old one. Keyed on the\n\t// identity alone, so a value pushed while someone types leaves it open.\n\tconst identity = $derived(view.identity)\n\t$effect(() => {\n\t\tvoid identity\n\t\tediting = false\n\t})\n\n\tfunction startEdit(): void {\n\t\tdraft = view.draft\n\t\trefusal = null\n\t\tediting = true\n\t}\n\n\tfunction save(): void {\n\t\tif (!identity) return\n\t\trefusal = null\n\t\ttry {\n\t\t\twidget?.current.invoke(identity, { payload: { value: draft } })\n\t\t\tediting = false\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n<div\n\tdata-widget-part=\"annex.root\"\n\tdata-state={view.state}\n\tdata-shape={view.state === \"value\" ? view.shape : undefined}\n\trole=\"group\"\n\taria-label={view.title}\n>\n\t{#if refusal}\n\t\t<p data-widget-part=\"annex.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if settings.showLabel && view.state !== \"pick\"}\n\t\t<p data-widget-part=\"annex.label label\">{view.title}</p>\n\t{/if}\n\n\t{#if editing && identity}\n\t\t<div data-widget-part=\"annex.editor\">\n\t\t\t<textarea\n\t\t\t\tid={`annex-${uid}-text`}\n\t\t\t\tdata-widget-part=\"annex.text\"\n\t\t\t\taria-label={view.title}\n\t\t\t\tbind:value={draft}\n\t\t\t></textarea>\n\t\t\t<div data-widget-part=\"annex.editor-actions toolbar\">\n\t\t\t\t<button type=\"button\" data-widget-part=\"annex.cancel\" onclick={() => (editing = false)}>\n\t\t\t\t\t{t(\"Cancel\")}\n\t\t\t\t</button>\n\t\t\t\t<button type=\"button\" data-widget-part=\"annex.save\" onclick={save}>\n\t\t\t\t\t{t(\"Save\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t{:else if view.state === \"value\"}\n\t\t<div data-widget-part=\"annex.value value\">\n\t\t\t{#if view.drawn.as === \"prose\"}\n\t\t\t\t<p data-widget-part=\"annex.prose\">{view.drawn.text}</p>\n\t\t\t{:else if view.drawn.as === \"chips\"}\n\t\t\t\t<ul data-widget-part=\"annex.chips list\" aria-label={view.title}>\n\t\t\t\t\t{#each view.drawn.chips as chip, i (i)}\n\t\t\t\t\t\t<li data-widget-part=\"annex.chip chip\">{chip}</li>\n\t\t\t\t\t{/each}\n\t\t\t\t</ul>\n\t\t\t{:else}\n\t\t\t\t<dl data-widget-part=\"annex.rows list\">\n\t\t\t\t\t{#each view.drawn.rows as row (row.key)}\n\t\t\t\t\t\t<div data-widget-part=\"annex.row row\" data-key={row.key}>\n\t\t\t\t\t\t\t<dt data-widget-part=\"annex.row-label label\">{row.label}</dt>\n\t\t\t\t\t\t\t{#if row.items}\n\t\t\t\t\t\t\t\t<dd data-widget-part=\"annex.row-value value\">\n\t\t\t\t\t\t\t\t\t{#if row.items.length}\n\t\t\t\t\t\t\t\t\t\t<ul data-widget-part=\"annex.row-items\">\n\t\t\t\t\t\t\t\t\t\t\t{#each row.items as item, i (i)}\n\t\t\t\t\t\t\t\t\t\t\t\t<li data-widget-part=\"annex.row-item\">{item}</li>\n\t\t\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</dd>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<dd data-widget-part=\"annex.row-value value\">{row.text}</dd>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/each}\n\t\t\t\t</dl>\n\t\t\t{/if}\n\t\t</div>\n\t{:else if view.state === \"hidden\" || view.state === \"pick\"}\n\t\t<div data-widget-part=\"annex.empty empty\" role=\"status\">\n\t\t\t<sp-icon name=\"clipboard-list\" size=\"20\"></sp-icon>\n\t\t\t<span>{view.empty}</span>\n\t\t</div>\n\t{/if}\n\n\t{#if view.canEdit && !editing}\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"annex.edit\"\n\t\t\taria-label={`${t(\"Edit\")} ${view.title}`}\n\t\t\tonclick={startEdit}\n\t\t>\n\t\t\t<sp-icon name=\"pencil\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Edit\")}</span>\n\t\t</button>\n\t{/if}\n</div>\n","shared/annex/annex.ts":"/**\n * Core's `annex` component (PLAN-core-widgets W9): one declared annex key, by\n * its label, in the shape it was declared in, as the page's UI worker runs\n * it. `npm run build` compiles it with the CLI's component bundler to\n * `dist/components/annex.js`, the module the app serves at `/core-ui/annex`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Annex from './Annex.svelte'\n\nexport default svelteComponent(Annex)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"d889831df761eb3df5aad25c6105f80b59570ee9f2c1d05c32aadfcb26821fc0","catalogVersion":"0.6.0-pr-8"}
1
+ {"slug":"annex","framework":"svelte","entry":"shared/annex/annex.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/annex/Annex.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Annex widget as a remote component (W9): the component context,\n\t * as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AnnexWidget from \"./AnnexWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"annex\", instanceId: \"annex\", title: \"Annex\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AnnexWidget /></WidgetBoundary>\n","shared/annex/AnnexWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Annex (PLAN-core-widgets W9): what the pipeline knows that I may see —\n\t * one declared annex key, by its label, from the viewer's own view of the\n\t * annex (`annex.v1`). Text is prose, a number or a choice one row, a list\n\t * chips, an object a row per member. Everything it shows is worked out in\n\t * the plain half (`annexWidgetView`); this only draws it.\n\t *\n\t * Never silent: with no key picked, nothing written, or nothing the\n\t * viewer may see, it says which, in one line.\n\t *\n\t * **Edit** is the Session data list's: a text field the host lists as the\n\t * viewer's to set gets an Edit button, which opens the text in place;\n\t * Save presses the field's ready-made action (`<owner>:annex#<key>`) with\n\t * `{ value }` — the same door and the same write. The new value comes\n\t * back through `annex.v1`; a refusal is the page's to say.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`annex.prose`, `annex.row row`, …), the state and\n\t * the drawn shape ride on the root's `data-state` and `data-shape`, and\n\t * the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport {\n\t\tannexWidgetFieldsFrom,\n\t\tannexWidgetView,\n\t\treadAnnexWidgetSettings\n\t} from \"@serene-pub/core-catalog/annex\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\tconst uid = $props.id()\n\n\tconst settings = $derived(\n\t\treadAnnexWidgetSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tannexWidgetView({\n\t\t\tannex: widget?.current.annex?.v1,\n\t\t\tfields: annexWidgetFieldsFrom(widget?.current.actions?.v1),\n\t\t\tkey: settings.key,\n\t\t\tviewer: widget?.current.viewer?.v1,\n\t\t\tlocale: widget?.current.locale?.v1,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** The editor, open, and its text. */\n\tlet editing = $state(false)\n\tlet draft = $state(\"\")\n\t/** Why the last Save did not go through, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\t// Another key picked: an open editor was for the old one. Keyed on the\n\t// identity alone, so a value pushed while someone types leaves it open.\n\tconst identity = $derived(view.identity)\n\t$effect(() => {\n\t\tvoid identity\n\t\tediting = false\n\t})\n\n\tfunction startEdit(): void {\n\t\tdraft = view.draft\n\t\trefusal = null\n\t\tediting = true\n\t}\n\n\tfunction save(): void {\n\t\tif (!identity) return\n\t\trefusal = null\n\t\ttry {\n\t\t\twidget?.current.invoke(identity, { payload: { value: draft } })\n\t\t\tediting = false\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n<div\n\tdata-widget-part=\"annex.root\"\n\tdata-state={view.state}\n\tdata-shape={view.state === \"value\" ? view.shape : undefined}\n\trole=\"group\"\n\taria-label={view.title}\n>\n\t{#if refusal}\n\t\t<p data-widget-part=\"annex.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if settings.showLabel && view.state !== \"pick\"}\n\t\t<p data-widget-part=\"annex.label label\">{view.title}</p>\n\t{/if}\n\n\t{#if editing && identity}\n\t\t<div data-widget-part=\"annex.editor\">\n\t\t\t<textarea\n\t\t\t\tid={`annex-${uid}-text`}\n\t\t\t\tdata-widget-part=\"annex.text\"\n\t\t\t\taria-label={view.title}\n\t\t\t\tbind:value={draft}\n\t\t\t></textarea>\n\t\t\t<div data-widget-part=\"annex.editor-actions toolbar\">\n\t\t\t\t<button type=\"button\" data-widget-part=\"annex.cancel\" onclick={() => (editing = false)}>\n\t\t\t\t\t{t(\"Cancel\")}\n\t\t\t\t</button>\n\t\t\t\t<button type=\"button\" data-widget-part=\"annex.save\" onclick={save}>\n\t\t\t\t\t{t(\"Save\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t{:else if view.state === \"value\"}\n\t\t<div data-widget-part=\"annex.value value\">\n\t\t\t{#if view.drawn.as === \"prose\"}\n\t\t\t\t<p data-widget-part=\"annex.prose\">{view.drawn.text}</p>\n\t\t\t{:else if view.drawn.as === \"chips\"}\n\t\t\t\t<ul data-widget-part=\"annex.chips list\" aria-label={view.title}>\n\t\t\t\t\t{#each view.drawn.chips as chip, i (i)}\n\t\t\t\t\t\t<li data-widget-part=\"annex.chip chip\">{chip}</li>\n\t\t\t\t\t{/each}\n\t\t\t\t</ul>\n\t\t\t{:else}\n\t\t\t\t<dl data-widget-part=\"annex.rows list\">\n\t\t\t\t\t{#each view.drawn.rows as row (row.key)}\n\t\t\t\t\t\t<div data-widget-part=\"annex.row row\" data-key={row.key}>\n\t\t\t\t\t\t\t<dt data-widget-part=\"annex.row-label label\">{row.label}</dt>\n\t\t\t\t\t\t\t{#if row.items}\n\t\t\t\t\t\t\t\t<dd data-widget-part=\"annex.row-value value\">\n\t\t\t\t\t\t\t\t\t{#if row.items.length}\n\t\t\t\t\t\t\t\t\t\t<ul data-widget-part=\"annex.row-items\">\n\t\t\t\t\t\t\t\t\t\t\t{#each row.items as item, i (i)}\n\t\t\t\t\t\t\t\t\t\t\t\t<li data-widget-part=\"annex.row-item\">{item}</li>\n\t\t\t\t\t\t\t\t\t\t\t{/each}\n\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t</dd>\n\t\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t\t<dd data-widget-part=\"annex.row-value value\">{row.text}</dd>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/each}\n\t\t\t\t</dl>\n\t\t\t{/if}\n\t\t</div>\n\t{:else if view.state === \"hidden\" || view.state === \"pick\"}\n\t\t<div data-widget-part=\"annex.empty empty\" role=\"status\">\n\t\t\t<sp-icon name=\"clipboard-list\" size=\"20\"></sp-icon>\n\t\t\t<span>{view.empty}</span>\n\t\t</div>\n\t{/if}\n\n\t{#if view.canEdit && !editing}\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-widget-part=\"annex.edit\"\n\t\t\taria-label={`${t(\"Edit\")} ${view.title}`}\n\t\t\tonclick={startEdit}\n\t\t>\n\t\t\t<sp-icon name=\"pencil\" size=\"14\"></sp-icon>\n\t\t\t<span>{t(\"Edit\")}</span>\n\t\t</button>\n\t{/if}\n</div>\n","shared/annex/annex.ts":"/**\n * Core's `annex` component (PLAN-core-widgets W9): one declared annex key, by\n * its label, in the shape it was declared in, as the page's UI worker runs\n * it. `npm run build` compiles it with the CLI's component bundler to\n * `dist/components/annex.js`, the module the app serves at `/core-ui/annex`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Annex from './Annex.svelte'\n\nexport default svelteComponent(Annex)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"d889831df761eb3df5aad25c6105f80b59570ee9f2c1d05c32aadfcb26821fc0","catalogVersion":"0.6.0-pr-9"}
@@ -30,7 +30,7 @@ import {
30
30
  user_derived,
31
31
  user_effect,
32
32
  widgetRefFromComponent
33
- } from "./shared-7SWDK5MC.js";
33
+ } from "./shared-HEAKNNZB.js";
34
34
 
35
35
  // dist/shared/ui/attendance/index.js
36
36
  var ATTENDANCE_DEFAULTS = Object.freeze({
@@ -1 +1 @@
1
- {"slug":"attendance","framework":"svelte","entry":"shared/attendance/attendance.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/attendance/Attendance.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Who's here widget as a remote component (W10): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AttendanceWidget from \"./AttendanceWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"attendance\", instanceId: \"attendance\", title: \"Who's here\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AttendanceWidget /></WidgetBoundary>\n","shared/attendance/AttendanceWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Who's here (PLAN-core-widgets W10): which people have this session open\n\t * now, as whom each writes, and who is typing — the session's attendance\n\t * (`attendance.v1`), drawn as two groups.\n\t *\n\t * **Here**: a row per person with the session open — their name, *you*\n\t * on the viewer's own, the persona each writes as (face and name, from\n\t * the cast), a typing pulse while one of their personas is typing, and\n\t * *Owner* / *Guest* as a quiet chip. Under it, *Nobody else is here.*\n\t * when the viewer has the room to themselves. **Away**: the session's\n\t * other people, with when they were last here (off with `showAway`). A\n\t * press on a persona opens its sheet (`open-character`). Everything it\n\t * shows is worked out in the plain half (`attendanceView`); this only\n\t * draws it, and keeps the clock the Away times are told from.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`attendance.person row`, …), the row's state rides\n\t * on `data-state`, and the default widget stylesheet draws them\n\t * (STYLE-GUIDE §6.16).\n\t */\n\timport type { ViewerV1 } from \"@serene-pub/sdk/component\"\n\timport { attendanceView, readAttendanceSettings } from \"@serene-pub/core-catalog/attendance\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\t/** The clock the Away rows' \"Last here …\" are told from, moved once a minute. */\n\tlet now = $state(Date.now())\n\t$effect(() => {\n\t\tconst tick = setInterval(() => (now = Date.now()), 60_000)\n\t\treturn () => clearInterval(tick)\n\t})\n\n\tconst settings = $derived(\n\t\treadAttendanceSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tattendanceView({\n\t\t\tattendance: widget?.current.attendance?.v1,\n\t\t\tcharacters: widget?.current.scope(\"characters\"),\n\t\t\tviewer: widget?.current.viewer?.v1 ?? NOBODY,\n\t\t\tsettings,\n\t\t\tnow,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function openPersona(characterId: number): Promise<void> {\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait widget?.current.request(\"open-character\", { characterId })\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n{#snippet personRow(person: (typeof view.here)[number], state: \"here\" | \"away\")}\n\t<li\n\t\tdata-widget-part=\"attendance.person row\"\n\t\tdata-state={state}\n\t\tdata-role={person.role}\n\t\tdata-you={person.you ? \"\" : undefined}\n\t\tdata-typing={person.typing ? \"\" : undefined}\n\t>\n\t\t<span data-widget-part=\"attendance.name\">{person.name}</span>\n\t\t{#if person.you}\n\t\t\t<span data-widget-part=\"attendance.you\">{t(\"you\")}</span>\n\t\t{/if}\n\t\t{#each person.personas as persona (persona.ref)}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"attendance.persona\"\n\t\t\t\tdata-ref={persona.ref}\n\t\t\t\ttitle={t(\"Open {name}\").replace(\"{name}\", persona.name)}\n\t\t\t\tonclick={() => openPersona(persona.characterId)}\n\t\t\t>\n\t\t\t\t{#if settings.faces}\n\t\t\t\t\t{#if persona.face}\n\t\t\t\t\t\t<img data-widget-part=\"attendance.face\" src={persona.face} alt=\"\" />\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<span data-widget-part=\"attendance.face\" data-blank=\"\">\n\t\t\t\t\t\t\t<sp-icon name=\"user-round\" size=\"12\"></sp-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t{/if}\n\t\t\t\t{/if}\n\t\t\t\t<span>{persona.name}</span>\n\t\t\t</button>\n\t\t{/each}\n\t\t{#if person.typing}\n\t\t\t<span data-widget-part=\"attendance.typing\" role=\"status\">{t(\"typing…\")}</span>\n\t\t{/if}\n\t\t{#if person.lastHere}\n\t\t\t<span data-widget-part=\"attendance.away\">{person.lastHere}</span>\n\t\t{/if}\n\t\t<span data-widget-part=\"attendance.role chip\">{person.roleChip}</span>\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"attendance.root\" data-faces={settings.faces ? \"\" : undefined}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"attendance.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if view.here.length}\n\t\t<section data-widget-part=\"attendance.group\" data-group=\"here\" aria-label={t(\"Here\")}>\n\t\t\t<h3 data-widget-part=\"attendance.group-head\">{t(\"Here\")}</h3>\n\t\t\t<ul data-widget-part=\"attendance.list list\">\n\t\t\t\t{#each view.here as person (person.key)}\n\t\t\t\t\t{@render personRow(person, \"here\")}\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t</section>\n\t{/if}\n\n\t{#if view.away.length}\n\t\t<section data-widget-part=\"attendance.group\" data-group=\"away\" aria-label={t(\"Away\")}>\n\t\t\t<h3 data-widget-part=\"attendance.group-head\">{t(\"Away\")}</h3>\n\t\t\t<ul data-widget-part=\"attendance.list list\">\n\t\t\t\t{#each view.away as person (person.key)}\n\t\t\t\t\t{@render personRow(person, \"away\")}\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t</section>\n\t{/if}\n</div>\n","shared/attendance/attendance.ts":"/**\n * Core's `attendance` component (PLAN-core-widgets W10): Who's here — the\n * session's people, who has it open now, as whom each writes and who is\n * typing, and who is away, as the page's UI worker runs it. `npm run build`\n * compiles it with the CLI's component bundler to\n * `dist/components/attendance.js`, the module the app serves at\n * `/core-ui/attendance`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Attendance from './Attendance.svelte'\n\nexport default svelteComponent(Attendance)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"f53c7418f2faacfbb80a5b0ffb4fdaf0a5ec618af80daf9d16ef9c2afdf694f4","catalogVersion":"0.6.0-pr-8"}
1
+ {"slug":"attendance","framework":"svelte","entry":"shared/attendance/attendance.ts","files":{"shared/WidgetBoundary.svelte":"<script lang=\"ts\">\n\t/**\n\t * The one boundary every core widget host draws its widget inside.\n\t *\n\t * Why (playtest item 15): a widget whose Svelte render threw after mount\n\t * went blank with nothing on screen — the worker reports a throw at mount\n\t * and in a handler, not one in a render. Here the throw is caught, said to\n\t * the page as a fatal report over the widget port (the page answers with\n\t * its own \"This widget stopped\" overlay), and one plain sentence is drawn.\n\t *\n\t * A handler's throw is not this boundary's: the worker reports it.\n\t */\n\timport type { Snippet } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\n\tlet { ctx, children }: { ctx: ComponentContext; children: Snippet } = $props()\n\n\tfunction report(error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\t\tconst where =\n\t\t\terror instanceof Error && error.stack\n\t\t\t\t? \"\\n\" + error.stack.split(\"\\n\").slice(1, 7).join(\"\\n\")\n\t\t\t\t: \"\"\n\t\ttry {\n\t\t\tctx.error(message + where, true)\n\t\t} catch {\n\t\t\t// A closed port has nobody to tell.\n\t\t}\n\t}\n</script>\n\n<svelte:boundary onerror={report}>\n\t{@render children()}\n\t{#snippet failed()}\n\t\t<p role=\"alert\">This widget stopped and can't show anything.</p>\n\t{/snippet}\n</svelte:boundary>\n","shared/attendance/Attendance.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Who's here widget as a remote component (W10): the component\n\t * context, as the widget context, around the widget.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AttendanceWidget from \"./AttendanceWidget.svelte\"\n\timport WidgetBoundary from \"../WidgetBoundary.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"attendance\", instanceId: \"attendance\", title: \"Who's here\" }\n\t\t)\n\t)\n</script>\n\n<WidgetBoundary {ctx}><AttendanceWidget /></WidgetBoundary>\n","shared/attendance/AttendanceWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Who's here (PLAN-core-widgets W10): which people have this session open\n\t * now, as whom each writes, and who is typing — the session's attendance\n\t * (`attendance.v1`), drawn as two groups.\n\t *\n\t * **Here**: a row per person with the session open — their name, *you*\n\t * on the viewer's own, the persona each writes as (face and name, from\n\t * the cast), a typing pulse while one of their personas is typing, and\n\t * *Owner* / *Guest* as a quiet chip. Under it, *Nobody else is here.*\n\t * when the viewer has the room to themselves. **Away**: the session's\n\t * other people, with when they were last here (off with `showAway`). A\n\t * press on a persona opens its sheet (`open-character`). Everything it\n\t * shows is worked out in the plain half (`attendanceView`); this only\n\t * draws it, and keeps the clock the Away times are told from.\n\t *\n\t * The markup carries no look: each element names what it is in\n\t * `data-widget-part` (`attendance.person row`, …), the row's state rides\n\t * on `data-state`, and the default widget stylesheet draws them\n\t * (STYLE-GUIDE §6.16).\n\t */\n\timport type { ViewerV1 } from \"@serene-pub/sdk/component\"\n\timport { attendanceView, readAttendanceSettings } from \"@serene-pub/core-catalog/attendance\"\n\timport { useWidgetContext } from \"../context\"\n\n\tconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current.t(source) ?? source\n\n\t/** The clock the Away rows' \"Last here …\" are told from, moved once a minute. */\n\tlet now = $state(Date.now())\n\t$effect(() => {\n\t\tconst tick = setInterval(() => (now = Date.now()), 60_000)\n\t\treturn () => clearInterval(tick)\n\t})\n\n\tconst settings = $derived(\n\t\treadAttendanceSettings(widget?.current.settings?.v1)\n\t)\n\tconst view = $derived(\n\t\tattendanceView({\n\t\t\tattendance: widget?.current.attendance?.v1,\n\t\t\tcharacters: widget?.current.scope(\"characters\"),\n\t\t\tviewer: widget?.current.viewer?.v1 ?? NOBODY,\n\t\t\tsettings,\n\t\t\tnow,\n\t\t\tt\n\t\t})\n\t)\n\n\t/** Why the page declined the last press, this widget's own. */\n\tlet refusal = $state<string | null>(null)\n\n\tasync function openPersona(characterId: number): Promise<void> {\n\t\trefusal = null\n\t\ttry {\n\t\t\tawait widget?.current.request(\"open-character\", { characterId })\n\t\t} catch (e) {\n\t\t\trefusal = e instanceof Error && e.message ? e.message : t(\"That did not go through. Try again.\")\n\t\t}\n\t}\n</script>\n\n{#snippet personRow(person: (typeof view.here)[number], state: \"here\" | \"away\")}\n\t<li\n\t\tdata-widget-part=\"attendance.person row\"\n\t\tdata-state={state}\n\t\tdata-role={person.role}\n\t\tdata-you={person.you ? \"\" : undefined}\n\t\tdata-typing={person.typing ? \"\" : undefined}\n\t>\n\t\t<span data-widget-part=\"attendance.name\">{person.name}</span>\n\t\t{#if person.you}\n\t\t\t<span data-widget-part=\"attendance.you\">{t(\"you\")}</span>\n\t\t{/if}\n\t\t{#each person.personas as persona (persona.ref)}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"attendance.persona\"\n\t\t\t\tdata-ref={persona.ref}\n\t\t\t\ttitle={t(\"Open {name}\").replace(\"{name}\", persona.name)}\n\t\t\t\tonclick={() => openPersona(persona.characterId)}\n\t\t\t>\n\t\t\t\t{#if settings.faces}\n\t\t\t\t\t{#if persona.face}\n\t\t\t\t\t\t<img data-widget-part=\"attendance.face\" src={persona.face} alt=\"\" />\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<span data-widget-part=\"attendance.face\" data-blank=\"\">\n\t\t\t\t\t\t\t<sp-icon name=\"user-round\" size=\"12\"></sp-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t{/if}\n\t\t\t\t{/if}\n\t\t\t\t<span>{persona.name}</span>\n\t\t\t</button>\n\t\t{/each}\n\t\t{#if person.typing}\n\t\t\t<span data-widget-part=\"attendance.typing\" role=\"status\">{t(\"typing…\")}</span>\n\t\t{/if}\n\t\t{#if person.lastHere}\n\t\t\t<span data-widget-part=\"attendance.away\">{person.lastHere}</span>\n\t\t{/if}\n\t\t<span data-widget-part=\"attendance.role chip\">{person.roleChip}</span>\n\t</li>\n{/snippet}\n\n<div data-widget-part=\"attendance.root\" data-faces={settings.faces ? \"\" : undefined}>\n\t{#if refusal}\n\t\t<p data-widget-part=\"attendance.alert\" role=\"alert\">{refusal}</p>\n\t{/if}\n\n\t{#if view.here.length}\n\t\t<section data-widget-part=\"attendance.group\" data-group=\"here\" aria-label={t(\"Here\")}>\n\t\t\t<h3 data-widget-part=\"attendance.group-head\">{t(\"Here\")}</h3>\n\t\t\t<ul data-widget-part=\"attendance.list list\">\n\t\t\t\t{#each view.here as person (person.key)}\n\t\t\t\t\t{@render personRow(person, \"here\")}\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t</section>\n\t{/if}\n\n\t{#if view.away.length}\n\t\t<section data-widget-part=\"attendance.group\" data-group=\"away\" aria-label={t(\"Away\")}>\n\t\t\t<h3 data-widget-part=\"attendance.group-head\">{t(\"Away\")}</h3>\n\t\t\t<ul data-widget-part=\"attendance.list list\">\n\t\t\t\t{#each view.away as person (person.key)}\n\t\t\t\t\t{@render personRow(person, \"away\")}\n\t\t\t\t{/each}\n\t\t\t</ul>\n\t\t</section>\n\t{/if}\n</div>\n","shared/attendance/attendance.ts":"/**\n * Core's `attendance` component (PLAN-core-widgets W10): Who's here — the\n * session's people, who has it open now, as whom each writes and who is\n * typing, and who is away, as the page's UI worker runs it. `npm run build`\n * compiles it with the CLI's component bundler to\n * `dist/components/attendance.js`, the module the app serves at\n * `/core-ui/attendance`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport Attendance from './Attendance.svelte'\n\nexport default svelteComponent(Attendance)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_ATTENDANCE,\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData,\n\ttype WidgetSectionScope\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\tattendance: { v1: ctx.attendance ?? EMPTY_ATTENDANCE },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// ⏳ The retired `menu` verb (C4, 2026-10-10; REMOVE in 0.7.0): no host\n\t\t\t// draws one, so it answers dismissed. A component places `sp-menu`.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\t// The scope string, by the table, to the section's `v1` — the same\n\t\t\t// lookup `ComponentContext.scope` makes, so both answer alike.\n\t\t\tscope: <S extends WidgetSectionScope>(scope: S) => scoped[WIDGET_SCOPED_SECTIONS[scope]],\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"f53c7418f2faacfbb80a5b0ffb4fdaf0a5ec618af80daf9d16ef9c2afdf694f4","catalogVersion":"0.6.0-pr-9"}
@@ -31,7 +31,7 @@ import {
31
31
  user_derived,
32
32
  user_effect,
33
33
  widgetRefFromComponent
34
- } from "./shared-7SWDK5MC.js";
34
+ } from "./shared-HEAKNNZB.js";
35
35
 
36
36
  // dist/genres/story/ui/authors-note/index.js
37
37
  var AUTHORS_NOTE_DEFAULTS = Object.freeze({