open-index/open-npm huggingface dataset:
npm package: @jcbyte/firebase-live-state
Description: Provides a React hook for synchronising a state variable with a Firebase Realtime Database at a given path.
Author: Joel Cutler
Latest version: 1.0.6

# firebase-live-state

Provides a React hook for synchronising a state variable with a [Firebase Realtime Database](https://firebase.google.com/docs/database) at a given path.

## Installation

```bash
npm i @jcbyte/firebase-live-state
```

## Usage

Ensure that your Firebase Realtime Database security rules allow read and write access to the path you're synchronising with.

Initialise firebase, and get the Realtime Database instance:

```ts
import { initializeApp } from "firebase/app";
import { getDatabase } from "firebase/database";

const firebaseApp = initializeApp({
	/* your config */
});
const db = getDatabase(firebaseApp);
```

Use `useLiveState` to create your synchronised state variable and setter:

```ts
import { useLiveState } from "@jcbyte/firebase-live-state";

export default function YourComponent() {
	const [obj, setObj] = useLiveState<T>(db, "/firebase/path");

	function increment() {
		setObj((prev) => {
			return {...prev, count: prev.count + 1};
		});
	}

	return (
		<div onClick={increment}>
			Count: {obj ? obj.count : "Loading..." :}
		</div>
	);
}
```

The state object will initially be `undefined` until the data at the specified path has been fetched.

The Realtime Database and state variable will stay synchronized. Any changes made to the state variable or the Firebase Realtime Database will reflect in the other automatically.

### Limitations

- ⚠️ **There must already be data in the Firebase Realtime Database at the given path to initialise correctly.** Without data, the state will remain as `undefined` permanently.
- State updates must be done using functional state updates (e.g., `setObj((prev) => {...})`).

## Licence

[Apache License 2.0](LICENSE)
npm package: @jcbyte/tts-queue
Description: A lightweight wrapper for the Web Speech API's SpeechSynthesis, enabling easy queuing and management of text-to-speech utterances.
Author: Joel Cutler
Latest version: 1.0.1

# tts-queue

A lightweight wrapper for the Web Speech API's SpeechSynthesis, enabling easy queuing and management of text-to-speech utterances.

## Installation

```bash
npm i @jcbyte/tts-queue
```

## Usage

### Basic Usage

```ts
import { TTS, TTSManager } from "@jcbyte/tts-queue";

// Create a new TTS instance
const tts = new TTS("Hello, this is a test of the TTS queue.");

// Optional: Set lifecycle callbacks
tts.onQueued = () => console.log("TTS instance queued");
tts.onPlaying = () => console.log("TTS instance started playing");
tts.onPaused = () => console.log("TTS instance paused");
tts.onResumed = () => console.log("TTS instance resumed");
tts.onCompleted = () => console.log("TTS instance completed");
tts.onCancelled = () => console.log("TTS instance cancelled");

// Enqueue the TTS instance to start playback
TTSManager.enqueue(tts);

// ...

// Access the current state of the TTS instance ("idle", "queued", "playing", etc.)
console.log(tts.state);
```

### Managing Playback

```ts
// Pause the currently playing TTS instance
TTSManager.pause();

// Resume the paused TTS instance
TTSManager.resume();

// Cancel a specific TTS instance (e.g., the one created above)
TTSManager.cancel(tts);

// Cancel all TTS instances in the queue and stop playback immediately
TTSManager.cancelAll();
```

### Global Configuration

You can set or update the global utterance configuration (e.g., language, pitch, rate, voice, volume) that will be applied to all newly created TTS instances:

```ts
TTSManager.updateConfig({
	lang: "en-US",
	pitch: 1.2,
	rate: 1,
	volume: 0.8,
	// voice: SpeechSynthesisVoice
});
```

All future TTS instances created will use these settings unless overridden individually.

You can access the underlying `SpeechSynthesisUtterance` if you need low-level control via `tts.utterance`.

### Creating Multiple TTS instances

```ts
const first = new TTS("This is the first sentence.");
const second = new TTS("And this is the second sentence.");

// Enqueue them; they will play sequentially
TTSManager.enqueue(first);
TTSManager.enqueue(second);
```

## Licence

[Apache License 2.0](LICENSE)