@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.11

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 (51) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE.md +0 -46
  3. package/dist/index.browser.js +1 -1
  4. package/dist/index.server.d.ts +0 -4
  5. package/dist/index.server.js +23 -407
  6. package/dist/middleware/elysia.js +2 -2
  7. package/dist/middleware/express.js +1 -1
  8. package/dist/middleware/fastify.js +2 -2
  9. package/dist/middleware/next/handler.d.ts +1 -1
  10. package/dist/middleware/next/middleware.d.ts +1 -1
  11. package/dist/packem_shared/{AbstractJsonReporter-DlugSJpY.js → AbstractJsonReporter-BO8Calb4.js} +1 -5
  12. package/dist/packem_shared/{AbstractJsonReporter-CjtVgHbU.js → AbstractJsonReporter-nOj0Ft1F.js} +1 -5
  13. package/dist/packem_shared/{JsonReporter-Dbw82ewj.js → JsonReporter-CCmj7oYL.js} +1 -1
  14. package/dist/packem_shared/{JsonReporter-BgPvIyC2.js → JsonReporter-Ck2PIAEw.js} +2 -2
  15. package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-BCvyNzXO.js} +1239 -7
  16. package/dist/packem_shared/{PrettyReporter-C2dCzIaf.js → PrettyReporter-BtTr13Ha.js} +1 -3
  17. package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CXAKYCb8.js} +2296 -2296
  18. package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
  19. package/dist/pail.server.d.ts +1 -76
  20. package/dist/processor/caller/caller-processor.js +1 -1
  21. package/dist/processor/environment-processor.js +10 -3
  22. package/dist/reporter/file/json-file-reporter.js +1 -1
  23. package/dist/reporter/http/abstract-http-reporter.js +1 -1
  24. package/dist/reporter/http/http-reporter.edge-light.js +1 -5
  25. package/dist/reporter/json/index.browser.js +2 -2
  26. package/dist/reporter/json/index.js +2 -2
  27. package/dist/reporter/pretty/index.browser.js +1 -1
  28. package/dist/reporter/pretty/index.js +1 -1
  29. package/dist/reporter/pretty/pretty-reporter.server.d.ts +1 -1
  30. package/dist/reporter/raw/raw-reporter.server.d.ts +1 -1
  31. package/dist/reporter/simple/simple-reporter.server.d.ts +1 -1
  32. package/dist/reporter/simple/simple-reporter.server.js +1 -1
  33. package/dist/types.d.ts +1 -1
  34. package/dist/utils/write-console-log-based-on-level.d.ts +1 -1
  35. package/dist/wide-event.d.ts +1 -1
  36. package/dist/wide-event.js +3 -2
  37. package/package.json +6 -17
  38. package/dist/interactive/index.d.ts +0 -2
  39. package/dist/interactive/index.js +0 -2
  40. package/dist/interactive/interactive-manager.d.ts +0 -108
  41. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  42. package/dist/packem_shared/InteractiveManager-CowYA3Hx.js +0 -178
  43. package/dist/packem_shared/InteractiveStreamHook-BypRlYTX.js +0 -133
  44. package/dist/packem_shared/Spinner-Cokext9b.js +0 -2183
  45. package/dist/packem_shared/getBarChar-D7JfmdTr.js +0 -459
  46. package/dist/packem_shared/index-BEfVUy9P.js +0 -1256
  47. package/dist/progress-bar.d.ts +0 -145
  48. package/dist/progress-bar.js +0 -459
  49. package/dist/spinner.d.ts +0 -220
  50. package/dist/spinner.js +0 -2183
  51. package/dist/utils/ansi-escapes.d.ts +0 -4
@@ -1,5 +1,5 @@
1
1
  const writeStream = (data, stream) => {
2
- const write = stream.__write ?? stream.write.bind(stream);
2
+ const write = stream["__write"] ?? stream.write.bind(stream);
3
3
  return write.call(stream, data);
4
4
  };
