buttplug 1.0.17 → 3.0.0-alpha.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.
Files changed (119) hide show
  1. package/.eslintrc +13 -0
  2. package/.github/FUNDING.yml +5 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +17 -0
  4. package/.jscsrc +3 -0
  5. package/.jshintrc +6 -0
  6. package/.yarnrc.yml +1 -0
  7. package/CHANGELOG.md +377 -24
  8. package/CODE_OF_CONDUCT.md +166 -0
  9. package/CONTRIBUTING.md +169 -0
  10. package/LICENSE +27 -0
  11. package/README.md +23 -126
  12. package/azure-pipelines.yml +19 -0
  13. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +19 -0
  14. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +58 -0
  15. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -0
  16. package/dist/main/src/client/ButtplugClientConnectorException.d.ts +11 -0
  17. package/dist/main/src/client/ButtplugClientConnectorException.js +42 -0
  18. package/dist/main/src/client/ButtplugClientConnectorException.js.map +1 -0
  19. package/dist/main/src/client/ButtplugClientDevice.d.ts +62 -0
  20. package/dist/main/src/client/ButtplugClientDevice.js +299 -0
  21. package/dist/main/src/client/ButtplugClientDevice.js.map +1 -0
  22. package/dist/main/src/client/Client.d.ts +42 -0
  23. package/dist/main/src/client/Client.js +237 -0
  24. package/dist/main/src/client/Client.js.map +1 -0
  25. package/dist/main/src/client/IButtplugClientConnector.d.ts +17 -0
  26. package/dist/main/src/client/IButtplugClientConnector.js +10 -0
  27. package/dist/main/src/client/IButtplugClientConnector.js.map +1 -0
  28. package/dist/main/src/core/Exceptions.d.ts +36 -0
  29. package/dist/main/src/core/Exceptions.js +107 -0
  30. package/dist/main/src/core/Exceptions.js.map +1 -0
  31. package/dist/main/src/core/Logging.d.ts +113 -0
  32. package/dist/main/src/core/Logging.js +170 -0
  33. package/dist/main/src/core/Logging.js.map +1 -0
  34. package/dist/main/src/core/MessageUtils.d.ts +9 -0
  35. package/dist/main/src/core/MessageUtils.js +52 -0
  36. package/dist/main/src/core/MessageUtils.js.map +1 -0
  37. package/dist/main/src/core/Messages.d.ts +260 -0
  38. package/dist/main/src/core/Messages.js +412 -0
  39. package/dist/main/src/core/Messages.js.map +1 -0
  40. package/dist/main/src/index.d.ts +17 -0
  41. package/dist/main/src/index.js +34 -0
  42. package/dist/main/src/index.js.map +1 -0
  43. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -0
  44. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +92 -0
  45. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -0
  46. package/dist/main/src/utils/ButtplugMessageSorter.d.ts +16 -0
  47. package/dist/main/src/utils/ButtplugMessageSorter.js +79 -0
  48. package/dist/main/src/utils/ButtplugMessageSorter.js.map +1 -0
  49. package/dist/main/src/utils/Utils.d.ts +1 -0
  50. package/dist/main/src/utils/Utils.js +8 -0
  51. package/dist/main/src/utils/Utils.js.map +1 -0
  52. package/dist/web/buttplug.js +6087 -16541
  53. package/dist/web/buttplug.min.js +2 -45
  54. package/dist/web/buttplug.min.js.LICENSE.txt +31 -0
  55. package/dist/web/buttplug.min.js.map +1 -1
  56. package/dist/web/index.html +10 -0
  57. package/jest-puppeteer.config.js +5 -0
  58. package/package.json +93 -44
  59. package/rollup.config.js +55 -0
  60. package/src/client/ButtplugBrowserWebsocketClientConnector.ts +56 -0
  61. package/src/client/ButtplugClientConnectorException.ts +16 -0
  62. package/src/client/ButtplugClientDevice.ts +255 -0
  63. package/src/client/Client.ts +233 -0
  64. package/src/client/IButtplugClientConnector.ts +18 -0
  65. package/src/core/Exceptions.ts +98 -0
  66. package/src/core/Logging.ts +194 -0
  67. package/src/core/MessageUtils.ts +26 -0
  68. package/src/core/Messages.ts +421 -0
  69. package/src/core/index.d.ts +4 -0
  70. package/src/index.ts +18 -0
  71. package/src/utils/ButtplugBrowserWebsocketConnector.ts +90 -0
  72. package/src/utils/ButtplugMessageSorter.ts +54 -0
  73. package/src/utils/Utils.ts +3 -0
  74. package/tsconfig.json +6 -5
  75. package/tslint.json +27 -0
  76. package/typedoc.js +9 -0
  77. package/util/convert_device_config.js +6 -0
  78. package/.netlify/state.json +0 -3
  79. package/LICENSE.md +0 -29
  80. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi.d.ts +0 -41
  81. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi.js +0 -2
  82. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi_bg.js +0 -6
  83. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi_bg.wasm +0 -0
  84. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi_bg.wasm.d.ts +0 -18
  85. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi_bg_node.js +0 -799
  86. package/dist/module/buttplug-rs-ffi/buttplug_rs_ffi_bg_web.js +0 -788
  87. package/dist/module/buttplug_ffi.d.ts +0 -3898
  88. package/dist/module/buttplug_ffi.js +0 -10541
  89. package/dist/module/client.d.ts +0 -30
  90. package/dist/module/client.js +0 -126
  91. package/dist/module/client.js.map +0 -1
  92. package/dist/module/connectors.d.ts +0 -13
  93. package/dist/module/connectors.js +0 -26
  94. package/dist/module/connectors.js.map +0 -1
  95. package/dist/module/device.d.ts +0 -85
  96. package/dist/module/device.js +0 -217
  97. package/dist/module/device.js.map +0 -1
  98. package/dist/module/errors.d.ts +0 -25
  99. package/dist/module/errors.js +0 -60
  100. package/dist/module/errors.js.map +0 -1
  101. package/dist/module/ffi.d.ts +0 -25
  102. package/dist/module/ffi.js +0 -243
  103. package/dist/module/ffi.js.map +0 -1
  104. package/dist/module/index.d.ts +0 -15
  105. package/dist/module/index.js +0 -16
  106. package/dist/module/index.js.map +0 -1
  107. package/dist/module/sorter.d.ts +0 -15
  108. package/dist/module/sorter.js +0 -43
  109. package/dist/module/sorter.js.map +0 -1
  110. package/dist/module/web_index.d.ts +0 -8
  111. package/dist/module/web_index.js +0 -12
  112. package/dist/module/web_index.js.map +0 -1
  113. package/dist/web/0.buttplug.js +0 -1389
  114. package/dist/web/1.buttplug.min.js +0 -2
  115. package/dist/web/1.buttplug.min.js.map +0 -1
  116. package/dist/web/b0219b34bc18e1ad0240.module.wasm +0 -0
  117. package/dist/web/e5566a8b6a3fda978549.module.wasm +0 -0
  118. package/index.html +0 -25
  119. package/webpack.base.cjs +0 -107
