Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 33x 33x 33x 40x 40x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 162x 26x 162x 162x 162x 162x 162x 2x 2x 160x 160x 162x 1x 1x 159x 162x 33x | import { HandlerType } from '../enums/handler-type';
import { engineHandler } from './handlers/engine-handler';
import { layerHandler } from './handlers/layer-handler';
import { sourceHandler } from './handlers/source-handler';
import { viewTargetHandler } from './handlers/view-target-handler';
import { filterHandler } from './handlers/filter-handler';
import { illusionService } from './illusion-service';
import { fileHandler } from './handlers/file-handler';
export class IllusionCore {
constructor(inWorker: boolean = false) {
illusionService.inWorker = inWorker;
}
private static handlerMap: {
[key in HandlerType]: any
} = {
[HandlerType.Engine]: engineHandler,
[HandlerType.Layer]: layerHandler,
[HandlerType.Source]: sourceHandler,
[HandlerType.ViewTarget]: viewTargetHandler,
[HandlerType.Filter]: filterHandler,
[HandlerType.File]: fileHandler
}
async do(command: string, data: Array<any> = []) {
if(!illusionService.module) {
await illusionService.init();
}
const [handlerType, actionType] = command.split('.');
const handler = IllusionCore.handlerMap[handlerType as HandlerType];
if(!handler) {
throw new Error(`invalid command type: ${handlerType}`);
}
const action = handler[actionType];
if(!action && typeof action !== 'function') {
throw new Error(`invalid action type: ${actionType}`);
}
return (action as Function).call(handler, ...data);
}
}; |