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.
Files changed (179) hide show
  1. package/.eslintrc.js +25 -25
  2. package/.jscsrc +2 -2
  3. package/.jshintrc +5 -5
  4. package/.prettierrc.json +3 -3
  5. package/.yarnrc.yml +5 -5
  6. package/CHANGELOG.md +591 -577
  7. package/LICENSE +27 -27
  8. package/README.md +105 -97
  9. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +6 -9
  10. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
  11. package/dist/main/src/client/{Client.d.ts → ButtplugClient.d.ts} +3 -4
  12. package/dist/main/src/client/ButtplugClient.js +232 -0
  13. package/dist/main/src/client/ButtplugClient.js.map +1 -0
  14. package/dist/main/src/client/ButtplugClientConnectorException.js +17 -7
  15. package/dist/main/src/client/ButtplugClientConnectorException.js.map +1 -1
  16. package/dist/main/src/client/ButtplugClientDevice.d.ts +13 -28
  17. package/dist/main/src/client/ButtplugClientDevice.js +105 -247
  18. package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
  19. package/dist/main/src/client/ButtplugClientDeviceCommand.d.ts +42 -0
  20. package/dist/main/src/client/ButtplugClientDeviceCommand.js +105 -0
  21. package/dist/main/src/client/ButtplugClientDeviceCommand.js.map +1 -0
  22. package/dist/main/src/client/ButtplugClientDeviceFeature.d.ts +18 -0
  23. package/dist/main/src/client/ButtplugClientDeviceFeature.js +166 -0
  24. package/dist/main/src/client/ButtplugClientDeviceFeature.js.map +1 -0
  25. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +1 -8
  26. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +1 -4
  27. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -1
  28. package/dist/main/src/core/Exceptions.js +27 -9
  29. package/dist/main/src/core/Exceptions.js.map +1 -1
  30. package/dist/main/src/core/Logging.js +12 -6
  31. package/dist/main/src/core/Logging.js.map +1 -1
  32. package/dist/main/src/core/Messages.d.ts +119 -230
  33. package/dist/main/src/core/Messages.js +50 -404
  34. package/dist/main/src/core/Messages.js.map +1 -1
  35. package/dist/main/src/index.d.ts +2 -2
  36. package/dist/main/src/index.js +4 -2
  37. package/dist/main/src/index.js.map +1 -1
  38. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +40 -52
  39. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
  40. package/dist/main/src/utils/ButtplugMessageSorter.js +27 -15
  41. package/dist/main/src/utils/ButtplugMessageSorter.js.map +1 -1
  42. package/dist/main/src/utils/Utils.js +1 -2
  43. package/dist/main/src/utils/Utils.js.map +1 -1
  44. package/dist/web/buttplug.js +1 -38
  45. package/dist/web/buttplug.mjs +595 -1984
  46. package/dist/web/client/ButtplugBrowserWebsocketClientConnector.d.ts +0 -7
  47. package/dist/web/client/{Client.d.ts → ButtplugClient.d.ts} +3 -11
  48. package/dist/web/client/ButtplugClientConnectorException.d.ts +0 -7
  49. package/dist/web/client/ButtplugClientDevice.d.ts +14 -29
  50. package/dist/web/client/ButtplugClientDeviceCommand.d.ts +42 -0
  51. package/dist/web/client/ButtplugClientDeviceFeature.d.ts +18 -0
  52. package/dist/web/client/ButtplugNodeWebsocketClientConnector.d.ts +1 -15
  53. package/dist/web/client/IButtplugClientConnector.d.ts +0 -7
  54. package/dist/web/core/Exceptions.d.ts +1 -1
  55. package/dist/web/core/Logging.d.ts +0 -7
  56. package/dist/web/core/Messages.d.ts +119 -229
  57. package/dist/web/index.d.ts +2 -2
  58. package/dist/web/utils/ButtplugBrowserWebsocketConnector.d.ts +0 -7
  59. package/examples/node/SYNC_MANIFEST.md +105 -0
  60. package/examples/node/application-example.ts +213 -0
  61. package/examples/node/async-example.ts +124 -0
  62. package/examples/node/connection-example.ts +76 -0
  63. package/examples/node/device-control-example.ts +131 -0
  64. package/examples/node/device-enumeration-example.ts +86 -0
  65. package/examples/node/device-info-example.ts +131 -0
  66. package/examples/node/errors-example.ts +166 -0
  67. package/examples/node/package-lock.json +281 -0
  68. package/examples/node/package.json +25 -0
  69. package/examples/node/remote-connector-example.ts +84 -0
  70. package/examples/node/tsconfig.json +14 -0
  71. package/examples/web/application-example.js +197 -0
  72. package/examples/web/async-example.js +90 -0
  73. package/examples/web/device-control-example.js +87 -0
  74. package/examples/web/device-enumeration-example.js +49 -0
  75. package/examples/web/device-info-example.js +100 -0
  76. package/examples/web/errors-example.js +110 -0
  77. package/examples/web/index.html +55 -0
  78. package/examples/web/logging.js +42 -0
  79. package/examples/web/ping-timeout-example.js +59 -0
  80. package/examples/web/remote-connector-example.js +68 -0
  81. package/node-test.js +24 -0
  82. package/node-test.ts +23 -5
  83. package/package.json +85 -87
  84. package/src/client/ButtplugBrowserWebsocketClientConnector.ts +25 -25
  85. package/src/client/ButtplugClient.ts +242 -0
  86. package/src/client/ButtplugClientConnectorException.ts +16 -16
  87. package/src/client/ButtplugClientDevice.ts +178 -401
  88. package/src/client/ButtplugClientDeviceCommand.ts +112 -0
  89. package/src/client/ButtplugClientDeviceFeature.ts +138 -0
  90. package/src/client/ButtplugNodeWebsocketClientConnector.ts +17 -17
  91. package/src/client/IButtplugClientConnector.ts +18 -18
  92. package/src/core/Exceptions.ts +107 -101
  93. package/src/core/Logging.ts +197 -197
  94. package/src/core/Messages.ts +205 -480
  95. package/src/core/index.d.ts +4 -4
  96. package/src/index.ts +21 -19
  97. package/src/utils/ButtplugBrowserWebsocketConnector.ts +89 -89
  98. package/src/utils/ButtplugMessageSorter.ts +66 -65
  99. package/src/utils/Utils.ts +3 -3
  100. package/tsconfig.json +22 -22
  101. package/tsfmt.json +14 -14
  102. package/tslint.json +27 -27
  103. package/typedocconfig.js +6 -6
  104. package/vite.config.ts +26 -26
  105. package/dist/main/src/client/Client.js +0 -242
  106. package/dist/main/src/client/Client.js.map +0 -1
  107. package/dist/main/src/core/MessageUtils.d.ts +0 -10
  108. package/dist/main/src/core/MessageUtils.js +0 -65
  109. package/dist/main/src/core/MessageUtils.js.map +0 -1
  110. package/dist/web/core/MessageUtils.d.ts +0 -10
  111. package/doc/.nojekyll +0 -1
  112. package/doc/assets/highlight.css +0 -22
  113. package/doc/assets/main.js +0 -58
  114. package/doc/assets/search.js +0 -1
  115. package/doc/assets/style.css +0 -1280
  116. package/doc/classes/ButtplugBrowserWebsocketClientConnector.html +0 -234
  117. package/doc/classes/ButtplugClient.html +0 -331
  118. package/doc/classes/ButtplugClientConnectorException.html +0 -216
  119. package/doc/classes/ButtplugClientDevice.html +0 -489
  120. package/doc/classes/ButtplugDeviceError.html +0 -218
  121. package/doc/classes/ButtplugDeviceMessage.html +0 -165
  122. package/doc/classes/ButtplugError.html +0 -220
  123. package/doc/classes/ButtplugInitError.html +0 -218
  124. package/doc/classes/ButtplugLogger.html +0 -288
  125. package/doc/classes/ButtplugMessage.html +0 -147
  126. package/doc/classes/ButtplugMessageError.html +0 -218
  127. package/doc/classes/ButtplugMessageSorter.html +0 -128
  128. package/doc/classes/ButtplugNodeWebsocketClientConnector.html +0 -239
  129. package/doc/classes/ButtplugPingError.html +0 -218
  130. package/doc/classes/ButtplugSystemMessage.html +0 -150
  131. package/doc/classes/ButtplugUnknownError.html +0 -218
  132. package/doc/classes/DeviceAdded.html +0 -186
  133. package/doc/classes/DeviceInfo.html +0 -114
  134. package/doc/classes/DeviceList.html +0 -160
  135. package/doc/classes/DeviceRemoved.html +0 -158
  136. package/doc/classes/Error.html +0 -179
  137. package/doc/classes/GenericDeviceMessageAttributes.html +0 -107
  138. package/doc/classes/GenericMessageSubcommand.html +0 -90
  139. package/doc/classes/LinearCmd.html +0 -187
  140. package/doc/classes/LogMessage.html +0 -134
  141. package/doc/classes/MessageAttributes.html +0 -160
  142. package/doc/classes/Ok.html +0 -151
  143. package/doc/classes/Ping.html +0 -151
  144. package/doc/classes/RawDeviceMessageAttributes.html +0 -86
  145. package/doc/classes/RawReadCmd.html +0 -188
  146. package/doc/classes/RawReading.html +0 -179
  147. package/doc/classes/RawSubscribeCmd.html +0 -170
  148. package/doc/classes/RawUnsubscribeCmd.html +0 -170
  149. package/doc/classes/RawWriteCmd.html +0 -188
  150. package/doc/classes/RequestDeviceList.html +0 -151
  151. package/doc/classes/RequestServerInfo.html +0 -169
  152. package/doc/classes/RotateCmd.html +0 -187
  153. package/doc/classes/RotateSubcommand.html +0 -108
  154. package/doc/classes/ScalarCmd.html +0 -170
  155. package/doc/classes/ScalarSubcommand.html +0 -108
  156. package/doc/classes/ScanningFinished.html +0 -146
  157. package/doc/classes/SensorDeviceMessageAttributes.html +0 -107
  158. package/doc/classes/SensorReadCmd.html +0 -179
  159. package/doc/classes/SensorReading.html +0 -188
  160. package/doc/classes/ServerInfo.html +0 -178
  161. package/doc/classes/StartScanning.html +0 -151
  162. package/doc/classes/StopAllDevices.html +0 -151
  163. package/doc/classes/StopDeviceCmd.html +0 -161
  164. package/doc/classes/StopScanning.html +0 -151
  165. package/doc/classes/VectorSubcommand.html +0 -108
  166. package/doc/enums/ActuatorType.html +0 -104
  167. package/doc/enums/ButtplugLogLevel.html +0 -97
  168. package/doc/enums/ErrorClass.html +0 -90
  169. package/doc/enums/SensorType.html +0 -90
  170. package/doc/functions/FromJSON.html +0 -113
  171. package/doc/index.html +0 -184
  172. package/doc/interfaces/IButtplugClientConnector.html +0 -137
  173. package/doc/modules.html +0 -176
  174. package/doc/variables/DEFAULT_MESSAGE_ID.html +0 -104
  175. package/doc/variables/MAX_ID.html +0 -104
  176. package/doc/variables/MESSAGE_SPEC_VERSION.html +0 -104
  177. package/doc/variables/SYSTEM_MESSAGE_ID.html +0 -104
  178. package/src/client/Client.ts +0 -276
  179. package/src/core/MessageUtils.ts +0 -48
