import { ChildrenLike, VirtualDOM } from '@youwol/rx-vdom'; import { CodeSnippetView } from '../md-widgets'; import { CellCommonAttributes } from './notebook-page'; import { CellTrait, ExecArgs, Scope, State } from './state'; import { BehaviorSubject, Observable } from 'rxjs'; /** * All attributes available for a {@link InterpreterCellView}. */ export type InterpreterCellAttributes = CellCommonAttributes & { /** * Name (exported symbol) of the JavaScript HTTP client used as an interpreter. */ interpreter: string; /** * Language used for syntax highlighting in the editor. */ language: 'javascript' | 'python'; /** * Captured variable name forwarded to the interpreter as input. * In the `interpreter-cell` DOM element, it is the attribute `captured-in` with * value defining the name of captured variables separated by space. */ capturedIn?: string[]; /** * Captured variable name forwarded from the interpreter as output. * In the `interpreter-cell` DOM element, it is the attribute `captured-out` with * value defining the name of captured variables separated by space. */ capturedOut?: string[]; }; /** * * Represents a cell that runs using a dedicated backend interpreter within a {@link NotebookPage}. * * They are typically included from a DOM definition with tag name `interpreter-cell` in MarkDown content, * see {@link InterpreterCellView.FromDom}. */ export declare class InterpreterCellView implements VirtualDOM<'div'>, CellTrait { readonly tag = "div"; /** * Classes associated with the view. */ readonly class = "mknb-InterpreterCellView"; readonly children: ChildrenLike; /** * Cell's ID. */ readonly cellId: string; /** * Cell's attributes. */ readonly cellAttributes: InterpreterCellAttributes; /** * State manager, owned by the parent {@link NotebookPage}. */ readonly state: State; readonly editorView: CodeSnippetView; /** * Observable over the source content of the cell. */ readonly content$: BehaviorSubject; /** * Emit when the cell is invalidated. */ readonly invalidated$: Observable; /** * Current state regarding whether the cell is reactive. */ readonly reactive$: BehaviorSubject; /** * Defines the methods to retrieve constructor's arguments from the DOM element `interpreter-cell` within * MarkDown content. * * * Be mindful of the conversion from `camelCase` to `kebab-case`. * */ static readonly FromDomAttributes: { cellId: (e: HTMLElement) => string; content: (e: HTMLElement) => string; readOnly: (e: HTMLElement) => boolean; lineNumber: (e: HTMLElement) => boolean; interpreter: (e: HTMLElement) => string; language: (e: HTMLElement) => "python" | "javascript"; capturedIn: (e: HTMLElement) => string[]; capturedOut: (e: HTMLElement) => string[]; }; /** * Initialize an instance of {@link InterpreterCellView} from a DOM element `interpreter-cell` in MarkDown content * (the parameter `state` is automatically provided). * * * The static property {@link InterpreterCellView.FromDomAttributes | FromDomAttributes} * defines the mapping between the DOM element and the constructor's attributes. * * * @param _p * @param _p.elem The DOM element. * @param _p.state The page state. */ static FromDom({ elem, state }: { elem: HTMLElement; state: State; }): InterpreterCellView; /** * Initialize a new instance. * * @param params * @param params.cellId The cell's ID. * @param params.content The cell's content. * @param params.state The page's state. * @param params.cellAttributes Cell's attributes. */ constructor(params: { cellId: string; content: string; state: State; cellAttributes: InterpreterCellAttributes; }); /** * Execute the cell. * * @param args See {@link ExecArgs}. */ execute({ scope, src, output$ }: ExecArgs): Promise; private headerView; } export declare class DropDownCaptureView implements VirtualDOM<'div'> { readonly tag = "div"; readonly children: ChildrenLike; readonly class = "dropdown d-flex flex-column justify-content-center"; readonly style: { fontSize: string; }; constructor(params: { mode: 'in' | 'out'; variables: string[]; }); }