typescript 5.6.0-dev.20240625 → 5.6.0-dev.20240627

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/tsserver.js CHANGED
@@ -15,9 +15,11 @@ and limitations under the License.
15
15
 
16
16
 
17
17
  "use strict";
18
+ var __create = Object.create;
18
19
  var __defProp = Object.defineProperty;
19
20
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
21
  var __getOwnPropNames = Object.getOwnPropertyNames;
22
+ var __getProtoOf = Object.getPrototypeOf;
21
23
  var __hasOwnProp = Object.prototype.hasOwnProperty;
22
24
  var __copyProps = (to, from, except, desc) => {
23
25
  if (from && typeof from === "object" || typeof from === "function") {
@@ -28,11 +30,29 @@ var __copyProps = (to, from, except, desc) => {
28
30
  return to;
29
31
  };
30
32
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+
42
+ // src/tsserver/server.ts
43
+ var import_os2 = __toESM(require("os"));
31
44
 
32
45
  // src/typescript/typescript.ts
33
46
  var typescript_exports = {};
34
47
  __reExport(typescript_exports, require("./typescript.js"));
35
48
 
49
+ // src/tsserver/nodeServer.ts
50
+ var import_child_process = __toESM(require("child_process"));
51
+ var import_fs = __toESM(require("fs"));
52
+ var import_net = __toESM(require("net"));
53
+ var import_os = __toESM(require("os"));
54
+ var import_readline = __toESM(require("readline"));
55
+
36
56
  // src/tsserver/common.ts
37
57
  function getLogLevel(level) {
38
58
  if (level) {
@@ -107,8 +127,6 @@ function parseServerMode() {
107
127
  }
108
128
  function initializeNodeSystem() {
109
129
  const sys4 = typescript_exports.Debug.checkDefined(typescript_exports.sys);
110
- const childProcess = require("child_process");
111
- const fs = require("fs");
112
130
  class Logger {
113
131
  constructor(logFilename, traceToConsole, level) {
114
132
  this.logFilename = logFilename;
@@ -120,7 +138,7 @@ function initializeNodeSystem() {
120
138
  this.fd = -1;
121
139
  if (this.logFilename) {
122
140
  try {
123
- this.fd = fs.openSync(this.logFilename, "w");
141
+ this.fd = import_fs.default.openSync(this.logFilename, "w");
124
142
  } catch (_) {
125
143
  }
126
144
  }
@@ -130,7 +148,7 @@ function initializeNodeSystem() {
130
148
  }
131
149
  close() {
132
150
  if (this.fd >= 0) {
133
- fs.close(this.fd, typescript_exports.noop);
151
+ import_fs.default.close(this.fd, typescript_exports.noop);
134
152
  }
135
153
  }
136
154
  getLogFileName() {
@@ -177,7 +195,7 @@ function initializeNodeSystem() {
177
195
  write(s, _type) {
178
196
  if (this.fd >= 0) {
179
197
  const buf = Buffer.from(s);
180
- fs.writeSync(
198
+ import_fs.default.writeSync(
181
199
  this.fd,
182
200
  buf,
183
201
  0,
@@ -228,7 +246,7 @@ function initializeNodeSystem() {
228
246
  if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
229
247
  logger.info(`Starting ${process.execPath} with args:${typescript_exports.server.stringifyIndented(args)}`);
230
248
  }
231
- childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { ELECTRON_RUN_AS_NODE: "1" } });
249
+ import_child_process.default.execFileSync(process.execPath, args, { stdio: "ignore", env: { ELECTRON_RUN_AS_NODE: "1" } });
232
250
  status = true;
233
251
  if (logger.hasLevel(typescript_exports.server.LogLevel.verbose)) {
234
252
  logger.info(`WatchGuard for path ${path} returned: OK`);
@@ -267,7 +285,7 @@ function initializeNodeSystem() {
267
285
  }
268
286
  let cancellationToken;
269
287
  try {
270
- const factory = require("./cancellationToken");
288
+ const factory = require("./cancellationToken.js");
271
289
  cancellationToken = factory(sys4.args);
272
290
  } catch (e) {
273
291
  cancellationToken = typescript_exports.server.nullCancellationToken;
@@ -349,11 +367,7 @@ function parseEventPort(eventPortStr) {
349
367
  return eventPort !== void 0 && !isNaN(eventPort) ? eventPort : void 0;
350
368
  }
351
369
  function startNodeSession(options, logger, cancellationToken) {
352
- const childProcess = require("child_process");
353
- const os = require("os");
354
- const net = require("net");
355
- const readline = require("readline");
356
- const rl = readline.createInterface({
370
+ const rl = import_readline.default.createInterface({
357
371
  input: process.stdin,
358
372
  output: process.stdout,
359
373
  terminal: false
@@ -406,7 +420,7 @@ function startNodeSession(options, logger, cancellationToken) {
406
420
  }
407
421
  }
408
422
  const typingsInstaller = (0, typescript_exports.combinePaths)((0, typescript_exports.getDirectoryPath)(typescript_exports.sys.getExecutingFilePath()), "typingsInstaller.js");
409
- this.installer = childProcess.fork(typingsInstaller, args, { execArgv });
423
+ this.installer = import_child_process.default.fork(typingsInstaller, args, { execArgv });
410
424
  this.installer.on("message", (m) => this.handleMessage(m));
411
425
  this.host.setImmediate(() => this.event({ pid: this.installer.pid }, "typingsInstallerPid"));
412
426
  process.on("exit", () => {
@@ -442,7 +456,7 @@ function startNodeSession(options, logger, cancellationToken) {
442
456
  });
443
457
  this.eventPort = eventPort;
444
458
  if (this.canUseEvents && this.eventPort) {
445
- const s = net.connect({ port: this.eventPort }, () => {
459
+ const s = import_net.default.connect({ port: this.eventPort }, () => {
446
460
  this.eventSocket = s;
447
461
  if (this.socketEventQueue) {
448
462
  for (const event2 of this.socketEventQueue) {
@@ -537,7 +551,7 @@ function startNodeSession(options, logger, cancellationToken) {
537
551
  function getGlobalTypingsCacheLocation() {
538
552
  switch (process.platform) {
539
553
  case "win32": {
540
- 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();
554
+ const basePath = process.env.LOCALAPPDATA || process.env.APPDATA || import_os.default.homedir && import_os.default.homedir() || process.env.USERPROFILE || process.env.HOMEDRIVE && process.env.HOMEPATH && (0, typescript_exports.normalizeSlashes)(process.env.HOMEDRIVE + process.env.HOMEPATH) || import_os.default.tmpdir();
541
555
  return (0, typescript_exports.combinePaths)((0, typescript_exports.combinePaths)((0, typescript_exports.normalizeSlashes)(basePath), "Microsoft/TypeScript"), typescript_exports.versionMajorMinor);
542
556
  }
543
557
  case "openbsd":
@@ -558,7 +572,7 @@ function startNodeSession(options, logger, cancellationToken) {
558
572
  return process.env.XDG_CACHE_HOME;
559
573
  }
560
574
  const usersDir = platformIsDarwin ? "Users" : "home";
561
- const homePath = os.homedir && os.homedir() || process.env.HOME || (process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}` || os.tmpdir();
575
+ const homePath = import_os.default.homedir && import_os.default.homedir() || process.env.HOME || (process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}` || import_os.default.tmpdir();
562
576
  const cacheFolder = platformIsDarwin ? "Library/Caches" : ".cache";
563
577
  return (0, typescript_exports.combinePaths)((0, typescript_exports.normalizeSlashes)(homePath), cacheFolder);
564
578
  }
@@ -605,5 +619,5 @@ function start({ args, logger, cancellationToken, serverMode, unknownServerMode,
605
619
  );
606
620
  }
607
621
  typescript_exports.setStackTraceLimit();
608
- start(initializeNodeSystem(), require("os").platform());
622
+ start(initializeNodeSystem(), import_os2.default.platform());
609
623
  //# sourceMappingURL=tsserver.js.map
@@ -2659,6 +2659,18 @@ declare namespace ts {
2659
2659
  trace?(s: string): void;
2660
2660
  require?(initialPath: string, moduleName: string): ModuleImportResult;
2661
2661
  }
2662
+ interface InstallPackageOptionsWithProject extends InstallPackageOptions {
2663
+ projectName: string;
2664
+ projectRootPath: Path;
2665
+ }
2666
+ interface ITypingsInstaller {
2667
+ isKnownTypesPackageName(name: string): boolean;
2668
+ installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
2669
+ enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
2670
+ attach(projectService: ProjectService): void;
2671
+ onProjectClosed(p: Project): void;
2672
+ readonly globalTypingsCacheLocation: string | undefined;
2673
+ }
2662
2674
  function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
2663
2675
  function toNormalizedPath(fileName: string): NormalizedPath;
2664
2676
  function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path;
@@ -2751,19 +2763,6 @@ declare namespace ts {
2751
2763
  positionToLineOffset(position: number): protocol.Location;
2752
2764
  isJavaScript(): boolean;
2753
2765
  }
2754
- interface InstallPackageOptionsWithProject extends InstallPackageOptions {
2755
- projectName: string;
2756
- projectRootPath: Path;
2757
- }
2758
- interface ITypingsInstaller {
2759
- isKnownTypesPackageName(name: string): boolean;
2760
- installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
2761
- enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
2762
- attach(projectService: ProjectService): void;
2763
- onProjectClosed(p: Project): void;
2764
- readonly globalTypingsCacheLocation: string | undefined;
2765
- }
2766
- const nullTypingsInstaller: ITypingsInstaller;
2767
2766
  function allRootFilesAreJsOrDts(project: Project): boolean;
2768
2767
  function allFilesAreJsOrDts(project: Project): boolean;
2769
2768
  enum ProjectKind {
@@ -2817,6 +2816,7 @@ declare namespace ts {
2817
2816
  private lastReportedVersion;
2818
2817
  protected projectErrors: Diagnostic[] | undefined;
2819
2818
  protected isInitialLoadPending: () => boolean;
2819
+ private typingsCache;
2820
2820
  private typingWatchers;
2821
2821
  private readonly cancellationToken;
2822
2822
  isNonTsProject(): boolean;
@@ -2829,7 +2829,6 @@ declare namespace ts {
2829
2829
  readonly jsDocParsingMode: JSDocParsingMode | undefined;
2830
2830
  isKnownTypesPackageName(name: string): boolean;
2831
2831
  installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
2832
- private get typingsCache();
2833
2832
  getCompilationSettings(): ts.CompilerOptions;
2834
2833
  getCompilerOptions(): ts.CompilerOptions;
2835
2834
  getNewLine(): string;
@@ -3148,6 +3147,7 @@ declare namespace ts {
3148
3147
  configFileName?: NormalizedPath;
3149
3148
  configFileErrors?: readonly Diagnostic[];
3150
3149
  }
3150
+ const nullTypingsInstaller: ITypingsInstaller;
3151
3151
  interface ProjectServiceOptions {
3152
3152
  host: ServerHost;
3153
3153
  logger: Logger;