NET-Web-API-w-Angular/my-app/node_modules/@babel/helper-module-imports/lib/import-builder.js.map

1 line
9.9 KiB
Text
Raw Normal View History

2024-02-09 00:38:41 +00:00
{"version":3,"names":["_assert","require","_t","callExpression","cloneNode","expressionStatement","identifier","importDeclaration","importDefaultSpecifier","importNamespaceSpecifier","importSpecifier","memberExpression","stringLiteral","variableDeclaration","variableDeclarator","ImportBuilder","constructor","importedSource","scope","hub","_statements","_resultName","_importedSource","_scope","_hub","done","statements","resultName","import","push","namespace","name","local","generateUidIdentifier","statement","length","assert","type","specifiers","default","id","named","importName","var","expression","defaultInterop","_interop","addHelper","wildcardInterop","callee","declarations","init","fail","prop","read","exports"],"sources":["../src/import-builder.ts"],"sourcesContent":["import assert from \"assert\";\nimport {\n callExpression,\n cloneNode,\n expressionStatement,\n identifier,\n importDeclaration,\n importDefaultSpecifier,\n importNamespaceSpecifier,\n importSpecifier,\n memberExpression,\n stringLiteral,\n variableDeclaration,\n variableDeclarator,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { Scope } from \"@babel/traverse\";\nimport type { File } from \"@babel/core\";\n\n/**\n * A class to track and accumulate mutations to the AST that will eventually\n * output a new require/import statement list.\n */\nexport default class ImportBuilder {\n private _statements: t.Statement[] = [];\n private _resultName: t.Identifier | t.MemberExpression = null;\n\n declare _scope: Scope;\n declare _hub: File[\"hub\"];\n private _importedSource: string;\n\n constructor(importedSource: string, scope: Scope, hub: File[\"hub\"]) {\n this._scope = scope;\n this._hub = hub;\n this._importedSource = importedSource;\n }\n\n done() {\n return {\n statements: this._statements,\n resultName: this._resultName,\n };\n }\n\n import() {\n this._statements.push(\n importDeclaration([], stringLiteral(this._importedSource)),\n );\n return this;\n }\n\n require() {\n this._statements.push(\n expressionStatement(\n callExpression(identifier(\"require\"), [\n stringLiteral(this._importedSource),\n ]),\n ),\n );\n return this;\n }\n\n namespace(name = \"namespace\") {\n const local = this._scope.generateUidIdentifier(name);\n\n const statement = this._statements[this._statements.length - 1];\n assert(statement.type === \"ImportDeclaration\");\n assert(statement.specifiers.length === 0);\n statement.specifiers = [importNamespaceSpecifier(local)];\n this._resultName = cloneNode(local);\n return this;\n }\n default(name: string) {\n const id = this._scope.generateUidIdentifier(name);\n const statement = this._statements[this._statements.length - 1];\n assert(statement.type === \"ImportDeclaration\");\n assert(statement.specifiers.length === 0);\n statement.specifiers = [importDefaultSpecifier(id)];\n this._resultName = cloneNode(id);\n return this;\n }\n named(name: string, importName: string) {\n if (importName === \"default\") return this.default(name);\n\n const id = this._scope.generateUidIdentifier(name);\n const statement = this._statements[this._statements.length - 1];\n assert(statement.type === \"ImportDeclaration\");\n assert(statement.specifiers.length === 0);\n statement.specifiers = [importSpecifier(id, identifier(importName))];\n this._resultName = cloneNode(id);\n return this;\n }\n\n var(name: string) {\n const id = this._scope.generateUidIdentifier(name);\n let statement = this._statements[this._statements.length - 1];\n if (statement.type !== \"ExpressionStatement\") {\n assert(this._resultName);\n statement = expressionStatement(this._resultName);\n this._statements.push(statement);\n }\n this._statements[this._statements.length - 1] = variableDeclaration(\"var\", [\n variableDeclarator(id, statement.expression),\n ]);\n this._resultName = cloneNode(id);\n return this;\n }\n\