Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tato30/vue-pdf

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tato30/vue-pdf - npm Package Compare versions

Comparing version 1.8.1 to 1.9.0

dist/types/components/utils/destination.d.ts

8

dist/types/components/layers/AnnotationLayer.vue.d.ts

@@ -6,4 +6,4 @@ import type { AnnotationEventPayload } from '../types';

document?: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
filter?: string[] | undefined;
map?: object | undefined;
annotationsFilter?: string[] | undefined;
annotationsMap?: object | undefined;
imageResourcesPath?: string | undefined;

@@ -18,4 +18,4 @@ hideForms?: boolean | undefined;

document?: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
filter?: string[] | undefined;
map?: object | undefined;
annotationsFilter?: string[] | undefined;
annotationsMap?: object | undefined;
imageResourcesPath?: string | undefined;

@@ -22,0 +22,0 @@ hideForms?: boolean | undefined;

@@ -0,8 +1,17 @@

import type { HighlightEventPayload, HighlightOptions } from '../types';
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api.js").PDFPageProxy | undefined;
viewport?: import("pdfjs-dist/types/src/display/display_utils.js").PageViewport | undefined;
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api.js").PDFPageProxy | undefined;
viewport?: import("pdfjs-dist/types/src/display/display_utils.js").PageViewport | undefined;
}>>>, {}, {}>;
page?: import("pdfjs-dist/types/src/display/api").PDFPageProxy | undefined;
viewport?: import("pdfjs-dist/types/src/display/display_utils").PageViewport | undefined;
highlightText?: string | undefined;
highlightOptions?: HighlightOptions | undefined;
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
highlight: (payload: HighlightEventPayload) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api").PDFPageProxy | undefined;
viewport?: import("pdfjs-dist/types/src/display/display_utils").PageViewport | undefined;
highlightText?: string | undefined;
highlightOptions?: HighlightOptions | undefined;
}>>> & {
onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
}, {}, {}>;
export default _default;

@@ -9,0 +18,0 @@ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;

import type { PageViewport } from 'pdfjs-dist';
import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TypedArray } from 'pdfjs-dist/types/src/display/api';
import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TextContent, TypedArray } from 'pdfjs-dist/types/src/display/api';
import type { Metadata } from 'pdfjs-dist/types/src/display/metadata';
export interface Match {
start: {
idx: number;
offset: number;
};
end: {
idx: number;
offset: number;
};
str: string;
oindex: number;
}
export type LoadedEventPayload = PageViewport;

@@ -9,2 +21,8 @@ export interface AnnotationEventPayload {

}
export interface HighlightEventPayload {
matches: Match[];
page: number;
textContent: TextContent;
textDivs: HTMLElement[];
}
export interface WatermarkOptions {

@@ -17,2 +35,28 @@ columns?: number;

}
export interface HighlightOptions {
ignoreCase?: boolean;
completeWords?: boolean;
}
export interface Base<T, S> {
type: T;
spec: S;
}
export type XYZ = Base<'XYZ', [left: number, top: number, zoom: number]>;
export type Fit = Base<'Fit', []>;
export type FitH = Base<'FitH', [top: number]>;
export type FitV = Base<'FitV', [left: number]>;
export type FitR = Base<'FitR', [
left: number,
bottom: number,
right: number,
top: number
]>;
export type FitB = Base<'FitB', []>;
export type FitBH = Base<'FitBH', [top: number]>;
export type FitBV = Base<'FitBV', [left: number]>;
export type PDFLocation = XYZ | Fit | FitH | FitV | FitR | FitB | FitBH | FitBV;
export interface PDFDestination {
pageIndex: number;
location: PDFLocation;
}
export type OnProgressCallback = (progressData: OnProgressParameters) => void;

@@ -22,4 +66,4 @@ export type UpdatePasswordFn = (newPassword: string) => void;

