fix(api): fix dpi types serialization (#9376)

* fix(api): fix dpi types serialization

closes #9370

* Update api-position-size-args.md

* lint

* setMinSize and setMaxSize

* Update api-position-size-args.md
This commit is contained in:
Amr Bashir 2024-04-15 12:04:20 +02:00 committed by GitHub
parent 1d39876f97
commit 48a7a78f80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 77 additions and 68 deletions

View File

@ -0,0 +1,5 @@
---
"@tauri-apps/api": "patch:bug"
---
Fix `Window/Webview/WebviewWindow.setSize`, `Window/Webview/WebviewWindow.setPostion`, `Window/WebviewWindow.setMinSize`, `Window/WebviewWindow.setMaxSize`, `Window/WebviewWindow.setCursorPosition` and `Menu/Submenu.popup` methods failing with invalid args.

File diff suppressed because one or more lines are too long

View File

@ -3017,7 +3017,7 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
[[package]]
name = "tauri"
version = "2.0.0-beta.13"
version = "2.0.0-beta.14"
dependencies = [
"anyhow",
"bytes",
@ -3066,7 +3066,7 @@ dependencies = [
[[package]]
name = "tauri-build"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"anyhow",
"cargo_toml",
@ -3088,7 +3088,7 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"base64 0.22.0",
"brotli",
@ -3113,7 +3113,7 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"heck",
"proc-macro2",
@ -3125,7 +3125,7 @@ dependencies = [
[[package]]
name = "tauri-plugin"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"anyhow",
"glob",
@ -3151,7 +3151,7 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"dpi",
"gtk",
@ -3168,7 +3168,7 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"cocoa",
"gtk",
@ -3190,7 +3190,7 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.0.0-beta.10"
version = "2.0.0-beta.11"
dependencies = [
"aes-gcm",
"brotli",

View File

@ -245,9 +245,10 @@ export class Menu extends MenuItemBase {
): Promise<void> {
let atValue = null
if (at) {
atValue = {
type: at instanceof PhysicalPosition ? 'Physical' : 'Logical',
data: at
atValue = {} as Record<string, unknown>
atValue[`${at instanceof PhysicalPosition ? 'Physical' : 'Logical'}`] = {
x: at.x,
y: at.y
}
}
return invoke('plugin:menu|popup', {

View File

@ -245,9 +245,10 @@ export class Submenu extends MenuItemBase {
): Promise<void> {
let atValue = null
if (at) {
atValue = {
type: at instanceof PhysicalPosition ? 'Physical' : 'Logical',
data: at
atValue = {} as Record<string, unknown>
atValue[`${at instanceof PhysicalPosition ? 'Physical' : 'Logical'}`] = {
x: at.x,
y: at.y
}
}
return invoke('plugin:menu|popup', {

View File

@ -417,15 +417,15 @@ class Webview {
)
}
const value = {} as Record<string, unknown>
value[`${size.type}`] = {
width: size.width,
height: size.height
}
return invoke('plugin:webview|set_webview_size', {
label: this.label,
value: {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
value
})
}
@ -452,15 +452,15 @@ class Webview {
)
}
const value = {} as Record<string, unknown>
value[`${position.type}`] = {
x: position.x,
y: position.y
}
return invoke('plugin:webview|set_webview_position', {
label: this.label,
value: {
type: position.type,
data: {
x: position.x,
y: position.y
}
}
value
})
}

View File

@ -1227,15 +1227,15 @@ class Window {
)
}
const value = {} as Record<string, unknown>
value[`${size.type}`] = {
width: size.width,
height: size.height
}
return invoke('plugin:window|set_size', {
label: this.label,
value: {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
value
})
}
@ -1259,17 +1259,18 @@ class Window {
)
}
let value = null as Record<string, unknown> | null
if (size) {
value = {}
value[`${size.type}`] = {
width: size.width,
height: size.height
}
}
return invoke('plugin:window|set_min_size', {
label: this.label,
value: size
? {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
: null
value
})
}
@ -1293,17 +1294,18 @@ class Window {
)
}
let value = null as Record<string, unknown> | null
if (size) {
value = {}
value[`${size.type}`] = {
width: size.width,
height: size.height
}
}
return invoke('plugin:window|set_max_size', {
label: this.label,
value: size
? {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
: null
value
})
}
@ -1330,15 +1332,15 @@ class Window {
)
}
const value = {} as Record<string, unknown>
value[`${position.type}`] = {
x: position.x,
y: position.y
}
return invoke('plugin:window|set_position', {
label: this.label,
value: {
type: position.type,
data: {
x: position.x,
y: position.y
}
}
value
})
}
@ -1516,15 +1518,15 @@ class Window {
)
}
const value = {} as Record<string, unknown>
value[`${position.type}`] = {
x: position.x,
y: position.y
}
return invoke('plugin:window|set_cursor_position', {
label: this.label,
value: {
type: position.type,
data: {
x: position.x,
y: position.y
}
}
value
})
}