feat: update dependencies
This commit is contained in:
parent
55fe1d144f
commit
3e087bd257
16 changed files with 2004 additions and 474 deletions
|
@ -74,7 +74,8 @@ async function message(message2, options) {
|
|||
cmd: "messageDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabel: opts?.okLabel?.toString()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -86,7 +87,11 @@ async function ask(message2, options) {
|
|||
cmd: "askDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabels: [
|
||||
opts?.okLabel?.toString() ?? "Yes",
|
||||
opts?.cancelLabel?.toString() ?? "No"
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -98,7 +103,11 @@ async function confirm(message2, options) {
|
|||
cmd: "confirmDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabels: [
|
||||
opts?.okLabel?.toString() ?? "Ok",
|
||||
opts?.cancelLabel?.toString() ?? "Cancel"
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
66
src/http.js
66
src/http.js
|
@ -48,40 +48,47 @@ var ResponseType = /* @__PURE__ */ ((ResponseType2) => {
|
|||
ResponseType2[ResponseType2["Binary"] = 3] = "Binary";
|
||||
return ResponseType2;
|
||||
})(ResponseType || {});
|
||||
async function formBody(data) {
|
||||
const form = {};
|
||||
const append = async (key, v) => {
|
||||
if (v !== null) {
|
||||
let r;
|
||||
if (typeof v === "string") {
|
||||
r = v;
|
||||
} else if (v instanceof Uint8Array || Array.isArray(v)) {
|
||||
r = Array.from(v);
|
||||
} else if (v instanceof File) {
|
||||
r = {
|
||||
file: Array.from(new Uint8Array(await v.arrayBuffer())),
|
||||
mime: v.type,
|
||||
fileName: v.name
|
||||
};
|
||||
} else if (typeof v.file === "string") {
|
||||
r = { file: v.file, mime: v.mime, fileName: v.fileName };
|
||||
} else {
|
||||
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName };
|
||||
}
|
||||
form[String(key)] = r;
|
||||
}
|
||||
};
|
||||
if (data instanceof FormData) {
|
||||
for (const [key, value] of data) {
|
||||
await append(key, value);
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
await append(key, value);
|
||||
}
|
||||
}
|
||||
return form;
|
||||
}
|
||||
var Body = class {
|
||||
constructor(type, payload) {
|
||||
this.type = type;
|
||||
this.payload = payload;
|
||||
}
|
||||
static form(data) {
|
||||
const form = {};
|
||||
const append = (key, v) => {
|
||||
if (v !== null) {
|
||||
let r;
|
||||
if (typeof v === "string") {
|
||||
r = v;
|
||||
} else if (v instanceof Uint8Array || Array.isArray(v)) {
|
||||
r = Array.from(v);
|
||||
} else if (v instanceof File) {
|
||||
r = { file: v.name, mime: v.type, fileName: v.name };
|
||||
} else if (typeof v.file === "string") {
|
||||
r = { file: v.file, mime: v.mime, fileName: v.fileName };
|
||||
} else {
|
||||
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName };
|
||||
}
|
||||
form[String(key)] = r;
|
||||
}
|
||||
};
|
||||
if (data instanceof FormData) {
|
||||
for (const [key, value] of data) {
|
||||
append(key, value);
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
append(key, value);
|
||||
}
|
||||
}
|
||||
return new Body("Form", form);
|
||||
return new Body("Form", data);
|
||||
}
|
||||
static json(data) {
|
||||
return new Body("Json", data);
|
||||
|
@ -124,6 +131,9 @@ var Client = class {
|
|||
if (jsonResponse) {
|
||||
options.responseType = 2 /* Text */;
|
||||
}
|
||||
if (options.body?.type === "Form") {
|
||||
options.body.payload = await formBody(options.body.payload);
|
||||
}
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Http",
|
||||
message: {
|
||||
|
|
277
src/index.js
277
src/index.js
|
@ -58,8 +58,7 @@ async function invoke(cmd, args = {}) {
|
|||
});
|
||||
}
|
||||
function convertFileSrc(filePath, protocol = "asset") {
|
||||
const path = encodeURIComponent(filePath);
|
||||
return navigator.userAgent.includes("Windows") ? `https://${protocol}.localhost/${path}` : `${protocol}://localhost/${path}`;
|
||||
return window.__TAURI__.convertFileSrc(filePath, protocol);
|
||||
}
|
||||
|
||||
// tauri/tooling/api/src/helpers/tauri.ts
|
||||
|
@ -189,7 +188,8 @@ async function message(message2, options) {
|
|||
cmd: "messageDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabel: opts?.okLabel?.toString()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -201,7 +201,11 @@ async function ask(message2, options) {
|
|||
cmd: "askDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabels: [
|
||||
opts?.okLabel?.toString() ?? "Yes",
|
||||
opts?.cancelLabel?.toString() ?? "No"
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -213,7 +217,11 @@ async function confirm(message2, options) {
|
|||
cmd: "confirmDialog",
|
||||
message: message2.toString(),
|
||||
title: opts?.title?.toString(),
|
||||
type: opts?.type
|
||||
type: opts?.type,
|
||||
buttonLabels: [
|
||||
opts?.okLabel?.toString() ?? "Ok",
|
||||
opts?.cancelLabel?.toString() ?? "Cancel"
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -576,40 +584,47 @@ var ResponseType = /* @__PURE__ */ ((ResponseType2) => {
|
|||
ResponseType2[ResponseType2["Binary"] = 3] = "Binary";
|
||||
return ResponseType2;
|
||||
})(ResponseType || {});
|
||||
async function formBody(data) {
|
||||
const form = {};
|
||||
const append = async (key, v) => {
|
||||
if (v !== null) {
|
||||
let r;
|
||||
if (typeof v === "string") {
|
||||
r = v;
|
||||
} else if (v instanceof Uint8Array || Array.isArray(v)) {
|
||||
r = Array.from(v);
|
||||
} else if (v instanceof File) {
|
||||
r = {
|
||||
file: Array.from(new Uint8Array(await v.arrayBuffer())),
|
||||
mime: v.type,
|
||||
fileName: v.name
|
||||
};
|
||||
} else if (typeof v.file === "string") {
|
||||
r = { file: v.file, mime: v.mime, fileName: v.fileName };
|
||||
} else {
|
||||
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName };
|
||||
}
|
||||
form[String(key)] = r;
|
||||
}
|
||||
};
|
||||
if (data instanceof FormData) {
|
||||
for (const [key, value] of data) {
|
||||
await append(key, value);
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
await append(key, value);
|
||||
}
|
||||
}
|
||||
return form;
|
||||
}
|
||||
var Body = class {
|
||||
constructor(type2, payload) {
|
||||
this.type = type2;
|
||||
this.payload = payload;
|
||||
}
|
||||
static form(data) {
|
||||
const form = {};
|
||||
const append = (key, v) => {
|
||||
if (v !== null) {
|
||||
let r;
|
||||
if (typeof v === "string") {
|
||||
r = v;
|
||||
} else if (v instanceof Uint8Array || Array.isArray(v)) {
|
||||
r = Array.from(v);
|
||||
} else if (v instanceof File) {
|
||||
r = { file: v.name, mime: v.type, fileName: v.name };
|
||||
} else if (typeof v.file === "string") {
|
||||
r = { file: v.file, mime: v.mime, fileName: v.fileName };
|
||||
} else {
|
||||
r = { file: Array.from(v.file), mime: v.mime, fileName: v.fileName };
|
||||
}
|
||||
form[String(key)] = r;
|
||||
}
|
||||
};
|
||||
if (data instanceof FormData) {
|
||||
for (const [key, value] of data) {
|
||||
append(key, value);
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
append(key, value);
|
||||
}
|
||||
}
|
||||
return new Body("Form", form);
|
||||
return new Body("Form", data);
|
||||
}
|
||||
static json(data) {
|
||||
return new Body("Json", data);
|
||||
|
@ -652,6 +667,9 @@ var Client = class {
|
|||
if (jsonResponse) {
|
||||
options.responseType = 2 /* Text */;
|
||||
}
|
||||
if (options.body?.type === "Form") {
|
||||
options.body.payload = await formBody(options.body.payload);
|
||||
}
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Http",
|
||||
message: {
|
||||
|
@ -1353,11 +1371,12 @@ async function installUpdate() {
|
|||
function onStatusChange(statusResult) {
|
||||
if (statusResult.error) {
|
||||
cleanListener();
|
||||
return reject(statusResult.error);
|
||||
reject(statusResult.error);
|
||||
return;
|
||||
}
|
||||
if (statusResult.status === "DONE") {
|
||||
cleanListener();
|
||||
return resolve2();
|
||||
resolve2();
|
||||
}
|
||||
}
|
||||
onUpdaterEvent(onStatusChange).then((fn) => {
|
||||
|
@ -1383,7 +1402,7 @@ async function checkUpdate() {
|
|||
return new Promise((resolve2, reject) => {
|
||||
function onUpdateAvailable(manifest) {
|
||||
cleanListener();
|
||||
return resolve2({
|
||||
resolve2({
|
||||
manifest,
|
||||
shouldUpdate: true
|
||||
});
|
||||
|
@ -1391,11 +1410,12 @@ async function checkUpdate() {
|
|||
function onStatusChange(statusResult) {
|
||||
if (statusResult.error) {
|
||||
cleanListener();
|
||||
return reject(statusResult.error);
|
||||
reject(statusResult.error);
|
||||
return;
|
||||
}
|
||||
if (statusResult.status === "UPTODATE") {
|
||||
cleanListener();
|
||||
return resolve2({
|
||||
resolve2({
|
||||
shouldUpdate: false
|
||||
});
|
||||
}
|
||||
|
@ -1619,6 +1639,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isMinimized() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMinimized"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isMaximized() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -1633,6 +1667,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isFocused() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isFocused"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isDecorated() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -1661,6 +1709,48 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isMaximizable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMaximizable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isMinimizable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMinimizable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isClosable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isClosable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isVisible() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -1675,6 +1765,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async title() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "title"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async theme() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -1741,6 +1845,51 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async setMaximizable(maximizable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setMaximizable",
|
||||
payload: maximizable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setMinimizable(minimizable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setMinimizable",
|
||||
payload: minimizable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setClosable(closable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setClosable",
|
||||
payload: closable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setTitle(title) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -1898,6 +2047,21 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async setContentProtected(protected_) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setContentProtected",
|
||||
payload: protected_
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setSize(size) {
|
||||
if (!size || size.type !== "Logical" && size.type !== "Physical") {
|
||||
throw new Error(
|
||||
|
@ -2164,10 +2328,16 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
});
|
||||
}
|
||||
async onResized(handler) {
|
||||
return this.listen("tauri://resize" /* WINDOW_RESIZED */, handler);
|
||||
return this.listen("tauri://resize" /* WINDOW_RESIZED */, (e) => {
|
||||
e.payload = mapPhysicalSize(e.payload);
|
||||
handler(e);
|
||||
});
|
||||
}
|
||||
async onMoved(handler) {
|
||||
return this.listen("tauri://move" /* WINDOW_MOVED */, handler);
|
||||
return this.listen("tauri://move" /* WINDOW_MOVED */, (e) => {
|
||||
e.payload = mapPhysicalPosition(e.payload);
|
||||
handler(e);
|
||||
});
|
||||
}
|
||||
async onCloseRequested(handler) {
|
||||
return this.listen("tauri://close-requested" /* WINDOW_CLOSE_REQUESTED */, (event) => {
|
||||
|
@ -2273,6 +2443,14 @@ var WebviewWindow = class extends WindowManager {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
static async getFocusedWindow() {
|
||||
for (const w of getAll()) {
|
||||
if (await w.isFocused()) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
var appWindow;
|
||||
if ("__TAURI_METADATA__" in window) {
|
||||
|
@ -2295,10 +2473,16 @@ function mapMonitor(m) {
|
|||
return m === null ? null : {
|
||||
name: m.name,
|
||||
scaleFactor: m.scaleFactor,
|
||||
position: new PhysicalPosition(m.position.x, m.position.y),
|
||||
size: new PhysicalSize(m.size.width, m.size.height)
|
||||
position: mapPhysicalPosition(m.position),
|
||||
size: mapPhysicalSize(m.size)
|
||||
};
|
||||
}
|
||||
function mapPhysicalPosition(m) {
|
||||
return new PhysicalPosition(m.x, m.y);
|
||||
}
|
||||
function mapPhysicalSize(m) {
|
||||
return new PhysicalSize(m.width, m.height);
|
||||
}
|
||||
async function currentMonitor() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -2344,6 +2528,7 @@ var os_exports = {};
|
|||
__export(os_exports, {
|
||||
EOL: () => EOL,
|
||||
arch: () => arch,
|
||||
locale: () => locale,
|
||||
platform: () => platform,
|
||||
tempdir: () => tempdir,
|
||||
type: () => type,
|
||||
|
@ -2390,6 +2575,14 @@ async function tempdir() {
|
|||
}
|
||||
});
|
||||
}
|
||||
async function locale() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Os",
|
||||
message: {
|
||||
cmd: "locale"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// tauri/tooling/api/src/index.ts
|
||||
var invoke2 = invoke;
|
||||
|
|
16
src/mocks.js
16
src/mocks.js
|
@ -19,12 +19,24 @@ function mockWindows(current, ...additionalWindows) {
|
|||
__currentWindow: { label: current }
|
||||
};
|
||||
}
|
||||
function mockConvertFileSrc(osName, windowsProtocolScheme = "https") {
|
||||
window.__TAURI__ = window.__TAURI__ ?? {};
|
||||
window.__TAURI__.convertFileSrc = function(filePath, protocol = "asset") {
|
||||
const path = encodeURIComponent(filePath);
|
||||
return osName === "windows" ? `${windowsProtocolScheme}://${protocol}.localhost/${path}` : `${protocol}://localhost/${path}`;
|
||||
};
|
||||
}
|
||||
function clearMocks() {
|
||||
delete window.__TAURI_IPC__;
|
||||
delete window.__TAURI_METADATA__;
|
||||
if (window.__TAURI__?.convertFileSrc)
|
||||
delete window.__TAURI__.convertFileSrc;
|
||||
if (window.__TAURI_IPC__)
|
||||
delete window.__TAURI_IPC__;
|
||||
if (window.__TAURI_METADATA__)
|
||||
delete window.__TAURI_METADATA__;
|
||||
}
|
||||
export {
|
||||
clearMocks,
|
||||
mockConvertFileSrc,
|
||||
mockIPC,
|
||||
mockWindows
|
||||
};
|
||||
|
|
|
@ -88,9 +88,18 @@ async function tempdir() {
|
|||
}
|
||||
});
|
||||
}
|
||||
async function locale() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Os",
|
||||
message: {
|
||||
cmd: "locale"
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
EOL,
|
||||
arch,
|
||||
locale,
|
||||
platform,
|
||||
tempdir,
|
||||
type,
|
||||
|
|
|
@ -36,8 +36,7 @@ async function invoke(cmd, args = {}) {
|
|||
});
|
||||
}
|
||||
function convertFileSrc(filePath, protocol = "asset") {
|
||||
const path = encodeURIComponent(filePath);
|
||||
return navigator.userAgent.includes("Windows") ? `https://${protocol}.localhost/${path}` : `${protocol}://localhost/${path}`;
|
||||
return window.__TAURI__.convertFileSrc(filePath, protocol);
|
||||
}
|
||||
export {
|
||||
convertFileSrc,
|
||||
|
|
|
@ -113,11 +113,12 @@ async function installUpdate() {
|
|||
function onStatusChange(statusResult) {
|
||||
if (statusResult.error) {
|
||||
cleanListener();
|
||||
return reject(statusResult.error);
|
||||
reject(statusResult.error);
|
||||
return;
|
||||
}
|
||||
if (statusResult.status === "DONE") {
|
||||
cleanListener();
|
||||
return resolve();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
onUpdaterEvent(onStatusChange).then((fn) => {
|
||||
|
@ -143,7 +144,7 @@ async function checkUpdate() {
|
|||
return new Promise((resolve, reject) => {
|
||||
function onUpdateAvailable(manifest) {
|
||||
cleanListener();
|
||||
return resolve({
|
||||
resolve({
|
||||
manifest,
|
||||
shouldUpdate: true
|
||||
});
|
||||
|
@ -151,11 +152,12 @@ async function checkUpdate() {
|
|||
function onStatusChange(statusResult) {
|
||||
if (statusResult.error) {
|
||||
cleanListener();
|
||||
return reject(statusResult.error);
|
||||
reject(statusResult.error);
|
||||
return;
|
||||
}
|
||||
if (statusResult.status === "UPTODATE") {
|
||||
cleanListener();
|
||||
return resolve({
|
||||
resolve({
|
||||
shouldUpdate: false
|
||||
});
|
||||
}
|
||||
|
|
172
src/window.js
172
src/window.js
|
@ -266,6 +266,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isMinimized() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMinimized"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isMaximized() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -280,6 +294,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isFocused() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isFocused"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isDecorated() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -308,6 +336,48 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async isMaximizable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMaximizable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isMinimizable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isMinimizable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isClosable() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "isClosable"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async isVisible() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -322,6 +392,20 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async title() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "title"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async theme() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -388,6 +472,51 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async setMaximizable(maximizable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setMaximizable",
|
||||
payload: maximizable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setMinimizable(minimizable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setMinimizable",
|
||||
payload: minimizable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setClosable(closable) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setClosable",
|
||||
payload: closable
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setTitle(title) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
@ -545,6 +674,21 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
}
|
||||
});
|
||||
}
|
||||
async setContentProtected(protected_) {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
message: {
|
||||
cmd: "manage",
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: "setContentProtected",
|
||||
payload: protected_
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
async setSize(size) {
|
||||
if (!size || size.type !== "Logical" && size.type !== "Physical") {
|
||||
throw new Error(
|
||||
|
@ -811,10 +955,16 @@ var WindowManager = class extends WebviewWindowHandle {
|
|||
});
|
||||
}
|
||||
async onResized(handler) {
|
||||
return this.listen("tauri://resize" /* WINDOW_RESIZED */, handler);
|
||||
return this.listen("tauri://resize" /* WINDOW_RESIZED */, (e) => {
|
||||
e.payload = mapPhysicalSize(e.payload);
|
||||
handler(e);
|
||||
});
|
||||
}
|
||||
async onMoved(handler) {
|
||||
return this.listen("tauri://move" /* WINDOW_MOVED */, handler);
|
||||
return this.listen("tauri://move" /* WINDOW_MOVED */, (e) => {
|
||||
e.payload = mapPhysicalPosition(e.payload);
|
||||
handler(e);
|
||||
});
|
||||
}
|
||||
async onCloseRequested(handler) {
|
||||
return this.listen("tauri://close-requested" /* WINDOW_CLOSE_REQUESTED */, (event) => {
|
||||
|
@ -920,6 +1070,14 @@ var WebviewWindow = class extends WindowManager {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
static async getFocusedWindow() {
|
||||
for (const w of getAll()) {
|
||||
if (await w.isFocused()) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
var appWindow;
|
||||
if ("__TAURI_METADATA__" in window) {
|
||||
|
@ -942,10 +1100,16 @@ function mapMonitor(m) {
|
|||
return m === null ? null : {
|
||||
name: m.name,
|
||||
scaleFactor: m.scaleFactor,
|
||||
position: new PhysicalPosition(m.position.x, m.position.y),
|
||||
size: new PhysicalSize(m.size.width, m.size.height)
|
||||
position: mapPhysicalPosition(m.position),
|
||||
size: mapPhysicalSize(m.size)
|
||||
};
|
||||
}
|
||||
function mapPhysicalPosition(m) {
|
||||
return new PhysicalPosition(m.x, m.y);
|
||||
}
|
||||
function mapPhysicalSize(m) {
|
||||
return new PhysicalSize(m.width, m.height);
|
||||
}
|
||||
async function currentMonitor() {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: "Window",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue