effective-progress 0.5.4 → 0.6.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 +11 -19
- package/dist/index.d.mts +4 -6
- package/dist/index.mjs +1175 -620
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
- spinner support for “we have no idea how long this takes” work
|
|
18
18
|
- keep using `Console.log` / `Effect.logInfo` while progress rendering is active
|
|
19
19
|
- familiar `.all` and `.forEach` APIs — swap `Effect` for `Progress`, get progress bars basically for free
|
|
20
|
-
- flicker-free rendering (
|
|
20
|
+
- flicker-free rendering with [Ink](https://github.com/vadimdemedes/ink)
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ bun add effective-progress
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Iterate items with a single progress bar.
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
import { Console, Effect } from "effect";
|
|
@@ -50,13 +50,7 @@ Effect.runPromise(program);
|
|
|
50
50
|
|
|
51
51
|
### Nested example
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
bun examples/nesting.ts
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
This demonstrates nested multibar behavior where parent tasks each run their own child progress bars.
|
|
53
|
+
Nested progress bars with tree-style rendering that highlights parent tasks and their subtasks
|
|
60
54
|
|
|
61
55
|
```ts
|
|
62
56
|
import { Effect } from "effect";
|
|
@@ -81,10 +75,15 @@ Effect.runPromise(program);
|
|
|
81
75
|
|
|
82
76
|
### Effect.all modes
|
|
83
77
|
|
|
84
|
-
|
|
78
|
+
Support for `either`/`validate` modes of `Effect.all` and render the amount of sucesses/failures.
|
|
85
79
|
|
|
86
80
|
<img alt="Mixed outcomes modes output" src="docs/images/mixedOutcomes.gif" width="600" />
|
|
87
81
|
|
|
82
|
+
- `Progress.all` in default mode (`mode: "default"`) remains fail-fast.
|
|
83
|
+
- In fail-fast runs, unresolved units remain unprocessed.
|
|
84
|
+
- `mode: "either"` and `mode: "validate"` run all effects and keep mixed outcomes in the task counters.
|
|
85
|
+
- Mixed outcomes can still finalize as `done` when all units are accounted for.
|
|
86
|
+
|
|
88
87
|
### Other examples
|
|
89
88
|
|
|
90
89
|
- `examples/simpleExample.ts` - low-boilerplate real-world flow
|
|
@@ -112,13 +111,6 @@ We support the `either`/`validate` modes of `Effect.all` and render the amount o
|
|
|
112
111
|
- Layout uses a 100-column baseline and grows when content requires more space.
|
|
113
112
|
- On narrow terminals, layout compacts to fit available width and tree prefixes are suppressed when description space is too tight.
|
|
114
113
|
|
|
115
|
-
### Mixed outcomes and `mode`
|
|
116
|
-
|
|
117
|
-
- `Progress.all` in default mode (`mode: "default"`) remains fail-fast.
|
|
118
|
-
- In fail-fast runs, unresolved units remain unprocessed.
|
|
119
|
-
- `mode: "either"` and `mode: "validate"` run all effects and keep mixed outcomes in the task counters.
|
|
120
|
-
- Mixed outcomes can still finalize as `done` when all units are accounted for.
|
|
121
|
-
|
|
122
114
|
## Manual task control
|
|
123
115
|
|
|
124
116
|
For manual usage, `task` still provides the current `Task` context, while logs continue through your outer `Console`:
|
|
@@ -131,8 +123,8 @@ const program = Progress.task(
|
|
|
131
123
|
yield* Console.log("This log is handled by the outer Console", { taskId: currentTask });
|
|
132
124
|
|
|
133
125
|
// Manual determinate updates:
|
|
134
|
-
yield* progress.
|
|
135
|
-
yield* progress.
|
|
126
|
+
yield* progress.incrementSucceeded(currentTask, 3);
|
|
127
|
+
yield* progress.incrementFailed(currentTask, 1);
|
|
136
128
|
yield* Effect.sleep("1 second");
|
|
137
129
|
}),
|
|
138
130
|
{ description: "Manual task", total: 10 },
|
package/dist/index.d.mts
CHANGED
|
@@ -37,8 +37,6 @@ declare const DeterminateTaskUnits_base: Schema.TaggedClass<DeterminateTaskUnits
|
|
|
37
37
|
declare class DeterminateTaskUnits extends DeterminateTaskUnits_base {}
|
|
38
38
|
declare const IndeterminateTaskUnits_base: Schema.TaggedClass<IndeterminateTaskUnits, "IndeterminateTaskUnits", {
|
|
39
39
|
readonly _tag: Schema.tag<"IndeterminateTaskUnits">;
|
|
40
|
-
} & {
|
|
41
|
-
spinnerFrame: typeof Schema.Number;
|
|
42
40
|
}>;
|
|
43
41
|
declare class IndeterminateTaskUnits extends IndeterminateTaskUnits_base {}
|
|
44
42
|
declare const TaskUnitsSchema: Schema.Union<[typeof DeterminateTaskUnits, typeof IndeterminateTaskUnits]>;
|
|
@@ -68,8 +66,8 @@ interface TaskStore {
|
|
|
68
66
|
interface ProgressService {
|
|
69
67
|
readonly addTask: (options: AddTaskOptions) => Effect.Effect<TaskId>;
|
|
70
68
|
readonly updateTask: (taskId: TaskId, options: UpdateTaskOptions) => Effect.Effect<void>;
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
69
|
+
readonly incrementSucceeded: (taskId: TaskId, amount?: number) => Effect.Effect<void>;
|
|
70
|
+
readonly incrementFailed: (taskId: TaskId, amount?: number) => Effect.Effect<void>;
|
|
73
71
|
readonly completeTask: (taskId: TaskId) => Effect.Effect<void>;
|
|
74
72
|
readonly failTask: (taskId: TaskId) => Effect.Effect<void>;
|
|
75
73
|
readonly log: (...args: ReadonlyArray<unknown>) => Effect.Effect<void>;
|
|
@@ -140,7 +138,7 @@ declare const ProgressTaskEventSchema: Schema.Union<[typeof TaskAddedEvent, type
|
|
|
140
138
|
type ProgressTaskEvent = typeof ProgressTaskEventSchema.Type;
|
|
141
139
|
declare const decodeProgressTaskEvent: (u: unknown, overrideOptions?: effect_SchemaAST0.ParseOptions) => TaskAddedEvent | TaskUpdatedEvent | TaskAdvancedEvent | TaskCompletedEvent | TaskFailedEvent | TaskRemovedEvent;
|
|
142
140
|
//#endregion
|
|
143
|
-
//#region src/
|
|
141
|
+
//#region src/services/progress.d.ts
|
|
144
142
|
declare const Progress_base: Context.TagClass<Progress, "stromseng.dev/effective-progress/Progress", ProgressService>;
|
|
145
143
|
declare class Progress extends Progress_base {
|
|
146
144
|
static readonly Default: Layer.Layer<Progress, never, never>;
|
|
@@ -177,7 +175,7 @@ declare const forEach: {
|
|
|
177
175
|
<A, B, E, R>(f: (item: A, index: number) => Effect.Effect<B, E, R>, options: ForEachOptions): (iterable: Iterable<A>) => Effect.Effect<ReadonlyArray<B>, E, Exclude<R, Progress | Task>>;
|
|
178
176
|
};
|
|
179
177
|
//#endregion
|
|
180
|
-
//#region src/stdio.d.ts
|
|
178
|
+
//#region src/services/stdio.d.ts
|
|
181
179
|
interface ProgressStdioService {
|
|
182
180
|
readonly stdout: NodeJS.WriteStream;
|
|
183
181
|
readonly stderr: NodeJS.WriteStream;
|