@teambit/typescript 0.0.737 → 0.0.738

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.
Files changed (43) hide show
  1. package/dist/cmds/check-types.cmd.js.map +1 -1
  2. package/dist/cmds/init.cmd.js.map +1 -1
  3. package/dist/compiler-options.js.map +1 -1
  4. package/dist/exceptions/index.js.map +1 -1
  5. package/dist/exceptions/transformer-not-found.js.map +1 -1
  6. package/dist/export-identifier.js.map +1 -1
  7. package/dist/export-list.js.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/schema-extractor-context.js.map +1 -1
  10. package/dist/schema-transformer.js.map +1 -1
  11. package/dist/schema-transformer.plugin.js.map +1 -1
  12. package/dist/transformers/class-deceleration.js.map +1 -1
  13. package/dist/transformers/constructor.js.map +1 -1
  14. package/dist/transformers/export-declaration.js.map +1 -1
  15. package/dist/transformers/function-declaration.js.map +1 -1
  16. package/dist/transformers/index-signature.js.map +1 -1
  17. package/dist/transformers/index.js.map +1 -1
  18. package/dist/transformers/interface-declaration.js.map +1 -1
  19. package/dist/transformers/literal-type.js.map +1 -1
  20. package/dist/transformers/method-declaration.js.map +1 -1
  21. package/dist/transformers/method-signature.js.map +1 -1
  22. package/dist/transformers/property-declaration.js.map +1 -1
  23. package/dist/transformers/property-signature.js.map +1 -1
  24. package/dist/transformers/source-file-transformer.js.map +1 -1
  25. package/dist/transformers/type-alias.js.map +1 -1
  26. package/dist/transformers/utils/get-params.js.map +1 -1
  27. package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
  28. package/dist/transformers/utils/to-function-schema.js.map +1 -1
  29. package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
  30. package/dist/transformers/variable-declaration.js.map +1 -1
  31. package/dist/transformers/variable-statement.js.map +1 -1
  32. package/dist/typescript.aspect.js.map +1 -1
  33. package/dist/typescript.compiler.js.map +1 -1
  34. package/dist/typescript.compiler.spec.js.map +1 -1
  35. package/dist/typescript.composition.js.map +1 -1
  36. package/dist/typescript.extractor.js.map +1 -1
  37. package/dist/typescript.main.runtime.js.map +1 -1
  38. package/dist/typescript.parser.js.map +1 -1
  39. package/dist/typescript.parser.spec.js.map +1 -1
  40. package/package-tar/teambit-typescript-0.0.738.tgz +0 -0
  41. package/package.json +10 -10
  42. package/{preview-1652930732694.js → preview-1653227849497.js} +2 -2
  43. package/package-tar/teambit-typescript-0.0.737.tgz +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["check-types.cmd.ts"],"names":["CheckTypesCmd","constructor","typescript","workspace","logger","report","userPattern","all","strict","ConsumerNotFound","components","getComponentsByUserInput","setStatusLine","length","files","getSupportedFilesForTsserver","initTsserverClientFromWorkspace","printTypeErrors","tsserver","getTsserverClient","Error","start","Date","now","getDiagnostic","end","msg","killTsServer","lastDiagnostics","code","data","chalk","red","green"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;AAU5CC,EAAAA,WAAW,CAASC,UAAT,EAA6CC,SAA7C,EAA2EC,MAA3E,EAA2F;AAAA,SAAlFF,UAAkF,GAAlFA,UAAkF;AAAA,SAA9CC,SAA8C,GAA9CA,SAA8C;AAAA,SAAhBC,MAAgB,GAAhBA,MAAgB;AAAA,kDAT/F,uBAS+F;AAAA,yDARxF,wBAQwF;AAAA,mDAP9F,EAO8F;AAAA,mDAN9F,aAM8F;AAAA,qDAL5F,CACR,CAAC,GAAD,EAAM,KAAN,EAAa,2DAAb,CADQ,EAER,CAAC,EAAD,EAAK,QAAL,EAAe,wCAAf,CAFQ,CAK4F;AAAE;;AAE5F,QAANC,MAAM,CAAC,CAACC,WAAD,CAAD,EAA0B;AAAEC,IAAAA,GAAG,GAAG,KAAR;AAAeC,IAAAA,MAAM,GAAG;AAAxB,GAA1B,EAA8F;AACxG,QAAI,CAAC,KAAK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} from '@teambit/legacy/dist/consumer/exceptions';\nimport { Logger } from '@teambit/logger';\nimport { Workspace } from '@teambit/workspace';\nimport chalk from 'chalk';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\nexport class CheckTypesCmd implements Command {\n name = 'check-types [pattern]';\n description = 'check typescript types';\n alias = '';\n group = 'development';\n options = [\n ['a', 'all', 'check-types for all components, not only modified and new'],\n ['', 'strict', 'in case issues found, exit with code 1'],\n ] as CommandOptions;\n\n constructor(private typescript: TypescriptMain, private workspace: Workspace, private logger: Logger) {}\n\n async report([userPattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {\n if (!this.workspace) throw new ConsumerNotFound();\n const components = await this.workspace.getComponentsByUserInput(all, userPattern);\n this.logger.setStatusLine(`checking types for ${components.length} components`);\n const files = this.typescript.getSupportedFilesForTsserver(components);\n await this.typescript.initTsserverClientFromWorkspace({ printTypeErrors: true }, files);\n const tsserver = this.typescript.getTsserverClient();\n if (!tsserver) throw new Error(`unable to start tsserver`);\n const start = Date.now();\n await tsserver.getDiagnostic(files);\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n tsserver.killTsServer();\n if (tsserver.lastDiagnostics.length) {\n return {\n code: strict ? 1 : 0,\n data: chalk.red(`${msg}. found errors in ${tsserver.lastDiagnostics.length} files.`),\n };\n }\n return {\n code: 0,\n data: chalk.green(`${msg}. no errors were found.`),\n };\n }\n}\n"]}
1
+ {"version":3,"names":["CheckTypesCmd","constructor","typescript","workspace","logger","report","userPattern","all","strict","ConsumerNotFound","components","getComponentsByUserInput","setStatusLine","length","files","getSupportedFilesForTsserver","initTsserverClientFromWorkspace","printTypeErrors","tsserver","getTsserverClient","Error","start","Date","now","getDiagnostic","end","msg","killTsServer","lastDiagnostics","code","data","chalk","red","green"],"sources":["check-types.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport { Logger } from '@teambit/logger';\nimport { Workspace } from '@teambit/workspace';\nimport chalk from 'chalk';\nimport { TypescriptMain } from '../typescript.main.runtime';\n\nexport class CheckTypesCmd implements Command {\n name = 'check-types [pattern]';\n description = 'check typescript types';\n alias = '';\n group = 'development';\n options = [\n ['a', 'all', 'check-types for all components, not only modified and new'],\n ['', 'strict', 'in case issues found, exit with code 1'],\n ] as CommandOptions;\n\n constructor(private typescript: TypescriptMain, private workspace: Workspace, private logger: Logger) {}\n\n async report([userPattern]: [string], { all = false, strict = false }: { all: boolean; strict: boolean }) {\n if (!this.workspace) throw new ConsumerNotFound();\n const components = await this.workspace.getComponentsByUserInput(all, userPattern);\n this.logger.setStatusLine(`checking types for ${components.length} components`);\n const files = this.typescript.getSupportedFilesForTsserver(components);\n await this.typescript.initTsserverClientFromWorkspace({ printTypeErrors: true }, files);\n const tsserver = this.typescript.getTsserverClient();\n if (!tsserver) throw new Error(`unable to start tsserver`);\n const start = Date.now();\n await tsserver.getDiagnostic(files);\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n tsserver.killTsServer();\n if (tsserver.lastDiagnostics.length) {\n return {\n code: strict ? 1 : 0,\n data: chalk.red(`${msg}. found errors in ${tsserver.lastDiagnostics.length} files.`),\n };\n }\n return {\n code: 0,\n data: chalk.green(`${msg}. no errors were found.`),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,aAAN,CAAuC;EAU5CC,WAAW,CAASC,UAAT,EAA6CC,SAA7C,EAA2EC,MAA3E,EAA2F;IAAA,KAAlFF,UAAkF,GAAlFA,UAAkF;IAAA,KAA9CC,SAA8C,GAA9CA,SAA8C;IAAA,KAAhBC,MAAgB,GAAhBA,MAAgB;IAAA,8CAT/F,uBAS+F;IAAA,qDARxF,wBAQwF;IAAA,+CAP9F,EAO8F;IAAA,+C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qBAAoBR,QAAQ,CAACU,eAAT,CAAyBf,MAAO,SAArE;MAFD,CAAP;IAID;;IACD,OAAO;MACLgB,IAAI,EAAE,CADD;MAELC,IAAI,EAAEC,gBAAA,CAAME,KAAN,CAAa,GAAEP,GAAI,yBAAnB;IAFD,CAAP;EAID;;AAnC2C"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["init.cmd.ts"],"sourcesContent":[""],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["compiler-options.ts"],"sourcesContent":["import type { CompilerOptions } from '@teambit/compiler';\n\nexport type TypeScriptCompilerOptions = {\n /**\n * tsconfig to use during compilation.\n */\n tsconfig: Record<string, any>;\n\n /**\n * path for .d.ts files to include during build.\n */\n types: string[];\n\n /**\n * Run the compiler for .js files. this will only affect whether to run the compiler on the files\n * or not. It won't change the tsconfig to support or not support js files.\n */\n compileJs?: boolean;\n\n /**\n * Run the compiler for .js files. this will only affect whether to run the compiler on the files\n * or not. It won't change the tsconfig to support or not support jsx files.\n */\n compileJsx?: boolean;\n} & Partial<CompilerOptions>;\n\nexport type TsCompilerOptionsWithoutTsConfig = Omit<TypeScriptCompilerOptions, 'tsconfig'>;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { TransformerNotFound } from './transformer-not-found';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { TransformerNotFound } from './transformer-not-found';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["transformer-not-found.ts"],"names":["TransformerNotFound","Error","constructor","node","component","kind","ts","SyntaxKind","id","toString","getText"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,mBAAN,SAAkCC,KAAlC,CAAwC;AAC7CC,EAAAA,WAAW,CAAUC,IAAV,EAA+BC,SAA/B,EAAqD;AAC9D,UACG,kEAAiED,IAAI,CAACE,IAAK,KAC1EC,sBAAGC,UAAH,CAAcJ,IAAI,CAACE,IAAnB,CACD,kBAAiBD,SAAS,CAACI,EAAV,CAAaC,QAAb,EAAwB;AAChD,aAAaN,IAAI,CAACO,OAAL,EAAe,EAJxB;AAD8D,SAA3CP,IAA2C,GAA3CA,IAA2C;AAAA,SAAtBC,SAAsB,GAAtBA,SAAsB;AAO/D;;AAR4C","sourcesContent":["import ts, { Node } from 'typescript';\nimport { Component } from '@teambit/component';\n\nexport class TransformerNotFound extends Error {\n constructor(readonly node: Node, readonly component: Component) {\n super(\n `typescript: could not find schema transformer for node of kind ${node.kind} (${\n ts.SyntaxKind[node.kind]\n }) in component ${component.id.toString()}.\nnode text: ${node.getText()}`\n );\n }\n}\n"]}
1
+ {"version":3,"names":["TransformerNotFound","Error","constructor","node","component","kind","ts","SyntaxKind","id","toString","getText"],"sources":["transformer-not-found.ts"],"sourcesContent":["import ts, { Node } from 'typescript';\nimport { Component } from '@teambit/component';\n\nexport class TransformerNotFound extends Error {\n constructor(readonly node: Node, readonly component: Component) {\n super(\n `typescript: could not find schema transformer for node of kind ${node.kind} (${\n ts.SyntaxKind[node.kind]\n }) in component ${component.id.toString()}.\nnode text: ${node.getText()}`\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,mBAAN,SAAkCC,KAAlC,CAAwC;EAC7CC,WAAW,CAAUC,IAAV,EAA+BC,SAA/B,EAAqD;IAC9D,MACG,kEAAiED,IAAI,CAACE,IAAK,KAC1EC,qBAAA,CAAGC,UAAH,CAAcJ,IAAI,CAACE,IAAnB,CACD,kBAAiBD,SAAS,CAACI,EAAV,CAAaC,QAAb,EAAwB;AAChD,aAAaN,IAAI,CAACO,OAAL,EAAe,EAJxB;IAD8D,KAA3CP,IAA2C,GAA3CA,IAA2C;IAAA,KAAtBC,SAAsB,GAAtBA,SAAsB;EAO/D;;AAR4C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["export-identifier.ts"],"names":["ExportIdentifier","constructor","id","filePath"],"mappings":";;;;;;;AAAO,MAAMA,gBAAN,CAAuB;AAC5BC,EAAAA,WAAW,CAAUC,EAAV,EAA+BC,QAA/B,EAAiD;AAAA,SAAvCD,EAAuC,GAAvCA,EAAuC;AAAA,SAAlBC,QAAkB,GAAlBA,QAAkB;AAAE;;AADlC","sourcesContent":["export class ExportIdentifier {\n constructor(readonly id: string, readonly filePath: string) {}\n}\n"]}
1
+ {"version":3,"names":["ExportIdentifier","constructor","id","filePath"],"sources":["export-identifier.ts"],"sourcesContent":["export class ExportIdentifier {\n constructor(readonly id: string, readonly filePath: string) {}\n}\n"],"mappings":";;;;;;;AAAO,MAAMA,gBAAN,CAAuB;EAC5BC,WAAW,CAAUC,EAAV,EAA+BC,QAA/B,EAAiD;IAAA,KAAvCD,EAAuC,GAAvCA,EAAuC;IAAA,KAAlBC,QAAkB,GAAlBA,QAAkB;EAAE;;AADlC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["export-list.ts"],"names":["ExportList","constructor","exports","includes","id","Boolean","find","exportId"],"mappings":";;;;;;;AAEO,MAAMA,UAAN,CAAiB;AACtBC,EAAAA,WAAW,CAAUC,OAAV,EAAuC;AAAA,SAA7BA,OAA6B,GAA7BA,OAA6B;AAAE;;AAEpDC,EAAAA,QAAQ,CAACC,EAAD,EAAa;AACnB,WAAOC,OAAO,CAAC,KAAKH,OAAL,CAAaI,IAAb,CAAmBC,QAAD,IAAcA,QAAQ,CAACH,EAAT,KAAgBA,EAAhD,CAAD,CAAd;AACD;;AALqB","sourcesContent":["import { ExportIdentifier } from './export-identifier';\n\nexport class ExportList {\n constructor(readonly exports: ExportIdentifier[]) {}\n\n includes(id: string) {\n return Boolean(this.exports.find((exportId) => exportId.id === id));\n }\n}\n"]}
1
+ {"version":3,"names":["ExportList","constructor","exports","includes","id","Boolean","find","exportId"],"sources":["export-list.ts"],"sourcesContent":["import { ExportIdentifier } from './export-identifier';\n\nexport class ExportList {\n constructor(readonly exports: ExportIdentifier[]) {}\n\n includes(id: string) {\n return Boolean(this.exports.find((exportId) => exportId.id === id));\n }\n}\n"],"mappings":";;;;;;;AAEO,MAAMA,UAAN,CAAiB;EACtBC,WAAW,CAAUC,OAAV,EAAuC;IAAA,KAA7BA,OAA6B,GAA7BA,OAA6B;EAAE;;EAEpDC,QAAQ,CAACC,EAAD,EAAa;IACnB,OAAOC,OAAO,CAAC,KAAKH,OAAL,CAAaI,IAAb,CAAmBC,QAAD,IAAcA,QAAQ,CAACH,EAAT,KAAgBA,EAAhD,CAAD,CAAd;EACD;;AALqB"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nexport { TypescriptCompiler } from './typescript.compiler';\nexport type { TypescriptMain, TsConfigTransformer } from './typescript.main.runtime';\nexport type { TypeScriptCompilerOptions, TsCompilerOptionsWithoutTsConfig } from './compiler-options';\nexport { TypescriptAspect } from './typescript.aspect';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nexport { TypescriptCompiler } from './typescript.compiler';\nexport type { TypescriptMain, TsConfigTransformer } from './typescript.main.runtime';\nexport type { TypeScriptCompilerOptions, TsCompilerOptionsWithoutTsConfig } from './compiler-options';\nexport { TypescriptAspect } from './typescript.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["schema-extractor-context.ts"],"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","file","fileName","getPathRelativeToComponent","filePath","basePath","filesystem","files","base","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","parseSourceFile","getSourceFileFromNode","def","getDefinition","firstDef","definition","startPosition","start","pos","nodeAtPos","visitDefinition","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","err","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","location","TypeRefSchema","type","ts","isTypeNode","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","isDefInSameLocation","loc","schemaNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AA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ChC,UAAIxC,UAAU,CAAC9C,IAAX,KAAoBX,IAAI,CAACK,aAAL,GAAqBO,QAA7C,EAAuD;AACrD,eAAO,KAAP;AACD;;AACD,YAAMsF,GAAG,GAAG,KAAKjG,WAAL,CAAiBD,IAAjB,CAAZ;AACA,aAAOkG,GAAG,CAACzF,IAAJ,KAAagD,UAAU,CAACE,KAAX,CAAiBlD,IAA9B,IAAsCyF,GAAG,CAACxF,SAAJ,KAAkB+C,UAAU,CAACE,KAAX,CAAiBpC,MAAhF;AACD,KAND;;AAQA,UAAMZ,IAAI,GAAG,KAAKsB,mBAAL,CAAyBwB,UAAU,CAAC9C,IAApC,CAAb;;AACA,QAAIA,IAAJ,EAAU;AACR,UAAIsF,mBAAmB,EAAvB,EAA2B;AACzB,eAAOH,gBAAgB,EAAvB;AACD;;AACD,YAAMK,UAAU,GAAG,MAAM,KAAKlB,IAAL,CAAUtE,IAAV,EAAgB8C,UAAU,CAACE,KAA3B,CAAzB;AACA,aAAOwC,UAAU,IAAIL,gBAAgB,EAArC;AACD;;AACD,UAAM3C,OAAO,GAAG,KAAKT,wBAAL,CAA8Be,UAAU,CAAC9C,IAAzC,CAAhB,CA1DqB,CA2DrB;;AACA,WAAO,KAAI6E,kCAAJ,EAAkBD,QAAlB,EAA4BF,OAA5B,EAAqCvF,SAArC,EAAgDqD,OAAhD,CAAP;AACD;;AArSiC","sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportDeclaration, Node, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { resolve, sep, relative } from 'path';\nimport { Component } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n\n return {\n file: absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName),\n line,\n character,\n };\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n /**\n * create a reference to a type from a component.\n * think if we don't need this because of type ref\n */\n // createRef() {\n // return {};\n // }\n\n getQuickInfo(node: Node) {\n return this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n private getSourceFile(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const sourceFile = this.getSourceFile(firstDef.file);\n\n return sourceFile;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(node: Node): Promise<Node | undefined> {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const startPosition = firstDef.start;\n const sourceFile = this.getSourceFile(firstDef.file);\n if (!sourceFile) {\n return undefined; // learn how to return a reference to a different component here.\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definition = await this.definition(node);\n if (!definition) {\n return undefined;\n }\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr = exportDec.moduleSpecifier?.getText() || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFile(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr);\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n const pkgName = this.parsePackageNameFromPath(definition.file);\n // TODO: find component id is exists, otherwise add the package name.\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"]}
1
+ {"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","file","fileName","getPathRelativeToComponent","filePath","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","parseSourceFile","getSourceFileFromNode","def","getDefinition","firstDef","head","definition","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","err","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","location","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode"],"sources":["schema-extractor-context.ts"],"sourcesContent":["import { TsserverClient } from '@teambit/ts-server';\nimport ts, { ExportDeclaration, Node, TypeNode } from 'typescript';\nimport { getTokenAtPosition } from 'tsutils';\nimport { head } from 'lodash';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { resolve, sep, relative } from 'path';\nimport { Component } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { ExportList } from './export-list';\nimport { typeNodeToSchema } from './transformers/utils/type-node-to-schema';\nimport { TransformerNotFound } from './exceptions';\nimport { parseTypeFromQuickInfo } from './transformers/utils/parse-type-from-quick-info';\n\nexport class SchemaExtractorContext {\n constructor(\n readonly tsserver: TsserverClient,\n readonly component: Component,\n readonly extractor: TypeScriptExtractor\n ) {}\n\n computeSchema(node: Node) {\n return this.extractor.computeSchema(node, this);\n }\n\n /**\n * returns the location of a node in a source file.\n */\n getLocation(node: Node, targetSourceFile?: ts.SourceFile, absolutePath = false): Location {\n const sourceFile = targetSourceFile || node.getSourceFile();\n const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const line = position.line + 1;\n const character = position.character + 1;\n\n return {\n file: absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName),\n line,\n character,\n };\n }\n\n getPathRelativeToComponent(filePath: string): string {\n const basePath = this.component.filesystem.files[0].base;\n return relative(basePath, filePath);\n }\n\n /**\n * returns a signature for a node.\n */\n async getSignature(node: Node) {\n return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));\n }\n\n /**\n * get the position for the tsserver.\n */\n getPosition(sourceFile: ts.SourceFile, line: number, offset: number): number {\n return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);\n }\n\n /**\n * get the path for a source file.\n */\n getPath(node: Node) {\n const sourceFile = node.getSourceFile();\n return sourceFile.fileName;\n }\n\n /**\n * create a reference to a type from a component.\n * think if we don't need this because of type ref\n */\n // createRef() {\n // return {};\n // }\n\n getQuickInfo(node: Node) {\n return this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.tsserver.getQuickInfo(this.getPath(node), this.getLocation(node));\n return quickInfo?.body?.displayString || '';\n }\n\n /**\n * returns the type definition for a type.\n */\n typeDefinition(node: Node) {\n return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));\n }\n\n visitTypeDefinition() {}\n\n private findFileInComponent(filePath: string) {\n return this.component.filesystem.files.find((file) => {\n // TODO: fix this line to support further extensions.\n if (file.path.includes(filePath)) {\n const strings = ['ts', 'tsx', 'js', 'jsx'].map((format) => {\n if (filePath.endsWith(format)) return filePath;\n return `${filePath}.${format}`;\n });\n\n return strings.find((string) => string === file.path);\n }\n\n return false;\n });\n }\n\n private parsePackageNameFromPath(path: string) {\n const parts = path.split('node_modules');\n if (parts.length === 1) return '';\n const lastPart = parts[parts.length - 1].replace(sep, '');\n const pkgParts = lastPart.split('/');\n if (lastPart.startsWith('@')) {\n // scoped package\n return `${pkgParts[0]}/${pkgParts[1]}`;\n }\n const pkgName = pkgParts[0];\n if (pkgName === 'typescript') {\n // it's a built-in type, such as \"string\".\n return '';\n }\n return pkgName;\n }\n\n /**\n * return the file if part of the component.\n * otherwise, a reference to the target package and the type name.\n */\n private getSourceFile(filePath: string) {\n const file = this.findFileInComponent(filePath);\n if (!file) return undefined;\n return this.extractor.parseSourceFile(file);\n }\n\n async getSourceFileFromNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const sourceFile = this.getSourceFile(firstDef.file);\n\n return sourceFile;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(node: Node): Promise<Node | undefined> {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n if (!firstDef) {\n return undefined;\n }\n\n const startPosition = firstDef.start;\n const sourceFile = this.getSourceFile(firstDef.file);\n if (!sourceFile) {\n return undefined; // learn how to return a reference to a different component here.\n }\n const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n return nodeAtPos;\n }\n\n /**\n * visit a definition for node - e.g. return it's schema.\n */\n async visitDefinition(node: Node): Promise<SchemaNode | undefined> {\n const definition = await this.definition(node);\n if (!definition) {\n return undefined;\n }\n return this.visit(definition.parent);\n }\n\n async visit(node: Node): Promise<SchemaNode> {\n return this.extractor.computeSchema(node, this);\n }\n\n references() {}\n\n isExported() {}\n\n isFromComponent() {}\n\n async getFileExports(exportDec: ExportDeclaration) {\n const file = exportDec.getSourceFile().fileName;\n const specifierPathStr = exportDec.moduleSpecifier?.getText() || '';\n const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);\n const absPath = resolve(file, '..', specifierPath);\n const sourceFile = this.getSourceFile(absPath);\n if (!sourceFile) return [];\n return this.extractor.computeExportedIdentifiers(sourceFile, this);\n }\n\n _exports: ExportList | undefined = undefined;\n\n setExports(exports: ExportList) {\n this._exports = exports;\n return this;\n }\n\n getExportedIdentifiers(node: Node) {\n return this.extractor.computeExportedIdentifiers(node, this);\n }\n\n async jump(file: AbstractVinyl, start: any): Promise<SchemaNode | undefined> {\n const sourceFile = this.extractor.parseSourceFile(file);\n const pos = this.getPosition(sourceFile, start.line, start.offset);\n const nodeAtPos = getTokenAtPosition(sourceFile, pos);\n if (!nodeAtPos) return undefined;\n\n // this causes some infinite loops. it's helpful for getting more data from types that are not exported.\n // e.g.\n // ```ts\n // class Bar {}\n // export const getBar = () => new Bar();\n // ```\n // if (nodeAtPos.kind === ts.SyntaxKind.Identifier) {\n // // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`\n // return this.visitDefinition(nodeAtPos);\n // }\n try {\n return await this.visit(nodeAtPos);\n } catch (err) {\n if (err instanceof TransformerNotFound) {\n return undefined;\n }\n throw err;\n }\n }\n\n /**\n * resolve a type by a node and its identifier.\n */\n async resolveType(\n node: Node & { type?: TypeNode },\n typeStr: string,\n isTypeStrFromQuickInfo = true\n ): Promise<SchemaNode> {\n const location = this.getLocation(node);\n if (this._exports?.includes(typeStr)) {\n return new TypeRefSchema(location, typeStr);\n }\n if (node.type && ts.isTypeNode(node.type)) {\n // if a node has \"type\" prop, it has the type data of the node. this normally happens when the code has the type\n // explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have \"type\"\n return typeNodeToSchema(node.type, this);\n }\n /**\n * tsserver has two different calls: \"definition\" and \"typeDefinition\".\n * normally, we need the \"typeDefinition\" to get the type data of a node.\n * sometimes, it has no data, for example when the node is of type TypeReference, and then using \"definition\" is\n * helpful. (couldn't find a rule when to use each one. e.g. \"VariableDeclaration\" sometimes has data only in\n * \"definition\" but it's not clear when/why).\n */\n const getDef = async () => {\n const typeDefinition = await this.typeDefinition(node);\n const headTypeDefinition = head(typeDefinition?.body);\n if (headTypeDefinition) {\n return headTypeDefinition;\n }\n const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));\n return head(definition?.body);\n };\n const definition = await getDef();\n\n // when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.\n const unknownExactType = async () => {\n if (isTypeStrFromQuickInfo) {\n return new InferenceTypeSchema(location, typeStr);\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type);\n };\n if (!definition) {\n return unknownExactType();\n }\n\n // the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location\n const isDefInSameLocation = () => {\n if (definition.file !== node.getSourceFile().fileName) {\n return false;\n }\n const loc = this.getLocation(node);\n return loc.line === definition.start.line && loc.character === definition.start.offset;\n };\n\n const file = this.findFileInComponent(definition.file);\n if (file) {\n if (isDefInSameLocation()) {\n return unknownExactType();\n }\n const schemaNode = await this.jump(file, definition.start);\n return schemaNode || unknownExactType();\n }\n const pkgName = this.parsePackageNameFromPath(definition.file);\n // TODO: find component id is exists, otherwise add the package name.\n return new TypeRefSchema(location, typeStr, undefined, pkgName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;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;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,sBAAN,CAA6B;EAClCC,WAAW,CACAC,QADA,EAEAC,SAFA,EAGAC,SAHA,EAIT;IAAA,KAHSF,QAGT,GAHSA,QAGT;IAAA,KAFSC,SAET,G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,CAACE,KAAX,CAAiBrC,MAAhF;IACD,CAND;;IAQA,MAAMb,IAAI,GAAG,KAAKuB,mBAAL,CAAyByB,UAAU,CAAChD,IAApC,CAAb;;IACA,IAAIA,IAAJ,EAAU;MACR,IAAI4F,mBAAmB,EAAvB,EAA2B;QACzB,OAAOJ,gBAAgB,EAAvB;MACD;;MACD,MAAMM,UAAU,GAAG,MAAM,KAAKpB,IAAL,CAAU1E,IAAV,EAAgBgD,UAAU,CAACE,KAA3B,CAAzB;MACA,OAAO4C,UAAU,IAAIN,gBAAgB,EAArC;IACD;;IACD,MAAM/C,OAAO,GAAG,KAAKT,wBAAL,CAA8BgB,UAAU,CAAChD,IAAzC,CAAhB,CA1DqB,CA2DrB;;IACA,OAAO,KAAIiF,kCAAJ,EAAkBD,QAAlB,EAA4BF,OAA5B,EAAqC3F,SAArC,EAAgDsD,OAAhD,CAAP;EACD;;AArSiC"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["schema-transformer.ts"],"sourcesContent":["import { Node } from 'typescript';\nimport { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { ExportIdentifier } from './export-identifier';\n\nexport type SchemaTransformer = {\n /**\n * determine whether to apply schema on given node.\n */\n predicate(node: Node): boolean;\n\n getIdentifiers(node: Node, context: SchemaExtractorContext): Promise<ExportIdentifier[]>;\n\n /**\n * transform the node into JSONSchema.\n */\n transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode>;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["schema-transformer.plugin.ts"],"names":["SchemaTransformerPlugin","constructor","schemaTransformerSlot","register","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,uBAAN,CAA0D;AAC/DC,EAAAA,WAAW,CAASC,qBAAT,EAAuD;AAAA,SAA9CA,qBAA8C,GAA9CA,qBAA8C;AAAA,qDAExD,sBAFwD;AAAA,sDAIvD,CAAC,MAAD,CAJuD;AAAE;;AAMtD,QAARC,QAAQ,CAACC,MAAD,EAAc;AAC1B,WAAO,KAAKF,qBAAL,CAA2BC,QAA3B,CAAoC,CAACC,MAAD,CAApC,CAAP;AACD;;AAT8D","sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { SchemaTransformerSlot } from './typescript.main.runtime';\n\nexport class SchemaTransformerPlugin implements PluginDefinition {\n constructor(private schemaTransformerSlot: SchemaTransformerSlot) {}\n\n pattern = '*.schema-extractor.*';\n\n runtimes = ['main'];\n\n async register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"]}
1
+ {"version":3,"names":["SchemaTransformerPlugin","constructor","schemaTransformerSlot","register","object"],"sources":["schema-transformer.plugin.ts"],"sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { SchemaTransformerSlot } from './typescript.main.runtime';\n\nexport class SchemaTransformerPlugin implements PluginDefinition {\n constructor(private schemaTransformerSlot: SchemaTransformerSlot) {}\n\n pattern = '*.schema-extractor.*';\n\n runtimes = ['main'];\n\n async register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,uBAAN,CAA0D;EAC/DC,WAAW,CAASC,qBAAT,EAAuD;IAAA,KAA9CA,qBAA8C,GAA9CA,qBAA8C;IAAA,iDAExD,sBAFwD;IAAA,kDAIvD,CAAC,MAAD,CAJuD;EAAE;;EAMtD,MAARC,QAAQ,CAACC,MAAD,EAAc;IAC1B,OAAO,KAAKF,qBAAL,CAA2BC,QAA3B,CAAoC,CAACC,MAAD,CAApC,CAAP;EACD;;AAT8D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["class-deceleration.ts"],"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","member","isPrivate","modifiers","some","modifier","PrivateKeyword","GetAccessor","getter","info","getQuickInfo","displaySig","body","displayString","typeStr","type","resolveType","GetAccessorSchema","getLocation","SetAccessor","setter","params","parameters","getQuickInfoDisplayString","SetAccessorSchema","computeSchema","ClassSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,4BAAN,CAAgE;AACrEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,gBAAnC;AACD,GAHoE,CAKrE;;;AACQC,EAAAA,OAAO,CAACL,IAAD,EAAyB;AAAA;;AACtC,WAAO,eAAAA,IAAI,CAACM,IAAL,0DAAWC,OAAX,OAAwB,SAA/B;AACD;;AAEmB,QAAdC,cAAc,CAACR,IAAD,EAAyB;AAC3C,WAAO,CAAC,KAAIS,oCAAJ,EAAqB,KAAKJ,OAAL,CAAaL,IAAb,CAArB,EAAyCA,IAAI,CAACU,aAAL,GAAqBC,QAA9D,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACZ,IAAD,EAAyBa,OAAzB,EAA0D;AACvE,UAAMC,SAAS,GAAG,KAAKT,OAAL,CAAaL,IAAb,CAAlB;AACA,UAAMe,OAAO,GAAG,MAAM,2BAAWf,IAAI,CAACe,OAAhB,EAAyB,MAAOC,MAAP,IAAkB;AAAA;;AAC/D,YAAMC,SAAS,wBAAGD,MAAM,CAACE,SAAV,sDAAG,kBAAkBC,IAAlB,CAAwBC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AACE,iBAAOb,OAAO,CAAC2B,aAAR,CAAsBxB,MAAtB,CAAP;AAhBJ;AAkBD,KAvBqB,CAAtB;AAwBA,WAAO,KAAIyB,gCAAJ,EAAgB3B,SAAhB,EAA2B,uBAAQC,OAAR,CAA3B,EAA6CF,OAAO,CAACoB,WAAR,CAAoBjC,IAApB,CAA7C,CAAP;AACD;;AAzCoE","sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema, GetAccessorSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { getParams } from './utils/get-params';\n\nexport class ClassDecelerationTransformer 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 ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\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 switch (member.kind) {\n case ts.SyntaxKind.GetAccessor: {\n const getter = member as ts.GetAccessorDeclaration;\n const info = await context.getQuickInfo(getter.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(getter, typeStr);\n return new GetAccessorSchema(context.getLocation(getter), getter.name.getText(), type, displaySig);\n }\n case ts.SyntaxKind.SetAccessor: {\n const setter = member as ts.SetAccessorDeclaration;\n const params = await getParams(setter.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(setter.name);\n return new SetAccessorSchema(context.getLocation(setter), setter.name.getText(), params[0], displaySig);\n }\n default:\n return context.computeSchema(member);\n }\n });\n return new ClassSchema(className, compact(members), context.getLocation(node));\n }\n}\n"]}
1
+ {"version":3,"names":["ClassDecelerationTransformer","predicate","node","kind","ts","SyntaxKind","ClassDeclaration","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","context","className","members","pMapSeries","member","isPrivate","modifiers","some","modifier","PrivateKeyword","GetAccessor","getter","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","GetAccessorSchema","getLocation","SetAccessor","setter","params","getParams","parameters","getQuickInfoDisplayString","SetAccessorSchema","computeSchema","ClassSchema","compact"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema, GetAccessorSchema, SetAccessorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ClassDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { getParams } from './utils/get-params';\n\nexport class ClassDecelerationTransformer 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 ExportIdentifier(this.getName(node), node.getSourceFile().fileName)];\n }\n\n async transform(node: ClassDeclaration, context: SchemaExtractorContext) {\n const className = this.getName(node);\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 switch (member.kind) {\n case ts.SyntaxKind.GetAccessor: {\n const getter = member as ts.GetAccessorDeclaration;\n const info = await context.getQuickInfo(getter.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(getter, typeStr);\n return new GetAccessorSchema(context.getLocation(getter), getter.name.getText(), type, displaySig);\n }\n case ts.SyntaxKind.SetAccessor: {\n const setter = member as ts.SetAccessorDeclaration;\n const params = await getParams(setter.parameters, context);\n const displaySig = await context.getQuickInfoDisplayString(setter.name);\n return new SetAccessorSchema(context.getLocation(setter), setter.name.getText(), params[0], displaySig);\n }\n default:\n return context.computeSchema(member);\n }\n });\n return new ClassSchema(className, compact(members), context.getLocation(node));\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,4BAAN,CAAgE;EACrEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,gBAAnC;EACD,CAHoE,CAKrE;;;EACQC,OAAO,CAACL,IAAD,EAAyB;IAAA;;IACtC,OAAO,eAAAA,IAAI,CAACM,IAAL,0DAAWC,OAAX,OAAwB,SAA/B;EACD;;EAEmB,MAAdC,cAAc,CAACR,IAAD,EAAyB;IAC3C,OAAO,CAAC,KAAIS,oCAAJ,EAAqB,KAAKJ,OAAL,CAAaL,IAAb,CAArB,EAAyCA,IAAI,CAACU,aAAL,GAAqBC,QAA9D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,C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AjB,EAA6B3B,OAA7B,CAArB;YACA,MAAMc,UAAU,GAAG,MAAMd,OAAO,CAAC4B,yBAAR,CAAkCJ,MAAM,CAAC/B,IAAzC,CAAzB;YACA,OAAO,KAAIoC,sCAAJ,EAAsB7B,OAAO,CAACsB,WAAR,CAAoBE,MAApB,CAAtB,EAAmDA,MAAM,CAAC/B,IAAP,CAAYC,OAAZ,EAAnD,EAA0E+B,MAAM,CAAC,CAAD,CAAhF,EAAqFX,UAArF,CAAP;UACD;;QACD;UACE,OAAOd,OAAO,CAAC8B,aAAR,CAAsB1B,MAAtB,CAAP;MAhBJ;IAkBD,CAvBqB,CAAtB;IAwBA,OAAO,KAAI2B,gCAAJ,EAAgB9B,SAAhB,EAA2B,IAAA+B,iBAAA,EAAQ9B,OAAR,CAA3B,EAA6CF,OAAO,CAACsB,WAAR,CAAoBnC,IAApB,CAA7C,CAAP;EACD;;AAzCoE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["constructor.ts"],"names":["Constructor","predicate","node","kind","ts","SyntaxKind","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","constructorDec","context","args","parameters","ConstructorSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,WAAN,CAA+C;AACpDC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,WAAnC;AACD;;AAEmB,QAAdM,cAAc,CAACJ,IAAD,EAA+B;AACjD,WAAO,CAAC,KAAIK,oCAAJ,EAAqB,aAArB,EAAoCL,IAAI,CAACM,aAAL,GAAqBC,QAAzD,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACC,cAAD,EAAyCC,OAAzC,EAA+F;AAC5G,UAAMC,IAAI,GAAG,MAAM,4BAAUF,cAAc,CAACG,UAAzB,EAAqCF,OAArC,CAAnB;AAEA,WAAO,KAAIG,sCAAJ,EAAsBH,OAAO,CAACI,WAAR,CAAoBL,cAApB,CAAtB,EAA2DE,IAA3D,CAAP;AACD;;AAbmD","sourcesContent":["import { SchemaNode, ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ConstructorDeclaration } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\n\nexport class Constructor implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(node: ConstructorDeclaration) {\n return [new ExportIdentifier('constructor', node.getSourceFile().fileName)];\n }\n\n async transform(constructorDec: ConstructorDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const args = await getParams(constructorDec.parameters, context);\n\n return new ConstructorSchema(context.getLocation(constructorDec), args);\n }\n}\n"]}
1
+ {"version":3,"names":["Constructor","predicate","node","kind","ts","SyntaxKind","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","constructorDec","context","args","getParams","parameters","ConstructorSchema","getLocation"],"sources":["constructor.ts"],"sourcesContent":["import { SchemaNode, ConstructorSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, ConstructorDeclaration } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\n\nexport class Constructor implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.Constructor;\n }\n\n async getIdentifiers(node: ConstructorDeclaration) {\n return [new ExportIdentifier('constructor', node.getSourceFile().fileName)];\n }\n\n async transform(constructorDec: ConstructorDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const args = await getParams(constructorDec.parameters, context);\n\n return new ConstructorSchema(context.getLocation(constructorDec), args);\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;;AAEO,MAAMA,WAAN,CAA+C;EACpDC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,WAAnC;EACD;;EAEmB,MAAdM,cAAc,CAACJ,IAAD,EAA+B;IACjD,OAAO,CAAC,KAAIK,oCAAJ,EAAqB,aAArB,EAAoCL,IAAI,CAACM,aAAL,GAAqBC,QAAzD,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,cAAD,EAAyCC,OAAzC,EAA+F;IAC5G,MAAMC,IAAI,GAAG,MAAM,IAAAC,sBAAA,EAAUH,cAAc,CAACI,UAAzB,EAAqCH,OAArC,CAAnB;IAEA,OAAO,KAAII,sCAAJ,EAAsBJ,OAAO,CAACK,WAAR,CAAoBN,cAApB,CAAtB,EAA2DE,IAA3D,CAAP;EACD;;AAbmD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["export-declaration.ts"],"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","schemas","Promise","all","element","visitDefinition","Module","getLocation","namespace","sourceFile","getSourceFileFromNode","Error","result","computeSchema","specifier"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA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YAAMF,UAAU,GAAG,MAAMxB,OAAO,CAACyB,qBAAR,CAA8BI,SAA9B,CAAzB;;AACA,UAAI,CAACL,UAAL,EAAiB;AACf,cAAM,IAAIE,KAAJ,CAAW,gCAAX,CAAN;AACD;;AACD,aAAO1B,OAAO,CAAC4B,aAAR,CAAsBJ,UAAtB,CAAP;AACD;;AAED,UAAM,IAAIE,KAAJ,CAAU,0BAAV,CAAN;AACD;;AAnEyD","sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportDec = node as ExportDeclarationNode;\n const exportClause = exportDec.exportClause;\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamedExports) {\n exportClause as NamedExports;\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return context.visitDefinition(element.name);\n })\n );\n\n return new Module(context.getLocation(node), compact(schemas));\n }\n // e.g. `export * as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamespaceExport) {\n exportClause as NamespaceExport;\n const namespace = exportClause.name.getText();\n const sourceFile = await context.getSourceFileFromNode(exportClause.name);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file for \"${namespace}\"`);\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\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 if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n throw new Error('unrecognized export type');\n }\n}\n"]}
1
+ {"version":3,"names":["ExportDeclaration","predicate","node","kind","SyntaxKind","getIdentifiers","exportDec","context","exportClause","ts","NamedExports","elements","map","elm","ExportIdentifier","name","getText","getSourceFile","fileName","NamespaceExport","moduleSpecifier","getFileExports","transform","schemas","Promise","all","element","visitDefinition","Module","getLocation","compact","namespace","sourceFile","getSourceFileFromNode","Error","result","computeSchema","specifier"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport ts, {\n Node,\n SyntaxKind,\n ExportDeclaration as ExportDeclarationNode,\n NamedExports,\n NamespaceExport,\n} from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class ExportDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === SyntaxKind.ExportDeclaration;\n }\n\n async getIdentifiers(exportDec: ExportDeclarationNode, context: SchemaExtractorContext) {\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamedExports) {\n exportDec.exportClause as NamedExports;\n return exportDec.exportClause.elements.map((elm) => {\n return new ExportIdentifier(elm.name.getText(), elm.getSourceFile().fileName);\n });\n }\n\n if (exportDec.exportClause?.kind === ts.SyntaxKind.NamespaceExport) {\n return [new ExportIdentifier(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];\n }\n\n if (exportDec.moduleSpecifier) {\n return context.getFileExports(exportDec);\n }\n\n return [];\n }\n\n async transform(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportDec = node as ExportDeclarationNode;\n const exportClause = exportDec.exportClause;\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamedExports) {\n exportClause as NamedExports;\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n return context.visitDefinition(element.name);\n })\n );\n\n return new Module(context.getLocation(node), compact(schemas));\n }\n // e.g. `export * as Composition from './button';\n if (exportClause?.kind === SyntaxKind.NamespaceExport) {\n exportClause as NamespaceExport;\n const namespace = exportClause.name.getText();\n const sourceFile = await context.getSourceFileFromNode(exportClause.name);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file for \"${namespace}\"`);\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\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 if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n throw new Error('unrecognized export type');\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;;AASA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEO,MAAMA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AAI,CAACL,UAAL,EAAiB;QACf,MAAM,IAAIE,KAAJ,CAAW,gCAAX,CAAN;MACD;;MACD,OAAO3B,OAAO,CAAC6B,aAAR,CAAsBJ,UAAtB,CAAP;IACD;;IAED,MAAM,IAAIE,KAAJ,CAAU,0BAAV,CAAN;EACD;;AAnEyD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["function-declaration.ts"],"names":["FunctionDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context"],"mappings":";;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,mBAAnC;AACD,GAH2D,CAK5D;;;AACoB,QAAdM,cAAc,CAACC,OAAD,EAAmC;AACrD,WAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;AACD;;AAEOF,EAAAA,OAAO,CAACF,OAAD,EAAmC;AAAA;;AAChD,WAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;AACD;;AAEc,QAATC,SAAS,CAACP,OAAD,EAAmCQ,OAAnC,EAAyF;AACtG,WAAO,8CAAqBR,OAArB,EAA8BQ,OAA9B,CAAP;AACD;;AAhB2D","sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"]}
1
+ {"version":3,"names":["FunctionDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","context","toFunctionLikeSchema"],"sources":["function-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, FunctionDeclaration as FunctionDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class FunctionDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.FunctionDeclaration;\n }\n\n // need to check for anonymous functions assigned for vars, const and let.\n async getIdentifiers(funcDec: FunctionDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: FunctionDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(funcDec: FunctionDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(funcDec, context);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;EAC5DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,mBAAnC;EACD,CAH2D,CAK5D;;;EACoB,MAAdM,cAAc,CAACC,OAAD,EAAmC;IACrD,OAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;EACD;;EAEOF,OAAO,CAACF,OAAD,EAAmC;IAAA;;IAChD,OAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;EACD;;EAEc,MAATC,SAAS,CAACP,OAAD,EAAmCQ,OAAnC,EAAyF;IACtG,OAAO,IAAAC,wCAAA,EAAqBT,OAArB,EAA8BQ,OAA9B,CAAP;EACD;;AAhB2D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index-signature.ts"],"names":["IndexSignature","predicate","node","kind","ts","SyntaxKind","getIdentifiers","transform","indexSig","context","params","parameters","type","IndexSignatureSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,cAAN,CAAkD;AACvDC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,cAAnC;AACD;;AAEmB,QAAdM,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,QAAD,EAAsCC,OAAtC,EAA4F;AACzG,UAAMC,MAAM,GAAG,MAAM,4BAAUF,QAAQ,CAACG,UAAnB,EAA+BF,OAA/B,CAArB;AACA,UAAMG,IAAI,GAAG,MAAM,0CAAiBJ,QAAQ,CAACI,IAA1B,EAAgCH,OAAhC,CAAnB;AACA,WAAO,KAAII,yCAAJ,EAAyBJ,OAAO,CAACK,WAAR,CAAoBN,QAApB,CAAzB,EAAwDE,MAAxD,EAAgEE,IAAhE,CAAP;AACD;;AAbsD","sourcesContent":["import { SchemaNode, IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, IndexSignatureDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { getParams } from './utils/get-params';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class IndexSignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IndexSignature;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(indexSig: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const params = await getParams(indexSig.parameters, context);\n const type = await typeNodeToSchema(indexSig.type, context);\n return new IndexSignatureSchema(context.getLocation(indexSig), params, type);\n }\n}\n"]}
1
+ {"version":3,"names":["IndexSignature","predicate","node","kind","ts","SyntaxKind","getIdentifiers","transform","indexSig","context","params","getParams","parameters","type","typeNodeToSchema","IndexSignatureSchema","getLocation"],"sources":["index-signature.ts"],"sourcesContent":["import { SchemaNode, IndexSignatureSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, IndexSignatureDeclaration } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { getParams } from './utils/get-params';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class IndexSignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.IndexSignature;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(indexSig: IndexSignatureDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n const params = await getParams(indexSig.parameters, context);\n const type = await typeNodeToSchema(indexSig.type, context);\n return new IndexSignatureSchema(context.getLocation(indexSig), params, type);\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;;AAEO,MAAMA,cAAN,CAAkD;EACvDC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,cAAnC;EACD;;EAEmB,MAAdM,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,QAAD,EAAsCC,OAAtC,EAA4F;IACzG,MAAMC,MAAM,GAAG,MAAM,IAAAC,sBAAA,EAAUH,QAAQ,CAACI,UAAnB,EAA+BH,OAA/B,CAArB;IACA,MAAMI,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBN,QAAQ,CAACK,IAA1B,EAAgCJ,OAAhC,CAAnB;IACA,OAAO,KAAIM,yCAAJ,EAAyBN,OAAO,CAACO,WAAR,CAAoBR,QAApB,CAAzB,EAAwDE,MAAxD,EAAgEG,IAAhE,CAAP;EACD;;AAbsD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { MethodDeclaration } from './method-declaration';\nexport { PropertyDeclaration } from './property-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { Constructor } from './constructor';\nexport { PropertySignature } from './property-signature';\nexport { LiteralTypeTransformer } from './literal-type';\nexport { IndexSignature } from './index-signature';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { MethodSignatureTransformer } from './method-signature';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ExportDeclaration } from './export-declaration';\nexport { FunctionDeclaration } from './function-declaration';\nexport { MethodDeclaration } from './method-declaration';\nexport { PropertyDeclaration } from './property-declaration';\nexport { VariableStatementTransformer } from './variable-statement';\nexport { VariableDeclaration } from './variable-declaration';\nexport { SourceFileTransformer } from './source-file-transformer';\nexport { TypeAliasTransformer } from './type-alias';\nexport { ClassDecelerationTransformer } from './class-deceleration';\nexport { Constructor } from './constructor';\nexport { PropertySignature } from './property-signature';\nexport { LiteralTypeTransformer } from './literal-type';\nexport { IndexSignature } from './index-signature';\nexport { InterfaceDeclarationTransformer } from './interface-declaration';\nexport { MethodSignatureTransformer } from './method-signature';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;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,"sources":["interface-declaration.ts"],"names":["InterfaceDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","member","typeSchema","computeSchema","InterfaceSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,+BAAN,CAAmE;AACxEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,oBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA0D;AAC5E,WAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;AACnF,UAAMC,OAAO,GAAG,MAAM,2BAAWF,YAAY,CAACE,OAAxB,EAAiC,MAAOC,MAAP,IAAkB;AACvE,YAAMC,UAAU,GAAG,MAAMH,OAAO,CAACI,aAAR,CAAsBF,MAAtB,CAAzB;AACA,aAAOC,UAAP;AACD,KAHqB,CAAtB;AAIA,WAAO,KAAIE,oCAAJ,EAAoBL,OAAO,CAACM,WAAR,CAAoBP,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,CAAP;AACD;;AAfuE","sourcesContent":["import ts, { Node, InterfaceDeclaration } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);\n }\n}\n"]}
1
+ {"version":3,"names":["InterfaceDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","InterfaceDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","interfaceDec","context","members","pMapSeries","member","typeSchema","computeSchema","InterfaceSchema","getLocation"],"sources":["interface-declaration.ts"],"sourcesContent":["import ts, { Node, InterfaceDeclaration } from 'typescript';\nimport pMapSeries from 'p-map-series';\nimport { InterfaceSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\nexport class InterfaceDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.InterfaceDeclaration;\n }\n\n async getIdentifiers(node: InterfaceDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(interfaceDec: InterfaceDeclaration, context: SchemaExtractorContext) {\n const members = await pMapSeries(interfaceDec.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n return new InterfaceSchema(context.getLocation(interfaceDec), interfaceDec.name.getText(), members);\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,+BAAN,CAAmE;EACxEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,oBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA0D;IAC5E,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,YAAD,EAAqCC,OAArC,EAAsE;IACnF,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWH,YAAY,CAACE,OAAxB,EAAiC,MAAOE,MAAP,IAAkB;MACvE,MAAMC,UAAU,GAAG,MAAMJ,OAAO,CAACK,aAAR,CAAsBF,MAAtB,CAAzB;MACA,OAAOC,UAAP;IACD,CAHqB,CAAtB;IAIA,OAAO,KAAIE,oCAAJ,EAAoBN,OAAO,CAACO,WAAR,CAAoBR,YAApB,CAApB,EAAuDA,YAAY,CAACL,IAAb,CAAkBC,OAAlB,EAAvD,EAAoFM,OAApF,CAAP;EACD;;AAfuE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["literal-type.ts"],"names":["LiteralTypeTransformer","predicate","node","kind","ts","SyntaxKind","LiteralType","getIdentifiers","transform","literalType","context","type","literal","getText","TypeRefSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,sBAAN,CAA0D;AAC/DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,WAAnC;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,WAAD,EAA+BC,OAA/B,EAAgE;AAC7E,UAAMC,IAAI,GAAGF,WAAW,CAACG,OAAZ,CAAoBC,OAApB,EAAb;AACA,WAAO,KAAIC,kCAAJ,EAAkBJ,OAAO,CAACK,WAAR,CAAoBN,WAApB,CAAlB,EAAoDE,IAApD,CAAP;AACD;;AAZ8D","sourcesContent":["import ts, { LiteralTypeNode, Node } from 'typescript';\nimport { TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class LiteralTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.LiteralType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(literalType: LiteralTypeNode, context: SchemaExtractorContext) {\n const type = literalType.literal.getText();\n return new TypeRefSchema(context.getLocation(literalType), type);\n }\n}\n"]}
1
+ {"version":3,"names":["LiteralTypeTransformer","predicate","node","kind","ts","SyntaxKind","LiteralType","getIdentifiers","transform","literalType","context","type","literal","getText","TypeRefSchema","getLocation"],"sources":["literal-type.ts"],"sourcesContent":["import ts, { LiteralTypeNode, Node } from 'typescript';\nimport { TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class LiteralTypeTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.LiteralType;\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(literalType: LiteralTypeNode, context: SchemaExtractorContext) {\n const type = literalType.literal.getText();\n return new TypeRefSchema(context.getLocation(literalType), type);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,sBAAN,CAA0D;EAC/DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,WAAnC;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,WAAD,EAA+BC,OAA/B,EAAgE;IAC7E,MAAMC,IAAI,GAAGF,WAAW,CAACG,OAAZ,CAAoBC,OAApB,EAAb;IACA,OAAO,KAAIC,kCAAJ,EAAkBJ,OAAO,CAACK,WAAR,CAAoBN,WAApB,CAAlB,EAAoDE,IAApD,CAAP;EACD;;AAZ8D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["method-declaration.ts"],"names":["MethodDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","methodDec","context"],"mappings":";;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,iBAAN,CAAqD;AAC1DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,iBAAnC;AACD;;AAEmB,QAAdM,cAAc,CAACC,OAAD,EAAiC;AACnD,WAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;AACD;;AAEOF,EAAAA,OAAO,CAACF,OAAD,EAAiC;AAAA;;AAC9C,WAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;AACD;;AAEc,QAATC,SAAS,CAACC,SAAD,EAAmCC,OAAnC,EAAyF;AACtG,WAAO,8CAAqBD,SAArB,EAAgCC,OAAhC,CAAP;AACD;;AAfyD","sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, MethodDeclaration as MethodDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class MethodDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.MethodDeclaration;\n }\n\n async getIdentifiers(funcDec: MethodDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: MethodDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(methodDec: MethodDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(methodDec, context);\n }\n}\n"]}
1
+ {"version":3,"names":["MethodDeclaration","predicate","node","kind","ts","SyntaxKind","getIdentifiers","funcDec","ExportIdentifier","getName","getSourceFile","fileName","name","getText","transform","methodDec","context","toFunctionLikeSchema"],"sources":["method-declaration.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, MethodDeclaration as MethodDeclarationNode } from 'typescript';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class MethodDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.MethodDeclaration;\n }\n\n async getIdentifiers(funcDec: MethodDeclarationNode) {\n return [new ExportIdentifier(this.getName(funcDec), funcDec.getSourceFile().fileName)];\n }\n\n private getName(funcDec: MethodDeclarationNode) {\n return funcDec.name?.getText() || '';\n }\n\n async transform(methodDec: MethodDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(methodDec, context);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,iBAAN,CAAqD;EAC1DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,iBAAnC;EACD;;EAEmB,MAAdM,cAAc,CAACC,OAAD,EAAiC;IACnD,OAAO,CAAC,KAAIC,oCAAJ,EAAqB,KAAKC,OAAL,CAAaF,OAAb,CAArB,EAA4CA,OAAO,CAACG,aAAR,GAAwBC,QAApE,CAAD,CAAP;EACD;;EAEOF,OAAO,CAACF,OAAD,EAAiC;IAAA;;IAC9C,OAAO,kBAAAA,OAAO,CAACK,IAAR,gEAAcC,OAAd,OAA2B,EAAlC;EACD;;EAEc,MAATC,SAAS,CAACC,SAAD,EAAmCC,OAAnC,EAAyF;IACtG,OAAO,IAAAC,wCAAA,EAAqBF,SAArB,EAAgCC,OAAhC,CAAP;EACD;;AAfyD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["method-signature.ts"],"names":["MethodSignatureTransformer","predicate","node","kind","ts","SyntaxKind","MethodSignature","getName","name","getText","getIdentifiers","transform","methodSig","context"],"mappings":";;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,0BAAN,CAA8D;AACnEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,eAAnC;AACD;;AAEDC,EAAAA,OAAO,CAACL,IAAD,EAA4B;AACjC,WAAOA,IAAI,CAACM,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,SAAD,EAAiCC,OAAjC,EAAuF;AACpG,WAAO,8CAAqBD,SAArB,EAAgCC,OAAhC,CAAP;AACD;;AAfkE","sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, MethodSignature as MethodSignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class MethodSignatureTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.MethodSignature;\n }\n\n getName(node: MethodSignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(methodSig: MethodSignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(methodSig, context);\n }\n}\n"]}
1
+ {"version":3,"names":["MethodSignatureTransformer","predicate","node","kind","ts","SyntaxKind","MethodSignature","getName","name","getText","getIdentifiers","transform","methodSig","context","toFunctionLikeSchema"],"sources":["method-signature.ts"],"sourcesContent":["import { SchemaNode } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, MethodSignature as MethodSignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { toFunctionLikeSchema } from './utils/to-function-schema';\n\nexport class MethodSignatureTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.MethodSignature;\n }\n\n getName(node: MethodSignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(methodSig: MethodSignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n return toFunctionLikeSchema(methodSig, context);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,0BAAN,CAA8D;EACnEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,eAAnC;EACD;;EAEDC,OAAO,CAACL,IAAD,EAA4B;IACjC,OAAOA,IAAI,CAACM,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,SAAD,EAAiCC,OAAjC,EAAuF;IACpG,OAAO,IAAAC,wCAAA,EAAqBF,SAArB,EAAgCC,OAAhC,CAAP;EACD;;AAfkE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["property-declaration.ts"],"names":["PropertyDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","propertyDec","context","info","getQuickInfo","displaySig","body","displayString","typeStr","type","resolveType","VariableSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,mBAAnC;AACD;;AAEDM,EAAAA,OAAO,CAACJ,IAAD,EAAgC;AACrC,WAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEmB,QAAdC,cAAc,CAACP,IAAD,EAAgC;AAClD,WAAO,CAAC,KAAIQ,oCAAJ,EAAqBR,IAAI,CAACK,IAAL,CAAUC,OAAV,EAArB,EAA0CN,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEc,QAATC,SAAS,CAACC,WAAD,EAAuCC,OAAvC,EAA6F;AAAA;;AAC1G,UAAMR,IAAI,GAAG,KAAKD,OAAL,CAAaQ,WAAb,CAAb;AACA,UAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,WAAW,CAACP,IAAjC,CAAnB;AACA,UAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;AACA,UAAMC,OAAO,GAAG,sDAAuBL,IAAvB,CAAhB;AACA,UAAMM,IAAI,GAAG,MAAMP,OAAO,CAACQ,WAAR,CAAoBT,WAApB,EAAiCO,OAAjC,CAAnB;AAEA,WAAO,KAAIG,mCAAJ,EAAmBT,OAAO,CAACU,WAAR,CAAoBX,WAApB,CAAnB,EAAqDP,IAArD,EAA2DW,UAAU,IAAI,EAAzE,EAA6EI,IAA7E,CAAP;AACD;;AArB2D","sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, PropertyDeclaration as PropertyDeclarationNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class PropertyDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertyDeclaration;\n }\n\n getName(node: PropertyDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: PropertyDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(propertyDec);\n const info = await context.getQuickInfo(propertyDec.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(propertyDec, typeStr);\n\n return new VariableSchema(context.getLocation(propertyDec), name, displaySig || '', type);\n }\n}\n"]}
1
+ {"version":3,"names":["PropertyDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","propertyDec","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","VariableSchema","getLocation"],"sources":["property-declaration.ts"],"sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, PropertyDeclaration as PropertyDeclarationNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class PropertyDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertyDeclaration;\n }\n\n getName(node: PropertyDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: PropertyDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(propertyDec: PropertyDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(propertyDec);\n const info = await context.getQuickInfo(propertyDec.name);\n const displaySig = info?.body?.displayString;\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(propertyDec, typeStr);\n\n return new VariableSchema(context.getLocation(propertyDec), name, displaySig || '', type);\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;;AAEO,MAAMA,mBAAN,CAAuD;EAC5DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,mBAAnC;EACD;;EAEDM,OAAO,CAACJ,IAAD,EAAgC;IACrC,OAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,CAACP,IAAD,EAAgC;IAClD,OAAO,CAAC,KAAIQ,oCAAJ,EAAqBR,IAAI,CAACK,IAAL,CAAUC,OAAV,EAArB,EAA0CN,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEc,MAATC,SAAS,CAACC,WAAD,EAAuCC,OAAvC,EAA6F;IAAA;;IAC1G,MAAMR,IAAI,GAAG,KAAKD,OAAL,CAAaQ,WAAb,CAAb;IACA,MAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,WAAW,CAACP,IAAjC,CAAnB;IACA,MAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;IACA,MAAMC,OAAO,GAAG,IAAAC,gDAAA,EAAuBN,IAAvB,CAAhB;IACA,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAR,CAAoBV,WAApB,EAAiCO,OAAjC,CAAnB;IAEA,OAAO,KAAII,mCAAJ,EAAmBV,OAAO,CAACW,WAAR,CAAoBZ,WAApB,CAAnB,EAAqDP,IAArD,EAA2DW,UAAU,IAAI,EAAzE,EAA6EK,IAA7E,CAAP;EACD;;AArB2D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["property-signature.ts"],"names":["PropertySignature","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","transform","prop","context","info","getQuickInfo","displaySig","body","displayString","type","FunctionType","propType","typeStr","resolveType","VariableSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,iBAAN,CAAqD;AAC1DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcL,iBAAnC;AACD;;AAEDM,EAAAA,OAAO,CAACJ,IAAD,EAA8B;AACnC,WAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEmB,QAAdC,cAAc,GAAG;AACrB,WAAO,EAAP;AACD;;AAEc,QAATC,SAAS,CAACC,IAAD,EAA8BC,OAA9B,EAAoF;AAAA;;AACjG,UAAML,IAAI,GAAG,KAAKD,OAAL,CAAaK,IAAb,CAAb;AACA,UAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,IAAI,CAACJ,IAA1B,CAAnB;AACA,UAAMQ,UAAU,GAAG,CAAAF,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEG,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;;AACA,QAAI,eAAAN,IAAI,CAACO,IAAL,0DAAWf,IAAX,MAAoBC,sBAAGC,UAAH,CAAcc,YAAtC,EAAoD;AAClD;AACA,YAAMC,QAAQ,GAAGT,IAAI,CAACO,IAAtB;AACA,aAAO,0CAAiBE,QAAjB,EAA2BR,OAA3B,CAAP;AACD;;AACD,UAAMS,OAAO,GAAG,sDAAuBR,IAAvB,CAAhB;AACA,UAAMK,IAAI,GAAG,MAAMN,OAAO,CAACU,WAAR,CAAoBX,IAApB,EAA0BU,OAA1B,CAAnB;AACA,WAAO,KAAIE,mCAAJ,EAAmBX,OAAO,CAACY,WAAR,CAAoBb,IAApB,CAAnB,EAA8CJ,IAA9C,EAAoDQ,UAApD,EAAgEG,IAAhE,CAAP;AACD;;AAzByD","sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { FunctionTypeNode, Node, PropertySignature as PropertySignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class PropertySignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertySignature;\n }\n\n getName(node: PropertySignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(prop);\n const info = await context.getQuickInfo(prop.name);\n const displaySig = info?.body?.displayString || '';\n if (prop.type?.kind === ts.SyntaxKind.FunctionType) {\n // e.g. `propertySig: () => void;` inside interface\n const propType = prop.type as FunctionTypeNode;\n return typeNodeToSchema(propType, context);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(prop, typeStr);\n return new VariableSchema(context.getLocation(prop), name, displaySig, type);\n }\n}\n"]}
1
+ {"version":3,"names":["PropertySignature","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","transform","prop","context","info","getQuickInfo","displaySig","body","displayString","type","FunctionType","propType","typeNodeToSchema","typeStr","parseTypeFromQuickInfo","resolveType","VariableSchema","getLocation"],"sources":["property-signature.ts"],"sourcesContent":["import { SchemaNode, VariableSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { FunctionTypeNode, Node, PropertySignature as PropertySignatureNode } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class PropertySignature implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.PropertySignature;\n }\n\n getName(node: PropertySignatureNode) {\n return node.name.getText();\n }\n\n async getIdentifiers() {\n return [];\n }\n\n async transform(prop: PropertySignatureNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(prop);\n const info = await context.getQuickInfo(prop.name);\n const displaySig = info?.body?.displayString || '';\n if (prop.type?.kind === ts.SyntaxKind.FunctionType) {\n // e.g. `propertySig: () => void;` inside interface\n const propType = prop.type as FunctionTypeNode;\n return typeNodeToSchema(propType, context);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(prop, typeStr);\n return new VariableSchema(context.getLocation(prop), name, displaySig, type);\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;;AAEO,MAAMA,iBAAN,CAAqD;EAC1DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcL,iBAAnC;EACD;;EAEDM,OAAO,CAACJ,IAAD,EAA8B;IACnC,OAAOA,IAAI,CAACK,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEmB,MAAdC,cAAc,GAAG;IACrB,OAAO,EAAP;EACD;;EAEc,MAATC,SAAS,CAACC,IAAD,EAA8BC,OAA9B,EAAoF;IAAA;;IACjG,MAAML,IAAI,GAAG,KAAKD,OAAL,CAAaK,IAAb,CAAb;IACA,MAAME,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAR,CAAqBH,IAAI,CAACJ,IAA1B,CAAnB;IACA,MAAMQ,UAAU,GAAG,CAAAF,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEG,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;;IACA,IAAI,eAAAN,IAAI,CAACO,IAAL,0DAAWf,IAAX,MAAoBC,qBAAA,CAAGC,UAAH,CAAcc,YAAtC,EAAoD;MAClD;MACA,MAAMC,QAAQ,GAAGT,IAAI,CAACO,IAAtB;MACA,OAAO,IAAAG,oCAAA,EAAiBD,QAAjB,EAA2BR,OAA3B,CAAP;IACD;;IACD,MAAMU,OAAO,GAAG,IAAAC,gDAAA,EAAuBV,IAAvB,CAAhB;IACA,MAAMK,IAAI,GAAG,MAAMN,OAAO,CAACY,WAAR,CAAoBb,IAApB,EAA0BW,OAA1B,CAAnB;IACA,OAAO,KAAIG,mCAAJ,EAAmBb,OAAO,CAACc,WAAR,CAAoBf,IAApB,CAAnB,EAA8CJ,IAA9C,EAAoDQ,UAApD,EAAgEG,IAAhE,CAAP;EACD;;AAzByD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["source-file-transformer.ts"],"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","reduce","acc","current","item","find","exportName","id","push","transform","schemas","exportNode","computeSchema","Module","getLocation","ast","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKO,MAAMA,qBAAN,CAAyD;AAC9DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,UAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACC,UAAD,EAAyBC,OAAzB,EAA0D;AAC5E,UAAMC,OAAO,GAAG,KAAKC,WAAL,CAAiBH,UAAjB,CAAhB;AAEA,UAAMI,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBJ,OAAO,CAACK,GAAR,CAAab,IAAD,IAAgB;AAC1B,aAAOO,OAAO,CAACO,sBAAR,CAA+Bd,IAA/B,CAAP;AACD,KAFD,CADwB,CAA1B;AAMA,UAAMe,SAAS,GAAG,uBAAQL,WAAR,EAAqBM,MAArB,CAAgD,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atten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(context.getLocation(node), schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\n );\n }\n}\n"]}
1
+ {"version":3,"names":["SourceFileTransformer","predicate","node","kind","ts","SyntaxKind","SourceFile","getIdentifiers","sourceFile","context","exports","listExports","exportNames","Promise","all","map","getExportedIdentifiers","exportIds","flatten","reduce","acc","current","item","find","exportName","id","push","transform","schemas","pMapSeries","exportNode","computeSchema","Module","getLocation","ast","compact","statements","statement","ExportDeclaration","isExport","Boolean","modifiers","modifier","ExportKeyword"],"sources":["source-file-transformer.ts"],"sourcesContent":["import ts, { Node, SourceFile } from 'typescript';\nimport { compact, flatten } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport { Module } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { ExportIdentifier } from '../export-identifier';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\n\nexport class SourceFileTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.SourceFile;\n }\n\n async getIdentifiers(sourceFile: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(sourceFile);\n\n const exportNames = await Promise.all(\n exports.map((node: Node) => {\n return context.getExportedIdentifiers(node);\n })\n );\n\n const exportIds = flatten(exportNames).reduce<ExportIdentifier[]>((acc, current) => {\n const item = acc.find((exportName) => exportName.id === current.id);\n if (!item) acc.push(current);\n return acc;\n }, []);\n\n return exportIds;\n }\n\n async transform(node: SourceFile, context: SchemaExtractorContext) {\n const exports = this.listExports(node);\n const schemas = await pMapSeries(exports, (exportNode) => {\n return context.computeSchema(exportNode);\n });\n\n return new Module(context.getLocation(node), schemas);\n }\n\n /**\n * list all exports of a source file.\n */\n private listExports(ast: SourceFile): Node[] {\n return compact(\n ast.statements.map((statement) => {\n if (statement.kind === ts.SyntaxKind.ExportDeclaration) return statement;\n const isExport = Boolean(\n statement.modifiers?.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n })\n );\n\n // eslint-disable-next-line consistent-return\n if (!isExport) return;\n return statement;\n })\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKO,MAAMA,qBAAN,CAAyD;EAC9DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,UAAnC;EACD;;EAE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,UAAH,CAAciC,iBAArC,EAAwD,OAAOD,SAAP;MACxD,MAAME,QAAQ,GAAGC,OAAO,yBACtBH,SAAS,CAACI,SADY,yDACtB,qBAAqBlB,IAArB,CAA2BmB,QAAD,IAAc;QACtC,OAAOA,QAAQ,CAACvC,IAAT,KAAkBC,qBAAA,CAAGC,UAAH,CAAcsC,aAAvC;MACD,CAFD,CADsB,CAAxB,CAFgC,CAQhC;;MACA,IAAI,CAACJ,QAAL,EAAe;MACf,OAAOF,SAAP;IACD,CAXD,CADK,CAAP;EAcD;;AAlD6D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["type-alias.ts"],"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","info","getQuickInfo","displaySig","body","displayString","TypeSchema","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,oBAAN,CAAwD;AAC7DC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,oBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA6B;AAC/C,WAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;AACD;;AAEOC,EAAAA,OAAO,CAACX,IAAD,EAAqC;AAClD,WAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;AACD;;AAEc,QAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;AAAA;;AAChF,UAAMC,IAAI,GAAG,MAAM,0CAAiBF,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;AACA,UAAME,IAAI,GAAG,MAAMF,OAAO,CAACG,YAAR,CAAqBJ,SAAS,CAACN,IAA/B,CAAnB;AACA,UAAMW,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;AACA,WAAO,KAAIC,+BAAJ,EAAeP,OAAO,CAACQ,WAAR,CAAoBT,SAApB,CAAf,EAA+C,KAAKF,OAAL,CAAaE,SAAb,CAA/C,EAAwEE,IAAxE,EAA8EG,UAAU,IAAI,EAA5F,CAAP;AACD;;AAlB4D","sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const info = await context.getQuickInfo(typeAlias.name);\n const displaySig = info?.body?.displayString;\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig || '');\n }\n}\n"]}
1
+ {"version":3,"names":["TypeAliasTransformer","predicate","node","kind","ts","SyntaxKind","TypeAliasDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","getName","transform","typeAlias","context","type","typeNodeToSchema","info","getQuickInfo","displaySig","body","displayString","TypeSchema","getLocation"],"sources":["type-alias.ts"],"sourcesContent":["import ts, { Node, TypeAliasDeclaration } from 'typescript';\nimport { TypeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { typeNodeToSchema } from './utils/type-node-to-schema';\n\nexport class TypeAliasTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.TypeAliasDeclaration;\n }\n\n async getIdentifiers(node: TypeAliasDeclaration) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n private getName(node: TypeAliasDeclaration): string {\n return node.name.getText();\n }\n\n async transform(typeAlias: TypeAliasDeclaration, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(typeAlias.type, context);\n const info = await context.getQuickInfo(typeAlias.name);\n const displaySig = info?.body?.displayString;\n return new TypeSchema(context.getLocation(typeAlias), this.getName(typeAlias), type, displaySig || '');\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;;AAEO,MAAMA,oBAAN,CAAwD;EAC7DC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,oBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA6B;IAC/C,OAAO,CAAC,KAAIM,oCAAJ,EAAqBN,IAAI,CAACO,IAAL,CAAUC,OAAV,EAArB,EAA0CR,IAAI,CAACS,aAAL,GAAqBC,QAA/D,CAAD,CAAP;EACD;;EAEOC,OAAO,CAACX,IAAD,EAAqC;IAClD,OAAOA,IAAI,CAACO,IAAL,CAAUC,OAAV,EAAP;EACD;;EAEc,MAATI,SAAS,CAACC,SAAD,EAAkCC,OAAlC,EAAmE;IAAA;;IAChF,MAAMC,IAAI,GAAG,MAAM,IAAAC,oCAAA,EAAiBH,SAAS,CAACE,IAA3B,EAAiCD,OAAjC,CAAnB;IACA,MAAMG,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,SAAS,CAACN,IAA/B,CAAnB;IACA,MAAMY,UAAU,GAAGF,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEG,IAAT,+CAAG,WAAYC,aAA/B;IACA,OAAO,KAAIC,+BAAJ,EAAeR,OAAO,CAACS,WAAR,CAAoBV,SAApB,CAAf,EAA+C,KAAKF,OAAL,CAAaE,SAAb,CAA/C,EAAwEE,IAAxE,EAA8EI,UAAU,IAAI,EAA5F,CAAP;EACD;;AAlB4D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["get-params.ts"],"names":["getParams","parameterNodes","context","param","ParameterSchema","getLocation","name","getText","getParamType","initializer","undefined","type","info","getQuickInfo","parsed","TypeRefSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,eAAeA,SAAf,CACLC,cADK,EAELC,OAFK,EAGuB;AAC5B,SAAO,2BAAWD,cAAX,EAA2B,MAAOE,KAAP,IAAiB;AACjD,WAAO,KAAIC,oCAAJ,EACLF,OAAO,CAACG,WAAR,CAAoBF,KAApB,CADK,EAELA,KAAK,CAACG,IAAN,CAAWC,OAAX,EAFK,EAGL,MAAMC,YAAY,CAACL,KAAD,EAAQD,OAAR,CAHb,EAILC,KAAK,CAACM,WAAN,GAAoBN,KAAK,CAACM,WAAN,CAAkBF,OAAlB,EAApB,GAAkDG,SAJ7C,CAAP;AAMD,GAPM,CAAP;AAQD;AAED;AACA;AACA;;;AACA,eAAeF,YAAf,CAA4BL,KAA5B,EAAyDD,OAAzD,EAA+G;AAC7G,MAAIC,KAAK,CAACQ,IAAV,EAAgB;AACd,UAAMA,IAAI,GAAGR,KAAK,CAACQ,IAAnB;AACA,WAAO,0CAAiBA,IAAjB,EAAuBT,OAAvB,CAAP;AACD;;AACD,QAAMU,IAAI,GAAG,MAAMV,OAAO,CAACW,YAAR,CAAqBV,KAAK,CAACG,IAA3B,CAAnB;AACA,QAAMQ,MAAM,GAAG,sDAAuBF,IAAvB,CAAf;AACA,SAAO,KAAIG,kCAAJ,EAAkBb,OAAO,CAACG,WAAR,CAAoBF,KAApB,CAAlB,EAA8CW,MAAM,IAAI,KAAxD,CAAP;AACD","sourcesContent":["import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { ParameterDeclaration, NodeArray } from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n context.getLocation(param),\n param.name.getText(),\n await getParamType(param, context),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\n/**\n * @todo: probably not needed. just call context.resolveType instead.\n */\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new TypeRefSchema(context.getLocation(param), parsed || 'any');\n}\n"]}
1
+ {"version":3,"names":["getParams","parameterNodes","context","pMapSeries","param","ParameterSchema","getLocation","name","getText","getParamType","initializer","undefined","type","typeNodeToSchema","info","getQuickInfo","parsed","parseTypeFromQuickInfo","TypeRefSchema"],"sources":["get-params.ts"],"sourcesContent":["import { ParameterSchema, SchemaNode, TypeRefSchema } from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { ParameterDeclaration, NodeArray } from 'typescript';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\nimport { typeNodeToSchema } from './type-node-to-schema';\n\nexport async function getParams(\n parameterNodes: NodeArray<ParameterDeclaration>,\n context: SchemaExtractorContext\n): Promise<ParameterSchema[]> {\n return pMapSeries(parameterNodes, async (param) => {\n return new ParameterSchema(\n context.getLocation(param),\n param.name.getText(),\n await getParamType(param, context),\n param.initializer ? param.initializer.getText() : undefined\n );\n });\n}\n\n/**\n * @todo: probably not needed. just call context.resolveType instead.\n */\nasync function getParamType(param: ParameterDeclaration, context: SchemaExtractorContext): Promise<SchemaNode> {\n if (param.type) {\n const type = param.type;\n return typeNodeToSchema(type, context);\n }\n const info = await context.getQuickInfo(param.name);\n const parsed = parseTypeFromQuickInfo(info);\n return new TypeRefSchema(context.getLocation(param), parsed || 'any');\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;;AAEO,eAAeA,SAAf,CACLC,cADK,EAELC,OAFK,EAGuB;EAC5B,OAAO,IAAAC,qBAAA,EAAWF,cAAX,EAA2B,MAAOG,KAAP,IAAiB;IACjD,OAAO,KAAIC,oCAAJ,EACLH,OAAO,CAACI,WAAR,CAAoBF,KAApB,CADK,EAELA,KAAK,CAACG,IAAN,CAAWC,OAAX,EAFK,EAGL,MAAMC,YAAY,CAACL,KAAD,EAAQF,OAAR,CAHb,EAILE,KAAK,CAACM,WAAN,GAAoBN,KAAK,CAACM,WAAN,CAAkBF,OAAlB,EAApB,GAAkDG,SAJ7C,CAAP;EAMD,CAPM,CAAP;AAQD;AAED;AACA;AACA;;;AACA,eAAeF,YAAf,CAA4BL,KAA5B,EAAyDF,OAAzD,EAA+G;EAC7G,IAAIE,KAAK,CAACQ,IAAV,EAAgB;IACd,MAAMA,IAAI,GAAGR,KAAK,CAACQ,IAAnB;IACA,OAAO,IAAAC,oCAAA,EAAiBD,IAAjB,EAAuBV,OAAvB,CAAP;EACD;;EACD,MAAMY,IAAI,GAAG,MAAMZ,OAAO,CAACa,YAAR,CAAqBX,KAAK,CAACG,IAA3B,CAAnB;EACA,MAAMS,MAAM,GAAG,IAAAC,gDAAA,EAAuBH,IAAvB,CAAf;EACA,OAAO,KAAII,kCAAJ,EAAkBhB,OAAO,CAACI,WAAR,CAAoBF,KAApB,CAAlB,EAA8CY,MAAM,IAAI,KAAxD,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["parse-type-from-quick-info.ts"],"names":["parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","Error","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAgCC,SAAhC,EAA2F;AAAA;;AAChG,MAAI,EAACA,SAAD,aAACA,SAAD,kCAACA,SAAS,CAAEC,IAAZ,4CAAC,gBAAiBC,aAAlB,CAAJ,EAAqC,OAAO,EAAP;AACrC,QAAMA,aAAa,GAAGF,SAAS,CAACC,IAAV,CAAeC,aAArC;AACA,QAAMC,YAAY,GAAGD,aAAa,CAACE,KAAd,CAAo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,GAAGjB,sBAAsB,CAACC,SAAD,CAAtC;AACA,QAAMiB,KAAK,GAAGD,OAAO,CAACZ,KAAR,CAAc,IAAd,CAAd;AACA,SAAOa,KAAK,CAACA,KAAK,CAACR,MAAN,GAAe,CAAhB,CAAL,CAAwBD,IAAxB,EAAP;AACD","sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n throw new Error(`quickinfo of a function below was not implemented.\\n${displayString}`);\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"]}
1
+ {"version":3,"names":["parseTypeFromQuickInfo","quickInfo","body","displayString","splitByColon","split","kind","tail","join","trim","length","Error","firstLine","splitBySpace","typeName","splitByEqual","parseReturnTypeFromQuickInfo","typeStr","array"],"sources":["parse-type-from-quick-info.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n\n/**\n * try to parse the type from the quickinfo.\n * this is an error-prone process, we do our best here.\n *\n * an example of a function with many \":\"\n * `export function getObj(a: string, func: (b: number) => {}) { return { a: 1, b: 2 } };`\n * which produce the following quickinfo:\n * ```ts\n * function getObj(a: string, func: (b: number) => {}): {\n * a: number;\n * b: number;\n * }\n * ```\n *\n * some examples of quickinfo:\n *\n * function ts.signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags): SymbolDisplayPart[]\n *\n * const enum ts.TypeFormatFlags\n *\n * (method) ts.TypeChecker.writeSignature(signature: Signature, enclosingDeclaration?: Node | undefined, flags?: TypeFormatFlags | undefined, kind?: SignatureKind | undefined, writer?: EmitTextWriter | undefined): string\n *\n * const obj: {\n * a: number;\n * b: number;\n * }\n *\n * function getObj(a: string): {\n * a: number;\n * b: number;\n * }\n */\nexport function parseTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo?.body?.displayString) return '';\n const displayString = quickInfo.body.displayString;\n const splitByColon = displayString.split(':');\n switch (quickInfo.body.kind) {\n case 'const':\n case 'property':\n case 'let':\n case 'var': {\n const [, ...tail] = splitByColon;\n return tail.join(':').trim();\n }\n case 'method':\n case 'function': {\n const split = displayString.split('): ');\n if (split.length !== 2) {\n throw new Error(`quickinfo of a function below was not implemented.\\n${displayString}`);\n }\n return split[1].trim();\n }\n case 'alias': {\n // e.g. (alias) class BuilderService\\nimport BuilderService\n // e.g. '(alias) type Serializable = {\\n' +\n // ' toString(): string;\\n' +\n // '}\\n' +\n // 'import Serializable'\n const firstLine = displayString.split('\\n')[0];\n const splitBySpace = firstLine.trim().split(' ');\n // first two are alias keyword and alias type\n const [, , typeName] = splitBySpace;\n return typeName;\n }\n case 'type': {\n // e.g. `type TaskSlot = SlotRegistry<BuildTask[]>`\n const splitByEqual = displayString.split('=');\n const [, ...tail] = splitByEqual;\n return tail.join('=').trim();\n }\n default:\n return splitByColon[splitByColon.length - 1].trim();\n }\n}\n\nexport function parseReturnTypeFromQuickInfo(quickInfo: protocol.QuickInfoResponse | undefined): string {\n if (!quickInfo) return '';\n const typeStr = parseTypeFromQuickInfo(quickInfo);\n const array = typeStr.split('=>');\n return array[array.length - 1].trim();\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAgCC,SAAhC,EAA2F;EAAA;;EAChG,IAAI,EAACA,SAAD,aAACA,SAAD,kCAACA,SAAS,CAAEC,IAAZ,4CAAC,gBAAiBC,aAAlB,CAAJ,EAAqC,OAAO,EAAP;EACrC,MAAMA,aAAa,GAAGF,SAAS,CAACC,IAAV,CAAeC,aAArC;EACA,MAAMC,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gB,OAAO,EAAP;EAChB,MAAMgB,OAAO,GAAGjB,sBAAsB,CAACC,SAAD,CAAtC;EACA,MAAMiB,KAAK,GAAGD,OAAO,CAACZ,KAAR,CAAc,IAAd,CAAd;EACA,OAAOa,KAAK,CAACA,KAAK,CAACR,MAAN,GAAe,CAAhB,CAAL,CAAwBD,IAAxB,EAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["to-function-schema.ts"],"names":["toFunctionLikeSchema","node","context","name","getText","info","getQuickInfo","returnTypeStr","displaySig","body","displayString","args","parameters","returnType","resolveType","modifiers","map","modifier","location","getLocation","FunctionLikeSchema"],"mappings":";;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,eAAeA,oBAAf,CAAoCC,IAApC,EAAgEC,OAAhE,EAAiG;AAAA;;AACtG,QAAMC,IAAI,GAAG,eAAAF,IAAI,CAACE,IAAL,0DAAWC,OAAX,OAAwB,EAArC,CADsG,CAEtG;;AACA,QAAMC,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,IAAI,CAACE,IAA1B,CAAnB;AACA,QAAMI,aAAa,GAAG,sDAAuBF,IAAvB,CAAtB;AACA,QAAMG,UAAU,GAAG,CAAAH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEI,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;AACA,QAAMC,IAAI,GAAG,MAAM,4BAAUV,IAAI,CAACW,UAAf,EAA2BV,OAA3B,CAAnB;AACA,QAAMW,UAAU,GAAG,MAAMX,OAAO,CAACY,WAAR,CAAoBb,IAApB,EAA0BM,aAA1B,CAAzB;AACA,QAAMQ,SAAS,GAAG,oBAAAd,IAAI,CAACc,SAAL,oEAAgBC,GAAhB,CAAqBC,QAAD,IAAcA,QAAQ,CAACb,OAAT,EAAlC,MAAyD,EAA3E;AACA,QAAMc,QAAQ,GAAGhB,OAAO,CAACiB,WAAR,CAAoBlB,IAApB,CAAjB;AAEA,SAAO,KAAImB,uCAAJ,EAAuBF,QAAvB,EAAiCf,IAAjC,EAAuCQ,IAAvC,EAA6CE,UAA7C,EAAyDL,UAAzD,EAAqEO,SAArE,CAAP;AACD","sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\n\nexport async function toFunctionLikeSchema(node: SignatureDeclaration, context: SchemaExtractorContext) {\n const name = node.name?.getText() || '';\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(node.name!);\n const returnTypeStr = parseTypeFromQuickInfo(info);\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const location = context.getLocation(node);\n\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[]);\n}\n"]}
1
+ {"version":3,"names":["toFunctionLikeSchema","node","context","name","getText","info","getQuickInfo","returnTypeStr","parseTypeFromQuickInfo","displaySig","body","displayString","args","getParams","parameters","returnType","resolveType","modifiers","map","modifier","location","getLocation","FunctionLikeSchema"],"sources":["to-function-schema.ts"],"sourcesContent":["import { SignatureDeclaration } from 'typescript';\nimport { FunctionLikeSchema, Modifier } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\nimport { parseTypeFromQuickInfo } from './parse-type-from-quick-info';\n\nexport async function toFunctionLikeSchema(node: SignatureDeclaration, context: SchemaExtractorContext) {\n const name = node.name?.getText() || '';\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const info = await context.getQuickInfo(node.name!);\n const returnTypeStr = parseTypeFromQuickInfo(info);\n const displaySig = info?.body?.displayString || '';\n const args = await getParams(node.parameters, context);\n const returnType = await context.resolveType(node, returnTypeStr);\n const modifiers = node.modifiers?.map((modifier) => modifier.getText()) || [];\n const location = context.getLocation(node);\n\n return new FunctionLikeSchema(location, name, args, returnType, displaySig, modifiers as Modifier[]);\n}\n"],"mappings":";;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,eAAeA,oBAAf,CAAoCC,IAApC,EAAgEC,OAAhE,EAAiG;EAAA;;EACtG,MAAMC,IAAI,GAAG,eAAAF,IAAI,CAACE,IAAL,0DAAWC,OAAX,OAAwB,EAArC,CADsG,CAEtG;;EACA,MAAMC,IAAI,GAAG,MAAMH,OAAO,CAACI,YAAR,CAAqBL,IAAI,CAACE,IAA1B,CAAnB;EACA,MAAMI,aAAa,GAAG,IAAAC,gDAAA,EAAuBH,IAAvB,CAAtB;EACA,MAAMI,UAAU,GAAG,CAAAJ,IAAI,SAAJ,IAAAA,IAAI,WAAJ,0BAAAA,IAAI,CAAEK,IAAN,0DAAYC,aAAZ,KAA6B,EAAhD;EACA,MAAMC,IAAI,GAAG,MAAM,IAAAC,sBAAA,EAAUZ,IAAI,CAACa,UAAf,EAA2BZ,OAA3B,CAAnB;EACA,MAAMa,UAAU,GAAG,MAAMb,OAAO,CAACc,WAAR,CAAoBf,IAApB,EAA0BM,aAA1B,CAAzB;EACA,MAAMU,SAAS,GAAG,oBAAAhB,IAAI,CAACgB,SAAL,oEAAgBC,GAAhB,CAAqBC,QAAD,IAAcA,QAAQ,CAACf,OAAT,EAAlC,MAAyD,EAA3E;EACA,MAAMgB,QAAQ,GAAGlB,OAAO,CAACmB,WAAR,CAAoBpB,IAApB,CAAjB;EAEA,OAAO,KAAIqB,uCAAJ,EAAuBF,QAAvB,EAAiCjB,IAAjC,EAAuCS,IAAvC,EAA6CG,UAA7C,EAAyDN,UAAzD,EAAqEQ,SAArE,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["type-node-to-schema.ts"],"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","TypePredicate","ConstructorType","NamedTupleMember","OptionalType","RestType","ConditionalType","InferType","ParenthesizedType","ThisType","IndexedAccessType","MappedType","TemplateLiteralType","TemplateLiteralTypeSpan","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","Error","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","computeSchema","TypeLiteralSchema","name","typeName","resolveType","params","parameters","returnType","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAcA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAaA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAC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AAxE,CAAN;AARJ;AAUD;;AAED,eAAehE,SAAf,CAAyB5B,IAAzB,EAA8CC,OAA9C,EAA+E;AAC7E,QAAMgG,QAAQ,GAAG,MAAM,2BAAWjG,IAAI,CAACiG,QAAhB,EAA0B,MAAOC,IAAP,IAAgB;AAC/D,UAAM5B,UAAU,GAAG,MAAMvE,gBAAgB,CAACmG,IAAD,EAAOjG,OAAP,CAAzC;AACA,WAAOqE,UAAP;AACD,GAHsB,CAAvB;AAIA,SAAO,KAAI6B,oCAAJ,EAAoBlG,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAApB,EAA+CiG,QAA/C,CAAP;AACD","sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.TypePredicate:\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.ConditionalType:\n case SyntaxKind.InferType:\n case SyntaxKind.ParenthesizedType:\n case SyntaxKind.ThisType:\n case SyntaxKind.IndexedAccessType:\n case SyntaxKind.MappedType:\n case SyntaxKind.TemplateLiteralType:\n case SyntaxKind.TemplateLiteralTypeSpan:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n throw new Error(`TypeNode \"${SyntaxKind[node.kind]}\" was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node \"${SyntaxKind[node.kind]}\" is not a TypeNode.\ncontext: ${node.getText()}`);\n }\n}\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n return new FunctionLikeSchema(location, name, params, returnType, '');\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n"]}
1
+ {"version":3,"names":["typeNodeToSchema","node","context","location","getLocation","isKeywordType","KeywordTypeSchema","getText","kind","SyntaxKind","IntersectionType","intersectionType","UnionType","unionType","TypeReference","typeReference","TypeLiteral","typeLiteral","LiteralType","LiteralTypeSchema","FunctionType","functionType","TypeQuery","typeQuery","ArrayType","arrayType","TypeOperator","typeOperator","TupleType","tupleType","TypePredicate","ConstructorType","NamedTupleMember","OptionalType","RestType","ConditionalType","InferType","ParenthesizedType","ThisType","IndexedAccessType","MappedType","TemplateLiteralType","TemplateLiteralTypeSpan","ImportType","ExpressionWithTypeArguments","JSDocTypeExpression","JSDocAllType","JSDocUnknownType","JSDocNonNullableType","JSDocNullableType","JSDocOptionalType","JSDocFunctionType","JSDocVariadicType","JSDocNamepathType","JSDocSignature","JSDocTypeLiteral","Error","AnyKeyword","BigIntKeyword","BooleanKeyword","IntrinsicKeyword","NeverKeyword","NumberKeyword","ObjectKeyword","StringKeyword","SymbolKeyword","UndefinedKeyword","UnknownKeyword","VoidKeyword","types","pMapSeries","type","typeSchema","TypeIntersectionSchema","TypeUnionSchema","members","member","computeSchema","TypeLiteralSchema","name","typeName","resolveType","params","getParams","parameters","returnType","FunctionLikeSchema","displaySig","getQuickInfoDisplayString","exprName","TypeQuerySchema","elementType","TypeArraySchema","operatorName","getOperatorName","operator","TypeOperatorSchema","KeyOfKeyword","UniqueKeyword","ReadonlyKeyword","elements","elem","TupleTypeSchema"],"sources":["type-node-to-schema.ts"],"sourcesContent":["import {\n TypeNode,\n SyntaxKind,\n KeywordTypeNode,\n FunctionTypeNode,\n TypeQueryNode,\n TypeReferenceNode,\n ArrayTypeNode,\n TypeOperatorNode,\n TupleTypeNode,\n IntersectionTypeNode,\n UnionTypeNode,\n TypeLiteralNode,\n} from 'typescript';\nimport {\n SchemaNode,\n TypeIntersectionSchema,\n TypeUnionSchema,\n TypeLiteralSchema,\n TypeQuerySchema,\n LiteralTypeSchema,\n KeywordTypeSchema,\n TypeArraySchema,\n TypeOperatorSchema,\n TupleTypeSchema,\n FunctionLikeSchema,\n} from '@teambit/semantics.entities.semantic-schema';\nimport pMapSeries from 'p-map-series';\nimport { SchemaExtractorContext } from '../../schema-extractor-context';\nimport { getParams } from './get-params';\n\n// eslint-disable-next-line complexity\nexport async function typeNodeToSchema(node: TypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const location = context.getLocation(node);\n if (isKeywordType(node)) {\n return new KeywordTypeSchema(location, node.getText());\n }\n switch (node.kind) {\n case SyntaxKind.IntersectionType:\n return intersectionType(node as IntersectionTypeNode, context);\n case SyntaxKind.UnionType:\n return unionType(node as UnionTypeNode, context);\n case SyntaxKind.TypeReference:\n return typeReference(node as TypeReferenceNode, context);\n case SyntaxKind.TypeLiteral:\n return typeLiteral(node as TypeLiteralNode, context);\n case SyntaxKind.LiteralType: // e.g. string/boolean\n return new LiteralTypeSchema(location, node.getText());\n case SyntaxKind.FunctionType:\n return functionType(node as FunctionTypeNode, context);\n case SyntaxKind.TypeQuery:\n return typeQuery(node as TypeQueryNode, context);\n case SyntaxKind.ArrayType:\n return arrayType(node as ArrayTypeNode, context);\n case SyntaxKind.TypeOperator:\n return typeOperator(node as TypeOperatorNode, context);\n case SyntaxKind.TupleType:\n return tupleType(node as TupleTypeNode, context);\n case SyntaxKind.TypePredicate:\n case SyntaxKind.ConstructorType:\n case SyntaxKind.NamedTupleMember:\n case SyntaxKind.OptionalType:\n case SyntaxKind.RestType:\n case SyntaxKind.ConditionalType:\n case SyntaxKind.InferType:\n case SyntaxKind.ParenthesizedType:\n case SyntaxKind.ThisType:\n case SyntaxKind.IndexedAccessType:\n case SyntaxKind.MappedType:\n case SyntaxKind.TemplateLiteralType:\n case SyntaxKind.TemplateLiteralTypeSpan:\n case SyntaxKind.ImportType:\n case SyntaxKind.ExpressionWithTypeArguments:\n case SyntaxKind.JSDocTypeExpression:\n case SyntaxKind.JSDocAllType:\n case SyntaxKind.JSDocUnknownType:\n case SyntaxKind.JSDocNonNullableType:\n case SyntaxKind.JSDocNullableType:\n case SyntaxKind.JSDocOptionalType:\n case SyntaxKind.JSDocFunctionType:\n case SyntaxKind.JSDocVariadicType:\n case SyntaxKind.JSDocNamepathType:\n case SyntaxKind.JSDocSignature:\n case SyntaxKind.JSDocTypeLiteral:\n throw new Error(`TypeNode \"${SyntaxKind[node.kind]}\" was not implemented yet.\ncontext: ${node.getText()}`);\n default:\n throw new Error(`Node \"${SyntaxKind[node.kind]}\" is not a TypeNode.\ncontext: ${node.getText()}`);\n }\n}\n\n/**\n * whether it's kind of `ts.KeywordTypeSyntaxKind`\n */\nfunction isKeywordType(node: TypeNode): node is KeywordTypeNode {\n switch (node.kind) {\n case SyntaxKind.AnyKeyword:\n case SyntaxKind.BigIntKeyword:\n case SyntaxKind.BooleanKeyword:\n case SyntaxKind.IntrinsicKeyword:\n case SyntaxKind.NeverKeyword:\n case SyntaxKind.NumberKeyword:\n case SyntaxKind.ObjectKeyword:\n case SyntaxKind.StringKeyword:\n case SyntaxKind.SymbolKeyword:\n case SyntaxKind.UndefinedKeyword:\n case SyntaxKind.UnknownKeyword:\n case SyntaxKind.VoidKeyword:\n return true;\n default:\n return false;\n }\n}\n\nasync function intersectionType(node: IntersectionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeIntersectionSchema(location, types);\n}\n\nasync function unionType(node: UnionTypeNode, context: SchemaExtractorContext) {\n const types = await pMapSeries(node.types, async (type) => {\n const typeSchema = await typeNodeToSchema(type, context);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeUnionSchema(location, types);\n}\n\n/**\n * not to be confused with \"LiteralType\", which is string/boolean/null.\n * this \"TypeLiteral\" is an object with properties, such as: `{ a: string; b: number }`, similar to Interface.\n */\nasync function typeLiteral(node: TypeLiteralNode, context: SchemaExtractorContext) {\n const members = await pMapSeries(node.members, async (member) => {\n const typeSchema = await context.computeSchema(member);\n return typeSchema;\n });\n const location = context.getLocation(node);\n return new TypeLiteralSchema(location, members);\n}\n\n/**\n * In the following example, `AriaButtonProps` is a type reference\n * ```ts\n * import type { AriaButtonProps } from '@react-types/button';\n * export type ButtonProps = AriaButtonProps & { a: string };\n * ```\n */\nasync function typeReference(node: TypeReferenceNode, context: SchemaExtractorContext) {\n const name = node.typeName.getText();\n const type = await context.resolveType(node, name, false);\n return type;\n}\n\nasync function functionType(node: FunctionTypeNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = node.name?.getText() || '';\n const params = await getParams(node.parameters, context);\n const returnType = await typeNodeToSchema(node.type, context);\n const location = context.getLocation(node);\n return new FunctionLikeSchema(location, name, params, returnType, '');\n}\n\n/**\n * e.g. `typeof Foo`\n */\nasync function typeQuery(node: TypeQueryNode, context: SchemaExtractorContext) {\n const displaySig = await context.getQuickInfoDisplayString(node.exprName);\n const type = await context.resolveType(node.exprName, node.exprName.getText(), false);\n const location = context.getLocation(node);\n return new TypeQuerySchema(location, type, displaySig);\n}\n\nasync function arrayType(node: ArrayTypeNode, context: SchemaExtractorContext) {\n const type = await typeNodeToSchema(node.elementType, context);\n const location = context.getLocation(node);\n return new TypeArraySchema(location, type);\n}\n\n/**\n * e.g. keyof typeof Foo\n */\nasync function typeOperator(node: TypeOperatorNode, context: SchemaExtractorContext) {\n const operatorName = getOperatorName(node.operator);\n const type = await typeNodeToSchema(node.type, context);\n return new TypeOperatorSchema(context.getLocation(node), operatorName, type);\n}\n\nfunction getOperatorName(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {\n switch (operator) {\n case SyntaxKind.KeyOfKeyword:\n return 'keyof';\n case SyntaxKind.UniqueKeyword:\n return 'unique';\n case SyntaxKind.ReadonlyKeyword:\n return 'readonly';\n default:\n throw new Error(`getOperatorName: unable to find operator name for ${operator}`);\n }\n}\n\nasync function tupleType(node: TupleTypeNode, context: SchemaExtractorContext) {\n const elements = await pMapSeries(node.elements, async (elem) => {\n const typeSchema = await typeNodeToSchema(elem, context);\n return typeSchema;\n });\n return new TupleTypeSchema(context.getLocation(node), elements);\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAcA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAaA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACO,eAAeA,gBAAf,CAAgCC,IAAhC,EAAgDC,OAAhD,EAAsG;EAC3G,MAAMC,QAAQ,GAAGD,OAAO,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P;AACD;;AAED,SAASuB,eAAT,CAAyBC,QAAzB,EAAoH;EAClH,QAAQA,QAAR;IACE,KAAKtF,wBAAA,CAAWwF,YAAhB;MACE,OAAO,OAAP;;IACF,KAAKxF,wBAAA,CAAWyF,aAAhB;MACE,OAAO,QAAP;;IACF,KAAKzF,wBAAA,CAAW0F,eAAhB;MACE,OAAO,UAAP;;IACF;MACE,MAAM,IAAI3C,KAAJ,CAAW,qDAAoDuC,QAAS,EAAxE,CAAN;EARJ;AAUD;;AAED,eAAelE,SAAf,CAAyB5B,IAAzB,EAA8CC,OAA9C,EAA+E;EAC7E,MAAMkG,QAAQ,GAAG,MAAM,IAAA9B,qBAAA,EAAWrE,IAAI,CAACmG,QAAhB,EAA0B,MAAOC,IAAP,IAAgB;IAC/D,MAAM7B,UAAU,GAAG,MAAMxE,gBAAgB,CAACqG,IAAD,EAAOnG,OAAP,CAAzC;IACA,OAAOsE,UAAP;EACD,CAHsB,CAAvB;EAIA,OAAO,KAAI8B,oCAAJ,EAAoBpG,OAAO,CAACE,WAAR,CAAoBH,IAApB,CAApB,EAA+CmG,QAA/C,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["variable-declaration.ts"],"names":["VariableDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","varDec","context","info","getQuickInfo","displaySig","body","displayString","location","getLocation","initializer","ArrowFunction","args","parameters","typeStr","returnType","resolveType","FunctionLikeSchema","type","VariableSchema"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAuD;AAC5DC,EAAAA,SAAS,C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AAG,sDAAuBX,IAAvB,CAAhB;AACA,UAAMe,IAAI,GAAG,MAAMhB,OAAO,CAACc,WAAR,CAAoBf,MAApB,EAA4Ba,OAA5B,CAAnB;AACA,WAAO,KAAIK,mCAAJ,EAAmBX,QAAnB,EAA6Bd,IAA7B,EAAmCW,UAAnC,EAA+Ca,IAA/C,CAAP;AACD;;AA3B2D","sourcesContent":["import { SchemaNode, VariableSchema, FunctionLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, VariableDeclaration as VariableDeclarationNode, ArrowFunction } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\nimport { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class VariableDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableDeclaration;\n }\n\n getName(node: VariableDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: VariableDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(varDec: VariableDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(varDec);\n const info = await context.getQuickInfo(varDec.name);\n const displaySig = info?.body?.displayString || '';\n const location = context.getLocation(varDec);\n if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {\n const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);\n const typeStr = parseReturnTypeFromQuickInfo(info);\n const returnType = await context.resolveType(varDec, typeStr);\n return new FunctionLikeSchema(location, name, args, returnType, displaySig);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableSchema(location, name, displaySig, type);\n }\n}\n"]}
1
+ {"version":3,"names":["VariableDeclaration","predicate","node","kind","ts","SyntaxKind","getName","name","getText","getIdentifiers","ExportIdentifier","getSourceFile","fileName","transform","varDec","context","info","getQuickInfo","displaySig","body","displayString","location","getLocation","initializer","ArrowFunction","args","getParams","parameters","typeStr","parseReturnTypeFromQuickInfo","returnType","resolveType","FunctionLikeSchema","parseTypeFromQuickInfo","type","VariableSchema"],"sources":["variable-declaration.ts"],"sourcesContent":["import { SchemaNode, VariableSchema, FunctionLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport ts, { Node, VariableDeclaration as VariableDeclarationNode, ArrowFunction } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { getParams } from './utils/get-params';\nimport { parseReturnTypeFromQuickInfo, parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\n\nexport class VariableDeclaration implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableDeclaration;\n }\n\n getName(node: VariableDeclarationNode) {\n return node.name.getText();\n }\n\n async getIdentifiers(node: VariableDeclarationNode) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(varDec: VariableDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const name = this.getName(varDec);\n const info = await context.getQuickInfo(varDec.name);\n const displaySig = info?.body?.displayString || '';\n const location = context.getLocation(varDec);\n if (varDec.initializer?.kind === ts.SyntaxKind.ArrowFunction) {\n const args = await getParams((varDec.initializer as ArrowFunction).parameters, context);\n const typeStr = parseReturnTypeFromQuickInfo(info);\n const returnType = await context.resolveType(varDec, typeStr);\n return new FunctionLikeSchema(location, name, args, returnType, displaySig);\n }\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(varDec, typeStr);\n return new VariableSchema(location, name, displaySig, type);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA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,MAAMf,OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAzB;MACA,OAAO,KAAII,uCAAJ,EAAuBX,QAAvB,EAAiCd,IAAjC,EAAuCkB,IAAvC,EAA6CK,UAA7C,EAAyDZ,UAAzD,CAAP;IACD;;IACD,MAAMU,OAAO,GAAG,IAAAK,gDAAA,EAAuBjB,IAAvB,CAAhB;IACA,MAAMkB,IAAI,GAAG,MAAMnB,OAAO,CAACgB,WAAR,CAAoBjB,MAApB,EAA4Bc,OAA5B,CAAnB;IACA,OAAO,KAAIO,mCAAJ,EAAmBd,QAAnB,EAA6Bd,IAA7B,EAAmCW,UAAnC,EAA+CgB,IAA/C,CAAP;EACD;;AA3B2D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["variable-statement.ts"],"names":["VariableStatementTransformer","predicate","node","kind","ts","SyntaxKind","VariableStatement","getIdentifiers","declarationList","declarations","map","dec","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","schemas","schema","visitDefinition","Module","getLocation"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAgE;AACrEC,EAAAA,SAAS,CAACC,IAAD,EAAa;AACpB,WAAOA,IAAI,CAACC,IAAL,KAAcC,sBAAGC,UAAH,CAAcC,iBAAnC;AACD;;AAEmB,QAAdC,cAAc,CAACL,IAAD,EAA0B;AAC5C,WAAOA,IAAI,CAACM,eAAL,CAAqBC,YAArB,CAAkCC,GAAlC,CAAuCC,GAAD,IAAS;AACpD,aAAO,KAAIC,oCAAJ,EAAqBD,GAAG,CAACE,IAAJ,CAASC,OAAT,EAArB,EAAyCH,GAAG,CAACI,aAAJ,GAAoBC,QAA7D,CAAP;AACD,KAFM,CAAP;AAGD;;AAEc,QAATC,SAAS,CAACf,IAAD,EAA0BgB,OAA1B,EAAgF;AAC7F,UAAMC,OAAO,GAAG,MAAM,2BAAWjB,IAAI,CAACM,eAAL,CAAqBC,YAAhC,EAA8C,MAAOE,GAAP,IAAe;AACjF;AACA,YAAMS,MAAM,GAAG,MAAMF,OAAO,CAACG,eAAR,CAAwBV,GAAG,CAACE,IAA5B,CAArB;AACA,aAAOO,MAAP;AACD,KAJqB,CAAtB;AAKA,WAAO,KAAIE,2BAAJ,EAAWJ,OAAO,CAACK,WAAR,CAAoBrB,IAApB,CAAX,EAAsC,uBAAQiB,OAAR,CAAtC,CAAP;AACD;;AAlBoE","sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport ts, { Node, VariableStatement } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * variable statement is a collection of variable declarations.\n * e.g. `export const a = 1, b = () => {}, c = {};`\n */\nexport class VariableStatementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableStatement;\n }\n\n async getIdentifiers(node: VariableStatement) {\n return node.declarationList.declarations.map((dec) => {\n return new ExportIdentifier(dec.name.getText(), dec.getSourceFile().fileName);\n });\n }\n\n async transform(node: VariableStatement, context: SchemaExtractorContext): Promise<SchemaNode> {\n const schemas = await pMapSeries(node.declarationList.declarations, async (dec) => {\n // this will get the schema from variable-declaration\n const schema = await context.visitDefinition(dec.name);\n return schema;\n });\n return new Module(context.getLocation(node), compact(schemas));\n }\n}\n"]}
1
+ {"version":3,"names":["VariableStatementTransformer","predicate","node","kind","ts","SyntaxKind","VariableStatement","getIdentifiers","declarationList","declarations","map","dec","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","schemas","pMapSeries","schema","visitDefinition","Module","getLocation","compact"],"sources":["variable-statement.ts"],"sourcesContent":["import { SchemaNode, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { compact } from 'lodash';\nimport pMapSeries from 'p-map-series';\nimport ts, { Node, VariableStatement } from 'typescript';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\n\n/**\n * variable statement is a collection of variable declarations.\n * e.g. `export const a = 1, b = () => {}, c = {};`\n */\nexport class VariableStatementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.VariableStatement;\n }\n\n async getIdentifiers(node: VariableStatement) {\n return node.declarationList.declarations.map((dec) => {\n return new ExportIdentifier(dec.name.getText(), dec.getSourceFile().fileName);\n });\n }\n\n async transform(node: VariableStatement, context: SchemaExtractorContext): Promise<SchemaNode> {\n const schemas = await pMapSeries(node.declarationList.declarations, async (dec) => {\n // this will get the schema from variable-declaration\n const schema = await context.visitDefinition(dec.name);\n return schema;\n });\n return new Module(context.getLocation(node), compact(schemas));\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAgE;EACrEC,SAAS,CAACC,IAAD,EAAa;IACpB,OAAOA,IAAI,CAACC,IAAL,KAAcC,qBAAA,CAAGC,UAAH,CAAcC,iBAAnC;EACD;;EAEmB,MAAdC,cAAc,CAACL,IAAD,EAA0B;IAC5C,OAAOA,IAAI,CAACM,eAAL,CAAqBC,YAArB,CAAkCC,GAAlC,CAAuCC,GAAD,IAAS;MACpD,OAAO,KAAIC,oCAAJ,EAAqBD,GAAG,CAACE,IAAJ,CAASC,OAAT,EAArB,EAAyCH,GAAG,CAACI,aAAJ,GAAoBC,QAA7D,CAAP;IACD,CAFM,CAAP;EAGD;;EAEc,MAATC,SAAS,CAACf,IAAD,EAA0BgB,OAA1B,EAAgF;IAC7F,MAAMC,OAAO,GAAG,MAAM,IAAAC,qBAAA,EAAWlB,IAAI,CAACM,eAAL,CAAqBC,YAAhC,EAA8C,MAAOE,GAAP,IAAe;MACjF;MACA,MAAMU,MAAM,GAAG,MAAMH,OAAO,CAACI,eAAR,CAAwBX,GAAG,CAACE,IAA5B,CAArB;MACA,OAAOQ,MAAP;IACD,CAJqB,CAAtB;IAKA,OAAO,KAAIE,2BAAJ,EAAWL,OAAO,CAACM,WAAR,CAAoBtB,IAApB,CAAX,EAAsC,IAAAuB,iBAAA,EAAQN,OAAR,CAAtC,CAAP;EACD;;AAlBoE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.aspect.ts"],"names":["TypescriptAspect","Aspect","create","id"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,gBAAgB,GAAGC,kBAAOC,MAAP,CAAc;AAC5CC,EAAAA,EAAE,EAAE;AADwC,CAAd,CAAzB","sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const TypescriptAspect = Aspect.create({\n id: 'teambit.typescript/typescript',\n});\n"]}
1
+ {"version":3,"names":["TypescriptAspect","Aspect","create","id"],"sources":["typescript.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const TypescriptAspect = Aspect.create({\n id: 'teambit.typescript/typescript',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,gBAAgB,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EAC5CC,EAAE,EAAE;AADwC,CAAd,CAAzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.compiler.ts"],"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","postBuild","Promise","all","packageJson","PackageJsonFile","loadFromCapsuleSync","packageJsonObject","types","write","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"mappings":";;;;;;;;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,mBAAGe,SAAH,CAAavG,gBAAKwB,IAAL,CAAUoE,GAAV,EAAe,eAAf,CAAb,EAA8CU,WAA9C,CAAlB,CAAZ,CAAN;AACD;;AAEO5I,EAAAA,iBAAiB,CAACJ,QAAD,EAAW;AAClC,WAAOkJ,IAAI,CAACC,SAAL,CAAenJ,QAAf,EAAyBwG,SAAzB,EAAoC,CAApC,CAAP;AACD;;AAEO3E,EAAAA,kBAAkB,CAACpB,QAAD,EAA2B;AACnD,QAAI,CAAC,KAAKD,eAAL,CAAqBC,QAArB,CAAL,EAAqC,OAAOA,QAAP;;AACrC,UAAM2I,aAAa,GAAG1G,gBAAK2G,OAAL,CAAa5I,QAAb,CAAtB;;AACA,WAAOA,QAAQ,CAAC0G,OAAT,CAAiB,IAAImC,MAAJ,CAAY,GAAEF,aAAc,GAA5B,CAAjB,EAAkD,KAAlD,CAAP,CAHmD,CAGc;AAClE;;AAEDG,EAAAA,OAAO,GAAG;AACR,WAAO,KAAK5J,QAAL,CAAc4J,OAArB;AACD;;AAhSiD","sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { TypeScriptCompilerOptions } from './compiler-options';\n\nexport class TypescriptCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n async postBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n if (packageJson.packageJsonObject.types) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"]}
1
+ {"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","postBuild","Promise","all","packageJson","PackageJsonFile","loadFromCapsuleSync","packageJsonObject","types","write","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"sources":["typescript.compiler.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { TypeScriptCompilerOptions } from './compiler-options';\n\nexport class TypescriptCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n async postBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n if (packageJson.packageJsonObject.types) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AA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BC,QAArB,CAAL,EAAqC,OAAOA,QAAP;;IACrC,MAAM2I,aAAa,GAAG1G,eAAA,CAAK2G,OAAL,CAAa5I,QAAb,CAAtB;;IACA,OAAOA,QAAQ,CAAC0G,OAAT,CAAiB,IAAImC,MAAJ,CAAY,GAAEF,aAAc,GAA5B,CAAjB,EAAkD,KAAlD,CAAP,CAHmD,CAGc;EAClE;;EAEDG,OAAO,GAAG;IACR,OAAO,KAAK5J,QAAL,CAAc4J,OAArB;EACD;;AAhSiD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.compiler.spec.ts"],"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","assign","TypescriptCompiler","TypescriptAspect","id","Logger","ts"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAGA,MAAMA,WAAW,GAAG;AAClBC,EAAAA,QAAQ,EAAE,EADQ;AAElBC,EAAAA,KAAK,EAAE;AAFW,CAApB;AAKAC,QAAQ,CAAC,oBAAD,EAAuB,MAAM;AACnCA,EAAAA,QAAQ,CAAC,sBAAD,EAAyB,MAAM;AACrCC,IAAAA,EAAE,CAAC,gEAAD,EAAmE,MAAM;AACzE,YAAMC,UAAU,GAAGC,aAAa,EAAhC;AACA,0BAAOD,UAAU,CAACE,oBAAX,CAAgC,UAAhC,CAAP,EAAoDC,EAApD,CAAuDC,KAAvD,CAA6DC,gBAAKC,IAAL,CAAU,MAAV,EAAkB,UAAlB,CAA7D;AACA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{ Logger } from '@teambit/logger';\nimport ts from 'typescript';\nimport { expect } from 'chai';\nimport path from 'path';\nimport { TypescriptAspect } from './typescript.aspect';\n\nimport { TypescriptCompiler } from './typescript.compiler';\nimport type { TsCompilerOptionsWithoutTsConfig } from './compiler-options';\n\nconst defaultOpts = {\n tsconfig: {},\n types: [],\n};\n\ndescribe('TypescriptCompiler', () => {\n describe('getDistPathBySrcPath', () => {\n it('should replace the extension with .js and prepend the dist dir', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(path.join('dist', 'index.js'));\n expect(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(path.join('dist', 'index.js'));\n });\n it('should not replace the extension if the file is not supported', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(path.join('dist', 'style.css'));\n expect(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(path.join('dist', 'index.d.ts'));\n });\n });\n describe('isFileSupported', () => {\n it('should support .ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.ts')).to.be.true;\n });\n it('should support .tsx files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.tsx')).to.be.true;\n });\n it('should not support .jsx files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.false;\n });\n it('should not support .js files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.js')).to.be.false;\n });\n it('should support .jsx files when passing compileJsx', () => {\n const tsCompiler = getTsCompiler({ compileJsx: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.true;\n });\n it('should support .js files when passing compileJs', () => {\n const tsCompiler = getTsCompiler({ compileJs: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.js')).to.be.true;\n });\n it('should not support .d.ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.d.ts')).to.be.false;\n });\n });\n});\n\nfunction getTsCompiler(opts: TsCompilerOptionsWithoutTsConfig = defaultOpts) {\n const finalOpts = Object.assign({}, defaultOpts, opts);\n return new TypescriptCompiler(TypescriptAspect.id, new Logger('test'), finalOpts, ts);\n}\n"]}
1
+ {"version":3,"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","expect","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","assign","TypescriptCompiler","TypescriptAspect","id","Logger","ts"],"sources":["typescript.compiler.spec.ts"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport ts from 'typescript';\nimport { expect } from 'chai';\nimport path from 'path';\nimport { TypescriptAspect } from './typescript.aspect';\n\nimport { TypescriptCompiler } from './typescript.compiler';\nimport type { TsCompilerOptionsWithoutTsConfig } from './compiler-options';\n\nconst defaultOpts = {\n tsconfig: {},\n types: [],\n};\n\ndescribe('TypescriptCompiler', () => {\n describe('getDistPathBySrcPath', () => {\n it('should replace the extension with .js and prepend the dist dir', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(path.join('dist', 'index.js'));\n expect(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(path.join('dist', 'index.js'));\n });\n it('should not replace the extension if the file is not supported', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(path.join('dist', 'style.css'));\n expect(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(path.join('dist', 'index.d.ts'));\n });\n });\n describe('isFileSupported', () => {\n it('should support .ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.ts')).to.be.true;\n });\n it('should support .tsx files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.tsx')).to.be.true;\n });\n it('should not support .jsx files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.false;\n });\n it('should not support .js files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.js')).to.be.false;\n });\n it('should support .jsx files when passing compileJsx', () => {\n const tsCompiler = getTsCompiler({ compileJsx: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.true;\n });\n it('should support .js files when passing compileJs', () => {\n const tsCompiler = getTsCompiler({ compileJs: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.js')).to.be.true;\n });\n it('should not support .d.ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.d.ts')).to.be.false;\n });\n });\n});\n\nfunction getTsCompiler(opts: TsCompilerOptionsWithoutTsConfig = defaultOpts) {\n const finalOpts = Object.assign({}, defaultOpts, opts);\n return new TypescriptCompiler(TypescriptAspect.id, new Logger('test'), finalOpts, ts);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;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;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAGA,MAAMA,WAAW,GAAG;EAClBC,QAAQ,EAAE,EADQ;EAElBC,KAAK,EAAE;AAFW,CAApB;AAKAC,QAAQ,CAAC,oBAAD,EAAuB,MAAM;EACnCA,QAAQ,CAAC,sBAAD,EAAyB,MAAM;IACrCC,EAAE,CAAC,gEAAD,EAAmE,MAAM;MACzE,MAAMC,UAAU,GAAGC,aAAa,EAAhC;MACA,IAAAC,cAAA,EAAOF,UAAU,CAACG,oBAAX,CAAgC,UAAhC,CAAP,EAAoDC,EAApD,CAAuDC,KAAvD,CAA6DC,eAAA,CAAKC,IAAL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,CAAiBC,EAAxC,EAA4C,KAAIC,gBAAJ,EAAW,MAAX,CAA5C,EAAgEN,SAAhE,EAA2EO,qBAA3E,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.composition.tsx"],"names":["Logo","height","display","justifyContent","width"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,MAAM,EAAE,MAAV;AAAkBC,IAAAA,OAAO,EAAE,MAA3B;AAAmCC,IAAAA,cAAc,EAAE;AAAnD;AAAZ,gBACE;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAAZ;AAA2B,EAAA,GAAG,EAAC;AAA/B,EADF,CADK","sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"]}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["typescript.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.extractor.ts"],"names":["TypeScriptExtractor","constructor","tsconfig","schemaTransformerSlot","tsMain","rootPath","undefined","parseSourceFile","file","ts","createSourceFile","path","contents","toString","ScriptTarget","Latest","compilerOptions","extract","component","tsserver","getTsServer","mainFile","mainAst","context","createContext","exportNames","computeExportedIdentifiers","setExports","ExportList","moduleSchema","computeSchema","flatExportsRecursively","apiScheme","location","getLocation","APISchema","node","transformer","getTransformer","getIdentifiers","TransformerNotFound","SchemaExtractorContext","getTsserverClient","initTsserverClient","transform","transformers","values","find","singleTransformer","predicate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,mBAAN,CAAqD;AAC1DC,EAAAA,WAAW,CACDC,QADC,EAEDC,qBAFC,EAGDC,MAHC,EAIDC,QAJC,EAKT;AAAA,SAJQH,QAIR,GAJQA,QAIR;AAAA,SAHQC,qBAGR,GAHQA,qBAGR;AAAA,SAFQC,MAER,GAFQA,MAER;AAAA,SADQC,QACR,GADQA,QACR;AAAA,sDAwC6CC,SAxC7C;AAAE;;AAEJC,EAAAA,eAAe,CAACC,IAAD,EAAsB;AACnC,WAAOC,sBAAGC,gBAAH,CACLF,IAAI,CAACG,IADA,EAELH,IAAI,CAACI,QAAL,CAAcC,QAAd,CAAuB,MAAvB,CAFK,EAGLJ,sBAAGK,YAAH,CAAgBC,MAHX,EAIL,IAJK,EAKL,KAAKb,QAAL,CAAcc,eALT,CAAP;AAOD;AAED;AACF;AACA;;;AACe,QAAPC,OAAO,CAACC,SAAD,EAA2C;AACtD,UAAMC,QAAQ,GAAG,MAAM,KAAKC,WAAL,EAAvB;AACA,UAA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AZ,EAAjB;;AACA,UAAIvB,QAAJ,EAAc;AACZ,aAAKA,QAAL,GAAgBA,QAAhB;AACA,eAAOA,QAAP;AACD;;AAED,WAAKA,QAAL,GAAgB,MAAM,KAAKf,MAAL,CAAYuC,kBAAZ,CAA+B,KAAKtC,QAApC,CAAtB;AACA,aAAO,KAAKc,QAAZ;AACD;;AAED,WAAO,KAAKA,QAAZ;AACD;;AAEkB,QAAbW,aAAa,CAACM,IAAD,EAAab,OAAb,EAAmE;AACpF,UAAMc,WAAW,GAAG,KAAKC,cAAL,CAAoBF,IAApB,EAA0Bb,OAAO,CAACL,SAAlC,CAApB,CADoF,CAEpF;AACA;;AACA,WAAOmB,WAAW,CAACO,SAAZ,CAAsBR,IAAtB,EAA4Bb,OAA5B,CAAP;AACD;AAED;AACF;AACA;;;AACUe,EAAAA,cAAc,CAACF,IAAD,EAAalB,SAAb,EAAmC;AACvD,UAAM2B,YAAY,GAAG,uBAAQ,KAAK1C,qBAAL,CAA2B2C,MAA3B,EAAR,CAArB;AACA,UAAMT,WAAW,GAAGQ,YAAY,CAACE,IAAb,CAAmBC,iBAAD,IAAuBA,iBAAiB,CAACC,SAAlB,CAA4Bb,IAA5B,CAAzC,CAApB;AAEA,QAAI,CAACC,WAAL,EAAkB,MAAM,KAAIG,iCAAJ,EAAwBJ,IAAxB,EAA8BlB,SAA9B,CAAN;AAElB,WAAOmB,WAAP;AACD;;AAhFyD","sourcesContent":["import ts, { Node } from 'typescript';\nimport { SchemaExtractor } from '@teambit/schema';\nimport { TsserverClient } from '@teambit/ts-server';\nimport { SchemaNode, APISchema, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { Component } from '@teambit/component';\n// @ts-ignore david what to do?\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { flatten } from 'lodash';\nimport { TypescriptMain, SchemaTransformerSlot } from './typescript.main.runtime';\nimport { TransformerNotFound } from './exceptions';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { ExportList } from './export-list';\n\nexport class TypeScriptExtractor implements SchemaExtractor {\n constructor(\n private tsconfig: any,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private tsMain: TypescriptMain,\n private rootPath: string\n ) {}\n\n parseSourceFile(file: AbstractVinyl) {\n return ts.createSourceFile(\n file.path,\n file.contents.toString('utf8'),\n ts.ScriptTarget.Latest,\n true,\n this.tsconfig.compilerOptions\n );\n }\n\n /**\n * extract a component schema.\n */\n async extract(component: Component): Promise<APISchema> {\n const tsserver = await this.getTsServer();\n const mainFile = component.mainFile;\n const mainAst = this.parseSourceFile(mainFile);\n const context = this.createContext(tsserver, component);\n const exportNames = await this.computeExportedIdentifiers(mainAst, context);\n context.setExports(new ExportList(exportNames));\n const moduleSchema = (await this.computeSchema(mainAst, context)) as Module;\n moduleSchema.flatExportsRecursively();\n const apiScheme = moduleSchema;\n const location = context.getLocation(mainAst);\n\n return new APISchema(location, apiScheme);\n }\n\n async computeExportedIdentifiers(node: Node, context: SchemaExtractorContext) {\n const transformer = this.getTransformer(node, context.component);\n if (!transformer || !transformer.getIdentifiers) throw new TransformerNotFound(node, context.component);\n return transformer.getIdentifiers(node, context);\n }\n\n private createContext(tsserver: TsserverClient, component: Component): SchemaExtractorContext {\n return new SchemaExtractorContext(tsserver, component, this);\n }\n\n private tsserver: TsserverClient | undefined = undefined;\n\n private async getTsServer() {\n if (!this.tsserver) {\n const tsserver = this.tsMain.getTsserverClient();\n if (tsserver) {\n this.tsserver = tsserver;\n return tsserver;\n }\n\n this.tsserver = await this.tsMain.initTsserverClient(this.rootPath);\n return this.tsserver;\n }\n\n return this.tsserver;\n }\n\n async computeSchema(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const transformer = this.getTransformer(node, context.component);\n // leave the next line commented out, it is used for debugging\n // console.log('transformer', transformer.constructor.name, node.getText());\n return transformer.transform(node, context);\n }\n\n /**\n * select the correct transformer for a node.\n */\n private getTransformer(node: Node, component: Component) {\n const transformers = flatten(this.schemaTransformerSlot.values());\n const transformer = transformers.find((singleTransformer) => singleTransformer.predicate(node));\n\n if (!transformer) throw new TransformerNotFound(node, component);\n\n return transformer;\n }\n}\n"]}
1
+ {"version":3,"names":["TypeScriptExtractor","constructor","tsconfig","schemaTransformerSlot","tsMain","rootPath","undefined","parseSourceFile","file","ts","createSourceFile","path","contents","toString","ScriptTarget","Latest","compilerOptions","extract","component","tsserver","getTsServer","mainFile","mainAst","context","createContext","exportNames","computeExportedIdentifiers","setExports","ExportList","moduleSchema","computeSchema","flatExportsRecursively","apiScheme","location","getLocation","APISchema","node","transformer","getTransformer","getIdentifiers","TransformerNotFound","SchemaExtractorContext","getTsserverClient","initTsserverClient","transform","transformers","flatten","values","find","singleTransformer","predicate"],"sources":["typescript.extractor.ts"],"sourcesContent":["import ts, { Node } from 'typescript';\nimport { SchemaExtractor } from '@teambit/schema';\nimport { TsserverClient } from '@teambit/ts-server';\nimport { SchemaNode, APISchema, Module } from '@teambit/semantics.entities.semantic-schema';\nimport { Component } from '@teambit/component';\n// @ts-ignore david what to do?\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { flatten } from 'lodash';\nimport { TypescriptMain, SchemaTransformerSlot } from './typescript.main.runtime';\nimport { TransformerNotFound } from './exceptions';\nimport { SchemaExtractorContext } from './schema-extractor-context';\nimport { ExportList } from './export-list';\n\nexport class TypeScriptExtractor implements SchemaExtractor {\n constructor(\n private tsconfig: any,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private tsMain: TypescriptMain,\n private rootPath: string\n ) {}\n\n parseSourceFile(file: AbstractVinyl) {\n return ts.createSourceFile(\n file.path,\n file.contents.toString('utf8'),\n ts.ScriptTarget.Latest,\n true,\n this.tsconfig.compilerOptions\n );\n }\n\n /**\n * extract a component schema.\n */\n async extract(component: Component): Promise<APISchema> {\n const tsserver = await this.getTsServer();\n const mainFile = component.mainFile;\n const mainAst = this.parseSourceFile(mainFile);\n const context = this.createContext(tsserver, component);\n const exportNames = await this.computeExportedIdentifiers(mainAst, context);\n context.setExports(new ExportList(exportNames));\n const moduleSchema = (await this.computeSchema(mainAst, context)) as Module;\n moduleSchema.flatExportsRecursively();\n const apiScheme = moduleSchema;\n const location = context.getLocation(mainAst);\n\n return new APISchema(location, apiScheme);\n }\n\n async computeExportedIdentifiers(node: Node, context: SchemaExtractorContext) {\n const transformer = this.getTransformer(node, context.component);\n if (!transformer || !transformer.getIdentifiers) throw new TransformerNotFound(node, context.component);\n return transformer.getIdentifiers(node, context);\n }\n\n private createContext(tsserver: TsserverClient, component: Component): SchemaExtractorContext {\n return new SchemaExtractorContext(tsserver, component, this);\n }\n\n private tsserver: TsserverClient | undefined = undefined;\n\n private async getTsServer() {\n if (!this.tsserver) {\n const tsserver = this.tsMain.getTsserverClient();\n if (tsserver) {\n this.tsserver = tsserver;\n return tsserver;\n }\n\n this.tsserver = await this.tsMain.initTsserverClient(this.rootPath);\n return this.tsserver;\n }\n\n return this.tsserver;\n }\n\n async computeSchema(node: Node, context: SchemaExtractorContext): Promise<SchemaNode> {\n const transformer = this.getTransformer(node, context.component);\n // leave the next line commented out, it is used for debugging\n // console.log('transformer', transformer.constructor.name, node.getText());\n return transformer.transform(node, context);\n }\n\n /**\n * select the correct transformer for a node.\n */\n private getTransformer(node: Node, component: Component) {\n const transformers = flatten(this.schemaTransformerSlot.values());\n const transformer = transformers.find((singleTransformer) => singleTransformer.predicate(node));\n\n if (!transformer) throw new TransformerNotFound(node, component);\n\n return transformer;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAA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,MAAMV,WAAW,GAAGQ,YAAY,CAACG,IAAb,CAAmBC,iBAAD,IAAuBA,iBAAiB,CAACC,SAAlB,CAA4Bd,IAA5B,CAAzC,CAApB;IAEA,IAAI,CAACC,WAAL,EAAkB,MAAM,KAAIG,iCAAJ,EAAwBJ,IAAxB,EAA8BlB,SAA9B,CAAN;IAElB,OAAOmB,WAAP;EACD;;AAhFyD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.main.runtime.ts"],"names":["TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","createSchemaExtractor","tsconfig","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","results","file","onFileChange","provider","schema","loggerExt","aspectLoader","cli","registerParser","TypeScriptParser","createLogger","registerPlugins","SchemaTransformerPlugin","tsMain","register","ExportDeclaration","FunctionDeclaration","MethodDeclaration","PropertyDeclaration","VariableStatementTransformer","VariableDeclaration","Constructor","SourceFileTransformer","TypeAliasTransformer","ClassDecelerationTransformer","PropertySignature","LiteralTypeTransformer","IndexSignature","InterfaceDeclarationTransformer","MethodSignatureTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","checkTypesCmd","CheckTypesCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"mappings":";;;;;;;;;;;;;;;;;;;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B,EAA0BzE,SAA1B,EAAqCF,MAArC,CAAtB;AACAqE,IAAAA,GAAG,CAACO,QAAJ,CAAaoB,aAAb;AAEA,WAAOrB,MAAP;AACD;;AAnNyB;;;gCAAf7E,c,aA0KMoG,kB;gCA1KNpG,c,kBA2KW,CAACqG,sBAAD,EAAeC,sBAAf,EAA6BC,uBAA7B,EAAiDC,4BAAjD,EAAkEC,gBAAlE,C;gCA3KXzG,c,WA4KI,CAAC0G,gBAAKC,QAAL,EAAD,C;;AA0CjB1F,gCAAiB2F,UAAjB,CAA4B5G,cAA5B;;AAEO,SAASc,0BAAT,CACLqB,MADK,EAEL5B,YAAmC,GAAG,EAFjC,EAGLsG,OAHK,EAIoB;AACzB,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcxG,YAAd,CAAL,EAAkC,OAAO4B,MAAP;AAClC,QAAM6E,SAAS,GAAGzG,YAAY,CAAC0G,MAAb,CAAoB,CAACC,GAAD,EAAMC,WAAN,KAAsB;AAC1D,WAAOA,WAAW,CAACD,GAAD,EAAML,OAAN,CAAlB;AACD,GAFiB,EAEf1E,MAFe,CAAlB;AAGA,SAAO6E,SAAP;AACD","sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { WatchOptions, Workspace } from '@teambit/workspace';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { Component } from '@teambit/component';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclaration,\n TypeAliasTransformer,\n FunctionDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDecelerationTransformer,\n Constructor,\n PropertySignature,\n LiteralTypeTransformer,\n IndexSignature,\n InterfaceDeclarationTransformer,\n MethodSignatureTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private workspace: Workspace\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('ES2020');\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(tsconfig, this.schemaTransformerSlot, this, path || this.workspace.path);\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n public getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [SchemaAspect, LoggerAspect, AspectLoaderAspect, WorkspaceAspect, CLIAspect];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [schema, loggerExt, aspectLoader, workspace, cli]: [SchemaMain, LoggerMain, AspectLoaderMain, Workspace, CLIMain],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsMain = new TypescriptMain(logger, schemaTransformerSlot, workspace);\n schemaTransformerSlot.register([\n new ExportDeclaration(),\n new FunctionDeclaration(),\n new MethodDeclaration(),\n new PropertyDeclaration(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new Constructor(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDecelerationTransformer(),\n new PropertySignature(),\n new LiteralTypeTransformer(),\n new IndexSignature(),\n new InterfaceDeclarationTransformer(),\n new MethodSignatureTransformer(),\n ]);\n\n if (workspace) {\n workspace.registerOnPreWatch(tsMain.onPreWatch.bind(this));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(this));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(this));\n }\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n cli.register(checkTypesCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"]}
1
+ {"version":3,"names":["TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","createSchemaExtractor","tsconfig","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","results","pMapSeries","file","onFileChange","provider","schema","loggerExt","aspectLoader","cli","registerParser","TypeScriptParser","createLogger","registerPlugins","SchemaTransformerPlugin","tsMain","register","ExportDeclaration","FunctionDeclaration","MethodDeclaration","PropertyDeclaration","VariableStatementTransformer","VariableDeclaration","Constructor","SourceFileTransformer","TypeAliasTransformer","ClassDecelerationTransformer","PropertySignature","LiteralTypeTransformer","IndexSignature","InterfaceDeclarationTransformer","MethodSignatureTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","checkTypesCmd","CheckTypesCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["typescript.main.runtime.ts"],"sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { WatchOptions, Workspace } from '@teambit/workspace';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { Component } from '@teambit/component';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclaration,\n TypeAliasTransformer,\n FunctionDeclaration,\n MethodDeclaration,\n PropertyDeclaration,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDecelerationTransformer,\n Constructor,\n PropertySignature,\n LiteralTypeTransformer,\n IndexSignature,\n InterfaceDeclarationTransformer,\n MethodSignatureTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n private schemaTransformerSlot: SchemaTransformerSlot,\n private workspace: Workspace\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('ES2020');\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(tsconfig, this.schemaTransformerSlot, this, path || this.workspace.path);\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n public getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [SchemaAspect, LoggerAspect, AspectLoaderAspect, WorkspaceAspect, CLIAspect];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [schema, loggerExt, aspectLoader, workspace, cli]: [SchemaMain, LoggerMain, AspectLoaderMain, Workspace, CLIMain],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsMain = new TypescriptMain(logger, schemaTransformerSlot, workspace);\n schemaTransformerSlot.register([\n new ExportDeclaration(),\n new FunctionDeclaration(),\n new MethodDeclaration(),\n new PropertyDeclaration(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new Constructor(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDecelerationTransformer(),\n new PropertySignature(),\n new LiteralTypeTransformer(),\n new IndexSignature(),\n new InterfaceDeclarationTransformer(),\n new MethodSignatureTransformer(),\n ]);\n\n if (workspace) {\n workspace.registerOnPreWatch(tsMain.onPreWatch.bind(this));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(this));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(this));\n }\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n cli.register(checkTypesCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAiBA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAeO,MAAMA,cAAN,CAAqB;EAC1BC,WAAW,CACDC,MADC,EAEDC,qBAFC,EAGDC,SAHC,EAIT;IAAA,KAH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CAApC;MACA5F,SAAS,CAAC8F,sBAAV,CAAiCpB,MAAM,CAAChB,iBAAP,CAAyBkC,IAAzB,CAA8B,IAA9B,CAAjC;IACD;;IAED,MAAMG,aAAa,GAAG,KAAIC,2BAAJ,EAAkBtB,MAAlB,EAA0B1E,SAA1B,EAAqCF,MAArC,CAAtB;IACAsE,GAAG,CAACO,QAAJ,CAAaoB,aAAb;IAEA,OAAOrB,MAAP;EACD;;AAnNyB;;;gCAAf9E,c,aA0KMqG,kB;gCA1KNrG,c,kBA2KW,CAACsG,sBAAD,EAAeC,sBAAf,EAA6BC,uBAA7B,EAAiDC,4BAAjD,EAAkEC,gBAAlE,C;gCA3KX1G,c,WA4KI,CAAC2G,eAAA,CAAKC,QAAL,EAAD,C;;AA0CjB3F,+BAAA,CAAiB4F,UAAjB,CAA4B7G,cAA5B;;AAEO,SAASc,0BAAT,CACLqB,MADK,EAEL5B,YAAmC,GAAG,EAFjC,EAGLuG,OAHK,EAIoB;EACzB,IAAI,CAACC,KAAK,CAACC,OAAN,CAAczG,YAAd,CAAL,EAAkC,OAAO4B,MAAP;EAClC,MAAM8E,SAAS,GAAG1G,YAAY,CAAC2G,MAAb,CAAoB,CAACC,GAAD,EAAMC,WAAN,KAAsB;IAC1D,OAAOA,WAAW,CAACD,GAAD,EAAML,OAAN,CAAlB;EACD,CAFiB,EAEf3E,MAFe,CAAlB;EAGA,OAAO8E,SAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.parser.ts"],"names":["TypeScriptParser","getExports","sourceFile","staticProperties","parseStaticProperties","exports","statements","filter","statement","modifiers","find","modifier","kind","ts","SyntaxKind","ExportKeyword","exportModels","map","child","declarationList","declarations","name","text","Export","get","undefined","withoutEmpty","exportModel","parseModule","modulePath","ast","createSourceFile","ScriptTarget","Latest","moduleExports","exportStaticProperties","Map","forEach","isExpressionStatement","isBinaryExpression","expression","operatorToken","EqualsToken","isPropertyAccessExpression","left","isIdentifier","targetName","propertyName","has","set","existingProperties","isStringLiteral","right","isNumericLiteral","UndefinedKeyword","NullKeyword","TrueKeyword","FalseKeyword","err","logger","error","constructor"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAQO,MAAMA,gBAAN,CAAyC;AAG9CC,EAAAA,UAAU,CAACC,UAAD,EAAmC;AAC3C,UAAMC,gBAAgB,GAAG,KAAKC,qBAAL,CAA2BF,UAA3B,CAAzB;AAEA,UAAMG,OAAO,GAAGH,UAAU,CAACI,UAAX,CAAsBC,MAAtB,CAA8BC,SAAD,IAAe;AAC1D,UAAI,CAACA,SAAS,CAACC,SAAf,EAA0B,OAAO,KAAP;AAC1B,aAAOD,SAAS,CAACC,SAAV,CAAoBC,IAApB,CAA0BC,QAAD,IAAc;AAC5C,eAAOA,QAAQ,CAACC,IAAT,KAAkBC,sBAAGC,UAAH,CAAcC,aAAvC;AACD,OAFM,CAAP;AAGD,KALe,CAAhB;AAOA,UAAMC,YAAY,GAAGX,OAAO,CAACY,GAAR,CAAaT,SAAD,IAAe;AAC9C;AACA,UAAI,uCAAoBA,SAApB,CAAJ,EAAoC;AAClC,cAAMU,KAAK,GAAIV,SAAD,CAAiCW,eAAjC,CAAiDC,YAAjD,CAA8D,CAA9D,CAAd;AACA,cAAMC,IAAI,GAAIH,KAAD,CAAeG,IAAf,CAAoBC,IAAjC;AACA,eAAO,KAAIC,2BAAJ,EAAWF,IAAX,EAAiBlB,gBAAgB,CAACqB,GAAjB,CAAqBH,IAArB,CAAjB,CAAP;AACD;;AAED,UAAI,yCAAsBb,SAAtB,CAAJ,EAAsC;AACpC,YAAI,CAACA,SAAS,CAACa,IAAf,EAAqB,OAAOI,SAAP;AACrB,cAAMJ,IAAI,GAAGb,SAAS,CAACa,IAAV,CAAeC,IAA5B;AACA,eAAO,KAAI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wC,gBAAtD,EAAwE;AAC7EJ,UAAAA,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAED,GAApB,CAAwBF,YAAxB,EAAsCtB,SAAtC;AACD,SAFM,MAEA,IAAIjB,SAAS,CAACgC,UAAV,CAAqBY,KAArB,CAA2BxC,IAA3B,KAAoCC,sBAAGC,UAAH,CAAcyC,WAAtD,EAAmE;AACxEL,UAAAA,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAED,GAApB,CAAwBF,YAAxB,EAAsC,IAAtC;AACD,SAFM,MAEA,IAAIvC,SAAS,CAACgC,UAAV,CAAqBY,KAArB,CAA2BxC,IAA3B,KAAoCC,sBAAGC,UAAH,CAAc0C,WAAtD,EAAmE;AACxEN,UAAAA,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAED,GAApB,CAAwBF,YAAxB,EAAsC,IAAtC;AACD,SAFM,MAEA,IAAIvC,SAAS,CAACgC,UAAV,CAAqBY,KAArB,CAA2BxC,IAA3B,KAAoCC,sBAAGC,UAAH,CAAc2C,YAAtD,EAAoE;AACzEP,UAAAA,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAED,GAApB,CAAwBF,YAAxB,EAAsC,KAAtC;AACD;AACF,OA3BD,CA2BE,OAAOW,GAAP,EAAY;AAAA;;AACZ,6BAAKC,MAAL,8DAAaC,KAAb,CAAmB,kCAAnB,EAAuDF,GAAvD;AACD;AACF,KA/BD;AAiCA,WAAOvB,sBAAP;AACD;;AAED0B,EAAAA,WAAW,CAASF,MAAT,EAAsC;AAAA,SAA7BA,MAA6B,GAA7BA,MAA6B;AAAA,uDAvF9B,uBAuF8B;AAAE;;AAxFL","sourcesContent":["import { Parser } from '@teambit/schema';\nimport { Export, StaticProperties } from '@teambit/semantics.entities.semantic-schema';\nimport { Logger } from '@teambit/logger';\nimport { readFileSync } from 'fs-extra';\nimport ts, {\n isClassDeclaration,\n isFunctionDeclaration,\n isVariableStatement,\n SourceFile,\n VariableStatement,\n} from 'typescript';\n\nexport class TypeScriptParser implements Parser {\n public extension = /^.*\\.(js|jsx|ts|tsx)$/;\n\n getExports(sourceFile: SourceFile): Export[] {\n const staticProperties = this.parseStaticProperties(sourceFile);\n\n const exports = sourceFile.statements.filter((statement) => {\n if (!statement.modifiers) return false;\n return statement.modifiers.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n });\n });\n\n const exportModels = exports.map((statement) => {\n // todo refactor to a registry of variable statements.\n if (isVariableStatement(statement)) {\n const child = (statement as VariableStatement).declarationList.declarations[0];\n const name = (child as any).name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n if (isFunctionDeclaration(statement)) {\n if (!statement.name) return undefined;\n const name = statement.name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n if (isClassDeclaration(statement)) {\n if (!statement.name) return undefined;\n const name = statement.name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n return undefined;\n });\n const withoutEmpty = exportModels.filter((exportModel) => exportModel !== undefined);\n // @ts-ignore\n return withoutEmpty;\n }\n\n parseModule(modulePath: string) {\n const ast = ts.createSourceFile(modulePath, readFileSync(modulePath, 'utf8'), ts.ScriptTarget.Latest);\n\n const moduleExports = this.getExports(ast);\n return moduleExports;\n }\n\n parseStaticProperties(sourceFile: SourceFile) {\n // TODO - should we also parse staticProperties inside classes / objects?\n\n const exportStaticProperties = new Map<string, StaticProperties>();\n\n sourceFile.statements.forEach((statement) => {\n try {\n if (!ts.isExpressionStatement(statement)) return;\n if (!ts.isBinaryExpression(statement.expression)) return;\n if (statement.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken) return;\n if (!ts.isPropertyAccessExpression(statement.expression.left)) return;\n if (!ts.isIdentifier(statement.expression.left.expression)) return;\n\n const targetName = statement.expression.left.expression.text;\n const propertyName = statement.expression.left.name.text;\n\n if (!exportStaticProperties.has(targetName)) exportStaticProperties.set(targetName, new Map());\n\n const existingProperties = exportStaticProperties.get(targetName);\n\n if (ts.isStringLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, statement.expression.right.text);\n } else if (ts.isNumericLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, +statement.expression.right.text);\n } else if (statement.expression.right.kind === ts.SyntaxKind.UndefinedKeyword) {\n existingProperties?.set(propertyName, undefined);\n } else if (statement.expression.right.kind === ts.SyntaxKind.NullKeyword) {\n existingProperties?.set(propertyName, null);\n } else if (statement.expression.right.kind === ts.SyntaxKind.TrueKeyword) {\n existingProperties?.set(propertyName, true);\n } else if (statement.expression.right.kind === ts.SyntaxKind.FalseKeyword) {\n existingProperties?.set(propertyName, false);\n }\n } catch (err) {\n this.logger?.error('failed parsing static properties', err);\n }\n });\n\n return exportStaticProperties;\n }\n\n constructor(private logger?: Logger | undefined) {}\n}\n"]}
1
+ {"version":3,"names":["TypeScriptParser","getExports","sourceFile","staticProperties","parseStaticProperties","exports","statements","filter","statement","modifiers","find","modifier","kind","ts","SyntaxKind","ExportKeyword","exportModels","map","isVariableStatement","child","declarationList","declarations","name","text","Export","get","isFunctionDeclaration","undefined","isClassDeclaration","withoutEmpty","exportModel","parseModule","modulePath","ast","createSourceFile","readFileSync","ScriptTarget","Latest","moduleExports","exportStaticProperties","Map","forEach","isExpressionStatement","isBinaryExpression","expression","operatorToken","EqualsToken","isPropertyAccessExpression","left","isIdentifier","targetName","propertyName","has","set","existingProperties","isStringLiteral","right","isNumericLiteral","UndefinedKeyword","NullKeyword","TrueKeyword","FalseKeyword","err","logger","error","constructor"],"sources":["typescript.parser.ts"],"sourcesContent":["import { Parser } from '@teambit/schema';\nimport { Export, StaticProperties } from '@teambit/semantics.entities.semantic-schema';\nimport { Logger } from '@teambit/logger';\nimport { readFileSync } from 'fs-extra';\nimport ts, {\n isClassDeclaration,\n isFunctionDeclaration,\n isVariableStatement,\n SourceFile,\n VariableStatement,\n} from 'typescript';\n\nexport class TypeScriptParser implements Parser {\n public extension = /^.*\\.(js|jsx|ts|tsx)$/;\n\n getExports(sourceFile: SourceFile): Export[] {\n const staticProperties = this.parseStaticProperties(sourceFile);\n\n const exports = sourceFile.statements.filter((statement) => {\n if (!statement.modifiers) return false;\n return statement.modifiers.find((modifier) => {\n return modifier.kind === ts.SyntaxKind.ExportKeyword;\n });\n });\n\n const exportModels = exports.map((statement) => {\n // todo refactor to a registry of variable statements.\n if (isVariableStatement(statement)) {\n const child = (statement as VariableStatement).declarationList.declarations[0];\n const name = (child as any).name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n if (isFunctionDeclaration(statement)) {\n if (!statement.name) return undefined;\n const name = statement.name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n if (isClassDeclaration(statement)) {\n if (!statement.name) return undefined;\n const name = statement.name.text;\n return new Export(name, staticProperties.get(name));\n }\n\n return undefined;\n });\n const withoutEmpty = exportModels.filter((exportModel) => exportModel !== undefined);\n // @ts-ignore\n return withoutEmpty;\n }\n\n parseModule(modulePath: string) {\n const ast = ts.createSourceFile(modulePath, readFileSync(modulePath, 'utf8'), ts.ScriptTarget.Latest);\n\n const moduleExports = this.getExports(ast);\n return moduleExports;\n }\n\n parseStaticProperties(sourceFile: SourceFile) {\n // TODO - should we also parse staticProperties inside classes / objects?\n\n const exportStaticProperties = new Map<string, StaticProperties>();\n\n sourceFile.statements.forEach((statement) => {\n try {\n if (!ts.isExpressionStatement(statement)) return;\n if (!ts.isBinaryExpression(statement.expression)) return;\n if (statement.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken) return;\n if (!ts.isPropertyAccessExpression(statement.expression.left)) return;\n if (!ts.isIdentifier(statement.expression.left.expression)) return;\n\n const targetName = statement.expression.left.expression.text;\n const propertyName = statement.expression.left.name.text;\n\n if (!exportStaticProperties.has(targetName)) exportStaticProperties.set(targetName, new Map());\n\n const existingProperties = exportStaticProperties.get(targetName);\n\n if (ts.isStringLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, statement.expression.right.text);\n } else if (ts.isNumericLiteral(statement.expression.right)) {\n existingProperties?.set(propertyName, +statement.expression.right.text);\n } else if (statement.expression.right.kind === ts.SyntaxKind.UndefinedKeyword) {\n existingProperties?.set(propertyName, undefined);\n } else if (statement.expression.right.kind === ts.SyntaxKind.NullKeyword) {\n existingProperties?.set(propertyName, null);\n } else if (statement.expression.right.kind === ts.SyntaxKind.TrueKeyword) {\n existingProperties?.set(propertyName, true);\n } else if (statement.expression.right.kind === ts.SyntaxKind.FalseKeyword) {\n existingProperties?.set(propertyName, false);\n }\n } catch (err) {\n this.logger?.error('failed parsing static properties', err);\n }\n });\n\n return exportStaticProperties;\n }\n\n constructor(private logger?: Logger | undefined) {}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAQO,MAAMA,gBAAN,CAAyC;EAG9CC,UAAU,CAACC,UAAD,EAAmC;IAC3C,MAAMC,gBAAgB,GAAG,KAAKC,qBAAL,CAA2BF,UAA3B,CAAzB;IAEA,MAAMG,OAAO,GAAGH,UAAU,CAACI,UAAX,CAAsBC,MAAtB,CAA8BC,SAAD,IAAe;MAC1D,IAAI,CAACA,SAAS,CAACC,SAAf,EAA0B,OAAO,KAAP;MAC1B,OAAOD,SAAS,CAACC,SAAV,CAAoBC,IAApB,CAA0BC,QAAD,IAAc;QAC5C,OAAOA,QAAQ,CAACC,IAAT,KAAkBC,qBAAA,CAAGC,UAAH,CAAcC,aAAvC;MACD,CAFM,CAAP;IAGD,CALe,CAAhB;IAOA,MAAMC,YAAY,GAAGX,OAAO,CAACY,GAAR,CAAaT,SAAD,IAAe;MAC9C;MACA,IAAI,IAAAU,iCAAA,EAAoBV,SAApB,CAAJ,EAAoC;QAClC,MAAMW,KAAK,GAAIX,SAAD,CAAiCY,eAAjC,CAAi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,YAAxB,EAAsC,KAAtC;QACD;MACF,CA3BD,CA2BE,OAAOW,GAAP,EAAY;QAAA;;QACZ,qBAAKC,MAAL,8DAAaC,KAAb,CAAmB,kCAAnB,EAAuDF,GAAvD;MACD;IACF,CA/BD;IAiCA,OAAOvB,sBAAP;EACD;;EAED0B,WAAW,CAASF,MAAT,EAAsC;IAAA,KAA7BA,MAA6B,GAA7BA,MAA6B;IAAA,mDAvF9B,uBAuF8B;EAAE;;AAxFL"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typescript.parser.spec.ts"],"names":["describe","exampleArrowFunction","exampleFunction","exampleClass","it","ast","ts","createSourceFile","ScriptTarget","Latest","exports","TypeScriptParser","getExports","exportArrow","find","x","identifier","to","exist","exportFunction","exportClass","staticProperties","get","equal","exampleFile","parseStaticProperties","exportHello","undefined","has","be","false"],"mappings":";;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEAA,QAAQ,CAAC,kBAAD,EAAqB,MAAM;AACjCA,EAAAA,QAAQ,CAAC,YAAD,EAAe,MAAM;AAC3B,UAAMC,oBAAoB,GAAI;AAClC;AACA;AACA,KAHI;AAKA,UAAMC,eAAe,GAAI;AAC7B;AACA;AACA,KAHI;AAKA,UAAMC,YAAY,GAAI;AAC1B;AACA;AACA,KAHI;AAKAC,IAAAA,EAAE,CAAC,6BAAD,EAAgC,MAAM;AACtC,YAAMC,GAAG,GAAGC,sBAAGC,gBAAH,CAAoB,aAApB,EAAmCN,oBAAnC,EAAyDK,sBAAGE,YAAH,CAAgBC,MAAzE,CAAZ;;AACA,YAAMC,OAAO,GAAG,KAAIC,+BAAJ,IAAuBC,UAAvB,CAAkCP,GAAlC,CAAhB;AAEA,YAAMQ,WAAW,GAAGH,OAAO,CAACI,IAAR,CAAcC,CAAD,IAAOA,CAAC,CAACC,UAAF,KAA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Y,EAAnD,CAAsDC,KAAtD;AACD,KANC,CAAF;AAOD,GAhDO,CAAR;AAiDD,CA3HO,CAAR","sourcesContent":["import ts from 'typescript';\nimport { expect } from 'chai';\n\nimport { TypeScriptParser } from './typescript.parser';\n\ndescribe('TypescriptParser', () => {\n describe('getExports', () => {\n const exampleArrowFunction = `\n export const arrow = () => { return 3; }\n arrow.textProperty = \"propertyValue\";\n `;\n\n const exampleFunction = `\n export function func() { return 3; }\n func.textProperty = \"propertyValue\";\n `;\n\n const exampleClass = `\n export class classy{ render() { return 3; } }\n classy.textProperty = \"propertyValue\";\n `;\n\n it('should parse arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow).to.exist;\n });\n\n it('should parse function exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'func');\n\n expect(exportFunction).to.exist;\n });\n\n it('should parse classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass).to.exist;\n });\n\n describe('staticProperties', () => {\n it('should include staticProperties, when on arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on regular functions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'func');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n });\n });\n\n describe('collectStaticProperties', () => {\n const exampleFile = `\n export const hello = () => { return 3; }\n\n hello.text = \"is\";\n hello.count = 3;\n hello.nullish = null;\n hello.undef = undefined;\n hello.disable = false;\n hello.enable = true;\n hello.complextLiteral = \\`what \\${hello.text} it?\\`;\n hello.nonAssignedProperty += 'value';\n `;\n\n it('should parse all primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n\n expect(staticProperties).to.exist;\n\n const exportHello = staticProperties.get('hello');\n expect(exportHello).to.exist;\n\n expect(exportHello?.get('text')).to.equal('is');\n expect(exportHello?.get('count')).to.equal(3);\n expect(exportHello?.get('nullish')).to.equal(null);\n expect(exportHello?.get('undef')).to.equal(undefined);\n expect(exportHello?.get('disable')).to.equal(false);\n expect(exportHello?.get('enable')).to.equal(true);\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non assignment statements', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('nonAssignedProperty')).to.be.false;\n });\n });\n});\n"]}
1
+ {"version":3,"names":["describe","exampleArrowFunction","exampleFunction","exampleClass","it","ast","ts","createSourceFile","ScriptTarget","Latest","exports","TypeScriptParser","getExports","exportArrow","find","x","identifier","expect","to","exist","exportFunction","exportClass","staticProperties","get","equal","exampleFile","parseStaticProperties","exportHello","undefined","has","be","false"],"sources":["typescript.parser.spec.ts"],"sourcesContent":["import ts from 'typescript';\nimport { expect } from 'chai';\n\nimport { TypeScriptParser } from './typescript.parser';\n\ndescribe('TypescriptParser', () => {\n describe('getExports', () => {\n const exampleArrowFunction = `\n export const arrow = () => { return 3; }\n arrow.textProperty = \"propertyValue\";\n `;\n\n const exampleFunction = `\n export function func() { return 3; }\n func.textProperty = \"propertyValue\";\n `;\n\n const exampleClass = `\n export class classy{ render() { return 3; } }\n classy.textProperty = \"propertyValue\";\n `;\n\n it('should parse arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow).to.exist;\n });\n\n it('should parse function exports', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportFunction = exports.find((x) => x.identifier === 'func');\n\n expect(exportFunction).to.exist;\n });\n\n it('should parse classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass).to.exist;\n });\n\n describe('staticProperties', () => {\n it('should include staticProperties, when on arrowFunctions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleArrowFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportArrow = exports.find((x) => x.identifier === 'arrow');\n\n expect(exportArrow?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on regular functions', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFunction, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'func');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n\n it('should include staticProperties, when on classes', () => {\n const ast = ts.createSourceFile('example.tsx', exampleClass, ts.ScriptTarget.Latest);\n const exports = new TypeScriptParser().getExports(ast);\n\n const exportClass = exports.find((x) => x.identifier === 'classy');\n\n expect(exportClass?.staticProperties?.get('textProperty')).to.equal('propertyValue');\n });\n });\n });\n\n describe('collectStaticProperties', () => {\n const exampleFile = `\n export const hello = () => { return 3; }\n\n hello.text = \"is\";\n hello.count = 3;\n hello.nullish = null;\n hello.undef = undefined;\n hello.disable = false;\n hello.enable = true;\n hello.complextLiteral = \\`what \\${hello.text} it?\\`;\n hello.nonAssignedProperty += 'value';\n `;\n\n it('should parse all primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n\n expect(staticProperties).to.exist;\n\n const exportHello = staticProperties.get('hello');\n expect(exportHello).to.exist;\n\n expect(exportHello?.get('text')).to.equal('is');\n expect(exportHello?.get('count')).to.equal(3);\n expect(exportHello?.get('nullish')).to.equal(null);\n expect(exportHello?.get('undef')).to.equal(undefined);\n expect(exportHello?.get('disable')).to.equal(false);\n expect(exportHello?.get('enable')).to.equal(true);\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non primitive values', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');\n\n expect(exportHello?.has('complextLiteral')).to.be.false;\n });\n\n it('should skip non assignment statements', () => {\n const ast = ts.createSourceFile('example.tsx', exampleFile, ts.ScriptTarget.Latest);\n const staticProperties = new TypeScriptParser().parseStaticProperties(ast);\n const exportHello = staticProperties.get('hello');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P,EAA4CX,EAA5C,CAA+CY,EAA/C,CAAkDC,KAAlD;IACD,CAjBC,CAAF;IAmBA3B,EAAE,CAAC,kCAAD,EAAqC,MAAM;MAC3C,MAAMC,GAAG,GAAGC,qBAAA,CAAGC,gBAAH,CAAoB,aAApB,EAAmCkB,WAAnC,EAAgDnB,qBAAA,CAAGE,YAAH,CAAgBC,MAAhE,CAAZ;;MACA,MAAMa,gBAAgB,GAAG,KAAIX,+BAAJ,IAAuBe,qBAAvB,CAA6CrB,GAA7C,CAAzB;MACA,MAAMsB,WAAW,GAAGL,gBAAgB,CAACC,GAAjB,CAAqB,OAArB,CAApB;MAEA,IAAAN,cAAA,EAAOU,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAEE,GAAb,CAAiB,iBAAjB,CAAP,EAA4CX,EAA5C,CAA+CY,EAA/C,CAAkDC,KAAlD;IACD,CANC,CAAF;IAQA3B,EAAE,CAAC,uCAAD,EAA0C,MAAM;MAChD,MAAMC,GAAG,GAAGC,qBAAA,CAAGC,gBAAH,CAAoB,aAApB,EAAmCkB,WAAnC,EAAgDnB,qBAAA,CAAGE,YAAH,CAAgBC,MAAhE,CAAZ;;MACA,MAAMa,gBAAgB,GAAG,KAAIX,+BAAJ,IAAuBe,qBAAvB,CAA6CrB,GAA7C,CAAzB;MACA,MAAMsB,WAAW,GAAGL,gBAAgB,CAACC,GAAjB,CAAqB,OAArB,CAApB;MAEA,IAAAN,cAAA,EAAOU,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAEE,GAAb,CAAiB,qBAAjB,CAAP,EAAgDX,EAAhD,CAAmDY,EAAnD,CAAsDC,KAAtD;IACD,CANC,CAAF;EAOD,CAhDO,CAAR;AAiDD,CA3HO,CAAR"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.737",
3
+ "version": "0.0.738",
4
4
  "homepage": "https://bit.dev/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "0.0.737"
9
+ "version": "0.0.738"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -18,20 +18,20 @@
18
18
  "@babel/runtime": "7.12.18",
19
19
  "core-js": "^3.0.0",
20
20
  "@teambit/harmony": "0.3.3",
21
- "@teambit/compiler": "0.0.737",
21
+ "@teambit/compiler": "0.0.738",
22
22
  "@teambit/typescript.modules.ts-config-mutator": "0.0.68",
23
- "@teambit/component": "0.0.737",
23
+ "@teambit/component": "0.0.738",
24
24
  "@teambit/semantics.entities.semantic-schema": "0.0.11",
25
25
  "@teambit/ts-server": "0.0.32",
26
- "@teambit/aspect-loader": "0.0.737",
26
+ "@teambit/aspect-loader": "0.0.738",
27
27
  "@teambit/bit-error": "0.0.394",
28
- "@teambit/builder": "0.0.737",
29
- "@teambit/isolator": "0.0.737",
28
+ "@teambit/builder": "0.0.738",
29
+ "@teambit/isolator": "0.0.738",
30
30
  "@teambit/logger": "0.0.583",
31
- "@teambit/schema": "0.0.737",
31
+ "@teambit/schema": "0.0.738",
32
32
  "@teambit/cli": "0.0.491",
33
- "@teambit/pkg": "0.0.737",
34
- "@teambit/workspace": "0.0.737"
33
+ "@teambit/pkg": "0.0.738",
34
+ "@teambit/workspace": "0.0.738"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/lodash": "4.14.165",
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.737/dist/typescript.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.737/dist/typescript.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.738/dist/typescript.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.738/dist/typescript.docs.mdx')]