@@ -35,8 +35,7 @@ namespace ts {
35
35
36
36
export type FileWatcherCallback = ( fileName : string , eventKind : FileWatcherEventKind , modifiedTime ?: Date ) => void ;
37
37
export type DirectoryWatcherCallback = ( fileName : string ) => void ;
38
- /*@internal */
39
- export interface WatchedFile {
38
+ interface WatchedFile {
40
39
readonly fileName : string ;
41
40
readonly callback : FileWatcherCallback ;
42
41
mtime : Date ;
@@ -81,8 +80,7 @@ namespace ts {
81
80
/* @internal */
82
81
export let unchangedPollThresholds = createPollingIntervalBasedLevels ( defaultChunkLevels ) ;
83
82
84
- /* @internal */
85
- export function setCustomPollingValues ( system : System ) {
83
+ function setCustomPollingValues ( system : System ) {
86
84
if ( ! system . getEnvironmentVariable ) {
87
85
return ;
88
86
}
@@ -189,31 +187,28 @@ namespace ts {
189
187
}
190
188
}
191
189
192
- /* @internal */
193
- export function createDynamicPriorityPollingWatchFile ( host : {
190
+ interface WatchedFileWithUnchangedPolls extends WatchedFileWithIsClosed {
191
+ unchangedPolls : number ;
192
+ }
193
+ function createDynamicPriorityPollingWatchFile ( host : {
194
194
getModifiedTime : NonNullable < System [ "getModifiedTime" ] > ;
195
195
setTimeout : NonNullable < System [ "setTimeout" ] > ;
196
196
} ) : HostWatchFile {
197
- interface WatchedFile extends ts . WatchedFile {
198
- isClosed ?: boolean ;
199
- unchangedPolls : number ;
200
- }
201
-
202
- interface PollingIntervalQueue extends Array < WatchedFile > {
197
+ interface PollingIntervalQueue extends Array < WatchedFileWithUnchangedPolls > {
203
198
pollingInterval : PollingInterval ;
204
199
pollIndex : number ;
205
200
pollScheduled : boolean ;
206
201
}
207
202
208
- const watchedFiles : WatchedFile [ ] = [ ] ;
209
- const changedFilesInLastPoll : WatchedFile [ ] = [ ] ;
203
+ const watchedFiles : WatchedFileWithUnchangedPolls [ ] = [ ] ;
204
+ const changedFilesInLastPoll : WatchedFileWithUnchangedPolls [ ] = [ ] ;
210
205
const lowPollingIntervalQueue = createPollingIntervalQueue ( PollingInterval . Low ) ;
211
206
const mediumPollingIntervalQueue = createPollingIntervalQueue ( PollingInterval . Medium ) ;
212
207
const highPollingIntervalQueue = createPollingIntervalQueue ( PollingInterval . High ) ;
213
208
return watchFile ;
214
209
215
210
function watchFile ( fileName : string , callback : FileWatcherCallback , defaultPollingInterval : PollingInterval ) : FileWatcher {
216
- const file : WatchedFile = {
211
+ const file : WatchedFileWithUnchangedPolls = {
217
212
fileName,
218
213
callback,
219
214
unchangedPolls : 0 ,
@@ -233,7 +228,7 @@ namespace ts {
233
228
}
234
229
235
230
function createPollingIntervalQueue ( pollingInterval : PollingInterval ) : PollingIntervalQueue {
236
- const queue = [ ] as WatchedFile [ ] as PollingIntervalQueue ;
231
+ const queue = [ ] as WatchedFileWithUnchangedPolls [ ] as PollingIntervalQueue ;
237
232
queue . pollingInterval = pollingInterval ;
238
233
queue . pollIndex = 0 ;
239
234
queue . pollScheduled = false ;
@@ -265,7 +260,7 @@ namespace ts {
265
260
}
266
261
}
267
262
268
- function pollQueue ( queue : ( WatchedFile | undefined ) [ ] , pollingInterval : PollingInterval , pollIndex : number , chunkSize : number ) {
263
+ function pollQueue ( queue : ( WatchedFileWithUnchangedPolls | undefined ) [ ] , pollingInterval : PollingInterval , pollIndex : number , chunkSize : number ) {
269
264
return pollWatchedFileQueue (
270
265
host ,
271
266
queue ,
@@ -274,7 +269,7 @@ namespace ts {
274
269
onWatchFileStat
275
270
) ;
276
271
277
- function onWatchFileStat ( watchedFile : WatchedFile , pollIndex : number , fileChanged : boolean ) {
272
+ function onWatchFileStat ( watchedFile : WatchedFileWithUnchangedPolls , pollIndex : number , fileChanged : boolean ) {
278
273
if ( fileChanged ) {
279
274
watchedFile . unchangedPolls = 0 ;
280
275
// Changed files go to changedFilesInLastPoll queue
@@ -311,12 +306,12 @@ namespace ts {
311
306
}
312
307
}
313
308
314
- function addToPollingIntervalQueue ( file : WatchedFile , pollingInterval : PollingInterval ) {
309
+ function addToPollingIntervalQueue ( file : WatchedFileWithUnchangedPolls , pollingInterval : PollingInterval ) {
315
310
pollingIntervalQueue ( pollingInterval ) . push ( file ) ;
316
311
scheduleNextPollIfNotAlreadyScheduled ( pollingInterval ) ;
317
312
}
318
313
319
- function addChangedFileToLowPollingIntervalQueue ( file : WatchedFile ) {
314
+ function addChangedFileToLowPollingIntervalQueue ( file : WatchedFileWithUnchangedPolls ) {
320
315
changedFilesInLastPoll . push ( file ) ;
321
316
scheduleNextPollIfNotAlreadyScheduled ( PollingInterval . Low ) ;
322
317
}
@@ -423,8 +418,7 @@ namespace ts {
423
418
}
424
419
}
425
420
426
- /* @internal */
427
- export function createSingleFileWatcherPerName (
421
+ function createSingleFileWatcherPerName (
428
422
watchFile : HostWatchFile ,
429
423
useCaseSensitiveFileNames : boolean
430
424
) : HostWatchFile {
@@ -474,8 +468,7 @@ namespace ts {
474
468
/**
475
469
* Returns true if file status changed
476
470
*/
477
- /*@internal */
478
- export function onWatchedFileStat ( watchedFile : WatchedFile , modifiedTime : Date ) : boolean {
471
+ function onWatchedFileStat ( watchedFile : WatchedFile , modifiedTime : Date ) : boolean {
479
472
const oldTime = watchedFile . mtime . getTime ( ) ;
480
473
const newTime = modifiedTime . getTime ( ) ;
481
474
if ( oldTime !== newTime ) {
@@ -512,8 +505,7 @@ namespace ts {
512
505
curSysLog = logger ;
513
506
}
514
507
515
- /*@internal */
516
- export interface RecursiveDirectoryWatcherHost {
508
+ interface RecursiveDirectoryWatcherHost {
517
509
watchDirectory : HostWatchDirectory ;
518
510
useCaseSensitiveFileNames : boolean ;
519
511
getCurrentDirectory : System [ "getCurrentDirectory" ] ;
@@ -529,8 +521,7 @@ namespace ts {
529
521
* that means if this is recursive watcher, watch the children directories as well
530
522
* (eg on OS that dont support recursive watch using fs.watch use fs.watchFile)
531
523
*/
532
- /*@internal */
533
- export function createDirectoryWatcherSupportingRecursive ( {
524
+ function createDirectoryWatcherSupportingRecursive ( {
534
525
watchDirectory,
535
526
useCaseSensitiveFileNames,
536
527
getCurrentDirectory,
@@ -792,8 +783,7 @@ namespace ts {
792
783
Directory ,
793
784
}
794
785
795
- /*@internal */
796
- export function createFileWatcherCallback ( callback : FsWatchCallback ) : FileWatcherCallback {
786
+ function createFileWatcherCallback ( callback : FsWatchCallback ) : FileWatcherCallback {
797
787
return ( _fileName , eventKind , modifiedTime ) => callback ( eventKind === FileWatcherEventKind . Changed ? "change" : "rename" , "" , modifiedTime ) ;
798
788
}
799
789
@@ -854,7 +844,7 @@ namespace ts {
854
844
/*@internal */
855
845
export interface CreateSystemWatchFunctions {
856
846
// Polling watch file
857
- pollingWatchFile : HostWatchFile ;
847
+ pollingWatchFileWorker : HostWatchFile ;
858
848
// For dynamic polling watch file
859
849
getModifiedTime : NonNullable < System [ "getModifiedTime" ] > ;
860
850
setTimeout : NonNullable < System [ "setTimeout" ] > ;
@@ -878,7 +868,7 @@ namespace ts {
878
868
879
869
/*@internal */
880
870
export function createSystemWatchFunctions ( {
881
- pollingWatchFile ,
871
+ pollingWatchFileWorker ,
882
872
getModifiedTime,
883
873
setTimeout,
884
874
clearTimeout,
@@ -896,6 +886,7 @@ namespace ts {
896
886
inodeWatching,
897
887
sysLog,
898
888
} : CreateSystemWatchFunctions ) : { watchFile : HostWatchFile ; watchDirectory : HostWatchDirectory ; } {
889
+ const pollingWatchFile = createSingleFileWatcherPerName ( pollingWatchFileWorker , useCaseSensitiveFileNames ) ;
899
890
let dynamicPollingWatchFile : HostWatchFile | undefined ;
900
891
let fixedChunkSizePollingWatchFile : HostWatchFile | undefined ;
901
892
let nonPollingWatchFile : HostWatchFile | undefined ;
@@ -1445,7 +1436,7 @@ namespace ts {
1445
1436
const fsSupportsRecursiveFsWatch = isNode4OrLater && ( process . platform === "win32" || process . platform === "darwin" ) ;
1446
1437
const getCurrentDirectory = memoize ( ( ) => process . cwd ( ) ) ;
1447
1438
const { watchFile, watchDirectory } = createSystemWatchFunctions ( {
1448
- pollingWatchFile : createSingleFileWatcherPerName ( fsWatchFileWorker , useCaseSensitiveFileNames ) ,
1439
+ pollingWatchFileWorker : fsWatchFileWorker ,
1449
1440
getModifiedTime,
1450
1441
setTimeout,
1451
1442
clearTimeout,
0 commit comments