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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* 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 Anki from './anki';
import type * as AnkiTemplates from './anki-templates';
import type * as AnkiTemplatesInternal from './anki-templates-internal';
import type * as Audio from './audio';
import type * as Dictionary from './dictionary';
import type * as Extension from './extension';
import type * as Settings from './settings';
import type * as TemplateRenderer from './template-renderer';
import type * as Api from './api';
import type * as Language from './language';
export type CreateNoteDetails = {
dictionaryEntry: Dictionary.DictionaryEntry;
mode: AnkiTemplatesInternal.CreateMode;
context: AnkiTemplatesInternal.Context;
template: string;
deckName: string;
modelName: string;
fields: Field[];
tags: string[];
requirements: Requirement[];
duplicateScope: Settings.AnkiDuplicateScope;
duplicateScopeCheckAllModels: boolean;
resultOutputMode: Settings.ResultOutputMode;
glossaryLayoutMode: Settings.GlossaryLayoutMode;
compactTags: boolean;
mediaOptions: MediaOptions | null;
dictionaryStylesMap: Map<string, string>;
};
export type Field = [
name: string,
value: string,
];
export type CreateNoteResult = {
note: Anki.Note;
errors: Error[];
requirements: Requirement[];
};
export type GetRenderingDataDetails = {
dictionaryEntry: Dictionary.DictionaryEntry;
mode: AnkiTemplatesInternal.CreateMode;
context: AnkiTemplatesInternal.Context;
resultOutputMode?: Settings.ResultOutputMode;
glossaryLayoutMode?: Settings.GlossaryLayoutMode;
compactTags?: boolean;
marker: string;
dictionaryStylesMap: Map<string, string>;
};
export type CommonData = AnkiTemplatesInternal.CreateDetails;
export type RequirementGeneric = {
type: 'audio' | 'screenshot' | 'clipboardImage' | 'clipboardText' | 'selectionText';
};
export type RequirementTextFurigana = {
type: 'textFurigana';
text: string;
readingMode: AnkiTemplates.TextFuriganaReadingMode;
};
export type RequirementDictionaryMedia = {
type: 'dictionaryMedia';
dictionary: string;
path: string;
};
export type Requirement = RequirementGeneric | RequirementTextFurigana | RequirementDictionaryMedia;
export type AudioMediaOptions = {
sources: Audio.AudioSourceInfo[];
preferredAudioIndex: number | null;
idleTimeout: number | null;
languageSummary: Language.LanguageSummary;
};
export type MediaOptions = {
audio: AudioMediaOptions | null;
screenshot: {
format: Settings.AnkiScreenshotFormat;
quality: number;
contentOrigin: Extension.ContentOrigin;
};
textParsing: {
optionsContext: Settings.OptionsContext;
scanLength: number;
};
};
export type TextFuriganaDetails = {
text: string;
readingMode: AnkiTemplates.TextFuriganaReadingMode;
};
export type BatchedRequestGroup = {
template: string;
commonDataRequestsMap: Map<CommonData, BatchedRequestData[]>;
};
export type BatchedRequestData = {
resolve: (result: TemplateRenderer.RenderResult) => void;
reject: (reason?: unknown) => void;
marker: string;
};
export type MinimalApi = {
injectAnkiNoteMedia(
timestamp: Api.ApiParam<'injectAnkiNoteMedia', 'timestamp'>,
definitionDetails: Api.ApiParam<'injectAnkiNoteMedia', 'definitionDetails'>,
audioDetails: Api.ApiParam<'injectAnkiNoteMedia', 'audioDetails'>,
screenshotDetails: Api.ApiParam<'injectAnkiNoteMedia', 'screenshotDetails'>,
clipboardDetails: Api.ApiParam<'injectAnkiNoteMedia', 'clipboardDetails'>,
dictionaryMediaDetails: Api.ApiParam<'injectAnkiNoteMedia', 'dictionaryMediaDetails'>,
): Promise<Api.ApiReturn<'injectAnkiNoteMedia'>>;
parseText(
text: Api.ApiParam<'parseText', 'text'>,
optionsContext: Api.ApiParam<'parseText', 'optionsContext'>,
scanLength: Api.ApiParam<'parseText', 'scanLength'>,
useInternalParser: Api.ApiParam<'parseText', 'useInternalParser'>,
useMecabParser: Api.ApiParam<'parseText', 'useMecabParser'>,
): Promise<Api.ApiReturn<'parseText'>>;
};
|