mirror of
https://github.com/zadam/trilium.git
synced 2025-12-30 03:04:29 +01:00
chore(pdfjs): copy locales during build
This commit is contained in:
parent
6e41d3591d
commit
07a1734d4b
@ -6,6 +6,9 @@
|
||||
"build": "tsx scripts/build.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@triliumnext/commons": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"pdfjs-dist": "5.4.530"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,37 @@
|
||||
import { join } from "path";
|
||||
import BuildHelper from "../../../scripts/build-utils";
|
||||
import { build as esbuild } from "esbuild";
|
||||
import { LOCALES } from "@triliumnext/commons";
|
||||
|
||||
const build = new BuildHelper("packages/pdfjs-viewer");
|
||||
|
||||
const LOCALE_MAPPINGS: Record<string, string> = {
|
||||
"es": "es-ES"
|
||||
};
|
||||
|
||||
async function main() {
|
||||
build.copy("viewer", "web");
|
||||
// Copy the viewer files.
|
||||
for (const file of [ "viewer.css", "viewer.html", "viewer.mjs" ]) {
|
||||
build.copy(`viewer/${file}`, `web/${file}`);
|
||||
}
|
||||
build.copy(`viewer/images`, `web/images`);
|
||||
|
||||
// Copy the custom files.
|
||||
await buildScript("web/custom.mjs");
|
||||
build.copy("src/custom.css", "web/custom.css");
|
||||
|
||||
// Copy locales.
|
||||
const localeMappings = {};
|
||||
for (const locale of LOCALES) {
|
||||
if (locale.id === "en" || locale.contentOnly || locale.devOnly) continue;
|
||||
const mappedLocale = LOCALE_MAPPINGS[locale.electronLocale] || locale.electronLocale.replace("_", "-");
|
||||
const localePath = `${locale.id}/viewer.ftl`;
|
||||
build.copy(`viewer/locale/${mappedLocale}/viewer.ftl`, `web/locale/${localePath}`);
|
||||
localeMappings[locale.id] = localePath;
|
||||
}
|
||||
build.writeJson("web/locale/locale.json", localeMappings);
|
||||
|
||||
// Copy pdfjs-dist files.
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.mjs", "build/pdf.mjs");
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.worker.mjs", "build/pdf.worker.mjs");
|
||||
}
|
||||
|
||||
@ -22,5 +22,8 @@
|
||||
"eslint.config.mjs"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../commons/tsconfig.app.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -1375,6 +1375,10 @@ importers:
|
||||
|
||||
packages/pdfjs-viewer:
|
||||
dependencies:
|
||||
'@triliumnext/commons':
|
||||
specifier: workspace:*
|
||||
version: link:../commons
|
||||
devDependencies:
|
||||
pdfjs-dist:
|
||||
specifier: 5.4.530
|
||||
version: 5.4.530
|
||||
@ -16044,8 +16048,6 @@ snapshots:
|
||||
'@ckeditor/ckeditor5-ui': 47.3.0
|
||||
'@ckeditor/ckeditor5-utils': 47.3.0
|
||||
ckeditor5: 47.3.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@ckeditor/ckeditor5-restricted-editing@47.3.0':
|
||||
dependencies:
|
||||
|
||||
@ -87,6 +87,15 @@ export default class BuildHelper {
|
||||
}
|
||||
}
|
||||
|
||||
writeJson(relativePath: string, data: any) {
|
||||
const fullPath = join(this.outDir, relativePath);
|
||||
const dirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
|
||||
if (dirPath) {
|
||||
mkdirpSync(dirPath);
|
||||
}
|
||||
writeFileSync(fullPath, JSON.stringify(data, null, 4), "utf-8");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function tryPath(paths: string[]) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user