UNPKG

magica

Version:

ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.

50 lines 2.34 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const misc_utils_of_mine_generic_1 = require("misc-utils-of-mine-generic"); const template_1 = require("./template/template"); const commandPreprocessor = []; /** internal - executes all registered preprocessor on given config */ function _compileTimePreprocess(config) { return __awaiter(this, void 0, void 0, function* () { install(); let cfg = config; yield misc_utils_of_mine_generic_1.serial(commandPreprocessor.filter(p => p.fnCompileTime).map(p => () => __awaiter(this, void 0, void 0, function* () { cfg = yield p.fnCompileTime(cfg); }))); return Object.assign({}, cfg); }); } exports._compileTimePreprocess = _compileTimePreprocess; function _runTimePreprocess(runOptions, commandOptions, commandIndex) { return __awaiter(this, void 0, void 0, function* () { if (!installed) { installed = true; install(); } yield misc_utils_of_mine_generic_1.serial(commandPreprocessor.filter(p => p.fnRuntime).map(p => () => __awaiter(this, void 0, void 0, function* () { yield p.fnRuntime(commandOptions, commandIndex, runOptions); }))); }); } exports._runTimePreprocess = _runTimePreprocess; function registerCommandPreprocessor(p) { commandPreprocessor.push(p); } exports.registerCommandPreprocessor = registerCommandPreprocessor; function install() { if (!installed) { installed = true; registerCommandPreprocessor(new template_1.Template()); } } let installed = false; //# sourceMappingURL=executeCommandPreprocessor.js.map