@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,118 +1,83 @@
|
|
|
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
|
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
-
|
|
9
6
|
require("core-js/modules/es.string.replace.js");
|
|
10
|
-
|
|
11
7
|
Object.defineProperty(exports, "__esModule", {
|
|
12
8
|
value: true
|
|
13
9
|
});
|
|
14
10
|
exports.SchemaExtractorContext = void 0;
|
|
15
|
-
|
|
16
11
|
function _defineProperty2() {
|
|
17
12
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
-
|
|
19
13
|
_defineProperty2 = function () {
|
|
20
14
|
return data;
|
|
21
15
|
};
|
|
22
|
-
|
|
23
16
|
return data;
|
|
24
17
|
}
|
|
25
|
-
|
|
26
18
|
function _typescript() {
|
|
27
19
|
const data = _interopRequireDefault(require("typescript"));
|
|
28
|
-
|
|
29
20
|
_typescript = function () {
|
|
30
21
|
return data;
|
|
31
22
|
};
|
|
32
|
-
|
|
33
23
|
return data;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
25
|
function _tsutils() {
|
|
37
26
|
const data = require("tsutils");
|
|
38
|
-
|
|
39
27
|
_tsutils = function () {
|
|
40
28
|
return data;
|
|
41
29
|
};
|
|
42
|
-
|
|
43
30
|
return data;
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
function _lodash() {
|
|
47
33
|
const data = require("lodash");
|
|
48
|
-
|
|
49
34
|
_lodash = function () {
|
|
50
35
|
return data;
|
|
51
36
|
};
|
|
52
|
-
|
|
53
37
|
return data;
|
|
54
38
|
}
|
|
55
|
-
|
|
56
39
|
function _utils() {
|
|
57
40
|
const data = require("@teambit/legacy/dist/utils");
|
|
58
|
-
|
|
59
41
|
_utils = function () {
|
|
60
42
|
return data;
|
|
61
43
|
};
|
|
62
|
-
|
|
63
44
|
return data;
|
|
64
45
|
}
|
|
65
|
-
|
|
66
46
|
function _path() {
|
|
67
47
|
const data = require("path");
|
|
68
|
-
|
|
69
48
|
_path = function () {
|
|
70
49
|
return data;
|
|
71
50
|
};
|
|
72
|
-
|
|
73
51
|
return data;
|
|
74
52
|
}
|
|
75
|
-
|
|
76
53
|
function _semanticsEntities() {
|
|
77
54
|
const data = require("@teambit/semantics.entities.semantic-schema");
|
|
78
|
-
|
|
79
55
|
_semanticsEntities = function () {
|
|
80
56
|
return data;
|
|
81
57
|
};
|
|
82
|
-
|
|
83
58
|
return data;
|
|
84
59
|
}
|
|
85
|
-
|
|
86
60
|
function _typeNodeToSchema() {
|
|
87
61
|
const data = require("./transformers/utils/type-node-to-schema");
|
|
88
|
-
|
|
89
62
|
_typeNodeToSchema = function () {
|
|
90
63
|
return data;
|
|
91
64
|
};
|
|
92
|
-
|
|
93
65
|
return data;
|
|
94
66
|
}
|
|
95
|
-
|
|
96
67
|
function _exceptions() {
|
|
97
68
|
const data = require("./exceptions");
|
|
98
|
-
|
|
99
69
|
_exceptions = function () {
|
|
100
70
|
return data;
|
|
101
71
|
};
|
|
102
|
-
|
|
103
72
|
return data;
|
|
104
73
|
}
|
|
105
|
-
|
|
106
74
|
function _parseTypeFromQuickInfo() {
|
|
107
75
|
const data = require("./transformers/utils/parse-type-from-quick-info");
|
|
108
|
-
|
|
109
76
|
_parseTypeFromQuickInfo = function () {
|
|
110
77
|
return data;
|
|
111
78
|
};
|
|
112
|
-
|
|
113
79
|
return data;
|
|
114
80
|
}
|
|
115
|
-
|
|
116
81
|
class SchemaExtractorContext {
|
|
117
82
|
constructor(tsserver, component, extractor, componentDeps) {
|
|
118
83
|
this.tsserver = tsserver;
|
|
@@ -121,15 +86,13 @@ class SchemaExtractorContext {
|
|
|
121
86
|
this.componentDeps = componentDeps;
|
|
122
87
|
(0, _defineProperty2().default)(this, "_exports", undefined);
|
|
123
88
|
}
|
|
124
|
-
|
|
125
89
|
computeSchema(node) {
|
|
126
90
|
return this.extractor.computeSchema(node, this);
|
|
127
91
|
}
|
|
92
|
+
|
|
128
93
|
/**
|
|
129
94
|
* returns the location of a node in a source file.
|
|
130
95
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
96
|
getLocation(node, targetSourceFile, absolutePath = false) {
|
|
134
97
|
const sourceFile = targetSourceFile || node.getSourceFile();
|
|
135
98
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
@@ -142,73 +105,60 @@ class SchemaExtractorContext {
|
|
|
142
105
|
character
|
|
143
106
|
};
|
|
144
107
|
}
|
|
145
|
-
|
|
146
108
|
getLocationAsString(node) {
|
|
147
109
|
const location = this.getLocation(node);
|
|
148
110
|
return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;
|
|
149
111
|
}
|
|
150
|
-
|
|
151
112
|
getPathRelativeToComponent(filePath) {
|
|
152
113
|
const basePath = this.component.filesystem.files[0].base;
|
|
153
114
|
return (0, _path().relative)(basePath, filePath);
|
|
154
115
|
}
|
|
116
|
+
|
|
155
117
|
/**
|
|
156
118
|
* returns a signature for a node.
|
|
157
119
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
120
|
async getSignature(node) {
|
|
161
121
|
return this.tsserver.getSignatureHelp(this.getPath(node), this.getLocation(node));
|
|
162
122
|
}
|
|
123
|
+
|
|
163
124
|
/**
|
|
164
125
|
* get the position for the tsserver.
|
|
165
126
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
127
|
getPosition(sourceFile, line, offset) {
|
|
169
128
|
return sourceFile.getPositionOfLineAndCharacter(line - 1, offset - 1);
|
|
170
129
|
}
|
|
130
|
+
|
|
171
131
|
/**
|
|
172
132
|
* get the path for a source file.
|
|
173
133
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
134
|
getPath(node) {
|
|
177
135
|
const sourceFile = node.getSourceFile();
|
|
178
136
|
return sourceFile.fileName;
|
|
179
137
|
}
|
|
180
|
-
|
|
181
138
|
async getQuickInfo(node) {
|
|
182
139
|
const location = this.getLocation(node);
|
|
183
|
-
|
|
184
140
|
try {
|
|
185
141
|
return await this.tsserver.getQuickInfo(this.getPath(node), location);
|
|
186
142
|
} catch (err) {
|
|
187
143
|
if (err.message === 'No content available.') {
|
|
188
144
|
throw new Error(`unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${location.character}`);
|
|
189
145
|
}
|
|
190
|
-
|
|
191
146
|
throw err;
|
|
192
147
|
}
|
|
193
148
|
}
|
|
194
|
-
|
|
195
149
|
async getQuickInfoDisplayString(node) {
|
|
196
150
|
var _quickInfo$body;
|
|
197
|
-
|
|
198
151
|
const quickInfo = await this.getQuickInfo(node);
|
|
199
152
|
return (quickInfo === null || quickInfo === void 0 ? void 0 : (_quickInfo$body = quickInfo.body) === null || _quickInfo$body === void 0 ? void 0 : _quickInfo$body.displayString) || '';
|
|
200
153
|
}
|
|
154
|
+
|
|
201
155
|
/**
|
|
202
156
|
* returns the type definition for a type.
|
|
203
157
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
158
|
typeDefinition(node) {
|
|
207
159
|
return this.tsserver.getTypeDefinition(this.getPath(node), this.getLocation(node));
|
|
208
160
|
}
|
|
209
|
-
|
|
210
161
|
visitTypeDefinition() {}
|
|
211
|
-
|
|
212
162
|
findFileInComponent(filePath) {
|
|
213
163
|
return this.component.filesystem.files.find(file => {
|
|
214
164
|
// TODO: fix this line to support further extensions.
|
|
@@ -219,59 +169,47 @@ class SchemaExtractorContext {
|
|
|
219
169
|
});
|
|
220
170
|
return strings.find(string => string === file.path);
|
|
221
171
|
}
|
|
222
|
-
|
|
223
172
|
return false;
|
|
224
173
|
});
|
|
225
174
|
}
|
|
226
|
-
|
|
227
175
|
parsePackageNameFromPath(path) {
|
|
228
176
|
const parts = path.split('node_modules');
|
|
229
177
|
if (parts.length === 1) return '';
|
|
230
178
|
const lastPart = parts[parts.length - 1].replace(_path().sep, '');
|
|
231
179
|
const pkgParts = lastPart.split('/');
|
|
232
|
-
|
|
233
180
|
if (lastPart.startsWith('@')) {
|
|
234
181
|
// scoped package
|
|
235
182
|
return `${pkgParts[0]}/${pkgParts[1]}`;
|
|
236
183
|
}
|
|
237
|
-
|
|
238
184
|
const pkgName = pkgParts[0];
|
|
239
|
-
|
|
240
185
|
if (pkgName === 'typescript') {
|
|
241
186
|
// it's a built-in type, such as "string".
|
|
242
187
|
return '';
|
|
243
188
|
}
|
|
244
|
-
|
|
245
189
|
return pkgName;
|
|
246
190
|
}
|
|
191
|
+
|
|
247
192
|
/**
|
|
248
193
|
* return the file if part of the component.
|
|
249
194
|
* otherwise, a reference to the target package and the type name.
|
|
250
195
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
196
|
getSourceFileInsideComponent(filePath) {
|
|
254
197
|
const file = this.findFileInComponent(filePath);
|
|
255
198
|
if (!file) return undefined;
|
|
256
199
|
return this.extractor.parseSourceFile(file);
|
|
257
200
|
}
|
|
258
|
-
|
|
259
201
|
async getSourceFileFromNode(node) {
|
|
260
202
|
const filePath = await this.getFilePathByNode(node);
|
|
261
|
-
|
|
262
203
|
if (!filePath) {
|
|
263
204
|
return undefined;
|
|
264
205
|
}
|
|
265
|
-
|
|
266
206
|
return this.getSourceFileInsideComponent(filePath);
|
|
267
207
|
}
|
|
268
|
-
|
|
269
208
|
async getFilePathByNode(node) {
|
|
270
209
|
const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));
|
|
271
210
|
const firstDef = (0, _lodash().head)(def.body);
|
|
272
211
|
return firstDef === null || firstDef === void 0 ? void 0 : firstDef.file;
|
|
273
212
|
}
|
|
274
|
-
|
|
275
213
|
async definitionInfo(node) {
|
|
276
214
|
const location = this.getLocation(node);
|
|
277
215
|
const filePath = this.getPath(node);
|
|
@@ -279,58 +217,44 @@ class SchemaExtractorContext {
|
|
|
279
217
|
const firstDef = (0, _lodash().head)(def.body);
|
|
280
218
|
return firstDef;
|
|
281
219
|
}
|
|
220
|
+
|
|
282
221
|
/**
|
|
283
222
|
* get a definition for a given node.
|
|
284
223
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
224
|
async definition(definitonInfo) {
|
|
288
225
|
const startPosition = definitonInfo.start;
|
|
289
226
|
const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);
|
|
290
|
-
|
|
291
227
|
if (!sourceFile) {
|
|
292
228
|
// it might be an external reference, cant get the node
|
|
293
229
|
return undefined;
|
|
294
230
|
}
|
|
295
|
-
|
|
296
231
|
const pos = this.getPosition(sourceFile, startPosition.line, startPosition.offset);
|
|
297
232
|
const nodeAtPos = (0, _tsutils().getTokenAtPosition)(sourceFile, pos);
|
|
298
233
|
return nodeAtPos;
|
|
299
234
|
}
|
|
235
|
+
|
|
300
236
|
/**
|
|
301
237
|
* visit a definition for node - e.g. return it's schema.
|
|
302
238
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
239
|
async visitDefinition(node) {
|
|
306
240
|
const definitionInfo = await this.definitionInfo(node);
|
|
307
|
-
|
|
308
241
|
if (!definitionInfo) {
|
|
309
242
|
return undefined;
|
|
310
243
|
}
|
|
311
|
-
|
|
312
244
|
const definition = await this.definition(definitionInfo);
|
|
313
|
-
|
|
314
245
|
if (!definition) {
|
|
315
246
|
return this.getTypeRefForExternalNode(node);
|
|
316
247
|
}
|
|
317
|
-
|
|
318
248
|
return this.visit(definition.parent);
|
|
319
249
|
}
|
|
320
|
-
|
|
321
250
|
async visit(node) {
|
|
322
251
|
return this.extractor.computeSchema(node, this);
|
|
323
252
|
}
|
|
324
|
-
|
|
325
253
|
references() {}
|
|
326
|
-
|
|
327
254
|
isExported() {}
|
|
328
|
-
|
|
329
255
|
isFromComponent() {}
|
|
330
|
-
|
|
331
256
|
async getFileExports(exportDec) {
|
|
332
257
|
var _exportDec$moduleSpec;
|
|
333
|
-
|
|
334
258
|
const file = exportDec.getSourceFile().fileName;
|
|
335
259
|
const specifierPathStr = ((_exportDec$moduleSpec = exportDec.moduleSpecifier) === null || _exportDec$moduleSpec === void 0 ? void 0 : _exportDec$moduleSpec.getText()) || '';
|
|
336
260
|
const specifierPath = specifierPathStr.substring(1, specifierPathStr.length - 1);
|
|
@@ -339,21 +263,20 @@ class SchemaExtractorContext {
|
|
|
339
263
|
if (!sourceFile) return [];
|
|
340
264
|
return this.extractor.computeExportedIdentifiers(sourceFile, this);
|
|
341
265
|
}
|
|
342
|
-
|
|
343
266
|
setExports(exports) {
|
|
344
267
|
this._exports = exports;
|
|
345
268
|
return this;
|
|
346
269
|
}
|
|
347
|
-
|
|
348
270
|
getExportedIdentifiers(node) {
|
|
349
271
|
return this.extractor.computeExportedIdentifiers(node, this);
|
|
350
272
|
}
|
|
351
|
-
|
|
352
273
|
async jump(file, start) {
|
|
353
274
|
const sourceFile = this.extractor.parseSourceFile(file);
|
|
354
275
|
const pos = this.getPosition(sourceFile, start.line, start.offset);
|
|
355
276
|
const nodeAtPos = (0, _tsutils().getTokenAtPosition)(sourceFile, pos);
|
|
356
|
-
if (!nodeAtPos) return undefined;
|
|
277
|
+
if (!nodeAtPos) return undefined;
|
|
278
|
+
|
|
279
|
+
// this causes some infinite loops. it's helpful for getting more data from types that are not exported.
|
|
357
280
|
// e.g.
|
|
358
281
|
// ```ts
|
|
359
282
|
// class Bar {}
|
|
@@ -363,31 +286,25 @@ class SchemaExtractorContext {
|
|
|
363
286
|
// // @todo: make sure with Ran that it's fine. Maybe it's better to do: `this.visit(nodeAtPos.parent);`
|
|
364
287
|
// return this.visitDefinition(nodeAtPos);
|
|
365
288
|
// }
|
|
366
|
-
|
|
367
289
|
try {
|
|
368
290
|
return await this.visit(nodeAtPos);
|
|
369
291
|
} catch (err) {
|
|
370
292
|
if (err instanceof _exceptions().TransformerNotFound) {
|
|
371
293
|
return undefined;
|
|
372
294
|
}
|
|
373
|
-
|
|
374
295
|
throw err;
|
|
375
296
|
}
|
|
376
297
|
}
|
|
298
|
+
|
|
377
299
|
/**
|
|
378
300
|
* resolve a type by a node and its identifier.
|
|
379
301
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
302
|
async resolveType(node, typeStr, isTypeStrFromQuickInfo = true) {
|
|
383
303
|
var _this$_exports;
|
|
384
|
-
|
|
385
304
|
const location = this.getLocation(node);
|
|
386
|
-
|
|
387
305
|
if ((_this$_exports = this._exports) !== null && _this$_exports !== void 0 && _this$_exports.includes(typeStr)) {
|
|
388
306
|
return new (_semanticsEntities().TypeRefSchema)(location, typeStr);
|
|
389
307
|
}
|
|
390
|
-
|
|
391
308
|
if (node.type && _typescript().default.isTypeNode(node.type)) {
|
|
392
309
|
// if a node has "type" prop, it has the type data of the node. this normally happens when the code has the type
|
|
393
310
|
// explicitly, e.g. `const str: string` vs implicitly `const str = 'some-string'`, which the node won't have "type"
|
|
@@ -400,66 +317,52 @@ class SchemaExtractorContext {
|
|
|
400
317
|
* helpful. (couldn't find a rule when to use each one. e.g. "VariableDeclaration" sometimes has data only in
|
|
401
318
|
* "definition" but it's not clear when/why).
|
|
402
319
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
320
|
const getDef = async () => {
|
|
406
321
|
const typeDefinition = await this.typeDefinition(node);
|
|
407
322
|
const headTypeDefinition = (0, _lodash().head)(typeDefinition === null || typeDefinition === void 0 ? void 0 : typeDefinition.body);
|
|
408
|
-
|
|
409
323
|
if (headTypeDefinition) {
|
|
410
324
|
return headTypeDefinition;
|
|
411
325
|
}
|
|
412
|
-
|
|
413
326
|
const definition = await this.tsserver.getDefinition(node.getSourceFile().fileName, this.getLocation(node));
|
|
414
327
|
return (0, _lodash().head)(definition === null || definition === void 0 ? void 0 : definition.body);
|
|
415
328
|
};
|
|
329
|
+
const definition = await getDef();
|
|
416
330
|
|
|
417
|
-
|
|
418
|
-
|
|
331
|
+
// when we can't figure out the component/package/type of this node, we'll use the typeStr as the type.
|
|
419
332
|
const unknownExactType = async () => {
|
|
420
333
|
if (isTypeStrFromQuickInfo) {
|
|
421
334
|
return new (_semanticsEntities().InferenceTypeSchema)(location, typeStr || 'any');
|
|
422
335
|
}
|
|
423
|
-
|
|
424
336
|
const info = await this.getQuickInfo(node);
|
|
425
337
|
const type = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
426
338
|
return new (_semanticsEntities().InferenceTypeSchema)(location, type, typeStr);
|
|
427
339
|
};
|
|
428
|
-
|
|
429
340
|
if (!definition) {
|
|
430
341
|
return unknownExactType();
|
|
431
|
-
}
|
|
432
|
-
|
|
342
|
+
}
|
|
433
343
|
|
|
344
|
+
// the reason for this check is to avoid infinite loop when calling `this.jump` with the same file+location
|
|
434
345
|
const isDefInSameLocation = () => {
|
|
435
346
|
if (definition.file !== node.getSourceFile().fileName) {
|
|
436
347
|
return false;
|
|
437
348
|
}
|
|
438
|
-
|
|
439
349
|
const loc = this.getLocation(node);
|
|
440
350
|
return loc.line === definition.start.line && loc.character === definition.start.offset;
|
|
441
351
|
};
|
|
442
|
-
|
|
443
352
|
const file = this.findFileInComponent(definition.file);
|
|
444
|
-
|
|
445
353
|
if (file) {
|
|
446
354
|
if (isDefInSameLocation()) {
|
|
447
355
|
return unknownExactType();
|
|
448
356
|
}
|
|
449
|
-
|
|
450
357
|
const schemaNode = await this.jump(file, definition.start);
|
|
451
358
|
return schemaNode || unknownExactType();
|
|
452
359
|
}
|
|
453
|
-
|
|
454
360
|
return this.getTypeRefForExternalPath(typeStr, definition.file, location);
|
|
455
361
|
}
|
|
456
|
-
|
|
457
362
|
getCompIdByPkgName(pkgName) {
|
|
458
363
|
var _this$componentDeps$f;
|
|
459
|
-
|
|
460
364
|
return (_this$componentDeps$f = this.componentDeps.find(dep => dep.packageName === pkgName)) === null || _this$componentDeps$f === void 0 ? void 0 : _this$componentDeps$f.componentId;
|
|
461
365
|
}
|
|
462
|
-
|
|
463
366
|
async getTypeRefForExternalNode(node) {
|
|
464
367
|
const info = await this.getQuickInfo(node);
|
|
465
368
|
const typeStr = (0, _parseTypeFromQuickInfo().parseTypeFromQuickInfo)(info);
|
|
@@ -467,26 +370,19 @@ class SchemaExtractorContext {
|
|
|
467
370
|
const filePath = this.getPath(node);
|
|
468
371
|
return this.getTypeRefForExternalPath(typeStr, filePath, location);
|
|
469
372
|
}
|
|
470
|
-
|
|
471
373
|
async getTypeRefForExternalPath(typeStr, filePath, location) {
|
|
472
374
|
const compIdByPath = await this.extractor.getComponentIDByPath(filePath);
|
|
473
|
-
|
|
474
375
|
if (compIdByPath) {
|
|
475
376
|
return new (_semanticsEntities().TypeRefSchema)(location, typeStr, compIdByPath);
|
|
476
377
|
}
|
|
477
|
-
|
|
478
378
|
const pkgName = this.parsePackageNameFromPath(filePath);
|
|
479
379
|
const compIdByPkg = this.getCompIdByPkgName(pkgName);
|
|
480
|
-
|
|
481
380
|
if (compIdByPkg) {
|
|
482
381
|
return new (_semanticsEntities().TypeRefSchema)(location, typeStr, compIdByPkg);
|
|
483
382
|
}
|
|
484
|
-
|
|
485
383
|
return new (_semanticsEntities().TypeRefSchema)(location, typeStr, undefined, pkgName);
|
|
486
384
|
}
|
|
487
|
-
|
|
488
385
|
}
|
|
489
|
-
|
|
490
386
|
exports.SchemaExtractorContext = SchemaExtractorContext;
|
|
491
387
|
|
|
492
388
|
//# sourceMappingURL=schema-extractor-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SchemaExtractorContext","constructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","definitonInfo","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"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// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\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 readonly componentDeps: ComponentDependency[]\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 const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\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 async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(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 getSourceFileInsideComponent(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 filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definitonInfo.start;\n const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\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 definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\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.getSourceFileInsideComponent(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 || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\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 return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\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;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;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,EAIAC,aAJA,EAKT;IAAA,KAJSH,QAIT,GAJSA,QAIT;IAAA,KAHSC,SAGT,GAHSA,SAGT;IAAA,KAFSC,SAET,GAFSA,SAET;IAAA,KADSC,aACT,GADSA,aACT;IAAA,kDA8MiCC,SA9MjC;EAAE;;EAEJC,aAAa,CAACC,IAAD,EAAa;IACxB,OAAO,KAAKJ,SAAL,CAAeG,aAAf,CAA6BC,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ructor","tsserver","component","extractor","componentDeps","undefined","computeSchema","node","getLocation","targetSourceFile","absolutePath","sourceFile","getSourceFile","position","getLineAndCharacterOfPosition","getStart","line","character","filePath","fileName","getPathRelativeToComponent","pathNormalizeToLinux","getLocationAsString","location","basePath","filesystem","files","base","relative","getSignature","getSignatureHelp","getPath","getPosition","offset","getPositionOfLineAndCharacter","getQuickInfo","err","message","Error","getQuickInfoDisplayString","quickInfo","body","displayString","typeDefinition","getTypeDefinition","visitTypeDefinition","findFileInComponent","find","file","path","includes","strings","map","format","endsWith","string","parsePackageNameFromPath","parts","split","length","lastPart","replace","sep","pkgParts","startsWith","pkgName","getSourceFileInsideComponent","parseSourceFile","getSourceFileFromNode","getFilePathByNode","def","getDefinition","firstDef","head","definitionInfo","definition","definitonInfo","startPosition","start","pos","nodeAtPos","getTokenAtPosition","visitDefinition","getTypeRefForExternalNode","visit","parent","references","isExported","isFromComponent","getFileExports","exportDec","specifierPathStr","moduleSpecifier","getText","specifierPath","substring","absPath","resolve","computeExportedIdentifiers","setExports","exports","_exports","getExportedIdentifiers","jump","TransformerNotFound","resolveType","typeStr","isTypeStrFromQuickInfo","TypeRefSchema","type","ts","isTypeNode","typeNodeToSchema","getDef","headTypeDefinition","unknownExactType","InferenceTypeSchema","info","parseTypeFromQuickInfo","isDefInSameLocation","loc","schemaNode","getTypeRefForExternalPath","getCompIdByPkgName","dep","packageName","componentId","compIdByPath","getComponentIDByPath","compIdByPkg"],"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// eslint-disable-next-line import/no-unresolved\nimport protocol from 'typescript/lib/protocol';\n// @ts-ignore david we should figure fix this.\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { resolve, sep, relative } from 'path';\nimport { Component, ComponentID } from '@teambit/component';\nimport { TypeRefSchema, SchemaNode, InferenceTypeSchema, Location } from '@teambit/semantics.entities.semantic-schema';\nimport { ComponentDependency } from '@teambit/dependency-resolver';\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 readonly componentDeps: ComponentDependency[]\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 const filePath = absolutePath ? sourceFile.fileName : this.getPathRelativeToComponent(sourceFile.fileName);\n\n return {\n filePath: pathNormalizeToLinux(filePath),\n line,\n character,\n };\n }\n\n getLocationAsString(node: Node): string {\n const location = this.getLocation(node);\n return `${node.getSourceFile().fileName}, line: ${location.line}, character: ${location.character}`;\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 async getQuickInfo(node: Node) {\n const location = this.getLocation(node);\n try {\n return await this.tsserver.getQuickInfo(this.getPath(node), location);\n } catch (err: any) {\n if (err.message === 'No content available.') {\n throw new Error(\n `unable to get quickinfo data from tsserver at ${this.getPath(node)}, Ln ${location.line}, Col ${\n location.character\n }`\n );\n }\n throw err;\n }\n }\n\n async getQuickInfoDisplayString(node: Node): Promise<string> {\n const quickInfo = await this.getQuickInfo(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 getSourceFileInsideComponent(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 filePath = await this.getFilePathByNode(node);\n if (!filePath) {\n return undefined;\n }\n return this.getSourceFileInsideComponent(filePath);\n }\n\n async getFilePathByNode(node: Node) {\n const def = await this.tsserver.getDefinition(this.getPath(node), this.getLocation(node));\n\n const firstDef = head(def.body);\n return firstDef?.file;\n }\n\n async definitionInfo(node: Node): Promise<protocol.DefinitionInfo | undefined> {\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n\n const def = await this.tsserver.getDefinition(filePath, location);\n\n const firstDef = head(def.body);\n\n return firstDef;\n }\n\n /**\n * get a definition for a given node.\n */\n async definition(definitonInfo: protocol.DefinitionInfo): Promise<Node | undefined> {\n const startPosition = definitonInfo.start;\n const sourceFile = this.getSourceFileInsideComponent(definitonInfo.file);\n if (!sourceFile) {\n // it might be an external reference, cant get the node\n return undefined;\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 definitionInfo = await this.definitionInfo(node);\n if (!definitionInfo) {\n return undefined;\n }\n\n const definition = await this.definition(definitionInfo);\n if (!definition) {\n return this.getTypeRefForExternalNode(node);\n }\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.getSourceFileInsideComponent(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 || 'any');\n }\n const info = await this.getQuickInfo(node);\n const type = parseTypeFromQuickInfo(info);\n return new InferenceTypeSchema(location, type, typeStr);\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 return this.getTypeRefForExternalPath(typeStr, definition.file, location);\n }\n\n private getCompIdByPkgName(pkgName: string): ComponentID | undefined {\n return this.componentDeps.find((dep) => dep.packageName === pkgName)?.componentId;\n }\n\n async getTypeRefForExternalNode(node: Node): Promise<TypeRefSchema> {\n const info = await this.getQuickInfo(node);\n const typeStr = parseTypeFromQuickInfo(info);\n const location = this.getLocation(node);\n const filePath = this.getPath(node);\n return this.getTypeRefForExternalPath(typeStr, filePath, location);\n }\n\n async getTypeRefForExternalPath(typeStr: string, filePath: string, location: Location): Promise<TypeRefSchema> {\n const compIdByPath = await this.extractor.getComponentIDByPath(filePath);\n if (compIdByPath) {\n return new TypeRefSchema(location, typeStr, compIdByPath);\n }\n const pkgName = this.parsePackageNameFromPath(filePath);\n const compIdByPkg = this.getCompIdByPkgName(pkgName);\n if (compIdByPkg) {\n return new TypeRefSchema(location, typeStr, compIdByPkg);\n }\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;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;E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9D,OAAO,GAAG,IAAI,CAACT,wBAAwB,CAACtC,QAAQ,CAAC;IACvD,MAAM+G,WAAW,GAAG,IAAI,CAACN,kBAAkB,CAAC1D,OAAO,CAAC;IACpD,IAAIgE,WAAW,EAAE;MACf,OAAO,KAAIrB,kCAAa,EAACrF,QAAQ,EAAEmF,OAAO,EAAEuB,WAAW,CAAC;IAC1D;IACA,OAAO,KAAIrB,kCAAa,EAACrF,QAAQ,EAAEmF,OAAO,EAAErG,SAAS,EAAE4D,OAAO,CAAC;EACjE;AACF;AAAC"}
|
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SchemaTransformerPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
function _defineProperty2() {
|
|
11
9
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
|
|
13
10
|
_defineProperty2 = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
class SchemaTransformerPlugin {
|
|
21
16
|
constructor(schemaTransformerSlot) {
|
|
22
17
|
this.schemaTransformerSlot = schemaTransformerSlot;
|
|
23
18
|
(0, _defineProperty2().default)(this, "pattern", '*.schema-extractor.*');
|
|
24
19
|
(0, _defineProperty2().default)(this, "runtimes", ['main']);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
register(object) {
|
|
28
22
|
return this.schemaTransformerSlot.register([object]);
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
exports.SchemaTransformerPlugin = SchemaTransformerPlugin;
|
|
34
26
|
|
|
35
27
|
//# sourceMappingURL=schema-transformer.plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
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 register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"],"mappings":"
|
|
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 register(object: any) {\n return this.schemaTransformerSlot.register([object]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAGO,MAAMA,uBAAuB,CAA6B;EAC/DC,WAAW,CAASC,qBAA4C,EAAE;IAAA,KAA9CA,qBAA4C,GAA5CA,qBAA4C;IAAA,iDAEtD,sBAAsB;IAAA,kDAErB,CAAC,MAAM,CAAC;EAJgD;EAMnEC,QAAQ,CAACC,MAAW,EAAE;IACpB,OAAO,IAAI,CAACF,qBAAqB,CAACC,QAAQ,CAAC,CAACC,MAAM,CAAC,CAAC;EACtD;AACF;AAAC"}
|