Skip to content

Commit 13a501e

Browse files
refactor: address pr comments.
1 parent 0d3a694 commit 13a501e

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ browser acts as the runtime host for render, lint, and typecheck flows.
4242

4343
- GitHub PAT setup and usage: [docs/byot.md](docs/byot.md)
4444

45-
## Editor Architecture
46-
47-
- Workspace-first editor architecture and migration notes: [docs/editor-workspace-architecture.md](docs/editor-workspace-architecture.md)
48-
4945
## Fine-Grained PAT Quick Setup
5046

5147
For PR/BYOT and AI chat flows, use a fine-grained GitHub PAT and follow the

src/modules/preview-runtime/iframe-preview-executor.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const createBootstrapScript = ({
4242
entryExportName,
4343
runtimeSpecifiers,
4444
channelId,
45+
parentOrigin,
4546
}) => {
4647
const isReactMode = mode === 'react'
4748
const reactImports = isReactMode
@@ -82,8 +83,12 @@ ${reactImports}
8283
${domImports}
8384
const __knightedChannelId = ${JSON.stringify(channelId)}
8485
const __knightedEntrySpecifier = ${JSON.stringify(entrySpecifier)}
86+
const __knightedParentOrigin = ${JSON.stringify(parentOrigin)}
8587
const __knightedEmit = payload => {
86-
parent.postMessage({ __knightedPreview: true, channelId: __knightedChannelId, ...payload }, '*')
88+
parent.postMessage(
89+
{ __knightedPreview: true, channelId: __knightedChannelId, ...payload },
90+
__knightedParentOrigin,
91+
)
8792
}
8893
8994
const __knightedRuntimeErrorFingerprints = new Set()
@@ -218,6 +223,10 @@ export const executeWorkspaceIframePreview = ({
218223
return
219224
}
220225

226+
if (!iframe.contentWindow || event.source !== iframe.contentWindow) {
227+
return
228+
}
229+
221230
const data = event?.data
222231
if (!data || data.__knightedPreview !== true || data.channelId !== channelId) {
223232
return
@@ -274,6 +283,7 @@ export const executeWorkspaceIframePreview = ({
274283
entryExportName,
275284
runtimeSpecifiers,
276285
channelId,
286+
parentOrigin: globalThis.location.origin,
277287
})
278288

279289
const doc = iframe.contentDocument

0 commit comments

Comments
 (0)