@hpcc-js/observablehq-compiler
Version:
hpcc-js - ObservableHQ Compiler (unoffical)
53 lines (52 loc) • 2.31 kB
TypeScript
import { type Notebook, type Cell, toNotebook, toCell } from "@observablehq/notebook-kit";
import { type Definition } from "@observablehq/notebook-kit/runtime";
export type { Notebook, Cell, Definition };
export { toNotebook, toCell };
export type RegularFunction = (...args: any[]) => any;
interface RegularFunctionConstructor {
new (...args: string[]): RegularFunction;
(...args: string[]): RegularFunction;
readonly prototype: RegularFunction;
}
export type AsyncFunction = (...args: any[]) => Promise<any>;
interface AsyncFunctionConstructor {
new (...args: string[]): AsyncFunction;
(...args: string[]): AsyncFunction;
readonly prototype: AsyncFunction;
}
export type GeneratorFunction = (...args: any[]) => Generator<any, any, any>;
interface GeneratorFunctionConstructor {
new (...args: string[]): GeneratorFunction;
(...args: string[]): GeneratorFunction;
readonly prototype: GeneratorFunction;
}
export type AsyncGeneratorFunction = (...args: any[]) => AsyncGenerator<any, any, any>;
interface AsyncGeneratorFunctionConstructor {
new (...args: string[]): AsyncGeneratorFunction;
(...args: string[]): AsyncGeneratorFunction;
readonly prototype: AsyncGeneratorFunction;
}
export type AnyFunction = RegularFunction | AsyncFunction | GeneratorFunction | AsyncGeneratorFunction;
export declare const FunctionConstructors: {
regular: RegularFunctionConstructor;
async: AsyncFunctionConstructor;
generator: GeneratorFunctionConstructor;
asyncGenerator: AsyncGeneratorFunctionConstructor;
};
interface Ref {
start: number;
end: number;
newText: string;
}
export interface Refs {
inputs: string[];
args: string[];
patches: Ref[];
}
export declare function createFunction(refs: Refs, async?: boolean, generator?: boolean, blockStatement?: boolean, body?: string): RegularFunction | undefined;
export declare const isRelativePath: (path: string) => boolean;
export declare const fixRelativeUrl: (path: string, basePath: string) => string;
export declare function obfuscatedImport(url: string): Promise<any>;
export declare function constructFunction(bodyStr: string, name?: string): AnyFunction;
export declare const html2notebook: (html: string) => Notebook;
export declare const notebook2html: (notebook: Notebook) => string;