@teambit/typescript 0.0.1110 → 0.0.1111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmds/check-types.cmd.js.map +1 -1
- package/dist/cmds/write-tsconfig.cmd.js +2 -1
- package/dist/cmds/write-tsconfig.cmd.js.map +1 -1
- package/dist/dedupe-path.spec.js.map +1 -1
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/transformer-not-found.js.map +1 -1
- package/dist/export-identifier.js.map +1 -1
- package/dist/identifier-list.js.map +1 -1
- package/dist/identifier.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{preview-1689736586631.js → preview-1689823719636.js} +2 -2
- package/dist/remove-types-task.js.map +1 -1
- package/dist/schema-extractor-context.js +8 -9
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/schema-transformer.plugin.js.map +1 -1
- package/dist/sourceFileTransformers/class.js.map +1 -1
- package/dist/sourceFileTransformers/empty-line-encoder.js.map +1 -1
- package/dist/sourceFileTransformers/export.js.map +1 -1
- package/dist/sourceFileTransformers/expression-statement.js.map +1 -1
- package/dist/sourceFileTransformers/function.js.map +1 -1
- package/dist/sourceFileTransformers/import.js.map +1 -1
- package/dist/sourceFileTransformers/index.js.map +1 -1
- package/dist/sourceFileTransformers/interface.js.map +1 -1
- package/dist/sourceFileTransformers/transform.js.map +1 -1
- package/dist/sourceFileTransformers/typeAlias.js.map +1 -1
- package/dist/sourceFileTransformers/variable.js.map +1 -1
- package/dist/transform-source-file.spec.js.map +1 -1
- package/dist/transformers/array-type.js.map +1 -1
- package/dist/transformers/binding-element.js.map +1 -1
- package/dist/transformers/class-declaration.js.map +1 -1
- package/dist/transformers/conditional-type.js.map +1 -1
- package/dist/transformers/constructor.js.map +1 -1
- package/dist/transformers/enum-declaration.js.map +1 -1
- package/dist/transformers/export-assignment.js.map +1 -1
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/expression-statement.js.map +1 -1
- package/dist/transformers/function-like.js.map +1 -1
- package/dist/transformers/get-accessor.js.map +1 -1
- package/dist/transformers/import-declaration.js.map +1 -1
- package/dist/transformers/index-signature.js.map +1 -1
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/indexed-access-type.js.map +1 -1
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/intersection-type.js.map +1 -1
- package/dist/transformers/keyword-type.js.map +1 -1
- package/dist/transformers/literal-type.js.map +1 -1
- package/dist/transformers/module-declaration.js.map +1 -1
- package/dist/transformers/named-tuple.js.map +1 -1
- package/dist/transformers/parameter.js.map +1 -1
- package/dist/transformers/parenthesized-type.js.map +1 -1
- package/dist/transformers/property-declaration.js.map +1 -1
- package/dist/transformers/set-accessor.js.map +1 -1
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/template-literal-type-span.js.map +1 -1
- package/dist/transformers/template-literal-type.js.map +1 -1
- package/dist/transformers/this-type.js.map +1 -1
- package/dist/transformers/tuple-type.js.map +1 -1
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/type-literal.js.map +1 -1
- package/dist/transformers/type-operator.js.map +1 -1
- package/dist/transformers/type-predicate.js.map +1 -1
- package/dist/transformers/type-query.js.map +1 -1
- package/dist/transformers/type-reference.js.map +1 -1
- package/dist/transformers/union-type.js.map +1 -1
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/tsconfig-writer.js.map +1 -1
- package/dist/typescript.aspect.js.map +1 -1
- package/dist/typescript.compiler.js.map +1 -1
- package/dist/typescript.compiler.spec.js.map +1 -1
- package/dist/typescript.composition.js.map +1 -1
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.js.map +1 -1
- package/dist/typescript.parser.js.map +1 -1
- package/dist/typescript.parser.spec.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.1111.tgz +0 -0
- package/package.json +18 -18
- package/package-tar/teambit-typescript-0.0.1110.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","functionNamesTransformer","mapping","context","updateTypeReference","node","ts","isTypeReferenceNode","typeName","getText","newTypeName","factory","updateTypeReferenceNode","createIdentifier","typeArguments","visitEachChild","visit","isFunctionDeclaration","isArrowFunction","isFunctionExpression","_node$name$getText","_node$name","_Object$entries$find$","_Object$entries$find","functionName","name","newName","Object","entries","find","key","includes","parameters","map","param","newParamType","type","visitNode","isIdentifier","oldName","newParamName","keys","updateParameterDeclaration","decorators","modifiers","dotDotDotToken","questionToken","initializer","isObjectBindingPattern","elements","element","newElementName","updateBindingElement","propertyName","createObjectBindingPattern","updatedBody","body","isBlock","updateReturnStatement","updateFunctionDeclaration","asteriskToken","typeParameters","updateArrowFunction","equalsGreaterThanToken","updateFunctionExpression","updatedStatements","statement","statements","isReturnStatement","expression","isJsxElement","jsxElement","openingElement","tagName","newTagName","updatedTagName","updatedOpeningElement","updateJsxOpeningElement","attributes","updatedClosingElement","closingElement","updateJsxClosingElement","createJsxClosingElement","updatedJsxElement","createJsxElement","children","updatedStatement","createReturnStatement","push","updateBlock","isExpressionStatement","text","updatedExpression","updatedReturnStatement","createBlock","exports"],"sources":["function.ts"],"sourcesContent":["import ts from 'typescript';\nimport { SourceFileTransformer } from '.';\n\nexport const functionNamesTransformer: SourceFileTransformer = (mapping: Record<string, string>) => {\n return (context) => {\n const updateTypeReference: ts.Visitor = (node) => {\n if (ts.isTypeReferenceNode(node)) {\n const typeName = node.typeName.getText();\n const newTypeName = mapping[typeName];\n if (newTypeName) {\n return ts.factory.updateTypeReferenceNode(node, ts.factory.createIdentifier(newTypeName), node.typeArguments);\n }\n }\n return ts.visitEachChild(node, updateTypeReference, context);\n };\n\n const visit: ts.Visitor = (node) => {\n if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n const functionName = node.name?.getText() ?? '';\n const newName = Object.entries(mapping).find(([key]) => functionName.includes(key))?.[1] ?? functionName;\n const parameters = node.parameters.map((param) => {\n const newParamType = param.type ? ts.visitNode(param.type, updateTypeReference) : param.type;\n if (ts.isIdentifier(param.name)) {\n const oldName = param.name.getText();\n const newParamName = Object.keys(mapping).find((key) => oldName.includes(key));\n if (newParamName) {\n return ts.factory.updateParameterDeclaration(\n param,\n param.decorators,\n param.modifiers,\n param.dotDotDotToken,\n ts.factory.createIdentifier(newParamName),\n param.questionToken,\n newParamType,\n param.initializer\n );\n }\n } else if (ts.isObjectBindingPattern(param.name)) {\n const elements = param.name.elements.map((element) => {\n const newElementName = mapping[element.name.getText()];\n if (newElementName) {\n return ts.factory.updateBindingElement(\n element,\n element.dotDotDotToken,\n element.propertyName,\n ts.factory.createIdentifier(newElementName),\n element.initializer\n );\n }\n return element;\n });\n const newParamName = ts.factory.createObjectBindingPattern(elements);\n return ts.factory.updateParameterDeclaration(\n param,\n param.decorators,\n param.modifiers,\n param.dotDotDotToken,\n newParamName,\n param.questionToken,\n newParamType,\n param.initializer\n );\n }\n return param;\n });\n\n if (ts.isFunctionDeclaration(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateFunctionDeclaration(\n node,\n node.decorators,\n node.modifiers,\n node.asteriskToken,\n newName ? ts.factory.createIdentifier(newName) : node.name,\n node.typeParameters,\n parameters,\n node.type,\n updatedBody\n );\n }\n if (ts.isArrowFunction(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateArrowFunction(\n node,\n node.modifiers,\n node.typeParameters,\n parameters,\n node.type,\n node.equalsGreaterThanToken,\n updatedBody\n );\n }\n if (ts.isFunctionExpression(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateFunctionExpression(\n node,\n node.modifiers,\n node.asteriskToken,\n newName ? ts.factory.createIdentifier(newName) : node.name,\n node.typeParameters,\n parameters,\n node.type,\n updatedBody\n );\n }\n }\n return ts.visitEachChild(node, visit, context);\n };\n\n function updateReturnStatement(body: ts.ConciseBody): ts.Block {\n if (ts.isBlock(body)) {\n const updatedStatements: ts.Statement[] = [];\n for (const statement of body.statements) {\n if (ts.isReturnStatement(statement) && statement.expression && ts.isJsxElement(statement.expression)) {\n const jsxElement = statement.expression;\n const openingElement = jsxElement.openingElement;\n const tagName = openingElement.tagName.getText();\n const newTagName = mapping[tagName];\n if (newTagName) {\n const updatedTagName = ts.factory.createIdentifier(newTagName);\n const updatedOpeningElement = ts.factory.updateJsxOpeningElement(\n openingElement,\n updatedTagName,\n openingElement.typeArguments,\n openingElement.attributes\n );\n const updatedClosingElement = jsxElement.closingElement\n ? ts.factory.updateJsxClosingElement(jsxElement.closingElement, updatedTagName)\n : ts.factory.createJsxClosingElement(updatedTagName);\n const updatedJsxElement = ts.factory.createJsxElement(\n updatedOpeningElement,\n jsxElement.children,\n updatedClosingElement\n );\n const updatedStatement = ts.factory.createReturnStatement(updatedJsxElement);\n updatedStatements.push(updatedStatement);\n } else {\n updatedStatements.push(statement);\n }\n } else {\n updatedStatements.push(statement);\n }\n }\n return ts.factory.updateBlock(body, updatedStatements);\n }\n if (\n ts.isExpressionStatement(body) &&\n ts.isReturnStatement(body.expression) &&\n body.expression.expression &&\n ts.isIdentifier(body.expression.expression)\n ) {\n const oldName = body.expression.expression.text;\n const newName = mapping[oldName];\n if (newName) {\n const updatedExpression = ts.factory.createIdentifier(newName);\n const updatedReturnStatement = ts.factory.createReturnStatement(updatedExpression);\n return ts.factory.createBlock([updatedReturnStatement], true);\n }\n }\n return ts.factory.createBlock([], true);\n }\n return (node) => ts.visitNode(node, visit);\n };\n};\n"],"mappings":";;;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAA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qBAAE,CAACK,OAAO,CAAC8E,WAAW,CAACjC,IAAI,EAAES,iBAAiB,CAAC;MACxD;MACA,IACE3D,qBAAE,CAACoF,qBAAqB,CAAClC,IAAI,CAAC,IAC9BlD,qBAAE,CAAC8D,iBAAiB,CAACZ,IAAI,CAACa,UAAU,CAAC,IACrCb,IAAI,CAACa,UAAU,CAACA,UAAU,IAC1B/D,qBAAE,CAACgC,YAAY,CAACkB,IAAI,CAACa,UAAU,CAACA,UAAU,CAAC,EAC3C;QACA,MAAM9B,OAAO,GAAGiB,IAAI,CAACa,UAAU,CAACA,UAAU,CAACsB,IAAI;QAC/C,MAAMjE,OAAO,GAAGxB,OAAO,CAACqC,OAAO,CAAC;QAChC,IAAIb,OAAO,EAAE;UACX,MAAMkE,iBAAiB,GAAGtF,qBAAE,CAACK,OAAO,CAACE,gBAAgB,CAACa,OAAO,CAAC;UAC9D,MAAMmE,sBAAsB,GAAGvF,qBAAE,CAACK,OAAO,CAAC4E,qBAAqB,CAACK,iBAAiB,CAAC;UAClF,OAAOtF,qBAAE,CAACK,OAAO,CAACmF,WAAW,CAAC,CAACD,sBAAsB,CAAC,EAAE,IAAI,CAAC;QAC/D;MACF;MACA,OAAOvF,qBAAE,CAACK,OAAO,CAACmF,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC;IACzC;IACA,OAAQzF,IAAI,IAAKC,qBAAE,CAAC+B,SAAS,CAAChC,IAAI,EAAEW,KAAK,CAAC;EAC5C,CAAC;AACH,CAAC;AAAC+E,OAAA,CAAA9F,wBAAA,GAAAA,wBAAA"}
|
|
1
|
+
{"version":3,"names":["functionNamesTransformer","mapping","context","updateTypeReference","node","ts","isTypeReferenceNode","typeName","getText","newTypeName","factory","updateTypeReferenceNode","createIdentifier","typeArguments","visitEachChild","visit","isFunctionDeclaration","isArrowFunction","isFunctionExpression","functionName","name","newName","Object","entries","find","key","includes","parameters","map","param","newParamType","type","visitNode","isIdentifier","oldName","newParamName","keys","updateParameterDeclaration","decorators","modifiers","dotDotDotToken","questionToken","initializer","isObjectBindingPattern","elements","element","newElementName","updateBindingElement","propertyName","createObjectBindingPattern","updatedBody","body","isBlock","updateReturnStatement","updateFunctionDeclaration","asteriskToken","typeParameters","updateArrowFunction","equalsGreaterThanToken","updateFunctionExpression","updatedStatements","statement","statements","isReturnStatement","expression","isJsxElement","jsxElement","openingElement","tagName","newTagName","updatedTagName","updatedOpeningElement","updateJsxOpeningElement","attributes","updatedClosingElement","closingElement","updateJsxClosingElement","createJsxClosingElement","updatedJsxElement","createJsxElement","children","updatedStatement","createReturnStatement","push","updateBlock","isExpressionStatement","text","updatedExpression","updatedReturnStatement","createBlock"],"sources":["function.ts"],"sourcesContent":["import ts from 'typescript';\nimport { SourceFileTransformer } from '.';\n\nexport const functionNamesTransformer: SourceFileTransformer = (mapping: Record<string, string>) => {\n return (context) => {\n const updateTypeReference: ts.Visitor = (node) => {\n if (ts.isTypeReferenceNode(node)) {\n const typeName = node.typeName.getText();\n const newTypeName = mapping[typeName];\n if (newTypeName) {\n return ts.factory.updateTypeReferenceNode(node, ts.factory.createIdentifier(newTypeName), node.typeArguments);\n }\n }\n return ts.visitEachChild(node, updateTypeReference, context);\n };\n\n const visit: ts.Visitor = (node) => {\n if (ts.isFunctionDeclaration(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n const functionName = node.name?.getText() ?? '';\n const newName = Object.entries(mapping).find(([key]) => functionName.includes(key))?.[1] ?? functionName;\n const parameters = node.parameters.map((param) => {\n const newParamType = param.type ? ts.visitNode(param.type, updateTypeReference) : param.type;\n if (ts.isIdentifier(param.name)) {\n const oldName = param.name.getText();\n const newParamName = Object.keys(mapping).find((key) => oldName.includes(key));\n if (newParamName) {\n return ts.factory.updateParameterDeclaration(\n param,\n param.decorators,\n param.modifiers,\n param.dotDotDotToken,\n ts.factory.createIdentifier(newParamName),\n param.questionToken,\n newParamType,\n param.initializer\n );\n }\n } else if (ts.isObjectBindingPattern(param.name)) {\n const elements = param.name.elements.map((element) => {\n const newElementName = mapping[element.name.getText()];\n if (newElementName) {\n return ts.factory.updateBindingElement(\n element,\n element.dotDotDotToken,\n element.propertyName,\n ts.factory.createIdentifier(newElementName),\n element.initializer\n );\n }\n return element;\n });\n const newParamName = ts.factory.createObjectBindingPattern(elements);\n return ts.factory.updateParameterDeclaration(\n param,\n param.decorators,\n param.modifiers,\n param.dotDotDotToken,\n newParamName,\n param.questionToken,\n newParamType,\n param.initializer\n );\n }\n return param;\n });\n\n if (ts.isFunctionDeclaration(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateFunctionDeclaration(\n node,\n node.decorators,\n node.modifiers,\n node.asteriskToken,\n newName ? ts.factory.createIdentifier(newName) : node.name,\n node.typeParameters,\n parameters,\n node.type,\n updatedBody\n );\n }\n if (ts.isArrowFunction(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateArrowFunction(\n node,\n node.modifiers,\n node.typeParameters,\n parameters,\n node.type,\n node.equalsGreaterThanToken,\n updatedBody\n );\n }\n if (ts.isFunctionExpression(node)) {\n const updatedBody = node.body && ts.isBlock(node.body) ? updateReturnStatement(node.body) : node.body;\n return ts.factory.updateFunctionExpression(\n node,\n node.modifiers,\n node.asteriskToken,\n newName ? ts.factory.createIdentifier(newName) : node.name,\n node.typeParameters,\n parameters,\n node.type,\n updatedBody\n );\n }\n }\n return ts.visitEachChild(node, visit, context);\n };\n\n function updateReturnStatement(body: ts.ConciseBody): ts.Block {\n if (ts.isBlock(body)) {\n const updatedStatements: ts.Statement[] = [];\n for (const statement of body.statements) {\n if (ts.isReturnStatement(statement) && statement.expression && ts.isJsxElement(statement.expression)) {\n const jsxElement = statement.expression;\n const openingElement = jsxElement.openingElement;\n const tagName = openingElement.tagName.getText();\n const newTagName = mapping[tagName];\n if (newTagName) {\n const updatedTagName = ts.factory.createIdentifier(newTagName);\n const updatedOpeningElement = ts.factory.updateJsxOpeningElement(\n openingElement,\n updatedTagName,\n openingElement.typeArguments,\n openingElement.attributes\n );\n const updatedClosingElement = jsxElement.closingElement\n ? ts.factory.updateJsxClosingElement(jsxElement.closingElement, updatedTagName)\n : ts.factory.createJsxClosingElement(updatedTagName);\n const updatedJsxElement = ts.factory.createJsxElement(\n updatedOpeningElement,\n jsxElement.children,\n updatedClosingElement\n );\n const updatedStatement = ts.factory.createReturnStatement(updatedJsxElement);\n updatedStatements.push(updatedStatement);\n } else {\n updatedStatements.push(statement);\n }\n } else {\n updatedStatements.push(statement);\n }\n }\n return ts.factory.updateBlock(body, updatedStatements);\n }\n if (\n ts.isExpressionStatement(body) &&\n ts.isReturnStatement(body.expression) &&\n body.expression.expression &&\n ts.isIdentifier(body.expression.expression)\n ) {\n const oldName = body.expression.expression.text;\n const newName = mapping[oldName];\n if (newName) {\n const updatedExpression = ts.factory.createIdentifier(newName);\n const updatedReturnStatement = ts.factory.createReturnStatement(updatedExpression);\n return ts.factory.createBlock([updatedReturnStatement], true);\n }\n }\n return ts.factory.createBlock([], true);\n }\n return (node) => ts.visitNode(node, visit);\n };\n};\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,wBAA+C,GAAIC,OAA+B,IAAK;EAClG,OAAQC,OAAO,IAAK;IAClB,MAAMC,mBAA+B,GAAIC,IAAI,IAAK;MAChD,IAAIC,qBAAE,CAACC,mBAAmB,CAACF,IAAI,CAAC,EAAE;QAChC,MAAMG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAACC,OAAO,EAAE;QACxC,MAAMC,WAAW,GAAGR,OAAO,CAACM,QAAQ,CAAC;QACrC,IAAIE,WAAW,EAAE;UACf,OAAOJ,qBAAE,CAACK,OAAO,CAACC,uBAAuB,CAACP,IAAI,EAAEC,qBAAE,CAACK,OAAO,CAACE,gBAAgB,CAACH,WAAW,CAAC,EAAEL,IAAI,CAACS,aAAa,CAAC;QAC/G;MACF;MACA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AACK,OAAO,CAAC+E,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC;IACzC;IACA,OAAQrF,IAAI,IAAKC,qBAAE,CAAC2B,SAAS,CAAC5B,IAAI,EAAEW,KAAK,CAAC;EAC5C,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["importTransformer","mapping","context","visit","node","ts","isImportDeclaration","moduleSpecifier","getText","slice","oldName","newName","Object","entries","includes","replace","importClause","namedBindings","isNamedImports","transformedBindings","elements","map","element","newElementName","name","text","startsWith","endsWith","factory","updateImportSpecifier","propertyName","createIdentifier","undefined","updatedImportClause","updateImportClause","isTypeOnly","createNamedImports","updateImportDeclaration","decorators","modifiers","createStringLiteral","isImportEqualsDeclaration","moduleReference","updatedImportEqualsDeclaration","updateImportEqualsDeclaration","createExternalModuleReference","isCallExpression","isIdentifier","expression","firstArg","arguments","isStringLiteral","updatedArg","updateCallExpression","typeArguments","visitEachChild","visitNode"],"sources":["import.ts"],"sourcesContent":["import ts from 'typescript';\nimport { SourceFileTransformer } from '.';\n\nexport const importTransformer: SourceFileTransformer = (mapping: Record<string, string>) => {\n return (context) => {\n const visit: ts.Visitor = (node) => {\n if (ts.isImportDeclaration(node)) {\n let moduleSpecifier = node.moduleSpecifier.getText().slice(1, -1);\n for (const [oldName, newName] of Object.entries(mapping)) {\n if (moduleSpecifier.includes(oldName)) {\n moduleSpecifier = moduleSpecifier.replace(oldName, newName);\n }\n }\n\n if (node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {\n const transformedBindings = node.importClause.namedBindings.elements.map((element) => {\n let newElementName = element.name.text;\n\n for (const [oldName, newName] of Object.entries(mapping)) {\n if (newElementName.startsWith(oldName) || newElementName.endsWith(oldName)) {\n newElementName = newElementName.replace(oldName, newName);\n }\n }\n\n return ts.factory.updateImportSpecifier(\n element,\n false,\n element.propertyName ? ts.factory.createIdentifier(newElementName) : undefined,\n ts.factory.createIdentifier(newElementName)\n );\n });\n\n const updatedImportClause = ts.factory.updateImportClause(\n node.importClause,\n node.importClause.isTypeOnly,\n node.importClause.name,\n ts.factory.createNamedImports(transformedBindings)\n );\n\n return ts.factory.updateImportDeclaration(\n node,\n node.decorators,\n node.modifiers,\n updatedImportClause,\n ts.factory.createStringLiteral(moduleSpecifier),\n undefined\n );\n }\n\n return ts.factory.updateImportDeclaration(\n node,\n node.decorators,\n node.modifiers,\n node.importClause,\n ts.factory.createStringLiteral(moduleSpecifier),\n undefined\n );\n }\n if (ts.isImportEqualsDeclaration(node)) {\n let moduleSpecifier = node.moduleReference.getText().slice(1, -1);\n for (const [oldName, newName] of Object.entries(mapping)) {\n if (moduleSpecifier.includes(oldName)) {\n moduleSpecifier = moduleSpecifier.replace(oldName, newName);\n }\n }\n\n const updatedImportEqualsDeclaration = ts.factory.updateImportEqualsDeclaration(\n node,\n node.decorators,\n node.modifiers,\n node.isTypeOnly,\n node.name,\n ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(moduleSpecifier))\n );\n\n return updatedImportEqualsDeclaration;\n }\n\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'require') {\n const [firstArg] = node.arguments;\n\n if (ts.isStringLiteral(firstArg)) {\n let moduleSpecifier = firstArg.text;\n\n for (const [oldName, newName] of Object.entries(mapping)) {\n if (moduleSpecifier.includes(oldName)) {\n moduleSpecifier = moduleSpecifier.replace(oldName, newName);\n }\n }\n\n const updatedArg = ts.factory.createStringLiteral(moduleSpecifier);\n return ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [\n updatedArg,\n ...node.arguments.slice(1),\n ]);\n }\n }\n\n return ts.visitEachChild(node, visit, context);\n };\n return (node) => ts.visitNode(node, visit);\n };\n};\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,iBAAwC,GAAIC,OAA+B,IAAK;EAC3F,OAAQC,OAAO,IAAK;I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K,EAAED,OAAO,CAAC;IAChD,CAAC;IACD,OAAQE,IAAI,IAAKC,qBAAE,CAACmD,SAAS,CAACpD,IAAI,EAAED,KAAK,CAAC;EAC5C,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport type SourceFileTransformer = (mapping: Record<string, string>) => ts.TransformerFactory<ts.SourceFile>;\n\nexport { classNamesTransformer } from './class';\nexport { interfaceNamesTransformer } from './interface';\nexport { variableNamesTransformer } from './variable';\nexport { functionNamesTransformer } from './function';\nexport { typeAliasNamesTransformer } from './typeAlias';\nexport { importTransformer } from './import';\nexport { expressionStatementTransformer } from './expression-statement';\nexport { exportTransformer } from './export';\nexport { transformSourceFile } from './transform';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["interfaceNamesTransformer","nameMapping","context","factory","visit","node","ts","isInterfaceDeclaration","oldName","name","text","newName","Object","keys","find","key","startsWith","endsWith","replacedName","replace","RegExp","updateInterfaceDeclaration","decorators","modifiers","createIdentifier","typeParameters","heritageClauses","members","visitEachChild","child","visitNode"],"sources":["interface.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport function interfaceNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile> {\n return (context) => {\n const { factory } = context;\n const visit: ts.Visitor = (node) => {\n if (ts.isInterfaceDeclaration(node)) {\n const oldName = node.name.text;\n const newName = Object.keys(nameMapping).find((key) => oldName.startsWith(key) || oldName.endsWith(key));\n if (newName) {\n const replacedName = oldName.startsWith(newName)\n ? oldName.replace(newName, nameMapping[newName])\n : oldName.replace(new RegExp(`${newName}$`), nameMapping[newName]);\n return factory.updateInterfaceDeclaration(\n node,\n node.decorators,\n node.modifiers,\n factory.createIdentifier(replacedName),\n node.typeParameters,\n node.heritageClauses,\n node.members\n );\n }\n }\n return ts.visitEachChild(node, (child) => visit(child), context);\n };\n return (node) => ts.visitNode(node, visit);\n };\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,yBAAyB,CAACC,WAAmC,EAAwC;EACnH,OAAQC,OAAO,IAAK;IAClB,MAAM;MAAEC;IAAQ,CAAC,GAAGD,OAAO;IAC3B,MAAME,KAAiB,GAAIC,IAAI,IAAK;MAClC,IAAIC,qBAAE,CAACC,sBAAsB,CAACF,IAAI,CAAC,EAAE;QACnC,MAAMG,OAAO,GAAGH,IAAI,CAACI,IAAI,CAACC,IAAI;QAC9B,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACZ,WAAW,CAAC,CAACa,IAAI,CAAEC,GAAG,IAAKP,OAAO,CAACQ,UAAU,CAACD,GAAG,CAAC,IAAIP,OAAO,CAACS,QAAQ,CAACF,GAAG,CAAC,CAAC;QACxG,IAAIJ,OAAO,EAAE;UACX,MAAMO,YAAY,GAAGV,OAAO,CAACQ,UAAU,CAACL,OAAO,CAAC,GAC5CH,OAAO,CAACW,OAAO,CAACR,OAAO,EAAEV,WAAW,CAACU,OAAO,CAAC,CAAC,GAC9CH,OAAO,CAACW,OAAO,CAAC,IAAIC,MAAM,CAAE,GAAET,OAAQ,GAAE,CAAC,EAAEV,WAAW,CAACU,OAAO,CAAC,CAAC;UACpE,OAAOR,OAAO,CAACkB,0BAA0B,CACvChB,IAAI,EACJA,IAAI,CAACiB,UAAU,EACfjB,IAAI,CAACkB,SAAS,EACdpB,OAAO,CAACqB,gBAAgB,CAACN,YAAY,CAAC,EACtCb,IAAI,CAACoB,cAAc,EACnBpB,IAAI,CAACqB,eAAe,EACpBrB,IAAI,CAACsB,OAAO,CACb;QACH;MACF;MACA,OAAOrB,qBAAE,CAACsB,cAAc,CAACvB,IAAI,EAAGwB,KAAK,IAAKzB,KAAK,CAACyB,KAAK,CAAC,EAAE3B,OAAO,CAAC;IAClE,CAAC;IACD,OAAQG,IAAI,IAAKC,qBAAE,CAACwB,SAAS,CAACzB,IAAI,EAAED,KAAK,CAAC;EAC5C,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["transformSourceFile","sourceFilePath","sourceFileContent","transformers","formatter","updates","ext","path","extname","compatibleExts","includes","transformed","Object","entries","forEach","oldStr","newStr","oldStringRegex","RegExp","replace","encoder","EmptyLineEncoder","encode","sourceFile","ts","createSourceFile","ScriptTarget","Latest","ScriptKind","TSX","transformedResult","transform","transformedSourceFile","printer","createPrinter","removeComments","transformedSourceFileStr","printFile","decode","emptyLineComment","emptyLineMarker","regex","formattedSourceFileStr","formatSnippet"],"sources":["transform.ts"],"sourcesContent":["import { Formatter } from '@teambit/formatter';\nimport ts from 'typescript';\nimport * as path from 'path';\nimport { EmptyLineEncoder } from './empty-line-encoder';\n/**\n * Transforms a TypeScript source file using the provided transformer.\n *\n * @param sourceFilePath Path to the TypeScript source file.\n * @param sourceFileContent The content of the source file.\n * @param transformers The transformers to be applied on the source file.\n * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.\n * @returns A promise that resolves to the transformed source file as a string.\n */\nexport async function transformSourceFile(\n sourceFilePath: string,\n sourceFileContent: string,\n transformers: ts.TransformerFactory<ts.SourceFile>[],\n formatter?: Formatter,\n updates?: Record<string, string>\n): Promise<string> {\n const ext = path.extname(sourceFilePath);\n const compatibleExts = ['.ts', '.tsx', '.js', '.jsx'];\n if (!compatibleExts.includes(ext)) {\n if (!updates) return sourceFileContent;\n let transformed = sourceFileContent;\n Object.entries(updates).forEach(([oldStr, newStr]) => {\n const oldStringRegex = new RegExp(oldStr, 'g');\n transformed = transformed.replace(oldStringRegex, newStr);\n });\n return transformed;\n }\n\n const encoder = new EmptyLineEncoder();\n sourceFileContent = encoder.encode(sourceFileContent);\n\n const sourceFile = ts.createSourceFile(\n sourceFilePath,\n sourceFileContent,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n );\n\n const transformedResult: ts.TransformationResult<ts.SourceFile> = ts.transform<ts.SourceFile>(\n sourceFile,\n transformers\n );\n const transformedSourceFile: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile;\n\n // const _identifierTransformer = identifierTransformer(updates || {});\n\n // const transformedResultWithIdentifiers: ts.TransformationResult<ts.SourceFile> =\n // ts.transform<ts.SourceFile>(transformedSourceFile, []);\n // const transformedSourceFileWithIdentifiers: ts.SourceFile\n // = transformedResultWithIdentifiers.transformed[0] as ts.SourceFile;\n\n const printer: ts.Printer = ts.createPrinter({\n removeComments: false,\n });\n\n let transformedSourceFileStr = printer.printFile(transformedSourceFile);\n transformedSourceFileStr = encoder.decode(transformedSourceFileStr);\n // Remove trailing empty line markers\n const emptyLineComment = `\\\\s*\\\\/\\\\*${encoder.emptyLineMarker}\\\\*\\\\/\\\\s*$`;\n const regex = new RegExp(emptyLineComment, 'g');\n transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');\n\n try {\n const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);\n return formattedSourceFileStr || transformedSourceFileStr;\n } catch {\n // We can ignore if the formatter fails\n // TODO: log the error\n // ignore\n }\n return transformedSourceFileStr;\n}\n\n// function createMarkingTransformer<T extends ts.Node>(innerTransformer: ts.TransformerFactory<T>)\n// : ts.TransformerFactory<T> {\n// return context => {\n// const innerTransform = innerTransformer(context);\n\n// return node => {\n// const result = innerTransform(node);\n\n// // Add a custom property to the node to mark it as transformed\n// // Note: this relies on TypeScript's internal behavior and may not be stable across versions\n// (result as any).__transformed = true;\n\n// return result;\n// };\n// };\n// }\n\n// const defaultTransformer: ts.TransformerFactory<ts.SourceFile> = () => {\n// const visit: ts.Visitor = node => {\n// // If the node has been marked as transformed by a specific transformer, don't transform it\n// if ((node as any).__transformed) {\n// return node;\n// }\n\n// // Your transformation logic goes here...\n// };\n\n// return node => ts.visitNode(node, visit);\n// };\n"],"mappings":";;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,mBAAmB,CACvCC,cAAsB,EACtBC,iBAAyB,EACzBC,YAAoD,EACpDC,SAAqB,EACrBC,OAAgC,EACf;EACjB,MAAMC,GAAG,GAAGC,IAAI,GAACC,OAAO,CAACP,cAAc,CAAC;EACxC,MAAMQ,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;EACrD,IAAI,CAACA,cAAc,CAACC,QAAQ,CAACJ,GAAG,CAAC,EAAE;IACjC,IAAI,CAACD,OAAO,EAAE,OAAOH,iBAAiB;IACtC,IAAIS,WAAW,GAAGT,iBAAiB;IACnCU,MAAM,CAACC,OAAO,CAACR,OAAO,CAAC,CAACS,OAAO,CAAC,CAAC,CAACC,MAAM,EAAEC,MAAM,CAAC,KAAK;MACpD,MAAMC,cAAc,GAAG,IAAIC,MAAM,CAACH,MAAM,EAAE,GAAG,CAAC;MAC9CJ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wB;AACjC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["typeAliasNamesTransformer","nameMapping","context","factory","visit","node","ts","isTypeAliasDeclaration","oldName","name","text","newName","Object","keys","find","key","startsWith","endsWith","replacedName","replace","RegExp","updateTypeAliasDeclaration","decorators","modifiers","createIdentifier","typeParameters","type","visitEachChild","child","visitNode"],"sources":["typeAlias.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport function typeAliasNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile> {\n return (context) => {\n const { factory } = context;\n const visit: ts.Visitor = (node) => {\n if (ts.isTypeAliasDeclaration(node)) {\n const oldName = node.name.text;\n const newName = Object.keys(nameMapping).find((key) => oldName.startsWith(key) || oldName.endsWith(key));\n if (newName) {\n const replacedName = oldName.startsWith(newName)\n ? oldName.replace(newName, nameMapping[newName])\n : oldName.replace(new RegExp(`${newName}$`), nameMapping[newName]);\n return factory.updateTypeAliasDeclaration(\n node,\n node.decorators,\n node.modifiers,\n factory.createIdentifier(replacedName),\n node.typeParameters,\n node.type\n );\n }\n }\n return ts.visitEachChild(node, (child) => visit(child), context);\n };\n return (node) => ts.visitNode(node, visit);\n };\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,yBAAyB,CAACC,WAAmC,EAAwC;EACnH,OAAQC,OAAO,IAAK;IAClB,MAAM;MAAEC;IAAQ,CAAC,GAAGD,OAAO;IAC3B,MAAME,KAAiB,GAAIC,IAAI,IAAK;MAClC,IAAIC,qBAAE,CAACC,sBAAsB,CAACF,IAAI,CAAC,EAAE;QACnC,MAAMG,OAAO,GAAGH,IAAI,CAACI,IAAI,CAACC,IAAI;QAC9B,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACZ,WAAW,CAAC,CAACa,IAAI,CAAEC,GAAG,IAAKP,OAAO,CAACQ,UAAU,CAACD,GAAG,CAAC,IAAIP,OAAO,CAACS,QAAQ,CAACF,GAAG,CAAC,CAAC;QACxG,IAAIJ,OAAO,EAAE;UACX,MAAMO,YAAY,GAAGV,OAAO,CAACQ,UAAU,CAACL,OAAO,CAAC,GAC5CH,OAAO,CAACW,OAAO,CAACR,OAAO,EAAEV,WAAW,CAACU,OAAO,CAAC,CAAC,GAC9CH,OAAO,CAACW,OAAO,CAAC,IAAIC,MAAM,CAAE,GAAET,OAAQ,GAAE,CAAC,EAAEV,WAAW,CAACU,OAAO,CAAC,CAAC;UACpE,OAAOR,OAAO,CAACkB,0BAA0B,CACvChB,IAAI,EACJA,IAAI,CAACiB,UAAU,EACfjB,IAAI,CAACkB,SAAS,EACdpB,OAAO,CAACqB,gBAAgB,CAACN,YAAY,CAAC,EACtCb,IAAI,CAACoB,cAAc,EACnBpB,IAAI,CAACqB,IAAI,CACV;QACH;MACF;MACA,OAAOpB,qBAAE,CAACqB,cAAc,CAACtB,IAAI,EAAGuB,KAAK,IAAKxB,KAAK,CAACwB,KAAK,CAAC,EAAE1B,OAAO,CAAC;IAClE,CAAC;IACD,OAAQG,IAAI,IAAKC,qBAAE,CAACuB,SAAS,CAACxB,IAAI,EAAED,KAAK,CAAC;EAC5C,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["variableNamesTransformer","nameMapping","context","factory","visit","node","ts","isVariableDeclaration","name","kind","SyntaxKind","Identifier","oldName","text","newName","Object","keys","find","key","startsWith","endsWith","replacedName","replace","RegExp","updateVariableDeclaration","createIdentifier","exclamationToken","type","initializer","visitEachChild","child","visitNode"],"sources":["variable.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport function variableNamesTransformer(nameMapping: Record<string, string>): ts.TransformerFactory<ts.SourceFile> {\n return (context) => {\n const { factory } = context;\n const visit: ts.Visitor = (node) => {\n if (ts.isVariableDeclaration(node) && node.name.kind === ts.SyntaxKind.Identifier) {\n const oldName = node.name.text;\n const newName = Object.keys(nameMapping).find((key) => oldName.startsWith(key) || oldName.endsWith(key));\n if (newName) {\n const replacedName = oldName.startsWith(newName)\n ? oldName.replace(newName, nameMapping[newName])\n : oldName.replace(new RegExp(`${newName}$`), nameMapping[newName]);\n\n return factory.updateVariableDeclaration(\n node,\n factory.createIdentifier(replacedName),\n node.exclamationToken,\n node.type,\n node.initializer\n );\n }\n }\n return ts.visitEachChild(node, (child) => visit(child), context);\n };\n return (node) => ts.visitNode(node, visit);\n };\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,wBAAwB,CAACC,WAAmC,EAAwC;EAClH,OAAQC,OAAO,IAAK;IAClB,MAAM;MAAEC;IAAQ,CAAC,GAAGD,OAAO;IAC3B,MAAME,KAAiB,GAAIC,IAAI,IAAK;MAClC,IAAIC,qBAAE,CAACC,qBAAqB,CAACF,IAAI,CAAC,IAAIA,IAAI,CAACG,IAAI,CAACC,IAAI,KAAKH,qBAAE,CAACI,UAAU,CAACC,UAAU,EAAE;QACjF,MAAMC,OAAO,GAAGP,IAAI,CAACG,IAAI,CAACK,IAAI;QAC9B,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACf,WAAW,CAAC,CAACgB,IAAI,CAAEC,GAAG,IAAKN,OAAO,CAACO,UAAU,CAACD,GAAG,CAAC,IAAIN,OAAO,CAACQ,QAAQ,CAACF,GAAG,CAAC,CAAC;QACxG,IAAIJ,OAAO,EAAE;UACX,MAAMO,YAAY,GAAGT,OAAO,CAACO,UAAU,CAACL,OAAO,CAAC,GAC5CF,OAAO,CAACU,OAAO,CAACR,OAAO,EAAEb,WAAW,CAACa,OAAO,CAAC,CAAC,GAC9CF,OAAO,CAACU,OAAO,CAAC,IAAIC,MAAM,CAAE,GAAET,OAAQ,GAAE,CAAC,EAAEb,WAAW,CAACa,OAAO,CAAC,CAAC;UAEpE,OAAOX,OAAO,CAACqB,yBAAyB,CACtCnB,IAAI,EACJF,OAAO,CAACsB,gBAAgB,CAACJ,YAAY,CAAC,EACtChB,IAAI,CAACqB,gBAAgB,EACrBrB,IAAI,CAACsB,IAAI,EACTtB,IAAI,CAACuB,WAAW,CACjB;QACH;MACF;MACA,OAAOtB,qBAAE,CAACuB,cAAc,CAACxB,IAAI,EAAGyB,KAAK,IAAK1B,KAAK,CAAC0B,KAAK,CAAC,EAAE5B,OAAO,CAAC;IAClE,CAAC;IACD,OAAQG,IAAI,IAAKC,qBAAE,CAACyB,SAAS,CAAC1B,IAAI,EAAED,KAAK,CAAC;EAC5C,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["normalizeFormatting","code","sourceFile","ts","createSourceFile","ScriptTarget","Latest","printer","createPrinter","newLine","NewLineKind","LineFeed","removeComments","printFile","describe","createTransformerTest","sourceCode","nameMapping","transformer","expectedCode","it","name","result","transformSourceFile","normalizedResult","normalizedExpectedCode","expect","toBe","testCases","classNamesTransformer","TestClass","functionNamesTransformer","testFunction","importTransformer","interfaceNamesTransformer","TestInterface","typeAliasNamesTransformer","TestType","variableNamesTransformer","testVariable","normalizedSourceCode"],"sources":["transform-source-file.spec.ts"],"sourcesContent":["import ts from 'typescript';\nimport {\n transformSourceFile,\n classNamesTransformer,\n functionNamesTransformer,\n importTransformer,\n interfaceNamesTransformer,\n typeAliasNamesTransformer,\n variableNamesTransformer,\n} from './sourceFileTransformers';\n\nfunction normalizeFormatting(code: string): string {\n const sourceFile = ts.createSourceFile('temp.ts', code, ts.ScriptTarget.Latest, true);\n const printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n });\n return printer.printFile(sourceFile);\n}\n\ndescribe('transformSourceFile', () => {\n const createTransformerTest = (\n sourceCode: string,\n nameMapping: any,\n transformer: (nameMapping: any) => ts.TransformerFactory<ts.SourceFile>,\n expectedCode: string\n ) => {\n it(`should correctly transform source code with ${transformer.name}`, async () => {\n const result = await transformSourceFile('test.ts', sourceCode, [transformer(nameMapping)]);\n const normalizedResult = normalizeFormatting(result);\n const normalizedExpectedCode = normalizeFormatting(expectedCode);\n\n expect(normalizedResult).toBe(normalizedExpectedCode);\n });\n };\n\n const testCases = [\n {\n transformer: classNamesTransformer,\n sourceCode: 'class TestClass {}',\n nameMapping: { TestClass: 'NewClassName' },\n expectedCode: 'class NewClassName {}',\n },\n {\n transformer: functionNamesTransformer,\n sourceCode: 'function testFunction() {}',\n nameMapping: { testFunction: 'newFunctionName' },\n expectedCode: 'function newFunctionName() {}',\n },\n {\n transformer: importTransformer,\n sourceCode: 'import { Test } from \"./test\";',\n nameMapping: { './test': './newTest' },\n expectedCode: 'import { Test } from \"./newTest\";',\n },\n {\n transformer: interfaceNamesTransformer,\n sourceCode: 'interface TestInterface {}',\n nameMapping: { TestInterface: 'NewInterfaceName' },\n expectedCode: 'interface NewInterfaceName {}',\n },\n {\n transformer: typeAliasNamesTransformer,\n sourceCode: 'type TestType = string;',\n nameMapping: { TestType: 'NewTypeName' },\n expectedCode: 'type NewTypeName = string;',\n },\n {\n transformer: variableNamesTransformer,\n sourceCode: 'let testVariable = \"test\";',\n nameMapping: { testVariable: 'newVariableName' },\n expectedCode: 'let newVariableName = \"test\";',\n },\n ];\n\n for (const { transformer, sourceCode, nameMapping, expectedCode } of testCases) {\n createTransformerTest(sourceCode, nameMapping, transformer, expectedCode);\n }\n\n it('should return original source code if no transformations are applied', async () => {\n const sourceCode = 'class TestClass {} function testFunction() {}';\n const result = await transformSourceFile('test.ts', sourceCode, []);\n const normalizedResult = normalizeFormatting(result);\n const normalizedSourceCode = normalizeFormatting(sourceCode);\n expect(normalizedResult).toBe(normalizedSourceCode);\n });\n\n it('should handle multiple transformers', async () => {\n const sourceCode = 'class TestClass {} function testFunction() {}';\n const expectedCode = 'class NewClassName {} function newFunctionName() {}';\n const result = await transformSourceFile('test.ts', sourceCode, [\n classNamesTransformer({ TestClass: 'NewClassName' }),\n functionNamesTransformer({ testFunction: 'newFunctionName' }),\n ]);\n const normalizedResult = normalizeFormatting(result);\n const normalizedExpectedCode = normalizeFormatting(expectedCode);\n expect(normalizedResult).toBe(normalizedExpectedCode);\n });\n});\n"],"mappings":";;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA,SAASA,mBAAmB,CAACC,IAAY,EAAU;EACjD,MAAMC,UAAU,GAAGC,qBAAE,CAACC,gBAAgB,CAAC,SAAS,EAAEH,IAAI,EAAEE,qBAAE,CAACE,YAAY,CAACC,MAAM,EAAE,IAAI,CAAC;EACrF,MAAMC,OAAO,GAAGJ,qBAAE,CAACK,aAAa,CAAC;IAC/BC,OAAO,EAAEN,qBAAE,CAACO,WAAW,CAACC,QAAQ;IAChCC,cAAc,EAAE;EAClB,CAAC,CAAC;EACF,OAAOL,OAAO,CAACM,SAAS,CAACX,UAAU,CAAC;AACtC;AAEAY,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpC,MAAMC,qBAAqB,GAAG,CAC5BC,UAAkB,EAClBC,WAAgB,EAChBC,WAAuE,EACvEC,YAAoB,KACjB;IACHC,EAAE,CAAE,+CAA8CF,WAAW,CAACG,IAAK,EAAC,EAAE,YAAY;MAChF,MAAMC,MAAM,GAAG,MAAM,IAAAC,6CAAmB,EAAC,SAAS,EAAEP,UAAU,EAAE,CAACE,WAAW,CAACD,WAAW,CAAC,CAAC,CAAC;MAC3F,MAAMO,gBAAgB,GAAGxB,mBAAmB,CAACsB,MAAM,CAAC;MACpD,MAAMG,sBAAsB,GAAGzB,mBAAmB,CAACmB,YAAY,CAAC;MAEhEO,MAAM,CAACF,gBAAgB,CAAC,CAACG,IAAI,CAACF,sBAAsB,CAAC;IACv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S,EAAEP,UAAU,EAAE,EAAE,CAAC;IACnE,MAAMQ,gBAAgB,GAAGxB,mBAAmB,CAACsB,MAAM,CAAC;IACpD,MAAMkB,oBAAoB,GAAGxC,mBAAmB,CAACgB,UAAU,CAAC;IAC5DU,MAAM,CAACF,gBAAgB,CAAC,CAACG,IAAI,CAACa,oBAAoB,CAAC;EACrD,CAAC,CAAC;EAEFpB,EAAE,CAAC,qCAAqC,EAAE,YAAY;IACpD,MAAMJ,UAAU,GAAG,+CAA+C;IAClE,MAAMG,YAAY,GAAG,qDAAqD;IAC1E,MAAMG,MAAM,GAAG,MAAM,IAAAC,6CAAmB,EAAC,SAAS,EAAEP,UAAU,EAAE,CAC9D,IAAAa,+CAAqB,EAAC;MAAEC,SAAS,EAAE;IAAe,CAAC,CAAC,EACpD,IAAAC,kDAAwB,EAAC;MAAEC,YAAY,EAAE;IAAkB,CAAC,CAAC,CAC9D,CAAC;IACF,MAAMR,gBAAgB,GAAGxB,mBAAmB,CAACsB,MAAM,CAAC;IACpD,MAAMG,sBAAsB,GAAGzB,mBAAmB,CAACmB,YAAY,CAAC;IAChEO,MAAM,CAACF,gBAAgB,CAAC,CAACG,IAAI,CAACF,sBAAsB,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ArrayTypeTransformer","predicate","node","kind","ts","SyntaxKind","ArrayType","getIdentifiers","transform","context","type","computeSchema","elementType","location","getLocation","TypeArraySchema"],"sources":["array-type.ts"],"sourcesContent":["import ts, { ArrayTypeNode, Node } from 'typescript';\nimport { TypeArraySchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ArrayTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ArrayType;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await context.computeSchema(node.elementType);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,oBAAoB,CAA8B;EAC7DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,SAAS;EAC9C;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAAmB,EAAEO,OAA+B,EAAE;IACpE,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,aAAa,CAACT,IAAI,CAACU,WAAW,CAAC;IAC1D,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,WAAW,CAACZ,IAAI,CAAC;IAC1C,OAAO,KAAIa,oCAAe,EAACF,QAAQ,EAAEH,IAAI,CAAC;EAC5C;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","Identifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new Identifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const doc = await context.jsDocToDocSchema(node);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,CAA8B;EAClEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,cAAc;EACnD;EAEA,MAAMC,cAAc,CAACL,IAAoB,EAAE;IACzC,OAAO,CAAC,KAAIM,wBAAU,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EAC7E;EAEA,MAAMC,SAAS,CAACX,IAAoB,EAAEY,OAA+B,EAAE;IAAA;IACrE,MAAML,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;IAChC,MAAMK,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAY,CAACd,IAAI,CAACO,IAAI,CAAC;IAClD,MAAMQ,UAAU,GAAG,CAAAF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAClD,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACN,IAAI,CAAC;IAC5C,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAW,CAACrB,IAAI,EAAEkB,OAAO,CAAC;IACrD,MAAMI,GAAG,GAAG,MAAMV,OAAO,CAACW,gBAAgB,CAACvB,IAAI,CAAC;IAChD,OAAO,KAAIwB,uCAAkB,EAACZ,OAAO,CAACa,WAAW,CAACzB,IAAI,CAAC,EAAEO,IAAI,EAAEQ,UAAU,EAAEK,IAAI,EAAE,KAAK,EAAEE,GAAG,CAAC;EAC9F;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ClassDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","Identifier","getSourceFile","fileName","getExpressionWithTypeArgs","context","token","heritageClauses","pMapSeries","filter","heritageClause","flatMap","h","types","map","type","expressionWithTypeArgs","typeArguments","expression","typeArgsNodes","t","computeSchema","location","getLocation","expressionNode","visitDefinition","UnresolvedSchema","ExpressionWithTypeArgumentsSchema","transform","className","extendsExpressionsWithTypeArgs","ExtendsKeyword","implementsExpressionsWithTypeArgs","ImplementsKeyword","typeParameters","typeParam","signature","getQuickInfoDisplayString","undefined","members","member","isPrivate","modifiers","some","modifier","PrivateKeyword","doc","jsDocToDocSchema","Error","ClassSchema","compact"],"sources":["class-declaration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport {\n ClassSchema,\n UnresolvedSchema,\n ExpressionWithTypeArgumentsSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ClassDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ClassDeclaration;\n }\n\n // @todo: in case of `export default class` the class has no name.\n private getName(node: ClassDeclaration) {\n return node.name?.getText() || 'default';\n }\n\n async getIdentifiers(node: ClassDeclaration) {\n return [new Identifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n private async getExpressionWithTypeArgs(\n node: ClassDeclaration,\n context: SchemaExtractorContext,\n token: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword\n ) {\n if (!node.heritageClauses) return [];\n\n return pMapSeries(\n node.heritageClauses\n .filter((heritageClause: ts.HeritageClause) => heritageClause.token === token)\n .flatMap((h: ts.HeritageClause) => {\n const { types } = h;\n const name = h.getText();\n return types.map((type) => ({ ...type, name }));\n }),\n async (expressionWithTypeArgs: ts.ExpressionWithTypeArguments & { name: string }) => {\n const { typeArguments, expression, name } = expressionWithTypeArgs;\n const typeArgsNodes = typeArguments ? await pMapSeries(typeArguments, (t) => context.computeSchema(t)) : [];\n const location = context.getLocation(expression);\n const expressionNode =\n (await context.visitDefinition(expression)) || new UnresolvedSchema(location, expression.getText());\n return new ExpressionWithTypeArgumentsSchema(typeArgsNodes, expressionNode, name, location);\n }\n );\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\n const extendsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ExtendsKeyword\n );\n\n const implementsExpressionsWithTypeArgs = await this.getExpressionWithTypeArgs(\n node,\n context,\n ts.SyntaxKind.ImplementsKeyword\n );\n\n const typeParameters = node.typeParameters?.map((typeParam) => {\n return typeParam.name.getText();\n });\n const signature = node.name ? await context.getQuickInfoDisplayString(node.name) : undefined;\n const members = await pMapSeries(node.members, async (member) => {\n const isPrivate = member.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword);\n if (isPrivate) {\n return null;\n }\n return context.computeSchema(member);\n });\n const doc = await context.jsDocToDocSchema(node);\n\n if (!signature) {\n throw Error(`Missing signature for class ${className} declaration`);\n }\n\n return new ClassSchema(\n className,\n compact(members),\n context.getLocation(node),\n signature,\n doc,\n typeParameters,\n extendsExpressionsWithTypeArgs,\n implementsExpressionsWithTypeArgs\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2C;AAAA;AAEpC,MAAMA,2BAA2B,CAA8B;EACpEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,gBAAgB;EACrD;;EAEA;EACQC,OAAO,CAACL,IAAsB,EAAE;IAAA;IACtC,OAAO,eAAAA,IAAI,CAACM,IAAI,+CAAT,WAAWC,OAAO,EAAE,KAAI,SAAS;EAC1C;EAEA,MAAMC,cAAc,CAACR,IAAsB,EAAE;IAC3C,OAAO,CAAC,KAAIS,wBAAU,EAAC,IAAI,CAACJ,OAAO,CAACL,IAAI,CAAC,EAAEA,IAAI,CAACU,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EAC5E;EAEA,MAAcC,yBAAyB,CACrCZ,IAAsB,EACtBa,OAA+B,EAC/BC,KAAqE,EACrE;IACA,IAAI,CAACd,IAAI,CAACe,eAAe,EAAE,OAAO,EAAE;IAEpC,OAAO,IAAAC,qBAAU,EACfhB,IAAI,CAACe,eAAe,CACjBE,MAAM,CAAEC,cAAiC,IAAKA,cAAc,CAACJ,KAAK,KAAKA,KAAK,CAAC,CAC7EK,OAAO,CAAEC,CAAoB,IAAK;MACjC,MAAM;QAAEC;MAAM,CAAC,GAAGD,CAAC;MACnB,MAAMd,IAAI,GAAGc,CAAC,CAACb,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jC,CAAC,CAAC;IACF,MAAMqC,SAAS,GAAG5C,IAAI,CAACM,IAAI,GAAG,MAAMO,OAAO,CAACgC,yBAAyB,CAAC7C,IAAI,CAACM,IAAI,CAAC,GAAGwC,SAAS;IAC5F,MAAMC,OAAO,GAAG,MAAM,IAAA/B,qBAAU,EAAChB,IAAI,CAAC+C,OAAO,EAAE,MAAOC,MAAM,IAAK;MAAA;MAC/D,MAAMC,SAAS,wBAAGD,MAAM,CAACE,SAAS,sDAAhB,kBAAkBC,IAAI,CAAEC,QAAQ,IAAKA,QAAQ,CAACnD,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACkD,cAAc,CAAC;MACtG,IAAIJ,SAAS,EAAE;QACb,OAAO,IAAI;MACb;MACA,OAAOpC,OAAO,CAACgB,aAAa,CAACmB,MAAM,CAAC;IACtC,CAAC,CAAC;IACF,MAAMM,GAAG,GAAG,MAAMzC,OAAO,CAAC0C,gBAAgB,CAACvD,IAAI,CAAC;IAEhD,IAAI,CAAC4C,SAAS,EAAE;MACd,MAAMY,KAAK,CAAE,+BAA8BnB,SAAU,cAAa,CAAC;IACrE;IAEA,OAAO,KAAIoB,gCAAW,EACpBpB,SAAS,EACT,IAAAqB,iBAAO,EAACX,OAAO,CAAC,EAChBlC,OAAO,CAACkB,WAAW,CAAC/B,IAAI,CAAC,EACzB4C,SAAS,EACTU,GAAG,EACHZ,cAAc,EACdJ,8BAA8B,EAC9BE,iCAAiC,CAClC;EACH;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ConditionalTypeTransformer","predicate","node","kind","SyntaxKind","ConditionalType","getIdentifiers","transform","context","checkType","computeSchema","extendsType","trueType","falseType","ConditionalTypeSchema","getLocation"],"sources":["conditional-type.ts"],"sourcesContent":["import { Node, SyntaxKind, ConditionalTypeNode } from 'typescript';\nimport { ConditionalTypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ConditionalTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ConditionalType;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ConditionalTypeNode, context: SchemaExtractorContext) {\n const checkType = await context.computeSchema(node.checkType);\n const extendsType = await context.computeSchema(node.extendsType);\n const trueType = await context.computeSchema(node.trueType);\n const falseType = await context.computeSchema(node.falseType);\n return new ConditionalTypeSchema(context.getLocation(node), checkType, extendsType, trueType, falseType);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,0BAA0B,CAA8B;EACnEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,eAAe;EACjD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACL,IAAyB,EAAEM,OAA+B,EAAE;IAC1E,MAAMC,SAAS,GAAG,MAAMD,OAAO,CAACE,aAAa,CAACR,IAAI,CAACO,SAAS,CAAC;IAC7D,MAAME,WAAW,GAAG,MAAMH,OAAO,CAACE,aAAa,CAACR,IAAI,CAACS,WAAW,CAAC;IACjE,MAAMC,QAAQ,GAAG,MAAMJ,OAAO,CAACE,aAAa,CAACR,IAAI,CAACU,QAAQ,CAAC;IAC3D,MAAMC,SAAS,GAAG,MAAML,OAAO,CAACE,aAAa,CAACR,IAAI,CAACW,SAAS,CAAC;IAC7D,OAAO,KAAIC,0CAAqB,EAACN,OAAO,CAACO,WAAW,CAACb,IAAI,CAAC,EAAEO,SAAS,EAAEE,WAAW,EAAEC,QAAQ,EAAEC,SAAS,CAAC;EAC1G;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ConstructorTransformer","predicate","node","kind","ts","SyntaxKind","Constructor","getIdentifiers","transform","context","args","pMapSeries","parameters","param","computeSchema","info","getQuickInfo","displaySig","body","displayString","returns","ThisTypeSchema","getLocation","parent","modifiers","map","modifier","getText","doc","jsDocToDocSchema","ConstructorSchema"],"sources":["constructor.ts"],"sourcesContent":["import ts, { Node, ConstructorDeclaration } from 'typescript';\nimport {\n ConstructorSchema,\n ParameterSchema,\n ThisTypeSchema,\n Modifier,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ConstructorTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ConstructorDeclaration, context: SchemaExtractorContext) {\n const args = await pMapSeries(node.parameters, async (param) => context.computeSchema(param));\n const info = await context.getQuickInfo(node);\n const displaySig = info?.body?.displayString || '';\n\n const returns = new ThisTypeSchema(context.getLocation(node.parent));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const doc = await context.jsDocToDocSchema(node);\n\n return new ConstructorSchema(\n context.getLocation(node),\n args as ParameterSchema[],\n returns,\n displaySig,\n modifiers as Modifier[],\n doc\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,sBAAsB,CAA8B;EAC/DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,WAAW;EAChD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAA4B,EAAEO,OAA+B,EAAE;IAAA;IAC7E,MAAMC,IAAI,GAAG,MAAM,IAAAC,qBAAU,EAACT,IAAI,CAACU,UAAU,EAAE,MAAOC,KAAK,IAAKJ,OAAO,CAACK,aAAa,CAACD,KAAK,CAAC,CAAC;IAC7F,MAAME,IAAI,GAAG,MAAMN,OAAO,CAACO,YAAY,CAACd,IAAI,CAAC;IAC7C,MAAMe,UAAU,GAAG,CAAAF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAElD,MAAMC,OAAO,GAAG,KAAIC,mCAAc,EAACZ,OAAO,CAACa,WAAW,CAACpB,IAAI,CAACqB,MAAM,CAAC,CAAC;IACpE,MAAMC,SAAS,GAAG,oBAAAtB,IAAI,CAACsB,SAAS,oDAAd,gBAAgBC,GAAG,CAAEC,QAAQ,IAAKA,QAAQ,CAACC,OAAO,EAAE,CAAC,KAAI,EAAE;IAC7E,MAAMC,GAAG,GAAG,MAAMnB,OAAO,CAACoB,gBAAgB,CAAC3B,IAAI,CAAC;IAEhD,OAAO,KAAI4B,sCAAiB,EAC1BrB,OAAO,CAACa,WAAW,CAACpB,IAAI,CAAC,EACzBQ,IAAI,EACJU,OAAO,EACPH,UAAU,EACVO,SAAS,EACTI,GAAG,CACJ;EACH;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","Identifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","pMapSeries","member","memberName","memberSignature","getQuickInfoDisplayString","memberDoc","jsDocToDocSchema","memberLocation","getLocation","memberValue","initializer","EnumMemberSchema","signature","doc","EnumSchema"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumMemberSchema, EnumSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<Identifier[]> {\n return [new Identifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const name = enumDec.name.getText();\n const members = await pMapSeries(enumDec.members, async (member) => {\n const memberName = member.name.getText();\n const memberSignature = await context.getQuickInfoDisplayString(member);\n const memberDoc = await context.jsDocToDocSchema(member);\n const memberLocation = await context.getLocation(member);\n const memberValue = member.initializer?.getText();\n return new EnumMemberSchema(memberLocation, memberName, memberSignature, memberValue, memberDoc);\n });\n const signature = await context.getQuickInfoDisplayString(enumDec.name);\n const doc = await context.jsDocToDocSchema(enumDec);\n return new EnumSchema(context.getLocation(enumDec), name, members, signature, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,0BAA0B,CAA8B;EACnEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,eAAe;EACpD;EAEA,MAAMC,cAAc,CAACL,IAAqB,EAAyB;IACjE,OAAO,CAAC,KAAIM,wBAAU,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EAC7E;EAEA,MAAMC,SAAS,CAACC,OAAwB,EAAEC,OAA+B,EAAE;IACzE,MAAMN,IAAI,GAAGK,OAAO,CAACL,IAAI,CAACC,OAAO,EAAE;IACnC,MAAMM,OAAO,GAAG,MAAM,IAAAC,qBAAU,EAACH,OAAO,CAACE,OAAO,EAAE,MAAOE,MAAM,IAAK;MAAA;MAClE,MAAMC,UAAU,GAAGD,MAAM,CAACT,IAAI,CAACC,OAAO,EAAE;MACxC,MAAMU,eAAe,GAAG,MAAML,OAAO,CAACM,yBAAyB,CAACH,MAAM,CAAC;MACvE,MAAMI,SAAS,GAAG,MAAMP,OAAO,CAACQ,gBAAgB,CAACL,MAAM,CAAC;MACxD,MAAMM,cAAc,GAAG,MAAMT,OAAO,CAACU,WAAW,CAACP,MAAM,CAAC;MACxD,MAAMQ,WAAW,0BAAGR,MAAM,CAACS,WAAW,wDAAlB,oBAAoBjB,OAAO,EAAE;MACjD,OAAO,KAAIkB,qCAAgB,EAACJ,cAAc,EAAEL,UAAU,EAAEC,eAAe,EAAEM,WAAW,EAAEJ,SAAS,CAAC;IAClG,CAAC,CAAC;IACF,MAAMO,SAAS,GAAG,MAAMd,OAAO,CAACM,yBAAyB,CAACP,OAAO,CAACL,IAAI,CAAC;IACvE,MAAMqB,GAAG,GAAG,MAAMf,OAAO,CAACQ,gBAAgB,CAACT,OAAO,CAAC;IACnD,OAAO,KAAIiB,+BAAU,EAAChB,OAAO,CAACU,WAAW,CAACX,OAAO,CAAC,EAAEL,IAAI,EAAEO,OAAO,EAAEa,SAAS,EAAEC,GAAG,CAAC;EACpF;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ExportAssignmentTransformer","predicate","node","kind","SyntaxKind","ExportAssignment","getIdentifiers","exportDec","specifier","expression","ExportIdentifier","getText","getSourceFile","fileName","transform","context","computeSchema"],"sources":["export-assignment.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { Node, SyntaxKind, ExportAssignment as ExportAssignmentNode } from 'typescript';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\n\n/**\n * This is either an export = or an export default declaration.\n * Unless isExportEquals is set, this node was parsed as an export default\n */\nexport class ExportAssignmentTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportAssignment;\n }\n\n async getIdentifiers(exportDec: ExportAssignmentNode) {\n const specifier = exportDec.expression;\n return [new ExportIdentifier(specifier.getText(), exportDec.getSourceFile().fileName)];\n }\n\n async transform(exportDec: ExportAssignmentNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const specifier = exportDec.expression;\n return context.computeSchema(specifier);\n }\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACO,MAAMA,2BAA2B,CAA8B;EACpEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,gBAAgB;EAClD;EAEA,MAAMC,cAAc,CAACC,SAA+B,EAAE;IACpD,MAAMC,SAAS,GAAGD,SAAS,CAACE,UAAU;IACtC,OAAO,CAAC,KAAIC,oCAAgB,EAACF,SAAS,CAACG,OAAO,EAAE,EAAEJ,SAAS,CAACK,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACxF;EAEA,MAAMC,SAAS,CAACP,SAA+B,EAAEQ,OAA+B,EAAuB;IACrG,MAAMP,SAAS,GAAGD,SAAS,CAACE,UAAU;IACtC,OAAOM,OAAO,CAACC,aAAa,CAACR,SAAS,CAAC;EACzC;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_semanticsEntities","data","require","_typescript","_interopRequireWildcard","_exportIdentifier","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ExportDeclarationTransformer","predicate","node","kind","SyntaxKind","ExportDeclaration","getIdentifiers","exportDec","context","_exportDec$moduleSpec","_exportDec$exportClau","_exportDec$exportClau2","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","exportClause","ts","NamedExports","elements","map","elm","_elm$propertyName","alias","propertyName","name","undefined","id","fileName","getSourceFile","ExportIdentifier","NamespaceExport","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","UnImplementedSchema","getLocation","computeSchema","schemas","namedExport","ModuleSchema","namespaceExport","exports","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","resolveType","parent","getLocationAsString","ExportSpecifier","e","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n ModuleSchema,\n UnresolvedSchema,\n UnImplementedSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n // e.g. `export { button1, button2 } as Composition from './button';\n const rawSourceFilePath = exportDec.moduleSpecifier?.getText();\n\n // strip off quotes ''\n const sourceFilePath = rawSourceFilePath && rawSourceFilePath.substring(1, rawSourceFilePath?.length - 1);\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n return exportDec.exportClause.elements.map((elm) => {\n const alias = (elm.propertyName && elm.name.getText()) || undefined;\n const id = elm.propertyName?.getText() || elm.name.getText();\n const fileName = elm.getSourceFile().fileName;\n\n return new ExportIdentifier(id, fileName, alias, sourceFilePath);\n });\n }\n\n // e.g. `export * as Composition from './button';\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [\n new ExportIdentifier(\n exportDec.exportClause.name.getText(),\n exportDec.getSourceFile().fileName,\n undefined,\n sourceFilePath\n ),\n ];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n // export * from 'webpack', export-all from a package\n if (!sourceFile) {\n return new UnImplementedSchema(\n context.getLocation(exportDec),\n exportDec.getText(),\n SyntaxKind[SyntaxKind.ExportDeclaration]\n );\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new ModuleSchema(context.getLocation(exportDec), schemas, []);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n try {\n const definitionInfo = await context.definitionInfo(element);\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return await context.resolveType(element, element.name.getText(), false);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return await context.computeSchema(definitionNode.parent);\n } catch (e) {\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof ModuleSchema)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":";;;;;;;;AAAA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CAACS,IAAI,CAACb,OAAO,CAAC,CAAC;EAC7C,MAAMqD,QAAQ,GAAG,MAAM3D,OAAO,CAAC4D,iBAAiB,CAAClD,YAAY,CAACS,IAAI,CAAC;EACnE,IAAI,CAACwC,QAAQ,EAAE;IACb,MAAM,IAAI9B,KAAK,CAAE,qCAAoC6B,SAAU,GAAE,CAAC;EACpE;EACA,MAAM5B,UAAU,GAAG9B,OAAO,CAAC6D,4BAA4B,CAACF,QAAQ,CAAC;EACjE,IAAI,CAAC7B,UAAU,EAAE;IACf;IACA,OAAO9B,OAAO,CAAC8D,yBAAyB,CAACJ,SAAS,EAAEC,QAAQ,EAAE3D,OAAO,CAACiC,WAAW,CAAClC,SAAS,CAAC,CAAC;EAC/F;EACA,MAAMgE,MAAM,GAAG,MAAM/D,OAAO,CAACkC,aAAa,CAACJ,UAAU,CAAC;EACtD,IAAI,EAAEiC,MAAM,YAAY1B,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIR,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAkC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
|
|
1
|
+
{"version":3,"names":["ExportDeclarationTransformer","predicate","node","kind","SyntaxKind","ExportDeclaration","getIdentifiers","exportDec","context","rawSourceFilePath","moduleSpecifier","getText","sourceFilePath","substring","length","exportClause","ts","NamedExports","elements","map","elm","alias","propertyName","name","undefined","id","fileName","getSourceFile","ExportIdentifier","NamespaceExport","getFileExports","transform","specifier","Error","sourceFile","getSourceFileFromNode","UnImplementedSchema","getLocation","computeSchema","schemas","namedExport","ModuleSchema","namespaceExport","isSameNode","nodeA","nodeB","pos","end","Promise","all","element","exportSpecifierToSchemaNode","definitionInfo","UnresolvedSchema","definitionNode","definition","resolveType","parent","getLocationAsString","ExportSpecifier","e","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import {\n SchemaNode,\n ModuleSchema,\n UnresolvedSchema,\n UnImplementedSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n ExportSpecifier,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n // e.g. `export { button1, button2 } as Composition from './button';\n const rawSourceFilePath = exportDec.moduleSpecifier?.getText();\n\n // strip off quotes ''\n const sourceFilePath = rawSourceFilePath && rawSourceFilePath.substring(1, rawSourceFilePath?.length - 1);\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n return exportDec.exportClause.elements.map((elm) => {\n const alias = (elm.propertyName && elm.name.getText()) || undefined;\n const id = elm.propertyName?.getText() || elm.name.getText();\n const fileName = elm.getSourceFile().fileName;\n\n return new ExportIdentifier(id, fileName, alias, sourceFilePath);\n });\n }\n\n // e.g. `export * as Composition from './button';\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [\n new ExportIdentifier(\n exportDec.exportClause.name.getText(),\n exportDec.getSourceFile().fileName,\n undefined,\n sourceFilePath\n ),\n ];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n // export * from 'webpack', export-all from a package\n if (!sourceFile) {\n return new UnImplementedSchema(\n context.getLocation(exportDec),\n exportDec.getText(),\n SyntaxKind[SyntaxKind.ExportDeclaration]\n );\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new ModuleSchema(context.getLocation(exportDec), schemas, []);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nfunction isSameNode(nodeA: Node, nodeB: Node): boolean {\n return nodeA.kind === nodeB.kind && nodeA.pos === nodeB.pos && nodeA.end === nodeB.end;\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return exportSpecifierToSchemaNode(element, context);\n })\n );\n\n return schemas;\n}\n\nasync function exportSpecifierToSchemaNode(element: ExportSpecifier, context: SchemaExtractorContext) {\n try {\n const definitionInfo = await context.definitionInfo(element);\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n\n const definitionNode = await context.definition(definitionInfo);\n\n if (!definitionNode) {\n return await context.resolveType(element, element.name.getText(), false);\n }\n\n // if it is reexported from another export\n if (isSameNode(element, definitionNode.parent)) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier)\n return exportSpecifierToSchemaNode(definitionNode.parent as ExportSpecifier, context);\n\n return await context.computeSchema(definitionNode.parent);\n } catch (e) {\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof ModuleSchema)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AAEjD,MAAMA,4BAA4B,CAA8B;EACrEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,wBAAU,CAACC,iBAAiB;EACnD;EAEA,MAAMC,cAAc,CAACC,SAAgC,EAAEC,OAA+B,EAAE;IAAA;IACtF;IACA,MAAMC,iBAAiB,4BAAGF,SAAS,CAACG,eAAe,0DAAzB,sBAA2BC,OAAO,EAAE;;IAE9D;IACA,MAAMC,cAAc,GAAGH,iBAAiB,IAAIA,iBAAiB,CAACI,SAAS,CAAC,CAAC,EAAE,CAAAJ,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEK,MAAM,IAAG,CAAC,CAAC;IAEzG,IAAI,0BAAAP,SAAS,CAACQ,YAAY,0DAAtB,sBAAwBZ,IAAI,MAAKa,qBAAE,CAACZ,UA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ACZ,OAAO,EAAE,CAAC;EACxF;AACF;AAEA,eAAe+B,eAAe,CAC5B3B,YAA6B,EAC7BR,SAAgC,EAChCC,OAA+B,EAC/B;EACA,MAAMqD,SAAS,GAAG9C,YAAY,CAACQ,IAAI,CAACZ,OAAO,EAAE;EAC7C,MAAMmD,QAAQ,GAAG,MAAMtD,OAAO,CAACuD,iBAAiB,CAAChD,YAAY,CAACQ,IAAI,CAAC;EACnE,IAAI,CAACuC,QAAQ,EAAE;IACb,MAAM,IAAI7B,KAAK,CAAE,qCAAoC4B,SAAU,GAAE,CAAC;EACpE;EACA,MAAM3B,UAAU,GAAG1B,OAAO,CAACwD,4BAA4B,CAACF,QAAQ,CAAC;EACjE,IAAI,CAAC5B,UAAU,EAAE;IACf;IACA,OAAO1B,OAAO,CAACyD,yBAAyB,CAACJ,SAAS,EAAEC,QAAQ,EAAEtD,OAAO,CAAC6B,WAAW,CAAC9B,SAAS,CAAC,CAAC;EAC/F;EACA,MAAM2D,MAAM,GAAG,MAAM1D,OAAO,CAAC8B,aAAa,CAACJ,UAAU,CAAC;EACtD,IAAI,EAAEgC,MAAM,YAAYzB,iCAAY,CAAC,EAAE;IACrC,MAAM,IAAIR,KAAK,CAAE,wCAAuC,CAAC;EAC3D;EACAiC,MAAM,CAACL,SAAS,GAAGA,SAAS;EAC5B,OAAOK,MAAM;AACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ExpressionStatementTransformer","predicate","node","kind","ts","SyntaxKind","ExpressionStatement","getIdentifiers","transform","context","location","getLocation","UnImplementedSchema","getText"],"sources":["expression-statement.ts"],"sourcesContent":["import ts, { Node, ExpressionStatement } from 'typescript';\nimport { UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { Identifier } from '../identifier';\n\nexport class ExpressionStatementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.ExpressionStatement;\n }\n\n async getIdentifiers(): Promise<Identifier[]> {\n return [];\n }\n\n async transform(node: ExpressionStatement, context: SchemaExtractorContext) {\n const location = context.getLocation(node);\n return new UnImplementedSchema(location, node.getText(), ts.SyntaxKind[node.kind]);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,8BAA8B,CAA8B;EACvEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,mBAAmB;EACxD;EAEA,MAAMC,cAAc,GAA0B;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,SAAS,CAACN,IAAyB,EAAEO,OAA+B,EAAE;IAC1E,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,CAACT,IAAI,CAAC;IAC1C,OAAO,KAAIU,wCAAmB,EAACF,QAAQ,EAAER,IAAI,CAACW,OAAO,EAAE,EAAET,qBAAE,CAACC,UAAU,CAACH,IAAI,CAACC,IAAI,CAAC,CAAC;EACpF;AACF;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["FunctionLikeTransformer","predicate","node","kind","ts","SyntaxKind","FunctionDeclaration","ArrowFunction","MethodDeclaration","CallSignature","ConstructSignature","IndexSignature","FunctionType","MethodSignature","getIdentifiers","funcDec","Identifier","getName","getSourceFile","fileName","name","getText","transform","context","getQuickInfoFromDefaultModifier","defaultModifier","modifiers","find","modifier","DefaultKeyword","getQuickInfo","equalsGreaterThanToken","info","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","pMapSeries","parameters","param","computeSchema","returnType","resolveType","Boolean","map","typeParameters","typeParam","location","getLocation","doc","jsDocToDocSchema","FunctionLikeSchema"],"sources":["function-like.ts"],"sourcesContent":["import { FunctionLikeSchema, ParameterSchema, SchemaNode, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, SignatureDeclaration } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { Identifier } from '../identifier';\n\nexport class FunctionLikeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return (\n node.kind === ts.SyntaxKind.FunctionDeclaration ||\n node.kind === ts.SyntaxKind.ArrowFunction ||\n node.kind === ts.SyntaxKind.MethodDeclaration ||\n node.kind === ts.SyntaxKind.CallSignature ||\n node.kind === ts.SyntaxKind.ConstructSignature ||\n node.kind === ts.SyntaxKind.IndexSignature ||\n node.kind === ts.SyntaxKind.FunctionType ||\n node.kind === ts.SyntaxKind.MethodSignature\n );\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: SignatureDeclaration) {\n return [new Identifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: SignatureDeclaration) {\n if (funcDec.kind === ts.SyntaxKind.ConstructSignature) return 'new';\n return funcDec.name?.getText() || '';\n }\n\n async transform(node: SignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(node);\n const getQuickInfoFromDefaultModifier = async () => {\n const defaultModifier = node.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword);\n if (defaultModifier) return context.getQuickInfo(defaultModifier);\n if (node.kind === ts.SyntaxKind.ArrowFunction) return context.getQuickInfo(node.equalsGreaterThanToken);\n return null;\n };\n const info = node.name ? await context.getQuickInfo(node.name) : await getQuickInfoFromDefaultModifier();\n const returnTypeStr = info ? parseTypeFromQuickInfo(info) : 'any';\n const displaySig = info?.body?.displayString || '';\n const args = (await pMapSeries(node.parameters, async (param) =>\n context.computeSchema(param)\n )) as ParameterSchema[];\n\n const returnType = await context.resolveType(node, returnTypeStr, Boolean(info));\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const typeParameters = node.typeParameters?.map((typeParam) => typeParam.name.getText());\n const location = context.getLocation(node);\n const doc = await context.jsDocToDocSchema(node);\n\n return new FunctionLikeSchema(\n location,\n name,\n args,\n returnType,\n displaySig,\n modifiers as Modifier[],\n doc,\n typeParameters\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,uBAAuB,CAA8B;EAChEC,SAAS,CAACC,IAAU,EAAE;IACpB,OACEA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,mBAAmB,IAC/CJ,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACE,aAAa,IACzCL,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACG,iBAAiB,IAC7CN,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACI,aAAa,IACzCP,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACK,kBAAkB,IAC9CR,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACM,cAAc,IAC1CT,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACO,YAAY,IACxCV,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACQ,eAAe;EAE/C;;EAEA;EACA,MAAMC,cAAc,CAACC,OAA6B,EAAE;IAClD,OAAO,CAAC,KAAIC,wBAAU,EAAC,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC,EAAEA,OAAO,CAACG,aAAa,EAAE,CAACC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