flagstaff 1.4.0 → 1.5.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/dist/ora.js +12 -4
- package/package.json +2 -2
package/dist/ora.js
CHANGED
|
@@ -77,6 +77,7 @@ const FALLBACK_INTERVAL = 100;
|
|
|
77
77
|
const DEFAULT_COLUMNS = 80;
|
|
78
78
|
const TRUNCATION_RESERVE = 1;
|
|
79
79
|
const activeHooksPerStream = new Map();
|
|
80
|
+
const writeHooks = new WeakMap();
|
|
80
81
|
const validColors = new Set(['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray']);
|
|
81
82
|
function paint(color, text) {
|
|
82
83
|
if (color === undefined || color === false)
|
|
@@ -428,13 +429,20 @@ export class Ora {
|
|
|
428
429
|
console.warn('[ora] Multiple concurrent spinners detected. This may cause visual corruption. Use one spinner at a time.');
|
|
429
430
|
}
|
|
430
431
|
const originalWrite = stream.write;
|
|
431
|
-
|
|
432
|
+
const record = { wrapped: originalWrite, live: true };
|
|
433
|
+
const hook = (chunk, encoding, callback) => record.live ? this.#hookedWrite(stream, originalWrite, chunk, encoding, callback) : originalWrite.call(stream, chunk, encoding, callback);
|
|
434
|
+
writeHooks.set(hook, record);
|
|
435
|
+
this.#hookedStreams.set(stream, hook);
|
|
432
436
|
activeHooksPerStream.set(stream, this);
|
|
433
|
-
stream.write =
|
|
437
|
+
stream.write = hook;
|
|
434
438
|
}
|
|
435
439
|
#uninstallHook() {
|
|
436
|
-
for (const [stream,
|
|
437
|
-
|
|
440
|
+
for (const [stream, hook] of this.#hookedStreams) {
|
|
441
|
+
const record = writeHooks.get(hook);
|
|
442
|
+
if (record)
|
|
443
|
+
record.live = false;
|
|
444
|
+
for (let top = writeHooks.get(stream.write); top && !top.live; top = writeHooks.get(stream.write))
|
|
445
|
+
stream.write = top.wrapped;
|
|
438
446
|
if (activeHooksPerStream.get(stream) === this)
|
|
439
447
|
activeHooksPerStream.delete(stream);
|
|
440
448
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagstaff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Spinners, progress, boxes and tables on one terminal frame loop, with a static projection for pipes, screen readers and agents, and a plugin host. No dependency outside the burgee family. Drop-in paths for ora, log-update, boxen and cli-table3.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"json"
|
|
142
142
|
],
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"closeout": "^1.1.
|
|
144
|
+
"closeout": "^1.1.3",
|
|
145
145
|
"linegauge": "^1.1.1",
|
|
146
146
|
"paratext": "^1.0.6",
|
|
147
147
|
"roundel": "^1.1.1"
|