|
@@ -92,17 +92,22 @@
|
|
|
// unlike `JSON.stringify`, we can't extend a type with a method similar to `toJSON`
|
|
|
// so that `structuredClone` would use, so until https://github.com/whatwg/html/issues/7428
|
|
|
// we manually call `toIPC`
|
|
|
- function recursiveCallToIPC(data) {
|
|
|
+ function processToIPCSymbol(data) {
|
|
|
+ // if this value changes, make sure to update it in:
|
|
|
+ // 1. process-ipc-message-fn.js
|
|
|
+ // 2. core.ts
|
|
|
+ const ToIPCSymbol = '__TAURI_TO_IPC__'
|
|
|
+
|
|
|
if (
|
|
|
typeof data === 'object' &&
|
|
|
'constructor' in data &&
|
|
|
data.constructor === Array
|
|
|
) {
|
|
|
- return data.map((v) => recursiveCallToIPC(v))
|
|
|
+ return data.map((v) => processToIPCSymbol(v))
|
|
|
}
|
|
|
|
|
|
- if (typeof data === 'object' && 'toIPC' in data) {
|
|
|
- return data.toIPC()
|
|
|
+ if (typeof data === 'object' && ToIPCSymbol in data) {
|
|
|
+ return data[ToIPCSymbol]()
|
|
|
}
|
|
|
|
|
|
if (
|
|
@@ -112,7 +117,7 @@
|
|
|
) {
|
|
|
const acc = {}
|
|
|
Object.entries(data).forEach(([k, v]) => {
|
|
|
- acc[k] = recursiveCallToIPC(v)
|
|
|
+ acc[k] = processToIPCSymbol(v)
|
|
|
})
|
|
|
return acc
|
|
|
}
|
|
@@ -120,7 +125,7 @@
|
|
|
return data
|
|
|
}
|
|
|
|
|
|
- data.payload = recursiveCallToIPC(data.payload)
|
|
|
+ data.payload = processToIPCSymbol(data.payload)
|
|
|
|
|
|
isolation.frame.contentWindow.postMessage(
|
|
|
data,
|