mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(desktop): let the Theme Studio popout resolve its runtime (#3272)
This commit is contained in:
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;`);
|
export const getDesktopAppStorage = () => state.desktopAppStorage;`);
|
||||||
|
|
||||||
const WINDOW_STUB = dataModule(`const state = globalThis[${JSON.stringify(LIVE_STATE_KEY)}];
|
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;`);
|
export const isTrustedOrigin = () => true;`);
|
||||||
|
|
||||||
const APP_LOGGER_STUB = dataModule(`const noop = () => undefined;
|
const APP_LOGGER_STUB = dataModule(`const noop = () => undefined;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import {DESKTOP_APP_ORIGIN} from '@electron/common/Constants';
|
import {DESKTOP_APP_ORIGIN} from '@electron/common/Constants';
|
||||||
import {createChildLogger} from '@electron/common/Logger';
|
import {createChildLogger} from '@electron/common/Logger';
|
||||||
import {RendererDocumentOwnerFactory} from '@electron/main/RendererDocumentOwner';
|
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';
|
import type {IpcMainInvokeEvent} from 'electron';
|
||||||
|
|
||||||
const BLANK_DOCUMENT_URL = 'about:blank';
|
const BLANK_DOCUMENT_URL = 'about:blank';
|
||||||
@@ -49,7 +49,7 @@ export function createPrivilegedRendererDocumentOwners(componentName: string): R
|
|||||||
const log = createChildLogger(componentName);
|
const log = createChildLogger(componentName);
|
||||||
return new RendererDocumentOwnerFactory({
|
return new RendererDocumentOwnerFactory({
|
||||||
policy: {
|
policy: {
|
||||||
isPrivilegedRendererDocument: ({sender, url}) => sender === getMainWindow()?.webContents && isTrustedOrigin(url),
|
isPrivilegedRendererDocument: ({sender, url}) => isAppDocumentWindowContents(sender) && isTrustedOrigin(url),
|
||||||
},
|
},
|
||||||
onWatcherFailure: (error, reason) => {
|
onWatcherFailure: (error, reason) => {
|
||||||
log.warn('Renderer document invalidation handling failed', {reason, error});
|
log.warn('Renderer document invalidation handling failed', {reason, error});
|
||||||
|
|||||||
@@ -364,6 +364,12 @@ function recoverMainWindowRendererBeforeShow(reason: string): void {
|
|||||||
reloadMainWindowRendererAfterGone(reason);
|
reloadMainWindowRendererAfterGone(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isAppDocumentWindowContents(contents: Electron.WebContents): boolean {
|
||||||
|
return [mainWindow, themeStudioPopoutWindow].some(
|
||||||
|
(window) => isAliveWindow(window) && window.webContents === contents,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function getThemeStudioPopoutWindow(): BrowserWindow | null {
|
function getThemeStudioPopoutWindow(): BrowserWindow | null {
|
||||||
if (isAliveWindow(themeStudioPopoutWindow)) {
|
if (isAliveWindow(themeStudioPopoutWindow)) {
|
||||||
return themeStudioPopoutWindow;
|
return themeStudioPopoutWindow;
|
||||||
|
|||||||
Reference in new issue
Block a user