Files
nextcloud-mcp-server/third_party/astrolabe/templates/index.php
T
Chris Coutinho 38adb96be4 fix(astrolabe): load pdfjs-dist externally to fix PDF viewer
When viewing PDF chunks in semantic search, the PDF viewer failed with
"can't access private field" errors. This was caused by:

1. CSP blocks web workers (worker-src 'none'), forcing fake worker mode
2. Vite transforms ES private fields in the bundle, but the worker file
   is untransformed, causing incompatible private field implementations
3. Vue's ref() wraps PDFDocumentProxy in a Proxy, which can't access
   ES private fields

Fixed by:
- Loading pdfjs-dist externally via script tag (avoids Vite transform)
- Creating pdfjs-loader.mjs that imports pdf.mjs and sets window.pdfjsLib
- Using Util::addScript() for CSP-compliant script loading with nonces
- Using shallowRef() instead of ref() for pdfDoc to avoid Proxy wrapper
- Setting workerSrc at runtime using OC.linkTo() for correct app path

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 21:08:44 +01:00

18 lines
536 B
PHP

<?php
declare(strict_types=1);
use OCA\Astrolabe\AppInfo\Application;
use OCP\Util;
// Load PDF.js loader first (must be external, not bundled by Vite,
// to avoid ES private field transformation issues with fake worker fallback)
// The loader imports pdf.mjs and sets window.pdfjsLib before the main app runs
Util::addScript(Application::APP_ID, 'pdfjs-loader');
Util::addScript(Application::APP_ID, Application::APP_ID . '-main');
Util::addStyle(Application::APP_ID, Application::APP_ID . '-main');
?>
<div id="astrolabe"></div>