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 | 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 56x 50x 56x 56x 56x 56x 56x 2x 2x 54x 54x 56x 1x 1x 53x 56x 3x | 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";
export class IllusionCore {
private static handlerMap: {
[key in HandlerType]: any
} = {
[HandlerType.Engine]: engineHandler,
[HandlerType.Layer]: layerHandler,
[HandlerType.Source]: sourceHandler,
[HandlerType.ViewTarget]: viewTargetHandler,
[HandlerType.Filter]: filterHandler
}
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);
}
}; |