svelte-pdf-view 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/PdfRenderer.svelte +3 -3
- package/dist/PdfViewerInner.svelte +3 -3
- package/dist/pdf-viewer/FindController.d.ts +1 -1
- package/dist/pdf-viewer/PDFPageView.d.ts +1 -1
- package/dist/pdf-viewer/PDFPageView.js +2 -2
- package/dist/pdf-viewer/PDFViewerCore.d.ts +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A modern, modular PDF viewer component for Svelte 5. Built on top of [PDF.js](https://mozilla.github.io/pdf.js/), with full TypeScript support and Shadow DOM isolation.
|
|
4
4
|
|
|
5
|
+
**[Live Demo](https://nullpointerexceptionkek.github.io/svelte-pdf-view/)**
|
|
6
|
+
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
9
|
- **PDF Rendering** - High-quality PDF rendering powered by PDF.js
|
package/dist/PdfRenderer.svelte
CHANGED
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
// Core instances
|
|
46
46
|
let viewer: import('./pdf-viewer/PDFViewerCore.js').PDFViewerCore | null = null;
|
|
47
47
|
let findController: import('./pdf-viewer/FindController.js').FindController | null = null;
|
|
48
|
-
let pdfjsLib: typeof import('pdfjs-dist') | null = null;
|
|
48
|
+
let pdfjsLib: typeof import('pdfjs-dist/legacy/build/pdf.mjs') | null = null;
|
|
49
49
|
|
|
50
50
|
async function initPdfJs() {
|
|
51
51
|
if (!browser) return null;
|
|
52
52
|
|
|
53
|
-
pdfjsLib = await import('pdfjs-dist');
|
|
54
|
-
const pdfjsWorker = await import('pdfjs-dist/build/pdf.worker.min.mjs?url');
|
|
53
|
+
pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
54
|
+
const pdfjsWorker = await import('pdfjs-dist/legacy/build/pdf.worker.min.mjs?url');
|
|
55
55
|
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker.default;
|
|
56
56
|
|
|
57
57
|
return pdfjsLib;
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
// Core instances (loaded dynamically)
|
|
44
44
|
let viewer: import('./pdf-viewer/PDFViewerCore.js').PDFViewerCore | null = null;
|
|
45
45
|
let findController: import('./pdf-viewer/FindController.js').FindController | null = null;
|
|
46
|
-
let pdfjsLib: typeof import('pdfjs-dist') | null = null;
|
|
46
|
+
let pdfjsLib: typeof import('pdfjs-dist/legacy/build/pdf.mjs') | null = null;
|
|
47
47
|
|
|
48
48
|
async function initPdfJs() {
|
|
49
49
|
if (!browser) return null;
|
|
50
50
|
|
|
51
|
-
pdfjsLib = await import('pdfjs-dist');
|
|
52
|
-
const pdfjsWorker = await import('pdfjs-dist/build/pdf.worker.min.mjs?url');
|
|
51
|
+
pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
52
|
+
const pdfjsWorker = await import('pdfjs-dist/legacy/build/pdf.worker.min.mjs?url');
|
|
53
53
|
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker.default;
|
|
54
54
|
|
|
55
55
|
return pdfjsLib;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { EventBus } from './EventBus.js';
|
|
6
6
|
import type { PDFViewerCore } from './PDFViewerCore.js';
|
|
7
|
-
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
7
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
8
8
|
export declare const FindState: {
|
|
9
9
|
readonly FOUND: 0;
|
|
10
10
|
readonly NOT_FOUND: 1;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* PDFPageView - Renders a single PDF page with canvas and text layer.
|
|
3
3
|
* This is a derivative work based on PDF.js pdf_page_view.js
|
|
4
4
|
*/
|
|
5
|
-
import type { PDFPageProxy, PageViewport } from 'pdfjs-dist';
|
|
5
|
+
import type { PDFPageProxy, PageViewport } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
6
6
|
import type { EventBus } from './EventBus.js';
|
|
7
7
|
export interface PDFPageViewOptions {
|
|
8
8
|
container: HTMLElement;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
|
-
import { setLayerDimensions } from 'pdfjs-dist';
|
|
15
|
+
import { setLayerDimensions } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
16
16
|
export const RenderingStates = {
|
|
17
17
|
INITIAL: 0,
|
|
18
18
|
RUNNING: 1,
|
|
@@ -227,7 +227,7 @@ export class PDFPageView {
|
|
|
227
227
|
this.div.appendChild(this.textLayerDiv);
|
|
228
228
|
try {
|
|
229
229
|
// Import TextLayer from pdfjs-dist
|
|
230
|
-
const { TextLayer } = await import('pdfjs-dist');
|
|
230
|
+
const { TextLayer } = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
231
231
|
const textContent = await this.pdfPage.getTextContent();
|
|
232
232
|
this.textDivs = [];
|
|
233
233
|
this.textContentItemsStr = [];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* PDFViewerCore - Main viewer that manages all pages in a scroll container.
|
|
3
3
|
* This is a derivative work based on PDF.js pdf_viewer.js
|
|
4
4
|
*/
|
|
5
|
-
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
5
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
6
6
|
import { EventBus } from './EventBus.js';
|
|
7
7
|
import { PDFPageView } from './PDFPageView.js';
|
|
8
8
|
export interface PDFViewerOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-pdf-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A modern, modular PDF viewer component for Svelte 5. Built on PDF.js with TypeScript support",
|
|
5
5
|
"author": "Louis Li",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"svelte": "
|
|
47
|
-
"
|
|
46
|
+
"@lucide/svelte": ">=0.500.0",
|
|
47
|
+
"svelte": "^5.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@lucide/svelte": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@eslint/compat": "^1.4.0",
|
|
56
56
|
"@eslint/js": "^9.39.1",
|
|
57
57
|
"@sveltejs/adapter-auto": "^7.0.0",
|
|
58
|
+
"@sveltejs/adapter-static": "^3.0.10",
|
|
58
59
|
"@sveltejs/kit": "^2.48.5",
|
|
59
60
|
"@sveltejs/package": "^2.5.6",
|
|
60
61
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|