@tato30/vue-pdf
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3838390
6
16828
31
1
0
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcanvas@3.0.0-rc2(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedini@1.3.8(transitive)
+ Addedmagic-string@0.30.12(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@3.71.0(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedpdfjs-dist@4.8.69(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
- Removed@mapbox/node-pre-gyp@1.0.11(transitive)
- Removedabbrev@1.1.1(transitive)
- Removedagent-base@6.0.2(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedaproba@2.0.0(transitive)
- Removedare-we-there-yet@2.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcanvas@2.11.2(transitive)
- Removedchownr@2.0.0(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddelegates@1.0.0(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedfs-minipass@2.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedgauge@3.0.2(transitive)
- Removedglob@7.2.3(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedhttps-proxy-agent@5.0.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedmagic-string@0.30.13(transitive)
- Removedmake-dir@3.1.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminipass@3.3.65.0.0(transitive)
- Removedminizlib@2.1.2(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedms@2.1.3(transitive)
- Removednan@2.22.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednopt@5.0.0(transitive)
- Removednpmlog@5.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpdfjs-dist@4.2.67(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedsemver@6.3.1(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedtar@6.2.1(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwide-align@1.1.5(transitive)
- Removedyallist@4.0.0(transitive)
Updatedpdfjs-dist@^4.5.136