/** * Streaming Message Renderer * * Replaces SillyTavern's native message display with custom Vue components, * supporting both live streaming and static rendering. * * Clean room implementation — MIT License */ import { inject, reactive, readonly, type App, type Reactive } from 'vue'; // --------------------------------------------------------------------------- // Context injected into each streaming message component // --------------------------------------------------------------------------- export type StreamingMessageContext = { /** Unique prefix for this renderer instance */ prefix: string; /** DOM element ID: `${prefix}-${message_id}` */ host_id: string; /** Index of the message being rendered */ message_id: number; /** Raw message content (updated during streaming) */ message: string; /** True while the message is actively streaming */ during_streaming: boolean; }; /** * Inject the streaming message context inside a component. * Must be called during setup() of a component rendered by mountStreamingMessages. */ export function injectStreamingMessageContext(): Readonly { return readonly(inject('streaming_message_context')!); } // --------------------------------------------------------------------------- // iframe / div host helpers // --------------------------------------------------------------------------- function createHostIframe(prefix: string, messageId: number): JQuery { return $('