Referencia de API
Referencia de Tipos
Definiciones de tipos TypeScript para el SDK VIDTREO.
Referencia de Tipos
Todos los tipos TypeScript exportados por los paquetes del SDK VIDTREO.
Tipos Principales
RecordingState
type RecordingState = 'idle' | 'countdown' | 'recording';SourceType
type SourceType = 'camera' | 'screen';RecordingStopResult
interface RecordingStopResult {
recordingId: string; // Identificador único de grabación
uploadUrl: string; // URL directa al video
blob: Blob; // Blob de video local
integrity?: IntegrityReport; // con integrity.enabled: el informe enviado con la subida
}RecordingMarkerInput / RecordingMarker
interface RecordingMarkerInput {
id: string; // 1 a 64 caracteres, único en la grabación
label: string; // 1 a 500 caracteres
}
interface RecordingMarker extends RecordingMarkerInput {
time: number; // segundos desde el inicio de la grabación, sin contar pausas
}Consulta Marcas de grabación.
IntegrityOptions / IntegrityReport
interface IntegrityOptions {
enabled: boolean;
policy?: 'report' | 'warn' | 'block'; // por defecto 'report'
challenges?: {
enabled: boolean;
count?: number; // por defecto 1; como máximo 25 gestos o 50 read-words
windowSeconds?: number; // por defecto 8
delaySeconds?: { min: number; max: number }; // por defecto 10 a 40
types?: Array<'turn-head-left' | 'turn-head-right' | 'hand-over-face' | 'read-words'>;
seed?: string;
lang?: 'en' | 'es';
burnIn?: boolean; // por defecto true
};
}
interface IntegritySignal {
code: IntegritySignalCode; // p. ej. "session.tab-hidden"
start: number; // segundos desde el inicio de la grabación, sin contar pausas
end: number | null; // null para un instante
confidence: 'low' | 'medium' | 'high' | 'insufficient';
source: 'sdk' | 'server';
detail: Record<string, string | number | boolean>;
}
interface IntegrityReport {
version: 1;
policy: 'report' | 'warn' | 'block';
recorder: { version: string; route: 'local-webcodecs' | 'safe-capture' };
capture: {
startedAt: string;
devices: IntegrityDevice[];
frameTiming: FrameTiming | null;
challenges: IntegrityChallenge[];
manifest: IntegrityManifest | null;
};
signals: IntegritySignal[];
truncated: boolean;
}IntegrityChallengePrompt ({ id, type, text, shownAt, windowSeconds, alternative }) e IntegrityBlockedReason ({ code, label, pattern }) son los datos que reciben onIntegrityChallenge y onIntegrityBlocked. Consulta Integridad de la captura para cada campo y código de señal.
AvailableDevices
interface AvailableDevices {
video: MediaDeviceInfo[]; // Cámaras disponibles
audio: MediaDeviceInfo[]; // Micrófonos disponibles
}Tipos de Configuración
VidtreoRecorderConfig
interface VidtreoRecorderConfig {
apiKey: string;
apiUrl?: string;
enableSourceSwitching?: boolean;
enableMute?: boolean;
enablePause?: boolean;
enableDeviceChange?: boolean;
maxRecordingTime?: number;
countdownDuration?: number;
userMetadata?: Record<string, unknown>;
onUploadComplete?: (result: UploadCompleteResult) => void;
onUploadProgress?: (progress: number) => void;
onUploadError?: (error: Error) => void;
onRecordingStart?: () => void;
onRecordingStop?: () => void;
onError?: (error: Error) => void;
integrity?: IntegrityOptions;
onIntegritySignal?: (signal: IntegritySignal) => void;
onIntegrityBlocked?: (reason: IntegrityBlockedReason) => void;
onIntegrityChallenge?: (prompt: IntegrityChallengePrompt) => void;
onIntegrityChallengeEnd?: (id: string) => void;
}Tipos de React
VidtreoRecorderState
interface VidtreoRecorderState {
recordingState: RecordingState;
stream: MediaStream | null;
isMuted: boolean;
isPaused: boolean;
error: string | null;
countdown: number | null;
timer: string;
uploadProgress: number | null;
isInitialized: boolean;
recordedBlob: Blob | null;
devices: {
cameras: MediaDeviceInfo[];
microphones: MediaDeviceInfo[];
selectedCamera: string | null;
selectedMic: string | null;
};
}VidtreoRecorderActions
interface VidtreoRecorderActions {
startRecording(sourceType?: SourceType): Promise<void>;
stopRecording(): Promise<RecordingStopResult>;
pauseRecording(): void;
resumeRecording(): void;
toggleMute(): void;
switchSource(sourceType: SourceType): Promise<void>;
changeCamera(deviceId: string): Promise<void>;
changeMic(deviceId: string): Promise<void>;
startPreview(sourceType?: SourceType): Promise<void>;
mark(marker: RecordingMarkerInput): void;
downloadVideo(): void;
cleanup(): void;
}VidtreoRecorderHandle
El ref del componente <VidtreoRecorder> de React. El componente de Vue expone la misma forma como VidtreoRecorderExposed.
interface VidtreoRecorderHandle {
mark(marker: RecordingMarkerInput): void;
}Consulta Marcas de grabación.
Importando Tipos
// Del Core SDK
import type {
VidtreoRecorderConfig,
RecordingState,
SourceType,
RecordingStopResult,
RecordingMarkerInput,
RecordingMarker,
IntegrityOptions,
IntegrityReport,
IntegritySignal,
AvailableDevices,
} from '@vidtreo/recorder';
// Del paquete React
import type {
VidtreoRecorderProps,
VidtreoRecorderState,
VidtreoRecorderActions,
PartialTranslations,
} from '@vidtreo/recorder-react';