recker 1.0.8 → 1.0.10-alpha.646ad5f
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.
- package/dist/cli/handler.d.ts.map +1 -1
- package/dist/cli/handler.js +17 -3
- package/dist/cli/index.js +81 -2
- package/dist/cli/tui/shell.d.ts +26 -0
- package/dist/cli/tui/shell.d.ts.map +1 -1
- package/dist/cli/tui/shell.js +1226 -151
- package/dist/utils/whois.d.ts.map +1 -1
- package/dist/utils/whois.js +17 -2
- package/package.json +4 -7
- package/dist/plugins/rate-limit.d.ts +0 -8
- package/dist/plugins/rate-limit.d.ts.map +0 -1
- package/dist/plugins/rate-limit.js +0 -57
- package/dist/utils/logger.d.ts +0 -33
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -160
- package/dist/utils/status-codes.d.ts +0 -84
- package/dist/utils/status-codes.d.ts.map +0 -1
- package/dist/utils/status-codes.js +0 -204
- package/dist/utils/task-pool.d.ts +0 -38
- package/dist/utils/task-pool.js +0 -104
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface TaskPoolOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Max concurrent tasks allowed to execute at once.
|
|
4
|
-
* @default Infinity (no concurrency cap)
|
|
5
|
-
*/
|
|
6
|
-
concurrency?: number;
|
|
7
|
-
/**
|
|
8
|
-
* Requests allowed per interval window.
|
|
9
|
-
* When provided with `interval`, starts will be spaced to respect the cap.
|
|
10
|
-
*/
|
|
11
|
-
requestsPerInterval?: number;
|
|
12
|
-
/**
|
|
13
|
-
* Interval window length in milliseconds.
|
|
14
|
-
*/
|
|
15
|
-
interval?: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Lightweight TaskPool for rate limiting and concurrency control.
|
|
19
|
-
*
|
|
20
|
-
* - Limits concurrent executions.
|
|
21
|
-
* - Enforces a max start rate (`requestsPerInterval` / `interval`) via a sliding window.
|
|
22
|
-
* - Respects AbortSignal both while queued and while running.
|
|
23
|
-
*/
|
|
24
|
-
export declare class TaskPool {
|
|
25
|
-
private readonly concurrency;
|
|
26
|
-
private readonly requestsPerInterval?;
|
|
27
|
-
private readonly interval?;
|
|
28
|
-
private queue;
|
|
29
|
-
private active;
|
|
30
|
-
private windowStart;
|
|
31
|
-
private startedInWindow;
|
|
32
|
-
private waitingTimer?;
|
|
33
|
-
constructor(options?: TaskPoolOptions);
|
|
34
|
-
run<T>(fn: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
35
|
-
private _removeFromQueue;
|
|
36
|
-
private _canStart;
|
|
37
|
-
private _schedule;
|
|
38
|
-
}
|
package/dist/utils/task-pool.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight TaskPool for rate limiting and concurrency control.
|
|
3
|
-
*
|
|
4
|
-
* - Limits concurrent executions.
|
|
5
|
-
* - Enforces a max start rate (`requestsPerInterval` / `interval`) via a sliding window.
|
|
6
|
-
* - Respects AbortSignal both while queued and while running.
|
|
7
|
-
*/
|
|
8
|
-
export class TaskPool {
|
|
9
|
-
concurrency;
|
|
10
|
-
requestsPerInterval;
|
|
11
|
-
interval;
|
|
12
|
-
queue = [];
|
|
13
|
-
active = 0;
|
|
14
|
-
windowStart = 0;
|
|
15
|
-
startedInWindow = 0;
|
|
16
|
-
waitingTimer;
|
|
17
|
-
constructor(options = {}) {
|
|
18
|
-
this.concurrency = options.concurrency ?? Number.POSITIVE_INFINITY;
|
|
19
|
-
this.requestsPerInterval = options.requestsPerInterval;
|
|
20
|
-
this.interval = options.interval;
|
|
21
|
-
}
|
|
22
|
-
run(fn, signal) {
|
|
23
|
-
if (signal?.aborted) {
|
|
24
|
-
return Promise.reject(signal.reason ?? new Error('Task aborted before enqueue'));
|
|
25
|
-
}
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
const task = { fn, resolve, reject, signal };
|
|
28
|
-
if (signal) {
|
|
29
|
-
const onAbort = () => {
|
|
30
|
-
this._removeFromQueue(task);
|
|
31
|
-
reject(signal.reason ?? new Error('Task aborted while queued'));
|
|
32
|
-
this._schedule();
|
|
33
|
-
};
|
|
34
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
35
|
-
task.abortCleanup = () => signal.removeEventListener('abort', onAbort);
|
|
36
|
-
}
|
|
37
|
-
this.queue.push(task);
|
|
38
|
-
this._schedule();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
_removeFromQueue(task) {
|
|
42
|
-
const index = this.queue.indexOf(task);
|
|
43
|
-
if (index >= 0) {
|
|
44
|
-
this.queue.splice(index, 1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
_canStart(now) {
|
|
48
|
-
if (this.active >= this.concurrency) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (this.requestsPerInterval == null || this.interval == null) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
if (now - this.windowStart >= this.interval) {
|
|
55
|
-
this.windowStart = now;
|
|
56
|
-
this.startedInWindow = 0;
|
|
57
|
-
}
|
|
58
|
-
if (this.startedInWindow < this.requestsPerInterval) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
_schedule() {
|
|
64
|
-
if (this.waitingTimer) {
|
|
65
|
-
// There's already a timer waiting for the next window; let it fire.
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const now = Date.now();
|
|
69
|
-
while (this.queue.length > 0 && this._canStart(Date.now())) {
|
|
70
|
-
const task = this.queue.shift();
|
|
71
|
-
if (task.signal?.aborted) {
|
|
72
|
-
task.abortCleanup?.();
|
|
73
|
-
task.reject(task.signal.reason ?? new Error('Task aborted while queued'));
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
this.active++;
|
|
77
|
-
this.startedInWindow++;
|
|
78
|
-
const clearAbort = task.abortCleanup;
|
|
79
|
-
if (clearAbort) {
|
|
80
|
-
clearAbort();
|
|
81
|
-
task.abortCleanup = undefined;
|
|
82
|
-
}
|
|
83
|
-
Promise.resolve()
|
|
84
|
-
.then(() => task.fn())
|
|
85
|
-
.then((result) => task.resolve(result))
|
|
86
|
-
.catch((error) => task.reject(error))
|
|
87
|
-
.finally(() => {
|
|
88
|
-
this.active--;
|
|
89
|
-
this._schedule();
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// If rate limit prevents starting now, schedule when the window resets
|
|
93
|
-
if (this.queue.length > 0 &&
|
|
94
|
-
this.requestsPerInterval != null &&
|
|
95
|
-
this.interval != null &&
|
|
96
|
-
!this._canStart(Date.now())) {
|
|
97
|
-
const wait = Math.max(0, this.windowStart + this.interval - Date.now());
|
|
98
|
-
this.waitingTimer = setTimeout(() => {
|
|
99
|
-
this.waitingTimer = undefined;
|
|
100
|
-
this._schedule();
|
|
101
|
-
}, wait);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|