Skip to content

Commit

Permalink
Merge branch 'master' into language-select
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Jan 31, 2024
2 parents 3e95962 + 3e419aa commit 39ec942
Show file tree
Hide file tree
Showing 23 changed files with 1,282 additions and 900 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@
"ext/js/general/object-property-accessor.js",
"ext/js/general/regex-util.js",
"ext/js/general/text-source-map.js",
"ext/js/language/deinflector.js",
"ext/js/language/language-transformer.js",
"ext/js/dictionary/dictionary-database.js",
"ext/js/dictionary/dictionary-data-util.js",
"ext/js/language/sandbox/japanese-util.js",
Expand Down
5 changes: 3 additions & 2 deletions dev/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"core": ["../types/ext/core"],
"css-style-applier": ["../types/ext/css-style-applier"],
"database": ["../types/ext/database"],
"deinflector": ["../types/ext/deinflector"],
"dictionary": ["../types/ext/dictionary"],
"dictionary-data": ["../types/ext/dictionary-data"],
"dictionary-data-util": ["../types/ext/dictionary-data-util"],
Expand All @@ -31,6 +30,8 @@
"japanese-util": ["../types/ext/japanese-util"],
"language": ["../types/ext/language"],
"ext/json-schema": ["../types/ext/json-schema"],
"language-transformer": ["../types/ext/language-transformer"],
"language-transformer-internal": ["../types/ext/language-transformer-internal"],
"log": ["../types/ext/log"],
"settings": ["../types/ext/settings"],
"structured-content": ["../types/ext/structured-content"],
Expand Down Expand Up @@ -65,7 +66,7 @@
"../ext/js/general/cache-map.js",
"../ext/js/general/regex-util.js",
"../ext/js/general/text-source-map.js",
"../ext/js/language/deinflector.js",
"../ext/js/language/language-transformer.js",
"../ext/js/dictionary/dictionary-importer.js",
"../ext/js/dictionary/dictionary-database.js",
"../ext/js/dictionary/dictionary-data-util.js",
Expand Down
645 changes: 0 additions & 645 deletions ext/data/deinflect.json

This file was deleted.

851 changes: 851 additions & 0 deletions ext/data/language/japanese-transforms.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ext/data/schemas/dictionary-term-bank-v3-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
"color": {
"type": "string"
},
"background": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
Expand Down Expand Up @@ -318,6 +321,9 @@
"borderWidth": {
"type": "string"
},
"clipPath": {
"type": "string"
},
"verticalAlign": {
"type": "string",
"enum": ["baseline", "sub", "super", "text-top", "text-bottom", "middle", "top", "bottom"],
Expand All @@ -328,6 +334,9 @@
"enum": ["start", "end", "left", "right", "center", "justify", "justify-all", "match-parent"],
"default": "start"
},
"textEmphasis": {
"type": "string"
},
"textShadow": {
"type": "string"
},
Expand Down
6 changes: 3 additions & 3 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ export class Backend {

await this._languageUtil.prepare();

/** @type {import('deinflector').ReasonsRaw} */
const deinflectionReasons = await fetchJson('/data/deinflect.json');
this._translator.prepare(deinflectionReasons);
/** @type {import('language-transformer').LanguageTransformDescriptor} */
const descriptor = await fetchJson('/data/language/japanese-transforms.json');
this._translator.prepare(descriptor);

this._applyOptions('background');

Expand Down
6 changes: 3 additions & 3 deletions ext/js/background/offscreen-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ export class TranslatorProxy {
}

/**
* @param {import('deinflector').ReasonsRaw} deinflectionReasons
* @param {import('language-transformer').LanguageTransformDescriptor} descriptor
*/
async prepare(deinflectionReasons) {
await this._offscreen.sendMessagePromise({action: 'translatorPrepareOffscreen', params: {deinflectionReasons}});
async prepare(descriptor) {
await this._offscreen.sendMessagePromise({action: 'translatorPrepareOffscreen', params: {descriptor}});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ext/js/background/offscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export class Offscreen {
}

/** @type {import('offscreen').ApiHandler<'translatorPrepareOffscreen'>} */
_prepareTranslatorHandler({deinflectionReasons}) {
this._translator.prepare(deinflectionReasons);
_prepareTranslatorHandler({descriptor}) {
this._translator.prepare(descriptor);
}

/** @type {import('offscreen').ApiHandler<'languageUtilPrepareOffscreen'>}*/
Expand Down
6 changes: 6 additions & 0 deletions ext/js/display/sandbox/structured-content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export class StructuredContentGenerator {
fontWeight,
fontSize,
color,
background,
backgroundColor,
textDecorationLine,
textDecorationStyle,
Expand All @@ -355,8 +356,10 @@ export class StructuredContentGenerator {
borderStyle,
borderRadius,
borderWidth,
clipPath,
verticalAlign,
textAlign,
textEmphasis,
textShadow,
margin,
marginTop,
Expand All @@ -377,9 +380,11 @@ export class StructuredContentGenerator {
if (typeof fontWeight === 'string') { style.fontWeight = fontWeight; }
if (typeof fontSize === 'string') { style.fontSize = fontSize; }
if (typeof color === 'string') { style.color = color; }
if (typeof background === 'string') { style.background = background; }
if (typeof backgroundColor === 'string') { style.backgroundColor = backgroundColor; }
if (typeof verticalAlign === 'string') { style.verticalAlign = verticalAlign; }
if (typeof textAlign === 'string') { style.textAlign = textAlign; }
if (typeof textEmphasis === 'string') { style.textEmphasis = textEmphasis; }
if (typeof textShadow === 'string') { style.textShadow = textShadow; }
if (typeof textDecorationLine === 'string') {
style.textDecoration = textDecorationLine;
Expand All @@ -396,6 +401,7 @@ export class StructuredContentGenerator {
if (typeof borderStyle === 'string') { style.borderStyle = borderStyle; }
if (typeof borderRadius === 'string') { style.borderRadius = borderRadius; }
if (typeof borderWidth === 'string') { style.borderWidth = borderWidth; }
if (typeof clipPath === 'string') { style.clipPath = clipPath; }
if (typeof margin === 'string') { style.margin = margin; }
if (typeof marginTop === 'number') { style.marginTop = `${marginTop}em`; }
if (typeof marginTop === 'string') { style.marginTop = marginTop; }
Expand Down
3 changes: 2 additions & 1 deletion ext/js/extension/web-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class WebExtension extends EventDispatcher {
*/
getLastError() {
const {lastError} = chrome.runtime;
if (typeof lastError !== 'undefined') {
if (lastError) {
if (lastError instanceof Error) { return lastError; }
const {message} = lastError;
return new Error(typeof message === 'string' ? message : 'An unknown web extension error occured');
}
Expand Down
140 changes: 0 additions & 140 deletions ext/js/language/deinflector.js

This file was deleted.

Loading

0 comments on commit 39ec942

Please sign in to comment.