@@ -0,0 +1,166 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our
7
+ project and our community a harassment-free experience for everyone,
8
+ regardless of age (see addendum), body size, disability, ethnicity,
9
+ gender identity and expression, level of experience, nationality,
10
+ personal appearance, race, religion, or sexual identity and
11
+ orientation.
12
+
13
+ ## Our Standards
14
+
15
+ Examples of behavior that contributes to creating a positive
16
+ environment include:
17
+
18
+ * Using welcoming and inclusive language
19
+ * Being respectful of differing viewpoints and experiences
20
+ * Gracefully accepting constructive criticism
21
+ * Focusing on what is best for the community
22
+ * Showing empathy towards other community members
23
+
24
+ Examples of unacceptable behavior by participants include:
25
+
26
+ * The use of unnecessary sexualized language or imagery and unwelcome
27
+ sexual attention or advances
28
+ * Trolling, insulting/derogatory comments, and personal or political
29
+ attacks
30
+ * Public or private harassment
31
+ * Publishing others' private information, such as a physical or
32
+ electronic address, without explicit permission
33
+ * Other conduct which could reasonably be considered inappropriate in
34
+ a professional setting
35
+
36
+ ## Our Responsibilities
37
+
38
+ Project maintainers are responsible for clarifying the standards of
39
+ acceptable behavior and are expected to take appropriate and fair
40
+ corrective action in response to any instances of unacceptable
41
+ behavior.
42
+
43
+ Project maintainers have the right and responsibility to remove, edit,
44
+ or reject comments, commits, code, wiki edits, issues, and other
45
+ contributions that are not aligned to this Code of Conduct, or to ban
46
+ temporarily or permanently any contributor for other behaviors that
47
+ they deem inappropriate, threatening, offensive, or harmful.
48
+
49
+ ## Scope
50
+
51
+ This Code of Conduct applies both within project spaces and in public
52
+ spaces when an individual is representing the project or its
53
+ community. Examples of representing a project or community include
54
+ using an official project e-mail address, posting via an official
55
+ social media account, or acting as an appointed representative at an
56
+ online or offline event. Representation of a project may be further
57
+ defined and clarified by project maintainers.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior
62
+ May be reported by contacting the project team at
63
+ admin@metafetish.com. All complaints will be reviewed and investigated
64
+ and will result in a response that is deemed necessary and appropriate
65
+ to the circumstances. The project team is obligated to maintain
66
+ confidentiality with regard to the reporter of an incident. Further
67
+ details of specific enforcement policies may be posted separately.
68
+
69
+ Project maintainers who do not follow or enforce the Code of Conduct
70
+ in good faith may face temporary or permanent repercussions as
71
+ determined by other members of the project's leadership.
72
+
73
+ ## Addendum for Metafetish Related Projects
74
+
75
+ While the project team seeks to welcome all contributors and
76
+ participants, due to the sexual nature of projects related to the
77
+ Metafetish organization, all contributors and participants should be
78
+ of provable legal age.
79
+
80
+ Working on projects related to the Metafetish organization may at
81
+ times require sexual situations to be discussed in project forums, be
82
+ they message boards, social media, chat systems, or other means not
83
+ listed here. These discussions should pertain only to usage of the
84
+ projects they involve, and should only include required details to
85
+ express some sort of issue or feature request. If the discussion
86
+ includes material that others may find objectionable for some reason,
87
+ the discussions should be prepended with content warnings.
88
+
89
+ While usage stories about projects are appreciated, unless they
90
+ express some issue with specific usage, we ask that they be kept to
91
+ outside forums, where they would be appropriate. There are many
92
+ sub-reddits, fetlife groups, and forum instances available for a
93
+ multitude of interests where usage can be discussed. If a proper venue
94
+ is not known, please contact project maintainers, as they may be able
95
+ to point to one.
96
+
97
+ If any contributor or project member feels that these considerations
98
+ have not been met, they should contact the project maintainers at
99
+ admin@metafetish.com.
100
+
101
+ # Moderation
102
+
103
+ These are the policies for upholding our community's standards of
104
+ conduct. If you feel that a thread needs moderation, please contact
105
+ the [Metafetish moderation team](mailto:admin@metafetish.com).
106
+
107
+ 1. Remarks that violate the standard of conduct, including hateful,
108
+ hurtful, oppressive, or exclusionary remarks, are not allowed.
109
+ (Cursing is allowed, but never targeting another user, and never in
110
+ a hateful manner.)
111
+ 2. Remarks that moderators find inappropriate, whether listed in the
112
+ code of conduct or not, are also not allowed.
113
+ 3. Moderators will first respond to such remarks with a warning.
114
+ 4. If the warning is unheeded, the user will be "kicked," i.e., kicked
115
+ out of the communication channel to cool off.
116
+ 5. If the user comes back and continues to make trouble, they will be
117
+ banned, i.e., indefinitely excluded.
118
+ 6. Moderators may choose at their discretion to un-ban the user if it
119
+ was a first offense and they offer the offended party a genuine
120
+ apology.
121
+ 7. If a moderator bans someone and you think it was unjustified,
122
+ please take it up with that moderator, or with a different
123
+ moderator, **in private**. Complaints about bans in-channel are not
124
+ allowed.
125
+ 8. Moderators are held to a higher standard than other community
126
+ members. If a moderator creates an inappropriate situation, they
127
+ should expect less leeway than others.
128
+
129
+ In this community we strive to go the extra step to look out for each
130
+ other. Don't just aim to be technically unimpeachable, try to be your
131
+ best self. In particular, avoid flirting with offensive or sensitive
132
+ issues, particularly if they're off-topic; this all too often leads to
133
+ unnecessary fights, hurt feelings, and damaged trust; worse, it can
134
+ drive people away from the community entirely.
135
+
136
+ And if someone takes issue with something you said or did, resist the
137
+ urge to be defensive. Just stop doing what it was they complained
138
+ about and apologize. Even if you feel you were misinterpreted or
139
+ unfairly accused, chances are good there was something you could've
140
+ communicated better — remember that it's your responsibility to make
141
+ your fellow community members comfortable. Everyone wants to get along
142
+ and we are all here first and foremost because we want to talk about
143
+ cool technology. You will find that people will be eager to assume
144
+ good intent and forgive as long as you earn their trust.
145
+
146
+ The enforcement policies listed above apply to all official Metafetish
147
+ venues; including all Slack channels and their related bridged IRC
148
+ channels, repositories and their respective issue trackers/wikis/etc,
149
+ message boards, and social media networks. For other projects adopting
150
+ this Code of Conduct, please contact the maintainers of those projects
151
+ for enforcement. If you wish to use this code of conduct for your own
152
+ project, consider explicitly mentioning your moderation policy or
153
+ making a copy with your own moderation policy so as to avoid
154
+ confusion.
155
+
156
+ # Attribution
157
+
158
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
159
+ available at [http://contributor-covenant.org/version/1/4][version]
160
+
161
+ [homepage]: http://contributor-covenant.org
162
+ [version]: http://contributor-covenant.org/version/1/4/
163
+
164
+ The Moderation portion of this Code of Conduct is adapted from
165
+ the
166
+ [Rust Language Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
@@ -0,0 +1,169 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in contributing to the Metafetish
4
+ Organization repo! We're looking forward to working with you to make
5
+ this project better.
6
+
7
+ ## Code Of Conduct
8
+
9
+ First off, you'll want to check out our [Code of Conduct](CODE_OF_CONDUCT.md), which
10
+ should be alongside this document. It outlines the rules and
11
+ expectations for interaction with our project.
12
+
13
+ ## For All Community
14
+
15
+ This section contains information for everyone involved with the
16
+ projects, whether developing or simply interested in using and
17
+ recommending improvements.
18
+
19
+ ### Communication
20
+
21
+ There are a couple of different ways in which you can interact with
22
+ other members of Metafetish projects.
23
+
24
+ - [We have a Slack instance](https://metafetish.slack.com). Note that an invitation is required
25
+ to join the slack instance. Please email admin@metafetish.com for an
26
+ invite, and include the email address you'd like to use to log in.
27
+ - [We have message boards](http://metafetish.club). We have Discourse forums available that
28
+ cover most of our projects. For anything that doesn't fit into one
29
+ of the categories, there's the General forum.
30
+
31
+ ### Anonymous Accounts
32
+
33
+ Due to the sensitive nature of Metafetish projects, some community
34
+ members prefer to use anonymous accounts, on message boards as well as
35
+ for contributing to code repos. We understand the need for this, and
36
+ try to be as accepting of that as possible without letting it
37
+ interfere with project progress.
38
+
39
+ Note that vetting by project leads will still need to occur before
40
+ administration rights after given to any account on a project resource
41
+ (forums, repos, etc), anonymous or otherwise.
42
+
43
+ ### Filing feature requests
44
+
45
+ If there are features you'd like in a project, you may request them by:
46
+
47
+ - If you have a github account, filing a github issue on the project.
48
+ - Otherwise, make a post on the message board in the appropriate
49
+ category, or on the General category if a proper category does not
50
+ exist.
51
+
52
+ Please be specific in your feature request. We will ask followup
53
+ questions for clarification, but the more information we have, the
54
+ better.
55
+
56
+ ### Filing bug reports
57
+
58
+ If you find a problem in a project, please do not hesitate to tell us.
59
+
60
+ - If you find a security bug, please email [admin@metafetish.com](mailto:admin@metafetish.com)
61
+ immediately, and we will work with you to resolve it and get the
62
+ information out to the community ASAP.
63
+ - For all other bugs:
64
+ - If you have a github account, filing a github issue on the project.
65
+ - Otherwise, make a post on the message board in the appropriate
66
+ category, or on the General category if a proper category does not
67
+ exist.
68
+
69
+ In the issue or post, you should let us know:
70
+
71
+ - The software you are using that has the bug
72
+ - The version of the software
73
+ - The operating system version of the computer you using the software
74
+ on.
75
+ - The steps you took to get to the problem.
76
+ - Whether the problem is repeatable.
77
+
78
+ Someone should hopefully follow up on your problem soon.
79
+
80
+ ## For Developer Community
81
+
82
+ This section contains information mainly related to helping in
83
+ development of Metafetish projects.
84
+
85
+ ### Getting up and running on a project
86
+
87
+ In many cases, if you are trying to start developing a new project,
88
+ information about compiling and using the project will be in the
89
+ README. If these instructions are missing or incomplete, you can ask
90
+ in the [proper category on the message boards]( http://metafetish.club), or file an issue on
91
+ the project if you have a github account. You can also contact us on
92
+ Slack if you have an account there.
93
+
94
+ Note that some of our projects are rather complicated, and span
95
+ multiple repositories and/or technologies. We do our best to keep
96
+ things up to date, but there may be times where we've missed updating
97
+ documentation. If something seems wrong, or isn't working for you, ask
98
+ us using one of the above methods.
99
+
100
+ ### Continuous Integration
101
+
102
+ In as many cases as possible, we have added continuous integration
103
+ services to run build checks on our software projects. These will
104
+ normally be [Travis](http://travis-ci.org) for macOS and linux builds (or platform
105
+ independent builds, like Node with no native requirements),
106
+ and [Appveyor](http://appveyor.com) for Windows builds. CI Badges are usually added to
107
+ the README.
108
+
109
+ ### Git/Github Workflow
110
+
111
+ This section goes over our git workflow. We realize that git can be
112
+ quite complicated and has a steep learning curve. We have done as much
113
+ as we can to make sure Github makes this easy for contributors. If you
114
+ are new to git, or if you do not understand some part of this section,
115
+ please let us know when you make a pull request, and we'll help out.
116
+ If you are not sure how to make a pull request on github,
117
+ contact [admin@metafetish.com](mailto:admin@metafetish.com) and a project lead will help.
118
+
119
+ As of this writing, Metafetish projects are maintained on
120
+ the [Metafetish Organization on Github](http://github.com/metafetish). 'master' branches on
121
+ Metafetish projects are kept as [Github protected branches](https://help.github.com/articles/about-protected-branches/), with
122
+ the following settings.
123
+
124
+ - All of the following rules apply to both users and administrators.
125
+ - No direct pushes to 'master'. All changes must be via Pull Request
126
+ (PR).
127
+ - No force pushes to 'master'. All rewrites must be done on feature
128
+ branches.
129
+ - PRs must be off the end of the 'master' branch to merge to master.
130
+ Github will enforce this in PRs.
131
+ - PRs must pass CI to merge. Due to the hardware focus of many
132
+ Metafetish projects, tests may be difficult to write in languages
133
+ without proper mocking utilities. Therefore, Code Coverage increase
134
+ is nice, but not required.
135
+ - PRs should have a reviewer if possible, but this is not enforced.
136
+
137
+ Metafetish organization projects maintain a 'rebase-only' workflow to
138
+ master when possible, where all branches will be a fast-forward merge.
139
+ Github PRs should manage this themselves, and will display an error if
140
+ this is not possible. Project management will be happy to work with
141
+ you to resolve the issue.
142
+
143
+ In order to reduce workload of contributors, repo dependencies should
144
+ be brought in by using the [git subtree method](https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/) instead of git
145
+ submodules. As this will require upkeep and documentation, please
146
+ discuss possible repo inclusion with project leads before submitting
147
+ pull requests with subtree merges.
148
+
149
+ ### Project Management
150
+
151
+ For project management, we usually use either [Trello](http://trello.com)
152
+ or [ZenHub](http://zenhub.io), depending on the level of integration needed with the
153
+ source code repo itself. More information about this is usually
154
+ included in the README for the specific project.
155
+
156
+ ### Documentation
157
+
158
+ Non-code documentation for projects is usually done in one of two
159
+ formats:
160
+
161
+ - Markdown, for all README and contributor facing files.
162
+ - org-mode, for large documentation sets and manuals.
163
+
164
+ As there is currently only one project lead using org-mode (but they
165
+ write most of the documentation), conversation from org-mode to
166
+ markdown can happen on request. Similarly, markdown versions of
167
+ org-mode documents may be checked in to documentation repos as needed.
168
+
169
+ Large manuals are usually managed using the [gitbook](https://github.com/GitbookIO/gitbook) format.
package/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2017-2018, Nonpolynomial Labs LLC
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of buttplug-js nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,136 +1,33 @@
1
- # Buttplug Rust FFI - WASM/Typescript/Javascript
2
-
3
- [![NPM](https://img.shields.io/npm/v/buttplug.svg)](https://www.npmjs.com/package/buttplug)
1
+ # Buttplug Typescript/JS Client Implementation
4
2
 
5
3
  [![Patreon donate button](https://img.shields.io/badge/patreon-donate-yellow.svg)](https://www.patreon.com/qdot)
6
- [![Discourse Forum](https://img.shields.io/badge/discourse-forum-blue.svg)](https://metafetish.club)
4
+ [![Github donate button](https://img.shields.io/badge/github-donate-ff69b4.svg)](https://www.github.com/sponsors/qdot)
5
+
6
+ [![Discourse Forum](https://img.shields.io/badge/discourse-forum-blue.svg)](https://discuss.buttplug.io)
7
7
  [![Discord](https://img.shields.io/discord/353303527587708932.svg?logo=discord)](https://discord.buttplug.io)
8
8
  [![Twitter](https://img.shields.io/twitter/follow/buttplugio.svg?style=social&logo=twitter)](https://twitter.com/buttplugio)
9
9
 
10
- Buttplug is a framework for hooking up hardware to interfaces, where hardware usually means sex
11
- toys, but could honestly be just about anything. Think of it as a userland HID manager for things
12
- that may not specifically be HID, but may go in your butt.
13
-
14
- Or other places too! We're not completely butt-centric, despite the project name. And logo.
15
-
16
- ## Support The Project
17
-
18
- If you find this project helpful, you can [support us via Patreon](http://patreon.com/qdot) or
19
- [Github Sponsors](https://github.com/sponsors/qdot)! Every donation helps us afford more research materials (sex toys).
20
-
21
- ## Documentation
22
-
23
- The [Buttplug Developer Guide](https://buttplug-developer-guide.docs.buttplug.io) is your best
24
- source of information for developing with Buttplug. It contains many Javascript examples using this
25
- library.
26
-
27
- API documentation coming soon.
28
-
29
- ## Supported Hardware
30
-
31
- See [IOSTIndex.com](https://iostindex.com/?filtersChanged=1&filter0ButtplugSupport=4) (link is filtered for hardware supported by this library) for a list of supported hardware.
32
-
33
- ## Installation
34
-
35
- For node/webpack applications, Buttplug JS can be installed via npm, using the ["Buttplug" package](https://www.npmjs.com/package/buttplug)
36
-
37
- For using Buttplug directly on the web, it can be included from a CDN. See the "Using Buttplug On the Web" section below.
38
-
39
- Any package with the word "Buttplug" in it that is < v1 can be ignored, the older JS packages were broken into multiple modules to support native node. At the moment, Buttplug is a single package that comes with all parts required for the web, and the node packages are deprecated.
40
-
41
- ## For Those Upgrading from Buttplug JS v0.x
42
-
43
- There are many breaking changes between Buttplug JS v0.x and Buttplug JS >= v1.x. It is recommended you check the examples in the [Developer Guide](https://buttplug-developer-guide.docs.buttplug.io) for updates between v0.x and v1.x+. Most of the logic should be the same, but there are some subtle differences in the API surface.
44
-
45
- If you have questions, you can [ask on the discord](https://discord.buttplug.io) or [file an issue](https://github.com/buttplugio/buttplug-rs-ffi/issues).
46
-
47
- ## A Note on Architecture
48
-
49
- Buttplug JS is only about 10% JS. There's enough JS (ok actually it's typescript) to get us to Rust, but most of Buttplug's logic, including toy control, hardware access, network communications, etc, are in Rust, via [buttplug-rs](https://github.com/buttplugio/buttplug-rs) that is compiled to WASM. This means that if something fails in Rust/WASM, it may look somewhat opaque in JS. If you find yourself running into these cases, please [file an issue on this repo](https://github.com/buttplugio/buttplug-rs-ffi) and we'll try to get things cleared up. The goal for the future is to return rust panic stacks across the WASM boundary for better logging, but this is still something we're working on.
50
-
51
- If you are curious about how the FFI fits together, [see the root README for the project](https://github.com/buttplugio/buttplug-rs-ffi).
52
-
53
- ## Platform Support and Runtimes
54
-
55
- Currently, Buttplug JS only supports usage on the web, either via packed web applications, or directly in webpages. Native Node access will be happening at some point in the future. For more info on native node access, [watch this issue in our repo](https://github.com/buttplugio/buttplug-rs-ffi/issues/11).
56
-
57
- ## Using Buttplug With Webpack
58
-
59
- Packing Buttplug in Webpack may require some extra work, as Buttplug JS involves WASM, which means asynchronous loading and asset finding.
60
-
61
- The first issue you may run into is with asset loading, as webpack can only be so smart about where the WASM blob is. If you don't set the `output.publicPath` webpack configuration, you'll possibly have issues with the WASM loader not being able to find the blob (resulting in 404 errors in your web console and your app not loading). You've got 2 choices here:
62
-
63
- * If you know where your application will reside on your server and that location will never change, set `output.publicPath` in your webpack configuration to match where your generated webpack files will be. For instance, if you have webpack building chunks to `dist`, your `output.publicPath` would be `/dist/`.
64
- * To handle your application being at *any* path, add the following code block and make sure it is run _before_ running `buttplugInit()`. This is a hack that finds the URL the current JS file is being loaded from, and uses that to load the WASM blob.
65
-
66
- ```javascript
67
- // If using typescript, uncomment this declare line
68
- declare var __webpack_public_path__: any;
69
-
70
- var scripts = document.getElementsByTagName( "script" );
71
- var lastScript = scripts[scripts.length - 1].src;
72
- __webpack_public_path__ = lastScript.substr(0, lastScript.lastIndexOf('/') + 1);
73
- ```
74
-
75
- After setting up your loading, you'll need to call buttplugInit() and make sure it succeeds before calling into Buttplug:
76
-
77
- ```javascript
78
- // This could also be awaited, just depends on your calling context.
79
- buttplugInit().then(() => console.log("Ready to set up buttplug calls!"));
80
- ```
81
-
82
- This will asynchronously load the library, in a way that webpack shouldn't complain about.
83
-
84
- Note that this has only been tested in Webpack 4. Webpack 5 has a mechanism for automating asynchronous loading, but this has not been experimented with in buttplug-js yet. If you try this and have suggestions, [please file an issue and let us know](https://github.com/buttplugio/buttplug-rs-ffi/issues).
85
-
86
- If you are using Webpack 5, you may need to use Webpack 4 style WASM loading for the time being. Add the following to your webpack config:
87
-
88
- ```javascript
89
- // Needed for webpack 5 only
90
- experiments.syncWebAssembly: true
91
- ```
92
-
93
- If you're seeing MIME issues (i.e. "unknown type" when trying load your app), you may need to set the MIME type in the Webpack configuration file. Add the following block to your rules object:
94
-
95
- ```javascript
96
- {
97
- test: /\.wasm$/,
98
- type: "webassembly/experimental"
99
- }
100
- ```
101
-
102
- If you still run into problems, [file an issue](https://github.com/buttplugio/buttplug-rs-ffi/issues)
103
-
104
- ## Using Buttplug On The Web
105
-
106
- Using the precompiled Buttplug library from a webpage (i.e. loading it as a script in an HTML file) will bring in a global named `Buttplug`. You'll need to run the init method in order to load the rest of the library from WASM, otherwise no calls to the library will work.
107
-
108
- ```html
109
- <!-- Change library version here to match current NPM version -->
110
- <script lang="javascript"
111
- src="https://cdn.jsdelivr.net/npm/buttplug@1.0.1/dist/web/buttplug.min.js">
112
- </script>
113
- <script lang="javascript">
114
- Buttplug.buttplugInit().then(() => console.log("Library loaded"));
115
- </script>
116
- ```
117
-
118
- Each of the examples in the [Developer Guide](https://buttplug-developer-guide.docs.buttplug.io) contain this call, in order to make every example complete.
119
-
120
- ## Support
121
-
122
- If you have questions, support is available via:
123
-
124
- - [Discord](https://discord.buttplug.io) - This is the best choice for support
125
- - [Mentions/DMs to @buttplugio on twitter](https://twitter.com/buttplugio)
10
+ This repo houses are pure .Net version of the Buttplug Typescript/Javascript Client, implementing
11
+ the Version 3 Buttplug Spec. It is expected to run from a browser against either [Intiface Central
12
+ (GUI)](https://intiface.com/central) or [Initface Engine
13
+ (CLI)](https://github.com/intiface/intiface-engine). No Rust FFI bindings are required.
126
14
 
127
- ## Contributing
15
+ ## What happened? Why is buttplug-csharp back?
128
16
 
129
- If you have issues or feature requests, please feel free to [file an issue](https://github.com/buttplugio/buttplug-rs-ffi/issues).
17
+ For those of you that have been around a while, you may remember that this used to be the main
18
+ Typescript/Javascript implementation. From 2017 to 2020, it was a reference version of the Buttplug
19
+ Intimate Haptics Control Standard.
130
20
 
131
- We are not looking for code contributions or pull requests at this time, and will not accept pull requests that do not have a matching issue where the matter was previously discussed. Pull requests should only be submitted after talking to [qdot](https://github.com/qdot) via issues (or on [discord](https://discord.buttplug.io) or [twitter DMs](https://twitter.com/buttplugio) if you would like to stay anonymous and out of recorded info on the repo) before submitting PRs. Random PRs without matching issues and discussion are likely to be closed without merging. and receiving approval to develop code based on an issue. Any random or non-issue pull requests will most likely be closed without merging.
21
+ Then I rewrote everything in Rust because I like Rust more and it's far easier for me to port across
22
+ platforms. This repo was archived ~2 years ago in preference to seating the C# client *and* server
23
+ on top of the [Rust implementation of Buttplug](https://github.com/buttplugio/buttplug), as part of
24
+ the [Rust FFI Project](https://github.com/buttplugio/buttplug-rs-ffi).
132
25
 
133
- ## License
26
+ That project ended up being a partial failure.
134
27
 
135
- Buttplug is BSD 3-Clause licensed. More information is available in
136
- the LICENSE file.
28
+ While the FFI system is handy for languages where it is very difficult to rebuild some parts of the
29
+ library (C/C++/Java/etc...), for managed langauges like Javascript and C#, requiring both the client
30
+ and server to use the FFI was overkill, and caused many extremely difficult-to-debug issues. With
31
+ that in mind, the Typescript implementation in this repo is being turned into a Client only. The
32
+ WASM server and Embedded Connector will stay in the FFI repo, but will be another NPM package that
33
+ will be optional.
@@ -0,0 +1,19 @@
1
+ trigger:
2
+ - master
3
+ - dev
4
+
5
+ jobs:
6
+ # - job: "MacOS"
7
+ # pool:
8
+ # vmImage: 'macos-10.13'
9
+ # steps:
10
+ # - template: 'build/build-test-freeze.yml'
11
+ # parameters:
12
+ # platform: "macos-x64"
13
+ - job: "Linux"
14
+ pool:
15
+ vmImage: 'ubuntu-16.04'
16
+ steps:
17
+ - template: 'build/build-test-freeze.yml'
18
+ parameters:
19
+ platform: "linux-x64"
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
3
+ * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
4
+ * project root for full license information.
5
+ *
6
+ * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
7
+ */
8
+ import { IButtplugClientConnector } from "./IButtplugClientConnector";
9
+ import { ButtplugMessage } from "../core/Messages";
10
+ import { ButtplugBrowserWebsocketConnector } from "../utils/ButtplugBrowserWebsocketConnector";
11
+ export declare class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketConnector implements IButtplugClientConnector {
12
+ private _sorter;
13
+ protected _ws: WebSocket | undefined;
14
+ constructor(_url: string);
15
+ get Connected(): boolean;
16
+ Send: (msg: ButtplugMessage) => Promise<ButtplugMessage>;
17
+ protected ParseIncomingMessage: (event: MessageEvent) => void;
18
+ protected OnReaderLoad(event: Event): void;
19
+ }
@@ -0,0 +1,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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ButtplugBrowserWebsocketClientConnector = void 0;
20
+ const MessageUtils_1 = require("../core/MessageUtils");
21
+ const ButtplugMessageSorter_1 = require("../utils/ButtplugMessageSorter");
22
+ const ButtplugBrowserWebsocketConnector_1 = require("../utils/ButtplugBrowserWebsocketConnector");
23
+ class ButtplugBrowserWebsocketClientConnector extends ButtplugBrowserWebsocketConnector_1.ButtplugBrowserWebsocketConnector {
24
+ constructor(_url) {
25
+ super(_url);
26
+ this._sorter = new ButtplugMessageSorter_1.ButtplugMessageSorter(true);
27
+ this.Send = (msg) => __awaiter(this, void 0, void 0, function* () {
28
+ if (!this.Connected) {
29
+ throw new Error("ButtplugClient not connected");
30
+ }
31
+ const p = this._sorter.PrepareOutgoingMessage(msg);
32
+ this.SendMessage(msg);
33
+ return yield p;
34
+ });
35
+ this.ParseIncomingMessage = (event) => {
36
+ if (typeof (event.data) === "string") {
37
+ const msgs = (0, MessageUtils_1.FromJSON)(event.data);
38
+ const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
39
+ this.emit("message", emitMsgs);
40
+ }
41
+ else if (event.data instanceof Blob) {
42
+ const reader = new FileReader();
43
+ reader.addEventListener("load", (ev) => { this.OnReaderLoad(ev); });
44
+ reader.readAsText(event.data);
45
+ }
46
+ };
47
+ }
48
+ get Connected() {
49
+ return this._ws !== undefined;
50
+ }
51
+ OnReaderLoad(event) {
52
+ const msgs = (0, MessageUtils_1.FromJSON)(event.target.result);
53
+ const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
54
+ this.emit("message", emitMsgs);
55
+ }
56
+ }
57
+ exports.ButtplugBrowserWebsocketClientConnector = ButtplugBrowserWebsocketClientConnector;
58
+ //# sourceMappingURL=ButtplugBrowserWebsocketClientConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtplugBrowserWebsocketClientConnector.js","sourceRoot":"","sources":["../../../../src/client/ButtplugBrowserWebsocketClientConnector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;;;;;;;;;;;;AAIb,uDAAgD;AAChD,0EAAuE;AACvE,kGAA+F;AAE/F,MAAa,uCAAwC,SAAQ,qEAAiC;IAK5F,YAAmB,IAAY;QAC7B,KAAK,CAAC,IAAI,CAAC,CAAC;QAJN,YAAO,GAA0B,IAAI,6CAAqB,CAAC,IAAI,CAAC,CAAC;QAWlE,SAAI,GAAG,CAAO,GAAoB,EAA4B,EAAE;YACrE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;aACjD;YACD,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACnD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC,CAAC;QACjB,CAAC,CAAA,CAAA;QAES,yBAAoB,GAAG,CAAC,KAAmB,EAAE,EAAE;YACvD,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;aAChC;iBAAM,IAAI,KAAK,CAAC,IAAI,YAAY,IAAI,EAAE;gBACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAChC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC/B;QACH,CAAC,CAAA;IAzBD,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC;IAChC,CAAC;IAuBS,YAAY,CAAC,KAAY;QACjC,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAE,KAAK,CAAC,MAAqB,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AAvCD,0FAuCC"}
@@ -0,0 +1,11 @@
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 { ButtplugException } from "../core/Exceptions";
9
+ export declare class ButtplugClientConnectorException extends ButtplugException {
10
+ constructor(message: string);
11
+ }