kamiyo / multi-progress-bars Goto Github PK
View Code? Open in Web Editor NEWA multi progress bar library for CLI, with support for indefinite task spinners
License: MIT License
A multi progress bar library for CLI, with support for indefinite task spinners
License: MIT License
[WEBPACK] ERROR in ./node_modules/multi-progress-bars/dist/multi-progress-bars.es.js 1:0
[WEBPACK] Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
This is due to having a "type": "commonjs"
in your top-level package.json: https://github.com/kamiyo/multi-progress-bars/blob/master/package.json#L13
I think it could be resolved in a way that "just works" with the default webpack behavior by renaming your dist/multi-progress-bars.es.js
to instead use a .mjs
extension (this would require two matching changes to the package.json).
The symbols used for showing partial bits of a loading bar are not supported in windows terminals (at least in cmd), would be good to have some sort of fallback so it doesnt look broken.
After terminating the process with Ctrl-C it does not actually close and timers continue to run in the background before erroring when trying to write to console.
This behaviour is not seen when disabling the progress bars and only requires a new instance of the MultiProgressBars class to be created. Its not affected by calling .close or .cleanup.
You can checkout the codebase I'm trying to use it in here: https://github.com/Inrixia/Floatplane-Downloader/tree/5dae0aa57be48cbb87bebc0bfa4f2c3fcad18eef
Right now with version 4.2.0
, importing multi-progress-bars
into a project using ES modules fails like this:
file:///....../node_modules/multi-progress-bars/dist/multi-progress-bars.mjs:1
import { green } from 'chalk';
^^^^^
SyntaxError: Named export 'green' not found. The requested module 'chalk' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'chalk';
const { green } = pkg;
It's caused by how the TypeScript transpiler optimize import statements if it compiles to an ES module, and how NodeJS treats CJS imports in said ES modules. The error message suggests a potential solution to the problem, but I'm not sure if the TypeScript transpiler could be configured to achieve these statements.
Related (yet not similar) issues are discussed here and here.
As a side note, the issue doesn't appear if dist/multi-progress-bars.cjs
is imported instead. However, this workaround can't be used with the current multi-progress-bars
release, as it defines an exports
section in its package.json
which masks direct access to the files in the dist/
folder. The workaround would require the exports
to be modified.
I'm using mbp like this:
const MultiProgressBars = require('multi-progress-bars')
const mpb = new MultiProgressBars();
and getting the following error:
TypeError: MultiProgressBars is not a constructor
What's the proper way to instatiate a progress bar? Thank you!
Line 1 in multi-progress-bars.mjs
import { green } from 'chalk';
throws exception
import { green } from 'chalk';
^^^^^
SyntaxError: Named export 'green' not found. The requested module 'chalk' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
I'm using node 16
so it should be
import chalk from 'chalk';
const { green } = chalk;
When creating a new bar using .addTask trying to set the percentage of the bar using
bar.addTask("/=== SUMMARY ===\\", { type: "percentage", percentage: 0.5 });
for example the percentage is not set.
I have to call bar.update(...) to set it.
When using a pattern of '' (empty string) a crash occours.
Example:
this.mpb?.setFooter({
message: `\n\n${processed}\n${downloaded}\n${speed}`,
pattern: '',
})
C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:421
const base = clampString(pattern.repeat(Math.ceil(this.logger.width / stringWidth__default['default'](pattern))), this.logger.width);
^
RangeError: Invalid count value
at String.repeat (<anonymous>)
at MultiProgressBars.makeBorder (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:421:42)
at MultiProgressBars.setFooter (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:472:50)
at Downloader.updateSummaryBar (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\dist\Downloader.js:69:19)
at Request.<anonymous> (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\dist\Downloader.js:137:34)
at Request.emit (node:events:390:28)
at IncomingMessage.<anonymous> (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\floatplane\node_modules\got\dist\source\core\index.js:800:18)
at Object.onceWrapper (node:events:509:28)
at IncomingMessage.emit (node:events:402:35)
at IncomingMessage.origin.emit (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\floatplane\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
Not sure what causes it to happen, but it will start to download a video and go through the entire process, then freeze when doing the ffmpeg info. It's somehow not detecting an already downloaded video and re-downloading it (guessing the size changed or something?), but because the name already exists, it can't finish the process so it just sits there forever.
https://cdn.discordapp.com/attachments/468977376794247199/841765883276820480/unknown.png One screenshot showing somebody else having the issue. Band-aid solution is to close the program, and delete both the original.mp4 and the new blank extension file and make it redownload the whole thing once more.
If you update examples/exampleBottom.ts to add stream: process.stderr
to the new MultiProgressBar()
constructor, and then run this example in a situation where stdout is not a TTY, e.g.
node bottomInput.js > /dev/null
then the MultiProgressBar UI does not update in place. Instead every increment/update call results in the console scrolling. There seems to be some garbage "aN;H" added to every newline --- even though i expect no newlines.
Is it possible there a bug where the cursor control characters are always sent to stdout, even if stream is stderr? I haven't looked at your code yet to see.
Tasks don't seem to show up if I don't add an "index" value, but the tool itself could add an index and thus aleviate the need to account for the tasks added and coming up with a new index. A function exposing alrady added taks (bars) would also be apreciated and in turn this could be used to come up with a new index. Thanks.
When there are enough bars that they go outside the terminals view a terminal update causes flickering.
Having the ability to remove bars or limit the amount would probably solve this issue.
@Hezkezl
Calling setFooter with a string that contains newlines results in massive console spam and loading bars completely breaking.
I presume this is due to the line counts being offset by the newlines.
Working:
this.mpb?.setFooter({
message: `${processed} - ${downloaded} - ${speed}`,
pattern: ' ',
});
Broken:
this.mpb?.setFooter({
message: `${processed}\n${downloaded}\n${speed}`,
pattern: ' ',
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.