新增处理器类型的定义
This commit is contained in:
parent
4473a9af41
commit
1954f8d612
39
src/base.ts
39
src/base.ts
@ -1,8 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* 配置基类,下划线开头的变量不会被序列化
|
||||||
|
*/
|
||||||
export class ConfigBase {
|
export class ConfigBase {
|
||||||
name: string = '';
|
name: string = '';
|
||||||
version:string = '1.0.0';
|
version:string = '1.0.0';
|
||||||
enable:boolean = true;
|
|
||||||
[key: string]: any;
|
[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 {
|
export interface FileOptions {
|
||||||
|
@ -1,7 +1,46 @@
|
|||||||
export abstract class ProcessorBase {
|
import { ConfigBase, FileInfo, ProcessorBase } from "./base";
|
||||||
public readonly name: string = '';
|
|
||||||
public readonly version: string = '1.0.0';
|
// todo: 类型参数待补完
|
||||||
public abstract exec(...args: any[]): any
|
|
||||||
|
export class BlockInfo{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BlockProcessorConfig extends ConfigBase{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户板材数据过滤与转换
|
||||||
|
*/
|
||||||
|
export abstract class BlockProcessor extends ProcessorBase<BlockInfo[],BlockInfo[],BlockProcessorConfig>{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LayoutInput {
|
||||||
|
|
||||||
|
}
|
||||||
|
export class LayoutOutput{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LyaoutProcessorConfig extends ConfigBase{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class LayoutProcessor extends ProcessorBase<LayoutInput,LayoutOutput,LyaoutProcessorConfig>{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ExporterInput{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ExporterProcessorConfig extends ConfigBase{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class ExporterProcessor extends ProcessorBase<ExporterInput,FileInfo,ExporterProcessorConfig>{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user