Skip to content

Commit

Permalink
feature: send response message when receiving messageport (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
levivilet authored Sep 22, 2024
1 parent b523f79 commit aa8c401
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion files/previewInjectedCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ const handleMessage = async (event) => {
}

const handleFirstMessage = (event) => {
const message = event.data
const { data, target } = event
const message = data
port = message.params[0]
port.onmessage = handleMessage
port.postMessage('ready')
target.postMessage({
jsonrpc: '2.0',
id: message.id,
result: null,
})
}

window.addEventListener('message', handleFirstMessage, {
Expand Down

0 comments on commit aa8c401

Please sign in to comment.