Pop-up dictionary browser extension for language learning. Successor to Yomichan. (PERSONAL FORK)
1/*
2 * Copyright (C) 2023-2025 Yomitan Authors
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18import type {TextToSpeechAudio} from '../../ext/js/media/text-to-speech-audio';
19import type * as Audio from './audio';
20import type * as AudioDownloader from './audio-downloader';
21import type * as Settings from './settings';
22
23export type CacheItem = {
24 sourceMap: Map<number, CachedInfoList>;
25 primaryCardAudio: PrimaryCardAudio | null;
26};
27
28export type CachedInfoList = {
29 infoListPromise: Promise<AudioInfoList>;
30 infoList: AudioInfoList | null;
31};
32
33export type AudioInfoList = AudioInfoListItem[];
34
35export type AudioInfoListItem = {
36 info: AudioDownloader.Info;
37 audioPromise: Promise<GenericAudio> | null;
38 audioResolved: boolean;
39 audio: GenericAudio | null;
40};
41
42export type PrimaryCardAudio = {
43 index: number;
44 subIndex: number | null;
45};
46
47export type SourceInfo = {
48 source: AudioSource | null;
49 subIndex: number | null;
50};
51
52export type AudioSource = {
53 index: number;
54 type: Settings.AudioSourceType;
55 url: string;
56 voice: string;
57 isInOptions: boolean;
58 downloadable: boolean;
59 name: string;
60 nameIndex: number;
61 nameUnique: boolean;
62};
63
64export type AudioSourceShort = {
65 type: Settings.AudioSourceType;
66 url: string;
67 voice: string;
68};
69
70export type AudioMediaOptions = {
71 sources: Audio.AudioSourceInfo[];
72 preferredAudioIndex: number | null;
73 enableDefaultAudioSources: boolean;
74};
75
76export type PlayAudioResult = {
77 audio: GenericAudio | null;
78 source: AudioSource | null;
79 subIndex: number;
80 valid: boolean;
81};
82
83export type TermAudio = {
84 audio: GenericAudio;
85 source: AudioSource;
86 subIndex: number;
87};
88
89export type CreateAudioResult = {
90 audio: GenericAudio | null;
91 index: number;
92 cacheUpdated: boolean;
93};
94
95export type GenericAudio = HTMLAudioElement | TextToSpeechAudio;
96
97export type MenuItemEntry = {
98 valid: boolean | null;
99 index: number | null;
100 name: string | null;
101};