diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-11-27 12:48:14 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-11-27 12:48:14 -0500 |
commit | 4da4827bcbcdd1ef163f635d9b29416ff272b0bb (patch) | |
tree | a8a0f1a8befdb78a554e1be91f2c6059ca3ad5f9 /types/dev | |
parent | fd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff) |
Add JSDoc type annotations to project (rebased)
Diffstat (limited to 'types/dev')
-rw-r--r-- | types/dev/dictionary-validate.d.ts | 31 | ||||
-rw-r--r-- | types/dev/manifest.d.ts | 112 | ||||
-rw-r--r-- | types/dev/schema-validate.d.ts | 24 | ||||
-rw-r--r-- | types/dev/vm.d.ts | 59 |
4 files changed, 226 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..4fdf3b14 --- /dev/null +++ b/types/dev/manifest.d.ts @@ -0,0 +1,112 @@ +/* + * 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 = { + manifest: chrome.runtime.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..f103de97 --- /dev/null +++ b/types/dev/vm.d.ts @@ -0,0 +1,59 @@ +/* + * 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 PseudoURL = { + hash: string; + host: string; + hostname: string; + href: string; + toString(): string; + origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + searchParams: URLSearchParams; + username: string; + toJSON(): string; +}; + +export type VMAssert = { + deepStrictEqual: (actual: unknown, expected: unknown) => void; +}; + +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>; |