# flagstaff/import

> Every export of flagstaff/import, with its signature and doc comment: fromCliSpinners, fromCliBoxes, plus 4 types.

Source: https://flagstaff.interlace.tools/docs/api/import

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->

`flagstaff/import` (R11) — the two data corpora the ecosystem already has, as plugins.

cli-spinners ships ~80 spinner styles and cli-boxes ships eight border sets, both as
plain JSON that thousands of programs already depend on. Neither is bundled here: the
weight of a corpus nobody asked for is exactly what U5 is about, and a caller who wants
one already has it on disk. So these take the JSON and hand back a plugin:

```js
import cliSpinners from 'cli-spinners';
import { fromCliSpinners } from 'flagstaff/import';
import { register } from 'flagstaff/plugin';

register(fromCliSpinners(cliSpinners));
spinner('moon');
```

The result is an ordinary plugin — it goes through the same `register()`, is validated
against the same schema, and can be replaced by another. That is the point: the gallery
opens full, and a third-party plugin starts as a copy of one of these.

```ts
import { fromCliSpinners, fromCliBoxes } from 'flagstaff/import';
```

## Functions

### fromCliBoxes

Turn cli-boxes' `boxes.json` into a plugin. Its shape is already ours, so this is a copy.

```ts
function fromCliBoxes(corpus: Record<string, CliBox>, { name }?: FromCliBoxesOptions): Plugin;
```

| Parameter | Type |
| :-- | :-- |
| `corpus` | `Record<string, CliBox>` |
| `{ name }` (optional) | `FromCliBoxesOptions` |

**Returns** `Plugin`

### fromCliSpinners

Turn cli-spinners' `spinners.json` into a plugin. The corpus stays the caller's.

```ts
function fromCliSpinners(corpus: Record<string, CliSpinner>, { name, staticFor }?: FromCliSpinnersOptions): Plugin;
```

| Parameter | Type |
| :-- | :-- |
| `corpus` | `Record<string, CliSpinner>` |
| `{ name, staticFor }` (optional) | `FromCliSpinnersOptions` |

**Returns** `Plugin`

## Interfaces

### CliSpinner

cli-spinners' shape: no `static`, because it has no projection for a pipe.

```ts
interface CliSpinner {
    frames: string[];
    interval?: number;
}
```

### FromCliBoxesOptions

```ts
interface FromCliBoxesOptions {
    name?: string;
}
```

### FromCliSpinnersOptions

```ts
interface FromCliSpinnersOptions {
    /** The plugin's name, which is what `flagstaff check` and the gallery label it with. */
    name?: string;
    /**
     * The static projection for a style, given its name and its frames. Default: `'…'` for
     * every one of them.
     *
     * The design sketched "the first frame" here, and that turned out to be wrong when it met
     * the corpus: a frozen `⠋` or `▰` is an animation stopped mid-stride, not a projection —
     * it tells a pipe, an agent and a screen reader nothing that `…` does not tell them
     * better. The parameter exists because it is the author's call, not this function's.
     */
    staticFor?: (name: string, spinner: CliSpinner) => string;
}
```

## Types

### CliBox

cli-boxes' shape — the same eight keys `BorderStyle` has, which is why it imports whole.

```ts
type CliBox = BorderStyle;
```
