text stringlengths 0 1.47k |
|---|
/** The Conversation event registry, where the host has one (dsh 0.1.2+). */ |
interface ConversationEvents { |
register(definition: ConversationNodeDefinition): () => void |
} |
/** |
* Look up the Conversation event registry without declaring the service, so |
* hosts that predate it still load the plugin. |
* @param host - client context. |
* @returns the registry, or undefined on dsh 0.1.1. |
*/ |
function conversationEvents(host: FoldingHost): ConversationEvents | undefined { |
const service = host.get('uiConversation') as { events?: Partial<ConversationEvents> } | undefined |
return typeof service?.events?.register === 'function' ? service.events as ConversationEvents : undefined |
} |
/** |
* Turn-tail registration valid on both slot shapes the host has shipped: dsh |
* 0.1.5 and earlier declare a chain (register requires `select`, orders by |
* `priority`), 0.1.6 onward a list (register requires `id`, orders by |
* `order`). Each register validates only its own kind's field. The cards sit |
* after the host's deliverables and before other plugins' low-rank entries. |
* @param host - client context, for the folding preference. |
* @returns the register options. |
*/ |
function turnTailOptions(host: FoldingHost) { |
const folds = foldingSource(host) |
return { |
name: 'conversation.chat.turnTail', |
id: 'dsh-visualize-cards', |
order: 100, |
priority: 100, |
select: selectTurnCards, |
inject: () => ({ hooks: { visualizeFolds: folds } }), |
} as const |
} |
/** |
* Register the keyed toolview and the dock preview. Waiting on each hole's |
* declaration mirrors the official registrants: entry application order is |
* loader-driven, and a direct register racing the declaration fails boot. |
* @param ctx - client root context. |
*/ |
export function apply(ctx: ClientContext): void { |
ctx.slots.inject('tool.call.toolview', () => ctx.slots.register( |
{ name: 'tool.call.toolview', key: 'visualize' }, |
VisualizeCard, |
)) |
ctx.slots.inject('conversation.input.dock', () => ctx.slots.register( |
{ name: 'conversation.input.dock', id: 'visualize-stream', order: 30 }, |
StreamingPreview, |
)) |
// The Chat target declares the turn tail after its own settings and the |
// Conversation registry are up, so both are resolvable here. |
ctx.slots.inject('conversation.chat.turnTail', () => { |
const events = conversationEvents(ctx) |
if (events === undefined) return () => undefined |
const disposeDefinition = events.register(turnCardsDefinition as ConversationNodeDefinition) |
const disposeTail = ctx.slots.register(turnTailOptions(ctx), TurnCards) |
return () => { |
disposeTail() |
disposeDefinition() |
} |
}) |
} |
# ===== file: src/client/theme.ts ===== |
/** |
* Host-theme resolution shared by the settled card and the streaming preview: |
* reads the DSH `--dsw-alias-*` design tokens (whale-blue brand accent |
* included) off `document.body` and derives the host color scheme. The body is |
* the read point because DSH mounts the token definitions there (dark override |
* under `body[data-ds-dark-theme]`), and custom properties only cascade |
* DOWNWARD — a `:root`-mounted theme still reaches the body by inheritance, |
* the reverse read never works. Missing tokens resolve to empty strings the |
* shell drops, so the frame stylesheet's `light-dark()` fallbacks apply |
* outside DSH. |
*/ |
/** Host design token → frame variable bridge (values resolved per render). */ |
const TOKEN_BRIDGE: readonly (readonly [string, string])[] = [ |
['foreground', '--dsw-alias-label-primary'], |
['card', '--dsw-alias-bg-layer-1'], |
['muted-foreground', '--dsw-alias-label-caption'], |
['border', '--dsw-alias-border-l2'], |
['primary', '--dsw-alias-brand-primary-new-colorprimary-new-color'], |
['primary-foreground', '--dsw-alias-label-primary-inverted'], |
] |
/** The bridged palette and scheme for one frame document build. */ |
export interface ResolvedTheme { |
themeVars: Record<string, string> |
colorScheme: 'light' | 'dark' |
} |
/** |
* Resolve the bridged palette and the host color scheme from computed style. |
* @returns the palette map and scheme for {@link buildFrameDoc}. |
*/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.