{"name":"@skiffyard/clispinner","description":"A terminal spinner that animates in its own task: 91 animations, status text, nothing drawn off a terminal","versions":{"0.4.0":{"version":"0.4.0","kind":"git","url":"https://github.com/skiffyard/deck-clispinner.git","ref":"0.4.0","commit":"20c3e665cd8895cda12f9949160a15d64a0faa22","checksum":"","yanked":false,"license":"MIT","requires":{},"engines":{"jennifer":"\u003e=0.27.0"},"capabilities":[],"keywords":["spinner","terminal","cli","progress"],"description":"A terminal spinner that animates in its own task: 91 animations, status text, nothing drawn off a terminal","publishedAt":"1795878408","repoId":1335332223,"repoOwnerId":362133827,"repoOwner":"skiffyard"}},"readme":"# @skiffyard/clispinner\n\n[![version](https://img.shields.io/github/v/tag/skiffyard/deck-clispinner?sort=semver\u0026label=version)](https://registry.jennifer-lang.dev/deck/skiffyard/clispinner)\n\nA terminal spinner for Jennifer. The animation runs in its own `spawn`ed task,\nso the caller carries on with the slow work while it spins.\n\n**[Documentation](https://skiffyard.github.io/deck-clispinner/)**\n\nThis deck is part of [Skiffyard](https://github.com/skiffyard), small community decks for [Jennifer](https://jennifer-lang.dev/).\n\n```toml\n[decks]\n\"@skiffyard/clispinner\" = \"^0.4.0\"\n```\n\n`jvc install` vendors it to `vendor/skiffyard/clispinner/`. Import it by its scoped\nname, not by a path into `vendor/`:\n\n```jennifer\nimport \"@skiffyard/clispinner/\" as spinner;\n\ndef sp as spinner.Spinner init spinner.startSpinner(\n    spinner.options(\"dots\", \"resolving the dependency graph\"));\n\n$sp = spinner.statusSpinner($sp, \"fetching @acme/demo 0.1.0\");\n$sp = spinner.updateSpinner($sp, spinner.options(\"bouncingBar\", \"vendoring\"));\n\nspinner.finishSpinner($sp, \"ok\", \"installed 3 decks\");\n```\n\n## API\n\n| Call | Does |\n| ---- | ---- |\n| `startSpinner(opts)` | launch the animation; returns a handle immediately |\n| `updateSpinner(sp, opts)` | replace animation, speed, label and stream; restarts the frame index |\n| `statusSpinner(sp, msg)` | replace the text to the right of the spinner |\n| `removeSpinner(sp)` | stop the task, erase the block, restore the cursor; returns frames drawn |\n| `finishSpinner(sp, mark, msg)` | `removeSpinner`, then print `mark msg` as a line that stays |\n| `options(name, label)` | an `Options` with defaults filled in |\n| `spinnerNames()` | all 91 animation names, sorted |\n| `spinnerSize(name)` | the animation's `Size` (`cols`, `rows`) |\n\nEvery verb takes the handle because the handle carries the command channel.\n`spawn` deep-copies its scope at launch, so the task never sees later writes to\nthe caller's variables; the channel is the only shared state. `removeSpinner`\nblocks until the task has finished and closes the channel, so sending to a\nremoved spinner throws a `closed` error. Always call `removeSpinner` or\n`finishSpinner`: a running spinner keeps the cursor hidden.\n\n## Options\n\n```jennifer\ndef o as spinner.Options init spinner.options(\"dots\", \"working\");\n$o.speed = 40;                    # ms per frame; 0 uses the animation's own\n$o.stream = spinner.STDOUT;       # default spinner.STDERR\n```\n\nBuild options with `options(name, label)`: the struct will gain fields, the\ncall will not. An unknown or empty name falls back to `dots` instead of\nthrowing, so user input can be passed through; `has(name)` in `src/frames.j`\nvalidates it. Any stream other than `STDOUT` becomes `STDERR`, and a negative\nspeed becomes 0.\n\n## Off a terminal it draws nothing\n\nWhether the stream is a terminal is checked once, at `startSpinner`. Off a\nterminal (piped, redirected) nothing is written, but the task still runs and\naccepts commands, so calling code needs no branch. `removeSpinner` then\nreturns `0`. Changing the stream with `updateSpinner` does not repeat the\ncheck.\n\n## Layout\n\nEach animation carries its measured size, because `len` counts runes, not\nterminal columns: `moon` is one emoji plus a space, 2 runes and 3 columns.\n`material` is 20 columns by 1 row.\n\nThe block never wraps, because a redraw erases only the rows the last block\noccupied and a wrapped row would stay on screen:\n\n- The frame is never cut. The status is cut, with an ellipsis (`…`).\n- The status gets as many rows as the animation is tall. Its own `\\n` breaks\n  are honoured within that budget; long lines are broken mid-word; text past\n  the last row is dropped and the cut marked with `…`.\n- The terminal's last column stays empty. A line ending at the edge leaves the\n  cursor in the pending-wrap state, and terminals disagree on what the next\n  newline does.\n- An animation taller than the window is clipped to the window height minus\n  one row (`soccerVertical` in a nine-row window draws eight rows). Without\n  this the terminal scrolls and the erase cannot reach the top rows.\n\nWidth and height are read on every frame. When they cannot be read the\nspinner assumes 80 columns by 24 rows (`FALLBACK_COLS`, `FALLBACK_ROWS`).\nStatus width is counted in runes, so wide characters in a status can still\noverflow.\n\n```jennifer\nspinner.statusSpinner($sp, \"resolving\\n  @acme/alpha\\n  @acme/beta\");\n```\n\n## The animations\n\n90 animations are ported from\n[cli-spinners](https://github.com/sindresorhus/cli-spinners) (MIT), so `dots`\nor `line` looks the way users expect. Frames are padded to the animation's\nwidth so the status column does not move. `soccerVertical` (2 columns by 12\nrows) is this deck's own: `soccerHeader` turned on its side, the only\nmulti-row animation. `src/frames.j` is generated from upstream's\n`spinners.json`; regenerate it instead of editing it by hand.\n\n## Development\n\n```sh\ntools/check-all.sh                     # the full gate, as CI runs it\njennifer test src/clispinner_test.j    # API and state machine\njennifer test src/frames_test.j        # the catalogue\ntools/check-docs.sh                    # docs against the code\ntools/pack.sh dist                     # build the release archive\njennifer lint demo.j                   # the demo is outside the gate\n./demo.j                               # the tour; needs a terminal\n./demo.j multiline                     # soccerVertical and a multi-row status\n./demo.j names                         # list every spinner\n```\n\nThe tests run off a terminal, so nothing is drawn. The state machine is tested\nthrough its pure functions (`applyCommand`, `advance`, `currentFrame`,\n`renderBlock`) and the task through the command round trip.\n\n## Licence\n\nMIT, see [LICENSE](LICENSE). Copyright (C) 2026 mplx \u0026lt;mplx@jennifer-lang.dev\u0026gt;.\nAnimation data from cli-spinners, MIT.\n","movedFrom":["@mplx/clispinner"]}