@serene-pub/core-catalog 0.6.0-pr-2 → 0.6.0-pr-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/components/{sessions → genres/chat}/authors-note/AuthorsNote.svelte +1 -1
- package/components/{sessions → genres/chat}/authors-note/AuthorsNoteWidget.svelte +1 -1
- package/components/{sessions → shared}/lore-entries/LoreEntries.svelte +1 -1
- package/components/{sessions → shared}/lore-entries/LoreEntriesWidget.svelte +1 -1
- package/components/{sessions → shared}/messages/MessageComposer.svelte +1 -1
- package/components/{sessions → shared}/messages/Messages.svelte +1 -1
- package/components/{sessions → shared}/messages/MessagesWidget.svelte +1 -1
- package/components/{sessions → shared}/messages/SessionComposer.svelte +1 -1
- package/components/{sessions → shared}/messages/SessionMessage.svelte +1 -1
- package/components/{sessions → shared}/messages/conversation.svelte.ts +1 -1
- package/components/{sessions → shared}/scene-portraits/ScenePortraits.svelte +1 -1
- package/components/{sessions → shared}/scene-portraits/ScenePortraitsWidget.svelte +1 -1
- package/components/{sessions → shared}/stats/Stats.svelte +1 -1
- package/components/{sessions → shared}/stats/StatsWidget.svelte +1 -1
- package/components/{sessions → shared}/world-state/WorldState.svelte +1 -1
- package/components/{sessions → shared}/world-state/WorldStateWidget.svelte +1 -1
- package/dist/components/authors-note.js +5 -5
- package/dist/components/authors-note.source.json +1 -1
- package/dist/components/core-ui.json +1 -1
- package/dist/components/lore-entries.js +5 -5
- package/dist/components/lore-entries.source.json +1 -1
- package/dist/components/messages.js +26 -26
- package/dist/components/messages.source.json +1 -1
- package/dist/components/scene-portraits.js +7 -7
- package/dist/components/scene-portraits.source.json +1 -1
- package/dist/components/{shared-TCQZXBE3.js → shared-3FGURYVS.js} +2 -2
- package/dist/components/{shared-AINANAIA.js → shared-FXYLABGF.js} +6 -6
- package/dist/components/{shared-UAQVMZZK.js → shared-U3UU5V7L.js} +3 -3
- package/dist/components/stats.js +6 -6
- package/dist/components/stats.source.json +1 -1
- package/dist/components/world-state.js +6 -6
- package/dist/components/world-state.source.json +1 -1
- package/dist/{answerForm.d.ts → factories/answerForm.d.ts} +4 -30
- package/dist/{answerForm.js → factories/answerForm.js} +4 -37
- package/dist/factories/once.d.ts +7 -0
- package/dist/factories/once.js +9 -0
- package/dist/{turnOrder.d.ts → factories/turnOrder.d.ts} +0 -22
- package/dist/{turnOrder.js → factories/turnOrder.js} +4 -104
- package/dist/genres/adventure/advanceTime.d.ts +11 -0
- package/dist/genres/adventure/advanceTime.js +17 -0
- package/dist/genres/adventure/answer.d.ts +23 -0
- package/dist/genres/adventure/answer.js +59 -0
- package/dist/genres/adventure/answerForm.d.ts +9 -0
- package/dist/genres/adventure/answerForm.js +11 -0
- package/dist/genres/adventure/ask.d.ts +73 -0
- package/dist/genres/adventure/ask.js +157 -0
- package/dist/genres/adventure/create.d.ts +36 -0
- package/dist/genres/adventure/create.js +62 -0
- package/dist/genres/adventure/index.d.ts +43 -0
- package/dist/genres/adventure/index.js +43 -0
- package/dist/genres/adventure/keeperAction.d.ts +24 -0
- package/dist/genres/adventure/keeperAction.js +150 -0
- package/dist/genres/adventure/look.d.ts +45 -0
- package/dist/genres/adventure/look.js +209 -0
- package/dist/{adventure.d.ts → genres/adventure/respond.d.ts} +10 -34
- package/dist/{adventure.js → genres/adventure/respond.js} +34 -60
- package/dist/genres/adventure/rest.d.ts +10 -0
- package/dist/genres/adventure/rest.js +16 -0
- package/dist/genres/adventure/turnOrder.d.ts +10 -0
- package/dist/genres/adventure/turnOrder.js +27 -0
- package/dist/genres/chat/answerForm.d.ts +9 -0
- package/dist/genres/chat/answerForm.js +11 -0
- package/dist/genres/chat/create.d.ts +7 -0
- package/dist/{createChat.js → genres/chat/create.js} +6 -6
- package/dist/genres/chat/generateImage.d.ts +7 -0
- package/dist/{generateImage.js → genres/chat/generateImage.js} +5 -5
- package/dist/genres/chat/index.d.ts +15 -0
- package/dist/genres/chat/index.js +15 -0
- package/dist/{narrate.d.ts → genres/chat/narrate.d.ts} +3 -3
- package/dist/{narrate.js → genres/chat/narrate.js} +34 -12
- package/dist/{narrateCharacter.d.ts → genres/chat/narrateCharacter.d.ts} +2 -2
- package/dist/{narrateCharacter.js → genres/chat/narrateCharacter.js} +35 -16
- package/dist/genres/chat/respond.d.ts +25 -0
- package/dist/{respond.js → genres/chat/respond.js} +48 -22
- package/dist/genres/chat/turnOrder.d.ts +9 -0
- package/dist/genres/chat/turnOrder.js +28 -0
- package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.d.ts +1 -1
- package/dist/genres/guide/answerForm.d.ts +9 -0
- package/dist/genres/guide/answerForm.js +11 -0
- package/dist/genres/guide/create.d.ts +24 -0
- package/dist/genres/guide/create.js +58 -0
- package/dist/genres/guide/index.d.ts +9 -0
- package/dist/genres/guide/index.js +9 -0
- package/dist/{guide.d.ts → genres/guide/respond.d.ts} +1 -20
- package/dist/{guide.js → genres/guide/respond.js} +29 -60
- package/dist/genres/guide/turnOrder.d.ts +10 -0
- package/dist/genres/guide/turnOrder.js +27 -0
- package/dist/genres/index.d.ts +14 -0
- package/dist/genres/index.js +41 -0
- package/dist/genres/lair/answerForm.d.ts +17 -0
- package/dist/genres/lair/answerForm.js +19 -0
- package/dist/genres/lair/buildRoom.d.ts +64 -0
- package/dist/genres/lair/buildRoom.js +244 -0
- package/dist/genres/lair/castellanAction.d.ts +27 -0
- package/dist/genres/lair/castellanAction.js +177 -0
- package/dist/genres/lair/create.d.ts +28 -0
- package/dist/genres/lair/create.js +69 -0
- package/dist/genres/lair/fileRoom.d.ts +53 -0
- package/dist/genres/lair/fileRoom.js +288 -0
- package/dist/genres/lair/index.d.ts +60 -0
- package/dist/genres/lair/index.js +60 -0
- package/dist/genres/lair/nudge.d.ts +25 -0
- package/dist/genres/lair/nudge.js +78 -0
- package/dist/{lair.d.ts → genres/lair/respond.d.ts} +15 -28
- package/dist/{lair.js → genres/lair/respond.js} +45 -76
- package/dist/genres/lair/reveal.d.ts +10 -0
- package/dist/genres/lair/reveal.js +18 -0
- package/dist/genres/lair/roomAnswer.d.ts +86 -0
- package/dist/genres/lair/roomAnswer.js +378 -0
- package/dist/genres/lair/trap.d.ts +11 -0
- package/dist/genres/lair/trap.js +24 -0
- package/dist/genres/lair/turnOrder.d.ts +9 -0
- package/dist/genres/lair/turnOrder.js +36 -0
- package/dist/genres/lair/whisper.d.ts +35 -0
- package/dist/genres/lair/whisper.js +90 -0
- package/dist/index.d.ts +47 -29
- package/dist/index.js +117 -88
- package/dist/{genres.js → registry/genres.js} +4 -4
- package/dist/{ui/sessions → registry}/widgets.js +6 -6
- package/dist/{presets.js → seed/presets.js} +28 -13
- package/dist/{prompts.js → seed/prompts.js} +27 -56
- package/dist/{annexField.d.ts → shared/annexField.d.ts} +3 -2
- package/dist/{annexField.js → shared/annexField.js} +6 -8
- package/dist/shared/builtins/branch.d.ts +8 -0
- package/dist/shared/builtins/branch.js +13 -0
- package/dist/{builtins.d.ts → shared/builtins/builtIn.d.ts} +16 -21
- package/dist/{builtins.js → shared/builtins/builtIn.js} +3 -37
- package/dist/shared/builtins/delete.d.ts +8 -0
- package/dist/shared/builtins/delete.js +13 -0
- package/dist/shared/builtins/edit.d.ts +8 -0
- package/dist/shared/builtins/edit.js +13 -0
- package/dist/shared/builtins/hide.d.ts +8 -0
- package/dist/shared/builtins/hide.js +13 -0
- package/dist/shared/builtins/index.d.ts +11 -0
- package/dist/shared/builtins/index.js +11 -0
- package/dist/shared/builtins/swipe.d.ts +8 -0
- package/dist/shared/builtins/swipe.js +17 -0
- package/dist/shared/sprites.d.ts +34 -0
- package/dist/shared/sprites.js +98 -0
- package/dist/shared/summarize/character.d.ts +9 -0
- package/dist/shared/summarize/character.js +10 -0
- package/dist/shared/summarize/history.d.ts +9 -0
- package/dist/shared/summarize/history.js +10 -0
- package/dist/shared/summarize/index.d.ts +10 -0
- package/dist/shared/summarize/index.js +10 -0
- package/dist/shared/summarize/scene.d.ts +38 -0
- package/dist/shared/summarize/scene.js +42 -0
- package/dist/shared/summarize/summarizeSpec.d.ts +54 -0
- package/dist/{summarize.js → shared/summarize/summarizeSpec.js} +8 -53
- package/dist/shared/summarize/world.d.ts +8 -0
- package/dist/shared/summarize/world.js +9 -0
- package/dist/{toolLoop.d.ts → shared/toolLoop.d.ts} +25 -3
- package/dist/{toolLoop.js → shared/toolLoop.js} +67 -14
- package/dist/{ui/sessions → shared/ui}/conversation/index.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/conversation/index.js +1 -1
- package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.js +1 -1
- package/dist/{ui/sessions → shared/ui}/lore-entries/index.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/scene-portraits/index.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/scene-portraits/index.js +1 -1
- package/dist/{ui/sessions → shared/ui}/session-state/index.d.ts +1 -1
- package/dist/{ui/sessions → shared/ui}/session-state/index.js +1 -1
- package/package.json +28 -28
- package/dist/adventureActions.d.ts +0 -169
- package/dist/adventureActions.js +0 -599
- package/dist/createChat.d.ts +0 -7
- package/dist/generateImage.d.ts +0 -7
- package/dist/lairActions.d.ts +0 -296
- package/dist/lairActions.js +0 -1287
- package/dist/respond.d.ts +0 -24
- package/dist/sprites.d.ts +0 -24
- package/dist/sprites.js +0 -102
- package/dist/summarize.d.ts +0 -76
- /package/components/{sessions → genres/chat}/authors-note/authors-note.ts +0 -0
- /package/components/{sessions/shared → shared}/context.ts +0 -0
- /package/components/{sessions → shared}/lore-entries/lore-entries.ts +0 -0
- /package/components/{sessions → shared}/messages/MessageBlocksView.svelte +0 -0
- /package/components/{sessions → shared}/messages/MessageControls.svelte +0 -0
- /package/components/{sessions → shared}/messages/MessageMediaStrip.svelte +0 -0
- /package/components/{sessions → shared}/messages/MessagePartsView.svelte +0 -0
- /package/components/{sessions → shared}/messages/MessageStateLedger.svelte +0 -0
- /package/components/{sessions → shared}/messages/NextCharacterBlock.svelte +0 -0
- /package/components/{sessions → shared}/messages/SessionContainer.svelte +0 -0
- /package/components/{sessions → shared}/messages/StateProposalList.svelte +0 -0
- /package/components/{sessions → shared}/messages/mediaStrip.ts +0 -0
- /package/components/{sessions → shared}/messages/messages.ts +0 -0
- /package/components/{sessions → shared}/scene-portraits/StatBars.svelte +0 -0
- /package/components/{sessions → shared}/scene-portraits/scene-portraits.ts +0 -0
- /package/components/{sessions → shared}/state/SlotControl.svelte +0 -0
- /package/components/{sessions → shared}/state/entryFinder.ts +0 -0
- /package/components/{sessions → shared}/state/slotWriter.svelte.ts +0 -0
- /package/components/{sessions → shared}/stats/stats.ts +0 -0
- /package/components/{sessions/shared → shared}/widgetRef.svelte.ts +0 -0
- /package/components/{sessions → shared}/world-state/world-state.ts +0 -0
- /package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.js +0 -0
- /package/dist/{entries.d.ts → registry/entries.d.ts} +0 -0
- /package/dist/{entries.js → registry/entries.js} +0 -0
- /package/dist/{genres.d.ts → registry/genres.d.ts} +0 -0
- /package/dist/{ui/sessions → registry}/layouts.d.ts +0 -0
- /package/dist/{ui/sessions → registry}/layouts.js +0 -0
- /package/dist/{slots.d.ts → registry/slots.d.ts} +0 -0
- /package/dist/{slots.js → registry/slots.js} +0 -0
- /package/dist/{statShapes.d.ts → registry/statShapes.d.ts} +0 -0
- /package/dist/{statShapes.js → registry/statShapes.js} +0 -0
- /package/dist/{ui/sessions → registry}/widgets.d.ts +0 -0
- /package/dist/{guideMascotImage.d.ts → seed/guideMascotImage.d.ts} +0 -0
- /package/dist/{guideMascotImage.js → seed/guideMascotImage.js} +0 -0
- /package/dist/{presets.d.ts → seed/presets.d.ts} +0 -0
- /package/dist/{prompts.d.ts → seed/prompts.d.ts} +0 -0
- /package/dist/{graphBuild.d.ts → shared/graphBuild.d.ts} +0 -0
- /package/dist/{graphBuild.js → shared/graphBuild.js} +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/dossier.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/dossier.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/text.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/conversation/text.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/lore-entries/index.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/scene-portraits/portraits.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/scene-portraits/portraits.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/barMath.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/barMath.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/shapes.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/shapes.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/stateView.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/session-state/stateView.js +0 -0
- /package/dist/{ui/sessions → shared/ui}/widgetContext.d.ts +0 -0
- /package/dist/{ui/sessions → shared/ui}/widgetContext.js +0 -0
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
user_derived,
|
|
32
32
|
user_effect,
|
|
33
33
|
widgetRefFromComponent
|
|
34
|
-
} from "./shared-
|
|
34
|
+
} from "./shared-U3UU5V7L.js";
|
|
35
35
|
|
|
36
|
-
// dist/ui/
|
|
36
|
+
// dist/shared/ui/lore-entries/index.js
|
|
37
37
|
var LORE_ENTRIES_FILTERS = Object.freeze([
|
|
38
38
|
{ value: "all", label: "All" },
|
|
39
39
|
{ value: "fired", label: "Read" },
|
|
@@ -105,7 +105,7 @@ function createLatestAsk() {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
// components/
|
|
108
|
+
// components/shared/lore-entries/LoreEntriesWidget.svelte
|
|
109
109
|
var root = from_html(`<p data-widget-part="lore-entries.note"> </p>`);
|
|
110
110
|
var root_1 = from_html(`<label data-widget-part="lore-entries.filter chip"><input type="radio" data-widget-part="lore-entries.filter-input"/> </label>`);
|
|
111
111
|
var root_2 = from_html(`<sp-option> </sp-option>`, 2);
|
|
@@ -496,7 +496,7 @@ function LoreEntriesWidget($$anchor, $$props) {
|
|
|
496
496
|
}
|
|
497
497
|
delegate(["input", "click", "change"]);
|
|
498
498
|
|
|
499
|
-
// components/
|
|
499
|
+
// components/shared/lore-entries/LoreEntries.svelte
|
|
500
500
|
function LoreEntries($$anchor, $$props) {
|
|
501
501
|
push($$props, true);
|
|
502
502
|
let settled = state(untrack(() => $$props.ctx.settings) !== void 0);
|
|
@@ -516,7 +516,7 @@ function LoreEntries($$anchor, $$props) {
|
|
|
516
516
|
pop();
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
// components/
|
|
519
|
+
// components/shared/lore-entries/lore-entries.ts
|
|
520
520
|
var lore_entries_default = svelteComponent(LoreEntries);
|
|
521
521
|
export {
|
|
522
522
|
lore_entries_default as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"slug":"lore-entries","framework":"svelte","entry":"sessions/lore-entries/lore-entries.ts","files":{"sessions/lore-entries/LoreEntries.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Lore entries widget as a remote component (R21): the component\n\t * context, as the native widget context, around `LoreEntriesWidget`.\n\t *\n\t * The widget asks the page for its first page only once its settings\n\t * have arrived: the page posts a widget's settings (it reads them) right\n\t * after it says ready, and an ask made before would be spent on the\n\t * declared defaults instead of this instance's sort and page size.\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 LoreEntriesWidget from \"./LoreEntriesWidget.svelte\"\n\timport { widgetRefFromComponent } from \"../shared/widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\tlet settled = $state(untrack(() => ctx.settings) !== undefined)\n\t$effect(() =>\n\t\tuntrack(() => ctx).subscribe((section) => {\n\t\t\tif (section === \"settings\") settled = true\n\t\t})\n\t)\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: \"lore-entries\", instanceId: \"lore-entries\", title: \"Lore entries\" }\n\t\t)\n\t)\n</script>\n\n<LoreEntriesWidget ready={settled} />\n","sessions/lore-entries/LoreEntriesWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Lore entries (PLAN-sdk-1.0 §3.9, R58; R21 port): the session's lorebook\n\t * entry by entry, with what this session's rankings made of each, and the\n\t * two marks — **Off** and **Pin** — which never force a re-embed.\n\t *\n\t * It reads its settings alone. Everything else is asked of the page: one\n\t * `session-entries` does the search, sort, filter and paging for the\n\t * page's own session (the declared `lore` scope is the grant for it), and\n\t * `set-entry-marks` sets a mark. The page answers every ask with its own\n\t * reply, so which answer to show is this widget's: its latest-ask guard.\n\t * A turn that writes the rankings tells it `lore:ranked` (R81), and it\n\t * pages again; so does a mark set anywhere else on an entry it shows, or\n\t * on any entry while it shows only Pinned or Off (`lore:marked`). The\n\t * refresh button stays.\n\t *\n\t * What goes wrong is said here, in this widget (R77) — never a toast every\n\t * lore widget shows. The book's owner and admins see the entries; anyone\n\t * else is told whose they are, because a widget declaration has no\n\t * visibility field of its own. So is a mark saved to the entry that a\n\t * dated amendment still decides in this session's story (the answer's\n\t * `heldBy`): the row reads as before, and the line says why.\n\t *\n\t * The markup carries no look (P3d): its elements carry `lore-entries.*`\n\t * widget parts and the default widget stylesheet draws them (STYLE-GUIDE\n\t * §6.16). State is the elements' own: a chosen filter is its radio's\n\t * `:checked`, a pressed mark its button's `aria-pressed`, an entry turned\n\t * off `data-off`.\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { SessionEntryV1, WidgetRequests } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tLORE_ENTRIES_FILTERS,\n\t\tLORE_ENTRIES_SORTS,\n\t\tcreateLatestAsk,\n\t\tloreEntriesEmptyLine,\n\t\tloreEntriesSpan,\n\t\tloreEntryName,\n\t\tloreEntryReadLine,\n\t\treadLoreEntriesSettings,\n\t\ttype LoreEntriesFilter,\n\t\ttype LoreEntriesSort\n\t} from \"@serene-pub/core-catalog/lore-entries\"\n\timport { useWidgetContext } from \"../shared/context\"\n\n\ttype Answer = WidgetRequests[\"session-entries\"][\"result\"]\n\ttype Ask = WidgetRequests[\"session-entries\"][\"params\"]\n\n\t/** Whether to ask the page yet: false until the host has posted this instance's settings. */\n\tlet { ready = true }: { ready?: boolean } = $props()\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\n\t// Primitives, so a push that changes neither asks nothing again.\n\tconst pageSize = $derived(\n\t\treadLoreEntriesSettings(widget?.current?.settings?.v1 as Record<string, unknown> | undefined).pageSize\n\t)\n\tconst settledSort = $derived(\n\t\treadLoreEntriesSettings(widget?.current?.settings?.v1 as Record<string, unknown> | undefined).sort\n\t)\n\n\tlet query = $state(\"\")\n\tlet sort = $state<LoreEntriesSort | null>(null)\n\tconst effectiveSort = $derived<LoreEntriesSort>(sort ?? settledSort)\n\tlet filter = $state<LoreEntriesFilter>(\"all\")\n\tlet offset = $state(0)\n\n\tlet answer = $state<Answer | null>(null)\n\t/** Why the page could not be read, this widget's own. */\n\tlet readError = $state<string | null>(null)\n\t/** Why a mark did not change, this widget's own. */\n\tlet markError = $state<string | null>(null)\n\t/**\n\t * A mark saved to the entry that a dated amendment still decides here\n\t * (`heldBy`): the row reads as before, and this says why.\n\t */\n\tlet markHeld = $state<string | null>(null)\n\n\t/** The filter radios' group name: one per mount, so two copies never share a group (F8). */\n\tconst filterGroup = `sp-lore-filter-${Math.random().toString(36).slice(2, 10)}`\n\n\tconst latest = createLatestAsk()\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t// The search asks once typing pauses, not once per keystroke.\n\tlet searched = $state(\"\")\n\t$effect(() => {\n\t\tconst q = query.trim()\n\t\tconst timer = setTimeout(() => (searched = q), 250)\n\t\treturn () => clearTimeout(timer)\n\t})\n\n\tconst askParams = (): Ask => ({\n\t\t...(searched ? { titleOrKey: searched } : {}),\n\t\tsort: effectiveSort,\n\t\tfilter,\n\t\toffset,\n\t\tlimit: pageSize\n\t})\n\n\tfunction ask(params: Ask) {\n\t\tconst ctx = widget?.current\n\t\tif (!ctx) return\n\t\tconst ticket = latest.next()\n\t\tctx.request(\"session-entries\", params).then(\n\t\t\t(res) => {\n\t\t\t\tif (!latest.isLatest(ticket)) return\n\t\t\t\treadError = null\n\t\t\t\tanswer = res\n\t\t\t\t// The page pulls a page that ran past the end back to the last one.\n\t\t\t\tif (typeof res.offset === \"number\" && res.offset !== offset) offset = res.offset\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (!latest.isLatest(ticket)) return\n\t\t\t\treadError = reason(e)\n\t\t\t}\n\t\t)\n\t}\n\n\t/** Ask again for the page on screen. */\n\tconst refresh = () => untrack(() => ready && ask(askParams()))\n\n\t// Each change of the search, sort, filter, page or page size asks again —\n\t// and a mark's line, refused or held, goes with the view it was said over.\n\t$effect(() => {\n\t\tif (!ready) return\n\t\tconst params = askParams()\n\t\tuntrack(() => {\n\t\t\tmarkError = null\n\t\t\tmarkHeld = null\n\t\t\task(params)\n\t\t})\n\t})\n\n\t// A turn wrote the rankings these entries read (R81): ask again.\n\t$effect(() => untrack(() => widget?.current?.on(\"lore:ranked\", refresh)))\n\n\t// A mark changed elsewhere — another widget, another tab, the entry\n\t// editor — on an entry shown here: ask again, so this list is never the\n\t// stale one. Showing only Pinned or Off, on any entry: the event names the\n\t// entry but not how this session reads it now, and it may have joined.\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"lore:marked\", (e) => {\n\t\t\t\tif (e.kind !== \"lore:marked\") return\n\t\t\t\tif (filter === \"pinned\" || filter === \"off\" || answer?.rows.some((r) => r.id === e.entryId))\n\t\t\t\t\trefresh()\n\t\t\t})\n\t\t)\n\t)\n\n\tfunction setFilter(value: LoreEntriesFilter) {\n\t\tfilter = value\n\t\toffset = 0\n\t}\n\n\tasync function setMark(row: SessionEntryV1, mark: \"off\" | \"pinned\") {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tmarkError = null\n\t\tmarkHeld = null\n\t\ttry {\n\t\t\tconst now = await ctx.request(\"set-entry-marks\", {\n\t\t\t\tentryId: row.id,\n\t\t\t\t...(mark === \"off\" ? { off: !row.off } : { pinned: !row.pinned })\n\t\t\t})\n\t\t\tif (now.heldBy)\n\t\t\t\tmarkHeld = t(\n\t\t\t\t\tnow.heldBy.mark === \"off\"\n\t\t\t\t\t\t? \"Saved to the entry, but an amendment dated {date} still decides whether it is off here.\"\n\t\t\t\t\t\t: \"Saved to the entry, but an amendment dated {date} still decides whether it is pinned here.\"\n\t\t\t\t).replace(\"{date}\", now.heldBy.date)\n\t\t\tif (answer)\n\t\t\t\tanswer = {\n\t\t\t\t\t...answer,\n\t\t\t\t\trows: answer.rows.map((r) => (r.id === row.id ? { ...r, off: now.off, pinned: now.pinned } : r))\n\t\t\t\t}\n\t\t} catch (e) {\n\t\t\tmarkError = t(\"Not changed: {reason}\").replace(\"{reason}\", reason(e))\n\t\t}\n\t\t// What the filter shows may have moved either way.\n\t\trefresh()\n\t}\n\n\tconst span = $derived(answer ? loreEntriesSpan(offset, pageSize, answer.total) : null)\n\tconst readLine = (r: SessionEntryV1) => loreEntryReadLine(r, Date.now(), t)\n</script>\n\n<div data-widget-part=\"lore-entries.root\" data-widget=\"lore-entries\">\n\t{#if answer?.ownerOnly}\n\t\t<p data-widget-part=\"lore-entries.note\">\n\t\t\t{t(\"These entries are the lorebook owner's to manage.\")}\n\t\t</p>\n\t{:else if answer && answer.lorebookId === null}\n\t\t<p data-widget-part=\"lore-entries.note\">{t(\"This session reads no lorebook.\")}</p>\n\t{:else}\n\t\t<div data-widget-part=\"lore-entries.search-bar toolbar\">\n\t\t\t<label data-widget-part=\"lore-entries.search\">\n\t\t\t\t<span data-widget-part=\"lore-entries.search-label\">{t(\"Search entries by title or key\")}</span>\n\t\t\t\t<span data-widget-part=\"lore-entries.search-icon\">\n\t\t\t\t\t<sp-icon name=\"search\" size=\"14\"></sp-icon>\n\t\t\t\t</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.search-input\"\n\t\t\t\t\tplaceholder={answer\n\t\t\t\t\t\t? t(\"Search {total} entries\").replace(\"{total}\", String(answer.total))\n\t\t\t\t\t\t: t(\"Search entries\")}\n\t\t\t\t\tvalue={query}\n\t\t\t\t\toninput={(e) => {\n\t\t\t\t\t\tquery = e.currentTarget.value\n\t\t\t\t\t\toffset = 0\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"lore-entries.refresh\"\n\t\t\t\taria-label={t(\"Refresh\")}\n\t\t\t\ttitle={t(\"Refresh\")}\n\t\t\t\tonclick={refresh}\n\t\t\t>\n\t\t\t\t<sp-icon name=\"refresh-cw\" size=\"14\"></sp-icon>\n\t\t\t</button>\n\t\t</div>\n\t\t<div data-widget-part=\"lore-entries.filter-bar toolbar\">\n\t\t\t<div data-widget-part=\"lore-entries.filters\" role=\"radiogroup\" aria-label={t(\"Show\")}>\n\t\t\t\t{#each LORE_ENTRIES_FILTERS as f (f.value)}\n\t\t\t\t\t<!-- Chosen is the radio's own `:checked`: the sheet reads it, no state attribute. -->\n\t\t\t\t\t<label data-widget-part=\"lore-entries.filter chip\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.filter-input\"\n\t\t\t\t\t\t\tname={filterGroup}\n\t\t\t\t\t\t\tvalue={f.value}\n\t\t\t\t\t\t\tchecked={filter === f.value}\n\t\t\t\t\t\t\tonchange={() => setFilter(f.value)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{t(f.label)}\n\t\t\t\t\t</label>\n\t\t\t\t{/each}\n\t\t\t</div>\n\t\t\t<span data-widget-part=\"lore-entries.sort\">\n\t\t\t\t<!-- The combobox's own label is the one visible \"Sort\" (the host draws it). -->\n\t\t\t\t<sp-combobox\n\t\t\t\t\tdata-widget-part=\"lore-entries.sort-field\"\n\t\t\t\t\tlabel={t(\"Sort\")}\n\t\t\t\t\tvalue={effectiveSort}\n\t\t\t\t\tonchange={(e: CustomEvent<{ value: string }>) => {\n\t\t\t\t\t\tconst next = LORE_ENTRIES_SORTS.find((s) => s.value === e.detail.value)\n\t\t\t\t\t\tif (!next) return\n\t\t\t\t\t\tsort = next.value\n\t\t\t\t\t\toffset = 0\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{#each LORE_ENTRIES_SORTS as o (o.value)}\n\t\t\t\t\t\t<sp-option value={o.value}>{t(o.label)}</sp-option>\n\t\t\t\t\t{/each}\n\t\t\t\t</sp-combobox>\n\t\t\t</span>\n\t\t</div>\n\n\t\t{#if readError}\n\t\t\t<p data-widget-part=\"lore-entries.alert\" role=\"alert\">{readError}</p>\n\t\t{/if}\n\t\t{#if markError}\n\t\t\t<p data-widget-part=\"lore-entries.alert\" role=\"alert\">{markError}</p>\n\t\t{/if}\n\t\t{#if markHeld}\n\t\t\t<p data-widget-part=\"lore-entries.held\" role=\"status\">{markHeld}</p>\n\t\t{/if}\n\n\t\t<ul data-widget-part=\"lore-entries.entries list\" aria-label={t(\"Lore entries\")}>\n\t\t\t{#each answer?.rows ?? [] as r (r.id)}\n\t\t\t\t<!-- Pressed marks are the buttons' own `aria-pressed`; an entry turned off is `data-off`. -->\n\t\t\t\t<li data-widget-part=\"lore-entries.entry row\" data-entry-id={r.id} data-off={r.off ? \"\" : undefined}>\n\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-text\">\n\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-title label\">\n\t\t\t\t\t\t\t{loreEntryName(r, t)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{#if r.keys.length}\n\t\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-keys\">{r.keys.join(t(\", \"))}</span>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-read\">{readLine(r)}</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span data-widget-part=\"lore-entries.marks\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.pin\"\n\t\t\t\t\t\t\taria-pressed={r.pinned}\n\t\t\t\t\t\t\taria-label={t(\"Pin {name}\").replace(\"{name}\", r.title || t(\"entry {id}\").replace(\"{id}\", String(r.id)))}\n\t\t\t\t\t\t\ttitle={r.pinned ? t(\"Pinned: always read\") : t(\"Pin: always read\")}\n\t\t\t\t\t\t\tonclick={() => setMark(r, \"pinned\")}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"pin\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.off\"\n\t\t\t\t\t\t\taria-pressed={r.off}\n\t\t\t\t\t\t\taria-label={t(\"Turn {name} off\").replace(\"{name}\", r.title || t(\"entry {id}\").replace(\"{id}\", String(r.id)))}\n\t\t\t\t\t\t\ttitle={r.off ? t(\"Off: never read\") : t(\"Turn off: never read\")}\n\t\t\t\t\t\t\tonclick={() => setMark(r, \"off\")}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"circle-off\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t{:else}\n\t\t\t\t{#if answer}\n\t\t\t\t\t<li data-widget-part=\"lore-entries.empty empty\">{loreEntriesEmptyLine(query, filter, t)}</li>\n\t\t\t\t{/if}\n\t\t\t{/each}\n\t\t</ul>\n\n\t\t{#if span?.paged}\n\t\t\t<div data-widget-part=\"lore-entries.pager\">\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.previous\"\n\t\t\t\t\tdisabled={!span.hasPrevious}\n\t\t\t\t\tonclick={() => (offset = span.previousOffset)}\n\t\t\t\t>\n\t\t\t\t\t{t(\"Previous\")}\n\t\t\t\t</button>\n\t\t\t\t<span data-widget-part=\"lore-entries.page-count\">\n\t\t\t\t\t{t(\"{from}–{to} of {total}\")\n\t\t\t\t\t\t.replace(\"{from}\", String(span.from))\n\t\t\t\t\t\t.replace(\"{to}\", String(span.to))\n\t\t\t\t\t\t.replace(\"{total}\", String(span.total))}\n\t\t\t\t</span>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.next\"\n\t\t\t\t\tdisabled={!span.hasNext}\n\t\t\t\t\tonclick={() => (offset = span.nextOffset)}\n\t\t\t\t>\n\t\t\t\t\t{t(\"Next\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t{/if}\n\t{/if}\n</div>\n","sessions/lore-entries/lore-entries.ts":"/**\n * Core's `lore-entries` component (R21, R58): the session's lorebook entry\n * by entry, with what this session's rankings made of each, and the two\n * marks — **Off** and **Pin**. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/lore-entries.js`, the module the app\n * serves at `/core-ui/lore-entries`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport LoreEntries from './LoreEntries.svelte'\n\nexport default svelteComponent(LoreEntries)\n","sessions/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","sessions/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_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} 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\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// No host menu across the port yet: dismissed, as a native host without one answers.\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\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":"dc0302b4eea4eb7f1aa80aef26956a2ff614d7a4f42e288fa9ebb669c684b088","catalogVersion":"0.6.0-pr-2"}
|
|
1
|
+
{"slug":"lore-entries","framework":"svelte","entry":"shared/lore-entries/lore-entries.ts","files":{"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/lore-entries/LoreEntries.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Lore entries widget as a remote component (R21): the component\n\t * context, as the native widget context, around `LoreEntriesWidget`.\n\t *\n\t * The widget asks the page for its first page only once its settings\n\t * have arrived: the page posts a widget's settings (it reads them) right\n\t * after it says ready, and an ask made before would be spent on the\n\t * declared defaults instead of this instance's sort and page size.\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 LoreEntriesWidget from \"./LoreEntriesWidget.svelte\"\n\timport { widgetRefFromComponent } from \"../widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\tlet settled = $state(untrack(() => ctx.settings) !== undefined)\n\t$effect(() =>\n\t\tuntrack(() => ctx).subscribe((section) => {\n\t\t\tif (section === \"settings\") settled = true\n\t\t})\n\t)\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: \"lore-entries\", instanceId: \"lore-entries\", title: \"Lore entries\" }\n\t\t)\n\t)\n</script>\n\n<LoreEntriesWidget ready={settled} />\n","shared/lore-entries/LoreEntriesWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * Lore entries (PLAN-sdk-1.0 §3.9, R58; R21 port): the session's lorebook\n\t * entry by entry, with what this session's rankings made of each, and the\n\t * two marks — **Off** and **Pin** — which never force a re-embed.\n\t *\n\t * It reads its settings alone. Everything else is asked of the page: one\n\t * `session-entries` does the search, sort, filter and paging for the\n\t * page's own session (the declared `lore` scope is the grant for it), and\n\t * `set-entry-marks` sets a mark. The page answers every ask with its own\n\t * reply, so which answer to show is this widget's: its latest-ask guard.\n\t * A turn that writes the rankings tells it `lore:ranked` (R81), and it\n\t * pages again; so does a mark set anywhere else on an entry it shows, or\n\t * on any entry while it shows only Pinned or Off (`lore:marked`). The\n\t * refresh button stays.\n\t *\n\t * What goes wrong is said here, in this widget (R77) — never a toast every\n\t * lore widget shows. The book's owner and admins see the entries; anyone\n\t * else is told whose they are, because a widget declaration has no\n\t * visibility field of its own. So is a mark saved to the entry that a\n\t * dated amendment still decides in this session's story (the answer's\n\t * `heldBy`): the row reads as before, and the line says why.\n\t *\n\t * The markup carries no look (P3d): its elements carry `lore-entries.*`\n\t * widget parts and the default widget stylesheet draws them (STYLE-GUIDE\n\t * §6.16). State is the elements' own: a chosen filter is its radio's\n\t * `:checked`, a pressed mark its button's `aria-pressed`, an entry turned\n\t * off `data-off`.\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { SessionEntryV1, WidgetRequests } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tLORE_ENTRIES_FILTERS,\n\t\tLORE_ENTRIES_SORTS,\n\t\tcreateLatestAsk,\n\t\tloreEntriesEmptyLine,\n\t\tloreEntriesSpan,\n\t\tloreEntryName,\n\t\tloreEntryReadLine,\n\t\treadLoreEntriesSettings,\n\t\ttype LoreEntriesFilter,\n\t\ttype LoreEntriesSort\n\t} from \"@serene-pub/core-catalog/lore-entries\"\n\timport { useWidgetContext } from \"../context\"\n\n\ttype Answer = WidgetRequests[\"session-entries\"][\"result\"]\n\ttype Ask = WidgetRequests[\"session-entries\"][\"params\"]\n\n\t/** Whether to ask the page yet: false until the host has posted this instance's settings. */\n\tlet { ready = true }: { ready?: boolean } = $props()\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\n\t// Primitives, so a push that changes neither asks nothing again.\n\tconst pageSize = $derived(\n\t\treadLoreEntriesSettings(widget?.current?.settings?.v1 as Record<string, unknown> | undefined).pageSize\n\t)\n\tconst settledSort = $derived(\n\t\treadLoreEntriesSettings(widget?.current?.settings?.v1 as Record<string, unknown> | undefined).sort\n\t)\n\n\tlet query = $state(\"\")\n\tlet sort = $state<LoreEntriesSort | null>(null)\n\tconst effectiveSort = $derived<LoreEntriesSort>(sort ?? settledSort)\n\tlet filter = $state<LoreEntriesFilter>(\"all\")\n\tlet offset = $state(0)\n\n\tlet answer = $state<Answer | null>(null)\n\t/** Why the page could not be read, this widget's own. */\n\tlet readError = $state<string | null>(null)\n\t/** Why a mark did not change, this widget's own. */\n\tlet markError = $state<string | null>(null)\n\t/**\n\t * A mark saved to the entry that a dated amendment still decides here\n\t * (`heldBy`): the row reads as before, and this says why.\n\t */\n\tlet markHeld = $state<string | null>(null)\n\n\t/** The filter radios' group name: one per mount, so two copies never share a group (F8). */\n\tconst filterGroup = `sp-lore-filter-${Math.random().toString(36).slice(2, 10)}`\n\n\tconst latest = createLatestAsk()\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t// The search asks once typing pauses, not once per keystroke.\n\tlet searched = $state(\"\")\n\t$effect(() => {\n\t\tconst q = query.trim()\n\t\tconst timer = setTimeout(() => (searched = q), 250)\n\t\treturn () => clearTimeout(timer)\n\t})\n\n\tconst askParams = (): Ask => ({\n\t\t...(searched ? { titleOrKey: searched } : {}),\n\t\tsort: effectiveSort,\n\t\tfilter,\n\t\toffset,\n\t\tlimit: pageSize\n\t})\n\n\tfunction ask(params: Ask) {\n\t\tconst ctx = widget?.current\n\t\tif (!ctx) return\n\t\tconst ticket = latest.next()\n\t\tctx.request(\"session-entries\", params).then(\n\t\t\t(res) => {\n\t\t\t\tif (!latest.isLatest(ticket)) return\n\t\t\t\treadError = null\n\t\t\t\tanswer = res\n\t\t\t\t// The page pulls a page that ran past the end back to the last one.\n\t\t\t\tif (typeof res.offset === \"number\" && res.offset !== offset) offset = res.offset\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (!latest.isLatest(ticket)) return\n\t\t\t\treadError = reason(e)\n\t\t\t}\n\t\t)\n\t}\n\n\t/** Ask again for the page on screen. */\n\tconst refresh = () => untrack(() => ready && ask(askParams()))\n\n\t// Each change of the search, sort, filter, page or page size asks again —\n\t// and a mark's line, refused or held, goes with the view it was said over.\n\t$effect(() => {\n\t\tif (!ready) return\n\t\tconst params = askParams()\n\t\tuntrack(() => {\n\t\t\tmarkError = null\n\t\t\tmarkHeld = null\n\t\t\task(params)\n\t\t})\n\t})\n\n\t// A turn wrote the rankings these entries read (R81): ask again.\n\t$effect(() => untrack(() => widget?.current?.on(\"lore:ranked\", refresh)))\n\n\t// A mark changed elsewhere — another widget, another tab, the entry\n\t// editor — on an entry shown here: ask again, so this list is never the\n\t// stale one. Showing only Pinned or Off, on any entry: the event names the\n\t// entry but not how this session reads it now, and it may have joined.\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"lore:marked\", (e) => {\n\t\t\t\tif (e.kind !== \"lore:marked\") return\n\t\t\t\tif (filter === \"pinned\" || filter === \"off\" || answer?.rows.some((r) => r.id === e.entryId))\n\t\t\t\t\trefresh()\n\t\t\t})\n\t\t)\n\t)\n\n\tfunction setFilter(value: LoreEntriesFilter) {\n\t\tfilter = value\n\t\toffset = 0\n\t}\n\n\tasync function setMark(row: SessionEntryV1, mark: \"off\" | \"pinned\") {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tmarkError = null\n\t\tmarkHeld = null\n\t\ttry {\n\t\t\tconst now = await ctx.request(\"set-entry-marks\", {\n\t\t\t\tentryId: row.id,\n\t\t\t\t...(mark === \"off\" ? { off: !row.off } : { pinned: !row.pinned })\n\t\t\t})\n\t\t\tif (now.heldBy)\n\t\t\t\tmarkHeld = t(\n\t\t\t\t\tnow.heldBy.mark === \"off\"\n\t\t\t\t\t\t? \"Saved to the entry, but an amendment dated {date} still decides whether it is off here.\"\n\t\t\t\t\t\t: \"Saved to the entry, but an amendment dated {date} still decides whether it is pinned here.\"\n\t\t\t\t).replace(\"{date}\", now.heldBy.date)\n\t\t\tif (answer)\n\t\t\t\tanswer = {\n\t\t\t\t\t...answer,\n\t\t\t\t\trows: answer.rows.map((r) => (r.id === row.id ? { ...r, off: now.off, pinned: now.pinned } : r))\n\t\t\t\t}\n\t\t} catch (e) {\n\t\t\tmarkError = t(\"Not changed: {reason}\").replace(\"{reason}\", reason(e))\n\t\t}\n\t\t// What the filter shows may have moved either way.\n\t\trefresh()\n\t}\n\n\tconst span = $derived(answer ? loreEntriesSpan(offset, pageSize, answer.total) : null)\n\tconst readLine = (r: SessionEntryV1) => loreEntryReadLine(r, Date.now(), t)\n</script>\n\n<div data-widget-part=\"lore-entries.root\" data-widget=\"lore-entries\">\n\t{#if answer?.ownerOnly}\n\t\t<p data-widget-part=\"lore-entries.note\">\n\t\t\t{t(\"These entries are the lorebook owner's to manage.\")}\n\t\t</p>\n\t{:else if answer && answer.lorebookId === null}\n\t\t<p data-widget-part=\"lore-entries.note\">{t(\"This session reads no lorebook.\")}</p>\n\t{:else}\n\t\t<div data-widget-part=\"lore-entries.search-bar toolbar\">\n\t\t\t<label data-widget-part=\"lore-entries.search\">\n\t\t\t\t<span data-widget-part=\"lore-entries.search-label\">{t(\"Search entries by title or key\")}</span>\n\t\t\t\t<span data-widget-part=\"lore-entries.search-icon\">\n\t\t\t\t\t<sp-icon name=\"search\" size=\"14\"></sp-icon>\n\t\t\t\t</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.search-input\"\n\t\t\t\t\tplaceholder={answer\n\t\t\t\t\t\t? t(\"Search {total} entries\").replace(\"{total}\", String(answer.total))\n\t\t\t\t\t\t: t(\"Search entries\")}\n\t\t\t\t\tvalue={query}\n\t\t\t\t\toninput={(e) => {\n\t\t\t\t\t\tquery = e.currentTarget.value\n\t\t\t\t\t\toffset = 0\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-widget-part=\"lore-entries.refresh\"\n\t\t\t\taria-label={t(\"Refresh\")}\n\t\t\t\ttitle={t(\"Refresh\")}\n\t\t\t\tonclick={refresh}\n\t\t\t>\n\t\t\t\t<sp-icon name=\"refresh-cw\" size=\"14\"></sp-icon>\n\t\t\t</button>\n\t\t</div>\n\t\t<div data-widget-part=\"lore-entries.filter-bar toolbar\">\n\t\t\t<div data-widget-part=\"lore-entries.filters\" role=\"radiogroup\" aria-label={t(\"Show\")}>\n\t\t\t\t{#each LORE_ENTRIES_FILTERS as f (f.value)}\n\t\t\t\t\t<!-- Chosen is the radio's own `:checked`: the sheet reads it, no state attribute. -->\n\t\t\t\t\t<label data-widget-part=\"lore-entries.filter chip\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.filter-input\"\n\t\t\t\t\t\t\tname={filterGroup}\n\t\t\t\t\t\t\tvalue={f.value}\n\t\t\t\t\t\t\tchecked={filter === f.value}\n\t\t\t\t\t\t\tonchange={() => setFilter(f.value)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{t(f.label)}\n\t\t\t\t\t</label>\n\t\t\t\t{/each}\n\t\t\t</div>\n\t\t\t<span data-widget-part=\"lore-entries.sort\">\n\t\t\t\t<!-- The combobox's own label is the one visible \"Sort\" (the host draws it). -->\n\t\t\t\t<sp-combobox\n\t\t\t\t\tdata-widget-part=\"lore-entries.sort-field\"\n\t\t\t\t\tlabel={t(\"Sort\")}\n\t\t\t\t\tvalue={effectiveSort}\n\t\t\t\t\tonchange={(e: CustomEvent<{ value: string }>) => {\n\t\t\t\t\t\tconst next = LORE_ENTRIES_SORTS.find((s) => s.value === e.detail.value)\n\t\t\t\t\t\tif (!next) return\n\t\t\t\t\t\tsort = next.value\n\t\t\t\t\t\toffset = 0\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{#each LORE_ENTRIES_SORTS as o (o.value)}\n\t\t\t\t\t\t<sp-option value={o.value}>{t(o.label)}</sp-option>\n\t\t\t\t\t{/each}\n\t\t\t\t</sp-combobox>\n\t\t\t</span>\n\t\t</div>\n\n\t\t{#if readError}\n\t\t\t<p data-widget-part=\"lore-entries.alert\" role=\"alert\">{readError}</p>\n\t\t{/if}\n\t\t{#if markError}\n\t\t\t<p data-widget-part=\"lore-entries.alert\" role=\"alert\">{markError}</p>\n\t\t{/if}\n\t\t{#if markHeld}\n\t\t\t<p data-widget-part=\"lore-entries.held\" role=\"status\">{markHeld}</p>\n\t\t{/if}\n\n\t\t<ul data-widget-part=\"lore-entries.entries list\" aria-label={t(\"Lore entries\")}>\n\t\t\t{#each answer?.rows ?? [] as r (r.id)}\n\t\t\t\t<!-- Pressed marks are the buttons' own `aria-pressed`; an entry turned off is `data-off`. -->\n\t\t\t\t<li data-widget-part=\"lore-entries.entry row\" data-entry-id={r.id} data-off={r.off ? \"\" : undefined}>\n\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-text\">\n\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-title label\">\n\t\t\t\t\t\t\t{loreEntryName(r, t)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{#if r.keys.length}\n\t\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-keys\">{r.keys.join(t(\", \"))}</span>\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t<span data-widget-part=\"lore-entries.entry-read\">{readLine(r)}</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span data-widget-part=\"lore-entries.marks\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.pin\"\n\t\t\t\t\t\t\taria-pressed={r.pinned}\n\t\t\t\t\t\t\taria-label={t(\"Pin {name}\").replace(\"{name}\", r.title || t(\"entry {id}\").replace(\"{id}\", String(r.id)))}\n\t\t\t\t\t\t\ttitle={r.pinned ? t(\"Pinned: always read\") : t(\"Pin: always read\")}\n\t\t\t\t\t\t\tonclick={() => setMark(r, \"pinned\")}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"pin\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tdata-widget-part=\"lore-entries.off\"\n\t\t\t\t\t\t\taria-pressed={r.off}\n\t\t\t\t\t\t\taria-label={t(\"Turn {name} off\").replace(\"{name}\", r.title || t(\"entry {id}\").replace(\"{id}\", String(r.id)))}\n\t\t\t\t\t\t\ttitle={r.off ? t(\"Off: never read\") : t(\"Turn off: never read\")}\n\t\t\t\t\t\t\tonclick={() => setMark(r, \"off\")}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<sp-icon name=\"circle-off\" size=\"14\"></sp-icon>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</span>\n\t\t\t\t</li>\n\t\t\t{:else}\n\t\t\t\t{#if answer}\n\t\t\t\t\t<li data-widget-part=\"lore-entries.empty empty\">{loreEntriesEmptyLine(query, filter, t)}</li>\n\t\t\t\t{/if}\n\t\t\t{/each}\n\t\t</ul>\n\n\t\t{#if span?.paged}\n\t\t\t<div data-widget-part=\"lore-entries.pager\">\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.previous\"\n\t\t\t\t\tdisabled={!span.hasPrevious}\n\t\t\t\t\tonclick={() => (offset = span.previousOffset)}\n\t\t\t\t>\n\t\t\t\t\t{t(\"Previous\")}\n\t\t\t\t</button>\n\t\t\t\t<span data-widget-part=\"lore-entries.page-count\">\n\t\t\t\t\t{t(\"{from}–{to} of {total}\")\n\t\t\t\t\t\t.replace(\"{from}\", String(span.from))\n\t\t\t\t\t\t.replace(\"{to}\", String(span.to))\n\t\t\t\t\t\t.replace(\"{total}\", String(span.total))}\n\t\t\t\t</span>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"lore-entries.next\"\n\t\t\t\t\tdisabled={!span.hasNext}\n\t\t\t\t\tonclick={() => (offset = span.nextOffset)}\n\t\t\t\t>\n\t\t\t\t\t{t(\"Next\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t{/if}\n\t{/if}\n</div>\n","shared/lore-entries/lore-entries.ts":"/**\n * Core's `lore-entries` component (R21, R58): the session's lorebook entry\n * by entry, with what this session's rankings made of each, and the two\n * marks — **Off** and **Pin**. `npm run build` compiles it with the CLI's\n * component bundler to `dist/components/lore-entries.js`, the module the app\n * serves at `/core-ui/lore-entries`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport LoreEntries from './LoreEntries.svelte'\n\nexport default svelteComponent(LoreEntries)\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_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} 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\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// No host menu across the port yet: dismissed, as a native host without one answers.\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\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":"32f644c204e076b064b93832d72df3432bb48d4da4fa652b303fc01669ceda7a","catalogVersion":"0.6.0-pr-4"}
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
user_derived,
|
|
63
63
|
user_effect,
|
|
64
64
|
widgetRefFromComponent
|
|
65
|
-
} from "./shared-
|
|
65
|
+
} from "./shared-U3UU5V7L.js";
|
|
66
66
|
|
|
67
67
|
// ../sdk/dist/predicates.js
|
|
68
68
|
var truthy = (v) => !!v && !(Array.isArray(v) && v.length === 0);
|
|
@@ -826,7 +826,7 @@ var stalenessVerdict = defineVerdict({
|
|
|
826
826
|
failing: () => ({ block: { head: 3 }, headNow: 4 })
|
|
827
827
|
});
|
|
828
828
|
|
|
829
|
-
// dist/ui/
|
|
829
|
+
// dist/shared/ui/conversation/dossier.js
|
|
830
830
|
var NO_LINE = {
|
|
831
831
|
controllable: false,
|
|
832
832
|
speaker: { name: UNCLAIMED_LINE_NAME.en, ref: null, face: null, sprite: null },
|
|
@@ -834,7 +834,7 @@ var NO_LINE = {
|
|
|
834
834
|
embedding: "hidden"
|
|
835
835
|
};
|
|
836
836
|
|
|
837
|
-
// dist/ui/
|
|
837
|
+
// dist/shared/ui/conversation/formAnswer.js
|
|
838
838
|
var rowId = (text3) => {
|
|
839
839
|
if (!/^\d{1,10}$/.test(text3))
|
|
840
840
|
return null;
|
|
@@ -909,7 +909,7 @@ function answeredOf(block) {
|
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
911
|
|
|
912
|
-
// dist/ui/
|
|
912
|
+
// dist/shared/ui/conversation/itemValues.js
|
|
913
913
|
function itemSpeakerOf(row) {
|
|
914
914
|
const envoy = envoySlugOfRef(row.metadata?.speaker);
|
|
915
915
|
if (envoy)
|
|
@@ -943,7 +943,7 @@ function itemValuesOf(row, facts) {
|
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
945
|
|
|
946
|
-
// dist/ui/
|
|
946
|
+
// dist/shared/ui/conversation/messageOrder.js
|
|
947
947
|
function orderedMessages(messages, order) {
|
|
948
948
|
return order === "newest-first" ? [...messages].reverse() : messages;
|
|
949
949
|
}
|
|
@@ -951,13 +951,13 @@ function conversationIndex(row, total, order) {
|
|
|
951
951
|
return order === "newest-first" ? total - 1 - row : row;
|
|
952
952
|
}
|
|
953
953
|
|
|
954
|
-
// dist/ui/
|
|
954
|
+
// dist/shared/ui/conversation/messageSpeaker.js
|
|
955
955
|
function messageEnvoySlug(msg) {
|
|
956
956
|
const ref = msg.metadata?.speaker;
|
|
957
957
|
return typeof ref === "string" && ref.startsWith("envoy:") ? ref.slice("envoy:".length) : null;
|
|
958
958
|
}
|
|
959
959
|
|
|
960
|
-
// dist/ui/
|
|
960
|
+
// dist/shared/ui/conversation/text.js
|
|
961
961
|
function statusTextIn(status, language, t) {
|
|
962
962
|
if (!status)
|
|
963
963
|
return "";
|
|
@@ -972,7 +972,7 @@ function setStatusTextResolver(language, t) {
|
|
|
972
972
|
resolve = (status) => statusTextIn(status, language(), t);
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
-
// dist/ui/
|
|
975
|
+
// dist/shared/ui/conversation/messageVerbState.js
|
|
976
976
|
var isReply = (m) => m.role !== "user" && (!!m.characterId || !!m.isNarratorResponse);
|
|
977
977
|
var VERB_REASONS = Object.freeze({
|
|
978
978
|
notYours: "not yours to change",
|
|
@@ -1075,7 +1075,7 @@ function quickRowActions(primary, ctx) {
|
|
|
1075
1075
|
})).filter((q) => q.state.shown && !q.state.disabled);
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
|
-
// dist/ui/
|
|
1078
|
+
// dist/shared/ui/conversation/slashPalette.js
|
|
1079
1079
|
function slashQueryOf(draft) {
|
|
1080
1080
|
const m = /^\/([^\s]*)$/.exec(draft);
|
|
1081
1081
|
return m ? m[1] : null;
|
|
@@ -1165,7 +1165,7 @@ function stepHighlight(current, count2, delta) {
|
|
|
1165
1165
|
return (current + delta + count2) % count2;
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
|
-
// dist/ui/
|
|
1168
|
+
// dist/shared/ui/conversation/composerTray.js
|
|
1169
1169
|
var ATTACHMENT_KINDS_V1 = ["image", "text", "pdf"];
|
|
1170
1170
|
var KIND_PLURAL = {
|
|
1171
1171
|
image: "images",
|
|
@@ -1277,7 +1277,7 @@ function sendableTrayIds(tray) {
|
|
|
1277
1277
|
return tray.filter((t) => t.status === "ready").map((t) => t.id);
|
|
1278
1278
|
}
|
|
1279
1279
|
|
|
1280
|
-
// components/
|
|
1280
|
+
// components/shared/messages/MessageComposer.svelte
|
|
1281
1281
|
var root = from_html(`<span data-widget-part="messages.edit-tab-label">Compose</span>`);
|
|
1282
1282
|
var root_1 = from_html(`<sp-tab><span data-widget-part="messages.edit-tab-body"><sp-icon></sp-icon> <!></span></sp-tab>`, 2);
|
|
1283
1283
|
var root_2 = from_html(`<span data-widget-part="messages.edit-tab-label">Preview</span>`);
|
|
@@ -1889,7 +1889,7 @@ function get_current_url() {
|
|
|
1889
1889
|
return current_url;
|
|
1890
1890
|
}
|
|
1891
1891
|
|
|
1892
|
-
// components/
|
|
1892
|
+
// components/shared/messages/conversation.svelte.ts
|
|
1893
1893
|
var KEY = /* @__PURE__ */ Symbol("sp-conversation");
|
|
1894
1894
|
function isUnmountDecline(e) {
|
|
1895
1895
|
const code = typeof e === "object" && e !== null ? e.code : void 0;
|
|
@@ -2101,7 +2101,7 @@ function useT() {
|
|
|
2101
2101
|
return (source2) => w?.current.t?.(source2) ?? source2;
|
|
2102
2102
|
}
|
|
2103
2103
|
|
|
2104
|
-
// components/
|
|
2104
|
+
// components/shared/messages/MessageControls.svelte
|
|
2105
2105
|
var root2 = from_html(`<span data-widget-part="messages.message-option-note"> </span>`);
|
|
2106
2106
|
var root_16 = from_html(`<button data-widget-part="messages.message-option"><sp-icon></sp-icon> <span> </span></button> <!>`, 3);
|
|
2107
2107
|
var root_22 = from_html(`<button data-widget-part="messages.message-option" title="Select for summary" aria-label="Select this message for summarization"><sp-icon></sp-icon> <span>Select for summary</span></button>`, 2);
|
|
@@ -2421,7 +2421,7 @@ function MessageControls($$anchor, $$props) {
|
|
|
2421
2421
|
}
|
|
2422
2422
|
delegate(["click"]);
|
|
2423
2423
|
|
|
2424
|
-
// components/
|
|
2424
|
+
// components/shared/messages/MessageBlocksView.svelte
|
|
2425
2425
|
var root3 = from_html(`<div data-widget-part="messages.block-markdown messages.prose"><sp-message-body></sp-message-body></div>`, 2);
|
|
2426
2426
|
var root_17 = from_html(`<dt data-widget-part="messages.block-kv-label"> </dt> <dd> </dd>`, 1);
|
|
2427
2427
|
var root_23 = from_html(`<dl data-widget-part="messages.block-kv"></dl>`);
|
|
@@ -2947,7 +2947,7 @@ function MessageBlocksView_1($$anchor, $$props) {
|
|
|
2947
2947
|
}
|
|
2948
2948
|
delegate(["click", "change", "input"]);
|
|
2949
2949
|
|
|
2950
|
-
// components/
|
|
2950
|
+
// components/shared/messages/MessagePartsView.svelte
|
|
2951
2951
|
var root4 = from_html(`<sp-icon></sp-icon>`, 2);
|
|
2952
2952
|
var root_110 = from_html(`<li> </li>`);
|
|
2953
2953
|
var root_29 = from_html(`<ul data-widget-part="messages.fold-list"></ul>`);
|
|
@@ -3168,7 +3168,7 @@ function MessagePartsView($$anchor, $$props) {
|
|
|
3168
3168
|
}
|
|
3169
3169
|
delegate(["click"]);
|
|
3170
3170
|
|
|
3171
|
-
// components/
|
|
3171
|
+
// components/shared/messages/mediaStrip.ts
|
|
3172
3172
|
var MEDIA_STRIP_MAX_TILES = 6;
|
|
3173
3173
|
var text2 = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
|
|
3174
3174
|
var count = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : null;
|
|
@@ -3218,7 +3218,7 @@ function viewImageParams(images, index2) {
|
|
|
3218
3218
|
};
|
|
3219
3219
|
}
|
|
3220
3220
|
|
|
3221
|
-
// components/
|
|
3221
|
+
// components/shared/messages/MessageMediaStrip.svelte
|
|
3222
3222
|
var gone = ($$anchor, item = noop) => {
|
|
3223
3223
|
var div = root_111();
|
|
3224
3224
|
var sp_icon_1 = child(div);
|
|
@@ -3428,7 +3428,7 @@ function MessageMediaStrip($$anchor, $$props) {
|
|
|
3428
3428
|
}
|
|
3429
3429
|
delegate(["click"]);
|
|
3430
3430
|
|
|
3431
|
-
// components/
|
|
3431
|
+
// components/shared/messages/StateProposalList.svelte
|
|
3432
3432
|
var root6 = from_html(`<div data-widget-part="messages.proposal" data-superseded="true"><sp-icon></sp-icon> <span data-widget-part="messages.proposal-text"> <span data-widget-part="messages.proposal-note"> </span></span></div>`, 2);
|
|
3433
3433
|
var root_113 = from_html(`<span data-widget-part="messages.proposal-anchor"> </span>`);
|
|
3434
3434
|
var root_211 = from_html(`<div data-widget-part="messages.proposal"><sp-icon></sp-icon> <span data-widget-part="messages.proposal-text"> <!></span> <span data-widget-part="messages.proposal-note">proposed</span> <button data-widget-part="messages.proposal-decide messages.proposal-accept">Accept</button> <button data-widget-part="messages.proposal-decide messages.proposal-reject">Reject</button></div>`, 2);
|
|
@@ -3520,7 +3520,7 @@ function StateProposalList($$anchor, $$props) {
|
|
|
3520
3520
|
}
|
|
3521
3521
|
delegate(["click"]);
|
|
3522
3522
|
|
|
3523
|
-
// components/
|
|
3523
|
+
// components/shared/messages/MessageStateLedger.svelte
|
|
3524
3524
|
var root7 = from_html(`<span data-widget-part="messages.ledger-separator">\xB7</span>`);
|
|
3525
3525
|
var root_114 = from_html(`<!> <span data-widget-part="messages.ledger-change"> </span>`, 1);
|
|
3526
3526
|
var root_212 = from_html(`<p data-widget-part="messages.ledger-line"><span data-widget-part="messages.ledger-owner"> </span> <!></p>`);
|
|
@@ -3642,7 +3642,7 @@ function MessageStateLedger($$anchor, $$props) {
|
|
|
3642
3642
|
pop();
|
|
3643
3643
|
}
|
|
3644
3644
|
|
|
3645
|
-
// components/
|
|
3645
|
+
// components/shared/messages/SessionMessage.svelte
|
|
3646
3646
|
var root8 = from_html(`<span data-widget-part="messages.message-avatar-glyph" aria-hidden="true"><sp-icon></sp-icon></span>`, 2);
|
|
3647
3647
|
var root_115 = from_html(`<img data-widget-part="messages.message-avatar-img"/>`);
|
|
3648
3648
|
var root_213 = from_html(`<span data-widget-part="messages.message-avatar-glyph" aria-hidden="true"> </span>`);
|
|
@@ -4503,7 +4503,7 @@ function SessionMessage($$anchor, $$props) {
|
|
|
4503
4503
|
}
|
|
4504
4504
|
delegate(["click"]);
|
|
4505
4505
|
|
|
4506
|
-
// components/
|
|
4506
|
+
// components/shared/messages/SessionContainer.svelte
|
|
4507
4507
|
var root9 = from_html(`<div data-widget-part="messages.log-note messages.log-floor" role="status" data-scope-not-granted="session:full"><sp-icon></sp-icon> <span data-widget-part="messages.log-floor-text"> </span></div>`, 2);
|
|
4508
4508
|
var root_117 = from_html(`<div data-widget-part="messages.log-loading messages.log-floor"><sp-icon></sp-icon> <span data-widget-part="messages.log-floor-text">Loading session\u2026</span></div>`, 2);
|
|
4509
4509
|
var root_215 = from_html(`<div data-widget-part="messages.log-empty messages.log-floor empty"><sp-icon></sp-icon> <span data-widget-part="messages.log-floor-text">Send a message to start</span></div>`, 2);
|
|
@@ -4934,7 +4934,7 @@ function SessionContainer($$anchor, $$props) {
|
|
|
4934
4934
|
}
|
|
4935
4935
|
delegate(["click"]);
|
|
4936
4936
|
|
|
4937
|
-
// components/
|
|
4937
|
+
// components/shared/messages/SessionComposer.svelte
|
|
4938
4938
|
var root10 = from_html(`<div data-widget-part="messages.join"><div data-widget-part="messages.join-text"><sp-icon></sp-icon> <h3 data-widget-part="messages.join-title">Join the conversation</h3> <p data-widget-part="messages.join-note">Add a persona to this session to send messages.</p></div> <button data-widget-part="messages.join-button"><sp-icon></sp-icon> Add your persona</button></div>`, 2);
|
|
4939
4939
|
var root_119 = from_html(`<button type="button" data-widget-part="messages.composer-actions-toggle"><span>Actions</span> <sp-icon></sp-icon></button>`, 2);
|
|
4940
4940
|
var root_216 = from_html(`<div data-widget-part="messages.composer-notice"><sp-host-view></sp-host-view></div>`, 2);
|
|
@@ -6194,7 +6194,7 @@ function SessionComposer($$anchor, $$props) {
|
|
|
6194
6194
|
}
|
|
6195
6195
|
delegate(["keydown", "click", "mousedown", "input"]);
|
|
6196
6196
|
|
|
6197
|
-
// components/
|
|
6197
|
+
// components/shared/messages/NextCharacterBlock.svelte
|
|
6198
6198
|
var root11 = from_html(`<div data-widget-part="messages.next-up-waiting"><span data-widget-part="messages.next-up-text">Waiting for a message \u2014 or pick who speaks next</span> <button type="button" data-widget-part="messages.next-up-pick"><sp-icon></sp-icon> <span>Pick</span></button></div>`, 2);
|
|
6199
6199
|
var root_120 = from_html(`<sp-avatar></sp-avatar>`, 2);
|
|
6200
6200
|
var root_218 = from_html(`<sp-icon></sp-icon>`, 2);
|
|
@@ -6330,7 +6330,7 @@ function NextCharacterBlock($$anchor, $$props) {
|
|
|
6330
6330
|
}
|
|
6331
6331
|
delegate(["click"]);
|
|
6332
6332
|
|
|
6333
|
-
// components/
|
|
6333
|
+
// components/shared/messages/MessagesWidget.svelte
|
|
6334
6334
|
var CONVERSATION_DEFAULTS = {
|
|
6335
6335
|
order: "oldest-first",
|
|
6336
6336
|
composerSkin: "classic",
|
|
@@ -6629,7 +6629,7 @@ function MessagesWidget($$anchor, $$props) {
|
|
|
6629
6629
|
}
|
|
6630
6630
|
delegate(["click"]);
|
|
6631
6631
|
|
|
6632
|
-
// components/
|
|
6632
|
+
// components/shared/messages/Messages.svelte
|
|
6633
6633
|
function Messages($$anchor, $$props) {
|
|
6634
6634
|
push($$props, true);
|
|
6635
6635
|
setContext(WIDGET_CONTEXT_KEY, widgetRefFromComponent(untrack(() => $$props.ctx), { id: "messages", instanceId: "messages", title: "Messages" }));
|
|
@@ -6637,7 +6637,7 @@ function Messages($$anchor, $$props) {
|
|
|
6637
6637
|
pop();
|
|
6638
6638
|
}
|
|
6639
6639
|
|
|
6640
|
-
// components/
|
|
6640
|
+
// components/shared/messages/messages.ts
|
|
6641
6641
|
var messages_default = svelteComponent(Messages);
|
|
6642
6642
|
export {
|
|
6643
6643
|
messages_default as default
|