thebe-core
Version:
Typescript based core functionality for Thebe
74 lines (73 loc) • 2.3 kB
TypeScript
import type ThebeCodeCell from './cell';
import type ThebeNotebook from './notebook';
import type ThebeServer from './server';
import type ThebeSession from './session';
import type { IError } from '@jupyterlab/nbformat';
export declare enum ServerStatusEvent {
'launching' = "launching",
'ready' = "server-ready",
'closed' = "closed",
'unknown' = "unknown"
}
export declare enum SessionStatusEvent {
'starting' = "starting",
'ready' = "ready",
'shutdown' = "shutdown"
}
export declare enum KernelStatusEvent {
'starting' = "starting",
'ready' = "ready",
'shutdown' = "shutdown"
}
export declare enum NotebookStatusEvent {
'attached' = "attached",
'detached' = "detached",
'executing' = "executing",
'idle' = "idle"
}
export declare enum CellStatusEvent {
'attached' = "attached",
'detached' = "detached",
'executing' = "executing",
'idle' = "idle"
}
export declare enum EventSubject {
'server' = "server",
'session' = "session",
'kernel' = "kernel",
'notebook' = "notebook",
'cell' = "cell"
}
export declare enum ErrorStatusEvent {
'warning' = "warning",
'executeError' = "execute-error",
'error' = "error",
'server' = "server-error",
'session' = "session-error"
}
export declare function errorToMessage(json: IError): string;
export declare enum ThebeEventType {
'status' = "status",
'error' = "error"
}
export type EventObject = ThebeServer | ThebeSession | ThebeNotebook | ThebeCodeCell;
export type StatusEvent = ServerStatusEvent | SessionStatusEvent | NotebookStatusEvent | CellStatusEvent | KernelStatusEvent | ErrorStatusEvent;
export interface ThebeEventData {
subject?: EventSubject;
id?: string;
status?: StatusEvent;
message: string;
object?: EventObject;
}
export type ThebeEventCb = (event: string, data: ThebeEventData) => void;
export declare class ThebeEvents {
listeners: Record<string, Map<ThebeEventCb, {
unbind: boolean;
}>>;
constructor();
_ensureMap(event: string): void;
trigger(event: ThebeEventType, evt: ThebeEventData): void;
on(event: ThebeEventType, cb: ThebeEventCb): () => void;
one(event: ThebeEventType, cb: ThebeEventCb): () => void;
off(event: ThebeEventType, cb: ThebeEventCb): void;
}