@neurosity/sdk 6.3.0 → 6.4.0-next.0
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 +61 -18
- package/dist/browser/neurosity.js +6 -6
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/Neurosity.js +5 -3
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +3 -1
- package/dist/cjs/api/bluetooth/BluetoothClient.js +9 -5
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +2 -2
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +3 -3
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +6 -4
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -2
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +4 -2
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +3 -3
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +8 -4
- package/dist/cjs/api/index.d.ts +3 -1
- package/dist/cjs/api/index.js +4 -0
- package/dist/electron/index.js +6 -6
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/Neurosity.js +5 -3
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +3 -1
- package/dist/esm/api/bluetooth/BluetoothClient.js +10 -6
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +2 -2
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +3 -3
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +7 -5
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -2
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +4 -2
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +3 -3
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +9 -5
- package/dist/esm/api/index.d.ts +3 -1
- package/dist/esm/api/index.js +4 -0
- package/dist/esm/neurosity.mjs +61 -18
- package/dist/examples/neurosity.iife.js +61 -18
- package/dist/examples/neurosity.js +6 -6
- package/dist/examples/neurosity.mjs +61 -18
- package/package.json +1 -1
|
@@ -2307,6 +2307,11 @@ var Neurosity = (function (exports) {
|
|
|
2307
2307
|
|
|
2308
2308
|
var NEVER = new Observable(noop);
|
|
2309
2309
|
|
|
2310
|
+
var isArray$2 = Array.isArray;
|
|
2311
|
+
function argsOrArgArray(args) {
|
|
2312
|
+
return args.length === 1 && isArray$2(args[0]) ? args[0] : args;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2310
2315
|
function filter(predicate, thisArg) {
|
|
2311
2316
|
return operate(function (source, subscriber) {
|
|
2312
2317
|
var index = 0;
|
|
@@ -2435,6 +2440,27 @@ var Neurosity = (function (exports) {
|
|
|
2435
2440
|
};
|
|
2436
2441
|
}
|
|
2437
2442
|
|
|
2443
|
+
function combineLatest$1() {
|
|
2444
|
+
var args = [];
|
|
2445
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2446
|
+
args[_i] = arguments[_i];
|
|
2447
|
+
}
|
|
2448
|
+
var resultSelector = popResultSelector(args);
|
|
2449
|
+
return resultSelector
|
|
2450
|
+
? pipe(combineLatest$1.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector))
|
|
2451
|
+
: operate(function (source, subscriber) {
|
|
2452
|
+
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
function combineLatestWith() {
|
|
2457
|
+
var otherSources = [];
|
|
2458
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2459
|
+
otherSources[_i] = arguments[_i];
|
|
2460
|
+
}
|
|
2461
|
+
return combineLatest$1.apply(void 0, __spreadArray([], __read(otherSources)));
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2438
2464
|
function concatMap(project, resultSelector) {
|
|
2439
2465
|
return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
|
|
2440
2466
|
}
|
|
@@ -43007,6 +43033,7 @@ var Neurosity = (function (exports) {
|
|
|
43007
43033
|
this.firebaseUser = new FirebaseUser(this.firebaseApp);
|
|
43008
43034
|
this._selectedDevice.next(undefined);
|
|
43009
43035
|
this.status$ = heartbeatAwareStatus(this.observeNamespace("status").pipe(share())).pipe(filterInternalKeys(), shareReplay(1));
|
|
43036
|
+
this.osVersion$ = this.observeNamespace("info/osVersion").pipe(shareReplay(1));
|
|
43010
43037
|
this.firebaseUser.onAuthStateChanged().subscribe((user) => {
|
|
43011
43038
|
this.user = user;
|
|
43012
43039
|
});
|
|
@@ -43040,6 +43067,9 @@ var Neurosity = (function (exports) {
|
|
|
43040
43067
|
.asObservable()
|
|
43041
43068
|
.pipe(filter((value) => value !== undefined));
|
|
43042
43069
|
}
|
|
43070
|
+
osVersion() {
|
|
43071
|
+
return this.osVersion$;
|
|
43072
|
+
}
|
|
43043
43073
|
// Automatically select device when user logs in
|
|
43044
43074
|
setAutoSelectedDevice() {
|
|
43045
43075
|
return __awaiter$b(this, void 0, void 0, function* () {
|
|
@@ -46304,7 +46334,7 @@ var Neurosity = (function (exports) {
|
|
|
46304
46334
|
const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
|
|
46305
46335
|
var gte_1 = gte;
|
|
46306
46336
|
|
|
46307
|
-
function osHasBluetoothSupport(selectedDevice) {
|
|
46337
|
+
function osHasBluetoothSupport(selectedDevice, osVersion) {
|
|
46308
46338
|
if (!selectedDevice) {
|
|
46309
46339
|
return false;
|
|
46310
46340
|
}
|
|
@@ -46317,7 +46347,9 @@ var Neurosity = (function (exports) {
|
|
|
46317
46347
|
if (isEmulator) {
|
|
46318
46348
|
return false;
|
|
46319
46349
|
}
|
|
46320
|
-
|
|
46350
|
+
// `osVersion` is updated in real time,
|
|
46351
|
+
// unlike accessing via `selectedDevice.osVersion`
|
|
46352
|
+
return gte_1(osVersion !== null && osVersion !== void 0 ? osVersion : selectedDevice.osVersion, "16.0.0");
|
|
46321
46353
|
}
|
|
46322
46354
|
|
|
46323
46355
|
var __awaiter$d = function (thisArg, _arguments, P, generator) {
|
|
@@ -46366,10 +46398,12 @@ var Neurosity = (function (exports) {
|
|
|
46366
46398
|
return yield navigator.bluetooth.getDevices();
|
|
46367
46399
|
});
|
|
46368
46400
|
}
|
|
46369
|
-
_autoConnect(selectedDevice$) {
|
|
46401
|
+
_autoConnect(selectedDevice$, osVersion$) {
|
|
46370
46402
|
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46371
46403
|
? merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$)))
|
|
46372
|
-
: NEVER),
|
|
46404
|
+
: NEVER), combineLatestWith(osVersion$), switchMap(([selectedDevice, osVersion]) => osHasBluetoothSupport(selectedDevice, osVersion)
|
|
46405
|
+
? of(selectedDevice)
|
|
46406
|
+
: EMPTY), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
|
|
46373
46407
|
var _a;
|
|
46374
46408
|
const { deviceNickname } = selectedDevice;
|
|
46375
46409
|
if (this.isConnected()) {
|
|
@@ -46609,7 +46643,7 @@ var Neurosity = (function (exports) {
|
|
|
46609
46643
|
const actions = this.pendingActions$.getValue();
|
|
46610
46644
|
this.pendingActions$.next(actions.filter((id) => id !== actionId));
|
|
46611
46645
|
}
|
|
46612
|
-
_autoToggleActionNotifications(selectedDevice$) {
|
|
46646
|
+
_autoToggleActionNotifications(selectedDevice$, osVersion$) {
|
|
46613
46647
|
return __awaiter$d(this, void 0, void 0, function* () {
|
|
46614
46648
|
let actionsCharacteristic;
|
|
46615
46649
|
let started = false;
|
|
@@ -46643,7 +46677,9 @@ var Neurosity = (function (exports) {
|
|
|
46643
46677
|
}
|
|
46644
46678
|
})));
|
|
46645
46679
|
selectedDevice$
|
|
46646
|
-
.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice
|
|
46680
|
+
.pipe(combineLatestWith(osVersion$), switchMap(([selectedDevice, osVersion]) => !osHasBluetoothSupport(selectedDevice, osVersion)
|
|
46681
|
+
? EMPTY
|
|
46682
|
+
: sideEffects$))
|
|
46647
46683
|
.subscribe();
|
|
46648
46684
|
});
|
|
46649
46685
|
}
|
|
@@ -46816,11 +46852,11 @@ var Neurosity = (function (exports) {
|
|
|
46816
46852
|
const connection = this.connection$.getValue();
|
|
46817
46853
|
return connection === exports.BLUETOOTH_CONNECTION.CONNECTED;
|
|
46818
46854
|
}
|
|
46819
|
-
_autoConnect(selectedDevice$) {
|
|
46855
|
+
_autoConnect(selectedDevice$, osVersion$) {
|
|
46820
46856
|
const selectedDeviceAfterDisconnect$ = this.onDisconnected$.pipe(switchMap(() => selectedDevice$));
|
|
46821
46857
|
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46822
46858
|
? merge(selectedDevice$, selectedDeviceAfterDisconnect$)
|
|
46823
|
-
: NEVER), switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
|
|
46859
|
+
: NEVER), combineLatestWith(osVersion$), switchMap(([selectedDevice, osVersion]) => !osHasBluetoothSupport(selectedDevice, osVersion)
|
|
46824
46860
|
? NEVER
|
|
46825
46861
|
: this.scan().pipe(switchMap((peripherals) => {
|
|
46826
46862
|
const peripheralMatch = peripherals.find((peripheral) => peripheral.name === (selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceNickname));
|
|
@@ -47048,7 +47084,7 @@ var Neurosity = (function (exports) {
|
|
|
47048
47084
|
const actions = this.pendingActions$.getValue();
|
|
47049
47085
|
this.pendingActions$.next(actions.filter((id) => id !== actionId));
|
|
47050
47086
|
}
|
|
47051
|
-
_autoToggleActionNotifications(selectedDevice$) {
|
|
47087
|
+
_autoToggleActionNotifications(selectedDevice$, osVersion$) {
|
|
47052
47088
|
return __awaiter$e(this, void 0, void 0, function* () {
|
|
47053
47089
|
let started = false;
|
|
47054
47090
|
const sideEffects$ = this.connection$.asObservable().pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
|
|
@@ -47079,7 +47115,9 @@ var Neurosity = (function (exports) {
|
|
|
47079
47115
|
}
|
|
47080
47116
|
})));
|
|
47081
47117
|
selectedDevice$
|
|
47082
|
-
.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice
|
|
47118
|
+
.pipe(combineLatestWith(osVersion$), switchMap(([selectedDevice, osVersion]) => !osHasBluetoothSupport(selectedDevice, osVersion)
|
|
47119
|
+
? EMPTY
|
|
47120
|
+
: sideEffects$))
|
|
47083
47121
|
.subscribe();
|
|
47084
47122
|
});
|
|
47085
47123
|
}
|
|
@@ -47232,6 +47270,7 @@ var Neurosity = (function (exports) {
|
|
|
47232
47270
|
class BluetoothClient {
|
|
47233
47271
|
constructor(options) {
|
|
47234
47272
|
this.selectedDevice$ = new ReplaySubject(1);
|
|
47273
|
+
this.osVersion$ = new ReplaySubject(1);
|
|
47235
47274
|
this.isAuthenticated$ = new ReplaySubject(1);
|
|
47236
47275
|
const { transport, selectedDevice$, createBluetoothToken } = options !== null && options !== void 0 ? options : {};
|
|
47237
47276
|
if (!transport) {
|
|
@@ -47243,7 +47282,9 @@ var Neurosity = (function (exports) {
|
|
|
47243
47282
|
selectedDevice$.subscribe(this.selectedDevice$);
|
|
47244
47283
|
}
|
|
47245
47284
|
// Auto Connect
|
|
47246
|
-
this.transport
|
|
47285
|
+
this.transport
|
|
47286
|
+
._autoConnect(this.selectedDevice$, this.osVersion$)
|
|
47287
|
+
.subscribe({
|
|
47247
47288
|
error: (error) => {
|
|
47248
47289
|
var _a;
|
|
47249
47290
|
this.transport.addLog(`Auto connect: error -> ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
@@ -47258,7 +47299,7 @@ var Neurosity = (function (exports) {
|
|
|
47258
47299
|
this.transport.addLog("Auto authentication not enabled");
|
|
47259
47300
|
}
|
|
47260
47301
|
// Auto manage action notifications
|
|
47261
|
-
this.transport._autoToggleActionNotifications(this.selectedDevice$);
|
|
47302
|
+
this.transport._autoToggleActionNotifications(this.selectedDevice$, this.osVersion$);
|
|
47262
47303
|
// Multicast metrics (share)
|
|
47263
47304
|
this._focus$ = this._subscribeWhileAuthenticated("focus");
|
|
47264
47305
|
this._calm$ = this._subscribeWhileAuthenticated("calm");
|
|
@@ -47282,7 +47323,7 @@ var Neurosity = (function (exports) {
|
|
|
47282
47323
|
const reauthenticateInterval$ = timer(0, REAUTHENTICATE_INTERVAL).pipe(tap(() => {
|
|
47283
47324
|
this.transport.addLog(`Auto authentication in progress...`);
|
|
47284
47325
|
}));
|
|
47285
|
-
return this.selectedDevice$.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
|
|
47326
|
+
return this.selectedDevice$.pipe(combineLatestWith(this.osVersion$), switchMap(([selectedDevice, osVersion]) => !osHasBluetoothSupport(selectedDevice, osVersion)
|
|
47286
47327
|
? EMPTY
|
|
47287
47328
|
: this.connection().pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
|
|
47288
47329
|
? reauthenticateInterval$
|
|
@@ -47302,7 +47343,8 @@ var Neurosity = (function (exports) {
|
|
|
47302
47343
|
_hasBluetoothSupport() {
|
|
47303
47344
|
return __awaiter$f(this, void 0, void 0, function* () {
|
|
47304
47345
|
const selectedDevice = yield firstValueFrom(this.selectedDevice$);
|
|
47305
|
-
|
|
47346
|
+
const osVersion = yield firstValueFrom(this.osVersion$);
|
|
47347
|
+
return osHasBluetoothSupport(selectedDevice, osVersion);
|
|
47306
47348
|
});
|
|
47307
47349
|
}
|
|
47308
47350
|
authenticate(token) {
|
|
@@ -47383,7 +47425,7 @@ var Neurosity = (function (exports) {
|
|
|
47383
47425
|
});
|
|
47384
47426
|
}
|
|
47385
47427
|
_subscribeWhileAuthenticated(characteristicName) {
|
|
47386
|
-
return this.selectedDevice$.pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
|
|
47428
|
+
return this.selectedDevice$.pipe(combineLatestWith(this.osVersion$), switchMap(([selectedDevice, osVersion]) => !osHasBluetoothSupport(selectedDevice, osVersion)
|
|
47387
47429
|
? EMPTY
|
|
47388
47430
|
: this.isAuthenticated$.pipe(distinctUntilChanged(), switchMap((isAuthenticated) => isAuthenticated
|
|
47389
47431
|
? this.transport.subscribeToCharacteristic({
|
|
@@ -47570,6 +47612,7 @@ var Neurosity = (function (exports) {
|
|
|
47570
47612
|
if (!!bluetoothTransport) {
|
|
47571
47613
|
this.bluetoothClient = new BluetoothClient({
|
|
47572
47614
|
selectedDevice$: this.onDeviceChange(),
|
|
47615
|
+
osVersion$: this.osVersion(),
|
|
47573
47616
|
createBluetoothToken: this.createBluetoothToken.bind(this),
|
|
47574
47617
|
transport: bluetoothTransport
|
|
47575
47618
|
});
|
|
@@ -47615,12 +47658,12 @@ var Neurosity = (function (exports) {
|
|
|
47615
47658
|
streamingState() {
|
|
47616
47659
|
const isWifiOnline = (state) => [STATUS.ONLINE, STATUS.UPDATING].includes(state);
|
|
47617
47660
|
return this.streamingMode$.pipe(switchMap((streamingMode) => {
|
|
47618
|
-
return this.onDeviceChange().pipe(switchMap((selectDevice) => {
|
|
47661
|
+
return this.onDeviceChange().pipe(combineLatestWith(this.osVersion()), switchMap(([selectDevice, osVersion]) => {
|
|
47619
47662
|
if (!selectDevice) {
|
|
47620
47663
|
return EMPTY;
|
|
47621
47664
|
}
|
|
47622
47665
|
const isUnableToUseBluetooth = this.isMissingBluetoothTransport ||
|
|
47623
|
-
!osHasBluetoothSupport(selectDevice);
|
|
47666
|
+
!osHasBluetoothSupport(selectDevice, osVersion);
|
|
47624
47667
|
if (isUnableToUseBluetooth) {
|
|
47625
47668
|
return this.cloudClient.status().pipe(map(({ state }) => ({
|
|
47626
47669
|
connected: isWifiOnline(state),
|
|
@@ -48286,7 +48329,7 @@ var Neurosity = (function (exports) {
|
|
|
48286
48329
|
if (hasOAuthError) {
|
|
48287
48330
|
return throwError(() => OAuthError);
|
|
48288
48331
|
}
|
|
48289
|
-
return this.cloudClient.
|
|
48332
|
+
return this.cloudClient.osVersion();
|
|
48290
48333
|
}
|
|
48291
48334
|
/**
|
|
48292
48335
|
* <StreamingModes wifi={true} bluetooth={true} />
|