瀏覽代碼

review suggestions

amrbashir 10 月之前
父節點
當前提交
d88aa47c4e

+ 2 - 2
crates/tauri/scripts/ipc.js

@@ -90,12 +90,12 @@
 
     // `postMessage` uses `structuredClone` to serialize the data before sending it
     // unlike `JSON.stringify`, we can't extend a type with a method similar to `toJSON`
-    // so that `structuredClone` would use, so untl https://github.com/whatwg/html/issues/7428
+    // so that `structuredClone` would use, so until https://github.com/whatwg/html/issues/7428
     // we manually call `toIPC`
     function recursiveCallToIPC(data) {
       if (
         typeof data === 'object' &&
-        'constrcutor' in data &&
+        'constructor' in data &&
         data.constructor === Array
       ) {
         return data.map((v) => recursiveCallToIPC(v))

+ 1 - 1
crates/tauri/scripts/process-ipc-message-fn.js

@@ -28,7 +28,7 @@
         typeof val.id === 'number'
       ) {
         return `__CHANNEL__:${val.id}`
-      } else if (typeof val === "object" &&'toIPC' in val){
+      } else if (typeof val === "object" && 'toIPC' in val){
         return val.toIPC()
       } else {
         return val

+ 4 - 4
packages/api/src/dpi.ts

@@ -8,7 +8,7 @@
  * @since 2.0.0
  */
 class LogicalSize {
-  type = 'Logical' as const
+  readonly type = 'Logical'
   width: number
   height: number
 
@@ -102,7 +102,7 @@ class LogicalSize {
  * @since 2.0.0
  */
 class PhysicalSize {
-  type = 'Physical' as const
+  readonly type = 'Physical'
   width: number
   height: number
 
@@ -192,7 +192,7 @@ class PhysicalSize {
  * @since 2.0.0
  */
 class LogicalPosition {
-  type = 'Logical' as const
+  readonly type = 'Logical'
   x: number
   y: number
 
@@ -286,7 +286,7 @@ class LogicalPosition {
  * @since 2.0.0
  */
 class PhysicalPosition {
-  type = 'Physical' as const
+  readonly type = 'Physical'
   x: number
   y: number
 

+ 7 - 4
packages/api/src/webview.ts

@@ -359,7 +359,7 @@ class Webview {
    * @returns The webview's position.
    */
   async position(): Promise<PhysicalPosition> {
-    return invoke<PhysicalPosition>('plugin:webview|webview_position', {
+    return invoke<{ x: number; y: number }>('plugin:webview|webview_position', {
       label: this.label
     }).then((p) => new PhysicalPosition(p))
   }
@@ -376,9 +376,12 @@ class Webview {
    * @returns The webview's size.
    */
   async size(): Promise<PhysicalSize> {
-    return invoke<PhysicalSize>('plugin:webview|webview_size', {
-      label: this.label
-    }).then((s) => new PhysicalSize(s))
+    return invoke<{ width: number; height: number }>(
+      'plugin:webview|webview_size',
+      {
+        label: this.label
+      }
+    ).then((s) => new PhysicalSize(s))
   }
 
   // Setters

+ 8 - 5
packages/api/src/window.ts

@@ -528,7 +528,7 @@ class Window {
    * @returns The window's inner position.
    */
   async innerPosition(): Promise<PhysicalPosition> {
-    return invoke<PhysicalPosition>('plugin:window|inner_position', {
+    return invoke<{ x: number; y: number }>('plugin:window|inner_position', {
       label: this.label
     }).then((p) => new PhysicalPosition(p))
   }
@@ -544,7 +544,7 @@ class Window {
    * @returns The window's outer position.
    */
   async outerPosition(): Promise<PhysicalPosition> {
-    return invoke<PhysicalPosition>('plugin:window|outer_position', {
+    return invoke<{ x: number; y: number }>('plugin:window|outer_position', {
       label: this.label
     }).then((p) => new PhysicalPosition(p))
   }
@@ -561,9 +561,12 @@ class Window {
    * @returns The window's inner size.
    */
   async innerSize(): Promise<PhysicalSize> {
-    return invoke<PhysicalSize>('plugin:window|inner_size', {
-      label: this.label
-    }).then((s) => new PhysicalSize(s))
+    return invoke<{ width: number; height: number }>(
+      'plugin:window|inner_size',
+      {
+        label: this.label
+      }
+    ).then((s) => new PhysicalSize(s))
   }
 
   /**