🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

svelte-pdfjs

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-pdfjs - npm Package Compare versions

Comparing version

to
0.5.0-rc.0

utils/vite.d.ts

7

CHANGELOG.md
# svelte-pdfjs
## 0.5.0-rc.0
### Minor Changes
- [breaking] change api for supplying worker
## 0.4.0

@@ -9,3 +15,2 @@

## 0.4.0-rc.0

@@ -12,0 +17,0 @@

3

index.d.ts

@@ -1,4 +0,3 @@

export { default as Document, key } from './PDFViewer/Document.svelte';
export { default as Document } from './PDFViewer/Document.svelte';
export { default as Page } from './PDFViewer/Page.svelte';
export * from './utils/target_dimension.js';
export { set_worker_src as setWorkerSrc } from './utils/worker.js';

@@ -1,4 +0,3 @@

export { default as Document, key } from './PDFViewer/Document.svelte';
export { default as Document } from './PDFViewer/Document.svelte';
export { default as Page } from './PDFViewer/Page.svelte';
export * from './utils/target_dimension.js';
export { set_worker_src as setWorkerSrc } from './utils/worker.js';
{
"name": "svelte-pdfjs",
"version": "0.4.0",
"version": "0.5.0-rc.0",
"engines": {

@@ -32,3 +32,3 @@ "node": ">=16.0.0"

"./utils/target_dimension": "./utils/target_dimension.js",
"./utils/worker": "./utils/worker.js"
"./utils/vite": "./utils/vite.js"
},

@@ -38,4 +38,4 @@ "svelte": "./index.js",

"svelte": "^3.46.4",
"pdfjs-dist": "^2.16.105"
"pdfjs-dist": "2.16.105"
}
}
import { SvelteComponentTyped } from "svelte";
import type { DocumentInitParameters, OnProgressParameters, PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
export declare const key: unique symbol;
import type { PDFDocumentProxy } from 'pdfjs-dist';
import type { DocumentInitParameters, OnProgressParameters } from 'pdfjs-dist/types/src/display/api.js';
declare const __propDef: {
props: {
/** The URL of the file to load. */ file?: string | URL;
/** The URL of the file to load. */ file?: string | URL | undefined;
/**
* Extra options provided to PDFJS.getDocument.
* @see https://github.com/mozilla/pdf.js/blob/41dab8e7b6c1e2684d4afabb8f02e40a874d8e85/src/display/api.js#L126
*/ loadOptions?: DocumentInitParameters;
*/ loadOptions?: DocumentInitParameters | undefined;
/**
* Callback that fires everytime a part of the PDF is downloaded. Can be useful for showing a progress bar.
*/ onProgress?: (params: OnProgressParameters) => void;
*/ onProgress?: ((params: OnProgressParameters) => void) | undefined;
};

@@ -15,0 +15,0 @@ slots: {

@@ -9,3 +9,3 @@ import { SvelteComponentTyped } from "svelte";

* @default {"canvas"}
*/ renderer?: 'canvas' | 'svg';
*/ renderer?: "canvas" | "svg" | undefined;
/**

@@ -17,15 +17,15 @@ * The page number to show.

* @default {1}
*/ scale?: number;
*/ scale?: number | undefined;
/**
* Rotate the page by a multiple of 90 degrees.
* @default {0}
*/ rotation?: MultipleOf90;
*/ rotation?: MultipleOf90 | undefined;
/**
* Render a separate text layer (only for the canvas renderer.)
* @default {false}
*/ renderTextLayer?: boolean;
*/ renderTextLayer?: boolean | undefined;
/**
* A callback invoked with the current page used to determine the viewport.
* Use this if you need something more complicated than the default based on scale.
*/ getViewport?: CalcViewport;
*/ getViewport?: CalcViewport | undefined;
};

@@ -32,0 +32,0 @@ events: {

import { SvelteComponentTyped } from "svelte";
import type { PDFPageProxy, PageViewport } from 'pdfjs-dist';
import type { PageViewport, PDFPageProxy } from 'pdfjs-dist';
declare const __propDef: {

@@ -4,0 +4,0 @@ props: {

@@ -6,9 +6,14 @@ ## svelte-pdfjs

## Usage
See [src/routes/+page.svelte](src/routes/+page.svelte)
You'll have to install `pdfjs-dist` and provide a worker to the `Document` component through svelte's context. For vite/sveltekit users a convenience function is exported through [svelte-pdfjs/utils/vite](src/lib/utils/vite.ts) which takes care of browser checks, resolving the url to the worker, setting the context and cleaning up when the component is destroyed.
See [src/routes/+page.svelte](src/routes/+page.svelte) and [src/routes/+layout.svelte](src/routes/+layout.svelte)
[Demo](https://gtm-nayan.github.io/svelte-pdfjs)
## Custom worker source
You can provide a custom worker URL using `setWorkerSrc`, see [src/routes/+layout.ts](src/routes/+layout.ts)
## Treeshaking
Because of how pdfjs-dist is bundled with webpack, automatic treeshaking isn't possible like it is with ES modules. You can manually patch your installation of `pdfjs-dist` to ignore unused parts and reduce your bundle size if you so wish. [Example](patches/pdfjs-dist%402.16.105.patch)
## SSR
For now this package cannot be used with SSR, contributions to improve in that area are more than welcome. Because of how pdfjs-dist is packaged, there is an eval which prevents bundlers from properly minifying whatever chunk it ends up in. To get around it, you can patch your installation of pdfjs-dist such that all instances of `_is_node.isNodeJs` are replaced with `false` since those parts aren't going to be used anyway.

@@ -15,0 +20,0 @@

import type { PDFPageProxy } from 'pdfjs-dist';
import type { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
import type { PageViewport } from 'pdfjs-dist/types/src/display/display_utils.js';
export declare type MultipleOf90 = 0 | 90 | 180 | 270;

@@ -4,0 +4,0 @@ export declare type CalcViewport = (page: PDFPageProxy, rotation: MultipleOf90) => PageViewport;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet