From bdaa77ff0d7c23f1594575ac22fb9693f1802b24 Mon Sep 17 00:00:00 2001 From: Cashew <52880648+Scrub1492@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:13:34 +0900 Subject: Narrow down enum types (#431) * narrow down enum types * add enum types * change from default to case * add enum types * remove comments * remove comments * fix * Move getErrorLevelValue to Logger * Add enum type for LogErrorLevelValue * add eslint switch-exhaustiveness-check rule * Revert "add eslint switch-exhaustiveness-check" This reverts commit 49f9caabf0af900bc5ba2b80f5baff72c27e02cd. * move from labelled loop to helper functions * move helper functions downward --- types/ext/dictionary-importer.d.ts | 25 ++++++++++++++++++++++-- types/ext/dom-text-scanner.d.ts | 39 ++++++++++++++++++++++++++++++++++++++ types/ext/log.d.ts | 11 +++++++++++ types/ext/text-scanner.d.ts | 13 +++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 types/ext/dom-text-scanner.d.ts (limited to 'types/ext') diff --git a/types/ext/dictionary-importer.d.ts b/types/ext/dictionary-importer.d.ts index cccfdc42..cda1bd19 100644 --- a/types/ext/dictionary-importer.d.ts +++ b/types/ext/dictionary-importer.d.ts @@ -23,9 +23,30 @@ import type * as StructuredContent from './structured-content'; export type OnProgressCallback = (data: ProgressData) => void; +/** + * An enum representing the import step. + * + * `-2` `-1` Dictionary import is uninitialized. + * + * `0` Load dictionary archive and validate index step. + * + * `1` Load schemas and get archive files step. + * + * `2` Load and validate dictionary data step. + * + * `3` Format dictionary data and extended data support step. + * + * `4` Resolve async requirements and import media step. + * + * `5` Add dictionary descriptor and import data step. + */ +export type ImportStep = -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5; + +export type ImportStepCount = 6; + export type ProgressData = { - stepIndex: number; - stepCount: number; + stepIndex: ImportStep; + stepCount: ImportStepCount; index: number; count: number; }; diff --git a/types/ext/dom-text-scanner.d.ts b/types/ext/dom-text-scanner.d.ts new file mode 100644 index 00000000..e3ae4b53 --- /dev/null +++ b/types/ext/dom-text-scanner.d.ts @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +/** + * An enum representing the attributes of the character. + * + * `0` Character should be ignored. + * + * `1` Character is collapsible whitespace. + * + * `2` Character should be added to the content. + * + * `3` Character should be added to the content and is a newline. + */ +export type CharacterAttributesEnum = 0 | 1 | 2 | 3; + +export type SeekTextNoteDetails = { + done: boolean; + lineHasWhitespace: boolean; + lineHasContent: boolean; + content: string; + offset: number; + remainder: number; + newlines: number; +}; diff --git a/types/ext/log.d.ts b/types/ext/log.d.ts index ac2f606b..904bf848 100644 --- a/types/ext/log.d.ts +++ b/types/ext/log.d.ts @@ -22,3 +22,14 @@ export type LoggerEventType = 'log'; export type LogContext = { url: string; }; + +/** + * An enum representing the log error level. + * + * `0` _log_, _info_, _debug_ level. + * + * `1` _warn_ level. + * + * `2` _error_ level. + */ +export type LogErrorLevelValue = 0 | 1 | 2; diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index 5b806dab..d56d623a 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -185,6 +185,19 @@ export type PointerEventType = ( 'script' ); +/** + * An enum representing the pen pointer state. + * + * `0` Not active. + * + * `1` Hovering. + * + * `2` Touching. + * + * `3` Hovering after touching. + */ +export type PenPointerState = 0 | 1 | 2 | 3; + export type SentenceTerminatorMap = Map; export type SentenceForwardQuoteMap = Map; -- cgit v1.2.3