{"version":3,"sources":["compile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,OAAO,EAAE,MAAM,EAAyB,MAAM,oBAAoB,CAAC;AAInE,OAAO,EAAe,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAO1E,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AACD,oBAAY,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,qBAAa,QAAQ;;gBAWL,eAAe,EAAE,EAAE,CAAC,eAAe,GAAG,MAAM;IAYxD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAE,OAAc,EAAE,eAAe,CAAC,EAAE,eAAe,GAAG,aAAa,EAAE;IAkJ1H,IAAI,CAAC,MAAM,UAAO,EAAE,eAAe,CAAC,EAAE,eAAe,GAAG,SAAS;IAsDjE,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,EAAE;IAI1C,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,EAAE,eAAe;IA+B/G,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,GAAG,SAAS,GAAG,YAAY;CAerM;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,sBAUjD;AAED,UAAU,eAAe;IAErB,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB,KAAK,EAAE;QACH,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC;QACvB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;QAEd,IAAI,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;IAEJ,aAAa,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CA+E9J;AAeD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,YAUhF","file":"compile.d.ts","sourcesContent":["import ts from \"typescript\";\nimport { readFileSync } from 'fs';\nimport { PACKAGE_NAME } from \"./config\";\nimport { errorFile } from \"./utils/error\";\nimport { info, warn } from \"./utils/log\";\nimport { normalize, resolve, dirname, relative } from 'path';\nimport Glob from 'glob';\nimport { parse as ParseModelFrom } from './parser/parser';\nimport { format, format as formatModel } from './parser/format';\nimport { printTree } from '@src/utils/console-print';\nimport Through from 'through2';\nimport Vinyl from 'vinyl';\nimport { toDataModel, ToDataReturn } from './converters/to-data-model';\nimport { toGraphQL } from \"./converters/to-graphql\";\nimport { _resolveImports } from \"./utils/resolve-imports\";\nimport { MacroAnnotationHandler } from \"tt-model\";\nimport { resolveAnnotationMacro } from \".\";\nconst TS_REGEX = /\\.ts$/i\n\n/** Compiler::compile */\nexport interface CompileResult {\n\tpath: string,\n\tcontent: string\n}\n\nexport type TargetExtension = '.js' | '.mjs' | '.cjs';\n\n/** Compile and resolve Model */\nexport class Compiler {\n\t/** Typescript Compiler Options */\n\t#compilerOptions: ts.CompilerOptions\n\t/** Link each file to resolved files using patterns */\n\t#fileToResolvedFiles: Map<string, Set<string>> = new Map();\n\t/** Link resolved file to original files */\n\t#resolvedFileToFiles: Map<string, Set<string>> = new Map();\n\t/**\n\t * Init compiler\n\t * @param {ts.CompilerOptions | string}\tcompilerOptions\t- Parsed typescript config or path to that file\n\t */\n\tconstructor(\n\t\tcompilerOptions: ts.CompilerOptions | string,\n\t) {\n\t\t//* Parse ts config\n\t\tif (typeof compilerOptions === 'string') compilerOptions = parseTsConfig(compilerOptions);\n\t\tthis.#compilerOptions = compilerOptions;\n\t}\n\n\t/**\n\t * Compile files\n\t * @param { string[]| Map<string, string> }\tfiles\t- List of target file paths or Map of files and their content\n\t * @param { boolean }\tpretty\t\t- Render pretty code\n\t * @param { boolean }\ttranspile\t- Transpile files to javascript\n\t */\n\tcompile(\n\t\tfiles: string[] | Map<string, string>,\n\t\tpretty: boolean = true,\n\t\ttargetExtension?: TargetExtension\n\t): CompileResult[] {\n\t\t// Target extension\n\t\tif (targetExtension != null && targetExtension !== '.js' && targetExtension !== '.mjs' && targetExtension !== '.cjs')\n\t\t\tthrow new Error(`Unsupported extension: ${targetExtension}`);\n\t\t// prepare\n\t\tlet filePaths: Set<string>;\n\t\tlet mapFiles: Map<string, string>;\n\t\tconst compilerOptions = this.#compilerOptions;\n\t\tconst factory = ts.factory;\n\t\t//* Load file data & paths\n\t\tinfo(`Load Content >>`);\n\t\tif (Array.isArray(files)) {\n\t\t\tfilePaths = new Set(files);\n\t\t\tmapFiles = files = new Map();\n\t\t\tfilePaths.forEach(function (file) {\n\t\t\t\tmapFiles.set(file, readFileSync(file, 'utf-8'));\n\t\t\t});\n\t\t} else {\n\t\t\tfilePaths = new Set(files.keys());\n\t\t\tmapFiles = files;\n\t\t}\n\t\t//* Add linked files\n\t\tfilePaths.forEach((file) => {\n\t\t\tthis.#resolvedFileToFiles.get(file)?.forEach(f => {\n\t\t\t\tif (!filePaths.has(f)) {\n\t\t\t\t\tfilePaths.add(f);\n\t\t\t\t\tmapFiles.set(file, readFileSync(file, 'utf-8'));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\t//* Parse files\n\t\tconst srcFiles: ts.SourceFile[] = [];\n\t\tconst rootFiles: Map<string, ts.SourceFile> = new Map();\n\t\tmapFiles.forEach(function (content, path) {\n\t\t\tlet srcFile = ts.createSourceFile(path, content, compilerOptions.target ?? ts.ScriptTarget.Latest, true);\n\t\t\tsrcFiles.push(srcFile);\n\t\t\trootFiles.set(path, srcFile)\n\t\t});\n\t\t//* Load target files from patterns\n\t\tinfo(`Load Patterns and files >>`);\n\t\tconst mapPatterns: Map<string, ResolvePatterns> = this._resolvePatterns(srcFiles);\n\t\tlet patternItems = Array.from(mapPatterns.values());\n\t\tif (patternItems.length === 0) {\n\t\t\twarn('--- No pattern found on all files ---');\n\t\t\tlet result = this.print(compilerOptions, rootFiles, targetExtension);\n\t\t\tinfo('</DONE>')\n\t\t\treturn result;\n\t\t}\n\t\t//* Link files\n\t\t// info(`Link files >>`);\n\t\t// let resolvedFileToFiles = this.#resolvedFileToFiles;\n\t\t// let fileToResolvedFiles = this.#fileToResolvedFiles;\n\t\t// Load resolved file paths\n\t\tfor (let i = 0, len = patternItems.length; i < len; ++i) {\n\t\t\tlet item = patternItems[i];\n\t\t\t// Add resolved files to set\n\t\t\titem.resolvedFiles.forEach(file => {\n\t\t\t\tfilePaths.add(file); // Add to paths\n\t\t\t});\n\t\t}\n\t\t//* Create program\n\t\tinfo(`Create Program >>`);\n\t\tconst pHost = ts.createCompilerHost(compilerOptions, true);\n\t\tpHost.readFile = function (fileName: string): string {\n\t\t\tvar k = normalize(fileName);\n\t\t\tvar f = mapFiles.get(k);\n\t\t\tif (f == null) {\n\t\t\t\tf = readFileSync(fileName, 'utf-8');\n\t\t\t\tmapFiles.set(k, f);\n\t\t\t}\n\t\t\treturn f;\n\t\t};\n\t\t/** Write results */\n\t\tpHost.writeFile = function (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly ts.SourceFile[]) {\n\t\t\t// Write only to existing files\n\t\t\tif (mapFiles.has(fileName)) mapFiles.set(fileName, data);\n\t\t};\n\t\tconst program = ts.createProgram(Array.from(filePaths), compilerOptions, pHost);\n\t\t//* Update root files\n\t\tfilePaths.forEach(file => {\n\t\t\trootFiles.set(file, program.getSourceFile(file)!);\n\t\t});\n\t\t//* Go through patterns and parse files\n\t\tinfo(`Parsing >>`);\n\t\tconst MarcoAnnotationMap: Map<ts.Node, MacroAnnotationHandler> = new Map();\n\t\tconst typechecker = program.getTypeChecker();\n\t\tfor (let i = 0, len = patternItems.length; i < len; ++i) {\n\t\t\tlet { files, patterns, resolvedFiles } = patternItems[i];\n\t\t\t//* Parse resolved files\n\t\t\tlet root = ParseModelFrom(resolvedFiles, program);\n\t\t\t// console.log('===ROOT===\\n', printTree(root, '\\t'));\n\t\t\t//* Format data\n\t\t\tlet formatted = formatModel(root);\n\t\t\t// console.log('===FORMATTED ROOT===\\n', printTree(formatted, '\\t'));\n\t\t\t//* Resolve macro annotations\n\t\t\tfor (let j = 0, len = resolvedFiles.length; j < len; ++j) {\n\t\t\t\tlet filePath = resolvedFiles[j];\n\t\t\t\tlet file = rootFiles.get(filePath);\n\t\t\t\tif (file == null) continue;\n\t\t\t\tfile = resolveAnnotationMacro(file, compilerOptions, typechecker, program, MarcoAnnotationMap);\n\t\t\t\trootFiles.set(filePath, file);\n\t\t\t}\n\t\t\t//* Add to target files\n\t\t\tfor (let j = 0, jLen = files.length; j < jLen; ++j) {\n\t\t\t\tlet { srcFile, node: targetNode, type: methodName } = files[j];\n\t\t\t\ttry {\n\t\t\t\t\t//* Compile data\n\t\t\t\t\tlet { imports, node: resultNode } = this.convertData(factory, srcFile, methodName, formatted, pretty, targetExtension);\n\t\t\t\t\t//* Replace patterns\n\t\t\t\t\tsrcFile = ts.transform(srcFile, [function (ctx: ts.TransformationContext) {\n\t\t\t\t\t\tfunction _visitor(node: ts.Node): ts.Node {\n\t\t\t\t\t\t\tif (node === targetNode) return resultNode;\n\t\t\t\t\t\t\telse return ts.visitEachChild(node, _visitor, ctx);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _visitor;\n\t\t\t\t\t}], compilerOptions).transformed[0] as ts.SourceFile;\n\t\t\t\t\t//* Inject imports\n\t\t\t\t\tif (imports.length) {\n\t\t\t\t\t\tsrcFile = factory.updateSourceFile(\n\t\t\t\t\t\t\tsrcFile,\n\t\t\t\t\t\t\t[...imports, ...srcFile.statements],\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tsrcFile.referencedFiles,\n\t\t\t\t\t\t\tsrcFile.typeReferenceDirectives,\n\t\t\t\t\t\t\tsrcFile.hasNoDefaultLib,\n\t\t\t\t\t\t\tsrcFile.libReferenceDirectives\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trootFiles.set(srcFile.fileName, srcFile);\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\tif (typeof err === 'string') err = new Error(`Converter error: ${err} at ${errorFile(srcFile, targetNode)}`);\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet result = this.print(compilerOptions, rootFiles, targetExtension);\n\t\tinfo('</DONE>')\n\t\treturn result;\n\t}\n\n\t/** Use by ::gulp adapter */\n\t#filesInfo: Map<string, { cwd: string, base: string }> = new Map();\n\t/**\n\t * Gulp adapter\n\t */\n\tgulp(\n\t\tpretty = true,\n\t\ttargetExtension?: TargetExtension | undefined\n\t) {\n\t\tconst files: Map<string, string> = new Map();\n\t\tconst self = this;\n\t\tconst filesInfo = this.#filesInfo;\n\t\treturn Through.obj(function (\n\t\t\tfile: Vinyl,\n\t\t\t_: any,\n\t\t\tcb: Through.TransformCallback\n\t\t) {\n\t\t\t//* Collect files\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\tfile.isDirectory() ||\n\t\t\t\t\tfile.isStream() ||\n\t\t\t\t\tfile.isSymbolic() ||\n\t\t\t\t\tfile.extname.toLowerCase() !== '.ts'\n\t\t\t\t) {\n\t\t\t\t\t// Ignore file\n\t\t\t\t\tcb(null, file);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet content: string;\n\t\t\t\t\tlet path = file.path;\n\t\t\t\t\tif (file.isBuffer()) content = file.contents!.toString('utf-8');\n\t\t\t\t\telse content = readFileSync(path, 'utf-8');\n\t\t\t\t\tfiles.set(path, content);\n\t\t\t\t\tfilesInfo.set(path, { cwd: file.cwd, base: file.base });\n\t\t\t\t\tcb(null);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tcb(error ?? 'ERROR', file);\n\t\t\t}\n\t\t}, function (cb: Through.TransformCallback) {\n\t\t\ttry {\n\t\t\t\t//* Compile files\n\t\t\t\tlet result = self.compile(files, pretty, targetExtension);\n\t\t\t\tfor (let i = 0, len = result.length; i < len; ++i) {\n\t\t\t\t\tlet item = result[i];\n\t\t\t\t\tlet path = item.path;\n\t\t\t\t\tlet info = filesInfo.get(path);\n\t\t\t\t\tif (info == null)\n\t\t\t\t\t\tthrow new Error(`Unexpected missing file info: ${path}`);\n\t\t\t\t\tthis.push(new Vinyl({\n\t\t\t\t\t\tpath: targetExtension ? path.replace(TS_REGEX, targetExtension) : path,\n\t\t\t\t\t\tbase: info.base,\n\t\t\t\t\t\tcwd: info.cwd,\n\t\t\t\t\t\tcontents: Buffer.from(item.content, 'utf-8')\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\tcb();\n\t\t\t} catch (error) {\n\t\t\t\tcb(error ?? 'ERROR');\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Resolve patterns, override this if you need to customize this logic */\n\t_resolvePatterns(srcFiles: ts.SourceFile[]) {\n\t\treturn resolvePatterns(srcFiles, PACKAGE_NAME, 'Model', 'scan', 'scanGraphQL');\n\t}\n\n\t/** print files  */\n\tprint(\n\t\tcompilerOptions: ts.CompilerOptions,\n\t\tfiles: Map<string, ts.SourceFile>,\n\t\ttargetExtension?: TargetExtension\n\t) {\n\t\tconst tsPrinter = ts.createPrinter();\n\t\t//* Resolve imports\n\t\tif (targetExtension != null)\n\t\t\tfiles = _resolveImports(tsPrinter, compilerOptions, files, targetExtension);\n\t\t//* Print files\n\t\tinfo(`Print files >>`);\n\t\tconst result: CompileResult[] = [];\n\t\tfiles.forEach(function (srcFile, path) {\n\t\t\ttry {\n\t\t\t\tresult.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tcontent: tsPrinter.printFile(srcFile)\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.log('path>>', path);\n\t\t\t\tconsole.log('>>', error);\n\t\t\t}\n\t\t});\n\t\t//* Transpile to JS\n\t\tif (targetExtension !== null) {\n\t\t\tinfo('Compile to JS>>');\n\t\t\tfor (let i = 0, len = result.length; i < len; ++i) {\n\t\t\t\tlet item = result[i];\n\t\t\t\titem.content = ts.transpile(item.content, compilerOptions, item.path);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Inject data into files */\n\tconvertData(\n\t\tnodeFactory: ts.NodeFactory,\n\t\tsrcFile: ts.SourceFile,\n\t\tmethodName: string,\n\t\tdata: ReturnType<typeof format>,\n\t\tpretty: boolean,\n\t\ttargetExtension: TargetExtension | undefined\n\t): ToDataReturn {\n\t\t//* Convert data into ts nodes\n\t\tlet result: ToDataReturn;\n\t\tswitch (methodName) {\n\t\t\tcase 'scan':\n\t\t\t\tresult = toDataModel(nodeFactory, srcFile, data, pretty, targetExtension);\n\t\t\t\tbreak;\n\t\t\tcase 'scanGraphQL':\n\t\t\t\tresult = toGraphQL(nodeFactory, srcFile, data, pretty, targetExtension);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow `Unexpected method \"${methodName}\"`;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n\n/** Parse tsConfig */\nexport function parseTsConfig(tsConfigPath: string) {\n\t//* Parse tsConfig\n\tvar tsP = ts.parseConfigFileTextToJson(\n\t\ttsConfigPath,\n\t\treadFileSync(tsConfigPath, 'utf-8')\n\t);\n\tif (tsP.error)\n\t\tthrow new Error(\n\t\t\t'Config file parse fails:' + tsP.error.messageText.toString()\n\t\t);\n\tvar tsP2 = ts.convertCompilerOptionsFromJson(\n\t\ttsP.config.compilerOptions,\n\t\tprocess.cwd(),\n\t\ttsConfigPath\n\t);\n\tif (tsP2.errors?.length)\n\t\tthrow new Error(\n\t\t\t'Config file parse fails:' +\n\t\t\ttsP2.errors.map(e => e.messageText.toString())\n\t\t);\n\treturn tsP2.options;\n}\n\n/** Resolve patterns response */\ninterface ResolvePatterns {\n\t/** Pattern key */\n\tid: string\n\t/** List of separated patterns */\n\tpatterns: string[]\n\t/** Files containing patterns */\n\tfiles: {\n\t\tsrcFile: ts.SourceFile\n\t\tnode: ts.Node\n\t\t/** Method type */\n\t\ttype: string\n\t}[]\n\t/** Paths of Resolved file by the pattern */\n\tresolvedFiles: string[]\n}\n/** Resolve patterns */\nexport function resolvePatterns(srcFiles: readonly ts.SourceFile[], packageName: string, className: string, ...methods: string[]): Map<string, ResolvePatterns> {\n\tconst result: Map<string, ResolvePatterns> = new Map();\n\tconst queue: ts.Node[] = [];\n\tconst errors: string[] = [];\n\tfor (let i = 0, len = srcFiles.length; i < len; ++i) {\n\t\ttry {\n\t\t\tconst srcFile = srcFiles[i];\n\t\t\tqueue.length = 0;\n\t\t\tqueue.push(srcFile);\n\t\t\tlet ModelVarNames: Set<string> = new Set();\n\t\t\tconst relativeDirname = relative(process.cwd(), dirname(srcFile.fileName));\n\t\t\tfor (let j = 0; j < queue.length; ++j) {\n\t\t\t\tlet node = queue[j];\n\t\t\t\tif (ts.isImportDeclaration(node)) {\n\t\t\t\t\tif (node.moduleSpecifier.getText().slice(1, -1) === packageName) {\n\t\t\t\t\t\t//* Load names used for \"Model\"\n\t\t\t\t\t\tnode.importClause?.namedBindings?.forEachChild(function (n) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tts.isImportSpecifier(n) &&\n\t\t\t\t\t\t\t\t(n.propertyName ?? n.name).getText() === className\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tModelVarNames.add(n.name.getText());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (ts.isCallExpression(node)) {\n\t\t\t\t\tlet expr = node.expression;\n\t\t\t\t\tif (\n\t\t\t\t\t\tts.isPropertyAccessExpression(expr) &&\n\t\t\t\t\t\tts.isIdentifier(expr.expression) &&\n\t\t\t\t\t\tModelVarNames.has(expr.expression.getText())\n\t\t\t\t\t) {\n\t\t\t\t\t\tlet propName = expr.name.getText();\n\t\t\t\t\t\tif (methods.includes(propName)) {\n\t\t\t\t\t\t\t//* Load and unify patterns\n\t\t\t\t\t\t\tlet patterns: string[] = extractStringArgs(node, srcFile);\n\t\t\t\t\t\t\tif (patterns.length === 0) break;\n\t\t\t\t\t\t\tlet originalPattern = patterns.join(', ');\n\t\t\t\t\t\t\tpatterns = originalPattern.split(',')\n\t\t\t\t\t\t\t\t.map(e => resolve(relativeDirname, e.trim())) // Get absolute paths\n\t\t\t\t\t\t\t\t.filter((a, i, arr) => arr.indexOf(a) === i); // Remove duplicates\n\t\t\t\t\t\t\t//* Add result\n\t\t\t\t\t\t\tlet key = patterns\n\t\t\t\t\t\t\t\t.slice(0) // create copy\n\t\t\t\t\t\t\t\t.sort((a, b) => a.localeCompare(b)) // sort to get unify form\n\t\t\t\t\t\t\t\t.join(',');\n\t\t\t\t\t\t\tlet v = result.get(key);\n\t\t\t\t\t\t\tif (v == null) {\n\t\t\t\t\t\t\t\tlet filePaths = _resolveFilesFromPatterns(patterns);\n\t\t\t\t\t\t\t\tif (filePaths.length === 0)\n\t\t\t\t\t\t\t\t\tthrow `No file found for pattern \"${originalPattern}\" at ${errorFile(srcFile, node)}`;\n\t\t\t\t\t\t\t\tresult.set(key, {\n\t\t\t\t\t\t\t\t\tid: key,\n\t\t\t\t\t\t\t\t\tpatterns,\n\t\t\t\t\t\t\t\t\tfiles: [{ srcFile, node, type: propName }],\n\t\t\t\t\t\t\t\t\tresolvedFiles: filePaths\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tv.files.push({\n\t\t\t\t\t\t\t\t\tsrcFile, node, type: propName\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push(...node.getChildren());\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tif (typeof err === 'string') errors.push(err);\n\t\t\telse throw err;\n\t\t}\n\t}\n\tif (errors.length > 0) throw new Error(`Got Errors:\\n- ${errors.join(\"\\n- \")}`);\n\treturn result;\n}\n\n/** Resolve files from patterns */\nfunction _resolveFilesFromPatterns(patterns: string[]): string[] {\n\tconst files: string[] = [];\n\tfor (let i = 0, len = patterns.length; i < len; ++i) {\n\t\tlet f = Glob.sync(patterns[i]);\n\t\tfor (let j = 0, jLen = f.length; j < jLen; ++j) {\n\t\t\tlet file = f[j];\n\t\t\tif (!files.includes(file))\n\t\t\t\tfiles.push(file);\n\t\t}\n\t}\n\treturn files;\n}\n\n\n/** Extract strings from call expression args */\nexport function extractStringArgs(node: ts.CallExpression, srcFile: ts.SourceFile) {\n\tlet arr: string[] = [];\n\tfor (let i = 0, args = node.arguments, len = args.length; i < len; ++i) {\n\t\tlet arg = args[i];\n\t\tif (ts.isStringLiteral(arg)) arr.push(arg.getText().slice(1, -1));\n\t\telse throw `Expected only static texts as arguments to \"${node.expression.getText()}\" at ${errorFile(srcFile, node)}`;\n\t}\n\treturn arr;\n}\n"]}