@neurosity/sdk 6.0.0 → 6.1.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/CHANGELOG.md +25 -0
- package/dist/browser/neurosity.iife.js +42 -112
- package/dist/browser/neurosity.js +8 -14
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/{Notion.d.ts → Neurosity.d.ts} +0 -0
- package/dist/cjs/{Notion.js → Neurosity.js} +0 -47
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +1 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.js +3 -0
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +1 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +21 -2
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +8 -1
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +16 -2
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -2
- package/dist/electron/index.js +8 -14
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/{Notion.d.ts → Neurosity.d.ts} +0 -0
- package/dist/esm/{Notion.js → Neurosity.js} +1 -48
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +1 -0
- package/dist/esm/api/bluetooth/BluetoothClient.js +3 -0
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +1 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +21 -2
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +8 -1
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +16 -2
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/neurosity.mjs +43 -111
- package/dist/examples/neurosity.iife.js +42 -112
- package/dist/examples/neurosity.js +8 -14
- package/dist/examples/neurosity.mjs +43 -111
- package/package.json +1 -1
- package/dist/cjs/skills/NotionOnDevice.d.ts +0 -7
- package/dist/cjs/skills/NotionOnDevice.js +0 -25
- package/dist/cjs/skills/createSkill.d.ts +0 -7
- package/dist/cjs/skills/createSkill.js +0 -40
- package/dist/cjs/skills/index.d.ts +0 -2
- package/dist/cjs/skills/index.js +0 -18
- package/dist/esm/skills/NotionOnDevice.d.ts +0 -7
- package/dist/esm/skills/NotionOnDevice.js +0 -21
- package/dist/esm/skills/createSkill.d.ts +0 -7
- package/dist/esm/skills/createSkill.js +0 -36
- package/dist/esm/skills/index.d.ts +0 -2
- package/dist/esm/skills/index.js +0 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# v5.0.0
|
|
2
|
+
|
|
3
|
+
- FEAT: Auto & manual device selection via `neurosity.selectDevice(...)` method
|
|
4
|
+
- FEAT: new methods: `neurosity.getDevices()` and `neurosity.onDeviceChange()`
|
|
5
|
+
- FIX: #46 Notion sends 1 packet of data even though it is asleep
|
|
6
|
+
- FIX: only send timesync actions if and when device is online
|
|
7
|
+
|
|
8
|
+
# v4.0.0
|
|
9
|
+
|
|
10
|
+
- Added types
|
|
11
|
+
- Improved documentation (Reference)
|
|
12
|
+
|
|
13
|
+
# v3.10.0
|
|
14
|
+
|
|
15
|
+
- Added periodic device status update call while subscribed to status
|
|
16
|
+
|
|
17
|
+
# v3.9.0
|
|
18
|
+
|
|
19
|
+
- Added clients connections and remove them when offline
|
|
20
|
+
|
|
21
|
+
# v3.8.1
|
|
22
|
+
|
|
23
|
+
### Package Updates
|
|
24
|
+
|
|
25
|
+
- Update IPK to v1.7.0
|
|
@@ -46328,8 +46328,11 @@ var Neurosity = (function (exports) {
|
|
|
46328
46328
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46329
46329
|
});
|
|
46330
46330
|
};
|
|
46331
|
+
const defaultOptions$1 = {
|
|
46332
|
+
autoConnect: true
|
|
46333
|
+
};
|
|
46331
46334
|
class WebBluetoothTransport {
|
|
46332
|
-
constructor() {
|
|
46335
|
+
constructor(options = {}) {
|
|
46333
46336
|
this.type = TRANSPORT_TYPE.WEB;
|
|
46334
46337
|
this.characteristicsByName = {};
|
|
46335
46338
|
this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
@@ -46339,11 +46342,17 @@ var Neurosity = (function (exports) {
|
|
|
46339
46342
|
this.connectionStream$ = this.connection$
|
|
46340
46343
|
.asObservable()
|
|
46341
46344
|
.pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
|
|
46345
|
+
this._isAutoConnectEnabled$ = new ReplaySubject(1);
|
|
46346
|
+
this.options = Object.assign(Object.assign({}, defaultOptions$1), options);
|
|
46342
46347
|
if (!isWebBluetoothSupported()) {
|
|
46343
46348
|
const errorMessage = "Web Bluetooth is not supported";
|
|
46344
46349
|
this.addLog(errorMessage);
|
|
46345
46350
|
throw new Error(errorMessage);
|
|
46346
46351
|
}
|
|
46352
|
+
this._isAutoConnectEnabled$.subscribe((autoConnect) => {
|
|
46353
|
+
this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
|
|
46354
|
+
});
|
|
46355
|
+
this._isAutoConnectEnabled$.next(this.options.autoConnect);
|
|
46347
46356
|
this.connection$.asObservable().subscribe((connection) => {
|
|
46348
46357
|
this.addLog(`connection status is ${connection}`);
|
|
46349
46358
|
});
|
|
@@ -46357,7 +46366,9 @@ var Neurosity = (function (exports) {
|
|
|
46357
46366
|
});
|
|
46358
46367
|
}
|
|
46359
46368
|
_autoConnect(selectedDevice$) {
|
|
46360
|
-
return
|
|
46369
|
+
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46370
|
+
? merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$)))
|
|
46371
|
+
: NEVER), switchMap((selectedDevice) => osHasBluetoothSupport(selectedDevice) ? of(selectedDevice) : EMPTY), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
|
|
46361
46372
|
var _a;
|
|
46362
46373
|
const { deviceNickname } = selectedDevice;
|
|
46363
46374
|
if (this.isConnected()) {
|
|
@@ -46388,6 +46399,9 @@ var Neurosity = (function (exports) {
|
|
|
46388
46399
|
return yield this.getServerServiceAndCharacteristics(advertisement.device);
|
|
46389
46400
|
})));
|
|
46390
46401
|
}
|
|
46402
|
+
enableAutoConnect(autoConnect) {
|
|
46403
|
+
this._isAutoConnectEnabled$.next(autoConnect);
|
|
46404
|
+
}
|
|
46391
46405
|
addLog(log) {
|
|
46392
46406
|
this.logs$.next(log);
|
|
46393
46407
|
}
|
|
@@ -46724,6 +46738,9 @@ var Neurosity = (function (exports) {
|
|
|
46724
46738
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46725
46739
|
});
|
|
46726
46740
|
};
|
|
46741
|
+
const defaultOptions$2 = {
|
|
46742
|
+
autoConnect: true
|
|
46743
|
+
};
|
|
46727
46744
|
class ReactNativeTransport {
|
|
46728
46745
|
constructor(options) {
|
|
46729
46746
|
this.type = TRANSPORT_TYPE.REACT_NATIVE;
|
|
@@ -46734,7 +46751,14 @@ var Neurosity = (function (exports) {
|
|
|
46734
46751
|
this.connectionStream$ = this.connection$
|
|
46735
46752
|
.asObservable()
|
|
46736
46753
|
.pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
|
|
46737
|
-
|
|
46754
|
+
this._isAutoConnectEnabled$ = new ReplaySubject(1);
|
|
46755
|
+
if (!options) {
|
|
46756
|
+
const errorMessage = "React Native transport: missing options.";
|
|
46757
|
+
this.addLog(errorMessage);
|
|
46758
|
+
throw new Error(errorMessage);
|
|
46759
|
+
}
|
|
46760
|
+
this.options = Object.assign(Object.assign({}, defaultOptions$2), options);
|
|
46761
|
+
const { BleManager, bleManagerEmitter, platform, autoConnect } = this.options;
|
|
46738
46762
|
if (!BleManager) {
|
|
46739
46763
|
const errorMessage = "React Native option: BleManager not provided.";
|
|
46740
46764
|
this.addLog(errorMessage);
|
|
@@ -46753,6 +46777,10 @@ var Neurosity = (function (exports) {
|
|
|
46753
46777
|
this.BleManager = BleManager;
|
|
46754
46778
|
this.bleManagerEmitter = bleManagerEmitter;
|
|
46755
46779
|
this.platform = platform;
|
|
46780
|
+
this._isAutoConnectEnabled$.next(autoConnect);
|
|
46781
|
+
this._isAutoConnectEnabled$.subscribe((autoConnect) => {
|
|
46782
|
+
this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
|
|
46783
|
+
});
|
|
46756
46784
|
// We create a single listener per event type to
|
|
46757
46785
|
// avoid missing events when multiple listeners are attached.
|
|
46758
46786
|
this.bleEvents = {
|
|
@@ -46788,7 +46816,9 @@ var Neurosity = (function (exports) {
|
|
|
46788
46816
|
}
|
|
46789
46817
|
_autoConnect(selectedDevice$) {
|
|
46790
46818
|
const selectedDeviceAfterDisconnect$ = this.onDisconnected$.pipe(switchMap(() => selectedDevice$));
|
|
46791
|
-
return
|
|
46819
|
+
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46820
|
+
? merge(selectedDevice$, selectedDeviceAfterDisconnect$)
|
|
46821
|
+
: NEVER), switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
|
|
46792
46822
|
? NEVER
|
|
46793
46823
|
: this.scan().pipe(switchMap((peripherals) => {
|
|
46794
46824
|
const peripheralMatch = peripherals.find((peripheral) => peripheral.name === (selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceNickname));
|
|
@@ -46797,6 +46827,9 @@ var Neurosity = (function (exports) {
|
|
|
46797
46827
|
return yield this.connect(peripheral);
|
|
46798
46828
|
})));
|
|
46799
46829
|
}
|
|
46830
|
+
enableAutoConnect(autoConnect) {
|
|
46831
|
+
this._isAutoConnectEnabled$.next(autoConnect);
|
|
46832
|
+
}
|
|
46800
46833
|
connection() {
|
|
46801
46834
|
return this.connectionStream$;
|
|
46802
46835
|
}
|
|
@@ -47250,6 +47283,9 @@ var Neurosity = (function (exports) {
|
|
|
47250
47283
|
}
|
|
47251
47284
|
})))));
|
|
47252
47285
|
}
|
|
47286
|
+
enableAutoConnect(autoConnect) {
|
|
47287
|
+
this.transport.enableAutoConnect(autoConnect);
|
|
47288
|
+
}
|
|
47253
47289
|
_hasBluetoothSupport() {
|
|
47254
47290
|
return __awaiter$f(this, void 0, void 0, function* () {
|
|
47255
47291
|
const selectedDevice = yield firstValueFrom(this.selectedDevice$);
|
|
@@ -47478,7 +47514,7 @@ var Neurosity = (function (exports) {
|
|
|
47478
47514
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47479
47515
|
});
|
|
47480
47516
|
};
|
|
47481
|
-
const defaultOptions$
|
|
47517
|
+
const defaultOptions$3 = {
|
|
47482
47518
|
timesync: false,
|
|
47483
47519
|
autoSelectDevice: true,
|
|
47484
47520
|
streamingMode: STREAMING_MODE.WIFI_ONLY,
|
|
@@ -47516,7 +47552,7 @@ var Neurosity = (function (exports) {
|
|
|
47516
47552
|
*/
|
|
47517
47553
|
this.streamingMode$ = new ReplaySubject(1);
|
|
47518
47554
|
const { streamingMode, bluetoothTransport } = options;
|
|
47519
|
-
this.options = Object.freeze(Object.assign(Object.assign({}, defaultOptions$
|
|
47555
|
+
this.options = Object.freeze(Object.assign(Object.assign({}, defaultOptions$3), options));
|
|
47520
47556
|
this.cloudClient = new CloudClient(this.options);
|
|
47521
47557
|
if (!!bluetoothTransport) {
|
|
47522
47558
|
this.bluetoothClient = new BluetoothClient({
|
|
@@ -48593,53 +48629,6 @@ var Neurosity = (function (exports) {
|
|
|
48593
48629
|
removeOAuthAccess() {
|
|
48594
48630
|
return this.cloudClient.removeOAuthAccess();
|
|
48595
48631
|
}
|
|
48596
|
-
/**
|
|
48597
|
-
* @internal
|
|
48598
|
-
* Proof of Concept for Skills - Not user facing yet
|
|
48599
|
-
*
|
|
48600
|
-
* Accesses a skill by Bundle ID. Additionally, allows to observe
|
|
48601
|
-
* and push skill metrics
|
|
48602
|
-
*
|
|
48603
|
-
* @param bundleId Bundle ID of skill
|
|
48604
|
-
* @returns Skill instance
|
|
48605
|
-
*/
|
|
48606
|
-
skill(bundleId) {
|
|
48607
|
-
return __awaiter$g(this, void 0, void 0, function* () {
|
|
48608
|
-
if (!(yield this.cloudClient.didSelectDevice())) {
|
|
48609
|
-
return Promise.reject(mustSelectDevice);
|
|
48610
|
-
}
|
|
48611
|
-
const skillData = yield this.cloudClient.skills.get(bundleId);
|
|
48612
|
-
if (skillData === null) {
|
|
48613
|
-
return Promise.reject(new Error(`${prefix}Access denied for: ${bundleId}. Make sure the skill is installed.`));
|
|
48614
|
-
}
|
|
48615
|
-
return {
|
|
48616
|
-
metric: (label) => {
|
|
48617
|
-
const metricName = `skill~${skillData.id}~${label}`;
|
|
48618
|
-
const subscription = new Observable((observer) => {
|
|
48619
|
-
const subscription = this.cloudClient.metrics.subscribe({
|
|
48620
|
-
metric: metricName,
|
|
48621
|
-
labels: [label],
|
|
48622
|
-
atomic: true
|
|
48623
|
-
});
|
|
48624
|
-
const listener = this.cloudClient.metrics.on(subscription, (...data) => {
|
|
48625
|
-
observer.next(...data);
|
|
48626
|
-
});
|
|
48627
|
-
return () => {
|
|
48628
|
-
this.cloudClient.metrics.unsubscribe(subscription, listener);
|
|
48629
|
-
};
|
|
48630
|
-
}).pipe(map((metric) => metric[label]));
|
|
48631
|
-
Object.defineProperty(subscription, "next", {
|
|
48632
|
-
value: (metricValue) => {
|
|
48633
|
-
this.cloudClient.metrics.next(metricName, {
|
|
48634
|
-
[label]: metricValue
|
|
48635
|
-
});
|
|
48636
|
-
}
|
|
48637
|
-
});
|
|
48638
|
-
return subscription;
|
|
48639
|
-
}
|
|
48640
|
-
};
|
|
48641
|
-
});
|
|
48642
|
-
}
|
|
48643
48632
|
/**
|
|
48644
48633
|
* <StreamingModes wifi={true} />
|
|
48645
48634
|
*
|
|
@@ -48710,71 +48699,12 @@ var Neurosity = (function (exports) {
|
|
|
48710
48699
|
}
|
|
48711
48700
|
}
|
|
48712
48701
|
|
|
48713
|
-
var __awaiter$h = function (thisArg, _arguments, P, generator) {
|
|
48714
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48715
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48716
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48717
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
48718
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
48719
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48720
|
-
});
|
|
48721
|
-
};
|
|
48722
|
-
/**
|
|
48723
|
-
* @internal
|
|
48724
|
-
*/
|
|
48725
|
-
function createNotionOnDevice(options) {
|
|
48726
|
-
return __awaiter$h(this, void 0, void 0, function* () {
|
|
48727
|
-
const neurosity = new Neurosity(options);
|
|
48728
|
-
const skill = Object.assign(Object.assign({}, (yield neurosity.skill(options.skill.bundleId))), { props: "props" in options.skill ? options.skill.props : {} });
|
|
48729
|
-
delete neurosity.skill;
|
|
48730
|
-
return [neurosity, skill];
|
|
48731
|
-
});
|
|
48732
|
-
}
|
|
48733
|
-
|
|
48734
|
-
var __awaiter$i = function (thisArg, _arguments, P, generator) {
|
|
48735
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48736
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48737
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48738
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
48739
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
48740
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48741
|
-
});
|
|
48742
|
-
};
|
|
48743
|
-
function createSkill(app) {
|
|
48744
|
-
return {
|
|
48745
|
-
subscribe: (options) => __awaiter$i(this, void 0, void 0, function* () {
|
|
48746
|
-
const [neurosity, skill] = yield createNotionOnDevice(Object.assign({}, options));
|
|
48747
|
-
const teardown = app(neurosity, skill);
|
|
48748
|
-
return {
|
|
48749
|
-
unsubscribe: () => __awaiter$i(this, void 0, void 0, function* () {
|
|
48750
|
-
yield neurosity.disconnect();
|
|
48751
|
-
if (teardown && "then" in teardown) {
|
|
48752
|
-
const cleanUp = yield teardown;
|
|
48753
|
-
if (typeof cleanUp === "function") {
|
|
48754
|
-
cleanUp();
|
|
48755
|
-
}
|
|
48756
|
-
}
|
|
48757
|
-
if (typeof teardown === "function" && "then" in teardown()) {
|
|
48758
|
-
return yield teardown();
|
|
48759
|
-
}
|
|
48760
|
-
if (typeof teardown === "function") {
|
|
48761
|
-
return teardown();
|
|
48762
|
-
}
|
|
48763
|
-
return teardown;
|
|
48764
|
-
})
|
|
48765
|
-
};
|
|
48766
|
-
})
|
|
48767
|
-
};
|
|
48768
|
-
}
|
|
48769
|
-
|
|
48770
48702
|
exports.Neurosity = Neurosity;
|
|
48771
48703
|
exports.Notion = Notion;
|
|
48772
48704
|
exports.BluetoothClient = BluetoothClient;
|
|
48773
48705
|
exports.WebBluetoothTransport = WebBluetoothTransport;
|
|
48774
48706
|
exports.ReactNativeTransport = ReactNativeTransport;
|
|
48775
48707
|
exports.osHasBluetoothSupport = osHasBluetoothSupport;
|
|
48776
|
-
exports.createSkill = createSkill;
|
|
48777
|
-
exports.createNotionOnDevice = createNotionOnDevice;
|
|
48778
48708
|
|
|
48779
48709
|
return exports;
|
|
48780
48710
|
|