@riboseinc/anafero-cli 0.0.32 → 0.0.34
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/CLI.tsx +12 -1
- package/build-site.mjs +8318 -8255
- package/dependencies.mts +4 -1
- package/package.json +2 -1
- package/{riboseinc-anafero-cli-0.0.32.tgz → riboseinc-anafero-cli-0.0.34.tgz} +0 -0
package/CLI.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { produce } from 'immer'
|
|
3
3
|
import { Text, Box, Static } from 'ink';
|
|
4
|
+
import { useThrottledCallback } from 'use-debounce';
|
|
4
5
|
import { Badge, ProgressBar, Spinner, StatusMessage } from '@inkjs/ui';
|
|
5
6
|
import { type Progress, type TaskProgressCallback, type TaskProgressCallbackReturnValue } from 'anafero/progress.mjs';
|
|
6
7
|
|
|
@@ -28,6 +29,8 @@ export const Processor: React.FC<ProcessorProps> = function({ rootTaskName, onSt
|
|
|
28
29
|
onStart({ onProgress: handleProgress });
|
|
29
30
|
}, []);
|
|
30
31
|
|
|
32
|
+
// TODO: Rewrite this to make throttling CLI progress updates easier?
|
|
33
|
+
|
|
31
34
|
function updateTask(taskPath: string, progress: Progress | null) {
|
|
32
35
|
const taskPathComponents = taskPath.split('|');
|
|
33
36
|
const taskName = taskPathComponents.pop()!;
|
|
@@ -56,11 +59,19 @@ export const Processor: React.FC<ProcessorProps> = function({ rootTaskName, onSt
|
|
|
56
59
|
}));
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
const updateTaskThrottled = useThrottledCallback(updateTask, 500, { leading: false, trailing: false });
|
|
63
|
+
|
|
59
64
|
function handleProgress(taskPath: string, progress?: Progress | null): TaskProgressCallbackReturnValue {
|
|
60
65
|
updateTask(taskPath, progress === undefined ? {} : progress);
|
|
61
66
|
return [
|
|
62
67
|
function handleSubsequentTaskProgress(progress: Progress | null) {
|
|
63
|
-
|
|
68
|
+
if (progress !== null) {
|
|
69
|
+
updateTaskThrottled(taskPath, progress);
|
|
70
|
+
} else {
|
|
71
|
+
// progress === null is a marker that task is completed,
|
|
72
|
+
// so we can’t throttle that (or it will left uncompleted in TUI)
|
|
73
|
+
updateTask(taskPath, progress);
|
|
74
|
+
}
|
|
64
75
|
},
|
|
65
76
|
function handleSubtask(subtaskRef: string, progress: Progress | null) {
|
|
66
77
|
return handleProgress(`${taskPath}|${subtaskRef}`, progress);
|