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,79 @@
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
+ 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.ButtplugMessageSorter = void 0;
34
+ const Messages = __importStar(require("../core/Messages"));
35
+ const Exceptions_1 = require("../core/Exceptions");
36
+ class ButtplugMessageSorter {
37
+ constructor(_useCounter) {
38
+ this._useCounter = _useCounter;
39
+ this._counter = 1;
40
+ this._waitingMsgs = new Map();
41
+ }
42
+ // One of the places we should actually return a promise, as we need to store
43
+ // them while waiting for them to return across the line.
44
+ // tslint:disable:promise-function-async
45
+ PrepareOutgoingMessage(msg) {
46
+ if (this._useCounter) {
47
+ msg.Id = this._counter;
48
+ // Always increment last, otherwise we might lose sync
49
+ this._counter += 1;
50
+ }
51
+ let res;
52
+ let rej;
53
+ const msgPromise = new Promise((resolve, reject) => { res = resolve; rej = reject; });
54
+ this._waitingMsgs.set(msg.Id, [res, rej]);
55
+ return msgPromise;
56
+ }
57
+ ParseIncomingMessages(msgs) {
58
+ const noMatch = [];
59
+ for (const x of msgs) {
60
+ if (x.Id !== Messages.SYSTEM_MESSAGE_ID && this._waitingMsgs.has(x.Id)) {
61
+ const [res, rej] = this._waitingMsgs.get(x.Id);
62
+ // If we've gotten back an error, reject the related promise using a
63
+ // ButtplugException derived type.
64
+ if (x.Type === Messages.Error) {
65
+ rej(Exceptions_1.ButtplugException.FromError(x));
66
+ continue;
67
+ }
68
+ res(x);
69
+ continue;
70
+ }
71
+ else {
72
+ noMatch.push(x);
73
+ }
74
+ }
75
+ return noMatch;
76
+ }
77
+ }
78
+ exports.ButtplugMessageSorter = ButtplugMessageSorter;
79
+ //# sourceMappingURL=ButtplugMessageSorter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtplugMessageSorter.js","sourceRoot":"","sources":["../../../../src/utils/ButtplugMessageSorter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2DAA6C;AAC7C,mDAAuD;AAEvD,MAAa,qBAAqB;IAIhC,YAA2B,WAAoB;QAApB,gBAAW,GAAX,WAAW,CAAS;QAHrC,aAAQ,GAAW,CAAC,CAAC;QACrB,iBAAY,GAAiF,IAAI,GAAG,EAAE,CAAC;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AC,CAAC;aACjB;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA1CD,sDA0CC"}
@@ -0,0 +1 @@
1
+ export declare function getRandomInt(max: number): number;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandomInt = void 0;
4
+ function getRandomInt(max) {
5
+ return Math.floor(Math.random() * Math.floor(max));
6
+ }
7
+ exports.getRandomInt = getRandomInt;
8
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/utils/Utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC"}