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;4BAC7C,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,OAAO,CAAC;4BAClE,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAC,MAAM;gCAClD,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;4BACvB,CAAC,CAAC,CAAC;wBACP,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;iBACN;gBACD,OAAO,CAAC,EAAE;oBACN,KAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;oBAChF,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;iBACjB;YACL,CAAC,CAAC;QACN,CAAC,CAAC;QAED,IAAI,CAAC,MAAc,CAAC,OAAO,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;IACL,mBAAC;AAAD,CAAC,AA3CD,IA2CC;AA3CY,oCAAY","sourcesContent":["import { Logger } from \"log4js\";\nimport * as path from \"path\";\nimport { Bundler } from \"../bundler/bundler\";\nimport { Compiler } from \"../compiler/compiler\";\nimport { Coverage } from \"../istanbul/coverage\";\nimport { Configuration } from \"../shared/configuration\";\nimport { File } from \"../shared/file\";\nimport { FileUtils } from \"../shared/file-utils\";\nimport { SharedProcessedFiles } from \"../shared/shared-processed-files\";\n\nexport class Preprocessor {\n\n public create: (helper: any, logger: any) => void;\n private log: Logger;\n\n constructor(bundler: Bundler, compiler: Compiler, private config: Configuration,\n coverage: Coverage, sharedProcessedFiles: SharedProcessedFiles) {\n\n this.create = (helper: any, logger: any) => {\n this.log = logger.create(\"preprocessor.karma-typescript\");\n\n coverage.initialize(helper, logger);\n\n return (content: string, file: File, done: (e: any, c?: string) => void) => {\n try {\n this.log.debug(\"Processing \\\"%s\\\". %s\", file.originalPath, content.length);\n file.path = config.transformPath(file.originalPath);\n file.relativePath = FileUtils.getRelativePath(file.originalPath, this.config.karma.basePath);\n\n compiler.compile(file, (emitOutput) => {\n if (emitOutput.hasError) {\n return done(\"COMPILATION ERROR\", content);\n }\n if (emitOutput.isDeclarationFile && !emitOutput.isAmbientModule) {\n return done(null, \" \");\n }\n bundler.bundle(file, emitOutput, (bundled: string) => {\n sharedProcessedFiles[path.normalize(file.originalPath)] = bundled;\n coverage.instrument(file, bundled, emitOutput, (result) => {\n done(null, result);\n });\n });\n });\n }\n catch (e) {\n this.log.error(\"%s\\n processing %s\\n%s\", e.message, file.originalPath, e.stack);\n done(e, null);\n }\n };\n };\n\n (this.create as any).$inject = [\"helper\", \"logger\"];\n }\n}\n"]}