Commit Graph

163 Commits

Author SHA1 Message Date
Elian Doran
fd7ee39963
build: ship only the better-sqlite3 files an artifact actually uses
Since v13 the package bundles a prebuilt binary for all eight platforms
it supports (~17 MB) on top of the SQLite amalgamation needed to compile
from scratch (~10 MB). A packaged artifact loads exactly one binary and
never compiles, so all of that but ~2 MB was dead weight:

  v0.104.1 (v12)   11.93 MB   deps/ + a compiled build/Release binary
  v13, untrimmed   27.0 MB    deps/ + eight prebuilds
  server, trimmed   4.5 MB    lib/ + linux-x64 + linuxmusl-x64
  desktop, trimmed  2.2 MB    lib/ + linux-x64

That is ~6 MB off each compressed Linux artifact, and leaves us below
what v0.104.1 shipped rather than 15 MB above it. lib/ plus one prebuild
is the complete runtime set -- verified by loading a copy pruned to just
those files and running a query against it.

Two things the trim has to get right, both covered:

Linux keeps the musl build alongside the glibc one. The server's dist is
produced once on a glibc runner and then consumed by both the Debian and
the Alpine images, and better-sqlite3 resolves linuxmusl-* at runtime on
the latter, so dropping it would break the amd64 image at startup. The
Electron artifacts opt out, since Electron ships no musl builds.

The platform and architecture are the ones being built *for*, not the
host's: the macOS runners are arm64 and also package darwin-x64, so
trimming by host arch would strip the binary that build needs.
TARGET_ARCH / MATRIX_ARCH already carry the target in CI.

An unsupported platform/arch throws rather than silently producing an
artifact with no native addon.

Also drops the better-sqlite3 cleanup from flake.nix's server install
phase: it removed deps/sqlite3 and the build/ scaffolding that held
build-time store paths, all of which the build now trims itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 18:07:02 +03:00
Elian Doran
fe5acbbb4a
build(ci): rebuild better-sqlite3 against an older glibc for Linux releases
better-sqlite3 v13's bundled N-API prebuilds are linked against a much
newer toolchain than the assets prebuild-install used to fetch, which
would have raised the glibc floor of every native Linux artifact and
dropped distributions we still support:

  v0.104.1 (v12 assets)  GLIBC_2.29 / GLIBCXX_3.4.20
  v13 prebuild, x64      GLIBC_2.34 / GLIBCXX_3.4.29
  v13 prebuild, arm64    GLIBC_2.38 / GLIBCXX_3.4.31

The arm64 figure drops Debian 12 "bookworm" -- including Raspberry Pi OS
-- along with Ubuntu 22.04 and RHEL 9; x64 drops Ubuntu 20.04, Debian 11
and RHEL 8. Nothing in better-sqlite3 needs a newer glibc: the addon
picked up GLIBC_2.34 because it was linked where libpthread had merged
into libc, and GLIBC_2.38 because GCC 13+ redirects strtol to the
__isoc23_* symbols. The floor is an artifact of the build host, so build
on an older one and substitute the result for the bundled prebuild.

Compiling in node:22-bullseye restores GLIBC_2.29 / GLIBCXX_3.4.21 --
glibc parity with v0.104.1, and the one-step GLIBCXX move constrains
nothing, since glibc 2.29 already implies a 2019-or-later distro. No
platform is lost.

Notes on the implementation:

- force_build is required. binding.gyp resolves both targets to
  `type: none` whenever a prebuild for the host exists, so an ordinary
  node-gyp run emits a stamp file and no addon.
- The compiled addon replaces prebuilds/<target>.node rather than
  relying on the build/Release fallback, leaving the loader's resolution
  order untouched.
- nodeLinker is "hoisted", so every dependant gets its own copy and the
  build scripts resolve <app>/node_modules before the root; all copies
  are patched. Each is replaced by rename, since these files are
  hardlinks into the pnpm store and writing in place would mutate it.
- python3 is apt-installed when absent: buildpack-deps supplies g++ and
  make but not python3, which node-gyp needs. Sources fall back to
  archive.debian.org so this keeps working once bullseye goes EOL on
  2026-08-31 -- an old *build* container is deliberate here, the same
  approach manylinux and Node's own release builds take.

