Merge branch 'main' of https://github.com/TriliumNext/Trilium into feat/about-dialog-overhaul

This commit is contained in:
Adorian Doran
2026-04-12 17:15:40 +03:00
470 changed files with 30220 additions and 21518 deletions

View File

@@ -51,8 +51,10 @@ export default class BuildHelper {
"electron",
"@electron/remote",
"better-sqlite3",
"pdfjs-dist",
"./xhr-sync-worker.js",
"vite"
"vite",
"tesseract.js"
],
metafile: true,
splitting: false,
@@ -66,6 +68,14 @@ export default class BuildHelper {
minify: true
});
writeFileSync(join(this.outDir, "meta.json"), JSON.stringify(result.metafile));
// Tesseract.js is marked as external above because its worker runs in
// a separate worker_thread. Copy the worker source, WASM core and all
// transitive runtime deps so they are available in dist/node_modules.
this.copyNodeModules([
"tesseract.js", "tesseract.js-core", "wasm-feature-detect",
"regenerator-runtime", "is-url", "bmp-js"
]);
}
buildFrontend() {

View File

@@ -1,11 +1,28 @@
import { join, resolve } from "path";
import { cpSync, exists, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
import { execSync } from "child_process";
import { rebuild } from "@electron/rebuild"
import { getElectronPath, isNixOS } from "./utils.mjs";
import { isNixOS } from "./utils.mjs";
const workspaceRoot = join(import.meta.dirname, "..");
// On NixOS, re-execute this script inside `nix develop` to get access to Python and other build tools.
// Skip this if we're already inside a nix shell or a nix build (NIX_BUILD_TOP is set during `nix build`).
if (isNixOS() && !process.env.IN_NIX_SHELL && !process.env.NIX_BUILD_TOP) {
console.log("Detected NixOS, re-running electron-rebuild inside 'nix develop'...");
try {
execSync("nix develop -c pnpm exec tsx scripts/electron-rebuild.mts", {
cwd: workspaceRoot,
stdio: "inherit",
env: { ...process.env, IN_NIX_SHELL: "1" }
});
process.exit(0);
} catch (e) {
console.error("Failed to run electron-rebuild inside 'nix develop'.");
process.exit(1);
}
}
function copyNativeDependencies(projectRoot: string) {
const destPath = join(projectRoot, "node_modules/better-sqlite3");
@@ -46,20 +63,8 @@ async function rebuildNativeDependencies(projectRoot: string) {
function determineElectronVersion(projectRoot: string) {
const packageJson = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"));
if (isNixOS()) {
console.log("Detected NixOS, reading Electron version from PATH");
try {
return execSync(`${getElectronPath()} --version`, { }).toString("utf-8");
} catch (e) {
console.error("Got error while trying to read the Electron version from shell. Make sure that an Electron version is in the PATH (e.g. `nix-shell -p electron`)");
process.exit(1);
}
} else {
console.log("Using Electron version from package.json");
return packageJson.devDependencies.electron;
}
console.log("Using Electron version from package.json");
return packageJson.devDependencies.electron;
}
for (const projectRoot of [ "apps/desktop", "apps/edit-docs" ]) {

View File

@@ -0,0 +1,56 @@
/**
* Runs `tsc --build` and filters out noisy cascade errors (TS6305).
* Numbers each remaining error and prints a summary at the end.
*/
import { execSync } from "child_process";
const SUPPRESSED_CODES = [ "TS6305" ];
const ERROR_LINE_PATTERN = /^.+\(\d+,\d+\): error TS\d+:/;
let output: string;
try {
output = execSync("tsc --build", {
encoding: "utf-8",
stdio: [ "inherit", "pipe", "pipe" ]
});
} catch (err: unknown) {
const execErr = err as { stdout?: string; stderr?: string };
output = (execErr.stdout ?? "") + (execErr.stderr ?? "");
}
const lines = output.split(/\r?\n/);
const filtered = lines.filter(
(line) => !SUPPRESSED_CODES.some((code) => line.includes(code))
);
let errorIndex = 0;
const numbered: string[] = [];
const seen = new Set<string>();
let skipContinuation = false;
for (const line of filtered) {
if (ERROR_LINE_PATTERN.test(line)) {
if (seen.has(line)) {
skipContinuation = true;
continue;
}
seen.add(line);
skipContinuation = false;
errorIndex++;
numbered.push(`[${errorIndex}] ${line}`);
} else if (line.trim()) {
// Continuation line (indented context for multi-line errors)
if (!skipContinuation) {
numbered.push(line);
}
}
}
if (errorIndex > 0) {
console.log(numbered.join("\n"));
console.log(`\n${errorIndex} error(s) found.`);
process.exit(1);
} else {
console.log("No errors found.");
}

View File

@@ -28,7 +28,7 @@ function resetPath() {
export function getElectronPath() {
if (isNixOS()) {
resetPath();
resetPath();
try {
const path = execSync("which electron").toString("utf-8").trimEnd();
@@ -37,8 +37,16 @@ export function getElectronPath() {
// Nothing to do, since we have a fallback below.
}
console.log("Using default since no Electron is available in path.");
return execSync("nix eval --raw nixpkgs#electron_37").toString("utf-8") + "/bin/electron";
console.log("No Electron in PATH, using 'nix develop' to get it...");
try {
const path = execSync("nix develop -c which electron", { stdio: ["pipe", "pipe", "pipe"] }).toString("utf-8").trimEnd();
return path;
} catch (e) {
console.error("\nFailed to get Electron from 'nix develop'.");
console.error("Please ensure you have a valid flake.nix with electron in devShells.default.");
process.exit(1);
}
} else {
return "electron";
}