typescript 5.1.0-dev.20230426 → 5.1.0-dev.20230427

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.
@@ -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-dev.20230426`;
57
+ var version = `${versionMajorMinor}.0-dev.20230427`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -3689,9 +3689,6 @@ var curSysLog = noop;
3689
3689
  function sysLog(s) {
3690
3690
  return curSysLog(s);
3691
3691
  }
3692
- function setSysLog(logger) {
3693
- curSysLog = logger;
3694
- }
3695
3692
  function createDirectoryWatcherSupportingRecursive({
3696
3693
  watchDirectory,
3697
3694
  useCaseSensitiveFileNames,
@@ -10005,10 +10002,15 @@ function createSingleLineStringWriter() {
10005
10002
  clear: () => str = ""
10006
10003
  };
10007
10004
  }
10008
- function copyEntries(source, target) {
10009
- source.forEach((value, key) => {
10010
- target.set(key, value);
10011
- });
10005
+ function forEachKey(map2, callback) {
10006
+ const iterator = map2.keys();
10007
+ for (const key of iterator) {
10008
+ const result = callback(key);
10009
+ if (result) {
10010
+ return result;
10011
+ }
10012
+ }
10013
+ return void 0;
10012
10014
  }
10013
10015
  function getFullWidth(node) {
10014
10016
  return node.end - node.pos;
@@ -10969,10 +10971,6 @@ function directoryProbablyExists(directoryName, host) {
10969
10971
  function closeFileWatcher(watcher) {
10970
10972
  watcher.close();
10971
10973
  }
10972
- function clearMap(map2, onDeleteValue) {
10973
- map2.forEach(onDeleteValue);
10974
- map2.clear();
10975
- }
10976
10974
  function getLastChild(node) {
10977
10975
  let lastChild;
10978
10976
  forEachChild(
@@ -30464,104 +30462,6 @@ function createBracketsMap() {
30464
30462
  }
30465
30463
 
30466
30464
  // src/compiler/watchUtilities.ts
30467
- function getWatchFactory(host, watchLogLevel, log2, getDetailWatchInfo2) {
30468
- setSysLog(watchLogLevel === 2 /* Verbose */ ? log2 : noop);
30469
- const plainInvokeFactory = {
30470
- watchFile: (file, callback, pollingInterval, options) => host.watchFile(file, callback, pollingInterval, options),
30471
- watchDirectory: (directory, callback, flags, options) => host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options)
30472
- };
30473
- const triggerInvokingFactory = watchLogLevel !== 0 /* None */ ? {
30474
- watchFile: createTriggerLoggingAddWatch("watchFile"),
30475
- watchDirectory: createTriggerLoggingAddWatch("watchDirectory")
30476
- } : void 0;
30477
- const factory2 = watchLogLevel === 2 /* Verbose */ ? {
30478
- watchFile: createFileWatcherWithLogging,
30479
- watchDirectory: createDirectoryWatcherWithLogging
30480
- } : triggerInvokingFactory || plainInvokeFactory;
30481
- const excludeWatcherFactory = watchLogLevel === 2 /* Verbose */ ? createExcludeWatcherWithLogging : returnNoopFileWatcher;
30482
- return {
30483
- watchFile: createExcludeHandlingAddWatch("watchFile"),
30484
- watchDirectory: createExcludeHandlingAddWatch("watchDirectory")
30485
- };
30486
- function createExcludeHandlingAddWatch(key) {
30487
- return (file, cb, flags, options, detailInfo1, detailInfo2) => {
30488
- var _a;
30489
- return !matchesExclude(file, key === "watchFile" ? options == null ? void 0 : options.excludeFiles : options == null ? void 0 : options.excludeDirectories, useCaseSensitiveFileNames(), ((_a = host.getCurrentDirectory) == null ? void 0 : _a.call(host)) || "") ? factory2[key].call(
30490
- /*thisArgs*/
30491
- void 0,
30492
- file,
30493
- cb,
30494
- flags,
30495
- options,
30496
- detailInfo1,
30497
- detailInfo2
30498
- ) : excludeWatcherFactory(file, flags, options, detailInfo1, detailInfo2);
30499
- };
30500
- }
30501
- function useCaseSensitiveFileNames() {
30502
- return typeof host.useCaseSensitiveFileNames === "boolean" ? host.useCaseSensitiveFileNames : host.useCaseSensitiveFileNames();
30503
- }
30504
- function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) {
30505
- log2(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
30506
- return {
30507
- close: () => log2(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`)
30508
- };
30509
- }
30510
- function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
30511
- log2(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
30512
- const watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2);
30513
- return {
30514
- close: () => {
30515
- log2(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
30516
- watcher.close();
30517
- }
30518
- };
30519
- }
30520
- function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
30521
- const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
30522
- log2(watchInfo);
30523
- const start = timestamp();
30524
- const watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
30525
- const elapsed = timestamp() - start;
30526
- log2(`Elapsed:: ${elapsed}ms ${watchInfo}`);
30527
- return {
30528
- close: () => {
30529
- const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
30530
- log2(watchInfo2);
30531
- const start2 = timestamp();
30532
- watcher.close();
30533
- const elapsed2 = timestamp() - start2;
30534
- log2(`Elapsed:: ${elapsed2}ms ${watchInfo2}`);
30535
- }
30536
- };
30537
- }
30538
- function createTriggerLoggingAddWatch(key) {
30539
- return (file, cb, flags, options, detailInfo1, detailInfo2) => plainInvokeFactory[key].call(
30540
- /*thisArgs*/
30541
- void 0,
30542
- file,
30543
- (...args) => {
30544
- const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
30545
- log2(triggerredInfo);
30546
- const start = timestamp();
30547
- cb.call(
30548
- /*thisArg*/
30549
- void 0,
30550
- ...args
30551
- );
30552
- const elapsed = timestamp() - start;
30553
- log2(`Elapsed:: ${elapsed}ms ${triggerredInfo}`);
30554
- },
30555
- flags,
30556
- options,
30557
- detailInfo1,
30558
- detailInfo2
30559
- );
30560
- }
30561
- function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3) {
30562
- return `WatchInfo: ${file} ${flags} ${JSON.stringify(options)} ${getDetailWatchInfo3 ? getDetailWatchInfo3(detailInfo1, detailInfo2) : detailInfo2 === void 0 ? detailInfo1 : `${detailInfo1} ${detailInfo2}`}`;
30563
- }
30564
- }
30565
30465
  function getFallbackOptions(options) {
30566
30466
  const fallbackPolling = options == null ? void 0 : options.fallbackPolling;
30567
30467
  return {
@@ -31140,8 +31040,6 @@ var screenStartingMessageCodes = [
31140
31040
  Diagnostics.Starting_compilation_in_watch_mode.code,
31141
31041
  Diagnostics.File_change_detected_Starting_incremental_compilation.code
31142
31042
  ];
31143
- var noopFileWatcher = { close: noop };
31144
- var returnNoopFileWatcher = () => noopFileWatcher;
31145
31043
 
31146
31044
  // src/jsTyping/_namespaces/ts.JsTyping.ts
31147
31045
  var ts_JsTyping_exports = {};
@@ -31466,11 +31364,11 @@ function renderPackageNameValidationFailureWorker(typing, result, name, isScopeN
31466
31364
 
31467
31365
  // src/jsTyping/shared.ts
31468
31366
  var ActionSet = "action::set";
31469
- var ActionInvalidate = "action::invalidate";
31470
31367
  var ActionPackageInstalled = "action::packageInstalled";
31471
31368
  var EventTypesRegistry = "event::typesRegistry";
31472
31369
  var EventBeginInstallTypes = "event::beginInstallTypes";
31473
31370
  var EventEndInstallTypes = "event::endInstallTypes";
31371
+ var ActionWatchTypingLocations = "action::watchTypingLocations";
31474
31372
  var Arguments;
31475
31373
  ((Arguments2) => {
31476
31374
  Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation";
@@ -31530,19 +31428,6 @@ function getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remainin
31530
31428
  }
31531
31429
  return { command, remaining: remaining - toSlice };
31532
31430
  }
31533
- function endsWith2(str, suffix, caseSensitive) {
31534
- const expectedPos = str.length - suffix.length;
31535
- return expectedPos >= 0 && (str.indexOf(suffix, expectedPos) === expectedPos || !caseSensitive && compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* EqualTo */);
31536
- }
31537
- function isPackageOrBowerJson(fileName, caseSensitive) {
31538
- return endsWith2(fileName, "/package.json", caseSensitive) || endsWith2(fileName, "/bower.json", caseSensitive);
31539
- }
31540
- function sameFiles(a, b, caseSensitive) {
31541
- return a === b || !caseSensitive && compareStringsCaseInsensitive(a, b) === 0 /* EqualTo */;
31542
- }
31543
- function getDetailWatchInfo(projectName, watchers) {
31544
- return `Project: ${projectName} watcher already invoked: ${watchers == null ? void 0 : watchers.isInvoked}`;
31545
- }
31546
31431
  var TypingsInstaller = class {
31547
31432
  constructor(installTypingHost, globalCachePath, safeListPath, typesMapLocation2, throttleLimit, log2 = nullLog) {
31548
31433
  this.installTypingHost = installTypingHost;
@@ -31560,13 +31445,10 @@ var TypingsInstaller = class {
31560
31445
  this.installRunCount = 1;
31561
31446
  this.inFlightRequestCount = 0;
31562
31447
  this.latestDistTag = "latest";
31563
- this.toCanonicalFileName = createGetCanonicalFileName(installTypingHost.useCaseSensitiveFileNames);
31564
- this.globalCachePackageJsonPath = combinePaths(globalCachePath, "package.json");
31565
31448
  const isLoggingEnabled = this.log.isEnabled();
31566
31449
  if (isLoggingEnabled) {
31567
31450
  this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}', types map path ${typesMapLocation2}`);
31568
31451
  }
31569
- this.watchFactory = getWatchFactory(this.installTypingHost, isLoggingEnabled ? 2 /* Verbose */ : 0 /* None */, (s) => this.log.writeLine(s), getDetailWatchInfo);
31570
31452
  this.processCacheLocation(this.globalCachePath);
31571
31453
  }
31572
31454
  closeProject(req) {
@@ -31583,8 +31465,8 @@ var TypingsInstaller = class {
31583
31465
  }
31584
31466
  return;
31585
31467
  }
31586
- clearMap(watchers, closeFileWatcher);
31587
31468
  this.projectWatchers.delete(projectName);
31469
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: [] });
31588
31470
  if (this.log.isEnabled()) {
31589
31471
  this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`);
31590
31472
  }
@@ -31617,7 +31499,7 @@ var TypingsInstaller = class {
31617
31499
  if (this.log.isEnabled()) {
31618
31500
  this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`);
31619
31501
  }
31620
- this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch, req.projectRootPath, req.watchOptions);
31502
+ this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch);
31621
31503
  if (discoverTypingsResult.newTypingNames.length) {
31622
31504
  this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames);
