diff options
| author | Darius Jahandarie <djahandarie@gmail.com> | 2023-12-06 03:53:16 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 03:53:16 +0000 |
| commit | bd5bc1a5db29903bc098995cd9262c4576bf76af (patch) | |
| tree | c9214189e0214480fcf6539ad1c6327aef6cbd1c /types/dev | |
| parent | fd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff) | |
| parent | 23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff) | |
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'types/dev')
| -rw-r--r-- | types/dev/dictionary-validate.d.ts | 31 | ||||
| -rw-r--r-- | types/dev/manifest.d.ts | 114 | ||||
| -rw-r--r-- | types/dev/schema-validate.d.ts | 24 | ||||
| -rw-r--r-- | types/dev/vm.d.ts | 38 |
4 files changed, 207 insertions, 0 deletions
diff --git a/types/dev/dictionary-validate.d.ts b/types/dev/dictionary-validate.d.ts new file mode 100644 index 00000000..c39f4335 --- /dev/null +++ b/types/dev/dictionary-validate.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 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 SchemaValidate from './schema-validate'; + +export type Schema = SchemaValidate.Schema; + +export type Schemas = { + index: Schema; + kanjiBankV1: Schema; + kanjiBankV3: Schema; + kanjiMetaBankV3: Schema; + tagBankV3: Schema; + termBankV1: Schema; + termBankV3: Schema; + termMetaBankV3: Schema; +}; diff --git a/types/dev/manifest.d.ts b/types/dev/manifest.d.ts new file mode 100644 index 00000000..e455208f --- /dev/null +++ b/types/dev/manifest.d.ts @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2023 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/>. + */ + +export type Manifest = chrome.runtime.Manifest; + +export type ManifestConfig = { + manifest: Manifest; + defaultVariant: string; + variants: ManifestVariant[]; +}; + +export type ManifestVariant = { + name: string; + buildable?: boolean; + inherit?: string; + fileName?: string; + fileCopies?: string[]; + excludeFiles?: string[]; + modifications: Modification[]; +}; + +export type Modification = ( + ModificationReplace | + ModificationDelete | + ModificationSet | + ModificationAdd | + ModificationRemove | + ModificationSplice | + ModificationCopy | + ModificationMove +); + +export type ModificationReplace = { + action: 'replace'; + path: PropertyPath; + pattern: string; + patternFlags: string; + replacement: string; +}; + +export type ModificationDelete = { + action: 'delete'; + path: PropertyPath; +}; + +export type ModificationSet = { + action: 'set'; + path: PropertyPath; + value: unknown; + before?: string; + after?: string; + index?: number; + command?: Command; +}; + +export type ModificationAdd = { + action: 'add'; + path: PropertyPath; + items: unknown[]; +}; + +export type ModificationRemove = { + action: 'remove'; + path: PropertyPath; + item: unknown; +}; + +export type ModificationSplice = { + action: 'splice'; + path: PropertyPath; + start: number; + deleteCount: number; + items: unknown[]; +}; + +export type ModificationCopy = { + action: 'copy'; + path: PropertyPath; + newPath: PropertyPath; + before?: string; + after?: string; + index?: number; +}; + +export type ModificationMove = { + action: 'move'; + path: PropertyPath; + newPath: PropertyPath; + before?: string; + after?: string; + index?: number; +}; + +export type PropertyPath = (string | number)[]; + +export type Command = { + command: string; + args: string[]; + trim: boolean; +}; diff --git a/types/dev/schema-validate.d.ts b/types/dev/schema-validate.d.ts new file mode 100644 index 00000000..b30c8a04 --- /dev/null +++ b/types/dev/schema-validate.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2023 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 AjvModule from 'ajv'; + +export type ValidateMode = 'ajv' | null; + +export type Schema = unknown; + +export type Ajv = typeof AjvModule.default; diff --git a/types/dev/vm.d.ts b/types/dev/vm.d.ts new file mode 100644 index 00000000..3eb0949f --- /dev/null +++ b/types/dev/vm.d.ts @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 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 Translation from '../ext/translation'; + +export type PseudoChrome = { + runtime: { + getURL(path: string): string; + }; +}; + +export type PseudoFetchResponse = { + ok: boolean; + status: number; + statusText: string; + text(): Promise<string>; + json(): Promise<unknown>; +}; + +export type OptionsPresetObject = { + [key: string]: OptionsPreset; +}; + +export type OptionsPreset = Partial<Translation.FindTermsOptions>; |