
export interface UseSchedulerFastCall {
  timeId: NodeJS.Timer | null,
  start: () => void
  pause: () => void
  stop: () => void
  onPlaying: () => void
}

/**
 * @description 重复执行的定时器， 会在组件的unMounted卸载
 */
export interface UseScheduler {
  (options: {
    delay: number,
    cb: () => void
  }): [UseSchedulerFastCall];
}

export interface UseSchedulerOnceProps {
  delay: number,
  cb: () => void
}

export interface UseAudioFastCall {
  src: string,
  playing: boolean,
  updateTime: string | number,
  duration: string | number,
  percentage: number
  play:() => void,
  pause:() => void,
  onended: ((this: GlobalEventHandlers, ev: Event) => any) | null
}

export interface UseAudioManager {
  (options: Partial<{
    url: string,
    format: string
  }>): [UseAudioFastCall, HTMLAudioElement]
}

// export interface UseDeviceDire {

// }

declare global {
  interface Window {
    navAppPage: {
      postMessage: (params: string) => void,
    },
    popPage: {
      postMessage: (params?: string) => void,
    },
    navigateExercise: {
      postMessage: (params?: string) => void,
    }
    navigateRecord: {
      postMessage: (params?: string) => void,
    }
    reloadGame: {
      postMessage: (params?: string) => void,
    },
    getToken: {
      postMessage: (params?: string) => void,
    },
    sharePoster: {
      postMessage: (params?: string) => void,
    },
    savePoster: {
      postMessage: (params?: string) => void,
    }
    returnToken: (token: string) => void
    $audio: HTMLAudioElement
  }
}
