Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ jobs:

- name: Verify packaged native modules
run: npm run verify:package -- --platform linux --arch x64

- name: Verify the package loads on other distros
run: npm run verify:package:distros
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jobs:
- name: Verify packaged native modules
run: npm run verify:package -- --platform ${{ matrix.platform }} --arch ${{ matrix.arch }}

- name: Verify the package loads on other distros
if: runner.os == 'Linux'
run: npm run verify:package:distros -- --arch ${{ matrix.arch }}

- name: Submit notarization (async)
if: matrix.platform == 'mac'
continue-on-error: true
Expand Down
7 changes: 6 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ npm run build:win # Build Windows NSIS installer
npm run build:mac # Build macOS DMG
npm run build:linux # Build Linux AppImage
npm run verify:package # Check the packaged native modules (arch, presence, load test)
npm run verify:package:distros # Load the Linux package on other distros (needs Docker)

# Database
npm run generate # Generate Prisma client (required after schema changes)
Expand Down Expand Up @@ -299,8 +300,12 @@ For detailed instructions on adding new features, including step-by-step develop
- **Artifact Naming**: `${productName}-${version}-${arch}.${ext}` (e.g., `MarkPDFdown-1.0.0-x64.exe`)

### Native Modules and Packaging
- **Build on the target architecture**: sharp, `@napi-rs/canvas` and the Prisma engine ship as prebuilt binaries that `npm ci` and `prisma generate` install for the host only, and electron-builder does not fetch those of another arch. Packaging `--x64` on an arm64 machine produces an app that crashes at startup, so `release.yml` runs one job per arch on a native runner.
- **Build on the target architecture**: `@napi-rs/canvas` and the Prisma engine ship as prebuilt binaries that `npm ci` and `prisma generate` install for the host only, and electron-builder does not fetch those of another arch. Packaging `--x64` on an arm64 machine produces an app that crashes at startup, so `release.yml` runs one job per arch on a native runner.
- **`npm run verify:package`** (`scripts/verify-package-arch.mjs`) checks an unpacked package: binary architectures, required modules, and, when the host can run the package, a real load test in the packaged Electron. Pass `-- --platform <mac|win|linux> --arch <x64|arm64>` for another target. CI fails on any problem.
- **Linux Prisma engines**: Prisma picks its engine at runtime from the user's distro family and libssl, so a Linux package carries one per combination (`scripts/prisma-engines.mjs`). `binaryTargets` comes from `PRISMA_BINARY_TARGETS`, so a list in the schema can't put the other arch's engines in a package: run Prisma through `npm run generate` / `npm run migrate:*` (`scripts/prisma-cli.mjs`). A bare `npx prisma generate` stops with an error about the missing variable. `npm run verify:package:distros` (`scripts/verify-package-distros.mjs`) checks in containers that each distro loads the engine meant for it.
- **No sharp in Electron on Linux**: its libvips bundles and exports glib, while Electron links the system's, so the two mix and sharp segfaults inside `g_object_unref` (seen on Fedora 44, glib 2.88). `RTLD_DEEPBIND` doesn't help. `@napi-rs/canvas` has no such clash.
- **`@napi-rs/canvas` is pinned to an exact version, 1.0.11**: 0.1.x up to 1.0.3 segfault when decoding a truncated image (0.1.88 on 41 of 225 damaged samples), which takes down the main process, and again on each start since the task is picked up again. 1.0.12 and 1.0.13 segfault in Electron 38 as soon as they load, while passing in plain Node. So bump it only with `npm run verify:package`, whose load check covers both. `pdf-to-png-converter` asks for 0.1.x, so the `overrides` entry in `package.json` keeps a single copy in the package.
- **Images leaving the machine carry no metadata**: `ImageSplitter` re-encodes uploads through `ImageReencoder`, dropping Exif (GPS, device) and bringing photos to quality 80, and never falls back to the original. `ModelService` re-encodes any page file that still looks like it has metadata, such as those split by an older version.
- **New native dependency**: add it to `requiredModules` in the verify script and to `scripts/package-load-check.cjs`.
- **PDF rendering**: go through `renderPdfPages` (`src/core/infrastructure/adapters/split/PDFPageRenderer.ts`), never `pdf-to-png-converter` directly. The converter looks for the pdf.js CMaps and standard fonts under `process.cwd()`, which only works in `npm run dev`; without them CJK text silently disappears from the page images. The renderer overrides those paths through a non-public file of the converter, so the converter's version is pinned: when upgrading, run the integration test and `npm run verify:package`. Both render `scripts/fixtures/pdf-render-check.pdf` from a directory without `node_modules`.
- **Windows is x64 only**: Prisma has no Windows arm64 engine, and an arm64 process can't load the x64 one. Windows on Arm runs the x64 build under emulation.
Expand Down
2 changes: 1 addition & 1 deletion README.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ src/
- **أداة البناء**: Vite 6
- **واجهة المستخدم**: Ant Design 5
- **قاعدة البيانات**: Prisma ORM + SQLite
- **معالجة PDF**: pdf-lib، pdf-to-png-converter، Sharp
- **معالجة PDF**: pdf-lib، pdf-to-png-converter، @napi-rs/canvas
- **Markdown**: react-markdown، remark-gfm، remark-math، rehype-katex، rehype-prism-plus
- **الاختبار**: Vitest + Testing Library

