2020-10-09 19:35:46 +02:00
|
|
|
import { ExportContext } from '../plugins/api/types';
|
|
|
|
import InteropService_Exporter_Base from './InteropService_Exporter_Base';
|
2023-07-12 11:30:38 +02:00
|
|
|
import { ExportOptions } from './types';
|
|
|
|
|
|
|
|
interface CustomImporter {
|
|
|
|
onInit(context: any): Promise<void>;
|
|
|
|
onProcessItem(context: any, itemType: number, item: any): Promise<void>;
|
|
|
|
onProcessResource(context: any, resource: any, filePath: string): Promise<void>;
|
|
|
|
onClose(context: any): Promise<void>;
|
|
|
|
}
|
2020-10-09 19:35:46 +02:00
|
|
|
|
|
|
|
export default class InteropService_Exporter_Custom extends InteropService_Exporter_Base {
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
private customContext_: ExportContext;
|
2023-07-12 11:30:38 +02:00
|
|
|
private module_: CustomImporter = null;
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2023-07-12 11:30:38 +02:00
|
|
|
public constructor(module: CustomImporter) {
|
2020-10-09 19:35:46 +02:00
|
|
|
super();
|
|
|
|
this.module_ = module;
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async init(destPath: string, options: ExportOptions) {
|
2020-10-09 19:35:46 +02:00
|
|
|
this.customContext_ = {
|
|
|
|
destPath: destPath,
|
|
|
|
options: options,
|
|
|
|
};
|
|
|
|
|
|
|
|
return this.module_.onInit(this.customContext_);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async processItem(itemType: number, item: any) {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.module_.onProcessItem(this.customContext_, itemType, item);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async processResource(resource: any, filePath: string) {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.module_.onProcessResource(this.customContext_, resource, filePath);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async close() {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.module_.onClose(this.customContext_);
|
|
|
|
}
|
|
|
|
}
|