buttplug 3.2.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +25 -25
- package/.jscsrc +2 -2
- package/.jshintrc +5 -5
- package/.prettierrc.json +3 -3
- package/.yarnrc.yml +5 -5
- package/CHANGELOG.md +591 -577
- package/LICENSE +27 -27
- package/README.md +105 -97
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +6 -9
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/client/{Client.d.ts → ButtplugClient.d.ts} +3 -4
- package/dist/main/src/client/ButtplugClient.js +232 -0
- package/dist/main/src/client/ButtplugClient.js.map +1 -0
- package/dist/main/src/client/ButtplugClientConnectorException.js +17 -7
- package/dist/main/src/client/ButtplugClientConnectorException.js.map +1 -1
- package/dist/main/src/client/ButtplugClientDevice.d.ts +13 -28
- package/dist/main/src/client/ButtplugClientDevice.js +105 -247
- package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
- package/dist/main/src/client/ButtplugClientDeviceCommand.d.ts +42 -0
- package/dist/main/src/client/ButtplugClientDeviceCommand.js +105 -0
- package/dist/main/src/client/ButtplugClientDeviceCommand.js.map +1 -0
- package/dist/main/src/client/ButtplugClientDeviceFeature.d.ts +18 -0
- package/dist/main/src/client/ButtplugClientDeviceFeature.js +166 -0
- package/dist/main/src/client/ButtplugClientDeviceFeature.js.map +1 -0
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +1 -8
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +1 -4
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/core/Exceptions.js +27 -9
- package/dist/main/src/core/Exceptions.js.map +1 -1
- package/dist/main/src/core/Logging.js +12 -6
- package/dist/main/src/core/Logging.js.map +1 -1
- package/dist/main/src/core/Messages.d.ts +119 -230
- package/dist/main/src/core/Messages.js +50 -404
- package/dist/main/src/core/Messages.js.map +1 -1
- package/dist/main/src/index.d.ts +2 -2
- package/dist/main/src/index.js +4 -2
- package/dist/main/src/index.js.map +1 -1
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +40 -52
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
- package/dist/main/src/utils/ButtplugMessageSorter.js +27 -15
- package/dist/main/src/utils/ButtplugMessageSorter.js.map +1 -1
- package/dist/main/src/utils/Utils.js +1 -2
- package/dist/main/src/utils/Utils.js.map +1 -1
- package/dist/web/buttplug.js +1 -38
- package/dist/web/buttplug.mjs +595 -1984
- package/dist/web/client/ButtplugBrowserWebsocketClientConnector.d.ts +0 -7
- package/dist/web/client/{Client.d.ts → ButtplugClient.d.ts} +3 -11
- package/dist/web/client/ButtplugClientConnectorException.d.ts +0 -7
- package/dist/web/client/ButtplugClientDevice.d.ts +14 -29
- package/dist/web/client/ButtplugClientDeviceCommand.d.ts +42 -0
- package/dist/web/client/ButtplugClientDeviceFeature.d.ts +18 -0
- package/dist/web/client/ButtplugNodeWebsocketClientConnector.d.ts +1 -15
- package/dist/web/client/IButtplugClientConnector.d.ts +0 -7
- package/dist/web/core/Exceptions.d.ts +1 -1
- package/dist/web/core/Logging.d.ts +0 -7
- package/dist/web/core/Messages.d.ts +119 -229
- package/dist/web/index.d.ts +2 -2
- package/dist/web/utils/ButtplugBrowserWebsocketConnector.d.ts +0 -7
- package/examples/node/SYNC_MANIFEST.md +105 -0
- package/examples/node/application-example.ts +213 -0
- package/examples/node/async-example.ts +124 -0
- package/examples/node/connection-example.ts +76 -0
- package/examples/node/device-control-example.ts +131 -0
- package/examples/node/device-enumeration-example.ts +86 -0
- package/examples/node/device-info-example.ts +131 -0
- package/examples/node/errors-example.ts +166 -0
- package/examples/node/package-lock.json +281 -0
- package/examples/node/package.json +25 -0
- package/examples/node/remote-connector-example.ts +84 -0
- package/examples/node/tsconfig.json +14 -0
- package/examples/web/application-example.js +197 -0
- package/examples/web/async-example.js +90 -0
- package/examples/web/device-control-example.js +87 -0
- package/examples/web/device-enumeration-example.js +49 -0
- package/examples/web/device-info-example.js +100 -0
- package/examples/web/errors-example.js +110 -0
- package/examples/web/index.html +55 -0
- package/examples/web/logging.js +42 -0
- package/examples/web/ping-timeout-example.js +59 -0
- package/examples/web/remote-connector-example.js +68 -0
- package/node-test.js +24 -0
- package/node-test.ts +23 -5
- package/package.json +85 -87
- package/src/client/ButtplugBrowserWebsocketClientConnector.ts +25 -25
- package/src/client/ButtplugClient.ts +242 -0
- package/src/client/ButtplugClientConnectorException.ts +16 -16
- package/src/client/ButtplugClientDevice.ts +178 -401
- package/src/client/ButtplugClientDeviceCommand.ts +112 -0
- package/src/client/ButtplugClientDeviceFeature.ts +138 -0
- package/src/client/ButtplugNodeWebsocketClientConnector.ts +17 -17
- package/src/client/IButtplugClientConnector.ts +18 -18
- package/src/core/Exceptions.ts +107 -101
- package/src/core/Logging.ts +197 -197
- package/src/core/Messages.ts +205 -480
- package/src/core/index.d.ts +4 -4
- package/src/index.ts +21 -19
- package/src/utils/ButtplugBrowserWebsocketConnector.ts +89 -89
- package/src/utils/ButtplugMessageSorter.ts +66 -65
- package/src/utils/Utils.ts +3 -3
- package/tsconfig.json +22 -22
- package/tsfmt.json +14 -14
- package/tslint.json +27 -27
- package/typedocconfig.js +6 -6
- package/vite.config.ts +26 -26
- package/dist/main/src/client/Client.js +0 -242
- package/dist/main/src/client/Client.js.map +0 -1
- package/dist/main/src/core/MessageUtils.d.ts +0 -10
- package/dist/main/src/core/MessageUtils.js +0 -65
- package/dist/main/src/core/MessageUtils.js.map +0 -1
- package/dist/web/core/MessageUtils.d.ts +0 -10
- package/doc/.nojekyll +0 -1
- package/doc/assets/highlight.css +0 -22
- package/doc/assets/main.js +0 -58
- package/doc/assets/search.js +0 -1
- package/doc/assets/style.css +0 -1280
- package/doc/classes/ButtplugBrowserWebsocketClientConnector.html +0 -234
- package/doc/classes/ButtplugClient.html +0 -331
- package/doc/classes/ButtplugClientConnectorException.html +0 -216
- package/doc/classes/ButtplugClientDevice.html +0 -489
- package/doc/classes/ButtplugDeviceError.html +0 -218
- package/doc/classes/ButtplugDeviceMessage.html +0 -165
- package/doc/classes/ButtplugError.html +0 -220
- package/doc/classes/ButtplugInitError.html +0 -218
- package/doc/classes/ButtplugLogger.html +0 -288
- package/doc/classes/ButtplugMessage.html +0 -147
- package/doc/classes/ButtplugMessageError.html +0 -218
- package/doc/classes/ButtplugMessageSorter.html +0 -128
- package/doc/classes/ButtplugNodeWebsocketClientConnector.html +0 -239
- package/doc/classes/ButtplugPingError.html +0 -218
- package/doc/classes/ButtplugSystemMessage.html +0 -150
- package/doc/classes/ButtplugUnknownError.html +0 -218
- package/doc/classes/DeviceAdded.html +0 -186
- package/doc/classes/DeviceInfo.html +0 -114
- package/doc/classes/DeviceList.html +0 -160
- package/doc/classes/DeviceRemoved.html +0 -158
- package/doc/classes/Error.html +0 -179
- package/doc/classes/GenericDeviceMessageAttributes.html +0 -107
- package/doc/classes/GenericMessageSubcommand.html +0 -90
- package/doc/classes/LinearCmd.html +0 -187
- package/doc/classes/LogMessage.html +0 -134
- package/doc/classes/MessageAttributes.html +0 -160
- package/doc/classes/Ok.html +0 -151
- package/doc/classes/Ping.html +0 -151
- package/doc/classes/RawDeviceMessageAttributes.html +0 -86
- package/doc/classes/RawReadCmd.html +0 -188
- package/doc/classes/RawReading.html +0 -179
- package/doc/classes/RawSubscribeCmd.html +0 -170
- package/doc/classes/RawUnsubscribeCmd.html +0 -170
- package/doc/classes/RawWriteCmd.html +0 -188
- package/doc/classes/RequestDeviceList.html +0 -151
- package/doc/classes/RequestServerInfo.html +0 -169
- package/doc/classes/RotateCmd.html +0 -187
- package/doc/classes/RotateSubcommand.html +0 -108
- package/doc/classes/ScalarCmd.html +0 -170
- package/doc/classes/ScalarSubcommand.html +0 -108
- package/doc/classes/ScanningFinished.html +0 -146
- package/doc/classes/SensorDeviceMessageAttributes.html +0 -107
- package/doc/classes/SensorReadCmd.html +0 -179
- package/doc/classes/SensorReading.html +0 -188
- package/doc/classes/ServerInfo.html +0 -178
- package/doc/classes/StartScanning.html +0 -151
- package/doc/classes/StopAllDevices.html +0 -151
- package/doc/classes/StopDeviceCmd.html +0 -161
- package/doc/classes/StopScanning.html +0 -151
- package/doc/classes/VectorSubcommand.html +0 -108
- package/doc/enums/ActuatorType.html +0 -104
- package/doc/enums/ButtplugLogLevel.html +0 -97
- package/doc/enums/ErrorClass.html +0 -90
- package/doc/enums/SensorType.html +0 -90
- package/doc/functions/FromJSON.html +0 -113
- package/doc/index.html +0 -184
- package/doc/interfaces/IButtplugClientConnector.html +0 -137
- package/doc/modules.html +0 -176
- package/doc/variables/DEFAULT_MESSAGE_ID.html +0 -104
- package/doc/variables/MAX_ID.html +0 -104
- package/doc/variables/MESSAGE_SPEC_VERSION.html +0 -104
- package/doc/variables/SYSTEM_MESSAGE_ID.html +0 -104
- package/src/client/Client.ts +0 -276
- package/src/core/MessageUtils.ts +0 -48
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
1
|
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
9
2
|
import { ButtplugMessage } from '../core/Messages';
|
|
10
3
|
import { ButtplugBrowserWebsocketConnector } from '../utils/ButtplugBrowserWebsocketConnector';
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
|
-
/// <reference types="node" />
|
|
9
1
|
import { ButtplugLogger } from '../core/Logging';
|
|
10
2
|
import { EventEmitter } from 'eventemitter3';
|
|
11
3
|
import { ButtplugClientDevice } from './ButtplugClientDevice';
|
|
@@ -21,21 +13,21 @@ export declare class ButtplugClient extends EventEmitter {
|
|
|
21
13
|
private _sorter;
|
|
22
14
|
constructor(clientName?: string);
|
|
23
15
|
get connected(): boolean;
|
|
24
|
-
get devices(): ButtplugClientDevice
|
|
16
|
+
get devices(): Map<number, ButtplugClientDevice>;
|
|
25
17
|
get isScanning(): boolean;
|
|
26
18
|
connect: (connector: IButtplugClientConnector) => Promise<void>;
|
|
27
19
|
disconnect: () => Promise<void>;
|
|
28
20
|
startScanning: () => Promise<void>;
|
|
29
21
|
stopScanning: () => Promise<void>;
|
|
30
22
|
stopAllDevices: () => Promise<void>;
|
|
31
|
-
private sendDeviceMessage;
|
|
32
23
|
protected disconnectHandler: () => void;
|
|
33
24
|
protected parseMessages: (msgs: Messages.ButtplugMessage[]) => void;
|
|
34
25
|
protected initializeConnection: () => Promise<boolean>;
|
|
26
|
+
private parseDeviceList;
|
|
35
27
|
protected requestDeviceList: () => Promise<void>;
|
|
36
28
|
protected shutdownConnection: () => Promise<void>;
|
|
37
29
|
protected sendMessage(msg: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage>;
|
|
38
30
|
protected checkConnector(): void;
|
|
39
31
|
protected sendMsgExpectOk: (msg: Messages.ButtplugMessage) => Promise<void>;
|
|
40
|
-
protected
|
|
32
|
+
protected sendMessageClosure: (msg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>;
|
|
41
33
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
1
|
import { ButtplugError } from '../core/Exceptions';
|
|
9
2
|
export declare class ButtplugClientConnectorException extends ButtplugError {
|
|
10
3
|
constructor(message: string);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { ButtplugClientDeviceFeature } from './ButtplugClientDeviceFeature';
|
|
3
|
+
import { DeviceOutputCommand } from './ButtplugClientDeviceCommand';
|
|
1
4
|
/*!
|
|
2
5
|
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
6
|
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
@@ -6,13 +9,13 @@
|
|
|
6
9
|
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
10
|
*/
|
|
8
11
|
import * as Messages from '../core/Messages';
|
|
9
|
-
import { EventEmitter } from 'eventemitter3';
|
|
10
12
|
/**
|
|
11
13
|
* Represents an abstract device, capable of taking certain kinds of messages.
|
|
12
14
|
*/
|
|
13
15
|
export declare class ButtplugClientDevice extends EventEmitter {
|
|
14
16
|
private _deviceInfo;
|
|
15
17
|
private _sendClosure;
|
|
18
|
+
private _features;
|
|
16
19
|
/**
|
|
17
20
|
* Return the name of the device.
|
|
18
21
|
*/
|
|
@@ -29,39 +32,21 @@ export declare class ButtplugClientDevice extends EventEmitter {
|
|
|
29
32
|
* Return the index of the device.
|
|
30
33
|
*/
|
|
31
34
|
get messageTimingGap(): number | undefined;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
get messageAttributes(): Messages.MessageAttributes;
|
|
36
|
-
static fromMsg(msg: Messages.DeviceInfo, sendClosure: (device: ButtplugClientDevice, msg: Messages.ButtplugDeviceMessage) => Promise<Messages.ButtplugMessage>): ButtplugClientDevice;
|
|
37
|
-
private allowedMsgs;
|
|
35
|
+
get features(): Map<number, ButtplugClientDeviceFeature>;
|
|
36
|
+
static fromMsg(msg: Messages.DeviceInfo, sendClosure: (msg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>): ButtplugClientDevice;
|
|
38
37
|
/**
|
|
39
38
|
* @param _index Index of the device, as created by the device manager.
|
|
40
39
|
* @param _name Name of the device.
|
|
41
40
|
* @param allowedMsgs Buttplug messages the device can receive.
|
|
42
41
|
*/
|
|
43
|
-
constructor(
|
|
44
|
-
send(msg: Messages.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
get oscillateAttributes(): Messages.GenericDeviceMessageAttributes[];
|
|
51
|
-
oscillate(speed: number | number[]): Promise<void>;
|
|
52
|
-
get rotateAttributes(): Messages.GenericDeviceMessageAttributes[];
|
|
53
|
-
rotate(values: number | [number, boolean][], clockwise?: boolean): Promise<void>;
|
|
54
|
-
get linearAttributes(): Messages.GenericDeviceMessageAttributes[];
|
|
55
|
-
linear(values: number | [number, number][], duration?: number): Promise<void>;
|
|
56
|
-
sensorRead(sensorIndex: number, sensorType: Messages.SensorType): Promise<number[]>;
|
|
57
|
-
get hasBattery(): boolean;
|
|
58
|
-
battery(): Promise<number>;
|
|
59
|
-
get hasRssi(): boolean;
|
|
60
|
-
rssi(): Promise<number>;
|
|
61
|
-
rawRead(endpoint: string, expectedLength: number, timeout: number): Promise<Uint8Array>;
|
|
62
|
-
rawWrite(endpoint: string, data: Uint8Array, writeWithResponse: boolean): Promise<void>;
|
|
63
|
-
rawSubscribe(endpoint: string): Promise<void>;
|
|
64
|
-
rawUnsubscribe(endpoint: string): Promise<void>;
|
|
42
|
+
private constructor();
|
|
43
|
+
send(msg: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage>;
|
|
44
|
+
protected sendMsgExpectOk: (msg: Messages.ButtplugMessage) => Promise<void>;
|
|
45
|
+
protected isOutputValid(featureIndex: number, type: Messages.OutputType): void;
|
|
46
|
+
hasOutput(type: Messages.OutputType): boolean;
|
|
47
|
+
hasInput(type: Messages.InputType): boolean;
|
|
48
|
+
runOutput(cmd: DeviceOutputCommand): Promise<void>;
|
|
65
49
|
stop(): Promise<void>;
|
|
50
|
+
battery(): Promise<number>;
|
|
66
51
|
emitDisconnected(): void;
|
|
67
52
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OutputType } from '../core/Messages';
|
|
2
|
+
declare class PercentOrSteps {
|
|
3
|
+
private _percent;
|
|
4
|
+
private _steps;
|
|
5
|
+
get percent(): number | undefined;
|
|
6
|
+
get steps(): number | undefined;
|
|
7
|
+
static createSteps(s: number): PercentOrSteps;
|
|
8
|
+
static createPercent(p: number): PercentOrSteps;
|
|
9
|
+
}
|
|
10
|
+
export declare class DeviceOutputCommand {
|
|
11
|
+
private _outputType;
|
|
12
|
+
private _value;
|
|
13
|
+
private _duration?;
|
|
14
|
+
constructor(_outputType: OutputType, _value: PercentOrSteps, _duration?: number | undefined);
|
|
15
|
+
get outputType(): OutputType;
|
|
16
|
+
get value(): PercentOrSteps;
|
|
17
|
+
get duration(): number | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare class DeviceOutputValueConstructor {
|
|
20
|
+
private _outputType;
|
|
21
|
+
constructor(_outputType: OutputType);
|
|
22
|
+
steps(steps: number): DeviceOutputCommand;
|
|
23
|
+
percent(percent: number): DeviceOutputCommand;
|
|
24
|
+
}
|
|
25
|
+
export declare class DeviceOutputPositionWithDurationConstructor {
|
|
26
|
+
steps(steps: number, duration: number): DeviceOutputCommand;
|
|
27
|
+
percent(percent: number, duration: number): DeviceOutputCommand;
|
|
28
|
+
}
|
|
29
|
+
export declare class DeviceOutput {
|
|
30
|
+
private constructor();
|
|
31
|
+
static get Vibrate(): DeviceOutputValueConstructor;
|
|
32
|
+
static get Rotate(): DeviceOutputValueConstructor;
|
|
33
|
+
static get Oscillate(): DeviceOutputValueConstructor;
|
|
34
|
+
static get Constrict(): DeviceOutputValueConstructor;
|
|
35
|
+
static get Inflate(): DeviceOutputValueConstructor;
|
|
36
|
+
static get Temperature(): DeviceOutputValueConstructor;
|
|
37
|
+
static get Led(): DeviceOutputValueConstructor;
|
|
38
|
+
static get Spray(): DeviceOutputValueConstructor;
|
|
39
|
+
static get Position(): DeviceOutputValueConstructor;
|
|
40
|
+
static get PositionWithDuration(): DeviceOutputPositionWithDurationConstructor;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DeviceOutputCommand } from './ButtplugClientDeviceCommand';
|
|
2
|
+
import * as Messages from "../core/Messages";
|
|
3
|
+
export declare class ButtplugClientDeviceFeature {
|
|
4
|
+
private _deviceIndex;
|
|
5
|
+
private _deviceName;
|
|
6
|
+
private _feature;
|
|
7
|
+
private _sendClosure;
|
|
8
|
+
constructor(_deviceIndex: number, _deviceName: string, _feature: Messages.DeviceFeature, _sendClosure: (msg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>);
|
|
9
|
+
protected send: (msg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>;
|
|
10
|
+
protected sendMsgExpectOk: (msg: Messages.ButtplugMessage) => Promise<void>;
|
|
11
|
+
protected isOutputValid(type: Messages.OutputType): void;
|
|
12
|
+
protected isInputValid(type: Messages.InputType): void;
|
|
13
|
+
protected sendOutputCmd(command: DeviceOutputCommand): Promise<void>;
|
|
14
|
+
hasOutput(type: Messages.OutputType): boolean;
|
|
15
|
+
hasInput(type: Messages.InputType): boolean;
|
|
16
|
+
runOutput(cmd: DeviceOutputCommand): Promise<void>;
|
|
17
|
+
runInput(inputType: Messages.InputType, inputCommand: Messages.InputCommandType): Promise<Messages.InputReading | undefined>;
|
|
18
|
+
}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
1
|
import { ButtplugBrowserWebsocketClientConnector } from './ButtplugBrowserWebsocketClientConnector';
|
|
9
2
|
export declare class ButtplugNodeWebsocketClientConnector extends ButtplugBrowserWebsocketClientConnector {
|
|
10
|
-
protected _websocketConstructor:
|
|
11
|
-
new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
|
|
12
|
-
prototype: WebSocket;
|
|
13
|
-
readonly CONNECTING: 0;
|
|
14
|
-
readonly OPEN: 1;
|
|
15
|
-
readonly CLOSING: 2;
|
|
16
|
-
readonly CLOSED: 3;
|
|
17
|
-
};
|
|
3
|
+
protected _websocketConstructor: typeof WebSocket;
|
|
18
4
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
1
|
import { ButtplugMessage } from '../core/Messages';
|
|
9
2
|
import { EventEmitter } from 'eventemitter3';
|
|
10
3
|
export interface IButtplugClientConnector extends EventEmitter {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ButtplugLogger } from './Logging';
|
|
1
2
|
/*!
|
|
2
3
|
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
4
|
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
@@ -6,7 +7,6 @@
|
|
|
6
7
|
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
8
|
*/
|
|
8
9
|
import * as Messages from './Messages';
|
|
9
|
-
import { ButtplugLogger } from './Logging';
|
|
10
10
|
export declare class ButtplugError extends Error {
|
|
11
11
|
get ErrorClass(): Messages.ErrorClass;
|
|
12
12
|
get InnerError(): Error | undefined;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
1
|
import { EventEmitter } from 'eventemitter3';
|
|
9
2
|
export declare enum ButtplugLogLevel {
|
|
10
3
|
Off = 0,
|
|
@@ -8,80 +8,31 @@
|
|
|
8
8
|
export declare const SYSTEM_MESSAGE_ID = 0;
|
|
9
9
|
export declare const DEFAULT_MESSAGE_ID = 1;
|
|
10
10
|
export declare const MAX_ID = 4294967295;
|
|
11
|
-
export declare const
|
|
12
|
-
export declare
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
Battery = "Battery",
|
|
37
|
-
RSSI = "RSSI",
|
|
38
|
-
Button = "Button",
|
|
39
|
-
Pressure = "Pressure"
|
|
40
|
-
}
|
|
41
|
-
export declare class GenericDeviceMessageAttributes {
|
|
42
|
-
FeatureDescriptor: string;
|
|
43
|
-
ActuatorType: ActuatorType;
|
|
44
|
-
StepCount: number;
|
|
45
|
-
Index: number;
|
|
46
|
-
constructor(data: Partial<GenericDeviceMessageAttributes>);
|
|
47
|
-
}
|
|
48
|
-
export declare class RawDeviceMessageAttributes {
|
|
49
|
-
Endpoints: Array<string>;
|
|
50
|
-
constructor(Endpoints: Array<string>);
|
|
51
|
-
}
|
|
52
|
-
export declare class SensorDeviceMessageAttributes {
|
|
53
|
-
FeatureDescriptor: string;
|
|
54
|
-
SensorType: SensorType;
|
|
55
|
-
StepRange: Array<number>;
|
|
56
|
-
Index: number;
|
|
57
|
-
constructor(data: Partial<GenericDeviceMessageAttributes>);
|
|
58
|
-
}
|
|
59
|
-
export declare abstract class ButtplugMessage {
|
|
60
|
-
Id: number;
|
|
61
|
-
constructor(Id: number);
|
|
62
|
-
get Type(): Function;
|
|
63
|
-
toJSON(): string;
|
|
64
|
-
toProtocolFormat(): object;
|
|
65
|
-
update(): void;
|
|
66
|
-
}
|
|
67
|
-
export declare abstract class ButtplugDeviceMessage extends ButtplugMessage {
|
|
68
|
-
DeviceIndex: number;
|
|
69
|
-
Id: number;
|
|
70
|
-
constructor(DeviceIndex: number, Id: number);
|
|
71
|
-
}
|
|
72
|
-
export declare abstract class ButtplugSystemMessage extends ButtplugMessage {
|
|
73
|
-
Id: number;
|
|
74
|
-
constructor(Id?: number);
|
|
75
|
-
}
|
|
76
|
-
export declare class Ok extends ButtplugSystemMessage {
|
|
77
|
-
Id: number;
|
|
78
|
-
static Name: string;
|
|
79
|
-
constructor(Id?: number);
|
|
80
|
-
}
|
|
81
|
-
export declare class Ping extends ButtplugMessage {
|
|
82
|
-
Id: number;
|
|
83
|
-
static Name: string;
|
|
84
|
-
constructor(Id?: number);
|
|
11
|
+
export declare const MESSAGE_SPEC_VERSION_MAJOR = 4;
|
|
12
|
+
export declare const MESSAGE_SPEC_VERSION_MINOR = 0;
|
|
13
|
+
export interface ButtplugMessage {
|
|
14
|
+
Ok?: Ok;
|
|
15
|
+
Ping?: Ping;
|
|
16
|
+
Error?: Error;
|
|
17
|
+
RequestServerInfo?: RequestServerInfo;
|
|
18
|
+
ServerInfo?: ServerInfo;
|
|
19
|
+
RequestDeviceList?: RequestDeviceList;
|
|
20
|
+
StartScanning?: StartScanning;
|
|
21
|
+
StopScanning?: StopScanning;
|
|
22
|
+
ScanningFinished?: ScanningFinished;
|
|
23
|
+
StopCmd?: StopCmd;
|
|
24
|
+
InputCmd?: InputCmd;
|
|
25
|
+
InputReading?: InputReading;
|
|
26
|
+
OutputCmd?: OutputCmd;
|
|
27
|
+
DeviceList?: DeviceList;
|
|
28
|
+
}
|
|
29
|
+
export declare function msgId(msg: ButtplugMessage): number;
|
|
30
|
+
export declare function setMsgId(msg: ButtplugMessage, id: number): void;
|
|
31
|
+
export interface Ok {
|
|
32
|
+
Id: number | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface Ping {
|
|
35
|
+
Id: number | undefined;
|
|
85
36
|
}
|
|
86
37
|
export declare enum ErrorClass {
|
|
87
38
|
ERROR_UNKNOWN = 0,
|
|
@@ -90,185 +41,124 @@ export declare enum ErrorClass {
|
|
|
90
41
|
ERROR_MSG = 3,
|
|
91
42
|
ERROR_DEVICE = 4
|
|
92
43
|
}
|
|
93
|
-
export
|
|
44
|
+
export interface Error {
|
|
94
45
|
ErrorMessage: string;
|
|
95
46
|
ErrorCode: ErrorClass;
|
|
96
|
-
Id: number;
|
|
97
|
-
static Name: string;
|
|
98
|
-
constructor(ErrorMessage: string, ErrorCode?: ErrorClass, Id?: number);
|
|
99
|
-
get Schemversion(): number;
|
|
100
|
-
}
|
|
101
|
-
export declare class DeviceInfo {
|
|
102
|
-
DeviceIndex: number;
|
|
103
|
-
DeviceName: string;
|
|
104
|
-
DeviceMessages: MessageAttributes;
|
|
105
|
-
DeviceDisplayName?: string;
|
|
106
|
-
DeviceMessageTimingGap?: number;
|
|
107
|
-
constructor(data: Partial<DeviceInfo>);
|
|
108
|
-
}
|
|
109
|
-
export declare class DeviceList extends ButtplugMessage {
|
|
110
|
-
static Name: string;
|
|
111
|
-
Devices: DeviceInfo[];
|
|
112
|
-
Id: number;
|
|
113
|
-
constructor(devices: DeviceInfo[], id?: number);
|
|
114
|
-
update(): void;
|
|
115
|
-
}
|
|
116
|
-
export declare class DeviceAdded extends ButtplugSystemMessage {
|
|
117
|
-
static Name: string;
|
|
118
|
-
DeviceIndex: number;
|
|
119
|
-
DeviceName: string;
|
|
120
|
-
DeviceMessages: MessageAttributes;
|
|
121
|
-
DeviceDisplayName?: string;
|
|
122
|
-
DeviceMessageTimingGap?: number;
|
|
123
|
-
constructor(data: Partial<DeviceAdded>);
|
|
124
|
-
update(): void;
|
|
125
|
-
}
|
|
126
|
-
export declare class DeviceRemoved extends ButtplugSystemMessage {
|
|
127
|
-
DeviceIndex: number;
|
|
128
|
-
static Name: string;
|
|
129
|
-
constructor(DeviceIndex: number);
|
|
47
|
+
Id: number | undefined;
|
|
130
48
|
}
|
|
131
|
-
export
|
|
132
|
-
Id: number;
|
|
133
|
-
static Name: string;
|
|
134
|
-
constructor(Id?: number);
|
|
49
|
+
export interface RequestDeviceList {
|
|
50
|
+
Id: number | undefined;
|
|
135
51
|
}
|
|
136
|
-
export
|
|
137
|
-
Id: number;
|
|
138
|
-
static Name: string;
|
|
139
|
-
constructor(Id?: number);
|
|
52
|
+
export interface StartScanning {
|
|
53
|
+
Id: number | undefined;
|
|
140
54
|
}
|
|
141
|
-
export
|
|
142
|
-
Id: number;
|
|
143
|
-
static Name: string;
|
|
144
|
-
constructor(Id?: number);
|
|
55
|
+
export interface StopScanning {
|
|
56
|
+
Id: number | undefined;
|
|
145
57
|
}
|
|
146
|
-
export
|
|
147
|
-
|
|
148
|
-
constructor();
|
|
58
|
+
export interface ScanningFinished {
|
|
59
|
+
Id: number | undefined;
|
|
149
60
|
}
|
|
150
|
-
export
|
|
61
|
+
export interface RequestServerInfo {
|
|
151
62
|
ClientName: string;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
constructor(ClientName: string, MessageVersion?: number, Id?: number);
|
|
63
|
+
ProtocolVersionMajor: number;
|
|
64
|
+
ProtocolVersionMinor: number;
|
|
65
|
+
Id: number | undefined;
|
|
156
66
|
}
|
|
157
|
-
export
|
|
158
|
-
MessageVersion: number;
|
|
67
|
+
export interface ServerInfo {
|
|
159
68
|
MaxPingTime: number;
|
|
160
69
|
ServerName: string;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
export declare class StopDeviceCmd extends ButtplugDeviceMessage {
|
|
166
|
-
DeviceIndex: number;
|
|
167
|
-
Id: number;
|
|
168
|
-
static Name: string;
|
|
169
|
-
constructor(DeviceIndex?: number, Id?: number);
|
|
170
|
-
}
|
|
171
|
-
export declare class StopAllDevices extends ButtplugMessage {
|
|
172
|
-
Id: number;
|
|
173
|
-
static Name: string;
|
|
174
|
-
constructor(Id?: number);
|
|
70
|
+
ProtocolVersionMajor: number;
|
|
71
|
+
ProtocolVersionMinor: number;
|
|
72
|
+
Id: number | undefined;
|
|
175
73
|
}
|
|
176
|
-
export
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
74
|
+
export interface DeviceFeature {
|
|
75
|
+
FeatureDescriptor: string;
|
|
76
|
+
Output: {
|
|
77
|
+
[key: string]: DeviceFeatureOutput;
|
|
78
|
+
};
|
|
79
|
+
Input: {
|
|
80
|
+
[key: string]: DeviceFeatureInput;
|
|
81
|
+
};
|
|
82
|
+
FeatureIndex: number;
|
|
83
|
+
}
|
|
84
|
+
export interface DeviceInfo {
|
|
187
85
|
DeviceIndex: number;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Clockwise: boolean;
|
|
195
|
-
constructor(Index: number, Speed: number, Clockwise: boolean);
|
|
86
|
+
DeviceName: string;
|
|
87
|
+
DeviceFeatures: {
|
|
88
|
+
[key: number]: DeviceFeature;
|
|
89
|
+
};
|
|
90
|
+
DeviceDisplayName?: string;
|
|
91
|
+
DeviceMessageTimingGap?: number;
|
|
196
92
|
}
|
|
197
|
-
export
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
static Create(deviceIndex: number, commands: [number, boolean][]): RotateCmd;
|
|
203
|
-
constructor(Rotations: RotateSubcommand[], DeviceIndex?: number, Id?: number);
|
|
93
|
+
export interface DeviceList {
|
|
94
|
+
Devices: {
|
|
95
|
+
[key: number]: DeviceInfo;
|
|
96
|
+
};
|
|
97
|
+
Id: number | undefined;
|
|
204
98
|
}
|
|
205
|
-
export declare
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
99
|
+
export declare enum OutputType {
|
|
100
|
+
Unknown = "Unknown",
|
|
101
|
+
Vibrate = "Vibrate",
|
|
102
|
+
Rotate = "Rotate",
|
|
103
|
+
Oscillate = "Oscillate",
|
|
104
|
+
Constrict = "Constrict",
|
|
105
|
+
Inflate = "Inflate",
|
|
106
|
+
Position = "Position",
|
|
107
|
+
HwPositionWithDuration = "HwPositionWithDuration",
|
|
108
|
+
Temperature = "Temperature",
|
|
109
|
+
Spray = "Spray",
|
|
110
|
+
Led = "Led"
|
|
209
111
|
}
|
|
210
|
-
export declare
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
constructor(Vectors: VectorSubcommand[], DeviceIndex?: number, Id?: number);
|
|
112
|
+
export declare enum InputType {
|
|
113
|
+
Unknown = "Unknown",
|
|
114
|
+
Battery = "Battery",
|
|
115
|
+
RSSI = "RSSI",
|
|
116
|
+
Button = "Button",
|
|
117
|
+
Pressure = "Pressure"
|
|
217
118
|
}
|
|
218
|
-
export declare
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Id: number;
|
|
223
|
-
static Name: string;
|
|
224
|
-
constructor(DeviceIndex: number, SensorIndex: number, SensorType: SensorType, Id?: number);
|
|
119
|
+
export declare enum InputCommandType {
|
|
120
|
+
Read = "Read",
|
|
121
|
+
Subscribe = "Subscribe",
|
|
122
|
+
Unsubscribe = "Unsubscribe"
|
|
225
123
|
}
|
|
226
|
-
export
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
SensorType: SensorType;
|
|
230
|
-
Data: number[];
|
|
231
|
-
Id: number;
|
|
232
|
-
static Name: string;
|
|
233
|
-
constructor(DeviceIndex: number, SensorIndex: number, SensorType: SensorType, Data: number[], Id?: number);
|
|
124
|
+
export interface DeviceFeatureInput {
|
|
125
|
+
Value: number[];
|
|
126
|
+
Command: InputCommandType[];
|
|
234
127
|
}
|
|
235
|
-
export
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
ExpectedLength: number;
|
|
239
|
-
Timeout: number;
|
|
240
|
-
Id: number;
|
|
241
|
-
static Name: string;
|
|
242
|
-
constructor(DeviceIndex: number, Endpoint: string, ExpectedLength: number, Timeout: number, Id?: number);
|
|
128
|
+
export interface DeviceFeatureOutput {
|
|
129
|
+
Value: number;
|
|
130
|
+
Duration?: number;
|
|
243
131
|
}
|
|
244
|
-
export
|
|
132
|
+
export interface OutputCmd {
|
|
245
133
|
DeviceIndex: number;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
constructor(DeviceIndex: number, Endpoint: string, Data: Uint8Array, WriteWithResponse: boolean, Id?: number);
|
|
134
|
+
FeatureIndex: number;
|
|
135
|
+
Command: {
|
|
136
|
+
[key: string]: DeviceFeatureOutput;
|
|
137
|
+
};
|
|
138
|
+
Id: number | undefined;
|
|
252
139
|
}
|
|
253
|
-
export
|
|
140
|
+
export interface InputCmd {
|
|
254
141
|
DeviceIndex: number;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
142
|
+
FeatureIndex: number;
|
|
143
|
+
Type: InputType;
|
|
144
|
+
Command: InputCommandType;
|
|
145
|
+
Id: number | undefined;
|
|
259
146
|
}
|
|
260
|
-
export
|
|
261
|
-
|
|
262
|
-
Endpoint: string;
|
|
263
|
-
Id: number;
|
|
264
|
-
static Name: string;
|
|
265
|
-
constructor(DeviceIndex: number, Endpoint: string, Id?: number);
|
|
147
|
+
export interface InputValue {
|
|
148
|
+
Value: number;
|
|
266
149
|
}
|
|
267
|
-
export
|
|
150
|
+
export interface InputReading {
|
|
268
151
|
DeviceIndex: number;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
152
|
+
FeatureIndex: number;
|
|
153
|
+
Reading: {
|
|
154
|
+
[key: string]: InputValue;
|
|
155
|
+
};
|
|
156
|
+
Id: number | undefined;
|
|
157
|
+
}
|
|
158
|
+
export interface StopCmd {
|
|
159
|
+
Id: number | undefined;
|
|
160
|
+
DeviceIndex: number | undefined;
|
|
161
|
+
FeatureIndex: number | undefined;
|
|
162
|
+
Inputs: boolean | undefined;
|
|
163
|
+
Outputs: boolean | undefined;
|
|
274
164
|
}
|
package/dist/web/index.d.ts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
7
|
*/
|
|
8
|
-
export * from './client/
|
|
8
|
+
export * from './client/ButtplugClient';
|
|
9
9
|
export * from './client/ButtplugClientDevice';
|
|
10
10
|
export * from './client/ButtplugBrowserWebsocketClientConnector';
|
|
11
11
|
export * from './client/ButtplugNodeWebsocketClientConnector';
|
|
12
12
|
export * from './client/ButtplugClientConnectorException';
|
|
13
13
|
export * from './utils/ButtplugMessageSorter';
|
|
14
|
+
export * from './client/ButtplugClientDeviceCommand';
|
|
14
15
|
export * from './client/IButtplugClientConnector';
|
|
15
16
|
export * from './core/Messages';
|
|
16
|
-
export * from './core/MessageUtils';
|
|
17
17
|
export * from './core/Logging';
|
|
18
18
|
export * from './core/Exceptions';
|