# [LiveDigital](https://livedigital.space/) SDK
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://choosealicense.com/licenses/mit/) [![npm version](https://img.shields.io/npm/v/@livedigital/client.svg?style=flat)](https://www.npmjs.com/package/@livedigital/client) ![release](https://github.com/vlprojects/livedigital-sdk/actions/workflows/release.yml/badge.svg)

## Installation

Use the package manager [npm](https://pip.pypa.io/en/stable/) or [yarn](https://yarnpkg.com/) to install livedigital-client.

```bash
yarn add @livedigital/client
```

## Usage

```
import Client from '@livedigital/client';

const client = new Client();
```

## Plugins
Now you can use the noise reduction and virtual backgrounds functionality. To do this, copy all the files from the
/files directory to the root directory of your project. Or your can specify the path in Client param staticFilesPath
And add tsvb-web.js scripts to your index.html
```
<script src="%PUBLIC_URL%/esdk/3.5.8/tsvb-web.js"></script>
```

## Development
### Submodules

To pull submodules required for the library build, use these commands:

```shell
git pull --recurse-submodules
git submodule update --init --recursive
```

### Public API And Docs

The SDK has a single public entrypoint: `src/index.ts`.

Everything around the public API is built from that file:

- package runtime bundle is built from `src/index.ts`
- published TypeScript types end up in `dist/index.d.ts`
- API Extractor validates that contract and stores the tracked baseline in `api/public-contract.api.md`
- TypeDoc generates Docusaurus-compatible markdown into `generated-docs/api`

### API Commands

```bash
yarn build
yarn api:check
yarn api:update
yarn docs:api
yarn docs:sync
```

- `yarn build` performs the full package build and refreshes `dist`, including `dist/index.d.ts`.
- `yarn api:check` reads `dist/index.d.ts` and checks that the public TypeScript contract still matches `api/public-contract.api.md`.
- `yarn api:update` updates `api/public-contract.api.md` after an intentional public API change.
- `yarn docs:api` runs TypeDoc against `src/index.ts` and regenerates markdown files in `generated-docs/api`.
- `yarn docs:sync` runs the full public API refresh flow: build, API contract update, and TypeDoc generation.

### How It Fits Together

`api/public-contract.api.md` is not user-facing documentation. It is a tracked contract snapshot used by API Extractor for CI checks and PR diffs.

`generated-docs/api` is the user-facing reference output for Docusaurus. It is generated by TypeDoc directly from `src/index.ts` and does not read `api/public-contract.api.md`.

Typical flow when the public API changes:

1. Update exports or public signatures reachable from `src/index.ts`.
2. Run `yarn build` to refresh `dist/index.d.ts`.
3. Run `yarn api:update` to accept the new public contract.
4. Run `yarn docs:api` to regenerate markdown reference docs.
5. Commit the code changes together with `api/public-contract.api.md`.

## Debugging

### Log Levels

LiveDigital client uses the [debug](https://www.npmjs.com/package/debug) module to log to the browser console.

There are three log severities:

- **debug**: verbose information logged to console.info
- **warn**: warning messages logged to console.warn
- **error**: error messages logged to console.error

All the logs generated by LiveDigital client have a namespace starting with “LiveDigital”
plus colon, followed by the log severity in upper case plus colon (just if “warn” or “error”),
and followed by the internal component name (if any) and the log message.

### Enable Logging

By default, logging is turned off. In order to enable it, the debug key in the browser's
localStorage must be set.
>Check the [debug](https://www.npmjs.com/package/debug) module documentation for further information regarding how to filter specific log messages based on namespace matching rules.

### Example

Within the <head> section of your HTML app:
```
<script>
  window.localStorage.setItem('debug', 'LiveDigital:*');
</script>

<script src='/js/your-bundled-app.js'></script>
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License

[MIT](https://choosealicense.com/licenses/mit/)
