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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buttplug",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Buttplug Client Implementation for Typescript/Javascript",
|
|
5
5
|
"homepage": "https://github.com/buttplugio/buttplug-js/",
|
|
6
6
|
"repository": {
|
|
@@ -20,15 +20,10 @@
|
|
|
20
20
|
"types": "./dist/main/src/index.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "trash dist dist-bundle && yarn build:all",
|
|
23
|
-
"build:all": "yarn build:main && yarn build:web
|
|
23
|
+
"build:all": "yarn build:main && yarn build:web",
|
|
24
24
|
"build:main": "tsc -p tsconfig.json",
|
|
25
25
|
"build:doc": "typedoc --options typedocconfig.js --out doc ./src/index.ts",
|
|
26
|
-
"build:
|
|
27
|
-
"tslint": "tslint --project tsconfig.json --outputAbsolutePaths -c ../../tslint.json \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
|
-
"tslint:fix": "tslint --project tsconfig.json --outputAbsolutePaths -c ../../tslint.json --fix semicolon,comma,no-var-keyword,ordered-imports \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
29
|
-
"build:web": "webpack --config=build/webpack.base.js",
|
|
30
|
-
"build:web:release": "webpack --progress --hide-modules --config=build/webpack.production.js",
|
|
31
|
-
"build:analyze": "webpack --hide-modules --config=build/webpack.analyzer.js",
|
|
26
|
+
"build:web": "vite build",
|
|
32
27
|
"pretest": "yarn build:main",
|
|
33
28
|
"test": "jest tests/*",
|
|
34
29
|
"web-test": "jest web-tests/test-web-library.ts",
|
|
@@ -36,63 +31,38 @@
|
|
|
36
31
|
},
|
|
37
32
|
"dependencies": {
|
|
38
33
|
"class-transformer": "^0.5.1",
|
|
39
|
-
"
|
|
34
|
+
"eventemitter3": "^5.0.1",
|
|
40
35
|
"reflect-metadata": "^0.1.13",
|
|
41
|
-
"ws": "^8.
|
|
36
|
+
"ws": "^8.14.2"
|
|
42
37
|
},
|
|
43
38
|
"devDependencies": {
|
|
44
39
|
"@types/commander": "^2.12.2",
|
|
45
|
-
"@types/expect-puppeteer": "^5.0.
|
|
46
|
-
"@types/jest": "^29.
|
|
47
|
-
"@types/jest-environment-puppeteer": "^5.0.
|
|
48
|
-
"@types/node": "^
|
|
40
|
+
"@types/expect-puppeteer": "^5.0.4",
|
|
41
|
+
"@types/jest": "^29.5.5",
|
|
42
|
+
"@types/jest-environment-puppeteer": "^5.0.4",
|
|
43
|
+
"@types/node": "^20.6.3",
|
|
49
44
|
"@types/uuid-parse": "^1.0.0",
|
|
50
|
-
"@types/ws": "^8.5.
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
52
|
-
"@typescript-eslint/parser": "^
|
|
45
|
+
"@types/ws": "^8.5.5",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
|
47
|
+
"@typescript-eslint/parser": "^6.7.2",
|
|
53
48
|
"copyfiles": "^2.4.1",
|
|
54
49
|
"cross-env": "^7.0.3",
|
|
55
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.50.0",
|
|
56
51
|
"eslint-plugin-node": "^11.1.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"jest-puppeteer": "^7.0.0",
|
|
62
|
-
"mock-socket": "^9.2.0",
|
|
63
|
-
"pkg": "^5.8.0",
|
|
64
|
-
"puppeteer": "^19.6.3",
|
|
65
|
-
"rollup": "^3.15.0",
|
|
66
|
-
"rollup-plugin-auto-external": "^2.0.0",
|
|
67
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
|
68
|
-
"rollup-plugin-html": "^0.2.1",
|
|
69
|
-
"rollup-plugin-json": "^4.0.0",
|
|
70
|
-
"rollup-plugin-node-builtins": "^2.1.2",
|
|
71
|
-
"rollup-plugin-node-globals": "^1.4.0",
|
|
72
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
73
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
74
|
-
"rollup-plugin-postcss-modules": "^2.1.1",
|
|
75
|
-
"rollup-plugin-terser": "^5.3.0",
|
|
76
|
-
"rollup-plugin-typescript2": "^0.34.1",
|
|
77
|
-
"selfsigned": "^2.1.1",
|
|
78
|
-
"style-loader": "^3.3.1",
|
|
79
|
-
"terser": "^4.x",
|
|
80
|
-
"terser-webpack-plugin": "^4.x",
|
|
52
|
+
"gts": "^5.0.1",
|
|
53
|
+
"jest": "^29.7.0",
|
|
54
|
+
"mock-socket": "^9.3.1",
|
|
55
|
+
"pkg": "^5.8.1",
|
|
81
56
|
"tmp": "^0.2.1",
|
|
82
57
|
"trash": "^8.1.1",
|
|
83
58
|
"trash-cli": "^5.0.0",
|
|
84
|
-
"ts-jest": "^29.
|
|
85
|
-
"ts-loader": "^8.x",
|
|
59
|
+
"ts-jest": "^29.1.1",
|
|
86
60
|
"ts-node": "^10.9.1",
|
|
87
|
-
"tslib": "^2.
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"webpack": "^4.42.1",
|
|
93
|
-
"webpack-bundle-analyzer": "^3.6.1",
|
|
94
|
-
"webpack-cli": "^3.3.11",
|
|
95
|
-
"webpack-merge": "^4.2.2",
|
|
61
|
+
"tslib": "^2.6.2",
|
|
62
|
+
"typedoc": "^0.25.1",
|
|
63
|
+
"typescript": "^5.2.2",
|
|
64
|
+
"vite": "^4.4.9",
|
|
65
|
+
"vite-plugin-dts": "^3.5.4",
|
|
96
66
|
"yarn": "^1.22.19"
|
|
97
67
|
},
|
|
98
68
|
"jest": {
|
|
@@ -10,42 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
12
12
|
import { ButtplugMessage } from '../core/Messages';
|
|
13
|
-
import { FromJSON } from '../core/MessageUtils';
|
|
14
|
-
import { ButtplugMessageSorter } from '../utils/ButtplugMessageSorter';
|
|
15
13
|
import { ButtplugBrowserWebsocketConnector } from '../utils/ButtplugBrowserWebsocketConnector';
|
|
16
14
|
|
|
17
15
|
export class ButtplugBrowserWebsocketClientConnector
|
|
18
16
|
extends ButtplugBrowserWebsocketConnector
|
|
19
17
|
implements IButtplugClientConnector
|
|
20
18
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
public Send = async (msg: ButtplugMessage): Promise<ButtplugMessage> => {
|
|
19
|
+
public send = (msg: ButtplugMessage): void => {
|
|
24
20
|
if (!this.Connected) {
|
|
25
21
|
throw new Error('ButtplugClient not connected');
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
this.SendMessage(msg);
|
|
29
|
-
return await p;
|
|
23
|
+
this.sendMessage(msg);
|
|
30
24
|
};
|
|
31
|
-
|
|
32
|
-
protected ParseIncomingMessage = (event: MessageEvent) => {
|
|
33
|
-
if (typeof event.data === 'string') {
|
|
34
|
-
const msgs = FromJSON(event.data);
|
|
35
|
-
const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
|
|
36
|
-
this.emit('message', emitMsgs);
|
|
37
|
-
} else if (event.data instanceof Blob) {
|
|
38
|
-
const reader = new (this._filereaderConstructor ?? FileReader)();
|
|
39
|
-
reader.addEventListener('load', (ev) => {
|
|
40
|
-
this.OnReaderLoad(ev);
|
|
41
|
-
});
|
|
42
|
-
reader.readAsText(event.data);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
protected OnReaderLoad(event: Event) {
|
|
47
|
-
const msgs = FromJSON((event.target as FileReader).result);
|
|
48
|
-
const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
|
|
49
|
-
this.emit('message', emitMsgs);
|
|
50
|
-
}
|
|
51
25
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ButtplugError,
|
|
14
14
|
ButtplugMessageError,
|
|
15
15
|
} from '../core/Exceptions';
|
|
16
|
-
import { EventEmitter } from '
|
|
16
|
+
import { EventEmitter } from 'eventemitter3';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Represents an abstract device, capable of taking certain kinds of messages.
|
|
@@ -209,7 +209,7 @@ export class ButtplugClientDevice extends EventEmitter {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
public get linearAttributes(): Messages.GenericDeviceMessageAttributes[] {
|
|
212
|
-
return this.messageAttributes.
|
|
212
|
+
return this.messageAttributes.LinearCmd ?? [];
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
public async linear(
|
|
@@ -10,10 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
import { ButtplugBrowserWebsocketClientConnector } from './ButtplugBrowserWebsocketClientConnector';
|
|
12
12
|
import { WebSocket as NodeWebSocket } from 'ws';
|
|
13
|
-
import { FileReader } from 'filereader';
|
|
14
13
|
|
|
15
14
|
export class ButtplugNodeWebsocketClientConnector extends ButtplugBrowserWebsocketClientConnector {
|
|
16
15
|
protected _websocketConstructor =
|
|
17
16
|
NodeWebSocket as unknown as typeof WebSocket;
|
|
18
|
-
protected _filereaderConstructor = FileReader;
|
|
19
17
|
}
|
package/src/client/Client.ts
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
11
|
import { ButtplugLogger } from '../core/Logging';
|
|
12
|
-
import { EventEmitter } from '
|
|
12
|
+
import { EventEmitter } from 'eventemitter3';
|
|
13
13
|
import { ButtplugClientDevice } from './ButtplugClientDevice';
|
|
14
14
|
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
15
|
+
import { ButtplugMessageSorter } from '../utils/ButtplugMessageSorter';
|
|
16
|
+
|
|
15
17
|
import * as Messages from '../core/Messages';
|
|
16
18
|
import {
|
|
17
19
|
ButtplugDeviceError,
|
|
@@ -28,6 +30,7 @@ export class ButtplugClient extends EventEmitter {
|
|
|
28
30
|
protected _clientName: string;
|
|
29
31
|
protected _logger = ButtplugLogger.Logger;
|
|
30
32
|
protected _isScanning = false;
|
|
33
|
+
private _sorter: ButtplugMessageSorter = new ButtplugMessageSorter(true);
|
|
31
34
|
|
|
32
35
|
constructor(clientName = 'Generic Buttplug Client') {
|
|
33
36
|
super();
|
|
@@ -58,7 +61,7 @@ export class ButtplugClient extends EventEmitter {
|
|
|
58
61
|
this._logger.Info(
|
|
59
62
|
`ButtplugClient: Connecting using ${connector.constructor.name}`
|
|
60
63
|
);
|
|
61
|
-
await connector.
|
|
64
|
+
await connector.connect();
|
|
62
65
|
this._connector = connector;
|
|
63
66
|
this._connector.addListener('message', this.parseMessages);
|
|
64
67
|
this._connector.addListener('disconnect', this.disconnectHandler);
|
|
@@ -69,7 +72,7 @@ export class ButtplugClient extends EventEmitter {
|
|
|
69
72
|
this._logger.Debug('ButtplugClient: Disconnect called');
|
|
70
73
|
this.checkConnector();
|
|
71
74
|
await this.shutdownConnection();
|
|
72
|
-
await this._connector!.
|
|
75
|
+
await this._connector!.disconnect();
|
|
73
76
|
};
|
|
74
77
|
|
|
75
78
|
public startScanning = async () => {
|
|
@@ -112,7 +115,8 @@ export class ButtplugClient extends EventEmitter {
|
|
|
112
115
|
};
|
|
113
116
|
|
|
114
117
|
protected parseMessages = (msgs: Messages.ButtplugMessage[]) => {
|
|
115
|
-
|
|
118
|
+
const leftoverMsgs = this._sorter.ParseIncomingMessages(msgs);
|
|
119
|
+
for (const x of leftoverMsgs) {
|
|
116
120
|
switch (x.constructor) {
|
|
117
121
|
case Messages.DeviceAdded: {
|
|
118
122
|
const addedMsg = x as Messages.DeviceAdded;
|
|
@@ -160,7 +164,7 @@ export class ButtplugClient extends EventEmitter {
|
|
|
160
164
|
const ping = serverinfo.MaxPingTime;
|
|
161
165
|
if (serverinfo.MessageVersion < Messages.MESSAGE_SPEC_VERSION) {
|
|
162
166
|
// Disconnect and throw an exception explaining the version mismatch problem.
|
|
163
|
-
await this._connector!.
|
|
167
|
+
await this._connector!.disconnect();
|
|
164
168
|
throw ButtplugError.LogAndError(
|
|
165
169
|
ButtplugInitError,
|
|
166
170
|
this._logger,
|
|
@@ -186,7 +190,7 @@ export class ButtplugClient extends EventEmitter {
|
|
|
186
190
|
// Disconnect and throw an exception with the error message we got back.
|
|
187
191
|
// This will usually only error out if we have a version mismatch that the
|
|
188
192
|
// server has detected.
|
|
189
|
-
await this._connector!.
|
|
193
|
+
await this._connector!.disconnect();
|
|
190
194
|
const err = msg as Messages.Error;
|
|
191
195
|
throw ButtplugError.LogAndError(
|
|
192
196
|
ButtplugInitError,
|
|
@@ -231,7 +235,9 @@ export class ButtplugClient extends EventEmitter {
|
|
|
231
235
|
msg: Messages.ButtplugMessage
|
|
232
236
|
): Promise<Messages.ButtplugMessage> {
|
|
233
237
|
this.checkConnector();
|
|
234
|
-
|
|
238
|
+
const p = this._sorter.PrepareOutgoingMessage(msg);
|
|
239
|
+
await this._connector!.send(msg);
|
|
240
|
+
return await p;
|
|
235
241
|
}
|
|
236
242
|
|
|
237
243
|
protected checkConnector() {
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ButtplugMessage } from '../core/Messages';
|
|
10
|
-
import { EventEmitter } from '
|
|
10
|
+
import { EventEmitter } from 'eventemitter3';
|
|
11
11
|
|
|
12
12
|
export interface IButtplugClientConnector extends EventEmitter {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
connect: () => Promise<void>;
|
|
14
|
+
disconnect: () => Promise<void>;
|
|
15
|
+
initialize: () => Promise<void>;
|
|
16
|
+
send: (msg: ButtplugMessage) => void;
|
|
17
17
|
readonly Connected: boolean;
|
|
18
18
|
}
|
package/src/core/Logging.ts
CHANGED
package/src/core/MessageUtils.ts
CHANGED
|
@@ -21,7 +21,7 @@ function getMessageClass(
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function fromJSON(str): Messages.ButtplugMessage[] {
|
|
25
25
|
const msgarray: object[] = JSON.parse(str);
|
|
26
26
|
const msgs: Messages.ButtplugMessage[] = [];
|
|
27
27
|
for (const x of Array.from(msgarray)) {
|
|
@@ -8,14 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
|
-
import { EventEmitter } from '
|
|
11
|
+
import { EventEmitter } from 'eventemitter3';
|
|
12
12
|
import { ButtplugMessage } from '../core/Messages';
|
|
13
|
-
import {
|
|
13
|
+
import { fromJSON } from '../core/MessageUtils';
|
|
14
14
|
|
|
15
15
|
export class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
16
16
|
protected _ws: WebSocket | undefined;
|
|
17
17
|
protected _websocketConstructor: typeof WebSocket | null = null;
|
|
18
|
-
protected _filereaderConstructor: typeof FileReader | null = null;
|
|
19
18
|
|
|
20
19
|
public constructor(private _url: string) {
|
|
21
20
|
super();
|
|
@@ -25,7 +24,7 @@ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
|
25
24
|
return this._ws !== undefined;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
public
|
|
27
|
+
public connect = async (): Promise<void> => {
|
|
29
28
|
const ws = new (this._websocketConstructor ?? WebSocket)(this._url);
|
|
30
29
|
let res;
|
|
31
30
|
let rej;
|
|
@@ -40,12 +39,12 @@ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
|
40
39
|
ws.addEventListener('open', async () => {
|
|
41
40
|
this._ws = ws;
|
|
42
41
|
try {
|
|
43
|
-
await this.
|
|
42
|
+
await this.initialize();
|
|
44
43
|
this._ws.addEventListener('message', (msg) => {
|
|
45
|
-
this.
|
|
44
|
+
this.parseIncomingMessage(msg);
|
|
46
45
|
});
|
|
47
46
|
this._ws.removeEventListener('close', conErrorCallback);
|
|
48
|
-
this._ws.addEventListener('close', this.
|
|
47
|
+
this._ws.addEventListener('close', this.disconnect);
|
|
49
48
|
// TODO This doesn't really communicate the chain why our initializer failed
|
|
50
49
|
res();
|
|
51
50
|
} catch (e) {
|
|
@@ -57,7 +56,7 @@ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
|
57
56
|
return p;
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
public
|
|
59
|
+
public disconnect = async (): Promise<void> => {
|
|
61
60
|
if (!this.Connected) {
|
|
62
61
|
return;
|
|
63
62
|
}
|
|
@@ -66,33 +65,28 @@ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
|
|
|
66
65
|
this.emit('disconnect');
|
|
67
66
|
};
|
|
68
67
|
|
|
69
|
-
public
|
|
68
|
+
public sendMessage(msg: ButtplugMessage) {
|
|
70
69
|
if (!this.Connected) {
|
|
71
70
|
throw new Error('ButtplugBrowserWebsocketConnector not connected');
|
|
72
71
|
}
|
|
73
72
|
this._ws!.send('[' + msg.toJSON() + ']');
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
public
|
|
75
|
+
public initialize = async (): Promise<void> => {
|
|
77
76
|
return Promise.resolve();
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
protected
|
|
81
|
-
console.log('Calling parent parse incoming');
|
|
79
|
+
protected parseIncomingMessage(event: MessageEvent) {
|
|
82
80
|
if (typeof event.data === 'string') {
|
|
83
|
-
const msgs =
|
|
81
|
+
const msgs = fromJSON(event.data);
|
|
84
82
|
this.emit('message', msgs);
|
|
85
83
|
} else if (event.data instanceof Blob) {
|
|
86
|
-
|
|
87
|
-
reader.addEventListener('load', (ev) => {
|
|
88
|
-
this.OnReaderLoad(ev);
|
|
89
|
-
});
|
|
90
|
-
reader.readAsText(event.data);
|
|
84
|
+
// No-op, we only use text message types.
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
87
|
|
|
94
|
-
protected
|
|
95
|
-
const msgs =
|
|
88
|
+
protected onReaderLoad(event: Event) {
|
|
89
|
+
const msgs = fromJSON((event.target as FileReader).result);
|
|
96
90
|
this.emit('message', msgs);
|
|
97
91
|
}
|
|
98
92
|
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
build: {
|
|
7
|
+
lib: {
|
|
8
|
+
// Could also be a dictionary or array of multiple entry points
|
|
9
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
10
|
+
name: 'buttplug',
|
|
11
|
+
// the proper extensions will be added
|
|
12
|
+
fileName: (format): string => {
|
|
13
|
+
if (format === 'umd') {
|
|
14
|
+
return 'buttplug.js';
|
|
15
|
+
}
|
|
16
|
+
return 'buttplug.mjs';
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
outDir: 'dist/web',
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
dts({
|
|
23
|
+
exclude: ['tests'],
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
});
|
package/.github/FUNDING.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Issues related to messages or system architecture
|
|
4
|
-
title: ''
|
|
5
|
-
labels: bug
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is. Remember, this should only pertain to bugs at the protocol or general architecture level. Library or application specific bugs should be files in their respective repos.
|
|
12
|
-
|
|
13
|
-
**Expected behavior**
|
|
14
|
-
A clear and concise description of what you expected to happen.
|
|
15
|
-
|
|
16
|
-
**Additional context**
|
|
17
|
-
Add any other context about the problem here.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Doc Build
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish-docs:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v3
|
|
13
|
-
- name: Set Node.js 18.x
|
|
14
|
-
uses: actions/setup-node@v3
|
|
15
|
-
with:
|
|
16
|
-
node-version: 18.x
|
|
17
|
-
- name: Run install
|
|
18
|
-
uses: borales/actions-yarn@v4
|
|
19
|
-
with:
|
|
20
|
-
cmd: install # will run `yarn install` command
|
|
21
|
-
- name: Build production bundle
|
|
22
|
-
uses: borales/actions-yarn@v4
|
|
23
|
-
with:
|
|
24
|
-
cmd: build:doc
|
|
25
|
-
- name: Deploy
|
|
26
|
-
uses: peaceiris/actions-gh-pages@v3
|
|
27
|
-
with:
|
|
28
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
-
publish_dir: doc/
|
package/azure-pipelines.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
trigger:
|
|
2
|
-
- master
|
|
3
|
-
- dev
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
# - job: "MacOS"
|
|
7
|
-
# pool:
|
|
8
|
-
# vmImage: 'macos-10.13'
|
|
9
|
-
# steps:
|
|
10
|
-
# - template: 'build/build-test-freeze.yml'
|
|
11
|
-
# parameters:
|
|
12
|
-
# platform: "macos-x64"
|
|
13
|
-
- job: "Linux"
|
|
14
|
-
pool:
|
|
15
|
-
vmImage: 'ubuntu-16.04'
|
|
16
|
-
steps:
|
|
17
|
-
- template: 'build/build-test-freeze.yml'
|
|
18
|
-
parameters:
|
|
19
|
-
platform: "linux-x64"
|