5
5
 
@@ -1,9 +1,5 @@
1
- import InteractiveManager from "./interactive/interactive-manager.d.ts";
1
+ import { InteractiveManager } from "@visulima/interactive-manager";
2
2
  import { PailBrowserImpl } from "./pail.d.ts";
3
- import type { MultiBarOptions, SingleBarOptions } from "./progress-bar.d.ts";
4
- import { MultiProgressBar, ProgressBar } from "./progress-bar.d.ts";
5
- import type { SpinnerOptions } from "./spinner.d.ts";
6
- import { MultiSpinner, Spinner } from "./spinner.d.ts";
7
3
  import type { ConstructorOptions, DefaultLogTypes, LoggerFunction, Reporter, ServerConstructorOptions } from "./types.d.ts";
8
4
  declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
9
5
  #private;
@@ -138,77 +134,6 @@ declare class PailServerImpl<T extends string = string, L extends string = strin
138
134
  * ```
139
135
  */
140
136
  restoreAll(): void;
141
- /**
142
- * Creates a single progress bar.
143
- * @param options Configuration options for the progress bar
144
- * @returns A new ProgressBar instance
145
- * @example
146
- * ```typescript
147
- * const logger = createPail({ interactive: true });
148
- * const bar = logger.createProgressBar({
149
- * total: 100,
150
- * format: 'Downloading [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'
151
- * });
152
- *
153
- * bar.start();
154
- * // ... do work and update progress
155
- * bar.update(50);
156
- * bar.stop();
157
- * ```
158
- */
159
- createProgressBar(options: SingleBarOptions): ProgressBar;
160
- /**
161
- * Creates a multi-bar progress manager for displaying multiple progress bars.
162
- * @param options Configuration options for the multi-bar manager
163
- * @returns A new MultiProgressBar instance
164
- * @example
165
- * ```typescript
166
- * const logger = createPail({ interactive: true });
167
- * const multiBar = logger.createMultiProgressBar();
168
- *
169
- * const bar1 = multiBar.create(100);
170
- * const bar2 = multiBar.create(200);
171
- *
172
- * bar1.start();
173
- * bar2.start();
174
- * // ... update bars as needed
175
- * multiBar.stop();
176
- * ```
177
- */
178
- createMultiProgressBar(options?: MultiBarOptions): MultiProgressBar;
179
- /**
180
- * Creates a single spinner.
181
- * @param options Configuration options for the spinner
182
- * @returns A new Spinner instance
183
- * @example
184
- * ```typescript
185
- * const logger = createPail({ interactive: true });
186
- * const spinner = logger.createSpinner({ name: 'dots' });
187
- * spinner.start('Loading...');
188
- * // ... do work
189
- * spinner.succeed('Done');
190
- * ```
191
- */
192
- createSpinner(options?: SpinnerOptions): Spinner;
193
- /**
194
- * Creates a multi-spinner manager for displaying multiple spinners.
195
- * @param options Configuration options for the multi-spinner manager
196
- * @returns A new MultiSpinner instance
197
- * @example
198
- * ```typescript
199
- * const logger = createPail({ interactive: true });
200
- * const multiSpinner = logger.createMultiSpinner();
201
- *
202
- * const spinner1 = multiSpinner.create('Loading 1');
203
- * const spinner2 = multiSpinner.create('Loading 2');
204
- *
205
- * spinner1.start();
206
- * spinner2.start();
207
- * // ... update spinners as needed
208
- * multiSpinner.stop();
209
- * ```
210
- */
211
- createMultiSpinner(options?: SpinnerOptions): MultiSpinner;
212
137
  /**
213
138
  * Clears the terminal screen.
214
139
  *
@@ -18,7 +18,7 @@ const getCallerFilename = () => {
18
18
  });
19
19
  return accumulator;
20
20
  }, []);
21
- const firstExternalFilePath = callers[0];
21
+ const firstExternalFilePath = callers.at(0);
22
22
  if (firstExternalFilePath) {
23
23
  return {
24
24
  columnNumber: firstExternalFilePath.columnNumber ?? void 0,
@@ -14,11 +14,18 @@ const detectEnvironment = () => {
14
14
  // PID
15
15
  pid: process.pid,
16
16
  // Region (including GCP Cloud Functions FUNCTION_REGION and GOOGLE_CLOUD_REGION)
17
- region: env.AWS_REGION || env.VERCEL_REGION || env.FLY_REGION || env.RENDER_REGION || env.CF_REGION || env.GOOGLE_CLOUD_REGION || env.FUNCTION_REGION || void 0,
17
+ region: env.AWS_REGION || env.VERCEL_REGION || env.FLY_REGION || env.RENDER_REGION || env.CF_REGION || env.GOOGLE_CLOUD_REGION || // GCP general
18
+ env.FUNCTION_REGION || // GCP Cloud Functions
19
+ void 0,
18
20
  // Service name - check common platform variables (including GCP Cloud Run / App Engine)
19
- service: env.SERVICE_NAME || env.APP_NAME || env.K_SERVICE || env.GAE_SERVICE || env.FUNCTION_TARGET || env.VERCEL_PROJECT_PRODUCTION_URL || env.FLY_APP_NAME || env.RAILWAY_SERVICE_NAME || env.RENDER_SERVICE_NAME || env.HEROKU_APP_NAME || void 0,
21
+ service: env.SERVICE_NAME || env.APP_NAME || env.K_SERVICE || // GCP Cloud Run
22
+ env.GAE_SERVICE || // GCP App Engine
23
+ env.FUNCTION_TARGET || // GCP Cloud Functions
24
+ env.VERCEL_PROJECT_PRODUCTION_URL || env.FLY_APP_NAME || env.RAILWAY_SERVICE_NAME || env.RENDER_SERVICE_NAME || env.HEROKU_APP_NAME || void 0,
20
25
  // Version (including GCP Cloud Run K_REVISION and App Engine GAE_VERSION)
21
- version: env.APP_VERSION || env.npm_package_version || env.K_REVISION || env.GAE_VERSION || env.RAILWAY_GIT_COMMIT_SHA?.slice(0, 7) || env.RENDER_GIT_COMMIT?.slice(0, 7) || void 0
26
+ version: env.APP_VERSION || env.npm_package_version || env.K_REVISION || // GCP Cloud Run revision
27
+ env.GAE_VERSION || // GCP App Engine version
28
+ env.RAILWAY_GIT_COMMIT_SHA?.slice(0, 7) || env.RENDER_GIT_COMMIT?.slice(0, 7) || void 0
22
29
  /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing */
23
30
  };
24
31
  return Object.fromEntries(Object.entries(info).filter(([, v]) => v !== void 0));
@@ -1,4 +1,4 @@
1
- import { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-CjtVgHbU.js';
1
+ import { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-nOj0Ft1F.js';
2
2
 
3
3
  class SafeStreamHandler {
4
4
  #ready = true;
@@ -20,7 +20,7 @@ const __cjs_getBuiltinModule = (module) => {
20
20
  const {
21
21
  Buffer
22
22
  } = __cjs_getBuiltinModule("node:buffer");
23
- import { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-CjtVgHbU.js';
23
+ import { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-nOj0Ft1F.js';
24
24
  const {
25
25
  gzipSync
26
26
  } = __cjs_getBuiltinModule("node:zlib");
@@ -284,11 +284,7 @@ class AbstractJsonReporter {
284
284
  if (file) {
285
285
  rest.file = `${file.name ?? ""}:${String(file.line)}${file.column ? `:${String(file.column)}` : ""}`;
286
286
  }
287
- if (message === EMPTY_SYMBOL) {
288
- rest.message = void 0;
289
- } else {
290
- rest.message = message;
291
- }
287
+ rest.message = message === EMPTY_SYMBOL ? void 0 : message;
292
288
  if (error) {
293
289
  rest.error = serialize(error, this.errorOptions);
294
290
  }
@@ -1,2 +1,2 @@
1
- export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-DlugSJpY.js';
2
- export { default as JsonReporter } from '../../packem_shared/JsonReporter-Dbw82ewj.js';
1
+ export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-BO8Calb4.js';
2
+ export { default as JsonReporter } from '../../packem_shared/JsonReporter-CCmj7oYL.js';
@@ -1,2 +1,2 @@
1
- export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-CjtVgHbU.js';
2
- export { default as JsonReporter } from '../../packem_shared/JsonReporter-BgPvIyC2.js';
1
+ export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-nOj0Ft1F.js';
2
+ export { default as JsonReporter } from '../../packem_shared/JsonReporter-Ck2PIAEw.js';
@@ -1 +1 @@
1
- export { default as PrettyReporter } from '../../packem_shared/PrettyReporter-C2dCzIaf.js';
1
+ export { default as PrettyReporter } from '../../packem_shared/PrettyReporter-BtTr13Ha.js';
@@ -1 +1 @@
1
- export { PrettyReporter } from '../../packem_shared/PrettyReporter-gMqa7j_m.js';
1
+ export { PrettyReporter } from '../../packem_shared/PrettyReporter-BCvyNzXO.js';
@@ -1,7 +1,7 @@
1
1
  import type { RenderErrorOptions } from "@visulima/error/error";
2
2
  import type { Options as InspectorOptions } from "@visulima/inspector";
3
+ import type { InteractiveManager } from "@visulima/interactive-manager";
3
4
  import type { LiteralUnion } from "type-fest";
4
- import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
5
5
  import type { ExtendedRfc5424LogLevels, InteractiveStreamReporter, ReadonlyMeta } from "../../types.d.ts";
6
6
  import type { PrettyStyleOptions } from "./abstract-pretty-reporter.d.ts";
7
7
  import { AbstractPrettyReporter } from "./abstract-pretty-reporter.d.ts";
@@ -1,5 +1,5 @@
1
1
  import type { Options as InspectorOptions } from "@visulima/inspector";
2
- import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
2
+ import type { InteractiveManager } from "@visulima/interactive-manager";
3
3
  import type { ReadonlyMeta, StreamAwareReporter } from "../../types.d.ts";
4
4
  declare class RawReporter<L extends string = string> implements StreamAwareReporter<L> {
5
5
  #private;
@@ -1,6 +1,6 @@
1
1
  import type { RenderErrorOptions } from "@visulima/error";
2
2
  import type { Options as InspectorOptions } from "@visulima/inspector";
3
- import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
3
+ import type { InteractiveManager } from "@visulima/interactive-manager";
4
4
  import type { InteractiveStreamReporter, ReadonlyMeta } from "../../types.d.ts";
5
5
  import type { PrettyStyleOptions } from "../pretty/abstract-pretty-reporter.d.ts";
6
6
  import { AbstractPrettyReporter } from "../pretty/abstract-pretty-reporter.d.ts";
@@ -9,7 +9,7 @@ const {
9
9
  stderr
10
10
  } = __cjs_getProcess;
11
11
  import colorize, { red, greenBright, cyan, green, grey, bold, bgGrey, underline, white } from '@visulima/colorize';
12
- import { A as AbstractPrettyReporter, d as defaultInspectorConfig, b as writeStream, t as terminalSize, c as getLongestBadge, g as getLongestLabel, e as getStringWidth, f as formatLabel, a as EMPTY_SYMBOL, i as inspect, w as wordWrap, r as renderError, W as WrapMode } from '../../packem_shared/abstract-pretty-reporter-szQO-IgK.js';
12
+ import { A as AbstractPrettyReporter, d as defaultInspectorConfig, w as writeStream, t as terminalSize, b as getLongestBadge, g as getLongestLabel, c as getStringWidth, f as formatLabel, a as EMPTY_SYMBOL, i as inspect, e as wordWrap, r as renderError, W as WrapMode } from '../../packem_shared/abstract-pretty-reporter-CXAKYCb8.js';
13
13
 
14
14
  const PAIL_DIST_REGEX = /[\\/]pail[\\/]dist/;
15
15
  const pailFileFilter = (line) => !PAIL_DIST_REGEX.test(line);
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AnsiColors } from "@visulima/colorize";
2
+ import type { InteractiveManager } from "@visulima/interactive-manager";
2
3
  import type { stringify } from "safe-stable-stringify";
3
4
  import type { LiteralUnion, Primitive } from "type-fest";
4
- import type InteractiveManager from "./interactive/interactive-manager.d.ts";
5
5
  /**
6
6
  * Global namespace for extending Pail's metadata interface.
7
7
  *
@@ -1,4 +1,4 @@
1
1
  import type { LiteralUnion } from "type-fest";
2
2
  import type { ExtendedRfc5424LogLevels } from "../types.d.ts";
3
- declare const writeConsoleLogBasedOnLevel: <L extends string = string>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>) => (...data: any[]) => void;
3
+ declare const writeConsoleLogBasedOnLevel: <L extends string = string>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>) => ((...data: any[]) => void);
4
4
  export default writeConsoleLogBasedOnLevel;
@@ -140,7 +140,7 @@ export declare class WideEvent<TData extends Record<string, unknown> = Record<st
140
140
  private readonly startTime;
141
141
  private status;
142
142
  private readonly timestamp;
143
- private readonly type;
143
+ private readonly _type;
144
144
  constructor(options: WideEventOptions<T>);
145
145
  /**
146
146
  * Record a debug-level lifecycle log entry.
@@ -66,7 +66,8 @@ class WideEvent {
66
66
  startTime;
67
67
  status;
68
68
  timestamp;
69
- type;
69
+ // @ts-expect-error TS6133 -- preserved for future use (richer event categorization)
70
+ _type;
70
71
  constructor(options) {
71
72
  this.name = options.name;
72
73
  this.pail = options.pail;
@@ -75,7 +76,7 @@ class WideEvent {
75
76
  this.timestamp = (/* @__PURE__ */ new Date()).toISOString();
76
77
  this.emitted = false;
77
78
  this.autoEmit = options.autoEmit ?? true;
78
- this.type = options.type ?? "info";
79
+ this._type = options.type ?? "info";
79
80
  this.level = "info";
80
81
  this.requestLogs = [];
81
82
  this.service = options.service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "4.0.0-alpha.10",
3
+ "version": "4.0.0-alpha.11",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -190,18 +190,6 @@
190
190
  "default": "./dist/reporter/http/http-reporter.js"
191
191
  }
192
192
  },
193
- "./progress-bar": {
194
- "types": "./dist/progress-bar.d.ts",
195
- "default": "./dist/progress-bar.js"
196
- },
197
- "./spinner": {
198
- "types": "./dist/spinner.d.ts",
199
- "default": "./dist/spinner.js"
200
- },
201
- "./interactive": {
202
- "types": "./dist/interactive/index.d.ts",
203
- "default": "./dist/interactive/index.js"
204
- },
205
193
  "./object-tree": {
206
194
  "types": "./dist/object-tree.d.ts",
207
195
  "default": "./dist/object-tree.js"
@@ -243,13 +231,14 @@
243
231
  "LICENSE.md"
244
232
  ],
245
233
  "dependencies": {
246
- "@visulima/colorize": "2.0.0-alpha.8",
247
- "type-fest": "5.5.0"
234
+ "@visulima/colorize": "2.0.0-alpha.10",
235
+ "@visulima/interactive-manager": "1.0.0-alpha.2",
236
+ "type-fest": "5.6.0"
248
237
  },
249
238
  "peerDependencies": {
250
239
  "@opentelemetry/api": "1.9.1",
251
240
  "@sveltejs/kit": ">=2.0",
252
- "@visulima/redact": "3.0.0-alpha.8",
241
+ "@visulima/redact": "3.0.0-alpha.10",
253
242
  "elysia": ">=1.0",
254
243
  "express": ">=4.0",
255
244
  "fastify": ">=4.0",
@@ -287,7 +276,7 @@
287
276
  }
288
277
  },
289
278
  "engines": {
290
- "node": ">=22.13 <=25.x"
279
+ "node": "^22.14.0 || >=24.10.0"
291
280
  },
292
281
  "os": [
293
282
  "darwin",
@@ -1,2 +0,0 @@
1
- export { default as InteractiveManager } from "./interactive-manager.d.ts";
2
- export { default as InteractiveStreamHook } from "./interactive-stream-hook.d.ts";
@@ -1,2 +0,0 @@
1
- export { default as InteractiveManager } from '../packem_shared/InteractiveManager-CowYA3Hx.js';
2
- export { default as InteractiveStreamHook } from '../packem_shared/InteractiveStreamHook-BypRlYTX.js';
@@ -1,108 +0,0 @@
1
- import type InteractiveStreamHook from "./interactive-stream-hook.d.ts";
2
- /** Supported stream types for interactive output */
3
- type StreamType = "stderr" | "stdout";
4
- /**
5
- * Interactive Manager.
6
- *
7
- * Manages interactive terminal output by coordinating stdout and stderr streams.
8
- * Enables features like progress bars, spinners, and dynamic updates by temporarily
9
- * capturing and controlling terminal output. Supports suspending and resuming
10
- * interactive mode for external output.
11
- * @example
12
- * ```typescript
13
- * const manager = new InteractiveManager(stdoutHook, stderrHook);
14
- *
15
- * // Start interactive mode
16
- * manager.hook();
17
- *
18
- * // Update output dynamically
19
- * manager.update("stdout", ["Processing...", "50% complete"]);
20
- *
21
- * // Temporarily suspend for external output
22
- * manager.suspend("stdout");
23
- * console.log("External message");
24
- * manager.resume("stdout");
25
- *
26
- * // End interactive mode and show final output
27
- * manager.unhook();
28
- * ```
29
- */
30
- declare class InteractiveManager {
31
- #private;
32
- /**
33
- * Creates a new InteractiveManager with the given stream hooks.
34
- * @param stdout Hook for stdout stream
35
- * @param stderr Hook for stderr stream
36
- */
37
- constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
38
- /**
39
- * Last printed rows count.
40
- *
41
- * Tracks the number of rows that were last written to the terminal.
42
- * Used internally for managing cursor positioning and output updates.
43
- */
44
- get lastLength(): number;
45
- /**
46
- * Rows count outside editable area.
47
- *
48
- * Tracks the number of rows that extend beyond the current terminal height.
49
- * Used for managing scrolling and ensuring all output remains visible.
50
- */
51
- get outside(): number;
52
- /**
53
- * Hook activity status.
54
- *
55
- * Indicates whether the interactive hooks are currently active.
56
- * When true, streams are being intercepted for interactive output.
57
- */
58
- get isHooked(): boolean;
59
- /**
60
- * Suspend status for active hooks.
61
- *
62
- * Indicates whether interactive mode is temporarily suspended.
63
- * When suspended, external output can be written without interference.
64
- */
65
- get isSuspended(): boolean;
66
- /**
67
- * Removes lines from the terminal output.
68
- *
69
- * Erases the specified number of lines from the bottom of the output,
70
- * moving the cursor up and clearing the lines. Useful for removing
71
- * previous interactive output before displaying new content.
72
- * @param stream The stream to erase lines from ("stdout" or "stderr")
73
- * @param count Number of lines to remove (defaults to lastLength)
74
- * @throws {TypeError} If the specified stream is not available
75
- */
76
- erase(stream: StreamType, count?: number): void;
77
- /**
78
- * Hook stdout and stderr streams.
79
- * @returns Success status
80
- */
81
- hook(): boolean;
82
- /**
83
- * Resume suspend hooks.
84
- * @param stream Stream to resume
85
- * @param eraseRowCount erase output rows count
86
- */
87
- resume(stream: StreamType, eraseRowCount?: number): void;
88
- /**
89
- * Suspend active hooks for external output.
90
- * @param stream Stream to suspend
91
- * @param erase erase output
92
- */
93
- suspend(stream: StreamType, erase?: boolean): void;
94
- /**
95
- * Unhooks both stdout and stderr streams and print their story of logs.
96
- * @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
97
- * @returns Success status
98
- */
99
- unhook(separateHistory?: boolean): boolean;
100
- /**
101
- * Update output.
102
- * @param stream Stream to write to
103
- * @param rows Text lines to write to standard output
104
- * @param from Index of the line starting from which the contents of the terminal are being overwritten
105
- */
106
- update(stream: StreamType, rows: string[], from?: number): void;
107
- }
108
- export default InteractiveManager;
@@ -1,68 +0,0 @@
1
- /**
2
- * Interactive Stream Hook.
3
- *
4
- * A utility class that hooks into Node.js WriteStreams to capture output
5
- * for interactive terminal applications. It allows temporarily intercepting
6
- * stream writes to enable features like progress bars and dynamic updates.
7
- * @example
8
- * ```typescript
9
- * const hook = new InteractiveStreamHook(process.stdout);
10
- * hook.active(); // Start capturing output
11
- *
12
- * // Output will be stored in history instead of being written to stdout
13
- * console.log("This won't appear immediately");
14
- *
15
- * hook.inactive(); // Stop capturing and replay stored output
16
- * ```
17
- */
18
- declare class InteractiveStreamHook {
19
- #private;
20
- /** Constant indicating the stream write operation was successful */
21
- static readonly DRAIN = true;
22
- /**
23
- * Creates a new InteractiveStreamHook for the given stream.
24
- * @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
25
- */
26
- constructor(stream: NodeJS.WriteStream);
27
- /**
28
- * Activates the stream hook.
29
- *
30
- * When active, all writes to the stream are captured in history instead of
31
- * being written immediately. This allows for interactive features like
32
- * progress bars that can update dynamically.
33
- */
34
- active(): void;
35
- /**
36
- * Erases the specified number of lines from the terminal.
37
- *
38
- * Uses ANSI escape sequences to remove lines from the current cursor position
39
- * upwards, which is useful for clearing previous output in interactive applications.
40
- * @param count Number of lines to erase (including the current line)
41
- */
42
- erase(count: number): void;
43
- /**
44
- * Deactivates the stream hook and replays captured output.
45
- *
46
- * Restores normal stream operation and outputs all captured history.
47
- * Optionally adds a newline separator before replaying the history.
48
- * @param separateHistory Whether to add a newline before replaying history
49
- */
50
- inactive(separateHistory?: boolean): void;
51
- /**
52
- * Renews the stream hook state.
53
- *
54
- * Restores the original stream write method and shows the cursor.
55
- * This is typically called when temporarily suspending interactive mode.
56
- */
57
- renew(): void;
58
- /**
59
- * Writes a message directly to the underlying stream.
60
- *
61
- * Bypasses the hook mechanism and writes directly using the original
62
- * stream write method. Useful for writing control sequences or
63
- * messages that should not be captured in history.
64
- * @param message The message to write to the stream
65
- */
66
- write(message: string): void;
67
- }
68
- export default InteractiveStreamHook;