mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00

- Updated `useToolOperation` to include file ID and operation parameters for better tracking. - Enhanced `useToolResources` to utilize refs for blob URL cleanup, improving performance and reducing unnecessary state updates. - Modified `ThumbnailGenerationService` to clarify worker setup and fallback mechanisms, removing excessive logging for cleaner output. - Refactored tool components (Compress, Convert, OCR, Split) to use `useFileActions` for state management, ensuring consistency across tools. - Expanded `FileContextState` and `FileContextActions` to support new file processing features and improved state management. - Added new `FileContextSelectors` for efficient file access and state querying, minimizing re-renders in components.
27 lines
753 B
JavaScript
27 lines
753 B
JavaScript
// Web Worker for lightweight data processing (not PDF rendering)
|
|
// PDF rendering must stay on main thread due to DOM dependencies
|
|
|
|
self.onmessage = async function(e) {
|
|
const { type, data, jobId } = e.data;
|
|
|
|
try {
|
|
// Handle PING for worker health check
|
|
if (type === 'PING') {
|
|
self.postMessage({ type: 'PONG', jobId });
|
|
return;
|
|
}
|
|
|
|
if (type === 'GENERATE_THUMBNAILS') {
|
|
// Web Workers cannot do PDF rendering due to DOM dependencies
|
|
// This is expected to fail and trigger main thread fallback
|
|
throw new Error('PDF rendering requires main thread (DOM access needed)');
|
|
}
|
|
} catch (error) {
|
|
self.postMessage({
|
|
type: 'ERROR',
|
|
jobId,
|
|
data: { error: error.message }
|
|
});
|
|
}
|
|
};
|