effective-progress 0.10.0 → 0.11.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 +120 -11
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/index.d.mts +179 -14
- package/dist/index.mjs +586 -608
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
> Pre-`1.0.0`, breaking changes may happen in any minor release. SemVer guarantees will begin at `1.0.0`.
|
|
7
7
|
> I recommend using only the `Progress.all` and `Progress.forEach` APIs for now, as they will likely change the least. The lower-level APIs for manual progress bar control are more likely to see breaking changes as I iterate on the design.
|
|
8
8
|
>
|
|
9
|
+
> I am currently waiting on https://github.com/anomalyco/opentui/issues/204 to swap the renderer to opentui.
|
|
10
|
+
>
|
|
9
11
|
> Please open an issue or reach out if you have any questions or want to contribute!
|
|
10
12
|
> Feedback and contributions are very welcome!
|
|
11
13
|
|
|
@@ -75,23 +77,59 @@ Effect.runPromise(program);
|
|
|
75
77
|
|
|
76
78
|
### Effect.all modes
|
|
77
79
|
|
|
78
|
-
Support for `either`/`validate` modes of `Effect.all` and render the amount of
|
|
80
|
+
Support for `either`/`validate` modes of `Effect.all` and render the amount of successes/failures.
|
|
79
81
|
|
|
80
82
|
<img alt="Mixed outcomes modes output" src="docs/images/mixedOutcomes.gif" width="600" />
|
|
81
83
|
|
|
82
84
|
- `Progress.all` in default mode (`mode: "default"`) remains fail-fast.
|
|
83
85
|
- In fail-fast runs, unresolved units remain unprocessed.
|
|
84
86
|
- `mode: "either"` and `mode: "validate"` run all effects and keep mixed outcomes in the task counters.
|
|
85
|
-
- Mixed outcomes can
|
|
87
|
+
- Mixed outcomes can finalize as `done` when all units are accounted for.
|
|
86
88
|
- Empty collections are valid inputs for `Progress.all` / `Progress.forEach` and render as `0/0` instead of failing.
|
|
87
89
|
|
|
90
|
+
### Single task with a typed handle
|
|
91
|
+
|
|
92
|
+
Use `Progress.task(...)` when you want one progress bar around a custom effect. The callback form gives you a task-local handle, so you can update counts, descriptions, and metadata without fetching the current task ID first.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { Console, Effect } from "effect";
|
|
96
|
+
import * as Progress from "effective-progress";
|
|
97
|
+
|
|
98
|
+
const program = Progress.task(
|
|
99
|
+
(task) =>
|
|
100
|
+
Effect.gen(function* () {
|
|
101
|
+
yield* Console.log("Starting deployment");
|
|
102
|
+
yield* task.incrementSucceeded();
|
|
103
|
+
yield* task.update({
|
|
104
|
+
description: "Uploading release bundle",
|
|
105
|
+
});
|
|
106
|
+
yield* Effect.sleep("1 second");
|
|
107
|
+
yield* task.incrementSucceeded(2);
|
|
108
|
+
}),
|
|
109
|
+
{
|
|
110
|
+
description: "Deploy release",
|
|
111
|
+
total: 3,
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
Effect.runPromise(program);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- The plain `Progress.task(effect, options)` form auto-finalizes from the effect exit.
|
|
119
|
+
- The callback form also auto-finalizes from the callback exit unless you explicitly `yield* task.complete` or `yield* task.fail` first.
|
|
120
|
+
- `yield* Progress.Task` exposes the current task ID when you need it.
|
|
121
|
+
|
|
88
122
|
### Other examples
|
|
89
123
|
|
|
90
124
|
- `examples/simpleExample.ts` - low-boilerplate real-world flow
|
|
91
|
-
- `examples/advancedExample.ts` -
|
|
125
|
+
- `examples/advancedExample.ts` - mixed high-level and low-level Progress service usage
|
|
126
|
+
- `examples/basic.ts` - minimal `Progress.all` usage
|
|
127
|
+
- `examples/nesting.ts` - nested tree rendering with parent and child tasks
|
|
92
128
|
- `examples/mixedOutcomes.ts` - fail-fast vs `either`/`validate` with mixed success/failure counters
|
|
93
129
|
- `examples/cliProgressSemantics.ts` - zero totals, negative totals clearing to unknown totals, overflow counts, and empty `all` / `forEach`
|
|
94
130
|
- `examples/unknownTotalCounting.ts` - count successes/failures without a known total and render `processed/?`
|
|
131
|
+
- `examples/typedMetadata.ts` - typed task metadata rendered through custom columns
|
|
132
|
+
- `examples/mixedNestedColumns.ts` - different column sets aligned across mixed task types
|
|
95
133
|
- `examples/showcase.ts` - nested concurrent tasks, spinner workloads, and mixed Effect/Console logging
|
|
96
134
|
- `examples/performance.ts` - stress-style run with high log volume and deeply nested progress updates
|
|
97
135
|
- `examples/performanceLong.ts` - longer-running stress run with roughly 10x the work of `performance.ts`
|
|
@@ -109,21 +147,42 @@ Support for `either`/`validate` modes of `Effect.all` and render the amount of s
|
|
|
109
147
|
### Ink renderer behavior
|
|
110
148
|
|
|
111
149
|
- Rendering is powered by [Ink](https://github.com/vadimdemedes/ink).
|
|
112
|
-
- Built-in columns are
|
|
150
|
+
- Built-in columns are exposed as `Progress.Columns.description()`, `bar()`, `amount()`, `elapsedEta()`, `elapsed()`, `eta()`, `spacer()`, and `defaults()`.
|
|
151
|
+
- `elapsedEta()` renders a compact clock-style column as `elapsed<eta` using the shape `00:00<00:00`; `defaults()` now uses that combined column.
|
|
113
152
|
- Determinate bars are segmented by outcome: succeeded (green), failed (red), and remaining (neutral).
|
|
153
|
+
- `bar()` defaults to a fixed width of `30`; pass `bar({ size: "fullwidth" })` to consume remaining row width or `bar({ size: 12 })` for an explicit width.
|
|
114
154
|
- Determinate amount text shows counters without prefixes: `<succeeded> <failed> <processed>/<total>`.
|
|
115
155
|
- Counts can exceed `total`; the amount text keeps those raw values (for example `12/10`) while the bar stays visually clamped at full.
|
|
116
156
|
- `total: 0` is valid for determinate tasks and renders as a full bar by default.
|
|
117
|
-
- Column widths are
|
|
118
|
-
-
|
|
119
|
-
- Sticky width can keep selected columns stable until the frame empties.
|
|
157
|
+
- Column widths are resolved per visual column index, so rows with different column definitions can still align with each other.
|
|
158
|
+
- Column `prepare(...)` functions can compute shared layout data once for all rows using the same column definition at a given index.
|
|
120
159
|
- On narrow terminals, layout compacts to fit available width and tree prefixes are suppressed when description space is too tight.
|
|
121
160
|
|
|
122
|
-
##
|
|
161
|
+
## Task API
|
|
162
|
+
|
|
163
|
+
`Progress.task(...)` supports two styles:
|
|
164
|
+
|
|
165
|
+
- `Progress.task(effect, options)` for the simple "wrap this effect in a task" case.
|
|
166
|
+
- `Progress.task((task) => effect, options)` when you want a typed handle for task-local control.
|
|
167
|
+
|
|
168
|
+
The handle exposes:
|
|
123
169
|
|
|
124
|
-
|
|
170
|
+
- `incrementSucceeded(amount?)`
|
|
171
|
+
- `incrementFailed(amount?)`
|
|
172
|
+
- `update({ description, total, countDisplay, transient, succeeded, failed })`
|
|
173
|
+
- `getMetadata`, `setMetadata`, `updateMetadata`
|
|
174
|
+
- `getSnapshot`
|
|
175
|
+
- `complete`
|
|
176
|
+
- `fail`
|
|
177
|
+
|
|
178
|
+
When you need lower-level control, the `Progress` service is available inside the effect and exposes APIs like `addTask`, `updateTask`, `incrementSucceeded(taskId, amount)`, and `completeTask(taskId)`.
|
|
179
|
+
|
|
180
|
+
Example using the lower-level service API:
|
|
125
181
|
|
|
126
182
|
```ts
|
|
183
|
+
import { Console, Effect } from "effect";
|
|
184
|
+
import * as Progress from "effective-progress";
|
|
185
|
+
|
|
127
186
|
const program = Progress.task(
|
|
128
187
|
Effect.gen(function* () {
|
|
129
188
|
const progress = yield* Progress.Progress;
|
|
@@ -145,9 +204,59 @@ Manual total behavior:
|
|
|
145
204
|
- negative totals on later `updateTask` calls also clear the total
|
|
146
205
|
- explicit `total: undefined` on `updateTask` clears the total and switches back to indeterminate rendering
|
|
147
206
|
|
|
148
|
-
##
|
|
207
|
+
## Typed metadata and custom columns
|
|
208
|
+
|
|
209
|
+
Tasks can carry typed metadata, and that metadata type flows into custom column renderers.
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { Effect } from "effect";
|
|
213
|
+
import * as Progress from "effective-progress";
|
|
214
|
+
|
|
215
|
+
interface EvalMeta {
|
|
216
|
+
readonly model: string;
|
|
217
|
+
readonly score: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const scoreColumn = (): Progress.ColumnDef<EvalMeta> => ({
|
|
221
|
+
align: "right",
|
|
222
|
+
flexShrink: 0,
|
|
223
|
+
minWidth: 5,
|
|
224
|
+
render: ({ task }) => `${task.metadata.score}%`,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const program = Progress.task(
|
|
228
|
+
(task) =>
|
|
229
|
+
Effect.gen(function* () {
|
|
230
|
+
yield* task.setMetadata({ model: "gpt-5.4", score: 91 });
|
|
231
|
+
yield* task.incrementSucceeded();
|
|
232
|
+
}),
|
|
233
|
+
{
|
|
234
|
+
description: "Run evaluation",
|
|
235
|
+
total: 1,
|
|
236
|
+
metadata: { model: "gpt-5.4", score: 0 },
|
|
237
|
+
columns: [
|
|
238
|
+
Progress.Columns.description(),
|
|
239
|
+
Progress.Columns.bar(),
|
|
240
|
+
{
|
|
241
|
+
flexShrink: 0,
|
|
242
|
+
minWidth: 10,
|
|
243
|
+
render: ({ task }) => task.metadata.model,
|
|
244
|
+
},
|
|
245
|
+
scoreColumn(),
|
|
246
|
+
Progress.Columns.elapsed(),
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`ColumnDef<M, P>` supports:
|
|
253
|
+
|
|
254
|
+
- `prepare(rows)` to derive shared data for all matching rows at that column index
|
|
255
|
+
- `render(cell, ctx)` to render the cell
|
|
256
|
+
- sizing hints with `flexGrow`, `flexShrink`, `flexBasis`, and `minWidth`
|
|
257
|
+
- `align` with `"left"`, `"center"`, or `"right"`
|
|
149
258
|
|
|
150
|
-
|
|
259
|
+
If a task does not provide `columns`, the renderer falls back to `Progress.Columns.defaults()`.
|
|
151
260
|
|
|
152
261
|
## Notes
|
|
153
262
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Brand, Context, Effect, Layer, Option, Schema } from "effect";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import "react/jsx-runtime";
|
|
4
|
+
import "cli-spinners";
|
|
2
5
|
import { Concurrency } from "effect/Types";
|
|
3
6
|
import * as effect_SchemaAST0 from "effect/SchemaAST";
|
|
4
7
|
|
|
@@ -10,12 +13,84 @@ declare const TaskStatusSchema: Schema.Literal<["running", "done", "failed"]>;
|
|
|
10
13
|
type TaskStatus = typeof TaskStatusSchema.Type;
|
|
11
14
|
declare const TaskCountDisplaySchema: Schema.Literal<["processedOnly", "detailed"]>;
|
|
12
15
|
type TaskCountDisplay = typeof TaskCountDisplaySchema.Type;
|
|
13
|
-
|
|
16
|
+
type ColumnAlign = "left" | "center" | "right";
|
|
17
|
+
interface TaskTreeInfo {
|
|
18
|
+
readonly depth: number;
|
|
19
|
+
readonly hasNextSibling: boolean;
|
|
20
|
+
readonly hasChildren: boolean;
|
|
21
|
+
readonly ancestorHasNextSibling: ReadonlyArray<boolean>;
|
|
22
|
+
}
|
|
23
|
+
interface TaskRowDerived {
|
|
24
|
+
readonly treePrefix: string;
|
|
25
|
+
readonly treePrefixWidth: number;
|
|
26
|
+
readonly descriptionWidth: number;
|
|
27
|
+
readonly treePrefixedDescriptionWidth: number;
|
|
28
|
+
readonly hasRenderableProgress: boolean;
|
|
29
|
+
readonly isDeterminate: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** All data available to a column cell. */
|
|
32
|
+
interface CellInfo<M = unknown> {
|
|
33
|
+
readonly task: TaskSnapshot & {
|
|
34
|
+
readonly metadata: M;
|
|
35
|
+
};
|
|
36
|
+
readonly tree: TaskTreeInfo;
|
|
37
|
+
readonly derived: TaskRowDerived;
|
|
38
|
+
}
|
|
39
|
+
interface ColumnRenderContext<P = void> {
|
|
40
|
+
readonly width?: number;
|
|
41
|
+
readonly now: number;
|
|
42
|
+
readonly spinnerTick: number;
|
|
43
|
+
readonly prepared: P;
|
|
44
|
+
}
|
|
45
|
+
type ColumnSizeValue<P = void> = number | ((prepared: P) => number | undefined);
|
|
46
|
+
type BivariantCallback<Args extends ReadonlyArray<unknown>, R> = {
|
|
47
|
+
bivarianceHack: (...args: Args) => R;
|
|
48
|
+
}["bivarianceHack"];
|
|
49
|
+
interface ColumnDef<M = unknown, P = void> {
|
|
50
|
+
readonly prepare?: BivariantCallback<[rows: ReadonlyArray<CellInfo<M>>], P>;
|
|
51
|
+
readonly render: BivariantCallback<[cell: CellInfo<M>, ctx: ColumnRenderContext<P>], ReactNode>;
|
|
52
|
+
readonly align?: ColumnAlign;
|
|
53
|
+
readonly flexGrow?: ColumnSizeValue<P>;
|
|
54
|
+
readonly flexShrink?: ColumnSizeValue<P>;
|
|
55
|
+
readonly flexBasis?: ColumnSizeValue<P>;
|
|
56
|
+
readonly minWidth?: ColumnSizeValue<P>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A typed facade over a single task created through the callback form of `task(...)`.
|
|
60
|
+
*
|
|
61
|
+
* Use this handle to update counts, metadata, description, or to explicitly finalize the task
|
|
62
|
+
* before the callback exits. If the callback returns or fails while the task is still `running`,
|
|
63
|
+
* the library auto-finalizes it from the callback exit status instead.
|
|
64
|
+
*/
|
|
65
|
+
interface TaskHandle<M> {
|
|
66
|
+
readonly id: TaskId;
|
|
67
|
+
/** Reads the current metadata value for the task using the metadata type inferred at creation. */
|
|
68
|
+
readonly getMetadata: Effect.Effect<M>;
|
|
69
|
+
/** Replaces the task metadata. */
|
|
70
|
+
readonly setMetadata: (metadata: M) => Effect.Effect<void>;
|
|
71
|
+
/** Updates the current metadata value atomically. */
|
|
72
|
+
readonly updateMetadata: (f: (m: M) => M) => Effect.Effect<void>;
|
|
73
|
+
/** Increments the succeeded counter for the task. */
|
|
74
|
+
readonly incrementSucceeded: (amount?: number) => Effect.Effect<void>;
|
|
75
|
+
/** Increments the failed counter for the task. */
|
|
76
|
+
readonly incrementFailed: (amount?: number) => Effect.Effect<void>;
|
|
77
|
+
/** Updates mutable task fields such as description, totals, and count display. */
|
|
78
|
+
readonly update: (options: UpdateTaskOptions) => Effect.Effect<void>;
|
|
79
|
+
/** Marks the task as done immediately. Finalization is terminal once the task leaves `running`. */
|
|
80
|
+
readonly complete: Effect.Effect<void>;
|
|
81
|
+
/** Marks the task as failed immediately. Finalization is terminal once the task leaves `running`. */
|
|
82
|
+
readonly fail: Effect.Effect<void>;
|
|
83
|
+
/** Reads the latest task snapshot. */
|
|
84
|
+
readonly getSnapshot: Effect.Effect<TaskSnapshot>;
|
|
85
|
+
}
|
|
86
|
+
interface AddTaskOptions<M = void> {
|
|
14
87
|
readonly description: string;
|
|
15
88
|
readonly total?: number;
|
|
16
89
|
readonly transient?: boolean;
|
|
17
90
|
readonly parentId?: TaskId;
|
|
18
91
|
readonly countDisplay?: TaskCountDisplay;
|
|
92
|
+
readonly metadata?: M;
|
|
93
|
+
readonly columns?: ReadonlyArray<ColumnDef<M, any>>;
|
|
19
94
|
}
|
|
20
95
|
interface UpdateTaskOptions {
|
|
21
96
|
readonly description?: string;
|
|
@@ -25,7 +100,7 @@ interface UpdateTaskOptions {
|
|
|
25
100
|
readonly transient?: boolean;
|
|
26
101
|
readonly countDisplay?: TaskCountDisplay;
|
|
27
102
|
}
|
|
28
|
-
type TrackOptions =
|
|
103
|
+
type TrackOptions = Omit<AddTaskOptions, "parentId">;
|
|
29
104
|
declare const TaskUnitsSchema: Schema.Struct<{
|
|
30
105
|
succeeded: typeof Schema.Number;
|
|
31
106
|
failed: typeof Schema.Number;
|
|
@@ -33,6 +108,11 @@ declare const TaskUnitsSchema: Schema.Struct<{
|
|
|
33
108
|
total: Schema.optional<typeof Schema.Number>;
|
|
34
109
|
}>;
|
|
35
110
|
type TaskUnits = typeof TaskUnitsSchema.Type;
|
|
111
|
+
declare const TaskProgressSampleSchema: Schema.Struct<{
|
|
112
|
+
timestamp: typeof Schema.Number;
|
|
113
|
+
processed: typeof Schema.Number;
|
|
114
|
+
}>;
|
|
115
|
+
type TaskProgressSample = typeof TaskProgressSampleSchema.Type;
|
|
36
116
|
declare const TaskSnapshotSchema: Schema.Struct<{
|
|
37
117
|
id: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
38
118
|
parentId: Schema.NullOr<Schema.brand<typeof Schema.Number, "TaskId">>;
|
|
@@ -48,6 +128,11 @@ declare const TaskSnapshotSchema: Schema.Struct<{
|
|
|
48
128
|
}>;
|
|
49
129
|
startedAt: typeof Schema.Number;
|
|
50
130
|
completedAt: Schema.NullOr<typeof Schema.Number>;
|
|
131
|
+
progressSamples: Schema.Array$<Schema.Struct<{
|
|
132
|
+
timestamp: typeof Schema.Number;
|
|
133
|
+
processed: typeof Schema.Number;
|
|
134
|
+
}>>;
|
|
135
|
+
metadata: typeof Schema.Unknown;
|
|
51
136
|
}>;
|
|
52
137
|
type TaskSnapshot = typeof TaskSnapshotSchema.Type;
|
|
53
138
|
declare const TaskSnapshot: (snapshot: TaskSnapshot) => TaskSnapshot;
|
|
@@ -58,9 +143,10 @@ interface RenderRow {
|
|
|
58
143
|
interface TaskStore {
|
|
59
144
|
readonly tasks: Map<TaskId, TaskSnapshot>;
|
|
60
145
|
readonly renderOrder: ReadonlyArray<RenderRow>;
|
|
146
|
+
readonly columns: Map<TaskId, ReadonlyArray<ColumnDef<any, any>>>;
|
|
61
147
|
}
|
|
62
148
|
interface ProgressService {
|
|
63
|
-
readonly addTask: (options: AddTaskOptions) => Effect.Effect<TaskId>;
|
|
149
|
+
readonly addTask: (options: AddTaskOptions<any>) => Effect.Effect<TaskId>;
|
|
64
150
|
readonly updateTask: (taskId: TaskId, options: UpdateTaskOptions) => Effect.Effect<void>;
|
|
65
151
|
readonly incrementSucceeded: (taskId: TaskId, amount?: number) => Effect.Effect<void>;
|
|
66
152
|
readonly incrementFailed: (taskId: TaskId, amount?: number) => Effect.Effect<void>;
|
|
@@ -69,13 +155,24 @@ interface ProgressService {
|
|
|
69
155
|
readonly log: (...args: ReadonlyArray<unknown>) => Effect.Effect<void>;
|
|
70
156
|
readonly getTask: (taskId: TaskId) => Effect.Effect<Option.Option<TaskSnapshot>>;
|
|
71
157
|
readonly listTasks: Effect.Effect<ReadonlyArray<TaskSnapshot>>;
|
|
72
|
-
readonly
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
158
|
+
readonly setMetadata: (taskId: TaskId, metadata: unknown) => Effect.Effect<void>;
|
|
159
|
+
readonly getMetadata: (taskId: TaskId) => Effect.Effect<unknown>;
|
|
160
|
+
/**
|
|
161
|
+
* Runs an effect inside a newly created task scope.
|
|
162
|
+
*
|
|
163
|
+
* The plain effect form auto-finalizes from the effect exit if the task is still `running`.
|
|
164
|
+
* The callback form exposes a typed `TaskHandle` for metadata and explicit lifecycle control, and
|
|
165
|
+
* also auto-finalizes from the callback exit if the handle did not already finalize the task.
|
|
166
|
+
*
|
|
167
|
+
* Use `Progress.task(...)` from `src/api.ts` when you want the service to be created automatically if needed.
|
|
168
|
+
*/
|
|
169
|
+
readonly task: {
|
|
77
170
|
<A, E, R>(effect: Effect.Effect<A, E, R>, options: AddTaskOptions): Effect.Effect<A, E, Exclude<R, Task>>;
|
|
78
171
|
<A, E, R>(options: AddTaskOptions): (effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Task>>;
|
|
172
|
+
<A, E, R>(f: (handle: TaskHandle<void>) => Effect.Effect<A, E, R>, options: AddTaskOptions<void>): Effect.Effect<A, E, Exclude<R, Task>>;
|
|
173
|
+
<M, A, E, R>(f: (handle: TaskHandle<M>) => Effect.Effect<A, E, R>, options: AddTaskOptions<M> & {
|
|
174
|
+
readonly metadata: M;
|
|
175
|
+
}): Effect.Effect<A, E, Exclude<R, Task>>;
|
|
79
176
|
};
|
|
80
177
|
}
|
|
81
178
|
declare const Task_base: Context.TagClass<Task, "stromseng.dev/effective-progress/Task", number & Brand.Brand<"TaskId">>;
|
|
@@ -141,6 +238,14 @@ declare class Progress extends Progress_base {
|
|
|
141
238
|
}
|
|
142
239
|
//#endregion
|
|
143
240
|
//#region src/api.d.ts
|
|
241
|
+
interface PublicTaskApi {
|
|
242
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, options: AddTaskOptions): Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
243
|
+
<A, E, R>(options: AddTaskOptions): (effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
244
|
+
<A, E, R>(f: (handle: TaskHandle<void>) => Effect.Effect<A, E, R>, options: AddTaskOptions<void>): Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
245
|
+
<M, A, E, R>(f: (handle: TaskHandle<M>) => Effect.Effect<A, E, R>, options: AddTaskOptions<M> & {
|
|
246
|
+
readonly metadata: M;
|
|
247
|
+
}): Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
248
|
+
}
|
|
144
249
|
interface EffectExecutionOptions {
|
|
145
250
|
readonly concurrency?: Concurrency;
|
|
146
251
|
readonly batching?: boolean | "inherit";
|
|
@@ -156,21 +261,81 @@ interface ForEachExecutionOptions extends EffectExecutionOptions {
|
|
|
156
261
|
readonly discard?: false | undefined;
|
|
157
262
|
}
|
|
158
263
|
type ForEachOptions = Omit<TrackOptions, "countDisplay"> & ForEachExecutionOptions;
|
|
159
|
-
type TaskOptions = AddTaskOptions
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
264
|
+
type TaskOptions<M = void> = AddTaskOptions<M>;
|
|
265
|
+
/**
|
|
266
|
+
* Runs an effect inside a task, creating and providing a `Progress` service automatically when one
|
|
267
|
+
* is not already present in the environment.
|
|
268
|
+
*
|
|
269
|
+
* The effect form tracks success and failure from the effect exit. The callback form exposes a
|
|
270
|
+
* typed `TaskHandle` for task-local updates, typed metadata, and explicit completion or failure,
|
|
271
|
+
* and otherwise auto-finalizes from the callback exit if the task is still `running`.
|
|
272
|
+
*/
|
|
273
|
+
declare const task$1: PublicTaskApi;
|
|
164
274
|
type AllArg = ReadonlyArray<Effect.Effect<any, any, any>> | Record<string, Effect.Effect<any, any, any>>;
|
|
275
|
+
/**
|
|
276
|
+
* Runs multiple effects under a single parent task and keeps the task counters in sync with the
|
|
277
|
+
* child effect outcomes.
|
|
278
|
+
*/
|
|
165
279
|
declare const all: {
|
|
166
280
|
<const Arg extends AllArg, O extends EffectAllExecutionOptions>(effects: Arg, options: Omit<TrackOptions, "total" | "countDisplay"> & O): AllReturn<Arg, O>;
|
|
167
281
|
<O extends EffectAllExecutionOptions>(options: Omit<TrackOptions, "total" | "countDisplay"> & O): <const Arg extends AllArg>(effects: Arg) => AllReturn<Arg, O>;
|
|
168
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* Runs `Effect.forEach` under a single parent task and advances the task counters as items finish.
|
|
285
|
+
*/
|
|
169
286
|
declare const forEach: {
|
|
170
287
|
<A, B, E, R>(iterable: Iterable<A>, f: (item: A, index: number) => Effect.Effect<B, E, R>, options: ForEachOptions): Effect.Effect<ReadonlyArray<B>, E, Exclude<R, Progress | Task>>;
|
|
171
288
|
<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>>;
|
|
172
289
|
};
|
|
173
290
|
//#endregion
|
|
291
|
+
//#region src/renderer/columns/amount-column.d.ts
|
|
292
|
+
interface AmountLayout {
|
|
293
|
+
readonly hasDetailedRows: boolean;
|
|
294
|
+
readonly countWidth: number;
|
|
295
|
+
readonly processedWidth: number;
|
|
296
|
+
readonly totalWidth: number;
|
|
297
|
+
readonly preferredWidth: number;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/renderer/columns/bar-column.d.ts
|
|
301
|
+
interface BarPrepared {
|
|
302
|
+
readonly hasDeterminateRows: boolean;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/renderer/columns/description-column.d.ts
|
|
306
|
+
interface DescriptionPrepared {
|
|
307
|
+
readonly minTreeWidth: number;
|
|
308
|
+
readonly preferredWidth: number;
|
|
309
|
+
}
|
|
310
|
+
declare namespace columns_d_exports {
|
|
311
|
+
export { AmountLayout, BarOptions, BarPrepared, DescriptionPrepared, SpacerOptions, amount, bar, defaults, description, elapsed, elapsedEta, eta, resolveColumnSizeValue, spacer };
|
|
312
|
+
}
|
|
313
|
+
interface SpacerOptions {
|
|
314
|
+
readonly flexGrow?: number;
|
|
315
|
+
readonly flexShrink?: number;
|
|
316
|
+
readonly flexBasis?: number;
|
|
317
|
+
readonly minWidth?: number;
|
|
318
|
+
}
|
|
319
|
+
interface BarOptions {
|
|
320
|
+
readonly size?: number | "fullwidth";
|
|
321
|
+
}
|
|
322
|
+
declare const spacer: <M = unknown>({
|
|
323
|
+
flexGrow,
|
|
324
|
+
flexShrink,
|
|
325
|
+
flexBasis,
|
|
326
|
+
minWidth
|
|
327
|
+
}?: SpacerOptions) => ColumnDef<M>;
|
|
328
|
+
declare const description: () => ColumnDef<any, DescriptionPrepared>;
|
|
329
|
+
declare const bar: ({
|
|
330
|
+
size
|
|
331
|
+
}?: BarOptions) => ColumnDef<any, BarPrepared>;
|
|
332
|
+
declare const amount: () => ColumnDef<any, AmountLayout>;
|
|
333
|
+
declare const elapsed: () => ColumnDef<any>;
|
|
334
|
+
declare const elapsedEta: () => ColumnDef<any>;
|
|
335
|
+
declare const eta: () => ColumnDef<any>;
|
|
336
|
+
declare const defaults: () => ReadonlyArray<ColumnDef<any, any>>;
|
|
337
|
+
declare const resolveColumnSizeValue: <P>(value: ColumnSizeValue<P> | undefined, prepared: P) => number | undefined;
|
|
338
|
+
//#endregion
|
|
174
339
|
//#region src/services/stdio.d.ts
|
|
175
340
|
interface ProgressStdioService {
|
|
176
341
|
readonly stdout: NodeJS.WriteStream;
|
|
@@ -181,4 +346,4 @@ declare class ProgressStdio extends ProgressStdio_base {
|
|
|
181
346
|
static readonly Default: Layer.Layer<ProgressStdio, never, never>;
|
|
182
347
|
}
|
|
183
348
|
//#endregion
|
|
184
|
-
export { AddTaskOptions, AllOptions, AllReturn, EffectAllExecutionOptions, EffectExecutionOptions, ForEachExecutionOptions, ForEachOptions, Progress, ProgressService, ProgressStdio, ProgressStdioService, ProgressTaskEvent, ProgressTaskEventSchema, RenderRow, Task, TaskAddedEvent, TaskAdvancedEvent, TaskCompletedEvent, TaskCountDisplay, TaskCountDisplaySchema, TaskFailedEvent, TaskId, TaskOptions, TaskRemovedEvent, TaskSnapshot, TaskSnapshotSchema, TaskStatus, TaskStatusSchema, TaskStore, TaskUnits, TaskUnitsSchema, TaskUpdatedEvent, TrackOptions, UpdateTaskOptions, all, decodeProgressTaskEvent, forEach, task };
|
|
349
|
+
export { AddTaskOptions, AllOptions, AllReturn, CellInfo, ColumnAlign, ColumnDef, ColumnRenderContext, ColumnSizeValue, columns_d_exports as Columns, EffectAllExecutionOptions, EffectExecutionOptions, ForEachExecutionOptions, ForEachOptions, Progress, ProgressService, ProgressStdio, ProgressStdioService, ProgressTaskEvent, ProgressTaskEventSchema, RenderRow, Task, TaskAddedEvent, TaskAdvancedEvent, TaskCompletedEvent, TaskCountDisplay, TaskCountDisplaySchema, TaskFailedEvent, TaskHandle, TaskId, TaskOptions, TaskProgressSample, TaskProgressSampleSchema, TaskRemovedEvent, TaskRowDerived, TaskSnapshot, TaskSnapshotSchema, TaskStatus, TaskStatusSchema, TaskStore, TaskTreeInfo, TaskUnits, TaskUnitsSchema, TaskUpdatedEvent, TrackOptions, UpdateTaskOptions, all, decodeProgressTaskEvent, forEach, task$1 as task };
|