@neurosity/sdk 6.2.0 → 6.2.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.
@@ -45709,34 +45709,34 @@ var Neurosity = (function (exports) {
45709
45709
  /**
45710
45710
  * @hidden
45711
45711
  */
45712
- var BLUETOOTH_CONNECTION;
45712
+
45713
45713
  (function (BLUETOOTH_CONNECTION) {
45714
45714
  BLUETOOTH_CONNECTION["SCANNING"] = "scanning";
45715
45715
  BLUETOOTH_CONNECTION["CONNECTED"] = "connected";
45716
45716
  BLUETOOTH_CONNECTION["CONNECTING"] = "connecting";
45717
45717
  BLUETOOTH_CONNECTION["DISCONNECTING"] = "disconnecting";
45718
45718
  BLUETOOTH_CONNECTION["DISCONNECTED"] = "disconnected";
45719
- })(BLUETOOTH_CONNECTION || (BLUETOOTH_CONNECTION = {}));
45719
+ })(exports.BLUETOOTH_CONNECTION || (exports.BLUETOOTH_CONNECTION = {}));
45720
45720
  /**
45721
45721
  * @hidden
45722
45722
  */
45723
- var TRANSPORT_TYPE;
45723
+
45724
45724
  (function (TRANSPORT_TYPE) {
45725
45725
  TRANSPORT_TYPE["WEB"] = "web";
45726
45726
  TRANSPORT_TYPE["REACT_NATIVE"] = "reactNative";
45727
- })(TRANSPORT_TYPE || (TRANSPORT_TYPE = {}));
45727
+ })(exports.TRANSPORT_TYPE || (exports.TRANSPORT_TYPE = {}));
45728
45728
 
45729
45729
  const encoder = new TextEncoder();
45730
45730
  const decoder = new TextDecoder("utf-8");
