38adb96be4
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>
18 lines
536 B
PHP
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>
|