Docker images are unaffected: they carry their own glibc.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 17:59:19 +03:00
Elian Doran
039b85ddd4
build: adapt the native build pipeline to better-sqlite3 v13
Some checks failed
Checks / main (push) Has been cancelled
v13 moves the addon onto N-API and ships prebuilt binaries for every
supported platform/arch inside the package itself. Three parts of the
build assumed the old prebuild-install/node-gyp layout.

Dropped `bindings` and `file-uri-to-path` from copyNodeModules: v13 no
longer depends on either, so the copy aborted the build outright with
"Unable to find any of the paths: .../node_modules/bindings".

Removed the Electron native rebuild. v13's binding.gyp resolves both of
its targets to `type: none` whenever a prebuild for the host exists, so
electron-rebuild.mts produced a stamp file and no addon on every install,
leaving BETTERSQLITE3_NATIVE_PATH pointing at a build/Release binary that
is never created -- `pnpm desktop:start` died on MODULE_NOT_FOUND. The
prebuilds are ABI-stable and load unchanged under Electron 42 (Node-API
10), so the rebuild step, its @electron/rebuild and prebuild-install
devDependencies, and the ELECTRON_NODEDIR plumbing in flake.nix all go.

Rebuilt the Docker images around the same short-circuit: `pnpm rebuild`
in the builder stages was also a no-op, so the images would have shipped
the upstream prebuild, which needs glibc >= 2.34 (x64) / >= 2.38 (arm64)
against bullseye's 2.31. The glibc images move to trixie and lose their
builder stage; the Alpine pair lose theirs too, since the linuxmusl-*
prebuilds only need libstdc++, which node:*-alpine already provides.
Alpine stays pinned to 3.23 for the musl 1.2.5 reason in #10627.

Dockerfile.legacy must keep compiling from source -- 32-bit ARM has no
prebuild at all, and linux/arm/v8 normalizes to arm64, whose prebuild
outruns that image's bullseye glibc. npm_config_force_build=1 restores
the real compile and link rules.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 17:09:31 +03:00
Elian Doran
cbb1d53f25
fix(desktop): make start-prod launch Electron correctly on NixOS
The `start-prod`/`start-prod-no-dir` scripts invoked the npm prebuilt
Electron binary directly (`electron dist`), which fails to load on NixOS
because it's dynamically linked against FHS system libraries that don't
exist there (libcups.so.2, libgtk-3, libnss3, ...). The dev launcher
already handles this via electron-start.mts, but prod never did.

Add scripts/electron-run-prod.mts, a build-free launcher that reuses the
same NixOS-aware getElectronPath() (preferring the Nix/nix-develop
Electron over the prebuilt binary) and sets LD_LIBRARY_PATH plus
--no-sandbox on NixOS. On all other platforms it's a transparent
`electron <args>` wrapper, so behaviour is unchanged.

Also extract the shared getNixLdLibraryPath() helper so the dev and prod
launchers stay DRY.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 13:29:30 +03:00
Elian Doran
c13f6e3469
fix(desktop): don't inject import.meta.url banner into sandboxed preload
The import.meta.url shim added for the bundled Claude Agent SDK prepends a
`require("node:url")` banner to every buildBackend output. The desktop build
compiled main.ts and preload.ts together, so the banner landed atop
preload.cjs, which runs in Electron's sandboxed renderer where
`require("node:url")` throws. That aborted the preload before it could expose
`electronApi`, leaving window.electronApi undefined: the window rendered a
transparent background with no Mica material behind it and DevTools could not
be opened.

Gate the shim (define + banner) behind a buildBackend option and build the
preload without it; the preload never references import.meta.url.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 14:36:01 +03:00
Elian Doran
6dd444e167
fix(desktop): make bundled Claude Agent SDK runnable in production
The desktop build bundles everything into a CJS main.cjs. CJS has no
import.meta, so esbuild rewrites import.meta.url to {} (undefined).
@anthropic-ai/claude-agent-sdk calls createRequire(import.meta.url) at
module top level, so evaluating it threw ERR_INVALID_ARG_VALUE, which
surfaced as "[trilium-app] dispatch failed for GET trilium-app://app/".

