@wix/zero-config-implementation 1.33.0 → 1.34.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.
Files changed (40) hide show
  1. package/dist/index.d.ts +2742 -45
  2. package/dist/index.js +289 -280
  3. package/dist/jsx-runtime-interceptor.d.ts +58 -42
  4. package/dist/jsx-runtime-loader.d.ts +27 -23
  5. package/package.json +2 -2
  6. package/src/index.ts +4 -0
  7. package/vite.config.ts +12 -0
  8. package/dist/component-renderer.d.ts +0 -31
  9. package/dist/converters/data-item-builder.d.ts +0 -18
  10. package/dist/converters/index.d.ts +0 -1
  11. package/dist/converters/to-editor-component.d.ts +0 -3
  12. package/dist/converters/utils.d.ts +0 -20
  13. package/dist/errors.d.ts +0 -230
  14. package/dist/extraction-types.d.ts +0 -7
  15. package/dist/information-extractors/css/index.d.ts +0 -3
  16. package/dist/information-extractors/css/parse.d.ts +0 -7
  17. package/dist/information-extractors/css/sass-adapter.d.ts +0 -2
  18. package/dist/information-extractors/css/selector-matcher.d.ts +0 -6
  19. package/dist/information-extractors/css/types.d.ts +0 -61
  20. package/dist/information-extractors/react/extractors/core/index.d.ts +0 -6
  21. package/dist/information-extractors/react/extractors/core/runner.d.ts +0 -23
  22. package/dist/information-extractors/react/extractors/core/store.d.ts +0 -17
  23. package/dist/information-extractors/react/extractors/core/tree-builder.d.ts +0 -15
  24. package/dist/information-extractors/react/extractors/core/types.d.ts +0 -40
  25. package/dist/information-extractors/react/extractors/css-properties.d.ts +0 -20
  26. package/dist/information-extractors/react/extractors/index.d.ts +0 -11
  27. package/dist/information-extractors/react/extractors/prop-tracker.d.ts +0 -21
  28. package/dist/information-extractors/react/index.d.ts +0 -8
  29. package/dist/information-extractors/react/types.d.ts +0 -38
  30. package/dist/information-extractors/react/utils/mock-generator.d.ts +0 -21
  31. package/dist/information-extractors/ts/components.d.ts +0 -14
  32. package/dist/information-extractors/ts/css-imports.d.ts +0 -2
  33. package/dist/information-extractors/ts/index.d.ts +0 -3
  34. package/dist/information-extractors/ts/types.d.ts +0 -54
  35. package/dist/information-extractors/ts/utils/semantic-type-resolver.d.ts +0 -12
  36. package/dist/manifest-pipeline.d.ts +0 -29
  37. package/dist/module-loader.d.ts +0 -27
  38. package/dist/ts-compiler.d.ts +0 -13
  39. package/dist/utils/css-class.d.ts +0 -9
  40. package/dist/wix-type-to-data-type.d.ts +0 -6
