@vue-pdf-viewer/viewer 0.0.0-experimental.90 → 0.0.0-experimental.92
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 +6 -2
- package/dist/{VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-CBjI861h.cjs → VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-BScYhDOi.cjs} +3 -3
- package/dist/{VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-Bsn-KClx.js → VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-wcaN6GfP.js} +3 -3
- package/dist/{index-DXV6cA9-.cjs → index-CzHTo4cp.cjs} +1 -1
- package/dist/{index-84NmTkW4.js → index-rgeR2HXX.js} +1 -1
- package/dist/index.cjs +20 -20
- package/dist/index.js +14244 -14105
- package/dist/license.cjs +1 -1
- package/dist/license.js +1 -1
- package/dist/types/composables/usePdf.d.ts +1 -0
- package/dist/types/composables/usePdfActualPages.d.ts +7 -0
- package/dist/types/utils/boundedConcurrency.d.ts +15 -0
- package/dist/types/utils/documentLayout.d.ts +27 -0
- package/dist/types/utils/searchHighlight.d.ts +1 -3
- package/dist/types/utils/types.d.ts +11 -3
- package/dist/types/utils/workerUrl.d.ts +21 -0
- package/package.json +7 -5
- package/dist/types/components/LayerTextSearchHighlight.vue.d.ts +0 -19
- /package/dist/{lib/assets → assets}/pdf-legacy/pdf.worker.min.mjs +0 -0
- /package/dist/{lib/assets → assets}/pdf.worker.min.mjs +0 -0
package/dist/license.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-BScYhDOi.cjs");exports.LicenseProduct=e.P;exports.LicenseType=e.Q;exports.useLicense=e.b3;
|
package/dist/license.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as c, Q as a, b3 as i } from "./VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-
|
|
1
|
+
import { P as c, Q as a, b3 as i } from "./VPdfViewer.vue_vue_type_style_index_1_scoped_fca1b787_lang-wcaN6GfP.js";
|
|
2
2
|
export {
|
|
3
3
|
c as LicenseProduct,
|
|
4
4
|
a as LicenseType,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MaybeRef } from 'vue';
|
|
2
2
|
import { type PDFOptions, type PDFSrc, type PDFDocumentOptions } from '../utils/types';
|
|
3
3
|
import { type PDFDocumentProxy, type PDFPageProxy } from 'pdfjs-dist/types/src/display/api';
|
|
4
|
+
export declare function configWorker(workerSrc?: string, legacy?: boolean): void;
|
|
4
5
|
declare function usePdf(src: MaybeRef<PDFSrc>, options?: PDFOptions, workerUrl?: string, documentOptions?: PDFDocumentOptions, wasmUrl?: string): {
|
|
5
6
|
pdfDocLoadingTask: import("vue").ShallowRef<import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined, import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined>;
|
|
6
7
|
getPage: (doc: PDFDocumentProxy, pageIndex: number) => Promise<PDFPageProxy>;
|
|
@@ -8,6 +8,13 @@ import { PDFSrc, ViewerPdfPage, ViewerState } from '@/utils/types';
|
|
|
8
8
|
* estimating would add a correction pass for no gain.
|
|
9
9
|
*/
|
|
10
10
|
export declare function isLazyLoadingEligible(source: PDFSrc | undefined): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Normalizes rotation to be a valid multiple of 90 degrees between 0-360.
|
|
13
|
+
*
|
|
14
|
+
* @param rotation - Rotation angle in degrees
|
|
15
|
+
* @returns Normalized rotation (0, 90, 180, or 270), or 0 if invalid
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeRotation(rotation: number): number;
|
|
11
18
|
/**
|
|
12
19
|
* Composable for managing PDF pages at base scale (100%).
|
|
13
20
|
*
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `task` over `items` with at most `limit` tasks in flight, starting them in item order.
|
|
3
|
+
*
|
|
4
|
+
* Exists for background work against the pdf.js worker. pdf.js answers requests in the order
|
|
5
|
+
* they arrive and caches page promises, so a request issued early cannot be overtaken later.
|
|
6
|
+
* Issuing a whole document's worth at once therefore puts anything the reader asks for next —
|
|
7
|
+
* the page they navigated to, the page being rendered — behind all of it. Keeping only a few
|
|
8
|
+
* in flight bounds that wait to `limit` requests.
|
|
9
|
+
*
|
|
10
|
+
* Results come back in item order. A task that rejects rejects the whole run, like
|
|
11
|
+
* `Promise.all`, and no further tasks start — otherwise the remaining lanes would keep the
|
|
12
|
+
* worker busy with results nobody reads. Once `shouldStop` returns true no further tasks
|
|
13
|
+
* start either; the ones already running finish, and the skipped slots are left `undefined`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, task: (item: T, index: number) => Promise<R>, shouldStop?: () => boolean): Promise<Array<R | undefined>>;
|
|
@@ -44,3 +44,30 @@ export declare function captureLayoutAnchor(totals: number[], position: number,
|
|
|
44
44
|
* Returns null when there is no layout to resolve against.
|
|
45
45
|
*/
|
|
46
46
|
export declare function resolveLayoutAnchor(totals: number[], anchor: LayoutAnchor, scale: number): number | null;
|
|
47
|
+
/** Minimum a page contributes to wrapped packing: its size at base scale. */
|
|
48
|
+
export interface WrappedPageSize {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
}
|
|
52
|
+
/** Rows produced by wrapping pages across a container of a given width. */
|
|
53
|
+
export interface WrappedRows {
|
|
54
|
+
/** Height of each row: the tallest page in it, at the given scale. */
|
|
55
|
+
rowHeights: number[];
|
|
56
|
+
/** Accumulated width of each row at the given scale. */
|
|
57
|
+
rowWidths: number[];
|
|
58
|
+
/** Row index each page sits in, by page index. */
|
|
59
|
+
rowOfPage: number[];
|
|
60
|
+
/** First page index of each row, by row index. */
|
|
61
|
+
rowStartPage: number[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Packs pages into rows the way the wrapped scroll mode lays them out.
|
|
65
|
+
*
|
|
66
|
+
* Rows are filled until the next page would overflow `clientWidth`, so a row holds as many
|
|
67
|
+
* pages as happen to fit — one for a wide page, several for narrow ones. The page-to-row
|
|
68
|
+
* mapping is therefore recorded here rather than derived later from an average page count
|
|
69
|
+
* per row, which is only correct when every page has the same width.
|
|
70
|
+
*/
|
|
71
|
+
export declare function packWrappedRows(pages: WrappedPageSize[], clientWidth: number, scale: number): WrappedRows;
|
|
72
|
+
/** Page index one past the last page of `row`. */
|
|
73
|
+
export declare function getRowEndPage(rowStartPage: number[], row: number, totalPages: number): number;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { CSSProperties } from 'vue';
|
|
2
|
-
import type { FlagKeyword, HighlightArea,
|
|
2
|
+
import type { FlagKeyword, HighlightArea, NormalizedKeyword, SingleKeyword } from './types';
|
|
3
3
|
export declare const normalizeFlagKeyword: (flagKeyword: FlagKeyword) => NormalizedKeyword;
|
|
4
4
|
export declare const normalizeSingleKeyword: (keyword: SingleKeyword, matchCase?: boolean, wholeWords?: boolean) => NormalizedKeyword;
|
|
5
5
|
export declare const sortHighlightPosition: (a: HighlightArea, b: HighlightArea) => 0 | 1 | -1;
|
|
6
6
|
export declare const getHighlightStyle: (area: HighlightArea) => CSSProperties;
|
|
7
7
|
export declare const unwrap: (ele: Node) => void;
|
|
8
|
-
export declare const getHighlightElement: (layerRef: HTMLElement, query: HighlightMatchPosition, selector?: string) => HTMLElement;
|
|
9
8
|
export declare const getHighlightElements: (layerRef: HTMLElement, querySelector: string) => Promise<NodeListOf<Element>>;
|
|
10
|
-
export declare function scrollHighlightIntoView(highlightEle: HTMLElement, pageContainer: HTMLElement, viewerContainer: HTMLElement): void;
|
|
@@ -235,7 +235,10 @@ export interface ViewerPdfPage {
|
|
|
235
235
|
width: number;
|
|
236
236
|
/** True until the real page has been fetched and dimensions corrected. */
|
|
237
237
|
isEstimated: boolean;
|
|
238
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Inherent page rotation (0/90/180/270). Estimated entries carry page 1's rotate, the
|
|
240
|
+
* value baked into their cloned viewport, until the real page arrives.
|
|
241
|
+
*/
|
|
239
242
|
pdfPageRotate: number;
|
|
240
243
|
}
|
|
241
244
|
export interface ItemMeasurement {
|
|
@@ -386,8 +389,11 @@ export interface TextHighlight {
|
|
|
386
389
|
export interface VPdfViewerProps {
|
|
387
390
|
src: MaybeRef<VPVSrc>;
|
|
388
391
|
/**
|
|
389
|
-
* The
|
|
390
|
-
* If unspecified, the viewer
|
|
392
|
+
* The URL of the PDF.js worker.
|
|
393
|
+
* If unspecified, the viewer uses the worker shipped in `@vue-pdf-viewer/viewer/assets/`
|
|
394
|
+
* (same version as the bundled `pdfjs-dist`), loaded as a real file so a CSP of
|
|
395
|
+
* `script-src 'self'` is sufficient. Setting this disables the automatic legacy-worker
|
|
396
|
+
* fallback for browsers without `Promise.withResolvers`.
|
|
391
397
|
*/
|
|
392
398
|
workerUrl?: string;
|
|
393
399
|
/**
|
|
@@ -461,6 +467,8 @@ export interface VPdfViewerProps {
|
|
|
461
467
|
/**
|
|
462
468
|
* A callback function that will be executed after each canvas is loaded.
|
|
463
469
|
* The key is the page number, and the value is the callback function.
|
|
470
|
+
* During print the callback receives a single scratch canvas that is reused for the next
|
|
471
|
+
* page, so draw synchronously and do not retain it.
|
|
464
472
|
*/
|
|
465
473
|
afterCanvasLoaded?: Record<number, CanvasLoadedCallback>;
|
|
466
474
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure resolution of the PDF.js worker URL. No DOM, no PDF.js, no Vue — see
|
|
3
|
+
* specs/004-csp-safe-pdf-worker/contracts/worker-url-resolution.md.
|
|
4
|
+
*/
|
|
5
|
+
export interface WorkerUrlInputs {
|
|
6
|
+
/** `workerUrl` prop. An empty string counts as absent. */
|
|
7
|
+
explicitUrl?: string;
|
|
8
|
+
/** `VPV:pdfLegacyWorker` session flag. */
|
|
9
|
+
legacy: boolean;
|
|
10
|
+
/** Default export of `virtual:vpv-pdf-worker-url`. */
|
|
11
|
+
bundledUrl: string;
|
|
12
|
+
/** Default export of `virtual:vpv-pdf-worker-legacy-url`. */
|
|
13
|
+
bundledLegacyUrl: string;
|
|
14
|
+
}
|
|
15
|
+
export interface WorkerUrlResult {
|
|
16
|
+
url: string;
|
|
17
|
+
/** True when the Vite/Nuxt dependency pre-bundle rewrite was applied. */
|
|
18
|
+
rewritten: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function rewritePrebundledUrl(url: string): string;
|
|
21
|
+
export declare function resolveWorkerUrl(inputs: WorkerUrlInputs): WorkerUrlResult;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-pdf-viewer/viewer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.0-experimental.
|
|
4
|
+
"version": "0.0.0-experimental.92",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"require": "./dist/license.cjs",
|
|
44
44
|
"types": "./dist/types/license.d.ts"
|
|
45
45
|
},
|
|
46
|
-
"./assets": "./dist/assets"
|
|
46
|
+
"./assets": "./dist/assets",
|
|
47
|
+
"./assets/*": "./dist/assets/*"
|
|
47
48
|
},
|
|
48
49
|
"style": "./dist/style/index.css",
|
|
49
50
|
"types": "./dist/types/index.d.ts",
|
|
@@ -57,10 +58,12 @@
|
|
|
57
58
|
"format": "prettier --write .",
|
|
58
59
|
"prebuild": "vitest run",
|
|
59
60
|
"postbuild": "vue-tsc --declaration --emitDeclarationOnly -p tsconfig.build.json",
|
|
60
|
-
"build": "vite build",
|
|
61
|
+
"build": "vite build && bun run verify:dist",
|
|
62
|
+
"verify:dist": "node scripts/verify-dist.mjs",
|
|
63
|
+
"typecheck:build": "tsc --noEmit -p tsconfig.node.json",
|
|
61
64
|
"preview": "vite preview",
|
|
62
65
|
"test": "vitest",
|
|
63
|
-
"prepublishOnly": "bun run vite build && bun run postbuild",
|
|
66
|
+
"prepublishOnly": "bun run vite build && bun run verify:dist && bun run postbuild",
|
|
64
67
|
"shadcn:add": "bunx shadcn-vue@latest add",
|
|
65
68
|
"prepare": "husky"
|
|
66
69
|
},
|
|
@@ -115,7 +118,6 @@
|
|
|
115
118
|
"unocss-preset-shadcn": "^0.3.1",
|
|
116
119
|
"vite": "^5.2.8",
|
|
117
120
|
"vite-plugin-node-polyfills": "^0.21.0",
|
|
118
|
-
"vite-plugin-static-copy": "^3.1.2",
|
|
119
121
|
"vite-svg-loader": "^5.1.0",
|
|
120
122
|
"vitest": "^3.2.4",
|
|
121
123
|
"vitest-browser-vue": "^1.1.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PageViewport } from 'pdfjs-dist';
|
|
2
|
-
import type { TextContent } from 'pdfjs-dist/types/src/display/text_layer';
|
|
3
|
-
interface OwnProps {
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
viewport: PageViewport;
|
|
6
|
-
textContent: TextContent;
|
|
7
|
-
searchKeyword?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<OwnProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<OwnProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
10
|
-
export default _default;
|
|
11
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
13
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
-
} : {
|
|
16
|
-
type: import('vue').PropType<T[K]>;
|
|
17
|
-
required: true;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
File without changes
|
|
File without changes
|