Fix RPC bridge response unwrapping and export
- Bridge was double-wrapping responses ({ok, result: {ok, base64}}) — now
forwards the server's payload directly, stripping only type/id fields
- Compute layouts after mutations so auto-layout frames position correctly
- Export createElement and resolveToTree from core for bridge JSX transform
- Fix package.json exports: remove node condition that pointed to non-existent
dist/, use publishConfig.exports for npm consumers
This commit is contained in:
parent
1f04926166
commit
c9e755a181
|
|
@ -69,7 +69,10 @@ function handleBrowserMessage(data: string) {
|
|||
pending.delete(msg.id)
|
||||
clearTimeout(req.timer)
|
||||
if (msg.ok === false) req.reject(new Error(msg.error ?? 'RPC failed'))
|
||||
else req.resolve(msg.result)
|
||||
else {
|
||||
const { type: _, id: __, ...payload } = msg
|
||||
req.resolve(payload)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore malformed messages
|
||||
|
|
@ -130,7 +133,7 @@ export function startAutomationBridge(server: ViteServer) {
|
|||
try {
|
||||
body = await preprocessRpc(body as Record<string, unknown>)
|
||||
const result = await sendToBrowser(body as Record<string, unknown>)
|
||||
return c.json({ ok: true, result })
|
||||
return c.json(result)
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e)
|
||||
return c.json({ ok: false, error: msg }, 502)
|
||||
|
|
|
|||
Loading…
Reference in a new issue