motoko
Version:
Compile and run Motoko smart contracts in Node.js or the browser.
136 lines • 4.28 kB
TypeScript
import { Node, AST } from './ast';
import { Scope } from './file';
import { Package, PackageInfo } from './package';
export type Motoko = ReturnType<typeof wrapMotoko>;
type Compiler = any;
export type Diagnostic = {
source: string;
range: {
start: {
line: number;
character: number;
};
end: {
line: number;
character: number;
};
};
severity: number;
code: string;
category: string;
message: string;
};
export type WasmMode = 'ic' | 'wasi';
export type Result = {
value?: any;
error: {
message?: string;
} | null;
};
export default function wrapMotoko(compiler: Compiler): {
version: any;
compiler: any;
file(path: string): {
path: string;
clone(): any;
read(): string;
write(content: string): void;
rename(newPath: string): void;
delete(): void;
list(): string[];
check(): Diagnostic[];
run(): {
stdout: string;
stderr: string;
result: Result;
};
candid(): string;
wasm(mode: WasmMode): any;
parseCandid(): object;
parseMotoko(enableRecovery?: boolean): Node;
parseMotokoWithDeps(enableRecovery?: boolean): {
ast: Node;
immediateImports: string[];
};
parseMotokoTyped(): {
ast: Node;
type: Node;
};
parseMotokoTypedWithScopeCache(scopeCache: Map<string, Scope>, enableRecovery?: boolean): [{
ast: Node;
type: Node;
immediateImports: string[];
}, Map<string, unknown>];
};
read(path: string): string;
write(path: string, content?: string): void;
rename(path: string, newPath: string): void;
delete(path: string): void;
list(directory: string): string[];
fetchPackage(name: string, info: string | PackageInfo): Promise<Package>;
installPackages(packages: Record<string, string | PackageInfo>): Promise<void>;
loadPackage(pkg: Package): void;
usePackage(name: string, directory: string): void;
clearPackages(): void;
validatePackage(pkg: Package): void;
setAliases(directory: string, aliases: Record<string, string>): void;
setPublicMetadata(values: string[]): void;
setRunStepLimit(limit: number): void;
setTypecheckerCombineSrcs(combineSrcs: boolean): void;
setExtraFlags(argv: string[]): void;
check(path: string): Diagnostic[];
checkWithScopeCache(path: string, scopeCache: Map<string, Scope>): {
diagnostics: Diagnostic[];
scopeCache: Map<string, Scope> | null;
};
run(path: string, libPaths?: string[] | undefined): {
stdout: string;
stderr: string;
result: Result;
};
candid(path: string): string;
wasm(path: string, mode: WasmMode): any;
parseCandid(content: string): object;
parseMotoko(content: string, enableRecovery?: boolean): Node;
parseMotokoWithDeps(path: string, content: string, enableRecovery?: boolean): {
ast: Node;
immediateImports: string[];
};
parseMotokoTyped: {
(paths: string): {
ast: Node;
type: Node;
};
(paths: string[]): {
ast: Node;
type: Node;
}[];
};
parseMotokoTypedWithScopeCache: {
(paths: string, scopeCache: Map<string, Scope>, enableRecovery?: boolean): [{
ast: Node;
type: Node;
immediateImports: string[];
}, Map<string, Scope>];
(paths: string[], scopeCache: Map<string, Scope>, enableRecovery?: boolean): [{
ast: Node;
type: Node;
immediateImports: string[];
}[], Map<string, Scope>];
};
contextualDotSuggestions(node: Node, program: {
ast: AST;
}): {
moduleUri: string;
funcName: string;
funcType: string;
}[] | undefined;
contextualDotModule(node: Node): {
moduleNameOrUri: string;
funcName: string;
} | undefined;
resolveMain(directory?: string): string | undefined;
resolveLib(directory?: string): string | undefined;
};
export {};
//# sourceMappingURL=index.d.ts.map