Skip to content

Commit

Permalink
Add minimumYomitanVersion parameter to dictionary index schema
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmk committed Jan 8, 2025
1 parent 37d13a8 commit 2446520
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ext/data/schemas/dictionary-index-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"type": "string",
"description": "Revision of the dictionary. This value is displayed, and used to check for dictionary updates."
},
"minimumYomitanVersion": {
"type": "string",
"description": "Minimum version of Yomitan that is compatible with this dictionary."
},
"sequenced": {
"type": "boolean",
"default": false,
Expand Down
12 changes: 11 additions & 1 deletion ext/js/dictionary/dictionary-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ZipReader as ZipReader0,
configure,
} from '../../lib/zip.js';
import {compareRevisions} from 'dictionary-data-util.js';
import {ExtensionError} from '../core/extension-error.js';
import {parseJson} from '../core/json.js';
import {toError} from '../core/to-error.js';
Expand Down Expand Up @@ -328,7 +329,16 @@ export class DictionaryImporter {
styles,
};

const {author, url, description, attribution, frequencyMode, isUpdatable, sourceLanguage, targetLanguage} = index;
const {minimumYomitanVersion, author, url, description, attribution, frequencyMode, isUpdatable, sourceLanguage, targetLanguage} = index;
if (typeof minimumYomitanVersion === 'string') {
const {version} = chrome.runtime.getManifest();
if (version === "0.0.0.0") {
// Running a development version of Yomitan
} else if (compareRevisions(version, minimumYomitanVersion)) {
throw new Error(`Dictionary is incompatible with this version of Yomitan (${version}; minimum required: ${minimumYomitanVersion})`);
}
summary.minimumYomitanVersion = minimumYomitanVersion;
}
if (typeof author === 'string') { summary.author = author; }
if (typeof url === 'string') { summary.url = url; }
if (typeof description === 'string') { summary.description = description; }
Expand Down
1 change: 1 addition & 0 deletions types/ext/dictionary-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Index = {
version?: IndexVersion;
title: string;
revision: string;
minimumYomitanVersion?: string;
sequenced?: boolean;
isUpdatable?: true;
indexUrl?: string;
Expand Down
1 change: 1 addition & 0 deletions types/ext/dictionary-importer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type Summary = {
title: string;
revision: string;
sequenced: boolean;
minimumYomitanVersion?: string;
version: number;
importDate: number;
prefixWildcardsSupported: boolean;
Expand Down

0 comments on commit 2446520

Please sign in to comment.