export type CodeWindow = Window & typeof globalThis & {
readonly vscodeWindowId: number;
};
export function ensureCodeWindow(targetWindow: Window, fallbackWindowId: number): asserts targetWindow is CodeWindow {
const codeWindow = targetWindow as Partial<CodeWindow>;
if (typeof codeWindow.vscodeWindowId !== 'number') {
Object.defineProperty(codeWindow, 'vscodeWindowId', {
get: () => fallbackWindowId
});
}
}
export const mainWindow = window as CodeWindow;
export function isAuxiliaryWindow(obj: Window): obj is CodeWindow {
if (obj === mainWindow) {
return false;
}
const candidate = obj as CodeWindow | undefined;
return typeof candidate?.vscodeWindowId === 'number';
}