@@ -1694,15 +1694,15 @@ var ts;
1694
1694
},
1695
1695
readFile: readFile,
1696
1696
writeFile: writeFile,
1697
- watchFile: function (fileName, callback) {
1697
+ watchFile: function (fileName, callback, pollingInterval ) {
1698
1698
if (useNonPollingWatchers) {
1699
1699
var watchedFile_1 = watchedFileSet.addFile(fileName, callback);
1700
1700
return {
1701
1701
close: function () { return watchedFileSet.removeFile(watchedFile_1); }
1702
1702
};
1703
1703
}
1704
1704
else {
1705
- _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
1705
+ _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged);
1706
1706
return {
1707
1707
close: function () { return _fs.unwatchFile(fileName, fileChanged); }
1708
1708
};
@@ -5145,7 +5145,7 @@ var ts;
5145
5145
mergeTypings(typingOptions.include);
5146
5146
exclude = typingOptions.exclude || [];
5147
5147
var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath);
5148
- if (projectRootPath !== undefined ) {
5148
+ if (projectRootPath) {
5149
5149
possibleSearchDirs.push(projectRootPath);
5150
5150
}
5151
5151
searchDirs = ts.deduplicate(possibleSearchDirs);
@@ -5262,6 +5262,32 @@ var ts;
5262
5262
})(JsTyping = ts.JsTyping || (ts.JsTyping = {}));
5263
5263
})(ts || (ts = {}));
5264
5264
var ts;
5265
+ (function (ts) {
5266
+ var server;
5267
+ (function (server) {
5268
+ server.ActionSet = "action::set";
5269
+ server.ActionInvalidate = "action::invalidate";
5270
+ server.EventInstall = "event::install";
5271
+ var Arguments;
5272
+ (function (Arguments) {
5273
+ Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation";
5274
+ Arguments.LogFile = "--logFile";
5275
+ Arguments.EnableTelemetry = "--enableTelemetry";
5276
+ })(Arguments = server.Arguments || (server.Arguments = {}));
5277
+ function hasArgument(argumentName) {
5278
+ return ts.sys.args.indexOf(argumentName) >= 0;
5279
+ }
5280
+ server.hasArgument = hasArgument;
5281
+ function findArgument(argumentName) {
5282
+ var index = ts.sys.args.indexOf(argumentName);
5283
+ return index >= 0 && index < ts.sys.args.length - 1
5284
+ ? ts.sys.args[index + 1]
5285
+ : undefined;
5286
+ }
5287
+ server.findArgument = findArgument;
5288
+ })(server = ts.server || (ts.server = {}));
5289
+ })(ts || (ts = {}));
5290
+ var ts;
5265
5291
(function (ts) {
5266
5292
var server;
5267
5293
(function (server) {
@@ -5293,7 +5319,7 @@ var ts;
5293
5319
function createInstallTypingsRequest(project, typingOptions, cachePath) {
5294
5320
return {
5295
5321
projectName: project.getProjectName(),
5296
- fileNames: project.getFileNames(),
5322
+ fileNames: project.getFileNames(true ),
5297
5323
compilerOptions: project.getCompilerOptions(),
5298
5324
typingOptions: typingOptions,
5299
5325
projectRootPath: getProjectRootPath(project),
@@ -38981,6 +39007,7 @@ var ts;
38981
39007
getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
38982
39008
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
38983
39009
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
39010
+ isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
38984
39011
dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker
38985
39012
};
38986
39013
verifyCompilerOptions();
@@ -39120,11 +39147,14 @@ var ts;
39120
39147
getSourceFile: program.getSourceFile,
39121
39148
getSourceFileByPath: program.getSourceFileByPath,
39122
39149
getSourceFiles: program.getSourceFiles,
39123
- isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; } ,
39150
+ isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary ,
39124
39151
writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
39125
39152
isEmitBlocked: isEmitBlocked
39126
39153
};
39127
39154
}
39155
+ function isSourceFileFromExternalLibrary(file) {
39156
+ return sourceFilesFoundSearchingNodeModules[file.path];
39157
+ }
39128
39158
function getDiagnosticsProducingTypeChecker() {
39129
39159
return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
39130
39160
}
@@ -52462,7 +52492,7 @@ var ts;
52462
52492
}
52463
52493
return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles);
52464
52494
};
52465
- Project.prototype.getFileNames = function () {
52495
+ Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries ) {
52466
52496
if (!this.program) {
52467
52497
return [];
52468
52498
}
@@ -52476,8 +52506,15 @@ var ts;
52476
52506
}
52477
52507
return rootFiles;
52478
52508
}
52479
- var sourceFiles = this.program.getSourceFiles();
52480
- return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); });
52509
+ var result = [];
52510
+ for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) {
52511
+ var f = _a[_i];
52512
+ if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) {
52513
+ continue;
52514
+ }
52515
+ result.push(server.asNormalizedPath(f.fileName));
52516
+ }
52517
+ return result;
52481
52518
};
52482
52519
Project.prototype.getAllEmittableFiles = function () {
52483
52520
if (!this.languageServiceEnabled) {
@@ -53067,11 +53104,11 @@ var ts;
53067
53104
return;
53068
53105
}
53069
53106
switch (response.kind) {
53070
- case "set" :
53107
+ case server.ActionSet :
53071
53108
this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings);
53072
53109
project.updateGraph();
53073
53110
break;
53074
- case "invalidate" :
53111
+ case server.ActionInvalidate :
53075
53112
this.typingsCache.invalidateCachedTypingsForProject(project);
53076
53113
break;
53077
53114
}
@@ -56241,8 +56278,9 @@ var ts;
56241
56278
return Logger;
56242
56279
}());
56243
56280
var NodeTypingsInstaller = (function () {
56244
- function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) {
56281
+ function NodeTypingsInstaller(telemetryEnabled, logger, eventPort, globalTypingsCacheLocation, newLine) {
56245
56282
var _this = this;
56283
+ this.telemetryEnabled = telemetryEnabled;
56246
56284
this.logger = logger;
56247
56285
this.eventPort = eventPort;
56248
56286
this.globalTypingsCacheLocation = globalTypingsCacheLocation;
@@ -56253,15 +56291,21 @@ var ts;
56253
56291
});
56254
56292
}
56255
56293
}
56294
+ NodeTypingsInstaller.prototype.setTelemetrySender = function (telemetrySender) {
56295
+ this.telemetrySender = telemetrySender;
56296
+ };
56256
56297
NodeTypingsInstaller.prototype.attach = function (projectService) {
56257
56298
var _this = this;
56258
56299
this.projectService = projectService;
56259
56300
if (this.logger.hasLevel(server.LogLevel.requestTime)) {
56260
56301
this.logger.info("Binding...");
56261
56302
}
56262
- var args = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation];
56303
+ var args = [server.Arguments.GlobalCacheLocation, this.globalTypingsCacheLocation];
56304
+ if (this.telemetryEnabled) {
56305
+ args.push(server.Arguments.EnableTelemetry);
56306
+ }
56263
56307
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
56264
- args.push("--logFile" , ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log"));
56308
+ args.push(server.Arguments.LogFile , ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log"));
56265
56309
}
56266
56310
var execArgv = [];
56267
56311
{
@@ -56297,19 +56341,36 @@ var ts;
56297
56341
if (this.logger.hasLevel(server.LogLevel.verbose)) {
56298
56342
this.logger.info("Received response: " + JSON.stringify(response));
56299
56343
}
56344
+ if (response.kind === server.EventInstall) {
56345
+ if (this.telemetrySender) {
56346
+ var body = {
56347
+ telemetryEventName: "typingsInstalled",
56348
+ payload: {
56349
+ installedPackages: response.packagesToInstall.join(",")
56350
+ }
56351
+ };
56352
+ var eventName = "telemetry";
56353
+ this.telemetrySender.event(body, eventName);
56354
+ }
56355
+ return;
56356
+ }
56300
56357
this.projectService.updateTypingsForProject(response);
56301
- if (response.kind == "set" && this.socket) {
56358
+ if (response.kind == server.ActionSet && this.socket) {
56302
56359
this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8");
56303
56360
}
56304
56361
};
56305
56362
return NodeTypingsInstaller;
56306
56363
}());
56307
56364
var IOSession = (function (_super) {
56308
56365
__extends(IOSession, _super);
56309
- function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, logger) {
56310
- _super.call(this, host, cancellationToken, useSingleInferredProject, disableAutomaticTypingAcquisition
56311
- ? server.nullTypingsInstaller
56312
- : new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents);
56366
+ function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) {
56367
+ var typingsInstaller = disableAutomaticTypingAcquisition
56368
+ ? undefined
56369
+ : new NodeTypingsInstaller(telemetryEnabled, logger, installerEventPort, globalTypingsCacheLocation, host.newLine);
56370
+ _super.call(this, host, cancellationToken, useSingleInferredProject, typingsInstaller || server.nullTypingsInstaller, Buffer.byteLength, process.hrtime, logger, canUseEvents);
56371
+ if (telemetryEnabled && typingsInstaller) {
56372
+ typingsInstaller.setTelemetrySender(this);
56373
+ }
56313
56374
}
56314
56375
IOSession.prototype.exit = function () {
56315
56376
this.logger.info("Exiting...");
@@ -56489,17 +56550,16 @@ var ts;
56489
56550
;
56490
56551
var eventPort;
56491
56552
{
56492
- var index = sys.args.indexOf("--eventPort");
56493
- if (index >= 0 && index < sys.args.length - 1) {
56494
- var v = parseInt(sys.args[index + 1]);
56495
- if (!isNaN(v)) {
56496
- eventPort = v;
56497
- }
56553
+ var str = server.findArgument("--eventPort");
56554
+ var v = str && parseInt(str);
56555
+ if (!isNaN(v)) {
56556
+ eventPort = v;
56498
56557
}
56499
56558
}
56500
- var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0;
56501
- var disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0;
56502
- var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), logger);
56559
+ var useSingleInferredProject = server.hasArgument("--useSingleInferredProject");
56560
+ var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition");
56561
+ var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry);
56562
+ var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), telemetryEnabled, logger);
56503
56563
process.on("uncaughtException", function (err) {
56504
56564
ioSession.logError(err, "unknown");
56505
56565
});
0 commit comments