amis-rpc-design/node_modules/@babel/generator/lib/index.js.map

1 line
12 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["_sourceMap","require","_printer","Generator","Printer","constructor","ast","opts","code","format","normalizeOptions","map","sourceMaps","SourceMap","generate","_opts$recordAndTupleS","auxiliaryCommentBefore","auxiliaryCommentAfter","shouldPrintComment","retainLines","retainFunctionParens","comments","compact","minified","concise","indent","adjustMultilineComment","style","jsescOption","Object","assign","quotes","wrap","minimal","recordAndTupleSyntaxType","topicToken","importAttributesKeyword","decoratorsBeforeExport","json","jsonCompatibleStrings","value","includes","length","console","error","filename","undefined","CodeGenerator","_generator","exports","gen"],"sources":["../src/index.ts"],"sourcesContent":["import SourceMap from \"./source-map.ts\";\nimport Printer from \"./printer.ts\";\nimport type * as t from \"@babel/types\";\nimport type { Opts as jsescOptions } from \"jsesc\";\nimport type { Format } from \"./printer.ts\";\nimport type {\n RecordAndTuplePluginOptions,\n PipelineOperatorPluginOptions,\n} from \"@babel/parser\";\nimport type {\n EncodedSourceMap,\n DecodedSourceMap,\n Mapping,\n} from \"@jridgewell/gen-mapping\";\n\n/**\n * Babel's code generator, turns an ast into code, maintaining sourcemaps,\n * user preferences, and valid output.\n */\n\nclass Generator extends Printer {\n constructor(\n ast: t.Node,\n opts: GeneratorOptions = {},\n code: string | { [filename: string]: string },\n ) {\n const format = normalizeOptions(code, opts);\n const map = opts.sourceMaps ? new SourceMap(opts, code) : null;\n super(format, map);\n\n this.ast = ast;\n }\n\n ast: t.Node;\n\n /**\n * Generate code and sourcemap from ast.\n *\n * Appends comments that weren't attached to any node to the end of the generated output.\n */\n\n generate() {\n return super.generate(this.ast);\n }\n}\n\n/**\n * Normalize generator options, setting defaults.\n *\n * - Detects code indentation.\n * - If `opts.compact = \"auto\"` and the code is over 500KB, `compact` will be set to `true`.\n */\n\nfunction normalizeOptions(\n code: string | { [filename: string]: string },\n opts: GeneratorOptions,\n): Format {\n const format: Format = {\n auxiliaryCommentBefore: opts.auxiliaryCommentBefore,\n auxiliaryCommentAfter: opts.auxiliaryCommentAfter,\n shouldPrintComment: opts.shouldPrintComment,\n retainLines: opts.retainLines,\n retainFunctionParens: opts.retainFunctionParens,\n comments: opts.comments == null || opts.comments,\n compact: opts.compact,\n minified: opts.minified,\n concise: opts.concise,\n indent: {\n adjustMultilineComment: true,\n style: \" \",\n },\n jsescOption: {\n quotes: \"double\",\n wrap: true,\n minimal: process.env.BABEL_8_BREAKING ? true : false,\n ...opts.jsescOption,\n },\n recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType ?? \"hash\",\n topicToken: opts.topicToken,\n importAttributesKeyword: opts.importAttributesKeyword,\n };\n\n if (!process.env.BABEL_8_BREAKING) {\n format.decoratorsBeforeExport = opts.decoratorsBeforeExport;\n format.jsescOption.json = opts.jsonCompatibleStrings;\n }\n\n if (format.minified) {\n format.compact = true;\n\n format.shouldPrintComment =\n format.shouldPrintComment || (() => format.comments);\n } else {\n format.shouldPrintComment =\n format.shouldPrintComment ||\n (value =>\n format.comments ||\n value.includes(\"@license\") ||\n value.includes(\"@preserve\"));\n }\n\n if (format.compact === \"auto\") {\n format.compact = typeof code === \"string\" && code.length > 500_000; // 500KB\n\n if (format.compact) {\n console.error(\n \"[BABEL] Note: The code generator has deoptimised the styling of \" +\n `${opts.filename} as it exceeds the max of ${\"500KB\"}.`,\n );\n }\n }\n\n if (format.compact) {\n format.indent.adjustMultilineComment = false;\n }\n\n const { auxiliaryCommentBefore, auxiliaryCommentAfter, shouldPrintComment } =\n