colorino 0.10.0 → 0.11.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 +96 -65
- package/dist/browser.bundle.cjs +129 -118
- package/dist/browser.bundle.mjs +130 -118
- package/dist/browser.cjs +13 -14
- package/dist/browser.d.cts +5 -5
- package/dist/browser.d.mts +5 -5
- package/dist/browser.d.ts +5 -5
- package/dist/browser.mjs +6 -6
- package/dist/node.cjs +59 -126
- package/dist/node.d.cts +3 -6
- package/dist/node.d.mts +3 -6
- package/dist/node.d.ts +3 -6
- package/dist/node.mjs +42 -108
- package/dist/shared/{colorino.B23laVKA.mjs → colorino.BPD_4Zhq.mjs} +126 -121
- package/dist/shared/{colorino.Y3oJ89MM.cjs → colorino.D9xuyiJg.cjs} +126 -124
- package/dist/shared/colorino.bX_hrCT6.d.cts +21 -0
- package/dist/shared/colorino.bX_hrCT6.d.mts +21 -0
- package/dist/shared/colorino.bX_hrCT6.d.ts +21 -0
- package/package.json +2 -1
- package/dist/shared/colorino.DVUvKR4R.d.cts +0 -465
- package/dist/shared/colorino.DVUvKR4R.d.mts +0 -465
- package/dist/shared/colorino.DVUvKR4R.d.ts +0 -465
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "colorino",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A super simple colorized logger that gets the most out of your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"husky": "^9.0.0",
|
|
76
76
|
"lint-staged": "^15.2.0",
|
|
77
77
|
"md-toc-cli": "^3.1.1",
|
|
78
|
+
"node-pty": "^1.1.0",
|
|
78
79
|
"oxfmt": "^0.9.0",
|
|
79
80
|
"oxlint": "^0.2.0",
|
|
80
81
|
"playwright": "^1.57.0",
|
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
type ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'trace' | 'debug';
|
|
2
|
-
type LogLevel = ConsoleMethod & string;
|
|
3
|
-
type Palette = Record<LogLevel, string>;
|
|
4
|
-
type TerminalTheme = 'dark' | 'light' | 'unknown';
|
|
5
|
-
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light' | 'minimal-dark' | 'minimal-light';
|
|
6
|
-
interface ColorinoOptions {
|
|
7
|
-
disableWarnings?: boolean;
|
|
8
|
-
theme?: TerminalTheme | ThemeName | 'auto';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare enum ColorLevel {
|
|
12
|
-
NO_COLOR = 0,
|
|
13
|
-
ANSI = 1,
|
|
14
|
-
ANSI256 = 2,
|
|
15
|
-
TRUECOLOR = 3
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ColorSupportDetectorInterface {
|
|
19
|
-
getColorLevel(): ColorLevel;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare class NodeColorSupportDetector implements ColorSupportDetectorInterface {
|
|
23
|
-
private readonly _process?;
|
|
24
|
-
private readonly _envForceColor?;
|
|
25
|
-
private readonly _envTerm?;
|
|
26
|
-
private readonly _envColorTerm?;
|
|
27
|
-
private readonly _envNoColor?;
|
|
28
|
-
private readonly _envCliColor?;
|
|
29
|
-
private readonly _envCliColorForce?;
|
|
30
|
-
private readonly _envWtSession?;
|
|
31
|
-
private readonly _isTTY?;
|
|
32
|
-
private readonly _theme;
|
|
33
|
-
constructor(_process?: NodeJS.Process | undefined, overrideTheme?: TerminalTheme);
|
|
34
|
-
isNodeEnv(): boolean;
|
|
35
|
-
getTheme(): TerminalTheme;
|
|
36
|
-
getColorLevel(): ColorLevel;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare class BrowserColorSupportDetector implements ColorSupportDetectorInterface {
|
|
40
|
-
private readonly _window;
|
|
41
|
-
private readonly _navigator;
|
|
42
|
-
private readonly _overrideTheme?;
|
|
43
|
-
constructor(_window: {
|
|
44
|
-
document: HTMLDocument;
|
|
45
|
-
matchMedia(arg0: string): {
|
|
46
|
-
matches: unknown;
|
|
47
|
-
};
|
|
48
|
-
} | undefined, _navigator: {
|
|
49
|
-
userAgent: string;
|
|
50
|
-
} | undefined, _overrideTheme?: TerminalTheme | undefined);
|
|
51
|
-
isBrowserEnv(): boolean;
|
|
52
|
-
getColorLevel(): ColorLevel;
|
|
53
|
-
getTheme(): TerminalTheme;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface ErrorConfig {
|
|
57
|
-
withStackTrace: boolean;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
61
|
-
private _promise;
|
|
62
|
-
constructor(res: Promise<Result<T, E>>);
|
|
63
|
-
static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
|
|
64
|
-
static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
|
|
65
|
-
static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
|
|
66
|
-
static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
67
|
-
static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
|
|
68
|
-
static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
69
|
-
static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
|
|
70
|
-
map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
|
|
71
|
-
andThrough<F>(f: (t: T) => Result<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
72
|
-
andTee(f: (t: T) => unknown): ResultAsync<T, E>;
|
|
73
|
-
orTee(f: (t: E) => unknown): ResultAsync<T, E>;
|
|
74
|
-
mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
|
|
75
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
76
|
-
andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
|
|
77
|
-
andThen<U, F>(f: (t: T) => Result<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
78
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
79
|
-
orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
|
|
80
|
-
orElse<U, A>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
|
|
81
|
-
match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
|
|
82
|
-
unwrapOr<A>(t: A): Promise<T | A>;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated will be removed in 9.0.0.
|
|
85
|
-
*
|
|
86
|
-
* You can use `safeTry` without this method.
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
* safeTry(async function* () {
|
|
90
|
-
* const okValue = yield* yourResult
|
|
91
|
-
* })
|
|
92
|
-
* ```
|
|
93
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
94
|
-
*/
|
|
95
|
-
safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
|
|
96
|
-
then<A, B>(successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
|
|
97
|
-
[Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
|
|
98
|
-
}
|
|
99
|
-
declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
|
|
100
|
-
declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
|
|
101
|
-
declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [infer H, ...infer Rest] ? H extends PromiseLike<infer HI> ? HI extends Result<unknown, unknown> ? [Dedup<HI>, ...UnwrapAsync<Rest>] : never : never : [] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result<infer L, infer R> ? Ok<L, R>[] : never : never : never;
|
|
102
|
-
declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
|
|
103
|
-
declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
|
|
104
|
-
declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
|
|
105
|
-
|
|
106
|
-
declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = {
|
|
107
|
-
[idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never;
|
|
108
|
-
};
|
|
109
|
-
declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
|
|
110
|
-
[idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never;
|
|
111
|
-
};
|
|
112
|
-
declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = {
|
|
113
|
-
[idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never;
|
|
114
|
-
};
|
|
115
|
-
declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
|
|
116
|
-
[idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never;
|
|
117
|
-
};
|
|
118
|
-
declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;
|
|
119
|
-
declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;
|
|
120
|
-
declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
|
|
121
|
-
declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
|
|
122
|
-
|
|
123
|
-
declare namespace Result {
|
|
124
|
-
/**
|
|
125
|
-
* Wraps a function with a try catch, creating a new function with the same
|
|
126
|
-
* arguments but returning `Ok` if successful, `Err` if the function throws
|
|
127
|
-
*
|
|
128
|
-
* @param fn function to wrap with ok on success or err on failure
|
|
129
|
-
* @param errorFn when an error is thrown, this will wrap the error result if provided
|
|
130
|
-
*/
|
|
131
|
-
function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
|
|
132
|
-
function combine<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
|
|
133
|
-
function combine<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResults<T>;
|
|
134
|
-
function combineWithAllErrors<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
135
|
-
function combineWithAllErrors<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
|
|
136
|
-
}
|
|
137
|
-
declare type Result<T, E> = Ok<T, E> | Err<T, E>;
|
|
138
|
-
interface IResult<T, E> {
|
|
139
|
-
/**
|
|
140
|
-
* Used to check if a `Result` is an `OK`
|
|
141
|
-
*
|
|
142
|
-
* @returns `true` if the result is an `OK` variant of Result
|
|
143
|
-
*/
|
|
144
|
-
isOk(): this is Ok<T, E>;
|
|
145
|
-
/**
|
|
146
|
-
* Used to check if a `Result` is an `Err`
|
|
147
|
-
*
|
|
148
|
-
* @returns `true` if the result is an `Err` variant of Result
|
|
149
|
-
*/
|
|
150
|
-
isErr(): this is Err<T, E>;
|
|
151
|
-
/**
|
|
152
|
-
* Maps a `Result<T, E>` to `Result<U, E>`
|
|
153
|
-
* by applying a function to a contained `Ok` value, leaving an `Err` value
|
|
154
|
-
* untouched.
|
|
155
|
-
*
|
|
156
|
-
* @param f The function to apply an `OK` value
|
|
157
|
-
* @returns the result of applying `f` or an `Err` untouched
|
|
158
|
-
*/
|
|
159
|
-
map<A>(f: (t: T) => A): Result<A, E>;
|
|
160
|
-
/**
|
|
161
|
-
* Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
|
|
162
|
-
* contained `Err` value, leaving an `Ok` value untouched.
|
|
163
|
-
*
|
|
164
|
-
* This function can be used to pass through a successful result while
|
|
165
|
-
* handling an error.
|
|
166
|
-
*
|
|
167
|
-
* @param f a function to apply to the error `Err` value
|
|
168
|
-
*/
|
|
169
|
-
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
|
170
|
-
/**
|
|
171
|
-
* Similar to `map` Except you must return a new `Result`.
|
|
172
|
-
*
|
|
173
|
-
* This is useful for when you need to do a subsequent computation using the
|
|
174
|
-
* inner `T` value, but that computation might fail.
|
|
175
|
-
* Additionally, `andThen` is really useful as a tool to flatten a
|
|
176
|
-
* `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
|
|
177
|
-
*
|
|
178
|
-
* @param f The function to apply to the current value
|
|
179
|
-
*/
|
|
180
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
181
|
-
andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
182
|
-
/**
|
|
183
|
-
* This "tee"s the current value to an passed-in computation such as side
|
|
184
|
-
* effect functions but still returns the same current value as the result.
|
|
185
|
-
*
|
|
186
|
-
* This is useful when you want to pass the current result to your side-track
|
|
187
|
-
* work such as logging but want to continue main-track work after that.
|
|
188
|
-
* This method does not care about the result of the passed in computation.
|
|
189
|
-
*
|
|
190
|
-
* @param f The function to apply to the current value
|
|
191
|
-
*/
|
|
192
|
-
andTee(f: (t: T) => unknown): Result<T, E>;
|
|
193
|
-
/**
|
|
194
|
-
* This "tee"s the current `Err` value to an passed-in computation such as side
|
|
195
|
-
* effect functions but still returns the same `Err` value as the result.
|
|
196
|
-
*
|
|
197
|
-
* This is useful when you want to pass the current `Err` value to your side-track
|
|
198
|
-
* work such as logging but want to continue error-track work after that.
|
|
199
|
-
* This method does not care about the result of the passed in computation.
|
|
200
|
-
*
|
|
201
|
-
* @param f The function to apply to the current `Err` value
|
|
202
|
-
*/
|
|
203
|
-
orTee(f: (t: E) => unknown): Result<T, E>;
|
|
204
|
-
/**
|
|
205
|
-
* Similar to `andTee` except error result of the computation will be passed
|
|
206
|
-
* to the downstream in case of an error.
|
|
207
|
-
*
|
|
208
|
-
* This version is useful when you want to make side-effects but in case of an
|
|
209
|
-
* error, you want to pass the error to the downstream.
|
|
210
|
-
*
|
|
211
|
-
* @param f The function to apply to the current value
|
|
212
|
-
*/
|
|
213
|
-
andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
|
|
214
|
-
andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
215
|
-
/**
|
|
216
|
-
* Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
|
|
217
|
-
*
|
|
218
|
-
* This is useful for error recovery.
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* @param f A function to apply to an `Err` value, leaving `Ok` values
|
|
222
|
-
* untouched.
|
|
223
|
-
*/
|
|
224
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
225
|
-
orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
226
|
-
/**
|
|
227
|
-
* Similar to `map` Except you must return a new `Result`.
|
|
228
|
-
*
|
|
229
|
-
* This is useful for when you need to do a subsequent async computation using
|
|
230
|
-
* the inner `T` value, but that computation might fail. Must return a ResultAsync
|
|
231
|
-
*
|
|
232
|
-
* @param f The function that returns a `ResultAsync` to apply to the current
|
|
233
|
-
* value
|
|
234
|
-
*/
|
|
235
|
-
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
236
|
-
/**
|
|
237
|
-
* Maps a `Result<T, E>` to `ResultAsync<U, E>`
|
|
238
|
-
* by applying an async function to a contained `Ok` value, leaving an `Err`
|
|
239
|
-
* value untouched.
|
|
240
|
-
*
|
|
241
|
-
* @param f An async function to apply an `OK` value
|
|
242
|
-
*/
|
|
243
|
-
asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
244
|
-
/**
|
|
245
|
-
* Unwrap the `Ok` value, or return the default if there is an `Err`
|
|
246
|
-
*
|
|
247
|
-
* @param v the default value to return if there is an `Err`
|
|
248
|
-
*/
|
|
249
|
-
unwrapOr<A>(v: A): T | A;
|
|
250
|
-
/**
|
|
251
|
-
*
|
|
252
|
-
* Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
|
|
253
|
-
* execute the function that matches the `Result` variant.
|
|
254
|
-
*
|
|
255
|
-
* Match callbacks do not necessitate to return a `Result`, however you can
|
|
256
|
-
* return a `Result` if you want to.
|
|
257
|
-
*
|
|
258
|
-
* `match` is like chaining `map` and `mapErr`, with the distinction that
|
|
259
|
-
* with `match` both functions must have the same return type.
|
|
260
|
-
*
|
|
261
|
-
* @param ok
|
|
262
|
-
* @param err
|
|
263
|
-
*/
|
|
264
|
-
match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
265
|
-
/**
|
|
266
|
-
* @deprecated will be removed in 9.0.0.
|
|
267
|
-
*
|
|
268
|
-
* You can use `safeTry` without this method.
|
|
269
|
-
* @example
|
|
270
|
-
* ```typescript
|
|
271
|
-
* safeTry(function* () {
|
|
272
|
-
* const okValue = yield* yourResult
|
|
273
|
-
* })
|
|
274
|
-
* ```
|
|
275
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
276
|
-
*/
|
|
277
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
278
|
-
/**
|
|
279
|
-
* **This method is unsafe, and should only be used in a test environments**
|
|
280
|
-
*
|
|
281
|
-
* Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
|
|
282
|
-
*
|
|
283
|
-
* @param config
|
|
284
|
-
*/
|
|
285
|
-
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
286
|
-
/**
|
|
287
|
-
* **This method is unsafe, and should only be used in a test environments**
|
|
288
|
-
*
|
|
289
|
-
* takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
|
|
290
|
-
* otherwise it throws a custom object.
|
|
291
|
-
*
|
|
292
|
-
* @param config
|
|
293
|
-
*/
|
|
294
|
-
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
295
|
-
}
|
|
296
|
-
declare class Ok<T, E> implements IResult<T, E> {
|
|
297
|
-
readonly value: T;
|
|
298
|
-
constructor(value: T);
|
|
299
|
-
isOk(): this is Ok<T, E>;
|
|
300
|
-
isErr(): this is Err<T, E>;
|
|
301
|
-
map<A>(f: (t: T) => A): Result<A, E>;
|
|
302
|
-
mapErr<U>(_f: (e: E) => U): Result<T, U>;
|
|
303
|
-
andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
304
|
-
andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
305
|
-
andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
|
|
306
|
-
andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
307
|
-
andTee(f: (t: T) => unknown): Result<T, E>;
|
|
308
|
-
orTee(_f: (t: E) => unknown): Result<T, E>;
|
|
309
|
-
orElse<R extends Result<unknown, unknown>>(_f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
310
|
-
orElse<U, A>(_f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
311
|
-
asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
312
|
-
asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
|
|
313
|
-
asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
314
|
-
asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
315
|
-
unwrapOr<A>(_v: A): T | A;
|
|
316
|
-
match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
|
|
317
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
318
|
-
_unsafeUnwrap(_?: ErrorConfig): T;
|
|
319
|
-
_unsafeUnwrapErr(config?: ErrorConfig): E;
|
|
320
|
-
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
321
|
-
}
|
|
322
|
-
declare class Err<T, E> implements IResult<T, E> {
|
|
323
|
-
readonly error: E;
|
|
324
|
-
constructor(error: E);
|
|
325
|
-
isOk(): this is Ok<T, E>;
|
|
326
|
-
isErr(): this is Err<T, E>;
|
|
327
|
-
map<A>(_f: (t: T) => A): Result<A, E>;
|
|
328
|
-
mapErr<U>(f: (e: E) => U): Result<T, U>;
|
|
329
|
-
andThrough<F>(_f: (t: T) => Result<unknown, F>): Result<T, E | F>;
|
|
330
|
-
andTee(_f: (t: T) => unknown): Result<T, E>;
|
|
331
|
-
orTee(f: (t: E) => unknown): Result<T, E>;
|
|
332
|
-
andThen<R extends Result<unknown, unknown>>(_f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
|
|
333
|
-
andThen<U, F>(_f: (t: T) => Result<U, F>): Result<U, E | F>;
|
|
334
|
-
orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
|
|
335
|
-
orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
|
|
336
|
-
asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
|
|
337
|
-
asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
|
|
338
|
-
asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
|
|
339
|
-
unwrapOr<A>(v: A): T | A;
|
|
340
|
-
match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
|
|
341
|
-
safeUnwrap(): Generator<Err<never, E>, T>;
|
|
342
|
-
_unsafeUnwrap(config?: ErrorConfig): T;
|
|
343
|
-
_unsafeUnwrapErr(_?: ErrorConfig): E;
|
|
344
|
-
[Symbol.iterator](): Generator<Err<never, E>, T>;
|
|
345
|
-
}
|
|
346
|
-
declare type Prev = [
|
|
347
|
-
never,
|
|
348
|
-
0,
|
|
349
|
-
1,
|
|
350
|
-
2,
|
|
351
|
-
3,
|
|
352
|
-
4,
|
|
353
|
-
5,
|
|
354
|
-
6,
|
|
355
|
-
7,
|
|
356
|
-
8,
|
|
357
|
-
9,
|
|
358
|
-
10,
|
|
359
|
-
11,
|
|
360
|
-
12,
|
|
361
|
-
13,
|
|
362
|
-
14,
|
|
363
|
-
15,
|
|
364
|
-
16,
|
|
365
|
-
17,
|
|
366
|
-
18,
|
|
367
|
-
19,
|
|
368
|
-
20,
|
|
369
|
-
21,
|
|
370
|
-
22,
|
|
371
|
-
23,
|
|
372
|
-
24,
|
|
373
|
-
25,
|
|
374
|
-
26,
|
|
375
|
-
27,
|
|
376
|
-
28,
|
|
377
|
-
29,
|
|
378
|
-
30,
|
|
379
|
-
31,
|
|
380
|
-
32,
|
|
381
|
-
33,
|
|
382
|
-
34,
|
|
383
|
-
35,
|
|
384
|
-
36,
|
|
385
|
-
37,
|
|
386
|
-
38,
|
|
387
|
-
39,
|
|
388
|
-
40,
|
|
389
|
-
41,
|
|
390
|
-
42,
|
|
391
|
-
43,
|
|
392
|
-
44,
|
|
393
|
-
45,
|
|
394
|
-
46,
|
|
395
|
-
47,
|
|
396
|
-
48,
|
|
397
|
-
49,
|
|
398
|
-
...0[]
|
|
399
|
-
];
|
|
400
|
-
declare type CollectResults<T, Collected extends unknown[] = [], Depth extends number = 50> = [
|
|
401
|
-
Depth
|
|
402
|
-
] extends [never] ? [] : T extends [infer H, ...infer Rest] ? H extends Result<infer L, infer R> ? CollectResults<Rest, [
|
|
403
|
-
...Collected,
|
|
404
|
-
[L, R]
|
|
405
|
-
], Prev[Depth]> : never : Collected;
|
|
406
|
-
declare type Transpose<A, Transposed extends unknown[][] = [], Depth extends number = 10> = A extends [infer T, ...infer Rest] ? T extends [infer L, infer R] ? Transposed extends [infer PL, infer PR] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [[...PL, L], [...PR, R]], Prev[Depth]> : never : never : Transpose<Rest, [[L], [R]], Prev[Depth]> : Transposed : Transposed;
|
|
407
|
-
declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [
|
|
408
|
-
infer L,
|
|
409
|
-
infer R
|
|
410
|
-
] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
|
|
411
|
-
declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
|
|
412
|
-
declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends (v: infer V) => unknown ? V : never : never) extends (_: unknown) => infer W ? [...MemberListOf<Exclude<T, W>>, W] : [];
|
|
413
|
-
declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [] ? never : NeverArrayToNever extends 1 ? T extends [never, ...infer Rest] ? [EmptyArrayToNever<Rest>] extends [never] ? never : T : T : T;
|
|
414
|
-
declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
|
|
415
|
-
declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
|
|
416
|
-
declare type IsLiteralArray<T> = T extends {
|
|
417
|
-
length: infer L;
|
|
418
|
-
} ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
|
|
419
|
-
declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
|
|
420
|
-
declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result<infer Oks, infer Errs> ? Result<Oks, Errs[]> : never;
|
|
421
|
-
declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
|
|
422
|
-
declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
|
|
423
|
-
|
|
424
|
-
declare class ColorinoError extends Error {
|
|
425
|
-
constructor(message: string);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
declare class InputValidator {
|
|
429
|
-
validateHex(hex: string): Result<boolean, ColorinoError>;
|
|
430
|
-
validatePalette(palette: Palette): Result<boolean, ColorinoError>;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
declare class Colorino {
|
|
434
|
-
private readonly _palette;
|
|
435
|
-
private readonly _validator;
|
|
436
|
-
private readonly _browserColorSupportDetector?;
|
|
437
|
-
private readonly _nodeColorSupportDetector?;
|
|
438
|
-
private readonly _options;
|
|
439
|
-
private _alreadyWarned;
|
|
440
|
-
private readonly _colorLevel;
|
|
441
|
-
private readonly isBrowser;
|
|
442
|
-
constructor(_palette: Palette, _validator: InputValidator, _browserColorSupportDetector?: BrowserColorSupportDetector | undefined, _nodeColorSupportDetector?: NodeColorSupportDetector | undefined, _options?: ColorinoOptions);
|
|
443
|
-
log(...args: unknown[]): void;
|
|
444
|
-
info(...args: unknown[]): void;
|
|
445
|
-
warn(...args: unknown[]): void;
|
|
446
|
-
error(...args: unknown[]): void;
|
|
447
|
-
trace(...args: unknown[]): void;
|
|
448
|
-
debug(...args: unknown[]): void;
|
|
449
|
-
private _detectColorSupport;
|
|
450
|
-
private _maybeWarnUser;
|
|
451
|
-
private _formatValue;
|
|
452
|
-
private _processArgs;
|
|
453
|
-
private _applyBrowserColors;
|
|
454
|
-
private _applyNodeColors;
|
|
455
|
-
private _output;
|
|
456
|
-
private _out;
|
|
457
|
-
private _filterStack;
|
|
458
|
-
private _cleanErrorStack;
|
|
459
|
-
private _printCleanTrace;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
declare const themePalettes: Record<ThemeName, Palette>;
|
|
463
|
-
|
|
464
|
-
export { Colorino as a, themePalettes as t };
|
|
465
|
-
export type { ColorinoOptions as C, LogLevel as L, Palette as P, ThemeName as T };
|