effective-progress 0.3.0 → 0.4.1
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/README.md +39 -50
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/renderer.ts +1156 -201
- package/src/runtime.ts +88 -29
- package/src/theme.ts +87 -0
- package/src/types.ts +7 -4
- package/src/colors.ts +0 -30
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
<img alt="Showcase output" src="docs/images/showcase.gif" width="600" />
|
|
13
13
|
|
|
14
|
-
`effective-progress` is an [Effect](https://effect.website/)-first terminal progress library with:
|
|
14
|
+
`effective-progress` is an [Effect](https://effect.website/)-first terminal progress-bar library with:
|
|
15
15
|
|
|
16
|
-
- multiple progress bars
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
16
|
+
- multiple nested tree-like progress bars
|
|
17
|
+
- spinner support for “we have no idea how long this takes” work
|
|
18
|
+
- clean log rendering alongside progress output, so you can keep using `Console.log` / `Effect.logInfo` without wrecking the UI
|
|
19
|
+
- familiar `.all` and `.forEach` APIs — swap `Effect` for `Progress`, get progress bars basically for free
|
|
20
|
+
- flicker-free rendering (in theory) by drawing everything in a single terminal frame
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
@@ -83,6 +83,9 @@ Effect.runPromise(program);
|
|
|
83
83
|
- `examples/advancedExample.ts` - full API usage with custom config and manual task control
|
|
84
84
|
- `examples/showcase.ts` - nested concurrent tasks, spinner workloads, and mixed Effect/Console logging
|
|
85
85
|
- `examples/performance.ts` - stress-style run with high log volume and deeply nested progress updates
|
|
86
|
+
- `examples/themeDepthPalette.ts` - depth-aware nested theming via `Theme.depthPalette`
|
|
87
|
+
- `examples/twoLineWidthCap.ts` - two-line determinate layout with `maxTaskWidth` clamping
|
|
88
|
+
- `examples/customColorStage.ts` - override `ColorStage` to emit plain (no ANSI) frame output
|
|
86
89
|
|
|
87
90
|
## Log retention
|
|
88
91
|
|
|
@@ -94,6 +97,12 @@ Effect.runPromise(program);
|
|
|
94
97
|
|
|
95
98
|
Configure global renderer behavior once, and a global base progress bar style:
|
|
96
99
|
|
|
100
|
+
Defaults:
|
|
101
|
+
|
|
102
|
+
- determinate layout: `single-line`
|
|
103
|
+
- max task width cap: unset (uses terminal width)
|
|
104
|
+
- bar width: `40`
|
|
105
|
+
|
|
97
106
|
```ts
|
|
98
107
|
import { Effect } from "effect";
|
|
99
108
|
import * as Progress from "effective-progress";
|
|
@@ -168,13 +177,9 @@ const program = Progress.task(
|
|
|
168
177
|
);
|
|
169
178
|
```
|
|
170
179
|
|
|
171
|
-
##
|
|
172
|
-
|
|
173
|
-
Colors are configured through the `Colorizer` service. You can set a global colorizer, or provide per-task overrides using `Effect.provideService`.
|
|
174
|
-
|
|
175
|
-
### Global colorizer
|
|
180
|
+
## Themes and render stages
|
|
176
181
|
|
|
177
|
-
|
|
182
|
+
Coloring is configured through the `Theme` service.
|
|
178
183
|
|
|
179
184
|
```ts
|
|
180
185
|
import chalk from "chalk";
|
|
@@ -183,51 +188,35 @@ import * as Progress from "effective-progress";
|
|
|
183
188
|
|
|
184
189
|
const program = Progress.task(myEffect, { description: "Work" }).pipe(
|
|
185
190
|
Effect.provideService(
|
|
186
|
-
Progress.
|
|
187
|
-
Progress.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
Progress.Theme,
|
|
192
|
+
Progress.Theme.of({
|
|
193
|
+
styles: {
|
|
194
|
+
plain: (text) => text,
|
|
195
|
+
barFill: chalk.hex("#00b894"),
|
|
196
|
+
barEmpty: chalk.white.dim,
|
|
197
|
+
barBracket: chalk.rgb(180, 190, 210),
|
|
198
|
+
spinner: chalk.ansi256(214),
|
|
199
|
+
statusDone: chalk.greenBright,
|
|
200
|
+
statusFailed: chalk.redBright.bold,
|
|
201
|
+
text: chalk.white,
|
|
202
|
+
units: chalk.whiteBright.bold,
|
|
203
|
+
eta: chalk.gray,
|
|
204
|
+
elapsed: chalk.gray,
|
|
205
|
+
treeConnector: chalk.gray,
|
|
206
|
+
},
|
|
207
|
+
depthPalette: (depth, role) => (role === "text" && depth > 0 ? chalk.cyanBright : undefined),
|
|
195
208
|
}),
|
|
196
209
|
),
|
|
197
210
|
);
|
|
198
211
|
```
|
|
199
212
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
Wrap any effect with `Effect.provideService(Colorizer, ...)` to override colors for that task (and its children). The colorizer is captured at task-creation time, so each task can have its own colors:
|
|
203
|
-
|
|
204
|
-
```ts
|
|
205
|
-
Progress.forEach(
|
|
206
|
-
["fetch", "transform", "persist"],
|
|
207
|
-
(stage) => Effect.gen(function* () {
|
|
208
|
-
yield* Effect.sleep("500 millis");
|
|
209
|
-
return stage;
|
|
210
|
-
}),
|
|
211
|
-
{ description: "Worker pipeline" },
|
|
212
|
-
).pipe(
|
|
213
|
-
Effect.provideService(
|
|
214
|
-
Progress.Colorizer,
|
|
215
|
-
Progress.Colorizer.of({
|
|
216
|
-
fill: chalk.red,
|
|
217
|
-
empty: chalk.white.dim,
|
|
218
|
-
brackets: chalk.white.dim,
|
|
219
|
-
percent: chalk.white.bold,
|
|
220
|
-
spinner: chalk.magentaBright,
|
|
221
|
-
done: chalk.greenBright,
|
|
222
|
-
failed: chalk.redBright,
|
|
223
|
-
}),
|
|
224
|
-
),
|
|
225
|
-
);
|
|
226
|
-
```
|
|
213
|
+
Render internals are split into overrideable stages:
|
|
227
214
|
|
|
228
|
-
|
|
215
|
+
- `BuildStage`: logical rows/cells/segments
|
|
216
|
+
- `ShrinkStage`: width fitting/collapse
|
|
217
|
+
- `ColorStage`: role -> styled terminal strings
|
|
229
218
|
|
|
230
|
-
|
|
219
|
+
You can replace any stage with `Effect.provideService(...)` while keeping defaults for the rest.
|
|
231
220
|
|
|
232
221
|
## Dependencies & package size
|
|
233
222
|
|
package/package.json
CHANGED