Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: animated spinner #334

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: animated spinner #334

wants to merge 1 commit into from

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Dec 28, 2024

closes #284

This PR enables an animated spinner with consola.start() which is stopped by consola.{sucess,fail,fatalerror}

The implementation also handles multi-line interrupts when the spinner is spinning and another log happens. both for build-in consola methods and when consola.wrapAll() is active.

[wip] it still can be problematic in ambiguous contexts, therefore we need a stable spy on stdout/stderr to count new lines and track them.

This PR is also likely landing for consola v4 as behavior change could be a regression.

@stijns96
Copy link

stijns96 commented Dec 31, 2024

I'm currently working with spinnies, but I really like to use Consola. Only thing for me that is missing is exactly this. Would be so great to have this!

Is this also handling that the consola.{sucess,fail,fatalerror} is overwriting the current spinner like spinnies does? I'd like to have a simple list like listr and spinnies that can be stopped on the same line.

@pi0
Copy link
Member Author

pi0 commented Jan 2, 2025

In the current, simplest implementation, (top-level) consola.sucess,fail,fatalerror finalizes (previous) loading state (started by consola.start)

I am thinking of two possible ways to expose controllable spinner instances for listr like behavior:

  • createSpinner(): Spinner (from consola/utils)
  • consola.start(): Spinner

I am leaning more towards the first as it is an explicit API and we can enhance it more easily without needing to hook into global events. And we keep consola.* behavior for minimal usage like other utils.

Another note to mention, I am thinking to use "stick to buttom" style similar to apt. Stick to top is possible and we can make sure it remains (semi) stable like webpackbar but it is so much costly at very least since we need to spy and rerender everything goes out in consola during spinning. (it all works well when consola/spinner is in control. as soon as another source wants writing to stdout/stderr things go complicated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animated spinner
2 participants