@neurosity/sdk 6.2.0 → 6.2.1-next.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 (299) hide show
  1. package/package.json +19 -23
  2. package/CHANGELOG.md +0 -25
  3. package/dist/browser/neurosity.iife.js +0 -48712
  4. package/dist/browser/neurosity.js +0 -666
  5. package/dist/browser/neurosity.js.map +0 -1
  6. package/dist/cjs/Neurosity.d.ts +0 -619
  7. package/dist/cjs/Neurosity.js +0 -1244
  8. package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +0 -72
  9. package/dist/cjs/api/bluetooth/BluetoothClient.js +0 -310
  10. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +0 -33
  11. package/dist/cjs/api/bluetooth/BluetoothTransport.js +0 -2
  12. package/dist/cjs/api/bluetooth/constants.d.ts +0 -4
  13. package/dist/cjs/api/bluetooth/constants.js +0 -9
  14. package/dist/cjs/api/bluetooth/index.d.ts +0 -4
  15. package/dist/cjs/api/bluetooth/index.js +0 -20
  16. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +0 -70
  17. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +0 -406
  18. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
  19. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +0 -11
  20. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
  21. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -10
  22. package/dist/cjs/api/bluetooth/types/index.d.ts +0 -31
  23. package/dist/cjs/api/bluetooth/types/index.js +0 -22
  24. package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +0 -1
  25. package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +0 -8
  26. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +0 -11
  27. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +0 -36
  28. package/dist/cjs/api/bluetooth/utils/encoding.d.ts +0 -3
  29. package/dist/cjs/api/bluetooth/utils/encoding.js +0 -22
  30. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -2
  31. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +0 -23
  32. package/dist/cjs/api/bluetooth/utils/stitch.d.ts +0 -5
  33. package/dist/cjs/api/bluetooth/utils/stitch.js +0 -22
  34. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +0 -54
  35. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +0 -430
  36. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -1
  37. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -8
  38. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +0 -1
  39. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +0 -11
  40. package/dist/cjs/api/firebase/FirebaseApp.d.ts +0 -20
  41. package/dist/cjs/api/firebase/FirebaseApp.js +0 -70
  42. package/dist/cjs/api/firebase/FirebaseDevice.d.ts +0 -68
  43. package/dist/cjs/api/firebase/FirebaseDevice.js +0 -146
  44. package/dist/cjs/api/firebase/FirebaseUser.d.ts +0 -53
  45. package/dist/cjs/api/firebase/FirebaseUser.js +0 -434
  46. package/dist/cjs/api/firebase/config.d.ts +0 -8
  47. package/dist/cjs/api/firebase/config.js +0 -11
  48. package/dist/cjs/api/firebase/deviceStore.d.ts +0 -26
  49. package/dist/cjs/api/firebase/deviceStore.js +0 -191
  50. package/dist/cjs/api/firebase/index.d.ts +0 -3
  51. package/dist/cjs/api/firebase/index.js +0 -19
  52. package/dist/cjs/api/https/config.d.ts +0 -1
  53. package/dist/cjs/api/https/config.js +0 -4
  54. package/dist/cjs/api/https/createOAuthURL.d.ts +0 -3
  55. package/dist/cjs/api/https/createOAuthURL.js +0 -18
  56. package/dist/cjs/api/https/getOAuthToken.d.ts +0 -3
  57. package/dist/cjs/api/https/getOAuthToken.js +0 -34
  58. package/dist/cjs/api/https/utils.d.ts +0 -2
  59. package/dist/cjs/api/https/utils.js +0 -13
  60. package/dist/cjs/api/index.d.ts +0 -109
  61. package/dist/cjs/api/index.js +0 -307
  62. package/dist/cjs/index.d.ts +0 -2
  63. package/dist/cjs/index.js +0 -18
  64. package/dist/cjs/subscriptions/SubscriptionManager.d.ts +0 -11
  65. package/dist/cjs/subscriptions/SubscriptionManager.js +0 -27
  66. package/dist/cjs/timesync/Timesync.d.ts +0 -20
  67. package/dist/cjs/timesync/Timesync.js +0 -78
  68. package/dist/cjs/timesync/index.d.ts +0 -1
  69. package/dist/cjs/timesync/index.js +0 -17
  70. package/dist/cjs/types/accelerometer.d.ts +0 -10
  71. package/dist/cjs/types/accelerometer.js +0 -2
  72. package/dist/cjs/types/actions.d.ts +0 -16
  73. package/dist/cjs/types/actions.js +0 -2
  74. package/dist/cjs/types/awareness.d.ts +0 -1
  75. package/dist/cjs/types/awareness.js +0 -2
  76. package/dist/cjs/types/brainwaves.d.ts +0 -26
  77. package/dist/cjs/types/brainwaves.js +0 -2
  78. package/dist/cjs/types/calm.d.ts +0 -6
  79. package/dist/cjs/types/calm.js +0 -2
  80. package/dist/cjs/types/client.d.ts +0 -22
  81. package/dist/cjs/types/client.js +0 -2
  82. package/dist/cjs/types/credentials.d.ts +0 -12
  83. package/dist/cjs/types/credentials.js +0 -2
  84. package/dist/cjs/types/deviceInfo.d.ts +0 -18
  85. package/dist/cjs/types/deviceInfo.js +0 -2
  86. package/dist/cjs/types/epoch.d.ts +0 -12
  87. package/dist/cjs/types/epoch.js +0 -2
  88. package/dist/cjs/types/experiment.d.ts +0 -9
  89. package/dist/cjs/types/experiment.js +0 -2
  90. package/dist/cjs/types/focus.d.ts +0 -6
  91. package/dist/cjs/types/focus.js +0 -2
  92. package/dist/cjs/types/hapticEffects.d.ts +0 -125
  93. package/dist/cjs/types/hapticEffects.js +0 -2
  94. package/dist/cjs/types/kinesis.d.ts +0 -6
  95. package/dist/cjs/types/kinesis.js +0 -2
  96. package/dist/cjs/types/marker.d.ts +0 -7
  97. package/dist/cjs/types/marker.js +0 -2
  98. package/dist/cjs/types/metrics.d.ts +0 -21
  99. package/dist/cjs/types/metrics.js +0 -2
  100. package/dist/cjs/types/oauth.d.ts +0 -20
  101. package/dist/cjs/types/oauth.js +0 -2
  102. package/dist/cjs/types/options.d.ts +0 -51
  103. package/dist/cjs/types/options.js +0 -2
  104. package/dist/cjs/types/sample.d.ts +0 -15
  105. package/dist/cjs/types/sample.js +0 -2
  106. package/dist/cjs/types/settings.d.ts +0 -13
  107. package/dist/cjs/types/settings.js +0 -2
  108. package/dist/cjs/types/signalQuality.d.ts +0 -13
  109. package/dist/cjs/types/signalQuality.js +0 -2
  110. package/dist/cjs/types/skill.d.ts +0 -68
  111. package/dist/cjs/types/skill.js +0 -2
  112. package/dist/cjs/types/status.d.ts +0 -26
  113. package/dist/cjs/types/status.js +0 -22
  114. package/dist/cjs/types/streaming.d.ts +0 -15
  115. package/dist/cjs/types/streaming.js +0 -20
  116. package/dist/cjs/types/subscriptions.d.ts +0 -23
  117. package/dist/cjs/types/subscriptions.js +0 -2
  118. package/dist/cjs/types/training.d.ts +0 -19
  119. package/dist/cjs/types/training.js +0 -2
  120. package/dist/cjs/types/user.d.ts +0 -12
  121. package/dist/cjs/types/user.js +0 -2
  122. package/dist/cjs/utils/errors.d.ts +0 -5
  123. package/dist/cjs/utils/errors.js +0 -17
  124. package/dist/cjs/utils/filterInternalKeys.d.ts +0 -3
  125. package/dist/cjs/utils/filterInternalKeys.js +0 -21
  126. package/dist/cjs/utils/hapticEffects.d.ts +0 -123
  127. package/dist/cjs/utils/hapticEffects.js +0 -130
  128. package/dist/cjs/utils/heartbeat.d.ts +0 -4
  129. package/dist/cjs/utils/heartbeat.js +0 -41
  130. package/dist/cjs/utils/is-node.d.ts +0 -1
  131. package/dist/cjs/utils/is-node.js +0 -9
  132. package/dist/cjs/utils/metrics.d.ts +0 -1
  133. package/dist/cjs/utils/metrics.js +0 -56
  134. package/dist/cjs/utils/oauth.d.ts +0 -9
  135. package/dist/cjs/utils/oauth.js +0 -92
  136. package/dist/cjs/utils/pick.d.ts +0 -1
  137. package/dist/cjs/utils/pick.js +0 -5
  138. package/dist/cjs/utils/pipes.d.ts +0 -46
  139. package/dist/cjs/utils/pipes.js +0 -71
  140. package/dist/cjs/utils/platform.d.ts +0 -30
  141. package/dist/cjs/utils/platform.js +0 -47
  142. package/dist/cjs/utils/subscription.d.ts +0 -6
  143. package/dist/cjs/utils/subscription.js +0 -55
  144. package/dist/cjs/utils/transferDevice.d.ts +0 -9
  145. package/dist/cjs/utils/transferDevice.js +0 -2
  146. package/dist/cjs/utils/whileOnline.d.ts +0 -8
  147. package/dist/cjs/utils/whileOnline.js +0 -15
  148. package/dist/electron/index.js +0 -86
  149. package/dist/electron/index.js.map +0 -1
  150. package/dist/esm/Neurosity.d.ts +0 -619
  151. package/dist/esm/Neurosity.js +0 -1213
  152. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +0 -72
  153. package/dist/esm/api/bluetooth/BluetoothClient.js +0 -306
  154. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +0 -33
  155. package/dist/esm/api/bluetooth/BluetoothTransport.js +0 -1
  156. package/dist/esm/api/bluetooth/constants.d.ts +0 -4
  157. package/dist/esm/api/bluetooth/constants.js +0 -6
  158. package/dist/esm/api/bluetooth/index.d.ts +0 -4
  159. package/dist/esm/api/bluetooth/index.js +0 -4
  160. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +0 -70
  161. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +0 -402
  162. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +0 -63
  163. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +0 -8
  164. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +0 -180
  165. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +0 -9
  166. package/dist/esm/api/bluetooth/types/index.d.ts +0 -31
  167. package/dist/esm/api/bluetooth/types/index.js +0 -19
  168. package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +0 -1
  169. package/dist/esm/api/bluetooth/utils/create6DigitPin.js +0 -4
  170. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +0 -11
  171. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +0 -31
  172. package/dist/esm/api/bluetooth/utils/encoding.d.ts +0 -3
  173. package/dist/esm/api/bluetooth/utils/encoding.js +0 -17
  174. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +0 -2
  175. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +0 -16
  176. package/dist/esm/api/bluetooth/utils/stitch.d.ts +0 -5
  177. package/dist/esm/api/bluetooth/utils/stitch.js +0 -18
  178. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +0 -54
  179. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +0 -426
  180. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +0 -1
  181. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +0 -4
  182. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +0 -1
  183. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +0 -7
  184. package/dist/esm/api/firebase/FirebaseApp.d.ts +0 -20
  185. package/dist/esm/api/firebase/FirebaseApp.js +0 -63
  186. package/dist/esm/api/firebase/FirebaseDevice.d.ts +0 -68
  187. package/dist/esm/api/firebase/FirebaseDevice.js +0 -139
  188. package/dist/esm/api/firebase/FirebaseUser.d.ts +0 -53
  189. package/dist/esm/api/firebase/FirebaseUser.js +0 -426
  190. package/dist/esm/api/firebase/config.d.ts +0 -8
  191. package/dist/esm/api/firebase/config.js +0 -8
  192. package/dist/esm/api/firebase/deviceStore.d.ts +0 -26
  193. package/dist/esm/api/firebase/deviceStore.js +0 -184
  194. package/dist/esm/api/firebase/index.d.ts +0 -3
  195. package/dist/esm/api/firebase/index.js +0 -3
  196. package/dist/esm/api/https/config.d.ts +0 -1
  197. package/dist/esm/api/https/config.js +0 -1
  198. package/dist/esm/api/https/createOAuthURL.d.ts +0 -3
  199. package/dist/esm/api/https/createOAuthURL.js +0 -11
  200. package/dist/esm/api/https/getOAuthToken.d.ts +0 -3
  201. package/dist/esm/api/https/getOAuthToken.js +0 -27
  202. package/dist/esm/api/https/utils.d.ts +0 -2
  203. package/dist/esm/api/https/utils.js +0 -9
  204. package/dist/esm/api/index.d.ts +0 -109
  205. package/dist/esm/api/index.js +0 -300
  206. package/dist/esm/index.d.ts +0 -2
  207. package/dist/esm/index.js +0 -2
  208. package/dist/esm/neurosity.mjs +0 -48700
  209. package/dist/esm/subscriptions/SubscriptionManager.d.ts +0 -11
  210. package/dist/esm/subscriptions/SubscriptionManager.js +0 -23
  211. package/dist/esm/timesync/Timesync.d.ts +0 -20
  212. package/dist/esm/timesync/Timesync.js +0 -71
  213. package/dist/esm/timesync/index.d.ts +0 -1
  214. package/dist/esm/timesync/index.js +0 -1
  215. package/dist/esm/types/accelerometer.d.ts +0 -10
  216. package/dist/esm/types/accelerometer.js +0 -1
  217. package/dist/esm/types/actions.d.ts +0 -16
  218. package/dist/esm/types/actions.js +0 -1
  219. package/dist/esm/types/awareness.d.ts +0 -1
  220. package/dist/esm/types/awareness.js +0 -1
  221. package/dist/esm/types/brainwaves.d.ts +0 -26
  222. package/dist/esm/types/brainwaves.js +0 -1
  223. package/dist/esm/types/calm.d.ts +0 -6
  224. package/dist/esm/types/calm.js +0 -1
  225. package/dist/esm/types/client.d.ts +0 -22
  226. package/dist/esm/types/client.js +0 -1
  227. package/dist/esm/types/credentials.d.ts +0 -12
  228. package/dist/esm/types/credentials.js +0 -1
  229. package/dist/esm/types/deviceInfo.d.ts +0 -18
  230. package/dist/esm/types/deviceInfo.js +0 -1
  231. package/dist/esm/types/epoch.d.ts +0 -12
  232. package/dist/esm/types/epoch.js +0 -1
  233. package/dist/esm/types/experiment.d.ts +0 -9
  234. package/dist/esm/types/experiment.js +0 -1
  235. package/dist/esm/types/focus.d.ts +0 -6
  236. package/dist/esm/types/focus.js +0 -1
  237. package/dist/esm/types/hapticEffects.d.ts +0 -125
  238. package/dist/esm/types/hapticEffects.js +0 -1
  239. package/dist/esm/types/kinesis.d.ts +0 -6
  240. package/dist/esm/types/kinesis.js +0 -1
  241. package/dist/esm/types/marker.d.ts +0 -7
  242. package/dist/esm/types/marker.js +0 -1
  243. package/dist/esm/types/metrics.d.ts +0 -21
  244. package/dist/esm/types/metrics.js +0 -1
  245. package/dist/esm/types/oauth.d.ts +0 -20
  246. package/dist/esm/types/oauth.js +0 -1
  247. package/dist/esm/types/options.d.ts +0 -51
  248. package/dist/esm/types/options.js +0 -1
  249. package/dist/esm/types/sample.d.ts +0 -15
  250. package/dist/esm/types/sample.js +0 -1
  251. package/dist/esm/types/settings.d.ts +0 -13
  252. package/dist/esm/types/settings.js +0 -1
  253. package/dist/esm/types/signalQuality.d.ts +0 -13
  254. package/dist/esm/types/signalQuality.js +0 -1
  255. package/dist/esm/types/skill.d.ts +0 -68
  256. package/dist/esm/types/skill.js +0 -1
  257. package/dist/esm/types/status.d.ts +0 -26
  258. package/dist/esm/types/status.js +0 -19
  259. package/dist/esm/types/streaming.d.ts +0 -15
  260. package/dist/esm/types/streaming.js +0 -17
  261. package/dist/esm/types/subscriptions.d.ts +0 -23
  262. package/dist/esm/types/subscriptions.js +0 -1
  263. package/dist/esm/types/training.d.ts +0 -19
  264. package/dist/esm/types/training.js +0 -1
  265. package/dist/esm/types/user.d.ts +0 -12
  266. package/dist/esm/types/user.js +0 -1
  267. package/dist/esm/utils/errors.d.ts +0 -5
  268. package/dist/esm/utils/errors.js +0 -11
  269. package/dist/esm/utils/filterInternalKeys.d.ts +0 -3
  270. package/dist/esm/utils/filterInternalKeys.js +0 -17
  271. package/dist/esm/utils/hapticEffects.d.ts +0 -123
  272. package/dist/esm/utils/hapticEffects.js +0 -125
  273. package/dist/esm/utils/heartbeat.d.ts +0 -4
  274. package/dist/esm/utils/heartbeat.js +0 -33
  275. package/dist/esm/utils/is-node.d.ts +0 -1
  276. package/dist/esm/utils/is-node.js +0 -5
  277. package/dist/esm/utils/metrics.d.ts +0 -1
  278. package/dist/esm/utils/metrics.js +0 -52
  279. package/dist/esm/utils/oauth.d.ts +0 -9
  280. package/dist/esm/utils/oauth.js +0 -64
  281. package/dist/esm/utils/pick.d.ts +0 -1
  282. package/dist/esm/utils/pick.js +0 -1
  283. package/dist/esm/utils/pipes.d.ts +0 -46
  284. package/dist/esm/utils/pipes.js +0 -65
  285. package/dist/esm/utils/platform.d.ts +0 -30
  286. package/dist/esm/utils/platform.js +0 -41
  287. package/dist/esm/utils/subscription.d.ts +0 -6
  288. package/dist/esm/utils/subscription.js +0 -24
  289. package/dist/esm/utils/transferDevice.d.ts +0 -9
  290. package/dist/esm/utils/transferDevice.js +0 -1
  291. package/dist/esm/utils/whileOnline.d.ts +0 -8
  292. package/dist/esm/utils/whileOnline.js +0 -11
  293. package/dist/examples/auth.html +0 -32
  294. package/dist/examples/cloud.html +0 -17
  295. package/dist/examples/index.html +0 -1
  296. package/dist/examples/neurosity.iife.js +0 -48712
  297. package/dist/examples/neurosity.js +0 -666
  298. package/dist/examples/neurosity.mjs +0 -48700
  299. package/dist/examples/training.html +0 -49
