52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
/**
|
|
* 配置基类,下划线开头的变量不会被序列化
|
|
*/
|
|
export class ConfigBase {
|
|
name: string = '';
|
|
version:string = '1.0.0';
|
|
[key: string]: any;
|
|
|
|
/**
|
|
* 序列化json方法
|
|
* @returns
|
|
*/
|
|
toJson(){
|
|
return JSON.stringify(this,(k,v)=>k[0]=='_'?undefined:v);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 加工处理器上下文
|
|
*/
|
|
export abstract class ProcessorContext<TInput,TOutput,TConfig extends ConfigBase>{
|
|
/**
|
|
* 输入数据
|
|
*/
|
|
public Input?:TInput;
|
|
/**
|
|
* 合并配置文件与临时输入参
|
|
*/
|
|
public params?:TConfig;
|
|
/**
|
|
* 输出数据
|
|
*/
|
|
public Ouput?:TOutput;
|
|
}
|
|
|
|
/**
|
|
* 处理器基类
|
|
*/
|
|
export abstract class ProcessorBase<TInput,TOutput,TConfig extends ConfigBase> {
|
|
public readonly name: string = '';
|
|
public readonly version: string = '1.0.0';
|
|
public abstract exec(context:ProcessorContext<TInput,TOutput,TConfig>):Promise<void>|void
|
|
}
|
|
|
|
export interface FileOptions {
|
|
encode?: string;
|
|
addBOM?: boolean;
|
|
}
|
|
export interface FileInfo extends FileOptions {
|
|
name: string,
|
|
content: string | Blob | Uint8Array,
|
|
} |