typescript 5.5.0-dev.20240319 → 5.5.0-dev.20240321
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/lib/lib.esnext.array.d.ts +35 -0
- package/lib/lib.esnext.d.ts +1 -0
- package/lib/tsc.js +130 -401
- package/lib/tsserver.js +108 -114
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +141 -372
- package/lib/typingsInstaller.js +18 -24
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -29,23 +29,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
29
|
};
|
|
30
30
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
31
31
|
|
|
32
|
-
// src/tsserver/_namespaces/ts.ts
|
|
33
|
-
var ts_exports = {};
|
|
34
|
-
|
|
35
32
|
// src/typescript/typescript.ts
|
|
36
33
|
var typescript_exports = {};
|
|
37
34
|
__reExport(typescript_exports, require("./typescript.js"));
|
|
38
35
|
|
|
39
|
-
// src/tsserver/_namespaces/ts.ts
|
|
40
|
-
__reExport(ts_exports, typescript_exports);
|
|
41
|
-
|
|
42
36
|
// src/tsserver/common.ts
|
|
43
37
|
function getLogLevel(level) {
|
|
44
38
|
if (level) {
|
|
45
39
|
const l = level.toLowerCase();
|
|
46
|
-
for (const name in
|
|
40
|
+
for (const name in typescript_exports.server.LogLevel) {
|
|
47
41
|
if (isNaN(+name) && l === name.toLowerCase()) {
|
|
48
|
-
return
|
|
42
|
+
return typescript_exports.server.LogLevel[name];
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
}
|
|
@@ -71,7 +65,7 @@ function parseLoggingEnvironmentString(logEnvStr) {
|
|
|
71
65
|
break;
|
|
72
66
|
case "-level":
|
|
73
67
|
const level = getLogLevel(value);
|
|
74
|
-
logEnv.detailLevel = level !== void 0 ? level :
|
|
68
|
+
logEnv.detailLevel = level !== void 0 ? level : typescript_exports.server.LogLevel.normal;
|
|
75
69
|
break;
|
|
76
70
|
case "-traceToConsole":
|
|
77
71
|
logEnv.traceToConsole = value.toLowerCase() === "true";
|
|
@@ -86,35 +80,35 @@ function parseLoggingEnvironmentString(logEnvStr) {
|
|
|
86
80
|
function getEntireValue(initialIndex) {
|
|
87
81
|
let pathStart = args[initialIndex];
|
|
88
82
|
let extraPartCounter = 0;
|
|
89
|
-
if (pathStart.charCodeAt(0) ===
|
|
83
|
+
if (pathStart.charCodeAt(0) === typescript_exports.CharacterCodes.doubleQuote && pathStart.charCodeAt(pathStart.length - 1) !== typescript_exports.CharacterCodes.doubleQuote) {
|
|
90
84
|
for (let i = initialIndex + 1; i < args.length; i++) {
|
|
91
85
|
pathStart += " ";
|
|
92
86
|
pathStart += args[i];
|
|
93
87
|
extraPartCounter++;
|
|
94
|
-
if (pathStart.charCodeAt(pathStart.length - 1) ===
|
|
88
|
+
if (pathStart.charCodeAt(pathStart.length - 1) === typescript_exports.CharacterCodes.doubleQuote)
|
|
95
89
|
break;
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
|
-
return { value: (0,
|
|
92
|
+
return { value: (0, typescript_exports.stripQuotes)(pathStart), extraPartCounter };
|
|
99
93
|
}
|
|
100
94
|
}
|
|
101
95
|
function parseServerMode() {
|
|
102
|
-
const mode =
|
|
96
|
+
const mode = typescript_exports.server.findArgument("--serverMode");
|
|
103
97
|
if (!mode)
|
|
104
98
|
return void 0;
|
|
105
99
|
switch (mode.toLowerCase()) {
|
|
106
100
|
case "semantic":
|
|
107
|
-
return
|
|
101
|
+
return typescript_exports.LanguageServiceMode.Semantic;
|
|
108
102
|
case "partialsemantic":
|
|
109
|
-
return
|
|
103
|
+
return typescript_exports.LanguageServiceMode.PartialSemantic;
|
|
110
104
|
case "syntactic":
|
|
111
|
-
return
|
|
105
|
+
return typescript_exports.LanguageServiceMode.Syntactic;
|
|
112
106
|
default:
|
|
113
107
|
return mode;
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
110
|
function initializeNodeSystem() {
|
|
117
|
-
const sys4 =
|
|
111
|
+
const sys4 = typescript_exports.Debug.checkDefined(typescript_exports.sys);
|
|
118
112
|
const childProcess = require("child_process");
|
|
119
113
|
const fs = require("fs");
|
|
120
114
|
class Logger {
|
|
@@ -138,20 +132,20 @@ function initializeNodeSystem() {
|
|
|
138
132
|
}
|
|
139
133
|
close() {
|
|
140
134
|
if (this.fd >= 0) {
|
|
141
|
-
fs.close(this.fd,
|
|
135
|
+
fs.close(this.fd, typescript_exports.noop);
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
getLogFileName() {
|
|
145
139
|
return this.logFilename;
|
|
146
140
|
}
|
|
147
141
|
perftrc(s) {
|
|
148
|
-
this.msg(s,
|
|
142
|
+
this.msg(s, typescript_exports.server.Msg.Perf);
|
|
149
143
|
}
|
|
150
144
|
info(s) {
|
|
151
|
-
this.msg(s,
|
|
145
|
+
this.msg(s, typescript_exports.server.Msg.Info);
|
|
152
146
|
}
|
|
153
147
|
err(s) {
|
|
154
|
-
this.msg(s,
|
|
148
|
+
this.msg(s, typescript_exports.server.Msg.Err);
|
|
155
149
|
}
|
|
156
150
|
startGroup() {
|
|
157
151
|
this.inGroup = true;
|
|
@@ -166,22 +160,22 @@ function initializeNodeSystem() {
|
|
|
166
160
|
hasLevel(level) {
|
|
167
161
|
return this.loggingEnabled() && this.level >= level;
|
|
168
162
|
}
|
|
169
|
-
msg(s, type =
|
|
163
|
+
msg(s, type = typescript_exports.server.Msg.Err) {
|
|
170
164
|
var _a, _b, _c;
|
|
171
165
|
switch (type) {
|
|
172
|
-
case
|
|
173
|
-
(_a =
|
|
166
|
+
case typescript_exports.server.Msg.Info:
|
|
167
|
+
(_a = typescript_exports.perfLogger) == null ? void 0 : _a.logInfoEvent(s);
|
|
174
168
|
break;
|
|
175
|
-
case
|
|
176
|
-
(_b =
|
|
169
|
+
case typescript_exports.server.Msg.Perf:
|
|
170
|
+
(_b = typescript_exports.perfLogger) == null ? void 0 : _b.logPerfEvent(s);
|
|
177
171
|
break;
|
|
178
172
|
default:
|
|
179
|
-
(_c =
|
|
173
|
+
(_c = typescript_exports.perfLogger) == null ? void 0 : _c.logErrEvent(s);
|
|
180
174
|
break;
|
|
181
175
|
}
|
|
182
176
|
if (!this.canWrite())
|
|
183
177
|
return;
|
|
184
|
-
s = `[${
|
|
178
|
+
s = `[${typescript_exports.server.nowString()}] ${s}
|
|
185
179
|
`;
|
|
186
180
|
if (!this.inGroup || this.firstInGroup) {
|
|
187
181
|
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
|
|
@@ -212,23 +206,23 @@ function initializeNodeSystem() {
|
|
|
212
206
|
}
|
|
213
207
|
}
|
|
214
208
|
}
|
|
215
|
-
const libDirectory = (0,
|
|
209
|
+
const libDirectory = (0, typescript_exports.getDirectoryPath)((0, typescript_exports.normalizePath)(sys4.getExecutingFilePath()));
|
|
216
210
|
const useWatchGuard = process.platform === "win32";
|
|
217
211
|
const originalWatchDirectory = sys4.watchDirectory.bind(sys4);
|
|
218
212
|
const logger = createLogger();
|
|
219
|
-
|
|
213
|
+
typescript_exports.Debug.loggingHost = {
|
|
220
214
|
log(level, s) {
|
|
221
215
|
switch (level) {
|
|
222
|
-
case
|
|
223
|
-
case
|
|
224
|
-
return logger.msg(s,
|
|
225
|
-
case
|
|
226
|
-
case
|
|
227
|
-
return logger.msg(s,
|
|
216
|
+
case typescript_exports.LogLevel.Error:
|
|
217
|
+
case typescript_exports.LogLevel.Warning:
|
|
218
|
+
return logger.msg(s, typescript_exports.server.Msg.Err);
|
|
219
|
+
case typescript_exports.LogLevel.Info:
|
|
220
|
+
case typescript_exports.LogLevel.Verbose:
|
|
221
|
+
return logger.msg(s, typescript_exports.server.Msg.Info);
|
|
228
222
|
}
|
|
229
223
|
}
|
|
230
224
|
};
|
|
231
|
-
const pending = (0,
|
|
225
|
+
const pending = (0, typescript_exports.createQueue)();
|
|
232
226
|
let canWrite = true;
|
|
233
227
|
if (useWatchGuard) {
|
|
234
228
|
const currentDrive = extractWatchDirectoryCacheKey(
|
|
@@ -241,35 +235,35 @@ function initializeNodeSystem() {
|
|
|
241
235
|
const cacheKey = extractWatchDirectoryCacheKey(path, currentDrive);
|
|
242
236
|
let status = cacheKey && statusCache.get(cacheKey);
|
|
243
237
|
if (status === void 0) {
|
|
244
|
-
if (logger.hasLevel(
|
|
238
|
+
if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
245
239
|
logger.info(`${cacheKey} for path ${path} not found in cache...`);
|
|
246
240
|
}
|
|
247
241
|
try {
|
|
248
|
-
const args = [(0,
|
|
249
|
-
if (logger.hasLevel(
|
|
250
|
-
logger.info(`Starting ${process.execPath} with args:${
|
|
242
|
+
const args = [(0, typescript_exports.combinePaths)(libDirectory, "watchGuard.js"), path];
|
|
243
|
+
if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
244
|
+
logger.info(`Starting ${process.execPath} with args:${typescript_exports.server.stringifyIndented(args)}`);
|
|
251
245
|
}
|
|
252
246
|
childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { ELECTRON_RUN_AS_NODE: "1" } });
|
|
253
247
|
status = true;
|
|
254
|
-
if (logger.hasLevel(
|
|
248
|
+
if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
255
249
|
logger.info(`WatchGuard for path ${path} returned: OK`);
|
|
256
250
|
}
|
|
257
251
|
} catch (e) {
|
|
258
252
|
status = false;
|
|
259
|
-
if (logger.hasLevel(
|
|
253
|
+
if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
260
254
|
logger.info(`WatchGuard for path ${path} returned: ${e.message}`);
|
|
261
255
|
}
|
|
262
256
|
}
|
|
263
257
|
if (cacheKey) {
|
|
264
258
|
statusCache.set(cacheKey, status);
|
|
265
259
|
}
|
|
266
|
-
} else if (logger.hasLevel(
|
|
260
|
+
} else if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
267
261
|
logger.info(`watchDirectory for ${path} uses cached drive information.`);
|
|
268
262
|
}
|
|
269
263
|
if (status) {
|
|
270
264
|
return watchDirectorySwallowingException(path, callback, recursive, options);
|
|
271
265
|
} else {
|
|
272
|
-
return
|
|
266
|
+
return typescript_exports.noopFileWatcher;
|
|
273
267
|
}
|
|
274
268
|
};
|
|
275
269
|
} else {
|
|
@@ -291,11 +285,11 @@ function initializeNodeSystem() {
|
|
|
291
285
|
const factory = require("./cancellationToken");
|
|
292
286
|
cancellationToken = factory(sys4.args);
|
|
293
287
|
} catch (e) {
|
|
294
|
-
cancellationToken =
|
|
288
|
+
cancellationToken = typescript_exports.server.nullCancellationToken;
|
|
295
289
|
}
|
|
296
|
-
const localeStr =
|
|
290
|
+
const localeStr = typescript_exports.server.findArgument("--locale");
|
|
297
291
|
if (localeStr) {
|
|
298
|
-
(0,
|
|
292
|
+
(0, typescript_exports.validateLocaleAndSetLanguage)(localeStr, sys4);
|
|
299
293
|
}
|
|
300
294
|
const modeOrUnknown = parseServerMode();
|
|
301
295
|
let serverMode;
|
|
@@ -315,10 +309,10 @@ function initializeNodeSystem() {
|
|
|
315
309
|
startSession: startNodeSession
|
|
316
310
|
};
|
|
317
311
|
function createLogger() {
|
|
318
|
-
const cmdLineLogFileName =
|
|
319
|
-
const cmdLineVerbosity = getLogLevel(
|
|
312
|
+
const cmdLineLogFileName = typescript_exports.server.findArgument("--logFile");
|
|
313
|
+
const cmdLineVerbosity = getLogLevel(typescript_exports.server.findArgument("--logVerbosity"));
|
|
320
314
|
const envLogOptions = parseLoggingEnvironmentString(process.env.TSS_LOG);
|
|
321
|
-
const unsubstitutedLogFileName = cmdLineLogFileName ? (0,
|
|
315
|
+
const unsubstitutedLogFileName = cmdLineLogFileName ? (0, typescript_exports.stripQuotes)(cmdLineLogFileName) : envLogOptions.logToFile ? envLogOptions.file || libDirectory + "/.log" + process.pid.toString() : void 0;
|
|
322
316
|
const substitutedLogFileName = unsubstitutedLogFileName ? unsubstitutedLogFileName.replace("PID", process.pid.toString()) : void 0;
|
|
323
317
|
const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
|
|
324
318
|
return new Logger(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity);
|
|
@@ -338,32 +332,32 @@ function initializeNodeSystem() {
|
|
|
338
332
|
}
|
|
339
333
|
}
|
|
340
334
|
function extractWatchDirectoryCacheKey(path, currentDriveKey) {
|
|
341
|
-
path = (0,
|
|
335
|
+
path = (0, typescript_exports.normalizeSlashes)(path);
|
|
342
336
|
if (isUNCPath(path)) {
|
|
343
|
-
const firstSlash = path.indexOf(
|
|
344
|
-
return firstSlash !== -1 ? (0,
|
|
337
|
+
const firstSlash = path.indexOf(typescript_exports.directorySeparator, 2);
|
|
338
|
+
return firstSlash !== -1 ? (0, typescript_exports.toFileNameLowerCase)(path.substring(0, firstSlash)) : path;
|
|
345
339
|
}
|
|
346
|
-
const rootLength = (0,
|
|
340
|
+
const rootLength = (0, typescript_exports.getRootLength)(path);
|
|
347
341
|
if (rootLength === 0) {
|
|
348
342
|
return currentDriveKey;
|
|
349
343
|
}
|
|
350
|
-
if (path.charCodeAt(1) ===
|
|
351
|
-
return (0,
|
|
344
|
+
if (path.charCodeAt(1) === typescript_exports.CharacterCodes.colon && path.charCodeAt(2) === typescript_exports.CharacterCodes.slash) {
|
|
345
|
+
return (0, typescript_exports.toFileNameLowerCase)(path.charAt(0));
|
|
352
346
|
}
|
|
353
|
-
if (path.charCodeAt(0) ===
|
|
347
|
+
if (path.charCodeAt(0) === typescript_exports.CharacterCodes.slash && path.charCodeAt(1) !== typescript_exports.CharacterCodes.slash) {
|
|
354
348
|
return currentDriveKey;
|
|
355
349
|
}
|
|
356
350
|
return void 0;
|
|
357
351
|
}
|
|
358
352
|
function isUNCPath(s) {
|
|
359
|
-
return s.length > 2 && s.charCodeAt(0) ===
|
|
353
|
+
return s.length > 2 && s.charCodeAt(0) === typescript_exports.CharacterCodes.slash && s.charCodeAt(1) === typescript_exports.CharacterCodes.slash;
|
|
360
354
|
}
|
|
361
355
|
function watchDirectorySwallowingException(path, callback, recursive, options) {
|
|
362
356
|
try {
|
|
363
357
|
return originalWatchDirectory(path, callback, recursive, options);
|
|
364
358
|
} catch (e) {
|
|
365
359
|
logger.info(`Exception when creating directory watcher: ${e.message}`);
|
|
366
|
-
return
|
|
360
|
+
return typescript_exports.noopFileWatcher;
|
|
367
361
|
}
|
|
368
362
|
}
|
|
369
363
|
}
|
|
@@ -381,7 +375,7 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
381
375
|
output: process.stdout,
|
|
382
376
|
terminal: false
|
|
383
377
|
});
|
|
384
|
-
const _NodeTypingsInstallerAdapter = class _NodeTypingsInstallerAdapter extends
|
|
378
|
+
const _NodeTypingsInstallerAdapter = class _NodeTypingsInstallerAdapter extends typescript_exports.server.TypingsInstallerAdapter {
|
|
385
379
|
constructor(telemetryEnabled2, logger2, host, globalTypingsCacheLocation, typingSafeListLocation2, typesMapLocation2, npmLocation2, validateDefaultNpmLocation2, event) {
|
|
386
380
|
super(
|
|
387
381
|
telemetryEnabled2,
|
|
@@ -397,27 +391,27 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
397
391
|
this.validateDefaultNpmLocation = validateDefaultNpmLocation2;
|
|
398
392
|
}
|
|
399
393
|
createInstallerProcess() {
|
|
400
|
-
if (this.logger.hasLevel(
|
|
394
|
+
if (this.logger.hasLevel(typescript_exports.server.LogLevel.requestTime)) {
|
|
401
395
|
this.logger.info("Binding...");
|
|
402
396
|
}
|
|
403
|
-
const args = [
|
|
397
|
+
const args = [typescript_exports.server.Arguments.GlobalCacheLocation, this.globalTypingsCacheLocation];
|
|
404
398
|
if (this.telemetryEnabled) {
|
|
405
|
-
args.push(
|
|
399
|
+
args.push(typescript_exports.server.Arguments.EnableTelemetry);
|
|
406
400
|
}
|
|
407
401
|
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
|
|
408
|
-
args.push(
|
|
402
|
+
args.push(typescript_exports.server.Arguments.LogFile, (0, typescript_exports.combinePaths)((0, typescript_exports.getDirectoryPath)((0, typescript_exports.normalizeSlashes)(this.logger.getLogFileName())), `ti-${process.pid}.log`));
|
|
409
403
|
}
|
|
410
404
|
if (this.typingSafeListLocation) {
|
|
411
|
-
args.push(
|
|
405
|
+
args.push(typescript_exports.server.Arguments.TypingSafeListLocation, this.typingSafeListLocation);
|
|
412
406
|
}
|
|
413
407
|
if (this.typesMapLocation) {
|
|
414
|
-
args.push(
|
|
408
|
+
args.push(typescript_exports.server.Arguments.TypesMapLocation, this.typesMapLocation);
|
|
415
409
|
}
|
|
416
410
|
if (this.npmLocation) {
|
|
417
|
-
args.push(
|
|
411
|
+
args.push(typescript_exports.server.Arguments.NpmLocation, this.npmLocation);
|
|
418
412
|
}
|
|
419
413
|
if (this.validateDefaultNpmLocation) {
|
|
420
|
-
args.push(
|
|
414
|
+
args.push(typescript_exports.server.Arguments.ValidateDefaultNpmLocation);
|
|
421
415
|
}
|
|
422
416
|
const execArgv = [];
|
|
423
417
|
for (const arg of process.execArgv) {
|
|
@@ -428,7 +422,7 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
428
422
|
break;
|
|
429
423
|
}
|
|
430
424
|
}
|
|
431
|
-
const typingsInstaller = (0,
|
|
425
|
+
const typingsInstaller = (0, typescript_exports.combinePaths)((0, typescript_exports.getDirectoryPath)(typescript_exports.sys.getExecutingFilePath()), "typingsInstaller.js");
|
|
432
426
|
this.installer = childProcess.fork(typingsInstaller, args, { execArgv });
|
|
433
427
|
this.installer.on("message", (m) => this.handleMessage(m));
|
|
434
428
|
this.host.setImmediate(() => this.event({ pid: this.installer.pid }, "typingsInstallerPid"));
|
|
@@ -445,12 +439,12 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
445
439
|
// buffer, but we have yet to find a way to retrieve that value.
|
|
446
440
|
_NodeTypingsInstallerAdapter.maxActiveRequestCount = 10;
|
|
447
441
|
let NodeTypingsInstallerAdapter = _NodeTypingsInstallerAdapter;
|
|
448
|
-
class IOSession extends
|
|
442
|
+
class IOSession extends typescript_exports.server.Session {
|
|
449
443
|
constructor() {
|
|
450
444
|
const event = (body, eventName) => {
|
|
451
445
|
this.event(body, eventName);
|
|
452
446
|
};
|
|
453
|
-
const host =
|
|
447
|
+
const host = typescript_exports.sys;
|
|
454
448
|
const typingsInstaller = disableAutomaticTypingAcquisition ? void 0 : new NodeTypingsInstallerAdapter(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event);
|
|
455
449
|
super({
|
|
456
450
|
host,
|
|
@@ -478,16 +472,16 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
478
472
|
this.constructed = true;
|
|
479
473
|
}
|
|
480
474
|
event(body, eventName) {
|
|
481
|
-
|
|
475
|
+
typescript_exports.Debug.assert(!!this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession");
|
|
482
476
|
if (this.canUseEvents && this.eventPort) {
|
|
483
477
|
if (!this.eventSocket) {
|
|
484
|
-
if (this.logger.hasLevel(
|
|
478
|
+
if (this.logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
|
|
485
479
|
this.logger.info(`eventPort: event "${eventName}" queued, but socket not yet initialized`);
|
|
486
480
|
}
|
|
487
481
|
(this.socketEventQueue || (this.socketEventQueue = [])).push({ body, eventName });
|
|
488
482
|
return;
|
|
489
483
|
} else {
|
|
490
|
-
|
|
484
|
+
typescript_exports.Debug.assert(this.socketEventQueue === void 0);
|
|
491
485
|
this.writeToEventSocket(body, eventName);
|
|
492
486
|
}
|
|
493
487
|
} else {
|
|
@@ -495,13 +489,13 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
495
489
|
}
|
|
496
490
|
}
|
|
497
491
|
writeToEventSocket(body, eventName) {
|
|
498
|
-
this.eventSocket.write(
|
|
492
|
+
this.eventSocket.write(typescript_exports.server.formatMessage(typescript_exports.server.toEvent(eventName, body), this.logger, this.byteLength, this.host.newLine), "utf8");
|
|
499
493
|
}
|
|
500
494
|
exit() {
|
|
501
495
|
var _a;
|
|
502
496
|
this.logger.info("Exiting...");
|
|
503
497
|
this.projectService.closeLog();
|
|
504
|
-
(_a =
|
|
498
|
+
(_a = typescript_exports.tracing) == null ? void 0 : _a.stopTracing();
|
|
505
499
|
process.exit(0);
|
|
506
500
|
}
|
|
507
501
|
listen() {
|
|
@@ -516,10 +510,10 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
516
510
|
}
|
|
517
511
|
class IpcIOSession extends IOSession {
|
|
518
512
|
writeMessage(msg) {
|
|
519
|
-
const verboseLogging = logger.hasLevel(
|
|
513
|
+
const verboseLogging = logger.hasLevel(typescript_exports.server.LogLevel.verbose);
|
|
520
514
|
if (verboseLogging) {
|
|
521
515
|
const json = JSON.stringify(msg);
|
|
522
|
-
logger.info(`${msg.type}:${
|
|
516
|
+
logger.info(`${msg.type}:${typescript_exports.server.indent(json)}`);
|
|
523
517
|
}
|
|
524
518
|
process.send(msg);
|
|
525
519
|
}
|
|
@@ -538,18 +532,18 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
538
532
|
});
|
|
539
533
|
}
|
|
540
534
|
}
|
|
541
|
-
const eventPort = parseEventPort(
|
|
542
|
-
const typingSafeListLocation =
|
|
543
|
-
const typesMapLocation =
|
|
544
|
-
const npmLocation =
|
|
545
|
-
const validateDefaultNpmLocation =
|
|
546
|
-
const disableAutomaticTypingAcquisition =
|
|
547
|
-
const useNodeIpc =
|
|
548
|
-
const telemetryEnabled =
|
|
549
|
-
const commandLineTraceDir =
|
|
550
|
-
const traceDir = commandLineTraceDir ? (0,
|
|
535
|
+
const eventPort = parseEventPort(typescript_exports.server.findArgument("--eventPort"));
|
|
536
|
+
const typingSafeListLocation = typescript_exports.server.findArgument(typescript_exports.server.Arguments.TypingSafeListLocation);
|
|
537
|
+
const typesMapLocation = typescript_exports.server.findArgument(typescript_exports.server.Arguments.TypesMapLocation) || (0, typescript_exports.combinePaths)((0, typescript_exports.getDirectoryPath)(typescript_exports.sys.getExecutingFilePath()), "typesMap.json");
|
|
538
|
+
const npmLocation = typescript_exports.server.findArgument(typescript_exports.server.Arguments.NpmLocation);
|
|
539
|
+
const validateDefaultNpmLocation = typescript_exports.server.hasArgument(typescript_exports.server.Arguments.ValidateDefaultNpmLocation);
|
|
540
|
+
const disableAutomaticTypingAcquisition = typescript_exports.server.hasArgument("--disableAutomaticTypingAcquisition");
|
|
541
|
+
const useNodeIpc = typescript_exports.server.hasArgument("--useNodeIpc");
|
|
542
|
+
const telemetryEnabled = typescript_exports.server.hasArgument(typescript_exports.server.Arguments.EnableTelemetry);
|
|
543
|
+
const commandLineTraceDir = typescript_exports.server.findArgument("--traceDirectory");
|
|
544
|
+
const traceDir = commandLineTraceDir ? (0, typescript_exports.stripQuotes)(commandLineTraceDir) : process.env.TSS_TRACE;
|
|
551
545
|
if (traceDir) {
|
|
552
|
-
(0,
|
|
546
|
+
(0, typescript_exports.startTracing)("server", traceDir);
|
|
553
547
|
}
|
|
554
548
|
const ioSession = useNodeIpc ? new IpcIOSession() : new IOSession();
|
|
555
549
|
process.on("uncaughtException", (err) => {
|
|
@@ -560,8 +554,8 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
560
554
|
function getGlobalTypingsCacheLocation() {
|
|
561
555
|
switch (process.platform) {
|
|
562
556
|
case "win32": {
|
|
563
|
-
const basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir && os.homedir() || process.env.USERPROFILE || process.env.HOMEDRIVE && process.env.HOMEPATH && (0,
|
|
564
|
-
return (0,
|
|
557
|
+
const basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir && os.homedir() || process.env.USERPROFILE || process.env.HOMEDRIVE && process.env.HOMEPATH && (0, typescript_exports.normalizeSlashes)(process.env.HOMEDRIVE + process.env.HOMEPATH) || os.tmpdir();
|
|
558
|
+
return (0, typescript_exports.combinePaths)((0, typescript_exports.combinePaths)((0, typescript_exports.normalizeSlashes)(basePath), "Microsoft/TypeScript"), typescript_exports.versionMajorMinor);
|
|
565
559
|
}
|
|
566
560
|
case "openbsd":
|
|
567
561
|
case "freebsd":
|
|
@@ -570,10 +564,10 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
570
564
|
case "linux":
|
|
571
565
|
case "android": {
|
|
572
566
|
const cacheLocation = getNonWindowsCacheLocation(process.platform === "darwin");
|
|
573
|
-
return (0,
|
|
567
|
+
return (0, typescript_exports.combinePaths)((0, typescript_exports.combinePaths)(cacheLocation, "typescript"), typescript_exports.versionMajorMinor);
|
|
574
568
|
}
|
|
575
569
|
default:
|
|
576
|
-
return
|
|
570
|
+
return typescript_exports.Debug.fail(`unsupported platform '${process.platform}'`);
|
|
577
571
|
}
|
|
578
572
|
}
|
|
579
573
|
function getNonWindowsCacheLocation(platformIsDarwin) {
|
|
@@ -583,50 +577,50 @@ function startNodeSession(options, logger, cancellationToken) {
|
|
|
583
577
|
const usersDir = platformIsDarwin ? "Users" : "home";
|
|
584
578
|
const homePath = os.homedir && os.homedir() || process.env.HOME || (process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}` || os.tmpdir();
|
|
585
579
|
const cacheFolder = platformIsDarwin ? "Library/Caches" : ".cache";
|
|
586
|
-
return (0,
|
|
580
|
+
return (0, typescript_exports.combinePaths)((0, typescript_exports.normalizeSlashes)(homePath), cacheFolder);
|
|
587
581
|
}
|
|
588
582
|
}
|
|
589
583
|
|
|
590
584
|
// src/tsserver/server.ts
|
|
591
585
|
function findArgumentStringArray(argName) {
|
|
592
|
-
const arg =
|
|
586
|
+
const arg = typescript_exports.server.findArgument(argName);
|
|
593
587
|
if (arg === void 0) {
|
|
594
|
-
return
|
|
588
|
+
return typescript_exports.emptyArray;
|
|
595
589
|
}
|
|
596
590
|
return arg.split(",").filter((name) => name !== "");
|
|
597
591
|
}
|
|
598
592
|
function start({ args, logger, cancellationToken, serverMode, unknownServerMode, startSession: startServer }, platform) {
|
|
599
593
|
logger.info(`Starting TS Server`);
|
|
600
|
-
logger.info(`Version: ${
|
|
594
|
+
logger.info(`Version: ${typescript_exports.version}`);
|
|
601
595
|
logger.info(`Arguments: ${args.join(" ")}`);
|
|
602
|
-
logger.info(`Platform: ${platform} NodeVersion: ${process.version} CaseSensitive: ${
|
|
596
|
+
logger.info(`Platform: ${platform} NodeVersion: ${process.version} CaseSensitive: ${typescript_exports.sys.useCaseSensitiveFileNames}`);
|
|
603
597
|
logger.info(`ServerMode: ${serverMode} hasUnknownServerMode: ${unknownServerMode}`);
|
|
604
|
-
|
|
605
|
-
if (
|
|
606
|
-
|
|
598
|
+
typescript_exports.setStackTraceLimit();
|
|
599
|
+
if (typescript_exports.Debug.isDebugging) {
|
|
600
|
+
typescript_exports.Debug.enableDebugInfo();
|
|
607
601
|
}
|
|
608
|
-
if (
|
|
609
|
-
|
|
602
|
+
if (typescript_exports.sys.tryEnableSourceMapsForHost && /^development$/i.test(typescript_exports.sys.getEnvironmentVariable("NODE_ENV"))) {
|
|
603
|
+
typescript_exports.sys.tryEnableSourceMapsForHost();
|
|
610
604
|
}
|
|
611
|
-
console.log = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "),
|
|
612
|
-
console.warn = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "),
|
|
613
|
-
console.error = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "),
|
|
605
|
+
console.log = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "), typescript_exports.server.Msg.Info);
|
|
606
|
+
console.warn = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "), typescript_exports.server.Msg.Err);
|
|
607
|
+
console.error = (...args2) => logger.msg(args2.length === 1 ? args2[0] : args2.join(", "), typescript_exports.server.Msg.Err);
|
|
614
608
|
startServer(
|
|
615
609
|
{
|
|
616
610
|
globalPlugins: findArgumentStringArray("--globalPlugins"),
|
|
617
611
|
pluginProbeLocations: findArgumentStringArray("--pluginProbeLocations"),
|
|
618
|
-
allowLocalPluginLoads:
|
|
619
|
-
useSingleInferredProject:
|
|
620
|
-
useInferredProjectPerProjectRoot:
|
|
621
|
-
suppressDiagnosticEvents:
|
|
622
|
-
noGetErrOnBackgroundUpdate:
|
|
623
|
-
canUseWatchEvents:
|
|
612
|
+
allowLocalPluginLoads: typescript_exports.server.hasArgument("--allowLocalPluginLoads"),
|
|
613
|
+
useSingleInferredProject: typescript_exports.server.hasArgument("--useSingleInferredProject"),
|
|
614
|
+
useInferredProjectPerProjectRoot: typescript_exports.server.hasArgument("--useInferredProjectPerProjectRoot"),
|
|
615
|
+
suppressDiagnosticEvents: typescript_exports.server.hasArgument("--suppressDiagnosticEvents"),
|
|
616
|
+
noGetErrOnBackgroundUpdate: typescript_exports.server.hasArgument("--noGetErrOnBackgroundUpdate"),
|
|
617
|
+
canUseWatchEvents: typescript_exports.server.hasArgument("--canUseWatchEvents"),
|
|
624
618
|
serverMode
|
|
625
619
|
},
|
|
626
620
|
logger,
|
|
627
621
|
cancellationToken
|
|
628
622
|
);
|
|
629
623
|
}
|
|
630
|
-
|
|
624
|
+
typescript_exports.setStackTraceLimit();
|
|
631
625
|
start(initializeNodeSystem(), require("os").platform());
|
|
632
626
|
//# sourceMappingURL=tsserver.js.map
|
package/lib/typescript.d.ts
CHANGED