@typescript-deploys/pr-build 5.1.0-pr-52984-22 → 5.1.0-pr-52984-26

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/tsc.js CHANGED
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.1";
26
- var version = `${versionMajorMinor}.0-insiders.20230301`;
26
+ var version = `${versionMajorMinor}.0-insiders.20230302`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
package/lib/tsserver.js CHANGED
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(server_exports);
2286
2286
 
2287
2287
  // src/compiler/corePublic.ts
2288
2288
  var versionMajorMinor = "5.1";
2289
- var version = `${versionMajorMinor}.0-insiders.20230301`;
2289
+ var version = `${versionMajorMinor}.0-insiders.20230302`;
2290
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2291
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2292
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -170850,17 +170850,14 @@ var TextStorage = class {
170850
170850
  * True when reloading contents of file from the disk is pending
170851
170851
  */
170852
170852
  this.pendingReloadFromDisk = false;
170853
- this.version = initialVersion || { svc: 0, text: 0 };
170853
+ this.version = initialVersion || 0;
170854
170854
  }
170855
170855
  getVersion() {
170856
- return this.svc ? `SVC-${this.version.svc}-${this.svc.getSnapshotVersion()}` : `Text-${this.version.text}`;
170856
+ return this.svc ? `SVC-${this.version}-${this.svc.getSnapshotVersion()}` : `Text-${this.version}`;
170857
170857
  }
170858
170858
  hasScriptVersionCache_TestOnly() {
170859
170859
  return this.svc !== void 0;
170860
170860
  }
