a0ca932b5c19431958575fb0e3a766bb.json
11.7 KB
{"ast":null,"code":"'use strict';\n\nconst TEMPLATE_REGEX = /(?:\\\\(u[a-f\\d]{4}|x[a-f\\d]{2}|.))|(?:\\{(~)?(\\w+(?:\\([^)]*\\))?(?:\\.\\w+(?:\\([^)]*\\))?)*)(?:[ \\t]|(?=\\r?\\n)))|(\\})|((?:.|[\\r\\n\\f])+?)/gi;\nconst STYLE_REGEX = /(?:^|\\.)(\\w+)(?:\\(([^)]*)\\))?/g;\nconst STRING_REGEX = /^(['\"])((?:\\\\.|(?!\\1)[^\\\\])*)\\1$/;\nconst ESCAPE_REGEX = /\\\\(u[a-f\\d]{4}|x[a-f\\d]{2}|.)|([^\\\\])/gi;\nconst ESCAPES = new Map([['n', '\\n'], ['r', '\\r'], ['t', '\\t'], ['b', '\\b'], ['f', '\\f'], ['v', '\\v'], ['0', '\\0'], ['\\\\', '\\\\'], ['e', '\\u001B'], ['a', '\\u0007']]);\n\nfunction unescape(c) {\n if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {\n return String.fromCharCode(parseInt(c.slice(1), 16));\n }\n\n return ESCAPES.get(c) || c;\n}\n\nfunction parseArguments(name, args) {\n const results = [];\n const chunks = args.trim().split(/\\s*,\\s*/g);\n let matches;\n\n for (const chunk of chunks) {\n if (!isNaN(chunk)) {\n results.push(Number(chunk));\n } else if (matches = chunk.match(STRING_REGEX)) {\n results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));\n } else {\n throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);\n }\n }\n\n return results;\n}\n\nfunction parseStyle(style) {\n STYLE_REGEX.lastIndex = 0;\n const results = [];\n let matches;\n\n while ((matches = STYLE_REGEX.exec(style)) !== null) {\n const name = matches[1];\n\n if (matches[2]) {\n const args = parseArguments(name, matches[2]);\n results.push([name].concat(args));\n } else {\n results.push([name]);\n }\n }\n\n return results;\n}\n\nfunction buildStyle(chalk, styles) {\n const enabled = {};\n\n for (const layer of styles) {\n for (const style of layer.styles) {\n enabled[style[0]] = layer.inverse ? null : style.slice(1);\n }\n }\n\n let current = chalk;\n\n for (const styleName of Object.keys(enabled)) {\n if (Array.isArray(enabled[styleName])) {\n if (!(styleName in current)) {\n throw new Error(`Unknown Chalk style: ${styleName}`);\n }\n\n if (enabled[styleName].length > 0) {\n current = current[styleName].apply(current, enabled[styleName]);\n } else {\n current = current[styleName];\n }\n }\n }\n\n return current;\n}\n\nmodule.exports = (chalk, tmp) => {\n const styles = [];\n const chunks = [];\n let chunk = []; // eslint-disable-next-line max-params\n\n tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {\n if (escapeChar) {\n chunk.push(unescape(escapeChar));\n } else if (style) {\n const str = chunk.join('');\n chunk = [];\n chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));\n styles.push({\n inverse,\n styles: parseStyle(style)\n });\n } else if (close) {\n if (styles.length === 0) {\n throw new Error('Found extraneous } in Chalk template literal');\n }\n\n chunks.push(buildStyle(chalk, styles)(chunk.join('')));\n chunk = [];\n styles.pop();\n } else {\n chunk.push(chr);\n }\n });\n chunks.push(chunk.join(''));\n\n if (styles.length > 0) {\n const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\\`}\\`)`;\n throw new Error(errMsg);\n }\n\n return chunks.join('');\n};","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/chalk/templates.js"],"names":["TEMPLATE_REGEX","STYLE_REGEX","STRING_REGEX","ESCAPE_REGEX","ESCAPES","Map","unescape","c","length","String","fromCharCode","parseInt","slice","get","parseArguments","name","args","results","chunks","trim","split","matches","chunk","isNaN","push","Number","match","replace","m","escape","chr","Error","parseStyle","style","lastIndex","exec","concat","buildStyle","chalk","styles","enabled","layer","inverse","current","styleName","Object","keys","Array","isArray","apply","module","exports","tmp","escapeChar","close","str","join","pop","errMsg"],"mappings":"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AAV,CAAN;AACA;;AAED,SAAOxC,MAAM,CAACsC,IAAP,CAAY,EAAZ,CAAP;AACA,CAnCD","sourcesContent":["'use strict';\nconst TEMPLATE_REGEX = /(?:\\\\(u[a-f\\d]{4}|x[a-f\\d]{2}|.))|(?:\\{(~)?(\\w+(?:\\([^)]*\\))?(?:\\.\\w+(?:\\([^)]*\\))?)*)(?:[ \\t]|(?=\\r?\\n)))|(\\})|((?:.|[\\r\\n\\f])+?)/gi;\nconst STYLE_REGEX = /(?:^|\\.)(\\w+)(?:\\(([^)]*)\\))?/g;\nconst STRING_REGEX = /^(['\"])((?:\\\\.|(?!\\1)[^\\\\])*)\\1$/;\nconst ESCAPE_REGEX = /\\\\(u[a-f\\d]{4}|x[a-f\\d]{2}|.)|([^\\\\])/gi;\n\nconst ESCAPES = new Map([\n\t['n', '\\n'],\n\t['r', '\\r'],\n\t['t', '\\t'],\n\t['b', '\\b'],\n\t['f', '\\f'],\n\t['v', '\\v'],\n\t['0', '\\0'],\n\t['\\\\', '\\\\'],\n\t['e', '\\u001B'],\n\t['a', '\\u0007']\n]);\n\nfunction unescape(c) {\n\tif ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {\n\t\treturn String.fromCharCode(parseInt(c.slice(1), 16));\n\t}\n\n\treturn ESCAPES.get(c) || c;\n}\n\nfunction parseArguments(name, args) {\n\tconst results = [];\n\tconst chunks = args.trim().split(/\\s*,\\s*/g);\n\tlet matches;\n\n\tfor (const chunk of chunks) {\n\t\tif (!isNaN(chunk)) {\n\t\t\tresults.push(Number(chunk));\n\t\t} else if ((matches = chunk.match(STRING_REGEX))) {\n\t\t\tresults.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));\n\t\t} else {\n\t\t\tthrow new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction parseStyle(style) {\n\tSTYLE_REGEX.lastIndex = 0;\n\n\tconst results = [];\n\tlet matches;\n\n\twhile ((matches = STYLE_REGEX.exec(style)) !== null) {\n\t\tconst name = matches[1];\n\n\t\tif (matches[2]) {\n\t\t\tconst args = parseArguments(name, matches[2]);\n\t\t\tresults.push([name].concat(args));\n\t\t} else {\n\t\t\tresults.push([name]);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction buildStyle(chalk, styles) {\n\tconst enabled = {};\n\n\tfor (const layer of styles) {\n\t\tfor (const style of layer.styles) {\n\t\t\tenabled[style[0]] = layer.inverse ? null : style.slice(1);\n\t\t}\n\t}\n\n\tlet current = chalk;\n\tfor (const styleName of Object.keys(enabled)) {\n\t\tif (Array.isArray(enabled[styleName])) {\n\t\t\tif (!(styleName in current)) {\n\t\t\t\tthrow new Error(`Unknown Chalk style: ${styleName}`);\n\t\t\t}\n\n\t\t\tif (enabled[styleName].length > 0) {\n\t\t\t\tcurrent = current[styleName].apply(current, enabled[styleName]);\n\t\t\t} else {\n\t\t\t\tcurrent = current[styleName];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn current;\n}\n\nmodule.exports = (chalk, tmp) => {\n\tconst styles = [];\n\tconst chunks = [];\n\tlet chunk = [];\n\n\t// eslint-disable-next-line max-params\n\ttmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {\n\t\tif (escapeChar) {\n\t\t\tchunk.push(unescape(escapeChar));\n\t\t} else if (style) {\n\t\t\tconst str = chunk.join('');\n\t\t\tchunk = [];\n\t\t\tchunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));\n\t\t\tstyles.push({inverse, styles: parseStyle(style)});\n\t\t} else if (close) {\n\t\t\tif (styles.length === 0) {\n\t\t\t\tthrow new Error('Found extraneous } in Chalk template literal');\n\t\t\t}\n\n\t\t\tchunks.push(buildStyle(chalk, styles)(chunk.join('')));\n\t\t\tchunk = [];\n\t\t\tstyles.pop();\n\t\t} else {\n\t\t\tchunk.push(chr);\n\t\t}\n\t});\n\n\tchunks.push(chunk.join(''));\n\n\tif (styles.length > 0) {\n\t\tconst errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\\`}\\`)`;\n\t\tthrow new Error(errMsg);\n\t}\n\n\treturn chunks.join('');\n};\n"]},"metadata":{},"sourceType":"script"}