Surface Input Schemas (src/service-surface-schemas.ts)

openchamber · packages/sdk/src/service-surface-schemas.ts · typescript · MIT
integration, database, ui, tag:surface, tag:validation

Defines Zod schemas for surface interaction events, messages, and controller commands used in remote surface communication.

// Source: https://github.com/openchamber/openchamber | License: MIT | Copyright 2025 Bohdan Triapitsyn
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from 'zod';

import {
  SURFACE_CONTROLLERS,
  SURFACE_DIMENSION_MAX,
  SURFACE_FRAME_MIMES,
  SURFACE_INPUT_BATCH_MAX,
  SURFACE_TEXT_MAX,
  SURFACE_TITLE_MAX,
} from './service-surface.ts';

const modifiersSchema = z.object({ alt: z.boolean(), ctrl: z.boolean(), meta: z.boolean(), shift: z.boolean() });

const finite = z.number().finite();

export const surfaceInputEventSchema = z.discriminatedUnion('type', [
  z.object({
    type: z.literal('pointer'),
    action: z.enum(['down', 'up', 'move']),
    x: finite,
    y: finite,
    button: z.number().int().min(-1).max(4),
    buttons: z.number().int().min(0).ma

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key