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
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
4
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
5
|
-
* project root for full license information.
|
|
6
|
-
*
|
|
7
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ButtplugLogger = exports.LogMessage = exports.ButtplugLogLevel = void 0;
|
|
11
|
-
const eventemitter3_1 = require("eventemitter3");
|
|
12
|
-
var ButtplugLogLevel;
|
|
13
|
-
(function (ButtplugLogLevel) {
|
|
14
|
-
ButtplugLogLevel[ButtplugLogLevel["Off"] = 0] = "Off";
|
|
15
|
-
ButtplugLogLevel[ButtplugLogLevel["Error"] = 1] = "Error";
|
|
16
|
-
ButtplugLogLevel[ButtplugLogLevel["Warn"] = 2] = "Warn";
|
|
17
|
-
ButtplugLogLevel[ButtplugLogLevel["Info"] = 3] = "Info";
|
|
18
|
-
ButtplugLogLevel[ButtplugLogLevel["Debug"] = 4] = "Debug";
|
|
19
|
-
ButtplugLogLevel[ButtplugLogLevel["Trace"] = 5] = "Trace";
|
|
20
|
-
})(ButtplugLogLevel
|
|
21
|
-
/**
|
|
22
|
-
* Representation of log messages for the internal logging utility.
|
|
23
|
-
*/
|
|
24
|
-
class LogMessage {
|
|
25
|
-
/**
|
|
26
|
-
* @param logMessage Log message.
|
|
27
|
-
* @param logLevel: Log severity level.
|
|
28
|
-
*/
|
|
29
|
-
constructor(logMessage, logLevel) {
|
|
30
|
-
const a = new Date();
|
|
31
|
-
const hour = a.getHours();
|
|
32
|
-
const min = a.getMinutes();
|
|
33
|
-
const sec = a.getSeconds();
|
|
34
|
-
this.timestamp = `${hour}:${min}:${sec}`;
|
|
35
|
-
this.logMessage = logMessage;
|
|
36
|
-
this.logLevel = logLevel;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns the log message.
|
|
40
|
-
*/
|
|
41
|
-
get Message() {
|
|
42
|
-
return this.logMessage;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns the log message level.
|
|
46
|
-
*/
|
|
47
|
-
get LogLevel() {
|
|
48
|
-
return this.logLevel;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns the log message timestamp.
|
|
52
|
-
*/
|
|
53
|
-
get Timestamp() {
|
|
54
|
-
return this.timestamp;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns a formatted string with timestamp, level, and message.
|
|
58
|
-
*/
|
|
59
|
-
get FormattedMessage() {
|
|
60
|
-
return `${ButtplugLogLevel[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.LogMessage = LogMessage;
|
|
64
|
-
/**
|
|
65
|
-
* Simple, global logging utility for the Buttplug client and server. Keeps an
|
|
66
|
-
* internal static reference to an instance of itself (singleton pattern,
|
|
67
|
-
* basically), and allows message logging throughout the module.
|
|
68
|
-
*/
|
|
69
|
-
class ButtplugLogger extends eventemitter3_1.EventEmitter {
|
|
70
|
-
/**
|
|
71
|
-
* Returns the stored static instance of the logger, creating one if it
|
|
72
|
-
* doesn't currently exist.
|
|
73
|
-
*/
|
|
74
|
-
static get Logger() {
|
|
75
|
-
if (ButtplugLogger.sLogger === undefined) {
|
|
76
|
-
ButtplugLogger.sLogger = new ButtplugLogger();
|
|
77
|
-
}
|
|
78
|
-
return this.sLogger;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Constructor. Can only be called internally since we regulate ButtplugLogger
|
|
82
|
-
* ownership.
|
|
83
|
-
*/
|
|
84
|
-
constructor() {
|
|
85
|
-
super();
|
|
86
|
-
/** Sets maximum log level to log to console */
|
|
87
|
-
this.maximumConsoleLogLevel = ButtplugLogLevel.Off;
|
|
88
|
-
/** Sets maximum log level for all log messages */
|
|
89
|
-
this.maximumEventLogLevel = ButtplugLogLevel.Off;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Set the maximum log level to output to console.
|
|
93
|
-
*/
|
|
94
|
-
get MaximumConsoleLogLevel() {
|
|
95
|
-
return this.maximumConsoleLogLevel;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get the maximum log level to output to console.
|
|
99
|
-
*/
|
|
100
|
-
set MaximumConsoleLogLevel(buttplugLogLevel) {
|
|
101
|
-
this.maximumConsoleLogLevel = buttplugLogLevel;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Set the global maximum log level
|
|
105
|
-
*/
|
|
106
|
-
get MaximumEventLogLevel() {
|
|
107
|
-
return this.maximumEventLogLevel;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Get the global maximum log level
|
|
111
|
-
*/
|
|
112
|
-
set MaximumEventLogLevel(logLevel) {
|
|
113
|
-
this.maximumEventLogLevel = logLevel;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Log new message at Error level.
|
|
117
|
-
*/
|
|
118
|
-
Error(msg) {
|
|
119
|
-
this.AddLogMessage(msg, ButtplugLogLevel.Error);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Log new message at Warn level.
|
|
123
|
-
*/
|
|
124
|
-
Warn(msg) {
|
|
125
|
-
this.AddLogMessage(msg, ButtplugLogLevel.Warn);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Log new message at Info level.
|
|
129
|
-
*/
|
|
130
|
-
Info(msg) {
|
|
131
|
-
this.AddLogMessage(msg, ButtplugLogLevel.Info);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Log new message at Debug level.
|
|
135
|
-
*/
|
|
136
|
-
Debug(msg) {
|
|
137
|
-
this.AddLogMessage(msg, ButtplugLogLevel.Debug);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Log new message at Trace level.
|
|
141
|
-
*/
|
|
142
|
-
Trace(msg) {
|
|
143
|
-
this.AddLogMessage(msg, ButtplugLogLevel.Trace);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Checks to see if message should be logged, and if so, adds message to the
|
|
147
|
-
* log buffer. May also print message and emit event.
|
|
148
|
-
*/
|
|
149
|
-
AddLogMessage(msg, level) {
|
|
150
|
-
// If nothing wants the log message we have, ignore it.
|
|
151
|
-
if (level > this.maximumEventLogLevel &&
|
|
152
|
-
level > this.maximumConsoleLogLevel) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const logMsg = new LogMessage(msg, level);
|
|
156
|
-
// Clients and console logging may have different needs. For instance, it
|
|
157
|
-
// could be that the client requests trace level, while all we want in the
|
|
158
|
-
// console is info level. This makes sure the client can't also spam the
|
|
159
|
-
// console.
|
|
160
|
-
if (level <= this.maximumConsoleLogLevel) {
|
|
161
|
-
console.log(logMsg.FormattedMessage);
|
|
162
|
-
}
|
|
163
|
-
if (level <= this.maximumEventLogLevel) {
|
|
164
|
-
this.emit('log', logMsg);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.ButtplugLogger = ButtplugLogger;
|
|
169
|
-
/** Singleton instance for the logger */
|
|
170
|
-
ButtplugLogger.sLogger = undefined;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
4
|
+
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
5
|
+
* project root for full license information.
|
|
6
|
+
*
|
|
7
|
+
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ButtplugLogger = exports.LogMessage = exports.ButtplugLogLevel = void 0;
|
|
11
|
+
const eventemitter3_1 = require("eventemitter3");
|
|
12
|
+
var ButtplugLogLevel;
|
|
13
|
+
(function (ButtplugLogLevel) {
|
|
14
|
+
ButtplugLogLevel[ButtplugLogLevel["Off"] = 0] = "Off";
|
|
15
|
+
ButtplugLogLevel[ButtplugLogLevel["Error"] = 1] = "Error";
|
|
16
|
+
ButtplugLogLevel[ButtplugLogLevel["Warn"] = 2] = "Warn";
|
|
17
|
+
ButtplugLogLevel[ButtplugLogLevel["Info"] = 3] = "Info";
|
|
18
|
+
ButtplugLogLevel[ButtplugLogLevel["Debug"] = 4] = "Debug";
|
|
19
|
+
ButtplugLogLevel[ButtplugLogLevel["Trace"] = 5] = "Trace";
|
|
20
|
+
})(ButtplugLogLevel || (exports.ButtplugLogLevel = ButtplugLogLevel = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Representation of log messages for the internal logging utility.
|
|
23
|
+
*/
|
|
24
|
+
class LogMessage {
|
|
25
|
+
/**
|
|
26
|
+
* @param logMessage Log message.
|
|
27
|
+
* @param logLevel: Log severity level.
|
|
28
|
+
*/
|
|
29
|
+
constructor(logMessage, logLevel) {
|
|
30
|
+
const a = new Date();
|
|
31
|
+
const hour = a.getHours();
|
|
32
|
+
const min = a.getMinutes();
|
|
33
|
+
const sec = a.getSeconds();
|
|
34
|
+
this.timestamp = `${hour}:${min}:${sec}`;
|
|
35
|
+
this.logMessage = logMessage;
|
|
36
|
+
this.logLevel = logLevel;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the log message.
|
|
40
|
+
*/
|
|
41
|
+
get Message() {
|
|
42
|
+
return this.logMessage;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the log message level.
|
|
46
|
+
*/
|
|
47
|
+
get LogLevel() {
|
|
48
|
+
return this.logLevel;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the log message timestamp.
|
|
52
|
+
*/
|
|
53
|
+
get Timestamp() {
|
|
54
|
+
return this.timestamp;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns a formatted string with timestamp, level, and message.
|
|
58
|
+
*/
|
|
59
|
+
get FormattedMessage() {
|
|
60
|
+
return `${ButtplugLogLevel[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.LogMessage = LogMessage;
|
|
64
|
+
/**
|
|
65
|
+
* Simple, global logging utility for the Buttplug client and server. Keeps an
|
|
66
|
+
* internal static reference to an instance of itself (singleton pattern,
|
|
67
|
+
* basically), and allows message logging throughout the module.
|
|
68
|
+
*/
|
|
69
|
+
class ButtplugLogger extends eventemitter3_1.EventEmitter {
|
|
70
|
+
/**
|
|
71
|
+
* Returns the stored static instance of the logger, creating one if it
|
|
72
|
+
* doesn't currently exist.
|
|
73
|
+
*/
|
|
74
|
+
static get Logger() {
|
|
75
|
+
if (ButtplugLogger.sLogger === undefined) {
|
|
76
|
+
ButtplugLogger.sLogger = new ButtplugLogger();
|
|
77
|
+
}
|
|
78
|
+
return this.sLogger;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Constructor. Can only be called internally since we regulate ButtplugLogger
|
|
82
|
+
* ownership.
|
|
83
|
+
*/
|
|
84
|
+
constructor() {
|
|
85
|
+
super();
|
|
86
|
+
/** Sets maximum log level to log to console */
|
|
87
|
+
this.maximumConsoleLogLevel = ButtplugLogLevel.Off;
|
|
88
|
+
/** Sets maximum log level for all log messages */
|
|
89
|
+
this.maximumEventLogLevel = ButtplugLogLevel.Off;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Set the maximum log level to output to console.
|
|
93
|
+
*/
|
|
94
|
+
get MaximumConsoleLogLevel() {
|
|
95
|
+
return this.maximumConsoleLogLevel;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the maximum log level to output to console.
|
|
99
|
+
*/
|
|
100
|
+
set MaximumConsoleLogLevel(buttplugLogLevel) {
|
|
101
|
+
this.maximumConsoleLogLevel = buttplugLogLevel;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Set the global maximum log level
|
|
105
|
+
*/
|
|
106
|
+
get MaximumEventLogLevel() {
|
|
107
|
+
return this.maximumEventLogLevel;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the global maximum log level
|
|
111
|
+
*/
|
|
112
|
+
set MaximumEventLogLevel(logLevel) {
|
|
113
|
+
this.maximumEventLogLevel = logLevel;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Log new message at Error level.
|
|
117
|
+
*/
|
|
118
|
+
Error(msg) {
|
|
119
|
+
this.AddLogMessage(msg, ButtplugLogLevel.Error);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Log new message at Warn level.
|
|
123
|
+
*/
|
|
124
|
+
Warn(msg) {
|
|
125
|
+
this.AddLogMessage(msg, ButtplugLogLevel.Warn);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Log new message at Info level.
|
|
129
|
+
*/
|
|
130
|
+
Info(msg) {
|
|
131
|
+
this.AddLogMessage(msg, ButtplugLogLevel.Info);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Log new message at Debug level.
|
|
135
|
+
*/
|
|
136
|
+
Debug(msg) {
|
|
137
|
+
this.AddLogMessage(msg, ButtplugLogLevel.Debug);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Log new message at Trace level.
|
|
141
|
+
*/
|
|
142
|
+
Trace(msg) {
|
|
143
|
+
this.AddLogMessage(msg, ButtplugLogLevel.Trace);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Checks to see if message should be logged, and if so, adds message to the
|
|
147
|
+
* log buffer. May also print message and emit event.
|
|
148
|
+
*/
|
|
149
|
+
AddLogMessage(msg, level) {
|
|
150
|
+
// If nothing wants the log message we have, ignore it.
|
|
151
|
+
if (level > this.maximumEventLogLevel &&
|
|
152
|
+
level > this.maximumConsoleLogLevel) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const logMsg = new LogMessage(msg, level);
|
|
156
|
+
// Clients and console logging may have different needs. For instance, it
|
|
157
|
+
// could be that the client requests trace level, while all we want in the
|
|
158
|
+
// console is info level. This makes sure the client can't also spam the
|
|
159
|
+
// console.
|
|
160
|
+
if (level <= this.maximumConsoleLogLevel) {
|
|
161
|
+
console.log(logMsg.FormattedMessage);
|
|
162
|
+
}
|
|
163
|
+
if (level <= this.maximumEventLogLevel) {
|
|
164
|
+
this.emit('log', logMsg);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.ButtplugLogger = ButtplugLogger;
|
|
169
|
+
/** Singleton instance for the logger */
|
|
170
|
+
ButtplugLogger.sLogger = undefined;
|
|
171
171
|
//# sourceMappingURL=Logging.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../../src/core/Logging.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iDAA6C;AAE7C,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,qDAAG,CAAA;IACH,yDAAK,CAAA;IACL,uDAAI,CAAA;IACJ,uDAAI,CAAA;IACJ,yDAAK,CAAA;IACL,yDAAK,CAAA;AACP,CAAC,EAPW,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../../src/core/Logging.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iDAA6C;AAE7C,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,qDAAG,CAAA;IACH,yDAAK,CAAA;IACL,uDAAI,CAAA;IACJ,uDAAI,CAAA;IACJ,yDAAK,CAAA;IACL,yDAAK,CAAA;AACP,CAAC,EAPW,gBAAgB,gCAAhB,gBAAgB,QAO3B;AAED;;GAEG;AACH,MAAa,UAAU;IAUrB;;;OAGG;IACH,YAAmB,UAAkB,EAAE,QAA0B;QAC/D,MA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,0EAA0E;QAC1E,wEAAwE;QACxE,WAAW;QACX,IAAI,KAAK,IAAI,IAAI,CAAC,sBAAsB,EAAE;YACxC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;SACtC;QACD,IAAI,KAAK,IAAI,IAAI,CAAC,oBAAoB,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC1B;IACH,CAAC;;AAjHH,wCAkHC;AAjHC,wCAAwC;AACvB,sBAAO,GAA+B,SAAS,AAAxC,CAAyC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
|
-
import * as Messages from './Messages';
|
|
9
|
-
export declare function
|
|
1
|
+
/*!
|
|
2
|
+
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
+
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
+
* project root for full license information.
|
|
5
|
+
*
|
|
6
|
+
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
import * as Messages from './Messages';
|
|
9
|
+
export declare function getMessageClassFromMessage(msg: Messages.ButtplugMessage): (new (...args: unknown[]) => Messages.ButtplugMessage) | null;
|
|
10
|
+
export declare function fromJSON(str: any): Messages.ButtplugMessage[];
|
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
-
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
-
* project root for full license information.
|
|
5
|
-
*
|
|
6
|
-
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
34
|
-
const class_transformer_1 = require("class-transformer");
|
|
35
|
-
const Messages = __importStar(require("./Messages"));
|
|
36
|
-
function getMessageClass(type) {
|
|
37
|
-
for (const value of Object.values(Messages)) {
|
|
38
|
-
if (typeof value === 'function' && 'Name' in value && value.Name === type) {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
+
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
+
* project root for full license information.
|
|
5
|
+
*
|
|
6
|
+
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.fromJSON = exports.getMessageClassFromMessage = void 0;
|
|
34
|
+
const class_transformer_1 = require("class-transformer");
|
|
35
|
+
const Messages = __importStar(require("./Messages"));
|
|
36
|
+
function getMessageClass(type) {
|
|
37
|
+
for (const value of Object.values(Messages)) {
|
|
38
|
+
if (typeof value === 'function' && 'Name' in value && value.Name === type) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function getMessageClassFromMessage(msg) {
|
|
45
|
+
// Making the bold assumption all message classes have the Name static. Should define a
|
|
46
|
+
// requirement for this in the abstract class.
|
|
47
|
+
return getMessageClass(Object.getPrototypeOf(msg).constructor.Name);
|
|
48
|
+
}
|
|
49
|
+
exports.getMessageClassFromMessage = getMessageClassFromMessage;
|
|
50
|
+
function fromJSON(str) {
|
|
51
|
+
const msgarray = JSON.parse(str);
|
|
52
|
+
const msgs = [];
|
|
53
|
+
for (const x of Array.from(msgarray)) {
|
|
54
|
+
const type = Object.getOwnPropertyNames(x)[0];
|
|
55
|
+
const cls = getMessageClass(type);
|
|
56
|
+
if (cls) {
|
|
57
|
+
const msg = (0, class_transformer_1.plainToInstance)(cls, x[type]);
|
|
58
|
+
msg.update();
|
|
59
|
+
msgs.push(msg);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return msgs;
|
|
63
|
+
}
|
|
64
|
+
exports.fromJSON = fromJSON;
|
|
59
65
|
//# sourceMappingURL=MessageUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtils.js","sourceRoot":"","sources":["../../../../src/core/MessageUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,yDAAoD;AACpD,qDAAuC;AAEvC,SAAS,eAAe,CACtB,IAAY;IAEZ,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;Q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