@sprucelabs/spruce-heartwood-utils 23.0.0 → 24.0.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/README.md CHANGED
@@ -16,4 +16,3 @@ Spruce XP Documentation
16
16
  <p align="center">
17
17
  <a href="https://developer.spruce.ai/#/"><img width="250" src="./docs/images/read-full-docs.png" /></a>
18
18
  </p>
19
-
@@ -1,9 +1,10 @@
1
1
  import EventEmitter from 'events';
2
- import { CachedValue, Device } from '@sprucelabs/heartwood-view-controllers';
2
+ import { CachedValue, Device, TheaterSettingValueTypes, TheatreSettingName } from '@sprucelabs/heartwood-view-controllers';
3
3
  import { Orientation } from '../types/heartwood.types';
4
4
  export declare class HeartwoodDevice extends EventEmitter implements Device {
5
5
  private storage;
6
6
  private orientation;
7
+ private isGettingKiosk;
7
8
  protected constructor(storage: Storage);
8
9
  openUrl(url: string): void;
9
10
  static Device(storage: Storage): HeartwoodDevice;
@@ -16,6 +17,6 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
16
17
  enablePushNotifications(): void;
17
18
  signalSkillViewLoaded(): void;
18
19
  sendCommand(command: string, payload?: Record<string, any>): void;
19
- getIsKioskModeEnabled(): Promise<boolean>;
20
- setIsKioskModeEnabled(_isKiosk: boolean): void;
20
+ setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
21
+ getTheatreSetting<N extends TheatreSettingName>(_name: N): Promise<TheaterSettingValueTypes[N] | null>;
21
22
  }
@@ -10,6 +10,7 @@ class HeartwoodDevice extends events_1.default {
10
10
  constructor(storage) {
11
11
  super();
12
12
  this.orientation = 'unknown-orientation';
13
+ this.isGettingKiosk = false;
13
14
  this.storage = storage;
14
15
  }
15
16
  openUrl(url) {
@@ -45,10 +46,10 @@ class HeartwoodDevice extends events_1.default {
45
46
  return this.orientation;
46
47
  }
47
48
  enablePushNotifications() {
48
- void this.sendCommand('enablePushNotifications');
49
+ this.sendCommand('enablePushNotifications');
49
50
  }
50
51
  signalSkillViewLoaded() {
51
- void this.sendCommand('skillViewLoaded');
52
+ this.sendCommand('skillViewLoaded');
52
53
  }
53
54
  sendCommand(command, payload) {
54
55
  var _a, _b, _c, _d, _e, _f, _g;
@@ -57,18 +58,43 @@ class HeartwoodDevice extends events_1.default {
57
58
  payload,
58
59
  };
59
60
  const message = JSON.stringify(options);
60
- //@ts-ignore
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);
62
- // @ts-ignore
63
- (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
61
+ if (!this.isGettingKiosk) {
62
+ //@ts-ignore
63
+ (_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);
64
+ // @ts-ignore
65
+ (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
66
+ }
64
67
  //@ts-ignore
65
68
  (_g = (_f = window.api) === null || _f === void 0 ? void 0 : _f.postMessage) === null || _g === void 0 ? void 0 : _g.call(_f, message);
66
69
  this.emit('command', command, payload);
67
70
  }
68
- async getIsKioskModeEnabled() {
69
- return false;
71
+ setTheatreSetting(name, value) {
72
+ this.sendCommand('setTheatreSetting', {
73
+ name,
74
+ value,
75
+ });
76
+ }
77
+ async getTheatreSetting(_name) {
78
+ //@ts-ignore
79
+ if (window.api) {
80
+ this.isGettingKiosk = true;
81
+ this.sendCommand('getIsKioskModeEnabled');
82
+ this.isGettingKiosk = false;
83
+ }
84
+ else {
85
+ return false;
86
+ }
87
+ return new Promise((resolve) => {
88
+ var _a, _b;
89
+ let timeout = setTimeout(() => resolve(false), 250);
90
+ //@ts-ignore
91
+ (_b = (_a = window.api) === null || _a === void 0 ? void 0 : _a.onMessage) === null || _b === void 0 ? void 0 : _b.call(_a, (json) => {
92
+ const { value } = JSON.parse(json);
93
+ clearTimeout(timeout);
94
+ resolve(value);
95
+ });
96
+ });
70
97
  }
71
- setIsKioskModeEnabled(_isKiosk) { }
72
98
  }
73
99
  exports.HeartwoodDevice = HeartwoodDevice;
74
100
  //# sourceMappingURL=HeartwoodDevice.js.map
@@ -1,9 +1,10 @@
1
1
  import EventEmitter from 'events';
2
- import { CachedValue, Device } from '@sprucelabs/heartwood-view-controllers';
2
+ import { CachedValue, Device, TheaterSettingValueTypes, TheatreSettingName } from '@sprucelabs/heartwood-view-controllers';
3
3
  import { Orientation } from '../types/heartwood.types';
4
4
  export declare class HeartwoodDevice extends EventEmitter implements Device {
5
5
  private storage;
6
6
  private orientation;
7
+ private isGettingKiosk;
7
8
  protected constructor(storage: Storage);
8
9
  openUrl(url: string): void;
9
10
  static Device(storage: Storage): HeartwoodDevice;
@@ -16,6 +17,6 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
16
17
  enablePushNotifications(): void;
17
18
  signalSkillViewLoaded(): void;
18
19
  sendCommand(command: string, payload?: Record<string, any>): void;
19
- getIsKioskModeEnabled(): Promise<boolean>;
20
- setIsKioskModeEnabled(_isKiosk: boolean): void;
20
+ setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
21
+ getTheatreSetting<N extends TheatreSettingName>(_name: N): Promise<TheaterSettingValueTypes[N] | null>;
21
22
  }
@@ -13,6 +13,7 @@ export class HeartwoodDevice extends EventEmitter {
13
13
  constructor(storage) {
14
14
  super();
15
15
  this.orientation = 'unknown-orientation';
16
+ this.isGettingKiosk = false;
16
17
  this.storage = storage;
17
18
  }
18
19
  openUrl(url) {
@@ -48,10 +49,10 @@ export class HeartwoodDevice extends EventEmitter {
48
49
  return this.orientation;
49
50
  }
50
51
  enablePushNotifications() {
51
- void this.sendCommand('enablePushNotifications');
52
+ this.sendCommand('enablePushNotifications');
52
53
  }
53
54
  signalSkillViewLoaded() {
54
- void this.sendCommand('skillViewLoaded');
55
+ this.sendCommand('skillViewLoaded');
55
56
  }
56
57
  sendCommand(command, payload) {
57
58
  var _a, _b, _c, _d, _e, _f, _g;
@@ -60,18 +61,43 @@ export class HeartwoodDevice extends EventEmitter {
60
61
  payload,
61
62
  };
62
63
  const message = JSON.stringify(options);
63
- //@ts-ignore
64
- (_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);
65
- // @ts-ignore
66
- (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
64
+ if (!this.isGettingKiosk) {
65
+ //@ts-ignore
66
+ (_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);
67
+ // @ts-ignore
68
+ (_e = window.AndroidInterface) === null || _e === void 0 ? void 0 : _e.postMessage(message);
69
+ }
67
70
  //@ts-ignore
68
71
  (_g = (_f = window.api) === null || _f === void 0 ? void 0 : _f.postMessage) === null || _g === void 0 ? void 0 : _g.call(_f, message);
69
72
  this.emit('command', command, payload);
70
73
  }
71
- getIsKioskModeEnabled() {
74
+ setTheatreSetting(name, value) {
75
+ this.sendCommand('setTheatreSetting', {
76
+ name,
77
+ value,
78
+ });
79
+ }
80
+ getTheatreSetting(_name) {
72
81
  return __awaiter(this, void 0, void 0, function* () {
73
- return false;
82
+ //@ts-ignore
83
+ if (window.api) {
84
+ this.isGettingKiosk = true;
85
+ this.sendCommand('getIsKioskModeEnabled');
86
+ this.isGettingKiosk = false;
87
+ }
88
+ else {
89
+ return false;
90
+ }
91
+ return new Promise((resolve) => {
92
+ var _a, _b;
93
+ let timeout = setTimeout(() => resolve(false), 250);
94
+ //@ts-ignore
95
+ (_b = (_a = window.api) === null || _a === void 0 ? void 0 : _a.onMessage) === null || _b === void 0 ? void 0 : _b.call(_a, (json) => {
96
+ const { value } = JSON.parse(json);
97
+ clearTimeout(timeout);
98
+ resolve(value);
99
+ });
100
+ });
74
101
  });
75
102
  }
76
- setIsKioskModeEnabled(_isKiosk) { }
77
103
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-heartwood-utils",
3
3
  "description": "Heartwood Utilities",
4
- "version": "23.0.0",
4
+ "version": "24.0.1",
5
5
  "skill": {
6
6
  "namespace": "heartwood"
7
7
  },