import { ChildrenLike, VirtualDOM } from '@youwol/rx-vdom'; import { CodeSnippetView } from '../md-widgets'; import { BehaviorSubject, Observable } from 'rxjs'; import { CellTrait, ExecArgs, Scope, State } from './state'; import { CellCommonAttributes } from './notebook-page'; /** * All attributes available for a javascript cell: the common ones + 'reactive'. */ export type JsCellAttributes = CellCommonAttributes & { /** * If the cell is reactive, Observables & Promises referenced are automatically resolved. * It uses a 'combineLatest' policy. */ reactive: boolean; }; /** * * Represents the execution side of a Javascript cell within a {@link NotebookPage}. * * This implementation does not provide the views (editor, outputs), it is used as it is when loading separated notebook * pages to retrieve exported symbols. * However, this implementation is typically inherited from {@link JsCellView} to provide the regular views of * a javascript cell. */ export declare class JsCellExecutor implements CellTrait { readonly cellId: string; /** * Initial source code. */ readonly content: string; /** * Emit when the cell is invalidated. */ readonly invalidated$: Observable; /** * State manager, owned by the parent {@link NotebookPage}. */ readonly state: State; readonly cellAttributes: JsCellAttributes; /** * Observable over the source content of the cell. */ readonly content$: BehaviorSubject; constructor(params: { cellId: string; content$: BehaviorSubject; state: State; cellAttributes: JsCellAttributes; }); /** * Execute the cell. See {@link execute}. * * @param args See {@link ExecArgs}. */ execute(args: ExecArgs): Promise; } /** * * Represents a Javascript cell within a {@link NotebookPage}. * * They are typically included from a DOM definition with tag name `js-cell` in MarkDown content, * see {@link JsCellView.FromDom}. */ export declare class JsCellView extends JsCellExecutor implements VirtualDOM<'div'> { readonly tag = "div"; /** * Classes associated with the view. */ readonly class = "mknb-JsCellView"; readonly children: ChildrenLike; /** * The encapsulated code editor view. */ readonly editorView: CodeSnippetView; /** * Defines the methods to retrieve constructor's arguments from the DOM element `js-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; reactive: (e: HTMLElement) => boolean; }; /** * Initialize an instance of {@link JsCellView} from a DOM element `js-cell` in MarkDown content * (the parameter `state` is automatically provided). * * * The static property {@link JsCellView.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; }): JsCellView; /** * 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: JsCellAttributes; }); }