Shim import.meta.url to the bundle's own file URL via esbuild define +
banner, so createRequire()/.resolve() anchor at dist/ and still resolve
sibling node_modules packages. Also ship the SDK's per-platform native
claude binary into dist/node_modules, since the JS is bundled but the
binary it spawns at query time cannot be.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 13:32:39 +03:00
AndreeaCorlaci
0c4b4fab0a Merge remote-tracking branch 'origin/main' into standalone-ios
Some checks are pending
Checks / main (push) Waiting to run
2026-06-08 08:35:56 +03:00
Elian Doran
555a90c789
refactor(ci): clean up relative CI 2026-05-29 11:01:53 +03:00
Elian Doran
74b7067b52
fix(edit-docs): not working due to missing preload 2026-05-25 16:46:37 +03:00
Elian Doran
d7ff9c90ad
chore(setup): remove electron remote 2026-05-24 20:25:59 +03:00
Elian Doran
3ec30e5bba
refactor(electron): use TypeScript for preload 2026-05-24 18:27:52 +03:00
Elian Doran
94265f72b2
fix(nix): not handling sqlite natives 2026-05-19 18:22:30 +03:00
Elian Doran
22650e0681
chore(deps): remove fs-extra 2026-05-16 16:45:17 +03:00
Elian Doran
a63ed029b1
refactor(standalone): rename project from client-standalone 2026-05-16 08:57:55 +03:00
Elian Doran
ea667299af
chore(scripts): remove now redundant standalone script 2026-05-14 21:19:51 +03:00
AndreeaCorlaci
c0dd5ba5f4 feat(mobile/ios): add trilium icon 2026-04-22 14:43:10 +03:00
Elian Doran
0e678a6870
chore(mobile): add a slighter warmer background 2026-04-20 20:23:17 +03:00
Elian Doran
07608a041b
feat(mobile): provide monochrome icon too 2026-04-20 20:21:13 +03:00
Elian Doran
4914ff7601
chore(mobile): icon clipped on Samsung with squircle 2026-04-20 20:20:06 +03:00
Elian Doran
97438ed46f
chore(mobile): icon clipped on Samsung with squircle 2026-04-20 20:16:53 +03:00
Elian Doran
f4790e59eb
chore(mobile): icon clipped on Pixel 10 2026-04-20 20:12:03 +03:00
Elian Doran
e956d951a8
chore(mobile): basic icon set 2026-04-20 20:07:47 +03:00
Elian Doran
28c6826b35
Merge remote-tracking branch 'origin/main' into standalone 2026-04-19 20:26:10 +03:00
Adorian Doran
c4d832eebc contributor list: update script name, change a comment 2026-04-19 18:33:35 +03:00
Elian Doran
2c744122ca
chore: update contributors list 2026-04-19 15:44:52 +03:00
Elian Doran
adc648d277
chore(scripts): tweak criteria for contributors 2026-04-19 15:34:14 +03:00
Elian Doran
a403aca054
chore(scripts): group translators separately 2026-04-19 13:16:08 +03:00
Elian Doran
e7f85bb447
chore(scripts): filter contributors by minimum commits 2026-04-19 13:12:41 +03:00
Elian Doran
e6e6c1feff
chore(scripts): filter contributors by role 2026-04-19 13:03:57 +03:00
Elian Doran
415d9364de
Merge remote-tracking branch 'origin/main' into feat/about-dialog-overhaul 2026-04-19 12:49:46 +03:00
Adorian Doran
900f308349 contributor list: switch to manual update, add a tool for a reference list (local Git + GitHub listing)
Some checks failed
Checks / main (push) Has been cancelled
2026-04-19 11:10:45 +03:00
Elian Doran
4ae3a00464
chore: remove Electron repro project 2026-04-19 10:55:29 +03:00
Adorian Doran
28b1eb71ba Merge branch 'main' of https://github.com/TriliumNext/Trilium into feat/about-dialog-overhaul
Some checks failed
Checks / main (push) Has been cancelled
2026-04-16 21:08:39 +03:00
Elian Doran
598317ea6e
chore: add reproduction sample for printing issue 2026-04-15 22:43:34 +03:00
Adorian Doran
3720851ff7 Merge branch 'main' of https://github.com/TriliumNext/Trilium into feat/about-dialog-overhaul 2026-04-12 17:15:40 +03:00
Elian Doran
8e7bd16a98
fix(docker): cannot access schema and DB 2026-04-09 19:16:26 +03:00
Elian Doran
2c2a20b80d
chore(server): bypass build warning 2026-04-09 18:29:00 +03:00
Elian Doran
b2e886fa26
fix(core): wrong package version
Some checks failed
Checks / main (push) Has been cancelled
Deploy Standalone App / Build and Deploy App (push) Has been cancelled
Dev / Test development (push) Has been cancelled
Dev / Build Docker image (push) Has been cancelled
Dev / Check Docker build (Dockerfile) (push) Has been cancelled
Dev / Check Docker build (Dockerfile.alpine) (push) Has been cancelled
2026-04-07 16:54:07 +03:00
Elian Doran
34c5cfb638
fix(scripts): update build info no longer updating 2026-04-07 16:00:44 +03:00
Elian Doran
38385ac936
Merge remote-tracking branch 'origin/main' into standalone 2026-04-06 14:28:40 +03:00
Elian Doran
dc1e0e8db4
fix(desktop): tesseract.js not copied 2026-04-05 22:22:58 +03:00
Elian Doran
1e861d1125
chore(ocr): externalize tesseract.js completely 2026-04-05 22:20:38 +03:00
Elian Doran
61dcc8db47
Revert "fix(ocr): not working in server prod"
This reverts commit f4f881e839.
2026-04-05 21:53:53 +03:00
Elian Doran
f4f881e839
fix(ocr): not working in server prod 2026-04-05 19:58:48 +03:00
Elian Doran
70ce86cd53
fix(scripts): electron rebuild failing in flake
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL Advanced / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on ${{ matrix.name }} (arm64, linux-arm64, ubuntu-24.04-arm) (push) Waiting to run
playwright / E2E tests on ${{ matrix.name }} (x64, linux-x64, ubuntu-22.04) (push) Waiting to run
2026-04-04 22:01:43 +03:00
Elian Doran
b52e65278e
Merge remote-tracking branch 'origin/main' into standalone
; Conflicts:
;	CLAUDE.md
;	apps/client/src/widgets/collections/board/data.spec.ts
;	apps/server/package.json
;	apps/server/src/routes/routes.ts
;	apps/server/src/services/app_info.ts
;	apps/server/src/services/blob-interface.ts
;	apps/server/src/services/entity_changes.ts
;	apps/server/src/services/handlers.ts
;	apps/server/src/services/hidden_subtree.ts
;	apps/server/src/services/image.ts
;	apps/server/src/services/options_init.ts
;	apps/server/src/services/search/services/search.ts
;	packages/trilium-core/src/services/blob.ts
;	packages/trilium-core/src/services/import/markdown.ts
;	packages/trilium-core/src/services/import/markdown/wikilink_internal_link.ts
;	packages/trilium-core/src/services/import/markdown/wikilink_transclusion.ts
;	packages/trilium-core/src/services/search/expressions/ocr_content.ts
;	packages/trilium-core/src/services/search/search_result.ts
;	packages/trilium-core/src/services/search/services/parse.ts
;	pnpm-lock.yaml
2026-04-04 17:16:52 +03:00
Elian Doran
fe81bde1c9
chore(scripts): fix electron rebuild failing due to Python on NixOS 2026-04-04 12:49:03 +03:00
Elian Doran
788e867a6c
fix(scripts): use flake when rebuilding Electron in postinstall script
Some checks failed
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL Advanced / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on ${{ matrix.name }} (arm64, linux-arm64, ubuntu-24.04-arm) (push) Waiting to run
playwright / E2E tests on ${{ matrix.name }} (x64, linux-x64, ubuntu-22.04) (push) Waiting to run
Deploy website / Build & deploy website (push) Has been cancelled
2026-04-04 12:38:23 +03:00
Elian Doran
2e34ec2a17
chore(server): remove sharp from externals 2026-04-03 09:04:04 +03:00
Elian Doran
9878f76f65
fix(ocr): sharp failing on Alpine
Some checks failed
Checks / main (push) Has been cancelled
2026-04-02 22:56:22 +03:00