Type the window and power-level casts. [skip build]
Checks / checks (push) Successful in 2m5s
Trigger cinny-mobile / dispatch (push) Successful in 2s

This commit is contained in:
2026-11-02 01:45:51 +11:00
parent 8d6aaa619f
commit b36335cde9
4 changed files with 65 additions and 28 deletions
+10 -12
View File
@@ -8,7 +8,7 @@ export const isElectron = (): boolean => typeof window !== 'undefined' && 'elect
*/
export const isCapacitorNative = (): boolean => {
if (typeof window === 'undefined') return false;
const cap = (window as any).Capacitor;
const cap = window.Capacitor;
return Boolean(
cap?.isNativePlatform?.() ||
cap?.getPlatform?.() === 'android' ||
@@ -26,7 +26,7 @@ export const openExternalUrl = async (url: string): Promise<void> => {
// Use Electron's shell.openExternal if in Electron
if (isElectron()) {
try {
const { electron } = window as any;
const { electron } = window;
if (electron?.shell?.openExternal) {
await electron.shell.openExternal(url);
console.log('[openExternalUrl] Electron shell.openExternal succeeded');
@@ -64,7 +64,7 @@ export const getYouTubeStream = async (url: string): Promise<YouTubeStreamInfo>
}
// Check for Electron
const { electron } = window as any;
const { electron } = window;
if (electron?.youtube?.getStream) {
const result = await electron.youtube.getStream(url);
// Electron returns { success: true, data: { video_url, title } } or { success: false, error }
@@ -75,7 +75,7 @@ export const getYouTubeStream = async (url: string): Promise<YouTubeStreamInfo>
}
// Check for Tauri
if ((window as any).__TAURI__) {
if (window.__TAURI__) {
const { invoke } = await import('@tauri-apps/api/core');
return invoke<YouTubeStreamInfo>('get_youtube_stream', { url });
}
@@ -93,13 +93,13 @@ export const isYouTubeStreamingAvailable = (): boolean => {
}
// Check for Electron
const { electron } = window as any;
const { electron } = window;
if (electron?.youtube?.getStream) {
return true;
}
// Check for Tauri
return !!(window as any).__TAURI__;
return !!window.__TAURI__;
};
/**
@@ -116,7 +116,7 @@ export const focusWindow = async (): Promise<void> => {
// Use Electron's window focus if in Electron
if (isElectron()) {
try {
const { electron } = window as any;
const { electron } = window;
if (electron?.window?.focus) {
await electron.window.focus();
}
@@ -138,18 +138,16 @@ export const setupNotificationTapListener = async (
// Use Electron's native notification handler if in Electron
if (isElectron()) {
try {
const { electron } = window as any;
const { electron } = window;
if (electron?.notification?.onNavigate) {
electron.notification.onNavigate((data: { path?: string }) => {
if (data.path && typeof data.path === 'string' && notificationTapCallback) {
notificationTapCallback(data.path);
}
});
return;
}
} catch (err) {
console.warn('Failed to set up Electron notification listener:', err);
return;
}
}
};
@@ -273,7 +271,7 @@ export const sendNotification = async (options: {
// Use Electron's native notification API if in Electron
if (isElectron()) {
try {
const { electron } = window as any;
const { electron } = window;
if (electron?.notification?.show) {
await electron.notification.show({
title,
@@ -308,7 +306,7 @@ export const readClipboardImage = async (): Promise<File | null> => {
// Use Electron's clipboard API if in Electron
if (isElectron()) {
try {
const { electron } = window as any;
const { electron } = window;
if (electron?.clipboard?.readImage) {
const result = await electron.clipboard.readImage();
// IPC may return a data URL string or { success, data } depending on path.