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

@tato30/vue-pdf

Package Overview
Dependencies
Maintainers
0
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.10.0 to 1.11.0

src/global.d.ts

2

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

@@ -15,3 +15,3 @@ import type { AnnotationEventPayload } from '../types';

annotationLoaded: (payload: any[]) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api").PDFPageProxy | undefined;

@@ -18,0 +18,0 @@ viewport?: import("pdfjs-dist/types/src/display/display_utils").PageViewport | undefined;

@@ -10,3 +10,3 @@ import type { HighlightEventPayload, HighlightOptions, TextLayerLoadedEventPayload } from '../types';

textLoaded: (payload: TextLayerLoadedEventPayload) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api").PDFPageProxy | undefined;

@@ -13,0 +13,0 @@ viewport?: import("pdfjs-dist/types/src/display/display_utils").PageViewport | undefined;

@@ -7,3 +7,3 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{

xfaLoaded: () => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
page?: import("pdfjs-dist/types/src/display/api").PDFPageProxy | undefined;

@@ -10,0 +10,0 @@ document?: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;

@@ -5,2 +5,2 @@ import type { PDFDocumentProxy } from 'pdfjs-dist';

declare function annotationEventsHandler(evt: Event, PDFDoc: PDFDocumentProxy, Annotations: Object[]): AnnotationEventPayload | Promise<AnnotationEventPayload | undefined> | undefined;
export { EVENTS_TO_HANDLER, annotationEventsHandler, };
export { annotationEventsHandler, EVENTS_TO_HANDLER };

@@ -11,2 +11,2 @@ /**

declare const isSpecLike: (list: any[]) => list is number[];
export { getDestinationArray, getDestinationRef, getLocation, isSpecLike };
export { getDestinationArray, getDestinationRef, getLocation, isSpecLike, };

@@ -38,3 +38,3 @@ import 'pdfjs-dist/web/pdf_viewer.css';

xfaLoaded: () => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
pdf?: import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined;

@@ -91,2 +91,5 @@ page?: number | undefined;

};
type __VLS_Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type __VLS_WithTemplateSlots<T, S> = T & {

@@ -97,4 +100,1 @@ new (): {

};
type __VLS_Prettify<T> = {
[K in keyof T]: T[K];
} & {};
{
"name": "@tato30/vue-pdf",
"version": "1.10.0",
"version": "1.11.0",
"description": "PDF component for Vue 3",

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

".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/index.umd.js",
"import": "./dist/index.mjs",
"types": "./dist/types/index.d.ts"
"import": "./dist/index.mjs"
},

@@ -41,11 +41,7 @@ "./style.css": "./dist/style.css",

"scripts": {
"dev": "vite --force --config vite.playground.ts",
"build": "npm run tests && npm run build:lib && npm run build:dts",
"build": "npm run build:lib && npm run build:dts",
"build:lib": "vite build",
"build:dts": "vue-tsc --declaration --emitDeclarationOnly -p tsconfig.build.json",
"preview": "vite preview --port 5050",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "vitest run",
"tests": "npm run test"
"lint:fix": "eslint --fix ."
},

@@ -56,21 +52,12 @@ "peerDependencies": {

"dependencies": {
"pdfjs-dist": "4.2.67"
"pdfjs-dist": "^4.5.136"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.5",
"@babel/core": "^7.21.8",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/node": "^18.16.3",
"@vitejs/plugin-vue": "^4.2.1",
"@vitest/browser": "^1.0.4",
"@vue/eslint-config-prettier": "^7.1.0",
"@vue/test-utils": "^2.4.3",
"eslint": "^8.39.0",
"typescript": "^4.9.4",
"vite": "^4.3.4",
"vitest": "^1.0.4",
"vue": "^3.2.47",
"vue-tsc": "^1.6.3",
"webdriverio": "^8.26.2"
"vue-tsc": "^1.6.3"
}
}

@@ -109,6 +109,6 @@ import * as PDFJS from 'pdfjs-dist'

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

@@ -115,0 +115,0 @@

@@ -0,1 +1,2 @@

/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

@@ -102,17 +103,45 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */

if (annotation.dest) {
// Get referenced page number of internal link
if (typeof annotation.dest === 'string') {
let explicitDest
if (typeof annotation.dest === 'string')
explicitDest = await PDFDoc.getDestination(annotation.dest)
else
explicitDest = annotation.dest
if (!Array.isArray(explicitDest)) {
console.warn(`Destination "${explicitDest}" is not a valid destination (dest="${annotation.dest}")`)
return buildAnnotationData(INTERNAL_LINK, {
referencedPage: Number(annotation.dest.substring(1, annotation.dest.length)),
referencedPage: null,
offset: null,
})
}
let offset = null
if (explicitDest.length === 5) {
offset = {
left: annotation.dest[2],
bottom: annotation.dest[3],
}
}
const [destRef] = explicitDest
if (Number.isInteger(destRef)) {
return buildAnnotationData(INTERNAL_LINK, {
referencedPage: Number(destRef) + 1,
offset,
})
}
else if (typeof destRef === 'object') {
const pageNumber = await PDFDoc.getPageIndex(destRef as RefProxy)
return buildAnnotationData(INTERNAL_LINK, {
referencedPage: pageNumber + 1,
offset,
})
}
else {
const pageIndex = await PDFDoc.getPageIndex(annotation.dest[0] as RefProxy)
console.warn(
`Destination "${destRef}" is not a valid destination (dest="${annotation.dest}")`,
)
return buildAnnotationData(INTERNAL_LINK, {
referencedPage: pageIndex + 1,
offset: {
left: annotation.dest[2],
bottom: annotation.dest[3],
},
referencedPage: null,
offset: null,
})

@@ -212,4 +241,3 @@ }

export {
EVENTS_TO_HANDLER,
annotationEventsHandler,
annotationEventsHandler, EVENTS_TO_HANDLER
}

@@ -64,4 +64,3 @@ /**

getLocation,
isSpecLike
isSpecLike,
}

@@ -8,5 +8,15 @@ import type { TextItem } from 'pdfjs-dist/types/src/display/api'

for (const textItem of textContent.items as TextItem[]) {
strs.push(textItem.str)
if (textItem.hasEOL)
strs.push('\n')
if (textItem.hasEOL) {
// Remove the break line hyphen in the middle of the sentence
if (textItem.str.endsWith('-')) {
const lastHyphen = textItem.str.lastIndexOf('-')
strs.push(textItem.str.substring(0, lastHyphen))
}
else {
strs.push(textItem.str, '\n')
}
}
else {
strs.push(textItem.str)
}
}

@@ -38,2 +48,15 @@

function convertMatches(matches: (number | string)[][], textContent: TextContent): Match[] {
function endOfLineOffset(item: TextItem) {
// When textitem has a EOL flag and the string has a hyphen at the end
// the hyphen should be removed (-1 len) so the sentence could be searched as a joined one.
// In other cases the EOL flag introduce a whitespace (+1 len) between two different sentences
if (item.hasEOL) {
if (item.str.endsWith('-'))
return -1
else
return 1
}
return 0
}
let index = 0

@@ -51,3 +74,4 @@ let tindex = 0

while (index !== end && mindex >= tindex + textItems[index].str.length) {
tindex += textItems[index].str.length + (textItems[index].hasEOL ? 1 : 0)
const item = textItems[index]
tindex += item.str.length + endOfLineOffset(item)
index++

@@ -64,3 +88,4 @@ }

while (index !== end && mindex > tindex + textItems[index].str.length) {
tindex += textItems[index].str.length + (textItems[index].hasEOL ? 1 : 0)
const item = textItems[index]
tindex += item.str.length + endOfLineOffset(item)
index++

@@ -67,0 +92,0 @@ }

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