@teambit/typescript 0.0.881 → 0.0.883
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmds/check-types.cmd.js +0 -21
- package/dist/cmds/check-types.cmd.js.map +1 -1
- package/dist/cmds/write-tsconfig.cmd.js +2 -25
- package/dist/cmds/write-tsconfig.cmd.js.map +1 -1
- package/dist/dedupe-path.spec.js +6 -8
- package/dist/dedupe-path.spec.js.map +1 -1
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/transformer-not-found.js +0 -7
- package/dist/exceptions/transformer-not-found.js.map +1 -1
- package/dist/export-identifier.js +0 -3
- package/dist/export-identifier.js.map +1 -1
- package/dist/export-list.js +0 -4
- package/dist/export-list.js.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/schema-extractor-context.js +16 -120
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/schema-transformer.plugin.js +0 -8
- package/dist/schema-transformer.plugin.js.map +1 -1
- package/dist/transformers/binding-element.js +0 -23
- package/dist/transformers/binding-element.js.map +1 -1
- package/dist/transformers/class-deceleration.js +2 -34
- package/dist/transformers/class-deceleration.js.map +1 -1
- package/dist/transformers/enum-declaration.js +0 -16
- package/dist/transformers/enum-declaration.js.map +1 -1
- package/dist/transformers/export-declaration.js +8 -47
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-declaration.js +2 -19
- package/dist/transformers/function-declaration.js.map +1 -1
- package/dist/transformers/index.js +0 -30
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/interface-declaration.js +0 -25
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/source-file-transformer.js +3 -24
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/type-alias.js +0 -23
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/utils/class-element-to-schema.js +0 -35
- package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/get-params.js +6 -33
- package/dist/transformers/utils/get-params.js.map +1 -1
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +4 -49
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/transformers/utils/parse-type-from-quick-info.js +4 -16
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
- package/dist/transformers/utils/to-function-like-schema.js +0 -15
- package/dist/transformers/utils/to-function-like-schema.js.map +1 -1
- package/dist/transformers/utils/type-element-to-schema.js +0 -37
- package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/type-node-to-schema.js +5 -71
- package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
- package/dist/transformers/variable-declaration.js +0 -30
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.js +0 -22
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/tsconfig-writer.js +8 -58
- package/dist/tsconfig-writer.js.map +1 -1
- package/dist/typescript.aspect.js +0 -5
- package/dist/typescript.aspect.js.map +1 -1
- package/dist/typescript.compiler.js +16 -83
- package/dist/typescript.compiler.js.map +1 -1
- package/dist/typescript.compiler.spec.js +0 -25
- package/dist/typescript.compiler.spec.js.map +1 -1
- package/dist/typescript.composition.js +0 -6
- package/dist/typescript.composition.js.map +1 -1
- package/dist/typescript.extractor.js +6 -50
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.js +10 -114
- package/dist/typescript.main.runtime.js.map +1 -1
- package/dist/typescript.parser.js +3 -30
- package/dist/typescript.parser.js.map +1 -1
- package/dist/typescript.parser.spec.js +0 -22
- package/dist/typescript.parser.spec.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.883.tgz +0 -0
- package/package.json +12 -12
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-typescript-0.0.881.tgz +0 -0
|
@@ -1,64 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.BindingElementTransformer = void 0;
|
|
11
|
-
|
|
12
9
|
function _typescript() {
|
|
13
10
|
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
-
|
|
15
11
|
_typescript = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _semanticsEntities() {
|
|
23
17
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
24
|
-
|
|
25
18
|
_semanticsEntities = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _exportIdentifier() {
|
|
33
24
|
const data = require("../export-identifier");
|
|
34
|
-
|
|
35
25
|
_exportIdentifier = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _parseTypeFromQuickInfo() {
|
|
43
31
|
const data = require("./utils/parse-type-from-quick-info");
|
|
44
|
-
|
|
45
32
|
_parseTypeFromQuickInfo = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _jsdocToDocSchema() {
|
|
53
38
|
const data = require("./utils/jsdoc-to-doc-schema");
|
|
54
|
-
|
|
55
39
|
_jsdocToDocSchema = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
/**
|
|
63
45
|
* for example:
|
|
64
46
|
*
|
|
@@ -70,14 +52,11 @@ class BindingElementTransformer {
|
|
|
70
52
|
predicate(node) {
|
|
71
53
|
return node.kind === _typescript().default.SyntaxKind.BindingElement;
|
|
72
54
|
}
|
|
73
|
-
|
|
74
55
|
async getIdentifiers(node) {
|
|
75
56
|
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
76
57
|
}
|
|
77
|
-
|
|
78
58
|
async transform(node, context) {
|
|
79
59
|
var _info$body;
|
|
80
|
-
|
|
81
60
|
const name = node.name.getText();
|
|
82
61
|
const info = await context.getQuickInfo(node.name);
|
|
83
62
|
const displaySig = (info === null || info === void 0 ? void 0 : (_info$body = info.body) === null || _info$body === void 0 ? void 0 : _info$body.displayString) || '';
|
|
@@ -86,9 +65,7 @@ class BindingElementTransformer {
|
|
|
86
65
|
const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
|
|
87
66
|
return new (_semanticsEntities().VariableLikeSchema)(context.getLocation(node), name, displaySig, type, false, doc);
|
|
88
67
|
}
|
|
89
|
-
|
|
90
68
|
}
|
|
91
|
-
|
|
92
69
|
exports.BindingElementTransformer = BindingElementTransformer;
|
|
93
70
|
|
|
94
71
|
//# sourceMappingURL=binding-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["BindingElementTransformer","predicate","node","kind","ts","SyntaxKind","BindingElement","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","context","info","getQuickInfo","displaySig","body","displayString","typeStr","parseTypeFromQuickInfo","type","resolveType","doc","jsDocToDocSchema","VariableLikeSchema","getLocation"],"sources":["binding-element.ts"],"sourcesContent":["import ts, { BindingElement, Node } from 'typescript';\nimport { VariableLikeSchema } from '@teambit/semantics.entities.semantic-schema';\nimport { SchemaTransformer } from '../schema-transformer';\nimport { SchemaExtractorContext } from '../schema-extractor-context';\nimport { ExportIdentifier } from '../export-identifier';\nimport { parseTypeFromQuickInfo } from './utils/parse-type-from-quick-info';\nimport { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\n\n/**\n * for example:\n *\n * const objBindingElem = { elem1: 1, elem2: 2 };\n * const { elem1 } = objBindingElem;\n * export { elem1 };\n */\nexport class BindingElementTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.BindingElement;\n }\n\n async getIdentifiers(node: BindingElement) {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(node: BindingElement, context: SchemaExtractorContext) {\n const name = node.name.getText();\n const info = await context.getQuickInfo(node.name);\n const displaySig = info?.body?.displayString || '';\n const typeStr = parseTypeFromQuickInfo(info);\n const type = await context.resolveType(node, typeStr);\n const doc = await jsDocToDocSchema(node, context);\n return new VariableLikeSchema(context.getLocation(node), name, displaySig, type, false, doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,CAA8B;EAClEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,cAAc;EACnD;EAEA,MAAMC,cAAc,CAACL,IAAoB,EAAE;IACzC,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACX,IAAoB,EAAEY,OAA+B,EAAE;IAAA;IACrE,MAAML,IAAI,GAAGP,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE;IAChC,MAAMK,IAAI,GAAG,MAAMD,OAAO,CAACE,YAAY,CAACd,IAAI,CAACO,IAAI,CAAC;IAClD,MAAMQ,UAAU,GAAG,CAAAF,IAAI,aAAJA,IAAI,qCAAJA,IAAI,CAAEG,IAAI,+CAAV,WAAYC,aAAa,KAAI,EAAE;IAClD,MAAMC,OAAO,GAAG,IAAAC,gDAAsB,EAACN,IAAI,CAAC;IAC5C,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACS,WAAW,CAACrB,IAAI,EAAEkB,OAAO,CAAC;IACrD,MAAMI,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACvB,IAAI,EAAEY,OAAO,CAAC;IACjD,OAAO,KAAIY,uCAAkB,EAACZ,OAAO,CAACa,WAAW,CAACzB,IAAI,CAAC,EAAEO,IAAI,EAAEQ,UAAU,EAAEK,IAAI,EAAE,KAAK,EAAEE,GAAG,CAAC;EAC9F;AACF;AAAC"}
|
|
@@ -1,119 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.ClassDecelerationTransformer = void 0;
|
|
11
|
-
|
|
12
9
|
function _pMapSeries() {
|
|
13
10
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
14
|
-
|
|
15
11
|
_pMapSeries = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _lodash() {
|
|
23
17
|
const data = require("lodash");
|
|
24
|
-
|
|
25
18
|
_lodash = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _semanticsEntities() {
|
|
33
24
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
34
|
-
|
|
35
25
|
_semanticsEntities = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _typescript() {
|
|
43
31
|
const data = _interopRequireDefault(require("typescript"));
|
|
44
|
-
|
|
45
32
|
_typescript = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _exportIdentifier() {
|
|
53
38
|
const data = require("../export-identifier");
|
|
54
|
-
|
|
55
39
|
_exportIdentifier = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
function _jsdocToDocSchema() {
|
|
63
45
|
const data = require("./utils/jsdoc-to-doc-schema");
|
|
64
|
-
|
|
65
46
|
_jsdocToDocSchema = function () {
|
|
66
47
|
return data;
|
|
67
48
|
};
|
|
68
|
-
|
|
69
49
|
return data;
|
|
70
50
|
}
|
|
71
|
-
|
|
72
51
|
function _classElementToSchema() {
|
|
73
52
|
const data = require("./utils/class-element-to-schema");
|
|
74
|
-
|
|
75
53
|
_classElementToSchema = function () {
|
|
76
54
|
return data;
|
|
77
55
|
};
|
|
78
|
-
|
|
79
56
|
return data;
|
|
80
57
|
}
|
|
81
|
-
|
|
82
58
|
class ClassDecelerationTransformer {
|
|
83
59
|
predicate(node) {
|
|
84
60
|
return node.kind === _typescript().default.SyntaxKind.ClassDeclaration;
|
|
85
|
-
}
|
|
86
|
-
|
|
61
|
+
}
|
|
87
62
|
|
|
63
|
+
// @todo: in case of `export default class` the class has no name.
|
|
88
64
|
getName(node) {
|
|
89
65
|
var _node$name;
|
|
90
|
-
|
|
91
66
|
return ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.getText()) || 'default';
|
|
92
67
|
}
|
|
93
|
-
|
|
94
68
|
async getIdentifiers(node) {
|
|
95
69
|
return [new (_exportIdentifier().ExportIdentifier)(this.getName(node), node.getSourceFile().fileName)];
|
|
96
70
|
}
|
|
97
|
-
|
|
98
71
|
async transform(node, context) {
|
|
99
72
|
const className = this.getName(node);
|
|
100
73
|
const members = await (0, _pMapSeries().default)(node.members, async member => {
|
|
101
74
|
var _member$modifiers;
|
|
102
|
-
|
|
103
75
|
const isPrivate = (_member$modifiers = member.modifiers) === null || _member$modifiers === void 0 ? void 0 : _member$modifiers.some(modifier => modifier.kind === _typescript().default.SyntaxKind.PrivateKeyword);
|
|
104
|
-
|
|
105
76
|
if (isPrivate) {
|
|
106
77
|
return null;
|
|
107
78
|
}
|
|
108
|
-
|
|
109
79
|
return (0, _classElementToSchema().classElementToSchema)(member, context);
|
|
110
80
|
});
|
|
111
81
|
const doc = await (0, _jsdocToDocSchema().jsDocToDocSchema)(node, context);
|
|
112
82
|
return new (_semanticsEntities().ClassSchema)(className, (0, _lodash().compact)(members), context.getLocation(node), doc);
|
|
113
83
|
}
|
|
114
|
-
|
|
115
84
|
}
|
|
116
|
-
|
|
117
85
|
exports.ClassDecelerationTransformer = ClassDecelerationTransformer;
|
|
118
86
|
|
|
119
87
|
//# sourceMappingURL=class-deceleration.js.map
|
|
@@ -1 +1 @@
|
|
|
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","classElementToSchema","doc","jsDocToDocSchema","ClassSchema","compact","getLocation"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema } 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 { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\nimport { classElementToSchema } from './utils/class-element-to-schema';\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 return classElementToSchema(member, context);\n });\n const doc = await jsDocToDocSchema(node, context);\n return new ClassSchema(className, compact(members), context.getLocation(node), doc);\n }\n}\n"],"mappings":"
|
|
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","classElementToSchema","doc","jsDocToDocSchema","ClassSchema","compact","getLocation"],"sources":["class-deceleration.ts"],"sourcesContent":["import pMapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport { ClassSchema } 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 { jsDocToDocSchema } from './utils/jsdoc-to-doc-schema';\nimport { classElementToSchema } from './utils/class-element-to-schema';\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 return classElementToSchema(member, context);\n });\n const doc = await jsDocToDocSchema(node, context);\n return new ClassSchema(className, compact(members), context.getLocation(node), doc);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;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,4BAA4B,CAA8B;EACrEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,gBAAgB;EACrD;;EAEA;EACQC,OAAO,CAACL,IAAsB,EAAE;IAAA;IACtC,OAAO,eAAAA,IAAI,CAACM,IAAI,+CAAT,WAAWC,OAAO,EAAE,KAAI,SAAS;EAC1C;EAEA,MAAMC,cAAc,CAACR,IAAsB,EAAE;IAC3C,OAAO,CAAC,KAAIS,oCAAgB,EAAC,IAAI,CAACJ,OAAO,CAACL,IAAI,CAAC,EAAEA,IAAI,CAACU,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EAClF;EAEA,MAAMC,SAAS,CAACZ,IAAsB,EAAEa,OAA+B,EAAE;IACvE,MAAMC,SAAS,GAAG,IAAI,CAACT,OAAO,CAACL,IAAI,CAAC;IACpC,MAAMe,OAAO,GAAG,MAAM,IAAAC,qBAAU,EAAChB,IAAI,CAACe,OAAO,EAAE,MAAOE,MAAM,IAAK;MAAA;MAC/D,MAAMC,SAAS,wBAAGD,MAAM,CAACE,SAAS,sDAAhB,kBAAkBC,IAAI,CAAEC,QAAQ,IAAKA,QAAQ,CAACpB,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACmB,cAAc,CAAC;MACtG,IAAIJ,SAAS,EAAE;QACb,OAAO,IAAI;MACb;MACA,OAAO,IAAAK,4CAAoB,EAACN,MAAM,EAAEJ,OAAO,CAAC;IAC9C,CAAC,CAAC;IACF,MAAMW,GAAG,GAAG,MAAM,IAAAC,oCAAgB,EAACzB,IAAI,EAAEa,OAAO,CAAC;IACjD,OAAO,KAAIa,gCAAW,EAACZ,SAAS,EAAE,IAAAa,iBAAO,EAACZ,OAAO,CAAC,EAAEF,OAAO,CAACe,WAAW,CAAC5B,IAAI,CAAC,EAAEwB,GAAG,CAAC;EACrF;AACF;AAAC"}
|
|
@@ -1,60 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.EnumDeclarationTransformer = void 0;
|
|
11
|
-
|
|
12
9
|
function _typescript() {
|
|
13
10
|
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
-
|
|
15
11
|
_typescript = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _semanticsEntities() {
|
|
23
17
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
24
|
-
|
|
25
18
|
_semanticsEntities = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _exportIdentifier() {
|
|
33
24
|
const data = require("../export-identifier");
|
|
34
|
-
|
|
35
25
|
_exportIdentifier = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
class EnumDeclarationTransformer {
|
|
43
31
|
predicate(node) {
|
|
44
32
|
return node.kind === _typescript().default.SyntaxKind.EnumDeclaration;
|
|
45
33
|
}
|
|
46
|
-
|
|
47
34
|
async getIdentifiers(node) {
|
|
48
35
|
return [new (_exportIdentifier().ExportIdentifier)(node.name.getText(), node.getSourceFile().fileName)];
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
async transform(enumDec, context) {
|
|
52
38
|
const members = enumDec.members.map(member => member.name.getText());
|
|
53
39
|
return new (_semanticsEntities().EnumSchema)(context.getLocation(enumDec), enumDec.name.getText(), members);
|
|
54
40
|
}
|
|
55
|
-
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
exports.EnumDeclarationTransformer = EnumDeclarationTransformer;
|
|
59
43
|
|
|
60
44
|
//# sourceMappingURL=enum-declaration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","map","member","EnumSchema","getLocation"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumSchema } 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 EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const members = enumDec.members.map((member) => member.name.getText());\n return new EnumSchema(context.getLocation(enumDec), enumDec.name.getText(), members);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["EnumDeclarationTransformer","predicate","node","kind","ts","SyntaxKind","EnumDeclaration","getIdentifiers","ExportIdentifier","name","getText","getSourceFile","fileName","transform","enumDec","context","members","map","member","EnumSchema","getLocation"],"sources":["enum-declaration.ts"],"sourcesContent":["import ts, { Node, EnumDeclaration } from 'typescript';\nimport { EnumSchema } 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 EnumDeclarationTransformer implements SchemaTransformer {\n predicate(node: Node) {\n return node.kind === ts.SyntaxKind.EnumDeclaration;\n }\n\n async getIdentifiers(node: EnumDeclaration): Promise<ExportIdentifier[]> {\n return [new ExportIdentifier(node.name.getText(), node.getSourceFile().fileName)];\n }\n\n async transform(enumDec: EnumDeclaration, context: SchemaExtractorContext) {\n const members = enumDec.members.map((member) => member.name.getText());\n return new EnumSchema(context.getLocation(enumDec), enumDec.name.getText(), members);\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;AAEO,MAAMA,0BAA0B,CAA8B;EACnEC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACC,eAAe;EACpD;EAEA,MAAMC,cAAc,CAACL,IAAqB,EAA+B;IACvE,OAAO,CAAC,KAAIM,oCAAgB,EAACN,IAAI,CAACO,IAAI,CAACC,OAAO,EAAE,EAAER,IAAI,CAACS,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACnF;EAEA,MAAMC,SAAS,CAACC,OAAwB,EAAEC,OAA+B,EAAE;IACzE,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAACC,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACT,IAAI,CAACC,OAAO,EAAE,CAAC;IACtE,OAAO,KAAIS,+BAAU,EAACJ,OAAO,CAACK,WAAW,CAACN,OAAO,CAAC,EAAEA,OAAO,CAACL,IAAI,CAACC,OAAO,EAAE,EAAEM,OAAO,CAAC;EACtF;AACF;AAAC"}
|
|
@@ -1,128 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.array.iterator.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.ExportDeclaration = void 0;
|
|
11
|
-
|
|
12
9
|
function _semanticsEntities() {
|
|
13
10
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
14
|
-
|
|
15
11
|
_semanticsEntities = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _typescript() {
|
|
23
17
|
const data = _interopRequireWildcard(require("typescript"));
|
|
24
|
-
|
|
25
18
|
_typescript = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _exportIdentifier() {
|
|
33
24
|
const data = require("../export-identifier");
|
|
34
|
-
|
|
35
25
|
_exportIdentifier = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
-
|
|
44
31
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
-
|
|
46
32
|
class ExportDeclaration {
|
|
47
33
|
predicate(node) {
|
|
48
34
|
return node.kind === _typescript().SyntaxKind.ExportDeclaration;
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
async getIdentifiers(exportDec, context) {
|
|
52
37
|
var _exportDec$exportClau, _exportDec$exportClau2;
|
|
53
|
-
|
|
54
38
|
if (((_exportDec$exportClau = exportDec.exportClause) === null || _exportDec$exportClau === void 0 ? void 0 : _exportDec$exportClau.kind) === _typescript().default.SyntaxKind.NamedExports) {
|
|
55
39
|
exportDec.exportClause;
|
|
56
40
|
return exportDec.exportClause.elements.map(elm => {
|
|
57
41
|
return new (_exportIdentifier().ExportIdentifier)(elm.name.getText(), elm.getSourceFile().fileName);
|
|
58
42
|
});
|
|
59
43
|
}
|
|
60
|
-
|
|
61
44
|
if (((_exportDec$exportClau2 = exportDec.exportClause) === null || _exportDec$exportClau2 === void 0 ? void 0 : _exportDec$exportClau2.kind) === _typescript().default.SyntaxKind.NamespaceExport) {
|
|
62
45
|
return [new (_exportIdentifier().ExportIdentifier)(exportDec.exportClause.name.getText(), exportDec.getSourceFile().fileName)];
|
|
63
46
|
}
|
|
64
|
-
|
|
65
47
|
if (exportDec.moduleSpecifier) {
|
|
66
48
|
return context.getFileExports(exportDec);
|
|
67
49
|
}
|
|
68
|
-
|
|
69
50
|
return [];
|
|
70
51
|
}
|
|
71
|
-
|
|
72
52
|
async transform(exportDec, context) {
|
|
73
|
-
const exportClause = exportDec.exportClause;
|
|
53
|
+
const exportClause = exportDec.exportClause;
|
|
74
54
|
|
|
55
|
+
// it's export-all, e.g. `export * from './button'`;
|
|
75
56
|
if (!exportClause) {
|
|
76
57
|
const specifier = exportDec.moduleSpecifier;
|
|
77
|
-
|
|
78
58
|
if (!specifier) {
|
|
79
59
|
throw new Error(`fatal: no specifier`);
|
|
80
60
|
}
|
|
81
|
-
|
|
82
61
|
const sourceFile = await context.getSourceFileFromNode(specifier);
|
|
83
|
-
|
|
84
62
|
if (!sourceFile) {
|
|
85
63
|
throw new Error(`unable to find the source-file`);
|
|
86
64
|
}
|
|
87
|
-
|
|
88
65
|
return context.computeSchema(sourceFile);
|
|
89
|
-
}
|
|
90
|
-
|
|
66
|
+
}
|
|
91
67
|
|
|
68
|
+
// e.g. `export { button1, button2 } as Composition from './button';
|
|
92
69
|
if (exportClause.kind === _typescript().SyntaxKind.NamedExports) {
|
|
93
70
|
const schemas = await namedExport(exportClause, context);
|
|
94
71
|
return new (_semanticsEntities().Module)(context.getLocation(exportDec), schemas);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
}
|
|
73
|
+
// e.g. `export * as Composition from './button';
|
|
98
74
|
if (exportClause.kind === _typescript().SyntaxKind.NamespaceExport) {
|
|
99
75
|
return namespaceExport(exportClause, exportDec, context);
|
|
100
|
-
}
|
|
101
|
-
|
|
76
|
+
}
|
|
102
77
|
|
|
78
|
+
// should never reach here. exportClause can be either NamespaceExport or NamedExports
|
|
103
79
|
throw new Error(`unrecognized exportClause type`);
|
|
104
80
|
}
|
|
105
|
-
|
|
106
81
|
}
|
|
107
|
-
|
|
108
82
|
exports.ExportDeclaration = ExportDeclaration;
|
|
109
|
-
|
|
110
83
|
async function namedExport(exportClause, context) {
|
|
111
84
|
const schemas = await Promise.all(exportClause.elements.map(async element => {
|
|
112
85
|
const definitionInfo = await context.definitionInfo(element);
|
|
113
|
-
|
|
114
86
|
if (!definitionInfo) {
|
|
115
87
|
// happens for example when the main index.ts file exports variable from an mdx file.
|
|
116
88
|
// tsserver is unable to get the definition node because it doesn't know to parse mdx files.
|
|
117
89
|
return new (_semanticsEntities().UnresolvedSchema)(context.getLocation(element.name), element.name.getText());
|
|
118
90
|
}
|
|
119
|
-
|
|
120
91
|
const definitionNode = await context.definition(definitionInfo);
|
|
121
|
-
|
|
122
92
|
if (!definitionNode) {
|
|
123
93
|
return context.getTypeRefForExternalNode(element);
|
|
124
94
|
}
|
|
125
|
-
|
|
126
95
|
if (definitionNode.parent.kind === _typescript().SyntaxKind.ExportSpecifier) {
|
|
127
96
|
// the definition node is the same node as element.name. tsserver wasn't able to find the source for it
|
|
128
97
|
// normally, "bit install" should fix it. another option is to open vscode and look for errors.
|
|
@@ -130,33 +99,25 @@ async function namedExport(exportClause, context) {
|
|
|
130
99
|
make sure "bit status" is clean and there are no errors about missing packages/links.
|
|
131
100
|
also, make sure the tsconfig.json in the root has the "jsx" setting defined.`);
|
|
132
101
|
}
|
|
133
|
-
|
|
134
102
|
return context.computeSchema(definitionNode.parent);
|
|
135
103
|
}));
|
|
136
104
|
return schemas;
|
|
137
105
|
}
|
|
138
|
-
|
|
139
106
|
async function namespaceExport(exportClause, exportDec, context) {
|
|
140
107
|
const namespace = exportClause.name.getText();
|
|
141
108
|
const filePath = await context.getFilePathByNode(exportClause.name);
|
|
142
|
-
|
|
143
109
|
if (!filePath) {
|
|
144
110
|
throw new Error(`unable to find the file-path for "${namespace}"`);
|
|
145
111
|
}
|
|
146
|
-
|
|
147
112
|
const sourceFile = context.getSourceFileInsideComponent(filePath);
|
|
148
|
-
|
|
149
113
|
if (!sourceFile) {
|
|
150
114
|
// it's a namespace from another component or an external package.
|
|
151
115
|
return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));
|
|
152
116
|
}
|
|
153
|
-
|
|
154
117
|
const result = await context.computeSchema(sourceFile);
|
|
155
|
-
|
|
156
118
|
if (!(result instanceof _semanticsEntities().Module)) {
|
|
157
119
|
throw new Error(`expect result to be instance of Module`);
|
|
158
120
|
}
|
|
159
|
-
|
|
160
121
|
result.namespace = namespace;
|
|
161
122
|
return result;
|
|
162
123
|
}
|
|
@@ -1 +1 @@
|
|
|
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","specifier","Error","sourceFile","getSourceFileFromNode","computeSchema","schemas","namedExport","Module","getLocation","namespaceExport","Promise","all","element","definitionInfo","UnresolvedSchema","definitionNode","definition","getTypeRefForExternalNode","parent","ExportSpecifier","getLocationAsString","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, Module, UnresolvedSchema } from '@teambit/semantics.entities.semantic-schema';\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(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new Module(context.getLocation(exportDec), schemas);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n const definitionInfo = await context.definitionInfo(element);\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n const definitionNode = await context.definition(definitionInfo);\n if (!definitionNode) {\n return context.getTypeRefForExternalNode(element);\n }\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n return context.computeSchema(definitionNode.parent);\n })\n );\n\n return schemas;\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":"
|
|
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","specifier","Error","sourceFile","getSourceFileFromNode","computeSchema","schemas","namedExport","Module","getLocation","namespaceExport","Promise","all","element","definitionInfo","UnresolvedSchema","definitionNode","definition","getTypeRefForExternalNode","parent","ExportSpecifier","getLocationAsString","namespace","filePath","getFilePathByNode","getSourceFileInsideComponent","getTypeRefForExternalPath","result"],"sources":["export-declaration.ts"],"sourcesContent":["import { SchemaNode, Module, UnresolvedSchema } from '@teambit/semantics.entities.semantic-schema';\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(exportDec: ExportDeclarationNode, context: SchemaExtractorContext): Promise<SchemaNode> {\n const exportClause = exportDec.exportClause;\n\n // it's export-all, e.g. `export * from './button'`;\n if (!exportClause) {\n const specifier = exportDec.moduleSpecifier;\n if (!specifier) {\n throw new Error(`fatal: no specifier`);\n }\n const sourceFile = await context.getSourceFileFromNode(specifier);\n if (!sourceFile) {\n throw new Error(`unable to find the source-file`);\n }\n return context.computeSchema(sourceFile);\n }\n\n // e.g. `export { button1, button2 } as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamedExports) {\n const schemas = await namedExport(exportClause, context);\n return new Module(context.getLocation(exportDec), schemas);\n }\n // e.g. `export * as Composition from './button';\n if (exportClause.kind === SyntaxKind.NamespaceExport) {\n return namespaceExport(exportClause, exportDec, context);\n }\n\n // should never reach here. exportClause can be either NamespaceExport or NamedExports\n throw new Error(`unrecognized exportClause type`);\n }\n}\n\nasync function namedExport(exportClause: NamedExports, context: SchemaExtractorContext): Promise<SchemaNode[]> {\n const schemas = await Promise.all(\n exportClause.elements.map(async (element) => {\n const definitionInfo = await context.definitionInfo(element);\n if (!definitionInfo) {\n // happens for example when the main index.ts file exports variable from an mdx file.\n // tsserver is unable to get the definition node because it doesn't know to parse mdx files.\n return new UnresolvedSchema(context.getLocation(element.name), element.name.getText());\n }\n const definitionNode = await context.definition(definitionInfo);\n if (!definitionNode) {\n return context.getTypeRefForExternalNode(element);\n }\n if (definitionNode.parent.kind === SyntaxKind.ExportSpecifier) {\n // the definition node is the same node as element.name. tsserver wasn't able to find the source for it\n // normally, \"bit install\" should fix it. another option is to open vscode and look for errors.\n throw new Error(`error: tsserver is unable to locate the identifier \"${element.name.getText()}\" at ${context.getLocationAsString(\n element.name\n )}.\nmake sure \"bit status\" is clean and there are no errors about missing packages/links.\nalso, make sure the tsconfig.json in the root has the \"jsx\" setting defined.`);\n }\n return context.computeSchema(definitionNode.parent);\n })\n );\n\n return schemas;\n}\n\nasync function namespaceExport(\n exportClause: NamespaceExport,\n exportDec: ExportDeclarationNode,\n context: SchemaExtractorContext\n) {\n const namespace = exportClause.name.getText();\n const filePath = await context.getFilePathByNode(exportClause.name);\n if (!filePath) {\n throw new Error(`unable to find the file-path for \"${namespace}\"`);\n }\n const sourceFile = context.getSourceFileInsideComponent(filePath);\n if (!sourceFile) {\n // it's a namespace from another component or an external package.\n return context.getTypeRefForExternalPath(namespace, filePath, context.getLocation(exportDec));\n }\n const result = await context.computeSchema(sourceFile);\n if (!(result instanceof Module)) {\n throw new Error(`expect result to be instance of Module`);\n }\n result.namespace = namespace;\n return result;\n}\n"],"mappings":"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"}
|
|
@@ -1,66 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.promise.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.FunctionDeclaration = void 0;
|
|
11
|
-
|
|
12
9
|
function _typescript() {
|
|
13
10
|
const data = _interopRequireDefault(require("typescript"));
|
|
14
|
-
|
|
15
11
|
_typescript = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _exportIdentifier() {
|
|
23
17
|
const data = require("../export-identifier");
|
|
24
|
-
|
|
25
18
|
_exportIdentifier = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _toFunctionLikeSchema() {
|
|
33
24
|
const data = require("./utils/to-function-like-schema");
|
|
34
|
-
|
|
35
25
|
_toFunctionLikeSchema = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
class FunctionDeclaration {
|
|
43
31
|
predicate(node) {
|
|
44
32
|
return node.kind === _typescript().default.SyntaxKind.FunctionDeclaration;
|
|
45
|
-
}
|
|
46
|
-
|
|
33
|
+
}
|
|
47
34
|
|
|
35
|
+
// need to check for anonymous functions assigned for vars, const and let.
|
|
48
36
|
async getIdentifiers(funcDec) {
|
|
49
37
|
return [new (_exportIdentifier().ExportIdentifier)(this.getName(funcDec), funcDec.getSourceFile().fileName)];
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
getName(funcDec) {
|
|
53
40
|
var _funcDec$name;
|
|
54
|
-
|
|
55
41
|
return ((_funcDec$name = funcDec.name) === null || _funcDec$name === void 0 ? void 0 : _funcDec$name.getText()) || '';
|
|
56
42
|
}
|
|
57
|
-
|
|
58
43
|
async transform(funcDec, context) {
|
|
59
44
|
return (0, _toFunctionLikeSchema().toFunctionLikeSchema)(funcDec, context);
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
}
|
|
63
|
-
|
|
64
47
|
exports.FunctionDeclaration = FunctionDeclaration;
|
|
65
48
|
|
|
66
49
|
//# sourceMappingURL=function-declaration.js.map
|
|
@@ -1 +1 @@
|
|
|
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-like-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":"
|
|
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-like-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,mBAAmB,CAA8B;EAC5DC,SAAS,CAACC,IAAU,EAAE;IACpB,OAAOA,IAAI,CAACC,IAAI,KAAKC,qBAAE,CAACC,UAAU,CAACL,mBAAmB;EACxD;;EAEA;EACA,MAAMM,cAAc,CAACC,OAAgC,EAAE;IACrD,OAAO,CAAC,KAAIC,oCAAgB,EAAC,IAAI,CAACC,OAAO,CAACF,OAAO,CAAC,EAAEA,OAAO,CAACG,aAAa,EAAE,CAACC,QAAQ,CAAC,CAAC;EACxF;EAEQF,OAAO,CAACF,OAAgC,EAAE;IAAA;IAChD,OAAO,kBAAAA,OAAO,CAACK,IAAI,kDAAZ,cAAcC,OAAO,EAAE,KAAI,EAAE;EACtC;EAEA,MAAMC,SAAS,CAACP,OAAgC,EAAEQ,OAA+B,EAAuB;IACtG,OAAO,IAAAC,4CAAoB,EAACT,OAAO,EAAEQ,OAAO,CAAC;EAC/C;AACF;AAAC"}
|