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
fix: render PDF previews across desktop platforms
nash_su454343fbf84c
diff --git a/package-lock.json b/package-lock.jsonindex 6aebf69d..f06d6a5f 100644--- a/package-lock.json+++ b/package-lock.json@@ -34,6 +34,7 @@"katex": "^0.16.45","lucide-react": "^1.7.0","mermaid": "^11.14.0",+ "pdfjs-dist": "^5.7.284","react": "^19.0.0","react-dom": "^19.0.0","react-i18next": "^17.0.2",@@ -101,7 +102,6 @@"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz","integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==","license": "MIT",- "peer": true,"dependencies": {"@babel/code-frame": "^7.29.0","@babel/generator": "^7.29.0",@@ -884,7 +884,6 @@"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz","integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==","license": "MIT",- "peer": true,"dependencies": {"@codemirror/state": "^6.0.0","@codemirror/view": "^6.23.0",@@ -961,7 +960,6 @@"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.6.0.tgz","integrity": "sha512-4nbvra5R5EtiCzr9BTHiTLc+MLXK2QGiAVYMyi8PkQd3SR+6ixar/Q/01Fa21TBIDOZXgeWV4WppsQolSreAPQ==","license": "MIT",- "peer": true,"dependencies": {"@marijn/find-cluster-break": "^1.0.0"}@@ -983,7 +981,6 @@"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.41.0.tgz","integrity": "sha512-6H/qadXsVuDY219Yljhohglve8xf4B8xJkVOEWfA5uiYKiTFppjqsvsfR5iPA0RbvRBoOyTZpbLIxe9+0UR8xA==","license": "MIT",- "peer": true,"dependencies": {"@codemirror/state": "^6.6.0","crelt": "^1.0.6",@@ -1135,10 +1132,31 @@"@noble/ciphers": "^1.0.0"}},+ "node_modules/@emnapi/core": {+ "version": "1.11.2",+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.2.tgz",+ "integrity": "sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@emnapi/wasi-threads": "1.2.2",+ "tslib": "^2.4.0"+ }+ },+ "node_modules/@emnapi/runtime": {+ "version": "1.11.2",+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.2.tgz",+ "integrity": "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^2.4.0"+ }+ },"node_modules/@emnapi/wasi-threads": {- "version": "1.2.1",- "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",- "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",+ "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==","license": "MIT","optional": true,"dependencies": {@@ -1591,7 +1609,6 @@"resolved": "https://registry.npmjs.org/@milkdown/core/-/core-7.20.0.tgz","integrity": "sha512-X9LaUcIR4Y2oiY2J5tslavlPVOwIB3X8/9z1bOeBjlIPtr+urbkY7YEX86EeLV9LyRQ3+t+jXaLMCIjW1wsV6w==","license": "MIT",- "peer": true,"dependencies": {"@milkdown/ctx": "7.20.0","@milkdown/exception": "7.20.0",@@ -1631,7 +1648,6 @@"resolved": "https://registry.npmjs.org/@milkdown/ctx/-/ctx-7.20.0.tgz","integrity": "sha512-LUK4xdsUngY2xCCvPTyHPifjAknJ5rE6VBjgsP+LySIUKeFUrhqzo/zz2vaOODKzm3DBMIhpZAoW3MAqxoMGIQ==","license": "MIT",- "peer": true,"dependencies": {"@milkdown/exception": "7.20.0"}@@ -1898,7 +1914,6 @@"resolved": "https://registry.npmjs.org/@milkdown/prose/-/prose-7.20.0.tgz","integrity": "sha512-Qe6jmKcXsjOfpk8duDFdkLCEo5044L8HSyKVn7ewAe7XJJPUM6bPQaP130UAznq75/+TiKxFCzurcrBO3LzNRg==","license": "MIT",- "peer": true,"dependencies": {"@milkdown/exception": "7.20.0","prosemirror-changeset": "^2.3.1",@@ -1947,7 +1962,6 @@"resolved": "https://registry.npmjs.org/@milkdown/transformer/-/transformer-7.20.0.tgz","integrity": "sha512-h7KGFr1o5AYwc+hEfnA3Dldo4jRrYOB/7KExaqelcjUz++KYI/9LXMOsV7CpgjtLI3Xtf2IIRTZND1+p2nsOaw==","license": "MIT",- "peer": true,"dependencies": {"@milkdown/exception": "7.20.0","@milkdown/prose": "7.20.0",@@ -2044,6 +2058,256 @@"node": ">=18"}},+ "node_modules/@napi-rs/canvas": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.100.tgz",+ "integrity": "sha512-xglYA6q3XO5P3BNJYxVZ1IV7DLVjp1Py6nwag88YntrS+3vKHyYcMqXVS4ZztJmwz2uGvz1FWhI/4LgbR5uQDA==",+ "license": "MIT",+ "optional": true,+ "workspaces": [+ "e2e/*"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ },+ "optionalDependencies": {+ "@napi-rs/canvas-android-arm64": "0.1.100",+ "@napi-rs/canvas-darwin-arm64": "0.1.100",+ "@napi-rs/canvas-darwin-x64": "0.1.100",+ "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.100",+ "@napi-rs/canvas-linux-arm64-gnu": "0.1.100",+ "@napi-rs/canvas-linux-arm64-musl": "0.1.100",+ "@napi-rs/canvas-linux-riscv64-gnu": "0.1.100",+ "@napi-rs/canvas-linux-x64-gnu": "0.1.100",+ "@napi-rs/canvas-linux-x64-musl": "0.1.100",+ "@napi-rs/canvas-win32-arm64-msvc": "0.1.100",+ "@napi-rs/canvas-win32-x64-msvc": "0.1.100"+ }+ },+ "node_modules/@napi-rs/canvas-android-arm64": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-0.1.100.tgz",+ "integrity": "sha512-hjhCKhntPv9+t4ckHymdx0phYNcVW+GKQR6Lzw2zE+pOVjOplSmtx9nNNknTjbEDLcuLZqA1y8ufKg1XfgftzQ==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-darwin-arm64": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-0.1.100.tgz",+ "integrity": "sha512-2PcswRaC7Ly645DGt88///zuFDhJxJYdKAs1uU3mfk1atYkXufgcgLfBpk6Tm12nCQBaNt1wpybuPZ4qOhTo8A==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-darwin-x64": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-0.1.100.tgz",+ "integrity": "sha512-ePNZtj7pNIva/siZMg+HmbeozkIjqUIYdoymH8HaA3qK7LfzFN4WMBM8G6HQ9ZC+H3+Dnn5pqtiXpgLykaPOhw==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-arm-gnueabihf": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-0.1.100.tgz",+ "integrity": "sha512-d5cDB48oWFGU8/XPhUOFAlySgb/VAu7D+s8fi55K1Pcfg8aPplHWqMgibhVLU8ky7Pyg/fuiVLz4Nf3JrSTuUA==",+ "cpu": [+ "arm"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-arm64-gnu": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-0.1.100.tgz",+ "integrity": "sha512-rDxgxRu69RvDlX/bh9o22DxLsGr8EqsNgotL9+RwQE1S0b0cqeatqsw6aW45mukm0B42DIAaAacKaYQ8cqS1nw==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-arm64-musl": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-0.1.100.tgz",+ "integrity": "sha512-K3mDW66N+xT2/V439u1alFANiBUjdEx2gLiNYnCmUsva5jZMxWTjafBYwTzYK+EMFMHrUoabuU+T1BIP5CgbYQ==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-riscv64-gnu": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-0.1.100.tgz",+ "integrity": "sha512-mooqUBTIsccZpnoQC4NgrC1v6C1vof39etLNMnBwCY+p0gajWJvAHLGQ6g/gGyS5YrpDW+GefSN4+Cvcr08UWw==",+ "cpu": [+ "riscv64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-x64-gnu": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-0.1.100.tgz",+ "integrity": "sha512-1eCvkDCazm7FFhsT7DfGOdSaHgZVK3bt/dSBl5EWHOWmnz+I7j8tPseJqqD81NF+MH21jKUK4wQSDjN0mdhnTg==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-linux-x64-musl": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-0.1.100.tgz",+ "integrity": "sha512-20arT6lnI19S68qNlii73TSEDbECNgzMz2EpldC1V3mZFuRkeujXkcebRk0LRJe9SEUAooYiLokfMViY8IX7yA==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-win32-arm64-msvc": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-arm64-msvc/-/canvas-win32-arm64-msvc-0.1.100.tgz",+ "integrity": "sha512-DZFFT1wIAg37LJw37yhMRFfjATd3vTQzjZ1Yki8u2vhO6Hi5VE6BVaGQ1aaDu7xb4iMErz+9EOwjpS7xcxFeBw==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },+ "node_modules/@napi-rs/canvas-win32-x64-msvc": {+ "version": "0.1.100",+ "resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-0.1.100.tgz",+ "integrity": "sha512-MyT1j3mHC2+Lu4pBi9mKyMJhtP6U7k7EldY7sj/uS5gJA65gTXt8MefJQXLJo5d/vZbuWmfxzkEUNc/urV3pHA==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ }+ },"node_modules/@napi-rs/wasm-runtime": {"version": "1.1.2","resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.2.tgz",@@ -2067,7 +2331,6 @@"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz","integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==","license": "MIT",- "peer": true,"engines": {"node": "^14.21.3 || >=16"},@@ -3336,7 +3599,6 @@"integrity": "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==","devOptional": true,"license": "MIT",- "peer": true,"dependencies": {"undici-types": "~7.18.0"}@@ -3346,7 +3608,6 @@"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz","integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==","license": "MIT",- "peer": true,"dependencies": {"csstype": "^3.2.2"}@@ -3869,7 +4130,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"baseline-browser-mapping": "^2.10.12","caniuse-lite": "^1.0.30001782",@@ -4042,7 +4302,6 @@"version": "12.0.0","resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-12.0.0.tgz","integrity": "sha512-csJvb+6kEiQaqo1woTdSAuOWdN0WTLIydkKrBnS+V5gZz0oqBrp4kQ35519QgK6TpBThiG3V1vNSHlIkv4AglQ==",- "peer": true,"dependencies": {"@chevrotain/cst-dts-gen": "12.0.0","@chevrotain/gast": "12.0.0",@@ -4423,7 +4682,6 @@"version": "3.33.3","resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.33.3.tgz","integrity": "sha512-Gej7U+OKR+LZ8kvX7rb2HhCYJ0IhvEFsnkud4SB1PR+BUY/TsSO0dmOW59WEVLu51b1Rm+gQRKoz4bLYxGSZ2g==",- "peer": true,"engines": {"node": ">=0.10"}@@ -4809,7 +5067,6 @@"version": "3.0.0","resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz","integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",- "peer": true,"engines": {"node": ">=12"}@@ -5356,7 +5613,6 @@"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz","integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==","license": "MIT",- "peer": true,"dependencies": {"accepts": "^2.0.0","body-parser": "^2.2.1",@@ -5780,7 +6036,6 @@"resolved": "https://registry.npmjs.org/graphology/-/graphology-0.26.0.tgz","integrity": "sha512-8SSImzgUUYC89Z042s+0r/vMibY7GX/Emz4LDO5e7jYXhuoWfHISPFJYjpRLUSJGq6UQ6xlenvX1p/hJdfXuXg==","license": "MIT",- "peer": true,"dependencies": {"events": "^3.3.0"},@@ -6061,7 +6316,6 @@"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.10.tgz","integrity": "sha512-mx/p18PLy5og9ufies2GOSUqep98Td9q4i/EF6X7yJgAiIopxqdfIO3jbqsi3jRgTgw88jMDEzVKi+V2EF+27w==","license": "MIT",- "peer": true,"engines": {"node": ">=16.9.0"}@@ -6146,7 +6400,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"@babel/runtime": "^7.29.2"},@@ -8546,6 +8799,18 @@"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==","license": "MIT"},+ "node_modules/pdfjs-dist": {+ "version": "5.7.284",+ "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-5.7.284.tgz",+ "integrity": "sha512-h4EdYQczmGhbOlqc3PPZwxevn7ApdWPbovAuWXOB/DjIyigSnwfy2oze7c6mRcSr9XgLp3eN3EeL4DyySTPMFw==",+ "license": "Apache-2.0",+ "engines": {+ "node": ">=22.13.0 || >=24"+ },+ "optionalDependencies": {+ "@napi-rs/canvas": "^0.1.100"+ }+ },"node_modules/picocolors": {"version": "1.1.1","resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",@@ -8798,7 +9063,6 @@"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.4.tgz","integrity": "sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==","license": "MIT",- "peer": true,"dependencies": {"orderedmap": "^2.0.0"}@@ -8832,7 +9096,6 @@"resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz","integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==","license": "MIT",- "peer": true,"dependencies": {"prosemirror-model": "^1.0.0","prosemirror-transform": "^1.0.0",@@ -8866,7 +9129,6 @@"resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.8.tgz","integrity": "sha512-TnKDdohEatgyZNGCDWIdccOHXhYloJwbwU+phw/a23KBvJIR9lWQWW7WHHK3vBdOLDNuF7TaX98GObUZOWkOnA==","license": "MIT",- "peer": true,"dependencies": {"prosemirror-model": "^1.20.0","prosemirror-state": "^1.0.0",@@ -8992,7 +9254,6 @@"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz","integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==","license": "MIT",- "peer": true,"engines": {"node": ">=0.10.0"}@@ -9002,7 +9263,6 @@"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz","integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==","license": "MIT",- "peer": true,"dependencies": {"scheduler": "^0.27.0"},@@ -9663,7 +9923,6 @@"resolved": "https://registry.npmjs.org/sigma/-/sigma-3.0.2.tgz","integrity": "sha512-/BUbeOwPGruiBOm0YQQ6ZMcLIZ6tf/W+Jcm7dxZyAX0tK3WP9/sq7/NAWBxPIxVahdGjCJoGwej0Gdrv0DxlQQ==","license": "MIT",- "peer": true,"dependencies": {"events": "^3.3.0","graphology-utils": "^2.5.2"@@ -10126,7 +10385,6 @@"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==","devOptional": true,"license": "Apache-2.0",- "peer": true,"bin": {"tsc": "bin/tsc","tsserver": "bin/tsserver"@@ -10423,7 +10681,6 @@"resolved": "https://registry.npmjs.org/vite/-/vite-8.0.3.tgz","integrity": "sha512-B9ifbFudT1TFhfltfaIPgjo9Z3mDynBTJSUYxTjOQruf/zHH+ezCQKcoqO+h7a9Pw9Nm/OtlXAiGT1axBgwqrQ==","license": "MIT",- "peer": true,"dependencies": {"lightningcss": "^1.32.0","picomatch": "^4.0.4",@@ -10643,7 +10900,6 @@"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.32.tgz","integrity": "sha512-vM4z4Q9tTafVfMAK7IVzmxg34rSzTFMyIe0UUEijUCkn9+23lj0WRfA83dg7eQZIUlgOSGrkViIaCfqSAUXsMw==","license": "MIT",- "peer": true,"dependencies": {"@vue/compiler-dom": "3.5.32","@vue/compiler-sfc": "3.5.32",@@ -10906,7 +11162,6 @@"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz","integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==","license": "MIT",- "peer": true,"funding": {"url": "https://github.com/sponsors/colinhacks"}diff --git a/package.json b/package.jsonindex 8d7892af..2dc6c039 100644--- a/package.json+++ b/package.json@@ -43,6 +43,7 @@"katex": "^0.16.45","lucide-react": "^1.7.0","mermaid": "^11.14.0",+ "pdfjs-dist": "^5.7.284","react": "^19.0.0","react-dom": "^19.0.0","react-i18next": "^17.0.2",diff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex 2084e560..e7f3727a 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -1861,6 +1861,7 @@ pub async fn read_file_as_base64(path: String) -> Result<FileBase64, String> {"bmp" => "image/bmp","tiff" | "tif" => "image/tiff","svg" => "image/svg+xml",+ "pdf" => "application/pdf",_ => "application/octet-stream",}.to_string();diff --git a/src/components/editor/file-preview.test.ts b/src/components/editor/file-preview.test.tsindex 7308fd5d..1ec92f19 100644--- a/src/components/editor/file-preview.test.ts+++ b/src/components/editor/file-preview.test.ts@@ -1,5 +1,18 @@import { describe, expect, it } from "vitest"-import { parseDelimitedContent } from "./file-preview"+import { clampPdfPage, decodeBase64, parseDelimitedContent } from "./file-preview"++describe("PDF preview helpers", () => {+ it("decodes PDF bytes without depending on asset URLs or platform paths", () => {+ expect([...decodeBase64("JVBERi0=")]).toEqual([37, 80, 68, 70, 45])+ })++ it("keeps requested pages inside the loaded document", () => {+ expect(clampPdfPage(-2, 10)).toBe(1)+ expect(clampPdfPage(6, 10)).toBe(6)+ expect(clampPdfPage(99, 10)).toBe(10)+ expect(clampPdfPage(2, 0)).toBe(1)+ })+})describe("parseDelimitedContent", () => {it("preserves delimiters, escaped quotes, and newlines inside quoted cells", () => {diff --git a/src/components/editor/file-preview.tsx b/src/components/editor/file-preview.tsxindex 7604ed6d..d081f0a9 100644--- a/src/components/editor/file-preview.tsx+++ b/src/components/editor/file-preview.tsx@@ -22,6 +22,8 @@ import {X,} from "lucide-react"import { useTranslation } from "react-i18next"+import type { PDFDocumentLoadingTask, PDFDocumentProxy, RenderTask } from "pdfjs-dist"+import { getFileSize, readFileAsBase64 } from "@/commands/fs"import {getFileCategory,getCodeLanguage,@@ -99,19 +101,139 @@ function PdfPreview({ filePath, content }: { filePath: string; content: string }const [showText, setShowText] = useState(false)const [page, setPage] = useState(1)const [zoom, setZoom] = useState(100)- const src = `${convertFileSrc(filePath)}#page=${page}&zoom=${zoom}`+ const [reloadKey, setReloadKey] = useState(0)+ const [document, setDocument] = useState<PDFDocumentProxy | null>(null)+ const [pageCount, setPageCount] = useState(0)+ const [loadError, setLoadError] = useState<string | null>(null)+ const [loading, setLoading] = useState(true)+ const canvasRef = useRef<HTMLCanvasElement | null>(null)++ useEffect(() => {+ let disposed = false+ let loadingTask: PDFDocumentLoadingTask | null = null+ let loadedDocument: PDFDocumentProxy | null = null++ setLoading(true)+ setLoadError(null)+ setDocument(null)+ setPageCount(0)+ setPage(1)++ void (async () => {+ try {+ // PDF.js receives bytes over Tauri IPC because WebView-native PDF+ // plugins and custom asset URLs are not portable across WebView2 and+ // WebKitGTK. Base64 temporarily expands memory, so very large files+ // must stay on the streaming system-reader path instead.+ const fileSize = await getFileSize(filePath)+ if (fileSize > MAX_INLINE_PDF_BYTES) throw new Error(t("preview.pdfTooLarge"))+ const [{ getDocument, GlobalWorkerOptions }, workerModule, file] = await Promise.all([+ // The legacy build includes the URL/Promise/AbortSignal polyfills+ // required by older WebKitGTK runtimes still shipped by supported+ // Linux distributions. Windows WebView2 also uses this same path.+ import("pdfjs-dist/legacy/build/pdf.mjs"),+ import("pdfjs-dist/legacy/build/pdf.worker.min.mjs?url"),+ readFileAsBase64(filePath),+ ])+ GlobalWorkerOptions.workerSrc = workerModule.default+ loadingTask = getDocument({ data: decodeBase64(file.base64) })+ loadedDocument = await loadingTask.promise+ if (disposed) {+ await loadedDocument.destroy()+ return+ }+ setDocument(loadedDocument)+ setPageCount(loadedDocument.numPages)+ } catch (error) {+ if (!disposed) setLoadError(error instanceof Error ? error.message : String(error))+ } finally {+ if (!disposed) setLoading(false)+ }+ })()++ return () => {+ disposed = true+ if (loadingTask) void loadingTask.destroy()+ else if (loadedDocument) void loadedDocument.destroy()+ }+ }, [filePath, reloadKey, t])++ useEffect(() => {+ if (!document || showText) return+ const canvas = canvasRef.current+ if (!canvas) return+ let disposed = false+ let renderTask: RenderTask | null = null++ void (async () => {+ try {+ const pdfPage = await document.getPage(Math.min(page, document.numPages))+ if (disposed) return+ const viewport = pdfPage.getViewport({ scale: (zoom / 100) * 1.25 })+ const pixelRatio = window.devicePixelRatio || 1+ const context = canvas.getContext("2d")+ if (!context) throw new Error("Canvas 2D rendering is unavailable")+ canvas.width = Math.floor(viewport.width * pixelRatio)+ canvas.height = Math.floor(viewport.height * pixelRatio)+ canvas.style.width = `${Math.floor(viewport.width)}px`+ canvas.style.height = `${Math.floor(viewport.height)}px`+ renderTask = pdfPage.render({+ canvas,+ canvasContext: context,+ viewport,+ transform: pixelRatio === 1 ? undefined : [pixelRatio, 0, 0, pixelRatio, 0, 0],+ })+ await renderTask.promise+ } catch (error) {+ if (!disposed && !(error instanceof Error && error.name === "RenderingCancelledException")) {+ setLoadError(error instanceof Error ? error.message : String(error))+ }+ }+ })()++ return () => {+ disposed = true+ renderTask?.cancel()+ }+ }, [document, page, showText, zoom])+return <div className="flex h-full min-h-0 flex-col p-4"><div className="mb-2 flex items-center gap-1.5 text-xs text-muted-foreground"><span className="min-w-0 flex-1 truncate" title={filePath}>{filePath}</span><button type="button" className="rounded border px-2 py-1 hover:bg-muted" onClick={() => setShowText((value) => !value)}>{showText ? t("preview.pdfDocument") : t("preview.pdfText")}</button>- {!showText && <><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.max(50, value - 25))}><Minus className="h-3.5 w-3.5" /></button><span className="w-10 text-center">{zoom}%</span><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.min(300, value + 25))}><Plus className="h-3.5 w-3.5" /></button><label className="ml-1 flex items-center gap-1">{t("preview.pdfPage")}<input value={page} min={1} type="number" onChange={(event) => setPage(Math.max(1, Number(event.target.value) || 1))} className="w-14 rounded border bg-background px-1 py-0.5" /></label></>}+ {!showText && <><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.max(50, value - 25))}><Minus className="h-3.5 w-3.5" /></button><span className="w-10 text-center">{zoom}%</span><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.min(300, value + 25))}><Plus className="h-3.5 w-3.5" /></button><label className="ml-1 flex items-center gap-1">{t("preview.pdfPage")}<input value={page} min={1} max={pageCount || undefined} type="number" onChange={(event) => setPage(clampPdfPage(Number(event.target.value) || 1, pageCount))} className="w-14 rounded border bg-background px-1 py-0.5" /></label><span>/ {pageCount || "–"}</span></>}+ <button type="button" onClick={() => void openPath(filePath)} className="rounded p-1 hover:bg-muted" title={t("preview.openWithSystem")} aria-label={t("preview.openWithSystem")}><ExternalLink className="h-3.5 w-3.5" /></button></div><div className="min-h-0 flex-1 overflow-hidden rounded-md border bg-white">- {showText ? <TextPreview filePath={filePath} content={content} label="PDF text" /> : <object key={src} data={src} type="application/pdf" className="h-full w-full"><iframe title={filePath} src={src} className="h-full w-full" /></object>}+ {showText ? <TextPreview filePath={filePath} content={content} label="PDF text" /> : loading ? (+ <div className="flex h-full items-center justify-center text-sm text-muted-foreground">{t("preview.pdfLoading")}</div>+ ) : loadError ? (+ <div className="flex h-full flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground">+ <FileQuestion className="h-8 w-8" />+ <p>{t("preview.pdfLoadError")}</p>+ <p className="max-w-xl break-words text-xs opacity-70">{loadError}</p>+ <button type="button" className="rounded border px-3 py-1.5 hover:bg-muted" onClick={() => setReloadKey((value) => value + 1)}>{t("preview.reload")}</button>+ </div>+ ) : (+ <div className="h-full overflow-auto bg-muted/30 p-4"><canvas ref={canvasRef} className="mx-auto bg-white shadow-sm" /></div>+ )}</div></div>}+const MAX_INLINE_PDF_BYTES = 128 * 1024 * 1024++export function decodeBase64(value: string): Uint8Array {+ const binary = atob(value)+ const bytes = new Uint8Array(binary.length)+ for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index)+ return bytes+}++export function clampPdfPage(page: number, pageCount: number): number {+ return Math.min(Math.max(1, Math.trunc(page)), Math.max(1, pageCount))+}+export function parseDelimitedContent(content: string, delimiter: string, maxRows = 500): string[][] {const rows: string[][] = []let cells: string[] = []diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex e5deb14c..d0b052f9 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -947,7 +947,10 @@"historyRestore": "Restore this version","pdfText": "Text","pdfDocument": "PDF",- "pdfPage": "Page"+ "pdfPage": "Page",+ "pdfLoading": "Loading PDF...",+ "pdfLoadError": "The PDF could not be rendered. You can retry or open it with the system app.",+ "pdfTooLarge": "This PDF is too large for the in-app preview. Open it with the system app."},"activity": {"processing": "Processing: {{title}}",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex 2283da5a..c9a6e4b7 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -947,7 +947,10 @@"historyRestore": "恢复此版本","pdfText": "文本","pdfDocument": "PDF",- "pdfPage": "页码"+ "pdfPage": "页码",+ "pdfLoading": "正在加载 PDF...",+ "pdfLoadError": "无法渲染此 PDF。你可以重试或使用系统应用打开。",+ "pdfTooLarge": "此 PDF 文件过大,无法在应用内预览。请使用系统应用打开。"},"activity": {"processing": "处理中:{{title}}",