45731
45731
  function encode$1(transportType, data) {
45732
- if (transportType === TRANSPORT_TYPE.REACT_NATIVE) {
45732
+ if (transportType === exports.TRANSPORT_TYPE.REACT_NATIVE) {
45733
45733
  // React Native expects a plain array of numbers and not a Uint8Array
45734
45734
  return [...encoder.encode(data)];
45735
45735
  }
45736
45736
  return encoder.encode(data);
45737
45737
  }
45738
45738
  function decode$1(transportType, data) {
45739
- if (transportType === TRANSPORT_TYPE.REACT_NATIVE) {
45739
+ if (transportType === exports.TRANSPORT_TYPE.REACT_NATIVE) {
45740
45740
  // React Native outpouts a plain array of numbers and not a Uint8Array
45741
45741
  return decoder.decode(new Uint8Array(data));
45742
45742
  }
@@ -46333,9 +46333,9 @@ var Neurosity = (function (exports) {
46333
46333
  };
46334
46334
  class WebBluetoothTransport {
46335
46335
  constructor(options = {}) {
46336
- this.type = TRANSPORT_TYPE.WEB;
46336
+ this.type = exports.TRANSPORT_TYPE.WEB;
46337
46337
  this.characteristicsByName = {};
46338
- this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
46338
+ this.connection$ = new BehaviorSubject(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
46339
46339
  this.pendingActions$ = new BehaviorSubject([]);
46340
46340
  this.logs$ = new ReplaySubject(10);
46341
46341
  this.onDisconnected$ = this._onDisconnected().pipe(share());
@@ -46357,7 +46357,7 @@ var Neurosity = (function (exports) {
46357
46357
  this.addLog(`connection status is ${connection}`);
46358
46358
  });
46359
46359
  this.onDisconnected$.subscribe(() => {
46360
- this.connection$.next(BLUETOOTH_CONNECTION.DISCONNECTED);
46360
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
46361
46361
  });
46362
46362
  }
46363
46363
  _getPairedDevices() {
@@ -46393,7 +46393,7 @@ var Neurosity = (function (exports) {
46393
46393
  this.addLog(`Auto connect: ${deviceNickname} was detected and previously paired`);
46394
46394
  return device;
46395
46395
  })), tap(() => {
46396
- this.connection$.next(BLUETOOTH_CONNECTION.SCANNING);
46396
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.SCANNING);
46397
46397
  }), switchMap((device) => onAdvertisementReceived(device)), switchMap((advertisement) => __awaiter$d(this, void 0, void 0, function* () {
46398
46398
  this.addLog(`Advertisement received for ${advertisement.device.name}`);
46399
46399
  return yield this.getServerServiceAndCharacteristics(advertisement.device);
@@ -46407,7 +46407,7 @@ var Neurosity = (function (exports) {
46407
46407
  }
46408
46408
  isConnected() {
46409
46409
  const connection = this.connection$.getValue();
46410
- return connection === BLUETOOTH_CONNECTION.CONNECTED;
46410
+ return connection === exports.BLUETOOTH_CONNECTION.CONNECTED;
46411
46411
  }
46412
46412
  connection() {
46413
46413
  return this.connectionStream$;
@@ -46463,9 +46463,9 @@ var Neurosity = (function (exports) {
46463
46463
  return __awaiter$d(this, void 0, void 0, function* () {
46464
46464
  try {
46465
46465
  this.device = device;
46466
- const isConnecting = this.connection$.getValue() === BLUETOOTH_CONNECTION.CONNECTING;
46466
+ const isConnecting = this.connection$.getValue() === exports.BLUETOOTH_CONNECTION.CONNECTING;
46467
46467
  if (!isConnecting) {
46468
- this.connection$.next(BLUETOOTH_CONNECTION.CONNECTING);
46468
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.CONNECTING);
46469
46469
  }
46470
46470
  this.server = yield device.gatt.connect();
46471
46471
  this.addLog(`Getting service...`);
@@ -46477,7 +46477,7 @@ var Neurosity = (function (exports) {
46477
46477
  CHARACTERISTIC_UUIDS_TO_NAMES[characteristic.uuid],
46478
46478
  characteristic
46479
46479
  ]));
46480
- this.connection$.next(BLUETOOTH_CONNECTION.CONNECTED);
46480
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.CONNECTED);
46481
46481
  }
46482
46482
  catch (error) {
46483
46483
  return Promise.reject(error);
@@ -46487,7 +46487,7 @@ var Neurosity = (function (exports) {
46487
46487
  _onDisconnected() {
46488
46488
  return this.connection$
46489
46489
  .asObservable()
46490
- .pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
46490
+ .pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
46491
46491
  ? fromDOMEvent(this.device, "gattserverdisconnected")
46492
46492
  : NEVER));
46493
46493
  }
@@ -46565,7 +46565,7 @@ var Neurosity = (function (exports) {
46565
46565
  // );
46566
46566
  // })
46567
46567
  );
46568
- return this.connection$.pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED ? data$ : NEVER));
46568
+ return this.connection$.pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED ? data$ : NEVER));
46569
46569
  }
46570
46570
  readCharacteristic(characteristicName, parse = false) {
46571
46571
  return __awaiter$d(this, void 0, void 0, function* () {
@@ -46612,7 +46612,7 @@ var Neurosity = (function (exports) {
46612
46612
  return __awaiter$d(this, void 0, void 0, function* () {
46613
46613
  let actionsCharacteristic;
46614
46614
  let started = false;
46615
- const sideEffects$ = this.connection$.asObservable().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
46615
+ const sideEffects$ = this.connection$.asObservable().pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
46616
46616
  ? defer(() => this.getCharacteristicByName("actions")).pipe(switchMap((characteristic) => {
46617
46617
  actionsCharacteristic = characteristic;
46618
46618
  return this.pendingActions$;
@@ -46743,9 +46743,9 @@ var Neurosity = (function (exports) {
46743
46743
  };
46744
46744
  class ReactNativeTransport {
46745
46745
  constructor(options) {
46746
- this.type = TRANSPORT_TYPE.REACT_NATIVE;
46746
+ this.type = exports.TRANSPORT_TYPE.REACT_NATIVE;
46747
46747
  this.characteristicsByName = {};
46748
- this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
46748
+ this.connection$ = new BehaviorSubject(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
46749
46749
  this.pendingActions$ = new BehaviorSubject([]);
46750
46750
  this.logs$ = new ReplaySubject(10);
46751
46751
  this.connectionStream$ = this.connection$
@@ -46805,7 +46805,7 @@ var Neurosity = (function (exports) {
46805
46805
  this.addLog(`connection status is ${connection}`);
46806
46806
  });
46807
46807
  this.onDisconnected$.subscribe(() => {
46808
- this.connection$.next(BLUETOOTH_CONNECTION.DISCONNECTED);
46808
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
46809
46809
  });
46810
46810
  }
46811
46811
  addLog(log) {
@@ -46813,7 +46813,7 @@ var Neurosity = (function (exports) {
46813
46813
  }
46814
46814
  isConnected() {
46815
46815
  const connection = this.connection$.getValue();
46816
- return connection === BLUETOOTH_CONNECTION.CONNECTED;
46816
+ return connection === exports.BLUETOOTH_CONNECTION.CONNECTED;
46817
46817
  }
46818
46818
  _autoConnect(selectedDevice$) {
46819
46819
  const selectedDeviceAfterDisconnect$ = this.onDisconnected$.pipe(switchMap(() => selectedDevice$));
@@ -46872,7 +46872,7 @@ var Neurosity = (function (exports) {
46872
46872
  ? scanOnce$
46873
46873
  : timer(0, RESCAN_INTERVAL).pipe(switchMap(() => scanOnce$));
46874
46874
  const peripherals$ = scan$.pipe(tap(() => {
46875
- this.connection$.next(BLUETOOTH_CONNECTION.SCANNING);
46875
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.SCANNING);
46876
46876
  }), takeUntil(this.onDisconnected$), switchMap(() => this.bleEvents.discoverPeripheral$),
46877
46877
  // Filter out devices that are not Neurosity devices
46878
46878
  filter((peripheral) => {
@@ -46903,7 +46903,7 @@ var Neurosity = (function (exports) {
46903
46903
  this.addLog("Peripheral not found");
46904
46904
  return;
46905
46905
  }
46906
- this.connection$.next(BLUETOOTH_CONNECTION.CONNECTING);
46906
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.CONNECTING);
46907
46907
  yield this.BleManager.connect(peripheral.id);
46908
46908
  this.addLog(`Getting service...`);
46909
46909
  const peripheralInfo = yield this.BleManager.retrieveServices(peripheral.id, [
@@ -46931,7 +46931,7 @@ var Neurosity = (function (exports) {
46931
46931
  yield this.BleManager.requestMTU(peripheral.id, ANDROID_MAX_MTU);
46932
46932
  }
46933
46933
  this.addLog(`Successfully connected to peripheral ${peripheral.id}`);
46934
- this.connection$.next(BLUETOOTH_CONNECTION.CONNECTED);
46934
+ this.connection$.next(exports.BLUETOOTH_CONNECTION.CONNECTED);
46935
46935
  resolve();
46936
46936
  }
46937
46937
  catch (error) {
@@ -46993,7 +46993,7 @@ var Neurosity = (function (exports) {
46993
46993
  return payload;
46994
46994
  }
46995
46995
  }));
46996
- return this.connection$.pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
46996
+ return this.connection$.pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
46997
46997
  ? getData(this.getCharacteristicByName(characteristicName))
46998
46998
  : NEVER));
46999
46999
  }
@@ -47039,7 +47039,7 @@ var Neurosity = (function (exports) {
47039
47039
  _autoToggleActionNotifications(selectedDevice$) {
47040
47040
  return __awaiter$e(this, void 0, void 0, function* () {
47041
47041
  let started = false;
47042
- const sideEffects$ = this.connection$.asObservable().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
47042
+ const sideEffects$ = this.connection$.asObservable().pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
47043
47043
  ? this.pendingActions$
47044
47044
  : NEVER), tap((pendingActions) => __awaiter$e(this, void 0, void 0, function* () {
47045
47045
  var _a, _b;
@@ -47272,7 +47272,7 @@ var Neurosity = (function (exports) {
47272
47272
  }));
47273
47273
  return this.selectedDevice$.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
47274
47274
  ? EMPTY
47275
- : this.connection().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
47275
+ : this.connection().pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
47276
47276
  ? reauthenticateInterval$
47277
47277
  : EMPTY), switchMap(() => __awaiter$f(this, void 0, void 0, function* () { return yield this.isAuthenticated(); })), tap(([isAuthenticated]) => __awaiter$f(this, void 0, void 0, function* () {
47278
47278
  if (!isAuthenticated) {
@@ -47616,9 +47616,9 @@ var Neurosity = (function (exports) {
47616
47616
  wifiStatus: this.cloudClient.status(),
47617
47617
  bluetoothConnection: !!(this === null || this === void 0 ? void 0 : this.bluetoothClient)
47618
47618
  ? this.bluetoothClient.connection()
47619
- : of(BLUETOOTH_CONNECTION.DISCONNECTED)
47619
+ : of(exports.BLUETOOTH_CONNECTION.DISCONNECTED)
47620
47620
  }).pipe(map(({ wifiStatus, bluetoothConnection }) => {
47621
- const isBluetoothConnected = bluetoothConnection === BLUETOOTH_CONNECTION.CONNECTED;
47621
+ const isBluetoothConnected = bluetoothConnection === exports.BLUETOOTH_CONNECTION.CONNECTED;
47622
47622
  switch (streamingMode) {
47623
47623
  default:
47624
47624
  case STREAMING_MODE.WIFI_ONLY:
@@ -657,8 +657,8 @@ var r=require("./compare"),e=function(e,o,u){return r(e,o,u)>=0};module.exports=
657
657
  },{"rxjs":"Zr8e","rxjs/operators":"v3iE","../../../utils/pipes":"Oj1i"}],"fihV":[function(require,module,exports) {
658
658
  "use strict";function t(t,i){return n(t)||r(t,i)||e()}function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function r(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var r=[],n=!0,i=!1,s=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(u){i=!0,s=u}finally{try{n||null==o.return||o.return()}finally{if(i)throw s}}return r}}function n(t){if(Array.isArray(t))return t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}var o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,s){function a(t){try{u(n.next(t))}catch(e){s(e)}}function o(t){try{u(n.throw(t))}catch(e){s(e)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,o)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BluetoothClient=void 0;var u=require("rxjs"),c=require("rxjs"),h=require("rxjs/operators"),p=require("rxjs/operators"),d=require("./web/WebBluetoothTransport"),f=require("./react-native/ReactNativeTransport"),l=require("./utils/csvBufferToEpoch"),v=require("./types"),b=require("./utils/osHasBluetoothSupport"),w=function(){function e(t){var r=this;i(this,e),this.selectedDevice$=new c.ReplaySubject(1),this.isAuthenticated$=new c.ReplaySubject(1);var n=null!=t?t:{},s=n.transport,a=n.selectedDevice$,o=n.createBluetoothToken;if(!s)throw new Error("No bluetooth transport provided.");this.transport=s,a&&a.subscribe(this.selectedDevice$),this.transport._autoConnect(this.selectedDevice$).subscribe({error:function(t){var e;r.transport.addLog("Auto connect: error -> ".concat(null!==(e=null==t?void 0:t.message)&&void 0!==e?e:t))}}),"function"==typeof o?(this.transport.addLog("Auto authentication enabled"),this._autoAuthenticate(o).subscribe()):this.transport.addLog("Auto authentication not enabled"),this.transport._autoToggleActionNotifications(this.selectedDevice$),this._focus$=this._subscribeWhileAuthenticated("focus"),this._calm$=this._subscribeWhileAuthenticated("calm"),this._accelerometer$=this._subscribeWhileAuthenticated("accelerometer"),this._brainwavesRaw$=this._subscribeWhileAuthenticated("raw"),this._brainwavesRawUnfiltered$=this._subscribeWhileAuthenticated("rawUnfiltered"),this._brainwavesPSD$=this._subscribeWhileAuthenticated("psd"),this._brainwavesPowerByBand$=this._subscribeWhileAuthenticated("powerByBand"),this._signalQuality$=this._subscribeWhileAuthenticated("signalQuality"),this._status$=this._subscribeWhileAuthenticated("status"),this._settings$=this._subscribeWhileAuthenticated("settings"),this._wifiNearbyNetworks$=this._subscribeWhileAuthenticated("wifiNearbyNetworks"),this._wifiConnections$=this._subscribeWhileAuthenticated("wifiConnections")}return a(e,[{key:"_autoAuthenticate",value:function(e){var r=this,n=(0,u.timer)(0,36e5).pipe((0,h.tap)(function(){r.transport.addLog("Auto authentication in progress...")}));return this.selectedDevice$.pipe((0,h.switchMap)(function(i){return(0,b.osHasBluetoothSupport)(i)?r.connection().pipe((0,h.switchMap)(function(t){return t===v.BLUETOOTH_CONNECTION.CONNECTED?n:c.EMPTY}),(0,h.switchMap)(function(){return o(r,void 0,void 0,regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.isAuthenticated();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}))}),(0,h.tap)(function(n){var i=t(n,1)[0];return o(r,void 0,void 0,regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i){t.next=8;break}return t.next=3,e();case 3:return r=t.sent,t.next=6,this.authenticate(r);case 6:t.next=9;break;case 8:this.transport.addLog("Already authenticated");case 9:case"end":return t.stop()}},t,this)}))})):c.EMPTY}))}},{key:"enableAutoConnect",value:function(t){this.transport.enableAutoConnect(t)}},{key:"_hasBluetoothSupport",value:function(){return o(this,void 0,void 0,regeneratorRuntime.mark(function t(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,u.firstValueFrom)(this.selectedDevice$);case 2:return e=t.sent,t.abrupt("return",(0,b.osHasBluetoothSupport)(e));case 4:case"end":return t.stop()}},t,this)}))}},{key:"authenticate",value:function(e){return o(this,void 0,void 0,regeneratorRuntime.mark(function r(){var n,i,s,a;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._hasBluetoothSupport();case 2:if(r.sent){r.next=7;break}return n="authenticate method: The OS version does not support Bluetooth.",this.transport.addLog(n),r.abrupt("return",Promise.reject(n));case 7:return r.next=9,this.transport.writeCharacteristic("auth",e);case 9:return r.next=11,this.isAuthenticated();case 11:return i=r.sent,s=t(i,1),a=s[0],this.transport.addLog("Authentication ".concat(a?"succeeded":"failed")),this.isAuthenticated$.next(a),r.abrupt("return",i);case 16:case"end":return r.stop()}},r,this)}))}},{key:"isAuthenticated",value:function(){return o(this,void 0,void 0,regeneratorRuntime.mark(function e(){var r,n,i,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.transport.readCharacteristic("auth",!0);case 2:return r=e.sent,n=t(r,2),i=n[0],s=n[1],this.isAuthenticated$.next(i),e.abrupt("return",[i,s]);case 8:case"end":return e.stop()}},e,this)}))}},{key:"scan",value:function(t){if(this.transport instanceof f.ReactNativeTransport)return this.transport.scan(t);if(this.transport instanceof d.WebBluetoothTransport)throw new Error("scan method is compatibly with the React Native transport only");throw new Error("unknown transport")}},{key:"connect",value:function(t){return this.transport instanceof f.ReactNativeTransport?this.transport.connect(t):this.transport instanceof d.WebBluetoothTransport?t?this.transport.connect(t):this.transport.connect():void 0}},{key:"disconnect",value:function(){return this.transport.disconnect()}},{key:"connection",value:function(){return this.transport.connection()}},{key:"logs",value:function(){return this.transport.logs$.asObservable()}},{key:"getDeviceId",value:function(){return o(this,void 0,void 0,regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.transport.readCharacteristic("deviceId"));case 1:case"end":return t.stop()}},t,this)}))}},{key:"_withAuthentication",value:function(t){return o(this,void 0,void 0,regeneratorRuntime.mark(function e(){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._hasBluetoothSupport();case 2:if(e.sent){e.next=7;break}return r="The OS version does not support Bluetooth.",this.transport.addLog(r),e.abrupt("return",Promise.reject(r));case 7:return e.next=9,(0,u.firstValueFrom)(this.isAuthenticated$);case 9:if(e.sent){e.next=14;break}return"Authentication required.",this.transport.addLog("Authentication required."),e.abrupt("return",Promise.reject("Authentication required."));case 14:return e.next=16,t();case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}},e,this)}))}},{key:"_subscribeWhileAuthenticated",value:function(t){var e=this;return this.selectedDevice$.pipe((0,h.switchMap)(function(r){return(0,b.osHasBluetoothSupport)(r)?e.isAuthenticated$.pipe((0,p.distinctUntilChanged)(),(0,h.switchMap)(function(r){return r?e.transport.subscribeToCharacteristic({characteristicName:t}):c.EMPTY})):c.EMPTY}),(0,h.share)())}},{key:"focus",value:function(){return this._focus$}},{key:"calm",value:function(){return this._calm$}},{key:"accelerometer",value:function(){return this._accelerometer$}},{key:"brainwaves",value:function(t){var e=this;switch(t){default:case"raw":return(0,u.defer)(function(){return e.getInfo()}).pipe((0,h.switchMap)(function(t){return e._brainwavesRaw$.pipe((0,l.csvBufferToEpoch)(t))}));case"rawUnfiltered":return(0,u.defer)(function(){return e.getInfo()}).pipe((0,h.switchMap)(function(t){return e._brainwavesRawUnfiltered$.pipe((0,l.csvBufferToEpoch)(t))}));case"psd":return this._brainwavesPSD$;case"powerByBand":return this._brainwavesPowerByBand$}}},{key:"signalQuality",value:function(){return this._signalQuality$}},{key:"addMarker",value:function(t){return o(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.dispatchAction({action:"marker",command:"add",message:{timestamp:Date.now(),label:t}});case 2:case"end":return e.stop()}},e,this)}))}},{key:"getInfo",value:function(){return o(this,void 0,void 0,regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._withAuthentication(function(){return(0,u.firstValueFrom)(e.transport.subscribeToCharacteristic({characteristicName:"deviceInfo"}))});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}))}},{key:"status",value:function(){return this._status$}},{key:"dispatchAction",value:function(t){return o(this,void 0,void 0,regeneratorRuntime.mark(function e(){var r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._withAuthentication(function(){return r.transport.dispatchAction({characteristicName:"actions",action:t})});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"settings",value:function(){return this._settings$}},{key:"haptics",value:function(t){return this.dispatchAction({action:"haptics",command:"queue",responseRequired:!0,responseTimeout:4e3,message:{effects:t}})}},{key:"wifi",get:function(){var t=this;return{nearbyNetworks:function(){return t._wifiNearbyNetworks$},connections:function(){return t._wifiConnections$},connect:function(e,r){return e?t.dispatchAction({action:"wifi",command:"connect",responseRequired:!0,responseTimeout:12e4,message:{ssid:e,password:null!=r?r:null}}):Promise.reject("Missing ssid")},forgetConnection:function(e){return e?t.dispatchAction({action:"wifi",command:"forget-connection",responseRequired:!0,responseTimeout:15e3,message:{ssid:e}}):Promise.reject("Missing ssid")},reset:function(){return t.dispatchAction({action:"wifi",command:"reset",responseRequired:!0,responseTimeout:3e4,message:{respondOnSuccess:!0}})},speedTest:function(){return t.dispatchAction({action:"wifi",command:"speed-test",responseRequired:!0,responseTimeout:6e4})}}}}]),e}();exports.BluetoothClient=w;
659
659
  },{"rxjs":"Zr8e","rxjs/operators":"v3iE","./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/csvBufferToEpoch":"WTrV","./types":"iwtf","./utils/osHasBluetoothSupport":"rH2Y"}],"TICO":[function(require,module,exports) {
660
- "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||e(r,t,o)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./BluetoothClient"),exports),t(require("./web/WebBluetoothTransport"),exports),t(require("./react-native/ReactNativeTransport"),exports),t(require("./utils/osHasBluetoothSupport"),exports);
661
- },{"./BluetoothClient":"fihV","./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/osHasBluetoothSupport":"rH2Y"}],"BZP9":[function(require,module,exports) {
660
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var o in t)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||e(r,t,o)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./BluetoothClient"),exports),t(require("./web/WebBluetoothTransport"),exports),t(require("./react-native/ReactNativeTransport"),exports),t(require("./utils/osHasBluetoothSupport"),exports),t(require("./types/index"),exports);
661
+ },{"./BluetoothClient":"fihV","./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/osHasBluetoothSupport":"rH2Y","./types/index":"iwtf"}],"BZP9":[function(require,module,exports) {
662
662
  "use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(t,n){return!n||"object"!==e(n)&&"function"!=typeof n?r(t):n}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){return a(e)||s(e,t)||c()}function c(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function s(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,i=!1,o=void 0;try{for(var u,c=e[Symbol.iterator]();!(n=(u=c.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(s){i=!0,o=s}finally{try{n||null==c.return||c.return()}finally{if(i)throw o}}return r}}function a(e){if(Array.isArray(e))return e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),e}var f=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),m=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),v=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return m(t,e),t},p=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function u(e){try{s(n.next(e))}catch(t){o(t)}}function c(e){try{s(n.throw(e))}catch(t){o(t)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(u,c)}s((n=n.apply(e,t||[])).next())})},b=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Notion=exports.Neurosity=void 0;var g=require("rxjs"),C=require("rxjs"),y=require("rxjs/operators"),w=b(require("fast-deep-equal")),O=require("./api/index"),k=require("./api/index"),S=require("./types/streaming"),M=require("./utils/subscription"),_=require("./types/status"),x=v(require("./utils/errors")),E=v(require("./utils/platform")),T=v(require("./utils/hapticEffects")),A=require("./utils/oauth"),D=require("./utils/oauth"),N=require("./api/https/createOAuthURL"),I=require("./api/https/getOAuthToken"),R=require("./utils/is-node"),F=require("./utils/metrics"),P=require("./api/bluetooth"),j=require("./api/bluetooth/types"),L={timesync:!1,autoSelectDevice:!0,streamingMode:S.STREAMING_MODE.WIFI_ONLY,emulator:!1,emulatorHost:"localhost",emulatorAuthPort:9099,emulatorDatabasePort:9e3,emulatorFunctionsPort:5001,emulatorFirestorePort:8080,emulatorOptions:{}},U=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l(this,e),this.streamingMode$=new C.ReplaySubject(1);var r=t.streamingMode,n=t.bluetoothTransport;this.options=Object.freeze(Object.assign(Object.assign({},L),t)),this.cloudClient=new O.CloudClient(this.options),n&&(this.bluetoothClient=new P.BluetoothClient({selectedDevice$:this.onDeviceChange(),createBluetoothToken:this.createBluetoothToken.bind(this),transport:n})),this._initStreamingMode(r,!!n)}return d(e,[{key:"_initStreamingMode",value:function(e,t){var r=[S.STREAMING_MODE.BLUETOOTH_WITH_WIFI_FALLBACK,S.STREAMING_MODE.WIFI_WITH_BLUETOOTH_FALLBACK].includes(e),n=!Object.values(S.STREAMING_MODE).includes(e),i=r&&!t;this.isMissingBluetoothTransport=i,!e||n||i?this.streamingMode$.next(S.STREAMING_MODE.WIFI_ONLY):this.streamingMode$.next(e)}},{key:"streamingState",value:function(){var e=this,t=function(e){return[_.STATUS.ONLINE,_.STATUS.UPDATING].includes(e)};return this.streamingMode$.pipe((0,y.switchMap)(function(r){return e.isMissingBluetoothTransport?e.cloudClient.status().pipe((0,y.map)(function(e){var n=e.state;return{connected:t(n),streamingMode:r,activeMode:S.STREAMING_TYPE.WIFI}})):e.onDeviceChange().pipe((0,y.switchMap)(function(n){return n?(0,g.combineLatest)({wifiStatus:e.cloudClient.status(),bluetoothConnection:(null==e?void 0:e.bluetoothClient)?e.bluetoothClient.connection():(0,g.of)(j.BLUETOOTH_CONNECTION.DISCONNECTED)}).pipe((0,y.map)(function(e){var n=e.wifiStatus,i=e.bluetoothConnection===j.BLUETOOTH_CONNECTION.CONNECTED;switch(r){default:case S.STREAMING_MODE.WIFI_ONLY:return{connected:t(n.state),streamingMode:r,activeMode:S.STREAMING_TYPE.WIFI};case S.STREAMING_MODE.WIFI_WITH_BLUETOOTH_FALLBACK:return{connected:t(n.state)||!i?t(n.state):i,streamingMode:r,activeMode:t(n.state)||!i?S.STREAMING_TYPE.WIFI:S.STREAMING_TYPE.BLUETOOTH};case S.STREAMING_MODE.BLUETOOTH_WITH_WIFI_FALLBACK:return{connected:!!i||t(n.state),streamingMode:r,activeMode:i?S.STREAMING_TYPE.BLUETOOTH:S.STREAMING_TYPE.WIFI}}}),(0,y.distinctUntilChanged)(function(e,t){return(0,w.default)(e,t)})):C.EMPTY}))}))}},{key:"_withStreamingModeObservable",value:function(e){var t=e.wifi,r=e.bluetooth;return this.streamingState().pipe((0,y.switchMap)(function(e){switch(e.activeMode){case S.STREAMING_TYPE.WIFI:return t();case S.STREAMING_TYPE.BLUETOOTH:return r();default:return t()}}))}},{key:"_withStreamingModePromise",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){var r,n,i,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.wifi,n=e.bluetooth,t.next=3,(0,C.firstValueFrom)(this.streamingState());case 3:i=t.sent,o=i.activeMode,t.t0=o,t.next=t.t0===S.STREAMING_TYPE.WIFI?8:t.t0===S.STREAMING_TYPE.BLUETOOTH?11:14;break;case 8:return t.next=10,r();case 10:return t.abrupt("return",t.sent);case 11:return t.next=13,n();case 13:return t.abrupt("return",t.sent);case 14:return t.next=16,r();case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}},t,this)}))}},{key:"_getCloudMetricDependencies",value:function(){return{options:this.options,cloudClient:this.cloudClient,onDeviceChange:this.onDeviceChange.bind(this),status:this.status.bind(this)}}},{key:"login",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cloudClient.login(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}))}},{key:"logout",value:function(){return p(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.logout();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"__getApp",value:function(){return this.cloudClient.__getApp()}},{key:"onAuthStateChanged",value:function(){return this.cloudClient.onAuthStateChanged()}},{key:"addDevice",value:function(e){var t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"addDevice"),2),r=t[0],n=t[1];return r?Promise.reject(n):this.cloudClient.addDevice(e)}},{key:"removeDevice",value:function(e){var t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"removeDevice"),2),r=t[0],n=t[1];return r?Promise.reject(n):this.cloudClient.removeDevice(e)}},{key:"transferDevice",value:function(e){var t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"transferDevice"),2),r=t[0],n=t[1];return r?Promise.reject(n):this.cloudClient.transferDevice(e)}},{key:"onUserDevicesChange",value:function(){var e=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"onUserDevicesChange"),2),t=e[0],r=e[1];return t?(0,g.throwError)(function(){return r}):this.cloudClient.onUserDevicesChange()}},{key:"onUserClaimsChange",value:function(){return this.cloudClient.onUserClaimsChange()}},{key:"getDevices",value:function(){return p(this,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.getDevices();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"selectDevice",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){var r,n,i,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=(0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"selectDevice"),n=u(r,2),i=n[0],o=n[1],!i){t.next=3;break}return t.abrupt("return",Promise.reject(o));case 3:return t.next=5,this.cloudClient.selectDevice(e);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}},t,this)}))}},{key:"getSelectedDevice",value:function(){return p(this,void 0,void 0,regeneratorRuntime.mark(function e(){var t,r,n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=(0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"getSelectedDevice"),r=u(t,2),n=r[0],i=r[1],!n){e.next=3;break}return e.abrupt("return",Promise.reject(i));case 3:return e.next=5,this.cloudClient.getSelectedDevice();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e,this)}))}},{key:"getInfo",value:function(){return p(this,void 0,void 0,regeneratorRuntime.mark(function e(){var t,r,n,i,o=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.didSelectDevice();case 2:if(e.sent){e.next=4;break}return e.abrupt("return",Promise.reject(x.mustSelectDevice));case 4:if(t=(0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"getInfo"),r=u(t,2),n=r[0],i=r[1],!n){e.next=7;break}return e.abrupt("return",Promise.reject(i));case 7:return e.next=9,this._withStreamingModePromise({wifi:function(){return o.cloudClient.getInfo()},bluetooth:function(){return o.bluetoothClient.getInfo()}});case 9:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}},e,this)}))}},{key:"onDeviceChange",value:function(){var e=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"onDeviceChange"),2),t=e[0],r=e[1];return t?(0,g.throwError)(function(){return r}):this.cloudClient.onDeviceChange()}},{key:"disconnect",value:function(){return p(this,void 0,void 0,regeneratorRuntime.mark(function e(){var t=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._withStreamingModePromise({wifi:function(){return t.cloudClient.disconnect()},bluetooth:function(){return t.bluetoothClient.disconnect()}});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"dispatchAction",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){var r,n,i,o,c=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cloudClient.didSelectDevice();case 2:if(t.sent){t.next=4;break}return t.abrupt("return",Promise.reject(x.mustSelectDevice));case 4:if(r=(0,D.validateOAuthScopeForAction)(this.cloudClient.userClaims,e),n=u(r,2),i=n[0],o=n[1],!i){t.next=7;break}return t.abrupt("return",Promise.reject(o));case 7:return t.next=9,this._withStreamingModePromise({wifi:function(){return c.cloudClient.dispatchAction(e)},bluetooth:function(){return c.bluetoothClient.dispatchAction(e)}});case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}},t,this)}))}},{key:"addMarker",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){var r=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cloudClient.didSelectDevice();case 2:if(t.sent){t.next=4;break}throw x.mustSelectDevice;case 4:if(e){t.next=6;break}throw new Error("".concat(x.prefix,"A label is required for addMarker"));case 6:return t.next=8,this._withStreamingModePromise({wifi:function(){return r.cloudClient.dispatchAction({command:"marker",action:"add",message:{label:e,timestamp:r.cloudClient.timestamp}})},bluetooth:function(){return r.bluetoothClient.addMarker(e)}});case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}},t,this)}))}},{key:"haptics",value:function(e){var t;return p(this,void 0,void 0,regeneratorRuntime.mark(function r(){var n,i,o,u,c,s,a=this;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n="haptics",r.next=3,this.cloudClient.didSelectDevice();case 3:if(r.sent){r.next=5;break}return r.abrupt("return",Promise.reject(x.mustSelectDevice));case 5:return r.next=7,this.getSelectedDevice();case 7:if(r.t1=t=r.sent,r.t0=null===r.t1,r.t0){r.next=11;break}r.t0=void 0===t;case 11:if(!r.t0){r.next=15;break}r.t2=void 0,r.next=16;break;case 15:r.t2=t.modelVersion;case 16:if(i=r.t2,E.supportsHaptics(i)){r.next=20;break}return r.abrupt("return",Promise.reject(x.metricNotSupportedByModel(n,i)));case 20:o=E.getPlatformHapticMotors(i),r.t3=regeneratorRuntime.keys(e);case 22:if((r.t4=r.t3()).done){r.next=33;break}if(u=r.t4.value,Object.keys(o).includes(u)){r.next=26;break}return r.abrupt("return",Promise.reject(x.locationNotFound(u,i)));case 26:if(c=e[u],7,!(c.length>7)){r.next=30;break}return r.abrupt("return",Promise.reject(x.exceededMaxItems(7)));case 30:o[u]=c,r.next=22;break;case 33:return s={command:n,action:"queue",responseRequired:!0,responseTimeout:1e3,message:{effects:o}},r.next=36,this._withStreamingModePromise({wifi:function(){return a.cloudClient.dispatchAction(s)},bluetooth:function(){return a.bluetoothClient.dispatchAction(s)}});case 36:return r.abrupt("return",r.sent);case 37:case"end":return r.stop()}},r,this)}))}},{key:"getHapticEffects",value:function(){return T}},{key:"accelerometer",value:function(){var e=this,t="accelerometer",r=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,t),2),n=r[0],i=r[1];return n?(0,g.throwError)(function(){return i}):this.onDeviceChange().pipe((0,y.switchMap)(function(r){var n=(null==r?void 0:r.modelVersion)||E.MODEL_VERSION_1;return E.supportsAccel(n)?e._withStreamingModeObservable({wifi:function(){return(0,F.getCloudMetric)(e._getCloudMetricDependencies(),{metric:t,labels:(0,M.getLabels)(t),atomic:!0})},bluetooth:function(){return e.bluetoothClient.accelerometer()}}):(0,g.throwError)(function(){return x.metricNotSupportedByModel(t,n)})}))}},{key:"brainwaves",value:function(e){var t=this,r=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"brainwaves"),2),n=r[0],i=r[1];return n?(0,g.throwError)(function(){return i}):this._withStreamingModeObservable({wifi:function(){return(0,F.getCloudMetric)(t._getCloudMetricDependencies(),{metric:"brainwaves",labels:e?[e]:[],atomic:!1})},bluetooth:function(){return t.bluetoothClient.brainwaves(e)}})}},{key:"calm",value:function(){var e=this,t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"calm"),2),r=t[0],n=t[1];return r?(0,g.throwError)(function(){return n}):this._withStreamingModeObservable({wifi:function(){return(0,F.getCloudMetric)(e._getCloudMetricDependencies(),{metric:"awareness",labels:["calm"],atomic:!1})},bluetooth:function(){return e.bluetoothClient.calm()}})}},{key:"signalQuality",value:function(){var e=this,t="signalQuality",r=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,t),2),n=r[0],i=r[1];return n?(0,g.throwError)(function(){return i}):this._withStreamingModeObservable({wifi:function(){return(0,F.getCloudMetric)(e._getCloudMetricDependencies(),{metric:t,labels:(0,M.getLabels)(t),atomic:!0})},bluetooth:function(){return e.bluetoothClient.signalQuality()}})}},{key:"settings",value:function(){var e=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"settings"),2),t=e[0],r=e[1];return t?(0,g.throwError)(function(){return r}):this.cloudClient.observeNamespace("settings")}},{key:"focus",value:function(){var e=this,t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"focus"),2),r=t[0],n=t[1];return r?(0,g.throwError)(function(){return n}):this._withStreamingModeObservable({wifi:function(){return(0,F.getCloudMetric)(e._getCloudMetricDependencies(),{metric:"awareness",labels:["focus"],atomic:!1})},bluetooth:function(){return e.bluetoothClient.focus()}})}},{key:"kinesis",value:function(e){var t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"kinesis"),2),r=t[0],n=t[1];return r?(0,g.throwError)(function(){return n}):(0,F.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"kinesis",labels:e?[e]:[],atomic:!1})}},{key:"predictions",value:function(e){var t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"predictions"),2),r=t[0],n=t[1];return r?(0,g.throwError)(function(){return n}):(0,F.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"predictions",labels:e?[e]:[],atomic:!1})}},{key:"status",value:function(){var e=this,t=u((0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"status"),2),r=t[0],n=t[1];return r?(0,g.throwError)(function(){return n}):this._withStreamingModeObservable({wifi:function(){return e.cloudClient.status()},bluetooth:function(){return e.bluetoothClient.status()}})}},{key:"changeSettings",value:function(e){return p(this,void 0,void 0,regeneratorRuntime.mark(function t(){var r,n,i,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cloudClient.didSelectDevice();case 2:if(t.sent){t.next=4;break}return t.abrupt("return",Promise.reject(x.mustSelectDevice));case 4:if(r=(0,A.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"changeSettings"),n=u(r,2),i=n[0],o=n[1],!i){t.next=7;break}return t.abrupt("return",Promise.reject(o));case 7:return t.next=9,this.cloudClient.changeSettings(e);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}},t,this)}))}},{key:"goOffline",value:function(){this.cloudClient.goOffline()}},{key:"goOnline",value:function(){this.cloudClient.goOnline()}},{key:"createAccount",value:function(e){return this.cloudClient.createAccount(e)}},{key:"deleteAccount",value:function(){return this.cloudClient.deleteAccount()}},{key:"createBluetoothToken",value:function(){return this.cloudClient.createBluetoothToken()}},{key:"createCustomToken",value:function(){return this.cloudClient.createCustomToken()}},{key:"getTimesyncOffset",value:function(){return this.options.timesync||console.warn("getTimesyncOffset() requires options.timesync to be true."),this.options.timesync?this.cloudClient.getTimesyncOffset():0}},{key:"createOAuthURL",value:function(e){return R.isNode?(0,N.createOAuthURL)(e,this.options):Promise.reject(new Error("".concat(x.prefix,"the createOAuthURL method must be used on the server side (node.js) for security reasons.")))}},{key:"getOAuthToken",value:function(e){return R.isNode?(0,I.getOAuthToken)(e,this.options):Promise.reject(new Error("".concat(x.prefix,"the getOAuthToken method must be used on the server side (node.js) for security reasons.")))}},{key:"removeOAuthAccess",value:function(){return this.cloudClient.removeOAuthAccess()}},{key:"onUserExperiments",value:function(){return this.cloudClient.onUserExperiments()}},{key:"deleteUserExperiment",value:function(e){return this.cloudClient.deleteUserExperiment(e)}},{key:"bluetooth",get:function(){return null==this?void 0:this.bluetoothClient}},{key:"training",get:function(){var e=this;return{record:function(t){return p(e,void 0,void 0,regeneratorRuntime.mark(function e(){var r,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.didSelectDevice();case 2:if(e.sent){e.next=4;break}throw x.mustSelectDevice;case 4:return r=this.cloudClient.user&&"uid"in this.cloudClient.user?this.cloudClient.user.uid:null,n=Object.assign(Object.assign({fit:!1,baseline:!1,timestamp:this.cloudClient.timestamp},t),{userId:r}),e.next=8,this.cloudClient.actions.dispatch({command:"training",action:"record",message:n});case 8:case"end":return e.stop()}},e,this)}))},stop:function(t){return p(e,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.didSelectDevice();case 2:if(e.sent){e.next=4;break}throw x.mustSelectDevice;case 4:return e.next=6,this.cloudClient.actions.dispatch({command:"training",action:"stop",message:Object.assign({},t)});case 6:case"end":return e.stop()}},e,this)}))},stopAll:function(){return p(e,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cloudClient.didSelectDevice();case 2:if(e.sent){e.next=4;break}throw x.mustSelectDevice;case 4:return e.next=6,this.cloudClient.actions.dispatch({command:"training",action:"stopAll",message:{}});case 6:case"end":return e.stop()}},e,this)}))}}}}]),e}();exports.Neurosity=U,U.credentialWithLink=k.credentialWithLink,U.createUser=O.createUser,U.SERVER_TIMESTAMP=k.SERVER_TIMESTAMP;var q=function(e){function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l(this,r),e=t(this,n(r).call(this,i)),console.log("The Notion class is deprecated and will be removed in the next version of the SDK. Please use the Neurosity class instead. e.g. new Notion() => new Neurosity()"),e}return i(r,U),r}();exports.Notion=q;
663
663
  },{"rxjs":"Zr8e","rxjs/operators":"v3iE","fast-deep-equal":"jIGR","./api/index":"LXvB","./types/streaming":"rekm","./utils/subscription":"yLLB","./types/status":"Ttuy","./utils/errors":"WDyG","./utils/platform":"wAkn","./utils/hapticEffects":"lLai","./utils/oauth":"xIH5","./api/https/createOAuthURL":"MDrB","./api/https/getOAuthToken":"nfg4","./utils/is-node":"vsps","./utils/metrics":"DCuD","./api/bluetooth":"TICO","./api/bluetooth/types":"iwtf"}],"QCba":[function(require,module,exports) {
664
664
  "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&("get"in o?t.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(r,i)||e(r,t,i)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./Neurosity"),exports),t(require("./api/bluetooth"),exports);