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
18export type ValueObject = {[key: string]: Value};
19
20export type Value = string | number | boolean | null | Value[] | ValueObject;
21
22export type ValueObjectOrArray = ValueObject | Value[];
23
24export type Type = 'string' | 'number' | 'integer' | 'object' | 'array' | 'boolean' | 'null';
25
26export type SchemaObject = {
27 type?: Type | Type[];
28 required?: string[];
29
30 default?: Value;
31 enum?: Value[];
32 const?: Value;
33 minimum?: number;
34 maximum?: number;
35 exclusiveMinimum?: number;
36 exclusiveMaximum?: number;
37 multipleOf?: number;
38 minLength?: number;
39 maxLength?: number;
40 pattern?: string;
41 patternFlags?: string;
42 minItems?: number;
43 maxItems?: number;
44 minProperties?: number;
45 maxProperties?: number;
46 definitions?: {[key: string]: Schema};
47
48 $ref?: string;
49
50 properties?: {[key: string]: Schema};
51 additionalProperties?: Schema;
52 not?: Schema;
53 oneOf?: Schema[];
54 allOf?: Schema[];
55 anyOf?: Schema[];
56 contains?: Schema;
57 prefixItems?: Schema[];
58 items?: Schema | Schema[]; // Legacy schema format for the array
59 additionalItems?: Schema;
60 if?: Schema;
61 then?: Schema;
62 else?: Schema;
63};
64
65export type Schema = SchemaObject | true | false;
66
67export type SchemaStackItem = {
68 schema: Schema | Schema[];
69 path: string | number | null;
70};
71
72export type ValueStackItem = {
73 value: unknown;
74 path: string | number | null;
75};