export type OnErrorCallback = (error: any) => void;
export type UsePDFSrc = string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters;
export interface UsePDFOptions {
export type PDFSrc = string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters;
export interface PDFOptions {
onProgress?: OnProgressCallback;

@@ -30,10 +74,11 @@ onPassword?: OnPasswordCallback;

}
export interface UsePDFInfoMetadata {
export interface PDFInfoMetadata {
info: Object;
metadata: Metadata;
}
export interface UsePDFInfo {
metadata: UsePDFInfoMetadata;
export interface PDFInfo {
metadata: PDFInfoMetadata;
attachments: Record<string, unknown>;
javascript: string[] | null;
outline: any;
}
import type { Ref } from 'vue';
import type { UsePDFInfo, UsePDFOptions, UsePDFSrc } from './types';
import type { PDFDestination, PDFInfo, PDFOptions, PDFSrc } from './types';
/**

@@ -21,6 +21,7 @@ * @typedef {Object} UsePDFParameters

*/
export declare function usePDF(src: UsePDFSrc | Ref<UsePDFSrc>, options?: UsePDFOptions): {
export declare function usePDF(src: PDFSrc | Ref<PDFSrc>, options?: PDFOptions): {
pdf: import("vue").ShallowRef<import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined>;
pages: import("vue").ShallowRef<number>;
info: import("vue").ShallowRef<{}> | import("vue").ShallowRef<UsePDFInfo>;
info: import("vue").ShallowRef<{}> | import("vue").ShallowRef<PDFInfo>;
getPDFDestination: (destination: string | any[] | null) => Promise<PDFDestination | null>;
};
import 'pdfjs-dist/web/pdf_viewer.css';
import type { AnnotationEventPayload, WatermarkOptions } from './types';
import type { AnnotationEventPayload, HighlightEventPayload, HighlightOptions, WatermarkOptions } from './types';
declare function reload(): void;
declare function cancel(): void;
declare function getAnnotationStorage(): import("pdfjs-dist/types/src/display/annotation_storage").AnnotationStorage | undefined;
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{

@@ -12,2 +11,4 @@ pdf?: import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined;

fitParent?: boolean | undefined;
width?: number | undefined;
height?: number | undefined;
textLayer?: boolean | undefined;

@@ -21,2 +22,4 @@ imageResourcesPath?: string | undefined;

watermarkOptions?: WatermarkOptions | undefined;
highlightText?: string | undefined;
highlightOptions?: HighlightOptions | undefined;
}>, {

@@ -28,5 +31,5 @@ page: number;

cancel: typeof cancel;
getAnnotationStorage: typeof getAnnotationStorage;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
annotation: (payload: AnnotationEventPayload) => void;
highlight: (payload: HighlightEventPayload) => void;
loaded: (payload: import("pdfjs-dist/types/src/display/display_utils").PageViewport) => void;

@@ -39,2 +42,4 @@ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{

fitParent?: boolean | undefined;
width?: number | undefined;
height?: number | undefined;
textLayer?: boolean | undefined;

@@ -48,2 +53,4 @@ imageResourcesPath?: string | undefined;

watermarkOptions?: WatermarkOptions | undefined;
highlightText?: string | undefined;
highlightOptions?: HighlightOptions | undefined;
}>, {

@@ -54,2 +61,3 @@ page: number;

onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined;
onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
onLoaded?: ((payload: import("pdfjs-dist/types/src/display/display_utils").PageViewport) => any) | undefined;

@@ -56,0 +64,0 @@ }, {

{
"name": "@tato30/vue-pdf",
"version": "1.8.1",
"version": "1.9.0",
"description": "PDF viewer for Vue 3",

@@ -5,0 +5,0 @@ "author": {

@@ -6,2 +6,3 @@ import type { PageViewport } from 'pdfjs-dist'

PDFDataRangeTransport,
TextContent,
TypedArray,

@@ -11,2 +12,15 @@ } from 'pdfjs-dist/types/src/display/api'

export interface Match {
start: {
idx: number
offset: number
}
end: {
idx: number
offset: number
}
str: string
oindex: number
}
export type LoadedEventPayload = PageViewport

@@ -19,2 +33,9 @@

export interface HighlightEventPayload {
matches: Match[]
page: number
textContent: TextContent
textDivs: HTMLElement[]
}
export interface WatermarkOptions {

@@ -28,2 +49,33 @@ columns?: number

export interface HighlightOptions {
ignoreCase?: boolean
completeWords?: boolean
}
export interface Base<T, S> {
type: T
spec: S
}
// These are types from the PDF 1.7 reference manual; Adobe
// Table 151 – Destination syntax
// (Coordinates origin is bottom left of page)
export type XYZ = Base<'XYZ', [left: number, top: number, zoom: number]>
export type Fit = Base<'Fit', []>
export type FitH = Base<'FitH', [top: number]>
export type FitV = Base<'FitV', [left: number]>
export type FitR = Base<
'FitR',
[left: number, bottom: number, right: number, top: number]
>
export type FitB = Base<'FitB', []>
export type FitBH = Base<'FitBH', [top: number]>
export type FitBV = Base<'FitBV', [left: number]>
export type PDFLocation = XYZ | Fit | FitH | FitV | FitR | FitB | FitBH | FitBV
export interface PDFDestination {
pageIndex: number
location: PDFLocation
}
export type OnProgressCallback = (progressData: OnProgressParameters) => void

@@ -34,3 +86,3 @@ export type UpdatePasswordFn = (newPassword: string) => void

export type UsePDFSrc =
export type PDFSrc =
| string

@@ -42,3 +94,3 @@ | URL

export interface UsePDFOptions {
export interface PDFOptions {
onProgress?: OnProgressCallback

@@ -50,3 +102,3 @@ onPassword?: OnPasswordCallback

export interface UsePDFInfoMetadata {
export interface PDFInfoMetadata {
info: Object

@@ -56,6 +108,7 @@ metadata: Metadata

export interface UsePDFInfo {
metadata: UsePDFInfoMetadata
export interface PDFInfo {
metadata: PDFInfoMetadata
attachments: Record<string, unknown>
javascript: string[] | null
outline: any
}

@@ -7,3 +7,4 @@ import * as PDFJS from 'pdfjs-dist'

import type { Ref } from 'vue'
import type { OnPasswordCallback, UsePDFInfo, UsePDFOptions, UsePDFSrc } from './types'
import type { OnPasswordCallback, PDFDestination, PDFInfo, PDFOptions, PDFSrc } from './types'
import { getDestinationArray, getDestinationRef, getLocation, isSpecLike } from './utils/destination'

@@ -36,4 +37,4 @@ // Could not find a way to make this work with vite, importing the worker entry bundle the whole worker to the the final output

*/
export function usePDF(src: UsePDFSrc | Ref<UsePDFSrc>,
options: UsePDFOptions = {
export function usePDF(src: PDFSrc | Ref<PDFSrc>,
options: PDFOptions = {
onProgress: undefined,

@@ -50,5 +51,5 @@ onPassword: undefined,

const pages = shallowRef(0)
const info = shallowRef<UsePDFInfo | {}>({})
const info = shallowRef<PDFInfo | {}>({})
function processLoadingTask(source: UsePDFSrc) {
function processLoadingTask(source: PDFSrc) {
const loadingTask = PDFJS.getDocument(source)

@@ -76,2 +77,3 @@ if (options.onProgress)

const javascript = await doc.getJavaScript()
const outline = await doc.getOutline()

@@ -82,2 +84,3 @@ info.value = {

javascript,
outline,
}

@@ -93,8 +96,33 @@ },

async function getPDFDestination(destination: string | any[] | null): Promise<PDFDestination | null> {
const document = await pdf.value?.promise
if (!document)
return null
const destArray = await getDestinationArray(document, destination)
const destRef = await getDestinationRef(document, destArray)
if (!destRef || !destArray)
return null
const pageIndex = await document.getPageIndex(destRef)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const name = destArray[1].name
const rest = destArray.slice(2)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const location = isSpecLike(rest) ? getLocation(name, rest) : null
return { pageIndex, location: location ?? { type: 'Fit', spec: [] } }
}
if (isRef(src)) {
processLoadingTask(src.value)
watch(src, () => processLoadingTask(src.value))
if (src.value !== undefined)
processLoadingTask(src.value)
watch(src, () => {
if (src.value !== undefined)
processLoadingTask(src.value)
})
}
else {
processLoadingTask(src)
if (src !== undefined)
processLoadingTask(src)
}

@@ -106,3 +134,4 @@

info,
getPDFDestination,
}
}

@@ -11,3 +11,2 @@ import type { Plugin } from 'vue'

export * from './components'
export default VuePDFPlugin

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc