# @soundworks/template-helpers

> set of generic helpers for the soundworks-template

Latest version **3.0.0** (published 2023-09-27) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @soundworks/template-helpers
pnpm add @soundworks/template-helpers
yarn add @soundworks/template-helpers
bun add @soundworks/template-helpers
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-09-27 |
| First published | 2020-08-31 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | b-ma |

## Links

- npm: https://www.npmjs.com/package/@soundworks/template-helpers
- Repository: https://github.com/collective-soundworks/soundworks-template-helpers
- Homepage: https://github.com/collective-soundworks/soundworks-template-helpers#readme
- Issues: https://github.com/collective-soundworks/soundworks-template-helpers/issues
- npm.io page: https://npm.io/package/@soundworks/template-helpers

## Dependencies (2)

- [lit](https://npm.io/package/lit.md) ^2.2.2
- [@ircam/sc-components](https://npm.io/package/@ircam/sc-components.md) ^3.0.0-alpha.40

## Recent versions

- 3.0.0 (latest) — 2023-09-27
- 2.0.1 — 2022-05-03
- 2.0.0 — 2022-04-28
- 1.2.3 — 2022-01-12
- 1.2.2 — 2022-01-12
- 1.2.1 — 2021-05-27
- 1.2.0 — 2021-05-21
- 1.1.0 — 2021-01-14
- 1.0.2 — 2020-10-23
- 1.0.1 — 2020-08-31
- 1.0.0 — 2020-08-31

## README

# `@soundworks/template-helpers`

> Set of common helpers for applications based on the [`soundworks-template`](https://github.com/collective-soundworks/soundworks-template). 
>
> _Helpers are already installed in the `soundworks-template`_

## Installation

```
npm install --save @soundworks/template-helpers
```

## `initQoS`

Initialize generic quality of service strategies.

For now, basically reload application when socket close or on visibility change.
__more refined strategies should be created over time.__

### Arguments

- `client {soundworks.Client}` - the soundworks client instance
- `options {Object}`
  + `options.socketClosed = true` - reloads the page if the socket connection is lost, 
    e.g. you generally don't want a client that cannot receive stop messages in a performance.
  + `options.visibilityChange = true` - reloads the page on visiblity change (
    e.g. when your page is no longer the focused tab all scheduling is broken

### Usage

```
import { Client } from '@soundworks/core/client';
import initQoS from '@soundworks/helpers/client/init-qos.js';

async function launch() {
  try {
    const client = new Client();
    await client.init(window.soundworksConfig);
    initQoS(client);

    // ...
  } catch(err) {
    console.error(err);
  }
}

launch();
```


## `renderInitializationScreens`

Display generic initialization screens for plugins

### Usage

```
import { Experience } from '@soundworks/core/client';
import { render, html } from 'lit-html';
import renderInitializationScreens from '@soundworks/template-helpers/client/render-initialization-screens.js';

class ControllerExperience extends Experience {
  constructor(client, config, $container) {
    super(client);

    this.config = config;
    this.$container = $container;

    renderInitializationScreens(client, config, $container);
  }

  // ...
}
```

## License

BSD-3-Clause

---
_Source: https://npm.io/package/@soundworks/template-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
