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 * as AnkiNoteBuilder from './anki-note-builder';
19import type * as AnkiTemplates from './anki-templates';
20import type * as Core from './core';
21
22export type RenderResult = {
23 result: string;
24 requirements: AnkiNoteBuilder.Requirement[];
25};
26
27export type RenderMultiItem = {
28 template: string;
29 templateItems: RenderMultiTemplateItem[];
30};
31
32export type RenderMultiTemplateItem = {
33 type: AnkiTemplates.RenderMode;
34 commonData: AnkiNoteBuilder.CommonData;
35 datas: PartialOrCompositeRenderData[];
36};
37
38export type PartialRenderData = {
39 marker: string;
40 commonData?: undefined;
41};
42
43export type CompositeRenderData = {
44 marker: string;
45 commonData: AnkiNoteBuilder.CommonData;
46};
47
48export type PartialOrCompositeRenderData = PartialRenderData | CompositeRenderData;
49
50export type DataType = {
51 modifier: (data: CompositeRenderData) => AnkiTemplates.NoteData;
52 composeData: (data: PartialOrCompositeRenderData, commonData: AnkiNoteBuilder.CommonData) => CompositeRenderData;
53};
54
55export type HelperOptionsFunction<TResult = unknown> = (context: unknown) => TResult;
56
57export type HelperOptions = {
58 fn?: HelperOptionsFunction;
59 inverse?: HelperOptionsFunction;
60 hash: Core.SerializableObject;
61 data?: Core.SafeAny;
62};
63
64export type HelperFunction<TReturn = unknown> = (args: unknown[], context: unknown, options: HelperOptions) => TReturn;
65
66export type HelperFunctionsDescriptor = [
67 name: string,
68 helper: HelperFunction<unknown>,
69][];
70
71export type SetupCallbackResult = {
72 requirements: AnkiNoteBuilder.Requirement[];
73};
74
75export type CleanupCallbackResult = void;