UNPKG

ive-connect

Version:

A universal haptic device control library for interactive experiences

114 lines (113 loc) 3.15 kB
/** * Handy API Implementation * * Based on the official Handy API */ import { HandyDeviceInfo, HspState, StrokeSettings } from "./types"; export declare class HandyApi { private readonly baseV3Url; private readonly baseV2Url; private readonly applicationId; private connectionKey; private serverTimeOffset; private _eventSource; constructor(baseV3Url: string, baseV2Url: string, applicationId: string, connectionKey?: string); /** * Set the connection key for API requests */ setConnectionKey(connectionKey: string): void; /** * Get the connection key */ getConnectionKey(): string; /** * Set the server time offset for synchronization */ setServerTimeOffset(offset: number): void; /** * Get the server time offset */ getServerTimeOffset(): number; /** * Estimate the current server time based on local time and offset */ estimateServerTime(): number; /** * Get headers for API requests */ private getHeaders; /** * Make an API request with error handling */ private request; /** * Check if the device is connected */ isConnected(): Promise<boolean>; /** * Get device information */ getDeviceInfo(): Promise<HandyDeviceInfo | null>; /** * Get the current device mode */ getMode(): Promise<number | null>; /** * Upload a script file to the hosting service * Returns the URL where the script can be accessed */ uploadScript(scriptFile: File | Blob): Promise<string | null>; /** * Setup script for HSSP playback */ setupScript(scriptUrl: string): Promise<boolean>; /** * Start playback with the HSSP protocol */ play(videoTime: number, playbackRate?: number, loop?: boolean): Promise<HspState | null>; /** * Stop playback */ stop(): Promise<HspState | null>; /** * Synchronize the device's time with video time */ syncVideoTime(videoTime: number, filter?: number): Promise<boolean>; /** * Get the current time offset */ getOffset(): Promise<number>; /** * Set the time offset */ setOffset(offset: number): Promise<boolean>; /** * Get the current stroke settings */ getStrokeSettings(): Promise<StrokeSettings | null>; /** * Set the stroke settings */ setStrokeSettings(settings: { min: number; max: number; }): Promise<StrokeSettings | null>; /** * Get the server time for synchronization calculations */ getServerTime(): Promise<number | null>; /** * Synchronize time with the server * Returns calculated server time offset */ syncTime(sampleCount?: number): Promise<number>; /** * Create an EventSource for server-sent events */ createEventSource(): EventSource; /** * Close the EventSource if it exists */ closeEventSource(): void; } export declare const createHandyApi: (baseV3Url: string, baseV2Url: string, applicationId: string, connectionKey?: string) => HandyApi;