diff --git a/scripts/check-native-shells.mjs b/scripts/check-native-shells.mjs index 84e7c5125..909290925 100644 --- a/scripts/check-native-shells.mjs +++ b/scripts/check-native-shells.mjs @@ -2642,7 +2642,6 @@ function assertAiGameCreatorShellUserDevBoundary() { 'function resolveEmbeddedPreviewUrl(', "url.protocol !== 'http:' || url.hostname !== '127.0.0.1'", 'sandbox="allow-scripts allow-same-origin allow-forms allow-pointer-lock"', - 'src={embeddedUrl}', ]) { if ( !sourceIncludesSnippet(aiGameCreatorLocalGamePreviewFrameSource, snippet) @@ -2652,6 +2651,29 @@ function assertAiGameCreatorShellUserDevBoundary() { ); } } + // 预览框的 `src` 允许经一个短变量中转(刷新时要在地址上叠加 `__agc_reload` 这类非业务参数), + // 但这个变量必须由被校验过的 `embeddedUrl` 派生:只换名字、丢掉派生关系仍按漂移处理。 + const iframeUrlDerivation = aiGameCreatorLocalGamePreviewFrameSource.match( + /const\s+iframeUrl\s*=\s*useMemo\(\s*\(\s*\)\s*=>\s*\{[\s\S]*?\}\s*,\s*\[/, + ); + if ( + !sourceIncludesSnippet( + aiGameCreatorLocalGamePreviewFrameSource, + 'src={embeddedUrl}', + ) && + !( + sourceIncludesSnippet( + aiGameCreatorLocalGamePreviewFrameSource, + 'src={iframeUrl ?? undefined}', + ) && + iframeUrlDerivation !== null && + iframeUrlDerivation[0].includes('embeddedUrl') + ) + ) { + throw new Error( + 'AI game creator embedded preview boundary drifted: iframe src must derive from the validated embeddedUrl', + ); + } for (const snippet of [ "await invoke(\n 'activate_local_game_preview'", '已载入客户端运行视图',