@sprucelabs/spruce-heartwood-utils 24.0.2 → 24.0.3
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.
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
private isGettingTheatreSetting;
|
|
8
8
|
protected constructor(storage: Storage);
|
|
9
9
|
openUrl(url: string): void;
|
|
10
10
|
static Device(storage: Storage): HeartwoodDevice;
|
|
@@ -18,5 +18,5 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
|
|
|
18
18
|
signalSkillViewLoaded(): void;
|
|
19
19
|
sendCommand(command: string, payload?: Record<string, any>): void;
|
|
20
20
|
setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
|
|
21
|
-
getTheatreSetting<N extends TheatreSettingName>(
|
|
21
|
+
getTheatreSetting<N extends TheatreSettingName>(name: N): Promise<TheaterSettingValueTypes[N] | null>;
|
|
22
22
|
}
|
|
@@ -10,7 +10,7 @@ class HeartwoodDevice extends events_1.default {
|
|
|
10
10
|
constructor(storage) {
|
|
11
11
|
super();
|
|
12
12
|
this.orientation = 'unknown-orientation';
|
|
13
|
-
this.
|
|
13
|
+
this.isGettingTheatreSetting = false;
|
|
14
14
|
this.storage = storage;
|
|
15
15
|
}
|
|
16
16
|
openUrl(url) {
|
|
@@ -58,7 +58,7 @@ class HeartwoodDevice extends events_1.default {
|
|
|
58
58
|
payload,
|
|
59
59
|
};
|
|
60
60
|
const message = JSON.stringify(options);
|
|
61
|
-
if (!this.
|
|
61
|
+
if (!this.isGettingTheatreSetting) {
|
|
62
62
|
//@ts-ignore
|
|
63
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
64
|
// @ts-ignore
|
|
@@ -74,24 +74,28 @@ class HeartwoodDevice extends events_1.default {
|
|
|
74
74
|
value,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
async getTheatreSetting(
|
|
77
|
+
async getTheatreSetting(name) {
|
|
78
78
|
//@ts-ignore
|
|
79
79
|
if (window.api) {
|
|
80
|
-
this.
|
|
81
|
-
this.sendCommand('
|
|
82
|
-
|
|
80
|
+
this.isGettingTheatreSetting = true;
|
|
81
|
+
this.sendCommand('getTheatreSetting', {
|
|
82
|
+
name,
|
|
83
|
+
});
|
|
84
|
+
this.isGettingTheatreSetting = false;
|
|
83
85
|
}
|
|
84
86
|
else {
|
|
85
|
-
return
|
|
87
|
+
return null;
|
|
86
88
|
}
|
|
87
89
|
return new Promise((resolve) => {
|
|
88
90
|
var _a, _b;
|
|
89
|
-
let timeout = setTimeout(() => resolve(
|
|
91
|
+
let timeout = setTimeout(() => resolve(null), 250);
|
|
90
92
|
//@ts-ignore
|
|
91
93
|
(_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
|
-
|
|
94
|
-
|
|
94
|
+
const { value, name: returnedName } = JSON.parse(json);
|
|
95
|
+
if (name === returnedName) {
|
|
96
|
+
clearTimeout(timeout);
|
|
97
|
+
resolve(value);
|
|
98
|
+
}
|
|
95
99
|
});
|
|
96
100
|
});
|
|
97
101
|
}
|
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
private isGettingTheatreSetting;
|
|
8
8
|
protected constructor(storage: Storage);
|
|
9
9
|
openUrl(url: string): void;
|
|
10
10
|
static Device(storage: Storage): HeartwoodDevice;
|
|
@@ -18,5 +18,5 @@ export declare class HeartwoodDevice extends EventEmitter implements Device {
|
|
|
18
18
|
signalSkillViewLoaded(): void;
|
|
19
19
|
sendCommand(command: string, payload?: Record<string, any>): void;
|
|
20
20
|
setTheatreSetting<N extends TheatreSettingName>(name: N, value: TheaterSettingValueTypes[N]): void;
|
|
21
|
-
getTheatreSetting<N extends TheatreSettingName>(
|
|
21
|
+
getTheatreSetting<N extends TheatreSettingName>(name: N): Promise<TheaterSettingValueTypes[N] | null>;
|
|
22
22
|
}
|
|
@@ -13,7 +13,7 @@ export class HeartwoodDevice extends EventEmitter {
|
|
|
13
13
|
constructor(storage) {
|
|
14
14
|
super();
|
|
15
15
|
this.orientation = 'unknown-orientation';
|
|
16
|
-
this.
|
|
16
|
+
this.isGettingTheatreSetting = false;
|
|
17
17
|
this.storage = storage;
|
|
18
18
|
}
|
|
19
19
|
openUrl(url) {
|
|
@@ -61,7 +61,7 @@ export class HeartwoodDevice extends EventEmitter {
|
|
|
61
61
|
payload,
|
|
62
62
|
};
|
|
63
63
|
const message = JSON.stringify(options);
|
|
64
|
-
if (!this.
|
|
64
|
+
if (!this.isGettingTheatreSetting) {
|
|
65
65
|
//@ts-ignore
|
|
66
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
67
|
// @ts-ignore
|
|
@@ -77,25 +77,29 @@ export class HeartwoodDevice extends EventEmitter {
|
|
|
77
77
|
value,
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
getTheatreSetting(
|
|
80
|
+
getTheatreSetting(name) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
82
|
//@ts-ignore
|
|
83
83
|
if (window.api) {
|
|
84
|
-
this.
|
|
85
|
-
this.sendCommand('
|
|
86
|
-
|
|
84
|
+
this.isGettingTheatreSetting = true;
|
|
85
|
+
this.sendCommand('getTheatreSetting', {
|
|
86
|
+
name,
|
|
87
|
+
});
|
|
88
|
+
this.isGettingTheatreSetting = false;
|
|
87
89
|
}
|
|
88
90
|
else {
|
|
89
|
-
return
|
|
91
|
+
return null;
|
|
90
92
|
}
|
|
91
93
|
return new Promise((resolve) => {
|
|
92
94
|
var _a, _b;
|
|
93
|
-
let timeout = setTimeout(() => resolve(
|
|
95
|
+
let timeout = setTimeout(() => resolve(null), 250);
|
|
94
96
|
//@ts-ignore
|
|
95
97
|
(_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
|
-
|
|
98
|
-
|
|
98
|
+
const { value, name: returnedName } = JSON.parse(json);
|
|
99
|
+
if (name === returnedName) {
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
resolve(value);
|
|
102
|
+
}
|
|
99
103
|
});
|
|
100
104
|
});
|
|
101
105
|
});
|