summaryrefslogtreecommitdiff
path: root/js/libdeno.ts
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-02-09 13:55:40 -0800
committerRyan Dahl <ry@tinyclouds.org>2019-02-09 16:55:40 -0500
commit1d36eb47eb882cb9305a6338019fa2a2b375d7b1 (patch)
tree4584aff9da784f3e05c4fb5314d5911772b4d655 /js/libdeno.ts
parent1502051453bf16787a59f43004b24d553d39bd26 (diff)
Support scoped variables, unblock REPL async op, and REPL error colors (#1721)
Diffstat (limited to 'js/libdeno.ts')
-rw-r--r--js/libdeno.ts47
1 files changed, 22 insertions, 25 deletions
diff --git a/js/libdeno.ts b/js/libdeno.ts
index 401ffae40..7d2bc3ede 100644
--- a/js/libdeno.ts
+++ b/js/libdeno.ts
@@ -3,11 +3,17 @@ import { globalEval } from "./global_eval";
// The libdeno functions are moved so that users can't access them.
type MessageCallback = (msg: Uint8Array) => void;
-export type PromiseRejectEvent =
- | "RejectWithNoHandler"
- | "HandlerAddedAfterReject"
- | "ResolveAfterResolved"
- | "RejectAfterResolved";
+
+interface EvalErrorInfo {
+ // Is the object thrown a native Error?
+ isNativeError: boolean;
+ // Was the error happened during compilation?
+ isCompileError: boolean;
+ // The actual thrown entity
+ // (might be an Error or anything else thrown by the user)
+ // If isNativeError is true, this is an Error
+ thrown: any; // tslint:disable-line:no-any
+}
interface Libdeno {
recv(cb: MessageCallback): void;
@@ -20,26 +26,17 @@ interface Libdeno {
builtinModules: { [s: string]: object };
- setGlobalErrorHandler: (
- handler: (
- message: string,
- source: string,
- line: number,
- col: number,
- error: Error
- ) => void
- ) => void;
-
- setPromiseRejectHandler: (
- handler: (
- error: Error | string,
- event: PromiseRejectEvent,
- /* tslint:disable-next-line:no-any */
- promise: Promise<any>
- ) => void
- ) => void;
-
- setPromiseErrorExaminer: (handler: () => boolean) => void;
+ /** Evaluate provided code in the current context.
+ * It differs from eval(...) in that it does not create a new context.
+ * Returns an array: [output, errInfo].
+ * If an error occurs, `output` becomes null and `errInfo` is non-null.
+ */
+ evalContext(
+ code: string
+ ): [any, EvalErrorInfo | null] /* tslint:disable-line:no-any */;
+
+ // tslint:disable-next-line:no-any
+ errorToJSON: (e: Error) => string;
}
const window = globalEval("this");