buttplug 3.1.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +13 -8
- package/CHANGELOG.md +23 -0
- package/README.md +24 -25
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -16
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +23 -52
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/client/ButtplugClientConnectorException.d.ts +11 -11
- package/dist/main/src/client/ButtplugClientConnectorException.js +41 -41
- package/dist/main/src/client/ButtplugClientDevice.d.ts +67 -67
- package/dist/main/src/client/ButtplugClientDevice.js +325 -324
- package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -18
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +19 -19
- package/dist/main/src/client/Client.d.ts +41 -40
- package/dist/main/src/client/Client.js +241 -235
- package/dist/main/src/client/Client.js.map +1 -1
- package/dist/main/src/client/IButtplugClientConnector.d.ts +16 -16
- package/dist/main/src/client/IButtplugClientConnector.js +9 -9
- package/dist/main/src/core/Exceptions.d.ts +36 -36
- package/dist/main/src/core/Exceptions.js +106 -106
- package/dist/main/src/core/Logging.d.ts +112 -112
- package/dist/main/src/core/Logging.js +170 -170
- package/dist/main/src/core/Logging.js.map +1 -1
- package/dist/main/src/core/MessageUtils.d.ts +10 -9
- package/dist/main/src/core/MessageUtils.js +64 -58
- package/dist/main/src/core/MessageUtils.js.map +1 -1
- package/dist/main/src/core/Messages.d.ts +275 -275
- package/dist/main/src/core/Messages.js +429 -429
- package/dist/main/src/core/Messages.js.map +1 -1
- package/dist/main/src/index.d.ts +18 -18
- package/dist/main/src/index.js +34 -34
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -22
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +95 -95
- package/dist/main/src/utils/ButtplugMessageSorter.d.ts +19 -19
- package/dist/main/src/utils/ButtplugMessageSorter.js +81 -81
- package/dist/main/src/utils/Utils.d.ts +1 -1
- package/dist/main/src/utils/Utils.js +7 -7
- package/dist/web/buttplug.js +38 -7126
- package/dist/web/buttplug.mjs +2258 -0
- package/dist/web/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -0
- package/dist/web/client/ButtplugClientConnectorException.d.ts +11 -0
- package/dist/web/client/ButtplugClientDevice.d.ts +67 -0
- package/dist/web/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -0
- package/dist/web/client/Client.d.ts +41 -0
- package/dist/web/client/IButtplugClientConnector.d.ts +16 -0
- package/dist/web/core/Exceptions.d.ts +36 -0
- package/dist/web/core/Logging.d.ts +112 -0
- package/dist/web/core/MessageUtils.d.ts +10 -0
- package/dist/web/core/Messages.d.ts +274 -0
- package/dist/web/index.d.ts +18 -0
- package/dist/web/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -0
- package/dist/web/utils/ButtplugMessageSorter.d.ts +19 -0
- package/dist/web/utils/Utils.d.ts +1 -0
- package/package.json +23 -53
- package/src/client/ButtplugBrowserWebsocketClientConnector.ts +2 -24
- package/src/client/ButtplugClientDevice.ts +5 -4
- package/src/client/Client.ts +17 -10
- package/src/client/IButtplugClientConnector.ts +4 -4
- package/src/core/MessageUtils.ts +9 -1
- package/src/utils/ButtplugBrowserWebsocketConnector.ts +12 -12
- package/vite.config.ts +26 -0
- package/.github/FUNDING.yml +0 -5
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -17
- package/.github/workflows/docs.yaml +0 -29
- package/azure-pipelines.yml +0 -19
- package/dist/web/buttplug.min.js +0 -3
- package/dist/web/buttplug.min.js.LICENSE.txt +0 -31
- package/dist/web/buttplug.min.js.map +0 -1
- package/jest-puppeteer.config.js +0 -5
- package/rollup.config.js +0 -55
- package/util/convert_device_config.js +0 -6
|
@@ -0,0 +1,2258 @@
|
|
|
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) {
|
|
72
|
+
case 1:
|
|
73
|
+
g[S].fn.call(g[S].context);
|
|
74
|
+
break;
|
|
75
|
+
case 2:
|
|
76
|
+
g[S].fn.call(g[S].context, p);
|
|
77
|
+
break;
|
|
78
|
+
case 3:
|
|
79
|
+
g[S].fn.call(g[S].context, p, m);
|
|
80
|
+
break;
|
|
81
|
+
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);
|
|
89
|
+
}
|
|
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])
|
|
99
|
+
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 {
|
|
127
|
+
/**
|
|
128
|
+
* @param logMessage Log message.
|
|
129
|
+
* @param logLevel: Log severity level.
|
|
130
|
+
*/
|
|
131
|
+
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;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns the log message.
|
|
137
|
+
*/
|
|
138
|
+
get Message() {
|
|
139
|
+
return this.logMessage;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the log message level.
|
|
143
|
+
*/
|
|
144
|
+
get LogLevel() {
|
|
145
|
+
return this.logLevel;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns the log message timestamp.
|
|
149
|
+
*/
|
|
150
|
+
get Timestamp() {
|
|
151
|
+
return this.timestamp;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns a formatted string with timestamp, level, and message.
|
|
155
|
+
*/
|
|
156
|
+
get FormattedMessage() {
|
|
157
|
+
return `${ct[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
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
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Returns the stored static instance of the logger, creating one if it
|
|
170
|
+
* doesn't currently exist.
|
|
171
|
+
*/
|
|
172
|
+
static get Logger() {
|
|
173
|
+
return le.sLogger === void 0 && (le.sLogger = new le()), this.sLogger;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Set the maximum log level to output to console.
|
|
177
|
+
*/
|
|
178
|
+
get MaximumConsoleLogLevel() {
|
|
179
|
+
return this.maximumConsoleLogLevel;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get the maximum log level to output to console.
|
|
183
|
+
*/
|
|
184
|
+
set MaximumConsoleLogLevel(e) {
|
|
185
|
+
this.maximumConsoleLogLevel = e;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Set the global maximum log level
|
|
189
|
+
*/
|
|
190
|
+
get MaximumEventLogLevel() {
|
|
191
|
+
return this.maximumEventLogLevel;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get the global maximum log level
|
|
195
|
+
*/
|
|
196
|
+
set MaximumEventLogLevel(e) {
|
|
197
|
+
this.maximumEventLogLevel = e;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Log new message at Error level.
|
|
201
|
+
*/
|
|
202
|
+
Error(e) {
|
|
203
|
+
this.AddLogMessage(
|
|
204
|
+
e,
|
|
205
|
+
1
|
|
206
|
+
/* Error */
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Log new message at Warn level.
|
|
211
|
+
*/
|
|
212
|
+
Warn(e) {
|
|
213
|
+
this.AddLogMessage(
|
|
214
|
+
e,
|
|
215
|
+
2
|
|
216
|
+
/* Warn */
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Log new message at Info level.
|
|
221
|
+
*/
|
|
222
|
+
Info(e) {
|
|
223
|
+
this.AddLogMessage(
|
|
224
|
+
e,
|
|
225
|
+
3
|
|
226
|
+
/* Info */
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Log new message at Debug level.
|
|
231
|
+
*/
|
|
232
|
+
Debug(e) {
|
|
233
|
+
this.AddLogMessage(
|
|
234
|
+
e,
|
|
235
|
+
4
|
|
236
|
+
/* Debug */
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Log new message at Trace level.
|
|
241
|
+
*/
|
|
242
|
+
Trace(e) {
|
|
243
|
+
this.AddLogMessage(
|
|
244
|
+
e,
|
|
245
|
+
5
|
|
246
|
+
/* Trace */
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Checks to see if message should be logged, and if so, adds message to the
|
|
251
|
+
* log buffer. May also print message and emit event.
|
|
252
|
+
*/
|
|
253
|
+
AddLogMessage(e, t) {
|
|
254
|
+
if (t > this.maximumEventLogLevel && t > this.maximumConsoleLogLevel)
|
|
255
|
+
return;
|
|
256
|
+
const n = new Tt(e, t);
|
|
257
|
+
t <= this.maximumConsoleLogLevel && console.log(n.FormattedMessage), t <= this.maximumEventLogLevel && this.emit("log", n);
|
|
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
|
+
}
|
|
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
|
+
}
|
|
1589
|
+
get ErrorClass() {
|
|
1590
|
+
return this.errorClass;
|
|
1591
|
+
}
|
|
1592
|
+
get InnerError() {
|
|
1593
|
+
return this.innerError;
|
|
1594
|
+
}
|
|
1595
|
+
get Id() {
|
|
1596
|
+
return this.messageId;
|
|
1597
|
+
}
|
|
1598
|
+
get ErrorMessage() {
|
|
1599
|
+
return new Q(this.message, this.ErrorClass, this.Id);
|
|
1600
|
+
}
|
|
1601
|
+
static LogAndError(e, t, n, i = X) {
|
|
1602
|
+
return t.Error(n), new e(n, i);
|
|
1603
|
+
}
|
|
1604
|
+
static FromError(e) {
|
|
1605
|
+
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);
|
|
1616
|
+
default:
|
|
1617
|
+
throw new Error(`Message type ${e.ErrorCode} not handled`);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
class Oe extends U {
|
|
1622
|
+
constructor(e, t = X) {
|
|
1623
|
+
super(e, z.ERROR_INIT, t);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
class P extends U {
|
|
1627
|
+
constructor(e, t = X) {
|
|
1628
|
+
super(e, z.ERROR_DEVICE, t);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
class de extends U {
|
|
1632
|
+
constructor(e, t = X) {
|
|
1633
|
+
super(e, z.ERROR_MSG, t);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
class Zt extends U {
|
|
1637
|
+
constructor(e, t = X) {
|
|
1638
|
+
super(e, z.ERROR_PING, t);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
class Qt extends U {
|
|
1642
|
+
constructor(e, t = X) {
|
|
1643
|
+
super(e, z.ERROR_UNKNOWN, t);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
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;
|
|
1651
|
+
}
|
|
1652
|
+
function ne(r) {
|
|
1653
|
+
return vt(Object.getPrototypeOf(r).constructor.Name);
|
|
1654
|
+
}
|
|
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);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
return t;
|
|
1668
|
+
}
|
|
1669
|
+
class ye extends ve {
|
|
1670
|
+
/**
|
|
1671
|
+
* @param _index Index of the device, as created by the device manager.
|
|
1672
|
+
* @param _name Name of the device.
|
|
1673
|
+
* @param allowedMsgs Buttplug messages the device can receive.
|
|
1674
|
+
*/
|
|
1675
|
+
constructor(e, t) {
|
|
1676
|
+
super(), this._deviceInfo = e, this._sendClosure = t, this.allowedMsgs = /* @__PURE__ */ new Map(), e.DeviceMessages.update();
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Return the name of the device.
|
|
1680
|
+
*/
|
|
1681
|
+
get name() {
|
|
1682
|
+
return this._deviceInfo.DeviceName;
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Return the user set name of the device.
|
|
1686
|
+
*/
|
|
1687
|
+
get displayName() {
|
|
1688
|
+
return this._deviceInfo.DeviceDisplayName;
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Return the index of the device.
|
|
1692
|
+
*/
|
|
1693
|
+
get index() {
|
|
1694
|
+
return this._deviceInfo.DeviceIndex;
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Return the index of the device.
|
|
1698
|
+
*/
|
|
1699
|
+
get messageTimingGap() {
|
|
1700
|
+
return this._deviceInfo.DeviceMessageTimingGap;
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Return a list of message types the device accepts.
|
|
1704
|
+
*/
|
|
1705
|
+
get messageAttributes() {
|
|
1706
|
+
return this._deviceInfo.DeviceMessages;
|
|
1707
|
+
}
|
|
1708
|
+
static fromMsg(e, t) {
|
|
1709
|
+
return new ye(e, t);
|
|
1710
|
+
}
|
|
1711
|
+
async send(e) {
|
|
1712
|
+
return await this._sendClosure(this, e);
|
|
1713
|
+
}
|
|
1714
|
+
async sendExpectOk(e) {
|
|
1715
|
+
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
|
+
}
|
|
1836
|
+
}
|
|
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;
|
|
1843
|
+
}
|
|
1844
|
+
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));
|
|
1941
|
+
}
|
|
1942
|
+
emitDisconnected() {
|
|
1943
|
+
this.emit("deviceremoved");
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
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 {
|
|
1954
|
+
constructor(e) {
|
|
1955
|
+
this._useCounter = e, this._counter = 1, this._waitingMsgs = /* @__PURE__ */ new Map();
|
|
1956
|
+
}
|
|
1957
|
+
// One of the places we should actually return a promise, as we need to store
|
|
1958
|
+
// them while waiting for them to return across the line.
|
|
1959
|
+
// tslint:disable:promise-function-async
|
|
1960
|
+
PrepareOutgoingMessage(e) {
|
|
1961
|
+
this._useCounter && (e.Id = this._counter, this._counter += 1);
|
|
1962
|
+
let t, n;
|
|
1963
|
+
const i = new Promise(
|
|
1964
|
+
(u, a) => {
|
|
1965
|
+
t = u, n = a;
|
|
1966
|
+
}
|
|
1967
|
+
);
|
|
1968
|
+
return this._waitingMsgs.set(e.Id, [t, n]), i;
|
|
1969
|
+
}
|
|
1970
|
+
ParseIncomingMessages(e) {
|
|
1971
|
+
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));
|
|
1977
|
+
continue;
|
|
1978
|
+
}
|
|
1979
|
+
i(n);
|
|
1980
|
+
continue;
|
|
1981
|
+
} else
|
|
1982
|
+
t.push(n);
|
|
1983
|
+
return t;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
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 {
|
|
1994
|
+
constructor(e) {
|
|
1995
|
+
super(e, z.ERROR_UNKNOWN);
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
class sn extends ve {
|
|
1999
|
+
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.`);
|
|
2101
|
+
}
|
|
2102
|
+
get connected() {
|
|
2103
|
+
return this._connector !== null && this._connector.Connected;
|
|
2104
|
+
}
|
|
2105
|
+
get devices() {
|
|
2106
|
+
this.checkConnector();
|
|
2107
|
+
const e = [];
|
|
2108
|
+
return this._devices.forEach((t) => {
|
|
2109
|
+
e.push(t);
|
|
2110
|
+
}), e;
|
|
2111
|
+
}
|
|
2112
|
+
get isScanning() {
|
|
2113
|
+
return this._isScanning;
|
|
2114
|
+
}
|
|
2115
|
+
async sendDeviceMessage(e, t) {
|
|
2116
|
+
if (this.checkConnector(), this._devices.get(e.index) === void 0)
|
|
2117
|
+
throw U.LogAndError(
|
|
2118
|
+
P,
|
|
2119
|
+
this._logger,
|
|
2120
|
+
`Device ${e.index} not available.`
|
|
2121
|
+
);
|
|
2122
|
+
return t.DeviceIndex = e.index, await this.sendMessage(t);
|
|
2123
|
+
}
|
|
2124
|
+
async sendMessage(e) {
|
|
2125
|
+
this.checkConnector();
|
|
2126
|
+
const t = this._sorter.PrepareOutgoingMessage(e);
|
|
2127
|
+
return await this._connector.send(e), await t;
|
|
2128
|
+
}
|
|
2129
|
+
checkConnector() {
|
|
2130
|
+
if (!this.connected)
|
|
2131
|
+
throw new Vt(
|
|
2132
|
+
"ButtplugClient not connected"
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
class en extends ve {
|
|
2137
|
+
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();
|
|
2157
|
+
}
|
|
2158
|
+
get Connected() {
|
|
2159
|
+
return this._ws !== void 0;
|
|
2160
|
+
}
|
|
2161
|
+
sendMessage(e) {
|
|
2162
|
+
if (!this.Connected)
|
|
2163
|
+
throw new Error("ButtplugBrowserWebsocketConnector not connected");
|
|
2164
|
+
this._ws.send("[" + e.toJSON() + "]");
|
|
2165
|
+
}
|
|
2166
|
+
parseIncomingMessage(e) {
|
|
2167
|
+
if (typeof e.data == "string") {
|
|
2168
|
+
const t = ot(e.data);
|
|
2169
|
+
this.emit("message", t);
|
|
2170
|
+
} else
|
|
2171
|
+
e.data instanceof Blob;
|
|
2172
|
+
}
|
|
2173
|
+
onReaderLoad(e) {
|
|
2174
|
+
const t = ot(e.target.result);
|
|
2175
|
+
this.emit("message", t);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
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
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
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 {
|
|
2193
|
+
constructor() {
|
|
2194
|
+
super(...arguments), this._websocketConstructor = nn.WebSocket;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
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
|
|
2258
|
+
};
|