170861
- useScriptVersionCache_TestOnly() {
170862
- this.switchToScriptVersionCache();
170863
- }
170864
170861
  resetSourceMapInfo() {
170865
170862
  this.info.sourceFileLike = void 0;
170866
170863
  this.info.closeSourceMapFileWatcher();
@@ -170873,15 +170870,17 @@ var TextStorage = class {
170873
170870
  useText(newText) {
170874
170871
  this.svc = void 0;
170875
170872
  this.text = newText;
170873
+ this.textSnapshot = void 0;
170876
170874
  this.lineMap = void 0;
170877
170875
  this.fileSize = void 0;
170878
170876
  this.resetSourceMapInfo();
170879
- this.version.text++;
170877
+ this.version++;
170880
170878
  }
170881
170879
  edit(start2, end, newText) {
170882
170880
  this.switchToScriptVersionCache().edit(start2, end - start2, newText);
170883
170881
  this.ownFileText = false;
170884
170882
  this.text = void 0;
170883
+ this.textSnapshot = void 0;
170885
170884
  this.lineMap = void 0;
170886
170885
  this.fileSize = void 0;
170887
170886
  this.resetSourceMapInfo();
@@ -170893,6 +170892,9 @@ var TextStorage = class {
170893
170892
  reload(newText) {
170894
170893
  Debug.assert(newText !== void 0);
170895
170894
  this.pendingReloadFromDisk = false;
170895
+ if (!this.text && this.svc) {
170896
+ this.text = getSnapshotText(this.svc.getSnapshot());
170897
+ }
170896
170898
  if (this.text !== newText) {
170897
170899
  this.useText(newText);
170898
170900
  this.ownFileText = false;
@@ -170905,21 +170907,18 @@ var TextStorage = class {
170905
170907
  * returns true if text changed
170906
170908
  */
170907
170909
  reloadWithFileText(tempFileName) {
170908
- const { text: newText, fileSize } = this.getFileTextAndSize(tempFileName);
170910
+ const { text: newText, fileSize } = tempFileName || !this.info.isDynamicOrHasMixedContent() ? this.getFileTextAndSize(tempFileName) : { text: "", fileSize: void 0 };
170909
170911
  const reloaded = this.reload(newText);
170910
170912
  this.fileSize = fileSize;
170911
170913
  this.ownFileText = !tempFileName || tempFileName === this.info.fileName;
170912
170914
  return reloaded;
170913
170915
  }
170914
170916
  /**
170915
- * Reloads the contents from the file if there is no pending reload from disk or the contents of file are same as file text
170916
- * returns true if text changed
170917
+ * Schedule reload from the disk if its not already scheduled and its not own text
170918
+ * returns true when scheduling reload
170917
170919
  */
170918
- reloadFromDisk() {
170919
- if (!this.pendingReloadFromDisk && !this.ownFileText) {
170920
- return this.reloadWithFileText();
170921
- }
170922
- return false;
170920
+ scheduleReloadIfNeeded() {
170921
+ return !this.pendingReloadFromDisk && !this.ownFileText ? this.pendingReloadFromDisk = true : false;
170923
170922
  }
170924
170923
  delayReloadFromFileIntoText() {
170925
170924
  this.pendingReloadFromDisk = true;
@@ -170935,39 +170934,48 @@ var TextStorage = class {
170935
170934
  return !!this.fileSize ? this.fileSize : !!this.text ? this.text.length : !!this.svc ? this.svc.getSnapshot().getLength() : this.getSnapshot().getLength();
170936
170935
  }
170937
170936
  getSnapshot() {
170938
- return this.useScriptVersionCacheIfValidOrOpen() ? this.svc.getSnapshot() : ScriptSnapshot.fromString(this.getOrLoadText());
170937
+ var _a2, _b;
170938
+ return ((_a2 = this.tryUseScriptVersionCache()) == null ? void 0 : _a2.getSnapshot()) || ((_b = this.textSnapshot) != null ? _b : this.textSnapshot = ScriptSnapshot.fromString(Debug.checkDefined(this.text)));
170939
170939
  }
170940
- getAbsolutePositionAndLineText(line) {
170941
- return this.switchToScriptVersionCache().getAbsolutePositionAndLineText(line);
170940
+ getAbsolutePositionAndLineText(oneBasedLine) {
170941
+ const svc = this.tryUseScriptVersionCache();
170942
+ if (svc)
170943
+ return svc.getAbsolutePositionAndLineText(oneBasedLine);
170944
+ const lineMap = this.getLineMap();
170945
+ return oneBasedLine <= lineMap.length ? {
170946
+ absolutePosition: lineMap[oneBasedLine - 1],
170947
+ lineText: this.text.substring(lineMap[oneBasedLine - 1], lineMap[oneBasedLine])
170948
+ } : {
170949
+ absolutePosition: this.text.length,
170950
+ lineText: void 0
170951
+ };
170942
170952
  }
170943
170953
  /**
170944
170954
  * @param line 0 based index
170945
170955
  */
170946
170956
  lineToTextSpan(line) {
170947
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
170948
- const lineMap = this.getLineMap();
170949
- const start2 = lineMap[line];
170950
- const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
170951
- return createTextSpanFromBounds(start2, end);
170952
- }
170953
- return this.svc.lineToTextSpan(line);
170957
+ const svc = this.tryUseScriptVersionCache();
170958
+ if (svc)
170959
+ return svc.lineToTextSpan(line);
170960
+ const lineMap = this.getLineMap();
170961
+ const start2 = lineMap[line];
170962
+ const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
170963
+ return createTextSpanFromBounds(start2, end);
170954
170964
  }
170955
170965
  /**
170956
170966
  * @param line 1 based index
170957
170967
  * @param offset 1 based index
170958
170968
  */
170959
170969
  lineOffsetToPosition(line, offset, allowEdits) {
170960
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
170961
- return computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
170962
- }
170963
- return this.svc.lineOffsetToPosition(line, offset);
170970
+ const svc = this.tryUseScriptVersionCache();
170971
+ return svc ? svc.lineOffsetToPosition(line, offset) : computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
170964
170972
  }
170965
170973
  positionToLineOffset(position) {
170966
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
170967
- const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
170968
- return { line: line + 1, offset: character + 1 };
170969
- }
170970
- return this.svc.positionToLineOffset(position);
170974
+ const svc = this.tryUseScriptVersionCache();
170975
+ if (svc)
170976
+ return svc.positionToLineOffset(position);
170977
+ const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
170978
+ return { line: line + 1, offset: character + 1 };
170971
170979
  }
170972
170980
  getFileTextAndSize(tempFileName) {
170973
170981
  let text;
@@ -170985,19 +170993,25 @@ var TextStorage = class {
170985
170993
  }
170986
170994
  return { text: getText() };
170987
170995
  }
170996
+ /** @internal */
170988
170997
  switchToScriptVersionCache() {
170989
170998
  if (!this.svc || this.pendingReloadFromDisk) {
170990
170999
  this.svc = ScriptVersionCache.fromString(this.getOrLoadText());
170991
- this.version.svc++;
171000
+ this.textSnapshot = void 0;
171001
+ this.version++;
170992
171002
  }
170993
171003
  return this.svc;
170994
171004
  }
170995
- useScriptVersionCacheIfValidOrOpen() {
170996
- if (this.isOpen) {
170997
- return this.switchToScriptVersionCache();
171005
+ tryUseScriptVersionCache() {
171006
+ if (!this.svc || this.pendingReloadFromDisk) {
171007
+ this.getOrLoadText();
170998
171008
  }
170999
- if (this.pendingReloadFromDisk) {
171000
- this.reloadWithFileText();
171009
+ if (this.isOpen) {
171010
+ if (!this.svc && !this.textSnapshot) {
171011
+ this.svc = ScriptVersionCache.fromString(Debug.checkDefined(this.text));
171012
+ this.textSnapshot = void 0;
171013
+ }
171014
+ return this.svc;
171001
171015
  }
171002
171016
  return this.svc;
171003
171017
  }
@@ -171010,13 +171024,14 @@ var TextStorage = class {
171010
171024
  }
171011
171025
  getLineMap() {
171012
171026
  Debug.assert(!this.svc, "ScriptVersionCache should not be set");
171013
- return this.lineMap || (this.lineMap = computeLineStarts(this.getOrLoadText()));
171027
+ return this.lineMap || (this.lineMap = computeLineStarts(Debug.checkDefined(this.text)));
171014
171028
  }
171015
171029
  getLineInfo() {
171016
- if (this.svc) {
171030
+ const svc = this.tryUseScriptVersionCache();
171031
+ if (svc) {
171017
171032
  return {
171018
- getLineCount: () => this.svc.getLineCount(),
171019
- getLineText: (line) => this.svc.getAbsolutePositionAndLineText(line + 1).lineText
171033
+ getLineCount: () => svc.getLineCount(),
171034
+ getLineText: (line) => svc.getAbsolutePositionAndLineText(line + 1).lineText
171020
171035
  };
171021
171036
  }
171022
171037
  const lineMap = this.getLineMap();
@@ -171040,20 +171055,11 @@ var ScriptInfo = class {
171040
171055
  this.isDynamic = isDynamicFileName(fileName);
171041
171056
  this.textStorage = new TextStorage(host, this, initialVersion);
171042
171057
  if (hasMixedContent || this.isDynamic) {
171043
- this.textStorage.reload("");
171044
171058
  this.realpath = this.path;
171045
171059
  }
171046
171060
  this.scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
171047
171061
  }
171048
171062
  /** @internal */
171049
- getVersion() {
171050
- return this.textStorage.version;
171051
- }
171052
- /** @internal */
171053
- getTelemetryFileSize() {
171054
- return this.textStorage.getTelemetryFileSize();
171055
- }
171056
- /** @internal */
171057
171063
  isDynamicOrHasMixedContent() {
171058
171064
  return this.hasMixedContent || this.isDynamic;
171059
171065
  }
@@ -171068,11 +171074,7 @@ var ScriptInfo = class {
171068
171074
  }
171069
171075
  close(fileExists = true) {
171070
171076
  this.textStorage.isOpen = false;
171071
- if (this.isDynamicOrHasMixedContent() || !fileExists) {
171072
- if (this.textStorage.reload("")) {
171073
- this.markContainingProjectsAsDirty();
171074
- }
171075
- } else if (this.textStorage.reloadFromDisk()) {
171077
+ if (fileExists && this.textStorage.scheduleReloadIfNeeded()) {
171076
171078
  this.markContainingProjectsAsDirty();
171077
171079
  }
171078
171080
  }
@@ -171252,22 +171254,12 @@ var ScriptInfo = class {
171252
171254
  this.markContainingProjectsAsDirty();
171253
171255
  }
171254
171256
  reloadFromFile(tempFileName) {
171255
- if (this.isDynamicOrHasMixedContent()) {
171256
- this.textStorage.reload("");
171257
+ if (this.textStorage.reloadWithFileText(tempFileName)) {
171257
171258
  this.markContainingProjectsAsDirty();
171258
171259
  return true;
171259
- } else {
171260
- if (this.textStorage.reloadWithFileText(tempFileName)) {
171261
- this.markContainingProjectsAsDirty();
171262
- return true;
171263
- }
171264
171260
  }
171265
171261
  return false;
171266
171262
  }
171267
- /** @internal */
171268
- getAbsolutePositionAndLineText(line) {
171269
- return this.textStorage.getAbsolutePositionAndLineText(line);
171270
- }
171271
171263
  editContent(start2, end, newText) {
171272
171264
  this.textStorage.edit(start2, end, newText);
171273
171265
  this.markContainingProjectsAsDirty();
@@ -171307,10 +171299,6 @@ var ScriptInfo = class {
171307
171299
  return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */;
171308
171300
  }
171309
171301
  /** @internal */
171310
- getLineInfo() {
171311
- return this.textStorage.getLineInfo();
171312
- }
171313
- /** @internal */
171314
171302
  closeSourceMapFileWatcher() {
171315
171303
  if (this.sourceMapFilePath && !isString(this.sourceMapFilePath)) {
171316
171304
  closeFileWatcherOf(this.sourceMapFilePath);
@@ -171455,7 +171443,7 @@ function countEachFileTypes(infos, includeSizes = false) {
171455
171443
  deferredSize: 0
171456
171444
  };
171457
171445
  for (const info of infos) {
171458
- const fileSize = includeSizes ? info.getTelemetryFileSize() : 0;
171446
+ const fileSize = includeSizes ? info.textStorage.getTelemetryFileSize() : 0;
171459
171447
  switch (info.scriptKind) {
171460
171448
  case 1 /* JS */:
171461
171449
  result.js += 1;
@@ -172439,10 +172427,26 @@ var Project3 = class {
172439
172427
  const elapsed = timestamp() - start2;
172440
172428
  this.sendPerformanceEvent("UpdateGraph", elapsed);
172441
172429
  this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram}${this.program ? ` structureIsReused:: ${StructureIsReused[this.program.structureIsReused]}` : ""} Elapsed: ${elapsed}ms`);
172442
- if (this.hasAddedorRemovedFiles) {
172430
+ if (this.projectService.logger.isTestLogger) {
172431
+ if (this.program !== oldProgram) {
172432
+ this.print(
172433
+ /*writeProjectFileNames*/
172434
+ true,
172435
+ this.hasAddedorRemovedFiles,
172436
+ /*writeFileVersionAndText*/
172437
+ true
172438
+ );
172439
+ } else {
172440
+ this.writeLog(`Same program as before`);
172441
+ }
172442
+ } else if (this.hasAddedorRemovedFiles) {
172443
172443
  this.print(
172444
172444
  /*writeProjectFileNames*/
172445
- true
172445
+ true,
172446
+ /*writeFileExplaination*/
172447
+ true,
172448
+ /*writeFileVersionAndText*/
172449
+ false
172446
172450
  );
172447
172451
  } else if (this.program !== oldProgram) {
172448
172452
  this.writeLog(`Different program with same set of files`);
@@ -172552,6 +172556,16 @@ var Project3 = class {
172552
172556
  return this.projectService.getScriptInfo(uncheckedFileName);
172553
172557
  }
172554
172558
  filesToString(writeProjectFileNames) {
172559
+ return this.filesToStringWorker(
172560
+ writeProjectFileNames,
172561
+ /*writeFileExplaination*/
172562
+ true,
172563
+ /*writeFileVersionAndText*/
172564
+ false
172565
+ );
172566
+ }
172567
+ /** @internal */
172568
+ filesToStringWorker(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
172555
172569
  if (this.isInitialLoadPending())
172556
172570
  return " Files (0) InitialLoadPending\n";
172557
172571
  if (!this.program)
@@ -172561,23 +172575,33 @@ var Project3 = class {
172561
172575
  `;
172562
172576
  if (writeProjectFileNames) {
172563
172577
  for (const file of sourceFiles) {
172564
- strBuilder += ` ${file.fileName}
172578
+ strBuilder += ` ${file.fileName}${writeFileVersionAndText ? ` ${file.version} ${JSON.stringify(file.text)}` : ""}
172565
172579
  `;
172566
172580
  }
172567
- strBuilder += "\n\n";
172568
- explainFiles(this.program, (s) => strBuilder += ` ${s}
172581
+ if (writeFileExplaination) {
172582
+ strBuilder += "\n\n";
172583
+ explainFiles(this.program, (s) => strBuilder += ` ${s}
172569
172584
  `);
172585
+ }
172570
172586
  }
172571
172587
  return strBuilder;
172572
172588
  }
172573
172589
  /** @internal */
172574
- print(writeProjectFileNames) {
172590
+ print(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
172575
172591
  this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
172576
- this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */)));
172592
+ this.writeLog(this.filesToStringWorker(
172593
+ writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */),
172594
+ writeFileExplaination && this.projectService.logger.hasLevel(3 /* verbose */),
172595
+ writeFileVersionAndText && this.projectService.logger.hasLevel(3 /* verbose */)
172596
+ ));
172577
172597
  this.writeLog("-----------------------------------------------");
172578
172598
  if (this.autoImportProviderHost) {
172579
172599
  this.autoImportProviderHost.print(
172580
172600
  /*writeProjectFileNames*/
172601
+ false,
172602
+ /*writeFileExplaination*/
172603
+ false,
172604
+ /*writeFileVersionAndText*/
172581
172605
  false
172582
172606
  );
172583
172607
  }
@@ -174532,7 +174556,11 @@ var _ProjectService = class {
174532
174556
  this.logger.info("`remove Project::");
174533
174557
  project.print(
174534
174558
  /*writeProjectFileNames*/
174535
- true
174559
+ true,
174560
+ /*writeFileExplaination*/
174561
+ true,
174562
+ /*writeFileVersionAndText*/
174563
+ false
174536
174564
  );
174537
174565
  project.close();
174538
174566
  if (Debug.shouldAssert(1 /* Normal */)) {
@@ -174671,7 +174699,7 @@ var _ProjectService = class {
174671
174699
  }
174672
174700
  deleteScriptInfo(info) {
174673
174701
  this.filenameToScriptInfo.delete(info.path);
174674
- this.filenameToScriptInfoVersion.set(info.path, info.getVersion());
174702
+ this.filenameToScriptInfoVersion.set(info.path, info.textStorage.version);
174675
174703
  const realpath = info.getRealpathIfDifferent();
174676
174704
  if (realpath) {
174677
174705
  this.realpathToScriptInfos.remove(realpath, info);
@@ -175755,7 +175783,7 @@ Dynamic files must always be opened with service's current directory or service
175755
175783
  const documentPositionMapper = getDocumentPositionMapper(
175756
175784
  { getCanonicalFileName: this.toCanonicalFileName, log: (s) => this.logger.info(s), getSourceFileLike: (f) => this.getSourceFileLike(f, projectName, declarationInfo) },
175757
175785
  declarationInfo.fileName,
175758
- declarationInfo.getLineInfo(),
175786
+ declarationInfo.textStorage.getLineInfo(),
175759
175787
  readMapFile
175760
175788
  );
175761
175789
  readMapFile = void 0;
@@ -176886,6 +176914,10 @@ function isConfigFile(config) {
176886
176914
  function printProjectWithoutFileNames(project) {
176887
176915
  project.print(
176888
176916
  /*writeProjectFileNames*/
176917
+ false,
176918
+ /*writeFileExplaination*/
176919
+ false,
176920
+ /*writeFileVersionAndText*/
176889
176921
  false
176890
176922
  );
176891
176923
  }
@@ -179328,7 +179360,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
179328
179360
  formatOptions
179329
179361
  );
179330
179362
  if (args.key === "\n" && (!edits || edits.length === 0 || allEditsBeforePos(edits, position))) {
179331
- const { lineText, absolutePosition } = scriptInfo.getAbsolutePositionAndLineText(args.line);
179363
+ const { lineText, absolutePosition } = scriptInfo.textStorage.getAbsolutePositionAndLineText(args.line);
179332
179364
  if (lineText && lineText.search("\\S") < 0) {
179333
179365
  const preferredIndent = languageService.getIndentationAtPosition(file, position, formatOptions);
179334
179366
  let hasIndent = 0;
@@ -179553,6 +179585,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
179553
179585
  change(args) {
179554
179586
  const scriptInfo = this.projectService.getScriptInfo(args.file);
179555
179587
  Debug.assert(!!scriptInfo);
179588
+ scriptInfo.textStorage.switchToScriptVersionCache();
179556
179589
  const start2 = scriptInfo.lineOffsetToPosition(args.line, args.offset);
179557
179590
  const end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
179558
179591
  if (start2 >= 0) {
@@ -3039,10 +3039,6 @@ declare namespace ts {
3039
3039
  remove(path: NormalizedPath): void;
3040
3040
  }
3041
3041
  function isDynamicFileName(fileName: NormalizedPath): boolean;
3042
- interface ScriptInfoVersion {
3043
- svc: number;
3044
- text: number;
3045
- }
3046
3042
  class ScriptInfo {
3047
3043
  private readonly host;
3048
3044
  readonly fileName: NormalizedPath;
@@ -3055,10 +3051,9 @@ declare namespace ts {
3055
3051
  readonly containingProjects: Project[];
3056
3052
  private formatSettings;
3057
3053
  private preferences;
3058
- private textStorage;
3059
- constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: ScriptInfoVersion);
3054
+ constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: number);
3060
3055
  isScriptOpen(): boolean;
3061
- open(newText: string): void;
3056
+ open(newText: string | undefined): void;
3062
3057
  close(fileExists?: boolean): void;
3063
3058
  getSnapshot(): IScriptSnapshot;
3064
3059
  private ensureRealPath;
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-insiders.20230301`;
38
+ version = `${versionMajorMinor}.0-insiders.20230302`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -168189,17 +168189,14 @@ ${options.prefix}` : "\n" : options.prefix
168189
168189
  * True when reloading contents of file from the disk is pending
168190
168190
  */
168191
168191
  this.pendingReloadFromDisk = false;
168192
- this.version = initialVersion || { svc: 0, text: 0 };
168192
+ this.version = initialVersion || 0;
168193
168193
  }
168194
168194
  getVersion() {
168195
- return this.svc ? `SVC-${this.version.svc}-${this.svc.getSnapshotVersion()}` : `Text-${this.version.text}`;
168195
+ return this.svc ? `SVC-${this.version}-${this.svc.getSnapshotVersion()}` : `Text-${this.version}`;
168196
168196
  }
168197
168197
  hasScriptVersionCache_TestOnly() {
168198
168198
  return this.svc !== void 0;
168199
168199
  }
168200
- useScriptVersionCache_TestOnly() {
168201
- this.switchToScriptVersionCache();
168202
- }
168203
168200
  resetSourceMapInfo() {
168204
168201
  this.info.sourceFileLike = void 0;
168205
168202
  this.info.closeSourceMapFileWatcher();
@@ -168212,15 +168209,17 @@ ${options.prefix}` : "\n" : options.prefix
168212
168209
  useText(newText) {
168213
168210
  this.svc = void 0;
168214
168211
  this.text = newText;
168212
+ this.textSnapshot = void 0;
168215
168213
  this.lineMap = void 0;
168216
168214
  this.fileSize = void 0;
168217
168215
  this.resetSourceMapInfo();
168218
- this.version.text++;
168216
+ this.version++;
168219
168217
  }
168220
168218
  edit(start, end, newText) {
168221
168219
  this.switchToScriptVersionCache().edit(start, end - start, newText);
168222
168220
  this.ownFileText = false;
168223
168221
  this.text = void 0;
168222
+ this.textSnapshot = void 0;
168224
168223
  this.lineMap = void 0;
168225
168224
  this.fileSize = void 0;
168226
168225
  this.resetSourceMapInfo();
@@ -168232,6 +168231,9 @@ ${options.prefix}` : "\n" : options.prefix
168232
168231
  reload(newText) {
168233
168232
  Debug.assert(newText !== void 0);
168234
168233
  this.pendingReloadFromDisk = false;
168234
+ if (!this.text && this.svc) {
168235
+ this.text = getSnapshotText(this.svc.getSnapshot());
168236
+ }
168235
168237
  if (this.text !== newText) {
168236
168238
  this.useText(newText);
168237
168239
  this.ownFileText = false;
@@ -168244,21 +168246,18 @@ ${options.prefix}` : "\n" : options.prefix
168244
168246
  * returns true if text changed
168245
168247
  */
168246
168248
  reloadWithFileText(tempFileName) {
168247
- const { text: newText, fileSize } = this.getFileTextAndSize(tempFileName);
168249
+ const { text: newText, fileSize } = tempFileName || !this.info.isDynamicOrHasMixedContent() ? this.getFileTextAndSize(tempFileName) : { text: "", fileSize: void 0 };
168248
168250
  const reloaded = this.reload(newText);
168249
168251
  this.fileSize = fileSize;
168250
168252
  this.ownFileText = !tempFileName || tempFileName === this.info.fileName;
168251
168253
  return reloaded;
168252
168254
  }
168253
168255
  /**
168254
- * Reloads the contents from the file if there is no pending reload from disk or the contents of file are same as file text
168255
- * returns true if text changed
168256
+ * Schedule reload from the disk if its not already scheduled and its not own text
168257
+ * returns true when scheduling reload
168256
168258
  */
168257
- reloadFromDisk() {
168258
- if (!this.pendingReloadFromDisk && !this.ownFileText) {
168259
- return this.reloadWithFileText();
168260
- }
168261
- return false;
168259
+ scheduleReloadIfNeeded() {
168260
+ return !this.pendingReloadFromDisk && !this.ownFileText ? this.pendingReloadFromDisk = true : false;
168262
168261
  }
168263
168262
  delayReloadFromFileIntoText() {
168264
168263
  this.pendingReloadFromDisk = true;
@@ -168274,39 +168273,48 @@ ${options.prefix}` : "\n" : options.prefix
168274
168273
  return !!this.fileSize ? this.fileSize : !!this.text ? this.text.length : !!this.svc ? this.svc.getSnapshot().getLength() : this.getSnapshot().getLength();
168275
168274
  }
168276
168275
  getSnapshot() {
168277
- return this.useScriptVersionCacheIfValidOrOpen() ? this.svc.getSnapshot() : ScriptSnapshot.fromString(this.getOrLoadText());
168276
+ var _a2, _b;
168277
+ return ((_a2 = this.tryUseScriptVersionCache()) == null ? void 0 : _a2.getSnapshot()) || ((_b = this.textSnapshot) != null ? _b : this.textSnapshot = ScriptSnapshot.fromString(Debug.checkDefined(this.text)));
168278
168278
  }
168279
- getAbsolutePositionAndLineText(line) {
168280
- return this.switchToScriptVersionCache().getAbsolutePositionAndLineText(line);
168279
+ getAbsolutePositionAndLineText(oneBasedLine) {
168280
+ const svc = this.tryUseScriptVersionCache();
168281
+ if (svc)
168282
+ return svc.getAbsolutePositionAndLineText(oneBasedLine);
168283
+ const lineMap = this.getLineMap();
168284
+ return oneBasedLine <= lineMap.length ? {
168285
+ absolutePosition: lineMap[oneBasedLine - 1],
168286
+ lineText: this.text.substring(lineMap[oneBasedLine - 1], lineMap[oneBasedLine])
168287
+ } : {
168288
+ absolutePosition: this.text.length,
168289
+ lineText: void 0
168290
+ };
168281
168291
  }
168282
168292
  /**
168283
168293
  * @param line 0 based index
168284
168294
  */
168285
168295
  lineToTextSpan(line) {
168286
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
168287
- const lineMap = this.getLineMap();
168288
- const start = lineMap[line];
168289
- const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
168290
- return createTextSpanFromBounds(start, end);
168291
- }
168292
- return this.svc.lineToTextSpan(line);
168296
+ const svc = this.tryUseScriptVersionCache();
168297
+ if (svc)
168298
+ return svc.lineToTextSpan(line);
168299
+ const lineMap = this.getLineMap();
168300
+ const start = lineMap[line];
168301
+ const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
168302
+ return createTextSpanFromBounds(start, end);
168293
168303
  }
168294
168304
  /**
168295
168305
  * @param line 1 based index
168296
168306
  * @param offset 1 based index
168297
168307
  */
168298
168308
  lineOffsetToPosition(line, offset, allowEdits) {
168299
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
168300
- return computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
168301
- }
168302
- return this.svc.lineOffsetToPosition(line, offset);
168309
+ const svc = this.tryUseScriptVersionCache();
168310
+ return svc ? svc.lineOffsetToPosition(line, offset) : computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
168303
168311
  }
168304
168312
  positionToLineOffset(position) {
168305
- if (!this.useScriptVersionCacheIfValidOrOpen()) {
168306
- const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
168307
- return { line: line + 1, offset: character + 1 };
168308
- }
168309
- return this.svc.positionToLineOffset(position);
168313
+ const svc = this.tryUseScriptVersionCache();
168314
+ if (svc)
168315
+ return svc.positionToLineOffset(position);
168316
+ const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
168317
+ return { line: line + 1, offset: character + 1 };
168310
168318
  }
168311
168319
  getFileTextAndSize(tempFileName) {
168312
168320
  let text;
@@ -168324,19 +168332,25 @@ ${options.prefix}` : "\n" : options.prefix
168324
168332
  }
168325
168333
  return { text: getText() };
168326
168334
  }
168335
+ /** @internal */
168327
168336
  switchToScriptVersionCache() {
168328
168337
  if (!this.svc || this.pendingReloadFromDisk) {
168329
168338
  this.svc = ScriptVersionCache.fromString(this.getOrLoadText());
168330
- this.version.svc++;
168339
+ this.textSnapshot = void 0;
168340
+ this.version++;
168331
168341
  }
168332
168342
  return this.svc;
168333
168343
  }
168334
- useScriptVersionCacheIfValidOrOpen() {
168335
- if (this.isOpen) {
168336
- return this.switchToScriptVersionCache();
168344
+ tryUseScriptVersionCache() {
168345
+ if (!this.svc || this.pendingReloadFromDisk) {
168346
+ this.getOrLoadText();
168337
168347
  }
168338
- if (this.pendingReloadFromDisk) {
168339
- this.reloadWithFileText();
168348
+ if (this.isOpen) {
168349
+ if (!this.svc && !this.textSnapshot) {
168350
+ this.svc = ScriptVersionCache.fromString(Debug.checkDefined(this.text));
168351
+ this.textSnapshot = void 0;
168352
+ }
168353
+ return this.svc;
168340
168354
  }
168341
168355
  return this.svc;
168342
168356
  }
@@ -168349,13 +168363,14 @@ ${options.prefix}` : "\n" : options.prefix
168349
168363
  }
168350
168364
  getLineMap() {
168351
168365
  Debug.assert(!this.svc, "ScriptVersionCache should not be set");
168352
- return this.lineMap || (this.lineMap = computeLineStarts(this.getOrLoadText()));
168366
+ return this.lineMap || (this.lineMap = computeLineStarts(Debug.checkDefined(this.text)));
168353
168367
  }
168354
168368
  getLineInfo() {
168355
- if (this.svc) {
168369
+ const svc = this.tryUseScriptVersionCache();
168370
+ if (svc) {
168356
168371
  return {
168357
- getLineCount: () => this.svc.getLineCount(),
168358
- getLineText: (line) => this.svc.getAbsolutePositionAndLineText(line + 1).lineText
168372
+ getLineCount: () => svc.getLineCount(),
168373
+ getLineText: (line) => svc.getAbsolutePositionAndLineText(line + 1).lineText
168359
168374
  };
168360
168375
  }
168361
168376
  const lineMap = this.getLineMap();
@@ -168376,20 +168391,11 @@ ${options.prefix}` : "\n" : options.prefix
168376
168391
  this.isDynamic = isDynamicFileName(fileName);
168377
168392
  this.textStorage = new TextStorage(host, this, initialVersion);
168378
168393
  if (hasMixedContent || this.isDynamic) {
168379
- this.textStorage.reload("");
168380
168394
  this.realpath = this.path;
168381
168395
  }
168382
168396
  this.scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
168383
168397
  }
168384
168398
  /** @internal */
168385
- getVersion() {
168386
- return this.textStorage.version;
168387
- }
168388
- /** @internal */
168389
- getTelemetryFileSize() {
168390
- return this.textStorage.getTelemetryFileSize();
168391
- }
168392
- /** @internal */
168393
168399
  isDynamicOrHasMixedContent() {
168394
168400
  return this.hasMixedContent || this.isDynamic;
168395
168401
  }
@@ -168404,11 +168410,7 @@ ${options.prefix}` : "\n" : options.prefix
168404
168410
  }
168405
168411
  close(fileExists = true) {
168406
168412
  this.textStorage.isOpen = false;
168407
- if (this.isDynamicOrHasMixedContent() || !fileExists) {
168408
- if (this.textStorage.reload("")) {
168409
- this.markContainingProjectsAsDirty();
168410
- }
168411
- } else if (this.textStorage.reloadFromDisk()) {
168413
+ if (fileExists && this.textStorage.scheduleReloadIfNeeded()) {
168412
168414
  this.markContainingProjectsAsDirty();
168413
168415
  }
168414
168416
  }
@@ -168588,22 +168590,12 @@ ${options.prefix}` : "\n" : options.prefix
168588
168590
  this.markContainingProjectsAsDirty();
168589
168591
  }
168590
168592
  reloadFromFile(tempFileName) {
168591
- if (this.isDynamicOrHasMixedContent()) {
168592
- this.textStorage.reload("");
168593
+ if (this.textStorage.reloadWithFileText(tempFileName)) {
168593
168594
  this.markContainingProjectsAsDirty();
168594
168595
  return true;
168595
- } else {
168596
- if (this.textStorage.reloadWithFileText(tempFileName)) {
168597
- this.markContainingProjectsAsDirty();
168598
- return true;
168599
- }
168600
168596
  }
168601
168597
  return false;
168602
168598
  }
168603
- /** @internal */
168604
- getAbsolutePositionAndLineText(line) {
168605
- return this.textStorage.getAbsolutePositionAndLineText(line);
168606
- }
168607
168599
  editContent(start, end, newText) {
168608
168600
  this.textStorage.edit(start, end, newText);
168609
168601
  this.markContainingProjectsAsDirty();
@@ -168643,10 +168635,6 @@ ${options.prefix}` : "\n" : options.prefix
168643
168635
  return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */;
168644
168636
  }
168645
168637
  /** @internal */
168646
- getLineInfo() {
168647
- return this.textStorage.getLineInfo();
168648
- }
168649
- /** @internal */
168650
168638
  closeSourceMapFileWatcher() {
168651
168639
  if (this.sourceMapFilePath && !isString(this.sourceMapFilePath)) {
168652
168640
  closeFileWatcherOf(this.sourceMapFilePath);
@@ -168777,7 +168765,7 @@ ${options.prefix}` : "\n" : options.prefix
168777
168765
  deferredSize: 0
168778
168766
  };
168779
168767
  for (const info of infos) {
168780
- const fileSize = includeSizes ? info.getTelemetryFileSize() : 0;
168768
+ const fileSize = includeSizes ? info.textStorage.getTelemetryFileSize() : 0;
168781
168769
  switch (info.scriptKind) {
168782
168770
  case 1 /* JS */:
168783
168771
  result.js += 1;
@@ -169807,10 +169795,26 @@ ${options.prefix}` : "\n" : options.prefix
169807
169795
  const elapsed = timestamp() - start;
169808
169796
  this.sendPerformanceEvent("UpdateGraph", elapsed);
169809
169797
  this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram}${this.program ? ` structureIsReused:: ${StructureIsReused[this.program.structureIsReused]}` : ""} Elapsed: ${elapsed}ms`);
169810
- if (this.hasAddedorRemovedFiles) {
169798
+ if (this.projectService.logger.isTestLogger) {
169799
+ if (this.program !== oldProgram) {
169800
+ this.print(
169801
+ /*writeProjectFileNames*/
169802
+ true,
169803
+ this.hasAddedorRemovedFiles,
169804
+ /*writeFileVersionAndText*/
169805
+ true
169806
+ );
169807
+ } else {
169808
+ this.writeLog(`Same program as before`);
169809
+ }
169810
+ } else if (this.hasAddedorRemovedFiles) {
169811
169811
  this.print(
169812
169812
  /*writeProjectFileNames*/
169813
- true
169813
+ true,
169814
+ /*writeFileExplaination*/
169815
+ true,
169816
+ /*writeFileVersionAndText*/
169817
+ false
169814
169818
  );
169815
169819
  } else if (this.program !== oldProgram) {
169816
169820
  this.writeLog(`Different program with same set of files`);
@@ -169920,6 +169924,16 @@ ${options.prefix}` : "\n" : options.prefix
169920
169924
  return this.projectService.getScriptInfo(uncheckedFileName);
169921
169925
  }
169922
169926
  filesToString(writeProjectFileNames) {
169927
+ return this.filesToStringWorker(
169928
+ writeProjectFileNames,
169929
+ /*writeFileExplaination*/
169930
+ true,
169931
+ /*writeFileVersionAndText*/
169932
+ false
169933
+ );
169934
+ }
169935
+ /** @internal */
169936
+ filesToStringWorker(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
169923
169937
  if (this.isInitialLoadPending())
169924
169938
  return " Files (0) InitialLoadPending\n";
169925
169939
  if (!this.program)
@@ -169929,23 +169943,33 @@ ${options.prefix}` : "\n" : options.prefix
169929
169943
  `;
169930
169944
  if (writeProjectFileNames) {
169931
169945
  for (const file of sourceFiles) {
169932
- strBuilder += ` ${file.fileName}
169946
+ strBuilder += ` ${file.fileName}${writeFileVersionAndText ? ` ${file.version} ${JSON.stringify(file.text)}` : ""}
169933
169947
  `;
169934
169948
  }
169935
- strBuilder += "\n\n";
169936
- explainFiles(this.program, (s) => strBuilder += ` ${s}
169949
+ if (writeFileExplaination) {
169950
+ strBuilder += "\n\n";
169951
+ explainFiles(this.program, (s) => strBuilder += ` ${s}
169937
169952
  `);
169953
+ }
169938
169954
  }
169939
169955
  return strBuilder;
169940
169956
  }
169941
169957
  /** @internal */
169942
- print(writeProjectFileNames) {
169958
+ print(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
169943
169959
  this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
169944
- this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */)));
169960
+ this.writeLog(this.filesToStringWorker(
169961
+ writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */),
169962
+ writeFileExplaination && this.projectService.logger.hasLevel(3 /* verbose */),
169963
+ writeFileVersionAndText && this.projectService.logger.hasLevel(3 /* verbose */)
169964
+ ));
169945
169965
  this.writeLog("-----------------------------------------------");
169946
169966
  if (this.autoImportProviderHost) {
169947
169967
  this.autoImportProviderHost.print(
169948
169968
  /*writeProjectFileNames*/
169969
+ false,
169970
+ /*writeFileExplaination*/
169971
+ false,
169972
+ /*writeFileVersionAndText*/
169949
169973
  false
169950
169974
  );
169951
169975
  }
@@ -171196,6 +171220,10 @@ ${options.prefix}` : "\n" : options.prefix
171196
171220
  function printProjectWithoutFileNames(project) {
171197
171221
  project.print(
171198
171222
  /*writeProjectFileNames*/
171223
+ false,
171224
+ /*writeFileExplaination*/
171225
+ false,
171226
+ /*writeFileVersionAndText*/
171199
171227
  false
171200
171228
  );
171201
171229
  }
@@ -171900,7 +171928,11 @@ ${options.prefix}` : "\n" : options.prefix
171900
171928
  this.logger.info("`remove Project::");
171901
171929
  project.print(
171902
171930
  /*writeProjectFileNames*/
171903
- true
171931
+ true,
171932
+ /*writeFileExplaination*/
171933
+ true,
171934
+ /*writeFileVersionAndText*/
171935
+ false
171904
171936
  );
171905
171937
  project.close();
171906
171938
  if (Debug.shouldAssert(1 /* Normal */)) {
@@ -172039,7 +172071,7 @@ ${options.prefix}` : "\n" : options.prefix
172039
172071
  }
172040
172072
  deleteScriptInfo(info) {
172041
172073
  this.filenameToScriptInfo.delete(info.path);
172042
- this.filenameToScriptInfoVersion.set(info.path, info.getVersion());
172074
+ this.filenameToScriptInfoVersion.set(info.path, info.textStorage.version);
172043
172075
  const realpath = info.getRealpathIfDifferent();
172044
172076
  if (realpath) {
172045
172077
  this.realpathToScriptInfos.remove(realpath, info);
@@ -173123,7 +173155,7 @@ Dynamic files must always be opened with service's current directory or service
173123
173155
  const documentPositionMapper = getDocumentPositionMapper(
173124
173156
  { getCanonicalFileName: this.toCanonicalFileName, log: (s) => this.logger.info(s), getSourceFileLike: (f) => this.getSourceFileLike(f, projectName, declarationInfo) },
173125
173157
  declarationInfo.fileName,
173126
- declarationInfo.getLineInfo(),
173158
+ declarationInfo.textStorage.getLineInfo(),
173127
173159
  readMapFile
173128
173160
  );
173129
173161
  readMapFile = void 0;
@@ -176756,7 +176788,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
176756
176788
  formatOptions
176757
176789
  );
176758
176790
  if (args.key === "\n" && (!edits || edits.length === 0 || allEditsBeforePos(edits, position))) {
176759
- const { lineText, absolutePosition } = scriptInfo.getAbsolutePositionAndLineText(args.line);
176791
+ const { lineText, absolutePosition } = scriptInfo.textStorage.getAbsolutePositionAndLineText(args.line);
176760
176792
  if (lineText && lineText.search("\\S") < 0) {
176761
176793
  const preferredIndent = languageService.getIndentationAtPosition(file, position, formatOptions);
176762
176794
  let hasIndent = 0;
@@ -176981,6 +177013,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
176981
177013
  change(args) {
176982
177014
  const scriptInfo = this.projectService.getScriptInfo(args.file);
176983
177015
  Debug.assert(!!scriptInfo);
177016
+ scriptInfo.textStorage.switchToScriptVersionCache();
176984
177017
  const start = scriptInfo.lineOffsetToPosition(args.line, args.offset);
176985
177018
  const end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
176986
177019
  if (start >= 0) {
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-insiders.20230301`;
38
+ version = `${versionMajorMinor}.0-insiders.20230302`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-insiders.20230301`;
57
+ var version = `${versionMajorMinor}.0-insiders.20230302`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-pr-52984-22",
5
+ "version": "5.1.0-pr-52984-26",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [