1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.getSortedUsageRows = exports.filterInteractivePlugins = void 0;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | const filterInteractivePlugins = (watchPlugins, globalConfig) => {
|
15 | const usageInfos = watchPlugins.map(
|
16 | p => p.getUsageInfo && p.getUsageInfo(globalConfig)
|
17 | );
|
18 | return watchPlugins.filter((_plugin, i) => {
|
19 | const usageInfo = usageInfos[i];
|
20 |
|
21 | if (usageInfo) {
|
22 | const {key} = usageInfo;
|
23 | return !usageInfos.slice(i + 1).some(u => !!u && key === u.key);
|
24 | }
|
25 |
|
26 | return false;
|
27 | });
|
28 | };
|
29 |
|
30 | exports.filterInteractivePlugins = filterInteractivePlugins;
|
31 |
|
32 | function notEmpty(value) {
|
33 | return value != null;
|
34 | }
|
35 |
|
36 | const getSortedUsageRows = (watchPlugins, globalConfig) =>
|
37 | filterInteractivePlugins(watchPlugins, globalConfig)
|
38 | .sort((a, b) => {
|
39 | if (a.isInternal && b.isInternal) {
|
40 |
|
41 | return 0;
|
42 | }
|
43 |
|
44 | if (a.isInternal !== b.isInternal) {
|
45 |
|
46 | return a.isInternal ? -1 : 1;
|
47 | }
|
48 |
|
49 | const usageInfoA = a.getUsageInfo && a.getUsageInfo(globalConfig);
|
50 | const usageInfoB = b.getUsageInfo && b.getUsageInfo(globalConfig);
|
51 |
|
52 | if (usageInfoA && usageInfoB) {
|
53 |
|
54 | return usageInfoA.key.localeCompare(usageInfoB.key);
|
55 | }
|
56 |
|
57 | return 0;
|
58 | })
|
59 | .map(p => p.getUsageInfo && p.getUsageInfo(globalConfig))
|
60 | .filter(notEmpty);
|
61 |
|
62 | exports.getSortedUsageRows = getSortedUsageRows;
|