buttplug 3.1.0 → 3.2.0
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 +13 -8
- package/CHANGELOG.md +24 -0
- package/README.md +24 -25
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -16
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +23 -57
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/client/ButtplugClientConnectorException.d.ts +11 -11
- package/dist/main/src/client/ButtplugClientConnectorException.js +41 -41
- package/dist/main/src/client/ButtplugClientDevice.d.ts +67 -68
- package/dist/main/src/client/ButtplugClientDevice.js +324 -324
- package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -19
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +19 -21
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/client/Client.d.ts +41 -41
- package/dist/main/src/client/Client.js +240 -235
- package/dist/main/src/client/Client.js.map +1 -1
- package/dist/main/src/client/IButtplugClientConnector.d.ts +16 -17
- package/dist/main/src/client/IButtplugClientConnector.js +9 -9
- package/dist/main/src/core/Exceptions.d.ts +36 -36
- package/dist/main/src/core/Exceptions.js +106 -106
- package/dist/main/src/core/Logging.d.ts +112 -113
- package/dist/main/src/core/Logging.js +170 -170
- package/dist/main/src/core/Logging.js.map +1 -1
- package/dist/main/src/core/MessageUtils.d.ts +9 -9
- package/dist/main/src/core/MessageUtils.js +58 -58
- package/dist/main/src/core/Messages.d.ts +275 -275
- package/dist/main/src/core/Messages.js +429 -429
- package/dist/main/src/core/Messages.js.map +1 -1
- package/dist/main/src/index.d.ts +18 -18
- package/dist/main/src/index.js +34 -34
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -24
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +95 -102
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
- package/dist/main/src/utils/ButtplugMessageSorter.d.ts +19 -19
- package/dist/main/src/utils/ButtplugMessageSorter.js +81 -81
- package/dist/main/src/utils/Utils.d.ts +1 -1
- package/dist/main/src/utils/Utils.js +7 -7
- package/dist/web/buttplug.js +38 -7616
- package/dist/web/buttplug.mjs +2254 -0
- package/dist/web/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -0
- package/dist/web/client/ButtplugClientConnectorException.d.ts +11 -0
- package/dist/web/client/ButtplugClientDevice.d.ts +67 -0
- package/dist/web/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -0
- package/dist/web/client/Client.d.ts +41 -0
- package/dist/web/client/IButtplugClientConnector.d.ts +16 -0
- package/dist/web/core/Exceptions.d.ts +36 -0
- package/dist/web/core/Logging.d.ts +112 -0
- package/dist/web/core/MessageUtils.d.ts +9 -0
- package/dist/web/core/Messages.d.ts +274 -0
- package/dist/web/index.d.ts +18 -0
- package/dist/web/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -0
- package/dist/web/utils/ButtplugMessageSorter.d.ts +19 -0
- package/dist/web/utils/Utils.d.ts +1 -0
- package/node-test.ts +5 -0
- package/package.json +23 -53
- package/src/client/ButtplugBrowserWebsocketClientConnector.ts +2 -28
- package/src/client/ButtplugClientDevice.ts +2 -2
- package/src/client/ButtplugNodeWebsocketClientConnector.ts +0 -2
- package/src/client/Client.ts +13 -7
- package/src/client/IButtplugClientConnector.ts +5 -5
- package/src/core/Logging.ts +1 -1
- package/src/core/MessageUtils.ts +1 -1
- package/src/utils/ButtplugBrowserWebsocketConnector.ts +14 -20
- package/vite.config.ts +26 -0
- package/.github/FUNDING.yml +0 -5
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -17
- package/.github/workflows/docs.yaml +0 -29
- package/azure-pipelines.yml +0 -19
- package/dist/web/buttplug.min.js +0 -3
- package/dist/web/buttplug.min.js.LICENSE.txt +0 -31
- package/dist/web/buttplug.min.js.map +0 -1
- package/jest-puppeteer.config.js +0 -5
- package/rollup.config.js +0 -55
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
9
|
+
import { ButtplugMessage } from '../core/Messages';
|
|
10
|
+
import { ButtplugBrowserWebsocketConnector } from '../utils/ButtplugBrowserWebsocketConnector';
|
|
11
|
+
export declare class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketConnector implements IButtplugClientConnector {
|
|
12
|
+
send: (msg: ButtplugMessage) => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import { ButtplugError } from '../core/Exceptions';
|
|
9
|
+
export declare class ButtplugClientConnectorException extends ButtplugError {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import * as Messages from '../core/Messages';
|
|
9
|
+
import { EventEmitter } from 'eventemitter3';
|
|
10
|
+
/**
|
|
11
|
+
* Represents an abstract device, capable of taking certain kinds of messages.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ButtplugClientDevice extends EventEmitter {
|
|
14
|
+
private _deviceInfo;
|
|
15
|
+
private _sendClosure;
|
|
16
|
+
/**
|
|
17
|
+
* Return the name of the device.
|
|
18
|
+
*/
|
|
19
|
+
get name(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Return the user set name of the device.
|
|
22
|
+
*/
|
|
23
|
+
get displayName(): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Return the index of the device.
|
|
26
|
+
*/
|
|
27
|
+
get index(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Return the index of the device.
|
|
30
|
+
*/
|
|
31
|
+
get messageTimingGap(): number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Return a list of message types the device accepts.
|
|
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;
|
|
38
|
+
/**
|
|
39
|
+
* @param _index Index of the device, as created by the device manager.
|
|
40
|
+
* @param _name Name of the device.
|
|
41
|
+
* @param allowedMsgs Buttplug messages the device can receive.
|
|
42
|
+
*/
|
|
43
|
+
constructor(_deviceInfo: Messages.DeviceInfo, _sendClosure: (device: ButtplugClientDevice, msg: Messages.ButtplugDeviceMessage) => Promise<Messages.ButtplugMessage>);
|
|
44
|
+
send(msg: Messages.ButtplugDeviceMessage): Promise<Messages.ButtplugMessage>;
|
|
45
|
+
sendExpectOk(msg: Messages.ButtplugDeviceMessage): Promise<void>;
|
|
46
|
+
scalar(scalar: Messages.ScalarSubcommand | Messages.ScalarSubcommand[]): Promise<void>;
|
|
47
|
+
private scalarCommandBuilder;
|
|
48
|
+
get vibrateAttributes(): Messages.GenericDeviceMessageAttributes[];
|
|
49
|
+
vibrate(speed: number | number[]): Promise<void>;
|
|
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>;
|
|
65
|
+
stop(): Promise<void>;
|
|
66
|
+
emitDisconnected(): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
import { ButtplugBrowserWebsocketClientConnector } from './ButtplugBrowserWebsocketClientConnector';
|
|
9
|
+
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
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { ButtplugLogger } from '../core/Logging';
|
|
10
|
+
import { EventEmitter } from 'eventemitter3';
|
|
11
|
+
import { ButtplugClientDevice } from './ButtplugClientDevice';
|
|
12
|
+
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
13
|
+
import * as Messages from '../core/Messages';
|
|
14
|
+
export declare class ButtplugClient extends EventEmitter {
|
|
15
|
+
protected _pingTimer: NodeJS.Timeout | null;
|
|
16
|
+
protected _connector: IButtplugClientConnector | null;
|
|
17
|
+
protected _devices: Map<number, ButtplugClientDevice>;
|
|
18
|
+
protected _clientName: string;
|
|
19
|
+
protected _logger: ButtplugLogger;
|
|
20
|
+
protected _isScanning: boolean;
|
|
21
|
+
private _sorter;
|
|
22
|
+
constructor(clientName?: string);
|
|
23
|
+
get connected(): boolean;
|
|
24
|
+
get devices(): ButtplugClientDevice[];
|
|
25
|
+
get isScanning(): boolean;
|
|
26
|
+
connect: (connector: IButtplugClientConnector) => Promise<void>;
|
|
27
|
+
disconnect: () => Promise<void>;
|
|
28
|
+
startScanning: () => Promise<void>;
|
|
29
|
+
stopScanning: () => Promise<void>;
|
|
30
|
+
stopAllDevices: () => Promise<void>;
|
|
31
|
+
private sendDeviceMessage;
|
|
32
|
+
protected disconnectHandler: () => void;
|
|
33
|
+
protected parseMessages: (msgs: Messages.ButtplugMessage[]) => void;
|
|
34
|
+
protected initializeConnection: () => Promise<boolean>;
|
|
35
|
+
protected requestDeviceList: () => Promise<void>;
|
|
36
|
+
protected shutdownConnection: () => Promise<void>;
|
|
37
|
+
protected sendMessage(msg: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage>;
|
|
38
|
+
protected checkConnector(): void;
|
|
39
|
+
protected sendMsgExpectOk: (msg: Messages.ButtplugMessage) => Promise<void>;
|
|
40
|
+
protected sendDeviceMessageClosure: (device: ButtplugClientDevice, msg: Messages.ButtplugDeviceMessage) => Promise<Messages.ButtplugMessage>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import { ButtplugMessage } from '../core/Messages';
|
|
9
|
+
import { EventEmitter } from 'eventemitter3';
|
|
10
|
+
export interface IButtplugClientConnector extends EventEmitter {
|
|
11
|
+
connect: () => Promise<void>;
|
|
12
|
+
disconnect: () => Promise<void>;
|
|
13
|
+
initialize: () => Promise<void>;
|
|
14
|
+
send: (msg: ButtplugMessage) => void;
|
|
15
|
+
readonly Connected: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import * as Messages from './Messages';
|
|
9
|
+
import { ButtplugLogger } from './Logging';
|
|
10
|
+
export declare class ButtplugError extends Error {
|
|
11
|
+
get ErrorClass(): Messages.ErrorClass;
|
|
12
|
+
get InnerError(): Error | undefined;
|
|
13
|
+
get Id(): number | undefined;
|
|
14
|
+
get ErrorMessage(): Messages.ButtplugMessage;
|
|
15
|
+
static LogAndError<T extends ButtplugError>(constructor: new (str: string, num: number) => T, logger: ButtplugLogger, message: string, id?: number): T;
|
|
16
|
+
static FromError(error: Messages.Error): ButtplugDeviceError | ButtplugInitError | ButtplugUnknownError | ButtplugPingError | ButtplugMessageError;
|
|
17
|
+
errorClass: Messages.ErrorClass;
|
|
18
|
+
innerError: Error | undefined;
|
|
19
|
+
messageId: number | undefined;
|
|
20
|
+
protected constructor(message: string, errorClass: Messages.ErrorClass, id?: number, inner?: Error);
|
|
21
|
+
}
|
|
22
|
+
export declare class ButtplugInitError extends ButtplugError {
|
|
23
|
+
constructor(message: string, id?: number);
|
|
24
|
+
}
|
|
25
|
+
export declare class ButtplugDeviceError extends ButtplugError {
|
|
26
|
+
constructor(message: string, id?: number);
|
|
27
|
+
}
|
|
28
|
+
export declare class ButtplugMessageError extends ButtplugError {
|
|
29
|
+
constructor(message: string, id?: number);
|
|
30
|
+
}
|
|
31
|
+
export declare class ButtplugPingError extends ButtplugError {
|
|
32
|
+
constructor(message: string, id?: number);
|
|
33
|
+
}
|
|
34
|
+
export declare class ButtplugUnknownError extends ButtplugError {
|
|
35
|
+
constructor(message: string, id?: number);
|
|
36
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
import { EventEmitter } from 'eventemitter3';
|
|
9
|
+
export declare enum ButtplugLogLevel {
|
|
10
|
+
Off = 0,
|
|
11
|
+
Error = 1,
|
|
12
|
+
Warn = 2,
|
|
13
|
+
Info = 3,
|
|
14
|
+
Debug = 4,
|
|
15
|
+
Trace = 5
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Representation of log messages for the internal logging utility.
|
|
19
|
+
*/
|
|
20
|
+
export declare class LogMessage {
|
|
21
|
+
/** Timestamp for the log message */
|
|
22
|
+
private timestamp;
|
|
23
|
+
/** Log Message */
|
|
24
|
+
private logMessage;
|
|
25
|
+
/** Log Level */
|
|
26
|
+
private logLevel;
|
|
27
|
+
/**
|
|
28
|
+
* @param logMessage Log message.
|
|
29
|
+
* @param logLevel: Log severity level.
|
|
30
|
+
*/
|
|
31
|
+
constructor(logMessage: string, logLevel: ButtplugLogLevel);
|
|
32
|
+
/**
|
|
33
|
+
* Returns the log message.
|
|
34
|
+
*/
|
|
35
|
+
get Message(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the log message level.
|
|
38
|
+
*/
|
|
39
|
+
get LogLevel(): ButtplugLogLevel;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the log message timestamp.
|
|
42
|
+
*/
|
|
43
|
+
get Timestamp(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a formatted string with timestamp, level, and message.
|
|
46
|
+
*/
|
|
47
|
+
get FormattedMessage(): string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Simple, global logging utility for the Buttplug client and server. Keeps an
|
|
51
|
+
* internal static reference to an instance of itself (singleton pattern,
|
|
52
|
+
* basically), and allows message logging throughout the module.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ButtplugLogger extends EventEmitter {
|
|
55
|
+
/** Singleton instance for the logger */
|
|
56
|
+
protected static sLogger: ButtplugLogger | undefined;
|
|
57
|
+
/** Sets maximum log level to log to console */
|
|
58
|
+
protected maximumConsoleLogLevel: ButtplugLogLevel;
|
|
59
|
+
/** Sets maximum log level for all log messages */
|
|
60
|
+
protected maximumEventLogLevel: ButtplugLogLevel;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the stored static instance of the logger, creating one if it
|
|
63
|
+
* doesn't currently exist.
|
|
64
|
+
*/
|
|
65
|
+
static get Logger(): ButtplugLogger;
|
|
66
|
+
/**
|
|
67
|
+
* Constructor. Can only be called internally since we regulate ButtplugLogger
|
|
68
|
+
* ownership.
|
|
69
|
+
*/
|
|
70
|
+
protected constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Set the maximum log level to output to console.
|
|
73
|
+
*/
|
|
74
|
+
get MaximumConsoleLogLevel(): ButtplugLogLevel;
|
|
75
|
+
/**
|
|
76
|
+
* Get the maximum log level to output to console.
|
|
77
|
+
*/
|
|
78
|
+
set MaximumConsoleLogLevel(buttplugLogLevel: ButtplugLogLevel);
|
|
79
|
+
/**
|
|
80
|
+
* Set the global maximum log level
|
|
81
|
+
*/
|
|
82
|
+
get MaximumEventLogLevel(): ButtplugLogLevel;
|
|
83
|
+
/**
|
|
84
|
+
* Get the global maximum log level
|
|
85
|
+
*/
|
|
86
|
+
set MaximumEventLogLevel(logLevel: ButtplugLogLevel);
|
|
87
|
+
/**
|
|
88
|
+
* Log new message at Error level.
|
|
89
|
+
*/
|
|
90
|
+
Error(msg: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Log new message at Warn level.
|
|
93
|
+
*/
|
|
94
|
+
Warn(msg: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Log new message at Info level.
|
|
97
|
+
*/
|
|
98
|
+
Info(msg: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Log new message at Debug level.
|
|
101
|
+
*/
|
|
102
|
+
Debug(msg: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Log new message at Trace level.
|
|
105
|
+
*/
|
|
106
|
+
Trace(msg: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Checks to see if message should be logged, and if so, adds message to the
|
|
109
|
+
* log buffer. May also print message and emit event.
|
|
110
|
+
*/
|
|
111
|
+
protected AddLogMessage(msg: string, level: ButtplugLogLevel): void;
|
|
112
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import * as Messages from './Messages';
|
|
9
|
+
export declare function fromJSON(str: any): Messages.ButtplugMessage[];
|
|
@@ -0,0 +1,274 @@
|
|
|
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
|
+
export declare const SYSTEM_MESSAGE_ID = 0;
|
|
9
|
+
export declare const DEFAULT_MESSAGE_ID = 1;
|
|
10
|
+
export declare const MAX_ID = 4294967295;
|
|
11
|
+
export declare const MESSAGE_SPEC_VERSION = 3;
|
|
12
|
+
export declare class MessageAttributes {
|
|
13
|
+
ScalarCmd?: Array<GenericDeviceMessageAttributes>;
|
|
14
|
+
RotateCmd?: Array<GenericDeviceMessageAttributes>;
|
|
15
|
+
LinearCmd?: Array<GenericDeviceMessageAttributes>;
|
|
16
|
+
RawReadCmd?: RawDeviceMessageAttributes;
|
|
17
|
+
RawWriteCmd?: RawDeviceMessageAttributes;
|
|
18
|
+
RawSubscribeCmd?: RawDeviceMessageAttributes;
|
|
19
|
+
SensorReadCmd?: Array<SensorDeviceMessageAttributes>;
|
|
20
|
+
SensorSubscribeCmd?: Array<SensorDeviceMessageAttributes>;
|
|
21
|
+
StopDeviceCmd: {};
|
|
22
|
+
constructor(data: Partial<MessageAttributes>);
|
|
23
|
+
update(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare enum ActuatorType {
|
|
26
|
+
Unknown = "Unknown",
|
|
27
|
+
Vibrate = "Vibrate",
|
|
28
|
+
Rotate = "Rotate",
|
|
29
|
+
Oscillate = "Oscillate",
|
|
30
|
+
Constrict = "Constrict",
|
|
31
|
+
Inflate = "Inflate",
|
|
32
|
+
Position = "Position"
|
|
33
|
+
}
|
|
34
|
+
export declare enum SensorType {
|
|
35
|
+
Unknown = "Unknown",
|
|
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);
|
|
85
|
+
}
|
|
86
|
+
export declare enum ErrorClass {
|
|
87
|
+
ERROR_UNKNOWN = 0,
|
|
88
|
+
ERROR_INIT = 1,
|
|
89
|
+
ERROR_PING = 2,
|
|
90
|
+
ERROR_MSG = 3,
|
|
91
|
+
ERROR_DEVICE = 4
|
|
92
|
+
}
|
|
93
|
+
export declare class Error extends ButtplugMessage {
|
|
94
|
+
ErrorMessage: string;
|
|
95
|
+
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);
|
|
130
|
+
}
|
|
131
|
+
export declare class RequestDeviceList extends ButtplugMessage {
|
|
132
|
+
Id: number;
|
|
133
|
+
static Name: string;
|
|
134
|
+
constructor(Id?: number);
|
|
135
|
+
}
|
|
136
|
+
export declare class StartScanning extends ButtplugMessage {
|
|
137
|
+
Id: number;
|
|
138
|
+
static Name: string;
|
|
139
|
+
constructor(Id?: number);
|
|
140
|
+
}
|
|
141
|
+
export declare class StopScanning extends ButtplugMessage {
|
|
142
|
+
Id: number;
|
|
143
|
+
static Name: string;
|
|
144
|
+
constructor(Id?: number);
|
|
145
|
+
}
|
|
146
|
+
export declare class ScanningFinished extends ButtplugSystemMessage {
|
|
147
|
+
static Name: string;
|
|
148
|
+
constructor();
|
|
149
|
+
}
|
|
150
|
+
export declare class RequestServerInfo extends ButtplugMessage {
|
|
151
|
+
ClientName: string;
|
|
152
|
+
MessageVersion: number;
|
|
153
|
+
Id: number;
|
|
154
|
+
static Name: string;
|
|
155
|
+
constructor(ClientName: string, MessageVersion?: number, Id?: number);
|
|
156
|
+
}
|
|
157
|
+
export declare class ServerInfo extends ButtplugSystemMessage {
|
|
158
|
+
MessageVersion: number;
|
|
159
|
+
MaxPingTime: number;
|
|
160
|
+
ServerName: string;
|
|
161
|
+
Id: number;
|
|
162
|
+
static Name: string;
|
|
163
|
+
constructor(MessageVersion: number, MaxPingTime: number, ServerName: string, Id?: number);
|
|
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);
|
|
175
|
+
}
|
|
176
|
+
export declare class GenericMessageSubcommand {
|
|
177
|
+
Index: number;
|
|
178
|
+
protected constructor(Index: number);
|
|
179
|
+
}
|
|
180
|
+
export declare class ScalarSubcommand extends GenericMessageSubcommand {
|
|
181
|
+
Scalar: number;
|
|
182
|
+
ActuatorType: ActuatorType;
|
|
183
|
+
constructor(Index: number, Scalar: number, ActuatorType: ActuatorType);
|
|
184
|
+
}
|
|
185
|
+
export declare class ScalarCmd extends ButtplugDeviceMessage {
|
|
186
|
+
Scalars: ScalarSubcommand[];
|
|
187
|
+
DeviceIndex: number;
|
|
188
|
+
Id: number;
|
|
189
|
+
static Name: string;
|
|
190
|
+
constructor(Scalars: ScalarSubcommand[], DeviceIndex?: number, Id?: number);
|
|
191
|
+
}
|
|
192
|
+
export declare class RotateSubcommand extends GenericMessageSubcommand {
|
|
193
|
+
Speed: number;
|
|
194
|
+
Clockwise: boolean;
|
|
195
|
+
constructor(Index: number, Speed: number, Clockwise: boolean);
|
|
196
|
+
}
|
|
197
|
+
export declare class RotateCmd extends ButtplugDeviceMessage {
|
|
198
|
+
Rotations: RotateSubcommand[];
|
|
199
|
+
DeviceIndex: number;
|
|
200
|
+
Id: number;
|
|
201
|
+
static Name: string;
|
|
202
|
+
static Create(deviceIndex: number, commands: [number, boolean][]): RotateCmd;
|
|
203
|
+
constructor(Rotations: RotateSubcommand[], DeviceIndex?: number, Id?: number);
|
|
204
|
+
}
|
|
205
|
+
export declare class VectorSubcommand extends GenericMessageSubcommand {
|
|
206
|
+
Position: number;
|
|
207
|
+
Duration: number;
|
|
208
|
+
constructor(Index: number, Position: number, Duration: number);
|
|
209
|
+
}
|
|
210
|
+
export declare class LinearCmd extends ButtplugDeviceMessage {
|
|
211
|
+
Vectors: VectorSubcommand[];
|
|
212
|
+
DeviceIndex: number;
|
|
213
|
+
Id: number;
|
|
214
|
+
static Name: string;
|
|
215
|
+
static Create(deviceIndex: number, commands: [number, number][]): LinearCmd;
|
|
216
|
+
constructor(Vectors: VectorSubcommand[], DeviceIndex?: number, Id?: number);
|
|
217
|
+
}
|
|
218
|
+
export declare class SensorReadCmd extends ButtplugDeviceMessage {
|
|
219
|
+
DeviceIndex: number;
|
|
220
|
+
SensorIndex: number;
|
|
221
|
+
SensorType: SensorType;
|
|
222
|
+
Id: number;
|
|
223
|
+
static Name: string;
|
|
224
|
+
constructor(DeviceIndex: number, SensorIndex: number, SensorType: SensorType, Id?: number);
|
|
225
|
+
}
|
|
226
|
+
export declare class SensorReading extends ButtplugDeviceMessage {
|
|
227
|
+
DeviceIndex: number;
|
|
228
|
+
SensorIndex: number;
|
|
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);
|
|
234
|
+
}
|
|
235
|
+
export declare class RawReadCmd extends ButtplugDeviceMessage {
|
|
236
|
+
DeviceIndex: number;
|
|
237
|
+
Endpoint: string;
|
|
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);
|
|
243
|
+
}
|
|
244
|
+
export declare class RawWriteCmd extends ButtplugDeviceMessage {
|
|
245
|
+
DeviceIndex: number;
|
|
246
|
+
Endpoint: string;
|
|
247
|
+
Data: Uint8Array;
|
|
248
|
+
WriteWithResponse: boolean;
|
|
249
|
+
Id: number;
|
|
250
|
+
static Name: string;
|
|
251
|
+
constructor(DeviceIndex: number, Endpoint: string, Data: Uint8Array, WriteWithResponse: boolean, Id?: number);
|
|
252
|
+
}
|
|
253
|
+
export declare class RawSubscribeCmd extends ButtplugDeviceMessage {
|
|
254
|
+
DeviceIndex: number;
|
|
255
|
+
Endpoint: string;
|
|
256
|
+
Id: number;
|
|
257
|
+
static Name: string;
|
|
258
|
+
constructor(DeviceIndex: number, Endpoint: string, Id?: number);
|
|
259
|
+
}
|
|
260
|
+
export declare class RawUnsubscribeCmd extends ButtplugDeviceMessage {
|
|
261
|
+
DeviceIndex: number;
|
|
262
|
+
Endpoint: string;
|
|
263
|
+
Id: number;
|
|
264
|
+
static Name: string;
|
|
265
|
+
constructor(DeviceIndex: number, Endpoint: string, Id?: number);
|
|
266
|
+
}
|
|
267
|
+
export declare class RawReading extends ButtplugDeviceMessage {
|
|
268
|
+
DeviceIndex: number;
|
|
269
|
+
Endpoint: string;
|
|
270
|
+
Data: number[];
|
|
271
|
+
Id: number;
|
|
272
|
+
static Name: string;
|
|
273
|
+
constructor(DeviceIndex: number, Endpoint: string, Data: number[], Id?: number);
|
|
274
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export * from './client/Client';
|
|
9
|
+
export * from './client/ButtplugClientDevice';
|
|
10
|
+
export * from './client/ButtplugBrowserWebsocketClientConnector';
|
|
11
|
+
export * from './client/ButtplugNodeWebsocketClientConnector';
|
|
12
|
+
export * from './client/ButtplugClientConnectorException';
|
|
13
|
+
export * from './utils/ButtplugMessageSorter';
|
|
14
|
+
export * from './client/IButtplugClientConnector';
|
|
15
|
+
export * from './core/Messages';
|
|
16
|
+
export * from './core/MessageUtils';
|
|
17
|
+
export * from './core/Logging';
|
|
18
|
+
export * from './core/Exceptions';
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import { EventEmitter } from 'eventemitter3';
|
|
9
|
+
import { ButtplugMessage } from '../core/Messages';
|
|
10
|
+
export declare class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
11
|
+
private _url;
|
|
12
|
+
protected _ws: WebSocket | undefined;
|
|
13
|
+
protected _websocketConstructor: typeof WebSocket | null;
|
|
14
|
+
constructor(_url: string);
|
|
15
|
+
get Connected(): boolean;
|
|
16
|
+
connect: () => Promise<void>;
|
|
17
|
+
disconnect: () => Promise<void>;
|
|
18
|
+
sendMessage(msg: ButtplugMessage): void;
|
|
19
|
+
initialize: () => Promise<void>;
|
|
20
|
+
protected parseIncomingMessage(event: MessageEvent): void;
|
|
21
|
+
protected onReaderLoad(event: Event): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import * as Messages from '../core/Messages';
|
|
9
|
+
export declare class ButtplugMessageSorter {
|
|
10
|
+
private _useCounter;
|
|
11
|
+
protected _counter: number;
|
|
12
|
+
protected _waitingMsgs: Map<number, [
|
|
13
|
+
(val: Messages.ButtplugMessage) => void,
|
|
14
|
+
(err: Error) => void
|
|
15
|
+
]>;
|
|
16
|
+
constructor(_useCounter: boolean);
|
|
17
|
+
PrepareOutgoingMessage(msg: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage>;
|
|
18
|
+
ParseIncomingMessages(msgs: Messages.ButtplugMessage[]): Messages.ButtplugMessage[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRandomInt(max: number): number;
|