jacdac-ts/DOCS.md

45 строки
1.1 KiB
Markdown
Исходник Обычный вид История

2021-08-23 17:24:04 +03:00
# JavaScript/TypeScript package
2021-10-28 01:55:41 +03:00
This package allows you to integrate Jacdac into web applications or Node.JS projects.
The package exposes **JDOM**, a dependency-free JavaScript object model
that reflects the state of the Jacdac elements and allows sending commands as well.
2021-08-25 19:11:29 +03:00
JDOM also handles connection through WebUSB, WebBLE and other transports.
2021-08-23 17:24:04 +03:00
2021-08-25 19:11:29 +03:00
To read guides and overview documents about JDOM, go to [JDOM documentation](https://microsoft.github.io/jacdac-docs/clients/javascript/jdom).
2021-08-23 17:24:04 +03:00
2021-08-25 19:11:29 +03:00
To browser the API documentation, use the list on this page to explore classes.
2021-08-23 17:24:04 +03:00
## Installation
2021-10-28 01:55:41 +03:00
Add the [jacdac-ts npm package](https://www.npmjs.com/package/jacdac-ts) module
2021-08-23 17:24:04 +03:00
to your project
```
npm install --save jacdac-ts
```
2021-10-28 01:55:41 +03:00
2021-08-23 17:24:04 +03:00
or
2021-10-28 01:55:41 +03:00
2021-08-23 17:24:04 +03:00
```
yarn add jacdac-ts
```
then import components as needed using ES6 import syntax
```javascript
import { createWebBus } from "jacdac-ts"
2021-10-28 01:55:41 +03:00
2021-10-14 20:49:31 +03:00
const bus = createWebBus()
2021-08-23 17:24:04 +03:00
```
### CDN / UMD
2021-10-28 01:55:41 +03:00
You can also use CDN services to import `jacdac` into your html page directly.
2021-08-23 17:24:04 +03:00
This will load the ES6 build of the library.
```html
<script src="https://unpkg.com/jacdac-ts@VERSION/dist/jacdac.js"></script>
```
2021-10-28 01:55:41 +03:00
where `@VERSION` is the desired version.