@rushstack/stream-collator 4.1.125 → 4.2.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,41 @@
1
1
  {
2
2
  "name": "@rushstack/stream-collator",
3
3
  "entries": [
4
+ {
5
+ "version": "4.2.0",
6
+ "tag": "@rushstack/stream-collator_v4.2.0",
7
+ "date": "Thu, 19 Feb 2026 00:04:53 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.0`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.22.0`"
20
+ },
21
+ {
22
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "version": "4.1.126",
29
+ "tag": "@rushstack/stream-collator_v4.1.126",
30
+ "date": "Sat, 07 Feb 2026 01:13:26 GMT",
31
+ "comments": {
32
+ "dependency": [
33
+ {
34
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.1.14`"
35
+ }
36
+ ]
37
+ }
38
+ },
4
39
  {
5
40
  "version": "4.1.125",
6
41
  "tag": "@rushstack/stream-collator_v4.1.125",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @rushstack/stream-collator
2
2
 
3
- This log was last generated on Wed, 04 Feb 2026 20:42:47 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 19 Feb 2026 00:04:53 GMT and should not be manually modified.
4
+
5
+ ## 4.2.0
6
+ Thu, 19 Feb 2026 00:04:53 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
11
+
12
+ ## 4.1.126
13
+ Sat, 07 Feb 2026 01:13:26 GMT
14
+
15
+ _Version update only_
4
16
 
5
17
  ## 4.1.125
6
18
  Wed, 04 Feb 2026 20:42:47 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.1"
8
+ "packageVersion": "7.56.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { TerminalChunkKind } from '@rushstack/terminal';
4
+ /**
5
+ * This API was introduced as a temporary measure.
6
+ * @deprecated Very soon we plan to replace this with the `Terminal` API from `@rushstack/node-core-library`.
7
+ * @beta
8
+ */
9
+ export class CollatedTerminal {
10
+ constructor(destination) {
11
+ this._destination = destination;
12
+ }
13
+ writeChunk(chunk) {
14
+ this._destination.writeChunk(chunk);
15
+ }
16
+ writeStdoutLine(message) {
17
+ this._destination.writeChunk({ text: message + '\n', kind: TerminalChunkKind.Stdout });
18
+ }
19
+ writeStderrLine(message) {
20
+ this._destination.writeChunk({ text: message + '\n', kind: TerminalChunkKind.Stderr });
21
+ }
22
+ }
23
+ //# sourceMappingURL=CollatedTerminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollatedTerminal.js","sourceRoot":"","sources":["../src/CollatedTerminal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAuB,iBAAiB,EAAyB,MAAM,qBAAqB,CAAC;AAEpG;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAG3B,YAAmB,WAA6B;QAC9C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAEM,UAAU,CAAC,KAAqB;QACrC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAEM,eAAe,CAAC,OAAe;QACpC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;IAEM,eAAe,CAAC,OAAe;QACpC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;CACF","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 { type ITerminalChunk, TerminalChunkKind, type TerminalWritable } from '@rushstack/terminal';\n\n/**\n * This API was introduced as a temporary measure.\n * @deprecated Very soon we plan to replace this with the `Terminal` API from `@rushstack/node-core-library`.\n * @beta\n */\nexport class CollatedTerminal {\n private readonly _destination: TerminalWritable;\n\n public constructor(destination: TerminalWritable) {\n this._destination = destination;\n }\n\n public writeChunk(chunk: ITerminalChunk): void {\n this._destination.writeChunk(chunk);\n }\n\n public writeStdoutLine(message: string): void {\n this._destination.writeChunk({ text: message + '\\n', kind: TerminalChunkKind.Stdout });\n }\n\n public writeStderrLine(message: string): void {\n this._destination.writeChunk({ text: message + '\\n', kind: TerminalChunkKind.Stderr });\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { TerminalWritable } from '@rushstack/terminal';
4
+ import { CollatedTerminal } from './CollatedTerminal';
5
+ /**
6
+ * An writable interface for managing output of simultaneous processes.
7
+ *
8
+ * @beta
9
+ */
10
+ export class CollatedWriter extends TerminalWritable {
11
+ constructor(taskName, collator) {
12
+ super({ preventAutoclose: true });
13
+ this.taskName = taskName;
14
+ this.terminal = new CollatedTerminal(this);
15
+ this._collator = collator;
16
+ this._bufferedChunks = [];
17
+ }
18
+ /**
19
+ * Returns true if this is the active writer for its associated {@link StreamCollator}.
20
+ */
21
+ get isActive() {
22
+ return this._collator.activeWriter === this;
23
+ }
24
+ /**
25
+ * For diagnostic purposes, if the writer is buffering chunks because it has
26
+ * not become active yet, they can be inspected via this property.
27
+ */
28
+ get bufferedChunks() {
29
+ return this._bufferedChunks;
30
+ }
31
+ /** {@inheritDoc @rushstack/terminal#TerminalWritable.onWriteChunk} */
32
+ onWriteChunk(chunk) {
33
+ this._collator._writerWriteChunk(this, chunk, this._bufferedChunks);
34
+ }
35
+ /** {@inheritDoc @rushstack/terminal#TerminalWritable.onClose} */
36
+ onClose() {
37
+ this._collator._writerClose(this, this._bufferedChunks);
38
+ }
39
+ /** @internal */
40
+ _flushBufferedChunks() {
41
+ for (const chunk of this._bufferedChunks) {
42
+ this._collator.destination.writeChunk(chunk);
43
+ }
44
+ this._bufferedChunks.length = 0;
45
+ }
46
+ }
47
+ //# sourceMappingURL=CollatedWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollatedWriter.js","sourceRoot":"","sources":["../src/CollatedWriter.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAuB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAOlD,YAAmB,QAAgB,EAAE,QAAwB;QAC3D,KAAK,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,KAAK,IAAI,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,sEAAsE;IAC/D,YAAY,CAAC,KAAqB;QACvC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACtE,CAAC;IAED,iEAAiE;IAC1D,OAAO;QACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED,gBAAgB;IACT,oBAAoB;QACzB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;CACF","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 { type ITerminalChunk, TerminalWritable } from '@rushstack/terminal';\n\nimport type { StreamCollator } from './StreamCollator';\nimport { CollatedTerminal } from './CollatedTerminal';\n\n/**\n * An writable interface for managing output of simultaneous processes.\n *\n * @beta\n */\nexport class CollatedWriter extends TerminalWritable {\n private readonly _collator: StreamCollator;\n private readonly _bufferedChunks: ITerminalChunk[];\n\n public readonly taskName: string;\n public readonly terminal: CollatedTerminal;\n\n public constructor(taskName: string, collator: StreamCollator) {\n super({ preventAutoclose: true });\n\n this.taskName = taskName;\n this.terminal = new CollatedTerminal(this);\n\n this._collator = collator;\n\n this._bufferedChunks = [];\n }\n\n /**\n * Returns true if this is the active writer for its associated {@link StreamCollator}.\n */\n public get isActive(): boolean {\n return this._collator.activeWriter === this;\n }\n\n /**\n * For diagnostic purposes, if the writer is buffering chunks because it has\n * not become active yet, they can be inspected via this property.\n */\n public get bufferedChunks(): ReadonlyArray<ITerminalChunk> {\n return this._bufferedChunks;\n }\n\n /** {@inheritDoc @rushstack/terminal#TerminalWritable.onWriteChunk} */\n public onWriteChunk(chunk: ITerminalChunk): void {\n this._collator._writerWriteChunk(this, chunk, this._bufferedChunks);\n }\n\n /** {@inheritDoc @rushstack/terminal#TerminalWritable.onClose} */\n public onClose(): void {\n this._collator._writerClose(this, this._bufferedChunks);\n }\n\n /** @internal */\n public _flushBufferedChunks(): void {\n for (const chunk of this._bufferedChunks) {\n this._collator.destination.writeChunk(chunk);\n }\n this._bufferedChunks.length = 0;\n }\n}\n"]}
@@ -0,0 +1,144 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { InternalError } from '@rushstack/node-core-library';
4
+ import { CollatedWriter } from './CollatedWriter';
5
+ import { CollatedTerminal } from './CollatedTerminal';
6
+ /**
7
+ * A static class which manages the output of multiple threads.
8
+ *
9
+ * @beta
10
+ */
11
+ export class StreamCollator {
12
+ constructor(options) {
13
+ this._taskNames = new Set();
14
+ this._writers = new Set();
15
+ // The writer whose output is being shown in realtime, or undefined if none
16
+ this._activeWriter = undefined;
17
+ // Writers that are not closed yet, and have never been active
18
+ this._openInactiveWriters = new Set();
19
+ // Writers that are now closed, but have accumulated buffered chunks, and have never been active
20
+ this._closedInactiveWriters = new Set();
21
+ this._preventReentrantCall = false;
22
+ this.destination = options.destination;
23
+ this.terminal = new CollatedTerminal(this.destination);
24
+ this._onWriterActive = options.onWriterActive;
25
+ }
26
+ /**
27
+ * Returns the currently active `CollatedWriter`, or `undefined` if no writer
28
+ * is active yet.
29
+ */
30
+ get activeWriter() {
31
+ return this._activeWriter;
32
+ }
33
+ /**
34
+ * For diagnostic purposes, returns the {@link CollatedWriter.taskName} for the
35
+ * currently active writer, or an empty string if no writer is active.
36
+ */
37
+ get activeTaskName() {
38
+ if (this._activeWriter) {
39
+ return this._activeWriter.taskName;
40
+ }
41
+ return '';
42
+ }
43
+ /**
44
+ * The list of writers that have been registered by calling {@link StreamCollator.registerTask},
45
+ * in the order that they were registered.
46
+ */
47
+ get writers() {
48
+ return this._writers;
49
+ }
50
+ /**
51
+ * Registers a new task to be collated, and constructs a {@link CollatedWriter} object
52
+ * to receive its input.
53
+ */
54
+ registerTask(taskName) {
55
+ if (this._taskNames.has(taskName)) {
56
+ throw new Error('A task with that name has already been registered');
57
+ }
58
+ const writer = new CollatedWriter(taskName, this);
59
+ this._writers.add(writer);
60
+ this._taskNames.add(writer.taskName);
61
+ // When a task is initially registered, it is open and has not accumulated any buffered chunks
62
+ this._openInactiveWriters.add(writer);
63
+ if (this._activeWriter === undefined) {
64
+ // If there is no active writer, then the first one to be registered becomes active.
65
+ this._assignActiveWriter(writer);
66
+ }
67
+ return writer;
68
+ }
69
+ /** @internal */
70
+ _writerWriteChunk(writer, chunk, bufferedChunks) {
71
+ this._checkForReentrantCall();
72
+ if (this._activeWriter === undefined) {
73
+ // If no writer is currently active, then the first one to write something becomes active
74
+ this._assignActiveWriter(writer);
75
+ }
76
+ if (writer.isActive) {
77
+ this.destination.writeChunk(chunk);
78
+ }
79
+ else {
80
+ bufferedChunks.push(chunk);
81
+ }
82
+ }
83
+ /** @internal */
84
+ _writerClose(writer, bufferedChunks) {
85
+ this._checkForReentrantCall();
86
+ if (writer.isActive) {
87
+ writer._flushBufferedChunks();
88
+ this._activeWriter = undefined;
89
+ // If any buffered writers are already closed, activate them each immediately
90
+ // We copy the set, since _assignActiveWriter() will be deleting from it.
91
+ for (const closedInactiveWriter of [...this._closedInactiveWriters]) {
92
+ try {
93
+ this._assignActiveWriter(closedInactiveWriter);
94
+ }
95
+ finally {
96
+ this._activeWriter = undefined;
97
+ }
98
+ }
99
+ let writerToActivate = undefined;
100
+ // Try to activate a writer that already accumulated some data
101
+ for (const openInactiveWriter of this._openInactiveWriters) {
102
+ if (openInactiveWriter.bufferedChunks.length > 0) {
103
+ writerToActivate = openInactiveWriter;
104
+ break;
105
+ }
106
+ }
107
+ if (!writerToActivate) {
108
+ // Otherwise just take the first one
109
+ for (const openInactiveWriter of this._openInactiveWriters) {
110
+ writerToActivate = openInactiveWriter;
111
+ break;
112
+ }
113
+ }
114
+ if (writerToActivate) {
115
+ this._assignActiveWriter(writerToActivate);
116
+ }
117
+ }
118
+ else {
119
+ this._openInactiveWriters.delete(writer);
120
+ this._closedInactiveWriters.add(writer);
121
+ }
122
+ }
123
+ _assignActiveWriter(writer) {
124
+ this._activeWriter = writer;
125
+ this._closedInactiveWriters.delete(writer);
126
+ this._openInactiveWriters.delete(writer);
127
+ if (this._onWriterActive) {
128
+ this._preventReentrantCall = true;
129
+ try {
130
+ this._onWriterActive(writer);
131
+ }
132
+ finally {
133
+ this._preventReentrantCall = false;
134
+ }
135
+ }
136
+ writer._flushBufferedChunks();
137
+ }
138
+ _checkForReentrantCall() {
139
+ if (this._preventReentrantCall) {
140
+ throw new InternalError('Reentrant call to StreamCollator');
141
+ }
142
+ }
143
+ }
144
+ //# sourceMappingURL=StreamCollator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamCollator.js","sourceRoot":"","sources":["../src/StreamCollator.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA0BtD;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAoBzB,YAAmB,OAA+B;QAnB1C,eAAU,GAAgB,IAAI,GAAG,EAAE,CAAC;QACpC,aAAQ,GAAwB,IAAI,GAAG,EAA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ights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { InternalError } from '@rushstack/node-core-library';\nimport type { TerminalWritable, ITerminalChunk } from '@rushstack/terminal';\n\nimport { CollatedWriter } from './CollatedWriter';\nimport { CollatedTerminal } from './CollatedTerminal';\n\n/**\n * Constructor options for {@link StreamCollator}.\n *\n * @beta\n */\nexport interface IStreamCollatorOptions {\n /**\n * The target {@link @rushstack/terminal#TerminalWritable} object that the\n * {@link StreamCollator} will write its output to.\n */\n destination: TerminalWritable;\n\n /**\n * An event handler that is called when a {@link CollatedWriter} becomes output,\n * before any of its chunks have been written to the destination.\n *\n * @remarks\n *\n * Each `CollatedWriter` object will become active exactly once\n * before the `StreamCollator` completes.\n */\n onWriterActive?: (writer: CollatedWriter) => void;\n}\n\n/**\n * A static class which manages the output of multiple threads.\n *\n * @beta\n */\nexport class StreamCollator {\n private _taskNames: Set<string> = new Set();\n private _writers: Set<CollatedWriter> = new Set();\n\n // The writer whose output is being shown in realtime, or undefined if none\n private _activeWriter: CollatedWriter | undefined = undefined;\n\n // Writers that are not closed yet, and have never been active\n private _openInactiveWriters: Set<CollatedWriter> = new Set();\n\n // Writers that are now closed, but have accumulated buffered chunks, and have never been active\n private _closedInactiveWriters: Set<CollatedWriter> = new Set();\n\n private _onWriterActive: ((writer: CollatedWriter) => void) | undefined;\n\n private _preventReentrantCall: boolean = false;\n\n public readonly destination: TerminalWritable;\n public readonly terminal: CollatedTerminal;\n\n public constructor(options: IStreamCollatorOptions) {\n this.destination = options.destination;\n this.terminal = new CollatedTerminal(this.destination);\n this._onWriterActive = options.onWriterActive;\n }\n\n /**\n * Returns the currently active `CollatedWriter`, or `undefined` if no writer\n * is active yet.\n */\n public get activeWriter(): CollatedWriter | undefined {\n return this._activeWriter;\n }\n\n /**\n * For diagnostic purposes, returns the {@link CollatedWriter.taskName} for the\n * currently active writer, or an empty string if no writer is active.\n */\n public get activeTaskName(): string {\n if (this._activeWriter) {\n return this._activeWriter.taskName;\n }\n return '';\n }\n\n /**\n * The list of writers that have been registered by calling {@link StreamCollator.registerTask},\n * in the order that they were registered.\n */\n public get writers(): ReadonlySet<CollatedWriter> {\n return this._writers;\n }\n\n /**\n * Registers a new task to be collated, and constructs a {@link CollatedWriter} object\n * to receive its input.\n */\n public registerTask(taskName: string): CollatedWriter {\n if (this._taskNames.has(taskName)) {\n throw new Error('A task with that name has already been registered');\n }\n\n const writer: CollatedWriter = new CollatedWriter(taskName, this);\n\n this._writers.add(writer);\n this._taskNames.add(writer.taskName);\n\n // When a task is initially registered, it is open and has not accumulated any buffered chunks\n this._openInactiveWriters.add(writer);\n\n if (this._activeWriter === undefined) {\n // If there is no active writer, then the first one to be registered becomes active.\n this._assignActiveWriter(writer);\n }\n\n return writer;\n }\n\n /** @internal */\n public _writerWriteChunk(\n writer: CollatedWriter,\n chunk: ITerminalChunk,\n bufferedChunks: ITerminalChunk[]\n ): void {\n this._checkForReentrantCall();\n\n if (this._activeWriter === undefined) {\n // If no writer is currently active, then the first one to write something becomes active\n this._assignActiveWriter(writer);\n }\n\n if (writer.isActive) {\n this.destination.writeChunk(chunk);\n } else {\n bufferedChunks.push(chunk);\n }\n }\n\n /** @internal */\n public _writerClose(writer: CollatedWriter, bufferedChunks: ITerminalChunk[]): void {\n this._checkForReentrantCall();\n\n if (writer.isActive) {\n writer._flushBufferedChunks();\n\n this._activeWriter = undefined;\n\n // If any buffered writers are already closed, activate them each immediately\n // We copy the set, since _assignActiveWriter() will be deleting from it.\n for (const closedInactiveWriter of [...this._closedInactiveWriters]) {\n try {\n this._assignActiveWriter(closedInactiveWriter);\n } finally {\n this._activeWriter = undefined;\n }\n }\n\n let writerToActivate: CollatedWriter | undefined = undefined;\n\n // Try to activate a writer that already accumulated some data\n for (const openInactiveWriter of this._openInactiveWriters) {\n if (openInactiveWriter.bufferedChunks.length > 0) {\n writerToActivate = openInactiveWriter;\n break;\n }\n }\n if (!writerToActivate) {\n // Otherwise just take the first one\n for (const openInactiveWriter of this._openInactiveWriters) {\n writerToActivate = openInactiveWriter;\n break;\n }\n }\n\n if (writerToActivate) {\n this._assignActiveWriter(writerToActivate);\n }\n } else {\n this._openInactiveWriters.delete(writer);\n this._closedInactiveWriters.add(writer);\n }\n }\n\n private _assignActiveWriter(writer: CollatedWriter): void {\n this._activeWriter = writer;\n\n this._closedInactiveWriters.delete(writer);\n this._openInactiveWriters.delete(writer);\n\n if (this._onWriterActive) {\n this._preventReentrantCall = true;\n try {\n this._onWriterActive(writer);\n } finally {\n this._preventReentrantCall = false;\n }\n }\n\n writer._flushBufferedChunks();\n }\n\n private _checkForReentrantCall(): void {\n if (this._preventReentrantCall) {\n throw new InternalError('Reentrant call to StreamCollator');\n }\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * This library enables a tool to display live console output from multiple concurrent processes,
5
+ * while ensuring that their output does not get jumbled together.
6
+ *
7
+ * @remarks
8
+ *
9
+ * For more info, please see the package {@link https://www.npmjs.com/package/@rushstack/stream-collator
10
+ * | README}.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { CollatedTerminal } from './CollatedTerminal';
15
+ export { CollatedWriter } from './CollatedWriter';
16
+ export { StreamCollator } from './StreamCollator';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAA+B,MAAM,kBAAkB,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\n/**\n * This library enables a tool to display live console output from multiple concurrent processes,\n * while ensuring that their output does not get jumbled together.\n *\n * @remarks\n *\n * For more info, please see the package {@link https://www.npmjs.com/package/@rushstack/stream-collator\n * | README}.\n *\n * @packageDocumentation\n */\n\nexport { CollatedTerminal } from './CollatedTerminal';\nexport { CollatedWriter } from './CollatedWriter';\nexport { StreamCollator, type IStreamCollatorOptions } from './StreamCollator';\n"]}
package/package.json CHANGED
@@ -1,24 +1,46 @@
1
1
  {
2
2
  "name": "@rushstack/stream-collator",
3
- "version": "4.1.125",
3
+ "version": "4.2.0",
4
4
  "description": "Display intelligible realtime output from concurrent processes",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/microsoft/rushstack.git",
8
8
  "directory": "libraries/stream-collator"
9
9
  },
10
- "main": "lib/index.js",
11
- "typings": "dist/stream-collator.d.ts",
10
+ "main": "./lib-commonjs/index.js",
11
+ "module": "./lib-esm/index.js",
12
+ "types": "./dist/stream-collator.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/stream-collator.d.ts",
16
+ "import": "./lib-esm/index.js",
17
+ "require": "./lib-commonjs/index.js"
18
+ },
19
+ "./lib/*": {
20
+ "types": "./lib-dts/*.d.ts",
21
+ "import": "./lib-esm/*.js",
22
+ "require": "./lib-commonjs/*.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "typesVersions": {
27
+ "*": {
28
+ "lib/*": [
29
+ "lib-dts/*"
30
+ ]
31
+ }
32
+ },
12
33
  "license": "MIT",
13
34
  "dependencies": {
14
- "@rushstack/node-core-library": "5.19.1",
15
- "@rushstack/terminal": "0.21.0"
35
+ "@rushstack/terminal": "0.22.0",
36
+ "@rushstack/node-core-library": "5.20.0"
16
37
  },
17
38
  "devDependencies": {
18
39
  "eslint": "~9.37.0",
19
- "@rushstack/heft": "1.1.13",
40
+ "@rushstack/heft": "1.2.0",
20
41
  "local-node-rig": "1.0.0"
21
42
  },
43
+ "sideEffects": false,
22
44
  "scripts": {
23
45
  "build": "heft build --clean",
24
46
  "_phase:build": "heft run --only build -- --clean",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes