Ver código fonte

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
Amr Bashir 1 ano atrás
pai
commit
48a7a78f80

+ 5 - 0
.changes/api-position-size-args.md

@@ -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.

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
core/tauri/scripts/bundle.global.js


+ 8 - 8
examples/api/src-tauri/Cargo.lock

@@ -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",

+ 4 - 3
tooling/api/src/menu/menu.ts

@@ -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', {

+ 4 - 3
tooling/api/src/menu/submenu.ts

@@ -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', {

+ 14 - 14
tooling/api/src/webview.ts

@@ -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
     })
   }
 

+ 41 - 39
tooling/api/src/window.ts

@@ -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
     })
   }
 

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff