histoire
Version:
A fast story book powered by Vite
32 lines (31 loc) • 1.46 kB
JavaScript
import { registerMarketplaceChannels } from '../../marketplace/channel.js';
import { getContextRegistry } from '../../runtime/registry.js';
import { createUiChannel } from './channel.js';
import { registerMcpChannel } from './mcp.js';
import { registerScreenshotSetupChannel } from './screenshot-setup.js';
import { registerScreenshotChannel } from './screenshot.js';
import { registerVisualChannel } from './visual.js';
/** Generation-scoped integration point for config, comments, and ACP features. */
const channels = new WeakMap();
/** Install dev-only handlers once on the generation's existing Vite socket. */
export function registerUiChannel(ctx, server, execution, isActive) {
const existing = channels.get(ctx);
if (existing)
return existing;
const channel = createUiChannel(server, isActive);
channels.set(ctx, channel);
getContextRegistry(ctx).cleanup.add(async () => {
channels.delete(ctx);
await channel.close();
});
registerScreenshotChannel(ctx, server, channel, execution, isActive);
registerVisualChannel(ctx, server, channel, execution, isActive);
registerScreenshotSetupChannel(ctx, channel, execution, isActive);
registerMcpChannel(ctx, channel);
registerMarketplaceChannels(ctx, channel, isActive);
return channel;
}
/** Additional dev slices attach handlers to this exact generation's channel. */
export function getUiChannel(ctx) {
return channels.get(ctx);
}