@sprucelabs/spruce-heartwood-utils 21.4.17 → 22.0.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.
@@ -15,5 +15,5 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
15
15
  getOrientation(): Orientation;
16
16
  enablePushNotifications(): void;
17
17
  signalSkillViewLoaded(): void;
18
- sendCommand(command: string, payload?: Record<string, any>): void;
18
+ sendCommand(command: string, payload?: Record<string, any>): Promise<void>;
19
19
  }
@@ -13,7 +13,7 @@ class HeartwoodDevice extends events_1.default {
13
13
  this.storage = storage;
14
14
  }
15
15
  openUrl(url) {
16
- this.sendCommand('openUrl', {
16
+ void this.sendCommand('openUrl', {
17
17
  url,
18
18
  });
19
19
  }
@@ -36,7 +36,7 @@ class HeartwoodDevice extends events_1.default {
36
36
  window.location.href = `tel:${phoneNumber}`;
37
37
  }
38
38
  vibrate() {
39
- this.sendCommand('vibrate');
39
+ void this.sendCommand('vibrate');
40
40
  }
41
41
  setOrientation(orientation) {
42
42
  this.orientation = orientation;
@@ -45,24 +45,24 @@ class HeartwoodDevice extends events_1.default {
45
45
  return this.orientation;
46
46
  }
47
47
  enablePushNotifications() {
48
- this.sendCommand('enablePushNotifications');
48
+ void this.sendCommand('enablePushNotifications');
49
49
  }
50
50
  signalSkillViewLoaded() {
51
- this.sendCommand('skillViewLoaded');
51
+ void this.sendCommand('skillViewLoaded');
52
52
  }
53
- sendCommand(command, payload) {
54
- var _a, _b, _c, _d;
53
+ async sendCommand(command, payload) {
54
+ var _a, _b, _c, _d, _e, _f, _g;
55
55
  const options = {
56
56
  command,
57
57
  payload,
58
58
  };
59
+ const message = JSON.stringify(options);
59
60
  //@ts-ignore
60
- (_d = (_c = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.postMessage) === null || _d === void 0 ? void 0 : _d.call(_c, JSON.stringify(options));
61
+ (_d = (_c = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.postMessage) === null || _d === void 0 ? void 0 : _d.call(_c, message);
61
62
  // @ts-ignore
62
- if (window.AndroidInterface) {
63
- // @ts-ignore
64
- window.AndroidInterface.postMessage(JSON.stringify(options));
65
- }
63
+ (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
64
+ //@ts-ignore
65
+ (_g = (_f = window.api) === null || _f === void 0 ? void 0 : _f.postMessage) === null || _g === void 0 ? void 0 : _g.call(_f, message);
66
66
  this.emit('command', command, payload);
67
67
  }
68
68
  }
@@ -15,5 +15,5 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
15
15
  getOrientation(): Orientation;
16
16
  enablePushNotifications(): void;
17
17
  signalSkillViewLoaded(): void;
18
- sendCommand(command: string, payload?: Record<string, any>): void;
18
+ sendCommand(command: string, payload?: Record<string, any>): Promise<void>;
19
19
  }
@@ -1,3 +1,12 @@
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
+ };
1
10
  import EventEmitter from 'events';
2
11
  import { assertOptions } from '@sprucelabs/schema';
3
12
  export class HeartwoodDevice extends EventEmitter {
@@ -7,7 +16,7 @@ export class HeartwoodDevice extends EventEmitter {
7
16
  this.storage = storage;
8
17
  }
9
18
  openUrl(url) {
10
- this.sendCommand('openUrl', {
19
+ void this.sendCommand('openUrl', {
11
20
  url,
12
21
  });
13
22
  }
@@ -30,7 +39,7 @@ export class HeartwoodDevice extends EventEmitter {
30
39
  window.location.href = `tel:${phoneNumber}`;
31
40
  }
32
41
  vibrate() {
33
- this.sendCommand('vibrate');
42
+ void this.sendCommand('vibrate');
34
43
  }
35
44
  setOrientation(orientation) {
36
45
  this.orientation = orientation;
@@ -39,24 +48,26 @@ export class HeartwoodDevice extends EventEmitter {
39
48
  return this.orientation;
40
49
  }
41
50
  enablePushNotifications() {
42
- this.sendCommand('enablePushNotifications');
51
+ void this.sendCommand('enablePushNotifications');
43
52
  }
44
53
  signalSkillViewLoaded() {
45
- this.sendCommand('skillViewLoaded');
54
+ void this.sendCommand('skillViewLoaded');
46
55
  }
47
56
  sendCommand(command, payload) {
48
- var _a, _b, _c, _d;
49
- const options = {
50
- command,
51
- payload,
52
- };
53
- //@ts-ignore
54
- (_d = (_c = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.postMessage) === null || _d === void 0 ? void 0 : _d.call(_c, JSON.stringify(options));
55
- // @ts-ignore
56
- if (window.AndroidInterface) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ var _a, _b, _c, _d, _e, _f, _g;
59
+ const options = {
60
+ command,
61
+ payload,
62
+ };
63
+ const message = JSON.stringify(options);
64
+ //@ts-ignore
65
+ (_d = (_c = (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.postMessage) === null || _d === void 0 ? void 0 : _d.call(_c, message);
57
66
  // @ts-ignore
58
- window.AndroidInterface.postMessage(JSON.stringify(options));
59
- }
60
- this.emit('command', command, payload);
67
+ (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
68
+ //@ts-ignore
69
+ (_g = (_f = window.api) === null || _f === void 0 ? void 0 : _f.postMessage) === null || _g === void 0 ? void 0 : _g.call(_f, message);
70
+ this.emit('command', command, payload);
71
+ });
61
72
  }
62
73
  }
@@ -4,11 +4,11 @@ export default class AutoLogoutViewPluginImpl {
4
4
  this.device = device;
5
5
  }
6
6
  enableAutoLogout(durationSec) {
7
- this.device.sendCommand('enableAutoLogout', {
7
+ void this.device.sendCommand('enableAutoLogout', {
8
8
  durationSec,
9
9
  });
10
10
  }
11
11
  disableAutoLogout() {
12
- this.device.sendCommand('disableAutoLogout', {});
12
+ void this.device.sendCommand('disableAutoLogout', {});
13
13
  }
14
14
  }
@@ -6,12 +6,12 @@ class AutoLogoutViewPluginImpl {
6
6
  this.device = device;
7
7
  }
8
8
  enableAutoLogout(durationSec) {
9
- this.device.sendCommand('enableAutoLogout', {
9
+ void this.device.sendCommand('enableAutoLogout', {
10
10
  durationSec,
11
11
  });
12
12
  }
13
13
  disableAutoLogout() {
14
- this.device.sendCommand('disableAutoLogout', {});
14
+ void this.device.sendCommand('disableAutoLogout', {});
15
15
  }
16
16
  }
17
17
  exports.default = AutoLogoutViewPluginImpl;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-heartwood-utils",
3
3
  "description": "Heartwood Utilities",
4
- "version": "21.4.17",
4
+ "version": "22.0.0",
5
5
  "skill": {
6
6
  "namespace": "heartwood"
7
7
  },