UNPKG

thebe-core

Version:

Typescript based core functionality for Thebe

49 lines (48 loc) 2.25 kB
import type ThebeSession from './session'; import type { IThebeCell, IThebeCellExecuteReturn } from './types'; import type { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import type { Config } from './config'; import { EventEmitter } from './emitter'; import type { INotebookContent, INotebookMetadata } from '@jupyterlab/nbformat'; export interface CodeBlock { id: string; source: string; [x: string]: any; } declare class ThebeNotebook { readonly id: string; readonly rendermime: IRenderMimeRegistry; cells: IThebeCell[]; metadata: INotebookMetadata; session?: ThebeSession; protected events: EventEmitter; constructor(id: string, config: Config, rendermime: IRenderMimeRegistry); static fromCodeBlocks(blocks: CodeBlock[], config: Config, rendermime: IRenderMimeRegistry): ThebeNotebook; static fromIpynb(ipynb: INotebookContent, config: Config, rendermime: IRenderMimeRegistry): ThebeNotebook; get parameters(): IThebeCell[] | undefined; get widgets(): IThebeCell[]; get last(): IThebeCell; get markdown(): IThebeCell[]; get code(): IThebeCell[]; /** * reset the notebook to its initial state by resetting each cell * * @param hideWidgets boolean */ reset(): void; numCells(): number; findCells(tag: string): IThebeCell[] | undefined; getCell(idx: number): IThebeCell; getCellById(id: string): IThebeCell | undefined; lastCell(): IThebeCell; updateParameters(newSource: string, interpolate?: boolean): void; waitForKernel(kernel: Promise<ThebeSession>): Promise<ThebeSession>; attachSession(session: ThebeSession): void; detachSession(): void; clear(): void; executeUpTo(cellId: string, stopOnError?: boolean, preprocessor?: (s: string) => string): Promise<(IThebeCellExecuteReturn | null)[]>; executeOnly(cellId: string, preprocessor?: (s: string) => string): Promise<IThebeCellExecuteReturn | null>; executeCells(cellIds: string[], stopOnError?: boolean, preprocessor?: (s: string) => string): Promise<(IThebeCellExecuteReturn | null)[]>; executeAll(stopOnError?: boolean, preprocessor?: (s: string) => string): Promise<(IThebeCellExecuteReturn | null)[]>; } export default ThebeNotebook;