@rushstack/terminal 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@rushstack/terminal",
3
3
  "entries": [
4
+ {
5
+ "version": "0.19.0",
6
+ "tag": "@rushstack/terminal_v0.19.0",
7
+ "date": "Fri, 03 Oct 2025 20:10:00 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "Normalize import of builtin modules to use the `node:` protocol."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.16.0`"
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "version": "0.18.0",
23
+ "tag": "@rushstack/terminal_v0.18.0",
24
+ "date": "Tue, 30 Sep 2025 23:57:45 GMT",
25
+ "comments": {
26
+ "minor": [
27
+ {
28
+ "comment": "Add ProblemCollector.onProblem notification callback"
29
+ },
30
+ {
31
+ "comment": "Update API contract for `SplitterTransform` to support adding and removing destinations after creation."
32
+ }
33
+ ],
34
+ "dependency": [
35
+ {
36
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.15.1`"
37
+ },
38
+ {
39
+ "comment": "Updating dependency \"@rushstack/problem-matcher\" to `0.1.1`"
40
+ }
41
+ ]
42
+ }
43
+ },
4
44
  {
5
45
  "version": "0.17.0",
6
46
  "tag": "@rushstack/terminal_v0.17.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Change Log - @rushstack/terminal
2
2
 
3
- This log was last generated on Tue, 30 Sep 2025 20:33:51 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 03 Oct 2025 20:10:00 GMT and should not be manually modified.
4
+
5
+ ## 0.19.0
6
+ Fri, 03 Oct 2025 20:10:00 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Normalize import of builtin modules to use the `node:` protocol.
11
+
12
+ ## 0.18.0
13
+ Tue, 30 Sep 2025 23:57:45 GMT
14
+
15
+ ### Minor changes
16
+
17
+ - Add ProblemCollector.onProblem notification callback
18
+ - Update API contract for `SplitterTransform` to support adding and removing destinations after creation.
4
19
 
5
20
  ## 0.17.0
6
21
  Tue, 30 Sep 2025 20:33:51 GMT
@@ -15,8 +15,8 @@ import type { IProblem } from '@rushstack/problem-matcher';
15
15
  import type { IProblemMatcher } from '@rushstack/problem-matcher';
16
16
  import type { IProblemMatcherJson } from '@rushstack/problem-matcher';
17
17
  import { NewlineKind } from '@rushstack/node-core-library';
18
- import { Writable } from 'stream';
19
- import { WritableOptions } from 'stream';
18
+ import { Writable } from 'node:stream';
19
+ import { WritableOptions } from 'node:stream';
20
20
 
21
21
  /**
22
22
  * Operations for working with text strings that contain
@@ -315,6 +315,10 @@ export declare interface IProblemCollectorOptions extends ITerminalWritableOptio
315
315
  * {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} definitions.
316
316
  */
317
317
  matcherJson?: IProblemMatcherJson[];
318
+ /**
319
+ * Optional callback invoked immediately whenever a problem is produced.
320
+ */
321
+ onProblem?: (problem: IProblem) => void;
318
322
  }
319
323
 
320
324
  /**
@@ -324,9 +328,9 @@ export declare interface IProblemCollectorOptions extends ITerminalWritableOptio
324
328
  */
325
329
  export declare interface ISplitterTransformOptions extends ITerminalWritableOptions {
326
330
  /**
327
- * Each input chunk will be passed to each destination in the array.
331
+ * Each input chunk will be passed to each destination in the iterable.
328
332
  */
329
- destinations: TerminalWritable[];
333
+ destinations: Iterable<TerminalWritable>;
330
334
  }
331
335
 
332
336
  /**
@@ -779,6 +783,7 @@ export declare class PrintUtilities {
779
783
  export declare class ProblemCollector extends TerminalWritable implements IProblemCollector {
780
784
  private readonly _matchers;
781
785
  private readonly _problems;
786
+ private readonly _onProblem;
782
787
  constructor(options: IProblemCollectorOptions);
783
788
  /**
784
789
  * {@inheritdoc IProblemCollector}
@@ -823,8 +828,25 @@ export declare class RemoveColorsTextRewriter extends TextRewriter {
823
828
  * @public
824
829
  */
825
830
  export declare class SplitterTransform extends TerminalWritable {
826
- readonly destinations: ReadonlyArray<TerminalWritable>;
831
+ private readonly _destinations;
827
832
  constructor(options: ISplitterTransformOptions);
833
+ get destinations(): ReadonlySet<TerminalWritable>;
834
+ /**
835
+ * Adds a destination to the set of destinations. Duplicates are ignored.
836
+ * Only new chunks received after the destination is added will be sent to it.
837
+ * @param destination - The destination to add.
838
+ */
839
+ addDestination(destination: TerminalWritable): void;
840
+ /**
841
+ * Removes a destination from the set of destinations. It will no longer receive chunks, and will be closed, unless
842
+ * `destination.preventAutoclose` is set to `true`.
843
+ * @param destination - The destination to remove.
844
+ * @param close - If `true` (default), the destination will be closed when removed, unless `destination.preventAutoclose` is set to `true`.
845
+ * @returns `true` if the destination was removed, `false` if it was not found.
846
+ * @remarks
847
+ * If the destination is not found, it will not be closed.
848
+ */
849
+ removeDestination(destination: TerminalWritable, close?: boolean): boolean;
828
850
  protected onWriteChunk(chunk: ITerminalChunk): void;
829
851
  protected onClose(): void;
830
852
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.11"
8
+ "packageVersion": "7.52.15"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleTerminalProvider.d.ts","sourceRoot":"","sources":["../src/ConsoleTerminalProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEvF;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,gBAAuB,aAAa,EAAE,OAAO,CAAoD;IAEjG;;OAEG;IACI,cAAc,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACI,YAAY,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,SAAgB,aAAa,EAAE,OAAO,CAAyC;gBAE5D,OAAO,GAAE,OAAO,CAAC,+BAA+B,CAAM;IAKzE;;OAEG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IA8BpE;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;CACF"}
1
+ {"version":3,"file":"ConsoleTerminalProvider.d.ts","sourceRoot":"","sources":["../src/ConsoleTerminalProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEvF;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,gBAAuB,aAAa,EAAE,OAAO,CAAoD;IAEjG;;OAEG;IACI,cAAc,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACI,YAAY,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,SAAgB,aAAa,EAAE,OAAO,CAAyC;gBAE5D,OAAO,GAAE,OAAO,CAAC,+BAA+B,CAAM;IAKzE;;OAEG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IA8BpE;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;CACF"}
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.ConsoleTerminalProvider = void 0;
9
- const os_1 = require("os");
9
+ const node_os_1 = require("node:os");
10
10
  const supports_color_1 = __importDefault(require("supports-color"));
11
11
  const ITerminalProvider_1 = require("./ITerminalProvider");
12
12
  /**
@@ -57,7 +57,7 @@ class ConsoleTerminalProvider {
57
57
  * {@inheritDoc ITerminalProvider.eolCharacter}
58
58
  */
59
59
  get eolCharacter() {
60
- return os_1.EOL;
60
+ return node_os_1.EOL;
61
61
  }
62
62
  }
63
63
  exports.ConsoleTerminalProvider = ConsoleTerminalProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleTerminalProvider.js","sourceRoot":"","sources":["../src/ConsoleTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,2BAAyB;AACzB,oEAA2C;AAE3C,2DAAuF;AAqBvF;;;;;GAKG;AACH,MAAa,uBAAuB;IAkBlC,YAAmB,UAAoD,EAAE;QALzE;;WAEG;QACa,kBAAa,GAAY,uBAAuB,CAAC,aAAa,CAAC;QAG7E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,OAAO,CAAC;YACtC,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,GAAG,CAAC;YAClC,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,QAAG,CAAC;IACb,CAAC;;AA7DH,0DA8DC;AA7DwB,qCAAa,GAAY,CAAC,CAAC,wBAAa,CAAC,MAAM,IAAI,CAAC,CAAC,wBAAa,CAAC,MAAM,AAA5D,CAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { EOL } from 'os';\nimport supportsColor from 'supports-color';\n\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * Options to be provided to a {@link ConsoleTerminalProvider}\n *\n * @beta\n */\nexport interface IConsoleTerminalProviderOptions {\n /**\n * If true, print verbose logging messages.\n */\n verboseEnabled: boolean;\n\n /**\n * If true, print debug logging messages. Note that \"verbose\" and \"debug\" are considered\n * separate message filters; if you want debug to imply verbose, it is up to your\n * application code to enforce that.\n */\n debugEnabled: boolean;\n}\n\n/**\n * Terminal provider that prints to STDOUT (for log- and verbose-level messages) and\n * STDERR (for warning- and error-level messages).\n *\n * @beta\n */\nexport class ConsoleTerminalProvider implements ITerminalProvider {\n public static readonly supportsColor: boolean = !!supportsColor.stdout && !!supportsColor.stderr;\n\n /**\n * If true, verbose-level messages should be written to the console.\n */\n public verboseEnabled: boolean;\n\n /**\n * If true, debug-level messages should be written to the console.\n */\n public debugEnabled: boolean;\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public readonly supportsColor: boolean = ConsoleTerminalProvider.supportsColor;\n\n public constructor(options: Partial<IConsoleTerminalProviderOptions> = {}) {\n this.verboseEnabled = !!options.verboseEnabled;\n this.debugEnabled = !!options.debugEnabled;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning:\n case TerminalProviderSeverity.error: {\n process.stderr.write(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n if (this.verboseEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n if (this.debugEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n process.stdout.write(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return EOL;\n }\n}\n"]}
1
+ {"version":3,"file":"ConsoleTerminalProvider.js","sourceRoot":"","sources":["../src/ConsoleTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,qCAA8B;AAE9B,oEAA2C;AAE3C,2DAAuF;AAqBvF;;;;;GAKG;AACH,MAAa,uBAAuB;IAkBlC,YAAmB,UAAoD,EAAE;QALzE;;WAEG;QACa,kBAAa,GAAY,uBAAuB,CAAC,aAAa,CAAC;QAG7E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,OAAO,CAAC;YACtC,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,GAAG,CAAC;YAClC,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,aAAG,CAAC;IACb,CAAC;;AA7DH,0DA8DC;AA7DwB,qCAAa,GAAY,CAAC,CAAC,wBAAa,CAAC,MAAM,IAAI,CAAC,CAAC,wBAAa,CAAC,MAAM,AAA5D,CAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { EOL } from 'node:os';\n\nimport supportsColor from 'supports-color';\n\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * Options to be provided to a {@link ConsoleTerminalProvider}\n *\n * @beta\n */\nexport interface IConsoleTerminalProviderOptions {\n /**\n * If true, print verbose logging messages.\n */\n verboseEnabled: boolean;\n\n /**\n * If true, print debug logging messages. Note that \"verbose\" and \"debug\" are considered\n * separate message filters; if you want debug to imply verbose, it is up to your\n * application code to enforce that.\n */\n debugEnabled: boolean;\n}\n\n/**\n * Terminal provider that prints to STDOUT (for log- and verbose-level messages) and\n * STDERR (for warning- and error-level messages).\n *\n * @beta\n */\nexport class ConsoleTerminalProvider implements ITerminalProvider {\n public static readonly supportsColor: boolean = !!supportsColor.stdout && !!supportsColor.stderr;\n\n /**\n * If true, verbose-level messages should be written to the console.\n */\n public verboseEnabled: boolean;\n\n /**\n * If true, debug-level messages should be written to the console.\n */\n public debugEnabled: boolean;\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public readonly supportsColor: boolean = ConsoleTerminalProvider.supportsColor;\n\n public constructor(options: Partial<IConsoleTerminalProviderOptions> = {}) {\n this.verboseEnabled = !!options.verboseEnabled;\n this.debugEnabled = !!options.debugEnabled;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning:\n case TerminalProviderSeverity.error: {\n process.stderr.write(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n if (this.verboseEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n if (this.debugEnabled) {\n process.stdout.write(data);\n }\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n process.stdout.write(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return EOL;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizeNewlinesTextRewriter.d.ts","sourceRoot":"","sources":["../src/NormalizeNewlinesTextRewriter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOtE;;;;GAIG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,YAAY;IAC7D,sEAAsE;IACtE,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACH,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,6EAA6E;IAC7E,SAAgB,kBAAkB,EAAE,OAAO,CAAC;gBAEzB,OAAO,EAAE,qCAAqC;IAO1D,UAAU,IAAI,iBAAiB;IAO/B,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAiC9D,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,MAAM;CAWtD"}
1
+ {"version":3,"file":"NormalizeNewlinesTextRewriter.d.ts","sourceRoot":"","sources":["../src/NormalizeNewlinesTextRewriter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOtE;;;;GAIG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,YAAY;IAC7D,sEAAsE;IACtE,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACH,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,6EAA6E;IAC7E,SAAgB,kBAAkB,EAAE,OAAO,CAAC;gBAEzB,OAAO,EAAE,qCAAqC;IAO1D,UAAU,IAAI,iBAAiB;IAO/B,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAiC9D,KAAK,CAAC,YAAY,EAAE,iBAAiB,GAAG,MAAM;CAWtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizeNewlinesTextRewriter.js","sourceRoot":"","sources":["../src/NormalizeN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iBAAiB,GAAG,IAAI,CAAC;oBAC/B,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,CAAC,CAAC;oBACZ,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC;oBAC7B,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC9B,CAAC;YACH,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;QAC5B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,YAA+B;QAC1C,MAAM,KAAK,GAAwC,YAAmD,CAAC;QACvG,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAE7B,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;YAC7B,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAtED,sEAsEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text, type NewlineKind } from '@rushstack/node-core-library';\nimport { TextRewriter, type TextRewriterState } from './TextRewriter';\n\ninterface INormalizeNewlinesTextRewriterState extends TextRewriterState {\n characterToIgnore: string;\n incompleteLine: boolean;\n}\n\n/**\n * Constructor options for {@link NormalizeNewlinesTextRewriter}\n *\n * @public\n */\nexport interface INormalizeNewlinesTextRewriterOptions {\n /**\n * Specifies how newlines should be represented in the output stream.\n */\n newlineKind: NewlineKind;\n\n /**\n * If `true`, then `NormalizeNewlinesTextRewriter.close()` will append a newline to\n * the output if it ends with an incomplete line.\n *\n * @remarks\n * If the output is an empty string, then a newline will NOT be appended,\n * because writing an empty string does not produce an incomplete line.\n */\n ensureNewlineAtEnd?: boolean;\n}\n\n/**\n * For use with {@link TextRewriterTransform}, this rewriter converts all newlines to\n * a standard format.\n *\n * @public\n */\nexport class NormalizeNewlinesTextRewriter extends TextRewriter {\n /** {@inheritDoc INormalizeNewlinesTextRewriterOptions.newlineKind} */\n public readonly newlineKind: NewlineKind;\n\n /**\n * The specific character sequence that will be used when appending newlines.\n */\n public readonly newline: string;\n\n /** {@inheritDoc INormalizeNewlinesTextRewriterOptions.ensureNewlineAtEnd} */\n public readonly ensureNewlineAtEnd: boolean;\n\n public constructor(options: INormalizeNewlinesTextRewriterOptions) {\n super();\n this.newlineKind = options.newlineKind;\n this.newline = Text.getNewline(options.newlineKind);\n this.ensureNewlineAtEnd = !!options.ensureNewlineAtEnd;\n }\n\n public initialize(): TextRewriterState {\n return {\n characterToIgnore: '',\n incompleteLine: false\n } as INormalizeNewlinesTextRewriterState;\n }\n\n public process(unknownState: TextRewriterState, text: string): string {\n const state: INormalizeNewlinesTextRewriterState = unknownState as INormalizeNewlinesTextRewriterState;\n\n let result: string = '';\n\n if (text.length > 0) {\n let i: number = 0;\n\n do {\n const c: string = text[i];\n ++i;\n\n if (c === state.characterToIgnore) {\n state.characterToIgnore = '';\n } else if (c === '\\r') {\n result += this.newline;\n state.characterToIgnore = '\\n';\n state.incompleteLine = false;\n } else if (c === '\\n') {\n result += this.newline;\n state.characterToIgnore = '\\r';\n state.incompleteLine = false;\n } else {\n result += c;\n state.characterToIgnore = '';\n state.incompleteLine = true;\n }\n } while (i < text.length);\n }\n\n return result;\n }\n\n public close(unknownState: TextRewriterState): string {\n const state: INormalizeNewlinesTextRewriterState = unknownState as INormalizeNewlinesTextRewriterState;\n state.characterToIgnore = '';\n\n if (state.incompleteLine) {\n state.incompleteLine = false;\n return this.newline;\n } else {\n return '';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"NormalizeNewlinesTextRewriter.js","sourceRoot":"","sources":["../src/NormalizeNewlinesTextRewriter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAsE;AAEtE,iDAAsE;AA6BtE;;;;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AAM,IAAI,CAAC,CAAC;oBACZ,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC;oBAC7B,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC9B,CAAC;YACH,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;QAC5B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,YAA+B;QAC1C,MAAM,KAAK,GAAwC,YAAmD,CAAC;QACvG,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAE7B,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;YAC7B,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAtED,sEAsEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text, type NewlineKind } from '@rushstack/node-core-library';\n\nimport { TextRewriter, type TextRewriterState } from './TextRewriter';\n\ninterface INormalizeNewlinesTextRewriterState extends TextRewriterState {\n characterToIgnore: string;\n incompleteLine: boolean;\n}\n\n/**\n * Constructor options for {@link NormalizeNewlinesTextRewriter}\n *\n * @public\n */\nexport interface INormalizeNewlinesTextRewriterOptions {\n /**\n * Specifies how newlines should be represented in the output stream.\n */\n newlineKind: NewlineKind;\n\n /**\n * If `true`, then `NormalizeNewlinesTextRewriter.close()` will append a newline to\n * the output if it ends with an incomplete line.\n *\n * @remarks\n * If the output is an empty string, then a newline will NOT be appended,\n * because writing an empty string does not produce an incomplete line.\n */\n ensureNewlineAtEnd?: boolean;\n}\n\n/**\n * For use with {@link TextRewriterTransform}, this rewriter converts all newlines to\n * a standard format.\n *\n * @public\n */\nexport class NormalizeNewlinesTextRewriter extends TextRewriter {\n /** {@inheritDoc INormalizeNewlinesTextRewriterOptions.newlineKind} */\n public readonly newlineKind: NewlineKind;\n\n /**\n * The specific character sequence that will be used when appending newlines.\n */\n public readonly newline: string;\n\n /** {@inheritDoc INormalizeNewlinesTextRewriterOptions.ensureNewlineAtEnd} */\n public readonly ensureNewlineAtEnd: boolean;\n\n public constructor(options: INormalizeNewlinesTextRewriterOptions) {\n super();\n this.newlineKind = options.newlineKind;\n this.newline = Text.getNewline(options.newlineKind);\n this.ensureNewlineAtEnd = !!options.ensureNewlineAtEnd;\n }\n\n public initialize(): TextRewriterState {\n return {\n characterToIgnore: '',\n incompleteLine: false\n } as INormalizeNewlinesTextRewriterState;\n }\n\n public process(unknownState: TextRewriterState, text: string): string {\n const state: INormalizeNewlinesTextRewriterState = unknownState as INormalizeNewlinesTextRewriterState;\n\n let result: string = '';\n\n if (text.length > 0) {\n let i: number = 0;\n\n do {\n const c: string = text[i];\n ++i;\n\n if (c === state.characterToIgnore) {\n state.characterToIgnore = '';\n } else if (c === '\\r') {\n result += this.newline;\n state.characterToIgnore = '\\n';\n state.incompleteLine = false;\n } else if (c === '\\n') {\n result += this.newline;\n state.characterToIgnore = '\\r';\n state.incompleteLine = false;\n } else {\n result += c;\n state.characterToIgnore = '';\n state.incompleteLine = true;\n }\n } while (i < text.length);\n }\n\n return result;\n }\n\n public close(unknownState: TextRewriterState): string {\n const state: INormalizeNewlinesTextRewriterState = unknownState as INormalizeNewlinesTextRewriterState;\n state.characterToIgnore = '';\n\n if (state.incompleteLine) {\n state.incompleteLine = false;\n return this.newline;\n } else {\n return '';\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PrefixProxyTerminalProvider.d.ts","sourceRoot":"","sources":["../src/PrefixProxyTerminalProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,uCAAuC;IACtD;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;CACrC;A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C,CAAC,CAAC,EAAE,CAAC;YAClE,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AA5DD,kEA4DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text } from '@rushstack/node-core-library';\nimport type { ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * @beta\n */\nexport interface IPrefixProxyTerminalProviderOptionsBase {\n /**\n * The {@link ITerminalProvider} that will be wrapped.\n */\n terminalProvider: ITerminalProvider;\n}\n\n/**\n * Options for {@link PrefixProxyTerminalProvider}, with a static prefix.\n *\n * @beta\n */\nexport interface IStaticPrefixProxyTerminalProviderOptions extends IPrefixProxyTerminalProviderOptionsBase {\n /**\n * The prefix that should be added to each line of output.\n */\n prefix: string;\n}\n\n/**\n * Options for {@link PrefixProxyTerminalProvider}.\n *\n * @beta\n */\nexport interface IDynamicPrefixProxyTerminalProviderOptions extends IPrefixProxyTerminalProviderOptionsBase {\n /**\n * A function that returns the prefix that should be added to each line of output. This is useful\n * for prefixing each line with a timestamp.\n */\n getPrefix: () => string;\n}\n\n/**\n * @beta\n */\nexport type IPrefixProxyTerminalProviderOptions =\n | IStaticPrefixProxyTerminalProviderOptions\n | IDynamicPrefixProxyTerminalProviderOptions;\n\n/**\n * Wraps an existing {@link ITerminalProvider} that prefixes each line of output with a specified\n * prefix string.\n *\n * @beta\n */\nexport class PrefixProxyTerminalProvider implements ITerminalProvider {\n private readonly _parentTerminalProvider: ITerminalProvider;\n private readonly _getPrefix: () => string;\n private readonly _newlineRegex: RegExp;\n private _isOnNewline: boolean;\n\n public constructor(options: IPrefixProxyTerminalProviderOptions) {\n const { terminalProvider } = options;\n\n this._parentTerminalProvider = terminalProvider;\n\n if ((options as IStaticPrefixProxyTerminalProviderOptions).prefix !== undefined) {\n const { prefix } = options as IStaticPrefixProxyTerminalProviderOptions;\n this._getPrefix = () => prefix;\n } else {\n const { getPrefix } = options as IDynamicPrefixProxyTerminalProviderOptions;\n this._getPrefix = getPrefix;\n }\n\n this._isOnNewline = true;\n\n this._newlineRegex = new RegExp(`${Text.escapeRegExp(terminalProvider.eolCharacter)}|\\\\n`, 'g');\n }\n\n /** @override */\n public get supportsColor(): boolean {\n return this._parentTerminalProvider.supportsColor;\n }\n\n /** @override */\n public get eolCharacter(): string {\n return this._parentTerminalProvider.eolCharacter;\n }\n\n /** @override */\n public write(data: string, severity: TerminalProviderSeverity): void {\n // We need to track newlines to ensure that the prefix is added to each line\n let currentIndex: number = 0;\n let newlineMatch: RegExpExecArray | null;\n\n while ((newlineMatch = this._newlineRegex.exec(data))) {\n // Extract the line, add the prefix, and write it out with the newline\n const newlineIndex: number = newlineMatch.index;\n const newIndex: number = newlineIndex + newlineMatch[0].length;\n const prefix: string = this._isOnNewline ? this._getPrefix() : '';\n const dataToWrite: string = `${prefix}${data.substring(currentIndex, newIndex)}`;\n this._parentTerminalProvider.write(dataToWrite, severity);\n // Update the currentIndex to start the search from the char after the newline\n currentIndex = newIndex;\n this._isOnNewline = true;\n }\n\n // The remaining data is not postfixed by a newline, so write out the data and set _isNewline to false\n const remainingData: string = data.substring(currentIndex);\n if (remainingData.length) {\n const prefix: string = this._isOnNewline ? this._getPrefix() : '';\n this._parentTerminalProvider.write(`${prefix}${remainingData}`, severity);\n this._isOnNewline = false;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PrefixProxyTerminalProvider.js","sourceRoot":"","sources":["../src/PrefixProxyTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAoD;AA8CpD;;;;;GAKG;AACH,MAAa,2BAA2B;IAMtC,YAAmB,OAA4C;QAC7D,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAA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AG,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;YACjF,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YAC1D,8EAA8E;YAC9E,YAAY,GAAG,QAAQ,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,sGAAsG;QACtG,MAAM,aAAa,GAAW,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,MAAM,GAAW,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AA5DD,kEA4DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text } from '@rushstack/node-core-library';\n\nimport type { ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * @beta\n */\nexport interface IPrefixProxyTerminalProviderOptionsBase {\n /**\n * The {@link ITerminalProvider} that will be wrapped.\n */\n terminalProvider: ITerminalProvider;\n}\n\n/**\n * Options for {@link PrefixProxyTerminalProvider}, with a static prefix.\n *\n * @beta\n */\nexport interface IStaticPrefixProxyTerminalProviderOptions extends IPrefixProxyTerminalProviderOptionsBase {\n /**\n * The prefix that should be added to each line of output.\n */\n prefix: string;\n}\n\n/**\n * Options for {@link PrefixProxyTerminalProvider}.\n *\n * @beta\n */\nexport interface IDynamicPrefixProxyTerminalProviderOptions extends IPrefixProxyTerminalProviderOptionsBase {\n /**\n * A function that returns the prefix that should be added to each line of output. This is useful\n * for prefixing each line with a timestamp.\n */\n getPrefix: () => string;\n}\n\n/**\n * @beta\n */\nexport type IPrefixProxyTerminalProviderOptions =\n | IStaticPrefixProxyTerminalProviderOptions\n | IDynamicPrefixProxyTerminalProviderOptions;\n\n/**\n * Wraps an existing {@link ITerminalProvider} that prefixes each line of output with a specified\n * prefix string.\n *\n * @beta\n */\nexport class PrefixProxyTerminalProvider implements ITerminalProvider {\n private readonly _parentTerminalProvider: ITerminalProvider;\n private readonly _getPrefix: () => string;\n private readonly _newlineRegex: RegExp;\n private _isOnNewline: boolean;\n\n public constructor(options: IPrefixProxyTerminalProviderOptions) {\n const { terminalProvider } = options;\n\n this._parentTerminalProvider = terminalProvider;\n\n if ((options as IStaticPrefixProxyTerminalProviderOptions).prefix !== undefined) {\n const { prefix } = options as IStaticPrefixProxyTerminalProviderOptions;\n this._getPrefix = () => prefix;\n } else {\n const { getPrefix } = options as IDynamicPrefixProxyTerminalProviderOptions;\n this._getPrefix = getPrefix;\n }\n\n this._isOnNewline = true;\n\n this._newlineRegex = new RegExp(`${Text.escapeRegExp(terminalProvider.eolCharacter)}|\\\\n`, 'g');\n }\n\n /** @override */\n public get supportsColor(): boolean {\n return this._parentTerminalProvider.supportsColor;\n }\n\n /** @override */\n public get eolCharacter(): string {\n return this._parentTerminalProvider.eolCharacter;\n }\n\n /** @override */\n public write(data: string, severity: TerminalProviderSeverity): void {\n // We need to track newlines to ensure that the prefix is added to each line\n let currentIndex: number = 0;\n let newlineMatch: RegExpExecArray | null;\n\n while ((newlineMatch = this._newlineRegex.exec(data))) {\n // Extract the line, add the prefix, and write it out with the newline\n const newlineIndex: number = newlineMatch.index;\n const newIndex: number = newlineIndex + newlineMatch[0].length;\n const prefix: string = this._isOnNewline ? this._getPrefix() : '';\n const dataToWrite: string = `${prefix}${data.substring(currentIndex, newIndex)}`;\n this._parentTerminalProvider.write(dataToWrite, severity);\n // Update the currentIndex to start the search from the char after the newline\n currentIndex = newIndex;\n this._isOnNewline = true;\n }\n\n // The remaining data is not postfixed by a newline, so write out the data and set _isNewline to false\n const remainingData: string = data.substring(currentIndex);\n if (remainingData.length) {\n const prefix: string = this._isOnNewline ? this._getPrefix() : '';\n this._parentTerminalProvider.write(`${prefix}${remainingData}`, severity);\n this._isOnNewline = false;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PrintUtilities.d.ts","sourceRoot":"","sources":["../src/PrintUtilities.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAW,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,cAAc;IACzB;;OAEG;WACW,eAAe,IAAI,MAAM,GAAG,SAAS;IAInD;;;;;;OAMG;WACW,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IACtF;;;;;;OAMG;WACW,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;IAC1F;;;;;;;OAOG;WACW,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAc3G;;;;;;OAMG;WACW,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAC/F;;;;;;OAMG;WACW,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IACnG;;;;;;;OAOG;WACW,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ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AAM,YAAY,GAAW,OAAO,GAAG,WAAW,CAAC;gBACnD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/F,CAAC;YACD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AArND,wCAqNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text } from '@rushstack/node-core-library';\nimport type { ITerminal } from './ITerminal';\n\n/**\n * A sensible fallback column width for consoles.\n *\n * @public\n */\nexport const DEFAULT_CONSOLE_WIDTH: number = 80;\n\n/**\n * A collection of utilities for printing messages to the console.\n *\n * @public\n */\nexport class PrintUtilities {\n /**\n * Returns the width of the console, measured in columns\n */\n public static getConsoleWidth(): number | undefined {\n return process.stdout?.columns;\n }\n\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWords(text: string, maxLineLength?: number, indent?: number): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWords(text: string, maxLineLength?: number, linePrefix?: string): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWords(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string;\n public static wrapWords(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string {\n const wrappedLines: string[] = PrintUtilities.wrapWordsToLines(\n text,\n maxLineLength,\n indentOrLinePrefix as string | undefined // TS is confused by the overloads\n );\n return wrappedLines.join('\\n');\n }\n\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[];\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[] {\n let linePrefix: string;\n switch (typeof indentOrLinePrefix) {\n case 'number':\n linePrefix = ' '.repeat(indentOrLinePrefix);\n break;\n case 'string':\n linePrefix = indentOrLinePrefix;\n break;\n default:\n linePrefix = '';\n break;\n }\n\n const linePrefixLength: number = linePrefix.length;\n\n if (!maxLineLength) {\n maxLineLength = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n }\n\n // Apply word wrapping and the provided line prefix, while also respecting existing newlines\n // and prefix spaces that may exist in the text string already.\n const lines: string[] = Text.splitByNewLines(text);\n\n const wrappedLines: string[] = [];\n for (const line of lines) {\n if (line.length + linePrefixLength <= maxLineLength) {\n wrappedLines.push(linePrefix + line);\n } else {\n const lineAdditionalPrefix: string = line.match(/^\\s*/)?.[0] || '';\n const whitespaceRegexp: RegExp = /\\s+/g;\n let currentWhitespaceMatch: RegExpExecArray | null = null;\n let previousWhitespaceMatch: RegExpExecArray | undefined;\n let currentLineStartIndex: number = lineAdditionalPrefix.length;\n let previousBreakRanOver: boolean = false;\n while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {\n if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {\n let whitespaceToSplitAt: RegExpExecArray | undefined;\n if (\n !previousWhitespaceMatch ||\n // Handle the case where there are two words longer than the maxLineLength in a row\n previousBreakRanOver\n ) {\n whitespaceToSplitAt = currentWhitespaceMatch;\n } else {\n whitespaceToSplitAt = previousWhitespaceMatch;\n }\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n } else {\n previousBreakRanOver = false;\n }\n\n previousWhitespaceMatch = currentWhitespaceMatch;\n }\n\n if (\n previousWhitespaceMatch &&\n line.length + linePrefixLength - currentLineStartIndex > maxLineLength\n ) {\n const whitespaceToSplitAt: RegExpExecArray = previousWhitespaceMatch;\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n }\n\n if (currentLineStartIndex < line.length) {\n wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));\n }\n }\n }\n\n return wrappedLines;\n }\n\n /**\n * Displays a message in the console wrapped in a box UI.\n *\n * @param message - The message to display.\n * @param terminal - The terminal to write the message to.\n * @param boxWidth - The width of the box, defaults to half of the console width.\n */\n public static printMessageInBox(message: string, terminal: ITerminal, boxWidth?: number): void {\n if (!boxWidth) {\n const consoleWidth: number = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n boxWidth = Math.floor(consoleWidth / 2);\n }\n\n const maxLineLength: number = boxWidth - 10;\n const wrappedMessageLines: string[] = PrintUtilities.wrapWordsToLines(message, maxLineLength);\n let longestLineLength: number = 0;\n const trimmedLines: string[] = [];\n for (const line of wrappedMessageLines) {\n const trimmedLine: string = line.trim();\n trimmedLines.push(trimmedLine);\n longestLineLength = Math.max(longestLineLength, trimmedLine.length);\n }\n\n if (longestLineLength > boxWidth - 2) {\n // If the longest line is longer than the box, print bars above and below the message\n // ═════════════\n // Message\n // ═════════════\n const headerAndFooter: string = ` ${'═'.repeat(boxWidth)}`;\n terminal.writeLine(headerAndFooter);\n for (const line of wrappedMessageLines) {\n terminal.writeLine(` ${line}`);\n }\n\n terminal.writeLine(headerAndFooter);\n } else {\n // ╔═══════════╗\n // ║ Message ║\n // ╚═══════════╝\n terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗`);\n for (const trimmedLine of trimmedLines) {\n const padding: number = boxWidth - trimmedLine.length - 2;\n const leftPadding: number = Math.floor(padding / 2);\n const rightPadding: number = padding - leftPadding;\n terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║`);\n }\n terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PrintUtilities.js","sourceRoot":"","sources":["../src/PrintUtilities.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAoD;AAIpD;;;;GAIG;AACU,QAAA,qBAAqB,GAAW,EAAE,CAAC;AAEhD;;;;GAIG;AACH,MAAa,cAAc;IACzB;;OAEG;IACI,MAAM,CAAC,eAAe;;QAC3B,OAAO,MAAA,OAAO,CAAC,MAAM,0CAAE,OAAO,CAAC;IACjC,CAAC;IA2BM,MAAM,CAAC,SAAS,CACrB,IAAY,EACZ,aAAsB,EACtB,kBAAoC;QAEpC,MAAM,YAAY,G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AAQ,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACpC,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;gBACvC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACjC,CAAC;YAED,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,gBAAgB;YAChB,gBAAgB;YAChB,gBAAgB;YAChB,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACrD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAW,QAAQ,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC1D,MAAM,WAAW,GAAW,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;gBACpD,MAAM,YAAY,GAAW,OAAO,GAAG,WAAW,CAAC;gBACnD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/F,CAAC;YACD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AArND,wCAqNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text } from '@rushstack/node-core-library';\n\nimport type { ITerminal } from './ITerminal';\n\n/**\n * A sensible fallback column width for consoles.\n *\n * @public\n */\nexport const DEFAULT_CONSOLE_WIDTH: number = 80;\n\n/**\n * A collection of utilities for printing messages to the console.\n *\n * @public\n */\nexport class PrintUtilities {\n /**\n * Returns the width of the console, measured in columns\n */\n public static getConsoleWidth(): number | undefined {\n return process.stdout?.columns;\n }\n\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWords(text: string, maxLineLength?: number, indent?: number): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWords(text: string, maxLineLength?: number, linePrefix?: string): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWords(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string;\n public static wrapWords(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string {\n const wrappedLines: string[] = PrintUtilities.wrapWordsToLines(\n text,\n maxLineLength,\n indentOrLinePrefix as string | undefined // TS is confused by the overloads\n );\n return wrappedLines.join('\\n');\n }\n\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[];\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[] {\n let linePrefix: string;\n switch (typeof indentOrLinePrefix) {\n case 'number':\n linePrefix = ' '.repeat(indentOrLinePrefix);\n break;\n case 'string':\n linePrefix = indentOrLinePrefix;\n break;\n default:\n linePrefix = '';\n break;\n }\n\n const linePrefixLength: number = linePrefix.length;\n\n if (!maxLineLength) {\n maxLineLength = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n }\n\n // Apply word wrapping and the provided line prefix, while also respecting existing newlines\n // and prefix spaces that may exist in the text string already.\n const lines: string[] = Text.splitByNewLines(text);\n\n const wrappedLines: string[] = [];\n for (const line of lines) {\n if (line.length + linePrefixLength <= maxLineLength) {\n wrappedLines.push(linePrefix + line);\n } else {\n const lineAdditionalPrefix: string = line.match(/^\\s*/)?.[0] || '';\n const whitespaceRegexp: RegExp = /\\s+/g;\n let currentWhitespaceMatch: RegExpExecArray | null = null;\n let previousWhitespaceMatch: RegExpExecArray | undefined;\n let currentLineStartIndex: number = lineAdditionalPrefix.length;\n let previousBreakRanOver: boolean = false;\n while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {\n if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {\n let whitespaceToSplitAt: RegExpExecArray | undefined;\n if (\n !previousWhitespaceMatch ||\n // Handle the case where there are two words longer than the maxLineLength in a row\n previousBreakRanOver\n ) {\n whitespaceToSplitAt = currentWhitespaceMatch;\n } else {\n whitespaceToSplitAt = previousWhitespaceMatch;\n }\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n } else {\n previousBreakRanOver = false;\n }\n\n previousWhitespaceMatch = currentWhitespaceMatch;\n }\n\n if (\n previousWhitespaceMatch &&\n line.length + linePrefixLength - currentLineStartIndex > maxLineLength\n ) {\n const whitespaceToSplitAt: RegExpExecArray = previousWhitespaceMatch;\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n }\n\n if (currentLineStartIndex < line.length) {\n wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));\n }\n }\n }\n\n return wrappedLines;\n }\n\n /**\n * Displays a message in the console wrapped in a box UI.\n *\n * @param message - The message to display.\n * @param terminal - The terminal to write the message to.\n * @param boxWidth - The width of the box, defaults to half of the console width.\n */\n public static printMessageInBox(message: string, terminal: ITerminal, boxWidth?: number): void {\n if (!boxWidth) {\n const consoleWidth: number = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n boxWidth = Math.floor(consoleWidth / 2);\n }\n\n const maxLineLength: number = boxWidth - 10;\n const wrappedMessageLines: string[] = PrintUtilities.wrapWordsToLines(message, maxLineLength);\n let longestLineLength: number = 0;\n const trimmedLines: string[] = [];\n for (const line of wrappedMessageLines) {\n const trimmedLine: string = line.trim();\n trimmedLines.push(trimmedLine);\n longestLineLength = Math.max(longestLineLength, trimmedLine.length);\n }\n\n if (longestLineLength > boxWidth - 2) {\n // If the longest line is longer than the box, print bars above and below the message\n // ═════════════\n // Message\n // ═════════════\n const headerAndFooter: string = ` ${'═'.repeat(boxWidth)}`;\n terminal.writeLine(headerAndFooter);\n for (const line of wrappedMessageLines) {\n terminal.writeLine(` ${line}`);\n }\n\n terminal.writeLine(headerAndFooter);\n } else {\n // ╔═══════════╗\n // ║ Message ║\n // ╚═══════════╝\n terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗`);\n for (const trimmedLine of trimmedLines) {\n const padding: number = boxWidth - trimmedLine.length - 2;\n const leftPadding: number = Math.floor(padding / 2);\n const rightPadding: number = padding - leftPadding;\n terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║`);\n }\n terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝`);\n }\n }\n}\n"]}
@@ -16,6 +16,10 @@ export interface IProblemCollectorOptions extends ITerminalWritableOptions {
16
16
  * {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} definitions.
17
17
  */
18
18
  matcherJson?: IProblemMatcherJson[];
19
+ /**
20
+ * Optional callback invoked immediately whenever a problem is produced.
21
+ */
22
+ onProblem?: (problem: IProblem) => void;
19
23
  }
20
24
  /**
21
25
  * A {@link TerminalWritable} that consumes line-oriented terminal output and extracts structured
@@ -31,6 +35,7 @@ export interface IProblemCollectorOptions extends ITerminalWritableOptions {
31
35
  export declare class ProblemCollector extends TerminalWritable implements IProblemCollector {
32
36
  private readonly _matchers;
33
37
  private readonly _problems;
38
+ private readonly _onProblem;
34
39
  constructor(options: IProblemCollectorOptions);
35
40
  /**
36
41
  * {@inheritdoc IProblemCollector}
@@ -1 +1 @@
1
- {"version":3,"file":"ProblemCollector.d.ts","sourceRoot":"","sources":["../src/ProblemCollector.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,mBAAmB,EAAE,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,OAAO,EAAE,wBAAwB;IAqBpD;;OAEG;IACH,IAAW,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,CAE3C;IAED;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAuBnD;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;CAiB1B"}
@@ -32,6 +32,7 @@ class ProblemCollector extends TerminalWritable_1.TerminalWritable {
32
32
  if (this._matchers.length === 0) {
33
33
  throw new Error('ProblemCollector requires at least one problem matcher.');
34
34
  }
35
+ this._onProblem = options.onProblem;
35
36
  }
36
37
  /**
37
38
  * {@inheritdoc IProblemCollector}
@@ -43,6 +44,7 @@ class ProblemCollector extends TerminalWritable_1.TerminalWritable {
43
44
  * {@inheritdoc TerminalWritable}
44
45
  */
45
46
  onWriteChunk(chunk) {
47
+ var _a;
46
48
  const text = chunk.text;
47
49
  if (text.length === 0 || text[text.length - 1] !== '\n') {
48
50
  throw new Error('ProblemCollector expects chunks that were split into newline terminated lines. ' +
@@ -57,6 +59,7 @@ class ProblemCollector extends TerminalWritable_1.TerminalWritable {
57
59
  matcherName: matcher.name
58
60
  };
59
61
  this._problems.add(finalized);
62
+ (_a = this._onProblem) === null || _a === void 0 ? void 0 : _a.call(this, finalized);
60
63
  }
61
64
  }
62
65
  }
@@ -64,6 +67,7 @@ class ProblemCollector extends TerminalWritable_1.TerminalWritable {
64
67
  * {@inheritdoc TerminalWritable}
65
68
  */
66
69
  onClose() {
70
+ var _a;
67
71
  for (const matcher of this._matchers) {
68
72
  if (matcher.flush) {
69
73
  const flushed = matcher.flush();
@@ -74,6 +78,7 @@ class ProblemCollector extends TerminalWritable_1.TerminalWritable {
74
78
  matcherName: matcher.name
75
79
  };
76
80
  this._problems.add(finalized);
81
+ (_a = this._onProblem) === null || _a === void 0 ? void 0 : _a.call(this, finalized);
77
82
  }
78
83
  }
79
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ProblemCollector.js","source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E,CAAC;YACxD,MAAM,IAAI,KAAK,CACb,iFAAiF;gBAC/E,iBAAiB;gBACjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CACvB,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,MAAM,OAAO,GAAqB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAa;oBAC1B,GAAG,OAAO;oBACV,WAAW,EAAE,OAAO,CAAC,IAAI;iBAC1B,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACO,OAAO;QACf,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,MAAM,OAAO,GAAe,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC5C,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAClC,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;wBAC9B,MAAM,SAAS,GAAa;4BAC1B,GAAG,OAAO;4BACV,WAAW,EAAE,OAAO,CAAC,IAAI;yBAC1B,CAAC;wBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAChC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3ED,4CA2EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { parseProblemMatchersJson } from '@rushstack/problem-matcher';\nimport type { IProblemMatcher, IProblemMatcherJson, IProblem } from '@rushstack/problem-matcher';\n\nimport type { ITerminalChunk } from './ITerminalChunk';\nimport { type ITerminalWritableOptions, TerminalWritable } from './TerminalWritable';\nimport type { IProblemCollector } from './IProblemCollector';\n\n/**\n * Constructor options for {@link ProblemCollector}.\n * @beta\n */\nexport interface IProblemCollectorOptions extends ITerminalWritableOptions {\n /**\n * The set of matchers that will be applied to each incoming line. Must contain at least one item.\n */\n matchers?: IProblemMatcher[];\n /**\n * VS Code style problem matcher definitions. These will be converted to\n * {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} definitions.\n */\n matcherJson?: IProblemMatcherJson[];\n}\n\n/**\n * A {@link TerminalWritable} that consumes line-oriented terminal output and extracts structured\n * problems using one or more {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} instances.\n *\n * @remarks\n * This collector expects that each incoming {@link ITerminalChunk} represents a single line terminated\n * by a `\"\\n\"` character (for example when preceded by {@link StderrLineTransform} / `StdioLineTransform`).\n * If a chunk does not end with a newline an error is thrown to surface incorrect pipeline wiring early.\n *\n * @beta\n */\nexport class ProblemCollector extends TerminalWritable implements IProblemCollector {\n private readonly _matchers: IProblemMatcher[];\n private readonly _problems: Set<IProblem> = new Set();\n\n public constructor(options: IProblemCollectorOptions) {\n super(options);\n\n if (\n !options ||\n ((!options.matchers || options.matchers.length === 0) &&\n (!options.matcherJson || options.matcherJson.length === 0))\n ) {\n throw new Error('ProblemCollector requires at least one problem matcher.');\n }\n\n const fromJson: IProblemMatcher[] = options.matcherJson\n ? parseProblemMatchersJson(options.matcherJson)\n : [];\n this._matchers = [...(options.matchers || []), ...fromJson];\n if (this._matchers.length === 0) {\n throw new Error('ProblemCollector requires at least one problem matcher.');\n }\n }\n\n /**\n * {@inheritdoc IProblemCollector}\n */\n public get problems(): ReadonlySet<IProblem> {\n return this._problems;\n }\n\n /**\n * {@inheritdoc TerminalWritable}\n */\n protected onWriteChunk(chunk: ITerminalChunk): void {\n const text: string = chunk.text;\n if (text.length === 0 || text[text.length - 1] !== '\\n') {\n throw new Error(\n 'ProblemCollector expects chunks that were split into newline terminated lines. ' +\n 'Invalid input: ' +\n JSON.stringify(text)\n );\n }\n\n for (const matcher of this._matchers) {\n const problem: IProblem | false = matcher.exec(text);\n if (problem) {\n const finalized: IProblem = {\n ...problem,\n matcherName: matcher.name\n };\n this._problems.add(finalized);\n }\n }\n }\n\n /**\n * {@inheritdoc TerminalWritable}\n */\n protected onClose(): void {\n for (const matcher of this._matchers) {\n if (matcher.flush) {\n const flushed: IProblem[] = matcher.flush();\n if (flushed && flushed.length > 0) {\n for (const problem of flushed) {\n const finalized: IProblem = {\n ...problem,\n matcherName: matcher.name\n };\n this._problems.add(finalized);\n }\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ProblemCollector.js","sourceRoot":"","sources":["../src/ProblemCollector.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,gEAAsE;AAItE,yDAAqF;AAuBrF;;;;;;;;;;GAUG;AACH,MAAa,gBAAiB,SAAQ,mCAAgB;IAKpD,YAAmB,OAAiC;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJA,cAAS,GAAkB,IAAI,GAAG,EAAE,CAAC;QAMpD,IACE,CAAC,OAAO;YACR,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;gBACnD,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,EAC7D,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,QAAQ,GAAsB,OAAO,CAAC,WAAW;YACrD,CAAC,CAAC,IAAA,0CAAwB,EAAC,OAAO,CAAC,WAAW,CAAC;YAC/C,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;QA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AAG,CAAC,EAAE,CAAC;oBAClC,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;wBAC9B,MAAM,SAAS,GAAa;4BAC1B,GAAG,OAAO;4BACV,WAAW,EAAE,OAAO,CAAC,IAAI;yBAC1B,CAAC;wBACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;wBAC9B,MAAA,IAAI,CAAC,UAAU,qDAAG,SAAS,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/ED,4CA+EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { parseProblemMatchersJson } from '@rushstack/problem-matcher';\nimport type { IProblemMatcher, IProblemMatcherJson, IProblem } from '@rushstack/problem-matcher';\n\nimport type { ITerminalChunk } from './ITerminalChunk';\nimport { type ITerminalWritableOptions, TerminalWritable } from './TerminalWritable';\nimport type { IProblemCollector } from './IProblemCollector';\n\n/**\n * Constructor options for {@link ProblemCollector}.\n * @beta\n */\nexport interface IProblemCollectorOptions extends ITerminalWritableOptions {\n /**\n * The set of matchers that will be applied to each incoming line. Must contain at least one item.\n */\n matchers?: IProblemMatcher[];\n /**\n * VS Code style problem matcher definitions. These will be converted to\n * {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} definitions.\n */\n matcherJson?: IProblemMatcherJson[];\n /**\n * Optional callback invoked immediately whenever a problem is produced.\n */\n onProblem?: (problem: IProblem) => void;\n}\n\n/**\n * A {@link TerminalWritable} that consumes line-oriented terminal output and extracts structured\n * problems using one or more {@link @rushstack/problem-matcher#IProblemMatcher | IProblemMatcher} instances.\n *\n * @remarks\n * This collector expects that each incoming {@link ITerminalChunk} represents a single line terminated\n * by a `\"\\n\"` character (for example when preceded by {@link StderrLineTransform} / `StdioLineTransform`).\n * If a chunk does not end with a newline an error is thrown to surface incorrect pipeline wiring early.\n *\n * @beta\n */\nexport class ProblemCollector extends TerminalWritable implements IProblemCollector {\n private readonly _matchers: IProblemMatcher[];\n private readonly _problems: Set<IProblem> = new Set();\n private readonly _onProblem: ((problem: IProblem) => void) | undefined;\n\n public constructor(options: IProblemCollectorOptions) {\n super(options);\n\n if (\n !options ||\n ((!options.matchers || options.matchers.length === 0) &&\n (!options.matcherJson || options.matcherJson.length === 0))\n ) {\n throw new Error('ProblemCollector requires at least one problem matcher.');\n }\n\n const fromJson: IProblemMatcher[] = options.matcherJson\n ? parseProblemMatchersJson(options.matcherJson)\n : [];\n this._matchers = [...(options.matchers || []), ...fromJson];\n if (this._matchers.length === 0) {\n throw new Error('ProblemCollector requires at least one problem matcher.');\n }\n this._onProblem = options.onProblem;\n }\n\n /**\n * {@inheritdoc IProblemCollector}\n */\n public get problems(): ReadonlySet<IProblem> {\n return this._problems;\n }\n\n /**\n * {@inheritdoc TerminalWritable}\n */\n protected onWriteChunk(chunk: ITerminalChunk): void {\n const text: string = chunk.text;\n if (text.length === 0 || text[text.length - 1] !== '\\n') {\n throw new Error(\n 'ProblemCollector expects chunks that were split into newline terminated lines. ' +\n 'Invalid input: ' +\n JSON.stringify(text)\n );\n }\n\n for (const matcher of this._matchers) {\n const problem: IProblem | false = matcher.exec(text);\n if (problem) {\n const finalized: IProblem = {\n ...problem,\n matcherName: matcher.name\n };\n this._problems.add(finalized);\n this._onProblem?.(finalized);\n }\n }\n }\n\n /**\n * {@inheritdoc TerminalWritable}\n */\n protected onClose(): void {\n for (const matcher of this._matchers) {\n if (matcher.flush) {\n const flushed: IProblem[] = matcher.flush();\n if (flushed && flushed.length > 0) {\n for (const problem of flushed) {\n const finalized: IProblem = {\n ...problem,\n matcherName: matcher.name\n };\n this._problems.add(finalized);\n this._onProblem?.(finalized);\n }\n }\n }\n }\n }\n}\n"]}
@@ -7,9 +7,9 @@ import type { ITerminalChunk } from './ITerminalChunk';
7
7
  */
8
8
  export interface ISplitterTransformOptions extends ITerminalWritableOptions {
9
9
  /**
10
- * Each input chunk will be passed to each destination in the array.
10
+ * Each input chunk will be passed to each destination in the iterable.
11
11
  */
12
- destinations: TerminalWritable[];
12
+ destinations: Iterable<TerminalWritable>;
13
13
  }
14
14
  /**
15
15
  * Use this instead of {@link TerminalTransform} if you need to output `ITerminalChunk`
@@ -24,8 +24,25 @@ export interface ISplitterTransformOptions extends ITerminalWritableOptions {
24
24
  * @public
25
25
  */
26
26
  export declare class SplitterTransform extends TerminalWritable {
27
- readonly destinations: ReadonlyArray<TerminalWritable>;
27
+ private readonly _destinations;
28
28
  constructor(options: ISplitterTransformOptions);
29
+ get destinations(): ReadonlySet<TerminalWritable>;
30
+ /**
31
+ * Adds a destination to the set of destinations. Duplicates are ignored.
32
+ * Only new chunks received after the destination is added will be sent to it.
33
+ * @param destination - The destination to add.
34
+ */
35
+ addDestination(destination: TerminalWritable): void;
36
+ /**
37
+ * Removes a destination from the set of destinations. It will no longer receive chunks, and will be closed, unless
38
+ * `destination.preventAutoclose` is set to `true`.
39
+ * @param destination - The destination to remove.
40
+ * @param close - If `true` (default), the destination will be closed when removed, unless `destination.preventAutoclose` is set to `true`.
41
+ * @returns `true` if the destination was removed, `false` if it was not found.
42
+ * @remarks
43
+ * If the destination is not found, it will not be closed.
44
+ */
45
+ removeDestination(destination: TerminalWritable, close?: boolean): boolean;
29
46
  protected onWriteChunk(chunk: ITerminalChunk): void;
30
47
  protected onClose(): void;
31
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SplitterTransform.d.ts","sourceRoot":"","sources":["../src/SplitterTransform.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,wBAAwB;IACzE;;OAEG;IACH,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;IACrD,SAAgB,YAAY,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;gBAE3C,OAAO,EAAE,yBAAyB;IAKrD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAMnD,SAAS,CAAC,OAAO,IAAI,IAAI;CAkB1B"}
1
+ {"version":3,"file":"SplitterTransform.d.ts","sourceRoot":"","sources":["../src/SplitterTransform.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,wBAAwB;IACzE;;OAEG;IACH,YAAY,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;CAC1C;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;gBAEnC,OAAO,EAAE,yBAAyB;IAKrD,IAAW,YAAY,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAEvD;IAED;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI;IAI1D;;;;;;;;OAQG;IACI,iBAAiB,CAAC,WAAW,EAAE,gBAAgB,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO;IAUvF,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAMnD,SAAS,CAAC,OAAO,IAAI,IAAI;CAoB1B"}
@@ -19,17 +19,46 @@ const TerminalWritable_1 = require("./TerminalWritable");
19
19
  class SplitterTransform extends TerminalWritable_1.TerminalWritable {
20
20
  constructor(options) {
21
21
  super();
22
- this.destinations = [...options.destinations];
22
+ this._destinations = new Set(options.destinations);
23
+ }
24
+ get destinations() {
25
+ return this._destinations;
26
+ }
27
+ /**
28
+ * Adds a destination to the set of destinations. Duplicates are ignored.
29
+ * Only new chunks received after the destination is added will be sent to it.
30
+ * @param destination - The destination to add.
31
+ */
32
+ addDestination(destination) {
33
+ this._destinations.add(destination);
34
+ }
35
+ /**
36
+ * Removes a destination from the set of destinations. It will no longer receive chunks, and will be closed, unless
37
+ * `destination.preventAutoclose` is set to `true`.
38
+ * @param destination - The destination to remove.
39
+ * @param close - If `true` (default), the destination will be closed when removed, unless `destination.preventAutoclose` is set to `true`.
40
+ * @returns `true` if the destination was removed, `false` if it was not found.
41
+ * @remarks
42
+ * If the destination is not found, it will not be closed.
43
+ */
44
+ removeDestination(destination, close = true) {
45
+ if (this._destinations.delete(destination)) {
46
+ if (close && !destination.preventAutoclose) {
47
+ destination.close();
48
+ }
49
+ return true;
50
+ }
51
+ return false;
23
52
  }
24
53
  onWriteChunk(chunk) {
25
- for (const destination of this.destinations) {
54
+ for (const destination of this._destinations) {
26
55
  destination.writeChunk(chunk);
27
56
  }
28
57
  }
29
58
  onClose() {
30
59
  const errors = [];
31
60
  // If an exception is thrown, try to ensure that the other destinations get closed properly
32
- for (const destination of this.destinations) {
61
+ for (const destination of this._destinations) {
33
62
  if (!destination.preventAutoclose) {
34
63
  try {
35
64
  destination.close();
@@ -39,6 +68,7 @@ class SplitterTransform extends TerminalWritable_1.TerminalWritable {
39
68
  }
40
69
  }
41
70
  }
71
+ this._destinations.clear();
42
72
  if (errors.length > 0) {
43
73
  throw errors[0];
44
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SplitterTransform.js","sourceRoot":"","sources":["../src/SplitterTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,yDAAqF;AAerF;;;;;;;;;;;GAWG;AACH,MAAa,iBAAkB,SAAQ,mCAAgB;IAGrD,YAAmB,OAAkC;QACnD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAES,YAAY,CAAC,KAAqB;QAC1C,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAES,OAAO;QACf,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,2FAA2F;QAC3F,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;gBAClC,IAAI,CAAC;oBACH,WAAW,CAAC,KAAK,EAAE,CAAC;gBACtB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,KAAc,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF;AAhCD,8CAgCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { TerminalWritable, type ITerminalWritableOptions } from './TerminalWritable';\nimport type { ITerminalChunk } from './ITerminalChunk';\n\n/**\n * Constructor options for {@link SplitterTransform}.\n *\n * @public\n */\nexport interface ISplitterTransformOptions extends ITerminalWritableOptions {\n /**\n * Each input chunk will be passed to each destination in the array.\n */\n destinations: TerminalWritable[];\n}\n\n/**\n * Use this instead of {@link TerminalTransform} if you need to output `ITerminalChunk`\n * data to more than one destination.\n *\n * @remarks\n *\n * Splitting streams complicates the pipeline topology and can make debugging more difficult.\n * For this reason, it is modeled as an explicit `SplitterTransform` node, rather than\n * as a built-in feature of `TerminalTransform`.\n *\n * @public\n */\nexport class SplitterTransform extends TerminalWritable {\n public readonly destinations: ReadonlyArray<TerminalWritable>;\n\n public constructor(options: ISplitterTransformOptions) {\n super();\n this.destinations = [...options.destinations];\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n for (const destination of this.destinations) {\n destination.writeChunk(chunk);\n }\n }\n\n protected onClose(): void {\n const errors: Error[] = [];\n\n // If an exception is thrown, try to ensure that the other destinations get closed properly\n for (const destination of this.destinations) {\n if (!destination.preventAutoclose) {\n try {\n destination.close();\n } catch (error) {\n errors.push(error as Error);\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors[0];\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SplitterTransform.js","sourceRoot":"","sources":["../src/SplitterTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,yDAAqF;AAerF;;;;;;;;;;;GAWG;AACH,MAAa,iBAAkB,SAAQ,mCAAgB;IAGrD,YAAmB,OAAkC;QACnD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,WAA6B;QACjD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;OAQG;IACI,iBAAiB,CAAC,WAA6B,EAAE,QAAiB,IAAI;QAC3E,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3C,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;gBAC3C,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAES,YAAY,CAAC,KAAqB;QAC1C,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC7C,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAES,OAAO;QACf,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,2FAA2F;QAC3F,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC7C,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;gBAClC,IAAI,CAAC;oBACH,WAAW,CAAC,KAAK,EAAE,CAAC;gBACtB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,KAAc,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAE3B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF;AAlED,8CAkEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { TerminalWritable, type ITerminalWritableOptions } from './TerminalWritable';\nimport type { ITerminalChunk } from './ITerminalChunk';\n\n/**\n * Constructor options for {@link SplitterTransform}.\n *\n * @public\n */\nexport interface ISplitterTransformOptions extends ITerminalWritableOptions {\n /**\n * Each input chunk will be passed to each destination in the iterable.\n */\n destinations: Iterable<TerminalWritable>;\n}\n\n/**\n * Use this instead of {@link TerminalTransform} if you need to output `ITerminalChunk`\n * data to more than one destination.\n *\n * @remarks\n *\n * Splitting streams complicates the pipeline topology and can make debugging more difficult.\n * For this reason, it is modeled as an explicit `SplitterTransform` node, rather than\n * as a built-in feature of `TerminalTransform`.\n *\n * @public\n */\nexport class SplitterTransform extends TerminalWritable {\n private readonly _destinations: Set<TerminalWritable>;\n\n public constructor(options: ISplitterTransformOptions) {\n super();\n this._destinations = new Set(options.destinations);\n }\n\n public get destinations(): ReadonlySet<TerminalWritable> {\n return this._destinations;\n }\n\n /**\n * Adds a destination to the set of destinations. Duplicates are ignored.\n * Only new chunks received after the destination is added will be sent to it.\n * @param destination - The destination to add.\n */\n public addDestination(destination: TerminalWritable): void {\n this._destinations.add(destination);\n }\n\n /**\n * Removes a destination from the set of destinations. It will no longer receive chunks, and will be closed, unless\n * `destination.preventAutoclose` is set to `true`.\n * @param destination - The destination to remove.\n * @param close - If `true` (default), the destination will be closed when removed, unless `destination.preventAutoclose` is set to `true`.\n * @returns `true` if the destination was removed, `false` if it was not found.\n * @remarks\n * If the destination is not found, it will not be closed.\n */\n public removeDestination(destination: TerminalWritable, close: boolean = true): boolean {\n if (this._destinations.delete(destination)) {\n if (close && !destination.preventAutoclose) {\n destination.close();\n }\n return true;\n }\n return false;\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n for (const destination of this._destinations) {\n destination.writeChunk(chunk);\n }\n }\n\n protected onClose(): void {\n const errors: Error[] = [];\n\n // If an exception is thrown, try to ensure that the other destinations get closed properly\n for (const destination of this._destinations) {\n if (!destination.preventAutoclose) {\n try {\n destination.close();\n } catch (error) {\n errors.push(error as Error);\n }\n }\n }\n\n this._destinations.clear();\n\n if (errors.length > 0) {\n throw errors[0];\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StdioWritable.d.ts","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAc,QAAQ,EAAE,aAAa,CAAuB;IAE5D,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;CAOpD"}
1
+ {"version":3,"file":"StdioWritable.d.ts","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAc,QAAQ,EAAE,aAAa,CAAuB;IAE5D,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;CAOpD"}
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.StdioWritable = void 0;
9
- const process_1 = __importDefault(require("process"));
9
+ const node_process_1 = __importDefault(require("node:process"));
10
10
  const ITerminalChunk_1 = require("./ITerminalChunk");
11
11
  const TerminalWritable_1 = require("./TerminalWritable");
12
12
  /**
@@ -22,10 +22,10 @@ const TerminalWritable_1 = require("./TerminalWritable");
22
22
  class StdioWritable extends TerminalWritable_1.TerminalWritable {
23
23
  onWriteChunk(chunk) {
24
24
  if (chunk.kind === ITerminalChunk_1.TerminalChunkKind.Stdout) {
25
- process_1.default.stdout.write(chunk.text);
25
+ node_process_1.default.stdout.write(chunk.text);
26
26
  }
27
27
  else if (chunk.kind === ITerminalChunk_1.TerminalChunkKind.Stderr) {
28
- process_1.default.stderr.write(chunk.text);
28
+ node_process_1.default.stderr.write(chunk.text);
29
29
  }
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StdioWritable.js","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,sDAA8B;AAC9B,qDAA0E;AAC1E,yDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAa,aAAc,SAAQ,mCAAgB;IAGvC,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,MAAM,EAAE,CAAC;YAC5C,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,MAAM,EAAE,CAAC;YACnD,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;;AATH,sCAUC;AATe,sBAAQ,GAAkB,IAAI,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport process from 'process';\nimport { type ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * A {@link TerminalWritable} subclass that writes its output directly to the process `stdout` and `stderr`\n * streams.\n *\n * @remarks\n * This is the standard output target for a process. You normally do not need to construct\n * this class; the {@link StdioWritable.\"instance\"} singleton can be used instead.\n *\n * @public\n */\nexport class StdioWritable extends TerminalWritable {\n public static instance: StdioWritable = new StdioWritable();\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stdout) {\n process.stdout.write(chunk.text);\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n process.stderr.write(chunk.text);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"StdioWritable.js","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,gEAAmC;AAEnC,qDAA0E;AAC1E,yDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAa,aAAc,SAAQ,mCAAgB;IAGvC,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,MAAM,EAAE,CAAC;YAC5C,sBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,MAAM,EAAE,CAAC;YACnD,sBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;;AATH,sCAUC;AATe,sBAAQ,GAAkB,IAAI,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport process from 'node:process';\n\nimport { type ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * A {@link TerminalWritable} subclass that writes its output directly to the process `stdout` and `stderr`\n * streams.\n *\n * @remarks\n * This is the standard output target for a process. You normally do not need to construct\n * this class; the {@link StdioWritable.\"instance\"} singleton can be used instead.\n *\n * @public\n */\nexport class StdioWritable extends TerminalWritable {\n public static instance: StdioWritable = new StdioWritable();\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stdout) {\n process.stdout.write(chunk.text);\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n process.stderr.write(chunk.text);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StringBufferTerminalProvider.d.ts","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAGvF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;GAMG;AACH,qBAAa,4BAA6B,YAAW,iBAAiB;IACpE,OAAO,CAAC,eAAe,CAAsC;IAC7D,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,YAAY,CAAsC;IAC1D,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,YAAY,CAAsC;IAE1D,OAAO,CAAC,cA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AAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IA8BpE;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,OAAO,CAElC;IAED;;OAEG;IACI,SAAS,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAI9D;;OAEG;IACI,UAAU,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAI/D;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAIrE;;OAEG;IACI,cAAc,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAInE;;OAEG;IACI,cAAc,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAInE;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAIrE,OAAO,CAAC,gBAAgB;CAezB"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringBufferTerminalProvider.js","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAmE;AACnE,2DAAuF;AACvF,6CAA0C;AAe1C;;;;;;GAMG;AACH,MAAa,4BAA4B;IASvC,YAAmB,gBAAyB,KAAK;QARzC,oBAAe,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACrD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAClD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAKxD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,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CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,OAAoC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,OAAoC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,gBAAgB,CAAC,OAAoC;QAC1D,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAEO,gBAAgB,CAAC,CAAS,EAAE,OAA+C;QACjF,OAAO,GAAG;YACR,0BAA0B,EAAE,IAAI;YAEhC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SACnB,CAAC;QAEF,CAAC,GAAG,wBAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;YACvC,OAAO,uBAAU,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;AArHD,oEAqHC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { StringBuilder, Text } from '@rushstack/node-core-library';\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\nimport { AnsiEscape } from './AnsiEscape';\n\n/**\n * @beta\n */\nexport interface IStringBufferOutputOptions {\n /**\n * If set to true, special characters like \\\\n, \\\\r, and the \\\\u001b character\n * in color control tokens will get normalized to [-n-], [-r-], and [-x-] respectively\n *\n * This option defaults to `true`\n */\n normalizeSpecialCharacters: boolean;\n}\n\n/**\n * Terminal provider that stores written data in buffers separated by severity.\n * This terminal provider is designed to be used when code that prints to a terminal\n * is being unit tested.\n *\n * @beta\n */\nexport class StringBufferTerminalProvider implements ITerminalProvider {\n private _standardBuffer: StringBuilder = new StringBuilder();\n private _verboseBuffer: StringBuilder = new StringBuilder();\n private _debugBuffer: StringBuilder = new StringBuilder();\n private _warningBuffer: StringBuilder = new StringBuilder();\n private _errorBuffer: StringBuilder = new StringBuilder();\n\n private _supportsColor: boolean;\n\n public constructor(supportsColor: boolean = false) {\n this._supportsColor = supportsColor;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning: {\n this._warningBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.error: {\n this._errorBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n this._verboseBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n this._debugBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n this._standardBuffer.append(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return '\\n';\n }\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public get supportsColor(): boolean {\n return this._supportsColor;\n }\n\n /**\n * Get everything that has been written at log-level severity.\n */\n public getOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._standardBuffer.toString(), options);\n }\n\n /**\n * @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}\n */\n public getVerbose(options?: IStringBufferOutputOptions): string {\n return this.getVerboseOutput(options);\n }\n\n /**\n * Get everything that has been written at verbose-level severity.\n */\n public getVerboseOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._verboseBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at debug-level severity.\n */\n public getDebugOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._debugBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at error-level severity.\n */\n public getErrorOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._errorBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at warning-level severity.\n */\n public getWarningOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._warningBuffer.toString(), options);\n }\n\n private _normalizeOutput(s: string, options: IStringBufferOutputOptions | undefined): string {\n options = {\n normalizeSpecialCharacters: true,\n\n ...(options || {})\n };\n\n s = Text.convertToLf(s);\n\n if (options.normalizeSpecialCharacters) {\n return AnsiEscape.formatForTests(s, { encodeNewlines: true });\n } else {\n return s;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"StringBufferTerminalProvider.js","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAmE;AAEnE,2DAAuF;AACvF,6CAA0C;AAe1C;;;;;;GAMG;AACH,MAAa,4BAA4B;IASvC,YAAmB,gBAAyB,KAAK;QARzC,oBAAe,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACrD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAClD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAKxD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB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CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,OAAoC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,gBAAgB,CAAC,OAAoC;QAC1D,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAEO,gBAAgB,CAAC,CAAS,EAAE,OAA+C;QACjF,OAAO,GAAG;YACR,0BAA0B,EAAE,IAAI;YAEhC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SACnB,CAAC;QAEF,CAAC,GAAG,wBAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;YACvC,OAAO,uBAAU,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;AArHD,oEAqHC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { StringBuilder, Text } from '@rushstack/node-core-library';\n\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\nimport { AnsiEscape } from './AnsiEscape';\n\n/**\n * @beta\n */\nexport interface IStringBufferOutputOptions {\n /**\n * If set to true, special characters like \\\\n, \\\\r, and the \\\\u001b character\n * in color control tokens will get normalized to [-n-], [-r-], and [-x-] respectively\n *\n * This option defaults to `true`\n */\n normalizeSpecialCharacters: boolean;\n}\n\n/**\n * Terminal provider that stores written data in buffers separated by severity.\n * This terminal provider is designed to be used when code that prints to a terminal\n * is being unit tested.\n *\n * @beta\n */\nexport class StringBufferTerminalProvider implements ITerminalProvider {\n private _standardBuffer: StringBuilder = new StringBuilder();\n private _verboseBuffer: StringBuilder = new StringBuilder();\n private _debugBuffer: StringBuilder = new StringBuilder();\n private _warningBuffer: StringBuilder = new StringBuilder();\n private _errorBuffer: StringBuilder = new StringBuilder();\n\n private _supportsColor: boolean;\n\n public constructor(supportsColor: boolean = false) {\n this._supportsColor = supportsColor;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning: {\n this._warningBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.error: {\n this._errorBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n this._verboseBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n this._debugBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n this._standardBuffer.append(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return '\\n';\n }\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public get supportsColor(): boolean {\n return this._supportsColor;\n }\n\n /**\n * Get everything that has been written at log-level severity.\n */\n public getOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._standardBuffer.toString(), options);\n }\n\n /**\n * @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}\n */\n public getVerbose(options?: IStringBufferOutputOptions): string {\n return this.getVerboseOutput(options);\n }\n\n /**\n * Get everything that has been written at verbose-level severity.\n */\n public getVerboseOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._verboseBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at debug-level severity.\n */\n public getDebugOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._debugBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at error-level severity.\n */\n public getErrorOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._errorBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at warning-level severity.\n */\n public getWarningOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._warningBuffer.toString(), options);\n }\n\n private _normalizeOutput(s: string, options: IStringBufferOutputOptions | undefined): string {\n options = {\n normalizeSpecialCharacters: true,\n\n ...(options || {})\n };\n\n s = Text.convertToLf(s);\n\n if (options.normalizeSpecialCharacters) {\n return AnsiEscape.formatForTests(s, { encodeNewlines: true });\n } else {\n return s;\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Writable, type WritableOptions } from 'stream';
1
+ import { Writable, type WritableOptions } from 'node:stream';
2
2
  import type { ITerminal } from './ITerminal';
3
3
  import { TerminalProviderSeverity } from './ITerminalProvider';
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalStreamWritable.d.ts","sourceRoot":"","sources":["../src/TerminalStreamWritable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,wBAAwB,CAAC;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,QAAQ;IAClD,OAAO,CAAC,YAAY,CAAyB;gBAE1B,OAAO,EAAE,8BAA8B;IA0BnD,MAAM,CACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,EACnC,QAAQ,EAAE,MAAM,EAEhB,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GACvC,IAAI;CAUR"}
1
+ {"version":3,"file":"TerminalStreamWritable.d.ts","sourceRoot":"","sources":["../src/TerminalStreamWritable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,wBAAwB,CAAC;IACnC;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,QAAQ;IAClD,OAAO,CAAC,YAAY,CAAyB;gBAE1B,OAAO,EAAE,8BAA8B;IA0BnD,MAAM,CACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,EACnC,QAAQ,EAAE,MAAM,EAEhB,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GACvC,IAAI;CAUR"}
@@ -3,14 +3,14 @@
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.TerminalStreamWritable = void 0;
6
- const stream_1 = require("stream");
6
+ const node_stream_1 = require("node:stream");
7
7
  const ITerminalProvider_1 = require("./ITerminalProvider");
8
8
  /**
9
9
  * A adapter to allow writing to a provided terminal using Writable streams.
10
10
  *
11
11
  * @beta
12
12
  */
13
- class TerminalStreamWritable extends stream_1.Writable {
13
+ class TerminalStreamWritable extends node_stream_1.Writable {
14
14
  constructor(options) {
15
15
  const { terminal, severity, writableOptions } = options;
16
16
  super(writableOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalStreamWritable.js","sourceRoot":"","sources":["../src/TerminalStreamWritable.ts"],"names":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,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1F,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,QAAQ,CAAC,CAAU,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,QAAQ,EAAE,CAAC;IACb,CAAC;CACF;AA5CD,wDA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Writable, type WritableOptions } from 'stream';\nimport type { ITerminal } from './ITerminal';\nimport { TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * Options for {@link TerminalStreamWritable}.\n *\n * @beta\n */\nexport interface ITerminalStreamWritableOptions {\n /**\n * The {@link ITerminal} that the Writable will write to.\n */\n terminal: ITerminal;\n /**\n * The severity of the messages that will be written to the {@link ITerminal}.\n */\n severity: TerminalProviderSeverity;\n /**\n * Options for the underlying Writable.\n */\n writableOptions?: WritableOptions;\n}\n\n/**\n * A adapter to allow writing to a provided terminal using Writable streams.\n *\n * @beta\n */\nexport class TerminalStreamWritable extends Writable {\n private _writeMethod: (data: string) => void;\n\n public constructor(options: ITerminalStreamWritableOptions) {\n const { terminal, severity, writableOptions } = options;\n super(writableOptions);\n\n this._writev = undefined;\n switch (severity) {\n case TerminalProviderSeverity.log:\n this._writeMethod = terminal.write.bind(terminal);\n break;\n case TerminalProviderSeverity.verbose:\n this._writeMethod = terminal.writeVerbose.bind(terminal);\n break;\n case TerminalProviderSeverity.debug:\n this._writeMethod = terminal.writeDebug.bind(terminal);\n break;\n case TerminalProviderSeverity.warning:\n this._writeMethod = terminal.writeWarning.bind(terminal);\n break;\n case TerminalProviderSeverity.error:\n this._writeMethod = terminal.writeError.bind(terminal);\n break;\n default:\n throw new Error(`Unknown severity: ${severity}`);\n }\n }\n\n public _write(\n chunk: string | Buffer | Uint8Array,\n encoding: string,\n // eslint-disable-next-line @rushstack/no-new-null\n callback: (error?: Error | null) => void\n ): void {\n try {\n const chunkData: string | Buffer = typeof chunk === 'string' ? chunk : Buffer.from(chunk);\n this._writeMethod(chunkData.toString());\n } catch (e: unknown) {\n callback(e as Error);\n return;\n }\n callback();\n }\n}\n"]}
1
+ {"version":3,"file":"TerminalStreamWritable.js","sourceRoot":"","sources":["../src/TerminalStreamWritable.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,6CAA6D;AAG7D,2DAA+D;AAsB/D;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,sBAAQ;IAGlD,YAAmB,OAAuC;QACxD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QACxD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,GAAG;gBAC/B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAClD,MAAM;YACR,KAAK,4CAAwB,CAAC,OAAO;gBACnC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACzD,MAAM;YACR,KAAK,4CAAwB,CAAC,KAAK;gBACjC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvD,MAAM;YACR,KAAK,4CAAwB,CAAC,OAAO;gBACnC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACzD,MAAM;YACR,KAAK,4CAAwB,CAAC,KAAK;gBACjC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvD,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAEM,MAAM,CACX,KAAmC,EACnC,QAAgB;IAChB,kDAAkD;IAClD,QAAwC;QAExC,IAAI,CAAC;YACH,MAAM,SAAS,GAAoB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1F,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,QAAQ,CAAC,CAAU,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,QAAQ,EAAE,CAAC;IACb,CAAC;CACF;AA5CD,wDA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Writable, type WritableOptions } from 'node:stream';\n\nimport type { ITerminal } from './ITerminal';\nimport { TerminalProviderSeverity } from './ITerminalProvider';\n\n/**\n * Options for {@link TerminalStreamWritable}.\n *\n * @beta\n */\nexport interface ITerminalStreamWritableOptions {\n /**\n * The {@link ITerminal} that the Writable will write to.\n */\n terminal: ITerminal;\n /**\n * The severity of the messages that will be written to the {@link ITerminal}.\n */\n severity: TerminalProviderSeverity;\n /**\n * Options for the underlying Writable.\n */\n writableOptions?: WritableOptions;\n}\n\n/**\n * A adapter to allow writing to a provided terminal using Writable streams.\n *\n * @beta\n */\nexport class TerminalStreamWritable extends Writable {\n private _writeMethod: (data: string) => void;\n\n public constructor(options: ITerminalStreamWritableOptions) {\n const { terminal, severity, writableOptions } = options;\n super(writableOptions);\n\n this._writev = undefined;\n switch (severity) {\n case TerminalProviderSeverity.log:\n this._writeMethod = terminal.write.bind(terminal);\n break;\n case TerminalProviderSeverity.verbose:\n this._writeMethod = terminal.writeVerbose.bind(terminal);\n break;\n case TerminalProviderSeverity.debug:\n this._writeMethod = terminal.writeDebug.bind(terminal);\n break;\n case TerminalProviderSeverity.warning:\n this._writeMethod = terminal.writeWarning.bind(terminal);\n break;\n case TerminalProviderSeverity.error:\n this._writeMethod = terminal.writeError.bind(terminal);\n break;\n default:\n throw new Error(`Unknown severity: ${severity}`);\n }\n }\n\n public _write(\n chunk: string | Buffer | Uint8Array,\n encoding: string,\n // eslint-disable-next-line @rushstack/no-new-null\n callback: (error?: Error | null) => void\n ): void {\n try {\n const chunkData: string | Buffer = typeof chunk === 'string' ? chunk : Buffer.from(chunk);\n this._writeMethod(chunkData.toString());\n } catch (e: unknown) {\n callback(e as Error);\n return;\n }\n callback();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/terminal",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "User interface primitives for console applications",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/terminal.d.ts",
@@ -12,11 +12,11 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "supports-color": "~8.1.1",
15
- "@rushstack/node-core-library": "5.15.0",
16
- "@rushstack/problem-matcher": "0.1.0"
15
+ "@rushstack/node-core-library": "5.16.0",
16
+ "@rushstack/problem-matcher": "0.1.1"
17
17
  },
18
18
  "devDependencies": {
19
- "@rushstack/heft": "0.74.3",
19
+ "@rushstack/heft": "1.0.0",
20
20
  "@types/supports-color": "8.1.3",
21
21
  "eslint": "~9.25.1",
22
22
  "decoupled-local-node-rig": "1.0.0"