Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a4aabff1d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -42,3 +42,6 @@ dev.env
|
||||
backend/vessel-backend
|
||||
data/
|
||||
backend/data-dev/
|
||||
|
||||
# Generated files
|
||||
frontend/static/pdf.worker.min.mjs
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
// Version is set at build time via -ldflags, or defaults to dev
|
||||
var Version = "0.4.10"
|
||||
var Version = "0.4.11"
|
||||
|
||||
func getEnvOrDefault(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
|
||||
@@ -12,6 +12,10 @@ RUN npm ci
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Copy PDF.js worker to static directory for local serving
|
||||
# This avoids CDN dependency and CORS issues with ESM modules
|
||||
RUN cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs static/
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vessel",
|
||||
"version": "0.4.10",
|
||||
"version": "0.4.11",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -11,7 +11,8 @@
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage"
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"postinstall": "cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs static/ 2>/dev/null || true"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^4.0.0",
|
||||
|
||||
@@ -150,8 +150,18 @@ async function loadPdfJs(): Promise<typeof import('pdfjs-dist')> {
|
||||
try {
|
||||
pdfjsLib = await import('pdfjs-dist');
|
||||
|
||||
// Set worker source using CDN for reliability
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.mjs`;
|
||||
// Use locally bundled worker (copied to static/ during build)
|
||||
// Falls back to CDN if local worker isn't available
|
||||
const localWorkerPath = '/pdf.worker.min.mjs';
|
||||
const cdnWorkerPath = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.mjs`;
|
||||
|
||||
// Try local first, with CDN fallback
|
||||
try {
|
||||
const response = await fetch(localWorkerPath, { method: 'HEAD' });
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = response.ok ? localWorkerPath : cdnWorkerPath;
|
||||
} catch {
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = cdnWorkerPath;
|
||||
}
|
||||
|
||||
return pdfjsLib;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user