buttplug 3.0.0 → 3.1.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 +20 -20
- package/.github/workflows/docs.yaml +29 -0
- package/CHANGELOG.md +24 -0
- package/README.md +67 -1
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +0 -3
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +3 -10
- package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
- package/dist/main/src/client/ButtplugClientDevice.d.ts +1 -2
- package/dist/main/src/client/ButtplugClientDevice.js +2 -2
- package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -0
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +20 -0
- package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -0
- package/dist/main/src/client/Client.d.ts +1 -2
- package/dist/main/src/client/Client.js +2 -2
- package/dist/main/src/client/Client.js.map +1 -1
- package/dist/main/src/client/IButtplugClientConnector.d.ts +1 -2
- package/dist/main/src/core/Logging.d.ts +1 -2
- package/dist/main/src/core/Logging.js +2 -2
- package/dist/main/src/core/Logging.js.map +1 -1
- package/dist/main/src/core/MessageUtils.js +15 -8
- package/dist/main/src/core/MessageUtils.js.map +1 -1
- package/dist/main/src/core/Messages.d.ts +24 -9
- package/dist/main/src/core/Messages.js +26 -10
- package/dist/main/src/core/Messages.js.map +1 -1
- package/dist/main/src/index.d.ts +1 -0
- package/dist/main/src/index.js +1 -0
- package/dist/main/src/index.js.map +1 -1
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +2 -2
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +6 -9
- package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
- package/dist/web/buttplug.js +376 -480
- package/dist/web/buttplug.min.js +1 -1
- package/dist/web/buttplug.min.js.map +1 -1
- package/doc/.nojekyll +1 -0
- package/doc/assets/highlight.css +22 -0
- package/doc/assets/main.js +58 -0
- package/doc/assets/search.js +1 -0
- package/doc/assets/style.css +1280 -0
- package/doc/classes/ButtplugBrowserWebsocketClientConnector.html +234 -0
- package/doc/classes/ButtplugClient.html +331 -0
- package/doc/classes/ButtplugClientConnectorException.html +216 -0
- package/doc/classes/ButtplugClientDevice.html +489 -0
- package/doc/classes/ButtplugDeviceError.html +218 -0
- package/doc/classes/ButtplugDeviceMessage.html +165 -0
- package/doc/classes/ButtplugError.html +220 -0
- package/doc/classes/ButtplugInitError.html +218 -0
- package/doc/classes/ButtplugLogger.html +288 -0
- package/doc/classes/ButtplugMessage.html +147 -0
- package/doc/classes/ButtplugMessageError.html +218 -0
- package/doc/classes/ButtplugMessageSorter.html +128 -0
- package/doc/classes/ButtplugNodeWebsocketClientConnector.html +239 -0
- package/doc/classes/ButtplugPingError.html +218 -0
- package/doc/classes/ButtplugSystemMessage.html +150 -0
- package/doc/classes/ButtplugUnknownError.html +218 -0
- package/doc/classes/DeviceAdded.html +186 -0
- package/doc/classes/DeviceInfo.html +114 -0
- package/doc/classes/DeviceList.html +160 -0
- package/doc/classes/DeviceRemoved.html +158 -0
- package/doc/classes/Error.html +179 -0
- package/doc/classes/GenericDeviceMessageAttributes.html +107 -0
- package/doc/classes/GenericMessageSubcommand.html +90 -0
- package/doc/classes/LinearCmd.html +187 -0
- package/doc/classes/LogMessage.html +134 -0
- package/doc/classes/MessageAttributes.html +160 -0
- package/doc/classes/Ok.html +151 -0
- package/doc/classes/Ping.html +151 -0
- package/doc/classes/RawDeviceMessageAttributes.html +86 -0
- package/doc/classes/RawReadCmd.html +188 -0
- package/doc/classes/RawReading.html +179 -0
- package/doc/classes/RawSubscribeCmd.html +170 -0
- package/doc/classes/RawUnsubscribeCmd.html +170 -0
- package/doc/classes/RawWriteCmd.html +188 -0
- package/doc/classes/RequestDeviceList.html +151 -0
- package/doc/classes/RequestServerInfo.html +169 -0
- package/doc/classes/RotateCmd.html +187 -0
- package/doc/classes/RotateSubcommand.html +108 -0
- package/doc/classes/ScalarCmd.html +170 -0
- package/doc/classes/ScalarSubcommand.html +108 -0
- package/doc/classes/ScanningFinished.html +146 -0
- package/doc/classes/SensorDeviceMessageAttributes.html +107 -0
- package/doc/classes/SensorReadCmd.html +179 -0
- package/doc/classes/SensorReading.html +188 -0
- package/doc/classes/ServerInfo.html +178 -0
- package/doc/classes/StartScanning.html +151 -0
- package/doc/classes/StopAllDevices.html +151 -0
- package/doc/classes/StopDeviceCmd.html +161 -0
- package/doc/classes/StopScanning.html +151 -0
- package/doc/classes/VectorSubcommand.html +108 -0
- package/doc/enums/ActuatorType.html +104 -0
- package/doc/enums/ButtplugLogLevel.html +97 -0
- package/doc/enums/ErrorClass.html +90 -0
- package/doc/enums/SensorType.html +90 -0
- package/doc/functions/FromJSON.html +113 -0
- package/doc/index.html +184 -0
- package/doc/interfaces/IButtplugClientConnector.html +137 -0
- package/doc/modules.html +176 -0
- package/doc/variables/DEFAULT_MESSAGE_ID.html +104 -0
- package/doc/variables/MAX_ID.html +104 -0
- package/doc/variables/MESSAGE_SPEC_VERSION.html +104 -0
- package/doc/variables/SYSTEM_MESSAGE_ID.html +104 -0
- package/node-test.ts +5 -0
- package/package.json +23 -21
- package/src/client/ButtplugBrowserWebsocketClientConnector.ts +1 -14
- package/src/client/ButtplugClientDevice.ts +1 -1
- package/src/client/ButtplugNodeWebsocketClientConnector.ts +17 -0
- package/src/client/Client.ts +1 -1
- package/src/client/IButtplugClientConnector.ts +1 -1
- package/src/core/Logging.ts +1 -1
- package/src/core/MessageUtils.ts +21 -11
- package/src/core/Messages.ts +51 -10
- package/src/index.ts +1 -0
- package/src/utils/ButtplugBrowserWebsocketConnector.ts +4 -8
- package/typedocconfig.js +6 -0
- package/CODE_OF_CONDUCT.md +0 -166
- package/CONTRIBUTING.md +0 -169
- package/dist/web/index.html +0 -10
- package/typedoc.js +0 -9
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SYSTEM_MESSAGE_ID | buttplug</title><meta name="description" content="Documentation for buttplug"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base="..">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<div class="field">
|
|
6
|
+
<div id="tsd-toolbar-links"></div></div>
|
|
7
|
+
<ul class="results">
|
|
8
|
+
<li class="state loading">Preparing search index...</li>
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">buttplug</a></div>
|
|
10
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
|
+
<div class="container container-main">
|
|
12
|
+
<div class="col-8 col-content">
|
|
13
|
+
<div class="tsd-page-title">
|
|
14
|
+
<ul class="tsd-breadcrumb">
|
|
15
|
+
<li><a href="../modules.html">buttplug</a></li>
|
|
16
|
+
<li><a href="SYSTEM_MESSAGE_ID.html">SYSTEM_MESSAGE_ID</a></li></ul>
|
|
17
|
+
<h1>Variable SYSTEM_MESSAGE_ID<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
|
|
18
|
+
<div class="tsd-signature">SYSTEM_<wbr/>MESSAGE_<wbr/>ID<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">0</span><span class="tsd-signature-symbol"> = 0</span></div><aside class="tsd-sources">
|
|
19
|
+
<ul>
|
|
20
|
+
<li>Defined in <a href="https://github.com/buttplugio/buttplug-js/blob/d899bf9/src/core/Messages.ts#L15">src/core/Messages.ts:15</a></li></ul></aside></div>
|
|
21
|
+
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
22
|
+
<div class="tsd-navigation settings">
|
|
23
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
24
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
|
|
25
|
+
<div class="tsd-accordion-details">
|
|
26
|
+
<div class="tsd-filter-visibility">
|
|
27
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
28
|
+
<ul id="tsd-filter-options">
|
|
29
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
30
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div>
|
|
31
|
+
<div class="tsd-theme-toggle">
|
|
32
|
+
<h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
33
|
+
<nav class="tsd-navigation primary">
|
|
34
|
+
<details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
|
|
35
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
|
|
36
|
+
<div class="tsd-accordion-details">
|
|
37
|
+
<ul>
|
|
38
|
+
<li><a href="../modules.html">buttplug</a>
|
|
39
|
+
<ul></ul></li></ul></div></details></nav>
|
|
40
|
+
<nav class="tsd-navigation secondary menu-sticky">
|
|
41
|
+
<ul>
|
|
42
|
+
<li class="tsd-kind-enum"><a href="../enums/ActuatorType.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-8-path"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)" id="icon-8-text"></path></svg>Actuator<wbr/>Type</a></li>
|
|
43
|
+
<li class="tsd-kind-enum"><a href="../enums/ButtplugLogLevel.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg>Buttplug<wbr/>Log<wbr/>Level</a></li>
|
|
44
|
+
<li class="tsd-kind-enum"><a href="../enums/ErrorClass.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg>Error<wbr/>Class</a></li>
|
|
45
|
+
<li class="tsd-kind-enum"><a href="../enums/SensorType.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg>Sensor<wbr/>Type</a></li>
|
|
46
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugBrowserWebsocketClientConnector.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg>Buttplug<wbr/>Browser<wbr/>Websocket<wbr/>Client<wbr/>Connector</a></li>
|
|
47
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugClient.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Client</a></li>
|
|
48
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugClientConnectorException.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Client<wbr/>Connector<wbr/>Exception</a></li>
|
|
49
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugClientDevice.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Client<wbr/>Device</a></li>
|
|
50
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugDeviceError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Device<wbr/>Error</a></li>
|
|
51
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugDeviceMessage.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Device<wbr/>Message</a></li>
|
|
52
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Error</a></li>
|
|
53
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugInitError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Init<wbr/>Error</a></li>
|
|
54
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugLogger.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Logger</a></li>
|
|
55
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugMessage.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Message</a></li>
|
|
56
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugMessageError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Message<wbr/>Error</a></li>
|
|
57
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugMessageSorter.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Message<wbr/>Sorter</a></li>
|
|
58
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugNodeWebsocketClientConnector.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Node<wbr/>Websocket<wbr/>Client<wbr/>Connector</a></li>
|
|
59
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugPingError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Ping<wbr/>Error</a></li>
|
|
60
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugSystemMessage.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>System<wbr/>Message</a></li>
|
|
61
|
+
<li class="tsd-kind-class"><a href="../classes/ButtplugUnknownError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Buttplug<wbr/>Unknown<wbr/>Error</a></li>
|
|
62
|
+
<li class="tsd-kind-class"><a href="../classes/DeviceAdded.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Device<wbr/>Added</a></li>
|
|
63
|
+
<li class="tsd-kind-class"><a href="../classes/DeviceInfo.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Device<wbr/>Info</a></li>
|
|
64
|
+
<li class="tsd-kind-class"><a href="../classes/DeviceList.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Device<wbr/>List</a></li>
|
|
65
|
+
<li class="tsd-kind-class"><a href="../classes/DeviceRemoved.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Device<wbr/>Removed</a></li>
|
|
66
|
+
<li class="tsd-kind-class"><a href="../classes/Error.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Error</a></li>
|
|
67
|
+
<li class="tsd-kind-class"><a href="../classes/GenericDeviceMessageAttributes.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Generic<wbr/>Device<wbr/>Message<wbr/>Attributes</a></li>
|
|
68
|
+
<li class="tsd-kind-class"><a href="../classes/GenericMessageSubcommand.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Generic<wbr/>Message<wbr/>Subcommand</a></li>
|
|
69
|
+
<li class="tsd-kind-class"><a href="../classes/LinearCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Linear<wbr/>Cmd</a></li>
|
|
70
|
+
<li class="tsd-kind-class"><a href="../classes/LogMessage.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Log<wbr/>Message</a></li>
|
|
71
|
+
<li class="tsd-kind-class"><a href="../classes/MessageAttributes.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Message<wbr/>Attributes</a></li>
|
|
72
|
+
<li class="tsd-kind-class"><a href="../classes/Ok.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ok</a></li>
|
|
73
|
+
<li class="tsd-kind-class"><a href="../classes/Ping.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Ping</a></li>
|
|
74
|
+
<li class="tsd-kind-class"><a href="../classes/RawDeviceMessageAttributes.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Device<wbr/>Message<wbr/>Attributes</a></li>
|
|
75
|
+
<li class="tsd-kind-class"><a href="../classes/RawReadCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Read<wbr/>Cmd</a></li>
|
|
76
|
+
<li class="tsd-kind-class"><a href="../classes/RawReading.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Reading</a></li>
|
|
77
|
+
<li class="tsd-kind-class"><a href="../classes/RawSubscribeCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Subscribe<wbr/>Cmd</a></li>
|
|
78
|
+
<li class="tsd-kind-class"><a href="../classes/RawUnsubscribeCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Unsubscribe<wbr/>Cmd</a></li>
|
|
79
|
+
<li class="tsd-kind-class"><a href="../classes/RawWriteCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Raw<wbr/>Write<wbr/>Cmd</a></li>
|
|
80
|
+
<li class="tsd-kind-class"><a href="../classes/RequestDeviceList.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Request<wbr/>Device<wbr/>List</a></li>
|
|
81
|
+
<li class="tsd-kind-class"><a href="../classes/RequestServerInfo.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Request<wbr/>Server<wbr/>Info</a></li>
|
|
82
|
+
<li class="tsd-kind-class"><a href="../classes/RotateCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Rotate<wbr/>Cmd</a></li>
|
|
83
|
+
<li class="tsd-kind-class"><a href="../classes/RotateSubcommand.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Rotate<wbr/>Subcommand</a></li>
|
|
84
|
+
<li class="tsd-kind-class"><a href="../classes/ScalarCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Scalar<wbr/>Cmd</a></li>
|
|
85
|
+
<li class="tsd-kind-class"><a href="../classes/ScalarSubcommand.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Scalar<wbr/>Subcommand</a></li>
|
|
86
|
+
<li class="tsd-kind-class"><a href="../classes/ScanningFinished.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Scanning<wbr/>Finished</a></li>
|
|
87
|
+
<li class="tsd-kind-class"><a href="../classes/SensorDeviceMessageAttributes.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Sensor<wbr/>Device<wbr/>Message<wbr/>Attributes</a></li>
|
|
88
|
+
<li class="tsd-kind-class"><a href="../classes/SensorReadCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Sensor<wbr/>Read<wbr/>Cmd</a></li>
|
|
89
|
+
<li class="tsd-kind-class"><a href="../classes/SensorReading.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Sensor<wbr/>Reading</a></li>
|
|
90
|
+
<li class="tsd-kind-class"><a href="../classes/ServerInfo.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Server<wbr/>Info</a></li>
|
|
91
|
+
<li class="tsd-kind-class"><a href="../classes/StartScanning.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Start<wbr/>Scanning</a></li>
|
|
92
|
+
<li class="tsd-kind-class"><a href="../classes/StopAllDevices.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Stop<wbr/>All<wbr/>Devices</a></li>
|
|
93
|
+
<li class="tsd-kind-class"><a href="../classes/StopDeviceCmd.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Stop<wbr/>Device<wbr/>Cmd</a></li>
|
|
94
|
+
<li class="tsd-kind-class"><a href="../classes/StopScanning.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Stop<wbr/>Scanning</a></li>
|
|
95
|
+
<li class="tsd-kind-class"><a href="../classes/VectorSubcommand.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Vector<wbr/>Subcommand</a></li>
|
|
96
|
+
<li class="tsd-kind-interface"><a href="../interfaces/IButtplugClientConnector.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg>IButtplug<wbr/>Client<wbr/>Connector</a></li>
|
|
97
|
+
<li class="tsd-kind-variable"><a href="DEFAULT_MESSAGE_ID.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg>DEFAULT_<wbr/>MESSAGE_<wbr/>ID</a></li>
|
|
98
|
+
<li class="tsd-kind-variable"><a href="MAX_ID.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>MAX_<wbr/>ID</a></li>
|
|
99
|
+
<li class="tsd-kind-variable"><a href="MESSAGE_SPEC_VERSION.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>MESSAGE_<wbr/>SPEC_<wbr/>VERSION</a></li>
|
|
100
|
+
<li class="current tsd-kind-variable"><a href="SYSTEM_MESSAGE_ID.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>SYSTEM_<wbr/>MESSAGE_<wbr/>ID</a></li>
|
|
101
|
+
<li class="tsd-kind-function"><a href="../functions/FromJSON.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-64-path"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)" id="icon-64-text"></path></svg>FromJSON</a></li></ul></nav></div></div>
|
|
102
|
+
<div class="container tsd-generator">
|
|
103
|
+
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
|
|
104
|
+
<div class="overlay"></div><script src="../assets/main.js"></script></body></html>
|
package/node-test.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buttplug",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Buttplug Client Implementation for Typescript/Javascript",
|
|
5
5
|
"homepage": "https://github.com/buttplugio/buttplug-js/",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build": "trash dist dist-bundle && yarn build:all",
|
|
23
23
|
"build:all": "yarn build:main && yarn build:web && yarn build:web:release",
|
|
24
24
|
"build:main": "tsc -p tsconfig.json",
|
|
25
|
-
"build:doc": "typedoc --options
|
|
25
|
+
"build:doc": "typedoc --options typedocconfig.js --out doc ./src/index.ts",
|
|
26
26
|
"build:rollup": "rollup -c",
|
|
27
27
|
"tslint": "tslint --project tsconfig.json --outputAbsolutePaths -c ../../tslint.json \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
28
|
"tslint:fix": "tslint --project tsconfig.json --outputAbsolutePaths -c ../../tslint.json --fix semicolon,comma,no-var-keyword,ordered-imports \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
@@ -36,31 +36,33 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"class-transformer": "^0.5.1",
|
|
39
|
-
"
|
|
39
|
+
"eventemitter3": "^5.0.0",
|
|
40
|
+
"reflect-metadata": "^0.1.13",
|
|
41
|
+
"ws": "^8.12.0"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@types/commander": "^2.12.2",
|
|
43
45
|
"@types/expect-puppeteer": "^5.0.2",
|
|
44
|
-
"@types/jest": "^29.
|
|
46
|
+
"@types/jest": "^29.4.0",
|
|
45
47
|
"@types/jest-environment-puppeteer": "^5.0.3",
|
|
46
|
-
"@types/node": "^18.
|
|
48
|
+
"@types/node": "^18.13.0",
|
|
47
49
|
"@types/uuid-parse": "^1.0.0",
|
|
48
|
-
"@types/ws": "^8.5.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
50
|
-
"@typescript-eslint/parser": "^5.
|
|
50
|
+
"@types/ws": "^8.5.4",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
52
|
+
"@typescript-eslint/parser": "^5.51.0",
|
|
51
53
|
"copyfiles": "^2.4.1",
|
|
52
54
|
"cross-env": "^7.0.3",
|
|
53
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.34.0",
|
|
54
56
|
"eslint-plugin-node": "^11.1.0",
|
|
55
57
|
"eslint-plugin-prettier": "^4.2.1",
|
|
56
|
-
"fork-ts-checker-webpack-plugin": "^7.
|
|
58
|
+
"fork-ts-checker-webpack-plugin": "^7.3.0",
|
|
57
59
|
"gts": "^3.1.1",
|
|
58
|
-
"jest": "^29.
|
|
59
|
-
"jest-puppeteer": "^
|
|
60
|
-
"mock-socket": "^9.
|
|
60
|
+
"jest": "^29.4.2",
|
|
61
|
+
"jest-puppeteer": "^7.0.0",
|
|
62
|
+
"mock-socket": "^9.2.0",
|
|
61
63
|
"pkg": "^5.8.0",
|
|
62
|
-
"puppeteer": "^19.
|
|
63
|
-
"rollup": "^3.
|
|
64
|
+
"puppeteer": "^19.6.3",
|
|
65
|
+
"rollup": "^3.15.0",
|
|
64
66
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
65
67
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
66
68
|
"rollup-plugin-html": "^0.2.1",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
70
72
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
71
73
|
"rollup-plugin-postcss": "^4.0.2",
|
|
72
|
-
"rollup-plugin-postcss-modules": "^2.1.
|
|
74
|
+
"rollup-plugin-postcss-modules": "^2.1.1",
|
|
73
75
|
"rollup-plugin-terser": "^5.3.0",
|
|
74
76
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
75
77
|
"selfsigned": "^2.1.1",
|
|
@@ -77,15 +79,15 @@
|
|
|
77
79
|
"terser": "^4.x",
|
|
78
80
|
"terser-webpack-plugin": "^4.x",
|
|
79
81
|
"tmp": "^0.2.1",
|
|
80
|
-
"trash": "^8.1.
|
|
82
|
+
"trash": "^8.1.1",
|
|
81
83
|
"trash-cli": "^5.0.0",
|
|
82
|
-
"ts-jest": "^29.0.
|
|
84
|
+
"ts-jest": "^29.0.5",
|
|
83
85
|
"ts-loader": "^8.x",
|
|
84
86
|
"ts-node": "^10.9.1",
|
|
85
|
-
"tslib": "^2.
|
|
87
|
+
"tslib": "^2.5.0",
|
|
86
88
|
"tslint": "^6.1.0",
|
|
87
|
-
"typedoc": "^0.23.
|
|
88
|
-
"typescript": "^4.9.
|
|
89
|
+
"typedoc": "^0.23.25",
|
|
90
|
+
"typescript": "^4.9.5",
|
|
89
91
|
"url-loader": "^4.1.1",
|
|
90
92
|
"webpack": "^4.42.1",
|
|
91
93
|
"webpack-bundle-analyzer": "^3.6.1",
|
|
@@ -19,15 +19,6 @@ export class ButtplugBrowserWebsocketClientConnector
|
|
|
19
19
|
implements IButtplugClientConnector
|
|
20
20
|
{
|
|
21
21
|
private _sorter: ButtplugMessageSorter = new ButtplugMessageSorter(true);
|
|
22
|
-
protected _ws: WebSocket | undefined;
|
|
23
|
-
|
|
24
|
-
public constructor(_url: string) {
|
|
25
|
-
super(_url);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public get Connected(): boolean {
|
|
29
|
-
return this._ws !== undefined;
|
|
30
|
-
}
|
|
31
22
|
|
|
32
23
|
public Send = async (msg: ButtplugMessage): Promise<ButtplugMessage> => {
|
|
33
24
|
if (!this.Connected) {
|
|
@@ -44,11 +35,7 @@ export class ButtplugBrowserWebsocketClientConnector
|
|
|
44
35
|
const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
|
|
45
36
|
this.emit('message', emitMsgs);
|
|
46
37
|
} else if (event.data instanceof Blob) {
|
|
47
|
-
|
|
48
|
-
reader.addEventListener('load', (ev) => {
|
|
49
|
-
this.OnReaderLoad(ev);
|
|
50
|
-
});
|
|
51
|
-
reader.readAsText(event.data);
|
|
38
|
+
// No-op, buttplug only uses text formatting.
|
|
52
39
|
}
|
|
53
40
|
};
|
|
54
41
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ButtplugError,
|
|
14
14
|
ButtplugMessageError,
|
|
15
15
|
} from '../core/Exceptions';
|
|
16
|
-
import { EventEmitter } from '
|
|
16
|
+
import { EventEmitter } from 'eventemitter3';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Represents an abstract device, capable of taking certain kinds of messages.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Buttplug JS Source Code File - Visit https://buttplug.io for more info about
|
|
3
|
+
* the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
|
|
4
|
+
* project root for full license information.
|
|
5
|
+
*
|
|
6
|
+
* @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
import { ButtplugBrowserWebsocketClientConnector } from './ButtplugBrowserWebsocketClientConnector';
|
|
12
|
+
import { WebSocket as NodeWebSocket } from 'ws';
|
|
13
|
+
|
|
14
|
+
export class ButtplugNodeWebsocketClientConnector extends ButtplugBrowserWebsocketClientConnector {
|
|
15
|
+
protected _websocketConstructor =
|
|
16
|
+
NodeWebSocket as unknown as typeof WebSocket;
|
|
17
|
+
}
|
package/src/client/Client.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
11
|
import { ButtplugLogger } from '../core/Logging';
|
|
12
|
-
import { EventEmitter } from '
|
|
12
|
+
import { EventEmitter } from 'eventemitter3';
|
|
13
13
|
import { ButtplugClientDevice } from './ButtplugClientDevice';
|
|
14
14
|
import { IButtplugClientConnector } from './IButtplugClientConnector';
|
|
15
15
|
import * as Messages from '../core/Messages';
|
package/src/core/Logging.ts
CHANGED
package/src/core/MessageUtils.ts
CHANGED
|
@@ -10,21 +10,31 @@
|
|
|
10
10
|
import { plainToInstance } from 'class-transformer';
|
|
11
11
|
import * as Messages from './Messages';
|
|
12
12
|
|
|
13
|
+
function getMessageClass(
|
|
14
|
+
type: string
|
|
15
|
+
): (new (...args: unknown[]) => Messages.ButtplugMessage) | null {
|
|
16
|
+
for (const value of Object.values(Messages)) {
|
|
17
|
+
if (typeof value === 'function' && 'Name' in value && value.Name === type) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
export function FromJSON(str): Messages.ButtplugMessage[] {
|
|
14
25
|
const msgarray: object[] = JSON.parse(str);
|
|
15
26
|
const msgs: Messages.ButtplugMessage[] = [];
|
|
16
27
|
for (const x of Array.from(msgarray)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
msgs.push(msg as Messages.ButtplugMessage);
|
|
28
|
+
const type = Object.getOwnPropertyNames(x)[0];
|
|
29
|
+
const cls = getMessageClass(type);
|
|
30
|
+
if (cls) {
|
|
31
|
+
const msg = plainToInstance<Messages.ButtplugMessage, unknown>(
|
|
32
|
+
cls,
|
|
33
|
+
x[type]
|
|
34
|
+
);
|
|
35
|
+
msg.update();
|
|
36
|
+
msgs.push(msg);
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
39
|
return msgs;
|
|
30
40
|
}
|
package/src/core/Messages.ts
CHANGED
|
@@ -85,18 +85,10 @@ export class SensorDeviceMessageAttributes {
|
|
|
85
85
|
Object.assign(this, data);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
|
|
88
89
|
export abstract class ButtplugMessage {
|
|
89
90
|
constructor(public Id: number) {}
|
|
90
91
|
|
|
91
|
-
/***
|
|
92
|
-
* Returns the message type name
|
|
93
|
-
*
|
|
94
|
-
* Usually, the message type name will be the same as the message class
|
|
95
|
-
* constructor, so the constructor name is used by default. However, in
|
|
96
|
-
* instances where a message has different versions (i.e. DeviceAddedVersion0
|
|
97
|
-
* and DeviceAddedVersion1), we will need to override this to set the message
|
|
98
|
-
* name.
|
|
99
|
-
*/
|
|
100
92
|
// tslint:disable-next-line:ban-types
|
|
101
93
|
public get Type(): Function {
|
|
102
94
|
return this.constructor;
|
|
@@ -108,7 +100,8 @@ export abstract class ButtplugMessage {
|
|
|
108
100
|
|
|
109
101
|
public toProtocolFormat(): object {
|
|
110
102
|
const jsonObj = {};
|
|
111
|
-
jsonObj[this.constructor.
|
|
103
|
+
jsonObj[(this.constructor as unknown as { Name: string }).Name] =
|
|
104
|
+
instanceToPlain(this);
|
|
112
105
|
return jsonObj;
|
|
113
106
|
}
|
|
114
107
|
|
|
@@ -128,12 +121,16 @@ export abstract class ButtplugSystemMessage extends ButtplugMessage {
|
|
|
128
121
|
}
|
|
129
122
|
|
|
130
123
|
export class Ok extends ButtplugSystemMessage {
|
|
124
|
+
static Name = 'Ok';
|
|
125
|
+
|
|
131
126
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
132
127
|
super(Id);
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
export class Ping extends ButtplugMessage {
|
|
132
|
+
static Name = 'Ping';
|
|
133
|
+
|
|
137
134
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
138
135
|
super(Id);
|
|
139
136
|
}
|
|
@@ -148,6 +145,8 @@ export enum ErrorClass {
|
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
export class Error extends ButtplugMessage {
|
|
148
|
+
static Name = 'Error';
|
|
149
|
+
|
|
151
150
|
constructor(
|
|
152
151
|
public ErrorMessage: string,
|
|
153
152
|
public ErrorCode: ErrorClass = ErrorClass.ERROR_UNKNOWN,
|
|
@@ -175,6 +174,8 @@ export class DeviceInfo {
|
|
|
175
174
|
}
|
|
176
175
|
|
|
177
176
|
export class DeviceList extends ButtplugMessage {
|
|
177
|
+
static Name = 'DeviceList';
|
|
178
|
+
|
|
178
179
|
@Type(() => DeviceInfo)
|
|
179
180
|
public Devices: DeviceInfo[];
|
|
180
181
|
public Id: number;
|
|
@@ -193,6 +194,8 @@ export class DeviceList extends ButtplugMessage {
|
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
export class DeviceAdded extends ButtplugSystemMessage {
|
|
197
|
+
static Name = 'DeviceAdded';
|
|
198
|
+
|
|
196
199
|
public DeviceIndex: number;
|
|
197
200
|
public DeviceName: string;
|
|
198
201
|
@Type(() => MessageAttributes)
|
|
@@ -211,36 +214,48 @@ export class DeviceAdded extends ButtplugSystemMessage {
|
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
export class DeviceRemoved extends ButtplugSystemMessage {
|
|
217
|
+
static Name = 'DeviceRemoved';
|
|
218
|
+
|
|
214
219
|
constructor(public DeviceIndex: number) {
|
|
215
220
|
super();
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
export class RequestDeviceList extends ButtplugMessage {
|
|
225
|
+
static Name = 'RequestDeviceList';
|
|
226
|
+
|
|
220
227
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
221
228
|
super(Id);
|
|
222
229
|
}
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
export class StartScanning extends ButtplugMessage {
|
|
233
|
+
static Name = 'StartScanning';
|
|
234
|
+
|
|
226
235
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
227
236
|
super(Id);
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
export class StopScanning extends ButtplugMessage {
|
|
241
|
+
static Name = 'StopScanning';
|
|
242
|
+
|
|
232
243
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
233
244
|
super(Id);
|
|
234
245
|
}
|
|
235
246
|
}
|
|
236
247
|
|
|
237
248
|
export class ScanningFinished extends ButtplugSystemMessage {
|
|
249
|
+
static Name = 'ScanningFinished';
|
|
250
|
+
|
|
238
251
|
constructor() {
|
|
239
252
|
super();
|
|
240
253
|
}
|
|
241
254
|
}
|
|
242
255
|
|
|
243
256
|
export class RequestServerInfo extends ButtplugMessage {
|
|
257
|
+
static Name = 'RequestServerInfo';
|
|
258
|
+
|
|
244
259
|
constructor(
|
|
245
260
|
public ClientName: string,
|
|
246
261
|
public MessageVersion: number = 0,
|
|
@@ -251,6 +266,8 @@ export class RequestServerInfo extends ButtplugMessage {
|
|
|
251
266
|
}
|
|
252
267
|
|
|
253
268
|
export class ServerInfo extends ButtplugSystemMessage {
|
|
269
|
+
static Name = 'ServerInfo';
|
|
270
|
+
|
|
254
271
|
constructor(
|
|
255
272
|
public MessageVersion: number,
|
|
256
273
|
public MaxPingTime: number,
|
|
@@ -262,6 +279,8 @@ export class ServerInfo extends ButtplugSystemMessage {
|
|
|
262
279
|
}
|
|
263
280
|
|
|
264
281
|
export class StopDeviceCmd extends ButtplugDeviceMessage {
|
|
282
|
+
static Name = 'StopDeviceCmd';
|
|
283
|
+
|
|
265
284
|
constructor(
|
|
266
285
|
public DeviceIndex: number = -1,
|
|
267
286
|
public Id: number = DEFAULT_MESSAGE_ID
|
|
@@ -271,6 +290,8 @@ export class StopDeviceCmd extends ButtplugDeviceMessage {
|
|
|
271
290
|
}
|
|
272
291
|
|
|
273
292
|
export class StopAllDevices extends ButtplugMessage {
|
|
293
|
+
static Name = 'StopAllDevices';
|
|
294
|
+
|
|
274
295
|
constructor(public Id: number = DEFAULT_MESSAGE_ID) {
|
|
275
296
|
super(Id);
|
|
276
297
|
}
|
|
@@ -291,6 +312,8 @@ export class ScalarSubcommand extends GenericMessageSubcommand {
|
|
|
291
312
|
}
|
|
292
313
|
|
|
293
314
|
export class ScalarCmd extends ButtplugDeviceMessage {
|
|
315
|
+
static Name = 'ScalarCmd';
|
|
316
|
+
|
|
294
317
|
constructor(
|
|
295
318
|
public Scalars: ScalarSubcommand[],
|
|
296
319
|
public DeviceIndex: number = -1,
|
|
@@ -307,6 +330,8 @@ export class RotateSubcommand extends GenericMessageSubcommand {
|
|
|
307
330
|
}
|
|
308
331
|
|
|
309
332
|
export class RotateCmd extends ButtplugDeviceMessage {
|
|
333
|
+
static Name = 'RotateCmd';
|
|
334
|
+
|
|
310
335
|
public static Create(
|
|
311
336
|
deviceIndex: number,
|
|
312
337
|
commands: [number, boolean][]
|
|
@@ -337,6 +362,8 @@ export class VectorSubcommand extends GenericMessageSubcommand {
|
|
|
337
362
|
}
|
|
338
363
|
|
|
339
364
|
export class LinearCmd extends ButtplugDeviceMessage {
|
|
365
|
+
static Name = 'LinearCmd';
|
|
366
|
+
|
|
340
367
|
public static Create(
|
|
341
368
|
deviceIndex: number,
|
|
342
369
|
commands: [number, number][]
|
|
@@ -361,6 +388,8 @@ export class LinearCmd extends ButtplugDeviceMessage {
|
|
|
361
388
|
}
|
|
362
389
|
|
|
363
390
|
export class SensorReadCmd extends ButtplugDeviceMessage {
|
|
391
|
+
static Name = 'SensorReadCmd';
|
|
392
|
+
|
|
364
393
|
constructor(
|
|
365
394
|
public DeviceIndex: number,
|
|
366
395
|
public SensorIndex: number,
|
|
@@ -372,6 +401,8 @@ export class SensorReadCmd extends ButtplugDeviceMessage {
|
|
|
372
401
|
}
|
|
373
402
|
|
|
374
403
|
export class SensorReading extends ButtplugDeviceMessage {
|
|
404
|
+
static Name = 'SensorReading';
|
|
405
|
+
|
|
375
406
|
constructor(
|
|
376
407
|
public DeviceIndex: number,
|
|
377
408
|
public SensorIndex: number,
|
|
@@ -384,6 +415,8 @@ export class SensorReading extends ButtplugDeviceMessage {
|
|
|
384
415
|
}
|
|
385
416
|
|
|
386
417
|
export class RawReadCmd extends ButtplugDeviceMessage {
|
|
418
|
+
static Name = 'RawReadCmd';
|
|
419
|
+
|
|
387
420
|
constructor(
|
|
388
421
|
public DeviceIndex: number,
|
|
389
422
|
public Endpoint: string,
|
|
@@ -396,6 +429,8 @@ export class RawReadCmd extends ButtplugDeviceMessage {
|
|
|
396
429
|
}
|
|
397
430
|
|
|
398
431
|
export class RawWriteCmd extends ButtplugDeviceMessage {
|
|
432
|
+
static Name = 'RawWriteCmd';
|
|
433
|
+
|
|
399
434
|
constructor(
|
|
400
435
|
public DeviceIndex: number,
|
|
401
436
|
public Endpoint: string,
|
|
@@ -408,6 +443,8 @@ export class RawWriteCmd extends ButtplugDeviceMessage {
|
|
|
408
443
|
}
|
|
409
444
|
|
|
410
445
|
export class RawSubscribeCmd extends ButtplugDeviceMessage {
|
|
446
|
+
static Name = 'RawSubscribeCmd';
|
|
447
|
+
|
|
411
448
|
constructor(
|
|
412
449
|
public DeviceIndex: number,
|
|
413
450
|
public Endpoint: string,
|
|
@@ -418,6 +455,8 @@ export class RawSubscribeCmd extends ButtplugDeviceMessage {
|
|
|
418
455
|
}
|
|
419
456
|
|
|
420
457
|
export class RawUnsubscribeCmd extends ButtplugDeviceMessage {
|
|
458
|
+
static Name = 'RawUnsubscribeCmd';
|
|
459
|
+
|
|
421
460
|
constructor(
|
|
422
461
|
public DeviceIndex: number,
|
|
423
462
|
public Endpoint: string,
|
|
@@ -428,6 +467,8 @@ export class RawUnsubscribeCmd extends ButtplugDeviceMessage {
|
|
|
428
467
|
}
|
|
429
468
|
|
|
430
469
|
export class RawReading extends ButtplugDeviceMessage {
|
|
470
|
+
static Name = 'RawReading';
|
|
471
|
+
|
|
431
472
|
constructor(
|
|
432
473
|
public DeviceIndex: number,
|
|
433
474
|
public Endpoint: string,
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export * from './client/Client';
|
|
10
10
|
export * from './client/ButtplugClientDevice';
|
|
11
11
|
export * from './client/ButtplugBrowserWebsocketClientConnector';
|
|
12
|
+
export * from './client/ButtplugNodeWebsocketClientConnector';
|
|
12
13
|
export * from './client/ButtplugClientConnectorException';
|
|
13
14
|
export * from './utils/ButtplugMessageSorter';
|
|
14
15
|
export * from './client/IButtplugClientConnector';
|