refactor: configure Hachidori in the SubMiner build

This commit is contained in:
2026-09-22 12:26:37 -07:00
parent 5354fdf7b9
commit d7e1d7edc6
10 changed files with 113 additions and 21 deletions
+13
View File
@@ -11,6 +11,19 @@ export const YOMITAN_POPUP_COMMAND_EVENT = 'subminer-yomitan-popup-command';
export const YOMITAN_LOOKUP_EVENT = 'subminer-yomitan-lookup';
export const PRIMARY_SUB_VISIBLE_ON_YOMITAN_POPUP_CLASS = 'primary-sub-visible-on-yomitan-popup';
// Only the active backend injects a reader. Consume its native attention events.
export function registerDictionaryPopupVisibilityListener(
state: 'shown' | 'hidden',
listener: () => void,
target: EventTarget = window,
): () => void {
const events = [`yomitan-popup-${state}`, `hachidori-popup-${state}`];
for (const event of events) target.addEventListener(event, listener);
return () => {
for (const event of events) target.removeEventListener(event, listener);
};
}
export function registerYomitanLookupListener(
target: EventTarget = window,
listener: () => void,