aboutsummaryrefslogtreecommitdiff
path: root/types/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-01 10:00:59 -0500
committerGitHub <noreply@github.com>2024-02-01 15:00:59 +0000
commitdfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch)
tree04686b943b84b33b8927238be17e4bc0dda7eb62 /types/ext
parent2356223942a21d1683ac38eed8e7b9485f453d87 (diff)
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code
Diffstat (limited to 'types/ext')
-rw-r--r--types/ext/anki-note-builder.d.ts20
-rw-r--r--types/ext/display.d.ts2
-rw-r--r--types/ext/frontend.d.ts3
-rw-r--r--types/ext/popup.d.ts7
-rw-r--r--types/ext/text-scanner.d.ts2
5 files changed, 34 insertions, 0 deletions
diff --git a/types/ext/anki-note-builder.d.ts b/types/ext/anki-note-builder.d.ts
index 092978ed..8aec3342 100644
--- a/types/ext/anki-note-builder.d.ts
+++ b/types/ext/anki-note-builder.d.ts
@@ -23,6 +23,7 @@ import type * as Dictionary from './dictionary';
import type * as Extension from './extension';
import type * as Settings from './settings';
import type * as TemplateRenderer from './template-renderer';
+import type * as Api from './api';
export type CreateNoteDetails = {
dictionaryEntry: Dictionary.DictionaryEntry;
@@ -118,3 +119,22 @@ export type BatchedRequestData = {
reject: (reason?: unknown) => void;
marker: string;
};
+
+export type MinimalApi = {
+ injectAnkiNoteMedia(
+ timestamp: Api.ApiParam<'injectAnkiNoteMedia', 'timestamp'>,
+ definitionDetails: Api.ApiParam<'injectAnkiNoteMedia', 'definitionDetails'>,
+ audioDetails: Api.ApiParam<'injectAnkiNoteMedia', 'audioDetails'>,
+ screenshotDetails: Api.ApiParam<'injectAnkiNoteMedia', 'screenshotDetails'>,
+ clipboardDetails: Api.ApiParam<'injectAnkiNoteMedia', 'clipboardDetails'>,
+ dictionaryMediaDetails: Api.ApiParam<'injectAnkiNoteMedia', 'dictionaryMediaDetails'>,
+ ): Promise<Api.ApiReturn<'injectAnkiNoteMedia'>>;
+
+ parseText(
+ text: Api.ApiParam<'parseText', 'text'>,
+ optionsContext: Api.ApiParam<'parseText', 'optionsContext'>,
+ scanLength: Api.ApiParam<'parseText', 'scanLength'>,
+ useInternalParser: Api.ApiParam<'parseText', 'useInternalParser'>,
+ useMecabParser: Api.ApiParam<'parseText', 'useMecabParser'>,
+ ): Promise<Api.ApiReturn<'parseText'>>;
+};
diff --git a/types/ext/display.d.ts b/types/ext/display.d.ts
index da24af75..351cf067 100644
--- a/types/ext/display.d.ts
+++ b/types/ext/display.d.ts
@@ -18,6 +18,7 @@
import type {DisplayContentManager} from '../../ext/js/display/display-content-manager';
import type {HotkeyHelpController} from '../../ext/js/input/hotkey-help-controller';
import type {TextSourceGenerator} from '../../ext/js/dom/text-source-generator';
+import type {API} from '../../ext/js/comm/api';
import type * as Dictionary from './dictionary';
import type * as Extension from './extension';
import type * as Settings from './settings';
@@ -127,6 +128,7 @@ export type SearchMode = null | 'popup' | 'action-popup';
export type GetSearchContextCallback = TextScannerTypes.GetSearchContextCallbackSync;
export type QueryParserConstructorDetails = {
+ api: API;
getSearchContext: GetSearchContextCallback;
textSourceGenerator: TextSourceGenerator;
};
diff --git a/types/ext/frontend.d.ts b/types/ext/frontend.d.ts
index 53a849a2..17f3d121 100644
--- a/types/ext/frontend.d.ts
+++ b/types/ext/frontend.d.ts
@@ -17,9 +17,12 @@
import type {PopupFactory} from '../../ext/js/app/popup-factory';
import type {HotkeyHandler} from '../../ext/js/input/hotkey-handler';
+import type {Application} from '../../ext/js/application';
/** Details about how to set up the instance. */
export type ConstructorDetails = {
+ /** The main application instance. */
+ application: Application;
/** The type of page, one of 'web', 'popup', or 'search'. */
pageType: PageType;
/** A PopupFactory instance to use for generating popups. */
diff --git a/types/ext/popup.d.ts b/types/ext/popup.d.ts
index 4246e24e..1ea25c15 100644
--- a/types/ext/popup.d.ts
+++ b/types/ext/popup.d.ts
@@ -19,6 +19,7 @@ import type {Popup} from '../../ext/js/app/popup';
import type {PopupProxy} from '../../ext/js/app/popup-proxy';
import type {PopupWindow} from '../../ext/js/app/popup-window';
import type {FrameOffsetForwarder} from '../../ext/js/comm/frame-offset-forwarder';
+import type {Application} from '../../ext/js/application';
import type * as DocumentUtil from './document-util';
import type * as Settings from './settings';
import type {EventNames, EventArgument as BaseEventArgument} from './core';
@@ -92,6 +93,8 @@ export type ValidSize = {
};
export type PopupConstructorDetails = {
+ /** The main application instance. */
+ application: Application;
/** The ID of the popup. */
id: string;
/** The depth of the popup. */
@@ -103,6 +106,8 @@ export type PopupConstructorDetails = {
};
export type PopupWindowConstructorDetails = {
+ /** The main application instance. */
+ application: Application;
/** The ID of the popup. */
id: string;
/** The depth of the popup. */
@@ -112,6 +117,8 @@ export type PopupWindowConstructorDetails = {
};
export type PopupProxyConstructorDetails = {
+ /** The main application instance. */
+ application: Application;
/** The ID of the popup. */
id: string;
/** The depth of the popup. */
diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts
index 3e1cb6c2..4253d6cc 100644
--- a/types/ext/text-scanner.d.ts
+++ b/types/ext/text-scanner.d.ts
@@ -17,6 +17,7 @@
import type {TextScanner} from '../../ext/js/language/text-scanner';
import type {TextSourceGenerator} from '../../ext/js/dom/text-source-generator';
+import type {API} from '../../ext/js/comm/api';
import type * as Dictionary from './dictionary';
import type * as Display from './display';
import type * as Input from './input';
@@ -138,6 +139,7 @@ export type GetSearchContextCallbackSync = () => SearchContext;
export type GetSearchContextCallbackAsync = () => Promise<SearchContext>;
export type ConstructorDetails = {
+ api: API;
node: HTMLElement | Window;
getSearchContext: GetSearchContextCallback;
ignoreElements?: (() => Element[]) | null;