import { HexView } from '../components/HexView'; import { MetadataCard } from '../components/MetadataCard'; import { base64ToBytes } from '../utils/download'; import type { ResponseRenderer } from './types'; export const imageRenderer: ResponseRenderer = { id: 'image', matches: (contentType, body) => typeof body === 'object' && body !== null && body.kind === 'binary' && contentType.startsWith('image/'), views: ['preview', 'raw'], defaultView: 'preview', supportsOverride: false, render: ({ view, body, ctx }) => { if (typeof body !== 'object' || body === null || body.kind !== 'binary') { return null; } if (view === 'preview') { const dataUrl = `data:${ctx.contentType};base64,${body.base64}`; return ( Response image ); } return (
); }, };