@hpcc-js/observablehq-compiler
Version:
hpcc-js - ObservableHQ Compiler (unoffical)
84 lines (83 loc) • 3.48 kB
TypeScript
import { type Notebook, type Definition } from "./kit/index.ts";
import { ohq } from "./observable-shim.ts";
import { Writer } from "./writer.ts";
export type InspectorFactoryEx = (name: string | undefined, id: string | number) => Inspector;
export interface Inspector {
_node?: HTMLDivElement;
pending(): void;
fulfilled(value: any): void;
rejected(error: Error): void;
}
declare function createCell(node: ohq.Node, options: CompileOptions): Promise<{
(runtime: ohq.Runtime, main: ohq.Module, inspector?: InspectorFactoryEx): void;
id: string | number;
modules: {
(runtime: ohq.Runtime, main: ohq.Module, inspector?: InspectorFactoryEx): ohq.Module;
importVariables: {
(main: ohq.Module, otherModule: ohq.Module): void;
delete: () => void;
}[];
variables: {
(module: ohq.Module, inspector?: InspectorFactoryEx): ohq.Variable;
delete: () => void;
write: (w: Writer) => void;
}[];
delete: () => void;
write: (w: Writer) => void;
}[];
variables: {
(module: ohq.Module, inspector?: InspectorFactoryEx): ohq.Variable;
delete: () => void;
write: (w: Writer) => void;
}[];
delete: () => void;
write: (w: Writer) => void;
}>;
export type CellFunc = Awaited<ReturnType<typeof createCell>>;
export interface CompileOptions {
baseUrl?: string;
importMode?: "recursive" | "precompiled";
}
export declare function notebook(_files?: ohq.File[], _cells?: CellFunc[], { baseUrl, importMode }?: CompileOptions): {
(runtime: ohq.Runtime, inspector?: InspectorFactoryEx): ohq.Module;
fileAttachments: Map<string, any>;
cells: Map<string | number, {
(runtime: ohq.Runtime, main: ohq.Module, inspector?: InspectorFactoryEx): void;
id: string | number;
modules: {
(runtime: ohq.Runtime, main: ohq.Module, inspector?: InspectorFactoryEx): ohq.Module;
importVariables: {
(main: ohq.Module, otherModule: ohq.Module): void;
delete: () => void;
}[];
variables: {
(module: ohq.Module, inspector?: InspectorFactoryEx): ohq.Variable;
delete: () => void;
write: (w: Writer) => void;
}[];
delete: () => void;
write: (w: Writer) => void;
}[];
variables: {
(module: ohq.Module, inspector?: InspectorFactoryEx): ohq.Variable;
delete: () => void;
write: (w: Writer) => void;
}[];
delete: () => void;
write: (w: Writer) => void;
}>;
set: (n: ohq.Node) => Promise<CellFunc>;
get: (id: string | number) => CellFunc | undefined;
delete: (id: string | number) => boolean;
clear: () => void;
write: (w: Writer) => void;
toString: (w?: Writer) => string;
};
type NotebookFunc = ReturnType<typeof notebook>;
export declare function isNotebookKit(value: any): value is Notebook;
export declare function isOhqNotebook(value: any): value is ohq.Notebook;
export declare function compile(notebookOrOjs: Notebook): Promise<Definition[]>;
export declare function compile(notebookOrOjs: ohq.Notebook, options?: CompileOptions): Promise<NotebookFunc>;
export declare function compile(notebookOrOjs: string, options?: CompileOptions): Promise<NotebookFunc>;
export type CompileFunc = Awaited<ReturnType<typeof compile>>;
export {};