@@ -1694,15 +1694,15 @@ var ts;
16941694 },
16951695 readFile: readFile,
16961696 writeFile: writeFile,
1697- watchFile: function (fileName, callback) {
1697+ watchFile: function (fileName, callback, pollingInterval ) {
16981698 if (useNonPollingWatchers) {
16991699 var watchedFile_1 = watchedFileSet.addFile(fileName, callback);
17001700 return {
17011701 close: function () { return watchedFileSet.removeFile(watchedFile_1); }
17021702 };
17031703 }
17041704 else {
1705- _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
1705+ _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged);
17061706 return {
17071707 close: function () { return _fs.unwatchFile(fileName, fileChanged); }
17081708 };
@@ -5145,7 +5145,7 @@ var ts;
51455145 mergeTypings(typingOptions.include);
51465146 exclude = typingOptions.exclude || [];
51475147 var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath);
5148- if (projectRootPath !== undefined ) {
5148+ if (projectRootPath) {
51495149 possibleSearchDirs.push(projectRootPath);
51505150 }
51515151 searchDirs = ts.deduplicate(possibleSearchDirs);
@@ -5262,6 +5262,32 @@ var ts;
52625262 })(JsTyping = ts.JsTyping || (ts.JsTyping = {}));
52635263})(ts || (ts = {}));
52645264var 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;
52655291(function (ts) {
52665292 var server;
52675293 (function (server) {
@@ -5293,7 +5319,7 @@ var ts;
52935319 function createInstallTypingsRequest(project, typingOptions, cachePath) {
52945320 return {
52955321 projectName: project.getProjectName(),
5296- fileNames: project.getFileNames(),
5322+ fileNames: project.getFileNames(true ),
52975323 compilerOptions: project.getCompilerOptions(),
52985324 typingOptions: typingOptions,
52995325 projectRootPath: getProjectRootPath(project),
@@ -38981,6 +39007,7 @@ var ts;
3898139007 getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
3898239008 getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
3898339009 getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
39010+ isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
3898439011 dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker
3898539012 };
3898639013 verifyCompilerOptions();
@@ -39120,11 +39147,14 @@ var ts;
3912039147 getSourceFile: program.getSourceFile,
3912139148 getSourceFileByPath: program.getSourceFileByPath,
3912239149 getSourceFiles: program.getSourceFiles,
39123- isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; } ,
39150+ isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary ,
3912439151 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
3912539152 isEmitBlocked: isEmitBlocked
3912639153 };
3912739154 }
39155+ function isSourceFileFromExternalLibrary(file) {
39156+ return sourceFilesFoundSearchingNodeModules[file.path];
39157+ }
3912839158 function getDiagnosticsProducingTypeChecker() {
3912939159 return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
3913039160 }
@@ -52462,7 +52492,7 @@ var ts;
5246252492 }
5246352493 return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles);
5246452494 };
52465- Project.prototype.getFileNames = function () {
52495+ Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries ) {
5246652496 if (!this.program) {
5246752497 return [];
5246852498 }
@@ -52476,8 +52506,15 @@ var ts;
5247652506 }
5247752507 return rootFiles;
5247852508 }
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;
5248152518 };
5248252519 Project.prototype.getAllEmittableFiles = function () {
5248352520 if (!this.languageServiceEnabled) {
@@ -53067,11 +53104,11 @@ var ts;
5306753104 return;
5306853105 }
5306953106 switch (response.kind) {
53070- case "set" :
53107+ case server.ActionSet :
5307153108 this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings);
5307253109 project.updateGraph();
5307353110 break;
53074- case "invalidate" :
53111+ case server.ActionInvalidate :
5307553112 this.typingsCache.invalidateCachedTypingsForProject(project);
5307653113 break;
5307753114 }
@@ -56241,8 +56278,9 @@ var ts;
5624156278 return Logger;
5624256279 }());
5624356280 var NodeTypingsInstaller = (function () {
56244- function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) {
56281+ function NodeTypingsInstaller(telemetryEnabled, logger, eventPort, globalTypingsCacheLocation, newLine) {
5624556282 var _this = this;
56283+ this.telemetryEnabled = telemetryEnabled;
5624656284 this.logger = logger;
5624756285 this.eventPort = eventPort;
5624856286 this.globalTypingsCacheLocation = globalTypingsCacheLocation;
@@ -56253,15 +56291,21 @@ var ts;
5625356291 });
5625456292 }
5625556293 }
56294+ NodeTypingsInstaller.prototype.setTelemetrySender = function (telemetrySender) {
56295+ this.telemetrySender = telemetrySender;
56296+ };
5625656297 NodeTypingsInstaller.prototype.attach = function (projectService) {
5625756298 var _this = this;
5625856299 this.projectService = projectService;
5625956300 if (this.logger.hasLevel(server.LogLevel.requestTime)) {
5626056301 this.logger.info("Binding...");
5626156302 }
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+ }
5626356307 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"));
5626556309 }
5626656310 var execArgv = [];
5626756311 {
@@ -56297,19 +56341,36 @@ var ts;
5629756341 if (this.logger.hasLevel(server.LogLevel.verbose)) {
5629856342 this.logger.info("Received response: " + JSON.stringify(response));
5629956343 }
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+ }
5630056357 this.projectService.updateTypingsForProject(response);
56301- if (response.kind == "set" && this.socket) {
56358+ if (response.kind == server.ActionSet && this.socket) {
5630256359 this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8");
5630356360 }
5630456361 };
5630556362 return NodeTypingsInstaller;
5630656363 }());
5630756364 var IOSession = (function (_super) {
5630856365 __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+ }
5631356374 }
5631456375 IOSession.prototype.exit = function () {
5631556376 this.logger.info("Exiting...");
@@ -56489,17 +56550,16 @@ var ts;
5648956550 ;
5649056551 var eventPort;
5649156552 {
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;
5649856557 }
5649956558 }
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);
5650356563 process.on("uncaughtException", function (err) {
5650456564 ioSession.logError(err, "unknown");
5650556565 });
0 commit comments