Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
djahandarie authored Dec 19, 2023
2 parents 5a2d95d + ae2e2db commit f68b238
Show file tree
Hide file tree
Showing 20 changed files with 302 additions and 281 deletions.
4 changes: 2 additions & 2 deletions dev/bin/generate-css-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {formatRulesJson, generateRules, getTargets} from '../generate-css-json.j

/** */
function main() {
for (const {cssFile, overridesCssFile, outputPath} of getTargets()) {
const json = formatRulesJson(generateRules(cssFile, overridesCssFile));
for (const {cssFilePath, overridesCssFilePath, outputPath} of getTargets()) {
const json = formatRulesJson(generateRules(cssFilePath, overridesCssFilePath));
fs.writeFileSync(outputPath, json, {encoding: 'utf8'});
}
}
Expand Down
20 changes: 10 additions & 10 deletions dev/generate-css-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ import {fileURLToPath} from 'url';
const dirname = path.dirname(fileURLToPath(import.meta.url));

/**
* @returns {{cssFile: string, overridesCssFile: string, outputPath: string}[]}
* @returns {{cssFilePath: string, overridesCssFilePath: string, outputPath: string}[]}
*/
export function getTargets() {
return [
{
cssFile: path.join(dirname, '..', 'ext/css/structured-content.css'),
overridesCssFile: path.join(dirname, 'data/structured-content-overrides.css'),
cssFilePath: path.join(dirname, '..', 'ext/css/structured-content.css'),
overridesCssFilePath: path.join(dirname, 'data/structured-content-overrides.css'),
outputPath: path.join(dirname, '..', 'ext/data/structured-content-style.json')
},
{
cssFile: path.join(dirname, '..', 'ext/css/display-pronunciation.css'),
overridesCssFile: path.join(dirname, 'data/display-pronunciation-overrides.css'),
cssFilePath: path.join(dirname, '..', 'ext/css/display-pronunciation.css'),
overridesCssFilePath: path.join(dirname, 'data/display-pronunciation-overrides.css'),
outputPath: path.join(dirname, '..', 'ext/data/pronunciation-style.json')
}
];
Expand Down Expand Up @@ -124,14 +124,14 @@ export function formatRulesJson(rules) {

/**
* Generates a CSS ruleset.
* @param {string} cssFile
* @param {string} overridesCssFile
* @param {string} cssFilePath
* @param {string} overridesCssFilePath
* @returns {import('css-style-applier').RawStyleData}
* @throws {Error}
*/
export function generateRules(cssFile, overridesCssFile) {
const content1 = fs.readFileSync(cssFile, {encoding: 'utf8'});
const content2 = fs.readFileSync(overridesCssFile, {encoding: 'utf8'});
export function generateRules(cssFilePath, overridesCssFilePath) {
const content1 = fs.readFileSync(cssFilePath, {encoding: 'utf8'});
const content2 = fs.readFileSync(overridesCssFilePath, {encoding: 'utf8'});
const stylesheet1 = /** @type {css.StyleRules} */ (css.parse(content1, {}).stylesheet);
const stylesheet2 = /** @type {css.StyleRules} */ (css.parse(content2, {}).stylesheet);

Expand Down
7 changes: 5 additions & 2 deletions ext/js/app/content-script-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {yomitan} from '../yomitan.js';
import {Frontend} from './frontend.js';
import {PopupFactory} from './popup-factory.js';

(async () => {
/** Entry point. */
async function main() {
try {
await yomitan.prepare();

Expand Down Expand Up @@ -57,4 +58,6 @@ import {PopupFactory} from './popup-factory.js';
} catch (e) {
log.error(e);
}
})();
}

await main();
9 changes: 6 additions & 3 deletions ext/js/background/background-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
import {yomitan} from '../yomitan.js';
import {Backend} from './backend.js';

(() => {
/** Entry point. */
async function main() {
yomitan.prepare(true);

const backend = new Backend();
backend.prepare();
})();
await backend.prepare();
}

main();
7 changes: 5 additions & 2 deletions ext/js/background/offscreen-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import {Offscreen} from './offscreen.js';

(() => {
/** Entry point. */
async function main() {
new Offscreen();
})();
}

await main();
Loading

0 comments on commit f68b238

Please sign in to comment.