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 'worker' cell. */ export type WorkerCellAttributes = CellCommonAttributes & { /** * Name (exported symbol) of the worker's pool used to execute the code. */ workersPool: string; /** * Whether to interpret code as JavaScript or Python (pyodide) snippet. */ mode: 'javascript' | 'python'; /** * The names of the captured variables forwarded to the worker along with the processing task. */ capturedIn?: string[]; /** * The names of the captured variable name forwarded to the main-thread from the worker. */ capturedOut?: string[]; }; /** * * Represents a worker cell within a {@link NotebookPage}. * * They are typically included from a DOM definition with tag name `worker-cell` in Markdown content, * see {@link WorkerCellView.FromDom}. */ export declare class WorkerCellView implements VirtualDOM<'div'>, CellTrait { readonly tag = "div"; /** * Classes associated with the view. */ readonly class = "mknb-JsCellView"; readonly children: ChildrenLike; /** * Cell's ID. */ readonly cellId: string; /** * Cell's attributes. */ readonly cellAttributes: WorkerCellAttributes; /** * State manager, owned by the parent {@link NotebookPage}. */ readonly state: State; /** * The encapsulated code editor view. */ 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 `worker-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; workersPool: (e: HTMLElement) => string; mode: (e: HTMLElement) => "python" | "javascript"; capturedIn: (e: HTMLElement) => string[]; capturedOut: (e: HTMLElement) => string[]; }; /** * Initialize an instance of {@link WorkerCellView} from a DOM element `worker-cell` in Markdown content * (the parameter `state` is automatically provided). * * * The static property {@link WorkerCellView.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; }): WorkerCellView; /** * 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: WorkerCellAttributes; }); /** * Execute the cell. * * @param args See {@link ExecArgs}. */ execute({ scope, src }: ExecArgs): Promise; private headerView; }