31623
31505
  } else {
@@ -31818,75 +31700,19 @@ var TypingsInstaller = class {
31818
31700
  host.createDirectory(directory);
31819
31701
  }
31820
31702
  }
31821
- watchFiles(projectName, files, projectRootPath, options) {
31703
+ watchFiles(projectName, files) {
31822
31704
  if (!files.length) {
31823
31705
  this.closeWatchers(projectName);
31824
31706
  return;
31825
31707
  }
31826
- let watchers = this.projectWatchers.get(projectName);
31827
- const toRemove = /* @__PURE__ */ new Map();
31828
- if (!watchers) {
31829
- watchers = /* @__PURE__ */ new Map();
31830
- this.projectWatchers.set(projectName, watchers);
31708
+ const existing = this.projectWatchers.get(projectName);
31709
+ const newSet = new Set(files);
31710
+ if (!existing || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
31711
+ this.projectWatchers.set(projectName, newSet);
31712
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files });
31831
31713
  } else {
31832
- copyEntries(watchers, toRemove);
31833
- }
31834
- watchers.isInvoked = false;
31835
- const isLoggingEnabled = this.log.isEnabled();
31836
- const createProjectWatcher = (path2, projectWatcherType) => {
31837
- const canonicalPath = this.toCanonicalFileName(path2);
31838
- toRemove.delete(canonicalPath);
31839
- if (watchers.has(canonicalPath)) {
31840
- return;
31841
- }
31842
- if (isLoggingEnabled) {
31843
- this.log.writeLine(`${projectWatcherType}:: Added:: WatchInfo: ${path2}`);
31844
- }
31845
- const watcher = projectWatcherType === "FileWatcher" /* FileWatcher */ ? this.watchFactory.watchFile(path2, () => {
31846
- if (!watchers.isInvoked) {
31847
- watchers.isInvoked = true;
31848
- this.sendResponse({ projectName, kind: ActionInvalidate });
31849
- }
31850
- }, 2e3 /* High */, options, projectName, watchers) : this.watchFactory.watchDirectory(path2, (f) => {
31851
- if (watchers.isInvoked || !fileExtensionIs(f, ".json" /* Json */)) {
31852
- return;
31853
- }
31854
- if (isPackageOrBowerJson(f, this.installTypingHost.useCaseSensitiveFileNames) && !sameFiles(f, this.globalCachePackageJsonPath, this.installTypingHost.useCaseSensitiveFileNames)) {
31855
- watchers.isInvoked = true;
31856
- this.sendResponse({ projectName, kind: ActionInvalidate });
31857
- }
31858
- }, 1 /* Recursive */, options, projectName, watchers);
31859
- watchers.set(canonicalPath, isLoggingEnabled ? {
31860
- close: () => {
31861
- this.log.writeLine(`${projectWatcherType}:: Closed:: WatchInfo: ${path2}`);
31862
- watcher.close();
31863
- }
31864
- } : watcher);
31865
- };
31866
- for (const file of files) {
31867
- if (file.endsWith("/package.json") || file.endsWith("/bower.json")) {
31868
- createProjectWatcher(file, "FileWatcher" /* FileWatcher */);
31869
- continue;
31870
- }
31871
- if (containsPath(projectRootPath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
31872
- const subDirectory = file.indexOf(directorySeparator, projectRootPath.length + 1);
31873
- if (subDirectory !== -1) {
31874
- createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */);
31875
- } else {
31876
- createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
31877
- }
31878
- continue;
31879
- }
31880
- if (containsPath(this.globalCachePath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
31881
- createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* DirectoryWatcher */);
31882
- continue;
31883
- }
31884
- createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
31714
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: void 0 });
31885
31715
  }
31886
- toRemove.forEach((watch, path2) => {
31887
- watch.close();
31888
- watchers.delete(path2);
31889
- });
31890
31716
  }
31891
31717
  createSetTypings(request, typings) {
31892
31718
  return {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-dev.20230426",
5
+ "version": "5.1.0-dev.20230427",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -115,5 +115,5 @@
115
115
  "node": "14.21.1",
116
116
  "npm": "8.19.3"
117
117
  },
118
- "gitHead": "eb014a26522dd809ae4d0e85634a62eabda2755a"
118
+ "gitHead": "157753520520fd0936bff280de30af56e15f94ee"
119
119
  }