tt-help-cli-ycl 1.3.11 → 1.3.13

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.
Files changed (61) hide show
  1. package/README.md +17 -17
  2. package/cli.js +9 -9
  3. package/package.json +45 -46
  4. package/{bat → scripts}/run-explore.bat +68 -68
  5. package/{bat → scripts}/run-explore.ps1 +81 -81
  6. package/{bat → scripts}/run-explore.sh +73 -73
  7. package/scripts/test-captcha-lib.mjs +68 -0
  8. package/scripts/test-captcha.mjs +81 -0
  9. package/scripts/test-incognito-lib.mjs +36 -0
  10. package/scripts/test-login-state.mjs +128 -0
  11. package/scripts/test-safe-click.mjs +45 -0
  12. package/src/cli/auto.js +186 -157
  13. package/src/cli/config.js +116 -0
  14. package/src/cli/explore-default.js +83 -0
  15. package/src/cli/explore.js +227 -181
  16. package/src/cli/progress.js +111 -111
  17. package/src/cli/refresh.js +216 -0
  18. package/src/cli/scrape.js +47 -47
  19. package/src/cli/utils.js +18 -18
  20. package/src/cli/videos.js +41 -41
  21. package/src/cli/watch.js +31 -31
  22. package/src/lib/args.js +456 -391
  23. package/src/lib/browser/anti-detect.js +23 -23
  24. package/src/lib/browser/cdp.js +194 -142
  25. package/src/lib/browser/launch.js +43 -43
  26. package/src/lib/browser/page.js +146 -87
  27. package/src/lib/constants.js +119 -119
  28. package/src/lib/delay.js +54 -54
  29. package/src/lib/explore-fetch.js +118 -118
  30. package/src/lib/fetcher.js +45 -45
  31. package/src/lib/filter.js +66 -66
  32. package/src/lib/io.js +54 -54
  33. package/src/lib/output.js +80 -80
  34. package/src/{scraper/modules/page-error-detector.mjs → lib/page-error-detector.js} +70 -70
  35. package/src/lib/parser.js +47 -47
  36. package/src/lib/retry.js +45 -45
  37. package/src/lib/scrape.js +40 -40
  38. package/src/{scraper/modules/scroll-collector.mjs → lib/scroll-collector.js} +231 -189
  39. package/src/lib/url.js +52 -52
  40. package/src/main.js +48 -0
  41. package/src/results/user-videos-bar.lar.lar.moeta.json +37 -0
  42. package/src/scraper/{auto-core.mjs → auto-core.js} +203 -194
  43. package/src/scraper/{core.mjs → core.js} +211 -190
  44. package/src/scraper/{explore-core.mjs → explore-core.js} +180 -171
  45. package/src/scraper/modules/{captcha-handler.mjs → captcha-handler.js} +114 -114
  46. package/src/scraper/modules/{comment-extractor.mjs → comment-extractor.js} +74 -69
  47. package/src/scraper/modules/{follow-extractor.mjs → follow-extractor.js} +121 -121
  48. package/src/scraper/modules/{guess-extractor.mjs → guess-extractor.js} +51 -51
  49. package/src/scraper/modules/page-error-detector.js +1 -0
  50. package/src/scraper/modules/{page-helpers.mjs → page-helpers.js} +48 -48
  51. package/src/scraper/modules/scroll-collector.js +8 -0
  52. package/src/scraper/refresh-core.js +179 -0
  53. package/src/videos/{core.mjs → core.js} +126 -126
  54. package/src/watch/data-store.js +431 -0
  55. package/src/watch/public/index.html +721 -690
  56. package/src/watch/{server.mjs → server.js} +484 -349
  57. package/src/main.mjs +0 -234
  58. package/src/test-auto-follow.cjs +0 -109
  59. package/src/test-extractors.cjs +0 -75
  60. package/src/test-follow.cjs +0 -41
  61. package/src/watch/data-store.mjs +0 -274
