A React table component that handles span data through message passing with flexible data type support.
postMessage events with structured dataThe component accepts two types of messages:
{
type: 'data',
data: {
span_id: string,
input: unknown,
output: unknown,
expected: unknown,
metadata: unknown | null
}
}
{
type: 'settings',
settings: {
theme: 'light' | 'dark',
readOnly: boolean
}
}
The component automatically listens for window.postMessage events and validates them against the schema. Invalid messages are logged as errors but don't crash the component.
window.postMessage({
type: 'data',
data: {
span_id: 'unique-id',
input: 'Some input text',
output: 'Some output text',
expected: 'Expected result',
metadata: { additional: 'info' }
}
}, '*');
window.postMessage({
type: 'settings',
settings: {
theme: 'dark',
readOnly: true
}
}, '*');
The component includes sample data on load:
├── backend/
│ └── index.ts # Hono server for serving files
├── frontend/
│ ├── components/
│ │ └── SpanTable.tsx # Main table component
│ └── index.html # Demo page with test messages
└── README.md
GET / - Serves the main demo pageGET /frontend/* - Serves frontend static filesPOST /api/send-message - Test endpoint for message sendingGET /api/health - Health check endpointThe demo page automatically sends test messages to demonstrate the component functionality: