From 4da4827bcbcdd1ef163f635d9b29416ff272b0bb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 12:48:14 -0500 Subject: Add JSDoc type annotations to project (rebased) --- types/dev/dictionary-validate.d.ts | 31 ++++++++++ types/dev/manifest.d.ts | 112 +++++++++++++++++++++++++++++++++++++ types/dev/schema-validate.d.ts | 24 ++++++++ types/dev/vm.d.ts | 59 +++++++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 types/dev/dictionary-validate.d.ts create mode 100644 types/dev/manifest.d.ts create mode 100644 types/dev/schema-validate.d.ts create mode 100644 types/dev/vm.d.ts (limited to 'types/dev') 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 . + */ + +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 . + */ + +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 . + */ + +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 . + */ + +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; + json(): Promise; +}; + +export type OptionsPresetObject = { + [key: string]: OptionsPreset; +}; + +export type OptionsPreset = Partial; -- cgit v1.2.3