effective-progress 0.5.1 → 0.5.3
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/dist/index.d.mts +179 -0
- package/dist/index.mjs +815 -0
- package/package.json +16 -5
- package/index.ts +0 -1
- package/src/api.ts +0 -197
- package/src/index.ts +0 -4
- package/src/ink-renderer/app.tsx +0 -31
- package/src/ink-renderer/columns/amount-column.tsx +0 -17
- package/src/ink-renderer/columns/bar-column.tsx +0 -31
- package/src/ink-renderer/columns/description-column.tsx +0 -7
- package/src/ink-renderer/columns/elapsed-column.tsx +0 -7
- package/src/ink-renderer/columns/eta-column.tsx +0 -18
- package/src/ink-renderer/columns/index.ts +0 -6
- package/src/ink-renderer/columns/types.ts +0 -11
- package/src/ink-renderer/format.ts +0 -55
- package/src/ink-renderer/index.ts +0 -1
- package/src/ink-renderer/layout.ts +0 -145
- package/src/ink-renderer/model.ts +0 -24
- package/src/ink-renderer/service.tsx +0 -121
- package/src/ink-renderer/task-row.tsx +0 -53
- package/src/ink-renderer/tree.ts +0 -62
- package/src/ink-renderer/types.ts +0 -18
- package/src/runtime.ts +0 -396
- package/src/terminal.ts +0 -61
- package/src/types.ts +0 -143
- package/src/utils.ts +0 -20
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Brand, Context, Effect, Layer, Option, Schema } from "effect";
|
|
2
|
+
import { Concurrency } from "effect/Types";
|
|
3
|
+
import * as effect_SchemaAST0 from "effect/SchemaAST";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
declare const TaskIdSchema: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
7
|
+
type TaskId = typeof TaskIdSchema.Type;
|
|
8
|
+
declare const TaskId: Brand.Brand.Constructor<number & Brand.Brand<"TaskId">>;
|
|
9
|
+
declare const TaskStatusSchema: Schema.Literal<["running", "done", "failed"]>;
|
|
10
|
+
type TaskStatus = typeof TaskStatusSchema.Type;
|
|
11
|
+
interface AddTaskOptions {
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly total?: number;
|
|
14
|
+
readonly transient?: boolean;
|
|
15
|
+
readonly parentId?: TaskId;
|
|
16
|
+
}
|
|
17
|
+
interface UpdateTaskOptions {
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly completed?: number;
|
|
20
|
+
readonly total?: number;
|
|
21
|
+
readonly transient?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type TrackOptions = Exclude<AddTaskOptions, "parentId">;
|
|
24
|
+
declare const DeterminateTaskUnits_base: Schema.TaggedClass<DeterminateTaskUnits, "DeterminateTaskUnits", {
|
|
25
|
+
readonly _tag: Schema.tag<"DeterminateTaskUnits">;
|
|
26
|
+
} & {
|
|
27
|
+
completed: typeof Schema.Number;
|
|
28
|
+
total: typeof Schema.Number;
|
|
29
|
+
}>;
|
|
30
|
+
declare class DeterminateTaskUnits extends DeterminateTaskUnits_base {}
|
|
31
|
+
declare const IndeterminateTaskUnits_base: Schema.TaggedClass<IndeterminateTaskUnits, "IndeterminateTaskUnits", {
|
|
32
|
+
readonly _tag: Schema.tag<"IndeterminateTaskUnits">;
|
|
33
|
+
} & {
|
|
34
|
+
spinnerFrame: typeof Schema.Number;
|
|
35
|
+
}>;
|
|
36
|
+
declare class IndeterminateTaskUnits extends IndeterminateTaskUnits_base {}
|
|
37
|
+
declare const TaskUnitsSchema: Schema.Union<[typeof DeterminateTaskUnits, typeof IndeterminateTaskUnits]>;
|
|
38
|
+
type TaskUnits = typeof TaskUnitsSchema.Type;
|
|
39
|
+
declare const TaskSnapshot_base: Schema.TaggedClass<TaskSnapshot, "TaskSnapshot", {
|
|
40
|
+
readonly _tag: Schema.tag<"TaskSnapshot">;
|
|
41
|
+
} & {
|
|
42
|
+
id: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
43
|
+
parentId: Schema.NullOr<Schema.brand<typeof Schema.Number, "TaskId">>;
|
|
44
|
+
description: typeof Schema.String;
|
|
45
|
+
status: Schema.Literal<["running", "done", "failed"]>;
|
|
46
|
+
transient: typeof Schema.Boolean;
|
|
47
|
+
units: Schema.Union<[typeof DeterminateTaskUnits, typeof IndeterminateTaskUnits]>;
|
|
48
|
+
startedAt: typeof Schema.Number;
|
|
49
|
+
completedAt: Schema.NullOr<typeof Schema.Number>;
|
|
50
|
+
}>;
|
|
51
|
+
declare class TaskSnapshot extends TaskSnapshot_base {}
|
|
52
|
+
interface RenderRow {
|
|
53
|
+
readonly id: TaskId;
|
|
54
|
+
readonly depth: number;
|
|
55
|
+
}
|
|
56
|
+
interface TaskStore {
|
|
57
|
+
readonly tasks: Map<TaskId, TaskSnapshot>;
|
|
58
|
+
readonly renderOrder: ReadonlyArray<RenderRow>;
|
|
59
|
+
}
|
|
60
|
+
interface ProgressService {
|
|
61
|
+
readonly addTask: (options: AddTaskOptions) => Effect.Effect<TaskId>;
|
|
62
|
+
readonly updateTask: (taskId: TaskId, options: UpdateTaskOptions) => Effect.Effect<void>;
|
|
63
|
+
readonly advanceTask: (taskId: TaskId, amount?: number) => Effect.Effect<void>;
|
|
64
|
+
readonly completeTask: (taskId: TaskId) => Effect.Effect<void>;
|
|
65
|
+
readonly failTask: (taskId: TaskId) => Effect.Effect<void>;
|
|
66
|
+
readonly log: (...args: ReadonlyArray<unknown>) => Effect.Effect<void>;
|
|
67
|
+
readonly getTask: (taskId: TaskId) => Effect.Effect<Option.Option<TaskSnapshot>>;
|
|
68
|
+
readonly listTasks: Effect.Effect<ReadonlyArray<TaskSnapshot>>;
|
|
69
|
+
readonly runTask: {
|
|
70
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, options: AddTaskOptions): Effect.Effect<A, E, Exclude<R, Task>>;
|
|
71
|
+
<A, E, R>(options: AddTaskOptions): (effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Task>>;
|
|
72
|
+
};
|
|
73
|
+
readonly withTask: {
|
|
74
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, options: AddTaskOptions): Effect.Effect<A, E, Exclude<R, Task>>;
|
|
75
|
+
<A, E, R>(options: AddTaskOptions): (effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Task>>;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare const Task_base: Context.TagClass<Task, "stromseng.dev/effective-progress/Task", number & Brand.Brand<"TaskId">>;
|
|
79
|
+
declare class Task extends Task_base {}
|
|
80
|
+
declare const TaskAddedEvent_base: Schema.TaggedClass<TaskAddedEvent, "TaskAdded", {
|
|
81
|
+
readonly _tag: Schema.tag<"TaskAdded">;
|
|
82
|
+
} & {
|
|
83
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
84
|
+
parentId: Schema.NullOr<Schema.brand<typeof Schema.Number, "TaskId">>;
|
|
85
|
+
description: typeof Schema.String;
|
|
86
|
+
total: Schema.optional<typeof Schema.Number>;
|
|
87
|
+
transient: typeof Schema.Boolean;
|
|
88
|
+
}>;
|
|
89
|
+
declare class TaskAddedEvent extends TaskAddedEvent_base {}
|
|
90
|
+
declare const TaskUpdatedEvent_base: Schema.TaggedClass<TaskUpdatedEvent, "TaskUpdated", {
|
|
91
|
+
readonly _tag: Schema.tag<"TaskUpdated">;
|
|
92
|
+
} & {
|
|
93
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
94
|
+
description: Schema.optional<typeof Schema.String>;
|
|
95
|
+
completed: Schema.optional<typeof Schema.Number>;
|
|
96
|
+
total: Schema.optional<typeof Schema.Number>;
|
|
97
|
+
transient: Schema.optional<typeof Schema.Boolean>;
|
|
98
|
+
}>;
|
|
99
|
+
declare class TaskUpdatedEvent extends TaskUpdatedEvent_base {}
|
|
100
|
+
declare const TaskAdvancedEvent_base: Schema.TaggedClass<TaskAdvancedEvent, "TaskAdvanced", {
|
|
101
|
+
readonly _tag: Schema.tag<"TaskAdvanced">;
|
|
102
|
+
} & {
|
|
103
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
104
|
+
amount: typeof Schema.Number;
|
|
105
|
+
}>;
|
|
106
|
+
declare class TaskAdvancedEvent extends TaskAdvancedEvent_base {}
|
|
107
|
+
declare const TaskCompletedEvent_base: Schema.TaggedClass<TaskCompletedEvent, "TaskCompleted", {
|
|
108
|
+
readonly _tag: Schema.tag<"TaskCompleted">;
|
|
109
|
+
} & {
|
|
110
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
111
|
+
}>;
|
|
112
|
+
declare class TaskCompletedEvent extends TaskCompletedEvent_base {}
|
|
113
|
+
declare const TaskFailedEvent_base: Schema.TaggedClass<TaskFailedEvent, "TaskFailed", {
|
|
114
|
+
readonly _tag: Schema.tag<"TaskFailed">;
|
|
115
|
+
} & {
|
|
116
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
117
|
+
}>;
|
|
118
|
+
declare class TaskFailedEvent extends TaskFailedEvent_base {}
|
|
119
|
+
declare const TaskRemovedEvent_base: Schema.TaggedClass<TaskRemovedEvent, "TaskRemoved", {
|
|
120
|
+
readonly _tag: Schema.tag<"TaskRemoved">;
|
|
121
|
+
} & {
|
|
122
|
+
taskId: Schema.brand<typeof Schema.Number, "TaskId">;
|
|
123
|
+
}>;
|
|
124
|
+
declare class TaskRemovedEvent extends TaskRemovedEvent_base {}
|
|
125
|
+
declare const ProgressTaskEventSchema: Schema.Union<[typeof TaskAddedEvent, typeof TaskUpdatedEvent, typeof TaskAdvancedEvent, typeof TaskCompletedEvent, typeof TaskFailedEvent, typeof TaskRemovedEvent]>;
|
|
126
|
+
type ProgressTaskEvent = typeof ProgressTaskEventSchema.Type;
|
|
127
|
+
declare const decodeProgressTaskEvent: (u: unknown, overrideOptions?: effect_SchemaAST0.ParseOptions) => TaskAddedEvent | TaskUpdatedEvent | TaskAdvancedEvent | TaskCompletedEvent | TaskFailedEvent | TaskRemovedEvent;
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/runtime.d.ts
|
|
130
|
+
declare const Progress_base: Context.TagClass<Progress, "stromseng.dev/effective-progress/Progress", ProgressService>;
|
|
131
|
+
declare class Progress extends Progress_base {
|
|
132
|
+
static readonly Default: Layer.Layer<Progress, never, never>;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/api.d.ts
|
|
136
|
+
interface EffectExecutionOptions {
|
|
137
|
+
readonly concurrency?: Concurrency;
|
|
138
|
+
readonly batching?: boolean | "inherit";
|
|
139
|
+
readonly concurrentFinalizers?: boolean;
|
|
140
|
+
}
|
|
141
|
+
interface EffectAllExecutionOptions extends EffectExecutionOptions {
|
|
142
|
+
readonly discard?: boolean;
|
|
143
|
+
readonly mode?: "default" | "validate" | "either";
|
|
144
|
+
}
|
|
145
|
+
type AllOptions = Omit<TrackOptions, "total"> & EffectAllExecutionOptions;
|
|
146
|
+
type AllReturn<Arg extends ReadonlyArray<Effect.Effect<any, any, any>> | Record<string, Effect.Effect<any, any, any>>, O extends EffectAllExecutionOptions> = [[Arg] extends [ReadonlyArray<Effect.Effect<any, any, any>>] ? Effect.All.ReturnTuple<Arg, Effect.All.IsDiscard<O>, Effect.All.ExtractMode<O>> : [Arg] extends [Record<string, Effect.Effect<any, any, any>>] ? Effect.All.ReturnObject<Arg, Effect.All.IsDiscard<O>, Effect.All.ExtractMode<O>> : never] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, Exclude<R, Progress | Task>> : never;
|
|
147
|
+
interface ForEachExecutionOptions extends EffectExecutionOptions {
|
|
148
|
+
readonly discard?: false | undefined;
|
|
149
|
+
}
|
|
150
|
+
type ForEachOptions = TrackOptions & ForEachExecutionOptions;
|
|
151
|
+
type TaskOptions = AddTaskOptions;
|
|
152
|
+
declare const task: {
|
|
153
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, options: TaskOptions): Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
154
|
+
<A, E, R>(options: TaskOptions): (effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Progress | Task>>;
|
|
155
|
+
};
|
|
156
|
+
type AllArg = ReadonlyArray<Effect.Effect<any, any, any>> | Record<string, Effect.Effect<any, any, any>>;
|
|
157
|
+
declare const all: {
|
|
158
|
+
<const Arg extends AllArg, O extends EffectAllExecutionOptions>(effects: Arg, options: Omit<TrackOptions, "total"> & O): AllReturn<Arg, O>;
|
|
159
|
+
<O extends EffectAllExecutionOptions>(options: Omit<TrackOptions, "total"> & O): <const Arg extends AllArg>(effects: Arg) => AllReturn<Arg, O>;
|
|
160
|
+
};
|
|
161
|
+
declare const forEach: {
|
|
162
|
+
<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>>;
|
|
163
|
+
<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>>;
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/terminal.d.ts
|
|
167
|
+
interface ProgressTerminalService {
|
|
168
|
+
readonly isTTY: Effect.Effect<boolean>;
|
|
169
|
+
readonly stderrRows: Effect.Effect<number | undefined>;
|
|
170
|
+
readonly stderrColumns: Effect.Effect<number | undefined>;
|
|
171
|
+
readonly writeStderr: (text: string) => Effect.Effect<void>;
|
|
172
|
+
readonly withRawInputCapture: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
173
|
+
}
|
|
174
|
+
declare const ProgressTerminal_base: Context.TagClass<ProgressTerminal, "stromseng.dev/ProgressTerminal", ProgressTerminalService>;
|
|
175
|
+
declare class ProgressTerminal extends ProgressTerminal_base {
|
|
176
|
+
static readonly Default: Layer.Layer<ProgressTerminal, never, never>;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { AddTaskOptions, AllOptions, AllReturn, DeterminateTaskUnits, EffectAllExecutionOptions, EffectExecutionOptions, ForEachExecutionOptions, ForEachOptions, IndeterminateTaskUnits, Progress, ProgressService, ProgressTaskEvent, ProgressTaskEventSchema, ProgressTerminal, ProgressTerminalService, RenderRow, Task, TaskAddedEvent, TaskAdvancedEvent, TaskCompletedEvent, TaskFailedEvent, TaskId, TaskOptions, TaskRemovedEvent, TaskSnapshot, TaskStatus, TaskStatusSchema, TaskStore, TaskUnits, TaskUnitsSchema, TaskUpdatedEvent, TrackOptions, UpdateTaskOptions, all, decodeProgressTaskEvent, forEach, task };
|