buttplug 3.0.0-alpha.5 → 3.1.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.
Files changed (103) hide show
  1. package/.eslintrc.js +20 -20
  2. package/.github/workflows/docs.yaml +29 -0
  3. package/CHANGELOG.md +22 -2
  4. package/README.md +67 -1
  5. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +0 -3
  6. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +4 -6
  7. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
  8. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +19 -0
  9. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +22 -0
  10. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -0
  11. package/dist/main/src/core/MessageUtils.js +15 -8
  12. package/dist/main/src/core/MessageUtils.js.map +1 -1
  13. package/dist/main/src/core/Messages.d.ts +24 -9
  14. package/dist/main/src/core/Messages.js +26 -10
  15. package/dist/main/src/core/Messages.js.map +1 -1
  16. package/dist/main/src/index.d.ts +1 -0
  17. package/dist/main/src/index.js +1 -0
  18. package/dist/main/src/index.js.map +1 -1
  19. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +2 -0
  20. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +6 -2
  21. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
  22. package/dist/web/buttplug.js +413 -27
  23. package/dist/web/buttplug.min.js +1 -1
  24. package/dist/web/buttplug.min.js.map +1 -1
  25. package/doc/.nojekyll +1 -0
  26. package/doc/assets/highlight.css +22 -0
  27. package/doc/assets/main.js +58 -0
  28. package/doc/assets/search.js +1 -0
  29. package/doc/assets/style.css +1280 -0
  30. package/doc/classes/ButtplugBrowserWebsocketClientConnector.html +234 -0
  31. package/doc/classes/ButtplugClient.html +331 -0
  32. package/doc/classes/ButtplugClientConnectorException.html +216 -0
  33. package/doc/classes/ButtplugClientDevice.html +489 -0
  34. package/doc/classes/ButtplugDeviceError.html +218 -0
  35. package/doc/classes/ButtplugDeviceMessage.html +165 -0
  36. package/doc/classes/ButtplugError.html +220 -0
  37. package/doc/classes/ButtplugInitError.html +218 -0
  38. package/doc/classes/ButtplugLogger.html +288 -0
  39. package/doc/classes/ButtplugMessage.html +147 -0
  40. package/doc/classes/ButtplugMessageError.html +218 -0
  41. package/doc/classes/ButtplugMessageSorter.html +128 -0
  42. package/doc/classes/ButtplugNodeWebsocketClientConnector.html +239 -0
  43. package/doc/classes/ButtplugPingError.html +218 -0
  44. package/doc/classes/ButtplugSystemMessage.html +150 -0
  45. package/doc/classes/ButtplugUnknownError.html +218 -0
  46. package/doc/classes/DeviceAdded.html +186 -0
  47. package/doc/classes/DeviceInfo.html +114 -0
  48. package/doc/classes/DeviceList.html +160 -0
  49. package/doc/classes/DeviceRemoved.html +158 -0
  50. package/doc/classes/Error.html +179 -0
  51. package/doc/classes/GenericDeviceMessageAttributes.html +107 -0
  52. package/doc/classes/GenericMessageSubcommand.html +90 -0
  53. package/doc/classes/LinearCmd.html +187 -0
  54. package/doc/classes/LogMessage.html +134 -0
  55. package/doc/classes/MessageAttributes.html +160 -0
  56. package/doc/classes/Ok.html +151 -0
  57. package/doc/classes/Ping.html +151 -0
  58. package/doc/classes/RawDeviceMessageAttributes.html +86 -0
  59. package/doc/classes/RawReadCmd.html +188 -0
  60. package/doc/classes/RawReading.html +179 -0
  61. package/doc/classes/RawSubscribeCmd.html +170 -0
  62. package/doc/classes/RawUnsubscribeCmd.html +170 -0
  63. package/doc/classes/RawWriteCmd.html +188 -0
  64. package/doc/classes/RequestDeviceList.html +151 -0
  65. package/doc/classes/RequestServerInfo.html +169 -0
  66. package/doc/classes/RotateCmd.html +187 -0
  67. package/doc/classes/RotateSubcommand.html +108 -0
  68. package/doc/classes/ScalarCmd.html +170 -0
  69. package/doc/classes/ScalarSubcommand.html +108 -0
  70. package/doc/classes/ScanningFinished.html +146 -0
  71. package/doc/classes/SensorDeviceMessageAttributes.html +107 -0
  72. package/doc/classes/SensorReadCmd.html +179 -0
  73. package/doc/classes/SensorReading.html +188 -0
  74. package/doc/classes/ServerInfo.html +178 -0
  75. package/doc/classes/StartScanning.html +151 -0
  76. package/doc/classes/StopAllDevices.html +151 -0
  77. package/doc/classes/StopDeviceCmd.html +161 -0
  78. package/doc/classes/StopScanning.html +151 -0
  79. package/doc/classes/VectorSubcommand.html +108 -0
  80. package/doc/enums/ActuatorType.html +104 -0
  81. package/doc/enums/ButtplugLogLevel.html +97 -0
  82. package/doc/enums/ErrorClass.html +90 -0
  83. package/doc/enums/SensorType.html +90 -0
  84. package/doc/functions/FromJSON.html +113 -0
  85. package/doc/index.html +184 -0
  86. package/doc/interfaces/IButtplugClientConnector.html +137 -0
  87. package/doc/modules.html +176 -0
  88. package/doc/variables/DEFAULT_MESSAGE_ID.html +104 -0
  89. package/doc/variables/MAX_ID.html +104 -0
  90. package/doc/variables/MESSAGE_SPEC_VERSION.html +104 -0
  91. package/doc/variables/SYSTEM_MESSAGE_ID.html +104 -0
  92. package/package.json +23 -21
  93. package/src/client/ButtplugBrowserWebsocketClientConnector.ts +1 -10
  94. package/src/client/ButtplugNodeWebsocketClientConnector.ts +19 -0
  95. package/src/core/MessageUtils.ts +21 -11
  96. package/src/core/Messages.ts +51 -10
  97. package/src/index.ts +1 -0
  98. package/src/utils/ButtplugBrowserWebsocketConnector.ts +4 -2
  99. package/typedocconfig.js +6 -0
  100. package/CODE_OF_CONDUCT.md +0 -166
  101. package/CONTRIBUTING.md +0 -169
  102. package/dist/web/index.html +0 -10
  103. package/typedoc.js +0 -9
