mirror of
https://github.com/scratchfoundation/scratch-link.git
synced 2024-11-14 19:05:03 -05:00
ae4eef4bb2
Also add a quick `global.d.ts` specifically for the playground. The playground stuff should probably move into a subdirectory...
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
|
|
// This file is only used for type-checking in playground.js
|
|
|
|
declare class ScratchLinkSafariSocket {
|
|
constructor(type: string);
|
|
static isSafariHelperCompatible(): boolean;
|
|
|
|
close(): void;
|
|
isOpen(): boolean;
|
|
open(): void;
|
|
sendMessage(message: object): void;
|
|
setHandleMessage(fn: (message: object) => void): void;
|
|
setOnClose(fn: (e: Error) => void): void;
|
|
setOnError(fn: (e: Error) => void): void;
|
|
setOnOpen(fn: () => void): void;
|
|
}
|
|
|
|
declare global {
|
|
class JSONRPC {
|
|
constructor();
|
|
didReceiveCall(method: string, params?: object): void;
|
|
sendRemoteNotification(method: string, params?: object): void;
|
|
sendRemoteRequest(method: string, params?: object): Promise<any>;
|
|
_handleMessage(jsonMessageObject: object): void;
|
|
_sendMessage(jsonMessageObject: object): void;
|
|
}
|
|
|
|
class ScratchLinkWebSocket {
|
|
constructor(type: string);
|
|
|
|
close(): void;
|
|
isOpen(): boolean;
|
|
open(): void;
|
|
sendMessage(message: object): void;
|
|
setHandleMessage(fn: (message: object) => void): void;
|
|
setOnClose(fn: (e: Error) => void): void;
|
|
setOnError(fn: (e: Error) => void): void;
|
|
setOnOpen(fn: () => void): void;
|
|
}
|
|
|
|
// This isn't proper TS but it seems to work for type checking in playground.js
|
|
var Scratch = {
|
|
BLE: new ScratchBLE,
|
|
BT: new ScratchBT,
|
|
ScratchLinkSafariSocket
|
|
};
|
|
}
|
|
export {};
|