@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.
Files changed (45) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/browser/neurosity.iife.js +42 -112
  3. package/dist/browser/neurosity.js +8 -14
  4. package/dist/browser/neurosity.js.map +1 -1
  5. package/dist/cjs/{Notion.d.ts → Neurosity.d.ts} +0 -0
  6. package/dist/cjs/{Notion.js → Neurosity.js} +0 -47
  7. package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +1 -0
  8. package/dist/cjs/api/bluetooth/BluetoothClient.js +3 -0
  9. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +1 -0
  10. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -0
  11. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +21 -2
  12. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +8 -1
  13. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +16 -2
  14. package/dist/cjs/index.d.ts +1 -2
  15. package/dist/cjs/index.js +1 -2
  16. package/dist/electron/index.js +8 -14
  17. package/dist/electron/index.js.map +1 -1
  18. package/dist/esm/{Notion.d.ts → Neurosity.d.ts} +0 -0
  19. package/dist/esm/{Notion.js → Neurosity.js} +1 -48
  20. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +1 -0
  21. package/dist/esm/api/bluetooth/BluetoothClient.js +3 -0
  22. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +1 -0
  23. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -0
  24. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +21 -2
  25. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +8 -1
  26. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +16 -2
  27. package/dist/esm/index.d.ts +1 -2
  28. package/dist/esm/index.js +1 -2
  29. package/dist/esm/neurosity.mjs +43 -111
  30. package/dist/examples/neurosity.iife.js +42 -112
  31. package/dist/examples/neurosity.js +8 -14
  32. package/dist/examples/neurosity.mjs +43 -111
  33. package/package.json +1 -1
  34. package/dist/cjs/skills/NotionOnDevice.d.ts +0 -7
  35. package/dist/cjs/skills/NotionOnDevice.js +0 -25
  36. package/dist/cjs/skills/createSkill.d.ts +0 -7
  37. package/dist/cjs/skills/createSkill.js +0 -40
  38. package/dist/cjs/skills/index.d.ts +0 -2
  39. package/dist/cjs/skills/index.js +0 -18
  40. package/dist/esm/skills/NotionOnDevice.d.ts +0 -7
  41. package/dist/esm/skills/NotionOnDevice.js +0 -21
  42. package/dist/esm/skills/createSkill.d.ts +0 -7
  43. package/dist/esm/skills/createSkill.js +0 -36
  44. package/dist/esm/skills/index.d.ts +0 -2
  45. package/dist/esm/skills/index.js +0 -2
@@ -46325,8 +46325,11 @@ var __awaiter$d = (undefined && undefined.__awaiter) || function (thisArg, _argu
46325
46325
  step((generator = generator.apply(thisArg, _arguments || [])).next());
46326
46326
  });
46327
46327
  };
46328
+ const defaultOptions$1 = {
46329
+ autoConnect: true
46330
+ };
46328
46331
  class WebBluetoothTransport {
46329
- constructor() {
46332
+ constructor(options = {}) {
46330
46333
  this.type = TRANSPORT_TYPE.WEB;
46331
46334
  this.characteristicsByName = {};
46332
46335
  this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
@@ -46336,11 +46339,17 @@ class WebBluetoothTransport {
46336
46339
  this.connectionStream$ = this.connection$
46337
46340
  .asObservable()
46338
46341
  .pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
46342
+ this._isAutoConnectEnabled$ = new ReplaySubject(1);
46343
+ this.options = Object.assign(Object.assign({}, defaultOptions$1), options);
46339
46344
  if (!isWebBluetoothSupported()) {
46340
46345
  const errorMessage = "Web Bluetooth is not supported";
46341
46346
  this.addLog(errorMessage);
46342
46347
  throw new Error(errorMessage);
46343
46348
  }
46349
+ this._isAutoConnectEnabled$.subscribe((autoConnect) => {
46350
+ this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
46351
+ });
46352
+ this._isAutoConnectEnabled$.next(this.options.autoConnect);
46344
46353
  this.connection$.asObservable().subscribe((connection) => {
46345
46354
  this.addLog(`connection status is ${connection}`);
46346
46355
  });
@@ -46354,7 +46363,9 @@ class WebBluetoothTransport {
46354
46363
  });
46355
46364
  }
46356
46365
  _autoConnect(selectedDevice$) {
46357
- return merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$))).pipe(switchMap((selectedDevice) => osHasBluetoothSupport(selectedDevice) ? of(selectedDevice) : EMPTY), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
46366
+ return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
46367
+ ? merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$)))
46368
+ : NEVER), switchMap((selectedDevice) => osHasBluetoothSupport(selectedDevice) ? of(selectedDevice) : EMPTY), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
46358
46369
  var _a;
46359
46370
  const { deviceNickname } = selectedDevice;
46360
46371
  if (this.isConnected()) {
@@ -46385,6 +46396,9 @@ class WebBluetoothTransport {
46385
46396
  return yield this.getServerServiceAndCharacteristics(advertisement.device);
46386
46397
  })));
46387
46398
  }
46399
+ enableAutoConnect(autoConnect) {
46400
+ this._isAutoConnectEnabled$.next(autoConnect);
46401
+ }
46388
46402
  addLog(log) {
46389
46403
  this.logs$.next(log);
46390
46404
  }
@@ -46721,6 +46735,9 @@ var __awaiter$e = (undefined && undefined.__awaiter) || function (thisArg, _argu
46721
46735
  step((generator = generator.apply(thisArg, _arguments || [])).next());
46722
46736
  });
46723
46737
  };
46738
+ const defaultOptions$2 = {
46739
+ autoConnect: true
46740
+ };
46724
46741
  class ReactNativeTransport {
46725
46742
  constructor(options) {
46726
46743
  this.type = TRANSPORT_TYPE.REACT_NATIVE;
@@ -46731,7 +46748,14 @@ class ReactNativeTransport {
46731
46748
  this.connectionStream$ = this.connection$
46732
46749
  .asObservable()
46733
46750
  .pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
46734
- const { BleManager, bleManagerEmitter, platform } = options;
46751
+ this._isAutoConnectEnabled$ = new ReplaySubject(1);
46752
+ if (!options) {
46753
+ const errorMessage = "React Native transport: missing options.";
46754
+ this.addLog(errorMessage);
46755
+ throw new Error(errorMessage);
46756
+ }
46757
+ this.options = Object.assign(Object.assign({}, defaultOptions$2), options);
46758
+ const { BleManager, bleManagerEmitter, platform, autoConnect } = this.options;
46735
46759
  if (!BleManager) {
46736
46760
  const errorMessage = "React Native option: BleManager not provided.";
46737
46761
  this.addLog(errorMessage);
@@ -46750,6 +46774,10 @@ class ReactNativeTransport {
46750
46774
  this.BleManager = BleManager;
46751
46775
  this.bleManagerEmitter = bleManagerEmitter;
46752
46776
  this.platform = platform;
46777
+ this._isAutoConnectEnabled$.next(autoConnect);
46778
+ this._isAutoConnectEnabled$.subscribe((autoConnect) => {
46779
+ this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
46780
+ });
46753
46781
  // We create a single listener per event type to
46754
46782
  // avoid missing events when multiple listeners are attached.
46755
46783
  this.bleEvents = {
@@ -46785,7 +46813,9 @@ class ReactNativeTransport {
46785
46813
  }
46786
46814
  _autoConnect(selectedDevice$) {
46787
46815
  const selectedDeviceAfterDisconnect$ = this.onDisconnected$.pipe(switchMap(() => selectedDevice$));
46788
- return merge(selectedDevice$, selectedDeviceAfterDisconnect$).pipe(switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
46816
+ return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
46817
+ ? merge(selectedDevice$, selectedDeviceAfterDisconnect$)
46818
+ : NEVER), switchMap((selectedDevice) => !osHasBluetoothSupport(selectedDevice)
46789
46819
  ? NEVER
46790
46820
  : this.scan().pipe(switchMap((peripherals) => {
46791
46821
  const peripheralMatch = peripherals.find((peripheral) => peripheral.name === (selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceNickname));
@@ -46794,6 +46824,9 @@ class ReactNativeTransport {
46794
46824
  return yield this.connect(peripheral);
46795
46825
  })));
46796
46826
  }
46827
+ enableAutoConnect(autoConnect) {
46828
+ this._isAutoConnectEnabled$.next(autoConnect);
46829
+ }
46797
46830
  connection() {
46798
46831
  return this.connectionStream$;
46799
46832
  }
@@ -47247,6 +47280,9 @@ class BluetoothClient {
47247
47280
  }
47248
47281
  })))));
47249
47282
  }