package/dist/index.d.ts CHANGED
@@ -1,45 +1,2742 @@
1
- import { EditorReactComponent } from '@wix/zero-config-schema';
2
- import { ResultAsync } from 'neverthrow';
3
- import { NotFoundError, ParseError } from './errors';
4
- import { ExtractionError } from './extraction-types';
5
- import { RunExtractorsOptions } from './information-extractors/react';
6
- export interface ManifestResult {
7
- component: EditorReactComponent;
8
- errors: ExtractionError[];
9
- }
10
- /**
11
- * Extract component manifest from a TypeScript source file.
12
- *
13
- * @param componentPath - Path to the TypeScript source file
14
- * @param compiledEntryPath - Path to the built JS entry file of the component's package (e.g. dist/index.js)
15
- * @param options.onError - Called for each non-fatal extraction error as it occurs
16
- * @errors
17
- * - {@link NotFoundError} — Source file does not exist (phase: `compile`)
18
- * - {@link ParseError} — TypeScript config or component types could not be parsed (phase: `compile` | `extract`)
19
- */
20
- export interface ExtractComponentManifestOptions extends RunExtractorsOptions {
21
- onError?: (error: ExtractionError) => void;
22
- }
23
- export declare function extractComponentManifest(componentPath: string, compiledEntryPath: string, options?: ExtractComponentManifestOptions): ResultAsync<ManifestResult, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>>;
24
- export type { ExtractionError } from './extraction-types';
25
- export type { EditorReactComponent } from '@wix/zero-config-schema';
26
- export type { ComponentInfoWithCss, ExtractedCssInfo, ProcessComponentResult } from './manifest-pipeline';
27
- /** TypeScript compilation & static analysis */
28
- export { compileTsFile } from './ts-compiler';
29
- export { extractAllComponentInfo, extractDefaultComponentInfo } from './information-extractors/ts/components';
30
- export { extractCssImports } from './information-extractors/ts/css-imports';
31
- export type { ComponentInfo, PropInfo, ResolvedType, ResolvedKind, DefaultValue, } from './information-extractors/ts/types';
32
- /** React render-time extraction */
33
- export type { RunExtractorsOptions } from './information-extractors/react';
34
- export { runExtractors, ExtractorStore, buildElementTree, createPropTrackerExtractor, createCssPropertiesExtractor, } from './information-extractors/react';
35
- export type { ExtractionResult, ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent, ExtractedElement, PropTrackerData, PropTrackerExtractorState, CssPropertiesData, CoupledComponentInfo, CoupledProp, DOMBinding, TrackingStores, PropWriteInfo, PropSpyMeta, } from './information-extractors/react';
36
- /** CSS parsing & selector matching */
37
- export { parseCss } from './information-extractors/css';
38
- export type { CSSParserAPI } from './information-extractors/css';
39
- /** Error classes */
40
- export { BaseError, NotFoundError, ParseError, ValidationError, IoError, DefectError, withDefectBoundary, } from './errors';
41
- /** Module loader primitives */
42
- export { loadModule, findComponent } from './module-loader';
43
- export type { LoadModuleFailure } from './module-loader';
44
- export { renderWithExtractors } from './component-renderer';
45
- export type { CreateElementListener } from './component-renderer';
1
+ import { ComponentType } from 'react';
2
+ import { default as default_2 } from 'typescript';
3
+ import { EditorReactComponent } from '@wix/zero-config-schema';
4
+ import { Program } from 'typescript';
5
+
6
+ /**
7
+ * Unbound added properties of a plugin
8
+ */
9
+ declare interface AddedProperties {
10
+ [PropName: string]: unknown
11
+ }
12
+
13
+ /**
14
+ * Single aggregate error
15
+ */
16
+ declare type AggregateErrorOption = unknown
17
+
18
+ /**
19
+ * Optional aggregate `errors` array
20
+ */
21
+ declare type AggregateErrors = DefinedAggregateErrors | undefined
22
+
23
+ /**
24
+ * Object with an `errors` property to set as `error.errors`
25
+ */
26
+ declare type AggregateErrorsProperty<
27
+ AggregateErrorsArg extends AggregateErrors,
28
+ CauseArg extends Cause,
29
+ > =
30
+ ConcatAggregateErrors<AggregateErrorsArg, CauseArg> extends never
31
+ ? { errors?: Error[] }
32
+ : {
33
+ errors: NormalizeAggregateErrors<
34
+ ConcatAggregateErrors<AggregateErrorsArg, CauseArg>
35
+ >
36
+ }
37
+
38
+ /**
39
+ * Root error class for the entire project. All domain errors extend this.
40
+ *
41
+ * Plugins attached here cascade to every subclass automatically.
42
+ * The `phase` prop defaults to `"unknown"` and is overridden at the call
43
+ * site or via `mapErr` as the error propagates through pipeline stages.
44
+ */
45
+ export declare const BaseError: SpecificErrorClass< {
46
+ name: "cli";
47
+ isOptions: (options: unknown) => boolean;
48
+ getOptions: (options?: Options) => {
49
+ custom: string;
50
+ stack?: boolean;
51
+ cause?: boolean;
52
+ props?: boolean;
53
+ colors?: boolean;
54
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
55
+ header?: Styles | "";
56
+ classes?: {
57
+ readonly [errorName: string]: Omit<Options_3, "classes">;
58
+ } & {
59
+ readonly [errorName: string]: Omit<Options_2, "classes">;
60
+ };
61
+ exitCode?: number;
62
+ silent?: boolean;
63
+ timeout?: number;
64
+ log?: (message: string) => void;
65
+ };
66
+ instanceMethods: {
67
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
68
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
69
+ };
70
+ }[], {
71
+ /** Pipeline stage where the error originated (composed at runtime). */
72
+ phase: string;
73
+ /** True if this error represents a violated invariant, not a user error. */
74
+ isDefect: boolean;
75
+ /** Process exit code used by BaseError.exit(). */
76
+ exitCode: number;
77
+ }, CustomClass>;
78
+
79
+ declare type BasicColors =
80
+ | 'black'
81
+ | 'red'
82
+ | 'green'
83
+ | 'yellow'
84
+ | 'blue'
85
+ | 'magenta'
86
+ | 'cyan'
87
+ | 'white'
88
+ | 'gray'
89
+
90
+ declare type BasicStyle =
91
+ | 'bold'
92
+ | 'underline'
93
+ | 'inverse'
94
+ | 'reset'
95
+ | 'dim'
96
+ | 'italic'
97
+ | 'hidden'
98
+ | 'strikethrough'
99
+ | 'visible'
100
+
101
+ /**
102
+ * Builds an element tree from HTML, merging with store data.
103
+ * Each element gets a semantic name from concatenated ancestor names.
104
+ */
105
+ export declare function buildElementTree(html: string, store: ExtractorStore): ExtractedElement[];
106
+
107
+ /**
108
+ * Optional `cause` option
109
+ */
110
+ declare type Cause = unknown
111
+
112
+ declare type CollectResults<T, Collected extends unknown[] = [], Depth extends number = 50> = [
113
+ Depth
114
+ ] extends [never] ? [] : T extends [infer H, ...infer Rest] ? H extends Result<infer L, infer R> ? CollectResults<Rest, [
115
+ ...Collected,
116
+ [L, R]
117
+ ], Prev[Depth]> : never : Collected;
118
+
119
+ declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [
120
+ infer L,
121
+ infer R
122
+ ] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
123
+
124
+ declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
125
+
126
+ declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
127
+
128
+ declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
129
+
130
+ declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
131
+
132
+ /**
133
+ * Properties shared by all `info` objects.
134
+ *
135
+ * @private This type is private and only exported as a temporary workaround
136
+ * for an open issue with TypeScript. It will be removed in a future release.
137
+ * See:
138
+ *
139
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
140
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
141
+ */
142
+ declare interface CommonInfo<Options = never> {
143
+ /**
144
+ * Normalized error instance.
145
+ *
146
+ * @example
147
+ * ```js
148
+ * export default {
149
+ * name: 'example',
150
+ * properties({ error }) {
151
+ * return { isInputError: error.name === 'InputError' }
152
+ * },
153
+ * }
154
+ * ```
155
+ */
156
+ error: ErrorInstance
157
+
158
+ /**
159
+ * Plugin's options, as returned by `getOptions()`.
160
+ *
161
+ * @example
162
+ * ```js
163
+ * export default {
164
+ * name: 'example',
165
+ * getOptions(options) {
166
+ * return options
167
+ * },
168
+ * // `new ErrorClass('message', { example: value })` sets
169
+ * // `error.example: value`
170
+ * properties({ options }) {
171
+ * return { example: options }
172
+ * },
173
+ * }
174
+ * ```
175
+ */
176
+ readonly options: Options
177
+
178
+ /**
179
+ * Current error class.
180
+ *
181
+ * @example
182
+ * ```js
183
+ * export default {
184
+ * name: 'example',
185
+ * instanceMethods: {
186
+ * addErrors({ error, ErrorClass }, errors = []) {
187
+ * error.errors = errors.map(ErrorClass.normalize)
188
+ * },
189
+ * },
190
+ * }
191
+ * ```
192
+ */
193
+ readonly ErrorClass: ErrorClass
194
+
195
+ /**
196
+ * Array containing both the current error class and all its subclasses
197
+ * (including deep ones).
198
+ *
199
+ * @example
200
+ * ```js
201
+ * export default {
202
+ * name: 'example',
203
+ * staticMethods: {
204
+ * isKnownErrorClass({ ErrorClasses }, value) {
205
+ * return ErrorClasses.includes(value)
206
+ * },
207
+ * },
208
+ * }
209
+ * ```
210
+ */
211
+ readonly ErrorClasses: readonly ErrorClass[]
212
+
213
+ /**
214
+ * Returns the `info` object from a specific `Error`.
215
+ * All members are present except for `info.errorInfo` itself.
216
+ *
217
+ * @example
218
+ * ```js
219
+ * export default {
220
+ * name: 'example',
221
+ * staticMethods: {
222
+ * getLogErrors:
223
+ * ({ errorInfo }) =>
224
+ * (errors) => {
225
+ * errors.forEach((error) => {
226
+ * const { options } = errorInfo(error)
227
+ * console.error(options.example?.stack ? error.stack : error.message)
228
+ * })
229
+ * },
230
+ * },
231
+ * }
232
+ * ```
233
+ */
234
+ readonly errorInfo: (error: unknown) => Info['errorInfo']
235
+ }
236
+
237
+ /**
238
+ * Compile a TypeScript file into a ts.Program.
239
+ *
240
+ * @param filePath - Path to the TypeScript source file
241
+ * @returns The compiled TypeScript program on success
242
+ * @errors
243
+ * - {@link NotFoundError} — Source file does not exist (phase: `compile`)
244
+ * - {@link ParseError} — TypeScript config could not be parsed (phase: `compile`)
245
+ */
246
+ export declare function compileTsFile(filePath: string): ResultAsync<default_2.Program, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>>;
247
+
248
+ export declare interface ComponentInfo {
249
+ componentName: string;
250
+ props: Record<string, PropInfo>;
251
+ }
252
+
253
+ export declare interface ComponentInfoWithCss extends CoupledComponentInfo {
254
+ css: ExtractedCssInfo[];
255
+ varUsedByTraceId: Map<string, Set<string>>;
256
+ }
257
+
258
+ /**
259
+ * Concatenate the `errors` option with `cause.errors`, if either is defined
260
+ */
261
+ declare type ConcatAggregateErrors<
262
+ AggregateErrorsArg extends AggregateErrors,
263
+ CauseArg extends Cause,
264
+ > = [AggregateErrorsArg] extends [DefinedAggregateErrors]
265
+ ? 'errors' extends keyof CauseArg
266
+ ? CauseArg['errors'] extends DefinedAggregateErrors
267
+ ? [...CauseArg['errors'], ...AggregateErrorsArg]
268
+ : AggregateErrorsArg
269
+ : AggregateErrorsArg
270
+ : 'errors' extends keyof CauseArg
271
+ ? CauseArg['errors'] extends DefinedAggregateErrors
272
+ ? CauseArg['errors']
273
+ : never
274
+ : never
275
+
276
+ /**
277
+ * Options of all core plugins
278
+ */
279
+ declare interface CorePluginsOptions<ChildProps extends ErrorProps> {
280
+ /**
281
+ * Error properties.
282
+ *
283
+ * @example
284
+ * ```js
285
+ * const error = new InputError('...', { props: { isUserError: true } })
286
+ * console.log(error.isUserError) // true
287
+ * ```
288
+ *
289
+ * @example
290
+ * ```js
291
+ * const InputError = BaseError.subclass('InputError', {
292
+ * props: { isUserError: true },
293
+ * })
294
+ * const error = new InputError('...')
295
+ * console.log(error.isUserError) // true
296
+ * ```
297
+ */
298
+ readonly props?: ChildProps
299
+ }
300
+
301
+ export declare interface CoupledComponentInfo {
302
+ componentName: string;
303
+ props: Record<string, CoupledProp>;
304
+ elements: ExtractedElement[];
305
+ innerElementProps?: Map<string, Record<string, CoupledProp>>;
306
+ propUsages: TrackingStores['propUsages'];
307
+ }
308
+
309
+ export declare interface CoupledProp extends PropInfo {
310
+ /** Full stores.propUsages key for this prop, e.g. "props.linkUrl". */
311
+ propPath: string;
312
+ logicOnly: boolean;
313
+ }
314
+
315
+ /**
316
+ * Creates a CSS properties extractor that determines relevant CSS properties
317
+ * for each element based on its tag and role.
318
+ */
319
+ export declare function createCssPropertiesExtractor(): ReactExtractor;
320
+
321
+ /**
322
+ * Event emitted for each DOM element created during render.
323
+ */
324
+ export declare interface CreateElementEvent {
325
+ tag: string;
326
+ props: Record<string, unknown>;
327
+ traceId: string;
328
+ children: unknown[];
329
+ store: ExtractorStore;
330
+ }
331
+
332
+ export declare interface CreateElementListener {
333
+ onCreateElement: (event: CreateElementEvent) => void;
334
+ }
335
+
336
+ /**
337
+ * Creates a prop tracker extractor that:
338
+ * 1. Generates spy-instrumented mock props during beforeRender
339
+ * 2. Detects spy markers in element props during onCreateElement
340
+ * 3. propUsages tracking data to the store namespaced by 'prop-tracker'
341
+ */
342
+ export declare function createPropTrackerExtractor(): {
343
+ extractor: ReactExtractor;
344
+ state: PropTrackerExtractorState;
345
+ };
346
+
347
+ /**
348
+ * `ErrorClass.subclass()`
349
+ *
350
+ * @private This type is private and only exported as a temporary workaround
351
+ * for an open issue with TypeScript. It will be removed in a future release.
352
+ * See:
353
+ *
354
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
355
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
356
+ */
357
+ declare type CreateSubclass<
358
+ PluginsArg extends Plugins,
359
+ ErrorPropsArg extends ErrorProps,
360
+ CustomClassArg extends CustomClass,
361
+ > = <
362
+ ChildPlugins extends Plugins = [],
363
+ ChildCustomClass extends CustomClassArg = CustomClassArg,
364
+ ChildProps extends ErrorProps = object,
365
+ >(
366
+ errorName: ErrorName,
367
+ options?: SpecificClassOptions<
368
+ PluginsArg,
369
+ ChildPlugins,
370
+ ChildProps,
371
+ ChildCustomClass
372
+ >,
373
+ ) => SpecificErrorClass<
374
+ [...PluginsArg, ...ChildPlugins],
375
+ MergeErrorProps<ErrorPropsArg, ChildProps>,
376
+ ChildCustomClass
377
+ >
378
+
379
+ /**
380
+ * API returned by parseCss function for querying parsed CSS
381
+ */
382
+ export declare interface CSSParserAPI {
383
+ /**
384
+ * Gets CSS properties for a specific selector
385
+ * @param selector - The selector to extract properties for
386
+ * @returns Array of CSS properties for the specified selector
387
+ */
388
+ getPropertiesForSelector: (selector: string) => CSSProperty[];
389
+ /**
390
+ * Gets all selectors and their properties from the CSS
391
+ * @returns Map from selector to its CSS properties
392
+ */
393
+ getAllProperties: () => Map<string, CSSProperty[]>;
394
+ /**
395
+ * Gets all CSS property names that use a specific CSS variable
396
+ * @param varName - The CSS variable name (with or without --)
397
+ * @returns Array of CSS property names that use this variable
398
+ */
399
+ getVarUsages: (varName: string) => string[];
400
+ /**
401
+ * Gets unique properties from multiple selectors with CSS cascade rules:
402
+ * - First selector wins (properties from earlier selectors take precedence)
403
+ * - Within a selector, last value wins (if property appears multiple times)
404
+ * @param selectors - Array of selectors to extract properties from
405
+ * @returns Map of property names to their values
406
+ */
407
+ getUniqueProperties: (selectors: string[]) => Map<string, string>;
408
+ /**
409
+ * Gets a DOM-matchable selector by stripping pseudo-classes.
410
+ * Returns null if the selector contains pseudo-elements (unmatchable against real DOM).
411
+ * @param selector - The original CSS selector string
412
+ * @returns DOM-matchable selector string or null
413
+ */
414
+ getDomSelector: (selector: string) => string | null;
415
+ /**
416
+ * Determines the CSS property type for a custom property based on how it is used.
417
+ * If all usages of varName are within the same CSS property, returns that property name.
418
+ * If usages differ, returns the CSS data type inferred from the initial value
419
+ * ('color', 'length', 'number', or 'string').
420
+ * Returns undefined if the variable is never used via var().
421
+ * @param varName - The CSS variable name (with or without --)
422
+ * @param defaultValue - The initial value string of the custom property
423
+ */
424
+ getVarPropertyType: (varName: string, defaultValue: string) => string | undefined;
425
+ }
426
+
427
+ export declare interface CssPropertiesData {
428
+ relevant: string[];
429
+ }
430
+
431
+ declare interface CSSProperty {
432
+ name: string;
433
+ value: string;
434
+ /** CSS variable names referenced via var() in this property's value */
435
+ varRefs?: string[];
436
+ }
437
+
438
+ /**
439
+ * `custom` option
440
+ *
441
+ * @private This type is private and only exported as a temporary workaround
442
+ * for an open issue with TypeScript. It will be removed in a future release.
443
+ * See:
444
+ *
445
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
446
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
447
+ */
448
+ declare interface CustomClass {
449
+ new (message: string, options?: InstanceOptions): Error
450
+ subclass: unknown
451
+ }
452
+
453
+ declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
454
+
455
+ /**
456
+ * Resolved default value with its type.
457
+ * For literals (string, number, boolean, null), the value is the actual JavaScript value.
458
+ * For structured literals (object, array), the value is the parsed JavaScript value.
459
+ * For unresolvable values (references, expressions), we store the raw source text.
460
+ */
461
+ export declare type DefaultValue = {
462
+ kind: 'string';
463
+ value: string;
464
+ } | {
465
+ kind: 'number';
466
+ value: number;
467
+ } | {
468
+ kind: 'boolean';
469
+ value: boolean;
470
+ } | {
471
+ kind: 'null';
472
+ value: null;
473
+ } | {
474
+ kind: 'object';
475
+ value: Record<string, unknown>;
476
+ } | {
477
+ kind: 'array';
478
+ value: unknown[];
479
+ } | {
480
+ kind: 'unresolved';
481
+ value: string;
482
+ };
483
+
484
+ /**
485
+ * Represents an unexpected internal failure — a violated invariant or
486
+ * impossible state that should never occur during normal operation.
487
+ *
488
+ * Exit code 70 (EX_SOFTWARE) signals an internal software error.
489
+ */
490
+ export declare const DefectError: SpecificErrorClass< {
491
+ name: "cli";
492
+ isOptions: (options: unknown) => boolean;
493
+ getOptions: (options?: Options) => {
494
+ custom: string;
495
+ stack?: boolean;
496
+ cause?: boolean;
497
+ props?: boolean;
498
+ colors?: boolean;
499
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
500
+ header?: Styles | "";
501
+ classes?: {
502
+ readonly [errorName: string]: Omit<Options_3, "classes">;
503
+ } & {
504
+ readonly [errorName: string]: Omit<Options_2, "classes">;
505
+ };
506
+ exitCode?: number;
507
+ silent?: boolean;
508
+ timeout?: number;
509
+ log?: (message: string) => void;
510
+ };
511
+ instanceMethods: {
512
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
513
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
514
+ };
515
+ }[], {
516
+ phase: string;
517
+ isDefect: boolean;
518
+ exitCode: number;
519
+ }, CustomClass>;
520
+
521
+ /**
522
+ * Aggregate `errors` array
523
+ */
524
+ declare type DefinedAggregateErrors = readonly AggregateErrorOption[]
525
+
526
+ export declare interface DOMBinding {
527
+ element: string;
528
+ attribute: string;
529
+ concatenated: boolean;
530
+ elementId: string;
531
+ }
532
+
533
+ export { EditorReactComponent }
534
+
535
+ 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;
536
+
537
+ export declare class Err<T, E> implements IResult<T, E> {
538
+ readonly error: E;
539
+ constructor(error: E);
540
+ isOk(): this is Ok<T, E>;
541
+ isErr(): this is Err<T, E>;
542
+ map<A>(_f: (t: T) => A): Result<A, E>;
543
+ mapErr<U>(f: (e: E) => U): Result<T, U>;
544
+ andThrough<F>(_f: (t: T) => Result<unknown, F>): Result<T, E | F>;
545
+ andTee(_f: (t: T) => unknown): Result<T, E>;
546
+ orTee(f: (t: E) => unknown): Result<T, E>;
547
+ andThen<R extends Result<unknown, unknown>>(_f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
548
+ andThen<U, F>(_f: (t: T) => Result<U, F>): Result<U, E | F>;
549
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
550
+ orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
551
+ asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
552
+ asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
553
+ asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
554
+ unwrapOr<A>(v: A): T | A;
555
+ match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
556
+ safeUnwrap(): Generator<Err<never, E>, T>;
557
+ _unsafeUnwrap(config?: ErrorConfig): T;
558
+ _unsafeUnwrapErr(_?: ErrorConfig): E;
559
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
560
+ }
561
+
562
+ export declare function err<T = never, E extends string = string>(err: E): Err<T, E>;
563
+
564
+ export declare function err<T = never, E = unknown>(err: E): Err<T, E>;
565
+
566
+ export declare function err<T = never, E extends void = void>(err: void): Err<T, void>;
567
+
568
+ export declare function errAsync<T = never, E = unknown>(err: E): ResultAsync<T, E>;
569
+
570
+ export declare function errAsync<T = never, E extends void = void>(err: void): ResultAsync<T, void>;
571
+
572
+ /**
573
+ * Error class
574
+ */
575
+ declare type ErrorClass<PluginsArg extends Plugins = Plugins> =
576
+ SpecificErrorClass<PluginsArg, ErrorProps, CustomClass>
577
+
578
+ declare interface ErrorConfig {
579
+ withStackTrace: boolean;
580
+ }
581
+
582
+ /**
583
+ * Error instance object
584
+ */
585
+ declare type ErrorInstance<PluginsArg extends Plugins = Plugins> =
586
+ SpecificErrorInstance<
587
+ PluginsArg,
588
+ ErrorProps,
589
+ CustomClass,
590
+ AggregateErrors,
591
+ Cause
592
+ >
593
+
594
+ /**
595
+ * Bound instance method of a plugin
596
+ */
597
+ declare type ErrorInstanceMethod<
598
+ InstanceMethodArg extends InstanceMethod,
599
+ MethodOptionsArg extends MethodOptions<Plugin>,
600
+ > = (
601
+ ...args: ErrorInstanceMethodParams<InstanceMethodArg, MethodOptionsArg>
602
+ ) => ReturnType<InstanceMethodArg>
603
+
604
+ /**
605
+ * Bound instance method parameters
606
+ */
607
+ declare type ErrorInstanceMethodParams<
608
+ InstanceMethodArg extends InstanceMethod,
609
+ MethodOptionsArg extends MethodOptions<Plugin>,
610
+ > =
611
+ | SliceFirst<Parameters<InstanceMethodArg>>
612
+ | ([MethodOptionsArg] extends [never]
613
+ ? never
614
+ : readonly [
615
+ ...SliceFirst<Parameters<InstanceMethodArg>>,
616
+ MethodOptionsArg,
617
+ ])
618
+
619
+ /**
620
+ * Bound instance methods of a plugin, always defined
621
+ */
622
+ declare type ErrorInstanceMethods<
623
+ InstanceMethodsArg extends InstanceMethods,
624
+ MethodOptionsArg extends MethodOptions<Plugin>,
625
+ > = {
626
+ readonly [MethodName in keyof InstanceMethodsArg]: ErrorInstanceMethod<
627
+ InstanceMethodsArg[MethodName],
628
+ MethodOptionsArg
629
+ >
630
+ }
631
+
632
+ /**
633
+ * Bound mixed method of a plugin
634
+ */
635
+ declare type ErrorMixedMethod<
636
+ InstanceMethodArg extends InstanceMethod,
637
+ MethodOptionsArg extends MethodOptions<Plugin>,
638
+ > = (
639
+ ...args: ErrorMixedMethodParams<InstanceMethodArg, MethodOptionsArg>
640
+ ) => ReturnType<InstanceMethodArg>
641
+
642
+ /**
643
+ * Bound mixed method parameters
644
+ */
645
+ declare type ErrorMixedMethodParams<
646
+ InstanceMethodArg extends InstanceMethod,
647
+ MethodOptionsArg extends MethodOptions<Plugin>,
648
+ > =
649
+ | readonly [unknown, ...SliceFirst<Parameters<InstanceMethodArg>>]
650
+ | ([MethodOptionsArg] extends [never]
651
+ ? never
652
+ : readonly [
653
+ unknown,
654
+ ...SliceFirst<Parameters<InstanceMethodArg>>,
655
+ MethodOptionsArg,
656
+ ])
657
+
658
+ /**
659
+ * Bound mixed methods of a plugin, always defined
660
+ */
661
+ declare type ErrorMixedMethods<
662
+ InstanceMethodsArg extends InstanceMethods,
663
+ MethodOptionsArg extends MethodOptions<Plugin>,
664
+ > = {
665
+ readonly [MethodName in keyof InstanceMethodsArg]: ErrorMixedMethod<
666
+ InstanceMethodsArg[MethodName],
667
+ MethodOptionsArg
668
+ >
669
+ }
670
+
671
+ /**
672
+ * Error class name
673
+ */
674
+ declare type ErrorName = `${string}Error`
675
+
676
+ /**
677
+ * Error properties
678
+ */
679
+ declare type ErrorProps = object
680
+
681
+ /**
682
+ * Bound static method of a plugin
683
+ */
684
+ declare type ErrorStaticMethod<
685
+ StaticMethodArg extends StaticMethod,
686
+ MethodOptionsArg extends MethodOptions<Plugin>,
687
+ > = (
688
+ ...args: ErrorStaticMethodParams<StaticMethodArg, MethodOptionsArg>
689
+ ) => ReturnType<StaticMethodArg>
690
+
691
+ /**
692
+ * Bound static method parameters
693
+ */
694
+ declare type ErrorStaticMethodParams<
695
+ StaticMethodArg extends StaticMethod,
696
+ MethodOptionsArg extends MethodOptions<Plugin>,
697
+ > =
698
+ | SliceFirst<Parameters<StaticMethodArg>>
699
+ | ([MethodOptionsArg] extends [never]
700
+ ? never
701
+ : readonly [...SliceFirst<Parameters<StaticMethodArg>>, MethodOptionsArg])
702
+
703
+ /**
704
+ * Bound static methods of a plugin, always defined
705
+ */
706
+ declare type ErrorStaticMethods<
707
+ StaticMethodsArg extends StaticMethods,
708
+ MethodOptionsArg extends MethodOptions<Plugin>,
709
+ > = {
710
+ readonly [MethodName in keyof StaticMethodsArg]: ErrorStaticMethod<
711
+ StaticMethodsArg[MethodName],
712
+ MethodOptionsArg
713
+ >
714
+ }
715
+
716
+ /**
717
+ * Non-dynamic members of error classes
718
+ *
719
+ * @private This type is private and only exported as a temporary workaround
720
+ * for an open issue with TypeScript. It will be removed in a future release.
721
+ * See:
722
+ *
723
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
724
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
725
+ */
726
+ declare interface ErrorSubclassCore<
727
+ PluginsArg extends Plugins,
728
+ ErrorPropsArg extends ErrorProps,
729
+ CustomClassArg extends CustomClass,
730
+ > {
731
+ /**
732
+ * Error subclass
733
+ *
734
+ * @example
735
+ * ```js
736
+ * throw new InputError('Missing file path.')
737
+ * ```
738
+ */
739
+ new <
740
+ ChildProps extends ErrorProps = ErrorProps,
741
+ AggregateErrorsArg extends AggregateErrors = AggregateErrors,
742
+ CauseArg extends Cause = Cause,
743
+ >(
744
+ message: string,
745
+ options?: ParentInstanceOptions<
746
+ PluginsArg,
747
+ ChildProps,
748
+ CustomClassArg,
749
+ AggregateErrorsArg,
750
+ CauseArg
751
+ >,
752
+ ...extra: ParentExtra<CustomClassArg>
753
+ ): SpecificErrorInstance<
754
+ PluginsArg,
755
+ MergeErrorProps<ErrorPropsArg, ChildProps>,
756
+ CustomClassArg,
757
+ AggregateErrorsArg,
758
+ CauseArg
759
+ >
760
+
761
+ readonly prototype: InstanceType<
762
+ ErrorSubclassCore<PluginsArg, ErrorPropsArg, CustomClassArg>
763
+ >
764
+
765
+ /**
766
+ * Creates and returns a child `ErrorClass`.
767
+ *
768
+ * @example
769
+ * ```js
770
+ * export const InputError = ErrorClass.subclass('InputError', options)
771
+ * ```
772
+ */
773
+ subclass: CreateSubclass<PluginsArg, ErrorPropsArg, CustomClassArg>
774
+
775
+ /**
776
+ * Normalizes invalid errors.
777
+ *
778
+ * If `error` is an instance of `ErrorClass` (or one of its subclasses), it is
779
+ * left as is. Otherwise, it is converted to `NewErrorClass`, which defaults
780
+ * to `ErrorClass` itself.
781
+ *
782
+ * @example
783
+ * ```js
784
+ * try {
785
+ * throw 'Missing file path.'
786
+ * } catch (invalidError) {
787
+ * const normalizedError = BaseError.normalize(invalidError)
788
+ * // This works: 'Missing file path.'
789
+ * // `normalizedError` is a `BaseError` instance.
790
+ * console.log(normalizedError.message.trim())
791
+ * }
792
+ * ```
793
+ */
794
+ normalize: NormalizeError<PluginsArg, ErrorPropsArg, CustomClassArg>
795
+ }
796
+
797
+ /**
798
+ * Options of a plugin
799
+ */
800
+ declare type ExternalPluginOptions<PluginArg extends Plugin> =
801
+ PluginArg extends Plugin
802
+ ? PluginArg['getOptions'] extends NonNullable<Plugin['getOptions']>
803
+ ? Parameters<PluginArg['getOptions']>[0]
804
+ : never
805
+ : never
806
+
807
+ /**
808
+ * Options of all non-core plugins
809
+ */
810
+ declare type ExternalPluginsOptions<PluginsArg extends Plugins> = {
811
+ readonly [PluginArg in PluginsArg[number] as PluginOptionName<PluginArg>]?: ExternalPluginOptions<PluginArg>
812
+ }
813
+
814
+ export declare function extractAllComponentInfo(program: default_2.Program, filePath: string): ComponentInfo[];
815
+
816
+ export declare function extractComponentManifest(componentPath: string, compiledEntryPath: string, options?: ExtractComponentManifestOptions): ResultAsync<ManifestResult, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>>;
817
+
818
+ /**
819
+ * Extract component manifest from a TypeScript source file.
820
+ *
821
+ * @param componentPath - Path to the TypeScript source file
822
+ * @param compiledEntryPath - Path to the built JS entry file of the component's package (e.g. dist/index.js)
823
+ * @param options.onError - Called for each non-fatal extraction error as it occurs
824
+ * @errors
825
+ * - {@link NotFoundError} — Source file does not exist (phase: `compile`)
826
+ * - {@link ParseError} — TypeScript config or component types could not be parsed (phase: `compile` | `extract`)
827
+ */
828
+ export declare interface ExtractComponentManifestOptions extends RunExtractorsOptions {
829
+ onError?: (error: ExtractionError) => void;
830
+ }
831
+
832
+ export declare function extractCssImports(program: Program): string[];
833
+
834
+ /**
835
+ * Extracts component info for only the default-exported component in a file.
836
+ * Returns `undefined` if the file has no default export or if the default export
837
+ * is not a recognized React component.
838
+ *
839
+ * Handles the re-export case where the entry file only re-exports the component
840
+ * from another file (e.g. `export { Foo as default } from './Foo'`). In that
841
+ * situation react-docgen-typescript finds no component in the entry file, so we
842
+ * follow the re-export to the defining file and extract from there instead.
843
+ */
844
+ export declare function extractDefaultComponentInfo(program: default_2.Program, filePath: string): ComponentInfo | undefined;
845
+
846
+ export declare interface ExtractedCssInfo {
847
+ filePath: string;
848
+ api: CSSParserAPI;
849
+ properties: Map<string, string>;
850
+ customProperties: Map<string, string>;
851
+ isCssModule: boolean;
852
+ }
853
+
854
+ export declare interface ExtractedElement {
855
+ traceId: string;
856
+ name: string;
857
+ tag: string;
858
+ attributes: Record<string, string>;
859
+ extractorData: Map<string, unknown>;
860
+ children: ExtractedElement[];
861
+ hasTextContent?: boolean;
862
+ }
863
+
864
+ declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
865
+ [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never;
866
+ };
867
+
868
+ declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = {
869
+ [idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never;
870
+ };
871
+
872
+ /** A non-fatal issue encountered during component extraction. */
873
+ export declare interface ExtractionError {
874
+ componentName: string;
875
+ phase: 'render' | 'coupling' | 'css' | 'loader' | 'conversion';
876
+ error: InstanceType<typeof BaseError>;
877
+ }
878
+
879
+ export declare interface ExtractionResult {
880
+ html: string;
881
+ store: ExtractorStore;
882
+ elements: ExtractedElement[];
883
+ }
884
+
885
+ declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
886
+ [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never;
887
+ };
888
+
889
+ declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = {
890
+ [idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never;
891
+ };
892
+
893
+ /**
894
+ * ExtractorStore - Shared store for extractors with namespace support
895
+ *
896
+ * Extractors write to this store during render, namespaced by their name:
897
+ * store.set(traceId, 'prop-tracker', { boundProps: ['label', 'onClick'] })
898
+ * store.set(traceId, 'css-properties', { relevant: ['color', 'background'] })
899
+ *
900
+ * Store structure: Map<traceId, Map<extractorName, data>>
901
+ */
902
+ export declare class ExtractorStore {
903
+ private data;
904
+ set<T>(traceId: string, extractorName: string, value: T): void;
905
+ get<T>(traceId: string, extractorName: string): T | undefined;
906
+ getAll(traceId: string): Map<string, unknown> | undefined;
907
+ entries(): IterableIterator<[string, Map<string, unknown>]>;
908
+ clear(): void;
909
+ }
910
+
911
+ declare const figureSet: {
912
+ readonly tick: string;
913
+ readonly info: string;
914
+ readonly warning: string;
915
+ readonly cross: string;
916
+ readonly square: string;
917
+ readonly squareSmall: string;
918
+ readonly squareSmallFilled: string;
919
+ readonly squareDarkShade: string;
920
+ readonly squareMediumShade: string;
921
+ readonly squareLightShade: string;
922
+ readonly squareTop: string;
923
+ readonly squareBottom: string;
924
+ readonly squareLeft: string;
925
+ readonly squareRight: string;
926
+ readonly squareCenter: string;
927
+ readonly circle: string;
928
+ readonly circleFilled: string;
929
+ readonly circleDotted: string;
930
+ readonly circleDouble: string;
931
+ readonly circleCircle: string;
932
+ readonly circleCross: string;
933
+ readonly circlePipe: string;
934
+ readonly circleQuestionMark: string;
935
+ readonly radioOn: string;
936
+ readonly radioOff: string;
937
+ readonly checkboxOn: string;
938
+ readonly checkboxOff: string;
939
+ readonly checkboxCircleOn: string;
940
+ readonly checkboxCircleOff: string;
941
+ readonly questionMarkPrefix: string;
942
+ readonly bullet: string;
943
+ readonly dot: string;
944
+ readonly ellipsis: string;
945
+ readonly pointer: string;
946
+ readonly pointerSmall: string;
947
+ readonly triangleUp: string;
948
+ readonly triangleUpSmall: string;
949
+ readonly triangleUpOutline: string;
950
+ readonly triangleDown: string;
951
+ readonly triangleDownSmall: string;
952
+ readonly triangleLeft: string;
953
+ readonly triangleLeftSmall: string;
954
+ readonly triangleRight: string;
955
+ readonly triangleRightSmall: string;
956
+ readonly lozenge: string;
957
+ readonly lozengeOutline: string;
958
+ readonly home: string;
959
+ readonly hamburger: string;
960
+ readonly smiley: string;
961
+ readonly mustache: string;
962
+ readonly heart: string;
963
+ readonly star: string;
964
+ readonly play: string;
965
+ readonly musicNote: string;
966
+ readonly musicNoteBeamed: string;
967
+ readonly nodejs: string;
968
+ readonly arrowUp: string;
969
+ readonly arrowDown: string;
970
+ readonly arrowLeft: string;
971
+ readonly arrowRight: string;
972
+ readonly arrowLeftRight: string;
973
+ readonly arrowUpDown: string;
974
+ readonly almostEqual: string;
975
+ readonly notEqual: string;
976
+ readonly lessOrEqual: string;
977
+ readonly greaterOrEqual: string;
978
+ readonly identical: string;
979
+ readonly infinity: string;
980
+ readonly subscriptZero: string;
981
+ readonly subscriptOne: string;
982
+ readonly subscriptTwo: string;
983
+ readonly subscriptThree: string;
984
+ readonly subscriptFour: string;
985
+ readonly subscriptFive: string;
986
+ readonly subscriptSix: string;
987
+ readonly subscriptSeven: string;
988
+ readonly subscriptEight: string;
989
+ readonly subscriptNine: string;
990
+ readonly oneHalf: string;
991
+ readonly oneThird: string;
992
+ readonly oneQuarter: string;
993
+ readonly oneFifth: string;
994
+ readonly oneSixth: string;
995
+ readonly oneSeventh: string;
996
+ readonly oneEighth: string;
997
+ readonly oneNinth: string;
998
+ readonly oneTenth: string;
999
+ readonly twoThirds: string;
1000
+ readonly twoFifths: string;
1001
+ readonly threeQuarters: string;
1002
+ readonly threeFifths: string;
1003
+ readonly threeEighths: string;
1004
+ readonly fourFifths: string;
1005
+ readonly fiveSixths: string;
1006
+ readonly fiveEighths: string;
1007
+ readonly sevenEighth: string;
1008
+ readonly line: string;
1009
+ readonly lineBold: string;
1010
+ readonly lineDouble: string;
1011
+ readonly lineDashed0: string;
1012
+ readonly lineDashed1: string;
1013
+ readonly lineDashed2: string;
1014
+ readonly lineDashed3: string;
1015
+ readonly lineDashed4: string;
1016
+ readonly lineDashed5: string;
1017
+ readonly lineDashed6: string;
1018
+ readonly lineDashed7: string;
1019
+ readonly lineDashed8: string;
1020
+ readonly lineDashed9: string;
1021
+ readonly lineDashed10: string;
1022
+ readonly lineDashed11: string;
1023
+ readonly lineDashed12: string;
1024
+ readonly lineDashed13: string;
1025
+ readonly lineDashed14: string;
1026
+ readonly lineDashed15: string;
1027
+ readonly lineVertical: string;
1028
+ readonly lineVerticalBold: string;
1029
+ readonly lineVerticalDouble: string;
1030
+ readonly lineVerticalDashed0: string;
1031
+ readonly lineVerticalDashed1: string;
1032
+ readonly lineVerticalDashed2: string;
1033
+ readonly lineVerticalDashed3: string;
1034
+ readonly lineVerticalDashed4: string;
1035
+ readonly lineVerticalDashed5: string;
1036
+ readonly lineVerticalDashed6: string;
1037
+ readonly lineVerticalDashed7: string;
1038
+ readonly lineVerticalDashed8: string;
1039
+ readonly lineVerticalDashed9: string;
1040
+ readonly lineVerticalDashed10: string;
1041
+ readonly lineVerticalDashed11: string;
1042
+ readonly lineDownLeft: string;
1043
+ readonly lineDownLeftArc: string;
1044
+ readonly lineDownBoldLeftBold: string;
1045
+ readonly lineDownBoldLeft: string;
1046
+ readonly lineDownLeftBold: string;
1047
+ readonly lineDownDoubleLeftDouble: string;
1048
+ readonly lineDownDoubleLeft: string;
1049
+ readonly lineDownLeftDouble: string;
1050
+ readonly lineDownRight: string;
1051
+ readonly lineDownRightArc: string;
1052
+ readonly lineDownBoldRightBold: string;
1053
+ readonly lineDownBoldRight: string;
1054
+ readonly lineDownRightBold: string;
1055
+ readonly lineDownDoubleRightDouble: string;
1056
+ readonly lineDownDoubleRight: string;
1057
+ readonly lineDownRightDouble: string;
1058
+ readonly lineUpLeft: string;
1059
+ readonly lineUpLeftArc: string;
1060
+ readonly lineUpBoldLeftBold: string;
1061
+ readonly lineUpBoldLeft: string;
1062
+ readonly lineUpLeftBold: string;
1063
+ readonly lineUpDoubleLeftDouble: string;
1064
+ readonly lineUpDoubleLeft: string;
1065
+ readonly lineUpLeftDouble: string;
1066
+ readonly lineUpRight: string;
1067
+ readonly lineUpRightArc: string;
1068
+ readonly lineUpBoldRightBold: string;
1069
+ readonly lineUpBoldRight: string;
1070
+ readonly lineUpRightBold: string;
1071
+ readonly lineUpDoubleRightDouble: string;
1072
+ readonly lineUpDoubleRight: string;
1073
+ readonly lineUpRightDouble: string;
1074
+ readonly lineUpDownLeft: string;
1075
+ readonly lineUpBoldDownBoldLeftBold: string;
1076
+ readonly lineUpBoldDownBoldLeft: string;
1077
+ readonly lineUpDownLeftBold: string;
1078
+ readonly lineUpBoldDownLeftBold: string;
1079
+ readonly lineUpDownBoldLeftBold: string;
1080
+ readonly lineUpDownBoldLeft: string;
1081
+ readonly lineUpBoldDownLeft: string;
1082
+ readonly lineUpDoubleDownDoubleLeftDouble: string;
1083
+ readonly lineUpDoubleDownDoubleLeft: string;
1084
+ readonly lineUpDownLeftDouble: string;
1085
+ readonly lineUpDownRight: string;
1086
+ readonly lineUpBoldDownBoldRightBold: string;
1087
+ readonly lineUpBoldDownBoldRight: string;
1088
+ readonly lineUpDownRightBold: string;
1089
+ readonly lineUpBoldDownRightBold: string;
1090
+ readonly lineUpDownBoldRightBold: string;
1091
+ readonly lineUpDownBoldRight: string;
1092
+ readonly lineUpBoldDownRight: string;
1093
+ readonly lineUpDoubleDownDoubleRightDouble: string;
1094
+ readonly lineUpDoubleDownDoubleRight: string;
1095
+ readonly lineUpDownRightDouble: string;
1096
+ readonly lineDownLeftRight: string;
1097
+ readonly lineDownBoldLeftBoldRightBold: string;
1098
+ readonly lineDownLeftBoldRightBold: string;
1099
+ readonly lineDownBoldLeftRight: string;
1100
+ readonly lineDownBoldLeftBoldRight: string;
1101
+ readonly lineDownBoldLeftRightBold: string;
1102
+ readonly lineDownLeftRightBold: string;
1103
+ readonly lineDownLeftBoldRight: string;
1104
+ readonly lineDownDoubleLeftDoubleRightDouble: string;
1105
+ readonly lineDownDoubleLeftRight: string;
1106
+ readonly lineDownLeftDoubleRightDouble: string;
1107
+ readonly lineUpLeftRight: string;
1108
+ readonly lineUpBoldLeftBoldRightBold: string;
1109
+ readonly lineUpLeftBoldRightBold: string;
1110
+ readonly lineUpBoldLeftRight: string;
1111
+ readonly lineUpBoldLeftBoldRight: string;
1112
+ readonly lineUpBoldLeftRightBold: string;
1113
+ readonly lineUpLeftRightBold: string;
1114
+ readonly lineUpLeftBoldRight: string;
1115
+ readonly lineUpDoubleLeftDoubleRightDouble: string;
1116
+ readonly lineUpDoubleLeftRight: string;
1117
+ readonly lineUpLeftDoubleRightDouble: string;
1118
+ readonly lineUpDownLeftRight: string;
1119
+ readonly lineUpBoldDownBoldLeftBoldRightBold: string;
1120
+ readonly lineUpDownBoldLeftBoldRightBold: string;
1121
+ readonly lineUpBoldDownLeftBoldRightBold: string;
1122
+ readonly lineUpBoldDownBoldLeftRightBold: string;
1123
+ readonly lineUpBoldDownBoldLeftBoldRight: string;
1124
+ readonly lineUpBoldDownLeftRight: string;
1125
+ readonly lineUpDownBoldLeftRight: string;
1126
+ readonly lineUpDownLeftBoldRight: string;
1127
+ readonly lineUpDownLeftRightBold: string;
1128
+ readonly lineUpBoldDownBoldLeftRight: string;
1129
+ readonly lineUpDownLeftBoldRightBold: string;
1130
+ readonly lineUpBoldDownLeftBoldRight: string;
1131
+ readonly lineUpBoldDownLeftRightBold: string;
1132
+ readonly lineUpDownBoldLeftBoldRight: string;
1133
+ readonly lineUpDownBoldLeftRightBold: string;
1134
+ readonly lineUpDoubleDownDoubleLeftDoubleRightDouble: string;
1135
+ readonly lineUpDoubleDownDoubleLeftRight: string;
1136
+ readonly lineUpDownLeftDoubleRightDouble: string;
1137
+ readonly lineCross: string;
1138
+ readonly lineBackslash: string;
1139
+ readonly lineSlash: string;
1140
+ };
1141
+
1142
+ export declare function findComponent(moduleExports: Record<string, unknown>, name: string): ComponentType<unknown> | null;
1143
+
1144
+ /**
1145
+ * `plugin.getOptions()` method
1146
+ */
1147
+ declare type GetOptions = (input: never, full: boolean) => unknown
1148
+
1149
+ /**
1150
+ * Bound added properties of a plugin, always defined
1151
+ */
1152
+ declare type GetProperties = (info: InfoParameter['properties']) => AddedProperties
1153
+
1154
+ declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
1155
+
1156
+ declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
1157
+
1158
+ declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;
1159
+
1160
+ declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;
1161
+
1162
+ /**
1163
+ * `info` is a plain object passed as the first argument to `properties()`,
1164
+ * instance methods and static methods.
1165
+ *
1166
+ * Its members are readonly and should not be mutated, except for `info.error`
1167
+ * inside instance methods (not inside `properties()`).
1168
+ */
1169
+ declare interface Info<Options = never> {
1170
+ /**
1171
+ * `info` object passed to `plugin.properties()`
1172
+ */
1173
+ readonly properties: CommonInfo<Options>
1174
+
1175
+ /**
1176
+ * `info` object passed to `plugin.instanceMethods.*()`
1177
+ */
1178
+ readonly instanceMethods: CommonInfo<Options>
1179
+
1180
+ /**
1181
+ * `info` object passed to `plugin.staticMethods.*()`
1182
+ */
1183
+ readonly staticMethods: Omit<CommonInfo<Options>, 'error'>
1184
+
1185
+ /**
1186
+ * `info` object returned by `errorInfo()`
1187
+ */
1188
+ readonly errorInfo: Omit<CommonInfo<Options>, 'errorInfo'>
1189
+ }
1190
+
1191
+ /**
1192
+ * `info` parameter. Unlike `Info`, this is not meant for plugin declarations,
1193
+ * but for plugin consumption.
1194
+ */
1195
+ declare type InfoParameter = {
1196
+ readonly [InfoName in keyof Info]: UntypedInfo<Info[InfoName]>
1197
+ }
1198
+
1199
+ /**
1200
+ * Unbound instance method of a plugin
1201
+ */
1202
+ declare type InstanceMethod = (
1203
+ info: InfoParameter['instanceMethods'],
1204
+ ...args: readonly never[]
1205
+ ) => unknown
1206
+
1207
+ /**
1208
+ * Unbound instance methods of a plugin
1209
+ */
1210
+ declare interface InstanceMethods {
1211
+ readonly [MethodName: string]: InstanceMethod
1212
+ }
1213
+
1214
+ /**
1215
+ * Options passed to error constructors: `new ErrorClass('message', options)`
1216
+ */
1217
+ declare type InstanceOptions<PluginsArg extends Plugins = Plugins> =
1218
+ SpecificInstanceOptions<PluginsArg, ErrorProps, AggregateErrors, Cause>
1219
+
1220
+ /** File system or network I/O failed (permissions, disk full, timeout). */
1221
+ export declare const IoError: SpecificErrorClass< {
1222
+ name: "cli";
1223
+ isOptions: (options: unknown) => boolean;
1224
+ getOptions: (options?: Options) => {
1225
+ custom: string;
1226
+ stack?: boolean;
1227
+ cause?: boolean;
1228
+ props?: boolean;
1229
+ colors?: boolean;
1230
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
1231
+ header?: Styles | "";
1232
+ classes?: {
1233
+ readonly [errorName: string]: Omit<Options_3, "classes">;
1234
+ } & {
1235
+ readonly [errorName: string]: Omit<Options_2, "classes">;
1236
+ };
1237
+ exitCode?: number;
1238
+ silent?: boolean;
1239
+ timeout?: number;
1240
+ log?: (message: string) => void;
1241
+ };
1242
+ instanceMethods: {
1243
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
1244
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
1245
+ };
1246
+ }[], {
1247
+ /** Pipeline stage where the error originated (composed at runtime). */
1248
+ phase: string;
1249
+ /** True if this error represents a violated invariant, not a user error. */
1250
+ isDefect: boolean;
1251
+ /** Process exit code used by BaseError.exit(). */
1252
+ exitCode: number;
1253
+ } & object, CustomClass>;
1254
+
1255
+ declare interface IResult<T, E> {
1256
+ /**
1257
+ * Used to check if a `Result` is an `OK`
1258
+ *
1259
+ * @returns `true` if the result is an `OK` variant of Result
1260
+ */
1261
+ isOk(): this is Ok<T, E>;
1262
+ /**
1263
+ * Used to check if a `Result` is an `Err`
1264
+ *
1265
+ * @returns `true` if the result is an `Err` variant of Result
1266
+ */
1267
+ isErr(): this is Err<T, E>;
1268
+ /**
1269
+ * Maps a `Result<T, E>` to `Result<U, E>`
1270
+ * by applying a function to a contained `Ok` value, leaving an `Err` value
1271
+ * untouched.
1272
+ *
1273
+ * @param f The function to apply an `OK` value
1274
+ * @returns the result of applying `f` or an `Err` untouched
1275
+ */
1276
+ map<A>(f: (t: T) => A): Result<A, E>;
1277
+ /**
1278
+ * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
1279
+ * contained `Err` value, leaving an `Ok` value untouched.
1280
+ *
1281
+ * This function can be used to pass through a successful result while
1282
+ * handling an error.
1283
+ *
1284
+ * @param f a function to apply to the error `Err` value
1285
+ */
1286
+ mapErr<U>(f: (e: E) => U): Result<T, U>;
1287
+ /**
1288
+ * Similar to `map` Except you must return a new `Result`.
1289
+ *
1290
+ * This is useful for when you need to do a subsequent computation using the
1291
+ * inner `T` value, but that computation might fail.
1292
+ * Additionally, `andThen` is really useful as a tool to flatten a
1293
+ * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
1294
+ *
1295
+ * @param f The function to apply to the current value
1296
+ */
1297
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
1298
+ andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
1299
+ /**
1300
+ * This "tee"s the current value to an passed-in computation such as side
1301
+ * effect functions but still returns the same current value as the result.
1302
+ *
1303
+ * This is useful when you want to pass the current result to your side-track
1304
+ * work such as logging but want to continue main-track work after that.
1305
+ * This method does not care about the result of the passed in computation.
1306
+ *
1307
+ * @param f The function to apply to the current value
1308
+ */
1309
+ andTee(f: (t: T) => unknown): Result<T, E>;
1310
+ /**
1311
+ * This "tee"s the current `Err` value to an passed-in computation such as side
1312
+ * effect functions but still returns the same `Err` value as the result.
1313
+ *
1314
+ * This is useful when you want to pass the current `Err` value to your side-track
1315
+ * work such as logging but want to continue error-track work after that.
1316
+ * This method does not care about the result of the passed in computation.
1317
+ *
1318
+ * @param f The function to apply to the current `Err` value
1319
+ */
1320
+ orTee(f: (t: E) => unknown): Result<T, E>;
1321
+ /**
1322
+ * Similar to `andTee` except error result of the computation will be passed
1323
+ * to the downstream in case of an error.
1324
+ *
1325
+ * This version is useful when you want to make side-effects but in case of an
1326
+ * error, you want to pass the error to the downstream.
1327
+ *
1328
+ * @param f The function to apply to the current value
1329
+ */
1330
+ andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
1331
+ andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
1332
+ /**
1333
+ * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
1334
+ *
1335
+ * This is useful for error recovery.
1336
+ *
1337
+ *
1338
+ * @param f A function to apply to an `Err` value, leaving `Ok` values
1339
+ * untouched.
1340
+ */
1341
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
1342
+ orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
1343
+ /**
1344
+ * Similar to `map` Except you must return a new `Result`.
1345
+ *
1346
+ * This is useful for when you need to do a subsequent async computation using
1347
+ * the inner `T` value, but that computation might fail. Must return a ResultAsync
1348
+ *
1349
+ * @param f The function that returns a `ResultAsync` to apply to the current
1350
+ * value
1351
+ */
1352
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
1353
+ /**
1354
+ * Maps a `Result<T, E>` to `ResultAsync<U, E>`
1355
+ * by applying an async function to a contained `Ok` value, leaving an `Err`
1356
+ * value untouched.
1357
+ *
1358
+ * @param f An async function to apply an `OK` value
1359
+ */
1360
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
1361
+ /**
1362
+ * Unwrap the `Ok` value, or return the default if there is an `Err`
1363
+ *
1364
+ * @param v the default value to return if there is an `Err`
1365
+ */
1366
+ unwrapOr<A>(v: A): T | A;
1367
+ /**
1368
+ *
1369
+ * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
1370
+ * execute the function that matches the `Result` variant.
1371
+ *
1372
+ * Match callbacks do not necessitate to return a `Result`, however you can
1373
+ * return a `Result` if you want to.
1374
+ *
1375
+ * `match` is like chaining `map` and `mapErr`, with the distinction that
1376
+ * with `match` both functions must have the same return type.
1377
+ *
1378
+ * @param ok
1379
+ * @param err
1380
+ */
1381
+ match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
1382
+ /**
1383
+ * @deprecated will be removed in 9.0.0.
1384
+ *
1385
+ * You can use `safeTry` without this method.
1386
+ * @example
1387
+ * ```typescript
1388
+ * safeTry(function* () {
1389
+ * const okValue = yield* yourResult
1390
+ * })
1391
+ * ```
1392
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
1393
+ */
1394
+ safeUnwrap(): Generator<Err<never, E>, T>;
1395
+ /**
1396
+ * **This method is unsafe, and should only be used in a test environments**
1397
+ *
1398
+ * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
1399
+ *
1400
+ * @param config
1401
+ */
1402
+ _unsafeUnwrap(config?: ErrorConfig): T;
1403
+ /**
1404
+ * **This method is unsafe, and should only be used in a test environments**
1405
+ *
1406
+ * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
1407
+ * otherwise it throws a custom object.
1408
+ *
1409
+ * @param config
1410
+ */
1411
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
1412
+ }
1413
+
1414
+ declare type IsLiteralArray<T> = T extends {
1415
+ length: infer L;
1416
+ } ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
1417
+
1418
+ /**
1419
+ * `plugin.isOptions()` method
1420
+ */
1421
+ declare type IsOptions = (input: unknown) => boolean
1422
+
1423
+ /**
1424
+ * Class-specific options, excluding plugin options
1425
+ */
1426
+ declare interface KnownClassOptions<
1427
+ ChildPlugins extends Plugins,
1428
+ ChildCustomClass extends CustomClass,
1429
+ > {
1430
+ /**
1431
+ * Plugins to add.
1432
+ *
1433
+ * @example
1434
+ * ```js
1435
+ * import modernErrorsBugs from 'modern-errors-bugs'
1436
+ * import modernErrorsSerialize from 'modern-errors-serialize'
1437
+ *
1438
+ * export const BaseError = ModernError.subclass('BaseError', {
1439
+ * plugins: [modernErrorsBugs, modernErrorsSerialize],
1440
+ * })
1441
+ * ```
1442
+ */
1443
+ readonly plugins?: ChildPlugins
1444
+
1445
+ /**
1446
+ * Custom class to add any methods, `constructor` or properties.
1447
+ *
1448
+ * @example
1449
+ * ```js
1450
+ * export const InputError = BaseError.subclass('InputError', {
1451
+ * // The `class` must extend from the parent error class
1452
+ * custom: class extends BaseError {
1453
+ * // If a `constructor` is defined, its parameters must be (message, options)
1454
+ * constructor(message, options) {
1455
+ * message += message.endsWith('.') ? '' : '.'
1456
+ * super(message, options)
1457
+ * }
1458
+ *
1459
+ * isUserInput() {
1460
+ * // ...
1461
+ * }
1462
+ * },
1463
+ * })
1464
+ *
1465
+ * const error = new InputError('Wrong user name')
1466
+ * console.log(error.message) // 'Wrong user name.'
1467
+ * console.log(error.isUserInput())
1468
+ * ```
1469
+ */
1470
+ readonly custom?: ChildCustomClass
1471
+ }
1472
+
1473
+ /**
1474
+ * Attempts to load a module, first via ESM `import()`, then via CJS `require`.
1475
+ *
1476
+ * ESM `import()` is preferred because it participates in the ESM loader hook
1477
+ * pipeline (registered via `module.register()` in the CLI). This is required
1478
+ * for JSX interception to work — the loader hook redirects `react/jsx-runtime`
1479
+ * to the interceptable version. CJS `require()` bypasses ESM hooks even when
1480
+ * loading ESM modules (Node 22+), so it's only used as a fallback.
1481
+ *
1482
+ * @param entryPath - Absolute path to the module entry point.
1483
+ * @returns A `ResultAsync` containing the module exports on success.
1484
+ * @errors {LoadModuleFailure} When both ESM import and CJS require fail.
1485
+ */
1486
+ export declare function loadModule(entryPath: string): ResultAsync<Record<string, unknown>, LoadModuleFailure>;
1487
+
1488
+ /**
1489
+ * Structured failure from `loadModule` when both ESM import and CJS require fail.
1490
+ * Carries each error separately so callers can report them independently.
1491
+ */
1492
+ export declare interface LoadModuleFailure {
1493
+ /** The ESM import error, or null when no ESM was attempted (e.g. empty path). */
1494
+ esmError: Error | null;
1495
+ /** The CJS require error, or a generic error for the empty-path case. */
1496
+ cjsError: Error;
1497
+ }
1498
+
1499
+ /**
1500
+ * Options passed to error constructors, excluding any plugin options
1501
+ */
1502
+ declare interface MainInstanceOptions<
1503
+ AggregateErrorsArg extends AggregateErrors,
1504
+ CauseArg extends Cause,
1505
+ > {
1506
+ /**
1507
+ * The `errors` option aggregates multiple errors into one. This is like
1508
+ * [`new AggregateError(errors)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/AggregateError)
1509
+ * except that it works with any error class.
1510
+ *
1511
+ * @example
1512
+ * ```js
1513
+ * const databaseError = new DatabaseError('...')
1514
+ * const authError = new AuthError('...')
1515
+ * throw new InputError('...', { errors: [databaseError, authError] })
1516
+ * // InputError: ... {
1517
+ * // [errors]: [
1518
+ * // DatabaseError: ...
1519
+ * // AuthError: ...
1520
+ * // ]
1521
+ * // }
1522
+ * ```
1523
+ */
1524
+ readonly errors?: AggregateErrorsArg
1525
+
1526
+ /**
1527
+ * Any error's message, class and options can be wrapped using the
1528
+ * [standard `cause` option](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause).
1529
+ *
1530
+ * Instead of being set as a `cause` property, the inner error is directly
1531
+ * [merged](https://github.com/ehmicky/merge-error-cause) to the outer error,
1532
+ * including its
1533
+ * [`message`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message),
1534
+ * [`stack`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack),
1535
+ * [`name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name),
1536
+ * [`AggregateError.errors`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError)
1537
+ * and any [additional property](#%EF%B8%8F-error-properties).
1538
+ *
1539
+ * @example
1540
+ * ```js
1541
+ * try {
1542
+ * // ...
1543
+ * } catch (cause) {
1544
+ * throw new InputError('Could not read the file.', { cause })
1545
+ * }
1546
+ * ```
1547
+ */
1548
+ readonly cause?: CauseArg
1549
+ }
1550
+
1551
+ export declare interface ManifestResult {
1552
+ component: EditorReactComponent;
1553
+ errors: ExtractionError[];
1554
+ }
1555
+
1556
+ 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] : [];
1557
+
1558
+ declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
1559
+
1560
+ /**
1561
+ * Merge error `props` from the class options and instance options
1562
+ */
1563
+ declare type MergeErrorProps<
1564
+ PropsOne extends ErrorProps,
1565
+ PropsTwo extends ErrorProps,
1566
+ > = SimpleSetProps<PropsOne, PropsTwo>
1567
+
1568
+ /**
1569
+ * Options passed to plugin methods:
1570
+ * `ErrorClass.{staticMethod}(..., options)`,
1571
+ * `ErrorClass.{instanceMethod}(error, ..., options)` or
1572
+ * `error.{instanceMethod}(..., options)`
1573
+ */
1574
+ declare type MethodOptions<PluginArg extends Plugin> =
1575
+ ExternalPluginOptions<PluginArg>
1576
+
1577
+ /**
1578
+ * Normalize each error in the `errors` option to `Error` instances
1579
+ */
1580
+ declare type NormalizeAggregateError<ErrorArg extends AggregateErrorOption> =
1581
+ ErrorArg extends Error ? ErrorArg : Error
1582
+
1583
+ /**
1584
+ * Normalize all errors in the `errors` option to `Error` instances
1585
+ */
1586
+ declare type NormalizeAggregateErrors<
1587
+ AggregateErrorsArg extends DefinedAggregateErrors,
1588
+ > = AggregateErrorsArg extends never[]
1589
+ ? []
1590
+ : AggregateErrorsArg extends readonly [
1591
+ infer AggregateErrorArg extends AggregateErrorOption,
1592
+ ...infer Rest extends DefinedAggregateErrors,
1593
+ ]
1594
+ ? [
1595
+ NormalizeAggregateError<AggregateErrorArg>,
1596
+ ...NormalizeAggregateErrors<Rest>,
1597
+ ]
1598
+ : NormalizeAggregateError<AggregateErrorsArg[number]>[]
1599
+
1600
+ /**
1601
+ * The `cause` option, as used when merged to the error instance
1602
+ */
1603
+ declare type NormalizedCause<CauseArg extends Cause> = CauseArg extends Error
1604
+ ? CauseArg
1605
+ : object
1606
+
1607
+ /**
1608
+ * Apply `ErrorClass.normalize()` on both `error` and `error.errors`
1609
+ */
1610
+ declare type NormalizeDeepError<
1611
+ ErrorArg,
1612
+ ParentError extends ErrorInstance,
1613
+ NewError extends ErrorInstance,
1614
+ > = ErrorArg extends {
1615
+ errors: infer AggregateErrorsArg extends DefinedAggregateErrors
1616
+ }
1617
+ ? Omit<NormalizeOneError<ErrorArg, ParentError, NewError>, 'errors'> & {
1618
+ errors: NormalizeManyErrors<AggregateErrorsArg, ParentError, NewError>
1619
+ }
1620
+ : NormalizeOneError<ErrorArg, ParentError, NewError>
1621
+
1622
+ /**
1623
+ * `ErrorClass.normalize()`.
1624
+ *
1625
+ * @private This type is private and only exported as a temporary workaround
1626
+ * for an open issue with TypeScript. It will be removed in a future release.
1627
+ * See:
1628
+ *
1629
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
1630
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
1631
+ */
1632
+ declare type NormalizeError<
1633
+ PluginsArg extends Plugins,
1634
+ ErrorPropsArg extends ErrorProps,
1635
+ CustomClassArg extends CustomClass,
1636
+ > = <
1637
+ ErrorArg,
1638
+ NewErrorClass extends SpecificErrorClass<
1639
+ PluginsArg,
1640
+ ErrorPropsArg,
1641
+ CustomClassArg
1642
+ > = SpecificErrorClass<PluginsArg, ErrorPropsArg, CustomClassArg>,
1643
+ >(
1644
+ error: ErrorArg,
1645
+ NewErrorClass?: NewErrorClass,
1646
+ ) => NormalizeDeepError<
1647
+ ErrorArg,
1648
+ InstanceType<SpecificErrorClass<PluginsArg, ErrorPropsArg, CustomClassArg>> &
1649
+ ErrorInstance,
1650
+ InstanceType<NewErrorClass> & ErrorInstance
1651
+ >
1652
+
1653
+ /**
1654
+ * Apply `ErrorClass.normalize()` on `error.errors`
1655
+ */
1656
+ declare type NormalizeManyErrors<
1657
+ AggregateErrorsArg extends DefinedAggregateErrors,
1658
+ ParentError extends ErrorInstance,
1659
+ NewError extends ErrorInstance,
1660
+ > = AggregateErrorsArg extends never[]
1661
+ ? []
1662
+ : AggregateErrorsArg extends readonly [
1663
+ infer AggregateErrorArg extends AggregateErrorOption,
1664
+ ...infer Rest extends DefinedAggregateErrors,
1665
+ ]
1666
+ ? [
1667
+ NormalizeDeepError<AggregateErrorArg, ParentError, NewError>,
1668
+ ...NormalizeManyErrors<Rest, ParentError, NewError>,
1669
+ ]
1670
+ : NormalizeDeepError<AggregateErrorsArg[number], ParentError, NewError>[]
1671
+
1672
+ /**
1673
+ * Apply `ErrorClass.normalize()` on `error`, but not `error.errors`
1674
+ */
1675
+ declare type NormalizeOneError<
1676
+ ErrorArg,
1677
+ ParentError extends ErrorInstance,
1678
+ NewError extends ErrorInstance,
1679
+ > = ErrorArg extends ParentError
1680
+ ? ErrorArg
1681
+ : ErrorArg extends Error
1682
+ ? SetProps<ErrorArg, NewError>
1683
+ : NewError
1684
+
1685
+ /** A required resource (file, module, component) could not be found. */
1686
+ export declare const NotFoundError: SpecificErrorClass< {
1687
+ name: "cli";
1688
+ isOptions: (options: unknown) => boolean;
1689
+ getOptions: (options?: Options) => {
1690
+ custom: string;
1691
+ stack?: boolean;
1692
+ cause?: boolean;
1693
+ props?: boolean;
1694
+ colors?: boolean;
1695
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
1696
+ header?: Styles | "";
1697
+ classes?: {
1698
+ readonly [errorName: string]: Omit<Options_3, "classes">;
1699
+ } & {
1700
+ readonly [errorName: string]: Omit<Options_2, "classes">;
1701
+ };
1702
+ exitCode?: number;
1703
+ silent?: boolean;
1704
+ timeout?: number;
1705
+ log?: (message: string) => void;
1706
+ };
1707
+ instanceMethods: {
1708
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
1709
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
1710
+ };
1711
+ }[], {
1712
+ /** Pipeline stage where the error originated (composed at runtime). */
1713
+ phase: string;
1714
+ /** True if this error represents a violated invariant, not a user error. */
1715
+ isDefect: boolean;
1716
+ /** Process exit code used by BaseError.exit(). */
1717
+ exitCode: number;
1718
+ } & object, CustomClass>;
1719
+
1720
+ export declare class Ok<T, E> implements IResult<T, E> {
1721
+ readonly value: T;
1722
+ constructor(value: T);
1723
+ isOk(): this is Ok<T, E>;
1724
+ isErr(): this is Err<T, E>;
1725
+ map<A>(f: (t: T) => A): Result<A, E>;
1726
+ mapErr<U>(_f: (e: E) => U): Result<T, U>;
1727
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
1728
+ andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
1729
+ andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
1730
+ andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
1731
+ andTee(f: (t: T) => unknown): Result<T, E>;
1732
+ orTee(_f: (t: E) => unknown): Result<T, E>;
1733
+ orElse<R extends Result<unknown, unknown>>(_f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
1734
+ orElse<U, A>(_f: (e: E) => Result<U, A>): Result<U | T, A>;
1735
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
1736
+ asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
1737
+ asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
1738
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
1739
+ unwrapOr<A>(_v: A): T | A;
1740
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
1741
+ safeUnwrap(): Generator<Err<never, E>, T>;
1742
+ _unsafeUnwrap(_?: ErrorConfig): T;
1743
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
1744
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
1745
+ }
1746
+
1747
+ export declare function ok<T, E = never>(value: T): Ok<T, E>;
1748
+
1749
+ export declare function ok<T extends void = void, E = never>(value: void): Ok<void, E>;
1750
+
1751
+ export declare function okAsync<T, E = never>(value: T): ResultAsync<T, E>;
1752
+
1753
+ export declare function okAsync<T extends void = void, E = never>(value: void): ResultAsync<void, E>;
1754
+
1755
+ /**
1756
+ * Like `Omit<Source, OmittedKeys>` except it reduces empty `{}` for simpler
1757
+ * debugging.
1758
+ */
1759
+ declare type OmitKeys<
1760
+ Source,
1761
+ OmittedKeys extends PropertyKey,
1762
+ > = keyof Source extends OmittedKeys ? object : Omit<Source, OmittedKeys>
1763
+
1764
+ /**
1765
+ * Options of `modern-errors-cli`
1766
+ */
1767
+ declare type Options = Omit<Options_2, 'classes' | 'custom'>;
1768
+
1769
+ /**
1770
+ * `handle-cli-error` options
1771
+ */
1772
+ declare type Options_2 = Options_3 & {
1773
+ /**
1774
+ * Process [exit code](https://en.wikipedia.org/wiki/Exit_status).
1775
+ *
1776
+ * We recommend values between 1 and 124 because the following exit codes have
1777
+ * some special meaning:
1778
+ *
1779
+ * - 0: success
1780
+ * - 125: invalid [`options`](#options)
1781
+ * - 126 to 255: used by shells like Bash
1782
+ *
1783
+ * @default 1
1784
+ */
1785
+ readonly exitCode?: number
1786
+
1787
+ /**
1788
+ * Exits the process without logging anything on the console.
1789
+ *
1790
+ * @default false
1791
+ */
1792
+ readonly silent?: boolean
1793
+
1794
+ /**
1795
+ * The process exits gracefully: it waits for any ongoing tasks (callbacks,
1796
+ * promises, etc.) to complete, up to a specific `timeout`.
1797
+ *
1798
+ * Special values:
1799
+ * - `0`: Exits right away, without waiting for ongoing tasks
1800
+ * - `Number.POSITIVE_INFINITY`: Waits for ongoing tasks forever, without
1801
+ * timing out
1802
+ *
1803
+ * @default 5000
1804
+ */
1805
+ readonly timeout?: number
1806
+
1807
+ /**
1808
+ * Function used to print the error message.
1809
+ *
1810
+ * @default console.error
1811
+ */
1812
+ readonly log?: (message: string) => void
1813
+
1814
+ /**
1815
+ * Specify different options per error class. The object:
1816
+ * - Keys are either the
1817
+ * [`error.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name),
1818
+ * or `"default"` (used if no `error.name` matches)
1819
+ * - Values are options objects
1820
+ *
1821
+ * @default {}
1822
+ *
1823
+ * @example
1824
+ * ```js
1825
+ * handleCliError(error, {
1826
+ * InputError: { exitCode: 1, stack: false },
1827
+ * DatabaseError: { exitCode: 2, stack: false },
1828
+ * default: { exitCode: 3 },
1829
+ * })
1830
+ * ```
1831
+ */
1832
+ readonly classes?: {
1833
+ readonly [errorName: string]: Omit<Options_2, 'classes'>
1834
+ }
1835
+ }
1836
+
1837
+ /**
1838
+ * `beautiful-error` options
1839
+ */
1840
+ declare interface Options_3 {
1841
+ /**
1842
+ * Whether to show the `error` stack trace.
1843
+ *
1844
+ * @default true
1845
+ */
1846
+ readonly stack?: boolean
1847
+
1848
+ /**
1849
+ * Whether to show nested errors, i.e.
1850
+ * [`error.cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
1851
+ * and
1852
+ * [`error.errors`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError/errors).
1853
+ *
1854
+ * @default true
1855
+ */
1856
+ readonly cause?: boolean
1857
+
1858
+ /**
1859
+ * Whether to show the error's additional properties.
1860
+ *
1861
+ * @default true
1862
+ */
1863
+ readonly props?: boolean
1864
+
1865
+ /**
1866
+ * Whether to colorize the error's message, stack trace and additional properties.
1867
+ *
1868
+ * Quoted strings in the error's message are printed in bold (for `"..."` and
1869
+ * `'...'`) and in italic (for `` `...` ``).
1870
+ *
1871
+ * @default `true` in terminals, `false` otherwise
1872
+ */
1873
+ readonly colors?: boolean
1874
+
1875
+ /**
1876
+ * Icon prepended to the error's name. The available values are listed
1877
+ * [here](https://github.com/sindresorhus/figures/blob/main/readme.md#figures-1).
1878
+ * Can be disabled by passing an empty string.
1879
+ *
1880
+ * @default 'cross'
1881
+ */
1882
+ readonly icon?: keyof typeof figureSet | ''
1883
+
1884
+ /**
1885
+ * Color/style of the error's icon and name. The available values are listed
1886
+ * [here](https://github.com/ehmicky/chalk-string#available-styles).
1887
+ * Several styles can be specified by using spaces.
1888
+ * Can be disabled by passing an empty string.
1889
+ *
1890
+ * @default 'red bold'
1891
+ */
1892
+ readonly header?: Styles | ''
1893
+
1894
+ /**
1895
+ * Name of a method to map the output. That method must take the output as a
1896
+ * string argument, transform it then return it.
1897
+ *
1898
+ * @example
1899
+ * ```js
1900
+ * class ExampleError extends Error {
1901
+ * beautiful(output) {
1902
+ * return output.replaceAll('secret', '***')
1903
+ * }
1904
+ * }
1905
+ *
1906
+ * const error = new ExampleError('Unknown value: secret')
1907
+ * const message = beautifulError(error) // 'Unknown value: ***'
1908
+ * ```
1909
+ *
1910
+ * @default 'beautiful'
1911
+ */
1912
+ readonly custom?: string | symbol
1913
+
1914
+ /**
1915
+ * Specify different options per error class. The object:
1916
+ * - Keys are either the
1917
+ * [`error.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name),
1918
+ * or `"default"` (used if no `error.name` matches)
1919
+ * - Values are options objects
1920
+ *
1921
+ * @default {}
1922
+ *
1923
+ * @example
1924
+ * ```js
1925
+ * const message = beautifulError(error, {
1926
+ * InputError: { icon: 'warning', stack: false },
1927
+ * DatabaseError: { icon: 'info', stack: false },
1928
+ * default: { icon: 'cross' },
1929
+ * })
1930
+ * ```
1931
+ */
1932
+ readonly classes?: {
1933
+ readonly [errorName: string]: Omit<Options_3, 'classes'>
1934
+ }
1935
+ }
1936
+
1937
+ /**
1938
+ * Last variadic arguments of the `constructor` of the parent error class
1939
+ */
1940
+ declare type ParentExtra<CustomClassArg extends CustomClass> =
1941
+ ConstructorParameters<CustomClassArg> extends readonly [
1942
+ unknown,
1943
+ unknown?,
1944
+ ...infer Extra extends readonly unknown[],
1945
+ ]
1946
+ ? Extra
1947
+ : readonly never[]
1948
+
1949
+ /**
1950
+ * Second argument of the `constructor` of the parent error class
1951
+ */
1952
+ declare type ParentInstanceOptions<
1953
+ PluginsArg extends Plugins,
1954
+ ChildProps extends ErrorProps,
1955
+ CustomClassArg extends CustomClass,
1956
+ AggregateErrorsArg extends AggregateErrors,
1957
+ CauseArg extends Cause,
1958
+ > = ConstructorParameters<CustomClassArg>[1] &
1959
+ SpecificInstanceOptions<PluginsArg, ChildProps, AggregateErrorsArg, CauseArg>
1960
+
1961
+ /**
1962
+ * Factory function that parses CSS and returns an API to query the parsed result
1963
+ * @param cssString - The CSS file content as a string
1964
+ * @returns API object with methods to query the parsed CSS
1965
+ */
1966
+ export declare function parseCss(cssString: string): CSSParserAPI;
1967
+
1968
+ /** Data could not be parsed or decoded (JSON, source code, config, CSS). */
1969
+ export declare const ParseError: SpecificErrorClass< {
1970
+ name: "cli";
1971
+ isOptions: (options: unknown) => boolean;
1972
+ getOptions: (options?: Options) => {
1973
+ custom: string;
1974
+ stack?: boolean;
1975
+ cause?: boolean;
1976
+ props?: boolean;
1977
+ colors?: boolean;
1978
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
1979
+ header?: Styles | "";
1980
+ classes?: {
1981
+ readonly [errorName: string]: Omit<Options_3, "classes">;
1982
+ } & {
1983
+ readonly [errorName: string]: Omit<Options_2, "classes">;
1984
+ };
1985
+ exitCode?: number;
1986
+ silent?: boolean;
1987
+ timeout?: number;
1988
+ log?: (message: string) => void;
1989
+ };
1990
+ instanceMethods: {
1991
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
1992
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
1993
+ };
1994
+ }[], {
1995
+ /** Pipeline stage where the error originated (composed at runtime). */
1996
+ phase: string;
1997
+ /** True if this error represents a violated invariant, not a user error. */
1998
+ isDefect: boolean;
1999
+ /** Process exit code used by BaseError.exit(). */
2000
+ exitCode: number;
2001
+ } & object, CustomClass>;
2002
+
2003
+ /**
2004
+ * Plugins extend `modern-errors` features.
2005
+ *
2006
+ * @example
2007
+ * ```js
2008
+ * export default {
2009
+ * // Name used to configure the plugin
2010
+ * name: 'example',
2011
+ *
2012
+ * // Set error properties
2013
+ * properties(info) {
2014
+ * return {}
2015
+ * },
2016
+ *
2017
+ * // Add instance methods like `ErrorClass.exampleMethod(error, ...args)` or
2018
+ * // `error.exampleMethod(...args)`
2019
+ * instanceMethods: {
2020
+ * exampleMethod(info, ...args) {
2021
+ * // ...
2022
+ * },
2023
+ * },
2024
+ *
2025
+ * // Add static methods like `ErrorClass.staticMethod(...args)`
2026
+ * staticMethods: {
2027
+ * staticMethod(info, ...args) {
2028
+ * // ...
2029
+ * },
2030
+ * },
2031
+ *
2032
+ * // Validate and normalize options
2033
+ * getOptions(options, full) {
2034
+ * return options
2035
+ * },
2036
+ *
2037
+ * // Determine if a value is plugin's options
2038
+ * isOptions(options) {
2039
+ * return typeof options === 'boolean'
2040
+ * },
2041
+ * }
2042
+ * ```
2043
+ */
2044
+ declare interface Plugin {
2045
+ /**
2046
+ * Plugin's name. It is used to configure the plugin's options.
2047
+ *
2048
+ * Only lowercase letters must be used (as opposed to `_` `-` `.` or uppercase
2049
+ * letters).
2050
+ *
2051
+ * @example
2052
+ * ```js
2053
+ * // Users configure this plugin using
2054
+ * // `ErrorClass.subclass('ErrorName', { example: ... })`
2055
+ * // or `new ErrorClass('...', { example: ... })
2056
+ * export default {
2057
+ * name: 'example',
2058
+ * }
2059
+ * ```
2060
+ */
2061
+ readonly name: string
2062
+
2063
+ /**
2064
+ * Normalize and return the plugin's `options`.
2065
+ * Required to use plugin `options`.
2066
+ *
2067
+ * If `options` are invalid, an `Error` should be thrown. The error message is
2068
+ * automatically prepended with `Invalid "${plugin.name}" options:`. Regular
2069
+ * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)s
2070
+ * should be thrown, as opposed to using `modern-errors` itself.
2071
+ *
2072
+ * The plugin's `options` can have any type.
2073
+ *
2074
+ * @example
2075
+ * ```js
2076
+ * export default {
2077
+ * name: 'example',
2078
+ * getOptions(options = true) {
2079
+ * if (typeof options !== 'boolean') {
2080
+ * throw new Error('It must be true or false.')
2081
+ * }
2082
+ *
2083
+ * return options
2084
+ * },
2085
+ * }
2086
+ * ```
2087
+ */
2088
+ readonly getOptions?: GetOptions
2089
+
2090
+ /**
2091
+ * Plugin users can pass the plugin's `options` as the last argument of any
2092
+ * plugin method (instance or static). `isOptions()` determines whether the
2093
+ * last argument of a plugin method are `options` or not.
2094
+ * This should be defined if the plugin has any method with arguments.
2095
+ *
2096
+ * If `options` are invalid but can be determined not to be the last argument
2097
+ * of any plugin's method, `isOptions()` should still return `true`. This
2098
+ * allows `getOptions()` to validate them and throw proper error messages.
2099
+ *
2100
+ * @example
2101
+ * ```js
2102
+ * // `ErrorClass.exampleMethod(error, 'one', true)` results in:
2103
+ * // options: true
2104
+ * // args: ['one']
2105
+ * // `ErrorClass.exampleMethod(error, 'one', 'two')` results in:
2106
+ * // options: undefined
2107
+ * // args: ['one', 'two']
2108
+ * export default {
2109
+ * name: 'example',
2110
+ * isOptions(options) {
2111
+ * return typeof options === 'boolean'
2112
+ * },
2113
+ * getOptions(options) {
2114
+ * return options
2115
+ * },
2116
+ * instanceMethod: {
2117
+ * exampleMethod({ options }, ...args) {
2118
+ * // ...
2119
+ * },
2120
+ * },
2121
+ * }
2122
+ * ```
2123
+ */
2124
+ readonly isOptions?: IsOptions
2125
+
2126
+ /**
2127
+ * Add error instance methods like `ErrorClass.methodName(error, ...args)` or
2128
+ * `error.methodName(...args)`. Unlike static methods, this should be used
2129
+ * when the method's main argument is an `error` instance.
2130
+ *
2131
+ * The first argument `info` is provided by `modern-errors`. The `error`
2132
+ * argument is passed as `info.error`. The other `...args` are forwarded from
2133
+ * the method's call.
2134
+ *
2135
+ * @example
2136
+ * ```js
2137
+ * export default {
2138
+ * name: 'example',
2139
+ * // `ErrorClass.concatMessage(error, "one")` or
2140
+ * // `error.concatMessage("one")`
2141
+ * // return `${error.message} - one`
2142
+ * instanceMethods: {
2143
+ * concatMessage(info, string) {
2144
+ * return `${info.error.message} - ${string}`
2145
+ * },
2146
+ * },
2147
+ * }
2148
+ * ```
2149
+ */
2150
+ readonly instanceMethods?: InstanceMethods
2151
+
2152
+ /**
2153
+ * Add error static methods like `ErrorClass.methodName(...args)`. Unlike
2154
+ * instance methods, this should be used when the method's main argument is
2155
+ * _not_ an `error` instance.
2156
+ *
2157
+ * The first argument `info` is provided by `modern-errors`. `info.error` is
2158
+ * not defined. The other `...args` are forwarded from the method's call.
2159
+ *
2160
+ * @example
2161
+ * ```js
2162
+ * export default {
2163
+ * name: 'example',
2164
+ * // `ErrorClass.multiply(2, 3)` returns `6`
2165
+ * staticMethods: {
2166
+ * multiply(info, first, second) {
2167
+ * return first * second
2168
+ * },
2169
+ * },
2170
+ * }
2171
+ * ```
2172
+ */
2173
+ readonly staticMethods?: StaticMethods
2174
+
2175
+ /**
2176
+ * Set properties on `error.*` (including `message` or `stack`).
2177
+ * The properties to set must be returned as an object.
2178
+ *
2179
+ * Error properties that are internal or secret can be prefixed with `_`.
2180
+ * This makes them
2181
+ * [non-enumerable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties),
2182
+ * which prevents iterating or logging them.
2183
+ *
2184
+ * @example
2185
+ * ```js
2186
+ * export default {
2187
+ * name: 'example',
2188
+ * // Sets `error.example: true`
2189
+ * properties() {
2190
+ * return { example: true }
2191
+ * },
2192
+ * }
2193
+ * ```
2194
+ */
2195
+ readonly properties?: GetProperties
2196
+ }
2197
+
2198
+ /**
2199
+ * Bound instance methods of a plugin, if defined
2200
+ */
2201
+ declare type PluginInstanceMethods<PluginArg extends Plugin> = PluginArg extends {
2202
+ instanceMethods: InstanceMethods
2203
+ }
2204
+ ? ErrorInstanceMethods<PluginArg['instanceMethods'], MethodOptions<PluginArg>>
2205
+ : object
2206
+
2207
+ /**
2208
+ * Bound mixed methods of a plugin, if defined
2209
+ */
2210
+ declare type PluginMixedMethods<PluginArg extends Plugin> = PluginArg extends {
2211
+ instanceMethods: InstanceMethods
2212
+ }
2213
+ ? ErrorMixedMethods<PluginArg['instanceMethods'], MethodOptions<PluginArg>>
2214
+ : object
2215
+
2216
+ /**
2217
+ * Exclude plugins with a `name` that is not typed `as const`
2218
+ */
2219
+ declare type PluginOptionName<PluginArg extends Plugin> =
2220
+ string extends PluginArg['name']
2221
+ ? never
2222
+ : ExternalPluginOptions<PluginArg> extends never
2223
+ ? never
2224
+ : PluginArg['name']
2225
+
2226
+ /**
2227
+ * Bound added properties of a plugin, if defined
2228
+ */
2229
+ declare type PluginProperties<PluginArg extends Plugin> = PluginArg extends Plugin
2230
+ ? PluginArg extends { properties: GetProperties }
2231
+ ? ReturnType<PluginArg['properties']>
2232
+ : object
2233
+ : object
2234
+
2235
+ /**
2236
+ * List of plugins
2237
+ */
2238
+ declare type Plugins = readonly Plugin[]
2239
+
2240
+ /**
2241
+ * Bound instance methods of all plugins
2242
+ */
2243
+ declare type PluginsInstanceMethods<PluginsArg extends Plugins> =
2244
+ UnionToIntersection<PluginInstanceMethods<PluginsArg[number]>> & {}
2245
+
2246
+ /**
2247
+ * Bound mixed methods of all plugins
2248
+ */
2249
+ declare type PluginsMixedMethods<PluginsArg extends Plugins> =
2250
+ UnionToIntersection<PluginMixedMethods<PluginsArg[number]>> & {}
2251
+
2252
+ /**
2253
+ * Options of all plugins, including core plugins
2254
+ */
2255
+ declare type PluginsOptions<
2256
+ PluginsArg extends Plugins,
2257
+ ChildProps extends ErrorProps,
2258
+ > = keyof ExternalPluginsOptions<PluginsArg> extends never
2259
+ ? CorePluginsOptions<ChildProps>
2260
+ : CorePluginsOptions<ChildProps> & ExternalPluginsOptions<PluginsArg>
2261
+
2262
+ /**
2263
+ * Bound added properties of all plugins
2264
+ */
2265
+ declare type PluginsProperties<PluginsArg extends Plugins> = UnionToIntersection<
2266
+ PluginProperties<PluginsArg[number]>
2267
+ > & {}
2268
+
2269
+ /**
2270
+ * Bound static methods of all plugins
2271
+ */
2272
+ declare type PluginsStaticMethods<PluginsArg extends Plugins> =
2273
+ UnionToIntersection<PluginStaticMethods<PluginsArg[number]>> & {}
2274
+
2275
+ /**
2276
+ * Bound static methods of a plugin, if defined
2277
+ */
2278
+ declare type PluginStaticMethods<PluginArg extends Plugin> = PluginArg extends {
2279
+ staticMethods: StaticMethods
2280
+ }
2281
+ ? ErrorStaticMethods<PluginArg['staticMethods'], MethodOptions<PluginArg>>
2282
+ : object
2283
+
2284
+ declare type Prev = [
2285
+ never,
2286
+ 0,
2287
+ 1,
2288
+ 2,
2289
+ 3,
2290
+ 4,
2291
+ 5,
2292
+ 6,
2293
+ 7,
2294
+ 8,
2295
+ 9,
2296
+ 10,
2297
+ 11,
2298
+ 12,
2299
+ 13,
2300
+ 14,
2301
+ 15,
2302
+ 16,
2303
+ 17,
2304
+ 18,
2305
+ 19,
2306
+ 20,
2307
+ 21,
2308
+ 22,
2309
+ 23,
2310
+ 24,
2311
+ 25,
2312
+ 26,
2313
+ 27,
2314
+ 28,
2315
+ 29,
2316
+ 30,
2317
+ 31,
2318
+ 32,
2319
+ 33,
2320
+ 34,
2321
+ 35,
2322
+ 36,
2323
+ 37,
2324
+ 38,
2325
+ 39,
2326
+ 40,
2327
+ 41,
2328
+ 42,
2329
+ 43,
2330
+ 44,
2331
+ 45,
2332
+ 46,
2333
+ 47,
2334
+ 48,
2335
+ 49,
2336
+ ...0[]
2337
+ ];
2338
+
2339
+ /** The result of processing a single component through the manifest pipeline. */
2340
+ export declare interface ProcessComponentResult {
2341
+ component: ComponentInfoWithCss;
2342
+ }
2343
+
2344
+ export declare interface PropInfo {
2345
+ name: string;
2346
+ type: string;
2347
+ required: boolean;
2348
+ defaultValue?: DefaultValue;
2349
+ resolvedType: ResolvedType;
2350
+ description?: string;
2351
+ deprecated?: boolean;
2352
+ }
2353
+
2354
+ export declare interface PropSpyMeta {
2355
+ path: string;
2356
+ propName: string;
2357
+ originalValue: unknown;
2358
+ }
2359
+
2360
+ export declare interface PropTrackerData {
2361
+ tag: string;
2362
+ role?: string;
2363
+ boundProps: string[];
2364
+ concatenatedAttrs: Map<string, string>;
2365
+ }
2366
+
2367
+ export declare interface PropTrackerExtractorState {
2368
+ stores: TrackingStores;
2369
+ }
2370
+
2371
+ export declare interface PropWriteInfo {
2372
+ elements: Map<string, {
2373
+ tag: string;
2374
+ elementId: string;
2375
+ }>;
2376
+ attributes: Map<string, {
2377
+ attr: string;
2378
+ concatenated: boolean;
2379
+ }>;
2380
+ }
2381
+
2382
+ /**
2383
+ * Interface for pluggable extractors.
2384
+ * Extractors can hook into any combination of lifecycle events.
2385
+ */
2386
+ export declare interface ReactExtractor {
2387
+ name: string;
2388
+ onBeforeRender?(context: RenderContext): void;
2389
+ onCreateElement?(event: CreateElementEvent): void;
2390
+ onRenderComplete?(event: RenderCompleteEvent): void;
2391
+ }
2392
+
2393
+ /**
2394
+ * Event emitted after render completes.
2395
+ */
2396
+ export declare interface RenderCompleteEvent {
2397
+ html: string;
2398
+ context: RenderContext;
2399
+ }
2400
+
2401
+ /**
2402
+ * Context available to extractors during the beforeRender phase.
2403
+ * Props are mutable - extractors can modify them before render.
2404
+ */
2405
+ export declare interface RenderContext {
2406
+ componentInfo: ComponentInfo;
2407
+ component: ComponentType<unknown>;
2408
+ props: Record<string, unknown>;
2409
+ store: ExtractorStore;
2410
+ }
2411
+
2412
+ /**
2413
+ * Renders a React component to static HTML while intercepting element creation.
2414
+ *
2415
+ * Uses monkey-patching of React.createElement and jsx/jsxs to notify listeners
2416
+ * when DOM elements are created. Each DOM element gets a unique `data-trace-id`
2417
+ * attribute for tracking.
2418
+ *
2419
+ * @param Component - The React component to render
2420
+ * @param componentProps - Props to pass to the component
2421
+ * @param listeners - Listeners to notify on each DOM element creation
2422
+ * @param store - Shared ExtractorStore, included in each CreateElementEvent
2423
+ * @returns Static HTML string with trace IDs on DOM elements
2424
+ *
2425
+ * @example
2426
+ * ```ts
2427
+ * const store = new ExtractorStore()
2428
+ * const tracker = createPropTracker(getSpyMetadata)
2429
+ * const html = renderWithExtractors(MyComponent, { title: 'Hello' }, [tracker], store)
2430
+ * // html contains: <div data-trace-id="t1">...</div>
2431
+ * // tracker.stores now has prop→DOM bindings
2432
+ * ```
2433
+ */
2434
+ export declare function renderWithExtractors(Component: ComponentType<unknown>, componentProps: unknown, listeners: CreateElementListener[], store: ExtractorStore): string;
2435
+
2436
+ /**
2437
+ * API to extract component props with full TypeScript type resolution
2438
+ */
2439
+ export declare type ResolvedKind = 'primitive' | 'semantic' | 'array' | 'object' | 'union' | 'intersection' | 'enum' | 'literal' | 'function';
2440
+
2441
+ export declare interface ResolvedType {
2442
+ kind: ResolvedKind;
2443
+ value?: unknown;
2444
+ /** For semantic types, the package the symbol came from */
2445
+ source?: string;
2446
+ properties?: Record<string, PropInfo>;
2447
+ elementType?: ResolvedType;
2448
+ types?: ResolvedType[];
2449
+ }
2450
+
2451
+ export declare namespace Result {
2452
+ /**
2453
+ * Wraps a function with a try catch, creating a new function with the same
2454
+ * arguments but returning `Ok` if successful, `Err` if the function throws
2455
+ *
2456
+ * @param fn function to wrap with ok on success or err on failure
2457
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
2458
+ */
2459
+ export function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
2460
+ export function combine<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResults<T>;
2461
+ export function combine<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResults<T>;
2462
+ export function combineWithAllErrors<T extends readonly [Result<unknown, unknown>, ...Result<unknown, unknown>[]]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
2463
+ export function combineWithAllErrors<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
2464
+ }
2465
+
2466
+ export declare type Result<T, E> = Ok<T, E> | Err<T, E>;
2467
+
2468
+ export declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
2469
+ private _promise;
2470
+ constructor(res: Promise<Result<T, E>>);
2471
+ static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
2472
+ static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
2473
+ static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
2474
+ static combine<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultAsyncs<T>;
2475
+ static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
2476
+ static combineWithAllErrors<T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
2477
+ static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
2478
+ map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
2479
+ andThrough<F>(f: (t: T) => Result<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
2480
+ andTee(f: (t: T) => unknown): ResultAsync<T, E>;
2481
+ orTee(f: (t: E) => unknown): ResultAsync<T, E>;
2482
+ mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
2483
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
2484
+ andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
2485
+ andThen<U, F>(f: (t: T) => Result<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
2486
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
2487
+ orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
2488
+ orElse<U, A>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
2489
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
2490
+ unwrapOr<A>(t: A): Promise<T | A>;
2491
+ /**
2492
+ * @deprecated will be removed in 9.0.0.
2493
+ *
2494
+ * You can use `safeTry` without this method.
2495
+ * @example
2496
+ * ```typescript
2497
+ * safeTry(async function* () {
2498
+ * const okValue = yield* yourResult
2499
+ * })
2500
+ * ```
2501
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
2502
+ */
2503
+ safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
2504
+ then<A, B>(successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
2505
+ [Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
2506
+ }
2507
+
2508
+ /**
2509
+ * Runs extractors through the full lifecycle and returns extraction results.
2510
+ *
2511
+ * @param componentInfo - TypeScript-extracted component information
2512
+ * @param component - The React component to render
2513
+ * @param extractors - Array of extractors to run
2514
+ * @returns Extraction results including HTML, store, and element tree
2515
+ */
2516
+ export declare function runExtractors(componentInfo: ComponentInfo, component: ComponentType<unknown>, extractors: ReactExtractor[], options?: RunExtractorsOptions): ExtractionResult;
2517
+
2518
+ export declare interface RunExtractorsOptions {
2519
+ /** Optional HOC to wrap the component before rendering (e.g. a context provider). */
2520
+ wrapper?: (component: ComponentType<unknown>) => ComponentType<unknown>;
2521
+ }
2522
+
2523
+ /**
2524
+ * Like `LowObject & HighObject` except that if both keys are defined,
2525
+ * `HighObject` overrides `LowObject` instead of intersecting to it
2526
+ */
2527
+ declare type SetProps<
2528
+ LowObject extends object,
2529
+ HighObject extends object,
2530
+ > = Omit<LowObject, keyof HighObject> & HighObject
2531
+
2532
+ /**
2533
+ * Like `SetProps<LowObject, HighObject>` except it reduces empty `{}` for
2534
+ * simpler debugging.
2535
+ */
2536
+ declare type SimpleSetProps<
2537
+ LowObject extends object,
2538
+ HighObject extends object,
2539
+ > = keyof LowObject extends keyof HighObject
2540
+ ? HighObject
2541
+ : keyof LowObject & keyof HighObject extends never
2542
+ ? LowObject & HighObject
2543
+ : SetProps<LowObject, HighObject>
2544
+
2545
+ /**
2546
+ * Omit the first item of a tuple
2547
+ */
2548
+ declare type SliceFirst<Tuple extends readonly unknown[]> =
2549
+ Tuple extends readonly [unknown, ...infer Rest extends readonly unknown[]]
2550
+ ? Rest
2551
+ : readonly never[]
2552
+
2553
+ /**
2554
+ * Class-specific options, used internally only with additional generics
2555
+ */
2556
+ declare type SpecificClassOptions<
2557
+ PluginsArg extends Plugins,
2558
+ ChildPlugins extends Plugins,
2559
+ ChildProps extends ErrorProps,
2560
+ ChildCustomClass extends CustomClass,
2561
+ > = KnownClassOptions<ChildPlugins, ChildCustomClass> &
2562
+ PluginsOptions<[...PluginsArg, ...ChildPlugins], ChildProps>
2563
+
2564
+ /**
2565
+ * Error class, with specific `props`, `custom`, etc.
2566
+ *
2567
+ * @private This type is private and only exported as a temporary workaround
2568
+ * for an open issue with TypeScript. It will be removed in a future release.
2569
+ * See:
2570
+ *
2571
+ * - [modern-errors issue #35](https://github.com/ehmicky/modern-errors/issues/35)
2572
+ * - [modern-errors issue #18](https://github.com/ehmicky/modern-errors/issues/18)
2573
+ * - [TypeScript issue #47663](https://github.com/microsoft/TypeScript/issues/47663)
2574
+ */
2575
+ declare type SpecificErrorClass<
2576
+ PluginsArg extends Plugins,
2577
+ ErrorPropsArg extends ErrorProps,
2578
+ CustomClassArg extends CustomClass,
2579
+ > = ErrorSubclassCore<PluginsArg, ErrorPropsArg, CustomClassArg> &
2580
+ OmitKeys<
2581
+ CustomClassArg,
2582
+ keyof ErrorSubclassCore<PluginsArg, ErrorPropsArg, CustomClassArg>
2583
+ > &
2584
+ PluginsStaticMethods<PluginsArg> &
2585
+ PluginsMixedMethods<PluginsArg>
2586
+
2587
+ /**
2588
+ * Error instance object, used internally with additional generics.
2589
+ * This mixes: `Error`, aggregate errors, plugin instance methods,
2590
+ * `plugin.properties()` and `props`, while ensuring those do not overlap each
2591
+ * other.
2592
+ */
2593
+ declare type SpecificErrorInstance<
2594
+ PluginsArg extends Plugins,
2595
+ ErrorPropsArg extends ErrorProps,
2596
+ CustomClassArg extends CustomClass,
2597
+ AggregateErrorsArg extends AggregateErrors,
2598
+ CauseArg extends Cause,
2599
+ > = SetProps<
2600
+ NormalizedCause<CauseArg>,
2601
+ SetProps<
2602
+ ErrorPropsArg,
2603
+ SetProps<
2604
+ PluginsProperties<PluginsArg>,
2605
+ SetProps<
2606
+ PluginsInstanceMethods<PluginsArg>,
2607
+ SetProps<
2608
+ InstanceType<CustomClassArg>,
2609
+ AggregateErrorsProperty<AggregateErrorsArg, CauseArg>
2610
+ >
2611
+ >
2612
+ >
2613
+ >
2614
+ >
2615
+
2616
+ /**
2617
+ * Options passed to error constructors, used internally only with additional
2618
+ * generics
2619
+ */
2620
+ declare type SpecificInstanceOptions<
2621
+ PluginsArg extends Plugins,
2622
+ ChildProps extends ErrorProps,
2623
+ AggregateErrorsArg extends AggregateErrors,
2624
+ CauseArg extends Cause,
2625
+ > = MainInstanceOptions<AggregateErrorsArg, CauseArg> &
2626
+ PluginsOptions<PluginsArg, ChildProps>
2627
+
2628
+ /**
2629
+ * Unbound static method of a plugin
2630
+ */
2631
+ declare type StaticMethod = (
2632
+ info: InfoParameter['staticMethods'],
2633
+ ...args: readonly never[]
2634
+ ) => unknown
2635
+
2636
+ /**
2637
+ * Unbound static methods of a plugin
2638
+ */
2639
+ declare interface StaticMethods {
2640
+ readonly [MethodName: string]: StaticMethod
2641
+ }
2642
+
2643
+ declare type Style =
2644
+ | BasicStyle
2645
+ | BasicColors
2646
+ | `${BasicColors}Bright`
2647
+ | `hex-${string}`
2648
+ | `rgb-${number}-${number}-${number}`
2649
+ | `bg${Capitalize<BasicColors>}`
2650
+ | `bg${Capitalize<BasicColors>}Bright`
2651
+ | `bgHex-${string}`
2652
+ | `bgRgb-${number}-${number}-${number}`
2653
+
2654
+ /**
2655
+ * Space-separated list of styles. Some styles require dash-separated arguments.
2656
+ */
2657
+ declare type Styles = Style | `${Style} ${Style}`
2658
+
2659
+ export declare interface TrackingStores {
2660
+ propUsages: Map<string, PropWriteInfo>;
2661
+ }
2662
+
2663
+ 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;
2664
+
2665
+ declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [infer Oks, infer Errs] ? Result<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
2666
+
2667
+ 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;
2668
+
2669
+ declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result<infer Oks, infer Errs> ? Result<Oks, Errs[]> : never;
2670
+
2671
+ declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
2672
+
2673
+ /**
2674
+ * Turn `T | T2 | ...` into `T & T2 & ...`
2675
+ */
2676
+ declare type UnionToIntersection<T> = (
2677
+ T extends unknown ? (arg: T) => unknown : never
2678
+ ) extends (arg: infer U) => unknown
2679
+ ? U
2680
+ : never
2681
+
2682
+ declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
2683
+
2684
+ /**
2685
+ * Remove the types of all `info.*` members to fix some type conflict issues
2686
+ */
2687
+ declare type UntypedInfo<SpecificInfo> = {
2688
+ readonly [InfoPropName in keyof SpecificInfo]: never
2689
+ }
2690
+
2691
+ 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;
2692
+
2693
+ /** Input or data does not satisfy validation rules. */
2694
+ export declare const ValidationError: SpecificErrorClass< {
2695
+ name: "cli";
2696
+ isOptions: (options: unknown) => boolean;
2697
+ getOptions: (options?: Options) => {
2698
+ custom: string;
2699
+ stack?: boolean;
2700
+ cause?: boolean;
2701
+ props?: boolean;
2702
+ colors?: boolean;
2703
+ icon?: ("infinity" | "tick" | "info" | "warning" | "cross" | "square" | "squareSmall" | "squareSmallFilled" | "squareDarkShade" | "squareMediumShade" | "squareLightShade" | "squareTop" | "squareBottom" | "squareLeft" | "squareRight" | "squareCenter" | "circle" | "circleFilled" | "circleDotted" | "circleDouble" | "circleCircle" | "circleCross" | "circlePipe" | "circleQuestionMark" | "radioOn" | "radioOff" | "checkboxOn" | "checkboxOff" | "checkboxCircleOn" | "checkboxCircleOff" | "questionMarkPrefix" | "bullet" | "dot" | "ellipsis" | "pointer" | "pointerSmall" | "triangleUp" | "triangleUpSmall" | "triangleUpOutline" | "triangleDown" | "triangleDownSmall" | "triangleLeft" | "triangleLeftSmall" | "triangleRight" | "triangleRightSmall" | "lozenge" | "lozengeOutline" | "home" | "hamburger" | "smiley" | "mustache" | "heart" | "star" | "play" | "musicNote" | "musicNoteBeamed" | "nodejs" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "arrowLeftRight" | "arrowUpDown" | "almostEqual" | "notEqual" | "lessOrEqual" | "greaterOrEqual" | "identical" | "subscriptZero" | "subscriptOne" | "subscriptTwo" | "subscriptThree" | "subscriptFour" | "subscriptFive" | "subscriptSix" | "subscriptSeven" | "subscriptEight" | "subscriptNine" | "oneHalf" | "oneThird" | "oneQuarter" | "oneFifth" | "oneSixth" | "oneSeventh" | "oneEighth" | "oneNinth" | "oneTenth" | "twoThirds" | "twoFifths" | "threeQuarters" | "threeFifths" | "threeEighths" | "fourFifths" | "fiveSixths" | "fiveEighths" | "sevenEighth" | "line" | "lineBold" | "lineDouble" | "lineDashed0" | "lineDashed1" | "lineDashed2" | "lineDashed3" | "lineDashed4" | "lineDashed5" | "lineDashed6" | "lineDashed7" | "lineDashed8" | "lineDashed9" | "lineDashed10" | "lineDashed11" | "lineDashed12" | "lineDashed13" | "lineDashed14" | "lineDashed15" | "lineVertical" | "lineVerticalBold" | "lineVerticalDouble" | "lineVerticalDashed0" | "lineVerticalDashed1" | "lineVerticalDashed2" | "lineVerticalDashed3" | "lineVerticalDashed4" | "lineVerticalDashed5" | "lineVerticalDashed6" | "lineVerticalDashed7" | "lineVerticalDashed8" | "lineVerticalDashed9" | "lineVerticalDashed10" | "lineVerticalDashed11" | "lineDownLeft" | "lineDownLeftArc" | "lineDownBoldLeftBold" | "lineDownBoldLeft" | "lineDownLeftBold" | "lineDownDoubleLeftDouble" | "lineDownDoubleLeft" | "lineDownLeftDouble" | "lineDownRight" | "lineDownRightArc" | "lineDownBoldRightBold" | "lineDownBoldRight" | "lineDownRightBold" | "lineDownDoubleRightDouble" | "lineDownDoubleRight" | "lineDownRightDouble" | "lineUpLeft" | "lineUpLeftArc" | "lineUpBoldLeftBold" | "lineUpBoldLeft" | "lineUpLeftBold" | "lineUpDoubleLeftDouble" | "lineUpDoubleLeft" | "lineUpLeftDouble" | "lineUpRight" | "lineUpRightArc" | "lineUpBoldRightBold" | "lineUpBoldRight" | "lineUpRightBold" | "lineUpDoubleRightDouble" | "lineUpDoubleRight" | "lineUpRightDouble" | "lineUpDownLeft" | "lineUpBoldDownBoldLeftBold" | "lineUpBoldDownBoldLeft" | "lineUpDownLeftBold" | "lineUpBoldDownLeftBold" | "lineUpDownBoldLeftBold" | "lineUpDownBoldLeft" | "lineUpBoldDownLeft" | "lineUpDoubleDownDoubleLeftDouble" | "lineUpDoubleDownDoubleLeft" | "lineUpDownLeftDouble" | "lineUpDownRight" | "lineUpBoldDownBoldRightBold" | "lineUpBoldDownBoldRight" | "lineUpDownRightBold" | "lineUpBoldDownRightBold" | "lineUpDownBoldRightBold" | "lineUpDownBoldRight" | "lineUpBoldDownRight" | "lineUpDoubleDownDoubleRightDouble" | "lineUpDoubleDownDoubleRight" | "lineUpDownRightDouble" | "lineDownLeftRight" | "lineDownBoldLeftBoldRightBold" | "lineDownLeftBoldRightBold" | "lineDownBoldLeftRight" | "lineDownBoldLeftBoldRight" | "lineDownBoldLeftRightBold" | "lineDownLeftRightBold" | "lineDownLeftBoldRight" | "lineDownDoubleLeftDoubleRightDouble" | "lineDownDoubleLeftRight" | "lineDownLeftDoubleRightDouble" | "lineUpLeftRight" | "lineUpBoldLeftBoldRightBold" | "lineUpLeftBoldRightBold" | "lineUpBoldLeftRight" | "lineUpBoldLeftBoldRight" | "lineUpBoldLeftRightBold" | "lineUpLeftRightBold" | "lineUpLeftBoldRight" | "lineUpDoubleLeftDoubleRightDouble" | "lineUpDoubleLeftRight" | "lineUpLeftDoubleRightDouble" | "lineUpDownLeftRight" | "lineUpBoldDownBoldLeftBoldRightBold" | "lineUpDownBoldLeftBoldRightBold" | "lineUpBoldDownLeftBoldRightBold" | "lineUpBoldDownBoldLeftRightBold" | "lineUpBoldDownBoldLeftBoldRight" | "lineUpBoldDownLeftRight" | "lineUpDownBoldLeftRight" | "lineUpDownLeftBoldRight" | "lineUpDownLeftRightBold" | "lineUpBoldDownBoldLeftRight" | "lineUpDownLeftBoldRightBold" | "lineUpBoldDownLeftBoldRight" | "lineUpBoldDownLeftRightBold" | "lineUpDownBoldLeftBoldRight" | "lineUpDownBoldLeftRightBold" | "lineUpDoubleDownDoubleLeftDoubleRightDouble" | "lineUpDoubleDownDoubleLeftRight" | "lineUpDownLeftDoubleRightDouble" | "lineCross" | "lineBackslash" | "lineSlash") | "";
2704
+ header?: Styles | "";
2705
+ classes?: {
2706
+ readonly [errorName: string]: Omit<Options_3, "classes">;
2707
+ } & {
2708
+ readonly [errorName: string]: Omit<Options_2, "classes">;
2709
+ };
2710
+ exitCode?: number;
2711
+ silent?: boolean;
2712
+ timeout?: number;
2713
+ log?: (message: string) => void;
2714
+ };
2715
+ instanceMethods: {
2716
+ exit: ({ error, options }: Info<Options>["instanceMethods"]) => void;
2717
+ pretty: ({ error, options: { exitCode, silent, timeout, log, ...beautifulErrorOptions }, }: Info<Options>["instanceMethods"]) => string;
2718
+ };
2719
+ }[], {
2720
+ /** Pipeline stage where the error originated (composed at runtime). */
2721
+ phase: string;
2722
+ /** True if this error represents a violated invariant, not a user error. */
2723
+ isDefect: boolean;
2724
+ /** Process exit code used by BaseError.exit(). */
2725
+ exitCode: number;
2726
+ } & object, CustomClass>;
2727
+
2728
+ /**
2729
+ * Wrap an async entry point with a defect boundary.
2730
+ *
2731
+ * If the wrapped function throws an exception (i.e. a defect that was not
2732
+ * captured as a Result), it is caught, wrapped in a DefectError, and printed
2733
+ * via BaseError.exit().
2734
+ *
2735
+ * @param fn - The entry point function to wrap
2736
+ * @throws {DefectError} If an unexpected exception occurs during execution
2737
+ */
2738
+ export declare function withDefectBoundary(fn: () => Promise<void>): Promise<void>;
2739
+
2740
+ declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
2741
+
2742
+ export { }