MCPcopy
hub / github.com/anomalyco/opencode / createSlots

Function createSlots

packages/tui/src/plugin/slots.tsx:25–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25export function createSlots() {
26 const empty: SlotView = () => null
27 const [view, setView] = createSignal<SlotView>(empty)
28 const Slot: SlotView = (props) => view()(props)
29
30 return {
31 Slot,
32 setup(api: HostPluginApi): HostSlots {
33 const registry = createSolidSlotRegistry<RuntimeSlotMap, TuiSlotContext>(
34 api.renderer,
35 { theme: api.theme },
36 {
37 onPluginError(event) {
38 console.error("[tui.slot] plugin error", {
39 plugin: event.pluginId,
40 slot: event.slot,
41 phase: event.phase,
42 source: event.source,
43 message: event.error.message,
44 })
45 },
46 },
47 )
48 const slot = createSlot<RuntimeSlotMap, TuiSlotContext>(registry)
49 setView(() => (props: TuiSlotProps<string>) => slot(props))
50
51 return {
52 register(plugin: HostSlotPlugin) {
53 if (!isHostSlotPlugin(plugin)) return () => {}
54 return registry.register(plugin)
55 },
56 dispose() {
57 setView(() => empty)
58 },
59 }
60 },
61 clear() {
62 setView(() => empty)
63 },
64 }
65}

Callers 1

createPluginRuntimeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected