@teambit/watcher 1.0.228 → 1.0.230

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.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.workspace/watcher@1.0.228" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.workspace/watcher@1.0.230" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -46,7 +46,8 @@
46
46
  "line": 52,
47
47
  "character": 10
48
48
  },
49
- "name": "EventMessages"
49
+ "name": "EventMessages",
50
+ "internalFilePath": "watcher.ts"
50
51
  },
51
52
  "isOptional": true
52
53
  },
@@ -66,7 +67,11 @@
66
67
  "line": 53,
67
68
  "character": 15
68
69
  },
69
- "name": "CompilationInitiator"
70
+ "name": "CompilationInitiator",
71
+ "componentId": {
72
+ "scope": "teambit.compilation",
73
+ "name": "compiler"
74
+ }
70
75
  },
71
76
  "isOptional": true
72
77
  },
@@ -250,7 +255,11 @@
250
255
  "line": 20,
251
256
  "character": 24
252
257
  },
253
- "name": "Workspace"
258
+ "name": "Workspace",
259
+ "componentId": {
260
+ "scope": "teambit.workspace",
261
+ "name": "workspace"
262
+ }
254
263
  },
255
264
  "isOptional": false,
256
265
  "isSpread": false
@@ -270,7 +279,11 @@
270
279
  "line": 21,
271
280
  "character": 20
272
281
  },
273
- "name": "ScopeMain"
282
+ "name": "ScopeMain",
283
+ "componentId": {
284
+ "scope": "teambit.scope",
285
+ "name": "scope"
286
+ }
274
287
  },
275
288
  "isOptional": false,
276
289
  "isSpread": false
@@ -290,7 +303,11 @@
290
303
  "line": 22,
291
304
  "character": 21
292
305
  },
293
- "name": "PubsubMain"
306
+ "name": "PubsubMain",
307
+ "componentId": {
308
+ "scope": "teambit.harmony",
309
+ "name": "pubsub"
310
+ }
294
311
  },
295
312
  "isOptional": false,
296
313
  "isSpread": false
@@ -310,7 +327,8 @@
310
327
  "line": 23,
311
328
  "character": 29
312
329
  },
313
- "name": "OnPreWatchSlot"
330
+ "name": "OnPreWatchSlot",
331
+ "internalFilePath": "watcher.main.runtime.ts"
314
332
  },
315
333
  "isOptional": false,
316
334
  "isSpread": false
@@ -330,7 +348,11 @@
330
348
  "line": 24,
331
349
  "character": 25
332
350
  },
333
- "name": "IpcEventsMain"
351
+ "name": "IpcEventsMain",
352
+ "componentId": {
353
+ "scope": "teambit.harmony",
354
+ "name": "ipc-events"
355
+ }
334
356
  },
335
357
  "isOptional": false,
336
358
  "isSpread": false
@@ -350,7 +372,11 @@
350
372
  "line": 25,
351
373
  "character": 22
352
374
  },
353
- "name": "Logger"
375
+ "name": "Logger",
376
+ "componentId": {
377
+ "scope": "teambit.harmony",
378
+ "name": "logger"
379
+ }
354
380
  },
355
381
  "isOptional": false,
356
382
  "isSpread": false
@@ -370,7 +396,11 @@
370
396
  "line": 26,
371
397
  "character": 28
372
398
  },
373
- "name": "GlobalConfigMain"
399
+ "name": "GlobalConfigMain",
400
+ "componentId": {
401
+ "scope": "teambit.harmony",
402
+ "name": "global-config"
403
+ }
374
404
  },
375
405
  "isOptional": false,
376
406
  "isSpread": false
@@ -486,7 +516,12 @@
486
516
  "line": 39,
487
517
  "character": 41
488
518
  },
489
- "name": "ComponentID"
519
+ "name": "ComponentID",
520
+ "componentId": {
521
+ "scope": "teambit.component",
522
+ "name": "component-id",
523
+ "version": "1.2.0"
524
+ }
490
525
  }
491
526
  },
492
527
  "isOptional": false,
@@ -551,7 +586,8 @@
551
586
  "line": 46,
552
587
  "character": 38
553
588
  },
554
- "name": "OnPreWatch"
589
+ "name": "OnPreWatch",
590
+ "internalFilePath": "watcher.main.runtime.ts"
555
591
  },
556
592
  "isOptional": false,
557
593
  "isSpread": false
@@ -664,7 +700,11 @@
664
700
  "line": 65,
665
701
  "character": 7
666
702
  },
667
- "name": "CLIMain"
703
+ "name": "CLIMain",
704
+ "componentId": {
705
+ "scope": "teambit.harmony",
706
+ "name": "cli"
707
+ }
668
708
  },
669
709
  {
670
710
  "__schema": "TypeRefSchema",
@@ -673,7 +713,11 @@
673
713
  "line": 66,
674
714
  "character": 7
675
715
  },
676
- "name": "Workspace"
716
+ "name": "Workspace",
717
+ "componentId": {
718
+ "scope": "teambit.workspace",
719
+ "name": "workspace"
720
+ }
677
721
  },
678
722
  {
679
723
  "__schema": "TypeRefSchema",
@@ -682,7 +726,11 @@
682
726
  "line": 67,
683
727
  "character": 7
684
728
  },
685
- "name": "ScopeMain"
729
+ "name": "ScopeMain",
730
+ "componentId": {
731
+ "scope": "teambit.scope",
732
+ "name": "scope"
733
+ }
686
734
  },
687
735
  {
688
736
  "__schema": "TypeRefSchema",
@@ -691,7 +739,11 @@
691
739
  "line": 68,
692
740
  "character": 7
693
741
  },
694
- "name": "PubsubMain"
742
+ "name": "PubsubMain",
743
+ "componentId": {
744
+ "scope": "teambit.harmony",
745
+ "name": "pubsub"
746
+ }
695
747
  },
696
748
  {
697
749
  "__schema": "TypeRefSchema",
@@ -700,7 +752,11 @@
700
752
  "line": 69,
701
753
  "character": 7
702
754
  },
703
- "name": "LoggerMain"
755
+ "name": "LoggerMain",
756
+ "componentId": {
757
+ "scope": "teambit.harmony",
758
+ "name": "logger"
759
+ }
704
760
  },
705
761
  {
706
762
  "__schema": "TypeRefSchema",
@@ -709,7 +765,11 @@
709
765
  "line": 70,
710
766
  "character": 7
711
767
  },
712
- "name": "IpcEventsMain"
768
+ "name": "IpcEventsMain",
769
+ "componentId": {
770
+ "scope": "teambit.harmony",
771
+ "name": "ipc-events"
772
+ }
713
773
  },
714
774
  {
715
775
  "__schema": "TypeRefSchema",
@@ -718,7 +778,11 @@
718
778
  "line": 71,
719
779
  "character": 7
720
780
  },
721
- "name": "GlobalConfigMain"
781
+ "name": "GlobalConfigMain",
782
+ "componentId": {
783
+ "scope": "teambit.harmony",
784
+ "name": "global-config"
785
+ }
722
786
  }
723
787
  ]
724
788
  },
@@ -768,7 +832,8 @@
768
832
  "line": 74,
769
833
  "character": 24
770
834
  },
771
- "name": "OnPreWatchSlot"
835
+ "name": "OnPreWatchSlot",
836
+ "internalFilePath": "watcher.main.runtime.ts"
772
837
  }
773
838
  ]
774
839
  },
@@ -928,7 +993,12 @@
928
993
  "line": 31,
929
994
  "character": 103
930
995
  },
931
- "name": "ComponentID"
996
+ "name": "ComponentID",
997
+ "componentId": {
998
+ "scope": "teambit.component",
999
+ "name": "component-id",
1000
+ "version": "1.2.0"
1001
+ }
932
1002
  }
933
1003
  },
934
1004
  "isOptional": false
@@ -1115,7 +1185,7 @@
1115
1185
  "line": 43,
1116
1186
  "character": 31
1117
1187
  },
1118
- "signature": "(filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: number, failureMsg?: string): void",
1188
+ "signature": "(filePaths: string[], buildResults: \u001b[2m(component: teambit.workspace/workspace)\u001b[22m OnComponentEventResult[], verbose: boolean, duration: number, failureMsg?: string): void",
1119
1189
  "name": "",
1120
1190
  "params": [
1121
1191
  {
@@ -1168,7 +1238,11 @@
1168
1238
  "line": 45,
1169
1239
  "character": 17
1170
1240
  },
1171
- "name": "OnComponentEventResult"
1241
+ "name": "OnComponentEventResult",
1242
+ "componentId": {
1243
+ "scope": "teambit.workspace",
1244
+ "name": "workspace"
1245
+ }
1172
1246
  }
1173
1247
  },
1174
1248
  "isOptional": false,
@@ -1280,7 +1354,8 @@
1280
1354
  "line": 52,
1281
1355
  "character": 10
1282
1356
  },
1283
- "name": "EventMessages"
1357
+ "name": "EventMessages",
1358
+ "internalFilePath": "watcher.ts"
1284
1359
  },
1285
1360
  "isOptional": true
1286
1361
  },
@@ -1300,7 +1375,11 @@
1300
1375
  "line": 53,
1301
1376
  "character": 15
1302
1377
  },
1303
- "name": "CompilationInitiator"
1378
+ "name": "CompilationInitiator",
1379
+ "componentId": {
1380
+ "scope": "teambit.compilation",
1381
+ "name": "compiler"
1382
+ }
1304
1383
  },
1305
1384
  "isOptional": true
1306
1385
  },
@@ -1446,7 +1525,8 @@
1446
1525
  "line": 61,
1447
1526
  "character": 32
1448
1527
  },
1449
- "name": "PathLinux"
1528
+ "name": "PathLinux",
1529
+ "internalFilePath": "watcher.ts"
1450
1530
  },
1451
1531
  "isOptional": false,
1452
1532
  "isSpread": false
@@ -1458,7 +1538,12 @@
1458
1538
  "line": 61,
1459
1539
  "character": 44
1460
1540
  },
1461
- "name": "ComponentID"
1541
+ "name": "ComponentID",
1542
+ "componentId": {
1543
+ "scope": "teambit.component",
1544
+ "name": "component-id",
1545
+ "version": "1.2.0"
1546
+ }
1462
1547
  }
1463
1548
  }
1464
1549
  ]
@@ -1499,7 +1584,11 @@
1499
1584
  "line": 76,
1500
1585
  "character": 24
1501
1586
  },
1502
- "name": "Workspace"
1587
+ "name": "Workspace",
1588
+ "componentId": {
1589
+ "scope": "teambit.workspace",
1590
+ "name": "workspace"
1591
+ }
1503
1592
  },
1504
1593
  "isOptional": false,
1505
1594
  "isSpread": false
@@ -1519,7 +1608,11 @@
1519
1608
  "line": 77,
1520
1609
  "character": 21
1521
1610
  },
1522
- "name": "PubsubMain"
1611
+ "name": "PubsubMain",
1612
+ "componentId": {
1613
+ "scope": "teambit.harmony",
1614
+ "name": "pubsub"
1615
+ }
1523
1616
  },
1524
1617
  "isOptional": false,
1525
1618
  "isSpread": false
@@ -1702,7 +1795,7 @@
1702
1795
  "line": 15,
1703
1796
  "character": 26
1704
1797
  },
1705
- "signature": "(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>",
1798
+ "signature": "(componentIds: \u001b[2m(component: teambit.component/component-id)\u001b[22m ComponentID[], watchOpts: WatchOptions): Promise<void>",
1706
1799
  "name": "",
1707
1800
  "params": [
1708
1801
  {
@@ -1727,7 +1820,12 @@
1727
1820
  "line": 15,
1728
1821
  "character": 41
1729
1822
  },
1730
- "name": "ComponentID"
1823
+ "name": "ComponentID",
1824
+ "componentId": {
1825
+ "scope": "teambit.component",
1826
+ "name": "component-id",
1827
+ "version": "1.2.0"
1828
+ }
1731
1829
  }
1732
1830
  },
1733
1831
  "isOptional": false,
@@ -1794,6 +1892,11 @@
1794
1892
  "character": 30
1795
1893
  },
1796
1894
  "name": "SlotRegistry",
1895
+ "componentId": {
1896
+ "scope": "teambit.harmony",
1897
+ "name": "harmony",
1898
+ "version": "0.4.6"
1899
+ },
1797
1900
  "typeArgs": [
1798
1901
  {
1799
1902
  "__schema": "TypeRefSchema",
@@ -1802,7 +1905,8 @@
1802
1905
  "line": 16,
1803
1906
  "character": 43
1804
1907
  },
1805
- "name": "OnPreWatch"
1908
+ "name": "OnPreWatch",
1909
+ "internalFilePath": "watcher.main.runtime.ts"
1806
1910
  }
1807
1911
  ]
1808
1912
  }
@@ -1842,7 +1946,11 @@
1842
1946
  "line": 20,
1843
1947
  "character": 24
1844
1948
  },
1845
- "name": "Workspace"
1949
+ "name": "Workspace",
1950
+ "componentId": {
1951
+ "scope": "teambit.workspace",
1952
+ "name": "workspace"
1953
+ }
1846
1954
  },
1847
1955
  "isOptional": false,
1848
1956
  "isSpread": false
@@ -1862,7 +1970,11 @@
1862
1970
  "line": 21,
1863
1971
  "character": 20
1864
1972
  },
1865
- "name": "ScopeMain"
1973
+ "name": "ScopeMain",
1974
+ "componentId": {
1975
+ "scope": "teambit.scope",
1976
+ "name": "scope"
1977
+ }
1866
1978
  },
1867
1979
  "isOptional": false,
1868
1980
  "isSpread": false
@@ -1882,7 +1994,11 @@
1882
1994
  "line": 22,
1883
1995
  "character": 21
1884
1996
  },
1885
- "name": "PubsubMain"
1997
+ "name": "PubsubMain",
1998
+ "componentId": {
1999
+ "scope": "teambit.harmony",
2000
+ "name": "pubsub"
2001
+ }
1886
2002
  },
1887
2003
  "isOptional": false,
1888
2004
  "isSpread": false
@@ -1902,7 +2018,8 @@
1902
2018
  "line": 23,
1903
2019
  "character": 29
1904
2020
  },
1905
- "name": "OnPreWatchSlot"
2021
+ "name": "OnPreWatchSlot",
2022
+ "internalFilePath": "watcher.main.runtime.ts"
1906
2023
  },
1907
2024
  "isOptional": false,
1908
2025
  "isSpread": false
@@ -1922,7 +2039,11 @@
1922
2039
  "line": 24,
1923
2040
  "character": 25
1924
2041
  },
1925
- "name": "IpcEventsMain"
2042
+ "name": "IpcEventsMain",
2043
+ "componentId": {
2044
+ "scope": "teambit.harmony",
2045
+ "name": "ipc-events"
2046
+ }
1926
2047
  },
1927
2048
  "isOptional": false,
1928
2049
  "isSpread": false
@@ -1942,7 +2063,11 @@
1942
2063
  "line": 25,
1943
2064
  "character": 22
1944
2065
  },
1945
- "name": "Logger"
2066
+ "name": "Logger",
2067
+ "componentId": {
2068
+ "scope": "teambit.harmony",
2069
+ "name": "logger"
2070
+ }
1946
2071
  },
1947
2072
  "isOptional": false,
1948
2073
  "isSpread": false
@@ -1962,7 +2087,11 @@
1962
2087
  "line": 26,
1963
2088
  "character": 28
1964
2089
  },
1965
- "name": "GlobalConfigMain"
2090
+ "name": "GlobalConfigMain",
2091
+ "componentId": {
2092
+ "scope": "teambit.harmony",
2093
+ "name": "global-config"
2094
+ }
1966
2095
  },
1967
2096
  "isOptional": false,
1968
2097
  "isSpread": false
@@ -2078,7 +2207,12 @@
2078
2207
  "line": 39,
2079
2208
  "character": 41
2080
2209
  },
2081
- "name": "ComponentID"
2210
+ "name": "ComponentID",
2211
+ "componentId": {
2212
+ "scope": "teambit.component",
2213
+ "name": "component-id",
2214
+ "version": "1.2.0"
2215
+ }
2082
2216
  }
2083
2217
  },
2084
2218
  "isOptional": false,
@@ -2143,7 +2277,8 @@
2143
2277
  "line": 46,
2144
2278
  "character": 38
2145
2279
  },
2146
- "name": "OnPreWatch"
2280
+ "name": "OnPreWatch",
2281
+ "internalFilePath": "watcher.main.runtime.ts"
2147
2282
  },
2148
2283
  "isOptional": false,
2149
2284
  "isSpread": false
@@ -2256,7 +2391,11 @@
2256
2391
  "line": 65,
2257
2392
  "character": 7
2258
2393
  },
2259
- "name": "CLIMain"
2394
+ "name": "CLIMain",
2395
+ "componentId": {
2396
+ "scope": "teambit.harmony",
2397
+ "name": "cli"
2398
+ }
2260
2399
  },
2261
2400
  {
2262
2401
  "__schema": "TypeRefSchema",
@@ -2265,7 +2404,11 @@
2265
2404
  "line": 66,
2266
2405
  "character": 7
2267
2406
  },
2268
- "name": "Workspace"
2407
+ "name": "Workspace",
2408
+ "componentId": {
2409
+ "scope": "teambit.workspace",
2410
+ "name": "workspace"
2411
+ }
2269
2412
  },
2270
2413
  {
2271
2414
  "__schema": "TypeRefSchema",
@@ -2274,7 +2417,11 @@
2274
2417
  "line": 67,
2275
2418
  "character": 7
2276
2419
  },
2277
- "name": "ScopeMain"
2420
+ "name": "ScopeMain",
2421
+ "componentId": {
2422
+ "scope": "teambit.scope",
2423
+ "name": "scope"
2424
+ }
2278
2425
  },
2279
2426
  {
2280
2427
  "__schema": "TypeRefSchema",
@@ -2283,7 +2430,11 @@
2283
2430
  "line": 68,
2284
2431
  "character": 7
2285
2432
  },
2286
- "name": "PubsubMain"
2433
+ "name": "PubsubMain",
2434
+ "componentId": {
2435
+ "scope": "teambit.harmony",
2436
+ "name": "pubsub"
2437
+ }
2287
2438
  },
2288
2439
  {
2289
2440
  "__schema": "TypeRefSchema",
@@ -2292,7 +2443,11 @@
2292
2443
  "line": 69,
2293
2444
  "character": 7
2294
2445
  },
2295
- "name": "LoggerMain"
2446
+ "name": "LoggerMain",
2447
+ "componentId": {
2448
+ "scope": "teambit.harmony",
2449
+ "name": "logger"
2450
+ }
2296
2451
  },
2297
2452
  {
2298
2453
  "__schema": "TypeRefSchema",
@@ -2301,7 +2456,11 @@
2301
2456
  "line": 70,
2302
2457
  "character": 7
2303
2458
  },
2304
- "name": "IpcEventsMain"
2459
+ "name": "IpcEventsMain",
2460
+ "componentId": {
2461
+ "scope": "teambit.harmony",
2462
+ "name": "ipc-events"
2463
+ }
2305
2464
  },
2306
2465
  {
2307
2466
  "__schema": "TypeRefSchema",
@@ -2310,7 +2469,11 @@
2310
2469
  "line": 71,
2311
2470
  "character": 7
2312
2471
  },
2313
- "name": "GlobalConfigMain"
2472
+ "name": "GlobalConfigMain",
2473
+ "componentId": {
2474
+ "scope": "teambit.harmony",
2475
+ "name": "global-config"
2476
+ }
2314
2477
  }
2315
2478
  ]
2316
2479
  },
@@ -2360,7 +2523,8 @@
2360
2523
  "line": 74,
2361
2524
  "character": 24
2362
2525
  },
2363
- "name": "OnPreWatchSlot"
2526
+ "name": "OnPreWatchSlot",
2527
+ "internalFilePath": "watcher.main.runtime.ts"
2364
2528
  }
2365
2529
  ]
2366
2530
  },
@@ -2451,7 +2615,7 @@
2451
2615
  "componentId": {
2452
2616
  "scope": "teambit.workspace",
2453
2617
  "name": "watcher",
2454
- "version": "1.0.228"
2618
+ "version": "1.0.230"
2455
2619
  },
2456
2620
  "taggedModuleExports": []
2457
2621
  }
@@ -0,0 +1,5 @@
1
+ export declare enum CheckTypes {
2
+ None = 0,// keep this. it equals zero. this way we can do "if checkTypes() ... "
3
+ EntireProject = 1,
4
+ ChangedFile = 2
5
+ }
@@ -0,0 +1,6 @@
1
+ import { WatcherAspect } from './watcher.aspect';
2
+ export type { WatchOptions } from './watcher';
3
+ export { CheckTypes } from './check-types';
4
+ export type { WatcherMain } from './watcher.main.runtime';
5
+ export default WatcherAspect;
6
+ export { WatcherAspect };
@@ -0,0 +1,4 @@
1
+ import { OnComponentEventResult } from '@teambit/workspace';
2
+ import { RootDirs } from './watcher';
3
+ export declare function formatWatchPathsSortByComponent(trackDirs: RootDirs): string;
4
+ export declare function formatCompileResults(compileResults: OnComponentEventResult[]): string;
@@ -0,0 +1,8 @@
1
+ import PQueue from 'p-queue';
2
+ export declare class WatchQueue {
3
+ private queue;
4
+ constructor(concurrency?: number);
5
+ getQueue(): PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>;
6
+ add<T>(fn: () => T, priority?: number): Promise<T>;
7
+ onIdle(): Promise<void>;
8
+ }
@@ -0,0 +1,46 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import type { PubsubMain } from '@teambit/pubsub';
4
+ import { WatcherMain } from './watcher.main.runtime';
5
+ export type WatchCmdOpts = {
6
+ verbose?: boolean;
7
+ skipPreCompilation?: boolean;
8
+ checkTypes?: string | boolean;
9
+ };
10
+ export declare class WatchCommand implements Command {
11
+ /**
12
+ * logger extension.
13
+ */
14
+ private pubsub;
15
+ /**
16
+ * logger extension.
17
+ */
18
+ private logger;
19
+ /**
20
+ * watcher extension.
21
+ */
22
+ private watcher;
23
+ name: string;
24
+ description: string;
25
+ extendedDescription: string;
26
+ helpUrl: string;
27
+ alias: string;
28
+ group: string;
29
+ options: CommandOptions;
30
+ constructor(
31
+ /**
32
+ * logger extension.
33
+ */
34
+ pubsub: PubsubMain,
35
+ /**
36
+ * logger extension.
37
+ */
38
+ logger: Logger,
39
+ /**
40
+ * watcher extension.
41
+ */
42
+ watcher: WatcherMain);
43
+ private registerToEvents;
44
+ private eventsListener;
45
+ report(cliArgs: [], watchCmdOpts: WatchCmdOpts): Promise<string>;
46
+ }
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const WatcherAspect: Aspect;
@@ -0,0 +1,108 @@
1
+ /// <reference types="node" />
2
+ import { PubsubMain } from '@teambit/pubsub';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import { Consumer } from '@teambit/legacy/dist/consumer';
5
+ import { ChildProcess } from 'child_process';
6
+ import { CompilationInitiator } from '@teambit/compiler';
7
+ import { Workspace, OnComponentEventResult } from '@teambit/workspace';
8
+ import { CheckTypes } from './check-types';
9
+ import { WatcherMain } from './watcher.main.runtime';
10
+ export type WatcherProcessData = {
11
+ watchProcess: ChildProcess;
12
+ compilerId: ComponentID;
13
+ componentIds: ComponentID[];
14
+ };
15
+ export type EventMessages = {
16
+ onAll: Function;
17
+ onStart: Function;
18
+ onReady: Function;
19
+ onChange: OnFileEventFunc;
20
+ onAdd: OnFileEventFunc;
21
+ onUnlink: OnFileEventFunc;
22
+ onError: Function;
23
+ };
24
+ export type OnFileEventFunc = (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: number, failureMsg?: string) => void;
25
+ export type WatchOptions = {
26
+ msgs?: EventMessages;
27
+ initiator?: CompilationInitiator;
28
+ verbose?: boolean;
29
+ spawnTSServer?: boolean;
30
+ checkTypes?: CheckTypes;
31
+ preCompile?: boolean;
32
+ compile?: boolean;
33
+ };
34
+ export type RootDirs = {
35
+ [dir: PathLinux]: ComponentID;
36
+ };
37
+ type PathLinux = string;
38
+ export declare class Watcher {
39
+ private workspace;
40
+ private pubsub;
41
+ private watcherMain;
42
+ private options;
43
+ private fsWatcher;
44
+ private changedFilesPerComponent;
45
+ private watchQueue;
46
+ private bitMapChangesInProgress;
47
+ private ipcEventsDir;
48
+ private rootDirs;
49
+ private verbose;
50
+ private multipleWatchers;
51
+ constructor(workspace: Workspace, pubsub: PubsubMain, watcherMain: WatcherMain, options: WatchOptions);
52
+ get consumer(): Consumer;
53
+ watch(): Promise<unknown>;
54
+ /**
55
+ * *** DEBOUNCING ***
56
+ * some actions trigger multiple files changes at (almost) the same time. e.g. "git pull".
57
+ * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.
58
+ * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).
59
+ * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,
60
+ * it'll only add the file to `this.changedFilesPerComponent` prop.
61
+ * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,
62
+ * indicating the next file-change to start a new execution.
63
+ *
64
+ * implementation wise, `lodash.debounce` doesn't help here, because:
65
+ * A) it doesn't return the results, unless "leading" option is true. here, it must be false, otherwise, it'll start
66
+ * the execution immediately.
67
+ * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay
68
+ * other components undesirably.
69
+ *
70
+ * *** QUEUE ***
71
+ * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components
72
+ * and .bitmap changes execution can still be processed concurrently.
73
+ * the following example explains why this is an issue.
74
+ * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.
75
+ * all these changes get pulled at the same time by "git pull", as a result, the execution of compA and the .bitmap
76
+ * happen at the same time.
77
+ * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this
78
+ * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.
79
+ * after this change, the workspace doesn't have this id anymore, which will trigger an error.
80
+ * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all
81
+ * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).
82
+ * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.
83
+ * in the example above, at this stage, the id will be resolved to compA@0.0.2.
84
+ * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at
85
+ * the same time. (the same way is done when loading all components from the filesystem/scope).
86
+ * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the
87
+ * .bitmap execution starts.
88
+ */
89
+ private handleChange;
90
+ private sleep;
91
+ private triggerCompChanges;
92
+ /**
93
+ * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.
94
+ */
95
+ private handleBitmapChanges;
96
+ private executeWatchOperationsOnRemove;
97
+ private executeWatchOperationsOnComponent;
98
+ private createOnComponentRemovedEvent;
99
+ private createOnComponentChangeEvent;
100
+ private createOnComponentAddEvent;
101
+ private isComponentWatchedExternally;
102
+ private getComponentIdByPath;
103
+ private getRelativePathLinux;
104
+ private findRootDirByFilePathRecursively;
105
+ private createWatcher;
106
+ private setRootDirs;
107
+ }
108
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { SlotRegistry } from '@teambit/harmony';
3
+ import { GlobalConfigMain } from '@teambit/global-config';
4
+ import { ScopeMain } from '@teambit/scope';
5
+ import { ComponentID } from '@teambit/component-id';
6
+ import { IpcEventsMain } from '@teambit/ipc-events';
7
+ import { Logger, LoggerMain } from '@teambit/logger';
8
+ import { PubsubMain } from '@teambit/pubsub';
9
+ import { Workspace } from '@teambit/workspace';
10
+ import { WatchOptions } from './watcher';
11
+ export type OnPreWatch = (componentIds: ComponentID[], watchOpts: WatchOptions) => Promise<void>;
12
+ export type OnPreWatchSlot = SlotRegistry<OnPreWatch>;
13
+ export declare class WatcherMain {
14
+ private workspace;
15
+ private scope;
16
+ private pubsub;
17
+ private onPreWatchSlot;
18
+ readonly ipcEvents: IpcEventsMain;
19
+ readonly logger: Logger;
20
+ readonly globalConfig: GlobalConfigMain;
21
+ constructor(workspace: Workspace, scope: ScopeMain, pubsub: PubsubMain, onPreWatchSlot: OnPreWatchSlot, ipcEvents: IpcEventsMain, logger: Logger, globalConfig: GlobalConfigMain);
22
+ watch(opts: WatchOptions): Promise<void>;
23
+ watchScopeInternalFiles(): Promise<void>;
24
+ triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
25
+ registerOnPreWatch(onPreWatchFunc: OnPreWatch): this;
26
+ static slots: ((registerFn: () => string) => SlotRegistry<OnPreWatch>)[];
27
+ static dependencies: import("@teambit/harmony").Aspect[];
28
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
29
+ static provider([cli, workspace, scope, pubsub, loggerMain, ipcEvents, globalConfig]: [
30
+ CLIMain,
31
+ Workspace,
32
+ ScopeMain,
33
+ PubsubMain,
34
+ LoggerMain,
35
+ IpcEventsMain,
36
+ GlobalConfigMain
37
+ ], _: any, [onPreWatchSlot]: [OnPreWatchSlot]): Promise<WatcherMain>;
38
+ }
39
+ export default WatcherMain;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/watcher",
3
- "version": "1.0.228",
3
+ "version": "1.0.230",
4
4
  "homepage": "https://bit.cloud/teambit/workspace/watcher",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "watcher",
9
- "version": "1.0.228"
9
+ "version": "1.0.230"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -18,21 +18,21 @@
18
18
  "fs-extra": "10.0.0",
19
19
  "@teambit/harmony": "0.4.6",
20
20
  "@teambit/component-id": "1.2.0",
21
- "@teambit/compiler": "1.0.228",
22
- "@teambit/logger": "0.0.954",
23
- "@teambit/workspace": "1.0.228",
24
- "@teambit/cli": "0.0.861",
25
- "@teambit/pubsub": "1.0.228",
26
- "@teambit/global-config": "0.0.864",
27
- "@teambit/ipc-events": "1.0.228",
28
- "@teambit/scope": "1.0.228"
21
+ "@teambit/compiler": "1.0.230",
22
+ "@teambit/logger": "0.0.955",
23
+ "@teambit/workspace": "1.0.230",
24
+ "@teambit/cli": "0.0.862",
25
+ "@teambit/pubsub": "1.0.230",
26
+ "@teambit/global-config": "0.0.865",
27
+ "@teambit/ipc-events": "1.0.230",
28
+ "@teambit/scope": "1.0.230"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/lodash": "4.14.165",
32
32
  "@types/fs-extra": "9.0.7",
33
33
  "@types/mocha": "9.1.0",
34
34
  "chai": "4.3.0",
35
- "@teambit/harmony.envs.core-aspect-env": "0.0.30"
35
+ "@teambit/harmony.envs.core-aspect-env": "0.0.33"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@teambit/legacy": "1.0.624"
package/tsconfig.json CHANGED
@@ -20,8 +20,7 @@
20
20
  "emitDeclarationOnly": true,
21
21
  "strict": true,
22
22
  "strictPropertyInitialization": false,
23
- "noImplicitAny": false,
24
- "composite": true
23
+ "noImplicitAny": false
25
24
  },
26
25
  "exclude": [
27
26
  "artifacts",
@@ -36,31 +35,5 @@
36
35
  "include": [
37
36
  "**/*",
38
37
  "**/*.json"
39
- ],
40
- "references": [
41
- {
42
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@1.0.228"
43
- },
44
- {
45
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.954"
46
- },
47
- {
48
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.228"
49
- },
50
- {
51
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.861"
52
- },
53
- {
54
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_pubsub@1.0.228"
55
- },
56
- {
57
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_global-config@0.0.864"
58
- },
59
- {
60
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_ipc-events@1.0.228"
61
- },
62
- {
63
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_scope@1.0.228"
64
- }
65
38
  ]
66
39
  }