From 150d2979266e4d01d775c5cc527bb0d3f224a90a Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 23 Oct 2025 09:20:18 +0000 Subject: [PATCH] fix(capacitor): getting capacitor to build --- BUILDING.md | 2 +- .../daily-notification-test/eslint.config.ts | 13 ++++- .../daily-notification-test/src/env.d.ts | 49 ++++++++++--------- .../daily-notification-test/src/globals.d.ts | 6 ++- .../src/types/global.d.ts | 21 +++++++- .../src/views/HomeView.vue | 8 +-- .../src/views/LogsView.vue | 6 +-- 7 files changed, 70 insertions(+), 35 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 82a2602..3b37b21 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -790,7 +790,7 @@ java -version # Should be 11+ # Solution: Clear Gradle cache ./gradlew clean -rm -rf ~/.gradle/caches/ +rm -rf ~/.gradle/caches ~/.gradle/daemon ``` #### Build Failures diff --git a/test-apps/daily-notification-test/eslint.config.ts b/test-apps/daily-notification-test/eslint.config.ts index edb1bbb..2460dd6 100644 --- a/test-apps/daily-notification-test/eslint.config.ts +++ b/test-apps/daily-notification-test/eslint.config.ts @@ -13,7 +13,18 @@ export default defineConfigWithVueTs( files: ['**/*.{ts,mts,tsx,vue}'], }, - globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']), + globalIgnores([ + '**/dist/**', + '**/dist-ssr/**', + '**/coverage/**', + '**/android/**', + '**/ios/**', + '**/node_modules/**', + '**/*.js', + '**/*.min.js', + '**/build/**', + '**/.gradle/**' + ]), pluginVue.configs['flat/essential'], vueTsConfigs.recommended, diff --git a/test-apps/daily-notification-test/src/env.d.ts b/test-apps/daily-notification-test/src/env.d.ts index b4ca750..bdb9f89 100644 --- a/test-apps/daily-notification-test/src/env.d.ts +++ b/test-apps/daily-notification-test/src/env.d.ts @@ -2,7 +2,7 @@ declare module '*.vue' { import type { DefineComponent } from 'vue' - const component: DefineComponent<{}, {}, any> + const component: DefineComponent, Record, unknown> export default component } @@ -10,48 +10,49 @@ declare module '*.vue' { declare module 'vue-facing-decorator' { import { ComponentOptions } from 'vue' - export interface ComponentOptionsWithProps extends ComponentOptions { - props?: any + export interface ComponentOptionsWithProps> extends ComponentOptions { + props?: Record } + // eslint-disable-next-line @typescript-eslint/no-explicit-any export function Component(options?: any): any export function toNative(component: T): T export class Vue { - $emit(event: string, ...args: any[]): void - $props: any - $data: any - $refs: any - $slots: any - $scopedSlots: any - $attrs: any - $listeners: any + $emit(event: string, ...args: unknown[]): void + $props: Record + $data: Record + $refs: Record + $slots: Record + $scopedSlots: Record + $attrs: Record + $listeners: Record $parent: Vue | null $root: Vue $children: Vue[] $el: Element | undefined $options: ComponentOptions $isServer: boolean - $ssrContext: any - $vnode: any - $createElement: any - $mount: any + $ssrContext: Record + $vnode: Record + $createElement: (...args: unknown[]) => unknown + $mount: (elementOrSelector?: string | Element) => Vue $forceUpdate: () => void $destroy: () => void $nextTick: (callback?: () => void) => Promise - $set: (target: any, key: string | number, value: any) => void - $delete: (target: any, key: string | number) => void - $watch: (expOrFn: string | Function, callback: Function, options?: any) => Function - $on: (event: string | string[], callback: Function) => Vue - $once: (event: string | string[], callback: Function) => Vue - $off: (event?: string | string[], callback?: Function) => Vue + $set: (target: Record, key: string | number, value: unknown) => void + $delete: (target: Record, key: string | number) => void + $watch: (expOrFn: string | ((...args: unknown[]) => unknown), callback: (...args: unknown[]) => unknown, options?: Record) => (...args: unknown[]) => unknown + $on: (event: string | string[], callback: (...args: unknown[]) => unknown) => Vue + $once: (event: string | string[], callback: (...args: unknown[]) => unknown) => Vue + $off: (event?: string | string[], callback?: (...args: unknown[]) => unknown) => Vue } - export function Prop(options?: any): PropertyDecorator + export function Prop(options?: Record): PropertyDecorator export function Emit(event?: string): MethodDecorator - export function Watch(path: string, options?: any): MethodDecorator + export function Watch(path: string, options?: Record): MethodDecorator export function Inject(key?: string | symbol): PropertyDecorator export function Provide(key?: string | symbol): PropertyDecorator - export function Model(event?: string, options?: any): PropertyDecorator + export function Model(event?: string, options?: Record): PropertyDecorator export function Ref(refKey?: string): PropertyDecorator } diff --git a/test-apps/daily-notification-test/src/globals.d.ts b/test-apps/daily-notification-test/src/globals.d.ts index 2a8fef5..0f62f35 100644 --- a/test-apps/daily-notification-test/src/globals.d.ts +++ b/test-apps/daily-notification-test/src/globals.d.ts @@ -2,6 +2,10 @@ export {} declare global { interface Window { - Capacitor?: any + Capacitor?: { + Plugins?: Record + isNativePlatform?: () => boolean + getPlatform?: () => string + } } } diff --git a/test-apps/daily-notification-test/src/types/global.d.ts b/test-apps/daily-notification-test/src/types/global.d.ts index 6ba7e16..cdb032f 100644 --- a/test-apps/daily-notification-test/src/types/global.d.ts +++ b/test-apps/daily-notification-test/src/types/global.d.ts @@ -31,7 +31,26 @@ declare global { } Capacitor?: { Plugins?: { - DailyNotification?: any + DailyNotification?: { + checkStatus(): Promise<{ + canScheduleNow: boolean + postNotificationsGranted: boolean + channelEnabled: boolean + channelImportance: number + channelId: string + exactAlarmsGranted: boolean + exactAlarmsSupported: boolean + androidVersion: number + nextScheduledAt: number + }> + scheduleNotification(options: { + title: string + body: string + scheduledTime: number + }): Promise + cancelNotification(id: string): Promise + requestPermissions(): Promise + } Clipboard?: { write(options: { string: string }): Promise } diff --git a/test-apps/daily-notification-test/src/views/HomeView.vue b/test-apps/daily-notification-test/src/views/HomeView.vue index 5d8d783..535918e 100644 --- a/test-apps/daily-notification-test/src/views/HomeView.vue +++ b/test-apps/daily-notification-test/src/views/HomeView.vue @@ -296,7 +296,7 @@ const runPluginDiagnostics = async (): Promise => { console.log('✅ DailyNotification plugin available') // Get all available plugins - const allPlugins = Object.keys((window as any).Capacitor?.Plugins || {}) + const allPlugins = Object.keys((window as Window & { Capacitor?: { Plugins?: Record } }).Capacitor?.Plugins || {}) console.log('📋 All available plugins:', allPlugins) // Test the checkStatus method @@ -311,7 +311,7 @@ const runPluginDiagnostics = async (): Promise => { dailyNotificationAvailable: true, allAvailablePlugins: allPlugins, dailyNotificationStatus: status, - capacitorVersion: (window as any).Capacitor?.getPlatform ? 'Available' : 'Unknown', + capacitorVersion: (window as Window & { Capacitor?: { getPlatform?: () => string } }).Capacitor?.getPlatform ? 'Available' : 'Unknown', webViewInfo: { userAgent: navigator.userAgent, platform: navigator.platform @@ -331,8 +331,8 @@ const runPluginDiagnostics = async (): Promise => { } } else { console.warn('⚠️ DailyNotification plugin not available') - const allPlugins = Object.keys((window as any).Capacitor?.Plugins || {}) - alert(`❌ Plugin Diagnostics Complete!\n\nPlatform: ${platform}\nDailyNotification Plugin: Not Available\n\nAll Available Plugins (${allPlugins.length}):\n${allPlugins.join(', ')}\n\nCapacitor Plugins Object:\n${JSON.stringify((window as any).Capacitor?.Plugins || {}, null, 2)}`) + const allPlugins = Object.keys((window as Window & { Capacitor?: { Plugins?: Record } }).Capacitor?.Plugins || {}) + alert(`❌ Plugin Diagnostics Complete!\n\nPlatform: ${platform}\nDailyNotification Plugin: Not Available\n\nAll Available Plugins (${allPlugins.length}):\n${allPlugins.join(', ')}\n\nCapacitor Plugins Object:\n${JSON.stringify((window as Window & { Capacitor?: { Plugins?: Record } }).Capacitor?.Plugins || {}, null, 2)}`) } } else { console.log('🌐 Running in web mode - plugin not available') diff --git a/test-apps/daily-notification-test/src/views/LogsView.vue b/test-apps/daily-notification-test/src/views/LogsView.vue index 6fe4018..c66a0ae 100644 --- a/test-apps/daily-notification-test/src/views/LogsView.vue +++ b/test-apps/daily-notification-test/src/views/LogsView.vue @@ -102,11 +102,11 @@ class LogsView extends Vue { this.isCopying = true try { const text = this.logs.map(l => `[${this.formatTimestamp(l.ts)}] ${l.msg}`).join('\n') - if ((navigator as any)?.clipboard?.writeText) { + if ((navigator as Navigator & { clipboard?: { writeText?: (text: string) => Promise } })?.clipboard?.writeText) { await navigator.clipboard.writeText(text); return } - const Cap = (window as any)?.Capacitor - const Clip = Cap?.Plugins?.Clipboard + const Cap = (window as Window & { Capacitor?: { Plugins?: Record } })?.Capacitor + const Clip = Cap?.Plugins?.Clipboard as { write?: (options: { string: string }) => Promise } | undefined if (Clip?.write) { await Clip.write({ string: text }); return } console.warn('No clipboard API available.') } finally {