buttplug 3.2.1 → 4.0.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 (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 -1
  6. package/CHANGELOG.md +577 -571
  7. package/LICENSE +27 -27
  8. package/README.md +97 -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 +227 -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 +118 -228
  33. package/dist/main/src/core/Messages.js +51 -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 +118 -227
  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 +209 -480
  95. package/src/core/index.d.ts +4 -4
  96. package/src/index.ts +21 -19
  97. package/src/utils/ButtplugBrowserWebsocketConnector.ts +89 -92
  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
@@ -1,136 +1,130 @@
1
- var rt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function Dt(r) {
3
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
4
- }
5
- var at = { exports: {} };
6
- (function(r) {
7
- var e = Object.prototype.hasOwnProperty, t = "~";
8
- function n() {
9
- }
10
- Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (t = !1));
11
- function i(l, v, p) {
12
- this.fn = l, this.context = v, this.once = p || !1;
13
- }
14
- function u(l, v, p, m, h) {
15
- if (typeof p != "function")
16
- throw new TypeError("The listener must be a function");
17
- var R = new i(p, m || l, h), E = t ? t + v : v;
18
- return l._events[E] ? l._events[E].fn ? l._events[E] = [l._events[E], R] : l._events[E].push(R) : (l._events[E] = R, l._eventsCount++), l;
19
- }
20
- function a(l, v) {
21
- --l._eventsCount === 0 ? l._events = new n() : delete l._events[v];
22
- }
23
- function f() {
24
- this._events = new n(), this._eventsCount = 0;
25
- }
26
- f.prototype.eventNames = function() {
27
- var v = [], p, m;
28
- if (this._eventsCount === 0)
29
- return v;
30
- for (m in p = this._events)
31
- e.call(p, m) && v.push(t ? m.slice(1) : m);
32
- return Object.getOwnPropertySymbols ? v.concat(Object.getOwnPropertySymbols(p)) : v;
33
- }, f.prototype.listeners = function(v) {
34
- var p = t ? t + v : v, m = this._events[p];
35
- if (!m)
36
- return [];
37
- if (m.fn)
38
- return [m.fn];
39
- for (var h = 0, R = m.length, E = new Array(R); h < R; h++)
40
- E[h] = m[h].fn;
41
- return E;
42
- }, f.prototype.listenerCount = function(v) {
43
- var p = t ? t + v : v, m = this._events[p];
44
- return m ? m.fn ? 1 : m.length : 0;
45
- }, f.prototype.emit = function(v, p, m, h, R, E) {
46
- var $ = t ? t + v : v;
47
- if (!this._events[$])
48
- return !1;
49
- var g = this._events[$], I = arguments.length, O, S;
50
- if (g.fn) {
51
- switch (g.once && this.removeListener(v, g.fn, void 0, !0), I) {
52
- case 1:
53
- return g.fn.call(g.context), !0;
54
- case 2:
55
- return g.fn.call(g.context, p), !0;
56
- case 3:
57
- return g.fn.call(g.context, p, m), !0;
58
- case 4:
59
- return g.fn.call(g.context, p, m, h), !0;
60
- case 5:
61
- return g.fn.call(g.context, p, m, h, R), !0;
62
- case 6:
63
- return g.fn.call(g.context, p, m, h, R, E), !0;
64
- }
65
- for (S = 1, O = new Array(I - 1); S < I; S++)
66
- O[S - 1] = arguments[S];
67
- g.fn.apply(g.context, O);
68
- } else {
69
- var W = g.length, C;
70
- for (S = 0; S < W; S++)
71
- switch (g[S].once && this.removeListener(v, g[S].fn, void 0, !0), I) {
1
+ function U(s) {
2
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
3
+ }
4
+ var k = { exports: {} }, A;
5
+ function j() {
6
+ return A || (A = 1, (function(s) {
7
+ var e = Object.prototype.hasOwnProperty, t = "~";
8
+ function n() {
9
+ }
10
+ Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (t = !1));
11
+ function a(u, i, o) {
12
+ this.fn = u, this.context = i, this.once = o || !1;
13
+ }
14
+ function g(u, i, o, c, v) {
15
+ if (typeof o != "function")
16
+ throw new TypeError("The listener must be a function");
17
+ var p = new a(o, c || u, v), h = t ? t + i : i;
18
+ return u._events[h] ? u._events[h].fn ? u._events[h] = [u._events[h], p] : u._events[h].push(p) : (u._events[h] = p, u._eventsCount++), u;
19
+ }
20
+ function l(u, i) {
21
+ --u._eventsCount === 0 ? u._events = new n() : delete u._events[i];
22
+ }
23
+ function f() {
24
+ this._events = new n(), this._eventsCount = 0;
25
+ }
26
+ f.prototype.eventNames = function() {
27
+ var i = [], o, c;
28
+ if (this._eventsCount === 0) return i;
29
+ for (c in o = this._events)
30
+ e.call(o, c) && i.push(t ? c.slice(1) : c);
31
+ return Object.getOwnPropertySymbols ? i.concat(Object.getOwnPropertySymbols(o)) : i;
32
+ }, f.prototype.listeners = function(i) {
33
+ var o = t ? t + i : i, c = this._events[o];
34
+ if (!c) return [];
35
+ if (c.fn) return [c.fn];
36
+ for (var v = 0, p = c.length, h = new Array(p); v < p; v++)
37
+ h[v] = c[v].fn;
38
+ return h;
39
+ }, f.prototype.listenerCount = function(i) {
40
+ var o = t ? t + i : i, c = this._events[o];
41
+ return c ? c.fn ? 1 : c.length : 0;
42
+ }, f.prototype.emit = function(i, o, c, v, p, h) {
43
+ var I = t ? t + i : i;
44
+ if (!this._events[I]) return !1;
45
+ var r = this._events[I], M = arguments.length, y, d;
46
+ if (r.fn) {
47
+ switch (r.once && this.removeListener(i, r.fn, void 0, !0), M) {
72
48
  case 1:
73
- g[S].fn.call(g[S].context);
74
- break;
49
+ return r.fn.call(r.context), !0;
75
50
  case 2:
76
- g[S].fn.call(g[S].context, p);
77
- break;
51
+ return r.fn.call(r.context, o), !0;
78
52
  case 3:
79
- g[S].fn.call(g[S].context, p, m);
80
- break;
53
+ return r.fn.call(r.context, o, c), !0;
81
54
  case 4:
82
- g[S].fn.call(g[S].context, p, m, h);
83
- break;
84
- default:
85
- if (!O)
86
- for (C = 1, O = new Array(I - 1); C < I; C++)
87
- O[C - 1] = arguments[C];
88
- g[S].fn.apply(g[S].context, O);
55
+ return r.fn.call(r.context, o, c, v), !0;
56
+ case 5:
57
+ return r.fn.call(r.context, o, c, v, p), !0;
58
+ case 6:
59
+ return r.fn.call(r.context, o, c, v, p, h), !0;
89
60
  }
90
- }
91
- return !0;
92
- }, f.prototype.on = function(v, p, m) {
93
- return u(this, v, p, m, !1);
94
- }, f.prototype.once = function(v, p, m) {
95
- return u(this, v, p, m, !0);
96
- }, f.prototype.removeListener = function(v, p, m, h) {
97
- var R = t ? t + v : v;
98
- if (!this._events[R])
61
+ for (d = 1, y = new Array(M - 1); d < M; d++)
62
+ y[d - 1] = arguments[d];
63
+ r.fn.apply(r.context, y);
64
+ } else {
65
+ var T = r.length, S;
66
+ for (d = 0; d < T; d++)
67
+ switch (r[d].once && this.removeListener(i, r[d].fn, void 0, !0), M) {
68
+ case 1:
69
+ r[d].fn.call(r[d].context);
70
+ break;
71
+ case 2:
72
+ r[d].fn.call(r[d].context, o);
73
+ break;
74
+ case 3:
75
+ r[d].fn.call(r[d].context, o, c);
76
+ break;
77
+ case 4:
78
+ r[d].fn.call(r[d].context, o, c, v);
79
+ break;
80
+ default:
81
+ if (!y) for (S = 1, y = new Array(M - 1); S < M; S++)
82
+ y[S - 1] = arguments[S];
83
+ r[d].fn.apply(r[d].context, y);
84
+ }
85
+ }
86
+ return !0;
87
+ }, f.prototype.on = function(i, o, c) {
88
+ return g(this, i, o, c, !1);
89
+ }, f.prototype.once = function(i, o, c) {
90
+ return g(this, i, o, c, !0);
91
+ }, f.prototype.removeListener = function(i, o, c, v) {
92
+ var p = t ? t + i : i;
93
+ if (!this._events[p]) return this;
94
+ if (!o)
95
+ return l(this, p), this;
96
+ var h = this._events[p];
97
+ if (h.fn)
98
+ h.fn === o && (!v || h.once) && (!c || h.context === c) && l(this, p);
99
+ else {
100
+ for (var I = 0, r = [], M = h.length; I < M; I++)
101
+ (h[I].fn !== o || v && !h[I].once || c && h[I].context !== c) && r.push(h[I]);
102
+ r.length ? this._events[p] = r.length === 1 ? r[0] : r : l(this, p);
103
+ }
99
104
  return this;
100
- if (!p)
101
- return a(this, R), this;
102
- var E = this._events[R];
103
- if (E.fn)
104
- E.fn === p && (!h || E.once) && (!m || E.context === m) && a(this, R);
105
- else {
106
- for (var $ = 0, g = [], I = E.length; $ < I; $++)
107
- (E[$].fn !== p || h && !E[$].once || m && E[$].context !== m) && g.push(E[$]);
108
- g.length ? this._events[R] = g.length === 1 ? g[0] : g : a(this, R);
109
- }
110
- return this;
111
- }, f.prototype.removeAllListeners = function(v) {
112
- var p;
113
- return v ? (p = t ? t + v : v, this._events[p] && a(this, p)) : (this._events = new n(), this._eventsCount = 0), this;
114
- }, f.prototype.off = f.prototype.removeListener, f.prototype.addListener = f.prototype.on, f.prefixed = t, f.EventEmitter = f, r.exports = f;
115
- })(at);
116
- var Nt = at.exports;
117
- const ve = /* @__PURE__ */ Dt(Nt);
118
- /*!
119
- * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
120
- * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
121
- * project root for full license information.
122
- *
123
- * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
124
- */
125
- var ct = /* @__PURE__ */ ((r) => (r[r.Off = 0] = "Off", r[r.Error = 1] = "Error", r[r.Warn = 2] = "Warn", r[r.Info = 3] = "Info", r[r.Debug = 4] = "Debug", r[r.Trace = 5] = "Trace", r))(ct || {});
126
- class Tt {
105
+ }, f.prototype.removeAllListeners = function(i) {
106
+ var o;
107
+ return i ? (o = t ? t + i : i, this._events[o] && l(this, o)) : (this._events = new n(), this._eventsCount = 0), this;
108
+ }, f.prototype.off = f.prototype.removeListener, f.prototype.addListener = f.prototype.on, f.prefixed = t, f.EventEmitter = f, s.exports = f;
109
+ })(k)), k.exports;
110
+ }
111
+ var q = j();
112
+ const P = /* @__PURE__ */ U(q);
113
+ var V = /* @__PURE__ */ ((s) => (s[s.Off = 0] = "Off", s[s.Error = 1] = "Error", s[s.Warn = 2] = "Warn", s[s.Info = 3] = "Info", s[s.Debug = 4] = "Debug", s[s.Trace = 5] = "Trace", s))(V || {});
114
+ class J {
115
+ /** Timestamp for the log message */
116
+ timestamp;
117
+ /** Log Message */
118
+ logMessage;
119
+ /** Log Level */
120
+ logLevel;
127
121
  /**
128
122
  * @param logMessage Log message.
129
123
  * @param logLevel: Log severity level.
130
124
  */
131
125
  constructor(e, t) {
132
- const n = /* @__PURE__ */ new Date(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds();
133
- this.timestamp = `${i}:${u}:${a}`, this.logMessage = e, this.logLevel = t;
126
+ const n = /* @__PURE__ */ new Date(), a = n.getHours(), g = n.getMinutes(), l = n.getSeconds();
127
+ this.timestamp = `${a}:${g}:${l}`, this.logMessage = e, this.logLevel = t;
134
128
  }
135
129
  /**
136
130
  * Returns the log message.
@@ -154,23 +148,29 @@ class Tt {
154
148
  * Returns a formatted string with timestamp, level, and message.
155
149
  */
156
150
  get FormattedMessage() {
157
- return `${ct[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
151
+ return `${V[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
158
152
  }
159
153
  }
160
- const ut = class le extends ve {
161
- /**
162
- * Constructor. Can only be called internally since we regulate ButtplugLogger
163
- * ownership.
164
- */
165
- constructor() {
166
- super(), this.maximumConsoleLogLevel = 0, this.maximumEventLogLevel = 0;
167
- }
154
+ class b extends P {
155
+ /** Singleton instance for the logger */
156
+ static sLogger = void 0;
157
+ /** Sets maximum log level to log to console */
158
+ maximumConsoleLogLevel = 0;
159
+ /** Sets maximum log level for all log messages */
160
+ maximumEventLogLevel = 0;
168
161
  /**
169
162
  * Returns the stored static instance of the logger, creating one if it
170
163
  * doesn't currently exist.
171
164
  */
172
165
  static get Logger() {
173
- return le.sLogger === void 0 && (le.sLogger = new le()), this.sLogger;
166
+ return b.sLogger === void 0 && (b.sLogger = new b()), this.sLogger;
167
+ }
168
+ /**
169
+ * Constructor. Can only be called internally since we regulate ButtplugLogger
170
+ * ownership.
171
+ */
172
+ constructor() {
173
+ super();
174
174
  }
175
175
  /**
176
176
  * Set the maximum log level to output to console.
@@ -253,1339 +253,11 @@ const ut = class le extends ve {
253
253
  AddLogMessage(e, t) {
254
254
  if (t > this.maximumEventLogLevel && t > this.maximumConsoleLogLevel)
255
255
  return;
256
- const n = new Tt(e, t);
256
+ const n = new J(e, t);
257
257
  t <= this.maximumConsoleLogLevel && console.log(n.FormattedMessage), t <= this.maximumEventLogLevel && this.emit("log", n);
258
258
  }
259
- };
260
- ut.sLogger = void 0;
261
- let Pt = ut;
262
- var b;
263
- (function(r) {
264
- r[r.PLAIN_TO_CLASS = 0] = "PLAIN_TO_CLASS", r[r.CLASS_TO_PLAIN = 1] = "CLASS_TO_PLAIN", r[r.CLASS_TO_CLASS = 2] = "CLASS_TO_CLASS";
265
- })(b || (b = {}));
266
- var kt = (
267
- /** @class */
268
- function() {
269
- function r() {
270
- this._typeMetadatas = /* @__PURE__ */ new Map(), this._transformMetadatas = /* @__PURE__ */ new Map(), this._exposeMetadatas = /* @__PURE__ */ new Map(), this._excludeMetadatas = /* @__PURE__ */ new Map(), this._ancestorsMap = /* @__PURE__ */ new Map();
271
- }
272
- return r.prototype.addTypeMetadata = function(e) {
273
- this._typeMetadatas.has(e.target) || this._typeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._typeMetadatas.get(e.target).set(e.propertyName, e);
274
- }, r.prototype.addTransformMetadata = function(e) {
275
- this._transformMetadatas.has(e.target) || this._transformMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._transformMetadatas.get(e.target).has(e.propertyName) || this._transformMetadatas.get(e.target).set(e.propertyName, []), this._transformMetadatas.get(e.target).get(e.propertyName).push(e);
276
- }, r.prototype.addExposeMetadata = function(e) {
277
- this._exposeMetadatas.has(e.target) || this._exposeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._exposeMetadatas.get(e.target).set(e.propertyName, e);
278
- }, r.prototype.addExcludeMetadata = function(e) {
279
- this._excludeMetadatas.has(e.target) || this._excludeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._excludeMetadatas.get(e.target).set(e.propertyName, e);
280
- }, r.prototype.findTransformMetadatas = function(e, t, n) {
281
- return this.findMetadatas(this._transformMetadatas, e, t).filter(function(i) {
282
- return !i.options || i.options.toClassOnly === !0 && i.options.toPlainOnly === !0 ? !0 : i.options.toClassOnly === !0 ? n === b.CLASS_TO_CLASS || n === b.PLAIN_TO_CLASS : i.options.toPlainOnly === !0 ? n === b.CLASS_TO_PLAIN : !0;
283
- });
284
- }, r.prototype.findExcludeMetadata = function(e, t) {
285
- return this.findMetadata(this._excludeMetadatas, e, t);
286
- }, r.prototype.findExposeMetadata = function(e, t) {
287
- return this.findMetadata(this._exposeMetadatas, e, t);
288
- }, r.prototype.findExposeMetadataByCustomName = function(e, t) {
289
- return this.getExposedMetadatas(e).find(function(n) {
290
- return n.options && n.options.name === t;
291
- });
292
- }, r.prototype.findTypeMetadata = function(e, t) {
293
- return this.findMetadata(this._typeMetadatas, e, t);
294
- }, r.prototype.getStrategy = function(e) {
295
- var t = this._excludeMetadatas.get(e), n = t && t.get(void 0), i = this._exposeMetadatas.get(e), u = i && i.get(void 0);
296
- return n && u || !n && !u ? "none" : n ? "excludeAll" : "exposeAll";
297
- }, r.prototype.getExposedMetadatas = function(e) {
298
- return this.getMetadata(this._exposeMetadatas, e);
299
- }, r.prototype.getExcludedMetadatas = function(e) {
300
- return this.getMetadata(this._excludeMetadatas, e);
301
- }, r.prototype.getExposedProperties = function(e, t) {
302
- return this.getExposedMetadatas(e).filter(function(n) {
303
- return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === b.CLASS_TO_CLASS || t === b.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === b.CLASS_TO_PLAIN : !0;
304
- }).map(function(n) {
305
- return n.propertyName;
306
- });
307
- }, r.prototype.getExcludedProperties = function(e, t) {
308
- return this.getExcludedMetadatas(e).filter(function(n) {
309
- return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === b.CLASS_TO_CLASS || t === b.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === b.CLASS_TO_PLAIN : !0;
310
- }).map(function(n) {
311
- return n.propertyName;
312
- });
313
- }, r.prototype.clear = function() {
314
- this._typeMetadatas.clear(), this._exposeMetadatas.clear(), this._excludeMetadatas.clear(), this._ancestorsMap.clear();
315
- }, r.prototype.getMetadata = function(e, t) {
316
- var n = e.get(t), i;
317
- n && (i = Array.from(n.values()).filter(function(m) {
318
- return m.propertyName !== void 0;
319
- }));
320
- for (var u = [], a = 0, f = this.getAncestors(t); a < f.length; a++) {
321
- var l = f[a], v = e.get(l);
322
- if (v) {
323
- var p = Array.from(v.values()).filter(function(m) {
324
- return m.propertyName !== void 0;
325
- });
326
- u.push.apply(u, p);
327
- }
328
- }
329
- return u.concat(i || []);
330
- }, r.prototype.findMetadata = function(e, t, n) {
331
- var i = e.get(t);
332
- if (i) {
333
- var u = i.get(n);
334
- if (u)
335
- return u;
336
- }
337
- for (var a = 0, f = this.getAncestors(t); a < f.length; a++) {
338
- var l = f[a], v = e.get(l);
339
- if (v) {
340
- var p = v.get(n);
341
- if (p)
342
- return p;
343
- }
344
- }
345
- }, r.prototype.findMetadatas = function(e, t, n) {
346
- var i = e.get(t), u;
347
- i && (u = i.get(n));
348
- for (var a = [], f = 0, l = this.getAncestors(t); f < l.length; f++) {
349
- var v = l[f], p = e.get(v);
350
- p && p.has(n) && a.push.apply(a, p.get(n));
351
- }
352
- return a.slice().reverse().concat((u || []).slice().reverse());
353
- }, r.prototype.getAncestors = function(e) {
354
- if (!e)
355
- return [];
356
- if (!this._ancestorsMap.has(e)) {
357
- for (var t = [], n = Object.getPrototypeOf(e.prototype.constructor); typeof n.prototype < "u"; n = Object.getPrototypeOf(n.prototype.constructor))
358
- t.push(n);
359
- this._ancestorsMap.set(e, t);
360
- }
361
- return this._ancestorsMap.get(e);
362
- }, r;
363
- }()
364
- ), F = new kt();
365
- function jt() {
366
- if (typeof globalThis < "u")
367
- return globalThis;
368
- if (typeof global < "u")
369
- return global;
370
- if (typeof window < "u")
371
- return window;
372
- if (typeof self < "u")
373
- return self;
374
- }
375
- function Bt(r) {
376
- return r !== null && typeof r == "object" && typeof r.then == "function";
377
- }
378
- var st = globalThis && globalThis.__spreadArray || function(r, e, t) {
379
- if (t || arguments.length === 2)
380
- for (var n = 0, i = e.length, u; n < i; n++)
381
- (u || !(n in e)) && (u || (u = Array.prototype.slice.call(e, 0, n)), u[n] = e[n]);
382
- return r.concat(u || Array.prototype.slice.call(e));
383
- };
384
- function $t(r) {
385
- var e = new r();
386
- return !(e instanceof Set) && !("push" in e) ? [] : e;
387
- }
388
- var oe = (
389
- /** @class */
390
- function() {
391
- function r(e, t) {
392
- this.transformationType = e, this.options = t, this.recursionStack = /* @__PURE__ */ new Set();
393
- }
394
- return r.prototype.transform = function(e, t, n, i, u, a) {
395
- var f = this;
396
- if (a === void 0 && (a = 0), Array.isArray(t) || t instanceof Set) {
397
- var l = i && this.transformationType === b.PLAIN_TO_CLASS ? $t(i) : [];
398
- return t.forEach(function(g, I) {
399
- var O = e ? e[I] : void 0;
400
- if (!f.options.enableCircularCheck || !f.isCircular(g)) {
401
- var S = void 0;
402
- if (typeof n != "function" && n && n.options && n.options.discriminator && n.options.discriminator.property && n.options.discriminator.subTypes) {
403
- if (f.transformationType === b.PLAIN_TO_CLASS) {
404
- S = n.options.discriminator.subTypes.find(function(Y) {
405
- return Y.name === g[n.options.discriminator.property];
406
- });
407
- var W = { newObject: l, object: g, property: void 0 }, C = n.typeFunction(W);
408
- S === void 0 ? S = C : S = S.value, n.options.keepDiscriminatorProperty || delete g[n.options.discriminator.property];
409
- }
410
- f.transformationType === b.CLASS_TO_CLASS && (S = g.constructor), f.transformationType === b.CLASS_TO_PLAIN && (g[n.options.discriminator.property] = n.options.discriminator.subTypes.find(function(Y) {
411
- return Y.value === g.constructor;
412
- }).name);
413
- } else
414
- S = n;
415
- var k = f.transform(O, g, S, void 0, g instanceof Map, a + 1);
416
- l instanceof Set ? l.add(k) : l.push(k);
417
- } else
418
- f.transformationType === b.CLASS_TO_CLASS && (l instanceof Set ? l.add(g) : l.push(g));
419
- }), l;
420
- } else {
421
- if (n === String && !u)
422
- return t == null ? t : String(t);
423
- if (n === Number && !u)
424
- return t == null ? t : Number(t);
425
- if (n === Boolean && !u)
426
- return t == null ? t : !!t;
427
- if ((n === Date || t instanceof Date) && !u)
428
- return t instanceof Date ? new Date(t.valueOf()) : t == null ? t : new Date(t);
429
- if (jt().Buffer && (n === Buffer || t instanceof Buffer) && !u)
430
- return t == null ? t : Buffer.from(t);
431
- if (Bt(t) && !u)
432
- return new Promise(function(g, I) {
433
- t.then(function(O) {
434
- return g(f.transform(void 0, O, n, void 0, void 0, a + 1));
435
- }, I);
436
- });
437
- if (!u && t !== null && typeof t == "object" && typeof t.then == "function")
438
- return t;
439
- if (typeof t == "object" && t !== null) {
440
- !n && t.constructor !== Object && (!Array.isArray(t) && t.constructor === Array || (n = t.constructor)), !n && e && (n = e.constructor), this.options.enableCircularCheck && this.recursionStack.add(t);
441
- var v = this.getKeys(n, t, u), p = e || {};
442
- !e && (this.transformationType === b.PLAIN_TO_CLASS || this.transformationType === b.CLASS_TO_CLASS) && (u ? p = /* @__PURE__ */ new Map() : n ? p = new n() : p = {});
443
- for (var m = function(g) {
444
- if (g === "__proto__" || g === "constructor")
445
- return "continue";
446
- var I = g, O = g, S = g;
447
- if (!h.options.ignoreDecorators && n) {
448
- if (h.transformationType === b.PLAIN_TO_CLASS) {
449
- var W = F.findExposeMetadataByCustomName(n, g);
450
- W && (S = W.propertyName, O = W.propertyName);
451
- } else if (h.transformationType === b.CLASS_TO_PLAIN || h.transformationType === b.CLASS_TO_CLASS) {
452
- var W = F.findExposeMetadata(n, g);
453
- W && W.options && W.options.name && (O = W.options.name);
454
- }
455
- }
456
- var C = void 0;
457
- h.transformationType === b.PLAIN_TO_CLASS ? C = t[I] : t instanceof Map ? C = t.get(I) : t[I] instanceof Function ? C = t[I]() : C = t[I];
458
- var k = void 0, Y = C instanceof Map;
459
- if (n && u)
460
- k = n;
461
- else if (n) {
462
- var N = F.findTypeMetadata(n, S);
463
- if (N) {
464
- var Me = { newObject: p, object: t, property: S }, he = N.typeFunction ? N.typeFunction(Me) : N.reflectedType;
465
- N.options && N.options.discriminator && N.options.discriminator.property && N.options.discriminator.subTypes ? t[I] instanceof Array ? k = N : (h.transformationType === b.PLAIN_TO_CLASS && (k = N.options.discriminator.subTypes.find(function(q) {
466
- if (C && C instanceof Object && N.options.discriminator.property in C)
467
- return q.name === C[N.options.discriminator.property];
468
- }), k === void 0 ? k = he : k = k.value, N.options.keepDiscriminatorProperty || C && C instanceof Object && N.options.discriminator.property in C && delete C[N.options.discriminator.property]), h.transformationType === b.CLASS_TO_CLASS && (k = C.constructor), h.transformationType === b.CLASS_TO_PLAIN && C && (C[N.options.discriminator.property] = N.options.discriminator.subTypes.find(function(q) {
469
- return q.value === C.constructor;
470
- }).name)) : k = he, Y = Y || N.reflectedType === Map;
471
- } else if (h.options.targetMaps)
472
- h.options.targetMaps.filter(function(q) {
473
- return q.target === n && !!q.properties[S];
474
- }).forEach(function(q) {
475
- return k = q.properties[S];
476
- });
477
- else if (h.options.enableImplicitConversion && h.transformationType === b.PLAIN_TO_CLASS) {
478
- var pe = Reflect.getMetadata("design:type", n.prototype, S);
479
- pe && (k = pe);
480
- }
481
- }
482
- var K = Array.isArray(t[I]) ? h.getReflectedType(n, S) : void 0, fe = e ? e[I] : void 0;
483
- if (p.constructor.prototype) {
484
- var re = Object.getOwnPropertyDescriptor(p.constructor.prototype, O);
485
- if ((h.transformationType === b.PLAIN_TO_CLASS || h.transformationType === b.CLASS_TO_CLASS) && // eslint-disable-next-line @typescript-eslint/unbound-method
486
- (re && !re.set || p[O] instanceof Function))
487
- return "continue";
488
- }
489
- if (!h.options.enableCircularCheck || !h.isCircular(C)) {
490
- var te = h.transformationType === b.PLAIN_TO_CLASS ? O : g, L = void 0;
491
- h.transformationType === b.CLASS_TO_PLAIN ? (L = t[te], L = h.applyCustomTransformations(L, n, te, t, h.transformationType), L = t[te] === L ? C : L, L = h.transform(fe, L, k, K, Y, a + 1)) : C === void 0 && h.options.exposeDefaultValues ? L = p[O] : (L = h.transform(fe, C, k, K, Y, a + 1), L = h.applyCustomTransformations(L, n, te, t, h.transformationType)), (L !== void 0 || h.options.exposeUnsetFields) && (p instanceof Map ? p.set(O, L) : p[O] = L);
492
- } else if (h.transformationType === b.CLASS_TO_CLASS) {
493
- var L = C;
494
- L = h.applyCustomTransformations(L, n, g, t, h.transformationType), (L !== void 0 || h.options.exposeUnsetFields) && (p instanceof Map ? p.set(O, L) : p[O] = L);
495
- }
496
- }, h = this, R = 0, E = v; R < E.length; R++) {
497
- var $ = E[R];
498
- m($);
499
- }
500
- return this.options.enableCircularCheck && this.recursionStack.delete(t), p;
501
- } else
502
- return t;
503
- }
504
- }, r.prototype.applyCustomTransformations = function(e, t, n, i, u) {
505
- var a = this, f = F.findTransformMetadatas(t, n, this.transformationType);
506
- return this.options.version !== void 0 && (f = f.filter(function(l) {
507
- return l.options ? a.checkVersion(l.options.since, l.options.until) : !0;
508
- })), this.options.groups && this.options.groups.length ? f = f.filter(function(l) {
509
- return l.options ? a.checkGroups(l.options.groups) : !0;
510
- }) : f = f.filter(function(l) {
511
- return !l.options || !l.options.groups || !l.options.groups.length;
512
- }), f.forEach(function(l) {
513
- e = l.transformFn({ value: e, key: n, obj: i, type: u, options: a.options });
514
- }), e;
515
- }, r.prototype.isCircular = function(e) {
516
- return this.recursionStack.has(e);
517
- }, r.prototype.getReflectedType = function(e, t) {
518
- if (e) {
519
- var n = F.findTypeMetadata(e, t);
520
- return n ? n.reflectedType : void 0;
521
- }
522
- }, r.prototype.getKeys = function(e, t, n) {
523
- var i = this, u = F.getStrategy(e);
524
- u === "none" && (u = this.options.strategy || "exposeAll");
525
- var a = [];
526
- if ((u === "exposeAll" || n) && (t instanceof Map ? a = Array.from(t.keys()) : a = Object.keys(t)), n)
527
- return a;
528
- if (this.options.ignoreDecorators && this.options.excludeExtraneousValues && e) {
529
- var f = F.getExposedProperties(e, this.transformationType), l = F.getExcludedProperties(e, this.transformationType);
530
- a = st(st([], f, !0), l, !0);
531
- }
532
- if (!this.options.ignoreDecorators && e) {
533
- var f = F.getExposedProperties(e, this.transformationType);
534
- this.transformationType === b.PLAIN_TO_CLASS && (f = f.map(function(m) {
535
- var h = F.findExposeMetadata(e, m);
536
- return h && h.options && h.options.name ? h.options.name : m;
537
- })), this.options.excludeExtraneousValues ? a = f : a = a.concat(f);
538
- var v = F.getExcludedProperties(e, this.transformationType);
539
- v.length > 0 && (a = a.filter(function(m) {
540
- return !v.includes(m);
541
- })), this.options.version !== void 0 && (a = a.filter(function(m) {
542
- var h = F.findExposeMetadata(e, m);
543
- return !h || !h.options ? !0 : i.checkVersion(h.options.since, h.options.until);
544
- })), this.options.groups && this.options.groups.length ? a = a.filter(function(m) {
545
- var h = F.findExposeMetadata(e, m);
546
- return !h || !h.options ? !0 : i.checkGroups(h.options.groups);
547
- }) : a = a.filter(function(m) {
548
- var h = F.findExposeMetadata(e, m);
549
- return !h || !h.options || !h.options.groups || !h.options.groups.length;
550
- });
551
- }
552
- return this.options.excludePrefixes && this.options.excludePrefixes.length && (a = a.filter(function(p) {
553
- return i.options.excludePrefixes.every(function(m) {
554
- return p.substr(0, m.length) !== m;
555
- });
556
- })), a = a.filter(function(p, m, h) {
557
- return h.indexOf(p) === m;
558
- }), a;
559
- }, r.prototype.checkVersion = function(e, t) {
560
- var n = !0;
561
- return n && e && (n = this.options.version >= e), n && t && (n = this.options.version < t), n;
562
- }, r.prototype.checkGroups = function(e) {
563
- return e ? this.options.groups.some(function(t) {
564
- return e.includes(t);
565
- }) : !0;
566
- }, r;
567
- }()
568
- ), ae = {
569
- enableCircularCheck: !1,
570
- enableImplicitConversion: !1,
571
- excludeExtraneousValues: !1,
572
- excludePrefixes: void 0,
573
- exposeDefaultValues: !1,
574
- exposeUnsetFields: !0,
575
- groups: void 0,
576
- ignoreDecorators: !1,
577
- strategy: void 0,
578
- targetMaps: void 0,
579
- version: void 0
580
- }, G = globalThis && globalThis.__assign || function() {
581
- return G = Object.assign || function(r) {
582
- for (var e, t = 1, n = arguments.length; t < n; t++) {
583
- e = arguments[t];
584
- for (var i in e)
585
- Object.prototype.hasOwnProperty.call(e, i) && (r[i] = e[i]);
586
- }
587
- return r;
588
- }, G.apply(this, arguments);
589
- }, Ft = (
590
- /** @class */
591
- function() {
592
- function r() {
593
- }
594
- return r.prototype.instanceToPlain = function(e, t) {
595
- var n = new oe(b.CLASS_TO_PLAIN, G(G({}, ae), t));
596
- return n.transform(void 0, e, void 0, void 0, void 0, void 0);
597
- }, r.prototype.classToPlainFromExist = function(e, t, n) {
598
- var i = new oe(b.CLASS_TO_PLAIN, G(G({}, ae), n));
599
- return i.transform(t, e, void 0, void 0, void 0, void 0);
600
- }, r.prototype.plainToInstance = function(e, t, n) {
601
- var i = new oe(b.PLAIN_TO_CLASS, G(G({}, ae), n));
602
- return i.transform(void 0, t, e, void 0, void 0, void 0);
603
- }, r.prototype.plainToClassFromExist = function(e, t, n) {
604
- var i = new oe(b.PLAIN_TO_CLASS, G(G({}, ae), n));
605
- return i.transform(e, t, void 0, void 0, void 0, void 0);
606
- }, r.prototype.instanceToInstance = function(e, t) {
607
- var n = new oe(b.CLASS_TO_CLASS, G(G({}, ae), t));
608
- return n.transform(void 0, e, void 0, void 0, void 0, void 0);
609
- }, r.prototype.classToClassFromExist = function(e, t, n) {
610
- var i = new oe(b.CLASS_TO_CLASS, G(G({}, ae), n));
611
- return i.transform(t, e, void 0, void 0, void 0, void 0);
612
- }, r.prototype.serialize = function(e, t) {
613
- return JSON.stringify(this.instanceToPlain(e, t));
614
- }, r.prototype.deserialize = function(e, t, n) {
615
- var i = JSON.parse(t);
616
- return this.plainToInstance(e, i, n);
617
- }, r.prototype.deserializeArray = function(e, t, n) {
618
- var i = JSON.parse(t);
619
- return this.plainToInstance(e, i, n);
620
- }, r;
621
- }()
622
- );
623
- function Le(r, e) {
624
- return e === void 0 && (e = {}), function(t, n) {
625
- var i = Reflect.getMetadata("design:type", t, n);
626
- F.addTypeMetadata({
627
- target: t.constructor,
628
- propertyName: n,
629
- reflectedType: i,
630
- typeFunction: r,
631
- options: e
632
- });
633
- };
634
- }
635
- var ft = new Ft();
636
- function Ut(r, e) {
637
- return ft.instanceToPlain(r, e);
638
- }
639
- function Wt(r, e, t) {
640
- return ft.plainToInstance(r, e, t);
641
- }
642
- /*! *****************************************************************************
643
- Copyright (C) Microsoft. All rights reserved.
644
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
645
- this file except in compliance with the License. You may obtain a copy of the
646
- License at http://www.apache.org/licenses/LICENSE-2.0
647
-
648
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
649
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
650
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
651
- MERCHANTABLITY OR NON-INFRINGEMENT.
652
-
653
- See the Apache Version 2.0 License for specific language governing permissions
654
- and limitations under the License.
655
- ***************************************************************************** */
656
- var it;
657
- (function(r) {
658
- (function(e) {
659
- var t = typeof rt == "object" ? rt : typeof self == "object" ? self : typeof this == "object" ? this : Function("return this;")(), n = i(r);
660
- typeof t.Reflect > "u" ? t.Reflect = r : n = i(t.Reflect, n), e(n);
661
- function i(u, a) {
662
- return function(f, l) {
663
- typeof u[f] != "function" && Object.defineProperty(u, f, { configurable: !0, writable: !0, value: l }), a && a(f, l);
664
- };
665
- }
666
- })(function(e) {
667
- var t = Object.prototype.hasOwnProperty, n = typeof Symbol == "function", i = n && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", u = n && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", a = typeof Object.create == "function", f = { __proto__: [] } instanceof Array, l = !a && !f, v = {
668
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
669
- create: a ? function() {
670
- return Ce(/* @__PURE__ */ Object.create(null));
671
- } : f ? function() {
672
- return Ce({ __proto__: null });
673
- } : function() {
674
- return Ce({});
675
- },
676
- has: l ? function(s, o) {
677
- return t.call(s, o);
678
- } : function(s, o) {
679
- return o in s;
680
- },
681
- get: l ? function(s, o) {
682
- return t.call(s, o) ? s[o] : void 0;
683
- } : function(s, o) {
684
- return s[o];
685
- }
686
- }, p = Object.getPrototypeOf(Function), m = typeof process == "object" && process.env && process.env.REFLECT_METADATA_USE_MAP_POLYFILL === "true", h = !m && typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : Lt(), R = !m && typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : It(), E = !m && typeof WeakMap == "function" ? WeakMap : Rt(), $ = new E();
687
- function g(s, o, c, d) {
688
- if (T(c)) {
689
- if (!Ve(s))
690
- throw new TypeError();
691
- if (!et(o))
692
- throw new TypeError();
693
- return he(s, o);
694
- } else {
695
- if (!Ve(s))
696
- throw new TypeError();
697
- if (!j(o))
698
- throw new TypeError();
699
- if (!j(d) && !T(d) && !se(d))
700
- throw new TypeError();
701
- return se(d) && (d = void 0), c = Z(c), pe(s, o, c, d);
702
- }
703
- }
704
- e("decorate", g);
705
- function I(s, o) {
706
- function c(d, y) {
707
- if (!j(d))
708
- throw new TypeError();
709
- if (!T(y) && !Ct(y))
710
- throw new TypeError();
711
- q(s, o, d, y);
712
- }
713
- return c;
714
- }
715
- e("metadata", I);
716
- function O(s, o, c, d) {
717
- if (!j(c))
718
- throw new TypeError();
719
- return T(d) || (d = Z(d)), q(s, o, c, d);
720
- }
721
- e("defineMetadata", O);
722
- function S(s, o, c) {
723
- if (!j(o))
724
- throw new TypeError();
725
- return T(c) || (c = Z(c)), fe(s, o, c);
726
- }
727
- e("hasMetadata", S);
728
- function W(s, o, c) {
729
- if (!j(o))
730
- throw new TypeError();
731
- return T(c) || (c = Z(c)), re(s, o, c);
732
- }
733
- e("hasOwnMetadata", W);
734
- function C(s, o, c) {
735
- if (!j(o))
736
- throw new TypeError();
737
- return T(c) || (c = Z(c)), te(s, o, c);
738
- }
739
- e("getMetadata", C);
740
- function k(s, o, c) {
741
- if (!j(o))
742
- throw new TypeError();
743
- return T(c) || (c = Z(c)), L(s, o, c);
744
- }
745
- e("getOwnMetadata", k);
746
- function Y(s, o) {
747
- if (!j(s))
748
- throw new TypeError();
749
- return T(o) || (o = Z(o)), Ze(s, o);
750
- }
751
- e("getMetadataKeys", Y);
752
- function N(s, o) {
753
- if (!j(s))
754
- throw new TypeError();
755
- return T(o) || (o = Z(o)), Qe(s, o);
756
- }
757
- e("getOwnMetadataKeys", N);
758
- function Me(s, o, c) {
759
- if (!j(o))
760
- throw new TypeError();
761
- T(c) || (c = Z(c));
762
- var d = K(
763
- o,
764
- c,
765
- /*Create*/
766
- !1
767
- );
768
- if (T(d) || !d.delete(s))
769
- return !1;
770
- if (d.size > 0)
771
- return !0;
772
- var y = $.get(o);
773
- return y.delete(c), y.size > 0 || $.delete(o), !0;
774
- }
775
- e("deleteMetadata", Me);
776
- function he(s, o) {
777
- for (var c = s.length - 1; c >= 0; --c) {
778
- var d = s[c], y = d(o);
779
- if (!T(y) && !se(y)) {
780
- if (!et(y))
781
- throw new TypeError();
782
- o = y;
783
- }
784
- }
785
- return o;
786
- }
787
- function pe(s, o, c, d) {
788
- for (var y = s.length - 1; y >= 0; --y) {
789
- var B = s[y], _ = B(o, c, d);
790
- if (!T(_) && !se(_)) {
791
- if (!j(_))
792
- throw new TypeError();
793
- d = _;
794
- }
795
- }
796
- return d;
797
- }
798
- function K(s, o, c) {
799
- var d = $.get(s);
800
- if (T(d)) {
801
- if (!c)
802
- return;
803
- d = new h(), $.set(s, d);
804
- }
805
- var y = d.get(o);
806
- if (T(y)) {
807
- if (!c)
808
- return;
809
- y = new h(), d.set(o, y);
810
- }
811
- return y;
812
- }
813
- function fe(s, o, c) {
814
- var d = re(s, o, c);
815
- if (d)
816
- return !0;
817
- var y = be(o);
818
- return se(y) ? !1 : fe(s, y, c);
819
- }
820
- function re(s, o, c) {
821
- var d = K(
822
- o,
823
- c,
824
- /*Create*/
825
- !1
826
- );
827
- return T(d) ? !1 : Mt(d.has(s));
828
- }
829
- function te(s, o, c) {
830
- var d = re(s, o, c);
831
- if (d)
832
- return L(s, o, c);
833
- var y = be(o);
834
- if (!se(y))
835
- return te(s, y, c);
836
- }
837
- function L(s, o, c) {
838
- var d = K(
839
- o,
840
- c,
841
- /*Create*/
842
- !1
843
- );
844
- if (!T(d))
845
- return d.get(s);
846
- }
847
- function q(s, o, c, d) {
848
- var y = K(
849
- c,
850
- d,
851
- /*Create*/
852
- !0
853
- );
854
- y.set(s, o);
855
- }
856
- function Ze(s, o) {
857
- var c = Qe(s, o), d = be(s);
858
- if (d === null)
859
- return c;
860
- var y = Ze(d, o);
861
- if (y.length <= 0)
862
- return c;
863
- if (c.length <= 0)
864
- return y;
865
- for (var B = new R(), _ = [], M = 0, w = c; M < w.length; M++) {
866
- var x = w[M], A = B.has(x);
867
- A || (B.add(x), _.push(x));
868
- }
869
- for (var V = 0, nt = y; V < nt.length; V++) {
870
- var x = nt[V], A = B.has(x);
871
- A || (B.add(x), _.push(x));
872
- }
873
- return _;
874
- }
875
- function Qe(s, o) {
876
- var c = [], d = K(
877
- s,
878
- o,
879
- /*Create*/
880
- !1
881
- );
882
- if (T(d))
883
- return c;
884
- for (var y = d.keys(), B = xt(y), _ = 0; ; ) {
885
- var M = Et(B);
886
- if (!M)
887
- return c.length = _, c;
888
- var w = At(M);
889
- try {
890
- c[_] = w;
891
- } catch (x) {
892
- try {
893
- Ot(B);
894
- } finally {
895
- throw x;
896
- }
897
- }
898
- _++;
899
- }
900
- }
901
- function Ke(s) {
902
- if (s === null)
903
- return 1;
904
- switch (typeof s) {
905
- case "undefined":
906
- return 0;
907
- case "boolean":
908
- return 2;
909
- case "string":
910
- return 3;
911
- case "symbol":
912
- return 4;
913
- case "number":
914
- return 5;
915
- case "object":
916
- return s === null ? 1 : 6;
917
- default:
918
- return 6;
919
- }
920
- }
921
- function T(s) {
922
- return s === void 0;
923
- }
924
- function se(s) {
925
- return s === null;
926
- }
927
- function wt(s) {
928
- return typeof s == "symbol";
929
- }
930
- function j(s) {
931
- return typeof s == "object" ? s !== null : typeof s == "function";
932
- }
933
- function _t(s, o) {
934
- switch (Ke(s)) {
935
- case 0:
936
- return s;
937
- case 1:
938
- return s;
939
- case 2:
940
- return s;
941
- case 3:
942
- return s;
943
- case 4:
944
- return s;
945
- case 5:
946
- return s;
947
- }
948
- var c = o === 3 ? "string" : o === 5 ? "number" : "default", d = tt(s, i);
949
- if (d !== void 0) {
950
- var y = d.call(s, c);
951
- if (j(y))
952
- throw new TypeError();
953
- return y;
954
- }
955
- return St(s, c === "default" ? "number" : c);
956
- }
957
- function St(s, o) {
958
- if (o === "string") {
959
- var c = s.toString;
960
- if (ie(c)) {
961
- var d = c.call(s);
962
- if (!j(d))
963
- return d;
964
- }
965
- var y = s.valueOf;
966
- if (ie(y)) {
967
- var d = y.call(s);
968
- if (!j(d))
969
- return d;
970
- }
971
- } else {
972
- var y = s.valueOf;
973
- if (ie(y)) {
974
- var d = y.call(s);
975
- if (!j(d))
976
- return d;
977
- }
978
- var B = s.toString;
979
- if (ie(B)) {
980
- var d = B.call(s);
981
- if (!j(d))
982
- return d;
983
- }
984
- }
985
- throw new TypeError();
986
- }
987
- function Mt(s) {
988
- return !!s;
989
- }
990
- function bt(s) {
991
- return "" + s;
992
- }
993
- function Z(s) {
994
- var o = _t(
995
- s,
996
- 3
997
- /* String */
998
- );
999
- return wt(o) ? o : bt(o);
1000
- }
1001
- function Ve(s) {
1002
- return Array.isArray ? Array.isArray(s) : s instanceof Object ? s instanceof Array : Object.prototype.toString.call(s) === "[object Array]";
1003
- }
1004
- function ie(s) {
1005
- return typeof s == "function";
1006
- }
1007
- function et(s) {
1008
- return typeof s == "function";
1009
- }
1010
- function Ct(s) {
1011
- switch (Ke(s)) {
1012
- case 3:
1013
- return !0;
1014
- case 4:
1015
- return !0;
1016
- default:
1017
- return !1;
1018
- }
1019
- }
1020
- function tt(s, o) {
1021
- var c = s[o];
1022
- if (c != null) {
1023
- if (!ie(c))
1024
- throw new TypeError();
1025
- return c;
1026
- }
1027
- }
1028
- function xt(s) {
1029
- var o = tt(s, u);
1030
- if (!ie(o))
1031
- throw new TypeError();
1032
- var c = o.call(s);
1033
- if (!j(c))
1034
- throw new TypeError();
1035
- return c;
1036
- }
1037
- function At(s) {
1038
- return s.value;
1039
- }
1040
- function Et(s) {
1041
- var o = s.next();
1042
- return o.done ? !1 : o;
1043
- }
1044
- function Ot(s) {
1045
- var o = s.return;
1046
- o && o.call(s);
1047
- }
1048
- function be(s) {
1049
- var o = Object.getPrototypeOf(s);
1050
- if (typeof s != "function" || s === p || o !== p)
1051
- return o;
1052
- var c = s.prototype, d = c && Object.getPrototypeOf(c);
1053
- if (d == null || d === Object.prototype)
1054
- return o;
1055
- var y = d.constructor;
1056
- return typeof y != "function" || y === s ? o : y;
1057
- }
1058
- function Lt() {
1059
- var s = {}, o = [], c = (
1060
- /** @class */
1061
- function() {
1062
- function _(M, w, x) {
1063
- this._index = 0, this._keys = M, this._values = w, this._selector = x;
1064
- }
1065
- return _.prototype["@@iterator"] = function() {
1066
- return this;
1067
- }, _.prototype[u] = function() {
1068
- return this;
1069
- }, _.prototype.next = function() {
1070
- var M = this._index;
1071
- if (M >= 0 && M < this._keys.length) {
1072
- var w = this._selector(this._keys[M], this._values[M]);
1073
- return M + 1 >= this._keys.length ? (this._index = -1, this._keys = o, this._values = o) : this._index++, { value: w, done: !1 };
1074
- }
1075
- return { value: void 0, done: !0 };
1076
- }, _.prototype.throw = function(M) {
1077
- throw this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), M;
1078
- }, _.prototype.return = function(M) {
1079
- return this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), { value: M, done: !0 };
1080
- }, _;
1081
- }()
1082
- );
1083
- return (
1084
- /** @class */
1085
- function() {
1086
- function _() {
1087
- this._keys = [], this._values = [], this._cacheKey = s, this._cacheIndex = -2;
1088
- }
1089
- return Object.defineProperty(_.prototype, "size", {
1090
- get: function() {
1091
- return this._keys.length;
1092
- },
1093
- enumerable: !0,
1094
- configurable: !0
1095
- }), _.prototype.has = function(M) {
1096
- return this._find(
1097
- M,
1098
- /*insert*/
1099
- !1
1100
- ) >= 0;
1101
- }, _.prototype.get = function(M) {
1102
- var w = this._find(
1103
- M,
1104
- /*insert*/
1105
- !1
1106
- );
1107
- return w >= 0 ? this._values[w] : void 0;
1108
- }, _.prototype.set = function(M, w) {
1109
- var x = this._find(
1110
- M,
1111
- /*insert*/
1112
- !0
1113
- );
1114
- return this._values[x] = w, this;
1115
- }, _.prototype.delete = function(M) {
1116
- var w = this._find(
1117
- M,
1118
- /*insert*/
1119
- !1
1120
- );
1121
- if (w >= 0) {
1122
- for (var x = this._keys.length, A = w + 1; A < x; A++)
1123
- this._keys[A - 1] = this._keys[A], this._values[A - 1] = this._values[A];
1124
- return this._keys.length--, this._values.length--, M === this._cacheKey && (this._cacheKey = s, this._cacheIndex = -2), !0;
1125
- }
1126
- return !1;
1127
- }, _.prototype.clear = function() {
1128
- this._keys.length = 0, this._values.length = 0, this._cacheKey = s, this._cacheIndex = -2;
1129
- }, _.prototype.keys = function() {
1130
- return new c(this._keys, this._values, d);
1131
- }, _.prototype.values = function() {
1132
- return new c(this._keys, this._values, y);
1133
- }, _.prototype.entries = function() {
1134
- return new c(this._keys, this._values, B);
1135
- }, _.prototype["@@iterator"] = function() {
1136
- return this.entries();
1137
- }, _.prototype[u] = function() {
1138
- return this.entries();
1139
- }, _.prototype._find = function(M, w) {
1140
- return this._cacheKey !== M && (this._cacheIndex = this._keys.indexOf(this._cacheKey = M)), this._cacheIndex < 0 && w && (this._cacheIndex = this._keys.length, this._keys.push(M), this._values.push(void 0)), this._cacheIndex;
1141
- }, _;
1142
- }()
1143
- );
1144
- function d(_, M) {
1145
- return _;
1146
- }
1147
- function y(_, M) {
1148
- return M;
1149
- }
1150
- function B(_, M) {
1151
- return [_, M];
1152
- }
1153
- }
1154
- function It() {
1155
- return (
1156
- /** @class */
1157
- function() {
1158
- function s() {
1159
- this._map = new h();
1160
- }
1161
- return Object.defineProperty(s.prototype, "size", {
1162
- get: function() {
1163
- return this._map.size;
1164
- },
1165
- enumerable: !0,
1166
- configurable: !0
1167
- }), s.prototype.has = function(o) {
1168
- return this._map.has(o);
1169
- }, s.prototype.add = function(o) {
1170
- return this._map.set(o, o), this;
1171
- }, s.prototype.delete = function(o) {
1172
- return this._map.delete(o);
1173
- }, s.prototype.clear = function() {
1174
- this._map.clear();
1175
- }, s.prototype.keys = function() {
1176
- return this._map.keys();
1177
- }, s.prototype.values = function() {
1178
- return this._map.values();
1179
- }, s.prototype.entries = function() {
1180
- return this._map.entries();
1181
- }, s.prototype["@@iterator"] = function() {
1182
- return this.keys();
1183
- }, s.prototype[u] = function() {
1184
- return this.keys();
1185
- }, s;
1186
- }()
1187
- );
1188
- }
1189
- function Rt() {
1190
- var s = 16, o = v.create(), c = d();
1191
- return (
1192
- /** @class */
1193
- function() {
1194
- function w() {
1195
- this._key = d();
1196
- }
1197
- return w.prototype.has = function(x) {
1198
- var A = y(
1199
- x,
1200
- /*create*/
1201
- !1
1202
- );
1203
- return A !== void 0 ? v.has(A, this._key) : !1;
1204
- }, w.prototype.get = function(x) {
1205
- var A = y(
1206
- x,
1207
- /*create*/
1208
- !1
1209
- );
1210
- return A !== void 0 ? v.get(A, this._key) : void 0;
1211
- }, w.prototype.set = function(x, A) {
1212
- var V = y(
1213
- x,
1214
- /*create*/
1215
- !0
1216
- );
1217
- return V[this._key] = A, this;
1218
- }, w.prototype.delete = function(x) {
1219
- var A = y(
1220
- x,
1221
- /*create*/
1222
- !1
1223
- );
1224
- return A !== void 0 ? delete A[this._key] : !1;
1225
- }, w.prototype.clear = function() {
1226
- this._key = d();
1227
- }, w;
1228
- }()
1229
- );
1230
- function d() {
1231
- var w;
1232
- do
1233
- w = "@@WeakMap@@" + M();
1234
- while (v.has(o, w));
1235
- return o[w] = !0, w;
1236
- }
1237
- function y(w, x) {
1238
- if (!t.call(w, c)) {
1239
- if (!x)
1240
- return;
1241
- Object.defineProperty(w, c, { value: v.create() });
1242
- }
1243
- return w[c];
1244
- }
1245
- function B(w, x) {
1246
- for (var A = 0; A < x; ++A)
1247
- w[A] = Math.random() * 255 | 0;
1248
- return w;
1249
- }
1250
- function _(w) {
1251
- return typeof Uint8Array == "function" ? typeof crypto < "u" ? crypto.getRandomValues(new Uint8Array(w)) : typeof msCrypto < "u" ? msCrypto.getRandomValues(new Uint8Array(w)) : B(new Uint8Array(w), w) : B(new Array(w), w);
1252
- }
1253
- function M() {
1254
- var w = _(s);
1255
- w[6] = w[6] & 79 | 64, w[8] = w[8] & 191 | 128;
1256
- for (var x = "", A = 0; A < s; ++A) {
1257
- var V = w[A];
1258
- (A === 4 || A === 6 || A === 8) && (x += "-"), V < 16 && (x += "0"), x += V.toString(16).toLowerCase();
1259
- }
1260
- return x;
1261
- }
1262
- }
1263
- function Ce(s) {
1264
- return s.__ = void 0, delete s.__, s;
1265
- }
1266
- });
1267
- })(it || (it = {}));
1268
- var Gt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Ie = (r, e, t, n) => {
1269
- for (var i = n > 1 ? void 0 : n ? zt(e, t) : e, u = r.length - 1, a; u >= 0; u--)
1270
- (a = r[u]) && (i = (n ? a(e, t, i) : a(i)) || i);
1271
- return n && i && Gt(e, t, i), i;
1272
- };
1273
- const X = 0, D = 1, Jt = 4294967295, ge = 3;
1274
- class Re {
1275
- constructor(e) {
1276
- Object.assign(this, e);
1277
- }
1278
- update() {
1279
- var e, t, n, i, u;
1280
- (e = this.ScalarCmd) == null || e.forEach((a, f) => a.Index = f), (t = this.RotateCmd) == null || t.forEach((a, f) => a.Index = f), (n = this.LinearCmd) == null || n.forEach((a, f) => a.Index = f), (i = this.SensorReadCmd) == null || i.forEach((a, f) => a.Index = f), (u = this.SensorSubscribeCmd) == null || u.forEach((a, f) => a.Index = f);
1281
- }
1282
- }
1283
- var ce = /* @__PURE__ */ ((r) => (r.Unknown = "Unknown", r.Vibrate = "Vibrate", r.Rotate = "Rotate", r.Oscillate = "Oscillate", r.Constrict = "Constrict", r.Inflate = "Inflate", r.Position = "Position", r))(ce || {}), ee = /* @__PURE__ */ ((r) => (r.Unknown = "Unknown", r.Battery = "Battery", r.RSSI = "RSSI", r.Button = "Button", r.Pressure = "Pressure", r))(ee || {});
1284
- class qt {
1285
- constructor(e) {
1286
- this.Index = 0, Object.assign(this, e);
1287
- }
1288
- }
1289
- class Ht {
1290
- constructor(e) {
1291
- this.Endpoints = e;
1292
- }
1293
- }
1294
- class Yt {
1295
- constructor(e) {
1296
- this.Index = 0, Object.assign(this, e);
1297
- }
1298
- }
1299
- class H {
1300
- constructor(e) {
1301
- this.Id = e;
1302
- }
1303
- // tslint:disable-next-line:ban-types
1304
- get Type() {
1305
- return this.constructor;
1306
- }
1307
- toJSON() {
1308
- return JSON.stringify(this.toProtocolFormat());
1309
- }
1310
- toProtocolFormat() {
1311
- const e = {};
1312
- return e[this.constructor.Name] = Ut(this), e;
1313
- }
1314
- update() {
1315
- }
1316
- }
1317
- class J extends H {
1318
- constructor(e, t) {
1319
- super(t), this.DeviceIndex = e, this.Id = t;
1320
- }
1321
- }
1322
- class ue extends H {
1323
- constructor(e = X) {
1324
- super(e), this.Id = e;
1325
- }
1326
- }
1327
- class we extends ue {
1328
- constructor(e = D) {
1329
- super(e), this.Id = e;
1330
- }
1331
- }
1332
- we.Name = "Ok";
1333
- class dt extends H {
1334
- constructor(e = D) {
1335
- super(e), this.Id = e;
1336
- }
1337
- }
1338
- dt.Name = "Ping";
1339
- var z = /* @__PURE__ */ ((r) => (r[r.ERROR_UNKNOWN = 0] = "ERROR_UNKNOWN", r[r.ERROR_INIT = 1] = "ERROR_INIT", r[r.ERROR_PING = 2] = "ERROR_PING", r[r.ERROR_MSG = 3] = "ERROR_MSG", r[r.ERROR_DEVICE = 4] = "ERROR_DEVICE", r))(z || {});
1340
- let Q = class extends H {
1341
- constructor(e, t = 0, n = D) {
1342
- super(n), this.ErrorMessage = e, this.ErrorCode = t, this.Id = n;
1343
- }
1344
- get Schemversion() {
1345
- return 0;
1346
- }
1347
- };
1348
- Q.Name = "Error";
1349
- class De {
1350
- constructor(e) {
1351
- Object.assign(this, e);
1352
- }
1353
- }
1354
- Ie([
1355
- Le(() => Re)
1356
- ], De.prototype, "DeviceMessages", 2);
1357
- class Ne extends H {
1358
- constructor(e, t = D) {
1359
- super(t), this.Devices = e, this.Id = t;
1360
- }
1361
- update() {
1362
- for (const e of this.Devices)
1363
- e.DeviceMessages.update();
1364
- }
1365
- }
1366
- Ne.Name = "DeviceList";
1367
- Ie([
1368
- Le(() => De)
1369
- ], Ne.prototype, "Devices", 2);
1370
- class _e extends ue {
1371
- constructor(e) {
1372
- super(), Object.assign(this, e);
1373
- }
1374
- update() {
1375
- this.DeviceMessages.update();
1376
- }
1377
- }
1378
- _e.Name = "DeviceAdded";
1379
- Ie([
1380
- Le(() => Re)
1381
- ], _e.prototype, "DeviceMessages", 2);
1382
- class Te extends ue {
1383
- constructor(e) {
1384
- super(), this.DeviceIndex = e;
1385
- }
1386
- }
1387
- Te.Name = "DeviceRemoved";
1388
- class Pe extends H {
1389
- constructor(e = D) {
1390
- super(e), this.Id = e;
1391
- }
1392
- }
1393
- Pe.Name = "RequestDeviceList";
1394
- class ke extends H {
1395
- constructor(e = D) {
1396
- super(e), this.Id = e;
1397
- }
1398
- }
1399
- ke.Name = "StartScanning";
1400
- class je extends H {
1401
- constructor(e = D) {
1402
- super(e), this.Id = e;
1403
- }
1404
- }
1405
- je.Name = "StopScanning";
1406
- class Be extends ue {
1407
- constructor() {
1408
- super();
1409
- }
1410
- }
1411
- Be.Name = "ScanningFinished";
1412
- class $e extends H {
1413
- constructor(e, t = 0, n = D) {
1414
- super(n), this.ClientName = e, this.MessageVersion = t, this.Id = n;
1415
- }
1416
- }
1417
- $e.Name = "RequestServerInfo";
1418
- class Fe extends ue {
1419
- constructor(e, t, n, i = D) {
1420
- super(), this.MessageVersion = e, this.MaxPingTime = t, this.ServerName = n, this.Id = i;
1421
- }
1422
- }
1423
- Fe.Name = "ServerInfo";
1424
- class Ue extends J {
1425
- constructor(e = -1, t = D) {
1426
- super(e, t), this.DeviceIndex = e, this.Id = t;
1427
- }
1428
- }
1429
- Ue.Name = "StopDeviceCmd";
1430
- class We extends H {
1431
- constructor(e = D) {
1432
- super(e), this.Id = e;
1433
- }
1434
259
  }
1435
- We.Name = "StopAllDevices";
1436
- class Se {
1437
- constructor(e) {
1438
- this.Index = e;
1439
- }
1440
- }
1441
- class xe extends Se {
1442
- constructor(e, t, n) {
1443
- super(e), this.Scalar = t, this.ActuatorType = n;
1444
- }
1445
- }
1446
- class me extends J {
1447
- constructor(e, t = -1, n = D) {
1448
- super(t, n), this.Scalars = e, this.DeviceIndex = t, this.Id = n;
1449
- }
1450
- }
1451
- me.Name = "ScalarCmd";
1452
- class ht extends Se {
1453
- constructor(e, t, n) {
1454
- super(e), this.Speed = t, this.Clockwise = n;
1455
- }
1456
- }
1457
- const pt = class lt extends J {
1458
- constructor(e, t = -1, n = D) {
1459
- super(t, n), this.Rotations = e, this.DeviceIndex = t, this.Id = n;
1460
- }
1461
- static Create(e, t) {
1462
- const n = new Array();
1463
- let i = 0;
1464
- for (const [u, a] of t)
1465
- n.push(new ht(i, u, a)), ++i;
1466
- return new lt(n, e);
1467
- }
1468
- };
1469
- pt.Name = "RotateCmd";
1470
- let Ae = pt;
1471
- class gt extends Se {
1472
- constructor(e, t, n) {
1473
- super(e), this.Position = t, this.Duration = n;
1474
- }
1475
- }
1476
- const mt = class yt extends J {
1477
- constructor(e, t = -1, n = D) {
1478
- super(t, n), this.Vectors = e, this.DeviceIndex = t, this.Id = n;
1479
- }
1480
- static Create(e, t) {
1481
- const n = new Array();
1482
- let i = 0;
1483
- for (const u of t)
1484
- n.push(new gt(i, u[0], u[1])), ++i;
1485
- return new yt(n, e);
1486
- }
1487
- };
1488
- mt.Name = "LinearCmd";
1489
- let Ee = mt;
1490
- class Ge extends J {
1491
- constructor(e, t, n, i = D) {
1492
- super(e, i), this.DeviceIndex = e, this.SensorIndex = t, this.SensorType = n, this.Id = i;
1493
- }
1494
- }
1495
- Ge.Name = "SensorReadCmd";
1496
- class ze extends J {
1497
- constructor(e, t, n, i, u = D) {
1498
- super(e, u), this.DeviceIndex = e, this.SensorIndex = t, this.SensorType = n, this.Data = i, this.Id = u;
1499
- }
1500
- }
1501
- ze.Name = "SensorReading";
1502
- class Je extends J {
1503
- constructor(e, t, n, i, u = D) {
1504
- super(e, u), this.DeviceIndex = e, this.Endpoint = t, this.ExpectedLength = n, this.Timeout = i, this.Id = u;
1505
- }
1506
- }
1507
- Je.Name = "RawReadCmd";
1508
- class qe extends J {
1509
- constructor(e, t, n, i, u = D) {
1510
- super(e, u), this.DeviceIndex = e, this.Endpoint = t, this.Data = n, this.WriteWithResponse = i, this.Id = u;
1511
- }
1512
- }
1513
- qe.Name = "RawWriteCmd";
1514
- class He extends J {
1515
- constructor(e, t, n = D) {
1516
- super(e, n), this.DeviceIndex = e, this.Endpoint = t, this.Id = n;
1517
- }
1518
- }
1519
- He.Name = "RawSubscribeCmd";
1520
- class Ye extends J {
1521
- constructor(e, t, n = D) {
1522
- super(e, n), this.DeviceIndex = e, this.Endpoint = t, this.Id = n;
1523
- }
1524
- }
1525
- Ye.Name = "RawUnsubscribeCmd";
1526
- class Xe extends J {
1527
- constructor(e, t, n, i = D) {
1528
- super(e, i), this.DeviceIndex = e, this.Endpoint = t, this.Data = n, this.Id = i;
1529
- }
1530
- }
1531
- Xe.Name = "RawReading";
1532
- const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1533
- __proto__: null,
1534
- ActuatorType: ce,
1535
- ButtplugDeviceMessage: J,
1536
- ButtplugMessage: H,
1537
- ButtplugSystemMessage: ue,
1538
- DEFAULT_MESSAGE_ID: D,
1539
- DeviceAdded: _e,
1540
- DeviceInfo: De,
1541
- DeviceList: Ne,
1542
- DeviceRemoved: Te,
1543
- Error: Q,
1544
- ErrorClass: z,
1545
- GenericDeviceMessageAttributes: qt,
1546
- GenericMessageSubcommand: Se,
1547
- LinearCmd: Ee,
1548
- MAX_ID: Jt,
1549
- MESSAGE_SPEC_VERSION: ge,
1550
- MessageAttributes: Re,
1551
- Ok: we,
1552
- Ping: dt,
1553
- RawDeviceMessageAttributes: Ht,
1554
- RawReadCmd: Je,
1555
- RawReading: Xe,
1556
- RawSubscribeCmd: He,
1557
- RawUnsubscribeCmd: Ye,
1558
- RawWriteCmd: qe,
1559
- RequestDeviceList: Pe,
1560
- RequestServerInfo: $e,
1561
- RotateCmd: Ae,
1562
- RotateSubcommand: ht,
1563
- SYSTEM_MESSAGE_ID: X,
1564
- ScalarCmd: me,
1565
- ScalarSubcommand: xe,
1566
- ScanningFinished: Be,
1567
- SensorDeviceMessageAttributes: Yt,
1568
- SensorReadCmd: Ge,
1569
- SensorReading: ze,
1570
- SensorType: ee,
1571
- ServerInfo: Fe,
1572
- StartScanning: ke,
1573
- StopAllDevices: We,
1574
- StopDeviceCmd: Ue,
1575
- StopScanning: je,
1576
- VectorSubcommand: gt
1577
- }, Symbol.toStringTag, { value: "Module" }));
1578
- /*!
1579
- * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1580
- * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1581
- * project root for full license information.
1582
- *
1583
- * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1584
- */
1585
- class U extends Error {
1586
- constructor(e, t, n = X, i) {
1587
- super(e), this.errorClass = z.ERROR_UNKNOWN, this.errorClass = t, this.innerError = i, this.messageId = n;
1588
- }
260
+ class m extends Error {
1589
261
  get ErrorClass() {
1590
262
  return this.errorClass;
1591
263
  }
@@ -1596,85 +268,173 @@ class U extends Error {
1596
268
  return this.messageId;
1597
269
  }
1598
270
  get ErrorMessage() {
1599
- return new Q(this.message, this.ErrorClass, this.Id);
271
+ return {
272
+ Error: {
273
+ Id: this.Id,
274
+ ErrorCode: this.ErrorClass,
275
+ ErrorMessage: this.message
276
+ }
277
+ };
1600
278
  }
1601
- static LogAndError(e, t, n, i = X) {
1602
- return t.Error(n), new e(n, i);
279
+ static LogAndError(e, t, n, a = C) {
280
+ return t.Error(n), new e(n, a);
1603
281
  }
1604
282
  static FromError(e) {
1605
283
  switch (e.ErrorCode) {
1606
- case z.ERROR_DEVICE:
1607
- return new P(e.ErrorMessage, e.Id);
1608
- case z.ERROR_INIT:
1609
- return new Oe(e.ErrorMessage, e.Id);
1610
- case z.ERROR_UNKNOWN:
1611
- return new Qt(e.ErrorMessage, e.Id);
1612
- case z.ERROR_PING:
1613
- return new Zt(e.ErrorMessage, e.Id);
1614
- case z.ERROR_MSG:
1615
- return new de(e.ErrorMessage, e.Id);
284
+ case w.ERROR_DEVICE:
285
+ return new E(e.ErrorMessage, e.Id);
286
+ case w.ERROR_INIT:
287
+ return new G(e.ErrorMessage, e.Id);
288
+ case w.ERROR_UNKNOWN:
289
+ return new z(e.ErrorMessage, e.Id);
290
+ case w.ERROR_PING:
291
+ return new K(e.ErrorMessage, e.Id);
292
+ case w.ERROR_MSG:
293
+ return new R(e.ErrorMessage, e.Id);
1616
294
  default:
1617
295
  throw new Error(`Message type ${e.ErrorCode} not handled`);
1618
296
  }
1619
297
  }
1620
- }
1621
- class Oe extends U {
1622
- constructor(e, t = X) {
1623
- super(e, z.ERROR_INIT, t);
298
+ errorClass = w.ERROR_UNKNOWN;
299
+ innerError;
300
+ messageId;
301
+ constructor(e, t, n = C, a) {
302
+ super(e), this.errorClass = t, this.innerError = a, this.messageId = n;
1624
303
  }
1625
304
  }
1626
- class P extends U {
1627
- constructor(e, t = X) {
1628
- super(e, z.ERROR_DEVICE, t);
305
+ class G extends m {
306
+ constructor(e, t = C) {
307
+ super(e, w.ERROR_INIT, t);
1629
308
  }
1630
309
  }
1631
- class de extends U {
1632
- constructor(e, t = X) {
1633
- super(e, z.ERROR_MSG, t);
310
+ class E extends m {
311
+ constructor(e, t = C) {
312
+ super(e, w.ERROR_DEVICE, t);
1634
313
  }
1635
314
  }
1636
- class Zt extends U {
1637
- constructor(e, t = X) {
1638
- super(e, z.ERROR_PING, t);
315
+ class R extends m {
316
+ constructor(e, t = C) {
317
+ super(e, w.ERROR_MSG, t);
1639
318
  }
1640
319
  }
1641
- class Qt extends U {
1642
- constructor(e, t = X) {
1643
- super(e, z.ERROR_UNKNOWN, t);
320
+ class K extends m {
321
+ constructor(e, t = C) {
322
+ super(e, w.ERROR_PING, t);
1644
323
  }
1645
324
  }
1646
- function vt(r) {
1647
- for (const e of Object.values(Xt))
1648
- if (typeof e == "function" && "Name" in e && e.Name === r)
1649
- return e;
1650
- return null;
325
+ class z extends m {
326
+ constructor(e, t = C) {
327
+ super(e, w.ERROR_UNKNOWN, t);
328
+ }
1651
329
  }
1652
- function ne(r) {
1653
- return vt(Object.getPrototypeOf(r).constructor.Name);
330
+ const C = 0, oe = 1, ae = 4294967295, H = 4, X = 0;
331
+ function F(s) {
332
+ for (let [e, t] of Object.entries(s))
333
+ if (t != null)
334
+ return t.Id;
335
+ throw new R(`Message ${s} does not have an ID.`);
1654
336
  }
1655
- function ot(r) {
1656
- const e = JSON.parse(r), t = [];
1657
- for (const n of Array.from(e)) {
1658
- const i = Object.getOwnPropertyNames(n)[0], u = vt(i);
1659
- if (u) {
1660
- const a = Wt(
1661
- u,
1662
- n[i]
1663
- );
1664
- a.update(), t.push(a);
337
+ function Y(s, e) {
338
+ for (let [t, n] of Object.entries(s))
339
+ if (n != null) {
340
+ n.Id = e;
341
+ return;
1665
342
  }
343
+ throw new R(`Message ${s} does not have an ID.`);
344
+ }
345
+ var w = /* @__PURE__ */ ((s) => (s[s.ERROR_UNKNOWN = 0] = "ERROR_UNKNOWN", s[s.ERROR_INIT = 1] = "ERROR_INIT", s[s.ERROR_PING = 2] = "ERROR_PING", s[s.ERROR_MSG = 3] = "ERROR_MSG", s[s.ERROR_DEVICE = 4] = "ERROR_DEVICE", s))(w || {}), _ = /* @__PURE__ */ ((s) => (s.Unknown = "Unknown", s.Vibrate = "Vibrate", s.Rotate = "Rotate", s.Oscillate = "Oscillate", s.Constrict = "Constrict", s.Inflate = "Inflate", s.Position = "Position", s.PositionWithDuration = "PositionWithDuration", s.Temperature = "Temperature", s.Spray = "Spray", s.Led = "Led", s))(_ || {}), D = /* @__PURE__ */ ((s) => (s.Unknown = "Unknown", s.Battery = "Battery", s.RSSI = "RSSI", s.Button = "Button", s.Pressure = "Pressure", s))(D || {}), L = /* @__PURE__ */ ((s) => (s.Read = "Read", s.Subscribe = "Subscribe", s.Unsubscribe = "Unsubscribe", s))(L || {});
346
+ class Q {
347
+ constructor(e, t, n, a) {
348
+ this._deviceIndex = e, this._deviceName = t, this._feature = n, this._sendClosure = a;
349
+ }
350
+ send = async (e) => await this._sendClosure(e);
351
+ sendMsgExpectOk = async (e) => {
352
+ const t = await this.send(e);
353
+ if (t.Ok === void 0)
354
+ throw t.Error !== void 0 ? m.FromError(t) : new R("Expected Ok or Error, and didn't get either!");
355
+ };
356
+ isOutputValid(e) {
357
+ if (this._feature.Output !== void 0 && !this._feature.Output.hasOwnProperty(e))
358
+ throw new E(`Feature index ${this._feature.FeatureIndex} does not support type ${e} for device ${this._deviceName}`);
359
+ }
360
+ isInputValid(e) {
361
+ if (this._feature.Input !== void 0 && !this._feature.Input.hasOwnProperty(e))
362
+ throw new E(`Feature index ${this._feature.FeatureIndex} does not support type ${e} for device ${this._deviceName}`);
363
+ }
364
+ async sendOutputCmd(e) {
365
+ if (this.isOutputValid(e.outputType), e.value === void 0)
366
+ throw new E(`${e.outputType} requires value defined`);
367
+ let t = e.outputType, n;
368
+ if (t == _.PositionWithDuration) {
369
+ if (e.duration === void 0)
370
+ throw new E("PositionWithDuration requires duration defined");
371
+ n = e.duration;
372
+ }
373
+ let a, g = e.value;
374
+ g.percent === void 0 ? a = e.value.steps : a = Math.ceil(this._feature.Output[t].Value[1] * g.percent);
375
+ let l = { Value: a, Duration: n }, f = {};
376
+ f[t.toString()] = l;
377
+ let u = {
378
+ OutputCmd: {
379
+ Id: 1,
380
+ DeviceIndex: this._deviceIndex,
381
+ FeatureIndex: this._feature.FeatureIndex,
382
+ Command: f
383
+ }
384
+ };
385
+ await this.sendMsgExpectOk(u);
386
+ }
387
+ hasOutput(e) {
388
+ return this._feature.Output !== void 0 ? this._feature.Output.hasOwnProperty(e.toString()) : !1;
389
+ }
390
+ hasInput(e) {
391
+ return this._feature.Input !== void 0 ? this._feature.Input.hasOwnProperty(e.toString()) : !1;
392
+ }
393
+ async runOutput(e) {
394
+ if (this._feature.Output !== void 0 && this._feature.Output.hasOwnProperty(e.outputType.toString()))
395
+ return this.sendOutputCmd(e);
396
+ throw new E(`Output type ${e.outputType} not supported by feature.`);
397
+ }
398
+ async runInput(e, t) {
399
+ this.isInputValid(e);
400
+ let n = this._feature.Input[e];
401
+ if (console.log(this._feature.Input), t === L.Unsubscribe && !n.Command.includes(L.Subscribe) && !n.Command.includes(t))
402
+ throw new E(`${e} does not support command ${t}`);
403
+ let a = {
404
+ InputCmd: {
405
+ Id: 1,
406
+ DeviceIndex: this._deviceIndex,
407
+ FeatureIndex: this._feature.FeatureIndex,
408
+ Type: e,
409
+ Command: t
410
+ }
411
+ };
412
+ if (t == L.Read) {
413
+ const g = await this.send(a);
414
+ if (g.InputReading !== void 0)
415
+ return g.InputReading;
416
+ throw g.Error !== void 0 ? m.FromError(g) : new R("Expected InputReading or Error, and didn't get either!");
417
+ } else
418
+ console.log(`Sending subscribe message: ${JSON.stringify(a)}`), await this.sendMsgExpectOk(a), console.log("Got back ok?");
1666
419
  }
1667
- return t;
1668
420
  }
1669
- class ye extends ve {
421
+ class B extends P {
422
+ //
423
+ // // Map of messages and their attributes (feature count, etc...)
424
+ // private allowedMsgs: Map<string, Messages.MessageAttributes> = new Map<
425
+ // string,
426
+ // Messages.MessageAttributes
427
+ // >();
428
+ //
1670
429
  /**
1671
430
  * @param _index Index of the device, as created by the device manager.
1672
431
  * @param _name Name of the device.
1673
432
  * @param allowedMsgs Buttplug messages the device can receive.
1674
433
  */
1675
434
  constructor(e, t) {
1676
- super(), this._deviceInfo = e, this._sendClosure = t, this.allowedMsgs = /* @__PURE__ */ new Map(), e.DeviceMessages.update();
435
+ super(), this._deviceInfo = e, this._sendClosure = t, this._features = new Map(Object.entries(e.DeviceFeatures).map(([n, a]) => [parseInt(n), new Q(e.DeviceIndex, e.DeviceName, a, t)]));
1677
436
  }
437
+ _features;
1678
438
  /**
1679
439
  * Return the name of the device.
1680
440
  */
@@ -1699,428 +459,210 @@ class ye extends ve {
1699
459
  get messageTimingGap() {
1700
460
  return this._deviceInfo.DeviceMessageTimingGap;
1701
461
  }
1702
- /**
1703
- * Return a list of message types the device accepts.
1704
- */
1705
- get messageAttributes() {
1706
- return this._deviceInfo.DeviceMessages;
462
+ get features() {
463
+ return this._features;
1707
464
  }
465
+ // /**
466
+ // * Return a list of message types the device accepts.
467
+ // */
468
+ // public get messageAttributes(): Messages.MessageAttributes {
469
+ // return this._deviceInfo.DeviceMessages;
470
+ // }
471
+ //
1708
472
  static fromMsg(e, t) {
1709
- return new ye(e, t);
473
+ return new B(e, t);
1710
474
  }
1711
475
  async send(e) {
1712
- return await this._sendClosure(this, e);
476
+ return await this._sendClosure(e);
1713
477
  }
1714
- async sendExpectOk(e) {
478
+ sendMsgExpectOk = async (e) => {
1715
479
  const t = await this.send(e);
1716
- switch (ne(t)) {
1717
- case we:
1718
- return;
1719
- case Q:
1720
- throw U.FromError(t);
1721
- default:
1722
- throw new de(
1723
- `Message type ${t.constructor} not handled by SendMsgExpectOk`
1724
- );
1725
- }
1726
- }
1727
- async scalar(e) {
1728
- Array.isArray(e) ? await this.sendExpectOk(new me(e, this.index)) : await this.sendExpectOk(new me([e], this.index));
1729
- }
1730
- async scalarCommandBuilder(e, t) {
1731
- var u;
1732
- const n = (u = this.messageAttributes.ScalarCmd) == null ? void 0 : u.filter(
1733
- (a) => a.ActuatorType === t
1734
- );
1735
- if (!n || n.length === 0)
1736
- throw new P(
1737
- `Device ${this.name} has no ${t} capabilities`
1738
- );
1739
- const i = [];
1740
- if (typeof e == "number")
1741
- n.forEach(
1742
- (a) => i.push(new xe(a.Index, e, t))
1743
- );
1744
- else if (Array.isArray(e)) {
1745
- if (e.length > n.length)
1746
- throw new P(
1747
- `${e.length} commands send to a device with ${n.length} vibrators`
1748
- );
1749
- n.forEach((a, f) => {
1750
- i.push(new xe(a.Index, e[f], t));
1751
- });
1752
- } else
1753
- throw new P(
1754
- `${t} can only take numbers or arrays of numbers.`
1755
- );
1756
- await this.scalar(i);
1757
- }
1758
- get vibrateAttributes() {
1759
- var e;
1760
- return ((e = this.messageAttributes.ScalarCmd) == null ? void 0 : e.filter(
1761
- (t) => t.ActuatorType === ce.Vibrate
1762
- )) ?? [];
1763
- }
1764
- async vibrate(e) {
1765
- await this.scalarCommandBuilder(e, ce.Vibrate);
1766
- }
1767
- get oscillateAttributes() {
1768
- var e;
1769
- return ((e = this.messageAttributes.ScalarCmd) == null ? void 0 : e.filter(
1770
- (t) => t.ActuatorType === ce.Oscillate
1771
- )) ?? [];
1772
- }
1773
- async oscillate(e) {
1774
- await this.scalarCommandBuilder(e, ce.Oscillate);
1775
- }
1776
- get rotateAttributes() {
1777
- return this.messageAttributes.RotateCmd ?? [];
1778
- }
1779
- async rotate(e, t) {
1780
- const n = this.messageAttributes.RotateCmd;
1781
- if (!n || n.length === 0)
1782
- throw new P(
1783
- `Device ${this.name} has no Rotate capabilities`
1784
- );
1785
- let i;
1786
- if (typeof e == "number")
1787
- i = Ae.Create(
1788
- this.index,
1789
- new Array(n.length).fill([e, t])
1790
- );
1791
- else if (Array.isArray(e))
1792
- i = Ae.Create(this.index, e);
1793
- else
1794
- throw new P(
1795
- "SendRotateCmd can only take a number and boolean, or an array of number/boolean tuples"
1796
- );
1797
- await this.sendExpectOk(i);
1798
- }
1799
- get linearAttributes() {
1800
- return this.messageAttributes.LinearCmd ?? [];
1801
- }
1802
- async linear(e, t) {
1803
- const n = this.messageAttributes.LinearCmd;
1804
- if (!n || n.length === 0)
1805
- throw new P(
1806
- `Device ${this.name} has no Linear capabilities`
1807
- );
1808
- let i;
1809
- if (typeof e == "number")
1810
- i = Ee.Create(
1811
- this.index,
1812
- new Array(n.length).fill([e, t])
1813
- );
1814
- else if (Array.isArray(e))
1815
- i = Ee.Create(this.index, e);
1816
- else
1817
- throw new P(
1818
- "SendLinearCmd can only take a number and number, or an array of number/number tuples"
1819
- );
1820
- await this.sendExpectOk(i);
1821
- }
1822
- async sensorRead(e, t) {
1823
- const n = await this.send(
1824
- new Ge(this.index, e, t)
1825
- );
1826
- switch (ne(n)) {
1827
- case ze:
1828
- return n.Data;
1829
- case Q:
1830
- throw U.FromError(n);
1831
- default:
1832
- throw new de(
1833
- `Message type ${n.constructor} not handled by sensorRead`
1834
- );
1835
- }
480
+ if (t.Ok === void 0 && t.Error !== void 0)
481
+ throw m.FromError(t);
482
+ };
483
+ isOutputValid(e, t) {
484
+ if (!this._deviceInfo.DeviceFeatures.hasOwnProperty(e.toString()))
485
+ throw new E(`Feature index ${e} does not exist for device ${this.name}`);
486
+ if (this._deviceInfo.DeviceFeatures[e.toString()].Outputs !== void 0 && !this._deviceInfo.DeviceFeatures[e.toString()].Outputs.hasOwnProperty(t))
487
+ throw new E(`Feature index ${e} does not support type ${t} for device ${this.name}`);
488
+ }
489
+ hasOutput(e) {
490
+ return this._features.values().filter((t) => t.hasOutput(e)).toArray().length > 0;
491
+ }
492
+ hasInput(e) {
493
+ return this._features.values().filter((t) => t.hasInput(e)).toArray().length > 0;
494
+ }
495
+ async runOutput(e) {
496
+ let t = [];
497
+ for (let n of this._features.values())
498
+ n.hasOutput(e.outputType) && t.push(n.runOutput(e));
499
+ if (t.length == 0)
500
+ return Promise.reject(`No features with output type ${e.outputType}`);
501
+ await Promise.all(t);
1836
502
  }
1837
- get hasBattery() {
1838
- var t;
1839
- const e = (t = this.messageAttributes.SensorReadCmd) == null ? void 0 : t.filter(
1840
- (n) => n.SensorType === ee.Battery
1841
- );
1842
- return e !== void 0 && e.length > 0;
503
+ async stop() {
504
+ await this.sendMsgExpectOk({ StopDeviceCmd: { Id: 1, DeviceIndex: this.index } });
1843
505
  }
1844
506
  async battery() {
1845
- var n;
1846
- if (!this.hasBattery)
1847
- throw new P(
1848
- `Device ${this.name} has no Battery capabilities`
1849
- );
1850
- const e = (n = this.messageAttributes.SensorReadCmd) == null ? void 0 : n.filter(
1851
- (i) => i.SensorType === ee.Battery
1852
- );
1853
- return (await this.sensorRead(
1854
- e[0].Index,
1855
- ee.Battery
1856
- ))[0] / 100;
1857
- }
1858
- get hasRssi() {
1859
- var t;
1860
- const e = (t = this.messageAttributes.SensorReadCmd) == null ? void 0 : t.filter(
1861
- (n) => n.SensorType === ee.RSSI
1862
- );
1863
- return e !== void 0 && e.length === 0;
1864
- }
1865
- async rssi() {
1866
- var n;
1867
- if (!this.hasRssi)
1868
- throw new P(
1869
- `Device ${this.name} has no RSSI capabilities`
1870
- );
1871
- const e = (n = this.messageAttributes.SensorReadCmd) == null ? void 0 : n.filter(
1872
- (i) => i.SensorType === ee.RSSI
1873
- );
1874
- return (await this.sensorRead(
1875
- e[0].Index,
1876
- ee.RSSI
1877
- ))[0];
1878
- }
1879
- async rawRead(e, t, n) {
1880
- if (!this.messageAttributes.RawReadCmd)
1881
- throw new P(
1882
- `Device ${this.name} has no raw read capabilities`
1883
- );
1884
- if (this.messageAttributes.RawReadCmd.Endpoints.indexOf(e) === -1)
1885
- throw new P(
1886
- `Device ${this.name} has no raw readable endpoint ${e}`
1887
- );
1888
- const i = await this.send(
1889
- new Je(this.index, e, t, n)
1890
- );
1891
- switch (ne(i)) {
1892
- case Xe:
1893
- return new Uint8Array(i.Data);
1894
- case Q:
1895
- throw U.FromError(i);
1896
- default:
1897
- throw new de(
1898
- `Message type ${i.constructor} not handled by rawRead`
1899
- );
1900
- }
1901
- }
1902
- async rawWrite(e, t, n) {
1903
- if (!this.messageAttributes.RawWriteCmd)
1904
- throw new P(
1905
- `Device ${this.name} has no raw write capabilities`
1906
- );
1907
- if (this.messageAttributes.RawWriteCmd.Endpoints.indexOf(e) === -1)
1908
- throw new P(
1909
- `Device ${this.name} has no raw writable endpoint ${e}`
1910
- );
1911
- await this.sendExpectOk(
1912
- new qe(this.index, e, t, n)
1913
- );
1914
- }
1915
- async rawSubscribe(e) {
1916
- if (!this.messageAttributes.RawSubscribeCmd)
1917
- throw new P(
1918
- `Device ${this.name} has no raw subscribe capabilities`
1919
- );
1920
- if (this.messageAttributes.RawSubscribeCmd.Endpoints.indexOf(e) === -1)
1921
- throw new P(
1922
- `Device ${this.name} has no raw subscribable endpoint ${e}`
1923
- );
1924
- await this.sendExpectOk(new He(this.index, e));
1925
- }
1926
- async rawUnsubscribe(e) {
1927
- if (!this.messageAttributes.RawSubscribeCmd)
1928
- throw new P(
1929
- `Device ${this.name} has no raw unsubscribe capabilities`
1930
- );
1931
- if (this.messageAttributes.RawSubscribeCmd.Endpoints.indexOf(e) === -1)
1932
- throw new P(
1933
- `Device ${this.name} has no raw unsubscribable endpoint ${e}`
1934
- );
1935
- await this.sendExpectOk(
1936
- new Ye(this.index, e)
1937
- );
1938
- }
1939
- async stop() {
1940
- await this.sendExpectOk(new Ue(this.index));
507
+ for (let e of this._features.values())
508
+ if (e.hasInput(D.Battery)) {
509
+ let t = await e.runInput(D.Battery, L.Read);
510
+ if (t === void 0)
511
+ throw new R("Got incorrect message back.");
512
+ if (t.Reading[D.Battery] === void 0)
513
+ throw new R("Got reading with no Battery info.");
514
+ return t.Reading[D.Battery].Value;
515
+ }
516
+ throw new E("No battery present on this device.");
1941
517
  }
1942
518
  emitDisconnected() {
1943
519
  this.emit("deviceremoved");
1944
520
  }
1945
521
  }
1946
- /*!
1947
- * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1948
- * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1949
- * project root for full license information.
1950
- *
1951
- * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1952
- */
1953
- class Kt {
522
+ class Z {
1954
523
  constructor(e) {
1955
- this._useCounter = e, this._counter = 1, this._waitingMsgs = /* @__PURE__ */ new Map();
524
+ this._useCounter = e;
1956
525
  }
526
+ _counter = 1;
527
+ _waitingMsgs = /* @__PURE__ */ new Map();
1957
528
  // One of the places we should actually return a promise, as we need to store
1958
529
  // them while waiting for them to return across the line.
1959
530
  // tslint:disable:promise-function-async
1960
531
  PrepareOutgoingMessage(e) {
1961
- this._useCounter && (e.Id = this._counter, this._counter += 1);
532
+ this._useCounter && (Y(e, this._counter), this._counter += 1);
1962
533
  let t, n;
1963
- const i = new Promise(
1964
- (u, a) => {
1965
- t = u, n = a;
534
+ const a = new Promise(
535
+ (g, l) => {
536
+ t = g, n = l;
1966
537
  }
1967
538
  );
1968
- return this._waitingMsgs.set(e.Id, [t, n]), i;
539
+ return this._waitingMsgs.set(F(e), [t, n]), a;
1969
540
  }
1970
541
  ParseIncomingMessages(e) {
1971
542
  const t = [];
1972
- for (const n of e)
1973
- if (n.Id !== X && this._waitingMsgs.has(n.Id)) {
1974
- const [i, u] = this._waitingMsgs.get(n.Id);
1975
- if (n.Type === Q) {
1976
- u(U.FromError(n));
543
+ for (const n of e) {
544
+ let a = F(n);
545
+ if (a !== C && this._waitingMsgs.has(a)) {
546
+ const [g, l] = this._waitingMsgs.get(a);
547
+ if (n.Error !== void 0) {
548
+ l(m.FromError(n.Error));
1977
549
  continue;
1978
550
  }
1979
- i(n);
551
+ g(n);
1980
552
  continue;
1981
553
  } else
1982
554
  t.push(n);
555
+ }
1983
556
  return t;
1984
557
  }
1985
558
  }
1986
- /*!
1987
- * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1988
- * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1989
- * project root for full license information.
1990
- *
1991
- * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1992
- */
1993
- class Vt extends U {
559
+ class ee extends m {
1994
560
  constructor(e) {
1995
- super(e, z.ERROR_UNKNOWN);
561
+ super(e, w.ERROR_UNKNOWN);
1996
562
  }
1997
563
  }
1998
- class sn extends ve {
564
+ class ce extends P {
565
+ _pingTimer = null;
566
+ _connector = null;
567
+ _devices = /* @__PURE__ */ new Map();
568
+ _clientName;
569
+ _logger = b.Logger;
570
+ _isScanning = !1;
571
+ _sorter = new Z(!0);
1999
572
  constructor(e = "Generic Buttplug Client") {
2000
- super(), this._pingTimer = null, this._connector = null, this._devices = /* @__PURE__ */ new Map(), this._logger = Pt.Logger, this._isScanning = !1, this._sorter = new Kt(!0), this.connect = async (t) => {
2001
- this._logger.Info(
2002
- `ButtplugClient: Connecting using ${t.constructor.name}`
2003
- ), await t.connect(), this._connector = t, this._connector.addListener("message", this.parseMessages), this._connector.addListener("disconnect", this.disconnectHandler), await this.initializeConnection();
2004
- }, this.disconnect = async () => {
2005
- this._logger.Debug("ButtplugClient: Disconnect called"), this.checkConnector(), await this.shutdownConnection(), await this._connector.disconnect();
2006
- }, this.startScanning = async () => {
2007
- this._logger.Debug("ButtplugClient: StartScanning called"), this._isScanning = !0, await this.sendMsgExpectOk(new ke());
2008
- }, this.stopScanning = async () => {
2009
- this._logger.Debug("ButtplugClient: StopScanning called"), this._isScanning = !1, await this.sendMsgExpectOk(new je());
2010
- }, this.stopAllDevices = async () => {
2011
- this._logger.Debug("ButtplugClient: StopAllDevices"), await this.sendMsgExpectOk(new We());
2012
- }, this.disconnectHandler = () => {
2013
- this._logger.Info("ButtplugClient: Disconnect event receieved."), this.emit("disconnect");
2014
- }, this.parseMessages = (t) => {
2015
- const n = this._sorter.ParseIncomingMessages(t);
2016
- for (const i of n)
2017
- switch (ne(i)) {
2018
- case _e: {
2019
- const u = i, a = ye.fromMsg(
2020
- u,
2021
- this.sendDeviceMessageClosure
2022
- );
2023
- this._devices.set(u.DeviceIndex, a), this.emit("deviceadded", a);
2024
- break;
2025
- }
2026
- case Te: {
2027
- const u = i;
2028
- if (this._devices.has(u.DeviceIndex)) {
2029
- const a = this._devices.get(u.DeviceIndex);
2030
- a == null || a.emitDisconnected(), this._devices.delete(u.DeviceIndex), this.emit("deviceremoved", a);
2031
- }
2032
- break;
2033
- }
2034
- case Be:
2035
- this._isScanning = !1, this.emit("scanningfinished", i);
2036
- break;
2037
- }
2038
- }, this.initializeConnection = async () => {
2039
- this.checkConnector();
2040
- const t = await this.sendMessage(
2041
- new $e(
2042
- this._clientName,
2043
- ge
2044
- )
2045
- );
2046
- switch (ne(t)) {
2047
- case Fe: {
2048
- const n = t;
2049
- if (this._logger.Info(
2050
- `ButtplugClient: Connected to Server ${n.ServerName}`
2051
- ), n.MaxPingTime, n.MessageVersion < ge)
2052
- throw await this._connector.disconnect(), U.LogAndError(
2053
- Oe,
2054
- this._logger,
2055
- `Server protocol version ${n.MessageVersion} is older than client protocol version ${ge}. Please update server.`
2056
- );
2057
- return await this.requestDeviceList(), !0;
2058
- }
2059
- case Q: {
2060
- await this._connector.disconnect();
2061
- const n = t;
2062
- throw U.LogAndError(
2063
- Oe,
2064
- this._logger,
2065
- `Cannot connect to server. ${n.ErrorMessage}`
2066
- );
2067
- }
2068
- }
2069
- return !1;
2070
- }, this.requestDeviceList = async () => {
2071
- this.checkConnector(), this._logger.Debug("ButtplugClient: ReceiveDeviceList called"), (await this.sendMessage(
2072
- new Pe()
2073
- )).Devices.forEach((n) => {
2074
- if (this._devices.has(n.DeviceIndex))
2075
- this._logger.Debug(`ButtplugClient: Device already added: ${n}`);
2076
- else {
2077
- const i = ye.fromMsg(
2078
- n,
2079
- this.sendDeviceMessageClosure
2080
- );
2081
- this._logger.Debug(`ButtplugClient: Adding Device: ${i}`), this._devices.set(n.DeviceIndex, i), this.emit("deviceadded", i);
2082
- }
2083
- });
2084
- }, this.shutdownConnection = async () => {
2085
- await this.stopAllDevices(), this._pingTimer !== null && (clearInterval(this._pingTimer), this._pingTimer = null);
2086
- }, this.sendMsgExpectOk = async (t) => {
2087
- const n = await this.sendMessage(t);
2088
- switch (ne(n)) {
2089
- case we:
2090
- return;
2091
- case Q:
2092
- throw U.FromError(n);
2093
- default:
2094
- throw U.LogAndError(
2095
- de,
2096
- this._logger,
2097
- `Message type ${ne(n).constructor} not handled by SendMsgExpectOk`
2098
- );
2099
- }
2100
- }, this.sendDeviceMessageClosure = async (t, n) => await this.sendDeviceMessage(t, n), this._clientName = e, this._logger.Debug(`ButtplugClient: Client ${e} created.`);
573
+ super(), this._clientName = e, this._logger.Debug(`ButtplugClient: Client ${e} created.`);
2101
574
  }
2102
575
  get connected() {
2103
576
  return this._connector !== null && this._connector.Connected;
2104
577
  }
2105
578
  get devices() {
2106
- this.checkConnector();
2107
- const e = [];
2108
- return this._devices.forEach((t) => {
2109
- e.push(t);
2110
- }), e;
579
+ return this.checkConnector(), this._devices;
2111
580
  }
2112
581
  get isScanning() {
2113
582
  return this._isScanning;
2114
583
  }
2115
- async sendDeviceMessage(e, t) {
2116
- if (this.checkConnector(), this._devices.get(e.index) === void 0)
2117
- throw U.LogAndError(
2118
- P,
584
+ connect = async (e) => {
585
+ this._logger.Info(
586
+ `ButtplugClient: Connecting using ${e.constructor.name}`
587
+ ), await e.connect(), this._connector = e, this._connector.addListener("message", this.parseMessages), this._connector.addListener("disconnect", this.disconnectHandler), await this.initializeConnection();
588
+ };
589
+ disconnect = async () => {
590
+ this._logger.Debug("ButtplugClient: Disconnect called"), this.checkConnector(), await this.shutdownConnection(), await this._connector.disconnect();
591
+ };
592
+ startScanning = async () => {
593
+ this._logger.Debug("ButtplugClient: StartScanning called"), this._isScanning = !0, await this.sendMsgExpectOk({ StartScanning: { Id: 1 } });
594
+ };
595
+ stopScanning = async () => {
596
+ this._logger.Debug("ButtplugClient: StopScanning called"), this._isScanning = !1, await this.sendMsgExpectOk({ StopScanning: { Id: 1 } });
597
+ };
598
+ stopAllDevices = async () => {
599
+ this._logger.Debug("ButtplugClient: StopAllDevices"), await this.sendMsgExpectOk({ StopAllDevices: { Id: 1 } });
600
+ };
601
+ disconnectHandler = () => {
602
+ this._logger.Info("ButtplugClient: Disconnect event receieved."), this.emit("disconnect");
603
+ };
604
+ parseMessages = (e) => {
605
+ const t = this._sorter.ParseIncomingMessages(e);
606
+ for (const n of t)
607
+ if (n.DeviceList !== void 0) {
608
+ this.parseDeviceList(n);
609
+ break;
610
+ } else n.ScanningFinished !== void 0 ? (this._isScanning = !1, this.emit("scanningfinished", n)) : console.log(JSON.stringify(e));
611
+ };
612
+ initializeConnection = async () => {
613
+ this.checkConnector();
614
+ const e = await this.sendMessage(
615
+ {
616
+ RequestServerInfo: {
617
+ ClientName: this._clientName,
618
+ Id: 1,
619
+ ProtocolVersionMajor: H,
620
+ ProtocolVersionMinor: X
621
+ }
622
+ }
623
+ );
624
+ if (e.ServerInfo !== void 0) {
625
+ const t = e;
626
+ return this._logger.Info(
627
+ `ButtplugClient: Connected to Server ${t.ServerName}`
628
+ ), t.MaxPingTime, await this.requestDeviceList(), !0;
629
+ } else if (e.Error !== void 0) {
630
+ await this._connector.disconnect();
631
+ const t = e.Error;
632
+ throw m.LogAndError(
633
+ G,
2119
634
  this._logger,
2120
- `Device ${e.index} not available.`
635
+ `Cannot connect to server. ${t.ErrorMessage}`
2121
636
  );
2122
- return t.DeviceIndex = e.index, await this.sendMessage(t);
2123
- }
637
+ }
638
+ return !1;
639
+ };
640
+ parseDeviceList = (e) => {
641
+ for (let [t, n] of Object.entries(e.Devices))
642
+ if (this._devices.has(n.DeviceIndex))
643
+ this._logger.Debug(`ButtplugClient: Device already added: ${n}`);
644
+ else {
645
+ const a = B.fromMsg(
646
+ n,
647
+ this.sendMessageClosure
648
+ );
649
+ this._logger.Debug(`ButtplugClient: Adding Device: ${a}`), this._devices.set(n.DeviceIndex, a), this.emit("deviceadded", a);
650
+ }
651
+ for (let [t, n] of this._devices.entries())
652
+ e.Devices.hasOwnProperty(t.toString()) || (this._devices.delete(t), this.emit("deviceremoved", n));
653
+ };
654
+ requestDeviceList = async () => {
655
+ this.checkConnector(), this._logger.Debug("ButtplugClient: ReceiveDeviceList called");
656
+ const e = await this.sendMessage(
657
+ {
658
+ RequestDeviceList: { Id: 1 }
659
+ }
660
+ );
661
+ this.parseDeviceList(e.DeviceList);
662
+ };
663
+ shutdownConnection = async () => {
664
+ await this.stopAllDevices(), this._pingTimer !== null && (clearInterval(this._pingTimer), this._pingTimer = null);
665
+ };
2124
666
  async sendMessage(e) {
2125
667
  this.checkConnector();
2126
668
  const t = this._sorter.PrepareOutgoingMessage(e);
@@ -2128,131 +670,200 @@ class sn extends ve {
2128
670
  }
2129
671
  checkConnector() {
2130
672
  if (!this.connected)
2131
- throw new Vt(
673
+ throw new ee(
2132
674
  "ButtplugClient not connected"
2133
675
  );
2134
676
  }
677
+ sendMsgExpectOk = async (e) => {
678
+ const t = await this.sendMessage(e);
679
+ if (t.Ok === void 0)
680
+ throw t.Error !== void 0 ? m.FromError(t) : m.LogAndError(
681
+ R,
682
+ this._logger,
683
+ `Message ${t} not handled by SendMsgExpectOk`
684
+ );
685
+ };
686
+ sendMessageClosure = async (e) => await this.sendMessage(e);
2135
687
  }
2136
- class en extends ve {
688
+ class te extends P {
2137
689
  constructor(e) {
2138
- super(), this._url = e, this._websocketConstructor = null, this.connect = async () => {
2139
- const t = new (this._websocketConstructor ?? WebSocket)(this._url);
2140
- let n, i;
2141
- const u = new Promise((f, l) => {
2142
- n = f, i = l;
2143
- }), a = () => i();
2144
- return t.addEventListener("open", async () => {
2145
- this._ws = t;
2146
- try {
2147
- await this.initialize(), this._ws.addEventListener("message", (f) => {
2148
- this.parseIncomingMessage(f);
2149
- }), this._ws.removeEventListener("close", a), this._ws.addEventListener("close", this.disconnect), n();
2150
- } catch (f) {
2151
- console.log(f), i();
2152
- }
2153
- }), t.addEventListener("close", a), u;
2154
- }, this.disconnect = async () => {
2155
- this.Connected && (this._ws.close(), this._ws = void 0, this.emit("disconnect"));
2156
- }, this.initialize = async () => Promise.resolve();
690
+ super(), this._url = e;
2157
691
  }
692
+ _ws;
693
+ _websocketConstructor = null;
2158
694
  get Connected() {
2159
695
  return this._ws !== void 0;
2160
696
  }
697
+ connect = async () => new Promise((e, t) => {
698
+ const n = new (this._websocketConstructor ?? WebSocket)(this._url), a = (l) => {
699
+ t(l);
700
+ }, g = (l) => t(l.reason);
701
+ n.addEventListener("open", async () => {
702
+ this._ws = n;
703
+ try {
704
+ await this.initialize(), this._ws.addEventListener("message", (l) => {
705
+ this.parseIncomingMessage(l);
706
+ }), this._ws.removeEventListener("close", g), this._ws.removeEventListener("error", a), this._ws.addEventListener("close", this.disconnect), e();
707
+ } catch (l) {
708
+ t(l);
709
+ }
710
+ }), n.addEventListener("error", a), n.addEventListener("close", g);
711
+ });
712
+ disconnect = async () => {
713
+ this.Connected && (this._ws.close(), this._ws = void 0, this.emit("disconnect"));
714
+ };
2161
715
  sendMessage(e) {
2162
716
  if (!this.Connected)
2163
717
  throw new Error("ButtplugBrowserWebsocketConnector not connected");
2164
- this._ws.send("[" + e.toJSON() + "]");
718
+ this._ws.send("[" + JSON.stringify(e) + "]");
2165
719
  }
720
+ initialize = async () => Promise.resolve();
2166
721
  parseIncomingMessage(e) {
2167
722
  if (typeof e.data == "string") {
2168
- const t = ot(e.data);
723
+ const t = JSON.parse(e.data);
2169
724
  this.emit("message", t);
2170
- } else
2171
- e.data instanceof Blob;
725
+ } else e.data instanceof Blob;
2172
726
  }
2173
727
  onReaderLoad(e) {
2174
- const t = ot(e.target.result);
728
+ const t = JSON.parse(e.target.result);
2175
729
  this.emit("message", t);
2176
730
  }
2177
731
  }
2178
- class tn extends en {
2179
- constructor() {
2180
- super(...arguments), this.send = (e) => {
2181
- if (!this.Connected)
2182
- throw new Error("ButtplugClient not connected");
2183
- this.sendMessage(e);
2184
- };
732
+ class se extends te {
733
+ send = (e) => {
734
+ if (!this.Connected)
735
+ throw new Error("ButtplugClient not connected");
736
+ this.sendMessage(e);
737
+ };
738
+ }
739
+ var $, W;
740
+ function ne() {
741
+ return W || (W = 1, $ = function() {
742
+ throw new Error(
743
+ "ws does not work in the browser. Browser clients must use the native WebSocket object"
744
+ );
745
+ }), $;
746
+ }
747
+ var re = ne();
748
+ class ue extends se {
749
+ _websocketConstructor = re.WebSocket;
750
+ }
751
+ class x {
752
+ _percent;
753
+ _steps;
754
+ get percent() {
755
+ return this._percent;
756
+ }
757
+ get steps() {
758
+ return this._steps;
759
+ }
760
+ static createSteps(e) {
761
+ let t = new x();
762
+ return t._steps = e, t;
763
+ }
764
+ static createPercent(e) {
765
+ if (e < 0 || e > 1)
766
+ throw new E(`Percent value ${e} is not in the range 0.0 <= x <= 1.0`);
767
+ let t = new x();
768
+ return t._percent = e, t;
2185
769
  }
2186
770
  }
2187
- var nn = function() {
2188
- throw new Error(
2189
- "ws does not work in the browser. Browser clients must use the native WebSocket object"
2190
- );
2191
- };
2192
- class on extends tn {
771
+ class N {
772
+ constructor(e, t, n) {
773
+ this._outputType = e, this._value = t, this._duration = n;
774
+ }
775
+ get outputType() {
776
+ return this._outputType;
777
+ }
778
+ get value() {
779
+ return this._value;
780
+ }
781
+ get duration() {
782
+ return this._duration;
783
+ }
784
+ }
785
+ class O {
786
+ constructor(e) {
787
+ this._outputType = e;
788
+ }
789
+ steps(e) {
790
+ return new N(this._outputType, x.createSteps(e), void 0);
791
+ }
792
+ percent(e) {
793
+ return new N(this._outputType, x.createPercent(e), void 0);
794
+ }
795
+ }
796
+ class ie {
797
+ steps(e, t) {
798
+ return new N(_.Position, x.createSteps(e), t);
799
+ }
800
+ percent(e, t) {
801
+ return new N(_.PositionWithDuration, x.createPercent(e), t);
802
+ }
803
+ }
804
+ class he {
2193
805
  constructor() {
2194
- super(...arguments), this._websocketConstructor = nn.WebSocket;
806
+ }
807
+ static get Vibrate() {
808
+ return new O(_.Vibrate);
809
+ }
810
+ static get Rotate() {
811
+ return new O(_.Rotate);
812
+ }
813
+ static get Oscillate() {
814
+ return new O(_.Oscillate);
815
+ }
816
+ static get Constrict() {
817
+ return new O(_.Constrict);
818
+ }
819
+ static get Inflate() {
820
+ return new O(_.Inflate);
821
+ }
822
+ static get Temperature() {
823
+ return new O(_.Temperature);
824
+ }
825
+ static get Led() {
826
+ return new O(_.Led);
827
+ }
828
+ static get Spray() {
829
+ return new O(_.Spray);
830
+ }
831
+ static get Position() {
832
+ return new O(_.Position);
833
+ }
834
+ static get PositionWithDuration() {
835
+ return new ie();
2195
836
  }
2196
837
  }
2197
838
  export {
2198
- ce as ActuatorType,
2199
- tn as ButtplugBrowserWebsocketClientConnector,
2200
- sn as ButtplugClient,
2201
- Vt as ButtplugClientConnectorException,
2202
- ye as ButtplugClientDevice,
2203
- P as ButtplugDeviceError,
2204
- J as ButtplugDeviceMessage,
2205
- U as ButtplugError,
2206
- Oe as ButtplugInitError,
2207
- ct as ButtplugLogLevel,
2208
- Pt as ButtplugLogger,
2209
- H as ButtplugMessage,
2210
- de as ButtplugMessageError,
2211
- Kt as ButtplugMessageSorter,
2212
- on as ButtplugNodeWebsocketClientConnector,
2213
- Zt as ButtplugPingError,
2214
- ue as ButtplugSystemMessage,
2215
- Qt as ButtplugUnknownError,
2216
- D as DEFAULT_MESSAGE_ID,
2217
- _e as DeviceAdded,
2218
- De as DeviceInfo,
2219
- Ne as DeviceList,
2220
- Te as DeviceRemoved,
2221
- Q as Error,
2222
- z as ErrorClass,
2223
- qt as GenericDeviceMessageAttributes,
2224
- Se as GenericMessageSubcommand,
2225
- Ee as LinearCmd,
2226
- Tt as LogMessage,
2227
- Jt as MAX_ID,
2228
- ge as MESSAGE_SPEC_VERSION,
2229
- Re as MessageAttributes,
2230
- we as Ok,
2231
- dt as Ping,
2232
- Ht as RawDeviceMessageAttributes,
2233
- Je as RawReadCmd,
2234
- Xe as RawReading,
2235
- He as RawSubscribeCmd,
2236
- Ye as RawUnsubscribeCmd,
2237
- qe as RawWriteCmd,
2238
- Pe as RequestDeviceList,
2239
- $e as RequestServerInfo,
2240
- Ae as RotateCmd,
2241
- ht as RotateSubcommand,
2242
- X as SYSTEM_MESSAGE_ID,
2243
- me as ScalarCmd,
2244
- xe as ScalarSubcommand,
2245
- Be as ScanningFinished,
2246
- Yt as SensorDeviceMessageAttributes,
2247
- Ge as SensorReadCmd,
2248
- ze as SensorReading,
2249
- ee as SensorType,
2250
- Fe as ServerInfo,
2251
- ke as StartScanning,
2252
- We as StopAllDevices,
2253
- Ue as StopDeviceCmd,
2254
- je as StopScanning,
2255
- gt as VectorSubcommand,
2256
- ot as fromJSON,
2257
- ne as getMessageClassFromMessage
839
+ se as ButtplugBrowserWebsocketClientConnector,
840
+ ce as ButtplugClient,
841
+ ee as ButtplugClientConnectorException,
842
+ B as ButtplugClientDevice,
843
+ E as ButtplugDeviceError,
844
+ m as ButtplugError,
845
+ G as ButtplugInitError,
846
+ V as ButtplugLogLevel,
847
+ b as ButtplugLogger,
848
+ R as ButtplugMessageError,
849
+ Z as ButtplugMessageSorter,
850
+ ue as ButtplugNodeWebsocketClientConnector,
851
+ K as ButtplugPingError,
852
+ z as ButtplugUnknownError,
853
+ oe as DEFAULT_MESSAGE_ID,
854
+ he as DeviceOutput,
855
+ N as DeviceOutputCommand,
856
+ ie as DeviceOutputPositionWithDurationConstructor,
857
+ O as DeviceOutputValueConstructor,
858
+ w as ErrorClass,
859
+ L as InputCommandType,
860
+ D as InputType,
861
+ J as LogMessage,
862
+ ae as MAX_ID,
863
+ H as MESSAGE_SPEC_VERSION_MAJOR,
864
+ X as MESSAGE_SPEC_VERSION_MINOR,
865
+ _ as OutputType,
866
+ C as SYSTEM_MESSAGE_ID,
867
+ F as msgId,
868
+ Y as setMsgId
2258
869
  };