UNPKG

histoire

Version:

A fast story book powered by Vite

18 lines (17 loc) • 1.49 kB
import { createScreenshotTask } from '../mcp/browser/screenshot.js'; import { mcpToolInputSchemas } from '../mcp/protocol/tool-schema.js'; /** Immutable Node preview authority is shared by screenshots and inspection. */ export function resolveNodePreviewOptions(target, capture, launch) { const { artifact, catalog, host, origin } = capture.value; catalog.getTarget(target.storyId, target.variantId, capture.revision); const manifest = artifact.manifest; const setupOwner = launch ? undefined : capture.value.setupOwner; return { root: artifact.root, host, launch, ...(setupOwner ? { setupOwner } : {}), target: { origin, storyId: target.storyId, variantId: target.variantId, epoch: capture.epoch, width: target.width, height: target.height, deviceScaleFactor: target.deviceScaleFactor, globals: target.globals ?? manifest.globals, colorScheme: target.colorScheme ?? (manifest.defaultColorScheme === 'auto' ? undefined : manifest.defaultColorScheme), textDirection: target.textDirection, backgroundColor: manifest.backgroundColor, isActive: capture.isActive } }; } /** Install production screenshot executor without runtime source or Vite imports. */ export function registerNodeScreenshotExecutor(operations, launch) { operations.registerExecutor('screenshot', (input, capture) => { const target = mcpToolInputSchemas.histoire_capture_screenshot.parse(input); return createScreenshotTask(resolveNodePreviewOptions(target, capture, launch)); }); }