mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
## Move editor under `frontend/editor/`
Pure restructure: `frontend/` becomes the workspace, `frontend/editor/`
holds
the PDF editor. 1775 file renames + 40 wiring edits. No logic changes.
### Why
`frontend/` is currently the editor — its `src/`, `public/`,
`src-tauri/`,
config files all sit at the root. Promoting `frontend/` to a
workspace and putting the editor in a sibling folder leaves room for
future
apps to drop in alongside it, sharing one `package.json` /
`node_modules` /
lint config / Storybook.
### What moves
frontend/
├── editor/ ← NEW: everything editor-specific
│ ├── src/ ← was frontend/src/
│ ├── public/ ← was frontend/public/
│ ├── src-tauri/ ← was frontend/src-tauri/
│ ├── index.html, vite.config.ts, vitest.config.ts, playwright.config.ts
│ ├── tsconfig*.json, tailwind.config.js, postcss.config.js
│ ├── scripts/
│ ├── .env, .env.desktop, .env.saas
│ └── DeveloperGuide.md
├── package.json, package-lock.json, node_modules/ ← workspace install
├── eslint.config.mjs, .prettierrc, .prettierignore ← shared tooling
├── .gitignore
└── README.md
### Wiring edits (40 files)
- `.taskfiles/frontend.yml`, `desktop.yml`, `e2e.yml`
- `build.gradle`, `app/core/build.gradle`
- `eslint.config.mjs`, `frontend/package.json`, `.gitignore`,
`.prettierignore`
- `docker/frontend/Dockerfile`
- 8 `.github/workflows/*.yml`, plus `.github/dependabot.yml`,
`.github/config/.files.yaml`, `.github/labeler-config-srvaroa.yml`
- `scripts/translations/**`
- Docs: `AGENTS.md`, `CLAUDE.md`, `ADDING_TOOLS.md`,
`DeveloperGuide.md`,
`WINDOWS_SIGNING.md`, `devGuide/HowToAddNewLanguage.md`,
`frontend/README.md`,
`frontend/editor/DeveloperGuide.md`
Plus 3 renamed + edited: `editor/vite.config.ts` (env path +
node_modules
walk-up), `editor/scripts/setup-env.mts` (renamed from `.ts` for
`import.meta.url`), `editor/scripts/build-provisioner.mjs` (resolve
src-tauri
relative to script).
### Verification
| Check | Result |
|---|---|
| `task frontend:typecheck:all` (6 variants) | exit 0 |
| `task frontend:lint` (eslint + dpdm) | exit 0 |
| `task frontend:format:check` | exit 0 |
| `task frontend:test` | 657 tests pass, 50 files |
| `task frontend:build:{core,proprietary,saas,desktop,prototypes}` | all
green |
| `task desktop:build` | full Tauri pipeline →
`Stirling-PDF_2.11.0_x64_en-US.msi` |
| `playwright test --list --project=stubbed` | 172 tests discovered |
`task desktop:build` exercises the heaviest path — Rust + WiX + MSI
bundle
against the moved `editor/src-tauri/`. If anything in the restructure
was
wrong it wouldn't have built.
### Test plan
- [ ] `frontend-validation.yml` green
- [ ] `e2e-stubbed.yml` green
- [ ] `tauri-build.yml` green on at least one platform
- [ ] `check_toml.yml` runs on a translation-touching PR
---------
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
69 lines
2.5 KiB
Rust
69 lines
2.5 KiB
Rust
#[cfg(target_os = "macos")]
|
|
mod macos {
|
|
use std::path::Path;
|
|
use std::sync::mpsc;
|
|
|
|
use objc2::rc::autoreleasepool;
|
|
use objc2::AnyThread;
|
|
use objc2_app_kit::NSPrintInfo;
|
|
use objc2_foundation::{MainThreadMarker, NSString, NSURL};
|
|
use objc2_pdf_kit::{PDFDocument, PDFPrintScalingMode};
|
|
use tauri::AppHandle;
|
|
|
|
#[tauri::command]
|
|
pub fn print_pdf_file_native(app: AppHandle, file_path: String, title: Option<String>) -> Result<(), String> {
|
|
if !Path::new(&file_path).exists() {
|
|
return Err(format!("Print file does not exist: {}", file_path));
|
|
}
|
|
|
|
let (sender, receiver) = mpsc::channel();
|
|
app.run_on_main_thread(move || {
|
|
let result = autoreleasepool(|_| {
|
|
let mtm = MainThreadMarker::new()
|
|
.ok_or_else(|| "macOS print must run on the main thread".to_string())?;
|
|
|
|
let path_string = NSString::from_str(&file_path);
|
|
let file_url = NSURL::fileURLWithPath(&path_string);
|
|
let document = unsafe { PDFDocument::initWithURL(PDFDocument::alloc(), &file_url) }
|
|
.ok_or_else(|| format!("Failed to load PDF for printing: {}", file_path))?;
|
|
|
|
let print_info = NSPrintInfo::sharedPrintInfo();
|
|
let print_operation = unsafe {
|
|
document
|
|
.printOperationForPrintInfo_scalingMode_autoRotate(
|
|
Some(&print_info),
|
|
PDFPrintScalingMode::PageScaleDownToFit,
|
|
true,
|
|
mtm,
|
|
)
|
|
}
|
|
.ok_or_else(|| "PDFKit did not create a print operation".to_string())?;
|
|
|
|
if let Some(job_title) = title.as_deref() {
|
|
print_operation.setJobTitle(Some(&NSString::from_str(job_title)));
|
|
}
|
|
|
|
print_operation.setShowsPrintPanel(true);
|
|
print_operation.setShowsProgressPanel(true);
|
|
let _ = print_operation.runOperation();
|
|
Ok(())
|
|
});
|
|
|
|
let _ = sender.send(result);
|
|
}).map_err(|error| error.to_string())?;
|
|
|
|
receiver
|
|
.recv()
|
|
.map_err(|error| error.to_string())?
|
|
}
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub use macos::print_pdf_file_native;
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
#[tauri::command]
|
|
pub fn print_pdf_file_native(_file_path: String, _title: Option<String>) -> Result<(), String> {
|
|
Err("Native PDF printing is only implemented on macOS".to_string())
|
|
}
|