refactor: remove ghostscript-wasm and update service worker and ghostscript loader

- Deleted the ghostscript-wasm binary file.
- Added new ICC profile file for color management.
- Updated service worker to change cache version and remove ghostscript-wasm assets from critical assets.
- Modified ghostscript loader to handle asset URLs more robustly and fetch the new ICC profile correctly.
This commit is contained in:
alam00000
2026-01-30 15:24:33 +05:30
parent 981aff3c5a
commit fa10e97a00
5 changed files with 38 additions and 153 deletions

View File

@@ -5,7 +5,7 @@
* Version: 1.1.0
*/
const CACHE_VERSION = 'bentopdf-v9';
const CACHE_VERSION = 'bentopdf-v10';
const CACHE_NAME = `${CACHE_VERSION}-static`;
const getBasePath = () => {
@@ -14,30 +14,10 @@ const getBasePath = () => {
return url.pathname.replace(/\/$/, '') || '';
};
const buildCriticalAssets = (basePath) => [
`${basePath}/pymupdf-wasm/pyodide.js`,
`${basePath}/pymupdf-wasm/pyodide.asm.js`,
`${basePath}/pymupdf-wasm/pyodide.asm.wasm`,
`${basePath}/pymupdf-wasm/python_stdlib.zip`,
`${basePath}/pymupdf-wasm/pyodide-lock.json`,
`${basePath}/pymupdf-wasm/pymupdf-1.26.3-cp313-none-pyodide_2025_0_wasm32.whl`,
`${basePath}/pymupdf-wasm/numpy-2.2.5-cp313-cp313-pyodide_2025_0_wasm32.whl`,
`${basePath}/pymupdf-wasm/opencv_python-4.11.0.86-cp313-cp313-pyodide_2025_0_wasm32.whl`,
`${basePath}/pymupdf-wasm/lxml-5.4.0-cp313-cp313-pyodide_2025_0_wasm32.whl`,
`${basePath}/pymupdf-wasm/python_docx-1.2.0-py3-none-any.whl`,
`${basePath}/pymupdf-wasm/pdf2docx-0.5.8-py3-none-any.whl`,
`${basePath}/pymupdf-wasm/fonttools-4.56.0-py3-none-any.whl`,
`${basePath}/pymupdf-wasm/typing_extensions-4.12.2-py3-none-any.whl`,
`${basePath}/pymupdf-wasm/pymupdf4llm-0.0.27-py3-none-any.whl`,
`${basePath}/ghostscript-wasm/gs.js`,
`${basePath}/ghostscript-wasm/gs.wasm`,
];
const buildCriticalAssets = () => [];
self.addEventListener('install', (event) => {
const basePath = getBasePath();
const CRITICAL_ASSETS = buildCriticalAssets(basePath);
const CRITICAL_ASSETS = buildCriticalAssets();
// console.log('🚀 [ServiceWorker] Installing version:', CACHE_VERSION);
// console.log('📍 [ServiceWorker] Base path detected:', basePath || '/');
// console.log('📦 [ServiceWorker] Will cache', CRITICAL_ASSETS.length, 'critical assets');
@@ -288,12 +268,6 @@ async function networkFirstStrategy(request) {
* Returns the local directory path for a given CDN package
*/
function getLocalPathForCDNUrl(pathname) {
if (pathname.includes('/@bentopdf/pymupdf-wasm')) {
return '/pymupdf-wasm/';
}
if (pathname.includes('/@bentopdf/gs-wasm')) {
return '/ghostscript-wasm/';
}
if (pathname.includes('/@matbee/libreoffice-converter')) {
return '/libreoffice-wasm/';
}
@@ -316,8 +290,6 @@ function shouldCache(pathname, isCDN = false) {
return (
pathname.includes('/libreoffice-wasm/') ||
pathname.includes('/pymupdf-wasm/') ||
pathname.includes('/ghostscript-wasm/') ||
pathname.includes('/embedpdf/') ||
pathname.includes('/assets/') ||
pathname.match(