@ircam/comote-helpers 0.3.3 → 1.0.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 (203) hide show
  1. package/.babelrc +5 -0
  2. package/.github/workflows/main.yml +3 -3
  3. package/.history/.gitignore_20250415160643 +6 -0
  4. package/.history/.gitignore_20250415160723 +6 -0
  5. package/.history/examples/simple-webview/package-lock_20250415130242.json +5109 -0
  6. package/.history/examples/simple-webview/package-lock_20250416103557.json +5109 -0
  7. package/.history/examples/simple-webview/package_20250415130704.json +26 -0
  8. package/.history/examples/simple-webview/package_20250415184837.json +26 -0
  9. package/.history/examples/simple-webview/package_20250415190300.json +23 -0
  10. package/.history/examples/simple-webview/src/server_20250415105733.js +20 -0
  11. package/.history/examples/simple-webview/src/server_20250415184604.js +20 -0
  12. package/.history/examples/soundworks/package_20250415132431.json +35 -0
  13. package/.history/examples/soundworks/package_20250416105956.json +35 -0
  14. package/.history/max/CoMote/examples/simple-webview/package_20250415184836.json +26 -0
  15. package/.history/max/CoMote/examples/simple-webview/package_20250415185949.json +23 -0
  16. package/.history/max/CoMote/examples/simple-webview/package_20250415185950.json +23 -0
  17. package/.history/max/CoMote/package-info_20241018173608.json +41 -0
  18. package/.history/max/CoMote/package-info_20250416105743.json +27 -0
  19. package/.history/max/CoMote/package-info_20250416105826.json +27 -0
  20. package/.history/max/CoMote/source/comote-connect/package_20250415132759.json +19 -0
  21. package/.history/max/CoMote/source/comote-connect/package_20250416110158.json +19 -0
  22. package/.history/max/CoMote/source/comote-connect/server_20250414175059.js +193 -0
  23. package/.history/max/CoMote/source/comote-connect/server_20250415180549.js +193 -0
  24. package/.history/package_20250415143437.json +26 -0
  25. package/.history/package_20250416105907.json +26 -0
  26. package/LICENSE +2 -2
  27. package/examples/simple-webview/README.md +10 -0
  28. package/examples/simple-webview/build/comote-simple-webview-server.js +44 -0
  29. package/examples/simple-webview/package-lock.json +5109 -0
  30. package/examples/simple-webview/package.json +23 -0
  31. package/examples/simple-webview/public/favicon.ico +0 -0
  32. package/examples/simple-webview/public/index.html +13 -0
  33. package/examples/simple-webview/public/index.mjs +3623 -0
  34. package/examples/simple-webview/public/styles.css +99 -0
  35. package/examples/simple-webview/src/client.js +35 -0
  36. package/examples/simple-webview/src/server.js +20 -0
  37. package/examples/soundworks/.build/clients/components/sw-audit.js +64 -0
  38. package/examples/soundworks/.build/clients/components/sw-audit.js.map +1 -0
  39. package/examples/soundworks/.build/clients/components/sw-credits.js +73 -0
  40. package/examples/soundworks/.build/clients/components/sw-credits.js.map +1 -0
  41. package/examples/soundworks/.build/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
  42. package/examples/soundworks/.build/clients/player/index.js +116 -0
  43. package/examples/soundworks/.build/clients/player/index.js.map +1 -0
  44. package/examples/soundworks/.build/clients/styles/app.scss +79 -0
  45. package/examples/soundworks/.build/clients/styles/normalize.scss +359 -0
  46. package/examples/soundworks/.build/clients/webview/index.js +72 -0
  47. package/examples/soundworks/.build/clients/webview/index.js.map +1 -0
  48. package/examples/soundworks/.build/public/css/app.css +76 -0
  49. package/examples/soundworks/.build/public/css/app.css.map +1 -0
  50. package/examples/soundworks/.build/public/css/normalize.css +321 -0
  51. package/examples/soundworks/.build/public/css/normalize.css.map +1 -0
  52. package/examples/soundworks/.build/public/player.js +98098 -0
  53. package/examples/soundworks/.build/public/player.js.map +1 -0
  54. package/examples/soundworks/.build/public/webview.js +50725 -0
  55. package/examples/soundworks/.build/public/webview.js.map +1 -0
  56. package/examples/soundworks/.build/server/index.js +57 -0
  57. package/examples/soundworks/.build/server/index.js.map +1 -0
  58. package/examples/soundworks/.build/server/schemas/.gitkeep +1 -0
  59. package/examples/soundworks/.build/server/schemas/global.js +19 -0
  60. package/examples/soundworks/.build/server/schemas/global.js.map +1 -0
  61. package/examples/soundworks/.build/server/tmpl/default.tmpl +27 -0
  62. package/examples/soundworks/.build/utils/catch-unhandled-errors.js +9 -0
  63. package/examples/soundworks/.build/utils/catch-unhandled-errors.js.map +1 -0
  64. package/examples/soundworks/.editorconfig +12 -0
  65. package/examples/soundworks/.eslintrc +3 -0
  66. package/examples/soundworks/.soundworks +7 -0
  67. package/examples/soundworks/.vendors/public/webcomponentsjs/CHANGELOG.md +76 -0
  68. package/examples/soundworks/.vendors/public/webcomponentsjs/LICENSE.md +19 -0
  69. package/examples/soundworks/.vendors/public/webcomponentsjs/README.md +259 -0
  70. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-ce.js +63 -0
  71. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-ce.js.map +1 -0
  72. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_dom.js +62 -0
  73. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_dom.js.map +1 -0
  74. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_js.js +95 -0
  75. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_js.js.map +1 -0
  76. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js +374 -0
  77. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js.map +1 -0
  78. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce.js +240 -0
  79. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce.js.map +1 -0
  80. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd.js +196 -0
  81. package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd.js.map +1 -0
  82. package/examples/soundworks/.vendors/public/webcomponentsjs/custom-elements-es5-adapter.js +15 -0
  83. package/examples/soundworks/.vendors/public/webcomponentsjs/package.json +51 -0
  84. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/custom-elements-es5-adapter-index.js +16 -0
  85. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-bundle-index.js +55 -0
  86. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-ce-index.js +17 -0
  87. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-pf_dom-index.js +19 -0
  88. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-pf_js-index.js +13 -0
  89. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-index.js +19 -0
  90. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-pf-index.js +25 -0
  91. package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-index.js +18 -0
  92. package/examples/soundworks/.vendors/public/webcomponentsjs/src/flag-parser.js +69 -0
  93. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/baseuri.js +28 -0
  94. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/after.js +47 -0
  95. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/before.js +40 -0
  96. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/index.js +14 -0
  97. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/remove.js +37 -0
  98. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/replace-with.js +42 -0
  99. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/custom-event.js +79 -0
  100. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/es6-misc.js +38 -0
  101. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/event-listener-options.js +122 -0
  102. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/get-attribute-names.js +27 -0
  103. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/matches.js +21 -0
  104. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/append.js +31 -0
  105. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/index.js +13 -0
  106. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/prepend.js +42 -0
  107. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/replace-children.js +45 -0
  108. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/promise.js +50 -0
  109. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/svg-element-class-list.js +28 -0
  110. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/symbol.js +64 -0
  111. package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/toggle-attribute.js +39 -0
  112. package/examples/soundworks/.vendors/public/webcomponentsjs/src/unresolved.js +32 -0
  113. package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.d.ts +175 -0
  114. package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.js +384 -0
  115. package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.js.map +1 -0
  116. package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-loader.js +238 -0
  117. package/examples/soundworks/LICENSE +28 -0
  118. package/examples/soundworks/README.md +26 -0
  119. package/examples/soundworks/config/application.yaml +8 -0
  120. package/examples/soundworks/config/env-default.yaml +12 -0
  121. package/examples/soundworks/package.json +35 -0
  122. package/examples/soundworks/public/favicon.ico +0 -0
  123. package/examples/soundworks/public/images/loader.gif +0 -0
  124. package/examples/soundworks/src/clients/components/sw-audit.js +78 -0
  125. package/examples/soundworks/src/clients/components/sw-credits.js +80 -0
  126. package/examples/soundworks/src/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
  127. package/examples/soundworks/src/clients/player/index.js +118 -0
  128. package/examples/soundworks/src/clients/styles/app.scss +79 -0
  129. package/examples/soundworks/src/clients/styles/normalize.scss +359 -0
  130. package/examples/soundworks/src/clients/webview/index.js +78 -0
  131. package/examples/soundworks/src/server/index.js +62 -0
  132. package/examples/soundworks/src/server/schemas/.gitkeep +1 -0
  133. package/examples/soundworks/src/server/schemas/global.js +18 -0
  134. package/examples/soundworks/src/server/tmpl/default.tmpl +27 -0
  135. package/examples/soundworks/src/utils/catch-unhandled-errors.js +9 -0
  136. package/index.html +51 -0
  137. package/max/CoMote/docs/sw.shared-state.maxref.xml +95 -0
  138. package/max/CoMote/examples/simple-webview/README.md +10 -0
  139. package/max/CoMote/examples/simple-webview/build/comote-simple-webview-server.js +44 -0
  140. package/max/CoMote/examples/simple-webview/comote-simple-webview-server.maxpat +186 -0
  141. package/max/CoMote/examples/simple-webview/package-lock.json +5109 -0
  142. package/max/CoMote/examples/simple-webview/package.json +23 -0
  143. package/max/CoMote/examples/simple-webview/public/favicon.ico +0 -0
  144. package/max/CoMote/examples/simple-webview/public/index.html +13 -0
  145. package/max/CoMote/examples/simple-webview/public/index.mjs +3623 -0
  146. package/max/CoMote/examples/simple-webview/public/styles.css +99 -0
  147. package/max/CoMote/examples/simple-webview/src/client.js +35 -0
  148. package/max/CoMote/examples/simple-webview/src/server.js +20 -0
  149. package/max/CoMote/examples/soundworks/.editorconfig +12 -0
  150. package/max/CoMote/examples/soundworks/.eslintrc +3 -0
  151. package/max/CoMote/examples/soundworks/.soundworks +7 -0
  152. package/max/CoMote/examples/soundworks/LICENSE +28 -0
  153. package/max/CoMote/examples/soundworks/README.md +26 -0
  154. package/max/CoMote/examples/soundworks/config/application.yaml +8 -0
  155. package/max/CoMote/examples/soundworks/config/env-default.yaml +12 -0
  156. package/max/CoMote/examples/soundworks/package.json +35 -0
  157. package/max/CoMote/examples/soundworks/public/favicon.ico +0 -0
  158. package/max/CoMote/examples/soundworks/public/images/loader.gif +0 -0
  159. package/max/CoMote/examples/soundworks/src/clients/components/sw-audit.js +78 -0
  160. package/max/CoMote/examples/soundworks/src/clients/components/sw-credits.js +80 -0
  161. package/max/CoMote/examples/soundworks/src/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
  162. package/max/CoMote/examples/soundworks/src/clients/player/index.js +118 -0
  163. package/max/CoMote/examples/soundworks/src/clients/styles/app.scss +79 -0
  164. package/max/CoMote/examples/soundworks/src/clients/styles/normalize.scss +359 -0
  165. package/max/CoMote/examples/soundworks/src/clients/webview/index.js +78 -0
  166. package/max/CoMote/examples/soundworks/src/server/index.js +62 -0
  167. package/max/CoMote/examples/soundworks/src/server/schemas/.gitkeep +1 -0
  168. package/max/CoMote/examples/soundworks/src/server/schemas/global.js +18 -0
  169. package/max/CoMote/examples/soundworks/src/server/tmpl/default.tmpl +27 -0
  170. package/max/CoMote/examples/soundworks/src/utils/catch-unhandled-errors.js +9 -0
  171. package/max/CoMote/extras/CoMote.maxpat +1994 -0
  172. package/max/CoMote/help/comote_osc_receive.maxhelp +946 -0
  173. package/max/CoMote/icon.png +0 -0
  174. package/max/CoMote/init/objectmappings.txt +2 -0
  175. package/max/CoMote/media/comote-screenshot.png +0 -0
  176. package/max/CoMote/package-info.json +27 -0
  177. package/max/CoMote/patchers/comote-connect/comote-connect-public/comote-connect-client.mjs +2821 -0
  178. package/max/CoMote/patchers/comote-connect/comote-connect-public/favicon.ico +0 -0
  179. package/max/CoMote/patchers/comote-connect/comote-connect-public/index.html +22 -0
  180. package/max/CoMote/patchers/comote-connect/comote-connect-server.js +24775 -0
  181. package/max/CoMote/patchers/comote-connect/comote-connect.maxpat +1048 -0
  182. package/max/CoMote/patchers/comote-connect/package.json +4 -0
  183. package/max/CoMote/patchers/comote_format_from_comote_v2.maxpat +613 -0
  184. package/max/CoMote/patchers/comote_format_from_v3.maxpat +443 -0
  185. package/max/CoMote/patchers/comote_format_gyro_v2_to_v3.maxpat +240 -0
  186. package/max/CoMote/patchers/comote_format_gyro_v3_to_v2.maxpat +240 -0
  187. package/max/CoMote/patchers/comote_format_heading_v2_to_v3.maxpat +171 -0
  188. package/max/CoMote/patchers/comote_osc_receive.maxpat +440 -0
  189. package/max/CoMote/patchers/comote_osc_to_list.maxpat +161 -0
  190. package/max/CoMote/readme.md +22 -0
  191. package/max/CoMote/source/comote-connect/client.js +104 -0
  192. package/max/CoMote/source/comote-connect/package-lock.json +591 -0
  193. package/max/CoMote/source/comote-connect/package.json +19 -0
  194. package/max/CoMote/source/comote-connect/server.js +193 -0
  195. package/max-update.bash +44 -0
  196. package/package.json +10 -29
  197. package/src/.editorbackup/network-infos.js~ +60 -0
  198. package/src/.editorbackup/wifi-infos.js~ +33 -0
  199. package/{network-infos.js → src/network-infos.js} +25 -16
  200. package/{qrcode.js → src/qrcode.js} +32 -30
  201. package/{server.js → src/server.js} +60 -47
  202. package/{wifi-infos.js → src/wifi-infos.js} +8 -12
  203. package/README.md +0 -160
@@ -1,19 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Server = void 0;
7
- var _ws = _interopRequireDefault(require("ws"));
8
- var _utf8Validate = _interopRequireDefault(require("utf-8-validate"));
9
- var _nodeOsc = require("node-osc");
10
- var _cloneDeep = _interopRequireDefault(require("clone-deep"));
11
- var _assignDeep = _interopRequireDefault(require("assign-deep"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ import { WebSocketServer } from 'ws';
2
+ import isValidUTF8 from 'utf-8-validate';
3
+ import { Server as OscServer } from 'node-osc';
4
+ import cloneDeep from 'clone-deep';
5
+ import assignDeep from 'assign-deep';
6
+
7
+ console.log(WebSocket);
8
+
13
9
  /**
14
10
  * @typedef {Object} CoMoteConfig
15
- * @property {String} id - id of the client CoMo.te
16
- * @property {Number} interval - period in ms of the sensors for the client CoMo.te
11
+ * @property {String} id - id of the client CoMote
12
+ * @property {Number} interval - period in ms of the sensors for the client CoMote
17
13
  * @property {CoMoteTarget} osc - OSC configuration
18
14
  * @property {CoMoteTarget} ws - WebSocket configuration
19
15
  */
@@ -22,9 +18,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
18
  * @typedef {Object} CoMoteTarget
23
19
  * @property {String} hostname - hostname or ip of the WebSocket or OSC server
24
20
  * @property {Number} port - listening port of the of the WebSocket or OSC server
25
- * @property {Boolean} autostart - enable streaming on CoMo.te application
21
+ * @property {Boolean} autostart - enable streaming on CoMote application
26
22
  */
27
23
 
24
+
28
25
  /**
29
26
  * Launch WebSocket and/or OSC server according to given `CoMoteConfig` object
30
27
  *
@@ -32,57 +29,60 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
32
29
  * @param {Object} options - options
33
30
  * @param {Object} [options.verbose=false] - logs debug informations
34
31
  */
35
- class Server {
32
+ export class Server {
36
33
  constructor(config, options) {
37
34
  /**
38
35
  * Configuration of the CoMote server
39
36
  */
40
- this.config = (0, _cloneDeep.default)((0, _assignDeep.default)({
37
+ this.config = cloneDeep(assignDeep({
41
38
  id: null,
42
39
  interval: null,
43
40
  osc: null,
44
41
  ws: null,
45
- verbose: false
42
+ verbose: false,
46
43
  }, config));
44
+
47
45
  this._verbose = !!options.verbose;
46
+
48
47
  if (this._verbose) {
49
- console.log('+ CoMo.te config:');
48
+ console.log('+ CoMote config:');
50
49
  console.log(this.config, '\n');
51
50
  }
51
+
52
52
  this._websocketServer = null;
53
53
  this._oscServer = null;
54
+
54
55
  this._wsListeners = new Set();
55
56
  this._oscListeners = new Set();
56
57
  }
58
+
57
59
  async start() {
58
60
  let wsPromise = true;
59
61
  let oscPromise = true;
62
+
60
63
  if (this.config.ws !== null) {
61
- const {
62
- hostname,
63
- port
64
- } = this.config.ws;
64
+ const { hostname, port } = this.config.ws;
65
+
65
66
  if (!Number.isInteger(port)) {
66
67
  throw new Error(`Invalid port "${port}" for WebSocket server`);
67
68
  }
69
+
68
70
  if (this._verbose) {
69
- console.log(`> CoMo.te: Launching WebSocket server on port: ${port}`);
71
+ console.log(`> CoMote: Launching WebSocket server on port: ${port}`);
70
72
  }
71
- this._websocketServer = new _ws.default.Server({
72
- port
73
- });
74
- const sockets = new Map();
73
+
74
+ this._websocketServer = new WebSocketServer({ port });
75
75
  this._websocketServer.on('connection', (socket, request) => {
76
76
  // const ip = request.socket.remoteAddress;
77
77
  socket.on('message', (data, isBinary) => {
78
78
  if (isBinary) {
79
79
  // @todo
80
80
  } else {
81
- if ((0, _utf8Validate.default)(data)) {
82
- // do we really need this check?
81
+ if (isValidUTF8(data)) { // do we really need this check?
83
82
  data = JSON.parse(data);
83
+
84
84
  if (this._verbose) {
85
- console.log(`> CoMo.te: new WebSocket message`, data);
85
+ console.log(`> CoMote: new WebSocket message`, data);
86
86
  }
87
87
 
88
88
  // console.log(data);
@@ -95,28 +95,30 @@ class Server {
95
95
  // When a socket closes, or disconnects, remove it from the array.
96
96
  socket.on('close', (code, data) => {
97
97
  if (this._verbose) {
98
- console.log('> CoMo.te: closed socket connection');
98
+ console.log('> CoMote: closed socket connection');
99
99
  }
100
100
  });
101
101
  });
102
+
102
103
  wsPromise = new Promise((resolve, reject) => {
103
104
  this._websocketServer.on('listening', () => {
104
105
  if (this._verbose) {
105
- console.log(`> CoMo.te: WebSocket server listening`);
106
+ console.log(`> CoMote: WebSocket server listening`);
106
107
  }
108
+
107
109
  resolve();
108
110
  });
111
+
109
112
  this._websocketServer.on('error', err => {
110
- console.log(`> CoMo.te: WebSocket server error`, err);
113
+ console.log(`> CoMote: WebSocket server error`, err);
111
114
  reject(err);
112
115
  });
113
116
  });
114
117
  }
118
+
115
119
  if (this.config.osc !== null) {
116
- const {
117
- hostname,
118
- port
119
- } = this.config.osc;
120
+ const { hostname, port } = this.config.osc;
121
+
120
122
  if (!Number.isInteger(port)) {
121
123
  throw new Error(`Invalid port "${port}" for OSC server`);
122
124
  }
@@ -125,46 +127,57 @@ class Server {
125
127
  if (!hostname) {
126
128
  hostname = '0.0.0.0';
127
129
  }
130
+
128
131
  if (this._verbose) {
129
- console.log(`> CoMo.te: Launching OSC server udp://${hostname}:${port}`);
132
+ console.log(`> CoMote: Launching OSC server udp://${hostname}:${port}`);
130
133
  }
134
+
131
135
  oscPromise = new Promise((resolve, reject) => {
132
- this._oscServer = new _nodeOsc.Server(this.config.osc.port, hostname, err => {
136
+ this._oscServer = new OscServer(this.config.osc.port, hostname, err => {
133
137
  if (err) {
134
- console.log(`> CoMo.te: OSC server error`, err);
138
+ console.log(`> CoMote: OSC server error`, err);
135
139
  reject();
136
140
  return;
137
141
  }
142
+
138
143
  if (this._verbose) {
139
- console.log(`> CoMo.te: OSC server listening`);
144
+ console.log(`> CoMote: OSC server listening`);
140
145
  }
146
+
141
147
  resolve();
142
148
  });
149
+
143
150
  this._oscServer.on('message', data => {
144
151
  let address = data.shift();
152
+
145
153
  if (this._verbose) {
146
- console.log(`> CoMo.te: new OSC message "${address}":`, data);
154
+ console.log(`> CoMote: new OSC message "${address}":`, data);
147
155
  }
156
+
148
157
  this._oscListeners.forEach(callback => callback(address, data));
149
158
  });
150
159
  });
151
160
  }
161
+
152
162
  return Promise.all([wsPromise, oscPromise]);
153
163
  }
164
+
154
165
  async stop() {
155
166
  if (this._websocketServer) {
156
167
  this._websocketServer.close();
157
168
  }
169
+
158
170
  if (this._oscServer) {
159
171
  this._oscServer.close();
160
172
  }
161
173
  }
162
174
 
163
- /**
164
- * Add a listener for incomming WebSocket message
165
- */
175
+ /**
176
+ * Add a listener for incomming WebSocket message
177
+ */
166
178
  addWsListener(callback) {
167
179
  this._wsListeners.add(callback);
180
+
168
181
  return () => this._wsListeners.delete(callback);
169
182
  }
170
183
 
@@ -180,6 +193,7 @@ class Server {
180
193
  */
181
194
  addOscListener(callback) {
182
195
  this._oscListeners.add(callback);
196
+
183
197
  return () => this._oscListeners.delete(callback);
184
198
  }
185
199
 
@@ -190,4 +204,3 @@ class Server {
190
204
  this._oscListeners.delete(callback);
191
205
  }
192
206
  }
193
- exports.Server = Server;
@@ -1,11 +1,5 @@
1
- "use strict";
1
+ import si from 'systeminformation';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWifiInfos = getWifiInfos;
7
- var _systeminformation = _interopRequireDefault(require("systeminformation"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
3
  /**
10
4
  * @typedef {Object} WifiInfos
11
5
  * @property {number} ssid - SSID of the WiFi connection
@@ -19,19 +13,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
13
  * @async
20
14
  * @return {WiFiInfos|null}
21
15
  */
22
- async function getWifiInfos() {
16
+ export async function getWifiInfos() {
23
17
  // find first wifi connection
24
- const wifiConnections = await _systeminformation.default.wifiConnections();
18
+ const wifiConnections = await si.wifiConnections();
25
19
  const conn = wifiConnections[0];
20
+
26
21
  if (!conn) {
27
22
  return null;
28
23
  }
29
24
 
30
25
  // find related interface
31
- const interfaces = await _systeminformation.default.networkInterfaces();
26
+ const interfaces = await si.networkInterfaces();
32
27
  const int = interfaces.find(int => int.iface === conn.iface);
28
+
33
29
  return {
34
30
  ssid: conn.ssid,
35
- ip: int.ip4
31
+ ip: int.ip4,
36
32
  };
37
- }
33
+ }
package/README.md DELETED
@@ -1,160 +0,0 @@
1
- # `CoMo.te helpers`
2
-
3
- > Javascript and Max/MSP utilities to create applications compatible with iPhone
4
- > and Android `CoMo.te` application, cf. [https://ismm-apps.ircam.fr/comote](https://ismm-apps.ircam.fr/comote).
5
-
6
-
7
- The CoMo.te application (iOS and Android) allows for streaming motion data (accelerometer, gyroscope) from the smartphone to desktop applications using either the OSC or Websockets protocols. The network's setup is facilitated by the use of a QR code generated by the targeted remote application receiving the motion sensor data.
8
-
9
- CoMo.te is especially designed for the CoMo applications family that enables real-time interaction between gestures/movements and sounds. Nevertheless, the CoMo.te application can be used with any software that makes use of the OSC protocol.
10
-
11
- Among the CoMo applications that make use of CoMo.te are CoMo-Vox to learn and train conducting gestures, and CoMo-Elements to interact collectively thought body movements with recorded sounds.
12
-
13
- CoMo.te and the CoMo applications are software designed and developed by IRCAM in the Sound-Music-Movement-Interaction team (UMR STMS).
14
-
15
- This repository provides utilities to help to generate the QRCode in the target application both for Max/MSP and Node.js.
16
-
17
-
18
-
19
- ## Table of Contents
20
-
21
- <!-- toc -->
22
-
23
- - [Max/MSP](#maxmsp)
24
- - [JS](#js)
25
- * [Node.js](#nodejs)
26
- * [API](#api)
27
- - [License](#license)
28
-
29
- <!-- tocstop -->
30
-
31
- ## Max/MSP
32
-
33
- Download the Max abstraction (i.e. CoMo.te.zip) from the lastest release in the releases page: https://github.com/ircam-ismm/comote-helpers/releases
34
- Unzip the package and copy the resulting directory in `~/Documents/Max 8/Packages`
35
-
36
- For now, the package only provide abstraction `[comote.connect]` that allows you to generate a QRCode that can be
37
- flashed within the CoMo.te application to configure the OSC stream.
38
-
39
- You can find more informations in the Helper patch: `~/Document/Max 8/Packages/CoMo.te/extras/CoMo.te.maxpat`
40
-
41
- This version requires Max 7.1 or higher.
42
-
43
- ## JS
44
-
45
- ### Node.js
46
-
47
- ```sh
48
- npm install --save @ircam/comote-helpers
49
- ```
50
-
51
- ### API
52
-
53
- <!-- api -->
54
-
55
- #### Classes
56
-
57
- <dl>
58
- <dt><a href="#Server">Server</a></dt>
59
- <dd><p>Launch WebSocket and/or OSC server according to given <code>CoMoteConfig</code> object</p>
60
- </dd>
61
- </dl>
62
-
63
- #### Functions
64
-
65
- <dl>
66
- <dt><a href="#rawLink">rawLink()</a></dt>
67
- <dd><p>Return the link to be encoded in the QRCode accroding to given <code>CoMoteConfig</code></p>
68
- </dd>
69
- <dt><a href="#terminal">terminal(config)</a></dt>
70
- <dd><p>Create a qrcode to be logged in terminal according to given `CoMoteConfig``</p>
71
- </dd>
72
- <dt><a href="#dataURL">dataURL(config)</a></dt>
73
- <dd><p>Create a qrcode to be used as in Image source according to given `CoMoteConfig``</p>
74
- </dd>
75
- </dl>
76
-
77
- #### Typedefs
78
-
79
- <dl>
80
- <dt><a href="#CoMoteConfig">CoMoteConfig</a> : <code>Object</code></dt>
81
- <dd></dd>
82
- <dt><a href="#CoMoteTarget">CoMoteTarget</a> : <code>Object</code></dt>
83
- <dd></dd>
84
- </dl>
85
-
86
- <a name="rawLink"></a>
87
-
88
- #### rawLink()
89
- Return the link to be encoded in the QRCode accroding to given `CoMoteConfig`
90
-
91
- **Kind**: global function
92
- <a name="terminal"></a>
93
-
94
- #### terminal(config)
95
- Create a qrcode to be logged in terminal according to given `CoMoteConfig``
96
-
97
- **Kind**: global function
98
-
99
- | Param | Type |
100
- | --- | --- |
101
- | config | [<code>CoMoteConfig</code>](#CoMoteConfig) |
102
-
103
- **Example**
104
- ```js
105
- console(await CoMoteQRCode.terminal(config));
106
- ```
107
- <a name="dataURL"></a>
108
-
109
- #### dataURL(config)
110
- Create a qrcode to be used as in Image source according to given `CoMoteConfig``
111
-
112
- **Kind**: global function
113
-
114
- | Param | Type |
115
- | --- | --- |
116
- | config | [<code>CoMoteConfig</code>](#CoMoteConfig) |
117
-
118
- **Example**
119
- ```js
120
- const qrCode = await CoMoteQRCode.dataURL(config));
121
-
122
- <img src="${qrCode}" />
123
- ```
124
- <a name="CoMoteConfig"></a>
125
-
126
- #### CoMoteConfig : <code>Object</code>
127
- **Kind**: global typedef
128
- **Properties**
129
-
130
- | Name | Type | Description |
131
- | --- | --- | --- |
132
- | id | <code>String</code> | id of the client CoMo.te |
133
- | interval | <code>Number</code> | period in ms of the sensors for the client CoMo.te |
134
- | osc | [<code>CoMoteTarget</code>](#CoMoteTarget) | OSC configuration |
135
- | ws | [<code>CoMoteTarget</code>](#CoMoteTarget) | WebSocket configuration |
136
-
137
- <a name="CoMoteTarget"></a>
138
-
139
- #### CoMoteTarget : <code>Object</code>
140
- **Kind**: global typedef
141
- **Properties**
142
-
143
- | Name | Type | Description |
144
- | --- | --- | --- |
145
- | hostname | <code>String</code> | hostname or ip of the WebSocket or OSC server |
146
- | port | <code>Number</code> | listening port of the of the WebSocket or OSC server |
147
- | autostart | <code>Boolean</code> | enable streaming on CoMo.te application |
148
-
149
-
150
- <!-- apistop -->
151
-
152
- ## Credits
153
-
154
- CoMo.te is developed by Ircam and the Music and Sound Science and Technology Joint Research Unit (STMS), supported by Ircam, CNRS, the French Ministry of Culture and Sorbonne University.
155
-
156
- Produced with the support of the French Ministry of Education, Youth and Sports (Edu-up system), the National Research Agency (ELEMENT project), and in partnership with Radio France.
157
-
158
- ## License
159
-
160
- BSD-3-Clause