effective-progress 0.3.0 → 0.4.0
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 +36 -50
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/renderer.ts +1157 -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
|
|
|
@@ -94,6 +94,12 @@ Effect.runPromise(program);
|
|
|
94
94
|
|
|
95
95
|
Configure global renderer behavior once, and a global base progress bar style:
|
|
96
96
|
|
|
97
|
+
Defaults:
|
|
98
|
+
|
|
99
|
+
- determinate layout: `single-line`
|
|
100
|
+
- max task width cap: unset (uses terminal width)
|
|
101
|
+
- bar width: `40`
|
|
102
|
+
|
|
97
103
|
```ts
|
|
98
104
|
import { Effect } from "effect";
|
|
99
105
|
import * as Progress from "effective-progress";
|
|
@@ -168,13 +174,9 @@ const program = Progress.task(
|
|
|
168
174
|
);
|
|
169
175
|
```
|
|
170
176
|
|
|
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
|
|
177
|
+
## Themes and render stages
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
Coloring is configured through the `Theme` service.
|
|
178
180
|
|
|
179
181
|
```ts
|
|
180
182
|
import chalk from "chalk";
|
|
@@ -183,51 +185,35 @@ import * as Progress from "effective-progress";
|
|
|
183
185
|
|
|
184
186
|
const program = Progress.task(myEffect, { description: "Work" }).pipe(
|
|
185
187
|
Effect.provideService(
|
|
186
|
-
Progress.
|
|
187
|
-
Progress.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
188
|
+
Progress.Theme,
|
|
189
|
+
Progress.Theme.of({
|
|
190
|
+
styles: {
|
|
191
|
+
plain: (text) => text,
|
|
192
|
+
barFill: chalk.hex("#00b894"),
|
|
193
|
+
barEmpty: chalk.white.dim,
|
|
194
|
+
barBracket: chalk.rgb(180, 190, 210),
|
|
195
|
+
spinner: chalk.ansi256(214),
|
|
196
|
+
statusDone: chalk.greenBright,
|
|
197
|
+
statusFailed: chalk.redBright.bold,
|
|
198
|
+
text: chalk.white,
|
|
199
|
+
units: chalk.whiteBright.bold,
|
|
200
|
+
eta: chalk.gray,
|
|
201
|
+
elapsed: chalk.gray,
|
|
202
|
+
treeConnector: chalk.gray,
|
|
203
|
+
},
|
|
204
|
+
depthPalette: (depth, role) => (role === "text" && depth > 0 ? chalk.cyanBright : undefined),
|
|
195
205
|
}),
|
|
196
206
|
),
|
|
197
207
|
);
|
|
198
208
|
```
|
|
199
209
|
|
|
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
|
-
```
|
|
210
|
+
Render internals are split into overrideable stages:
|
|
227
211
|
|
|
228
|
-
|
|
212
|
+
- `BuildStage`: logical rows/cells/segments
|
|
213
|
+
- `ShrinkStage`: width fitting/collapse
|
|
214
|
+
- `ColorStage`: role -> styled terminal strings
|
|
229
215
|
|
|
230
|
-
|
|
216
|
+
You can replace any stage with `Effect.provideService(...)` while keeping defaults for the rest.
|
|
231
217
|
|
|
232
218
|
## Dependencies & package size
|
|
233
219
|
|
package/package.json
CHANGED