UNPKG

@codesandbox/sdk

Version:
34 lines (33 loc) 1.28 kB
import { PitcherResponseStatus } from "./index"; export interface PitcherRequestPayload { id: number; method: string; params: unknown; } export interface PitcherNotificationPayload { method: string; params: unknown; } export interface PitcherResponsePayload { id: number; method: string; status: PitcherResponseStatus.RESOLVED; result: unknown; } export interface PitcherErrorPayload { id: number; status: PitcherResponseStatus.REJECTED; error: { code: number; data?: unknown; message: string; }; } export declare function encodeMessage(message: any): Uint8Array; export declare function decodeMessage(blob: Uint8Array): any; export declare function isNotificationPayload(payload: any): payload is PitcherNotificationPayload; export declare function isErrorPayload(payload: any): payload is PitcherErrorPayload; export declare function isResultPayload(payload: any): payload is PitcherResponsePayload; export declare function createNotificationPayload(payload: PitcherNotificationPayload): Uint8Array; export declare function createRequestPayload(payload: PitcherRequestPayload): Uint8Array; export declare function createResponsePayload(payload: PitcherResponsePayload | PitcherErrorPayload): Uint8Array;