@hpcc-js/observablehq-compiler
Version:
hpcc-js - ObservableHQ Compiler (unoffical)
112 lines (111 loc) • 4.21 kB
TypeScript
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;
};
export declare function compile(notebookOrOjs: ohq.Notebook | string, { baseUrl, importMode }?: CompileOptions): Promise<{
(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;
}>;
export type compileFunc = Awaited<ReturnType<typeof compile>>;
export {};