|
| 1 | +# open-files |
| 2 | + |
| 3 | +Minimal, sleek, cross-platform document viewer for PDF, Markdown, JSON, Text, Mermaid, and EPUB. |
| 4 | + |
| 5 | +Built with Tauri v2 + React + TypeScript + Vite. |
| 6 | + |
| 7 | +## Supported Formats |
| 8 | + |
| 9 | +| Format | Extensions | Renderer | |
| 10 | +| -------- | --------------------------------------- | ------------------- | |
| 11 | +| PDF | `.pdf` | pdfjs-dist | |
| 12 | +| Markdown | `.md`, `.markdown` | @create-markdown/core + preview | |
| 13 | +| Mermaid | `.mmd`, `.mermaid` | @create-markdown/preview-mermaid | |
| 14 | +| JSON | `.json` | Pretty-print with error display | |
| 15 | +| Text | `.txt`, `.log`, `.csv`, `.yaml`, `.toml`, `.xml`, etc. | Preformatted viewer | |
| 16 | +| EPUB | `.epub` | epubjs | |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- [Node.js](https://nodejs.org/) (v20+) |
| 21 | +- [pnpm](https://pnpm.io/) (v8+) |
| 22 | +- [Rust](https://rustup.rs/) (for Tauri native builds) |
| 23 | +- Xcode Command Line Tools (macOS) or equivalent platform toolchain |
| 24 | + |
| 25 | +## Getting Started |
| 26 | + |
| 27 | +```bash |
| 28 | +# Install dependencies |
| 29 | +pnpm install |
| 30 | + |
| 31 | +# Run in browser (dev mode, no Tauri shell) |
| 32 | +pnpm dev |
| 33 | +# Open http://localhost:1420 |
| 34 | + |
| 35 | +# Run as native desktop app (requires Rust toolchain) |
| 36 | +pnpm tauri:dev |
| 37 | + |
| 38 | +# Build native app bundle |
| 39 | +pnpm tauri:build |
| 40 | + |
| 41 | +# Initialize mobile projects when the local toolchains are installed |
| 42 | +pnpm tauri:ios:init |
| 43 | +pnpm tauri:android:init |
| 44 | +``` |
| 45 | + |
| 46 | +## Scripts |
| 47 | + |
| 48 | +| Command | Description | |
| 49 | +| ----------------- | ---------------------------------------- | |
| 50 | +| `pnpm dev` | Start Vite dev server (browser mode) | |
| 51 | +| `pnpm build` | TypeScript check + Vite production build | |
| 52 | +| `pnpm preview` | Preview production build | |
| 53 | +| `pnpm typecheck` | TypeScript type checking only | |
| 54 | +| `pnpm test` | Run unit tests with Vitest | |
| 55 | +| `pnpm secrets:scan` | Scan tracked and untracked source files for common secret patterns | |
| 56 | +| `pnpm setup:hooks` | Enable the repository pre-commit hook locally | |
| 57 | +| `pnpm tauri:dev` | Launch Tauri desktop app in dev mode | |
| 58 | +| `pnpm tauri:build`| Build native desktop app bundle | |
| 59 | +| `pnpm tauri:ios:init` | Generate the iOS target project | |
| 60 | +| `pnpm tauri:ios:dev` | Launch on iOS simulator/device | |
| 61 | +| `pnpm tauri:ios:build` | Build the iOS app | |
| 62 | +| `pnpm tauri:android:init` | Generate the Android target project | |
| 63 | +| `pnpm tauri:android:dev` | Launch on Android emulator/device | |
| 64 | +| `pnpm tauri:android:build` | Build the Android app | |
| 65 | + |
| 66 | +## Secret Safety |
| 67 | + |
| 68 | +This repo intentionally ignores local env files, signing material, credentials, and build artifacts. The committed pre-commit hook runs `node scripts/secret-scan.mjs` to block common API keys, private key blocks, and credential assignments before commit. |
| 69 | + |
| 70 | +`pnpm install` enables `.githooks/` automatically via the `prepare` script. If hooks are not active, run: |
| 71 | + |
| 72 | +```bash |
| 73 | +pnpm setup:hooks |
| 74 | +pnpm secrets:scan |
| 75 | +``` |
| 76 | + |
| 77 | +GitHub Actions also runs the same secret scan on pushes and pull requests. |
| 78 | + |
| 79 | +## Architecture |
| 80 | + |
| 81 | +``` |
| 82 | +open-files/ |
| 83 | + index.html # Vite entry |
| 84 | + src/ |
| 85 | + main.tsx # React mount |
| 86 | + App.tsx # Main app shell (header, drop zone, routing) |
| 87 | + fileTypes.ts # File extension detection |
| 88 | + useFileLoader.ts # File loading (Tauri native or browser fallback) |
| 89 | + renderMarkdown.ts # Markdown/Mermaid rendering pipeline with DOMPurify |
| 90 | + styles.css # System-aware light/dark theme |
| 91 | + viewers/ |
| 92 | + PdfViewer.tsx # PDF rendering with pdfjs-dist |
| 93 | + MarkdownViewer.tsx # Markdown with @create-markdown/preview |
| 94 | + MermaidViewer.tsx # Mermaid via fenced code block rendering |
| 95 | + JsonViewer.tsx # JSON pretty-print with error handling |
| 96 | + TextViewer.tsx # Plain text / log / CSV viewer |
| 97 | + EpubViewer.tsx # EPUB reader with navigation |
| 98 | + __tests__/ |
| 99 | + fileTypes.test.ts # File type detection tests |
| 100 | + src-tauri/ |
| 101 | + src/ # Rust backend (Tauri plugins) |
| 102 | + tauri.conf.json # Tauri v2 configuration |
| 103 | + capabilities/ # Tauri v2 permission capabilities |
| 104 | + Cargo.toml # Rust dependencies |
| 105 | +``` |
| 106 | + |
| 107 | +## Features |
| 108 | + |
| 109 | +- Single-window UI with clean empty state and unsupported-format messaging |
| 110 | +- Open files via native dialog (Tauri) or browser file picker (dev mode) |
| 111 | +- Drag and drop file loading |
| 112 | +- File metadata display (name, size, format) |
| 113 | +- System-aware light/dark theme (follows OS preference) |
| 114 | +- PDF page navigation |
| 115 | +- EPUB chapter navigation |
| 116 | + |
| 117 | +## Release Targets |
| 118 | + |
| 119 | +open-files uses Tauri v2 so the same React/TypeScript interface can be packaged for macOS, Windows, Linux, iOS, and Android. Desktop builds are ready from this scaffold. Mobile targets are initialized with the scripts above once Xcode/iOS and Android SDK/JDK prerequisites are installed on the release machine. |
| 120 | + |
| 121 | +## Known Limitations |
| 122 | + |
| 123 | +- Markdown renders Mermaid fenced code blocks via @create-markdown/preview-mermaid |
| 124 | +- EPUB rendering depends on epubjs which has limited CSS support for complex layouts |
| 125 | +- PDF worker is bundled inline; large PDFs may be slow on first render |
| 126 | +- No file watching or auto-reload on external changes |
| 127 | +- No search within documents |
| 128 | +- No print support |
| 129 | +- Browser dev mode uses `<input type="file">` fallback instead of native dialog |
| 130 | +- Android builds require a Java runtime plus Android SDK tooling; those are not bundled with this repo |
| 131 | + |
| 132 | +## License |
| 133 | + |
| 134 | +MIT |
0 commit comments