FIX - clone custom app frame messages

This commit is contained in:
Leon.Schmidt
2026-08-11 21:46:40 +02:00
parent dc401e2b87
commit 5d984b5efe
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -33,6 +33,7 @@ import {
getLbPhoneCallbackResource,
usesLbPhoneHostRuntime,
} from '@/utils/lbPhoneAppBridge'
import { cloneJsonData } from '@/utils/clone'
import { nuiCall } from '@/utils/nui'
const props = defineProps<{
@@ -150,7 +151,7 @@ function postToFrame(payload: unknown): boolean {
if (!target) return false
try {
target.postMessage(payload, postMessageOrigin.value)
target.postMessage(cloneJsonData(payload), postMessageOrigin.value)
return true
} catch (error) {
console.error(`[Custom apps] Could not message ${props.app.id}.`, error)
+20
View File
@@ -0,0 +1,20 @@
import { reactive } from 'vue'
import { describe, expect, it } from 'vitest'
import { cloneJsonData } from '@/utils/clone'
describe('JSON data cloning', () => {
it('turns reactive custom app payloads into structured-cloneable data', () => {
const payload = reactive({
action: 'setSpeedCameras',
data: [{ id: 1, label: 'Alta Street' }],
})
expect(() => structuredClone(payload)).toThrow()
const cloned = cloneJsonData(payload)
expect(cloned).toEqual(payload)
expect(() => structuredClone(cloned)).not.toThrow()
})
})