@@ -1,307 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CloudClient = exports.SERVER_TIMESTAMP = exports.createUser = exports.credentialWithLink = void 0;
13
- const rxjs_1 = require("rxjs");
14
- const rxjs_2 = require("rxjs");
15
- const operators_1 = require("rxjs/operators");
16
- const firebase_1 = require("./firebase");
17
- const timesync_1 = require("../timesync");
18
- const SubscriptionManager_1 = require("../subscriptions/SubscriptionManager");
19
- const heartbeat_1 = require("../utils/heartbeat");
20
- const filterInternalKeys_1 = require("../utils/filterInternalKeys");
21
- var firebase_2 = require("./firebase");
22
- Object.defineProperty(exports, "credentialWithLink", { enumerable: true, get: function () { return firebase_2.credentialWithLink; } });
23
- Object.defineProperty(exports, "createUser", { enumerable: true, get: function () { return firebase_2.createUser; } });
24
- Object.defineProperty(exports, "SERVER_TIMESTAMP", { enumerable: true, get: function () { return firebase_2.SERVER_TIMESTAMP; } });
25
- /**
26
- * @hidden
27
- */
28
- class CloudClient {
29
- constructor(options) {
30
- /**
31
- * @internal
32
- */
33
- this._selectedDevice = new rxjs_1.ReplaySubject(1);
34
- this.options = options;
35
- this.subscriptionManager = new SubscriptionManager_1.SubscriptionManager();
36
- this.firebaseApp = new firebase_1.FirebaseApp(options);
37
- this.firebaseUser = new firebase_1.FirebaseUser(this.firebaseApp);
38
- this._selectedDevice.next(undefined);
39
- this.status$ = (0, heartbeat_1.heartbeatAwareStatus)(this.observeNamespace("status").pipe((0, operators_1.share)())).pipe((0, filterInternalKeys_1.filterInternalKeys)(), (0, operators_1.shareReplay)(1));
40
- this.firebaseUser.onAuthStateChanged().subscribe((user) => {
41
- this.user = user;
42
- });
43
- this.firebaseUser.onUserClaimsChange().subscribe((userClaims) => {
44
- this.userClaims = userClaims;
45
- });
46
- this.onDeviceChange().subscribe((device) => {
47
- if (this.firebaseDevice) {
48
- this.firebaseDevice.disconnect();
49
- }
50
- if (!device) {
51
- return;
52
- }
53
- this.firebaseDevice = new firebase_1.FirebaseDevice({
54
- deviceId: device.deviceId,
55
- firebaseApp: this.firebaseApp,
56
- dependencies: {
57
- subscriptionManager: this.subscriptionManager
58
- }
59
- });
60
- if (this.options.timesync) {
61
- this.timesync = new timesync_1.Timesync({
62
- status$: this.status(),
63
- getTimesync: this.firebaseDevice.getTimesync.bind(this.firebaseDevice)
64
- });
65
- }
66
- });
67
- }
68
- onDeviceChange() {
69
- return this._selectedDevice
70
- .asObservable()
71
- .pipe((0, operators_1.filter)((value) => value !== undefined));
72
- }
73
- // Automatically select device when user logs in
74
- setAutoSelectedDevice() {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- // Select based on `deviceId` passed
77
- if (this.options.deviceId) {
78
- return yield this.selectDevice((devices) => {
79
- return devices.find((device) => device.deviceId === this.options.deviceId);
80
- });
81
- }
82
- // Auto select first-claimed device
83
- if (!this.options.deviceId && this.options.autoSelectDevice) {
84
- return yield this.selectDevice((devices) => {
85
- // Auto select first device
86
- return devices[0];
87
- });
88
- }
89
- return null;
90
- });
91
- }
92
- get actions() {
93
- return {
94
- dispatch: (action) => {
95
- return this.firebaseDevice.dispatchAction(action);
96
- }
97
- };
98
- }
99
- dispatchAction(action) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- return yield this.firebaseDevice.dispatchAction(action);
102
- });
103
- }
104
- disconnect() {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- return this.firebaseApp.disconnect();
107
- });
108
- }
109
- getInfo() {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- return yield this.firebaseDevice.getInfo();
112
- });
113
- }
114
- login(credentials) {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- if (this.user) {
117
- return Promise.reject(`Already logged in.`);
118
- }
119
- const auth = yield this.firebaseUser.login(credentials);
120
- const selectedDevice = yield this.setAutoSelectedDevice();
121
- return Object.assign(Object.assign({}, auth), { selectedDevice });
122
- });
123
- }
124
- logout() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- if (this.firebaseDevice) {
127
- this.firebaseDevice.disconnect();
128
- }
129
- return yield this.firebaseUser.logout();
130
- });
131
- }
132
- onAuthStateChanged() {
133
- return this.firebaseUser.onAuthStateChanged().pipe((0, operators_1.switchMap)((user) => __awaiter(this, void 0, void 0, function* () {
134
- if (!user) {
135
- return null;
136
- }
137
- const selectedDevice = this.didSelectDevice()
138
- ? yield this.getSelectedDevice()
139
- : yield this.setAutoSelectedDevice();
140
- return Object.assign(Object.assign({}, user), { selectedDevice });
141
- })));
142
- }
143
- getDevices() {
144
- return this.firebaseUser.getDevices();
145
- }
146
- addDevice(deviceId) {
147
- return this.firebaseUser.addDevice(deviceId);
148
- }
149
- removeDevice(deviceId) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- const [hasError, errorMessage] = yield this.firebaseUser
152
- .removeDevice(deviceId)
153
- .then(() => [false])
154
- .catch((error) => [true, error]);
155
- if (hasError) {
156
- return Promise.reject(errorMessage);
157
- }
158
- const selectedDevice = yield this.getSelectedDevice();
159
- if ((selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceId) === deviceId) {
160
- this._selectedDevice.next(null);
161
- }
162
- });
163
- }
164
- transferDevice(options) {
165
- return __awaiter(this, void 0, void 0, function* () {
166
- const [hasError, error] = yield this.firebaseUser
167
- .transferDevice(options)
168
- .then(() => [false])
169
- .catch((error) => [true, error]);
170
- if (hasError) {
171
- return Promise.reject(error);
172
- }
173
- const selectedDevice = yield this.getSelectedDevice();
174
- if ((selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceId) === options.deviceId) {
175
- this._selectedDevice.next(null);
176
- }
177
- });
178
- }
179
- onUserDevicesChange() {
180
- return this.firebaseUser.onUserDevicesChange();
181
- }
182
- onUserClaimsChange() {
183
- return this.firebaseUser.onUserClaimsChange();
184
- }
185
- didSelectDevice() {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- const selectedDevice = yield this.getSelectedDevice();
188
- return !!selectedDevice;
189
- });
190
- }
191
- selectDevice(deviceSelector) {
192
- return __awaiter(this, void 0, void 0, function* () {
193
- const devices = yield this.getDevices();
194
- if (!devices) {
195
- return Promise.reject(`Did not find any devices for this user. Make sure your device is claimed by your Neurosity account.`);
196
- }
197
- const deviceTupleSelector = (devices) => devices.find((device) => {
198
- if (!Array.isArray(deviceSelector)) {
199
- return false;
200
- }
201
- const [deviceKey, deviceValue] = deviceSelector;
202
- return (JSON.stringify(device === null || device === void 0 ? void 0 : device[deviceKey]) === JSON.stringify(deviceValue));
203
- });
204
- const device = typeof deviceSelector === "function"
205
- ? deviceSelector(devices)
206
- : deviceTupleSelector(devices);
207
- if (!device) {
208
- return Promise.reject(`A device was not provided. Try returning a device from the devicesList provided in the callback.`);
209
- }
210
- const hasPermission = yield this.firebaseUser.hasDevicePermission(device.deviceId);
211
- if (!hasPermission) {
212
- return Promise.reject(`Rejected device access due to permissions.`);
213
- }
214
- this._selectedDevice.next(device);
215
- return device;
216
- });
217
- }
218
- getSelectedDevice() {
219
- return __awaiter(this, void 0, void 0, function* () {
220
- return yield (0, rxjs_2.firstValueFrom)(this._selectedDevice);
221
- });
222
- }
223
- status() {
224
- return this.status$;
225
- }
226
- observeNamespace(namespace) {
227
- const getNamespaceValues = () => (0, rxjs_2.fromEventPattern)((handler) => this.firebaseDevice.onNamespace(namespace, handler), (handler) => this.firebaseDevice.offNamespace(namespace, handler));
228
- return this.onDeviceChange().pipe((0, operators_1.switchMap)((selectedDevice) => {
229
- return selectedDevice ? getNamespaceValues() : rxjs_1.EMPTY;
230
- }));
231
- }
232
- onceNamespace(namespace) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- return yield this.firebaseDevice.onceNamespace(namespace);
235
- });
236
- }
237
- get metrics() {
238
- return {
239
- next: (metricName, metricValue) => {
240
- this.firebaseDevice.nextMetric(metricName, metricValue);
241
- },
242
- on: (subscription, callback) => {
243
- return this.firebaseDevice.onMetric(subscription, callback);
244
- },
245
- subscribe: (subscription) => {
246
- const subscriptionCreated = this.firebaseDevice.subscribeToMetric(subscription);
247
- this.subscriptionManager.add(subscriptionCreated);
248
- return subscriptionCreated;
249
- },
250
- unsubscribe: (subscription, listener) => {
251
- this.subscriptionManager.remove(subscription);
252
- this.firebaseDevice.unsubscribeFromMetric(subscription);
253
- this.firebaseDevice.removeMetricListener(subscription, listener);
254
- }
255
- };
256
- }
257
- createAccount(credentials) {
258
- return this.firebaseUser.createAccount(credentials);
259
- }
260
- deleteAccount() {
261
- return this.firebaseUser.deleteAccount();
262
- }
263
- createBluetoothToken() {
264
- return this.firebaseDevice.createBluetoothToken();
265
- }
266
- createCustomToken() {
267
- return this.firebaseUser.createCustomToken();
268
- }
269
- removeOAuthAccess() {
270
- return this.firebaseUser.removeOAuthAccess();
271
- }
272
- onUserExperiments() {
273
- return this.firebaseUser.onUserExperiments();
274
- }
275
- deleteUserExperiment(experimentId) {
276
- return this.firebaseUser.deleteUserExperiment(experimentId);
277
- }
278
- get skills() {
279
- return {
280
- get: (bundleId) => __awaiter(this, void 0, void 0, function* () {
281
- return this.firebaseDevice.getSkill(bundleId);
282
- })
283
- };
284
- }
285
- get timestamp() {
286
- return this.options.timesync ? this.timesync.timestamp : Date.now();
287
- }
288
- getTimesyncOffset() {
289
- return this.timesync.offset;
290
- }
291
- changeSettings(settings) {
292
- return this.firebaseDevice.changeSettings(settings);
293
- }
294
- goOffline() {
295
- this.firebaseApp.goOffline();
296
- }
297
- goOnline() {
298
- this.firebaseApp.goOnline();
299
- }
300
- /**
301
- * @internal
302
- */
303
- __getApp() {
304
- return this.firebaseApp.app;
305
- }
306
- }
307
- exports.CloudClient = CloudClient;
@@ -1,2 +0,0 @@
1
- export * from "./Neurosity";
2
- export * from "./api/bluetooth";
package/dist/cjs/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Neurosity"), exports);
18
- __exportStar(require("./api/bluetooth"), exports);
@@ -1,11 +0,0 @@
1
- import { Subscription, Subscriptions } from "../types/subscriptions";
2
- /**
3
- * @hidden
4
- */
5
- export declare class SubscriptionManager {
6
- private _subscriptions;
7
- get(): Subscriptions;
8
- toList(): Subscription[];
9
- add(subscription: Subscription): void;
10
- remove(subscription: Subscription): void;
11
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubscriptionManager = void 0;
4
- /**
5
- * @hidden
6
- */
7
- class SubscriptionManager {
8
- constructor() {
9
- this._subscriptions = {};
10
- }
11
- get() {
12
- return this._subscriptions;
13
- }
14
- toList() {
15
- return Object.values(this._subscriptions);
16
- }
17
- add(subscription) {
18
- this._subscriptions[subscription.id] = subscription;
19
- }
20
- remove(subscription) {
21
- if (!(subscription.id in this._subscriptions)) {
22
- return;
23
- }
24
- Reflect.deleteProperty(this._subscriptions, subscription.id);
25
- }
26
- }
27
- exports.SubscriptionManager = SubscriptionManager;
@@ -1,20 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { DeviceStatus } from "../types/status";
3
- declare type Options = {
4
- getTimesync: () => Promise<number>;
5
- status$: Observable<DeviceStatus>;
6
- bufferSize?: number;
7
- updateInterval?: number;
8
- };
9
- export declare class Timesync {
10
- options: Options;
11
- _offset: number;
12
- constructor(options: Options);
13
- start(): void;
14
- filterOutliers(): import("rxjs").UnaryFunction<Observable<number[]>, Observable<number[]>>;
15
- toOffset(): import("rxjs").UnaryFunction<Observable<unknown>, Observable<number>>;
16
- private average;
17
- get offset(): number;
18
- get timestamp(): number;
19
- }
20
- export {};
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Timesync = void 0;
16
- const rxjs_1 = require("rxjs");
17
- const operators_1 = require("rxjs/operators");
18
- const operators_2 = require("rxjs/operators");
19
- const outliers_1 = __importDefault(require("outliers"));
20
- const whileOnline_1 = require("../utils/whileOnline");
21
- const defaultOptions = {
22
- bufferSize: 100,
23
- updateInterval: 1 * 60 * 1000 // every minute
24
- };
25
- class Timesync {
26
- constructor(options) {
27
- this._offset = 0;
28
- this.options = Object.assign(Object.assign({}, defaultOptions), options);
29
- this.start();
30
- }
31
- start() {
32
- const { bufferSize, updateInterval, status$ } = this.options;
33
- const burst$ = (0, rxjs_1.range)(0, bufferSize);
34
- const timer$ = (0, rxjs_1.timer)(updateInterval, updateInterval).pipe((0, operators_1.map)((i) => bufferSize + i), (0, whileOnline_1.whileOnline)({
35
- status$,
36
- allowWhileOnSleepMode: true
37
- }));
38
- const firstTimeDeviceIsOnline$ = status$.pipe((0, operators_1.filter)((status) => status.state === "online"), (0, operators_1.take)(1));
39
- firstTimeDeviceIsOnline$
40
- .pipe((0, operators_2.switchMap)(() => {
41
- return burst$.pipe((0, operators_1.concatWith)(timer$), this.toOffset(), (0, operators_2.bufferCount)(bufferSize, 1), this.filterOutliers(), (0, operators_1.map)((list) => this.average(list)));
42
- }))
43
- .subscribe((offset) => {
44
- this._offset = offset;
45
- });
46
- }
47
- filterOutliers() {
48
- return (0, rxjs_1.pipe)((0, operators_1.map)((offsets) => {
49
- return offsets.filter((0, outliers_1.default)());
50
- }));
51
- }
52
- toOffset() {
53
- const { getTimesync } = this.options;
54
- return (0, rxjs_1.pipe)((0, operators_2.concatMap)(() => __awaiter(this, void 0, void 0, function* () {
55
- const requestStartTime = Date.now();
56
- const [error, serverTime] = yield getTimesync()
57
- .then((offset) => [null, offset])
58
- .catch((error) => [error]);
59
- if (error) {
60
- return 0;
61
- }
62
- const responseEndTime = Date.now();
63
- const oneWayDuration = (responseEndTime - requestStartTime) / 2;
64
- const offset = responseEndTime - oneWayDuration - serverTime;
65
- return offset;
66
- })));
67
- }
68
- average(list) {
69
- return Math.round(list.reduce((acc, number) => acc + number) / list.length);
70
- }
71
- get offset() {
72
- return this._offset;
73
- }
74
- get timestamp() {
75
- return Date.now() + this._offset;
76
- }
77
- }
78
- exports.Timesync = Timesync;
@@ -1 +0,0 @@
1
- export * from "./Timesync";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Timesync"), exports);
@@ -1,10 +0,0 @@
1
- export interface Accelerometer {
2
- acceleration: number;
3
- inclination: number;
4
- orientation: number;
5
- pitch: number;
6
- roll: number;
7
- x: number;
8
- y: number;
9
- z: number;
10
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export interface Action {
5
- command: string;
6
- action: string;
7
- message?: any;
8
- responseRequired?: boolean;
9
- responseTimeout?: number;
10
- }
11
- /**
12
- * @hidden
13
- */
14
- export interface Actions {
15
- dispatch(action: Action): Promise<any>;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export declare type AwarenessLabels = "calm" | "focus";
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,26 +0,0 @@
1
- export declare type BrainwavesLabel = "raw" | "rawUnfiltered" | "powerByBand" | "psd";
2
- export declare type AmplitudeByChannel = number[][];
3
- export interface Epoch {
4
- data: AmplitudeByChannel;
5
- info: {
6
- samplingRate: number;
7
- startTime: number;
8
- };
9
- }
10
- export declare type PSDByChannel = number[][];
11
- export interface PSD {
12
- psd: PSDByChannel;
13
- freqs: number[];
14
- info: {
15
- samplingRate: number;
16
- startTime: number;
17
- };
18
- }
19
- export declare type BandName = "gamma" | "beta" | "alpha" | "theta" | "delta";
20
- export interface PowerByBand {
21
- gamma: number[];
22
- beta: number[];
23
- alpha: number[];
24
- theta: number[];
25
- delta: number[];
26
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- export interface Calm {
2
- metric: "awareness";
3
- label: "calm";
4
- probability: number;
5
- timestamp: number;
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { User } from "@firebase/auth-types";
3
- import { Actions } from "./actions";
4
- import { Metrics } from "./metrics";
5
- import { SkillsClient } from "./skill";
6
- import { Credentials } from "./credentials";
7
- import { ChangeSettings } from "./settings";
8
- /**
9
- * @hidden
10
- */
11
- export interface Client {
12
- user: User | null;
13
- actions: Actions;
14
- disconnect(): Promise<any>;
15
- getInfo(): Promise<any>;
16
- login?(credentials: Credentials): Promise<any>;
17
- observeNamespace(namespace: string): Observable<any>;
18
- metrics: Metrics;
19
- skills: SkillsClient;
20
- timestamp: number;
21
- changeSettings(settings: ChangeSettings): Promise<void>;
22
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- export declare type CustomToken = {
2
- customToken: string;
3
- };
4
- export declare type EmailAndPassword = {
5
- email: string;
6
- password: string;
7
- };
8
- export declare type OAuthCredentials = {
9
- idToken: string;
10
- providerId: string;
11
- };
12
- export declare type Credentials = EmailAndPassword | OAuthCredentials | CustomToken;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- export interface DeviceInfo {
2
- deviceId: string;
3
- deviceNickname: string;
4
- channelNames: string[];
5
- channels: number;
6
- samplingRate: number;
7
- manufacturer: string;
8
- model: string;
9
- modelName: string;
10
- modelVersion: string;
11
- osVersion: string;
12
- apiVersion: string;
13
- emulator?: boolean;
14
- }
15
- declare type DeviceSelectorKeyValue = [string, string | number | string[]];
16
- declare type DeviceSelectorFunction = (devices: DeviceInfo[]) => DeviceInfo;
17
- export declare type DeviceSelector = DeviceSelectorKeyValue | DeviceSelectorFunction;
18
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- import { Marker } from "./marker";
2
- /**
3
- * @hidden
4
- */
5
- export declare type Epoch = {
6
- data: number[];
7
- info?: {
8
- channelNames?: string[];
9
- samplingRate?: number;
10
- marker?: Marker[];
11
- };
12
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });