|
| 1 | +/** Whether this is a webpack bundle or not. */ |
| 2 | +export const isBundle: boolean; |
| 3 | + |
| 4 | +/** Whether asc runs the sources directly or not. */ |
| 5 | +export const isDev: boolean; |
| 6 | + |
| 7 | +/** AssemblyScript version. */ |
| 8 | +export const version: string; |
| 9 | + |
| 10 | +/** Command line option description. */ |
| 11 | +export interface OptionDescription { |
| 12 | + /** Textual description. */ |
| 13 | + description: string | string[]; |
| 14 | + /** Option type, e.g. `string`. */ |
| 15 | + type: string; |
| 16 | + /** Option aliases, if any. */ |
| 17 | + aliases?: string[]; |
| 18 | +} |
| 19 | + |
| 20 | +/** Available CLI options. */ |
| 21 | +export const options: { [key: string]: OptionDescription }; |
| 22 | + |
| 23 | +/** Common root used in source maps. */ |
| 24 | +export var sourceMapRoot: string; |
| 25 | + |
| 26 | +/** Prefix used for library files. */ |
| 27 | +export var libraryPrefix: string; |
| 28 | + |
| 29 | +/** Default Binaryen optimization level. */ |
| 30 | +export var defaultOptimizeLevel: number; |
| 31 | + |
| 32 | +/** Default Binaryen shrink level. */ |
| 33 | +export var defaultShrinkLevel: number; |
| 34 | + |
| 35 | +/** Bundled library files. */ |
| 36 | +export const libraryFiles: { [key: string]: string }; |
| 37 | + |
| 38 | +/** Bundled definition files. */ |
| 39 | +export const definitionFiles: { assembly: string, portable: string }; |
| 40 | + |
| 41 | +/** A compatible output stream. */ |
| 42 | +export interface OutputStream { |
| 43 | + /** Writes another chunk of data to the stream. */ |
| 44 | + write(chunk: Uint8Array | string): void; |
| 45 | + /** Converts the output to a buffer. */ |
| 46 | + toBuffer(): Uint8Array; |
| 47 | + /** Converts the output to a string. */ |
| 48 | + toString(): string; |
| 49 | +} |
| 50 | + |
| 51 | +/** Compiler API options. */ |
| 52 | +interface CompilerOptions { |
| 53 | + /** Standard output stream to use. */ |
| 54 | + stdout?: OutputStream; |
| 55 | + /** Standard error stream to use. */ |
| 56 | + stderr?: OutputStream; |
| 57 | + /** Reads a file from disk (or memory). */ |
| 58 | + readFile?: (name: string) => string | null; |
| 59 | + /** Writes a file to disk (or memory). */ |
| 60 | + writeFile?: (name: string, contents: Uint8Array) => void; |
| 61 | + /** Lists all files within a directory. */ |
| 62 | + listFiles?: (dir: string) => string[] | null; |
| 63 | +} |
| 64 | + |
| 65 | +/** Convenience function that parses and compiles source strings directly. */ |
| 66 | +export function compileString(sources: { [key: string]: string } | string, options?: CompilerOptions): { |
| 67 | + /** Standard output. */ |
| 68 | + stdout: OutputStream, |
| 69 | + /** Standard error. */ |
| 70 | + stderr: OutputStream, |
| 71 | + /** Emitted binary. */ |
| 72 | + binary: Uint8Array | null, |
| 73 | + /** Emitted text format. */ |
| 74 | + text: string | null |
| 75 | +} |
| 76 | + |
| 77 | +/** Runs the command line utility using the specified arguments array. */ |
| 78 | +export function main(argv: string[], options: CompilerOptions, callback?: (err: Error | null) => number): number; |
| 79 | +export function main(argv: string[], callback?: (err: Error | null) => number): number; |
| 80 | + |
| 81 | +/** Checks diagnostics emitted so far for errors. */ |
| 82 | +export function checkDiagnostics(emitter: any, stderr?: OutputStream): boolean; |
| 83 | + |
| 84 | +/** An object of stats for the current task. */ |
| 85 | +export interface Stats { |
| 86 | + readTime: number, |
| 87 | + readCount: number, |
| 88 | + writeTime: number, |
| 89 | + writeCount: number, |
| 90 | + parseTime: number, |
| 91 | + parseCount: number, |
| 92 | + compileTime: number, |
| 93 | + compileCount: number, |
| 94 | + emitTime: number, |
| 95 | + emitCount: number, |
| 96 | + validateTime: number, |
| 97 | + validateCount: number, |
| 98 | + optimizeTime: number, |
| 99 | + optimizeCount: number |
| 100 | +} |
| 101 | + |
| 102 | +/** Creates an empty set of stats. */ |
| 103 | +export function createStats(): Stats; |
| 104 | + |
| 105 | +/** Measures the execution time of the specified function. */ |
| 106 | +export function measure(fn: Function): number; |
| 107 | + |
| 108 | +/** Formats a high resolution time to a human readable string. */ |
| 109 | +export function formatTime(time: number): string; |
| 110 | + |
| 111 | +/** Formats and prints out the contents of a set of stats. */ |
| 112 | +export function printStats(stats: Stats, output: OutputStream): void; |
| 113 | + |
| 114 | +/** Creates a memory stream that can be used in place of stdout/stderr. */ |
| 115 | +export function createMemoryStream(fn?: (chunk: Uint8Array | string) => void): OutputStream; |
| 116 | + |
| 117 | +/** Compatible TypeScript compiler options for syntax highlighting etc. */ |
| 118 | +export const tscOptions: { [key: string]: any }; |
0 commit comments