aboutsummaryrefslogtreecommitdiff
path: root/types/ext/translator.d.ts
blob: 0a4053cff490313b0672d6d57d85a8cfc0b6d24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (C) 2023-2024  Yomitan Authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

import type * as Dictionary from './dictionary';
import type * as DictionaryDatabaseTypes from './dictionary-database';

/**
 * Information about how popup content should be shown, specifically related to the outer popup frame.
 */
export type TermFrequencySimple = {
    /** The term. */
    term: string;
    /** The reading of the term. */
    reading: string | null;
    /** The name of the dictionary that the term frequency originates from. */
    dictionary: string;
    /** Whether or not a reading was specified. */
    hasReading: boolean;
    /** The frequency value for the term. */
    frequency: number;
    /** The display value for the frequency, or `null` if none is specified. */
    displayValue: string | null;
    /** Whether or not the `frequency` field is derived from a parsed string. */
    displayValueParsed: boolean;
};

export type TagGroup = {
    dictionary: string;
    tagNames: string[];
};

export type TagExpansionTarget = {
    tags: Dictionary.Tag[];
    tagGroups: TagGroup[];
};

export type DictionaryTagCache = Map<string, TagCache>;

export type TagCache = Map<string, DictionaryDatabaseTypes.Tag | null>;

export type TagTargetMap = Map<string, Map<string, TagTargetItem>>;

export type TagTargetItem = {
    query: string;
    dictionary: string;
    tagName: string;
    cache: TagCache | null;
    databaseTag: DictionaryDatabaseTypes.Tag | null;
    targets: Dictionary.Tag[][];
};

export type SequenceQuery = {
    query: number;
    dictionary: string;
};

export type FindTermsMode = 'simple' | 'group' | 'merge' | 'split';

export type TermReadingItem = {
    term: string;
    reading: string | null;
};

export type TermReadingList = TermReadingItem[];

export type FindTermsResult = {
    dictionaryEntries: Dictionary.TermDictionaryEntry[];
    originalTextLength: number;
};