package/.eslintrc.js CHANGED
@@ -1,20 +1,20 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es2021: true,
5
- node: true,
6
- },
7
- extends: [
8
- "eslint:recommended",
9
- "plugin:@typescript-eslint/recommended",
10
- "./node_modules/gts",
11
- ],
12
- overrides: [],
13
- parser: "@typescript-eslint/parser",
14
- parserOptions: {
15
- ecmaVersion: "latest",
16
- sourceType: "module",
17
- },
18
- plugins: ["@typescript-eslint"],
19
- rules: {},
20
- };
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ node: true,
6
+ },
7
+ extends: [
8
+ "eslint:recommended",
9
+ "plugin:@typescript-eslint/recommended",
10
+ "./node_modules/gts",
11
+ ],
12
+ overrides: [],
13
+ parser: "@typescript-eslint/parser",
14
+ parserOptions: {
15
+ ecmaVersion: "latest",
16
+ sourceType: "module",
17
+ },
18
+ plugins: ["@typescript-eslint"],
19
+ rules: {},
20
+ };
@@ -0,0 +1,29 @@
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/CHANGELOG.md CHANGED
@@ -1,12 +1,32 @@
1
- # v3.0.0 (2022/12/28)
1
+ # v3.1.0 (2023/02/11)
2
+
3
+ ## Features
4
+
5
+ - Added support for Node Websockets via new connector class (#244)
6
+
7
+ ## Bugfixes
8
+
9
+ - Fixed issues with using buttplug-js in minified projects (#246)
10
+ - Changed from type-based class resolution to static naming, class name mangling should no longer
11
+ be an issue.
12
+
13
+ # v3.0.0 (2022/12/30)
14
+
15
+ ## Features
2
16
 
3
17
  - Back to pure Typescript. Back to the good shit.
18
+ - Removed server
19
+ - Brought implementation in line with the FFI Client API, so minimal changes should be needed for
20
+ porting from v1.
4
21
 
5
22
  # v2.0.0
6
23
 
24
+ ## Whatever
25
+
7
26
  - There is no buttplug-js v2
8
27
  - There is no Miss Zarves
9
- - (Version skipped to align JS and C# implementation versions)
28
+ - (Version skipped to align JS and C# implementation versions, which will probably fall out of
29
+ alignment again very quickly)
10
30
 
11
31
  # v1.0.16 (2021/10/16) (FFI Impl)
12
32
 
package/README.md CHANGED
@@ -12,7 +12,18 @@ the Version 3 Buttplug Spec. It is expected to run from a browser against either
12
12
  (GUI)](https://intiface.com/central) or [Initface Engine
13
13
  (CLI)](https://github.com/intiface/intiface-engine). No Rust FFI bindings are required.
14
14
 
15
- ## What happened? Why is buttplug-csharp back?
15
+
16
+ ## Using buttplug-js with Node
17
+
18
+ buttplug-js works with both pure web builds, as well as node applications. To use buttplug-js with node, use the `ButtplugNodeWebsocketClientConnector` class instead of the `ButtplugBrowserWebsocketClientConnector` class. That should be the only change needed, all of the API stays the same. See the Documentation section for more info.
19
+
20
+ ## Documentation
21
+
22
+ Documentation on how to use Buttplug in general, as well as examples for buttplug-js, can be found in the [Buttplug Developer Guide](https://docs.buttplug.io/docs/dev-guide).
23
+
24
+ API documentation for buttplug-js can be found at https://buttplugio.github.io/buttplug-js.
25
+
26
+ ## What happened? Why is buttplug-js back?
16
27
 
17
28
  For those of you that have been around a while, you may remember that this used to be the main
18
29
  Typescript/Javascript implementation. From 2017 to 2020, it was a reference version of the Buttplug
@@ -31,3 +42,58 @@ and server to use the FFI was overkill, and caused many extremely difficult-to-d
31
42
  that in mind, the Typescript implementation in this repo is being turned into a Client only. The
32
43
  WASM server and Embedded Connector will stay in the FFI repo, but will be another NPM package that
33
44
  will be optional.
45
+
46
+ ## Contributing
47
+
48
+ If you have issues or feature requests, [please feel free to file an issue on this repo](issues/).
49
+
50
+ We are not looking for code contributions or pull requests at this time, and will not accept pull
51
+ requests that do not have a matching issue where the matter was previously discussed. Pull requests
52
+ should only be submitted after talking to [qdot](https://github.com/qdot) via issues on this repo
53
+ (or on [discourse](https://discuss.buttplug.io) or [discord](https://discord.buttplug.io) if you
54
+ would like to stay anonymous and out of recorded info on the repo) before submitting PRs. Random PRs
55
+ without matching issues and discussion are likely to be closed without merging. and receiving
56
+ approval to develop code based on an issue. Any random or non-issue pull requests will most likely
57
+ be closed without merging.
58
+
59
+ If you'd like to contribute in a non-technical way, we need money to keep up with supporting the
60
+ latest and greatest hardware. We have multiple ways to donate!
61
+
62
+ - [Patreon](https://patreon.com/qdot)
63
+ - [Github Sponsors](https://github.com/sponsors/qdot)
64
+ - [Ko-Fi](https://ko-fi.com/qdot76367)
65
+
66
+ ## License
67
+
68
+ This project is BSD 3-Clause licensed.
69
+
70
+ ```text
71
+
72
+ Copyright (c) 2016-2023, Nonpolynomial, LLC
73
+ All rights reserved.
74
+
75
+ Redistribution and use in source and binary forms, with or without
76
+ modification, are permitted provided that the following conditions are met:
77
+
78
+ * Redistributions of source code must retain the above copyright notice, this
79
+ list of conditions and the following disclaimer.
80
+
81
+ * Redistributions in binary form must reproduce the above copyright notice,
82
+ this list of conditions and the following disclaimer in the documentation
83
+ and/or other materials provided with the distribution.
84
+
85
+ * Neither the name of buttplug nor the names of its
86
+ contributors may be used to endorse or promote products derived from
87
+ this software without specific prior written permission.
88
+
89
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
90
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
92
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
93
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
95
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
96
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
97
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
98
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
99
+ ```
@@ -10,9 +10,6 @@ import { ButtplugMessage } from '../core/Messages';
10
10
  import { ButtplugBrowserWebsocketConnector } from '../utils/ButtplugBrowserWebsocketConnector';
11
11
  export declare class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketConnector implements IButtplugClientConnector {
12
12
  private _sorter;
13
- protected _ws: WebSocket | undefined;
14
- constructor(_url: string);
15
- get Connected(): boolean;
16
13
  Send: (msg: ButtplugMessage) => Promise<ButtplugMessage>;
17
14
  protected ParseIncomingMessage: (event: MessageEvent) => void;
18
15
  protected OnReaderLoad(event: Event): void;
@@ -21,8 +21,8 @@ const MessageUtils_1 = require("../core/MessageUtils");
21
21
  const ButtplugMessageSorter_1 = require("../utils/ButtplugMessageSorter");
22
22
  const ButtplugBrowserWebsocketConnector_1 = require("../utils/ButtplugBrowserWebsocketConnector");
23
23
  class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketConnector_1.ButtplugBrowserWebsocketConnector {
24
- constructor(_url) {
25
- super(_url);
24
+ constructor() {
25
+ super(...arguments);
26
26
  this._sorter = new ButtplugMessageSorter_1.ButtplugMessageSorter(true);
27
27
  this.Send = (msg) => __awaiter(this, void 0, void 0, function* () {
28
28
  if (!this.Connected) {
@@ -33,13 +33,14 @@ class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketCo
33
33
  return yield p;
34
34
  });
35
35
  this.ParseIncomingMessage = (event) => {
36
+ var _a;
36
37
  if (typeof event.data === 'string') {
37
38
  const msgs = (0, MessageUtils_1.FromJSON)(event.data);
38
39
  const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
39
40
  this.emit('message', emitMsgs);
40
41
  }
41
42
  else if (event.data instanceof Blob) {
42
- const reader = new FileReader();
43
+ const reader = new ((_a = this._filereaderConstructor) !== null && _a !== void 0 ? _a : FileReader)();
43
44
  reader.addEventListener('load', (ev) => {
44
45
  this.OnReaderLoad(ev);
45
46
  });
@@ -47,9 +48,6 @@ class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketCo
47
48
  }
48
49
  };
49
50
  }
50
- get Connected() {
51
- return this._ws !== undefined;
52
- }
53
51
  OnReaderLoad(event) {
54
52
  const msgs = (0, MessageUtils_1.FromJSON)(event.target.result);
55
53
  const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
@@ -1 +1 @@
1
- {"version":3,"file":"ButtplugBrowserWebsocketClientConnector.js","sourceRoot":"","sources":["../../../../src/client/ButtplugBrowserWebsocketClientConnector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;AAIb,uDAAgD;AAChD,0EAAuE;AACvE,kGAA+F;AAE/F,MAAa,uCACX,SAAQ,qEAAiC;IAMzC,YAAmB,IAAY;QAC7B,KAAK,CAAC,IAAI,CAAC,CAAC;QAJN,YAAO,GAA0B,IAAI,6CAAqB,CAAC,IAAI,CAAC,CAAC;QAWlE,SAAI,GAAG,CAAO,GAAoB,EAA4B,EAAE;YACrE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;aACjD;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACnD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC,CAAC;QACjB,CAAC,CAAA,CAAC;QAEQ,yBAAoB,GAAG,CAAC,KAAmB,EAAE,EAAE;YACvD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;aAChC;iBAAM,IAAI,KAAK,CAAC,IAAI,YAAY,IAAI,EAAE;gBACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAChC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;oBACrC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC;IA3BF,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC;IAChC,CAAC;IAyBS,YAAY,CAAC,KAAY;QACjC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAE,KAAK,CAAC,MAAqB,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AA3CD,0FA2CC"}
1
+ {"version":3,"file":"ButtplugBrowserWebsocketClientConnector.js","sourceRoot":"","sources":["../../../../src/client/ButtplugBrowserWebsocketClientConnector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;AAIb,uDAAgD;AAChD,0EAAuE;AACvE,kGAA+F;AAE/F,MAAa,uCACX,SAAQ,qEAAiC;IAD3C;;QAIU,YAAO,GAA0B,IAAI,6CAAqB,CAAC,IAAI,CAAC,CAAC;QAElE,SAAI,GAAG,CAAO,GAAoB,EAA4B,EAAE;YACrE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;aACjD;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACnD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC,CAAC;QACjB,CAAC,CAAA,CAAC;QAEQ,yBAAoB,GAAG,CAAC,KAAmB,EAAE,EAAE;;YACvD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;aAChC;iBAAM,IAAI,KAAK,CAAC,IAAI,YAAY,IAAI,EAAE;gBACrC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAA,IAAI,CAAC,sBAAsB,mCAAI,UAAU,CAAC,EAAE,CAAC;gBACjE,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;oBACrC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC;IAOJ,CAAC;IALW,YAAY,CAAC,KAAY;QACjC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAE,KAAK,CAAC,MAAqB,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AAlCD,0FAkCC"}
@@ -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 { 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 CLOSED: number;
14
+ readonly CLOSING: number;
15
+ readonly CONNECTING: number;
16
+ readonly OPEN: number;
17
+ };
18
+ protected _filereaderConstructor: any;
19
+ }
@@ -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
+ 'use strict';
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ButtplugNodeWebsocketClientConnector = void 0;
11
+ const ButtplugBrowserWebsocketClientConnector_1 = require("./ButtplugBrowserWebsocketClientConnector");
12
+ const ws_1 = require("ws");
13
+ const filereader_1 = require("filereader");
14
+ class ButtplugNodeWebsocketClientConnector extends ButtplugBrowserWebsocketClientConnector_1.ButtplugBrowserWebsocketClientConnector {
15
+ constructor() {
16
+ super(...arguments);
17
+ this._websocketConstructor = ws_1.WebSocket;
18
+ this._filereaderConstructor = filereader_1.FileReader;
19
+ }
20
+ }
21
+ exports.ButtplugNodeWebsocketClientConnector = ButtplugNodeWebsocketClientConnector;
22
+ //# sourceMappingURL=ButtplugNodeWebsocketClientConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtplugNodeWebsocketClientConnector.js","sourceRoot":"","sources":["../../../../src/client/ButtplugNodeWebsocketClientConnector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;AAEb,uGAAoG;AACpG,2BAAgD;AAChD,2CAAwC;AAExC,MAAa,oCAAqC,SAAQ,iFAAuC;IAAjG;;QACY,0BAAqB,GAC7B,cAA4C,CAAC;QACrC,2BAAsB,GAAG,uBAAU,CAAC;IAChD,CAAC;CAAA;AAJD,oFAIC"}
@@ -33,18 +33,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.FromJSON = void 0;
34
34
  const class_transformer_1 = require("class-transformer");
35
35
  const Messages = __importStar(require("./Messages"));
36
+ function getMessageClass(type) {
37
+ for (const value of Object.values(Messages)) {
38
+ if (typeof value === 'function' && 'Name' in value && value.Name === type) {
39
+ return value;
40
+ }
41
+ }
42
+ return null;
43
+ }
36
44
  function FromJSON(str) {
37
45
  const msgarray = JSON.parse(str);
38
46
  const msgs = [];
39
47
  for (const x of Array.from(msgarray)) {
40
- // Can't get this to resolve nicely as a type, so just start from any and cast
41
- // after. Not sure how to resolve plainToClass to a type since this is
42
- // dynamic.
43
- //
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- const msg = (0, class_transformer_1.plainToInstance)(Messages[Object.getOwnPropertyNames(x)[0]], x[Object.getOwnPropertyNames(x)[0]]);
46
- msg.update();
47
- msgs.push(msg);
48
+ const type = Object.getOwnPropertyNames(x)[0];
49
+ const cls = getMessageClass(type);
50
+ if (cls) {
51
+ const msg = (0, class_transformer_1.plainToInstance)(cls, x[type]);
52
+ msg.update();
53
+ msgs.push(msg);
54
+ }
48
55
  }
49
56
  return msgs;
50
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MessageUtils.js","sourceRoot":"","sources":["../../../../src/core/MessageUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,yDAAoD;AACpD,qDAAuC;AAEvC,SAAgB,QAAQ,CAAC,GAAG;IAC1B,MAAM,QAAQ,GAAa,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAA+B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACpC,8EAA8E;QAC9E,sEAAsE;QACtE,WAAW;QACX,EAAE;QACF,8DAA8D;QAC9D,MAAM,GAAG,GAAQ,IAAA,mCAAe,EAC9B,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1C,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACpC,CAAC;QACD,GAAgC,CAAC,MAAM,EAAE,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,GAA+B,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAjBD,4BAiBC"}
1
+ {"version":3,"file":"MessageUtils.js","sourceRoot":"","sources":["../../../../src/core/MessageUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,yDAAoD;AACpD,qDAAuC;AAEvC,SAAS,eAAe,CACtB,IAAY;IAEZ,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC3C,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;YACzE,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAG;IAC1B,MAAM,QAAQ,GAAa,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAA+B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,GAAG,EAAE;YACP,MAAM,GAAG,GAAG,IAAA,mCAAe,EACzB,GAAG,EACH,CAAC,CAAC,IAAI,CAAC,CACR,CAAC;YACF,GAAG,CAAC,MAAM,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAChB;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,4BAgBC"}
@@ -60,15 +60,6 @@ export declare class SensorDeviceMessageAttributes {
60
60
  export declare abstract class ButtplugMessage {
61
61
  Id: number;
62
62
  constructor(Id: number);
63
- /***
64
- * Returns the message type name
65
- *
66
- * Usually, the message type name will be the same as the message class
67
- * constructor, so the constructor name is used by default. However, in
68
- * instances where a message has different versions (i.e. DeviceAddedVersion0
69
- * and DeviceAddedVersion1), we will need to override this to set the message
70
- * name.
71
- */
72
63
  get Type(): Function;
73
64
  toJSON(): string;
74
65
  toProtocolFormat(): object;
@@ -85,10 +76,12 @@ export declare abstract class ButtplugSystemMessage extends ButtplugMessage {
85
76
  }
86
77
  export declare class Ok extends ButtplugSystemMessage {
87
78
  Id: number;
79
+ static Name: string;
88
80
  constructor(Id?: number);
89
81
  }
90
82
  export declare class Ping extends ButtplugMessage {
91
83
  Id: number;
84
+ static Name: string;
92
85
  constructor(Id?: number);
93
86
  }
94
87
  export declare enum ErrorClass {
@@ -102,6 +95,7 @@ export declare class Error extends ButtplugMessage {
102
95
  ErrorMessage: string;
103
96
  ErrorCode: ErrorClass;
104
97
  Id: number;
98
+ static Name: string;
105
99
  constructor(ErrorMessage: string, ErrorCode?: ErrorClass, Id?: number);
106
100
  get Schemversion(): number;
107
101
  }
@@ -114,12 +108,14 @@ export declare class DeviceInfo {
114
108
  constructor(data: Partial<DeviceInfo>);
115
109
  }
116
110
  export declare class DeviceList extends ButtplugMessage {
111
+ static Name: string;
117
112
  Devices: DeviceInfo[];
118
113
  Id: number;
119
114
  constructor(devices: DeviceInfo[], id?: number);
120
115
  update(): void;
121
116
  }
122
117
  export declare class DeviceAdded extends ButtplugSystemMessage {
118
+ static Name: string;
123
119
  DeviceIndex: number;
124
120
  DeviceName: string;
125
121
  DeviceMessages: MessageAttributes;
@@ -130,27 +126,33 @@ export declare class DeviceAdded extends ButtplugSystemMessage {
130
126
  }
131
127
  export declare class DeviceRemoved extends ButtplugSystemMessage {
132
128
  DeviceIndex: number;
129
+ static Name: string;
133
130
  constructor(DeviceIndex: number);
134
131
  }
135
132
  export declare class RequestDeviceList extends ButtplugMessage {
136
133
  Id: number;
134
+ static Name: string;
137
135
  constructor(Id?: number);
138
136
  }
139
137
  export declare class StartScanning extends ButtplugMessage {
140
138
  Id: number;
139
+ static Name: string;
141
140
  constructor(Id?: number);
142
141
  }
143
142
  export declare class StopScanning extends ButtplugMessage {
144
143
  Id: number;
144
+ static Name: string;
145
145
  constructor(Id?: number);
146
146
  }
147
147
  export declare class ScanningFinished extends ButtplugSystemMessage {
148
+ static Name: string;
148
149
  constructor();
149
150
  }
150
151
  export declare class RequestServerInfo extends ButtplugMessage {
151
152
  ClientName: string;
152
153
  MessageVersion: number;
153
154
  Id: number;
155
+ static Name: string;
154
156
  constructor(ClientName: string, MessageVersion?: number, Id?: number);
155
157
  }
156
158
  export declare class ServerInfo extends ButtplugSystemMessage {
@@ -158,15 +160,18 @@ export declare class ServerInfo extends ButtplugSystemMessage {
158
160
  MaxPingTime: number;
159
161
  ServerName: string;
160
162
  Id: number;
163
+ static Name: string;
161
164
  constructor(MessageVersion: number, MaxPingTime: number, ServerName: string, Id?: number);
162
165
  }
163
166
  export declare class StopDeviceCmd extends ButtplugDeviceMessage {
164
167
  DeviceIndex: number;
165
168
  Id: number;
169
+ static Name: string;
166
170
  constructor(DeviceIndex?: number, Id?: number);
167
171
  }
168
172
  export declare class StopAllDevices extends ButtplugMessage {
169
173
  Id: number;
174
+ static Name: string;
170
175
  constructor(Id?: number);
171
176
  }
172
177
  export declare class GenericMessageSubcommand {
@@ -182,6 +187,7 @@ export declare class ScalarCmd extends ButtplugDeviceMessage {
182
187
  Scalars: ScalarSubcommand[];
183
188
  DeviceIndex: number;
184
189
  Id: number;
190
+ static Name: string;
185
191
  constructor(Scalars: ScalarSubcommand[], DeviceIndex?: number, Id?: number);
186
192
  }
187
193
  export declare class RotateSubcommand extends GenericMessageSubcommand {
@@ -193,6 +199,7 @@ export declare class RotateCmd extends ButtplugDeviceMessage {
193
199
  Rotations: RotateSubcommand[];
194
200
  DeviceIndex: number;
195
201
  Id: number;
202
+ static Name: string;
196
203
  static Create(deviceIndex: number, commands: [number, boolean][]): RotateCmd;
197
204
  constructor(Rotations: RotateSubcommand[], DeviceIndex?: number, Id?: number);
198
205
  }
@@ -205,6 +212,7 @@ export declare class LinearCmd extends ButtplugDeviceMessage {
205
212
  Vectors: VectorSubcommand[];
206
213
  DeviceIndex: number;
207
214
  Id: number;
215
+ static Name: string;
208
216
  static Create(deviceIndex: number, commands: [number, number][]): LinearCmd;
209
217
  constructor(Vectors: VectorSubcommand[], DeviceIndex?: number, Id?: number);
210
218
  }
@@ -213,6 +221,7 @@ export declare class SensorReadCmd extends ButtplugDeviceMessage {
213
221
  SensorIndex: number;
214
222
  SensorType: SensorType;
215
223
  Id: number;
224
+ static Name: string;
216
225
  constructor(DeviceIndex: number, SensorIndex: number, SensorType: SensorType, Id?: number);
217
226
  }
218
227
  export declare class SensorReading extends ButtplugDeviceMessage {
@@ -221,6 +230,7 @@ export declare class SensorReading extends ButtplugDeviceMessage {
221
230
  SensorType: SensorType;
222
231
  Data: number[];
223
232
  Id: number;
233
+ static Name: string;
224
234
  constructor(DeviceIndex: number, SensorIndex: number, SensorType: SensorType, Data: number[], Id?: number);
225
235
  }
226
236
  export declare class RawReadCmd extends ButtplugDeviceMessage {
@@ -229,6 +239,7 @@ export declare class RawReadCmd extends ButtplugDeviceMessage {
229
239
  ExpectedLength: number;
230
240
  Timeout: number;
231
241
  Id: number;
242
+ static Name: string;
232
243
  constructor(DeviceIndex: number, Endpoint: string, ExpectedLength: number, Timeout: number, Id?: number);
233
244
  }
234
245
  export declare class RawWriteCmd extends ButtplugDeviceMessage {
@@ -237,18 +248,21 @@ export declare class RawWriteCmd extends ButtplugDeviceMessage {
237
248
  Data: Uint8Array;
238
249
  WriteWithResponse: boolean;
239
250
  Id: number;
251
+ static Name: string;
240
252
  constructor(DeviceIndex: number, Endpoint: string, Data: Uint8Array, WriteWithResponse: boolean, Id?: number);
241
253
  }
242
254
  export declare class RawSubscribeCmd extends ButtplugDeviceMessage {
243
255
  DeviceIndex: number;
244
256
  Endpoint: string;
245
257
  Id: number;
258
+ static Name: string;
246
259
  constructor(DeviceIndex: number, Endpoint: string, Id?: number);
247
260
  }
248
261
  export declare class RawUnsubscribeCmd extends ButtplugDeviceMessage {
249
262
  DeviceIndex: number;
250
263
  Endpoint: string;
251
264
  Id: number;
265
+ static Name: string;
252
266
  constructor(DeviceIndex: number, Endpoint: string, Id?: number);
253
267
  }
254
268
  export declare class RawReading extends ButtplugDeviceMessage {
@@ -256,5 +270,6 @@ export declare class RawReading extends ButtplugDeviceMessage {
256
270
  Endpoint: string;
257
271
  Data: number[];
258
272
  Id: number;
273
+ static Name: string;
259
274
  constructor(DeviceIndex: number, Endpoint: string, Data: number[], Id?: number);
260
275
  }