|
1 | | -# buttplug-wasm |
| 1 | +# Buttplug WASM Packages |
2 | 2 |
|
3 | | -Buttplug WASM connector for running an embedded Buttplug server directly in the browser via WebAssembly and Web Bluetooth. |
| 3 | +This workspace contains the npm packages for running a Buttplug server in the browser via WebAssembly. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +## Packages |
| 6 | + |
| 7 | +| Package | Description | |
| 8 | +|---------|-------------| |
| 9 | +| [`buttplug-wasm-blob`](packages/blob/) | WASM server binary + typed FFI wrapper. Use this if you're building your own connector for a third-party buttplug client library. | |
| 10 | +| [`buttplug-wasm`](packages/connector/) | Ready-made connector for the official [`buttplug`](https://www.npmjs.com/package/buttplug) JS client library. | |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +If you're using the official buttplug JS client: |
6 | 15 |
|
7 | 16 | ```bash |
8 | 17 | npm install buttplug-wasm buttplug |
9 | 18 | ``` |
10 | 19 |
|
11 | | -## Usage |
12 | | - |
13 | 20 | ```typescript |
14 | 21 | import { ButtplugClient } from 'buttplug'; |
15 | 22 | import { ButtplugWasmClientConnector } from 'buttplug-wasm'; |
16 | 23 |
|
17 | | -// Optional: enable debug logging |
18 | | -await ButtplugWasmClientConnector.activateLogging("debug"); |
19 | | - |
20 | 24 | const connector = new ButtplugWasmClientConnector(); |
21 | 25 | const client = new ButtplugClient("My App"); |
22 | | - |
23 | 26 | await client.connect(connector); |
24 | | -await client.startScanning(); |
25 | | - |
26 | | -client.on("deviceadded", (device) => { |
27 | | - console.log(`Device connected: ${device.Name}`); |
28 | | -}); |
29 | 27 | ``` |
30 | 28 |
|
31 | | -## How it works |
| 29 | +## Building |
32 | 30 |
|
33 | | -This package bundles a full Buttplug server compiled to WebAssembly. When you create a `ButtplugWasmClientConnector`, it: |
34 | | - |
35 | | -1. Loads and initializes the WASM module (lazy, on first `connect()`) |
36 | | -2. Creates an embedded Buttplug server instance |
37 | | -3. Communicates with the server via JSON message passing over the WASM boundary |
38 | | -4. Uses Web Bluetooth for device discovery and communication |
39 | | - |
40 | | -No external server process needed — everything runs in-browser. |
41 | | - |
42 | | -## Requirements |
43 | | - |
44 | | -- A browser with Web Bluetooth support (Chrome, Edge, Opera) |
45 | | -- HTTPS context (Web Bluetooth requires secure origins) |
46 | | -- The `buttplug` npm package (peer dependency for `ButtplugClient`) |
| 31 | +```bash |
| 32 | +npm install |
| 33 | +npm run build # builds wasm-pack + both packages |
| 34 | +``` |
47 | 35 |
|
48 | 36 | ## License |
49 | 37 |
|
|
0 commit comments