@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.
- package/dist/browser/neurosity.iife.js +29 -29
- package/dist/browser/neurosity.js +2 -2
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/api/bluetooth/index.d.ts +1 -0
- package/dist/cjs/api/bluetooth/index.js +1 -0
- package/dist/electron/index.js +2 -2
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/api/bluetooth/index.d.ts +1 -0
- package/dist/esm/api/bluetooth/index.js +1 -0
- package/dist/esm/neurosity.mjs +1 -1
- package/dist/examples/neurosity.iife.js +29 -29
- package/dist/examples/neurosity.js +2 -2
- package/dist/examples/neurosity.mjs +1 -1
- package/package.json +1 -1
|
@@ -18,3 +18,4 @@ __exportStar(require("./BluetoothClient"), exports);
|
|
|
18
18
|
__exportStar(require("./web/WebBluetoothTransport"), exports);
|
|
19
19
|
__exportStar(require("./react-native/ReactNativeTransport"), exports);
|
|
20
20
|
__exportStar(require("./utils/osHasBluetoothSupport"), exports);
|
|
21
|
+
__exportStar(require("./types/index"), exports);
|
package/dist/electron/index.js
CHANGED
|
@@ -77,8 +77,8 @@ process.env.HMR_PORT=0;process.env.HMR_HOSTNAME="localhost";parcelRequire=functi
|
|
|
77
77
|
},{"../../../utils/pipes":"Oj1i"}],"fihV":[function(require,module,exports) {
|
|
78
78
|
"use strict";var t=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(r,n){function o(t){try{c(s.next(t))}catch(e){n(e)}}function a(t){try{c(s.throw(t))}catch(e){n(e)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}c((s=s.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BluetoothClient=void 0;const e=require("rxjs"),i=require("rxjs"),s=require("rxjs/operators"),r=require("rxjs/operators"),n=require("./web/WebBluetoothTransport"),o=require("./react-native/ReactNativeTransport"),a=require("./utils/csvBufferToEpoch"),c=require("./types"),h=require("./utils/osHasBluetoothSupport");class u{constructor(t){this.selectedDevice$=new i.ReplaySubject(1),this.isAuthenticated$=new i.ReplaySubject(1);const{transport:e,selectedDevice$:s,createBluetoothToken:r}=null!=t?t:{};if(!e)throw new Error("No bluetooth transport provided.");this.transport=e,s&&s.subscribe(this.selectedDevice$),this.transport._autoConnect(this.selectedDevice$).subscribe({error:t=>{var e;this.transport.addLog(`Auto connect: error -> ${null!==(e=null==t?void 0:t.message)&&void 0!==e?e:t}`)}}),"function"==typeof r?(this.transport.addLog("Auto authentication enabled"),this._autoAuthenticate(r).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")}_autoAuthenticate(r){const n=(0,e.timer)(0,36e5).pipe((0,s.tap)(()=>{this.transport.addLog("Auto authentication in progress...")}));return this.selectedDevice$.pipe((0,s.switchMap)(e=>(0,h.osHasBluetoothSupport)(e)?this.connection().pipe((0,s.switchMap)(t=>t===c.BLUETOOTH_CONNECTION.CONNECTED?n:i.EMPTY),(0,s.switchMap)(()=>t(this,void 0,void 0,function*(){return yield this.isAuthenticated()})),(0,s.tap)(([e])=>t(this,void 0,void 0,function*(){if(e)this.transport.addLog("Already authenticated");else{const t=yield r();yield this.authenticate(t)}}))):i.EMPTY))}enableAutoConnect(t){this.transport.enableAutoConnect(t)}_hasBluetoothSupport(){return t(this,void 0,void 0,function*(){const t=yield(0,e.firstValueFrom)(this.selectedDevice$);return(0,h.osHasBluetoothSupport)(t)})}authenticate(e){return t(this,void 0,void 0,function*(){if(!(yield this._hasBluetoothSupport())){const t="authenticate method: The OS version does not support Bluetooth.";return this.transport.addLog(t),Promise.reject(t)}yield this.transport.writeCharacteristic("auth",e);const t=yield this.isAuthenticated(),[i]=t;return this.transport.addLog(`Authentication ${i?"succeeded":"failed"}`),this.isAuthenticated$.next(i),t})}isAuthenticated(){return t(this,void 0,void 0,function*(){const[t,e]=yield this.transport.readCharacteristic("auth",!0);return this.isAuthenticated$.next(t),[t,e]})}scan(t){if(this.transport instanceof o.ReactNativeTransport)return this.transport.scan(t);if(this.transport instanceof n.WebBluetoothTransport)throw new Error("scan method is compatibly with the React Native transport only");throw new Error("unknown transport")}connect(t){return this.transport instanceof o.ReactNativeTransport?this.transport.connect(t):this.transport instanceof n.WebBluetoothTransport?t?this.transport.connect(t):this.transport.connect():void 0}disconnect(){return this.transport.disconnect()}connection(){return this.transport.connection()}logs(){return this.transport.logs$.asObservable()}getDeviceId(){return t(this,void 0,void 0,function*(){return this.transport.readCharacteristic("deviceId")})}_withAuthentication(i){return t(this,void 0,void 0,function*(){if(!(yield this._hasBluetoothSupport())){const t="The OS version does not support Bluetooth.";return this.transport.addLog(t),Promise.reject(t)}if(!(yield(0,e.firstValueFrom)(this.isAuthenticated$))){const t="Authentication required.";return this.transport.addLog(t),Promise.reject(t)}return yield i()})}_subscribeWhileAuthenticated(t){return this.selectedDevice$.pipe((0,s.switchMap)(e=>(0,h.osHasBluetoothSupport)(e)?this.isAuthenticated$.pipe((0,r.distinctUntilChanged)(),(0,s.switchMap)(e=>e?this.transport.subscribeToCharacteristic({characteristicName:t}):i.EMPTY)):i.EMPTY),(0,s.share)())}focus(){return this._focus$}calm(){return this._calm$}accelerometer(){return this._accelerometer$}brainwaves(t){switch(t){default:case"raw":return(0,e.defer)(()=>this.getInfo()).pipe((0,s.switchMap)(t=>this._brainwavesRaw$.pipe((0,a.csvBufferToEpoch)(t))));case"rawUnfiltered":return(0,e.defer)(()=>this.getInfo()).pipe((0,s.switchMap)(t=>this._brainwavesRawUnfiltered$.pipe((0,a.csvBufferToEpoch)(t))));case"psd":return this._brainwavesPSD$;case"powerByBand":return this._brainwavesPowerByBand$}}signalQuality(){return this._signalQuality$}addMarker(e){return t(this,void 0,void 0,function*(){yield this.dispatchAction({action:"marker",command:"add",message:{timestamp:Date.now(),label:e}})})}getInfo(){return t(this,void 0,void 0,function*(){return yield this._withAuthentication(()=>(0,e.firstValueFrom)(this.transport.subscribeToCharacteristic({characteristicName:"deviceInfo"})))})}status(){return this._status$}dispatchAction(e){return t(this,void 0,void 0,function*(){return yield this._withAuthentication(()=>this.transport.dispatchAction({characteristicName:"actions",action:e}))})}settings(){return this._settings$}haptics(t){return this.dispatchAction({action:"haptics",command:"queue",responseRequired:!0,responseTimeout:4e3,message:{effects:t}})}get wifi(){return{nearbyNetworks:()=>this._wifiNearbyNetworks$,connections:()=>this._wifiConnections$,connect:(t,e)=>t?this.dispatchAction({action:"wifi",command:"connect",responseRequired:!0,responseTimeout:12e4,message:{ssid:t,password:null!=e?e:null}}):Promise.reject("Missing ssid"),forgetConnection:t=>t?this.dispatchAction({action:"wifi",command:"forget-connection",responseRequired:!0,responseTimeout:15e3,message:{ssid:t}}):Promise.reject("Missing ssid"),reset:()=>this.dispatchAction({action:"wifi",command:"reset",responseRequired:!0,responseTimeout:3e4,message:{respondOnSuccess:!0}}),speedTest:()=>this.dispatchAction({action:"wifi",command:"speed-test",responseRequired:!0,responseTimeout:6e4})}}}exports.BluetoothClient=u;
|
|
79
79
|
},{"./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/csvBufferToEpoch":"WTrV","./types":"iwtf","./utils/osHasBluetoothSupport":"rH2Y"}],"TICO":[function(require,module,exports) {
|
|
80
|
-
"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);
|
|
81
|
-
},{"./BluetoothClient":"fihV","./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/osHasBluetoothSupport":"rH2Y"}],"BZP9":[function(require,module,exports) {
|
|
80
|
+
"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);
|
|
81
|
+
},{"./BluetoothClient":"fihV","./web/WebBluetoothTransport":"ouKb","./react-native/ReactNativeTransport":"FtS5","./utils/osHasBluetoothSupport":"rH2Y","./types/index":"iwtf"}],"BZP9":[function(require,module,exports) {
|
|
82
82
|
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&("get"in s?t.__esModule:!s.writable&&!s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,o,s)}:function(e,t,i,o){void 0===o&&(o=i),e[o]=t[i]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(i){if(i&&i.__esModule)return i;var o={};if(null!=i)for(var s in i)"default"!==s&&Object.prototype.hasOwnProperty.call(i,s)&&e(o,i,s);return t(o,i),o},o=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))(function(s,n){function r(e){try{l(o.next(e))}catch(t){n(t)}}function c(e){try{l(o.throw(e))}catch(t){n(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,c)}l((o=o.apply(e,t||[])).next())})},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Notion=exports.Neurosity=void 0;const n=require("rxjs"),r=require("rxjs"),c=require("rxjs/operators"),l=s(require("fast-deep-equal")),u=require("./api/index"),a=require("./api/index"),d=require("./types/streaming"),h=require("./utils/subscription"),m=require("./types/status"),C=i(require("./utils/errors")),p=i(require("./utils/platform")),v=i(require("./utils/hapticEffects")),g=require("./utils/oauth"),f=require("./utils/oauth"),O=require("./api/https/createOAuthURL"),S=require("./api/https/getOAuthToken"),M=require("./utils/is-node"),b=require("./utils/metrics"),T=require("./api/bluetooth"),_=require("./api/bluetooth/types"),E={timesync:!1,autoSelectDevice:!0,streamingMode:d.STREAMING_MODE.WIFI_ONLY,emulator:!1,emulatorHost:"localhost",emulatorAuthPort:9099,emulatorDatabasePort:9e3,emulatorFunctionsPort:5001,emulatorFirestorePort:8080,emulatorOptions:{}};class A{constructor(e={}){this.streamingMode$=new r.ReplaySubject(1);const{streamingMode:t,bluetoothTransport:i}=e;this.options=Object.freeze(Object.assign(Object.assign({},E),e)),this.cloudClient=new u.CloudClient(this.options),i&&(this.bluetoothClient=new T.BluetoothClient({selectedDevice$:this.onDeviceChange(),createBluetoothToken:this.createBluetoothToken.bind(this),transport:i})),this._initStreamingMode(t,!!i)}_initStreamingMode(e,t){const i=[d.STREAMING_MODE.BLUETOOTH_WITH_WIFI_FALLBACK,d.STREAMING_MODE.WIFI_WITH_BLUETOOTH_FALLBACK].includes(e),o=!Object.values(d.STREAMING_MODE).includes(e),s=i&&!t;this.isMissingBluetoothTransport=s,!e||o||s?this.streamingMode$.next(d.STREAMING_MODE.WIFI_ONLY):this.streamingMode$.next(e)}streamingState(){const e=e=>[m.STATUS.ONLINE,m.STATUS.UPDATING].includes(e);return this.streamingMode$.pipe((0,c.switchMap)(t=>this.isMissingBluetoothTransport?this.cloudClient.status().pipe((0,c.map)(({state:i})=>({connected:e(i),streamingMode:t,activeMode:d.STREAMING_TYPE.WIFI}))):this.onDeviceChange().pipe((0,c.switchMap)(i=>i?(0,n.combineLatest)({wifiStatus:this.cloudClient.status(),bluetoothConnection:(null==this?void 0:this.bluetoothClient)?this.bluetoothClient.connection():(0,n.of)(_.BLUETOOTH_CONNECTION.DISCONNECTED)}).pipe((0,c.map)(({wifiStatus:i,bluetoothConnection:o})=>{const s=o===_.BLUETOOTH_CONNECTION.CONNECTED;switch(t){default:case d.STREAMING_MODE.WIFI_ONLY:return{connected:e(i.state),streamingMode:t,activeMode:d.STREAMING_TYPE.WIFI};case d.STREAMING_MODE.WIFI_WITH_BLUETOOTH_FALLBACK:return{connected:e(i.state)||!s?e(i.state):s,streamingMode:t,activeMode:e(i.state)||!s?d.STREAMING_TYPE.WIFI:d.STREAMING_TYPE.BLUETOOTH};case d.STREAMING_MODE.BLUETOOTH_WITH_WIFI_FALLBACK:return{connected:!!s||e(i.state),streamingMode:t,activeMode:s?d.STREAMING_TYPE.BLUETOOTH:d.STREAMING_TYPE.WIFI}}}),(0,c.distinctUntilChanged)((e,t)=>(0,l.default)(e,t))):r.EMPTY))))}_withStreamingModeObservable(e){const{wifi:t,bluetooth:i}=e;return this.streamingState().pipe((0,c.switchMap)(({activeMode:e})=>{switch(e){case d.STREAMING_TYPE.WIFI:return t();case d.STREAMING_TYPE.BLUETOOTH:return i();default:return t()}}))}_withStreamingModePromise(e){return o(this,void 0,void 0,function*(){const{wifi:t,bluetooth:i}=e,{activeMode:o}=yield(0,r.firstValueFrom)(this.streamingState());switch(o){case d.STREAMING_TYPE.WIFI:return yield t();case d.STREAMING_TYPE.BLUETOOTH:return yield i();default:return yield t()}})}get bluetooth(){return null==this?void 0:this.bluetoothClient}_getCloudMetricDependencies(){return{options:this.options,cloudClient:this.cloudClient,onDeviceChange:this.onDeviceChange.bind(this),status:this.status.bind(this)}}login(e){return o(this,void 0,void 0,function*(){return yield this.cloudClient.login(e)})}logout(){return o(this,void 0,void 0,function*(){return yield this.cloudClient.logout()})}__getApp(){return this.cloudClient.__getApp()}onAuthStateChanged(){return this.cloudClient.onAuthStateChanged()}addDevice(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"addDevice");return t?Promise.reject(i):this.cloudClient.addDevice(e)}removeDevice(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"removeDevice");return t?Promise.reject(i):this.cloudClient.removeDevice(e)}transferDevice(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"transferDevice");return t?Promise.reject(i):this.cloudClient.transferDevice(e)}onUserDevicesChange(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"onUserDevicesChange");return e?(0,n.throwError)(()=>t):this.cloudClient.onUserDevicesChange()}onUserClaimsChange(){return this.cloudClient.onUserClaimsChange()}getDevices(){return o(this,void 0,void 0,function*(){return yield this.cloudClient.getDevices()})}selectDevice(e){return o(this,void 0,void 0,function*(){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"selectDevice");return t?Promise.reject(i):yield this.cloudClient.selectDevice(e)})}getSelectedDevice(){return o(this,void 0,void 0,function*(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"getSelectedDevice");return e?Promise.reject(t):yield this.cloudClient.getSelectedDevice()})}getInfo(){return o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))return Promise.reject(C.mustSelectDevice);const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"getInfo");return e?Promise.reject(t):yield this._withStreamingModePromise({wifi:()=>this.cloudClient.getInfo(),bluetooth:()=>this.bluetoothClient.getInfo()})})}onDeviceChange(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"onDeviceChange");return e?(0,n.throwError)(()=>t):this.cloudClient.onDeviceChange()}disconnect(){return o(this,void 0,void 0,function*(){return yield this._withStreamingModePromise({wifi:()=>this.cloudClient.disconnect(),bluetooth:()=>this.bluetoothClient.disconnect()})})}dispatchAction(e){return o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))return Promise.reject(C.mustSelectDevice);const[t,i]=(0,f.validateOAuthScopeForAction)(this.cloudClient.userClaims,e);return t?Promise.reject(i):yield this._withStreamingModePromise({wifi:()=>this.cloudClient.dispatchAction(e),bluetooth:()=>this.bluetoothClient.dispatchAction(e)})})}addMarker(e){return o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))throw C.mustSelectDevice;if(!e)throw new Error(`${C.prefix}A label is required for addMarker`);return yield this._withStreamingModePromise({wifi:()=>this.cloudClient.dispatchAction({command:"marker",action:"add",message:{label:e,timestamp:this.cloudClient.timestamp}}),bluetooth:()=>this.bluetoothClient.addMarker(e)})})}haptics(e){var t;return o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))return Promise.reject(C.mustSelectDevice);const i=null===(t=yield this.getSelectedDevice())||void 0===t?void 0:t.modelVersion;if(!p.supportsHaptics(i))return Promise.reject(C.metricNotSupportedByModel("haptics",i));const o=p.getPlatformHapticMotors(i);for(const t in e){if(!Object.keys(o).includes(t))return Promise.reject(C.locationNotFound(t,i));const s=e[t],n=7;if(s.length>n)return Promise.reject(C.exceededMaxItems(n));o[t]=s}const s={command:"haptics",action:"queue",responseRequired:!0,responseTimeout:1e3,message:{effects:o}};return yield this._withStreamingModePromise({wifi:()=>this.cloudClient.dispatchAction(s),bluetooth:()=>this.bluetoothClient.dispatchAction(s)})})}getHapticEffects(){return v}accelerometer(){const e="accelerometer",[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,e);return t?(0,n.throwError)(()=>i):this.onDeviceChange().pipe((0,c.switchMap)(t=>{const i=(null==t?void 0:t.modelVersion)||p.MODEL_VERSION_1;return p.supportsAccel(i)?this._withStreamingModeObservable({wifi:()=>(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:e,labels:(0,h.getLabels)(e),atomic:!0}),bluetooth:()=>this.bluetoothClient.accelerometer()}):(0,n.throwError)(()=>C.metricNotSupportedByModel(e,i))}))}brainwaves(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"brainwaves");return t?(0,n.throwError)(()=>i):this._withStreamingModeObservable({wifi:()=>(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"brainwaves",labels:e?[e]:[],atomic:!1}),bluetooth:()=>this.bluetoothClient.brainwaves(e)})}calm(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"calm");return e?(0,n.throwError)(()=>t):this._withStreamingModeObservable({wifi:()=>(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"awareness",labels:["calm"],atomic:!1}),bluetooth:()=>this.bluetoothClient.calm()})}signalQuality(){const e="signalQuality",[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,e);return t?(0,n.throwError)(()=>i):this._withStreamingModeObservable({wifi:()=>(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:e,labels:(0,h.getLabels)(e),atomic:!0}),bluetooth:()=>this.bluetoothClient.signalQuality()})}settings(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"settings");return e?(0,n.throwError)(()=>t):this.cloudClient.observeNamespace("settings")}focus(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"focus");return e?(0,n.throwError)(()=>t):this._withStreamingModeObservable({wifi:()=>(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"awareness",labels:["focus"],atomic:!1}),bluetooth:()=>this.bluetoothClient.focus()})}kinesis(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"kinesis");return t?(0,n.throwError)(()=>i):(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"kinesis",labels:e?[e]:[],atomic:!1})}predictions(e){const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"predictions");return t?(0,n.throwError)(()=>i):(0,b.getCloudMetric)(this._getCloudMetricDependencies(),{metric:"predictions",labels:e?[e]:[],atomic:!1})}status(){const[e,t]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"status");return e?(0,n.throwError)(()=>t):this._withStreamingModeObservable({wifi:()=>this.cloudClient.status(),bluetooth:()=>this.bluetoothClient.status()})}changeSettings(e){return o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))return Promise.reject(C.mustSelectDevice);const[t,i]=(0,g.validateOAuthScopeForFunctionName)(this.cloudClient.userClaims,"changeSettings");return t?Promise.reject(i):yield this.cloudClient.changeSettings(e)})}get training(){return{record:e=>o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))throw C.mustSelectDevice;const t=this.cloudClient.user&&"uid"in this.cloudClient.user?this.cloudClient.user.uid:null,i=Object.assign(Object.assign({fit:!1,baseline:!1,timestamp:this.cloudClient.timestamp},e),{userId:t});yield this.cloudClient.actions.dispatch({command:"training",action:"record",message:i})}),stop:e=>o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))throw C.mustSelectDevice;yield this.cloudClient.actions.dispatch({command:"training",action:"stop",message:Object.assign({},e)})}),stopAll:()=>o(this,void 0,void 0,function*(){if(!(yield this.cloudClient.didSelectDevice()))throw C.mustSelectDevice;yield this.cloudClient.actions.dispatch({command:"training",action:"stopAll",message:{}})})}}goOffline(){this.cloudClient.goOffline()}goOnline(){this.cloudClient.goOnline()}createAccount(e){return this.cloudClient.createAccount(e)}deleteAccount(){return this.cloudClient.deleteAccount()}createBluetoothToken(){return this.cloudClient.createBluetoothToken()}createCustomToken(){return this.cloudClient.createCustomToken()}getTimesyncOffset(){return this.options.timesync||console.warn("getTimesyncOffset() requires options.timesync to be true."),this.options.timesync?this.cloudClient.getTimesyncOffset():0}createOAuthURL(e){return M.isNode?(0,O.createOAuthURL)(e,this.options):Promise.reject(new Error(`${C.prefix}the createOAuthURL method must be used on the server side (node.js) for security reasons.`))}getOAuthToken(e){return M.isNode?(0,S.getOAuthToken)(e,this.options):Promise.reject(new Error(`${C.prefix}the getOAuthToken method must be used on the server side (node.js) for security reasons.`))}removeOAuthAccess(){return this.cloudClient.removeOAuthAccess()}onUserExperiments(){return this.cloudClient.onUserExperiments()}deleteUserExperiment(e){return this.cloudClient.deleteUserExperiment(e)}}exports.Neurosity=A,A.credentialWithLink=a.credentialWithLink,A.createUser=u.createUser,A.SERVER_TIMESTAMP=a.SERVER_TIMESTAMP;class w extends A{constructor(e={}){super(e),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()")}}exports.Notion=w;
|
|
83
83
|
},{"./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) {
|
|
84
84
|
"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);
|