aboutsummaryrefslogtreecommitdiff
path: root/ext/js/dictionary
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/dictionary')
-rw-r--r--ext/js/dictionary/dictionary-data-util.js8
-rw-r--r--ext/js/dictionary/dictionary-database.js58
-rw-r--r--ext/js/dictionary/dictionary-importer.js34
-rw-r--r--ext/js/dictionary/dictionary-worker-handler.js4
-rw-r--r--ext/js/dictionary/dictionary-worker-media-loader.js2
-rw-r--r--ext/js/dictionary/dictionary-worker.js6
6 files changed, 56 insertions, 56 deletions
diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js
index dfdd5601..1c5dd5e5 100644
--- a/ext/js/dictionary/dictionary-data-util.js
+++ b/ext/js/dictionary/dictionary-data-util.js
@@ -85,7 +85,7 @@ export function groupTermFrequencies(dictionaryEntry) {
frequencies.push({
term,
reading,
- values: [...values.values()]
+ values: [...values.values()],
});
}
results.push({dictionary, frequencies});
@@ -122,7 +122,7 @@ export function groupKanjiFrequencies(sourceFrequencies) {
for (const {character, values} of map2.values()) {
frequencies.push({
character,
- values: [...values.values()]
+ values: [...values.values()],
});
}
results.push({dictionary, frequencies});
@@ -159,7 +159,7 @@ export function getGroupedPronunciations(dictionaryEntry) {
groupedPronunciation = {
pronunciation,
terms: new Set(),
- reading
+ reading,
};
dictionaryGroupedPronunciationList.push(groupedPronunciation);
}
@@ -185,7 +185,7 @@ export function getGroupedPronunciations(dictionaryEntry) {
terms: [...terms],
reading,
exclusiveTerms,
- exclusiveReadings
+ exclusiveReadings,
});
}
diff --git a/ext/js/dictionary/dictionary-database.js b/ext/js/dictionary/dictionary-database.js
index ca90f6a6..e15d486c 100644
--- a/ext/js/dictionary/dictionary-database.js
+++ b/ext/js/dictionary/dictionary-database.js
@@ -68,67 +68,67 @@ export class DictionaryDatabase {
stores: {
terms: {
primaryKey: {keyPath: 'id', autoIncrement: true},
- indices: ['dictionary', 'expression', 'reading']
+ indices: ['dictionary', 'expression', 'reading'],
},
kanji: {
primaryKey: {autoIncrement: true},
- indices: ['dictionary', 'character']
+ indices: ['dictionary', 'character'],
},
tagMeta: {
primaryKey: {autoIncrement: true},
- indices: ['dictionary']
+ indices: ['dictionary'],
},
dictionaries: {
primaryKey: {autoIncrement: true},
- indices: ['title', 'version']
- }
- }
+ indices: ['title', 'version'],
+ },
+ },
}),
{
version: 30,
stores: {
termMeta: {
primaryKey: {autoIncrement: true},
- indices: ['dictionary', 'expression']
+ indices: ['dictionary', 'expression'],
},
kanjiMeta: {
primaryKey: {autoIncrement: true},
- indices: ['dictionary', 'character']
+ indices: ['dictionary', 'character'],
},
tagMeta: {
primaryKey: {autoIncrement: true},
- indices: ['dictionary', 'name']
- }
- }
+ indices: ['dictionary', 'name'],
+ },
+ },
},
{
version: 40,
stores: {
terms: {
primaryKey: {keyPath: 'id', autoIncrement: true},
- indices: ['dictionary', 'expression', 'reading', 'sequence']
- }
- }
+ indices: ['dictionary', 'expression', 'reading', 'sequence'],
+ },
+ },
},
{
version: 50,
stores: {
terms: {
primaryKey: {keyPath: 'id', autoIncrement: true},
- indices: ['dictionary', 'expression', 'reading', 'sequence', 'expressionReverse', 'readingReverse']
- }
- }
+ indices: ['dictionary', 'expression', 'reading', 'sequence', 'expressionReverse', 'readingReverse'],
+ },
+ },
},
{
version: 60,
stores: {
media: {
primaryKey: {keyPath: 'id', autoIncrement: true},
- indices: ['dictionary', 'path']
- }
- }
- }
- ])
+ indices: ['dictionary', 'path'],
+ },
+ },
+ },
+ ]),
);
}
@@ -179,11 +179,11 @@ export class DictionaryDatabase {
['terms', 'dictionary'],
['termMeta', 'dictionary'],
['tagMeta', 'dictionary'],
- ['media', 'dictionary']
+ ['media', 'dictionary'],
],
[
- ['dictionaries', 'title']
- ]
+ ['dictionaries', 'title'],
+ ],
];
let storeCount = 0;
@@ -196,7 +196,7 @@ export class DictionaryDatabase {
count: 0,
processed: 0,
storeCount,
- storesProcesed: 0
+ storesProcesed: 0,
};
/**
@@ -370,7 +370,7 @@ export class DictionaryDatabase {
['terms', 'dictionary'],
['termMeta', 'dictionary'],
['tagMeta', 'dictionary'],
- ['media', 'dictionary']
+ ['media', 'dictionary'],
];
const objectStoreNames = targets.map(([objectStoreName]) => objectStoreName);
const transaction = this._db.transaction(objectStoreNames, 'readonly');
@@ -596,7 +596,7 @@ export class DictionaryDatabase {
score: row.score,
dictionary: row.dictionary,
id: row.id,
- sequence: typeof sequence === 'number' ? sequence : -1
+ sequence: typeof sequence === 'number' ? sequence : -1,
};
}
@@ -615,7 +615,7 @@ export class DictionaryDatabase {
tags: this._splitField(row.tags),
definitions: row.meanings,
stats: typeof stats === 'object' && stats !== null ? stats : {},
- dictionary: row.dictionary
+ dictionary: row.dictionary,
};
}
diff --git a/ext/js/dictionary/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js
index 98612d9e..62453a13 100644
--- a/ext/js/dictionary/dictionary-importer.js
+++ b/ext/js/dictionary/dictionary-importer.js
@@ -22,7 +22,7 @@ import {
TextWriter as TextWriter0,
Uint8ArrayReader as Uint8ArrayReader0,
ZipReader as ZipReader0,
- configure
+ configure,
} from '../../lib/zip.js';
import {ExtensionError} from '../core/extension-error.js';
import {parseJson} from '../core/json.js';
@@ -69,8 +69,8 @@ export class DictionaryImporter {
configure({
workerScripts: {
deflate: ['../../lib/z-worker.js'],
- inflate: ['../../lib/z-worker.js']
- }
+ inflate: ['../../lib/z-worker.js'],
+ },
});
// Read archive
@@ -108,7 +108,7 @@ export class DictionaryImporter {
if (await dictionaryDatabase.dictionaryExists(dictionaryTitle)) {
return {
errors: [new Error(`Dictionary ${dictionaryTitle} is already imported, skipped it.`)],
- result: null
+ result: null,
};
}
@@ -123,7 +123,7 @@ export class DictionaryImporter {
['termMetaFiles', /^term_meta_bank_(\d+)\.json$/],
['kanjiFiles', /^kanji_bank_(\d+)\.json$/],
['kanjiMetaFiles', /^kanji_meta_bank_(\d+)\.json$/],
- ['tagFiles', /^tag_bank_(\d+)\.json$/]
+ ['tagFiles', /^tag_bank_(\d+)\.json$/],
];
const {termFiles, termMetaFiles, kanjiFiles, kanjiMetaFiles, tagFiles} = Object.fromEntries(this._getArchiveFiles(fileMap, queryDetails));
@@ -187,7 +187,7 @@ export class DictionaryImporter {
kanji: {total: kanjiList.length},
kanjiMeta: this._getMetaCounts(kanjiMetaList),
tagMeta: {total: tagList.length},
- media: {total: media.length}
+ media: {total: media.length},
};
const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported, counts});
await dictionaryDatabase.bulkAdd('dictionaries', [summary], 0, 1);
@@ -238,7 +238,7 @@ export class DictionaryImporter {
stepIndex: 0,
stepCount: 6,
index: 0,
- count: 0
+ count: 0,
};
}
@@ -282,7 +282,7 @@ export class DictionaryImporter {
version,
importDate: Date.now(),
prefixWildcardsSupported,
- counts
+ counts,
};
const {author, url, description, attribution, frequencyMode, sourceLanguage, targetLanguage} = index;
@@ -361,7 +361,7 @@ export class DictionaryImporter {
/** @type {import('dictionary-data').TermGlossaryImage} */
const target = {
type: 'image',
- path: '' // Will be populated during requirement resolution
+ path: '', // Will be populated during requirement resolution
};
requirements.push({type: 'image', target, source: data, entry});
return target;
@@ -377,7 +377,7 @@ export class DictionaryImporter {
const content = this._prepareStructuredContent(data.content, entry, requirements);
return {
type: 'structured-content',
- content
+ content,
};
}
@@ -419,7 +419,7 @@ export class DictionaryImporter {
/** @type {import('structured-content').ImageElement} */
const target = {
tag: 'img',
- path: '' // Will be populated during requirement resolution
+ path: '', // Will be populated during requirement resolution
};
requirements.push({type: 'structured-content-image', target, source: content, entry});
return target;
@@ -441,7 +441,7 @@ export class DictionaryImporter {
}
return {
- media: [...media.values()]
+ media: [...media.values()],
};
}
@@ -456,7 +456,7 @@ export class DictionaryImporter {
context,
requirement.target,
requirement.source,
- requirement.entry
+ requirement.entry,
);
break;
case 'structured-content-image':
@@ -464,7 +464,7 @@ export class DictionaryImporter {
context,
requirement.target,
requirement.source,
- requirement.entry
+ requirement.entry,
);
break;
default:
@@ -495,7 +495,7 @@ export class DictionaryImporter {
verticalAlign,
border,
borderRadius,
- sizeUnits
+ sizeUnits,
} = source;
await this._createImageData(context, target, source, entry);
if (typeof verticalAlign === 'string') { target.verticalAlign = verticalAlign; }
@@ -523,7 +523,7 @@ export class DictionaryImporter {
appearance,
background,
collapsed,
- collapsible
+ collapsible,
} = source;
const {width, height} = await this._getImageMedia(context, path, entry);
target.path = path;
@@ -601,7 +601,7 @@ export class DictionaryImporter {
mediaType,
width,
height,
- content
+ content,
};
media.set(path, mediaData);
diff --git a/ext/js/dictionary/dictionary-worker-handler.js b/ext/js/dictionary/dictionary-worker-handler.js
index 4e263c21..8c74373c 100644
--- a/ext/js/dictionary/dictionary-worker-handler.js
+++ b/ext/js/dictionary/dictionary-worker-handler.js
@@ -67,7 +67,7 @@ export class DictionaryWorkerHandler {
const onProgress = (...args) => {
self.postMessage({
action: 'progress',
- params: {args}
+ params: {args},
});
};
let response;
@@ -92,7 +92,7 @@ export class DictionaryWorkerHandler {
const {result, errors} = await dictionaryImporter.importDictionary(dictionaryDatabase, archiveContent, details);
return {
result,
- errors: errors.map((error) => ExtensionError.serialize(error))
+ errors: errors.map((error) => ExtensionError.serialize(error)),
};
} finally {
void dictionaryDatabase.close();
diff --git a/ext/js/dictionary/dictionary-worker-media-loader.js b/ext/js/dictionary/dictionary-worker-media-loader.js
index 5c18e184..e6f8222b 100644
--- a/ext/js/dictionary/dictionary-worker-media-loader.js
+++ b/ext/js/dictionary/dictionary-worker-media-loader.js
@@ -57,7 +57,7 @@ export class DictionaryWorkerMediaLoader {
// This is executed in a Worker context, so the self needs to be force cast
/** @type {Worker} */ (/** @type {unknown} */ (self)).postMessage({
action: 'getImageDetails',
- params: {id, content, mediaType}
+ params: {id, content, mediaType},
}, [content]);
});
}
diff --git a/ext/js/dictionary/dictionary-worker.js b/ext/js/dictionary/dictionary-worker.js
index bd6d5345..26e23f30 100644
--- a/ext/js/dictionary/dictionary-worker.js
+++ b/ext/js/dictionary/dictionary-worker.js
@@ -37,7 +37,7 @@ export class DictionaryWorker {
{details, archiveContent},
[archiveContent],
onProgress,
- this._formatImportDictionaryResult.bind(this)
+ this._formatImportDictionaryResult.bind(this),
);
}
@@ -82,7 +82,7 @@ export class DictionaryWorker {
reject,
onMessage: null,
onProgress,
- formatResult
+ formatResult,
};
// Ugly typecast below due to not being able to explicitly state the template types
/** @type {(event: MessageEvent<import('dictionary-worker').MessageData<TResponseRaw>>) => void} */
@@ -200,7 +200,7 @@ export class DictionaryWorker {
const {result, errors} = response;
return {
result,
- errors: errors.map((error) => ExtensionError.deserialize(error))
+ errors: errors.map((error) => ExtensionError.deserialize(error)),
};
}
}