@@ -1,118 +1,118 @@
1
- import { chromium } from 'playwright';
2
- import { browser, saveBrowser, configPath } from './constants.js';
3
- import { detectBrowser } from './browser/launch.js';
4
- import { getAntiDetectScript } from './browser/anti-detect.js';
5
- import { retryWithBackoff } from './retry.js';
6
- import { scrollAndCollect } from '../scraper/modules/scroll-collector.mjs';
7
-
8
- const EXPLORE_URL = 'https://www.tiktok.com/explore';
9
-
10
- function sleep(ms) {
11
- return new Promise(r => setTimeout(r, ms));
12
- }
13
-
14
- export async function fetchExplore(count = 100) {
15
- let browserPath = browser;
16
- let browserSource = '配置';
17
-
18
- if (!browserPath) {
19
- console.log(' [0/6] 未配置浏览器,正在自动探测...');
20
- const detected = detectBrowser();
21
- if (detected) {
22
- browserPath = detected;
23
- browserSource = '自动探测';
24
- try {
25
- saveBrowser(browserPath);
26
- console.log(` [0/6] 已保存浏览器路径到配置: ${configPath}`);
27
- } catch (err) {
28
- console.log(` [0/6] 保存配置失败: ${err.message}`);
29
- }
30
- }
31
- }
32
-
33
- const launchOptions = {
34
- headless: true,
35
- args: [
36
- '--no-sandbox',
37
- '--disable-setuid-sandbox',
38
- '--disable-blink-features=AutomationControlled',
39
- '--disable-dev-shm-usage',
40
- ],
41
- };
42
-
43
- if (browserPath) {
44
- console.log(` [0/6] 使用${browserSource}浏览器: ${browserPath}`);
45
- launchOptions.executablePath = browserPath;
46
- }
47
-
48
- let instance;
49
- try {
50
- instance = await chromium.launch(launchOptions);
51
- } catch (err) {
52
- if (browserPath) {
53
- console.log(` [0/6] 浏览器启动失败 (${err.message}),回退到 Playwright Chromium...`);
54
- }
55
- instance = await chromium.launch({
56
- headless: true,
57
- args: launchOptions.args,
58
- });
59
- }
60
-
61
- try {
62
- const context = await instance.newContext({
63
- viewport: { width: 1280, height: 900 },
64
- userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
65
- locale: 'en-US',
66
- });
67
-
68
- await context.addInitScript(getAntiDetectScript());
69
-
70
- const page = await context.newPage();
71
- await retryWithBackoff(() => page.goto(EXPLORE_URL, { waitUntil: 'load', timeout: 30000 }));
72
- console.log(' [1/6] 页面已加载');
73
-
74
- await sleep(5000);
75
-
76
- const allUrls = await scrollAndCollect(page, {
77
- container: null,
78
- collectFn: () => ({
79
- items: Array.from(document.querySelectorAll('a'))
80
- .filter(a => /\/video\/\d{16,20}/.test(a.href))
81
- .map(a => a.href),
82
- }),
83
- maxItems: count * 2,
84
- delayRange: [1500, 2500],
85
- staleThreshold: 5,
86
- onRound: (round, items, allItems) => {
87
- if ((round + 1) % 10 === 0) {
88
- const uniqueCount = [...new Set(allItems)].length;
89
- console.log(` [2/6] 滚动 ${round + 1},当前 ${uniqueCount} 个视频`);
90
- }
91
- },
92
- });
93
-
94
- await sleep(3000);
95
-
96
- const unique = [...new Set(allUrls)];
97
- console.log(` [4/6] 共检测到 ${unique.length} 个不重复视频`);
98
-
99
- const results = [];
100
- const seen = new Set();
101
- for (const url of unique) {
102
- if (results.length >= count) break;
103
- const videoId = url.match(/video\/(\d{16,20})$/)?.[1];
104
- if (videoId && !seen.has(videoId)) {
105
- seen.add(videoId);
106
- const user = url.match(/\/@([^/]+)/)?.[1];
107
- if (user) {
108
- results.push({ user, id: videoId, url });
109
- }
110
- }
111
- }
112
-
113
- console.log(` [5/6] 去重后 ${results.length} 个`);
114
- return results;
115
- } finally {
116
- await instance.close();
117
- }
118
- }
1
+ import { chromium } from 'playwright';
2
+ import { browser, saveBrowser, configPath } from './constants.js';
3
+ import { detectBrowser } from './browser/launch.js';
4
+ import { getAntiDetectScript } from './browser/anti-detect.js';
5
+ import { retryWithBackoff } from './retry.js';
6
+ import { scrollAndCollect } from './scroll-collector.js';
7
+
8
+ const EXPLORE_URL = 'https://www.tiktok.com/explore';
9
+
10
+ function sleep(ms) {
11
+ return new Promise(r => setTimeout(r, ms));
12
+ }
13
+
14
+ export async function fetchExplore(count = 100) {
15
+ let browserPath = browser;
16
+ let browserSource = '配置';
17
+
18
+ if (!browserPath) {
19
+ console.log(' [0/6] 未配置浏览器,正在自动探测...');
20
+ const detected = detectBrowser();
21
+ if (detected) {
22
+ browserPath = detected;
23
+ browserSource = '自动探测';
24
+ try {
25
+ saveBrowser(browserPath);
26
+ console.log(` [0/6] 已保存浏览器路径到配置: ${configPath}`);
27
+ } catch (err) {
28
+ console.log(` [0/6] 保存配置失败: ${err.message}`);
29
+ }
30
+ }
31
+ }
32
+
33
+ const launchOptions = {
34
+ headless: true,
35
+ args: [
36
+ '--no-sandbox',
37
+ '--disable-setuid-sandbox',
38
+ '--disable-blink-features=AutomationControlled',
39
+ '--disable-dev-shm-usage',
40
+ ],
41
+ };
42
+
43
+ if (browserPath) {
44
+ console.log(` [0/6] 使用${browserSource}浏览器: ${browserPath}`);
45
+ launchOptions.executablePath = browserPath;
46
+ }
47
+
48
+ let instance;
49
+ try {
50
+ instance = await chromium.launch(launchOptions);
51
+ } catch (err) {
52
+ if (browserPath) {
53
+ console.log(` [0/6] 浏览器启动失败 (${err.message}),回退到 Playwright Chromium...`);
54
+ }
55
+ instance = await chromium.launch({
56
+ headless: true,
57
+ args: launchOptions.args,
58
+ });
59
+ }
60
+
61
+ try {
62
+ const context = await instance.newContext({
63
+ viewport: { width: 1280, height: 900 },
64
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
65
+ locale: 'en-US',
66
+ });
67
+
68
+ await context.addInitScript(getAntiDetectScript());
69
+
70
+ const page = await context.newPage();
71
+ await retryWithBackoff(() => page.goto(EXPLORE_URL, { waitUntil: 'load', timeout: 30000 }));
72
+ console.log(' [1/6] 页面已加载');
73
+
74
+ await sleep(5000);
75
+
76
+ const allUrls = await scrollAndCollect(page, {
77
+ container: null,
78
+ collectFn: () => ({
79
+ items: Array.from(document.querySelectorAll('a'))
80
+ .filter(a => /\/video\/\d{16,20}/.test(a.href))
81
+ .map(a => a.href),
82
+ }),
83
+ maxItems: count * 2,
84
+ delayRange: [1500, 2500],
85
+ staleThreshold: 5,
86
+ onRound: (round, items, allItems) => {
87
+ if ((round + 1) % 10 === 0) {
88
+ const uniqueCount = [...new Set(allItems)].length;
89
+ console.log(` [2/6] 滚动 ${round + 1},当前 ${uniqueCount} 个视频`);
90
+ }
91
+ },
92
+ });
93
+
94
+ await sleep(3000);
95
+
96
+ const unique = [...new Set(allUrls)];
97
+ console.log(` [4/6] 共检测到 ${unique.length} 个不重复视频`);
98
+
99
+ const results = [];
100
+ const seen = new Set();
101
+ for (const url of unique) {
102
+ if (results.length >= count) break;
103
+ const videoId = url.match(/video\/(\d{16,20})$/)?.[1];
104
+ if (videoId && !seen.has(videoId)) {
105
+ seen.add(videoId);
106
+ const user = url.match(/\/@([^/]+)/)?.[1];
107
+ if (user) {
108
+ results.push({ user, id: videoId, url });
109
+ }
110
+ }
111
+ }
112
+
113
+ console.log(` [5/6] 去重后 ${results.length} 个`);
114
+ return results;
115
+ } finally {
116
+ await instance.close();
117
+ }
118
+ }
@@ -1,45 +1,45 @@
1
- import { fetch, ProxyAgent } from 'undici';
2
- import { DEFAULT_PROXY } from './constants.js';
3
- import { isProfileUrl } from './url.js';
4
-
5
- const HEADERS = {
6
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
7
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
8
- 'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
9
- 'Accept-Encoding': 'gzip, deflate, br',
10
- 'Connection': 'keep-alive',
11
- 'Upgrade-Insecure-Requests': '1',
12
- 'Sec-Fetch-Dest': 'document',
13
- 'Sec-Fetch-Mode': 'navigate',
14
- 'Sec-Fetch-Site': 'none',
15
- 'Sec-Fetch-User': '?1',
16
- 'Cache-Control': 'max-age=0',
17
- };
18
-
19
- export { isProfileUrl } from './url.js';
20
-
21
- export async function fetchHtml(url, proxyUrl) {
22
- const p = proxyUrl || DEFAULT_PROXY;
23
- const agent = new ProxyAgent(p);
24
- let lastError;
25
-
26
- for (let attempt = 1; attempt <= 3; attempt++) {
27
- try {
28
- const res = await fetch(url, {
29
- headers: HEADERS,
30
- dispatcher: agent,
31
- redirect: 'follow',
32
- });
33
- const html = await res.text();
34
- return html;
35
- } catch (err) {
36
- lastError = err;
37
- if (attempt < 3) {
38
- const waitMs = Math.pow(2, attempt - 1) * 3000 + Math.random() * 2000;
39
- await new Promise(r => setTimeout(r, waitMs));
40
- }
41
- }
42
- }
43
-
44
- throw new Error(`请求 ${url} 失败(已重试 3 次),代理 ${p} 不可用`);
45
- }
1
+ import { fetch, ProxyAgent } from 'undici';
2
+ import { DEFAULT_PROXY } from './constants.js';
3
+ import { isProfileUrl } from './url.js';
4
+
5
+ const HEADERS = {
6
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
7
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
8
+ 'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
9
+ 'Accept-Encoding': 'gzip, deflate, br',
10
+ 'Connection': 'keep-alive',
11
+ 'Upgrade-Insecure-Requests': '1',
12
+ 'Sec-Fetch-Dest': 'document',
13
+ 'Sec-Fetch-Mode': 'navigate',
14
+ 'Sec-Fetch-Site': 'none',
15
+ 'Sec-Fetch-User': '?1',
16
+ 'Cache-Control': 'max-age=0',
17
+ };
18
+
19
+ export { isProfileUrl } from './url.js';
20
+
21
+ export async function fetchHtml(url, proxyUrl) {
22
+ const p = proxyUrl || DEFAULT_PROXY;
23
+ const agent = new ProxyAgent(p);
24
+ let lastError;
25
+
26
+ for (let attempt = 1; attempt <= 3; attempt++) {
27
+ try {
28
+ const res = await fetch(url, {
29
+ headers: HEADERS,
30
+ dispatcher: agent,
31
+ redirect: 'follow',
32
+ });
33
+ const html = await res.text();
34
+ return html;
35
+ } catch (err) {
36
+ lastError = err;
37
+ if (attempt < 3) {
38
+ const waitMs = Math.pow(2, attempt - 1) * 3000 + Math.random() * 2000;
39
+ await new Promise(r => setTimeout(r, waitMs));
40
+ }
41
+ }
42
+ }
43
+
44
+ throw new Error(`请求 ${url} 失败(已重试 3 次),代理 ${p} 不可用`);
45
+ }
package/src/lib/filter.js CHANGED
@@ -1,66 +1,66 @@
1
- export function parseFilter(filterStr) {
2
- if (!filterStr) return null;
3
-
4
- const filter = {};
5
- const pairs = filterStr.split('&');
6
-
7
- for (const pair of pairs) {
8
- const [key, value] = pair.split('=');
9
- if (!key || value === undefined) continue;
10
-
11
- const trimmedKey = key.trim();
12
- const trimmedValue = value.trim();
13
-
14
- // 处理布尔值
15
- if (trimmedValue === 'true') {
16
- filter[trimmedKey] = true;
17
- } else if (trimmedValue === 'false') {
18
- filter[trimmedKey] = false;
19
- } else {
20
- // 支持逗号分隔的多个值(如 locationCreated=DE,ES)
21
- filter[trimmedKey] = trimmedValue.split(',').map(v => v.trim());
22
- }
23
- }
24
-
25
- return Object.keys(filter).length > 0 ? filter : null;
26
- }
27
-
28
- export function applyFilter(results, filter) {
29
- if (!filter || results.length === 0) return results;
30
-
31
- return results.filter(item => {
32
- for (const [key, expectedValue] of Object.entries(filter)) {
33
- const actualValue = item[key];
34
-
35
- // 如果字段不存在,过滤掉
36
- if (actualValue === undefined || actualValue === null) {
37
- return false;
38
- }
39
-
40
- // 数组值匹配(如 locationCreated=DE,ES)
41
- if (Array.isArray(expectedValue)) {
42
- if (!expectedValue.includes(String(actualValue))) {
43
- return false;
44
- }
45
- }
46
- // 布尔值或精确匹配
47
- else if (actualValue !== expectedValue) {
48
- return false;
49
- }
50
- }
51
- return true;
52
- });
53
- }
54
-
55
- export function formatFilterDescription(filter) {
56
- if (!filter) return '';
57
-
58
- const parts = Object.entries(filter).map(([key, value]) => {
59
- if (Array.isArray(value)) {
60
- return `${key}=${value.join(',')}`;
61
- }
62
- return `${key}=${value}`;
63
- });
64
-
65
- return parts.join(' & ');
66
- }
1
+ export function parseFilter(filterStr) {
2
+ if (!filterStr) return null;
3
+
4
+ const filter = {};
5
+ const pairs = filterStr.split('&');
6
+
7
+ for (const pair of pairs) {
8
+ const [key, value] = pair.split('=');
9
+ if (!key || value === undefined) continue;
10
+
11
+ const trimmedKey = key.trim();
12
+ const trimmedValue = value.trim();
13
+
14
+ // 处理布尔值
15
+ if (trimmedValue === 'true') {
16
+ filter[trimmedKey] = true;
17
+ } else if (trimmedValue === 'false') {
18
+ filter[trimmedKey] = false;
19
+ } else {
20
+ // 支持逗号分隔的多个值(如 locationCreated=DE,ES)
21
+ filter[trimmedKey] = trimmedValue.split(',').map(v => v.trim());
22
+ }
23
+ }
24
+
25
+ return Object.keys(filter).length > 0 ? filter : null;
26
+ }
27
+
28
+ export function applyFilter(results, filter) {
29
+ if (!filter || results.length === 0) return results;
30
+
31
+ return results.filter(item => {
32
+ for (const [key, expectedValue] of Object.entries(filter)) {
33
+ const actualValue = item[key];
34
+
35
+ // 如果字段不存在,过滤掉
36
+ if (actualValue === undefined || actualValue === null) {
37
+ return false;
38
+ }
39
+
40
+ // 数组值匹配(如 locationCreated=DE,ES)
41
+ if (Array.isArray(expectedValue)) {
42
+ if (!expectedValue.includes(String(actualValue))) {
43
+ return false;
44
+ }
45
+ }
46
+ // 布尔值或精确匹配
47
+ else if (actualValue !== expectedValue) {
48
+ return false;
49
+ }
50
+ }
51
+ return true;
52
+ });
53
+ }
54
+
55
+ export function formatFilterDescription(filter) {
56
+ if (!filter) return '';
57
+
58
+ const parts = Object.entries(filter).map(([key, value]) => {
59
+ if (Array.isArray(value)) {
60
+ return `${key}=${value.join(',')}`;
61
+ }
62
+ return `${key}=${value}`;
63
+ });
64
+
65
+ return parts.join(' & ');
66
+ }
package/src/lib/io.js CHANGED
@@ -1,54 +1,54 @@
1
- import { extractDisplayPath } from './url.js';
2
-
3
- let lastBarCount = 0;
4
-
5
- export function createProgressBar(current, total, maxWidth = 30) {
6
- const filled = Math.round((current / total) * maxWidth);
7
- return '█'.repeat(filled).padEnd(maxWidth);
8
- }
9
-
10
- export function calculateConcurrency(total) {
11
- return Math.min(5, Math.max(1, Math.floor(total / 10)), total);
12
- }
13
-
14
- export function createMultiProgressBars(count) {
15
- return Array.from({ length: count }, () => ({
16
- current: 0,
17
- total: 0,
18
- status: 'pending',
19
- url: '',
20
- }));
21
- }
22
-
23
- export function renderMultiProgressBars(bars, maxWidth = 30) {
24
- const activeBars = bars.filter(bar => bar.total > 0);
25
-
26
- if (activeBars.length === 0) return;
27
-
28
- const lines = activeBars.map((bar) => {
29
- const prog = createProgressBar(bar.current, bar.total, maxWidth);
30
- const icon = bar.status === 'done' ? '✓' :
31
- bar.status === 'error' ? '' : '⟳';
32
- const urlDisplay = bar.url ? extractDisplayPath(bar.url) : '';
33
- return ` [${prog}] ${bar.current}/${bar.total} ${icon} ${urlDisplay}`;
34
- });
35
-
36
- const output = lines.join('\n');
37
-
38
- if (lastBarCount > 0) {
39
- process.stdout.write(`\x1b[${lastBarCount}A`);
40
- }
41
-
42
- process.stdout.write('\x1b[0J');
43
- process.stdout.write(output + '\n');
44
-
45
- lastBarCount = activeBars.length;
46
- }
47
-
48
- export function clearProgressBars() {
49
- if (lastBarCount > 0) {
50
- process.stdout.write(`\x1b[${lastBarCount}A`);
51
- process.stdout.write('\x1b[0J');
52
- lastBarCount = 0;
53
- }
54
- }
1
+ import { extractDisplayPath } from './url.js';
2
+
3
+ let lastBarCount = 0;
4
+
5
+ export function createProgressBar(current, total, maxWidth = 30) {
6
+ const filled = Math.round((current / total) * maxWidth);
7
+ return '█'.repeat(filled).padEnd(maxWidth);
8
+ }
9
+
10
+ export function calculateConcurrency(total) {
11
+ return Math.min(5, Math.max(1, Math.floor(total / 10)), total);
12
+ }
13
+
14
+ export function createMultiProgressBars(count) {
15
+ return Array.from({ length: count }, () => ({
16
+ current: 0,
17
+ total: 0,
18
+ status: 'pending',
19
+ url: '',
20
+ }));
21
+ }
22
+
23
+ export function renderMultiProgressBars(bars, maxWidth = 30) {
24
+ const activeBars = bars.filter(bar => bar.total > 0);
25
+
26
+ if (activeBars.length === 0) return;
27
+
28
+ const lines = activeBars.map((bar) => {
29
+ const prog = createProgressBar(bar.current, bar.total, maxWidth);
30
+ const icon = bar.status === 'done' ? '✓' :
31
+ bar.status === 'error' ? '' : '⟳';
32
+ const urlDisplay = bar.url ? extractDisplayPath(bar.url) : '';
33
+ return ` [${prog}] ${bar.current}/${bar.total} ${icon} ${urlDisplay}`;
34
+ });
35
+
36
+ const output = lines.join('\n');
37
+
38
+ if (lastBarCount > 0) {
39
+ process.stdout.write(`\x1b[${lastBarCount}A`);
40
+ }
41
+
42
+ process.stdout.write('\x1b[0J');
43
+ process.stdout.write(output + '\n');
44
+
45
+ lastBarCount = activeBars.length;
46
+ }
47
+
48
+ export function clearProgressBars() {
49
+ if (lastBarCount > 0) {
50
+ process.stdout.write(`\x1b[${lastBarCount}A`);
51
+ process.stdout.write('\x1b[0J');
52
+ lastBarCount = 0;
53
+ }
54
+ }