@stamhoofd/stdsync 2.157.1 → 2.160.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/LICENSE.md +7 -7
- package/dist/index.js +1 -108
- package/dist/index.js.map +1 -1
- package/dist-types/index.d.ts +1 -31
- package/dist-types/index.d.ts.map +1 -1
- package/package.json +40 -32
package/LICENSE.md
CHANGED
|
@@ -5,25 +5,25 @@ Copyright 2020 Codawood BV
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
|
|
6
6
|
|
|
7
7
|
1. Eligibility:
|
|
8
|
-
This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
|
|
8
|
+
This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
|
|
9
9
|
|
|
10
10
|
2. Modifications:
|
|
11
|
-
Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
|
|
11
|
+
Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
|
|
12
12
|
|
|
13
13
|
3. Precedence of Existing Licenses:
|
|
14
|
-
If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
|
|
14
|
+
If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
|
|
15
15
|
|
|
16
16
|
4. Data Protection / GDPR Responsibility:
|
|
17
|
-
Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
|
|
17
|
+
Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
|
|
18
18
|
|
|
19
19
|
5. Termination and Revocation:
|
|
20
|
-
The copyright holders may revoke this license at any time, at their sole discretion.
|
|
20
|
+
The copyright holders may revoke this license at any time, at their sole discretion.
|
|
21
21
|
|
|
22
22
|
6. Governing Law:
|
|
23
|
-
This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
|
|
23
|
+
This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
|
|
24
24
|
|
|
25
25
|
7. Third-Party Licenses:
|
|
26
|
-
Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
|
|
26
|
+
Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
|
|
27
27
|
|
|
28
28
|
For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
|
|
29
29
|
|
package/dist/index.js
CHANGED
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Selects the destination for write(); live output is always drawn on stdout. */
|
|
3
|
-
export var OutputStream;
|
|
4
|
-
(function (OutputStream) {
|
|
5
|
-
OutputStream["Stdout"] = "stdout";
|
|
6
|
-
OutputStream["Stderr"] = "stderr";
|
|
7
|
-
})(OutputStream || (OutputStream = {}));
|
|
8
|
-
/** Keeps a replaceable block of terminal output below ordinary stdout and stderr writes. */
|
|
9
|
-
export class StdSync {
|
|
10
|
-
stdout;
|
|
11
|
-
stderr;
|
|
12
|
-
writeStdout;
|
|
13
|
-
writeStderr;
|
|
14
|
-
// The original bound writes bypass the temporary hooks when clearing or redrawing.
|
|
15
|
-
content = '';
|
|
16
|
-
lines = 0;
|
|
17
|
-
// A write without a trailing newline leaves the cursor above the live block.
|
|
18
|
-
partial = false;
|
|
19
|
-
/** Defaults to the process streams; pass streams explicitly when embedding or testing. */
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.stdout = options.stdout ?? process.stdout;
|
|
22
|
-
this.stderr = options.stderr ?? process.stderr;
|
|
23
|
-
this.writeStdout = this.stdout.write.bind(this.stdout);
|
|
24
|
-
this.writeStderr = this.stderr.write.bind(this.stderr);
|
|
25
|
-
}
|
|
26
|
-
get isTTY() {
|
|
27
|
-
return !!this.stdout.isTTY;
|
|
28
|
-
}
|
|
29
|
-
/** Replace the live block. On non-TTY stdout this is a no-op. */
|
|
30
|
-
setLive(content) {
|
|
31
|
-
if (!this.isTTY) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!this.content) {
|
|
35
|
-
// Intercept writes through these stream objects, including console output.
|
|
36
|
-
this.stdout.write = ((chunk, encoding, callback) => this.write(chunk, OutputStream.Stdout, encoding, callback));
|
|
37
|
-
this.stderr.write = ((chunk, encoding, callback) => this.write(chunk, OutputStream.Stderr, encoding, callback));
|
|
38
|
-
}
|
|
39
|
-
this.clear();
|
|
40
|
-
this.content = content;
|
|
41
|
-
if (!this.partial) {
|
|
42
|
-
this.render();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** Write to either stream, temporarily moving the live block out of the way. */
|
|
46
|
-
write(chunk, stream = OutputStream.Stdout, encoding, callback) {
|
|
47
|
-
if (this.content && !this.partial) {
|
|
48
|
-
this.clear();
|
|
49
|
-
}
|
|
50
|
-
const result = stream === OutputStream.Stdout
|
|
51
|
-
? this.writeStdout(chunk, encoding, callback)
|
|
52
|
-
: this.writeStderr(chunk, encoding, callback);
|
|
53
|
-
if (this.content) {
|
|
54
|
-
// Wait for a complete line before redrawing, so split writes remain contiguous.
|
|
55
|
-
this.partial = !/[\r\n]$/.test(String(chunk));
|
|
56
|
-
if (!this.partial) {
|
|
57
|
-
this.render();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
/** Erase the live block and restore the original stream writes. */
|
|
63
|
-
clearLive() {
|
|
64
|
-
if (!this.content) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this.clear();
|
|
68
|
-
this.content = '';
|
|
69
|
-
this.lines = 0;
|
|
70
|
-
this.partial = false;
|
|
71
|
-
this.stdout.write = this.writeStdout;
|
|
72
|
-
this.stderr.write = this.writeStderr;
|
|
73
|
-
}
|
|
74
|
-
/** Keep the last live block visible as ordinary output and restore stream writes. */
|
|
75
|
-
done() {
|
|
76
|
-
if (!this.content) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (this.partial) {
|
|
80
|
-
// A partial log must finish before the live block can become permanent.
|
|
81
|
-
this.writeStdout('\n');
|
|
82
|
-
this.partial = false;
|
|
83
|
-
this.render();
|
|
84
|
-
}
|
|
85
|
-
this.content = '';
|
|
86
|
-
this.lines = 0;
|
|
87
|
-
this.stdout.write = this.writeStdout;
|
|
88
|
-
this.stderr.write = this.writeStderr;
|
|
89
|
-
}
|
|
90
|
-
clear() {
|
|
91
|
-
if (this.lines) {
|
|
92
|
-
// Move to the start of the rendered block, then erase to the bottom.
|
|
93
|
-
this.writeStdout(`\x1b[${this.lines}A\x1b[0J`);
|
|
94
|
-
this.lines = 0;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
render() {
|
|
98
|
-
if (this.content) {
|
|
99
|
-
this.writeStdout(`${this.content}\n`);
|
|
100
|
-
const columns = this.stdout.columns;
|
|
101
|
-
// Count terminal rows rather than newline-delimited lines: text may wrap.
|
|
102
|
-
this.lines = this.content.split('\n').reduce((lines, line) => {
|
|
103
|
-
const width = stripVTControlCharacters(line).length;
|
|
104
|
-
return lines + (columns ? Math.max(1, Math.ceil(width / columns)) : 1);
|
|
105
|
-
}, 0);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
export { StdSync, OutputStream } from '@stamhoofd/node-terminal';
|
|
109
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare enum OutputStream {
|
|
3
|
-
Stdout = "stdout",
|
|
4
|
-
Stderr = "stderr"
|
|
5
|
-
}
|
|
6
|
-
/** Keeps a replaceable block of terminal output below ordinary stdout and stderr writes. */
|
|
7
|
-
export declare class StdSync {
|
|
8
|
-
private readonly stdout;
|
|
9
|
-
private readonly stderr;
|
|
10
|
-
private readonly writeStdout;
|
|
11
|
-
private readonly writeStderr;
|
|
12
|
-
private content;
|
|
13
|
-
private lines;
|
|
14
|
-
private partial;
|
|
15
|
-
/** Defaults to the process streams; pass streams explicitly when embedding or testing. */
|
|
16
|
-
constructor(options?: {
|
|
17
|
-
stdout?: NodeJS.WriteStream;
|
|
18
|
-
stderr?: NodeJS.WriteStream;
|
|
19
|
-
});
|
|
20
|
-
get isTTY(): boolean;
|
|
21
|
-
/** Replace the live block. On non-TTY stdout this is a no-op. */
|
|
22
|
-
setLive(content: string): void;
|
|
23
|
-
/** Write to either stream, temporarily moving the live block out of the way. */
|
|
24
|
-
write(chunk: string | Uint8Array, stream?: OutputStream, encoding?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean;
|
|
25
|
-
/** Erase the live block and restore the original stream writes. */
|
|
26
|
-
clearLive(): void;
|
|
27
|
-
/** Keep the last live block visible as ordinary output and restore stream writes. */
|
|
28
|
-
done(): void;
|
|
29
|
-
private clear;
|
|
30
|
-
private render;
|
|
31
|
-
}
|
|
1
|
+
export { StdSync, OutputStream } from '@stamhoofd/node-terminal';
|
|
32
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@stamhoofd/stdsync",
|
|
3
|
+
"version": "2.160.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/stamhoofd/stamhoofd.git",
|
|
7
|
+
"directory": "shared/stdsync"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist-types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist-types/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"dist-types",
|
|
21
|
+
"package.json"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@stamhoofd/node-terminal": "2.160.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"oxlint-plugin-stamhoofd": "2.160.0",
|
|
28
|
+
"vitest": "4.1.12"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"license": "UNLICENSED",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --build tsconfig.build.json",
|
|
36
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
37
|
+
"example": "pnpm run build && node examples/live-output.mjs",
|
|
38
|
+
"lint": "oxlint . --quiet --type-aware --threads 2",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
}
|
|
41
|
+
}
|