desktopr 1.2.1 → 1.2.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.
package/dist-sdk/_constants.d.ts
CHANGED
package/dist-sdk/_constants.js
CHANGED
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.READY_EVENT_NAME = exports.COMAPNION_WINDOW_LABEL_PREFIX = exports.APP_VERSION = exports.APP_URL = void 0;
|
|
6
|
+
exports.WINDOWS_LABELS_TRACKER_VARIABLE_NAME = exports.READY_EVENT_NAME = exports.COMAPNION_WINDOW_LABEL_PREFIX = exports.APP_VERSION = exports.APP_URL = void 0;
|
|
7
7
|
const bridge_constants_json_1 = __importDefault(require("./bridge.constants.json"));
|
|
8
8
|
exports.APP_URL = bridge_constants_json_1.default.appUrl;
|
|
9
9
|
exports.APP_VERSION = bridge_constants_json_1.default.appVersion;
|
|
10
10
|
exports.COMAPNION_WINDOW_LABEL_PREFIX = bridge_constants_json_1.default.companionWindowLabelPrefix;
|
|
11
11
|
exports.READY_EVENT_NAME = "dtrReady";
|
|
12
|
+
exports.WINDOWS_LABELS_TRACKER_VARIABLE_NAME = "open-windows-labels-tracker-rpkw6kjzxn8bfhj5u74q";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newWindow = exports.waitTauri = exports.tauriReadyCheck = void 0;
|
|
3
|
+
exports.closeWindow = exports.newWindow = exports.waitTauri = exports.tauriReadyCheck = void 0;
|
|
4
|
+
const sdk_1 = require("../../../sdk");
|
|
4
5
|
const _constants_1 = require("../../../_constants");
|
|
5
6
|
const utils_1 = require("suffro-lib/utils");
|
|
6
7
|
const tauriReadyCheck = () => typeof window !== "undefined" &&
|
|
@@ -26,10 +27,39 @@ const newWindow = async (core, options) => {
|
|
|
26
27
|
const randomWindowLabel = `w_${Math.random()
|
|
27
28
|
.toString(36)
|
|
28
29
|
.substring(2, 2 + 8)}`;
|
|
30
|
+
const labelToSet = (options?.label) ?? randomWindowLabel;
|
|
31
|
+
try {
|
|
32
|
+
const usedLabelsJSON = await sdk_1.Desktopr.globalVariables.get(_constants_1.WINDOWS_LABELS_TRACKER_VARIABLE_NAME);
|
|
33
|
+
let usedLabelsObj = await JSON.parse(usedLabelsJSON);
|
|
34
|
+
usedLabelsObj[labelToSet] = true;
|
|
35
|
+
const updatedUsedLabelsJSON = JSON.stringify(usedLabelsObj);
|
|
36
|
+
await sdk_1.Desktopr.globalVariables.set(_constants_1.WINDOWS_LABELS_TRACKER_VARIABLE_NAME, updatedUsedLabelsJSON);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.warn("Could not update used windows labels tracker");
|
|
40
|
+
}
|
|
29
41
|
core.invoke("dtr_win_open", {
|
|
30
|
-
label:
|
|
31
|
-
fullscreen: options?.fullscreen || false,
|
|
32
|
-
url: options?.url ?? "",
|
|
42
|
+
label: labelToSet,
|
|
43
|
+
fullscreen: (options?.fullscreen) || false,
|
|
44
|
+
url: (options?.url) ?? "",
|
|
33
45
|
});
|
|
34
46
|
};
|
|
35
47
|
exports.newWindow = newWindow;
|
|
48
|
+
const closeWindow = async (core, label) => {
|
|
49
|
+
const trimmedLabel = (label?.trim()) ?? "";
|
|
50
|
+
const _label = trimmedLabel ?? "main";
|
|
51
|
+
try {
|
|
52
|
+
if (trimmedLabel) {
|
|
53
|
+
const usedLabelsJSON = await sdk_1.Desktopr.globalVariables.get(_constants_1.WINDOWS_LABELS_TRACKER_VARIABLE_NAME);
|
|
54
|
+
let usedLabelsObj = await JSON.parse(usedLabelsJSON);
|
|
55
|
+
delete usedLabelsObj[trimmedLabel];
|
|
56
|
+
const updatedUsedLabelsJSON = JSON.stringify(usedLabelsObj);
|
|
57
|
+
await sdk_1.Desktopr.globalVariables.set(_constants_1.WINDOWS_LABELS_TRACKER_VARIABLE_NAME, updatedUsedLabelsJSON);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.warn("Could not update used windows labels tracker");
|
|
62
|
+
}
|
|
63
|
+
core.invoke("dtr_win_close", { _label });
|
|
64
|
+
};
|
|
65
|
+
exports.closeWindow = closeWindow;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildWindow = buildWindow;
|
|
4
4
|
const _helpers_1 = require("../companion/_helpers");
|
|
5
|
+
const _helpers_2 = require("./_helpers");
|
|
5
6
|
function buildWindow(core) {
|
|
6
7
|
const randomWindowLabel = `w_${Math.random().toString(36).substring(2, 2 + 8)}`;
|
|
7
8
|
return {
|
|
@@ -21,13 +22,9 @@ function buildWindow(core) {
|
|
|
21
22
|
openFullscreen: options?.fullscreen
|
|
22
23
|
});
|
|
23
24
|
else
|
|
24
|
-
|
|
25
|
-
label: ((options?.label) ?? randomWindowLabel),
|
|
26
|
-
fullscreen: ((options?.fullscreen) || false),
|
|
27
|
-
url: ((options?.url) ?? "")
|
|
28
|
-
});
|
|
25
|
+
(0, _helpers_2.newWindow)(core, options);
|
|
29
26
|
},
|
|
30
|
-
close: (label) =>
|
|
27
|
+
close: (label) => (0, _helpers_2.closeWindow)(core, label),
|
|
31
28
|
getInfo: (label) => core.invoke("dtr_win_get_info", { label }),
|
|
32
29
|
state: {}
|
|
33
30
|
};
|