소스 검색

fix: serialize Uint8Array and ArrayBuffer as number[], closes #10336 (#10797)

Lucas Fernandes Nogueira 11 달 전
부모
커밋
fbe76a955a
4개의 변경된 파일14개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 0
      .changes/serialize-array-buffer.md
  2. 0 0
      core/tauri/scripts/bundle.global.js
  3. 5 1
      core/tauri/scripts/process-ipc-message-fn.js
  4. 3 7
      tooling/api/src/image.ts

+ 6 - 0
.changes/serialize-array-buffer.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch:bug
+"@tauri-apps/api": patch:bug
+---
+
+Uint8Arrays and ArrayBuffers are now properly serialized as an array of numbers.

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
core/tauri/scripts/bundle.global.js


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

@@ -20,7 +20,11 @@
         let o = {}
         val.forEach((v, k) => (o[k] = v))
         return o
-      } else if (
+      } else if (val instanceof Uint8Array) {
+        return Array.from(val)
+      } else if (val instanceof ArrayBuffer) {
+        return Array.from(new Uint8Array(val))
+      }  else if (
         val instanceof Object &&
         '__TAURI_CHANNEL_MARKER__' in val &&
         typeof val.id === 'number'

+ 3 - 7
tooling/api/src/image.ts

@@ -102,13 +102,9 @@ export function transformImage<T>(
       ? null
       : typeof image === 'string'
         ? image
-        : image instanceof Uint8Array
-          ? Array.from(image)
-          : image instanceof ArrayBuffer
-            ? Array.from(new Uint8Array(image))
-            : image instanceof Image
-              ? image.rid
-              : image
+        : image instanceof Image
+          ? image.rid
+          : image
 
   return ret as T
 }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.