magica
Version:
ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.
43 lines (42 loc) • 1.65 kB
TypeScript
import { FS } from '../file/emscriptenFs';
import { File } from '../file/file';
import { NativeResult } from '../imageMagick/createMain';
import { IFile, Options } from '../types';
import { main } from './main';
import { run } from './run';
export declare function isCustomCommand(c: string[]): Promise<boolean>;
/**
* In [run]'s [script] property, or in commands given to [main], lines starting with `!js:` are be evaluated as a JavaScript function that accept one parameter context which is an object containing utilities that can be used asynchronously. This interface describes such an object. The expression `!js:` can be configured using [Options].
*
* ```js
* result = await run({
* script: `
* convert rose: foo.gif
* !js: c=>c.pushStdout(FS.readdir('.').join(', '))
* !js: async c=> {const f = c.File.asFile(c.files[0]) ; c.pushStdout(JSON.stringify(await f.size())) }
* `
* })
* ```
*/
export interface CustomCommandContext {
FS: FS;
options: Partial<Options>;
log(...s: string[]): void;
error(...s: string[]): void;
File: typeof File;
writeFile(f: File): void;
isFile(f: string): boolean;
readFile(f: string): File;
isDirectory(f: string): boolean;
run: typeof run;
main: typeof main;
includeOutputFiles(files: (string | IFile)[], exclude?: boolean): void;
}
export interface CustomCommandDispatchOptions {
command: string[];
options: Partial<Options>;
FS: FS;
/** can be used by custom commands to manipulate outputFiles*/
outputFiles: File[];
}
export declare function dispatchCustomCommand(o: CustomCommandDispatchOptions): Promise<NativeResult>;