buttplug 3.2.1 → 3.2.2

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/.yarnrc.yml CHANGED
@@ -1 +1,5 @@
1
+ compressionLevel: mixed
2
+
3
+ enableGlobalCache: false
4
+
1
5
  nodeLinker: node-modules
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v3.2.2 (2024/03/02)
2
+
3
+ ## Bugfixes
4
+
5
+ - Actually throw exceptions when there are websocket connection issues. (#257)
6
+
1
7
  # v3.2.1 (2023/09/23)
2
8
 
3
9
  ## Bugfixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buttplug",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Buttplug Client Implementation for Typescript/Javascript",
5
5
  "homepage": "https://github.com/buttplugio/buttplug-js/",
6
6
  "repository": {
@@ -32,38 +32,38 @@
32
32
  "dependencies": {
33
33
  "class-transformer": "^0.5.1",
34
34
  "eventemitter3": "^5.0.1",
35
- "reflect-metadata": "^0.1.13",
36
- "ws": "^8.14.2"
35
+ "reflect-metadata": "^0.2.1",
36
+ "ws": "^8.16.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/commander": "^2.12.2",
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",
44
- "@types/uuid-parse": "^1.0.0",
45
- "@types/ws": "^8.5.5",
46
- "@typescript-eslint/eslint-plugin": "^6.7.2",
47
- "@typescript-eslint/parser": "^6.7.2",
40
+ "@types/expect-puppeteer": "^5.0.6",
41
+ "@types/jest": "^29.5.12",
42
+ "@types/jest-environment-puppeteer": "^5.0.6",
43
+ "@types/node": "^20.11.24",
44
+ "@types/uuid-parse": "^1.0.2",
45
+ "@types/ws": "^8.5.10",
46
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
47
+ "@typescript-eslint/parser": "^7.1.0",
48
48
  "copyfiles": "^2.4.1",
49
49
  "cross-env": "^7.0.3",
50
- "eslint": "^8.50.0",
50
+ "eslint": "^8.57.0",
51
51
  "eslint-plugin-node": "^11.1.0",
52
- "gts": "^5.0.1",
52
+ "gts": "^5.2.0",
53
53
  "jest": "^29.7.0",
54
54
  "mock-socket": "^9.3.1",
55
55
  "pkg": "^5.8.1",
56
- "tmp": "^0.2.1",
56
+ "tmp": "^0.2.3",
57
57
  "trash": "^8.1.1",
58
58
  "trash-cli": "^5.0.0",
59
- "ts-jest": "^29.1.1",
60
- "ts-node": "^10.9.1",
59
+ "ts-jest": "^29.1.2",
60
+ "ts-node": "^10.9.2",
61
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",
66
- "yarn": "^1.22.19"
62
+ "typedoc": "^0.25.9",
63
+ "typescript": "^5.3.3",
64
+ "vite": "^5.1.4",
65
+ "vite-plugin-dts": "^3.7.3",
66
+ "yarn": "^1.22.21"
67
67
  },
68
68
  "jest": {
69
69
  "moduleFileExtensions": [
@@ -25,35 +25,32 @@ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
25
25
  }
26
26
 
27
27
  public connect = async (): Promise<void> => {
28
- const ws = new (this._websocketConstructor ?? WebSocket)(this._url);
29
- let res;
30
- let rej;
31
- const p = new Promise<void>((resolve, reject) => {
32
- res = resolve;
33
- rej = reject;
34
- });
35
- // In websockets, our error rarely tells us much, as for security reasons
36
- // browsers usually only throw Error Code 1006. It's up to those using this
37
- // library to state what the problem might be.
38
- const conErrorCallback = () => rej();
39
- ws.addEventListener('open', async () => {
40
- this._ws = ws;
41
- try {
42
- await this.initialize();
43
- this._ws.addEventListener('message', (msg) => {
44
- this.parseIncomingMessage(msg);
45
- });
46
- this._ws.removeEventListener('close', conErrorCallback);
47
- this._ws.addEventListener('close', this.disconnect);
48
- // TODO This doesn't really communicate the chain why our initializer failed
49
- res();
50
- } catch (e) {
51
- console.log(e);
52
- rej();
53
- }
28
+ return new Promise<void>((resolve, reject) => {
29
+ const ws = new (this._websocketConstructor ?? WebSocket)(this._url);
30
+ const onErrorCallback = (event: Event) => {reject(event)}
31
+ const onCloseCallback = (event: CloseEvent) => reject(event.reason)
32
+ ws.addEventListener('open', async () => {
33
+ this._ws = ws;
34
+ try {
35
+ await this.initialize();
36
+ this._ws.addEventListener('message', (msg) => {
37
+ this.parseIncomingMessage(msg);
38
+ });
39
+ this._ws.removeEventListener('close', onCloseCallback);
40
+ this._ws.removeEventListener('error', onErrorCallback);
41
+ this._ws.addEventListener('close', this.disconnect);
42
+ resolve();
43
+ } catch (e) {
44
+ reject(e);
45
+ }
46
+ });
47
+ // In websockets, our error rarely tells us much, as for security reasons
48
+ // browsers usually only throw Error Code 1006. It's up to those using this
49
+ // library to state what the problem might be.
50
+
51
+ ws.addEventListener('error', onErrorCallback)
52
+ ws.addEventListener('close', onCloseCallback);
54
53
  });
55
- ws.addEventListener('close', conErrorCallback);
56
- return p;
57
54
  };
58
55
 
59
56
  public disconnect = async (): Promise<void> => {