Browse Source

fix(capacitor): getting capacitor to build

master
Matthew Raymer 2 days ago
parent
commit
150d297926
  1. 2
      BUILDING.md
  2. 13
      test-apps/daily-notification-test/eslint.config.ts
  3. 49
      test-apps/daily-notification-test/src/env.d.ts
  4. 6
      test-apps/daily-notification-test/src/globals.d.ts
  5. 21
      test-apps/daily-notification-test/src/types/global.d.ts
  6. 8
      test-apps/daily-notification-test/src/views/HomeView.vue
  7. 6
      test-apps/daily-notification-test/src/views/LogsView.vue

2
BUILDING.md

@ -790,7 +790,7 @@ java -version # Should be 11+
# Solution: Clear Gradle cache # Solution: Clear Gradle cache
./gradlew clean ./gradlew clean
rm -rf ~/.gradle/caches/ rm -rf ~/.gradle/caches ~/.gradle/daemon
``` ```
#### Build Failures #### Build Failures

13
test-apps/daily-notification-test/eslint.config.ts

@ -13,7 +13,18 @@ export default defineConfigWithVueTs(
files: ['**/*.{ts,mts,tsx,vue}'], 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'], pluginVue.configs['flat/essential'],
vueTsConfigs.recommended, vueTsConfigs.recommended,

49
test-apps/daily-notification-test/src/env.d.ts

@ -2,7 +2,7 @@
declare module '*.vue' { declare module '*.vue' {
import type { DefineComponent } from 'vue' import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any> const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
export default component export default component
} }
@ -10,48 +10,49 @@ declare module '*.vue' {
declare module 'vue-facing-decorator' { declare module 'vue-facing-decorator' {
import { ComponentOptions } from 'vue' import { ComponentOptions } from 'vue'
export interface ComponentOptionsWithProps<T = any> extends ComponentOptions<T> { export interface ComponentOptionsWithProps<T = Record<string, unknown>> extends ComponentOptions<T> {
props?: any props?: Record<string, unknown>
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function Component(options?: any): any export function Component(options?: any): any
export function toNative<T>(component: T): T export function toNative<T>(component: T): T
export class Vue { export class Vue {
$emit(event: string, ...args: any[]): void $emit(event: string, ...args: unknown[]): void
$props: any $props: Record<string, unknown>
$data: any $data: Record<string, unknown>
$refs: any $refs: Record<string, unknown>
$slots: any $slots: Record<string, unknown>
$scopedSlots: any $scopedSlots: Record<string, unknown>
$attrs: any $attrs: Record<string, unknown>
$listeners: any $listeners: Record<string, unknown>
$parent: Vue | null $parent: Vue | null
$root: Vue $root: Vue
$children: Vue[] $children: Vue[]
$el: Element | undefined $el: Element | undefined
$options: ComponentOptions $options: ComponentOptions
$isServer: boolean $isServer: boolean
$ssrContext: any $ssrContext: Record<string, unknown>
$vnode: any $vnode: Record<string, unknown>
$createElement: any $createElement: (...args: unknown[]) => unknown
$mount: any $mount: (elementOrSelector?: string | Element) => Vue
$forceUpdate: () => void $forceUpdate: () => void
$destroy: () => void $destroy: () => void
$nextTick: (callback?: () => void) => Promise<void> $nextTick: (callback?: () => void) => Promise<void>
$set: (target: any, key: string | number, value: any) => void $set: (target: Record<string, unknown>, key: string | number, value: unknown) => void
$delete: (target: any, key: string | number) => void $delete: (target: Record<string, unknown>, key: string | number) => void
$watch: (expOrFn: string | Function, callback: Function, options?: any) => Function $watch: (expOrFn: string | ((...args: unknown[]) => unknown), callback: (...args: unknown[]) => unknown, options?: Record<string, unknown>) => (...args: unknown[]) => unknown
$on: (event: string | string[], callback: Function) => Vue $on: (event: string | string[], callback: (...args: unknown[]) => unknown) => Vue
$once: (event: string | string[], callback: Function) => Vue $once: (event: string | string[], callback: (...args: unknown[]) => unknown) => Vue
$off: (event?: string | string[], callback?: Function) => Vue $off: (event?: string | string[], callback?: (...args: unknown[]) => unknown) => Vue
} }
export function Prop(options?: any): PropertyDecorator export function Prop(options?: Record<string, unknown>): PropertyDecorator
export function Emit(event?: string): MethodDecorator export function Emit(event?: string): MethodDecorator
export function Watch(path: string, options?: any): MethodDecorator export function Watch(path: string, options?: Record<string, unknown>): MethodDecorator
export function Inject(key?: string | symbol): PropertyDecorator export function Inject(key?: string | symbol): PropertyDecorator
export function Provide(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<string, unknown>): PropertyDecorator
export function Ref(refKey?: string): PropertyDecorator export function Ref(refKey?: string): PropertyDecorator
} }

6
test-apps/daily-notification-test/src/globals.d.ts

@ -2,6 +2,10 @@ export {}
declare global { declare global {
interface Window { interface Window {
Capacitor?: any Capacitor?: {
Plugins?: Record<string, unknown>
isNativePlatform?: () => boolean
getPlatform?: () => string
}
} }
} }

21
test-apps/daily-notification-test/src/types/global.d.ts

@ -31,7 +31,26 @@ declare global {
} }
Capacitor?: { Capacitor?: {
Plugins?: { 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<void>
cancelNotification(id: string): Promise<void>
requestPermissions(): Promise<boolean>
}
Clipboard?: { Clipboard?: {
write(options: { string: string }): Promise<void> write(options: { string: string }): Promise<void>
} }

8
test-apps/daily-notification-test/src/views/HomeView.vue

@ -296,7 +296,7 @@ const runPluginDiagnostics = async (): Promise<void> => {
console.log('✅ DailyNotification plugin available') console.log('✅ DailyNotification plugin available')
// Get all available plugins // Get all available plugins
const allPlugins = Object.keys((window as any).Capacitor?.Plugins || {}) const allPlugins = Object.keys((window as Window & { Capacitor?: { Plugins?: Record<string, unknown> } }).Capacitor?.Plugins || {})
console.log('📋 All available plugins:', allPlugins) console.log('📋 All available plugins:', allPlugins)
// Test the checkStatus method // Test the checkStatus method
@ -311,7 +311,7 @@ const runPluginDiagnostics = async (): Promise<void> => {
dailyNotificationAvailable: true, dailyNotificationAvailable: true,
allAvailablePlugins: allPlugins, allAvailablePlugins: allPlugins,
dailyNotificationStatus: status, dailyNotificationStatus: status,
capacitorVersion: (window as any).Capacitor?.getPlatform ? 'Available' : 'Unknown', capacitorVersion: (window as Window & { Capacitor?: { getPlatform?: () => string } }).Capacitor?.getPlatform ? 'Available' : 'Unknown',
webViewInfo: { webViewInfo: {
userAgent: navigator.userAgent, userAgent: navigator.userAgent,
platform: navigator.platform platform: navigator.platform
@ -331,8 +331,8 @@ const runPluginDiagnostics = async (): Promise<void> => {
} }
} else { } else {
console.warn('⚠️ DailyNotification plugin not available') console.warn('⚠️ DailyNotification plugin not available')
const allPlugins = Object.keys((window as any).Capacitor?.Plugins || {}) const allPlugins = Object.keys((window as Window & { Capacitor?: { Plugins?: Record<string, unknown> } }).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)}`) 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<string, unknown> } }).Capacitor?.Plugins || {}, null, 2)}`)
} }
} else { } else {
console.log('🌐 Running in web mode - plugin not available') console.log('🌐 Running in web mode - plugin not available')

6
test-apps/daily-notification-test/src/views/LogsView.vue

@ -102,11 +102,11 @@ class LogsView extends Vue {
this.isCopying = true this.isCopying = true
try { try {
const text = this.logs.map(l => `[${this.formatTimestamp(l.ts)}] ${l.msg}`).join('\n') 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<void> } })?.clipboard?.writeText) {
await navigator.clipboard.writeText(text); return await navigator.clipboard.writeText(text); return
} }
const Cap = (window as any)?.Capacitor const Cap = (window as Window & { Capacitor?: { Plugins?: Record<string, unknown> } })?.Capacitor
const Clip = Cap?.Plugins?.Clipboard const Clip = Cap?.Plugins?.Clipboard as { write?: (options: { string: string }) => Promise<void> } | undefined
if (Clip?.write) { await Clip.write({ string: text }); return } if (Clip?.write) { await Clip.write({ string: text }); return }
console.warn('No clipboard API available.') console.warn('No clipboard API available.')
} finally { } finally {

Loading…
Cancel
Save