UNPKG

@vscode/sync-api-common

Version:

An RPC implementation between Web and NodeJS workers that works sync

53 lines (52 loc) 2.15 kB
import { Disposable } from './disposable'; import type { RequestType, ClientConnection, ServiceConnection, Params } from './connection'; interface _TextEncoder { encode(input?: string): Uint8Array; } interface _TextDecoder { decode(input?: Uint8Array): string; } interface _TestServiceConnection<RequestHandlers extends RequestType | undefined = undefined, ReadyParams extends Params | undefined = undefined> extends ServiceConnection<RequestHandlers, ReadyParams> { terminate(): Promise<number>; } export declare enum _RALType { Browser = 1, Node = 2 } interface RAL { readonly type: _RALType; readonly TextEncoder: { create(encoding?: string): _TextEncoder; }; readonly TextDecoder: { create(encoding?: string): _TextDecoder; }; readonly console: { info(message?: any, ...optionalParams: any[]): void; log(message?: any, ...optionalParams: any[]): void; warn(message?: any, ...optionalParams: any[]): void; error(message?: any, ...optionalParams: any[]): void; }; readonly timer: { setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable; setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable; setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable; }; readonly $testing: { readonly ClientConnection: { create<Requests extends RequestType | undefined = undefined, ReadyParams extends Params | undefined = undefined>(): ClientConnection<Requests, ReadyParams>; }; readonly ServiceConnection: { create<RequestHandlers extends RequestType | undefined = undefined, ReadyParams extends Params | undefined = undefined>(script: string, testCase?: string): _TestServiceConnection<RequestHandlers, ReadyParams>; }; readonly testCase: string; }; } declare function RAL(): RAL; declare namespace RAL { const Type: typeof _RALType; type TextEncoder = _TextEncoder; type TextDecoder = _TextDecoder; function install(ral: RAL): void; } export default RAL;