# Client.js

`Client.js` is a [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript) library for implementing cross-browser BIM Project management applications. `Client.js` provides the following benefits:

- easy access to the server resources like Projects, Files, Issues etc
- integration of the [VisualizeJS](https://cloud.opendesign.com/docs/index.html#/visualizejs) library with the [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server)
- convenient API to open BIM files from the server for rendering and data management
- optimizations and improvements of the quality of rendering BIM files

## Table of contents

- [Installation](#installation)
- [Example](#example)
- [Copyright and license](#copyright-and-license)

## Installation

### Install via [npm](https://npmjs.org)

Open a terminal in your project folder and run:

```sh
npm install open-cloud-cllient
```

The `Client.js` package will be downloaded and installed. Then you're ready to import it in your code, see [example](#example) below.

### CDN or static hosting

Declare your script, and then use `ODA` object as shown below.

```javascript
<script src="https://opencloud.azureedge.net/libs/clientjs/24.12/client.min.js"></script>

<script>
  const client = new ODA.Client();

  // place your code here (see example below)
</script>
```

## Example

Download and render a drawing file from the `Open Cloud Server`:

```javascript
// create instance of the Client class for working with server
const client = new ODA.Client({ serverUrl: "https://cloud.opendesign.com/api" });

// create instance of Viewer class for rendering drawing files
const viewer = new ODA.Viewer(client);

// initialize Viewer it with the specified <canvas> element
await viewer.initialize(canvas);

// login to the server
await client.signInWithEmail("email", "password");

// get file list from the server
const files = await client.getFiles();

// open the first file in the list
await viewer.open(files.result[0]);
```

To learn more, see [First application guide](https://cloud.opendesign.com/docs/index.html#/guide).

## Copyright and license

Code and documentation copyright 2002-2023 the [Open Design Alliance](https://opendesign.com). Code is distributed under a proprietary license, see `LICENSE` for more information.