47283
+ enableAutoConnect(autoConnect) {
47284
+ this.transport.enableAutoConnect(autoConnect);
47285
+ }
47250
47286
  _hasBluetoothSupport() {
47251
47287
  return __awaiter$f(this, void 0, void 0, function* () {
47252
47288
  const selectedDevice = yield firstValueFrom(this.selectedDevice$);
@@ -47475,7 +47511,7 @@ var __awaiter$g = (undefined && undefined.__awaiter) || function (thisArg, _argu
47475
47511
  step((generator = generator.apply(thisArg, _arguments || [])).next());
47476
47512
  });
47477
47513
  };
47478
- const defaultOptions$1 = {
47514
+ const defaultOptions$3 = {
47479
47515
  timesync: false,
47480
47516
  autoSelectDevice: true,
47481
47517
  streamingMode: STREAMING_MODE.WIFI_ONLY,
@@ -47513,7 +47549,7 @@ class Neurosity {
47513
47549
  */
47514
47550
  this.streamingMode$ = new ReplaySubject(1);
47515
47551
  const { streamingMode, bluetoothTransport } = options;
47516
- this.options = Object.freeze(Object.assign(Object.assign({}, defaultOptions$1), options));
47552
+ this.options = Object.freeze(Object.assign(Object.assign({}, defaultOptions$3), options));
47517
47553
  this.cloudClient = new CloudClient(this.options);
47518
47554
  if (!!bluetoothTransport) {
47519
47555
  this.bluetoothClient = new BluetoothClient({
@@ -48590,53 +48626,6 @@ class Neurosity {
48590
48626
  removeOAuthAccess() {
48591
48627
  return this.cloudClient.removeOAuthAccess();
48592
48628
  }
48593
- /**
48594
- * @internal
48595
- * Proof of Concept for Skills - Not user facing yet
48596
- *
48597
- * Accesses a skill by Bundle ID. Additionally, allows to observe
48598
- * and push skill metrics
48599
- *
48600
- * @param bundleId Bundle ID of skill
48601
- * @returns Skill instance
48602
- */
48603
- skill(bundleId) {
48604
- return __awaiter$g(this, void 0, void 0, function* () {
48605
- if (!(yield this.cloudClient.didSelectDevice())) {
48606
- return Promise.reject(mustSelectDevice);
48607
- }
48608
- const skillData = yield this.cloudClient.skills.get(bundleId);
48609
- if (skillData === null) {
48610
- return Promise.reject(new Error(`${prefix}Access denied for: ${bundleId}. Make sure the skill is installed.`));
48611
- }
48612
- return {
48613
- metric: (label) => {
48614
- const metricName = `skill~${skillData.id}~${label}`;
48615
- const subscription = new Observable((observer) => {
48616
- const subscription = this.cloudClient.metrics.subscribe({
48617
- metric: metricName,
48618
- labels: [label],
48619
- atomic: true
48620
- });
48621
- const listener = this.cloudClient.metrics.on(subscription, (...data) => {
48622
- observer.next(...data);
48623
- });
48624
- return () => {
48625
- this.cloudClient.metrics.unsubscribe(subscription, listener);
48626
- };
48627
- }).pipe(map((metric) => metric[label]));
48628
- Object.defineProperty(subscription, "next", {
48629
- value: (metricValue) => {
48630
- this.cloudClient.metrics.next(metricName, {
48631
- [label]: metricValue
48632
- });
48633
- }
48634
- });
48635
- return subscription;
48636
- }
48637
- };
48638
- });
48639
- }
48640
48629
  /**
48641
48630
  * <StreamingModes wifi={true} />
48642
48631
  *
@@ -48707,61 +48696,4 @@ class Notion extends Neurosity {
48707
48696
  }
48708
48697
  }
48709
48698
 
48710
- var __awaiter$h = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
48711
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48712
- return new (P || (P = Promise))(function (resolve, reject) {
48713
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48714
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48715
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48716
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48717
- });
48718
- };
48719
- /**
48720
- * @internal
48721
- */
48722
- function createNotionOnDevice(options) {
48723
- return __awaiter$h(this, void 0, void 0, function* () {
48724
- const neurosity = new Neurosity(options);
48725
- const skill = Object.assign(Object.assign({}, (yield neurosity.skill(options.skill.bundleId))), { props: "props" in options.skill ? options.skill.props : {} });
48726
- delete neurosity.skill;
48727
- return [neurosity, skill];
48728
- });
48729
- }
48730
-
48731
- var __awaiter$i = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
48732
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48733
- return new (P || (P = Promise))(function (resolve, reject) {
48734
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48735
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48736
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48737
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48738
- });
48739
- };
48740
- function createSkill(app) {
48741
- return {
48742
- subscribe: (options) => __awaiter$i(this, void 0, void 0, function* () {
48743
- const [neurosity, skill] = yield createNotionOnDevice(Object.assign({}, options));
48744
- const teardown = app(neurosity, skill);
48745
- return {
48746
- unsubscribe: () => __awaiter$i(this, void 0, void 0, function* () {
48747
- yield neurosity.disconnect();
48748
- if (teardown && "then" in teardown) {
48749
- const cleanUp = yield teardown;
48750
- if (typeof cleanUp === "function") {
48751
- cleanUp();
48752
- }
48753
- }
48754
- if (typeof teardown === "function" && "then" in teardown()) {
48755
- return yield teardown();
48756
- }
48757
- if (typeof teardown === "function") {
48758
- return teardown();
48759
- }
48760
- return teardown;
48761
- })
48762
- };
48763
- })
48764
- };
48765
- }
48766
-
48767
- export { Neurosity, Notion, BluetoothClient, WebBluetoothTransport, ReactNativeTransport, osHasBluetoothSupport, createSkill, createNotionOnDevice };
48699
+ export { Neurosity, Notion, BluetoothClient, WebBluetoothTransport, ReactNativeTransport, osHasBluetoothSupport };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neurosity/sdk",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "description": "Neurosity SDK",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,7 +0,0 @@
1
- import { Neurosity } from "../Notion";
2
- import { SDKOptions } from "../types/options";
3
- import { Skill } from "../types/skill";
4
- export declare type NotionOnDevice = Omit<Neurosity, "skill">;
5
- export interface OnDeviceOptions extends SDKOptions {
6
- skill: Skill;
7
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createNotionOnDevice = void 0;
13
- const Notion_1 = require("../Notion");
14
- /**
15
- * @internal
16
- */
17
- function createNotionOnDevice(options) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const neurosity = new Notion_1.Neurosity(options);
20
- const skill = Object.assign(Object.assign({}, (yield neurosity.skill(options.skill.bundleId))), { props: "props" in options.skill ? options.skill.props : {} });
21
- delete neurosity.skill;
22
- return [neurosity, skill];
23
- });
24
- }
25
- exports.createNotionOnDevice = createNotionOnDevice;
@@ -1,7 +0,0 @@
1
- import { OnDeviceOptions, NotionOnDevice } from "./NotionOnDevice";
2
- import { SkillInstance, SkillSubscription } from "../types/skill";
3
- declare type SkillApp = (neurosity: NotionOnDevice, skill: SkillInstance) => () => Promise<void>;
4
- export declare function createSkill(app: SkillApp): {
5
- subscribe: (options: OnDeviceOptions) => Promise<SkillSubscription>;
6
- };
7
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createSkill = void 0;
13
- const NotionOnDevice_1 = require("./NotionOnDevice");
14
- function createSkill(app) {
15
- return {
16
- subscribe: (options) => __awaiter(this, void 0, void 0, function* () {
17
- const [neurosity, skill] = yield (0, NotionOnDevice_1.createNotionOnDevice)(Object.assign({}, options));
18
- const teardown = app(neurosity, skill);
19
- return {
20
- unsubscribe: () => __awaiter(this, void 0, void 0, function* () {
21
- yield neurosity.disconnect();
22
- if (teardown && "then" in teardown) {
23
- const cleanUp = yield teardown;
24
- if (typeof cleanUp === "function") {
25
- cleanUp();
26
- }
27
- }
28
- if (typeof teardown === "function" && "then" in teardown()) {
29
- return yield teardown();
30
- }
31
- if (typeof teardown === "function") {
32
- return teardown();
33
- }
34
- return teardown;
35
- })
36
- };
37
- })
38
- };
39
- }
40
- exports.createSkill = createSkill;
@@ -1,2 +0,0 @@
1
- export * from "./createSkill";
2
- export * from "./NotionOnDevice";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createSkill"), exports);
18
- __exportStar(require("./NotionOnDevice"), exports);
@@ -1,7 +0,0 @@
1
- import { Neurosity } from "../Notion";
2
- import { SDKOptions } from "../types/options";
3
- import { Skill } from "../types/skill";
4
- export declare type NotionOnDevice = Omit<Neurosity, "skill">;
5
- export interface OnDeviceOptions extends SDKOptions {
6
- skill: Skill;
7
- }
@@ -1,21 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Neurosity } from "../Notion";
11
- /**
12
- * @internal
13
- */
14
- export function createNotionOnDevice(options) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const neurosity = new Neurosity(options);
17
- const skill = Object.assign(Object.assign({}, (yield neurosity.skill(options.skill.bundleId))), { props: "props" in options.skill ? options.skill.props : {} });
18
- delete neurosity.skill;
19
- return [neurosity, skill];
20
- });
21
- }
@@ -1,7 +0,0 @@
1
- import { OnDeviceOptions, NotionOnDevice } from "./NotionOnDevice";
2
- import { SkillInstance, SkillSubscription } from "../types/skill";
3
- declare type SkillApp = (neurosity: NotionOnDevice, skill: SkillInstance) => () => Promise<void>;
4
- export declare function createSkill(app: SkillApp): {
5
- subscribe: (options: OnDeviceOptions) => Promise<SkillSubscription>;
6
- };
7
- export {};
@@ -1,36 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createNotionOnDevice } from "./NotionOnDevice";
11
- export function createSkill(app) {
12
- return {
13
- subscribe: (options) => __awaiter(this, void 0, void 0, function* () {
14
- const [neurosity, skill] = yield createNotionOnDevice(Object.assign({}, options));
15
- const teardown = app(neurosity, skill);
16
- return {
17
- unsubscribe: () => __awaiter(this, void 0, void 0, function* () {
18
- yield neurosity.disconnect();
19
- if (teardown && "then" in teardown) {
20
- const cleanUp = yield teardown;
21
- if (typeof cleanUp === "function") {
22
- cleanUp();
23
- }
24
- }
25
- if (typeof teardown === "function" && "then" in teardown()) {
26
- return yield teardown();
27
- }
28
- if (typeof teardown === "function") {
29
- return teardown();
30
- }
31
- return teardown;
32
- })
33
- };
34
- })
35
- };
36
- }
@@ -1,2 +0,0 @@
1
- export * from "./createSkill";
2
- export * from "./NotionOnDevice";
@@ -1,2 +0,0 @@
1
- export * from "./createSkill";
2
- export * from "./NotionOnDevice";