LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
feat: bundle PDFium dynamic library per platform
nash_sue759a8380b0f
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex a78b02ef..7a399667 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -18,12 +18,15 @@ jobs:- platform: macos-latestargs: '--target aarch64-apple-darwin'rust_target: aarch64-apple-darwin+ pdfium_platform: mac-arm64- platform: ubuntu-22.04args: ''rust_target: ''+ pdfium_platform: linux-x64- platform: windows-latestargs: ''rust_target: ''+ pdfium_platform: win-x64runs-on: ${{ matrix.platform }}@@ -58,6 +61,10 @@ jobs:- name: Install frontend dependenciesrun: npm install+ - name: Fetch PDFium dynamic library (${{ matrix.pdfium_platform }})+ shell: bash+ run: ./scripts/fetch-pdfium.sh ${{ matrix.pdfium_platform }}+- name: Build Tauri appuses: tauri-apps/tauri-action@v0env:diff --git a/.gitignore b/.gitignoreindex dd70a6b9..001150dd 100644--- a/.gitignore+++ b/.gitignore@@ -11,6 +11,12 @@ src-tauri/target/# Tauri generated filessrc-tauri/gen/+# Bundled PDFium binaries — downloaded per-platform by scripts/fetch-pdfium.sh+# (invoked by CI). Too large to track in git.+src-tauri/pdfium/*.dylib+src-tauri/pdfium/*.dll+src-tauri/pdfium/*.so+# Environment files.env.env.localdiff --git a/package-lock.json b/package-lock.jsonindex 7843b488..542f4c0a 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "llm-wiki",- "version": "0.3.3",+ "version": "0.3.4","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "llm-wiki",- "version": "0.3.3",+ "version": "0.3.4","dependencies": {"@base-ui/react": "^1.3.0","@fontsource-variable/geist": "^5.2.8",diff --git a/package.json b/package.jsonindex a6247592..8d816d51 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "llm-wiki","private": true,- "version": "0.3.3",+ "version": "0.3.4","type": "module","scripts": {"dev": "vite",diff --git a/scripts/fetch-pdfium.sh b/scripts/fetch-pdfium.shnew file mode 100755index 00000000..a0dcfc0f--- /dev/null+++ b/scripts/fetch-pdfium.sh@@ -0,0 +1,86 @@+#!/usr/bin/env bash+# Download the platform-appropriate PDFium dynamic library from+# bblanchon/pdfium-binaries into src-tauri/pdfium/. Invoked by CI+# before `tauri build` and can also be run locally.+#+# Usage:+# scripts/fetch-pdfium.sh [platform]+#+# If platform is omitted, it is auto-detected. Supported platforms:+# mac-arm64, mac-x64, win-x64, linux-x64+set -euo pipefail++PLATFORM="${1:-}"++if [[ -z "$PLATFORM" ]]; then+ OS="$(uname -s)"+ ARCH="$(uname -m)"+ case "$OS" in+ Darwin)+ case "$ARCH" in+ arm64) PLATFORM="mac-arm64" ;;+ x86_64) PLATFORM="mac-x64" ;;+ *) echo "Unsupported macOS arch: $ARCH" >&2; exit 1 ;;+ esac+ ;;+ Linux)+ case "$ARCH" in+ x86_64) PLATFORM="linux-x64" ;;+ aarch64) PLATFORM="linux-arm64" ;;+ *) echo "Unsupported Linux arch: $ARCH" >&2; exit 1 ;;+ esac+ ;;+ MINGW*|MSYS*|CYGWIN*)+ PLATFORM="win-x64"+ ;;+ *)+ echo "Unsupported OS: $OS" >&2; exit 1 ;;+ esac+fi++SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"+DEST="$REPO_ROOT/src-tauri/pdfium"+mkdir -p "$DEST"++case "$PLATFORM" in+ mac-arm64|mac-x64|linux-x64|linux-arm64)+ ARCHIVE="pdfium-${PLATFORM}.tgz"+ EXTRACT_CMD="tar -xzf"+ ;;+ win-x64)+ ARCHIVE="pdfium-${PLATFORM}.zip"+ EXTRACT_CMD="unzip -o"+ ;;+ *)+ echo "Unsupported platform: $PLATFORM" >&2; exit 1 ;;+esac++URL="https://github.com/bblanchon/pdfium-binaries/releases/latest/download/${ARCHIVE}"+WORKDIR="$(mktemp -d)"+trap 'rm -rf "$WORKDIR"' EXIT++echo "[fetch-pdfium] platform=$PLATFORM"+echo "[fetch-pdfium] downloading $URL"+curl -fsSL "$URL" -o "$WORKDIR/$ARCHIVE"++echo "[fetch-pdfium] extracting"+(cd "$WORKDIR" && $EXTRACT_CMD "$ARCHIVE")++# Copy just the dynamic library into src-tauri/pdfium/.+# The archives place it at lib/libpdfium.<dylib|so> on Unix and at+# bin/pdfium.dll on Windows.+case "$PLATFORM" in+ mac-arm64|mac-x64)+ cp "$WORKDIR/lib/libpdfium.dylib" "$DEST/libpdfium.dylib"+ ;;+ linux-x64|linux-arm64)+ cp "$WORKDIR/lib/libpdfium.so" "$DEST/libpdfium.so"+ ;;+ win-x64)+ cp "$WORKDIR/bin/pdfium.dll" "$DEST/pdfium.dll"+ ;;+esac++echo "[fetch-pdfium] installed to $DEST:"+ls -lh "$DEST"diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 31f5be65..d186a94f 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -4361,7 +4361,7 @@ checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"[[package]]name = "llm-wiki"-version = "0.3.3"+version = "0.3.4"dependencies = ["arrow-array","arrow-schema",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 44399d6b..dfd9bc18 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "llm-wiki"-version = "0.3.3"+version = "0.3.4"description = "LLM Wiki - A personal knowledge base for LLM concepts"authors = []edition = "2021"diff --git a/src-tauri/pdfium/.gitkeep b/src-tauri/pdfium/.gitkeepnew file mode 100644index 00000000..e69de29bdiff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex 02619c41..f60fe694 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -120,25 +120,129 @@ fn write_cache(original: &Path, text: &str) -> Result<(), String> {static PDFIUM: std::sync::OnceLock<Result<pdfium_render::prelude::Pdfium, String>> =std::sync::OnceLock::new();+/// Additional resource directory hint, set by the Tauri setup() callback+/// once the AppHandle is available. Lets the pdfium resolver find the+/// bundled dylib without re-implementing Tauri's platform-specific+/// resource-dir logic.+static RESOURCE_DIR_HINT: std::sync::OnceLock<std::path::PathBuf> =+ std::sync::OnceLock::new();++/// Called from Tauri's setup() with the resolved resource directory.+/// No-op if already set.+pub fn set_resource_dir_hint(dir: std::path::PathBuf) {+ let _ = RESOURCE_DIR_HINT.set(dir);+}++/// Enumerate plausible locations for the PDFium dynamic library on the+/// current platform. Order from most specific to least:+/// 1. `$PDFIUM_DYNAMIC_LIB_PATH` env var (local dev convenience)+/// 2. Tauri resource dir (set via setup()) — the authoritative location+/// 3. Paths relative to the executable where Tauri's bundler lands+/// resources on each platform (macOS Frameworks / Resources /+/// MacOS dir, Windows sibling, Linux sibling)+/// 4. OS dynamic loader search path (last resort)+fn pdfium_candidate_paths() -> Vec<String> {+ let mut v: Vec<String> = Vec::new();++ if let Ok(p) = std::env::var("PDFIUM_DYNAMIC_LIB_PATH") {+ v.push(p);+ }++ // Tauri-resolved resource directory (set during setup()).+ if let Some(resource_dir) = RESOURCE_DIR_HINT.get() {+ #[cfg(target_os = "macos")]+ v.push(+ resource_dir+ .join("libpdfium.dylib")+ .to_string_lossy()+ .into_owned(),+ );+ #[cfg(target_os = "windows")]+ {+ v.push(+ resource_dir+ .join("pdfium.dll")+ .to_string_lossy()+ .into_owned(),+ );+ v.push(+ resource_dir+ .join("libpdfium.dll")+ .to_string_lossy()+ .into_owned(),+ );+ }+ #[cfg(target_os = "linux")]+ v.push(+ resource_dir+ .join("libpdfium.so")+ .to_string_lossy()+ .into_owned(),+ );+ }++ if let Ok(exe) = std::env::current_exe() {+ if let Some(exe_dir) = exe.parent() {+ let push = |v: &mut Vec<String>, p: std::path::PathBuf| {+ v.push(p.to_string_lossy().into_owned());+ };++ #[cfg(target_os = "macos")]+ {+ // Tauri .app bundle layout:+ // Contents/MacOS/<binary>+ // Contents/Frameworks/libpdfium.dylib ← preferred+ // Contents/Resources/libpdfium.dylib ← fallback+ push(&mut v, exe_dir.join("../Frameworks/libpdfium.dylib"));+ push(&mut v, exe_dir.join("../Resources/libpdfium.dylib"));+ push(&mut v, exe_dir.join("libpdfium.dylib"));+ }++ #[cfg(target_os = "windows")]+ {+ // bblanchon/pdfium-binaries ships the Windows DLL as+ // `pdfium.dll` (no `lib` prefix). Try both.+ push(&mut v, exe_dir.join("pdfium.dll"));+ push(&mut v, exe_dir.join("libpdfium.dll"));+ push(&mut v, exe_dir.join("resources").join("pdfium.dll"));+ }++ #[cfg(target_os = "linux")]+ {+ push(&mut v, exe_dir.join("libpdfium.so"));+ push(&mut v, exe_dir.join("resources").join("libpdfium.so"));+ push(&mut v, exe_dir.join("../lib/libpdfium.so"));+ }+ }+ }++ v+}+fn pdfium() -> Result<&'static pdfium_render::prelude::Pdfium, String> {PDFIUM.get_or_init(|| {use pdfium_render::prelude::*;- // Resolution order:- // 1. PDFIUM_DYNAMIC_LIB_PATH env var (absolute path to dylib)- // 2. ./libpdfium.<ext> next to the binary- // 3. The OS dynamic loader's default search path- let bindings = if let Ok(path) = std::env::var("PDFIUM_DYNAMIC_LIB_PATH") {- Pdfium::bind_to_library(path)- } else {- Pdfium::bind_to_library(- Pdfium::pdfium_platform_library_name_at_path("./"),- )- .or_else(|_| Pdfium::bind_to_system_library())- };- bindings+ let candidates = pdfium_candidate_paths();+ for path in &candidates {+ if let Ok(bindings) = Pdfium::bind_to_library(path) {+ eprintln!("[pdfium] loaded dynamic library from {path}");+ return Ok(Pdfium::new(bindings));+ }+ }+ // Last resort: let the OS dynamic loader find it.+ Pdfium::bind_to_system_library().map(Pdfium::new)- .map_err(|e| format!("Failed to bind to Pdfium library: {e}"))+ .map_err(|e| {+ format!(+ "Failed to locate Pdfium library. Tried: {} — and the system search path. Last error: {e}",+ if candidates.is_empty() {+ "(no candidates)".to_string()+ } else {+ candidates.join(", ")+ }+ )+ })}).as_ref().map_err(|e| e.clone())diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 7d94ca3f..8a1e1978 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -21,6 +21,15 @@ pub fn run() {.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_store::Builder::default().build())+ .setup(|app| {+ // Let the PDF extractor find the bundled pdfium dynamic+ // library via Tauri's platform-correct resource path.+ use tauri::Manager;+ if let Ok(dir) = app.path().resource_dir() {+ commands::fs::set_resource_dir_hint(dir);+ }+ Ok(())+ }).invoke_handler(tauri::generate_handler![commands::fs::read_file,commands::fs::write_file,diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 85408ed1..c2878023 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "LLM Wiki",- "version": "0.3.3",+ "version": "0.3.4","identifier": "com.llmwiki.app","build": {"beforeDevCommand": "npm run dev",diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.jsonnew file mode 100644index 00000000..5a7aa6af--- /dev/null+++ b/src-tauri/tauri.linux.conf.json@@ -0,0 +1,7 @@+{+ "bundle": {+ "resources": {+ "pdfium/libpdfium.so": "./libpdfium.so"+ }+ }+}diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.jsonnew file mode 100644index 00000000..c3eac674--- /dev/null+++ b/src-tauri/tauri.macos.conf.json@@ -0,0 +1,10 @@+{+ "bundle": {+ "resources": {+ "pdfium/libpdfium.dylib": "./libpdfium.dylib"+ },+ "macOS": {+ "frameworks": ["pdfium/libpdfium.dylib"]+ }+ }+}diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.jsonnew file mode 100644index 00000000..0aa879b5--- /dev/null+++ b/src-tauri/tauri.windows.conf.json@@ -0,0 +1,7 @@+{+ "bundle": {+ "resources": {+ "pdfium/pdfium.dll": "./pdfium.dll"+ }+ }+}