feat: separate AGPL libraries and add dynamic WASM loading

- Add WASM settings page for configuring external AGPL modules
- Implement dynamic loading for PyMuPDF, Ghostscript, and CoherentPDF
- Add Cloudflare Worker proxy for serving WASM files with CORS
- Update all affected tool pages to check WASM availability
- Add showWasmRequiredDialog for missing module configuration

Documentation:
- Update README, licensing.html, and docs to clarify AGPL components
  are not bundled and must be configured separately
- Add WASM-PROXY.md deployment guide with recommended source URLs
- Rename "CPDF" to "CoherentPDF" for consistency
This commit is contained in:
alam00000
2026-01-27 15:26:11 +05:30
parent f6d432eaa7
commit 2c85ca74e9
75 changed files with 9696 additions and 6587 deletions

View File

@@ -1,4 +1,6 @@
import { PyMuPDF } from '@bentopdf/pymupdf-wasm';
import { isWasmAvailable, getWasmBaseUrl } from '../config/wasm-cdn-config.js';
import { showWasmRequiredDialog } from '../utils/wasm-provider.js';
import { loadPyMuPDF, isPyMuPDFAvailable } from '../utils/pymupdf-loader.js';
import { createIcons, icons } from 'lucide';
import { downloadFile } from '../utils/helpers';
@@ -10,13 +12,11 @@ interface DeskewResult {
}
let selectedFiles: File[] = [];
let pymupdf: PyMuPDF | null = null;
let pymupdf: any = null;
function initPyMuPDF(): PyMuPDF {
async function initPyMuPDF(): Promise<any> {
if (!pymupdf) {
pymupdf = new PyMuPDF({
assetPath: import.meta.env.BASE_URL + 'pymupdf-wasm/',
});
pymupdf = await loadPyMuPDF();
}
return pymupdf;
}
@@ -137,6 +137,12 @@ async function processDeskew(): Promise<void> {
return;
}
// Check if PyMuPDF is configured
if (!isWasmAvailable('pymupdf')) {
showWasmRequiredDialog('pymupdf');
return;
}
const thresholdSelect = document.getElementById(
'deskew-threshold'
) as HTMLSelectElement;
@@ -148,7 +154,7 @@ async function processDeskew(): Promise<void> {
showLoader('Initializing PyMuPDF...');
try {
const pdf = initPyMuPDF();
const pdf = await initPyMuPDF();
await pdf.load();
for (const file of selectedFiles) {