mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-22 17:16:19 -07:00
feat(dictionary): add Hachidori backend support
- Add backend selection, setup gating, Anki integration, and external host support - Add launcher flags, documentation, packaging, and focused tests - Open on-demand overlay modals on the first attempt
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// Shared by native modules and manifest-loaded content scripts.
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function normaliseLookupTerm(term, reading = "") {
|
||||
if (typeof term !== "string" || typeof reading !== "string" || term.trim() === "") {
|
||||
throw new TypeError("Lookup statistics require a nonempty term and a reading string.");
|
||||
}
|
||||
return { term: term.trim().normalize("NFC"), reading: reading.trim().normalize("NFC") };
|
||||
}
|
||||
|
||||
function lookupStatsPrefix(descriptor) {
|
||||
return `lookupStats:${JSON.stringify(descriptor.generation)}:`;
|
||||
}
|
||||
|
||||
function lookupStatsKey(descriptor, { term, reading }) {
|
||||
return lookupStatsPrefix(descriptor) + JSON.stringify([term, reading]);
|
||||
}
|
||||
|
||||
globalThis.HDLookupStats = { normaliseLookupTerm, lookupStatsPrefix, lookupStatsKey };
|
||||
}());
|
||||
Reference in New Issue
Block a user