2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-10-03 21:41:59 -04:00
|
|
|
import { globalEval } from "./global_eval";
|
2018-08-25 15:42:49 -04:00
|
|
|
|
|
|
|
// The libdeno functions are moved so that users can't access them.
|
|
|
|
type MessageCallback = (msg: Uint8Array) => void;
|
2018-10-12 14:22:52 -04:00
|
|
|
export type PromiseRejectEvent =
|
|
|
|
| "RejectWithNoHandler"
|
|
|
|
| "HandlerAddedAfterReject"
|
|
|
|
| "ResolveAfterResolved"
|
|
|
|
| "RejectAfterResolved";
|
|
|
|
|
2018-08-25 15:42:49 -04:00
|
|
|
interface Libdeno {
|
|
|
|
recv(cb: MessageCallback): void;
|
|
|
|
|
2018-09-27 17:33:10 -04:00
|
|
|
send(control: ArrayBufferView, data?: ArrayBufferView): null | Uint8Array;
|
2018-08-25 15:42:49 -04:00
|
|
|
|
2018-09-25 01:27:02 -04:00
|
|
|
print(x: string, isErr?: boolean): void;
|
2018-08-25 15:42:49 -04:00
|
|
|
|
2018-10-24 02:17:10 -04:00
|
|
|
shared: ArrayBuffer;
|
|
|
|
|
2019-01-06 16:32:21 -05:00
|
|
|
builtinModules: { [s: string]: object };
|
|
|
|
|
2018-08-26 03:57:16 -04:00
|
|
|
setGlobalErrorHandler: (
|
|
|
|
handler: (
|
|
|
|
message: string,
|
|
|
|
source: string,
|
|
|
|
line: number,
|
|
|
|
col: number,
|
|
|
|
error: Error
|
|
|
|
) => void
|
|
|
|
) => void;
|
|
|
|
|
2018-10-12 14:22:52 -04:00
|
|
|
setPromiseRejectHandler: (
|
|
|
|
handler: (
|
|
|
|
error: Error | string,
|
|
|
|
event: PromiseRejectEvent,
|
|
|
|
/* tslint:disable-next-line:no-any */
|
|
|
|
promise: Promise<any>
|
|
|
|
) => void
|
|
|
|
) => void;
|
|
|
|
|
|
|
|
setPromiseErrorExaminer: (handler: () => boolean) => void;
|
2018-08-25 15:42:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const window = globalEval("this");
|
|
|
|
export const libdeno = window.libdeno as Libdeno;
|