fix(desktop): let the Theme Studio popout resolve its runtime (#3272)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-08 03:05:37 +02:00
1 parent d00389ab30
commit 795e190bda
3 files changed
+9 -3

No files matched your search

@@ -78,7 +78,7 @@ const DESKTOP_APP_STORAGE_STUB = dataModule(`const state = globalThis[${JSON.str
export const getDesktopAppStorage = () => state.desktopAppStorage;`);
const WINDOW_STUB = dataModule(`const state = globalThis[${JSON.stringify(LIVE_STATE_KEY)}];
export const getMainWindow = () => state.mainWindow;
export const isAppDocumentWindowContents = (contents) => state.mainWindow?.webContents === contents;
export const isTrustedOrigin = () => true;`);
const APP_LOGGER_STUB = dataModule(`const noop = () => undefined;
@@ -3,7 +3,7 @@
import {DESKTOP_APP_ORIGIN} from '@electron/common/Constants';
import {createChildLogger} from '@electron/common/Logger';
import {RendererDocumentOwnerFactory} from '@electron/main/RendererDocumentOwner';
import {getMainWindow, isTrustedOrigin} from '@electron/main/Window';
import {isAppDocumentWindowContents, isTrustedOrigin} from '@electron/main/Window';
import type {IpcMainInvokeEvent} from 'electron';
const BLANK_DOCUMENT_URL = 'about:blank';
@@ -49,7 +49,7 @@ export function createPrivilegedRendererDocumentOwners(componentName: string): R
const log = createChildLogger(componentName);
return new RendererDocumentOwnerFactory({
policy: {
isPrivilegedRendererDocument: ({sender, url}) => sender === getMainWindow()?.webContents && isTrustedOrigin(url),
isPrivilegedRendererDocument: ({sender, url}) => isAppDocumentWindowContents(sender) && isTrustedOrigin(url),
},
onWatcherFailure: (error, reason) => {
log.warn('Renderer document invalidation handling failed', {reason, error});
+6
View File
@@ -364,6 +364,12 @@ function recoverMainWindowRendererBeforeShow(reason: string): void {
reloadMainWindowRendererAfterGone(reason);
}
export function isAppDocumentWindowContents(contents: Electron.WebContents): boolean {
return [mainWindow, themeStudioPopoutWindow].some(
(window) => isAliveWindow(window) && window.webContents === contents,
);
}
function getThemeStudioPopoutWindow(): BrowserWindow | null {
if (isAliveWindow(themeStudioPopoutWindow)) {
return themeStudioPopoutWindow;