package/src/index.ts CHANGED
@@ -1,19 +1,21 @@
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
-
9
- export * from './client/Client';
10
- export * from './client/ButtplugClientDevice';
11
- export * from './client/ButtplugBrowserWebsocketClientConnector';
12
- export * from './client/ButtplugNodeWebsocketClientConnector';
13
- export * from './client/ButtplugClientConnectorException';
14
- export * from './utils/ButtplugMessageSorter';
15
- export * from './client/IButtplugClientConnector';
16
- export * from './core/Messages';
17
- export * from './core/MessageUtils';
18
- export * from './core/Logging';
19
- export * from './core/Exceptions';
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
+
9
+ export * from './client/ButtplugClient';
10
+ export * from './client/ButtplugClientDevice';
11
+ export * from './client/ButtplugBrowserWebsocketClientConnector';
12
+ export * from './client/ButtplugNodeWebsocketClientConnector';
13
+ export * from './client/ButtplugClientConnectorException';
14
+ export * from './utils/ButtplugMessageSorter';
15
+ export * from './client/ButtplugClientDeviceCommand';
16
+ export * from './client/IButtplugClientConnector';
17
+ //export * from './core/MessageClasses';
18
+ export * from './core/Messages';
19
+ //export * from './core/MessageUtils';
20
+ export * from './core/Logging';
21
+ export * from './core/Exceptions';
@@ -1,89 +1,89 @@
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
-
9
- 'use strict';
10
-
11
- import { EventEmitter } from 'eventemitter3';
12
- import { ButtplugMessage } from '../core/Messages';
13
- import { fromJSON } from '../core/MessageUtils';
14
-
15
- export class ButtplugBrowserWebsocketConnector extends EventEmitter {
16
- protected _ws: WebSocket | undefined;
17
- protected _websocketConstructor: typeof WebSocket | null = null;
18
-
19
- public constructor(private _url: string) {
20
- super();
21
- }
22
-
23
- public get Connected(): boolean {
24
- return this._ws !== undefined;
25
- }
26
-
27
- public connect = async (): Promise<void> => {
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);
53
- });
54
- };
55
-
56
- public disconnect = async (): Promise<void> => {
57
- if (!this.Connected) {
58
- return;
59
- }
60
- this._ws!.close();
61
- this._ws = undefined;
62
- this.emit('disconnect');
63
- };
64
-
65
- public sendMessage(msg: ButtplugMessage) {
66
- if (!this.Connected) {
67
- throw new Error('ButtplugBrowserWebsocketConnector not connected');
68
- }
69
- this._ws!.send('[' + msg.toJSON() + ']');
70
- }
71
-
72
- public initialize = async (): Promise<void> => {
73
- return Promise.resolve();
74
- };
75
-
76
- protected parseIncomingMessage(event: MessageEvent) {
77
- if (typeof event.data === 'string') {
78
- const msgs = fromJSON(event.data);
79
- this.emit('message', msgs);
80
- } else if (event.data instanceof Blob) {
81
- // No-op, we only use text message types.
82
- }
83
- }
84
-
85
- protected onReaderLoad(event: Event) {
86
- const msgs = fromJSON((event.target as FileReader).result);
87
- this.emit('message', msgs);
88
- }
89
- }
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
+
9
+ 'use strict';
10
+
11
+ import { EventEmitter } from 'eventemitter3';
12
+ import { ButtplugMessage } from '../core/Messages';
13
+ //import { fromJSON } from '../core/MessageUtils';
14
+
15
+ export class ButtplugBrowserWebsocketConnector extends EventEmitter {
16
+ protected _ws: WebSocket | undefined;
17
+ protected _websocketConstructor: typeof WebSocket | null = null;
18
+
19
+ public constructor(private _url: string) {
20
+ super();
21
+ }
22
+
23
+ public get Connected(): boolean {
24
+ return this._ws !== undefined;
25
+ }
26
+
27
+ public connect = async (): Promise<void> => {
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);
53
+ });
54
+ };
55
+
56
+ public disconnect = async (): Promise<void> => {
57
+ if (!this.Connected) {
58
+ return;
59
+ }
60
+ this._ws!.close();
61
+ this._ws = undefined;
62
+ this.emit('disconnect');
63
+ };
64
+
65
+ public sendMessage(msg: ButtplugMessage) {
66
+ if (!this.Connected) {
67
+ throw new Error('ButtplugBrowserWebsocketConnector not connected');
68
+ }
69
+ this._ws!.send('[' + JSON.stringify(msg) + ']');
70
+ }
71
+
72
+ public initialize = async (): Promise<void> => {
73
+ return Promise.resolve();
74
+ };
75
+
76
+ protected parseIncomingMessage(event: MessageEvent) {
77
+ if (typeof event.data === 'string') {
78
+ const msgs: ButtplugMessage[] = JSON.parse(event.data);
79
+ this.emit('message', msgs);
80
+ } else if (event.data instanceof Blob) {
81
+ // No-op, we only use text message types.
82
+ }
83
+ }
84
+
85
+ protected onReaderLoad(event: Event) {
86
+ const msgs: ButtplugMessage[] = JSON.parse((event.target as FileReader).result as string);
87
+ this.emit('message', msgs);
88
+ }
89
+ }
@@ -1,65 +1,66 @@
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
-
9
- import * as Messages from '../core/Messages';
10
- import { ButtplugError } from '../core/Exceptions';
11
-
12
- export class ButtplugMessageSorter {
13
- protected _counter = 1;
14
- protected _waitingMsgs: Map<
15
- number,
16
- [(val: Messages.ButtplugMessage) => void, (err: Error) => void]
17
- > = new Map();
18
-
19
- public constructor(private _useCounter: boolean) {}
20
-
21
- // One of the places we should actually return a promise, as we need to store
22
- // them while waiting for them to return across the line.
23
- // tslint:disable:promise-function-async
24
- public PrepareOutgoingMessage(
25
- msg: Messages.ButtplugMessage
26
- ): Promise<Messages.ButtplugMessage> {
27
- if (this._useCounter) {
28
- msg.Id = this._counter;
29
- // Always increment last, otherwise we might lose sync
30
- this._counter += 1;
31
- }
32
- let res;
33
- let rej;
34
- const msgPromise = new Promise<Messages.ButtplugMessage>(
35
- (resolve, reject) => {
36
- res = resolve;
37
- rej = reject;
38
- }
39
- );
40
- this._waitingMsgs.set(msg.Id, [res, rej]);
41
- return msgPromise;
42
- }
43
-
44
- public ParseIncomingMessages(
45
- msgs: Messages.ButtplugMessage[]
46
- ): Messages.ButtplugMessage[] {
47
- const noMatch: Messages.ButtplugMessage[] = [];
48
- for (const x of msgs) {
49
- if (x.Id !== Messages.SYSTEM_MESSAGE_ID && this._waitingMsgs.has(x.Id)) {
50
- const [res, rej] = this._waitingMsgs.get(x.Id)!;
51
- // If we've gotten back an error, reject the related promise using a
52
- // ButtplugException derived type.
53
- if (x.Type === Messages.Error) {
54
- rej(ButtplugError.FromError(x as Messages.Error));
55
- continue;
56
- }
57
- res(x);
58
- continue;
59
- } else {
60
- noMatch.push(x);
61
- }
62
- }
63
- return noMatch;
64
- }
65
- }
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
+
9
+ import * as Messages from '../core/Messages';
10
+ import { ButtplugError } from '../core/Exceptions';
11
+
12
+ export class ButtplugMessageSorter {
13
+ protected _counter = 1;
14
+ protected _waitingMsgs: Map<
15
+ number,
16
+ [(val: Messages.ButtplugMessage) => void, (err: Error) => void]
17
+ > = new Map();
18
+
19
+ public constructor(private _useCounter: boolean) {}
20
+
21
+ // One of the places we should actually return a promise, as we need to store
22
+ // them while waiting for them to return across the line.
23
+ // tslint:disable:promise-function-async
24
+ public PrepareOutgoingMessage(
25
+ msg: Messages.ButtplugMessage
26
+ ): Promise<Messages.ButtplugMessage> {
27
+ if (this._useCounter) {
28
+ Messages.setMsgId(msg, this._counter);
29
+ // Always increment last, otherwise we might lose sync
30
+ this._counter += 1;
31
+ }
32
+ let res;
33
+ let rej;
34
+ const msgPromise = new Promise<Messages.ButtplugMessage>(
35
+ (resolve, reject) => {
36
+ res = resolve;
37
+ rej = reject;
38
+ }
39
+ );
40
+ this._waitingMsgs.set(Messages.msgId(msg), [res, rej]);
41
+ return msgPromise;
42
+ }
43
+
44
+ public ParseIncomingMessages(
45
+ msgs: Messages.ButtplugMessage[]
46
+ ): Messages.ButtplugMessage[] {
47
+ const noMatch: Messages.ButtplugMessage[] = [];
48
+ for (const x of msgs) {
49
+ let id = Messages.msgId(x);
50
+ if (id !== Messages.SYSTEM_MESSAGE_ID && this._waitingMsgs.has(id)) {
51
+ const [res, rej] = this._waitingMsgs.get(id)!;
52
+ // If we've gotten back an error, reject the related promise using a
53
+ // ButtplugException derived type.
54
+ if (x.Error !== undefined) {
55
+ rej(ButtplugError.FromError(x.Error!));
56
+ continue;
57
+ }
58
+ res(x);
59
+ continue;
60
+ } else {
61
+ noMatch.push(x);
62
+ }
63
+ }
64
+ return noMatch;
65
+ }
66
+ }
@@ -1,3 +1,3 @@
1
- export function getRandomInt(max: number) {
2
- return Math.floor(Math.random() * Math.floor(max));
3
- }
1
+ export function getRandomInt(max: number) {
2
+ return Math.floor(Math.random() * Math.floor(max));
3
+ }
package/tsconfig.json CHANGED
@@ -1,22 +1,22 @@
1
- {
2
- "compilerOptions" : {
3
- "baseUrl": "./src",
4
- "lib": ["es2015", "dom", "es6"],
5
- "target": "es6",
6
- "module": "commonjs",
7
- "moduleResolution": "node",
8
- "sourceMap": true,
9
- "emitDecoratorMetadata": true,
10
- "experimentalDecorators": true,
11
- "strictNullChecks": true,
12
- "noImplicitThis": true,
13
- "declaration": true,
14
- "outDir": "./dist/main",
15
- "esModuleInterop": true
16
- },
17
- "include": [
18
- "./src/*.ts",
19
- "./src/**/*.ts",
20
- "./tests/**/*.ts"
21
- ]
22
- }
1
+ {
2
+ "compilerOptions" : {
3
+ "baseUrl": "./src",
4
+ "lib": ["esnext", "dom"],
5
+ "target": "esnext",
6
+ "module": "commonjs",
7
+ "moduleResolution": "node",
8
+ "sourceMap": true,
9
+ "emitDecoratorMetadata": true,
10
+ "experimentalDecorators": true,
11
+ "strictNullChecks": true,
12
+ "noImplicitThis": true,
13
+ "declaration": true,
14
+ "outDir": "./dist/main",
15
+ "esModuleInterop": true
16
+ },
17
+ "include": [
18
+ "./src/*.ts",
19
+ "./src/**/*.ts",
20
+ "./tests/**/*.ts"
21
+ ]
22
+ }
package/tsfmt.json CHANGED
@@ -1,14 +1,14 @@
1
- {
2
- "indentSize": 2,
3
- "tabSize": 2,
4
- "convertTabsToSpaces": true,
5
- "insertSpaceAfterCommaDelimiter": true,
6
- "insertSpaceAfterSemicolonInForStatements": true,
7
- "insertSpaceBeforeAndAfterBinaryOperators": true,
8
- "insertSpaceAfterKeywordsInControlFlowStatements": true,
9
- "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
10
- "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
11
- "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
12
- "placeOpenBraceOnNewLineForFunctions": false,
13
- "placeOpenBraceOnNewLineForControlBlocks": false
14
- }
1
+ {
2
+ "indentSize": 2,
3
+ "tabSize": 2,
4
+ "convertTabsToSpaces": true,
5
+ "insertSpaceAfterCommaDelimiter": true,
6
+ "insertSpaceAfterSemicolonInForStatements": true,
7
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
8
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
9
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
10
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
11
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
12
+ "placeOpenBraceOnNewLineForFunctions": false,
13
+ "placeOpenBraceOnNewLineForControlBlocks": false
14
+ }
package/tslint.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "extends": [
3
- "tslint:recommended"
4
- ],
5
- "linterOptions": {
6
- "exclude": [
7
- "**/buttplug-gui-proto.d.ts"
8
- ]
9
- },
10
- "jsRules": {},
11
- "rules": {
12
- "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
13
- "only-arrow-functions": [false],
14
- "indent": [true, "spaces", 2],
15
- "no-var-requires": [false],
16
- "ordered-imports": [false],
17
- "no-console": [false],
18
- "object-literal-sort-keys": [false],
19
- "max-classes-per-file": [false],
20
- "no-bitwise": [false],
21
- "semicolon": [true, "always"],
22
- "promise-function-async": true,
23
- "no-invalid-template-strings": true,
24
- "no-floating-promises": true
25
- },
26
- "rulesDirectory": []
27
- }
1
+ {
2
+ "extends": [
3
+ "tslint:recommended"
4
+ ],
5
+ "linterOptions": {
6
+ "exclude": [
7
+ "**/buttplug-gui-proto.d.ts"
8
+ ]
9
+ },
10
+ "jsRules": {},
11
+ "rules": {
12
+ "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
13
+ "only-arrow-functions": [false],
14
+ "indent": [true, "spaces", 2],
15
+ "no-var-requires": [false],
16
+ "ordered-imports": [false],
17
+ "no-console": [false],
18
+ "object-literal-sort-keys": [false],
19
+ "max-classes-per-file": [false],
20
+ "no-bitwise": [false],
21
+ "semicolon": [true, "always"],
22
+ "promise-function-async": true,
23
+ "no-invalid-template-strings": true,
24
+ "no-floating-promises": true
25
+ },
26
+ "rulesDirectory": []
27
+ }
package/typedocconfig.js CHANGED
@@ -1,6 +1,6 @@
1
- /** @type {import('typedoc').TypeDocOptions} */
2
- module.exports = {
3
- exclude: '**/+(test|example|node_modules)/**/*.ts',
4
- excludeExternals: true,
5
- excludePrivate: true,
6
- };
1
+ /** @type {import('typedoc').TypeDocOptions} */
2
+ module.exports = {
3
+ exclude: '**/+(test|example|node_modules)/**/*.ts',
4
+ excludeExternals: true,
5
+ excludePrivate: true,
6
+ };
package/vite.config.ts CHANGED
@@ -1,26 +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
- });
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
+ });