Expand Down
2 changes: 1 addition & 1 deletion README.fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ src/
- **ابزار ساخت**: Vite 6
- **رابط کاربری**: Ant Design 5
- **پایگاه داده**: Prisma ORM + SQLite
- **پردازش PDF**: pdf-lib، pdf-to-png-converter، Sharp
- **پردازش PDF**: pdf-lib، pdf-to-png-converter، @napi-rs/canvas
- **Markdown**: react-markdown، remark-gfm، remark-math، rehype-katex، rehype-prism-plus
- **تست**: Vitest + Testing Library

Expand Down
2 changes: 1 addition & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ src/
- **ビルドツール**:Vite 6
- **UI**:Ant Design 5
- **データベース**:Prisma ORM + SQLite
- **PDF処理**:pdf-lib、pdf-to-png-converter、Sharp
- **PDF処理**:pdf-lib、pdf-to-png-converter、@napi-rs/canvas
- **Markdown**:react-markdown、remark-gfm、remark-math、rehype-katex、rehype-prism-plus
- **テスト**:Vitest + Testing Library

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ src/
- **Build Tool**: Vite 6
- **UI**: Ant Design 5
- **Database**: Prisma ORM + SQLite
- **PDF Processing**: pdf-lib, pdf-to-png-converter, Sharp
- **PDF Processing**: pdf-lib, pdf-to-png-converter, @napi-rs/canvas
- **Markdown**: react-markdown, remark-gfm, remark-math, rehype-katex, rehype-prism-plus
- **Testing**: Vitest + Testing Library

Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ src/
- **Инструмент сборки**: Vite 6
- **UI**: Ant Design 5
- **База данных**: Prisma ORM + SQLite
- **Обработка PDF**: pdf-lib, pdf-to-png-converter, Sharp
- **Обработка PDF**: pdf-lib, pdf-to-png-converter, @napi-rs/canvas
- **Markdown**: react-markdown, remark-gfm, remark-math, rehype-katex, rehype-prism-plus
- **Тестирование**: Vitest + Testing Library

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ src/
- **构建工具**:Vite 6
- **UI**:Ant Design 5
- **数据库**:Prisma ORM + SQLite
- **PDF 处理**:pdf-lib、pdf-to-png-converter、Sharp
- **PDF 处理**:pdf-lib、pdf-to-png-converter、@napi-rs/canvas
- **Markdown**:react-markdown、remark-gfm、remark-math、rehype-katex、rehype-prism-plus
- **测试**:Vitest + Testing Library

Expand Down
4 changes: 3 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ async function ensurePrismaClient() {
shell: true,
env: {
...process.env,
DATABASE_URL: 'file:./placeholder.db'
DATABASE_URL: 'file:./placeholder.db',
// schema.prisma 通过该变量读取 binaryTargets;这里只在用户本机运行,生成 native 即可
PRISMA_BINARY_TARGETS: '["native"]'
}
});
console.log('✅ Prisma client generated successfully.');
Expand Down
4 changes: 2 additions & 2 deletions docs/CONVERTER_WORKER_DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ model TaskDetail {

**执行命令**:
```bash
npx prisma migrate dev --name add_taskdetail_metrics
npm run migrate:dev -- --name add_taskdetail_metrics
```

**SQL 内容** (自动生成):
Expand Down Expand Up @@ -1523,7 +1523,7 @@ export class MockLLMClient extends LLMClient {
### Phase 1: 数据库准备 ✅

- [ ] 更新 `schema.prisma`(添加 TaskDetail 新字段)
- [ ] 执行 `npx prisma migrate dev --name add_taskdetail_metrics`
- [ ] 执行 `npm run migrate:dev -- --name add_taskdetail_metrics`
- [ ] 验证迁移成功
- [ ] 更新 TypeScript 类型定义

Expand Down
1 change: 1 addition & 0 deletions docs/IPC_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Application information.
| Method | Description |
|--------|-------------|
| `window.api.app.getVersion()` | Get app version from package.json |
| `window.api.app.getDatabaseStatus()` | Wait for the startup database initialization; `success: false` with `error` when it failed, plus `databasePath` when rebuilding the database file can help |

---

Expand Down
4 changes: 2 additions & 2 deletions docs/TASK_STATE_DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ model TaskDetail {

```bash
# 添加新字段到 Task 表
npx prisma migrate dev --name add_task_worker_fields
npm run migrate:dev -- --name add_task_worker_fields

# 添加新字段到 TaskDetail 表
npx prisma migrate dev --name add_taskdetail_worker_fields
npm run migrate:dev -- --name add_taskdetail_worker_fields
```

---
Expand Down
Loading
Loading