Skip to content

Commit bc51cd1

Browse files
committed
Release open-files v0.0.1
0 parents  commit bc51cd1

94 files changed

Lines changed: 22978 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
node scripts/secret-scan.mjs

.github/workflows/secret-scan.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Secret scan
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
secret-scan:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22
20+
- name: Scan for committed secrets
21+
run: node scripts/secret-scan.mjs

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# dependencies
2+
node_modules/
3+
4+
# build
5+
dist/
6+
tsconfig.tsbuildinfo
7+
8+
# Tauri
9+
src-tauri/target/
10+
11+
# local env/secrets (examples are safe to commit)
12+
.env
13+
.env.*
14+
!.env.example
15+
!.env.*.example
16+
secrets/
17+
*.pem
18+
*.key
19+
*.p8
20+
*.p12
21+
*.jks
22+
*.keystore
23+
*.mobileprovision
24+
*.provisionprofile
25+
*.cer
26+
*.cert
27+
*.crt
28+
*.der
29+
*.asc
30+
*.gpg
31+
*.kdbx
32+
*.age
33+
34+
# logs
35+
logs/
36+
*.log
37+
npm-debug.log*
38+
yarn-debug.log*
39+
yarn-error.log*
40+
pnpm-debug.log*
41+
42+
# local overrides
43+
*.local
44+
45+
# IDE
46+
.vscode/
47+
.idea/
48+
*.swp
49+
*.swo
50+
*~
51+
52+
# OS
53+
.DS_Store
54+
Thumbs.db

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/open-files.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>open-files</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "open-files",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"preview": "vite preview",
10+
"typecheck": "tsc --noEmit",
11+
"test": "vitest run",
12+
"tauri": "tauri",
13+
"tauri:dev": "tauri dev",
14+
"tauri:build": "tauri build",
15+
"tauri:ios:init": "tauri ios init",
16+
"tauri:ios:dev": "tauri ios dev",
17+
"tauri:ios:build": "tauri ios build",
18+
"tauri:android:init": "tauri android init",
19+
"tauri:android:dev": "tauri android dev",
20+
"tauri:android:build": "tauri android build",
21+
"prepare": "git config core.hooksPath .githooks || true",
22+
"setup:hooks": "git config core.hooksPath .githooks",
23+
"secrets:scan": "node scripts/secret-scan.mjs",
24+
"release:mac:unsigned": "CI=true tauri build --bundles app,dmg --no-sign"
25+
},
26+
"dependencies": {
27+
"@create-markdown/core": "^2.0.3",
28+
"@create-markdown/preview": "^2.0.3",
29+
"@create-markdown/preview-mermaid": "^2.0.3",
30+
"@tauri-apps/api": "^2",
31+
"@tauri-apps/plugin-dialog": "^2",
32+
"@tauri-apps/plugin-fs": "^2",
33+
"dompurify": "^3.2.4",
34+
"epubjs": "^0.3.93",
35+
"mermaid": "^11",
36+
"pdfjs-dist": "^4.10.38",
37+
"react": "^19.1.0",
38+
"react-dom": "^19.1.0"
39+
},
40+
"devDependencies": {
41+
"@tauri-apps/cli": "^2",
42+
"@types/react": "^19.1.2",
43+
"@types/react-dom": "^19.1.2",
44+
"@vitejs/plugin-react": "^4.4.1",
45+
"typescript": "~5.8.3",
46+
"vite": "^6.3.4",
47+
"vitest": "^3.1.2"
48+
}
49+
}

0 commit comments

Comments
 (0)