AutolangDocs

Type Reference

The complete TypeScript declarations exported by the autolang-compiler package โ€” types, enums, interfaces, and the main ACompiler class.

If you're just getting started, see the npm Integration Guide for usage examples first.

๐Ÿ“„ Full Declarations

These types are shipped with the package. If you use TypeScript, they're picked up automatically โ€” no separate @types install needed.

// โ”€โ”€ Primitive types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ type AObject = number; type AutolangType = | number | null | undefined | string | boolean | void | AObject | object | number[] | string[] | boolean[] | AObject[] | object[] | Set<any> | Map<any, any>; // Native function bound to an Autolang function declaration. // Parameters map directly to the Autolang function's parameter list. type AutolangNativeFunc = ( thisArg: AutolangType, ...args: AutolangType[] ) => AutolangType; // โ”€โ”€ Compiler configuration โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ // Passed to ACompiler.create() to control which standard libraries are loaded. interface ACompilerConfig { addStdFile?: boolean; addStdRegex?: boolean; addStdJson?: boolean; addStdMath?: boolean; } // โ”€โ”€ Library configuration โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ // Used when registering a native library or configuring the main source. interface LibraryConfig { autoImport?: boolean; // skip @import in all files allowLateinitKeyword?: boolean; // allow "lateinit var" allowNonNullAssertion?: boolean; // allow the ! postfix operator } // โ”€โ”€ Runtime exception object โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ interface AException { message: string; } // โ”€โ”€ Security rule types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ enum AllowRuleType { PLAIN_PREFIX = 0, // plain string prefix (special chars escaped) REGEX = 1, // full ECMAScript regex pattern } type AllowRule = | string // shorthand for PLAIN_PREFIX | [AllowRuleType, string] // tuple form | { type: AllowRuleType, value: string }; // object form // โ”€โ”€ Main compiler class โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ declare class ACompiler { static create(config?: ACompilerConfig): Promise<ACompiler>; // Output buffer getOutput(): any; clearOutput(): void; setOutput(output: string): void; // Library registration registerBuiltInLibrary( name: string, source: string, config?: LibraryConfig, methods?: Record<string, AutolangNativeFunc> ): void; // Compiler options setMainSourceConfig(config: LibraryConfig): void; setLimitOpcodeCount(limit: number): void; getLimitOpcodeCount(): number; // Security โ€” HTTP (requires std/http) setAllowedDomainsRules(rules: AllowRule[]): void; // Security โ€” File system (requires std/file) setAllowFileRead(allow: boolean): void; setAllowFileWrite(allow: boolean): void; setAllowFileDelete(allow: boolean): void; setAllowedFilePathsRules(rules: AllowRule[]): void; setFileBasePath(path: string): void; // Compilation & execution compileAndRun(path: string, code: string): Promise<boolean>; compile(path: string, code: string): Promise<boolean>; run(): Promise<boolean>; // Diagnostics hasCompilerError(): boolean; throwException(message: string): boolean; hasException(): boolean; getException(): AException | null; // Callbacks (fired during compilation) setOnError(callback: ((error: string) => void) | null): void; setOnWarning(callback: ((warning: string) => void) | null): void; // State reset refresh(): void; // Cleanup dispose(): void; } export { ACompiler, AllowRuleType, type ACompilerConfig, type AException, type AObject, type AllowRule, type AutolangNativeFunc, type AutolangType, type LibraryConfig };

For security-related methods (setAllowedDomainsRules, setAllowFileRead, etc.), see Security & Sandboxing.